not-react-native-macos 0.87.1-rc.2 → 0.87.1-rc.3
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.
|
@@ -1,23 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
// [macOS] macOS
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
11
|
+
// [macOS] The macOS implementation of Platform.
|
|
12
|
+
//
|
|
13
|
+
// `PlatformTypes.js` upstream already declares `'macos'` in `PlatformOSType`
|
|
14
|
+
// and a `MacOSPlatform` shape; only the module was missing, so `Platform.OS`
|
|
15
|
+
// came out as `'ios'` and every `Platform.select({macos: ...})` in the
|
|
16
|
+
// ecosystem silently took the iOS branch.
|
|
17
|
+
//
|
|
18
|
+
// The native constants come from the same `PlatformConstants` turbo module iOS
|
|
19
|
+
// uses -- the fork builds it for macOS and `RCTConstants.m` reports
|
|
20
|
+
// `RCTPlatformName` as `"macos"`. There is no interface idiom on macOS, so
|
|
21
|
+
// `isTV` and `isVision` are constants rather than reads. macOS]
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
// from 'react-native' with platform-specific extensions. It can be deleted
|
|
19
|
-
// once we remove the "./*" mapping from package.json "exports".
|
|
23
|
+
import type {PlatformSelectSpec, PlatformType} from './PlatformTypes';
|
|
20
24
|
|
|
21
|
-
import
|
|
25
|
+
import NativePlatformConstantsIOS from './NativePlatformConstantsIOS';
|
|
26
|
+
|
|
27
|
+
const Platform: PlatformType = {
|
|
28
|
+
__constants: null,
|
|
29
|
+
OS: 'macos',
|
|
30
|
+
// $FlowFixMe[unsafe-getters-setters]
|
|
31
|
+
get Version(): string {
|
|
32
|
+
// $FlowFixMe[object-this-reference]
|
|
33
|
+
return this.constants.osVersion;
|
|
34
|
+
},
|
|
35
|
+
// $FlowFixMe[unsafe-getters-setters]
|
|
36
|
+
get constants(): {
|
|
37
|
+
isTesting: boolean,
|
|
38
|
+
osVersion: string,
|
|
39
|
+
reactNativeVersion: {
|
|
40
|
+
major: number,
|
|
41
|
+
minor: number,
|
|
42
|
+
patch: number,
|
|
43
|
+
prerelease: ?number,
|
|
44
|
+
},
|
|
45
|
+
systemName: string,
|
|
46
|
+
} {
|
|
47
|
+
// $FlowFixMe[object-this-reference]
|
|
48
|
+
if (this.__constants == null) {
|
|
49
|
+
// $FlowFixMe[object-this-reference]
|
|
50
|
+
this.__constants = NativePlatformConstantsIOS.getConstants();
|
|
51
|
+
}
|
|
52
|
+
// $FlowFixMe[object-this-reference]
|
|
53
|
+
return this.__constants;
|
|
54
|
+
},
|
|
55
|
+
// $FlowFixMe[unsafe-getters-setters]
|
|
56
|
+
get isTV(): boolean {
|
|
57
|
+
return false;
|
|
58
|
+
},
|
|
59
|
+
// $FlowFixMe[unsafe-getters-setters]
|
|
60
|
+
get isVision(): boolean {
|
|
61
|
+
return false;
|
|
62
|
+
},
|
|
63
|
+
// $FlowFixMe[unsafe-getters-setters]
|
|
64
|
+
get isTesting(): boolean {
|
|
65
|
+
if (__DEV__) {
|
|
66
|
+
// $FlowFixMe[object-this-reference]
|
|
67
|
+
return this.constants.isTesting;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
},
|
|
71
|
+
// $FlowFixMe[unsafe-getters-setters]
|
|
72
|
+
get isDisableAnimations(): boolean {
|
|
73
|
+
// $FlowFixMe[object-this-reference]
|
|
74
|
+
return this.constants.isDisableAnimations ?? this.isTesting;
|
|
75
|
+
},
|
|
76
|
+
// `macos` first, then `ios`, then `native`, then `default`. The iOS step
|
|
77
|
+
// matters: almost every `Platform.select` in the ecosystem predates macOS and
|
|
78
|
+
// only offers an `ios` branch, which is the right one to take here.
|
|
79
|
+
select: <T>(spec: PlatformSelectSpec<T>): T =>
|
|
80
|
+
// $FlowFixMe[incompatible-type]
|
|
81
|
+
'macos' in spec
|
|
82
|
+
? spec.macos
|
|
83
|
+
: 'ios' in spec
|
|
84
|
+
? spec.ios
|
|
85
|
+
: 'native' in spec
|
|
86
|
+
? spec.native
|
|
87
|
+
: spec.default,
|
|
88
|
+
};
|
|
22
89
|
|
|
23
90
|
export default Platform;
|