@office-iss/react-native-win32 0.0.0-canary.289 → 0.0.0-canary.290

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 (112) hide show
  1. package/.flowconfig +1 -2
  2. package/CHANGELOG.json +16 -1
  3. package/CHANGELOG.md +13 -5
  4. package/Libraries/Animated/Animated.js.flow +1 -3
  5. package/Libraries/Animated/AnimatedExports.js.flow +12 -0
  6. package/Libraries/Animated/components/AnimatedScrollView.js +2 -1
  7. package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
  8. package/Libraries/Animated/createAnimatedComponent.js +92 -56
  9. package/Libraries/Animated/nodes/AnimatedProps.js +29 -26
  10. package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -1
  11. package/Libraries/AppState/AppState.js +1 -1
  12. package/Libraries/Blob/URL.js +1 -1
  13. package/Libraries/Blob/URLSearchParams.js +106 -31
  14. package/Libraries/Blob/URLSearchParams.js.flow +12 -7
  15. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
  16. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
  17. package/Libraries/Components/Keyboard/Keyboard.js +1 -1
  18. package/Libraries/Components/Pressable/Pressable.js +14 -3
  19. package/Libraries/Components/Pressable/Pressable.win32.js +14 -3
  20. package/Libraries/Components/ScrollView/ScrollView.d.ts +1 -1
  21. package/Libraries/Components/ScrollView/ScrollView.js +14 -17
  22. package/Libraries/Components/Switch/Switch.d.ts +3 -0
  23. package/Libraries/Components/Switch/Switch.js +1 -1
  24. package/Libraries/Components/TextInput/TextInput.d.ts +64 -33
  25. package/Libraries/Components/TextInput/TextInput.flow.js +15 -16
  26. package/Libraries/Components/TextInput/TextInput.js +34 -27
  27. package/Libraries/Components/TextInput/TextInput.win32.js +34 -27
  28. package/Libraries/Components/TextInput/TextInputState.js +1 -1
  29. package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
  30. package/Libraries/Components/Touchable/TouchableBounce.js +2 -1
  31. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  32. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +2 -2
  33. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +2 -2
  34. package/Libraries/Components/Touchable/TouchableOpacity.js +2 -1
  35. package/Libraries/Components/View/ViewAccessibility.js +2 -1
  36. package/Libraries/Components/View/ViewAccessibility.win32.js +2 -1
  37. package/Libraries/Components/View/ViewPropTypes.js +49 -3
  38. package/Libraries/Components/View/ViewPropTypes.win32.js +49 -3
  39. package/Libraries/Core/ReactNativeVersion.js +1 -1
  40. package/Libraries/Debugging/DebuggingOverlayRegistry.js +3 -3
  41. package/Libraries/EventEmitter/NativeEventEmitter.js +4 -2
  42. package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +2 -2
  43. package/Libraries/Image/Image.d.ts +26 -10
  44. package/Libraries/Image/Image.js.flow +3 -3
  45. package/Libraries/Image/ImageBackground.js +2 -0
  46. package/Libraries/Image/ImageProps.js +19 -14
  47. package/Libraries/Interaction/InteractionManager.d.ts +13 -0
  48. package/Libraries/Interaction/InteractionManager.js +1 -1
  49. package/Libraries/Interaction/PanResponder.js +3 -3
  50. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
  51. package/Libraries/Linking/Linking.js +1 -1
  52. package/Libraries/Lists/FlatList.js +7 -10
  53. package/Libraries/Lists/SectionList.js +39 -42
  54. package/Libraries/Lists/SectionListModern.js +22 -31
  55. package/Libraries/Lists/VirtualizedList.js +1 -0
  56. package/Libraries/Lists/VirtualizedSectionList.js +1 -0
  57. package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
  58. package/Libraries/NativeComponent/BaseViewConfig.ios.js +1 -0
  59. package/Libraries/NativeComponent/BaseViewConfig.win32.js +1 -0
  60. package/Libraries/Network/RCTNetworking.android.js +1 -1
  61. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  62. package/Libraries/Network/RCTNetworking.js.flow +1 -1
  63. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  64. package/Libraries/NewAppScreen/components/DebugInstructions.js +1 -3
  65. package/Libraries/NewAppScreen/components/Header.js +1 -3
  66. package/Libraries/NewAppScreen/components/HermesBadge.js +1 -3
  67. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +1 -3
  68. package/Libraries/NewAppScreen/components/ReloadInstructions.js +1 -3
  69. package/Libraries/Pressability/Pressability.js +1 -1
  70. package/Libraries/Pressability/Pressability.win32.js +1 -1
  71. package/Libraries/ReactNative/AppContainer-dev.js +2 -2
  72. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -4
  73. package/Libraries/ReactNative/RendererImplementation.js +4 -0
  74. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
  75. package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -3
  76. package/Libraries/StyleSheet/StyleSheet.js +25 -2
  77. package/Libraries/StyleSheet/StyleSheet.js.flow +24 -2
  78. package/Libraries/StyleSheet/StyleSheetTypes.js +13 -3
  79. package/Libraries/StyleSheet/flattenStyle.js +7 -3
  80. package/Libraries/StyleSheet/private/_TransformStyle.js +3 -3
  81. package/Libraries/Text/Text.d.ts +2 -5
  82. package/Libraries/Text/TextProps.js +3 -2
  83. package/Libraries/Text/TextProps.win32.js +3 -2
  84. package/Libraries/Types/CoreEventTypes.d.ts +6 -1
  85. package/Libraries/Types/CoreEventTypes.js +1 -1
  86. package/Libraries/Types/CoreEventTypes.win32.js +1 -1
  87. package/Libraries/Utilities/DeviceInfo.js +2 -0
  88. package/Libraries/Utilities/Dimensions.js +1 -1
  89. package/Libraries/Utilities/Dimensions.win32.js +1 -1
  90. package/Libraries/Utilities/PlatformTypes.js +9 -3
  91. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  92. package/Libraries/vendor/core/ErrorUtils.js +2 -0
  93. package/flow/global.js +2 -0
  94. package/index.js +3 -0
  95. package/index.win32.js +3 -0
  96. package/interface.js +0 -4
  97. package/overrides.json +19 -25
  98. package/package.json +13 -13
  99. package/src/private/animated/NativeAnimatedHelper.js +3 -1
  100. package/src/private/animated/NativeAnimatedHelper.win32.js +3 -1
  101. package/src/private/animated/createAnimatedPropsHook.js +1 -0
  102. package/src/private/animated/createAnimatedPropsMemoHook.js +1 -2
  103. package/src/private/featureflags/ReactNativeFeatureFlags.js +18 -18
  104. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +3 -3
  105. package/src/private/inspector/getInspectorDataForViewAtPoint.js +2 -2
  106. package/src/private/types/HostInstance.js +61 -3
  107. package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -5
  108. package/src-win/Libraries/Text/Text.d.ts +2 -5
  109. package/types/modules/LaunchScreen.d.ts +9 -1
  110. package/Libraries/Utilities/DeviceInfo.win32.js +0 -19
  111. package/flow/jest.js +0 -1289
  112. package/src/private/utilities/ensureInstance.js +0 -21
