react-native-macos/Libraries/Linking/NativeIntentAndroid.js

32 строки
869 B
JavaScript
Исходник Обычный вид История

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
'use strict';
import type {TurboModule} from '../TurboModule/RCTExport';
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
+getInitialURL: () => Promise<string>;
+canOpenURL: (url: string) => Promise<boolean>;
+openURL: (url: string) => Promise<void>;
+openSettings: () => Promise<void>;
+sendIntent: (
action: string,
extras: ?Array<{
key: string,
value: string | number | boolean, // TODO(T67672788): Union types are not type safe
...
}>,
) => Promise<void>;
}
Fix NativeLinking split Summary: In D24324247 (https://github.com/facebook/react-native/commit/56c363e39af6488904cbfd2046314c45babeb0f4), I split NativeLinking into NativeLinkingManager and NativeIntentAndroid. There was this line in NativeLinking.js, that I didn't migrate correctly: ``` export default ((Platform.OS === 'android' ? TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid') : TurboModuleRegistry.getEnforcing<Spec>('LinkingManager')): Spec); ``` I separated this conditional statement into two others: ``` export default TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid'); export default TurboModuleRegistry.getEnforcing<Spec>('LinkingManager'); ``` The problem here is that now on iOS, we're hard requiring IntentAndroid, and on Android, we're hard requiring LinkingManager. Understandably, this started throwing errors in our e2e infra. This diff fixes this problem by: 1. Changing the relevant `getEnforcing` calls into `get` calls. 2. Wrapping all usages of NativeIntentAndroid, and NativeLinkingManager, which are already guarded by `Platform.OS` checks, by a nullthrows. This should satisfy flow. **Note:** NativeIntentAndroid is only used on Android, where it must be available. Similarly, NativeLinkingManager is only used on iOS, where it must be available. Changelog: [Internal] build-break overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: fbandroid_sheriff Differential Revision: D24338558 fbshipit-source-id: b0d22cba77e67837834269deaa317dc73d2457dc
2020-10-15 21:46:33 +03:00
export default (TurboModuleRegistry.get<Spec>('IntentAndroid'): ?Spec);