@office-iss/react-native-win32 0.81.2 → 0.82.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 (209) hide show
  1. package/.flowconfig +3 -11
  2. package/CHANGELOG.json +118 -43
  3. package/CHANGELOG.md +45 -27
  4. package/IntegrationTests/IntegrationTestsApp.js +2 -2
  5. package/IntegrationTests/LayoutEventsTest.js +3 -3
  6. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -3
  7. package/Libraries/Alert/RCTAlertManager.android.js +4 -2
  8. package/Libraries/Animated/Animated.d.ts +2 -0
  9. package/Libraries/Animated/AnimatedEvent.js +1 -1
  10. package/Libraries/Animated/AnimatedExports.js.flow +1 -0
  11. package/Libraries/Animated/AnimatedImplementation.js +4 -2
  12. package/Libraries/Animated/AnimatedMock.js +1 -1
  13. package/Libraries/Animated/Easing.js +2 -0
  14. package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
  15. package/Libraries/Animated/animations/Animation.js +19 -20
  16. package/Libraries/Animated/animations/TimingAnimation.js +2 -0
  17. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  18. package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
  19. package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
  20. package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
  21. package/Libraries/Animated/nodes/AnimatedNode.js +14 -7
  22. package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
  23. package/Libraries/Animated/nodes/AnimatedProps.js +32 -32
  24. package/Libraries/Animated/nodes/AnimatedStyle.js +23 -21
  25. package/Libraries/Animated/nodes/AnimatedTransform.js +6 -6
  26. package/Libraries/Animated/nodes/AnimatedValue.js +18 -26
  27. package/Libraries/AppState/AppState.js +8 -4
  28. package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
  29. package/Libraries/BatchedBridge/MessageQueue.js +5 -0
  30. package/Libraries/BatchedBridge/NativeModules.js +1 -1
  31. package/Libraries/Blob/BlobManager.js +1 -1
  32. package/Libraries/Blob/URLSearchParams.js +2 -0
  33. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -2
  34. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -2
  35. package/Libraries/Components/Button.js +1 -1
  36. package/Libraries/Components/Button.win32.js +1 -1
  37. package/Libraries/Components/Pressable/Pressable.js +10 -1
  38. package/Libraries/Components/Pressable/Pressable.win32.js +9 -0
  39. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  40. package/Libraries/Components/ScrollView/ScrollView.js +13 -4
  41. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  42. package/Libraries/Components/StatusBar/StatusBar.js +2 -2
  43. package/Libraries/Components/Switch/Switch.js +1 -1
  44. package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
  45. package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
  46. package/Libraries/Components/TextInput/TextInput.js +14 -5
  47. package/Libraries/Components/TextInput/TextInput.win32.js +15 -7
  48. package/Libraries/Components/TextInput/TextInputState.js +1 -1
  49. package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
  50. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
  51. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  52. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  53. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  54. package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
  55. package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
  56. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  57. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
  58. package/Libraries/Components/View/View.js +81 -167
  59. package/Libraries/Components/View/View.win32.js +3 -1
  60. package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
  61. package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
  62. package/Libraries/Core/ExceptionsManager.js +4 -2
  63. package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
  64. package/Libraries/Core/ReactNativeVersion.js +37 -10
  65. package/Libraries/Core/Timers/JSTimers.js +4 -1
  66. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  67. package/Libraries/Core/Timers/immediateShim.js +2 -1
  68. package/Libraries/Core/Timers/queueMicrotask.js +1 -0
  69. package/Libraries/Core/setUpPerformance.js +3 -4
  70. package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
  71. package/Libraries/Image/Image.android.js +327 -111
  72. package/Libraries/Image/Image.ios.js +6 -1
  73. package/Libraries/Image/Image.win32.js +6 -1
  74. package/Libraries/Image/ImageSourceUtils.js +8 -2
  75. package/Libraries/Image/assetPaths.js +1 -1
  76. package/Libraries/Image/resolveAssetSource.js +1 -1
  77. package/Libraries/Image/resolveAssetSource.win32.js +6 -7
  78. package/Libraries/Interaction/InteractionManager.js +118 -167
  79. package/Libraries/Interaction/PanResponder.js +7 -52
  80. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
  81. package/Libraries/Lists/FlatList.js +5 -6
  82. package/Libraries/LogBox/Data/LogBoxData.js +5 -2
  83. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  84. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +2 -2
  85. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
  86. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
  87. package/Libraries/Modal/Modal.js +3 -3
  88. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  89. package/Libraries/NativeComponent/ViewConfig.js +2 -2
  90. package/Libraries/Network/RCTNetworking.android.js +1 -1
  91. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  92. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  93. package/Libraries/Network/XMLHttpRequest.js +20 -5
  94. package/Libraries/Network/convertRequestBody.js +1 -1
  95. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
  96. package/Libraries/Pressability/HoverState.js +2 -0
  97. package/Libraries/Pressability/HoverState.win32.js +2 -0
  98. package/Libraries/Pressability/Pressability.js +1 -1
  99. package/Libraries/Pressability/Pressability.win32.js +1 -1
  100. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
  101. package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
  102. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
  103. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
  104. package/Libraries/ReactNative/RendererImplementation.js +116 -116
  105. package/Libraries/ReactNative/UIManager.js +3 -3
  106. package/Libraries/ReactNative/renderApplication.js +1 -0
  107. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
  108. package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
  109. package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
  110. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
  111. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
  112. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
  113. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
  114. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  115. package/Libraries/Share/Share.js +4 -0
  116. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  117. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
  118. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
  119. package/Libraries/StyleSheet/StyleSheet.d.ts +7 -22
  120. package/Libraries/StyleSheet/StyleSheetExports.js +2 -8
  121. package/Libraries/StyleSheet/StyleSheetExports.js.flow +11 -18
  122. package/Libraries/StyleSheet/flattenStyle.js +2 -2
  123. package/Libraries/StyleSheet/processAspectRatio.js +2 -0
  124. package/Libraries/StyleSheet/processFilter.js +5 -5
  125. package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
  126. package/Libraries/Text/Text.js +534 -234
  127. package/Libraries/Text/Text.win32.js +647 -274
  128. package/Libraries/Text/TextNativeComponent.js +2 -2
  129. package/Libraries/Text/TextNativeComponent.win32.js +2 -2
  130. package/Libraries/Utilities/Appearance.d.ts +3 -5
  131. package/Libraries/Utilities/Appearance.js +5 -17
  132. package/Libraries/Utilities/HMRClient.js +2 -1
  133. package/Libraries/Utilities/Platform.android.js +3 -3
  134. package/Libraries/Utilities/Platform.d.ts +1 -0
  135. package/Libraries/Utilities/Platform.ios.js +1 -1
  136. package/Libraries/Utilities/Platform.win32.js +3 -3
  137. package/Libraries/Utilities/PlatformTypes.js +1 -1
  138. package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
  139. package/Libraries/Utilities/SceneTracker.js +1 -1
  140. package/Libraries/Utilities/codegenNativeCommands.js +1 -1
  141. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  142. package/Libraries/Utilities/createPerformanceLogger.js +32 -0
  143. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
  144. package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
  145. package/Libraries/Utilities/useMergeRefs.js +1 -1
  146. package/Libraries/WebSocket/WebSocketInterceptor.js +2 -0
  147. package/Libraries/promiseRejectionTrackingOptions.js +17 -31
  148. package/Libraries/vendor/emitter/EventEmitter.js +1 -1
  149. package/flow/bom.js.flow +223 -1
  150. package/flow/prettier.js.flow +14 -0
  151. package/index.js +14 -2
  152. package/index.win32.js +16 -2
  153. package/jest/local-setup.js +2 -2
  154. package/jest/mock.js +1 -1
  155. package/jest/mockComponent.js +9 -9
  156. package/jest/mockNativeComponent.js +3 -2
  157. package/jest/mocks/Modal.js +1 -1
  158. package/jest/mocks/ScrollView.js +1 -1
  159. package/jest/mocks/ViewNativeComponent.js +1 -1
  160. package/jest/setup.js +23 -12
  161. package/overrides.json +23 -23
  162. package/package.json +28 -27
  163. package/saveAssetPlugin.js +2 -2
  164. package/src/private/animated/NativeAnimatedHelper.js +16 -5
  165. package/src/private/animated/NativeAnimatedHelper.win32.js +16 -5
  166. package/src/private/animated/createAnimatedPropsHook.js +11 -60
  167. package/src/private/animated/createAnimatedPropsMemoHook.js +8 -54
  168. package/src/private/components/virtualview/VirtualView.js +43 -12
  169. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
  170. package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
  171. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
  172. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
  173. package/src/private/featureflags/ReactNativeFeatureFlags.js +85 -52
  174. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
  175. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +15 -6
  176. package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
  177. package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
  178. package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
  179. package/src/private/types/HostInstance.js +4 -1
  180. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
  181. package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
  182. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
  183. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
  184. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
  185. package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
  186. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
  187. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +15 -12
  188. package/src/private/webapis/dom/oldstylecollections/NodeList.js +14 -11
  189. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  190. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
  191. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
  192. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
  193. package/src/private/webapis/performance/EventTiming.js +40 -25
  194. package/src/private/webapis/performance/LongTasks.js +35 -2
  195. package/src/private/webapis/performance/Performance.js +347 -166
  196. package/src/private/webapis/performance/PerformanceEntry.js +40 -23
  197. package/src/private/webapis/performance/PerformanceObserver.js +37 -29
  198. package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
  199. package/src/private/webapis/performance/ResourceTiming.js +29 -18
  200. package/src/private/webapis/performance/UserTiming.js +92 -34
  201. package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
  202. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
  203. package/src/private/webapis/performance/internals/Utilities.js +9 -0
  204. package/src/private/webapis/performance/specs/NativePerformance.js +23 -23
  205. package/src/private/webapis/structuredClone/structuredClone.js +10 -10
  206. package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  207. package/Libraries/Interaction/InteractionManagerStub.js +0 -184
  208. package/Libraries/Interaction/TaskQueue.js +0 -183
  209. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -31
