@react-native-oh/react-native-harmony 0.72.82 → 0.77.18

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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-Meta +21 -0
  3. package/Libraries/Alert/delegates/AlertDelegate.harmony.ts +84 -0
  4. package/Libraries/Alert/{AlertManager.ts → delegates/AlertManager.harmony.ts} +10 -4
  5. package/Libraries/Animated/shouldUseTurboAnimatedModule.harmony.ts +10 -0
  6. package/Libraries/Components/AccessibilityInfo/delegates/AccessibilityInfoDelegate.harmony.ts +44 -0
  7. package/Libraries/Components/AccessibilityInfo/{NativeAccessibilityInfoHarmony.ts → delegates/NativeAccessibilityInfoHarmony.harmony.ts} +9 -2
  8. package/Libraries/Components/Keyboard/delegates/KeyboardAvoidingViewDelegate.harmony.ts +42 -0
  9. package/Libraries/Components/RefreshControl/delegates/RefreshControlDelegate.harmony.tsx +29 -0
  10. package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +93 -31
  11. package/Libraries/Components/ScrollView/delegates/ScrollViewDelegate.harmony.tsx +41 -0
  12. package/Libraries/Components/ScrollView/delegates/ScrollViewNativeComponentDelegate.harmony.ts +89 -0
  13. package/Libraries/Components/ScrollView/processDecelerationRate.harmony.ts +19 -0
  14. package/Libraries/Components/StatusBar/delegates/NativeStatusBarManagerHarmony.harmony.ts +53 -0
  15. package/Libraries/Components/StatusBar/delegates/StatusBarDelegate.harmony.ts +83 -0
  16. package/Libraries/Components/TextInput/delegates/TextInputDelegate.harmony.tsx +98 -0
  17. package/Libraries/Components/TextInput/delegates/TextInputStateDelegate.harmony.tsx +20 -0
  18. package/Libraries/Components/Touchable/delegates/TouchableHighlightDelegate.harmony.ts +14 -0
  19. package/Libraries/Components/Touchable/delegates/TouchableNativeFeedbackDelegate.harmony.ts +14 -0
  20. package/Libraries/Components/Touchable/delegates/TouchableWithoutFeedbackDelegate.harmony.ts +14 -0
  21. package/Libraries/Components/delegates/ButtonDelegate.harmony.ts +41 -0
  22. package/Libraries/Core/setUpPlatform.harmony.js +30 -0
  23. package/Libraries/Image/AssetSourceResolver.harmony.ts +75 -29
  24. package/Libraries/Image/Image.harmony.ts +17 -0
  25. package/Libraries/NativeComponent/BaseViewConfig.harmony.js +12 -326
  26. package/Libraries/NativeComponent/delegates/ViewConfigIgnoreDelegate.harmony.ts +13 -0
  27. package/Libraries/ReactNative/delegates/BridgelessUIManagerDelegate.harmony.ts +14 -0
  28. package/Libraries/ReactNative/delegates/I18nManagerDelegate.harmony.ts +22 -0
  29. package/Libraries/Settings/Settings.harmony.ts +20 -0
  30. package/Libraries/Share/delegates/ShareDelegate.harmony.ts +42 -0
  31. package/Libraries/StyleSheet/NativePlatformColor.harmony.ts +15 -0
  32. package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +8 -1
  33. package/Libraries/Utilities/BackHandler.harmony.ts +10 -0
  34. package/Libraries/Utilities/NativePlatformConstantsHarmony.harmony.ts +17 -0
  35. package/Libraries/Utilities/Platform.harmony.ts +38 -13
  36. package/Libraries/Vibration/delegates/VibrationDelegate.harmony.ts +14 -0
  37. package/NOTICE.md +846 -0
  38. package/README.md +2 -2
  39. package/index.js +53 -63
  40. package/jest.config.js +0 -7
  41. package/metro.config.d.ts +17 -0
  42. package/metro.config.js +398 -115
  43. package/package.json +58 -37
  44. package/react-native.config.js +57 -9
  45. package/react_native_openharmony.har +0 -0
  46. package/tsconfig.json +10 -4
  47. package/types/index.harmony.d.ts +99 -0
  48. package/Libraries/Alert/Alert.harmony.js +0 -77
  49. package/Libraries/Animated/NativeAnimatedHelper.harmony.js +0 -601
  50. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +0 -441
  51. package/Libraries/Components/Button/Button.harmony.js +0 -451
  52. package/Libraries/Components/Image/Image.flow.harmony.js +0 -53
  53. package/Libraries/Components/Image/Image.harmony.js +0 -317
  54. package/Libraries/Components/Image/NativeImageLoaderHarmony.js +0 -38
  55. package/Libraries/Components/Keyboard/KeyboardAvoidingView.harmony.js +0 -256
  56. package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +0 -210
  57. package/Libraries/Components/ScrollView/ScrollView.harmony.js +0 -1951
  58. package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +0 -24
  59. package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +0 -71
  60. package/Libraries/Components/StatusBar/StatusBar.harmony.js +0 -447
  61. package/Libraries/Components/TextInput/TextInput.harmony.js +0 -1716
  62. package/Libraries/Components/TextInput/TextInputState.harmony.js +0 -220
  63. package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +0 -396
  64. package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +0 -364
  65. package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +0 -227
  66. package/Libraries/Components/View/View.harmony.js +0 -149
  67. package/Libraries/Core/setUpReactDevTools.harmony.js +0 -93
  68. package/Libraries/ReactNative/I18nManager.harmony.js +0 -78
  69. package/Libraries/ReactNative/UIManager.harmony.js +0 -210
  70. package/Libraries/Settings/Settings.harmony.js +0 -15
  71. package/Libraries/Share/Share.harmony.js +0 -174
  72. package/Libraries/StyleSheet/NativePlatformColor.ts +0 -8
  73. package/Libraries/Utilities/BackHandler.harmony.js +0 -109
  74. package/Libraries/Utilities/NativePlatformConstants.harmony.ts +0 -8
  75. package/Libraries/Utilities/Platform.d.ts +0 -117
  76. package/Libraries/Utilities/createPerformanceLogger.harmony.js +0 -328
  77. package/Libraries/Vibration/Vibration.harmony.js +0 -88
  78. package/harmony/.keep +0 -0
  79. package/harmony/rnoh-hvigor-plugin-0.2.0.tgz +0 -0
  80. package/react_native_openharmony_release.har +0 -0
  81. package/types/index.d.ts +0 -108
