UNPKG

native-fn

Version:
107 lines (99 loc) 3.24 kB
declare interface NativePlugin<Key extends string, Module, Constants extends Record<string, any> = Record<string, any>, Errors extends Record<string, ErrorConstructor> = Record<string, ErrorConstructor>> { installed: boolean; name: Key; module: Module; Constants: Constants; Errors: Errors; } declare enum AppOpenState { Scheme = 0, Universal = 1, Intent = 2, Fallback = 3, Store = 4 } declare enum MessengerType { Telephone = "telephone", Message = "message", Mail = "mail" } declare enum OS { Unknown = "Unknown", Android = "Android", iOS = "iOS", Windows = "Windows", MacOS = "MacOS" } declare interface AppInfo { scheme?: URLCandidate; fallback?: URLCandidateOrFallback; timeout?: number; allowAppStore?: boolean; allowWebStore?: boolean; } declare interface AndroidAppInfo extends AppInfo { packageName?: string; intent?: URLCandidate; } declare interface IOSAppInfo extends MacOSAppInfo { universal?: URLCandidate; } declare interface WindowsAppInfo extends AppInfo { productId?: string; } declare interface MacOSAppInfo extends AppInfo { bundleId?: string; trackId?: string; } declare interface StoreInfo { appStore?: string; webStore?: string; } declare interface AppOpenOptions { [OS.Android]?: AndroidAppInfo; ['android']?: AndroidAppInfo; [OS.iOS]?: IOSAppInfo; ['ios']?: IOSAppInfo; [OS.Windows]?: WindowsAppInfo; ['windows']?: WindowsAppInfo; [OS.MacOS]?: MacOSAppInfo; ['mac']?: MacOSAppInfo; } declare type URLCandidate = URL | string; declare type URLCandidateOrFallback = URLCandidate | (() => any); declare type URLStringOrFallback = string | (() => any); declare type Stringifiable = string | number | boolean | HTMLElement | null | undefined; declare type StringifiableSequence = Stringifiable[] | NodeList | NodeListOf<Node> | HTMLCollectionBase; declare type MessengerOpenOptions = { to?: Stringifiable | StringifiableSequence; cc?: Stringifiable | StringifiableSequence; bcc?: Stringifiable | StringifiableSequence; subject?: Stringifiable; body?: Stringifiable; } | HTMLFormElement | FormData; declare type Messenger = Record<MessengerType, (options: MessengerOpenOptions) => Promise<void>>; declare interface AppInstance { open(options: AppOpenOptions): Promise<AppOpenState>; messenger: Messenger; } declare const URLOpenError: ErrorConstructor; declare module 'native-fn' { interface NativePlugins { App: AppInstance; } interface NativeConstants { AppOpenState: typeof AppOpenState; Messengers: typeof MessengerType; } interface NativeErrors { URLOpenError: typeof URLOpenError; } } declare const NativeAppPlugin: NativePlugin<'App', AppInstance, { AppOpenState: typeof AppOpenState; Messengers: typeof MessengerType; }, { URLOpenError: typeof URLOpenError; }>; export { NativeAppPlugin as default }; export type { AndroidAppInfo, AppInfo, AppInstance, AppOpenOptions, IOSAppInfo, MacOSAppInfo, Messenger, MessengerOpenOptions, StoreInfo, Stringifiable, StringifiableSequence, URLCandidate, URLCandidateOrFallback, URLStringOrFallback, WindowsAppInfo };