package/.flowconfig CHANGED
@@ -31,7 +31,6 @@
31
31
  <PROJECT_ROOT>/Libraries/StyleSheet/PlatformColorValueTypes.js
32
32
  <PROJECT_ROOT>/Libraries/Text/TextProps.js
33
33
  <PROJECT_ROOT>/Libraries/Types/CoreEventTypes.js
34
- <PROJECT_ROOT>/Libraries/Utilities/DeviceInfo.js
35
34
  <PROJECT_ROOT>/Libraries/Utilities/Dimensions.js
36
35
  <PROJECT_ROOT>/Libraries/Utilities/Platform.flow.js
37
36
  <PROJECT_ROOT>/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js
@@ -168,4 +167,4 @@ untyped-import
168
167
  untyped-type-import
169
168
 
170
169
  [version]
171
- ^0.265.2
170
+ ^0.266.1
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@office-iss/react-native-win32",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 19 Jun 2025 17:15:20 GMT",
5
+ "date": "Fri, 20 Jun 2025 05:21:03 GMT",
6
+ "version": "0.0.0-canary.290",
7
+ "tag": "@office-iss/react-native-win32_v0.0.0-canary.290",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "kvineeth@microsoft.com",
12
+ "package": "@office-iss/react-native-win32",
13
+ "commit": "ca29f4ea3226621a8c1e8f9553fe55302ff6d4b9",
14
+ "comment": "Integrate RN Nightly Build 0.80.0-nightly-20250331-398ac1f71"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Thu, 19 Jun 2025 17:16:23 GMT",
6
21
  "version": "0.0.0-canary.289",
