@office-iss/react-native-win32 0.74.4 → 0.75.0-preview.2

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 (214) hide show
  1. package/.flowconfig +9 -4
  2. package/CHANGELOG.json +569 -51
  3. package/CHANGELOG.md +173 -30
  4. package/Libraries/Animated/AnimatedImplementation.js +2 -0
  5. package/Libraries/Animated/NativeAnimatedHelper.js +4 -0
  6. package/Libraries/Animated/NativeAnimatedHelper.win32.js +4 -0
  7. package/Libraries/Animated/createAnimatedComponent.js +10 -4
  8. package/Libraries/Animated/useAnimatedProps.js +56 -28
  9. package/Libraries/BatchedBridge/MessageQueue.js +1 -0
  10. package/Libraries/Components/Button.js +10 -5
  11. package/Libraries/Components/Button.win32.js +1 -0
  12. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +11 -2
  13. package/Libraries/Components/Pressable/Pressable.js +13 -6
  14. package/Libraries/Components/Pressable/Pressable.win32.js +13 -6
  15. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +4 -0
  16. package/Libraries/Components/ScrollView/ScrollView.js +109 -29
  17. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +6 -0
  18. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +13 -1
  19. package/Libraries/Components/StatusBar/StatusBar.js +1 -21
  20. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +0 -15
  21. package/Libraries/Components/TextInput/InputAccessoryView.js +10 -1
  22. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +0 -12
  23. package/Libraries/Components/TextInput/TextInput.d.ts +0 -19
  24. package/Libraries/Components/TextInput/TextInput.js +14 -70
  25. package/Libraries/Components/TextInput/TextInput.win32.js +15 -72
  26. package/Libraries/Components/Touchable/Touchable.js +2 -2
  27. package/Libraries/Components/Touchable/TouchableHighlight.d.ts +4 -10
  28. package/Libraries/Components/Touchable/TouchableHighlight.js +3 -1
  29. package/Libraries/Components/Touchable/TouchableOpacity.d.ts +4 -32
  30. package/Libraries/Components/Touchable/TouchableOpacity.js +3 -1
  31. package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +8 -0
  32. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +117 -111
  33. package/Libraries/Components/View/ReactNativeStyleAttributes.js +6 -0
  34. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  35. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  36. package/Libraries/Components/View/View.js +0 -11
  37. package/Libraries/Components/View/View.win32.js +0 -11
  38. package/Libraries/Components/View/ViewAccessibility.js +4 -4
  39. package/Libraries/Components/View/ViewAccessibility.win32.js +6 -6
  40. package/Libraries/Components/View/ViewPropTypes.d.ts +7 -49
  41. package/Libraries/Components/View/ViewPropTypes.js +7 -0
  42. package/Libraries/Components/View/ViewPropTypes.win32.js +7 -0
  43. package/Libraries/Core/Devtools/loadBundleFromServer.js +3 -3
  44. package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +153 -0
  45. package/Libraries/Core/Devtools/parseErrorStack.js +5 -5
  46. package/Libraries/Core/Devtools/parseHermesStack.js +22 -16
  47. package/Libraries/Core/ErrorHandlers.js +116 -0
  48. package/Libraries/Core/ExceptionsManager.js +2 -2
  49. package/Libraries/Core/ReactNativeVersion.js +3 -3
  50. package/Libraries/Core/setUpDeveloperTools.js +3 -1
  51. package/Libraries/Core/setUpPerformance.js +6 -4
  52. package/Libraries/Core/setUpReactDevTools.js +70 -10
  53. package/Libraries/Core/setUpTimers.js +50 -31
  54. package/Libraries/Debugging/DebuggingOverlayRegistry.js +1 -1
  55. package/Libraries/Image/Image.android.js +23 -13
  56. package/Libraries/Image/Image.d.ts +14 -15
  57. package/Libraries/Image/Image.ios.js +21 -11
  58. package/Libraries/Image/Image.win32.js +5 -3
  59. package/Libraries/Image/ImageProps.js +16 -5
  60. package/Libraries/Image/ImageTypes.flow.js +7 -2
  61. package/Libraries/Image/ImageUtils.js +1 -0
  62. package/Libraries/Image/ImageViewNativeComponent.js +2 -1
  63. package/Libraries/Inspector/ElementBox.js +6 -3
  64. package/Libraries/Inspector/ElementProperties.js +1 -1
  65. package/Libraries/Interaction/TouchHistoryMath.js +4 -4
  66. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +6 -26
  67. package/Libraries/JSInspector/NetworkAgent.js +1 -1
  68. package/Libraries/LogBox/Data/LogBoxData.js +39 -29
  69. package/Libraries/LogBox/Data/LogBoxLog.js +114 -2
  70. package/Libraries/LogBox/Data/parseLogBoxLog.js +168 -53
  71. package/Libraries/LogBox/LogBox.js +29 -12
  72. package/Libraries/LogBox/LogBoxNotificationContainer.js +4 -0
  73. package/Libraries/LogBox/UI/LogBoxInspector.js +8 -70
  74. package/Libraries/LogBox/UI/LogBoxInspectorBody.js +87 -0
  75. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +6 -42
  76. package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +58 -0
  77. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +5 -66
  78. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +8 -52
  79. package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +76 -0
  80. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +8 -5
  81. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +8 -5
  82. package/Libraries/LogBox/UI/LogBoxNotification.js +13 -152
  83. package/Libraries/LogBox/UI/LogBoxNotificationCountBadge.js +63 -0
  84. package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +67 -0
  85. package/Libraries/LogBox/UI/LogBoxNotificationMessage.js +57 -0
  86. package/Libraries/NativeComponent/BaseViewConfig.android.js +5 -0
  87. package/Libraries/NativeComponent/BaseViewConfig.ios.js +5 -0
  88. package/Libraries/NativeComponent/BaseViewConfig.win32.js +5 -0
  89. package/Libraries/NativeComponent/NativeComponentRegistry.js +12 -5
  90. package/Libraries/NativeComponent/StaticViewConfigValidator.js +3 -0
  91. package/Libraries/Network/XMLHttpRequest.js +5 -1
  92. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +3 -3
  93. package/Libraries/Pressability/Pressability.js +3 -51
  94. package/Libraries/Pressability/Pressability.win32.js +3 -51
  95. package/Libraries/ReactNative/AppContainer-dev.js +3 -2
  96. package/Libraries/ReactNative/AppContainer-prod.js +2 -1
  97. package/Libraries/ReactNative/AppContainer.js +2 -0
  98. package/Libraries/ReactNative/AppRegistry.d.ts +7 -0
  99. package/Libraries/ReactNative/AppRegistry.js +10 -4
  100. package/Libraries/ReactNative/BridgelessUIManager.js +1 -21
  101. package/Libraries/ReactNative/FabricUIManager.js +0 -51
  102. package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +1 -0
  103. package/Libraries/ReactNative/RendererImplementation.js +20 -2
  104. package/Libraries/ReactNative/UIManager.d.ts +0 -21
  105. package/Libraries/ReactNative/UIManagerProperties.js +0 -3
  106. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +5 -341
  107. package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -8
  108. package/Libraries/ReactNative/renderApplication.js +3 -0
  109. package/Libraries/Renderer/implementations/ReactFabric-dev.js +15682 -27088
  110. package/Libraries/Renderer/implementations/ReactFabric-prod.js +5082 -4381
  111. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3480 -2571
  112. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +15943 -27543
  113. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5303 -4606
  114. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3450 -2572
  115. package/Libraries/Renderer/shims/ReactFabric.js +2 -2
  116. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
  117. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  118. package/Libraries/Renderer/shims/ReactNativeTypes.js +24 -3
  119. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -2
  120. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
  121. package/Libraries/Share/Share.d.ts +16 -10
  122. package/Libraries/Share/Share.js +14 -15
  123. package/Libraries/StyleSheet/StyleSheet.d.ts +1 -1
  124. package/Libraries/StyleSheet/StyleSheet.js +3 -10
  125. package/Libraries/StyleSheet/StyleSheet.win32.js +3 -10
  126. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +21 -21
  127. package/Libraries/StyleSheet/StyleSheetTypes.js +24 -18
  128. package/Libraries/StyleSheet/flattenStyle.js +1 -0
  129. package/Libraries/StyleSheet/processFilter.js +132 -0
  130. package/Libraries/StyleSheet/processTransform.js +18 -3
  131. package/Libraries/Text/Text.js +151 -128
  132. package/Libraries/Text/Text.win32.js +163 -138
  133. package/Libraries/Text/TextNativeComponent.js +5 -4
  134. package/Libraries/Text/TextNativeComponent.win32.js +5 -4
  135. package/Libraries/Text/TextProps.js +6 -6
  136. package/Libraries/Text/TextProps.win32.js +6 -6
  137. package/Libraries/TurboModule/TurboModuleRegistry.js +2 -1
  138. package/Libraries/Types/CodegenTypes.js +3 -0
  139. package/Libraries/Utilities/{LoadingView.android.js → DevLoadingView.js} +33 -11
  140. package/Libraries/Utilities/Dimensions.js +1 -0
  141. package/Libraries/Utilities/Dimensions.win32.js +1 -0
  142. package/Libraries/Utilities/HMRClient.js +36 -8
  143. package/Libraries/Utilities/HMRClientProdShim.js +1 -0
  144. package/Libraries/Utilities/Platform.android.js +5 -5
  145. package/Libraries/Utilities/Platform.d.ts +1 -1
  146. package/Libraries/Utilities/Platform.flow.js +2 -2
  147. package/Libraries/Utilities/Platform.flow.win32.js +3 -3
  148. package/Libraries/Utilities/Platform.ios.js +1 -1
  149. package/Libraries/Utilities/Platform.win32.js +1 -1
  150. package/Libraries/Utilities/RCTLog.js +1 -0
  151. package/Libraries/Utilities/ReactNativeTestTools.js +12 -24
  152. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +11 -6
  153. package/Libraries/__tests__/ButtonWin32-test.js +7 -6
  154. package/Libraries/promiseRejectionTrackingOptions.js +1 -0
  155. package/jest/mockComponent.js +7 -0
  156. package/jest/renderer.js +25 -14
  157. package/jest/setup.js +19 -13
  158. package/jest.config.js +2 -1
  159. package/overrides.json +32 -31
  160. package/package.json +27 -25
  161. package/rn-get-polyfills.js +1 -0
  162. package/src/private/core/composeStyles.js +27 -0
  163. package/src/private/featureflags/ReactNativeFeatureFlags.js +93 -33
  164. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
  165. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +56 -0
  166. package/src/private/fusebox/setUpFuseboxReactDevToolsDispatcher.js +108 -0
  167. package/src/private/specs/modules/NativeBlobModule.js +4 -2
  168. package/src/private/specs/modules/NativeDevSettings.js +1 -0
  169. package/src/private/specs/modules/NativePlatformConstantsAndroid.js +1 -1
  170. package/src/private/specs/modules/NativePlatformConstantsIOS.js +1 -1
  171. package/src/private/specs/modules/NativePlatformConstantsWin.js +1 -1
  172. package/src/private/specs/modules/NativePushNotificationManagerIOS.js +0 -4
  173. package/src/private/specs/modules/NativeUIManager.js +0 -7
  174. package/src/private/webapis/dom/geometry/DOMRectReadOnly.js +24 -24
  175. package/src/private/webapis/dom/nodes/ReactNativeElement.js +11 -14
  176. package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +2 -3
  177. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +24 -54
  178. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -13
  179. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +468 -0
  180. package/src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock.js +413 -0
  181. package/src/private/webapis/dom/oldstylecollections/DOMRectList.js +4 -4
  182. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +4 -4
  183. package/src/private/webapis/dom/oldstylecollections/NodeList.js +5 -5
  184. package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +34 -0
  185. package/src/private/webapis/microtasks/specs/NativeMicrotasks.js +21 -0
  186. package/src/private/webapis/performance/EventCounts.js +1 -1
  187. package/src/private/webapis/performance/MemoryInfo.js +9 -9
  188. package/src/private/webapis/performance/Performance.js +10 -56
  189. package/src/private/webapis/performance/PerformanceObserver.js +30 -22
  190. package/src/private/webapis/performance/RawPerformanceEntry.js +2 -7
  191. package/src/private/webapis/performance/ReactNativeStartupTiming.js +18 -18
  192. package/src/private/webapis/performance/UserTiming.js +63 -0
  193. package/src/private/webapis/performance/{NativePerformance.js → specs/NativePerformance.js} +3 -2
  194. package/src/private/webapis/performance/{NativePerformanceObserver.js → specs/NativePerformanceObserver.js} +2 -2
  195. package/src/private/webapis/performance/{__mocks__ → specs/__mocks__}/NativePerformance.js +1 -1
  196. package/src/private/webapis/performance/{__mocks__ → specs/__mocks__}/NativePerformanceObserver.js +3 -4
  197. package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +7 -49
  198. package/types/modules/globals.d.ts +4 -0
  199. package/Libraries/Components/ScrollView/ScrollView.win32.js +0 -1915
  200. package/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js +0 -13
  201. package/Libraries/Utilities/LoadingView.ios.js +0 -50
  202. package/Libraries/Utilities/LoadingView.js +0 -16
  203. package/jest/ReactNativeInternalFeatureFlagsMock.js +0 -13
  204. package/src/private/featureflags/NativeReactNativeFeatureFlags.js +0 -44
  205. package/src/private/featureflags/__tests__/ReactNativeFeatureFlags-test.js +0 -92
  206. package/src/private/specs/modules/NativeAnimationsDebugModule.js +0 -20
  207. package/src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js +0 -85
  208. package/src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js +0 -80
  209. package/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js +0 -161
  210. package/src/private/webapis/performance/__tests__/EventCounts-test.js +0 -116
  211. package/src/private/webapis/performance/__tests__/NativePerformanceMock-test.js +0 -82
  212. package/src/private/webapis/performance/__tests__/NativePerformanceObserverMock-test.js +0 -108
  213. package/src/private/webapis/performance/__tests__/Performance-test.js +0 -117
  214. package/src/private/webapis/performance/__tests__/PerformanceObserver-test.js +0 -208
