@office-iss/react-native-win32 0.75.1 → 0.76.0-preview.1

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 (174) hide show
  1. package/.eslintrc.js +11 -0
  2. package/.flowconfig +5 -4
  3. package/CHANGELOG.json +172 -40
  4. package/CHANGELOG.md +57 -24
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/Animated/AnimatedEvent.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +7 -7
  8. package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
  9. package/Libraries/Animated/animations/Animation.js +11 -1
  10. package/Libraries/Animated/animations/DecayAnimation.js +1 -1
  11. package/Libraries/Animated/animations/SpringAnimation.js +1 -1
  12. package/Libraries/Animated/animations/TimingAnimation.js +2 -1
  13. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  14. package/Libraries/Animated/createAnimatedComponent.js +10 -9
  15. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
  17. package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
  18. package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
  19. package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
  20. package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
  21. package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
  23. package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
  24. package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
  25. package/Libraries/Animated/useAnimatedProps.js +142 -7
  26. package/Libraries/BatchedBridge/NativeModules.js +2 -0
  27. package/Libraries/Blob/FileReader.js +1 -1
  28. package/Libraries/Blob/URL.js +2 -62
  29. package/Libraries/Blob/URLSearchParams.js +71 -0
  30. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
  31. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
  32. package/Libraries/Components/ScrollView/ScrollView.js +131 -169
  33. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  34. package/Libraries/Components/StatusBar/StatusBar.js +3 -1
  35. package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
  36. package/Libraries/Components/TextInput/TextInput.js +230 -94
  37. package/Libraries/Components/TextInput/TextInput.win32.js +230 -100
  38. package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
  39. package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
  40. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +2 -0
  41. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  42. package/Libraries/Components/View/ViewNativeComponent.js +0 -1
  43. package/Libraries/Components/View/ViewPropTypes.js +14 -0
  44. package/Libraries/Components/View/ViewPropTypes.win32.js +14 -0
  45. package/Libraries/Core/ExceptionsManager.js +2 -0
  46. package/Libraries/Core/InitializeCore.js +3 -1
  47. package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
  48. package/Libraries/Core/ReactNativeVersion.js +4 -4
  49. package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
  50. package/Libraries/Core/setUpErrorHandling.js +7 -1
  51. package/Libraries/Core/setUpGlobals.js +1 -0
  52. package/Libraries/Core/setUpReactRefresh.js +0 -4
  53. package/Libraries/Image/AssetSourceResolver.js +28 -1
  54. package/Libraries/Image/Image.android.js +9 -14
  55. package/Libraries/Image/Image.ios.js +11 -22
  56. package/Libraries/Image/Image.win32.js +11 -24
  57. package/Libraries/Image/ImageBackground.js +1 -8
  58. package/Libraries/Image/ImageUtils.js +9 -9
  59. package/Libraries/Image/ImageViewNativeComponent.js +1 -0
  60. package/Libraries/Inspector/Inspector.js +3 -2
  61. package/Libraries/Inspector/Inspector.win32.js +3 -2
  62. package/Libraries/Inspector/InspectorPanel.js +16 -10
  63. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  64. package/Libraries/Interaction/TaskQueue.js +1 -0
  65. package/Libraries/Lists/FlatList.js +1 -1
  66. package/Libraries/Lists/SectionList.js +2 -2
  67. package/Libraries/Lists/SectionListModern.js +3 -3
  68. package/Libraries/LogBox/Data/LogBoxData.js +24 -3
  69. package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
  70. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
  71. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +9 -29
  72. package/Libraries/Modal/Modal.js +0 -1
  73. package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
  74. package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
  75. package/Libraries/NativeComponent/BaseViewConfig.win32.js +7 -0
  76. package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
  77. package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
  78. package/Libraries/Network/XMLHttpRequest.js +4 -2
  79. package/Libraries/ReactNative/AppContainer-dev.js +1 -5
  80. package/Libraries/ReactNative/AppContainer-prod.js +1 -5
  81. package/Libraries/ReactNative/AppContainer.js +0 -1
  82. package/Libraries/ReactNative/AppRegistry.js +0 -6
  83. package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
  84. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
  85. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
  86. package/Libraries/ReactNative/RendererImplementation.js +26 -4
  87. package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
  88. package/Libraries/ReactNative/renderApplication.js +0 -2
  89. package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
  90. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  91. package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
  92. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +74 -15
  93. package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
  94. package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
  95. package/Libraries/StyleSheet/processBoxShadow.js +211 -0
  96. package/Libraries/StyleSheet/processFilter.js +231 -42
  97. package/Libraries/Text/Text.js +394 -196
  98. package/Libraries/Text/Text.win32.js +442 -229
  99. package/Libraries/Text/TextNativeComponent.js +2 -1
  100. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  101. package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
  102. package/Libraries/Types/CodegenTypes.js +3 -1
  103. package/Libraries/Utilities/Appearance.js +108 -84
  104. package/Libraries/Utilities/DevLoadingView.js +2 -4
  105. package/Libraries/Utilities/HMRClient.js +2 -1
  106. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  107. package/Libraries/Utilities/createPerformanceLogger.js +0 -9
  108. package/Libraries/Utilities/stringifyViewConfig.js +22 -0
  109. package/Libraries/Utilities/useColorScheme.js +3 -3
  110. package/Libraries/WebSocket/WebSocket.js +1 -1
  111. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  112. package/Libraries/vendor/emitter/EventEmitter.js +6 -5
  113. package/flow/jest.js +2 -2
  114. package/index.js +3 -1
  115. package/index.win32.js +3 -1
  116. package/jest/mockComponent.js +4 -1
  117. package/jest/mockModal.js +1 -3
  118. package/jest/mockScrollView.js +1 -1
  119. package/jest/renderer.js +2 -2
  120. package/jest/setup.js +16 -13
  121. package/jest.config.js +1 -2
  122. package/overrides.json +22 -22
  123. package/package.json +27 -26
  124. package/src/private/animated/NativeAnimatedHelper.js +438 -0
  125. package/src/private/animated/NativeAnimatedHelper.win32.js +440 -0
  126. package/src/private/animated/NativeAnimatedValidation.js +64 -0
  127. package/src/private/components/HScrollViewNativeComponents.js +56 -0
  128. package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
  129. package/src/private/components/VScrollViewNativeComponents.js +48 -0
  130. package/src/private/components/useSyncOnScroll.js +48 -0
  131. package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
  132. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
  133. package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
  134. package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
  135. package/src/private/setup/setUpDOM.js +28 -0
  136. package/src/private/setup/setUpIntersectionObserver.js +27 -0
  137. package/src/private/setup/setUpMutationObserver.js +26 -0
  138. package/src/private/setup/setUpPerformanceObserver.js +64 -0
  139. package/src/private/specs/modules/NativeAppearance.js +3 -3
  140. package/src/private/specs/modules/NativeLinkingManager.js +1 -1
  141. package/src/private/specs/modules/NativePlatformConstantsWin.js +7 -0
  142. package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
  143. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
  144. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
  145. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
  146. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
  147. package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
  148. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
  149. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
  150. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
  151. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
  152. package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
  153. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
  154. package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
  155. package/src/private/webapis/performance/LongTasks.js +39 -0
  156. package/src/private/webapis/performance/Performance.js +22 -9
  157. package/src/private/webapis/performance/PerformanceEntry.js +36 -18
  158. package/src/private/webapis/performance/PerformanceObserver.js +29 -43
  159. package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
  160. package/src/private/webapis/performance/UserTiming.js +17 -12
  161. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
  162. package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  163. package/types/experimental.d.ts +20 -1
  164. package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
  165. package/Libraries/Animated/NativeAnimatedHelper.win32.js +0 -617
  166. package/Libraries/Core/setUpIntersectionObserver.js +0 -16
  167. package/Libraries/Core/setUpMutationObserver.js +0 -16
  168. package/Libraries/Core/setUpPerformanceObserver.js +0 -18
  169. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
  170. package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
  171. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
  172. package/src/private/core/setUpDOM.js +0 -18
  173. package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
  174. /package/src/private/{core → styles}/composeStyles.js +0 -0
