@react-native-oh/react-native-harmony 0.72.10

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 (34) hide show
  1. package/Libraries/Alert/Alert.harmony.js +71 -0
  2. package/Libraries/Alert/AlertManager.ts +35 -0
  3. package/Libraries/Animated/NativeAnimatedHelper.harmony.js +601 -0
  4. package/Libraries/Components/Button/Button.harmony.js +451 -0
  5. package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +208 -0
  6. package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +75 -0
  7. package/Libraries/Components/ScrollView/ScrollView.harmony.js +1940 -0
  8. package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +24 -0
  9. package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +68 -0
  10. package/Libraries/Components/StatusBar/StatusBar.harmony.js +447 -0
  11. package/Libraries/Components/TextInput/TextInput.harmony.js +1697 -0
  12. package/Libraries/Components/TextInput/TextInputState.harmony.js +220 -0
  13. package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +396 -0
  14. package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +364 -0
  15. package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +227 -0
  16. package/Libraries/Components/View/View.harmony.js +149 -0
  17. package/Libraries/Core/setUpErrorHandling.harmony.js +35 -0
  18. package/Libraries/Image/AssetSourceResolver.harmony.ts +32 -0
  19. package/Libraries/NativeComponent/BaseViewConfig.harmony.js +325 -0
  20. package/Libraries/NativeModules/specs/NativeDevSettings.harmony.js +10 -0
  21. package/Libraries/Network/XMLHttpRequest.harmony.js +677 -0
  22. package/Libraries/Settings/Settings.harmony.js +15 -0
  23. package/Libraries/Utilities/BackHandler.harmony.js +109 -0
  24. package/Libraries/Utilities/NativePlatformConstantsHarmony.ts +8 -0
  25. package/Libraries/Utilities/Platform.d.ts +117 -0
  26. package/Libraries/Utilities/Platform.harmony.ts +33 -0
  27. package/Libraries/Utilities/createPerformanceLogger.harmony.js +328 -0
  28. package/index.js +178 -0
  29. package/metro.config.js +190 -0
  30. package/package.json +45 -0
  31. package/react-native.config.js +10 -0
  32. package/rnoh-4.0.0.200.har +0 -0
  33. package/tsconfig.json +13 -0
  34. package/types/index.d.ts +101 -0
