@office-iss/react-native-win32 0.0.0-canary.274 → 0.0.0-canary.276

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 (96) hide show
  1. package/.flowconfig +5 -1
  2. package/CHANGELOG.json +31 -1
  3. package/CHANGELOG.md +20 -4
  4. package/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts +1 -0
  5. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +13 -0
  6. package/Libraries/Animated/animations/Animation.js +1 -5
  7. package/Libraries/Animated/components/AnimatedFlatList.js +1 -1
  8. package/Libraries/Animated/components/AnimatedSectionList.js +3 -1
  9. package/Libraries/Animated/useAnimatedProps.js +2 -14
  10. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +16 -2
  11. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +21 -2
  12. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +2 -0
  13. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +0 -1
  14. package/Libraries/Components/ScrollView/ScrollView.js +35 -74
  15. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +0 -2
  16. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +0 -1
  17. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  18. package/Libraries/Components/TextInput/TextInput.flow.js +6 -0
  19. package/Libraries/Components/TextInput/TextInput.js +7 -1
  20. package/Libraries/Components/TextInput/TextInput.win32.js +7 -1
  21. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -2
  22. package/Libraries/Components/View/ViewPropTypes.d.ts +7 -0
  23. package/Libraries/Components/View/ViewPropTypes.js +0 -3
  24. package/Libraries/Components/View/ViewPropTypes.win32.js +0 -3
  25. package/Libraries/Core/ExceptionsManager.js +7 -4
  26. package/Libraries/Core/ReactNativeVersion.js +1 -1
  27. package/Libraries/Core/setUpErrorHandling.js +20 -18
  28. package/Libraries/Core/setUpTimers.js +4 -12
  29. package/Libraries/Image/Image.android.js +0 -2
  30. package/Libraries/Image/Image.d.ts +2 -0
  31. package/Libraries/Image/ImageProps.js +2 -1
  32. package/Libraries/Image/ImageResizeMode.d.ts +8 -1
  33. package/Libraries/Image/ImageResizeMode.js +4 -1
  34. package/Libraries/Image/ImageSource.d.ts +0 -2
  35. package/Libraries/Image/ImageSource.js +0 -2
  36. package/Libraries/Image/ImageUtils.js +6 -3
  37. package/Libraries/Image/ImageViewNativeComponent.js +3 -1
  38. package/Libraries/Inspector/Inspector.win32.js +1 -1
  39. package/Libraries/Interaction/InteractionManager.js +6 -1
  40. package/Libraries/Interaction/InteractionManagerStub.js +176 -0
  41. package/Libraries/Lists/FlatList.js +2 -2
  42. package/Libraries/LogBox/LogBox.js +1 -1
  43. package/Libraries/LogBox/UI/AnsiHighlight.js +26 -17
  44. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +6 -1
  45. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +6 -1
  46. package/Libraries/Modal/Modal.d.ts +5 -0
  47. package/Libraries/Modal/Modal.js +17 -0
  48. package/Libraries/NewAppScreen/components/HermesBadge.js +1 -1
  49. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +49 -2
  50. package/Libraries/Pressability/usePressability.js +4 -1
  51. package/Libraries/ReactNative/AppRegistry.js +0 -6
  52. package/Libraries/ReactNative/RendererImplementation.js +12 -12
  53. package/Libraries/ReactNative/renderApplication.js +3 -4
  54. package/Libraries/ReactNative/requireNativeComponent.js +2 -1
  55. package/Libraries/Renderer/implementations/ReactFabric-dev.js +26149 -15434
  56. package/Libraries/Renderer/implementations/ReactFabric-prod.js +1630 -2675
  57. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +1691 -2954
  58. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27069 -16192
  59. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1657 -2714
  60. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1733 -2980
  61. package/Libraries/Renderer/shims/ReactFabric.js +3 -3
  62. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
  63. package/Libraries/Renderer/shims/ReactNative.js +3 -3
  64. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
  65. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +7 -1
  66. package/Libraries/StyleSheet/StyleSheetTypes.js +5 -4
  67. package/Libraries/StyleSheet/processBackgroundImage.js +87 -110
  68. package/Libraries/TurboModule/TurboModuleRegistry.js +5 -5
  69. package/Libraries/Utilities/Appearance.js +3 -1
  70. package/Libraries/Utilities/BackHandler.android.js +6 -18
  71. package/Libraries/Utilities/BackHandler.d.ts +0 -4
  72. package/Libraries/Utilities/BackHandler.ios.js +0 -7
  73. package/Libraries/Utilities/BackHandler.win32.js +6 -18
  74. package/Libraries/Utilities/__mocks__/BackHandler.js +3 -8
  75. package/jest/setup.js +5 -1
  76. package/overrides.json +9 -9
  77. package/package.json +14 -14
  78. package/src/private/components/HScrollViewNativeComponents.js +1 -26
  79. package/src/private/components/VScrollViewNativeComponents.js +2 -24
  80. package/src/private/featureflags/ReactNativeFeatureFlags.js +24 -55
  81. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -7
  82. package/src/private/setup/setUpDOM.js +14 -6
  83. package/src/private/setup/setUpMutationObserver.js +5 -0
  84. package/src/private/specs/components/RCTModalHostViewNativeComponent.js +8 -0
  85. package/src/private/specs/modules/NativeAccessibilityInfo.js +6 -0
  86. package/src/private/specs/modules/NativeAccessibilityInfoWin32.js +6 -0
  87. package/src/private/specs/modules/NativeActionSheetManager.js +2 -0
  88. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +96 -11
  89. package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +26 -0
  90. package/src/private/webapis/intersectionobserver/IntersectionObserverManager.js +1 -0
  91. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
  92. package/src/private/webapis/intersectionobserver/specs/__mocks__/NativeIntersectionObserver.js +9 -0
  93. package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +7 -0
  94. package/Libraries/ReactNative/ReactFabricInternals.js +0 -17
  95. package/src/private/components/useSyncOnScroll.js +0 -48
  96. package/types/experimental.d.ts +0 -59