@@ -4,66 +4,113 @@
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
- * @format
7
+ * @format strict-local
8
8
  * @flow
9
+ * @oncall react-native
9
10
  */
10
11
 
11
12
  'use strict';
12
13
 
13
- export type FilterPrimitive =
14
- | {brightness: number | string}
15
- | {blur: number | string}
16
- | {contrast: number | string}
17
- | {grayscale: number | string}
18
- | {hueRotate: number | string}
19
- | {invert: number | string}
20
- | {opacity: number | string}
21
- | {saturate: number | string}
22
- | {sepia: number | string};
14
+ import type {ColorValue} from './StyleSheet';
15
+ import type {DropShadowPrimitive, FilterFunction} from './StyleSheetTypes';
16
+
17
+ import processColor from './processColor';
18
+
19
+ type ParsedFilter =
20
+ | {brightness: number}
21
+ | {blur: number}
22
+ | {contrast: number}
23
+ | {grayscale: number}
24
+ | {hueRotate: number}
25
+ | {invert: number}
26
+ | {opacity: number}
27
+ | {saturate: number}
28
+ | {sepia: number}
29
+ | {dropShadow: ParsedDropShadow};
30
+
31
+ type ParsedDropShadow = {
32
+ offsetX: number,
33
+ offsetY: number,
34
+ standardDeviation?: number,
35
+ color?: ColorValue,
36
+ };
23
37
 
