export type NativePlatform = "server" | "browser" | "webview" | "ios" | "android" | "expo" | string;
export type NativeTarget = "browser" | "mobile";

export interface NativeAdapter<TOptions = unknown, TResult = unknown> {
  supported?: () => boolean;
  run(options?: TOptions): TResult | Promise<TResult>;
}

export interface NativeCapability<TOptions = unknown, TResult = unknown> {
  browser?: NativeAdapter<TOptions, TResult>;
  mobile?: NativeAdapter<TOptions, TResult>;
}

export interface NativeRunOptions {
  target?: NativeTarget;
}

export interface NativeBrowserRuntime {
  target: NativeTarget;
  isMobile: boolean;
  register(name: string, capability: NativeCapability): void;
  unregister(name: string): void;
  supports(name: string): boolean;
  run<TResult = unknown>(name: string, options?: unknown): Promise<TResult>;
}
