@office-iss/react-native-win32 0.0.0-canary.288 → 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 (59) hide show
  1. package/.flowconfig +3 -2
  2. package/CHANGELOG.json +22 -1
  3. package/CHANGELOG.md +16 -7
  4. package/Libraries/Alert/Alert.d.ts +4 -1
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/Animated/Easing.js +13 -15
  7. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  8. package/Libraries/Animated/nodes/AnimatedNode.js +2 -1
  9. package/Libraries/Animated/nodes/AnimatedProps.js +18 -1
  10. package/Libraries/Animated/nodes/AnimatedValue.js +6 -2
  11. package/Libraries/Blob/URL.js +23 -10
  12. package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +2 -1
  13. package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
  14. package/Libraries/Components/TextInput/TextInput.d.ts +6 -0
  15. package/Libraries/Components/TextInput/TextInput.flow.js +36 -3
  16. package/Libraries/Components/TextInput/TextInput.js +101 -110
  17. package/Libraries/Components/TextInput/TextInput.win32.js +102 -111
  18. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +2 -1
  19. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  20. package/Libraries/Core/ReactNativeVersion.js +2 -2
  21. package/Libraries/Image/Tests/ImageWin32Test.d.ts +2 -1
  22. package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
  23. package/Libraries/Interaction/TaskQueue.js +1 -0
  24. package/Libraries/Modal/Modal.js +30 -4
  25. package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
  26. package/Libraries/ReactNative/AppRegistry.js +2 -322
  27. package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
  28. package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
  29. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
  30. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
  31. package/Libraries/StyleSheet/StyleSheet.js +5 -197
  32. package/Libraries/StyleSheet/StyleSheet.js.flow +166 -0
  33. package/Libraries/StyleSheet/{StyleSheet.win32.js → StyleSheetExports.js} +2 -151
  34. package/Libraries/StyleSheet/StyleSheetExports.js.flow +110 -0
  35. package/Libraries/StyleSheet/StyleSheetTypes.js +42 -18
  36. package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
  37. package/Libraries/{Modal/ModalInjection.js → Types/CodegenTypesNamespace.js} +4 -5
  38. package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
  39. package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
  40. package/Libraries/vendor/emitter/EventEmitter.js +6 -2
  41. package/flow/global.js +1 -0
  42. package/flow/jest.js +4 -2
  43. package/index.js +47 -43
  44. package/index.win32.js +60 -55
  45. package/overrides.json +8 -16
  46. package/package.json +14 -14
  47. package/src/private/animated/NativeAnimatedHelper.js +18 -7
  48. package/src/private/animated/NativeAnimatedHelper.win32.js +18 -7
  49. package/src/private/animated/createAnimatedPropsHook.js +34 -15
  50. package/src/private/featureflags/ReactNativeFeatureFlags.js +14 -31
  51. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +9 -1
  52. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -3
  53. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -18
  54. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
  55. package/src/types/third_party/event-target-shim.d.ts +392 -0
  56. package/src-win/Libraries/Components/TextInput/Tests/TextInputTest.tsx +7 -7
  57. package/src-win/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +3 -3
  58. package/src-win/Libraries/Image/Tests/ImageWin32Test.tsx +1 -1
  59. package/types/index.d.ts +4 -0
@@ -24,6 +24,7 @@ import {
24
24
  useCallback,
25
25
  useEffect,
26
26
  useInsertionEffect,
27
+ useMemo,
27
28
  useReducer,
28
29
  useRef,
29
30
  } from 'react';