@@ -61,7 +61,7 @@ function structuredCloneInternal<T>(value: T): T {
61
61
 
62
62
  // Handles circular references.
63
63
  if (memory.has(value)) {
64
- // $FlowExpectedError[incompatible-return] we know memory.get(value) is T
64
+ // $FlowExpectedError[incompatible-type] we know memory.get(value) is T
65
65
  return memory.get(value);
66
66
  }
67
67
 
@@ -74,12 +74,12 @@ function structuredCloneInternal<T>(value: T): T {
74
74
  result[key] = structuredCloneInternal(value[key]);
75
75
  }
76
76
 
77
- // $FlowExpectedError[incompatible-return] we know result is T
77
+ // $FlowExpectedError[incompatible-type] we know result is T
78
78
  return result;
79
79
  }
80
80
 
81
81
  // Simple object fast path
82
- // $FlowIssue[prop-missing] Why doesn't Flow know about Object.prototype?
82
+ // $FlowFixMe[prop-missing] Why doesn't Flow know about Object.prototype?
83
83
  if (Object.getPrototypeOf(value) === ObjectPrototype) {
84
84
  const result = {};
85
85
  memory.set(value, result);
@@ -89,7 +89,7 @@ function structuredCloneInternal<T>(value: T): T {
89
89
  result[key] = structuredCloneInternal(value[key]);
90
90
  }
91
91
 
92
- // $FlowExpectedError[incompatible-return] we know result is T
92
+ // $FlowExpectedError[incompatible-type] we know result is T
93
93
  return result;
94
94
  }
