@office-iss/react-native-win32 0.0.0-canary.257 → 0.0.0-canary.259

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 (73) hide show
  1. package/.flowconfig +3 -3
  2. package/CHANGELOG.json +55 -1
  3. package/CHANGELOG.md +28 -8
  4. package/Libraries/Alert/Alert.js +3 -0
  5. package/Libraries/Animated/nodes/AnimatedValue.js +1 -0
  6. package/Libraries/Animated/useAnimatedProps.js +68 -3
  7. package/Libraries/BatchedBridge/NativeModules.js +2 -0
  8. package/Libraries/Components/ScrollView/ScrollView.js +124 -165
  9. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +3 -0
  10. package/Libraries/Components/TextInput/TextInput.js +204 -73
  11. package/Libraries/Components/TextInput/TextInput.win32.js +204 -79
  12. package/Libraries/Components/View/ReactNativeStyleAttributes.js +11 -0
  13. package/Libraries/Core/ErrorHandlers.js +9 -0
  14. package/Libraries/Core/ExceptionsManager.js +2 -0
  15. package/Libraries/Core/InitializeCore.js +2 -0
  16. package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
  17. package/Libraries/Core/ReactNativeVersion.js +3 -3
  18. package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
  19. package/Libraries/Core/setUpGlobals.js +1 -0
  20. package/Libraries/Core/setUpReactRefresh.js +0 -4
  21. package/Libraries/Image/ImageViewNativeComponent.js +1 -0
  22. package/Libraries/Interaction/TaskQueue.js +1 -0
  23. package/Libraries/Lists/SectionList.js +1 -1
  24. package/Libraries/LogBox/Data/LogBoxData.js +1 -0
  25. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +20 -8
  26. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +20 -8
  27. package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
  28. package/Libraries/NativeComponent/BaseViewConfig.ios.js +3 -0
  29. package/Libraries/NativeComponent/BaseViewConfig.win32.js +3 -0
  30. package/Libraries/NativeComponent/NativeComponentRegistry.js +9 -2
  31. package/Libraries/ReactNative/AppContainer-dev.js +1 -5
  32. package/Libraries/ReactNative/AppContainer-prod.js +1 -5
  33. package/Libraries/ReactNative/AppContainer.js +0 -1
  34. package/Libraries/ReactNative/AppRegistry.js +0 -6
  35. package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
  36. package/Libraries/ReactNative/renderApplication.js +0 -2
  37. package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -1
  38. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +46 -0
  39. package/Libraries/StyleSheet/StyleSheetTypes.js +48 -5
  40. package/Libraries/StyleSheet/processBoxShadow.js +211 -0
  41. package/Libraries/StyleSheet/processFilter.js +226 -41
  42. package/Libraries/Text/Text.js +393 -196
  43. package/Libraries/Text/Text.win32.js +440 -228
  44. package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
  45. package/Libraries/Types/CodegenTypes.js +3 -1
  46. package/Libraries/Utilities/HMRClient.js +1 -0
  47. package/Libraries/Utilities/Platform.android.js +1 -1
  48. package/Libraries/Utilities/Platform.d.ts +1 -1
  49. package/Libraries/Utilities/Platform.flow.js +2 -2
  50. package/Libraries/Utilities/Platform.flow.win32.js +3 -3
  51. package/Libraries/Utilities/Platform.ios.js +1 -1
  52. package/Libraries/Utilities/Platform.win32.js +1 -1
  53. package/Libraries/vendor/emitter/EventEmitter.js +1 -0
  54. package/index.js +1 -0
  55. package/index.win32.js +1 -0
  56. package/jest/mockComponent.js +4 -1
  57. package/jest/setup.js +8 -1
  58. package/overrides.json +11 -11
  59. package/package.json +23 -23
  60. package/src/private/core/components/HScrollViewNativeComponents.js +55 -0
  61. package/src/private/core/components/VScrollViewNativeComponents.js +47 -0
  62. package/src/private/core/components/useSyncOnScroll.js +48 -0
  63. package/src/private/featureflags/ReactNativeFeatureFlags.js +70 -12
  64. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +12 -4
  65. package/src/private/specs/modules/NativeLinkingManager.js +1 -1
  66. package/src/private/specs/modules/NativePlatformConstantsAndroid.js +1 -1
  67. package/src/private/specs/modules/NativePlatformConstantsIOS.js +1 -1
  68. package/src/private/specs/modules/NativePlatformConstantsWin.js +8 -1
  69. package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
  70. package/src/private/webapis/performance/PerformanceEntry.js +1 -1
  71. package/src/private/webapis/performance/RawPerformanceEntry.js +5 -0
  72. package/types/experimental.d.ts +12 -1
  73. package/Libraries/Text/TextOptimized.js +0 -538
