@react-native-oh/react-native-harmony 0.72.23 → 0.72.27

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 (44) hide show
  1. package/Libraries/Alert/Alert.harmony.js +71 -71
  2. package/Libraries/Alert/AlertManager.ts +35 -35
  3. package/Libraries/Animated/NativeAnimatedHelper.harmony.js +601 -601
  4. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +445 -426
  5. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.harmony.js +30 -0
  6. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.harmony.js +26 -0
  7. package/Libraries/Components/Button/Button.harmony.js +450 -450
  8. package/Libraries/Components/Image/Image.flow.harmony.js +53 -0
  9. package/Libraries/Components/Image/Image.harmony.js +299 -0
  10. package/Libraries/Components/Image/NativeImageLoaderHarmony.js +38 -0
  11. package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +210 -208
  12. package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +76 -75
  13. package/Libraries/Components/ScrollView/ScrollView.harmony.js +1951 -1930
  14. package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +24 -24
  15. package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +71 -68
  16. package/Libraries/Components/StatusBar/StatusBar.harmony.js +447 -447
  17. package/Libraries/Components/TextInput/TextInput.harmony.js +1707 -1697
  18. package/Libraries/Components/TextInput/TextInputState.harmony.js +220 -220
  19. package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +396 -396
  20. package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +364 -364
  21. package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +227 -227
  22. package/Libraries/Components/View/View.harmony.js +149 -149
  23. package/Libraries/Core/setUpReactDevTools.harmony.js +93 -93
  24. package/Libraries/Image/AssetSourceResolver.harmony.ts +78 -78
  25. package/Libraries/NativeComponent/BaseViewConfig.harmony.js +337 -337
  26. package/Libraries/ReactNative/UIManager.harmony.js +210 -210
  27. package/Libraries/Settings/Settings.harmony.js +15 -15
  28. package/Libraries/Share/Share.harmony.js +174 -0
  29. package/Libraries/StyleSheet/NativePlatformColor.ts +8 -8
  30. package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +14 -14
  31. package/Libraries/Utilities/BackHandler.harmony.js +109 -109
  32. package/Libraries/Utilities/{NativePlatformConstantsHarmony.ts → NativePlatformConstants.harmony.ts} +8 -8
  33. package/Libraries/Utilities/Platform.d.ts +117 -117
  34. package/Libraries/Utilities/Platform.harmony.ts +33 -33
  35. package/Libraries/Utilities/createPerformanceLogger.harmony.js +328 -328
  36. package/Libraries/Vibration/Vibration.harmony.js +88 -88
  37. package/index.js +212 -202
  38. package/jest.config.js +5 -5
  39. package/metro.config.js +348 -349
  40. package/package.json +58 -55
  41. package/react-native.config.js +10 -10
  42. package/{rnoh-4.1.0.404-vmall.har → react_native_openharmony.har} +0 -0
  43. package/tsconfig.json +13 -13
  44. package/types/index.d.ts +101 -101
