@react-native-oh/react-native-harmony 0.72.23-3 → 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.
Files changed (44) hide show
  1. package/Libraries/Alert/Alert.harmony.js +71 -71
  2. package/Libraries/Alert/AlertManager.ts +35 -35
  3. package/Libraries/Animated/NativeAnimatedHelper.harmony.js +601 -601
  4. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +445 -426
  5. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.harmony.js +30 -0
  6. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.harmony.js +26 -0
  7. package/Libraries/Components/Button/Button.harmony.js +450 -450
  8. package/Libraries/Components/Image/Image.flow.harmony.js +53 -0
  9. package/Libraries/Components/Image/Image.harmony.js +299 -0
  10. package/Libraries/Components/Image/NativeImageLoaderHarmony.js +38 -0
  11. package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +210 -210
  12. package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +76 -75
  13. package/Libraries/Components/ScrollView/ScrollView.harmony.js +1951 -1951
  14. package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +24 -24
  15. package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +71 -68
  16. package/Libraries/Components/StatusBar/StatusBar.harmony.js +447 -447
  17. package/Libraries/Components/TextInput/TextInput.harmony.js +1707 -1707
  18. package/Libraries/Components/TextInput/TextInputState.harmony.js +220 -220
  19. package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +396 -396
  20. package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +364 -364
  21. package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +227 -227
  22. package/Libraries/Components/View/View.harmony.js +149 -149
  23. package/Libraries/Core/setUpReactDevTools.harmony.js +93 -93
  24. package/Libraries/Image/AssetSourceResolver.harmony.ts +78 -78
  25. package/Libraries/NativeComponent/BaseViewConfig.harmony.js +337 -337
  26. package/Libraries/ReactNative/UIManager.harmony.js +210 -210
  27. package/Libraries/Settings/Settings.harmony.js +15 -15
  28. package/Libraries/Share/Share.harmony.js +174 -174
  29. package/Libraries/StyleSheet/NativePlatformColor.ts +8 -8
  30. package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +14 -14
  31. package/Libraries/Utilities/BackHandler.harmony.js +109 -109
  32. package/Libraries/Utilities/{NativePlatformConstantsHarmony.ts → NativePlatformConstants.harmony.ts} +8 -8
  33. package/Libraries/Utilities/Platform.d.ts +117 -117
  34. package/Libraries/Utilities/Platform.harmony.ts +33 -33
  35. package/Libraries/Utilities/createPerformanceLogger.harmony.js +328 -328
  36. package/Libraries/Vibration/Vibration.harmony.js +88 -88
  37. package/index.js +212 -212
  38. package/jest.config.js +5 -5
  39. package/metro.config.js +348 -348
  40. package/package.json +57 -57
  41. package/react-native.config.js +10 -10
  42. package/react_native_openharmony.har +0 -0
  43. package/tsconfig.json +13 -13
  44. package/types/index.d.ts +101 -101
