UNPKG

@itwin/core-frontend

Version:
117 lines 5.22 kB
/** @packageDocumentation * @module NativeApp */ import { BeEvent, GuidString } from "@itwin/core-bentley"; import { BriefcaseDownloader, BriefcaseProps, CatalogIModel, IModelVersion, InternetConnectivityStatus, IpcSocketFrontend, LocalBriefcaseProps, NativeAppFunctions, StorageValue, SyncMode } from "@itwin/core-common"; import { IpcAppOptions } from "./IpcApp"; import { OnDownloadProgress } from "./BriefcaseConnection"; /** Properties for specifying the BriefcaseId for downloading. May either specify a BriefcaseId directly (preferable) or, for * backwards compatibility, a [SyncMode]($common). If [SyncMode.PullAndPush]($common) is supplied, a new briefcaseId will be acquired. * @public */ export type DownloadBriefcaseId = { syncMode?: SyncMode; briefcaseId?: never; } | { briefcaseId: number; syncMode?: never; }; /** * Options to download a briefcase * @public */ export type DownloadBriefcaseOptions = DownloadBriefcaseId & { /** the full path for the briefcase file */ fileName?: string; /** Function called regularly to report progress of download. */ progressCallback?: OnDownloadProgress; /** interval for calling progress function, in milliseconds */ progressInterval?: number; }; /** * Options for [[NativeApp.startup]] * @public */ export interface NativeAppOpts extends IpcAppOptions { nativeApp?: object; } /** * The frontend of a native application * @see [Native Applications]($docs/learning/NativeApps.md) * @public */ export declare class NativeApp { private static _removeAppNotify?; /** A Proxy to call one of the [NativeAppFunctions]($common) functions via IPC. */ static nativeAppIpc: import("@itwin/core-bentley").PickAsyncMethods<NativeAppFunctions>; static catalogIpc: import("@itwin/core-bentley").PickAsyncMethods<CatalogIModel.IpcMethods>; private static _storages; private static _onOnline; private static _onOffline; private static setConnectivity; private static hookBrowserConnectivityEvents; private static unhookBrowserConnectivityEvents; /** event called when internet connectivity changes, if known */ static onInternetConnectivityChanged: BeEvent<(status: InternetConnectivityStatus) => void>; /** determine whether the app currently has internet connectivity, if known */ static checkInternetConnectivity(): Promise<InternetConnectivityStatus>; /** @internal */ static overrideInternetConnectivity(status: InternetConnectivityStatus): Promise<void>; private static _isValid; static get isValid(): boolean; /** * This is called by either ElectronApp.startup or MobileApp.startup - it should not be called directly * @internal */ static startup(ipc: IpcSocketFrontend, opts?: NativeAppOpts): Promise<void>; /** @internal */ static shutdown(): Promise<void>; static requestDownloadBriefcase(iTwinId: string, iModelId: string, downloadOptions: DownloadBriefcaseOptions, asOf?: IModelVersion): Promise<BriefcaseDownloader>; /** Get the full path filename for a briefcase within the briefcase cache */ static getBriefcaseFileName(props: BriefcaseProps): Promise<string>; /** Delete an existing briefcase * @param fileName the briefcase fileName */ static deleteBriefcase(fileName: string): Promise<void>; /** Get a list of all briefcase files held in the local briefcase cache directory */ static getCachedBriefcases(iModelId?: GuidString): Promise<LocalBriefcaseProps[]>; /** * Open a [[Storage]]. Creates a new Storage with that name if it does not already exist. * @param name Should be a local filename without an extension. * @returns a Promise for the [[Storage]]. */ static openStorage(name: string): Promise<Storage>; /** * Close a Storage and optionally delete it. * @param storage normally not call directly instead use Storage.close() * @param deleteStorage if true, delete the storage from disk after closing it. */ static closeStorage(storage: Storage, deleteStorage?: boolean): Promise<void>; /** Get the list of existing Storages on the local disk. */ static getStorageNames(): Promise<string[]>; } /** * A local disk-based cache for key value pairs for NativeApps. * @note This should be used only for local caching, since its not guaranteed to exist permanently. * @public */ export declare class Storage { readonly id: string; constructor(id: string); /** get the type of a value for a key, or undefined if not present. */ getValueType(key: string): Promise<"number" | "string" | "boolean" | "Uint8Array" | "null" | undefined>; /** Get the value for a key */ getData(key: string): Promise<StorageValue>; /** Set value for a key */ setData(key: string, value: StorageValue): Promise<void>; /** * Return an array of all keys in this Storage. * @note This can be expensive, depending on the number of keys present. */ getKeys(): Promise<string[]>; /** Remove a key and its data. */ removeData(key: string): Promise<void>; /** Remove all keys and their data. */ removeAll(): Promise<void>; } //# sourceMappingURL=NativeApp.d.ts.map