@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,149 +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;
|
|
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 +1,93 @@
|
|
|
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
|
+
/**
|
|
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 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAssetDestRelativePath,
|
|
3
|
-
Asset,
|
|
4
|
-
} from '@react-native-oh/react-native-harmony-cli/src/assetResolver';
|
|
5
|
-
import {
|
|
6
|
-
getBasePath,
|
|
7
|
-
} from '@react-native/assets-registry/path-support';
|
|
8
|
-
import { Platform } from 'react-native';
|
|
9
|
-
|
|
10
|
-
type ResolvedAssetSource = {
|
|
11
|
-
readonly __packager_asset: boolean;
|
|
12
|
-
readonly width?: number;
|
|
13
|
-
readonly height?: number;
|
|
14
|
-
readonly uri: string;
|
|
15
|
-
readonly scale: number;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function getAssetPath(asset: Asset): string {
|
|
19
|
-
const assetDir = getBasePath(asset);
|
|
20
|
-
return assetDir + '/' + asset.name + '.' + asset.type;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class AssetSourceResolver {
|
|
24
|
-
constructor(
|
|
25
|
-
private serverUrl: string | undefined,
|
|
26
|
-
private jsbundleUrl: string | undefined,
|
|
27
|
-
private asset: Asset
|
|
28
|
-
) {}
|
|
29
|
-
|
|
30
|
-
isLoadedFromServer(): boolean {
|
|
31
|
-
return !!this.serverUrl;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public defaultAsset(): ResolvedAssetSource {
|
|
35
|
-
if (this.isLoadedFromServer()) {
|
|
36
|
-
return this.assetServerURL();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
__packager_asset: this.asset.__packager_asset,
|
|
41
|
-
uri: `asset://${getAssetDestRelativePath(this.asset)}`,
|
|
42
|
-
scale: 1,
|
|
43
|
-
width: this.asset.width,
|
|
44
|
-
height: this.asset.height,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Returns an absolute URL which can be used to fetch the asset
|
|
50
|
-
* from the devserver
|
|
51
|
-
*/
|
|
52
|
-
assetServerURL(): ResolvedAssetSource {
|
|
53
|
-
if (!this.serverUrl) {
|
|
54
|
-
throw new Error('need server to load from');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return this.fromSource(
|
|
58
|
-
this.serverUrl +
|
|
59
|
-
getAssetPath(this.asset) +
|
|
60
|
-
'?platform=' +
|
|
61
|
-
Platform.OS +
|
|
62
|
-
'&hash=' +
|
|
63
|
-
this.asset.hash,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
fromSource(source: string): ResolvedAssetSource {
|
|
68
|
-
return {
|
|
69
|
-
__packager_asset: true,
|
|
70
|
-
width: this.asset.width,
|
|
71
|
-
height: this.asset.height,
|
|
72
|
-
uri: source,
|
|
73
|
-
scale: 1,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
module.exports = AssetSourceResolver;
|
|
1
|
+
import {
|
|
2
|
+
getAssetDestRelativePath,
|
|
3
|
+
Asset,
|
|
4
|
+
} from '@react-native-oh/react-native-harmony-cli/src/assetResolver';
|
|
5
|
+
import {
|
|
6
|
+
getBasePath,
|
|
7
|
+
} from '@react-native/assets-registry/path-support';
|
|
8
|
+
import { Platform } from 'react-native';
|
|
9
|
+
|
|
10
|
+
type ResolvedAssetSource = {
|
|
11
|
+
readonly __packager_asset: boolean;
|
|
12
|
+
readonly width?: number;
|
|
13
|
+
readonly height?: number;
|
|
14
|
+
readonly uri: string;
|
|
15
|
+
readonly scale: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function getAssetPath(asset: Asset): string {
|
|
19
|
+
const assetDir = getBasePath(asset);
|
|
20
|
+
return assetDir + '/' + asset.name + '.' + asset.type;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class AssetSourceResolver {
|
|
24
|
+
constructor(
|
|
25
|
+
private serverUrl: string | undefined,
|
|
26
|
+
private jsbundleUrl: string | undefined,
|
|
27
|
+
private asset: Asset
|
|
28
|
+
) {}
|
|
29
|
+
|
|
30
|
+
isLoadedFromServer(): boolean {
|
|
31
|
+
return !!this.serverUrl;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public defaultAsset(): ResolvedAssetSource {
|
|
35
|
+
if (this.isLoadedFromServer()) {
|
|
36
|
+
return this.assetServerURL();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
__packager_asset: this.asset.__packager_asset,
|
|
41
|
+
uri: `asset://${getAssetDestRelativePath(this.asset)}`,
|
|
42
|
+
scale: 1,
|
|
43
|
+
width: this.asset.width,
|
|
44
|
+
height: this.asset.height,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns an absolute URL which can be used to fetch the asset
|
|
50
|
+
* from the devserver
|
|
51
|
+
*/
|
|
52
|
+
assetServerURL(): ResolvedAssetSource {
|
|
53
|
+
if (!this.serverUrl) {
|
|
54
|
+
throw new Error('need server to load from');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return this.fromSource(
|
|
58
|
+
this.serverUrl +
|
|
59
|
+
getAssetPath(this.asset) +
|
|
60
|
+
'?platform=' +
|
|
61
|
+
Platform.OS +
|
|
62
|
+
'&hash=' +
|
|
63
|
+
this.asset.hash,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fromSource(source: string): ResolvedAssetSource {
|
|
68
|
+
return {
|
|
69
|
+
__packager_asset: true,
|
|
70
|
+
width: this.asset.width,
|
|
71
|
+
height: this.asset.height,
|
|
72
|
+
uri: source,
|
|
73
|
+
scale: 1,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = AssetSourceResolver;
|