@office-iss/react-native-win32 0.71.4 → 0.72.0-preview.1

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 (323) hide show
  1. package/.flowconfig +15 -3
  2. package/CHANGELOG.json +310 -40
  3. package/CHANGELOG.md +145 -23
  4. package/IntegrationTests/IntegrationTestHarnessTest.js +1 -0
  5. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +1 -1
  6. package/Libraries/Alert/Alert.d.ts +4 -4
  7. package/Libraries/Alert/Alert.win32.js +1 -0
  8. package/Libraries/Animated/Animated.d.ts +17 -6
  9. package/Libraries/Animated/NativeAnimatedHelper.js +18 -6
  10. package/Libraries/Animated/NativeAnimatedHelper.win32.js +606 -0
  11. package/Libraries/Animated/bezier.js +1 -1
  12. package/Libraries/Animated/components/AnimatedFlatList.js +8 -3
  13. package/Libraries/Animated/components/AnimatedScrollView.js +4 -1
  14. package/Libraries/Animated/components/AnimatedSectionList.js +12 -3
  15. package/Libraries/Animated/createAnimatedComponent.js +26 -239
  16. package/Libraries/Animated/nodes/AnimatedColor.js +47 -80
  17. package/Libraries/Animated/nodes/AnimatedInterpolation.js +167 -121
  18. package/Libraries/Animated/nodes/AnimatedNode.js +3 -5
  19. package/Libraries/Animated/nodes/AnimatedProps.js +7 -6
  20. package/Libraries/Animated/nodes/AnimatedStyle.js +42 -8
  21. package/Libraries/Animated/nodes/AnimatedTransform.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedValue.js +8 -12
  23. package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -1
  24. package/Libraries/Animated/useAnimatedProps.js +7 -10
  25. package/Libraries/BatchedBridge/MessageQueue.js +2 -1
  26. package/Libraries/BatchedBridge/NativeModules.d.ts +1 -1
  27. package/Libraries/BatchedBridge/NativeModules.js +1 -0
  28. package/Libraries/Blob/Blob.js +4 -0
  29. package/Libraries/Blob/FileReader.js +30 -2
  30. package/Libraries/Blob/URL.js +3 -1
  31. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +2 -2
  32. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -3
  33. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -3
  34. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +6 -4
  35. package/Libraries/Components/Button.js +3 -2
  36. package/Libraries/Components/Button.win32.js +451 -0
  37. package/Libraries/Components/Clipboard/Clipboard.js +1 -1
  38. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -0
  39. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -0
  40. package/Libraries/Components/Pressable/Pressable.d.ts +1 -1
  41. package/Libraries/Components/Pressable/Pressable.js +1 -1
  42. package/Libraries/Components/RefreshControl/RefreshControl.js +1 -0
  43. package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -2
  44. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -2
  45. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +12 -6
  46. package/Libraries/Components/ScrollView/ScrollView.d.ts +2 -2
  47. package/Libraries/Components/ScrollView/ScrollView.js +149 -91
  48. package/Libraries/Components/ScrollView/ScrollView.win32.js +1939 -0
  49. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -6
  50. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +5 -7
  51. package/Libraries/Components/ScrollView/ScrollViewViewConfig.js +1 -1
  52. package/Libraries/Components/StatusBar/StatusBar.js +3 -0
  53. package/Libraries/Components/Switch/Switch.js +3 -1
  54. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +21 -11
  55. package/Libraries/Components/TextInput/InputAccessoryView.d.ts +1 -1
  56. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +11 -5
  57. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +51 -0
  58. package/Libraries/Components/TextInput/TextInput.Types.win32.js +3 -0
  59. package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +1 -0
  60. package/Libraries/Components/TextInput/TextInput.d.ts +15 -5
  61. package/Libraries/Components/TextInput/TextInput.flow.js +1 -1
  62. package/Libraries/Components/TextInput/TextInput.js +130 -103
  63. package/Libraries/Components/TextInput/TextInput.win32.js +202 -890
  64. package/Libraries/Components/Touchable/Touchable.d.ts +1 -1
  65. package/Libraries/Components/Touchable/Touchable.flow.js +30 -4
  66. package/Libraries/Components/Touchable/Touchable.js +6 -3
  67. package/Libraries/Components/Touchable/Touchable.win32.js +6 -3
  68. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  69. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +2 -2
  70. package/Libraries/Components/Touchable/TouchableOpacity.js +3 -0
  71. package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +1 -1
  72. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
  73. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +189 -0
  74. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlayNativeComponent.js +43 -0
  75. package/Libraries/Components/View/ReactNativeStyleAttributes.js +26 -0
  76. package/Libraries/Components/View/View.js +71 -45
  77. package/Libraries/Components/View/View.win32.js +38 -16
  78. package/Libraries/Components/View/ViewAccessibility.d.ts +6 -6
  79. package/Libraries/Components/View/ViewAccessibility.js +10 -1
  80. package/Libraries/Components/View/ViewAccessibility.win32.d.ts +5 -5
  81. package/Libraries/Components/View/ViewNativeComponent.js +32 -8
  82. package/Libraries/Components/View/ViewPropTypes.d.ts +1 -1
  83. package/Libraries/Components/View/ViewPropTypes.js +1 -1
  84. package/Libraries/Components/View/ViewPropTypes.win32.d.ts +1 -1
  85. package/Libraries/Components/View/ViewPropTypes.win32.js +1 -1
  86. package/Libraries/Core/Devtools/openFileInEditor.js +1 -0
  87. package/Libraries/Core/Devtools/openURLInBrowser.js +1 -0
  88. package/Libraries/Core/Devtools/parseErrorStack.js +2 -2
  89. package/Libraries/Core/Devtools/parseHermesStack.js +54 -34
  90. package/Libraries/Core/ExceptionsManager.js +2 -2
  91. package/Libraries/Core/InitializeCore.js +2 -1
  92. package/Libraries/Core/ReactNativeVersion.js +3 -3
  93. package/Libraries/Core/ReactNativeVersionCheck.js +1 -9
  94. package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -9
  95. package/Libraries/Core/Timers/JSTimers.js +1 -1
  96. package/Libraries/Core/Timers/immediateShim.js +1 -0
  97. package/Libraries/Core/Timers/queueMicrotask.js +1 -1
  98. package/Libraries/Core/setUpAlert.js +1 -1
  99. package/Libraries/Core/setUpDOM.js +18 -0
  100. package/Libraries/Core/setUpDeveloperTools.js +1 -1
  101. package/Libraries/Core/setUpGlobals.js +5 -2
  102. package/Libraries/Core/setUpNavigator.js +6 -5
  103. package/Libraries/Core/setUpPerformance.js +23 -13
  104. package/Libraries/Core/setUpReactDevTools.js +2 -0
  105. package/Libraries/Core/setUpSegmentFetcher.js +0 -41
  106. package/Libraries/Core/setUpTimers.js +2 -2
  107. package/Libraries/DOM/Geometry/DOMRect.js +82 -0
  108. package/Libraries/DOM/Geometry/DOMRectReadOnly.js +188 -0
  109. package/Libraries/DOM/Nodes/ReactNativeElement.js +75 -0
  110. package/Libraries/DOM/Nodes/ReadOnlyElement.js +89 -0
  111. package/Libraries/DOM/Nodes/ReadOnlyNode.js +167 -0
  112. package/Libraries/DOM/OldStyleCollections/ArrayLikeUtils.js +46 -0
  113. package/Libraries/DOM/OldStyleCollections/DOMRectList.js +76 -0
  114. package/Libraries/DOM/OldStyleCollections/HTMLCollection.js +82 -0
  115. package/Libraries/DOM/OldStyleCollections/NodeList.js +104 -0
  116. package/Libraries/DevToolsSettings/DevToolsSettingsManager.android.js +35 -0
  117. package/Libraries/DevToolsSettings/DevToolsSettingsManager.d.ts +20 -0
  118. package/Libraries/DevToolsSettings/DevToolsSettingsManager.ios.js +49 -0
  119. package/Libraries/DevToolsSettings/DevToolsSettingsManager.win32.js +35 -0
  120. package/Libraries/{Utilities/NativeDevSplitBundleLoader.js → DevToolsSettings/NativeDevToolsSettingsManager.js} +7 -2
  121. package/Libraries/EventEmitter/NativeEventEmitter.d.ts +1 -2
  122. package/Libraries/EventEmitter/RCTDeviceEventEmitter.d.ts +1 -2
  123. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +9 -1
  124. package/Libraries/Events/EventPolyfill.js +1 -1
  125. package/Libraries/Image/AssetRegistry.js +1 -1
  126. package/Libraries/Image/AssetSourceResolver.js +3 -3
  127. package/Libraries/Image/Image.android.js +4 -1
  128. package/Libraries/Image/Image.d.ts +63 -2
  129. package/Libraries/Image/Image.ios.js +3 -0
  130. package/Libraries/Image/Image.win32.js +3 -0
  131. package/Libraries/Image/ImageBackground.js +1 -0
  132. package/Libraries/Image/ImageProps.js +1 -1
  133. package/Libraries/Image/ImageViewNativeComponent.js +4 -4
  134. package/Libraries/Image/RelativeImageStub.js +1 -1
  135. package/Libraries/Image/TextInlineImageNativeComponent.js +1 -1
  136. package/Libraries/Image/resolveAssetSource.js +1 -1
  137. package/Libraries/Inspector/DevtoolsOverlay.js +29 -19
  138. package/Libraries/Inspector/ElementBox.js +4 -1
  139. package/Libraries/Inspector/Inspector.js +5 -6
  140. package/Libraries/Inspector/Inspector.win32.js +7 -6
  141. package/Libraries/Inspector/InspectorOverlay.js +3 -3
  142. package/Libraries/Inspector/InspectorOverlay.win32.js +2 -1
  143. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  144. package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -1
  145. package/Libraries/Interaction/PanResponder.js +5 -6
  146. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -1
  147. package/Libraries/Linking/Linking.js +1 -4
  148. package/Libraries/Lists/FillRateHelper.js +4 -238
  149. package/Libraries/Lists/FlatList.d.ts +15 -22
  150. package/Libraries/Lists/FlatList.js +9 -6
  151. package/Libraries/Lists/SectionList.d.ts +10 -6
  152. package/Libraries/Lists/SectionList.js +5 -3
  153. package/Libraries/Lists/SectionListModern.js +3 -3
  154. package/Libraries/Lists/ViewabilityHelper.js +8 -344
  155. package/Libraries/Lists/VirtualizeUtils.js +4 -244
  156. package/Libraries/Lists/VirtualizedList.js +10 -1867
  157. package/Libraries/Lists/VirtualizedListContext.js +6 -104
  158. package/Libraries/Lists/VirtualizedSectionList.js +9 -602
  159. package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +1 -0
  160. package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
  161. package/Libraries/LogBox/Data/LogBoxData.js +1 -1
  162. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  163. package/Libraries/LogBox/LogBox.js +1 -1
  164. package/Libraries/LogBox/UI/LogBoxInspector.js +1 -3
  165. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +168 -0
  166. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +3 -0
  167. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +193 -0
  168. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -0
  169. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +2 -2
  170. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +7 -3
  171. package/Libraries/LogBox/UI/LogBoxMessage.js +87 -5
  172. package/Libraries/LogBox/UI/LogBoxNotification.js +5 -7
  173. package/Libraries/Modal/Modal.js +2 -2
  174. package/Libraries/NativeComponent/BaseViewConfig.android.js +32 -12
  175. package/Libraries/NativeComponent/BaseViewConfig.ios.js +43 -19
  176. package/Libraries/NativeComponent/BaseViewConfig.win32.js +43 -19
  177. package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +4 -1
  178. package/Libraries/NativeComponent/ViewConfig.js +1 -0
  179. package/Libraries/NativeComponent/ViewConfigIgnore.js +1 -4
  180. package/Libraries/Network/RCTNetworking.android.js +2 -2
  181. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  182. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  183. package/Libraries/Network/XMLHttpRequest.js +1 -1
  184. package/Libraries/Pressability/Pressability.js +11 -5
  185. package/Libraries/Pressability/Pressability.win32.js +9 -3
  186. package/Libraries/ReactNative/AppContainer.js +7 -1
  187. package/Libraries/ReactNative/AppRegistry.d.ts +1 -1
  188. package/Libraries/ReactNative/AppRegistry.js +10 -13
  189. package/Libraries/ReactNative/FabricUIManager.js +24 -8
  190. package/Libraries/ReactNative/NativeUIManager.js +5 -5
  191. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +10 -10
  192. package/Libraries/ReactNative/UIManager.js +142 -1
  193. package/Libraries/ReactNative/getCachedComponentWithDebugName.js +5 -5
  194. package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -1
  195. package/Libraries/ReactNative/requireNativeComponent.d.ts +1 -1
  196. package/Libraries/ReactNative/requireNativeComponent.js +1 -1
  197. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -0
  198. package/Libraries/Renderer/implementations/ReactFabric-dev.js +26 -3
  199. package/Libraries/Renderer/implementations/ReactFabric-prod.js +13 -1
  200. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +13 -1
  201. package/Libraries/Renderer/public/ReactFabricPublicInstanceUtils.js +38 -0
  202. package/Libraries/Renderer/shims/ReactNativeTypes.js +38 -20
  203. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +7 -7
  204. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
  205. package/Libraries/Share/Share.js +1 -1
  206. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
  207. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  208. package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
  209. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +115 -76
  210. package/Libraries/StyleSheet/StyleSheetTypes.js +188 -33
  211. package/Libraries/StyleSheet/flattenStyle.js +2 -0
  212. package/Libraries/StyleSheet/normalizeColor.js +1 -1
  213. package/Libraries/StyleSheet/processColor.js +1 -1
  214. package/Libraries/Text/Text.d.ts +12 -2
  215. package/Libraries/Text/Text.js +50 -41
  216. package/Libraries/Text/TextProps.js +3 -4
  217. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
  218. package/Libraries/Types/CodegenTypes.js +1 -0
  219. package/Libraries/UTFSequence.js +3 -1
  220. package/Libraries/Utilities/Appearance.d.ts +10 -0
  221. package/Libraries/Utilities/Appearance.js +13 -0
  222. package/Libraries/Utilities/Dimensions.js +1 -1
  223. package/Libraries/Utilities/Dimensions.win32.js +1 -1
  224. package/Libraries/Utilities/GlobalPerformanceLogger.js +12 -1
  225. package/Libraries/Utilities/HMRClient.js +16 -10
  226. package/Libraries/Utilities/{createPerformanceLogger.d.ts → IPerformanceLogger.d.ts} +4 -4
  227. package/Libraries/Utilities/IPerformanceLogger.js +49 -0
  228. package/Libraries/Utilities/LoadingView.android.js +28 -11
  229. package/Libraries/Utilities/NativeAppearance.js +1 -0
  230. package/Libraries/Utilities/NativePlatformConstantsWin.js +1 -1
  231. package/Libraries/Utilities/PixelRatio.js +2 -2
  232. package/Libraries/Utilities/Platform.win32.js +1 -1
  233. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  234. package/Libraries/Utilities/__mocks__/PixelRatio.js +1 -1
  235. package/Libraries/Utilities/codegenNativeCommands.js +2 -0
  236. package/Libraries/Utilities/createPerformanceLogger.js +55 -43
  237. package/Libraries/Utilities/stringifySafe.js +2 -7
  238. package/Libraries/Utilities/useColorScheme.js +1 -1
  239. package/Libraries/Utilities/useWindowDimensions.js +3 -3
  240. package/Libraries/WebPerformance/EventCounts.js +78 -0
  241. package/Libraries/WebPerformance/MemoryInfo.js +54 -0
  242. package/Libraries/WebPerformance/NativePerformance.js +38 -0
  243. package/Libraries/WebPerformance/NativePerformanceObserver.js +22 -7
  244. package/Libraries/WebPerformance/Performance.js +312 -0
  245. package/Libraries/WebPerformance/PerformanceEntry.js +45 -0
  246. package/Libraries/WebPerformance/PerformanceEventTiming.js +38 -0
  247. package/Libraries/WebPerformance/PerformanceObserver.js +196 -101
  248. package/Libraries/WebPerformance/RawPerformanceEntry.js +87 -0
  249. package/Libraries/WebPerformance/ReactNativeStartupTiming.js +65 -0
  250. package/Libraries/WebPerformance/__mocks__/NativePerformance.js +65 -0
  251. package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +101 -0
  252. package/Libraries/YellowBox/YellowBoxDeprecated.js +1 -1
  253. package/Libraries/vendor/core/ErrorUtils.js +1 -1
  254. package/Libraries/vendor/emitter/EventEmitter.d.ts +2 -2
  255. package/Libraries/vendor/emitter/EventEmitter.js +9 -1
  256. package/flow/global.js +29 -4
  257. package/flow/jest.js +258 -164
  258. package/index.js +56 -42
  259. package/index.win32.js +56 -42
  260. package/interface.js +1 -1
  261. package/jest/local-setup.js +33 -0
  262. package/jest/mockComponent.js +4 -2
  263. package/jest/mockNativeComponent.js +1 -1
  264. package/jest/mockScrollView.js +2 -1
  265. package/jest/react-native-env.js +1 -3
  266. package/jest/setup.js +11 -8
  267. package/overrides.json +115 -85
  268. package/package.json +38 -28
  269. package/rn-get-polyfills.js +1 -1
  270. package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +68 -0
  271. package/src/Libraries/Components/View/ViewAccessibility.win32.d.ts +5 -5
  272. package/src/Libraries/Components/View/ViewPropTypes.win32.d.ts +1 -1
  273. package/types/index.d.ts +2 -6
  274. package/types/modules/Codegen.d.ts +4 -4
  275. package/types/modules/globals.d.ts +27 -25
  276. package/types/public/DeprecatedPropertiesAlias.d.ts +0 -20
  277. package/types/public/ReactNativeRenderer.d.ts +2 -7
  278. package/Libraries/Animated/createAnimatedComponentInjection.js +0 -48
  279. package/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js +0 -48
  280. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.flow.js +0 -208
  281. package/Libraries/Components/ActivityIndicator/ActivityIndicator.flow.js +0 -58
  282. package/Libraries/Components/DatePicker/DatePickerIOS.android.js +0 -47
  283. package/Libraries/Components/DatePicker/DatePickerIOS.d.ts +0 -92
  284. package/Libraries/Components/DatePicker/DatePickerIOS.flow.android.js +0 -14
  285. package/Libraries/Components/DatePicker/DatePickerIOS.flow.ios.js +0 -113
  286. package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +0 -242
  287. package/Libraries/Components/DatePicker/DatePickerIOS.win32.js +0 -47
  288. package/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js +0 -60
  289. package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +0 -26
  290. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +0 -45
  291. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.d.ts +0 -62
  292. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +0 -75
  293. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.win32.js +0 -45
  294. package/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js +0 -33
  295. package/Libraries/Components/SafeAreaView/SafeAreaView.flow.js +0 -19
  296. package/Libraries/Components/Slider/Slider.d.ts +0 -132
  297. package/Libraries/Components/Slider/Slider.js +0 -282
  298. package/Libraries/Components/Slider/SliderNativeComponent.js +0 -56
  299. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +0 -23
  300. package/Libraries/Interaction/Batchinator.js +0 -76
  301. package/Libraries/Interaction/BridgeSpyStallHandler.js +0 -63
  302. package/Libraries/Interaction/InteractionStallDebugger.js +0 -23
  303. package/Libraries/Interaction/PanResponder.flow.js +0 -257
  304. package/Libraries/Lists/CellRenderMask.js +0 -155
  305. package/Libraries/Lists/ChildListCollection.js +0 -72
  306. package/Libraries/Lists/StateSafePureComponent.js +0 -85
  307. package/Libraries/Lists/VirtualizedList.d.ts +0 -347
  308. package/Libraries/Lists/VirtualizedListCellRenderer.js +0 -259
  309. package/Libraries/Lists/VirtualizedListProps.js +0 -279
  310. package/Libraries/Performance/PureComponentDebug.js +0 -74
  311. package/Libraries/Reliability/UserFlow.js +0 -158
  312. package/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts +0 -149
  313. package/Libraries/Renderer/shims/ReactNativeTypes.d.ts +0 -141
  314. package/Libraries/Utilities/MatrixMath.js +0 -748
  315. package/Libraries/Utilities/buildStyleInterpolator.js +0 -209
  316. package/Libraries/Utilities/clamp.js +0 -23
  317. package/Libraries/Utilities/deprecatedPropType.js +0 -36
  318. package/Libraries/Utilities/groupByEveryN.js +0 -51
  319. package/Libraries/Utilities/mergeIntoFast.js +0 -26
  320. package/Libraries/Utilities/setAndForwardRef.js +0 -71
  321. package/Libraries/Utilities/truncate.js +0 -51
  322. package/flow/JSITimerInternalType.js +0 -30
  323. package/flow/use-sync-external-store.js +0 -19