@@ -0,0 +1,53 @@
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
+ import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
12
+ import type {ResolvedAssetSource} from 'react-native/Libraries/Image/AssetSourceResolver';
13
+ import type {ImageProps as ImagePropsType} from 'react-native/Libraries/Image/ImageProps';
14
+
15
+ import ImageViewNativeComponent from 'react-native/Libraries/Image/ImageViewNativeComponent';
16
+ import * as React from 'react';
17
+
18
+ type ImageComponentStaticsHarmony = $ReadOnly<{|
19
+ getSize: (
20
+ uri: string,
21
+ success: (width: number, height: number) => void,
22
+ failure?: (error: any) => void,
23
+ ) => void,
24
+
25
+ getSizeWithHeaders(
26
+ uri: string,
27
+ headers: {[string]: string, ...},
28
+ success: (width: number, height: number) => void,
29
+ failure?: (error: any) => void,
30
+ ): any,
31
+
32
+ prefetch(url: string, callback: ?(requestId: number) => void): any,
33
+
34
+ prefetchWithMetadata(
35
+ url: string,
36
+ queryRootName: string,
37
+ rootTag?: ?RootTag,
38
+ ): any,
39
+
40
+ queryCache(
41
+ urls: Array<string>,
42
+ ): Promise<{[string]: 'memory' | 'disk' | 'disk/memory', ...}>,
43
+
44
+ resolveAssetSource(source: any): ?ResolvedAssetSource,
45
+
46
+ abortPrefetch(requestId: number): void,
47
+ |}>;
48
+
49
+ export type ImageHarmony = React.AbstractComponent<
50
+ ImagePropsType,
51
+ React.ElementRef<typeof ImageViewNativeComponent>,
52
+ > &
53
+ ImageComponentStaticsHarmony;
@@ -0,0 +1,299 @@
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
+ import type {ImageStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
12
+ import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
13
+ import type {ImageHarmony} from './Image.flow.harmony';
14
+ import type {ImageProps as ImagePropsType} from 'react-native/Libraries/Image/ImageProps';
15
+
16
+ import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';
17
+ import StyleSheet from 'react-native/Libraries/StyleSheet/StyleSheet';
18
+ import ImageAnalyticsTagContext from 'react-native/Libraries/Image/ImageAnalyticsTagContext';
19
+ import ImageInjection from 'react-native/Libraries/Image/ImageInjection';
20
+ import {getImageSourcesFromImageProps} from 'react-native/Libraries/Image/ImageSourceUtils';
21
+ import {convertObjectFitToResizeMode} from 'react-native/Libraries/Image/ImageUtils';
22
+ import ImageViewNativeComponent from 'react-native/Libraries/Image/ImageViewNativeComponent';
23
+ import NativeImageLoaderHarmony from './NativeImageLoaderHarmony';
24
+ import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
25
+ import * as React from 'react';
26
+
27
+ let _requestId = 1;
28
+ function generateRequestId() {
29
+ return _requestId++;
30
+ }
31
+
32
+ function getSize(
33
+ uri: string,
34
+ success: (width: number, height: number) => void,
35
+ failure?: (error: any) => void,
36
+ ) {
37
+ NativeImageLoaderHarmony.getSize(uri)
38
+ .then(([width, height]) => success(width, height))
39
+ .catch(
40
+ failure ||
41
+ function () {
42
+ console.warn('Failed to get size for image ' + uri);
43
+ },
44
+ );
45
+ }
46
+
47
+ function getSizeWithHeaders(
48
+ uri: string,
49
+ headers: {[string]: string, ...},
50
+ success: (width: number, height: number) => void,
51
+ failure?: (error: any) => void,
52
+ ): any {
53
+ return NativeImageLoaderHarmony.getSizeWithHeaders(uri, headers)
54
+ .then(function (sizes) {
55
+ success(sizes.width, sizes.height);
56
+ })
57
+ .catch(
58
+ failure ||
59
+ function () {
60
+ console.warn('Failed to get size for image: ' + uri);
61
+ },
62
+ );
63
+ }
64
+
65
+ function prefetchWithMetadata(
66
+ url: string,
67
+ queryRootName: string,
68
+ rootTag?: ?RootTag,
69
+ ): any {
70
+ if (NativeImageLoaderHarmony.prefetchImageWithMetadata) {
71
+ // number params like rootTag cannot be nullable before TurboModules is available
72
+ return NativeImageLoaderHarmony.prefetchImageWithMetadata(
73
+ url,
74
+ queryRootName,
75
+ // NOTE: RootTag type
76
+ // $FlowFixMe[incompatible-call] RootTag: number is incompatible with RootTag
77
+ rootTag ? rootTag : 0,
78
+ );
79
+ } else {
80
+ const requestId = generateRequestId();
81
+ return NativeImageLoaderHarmony.prefetchImage(url, requestId);
82
+ }
83
+ }
84
+
85
+ function prefetch(url: string, callback: ?(requestId: number) => void): any {
86
+ const requestId = generateRequestId();
87
+ callback && callback(requestId);
88
+ return NativeImageLoaderHarmony.prefetchImage(url, requestId);
89
+ }
90
+
91
+ function abortPrefetch(requestId: number): void {
92
+ NativeImageLoaderHarmony.abortPrefetch(requestId);
93
+ }
94
+
95
+ async function queryCache(
96
+ urls: Array<string>,
97
+ ): Promise<{[string]: 'memory' | 'disk' | 'disk/memory', ...}> {
98
+ return await NativeImageLoaderHarmony.queryCache(urls);
99
+ }
100
+
101
+ export type ImageComponentStatics = $ReadOnly<{|
102
+ getSize: typeof getSize,
103
+ getSizeWithHeaders: typeof getSizeWithHeaders,
104
+ prefetch: typeof prefetch,
105
+ prefetchWithMetadata: typeof prefetchWithMetadata,
106
+ queryCache: typeof queryCache,
107
+ resolveAssetSource: typeof resolveAssetSource,
108
+ abortPrefetch: typeof abortPrefetch,
109
+ |}>;
110
+
111
+ /**
112
+ * A React component for displaying different types of images,
113
+ * including network images, static resources, temporary local images, and
114
+ * images from local disk, such as the camera roll.
115
+ *
116
+ * See https://reactnative.dev/docs/image
117
+ */
118
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
119
+ * LTI update could not be added via codemod */
120
+ const BaseImage = (props: ImagePropsType, forwardedRef) => {
121
+ const source = getImageSourcesFromImageProps(props) || {
122
+ uri: undefined,
123
+ width: undefined,
124
+ height: undefined,
125
+ };
126
+
127
+ let sources;
128
+ let style: ImageStyleProp;
129
+ if (Array.isArray(source)) {
130
+ // $FlowFixMe[underconstrained-implicit-instantiation]
131
+ style = flattenStyle([styles.base, props.style]) || {};
132
+ sources = source;
133
+ } else {
134
+ // $FlowFixMe[incompatible-type]
135
+ const {width = props.width, height = props.height, uri} = source;
136
+ // $FlowFixMe[underconstrained-implicit-instantiation]
137
+ style = flattenStyle([{width, height}, styles.base, props.style]) || {};
138
+ sources = [source];
139
+
140
+ if (uri === '') {
141
+ console.warn('source.uri should not be an empty string');
142
+ }
143
+ }
144
+
145
+ const objectFit =
146
+ // $FlowFixMe[prop-missing]
147
+ style && style.objectFit
148
+ ? convertObjectFitToResizeMode(style.objectFit)
149
+ : null;
150
+ const resizeMode =
151
+ // $FlowFixMe[prop-missing]
152
+ objectFit || props.resizeMode || (style && style.resizeMode) || 'cover';
153
+ // $FlowFixMe[prop-missing]
154
+ const tintColor = props.tintColor || style.tintColor;
155
+
156
+ if (props.children != null) {
157
+ throw new Error(
158
+ 'The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.',
159
+ );
160
+ }
161
+ const {
162
+ 'aria-busy': ariaBusy,
163
+ 'aria-checked': ariaChecked,
164
+ 'aria-disabled': ariaDisabled,
165
+ 'aria-expanded': ariaExpanded,
166
+ 'aria-selected': ariaSelected,
167
+ height,
168
+ src,
169
+ width,
170
+ ...restProps
171
+ } = props;
172
+
173
+ const _accessibilityState = {
174
+ busy: ariaBusy ?? props.accessibilityState?.busy,
175
+ checked: ariaChecked ?? props.accessibilityState?.checked,
176
+ disabled: ariaDisabled ?? props.accessibilityState?.disabled,
177
+ expanded: ariaExpanded ?? props.accessibilityState?.expanded,
178
+ selected: ariaSelected ?? props.accessibilityState?.selected,
179
+ };
180
+ const accessibilityLabel = props['aria-label'] ?? props.accessibilityLabel;
181
+
182
+ return (
183
+ <ImageAnalyticsTagContext.Consumer>
184
+ {analyticTag => {
185
+ return (
186
+ <ImageViewNativeComponent
187
+ accessibilityState={_accessibilityState}
188
+ {...restProps}
189
+ accessible={props.alt !== undefined ? true : props.accessible}
190
+ accessibilityLabel={accessibilityLabel ?? props.alt}
191
+ ref={forwardedRef}
192
+ style={style}
193
+ resizeMode={resizeMode}
194
+ tintColor={tintColor}
195
+ source={sources}
196
+ internal_analyticTag={analyticTag}
197
+ />
198
+ );
199
+ }}
200
+ </ImageAnalyticsTagContext.Consumer>
201
+ );
202
+ };
203
+
204
+ const ImageForwardRef = React.forwardRef<
205
+ ImagePropsType,
206
+ React.ElementRef<typeof ImageViewNativeComponent>,
207
+ >(BaseImage);
208
+
209
+ let Image = ImageForwardRef;
210
+ if (ImageInjection.unstable_createImageComponent != null) {
211
+ Image = ImageInjection.unstable_createImageComponent(Image);
212
+ }
213
+
214
+ Image.displayName = 'Image';
215
+
216
+ /**
217
+ * Retrieve the width and height (in pixels) of an image prior to displaying it.
218
+ *
219
+ * See https://reactnative.dev/docs/image#getsize
220
+ */
221
+ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment
222
+ * suppresses an error found when Flow v0.89 was deployed. To see the error,
223
+ * delete this comment and run Flow. */
224
+ Image.getSize = getSize;
225
+
226
+ /**
227
+ * Retrieve the width and height (in pixels) of an image prior to displaying it
228
+ * with the ability to provide the headers for the request.
229
+ *
230
+ * See https://reactnative.dev/docs/image#getsizewithheaders
231
+ */
232
+ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment
233
+ * suppresses an error found when Flow v0.89 was deployed. To see the error,
234
+ * delete this comment and run Flow. */
235
+ Image.getSizeWithHeaders = getSizeWithHeaders;
236
+
237
+ /**
238
+ * Prefetches a remote image for later use by downloading it to the disk
239
+ * cache.
240
+ *
241
+ * See https://reactnative.dev/docs/image#prefetch
242
+ */
243
+ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment
244
+ * suppresses an error found when Flow v0.89 was deployed. To see the error,
245
+ * delete this comment and run Flow. */
246
+ Image.prefetch = prefetch;
247
+
248
+ /**
249
+ * Prefetches a remote image for later use by downloading it to the disk
250
+ * cache, and adds metadata for queryRootName and rootTag.
251
+ *
252
+ * See https://reactnative.dev/docs/image#prefetch
253
+ */
254
+ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment
255
+ * suppresses an error found when Flow v0.89 was deployed. To see the error,
256
+ * delete this comment and run Flow. */
257
+ Image.prefetchWithMetadata = prefetchWithMetadata;
258
+
259
+ /**
260
+ * Performs cache interrogation.
261
+ *
262
+ * See https://reactnative.dev/docs/image#querycache
263
+ */
264
+ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment
265
+ * suppresses an error found when Flow v0.89 was deployed. To see the error,
266
+ * delete this comment and run Flow. */
267
+ Image.queryCache = queryCache;
268
+
269
+ /**
270
+ * Resolves an asset reference into an object.
271
+ *
272
+ * See https://reactnative.dev/docs/image#resolveassetsource
273
+ */
274
+ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment
275
+ * suppresses an error found when Flow v0.89 was deployed. To see the error,
276
+ * delete this comment and run Flow. */
277
+ Image.resolveAssetSource = resolveAssetSource;
278
+
279
+ /**
280
+ * Abort prefetch request.
281
+ *
282
+ * See https://reactnative.dev/docs/image#abortprefetch
283
+ */
284
+ // $FlowFixMe[incompatible-use] This property isn't writable but we're actually defining it here for the first time.
285
+ Image.abortPrefetch = abortPrefetch;
286
+
287
+ /**
288
+ * Switch to `deprecated-react-native-prop-types` for compatibility with future
289
+ * releases. This is deprecated and will be removed in the future.
290
+ */
291
+ Image.propTypes = require('deprecated-react-native-prop-types').ImagePropTypes;
292
+
293
+ const styles = StyleSheet.create({
294
+ base: {
295
+ overflow: 'hidden',
296
+ },
297
+ });
298
+
299
+ module.exports = ((Image: any): ImageHarmony);
@@ -0,0 +1,38 @@
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
+ import type {RootTag} from 'react-native/Libraries/TurboModule/RCTExport';
12
+ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
13
+
14
+ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
15
+
16
+ export interface Spec extends TurboModule {
17
+ +getConstants: () => {||};
18
+ // Return [width, height] of image uri
19
+ +getSize: (uri: string) => Promise<$ReadOnlyArray<number>>;
20
+ +getSizeWithHeaders: (
21
+ uri: string,
22
+ headers: Object,
23
+ ) => Promise<{
24
+ width: number,
25
+ height: number,
26
+ ...
27
+ }>;
28
+ +prefetchImage: (uri: string, requestId: number) => Promise<boolean>;
29
+ +prefetchImageWithMetadata?: (
30
+ uri: string,
31
+ queryRootName: string,
32
+ rootTag: RootTag,
33
+ ) => Promise<boolean>;
34
+ +queryCache: (uris: Array<string>) => Promise<Object>;
35
+ +abortPrefetch: (requestId: number) => void;
36
+ }
37
+
38
+ export default (TurboModuleRegistry.getEnforcing<Spec>('ImageLoader'): Spec);