@office-iss/react-native-win32 0.0.0-canary.258 → 0.0.0-canary.260
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.
- package/.flowconfig +2 -4
- package/CHANGELOG.json +31 -1
- package/CHANGELOG.md +24 -8
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Animated/AnimatedImplementation.js +7 -7
- package/Libraries/Animated/animations/Animation.js +10 -0
- package/Libraries/Animated/animations/TimingAnimation.js +1 -0
- package/Libraries/Animated/components/AnimatedScrollView.js +2 -2
- package/Libraries/Animated/createAnimatedComponent.js +1 -1
- package/Libraries/Animated/nodes/AnimatedValue.js +1 -0
- package/Libraries/Animated/useAnimatedProps.js +138 -6
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/FileReader.js +1 -1
- package/Libraries/Blob/URL.js +2 -62
- package/Libraries/Blob/URLSearchParams.js +71 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +3 -0
- package/Libraries/Components/ScrollView/ScrollView.js +5 -5
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +3 -0
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -1
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +3 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
- package/Libraries/Components/TextInput/TextInput.js +220 -80
- package/Libraries/Components/TextInput/TextInput.win32.js +220 -86
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +2 -0
- package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/Libraries/Components/View/ViewNativeComponent.js +6 -0
- package/Libraries/Components/View/ViewPropTypes.js +14 -0
- package/Libraries/Components/View/ViewPropTypes.win32.js +14 -0
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/InitializeCore.js +1 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/setUpErrorHandling.js +7 -1
- package/Libraries/Core/setUpReactRefresh.js +0 -4
- package/Libraries/Image/AssetSourceResolver.js +28 -1
- package/Libraries/Image/Image.android.js +9 -14
- package/Libraries/Image/Image.ios.js +11 -22
- package/Libraries/Image/Image.win32.js +10 -21
- package/Libraries/Image/ImageBackground.js +1 -8
- package/Libraries/Image/ImageUtils.js +9 -9
- package/Libraries/Image/ImageViewNativeComponent.js +4 -0
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/SectionList.js +2 -2
- package/Libraries/Lists/SectionListModern.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +31 -4
- package/Libraries/NativeComponent/BaseViewConfig.android.js +2 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +7 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +9 -2
- package/Libraries/Network/XMLHttpRequest.js +4 -2
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
- package/Libraries/ReactNative/RendererImplementation.js +24 -2
- package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
- package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -1
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +57 -19
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -23
- package/Libraries/StyleSheet/processBackgroundImage.js +286 -0
- package/Libraries/StyleSheet/processBoxShadow.js +211 -0
- package/Libraries/StyleSheet/processFilter.js +24 -14
- package/Libraries/Text/Text.js +395 -212
- package/Libraries/Text/Text.win32.js +443 -245
- package/Libraries/Text/TextNativeComponent.js +7 -0
- package/Libraries/Text/TextNativeComponent.win32.js +7 -0
- package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
- package/Libraries/Types/CodegenTypes.js +3 -1
- package/Libraries/Utilities/HMRClient.js +1 -0
- package/Libraries/Utilities/Platform.android.js +1 -1
- package/Libraries/Utilities/Platform.d.ts +1 -1
- package/Libraries/Utilities/Platform.flow.js +2 -2
- package/Libraries/Utilities/Platform.flow.win32.js +3 -3
- package/Libraries/Utilities/Platform.ios.js +1 -1
- package/Libraries/Utilities/Platform.win32.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +1 -0
- package/flow/jest.js +2 -2
- package/index.js +1 -0
- package/index.win32.js +1 -0
- package/jest/mockModal.js +1 -3
- package/jest/mockScrollView.js +1 -1
- package/jest/renderer.js +2 -2
- package/jest/setup.js +16 -9
- package/overrides.json +16 -16
- package/package.json +15 -15
- package/src/private/{core/components → components}/HScrollViewNativeComponents.js +8 -8
- package/src/private/{core/components → components}/VScrollViewNativeComponents.js +7 -7
- package/src/private/{core/components → components}/useSyncOnScroll.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +143 -19
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +25 -5
- package/src/private/hooks/DebouncedEffectImplementation.js +148 -0
- package/src/private/hooks/useDebouncedEffect.js +23 -0
- package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
- package/src/private/setup/setUpDOM.js +28 -0
- package/src/private/setup/setUpIntersectionObserver.js +27 -0
- package/src/private/setup/setUpMutationObserver.js +26 -0
- package/src/private/setup/setUpPerformanceObserver.js +64 -0
- package/src/private/specs/modules/NativeDebuggerSessionObserver.js +23 -0
- package/src/private/specs/modules/NativeLinkingManager.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsAndroid.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsIOS.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsWin.js +8 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +1 -1
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +5 -8
- package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +1 -1
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +5 -5
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
- package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
- package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
- package/src/private/webapis/performance/LongTasks.js +39 -0
- package/src/private/webapis/performance/Performance.js +22 -9
- package/src/private/webapis/performance/PerformanceEntry.js +36 -18
- package/src/private/webapis/performance/PerformanceObserver.js +29 -43
- package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
- package/src/private/webapis/performance/UserTiming.js +17 -12
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
- package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/types/experimental.d.ts +20 -1
- package/Libraries/Core/setUpIntersectionObserver.js +0 -16
- package/Libraries/Core/setUpMutationObserver.js +0 -16
- package/Libraries/Core/setUpPerformanceObserver.js +0 -18
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
- package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
- package/Libraries/Text/TextOptimized.js +0 -538
- package/src/private/core/setUpDOM.js +0 -18
- package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
- /package/src/private/{core → styles}/composeStyles.js +0 -0
|
@@ -1,538 +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
|
-
import type {PressEvent} from '../Types/CoreEventTypes';
|
|
12
|
-
import type {NativeTextProps} from './TextNativeComponent';
|
|
13
|
-
import type {PressRetentionOffset, TextProps} from './TextProps';
|
|
14
|
-
|
|
15
|
-
import * as PressabilityDebug from '../Pressability/PressabilityDebug';
|
|
16
|
-
import usePressability from '../Pressability/usePressability';
|
|
17
|
-
import flattenStyle from '../StyleSheet/flattenStyle';
|
|
18
|
-
import processColor from '../StyleSheet/processColor';
|
|
19
|
-
import Platform from '../Utilities/Platform';
|
|
20
|
-
import TextAncestor from './TextAncestor';
|
|
21
|
-
import {NativeText, NativeVirtualText} from './TextNativeComponent';
|
|
22
|
-
import * as React from 'react';
|
|
23
|
-
import {useContext, useMemo, useState} from 'react';
|
|
24
|
-
|
|
25
|
-
type TextForwardRef = React.ElementRef<
|
|
26
|
-
typeof NativeText | typeof NativeVirtualText,
|
|
27
|
-
>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Text is the fundamental component for displaying text.
|
|
31
|
-
*
|
|
32
|
-
* @see https://reactnative.dev/docs/text
|
|
33
|
-
*
|
|
34
|
-
* NOTE: This file is a short term fork of `Text` for the purpose of performance
|
|
35
|
-
* testing. Any changes to either this component or `Text` should be avoided
|
|
36
|
-
* while this file exists.
|
|
37
|
-
*
|
|
38
|
-
* Specific differences from `Text`:
|
|
39
|
-
* - Lazy init Pressability via a nested component
|
|
40
|
-
* - Skip children context wrapper when safe.
|
|
41
|
-
* - Move props destructuring to function param.
|
|
42
|
-
*/
|
|
43
|
-
const TextOptimized: React.AbstractComponent<TextProps, TextForwardRef> =
|
|
44
|
-
React.forwardRef(
|
|
45
|
-
(
|
|
46
|
-
{
|
|
47
|
-
accessible,
|
|
48
|
-
accessibilityLabel,
|
|
49
|
-
accessibilityState,
|
|
50
|
-
allowFontScaling,
|
|
51
|
-
'aria-busy': ariaBusy,
|
|
52
|
-
'aria-checked': ariaChecked,
|
|
53
|
-
'aria-disabled': ariaDisabled,
|
|
54
|
-
'aria-expanded': ariaExpanded,
|
|
55
|
-
'aria-label': ariaLabel,
|
|
56
|
-
'aria-selected': ariaSelected,
|
|
57
|
-
children,
|
|
58
|
-
ellipsizeMode,
|
|
59
|
-
disabled,
|
|
60
|
-
id,
|
|
61
|
-
nativeID,
|
|
62
|
-
numberOfLines,
|
|
63
|
-
onLongPress,
|
|
64
|
-
onPress,
|
|
65
|
-
onPressIn,
|
|
66
|
-
onPressOut,
|
|
67
|
-
onResponderGrant,
|
|
68
|
-
onResponderMove,
|
|
69
|
-
onResponderRelease,
|
|
70
|
-
onResponderTerminate,
|
|
71
|
-
onResponderTerminationRequest,
|
|
72
|
-
onStartShouldSetResponder,
|
|
73
|
-
pressRetentionOffset,
|
|
74
|
-
selectable,
|
|
75
|
-
selectionColor,
|
|
76
|
-
suppressHighlighting,
|
|
77
|
-
style,
|
|
78
|
-
...restProps
|
|
79
|
-
}: TextProps,
|
|
80
|
-
forwardedRef,
|
|
81
|
-
) => {
|
|
82
|
-
const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
|
|
83
|
-
|
|
84
|
-
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
85
|
-
accessibilityState;
|
|
86
|
-
if (
|
|
87
|
-
ariaBusy != null ||
|
|
88
|
-
ariaChecked != null ||
|
|
89
|
-
ariaDisabled != null ||
|
|
90
|
-
ariaExpanded != null ||
|
|
91
|
-
ariaSelected != null
|
|
92
|
-
) {
|
|
93
|
-
if (_accessibilityState != null) {
|
|
94
|
-
_accessibilityState = {
|
|
95
|
-
busy: ariaBusy ?? _accessibilityState.busy,
|
|
96
|
-
checked: ariaChecked ?? _accessibilityState.checked,
|
|
97
|
-
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
98
|
-
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
99
|
-
selected: ariaSelected ?? _accessibilityState.selected,
|
|
100
|
-
};
|
|
101
|
-
} else {
|
|
102
|
-
_accessibilityState = {
|
|
103
|
-
busy: ariaBusy,
|
|
104
|
-
checked: ariaChecked,
|
|
105
|
-
disabled: ariaDisabled,
|
|
106
|
-
expanded: ariaExpanded,
|
|
107
|
-
selected: ariaSelected,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const _accessibilityStateDisabled = _accessibilityState?.disabled;
|
|
113
|
-
const _disabled = disabled ?? _accessibilityStateDisabled;
|
|
114
|
-
|
|
115
|
-
const isPressable =
|
|
116
|
-
(onPress != null ||
|
|
117
|
-
onLongPress != null ||
|
|
118
|
-
onStartShouldSetResponder != null) &&
|
|
119
|
-
_disabled !== true;
|
|
120
|
-
|
|
121
|
-
// TODO: Move this processing to the view configuration.
|
|
122
|
-
const _selectionColor =
|
|
123
|
-
selectionColor == null ? null : processColor(selectionColor);
|
|
124
|
-
|
|
125
|
-
let _style = style;
|
|
126
|
-
if (__DEV__) {
|
|
127
|
-
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
128
|
-
_style = [style, {color: 'magenta'}];
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let _numberOfLines = numberOfLines;
|
|
133
|
-
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
134
|
-
if (__DEV__) {
|
|
135
|
-
console.error(
|
|
136
|
-
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
_numberOfLines = 0;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
let _selectable = selectable;
|
|
143
|
-
|
|
144
|
-
const processedStyle = flattenStyle(_style);
|
|
145
|
-
if (processedStyle != null) {
|
|
146
|
-
if (typeof processedStyle.fontWeight === 'number') {
|
|
147
|
-
// $FlowFixMe[cannot-write]
|
|
148
|
-
processedStyle.fontWeight = processedStyle.fontWeight.toString();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (processedStyle.userSelect != null) {
|
|
152
|
-
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
153
|
-
// $FlowFixMe[cannot-write]
|
|
154
|
-
delete processedStyle.userSelect;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (processedStyle.verticalAlign != null) {
|
|
158
|
-
// $FlowFixMe[cannot-write]
|
|
159
|
-
processedStyle.textAlignVertical =
|
|
160
|
-
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
161
|
-
// $FlowFixMe[cannot-write]
|
|
162
|
-
delete processedStyle.verticalAlign;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const _nativeID = id ?? nativeID;
|
|
167
|
-
|
|
168
|
-
const hasTextAncestor = useContext(TextAncestor);
|
|
169
|
-
if (hasTextAncestor) {
|
|
170
|
-
if (isPressable) {
|
|
171
|
-
return (
|
|
172
|
-
<NativePressableVirtualText
|
|
173
|
-
ref={forwardedRef}
|
|
174
|
-
textProps={{
|
|
175
|
-
...restProps,
|
|
176
|
-
accessibilityLabel: _accessibilityLabel,
|
|
177
|
-
accessibilityState: _accessibilityState,
|
|
178
|
-
nativeID: _nativeID,
|
|
179
|
-
numberOfLines: _numberOfLines,
|
|
180
|
-
selectable: _selectable,
|
|
181
|
-
selectionColor: _selectionColor,
|
|
182
|
-
style: processedStyle,
|
|
183
|
-
disabled: disabled,
|
|
184
|
-
children,
|
|
185
|
-
}}
|
|
186
|
-
textPressabilityProps={{
|
|
187
|
-
onLongPress,
|
|
188
|
-
onPress,
|
|
189
|
-
onPressIn,
|
|
190
|
-
onPressOut,
|
|
191
|
-
onResponderGrant,
|
|
192
|
-
onResponderMove,
|
|
193
|
-
onResponderRelease,
|
|
194
|
-
onResponderTerminate,
|
|
195
|
-
onResponderTerminationRequest,
|
|
196
|
-
onStartShouldSetResponder,
|
|
197
|
-
pressRetentionOffset,
|
|
198
|
-
suppressHighlighting,
|
|
199
|
-
}}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return (
|
|
205
|
-
<NativeVirtualText
|
|
206
|
-
{...restProps}
|
|
207
|
-
accessibilityLabel={_accessibilityLabel}
|
|
208
|
-
accessibilityState={_accessibilityState}
|
|
209
|
-
isHighlighted={false}
|
|
210
|
-
isPressable={false}
|
|
211
|
-
nativeID={_nativeID}
|
|
212
|
-
numberOfLines={_numberOfLines}
|
|
213
|
-
ref={forwardedRef}
|
|
214
|
-
selectable={_selectable}
|
|
215
|
-
selectionColor={_selectionColor}
|
|
216
|
-
style={processedStyle}
|
|
217
|
-
disabled={disabled}>
|
|
218
|
-
{children}
|
|
219
|
-
</NativeVirtualText>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
224
|
-
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
225
|
-
if (
|
|
226
|
-
_disabled !== _accessibilityStateDisabled &&
|
|
227
|
-
((_disabled != null && _disabled !== false) ||
|
|
228
|
-
(_accessibilityStateDisabled != null &&
|
|
229
|
-
_accessibilityStateDisabled !== false))
|
|
230
|
-
) {
|
|
231
|
-
_accessibilityState = {..._accessibilityState, disabled: _disabled};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const _accessible = Platform.select({
|
|
235
|
-
ios: accessible !== false,
|
|
236
|
-
android:
|
|
237
|
-
accessible == null
|
|
238
|
-
? onPress != null || onLongPress != null
|
|
239
|
-
: accessible,
|
|
240
|
-
default: accessible,
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
let nativeText = null;
|
|
244
|
-
if (isPressable) {
|
|
245
|
-
nativeText = (
|
|
246
|
-
<NativePressableText
|
|
247
|
-
ref={forwardedRef}
|
|
248
|
-
textProps={{
|
|
249
|
-
...restProps,
|
|
250
|
-
accessibilityLabel: _accessibilityLabel,
|
|
251
|
-
accessibilityState: _accessibilityState,
|
|
252
|
-
accessible: _accessible,
|
|
253
|
-
allowFontScaling: allowFontScaling !== false,
|
|
254
|
-
disabled: _disabled,
|
|
255
|
-
ellipsizeMode: ellipsizeMode ?? 'tail',
|
|
256
|
-
nativeID: _nativeID,
|
|
257
|
-
numberOfLines: _numberOfLines,
|
|
258
|
-
selectable: _selectable,
|
|
259
|
-
selectionColor: _selectionColor,
|
|
260
|
-
style: processedStyle,
|
|
261
|
-
children,
|
|
262
|
-
}}
|
|
263
|
-
textPressabilityProps={{
|
|
264
|
-
onLongPress,
|
|
265
|
-
onPress,
|
|
266
|
-
onPressIn,
|
|
267
|
-
onPressOut,
|
|
268
|
-
onResponderGrant,
|
|
269
|
-
onResponderMove,
|
|
270
|
-
onResponderRelease,
|
|
271
|
-
onResponderTerminate,
|
|
272
|
-
onResponderTerminationRequest,
|
|
273
|
-
onStartShouldSetResponder,
|
|
274
|
-
pressRetentionOffset,
|
|
275
|
-
suppressHighlighting,
|
|
276
|
-
}}
|
|
277
|
-
/>
|
|
278
|
-
);
|
|
279
|
-
} else {
|
|
280
|
-
nativeText = (
|
|
281
|
-
<NativeText
|
|
282
|
-
{...restProps}
|
|
283
|
-
accessibilityLabel={_accessibilityLabel}
|
|
284
|
-
accessibilityState={_accessibilityState}
|
|
285
|
-
accessible={_accessible}
|
|
286
|
-
allowFontScaling={allowFontScaling !== false}
|
|
287
|
-
disabled={_disabled}
|
|
288
|
-
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
289
|
-
isHighlighted={false}
|
|
290
|
-
nativeID={_nativeID}
|
|
291
|
-
numberOfLines={_numberOfLines}
|
|
292
|
-
ref={forwardedRef}
|
|
293
|
-
selectable={_selectable}
|
|
294
|
-
selectionColor={_selectionColor}
|
|
295
|
-
style={processedStyle}>
|
|
296
|
-
{children}
|
|
297
|
-
</NativeText>
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (children == null) {
|
|
302
|
-
return nativeText;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// If the children do not contain a JSX element it would not be possible to have a
|
|
306
|
-
// nested `Text` component so we can skip adding the `TextAncestor` context wrapper
|
|
307
|
-
// which has a performance overhead. Since we do this for performance reasons we need
|
|
308
|
-
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
309
|
-
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
310
|
-
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
311
|
-
if (Array.isArray(children) && children.length <= 3) {
|
|
312
|
-
let hasNonTextChild = false;
|
|
313
|
-
for (let child of children) {
|
|
314
|
-
if (child != null && typeof child === 'object') {
|
|
315
|
-
hasNonTextChild = true;
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
if (!hasNonTextChild) {
|
|
320
|
-
return nativeText;
|
|
321
|
-
}
|
|
322
|
-
} else if (typeof children !== 'object') {
|
|
323
|
-
return nativeText;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return (
|
|
327
|
-
<TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
|
|
328
|
-
);
|
|
329
|
-
},
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
TextOptimized.displayName = 'TextOptimized';
|
|
333
|
-
|
|
334
|
-
type TextPressabilityProps = $ReadOnly<{
|
|
335
|
-
onLongPress?: ?(event: PressEvent) => mixed,
|
|
336
|
-
onPress?: ?(event: PressEvent) => mixed,
|
|
337
|
-
onPressIn?: ?(event: PressEvent) => mixed,
|
|
338
|
-
onPressOut?: ?(event: PressEvent) => mixed,
|
|
339
|
-
onResponderGrant?: ?(event: PressEvent) => void,
|
|
340
|
-
onResponderMove?: ?(event: PressEvent) => void,
|
|
341
|
-
onResponderRelease?: ?(event: PressEvent) => void,
|
|
342
|
-
onResponderTerminate?: ?(event: PressEvent) => void,
|
|
343
|
-
onResponderTerminationRequest?: ?() => boolean,
|
|
344
|
-
onStartShouldSetResponder?: ?() => boolean,
|
|
345
|
-
pressRetentionOffset?: ?PressRetentionOffset,
|
|
346
|
-
suppressHighlighting?: ?boolean,
|
|
347
|
-
}>;
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Hook that handles setting up Pressability of Text components.
|
|
351
|
-
*
|
|
352
|
-
* NOTE: This hook is relatively expensive so it should only be used absolutely necessary.
|
|
353
|
-
*/
|
|
354
|
-
function useTextPressability({
|
|
355
|
-
onLongPress,
|
|
356
|
-
onPress,
|
|
357
|
-
onPressIn,
|
|
358
|
-
onPressOut,
|
|
359
|
-
onResponderGrant,
|
|
360
|
-
onResponderMove,
|
|
361
|
-
onResponderRelease,
|
|
362
|
-
onResponderTerminate,
|
|
363
|
-
onResponderTerminationRequest,
|
|
364
|
-
onStartShouldSetResponder,
|
|
365
|
-
pressRetentionOffset,
|
|
366
|
-
suppressHighlighting,
|
|
367
|
-
}: TextPressabilityProps) {
|
|
368
|
-
const [isHighlighted, setHighlighted] = useState(false);
|
|
369
|
-
|
|
370
|
-
// Setup pressability config and wrap callbacks needs to track the highlight state.
|
|
371
|
-
const config = useMemo(() => {
|
|
372
|
-
let _onPressIn = onPressIn;
|
|
373
|
-
let _onPressOut = onPressOut;
|
|
374
|
-
|
|
375
|
-
// Updating isHighlighted causes unnecessary re-renders for platforms that don't use it
|
|
376
|
-
// in the best case, and cause issues with text selection in the worst case. Forcing
|
|
377
|
-
// the isHighlighted prop to false on all platforms except iOS.
|
|
378
|
-
if (Platform.OS === 'ios') {
|
|
379
|
-
_onPressIn = (event: PressEvent) => {
|
|
380
|
-
setHighlighted(suppressHighlighting == null || !suppressHighlighting);
|
|
381
|
-
onPressIn?.(event);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
_onPressOut = (event: PressEvent) => {
|
|
385
|
-
setHighlighted(false);
|
|
386
|
-
onPressOut?.(event);
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
return {
|
|
391
|
-
disabled: false,
|
|
392
|
-
pressRectOffset: pressRetentionOffset,
|
|
393
|
-
onLongPress,
|
|
394
|
-
onPress,
|
|
395
|
-
onPressIn: _onPressIn,
|
|
396
|
-
onPressOut: _onPressOut,
|
|
397
|
-
};
|
|
398
|
-
}, [
|
|
399
|
-
pressRetentionOffset,
|
|
400
|
-
onLongPress,
|
|
401
|
-
onPress,
|
|
402
|
-
onPressIn,
|
|
403
|
-
onPressOut,
|
|
404
|
-
suppressHighlighting,
|
|
405
|
-
]);
|
|
406
|
-
|
|
407
|
-
// Init the pressability class
|
|
408
|
-
const eventHandlers = usePressability(config);
|
|
409
|
-
|
|
410
|
-
// Create NativeText event handlers which proxy events to pressability
|
|
411
|
-
const eventHandlersForText = useMemo(
|
|
412
|
-
() =>
|
|
413
|
-
eventHandlers == null
|
|
414
|
-
? null
|
|
415
|
-
: {
|
|
416
|
-
onResponderGrant(event: PressEvent) {
|
|
417
|
-
eventHandlers.onResponderGrant(event);
|
|
418
|
-
if (onResponderGrant != null) {
|
|
419
|
-
onResponderGrant(event);
|
|
420
|
-
}
|
|
421
|
-
},
|
|
422
|
-
onResponderMove(event: PressEvent) {
|
|
423
|
-
eventHandlers.onResponderMove(event);
|
|
424
|
-
if (onResponderMove != null) {
|
|
425
|
-
onResponderMove(event);
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
onResponderRelease(event: PressEvent) {
|
|
429
|
-
eventHandlers.onResponderRelease(event);
|
|
430
|
-
if (onResponderRelease != null) {
|
|
431
|
-
onResponderRelease(event);
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
onResponderTerminate(event: PressEvent) {
|
|
435
|
-
eventHandlers.onResponderTerminate(event);
|
|
436
|
-
if (onResponderTerminate != null) {
|
|
437
|
-
onResponderTerminate(event);
|
|
438
|
-
}
|
|
439
|
-
},
|
|
440
|
-
onClick: eventHandlers.onClick,
|
|
441
|
-
onResponderTerminationRequest:
|
|
442
|
-
onResponderTerminationRequest != null
|
|
443
|
-
? onResponderTerminationRequest
|
|
444
|
-
: eventHandlers.onResponderTerminationRequest,
|
|
445
|
-
onStartShouldSetResponder:
|
|
446
|
-
onStartShouldSetResponder != null
|
|
447
|
-
? onStartShouldSetResponder
|
|
448
|
-
: eventHandlers.onStartShouldSetResponder,
|
|
449
|
-
},
|
|
450
|
-
[
|
|
451
|
-
eventHandlers,
|
|
452
|
-
onResponderGrant,
|
|
453
|
-
onResponderMove,
|
|
454
|
-
onResponderRelease,
|
|
455
|
-
onResponderTerminate,
|
|
456
|
-
onResponderTerminationRequest,
|
|
457
|
-
onStartShouldSetResponder,
|
|
458
|
-
],
|
|
459
|
-
);
|
|
460
|
-
|
|
461
|
-
// Return the highlight state and NativeText event handlers
|
|
462
|
-
return useMemo(
|
|
463
|
-
() => [isHighlighted, eventHandlersForText],
|
|
464
|
-
[isHighlighted, eventHandlersForText],
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
type NativePressableTextProps = $ReadOnly<{
|
|
469
|
-
textProps: NativeTextProps,
|
|
470
|
-
textPressabilityProps: TextPressabilityProps,
|
|
471
|
-
}>;
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Wrap the NativeVirtualText component and initialize pressability.
|
|
475
|
-
*
|
|
476
|
-
* This logic is split out from the main Text component to enable the more
|
|
477
|
-
* expensive pressability logic to be only initialized when needed.
|
|
478
|
-
*/
|
|
479
|
-
const NativePressableVirtualText: React.AbstractComponent<
|
|
480
|
-
NativePressableTextProps,
|
|
481
|
-
TextForwardRef,
|
|
482
|
-
> = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
|
|
483
|
-
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
484
|
-
textPressabilityProps,
|
|
485
|
-
);
|
|
486
|
-
|
|
487
|
-
return (
|
|
488
|
-
<NativeVirtualText
|
|
489
|
-
{...textProps}
|
|
490
|
-
{...eventHandlersForText}
|
|
491
|
-
isHighlighted={isHighlighted}
|
|
492
|
-
isPressable={true}
|
|
493
|
-
ref={forwardedRef}
|
|
494
|
-
/>
|
|
495
|
-
);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Wrap the NativeText component and initialize pressability.
|
|
500
|
-
*
|
|
501
|
-
* This logic is split out from the main Text component to enable the more
|
|
502
|
-
* expensive pressability logic to be only initialized when needed.
|
|
503
|
-
*/
|
|
504
|
-
const NativePressableText: React.AbstractComponent<
|
|
505
|
-
NativePressableTextProps,
|
|
506
|
-
TextForwardRef,
|
|
507
|
-
> = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
|
|
508
|
-
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
509
|
-
textPressabilityProps,
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
return (
|
|
513
|
-
<NativeText
|
|
514
|
-
{...textProps}
|
|
515
|
-
{...eventHandlersForText}
|
|
516
|
-
isHighlighted={isHighlighted}
|
|
517
|
-
isPressable={true}
|
|
518
|
-
ref={forwardedRef}
|
|
519
|
-
/>
|
|
520
|
-
);
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
const userSelectToSelectableMap = {
|
|
524
|
-
auto: true,
|
|
525
|
-
text: true,
|
|
526
|
-
none: false,
|
|
527
|
-
contain: true,
|
|
528
|
-
all: true,
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
const verticalAlignToTextAlignVerticalMap = {
|
|
532
|
-
auto: 'auto',
|
|
533
|
-
top: 'top',
|
|
534
|
-
bottom: 'bottom',
|
|
535
|
-
middle: 'center',
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
module.exports = TextOptimized;
|
|
@@ -1,18 +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 DOMRect from '../webapis/dom/geometry/DOMRect';
|
|
12
|
-
import DOMRectReadOnly from '../webapis/dom/geometry/DOMRectReadOnly';
|
|
13
|
-
|
|
14
|
-
// $FlowExpectedError[cannot-write] The global isn't writable anywhere but here, where we define it
|
|
15
|
-
global.DOMRect = DOMRect;
|
|
16
|
-
|
|
17
|
-
// $FlowExpectedError[cannot-write] The global isn't writable anywhere but here, where we define it
|
|
18
|
-
global.DOMRectReadOnly = DOMRectReadOnly;
|
|
@@ -1,55 +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
|
-
* @flow strict
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {HighResTimeStamp, PerformanceEntryJSON} from './PerformanceEntry';
|
|
12
|
-
|
|
13
|
-
import {PerformanceEntry} from './PerformanceEntry';
|
|
14
|
-
|
|
15
|
-
export type PerformanceEventTimingJSON = {
|
|
16
|
-
...PerformanceEntryJSON,
|
|
17
|
-
processingStart: HighResTimeStamp,
|
|
18
|
-
processingEnd: HighResTimeStamp,
|
|
19
|
-
interactionId: number,
|
|
20
|
-
...
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default class PerformanceEventTiming extends PerformanceEntry {
|
|
24
|
-
processingStart: HighResTimeStamp;
|
|
25
|
-
processingEnd: HighResTimeStamp;
|
|
26
|
-
interactionId: number;
|
|
27
|
-
|
|
28
|
-
constructor(init: {
|
|
29
|
-
name: string,
|
|
30
|
-
startTime?: HighResTimeStamp,
|
|
31
|
-
duration?: HighResTimeStamp,
|
|
32
|
-
processingStart?: HighResTimeStamp,
|
|
33
|
-
processingEnd?: HighResTimeStamp,
|
|
34
|
-
interactionId?: number,
|
|
35
|
-
}) {
|
|
36
|
-
super({
|
|
37
|
-
name: init.name,
|
|
38
|
-
entryType: 'event',
|
|
39
|
-
startTime: init.startTime ?? 0,
|
|
40
|
-
duration: init.duration ?? 0,
|
|
41
|
-
});
|
|
42
|
-
this.processingStart = init.processingStart ?? 0;
|
|
43
|
-
this.processingEnd = init.processingEnd ?? 0;
|
|
44
|
-
this.interactionId = init.interactionId ?? 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
toJSON(): PerformanceEventTimingJSON {
|
|
48
|
-
return {
|
|
49
|
-
...super.toJSON(),
|
|
50
|
-
processingStart: this.processingStart,
|
|
51
|
-
processingEnd: this.processingEnd,
|
|
52
|
-
interactionId: this.interactionId,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
File without changes
|