@@ -1,748 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @noflow
9
- */
10
-
11
- 'use strict';
12
-
13
- const invariant = require('invariant');
14
-
15
- /**
16
- * Memory conservative (mutative) matrix math utilities. Uses "command"
17
- * matrices, which are reusable.
18
- */
19
- const MatrixMath = {
20
- createIdentityMatrix: function () {
21
- return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
22
- },
23
-
24
- createCopy: function (m) {
25
- return [
26
- m[0],
27
- m[1],
28
- m[2],
29
- m[3],
30
- m[4],
31
- m[5],
32
- m[6],
33
- m[7],
34
- m[8],
35
- m[9],
36
- m[10],
37
- m[11],
38
- m[12],
39
- m[13],
40
- m[14],
41
- m[15],
42
- ];
43
- },
44
-
45
- createOrthographic: function (left, right, bottom, top, near, far) {
46
- const a = 2 / (right - left);
47
- const b = 2 / (top - bottom);
48
- const c = -2 / (far - near);
49
-
50
- const tx = -(right + left) / (right - left);
51
- const ty = -(top + bottom) / (top - bottom);
52
- const tz = -(far + near) / (far - near);
53
-
54
- return [a, 0, 0, 0, 0, b, 0, 0, 0, 0, c, 0, tx, ty, tz, 1];
55
- },
56
-
57
- createFrustum: function (left, right, bottom, top, near, far) {
58
- const r_width = 1 / (right - left);
59
- const r_height = 1 / (top - bottom);
60
- const r_depth = 1 / (near - far);
61
- const x = 2 * (near * r_width);
62
- const y = 2 * (near * r_height);
63
- const A = (right + left) * r_width;
64
- const B = (top + bottom) * r_height;
65
- const C = (far + near) * r_depth;
66
- const D = 2 * (far * near * r_depth);
67
- return [x, 0, 0, 0, 0, y, 0, 0, A, B, C, -1, 0, 0, D, 0];
68
- },
69
-
70
- /**
71
- * This create a perspective projection towards negative z
72
- * Clipping the z range of [-near, -far]
73
- *
74
- * @param fovInRadians - field of view in radians
75
- */
76
- createPerspective: function (fovInRadians, aspect, near, far) {
77
- const h = 1 / Math.tan(fovInRadians / 2);
78
- const r_depth = 1 / (near - far);
79
- const C = (far + near) * r_depth;
80
- const D = 2 * (far * near * r_depth);
81
- return [h / aspect, 0, 0, 0, 0, h, 0, 0, 0, 0, C, -1, 0, 0, D, 0];
82
- },
83
-
84
- createTranslate2d: function (x, y) {
85
- const mat = MatrixMath.createIdentityMatrix();
86
- MatrixMath.reuseTranslate2dCommand(mat, x, y);
87
- return mat;
88
- },
89
-
90
- reuseTranslate2dCommand: function (matrixCommand, x, y) {
91
- matrixCommand[12] = x;
92
- matrixCommand[13] = y;
93
- },
94
-
95
- reuseTranslate3dCommand: function (matrixCommand, x, y, z) {
96
- matrixCommand[12] = x;
97
- matrixCommand[13] = y;
98
- matrixCommand[14] = z;
99
- },
100
-
101
- createScale: function (factor) {
102
- const mat = MatrixMath.createIdentityMatrix();
103
- MatrixMath.reuseScaleCommand(mat, factor);
104
- return mat;
105
- },
106
-
107
- reuseScaleCommand: function (matrixCommand, factor) {
108
- matrixCommand[0] = factor;
109
- matrixCommand[5] = factor;
110
- },
111
-
112
- reuseScale3dCommand: function (matrixCommand, x, y, z) {
113
- matrixCommand[0] = x;
114
- matrixCommand[5] = y;
115
- matrixCommand[10] = z;
116
- },
117
-
118
- reusePerspectiveCommand: function (matrixCommand, p) {
119
- matrixCommand[11] = -1 / p;
120
- },
121
-
122
- reuseScaleXCommand(matrixCommand, factor) {
123
- matrixCommand[0] = factor;
124
- },
125
-
126
- reuseScaleYCommand(matrixCommand, factor) {
127
- matrixCommand[5] = factor;
128
- },
129
-
130
- reuseScaleZCommand(matrixCommand, factor) {
131
- matrixCommand[10] = factor;
132
- },
133
-
134
- reuseRotateXCommand: function (matrixCommand, radians) {
135
- matrixCommand[5] = Math.cos(radians);
136
- matrixCommand[6] = Math.sin(radians);
137
- matrixCommand[9] = -Math.sin(radians);
138
- matrixCommand[10] = Math.cos(radians);
139
- },
140
-
141
- reuseRotateYCommand: function (matrixCommand, amount) {
142
- matrixCommand[0] = Math.cos(amount);
143
- matrixCommand[2] = -Math.sin(amount);
144
- matrixCommand[8] = Math.sin(amount);
145
- matrixCommand[10] = Math.cos(amount);
146
- },
147
-
148
- // http://www.w3.org/TR/css3-transforms/#recomposing-to-a-2d-matrix
149
- reuseRotateZCommand: function (matrixCommand, radians) {
150
- matrixCommand[0] = Math.cos(radians);
151
- matrixCommand[1] = Math.sin(radians);
152
- matrixCommand[4] = -Math.sin(radians);
153
- matrixCommand[5] = Math.cos(radians);
154
- },
155
-
156
- createRotateZ: function (radians) {
157
- const mat = MatrixMath.createIdentityMatrix();
158
- MatrixMath.reuseRotateZCommand(mat, radians);
159
- return mat;
160
- },
161
-
162
- reuseSkewXCommand: function (matrixCommand, radians) {
163
- matrixCommand[4] = Math.tan(radians);
164
- },
165
-
166
- reuseSkewYCommand: function (matrixCommand, radians) {
167
- matrixCommand[1] = Math.tan(radians);
168
- },
169
-
170
- multiplyInto: function (out, a, b) {
171
- const a00 = a[0],
172
- a01 = a[1],
173
- a02 = a[2],
174
- a03 = a[3],
175
- a10 = a[4],
176
- a11 = a[5],
177
- a12 = a[6],
178
- a13 = a[7],
179
- a20 = a[8],
180
- a21 = a[9],
181
- a22 = a[10],
182
- a23 = a[11],
183
- a30 = a[12],
184
- a31 = a[13],
185
- a32 = a[14],
186
- a33 = a[15];
187
-
188
- let b0 = b[0],
189
- b1 = b[1],
190
- b2 = b[2],
191
- b3 = b[3];
192
- out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
193
- out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
194
- out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
195
- out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
196
-
197
- b0 = b[4];
198
- b1 = b[5];
199
- b2 = b[6];
200
- b3 = b[7];
201
- out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
202
- out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
203
- out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
204
- out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
205
-
206
- b0 = b[8];
207
- b1 = b[9];
208
- b2 = b[10];
209
- b3 = b[11];
210
- out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
211
- out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
212
- out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
213
- out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
214
-
215
- b0 = b[12];
216
- b1 = b[13];
217
- b2 = b[14];
218
- b3 = b[15];
219
- out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
220
- out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
221
- out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
222
- out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
223
- },
224
-
225
- determinant(matrix: Array<number>): number {
226
- const [
227
- m00,
228
- m01,
229
- m02,
230
- m03,
231
- m10,
232
- m11,
233
- m12,
234
- m13,
235
- m20,
236
- m21,
237
- m22,
238
- m23,
239
- m30,
240
- m31,
241
- m32,
242
- m33,
243
- ] = matrix;
244
- return (
245
- m03 * m12 * m21 * m30 -
246
- m02 * m13 * m21 * m30 -
247
- m03 * m11 * m22 * m30 +
248
- m01 * m13 * m22 * m30 +
249
- m02 * m11 * m23 * m30 -
250
- m01 * m12 * m23 * m30 -
251
- m03 * m12 * m20 * m31 +
252
- m02 * m13 * m20 * m31 +
253
- m03 * m10 * m22 * m31 -
254
- m00 * m13 * m22 * m31 -
255
- m02 * m10 * m23 * m31 +
256
- m00 * m12 * m23 * m31 +
257
- m03 * m11 * m20 * m32 -
258
- m01 * m13 * m20 * m32 -
259
- m03 * m10 * m21 * m32 +
260
- m00 * m13 * m21 * m32 +
261
- m01 * m10 * m23 * m32 -
262
- m00 * m11 * m23 * m32 -
263
- m02 * m11 * m20 * m33 +
264
- m01 * m12 * m20 * m33 +
265
- m02 * m10 * m21 * m33 -
266
- m00 * m12 * m21 * m33 -
267
- m01 * m10 * m22 * m33 +
268
- m00 * m11 * m22 * m33
269
- );
270
- },
271
-
272
- /**
273
- * Inverse of a matrix. Multiplying by the inverse is used in matrix math
274
- * instead of division.
275
- *
276
- * Formula from:
277
- * http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
278
- */
279
- inverse(matrix: Array<number>): Array<number> {
280
- const det = MatrixMath.determinant(matrix);
281
- if (!det) {
282
- return matrix;
283
- }
284
- const [
285
- m00,
286
- m01,
287
- m02,
288
- m03,
289
- m10,
290
- m11,
291
- m12,
292
- m13,
293
- m20,
294
- m21,
295
- m22,
296
- m23,
297
- m30,
298
- m31,
299
- m32,
300
- m33,
301
- ] = matrix;
302
- return [
303
- (m12 * m23 * m31 -
304
- m13 * m22 * m31 +
305
- m13 * m21 * m32 -
306
- m11 * m23 * m32 -
307
- m12 * m21 * m33 +
308
- m11 * m22 * m33) /
309
- det,
310
- (m03 * m22 * m31 -
311
- m02 * m23 * m31 -
312
- m03 * m21 * m32 +
313
- m01 * m23 * m32 +
314
- m02 * m21 * m33 -
315
- m01 * m22 * m33) /
316
- det,
317
- (m02 * m13 * m31 -
318
- m03 * m12 * m31 +
319
- m03 * m11 * m32 -
320
- m01 * m13 * m32 -
321
- m02 * m11 * m33 +
322
- m01 * m12 * m33) /
323
- det,
324
- (m03 * m12 * m21 -
325
- m02 * m13 * m21 -
326
- m03 * m11 * m22 +
327
- m01 * m13 * m22 +
328
- m02 * m11 * m23 -
329
- m01 * m12 * m23) /
330
- det,
331
- (m13 * m22 * m30 -
332
- m12 * m23 * m30 -
333
- m13 * m20 * m32 +
334
- m10 * m23 * m32 +
335
- m12 * m20 * m33 -
336
- m10 * m22 * m33) /
337
- det,
338
- (m02 * m23 * m30 -
339
- m03 * m22 * m30 +
340
- m03 * m20 * m32 -
341
- m00 * m23 * m32 -
342
- m02 * m20 * m33 +
343
- m00 * m22 * m33) /
344
- det,
345
- (m03 * m12 * m30 -
346
- m02 * m13 * m30 -
347
- m03 * m10 * m32 +
348
- m00 * m13 * m32 +
349
- m02 * m10 * m33 -
350
- m00 * m12 * m33) /
351
- det,
352
- (m02 * m13 * m20 -
353
- m03 * m12 * m20 +
354
- m03 * m10 * m22 -
355
- m00 * m13 * m22 -
356
- m02 * m10 * m23 +
357
- m00 * m12 * m23) /
358
- det,
359
- (m11 * m23 * m30 -
360
- m13 * m21 * m30 +
361
- m13 * m20 * m31 -
362
- m10 * m23 * m31 -
363
- m11 * m20 * m33 +
364
- m10 * m21 * m33) /
365
- det,
366
- (m03 * m21 * m30 -
367
- m01 * m23 * m30 -
368
- m03 * m20 * m31 +
369
- m00 * m23 * m31 +
370
- m01 * m20 * m33 -
371
- m00 * m21 * m33) /
372
- det,
373
- (m01 * m13 * m30 -
374
- m03 * m11 * m30 +
375
- m03 * m10 * m31 -
376
- m00 * m13 * m31 -
377
- m01 * m10 * m33 +
378
- m00 * m11 * m33) /
379
- det,
380
- (m03 * m11 * m20 -
381
- m01 * m13 * m20 -
382
- m03 * m10 * m21 +
383
- m00 * m13 * m21 +
384
- m01 * m10 * m23 -
385
- m00 * m11 * m23) /
386
- det,
387
- (m12 * m21 * m30 -
388
- m11 * m22 * m30 -
389
- m12 * m20 * m31 +
390
- m10 * m22 * m31 +
391
- m11 * m20 * m32 -
392
- m10 * m21 * m32) /
393
- det,
394
- (m01 * m22 * m30 -
395
- m02 * m21 * m30 +
396
- m02 * m20 * m31 -
397
- m00 * m22 * m31 -
398
- m01 * m20 * m32 +
399
- m00 * m21 * m32) /
400
- det,
401
- (m02 * m11 * m30 -
402
- m01 * m12 * m30 -
403
- m02 * m10 * m31 +
404
- m00 * m12 * m31 +
405
- m01 * m10 * m32 -
406
- m00 * m11 * m32) /
407
- det,
408
- (m01 * m12 * m20 -
409
- m02 * m11 * m20 +
410
- m02 * m10 * m21 -
411
- m00 * m12 * m21 -
412
- m01 * m10 * m22 +
413
- m00 * m11 * m22) /
414
- det,
415
- ];
416
- },
417
-
418
- /**
419
- * Turns columns into rows and rows into columns.
420
- */
421
- transpose(m: Array<number>): Array<number> {
422
- return [
423
- m[0],
424
- m[4],
425
- m[8],
426
- m[12],
427
- m[1],
428
- m[5],
429
- m[9],
430
- m[13],
431
- m[2],
432
- m[6],
433
- m[10],
434
- m[14],
435
- m[3],
436
- m[7],
437
- m[11],
438
- m[15],
439
- ];
440
- },
441
-
442
- /**
443
- * Based on: http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c
444
- */
445
- multiplyVectorByMatrix(v: Array<number>, m: Array<number>): Array<number> {
446
- const [vx, vy, vz, vw] = v;
447
- return [
448
- vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12],
449
- vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13],
450
- vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14],
451
- vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15],
452
- ];
453
- },
454
-
455
- /**
456
- * From: https://code.google.com/p/webgl-mjs/source/browse/mjs.js
457
- */
458
- v3Length(a: Array<number>): number {
459
- return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
460
- },
461
-
462
- /**
463
- * Based on: https://code.google.com/p/webgl-mjs/source/browse/mjs.js
464
- */
465
- v3Normalize(vector: Array<number>, v3Length: number): Array<number> {
466
- const im = 1 / (v3Length || MatrixMath.v3Length(vector));
467
- return [vector[0] * im, vector[1] * im, vector[2] * im];
468
- },
469
-
470
- /**
471
- * The dot product of a and b, two 3-element vectors.
472
- * From: https://code.google.com/p/webgl-mjs/source/browse/mjs.js
473
- */
474
- v3Dot(a, b) {
475
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
476
- },
477
-
478
- /**
479
- * From:
480
- * http://www.opensource.apple.com/source/WebCore/WebCore-514/platform/graphics/transforms/TransformationMatrix.cpp
481
- */
482
- v3Combine(
483
- a: Array<number>,
484
- b: Array<number>,
485
- aScale: number,
486
- bScale: number,
487
- ): Array<number> {
488
- return [
489
- aScale * a[0] + bScale * b[0],
490
- aScale * a[1] + bScale * b[1],
491
- aScale * a[2] + bScale * b[2],
492
- ];
493
- },
494
-
495
- /**
496
- * From:
497
- * http://www.opensource.apple.com/source/WebCore/WebCore-514/platform/graphics/transforms/TransformationMatrix.cpp
498
- */
499
- v3Cross(a: Array<number>, b: Array<number>): Array<number> {
500
- return [
501
- a[1] * b[2] - a[2] * b[1],
502
- a[2] * b[0] - a[0] * b[2],
503
- a[0] * b[1] - a[1] * b[0],
504
- ];
505
- },
506
-
507
- /**
508
- * Based on:
509
- * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/
510
- * and:
511
- * http://quat.zachbennett.com/
512
- *
513
- * Note that this rounds degrees to the thousandth of a degree, due to
514
- * floating point errors in the creation of the quaternion.
515
- *
516
- * Also note that this expects the qw value to be last, not first.
517
- *
518
- * Also, when researching this, remember that:
519
- * yaw === heading === z-axis
520
- * pitch === elevation/attitude === y-axis
521
- * roll === bank === x-axis
522
- */
523
- quaternionToDegreesXYZ(q: Array<number>, matrix, row): Array<number> {
524
- const [qx, qy, qz, qw] = q;
525
- const qw2 = qw * qw;
526
- const qx2 = qx * qx;
527
- const qy2 = qy * qy;
528
- const qz2 = qz * qz;
529
- const test = qx * qy + qz * qw;
530
- const unit = qw2 + qx2 + qy2 + qz2;
531
- const conv = 180 / Math.PI;
532
-
533
- if (test > 0.49999 * unit) {
534
- return [0, 2 * Math.atan2(qx, qw) * conv, 90];
535
- }
536
- if (test < -0.49999 * unit) {
537
- return [0, -2 * Math.atan2(qx, qw) * conv, -90];
538
- }
539
-
540
- return [
541
- MatrixMath.roundTo3Places(
542
- Math.atan2(2 * qx * qw - 2 * qy * qz, 1 - 2 * qx2 - 2 * qz2) * conv,
543
- ),
544
- MatrixMath.roundTo3Places(
545
- Math.atan2(2 * qy * qw - 2 * qx * qz, 1 - 2 * qy2 - 2 * qz2) * conv,
546
- ),
547
- MatrixMath.roundTo3Places(Math.asin(2 * qx * qy + 2 * qz * qw) * conv),
548
- ];
549
- },
550
-
551
- /**
552
- * Based on:
553
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
554
- */
555
- roundTo3Places(n: number): number {
556
- const arr = n.toString().split('e');
557
- return Math.round(arr[0] + 'e' + (arr[1] ? +arr[1] - 3 : 3)) * 0.001;
558
- },
559
-
560
- /**
561
- * Decompose a matrix into separate transform values, for use on platforms
562
- * where applying a precomposed matrix is not possible, and transforms are
563
- * applied in an inflexible ordering (e.g. Android).
564
- *
565
- * Implementation based on
566
- * http://www.w3.org/TR/css3-transforms/#decomposing-a-2d-matrix
567
- * http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
568
- * which was based on
569
- * http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c
570
- */
571
- decomposeMatrix(transformMatrix: Array<number>): ?Object {
572
- invariant(
573
- transformMatrix.length === 16,
574
- 'Matrix decomposition needs a list of 3d matrix values, received %s',
575
- transformMatrix,
576
- );
577
-
578
- // output values
579
- let perspective = [];
580
- const quaternion = [];
581
- const scale = [];
582
- const skew = [];
583
- const translation = [];
584
-
585
- // create normalized, 2d array matrix
586
- // and normalized 1d array perspectiveMatrix with redefined 4th column
587
- if (!transformMatrix[15]) {
588
- return;
589
- }
590
- const matrix = [];
591
- const perspectiveMatrix = [];
592
- for (let i = 0; i < 4; i++) {
593
- matrix.push([]);
594
- for (let j = 0; j < 4; j++) {
595
- const value = transformMatrix[i * 4 + j] / transformMatrix[15];
596
- matrix[i].push(value);
597
- perspectiveMatrix.push(j === 3 ? 0 : value);
598
- }
599
- }
600
- perspectiveMatrix[15] = 1;
601
-
602
- // test for singularity of upper 3x3 part of the perspective matrix
603
- if (!MatrixMath.determinant(perspectiveMatrix)) {
604
- return;
605
- }
606
-
607
- // isolate perspective
608
- if (matrix[0][3] !== 0 || matrix[1][3] !== 0 || matrix[2][3] !== 0) {
609
- // rightHandSide is the right hand side of the equation.
610
- // rightHandSide is a vector, or point in 3d space relative to the origin.
611
- const rightHandSide = [
612
- matrix[0][3],
613
- matrix[1][3],
614
- matrix[2][3],
615
- matrix[3][3],
616
- ];
617
-
618
- // Solve the equation by inverting perspectiveMatrix and multiplying
619
- // rightHandSide by the inverse.
620
- const inversePerspectiveMatrix = MatrixMath.inverse(perspectiveMatrix);
621
- const transposedInversePerspectiveMatrix = MatrixMath.transpose(
622
- inversePerspectiveMatrix,
623
- );
624
- perspective = MatrixMath.multiplyVectorByMatrix(
625
- rightHandSide,
626
- transposedInversePerspectiveMatrix,
627
- );
628
- } else {
629
- // no perspective
630
- perspective[0] = perspective[1] = perspective[2] = 0;
631
- perspective[3] = 1;
632
- }
633
-
634
- // translation is simple
635
- for (let i = 0; i < 3; i++) {
636
- translation[i] = matrix[3][i];
637
- }
638
-
639
- // Now get scale and shear.
640
- // 'row' is a 3 element array of 3 component vectors
641
- const row = [];
642
- for (let i = 0; i < 3; i++) {
643
- row[i] = [matrix[i][0], matrix[i][1], matrix[i][2]];
644
- }
645
-
646
- // Compute X scale factor and normalize first row.
647
- scale[0] = MatrixMath.v3Length(row[0]);
648
- row[0] = MatrixMath.v3Normalize(row[0], scale[0]);
649
-
650
- // Compute XY shear factor and make 2nd row orthogonal to 1st.
651
- skew[0] = MatrixMath.v3Dot(row[0], row[1]);
652
- row[1] = MatrixMath.v3Combine(row[1], row[0], 1.0, -skew[0]);
653
-
654
- // Now, compute Y scale and normalize 2nd row.
655
- scale[1] = MatrixMath.v3Length(row[1]);
656
- row[1] = MatrixMath.v3Normalize(row[1], scale[1]);
657
- skew[0] /= scale[1];
658
-
659
- // Compute XZ and YZ shears, orthogonalize 3rd row
660
- skew[1] = MatrixMath.v3Dot(row[0], row[2]);
661
- row[2] = MatrixMath.v3Combine(row[2], row[0], 1.0, -skew[1]);
662
- skew[2] = MatrixMath.v3Dot(row[1], row[2]);
663
- row[2] = MatrixMath.v3Combine(row[2], row[1], 1.0, -skew[2]);
664
-
665
- // Next, get Z scale and normalize 3rd row.
666
- scale[2] = MatrixMath.v3Length(row[2]);
667
- row[2] = MatrixMath.v3Normalize(row[2], scale[2]);
668
- skew[1] /= scale[2];
669
- skew[2] /= scale[2];
670
-
671
- // At this point, the matrix (in rows) is orthonormal.
672
- // Check for a coordinate system flip. If the determinant
673
- // is -1, then negate the matrix and the scaling factors.
674
- const pdum3 = MatrixMath.v3Cross(row[1], row[2]);
675
- if (MatrixMath.v3Dot(row[0], pdum3) < 0) {
676
- for (let i = 0; i < 3; i++) {
677
- scale[i] *= -1;
678
- row[i][0] *= -1;
679
- row[i][1] *= -1;
680
- row[i][2] *= -1;
681
- }
682
- }
683
-
684
- // Now, get the rotations out
685
- quaternion[0] =
686
- 0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
687
- quaternion[1] =
688
- 0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
689
- quaternion[2] =
690
- 0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
691
- quaternion[3] =
692
- 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
693
-
694
- if (row[2][1] > row[1][2]) {
695
- quaternion[0] = -quaternion[0];
696
- }
697
- if (row[0][2] > row[2][0]) {
698
- quaternion[1] = -quaternion[1];
699
- }
700
- if (row[1][0] > row[0][1]) {
701
- quaternion[2] = -quaternion[2];
702
- }
703
-
704
- // correct for occasional, weird Euler synonyms for 2d rotation
705
- let rotationDegrees;
706
- if (
707
- quaternion[0] < 0.001 &&
708
- quaternion[0] >= 0 &&
709
- quaternion[1] < 0.001 &&
710
- quaternion[1] >= 0
711
- ) {
712
- // this is a 2d rotation on the z-axis
713
- rotationDegrees = [
714
- 0,
715
- 0,
716
- MatrixMath.roundTo3Places(
717
- (Math.atan2(row[0][1], row[0][0]) * 180) / Math.PI,
718
- ),
719
- ];
720
- } else {
721
- rotationDegrees = MatrixMath.quaternionToDegreesXYZ(
722
- quaternion,
723
- matrix,
724
- row,
725
- );
726
- }
727
-
728
- // expose both base data and convenience names
729
- return {
730
- rotationDegrees,
731
- perspective,
732
- quaternion,
733
- scale,
734
- skew,
735
- translation,
736
-
737
- rotate: rotationDegrees[2],
738
- rotateX: rotationDegrees[0],
739
- rotateY: rotationDegrees[1],
740
- scaleX: scale[0],
741
- scaleY: scale[1],
742
- translateX: translation[0],
743
- translateY: translation[1],
744
- };
745
- },
746
- };
747
-
748
- module.exports = MatrixMath;