@@ -0,0 +1,211 @@
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 {ProcessedColorValue} from './processColor';
13
+ import type {BoxShadowPrimitive} from './StyleSheetTypes';
14
+
15
+ import processColor from './processColor';
16
+
17
+ export type ParsedBoxShadow = {
18
+ offsetX: number,
19
+ offsetY: number,
20
+ color?: ProcessedColorValue,
21
+ blurRadius?: number,
22
+ spreadDistance?: number,
23
+ inset?: boolean,
24
+ };
25
+
26
+ export default function processBoxShadow(
27
+ rawBoxShadows: ?($ReadOnlyArray<BoxShadowPrimitive> | string),
28
+ ): Array<ParsedBoxShadow> {
29
+ const result: Array<ParsedBoxShadow> = [];
30
+ if (rawBoxShadows == null) {
31
+ return result;
32
+ }
33
+
34
+ const boxShadowList =
35
+ typeof rawBoxShadows === 'string'
36
+ ? parseBoxShadowString(rawBoxShadows)
37
+ : rawBoxShadows;
38
+
39
+ for (const rawBoxShadow of boxShadowList) {
40
+ const parsedBoxShadow: ParsedBoxShadow = {
41
+ offsetX: 0,
42
+ offsetY: 0,
43
+ };
44
+
45
+ let value;
46
+ for (const arg in rawBoxShadow) {
47
+ switch (arg) {
48
+ case 'offsetX':
49
+ value =
50
+ typeof rawBoxShadow.offsetX === 'string'
51
+ ? parseLength(rawBoxShadow.offsetX)
52
+ : rawBoxShadow.offsetX;
53
+ if (value == null) {
54
+ return [];
55
+ }
56
+
57
+ parsedBoxShadow.offsetX = value;
58
+ break;
59
+ case 'offsetY':
60
+ value =
61
+ typeof rawBoxShadow.offsetY === 'string'
62
+ ? parseLength(rawBoxShadow.offsetY)
63
+ : rawBoxShadow.offsetY;
64
+ if (value == null) {
65
+ return [];
66
+ }
67
+
68
+ parsedBoxShadow.offsetY = value;
69
+ break;
70
+ case 'spreadDistance':
71
+ value =
72
+ typeof rawBoxShadow.spreadDistance === 'string'
73
+ ? parseLength(rawBoxShadow.spreadDistance)
74
+ : rawBoxShadow.spreadDistance;
75
+ if (value == null) {
76
+ return [];
77
+ }
78
+
79
+ parsedBoxShadow.spreadDistance = value;
80
+ break;
81
+ case 'blurRadius':
82
+ value =
83
+ typeof rawBoxShadow.blurRadius === 'string'
84
+ ? parseLength(rawBoxShadow.blurRadius)
85
+ : rawBoxShadow.blurRadius;
86
+ if (value == null || value < 0) {
87
+ return [];
88
+ }
89
+
90
+ parsedBoxShadow.blurRadius = value;
91
+ break;
92
+ case 'color':
93
+ const color = processColor(rawBoxShadow.color);
94
+ if (color == null) {
95
+ return [];
96
+ }
97
+
98
+ parsedBoxShadow.color = color;
99
+ break;
100
+ case 'inset':
101
+ parsedBoxShadow.inset = rawBoxShadow.inset;
102
+ }
103
+ }
104
+ result.push(parsedBoxShadow);
105
+ }
106
+ return result;
107
+ }
108
+
109
+ function parseBoxShadowString(
110
+ rawBoxShadows: string,
111
+ ): Array<BoxShadowPrimitive> {
112
+ let result: Array<BoxShadowPrimitive> = [];
113
+
114
+ for (const rawBoxShadow of rawBoxShadows
115
+ .split(/,(?![^()]*\))/) // split by comma that is not in parenthesis
116
+ .map(bS => bS.trim())
117
+ .filter(bS => bS !== '')) {
118
+ const boxShadow: BoxShadowPrimitive = {
119
+ offsetX: 0,
120
+ offsetY: 0,
121
+ };
122
+ let offsetX: number | string;
123
+ let offsetY: number | string;
124
+ let keywordDetectedAfterLength = false;
125
+
126
+ let lengthCount = 0;
127
+
128
+ // split rawBoxShadow string by all whitespaces that are not in parenthesis
129
+ const args = rawBoxShadow.split(/\s+(?![^(]*\))/);
130
+ for (const arg of args) {
131
+ const processedColor = processColor(arg);
132
+ if (processedColor != null) {
133
+ if (boxShadow.color != null) {
134
+ return [];
135
+ }
136
+ if (offsetX != null) {
137
+ keywordDetectedAfterLength = true;
138
+ }
139
+ boxShadow.color = arg;
140
+ continue;
141
+ }
142
+
143
+ if (arg === 'inset') {
144
+ if (boxShadow.inset != null) {
145
+ return [];
146
+ }
147
+ if (offsetX != null) {
148
+ keywordDetectedAfterLength = true;
149
+ }
150
+ boxShadow.inset = true;
151
+ continue;
152
+ }
153
+
154
+ switch (lengthCount) {
155
+ case 0:
156
+ offsetX = arg;
157
+ lengthCount++;
158
+ break;
159
+ case 1:
160
+ if (keywordDetectedAfterLength) {
161
+ return [];
162
+ }
163
+ offsetY = arg;
164
+ lengthCount++;
165
+ break;
166
+ case 2:
167
+ if (keywordDetectedAfterLength) {
168
+ return [];
169
+ }
170
+ boxShadow.blurRadius = arg;
171
+ lengthCount++;
172
+ break;
173
+ case 3:
174
+ if (keywordDetectedAfterLength) {
175
+ return [];
176
+ }
177
+ boxShadow.spreadDistance = arg;
178
+ lengthCount++;
179
+ break;
180
+ default:
181
+ return [];
182
+ }
183
+ }
184
+
185
+ if (offsetX == null || offsetY == null) {
186
+ return [];
187
+ }
188
+
189
+ boxShadow.offsetX = offsetX;
190
+ boxShadow.offsetY = offsetY;
191
+
192
+ result.push(boxShadow);
193
+ }
194
+ return result;
195
+ }
196
+
197
+ function parseLength(length: string): ?number {
198
+ // matches on args with units like "1.5 5% -80deg"
199
+ const argsWithUnitsRegex = /([+-]?\d*(\.\d+)?)([\w\W]+)?/g;
200
+ const match = argsWithUnitsRegex.exec(length);
201
+
202
+ if (!match || Number.isNaN(match[1])) {
203
+ return null;
204
+ }
205
+
206
+ if (match[3] != null && match[3] !== 'px') {
207
+ return null;
208
+ }
209
+
210
+ return Number(match[1]);
211
+ }
@@ -4,64 +4,107 @@
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
+ // matches on functions with args like "drop-shadow(1.5)"
48
+ const regex = /([\w-]+)\(([^)]+)\)/g;
31
49
  let matches;
