@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.
- package/LICENSE +21 -0
- package/LICENSE-Meta +21 -0
- package/Libraries/Alert/delegates/AlertDelegate.harmony.ts +84 -0
- package/Libraries/Alert/{AlertManager.ts → delegates/AlertManager.harmony.ts} +10 -4
- package/Libraries/Animated/shouldUseTurboAnimatedModule.harmony.ts +10 -0
- package/Libraries/Components/AccessibilityInfo/delegates/AccessibilityInfoDelegate.harmony.ts +44 -0
- package/Libraries/Components/AccessibilityInfo/{NativeAccessibilityInfoHarmony.ts → delegates/NativeAccessibilityInfoHarmony.harmony.ts} +9 -2
- package/Libraries/Components/Keyboard/delegates/KeyboardAvoidingViewDelegate.harmony.ts +42 -0
- package/Libraries/Components/RefreshControl/delegates/RefreshControlDelegate.harmony.tsx +29 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +93 -31
- package/Libraries/Components/ScrollView/delegates/ScrollViewDelegate.harmony.tsx +41 -0
- package/Libraries/Components/ScrollView/delegates/ScrollViewNativeComponentDelegate.harmony.ts +89 -0
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.ts +19 -0
- package/Libraries/Components/StatusBar/delegates/NativeStatusBarManagerHarmony.harmony.ts +53 -0
- package/Libraries/Components/StatusBar/delegates/StatusBarDelegate.harmony.ts +83 -0
- package/Libraries/Components/TextInput/delegates/TextInputDelegate.harmony.tsx +98 -0
- package/Libraries/Components/TextInput/delegates/TextInputStateDelegate.harmony.tsx +20 -0
- package/Libraries/Components/Touchable/delegates/TouchableHighlightDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableNativeFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableWithoutFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/delegates/ButtonDelegate.harmony.ts +41 -0
- package/Libraries/Core/setUpPlatform.harmony.js +30 -0
- package/Libraries/Image/AssetSourceResolver.harmony.ts +75 -29
- package/Libraries/Image/Image.harmony.ts +17 -0
- package/Libraries/NativeComponent/BaseViewConfig.harmony.js +12 -326
- package/Libraries/NativeComponent/delegates/ViewConfigIgnoreDelegate.harmony.ts +13 -0
- package/Libraries/ReactNative/delegates/BridgelessUIManagerDelegate.harmony.ts +14 -0
- package/Libraries/ReactNative/delegates/I18nManagerDelegate.harmony.ts +22 -0
- package/Libraries/Settings/Settings.harmony.ts +20 -0
- package/Libraries/Share/delegates/ShareDelegate.harmony.ts +42 -0
- package/Libraries/StyleSheet/NativePlatformColor.harmony.ts +15 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +8 -1
- package/Libraries/Utilities/BackHandler.harmony.ts +10 -0
- package/Libraries/Utilities/NativePlatformConstantsHarmony.harmony.ts +17 -0
- package/Libraries/Utilities/Platform.harmony.ts +38 -13
- package/Libraries/Vibration/delegates/VibrationDelegate.harmony.ts +14 -0
- package/NOTICE.md +846 -0
- package/README.md +2 -2
- package/index.js +53 -63
- package/jest.config.js +0 -7
- package/metro.config.d.ts +17 -0
- package/metro.config.js +398 -115
- package/package.json +58 -37
- package/react-native.config.js +57 -9
- package/react_native_openharmony.har +0 -0
- package/tsconfig.json +10 -4
- package/types/index.harmony.d.ts +99 -0
- package/Libraries/Alert/Alert.harmony.js +0 -77
- package/Libraries/Animated/NativeAnimatedHelper.harmony.js +0 -601
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +0 -441
- package/Libraries/Components/Button/Button.harmony.js +0 -451
- package/Libraries/Components/Image/Image.flow.harmony.js +0 -53
- package/Libraries/Components/Image/Image.harmony.js +0 -317
- package/Libraries/Components/Image/NativeImageLoaderHarmony.js +0 -38
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.harmony.js +0 -256
- package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +0 -210
- package/Libraries/Components/ScrollView/ScrollView.harmony.js +0 -1951
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +0 -24
- package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +0 -71
- package/Libraries/Components/StatusBar/StatusBar.harmony.js +0 -447
- package/Libraries/Components/TextInput/TextInput.harmony.js +0 -1716
- package/Libraries/Components/TextInput/TextInputState.harmony.js +0 -220
- package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +0 -396
- package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +0 -364
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +0 -227
- package/Libraries/Components/View/View.harmony.js +0 -149
- package/Libraries/Core/setUpReactDevTools.harmony.js +0 -93
- package/Libraries/ReactNative/I18nManager.harmony.js +0 -78
- package/Libraries/ReactNative/UIManager.harmony.js +0 -210
- package/Libraries/Settings/Settings.harmony.js +0 -15
- package/Libraries/Share/Share.harmony.js +0 -174
- package/Libraries/StyleSheet/NativePlatformColor.ts +0 -8
- package/Libraries/Utilities/BackHandler.harmony.js +0 -109
- package/Libraries/Utilities/NativePlatformConstants.harmony.ts +0 -8
- package/Libraries/Utilities/Platform.d.ts +0 -117
- package/Libraries/Utilities/createPerformanceLogger.harmony.js +0 -328
- package/Libraries/Vibration/Vibration.harmony.js +0 -88
- package/harmony/.keep +0 -0
- package/harmony/rnoh-hvigor-plugin-0.2.0.tgz +0 -0
- package/react_native_openharmony_release.har +0 -0
- package/types/index.d.ts +0 -108
|
@@ -1,149 +0,0 @@
|
|
|
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;
|
|
@@ -1,93 +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
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
if (__DEV__) {
|
|
14
|
-
let isWebSocketOpen = false;
|
|
15
|
-
let ws = null;
|
|
16
|
-
|
|
17
|
-
const reactDevTools = require('react-devtools-core');
|
|
18
|
-
const connectToDevTools = () => {
|
|
19
|
-
if (ws !== null && isWebSocketOpen) {
|
|
20
|
-
// If the DevTools backend is already connected, don't recreate the WebSocket.
|
|
21
|
-
// This would break the connection.
|
|
22
|
-
// If there isn't an active connection, a backend may be waiting to connect,
|
|
23
|
-
// in which case it's okay to make a new one.
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// not when debugging in chrome
|
|
28
|
-
// TODO(t12832058) This check is broken
|
|
29
|
-
if (!window.document) {
|
|
30
|
-
const AppState = require('react-native/Libraries/AppState/AppState');
|
|
31
|
-
const getDevServer = require('react-native/Libraries/Core/Devtools/getDevServer');
|
|
32
|
-
|
|
33
|
-
// Don't steal the DevTools from currently active app.
|
|
34
|
-
// Note: if you add any AppState subscriptions to this file,
|
|
35
|
-
// you will also need to guard against `AppState.isAvailable`,
|
|
36
|
-
// or the code will throw for bundles that don't have it.
|
|
37
|
-
const isAppActive = () => AppState.currentState !== 'background';
|
|
38
|
-
|
|
39
|
-
// RNOH patch: wait until appstate is active before connecting
|
|
40
|
-
if (!isAppActive()) {
|
|
41
|
-
const subscription = AppState.addEventListener('change', () => {
|
|
42
|
-
if (isAppActive()) {
|
|
43
|
-
connectToDevTools();
|
|
44
|
-
subscription.remove();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Get hostname from development server (packager)
|
|
51
|
-
const devServer = getDevServer();
|
|
52
|
-
const host = devServer.bundleLoadedFromServer
|
|
53
|
-
? devServer.url
|
|
54
|
-
.replace(/https?:\/\//, '')
|
|
55
|
-
.replace(/\/$/, '')
|
|
56
|
-
.split(':')[0]
|
|
57
|
-
: 'localhost';
|
|
58
|
-
|
|
59
|
-
// Read the optional global variable for backward compatibility.
|
|
60
|
-
// It was added in https://github.com/facebook/react-native/commit/bf2b435322e89d0aeee8792b1c6e04656c2719a0.
|
|
61
|
-
const port =
|
|
62
|
-
window.__REACT_DEVTOOLS_PORT__ != null
|
|
63
|
-
? window.__REACT_DEVTOOLS_PORT__
|
|
64
|
-
: 8097;
|
|
65
|
-
|
|
66
|
-
const WebSocket = require('react-native/Libraries/WebSocket/WebSocket');
|
|
67
|
-
ws = new WebSocket('ws://' + host + ':' + port);
|
|
68
|
-
ws.addEventListener('close', event => {
|
|
69
|
-
isWebSocketOpen = false;
|
|
70
|
-
});
|
|
71
|
-
ws.addEventListener('open', event => {
|
|
72
|
-
isWebSocketOpen = true;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const ReactNativeStyleAttributes = require('react-native/Libraries/Components/View/ReactNativeStyleAttributes');
|
|
76
|
-
const devToolsSettingsManager = require('react-native/Libraries/DevToolsSettings/DevToolsSettingsManager');
|
|
77
|
-
|
|
78
|
-
reactDevTools.connectToDevTools({
|
|
79
|
-
isAppActive,
|
|
80
|
-
resolveRNStyle: require('react-native/Libraries/StyleSheet/flattenStyle'),
|
|
81
|
-
nativeStyleEditorValidAttributes: Object.keys(
|
|
82
|
-
ReactNativeStyleAttributes,
|
|
83
|
-
),
|
|
84
|
-
websocket: ws,
|
|
85
|
-
devToolsSettingsManager,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter');
|
|
91
|
-
RCTNativeAppEventEmitter.addListener('RCTDevMenuShown', connectToDevTools);
|
|
92
|
-
connectToDevTools(); // Try connecting once on load
|
|
93
|
-
}
|
|
@@ -1,78 +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
|
-
import NativeI18nManager from 'react-native/Libraries/ReactNative/NativeI18nManager';
|
|
12
|
-
|
|
13
|
-
const i18nConstants: {|
|
|
14
|
-
doLeftAndRightSwapInRTL: boolean,
|
|
15
|
-
isRTL: boolean,
|
|
16
|
-
localeIdentifier?: ?string,
|
|
17
|
-
|} = getI18nManagerConstants();
|
|
18
|
-
|
|
19
|
-
function getI18nManagerConstants() {
|
|
20
|
-
if (NativeI18nManager) {
|
|
21
|
-
const {isRTL, doLeftAndRightSwapInRTL, localeIdentifier} =
|
|
22
|
-
NativeI18nManager.getConstants();
|
|
23
|
-
return {isRTL, doLeftAndRightSwapInRTL, localeIdentifier};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
isRTL: false,
|
|
28
|
-
doLeftAndRightSwapInRTL: true,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = {
|
|
33
|
-
getConstants: (): {|
|
|
34
|
-
doLeftAndRightSwapInRTL: boolean,
|
|
35
|
-
isRTL: boolean,
|
|
36
|
-
localeIdentifier: ?string,
|
|
37
|
-
|} => {
|
|
38
|
-
// RNOH patch
|
|
39
|
-
// return i18nConstants;
|
|
40
|
-
return Platform.OS === "harmony" ? getI18nManagerConstants() : i18nConstants;
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
allowRTL: (shouldAllow: boolean) => {
|
|
44
|
-
if (!NativeI18nManager) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
NativeI18nManager.allowRTL(shouldAllow);
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
forceRTL: (shouldForce: boolean) => {
|
|
52
|
-
if (!NativeI18nManager) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
NativeI18nManager.forceRTL(shouldForce);
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
swapLeftAndRightInRTL: (flipStyles: boolean) => {
|
|
60
|
-
if (!NativeI18nManager) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
NativeI18nManager.swapLeftAndRightInRTL(flipStyles);
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
// RNOH patch
|
|
68
|
-
get isRTL() {
|
|
69
|
-
return Platform.OS === "harmony" ? getI18nManagerConstants().isRTL : i18nConstants.isRTL;
|
|
70
|
-
},
|
|
71
|
-
// isRTL: i18nConstants.isRTL,
|
|
72
|
-
|
|
73
|
-
// RNOH patch
|
|
74
|
-
get doLeftAndRightSwapInRTL() {
|
|
75
|
-
return Platform.OS === "harmony" ? getI18nManagerConstants().doLeftAndRightSwapInRTL : i18nConstants.doLeftAndRightSwapInRTL;
|
|
76
|
-
},
|
|
77
|
-
// doLeftAndRightSwapInRTL: i18nConstants.doLeftAndRightSwapInRTL,
|
|
78
|
-
};
|
|
@@ -1,210 +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
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// RNOH patch: imports
|
|
12
|
-
import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
|
|
13
|
-
import type {Spec} from 'react-native/Libraries/ReactNative/NativeUIManager';
|
|
14
|
-
|
|
15
|
-
import {getFabricUIManager} from 'react-native/Libraries/ReactNative/FabricUIManager';
|
|
16
|
-
import nullthrows from 'nullthrows';
|
|
17
|
-
|
|
18
|
-
export interface UIManagerJSInterface extends Spec {
|
|
19
|
-
+getViewManagerConfig: (viewManagerName: string) => Object;
|
|
20
|
-
+hasViewManagerConfig: (viewManagerName: string) => boolean;
|
|
21
|
-
+createView: (
|
|
22
|
-
reactTag: ?number,
|
|
23
|
-
viewName: string,
|
|
24
|
-
rootTag: RootTag,
|
|
25
|
-
props: Object,
|
|
26
|
-
) => void;
|
|
27
|
-
+updateView: (reactTag: number, viewName: string, props: Object) => void;
|
|
28
|
-
+manageChildren: (
|
|
29
|
-
containerTag: ?number,
|
|
30
|
-
moveFromIndices: Array<number>,
|
|
31
|
-
moveToIndices: Array<number>,
|
|
32
|
-
addChildReactTags: Array<number>,
|
|
33
|
-
addAtIndices: Array<number>,
|
|
34
|
-
removeAtIndices: Array<number>,
|
|
35
|
-
) => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isFabricReactTag(reactTag: number): boolean {
|
|
39
|
-
// React reserves even numbers for Fabric.
|
|
40
|
-
return reactTag % 2 === 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// RNOH patch: always export BridgelessUIManager properties
|
|
44
|
-
const BridgelessUIManager: UIManagerJSInterface = require('react-native/Libraries/ReactNative/BridgelessUIManager')
|
|
45
|
-
const PaperUIManager: UIManagerJSInterface =
|
|
46
|
-
global.RN$Bridgeless === true
|
|
47
|
-
? {}
|
|
48
|
-
: require('react-native/Libraries/ReactNative/PaperUIManager');
|
|
49
|
-
|
|
50
|
-
// $FlowFixMe[cannot-spread-interface]
|
|
51
|
-
const UIManager = {
|
|
52
|
-
...BridgelessUIManager,
|
|
53
|
-
...PaperUIManager,
|
|
54
|
-
measure(
|
|
55
|
-
reactTag: number,
|
|
56
|
-
callback: (
|
|
57
|
-
left: number,
|
|
58
|
-
top: number,
|
|
59
|
-
width: number,
|
|
60
|
-
height: number,
|
|
61
|
-
pageX: number,
|
|
62
|
-
pageY: number,
|
|
63
|
-
) => void,
|
|
64
|
-
): void {
|
|
65
|
-
if (isFabricReactTag(reactTag)) {
|
|
66
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
67
|
-
const shadowNode =
|
|
68
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
69
|
-
if (shadowNode) {
|
|
70
|
-
FabricUIManager.measure(shadowNode, callback);
|
|
71
|
-
} else {
|
|
72
|
-
console.warn(`measure cannot find view with tag #${reactTag}`);
|
|
73
|
-
// $FlowFixMe[incompatible-call]
|
|
74
|
-
callback();
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
// Paper
|
|
78
|
-
UIManagerImpl.measure(reactTag, callback);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
measureInWindow(
|
|
83
|
-
reactTag: number,
|
|
84
|
-
callback: (
|
|
85
|
-
left: number,
|
|
86
|
-
top: number,
|
|
87
|
-
width: number,
|
|
88
|
-
height: number,
|
|
89
|
-
) => void,
|
|
90
|
-
): void {
|
|
91
|
-
if (isFabricReactTag(reactTag)) {
|
|
92
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
93
|
-
const shadowNode =
|
|
94
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
95
|
-
if (shadowNode) {
|
|
96
|
-
FabricUIManager.measureInWindow(shadowNode, callback);
|
|
97
|
-
} else {
|
|
98
|
-
console.warn(`measure cannot find view with tag #${reactTag}`);
|
|
99
|
-
// $FlowFixMe[incompatible-call]
|
|
100
|
-
callback();
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
// Paper
|
|
104
|
-
UIManagerImpl.measureInWindow(reactTag, callback);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
measureLayout(
|
|
109
|
-
reactTag: number,
|
|
110
|
-
ancestorReactTag: number,
|
|
111
|
-
errorCallback: (error: Object) => void,
|
|
112
|
-
callback: (
|
|
113
|
-
left: number,
|
|
114
|
-
top: number,
|
|
115
|
-
width: number,
|
|
116
|
-
height: number,
|
|
117
|
-
) => void,
|
|
118
|
-
): void {
|
|
119
|
-
if (isFabricReactTag(reactTag)) {
|
|
120
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
121
|
-
const shadowNode =
|
|
122
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
123
|
-
const ancestorShadowNode =
|
|
124
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(ancestorReactTag);
|
|
125
|
-
|
|
126
|
-
if (!shadowNode || !ancestorShadowNode) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
FabricUIManager.measureLayout(
|
|
131
|
-
shadowNode,
|
|
132
|
-
ancestorShadowNode,
|
|
133
|
-
errorCallback,
|
|
134
|
-
callback,
|
|
135
|
-
);
|
|
136
|
-
} else {
|
|
137
|
-
// Paper
|
|
138
|
-
UIManagerImpl.measureLayout(
|
|
139
|
-
reactTag,
|
|
140
|
-
ancestorReactTag,
|
|
141
|
-
errorCallback,
|
|
142
|
-
callback,
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
measureLayoutRelativeToParent(
|
|
148
|
-
reactTag: number,
|
|
149
|
-
errorCallback: (error: Object) => void,
|
|
150
|
-
callback: (
|
|
151
|
-
left: number,
|
|
152
|
-
top: number,
|
|
153
|
-
width: number,
|
|
154
|
-
height: number,
|
|
155
|
-
) => void,
|
|
156
|
-
): void {
|
|
157
|
-
if (isFabricReactTag(reactTag)) {
|
|
158
|
-
console.warn(
|
|
159
|
-
'RCTUIManager.measureLayoutRelativeToParent method is deprecated and it will not be implemented in newer versions of RN (Fabric) - T47686450',
|
|
160
|
-
);
|
|
161
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
162
|
-
const shadowNode =
|
|
163
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
164
|
-
if (shadowNode) {
|
|
165
|
-
FabricUIManager.measure(
|
|
166
|
-
shadowNode,
|
|
167
|
-
(left, top, width, height, pageX, pageY) => {
|
|
168
|
-
callback(left, top, width, height);
|
|
169
|
-
},
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
// Paper
|
|
174
|
-
UIManagerImpl.measureLayoutRelativeToParent(
|
|
175
|
-
reactTag,
|
|
176
|
-
errorCallback,
|
|
177
|
-
callback,
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
dispatchViewManagerCommand(
|
|
183
|
-
reactTag: number,
|
|
184
|
-
commandName: number | string,
|
|
185
|
-
commandArgs: any[],
|
|
186
|
-
) {
|
|
187
|
-
if (isFabricReactTag(reactTag)) {
|
|
188
|
-
const FabricUIManager = nullthrows(getFabricUIManager());
|
|
189
|
-
const shadowNode =
|
|
190
|
-
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
|
|
191
|
-
if (shadowNode) {
|
|
192
|
-
// Transform the accidental CommandID into a CommandName which is the stringified number.
|
|
193
|
-
// The interop layer knows how to convert this number into the right method name.
|
|
194
|
-
// Stringify a string is a no-op, so it's safe.
|
|
195
|
-
commandName = `${commandName}`;
|
|
196
|
-
FabricUIManager.dispatchCommand(shadowNode, commandName, commandArgs);
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
UIManagerImpl.dispatchViewManagerCommand(
|
|
200
|
-
reactTag,
|
|
201
|
-
// We have some legacy components that are actually already using strings. ¯\_(ツ)_/¯
|
|
202
|
-
// $FlowFixMe[incompatible-call]
|
|
203
|
-
commandName,
|
|
204
|
-
commandArgs,
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
module.exports = UIManager;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const Settings = {
|
|
2
|
-
get(key: string): mixed {
|
|
3
|
-
return null;
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
set(settings: Object) {},
|
|
7
|
-
|
|
8
|
-
watchKeys(keys: string | Array<string>, callback: Function): number {
|
|
9
|
-
return -1;
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
clearWatch(watchId: number) {},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
module.exports = Settings;
|