@react-native-oh/react-native-harmony 0.72.23-3 → 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 -210
  12. package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +76 -75
  13. package/Libraries/Components/ScrollView/ScrollView.harmony.js +1951 -1951
  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 -1707
  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 -174
  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 -212
  38. package/jest.config.js +5 -5
  39. package/metro.config.js +348 -348
  40. package/package.json +57 -57
  41. package/react-native.config.js +10 -10
  42. package/react_native_openharmony.har +0 -0
  43. package/tsconfig.json +13 -13
  44. package/types/index.d.ts +101 -101
@@ -1,174 +1,174 @@
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
- import NativeActionSheetManager from 'react-native/Libraries/ActionSheetIOS/NativeActionSheetManager';
12
- import NativeShareModule from 'react-native/Libraries/Share/NativeShareModule';
13
-
14
- const processColor = require('react-native/Libraries/StyleSheet/processColor').default;
15
- const PlatformOS = 'android'; // rnoh: patch
16
- const invariant = require('invariant');
17
-
18
- type Content =
19
- | {
20
- title?: string,
21
- message: string,
22
- ...
23
- }
24
- | {
25
- title?: string,
26
- url: string,
27
- ...
28
- };
29
- type Options = {
30
- dialogTitle?: string,
31
- excludedActivityTypes?: Array<string>,
32
- tintColor?: string,
33
- subject?: string,
34
- anchor?: number,
35
- ...
36
- };
37
-
38
- class Share {
39
- /**
40
- * Open a dialog to share text content.
41
- *
42
- * In iOS, Returns a Promise which will be invoked an object containing `action`, `activityType`.
43
- * If the user dismissed the dialog, the Promise will still be resolved with action being `Share.dismissedAction`
44
- * and all the other keys being undefined.
45
- *
46
- * In Android, Returns a Promise which always be resolved with action being `Share.sharedAction`.
47
- *
48
- * ### Content
49
- *
50
- * - `message` - a message to share
51
- *
52
- * #### iOS
53
- *
54
- * - `url` - a URL to share
55
- *
56
- * At least one of URL and message is required.
57
- *
58
- * #### Android
59
- *
60
- * - `title` - title of the message
61
- *
62
- * ### Options
63
- *
64
- * #### iOS
65
- *
66
- * - `subject` - a subject to share via email
67
- * - `excludedActivityTypes`
68
- * - `tintColor`
69
- *
70
- * #### Android
71
- *
72
- * - `dialogTitle`
73
- *
74
- */
75
- static share(
76
- content: Content,
77
- options: Options = {},
78
- ): Promise<{action: string, activityType: ?string}> {
79
- invariant(
80
- typeof content === 'object' && content !== null,
81
- 'Content to share must be a valid object',
82
- );
83
- invariant(
84
- typeof content.url === 'string' || typeof content.message === 'string' || typeof content.title === 'string', // rnoh: patch
85
- 'At least one of URL, title and message is required', // rnoh: patch
86
- );
87
- invariant(
88
- typeof options === 'object' && options !== null,
89
- 'Options must be a valid object',
90
- );
91
-
92
- if (PlatformOS === 'android') {
93
- invariant(
94
- NativeShareModule,
95
- 'ShareModule should be registered on Android.',
96
- );
97
- invariant(
98
- content.title == null || typeof content.title === 'string',
99
- 'Invalid title: title should be a string.',
100
- );
101
-
102
- const newContent = {
103
- title: content.title,
104
- message:
105
- typeof content.message === 'string' ? content.message : undefined,
106
- url: typeof content.url === 'string' ? content.url : undefined, // rnoh: patch
107
- };
108
-
109
- return NativeShareModule.share(newContent, options.dialogTitle)
110
- .then(
111
- result => ({
112
- activityType: null,
113
- ...result,
114
- }),
115
- );
116
- } else if (PlatformOS=== 'ios') { // rnoh: patch
117
- return new Promise((resolve, reject) => {
118
- const tintColor = processColor(options.tintColor);
119
-
120
- invariant(
121
- tintColor == null || typeof tintColor === 'number',
122
- 'Unexpected color given for options.tintColor',
123
- );
124
-
125
- invariant(
126
- NativeActionSheetManager,
127
- 'NativeActionSheetManager is not registered on iOS, but it should be.',
128
- );
129
-
130
- NativeActionSheetManager.showShareActionSheetWithOptions(
131
- {
132
- message:
133
- typeof content.message === 'string' ? content.message : undefined,
134
- url: typeof content.url === 'string' ? content.url : undefined,
135
- subject: options.subject,
136
- tintColor: typeof tintColor === 'number' ? tintColor : undefined,
137
- anchor:
138
- typeof options.anchor === 'number' ? options.anchor : undefined,
139
- excludedActivityTypes: options.excludedActivityTypes,
140
- },
141
- error => reject(error),
142
- (success, activityType) => {
143
- if (success) {
144
- resolve({
145
- action: 'sharedAction',
146
- activityType: activityType,
147
- });
148
- } else {
149
- resolve({
150
- action: 'dismissedAction',
151
- activityType: null,
152
- });
153
- }
154
- },
155
- );
156
- });
157
- } else {
158
- return Promise.reject(new Error('Unsupported platform'));
159
- }
160
- }
161
-
162
- /**
163
- * The content was successfully shared.
164
- */
165
- static sharedAction: 'sharedAction' = 'sharedAction';
166
-
167
- /**
168
- * The dialog has been dismissed.
169
- * @platform ios
170
- */
171
- static dismissedAction: 'dismissedAction' = 'dismissedAction';
172
- }
173
-
174
- module.exports = Share;
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
+ import NativeActionSheetManager from 'react-native/Libraries/ActionSheetIOS/NativeActionSheetManager';
12
+ import NativeShareModule from 'react-native/Libraries/Share/NativeShareModule';
13
+
14
+ const processColor = require('react-native/Libraries/StyleSheet/processColor').default;
15
+ const PlatformOS = 'android'; // rnoh: patch
16
+ const invariant = require('invariant');
17
+
18
+ type Content =
19
+ | {
20
+ title?: string,
21
+ message: string,
22
+ ...
23
+ }
24
+ | {
25
+ title?: string,
26
+ url: string,
27
+ ...
28
+ };
29
+ type Options = {
30
+ dialogTitle?: string,
31
+ excludedActivityTypes?: Array<string>,
32
+ tintColor?: string,
33
+ subject?: string,
34
+ anchor?: number,
35
+ ...
36
+ };
37
+
38
+ class Share {
39
+ /**
40
+ * Open a dialog to share text content.
41
+ *
42
+ * In iOS, Returns a Promise which will be invoked an object containing `action`, `activityType`.
43
+ * If the user dismissed the dialog, the Promise will still be resolved with action being `Share.dismissedAction`
44
+ * and all the other keys being undefined.
45
+ *
46
+ * In Android, Returns a Promise which always be resolved with action being `Share.sharedAction`.
47
+ *
48
+ * ### Content
49
+ *
50
+ * - `message` - a message to share
51
+ *
52
+ * #### iOS
53
+ *
54
+ * - `url` - a URL to share
55
+ *
56
+ * At least one of URL and message is required.
57
+ *
58
+ * #### Android
59
+ *
60
+ * - `title` - title of the message
61
+ *
62
+ * ### Options
63
+ *
64
+ * #### iOS
65
+ *
66
+ * - `subject` - a subject to share via email
67
+ * - `excludedActivityTypes`
68
+ * - `tintColor`
69
+ *
70
+ * #### Android
71
+ *
72
+ * - `dialogTitle`
73
+ *
74
+ */
75
+ static share(
76
+ content: Content,
77
+ options: Options = {},
78
+ ): Promise<{action: string, activityType: ?string}> {
79
+ invariant(
80
+ typeof content === 'object' && content !== null,
81
+ 'Content to share must be a valid object',
82
+ );
83
+ invariant(
84
+ typeof content.url === 'string' || typeof content.message === 'string' || typeof content.title === 'string', // rnoh: patch
85
+ 'At least one of URL, title and message is required', // rnoh: patch
86
+ );
87
+ invariant(
88
+ typeof options === 'object' && options !== null,
89
+ 'Options must be a valid object',
90
+ );
91
+
92
+ if (PlatformOS === 'android') {
93
+ invariant(
94
+ NativeShareModule,
95
+ 'ShareModule should be registered on Android.',
96
+ );
97
+ invariant(
98
+ content.title == null || typeof content.title === 'string',
99
+ 'Invalid title: title should be a string.',
100
+ );
101
+
102
+ const newContent = {
103
+ title: content.title,
104
+ message:
105
+ typeof content.message === 'string' ? content.message : undefined,
106
+ url: typeof content.url === 'string' ? content.url : undefined, // rnoh: patch
107
+ };
108
+
109
+ return NativeShareModule.share(newContent, options.dialogTitle)
110
+ .then(
111
+ result => ({
112
+ activityType: null,
113
+ ...result,
114
+ }),
115
+ );
116
+ } else if (PlatformOS=== 'ios') { // rnoh: patch
117
+ return new Promise((resolve, reject) => {
118
+ const tintColor = processColor(options.tintColor);
119
+
120
+ invariant(
121
+ tintColor == null || typeof tintColor === 'number',
122
+ 'Unexpected color given for options.tintColor',
123
+ );
124
+
125
+ invariant(
126
+ NativeActionSheetManager,
127
+ 'NativeActionSheetManager is not registered on iOS, but it should be.',
128
+ );
129
+
130
+ NativeActionSheetManager.showShareActionSheetWithOptions(
131
+ {
132
+ message:
133
+ typeof content.message === 'string' ? content.message : undefined,
134
+ url: typeof content.url === 'string' ? content.url : undefined,
135
+ subject: options.subject,
136
+ tintColor: typeof tintColor === 'number' ? tintColor : undefined,
137
+ anchor:
138
+ typeof options.anchor === 'number' ? options.anchor : undefined,
139
+ excludedActivityTypes: options.excludedActivityTypes,
140
+ },
141
+ error => reject(error),
142
+ (success, activityType) => {
143
+ if (success) {
144
+ resolve({
145
+ action: 'sharedAction',
146
+ activityType: activityType,
147
+ });
148
+ } else {
149
+ resolve({
150
+ action: 'dismissedAction',
151
+ activityType: null,
152
+ });
153
+ }
154
+ },
155
+ );
156
+ });
157
+ } else {
158
+ return Promise.reject(new Error('Unsupported platform'));
159
+ }
160
+ }
161
+
162
+ /**
163
+ * The content was successfully shared.
164
+ */
165
+ static sharedAction: 'sharedAction' = 'sharedAction';
166
+
167
+ /**
168
+ * The dialog has been dismissed.
169
+ * @platform ios
170
+ */
171
+ static dismissedAction: 'dismissedAction' = 'dismissedAction';
172
+ }
173
+
174
+ module.exports = Share;
@@ -1,8 +1,8 @@
1
- import { TurboModule, TurboModuleRegistry } from "react-native";
2
-
3
- interface Spec extends TurboModule {
4
- getSystemColor: () => string | null;
5
- }
6
-
7
- export const NativePlatformColor =
8
- TurboModuleRegistry.getEnforcing<Spec>("PlatformColor");
1
+ import { TurboModule, TurboModuleRegistry } from "react-native";
2
+
3
+ interface Spec extends TurboModule {
4
+ getSystemColor: () => string | null;
5
+ }
6
+
7
+ export const NativePlatformColor =
8
+ TurboModuleRegistry.getEnforcing<Spec>("PlatformColor");
@@ -1,14 +1,14 @@
1
- import { NativePlatformColor } from "./NativePlatformColor";
2
-
3
- export const PlatformColor = (...colors: string[]) => {
4
- const color = NativePlatformColor.getSystemColor(colors);
5
- return color;
6
- };
7
-
8
- export const normalizeColorObject = (color: string) => {
9
- return color;
10
- };
11
-
12
- export const processColorObject = (color: string) => {
13
- return color;
14
- };
1
+ import { NativePlatformColor } from "./NativePlatformColor";
2
+
3
+ export const PlatformColor = (...colors: string[]) => {
4
+ const color = NativePlatformColor.getSystemColor(colors);
5
+ return color;
6
+ };
7
+
8
+ export const normalizeColorObject = (color: string) => {
9
+ return color;
10
+ };
11
+
12
+ export const processColorObject = (color: string) => {
13
+ return color;
14
+ };
@@ -1,109 +1,109 @@
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
- // RNOH: This is a copy of the original Android file
12
-
13
- import NativeDeviceEventManager from 'react-native/Libraries/NativeModules/specs/NativeDeviceEventManager';
14
- import RCTDeviceEventEmitter from 'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter';
15
-
16
- const DEVICE_BACK_EVENT = 'hardwareBackPress';
17
-
18
- type BackPressEventName = 'backPress' | 'hardwareBackPress';
19
-
20
- const _backPressSubscriptions = [];
21
-
22
- RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function () {
23
- for (let i = _backPressSubscriptions.length - 1; i >= 0; i--) {
24
- if (_backPressSubscriptions[i]()) {
25
- return;
26
- }
27
- }
28
-
29
- BackHandler.exitApp();
30
- });
31
-
32
- /**
33
- * Detect hardware button presses for back navigation.
34
- *
35
- * Android: Detect hardware back button presses, and programmatically invoke the default back button
36
- * functionality to exit the app if there are no listeners or if none of the listeners return true.
37
- *
38
- * iOS: Not applicable.
39
- *
40
- * The event subscriptions are called in reverse order (i.e. last registered subscription first),
41
- * and if one subscription returns true then subscriptions registered earlier will not be called.
42
- *
43
- * Example:
44
- *
45
- * ```javascript
46
- * BackHandler.addEventListener('hardwareBackPress', function() {
47
- * // this.onMainScreen and this.goBack are just examples, you need to use your own implementation here
48
- * // Typically you would use the navigator here to go to the last state.
49
- *
50
- * if (!this.onMainScreen()) {
51
- * this.goBack();
52
- * return true;
53
- * }
54
- * return false;
55
- * });
56
- * ```
57
- */
58
- type TBackHandler = {|
59
- +exitApp: () => void,
60
- +addEventListener: (
61
- eventName: BackPressEventName,
62
- handler: () => ?boolean,
63
- ) => {remove: () => void, ...},
64
- +removeEventListener: (
65
- eventName: BackPressEventName,
66
- handler: () => ?boolean,
67
- ) => void,
68
- |};
69
- const BackHandler: TBackHandler = {
70
- exitApp: function (): void {
71
- if (!NativeDeviceEventManager) {
72
- return;
73
- }
74
-
75
- NativeDeviceEventManager.invokeDefaultBackPressHandler();
76
- },
77
-
78
- /**
79
- * Adds an event handler. Supported events:
80
- *
81
- * - `hardwareBackPress`: Fires when the Android hardware back button is pressed.
82
- */
83
- addEventListener: function (
84
- eventName: BackPressEventName,
85
- handler: () => ?boolean,
86
- ): {remove: () => void, ...} {
87
- if (_backPressSubscriptions.indexOf(handler) === -1) {
88
- _backPressSubscriptions.push(handler);
89
- }
90
- return {
91
- remove: (): void => BackHandler.removeEventListener(eventName, handler),
92
- };
93
- },
94
-
95
- /**
96
- * Removes the event handler.
97
- */
98
- removeEventListener: function (
99
- eventName: BackPressEventName,
100
- handler: () => ?boolean,
101
- ): void {
102
- const index = _backPressSubscriptions.indexOf(handler);
103
- if (index !== -1) {
104
- _backPressSubscriptions.splice(index, 1);
105
- }
106
- },
107
- };
108
-
109
- module.exports = BackHandler;
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
+ // RNOH: This is a copy of the original Android file
12
+
13
+ import NativeDeviceEventManager from 'react-native/Libraries/NativeModules/specs/NativeDeviceEventManager';
14
+ import RCTDeviceEventEmitter from 'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter';
15
+
16
+ const DEVICE_BACK_EVENT = 'hardwareBackPress';
17
+
18
+ type BackPressEventName = 'backPress' | 'hardwareBackPress';
19
+
20
+ const _backPressSubscriptions = [];
21
+
22
+ RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function () {
23
+ for (let i = _backPressSubscriptions.length - 1; i >= 0; i--) {
24
+ if (_backPressSubscriptions[i]()) {
25
+ return;
26
+ }
27
+ }
28
+
29
+ BackHandler.exitApp();
30
+ });
31
+
32
+ /**
33
+ * Detect hardware button presses for back navigation.
34
+ *
35
+ * Android: Detect hardware back button presses, and programmatically invoke the default back button
36
+ * functionality to exit the app if there are no listeners or if none of the listeners return true.
37
+ *
38
+ * iOS: Not applicable.
39
+ *
40
+ * The event subscriptions are called in reverse order (i.e. last registered subscription first),
41
+ * and if one subscription returns true then subscriptions registered earlier will not be called.
42
+ *
43
+ * Example:
44
+ *
45
+ * ```javascript
46
+ * BackHandler.addEventListener('hardwareBackPress', function() {
47
+ * // this.onMainScreen and this.goBack are just examples, you need to use your own implementation here
48
+ * // Typically you would use the navigator here to go to the last state.
49
+ *
50
+ * if (!this.onMainScreen()) {
51
+ * this.goBack();
52
+ * return true;
53
+ * }
54
+ * return false;
55
+ * });
56
+ * ```
57
+ */
58
+ type TBackHandler = {|
59
+ +exitApp: () => void,
60
+ +addEventListener: (
61
+ eventName: BackPressEventName,
62
+ handler: () => ?boolean,
63
+ ) => {remove: () => void, ...},
64
+ +removeEventListener: (
65
+ eventName: BackPressEventName,
66
+ handler: () => ?boolean,
67
+ ) => void,
68
+ |};
69
+ const BackHandler: TBackHandler = {
70
+ exitApp: function (): void {
71
+ if (!NativeDeviceEventManager) {
72
+ return;
73
+ }
74
+
75
+ NativeDeviceEventManager.invokeDefaultBackPressHandler();
76
+ },
77
+
78
+ /**
79
+ * Adds an event handler. Supported events:
80
+ *
81
+ * - `hardwareBackPress`: Fires when the Android hardware back button is pressed.
82
+ */
83
+ addEventListener: function (
84
+ eventName: BackPressEventName,
85
+ handler: () => ?boolean,
86
+ ): {remove: () => void, ...} {
87
+ if (_backPressSubscriptions.indexOf(handler) === -1) {
88
+ _backPressSubscriptions.push(handler);
89
+ }
90
+ return {
91
+ remove: (): void => BackHandler.removeEventListener(eventName, handler),
92
+ };
93
+ },
94
+
95
+ /**
96
+ * Removes the event handler.
97
+ */
98
+ removeEventListener: function (
99
+ eventName: BackPressEventName,
100
+ handler: () => ?boolean,
101
+ ): void {
102
+ const index = _backPressSubscriptions.indexOf(handler);
103
+ if (index !== -1) {
104
+ _backPressSubscriptions.splice(index, 1);
105
+ }
106
+ },
107
+ };
108
+
109
+ module.exports = BackHandler;
@@ -1,8 +1,8 @@
1
- import { TurboModule, TurboModuleRegistry } from 'react-native';
2
- import { PlatformHarmonyConstants } from "./Platform";
3
-
4
- interface Spec extends TurboModule {
5
- getConstants: () => PlatformHarmonyConstants;
6
- }
7
-
8
- export const NativePlatformConstantsHarmony = TurboModuleRegistry.getEnforcing<Spec>('PlatformConstants');
1
+ import { TurboModule, TurboModuleRegistry } from 'react-native';
2
+ import { PlatformHarmonyConstants } from "./Platform";
3
+
4
+ interface Spec extends TurboModule {
5
+ getConstants: () => PlatformHarmonyConstants;
6
+ }
7
+
8
+ export const NativePlatformConstantsHarmony = TurboModuleRegistry.getEnforcing<Spec>('PlatformConstants');