/** * JS Bridge protocol definitions for Huawei HarmonyOS <-> Web communication. * * Communication flow: * Web -> Native: window.aigensHuawei.postMessage(JSON.stringify(BridgeRequest)) * Native -> Web: window.aigensHuaweiCallback(callbackId, BridgeResponse) (success) * window.aigensHuaweiError(callbackId, errorMessage) (failure) */ export interface CorePlugin { dismiss(options: any): Promise; finish(options: any): Promise; getMember(options: any): Promise<{ member: Member; }>; getDeeplink(options: any): Promise<{ deeplink: Deeplink; }>; isInstalledApp(options: { key: string; }): Promise<{ install: boolean; }>; isDebug(): Promise<{ debug: boolean; }>; isHuawei(): Promise<{ huawei: boolean; }>; openExternalUrl(options: { url: string; }): Promise; /** * @param value : 0 - 1 */ setTextZoom(options: { value: number; }): Promise; /** * Promise: { value: string, type: 'text/plain' } */ readClipboard(): Promise; makeHKFPSPayment(options: FPSPaymentOptions): Promise; /** * Enable or disable native back press handling. * When false, system back (swipe, button) is completely ignored while the WebView is open. * DISMISS still works programmatically. After the WebView is dismissed, * the host app's normal back behavior is automatically restored. * When true (default), back press navigates WebView back, or dismisses if no history. * @param options.enable true or false */ setNativeBackPressEnabled(options: { enable: boolean; }): Promise<{ enabled: boolean; }>; /** * Register a callback invoked when a native back press occurs. * Only effective when NativeBackPressEnabled = true. * If NativeBackPressEnabled = false, a warning is logged to console. * @param callback Called on back press (swipe, button, etc.) */ setNativeBackPressHandler(callback: () => void): void; } export interface FPSPaymentOptions { paymentRequestUrl: string; callbackUrl?: string; typeIdentifier?: string; title?: string; } export interface FPSResultOptions { result: boolean; url?: string; intent?: string; } export interface Member { "memberCode"?: string; "source"?: string; "sessionId"?: string; "deviceId": string; "appScheme"?: string; "universalLink"?: string; "name"?: string; "email"?: string; "phone"?: string; } export interface Deeplink { "addItemId"?: string; "addDiscountCode"?: string; "addOfferId"?: string; "addOrder"?: string; } /** Web -> Native request */ export interface BridgeRequest { /** Unique callback ID for matching response */ id: string; /** Method name to invoke on native side */ method: BridgeMethod; /** Optional parameters for the method */ params?: Record; } /** Native -> Web success response */ export interface BridgeResponse { /** Matches request id */ id: string; /** Result data on success */ result?: any; } /** Native -> Web error response */ export interface BridgeErrorResponse { /** Matches request id */ id: string; /** Error message */ error: string; } /** All supported bridge methods (mirrors CorePlugin + GeolocationPlugin interfaces) */ export declare type BridgeMethod = 'getMember' | 'getDeeplink' | 'isDebug' | 'isHuawei' | 'dismiss' | 'finish' | 'openExternalUrl' | 'isInstalledApp' | 'setTextZoom' | 'readClipboard' | 'makeHKFPSPayment' | 'setNativeBackPressEnabled' | 'setNativeBackPressHandler' | 'getCurrentPosition' | 'watchPosition' | 'clearWatch' | 'checkGeolocationPermissions' | 'requestGeolocationPermissions' | 'getId' | 'getInfo' | 'getBatteryInfo' | 'getLanguageCode' | 'preferencesConfigure' | 'preferencesGet' | 'preferencesSet' | 'preferencesRemove' | 'preferencesClear' | 'preferencesKeys' | 'shareCanShare' | 'shareShare' | 'cameraGetPhoto' | 'cameraPickImages' | 'checkCameraPermissions' | 'requestCameraPermissions'; /** Object injected into WebView by HarmonyOS native via javaScriptProxy */ export interface AigensHuaweiBridge { /** * Send a message to native side. * @param json JSON-stringified BridgeRequest */ postMessage(json: string): void; } declare global { interface Window { aigensHuawei?: AigensHuaweiBridge; aigensHuaweiCallback?: (id: string, result: any) => void; aigensHuaweiError?: (id: string, error: string) => void; isHuaWei?: boolean; aigensGeolocationWatch?: (id: string, position: Position) => void; aigensGeolocationWatchError?: (id: string, error: string) => void; aigensNativeBackPress?: () => void; } } export declare type CallbackID = string; export interface PermissionStatus { location: string; coarseLocation: string; } export declare type GeolocationPermissionType = 'location' | 'coarseLocation'; export interface GeolocationPluginPermissions { permissions: GeolocationPermissionType[]; } export interface GeolocationPlugin { getCurrentPosition(options?: PositionOptions): Promise; watchPosition(options: PositionOptions, callback: WatchPositionCallback): Promise; clearWatch(options: ClearWatchOptions): Promise; checkPermissions(): Promise; requestPermissions(permissions?: GeolocationPluginPermissions): Promise; } export interface ClearWatchOptions { id: CallbackID; } export interface GeolocationCoords { latitude: number; longitude: number; accuracy: number; altitudeAccuracy: number | null | undefined; altitude: number | null; speed: number | null; heading: number | null; } export interface Position { timestamp: number; coords: GeolocationCoords; } export interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } export declare type WatchPositionCallback = (position: Position | null, err?: any) => void; export declare type OperatingSystem = 'ios' | 'android' | 'windows' | 'mac' | 'harmony' | 'unknown'; export interface DeviceId { uuid: string; } export interface DeviceInfo { name?: string; model: string; platform: 'ios' | 'android' | 'web' | 'harmony'; operatingSystem: OperatingSystem; osVersion: string; manufacturer: string; isVirtual: boolean; memUsed?: number; diskFree?: number; diskTotal?: number; realDiskFree?: number; realDiskTotal?: number; webViewVersion: string; } export interface BatteryInfo { batteryLevel?: number; isCharging?: boolean; } export interface GetLanguageCodeResult { value: string; } export interface DevicePlugin { getId(): Promise; getInfo(): Promise; getBatteryInfo(): Promise; getLanguageCode(): Promise; } export interface ConfigureOptions { /** Preferences group; maps to the native preferences store name. Default: 'CapacitorStorage' */ group?: string; } export interface GetOptions { key: string; } export interface GetResult { /** The stored value, or null if the key was never set / was removed */ value: string | null; } export interface SetOptions { key: string; value: string; } export interface RemoveOptions { key: string; } export interface KeysResult { keys: string[]; } export interface PreferencesPlugin { configure(options: ConfigureOptions): Promise; get(options: GetOptions): Promise; set(options: SetOptions): Promise; remove(options: RemoveOptions): Promise; clear(): Promise; keys(): Promise; } export interface ShareOptions { /** Title for the shared message (email subject when sharing to email) */ title?: string; /** Text to share */ text?: string; /** URL to share (http, https or file:// URL) */ url?: string; /** * Title for the share modal. Not supported on HarmonyOS (the system * share panel has no configurable title) — ignored. */ dialogTitle?: string; } export interface ShareResult { /** Identifier of the app that received the share; always '' on HarmonyOS */ activityType?: string; } export interface CanShareResult { value: boolean; } export interface SharePlugin { canShare(): Promise; share(options: ShareOptions): Promise; } /** * Permission status. The HarmonyOS system pickers need no permissions, * so both fields are always 'granted'. */ export interface CameraPermissionStatus { camera: 'granted'; photos: 'granted'; } /** Where to get the photo from */ export declare type CameraSource = 'PROMPT' | 'CAMERA' | 'PHOTOS'; /** Camera direction (used when source is CAMERA) */ export declare type CameraDirection = 'REAR' | 'FRONT'; /** How the photo data should be returned */ export declare type CameraResultType = 'uri' | 'base64' | 'dataUrl'; export interface ImageOptions { /** JPEG quality 0-100 (applied when returning base64/dataUrl) */ quality?: number; /** * Whether to allow editing. Not supported on HarmonyOS system * pickers — ignored. */ allowEditing?: boolean; /** Required: how the data should be returned */ resultType: CameraResultType; /** Target width; aspect ratio is preserved when only one dimension is given */ width?: number; /** Target height; aspect ratio is preserved when only one dimension is given */ height?: number; /** Source; defaults to CameraSource.Prompt */ source?: CameraSource; /** Camera direction when source is CAMERA; defaults to Rear */ direction?: CameraDirection; /** ActionSheet title for the PROMPT source (default 'Photo') */ promptLabelHeader?: string; /** ActionSheet label for choosing the gallery (default 'From Photos') */ promptLabelPhoto?: string; /** ActionSheet label for choosing the camera (default 'Take Picture') */ promptLabelPicture?: string; /** * Label of the cancel button. Not supported on HarmonyOS (the * ActionMenu is dismissed via back/overlay) — accepted for * @capacitor/camera drop-in compatibility, ignored. */ promptLabelCancel?: string; } export interface Photo { /** Base64 JPEG data when resultType is 'base64' */ base64String?: string; /** 'data:image/jpeg;base64,...' when resultType is 'dataUrl' */ dataUrl?: string; /** Sandbox file path when resultType is 'uri' */ path?: string; /** 'file://' + path — directly loadable by an inside the WebView */ webPath?: string; /** Always 'jpeg' on HarmonyOS */ format: string; /** Always false on HarmonyOS */ saved: boolean; } export interface GalleryPhotos { photos: GalleryPhoto[]; } export interface GalleryPhoto { path?: string; webPath: string; format: string; } export interface GalleryImageOptions { /** Max number of pictures; 0/undefined = unlimited (system max 500) */ limit?: number; } export interface CameraPlugin { getPhoto(options: ImageOptions): Promise; pickImages(options?: GalleryImageOptions): Promise; checkPermissions(): Promise; /** No-op: system pickers need no permissions, always resolves 'granted' */ requestPermissions(): Promise; }