@@ -25,6 +25,18 @@ type IntersectionObserverInit = {
25
25
  // root?: ReactNativeElement, // This option exists on the Web but it's not currently supported in React Native.
26
26
  // rootMargin?: string, // This option exists on the Web but it's not currently supported in React Native.
27
27
  threshold?: number | $ReadOnlyArray<number>,
28
+
29
+ /**
30
+ * This is a React Native specific option (not spec compliant) that specifies
31
+ * ratio threshold(s) of the intersection area to the total `root` area.
32
+ *
33
+ * If set, it will either be a singular ratio value between 0-1 (inclusive)
34
+ * or an array of such ratios.
35
+ *
36
+ * Note: If `rn_rootThreshold` is set, and `threshold` is not set,
37
+ * `threshold` will not default to [0] (as per spec)
38
+ */
39
+ rn_rootThreshold?: number | $ReadOnlyArray<number>,
28
40
  };
29
41
 
30
42
  /**
@@ -44,13 +56,16 @@ type IntersectionObserverInit = {
44
56
  * elements with the same observer.
45
57
  *
46
58
  * This implementation only supports the `threshold` option at the moment
47
- * (`root` and `rootMargin` are not supported).
59
+ * (`root` and `rootMargin` are not supported) and provides a React Native specific
60
+ * option `rn_rootThreshold`.
61
+ *
48
62
  */
