@office-iss/react-native-win32 0.75.2 → 0.76.0-preview.2
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/.eslintrc.js +11 -0
- package/.flowconfig +5 -4
- package/CHANGELOG.json +191 -47
- package/CHANGELOG.md +63 -28
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +7 -7
- package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
- package/Libraries/Animated/animations/Animation.js +11 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -1
- package/Libraries/Animated/animations/SpringAnimation.js +1 -1
- package/Libraries/Animated/animations/TimingAnimation.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +10 -9
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
- package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
- package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
- package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
- package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
- package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
- package/Libraries/Animated/useAnimatedProps.js +142 -7
- 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/Keyboard/KeyboardAvoidingView.js +17 -0
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +131 -169
- 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/RCTTextInputViewConfig.js +10 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
- package/Libraries/Components/TextInput/TextInput.js +230 -94
- package/Libraries/Components/TextInput/TextInput.win32.js +230 -100
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +23 -1
- 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 +0 -1
- 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 +3 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
- package/Libraries/Core/ReactNativeVersion.js +4 -4
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
- package/Libraries/Core/setUpDeveloperTools.js +5 -1
- package/Libraries/Core/setUpErrorHandling.js +7 -1
- package/Libraries/Core/setUpGlobals.js +1 -0
- 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 +11 -24
- package/Libraries/Image/ImageBackground.js +1 -8
- package/Libraries/Image/ImageUtils.js +9 -9
- package/Libraries/Image/ImageViewNativeComponent.js +1 -0
- package/Libraries/Inspector/Inspector.js +3 -2
- package/Libraries/Inspector/Inspector.win32.js +3 -2
- package/Libraries/Inspector/InspectorPanel.js +16 -10
- 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 +3 -3
- package/Libraries/LogBox/Data/LogBoxData.js +24 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +9 -29
- package/Libraries/Modal/Modal.js +0 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +9 -1
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +17 -1
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +17 -1
- package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
- package/Libraries/Network/XMLHttpRequest.js +4 -2
- package/Libraries/ReactNative/AppContainer-dev.js +1 -5
- package/Libraries/ReactNative/AppContainer-prod.js +1 -5
- package/Libraries/ReactNative/AppContainer.js +0 -1
- package/Libraries/ReactNative/AppRegistry.js +0 -6
- 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 +26 -4
- package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
- package/Libraries/ReactNative/renderApplication.js +0 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +152 -2
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
- package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
- package/Libraries/StyleSheet/processBoxShadow.js +209 -0
- package/Libraries/StyleSheet/processFilter.js +231 -42
- package/Libraries/Text/Text.js +394 -196
- package/Libraries/Text/Text.win32.js +442 -229
- package/Libraries/Text/TextNativeComponent.js +2 -1
- package/Libraries/Text/TextNativeComponent.win32.js +1 -1
- package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
- package/Libraries/Types/CodegenTypes.js +3 -1
- package/Libraries/Utilities/Appearance.js +108 -84
- package/Libraries/Utilities/DevLoadingView.js +2 -4
- package/Libraries/Utilities/HMRClient.js +8 -6
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +0 -9
- package/Libraries/Utilities/stringifyViewConfig.js +22 -0
- package/Libraries/Utilities/useColorScheme.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/promiseRejectionTrackingOptions.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +6 -5
- package/flow/jest.js +2 -2
- package/index.js +3 -1
- package/index.win32.js +3 -1
- package/jest/mockComponent.js +4 -1
- package/jest/mockModal.js +1 -3
- package/jest/mockScrollView.js +1 -1
- package/jest/renderer.js +2 -2
- package/jest/setup.js +16 -13
- package/jest.config.js +1 -2
- package/overrides.json +22 -22
- package/package.json +32 -30
- package/src/private/animated/NativeAnimatedHelper.js +438 -0
- package/src/private/animated/NativeAnimatedHelper.win32.js +440 -0
- package/src/private/animated/NativeAnimatedValidation.js +64 -0
- package/src/private/components/HScrollViewNativeComponents.js +56 -0
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +29 -0
- package/src/private/components/VScrollViewNativeComponents.js +48 -0
- package/src/private/components/useSyncOnScroll.js +48 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
- package/src/private/fusebox/FuseboxSessionObserver.js +42 -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/NativeAppearance.js +3 -3
- package/src/private/specs/modules/NativeLinkingManager.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsWin.js +7 -0
- package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
- 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 +5 -3
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
- 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 +12 -98
- package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +0 -617
- 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/Utilities/verifyComponentAttributeEquivalence.js +0 -135
- 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
|
@@ -110,11 +110,102 @@ export interface FlexStyle {
|
|
|
110
110
|
top?: DimensionValue | undefined;
|
|
111
111
|
width?: DimensionValue | undefined;
|
|
112
112
|
zIndex?: number | undefined;
|
|
113
|
+
direction?: 'inherit' | 'ltr' | 'rtl' | undefined;
|
|
113
114
|
|
|
114
115
|
/**
|
|
115
|
-
*
|
|
116
|
+
* Equivalent to `top`, `bottom`, `right` and `left`
|
|
116
117
|
*/
|
|
117
|
-
|
|
118
|
+
inset?: DimensionValue | undefined;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Equivalent to `top`, `bottom`
|
|
122
|
+
*/
|
|
123
|
+
insetBlock?: DimensionValue | undefined;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Equivalent to `bottom`
|
|
127
|
+
*/
|
|
128
|
+
insetBlockEnd?: DimensionValue | undefined;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Equivalent to `top`
|
|
132
|
+
*/
|
|
133
|
+
insetBlockStart?: DimensionValue | undefined;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Equivalent to `right` and `left`
|
|
137
|
+
*/
|
|
138
|
+
insetInline?: DimensionValue | undefined;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Equivalent to `right` or `left`
|
|
142
|
+
*/
|
|
143
|
+
insetInlineEnd?: DimensionValue | undefined;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Equivalent to `right` or `left`
|
|
147
|
+
*/
|
|
148
|
+
insetInlineStart?: DimensionValue | undefined;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Equivalent to `marginVertical`
|
|
152
|
+
*/
|
|
153
|
+
marginBlock?: DimensionValue | undefined;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Equivalent to `marginBottom`
|
|
157
|
+
*/
|
|
158
|
+
marginBlockEnd?: DimensionValue | undefined;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Equivalent to `marginTop`
|
|
162
|
+
*/
|
|
163
|
+
marginBlockStart?: DimensionValue | undefined;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Equivalent to `marginHorizontal`
|
|
167
|
+
*/
|
|
168
|
+
marginInline?: DimensionValue | undefined;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Equivalent to `marginEnd`
|
|
172
|
+
*/
|
|
173
|
+
marginInlineEnd?: DimensionValue | undefined;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Equivalent to `marginStart`
|
|
177
|
+
*/
|
|
178
|
+
marginInlineStart?: DimensionValue | undefined;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Equivalent to `paddingVertical`
|
|
182
|
+
*/
|
|
183
|
+
paddingBlock?: DimensionValue | undefined;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Equivalent to `paddingBottom`
|
|
187
|
+
*/
|
|
188
|
+
paddingBlockEnd?: DimensionValue | undefined;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Equivalent to `paddingTop`
|
|
192
|
+
*/
|
|
193
|
+
paddingBlockStart?: DimensionValue | undefined;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Equivalent to `paddingHorizontal`
|
|
197
|
+
*/
|
|
198
|
+
paddingInline?: DimensionValue | undefined;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Equivalent to `paddingEnd`
|
|
202
|
+
*/
|
|
203
|
+
paddingInlineEnd?: DimensionValue | undefined;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Equivalent to `paddingStart`
|
|
207
|
+
*/
|
|
208
|
+
paddingInlineStart?: DimensionValue | undefined;
|
|
118
209
|
}
|
|
119
210
|
|
|
120
211
|
export interface ShadowStyleIOS {
|
|
@@ -229,6 +320,62 @@ export interface TransformsStyle {
|
|
|
229
320
|
translateY?: AnimatableNumericValue | undefined;
|
|
230
321
|
}
|
|
231
322
|
|
|
323
|
+
export type FilterFunction =
|
|
324
|
+
| {brightness: number | string}
|
|
325
|
+
| {blur: number | string}
|
|
326
|
+
| {contrast: number | string}
|
|
327
|
+
| {grayscale: number | string}
|
|
328
|
+
| {hueRotate: number | string}
|
|
329
|
+
| {invert: number | string}
|
|
330
|
+
| {opacity: number | string}
|
|
331
|
+
| {saturate: number | string}
|
|
332
|
+
| {sepia: number | string}
|
|
333
|
+
| {dropShadow: DropShadowValue | string};
|
|
334
|
+
|
|
335
|
+
export type DropShadowValue = {
|
|
336
|
+
offsetX: number | string;
|
|
337
|
+
offsetY: number | string;
|
|
338
|
+
standardDeviation?: number | string | undefined;
|
|
339
|
+
color?: ColorValue | number | undefined;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export type BoxShadowValue = {
|
|
343
|
+
offsetX: number | string;
|
|
344
|
+
offsetY: number | string;
|
|
345
|
+
color?: string | undefined;
|
|
346
|
+
blurRadius?: ColorValue | number | undefined;
|
|
347
|
+
spreadDistance?: number | string | undefined;
|
|
348
|
+
inset?: boolean | undefined;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export type BlendMode =
|
|
352
|
+
| 'normal'
|
|
353
|
+
| 'multiply'
|
|
354
|
+
| 'screen'
|
|
355
|
+
| 'overlay'
|
|
356
|
+
| 'darken'
|
|
357
|
+
| 'lighten'
|
|
358
|
+
| 'color-dodge'
|
|
359
|
+
| 'color-burn'
|
|
360
|
+
| 'hard-light'
|
|
361
|
+
| 'soft-light'
|
|
362
|
+
| 'difference'
|
|
363
|
+
| 'exclusion'
|
|
364
|
+
| 'hue'
|
|
365
|
+
| 'saturation'
|
|
366
|
+
| 'color'
|
|
367
|
+
| 'luminosity';
|
|
368
|
+
|
|
369
|
+
export type GradientValue = {
|
|
370
|
+
type: 'linearGradient';
|
|
371
|
+
// Angle or direction enums
|
|
372
|
+
direction?: string | undefined;
|
|
373
|
+
colorStops: ReadonlyArray<{
|
|
374
|
+
color: ColorValue;
|
|
375
|
+
positions?: ReadonlyArray<string[]> | undefined;
|
|
376
|
+
}>;
|
|
377
|
+
};
|
|
378
|
+
|
|
232
379
|
/**
|
|
233
380
|
* @see https://reactnative.dev/docs/view#style
|
|
234
381
|
*/
|
|
@@ -278,7 +425,10 @@ export interface ViewStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle {
|
|
|
278
425
|
* Controls whether the View can be the target of touch events.
|
|
279
426
|
*/
|
|
280
427
|
pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto' | undefined;
|
|
428
|
+
isolation?: 'auto' | 'isolate' | undefined;
|
|
281
429
|
cursor?: CursorValue | undefined;
|
|
430
|
+
boxShadow?: ReadonlyArray<BoxShadowValue> | string | undefined;
|
|
431
|
+
filter?: ReadonlyArray<FilterFunction> | string | undefined;
|
|
282
432
|
}
|
|
283
433
|
|
|
284
434
|
export type FontVariant =
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type AnimatedNode from '../Animated/nodes/AnimatedNode';
|
|
14
|
-
import type {FilterPrimitive} from '../StyleSheet/processFilter';
|
|
15
14
|
import type {
|
|
16
15
|
____DangerouslyImpreciseStyle_InternalOverrides,
|
|
17
16
|
____ImageStyle_InternalOverrides,
|
|
@@ -691,15 +690,66 @@ export type ____ShadowStyle_Internal = $ReadOnly<{
|
|
|
691
690
|
...____ShadowStyle_InternalOverrides,
|
|
692
691
|
}>;
|
|
693
692
|
|
|
694
|
-
type
|
|
695
|
-
|
|
696
|
-
}
|
|
693
|
+
export type FilterFunction =
|
|
694
|
+
| {brightness: number | string}
|
|
695
|
+
| {blur: number | string}
|
|
696
|
+
| {contrast: number | string}
|
|
697
|
+
| {grayscale: number | string}
|
|
698
|
+
| {hueRotate: number | string}
|
|
699
|
+
| {invert: number | string}
|
|
700
|
+
| {opacity: number | string}
|
|
701
|
+
| {saturate: number | string}
|
|
702
|
+
| {sepia: number | string}
|
|
703
|
+
| {dropShadow: DropShadowValue | string};
|
|
704
|
+
|
|
705
|
+
export type DropShadowValue = {
|
|
706
|
+
offsetX: number | string,
|
|
707
|
+
offsetY: number | string,
|
|
708
|
+
standardDeviation?: number | string,
|
|
709
|
+
color?: ____ColorValue_Internal,
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
export type GradientValue = {
|
|
713
|
+
type: 'linearGradient',
|
|
714
|
+
// Angle or direction enums
|
|
715
|
+
direction?: string,
|
|
716
|
+
colorStops: $ReadOnlyArray<{
|
|
717
|
+
color: ____ColorValue_Internal,
|
|
718
|
+
positions?: $ReadOnlyArray<string>,
|
|
719
|
+
}>,
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
export type BoxShadowValue = {
|
|
723
|
+
offsetX: number | string,
|
|
724
|
+
offsetY: number | string,
|
|
725
|
+
color?: ____ColorValue_Internal,
|
|
726
|
+
blurRadius?: number | string,
|
|
727
|
+
spreadDistance?: number | string,
|
|
728
|
+
inset?: boolean,
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
type ____BlendMode_Internal =
|
|
732
|
+
| 'normal'
|
|
733
|
+
| 'multiply'
|
|
734
|
+
| 'screen'
|
|
735
|
+
| 'overlay'
|
|
736
|
+
| 'darken'
|
|
737
|
+
| 'lighten'
|
|
738
|
+
| 'color-dodge'
|
|
739
|
+
| 'color-burn'
|
|
740
|
+
| 'hard-light'
|
|
741
|
+
| 'soft-light'
|
|
742
|
+
| 'difference'
|
|
743
|
+
| 'exclusion'
|
|
744
|
+
| 'hue'
|
|
745
|
+
| 'saturation'
|
|
746
|
+
| 'color'
|
|
747
|
+
| 'luminosity';
|
|
697
748
|
|
|
698
749
|
export type ____ViewStyle_InternalCore = $ReadOnly<{
|
|
699
750
|
...$Exact<____LayoutStyle_Internal>,
|
|
700
751
|
...$Exact<____ShadowStyle_Internal>,
|
|
701
752
|
...$Exact<____TransformStyle_Internal>,
|
|
702
|
-
...____FilterStyle_Internal,
|
|
703
753
|
backfaceVisibility?: 'visible' | 'hidden',
|
|
704
754
|
backgroundColor?: ____ColorValue_Internal,
|
|
705
755
|
borderColor?: ____ColorValue_Internal,
|
|
@@ -738,6 +788,11 @@ export type ____ViewStyle_InternalCore = $ReadOnly<{
|
|
|
738
788
|
elevation?: number,
|
|
739
789
|
pointerEvents?: 'auto' | 'none' | 'box-none' | 'box-only',
|
|
740
790
|
cursor?: CursorValue,
|
|
791
|
+
boxShadow?: $ReadOnlyArray<BoxShadowValue> | string,
|
|
792
|
+
filter?: $ReadOnlyArray<FilterFunction> | string,
|
|
793
|
+
experimental_mixBlendMode?: ____BlendMode_Internal,
|
|
794
|
+
experimental_backgroundImage?: $ReadOnlyArray<GradientValue> | string,
|
|
795
|
+
isolation?: 'auto' | 'isolate',
|
|
741
796
|
}>;
|
|
742
797
|
|
|
743
798
|
export type ____ViewStyle_Internal = $ReadOnly<{
|
|
@@ -0,0 +1,384 @@
|
|
|
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-local
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import type {ProcessedColorValue} from './processColor';
|
|
14
|
+
import type {GradientValue} from './StyleSheetTypes';
|
|
15
|
+
|
|
16
|
+
const processColor = require('./processColor').default;
|
|
17
|
+
const DIRECTION_REGEX =
|
|
18
|
+
/^to\s+(?:top|bottom|left|right)(?:\s+(?:top|bottom|left|right))?/;
|
|
19
|
+
const ANGLE_UNIT_REGEX = /^([+-]?\d*\.?\d+)(deg|grad|rad|turn)$/i;
|
|
20
|
+
|
|
21
|
+
const TO_BOTTOM_START_END_POINTS = {
|
|
22
|
+
start: {x: 0.5, y: 0},
|
|
23
|
+
end: {x: 0.5, y: 1},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type ParsedGradientValue = {
|
|
27
|
+
type: 'linearGradient',
|
|
28
|
+
start: {x: number, y: number},
|
|
29
|
+
end: {x: number, y: number},
|
|
30
|
+
colorStops: $ReadOnlyArray<{
|
|
31
|
+
color: ProcessedColorValue,
|
|
32
|
+
position: number,
|
|
33
|
+
}>,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default function processBackgroundImage(
|
|
37
|
+
backgroundImage: ?($ReadOnlyArray<GradientValue> | string),
|
|
38
|
+
): $ReadOnlyArray<ParsedGradientValue> {
|
|
39
|
+
let result: $ReadOnlyArray<ParsedGradientValue> = [];
|
|
40
|
+
if (backgroundImage == null) {
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (typeof backgroundImage === 'string') {
|
|
45
|
+
result = parseCSSLinearGradient(backgroundImage.replace(/\n/g, ' '));
|
|
46
|
+
} else if (Array.isArray(backgroundImage)) {
|
|
47
|
+
for (const bgImage of backgroundImage) {
|
|
48
|
+
const processedColorStops: Array<{
|
|
49
|
+
color: ProcessedColorValue,
|
|
50
|
+
position: number | null,
|
|
51
|
+
}> = [];
|
|
52
|
+
for (let index = 0; index < bgImage.colorStops.length; index++) {
|
|
53
|
+
const colorStop = bgImage.colorStops[index];
|
|
54
|
+
const processedColor = processColor(colorStop.color);
|
|
55
|
+
if (processedColor == null) {
|
|
56
|
+
// If a color is invalid, return an empty array and do not apply gradient. Same as web.
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
if (colorStop.positions != null && colorStop.positions.length > 0) {
|
|
60
|
+
for (const position of colorStop.positions) {
|
|
61
|
+
if (position.endsWith('%')) {
|
|
62
|
+
processedColorStops.push({
|
|
63
|
+
color: processedColor,
|
|
64
|
+
position: parseFloat(position) / 100,
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
// If a position is invalid, return an empty array and do not apply gradient. Same as web.
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
processedColorStops.push({
|
|
73
|
+
color: processedColor,
|
|
74
|
+
position: null,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let points: {
|
|
80
|
+
start: ParsedGradientValue['start'],
|
|
81
|
+
end: ParsedGradientValue['end'],
|
|
82
|
+
} | null = null;
|
|
83
|
+
|
|
84
|
+
if (typeof bgImage.direction === 'undefined') {
|
|
85
|
+
points = TO_BOTTOM_START_END_POINTS;
|
|
86
|
+
} else if (ANGLE_UNIT_REGEX.test(bgImage.direction)) {
|
|
87
|
+
const angle = parseAngle(bgImage.direction);
|
|
88
|
+
if (angle != null) {
|
|
89
|
+
points = calculateStartEndPointsFromAngle(angle);
|
|
90
|
+
}
|
|
91
|
+
} else if (DIRECTION_REGEX.test(bgImage.direction)) {
|
|
92
|
+
const processedPoints = calculateStartEndPointsFromDirection(
|
|
93
|
+
bgImage.direction,
|
|
94
|
+
);
|
|
95
|
+
if (processedPoints != null) {
|
|
96
|
+
points = processedPoints;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const fixedColorStops = getFixedColorStops(processedColorStops);
|
|
101
|
+
|
|
102
|
+
if (points != null) {
|
|
103
|
+
result = result.concat({
|
|
104
|
+
type: 'linearGradient',
|
|
105
|
+
start: points.start,
|
|
106
|
+
end: points.end,
|
|
107
|
+
colorStops: fixedColorStops,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function parseCSSLinearGradient(
|
|
117
|
+
cssString: string,
|
|
118
|
+
): $ReadOnlyArray<ParsedGradientValue> {
|
|
119
|
+
const gradients = [];
|
|
120
|
+
let match;
|
|
121
|
+
const linearGradientRegex = /linear-gradient\s*\(((?:\([^)]*\)|[^())])*)\)/gi;
|
|
122
|
+
|
|
123
|
+
while ((match = linearGradientRegex.exec(cssString))) {
|
|
124
|
+
const gradientContent = match[1];
|
|
125
|
+
const parts = gradientContent.split(',');
|
|
126
|
+
let points = TO_BOTTOM_START_END_POINTS;
|
|
127
|
+
const trimmedDirection = parts[0].trim().toLowerCase();
|
|
128
|
+
const colorStopRegex =
|
|
129
|
+
/\s*((?:(?:rgba?|hsla?)\s*\([^)]+\))|#[0-9a-fA-F]+|[a-zA-Z]+)(?:\s+(-?[0-9.]+%?)(?:\s+(-?[0-9.]+%?))?)?\s*/gi;
|
|
130
|
+
|
|
131
|
+
if (ANGLE_UNIT_REGEX.test(trimmedDirection)) {
|
|
132
|
+
const angle = parseAngle(trimmedDirection);
|
|
133
|
+
if (angle != null) {
|
|
134
|
+
points = calculateStartEndPointsFromAngle(angle);
|
|
135
|
+
parts.shift();
|
|
136
|
+
} else {
|
|
137
|
+
// If an angle is invalid, return an empty array and do not apply any gradient. Same as web.
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
} else if (DIRECTION_REGEX.test(trimmedDirection)) {
|
|
141
|
+
const parsedPoints =
|
|
142
|
+
calculateStartEndPointsFromDirection(trimmedDirection);
|
|
143
|
+
if (parsedPoints != null) {
|
|
144
|
+
points = parsedPoints;
|
|
145
|
+
parts.shift();
|
|
146
|
+
} else {
|
|
147
|
+
// If a direction is invalid, return an empty array and do not apply any gradient. Same as web.
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
} else if (!colorStopRegex.test(trimmedDirection)) {
|
|
151
|
+
// If first part is not an angle/direction or a color stop, return an empty array and do not apply any gradient. Same as web.
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
colorStopRegex.lastIndex = 0;
|
|
155
|
+
|
|
156
|
+
const colorStops = [];
|
|
157
|
+
const fullColorStopsStr = parts.join(',');
|
|
158
|
+
let colorStopMatch;
|
|
159
|
+
while ((colorStopMatch = colorStopRegex.exec(fullColorStopsStr))) {
|
|
160
|
+
const [, color, position1, position2] = colorStopMatch;
|
|
161
|
+
const processedColor = processColor(color.trim().toLowerCase());
|
|
162
|
+
if (processedColor == null) {
|
|
163
|
+
// If a color is invalid, return an empty array and do not apply any gradient. Same as web.
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (typeof position1 !== 'undefined') {
|
|
168
|
+
if (position1.endsWith('%')) {
|
|
169
|
+
colorStops.push({
|
|
170
|
+
color: processedColor,
|
|
171
|
+
position: parseFloat(position1) / 100,
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
// If a position is invalid, return an empty array and do not apply any gradient. Same as web.
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
colorStops.push({
|
|
179
|
+
color: processedColor,
|
|
180
|
+
position: null,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (typeof position2 !== 'undefined') {
|
|
185
|
+
if (position2.endsWith('%')) {
|
|
186
|
+
colorStops.push({
|
|
187
|
+
color: processedColor,
|
|
188
|
+
position: parseFloat(position2) / 100,
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
// If a position is invalid, return an empty array and do not apply any gradient. Same as web.
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const fixedColorStops = getFixedColorStops(colorStops);
|
|
198
|
+
|
|
199
|
+
gradients.push({
|
|
200
|
+
type: 'linearGradient',
|
|
201
|
+
start: points.start,
|
|
202
|
+
end: points.end,
|
|
203
|
+
colorStops: fixedColorStops,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return gradients;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function calculateStartEndPointsFromDirection(direction: string): ?{
|
|
211
|
+
start: {x: number, y: number},
|
|
212
|
+
end: {x: number, y: number},
|
|
213
|
+
} {
|
|
214
|
+
// Remove extra whitespace
|
|
215
|
+
const normalizedDirection = direction.replace(/\s+/g, ' ');
|
|
216
|
+
|
|
217
|
+
switch (normalizedDirection) {
|
|
218
|
+
case 'to right':
|
|
219
|
+
return {
|
|
220
|
+
start: {x: 0, y: 0.5},
|
|
221
|
+
end: {x: 1, y: 0.5},
|
|
222
|
+
};
|
|
223
|
+
case 'to left':
|
|
224
|
+
return {
|
|
225
|
+
start: {x: 1, y: 0.5},
|
|
226
|
+
end: {x: 0, y: 0.5},
|
|
227
|
+
};
|
|
228
|
+
case 'to bottom':
|
|
229
|
+
return TO_BOTTOM_START_END_POINTS;
|
|
230
|
+
case 'to top':
|
|
231
|
+
return {
|
|
232
|
+
start: {x: 0.5, y: 1},
|
|
233
|
+
end: {x: 0.5, y: 0},
|
|
234
|
+
};
|
|
235
|
+
case 'to bottom right':
|
|
236
|
+
case 'to right bottom':
|
|
237
|
+
return {
|
|
238
|
+
start: {x: 0, y: 0},
|
|
239
|
+
end: {x: 1, y: 1},
|
|
240
|
+
};
|
|
241
|
+
case 'to top left':
|
|
242
|
+
case 'to left top':
|
|
243
|
+
return {
|
|
244
|
+
start: {x: 1, y: 1},
|
|
245
|
+
end: {x: 0, y: 0},
|
|
246
|
+
};
|
|
247
|
+
case 'to bottom left':
|
|
248
|
+
case 'to left bottom':
|
|
249
|
+
return {
|
|
250
|
+
start: {x: 1, y: 0},
|
|
251
|
+
end: {x: 0, y: 1},
|
|
252
|
+
};
|
|
253
|
+
case 'to top right':
|
|
254
|
+
case 'to right top':
|
|
255
|
+
return {
|
|
256
|
+
start: {x: 0, y: 1},
|
|
257
|
+
end: {x: 1, y: 0},
|
|
258
|
+
};
|
|
259
|
+
default:
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function calculateStartEndPointsFromAngle(angleRadians: number): {
|
|
265
|
+
start: {x: number, y: number},
|
|
266
|
+
end: {x: number, y: number},
|
|
267
|
+
} {
|
|
268
|
+
// Normalize angle to be between 0 and 2π
|
|
269
|
+
let angleRadiansNormalized = angleRadians % (2 * Math.PI);
|
|
270
|
+
if (angleRadiansNormalized < 0) {
|
|
271
|
+
angleRadiansNormalized += 2 * Math.PI;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const endX = 0.5 + 0.5 * Math.sin(angleRadiansNormalized);
|
|
275
|
+
const endY = 0.5 - 0.5 * Math.cos(angleRadiansNormalized);
|
|
276
|
+
|
|
277
|
+
const startX = 1 - endX;
|
|
278
|
+
const startY = 1 - endY;
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
start: {x: startX, y: startY},
|
|
282
|
+
end: {x: endX, y: endY},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function parseAngle(angle: string): ?number {
|
|
287
|
+
const match = angle.match(ANGLE_UNIT_REGEX);
|
|
288
|
+
if (!match) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const [, value, unit] = match;
|
|
293
|
+
|
|
294
|
+
const numericValue = parseFloat(value);
|
|
295
|
+
switch (unit) {
|
|
296
|
+
case 'deg':
|
|
297
|
+
return (numericValue * Math.PI) / 180;
|
|
298
|
+
case 'grad':
|
|
299
|
+
return (numericValue * Math.PI) / 200;
|
|
300
|
+
case 'rad':
|
|
301
|
+
return numericValue;
|
|
302
|
+
case 'turn':
|
|
303
|
+
return numericValue * 2 * Math.PI;
|
|
304
|
+
default:
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// https://drafts.csswg.org/css-images-4/#color-stop-fixup
|
|
310
|
+
function getFixedColorStops(
|
|
311
|
+
colorStops: $ReadOnlyArray<{
|
|
312
|
+
color: ProcessedColorValue,
|
|
313
|
+
position: number | null,
|
|
314
|
+
}>,
|
|
315
|
+
): Array<{
|
|
316
|
+
color: ProcessedColorValue,
|
|
317
|
+
position: number,
|
|
318
|
+
}> {
|
|
319
|
+
let fixedColorStops: Array<{
|
|
320
|
+
color: ProcessedColorValue,
|
|
321
|
+
position: number,
|
|
322
|
+
}> = [];
|
|
323
|
+
let hasNullPositions = false;
|
|
324
|
+
let maxPositionSoFar = colorStops[0].position ?? 0;
|
|
325
|
+
for (let i = 0; i < colorStops.length; i++) {
|
|
326
|
+
const colorStop = colorStops[i];
|
|
327
|
+
let newPosition = colorStop.position;
|
|
328
|
+
if (newPosition === null) {
|
|
329
|
+
// Step 1:
|
|
330
|
+
// If the first color stop does not have a position,
|
|
331
|
+
// set its position to 0%. If the last color stop does not have a position,
|
|
332
|
+
// set its position to 100%.
|
|
333
|
+
if (i === 0) {
|
|
334
|
+
newPosition = 0;
|
|
335
|
+
} else if (i === colorStops.length - 1) {
|
|
336
|
+
newPosition = 1;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
// Step 2:
|
|
340
|
+
// If a color stop or transition hint has a position
|
|
341
|
+
// that is less than the specified position of any color stop or transition hint
|
|
342
|
+
// before it in the list, set its position to be equal to the
|
|
343
|
+
// largest specified position of any color stop or transition hint before it.
|
|
344
|
+
if (newPosition !== null) {
|
|
345
|
+
newPosition = Math.max(newPosition, maxPositionSoFar);
|
|
346
|
+
fixedColorStops[i] = {
|
|
347
|
+
color: colorStop.color,
|
|
348
|
+
position: newPosition,
|
|
349
|
+
};
|
|
350
|
+
maxPositionSoFar = newPosition;
|
|
351
|
+
} else {
|
|
352
|
+
hasNullPositions = true;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Step 3:
|
|
357
|
+
// If any color stop still does not have a position,
|
|
358
|
+
// then, for each run of adjacent color stops without positions,
|
|
359
|
+
// set their positions so that they are evenly spaced between the preceding and
|
|
360
|
+
// following color stops with positions.
|
|
361
|
+
if (hasNullPositions) {
|
|
362
|
+
let lastDefinedIndex = 0;
|
|
363
|
+
for (let i = 1; i < fixedColorStops.length; i++) {
|
|
364
|
+
if (fixedColorStops[i] !== undefined) {
|
|
365
|
+
const unpositionedStops = i - lastDefinedIndex - 1;
|
|
366
|
+
if (unpositionedStops > 0) {
|
|
367
|
+
const startPosition = fixedColorStops[lastDefinedIndex].position;
|
|
368
|
+
const endPosition = fixedColorStops[i].position;
|
|
369
|
+
const increment =
|
|
370
|
+
(endPosition - startPosition) / (unpositionedStops + 1);
|
|
371
|
+
for (let j = 1; j <= unpositionedStops; j++) {
|
|
372
|
+
fixedColorStops[lastDefinedIndex + j] = {
|
|
373
|
+
color: colorStops[lastDefinedIndex + j].color,
|
|
374
|
+
position: startPosition + increment * j,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
lastDefinedIndex = i;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return fixedColorStops;
|
|
384
|
+
}
|