@react-native-oh/react-native-harmony 0.61.16

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 (82) hide show
  1. package/Libraries/ART/ReactNativeART.js +43 -0
  2. package/Libraries/Animated/Animated.js +154 -0
  3. package/Libraries/Animated/delegates/createAnimatedComponentDelegate.js +20 -0
  4. package/Libraries/Animated/src/Easing.js +20 -0
  5. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +15 -0
  6. package/Libraries/Components/AppleTV/TVEventHandler.js +13 -0
  7. package/Libraries/Components/CheckBox/CheckBox.tsx +182 -0
  8. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.tsx +32 -0
  9. package/Libraries/Components/DatePickerIOS/DatePickerIOS.tsx +285 -0
  10. package/Libraries/Components/MaskedView/MaskedView.tsx +32 -0
  11. package/Libraries/Components/Picker/Picker.tsx +303 -0
  12. package/Libraries/Components/PickerIOS/PickerIOS.tsx +175 -0
  13. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.tsx +156 -0
  14. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.tsx +65 -0
  15. package/Libraries/Components/PushNotificationIOS/PushNotificationIOS.tsx +609 -0
  16. package/Libraries/Components/RefreshControl/RefreshControl.tsx +54 -0
  17. package/Libraries/Components/ScrollView/ScrollView.js +34 -0
  18. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.tsx +79 -0
  19. package/Libraries/Components/Slider/Slider.tsx +204 -0
  20. package/Libraries/Components/TextInput/TextInput.js +24 -0
  21. package/Libraries/Components/TimePickerAndroid/TimePickerAndroid.tsx +20 -0
  22. package/Libraries/Components/Touchable/TouchableOpacity.js +90 -0
  23. package/Libraries/Components/View/ViewPropTypes.js +16 -0
  24. package/Libraries/Components/View/delegate/ViewDelegate.js +49 -0
  25. package/Libraries/Core/ReactNativeVersion.js +21 -0
  26. package/Libraries/Core/polyfillPromise.js +18 -0
  27. package/Libraries/Core/setUpPlatform.js +13 -0
  28. package/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js +16 -0
  29. package/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js +16 -0
  30. package/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.js +15 -0
  31. package/Libraries/DeprecatedPropTypes/DeprecatedImageSourcePropType.js +16 -0
  32. package/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js +15 -0
  33. package/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js +15 -0
  34. package/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js +16 -0
  35. package/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js +15 -0
  36. package/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js +16 -0
  37. package/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js +15 -0
  38. package/Libraries/DeprecatedPropTypes/DeprecatedTextInputPropTypes.js +15 -0
  39. package/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js +16 -0
  40. package/Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js +15 -0
  41. package/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js +15 -0
  42. package/Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js +15 -0
  43. package/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js +16 -0
  44. package/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js +15 -0
  45. package/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js +20 -0
  46. package/Libraries/EventEmitter/NativeEventEmitter.js +50 -0
  47. package/Libraries/Image/Image.tsx +88 -0
  48. package/Libraries/Promise.js +50 -0
  49. package/Libraries/Storage/AsyncStorage.ts +216 -0
  50. package/Libraries/Storage/helpers.ts +36 -0
  51. package/Libraries/Storage/hooks.ts +19 -0
  52. package/Libraries/Storage/index.ts +5 -0
  53. package/Libraries/Storage/types.ts +43 -0
  54. package/Libraries/StyleSheet/EdgeInsetsPropType.js +15 -0
  55. package/Libraries/StyleSheet/PointPropType.js +15 -0
  56. package/Libraries/Utilities/Platform.harmony.ts +68 -0
  57. package/Libraries/Utilities/setAndForwardRef.js +71 -0
  58. package/README.dev.md +55 -0
  59. package/README.md +146 -0
  60. package/compat/ensurePropTypes.js +45 -0
  61. package/compat/getNoopPropType.js +42 -0
  62. package/compat/restoreRemoveListener.js +117 -0
  63. package/index.js +348 -0
  64. package/package.json +45 -0
  65. package/patched-virtualized-list/VirtualizedList.js +87 -0
  66. package/polyfills/dateSlash.js +89 -0
  67. package/react_native_harmony.har +0 -0
  68. package/src/private/specs/AsyncStorage.ts +37 -0
  69. package/src/private/specs/NativeDatePickerAndroid.ts +27 -0
  70. package/src/private/specs/NativeTimePickerAndroid.ts +28 -0
  71. package/src/private/specs/PushNotificationIOS.ts +167 -0
  72. package/src/private/specs/components/CheckBoxNativeComponent.ts +35 -0
  73. package/src/private/specs/components/DatePickerNativeComponent.ts +40 -0
  74. package/src/private/specs/components/MaskedViewNativeComponent.ts +17 -0
  75. package/src/private/specs/components/PickerIOSNativeComponent.ts +53 -0
  76. package/src/private/specs/components/PickerNativeComponent.ts +67 -0
  77. package/src/private/specs/components/ProgressBarNativeComponent.ts +24 -0
  78. package/src/private/specs/components/ProgressViewNativeComponent.ts +24 -0
  79. package/src/private/specs/components/ProgressWheelNativeComponent.ts +18 -0
  80. package/src/private/specs/components/RNSliderNativeComponent.ts +44 -0
  81. package/src/private/specs/components/SegmentedControlNativeComponent.ts +38 -0
  82. package/src/private/specs/components/TimePickerNativeComponent.ts +40 -0