@@ -1,174 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @flow strict-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 +0,0 @@
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,109 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict-local
8
- * @format
9
- */
10
-
11
- // 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 +0,0 @@
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,117 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- */
9
-
10
- /**
11
- * @see https://reactnative.dev/docs/platform-specific-code#content
12
- */
13
- export type PlatformOSType =
14
- | 'ios'
15
- | 'android'
16
- | 'macos'
17
- | 'windows'
18
- | 'web'
19
- | "harmony" // RNOH: patch
20
- | 'native';
21
- type PlatformConstants = {
22
- isTesting: boolean;
23
- reactNativeVersion: {
24
- major: number;
25
- minor: number;
26
- patch: number;
27
- prerelease?: number | null | undefined;
28
- };
29
- };
30
- interface PlatformStatic {
31
- isTV: boolean;
32
- isTesting: boolean;
33
- Version: number | string;
34
- constants: PlatformConstants;
35
-
36
- /**
37
- * @see https://reactnative.dev/docs/platform-specific-code#content
38
- */
39
- select<T>(
40
- specifics:
41
- | ({ [platform in PlatformOSType]?: T } & { default: T; })
42
- | { [platform in PlatformOSType]: T },
43
- ): T;
44
- select<T>(specifics: { [platform in PlatformOSType]?: T }): T | undefined;
45
- }
46
-
47
- interface PlatformIOSStatic extends PlatformStatic {
48
- constants: PlatformConstants & {
49
- forceTouchAvailable: boolean;
50
- interfaceIdiom: string;
51
- osVersion: string;
52
- systemName: string;
53
- };
54
- OS: 'ios';
55
- isPad: boolean;
56
- isTV: boolean;
57
- Version: string;
58
- }
59
-
60
- interface PlatformAndroidStatic extends PlatformStatic {
61
- constants: PlatformConstants & {
62
- Version: number;
63
- Release: string;
64
- Serial: string;
65
- Fingerprint: string;
66
- Model: string;
67
- Brand: string;
68
- Manufacturer: string;
69
- ServerHost?: string | undefined;
70
- uiMode: 'car' | 'desk' | 'normal' | 'tv' | 'watch' | 'unknown';
71
- };
72
- OS: 'android';
73
- Version: number;
74
- }
75
-
76
- interface PlatformMacOSStatic extends PlatformStatic {
77
- OS: 'macos';
78
- Version: string;
79
- constants: PlatformConstants & {
80
- osVersion: string;
81
- };
82
- }
83
-
84
- interface PlatformWindowsOSStatic extends PlatformStatic {
85
- OS: 'windows';
86
- Version: number;
87
- constants: PlatformConstants & {
88
- osVersion: number;
89
- };
90
- }
91
-
92
- interface PlatformWebStatic extends PlatformStatic {
93
- OS: 'web';
94
- }
95
-
96
- // begin RNOH: patch
97
- export type PlatformHarmonyConstants = PlatformConstants & {
98
- deviceType: "default" | "phone" | "wearable" | "liteWearable" | "tablet" | "tv" | "car" | "smartVision";
99
- osFullName: string;
100
- Model: string;
101
- };
102
-
103
- export interface PlatformHarmonyStatic extends PlatformStatic {
104
- OS: 'harmony';
105
- constants: PlatformHarmonyConstants;
106
- }
107
- // end RNOH: patch
108
-
109
- export type Platform =
110
- | PlatformIOSStatic
111
- | PlatformAndroidStatic
112
- | PlatformWindowsOSStatic
113
- | PlatformMacOSStatic
114
- | PlatformWebStatic
115
- | PlatformHarmonyStatic; // RNOH: patch
116
-
117
- export const Platform: Platform;