@office-iss/react-native-win32 0.0.0-canary.287 → 0.0.0-canary.289

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 (192) hide show
  1. package/.flowconfig +6 -2
  2. package/CHANGELOG.json +63 -1
  3. package/CHANGELOG.md +24 -4
  4. package/Libraries/Alert/Alert.d.ts +4 -1
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/{Modal/ModalInjection.js → Alert/RCTAlertManager.js.flow} +7 -4
  7. package/Libraries/Animated/Animated.js +8 -37
  8. package/Libraries/Animated/Animated.js.flow +15 -0
  9. package/Libraries/Animated/AnimatedExports.js +47 -0
  10. package/Libraries/Animated/AnimatedExports.js.flow +48 -0
  11. package/Libraries/Animated/Easing.js +13 -15
  12. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  13. package/Libraries/Animated/nodes/AnimatedNode.js +2 -1
  14. package/Libraries/Animated/nodes/AnimatedProps.js +18 -1
  15. package/Libraries/Animated/nodes/AnimatedValue.js +6 -2
  16. package/Libraries/Animated/useAnimatedValue.js +1 -3
  17. package/Libraries/Blob/URL.js +23 -10
  18. package/Libraries/Blob/URLSearchParams.js.flow +23 -0
  19. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
  20. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
  21. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js.flow +20 -0
  22. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +8 -8
  23. package/Libraries/Components/Button.js +2 -2
  24. package/Libraries/Components/Button.win32.js +2 -2
  25. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +14 -100
  26. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +64 -4
  27. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +138 -0
  28. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +7 -4
  29. package/Libraries/Components/LayoutConformance/LayoutConformance.js +6 -4
  30. package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
  31. package/Libraries/Components/Pressable/Pressable.js +18 -63
  32. package/Libraries/Components/Pressable/Pressable.win32.js +19 -65
  33. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  34. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +4 -46
  35. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +10 -4
  36. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +54 -0
  37. package/Libraries/Components/RefreshControl/RefreshControl.js +10 -7
  38. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +2 -1
  39. package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -1
  40. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -1
  41. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +2 -4
  42. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +2 -4
  43. package/Libraries/Components/ScrollView/ScrollView.js +43 -59
  44. package/Libraries/Components/ScrollView/ScrollViewCommands.js +1 -1
  45. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -4
  46. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -7
  47. package/Libraries/Components/StatusBar/StatusBar.js +33 -22
  48. package/Libraries/Components/Switch/Switch.js +70 -41
  49. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -4
  50. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +2 -4
  51. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +2 -4
  52. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  53. package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +2 -1
  54. package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
  55. package/Libraries/Components/TextInput/TextInput.d.ts +6 -0
  56. package/Libraries/Components/TextInput/TextInput.flow.js +45 -14
  57. package/Libraries/Components/TextInput/TextInput.js +121 -136
  58. package/Libraries/Components/TextInput/TextInput.win32.js +122 -137
  59. package/Libraries/Components/TextInput/TextInputState.js +2 -18
  60. package/Libraries/Components/TextInput/TextInputState.win32.js +2 -18
  61. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +1 -1
  62. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +2 -1
  63. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  64. package/Libraries/Components/Touchable/Touchable.js +7 -7
  65. package/Libraries/Components/Touchable/Touchable.win32.js +7 -7
  66. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableHighlight.js +35 -14
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +95 -47
  69. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +248 -43
  70. package/Libraries/Components/Touchable/TouchableOpacity.js +52 -10
  71. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +112 -59
  72. package/Libraries/Components/View/View.js +1 -1
  73. package/Libraries/Components/View/View.win32.js +1 -1
  74. package/Libraries/Components/View/ViewNativeComponent.js +2 -4
  75. package/Libraries/Components/View/ViewPropTypes.js +15 -12
  76. package/Libraries/Components/View/ViewPropTypes.win32.js +74 -71
  77. package/Libraries/Core/ReactNativeVersion.js +2 -2
  78. package/Libraries/Core/setUpReactDevTools.js +2 -0
  79. package/Libraries/Debugging/DebuggingOverlayRegistry.js +10 -7
  80. package/Libraries/Image/Image.android.js +1 -1
  81. package/Libraries/Image/Image.js.flow +27 -0
  82. package/Libraries/Image/ImageBackground.js +1 -1
  83. package/Libraries/Image/ImageProps.js +97 -30
  84. package/Libraries/Image/ImageTypes.flow.js +16 -6
  85. package/Libraries/Image/ImageViewNativeComponent.js +3 -5
  86. package/Libraries/Image/Tests/ImageWin32Test.d.ts +2 -1
  87. package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
  88. package/Libraries/Image/TextInlineImageNativeComponent.js +2 -4
  89. package/Libraries/Interaction/InteractionManager.js +9 -1
  90. package/Libraries/Interaction/PanResponder.js +11 -11
  91. package/Libraries/Interaction/TaskQueue.js +3 -2
  92. package/Libraries/Lists/FlatList.js +8 -7
  93. package/Libraries/LogBox/LogBox.js +1 -1
  94. package/Libraries/Modal/Modal.js +30 -4
  95. package/Libraries/NativeComponent/BaseViewConfig.js.flow +14 -0
  96. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  97. package/Libraries/Network/RCTNetworking.js.flow +44 -0
  98. package/Libraries/Network/XMLHttpRequest_new.js +3 -0
  99. package/Libraries/Network/XMLHttpRequest_old.js +3 -0
  100. package/Libraries/Pressability/HoverState.js +1 -0
  101. package/Libraries/Pressability/HoverState.win32.js +1 -0
  102. package/Libraries/Pressability/Pressability.js +2 -2
  103. package/Libraries/Pressability/Pressability.win32.js +3 -3
  104. package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
  105. package/Libraries/ReactNative/AppRegistry.js +2 -322
  106. package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
  107. package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
  108. package/Libraries/ReactNative/FabricUIManager.js +5 -3
  109. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +7 -5
  110. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
  111. package/Libraries/ReactNative/RendererImplementation.js +3 -5
  112. package/Libraries/ReactNative/requireNativeComponent.js +1 -1
  113. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +12 -0
  114. package/Libraries/Renderer/shims/ReactNativeTypes.js +39 -91
  115. package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +22 -0
  116. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
  117. package/Libraries/StyleSheet/StyleSheet.js +5 -197
  118. package/Libraries/StyleSheet/StyleSheet.js.flow +166 -0
  119. package/Libraries/StyleSheet/{StyleSheet.win32.js → StyleSheetExports.js} +2 -151
  120. package/Libraries/StyleSheet/StyleSheetExports.js.flow +110 -0
  121. package/Libraries/StyleSheet/StyleSheetTypes.js +42 -18
  122. package/Libraries/Text/Text.d.ts +1 -1
  123. package/Libraries/Text/Text.js +3 -1
  124. package/Libraries/Text/Text.win32.js +3 -1
  125. package/Libraries/Text/TextNativeComponent.js +1 -1
  126. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  127. package/Libraries/Text/TextProps.js +124 -84
  128. package/Libraries/Text/TextProps.win32.js +124 -84
  129. package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
  130. package/Libraries/Types/CodegenTypesNamespace.js +14 -0
  131. package/Libraries/Types/CoreEventTypes.js +1 -1
  132. package/Libraries/Types/CoreEventTypes.win32.js +1 -1
  133. package/Libraries/Types/ReactDevToolsTypes.js +4 -8
  134. package/Libraries/Utilities/BackHandler.js.flow +25 -0
  135. package/Libraries/Utilities/DevSettings.js +14 -0
  136. package/Libraries/Utilities/Dimensions.js +5 -0
  137. package/Libraries/Utilities/Dimensions.win32.js +5 -0
  138. package/{flow/Position.js → Libraries/Utilities/Platform.js.flow} +3 -6
  139. package/Libraries/Utilities/PlatformTypes.js +97 -7
  140. package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
  141. package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
  142. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  143. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +2 -4
  144. package/Libraries/vendor/emitter/EventEmitter.js +6 -2
  145. package/flow/global.js +1 -0
  146. package/flow/jest.js +4 -2
  147. package/index.js +47 -43
  148. package/index.win32.js +63 -59
  149. package/overrides.json +27 -35
  150. package/package.json +18 -18
  151. package/src/private/animated/NativeAnimatedHelper.js +18 -7
  152. package/src/private/animated/NativeAnimatedHelper.win32.js +18 -7
  153. package/src/private/animated/createAnimatedPropsHook.js +34 -15
  154. package/src/private/components/HScrollViewNativeComponents.js +1 -1
  155. package/src/private/components/VScrollViewNativeComponents.js +1 -1
  156. package/src/private/featureflags/ReactNativeFeatureFlags.js +24 -36
  157. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +9 -1
  158. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +4 -4
  159. package/src/private/inspector/getInspectorDataForViewAtPoint.js +2 -4
  160. package/src/private/setup/setUpDOM.js +36 -1
  161. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
  162. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +1 -1
  163. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
  164. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +1 -1
  165. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +1 -1
  166. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +1 -1
  167. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
  168. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
  169. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
  170. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +1 -1
  171. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
  172. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  173. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
  174. package/src/private/types/HostComponent.js +16 -0
  175. package/src/private/types/HostInstance.js +50 -0
  176. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +1 -0
  177. package/src/private/webapis/dom/nodes/ReactNativeElement.js +40 -32
  178. package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +1 -1
  179. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
  180. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -19
  181. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
  182. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +4 -4
  183. package/src/private/webapis/mutationobserver/MutationObserver.js +9 -9
  184. package/src/private/webapis/performance/PerformanceObserver.js +6 -6
  185. package/src/types/globals.d.ts +628 -0
  186. package/src/types/third_party/event-target-shim.d.ts +392 -0
  187. package/src-win/Libraries/Components/TextInput/Tests/TextInputTest.tsx +7 -7
  188. package/src-win/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +3 -3
  189. package/src-win/Libraries/Image/Tests/ImageWin32Test.tsx +1 -1
  190. package/src-win/Libraries/Text/Text.d.ts +1 -1
  191. package/types/index.d.ts +5 -52
  192. package/types/modules/globals.d.ts +0 -599