@@ -1,208 +1,210 @@
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
9
- */
10
-
11
- const OS = "ios"; // RNOH: patch - replaced occurrences Platform.OS with OS
12
-
13
- //RNOH: patch - fix imports
14
- import type { ColorValue } from "react-native/Libraries/StyleSheet/StyleSheet";
15
- import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
16
-
17
- import AndroidSwipeRefreshLayoutNativeComponent, {
18
- Commands as AndroidSwipeRefreshLayoutCommands,
19
- } from "react-native/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent";
20
- import PullToRefreshViewNativeComponent, {
21
- Commands as PullToRefreshCommands,
22
- } from "react-native/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent";
23
-
24
- const Platform = require("../../Utilities/Platform");
25
- const React = require("react");
26
-
27
- type IOSProps = $ReadOnly<{|
28
- /**
29
- * The color of the refresh indicator.
30
- */
31
- tintColor?: ?ColorValue,
32
- /**
33
- * Title color.
34
- */
35
- titleColor?: ?ColorValue,
36
- /**
37
- * The title displayed under the refresh indicator.
38
- */
39
- title?: ?string,
40
- |}>;
41
-
42
- type AndroidProps = $ReadOnly<{|
43
- /**
44
- * Whether the pull to refresh functionality is enabled.
45
- */
46
- enabled?: ?boolean,
47
- /**
48
- * The colors (at least one) that will be used to draw the refresh indicator.
49
- */
50
- colors?: ?$ReadOnlyArray<ColorValue>,
51
- /**
52
- * The background color of the refresh indicator.
53
- */
54
- progressBackgroundColor?: ?ColorValue,
55
- /**
56
- * Size of the refresh indicator.
57
- */
58
- size?: ?("default" | "large"),
59
- |}>;
60
-
61
- export type RefreshControlProps = $ReadOnly<{|
62
- ...ViewProps,
63
- ...IOSProps,
64
- ...AndroidProps,
65
-
66
- /**
67
- * Called when the view starts refreshing.
68
- */
69
- onRefresh?: ?() => void | Promise<void>,
70
-
71
- /**
72
- * Whether the view should be indicating an active refresh.
73
- */
74
- refreshing: boolean,
75
-
76
- /**
77
- * Progress view top offset
78
- */
79
- progressViewOffset?: ?number,
80
- |}>;
81
-
82
- /**
83
- * This component is used inside a ScrollView or ListView to add pull to refresh
84
- * functionality. When the ScrollView is at `scrollY: 0`, swiping down
85
- * triggers an `onRefresh` event.
86
- *
87
- * ### Usage example
88
- *
89
- * ``` js
90
- * class RefreshableList extends Component {
91
- * constructor(props) {
92
- * super(props);
93
- * this.state = {
94
- * refreshing: false,
95
- * };
96
- * }
97
- *
98
- * _onRefresh() {
99
- * this.setState({refreshing: true});
100
- * fetchData().then(() => {
101
- * this.setState({refreshing: false});
102
- * });
103
- * }
104
- *
105
- * render() {
106
- * return (
107
- * <ListView
108
- * refreshControl={
109
- * <RefreshControl
110
- * refreshing={this.state.refreshing}
111
- * onRefresh={this._onRefresh.bind(this)}
112
- * />
113
- * }
114
- * ...
115
- * >
116
- * ...
117
- * </ListView>
118
- * );
119
- * }
120
- * ...
121
- * }
122
- * ```
123
- *
124
- * __Note:__ `refreshing` is a controlled prop, this is why it needs to be set to true
125
- * in the `onRefresh` function otherwise the refresh indicator will stop immediately.
126
- */
127
- class RefreshControl extends React.Component<RefreshControlProps> {
128
- _nativeRef: ?React.ElementRef<
129
- | typeof PullToRefreshViewNativeComponent
130
- | typeof AndroidSwipeRefreshLayoutNativeComponent
131
- >;
132
- _lastNativeRefreshing = false;
133
-
134
- componentDidMount() {
135
- this._lastNativeRefreshing = this.props.refreshing;
136
- }
137
-
138
- componentDidUpdate(prevProps: RefreshControlProps) {
139
- // RefreshControl is a controlled component so if the native refreshing
140
- // value doesn't match the current js refreshing prop update it to
141
- // the js value.
142
- if (this.props.refreshing !== prevProps.refreshing) {
143
- this._lastNativeRefreshing = this.props.refreshing;
144
- } else if (
145
- this.props.refreshing !== this._lastNativeRefreshing &&
146
- this._nativeRef
147
- ) {
148
- // RNOH: patch - replaced occurrences Platform.OS with OS
149
- if (OS === "android") {
150
- AndroidSwipeRefreshLayoutCommands.setNativeRefreshing(
151
- this._nativeRef,
152
- this.props.refreshing
153
- );
154
- } else {
155
- PullToRefreshCommands.setNativeRefreshing(
156
- this._nativeRef,
157
- this.props.refreshing
158
- );
159
- }
160
- this._lastNativeRefreshing = this.props.refreshing;
161
- }
162
- }
163
-
164
- render(): React.Node {
165
- // RNOH: patch - replaced occurrences Platform.OS with OS
166
- if (OS === "ios") {
167
- const { enabled, colors, progressBackgroundColor, size, ...props } =
168
- this.props;
169
- return (
170
- <PullToRefreshViewNativeComponent
171
- {...props}
172
- ref={this._setNativeRef}
173
- onRefresh={this._onRefresh}
174
- />
175
- );
176
- } else {
177
- const { tintColor, titleColor, title, ...props } = this.props;
178
- return (
179
- <AndroidSwipeRefreshLayoutNativeComponent
180
- {...props}
181
- ref={this._setNativeRef}
182
- onRefresh={this._onRefresh}
183
- />
184
- );
185
- }
186
- }
187
-
188
- _onRefresh = () => {
189
- this._lastNativeRefreshing = true;
190
-
191
- // $FlowFixMe[unused-promise]
192
- this.props.onRefresh && this.props.onRefresh();
193
-
194
- // The native component will start refreshing so force an update to
195
- // make sure it stays in sync with the js component.
196
- this.forceUpdate();
197
- };
198
-
199
- _setNativeRef = (
200
- ref: ?React.ElementRef<
201
- | typeof PullToRefreshViewNativeComponent
202
- | typeof AndroidSwipeRefreshLayoutNativeComponent
203
- >
204
- ) => {
205
- this._nativeRef = ref;
206
- };
207
- }
208
- module.exports = RefreshControl;
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
9
+ */
10
+
11
+ const OS = "ios"; // RNOH: patch - replaced occurrences Platform.OS with OS
12
+
13
+ //RNOH: patch - fix imports
14
+ import type { ColorValue } from "react-native/Libraries/StyleSheet/StyleSheet";
15
+ import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
16
+
17
+ import AndroidSwipeRefreshLayoutNativeComponent, {
18
+ Commands as AndroidSwipeRefreshLayoutCommands,
19
+ } from "react-native/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent";
20
+ import PullToRefreshViewNativeComponent, {
21
+ Commands as PullToRefreshCommands,
22
+ } from "react-native/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent";
23
+
24
+ const Platform = require("../../Utilities/Platform");
25
+ const React = require("react");
26
+
27
+ type IOSProps = $ReadOnly<{|
28
+ /**
29
+ * The color of the refresh indicator.
30
+ */
31
+ tintColor?: ?ColorValue,
32
+ /**
33
+ * Title color.
34
+ */
35
+ titleColor?: ?ColorValue,
36
+ /**
37
+ * The title displayed under the refresh indicator.
38
+ */
39
+ title?: ?string,
40
+ |}>;
41
+
42
+ type AndroidProps = $ReadOnly<{|
43
+ /**
44
+ * Whether the pull to refresh functionality is enabled.
45
+ */
46
+ enabled?: ?boolean,
47
+ /**
48
+ * The colors (at least one) that will be used to draw the refresh indicator.
49
+ */
50
+ colors?: ?$ReadOnlyArray<ColorValue>,
51
+ /**
52
+ * The background color of the refresh indicator.
53
+ */
54
+ progressBackgroundColor?: ?ColorValue,
55
+ /**
56
+ * Size of the refresh indicator.
57
+ */
58
+ size?: ?("default" | "large"),
59
+ |}>;
60
+
61
+ export type RefreshControlProps = $ReadOnly<{|
62
+ ...ViewProps,
63
+ ...IOSProps,
64
+ ...AndroidProps,
65
+
66
+ /**
67
+ * Called when the view starts refreshing.
68
+ */
69
+ onRefresh?: ?() => void | Promise<void>,
70
+
71
+ /**
72
+ * Whether the view should be indicating an active refresh.
73
+ */
74
+ refreshing: boolean,
75
+
76
+ /**
77
+ * Progress view top offset
78
+ */
79
+ progressViewOffset?: ?number,
80
+ |}>;
81
+
82
+ /**
83
+ * This component is used inside a ScrollView or ListView to add pull to refresh
84
+ * functionality. When the ScrollView is at `scrollY: 0`, swiping down
85
+ * triggers an `onRefresh` event.
86
+ *
87
+ * ### Usage example
88
+ *
89
+ * ``` js
90
+ * class RefreshableList extends Component {
91
+ * constructor(props) {
92
+ * super(props);
93
+ * this.state = {
94
+ * refreshing: false,
95
+ * };
96
+ * }
97
+ *
98
+ * _onRefresh() {
99
+ * this.setState({refreshing: true});
100
+ * fetchData().then(() => {
101
+ * this.setState({refreshing: false});
102
+ * });
103
+ * }
104
+ *
105
+ * render() {
106
+ * return (
107
+ * <ListView
108
+ * refreshControl={
109
+ * <RefreshControl
110
+ * refreshing={this.state.refreshing}
111
+ * onRefresh={this._onRefresh.bind(this)}
112
+ * />
113
+ * }
114
+ * ...
115
+ * >
116
+ * ...
117
+ * </ListView>
118
+ * );
119
+ * }
120
+ * ...
121
+ * }
122
+ * ```
123
+ *
124
+ * __Note:__ `refreshing` is a controlled prop, this is why it needs to be set to true
125
+ * in the `onRefresh` function otherwise the refresh indicator will stop immediately.
126
+ */
127
+ class RefreshControl extends React.Component<RefreshControlProps> {
128
+ _nativeRef: ?React.ElementRef<
129
+ | typeof PullToRefreshViewNativeComponent
130
+ | typeof AndroidSwipeRefreshLayoutNativeComponent
131
+ >;
132
+ _lastNativeRefreshing = false;
133
+
134
+ componentDidMount() {
135
+ this._lastNativeRefreshing = this.props.refreshing;
136
+ }
137
+
138
+ componentDidUpdate(prevProps: RefreshControlProps) {
139
+ // RefreshControl is a controlled component so if the native refreshing
140
+ // value doesn't match the current js refreshing prop update it to
141
+ // the js value.
142
+ if (this.props.refreshing !== prevProps.refreshing) {
143
+ this._lastNativeRefreshing = this.props.refreshing;
144
+ } else if (
145
+ this.props.refreshing !== this._lastNativeRefreshing &&
146
+ this._nativeRef
147
+ ) {
148
+ // RNOH: patch - replaced occurrences Platform.OS with OS
149
+ if (OS === "android") {
150
+ AndroidSwipeRefreshLayoutCommands.setNativeRefreshing(
151
+ this._nativeRef,
152
+ this.props.refreshing
153
+ );
154
+ } else {
155
+ PullToRefreshCommands.setNativeRefreshing(
156
+ this._nativeRef,
157
+ this.props.refreshing
158
+ );
159
+ }
160
+ this._lastNativeRefreshing = this.props.refreshing;
161
+ }
162
+ }
163
+
164
+ render(): React.Node {
165
+ // RNOH: patch - replaced occurrences Platform.OS with OS
166
+ if (OS === "ios") {
167
+ // RNOH: patch - change descructuring to pass "progressBackgroundColor", "enabled" and "size" to PullToRefreshViewNativeComponent
168
+ // BEFORE: const { enabled, colors, progressBackgroundColor, size, ...props } =
169
+ const {colors, ...props } =
170
+ this.props;
171
+ return (
172
+ <PullToRefreshViewNativeComponent
173
+ {...props}
174
+ ref={this._setNativeRef}
175
+ onRefresh={this._onRefresh}
176
+ />
177
+ );
178
+ } else {
179
+ const { tintColor, titleColor, title, ...props } = this.props;
180
+ return (
181
+ <AndroidSwipeRefreshLayoutNativeComponent
182
+ {...props}
183
+ ref={this._setNativeRef}
184
+ onRefresh={this._onRefresh}
185
+ />
186
+ );
187
+ }
188
+ }
189
+
190
+ _onRefresh = () => {
191
+ this._lastNativeRefreshing = true;
192
+
193
+ // $FlowFixMe[unused-promise]
194
+ this.props.onRefresh && this.props.onRefresh();
195
+
196
+ // The native component will start refreshing so force an update to
197
+ // make sure it stays in sync with the js component.
198
+ this.forceUpdate();
199
+ };
200
+
201
+ _setNativeRef = (
202
+ ref: ?React.ElementRef<
203
+ | typeof PullToRefreshViewNativeComponent
204
+ | typeof AndroidSwipeRefreshLayoutNativeComponent
205
+ >
206
+ ) => {
207
+ this._nativeRef = ref;
208
+ };
209
+ }
210
+ module.exports = RefreshControl;
@@ -1,75 +1,76 @@
1
- import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
2
- import { TurboModuleRegistry, View, ViewProps } from 'react-native';
3
- import { useEffect, useState } from 'react';
4
- import React from 'react';
5
-
6
- import RCTDeviceEventEmitter from 'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter.js';
7
-
8
- type SafeAreaInsets = {
9
- top: number;
10
- left: number;
11
- right: number;
12
- bottom: number;
13
- };
14
-
15
- interface SafeAreaTurboModuleProtocol {
16
- getInitialInsets(): SafeAreaInsets;
17
- }
18
-
19
- interface Spec extends TurboModule, SafeAreaTurboModuleProtocol {}
20
-
21
- const safeAreaTurboModule = TurboModuleRegistry.get<Spec>(
22
- 'SafeAreaTurboModule'
23
- )!;
24
-
25
- export default React.forwardRef<View, ViewProps>(
26
- ({ children, ...otherProps }, ref) => {
27
- const [topInset, setTopInset] = useState(
28
- safeAreaTurboModule.getInitialInsets().top
29
- );
30
- const [leftInset, setLeftInset] = useState(
31
- safeAreaTurboModule.getInitialInsets().left
32
- );
33
- const [rightInset, setRightInset] = useState(
34
- safeAreaTurboModule.getInitialInsets().right
35
- );
36
- const [bottomInset, setBottomInset] = useState(
37
- safeAreaTurboModule.getInitialInsets().bottom
38
- );
39
-
40
- useEffect(
41
- function subscribeToSafeAreaChanges() {
42
- const subscription = (RCTDeviceEventEmitter as any).addListener(
43
- 'SAFE_AREA_INSETS_CHANGE',
44
- (insets: SafeAreaInsets) => {
45
- setTopInset(insets.top);
46
- setBottomInset(insets.bottom);
47
- setLeftInset(insets.left);
48
- setRightInset(insets.right);
49
- }
50
- );
51
- return () => {
52
- subscription.remove();
53
- };
54
- },
55
- [setTopInset, setLeftInset, setRightInset, setBottomInset]
56
- );
57
-
58
- return (
59
- <View ref={ref} {...otherProps}>
60
- <View
61
- style={{
62
- width: '100%',
63
- height: '100%',
64
- paddingTop: topInset,
65
- paddingLeft: leftInset,
66
- paddingRight: rightInset,
67
- paddingBottom: bottomInset,
68
- }}
69
- >
70
- {children}
71
- </View>
72
- </View>
73
- );
74
- }
75
- );
1
+ import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
2
+ import { TurboModuleRegistry, View, ViewProps } from "react-native";
3
+ import { useEffect, useState } from "react";
4
+ import React from "react";
5
+
6
+ import RCTDeviceEventEmitter from "react-native/Libraries/EventEmitter/RCTDeviceEventEmitter.js";
7
+
8
+ type SafeAreaInsets = {
9
+ top: number;
10
+ left: number;
11
+ right: number;
12
+ bottom: number;
13
+ };
14
+
15
+ interface SafeAreaTurboModuleProtocol {
16
+ getInitialInsets(): SafeAreaInsets;
17
+ }
18
+
19
+ interface Spec extends TurboModule, SafeAreaTurboModuleProtocol {}
20
+
21
+ const safeAreaTurboModule = TurboModuleRegistry.get<Spec>(
22
+ "SafeAreaTurboModule"
23
+ )!;
24
+
25
+ export default React.forwardRef<View, ViewProps>(
26
+ ({ children, style, ...otherProps }, ref) => {
27
+ const [topInset, setTopInset] = useState(
28
+ safeAreaTurboModule.getInitialInsets().top
29
+ );
30
+ const [leftInset, setLeftInset] = useState(
31
+ safeAreaTurboModule.getInitialInsets().left
32
+ );
33
+ const [rightInset, setRightInset] = useState(
34
+ safeAreaTurboModule.getInitialInsets().right
35
+ );
36
+ const [bottomInset, setBottomInset] = useState(
37
+ safeAreaTurboModule.getInitialInsets().bottom
38
+ );
39
+
40
+ useEffect(
41
+ function subscribeToSafeAreaChanges() {
42
+ const subscription = (RCTDeviceEventEmitter as any).addListener(
43
+ "SAFE_AREA_INSETS_CHANGE",
44
+ (insets: SafeAreaInsets) => {
45
+ setTopInset(insets.top);
46
+ setBottomInset(insets.bottom);
47
+ setLeftInset(insets.left);
48
+ setRightInset(insets.right);
49
+ }
50
+ );
51
+ return () => {
52
+ subscription.remove();
53
+ };
54
+ },
55
+ [setTopInset, setLeftInset, setRightInset, setBottomInset]
56
+ );
57
+
58
+ return (
59
+ <View
60
+ ref={ref}
61
+ style={[
62
+ style,
63
+ {
64
+ paddingTop: topInset,
65
+ paddingLeft: leftInset,
66
+ paddingRight: rightInset,
67
+ paddingBottom: bottomInset,
68
+ },
69
+ ]}
70
+ {...otherProps}
71
+ >
72
+ {children}
73
+ </View>
74
+ );
75
+ }
76
+ );