@signiant/media-shuttle-sdk-base
Version:
The base parent sdk behind other media shuttle sdks (e.g. media-shuttle-sdk)
50 lines • 2.49 kB
TypeScript
/// <reference types="node" />
/**
* The idea behind the TransferClient is that it is suppose to abstract away the differences
* between an app and appless mode of operation.
*
* For example, in app downloads we have to talk to the app to open a file picker dialog whereas appless we have to ask the browser for the
* same thing. In both cases we want the same thing, a string containing the absolute path
* of the folder on the callers directory. If callers hold a reference to the TransferClient they
* don't have to care about *how* the operation is done only that they get the result they
* are looking for.
*
* Note that callers of the SDK should never be given direct access to the TransferClient as
* some operations (e.g. open folder) could be abused (e.g. open dozens of folders in a
* foreign file system potentially causing that system to crash);
*/
import { TransferConfig } from '../transfer';
import { Download, TransferEventCallback, TransferEventType } from '../../external';
import EventEmitter from 'events';
/**
* Note these options may be ignored in some cases, like if there is already a pre-existing,
* initialized message channel with the app.
*/
export interface TransferClientInitializationOptions {
/**
* True to ignore pre-checks like is the app installed.
*/
force?: boolean;
}
export interface ClientInfo {
clientId?: string;
appVersion?: string;
}
interface TransferClient extends EventEmitter {
initialize(options?: TransferClientInitializationOptions): Promise<void>;
get initialized(): boolean;
selectDestinationFolder(originator: string): Promise<string>;
selectFiles(originator: string): Promise<any[]>;
openFolder(path: string, originator: string): Promise<void>;
startDownload(originator: string, transferConfig: TransferConfig): Promise<void>;
startUpload(originator: string, transferConfig: TransferConfig): Promise<void>;
cancelTransfer(originator: string): Promise<void>;
setEventHandler(originator: string, eventType: TransferEventType | RegExp, callback: TransferEventCallback<Download>): any;
removeSelectedFiles(paths: string[], originator: string): Promise<void>;
removeEventHandler(originator: string, eventType: TransferEventType | RegExp): boolean;
removeAllEventHandlers(originator: string): boolean;
reinitialize(): Promise<void>;
get clientInfo(): ClientInfo;
}
export default TransferClient;
//# sourceMappingURL=TransferClient.d.ts.map