|
1 | | -import { NitroModules } from 'react-native-nitro-modules'; |
2 | | -import type { |
3 | | - InAppBrowserNitro, |
4 | | - InAppBrowserOptions, |
5 | | - InAppBrowserResult, |
6 | | - InAppBrowserAuthResult, |
7 | | -} from './InAppBrowserNitro.nitro'; |
8 | | - |
9 | | -const InAppBrowserNitroHybridObject = |
10 | | - NitroModules.createHybridObject<InAppBrowserNitro>('InAppBrowserNitro'); |
11 | | - |
12 | | -/** |
13 | | - * InAppBrowser - A fast, modern in-app browser for React Native using Nitro modules |
14 | | - * |
15 | | - * Provides access to the system's web browser (Safari on iOS, Chrome Custom Tabs on Android) |
16 | | - * with support for authentication flows, deep linking, and performance optimizations. |
17 | | - */ |
18 | | -export class InAppBrowser { |
19 | | - /** |
20 | | - * Check if the device supports InAppBrowser |
21 | | - * @returns Promise<boolean> - true if supported, false otherwise |
22 | | - */ |
23 | | - static async isAvailable(): Promise<boolean> { |
24 | | - return InAppBrowserNitroHybridObject.isAvailable(); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * Open a URL in the in-app browser |
29 | | - * @param url - The URL to open |
30 | | - * @param options - Browser configuration options |
31 | | - * @returns Promise<InAppBrowserResult> - Result of the browser operation |
32 | | - */ |
33 | | - static async open( |
34 | | - url: string, |
35 | | - options?: InAppBrowserOptions |
36 | | - ): Promise<InAppBrowserResult> { |
37 | | - return InAppBrowserNitroHybridObject.open(url, options); |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * Open a URL for authentication flow (OAuth, etc.) |
42 | | - * @param url - The URL to open for authentication |
43 | | - * @param redirectUrl - The redirect URL scheme to listen for |
44 | | - * @param options - Browser configuration options |
45 | | - * @returns Promise<InAppBrowserAuthResult> - Result of the authentication |
46 | | - */ |
47 | | - static async openAuth( |
48 | | - url: string, |
49 | | - redirectUrl: string, |
50 | | - options?: InAppBrowserOptions |
51 | | - ): Promise<InAppBrowserAuthResult> { |
52 | | - return InAppBrowserNitroHybridObject.openAuth(url, redirectUrl, options); |
53 | | - } |
54 | | - |
55 | | - /** |
56 | | - * Close the currently opened in-app browser |
57 | | - * @returns Promise<void> |
58 | | - */ |
59 | | - static async close(): Promise<void> { |
60 | | - return InAppBrowserNitroHybridObject.close(); |
61 | | - } |
| 1 | +import { InAppBrowser } from './InAppBrowserCore'; |
62 | 2 |
|
63 | | - /** |
64 | | - * Close the currently opened authentication session |
65 | | - * @returns Promise<void> |
66 | | - */ |
67 | | - static async closeAuth(): Promise<void> { |
68 | | - return InAppBrowserNitroHybridObject.closeAuth(); |
69 | | - } |
70 | | -} |
| 3 | +// Export the main class |
| 4 | +export { InAppBrowser } from './InAppBrowserCore'; |
71 | 5 |
|
72 | 6 | // Export types for external use |
73 | 7 | export type { |
|
0 commit comments