@react-native-oh/react-native-harmony 0.72.86 → 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 +1 -5
  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,337 +1,23 @@
1
1
  /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @flow strict-local
9
6
  */
7
+ import baseViewConfigIOS from './BaseViewConfig.ios';
8
+ import baseViewConfigAndroid from './BaseViewConfig.android';
10
9
 
11
- // RNOH - added missing .harmony file
12
-
13
- import type {PartialViewConfigWithoutName} from 'react-native/Libraries/NativeComponent/PlatformBaseViewConfig';
14
-
15
- import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
16
- import {DynamicallyInjectedByGestureHandler} from 'react-native/Libraries/NativeComponent/ViewConfigIgnore';
17
-
18
- const bubblingEventTypes = {
19
- // Bubbling events from UIManagerModuleConstants.java
20
- topChange: {
21
- phasedRegistrationNames: {
22
- captured: 'onChangeCapture',
23
- bubbled: 'onChange',
24
- },
25
- },
26
- topFocus: {
27
- phasedRegistrationNames: {
28
- bubbled: 'onFocus',
29
- captured: 'onFocusCapture',
30
- },
31
- },
32
- topBlur: {
33
- phasedRegistrationNames: {
34
- bubbled: 'onBlur',
35
- captured: 'onBlurCapture',
36
- },
37
- },
38
- topSelect: {
39
- phasedRegistrationNames: {
40
- captured: 'onSelectCapture',
41
- bubbled: 'onSelect',
42
- },
43
- },
44
- topTouchEnd: {
45
- phasedRegistrationNames: {
46
- captured: 'onTouchEndCapture',
47
- bubbled: 'onTouchEnd',
48
- },
49
- },
50
- topTouchCancel: {
51
- phasedRegistrationNames: {
52
- captured: 'onTouchCancelCapture',
53
- bubbled: 'onTouchCancel',
54
- },
55
- },
56
- topTouchStart: {
57
- phasedRegistrationNames: {
58
- captured: 'onTouchStartCapture',
59
- bubbled: 'onTouchStart',
60
- },
61
- },
62
- topTouchMove: {
63
- phasedRegistrationNames: {
64
- captured: 'onTouchMoveCapture',
65
- bubbled: 'onTouchMove',
66
- },
67
- },
68
-
69
- // Experimental/Work in Progress Pointer Events (not yet ready for use)
70
- topPointerCancel: {
71
- phasedRegistrationNames: {
72
- captured: 'onPointerCancelCapture',
73
- bubbled: 'onPointerCancel',
74
- },
75
- },
76
- topPointerDown: {
77
- phasedRegistrationNames: {
78
- captured: 'onPointerDownCapture',
79
- bubbled: 'onPointerDown',
80
- },
81
- },
82
- topPointerEnter: {
83
- phasedRegistrationNames: {
84
- captured: 'onPointerEnterCapture',
85
- bubbled: 'onPointerEnter',
86
- skipBubbling: true,
87
- },
88
- },
89
- topPointerLeave: {
90
- phasedRegistrationNames: {
91
- captured: 'onPointerLeaveCapture',
92
- bubbled: 'onPointerLeave',
93
- skipBubbling: true,
94
- },
95
- },
96
- topPointerMove: {
97
- phasedRegistrationNames: {
98
- captured: 'onPointerMoveCapture',
99
- bubbled: 'onPointerMove',
100
- },
101
- },
102
- topPointerUp: {
103
- phasedRegistrationNames: {
104
- captured: 'onPointerUpCapture',
105
- bubbled: 'onPointerUp',
106
- },
107
- },
108
- topPointerOut: {
109
- phasedRegistrationNames: {
110
- captured: 'onPointerOutCapture',
111
- bubbled: 'onPointerOut',
112
- },
113
- },
114
- topPointerOver: {
115
- phasedRegistrationNames: {
116
- captured: 'onPointerOverCapture',
117
- bubbled: 'onPointerOver',
118
- },
119
- },
120
- };
121
-
122
- const directEventTypes = {
123
- topAccessibilityAction: {
124
- registrationName: 'onAccessibilityAction',
125
- },
126
- onGestureHandlerEvent: DynamicallyInjectedByGestureHandler({
127
- registrationName: 'onGestureHandlerEvent',
128
- }),
129
- onGestureHandlerStateChange: DynamicallyInjectedByGestureHandler({
130
- registrationName: 'onGestureHandlerStateChange',
131
- }),
132
-
133
- // Direct events from UIManagerModuleConstants.java
134
- topContentSizeChange: {
135
- registrationName: 'onContentSizeChange',
136
- },
137
- topScrollBeginDrag: {
138
- registrationName: 'onScrollBeginDrag',
139
- },
140
- topMessage: {
141
- registrationName: 'onMessage',
142
- },
143
- topSelectionChange: {
144
- registrationName: 'onSelectionChange',
145
- },
146
- topLoadingFinish: {
147
- registrationName: 'onLoadingFinish',
10
+ export default {
11
+ bubblingEventTypes: {
12
+ ...baseViewConfigAndroid.baseViewConfigAndroid,
13
+ ...baseViewConfigIOS.bubblingEventTypes,
148
14
  },
149
- topMomentumScrollEnd: {
150
- registrationName: 'onMomentumScrollEnd',
15
+ directEventTypes: {
16
+ ...baseViewConfigAndroid.directEventTypes,
17
+ ...baseViewConfigIOS.directEventTypes,
151
18
  },
152
- topClick: {
153
- registrationName: 'onClick',
154
- },
155
- topLoadingStart: {
156
- registrationName: 'onLoadingStart',
157
- },
158
- topLoadingError: {
159
- registrationName: 'onLoadingError',
160
- },
161
- topMomentumScrollBegin: {
162
- registrationName: 'onMomentumScrollBegin',
163
- },
164
- topScrollEndDrag: {
165
- registrationName: 'onScrollEndDrag',
166
- },
167
- topScroll: {
168
- registrationName: 'onScroll',
169
- },
170
- topLayout: {
171
- registrationName: 'onLayout',
172
- },
173
- };
174
-
175
- const validAttributesForNonEventProps = {
176
- // @ReactProps from BaseViewManager
177
- backgroundColor: {process: require('react-native/Libraries/StyleSheet/processColor').default},
178
- transform: true,
179
- opacity: true,
180
- elevation: true,
181
- shadowColor: {process: require('react-native/Libraries/StyleSheet/processColor').default},
182
- zIndex: true,
183
- renderToHardwareTextureAndroid: true,
184
- testID: true,
185
- nativeID: true,
186
- accessibilityLabelledBy: true,
187
- accessibilityLabel: true,
188
- accessibilityHint: true,
189
- accessibilityRole: true,
190
- accessibilityCollection: true,
191
- accessibilityCollectionItem: true,
192
- accessibilityState: true,
193
- accessibilityActions: true,
194
- accessibilityValue: true,
195
- importantForAccessibility: true,
196
- rotation: true,
197
- scaleX: true,
198
- scaleY: true,
199
- translateX: true,
200
- translateY: true,
201
- accessibilityLiveRegion: true,
202
-
203
- // @ReactProps from LayoutShadowNode
204
- width: true,
205
- minWidth: true,
206
- collapsable: true,
207
- maxWidth: true,
208
- height: true,
209
- minHeight: true,
210
- maxHeight: true,
211
- flex: true,
212
- flexGrow: true,
213
- rowGap: true,
214
- columnGap: true,
215
- gap: true,
216
- flexShrink: true,
217
- flexBasis: true,
218
- aspectRatio: true,
219
- flexDirection: true,
220
- flexWrap: true,
221
- alignSelf: true,
222
- alignItems: true,
223
- alignContent: true,
224
- justifyContent: true,
225
- overflow: true,
226
- display: true,
227
-
228
- margin: true,
229
- marginBlock: true,
230
- marginBlockEnd: true,
231
- marginBlockStart: true,
232
- marginBottom: true,
233
- marginEnd: true,
234
- marginHorizontal: true,
235
- marginInline: true,
236
- marginInlineEnd: true,
237
- marginInlineStart: true,
238
- marginLeft: true,
239
- marginRight: true,
240
- marginStart: true,
241
- marginTop: true,
242
- marginVertical: true,
243
-
244
- padding: true,
245
- paddingBlock: true,
246
- paddingBlockEnd: true,
247
- paddingBlockStart: true,
248
- paddingBottom: true,
249
- paddingEnd: true,
250
- paddingHorizontal: true,
251
- paddingInline: true,
252
- paddingInlineEnd: true,
253
- paddingInlineStart: true,
254
- paddingLeft: true,
255
- paddingRight: true,
256
- paddingStart: true,
257
- paddingTop: true,
258
- paddingVertical: true,
259
-
260
- borderWidth: true,
261
- borderStartWidth: true,
262
- borderEndWidth: true,
263
- borderTopWidth: true,
264
- borderBottomWidth: true,
265
- borderLeftWidth: true,
266
- borderRightWidth: true,
267
-
268
- start: true,
269
- end: true,
270
- left: true,
271
- right: true,
272
- top: true,
273
- bottom: true,
274
-
275
- position: true,
276
-
277
- style: ReactNativeStyleAttributes,
278
- };
279
-
280
- // Props for bubbling and direct events
281
- const validAttributesForEventProps = {
282
- onLayout: true,
283
-
284
- // PanResponder handlers
285
- onMoveShouldSetResponder: true,
286
- onMoveShouldSetResponderCapture: true,
287
- onStartShouldSetResponder: true,
288
- onStartShouldSetResponderCapture: true,
289
- onResponderGrant: true,
290
- onResponderReject: true,
291
- onResponderStart: true,
292
- onResponderEnd: true,
293
- onResponderRelease: true,
294
- onResponderMove: true,
295
- onResponderTerminate: true,
296
- onResponderTerminationRequest: true,
297
- onShouldBlockNativeResponder: true,
298
-
299
- // Touch events
300
- onTouchStart: true,
301
- onTouchMove: true,
302
- onTouchEnd: true,
303
- onTouchCancel: true,
304
-
305
- // Pointer events
306
- onPointerEnter: true,
307
- onPointerEnterCapture: true,
308
- onPointerLeave: true,
309
- onPointerLeaveCapture: true,
310
- onPointerMove: true,
311
- onPointerMoveCapture: true,
312
- onPointerOut: true,
313
- onPointerOutCapture: true,
314
- onPointerOver: true,
315
- onPointerOverCapture: true,
316
- };
317
-
318
- /**
319
- * On Android, Props are derived from a ViewManager and its ShadowNode.
320
- *
321
- * Where did we find these base platform props from?
322
- * - Nearly all component ViewManagers descend from BaseViewManager,
323
- * - and BaseViewManagers' ShadowNodes descend from LayoutShadowNode.
324
- * - Also, all components inherit ViewConfigs from UIManagerModuleConstants.java.
325
- *
326
- * So, these ViewConfigs are generated from LayoutShadowNode and BaseViewManager.
327
- */
328
- const PlatformBaseViewConfigAndroid: PartialViewConfigWithoutName = {
329
- directEventTypes,
330
- bubblingEventTypes,
331
19
  validAttributes: {
332
- ...validAttributesForNonEventProps,
333
- ...validAttributesForEventProps,
20
+ ...baseViewConfigAndroid.validAttributes,
21
+ ...baseViewConfigIOS.validAttributes,
334
22
  },
335
23
  };
336
-
337
- export default PlatformBaseViewConfigAndroid;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+ import { BaseViewConfigIgnoreDelegate } from './BaseViewConfigIgnoreDelegate';
8
+
9
+ export default class ViewConfigIgnoreDelegate extends BaseViewConfigIgnoreDelegate {
10
+ override conditionallyIgnoredEventHandlers<T>(value: T): T | undefined {
11
+ return value;
12
+ }
13
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ import { BaseBridgelessUIManagerDelegate } from './BaseBridgelessUIManagerDelegate';
9
+
10
+ export default class BridgelessUIManagerDelegate extends BaseBridgelessUIManagerDelegate {
11
+ override selectAndroidOrIOSImplementation(): 'android' | 'ios' {
12
+ return 'android';
13
+ }
14
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
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
+
8
+ import { BaseI18nManagerDelegate } from './BaseI18nManagerDelegate';
9
+
10
+ export default class I18nManagerDelegate extends BaseI18nManagerDelegate {
11
+ override getConstants = () => {
12
+ return this.ctx.constantsCallback();
13
+ };
14
+
15
+ get isRTL(): boolean {
16
+ return this.ctx.constantsCallback().isRTL;
17
+ }
18
+
19
+ get doLeftAndRightSwapInRTL(): boolean {
20
+ return this.ctx.constantsCallback().doLeftAndRightSwapInRTL;
21
+ }
22
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ export default {
9
+ get(key: string): null | unknown {
10
+ return null;
11
+ },
12
+
13
+ set(settings: Object) {},
14
+
15
+ watchKeys(keys: string | string[], callback: () => void): number {
16
+ return -1;
17
+ },
18
+
19
+ clearWatch(watchId: number) {},
20
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ import invariant from 'invariant';
9
+ import {
10
+ BaseShareDelegate,
11
+ ShareAction,
12
+ ShareContent,
13
+ ShareOptions,
14
+ } from './BaseShareDelegate';
15
+ // @ts-ignore
16
+ import NativeShareModule from '../NativeShareModule';
17
+
18
+ export default class ShareDelegate extends BaseShareDelegate {
19
+ override async onShare(
20
+ content: ShareContent,
21
+ options: ShareOptions
22
+ ): Promise<ShareAction> {
23
+ invariant(NativeShareModule, 'ShareModule should be registered.');
24
+ invariant(
25
+ typeof content.url === 'string' ||
26
+ typeof content.message === 'string' ||
27
+ typeof content.title === 'string',
28
+ 'At least one of URL, title and message is required'
29
+ );
30
+ const newContent = {
31
+ title: content.title,
32
+ message:
33
+ typeof content.message === 'string' ? content.message : undefined,
34
+ url: typeof content.url === 'string' ? content.url : undefined,
35
+ };
36
+ const result = await NativeShareModule.share(
37
+ newContent,
38
+ options.dialogTitle
39
+ );
40
+ return { activityType: null, ...result };
41
+ }
42
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ import { TurboModule, TurboModuleRegistry } from 'react-native';
9
+
10
+ interface Spec extends TurboModule {
11
+ getSystemColor: (colorKeys: string[]) => string | null;
12
+ }
13
+
14
+ export const NativePlatformColor =
15
+ TurboModuleRegistry.getEnforcing<Spec>('PlatformColor');
@@ -1,4 +1,11 @@
1
- import { NativePlatformColor } from "./NativePlatformColor";
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ import { NativePlatformColor } from './NativePlatformColor.harmony';
2
9
 
3
10
  export const PlatformColor = (...colors: string[]) => {
4
11
  const color = NativePlatformColor.getSystemColor(colors);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ // @ts-ignore
9
+ import BackHandler from './BackHandler.android';
10
+ export default BackHandler;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ import type { PlatformHarmonyConstants } from './Platform';
9
+ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
10
+ import type { TurboModule } from '../TurboModule/RCTExport';
11
+
12
+ interface Spec extends TurboModule {
13
+ getConstants: () => PlatformHarmonyConstants;
14
+ }
15
+
16
+ export const NativePlatformConstantsHarmony =
17
+ TurboModuleRegistry.getEnforcing<Spec>('PlatformConstants');
@@ -1,33 +1,58 @@
1
- import { NativePlatformConstantsHarmony } from "./NativePlatformConstants";
2
- import type { PlatformHarmonyStatic, PlatformHarmonyConstants, PlatformOSType } from "./Platform";
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ import { NativePlatformConstantsHarmony } from './NativePlatformConstantsHarmony.harmony';
9
+ import type {
10
+ PlatformHarmonyStatic,
11
+ PlatformHarmonyConstants,
12
+ PlatformOSType,
13
+ } from './Platform';
14
+
15
+ module.exports = {
16
+ _constants: undefined,
17
+ OS: 'harmony',
3
18
 
4
- const Platform = {
5
- __constants: undefined as undefined | PlatformHarmonyConstants,
6
- OS: 'harmony' as const,
7
19
  get constants() {
8
- if (this.__constants == null) {
9
- this.__constants = NativePlatformConstantsHarmony.getConstants();
20
+ if (this._constants == null) {
21
+ this._constants = NativePlatformConstantsHarmony.getConstants();
10
22
  }
11
- return this.__constants;
23
+ return this._constants!;
12
24
  },
25
+
13
26
  get Version() {
14
27
  return this.constants.osFullName;
15
28
  },
29
+
16
30
  get isPad() {
17
31
  return this.constants.deviceType === 'tablet';
18
32
  },
33
+
19
34
  get isTV() {
20
35
  return this.constants.deviceType === 'tv';
21
36
  },
37
+
22
38
  get isTesting() {
23
39
  if (__DEV__) {
24
40
  return this.constants.isTesting;
25
41
  }
26
42
  return false;
27
43
  },
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
44
 
33
- module.exports = Platform as PlatformHarmonyStatic;
45
+ select<T>(
46
+ spec:
47
+ | ({ [platform in PlatformOSType]?: T } & { default: T })
48
+ | { [platform in PlatformOSType]: T }
49
+ ) {
50
+ return 'harmony' in spec
51
+ ? spec.harmony
52
+ : 'native' in spec
53
+ ? spec.native
54
+ : spec.default;
55
+ },
56
+ } satisfies PlatformHarmonyStatic & {
57
+ _constants: undefined | PlatformHarmonyConstants;
58
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
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
+
8
+ import { BaseVibrationDelegate } from './BaseVibrationDelegate';
9
+
10
+ export default class VibrationDelegate extends BaseVibrationDelegate {
11
+ override shouldUseAndroidImplementation(): boolean {
12
+ return true;
13
+ }
14
+ }