@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.
- package/Libraries/Alert/Alert.harmony.js +71 -71
- package/Libraries/Alert/AlertManager.ts +35 -35
- package/Libraries/Animated/NativeAnimatedHelper.harmony.js +601 -601
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +445 -426
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.harmony.js +30 -0
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.harmony.js +26 -0
- package/Libraries/Components/Button/Button.harmony.js +450 -450
- package/Libraries/Components/Image/Image.flow.harmony.js +53 -0
- package/Libraries/Components/Image/Image.harmony.js +299 -0
- package/Libraries/Components/Image/NativeImageLoaderHarmony.js +38 -0
- package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +210 -208
- package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +76 -75
- package/Libraries/Components/ScrollView/ScrollView.harmony.js +1951 -1930
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +24 -24
- package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +71 -68
- package/Libraries/Components/StatusBar/StatusBar.harmony.js +447 -447
- package/Libraries/Components/TextInput/TextInput.harmony.js +1707 -1697
- package/Libraries/Components/TextInput/TextInputState.harmony.js +220 -220
- package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +396 -396
- package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +364 -364
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +227 -227
- package/Libraries/Components/View/View.harmony.js +149 -149
- package/Libraries/Core/setUpReactDevTools.harmony.js +93 -93
- package/Libraries/Image/AssetSourceResolver.harmony.ts +78 -78
- package/Libraries/NativeComponent/BaseViewConfig.harmony.js +337 -337
- package/Libraries/ReactNative/UIManager.harmony.js +210 -210
- package/Libraries/Settings/Settings.harmony.js +15 -15
- package/Libraries/Share/Share.harmony.js +174 -0
- package/Libraries/StyleSheet/NativePlatformColor.ts +8 -8
- package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +14 -14
- package/Libraries/Utilities/BackHandler.harmony.js +109 -109
- package/Libraries/Utilities/{NativePlatformConstantsHarmony.ts → NativePlatformConstants.harmony.ts} +8 -8
- package/Libraries/Utilities/Platform.d.ts +117 -117
- package/Libraries/Utilities/Platform.harmony.ts +33 -33
- package/Libraries/Utilities/createPerformanceLogger.harmony.js +328 -328
- package/Libraries/Vibration/Vibration.harmony.js +88 -88
- package/index.js +212 -202
- package/jest.config.js +5 -5
- package/metro.config.js +348 -349
- package/package.json +58 -55
- package/react-native.config.js +10 -10
- package/{rnoh-4.1.0.404-vmall.har → react_native_openharmony.har} +0 -0
- package/tsconfig.json +13 -13
- package/types/index.d.ts +101 -101
|
@@ -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;
|
package/Libraries/Utilities/{NativePlatformConstantsHarmony.ts → NativePlatformConstants.harmony.ts}
RENAMED
|
@@ -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');
|
|
@@ -1,117 +1,117 @@
|
|
|
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;
|
|
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;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { NativePlatformConstantsHarmony } from "./
|
|
2
|
-
import type { PlatformHarmonyStatic, PlatformHarmonyConstants, PlatformOSType } from "./Platform";
|
|
3
|
-
|
|
4
|
-
const Platform = {
|
|
5
|
-
__constants: undefined as undefined | PlatformHarmonyConstants,
|
|
6
|
-
OS: 'harmony' as const,
|
|
7
|
-
get constants() {
|
|
8
|
-
if (this.__constants == null) {
|
|
9
|
-
this.__constants = NativePlatformConstantsHarmony.getConstants();
|
|
10
|
-
}
|
|
11
|
-
return this.__constants;
|
|
12
|
-
},
|
|
13
|
-
get Version() {
|
|
14
|
-
return this.constants.osFullName;
|
|
15
|
-
},
|
|
16
|
-
get isPad() {
|
|
17
|
-
return this.constants.deviceType === 'tablet';
|
|
18
|
-
},
|
|
19
|
-
get isTV() {
|
|
20
|
-
return this.constants.deviceType === 'tv';
|
|
21
|
-
},
|
|
22
|
-
get isTesting() {
|
|
23
|
-
if (__DEV__) {
|
|
24
|
-
return this.constants.isTesting;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
},
|
|
28
|
-
select<T>(spec: ({ [platform in PlatformOSType]?: T } & { default: T; }) | { [platform in PlatformOSType]: T }) {
|
|
29
|
-
return 'harmony' in spec ? spec.harmony : 'native' in spec ? spec.native : spec.default;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
module.exports = Platform as PlatformHarmonyStatic;
|
|
1
|
+
import { NativePlatformConstantsHarmony } from "./NativePlatformConstants";
|
|
2
|
+
import type { PlatformHarmonyStatic, PlatformHarmonyConstants, PlatformOSType } from "./Platform";
|
|
3
|
+
|
|
4
|
+
const Platform = {
|
|
5
|
+
__constants: undefined as undefined | PlatformHarmonyConstants,
|
|
6
|
+
OS: 'harmony' as const,
|
|
7
|
+
get constants() {
|
|
8
|
+
if (this.__constants == null) {
|
|
9
|
+
this.__constants = NativePlatformConstantsHarmony.getConstants();
|
|
10
|
+
}
|
|
11
|
+
return this.__constants;
|
|
12
|
+
},
|
|
13
|
+
get Version() {
|
|
14
|
+
return this.constants.osFullName;
|
|
15
|
+
},
|
|
16
|
+
get isPad() {
|
|
17
|
+
return this.constants.deviceType === 'tablet';
|
|
18
|
+
},
|
|
19
|
+
get isTV() {
|
|
20
|
+
return this.constants.deviceType === 'tv';
|
|
21
|
+
},
|
|
22
|
+
get isTesting() {
|
|
23
|
+
if (__DEV__) {
|
|
24
|
+
return this.constants.isTesting;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
},
|
|
28
|
+
select<T>(spec: ({ [platform in PlatformOSType]?: T } & { default: T; }) | { [platform in PlatformOSType]: T }) {
|
|
29
|
+
return 'harmony' in spec ? spec.harmony : 'native' in spec ? spec.native : spec.default;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = Platform as PlatformHarmonyStatic;
|