95
95
 
@@ -99,7 +99,7 @@ function structuredCloneInternal<T>(value: T): T {
99
99
  if (value instanceof Cls) {
100
100
  const result = new Cls(value);
101
101
  memory.set(value, result);
102
- // $FlowExpectedError[incompatible-return] we know result is T
102
+ // $FlowExpectedError[incompatible-type] we know result is T
103
103
  return result;
104
104
  }
105
105
  }
@@ -115,7 +115,7 @@ function structuredCloneInternal<T>(value: T): T {
115
115
  );
116
116
  }
117
117
 
118
- // $FlowExpectedError[incompatible-return] we know result is T
118
+ // $FlowExpectedError[incompatible-type] we know result is T
119
119
  return result;
120
120
  }
121
121
 
@@ -127,7 +127,7 @@ function structuredCloneInternal<T>(value: T): T {
127
127
  result.add(structuredCloneInternal(innerValue));
128
128
  }
129
129
 
130
- // $FlowExpectedError[incompatible-return] we know result is T
130
+ // $FlowExpectedError[incompatible-type] we know result is T
131
131
  return result;
132
132
  }
133
133
 
@@ -135,7 +135,7 @@ function structuredCloneInternal<T>(value: T): T {
135
135
  const result = new RegExp(value.source, value.flags);
136
136
  memory.set(value, result);
137
137
 
138
- // $FlowExpectedError[incompatible-return] we know result is T
138
+ // $FlowExpectedError[incompatible-type] we know result is T
139
139
  return result;
140
140
  }