@@ -17,9 +17,8 @@ import type {
17
17
  import type NodeList from '../oldstylecollections/NodeList';
18
18
  import type ReadOnlyElement from './ReadOnlyElement';
19
19
 
20
- import {getFabricUIManager} from '../../../../../Libraries/ReactNative/FabricUIManager';
21
20
  import {createNodeList} from '../oldstylecollections/NodeList';
22
- import nullthrows from 'nullthrows';
21
+ import NativeDOM from './specs/NativeDOM';
23
22
 
24
23
  // We initialize this lazily to avoid a require cycle
25
24
  // (`ReadOnlyElement` also depends on `ReadOnlyNode`).
@@ -52,7 +51,7 @@ export default class ReadOnlyNode {
52
51
  return false;
53
52
  }
54
53
 
55
- return nullthrows(getFabricUIManager()).isConnected(shadowNode);
54
+ return NativeDOM.isConnected(shadowNode);
56
55
  }
57
56
 
58
57
  get lastChild(): ReadOnlyNode | null {
@@ -125,9 +124,7 @@ export default class ReadOnlyNode {
125
124
  return null;
126
125
  }
127
126
 
128
- const parentInstanceHandle = nullthrows(getFabricUIManager()).getParentNode(
129
- shadowNode,
130
- );
127
+ const parentInstanceHandle = NativeDOM.getParentNode(shadowNode);
131
128
 
132
129
  if (parentInstanceHandle == null) {
133
130
  return null;
@@ -171,10 +168,7 @@ export default class ReadOnlyNode {
171
168
  return ReadOnlyNode.DOCUMENT_POSITION_DISCONNECTED;
172
169
  }
173
170
 
174
- return nullthrows(getFabricUIManager()).compareDocumentPosition(
175
- shadowNode,
176
- otherShadowNode,
177
- );
171
+ return NativeDOM.compareDocumentPosition(shadowNode, otherShadowNode);
178
172
  }
179
173
 
180
174
  contains(otherNode: ReadOnlyNode): boolean {
@@ -323,9 +317,7 @@ export function getChildNodes(
323
317
  return [];
324
318
  }
325
319
 
326
- const childNodeInstanceHandles = nullthrows(
327
- getFabricUIManager(),
328
- ).getChildNodes(shadowNode);
320
+ const childNodeInstanceHandles = NativeDOM.getChildNodes(shadowNode);
329
321
  return childNodeInstanceHandles
330
322
  .map(instanceHandle =>
331
323
  getPublicInstanceFromInternalInstanceHandle(instanceHandle),
@@ -0,0 +1,468 @@
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
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ import type {
12
+ InternalInstanceHandle as InstanceHandle,
13
+ Node as ShadowNode,
14
+ } from '../../../../../../Libraries/Renderer/shims/ReactNativeTypes';
15
+ import type {TurboModule} from '../../../../../../Libraries/TurboModule/RCTExport';
16
+
17
+ import * as TurboModuleRegistry from '../../../../../../Libraries/TurboModule/TurboModuleRegistry';
18
+ import nullthrows from 'nullthrows';
19
+
20
+ export type MeasureInWindowOnSuccessCallback = (
21
+ x: number,
22
+ y: number,
23
+ width: number,
24
+ height: number,
25
+ ) => void;
26
+
27
+ export type MeasureOnSuccessCallback = (
28
+ x: number,
29
+ y: number,
30
+ width: number,
31
+ height: number,
32
+ pageX: number,
33
+ pageY: number,
34
+ ) => void;
35
+
36
+ export type MeasureLayoutOnSuccessCallback = (
37
+ left: number,
38
+ top: number,
39
+ width: number,
40
+ height: number,
41
+ ) => void;
42
+
43
+ export interface Spec extends TurboModule {
44
+ +getParentNode: (
45
+ shadowNode: mixed /* ShadowNode */,
46
+ ) => mixed /* ?InstanceHandle */;
47
+
48
+ +getChildNodes: (
49
+ shadowNode: mixed /* ShadowNode */,
50
+ ) => $ReadOnlyArray<mixed> /* $ReadOnlyArray<InstanceHandle> */;
51
+
52
+ +isConnected: (shadowNode: mixed /* ShadowNode */) => boolean;
53
+
54
+ +compareDocumentPosition: (
55
+ shadowNode: mixed /* ShadowNode */,
56
+ otherShadowNode: mixed /* ShadowNode */,
57
+ ) => number;
58
+
59
+ +getTextContent: (shadowNode: mixed /* ShadowNode */) => string;
60
+
61
+ +getBoundingClientRect: (
62
+ shadowNode: mixed /* ShadowNode */,
63
+ includeTransform: boolean,
64
+ ) => $ReadOnlyArray<number> /* [x: number, y: number, width: number, height: number] */;
65
+
66
+ +getOffset: (
67
+ shadowNode: mixed /* ShadowNode */,
68
+ ) => $ReadOnlyArray<mixed> /* [offsetParent: ?InstanceHandle, top: number, left: number] */;
69
+
70
+ +getScrollPosition: (
71
+ shadowNode: mixed /* ShadowNode */,
72
+ ) => $ReadOnlyArray<number> /* [scrollLeft: number, scrollTop: number] */;
73
+
74
+ +getScrollSize: (
75
+ shadowNode: mixed /* ShadowNode */,
76
+ ) => $ReadOnlyArray<number> /* [scrollWidth: number, scrollHeight: number] */;
77
+
78
+ +getInnerSize: (
79
+ shadowNode: mixed /* ShadowNode */,
80
+ ) => $ReadOnlyArray<number> /* [width: number, height: number] */;
81
+
82
+ +getBorderWidth: (
83
+ shadowNode: mixed /* ShadowNode */,
84
+ ) => $ReadOnlyArray<number> /* [topWidth: number, rightWidth: number, bottomWidth: number, leftWidth: number] */;
85
+
86
+ +getTagName: (shadowNode: mixed /* ShadowNode */) => string;
87
+
88
+ +hasPointerCapture: (
89
+ shadowNode: mixed /* ShadowNode */,
90
+ pointerId: number,
91
+ ) => boolean;
92
+
93
+ +setPointerCapture: (
94
+ shadowNode: mixed /* ShadowNode */,
95
+ pointerId: number,
96
+ ) => void;
97
+
98
+ +releasePointerCapture: (
99
+ shadowNode: mixed /* ShadowNode */,
100
+ pointerId: number,
101
+ ) => void;
102
+
103
+ /**
104
+ * Legacy layout APIs
105
+ */
106
+
107
+ +measure: (shadowNode: mixed, callback: MeasureOnSuccessCallback) => void;
108
+
109
+ +measureInWindow: (
110
+ shadowNode: mixed,
111
+ callback: MeasureInWindowOnSuccessCallback,
112
+ ) => void;
113
+
114
+ +measureLayout: (
115
+ shadowNode: mixed,
116
+ relativeNode: mixed,
117
+ onFail: () => void,
118
+ onSuccess: MeasureLayoutOnSuccessCallback,
119
+ ) => void;
120
+ }
121
+
122
+ const RawNativeDOM = (TurboModuleRegistry.get<Spec>('NativeDOMCxx'): ?Spec);
123
+
124
+ // This is the actual interface of this module, but the native module codegen
125
+ // isn't expressive enough yet.
126
+ export interface RefinedSpec {
127
+ /**
128
+ * This is a React Native implementation of `Node.prototype.parentNode`
129
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode).
130
+ *
131
+ * If a version of the given shadow node is present in the current revision of
132
+ * an active shadow tree, it returns the instance handle of its parent.
133
+ * Otherwise, it returns `null`.
134
+ */
135
+ +getParentNode: (shadowNode: ShadowNode) => ?InstanceHandle;
136
+
137
+ /**
138
+ * This is a React Native implementation of `Node.prototype.childNodes`
139
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes).
140
+ *
141
+ * If a version of the given shadow node is present in the current revision
142
+ * of an active shadow tree, it returns an array of instance handles of its
143
+ * children. Otherwise, it returns an empty array.
144
+ */
145
+ +getChildNodes: (shadowNode: ShadowNode) => $ReadOnlyArray<InstanceHandle>;
146
+
147
+ /**
148
+ * This is a React Native implementation of `Node.prototype.isConnected`
149
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected).
150
+ *
151
+ * Indicates whether a version of the given shadow node is present in the
152
+ * current revision of an active shadow tree.
153
+ */
154
+ +isConnected: (shadowNode: ShadowNode) => boolean;
155
+
156
+ /**
157
+ * This is a React Native implementation of `Node.prototype.compareDocumentPosition`
158
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition).
159
+ *
160
+ * It uses the version of the shadow nodes that are present in the current
161
+ * revision of the shadow tree (if any). If any of the nodes is not present,
162
+ * it just indicates they are disconnected.
163
+ */
164
+ +compareDocumentPosition: (
165
+ shadowNode: ShadowNode,
166
+ otherShadowNode: ShadowNode,
167
+ ) => number;
168
+
169
+ /**
170
+ * This is a React Native implementation of `Element.prototype.textContent`
171
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/Element/textContent).
172
+ *
173
+ * It uses the version of the shadow node that is present in the current
174
+ * revision of the shadow tree.
175
+ * If the version is present, is traverses all its children in DFS and
176
+ * concatenates all the text contents. Otherwise, it returns an empty string.
177
+ *
178
+ * This is also used to access the text content of text nodes, which does not
179
+ * need any traversal.
180
+ */
181
+ +getTextContent: (shadowNode: ShadowNode) => string;
182
+
183
+ /**
184
+ * This is a React Native implementation of `Element.prototype.getBoundingClientRect`
185
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
186
+ *
187
+ * This is similar to `measureInWindow`, except it's explicitly synchronous
188
+ * (returns the result instead of passing it to a callback).
189
+ *
190
+ * It allows indicating whether to include transforms so it can also be used
191
+ * to implement methods like [`offsetWidth`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth)
192
+ * and [`offsetHeight`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight).
193
+ */
194
+ +getBoundingClientRect: (
195
+ shadowNode: ShadowNode,
196
+ includeTransform: boolean,
197
+ ) => $ReadOnly<
198
+ [
199
+ /* x: */ number,
200
+ /* y: */ number,
201
+ /* width: */ number,
202
+ /* height: */ number,
203
+ ],
204
+ >;
205
+
206
+ /**
207
+ * This is a method to access the offset information for a shadow node, to
208
+ * implement these methods:
209
+ * - `HTMLElement.prototype.offsetParent`: see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent.
210
+ * - `HTMLElement.prototype.offsetTop`: see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop.
211
+ * - `HTMLElement.prototype.offsetLeft`: see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetLeft.
212
+ *
213
+ * It uses the version of the shadow node that is present in the current
214
+ * revision of the shadow tree. If the node is not present or is not
215
+ * displayed (because any of its ancestors or itself have 'display: none'),
216
+ * it returns `undefined`. Otherwise, it returns its parent (as all nodes in
217
+ * React Native are currently "positioned") and its offset relative to its
218
+ * parent.
219
+ */
220
+ +getOffset: (
221
+ shadowNode: ShadowNode,
222
+ ) => $ReadOnly<
223
+ [
224
+ /* offsetParent: */ ?InstanceHandle,
225
+ /* top: */ number,
226
+ /* left: */ number,
227
+ ],
228
+ >;
229
+
230
+ /**
231
+ * This is a method to access scroll information for a shadow node, to
232
+ * implement these methods:
233
+ * - `Element.prototype.scrollLeft`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft.
234
+ * - `Element.prototype.scrollTop`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop.
235
+ *
236
+ * It uses the version of the shadow node that is present in the current
237
+ * revision of the shadow tree. If the node is not present or is not displayed
238
+ * (because any of its ancestors or itself have 'display: none'), it returns
239
+ * `undefined`. Otherwise, it returns the scroll position.
240
+ */
241
+ +getScrollPosition: (
242
+ shadowNode: ShadowNode,
243
+ ) => $ReadOnly<[/* scrollLeft: */ number, /* scrollTop: */ number]>;
244
+
245
+ /**
246
+ *
247
+ * This is a method to access the scroll information of a shadow node, to
248
+ * implement these methods:
249
+ * - `Element.prototype.scrollWidth`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth.
250
+ * - `Element.prototype.scrollHeight`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight.
251
+ *
252
+ * It uses the version of the shadow node that is present in the current
253
+ * revision of the shadow tree. If the node is not present or is not displayed
254
+ * (because any of its ancestors or itself have 'display: none'), it returns
255
+ * `undefined`. Otherwise, it returns the scroll size.
256
+ */
257
+ +getScrollSize: (
258
+ shadowNode: ShadowNode,
259
+ ) => $ReadOnly<[/* scrollWidth: */ number, /* scrollHeight: */ number]>;
260
+
261
+ /**
262
+ * This is a method to access the inner size of a shadow node, to implement
263
+ * these methods:
264
+ * - `Element.prototype.clientWidth`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth.
265
+ * - `Element.prototype.clientHeight`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight.
266
+ *
267
+ * It uses the version of the shadow node that is present in the current
268
+ * revision of the shadow tree. If the node is not present, it is not
269
+ * displayed (because any of its ancestors or itself have 'display: none'), or
270
+ * it has an inline display, it returns `undefined`. Otherwise, it returns its
271
+ * inner size.
272
+ */
273
+ +getInnerSize: (
274
+ shadowNode: ShadowNode,
275
+ ) => $ReadOnly<[/* width: */ number, /* height: */ number]>;
276
+
277
+ /**
278
+ * This is a method to access the border size of a shadow node, to implement
279
+ * these methods:
280
+ * - `Element.prototype.clientLeft`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientLeft.
281
+ * - `Element.prototype.clientTop`: see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop.
282
+ *
283
+ * It uses the version of the shadow node that is present in the current
284
+ * revision of the shadow tree. If the node is not present, it is not
285
+ * displayed (because any of its ancestors or itself have 'display: none'), or
286
+ * it has an inline display, it returns `undefined`. Otherwise, it returns its
287
+ * border size.
288
+ */
289
+ +getBorderWidth: (
290
+ shadowNode: ShadowNode,
291
+ ) => $ReadOnly<
292
+ [
293
+ /* topWidth: */ number,
294
+ /* rightWidth: */ number,
295
+ /* bottomWidth: */ number,
296
+ /* leftWidth: */ number,
297
+ ],
298
+ >;
299
+
300
+ /**
301
+ * This is a method to access the normalized tag name of a shadow node, to
302
+ * implement `Element.prototype.tagName` (see https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName).
303
+ */
304
+ +getTagName: (shadowNode: ShadowNode) => string;
305
+
306
+ /**
307
+ * Pointer Capture APIs
308
+ */
309
+
310
+ +hasPointerCapture: (shadowNode: ShadowNode, pointerId: number) => boolean;
311
+
312
+ +setPointerCapture: (shadowNode: ShadowNode, pointerId: number) => void;
313
+
314
+ +releasePointerCapture: (shadowNode: ShadowNode, pointerId: number) => void;
315
+
316
+ /**
317
+ * Legacy layout APIs
318
+ */
319
+
320
+ +measure: (
321
+ shadowNode: ShadowNode,
322
+ callback: MeasureOnSuccessCallback,
323
+ ) => void;
324
+
325
+ +measureInWindow: (
326
+ shadowNode: ShadowNode,
327
+ callback: MeasureInWindowOnSuccessCallback,
328
+ ) => void;
329
+
330
+ +measureLayout: (
331
+ shadowNode: ShadowNode,
332
+ relativeNode: ShadowNode,
333
+ onFail: () => void,
334
+ onSuccess: MeasureLayoutOnSuccessCallback,
335
+ ) => void;
336
+ }
337
+
338
+ const NativeDOM: RefinedSpec = {
339
+ getParentNode(shadowNode) {
340
+ // $FlowExpectedError[incompatible-cast]
341
+ return (nullthrows(RawNativeDOM).getParentNode(
342
+ shadowNode,
343
+ ): ?InstanceHandle);
344
+ },
345
+
346
+ getChildNodes(shadowNode) {
347
+ // $FlowExpectedError[incompatible-cast]
348
+ return (nullthrows(RawNativeDOM).getChildNodes(
349
+ shadowNode,
350
+ ): $ReadOnlyArray<InstanceHandle>);
351
+ },
352
+
353
+ isConnected(shadowNode) {
354
+ return nullthrows(RawNativeDOM).isConnected(shadowNode);
355
+ },
356
+
357
+ compareDocumentPosition(shadowNode, otherShadowNode) {
358
+ return nullthrows(RawNativeDOM).compareDocumentPosition(
359
+ shadowNode,
360
+ otherShadowNode,
361
+ );
362
+ },
363
+
364
+ getTextContent(shadowNode) {
365
+ return nullthrows(RawNativeDOM).getTextContent(shadowNode);
366
+ },
367
+
368
+ getBoundingClientRect(shadowNode, includeTransform: boolean) {
369
+ // $FlowExpectedError[incompatible-cast]
370
+ return (nullthrows(RawNativeDOM).getBoundingClientRect(
371
+ shadowNode,
372
+ includeTransform,
373
+ ): $ReadOnly<
374
+ [
375
+ /* x: */ number,
376
+ /* y: */ number,
377
+ /* width: */ number,
378
+ /* height: */ number,
379
+ ],
380
+ >);
381
+ },
382
+
383
+ getOffset(shadowNode) {
384
+ // $FlowExpectedError[incompatible-cast]
385
+ return (nullthrows(RawNativeDOM).getOffset(shadowNode): $ReadOnly<
386
+ [
387
+ /* offsetParent: */ ?InstanceHandle,
388
+ /* top: */ number,
389
+ /* left: */ number,
390
+ ],
391
+ >);
392
+ },
393
+
394
+ getScrollPosition(shadowNode) {
395
+ // $FlowExpectedError[incompatible-cast]
396
+ return (nullthrows(RawNativeDOM).getScrollPosition(shadowNode): $ReadOnly<
397
+ [/* scrollLeft: */ number, /* scrollTop: */ number],
398
+ >);
399
+ },
400
+
401
+ getScrollSize(shadowNode) {
402
+ // $FlowExpectedError[incompatible-cast]
403
+ return (nullthrows(RawNativeDOM).getScrollSize(shadowNode): $ReadOnly<
404
+ [/* scrollWidth: */ number, /* scrollHeight: */ number],
405
+ >);
406
+ },
407
+
408
+ getInnerSize(shadowNode) {
409
+ // $FlowExpectedError[incompatible-cast]
410
+ return (nullthrows(RawNativeDOM).getInnerSize(shadowNode): $ReadOnly<
411
+ [/* width: */ number, /* height: */ number],
412
+ >);
413
+ },
414
+
415
+ getBorderWidth(shadowNode) {
416
+ // $FlowExpectedError[incompatible-cast]
417
+ return (nullthrows(RawNativeDOM).getBorderWidth(shadowNode): $ReadOnly<
418
+ [
419
+ /* topWidth: */ number,
420
+ /* rightWidth: */ number,
421
+ /* bottomWidth: */ number,
422
+ /* leftWidth: */ number,
423
+ ],
424
+ >);
425
+ },
426
+
427
+ getTagName(shadowNode) {
428
+ return nullthrows(RawNativeDOM).getTagName(shadowNode);
429
+ },
430
+
431
+ hasPointerCapture(shadowNode, pointerId) {
432
+ return nullthrows(RawNativeDOM).hasPointerCapture(shadowNode, pointerId);
433
+ },
434
+
435
+ setPointerCapture(shadowNode, pointerId) {
436
+ return nullthrows(RawNativeDOM).setPointerCapture(shadowNode, pointerId);
437
+ },
438
+
439
+ releasePointerCapture(shadowNode, pointerId) {
440
+ return nullthrows(RawNativeDOM).releasePointerCapture(
441
+ shadowNode,
442
+ pointerId,
443
+ );
444
+ },
445
+
446
+ /**
447
+ * Legacy layout APIs
448
+ */
449
+
450
+ measure(shadowNode, callback) {
451
+ return nullthrows(RawNativeDOM).measure(shadowNode, callback);
452
+ },
453
+
454
+ measureInWindow(shadowNode, callback) {
455
+ return nullthrows(RawNativeDOM).measureInWindow(shadowNode, callback);
456
+ },
457
+
458
+ measureLayout(shadowNode, relativeNode, onFail, onSuccess) {
459
+ return nullthrows(RawNativeDOM).measureLayout(
460
+ shadowNode,
461
+ relativeNode,
462
+ onFail,
463
+ onSuccess,
464
+ );
465
+ },
466
+ };
467
+
468
+ export default NativeDOM;