49
63
  export default class IntersectionObserver {
50
64
  _callback: IntersectionObserverCallback;
51
65
  _thresholds: $ReadOnlyArray<number>;
52
66
  _observationTargets: Set<ReactNativeElement> = new Set();
53
67
  _intersectionObserverId: ?IntersectionObserverId;
68
+ _rootThresholds: $ReadOnlyArray<number> | null;
54
69
 
55
70
  constructor(
56
71
  callback: IntersectionObserverCallback,
@@ -83,7 +98,12 @@ export default class IntersectionObserver {
83
98
  }
84
99
 
85
100
  this._callback = callback;
86
- this._thresholds = normalizeThresholds(options?.threshold);
101
+
102
+ this._rootThresholds = normalizeRootThreshold(options?.rn_rootThreshold);
103
+ this._thresholds = normalizeThreshold(
104
+ options?.threshold,
105
+ this._rootThresholds != null, // only provide default if no rootThreshold
106
+ );
87
107
  }
88
108
 
89
109
  /**
@@ -115,14 +135,27 @@ export default class IntersectionObserver {
115
135
  * A list of thresholds, sorted in increasing numeric order, where each
116
136
  * threshold is a ratio of intersection area to bounding box area of an
117
137
  * observed target.
118
- * Notifications for a target are generated when any of the thresholds are
119
- * crossed for that target.
120
- * If no value was passed to the constructor, `0` is used.
138
+ * Notifications for a target are generated when any of the thresholds specified
139
+ * in `rn_rootThreshold` or `threshold` are crossed for that target.
140
+ *
141
+ * If no value was passed to the constructor, and no `rn_rootThreshold`
142
+ * is set, `0` is used.
121
143
  */
122
144
  get thresholds(): $ReadOnlyArray<number> {
123
145
  return this._thresholds;
124
146
  }
125
147
 
148
+ /**
149
+ * A list of root thresholds, sorted in increasing numeric order, where each
150
+ * threshold is a ratio of intersection area to bounding box area of the specified
151
+ * root view, which defaults to the viewport.
152
+ * Notifications for a target are generated when any of the thresholds specified
153
+ * in `rn_rootThreshold` or `threshold` are crossed for that target.
154
+ */
155
+ get rootThresholds(): $ReadOnlyArray<number> | null {
156
+ return this._rootThresholds;
157
+ }
158
+
126
159
  /**
127
160
  * Adds an element to the set of target elements being watched by the
128
161
  * `IntersectionObserver`.
@@ -221,32 +254,84 @@ export default class IntersectionObserver {
221
254
  * Converts the user defined `threshold` value into an array of sorted valid
222
255
  * threshold options for `IntersectionObserver` (double ∈ [0, 1]).
223
256
  *
257
+ * If `defaultEmpty` is true, then defaults to empty array, otherwise [0].
258
+ *
224
259
  * @example
225
260
  * normalizeThresholds(0.5); // → [0.5]
226
261
  * normalizeThresholds([1, 0.5, 0]); // → [0, 0.5, 1]
227
262
  * normalizeThresholds(['1', '0.5', '0']); // → [0, 0.5, 1]
263
+ * normalizeThresholds(null); // → [0]
264
+ * normalizeThresholds([null, null]); // → [0, 0]
265
+ *
266
+ * normalizeThresholds([null], true); // → [0]
267
+ * normalizeThresholds(null, true); // → []
268
+ * normalizeThresholds([], true); // → []
228
269
  */
229
- function normalizeThresholds(threshold: mixed): $ReadOnlyArray<number> {
270
+ function normalizeThreshold(
271
+ threshold: mixed,
272
+ defaultEmpty: boolean = false,
273
+ ): $ReadOnlyArray<number> {
230
274
  if (Array.isArray(threshold)) {
231
275
  if (threshold.length > 0) {
232
- return threshold.map(normalizeThresholdValue).sort();
276
+ return threshold
277
+ .map(t => normalizeThresholdValue(t, 'threshold'))
278
+ .map(t => t ?? 0)
279
+ .sort();
280
+ } else if (defaultEmpty) {
281
+ return [];
233
282
  } else {
234
283
  return [0];
235
284
  }
236
285
  }
237
286
 
238
- return [normalizeThresholdValue(threshold)];
287
+ const normalized = normalizeThresholdValue(threshold, 'threshold');
288
+ if (normalized == null) {
289
+ return defaultEmpty ? [] : [0];
290
+ }
291
+
292
+ return [normalized];
293
+ }
294
+
295
+ /**
296
+ * Converts the user defined `rn_rootThreshold` value into an array of sorted valid
297
+ * threshold options for `IntersectionObserver` (double ∈ [0, 1]).
298
+ *
299
+ * If invalid array or null, returns null.
300
+ *
301
+ * @example
302
+ * normalizeRootThreshold(0.5); // → [0.5]
303
+ * normalizeRootThresholds([1, 0.5, 0]); // → [0, 0.5, 1]
304
+ * normalizeRootThresholds([null, '0.5', '0']); // → [0, 0.5]
305
+ * normalizeRootThresholds(null); // → null
306
+ * normalizeRootThresholds([null, null]); // → null
307
+ */
308
+ function normalizeRootThreshold(
309
+ rootThreshold: mixed,
310
+ ): null | $ReadOnlyArray<number> {
311
+ if (Array.isArray(rootThreshold)) {
312
+ const normalizedArr = rootThreshold
313
+ .map(rt => normalizeThresholdValue(rt, 'rn_rootThreshold'))
314
+ .filter((rt): rt is number => rt != null)
315
+ .sort();
316
+ return normalizedArr.length === 0 ? null : normalizedArr;
317
+ }
318
+
319
+ const normalized = normalizeThresholdValue(rootThreshold, 'rn_rootThreshold');
320
+ return normalized == null ? null : [normalized];
239
321
  }
240
322
 
241
- function normalizeThresholdValue(threshold: mixed): number {
323
+ function normalizeThresholdValue(
324
+ threshold: mixed,
325
+ property: string,
326
+ ): null | number {
242
327
  if (threshold == null) {
243
- return 0;
328
+ return null;
244
329
  }
245
330
 
246
331
  const thresholdAsNumber = Number(threshold);
247
332
  if (!Number.isFinite(thresholdAsNumber)) {
248
333
  throw new TypeError(
249
- "Failed to read the 'threshold' property from 'IntersectionObserverInit': The provided double value is non-finite.",
334
+ `Failed to read the '${property}' property from 'IntersectionObserverInit': The provided double value is non-finite.`,
250
335
  );
251
336
  }
252
337
 
@@ -74,6 +74,32 @@ export default class IntersectionObserverEntry {
74
74
  return Math.min(ratio, 1);
75
75
  }
76
76
 
77
+ /**
78
+ * Returns the ratio of the `intersectionRect` to the `boundingRootRect`.
79
+ */
80
+ get rn_intersectionRootRatio(): number {
81
+ const intersectionRect = this.intersectionRect;
82
+
83
+ const rootRect = this._nativeEntry.rootRect;
84
+ const boundingRootRect = new DOMRectReadOnly(
85
+ rootRect[0],
86
+ rootRect[1],
87
+ rootRect[2],
88
+ rootRect[3],
89
+ );
90
+
91
+ if (boundingRootRect.width === 0 || boundingRootRect.height === 0) {
92
+ return 0;
93
+ }
94
+
95
+ const ratio =
96
+ (intersectionRect.width * intersectionRect.height) /
97
+ (boundingRootRect.width * boundingRootRect.height);
98
+
99
+ // Prevent rounding errors from making this value greater than 1.
100
+ return Math.min(ratio, 1);
101
+ }
102
+
77
103
  /**
78
104
  * Returns a `DOMRectReadOnly` representing the target's visible area.
79
105
  */
@@ -162,6 +162,7 @@ export function observe({
162
162
  intersectionObserverId,
163
163
  targetShadowNode,
164
164
  thresholds: registeredObserver.observer.thresholds,
165
+ rootThresholds: registeredObserver.observer.rootThresholds,
165
166
  });
166
167
 
167
168
  return true;
@@ -26,6 +26,7 @@ export type NativeIntersectionObserverObserveOptions = {
26
26
  intersectionObserverId: number,
27
27
  targetShadowNode: mixed,
28
28
  thresholds: $ReadOnlyArray<number>,
29
+ rootThresholds?: ?$ReadOnlyArray<number>,
29
30
  };
30
31
 
31
32
  export interface Spec extends TurboModule {
@@ -23,8 +23,10 @@ import nullthrows from 'nullthrows';
23
23
 
24
24
  type ObserverState = {
25
25
  thresholds: $ReadOnlyArray<number>,
26
+ rootThresholds?: ?$ReadOnlyArray<number>,
26
27
  intersecting: boolean,
27
28
  currentThreshold: ?number,
29
+ currentRootThreshold: ?number,
28
30
  };
29
31
 
30
32
  type Observation = {
@@ -74,8 +76,10 @@ const NativeIntersectionObserverMock = {
74
76
  ...options,
75
77
  state: {
76
78
  thresholds: options.thresholds,
79
+ rootThresholds: options.rootThresholds,
77
80
  intersecting: false,
78
81
  currentThreshold: null,
82
+ currentRootThreshold: null,
79
83
  },
80
84
  };
81
85
  observations.push(observation);
@@ -141,9 +145,14 @@ const NativeIntersectionObserverMock = {
141
145
  if (observation.state.intersecting) {
142
146
  observation.state.intersecting = false;
143
147
  observation.state.currentThreshold = null;
148
+ observation.state.currentRootThreshold = null;
144
149
  } else {
145
150
  observation.state.intersecting = true;
146
151
  observation.state.currentThreshold = observation.thresholds[0];
152
+ observation.state.currentRootThreshold =
153
+ observation.rootThresholds != null
154
+ ? observation.rootThresholds[0]
155
+ : null;
147
156
  }
148
157
  pendingRecords.push(createRecordFromObservation(observation));
149
158
  setImmediate(notifyIntersectionObservers);
@@ -343,6 +343,13 @@ export interface ViewProps
343
343
  * Used to reference react managed views from native code.
344
344
  */
345
345
  nativeID?: string | undefined;
346
+
347
+ /**
348
+ * Contols whether this view, and its transitive children, are laid in a way
349
+ * consistent with web browsers ('strict'), or consistent with existing
350
+ * React Native code which may rely on incorrect behavior ('classic').
351
+ */
352
+ experimental_layoutConformance?: 'strict' | 'classic' | undefined;
346
353
  }
347
354
 
348
355
  // For backwards compat.... // Win32
@@ -1,17 +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-local
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- const createReactNativeComponentClass = require('../Renderer/shims/createReactNativeComponentClass');
14
-
15
- module.exports = {
16
- createReactNativeComponentClass,
17
- };
@@ -1,48 +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-local
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
- import type {ScrollViewNativeProps} from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponentType';
13
- import type {HostComponent} from '../../../Libraries/Renderer/shims/ReactNativeTypes';
14
-
15
- import * as React from 'react';
16
- import {useImperativeHandle, useRef, useState} from 'react';
17
-
18
- export type TScrollViewNativeComponentInstance = React.ElementRef<
19
- HostComponent<ScrollViewNativeProps>,
20
- >;
21
-
22
- export type TScrollViewNativeImperativeHandle = {
23
- componentRef: React.RefObject<TScrollViewNativeComponentInstance | null>,
24
- unstable_setEnableSyncOnScroll: (enabled: true) => void,
25
- };
26
-
27
- /**
28
- * Hook used by `HScrollViewNativeComponent` and `VScrollViewNativeComponent`
29
- * to make an implementation of `unstable_setEnableSyncOnScroll` available that
30
- * does not require updating all `ScrollView` children.
31
- */
32
- export default function useSyncOnScroll(
33
- inputRef: ?React.RefSetter<TScrollViewNativeImperativeHandle | null>,
34
- ): [React.RefSetter<TScrollViewNativeComponentInstance | null>, true | void] {
35
- const componentRef = useRef<TScrollViewNativeComponentInstance | null>(null);
36
- const [enableSyncOnScroll, setEnableSyncOnScroll] = useState<true | void>();
37
-
38
- useImperativeHandle<TScrollViewNativeImperativeHandle>(inputRef, () => {
39
- return {
40
- componentRef,
41
- unstable_setEnableSyncOnScroll(enabled: true): void {
42
- setEnableSyncOnScroll(enabled);
43
- },
44
- };
45
- }, []);
46
-
47
- return [componentRef, enableSyncOnScroll];
48
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- */
9
-
10
- /**
11
- * These are types for things that are present for New Architecture enabled apps
12
- * which is currently considered experimental.
13
- *
14
- * To load the types declared here in an actual project, there are three ways.
15
- *
16
- * 1. If your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
17
- * is to add `"react-native/types/experimental"` to the `"types"` array.
18
- *
19
- * 2. Alternatively, a specific import syntax can to be used from a typescript file.
20
- * This module does not exist in reality, which is why the {} is important:
21
- *
22
- * ```ts
23
- * import {} from 'react-native/types/experimental'
24
- * ```
25
- *
26
- * 3. It is also possible to include it through a triple-slash reference:
27
- *
28
- * ```ts
29
- * /// <reference types="react-native/types/experimental" />
30
- * ```
31
- *
32
- * Either the import or the reference only needs to appear once, anywhere in the project.
33
- */
34
-
35
- import {
36
- GradientValue,
37
- BlendMode,
38
- } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
39
-
40
- export {};
41
-
42
- declare module '.' {
43
- export interface ViewProps {
44
- /**
45
- * Contols whether this view, and its transitive children, are laid in a way
46
- * consistent with web browsers ('strict'), or consistent with existing
47
- * React Native code which may rely on incorrect behavior ('classic').
48
- */
49
- experimental_layoutConformance?: 'strict' | 'classic' | undefined;
50
- }
51
-
52
- export interface ViewStyle {
53
- mixBlendMode?: BlendMode | undefined;
54
- experimental_backgroundImage?:
55
- | ReadonlyArray<GradientValue>
56
- | string
57
- | undefined;
58
- }
59
- }