@@ -0,0 +1,149 @@
1
+ /*
2
+ * RNOH patches:
3
+ * - imports
4
+ * - disable view flattening (collapsable prop) for box-only and none pointer events
5
+ */
6
+
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ * @format
14
+ * @flow strict-local
15
+ */
16
+
17
+ import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
18
+
19
+ import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';
20
+ import TextAncestor from 'react-native/Libraries/Text/TextAncestor';
21
+ import {getAccessibilityRoleFromRole} from 'react-native/Libraries/Utilities/AcessibilityMapping';
22
+ import ViewNativeComponent from 'react-native/Libraries/Components/View/ViewNativeComponent';
23
+ import * as React from 'react';
24
+
25
+ export type Props = ViewProps;
26
+
27
+ /**
28
+ * The most fundamental component for building a UI, View is a container that
29
+ * supports layout with flexbox, style, some touch handling, and accessibility
30
+ * controls.
31
+ *
32
+ * @see https://reactnative.dev/docs/view
33
+ */
34
+ const View: React.AbstractComponent<
35
+ ViewProps,
36
+ React.ElementRef<typeof ViewNativeComponent>,
37
+ > = React.forwardRef(
38
+ (
39
+ {
40
+ accessibilityElementsHidden,
41
+ accessibilityLabel,
42
+ accessibilityLabelledBy,
43
+ accessibilityLiveRegion,
44
+ accessibilityRole,
45
+ accessibilityState,
46
+ accessibilityValue,
47
+ 'aria-busy': ariaBusy,
48
+ 'aria-checked': ariaChecked,
49
+ 'aria-disabled': ariaDisabled,
50
+ 'aria-expanded': ariaExpanded,
51
+ 'aria-hidden': ariaHidden,
52
+ 'aria-label': ariaLabel,
53
+ 'aria-labelledby': ariaLabelledBy,
54
+ 'aria-live': ariaLive,
55
+ 'aria-selected': ariaSelected,
56
+ 'aria-valuemax': ariaValueMax,
57
+ 'aria-valuemin': ariaValueMin,
58
+ 'aria-valuenow': ariaValueNow,
59
+ 'aria-valuetext': ariaValueText,
60
+ focusable,
61
+ id,
62
+ importantForAccessibility,
63
+ nativeID,
64
+ pointerEvents,
65
+ role,
66
+ tabIndex,
67
+ collapsable,
68
+ ...otherProps
69
+ }: ViewProps,
70
+ forwardedRef,
71
+ ) => {
72
+ const _accessibilityLabelledBy =
73
+ ariaLabelledBy?.split(/\s*,\s*/g) ?? accessibilityLabelledBy;
74
+
75
+ let _accessibilityState;
76
+ if (
77
+ accessibilityState != null ||
78
+ ariaBusy != null ||
79
+ ariaChecked != null ||
80
+ ariaDisabled != null ||
81
+ ariaExpanded != null ||
82
+ ariaSelected != null
83
+ ) {
84
+ _accessibilityState = {
85
+ busy: ariaBusy ?? accessibilityState?.busy,
86
+ checked: ariaChecked ?? accessibilityState?.checked,
87
+ disabled: ariaDisabled ?? accessibilityState?.disabled,
88
+ expanded: ariaExpanded ?? accessibilityState?.expanded,
89
+ selected: ariaSelected ?? accessibilityState?.selected,
90
+ };
91
+ }
92
+ let _accessibilityValue;
93
+ if (
94
+ accessibilityValue != null ||
95
+ ariaValueMax != null ||
96
+ ariaValueMin != null ||
97
+ ariaValueNow != null ||
98
+ ariaValueText != null
99
+ ) {
100
+ _accessibilityValue = {
101
+ max: ariaValueMax ?? accessibilityValue?.max,
102
+ min: ariaValueMin ?? accessibilityValue?.min,
103
+ now: ariaValueNow ?? accessibilityValue?.now,
104
+ text: ariaValueText ?? accessibilityValue?.text,
105
+ };
106
+ }
107
+
108
+ // $FlowFixMe[underconstrained-implicit-instantiation]
109
+ let style = flattenStyle(otherProps.style);
110
+
111
+ const newPointerEvents = style?.pointerEvents || pointerEvents;
112
+
113
+ return (
114
+ <TextAncestor.Provider value={false}>
115
+ <ViewNativeComponent
116
+ {...otherProps}
117
+ accessibilityLiveRegion={
118
+ ariaLive === 'off' ? 'none' : ariaLive ?? accessibilityLiveRegion
119
+ }
120
+ accessibilityLabel={ariaLabel ?? accessibilityLabel}
121
+ focusable={tabIndex !== undefined ? !tabIndex : focusable}
122
+ accessibilityState={_accessibilityState}
123
+ accessibilityRole={
124
+ role ? getAccessibilityRoleFromRole(role) : accessibilityRole
125
+ }
126
+ accessibilityElementsHidden={
127
+ ariaHidden ?? accessibilityElementsHidden
128
+ }
129
+ accessibilityLabelledBy={_accessibilityLabelledBy}
130
+ accessibilityValue={_accessibilityValue}
131
+ collapsable={["box-only", "none"].includes(newPointerEvents) ? false : collapsable} // RNOH: patch
132
+ importantForAccessibility={
133
+ ariaHidden === true
134
+ ? 'no-hide-descendants'
135
+ : importantForAccessibility
136
+ }
137
+ nativeID={id ?? nativeID}
138
+ style={style}
139
+ pointerEvents={newPointerEvents}
140
+ ref={forwardedRef}
141
+ />
142
+ </TextAncestor.Provider>
143
+ );
144
+ },
145
+ );
146
+
147
+ View.displayName = 'View';
148
+
149
+ module.exports = View;
@@ -0,0 +1,35 @@
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
+ 'use strict';
12
+
13
+ /**
14
+ * Sets up the console and exception handling (redbox) for React Native.
15
+ * You can use this module directly, or just require InitializeCore.
16
+ */
17
+ const ExceptionsManager = require('react-native/Libraries/Core/ExceptionsManager'); // RNOH: patch
18
+ ExceptionsManager.installConsoleErrorReporter();
19
+
20
+ global.__fbDisableExceptionsManager = true; // RNOH: patch
21
+
22
+ // Set up error handler
23
+ if (!global.__fbDisableExceptionsManager) {
24
+ const handleError = (e: mixed, isFatal: boolean) => {
25
+ try {
26
+ ExceptionsManager.handleException(e, isFatal);
27
+ } catch (ee) {
28
+ console.log('Failed to print error: ', ee.message);
29
+ throw e;
30
+ }
31
+ };
32
+
33
+ const ErrorUtils = require('react-native/Libraries/vendor/core/ErrorUtils'); // RNOH: patch
34
+ ErrorUtils.setGlobalHandler(handleError);
35
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ getAssetDestRelativePath,
3
+ Asset,
4
+ } from '@react-native-oh/react-native-harmony-cli/src/assetResolver';
5
+
6
+ type ResolvedAssetSource = {
7
+ readonly __packager_asset: boolean;
8
+ readonly width?: number;
9
+ readonly height?: number;
10
+ readonly uri: string;
11
+ readonly scale: number;
12
+ };
13
+
14
+ class AssetSourceResolver {
15
+ constructor(
16
+ private serverUrl: string | undefined,
17
+ private jsbundleUrl: string | undefined,
18
+ private asset: Asset
19
+ ) {}
20
+
21
+ public defaultAsset(): ResolvedAssetSource {
22
+ return {
23
+ __packager_asset: this.asset.__packager_asset,
24
+ uri: `asset://${getAssetDestRelativePath(this.asset)}`,
25
+ scale: 1,
26
+ width: this.asset.width,
27
+ height: this.asset.height,
28
+ };
29
+ }
30
+ }
31
+
32
+ module.exports = AssetSourceResolver;
@@ -0,0 +1,325 @@
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
+ // 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
+ topSelect: {
27
+ phasedRegistrationNames: {
28
+ captured: 'onSelectCapture',
29
+ bubbled: 'onSelect',
30
+ },
31
+ },
32
+ topTouchEnd: {
33
+ phasedRegistrationNames: {
34
+ captured: 'onTouchEndCapture',
35
+ bubbled: 'onTouchEnd',
36
+ },
37
+ },
38
+ topTouchCancel: {
39
+ phasedRegistrationNames: {
40
+ captured: 'onTouchCancelCapture',
41
+ bubbled: 'onTouchCancel',
42
+ },
43
+ },
44
+ topTouchStart: {
45
+ phasedRegistrationNames: {
46
+ captured: 'onTouchStartCapture',
47
+ bubbled: 'onTouchStart',
48
+ },
49
+ },
50
+ topTouchMove: {
51
+ phasedRegistrationNames: {
52
+ captured: 'onTouchMoveCapture',
53
+ bubbled: 'onTouchMove',
54
+ },
55
+ },
56
+
57
+ // Experimental/Work in Progress Pointer Events (not yet ready for use)
58
+ topPointerCancel: {
59
+ phasedRegistrationNames: {
60
+ captured: 'onPointerCancelCapture',
61
+ bubbled: 'onPointerCancel',
62
+ },
63
+ },
64
+ topPointerDown: {
65
+ phasedRegistrationNames: {
66
+ captured: 'onPointerDownCapture',
67
+ bubbled: 'onPointerDown',
68
+ },
69
+ },
70
+ topPointerEnter: {
71
+ phasedRegistrationNames: {
72
+ captured: 'onPointerEnterCapture',
73
+ bubbled: 'onPointerEnter',
74
+ skipBubbling: true,
75
+ },
76
+ },
77
+ topPointerLeave: {
78
+ phasedRegistrationNames: {
79
+ captured: 'onPointerLeaveCapture',
80
+ bubbled: 'onPointerLeave',
81
+ skipBubbling: true,
82
+ },
83
+ },
84
+ topPointerMove: {
85
+ phasedRegistrationNames: {
86
+ captured: 'onPointerMoveCapture',
87
+ bubbled: 'onPointerMove',
88
+ },
89
+ },
90
+ topPointerUp: {
91
+ phasedRegistrationNames: {
92
+ captured: 'onPointerUpCapture',
93
+ bubbled: 'onPointerUp',
94
+ },
95
+ },
96
+ topPointerOut: {
97
+ phasedRegistrationNames: {
98
+ captured: 'onPointerOutCapture',
99
+ bubbled: 'onPointerOut',
100
+ },
101
+ },
102
+ topPointerOver: {
103
+ phasedRegistrationNames: {
104
+ captured: 'onPointerOverCapture',
105
+ bubbled: 'onPointerOver',
106
+ },
107
+ },
108
+ };
109
+
110
+ const directEventTypes = {
111
+ topAccessibilityAction: {
112
+ registrationName: 'onAccessibilityAction',
113
+ },
114
+ onGestureHandlerEvent: DynamicallyInjectedByGestureHandler({
115
+ registrationName: 'onGestureHandlerEvent',
116
+ }),
117
+ onGestureHandlerStateChange: DynamicallyInjectedByGestureHandler({
118
+ registrationName: 'onGestureHandlerStateChange',
119
+ }),
120
+
121
+ // Direct events from UIManagerModuleConstants.java
122
+ topContentSizeChange: {
123
+ registrationName: 'onContentSizeChange',
124
+ },
125
+ topScrollBeginDrag: {
126
+ registrationName: 'onScrollBeginDrag',
127
+ },
128
+ topMessage: {
129
+ registrationName: 'onMessage',
130
+ },
131
+ topSelectionChange: {
132
+ registrationName: 'onSelectionChange',
133
+ },
134
+ topLoadingFinish: {
135
+ registrationName: 'onLoadingFinish',
136
+ },
137
+ topMomentumScrollEnd: {
138
+ registrationName: 'onMomentumScrollEnd',
139
+ },
140
+ topClick: {
141
+ registrationName: 'onClick',
142
+ },
143
+ topLoadingStart: {
144
+ registrationName: 'onLoadingStart',
145
+ },
146
+ topLoadingError: {
147
+ registrationName: 'onLoadingError',
148
+ },
149
+ topMomentumScrollBegin: {
150
+ registrationName: 'onMomentumScrollBegin',
151
+ },
152
+ topScrollEndDrag: {
153
+ registrationName: 'onScrollEndDrag',
154
+ },
155
+ topScroll: {
156
+ registrationName: 'onScroll',
157
+ },
158
+ topLayout: {
159
+ registrationName: 'onLayout',
160
+ },
161
+ };
162
+
163
+ const validAttributesForNonEventProps = {
164
+ // @ReactProps from BaseViewManager
165
+ backgroundColor: {process: require('react-native/Libraries/StyleSheet/processColor').default},
166
+ transform: true,
167
+ opacity: true,
168
+ elevation: true,
169
+ shadowColor: {process: require('react-native/Libraries/StyleSheet/processColor').default},
170
+ zIndex: true,
171
+ renderToHardwareTextureAndroid: true,
172
+ testID: true,
173
+ nativeID: true,
174
+ accessibilityLabelledBy: true,
175
+ accessibilityLabel: true,
176
+ accessibilityHint: true,
177
+ accessibilityRole: true,
178
+ accessibilityCollection: true,
179
+ accessibilityCollectionItem: true,
180
+ accessibilityState: true,
181
+ accessibilityActions: true,
182
+ accessibilityValue: true,
183
+ importantForAccessibility: true,
184
+ rotation: true,
185
+ scaleX: true,
186
+ scaleY: true,
187
+ translateX: true,
188
+ translateY: true,
189
+ accessibilityLiveRegion: true,
190
+
191
+ // @ReactProps from LayoutShadowNode
192
+ width: true,
193
+ minWidth: true,
194
+ collapsable: true,
195
+ maxWidth: true,
196
+ height: true,
197
+ minHeight: true,
198
+ maxHeight: true,
199
+ flex: true,
200
+ flexGrow: true,
201
+ rowGap: true,
202
+ columnGap: true,
203
+ gap: true,
204
+ flexShrink: true,
205
+ flexBasis: true,
206
+ aspectRatio: true,
207
+ flexDirection: true,
208
+ flexWrap: true,
209
+ alignSelf: true,
210
+ alignItems: true,
211
+ alignContent: true,
212
+ justifyContent: true,
213
+ overflow: true,
214
+ display: true,
215
+
216
+ margin: true,
217
+ marginBlock: true,
218
+ marginBlockEnd: true,
219
+ marginBlockStart: true,
220
+ marginBottom: true,
221
+ marginEnd: true,
222
+ marginHorizontal: true,
223
+ marginInline: true,
224
+ marginInlineEnd: true,
225
+ marginInlineStart: true,
226
+ marginLeft: true,
227
+ marginRight: true,
228
+ marginStart: true,
229
+ marginTop: true,
230
+ marginVertical: true,
231
+
232
+ padding: true,
233
+ paddingBlock: true,
234
+ paddingBlockEnd: true,
235
+ paddingBlockStart: true,
236
+ paddingBottom: true,
237
+ paddingEnd: true,
238
+ paddingHorizontal: true,
239
+ paddingInline: true,
240
+ paddingInlineEnd: true,
241
+ paddingInlineStart: true,
242
+ paddingLeft: true,
243
+ paddingRight: true,
244
+ paddingStart: true,
245
+ paddingTop: true,
246
+ paddingVertical: true,
247
+
248
+ borderWidth: true,
249
+ borderStartWidth: true,
250
+ borderEndWidth: true,
251
+ borderTopWidth: true,
252
+ borderBottomWidth: true,
253
+ borderLeftWidth: true,
254
+ borderRightWidth: true,
255
+
256
+ start: true,
257
+ end: true,
258
+ left: true,
259
+ right: true,
260
+ top: true,
261
+ bottom: true,
262
+
263
+ position: true,
264
+
265
+ style: ReactNativeStyleAttributes,
266
+ };
267
+
268
+ // Props for bubbling and direct events
269
+ const validAttributesForEventProps = {
270
+ onLayout: true,
271
+
272
+ // PanResponder handlers
273
+ onMoveShouldSetResponder: true,
274
+ onMoveShouldSetResponderCapture: true,
275
+ onStartShouldSetResponder: true,
276
+ onStartShouldSetResponderCapture: true,
277
+ onResponderGrant: true,
278
+ onResponderReject: true,
279
+ onResponderStart: true,
280
+ onResponderEnd: true,
281
+ onResponderRelease: true,
282
+ onResponderMove: true,
283
+ onResponderTerminate: true,
284
+ onResponderTerminationRequest: true,
285
+ onShouldBlockNativeResponder: true,
286
+
287
+ // Touch events
288
+ onTouchStart: true,
289
+ onTouchMove: true,
290
+ onTouchEnd: true,
291
+ onTouchCancel: true,
292
+
293
+ // Pointer events
294
+ onPointerEnter: true,
295
+ onPointerEnterCapture: true,
296
+ onPointerLeave: true,
297
+ onPointerLeaveCapture: true,
298
+ onPointerMove: true,
299
+ onPointerMoveCapture: true,
300
+ onPointerOut: true,
301
+ onPointerOutCapture: true,
302
+ onPointerOver: true,
303
+ onPointerOverCapture: true,
304
+ };
305
+
306
+ /**
307
+ * On Android, Props are derived from a ViewManager and its ShadowNode.
308
+ *
309
+ * Where did we find these base platform props from?
310
+ * - Nearly all component ViewManagers descend from BaseViewManager,
311
+ * - and BaseViewManagers' ShadowNodes descend from LayoutShadowNode.
312
+ * - Also, all components inherit ViewConfigs from UIManagerModuleConstants.java.
313
+ *
314
+ * So, these ViewConfigs are generated from LayoutShadowNode and BaseViewManager.
315
+ */
316
+ const PlatformBaseViewConfigAndroid: PartialViewConfigWithoutName = {
317
+ directEventTypes,
318
+ bubblingEventTypes,
319
+ validAttributes: {
320
+ ...validAttributesForNonEventProps,
321
+ ...validAttributesForEventProps,
322
+ },
323
+ };
324
+
325
+ export default PlatformBaseViewConfigAndroid;
@@ -0,0 +1,10 @@
1
+ export default {
2
+ reload() {},
3
+ reloadWithReason(reason) {},
4
+ onFastRefresh() {},
5
+ setHotLoadingEnabled(isHotLoadingEnabled) {},
6
+ setIsDebuggingRemotely(isDebuggingRemotelyEnabled) {},
7
+ setProfilingEnabled(isProfilingEnabled) {},
8
+ toggleElementInspector() {},
9
+ addMenuItem(title) {},
10
+ };