@react-native-oh-tpl/react-native-inappbrowser-reborn
Version:
InAppBrowser for React Native
44 lines (35 loc) • 1.81 kB
text/typescript
/*
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
* Use of this source code is governed by a MIT license that can be
* found in the LICENSE file.
*/
import { TurboModuleRegistry, RootTag } from 'react-native';
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
/**
* Codegen restriction: All TypeScript interfaces extending TurboModule must be called 'Spec'.
*/
export type BrowserOptions = {url: string, redirectUrl?:string,dismissButtonStyle?: string, preferredBarTintColor?: string, preferredControlTintColor?: string, animated?: boolean, modalEnabled?: boolean, readerMode?: boolean, enableBarCollapsing?: boolean}
export type BrowserResult = {type: string ,message?:string}
export type AuthSessionResult = {type: string,url?:string}
export type InAppBrowserOptions = {
dismissButtonStyle?: string, preferredBarTintColor?: string, preferredControlTintColor?: string, animated?: boolean, modalEnabled?: boolean, readerMode?: boolean, enableBarCollapsing?: boolean,ephemeralWebSession?:boolean
}
export type InAppBrowserHarmonyOptions = {
dismissButtonStyle?: 'done' | 'close' | 'cancel',
preferredBarTintColor?: string,
preferredControlTintColor?: string,
animated?:boolean,
modalEnabled?:boolean,
readerMode?:boolean,
enableBarCollapsing?:boolean
}
export interface Spec extends TurboModule {
open(options: BrowserOptions): Promise<BrowserResult>;
openAuth(url: string,redirectUrl: string,options?: InAppBrowserOptions): Promise<AuthSessionResult>;
close(): void;
warmup(): Promise<boolean>;
mayLaunchUrl(mostLikelyUrl: string,otherUrls: string[]): void
closeAuth(): void ;
isAvailable(): Promise<boolean>;
}
export default TurboModuleRegistry.get<Spec>('RNInAppBrowser')!;