24
38
  export default function processFilter(
25
- filter: $ReadOnlyArray<FilterPrimitive> | string,
26
- ): $ReadOnlyArray<FilterPrimitive> {
27
- let result: Array<FilterPrimitive> = [];
39
+ filter: ?($ReadOnlyArray<FilterFunction> | string),
40
+ ): $ReadOnlyArray<ParsedFilter> {
41
+ let result: Array<ParsedFilter> = [];
42
+ if (filter == null) {
43
+ return result;
44
+ }
45
+
28
46
  if (typeof filter === 'string') {
29
- // matches on functions with args like "brightness(1.5)"
30
- const regex = new RegExp(/(\w+)\(([^)]+)\)/g);
47
+ filter = filter.replace(/\n/g, ' ');
48
+
49
+ // matches on functions with args and nested functions like "drop-shadow(10 10 10 rgba(0, 0, 0, 1))"
50
+ const regex = /([\w-]+)\(([^()]*|\([^()]*\)|[^()]*\([^()]*\)[^()]*)\)/g;
31
51
  let matches;
32
52
 
33
53
  while ((matches = regex.exec(filter))) {
34
- const amount = _getFilterAmount(matches[1], matches[2]);
35
-
36
- if (amount != null) {
37
- const filterPrimitive = {};
38
- // $FlowFixMe The key will be the correct one but flow can't see that.
39
- filterPrimitive[matches[1]] = amount;
40
- // $FlowFixMe The key will be the correct one but flow can't see that.
41
- result.push(filterPrimitive);
54
+ let filterName = matches[1].toLowerCase();
55
+ if (filterName === 'drop-shadow') {
56
+ const dropShadow = parseDropShadow(matches[2]);
57
+ if (dropShadow != null) {
58
+ result.push({dropShadow});
59
+ } else {
60
+ return [];
61
+ }
42
62
  } else {
43
- // If any primitive is invalid then apply none of the filters. This is how
44
- // web works and makes it clear that something is wrong becuase no
45
- // graphical effects are happening.
46
- return [];
63
+ const camelizedName =
64
+ filterName === 'drop-shadow'
65
+ ? 'dropShadow'
66
+ : filterName === 'hue-rotate'
67
+ ? 'hueRotate'
68
+ : filterName;
69
+ const amount = _getFilterAmount(camelizedName, matches[2]);
70
+
71
+ if (amount != null) {
72
+ const filterFunction = {};
73
+ // $FlowFixMe The key will be the correct one but flow can't see that.
74
+ filterFunction[camelizedName] = amount;
75
+ // $FlowFixMe The key will be the correct one but flow can't see that.
76
+ result.push(filterFunction);
77
+ } else {
78
+ // If any primitive is invalid then apply none of the filters. This is how
79
+ // web works and makes it clear that something is wrong becuase no
80
+ // graphical effects are happening.
81
+ return [];
82
+ }
47
83
  }
48
84
  }
49
- } else {
50
- for (const filterPrimitive of filter) {
51
- const [filterName, filterValue] = Object.entries(filterPrimitive)[0];
52
- const amount = _getFilterAmount(filterName, filterValue);
53
-
54
- if (amount != null) {
55
- const resultObject = {};
56
- // $FlowFixMe
57
- resultObject[filterName] = amount;
85
+ } else if (Array.isArray(filter)) {
86
+ for (const filterFunction of filter) {
87
+ const [filterName, filterValue] = Object.entries(filterFunction)[0];
88
+ if (filterName === 'dropShadow') {
58
89
  // $FlowFixMe
59
- result.push(resultObject);
90
+ const dropShadow = parseDropShadow(filterValue);
91
+ if (dropShadow == null) {
92
+ return [];
93
+ }
94
+ result.push({dropShadow});
60
95
  } else {
61
- // If any primitive is invalid then apply none of the filters. This is how
62
- // web works and makes it clear that something is wrong becuase no
63
- // graphical effects are happening.
64
- return [];
96
+ const amount = _getFilterAmount(filterName, filterValue);
97
+
98
+ if (amount != null) {
99
+ const resultObject = {};
100
+ // $FlowFixMe
101
+ resultObject[filterName] = amount;
102
+ // $FlowFixMe
103
+ result.push(resultObject);
104
+ } else {
105
+ // If any primitive is invalid then apply none of the filters. This is how
106
+ // web works and makes it clear that something is wrong becuase no
107
+ // graphical effects are happening.
108
+ return [];
109
+ }
65
110
  }
66
111
  }
112
+ } else {
113
+ throw new TypeError(`${typeof filter} filter is not a string or array`);
67
114
  }
68
115
 
69
116
  return result;
@@ -130,3 +177,145 @@ function _getFilterAmount(filterName: string, filterArgs: mixed): ?number {
130
177
  return undefined;
131
178
  }
132
179
  }
180
+
181
+ function parseDropShadow(
182
+ rawDropShadow: string | DropShadowPrimitive,
183
+ ): ?ParsedDropShadow {
184
+ const dropShadow =
185
+ typeof rawDropShadow === 'string'
186
+ ? parseDropShadowString(rawDropShadow)
187
+ : rawDropShadow;
188
+
189
+ const parsedDropShadow: ParsedDropShadow = {
190
+ offsetX: 0,
191
+ offsetY: 0,
192
+ };
193
+ let offsetX: number;
194
+ let offsetY: number;
195
+
196
+ for (const arg in dropShadow) {
197
+ let value;
198
+ switch (arg) {
199
+ case 'offsetX':
200
+ value =
201
+ typeof dropShadow.offsetX === 'string'
202
+ ? parseLength(dropShadow.offsetX)
203
+ : dropShadow.offsetX;
204
+ if (value == null) {
205
+ return null;
206
+ }
207
+ offsetX = value;
208
+ break;
209
+ case 'offsetY':
210
+ value =
211
+ typeof dropShadow.offsetY === 'string'
212
+ ? parseLength(dropShadow.offsetY)
213
+ : dropShadow.offsetY;
214
+ if (value == null) {
215
+ return null;
216
+ }
217
+ offsetY = value;
218
+ break;
219
+ case 'standardDeviation':
220
+ value =
221
+ typeof dropShadow.standardDeviation === 'string'
222
+ ? parseLength(dropShadow.standardDeviation)
223
+ : dropShadow.standardDeviation;
224
+ if (value == null || value < 0) {
225
+ return null;
226
+ }
227
+ parsedDropShadow.standardDeviation = value;
228
+ break;
229
+ case 'color':
230
+ const color = processColor(dropShadow.color);
231
+ if (color == null) {
232
+ return null;
233
+ }
234
+ parsedDropShadow.color = color;
235
+ break;
236
+ default:
237
+ return null;
238
+ }
239
+ }
240
+
241
+ if (offsetX == null || offsetY == null) {
242
+ return null;
243
+ }
244
+
245
+ parsedDropShadow.offsetX = offsetX;
246
+ parsedDropShadow.offsetY = offsetY;
247
+
248
+ return parsedDropShadow;
249
+ }
250
+
251
+ function parseDropShadowString(rawDropShadow: string): ?DropShadowPrimitive {
252
+ const dropShadow: DropShadowPrimitive = {
253
+ offsetX: 0,
254
+ offsetY: 0,
255
+ };
256
+ let offsetX: string;
257
+ let offsetY: string;
258
+ let lengthCount = 0;
259
+ let keywordDetectedAfterLength = false;
260
+
261
+ // split args by all whitespaces that are not in parenthesis
262
+ for (const arg of rawDropShadow.split(/\s+(?![^(]*\))/)) {
263
+ const processedColor = processColor(arg);
264
+ if (processedColor != null) {
265
+ if (dropShadow.color != null) {
266
+ return null;
267
+ }
268
+ if (offsetX != null) {
269
+ keywordDetectedAfterLength = true;
270
+ }
271
+ dropShadow.color = arg;
272
+ continue;
273
+ }
274
+
275
+ switch (lengthCount) {
276
+ case 0:
277
+ offsetX = arg;
278
+ lengthCount++;
279
+ break;
280
+ case 1:
281
+ if (keywordDetectedAfterLength) {
282
+ return null;
283
+ }
284
+ offsetY = arg;
285
+ lengthCount++;
286
+ break;
287
+ case 2:
288
+ if (keywordDetectedAfterLength) {
289
+ return null;
290
+ }
291
+ dropShadow.standardDeviation = arg;
292
+ lengthCount++;
293
+ break;
294
+ default:
295
+ return null;
296
+ }
297
+ }
298
+ if (offsetX == null || offsetY == null) {
299
+ return null;
300
+ }
301
+
302
+ dropShadow.offsetX = offsetX;
303
+ dropShadow.offsetY = offsetY;
304
+ return dropShadow;
305
+ }
306
+
307
+ function parseLength(length: string): ?number {
308
+ // matches on args with units like "1.5 5% -80deg"
309
+ const argsWithUnitsRegex = /([+-]?\d*(\.\d+)?)([\w\W]+)?/g;
310
+ const match = argsWithUnitsRegex.exec(length);
311
+
312
+ if (!match || Number.isNaN(match[1])) {
313
+ return null;
314
+ }
315
+
316
+ if (match[3] != null && match[3] !== 'px') {
317
+ return null;
318
+ }
319
+
320
+ return Number(match[1]);
321
+ }