141
141
 
@@ -162,7 +162,7 @@ function structuredCloneInternal<T>(value: T): T {
162
162
 
163
163
  result.stack = value.stack;
164
164
 
165
- // $FlowExpectedError[incompatible-return] we know result is T
165
+ // $FlowExpectedError[incompatible-type] we know result is T
166
166
  return result;
167
167
  }
168
168
 
@@ -185,7 +185,7 @@ function structuredCloneInternal<T>(value: T): T {
185
185
  result[key] = structuredCloneInternal(value[key]);
186
186
  }
187
187
 
188
- // $FlowExpectedError[incompatible-return] we know result is T
188
+ // $FlowExpectedError[incompatible-type] we know result is T
189
189
  return result;
190
190
  }
191
191
 
@@ -30,7 +30,7 @@ import { IKeyboardEvent } from '../View/ViewPropTypes';
30
30
  const BoundingDimensions = require('./BoundingDimensions');
31
31
  const Position = require('./Position');
32
32
 
33
- const {findNodeHandle} = require('../../ReactNative/RendererProxy');
33
+ const {findNodeHandle} = require('../../Renderer/shims/ReactNative');
34
34
 
35
35
  /**
36
36
  * Extracts a single touch, generally this is the active touch or touch that
@@ -1,184 +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
- * @flow strict
8
- * @format
9
- */
10
-
11
- import type {EventSubscription} from '../vendor/emitter/EventEmitter';
12
-
13
- const invariant = require('invariant');
14
-
15
- export type Handle = number;
16
-
17
- type Task =
18
- | {
19
- name: string,
20
- run: () => void,
21
- }
22
- | {
23
- name: string,
24
- gen: () => Promise<void>,
25
- }
26
- | (() => void);
27
-
28
- // NOTE: The original implementation of `InteractionManager` never rejected
29
- // the returned promise. This preserves that behavior in the stub.
30
- function reject(error: Error): void {
31
- setTimeout(() => {
32
- throw error;
33
- }, 0);
34
- }
35
-
36
- /**
37
- * InteractionManager allows long-running work to be scheduled after any
38
- * interactions/animations have completed. In particular, this allows JavaScript
39
- * animations to run smoothly.
40
- *
41
- * Applications can schedule tasks to run after interactions with the following:
42
- *
43
- * ```
44
- * InteractionManager.runAfterInteractions(() => {
45
- * // ...long-running synchronous task...
46
- * });
47
- * ```
48
- *
49
- * Compare this to other scheduling alternatives:
50
- *
51
- * - requestAnimationFrame(): for code that animates a view over time.
52
- * - setImmediate/setTimeout(): run code later, note this may delay animations.
53
- * - runAfterInteractions(): run code later, without delaying active animations.
54
- *
55
- * The touch handling system considers one or more active touches to be an
56
- * 'interaction' and will delay `runAfterInteractions()` callbacks until all
57
- * touches have ended or been cancelled.
58
- *
59
- * InteractionManager also allows applications to register animations by
60
- * creating an interaction 'handle' on animation start, and clearing it upon
61
- * completion:
62
- *
63
- * ```
64
- * var handle = InteractionManager.createInteractionHandle();
65
- * // run animation... (`runAfterInteractions` tasks are queued)
66
- * // later, on animation completion:
67
- * InteractionManager.clearInteractionHandle(handle);
68
- * // queued tasks run if all handles were cleared
69
- * ```
70
- *
71
- * `runAfterInteractions` takes either a plain callback function, or a
72
- * `PromiseTask` object with a `gen` method that returns a `Promise`. If a
73
- * `PromiseTask` is supplied, then it is fully resolved (including asynchronous
74
- * dependencies that also schedule more tasks via `runAfterInteractions`) before
75
- * starting on the next task that might have been queued up synchronously
76
- * earlier.
77
- *
78
- * By default, queued tasks are executed together in a loop in one
79
- * `setImmediate` batch. If `setDeadline` is called with a positive number, then
80
- * tasks will only be executed until the deadline (in terms of js event loop run
81
- * time) approaches, at which point execution will yield via setTimeout,
82
- * allowing events such as touches to start interactions and block queued tasks
83
- * from executing, making apps more responsive.
84
- *
85
- * @deprecated
86
- */
87
- const InteractionManagerStub = {
88
- Events: {
89
- interactionStart: 'interactionStart',
90
- interactionComplete: 'interactionComplete',
91
- },
92
-
93
- /**
94
- * Schedule a function to run after all interactions have completed. Returns a cancellable
95
- * "promise".
96
- *
97
- * @deprecated
98
- */
99
- runAfterInteractions(task: ?Task): {
100
- then: <U>(
101
- onFulfill?: ?(void) => ?(Promise<U> | U),
102
- onReject?: ?(error: mixed) => ?(Promise<U> | U),
103
- ) => Promise<U>,
104
- cancel: () => void,
105
- ...
106
- } {
107
- let immediateID: ?$FlowIssue;
108
- const promise = new Promise(resolve => {
109
- immediateID = setImmediate(() => {
110
- if (typeof task === 'object' && task !== null) {
111
- if (typeof task.gen === 'function') {
112
- task.gen().then(resolve, reject);
113
- } else if (typeof task.run === 'function') {
114
- try {
115
- task.run();
116
- resolve();
117
- } catch (error) {
118
- reject(error);
119
- }
120
- } else {
121
- reject(new TypeError(`Task "${task.name}" missing gen or run.`));
122
- }
123
- } else if (typeof task === 'function') {
124
- try {
125
- task();
126
- resolve();
127
- } catch (error) {
128
- reject(error);
129
- }
130
- } else {
131
- reject(new TypeError('Invalid task of type: ' + typeof task));
132
- }
133
- });
134
- });
135
-
136
- return {
137
- // $FlowFixMe[method-unbinding] added when improving typing for this parameters
138
- then: promise.then.bind(promise),
139
- cancel() {
140
- clearImmediate(immediateID);
141
- },
142
- };
143
- },
144
-
145
- /**
146
- * Notify manager that an interaction has started.
147
- *
148
- * @deprecated
149
- */
150
- createInteractionHandle(): Handle {
151
- return -1;
152
- },
153
-
154
- /**
155
- * Notify manager that an interaction has completed.
156
- *
157
- * @deprecated
158
- */
159
- clearInteractionHandle(handle: Handle) {
160
- invariant(!!handle, 'InteractionManager: Must provide a handle to clear.');
161
- },
162
-
163
- /**
164
- * @deprecated
165
- */
166
- addListener(): EventSubscription {
167
- return {
168
- remove() {},
169
- };
170
- },
171
-
172
- /**
173
- * A positive number will use setTimeout to schedule any tasks after the
174
- * eventLoopRunningTime hits the deadline value, otherwise all tasks will be
175
- * executed in one setImmediate batch (default).
176
- *
177
- * @deprecated
178
- */
179
- setDeadline(deadline: number) {
180
- // Do nothing.
181
- },
182
- };
183
-
184
- export default InteractionManagerStub;
@@ -1,183 +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
- * @flow strict
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- const invariant = require('invariant');
14
-
15
- export type SimpleTask = {
16
- name: string,
17
- run: () => void,
18
- };
19
- export type PromiseTask = {
20
- name: string,
21
- gen: () => Promise<void>,
22
- };
23
- export type Task = SimpleTask | PromiseTask | (() => void);
24
-
25
- const DEBUG: false = false;
26
-
27
- /**
28
- * TaskQueue - A system for queueing and executing a mix of simple callbacks and
29
- * trees of dependent tasks based on Promises. No tasks are executed unless
30
- * `processNext` is called.
31
- *
32
- * `enqueue` takes a Task object with either a simple `run` callback, or a
33
- * `gen` function that returns a `Promise` and puts it in the queue. If a gen
34
- * function is supplied, then the promise it returns will block execution of
35
- * tasks already in the queue until it resolves. This can be used to make sure
36
- * the first task is fully resolved (including asynchronous dependencies that
37
- * also schedule more tasks via `enqueue`) before starting on the next task.
38
- * The `onMoreTasks` constructor argument is used to inform the owner that an
39
- * async task has resolved and that the queue should be processed again.
40
- *
41
- * Note: Tasks are only actually executed with explicit calls to `processNext`.
42
- */
43
- class TaskQueue {
44
- /**
45
- * TaskQueue instances are self contained and independent, so multiple tasks
46
- * of varying semantics and priority can operate together.
47
- *
48
- * `onMoreTasks` is invoked when `PromiseTask`s resolve if there are more
49
- * tasks to process.
50
- */
51
- constructor({onMoreTasks}: {onMoreTasks: () => void, ...}) {
52
- this._onMoreTasks = onMoreTasks;
53
- this._queueStack = [{tasks: [], popable: false}];
54
- }
55
-
56
- /**
57
- * Add a task to the queue. It is recommended to name your tasks for easier
58
- * async debugging. Tasks will not be executed until `processNext` is called
59
- * explicitly.
60
- */
61
- enqueue(task: Task): void {
62
- this._getCurrentQueue().push(task);
63
- }
64
-
65
- enqueueTasks(tasks: Array<Task>): void {
66
- tasks.forEach(task => this.enqueue(task));
67
- }
68
-
69
- cancelTasks(tasksToCancel: Array<Task>): void {
70
- // search through all tasks and remove them.
71
- this._queueStack = this._queueStack
72
- .map(queue => ({
73
- ...queue,
74
- tasks: queue.tasks.filter(task => tasksToCancel.indexOf(task) === -1),
75
- }))
76
- .filter((queue, idx) => queue.tasks.length > 0 || idx === 0);
77
- }
78
-
79
- /**
80
- * Check to see if `processNext` should be called.
81
- *
82
- * @returns {boolean} Returns true if there are tasks that are ready to be
83
- * processed with `processNext`, or returns false if there are no more tasks
84
- * to be processed right now, although there may be tasks in the queue that
85
- * are blocked by earlier `PromiseTask`s that haven't resolved yet.
86
- * `onMoreTasks` will be called after each `PromiseTask` resolves if there are
87
- * tasks ready to run at that point.
88
- */
89
- hasTasksToProcess(): boolean {
90
- return this._getCurrentQueue().length > 0;
91
- }
92
-
93
- /**
94
- * Executes the next task in the queue.
95
- */
96
- processNext(): void {
97
- const queue = this._getCurrentQueue();
98
- if (queue.length) {
99
- const task = queue.shift();
100
- try {
101
- if (typeof task === 'object' && task.gen) {
102
- DEBUG && console.log('TaskQueue: genPromise for task ' + task.name);
103
- this._genPromise(task);
104
- } else if (typeof task === 'object' && task.run) {
105
- DEBUG && console.log('TaskQueue: run task ' + task.name);
106
- task.run();
107
- } else {
108
- invariant(
109
- typeof task === 'function',
110
- 'Expected Function, SimpleTask, or PromiseTask, but got:\n' +
111
- JSON.stringify(task, null, 2),
112
- );
113
- DEBUG && console.log('TaskQueue: run anonymous task');
114
- task();
115
- }
116
- } catch (e) {
117
- e.message =
118
- // $FlowFixMe[incompatible-type]
119
- // $FlowFixMe[incompatible-use]
120
- 'TaskQueue: Error with task ' + (task.name || '') + ': ' + e.message;
121
- throw e;
122
- }
123
- }
124
- }
125
-
126
- _queueStack: Array<{
127
- tasks: Array<Task>,
128
- popable: boolean,
129
- ...
130
- }>;
131
- _onMoreTasks: () => void;
132
-
133
- _getCurrentQueue(): Array<Task> {
134
- const stackIdx = this._queueStack.length - 1;
135
- const queue = this._queueStack[stackIdx];
136
- if (
137
- queue.popable &&
138
- queue.tasks.length === 0 &&
139
- this._queueStack.length > 1
140
- ) {
141
- this._queueStack.pop();
142
- DEBUG &&
143
- console.log('TaskQueue: popped queue: ', {
144
- stackIdx,
145
- queueStackSize: this._queueStack.length,
146
- });
147
- return this._getCurrentQueue();
148
- } else {
149
- return queue.tasks;
150
- }
151
- }
152
-
153
- _genPromise(task: PromiseTask) {
154
- // Each async task pushes it's own queue onto the queue stack. This
155
- // effectively defers execution of previously queued tasks until the promise
156
- // resolves, at which point we allow the new queue to be popped, which
157
- // happens once it is fully processed.
158
- this._queueStack.push({tasks: [], popable: false});
159
- const stackIdx = this._queueStack.length - 1;
160
- const stackItem = this._queueStack[stackIdx];
161
- DEBUG && console.log('TaskQueue: push new queue: ', {stackIdx});
162
- DEBUG && console.log('TaskQueue: exec gen task ' + task.name);
163
- task
164
- .gen()
165
- .then(() => {
166
- DEBUG &&
167
- console.log('TaskQueue: onThen for gen task ' + task.name, {
168
- stackIdx,
169
- queueStackSize: this._queueStack.length,
170
- });
171
- stackItem.popable = true;
172
- this.hasTasksToProcess() && this._onMoreTasks();
173
- })
174
- .catch(ex => {
175
- setTimeout(() => {
176
- ex.message = `TaskQueue: Error resolving Promise in task ${task.name}: ${ex.message}`;
177
- throw ex;
178
- }, 0);
179
- });
180
- }
181
- }
182
-
183
- export default TaskQueue;
@@ -1,31 +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
- * @flow strict
8
- * @format
9
- */
10
-
11
- export type FeatureFlags = {
12
- /**
13
- * Function used to enable / disable W3C pointer event emitting in React Native.
14
- * If enabled you must also flip the equivalent native flags on each platform:
15
- * iOS -> RCTSetDispatchW3CPointerEvents
16
- * Android -> ReactFeatureFlags.dispatchPointerEvents
17
- */
18
- shouldEmitW3CPointerEvents: () => boolean,
19
- /**
20
- * Function used to enable / disable Pressibility from using W3C Pointer Events
21
- * for its hover callbacks
22
- */
23
- shouldPressibilityUseW3CPointerEventsForHover: () => boolean,
24
- };
25
-
26
- const ReactNativeFeatureFlags: FeatureFlags = {
27
- shouldEmitW3CPointerEvents: () => false,
28
- shouldPressibilityUseW3CPointerEventsForHover: () => false,
29
- };
30
-
31
- export default ReactNativeFeatureFlags;