7
22
  "tag": "@office-iss/react-native-win32_v0.0.0-canary.289",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,18 +1,26 @@
1
1
  # Change Log - @office-iss/react-native-win32
2
2
 
3
- <!-- This log was last generated on Thu, 19 Jun 2025 17:15:20 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Fri, 20 Jun 2025 05:21:03 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.0.0-canary.289
7
+ ## 0.0.0-canary.290
8
8
 
9
- Thu, 19 Jun 2025 17:15:20 GMT
9
+ Fri, 20 Jun 2025 05:21:03 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
- - Integrate RN Nightly Build 0.80.0-nightly-20250317-fc7385c1e (hmalothu@microsoft.com)
14
- - Update to @types/react 19 (30809111+acoates-ms@users.noreply.github.com)
13
+ - Integrate RN Nightly Build 0.80.0-nightly-20250331-398ac1f71 (kvineeth@microsoft.com)
15
14
 
15
+ ## 0.0.0-canary.289
16
+
17
+ Thu, 19 Jun 2025 17:16:23 GMT
18
+
19
+ ### Changes
20
+
21
+ - Integrate RN Nightly Build 0.80.0-nightly-20250317-fc7385c1e (hmalothu@microsoft.com)
22
+ - Update to @types/react 19 (30809111+acoates-ms@users.noreply.github.com)
23
+
16
24
  ## 0.0.0-canary.288
17
25
 
18
26
  Fri, 30 May 2025 05:24:59 GMT
@@ -9,7 +9,5 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- import * as Animated from './AnimatedExports';
13
-
12
+ export * as default from './AnimatedExports';
14
13
  export type {CompositeAnimation, Numeric} from './AnimatedImplementation';
15
- export default Animated;
@@ -24,7 +24,19 @@ export {default as Node} from './nodes/AnimatedNode';
24
24
  export {default as Value} from './nodes/AnimatedValue';
25
25
  export {default as ValueXY} from './nodes/AnimatedValueXY';
26
26
 
27
+ /** @deprecated Use Animated.Interpolation instead */
28
+ export type {default as AnimatedInterpolation} from './nodes/AnimatedInterpolation';
29
+ /** @deprecated Use Animated.Color instead */
30
+ export type {default as AnimatedColor} from './nodes/AnimatedColor';
31
+
27
32
  export type {AnimatedValueConfig as AnimatedConfig} from './nodes/AnimatedValue';
33
+ export type {default as AnimatedNode} from './nodes/AnimatedNode';
34
+ export type {default as AnimatedAddition} from './nodes/AnimatedAddition';
35
+ export type {default as AnimatedDiffClamp} from './nodes/AnimatedDiffClamp';
36
+ export type {default as AnimatedDivision} from './nodes/AnimatedDivision';
37
+ export type {default as AnimatedModulo} from './nodes/AnimatedModulo';
38
+ export type {default as AnimatedMultiplication} from './nodes/AnimatedMultiplication';
39
+ export type {default as AnimatedSubtraction} from './nodes/AnimatedSubtraction';
28
40
 
29
41
  export const add = AnimatedImplementation.add;
30
42
  export const attachNativeEvent = AnimatedImplementation.attachNativeEvent;
@@ -46,11 +46,12 @@ const AnimatedScrollView: AnimatedComponentType<Props, Instance> =
46
46
  props.style != null