@@ -0,0 +1,43 @@
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
+ import View from '@react-native-oh/react-native-harmony/Libraries/Components/View/View';
8
+
9
+ class Path {
10
+ constructor() {
11
+ }
12
+
13
+ moveTo() {
14
+ return this;
15
+ }
16
+
17
+ lineTo() {
18
+ return this;
19
+ }
20
+
21
+ arc() {
22
+ return this;
23
+ }
24
+
25
+ close() {
26
+ return this;
27
+ }
28
+ }
29
+
30
+ const ReactART = {
31
+ LinearGradient: View,
32
+ RadialGradient: View,
33
+ Pattern: View,
34
+ Transform: View,
35
+ Path: Path,
36
+ Surface: View,
37
+ Group: View,
38
+ ClippingRectangle: View,
39
+ Shape: View,
40
+ Text: View,
41
+ };
42
+
43
+ module.exports = ReactART;
@@ -0,0 +1,154 @@
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
+ 'use strict';
9
+
10
+ // Wrap Harmony 0.77 Animated to restore RN 0.61-friendly call patterns,
11
+ // especially around Animated.event where the second options argument
12
+ // used to be optional or a listener function.
13
+ // It preserves the lazy getters React Native uses to avoid require cycles.
14
+
15
+ const React = require('react');
16
+ const Animated77 = require('@react-native-oh/react-native-harmony/Libraries/Animated/Animated').default;
17
+
18
+ function withAnimatedEventShim(baseEvent) {
19
+ return function wrappedEvent(mapping, optionsOrListener, legacyThirdOptions) {
20
+ // RN 0.61 often called Animated.event(mapping) without options.
21
+ // Ensure options exist to avoid warnings and keep semantics.
22
+ if (typeof optionsOrListener === 'function') {
23
+ // Animated.event(mapping, listener)
24
+ return baseEvent(mapping, {useNativeDriver: false, listener: optionsOrListener});
25
+ }
26
+ if (optionsOrListener == null && legacyThirdOptions && typeof legacyThirdOptions === 'object') {
27
+ // Tolerate historical signatures with a third config arg.
28
+ return baseEvent(mapping, legacyThirdOptions);
29
+ }
30
+ const config = optionsOrListener ?? {useNativeDriver: false};
31
+ return baseEvent(mapping, config);
32
+ };
33
+ }
34
+
35
+ function withAnimationConfigShim(baseFn) {
36
+ return function wrappedAnimation(value, config) {
37
+ const cfg = config ?? {};
38
+ if (typeof cfg.useNativeDriver === 'undefined') {
39
+ cfg.useNativeDriver = false;
40
+ }
41
+ return baseFn(value, cfg);
42
+ };
43
+ }
44
+
45
+ // Attach legacy `_component` access to refs returned from Animated components.
46
+ function attachLegacyComponentGetter(node) {
47
+ if (!node || typeof node !== 'object' || ('_component' in node)) {
48
+ return node;
49
+ }
50
+ try {
51
+ Object.defineProperty(node, '_component', {
52
+ configurable: true,
53
+ get: () => node,
54
+ });
55
+ } catch (_e) {
56
+ // ignore if defineProperty fails
57
+ }
58
+ return node;
59
+ }
60
+
61
+ function withRefShim(Component) {
62
+ if (!Component) {
63
+ return Component;
64
+ }
65
+ return React.forwardRef((props, ref) => {
66
+ const setRef = node => {
67
+ const finalNode = attachLegacyComponentGetter(node);
68
+ if (typeof ref === 'function') {
69
+ ref(finalNode);
70
+ } else if (ref && typeof ref === 'object') {
71
+ ref.current = finalNode;
72
+ }
73
+ };
74
+ return React.createElement(Component, {...props, ref: setRef});
75
+ });
76
+ }
77
+
78
+ const AnimatedWrapped = {};
79
+ Object.defineProperties(
80
+ AnimatedWrapped,
81
+ Object.getOwnPropertyDescriptors(Animated77)
82
+ );
83
+
84
+ const baseEvent =
85
+ typeof Animated77.event === 'function' ? Animated77.event : null;
86
+ const baseTiming =
87
+ typeof Animated77.timing === 'function' ? Animated77.timing : null;
88
+ const baseSpring =
89
+ typeof Animated77.spring === 'function' ? Animated77.spring : null;
90
+ const baseDecay =
91
+ typeof Animated77.decay === 'function' ? Animated77.decay : null;
92
+
93
+ if (baseEvent) {
94
+ AnimatedWrapped.event = withAnimatedEventShim(baseEvent);
95
+ }
96
+ if (baseTiming) {
97
+ AnimatedWrapped.timing = withAnimationConfigShim(baseTiming);
98
+ }
99
+ if (baseSpring) {
100
+ AnimatedWrapped.spring = withAnimationConfigShim(baseSpring);
101
+ }
102
+ if (baseDecay) {
103
+ AnimatedWrapped.decay = withAnimationConfigShim(baseDecay);
104
+ }
105
+
106
+ // Ensure legacy `_component` is available on common Animated components
107
+ // and any user-created animated components via createAnimatedComponent.
108
+ AnimatedWrapped.createAnimatedComponent = function (Component) {
109
+ const Base = Animated77.createAnimatedComponent?.(Component);
110
+ return withRefShim(Base || Component);
111
+ };
112
+
113
+
114
+ /**
115
+ * Wraps animated components lazily to avoid dependency cycles.
116
+ *
117
+ * Without lazy loading, we'd have a circular dependency like:
118
+ * Animated -> Animated.AnimatedScrollView -> ... -> Animated
119
+ *
120
+ * Instead of requiring components immediately, we define them as getters
121
+ * that only access the underlying component when first accessed. This defers
122
+ * the actual component resolution until runtime, breaking the cycle.
123
+ */
124
+ function wrapLazyComponent(name) {
125
+ const descriptor = Object.getOwnPropertyDescriptor(Animated77, name);
126
+ if (!descriptor) {
127
+ return;
128
+ }
129
+ Object.defineProperty(AnimatedWrapped, name, {
130
+ configurable: true,
131
+ enumerable: descriptor.enumerable,
132
+ get() {
133
+ const Component = descriptor.get
134
+ ? descriptor.get.call(Animated77)
135
+ : descriptor.value;
136
+ const Wrapped = withRefShim(Component);
137
+ Object.defineProperty(AnimatedWrapped, name, {
138
+ configurable: true,
139
+ enumerable: descriptor.enumerable,
140
+ value: Wrapped,
141
+ writable: true,
142
+ });
143
+ return Wrapped;
144
+ },
145
+ });
146
+ }
147
+
148
+ ['View', 'Image', 'ScrollView', 'SectionList', 'FlatList', 'Text'].forEach(
149
+ wrapLazyComponent
150
+ );
151
+
152
+ // Export in both CommonJS and compat default form.
153
+ module.exports = AnimatedWrapped;
154
+ module.exports.default = AnimatedWrapped;
@@ -0,0 +1,20 @@
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
+ import setAndForwardRef from '../../Utilities/setAndForwardRef';
8
+
9
+ export function processRef(ref) {
10
+ return setAndForwardRef({
11
+ getForwardedRef: () => ref,
12
+ setLocalRef: (localRef) => {
13
+ if (localRef != null && localRef.getNode == null) {
14
+ localRef.getNode = () => {
15
+ return localRef;
16
+ };
17
+ }
18
+ },
19
+ });
20
+ }
@@ -0,0 +1,20 @@
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
+ /**
9
+ * Legacy deep import alias for RN 0.61 compatibility.
10
+ * Maps react-native/Libraries/Animated/src/Easing -> ../Easing
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ // Deep import alias for RN 0.61 projects that used
16
+ // `react-native/Libraries/Animated/src/Easing`.
17
+ // We forward directly to Harmony's Easing module.
18
+ const mod = require('@react-native-oh/react-native-harmony/Libraries/Animated/Easing');
19
+ module.exports = mod && mod.default ? mod.default : mod;
20
+ module.exports.default = module.exports;
@@ -0,0 +1,15 @@
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 OriginalAccessibilityInfo from '@react-native-oh/react-native-harmony/Libraries/Components/AccessibilityInfo/AccessibilityInfo';
9
+
10
+ const AccessibilityInfoWrapper = {
11
+ ...OriginalAccessibilityInfo,
12
+ fetch: OriginalAccessibilityInfo.isScreenReaderEnabled,
13
+ };
14
+
15
+ export default AccessibilityInfoWrapper;
@@ -0,0 +1,13 @@
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
+ class TVEventHandler {
9
+ enable() {}
10
+ disable() {}
11
+ }
12
+
13
+ module.exports = TVEventHandler;
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its 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
+ */
8
+ /**
9
+ * NOTICE: This file is copied from @react-native-oh-tpl/checkbox and adapted.
10
+ *
11
+ * CheckBox was initially part of the RN hence such copyright header is used.
12
+ * This component was later extracted and moved to a separate library.
13
+ * The copyright header above is also used in the react-native-community version, but the community version is converted to TypeScript.
14
+ * @react-native-oh-tpl/checkbox is based on from react-native-community and slightly adapted for OHOS.
15
+ */
16
+
17
+ //@ts-check
18
+ import nullthrows from 'nullthrows';
19
+ import React from 'react';
20
+ import {
21
+ View,
22
+ StyleSheet,
23
+ processColor,
24
+ ViewProps,
25
+ NativeMethods,
26
+ NativeSyntheticEvent,
27
+ } from 'react-native';
28
+ // @ts-ignore
29
+ import setAndForwardRef from '../../Utilities/setAndForwardRef';
30
+ import CheckBoxNativeComponent from '../../../src/private/specs/components/CheckBoxNativeComponent';
31
+
32
+ type CheckBoxEvent = NativeSyntheticEvent<
33
+ Readonly<{
34
+ target: number;
35
+ value: boolean;
36
+ }>
37
+ >;
38
+
39
+ type CommonProps = Readonly<
40
+ ViewProps & {
41
+ /**
42
+ * Used in case the props change removes the component.
43
+ */
44
+ onChange?: (event: CheckBoxEvent) => void;
45
+
46
+ /**
47
+ * Invoked with the new value when the value changes.
48
+ */
49
+ onValueChange?: (value: boolean) => void;
50
+
51
+ /**
52
+ * If true the user won't be able to toggle the checkbox.
53
+ * Default value is false.
54
+ */
55
+ disabled?: boolean;
56
+ /**
57
+ * Used to locate this view in end-to-end tests.
58
+ */
59
+ testID?: string,
60
+ }
61
+ >;
62
+
63
+ type CheckBoxNativeType = NativeMethods;
64
+
65
+ type Props = Readonly<
66
+ CommonProps & {
67
+ /**
68
+ * The value of the checkbox. If true the checkbox will be turned on.
69
+ * Default value is false.
70
+ */
71
+ value?: boolean;
72
+
73
+ /**
74
+ * Used to get the ref for the native checkbox
75
+ */
76
+ forwardedRef?: React.Ref<CheckBoxNativeType>;
77
+
78
+ /**
79
+ * Controls the colors the checkbox has in checked and unchecked states.
80
+ */
81
+ tintColors?: { true?: any; false?: any };
82
+
83
+ // BEGIN: @react-native-community/checkbox props
84
+ /**
85
+ * @deprecated: Use lineWidth instead
86
+ */
87
+ // strokeWidth?: number;
88
+ // markSize?: number;
89
+ // lineWidth?: number;
90
+
91
+ // strokeColor: string;
92
+ // onCheckColor: string;
93
+ // tintColor: string;
94
+ // END: @react-native-community/checkbox props
95
+ }
96
+ >;
97
+
98
+ class CheckBox extends React.Component<Props> {
99
+ _nativeRef: React.Ref<CheckBoxNativeType> | null = null;
100
+ _setNativeRef = setAndForwardRef({
101
+ getForwardedRef: () => this.props.forwardedRef,
102
+ setLocalRef: (ref: any) => {
103
+ this._nativeRef = ref;
104
+ },
105
+ });
106
+
107
+ _onChange = (event: CheckBoxEvent) => {
108
+ const value = this.props.value || false;
109
+
110
+ // @ts-ignore
111
+ nullthrows(this._nativeRef).setNativeProps({ value: value });
112
+
113
+ // Change the props after the native props are set in case the props
114
+ // change removes the component
115
+ this.props.onChange && this.props.onChange(event);
116
+ this.props.onValueChange &&
117
+ this.props.onValueChange(event.nativeEvent.value);
118
+ };
119
+
120
+ render() {
121
+ const { tintColors, style, ...props } = this.props;
122
+ const disabled = this.props.disabled || false;
123
+ const value = this.props.value || false;
124
+
125
+ const nativeProps = {
126
+ ...props,
127
+ onStartShouldSetResponder: () => true,
128
+ onResponderTerminationRequest: () => false,
129
+ enabled: !disabled,
130
+ on: value,
131
+ /**
132
+ * - #317aff to be consistent with default button. It's not exactly the color used by the platform by default, but so is the case with button.
133
+ * The color used by button can't be changed because of strict breaking changes policy.
134
+ */
135
+ checkedColor: tintColors?.true !== undefined
136
+ ? processColor(tintColors.true)
137
+ : processColor('#317aff'),
138
+ /**
139
+ * #666666 — color used by Android
140
+ */
141
+ uncheckedColor: tintColors?.false !== undefined
142
+ ? processColor(tintColors.false)
143
+ : processColor('#666666'),
144
+ style: [styles.rctCheckBox, style],
145
+ boxType: 'square',
146
+ strokeColor: processColor('#ffffff')!,
147
+ };
148
+ return (
149
+ <View style={styles.container}>
150
+ <CheckBoxNativeComponent
151
+ {...nativeProps}
152
+ ref={this._setNativeRef}
153
+ onValueChange={this._onChange}
154
+ />
155
+ </View>
156
+ );
157
+ }
158
+ }
159
+
160
+ const styles = StyleSheet.create({
161
+ container: {
162
+ padding: 7,
163
+ },
164
+ rctCheckBox: {
165
+ height: 18,
166
+ width: 18,
167
+ },
168
+ });
169
+
170
+ /**
171
+ * Can't use CheckBoxNativeType because it has different props
172
+ */
173
+ type CheckBoxType = NativeMethods;
174
+
175
+ const CheckBoxWithRef = React.forwardRef(function CheckBoxWithRef(
176
+ props: Props,
177
+ ref: React.Ref<CheckBoxType>
178
+ ) {
179
+ return <CheckBox {...props} forwardedRef={ref} />;
180
+ });
181
+
182
+ export default CheckBoxWithRef;
@@ -0,0 +1,32 @@
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
+ /**
9
+ * Implements a module with the interface of [DatePickerAndroid](https://reactnative-archive-august-2023.netlify.app/docs/0.61/datepickerandroid)
10
+ */
11
+
12
+ import NativeDatePickerAndroid from "../../../src/private/specs/NativeDatePickerAndroid";
13
+
14
+ type Options = {
15
+ date?: Date;
16
+ minDate?: Date;
17
+ maxDate?: Date;
18
+ mode?: "calendar" | "spinner" | "default";
19
+ };
20
+
21
+ export default {
22
+ open: async ({ date, minDate, maxDate, mode }: Options) => {
23
+ return await NativeDatePickerAndroid.open({
24
+ date: date?.getTime?.(),
25
+ minDate: minDate?.getTime?.(),
26
+ maxDate: maxDate?.getTime?.(),
27
+ mode: mode ?? "default",
28
+ });
29
+ },
30
+ dateSetAction: "dateSetAction",
31
+ dismissedAction: "dismissedAction",
32
+ };