@@ -51,6 +52,31 @@ export default function createAnimatedPropsHook(
51
52
  ): AnimatedPropsHook {
52
53
  const useAnimatedPropsMemo = createAnimatedPropsMemoHook(allowlist);
53
54
 
55
+ const useNativePropsInFabric =
56
+ ReactNativeFeatureFlags.shouldUseSetNativePropsInFabric();
57
+
58
+ const useNativeAnimatedEvents: <TProps: {...}>(
59
+ node: AnimatedProps,
60
+ props: TProps,
61
+ ) => $ReadOnlyArray<[string, AnimatedEvent]> =
62
+ ReactNativeFeatureFlags.avoidAnimatedRefInvalidation()
63
+ ? function useNativeAnimatedEventsFromAnimatedProps(node, props) {
64
+ return useMemo(() => node.__getNativeAnimatedEventTuples(), [node]);
65
+ }
66
+ : function useNativeAnimatedEventsFromProps(node, props) {
67
+ return useMemo(() => {
68
+ const tuples = [];
69
+ for (const propName in props) {
70
+ // $FlowFixMe[invalid-computed-prop]
71
+ const propValue = props[propName];
72
+ if (propValue instanceof AnimatedEvent && propValue.__isNative) {
73
+ tuples.push([propName, propValue]);
74
+ }
75
+ }
76
+ return tuples;
77
+ }, [props]);
78
+ };
79
+
54
80
  return function useAnimatedProps<TProps: {...}, TInstance>(
55
81
  props: TProps,
56
82
  ): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
@@ -63,9 +89,6 @@ export default function createAnimatedPropsHook(
63
89
  props,
64
90
  );
65
91
 
66
- const useNativePropsInFabric =
67
- ReactNativeFeatureFlags.shouldUseSetNativePropsInFabric();
68
-
69
92
  useEffect(() => {
70
93
  // If multiple components call `flushQueue`, the first one will flush the
71
94
  // queue and subsequent ones will do nothing.
@@ -95,6 +118,8 @@ export default function createAnimatedPropsHook(
95
118
 
96
119
  useAnimatedPropsLifecycle(node);
97
120
 
121
+ const eventTuples = useNativeAnimatedEvents(node, props);
122
+
98
123
  // TODO: This "effect" does three things:
99
124
  //
100
125
  // 1) Call `setNativeView`.
@@ -182,24 +207,18 @@ export default function createAnimatedPropsHook(
182
207
  };
183
208
 
184
209
  const target = getEventTarget(instance);
185
- const events = [];
186
210
  const animatedValueListeners: AnimatedValueListeners = [];
187
211
 
188
- for (const propName in props) {
189
- // $FlowFixMe[invalid-computed-prop]
190
- const propValue = props[propName];
191
- if (propValue instanceof AnimatedEvent && propValue.__isNative) {
192
- propValue.__attach(target, propName);
193
- events.push([propName, propValue]);
194
- // $FlowFixMe[incompatible-call] - the `addListenersToPropsValue` drills down the propValue.
195
- addListenersToPropsValue(propValue, animatedValueListeners);
196
- }
212
+ for (const [propName, propValue] of eventTuples) {
213
+ propValue.__attach(target, propName);
214
+ // $FlowFixMe[incompatible-call] - the `addListenersToPropsValue` drills down the propValue.
215
+ addListenersToPropsValue(propValue, animatedValueListeners);
197
216
  }
198
217
 
199
218
  return () => {
200
219
  onUpdateRef.current = null;
201
220
 
202
- for (const [propName, propValue] of events) {
221
+ for (const [propName, propValue] of eventTuples) {
203
222
  propValue.__detach(target, propName);
204
223
  }
205
224
 
@@ -208,7 +227,7 @@ export default function createAnimatedPropsHook(
208
227
  }
209
228
  };
210
229
  },
211
- [node, useNativePropsInFabric, props],
230
+ [eventTuples, node],
212
231
  );
213
232
  const callbackRef = useRefEffect<TInstance>(refEffect);
214
233
 
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @generated SignedSource<<3e68d888bf4d8ac71b63571a639d265b>>
7
+ * @generated SignedSource<<e76d584cb67e2feae209795beb2009d6>>
8
8
  * @flow strict
9
9
  */
10
10
 
@@ -30,18 +30,16 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{
30
30
  jsOnlyTestFlag: Getter<boolean>,
31
31
  animatedShouldDebounceQueueFlush: Getter<boolean>,
32
32
  animatedShouldUseSingleOp: Getter<boolean>,
33
+ avoidAnimatedRefInvalidation: Getter<boolean>,
33
34
  avoidStateUpdateInAnimatedPropsMemo: Getter<boolean>,
34
35
  disableInteractionManager: Getter<boolean>,
35
36
  enableAccessToHostTreeInFabric: Getter<boolean>,
36
- enableAnimatedClearImmediateFix: Getter<boolean>,
37
- enableDOMDocumentAPI: Getter<boolean>,
38
37
  fixVirtualizeListCollapseWindowSize: Getter<boolean>,
39
38
  isLayoutAnimationEnabled: Getter<boolean>,
40
39
  scheduleAnimatedCleanupInMicrotask: Getter<boolean>,
41
40
  shouldUseAnimatedObjectForTransform: Getter<boolean>,
42
41
  shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter<boolean>,
43
42
  shouldUseSetNativePropsInFabric: Getter<boolean>,
44
- useRefsForTextInputState: Getter<boolean>,
45
43
  }>;
46
44
 
47
45
  export type ReactNativeFeatureFlagsJsOnlyOverrides = OverridesFor<ReactNativeFeatureFlagsJsOnly>;
@@ -50,6 +48,7 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
50
48
  ...ReactNativeFeatureFlagsJsOnly,
51
49
  commonTestFlag: Getter<boolean>,
52
50
  commonTestFlagWithoutNativeImplementation: Getter<boolean>,
51
+ animatedShouldSignalBatch: Getter<boolean>,
53
52
  disableMountItemReorderingAndroid: Getter<boolean>,
54
53
  enableAccumulatedUpdatesInRawPropsAndroid: Getter<boolean>,
55
54
  enableBridgelessArchitecture: Getter<boolean>,
@@ -65,7 +64,6 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
65
64
  enableLongTaskAPI: Getter<boolean>,
66
65
  enableNativeCSSParsing: Getter<boolean>,
67
66
  enableNewBackgroundAndBorderDrawables: Getter<boolean>,
68
- enablePreciseSchedulingForPremountItemsOnAndroid: Getter<boolean>,
69
67
  enablePropsUpdateReconciliationAndroid: Getter<boolean>,
70
68
  enableReportEventPaintTime: Getter<boolean>,
71
69
  enableSynchronousStateUpdates: Getter<boolean>,
@@ -74,7 +72,6 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
74
72
  enableViewRecycling: Getter<boolean>,
75
73
  enableViewRecyclingForText: Getter<boolean>,
76
74
  enableViewRecyclingForView: Getter<boolean>,
77
- excludeYogaFromRawProps: Getter<boolean>,
78
75
  fixDifferentiatorEmittingUpdatesWithWrongParentTag: Getter<boolean>,
79
76
  fixMappingOfEventPrioritiesBetweenFabricAndReact: Getter<boolean>,
80
77
  fixMountingCoordinatorReportedPendingTransactionsOnAndroid: Getter<boolean>,
@@ -109,6 +106,11 @@ export const animatedShouldDebounceQueueFlush: Getter<boolean> = createJavaScrip
109
106
  */
110
107
  export const animatedShouldUseSingleOp: Getter<boolean> = createJavaScriptFlagGetter('animatedShouldUseSingleOp', false);
111
108
 
109
+ /**
110
+ * Changes `useAnimatedProps` to avoid invalidating the callback ref whenever `props` changes.
111
+ */
112
+ export const avoidAnimatedRefInvalidation: Getter<boolean> = createJavaScriptFlagGetter('avoidAnimatedRefInvalidation', false);
113
+
112
114
  /**
113
115
  * Changes `useAnimatedPropsMemo` to avoid state updates to invalidate the cached `AnimatedProps`.
114
116
  */
@@ -124,16 +126,6 @@ export const disableInteractionManager: Getter<boolean> = createJavaScriptFlagGe
124
126
  */
125
127
  export const enableAccessToHostTreeInFabric: Getter<boolean> = createJavaScriptFlagGetter('enableAccessToHostTreeInFabric', false);
126
128
 
127
- /**
128
- * Enables an experimental to use the proper clearIntermediate instead of calling the wrong clearTimeout and canceling another timer.
129
- */
130
- export const enableAnimatedClearImmediateFix: Getter<boolean> = createJavaScriptFlagGetter('enableAnimatedClearImmediateFix', true);
131
-
132
- /**
133
- * Enables the DOM Document API, exposing instaces of document through `getRootNode` and `ownerDocument`, and providing access to the `documentElement` representing the root node. This flag will be short-lived, only to test the Document API specifically, and then it will be collapsed into the enableAccessToHostTreeInFabric flag.
134
- */
135
- export const enableDOMDocumentAPI: Getter<boolean> = createJavaScriptFlagGetter('enableDOMDocumentAPI', false);
136
-
137
129
  /**
138
130
  * Fixing an edge case where the current window size is not properly calculated with fast scrolling. Window size collapsed to 1 element even if windowSize more than the current amount of elements
139
131
  */
@@ -164,11 +156,6 @@ export const shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter<boolean> = cre
164
156
  */
165
157
  export const shouldUseSetNativePropsInFabric: Getter<boolean> = createJavaScriptFlagGetter('shouldUseSetNativePropsInFabric', true);
166
158
 
167
- /**
168
- * Enable a variant of TextInput that moves some state to refs to avoid unnecessary re-renders
169
- */
170
- export const useRefsForTextInputState: Getter<boolean> = createJavaScriptFlagGetter('useRefsForTextInputState', false);
171
-
172
159
  /**
173
160
  * Common flag for testing. Do NOT modify.
174
161
  */
@@ -177,6 +164,10 @@ export const commonTestFlag: Getter<boolean> = createNativeFlagGetter('commonTes
177
164
  * Common flag for testing (without native implementation). Do NOT modify.
178
165
  */
179
166
  export const commonTestFlagWithoutNativeImplementation: Getter<boolean> = createNativeFlagGetter('commonTestFlagWithoutNativeImplementation', false);
167
+ /**
168
+ * Enables start- and finishOperationBatch on any platform.
169
+ */
170
+ export const animatedShouldSignalBatch: Getter<boolean> = createNativeFlagGetter('animatedShouldSignalBatch', false);
180
171
  /**
181
172
  * Prevent FabricMountingManager from reordering mountitems, which may lead to invalid state on the UI thread
182
173
  */
@@ -186,7 +177,7 @@ export const disableMountItemReorderingAndroid: Getter<boolean> = createNativeFl
186
177
  */
187
178
  export const enableAccumulatedUpdatesInRawPropsAndroid: Getter<boolean> = createNativeFlagGetter('enableAccumulatedUpdatesInRawPropsAndroid', false);
188
179
  /**
189
- * Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer.
180
+ * Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer`.
190
181
  */
191
182
  export const enableBridgelessArchitecture: Getter<boolean> = createNativeFlagGetter('enableBridgelessArchitecture', false);
192
183
  /**
@@ -237,10 +228,6 @@ export const enableNativeCSSParsing: Getter<boolean> = createNativeFlagGetter('e
237
228
  * Use BackgroundDrawable and BorderDrawable instead of CSSBackgroundDrawable
238
229
  */
239
230
  export const enableNewBackgroundAndBorderDrawables: Getter<boolean> = createNativeFlagGetter('enableNewBackgroundAndBorderDrawables', false);
240
- /**
241
- * Moves execution of pre-mount items to outside the choregrapher in the main thread, so we can estimate idle time more precisely (Android only).
242
- */
243
- export const enablePreciseSchedulingForPremountItemsOnAndroid: Getter<boolean> = createNativeFlagGetter('enablePreciseSchedulingForPremountItemsOnAndroid', false);
244
231
  /**
245
232
  * When enabled, Android will receive prop updates based on the differences between the last rendered shadow node and the last committed shadow node.
246
233
  */
@@ -273,10 +260,6 @@ export const enableViewRecyclingForText: Getter<boolean> = createNativeFlagGette
273
260
  * Enables View Recycling for <View> via ReactViewGroup/ReactViewManager.
274
261
  */
275
262
  export const enableViewRecyclingForView: Getter<boolean> = createNativeFlagGetter('enableViewRecyclingForView', true);
276
- /**
277
- * When enabled, rawProps in Props will not include Yoga specific props.
278
- */
279
- export const excludeYogaFromRawProps: Getter<boolean> = createNativeFlagGetter('excludeYogaFromRawProps', false);
280
263
  /**
281
264
  * Fixes a bug in Differentiator where parent views may be referenced before they're created
282
265
  */
@@ -294,7 +277,7 @@ export const fixMountingCoordinatorReportedPendingTransactionsOnAndroid: Getter<
294
277
  */
295
278
  export const fuseboxEnabledRelease: Getter<boolean> = createNativeFlagGetter('fuseboxEnabledRelease', false);
296
279
  /**
297
- * Enable network inspection support in the React Native DevTools CDP backend. This flag is global and should not be changed across React Host lifetimes.
280
+ * Enable network inspection support in the React Native DevTools CDP backend. Requires `enableBridgelessArchitecture`. This flag is global and should not be changed across React Host lifetimes.
298
281
  */
299
282
  export const fuseboxNetworkInspectionEnabled: Getter<boolean> = createNativeFlagGetter('fuseboxNetworkInspectionEnabled', false);
300
283
  /**
@@ -96,9 +96,17 @@ export function setOverrides(
96
96
  }
97
97
 
98
98
  const reportedConfigNames: Set<string> = new Set();
99
+ const hasTurboModules =
100
+ global.RN$Bridgeless === true || global.__turboModuleProxy != null;
99
101
 
100
102
  function maybeLogUnavailableNativeModuleError(configName: string): void {
101
- if (!NativeReactNativeFeatureFlags && !reportedConfigNames.has(configName)) {
103
+ if (
104
+ !NativeReactNativeFeatureFlags &&
105
+ // Don't log more than once per config
106
+ !reportedConfigNames.has(configName) &&
107
+ // Don't log in the legacy architecture.
108
+ hasTurboModules
109
+ ) {
102
110
  reportedConfigNames.add(configName);
103
111
  console.error(
104
112
  `Could not access feature flag '${configName}' because native module method was not available`,
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @generated SignedSource<<0d611c17d522627c59a68d083eb6b6dc>>
7
+ * @generated SignedSource<<22d8e7623a2eee5182c786f2ec914401>>
8
8
  * @flow strict
9
9
  */
10
10
 
@@ -25,6 +25,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod
25
25
  export interface Spec extends TurboModule {
26
26
  +commonTestFlag?: () => boolean;
27
27
  +commonTestFlagWithoutNativeImplementation?: () => boolean;
28
+ +animatedShouldSignalBatch?: () => boolean;
28
29
  +disableMountItemReorderingAndroid?: () => boolean;
29
30
  +enableAccumulatedUpdatesInRawPropsAndroid?: () => boolean;
30
31
  +enableBridgelessArchitecture?: () => boolean;
@@ -40,7 +41,6 @@ export interface Spec extends TurboModule {
40
41
  +enableLongTaskAPI?: () => boolean;
41
42
  +enableNativeCSSParsing?: () => boolean;
42
43
  +enableNewBackgroundAndBorderDrawables?: () => boolean;
43
- +enablePreciseSchedulingForPremountItemsOnAndroid?: () => boolean;
44
44
  +enablePropsUpdateReconciliationAndroid?: () => boolean;
45
45
  +enableReportEventPaintTime?: () => boolean;
46
46
  +enableSynchronousStateUpdates?: () => boolean;
@@ -49,7 +49,6 @@ export interface Spec extends TurboModule {
49
49
  +enableViewRecycling?: () => boolean;
50
50
  +enableViewRecyclingForText?: () => boolean;
51
51
  +enableViewRecyclingForView?: () => boolean;
52
- +excludeYogaFromRawProps?: () => boolean;
53
52
  +fixDifferentiatorEmittingUpdatesWithWrongParentTag?: () => boolean;
54
53
  +fixMappingOfEventPrioritiesBetweenFabricAndReact?: () => boolean;
55
54
  +fixMountingCoordinatorReportedPendingTransactionsOnAndroid?: () => boolean;
@@ -188,25 +188,12 @@ export default class ReadOnlyNode {
188
188
  }
189
189
 
190
190
  getRootNode(): ReadOnlyNode {
191
- if (ReactNativeFeatureFlags.enableDOMDocumentAPI()) {
192
- if (this.isConnected) {
193
- // If this is the document node, then the root node is itself.
194
- return this.ownerDocument ?? this;
195
- }
196
-
197
- return this;
198
- } else {
199
- // eslint-disable-next-line consistent-this
200
- let lastKnownParent: ReadOnlyNode = this;
201
- let nextPossibleParent: ?ReadOnlyNode = this.parentNode;
202
-
203
- while (nextPossibleParent != null) {
204
- lastKnownParent = nextPossibleParent;
205
- nextPossibleParent = nextPossibleParent.parentNode;
206
- }
207
-
208
- return lastKnownParent;
191
+ if (this.isConnected) {
192
+ // If this is the document node, then the root node is itself.
193
+ return this.ownerDocument ?? this;
209
194
  }
195
+
196
+ return this;
210
197
  }
211
198
 
212
199
  hasChildNodes(): boolean {
@@ -129,6 +129,12 @@ export function getNativeElementReference(
129
129
  // $FlowExpectedError[incompatible-cast] We know ReadOnlyElement instances provide InternalInstanceHandle
130
130
  const instanceHandle = getInstanceHandle(node) as InternalInstanceHandle;
131
131
 
132
+ if (isReactNativeDocumentElementInstanceHandle(instanceHandle)) {
133
+ return getNativeElementReferenceFromReactNativeDocumentElementInstanceHandle(
134
+ instanceHandle,
135
+ );
136
+ }
137
+
132
138
  // $FlowExpectedError[incompatible-return]
133
139
  return getRendererProxy().getNodeFromInternalInstanceHandle(instanceHandle);
134
140
  }