32
50
 
33
51
  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);
52
+ let filterName = matches[1].toLowerCase();
53
+ if (filterName === 'drop-shadow') {
54
+ const dropShadow = parseDropShadow(matches[2]);
55
+ if (dropShadow != null) {
56
+ result.push({dropShadow});
57
+ } else {
58
+ return [];
59
+ }
42
60
  } 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 [];
61
+ const camelizedName =
62
+ filterName === 'drop-shadow'
63
+ ? 'dropShadow'
64
+ : filterName === 'hue-rotate'
65
+ ? 'hueRotate'
66
+ : filterName;
67
+ const amount = _getFilterAmount(camelizedName, matches[2]);
68
+
69
+ if (amount != null) {
70
+ const filterFunction = {};
71
+ // $FlowFixMe The key will be the correct one but flow can't see that.
72
+ filterFunction[camelizedName] = amount;
73
+ // $FlowFixMe The key will be the correct one but flow can't see that.
74
+ result.push(filterFunction);
75
+ } else {
76
+ // If any primitive is invalid then apply none of the filters. This is how
77
+ // web works and makes it clear that something is wrong becuase no
78
+ // graphical effects are happening.
79
+ return [];
80
+ }
47
81
  }
48
82
  }
49
83
  } 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;
84
+ for (const filterFunction of filter) {
85
+ const [filterName, filterValue] = Object.entries(filterFunction)[0];
86
+ if (filterName === 'dropShadow') {
58
87
  // $FlowFixMe
59
- result.push(resultObject);
88
+ const dropShadow = parseDropShadow(filterValue);
89
+ if (dropShadow == null) {
90
+ return [];
91
+ }
92
+ result.push({dropShadow});
60
93
  } 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 [];
94
+ const amount = _getFilterAmount(filterName, filterValue);
95
+
96
+ if (amount != null) {
97
+ const resultObject = {};
98
+ // $FlowFixMe
99
+ resultObject[filterName] = amount;
100
+ // $FlowFixMe
101
+ result.push(resultObject);
102
+ } else {
103
+ // If any primitive is invalid then apply none of the filters. This is how
104
+ // web works and makes it clear that something is wrong becuase no
105
+ // graphical effects are happening.
106
+ return [];
107
+ }
65
108
  }
66
109
  }
67
110
  }