@@ -10,11 +10,13 @@
10
10
 
11
11
  import type {
12
12
  HostInstance,
13
- INativeMethods,
14
- InternalInstanceHandle,
13
+ LegacyHostInstanceMethods,
15
14
  MeasureInWindowOnSuccessCallback,
16
15
  MeasureLayoutOnSuccessCallback,
17
16
  MeasureOnSuccessCallback,
17
+ } from '../../../src/private/types/HostInstance';
18
+ import type {
19
+ InternalInstanceHandle,
18
20
  ViewConfig,
19
21
  } from '../../Renderer/shims/ReactNativeTypes';
20
22
 
@@ -38,7 +40,9 @@ const noop = () => {};
38
40
  /**
39
41
  * This is used for refs on host components.
40
42
  */
41
- export default class ReactFabricHostComponent implements INativeMethods {
43
+ export default class ReactFabricHostComponent
44
+ implements LegacyHostInstanceMethods
45
+ {
42
46
  // These need to be accessible from `ReactFabricPublicInstanceUtils`.
43
47
  __nativeTag: number;
44
48
  __internalInstanceHandle: InternalInstanceHandle;
@@ -56,12 +60,10 @@ export default class ReactFabricHostComponent implements INativeMethods {
56
60
  }
57
61
 
58
62
  blur() {
59
- // $FlowFixMe[incompatible-exact] Migrate all usages of `NativeMethods` to an interface to fix this.
60
63
  TextInputState.blurTextInput(this);
61
64
  }
62
65
 
63
66
  focus() {
64
- // $FlowFixMe[incompatible-exact] Migrate all usages of `NativeMethods` to an interface to fix this.
65
67
  TextInputState.focusTextInput(this);
66
68
  }
67
69
 
@@ -71,10 +71,7 @@ function getReadOnlyTextClass(): Class<ReadOnlyTextT> {
71
71
  }
72
72
 
73
73
  export function createPublicRootInstance(rootTag: RootTag): PublicRootInstance {
74
- if (
75
- ReactNativeFeatureFlags.enableAccessToHostTreeInFabric() &&
76
- ReactNativeFeatureFlags.enableDOMDocumentAPI()
77
- ) {
74
+ if (ReactNativeFeatureFlags.enableAccessToHostTreeInFabric()) {
78
75
  const ReactNativeDocumentModule = getReactNativeDocumentModule();
79
76
 
80
77
  // $FlowExpectedError[incompatible-return]
@@ -8,13 +8,11 @@
8
8
  * @flow strict-local
9
9
  */
10
10
 
11
+ import type {HostInstance} from '../../src/private/types/HostInstance';
11
12
  import type {
12
- HostComponent,
13
- HostInstance,
14
13
  InternalInstanceHandle,
15
14
  Node,
16
15
  } from '../Renderer/shims/ReactNativeTypes';
17
- import type ReactFabricHostComponent from './ReactFabricPublicInstance/ReactFabricHostComponent';
18
16
  import type {ElementRef, ElementType} from 'react';
19
17
 
20
18
  import {
@@ -136,8 +134,8 @@ export function isProfilingRenderer(): boolean {
136
134
  }
137
135
 
138
136
  export function isChildPublicInstance(
139
- parentInstance: ReactFabricHostComponent | HostComponent<empty>,
140
- childInstance: ReactFabricHostComponent | HostComponent<empty>,
137
+ parentInstance: HostInstance,
138
+ childInstance: HostInstance,
141
139
  ): boolean {
142
140
  return require('../Renderer/shims/ReactNative').default.isChildPublicInstance(
143
141
  parentInstance,
@@ -10,7 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
13
+ import type {HostComponent} from '../../src/private/types/HostComponent';
14
14
 
15
15
  const createReactNativeComponentClass =
16
16
  require('../Renderer/shims/createReactNativeComponentClass').default;
@@ -36,7 +36,19 @@ import typeof deepFreezeAndThrowOnMutationInDev from '../Utilities/deepFreezeAnd
36
36
  import typeof deepDiffer from '../Utilities/differ/deepDiffer';
37
37
  import typeof Platform from '../Utilities/Platform';
38
38
 
39
+ // Expose these types to the React renderer
40
+ export type {
41
+ HostInstance as PublicInstance,
42
+
43
+ // These types are only necessary for Paper
44
+ LegacyHostInstanceMethods as LegacyPublicInstance,
45
+ MeasureOnSuccessCallback,
46
+ MeasureInWindowOnSuccessCallback,
47
+ MeasureLayoutOnSuccessCallback,
48
+ } from '../../src/private/types/HostInstance';
49
+
39
50
  export type {PublicRootInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance';
51
+ export type PublicTextInstance = ReturnType<createPublicTextInstance>;
40
52
 
41
53
  // flowlint unsafe-getters-setters:off
42
54
  module.exports = {
@@ -7,35 +7,25 @@
7
7
  * @noformat
8
8
  * @nolint
9
9
  * @flow strict
10
- * @generated SignedSource<<c1ce40ef01008fe3cd38df1d9ff46f56>>
10
+ * @generated SignedSource<<5c76b092e0c981f96ca894e381ee593b>>
11
11
  */
12
12
 
13
- import type {ElementRef, ElementType, MixedElement} from 'react';
14
- // $FlowFixMe[nonstrict-import] TODO(@rubennorte)
15
- import {type PublicRootInstance} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
16
-
17
- export type MeasureOnSuccessCallback = (
18
- x: number,
19
- y: number,
20
- width: number,
21
- height: number,
22
- pageX: number,
23
- pageY: number,
24
- ) => void;
25
-
26
- export type MeasureInWindowOnSuccessCallback = (
27
- x: number,
28
- y: number,
29
- width: number,
30
- height: number,
31
- ) => void;
32
-
33
- export type MeasureLayoutOnSuccessCallback = (
34
- left: number,
35
- top: number,
36
- width: number,
37
- height: number,
38
- ) => void;
13
+ import type {
14
+ Component as ReactComponent,
15
+ ElementRef,
16
+ ElementType,
17
+ MixedElement,
18
+ } from 'react';
19
+ import type {
20
+ // $FlowFixMe[nonstrict-import] TODO(@rubennorte)
21
+ MeasureOnSuccessCallback,
22
+ // $FlowFixMe[nonstrict-import] TODO(@rubennorte)
23
+ PublicInstance,
24
+ // $FlowFixMe[nonstrict-import] TODO(@rubennorte)
25
+ PublicRootInstance,
26
+ // $FlowFixMe[nonstrict-import] TODO(@rubennorte)
27
+ PublicTextInstance,
28
+ } from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
39
29
 
40
30
  export type AttributeType<T, V> =
41
31
  | true
@@ -101,45 +91,6 @@ export type PartialViewConfig = $ReadOnly<{
101
91
  validAttributes?: PartialAttributeConfiguration,
102
92
  }>;
103
93
 
104
- /**
105
- * Current usages should migrate to this definition
106
- */
107
- export interface INativeMethods {
108
- blur(): void;
109
- focus(): void;
110
- measure(callback: MeasureOnSuccessCallback): void;
111
- measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;
112
- measureLayout(
113
- relativeToNativeNode: number | HostInstance,
114
- onSuccess: MeasureLayoutOnSuccessCallback,
115
- onFail?: () => void,
116
- ): void;
117
- setNativeProps(nativeProps: {...}): void;
118
- }
119
-
120
- export type NativeMethods = $ReadOnly<{
121
- blur(): void,
122
- focus(): void,
123
- measure(callback: MeasureOnSuccessCallback): void,
124
- measureInWindow(callback: MeasureInWindowOnSuccessCallback): void,
125
- measureLayout(
126
- relativeToNativeNode: number | HostInstance,
127
- onSuccess: MeasureLayoutOnSuccessCallback,
128
- onFail?: () => void,
129
- ): void,
130
- setNativeProps(nativeProps: {...}): void,
131
- }>;
132
-
133
- // This validates that INativeMethods and NativeMethods stay in sync using Flow!
134
- declare const ensureNativeMethodsAreSynced: NativeMethods;
135
- (ensureNativeMethodsAreSynced: INativeMethods);
136
-
137
- export type HostInstance = NativeMethods;
138
- export type HostComponent<Config: {...}> = component(
139
- ref: React$RefSetter<HostInstance>,
140
- ...Config
141
- );
142
-
143
94
  type InspectorDataProps = $ReadOnly<{
144
95
  [propName: string]: string,
145
96
  ...
@@ -165,18 +116,19 @@ export type InspectorData = $ReadOnly<{
165
116
  componentStack: string,
166
117
  }>;
167
118
 
168
- export type TouchedViewDataAtPoint = $ReadOnly<{
169
- pointerY: number,
170
- touchedViewTag?: number,
171
- frame: $ReadOnly<{
172
- top: number,
173
- left: number,
174
- width: number,
175
- height: number,
176
- }>,
177
- closestPublicInstance?: PublicInstance,
178
- ...InspectorData,
179
- }>;
119
+ export type TouchedViewDataAtPoint = $ReadOnly<
120
+ {
121
+ pointerY: number,
122
+ touchedViewTag?: number,
123
+ frame: $ReadOnly<{
124
+ top: number,
125
+ left: number,
126
+ width: number,
127
+ height: number,
128
+ }>,
129
+ closestPublicInstance?: PublicInstance,
130
+ } & InspectorData,
131
+ >;
180
132
 
181
133
  export type RenderRootOptions = {
182
134
  onUncaughtError?: (
@@ -188,7 +140,8 @@ export type RenderRootOptions = {
188
140
  errorInfo: {
189
141
  +componentStack?: ?string,
190
142
  // $FlowFixMe[unclear-type] unknown props and state.
191
- +errorBoundary?: ?React$Component<any, any>,
143
+ // $FlowFixMe[value-as-type] Component in react repo is any-typed, but it will be well typed externally.
144
+ +errorBoundary?: ?ReactComponent<any, any>,
192
145
  },
193
146
  ) => void,
194
147
  onRecoverableError?: (
@@ -204,20 +157,17 @@ export type RenderRootOptions = {
204
157
  export type ReactNativeType = {
205
158
  findHostInstance_DEPRECATED<TElementType: ElementType>(
206
159
  componentOrHandle: ?(ElementRef<TElementType> | number),
207
- ): ?HostInstance,
160
+ ): ?PublicInstance,
208
161
  findNodeHandle<TElementType: ElementType>(
209
162
  componentOrHandle: ?(ElementRef<TElementType> | number),
210
163
  ): ?number,
211
- isChildPublicInstance(
212
- parent: PublicInstance | HostComponent<empty>,
213
- child: PublicInstance | HostComponent<empty>,
214
- ): boolean,
164
+ isChildPublicInstance(parent: PublicInstance, child: PublicInstance): boolean,
215
165
  dispatchCommand(
216
- handle: HostInstance,
166
+ handle: PublicInstance,
217
167
  command: string,
218
168
  args: Array<mixed>,
219
169
  ): void,
220
- sendAccessibilityEvent(handle: HostInstance, eventType: string): void,
170
+ sendAccessibilityEvent(handle: PublicInstance, eventType: string): void,
221
171
  render(
222
172
  element: MixedElement,
223
173
  containerTag: number,
@@ -232,23 +182,21 @@ export type ReactNativeType = {
232
182
 
233
183
  export opaque type Node = mixed;
234
184
  export opaque type InternalInstanceHandle = mixed;
235
- type PublicInstance = mixed;
236
- type PublicTextInstance = mixed;
237
185
 
238
186
  export type ReactFabricType = {
239
187
  findHostInstance_DEPRECATED<TElementType: ElementType>(
240
188
  componentOrHandle: ?(ElementRef<TElementType> | number),
241
- ): ?HostInstance,
189
+ ): ?PublicInstance,
242
190
  findNodeHandle<TElementType: ElementType>(
243
191
  componentOrHandle: ?(ElementRef<TElementType> | number),
244
192
  ): ?number,
245
193
  dispatchCommand(
246
- handle: HostInstance,
194
+ handle: PublicInstance,
247
195
  command: string,
248
196
  args: Array<mixed>,
249
197
  ): void,
250
198
  isChildPublicInstance(parent: PublicInstance, child: PublicInstance): boolean,
251
- sendAccessibilityEvent(handle: HostInstance, eventType: string): void,
199
+ sendAccessibilityEvent(handle: PublicInstance, eventType: string): void,
252
200
  render(
253
201
  element: MixedElement,
254
202
  containerTag: number,
@@ -0,0 +1,22 @@
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
+ * @flow strict-local
9
+ */
10
+
11
+ import type {ProcessedColorValue} from './processColor';
12
+ import type {ColorValue, NativeColorValue} from './StyleSheet';
13
+
14
+ declare export function PlatformColor(...names: Array<string>): ColorValue;
15
+
16
+ declare export function normalizeColorObject(
17
+ color: NativeColorValue,
18
+ ): ?ProcessedColorValue;
19
+
20
+ declare export function processColorObject(
21
+ color: NativeColorValue,
22
+ ): ?NativeColorValue;
@@ -17,6 +17,12 @@ export type DynamicColorIOSTuple = {
17
17
  highContrastDark?: ColorValue,
18
18
  };
19
19
 
20
+ /**
21
+ * Specify color to display depending on the current system appearance settings
22
+ *
23
+ * @param tuple Colors you want to use for "light mode" and "dark mode"
24
+ * @platform ios
25
+ */
20
26
  export const DynamicColorIOS = (tuple: DynamicColorIOSTuple): ColorValue => {
21
27
  throw new Error('DynamicColorIOS is not available on this platform.');
22
28
  };
@@ -10,25 +10,21 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ import typeof * as StyleSheetExports from './StyleSheetExports';
13
14
  import type {
14
15
  ____ColorValue_Internal,
15
16
  ____DangerouslyImpreciseStyle_Internal,
16
17
  ____DangerouslyImpreciseStyleProp_Internal,
17
18
  ____ImageStyle_Internal,
18
19
  ____ImageStyleProp_Internal,
19
- ____Styles_Internal,
20
20
  ____TextStyle_Internal,
21
21
  ____TextStyleProp_Internal,
22
22
  ____ViewStyle_Internal,
23
23
  ____ViewStyleProp_Internal,
24
24
  } from './StyleSheetTypes';
25
-
26
- import composeStyles from '../../src/private/styles/composeStyles';
27
- import flatten from './flattenStyle';
28
-
29
- const ReactNativeStyleAttributes =
30
- require('../Components/View/ReactNativeStyleAttributes').default;
31
- const PixelRatio = require('../Utilities/PixelRatio').default;
25
+ const StyleSheet: StyleSheetExports = (
26
+ require('./StyleSheetExports') as $FlowFixMe
27
+ ).default;
32
28
 
33
29
  export type {NativeColorValue} from './StyleSheetTypes';
34
30
 
@@ -166,192 +162,4 @@ export type ImageStyle = ____ImageStyle_Internal;
166
162
  */
167
163
  export type DangerouslyImpreciseStyle = ____DangerouslyImpreciseStyle_Internal;
168
164
 
169
- let hairlineWidth: number = PixelRatio.roundToNearestPixel(0.4);
170
- if (hairlineWidth === 0) {
171
- hairlineWidth = 1 / PixelRatio.get();
172
- }
173
-
174
- const absoluteFill: {
175
- +bottom: 0,
176
- +left: 0,
177
- +position: 'absolute',
178
- +right: 0,
179
- +top: 0,
180
- } = {
181
- position: 'absolute',
182
- left: 0,
183
- right: 0,
184
- top: 0,
185
- bottom: 0,
186
- };
187
- if (__DEV__) {
188
- Object.freeze(absoluteFill);
189
- }
190
-
191
- /**
192
- * A StyleSheet is an abstraction similar to CSS StyleSheets
193
- *
194
- * Create a new StyleSheet:
195
- *
196
- * ```
197
- * const styles = StyleSheet.create({
198
- * container: {
199
- * borderRadius: 4,
200
- * borderWidth: 0.5,
201
- * borderColor: '#d6d7da',
202
- * },
203
- * title: {
204
- * fontSize: 19,
205
- * fontWeight: 'bold',
206
- * },
207
- * activeTitle: {
208
- * color: 'red',
209
- * },
210
- * });
211
- * ```
212
- *
213
- * Use a StyleSheet:
214
- *
215
- * ```
216
- * <View style={styles.container}>
217
- * <Text style={[styles.title, this.props.isActive && styles.activeTitle]} />
218
- * </View>
219
- * ```
220
- *
221
- * Code quality:
222
- *
223
- * - By moving styles away from the render function, you're making the code
224
- * easier to understand.
225
- * - Naming the styles is a good way to add meaning to the low level components
226
- * in the render function, and encourage reuse.
227
- * - In most IDEs, using `StyleSheet.create()` will offer static type checking
228
- * and suggestions to help you write valid styles.
229
- *
230
- */
231
- export default {
232
- /**
233
- * This is defined as the width of a thin line on the platform. It can be
234
- * used as the thickness of a border or division between two elements.
235
- * Example:
236
- * ```
237
- * {
238
- * borderBottomColor: '#bbb',
239
- * borderBottomWidth: StyleSheet.hairlineWidth
240
- * }
241
- * ```
242
- *
243
- * This constant will always be a round number of pixels (so a line defined
244
- * by it look crisp) and will try to match the standard width of a thin line
245
- * on the underlying platform. However, you should not rely on it being a
246
- * constant size, because on different platforms and screen densities its
247
- * value may be calculated differently.
248
- *
249
- * A line with hairline width may not be visible if your simulator is downscaled.
250
- */
251
- hairlineWidth,
252
-
253
- /**
254
- * A very common pattern is to create overlays with position absolute and zero positioning,
255
- * so `absoluteFill` can be used for convenience and to reduce duplication of these repeated
256
- * styles.
257
- */
258
- absoluteFill: (absoluteFill: any), // TODO: This should be updated after we fix downstream Flow sites.
259
-
260
- /**
261
- * Sometimes you may want `absoluteFill` but with a couple tweaks - `absoluteFillObject` can be
262
- * used to create a customized entry in a `StyleSheet`, e.g.:
263
- *
264
- * const styles = StyleSheet.create({
265
- * wrapper: {
266
- * ...StyleSheet.absoluteFillObject,
267
- * top: 10,
268
- * backgroundColor: 'transparent',
269
- * },
270
- * });
271
- */
272
- absoluteFillObject: absoluteFill,
273
-
274
- /**
275
- * Combines two styles such that `style2` will override any styles in `style1`.
276
- * If either style is falsy, the other one is returned without allocating an
277
- * array, saving allocations and maintaining reference equality for
278
- * PureComponent checks.
279
- */
280
- compose: composeStyles,
281
-
282
- /**
283
- * Flattens an array of style objects, into one aggregated style object.
284
- *
285
- * Example:
286
- * ```
287
- * const styles = StyleSheet.create({
288
- * listItem: {
289
- * flex: 1,
290
- * fontSize: 16,
291
- * color: 'white'
292
- * },
293
- * selectedListItem: {
294
- * color: 'green'
295
- * }
296
- * });
297
- *
298
- * StyleSheet.flatten([styles.listItem, styles.selectedListItem])
299
- * // returns { flex: 1, fontSize: 16, color: 'green' }
300
- * ```
301
- */
302
- flatten,
303
-
304
- /**
305
- * WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will
306
- * not be reliably announced. The whole thing might be deleted, who knows? Use
307
- * at your own risk.
308
- *
309
- * Sets a function to use to pre-process a style property value. This is used
310
- * internally to process color and transform values. You should not use this
311
- * unless you really know what you are doing and have exhausted other options.
312
- */
313
- setStyleAttributePreprocessor(
314
- property: string,
315
- process: (nextProp: mixed) => mixed,
316
- ) {
317
- let value;
318
-
319
- if (ReactNativeStyleAttributes[property] === true) {
320
- value = {process};
321
- } else if (typeof ReactNativeStyleAttributes[property] === 'object') {
322
- value = {...ReactNativeStyleAttributes[property], process};
323
- } else {
324
- console.error(`${property} is not a valid style attribute`);
325
- return;
326
- }
327
-
328
- if (
329
- __DEV__ &&
330
- typeof value.process === 'function' &&
331
- typeof ReactNativeStyleAttributes[property]?.process === 'function' &&
332
- value.process !== ReactNativeStyleAttributes[property]?.process
333
- ) {
334
- console.warn(`Overwriting ${property} style attribute preprocessor`);
335
- }
336
-
337
- ReactNativeStyleAttributes[property] = value;
338
- },
339
-
340
- /**
341
- * An identity function for creating style sheets.
342
- */
343
- // $FlowFixMe[unsupported-variance-annotation]
344
- create<+S: ____Styles_Internal>(obj: S): $ReadOnly<S> {
345
- // TODO: This should return S as the return type. But first,
346
- // we need to codemod all the callsites that are typing this
347
- // return value as a number (even though it was opaque).
348
- if (__DEV__) {
349
- for (const key in obj) {
350
- if (obj[key]) {
351
- Object.freeze(obj[key]);
352
- }
353
- }
354
- }
355
- return obj;
356
- },
357
- };
165
+ export default StyleSheet;