47
47
  ) {
48
48
  return (
49
- // $FlowFixMe[prop-missing]
49
+ // $FlowFixMe - It should return an Animated ScrollView but it returns a ScrollView with Animated props applied.
50
50
  <AnimatedScrollViewWithInvertedRefreshControl
51
51
  scrollEventThrottle={0.0001}
52
52
  {...props}
53
53
  ref={forwardedRef}
54
+ // $FlowFixMe[incompatible-type]
54
55
  refreshControl={props.refreshControl}
55
56
  />
56
57
  );
@@ -18,5 +18,5 @@ import * as React from 'react';
18
18
  export default (createAnimatedComponent(SectionList): AnimatedComponentType<
19
19
  React.ElementConfig<typeof SectionList>,
20
20
  // $FlowExpectedError[unclear-type]
21
- SectionList<SectionBase<any>>,
21
+ SectionList<any, SectionBase<any>>,
22
22
  >);
@@ -8,7 +8,16 @@
8
8
  * @format
9
9
  */
10
10
 
11
+ import type AnimatedAddition from './nodes/AnimatedAddition';
12
+ import type AnimatedDiffClamp from './nodes/AnimatedDiffClamp';
13
+ import type AnimatedDivision from './nodes/AnimatedDivision';
14
+ import type AnimatedInterpolation from './nodes/AnimatedInterpolation';
15
+ import type AnimatedModulo from './nodes/AnimatedModulo';
16
+ import type AnimatedMultiplication from './nodes/AnimatedMultiplication';
17
+ import type AnimatedNode from './nodes/AnimatedNode';
11
18
  import type {AnimatedPropsAllowlist} from './nodes/AnimatedProps';
19
+ import type AnimatedSubtraction from './nodes/AnimatedSubtraction';
20
+ import type AnimatedValue from './nodes/AnimatedValue';
12
21
 
13
22
  import createAnimatedPropsHook from '../../src/private/animated/createAnimatedPropsHook';
14
23
  import composeStyles from '../../src/private/styles/composeStyles';
@@ -17,34 +26,62 @@ import useMergeRefs from '../Utilities/useMergeRefs';
17
26
  import * as React from 'react';
18
27
  import {useMemo} from 'react';
19
28
 
20
- export type AnimatedProps<Props: {...}> = {
21
- // eslint-disable-next-line no-unused-vars
22
- +[_K in keyof (Props &
23
- $ReadOnly<{
24
- passthroughAnimatedPropExplicitValues?: React.ElementConfig<
25
- typeof View,
26
- >,
27
- }>)]: any,
28
- };
29
+ type Nullable = void | null;
30
+ type Primitive = string | number | boolean | symbol | void;
31
+ type Builtin = (...$ReadOnlyArray<empty>) => mixed | Date | Error | RegExp;
32
+
33
+ export type WithAnimatedValue<+T> = T extends Builtin | Nullable
34
+ ? T
35
+ : T extends Primitive
36
+ ?
37
+ | T
38
+ | AnimatedNode
39
+ | AnimatedAddition
40
+ | AnimatedSubtraction
41
+ | AnimatedDivision
42
+ | AnimatedMultiplication
43
+ | AnimatedModulo
44
+ | AnimatedDiffClamp
45
+ | AnimatedValue
46
+ | AnimatedInterpolation<number | string>
47
+ | AnimatedInterpolation<number>
48
+ | AnimatedInterpolation<string>
49
+ : T extends $ReadOnlyArray<infer P>
50
+ ? $ReadOnlyArray<WithAnimatedValue<P>>
51
+ : T extends {...}
52
+ ? {+[K in keyof T]: WithAnimatedValue<T[K]>}
53
+ : T;
29
54
 
30
- // We could use a mapped type here to introduce acceptable Animated variants
31
- // of properties, instead of doing so in the core StyleSheetTypes
32
- // Inexact Props are not supported, they'll be made exact here.
33
- export type StrictAnimatedProps<Props: {...}> = $ReadOnly<{
34
- ...$Exact<Props>,
35
- passthroughAnimatedPropExplicitValues?: ?Props,
55
+ type NonAnimatedProps =
56
+ | 'ref'
57
+ | 'innerViewRef'
58
+ | 'scrollViewRef'
59
+ | 'testID'
60
+ | 'disabled'
61
+ | 'accessibilityLabel';
62
+ type PassThroughProps = $ReadOnly<{
63
+ passthroughAnimatedPropExplicitValues?: React.ElementConfig<
64
+ typeof View,
65
+ > | null,
36
66
  }>;
37
67
 
68
+ export type AnimatedProps<Props: {...}> = {
69
+ [K in keyof Props]: K extends NonAnimatedProps
70
+ ? Props[K]
71
+ : WithAnimatedValue<Props[K]>,
72
+ } & PassThroughProps;
73
+
74
+ export type AnimatedBaseProps<Props: {...}> = {
75
+ [K in keyof Props]: K extends NonAnimatedProps
76
+ ? Props[K]
77
+ : WithAnimatedValue<Props[K]>,
78
+ };
79
+
38
80
  export type AnimatedComponentType<Props: {...}, +Instance = mixed> = component(
39
81
  ref?: React.RefSetter<Instance>,
40
82
  ...AnimatedProps<Props>
41
83
  );
42
84
 
43
- export type StrictAnimatedComponentType<
44
- Props: {...},
45
- +Instance = mixed,
46
- > = component(ref: React.RefSetter<Instance>, ...StrictAnimatedProps<Props>);
47
-
48
85
  export default function createAnimatedComponent<
49
86
  TInstance: React.ComponentType<any>,
50
87
  >(
@@ -62,48 +99,47 @@ export function unstable_createAnimatedComponentWithAllowlist<
62
99
  >(
63
100
  Component: TInstance,
64
101
  allowlist: ?AnimatedPropsAllowlist,
65
- ): StrictAnimatedComponentType<TProps, React.ElementRef<TInstance>> {
102
+ ): AnimatedComponentType<TProps, React.ElementRef<TInstance>> {
66
103
  const useAnimatedProps = createAnimatedPropsHook(allowlist);
67
104
 
68
- const AnimatedComponent: StrictAnimatedComponentType<
105
+ const AnimatedComponent: AnimatedComponentType<
69
106
  TProps,
70
107
  React.ElementRef<TInstance>,
71
- > = React.forwardRef<
72
- StrictAnimatedProps<TProps>,
73
- React.ElementRef<TInstance>,
74
- >((props, forwardedRef) => {
75
- const [reducedProps, callbackRef] = useAnimatedProps<
76
- TProps,
77
- React.ElementRef<TInstance>,
78
- >(props);
79
- const ref = useMergeRefs<React.ElementRef<TInstance>>(
80
- callbackRef,
81
- forwardedRef,
82
- );
108
+ > = React.forwardRef<AnimatedProps<TProps>, React.ElementRef<TInstance>>(
109
+ (props, forwardedRef) => {
110
+ const [reducedProps, callbackRef] = useAnimatedProps<
111
+ TProps,
112
+ React.ElementRef<TInstance>,
113
+ >(props);
114
+ const ref = useMergeRefs<React.ElementRef<TInstance>>(
115
+ callbackRef,
116
+ forwardedRef,
117
+ );
83
118
 
84
- // Some components require explicit passthrough values for animation
85
- // to work properly. For example, if an animated component is
86
- // transformed and Pressable, onPress will not work after transform
87
- // without these passthrough values.
88
- // $FlowFixMe[prop-missing]
89
- const {passthroughAnimatedPropExplicitValues, style} = reducedProps;
90
- const passthroughStyle = passthroughAnimatedPropExplicitValues?.style;
91
- const mergedStyle = useMemo(
92
- () => composeStyles(style, passthroughStyle),
93
- [passthroughStyle, style],
94
- );
119
+ // Some components require explicit passthrough values for animation
120
+ // to work properly. For example, if an animated component is
121
+ // transformed and Pressable, onPress will not work after transform
122
+ // without these passthrough values.
123
+ // $FlowFixMe[prop-missing]
124
+ const {passthroughAnimatedPropExplicitValues, style} = reducedProps;
125
+ const passthroughStyle = passthroughAnimatedPropExplicitValues?.style;
126
+ const mergedStyle = useMemo(
127
+ () => composeStyles(style, passthroughStyle),
128
+ [passthroughStyle, style],
129
+ );
95
130
 
96
- // NOTE: It is important that `passthroughAnimatedPropExplicitValues` is
97
- // spread after `reducedProps` but before `style`.
98
- return (
99
- <Component
100
- {...reducedProps}
101
- {...passthroughAnimatedPropExplicitValues}
102
- style={mergedStyle}
103
- ref={ref}
104
- />
105
- );
106
- });
131
+ // NOTE: It is important that `passthroughAnimatedPropExplicitValues` is
132
+ // spread after `reducedProps` but before `style`.
133
+ return (
134
+ <Component
135
+ {...reducedProps}
136
+ {...passthroughAnimatedPropExplicitValues}
137
+ style={mergedStyle}
138
+ ref={ref}
139
+ />
140
+ );
141
+ },
142
+ );
107
143
 
108
144
  AnimatedComponent.displayName = `Animated(${
109
145
  Component.displayName || 'Anonymous'
@@ -25,6 +25,12 @@ export type AnimatedPropsAllowlist = $ReadOnly<{
25
25
  [string]: true,
26
26
  }>;
27
27
 
28
+ type TargetView = {
29
+ +instance: TargetViewInstance,
30
+ connectedViewTag: ?number,
31
+ };
32
+ type TargetViewInstance = React.ElementRef<React.ElementType>;
33
+
28
34
  function createAnimatedProps(
29
35
  inputProps: {[string]: mixed},
30
36
  allowlist: ?AnimatedPropsAllowlist,
@@ -75,11 +81,11 @@ function createAnimatedProps(
75
81
  }
76
82
 
77
83
  export default class AnimatedProps extends AnimatedNode {
78
- #animatedView: any;
79
84
  #callback: () => void;
80
85
  #nodeKeys: $ReadOnlyArray<string>;
81
86
  #nodes: $ReadOnlyArray<AnimatedNode>;
82
87
  #props: {[string]: mixed};
88
+ #target: ?TargetView = null;
83
89
 
84
90
  constructor(
85
91
  inputProps: {[string]: mixed},
@@ -89,7 +95,6 @@ export default class AnimatedProps extends AnimatedNode {
89
95
  ) {
90
96
  super(config);
91
97
  const [nodeKeys, nodes, props] = createAnimatedProps(inputProps, allowlist);
92
- this.#animatedView = null;
93
98
  this.#nodeKeys = nodeKeys;
94
99
  this.#nodes = nodes;
95
100
  this.#props = props;
@@ -181,10 +186,10 @@ export default class AnimatedProps extends AnimatedNode {
181
186
  }
182
187
 
183
188
  __detach(): void {
184
- if (this.__isNative && this.#animatedView) {
185
- this.__disconnectAnimatedView();
189
+ if (this.__isNative && this.#target != null) {
190
+ this.#disconnectAnimatedView(this.#target);
186
191
  }
187
- this.#animatedView = null;
192
+ this.#target = null;
188
193
 
189
194
  const nodes = this.#nodes;
190
195
  for (let ii = 0, length = nodes.length; ii < length; ii++) {
@@ -210,56 +215,54 @@ export default class AnimatedProps extends AnimatedNode {
210
215
  this.__isNative = true;
211
216
 
212
217
  // Since this does not call the super.__makeNative, we need to store the
213
- // supplied platformConfig here, before calling __connectAnimatedView
218
+ // supplied platformConfig here, before calling #connectAnimatedView
214
219
  // where it will be needed to traverse the graph of attached values.
215
220
  super.__setPlatformConfig(platformConfig);
216
221
 
217
- if (this.#animatedView) {
218
- this.__connectAnimatedView();
222
+ if (this.#target != null) {
223
+ this.#connectAnimatedView(this.#target);
219
224
  }
220
225
  }
221
226
  }
222
227
 
223
- setNativeView(animatedView: any): void {
224
- if (this.#animatedView === animatedView) {
228
+ setNativeView(instance: TargetViewInstance): void {
229
+ if (this.#target?.instance === instance) {
225
230
  return;
226
231
  }
227
- this.#animatedView = animatedView;
232
+ this.#target = {instance, connectedViewTag: null};
228
233
  if (this.__isNative) {
229
- this.__connectAnimatedView();
234
+ this.#connectAnimatedView(this.#target);
230
235
  }
231
236
  }
232
237
 
233
- __connectAnimatedView(): void {
238
+ #connectAnimatedView(target: TargetView): void {
234
239
  invariant(this.__isNative, 'Expected node to be marked as "native"');
235
- let nativeViewTag: ?number = findNodeHandle(this.#animatedView);
236
- if (nativeViewTag == null) {
240
+ let viewTag: ?number = findNodeHandle(target.instance);
241
+ if (viewTag == null) {
237
242
  if (process.env.NODE_ENV === 'test') {
238
- nativeViewTag = -1;
243
+ viewTag = -1;
239
244
  } else {
240
245
  throw new Error('Unable to locate attached view in the native tree');
241
246
  }
242
247
  }
243
248
  NativeAnimatedHelper.API.connectAnimatedNodeToView(
244
249
  this.__getNativeTag(),
245
- nativeViewTag,
250
+ viewTag,
246
251
  );
252
+ target.connectedViewTag = viewTag;
247
253
  }
248
254
 
249
- __disconnectAnimatedView(): void {
255
+ #disconnectAnimatedView(target: TargetView): void {
250
256
  invariant(this.__isNative, 'Expected node to be marked as "native"');
251
- let nativeViewTag: ?number = findNodeHandle(this.#animatedView);
252
- if (nativeViewTag == null) {
253
- if (process.env.NODE_ENV === 'test') {
254
- nativeViewTag = -1;
255
- } else {
256
- throw new Error('Unable to locate attached view in the native tree');
257
- }
257
+ const viewTag = target.connectedViewTag;
258
+ if (viewTag == null) {
259
+ return;
258
260
  }
259
261
  NativeAnimatedHelper.API.disconnectAnimatedNodeFromView(
260
262
  this.__getNativeTag(),
261
- nativeViewTag,
263
+ viewTag,
262
264
  );
265
+ target.connectedViewTag = null;
263
266
  }
264
267
 
265
268
  __restoreDefaultValues(): void {
@@ -214,7 +214,9 @@ export default class AnimatedValueXY extends AnimatedWithChildren {
214
214
  *
215
215
  * See https://reactnative.dev/docs/animatedvaluexy#gettranslatetransform
216
216
  */
217
- getTranslateTransform(): Array<{[key: string]: AnimatedValue, ...}> {
217
+ getTranslateTransform(): Array<
218
+ {translateX: AnimatedValue} | {translateY: AnimatedValue},
219
+ > {
218
220
  return [{translateX: this.x}, {translateY: this.y}];
219
221
  }
220
222
 
@@ -107,7 +107,7 @@ class AppStateImpl {
107
107
  */
108
108
  addEventListener<K: AppStateEvent>(
109
109
  type: K,
110
- handler: (...$ElementType<AppStateEventDefinitions, K>) => void,
110
+ handler: (...AppStateEventDefinitions[K]) => void,
111
111
  ): EventSubscription {
112
112
  const emitter = this._emitter;
113
113
  if (emitter == null) {
@@ -160,7 +160,7 @@ export class URL {
160
160
 
161
161
  get searchParams(): URLSearchParams {
162
162
  if (this._searchParamsInstance == null) {
163
- this._searchParamsInstance = new URLSearchParams();
163
+ this._searchParamsInstance = new URLSearchParams(this.search);
164
164
  }
165
165
  return this._searchParamsInstance;
166
166
  }
@@ -11,60 +11,135 @@
11
11
  // Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src
12
12
  // The reference code bloat comes from Unicode issues with URLs, so those won't work here.
13
13
  export class URLSearchParams {
14
- _searchParams: Array<[string, string]> = [];
14
+ _searchParams: Map<string, string[]> = new Map();
15
15
 
16
- constructor(params?: Record<string, string>) {
17
- if (typeof params === 'object') {
18
- Object.keys(params).forEach(key => this.append(key, params[key]));
16
+ constructor(params?: Record<string, string> | string | [string, string][]) {
17
+ if (params === null) {
18
+ return;
19
+ }
20
+
21
+ if (typeof params === 'string') {
22
+ // URLSearchParams("key1=value1&key2=value2");
23
+ params
24
+ .replace(/^\?/, '')
25
+ .split('&')
26
+ .forEach(pair => {
27
+ if (!pair) {
28
+ return;
29
+ }
30
+ const [key, value] = pair
31
+ .split('=')
32
+ .map(part => decodeURIComponent(part.replace(/\+/g, ' ')));
33
+ this.append(key, value);
34
+ });
35
+ } else if (Array.isArray(params)) {
36
+ //URLSearchParams([["key1", "value1"], ["key2", "value2"]]);
37
+ params.forEach(([key, value]) => this.append(key, value));
38
+ } else if (typeof params === 'object') {
39
+ //URLSearchParams({ key1: "value1", key2: "value2" });
40
+ Object.entries(params).forEach(([key, value]) => this.append(key, value));
19
41
  }
20
42
  }
21
43
 
22
44
  append(key: string, value: string): void {
23
- this._searchParams.push([key, value]);
45
+ if (!this._searchParams.has(key)) {
46
+ this._searchParams.set(key, [value]); // Initialize with an array if key is missing
47
+ } else {
48
+ this._searchParams.get(key)?.push(value); // Else push the value to the array
49
+ }
50
+ }
51
+
52
+ delete(name: string): void {
53
+ this._searchParams.delete(name);
24
54
  }
25
55
 
26
- delete(name: string): empty {
27
- throw new Error('URLSearchParams.delete is not implemented');
56
+ get(name: string): string | null {
57
+ const values = this._searchParams.get(name);
58
+ return values ? values[0] : null;
28
59
  }
29
60
 
30
- get(name: string): empty {
31
- throw new Error('URLSearchParams.get is not implemented');
61
+ getAll(name: string): string[] {
62
+ return this._searchParams.get(name) ?? [];
32
63
  }
33
64
 
34
- getAll(name: string): empty {
35
- throw new Error('URLSearchParams.getAll is not implemented');
65
+ has(name: string): boolean {
66
+ return this._searchParams.has(name);
36
67
  }
37
68
 
38
- has(name: string): empty {
39
- throw new Error('URLSearchParams.has is not implemented');
69
+ set(name: string, value: string): void {
70
+ this._searchParams.set(name, [value]);
40
71
  }
41
72
 
42
- set(name: string, value: string): empty {
43
- throw new Error('URLSearchParams.set is not implemented');
73
+ keys(): Iterator<string> {
74
+ return this._searchParams.keys();
44
75
  }
45
76
 
46
- sort(): empty {
47
- throw new Error('URLSearchParams.sort is not implemented');
77
+ values(): Iterator<string> {
78
+ function* generateValues(params: Map<string, string[]>): Iterator<string> {
79
+ for (const valueArray of params.values()) {
80
+ for (const value of valueArray) {
81
+ yield value;
82
+ }
83
+ }
84
+ }
85
+ return generateValues(this._searchParams);
86
+ }
87
+
88
+ entries(): Iterator<[string, string]> {
89
+ function* generateEntries(
90
+ params: Map<string, string[]>,
91
+ ): Iterator<[string, string]> {
92
+ for (const [key, values] of params) {
93
+ for (const value of values) {
94
+ yield [key, value];
95
+ }
96
+ }
97
+ }
98
+
99
+ return generateEntries(this._searchParams);
100
+ }
101
+
102
+ forEach(
103
+ callback: (value: string, key: string, searchParams: this) => void,
104
+ ): void {
105
+ for (const [key, values] of this._searchParams) {
106
+ for (const value of values) {
107
+ callback(value, key, this);
108
+ }
109
+ }
110
+ }
111
+
112
+ sort(): void {
113
+ this._searchParams = new Map(
114
+ [...this._searchParams.entries()].sort(([a], [b]) => a.localeCompare(b)),
115
+ );
48
116
  }
49
117
 
50
118
  // $FlowFixMe[unsupported-syntax]
51
119
  [Symbol.iterator](): Iterator<[string, string]> {
52
- return this._searchParams[Symbol.iterator]();
120
+ const entries: [string, string][] = [];
121
+
122
+ for (const [key, values] of this._searchParams) {
123
+ for (const value of values) {
124
+ entries.push([key, value]);
125
+ }
126
+ }
127
+
128
+ return entries[Symbol.iterator]();
53
129
  }
54
130
 
55
131
  toString(): string {
56
- if (this._searchParams.length === 0) {
57
- return '';
58
- }
59
- const last = this._searchParams.length - 1;
60
- return this._searchParams.reduce((acc, curr, index) => {
61
- return (
62
- acc +
63
- encodeURIComponent(curr[0]) +
64
- '=' +
65
- encodeURIComponent(curr[1]) +
66
- (index === last ? '' : '&')
67
- );
68
- }, '');
132
+ return Array.from(this._searchParams.entries())
133
+ .map(([key, values]) =>
134
+ values
135
+ .map(
136
+ value =>
137
+ `${encodeURIComponent(key).replace(/%20/g, '+')}=${encodeURIComponent(
138
+ value,
139
+ ).replace(/%20/g, '+')}`, // Convert only spaces to '+'
140
+ )
141
+ .join('&'),
142
+ )
143
+ .join('&');
69
144
  }
70
145
  }
@@ -10,14 +10,19 @@
10
10
 
11
11
  declare export class URLSearchParams {
12
12
  _searchParams: Array<[string, string]>;
13
- constructor(params?: Record<string, string>): void;
13
+ constructor(
14
+ params?: Record<string, string> | string | Array<[string, string]>,
15
+ ): void;
14
16
  append(key: string, value: string): void;
15
- delete(name: string): empty;
16
- get(name: string): empty;
17
- getAll(name: string): empty;
18
- has(name: string): empty;
19
- set(name: string, value: string): empty;
20
- sort(): empty;
17
+ delete(name: string): void;
18
+ get(name: string): string;
19
+ getAll(name: string): Array<string>;
20
+ has(name: string): boolean;
21
+ set(name: string, value: string): void;
22
+ sort(): void;
21
23
  @@iterator(): Iterator<[string, string]>;
22
24
  toString(): string;
25
+ keys(): Iterator<string>;
26
+ values(): Iterator<string>;
27
+ entries(): Iterator<[string, string]>;
23
28
  }