@@ -130,3 +173,145 @@ function _getFilterAmount(filterName: string, filterArgs: mixed): ?number {
130
173
  return undefined;
131
174
  }
132
175
  }
176
+
177
+ function parseDropShadow(
178
+ rawDropShadow: string | DropShadowPrimitive,
179
+ ): ?ParsedDropShadow {
180
+ const dropShadow =
181
+ typeof rawDropShadow === 'string'
182
+ ? parseDropShadowString(rawDropShadow)
183
+ : rawDropShadow;
184
+
185
+ const parsedDropShadow: ParsedDropShadow = {
186
+ offsetX: 0,
187
+ offsetY: 0,
188
+ };
189
+ let offsetX: number;
190
+ let offsetY: number;
191
+
192
+ for (const arg in dropShadow) {
193
+ let value;
194
+ switch (arg) {
195
+ case 'offsetX':
196
+ value =
197
+ typeof dropShadow.offsetX === 'string'
198
+ ? parseLength(dropShadow.offsetX)
199
+ : dropShadow.offsetX;
200
+ if (value == null) {
201
+ return null;
202
+ }
203
+ offsetX = value;
204
+ break;
205
+ case 'offsetY':
206
+ value =
207
+ typeof dropShadow.offsetY === 'string'
208
+ ? parseLength(dropShadow.offsetY)
209
+ : dropShadow.offsetY;
210
+ if (value == null) {
211
+ return null;
212
+ }
213
+ offsetY = value;
214
+ break;
215
+ case 'standardDeviation':
216
+ value =
217
+ typeof dropShadow.standardDeviation === 'string'
218
+ ? parseLength(dropShadow.standardDeviation)
219
+ : dropShadow.standardDeviation;
220
+ if (value == null || value < 0) {
221
+ return null;
222
+ }
223
+ parsedDropShadow.standardDeviation = value;
224
+ break;
225
+ case 'color':
226
+ const color = processColor(dropShadow.color);
227
+ if (color == null) {
228
+ return null;
229
+ }
230
+ parsedDropShadow.color = color;
231
+ break;
232
+ default:
233
+ return null;
234
+ }
235
+ }
236
+
237
+ if (offsetX == null || offsetY == null) {
238
+ return null;
239
+ }
240
+
241
+ parsedDropShadow.offsetX = offsetX;
242
+ parsedDropShadow.offsetY = offsetY;
243
+
244
+ return parsedDropShadow;
245
+ }
246
+
247
+ function parseDropShadowString(rawDropShadow: string): ?DropShadowPrimitive {
248
+ const dropShadow: DropShadowPrimitive = {
249
+ offsetX: 0,
250
+ offsetY: 0,
251
+ };
252
+ let offsetX: string;
253
+ let offsetY: string;
254
+ let lengthCount = 0;
255
+ let keywordDetectedAfterLength = false;
256
+
257
+ // split on all whitespaces
258
+ for (const arg of rawDropShadow.split(/\s+/)) {
259
+ const processedColor = processColor(arg);
260
+ if (processedColor != null) {
261
+ if (dropShadow.color != null) {
262
+ return null;
263
+ }
264
+ if (offsetX != null) {
265
+ keywordDetectedAfterLength = true;
266
+ }
267
+ dropShadow.color = arg;
268
+ continue;
269
+ }
270
+
271
+ switch (lengthCount) {
272
+ case 0:
273
+ offsetX = arg;
274
+ lengthCount++;
275
+ break;
276
+ case 1:
277
+ if (keywordDetectedAfterLength) {
278
+ return null;
279
+ }
280
+ offsetY = arg;
281
+ lengthCount++;
282
+ break;
283
+ case 2:
284
+ if (keywordDetectedAfterLength) {
285
+ return null;
286
+ }
287
+ dropShadow.standardDeviation = arg;
288
+ lengthCount++;
289
+ break;
290
+ default:
291
+ return null;
292
+ }
293
+ }
294
+ if (offsetX == null || offsetY == null) {
295
+ return null;
296
+ }
297
+
298
+ dropShadow.offsetX = offsetX;
299
+ dropShadow.offsetY = offsetY;
300
+ return dropShadow;
301
+ }
302
+
303
+ function parseLength(length: string): ?number {
304
+ // matches on args with units like "1.5 5% -80deg"
305
+ const argsWithUnitsRegex = /([+-]?\d*(\.\d+)?)([\w\W]+)?/g;
306
+ const match = argsWithUnitsRegex.exec(length);
307
+
308
+ if (!match || Number.isNaN(match[1])) {
309
+ return null;
310
+ }
311
+
312
+ if (match[3] != null && match[3] !== 'px') {
313
+ return null;
314
+ }
315
+
316
+ return Number(match[1]);
317
+ }