diff --git a/libantosdk/build/debug/core/ts/antos.d.ts b/libantosdk/build/debug/core/ts/antos.d.ts index 02b393b..8daae6b 100644 --- a/libantosdk/build/debug/core/ts/antos.d.ts +++ b/libantosdk/build/debug/core/ts/antos.d.ts @@ -1,3 +1,338 @@ +declare namespace OS { + namespace API { + /** + * Interface for user login data + * + * @export + * @interface UserLoginType + */ + interface UserLoginType { + /** + * The user credential + * + * @type {string} + * @memberof UserLoginType + */ + username: string; + /** + * The user password + * + * @type {string} + * @memberof UserLoginType + */ + password: string; + } + /** + * Interface for a command sent to + * server side package manage, it contains two field: + * + * @export + * @interface PackageCommandType + */ + interface PackageCommandType { + /** + * Command name, should be: `init`, `cache`, `install`, + * `uninstall` or `list` + * + * @type {string} + * @memberof PackageCommandType + */ + command: string; + /** + * Parameter object of each command + * + * @type {GenericObject} + * @memberof PackageCommandType + */ + args: GenericObject; + } + /** + * + * Interface for basic request result returned + * from the server-side. A valid server-side response should + * be in the following format + * ```json + * { + * "error": boolean or string_err, + * "result": JSON result object + * } + * ``` + * + * @export + * @interface RequestResult + */ + interface RequestResult { + /** + * Indicate whether the response is error + * + * @type {(boolean | string)} + * @memberof RequestResult + */ + error: boolean | string; + /** + * The response result, this value must be + * set when `error` is false + * + * @type {(string + * | boolean + * | GenericObject + * | any[] + * | FileInfoType + * | FileInfoType[] + * | setting.UserSettingType)} + * @memberof RequestResult + */ + result: string | boolean | GenericObject | any[] | FileInfoType | FileInfoType[] | setting.UserSettingType; + } + /** + * The host name of the server-side + */ + var HOST: string; + /** + * The base URI of the server-side API + */ + var BASE_URI: string; + /** + * The base REST URI of the server-side API + */ + var REST: string; + /** + * The namespace `handle` contains some low level API to + * communicate with the server side API. It is the only + * API layer that communicate directly with the server. + * To make AntOS compatible with any server side API, + * all exported variable unctions defined in the `handle` + * namespace should be re-implemented + */ + namespace handle { + /** + * Base URI for reading content of VFS file + */ + var get: string; + /** + * Base URI for VFS file sharing + */ + var shared: string; + /** + * Send a request to the server-side API for a directory scanning + * operation + * + * @export + * @param {string} p a VFS file path e.g. home://test/ + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or a list of FileInfoType + */ + function scandir(p: string): Promise; + /** + * + * Send a request to the server-side API for directory creation + * + * @export + * @param {string} p VFS path of the directory to be created + * @returns {Promise} A promise on a RequestResult + * which contains an error or true on success + */ + function mkdir(p: string): Promise; + /** + * Send a request to the server-side API for sharing/unsharing a VFS file, + * once shared a VFS file will be publicly visible by everyone + * + * @export + * @param {string} p VFS file path to be shared + * @param {boolean} pub flag: share (true) or unshare (false) + * @returns {Promise} A promise on a RequestResult + * which contains an error or true on success + */ + function sharefile(p: string, pub: boolean): Promise; + /** + * Get VFS file meta-data + * + * @export + * @param {string} p VFS file path + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or an object of FileInfoType + */ + function fileinfo(p: string): Promise; + /** + * Read a VFS file content. There are many ways a VFS file can be read: + * - Read as a raw text content + * - Read as a javascript file, in this case the content of the + * file will be executed + * - Read as JSON object + * + * @export + * @param {string} p path of the VFS file + * @param {string} t return data type: + * - jsonp: the response is an json object + * - script: the response is a javascript code + * - xml, html: the response is a XML/HTML object + * - text: plain text + * + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or an object of [[FileInfoType]] + */ + function readfile(p: string, t: string): Promise; + /** + * Move a file to another location on server-side + * + * @export + * @param {string} s VFS source file path + * @param {string} d VFS destination file path + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or a success response + */ + function move(s: string, d: string): Promise; + /** + * Delete a VFS file on the server-side + * + * @export + * @param {string} p VFS file path + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or a success response + */ + function remove(p: string): Promise; + /** + * Read the file as binary data + * + * @export + * @param {string} p VFS file to be read + * @returns {Promise} a Promise on an array buffer + */ + function fileblob(p: string): Promise; + /** + * Send a command to the serverside package manager + * + * @export + * @param {PackageCommandType} d a package command of type PackageCommandType + * @returns {Promise} a promise on a [[RequestResult]] + */ + function packages(d: PackageCommandType): Promise; + /** + * Upload file to the server via VFS interface + * + * @export + * @param {string} d VFS destination directory path + * @returns {Promise} a promise on a [[RequestResult]] + */ + function upload(d: string): Promise; + /** + * Write Base 64 encoded data to a VFS file + * + * @export + * @param {string} p path to the VFS file + * @param {string} d file data encoded in Base 64 + * @returns {Promise} a promise on a [[RequestResult]] + */ + function write(p: string, d: string): Promise; + /** + * An apigateway allows client side to execute a custom server-side + * script and get back the result. This gateway is particularly + * useful in case of performing a task that is not provided by the core + * API + * + * @export + * @param {GenericObject} d execution indication, provided only when ws is `false` + * otherwise, `d` should be written directly to the websocket stream as JSON object. + * Two possible formats of `d`: + * ```text + * execute an server-side script file: + * + * { + * path: [VFS path], + * parameters: [parameters of the server-side script] + * } + * + * or, execute directly a snippet of server-side script: + * + * { code: [server-side script code snippet as string] } + * + * ``` + * + * @param {boolean} ws flag indicate whether to use websocket for the connection + * to the gateway API. In case of streaming data, the websocket is preferred + * @returns {Promise} a promise on the result object (any) + */ + function apigateway(d: GenericObject, ws: boolean): Promise; + /** + * Check if a user is logged in + * + * @export + * @returns {Promise} a promise on a [[RequestResult]] that + * contains an error or a [[UserSettingType]] object + */ + function auth(): Promise; + /** + * Perform a login operation + * + * @export + * @param {UserLoginType} d user data [[UserLoginType]] + * @returns {Promise} a promise on a [[RequestResult]] that + * contains an error or a [[UserSettingType]] object + */ + function login(d: UserLoginType): Promise; + /** + * Perform a logout operation + * + * @export + * @returns {Promise} a promise on a [[RequestResult]] + */ + function logout(): Promise; + /** + * Save the current user settings + * + * @export + * @returns {Promise} a promise on a [[RequestResult]] + */ + function setting(): Promise; + /** + * This is the low level function of AntOS VDB API. + * It requests the server API to perform some simple + * SQL query. + * + * @export + * @param {string} cmd action to perform: save, delete, get, select + * @param {GenericObject} d data object of the request based on each action: + * - save: + * ``` + * { table: "table name", data: [record data object]} + * ``` + * - get: + * ``` + * { table: "table name", id: [record id]} + * ``` + * - delete: + * ``` + * { table: "table name", id: [record id]} + * or + * { table: "table name", cond: [conditional object]} + * ``` + * - select: + * ``` + * { table: "table name", cond: [conditional object]} + * ``` + * @returns {Promise} a promise of [[RequestResult]] on the + * query data + * + * A conditional object represents a SQL condition statement as an object, + * example: `pid = 10 AND cid = 2 ORDER BY date DESC` + * ``` + * { + * exp: { + * "and": { + * pid: 10, + * cid: 2 + * } + * }, + * order: { + * date: "DESC" + * } + * } + * ``` + */ + function dbquery(cmd: string, d: GenericObject): Promise; + } + } +} declare namespace OS { namespace GUI { /** @@ -45,10 +380,11 @@ declare namespace OS { * * Need to be implemented by subclasses * - * @abstract - * @memberof SubWindow + * + * @returns {void} + * @memberof BaseDialog */ - abstract init(): void; + init(): void; /** * Main entry point after rendering of the sub-window * @@ -77,6 +413,13 @@ declare namespace OS { * @memberof SubWindow */ hide(): void; + /** + * blur the sub-window + * + * @returns {void} + * @memberof SubWindow + */ + blur(): void; } /** * Abstract prototype of all AntOS dialogs widget @@ -925,2458 +1268,6 @@ declare namespace OS { const schemes: GenericObject; } } -declare namespace OS { - namespace API { - /** - * Data type exchanged via - * the global Announcement interface - * - * @export - * @interface AnnouncementDataType - */ - interface AnnouncementDataType { - /** - * message string - * - * @type {string| FormattedString} - * @memberof AppAnnouncementDataType - */ - message: string | FormattedString; - /** - * Process ID - * - * @type {number} - * @memberof AppAnnouncementDataType - */ - id: number; - /** - * App name - * - * @type {string | FormattedString} - * @memberof AppAnnouncementDataType - */ - name: string | FormattedString; - /** - * Icon file - * - * @type {string} - * @memberof AppAnnouncementDataType - */ - icon?: string; - /** - * App icon class - * - * @type {string} - * @memberof AppAnnouncementDataType - */ - iconclass?: string; - /** - * User specific data - * - * @type {*} - * @memberof AppAnnouncementDataType - */ - u_data?: T; - } - /** - * Observable entry type definition - * - * @export - * @interface ObservableEntryType - */ - interface ObservableEntryType { - /** - * A Set of callbacks that should be called only once. - * These callbacks will be removed after the first - * occurrence of the corresponding event - * - * @memberof ObservableEntryType - */ - one: Set<(d: any) => void>; - /** - * A Set of callbacks that should be called - * every time the corresponding event is triggered - * - * @memberof ObservableEntryType - */ - many: Set<(d: any) => void>; - } - /** - * Announcement listener type definition - * - * @export - * @interface AnnouncerListenerType - */ - interface AnnouncerListenerType { - [index: number]: { - /** - * The event name - * - * @type {string} - */ - e: string; - /** - * The event callback - * - */ - f: (d: any) => void; - }[]; - } - /** - * This class is the based class used in AntOS event - * announcement system. - * It implements the observer pattern using simple - * subscribe/publish mechanism - * @export - * @class Announcer - */ - class Announcer { - /** - * The observable object that stores event name - * and its corresponding callback in [[ObservableEntryType]] - * - * @type {GenericObject} - * @memberof Announcer - */ - observable: GenericObject; - /** - * Enable/disable the announcer - * - * @type {boolean} - * @memberof Announcer - */ - enable: boolean; - /** - *Creates an instance of Announcer. - * @memberof Announcer - */ - constructor(); - /** - * Disable the announcer, when this function is called - * all events and their callbacks will be removed - * - * @returns - * @memberof Announcer - */ - disable(): boolean; - /** - * Subscribe to an event, the callback will be called - * every time the corresponding event is trigged - * - * @param {string} evtName event name - * @param {(d: any) => void} callback The corresponding callback - * @returns {void} - * @memberof Announcer - */ - on(evtName: string, callback: (d: any) => void): void; - /** - * Subscribe to an event, the callback will - * be called only once and then removed from the announcer - * - * @param {string} evtName event name - * @param {(d: any) => void} callback the corresponding callback - * @returns {void} - * @memberof Announcer - */ - one(evtName: string, callback: (d: any) => void): void; - /** - * Unsubscribe the callback from an event - * - * @param {string} evtName event name - * @param {(d: any) => void} [callback] the callback to be unsubscribed. - * When the `callback` is `*`, all callbacks related to `evtName` will be - * removed - * @memberof Announcer - */ - off(evtName: string, callback?: (d: any) => void): void; - /** - * Trigger an event - * - * @param {string} evtName event name - * @param {*} data data object that will be send to all related callback - * @returns {void} - * @memberof Announcer - */ - trigger(evtName: string, data: any): void; - } - } - /** - * This namespace defines every thing related to the system announcement. - * - * The system announcement provides a global way to communicate between - * processes (applications/services) using the subscribe/publish - * mechanism - */ - namespace announcer { - /** - * The global announcer object that manages global events - * and callbacks - */ - var observable: API.Announcer; - /** - * This variable is used to allocate the `id` of all messages - * passing between publishers and subscribers in the - * system announcement - */ - var quota: 0; - /** - * Placeholder of all global events listeners - */ - var listeners: API.AnnouncerListenerType; - /** - * Subscribe to a global event - * - * @export - * @param {string} e event name - * @param {(d: API.AnnouncementDataType) => void} f event callback - * @param {GUI.BaseModel} a the process (Application/service) related to the callback - */ - function on(e: string, f: (d: API.AnnouncementDataType) => void, a: BaseModel): void; - /** - * Trigger a global event - * - * @export - * @param {string} e event name - * @param {*} d data passing to all related callback - */ - function trigger(e: string, d: any): void; - /** - * Report system fail. This will trigger the global `fail` - * event - * - * @export - * @param {(string | FormattedString)} m message string - * @param {Error} e error to be reported - */ - function osfail(m: string | FormattedString, e: Error): void; - /** - * Report system error. This will trigger the global `error` - * event - * - * @export - * @param {(string | FormattedString)} m message string - * @param {Error} e error to be reported - */ - function oserror(m: string | FormattedString, e: Error): void; - /** - * Trigger system notification (`info` event) - * - * @export - * @param {(string | FormattedString)} m notification message - */ - function osinfo(m: string | FormattedString): void; - /** - * - * - * @export - * @param {string} e event name - * @param {(string| FormattedString)} m event message - * @param {*} [d] user data - */ - function ostrigger(e: string, m: string | FormattedString, d?: any): void; - /** - * Unregister a process (application/service) from - * the global announcement system - * - * @export - * @param {GUI.BaseModel} app reference to the process - * @returns {void} - */ - function unregister(app: BaseModel): void; - /** - * Allocate message id - * - * @export - * @returns {number} - */ - function getMID(): number; - } -} -declare namespace OS { - /** - * This namespace dedicated to all operations related to system - * process management - */ - namespace PM { - /** - * A process is either an instance of an application or a service - */ - type ProcessType = application.BaseApplication | application.BaseService; - /** - * Alias to all classes that extends [[BaseModel]] - */ - type ModelTypeClass = { - new (args: AppArgumentsType[]): T; - }; - /** - * Process id allocator, when a new process is created, the value of - * this variable is increased - */ - var pidalloc: number; - /** - * All running processes is stored in this variables - */ - var processes: GenericObject; - /** - * Create a new process of application or service - * - * @export - * @param {string} app class name string - * @param {ProcessTypeClass} cls prototype class - * @param {GUI.AppArgumentsType[]} [args] process arguments - * @returns {Promise} a promise on the created process - */ - function createProcess(app: string, cls: ModelTypeClass, args?: AppArgumentsType[]): Promise; - /** - * Get the reference to a process using its id - * - * @export - * @param {number} pid - * @returns {BaseModel} - */ - function appByPid(pid: number): BaseModel; - /** - * Kill a process - * - * @export - * @param {OS.GUI.BaseModel} app reference to the process - * @returns {void} - */ - function kill(app: BaseModel): void; - /** - * Kill all process of an application or service - * - * @export - * @param {string} app process class name - * @param {boolean} force force exit all process - * @returns {void} - */ - function killAll(app: string, force: boolean): void; - } -} -declare namespace OS { - namespace API { - /** - * Interface for user login data - * - * @export - * @interface UserLoginType - */ - interface UserLoginType { - /** - * The user credential - * - * @type {string} - * @memberof UserLoginType - */ - username: string; - /** - * The user password - * - * @type {string} - * @memberof UserLoginType - */ - password: string; - } - /** - * Interface for a command sent to - * server side package manage, it contains two field: - * - * @export - * @interface PackageCommandType - */ - interface PackageCommandType { - /** - * Command name, should be: `init`, `cache`, `install`, - * `uninstall` or `list` - * - * @type {string} - * @memberof PackageCommandType - */ - command: string; - /** - * Parameter object of each command - * - * @type {GenericObject} - * @memberof PackageCommandType - */ - args: GenericObject; - } - /** - * - * Interface for basic request result returned - * from the server-side. A valid server-side response should - * be in the following format - * ```json - * { - * "error": boolean or string_err, - * "result": JSON result object - * } - * ``` - * - * @export - * @interface RequestResult - */ - interface RequestResult { - /** - * Indicate whether the response is error - * - * @type {(boolean | string)} - * @memberof RequestResult - */ - error: boolean | string; - /** - * The response result, this value must be - * set when `error` is false - * - * @type {(string - * | boolean - * | GenericObject - * | any[] - * | FileInfoType - * | FileInfoType[] - * | setting.UserSettingType)} - * @memberof RequestResult - */ - result: string | boolean | GenericObject | any[] | FileInfoType | FileInfoType[] | setting.UserSettingType; - } - /** - * The host name of the server-side - */ - var HOST: string; - /** - * The base URI of the server-side API - */ - var BASE_URI: string; - /** - * The base REST URI of the server-side API - */ - var REST: string; - /** - * The namespace `handle` contains some low level API to - * communicate with the server side API. It is the only - * API layer that communicate directly with the server. - * To make AntOS compatible with any server side API, - * all exported variable unctions defined in the `handle` - * namespace should be re-implemented - */ - namespace handle { - /** - * Base URI for reading content of VFS file - */ - var get: string; - /** - * Base URI for VFS file sharing - */ - var shared: string; - /** - * Send a request to the server-side API for a directory scanning - * operation - * - * @export - * @param {string} p a VFS file path e.g. home://test/ - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or a list of FileInfoType - */ - function scandir(p: string): Promise; - /** - * - * Send a request to the server-side API for directory creation - * - * @export - * @param {string} p VFS path of the directory to be created - * @returns {Promise} A promise on a RequestResult - * which contains an error or true on success - */ - function mkdir(p: string): Promise; - /** - * Send a request to the server-side API for sharing/unsharing a VFS file, - * once shared a VFS file will be publicly visible by everyone - * - * @export - * @param {string} p VFS file path to be shared - * @param {boolean} pub flag: share (true) or unshare (false) - * @returns {Promise} A promise on a RequestResult - * which contains an error or true on success - */ - function sharefile(p: string, pub: boolean): Promise; - /** - * Get VFS file meta-data - * - * @export - * @param {string} p VFS file path - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or an object of FileInfoType - */ - function fileinfo(p: string): Promise; - /** - * Read a VFS file content. There are many ways a VFS file can be read: - * - Read as a raw text content - * - Read as a javascript file, in this case the content of the - * file will be executed - * - Read as JSON object - * - * @export - * @param {string} p path of the VFS file - * @param {string} t return data type: - * - jsonp: the response is an json object - * - script: the response is a javascript code - * - xml, html: the response is a XML/HTML object - * - text: plain text - * - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or an object of [[FileInfoType]] - */ - function readfile(p: string, t: string): Promise; - /** - * Move a file to another location on server-side - * - * @export - * @param {string} s VFS source file path - * @param {string} d VFS destination file path - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or a success response - */ - function move(s: string, d: string): Promise; - /** - * Delete a VFS file on the server-side - * - * @export - * @param {string} p VFS file path - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or a success response - */ - function remove(p: string): Promise; - /** - * Read the file as binary data - * - * @export - * @param {string} p VFS file to be read - * @returns {Promise} a Promise on an array buffer - */ - function fileblob(p: string): Promise; - /** - * Send a command to the serverside package manager - * - * @export - * @param {PackageCommandType} d a package command of type PackageCommandType - * @returns {Promise} a promise on a [[RequestResult]] - */ - function packages(d: PackageCommandType): Promise; - /** - * Upload file to the server via VFS interface - * - * @export - * @param {string} d VFS destination directory path - * @returns {Promise} a promise on a [[RequestResult]] - */ - function upload(d: string): Promise; - /** - * Write Base 64 encoded data to a VFS file - * - * @export - * @param {string} p path to the VFS file - * @param {string} d file data encoded in Base 64 - * @returns {Promise} a promise on a [[RequestResult]] - */ - function write(p: string, d: string): Promise; - /** - * An apigateway allows client side to execute a custom server-side - * script and get back the result. This gateway is particularly - * useful in case of performing a task that is not provided by the core - * API - * - * @export - * @param {GenericObject} d execution indication, provided only when ws is `false` - * otherwise, `d` should be written directly to the websocket stream as JSON object. - * Two possible formats of `d`: - * ```text - * execute an server-side script file: - * - * { - * path: [VFS path], - * parameters: [parameters of the server-side script] - * } - * - * or, execute directly a snippet of server-side script: - * - * { code: [server-side script code snippet as string] } - * - * ``` - * - * @param {boolean} ws flag indicate whether to use websocket for the connection - * to the gateway API. In case of streaming data, the websocket is preferred - * @returns {Promise} a promise on the result object (any) - */ - function apigateway(d: GenericObject, ws: boolean): Promise; - /** - * Check if a user is logged in - * - * @export - * @returns {Promise} a promise on a [[RequestResult]] that - * contains an error or a [[UserSettingType]] object - */ - function auth(): Promise; - /** - * Perform a login operation - * - * @export - * @param {UserLoginType} d user data [[UserLoginType]] - * @returns {Promise} a promise on a [[RequestResult]] that - * contains an error or a [[UserSettingType]] object - */ - function login(d: UserLoginType): Promise; - /** - * Perform a logout operation - * - * @export - * @returns {Promise} a promise on a [[RequestResult]] - */ - function logout(): Promise; - /** - * Save the current user settings - * - * @export - * @returns {Promise} a promise on a [[RequestResult]] - */ - function setting(): Promise; - /** - * This is the low level function of AntOS VDB API. - * It requests the server API to perform some simple - * SQL query. - * - * @export - * @param {string} cmd action to perform: save, delete, get, select - * @param {GenericObject} d data object of the request based on each action: - * - save: - * ``` - * { table: "table name", data: [record data object]} - * ``` - * - get: - * ``` - * { table: "table name", id: [record id]} - * ``` - * - delete: - * ``` - * { table: "table name", id: [record id]} - * or - * { table: "table name", cond: [conditional object]} - * ``` - * - select: - * ``` - * { table: "table name", cond: [conditional object]} - * ``` - * @returns {Promise} a promise of [[RequestResult]] on the - * query data - * - * A conditional object represents a SQL condition statement as an object, - * example: `pid = 10 AND cid = 2 ORDER BY date DESC` - * ``` - * { - * exp: { - * "and": { - * pid: 10, - * cid: 2 - * } - * }, - * order: { - * date: "DESC" - * } - * } - * ``` - */ - function dbquery(cmd: string, d: GenericObject): Promise; - } - } -} -declare namespace OS { - /** - * This namespace is dedicated to everything related to the - * global system settings - */ - namespace setting { - /** - * User setting type definition - * - * @export - * @interface UserSettingType - */ - interface UserSettingType { - /** - * User full name - * - * @type {string} - * @memberof UserSettingType - */ - name: string; - /** - * User name - * - * @type {string} - * @memberof UserSettingType - */ - username: string; - /** - * User id - * - * @type {number} - * @memberof UserSettingType - */ - id: number; - /** - * User groups - * - * @type {{ [index: number]: string }} - * @memberof UserSettingType - */ - group?: { - [index: number]: string; - }; - [propName: string]: any; - } - /** - * Virtual desktop setting data type - * - * @export - * @interface DesktopSettingType - */ - interface DesktopSettingType { - /** - * Desktop VFS path - * - * @type {string} - * @memberof DesktopSettingType - */ - path: string; - /** - * Desktop menu, can be added automatically by applications - * - * @type {GUI.BasicItemType[]} - * @memberof DesktopSettingType - */ - menu: GUI.BasicItemType[]; - /** - * Show desktop hidden files - * - * @type {boolean} - * @memberof DesktopSettingType - */ - showhidden: boolean; - [propName: string]: any; - } - /** - * Wallpaper setting data type - * - * @export - * @interface WPSettingType - */ - interface WPSettingType { - /** - * Repeat wallpaper: - * - `repeat` - * - `repeat-x` - * - `repeat-y` - * - `no-repeat` - * - * @type {string} - * @memberof WPSettingType - */ - repeat: string; - /** - * Wallpaper size - * - `contain` - * - `cover` - * - `auto` - * - * @type {string} - * @memberof WPSettingType - */ - size: string; - /** - * VFS path to the wallpaper image - * - * @type {string} - * @memberof WPSettingType - */ - url: string; - } - /** - * Theme setting data type - * - * @export - * @interface ThemeSettingType - */ - interface ThemeSettingType { - /** - * Theme name, this value is used for looking - * theme file in system asset - * - * @type {string} - * @memberof ThemeSettingType - */ - name: string; - /** - * Theme user-friendly text - * - * @type {string} - * @memberof ThemeSettingType - */ - text: string; - } - /** - * Appearance setting data type - * - * @export - * @interface AppearanceSettingType - */ - interface AppearanceSettingType { - /** - * Current theme name - * - * @type {string} - * @memberof AppearanceSettingType - */ - theme: string; - /** - * All themes available in the system - * - * @type {ThemeSettingType[]} - * @memberof AppearanceSettingType - */ - themes: ThemeSettingType[]; - /** - * Current wallpaper setting - * - * @type {WPSettingType} - * @memberof AppearanceSettingType - */ - wp: WPSettingType; - /** - * All wallpapers available in the system - * - * @type {string[]} - * @memberof AppearanceSettingType - */ - wps: string[]; - } - /** - * VFS Mount points setting data type - * - * @export - * @interface VFSMountPointSettingType - */ - interface VFSMountPointSettingType { - /** - * Path to the mount point - * - * @type {string} - * @memberof VFSMountPointSettingType - */ - path: string; - /** - * User friendly mount point name - * - * @type {string} - * @memberof VFSMountPointSettingType - */ - text: string; - [propName: string]: any; - } - /** - * VFS setting data type - * - * @export - * @interface VFSSettingType - */ - interface VFSSettingType { - /** - * mount points setting - * - * @type {VFSMountPointSettingType[]} - * @memberof VFSSettingType - */ - mountpoints: VFSMountPointSettingType[]; - [propName: string]: any; - } - /** - * Global system setting data type - * - * @export - * @interface SystemSettingType - */ - interface SystemSettingType { - /** - * System error report URL - * - * @type {string} - * @memberof SystemSettingType - */ - error_report: string; - /** - * Current system locale e.g. `en_GB` - * - * @type {string} - * @memberof SystemSettingType - */ - locale: string; - /** - * System menus - * - * @type {API.PackageMetaType[]} - * @memberof API.PackageMetaType - */ - menu: API.PackageMetaType[]; - /** - * Packages meta-data - * - * @type {{ [index: string]: API.PackageMetaType }} - * @memberof SystemSettingType - */ - packages: { - [index: string]: API.PackageMetaType; - }; - /** - * Path to the installed packages - * - * @type {{ - * user: string; - * system: string; - * }} - * @memberof SystemSettingType - */ - pkgpaths: { - /** - * User specific packages install location - * - * @type {string} - */ - user: string; - /** - * System packages install location - * - * @type {string} - */ - system: string; - }; - /** - * Package repositories setting. - * This configuration is used by [[MarketPlace]] - * for package management - * - * @type {{ - * text: string; - * url: string; - * }[]} - * @memberof SystemSettingType - */ - repositories: { - /** - * Repository name - * - * @type {string} - */ - text: string; - /** - * Repository uri - * - * @type {string} - */ - url: string; - }[]; - /** - * Startup applications and services - * - * @type {{ - * apps: string[]; - * services: string[]; - * }} - * @memberof SystemSettingType - */ - startup: { - /** - * List of application names - * - * @type {string[]} - */ - apps: string[]; - /** - * List of service names - * - * @type {string[]} - */ - services: string[]; - /** - * List of pinned applications - * - * @type {string[]} - */ - pinned: string[]; - }; - } - /** - * User settings - */ - var user: UserSettingType; - /** - * Application settings - */ - var applications: GenericObject; - /** - * Desktop settings - */ - var desktop: DesktopSettingType; - /** - * Appearance settings - */ - var appearance: AppearanceSettingType; - /** - * VFS settings - */ - var VFS: VFSSettingType; - /** - * System settings - */ - var system: SystemSettingType; - } - /** - * Reset the system settings to default values - * - * @export - */ - function resetSetting(): void; - /** - * Apply the input parameter object to system settings. - * This object could be an object loaded from - * setting JSON file saved on the server. - * - * @export - * @param {*} conf - */ - function systemSetting(conf: any): void; -} -/// -declare namespace OS { - namespace application { - /** - * Services are processes that run in the background and - * are waken up in certain circumstances such as by global - * events or user interactions. - * - * Each service takes an entry in the system tray menu - * located on the system panel. This menu entry is used - * to access to service visual contents such as: options, - * task performing based on user interaction, etc. - * - * Services are singleton processes, there is only - * one process of a service at a time - * - * @export - * @abstract - * @class BaseService - * @extends {BaseModel} - */ - abstract class BaseService extends BaseModel { - /** - * The service icon shown in the system tray - * - * @type {string} - * @memberof BaseService - */ - icon: string; - /** - * CSS class of the service icon shown in the system tray - * - * @type {string} - * @memberof BaseService - */ - iconclass: string; - /** - * Text of the service shown in the system tray - * - * @type {string} - * @memberof BaseService - */ - text: string; - /** - * Reference to the menu entry DOM element attached - * to the service - * - * @type {HTMLElement} - * @memberof BaseService - */ - domel: HTMLElement; - /** - * Reference to the timer that periodically executes the callback - * defined in [[watch]]. - * - * @private - * @type {number} - * @memberof BaseService - */ - private timer; - /** - * Reference to the system tray menu - * - * @type {HTMLElement} - * @memberof BaseService - */ - holder: HTMLElement; - /** - * Placeholder for service select callback - * - * @memberof BaseService - */ - onmenuselect: (d: OS.GUI.TagEventType) => void; - /** - *Creates an instance of BaseService. - * @param {string} name service class name - * @param {AppArgumentsType[]} args service arguments - * @memberof BaseService - */ - constructor(name: string, args: AppArgumentsType[]); - /** - * Do nothing - * - * @memberof BaseService - */ - hide(): void; - /** - * Init the service before attaching it to - * the system tray: event subscribe, scheme - * loading. - * - * Should be implemented by all subclasses - * - * @abstract - * @memberof BaseService - */ - abstract init(): void; - /** - * Refresh the service menu entry in the - * system tray - * - * @memberof BaseService - */ - update(): void; - /** - * Get the service meta-data - * - * @returns {API.PackageMetaType} - * @memberof BaseService - */ - meta(): API.PackageMetaType; - /** - * Attach the service to a menu element - * such as the system tray menu - * - * @param {HTMLElement} h - * @memberof BaseService - */ - attach(h: HTMLElement): void; - /** - * Set the callback that will be called periodically - * after a period of time. - * - * Each service should only have at most one watcher - * - * @protected - * @param {number} t period time in seconds - * @param {() => void} f callback function - * @returns {number} - * @memberof BaseService - */ - protected watch(t: number, f: () => void): number; - /** - * This function is called when the service - * is exited - * - * @protected - * @param {BaseEvent} evt exit event - * @returns - * @memberof BaseService - */ - protected onexit(evt: BaseEvent): JQuery; - /** - * Do nothing - * - * @memberof BaseService - */ - main(): void; - /** - * Do nothing - * - * @memberof BaseService - */ - show(): void; - /** - * Awake the service, this function is usually called when - * the system tray menu entry attached to the service is - * selected. - * - * This function should be implemented by all subclasses - * - * @abstract - * @param {GUI.TagEventType} e - * @memberof BaseService - */ - abstract awake(e: GUI.TagEventType): void; - /** - * Do nothing - * - * @protected - * @param {BaseEvent} evt - * @memberof BaseService - */ - protected cleanup(evt: BaseEvent): void; - } - } -} -declare type VFSFileHandleClass = { - new (...args: any[]): OS.API.VFS.BaseFileHandle; -}; -interface String { - /** - * Convert a string to VFS file handle. - * - * This function will create a file handle object from the string - * with the help of [[VFS.findHandles]] - * - * @returns {OS.API.VFS.BaseFileHandle} - * @memberof String - */ - asFileHandle(): OS.API.VFS.BaseFileHandle; -} -declare namespace OS { - namespace API { - /** - * User permission data type - * - * @export - * @interface UserPermissionType - */ - interface UserPermissionType { - read: boolean; - write: boolean; - exec: boolean; - } - /** - * VFS file meta-data data type - * - * @export - * @interface FileInfoType - */ - interface FileInfoType { - /** - * File mime type - * - * @type {string} - * @memberof FileInfoType - */ - mime: string; - /** - * File size - * - * @type {number} - * @memberof FileInfoType - */ - size: number; - /** - * File name - * - * @type {string} - * @memberof FileInfoType - */ - name: string; - /** - * File path - * - * @type {string} - * @memberof FileInfoType - */ - path: string; - /** - * File type: - * - `file` - * - `dir` - * - `app` - * - * @type {string} - * @memberof FileInfoType - */ - type: string; - /** - * File permission - * - * @type {{ - * group: UserPermissionType; - * owner: UserPermissionType; - * other: UserPermissionType; - * }} - * @memberof FileInfoType - */ - perm?: { - /** - * Group permission - * - * @type {UserPermissionType} - */ - group: UserPermissionType; - /** - * Owner permission - * - * @type {UserPermissionType} - */ - owner: UserPermissionType; - /** - * Other permission - * - * @type {UserPermissionType} - */ - other: UserPermissionType; - }; - /** - * Creation time - * - * @type {string} - * @memberof FileInfoType - */ - ctime?: string; - /** - * Modification time - * - * @type {string} - * @memberof FileInfoType - */ - mtime?: string; - /** - * Group id - * - * @type {number} - * @memberof FileInfoType - */ - gid?: number; - /** - * User id - * - * @type {number} - * @memberof FileInfoType - */ - uid?: number; - [propName: string]: any; - } - /** - * This namespace is dedicated to all APIs related to - * AntOS Virtual File System (VFS) - */ - namespace VFS { - /** - * Placeholder stores VFS file protocol patterns and its attached file handle class. - * - */ - const handles: GenericObject; - /** - * Register a protocol to a handle class - * - * @export - * @param {string} protos VFS protocol pattern - * @param {VFSFileHandleClass} cls handle class - */ - function register(protos: string, cls: VFSFileHandleClass): void; - /** - * Load custom VFS handles if the package vfsx available - * - * @export - * @param {boolean} [force] force load the file - * @return {*} {Promise} - */ - function loadVFSX(force?: boolean): Promise; - /** - * Looking for a attached file handle class of a string protocol - * - * When converting a string to file handle, the system will look - * for a protocol pattern in the string, if the protocol found, - * its attached handle class (found in [[VFS.handles]]) will be - * used to initialize a file handle object from the string - * - * ```typescript - * "home://data/test.txt".asFileHandle() // -> an instance of RemoteFileHandle - * ``` - * @export - * @param {string} proto protocol string - * @returns {VFSFileHandleClass[]} - */ - function findHandles(proto: string): VFSFileHandleClass[]; - /** - * Abstract prototype of all all VFS file handle definition. - * - * This prototype provides a standardized interface to access - * to different underlay file systems such as remote file, - * cloud file (Dropbox, Google drive, etc.), URL or memory-based file - * - * @export - * @abstract - * @class BaseFileHandle - */ - abstract class BaseFileHandle { - /** - * Flag indicates whether the file is dirty - * - * @type {boolean} - * @memberof BaseFileHandle - */ - dirty: boolean; - /** - * Once read, file content will be cached in this placeholder - * - * @type {*} - * @memberof BaseFileHandle - */ - cache: any; - /** - * Flag indicated whether the file meta-data is loaded - * - * @type {boolean} - * @memberof BaseFileHandle - */ - ready: boolean; - /** - * File path - * - * @type {string} - * @memberof BaseFileHandle - */ - path: string; - /** - * File protocol e.g: - * - `os://` - * - `home://` - * - * @type {string} - * @memberof BaseFileHandle - */ - protocol: string; - /** - * List of path segments - * - * @type {string[]} - * @memberof BaseFileHandle - */ - genealogy: string[]; - /** - * File base name - * - * @type {string} - * @memberof BaseFileHandle - */ - basename: string; - /** - * Once loaded, [[ready]] will be set to true and - * file meta-data will be stored in this place holder - * - * @type {FileInfoType} - * @memberof BaseFileHandle - */ - info: FileInfoType; - /** - * File extension - * - * @type {string} - * @memberof BaseFileHandle - */ - ext: string; - /** - * - * File type - * @type {string} - * @memberof BaseFileHandle - */ - type: string; - /** - *Creates an instance of BaseFileHandle. - * @param {string} path file path - * @memberof BaseFileHandle - */ - constructor(path: string); - /** - * Set a file path to the current file handle - * - * @param {string} p - * @returns {void} - * @memberof BaseFileHandle - */ - setPath(p: string): void; - /** - * Getter: Get the file basename - * Setter: set the file name - * - * @returns {string} - * @memberof BaseFileHandle - */ - get filename(): string; - set filename(v: string); - /** - * Set data to the file cache - * - * @param {*} v data object - * @returns {BaseFileHandle} - * @memberof BaseFileHandle - */ - setCache(v: any): BaseFileHandle; - /** - * Return the object itself - * - * @returns {BaseFileHandle} - * @memberof BaseFileHandle - */ - asFileHandle(): BaseFileHandle; - /** - * Check whether the current file is the root of the file tree - * - * @returns {boolean} - * @memberof BaseFileHandle - */ - isRoot(): boolean; - /** - * Check whether the current file is a hidden file - * - * @returns {boolean} - * @memberof BaseFileHandle - */ - isHidden(): boolean; - /** - * Get hash number of the current file path - * - * @returns {number} - * @memberof BaseFileHandle - */ - hash(): number; - /** - * Convert the current file cache to Base64 - * - * @protected - * @param {string} t type of the file cache: - * - `object` - * - `mime type` - * @returns {(Promise)} promise on the converted data - * @memberof BaseFileHandle - */ - protected b64(t: string): Promise; - /** - * Get the parent file handle of the current file - * - * @returns {BaseFileHandle} - * @memberof BaseFileHandle - */ - parent(): BaseFileHandle; - /** - * Load the file meta-data before performing - * any task - * - * @returns {Promise} a promise on file meta-data - * @memberof BaseFileHandle - */ - onready(): Promise; - /** - * Public read operation - * - * This function calls the [[_rd]] function to perform the operation. - * - * If the current file is a directory, then the operation - * will return the meta-data of all files inside of the directory. - * Otherwise, file content will be returned - * - * @param {string} t data type - * - jsonp: the response is an json object - * - script: the response is a javascript code - * - xml, html: the response is a XML/HTML object - * - text: plain text - * - binary - * - * @returns {Promise} a promise on the file content - * @memberof BaseFileHandle - */ - read(t?: string): Promise; - /** - * Write the file cache to the actual file - * - * This function calls the [[_wr]] function to perform the operation - * - * @param {string} t data type - * - `base64` - * - `object` - * - `mime type` - * - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - write(t: string): Promise; - /** - * Sub-directory creation - * - * This function calls the [[_mk]] function to perform the operation - * - * @param {string} d sub directory name - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - mk(d: string): Promise; - /** - * Delete the file - * - * This function calls the [[_rm]] function to perform the operation - * - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - remove(): Promise; - /** - * Upload a file to the current directory - * - * Only work when the current file is a directory - * - * This function calls the [[_up]] function to perform the operation - * - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - upload(): Promise; - /** - * Share the file by publish it. - * - * Only work with file - * - * This function calls the [[_pub]] function to perform the operation - * - * @returns {Promise} promise on operation result - * @memberof BaseFileHandle - */ - publish(): Promise; - /** - * Download the file. - * - * Only work with file - * - * This function calls the [[_down]] function to perform the operation - * - * @returns {Promise} Promise on the operation result - * @memberof BaseFileHandle - */ - download(): Promise; - /** - * Move the current file to another location - * - * This function calls the [[_mv]] function to perform the operation - * - * @param {string} d destination location - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - move(d: string): Promise; - /** - * Execute the current file. - * - * This action depends on each file protocol - * - * This function calls the [[_exec]] function to perform the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - execute(): Promise; - /** - * Get an accessible link to the file - * that can be accessed from the browser - * - * @returns {string} - * @memberof BaseFileHandle - */ - getlink(): string; - /** - * Helper function returns a promise on unsupported action - * - * @param {string} t action name - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected unsupported(t: string): Promise; - /** - * Low level protocol-specific read operation - * - * This function should be overridden on the file handle class - * that supports the operation - * - * @protected - * @param {string} t data type, see [[read]] - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _rd(t: string): Promise; - /** - * Low level protocol-specific write operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @protected - * @param {string} t data type, see [[write]] - * @param {*} [d] - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _wr(t: string, d?: any): Promise; - /** - * Low level protocol-specific sub-directory creation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @protected - * @param {string} d sub directory name - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _mk(d: string): Promise; - /** - * Low level protocol-specific delete operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _rm(): Promise; - /** - * Low level protocol-specific move operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @protected - * @param {string} d - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _mv(d: string): Promise; - /** - * Low level protocol-specific upload operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _up(): Promise; - /** - * Low level protocol-specific download operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _down(): Promise; - /** - * Low level protocol-specific execute operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _exec(): Promise; - /** - * Low level protocol-specific share operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _pub(): Promise; - /** - * Read the current file meta-data - * - * should be implemented by subclasses - * - * @abstract - * @returns {Promise} - * @memberof BaseFileHandle - */ - abstract meta(): Promise; - } - /** - * Remote file handle allows to perform file operation - * on AntOS remote server files. Its protocol is defined - * by the following pattern: - * - * ``` - * ^(home|desktop|os|Untitled)$ - * ``` - * - * @class RemoteFileHandle - * @extends {BaseFileHandle} - */ - class RemoteFileHandle extends BaseFileHandle { - /** - *Creates an instance of RemoteFileHandle. - * @param {string} path file path - * @memberof RemoteFileHandle - */ - constructor(path: string); - /** - * Read remote file meta-data - * - * @returns {Promise} - * @memberof RemoteFileHandle - */ - meta(): Promise; - /** - * Remote file access link - * - * @returns {string} - * @memberof RemoteFileHandle - */ - getlink(): string; - /** - * Read remote file content. - * - * If the current file is a directory, then the operation - * will return the meta-data of all files inside of the directory. - * Otherwise, file content will be returned - * - * @protected - * @param {string} t data type see [[read]] - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _rd(t: string): Promise; - /** - * Write file cache to the remote file - * - * @protected - * @param {string} t data type see [[write]] - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _wr(t: string): Promise; - /** - * Create sub directory - * - * Only work on directory file handle - * - * @protected - * @param {string} d sub directory name - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _mk(d: string): Promise; - /** - * Delete file/folder - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _rm(): Promise; - /** - * Move file/folder - * - * @protected - * @param {string} d - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _mv(d: string): Promise; - /** - * Upload a file - * - * Only work with directory file handle - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _up(): Promise; - /** - * Download a file - * - * only work with file - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _down(): Promise; - /** - * Publish a file - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _pub(): Promise; - } - /** - * Package file is remote file ([[RemoteFileHandle]]) located either in - * the local user packages location or system packages - * location, it should be in the following format: - * - * ``` - * pkg://PKG_NAME/path/to/file - * - * ``` - * - * The system will locale the package name PKG_NAME either in the system domain - * or in user domain and return the correct path to the package - * - * @export - * @class PackageFileHandle - * @extends {RemoteFileHandle} - */ - class PackageFileHandle extends RemoteFileHandle { - /** - *Creates an instance of PackageFileHandle. - * @param {string} pkg_path package path in string - * @memberof PackageFileHandle - */ - constructor(pkg_path: string); - } - /** - * Application file is an AntOS special file allowing to - * refer to an application as a regular file. Its protocol - * pattern is defined as: - * - * ```typescript - * "^app$" // e.g. app://Setting - * ``` - * - * @class ApplicationHandle - * @extends {BaseFileHandle} - */ - class ApplicationHandle extends BaseFileHandle { - /** - *Creates an instance of ApplicationHandle. - * @param {string} path file path - * @memberof ApplicationHandle - */ - constructor(path: string); - /** - * Read application meta-data - * - * @returns {Promise} - * @memberof ApplicationHandle - */ - meta(): Promise; - /** - * If the current file is root (e.g. `app://`), the operation - * will return all system packages meta-data. - * - * Otherwise, an error will be thrown - * - * @protected - * @param {string} t - * @returns {Promise} - * @memberof ApplicationHandle - */ - protected _rd(t: string): Promise; - } - /** - * A buffer file handle represents a virtual file that is stored - * on the system memory. Its protocol pattern is defined as: - * - * ```typescript - * "^mem$" // e.g. mem://test.txt - * ``` - * - * @class BufferFileHandle - * @extends {BaseFileHandle} - */ - class BufferFileHandle extends BaseFileHandle { - /** - *Creates an instance of BufferFileHandle. - * @param {string} path file path - * @param {string} mime file mime-type - * @param {*} data file data - * @memberof BufferFileHandle - */ - constructor(path: string, mime: string, data: any); - /** - * Read the file meta-data - * - * @returns {Promise} - * @memberof BufferFileHandle - */ - meta(): Promise; - /** - * Read file content stored in the file cached - * - * @protected - * @param {string} t data type see [[read]] - * @returns {Promise} - * @memberof BufferFileHandle - */ - protected _rd(t: string): Promise; - /** - * Write data to the file cache - * - * @protected - * @param {string} t data type, see [[write]] - * @param {*} d data - * @returns {Promise} - * @memberof BufferFileHandle - */ - protected _wr(t: string, d: any): Promise; - /** - * Download the buffer file - * - * @protected - * @returns {Promise} - * @memberof BufferFileHandle - */ - protected _down(): Promise; - } - /** - * URL file handle represents a HTTP/HTTPs link url - * as an AntOS VFS file handle. Its protocol is defined as - * - * ``` - * ^(http|https|ftp)$ - * ``` - * - * @class URLFileHandle - * @extends {BaseFileHandle} - */ - class URLFileHandle extends BaseFileHandle { - /** - *Creates an instance of URLFileHandle. - * @param {string} path - * @memberof URLFileHandle - */ - constructor(path: string); - /** - * Read file meta-data - * - * @returns {Promise} - * @memberof URLFileHandle - */ - meta(): Promise; - /** - * Read URL content - * - * @protected - * @param {string} t data type see [[read]] - * @returns {Promise} - * @memberof URLFileHandle - */ - protected _rd(t: string): Promise; - } - /** - * Shared file handle represents all AntOS shared file. - * Its protocol is defined as: - * - * ``` - * ^shared$ - * ``` - * - * @class SharedFileHandle - * @extends {API.VFS.BaseFileHandle} - */ - class SharedFileHandle extends API.VFS.BaseFileHandle { - /** - *Creates an instance of SharedFileHandle. - * @param {string} path file path - * @memberof SharedFileHandle - */ - constructor(path: string); - /** - * Read file meta-data - * - * @returns {Promise} - * @memberof SharedFileHandle - */ - meta(): Promise; - /** - * Read file content - * - * @protected - * @param {string} t data type, see [[read]] - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _rd(t: string): Promise; - /** - * write data to shared file - * - * @protected - * @param {string} t data type, see [[write]] - * @param {string} d file data - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _wr(t: string, d: string): Promise; - /** - * Un-publish the file - * - * @protected - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _rm(): Promise; - /** - * Download shared file - * - * @protected - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _down(): Promise; - /** - * Un publish the file - * - * @protected - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _pub(): Promise; - } - /**Utilities global functions */ - /** - * Read a file content from a zip archive - * - * The content type should be: - * - base64 : the result will be a string, the binary in a base64 form. - * - text (or string): the result will be an unicode string. - * - binarystring: the result will be a string in “binary” form, using 1 byte per char (2 bytes). - * - array: the result will be an Array of bytes (numbers between 0 and 255). - * - uint8array : the result will be a Uint8Array. This requires a compatible browser. - * - arraybuffer : the result will be a ArrayBuffer. This requires a compatible browser. - * - blob : the result will be a Blob. This requires a compatible browser. * - * If file_name is not specified, the first file_name in the zip archive will be read - * @export - * @param {string} file zip file - * @param {string} type content type to read - * @param {string} [file_name] the file should be read from the zip archive - * @return {*} {Promise} - */ - function readFileFromZip(file: string, type: string, file_name?: string): Promise; - /** - * Cat all files to a single out-put - * - * @export - * @param {string[]} list list of VFS files - * @param {string} data input data string that will be cat to the files content - * @param {string} join_by join on files content by this string - * @return {*} {Promise} - */ - function cat(list: string[], data: string, join_by?: string): Promise; - /** - * Read all files content on the list - * - * @export - * @param {string[]} list list of VFS files - * @param {GenericObject[]} contents content array - * @return {void} - */ - function read_files(list: string[]): Promise[]>; - /** - * Copy files to a folder - * - * @export - * @param {string[]} files list of files - * @param {string} to destination folder - * @return {*} {Promise} - */ - function copy(files: string[], to: string): Promise; - /** - * Create a zip archive from a folder - * - * @export - * @param {string} src source file/folder - * @param {string} dest destination archive - * @return {*} {Promise} - */ - function mkar(src: string, dest: string): Promise; - /** - * Create a list of directories - * - * @export - * @param {string[]} list of directories to be created - * @param {boolen} sync sync/async of directory creation - * @return {*} {Promise} - */ - function mkdirAll(list: string[], sync?: boolean): Promise; - /** - * - * - * @export Extract a zip fle - * @param {string} zfile zip file to extract - * @param {(zip:any) => Promise} [dest_callback] a callback to get extraction destination - * @return {*} {Promise} - */ - function extractZip(zfile: string | API.VFS.BaseFileHandle, dest_callback: (zip: any) => Promise): Promise; - /** - * Make files from a set of template files - * - * @export - * @param {Array} list mapping paths between templates files and created files - * @param {string} path files destination - * @param {(data: string) => string} callback: pre-processing files content before writing to destination files - * @return {*} {Promise} - */ - function mktpl(list: Array, path: string, callback: (data: string) => string): Promise; - } - } -} -/// -declare namespace OS { - /** - * This namespace is dedicated to application and service definition. - * When an application is loaded, its prototype definition will be - * inserted to this namespace for reuse lately - */ - namespace application { - /** - * Abstract prototype of all AntOS applications. - * Any new application definition should extend - * this prototype - * - * @export - * @abstract - * @class BaseApplication - * @extends {BaseModel} - */ - abstract class BaseApplication extends BaseModel { - /** - * Placeholder of all settings specific to the application. - * The settings stored in this object will be saved to system - * setting when logout and can be reused in the next login session - * - * @type {GenericObject} - * @memberof BaseApplication - */ - setting: GenericObject; - /** - * Hotkeys (shortcuts) defined for this application - * - * @protected - * @type {GUI.ShortcutType} - * @memberof BaseApplication - */ - protected keycomb: GUI.ShortcutType; - /** - * Reference to the system dock - * - * @type {GUI.tag.AppDockTag} - * @memberof BaseApplication - */ - sysdock: GUI.tag.AppDockTag; - /** - * Reference to the system application menu located - * on the system panel - * - * @type {GUI.tag.MenuTag} - * @memberof BaseApplication - */ - appmenu: GUI.tag.MenuTag; - /** - *Creates an instance of BaseApplication. - * @param {string} name application name - * @param {AppArgumentsType[]} args application arguments - * @memberof BaseApplication - */ - constructor(name: string, args: AppArgumentsType[]); - /** - * Init the application, this function is called when the - * application process is created and docked in the application - * dock. - * - * The application UI will be rendered after the execution - * of this function. - * - * @returns {void} - * @memberof BaseApplication - */ - init(): void; - /** - * Render the application UI by first loading its scheme - * and then mount this scheme to the DOM tree - * - * @protected - * @returns {void} - * @memberof BaseApplication - */ - protected loadScheme(): void; - /** - * API function to perform an heavy task. - * This function will trigger the global `loading` - * event at the beginning of the task, and the `loaded` - * event after finishing the task - * - * @protected - * @param {Promise} promise the promise on a task to be performed - * @returns {Promise} - * @memberof BaseApplication - */ - protected load(promise: Promise): Promise; - /** - * Bind a hotkey to the application, this function - * is used to define application keyboard shortcut - * - * @protected - * @param {string} k the hotkey to bind, should be in the following - * format: `[ALT|SHIFT|CTRL|META]-KEY`, e.g. `CTRL-S` - * @param {(e: JQuery.KeyboardEventBase) => void} f the callback function - * @returns {void} - * @memberof BaseApplication - */ - protected bindKey(k: string, f: (e: JQuery.KeyboardEventBase) => void): void; - /** - * Update the application local from the system - * locale or application specific locale configuration - * - * @param {string} name locale name e.g. `en_GB` - * @returns {void} - * @memberof BaseApplication - */ - updateLocale(name: string): void; - /** - * Execute the callback subscribed to a - * keyboard shortcut - * - * @param {string} fnk meta or modifier key e.g. `CTRL`, `ALT`, `SHIFT` or `META` - * @param {string} c a regular key - * @param {JQuery.KeyDownEvent} e JQuery keyboard event - * @returns {boolean} return whether the shortcut is executed - * @memberof BaseApplication - */ - shortcut(fnk: string, c: string, e: JQuery.KeyDownEvent): boolean; - /** - * Apply a setting to the application - * - * @protected - * @param {string} k the setting name - * @memberof BaseApplication - */ - protected applySetting(k: string): void; - /** - * Apply all settings to the application - * - * @protected - * @memberof BaseApplication - */ - protected applyAllSetting(): void; - /** - * Set a setting value to the application setting - * registry - * - * @protected - * @param {string} k setting name - * @param {*} v setting value - * @returns {void} - * @memberof BaseApplication - */ - protected registry(k: string, v: any): void; - /** - * Show the appliation - * - * @returns {void} - * @memberof BaseApplication - */ - show(): void; - /** - * Blur the application - * - * @returns {void} - * @memberof BaseApplication - */ - blur(): void; - /** - * Hide the application - * - * @returns {void} - * @memberof BaseApplication - */ - hide(): void; - /** - * Maximize or restore the application window size - * and its position - * - * @returns {void} - * @memberof BaseApplication - */ - toggle(): void; - /** - * Get the application title - * - * @returns {(string| FormattedString)} - * @memberof BaseApplication - */ - title(): string | FormattedString; - /** - * Function called when the application exit. - * If the input exit event is prevented, the application - * process will not be killed - * - * - * @protected - * @param {BaseEvent} evt exit event - * @memberof BaseApplication - */ - protected onexit(evt: BaseEvent): void; - /** - * Get the application meta-data - * - * @returns {API.PackageMetaType} - * @memberof BaseApplication - */ - meta(): API.PackageMetaType; - /** - * Base menu definition. This function - * returns the based menu definition of all applications. - * Other application specific menu entries - * should be defined in [[menu]] function - * - * @protected - * @returns {GUI.BasicItemType[]} - * @memberof BaseApplication - */ - protected baseMenu(): GUI.BasicItemType[]; - /** - * The main application entry that is called after - * the application UI is rendered. This application - * must be implemented by all subclasses - * - * @abstract - * @memberof BaseApplication - */ - abstract main(): void; - /** - * Application specific menu definition - * - * @protected - * @returns {GUI.BasicItemType[]} - * @memberof BaseApplication - */ - protected menu(): GUI.BasicItemType[]; - /** - * The cleanup function that is called by [[onexit]] function. - * Application need to override this function to perform some - * specific task before exiting or to prevent the application - * to be exited - * - * @protected - * @param {BaseEvent} e - * @memberof BaseApplication - */ - protected cleanup(e: BaseEvent): void; - } - } -} /** * Reference to the global this */ @@ -3517,6 +1408,13 @@ interface Date { * @memberof Date */ timestamp(): number; + /** + * Covnert to GMTString + * + * @returns {number} + * @memberof Date + */ + toGMTString(): string; } /** * Generic key-value pair object interface @@ -4322,6 +2220,274 @@ declare namespace OS { } } /// +declare namespace OS { + /** + * This namespace is dedicated to application and service definition. + * When an application is loaded, its prototype definition will be + * inserted to this namespace for reuse lately + */ + namespace application { + /** + * Abstract prototype of all AntOS applications. + * Any new application definition should extend + * this prototype + * + * @export + * @abstract + * @class BaseApplication + * @extends {BaseModel} + */ + abstract class BaseApplication extends BaseModel { + /** + * Placeholder of all settings specific to the application. + * The settings stored in this object will be saved to system + * setting when logout and can be reused in the next login session + * + * @type {GenericObject} + * @memberof BaseApplication + */ + setting: GenericObject; + /** + * Hotkeys (shortcuts) defined for this application + * + * @protected + * @type {GUI.ShortcutType} + * @memberof BaseApplication + */ + protected keycomb: GUI.ShortcutType; + /** + * Reference to the system dock + * + * @type {GUI.tag.AppDockTag} + * @memberof BaseApplication + */ + sysdock: GUI.tag.AppDockTag; + /** + * Reference to the system application menu located + * on the system panel + * + * @type {GUI.tag.MenuTag} + * @memberof BaseApplication + */ + appmenu: GUI.tag.MenuTag; + /** + * Loading animation check timeout + * + * @private + * @memberof BaseApplication + */ + private _loading_toh; + /** + * Store pending loading task + * + * @private + * @type {number[]} + * @memberof BaseApplication + */ + private _pending_task; + /** + *Creates an instance of BaseApplication. + * @param {string} name application name + * @param {AppArgumentsType[]} args application arguments + * @memberof BaseApplication + */ + constructor(name: string, args: AppArgumentsType[]); + /** + * Init the application, this function is called when the + * application process is created and docked in the application + * dock. + * + * The application UI will be rendered after the execution + * of this function. + * + * @returns {void} + * @memberof BaseApplication + */ + init(): void; + /** + * Render the application UI by first loading its scheme + * and then mount this scheme to the DOM tree + * + * @protected + * @returns {void} + * @memberof BaseApplication + */ + protected loadScheme(): void; + /** + * API function to perform an heavy task. + * This function will trigger the global `loading` + * event at the beginning of the task, and the `loaded` + * event after finishing the task + * + * @protected + * @param {Promise} promise the promise on a task to be performed + * @returns {Promise} + * @memberof BaseApplication + */ + protected load(promise: Promise): Promise; + /** + * Bind a hotkey to the application, this function + * is used to define application keyboard shortcut + * + * @protected + * @param {string} k the hotkey to bind, should be in the following + * format: `[ALT|SHIFT|CTRL|META]-KEY`, e.g. `CTRL-S` + * @param {(e: JQuery.KeyboardEventBase) => void} f the callback function + * @returns {void} + * @memberof BaseApplication + */ + protected bindKey(k: string, f: (e: JQuery.KeyboardEventBase) => void): void; + /** + * Update the application local from the system + * locale or application specific locale configuration + * + * @param {string} name locale name e.g. `en_GB` + * @returns {void} + * @memberof BaseApplication + */ + updateLocale(name: string): void; + /** + * Execute the callback subscribed to a + * keyboard shortcut + * + * @param {string} fnk meta or modifier key e.g. `CTRL`, `ALT`, `SHIFT` or `META` + * @param {string} c a regular key + * @param {JQuery.KeyDownEvent} e JQuery keyboard event + * @returns {boolean} return whether the shortcut is executed + * @memberof BaseApplication + */ + shortcut(fnk: string, c: string, e: JQuery.KeyDownEvent): boolean; + /** + * Apply a setting to the application + * + * @protected + * @param {string} k the setting name + * @memberof BaseApplication + */ + protected applySetting(k: string): void; + /** + * Apply all settings to the application + * + * @protected + * @memberof BaseApplication + */ + protected applyAllSetting(): void; + /** + * Set a setting value to the application setting + * registry + * + * @protected + * @param {string} k setting name + * @param {*} v setting value + * @returns {void} + * @memberof BaseApplication + */ + protected registry(k: string, v: any): void; + /** + * Show the appliation + * + * @returns {void} + * @memberof BaseApplication + */ + show(): void; + /** + * Blur the application + * + * @returns {void} + * @memberof BaseApplication + */ + blur(): void; + /** + * Hide the application + * + * @returns {void} + * @memberof BaseApplication + */ + hide(): void; + /** + * Maximize or restore the application window size + * and its position + * + * @returns {void} + * @memberof BaseApplication + */ + toggle(): void; + /** + * Get the application title + * + * @returns {(string| FormattedString)} + * @memberof BaseApplication + */ + title(): string | FormattedString; + /** + * Function called when the application exit. + * If the input exit event is prevented, the application + * process will not be killed + * + * + * @protected + * @param {BaseEvent} evt exit event + * @memberof BaseApplication + */ + protected onexit(evt: BaseEvent): void; + /** + * Get the application meta-data + * + * @returns {API.PackageMetaType} + * @memberof BaseApplication + */ + meta(): API.PackageMetaType; + /** + * Base menu definition. This function + * returns the based menu definition of all applications. + * Other application specific menu entries + * should be defined in [[menu]] function + * + * @protected + * @returns {GUI.BasicItemType[]} + * @memberof BaseApplication + */ + protected baseMenu(): GUI.BasicItemType[]; + /** + * The main application entry that is called after + * the application UI is rendered. This application + * must be implemented by all subclasses + * + * @abstract + * @memberof BaseApplication + */ + abstract main(): void; + /** + * Application specific menu definition + * + * @protected + * @returns {GUI.BasicItemType[]} + * @memberof BaseApplication + */ + protected menu(): GUI.BasicItemType[]; + /** + * The cleanup function that is called by [[onexit]] function. + * Application need to override this function to perform some + * specific task before exiting or to prevent the application + * to be exited + * + * @protected + * @param {BaseEvent} e + * @memberof BaseApplication + */ + protected cleanup(e: BaseEvent): void; + /** + * Check if the loading tasks ended, + * if it the case, stop the animation + * + * @private + * @memberof BaseApplication + */ + private animation_check; + } + } +} +/// declare namespace OS { /** * Application argument type definition @@ -4835,266 +3001,1512 @@ declare namespace OS { } } declare namespace OS { - namespace API { - /** - * Simple Virtual Database (VDB) application API. - * - * This API abstracts and provides a standard way to - * connect to a server-side relational database (e.g. sqlite). - * - * Each user when connected has their own database previously - * created. All VDB operations related to that user will be - * performed on this database. - * - * The creation of user database need to be managed by the server-side API. - * The VDB API assumes that the database already exist. All operations - * is performed in tables level - * - * @export - * @class DB - */ - class DB { + namespace GUI { + namespace tag { /** - * A table name on the user's database + * A switch tag is basically used to visualize an boolean data value. * - * @private - * @type {string} - * @memberof DB + * @export + * @class SwitchTag + * @extends {AFXTag} */ - private table; - /** - *Creates an instance of DB. - * @param {string} table table name - * @memberof DB - */ - constructor(table: string); - /** - * Save data to the current table. The input - * data must conform to the table record format. - * - * On the server side, if the table doest not - * exist yet, it should be created automatically - * by inferring the data structure of the input - * object - * - * @param {GenericObject} d data object represents a current table record - * @returns {Promise} - * @memberof DB - */ - save(d: GenericObject): Promise; - /** - * delete record(s) from the current table by - * a conditional object - * - * @param {*} c conditional object, c can be: - * - * * a `number`: the operation will delete the record with `id = c` - * * a `string`: The SQL string condition that selects record to delete - * * a conditional object represents a SQL condition statement as an object, - * example: `pid = 10 AND cid = 2` is represented by: - * - * ```typescript - * { - * exp: { - * "and": { - * pid: 10, - * cid: 2 - * } - * } - * ``` - * - * @returns {Promise} - * @memberof DB - */ - delete(c: GenericObject | number | string): Promise; - /** - * Get a record in the table by its primary key - * - * @param {number} id the primary key value - * @returns {Promise>} Promise on returned record data - * @memberof DB - */ - get(id: number): Promise>; - /** - * Find records by a condition - * - * @param {GenericObject} cond conditional object - * - * a conditional object represents a SQL condition statement as an object, - * example: `pid = 10 AND cid = 2 ORDER BY date DESC` is represented by: - * - * ```typescript - * { - * exp: { - * "and": { - * pid: 10, - * cid: 2 - * } - * }, - * order: { - * date: "DESC" - * } - * } - * ``` - * @returns {Promise[]>} - * @memberof DB - */ - find(cond: GenericObject): Promise[]>; + class SwitchTag extends AFXTag { + /** + * Placeholder for the onchange event handle + * + * @private + * @type {TagEventCallback} + * @memberof SwitchTag + */ + private _onchange; + /** + * Setter: Turn on/off the switch + * + * Getter: Check whether the switch is turned on + * + * @memberof SwitchTag + */ + set swon(v: boolean); + get swon(): boolean; + /** + * Setter: Enable the switch + * + * Getter: Check whether the switch is enabled + * + * @memberof SwitchTag + */ + set enable(v: boolean); + get enable(): boolean; + /** + * Set the onchange event handle + * + * @memberof SwitchTag + */ + set onswchange(v: TagEventCallback); + /** + * Mount the tag and bind the click event to the switch + * + * @protected + * @memberof SwitchTag + */ + protected mount(): void; + /** + * This function will turn the switch (on/off) + * and trigger the onchange event + * + * @private + * @param {JQuery.ClickEvent} e + * @returns + * @memberof SwitchTag + */ + private makechange; + /** + * Tag layout definition + * + * @protected + * @returns + * @memberof SwitchTag + */ + protected layout(): { + el: string; + ref: string; + }[]; + /** + * Init the tag: + * - switch is turn off + * - switch is enabled + * + * @protected + * @memberof SwitchTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @memberof SwitchTag + */ + protected calibrate(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof SwitchTag + */ + protected reload(d?: any): void; + } } } } declare namespace OS { namespace GUI { - /** - * - * Interface for an application dock item - * - * @export - * @interface AppDockItemType - */ - interface AppDockItemType { - /** - * Reference to the application process represented - * by the dock item - * - * @type {application.BaseApplication} - * @memberof AppDockItemType - */ - app: application.BaseApplication; - /** - * Reference to the DOM element of - * the owner dock item - * - * @type {AFXTag} - * @memberof AppDockItemType - */ - domel?: AFXTag; - [propName: string]: any; - } namespace tag { /** - * This class define the AntOS system application dock tag + * Definition of system file view widget * * @export - * @class AppDockTag + * @class FileViewTag * @extends {AFXTag} */ - class AppDockTag extends AFXTag { + class FileViewTag extends AFXTag { /** - * variable holds the application select event - * callback handle + * placeholder for file select event callback * * @private - * @type {TagEventCallback} - * @memberof AppDockTag + * @type {TagEventCallback} + * @memberof FileViewTag */ - private _onappselect; + private _onfileselect; /** - * Items data of the dock + * placeholder for file open event callback * * @private - * @type {AppDockItemType[]} - * @memberof AppDockTag + * @type {TagEventCallback} + * @memberof FileViewTag */ - private _items; + private _onfileopen; /** - * Reference to the currently select application - * process in the dock + * Reference to the all selected files meta-datas * * @private - * @type {AppDockItemType} - * @memberof AppDockTag + * @type {API.FileInfoType[]} + * @memberof FileViewTag */ - private _selectedItem; + private _selectedFiles; /** - *Creates an instance of AppDockTag. - * @memberof AppDockTag + * Data placeholder of the current working directory + * + * @private + * @type {API.FileInfoType[]} + * @memberof FileViewTag + */ + private _data; + /** + * The path of the current working directory + * + * @private + * @type {string} + * @memberof FileViewTag + */ + private _path; + /** + * Header definition of the widget grid view + * + * @private + * @type {(GenericObject[])} + * @memberof FileViewTag + */ + private _header; + /** + * placeholder for the user-specified meta-data fetch function + * + * @private + * @memberof FileViewTag + */ + private _fetch; + /** + *Creates an instance of FileViewTag. + * @memberof FileViewTag */ constructor(); /** - * Implementation of the abstract function: Update the current tag. - * It do nothing for this tag + * Init the widget before mounting * * @protected - * @param {*} [d] - * @memberof AppDockTag - */ - protected reload(d?: any): void; - /** - * Init the tag before mounting - * - * @protected - * @memberof AppDockTag + * @memberof FileViewTag */ protected init(): void; /** - * The tag layout, it is empty on creation but elements will - * be added automatically to it in operation + * Update the current widget, do nothing * * @protected - * @returns {TagLayoutType[]} - * @memberof AppDockTag + * @param {*} [d] + * @memberof FileViewTag */ - protected layout(): TagLayoutType[]; + protected reload(d?: any): void; /** - * getter to get the dock items + * set the function that allows to fetch file entries. + * This handle function should return a promise on + * an arry of [[API.FileInfoType]] * - * @readonly - * @type {AppDockItemType[]} - * @memberof AppDockTag + * @memberof FileViewTag */ - get items(): AppDockItemType[]; + set fetch(v: (p: string) => Promise); + /** + * set the callback handle for the file select event. + * The parameter of the callback should be an object + * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] + * + * @memberof FileViewTag + */ + set onfileselect(e: TagEventCallback); + /** + set the callback handle for the file open event. + * The parameter of the callback should be an object + * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] + * + * @memberof FileViewTag + */ + set onfileopen(e: TagEventCallback); /** * Setter: * - * set the selected application in the dock - * this will trigger two event: - * - `focus`: on the selected application - * - `blur`: on all other applications on the dock + * chang the view of the widget, there are three different views + * - `icon` + * - `list` + * - `tree` * * Getter: * - * Get the current selected application - * on the dock + * Get the current view setting of the widget * - * @memberof AppDockTag + * @memberof FileViewTag */ - set selectedApp(v: application.BaseApplication); - get selectedApp(): application.BaseApplication; + set view(v: string); + get view(): string; /** - * Get selected item of the dock + * Setter: + * + * Turn on/off the changing current working directory feature + * of the widget when a directory is double clicked. If enabled, + * the widget will use the configured [[fetch]] function to query + * the content of the selected directory + * + * Getter: + * + * check whether changing current working directory feature + * is enabled + * + * @memberof FileViewTag + */ + set chdir(v: boolean); + get chdir(): boolean; + /** + * Setter : Enable or disable the status bar of the widget + * + * Getter: Check whether the status bar is enabled + * + * @memberof FileViewTag + */ + set status(v: boolean); + get status(): boolean; + /** + * Setter: + * + * Allow the widget to show or hide hidden file + * + * Getter: + * + * Check whether the hidden file should be shown in + * the widget + * + * @memberof FileViewTag + */ + set showhidden(v: boolean); + get showhidden(): boolean; + /** + * Setter: + * + * Allow multiple selection on file view + * + * Getter: + * + * Check whether the multiselection is actived + * + * @memberof FileViewTag + */ + set multiselect(v: boolean); + get multiselect(): boolean; + /** + * Get the current selected file * * @readonly - * @type {AppDockItemType} - * @memberof AppDockTag + * @type {API.FileInfoType} + * @memberof FileViewTag */ - get selectedItem(): AppDockItemType; + get selectedFile(): API.FileInfoType; /** - * When a new application process is created, this function - * will be called to add new application entry to the dock. - * The added application will becomes the current selected - * application + * Get all selected files * - * @param {AppDockItemType} item an application dock item entry - * @memberof AppDockTag + * @readonly + * @type {API.FileInfoType[]} + * @memberof FileViewTag */ - newapp(item: AppDockItemType): void; + get selectedFiles(): API.FileInfoType[]; /** - * Delete and application entry from the dock. - * This function will be called when an application - * is exit + * Setter: * - * @param {BaseApplication} a the application to be removed from the dock - * @memberof AppDockTag + * Set the path of the current working directory. + * When called the widget will refresh the current + * working directory using the configured [[fetch]] + * function + * + * Getter: + * + * Get the path of the current working directory + * + * @memberof FileViewTag */ - removeapp(a: application.BaseApplication): void; + set path(v: string); + get path(): string; /** - * Mount the current dock tag + * Setter: Set the data of the current working directory + * + * Getter: Get the data of the current working directory + * + * @memberof FileViewTag + */ + set data(v: API.FileInfoType[]); + get data(): API.FileInfoType[]; + /** + * Set the file drag and drop event handle. This allows application + * to define custom behavior of the event + * + * @memberof FileViewTag + */ + set ondragndrop(v: TagEventCallback>); + /** + * Sort file by its type + * + * @private + * @param {API.FileInfoType} a + * @param {API.FileInfoType} b + * @return {*} {number} + * @memberof FileViewTag + */ + private sortByType; + /** + * sort file by its name + * + * @private + * @param {API.FileInfoType} a first file meta-data + * @param {API.FileInfoType} b second file meta-data + * @returns {number} + * @memberof FileViewTag + */ + private sortByName; + /** + * calibrate the widget layout + * + * @memberof FileViewTag + */ + calibrate(): void; + /** + * Refresh the list view of the widget. This function + * is called when the view of the widget changed to `icon` + * + * @private + * @memberof FileViewTag + */ + private refreshList; + /** + * Refresh the grid view of the widget, this function is called + * when the view of the widget set to `list` + * + * @private + * @memberof FileViewTag + */ + private refreshGrid; + /** + * Refresh the Treeview of the widget, this function is called + * when the view of the widget set to `tree` + * + * @private + * @memberof FileViewTag + */ + private refreshTree; + /** + * Create the tree data from the list of input + * file meta-data + * + * @private + * @param {API.FileInfoType[]} data list of file meta-data + * @returns {TreeViewDataType[]} + * @memberof FileViewTag + */ + private getTreeData; + /** + * Refresh data of the current widget view + * + * @private + * @returns {void} + * @memberof FileViewTag + */ + private refreshData; + /** + * Switch between three view options + * + * @private + * @memberof FileViewTag + */ + private switchView; + /** + * This function triggers the file select event + * + * @private + * @param {API.FileInfoType} e selected file meta-data + * @memberof FileViewTag + */ + private fileselect; + /** + * This function triggers the file open event + * + * @private + * @param {API.FileInfoType} e selected file meta-data + * @memberof FileViewTag + */ + private filedbclick; + /** + * Mount the widget in the DOM tree * * @protected - * @memberof AppDockTag + * @memberof FileViewTag */ protected mount(): void; + /** + * Layout definition of the widget + * + * @protected + * @returns {TagLayoutType[]} + * @memberof FileViewTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +/// +/** + * + * Extend the HTMLElement interface with some utility function need + * by AFX API + * + * @interface HTMLElement + */ +interface HTMLElement { + /** + * Recursively update a tag and all its children + * + * @param {*} [d] data to send to all element in the DOM subtree + * @memberof HTMLElement + */ + update(d?: any): void; + /** + * + * AFX will automatically bind the context menu on an HTMLElement + * if this function is defined on that element. The function should + * define the content of the context menu and its action + * + * Once the context menu is bound to the element, all context menu handle + * defined on any child of this element will be ignored. + * + * @param {JQuery.MouseEventBase} e a mouse event + * @param {OS.GUI.tag.MenuTag} m The context menu element [[MenuTag]] + * @memberof HTMLElement + */ + contextmenuHandle(e: JQuery.MouseEventBase, m: OS.GUI.tag.MenuTag): void; + /** + * Mount the element and all the children on its DOM subtree. This action + * is performed in a top-down manner + * + * @memberof HTMLElement + */ + sync(): void; + /** + * + * This action allows to generated all the DOM nodes defined by all AFX tags + * in its hierarchy. + * It performs two operations, one top-down operation to generate all the + * necessary DOM nodes, another bottom-up operation to init all the AFX tag + * in the current element DOM hierarchy + * + * @param {OS.API.Announcer} o an AntOS observable object + * @memberof HTMLElement + */ + afxml(o: OS.API.Announcer): void; + /** + * Perform DOM generation ([[afxml]]) then mount ([[sync]]) all the + * elements. + * + * @param {OS.API.Announcer} o an AntOS observable object + * @param {boolean} [flag] indicates whether this is the top-most call of the operation + * @memberof HTMLElement + */ + uify(o: OS.API.Announcer, flag?: boolean): void; + /** + * + * + * @type {*} + * @memberof HTMLElement + */ + mozRequestFullScreen: any; + /** + * + * + * @type {*} + * @memberof HTMLElement + */ + webkitRequestFullscreen: any; + /** + * + * + * @type {*} + * @memberof HTMLElement + */ + msRequestFullscreen: any; +} +/** + * + * + * @interface Document + */ +interface Document { + mozCancelFullScreen: any; + webkitExitFullscreen: any; + cancelFullScreen: any; +} +declare namespace OS { + namespace GUI { + /** + * [[TagLayoutType]] interface using by AFX tags to defined + * its internal DOM hierarchy + * + * @export + * @interface TagLayoutType + */ + interface TagLayoutType { + /** + * Element tag name + * + * @type {string} + * @memberof TagLayoutType + */ + el: string; + /** + * Children layout of the current element + * + * @type {TagLayoutType[]} + * @memberof TagLayoutType + */ + children?: TagLayoutType[]; + /** + * Reference name of the element used by AFX Tag + * + * @type {string} + * @memberof TagLayoutType + */ + ref?: string; + /** + * CSS class of the element + * + * @type {string} + * @memberof TagLayoutType + */ + class?: string; + /** + * this is the `data-id` attribute of the element, + * can be query by the [[aid]] Tag API function. + * Not to be confused with the DOM `id` attribute + * + * @type {(string | number)} + * @memberof TagLayoutType + */ + id?: string | number; + /** + * Tooltip text of the element + * + * @type {(string | FormattedString)} + * @memberof TagLayoutType + */ + tooltip?: string | FormattedString; + /** + * `data-width` of the element, not to be confused with + * the `width` attribute of the DOM element + * + * @type {number|string} + * @memberof TagLayoutType + */ + width?: number | string; + /** + ** `data-height` of the element, not to be confused with + * the `height` attribute of the DOM element + * + * @type {number|string} + * @memberof TagLayoutType + */ + height?: number | string; + } + /** + * Data type for event issued by AFX tags + * + * @export + * @interface TagEventDataType + * @template T item template + */ + interface TagEventDataType { + /** + * Reference to the item involved in the event + * + * @type {T} + * @memberof TagEventDataType + */ + item?: T; + [propName: string]: any; + } + /** + * Format of the event issued by AFX tags + * + * @export + * @interface TagEventType + * @template T data type + */ + interface TagEventType { + /** + * `data-id` of the tag that trigger the + * event + * + * @type {(number | string)} + * @memberof TagEventType + */ + id: number | string; + /** + * Data object of the event + * + * @type {T} + * @memberof TagEventType + */ + data: T; + } + /** + * Drag and Drop data type sent between mouse events + * + * @export + * @interface DnDEventDataType + * @template T + */ + interface DnDEventDataType { + /** + * Reference to the source DOM element + * + * @type {T} + * @memberof DnDEventDataType + */ + from: T[]; + /** + * Reference to the target DOM element + * + * @type {T} + * @memberof DnDEventDataType + */ + to: T; + } + /** + * Tag event callback type + */ + type TagEventCallback = (e: TagEventType) => void; + /** + * Base abstract class for tag implementation, any AFX tag should be + * subclass of this class + * + * @export + * @abstract + * @class AFXTag + * @extends {HTMLElement} + */ + abstract class AFXTag extends HTMLElement { + /** + * The announcer object of the tag + * + * @type {API.Announcer} + * @memberof AFXTag + */ + observable: API.Announcer; + /** + * Reference to some of the tag's children + * element. This reference object is built + * based on the `ref` property found in the + * tag layout [[TagLayoutType]] + * + * @protected + * @type {GenericObject} + * @memberof AFXTag + */ + protected refs: GenericObject; + /** + * boolean value indicated whether the tag + * is already mounted in the DOM tree + * + * @protected + * @type {boolean} + * @memberof AFXTag + */ + protected _mounted: boolean; + /** + *Creates an instance of AFXTag. + * @memberof AFXTag + */ + constructor(); + /** + * This function verifies if a property name of the input object + * corresponds to a setter of the current tag. If this is the + * case, it sets the value of that property to the setter + * + * @param {GenericObject} v input object + * @memberof AFXTag + */ + set(v: GenericObject): void; + /** + * Setter to set the tooltip text to the current tag. + * The text should be in the following format: + * ```text + * cr|cl|ct|cb: tooltip text + * ``` + * + * @memberof AFXTag + */ + set tooltip(v: string); + /** + * + * This function looking for a property name of the tag + * in its prototype chain. The descriptor of the property + * will be returned if it exists + * + * @private + * @param {string} k the property name to be queried + * @returns {PropertyDescriptor} the property descriptor or undefined + * @memberof AFXTag + */ + private descriptor_of; + /** + * Setter: set the id of the tag in string or number + * + * Getter: get the id of the current tag + * + * @memberof AFXTag + */ + set aid(v: string | number); + get aid(): string | number; + /** + * Implementation from HTMLElement interface, + * this function mount the current tag hierarchy + * + * @returns {void} + * @memberof AFXTag + */ + sync(): void; + /** + * Generate the DOM hierarchy of the current tag + * + * @param {API.Announcer} o observable object + * @memberof AFXTag + */ + afxml(o: API.Announcer): void; + /** + * Update the current tag hierarchy + * + * @param {*} d any data object + * @memberof AFXTag + */ + update(d: any): void; + /** + * Init the current tag, this function + * is called before the [[mount]] function + * + * @protected + * @abstract + * @memberof AFXTag + */ + protected abstract init(): void; + /** + * Mount only the current tag + * + * @protected + * @abstract + * @memberof AFXTag + */ + protected abstract mount(): void; + /** + * Layout definition of a tag + * + * @protected + * @abstract + * @returns {TagLayoutType[]} tag layout object + * @memberof AFXTag + */ + protected abstract layout(): TagLayoutType[]; + /** + * Update only the current tag, this function is + * called by [[update]] before chaining the + * update process to its children + * + * @protected + * @abstract + * @param {*} [d] + * @memberof AFXTag + */ + protected abstract reload(d?: any): void; + /** + * This function is used to re-render the current + * tag + * + * @protected + * @memberof AFXTag + */ + protected calibrate(): void; + /** + * This function parses the input layout object + * and generates all the elements defined by + * the tag + * + * @private + * @param {TagLayoutType} tag tag layout object + * @returns {Element} the DOM element specified by the tag layout + * @memberof AFXTag + */ + private mkui; + /** + * This function inserts or removes an attribute name + * to/from the target element based on the input `flag`. + * + * @protected + * @param {boolean} flag indicates whether the attribute name should be inserted o removed + * @param {string} v the attribute name + * @param {HTMLElement} [el] the target element + * @memberof AFXTag + */ + protected attsw(flag: boolean, v: string, el?: HTMLElement): void; + /** + * Insert the attribute name to the target element + * + * @protected + * @param {string} v the attribute name + * @param {HTMLElement} [el] the target element + * @memberof AFXTag + */ + protected atton(v: string, el?: HTMLElement): void; + /** + * Remove the attribute name from the target element + * + * @protected + * @param {string} v attribute name + * @param {HTMLElement} [el] the target element + * @memberof AFXTag + */ + protected attoff(v: string, el?: HTMLElement): void; + /** + * Verify if the target element has an attribute name + * + * @protected + * @param {string} v attribute name + * @param {HTMLElement} [el] target element + * @returns {boolean} + * @memberof AFXTag + */ + protected hasattr(v: string, el?: HTMLElement): boolean; + } + /** + * All the AFX tags are defined in this namespace, + * these tags are defined as custom DOM elements and will be + * stored in the `customElements` registry of the browser + */ + namespace tag { + /** + * Define an AFX tag as a custom element and add it to the + * global `customElements` registry. If the tag is redefined, i.e. + * the tag already exists, its behavior will be updated with the + * new definition + * + * @export + * @template T all classes that extends [[AFXTag]] + * @param {string} name name of the tag + * @param {{ new (): T }} cls the class that defines the tag + * @returns {void} + */ + function define(name: string, cls: { + new (): T; + }): void; + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * List item event data type + */ + type ListItemEventData = TagEventDataType; + /** + * A list item represent the individual view of an item in the [[ListView]]. + * This class is an abstract prototype class, implementation of any + * list view item should extend it + * + * + * @export + * @abstract + * @class ListViewItemTag + * @extends {AFXTag} + */ + abstract class ListViewItemTag extends AFXTag { + /** + * Data placeholder for the list item + * + * @private + * @type {GenericObject} + * @memberof ListViewItemTag + */ + private _data; + /** + * placeholder for the item select event callback + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onselect; + /** + * Context menu event callback handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onctxmenu; + /** + * Click event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onclick; + /** + * Double click event callback handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _ondbclick; + /** + * Item close event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onclose; + /** + *Creates an instance of ListViewItemTag. + * @memberof ListViewItemTag + */ + constructor(); + /** + * Setter: Turn on/off the `closable` feature of the list item + * + * Getter: Check whether the item is closable + * + * @memberof ListViewItemTag + */ + set closable(v: boolean); + get closable(): boolean; + /** + * Set item select event handle + * + * @memberof ListViewItemTag + */ + set onitemselect(v: TagEventCallback); + /** + * Setter: select/unselect the current item + * + * Getter: Check whether the current item is selected + * + * @memberof ListViewItemTag + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Set the context menu event handle + * + * @memberof ListViewItemTag + */ + set onctxmenu(v: TagEventCallback); + /** + * Set the item click event handle + * + * @memberof ListViewItemTag + */ + set onitemclick(v: TagEventCallback); + /** + * Set the item double click event handle + * + * @memberof ListViewItemTag + */ + set onitemdbclick(v: TagEventCallback); + /** + * set the item close event handle + * + * @memberof ListViewItemTag + */ + set onitemclose(v: TagEventCallback); + /** + * Mount the tag and bind some events + * + * @protected + * @memberof ListViewItemTag + */ + protected mount(): void; + /** + * Layout definition of the item tag. + * This function define the outer layout of the item. + * Custom inner layout of each item implementation should + * be defined in [[itemlayout]] + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ListViewItemTag + */ + protected layout(): TagLayoutType[]; + /** + * Setter: + * + * Set the data of the list item. This will + * trigger the [[ondatachange]] function + * + * Getter: + * + * Get the data of the current list item + * + * @memberof ListViewItemTag + */ + set data(v: GenericObject); + get data(): GenericObject; + /** + * Any subclass of this class should implement this + * function to provide its custom item layout + * + * @protected + * @abstract + * @returns {TagLayoutType} + * @memberof ListViewItemTag + */ + protected abstract itemlayout(): TagLayoutType; + /** + * This function is called when the item data is changed. + * It should be implemented in all subclass of this class + * + * @protected + * @abstract + * @memberof ListViewItemTag + */ + protected abstract ondatachange(): void; + } + /** + * The layout of a simple list item contains only a + * AFX label + * + * @export + * @class SimpleListItemTag + * @extends {ListViewItemTag} + */ + class SimpleListItemTag extends ListViewItemTag { + /** + *Creates an instance of SimpleListItemTag. + * @memberof SimpleListItemTag + */ + constructor(); + /** + * Reset some property to default + * + * @protected + * @memberof SimpleListItemTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @memberof SimpleListItemTag + */ + protected calibrate(): void; + /** + * Refresh the inner label when the item data + * is changed + * + * @protected + * @returns {void} + * @memberof SimpleListItemTag + */ + protected ondatachange(): void; + /** + * Re-render the list item + * + * @protected + * @memberof SimpleListItemTag + */ + protected reload(): void; + /** + * List item custom layout definition + * + * @protected + * @returns {TagLayoutType} + * @memberof SimpleListItemTag + */ + protected itemlayout(): TagLayoutType; + } + /** + * This tag defines a traditional or a dropdown list widget. + * It contains a collection of list items in which layout + * of each item may be variable + * + * @export + * @class ListViewTag + * @extends {AFXTag} + */ + class ListViewTag extends AFXTag { + /** + * placeholder of list select event handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewTag + */ + private _onlistselect; + /** + * placeholder of list double click event handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewTag + */ + private _onlistdbclick; + /** + * placeholder of list drag and drop event handle + * + * @private + * @type {TagEventCallback>} + * @memberof ListViewTag + */ + private _ondragndrop; + /** + * placeholder of list item close event handle + * + * @private + * @memberof ListViewTag + */ + private _onitemclose; + /** + * placeholder of drag and drop mouse down event handle + * + * @private + * @memberof ListViewTag + */ + private _onmousedown; + /** + * placeholder of drag and drop mouse up event handle + * + * @private + * @memberof ListViewTag + */ + private _onmouseup; + /** + * placeholder of drag and drop mouse move event handle + * + * @private + * @memberof ListViewTag + */ + private _onmousemove; + /** + * Reference to the latest selected DOM item + * + * @private + * @type {ListViewItemTag} + * @memberof ListViewTag + */ + private _selectedItem; + /** + * A collection of selected items in the list. + * The maximum size of this collection is 1 if + * the [[multiselect]] feature is disabled + * + * @private + * @type {ListViewItemTag[]} + * @memberof ListViewTag + */ + private _selectedItems; + /** + * Data placeholder of the list + * + * @private + * @type {GenericObject[]} + * @memberof ListViewTag + */ + private _data; + /** + * Event data passing between mouse event when performing + * drag and drop on the list + * + * @private + * @type {{ from: ListViewItemTag[]; to: ListViewItemTag }} + * @memberof ListViewTag + */ + private _dnd; + /** + *Creates an instance of ListViewTag. + * @memberof ListViewTag + */ + constructor(); + /** + * Reset the tag's properties to the default values + * + * @protected + * @memberof ListViewTag + */ + protected init(): void; + /** + * This function does nothing + * + * @protected + * @param {*} [d] + * @memberof ListViewTag + */ + protected reload(d?: any): void; + /** + * Setter: toggle between dropdown and traditional list + * + * Getter: Check whether the list is dropdown or traditional list + * + * @memberof ListViewTag + */ + set dropdown(v: boolean); + /** + * Set drag and drop event handle + * + * @memberof ListViewTag + */ + set ondragndrop(v: TagEventCallback>); + /** + * Set list select event handle + * + * @memberof ListViewTag + */ + set onlistselect(v: TagEventCallback); + /** + * Set double click event handle + * + * @memberof ListViewTag + */ + set onlistdbclick(v: TagEventCallback); + /** + * Set item close event handle + * + * @memberof ListViewTag + */ + set onitemclose(v: (e: TagEventType) => boolean); + get dropdown(): boolean; + /** + * Setter: + * + * Set the default tag name of list's items. + * If the tag name is not specified in the + * data of a list item, this tag will be used + * + * Getter: + * + * Get the default tag name of list item + * + * @memberof ListViewTag + */ + set itemtag(v: string); + get itemtag(): string; + /** + * Setter: + * + * Turn on/off of the `multiselect` feature + * + * Getter: + * + * Check whether multi-select is allowed + * in this list + * + * @memberof ListViewTag + */ + set multiselect(v: boolean); + get multiselect(): boolean; + /** + * Setter: Enable/disable drag and drop event in the list + * + * Getter: Check whether the drag and drop event is enabled + * + * @memberof ListViewTag + */ + set dragndrop(v: boolean); + get dragndrop(): boolean; + /** + * Set the buttons layout of the list. + * Button layout allows to add some custom + * behaviors to the list. + * + * Each button data should define the [[onbtclick]] + * event handle to specify the custom behavior + * + * When the list is configured as dropdown. The buttons + * layout will be disabled + * + * Example of a button data: + * + * ``` + * { + * text: "Button text", + * icon: "home://path/to/icon.png", + * iconclass: "icon-class-name", + * onbtclick: (e) => console.log(e) + * } + * ``` + * + * @memberof ListViewTag + */ + set buttons(v: GenericObject[]); + /** + * Getter: Get data of the list + * + * Setter: Set data to the list + * + * @type {GenericObject[]} + * @memberof ListViewTag + */ + get data(): GenericObject[]; + set data(data: GenericObject[]); + /** + * Do nothing + * + * @protected + * @memberof ListViewTag + */ + protected ondatachange(): void; + /** + * Setter: Select list item(s) by their indexes + * + * Getter: Get the indexes of all selected items + * + * @memberof ListViewTag + */ + set selected(idx: number | number[]); + /** + * Get the latest selected item + * + * @readonly + * @type {ListViewItemTag} + * @memberof ListViewTag + */ + get selectedItem(): ListViewItemTag; + /** + * Get all the selected items + * + * @readonly + * @type {ListViewItemTag[]} + * @memberof ListViewTag + */ + get selectedItems(): ListViewItemTag[]; + get selected(): number | number[]; + /** + * Add an item to the beginning of the list + * + * @param {GenericObject} item + * @returns {ListViewItemTag} the added list item element + * @memberof ListViewTag + */ + unshift(item: GenericObject): ListViewItemTag; + /** + * check whether the list has data + * + * @private + * @param {GenericObject} v + * @returns + * @memberof ListViewTag + */ + private has_data; + /** + * Add an item to the beginning or end of the list + * + * @param {GenericObject} item list item data + * @param {boolean} [flag] indicates whether to add the item in the beginning of the list + * @returns {ListViewItemTag} the added list item element + * @memberof ListViewTag + */ + push(item: GenericObject, flag?: boolean): ListViewItemTag; + /** + * Delete an item + * + * @param {ListViewItemTag} item item DOM element + * @memberof ListViewTag + */ + delete(item: ListViewItemTag): void; + /** + * Select item next to the currently selected item. + * If there is no item selected, the first item will + * be selected + * + * @returns {void} + * @memberof ListViewTag + */ + selectNext(): void; + /** + * Select the previous item in the list. + * + * @returns {void} + * @memberof ListViewTag + */ + selectPrev(): void; + /** + * Unselect all the selected items in the list + * + * @returns {void} + * @memberof ListViewTag + */ + unselect(): void; + /** + * This function triggers the click event on an item + * + * @private + * @param {TagEventType} e tag event object + * @param {boolean} flag indicates whether this is a double click event + * @returns {void} + * @memberof ListViewTag + */ + private iclick; + /** + * This function triggers the double click event on an item + * + * @private + * @param {TagEventType} e tag event object + * @returns + * @memberof ListViewTag + */ + private idbclick; + /** + * This function triggers the list item select event + * + * @private + * @param {TagEventType} e tag event object + * @returns + * @memberof ListViewTag + */ + private iselect; + /** + * Mount the tag and bind some basic event + * + * @protected + * @returns {void} + * @memberof ListViewTag + */ + protected mount(): void; + /** + * This function triggers the item close event + * + * @private + * @param {TagEventType} e tag event object + * @returns {void} + * @memberof ListViewTag + */ + private iclose; + /** + * Show the dropdown list. + * This function is called only when the list is a dropdown + * list + * + * @protected + * @param {*} e + * @returns {void} + * @memberof ListViewTag + */ + protected showlist(e: any): void; + /** + * Hide the dropdown list. + * This function is called only when the list is a dropdown + * list + * + * @protected + * @param {*} e + * @memberof ListViewTag + */ + protected dropoff(e: any): void; + /** + * calibrate the list layout + * + * @protected + * @returns {void} + * @memberof ListViewTag + */ + protected calibrate(): void; + /** + * List view layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ListViewTag + */ + protected layout(): TagLayoutType[]; } } } @@ -5197,184 +4609,273 @@ declare namespace OS { namespace GUI { namespace tag { /** - * This class defines basic AFX label tag. - * A label contains a text and an icon (optional) + * Tag event data type definition + */ + type TabEventData = TagEventDataType; + /** + * a TabBar allows to control a collection of tabs * * @export - * @class LabelTag + * @class TabBarTag * @extends {AFXTag} */ - class LabelTag extends AFXTag { + export class TabBarTag extends AFXTag { /** - * placeholder of the text to be displayed + * Placeholder of currently selected tab index * * @private - * @type {(string | FormattedString)} - * @memberof LabelTag + * @type {number} + * @memberof TabBarTag */ - private _text; + private _selected; /** - *Creates an instance of LabelTag. - * @memberof LabelTag + * Placeholder of tab close event handle + * + * @private + * @memberof TabBarTag + */ + private _ontabclose; + /** + * Placeholder of tab select event handle + * + * @private + * @type {TagEventCallback} + * @memberof TabBarTag + */ + private _ontabselect; + /** + *Creates an instance of TabBarTag. + * @memberof TabBarTag */ constructor(); /** - * this implementation does nothing in this tag + * Init the tag * * @protected - * @memberof LabelTag - */ - protected mount(): void; - /** - * Refresh the text in the label - * - * @protected - * @param {*} d - * @memberof LabelTag - */ - protected reload(d: any): void; - /** - * Reset to default some property value - * - * @protected - * @memberof LabelTag + * @memberof TabBarTag */ protected init(): void; - /** - * This implementation of the function does nothing - * - * @protected - * @memberof LabelTag - */ - protected calibrate(): void; - /** - * Set the VFS path of the label icon - * - * @memberof LabelTag - */ - set icon(v: string); - /** - * Set the CSS class of the label icon - * - * @memberof LabelTag - */ - set iconclass(v: string); - /** - * Setter: Set the text of the label - * - * Getter: Get the text displayed on the label - * - * @memberof LabelTag - */ - set text(v: string | FormattedString); - get text(): string | FormattedString; - /** - * Lqbel layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof LabelTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A switch tag is basically used to visualize an boolean data value. - * - * @export - * @class SwitchTag - * @extends {AFXTag} - */ - class SwitchTag extends AFXTag { - /** - * Placeholder for the onchange event handle - * - * @private - * @type {TagEventCallback} - * @memberof SwitchTag - */ - private _onchange; - /** - * Setter: Turn on/off the switch - * - * Getter: Check whether the switch is turned on - * - * @memberof SwitchTag - */ - set swon(v: boolean); - get swon(): boolean; - /** - * Setter: Enable the switch - * - * Getter: Check whether the switch is enabled - * - * @memberof SwitchTag - */ - set enable(v: boolean); - get enable(): boolean; - /** - * Set the onchange event handle - * - * @memberof SwitchTag - */ - set onswchange(v: TagEventCallback); - /** - * Mount the tag and bind the click event to the switch - * - * @protected - * @memberof SwitchTag - */ - protected mount(): void; - /** - * This function will turn the switch (on/off) - * and trigger the onchange event - * - * @private - * @param {JQuery.ClickEvent} e - * @returns - * @memberof SwitchTag - */ - private makechange; - /** - * Tag layout definition - * - * @protected - * @returns - * @memberof SwitchTag - */ - protected layout(): { - el: string; - ref: string; - }[]; - /** - * Init the tag: - * - switch is turn off - * - switch is enabled - * - * @protected - * @memberof SwitchTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @memberof SwitchTag - */ - protected calibrate(): void; /** * Do nothing * * @protected * @param {*} [d] - * @memberof SwitchTag + * @memberof TabBarTag */ protected reload(d?: any): void; + /** + * Setter: Enable/disable a tab to be closed + * + * Getter: Check whether tabs can be closed + * + * @memberof TabBarTag + */ + set closable(v: boolean); + get closable(): boolean; + /** + * Add a tab in the end of the tab bar + * + * @param {GenericObject} item tab data + * @memberof TabBarTag + */ + push(item: GenericObject): ListViewItemTag; + /** + * Delete a tab + * + * @param {ListViewItemTag} el reference to DOM element of a tab + * @memberof TabBarTag + */ + delete(el: ListViewItemTag): void; + /** + * Add a tab to the beginning of the tab bar + * + * @param {GenericObject} item tab data + * @memberof TabBarTag + */ + unshift(item: GenericObject): ListViewItemTag; + /** + * Setter: Set tabs data + * + * Getter: Get all tabs data + * + * @memberof TabBarTag + */ + set items(v: GenericObject[]); + get items(): GenericObject[]; + /** + * Setter: Select a tab by its index + * + * Getter: Get the currently selected tab + * + * @memberof TabBarTag + */ + set selected(v: number | number[]); + get selected(): number | number[]; + /** + * Set the tab close event handle + * + * @memberof TabBarTag + */ + set ontabclose(v: (e: TagEventType) => boolean); + /** + * Set the tab select event handle + * + * @memberof TabBarTag + */ + set ontabselect(v: TagEventCallback); + /** + * Mount the tab bar and bind some basic events + * + * @protected + * @memberof TabBarTag + */ + protected mount(): void; + /** + * TabBar layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof TabBarTag + */ + protected layout(): TagLayoutType[]; + } + export {}; + } + } +} +declare namespace OS { + namespace GUI { + /** + * Color type used by AFX API + * + * @export + * @interface ColorType + */ + interface ColorType { + /** + * Red chanel + * + * @type {number} + * @memberof ColorType + */ + r: number; + /** + * Green chanel + * + * @type {number} + * @memberof ColorType + */ + g: number; + /** + * Blue chanel + * + * @type {number} + * @memberof ColorType + */ + b: number; + /** + * Alpha chanel + * + * @type {number} + * @memberof ColorType + */ + a?: number; + /** + * color text in CSS format + * + * @type {string} + * @memberof ColorType + */ + text?: string; + /** + * Color in hex format + * + * @type {string} + * @memberof ColorType + */ + hex?: string; + } + namespace tag { + /** + * Class definition of Color picker widget + * + * @export + * @class ColorPickerTag + * @extends {AFXTag} + */ + class ColorPickerTag extends AFXTag { + /** + * The current selected color object + * + * @private + * @type {ColorType} + * @memberof ColorPickerTag + */ + private _selectedColor; + /** + * placeholder for the color select event callback + * + * @private + * @type {TagEventCallback} + * @memberof ColorPickerTag + */ + private _oncolorselect; + /** + * Creates an instance of ColorPickerTag. + * @memberof ColorPickerTag + */ + constructor(); + /** + * Init tag before mounting, do nothing + * + * @protected + * @memberof ColorPickerTag + */ + protected init(): void; + /** + * Reload tag, do nothing + * + * @protected + * @param {*} [d] + * @memberof ColorPickerTag + */ + protected reload(d?: any): void; + /** + * Get selected color value + * + * @readonly + * @type {ColorType} + * @memberof ColorPickerTag + */ + get selectedColor(): ColorType; + /** + * Set the color select event handle + * + * @memberof ColorPickerTag + */ + set oncolorselect(v: TagEventCallback); + /** + * Mount the widget to DOM tree + * + * @protected + * @memberof ColorPickerTag + */ + protected mount(): void; + /** + * Build the color palette + * + * @private + * @memberof ColorPickerTag + */ + private build_palette; + /** + * layout definition of the widget + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ColorPickerTag + */ + protected layout(): TagLayoutType[]; } } } @@ -5543,81 +5044,1354 @@ declare namespace OS { namespace GUI { namespace tag { /** - * Meta tag that represents the virtual desktop environment. - * In near future, we may have multiple virtual desktop environments. - * Each desktop environment has a simple file manager and a window - * manager that render the window in a specific order. + * This class defines basic AFX label tag. + * A label contains a text and an icon (optional) * * @export - * @class DesktopTag - * @extends {FloatListTag} + * @class LabelTag + * @extends {AFXTag} */ - class DesktopTag extends FloatListTag { + class LabelTag extends AFXTag { /** - * internal handle to the desktop file location + * placeholder of the text to be displayed * * @private - * @type {API.VFS.BaseFileHandle} - * @memberof DesktopTag + * @type {(string | FormattedString)} + * @memberof LabelTag */ - private file; + private _text; /** - * local observer that detect if a new child element is - * added or removed - * - * @private - * @type {MutationObserver} - * @memberof DesktopTag - */ - private observer; - /** - * Internal list of the current opened window - * - * @private - * @type {Set} - * @memberof DesktopTag - */ - private window_list; - /** - * Creates an instance of DesktopTag. - * @memberof DesktopTag + *Creates an instance of LabelTag. + * @memberof LabelTag */ constructor(); /** - * Mount the virtual desktop to the DOM tree + * this implementation does nothing in this tag * * @protected - * @memberof DesktopTag + * @memberof LabelTag */ protected mount(): void; /** - * Display all files and folders in the specific desktop location + * Refresh the text in the label * - * @return {*} {Promise} - * @memberof DesktopTag + * @protected + * @param {*} d + * @memberof LabelTag */ - refresh(): Promise; + protected reload(d: any): void; /** - * Remove this element from its parent + * Reset to default some property value * - * @memberof DesktopTag + * @protected + * @memberof LabelTag */ - remove(): void; + protected init(): void; /** - * Active a window above all other windows + * This implementation of the function does nothing + * + * @protected + * @memberof LabelTag + */ + protected calibrate(): void; + /** + * Set the VFS path of the label icon + * + * @memberof LabelTag + */ + set icon(v: string); + /** + * Set the CSS class of the label icon + * + * @memberof LabelTag + */ + set iconclass(v: string); + /** + * Setter: Set the text of the label + * + * Getter: Get the text displayed on the label + * + * @memberof LabelTag + */ + set text(v: string | FormattedString); + get text(): string | FormattedString; + /** + * Setter: Turn on/off text selection + * + * Getter: Check whether the label is selectable + * + * @memberof LabelTag + */ + set selectable(v: boolean); + get swon(): boolean; + /** + * Lqbel layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof LabelTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +declare namespace OS { + namespace GUI { + /** + * Tab container data type definition + * + * @export + * @interface TabContainerTabType + */ + interface TabContainerTabType { + /** + * Reference to the DOM element of the current container + * + * @type {HTMLElement} + * @memberof TabContainerTabType + */ + container: HTMLElement; + [propName: string]: any; + } + namespace tag { + /** + * A tab container allows to attach each tab on a [[TabBarTag]] + * with a container widget. The attached container widget should be + * composed inside a [[HBoxTag]] + * + * The tab bar in a tab container can be configured to display tabs + * in horizontal (row) or vertical (column) order. Default to vertical order + * + * Once a tab is selected, its attached container will be shown + * + * @export + * @class TabContainerTag + * @extends {AFXTag} + */ + class TabContainerTag extends AFXTag { + /** + * Reference to the currently selected tab DOM element * * @private - * @param {WindowTag} win - * @memberof DesktopTag + * @type {TabContainerTabType} + * @memberof TabContainerTag */ - private selectWindow; + private _selectedTab; /** - * Render all windows in order from bottom to top + * Placeholder of the tab select event handle * * @private - * @memberof DesktopTag + * @type {TagEventCallback} + * @memberof TabContainerTag */ - private render; + private _ontabselect; + /** + *Creates an instance of TabContainerTag. + * @memberof TabContainerTag + */ + constructor(); + /** + * Init the tab bar direction to vertical (column) + * + * @protected + * @memberof TabContainerTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof TabContainerTag + */ + protected reload(d?: any): void; + /** + * Set the tab select event handle + * + * @memberof TabContainerTag + */ + set ontabselect(f: TagEventCallback); + /** + * Get all tab items in the container + * + * @readonly + * @type {TabContainerTabType[]} + * @memberof TabContainerTag + */ + get tabs(): TabContainerTabType[]; + /** + * Select a tab by its index + * + * @memberof TabContainerTag + */ + set selectedIndex(i: number); + /** + * Setter: + * + * Set the tab bar direction: + * - `row`: horizontal direction + * - `column`: vertical direction + * + * Getter: + * + * Get the tab bar direction + * + * @memberof TabContainerTag + */ + set dir(v: "row" | "column"); + get dir(): "row" | "column"; + /** + * Setter: + * + * Select a tab using the its tab data type. + * This will show the attached container to the tab + * + * Getter: + * + * Get the tab data of the currently selected Tab + * + * @memberof TabContainerTag + */ + set selectedTab(v: TabContainerTabType); + get selectedTab(): TabContainerTabType; + /** + * Set the tab bar width, this function only + * works when the tab bar direction is set to + * `row` + * + * @memberof TabContainerTag + */ + set tabbarwidth(v: number); + /** + * Set the tab bar height, this function only works + * when the tab bar direction is set to `column` + * + * @memberof TabContainerTag + */ + set tabbarheight(v: number); + /** + * Add a new tab with container to the container + * + * item should be in the following format: + * + * ```ts + * { + * text: string, + * icon?: string, + * iconclass?: string, + * container: HTMLElement + * } + * ``` + * + * @param {GenericObject} item tab descriptor + * @param {boolean} insert insert the tab content to the container ? + * @returns {ListViewItemTag} the tab DOM element + * @memberof TabContainerTag + */ + addTab(item: GenericObject, insert: boolean): ListViewItemTag; + /** + * Remove a tab from the container + * + * @param {ListViewItemTag} tab the tab item to be removed + * @memberof TabContainerTag + */ + removeTab(tab: ListViewItemTag): void; + /** + * Mount the tag and bind basic events + * + * @protected + * @memberof TabContainerTag + */ + protected mount(): void; + /** + * calibrate the tab container + * + * @memberof TabContainerTag + */ + calibrate(): void; + /** + * Layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof TabContainerTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +/** + * Extend the Array interface with some + * property needed by AFX API + * + * @interface Array + * @template T + */ +interface Array { + /** + * Reference to a DOM element created by AFX API, + * this property is used by some AFX tags to refer + * to its child element in it data object + * + * @type {GenericObject} + * @memberof Array + */ + domel?: GenericObject; +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * Row item event data type + */ + type GridRowEventData = TagEventDataType; + /** + * A grid Row is a simple element that + * contains a group of grid cell + * + * @export + * @class GridRowTag + * @extends {AFXTag} + */ + class GridRowTag extends AFXTag { + /** + * Data placeholder for a collection of cell data + * + * @type {GenericObject[]} + * @memberof GridRowTag + */ + data: GenericObject[]; + /** + * placeholder for the row select event callback + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onselect; + /** + *Creates an instance of GridRowTag. + * @memberof GridRowTag + */ + constructor(); + /** + * Set item select event handle + * + * @memberof ListViewItemTag + */ + set onrowselect(v: TagEventCallback); + /** + * Setter: select/unselect the current item + * + * Getter: Check whether the current item is selected + * + * @memberof ListViewItemTag + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Mount the tag, do nothing + * + * @protected + * @memberof GridRowTag + */ + protected mount(): void; + /** + * Init the tag before mounting: reset the data placeholder + * + * @protected + * @memberof GridRowTag + */ + protected init(): void; + /** + * Empty layout + * + * @protected + * @returns {TagLayoutType[]} + * @memberof GridRowTag + */ + protected layout(): TagLayoutType[]; + /** + * This function does nothing in this tag + * + * @protected + * @memberof GridRowTag + */ + protected calibrate(): void; + /** + * This function does nothing in this tag + * + * @protected + * @param {*} [d] + * @memberof GridRowTag + */ + protected reload(d?: any): void; + } + /** + * Event data used by grid cell + */ + type CellEventData = TagEventDataType; + /** + * Prototype of any grid cell, custom grid cell + * definition should extend and implement this + * abstract prototype + * + * @export + * @abstract + * @class GridCellPrototype + * @extends {AFXTag} + */ + abstract class GridCellPrototype extends AFXTag { + /** + * placeholder for cell selected event callback + * + * @private + * @type {TagEventCallback} + * @memberof GridCellPrototype + */ + private _oncellselect; + /** + * placeholder for cell double click event callback + * + * @private + * @type {TagEventCallback} + * @memberof GridCellPrototype + */ + private _oncelldbclick; + /** + * Data placeholder of the current cell + * + * @private + * @type {GenericObject} + * @memberof GridCellPrototype + */ + private _data; + /** + *Creates an instance of GridCellPrototype. + * @memberof GridCellPrototype + */ + constructor(); + /** + * Set the cell selected event callback + * + * @memberof GridCellPrototype + */ + set oncellselect(v: TagEventCallback); + /** + * Set the cell double click event callback + * + * @memberof GridCellPrototype + */ + set oncelldbclick(v: TagEventCallback); + /** + * Setter: + * + * Set the data of the cell, this will trigger + * the [[ondatachange]] function + * + * Getter: + * + * Get the current cell data placeholder + * + * @memberof GridCellPrototype + */ + set data(v: GenericObject); + get data(): GenericObject; + /** + * Setter: + * + * Set/unset the current cell as selected. + * This will trigger the [[cellselect]] + * event + * + * Getter: + * + * Check whether the current cell is selected + * + * @memberof GridCellPrototype + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Update the current cell. This will + * reset the cell data + * + * @protected + * @param {*} d + * @memberof GridCellPrototype + */ + protected reload(d: any): void; + /** + * Mount the current cell to the grid + * + * @protected + * @memberof GridCellPrototype + */ + protected mount(): void; + /** + * This function triggers the cell select + * event + * + * @private + * @param {TagEventType} e + * @param {boolean} flag + * @returns {void} + * @memberof GridCellPrototype + */ + private cellselect; + /** + * Abstract function called when the cell data changed. + * This should be implemented by subclasses + * + * @protected + * @abstract + * @memberof GridCellPrototype + */ + protected abstract ondatachange(): void; + } + /** + * Simple grid cell defines a grid cell with + * an [[LabelTag]] as it cell layout + * + * @export + * @class SimpleGridCellTag + * @extends {GridCellPrototype} + */ + class SimpleGridCellTag extends GridCellPrototype { + /** + *Creates an instance of SimpleGridCellTag. + * @memberof SimpleGridCellTag + */ + constructor(); + /** + * Reset the label of the cell with its data + * + * @protected + * @memberof SimpleGridCellTag + */ + protected ondatachange(): void; + /** + * This function do nothing in this tag + * + * @protected + * @memberof SimpleGridCellTag + */ + protected init(): void; + /** + * This function do nothing in this tag + * + * @protected + * @memberof SimpleGridCellTag + */ + protected calibrate(): void; + /** + * The layout of the cell with a simple [[LabelTag]] + * + * @returns + * @memberof SimpleGridCellTag + */ + layout(): { + el: string; + ref: string; + }[]; + } + /** + * A Grid contains a header and a collection grid rows + * which has the same number of cells as the number of + * the header elements + * + * @export + * @class GridViewTag + * @extends {AFXTag} + */ + class GridViewTag extends AFXTag { + /** + * Grid header definition + * + * @private + * @type {GenericObject[]} + * @memberof GridViewTag + */ + private _header; + /** + * Grid rows data placeholder + * + * @private + * @type {GenericObject[][]} + * @memberof GridViewTag + */ + private _rows; + /** + * Reference to the current selected row DOM element + * + * @private + * @type {GridRowTag} + * @memberof GridViewTag + */ + private _selectedRow; + /** + * A collection of selected grid rows DOM element + * + * @private + * @type {GridRowTag[]} + * @memberof GridViewTag + */ + private _selectedRows; + /** + * Reference to the current selected cell + * + * @private + * @type {GridCellPrototype} + * @memberof GridViewTag + */ + private _selectedCell; + /** + * Cell select event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof GridViewTag + */ + private _oncellselect; + /** + * Row select event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof GridViewTag + */ + private _onrowselect; + /** + * Cell double click event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof GridViewTag + */ + private _oncelldbclick; + /** + * Event data passing between mouse event when performing + * drag and drop on the list + * + * @private + * @type {{ from: GridRowTag[]; to: GridRowTag }} + * @memberof GridViewTag + */ + private _dnd; + /** + * placeholder of list drag and drop event handle + * + * @private + * @type {TagEventCallback>} + * @memberof GridViewTag + */ + private _ondragndrop; + /** + * Creates an instance of GridViewTag. + * @memberof GridViewTag + */ + constructor(); + /** + * Set drag and drop event handle + * + * @memberof GridViewTag + */ + set ondragndrop(v: TagEventCallback>); + /** + * Setter: Enable/disable drag and drop event in the list + * + * Getter: Check whether the drag and drop event is enabled + * + * @memberof GridViewTag + */ + set dragndrop(v: boolean); + get dragndrop(): boolean; + /** + * placeholder of drag and drop mouse down event handle + * + * @private + * @memberof GridViewTag + */ + private _onmousedown; + /** + * placeholder of drag and drop mouse up event handle + * + * @private + * @memberof GridViewTag + */ + private _onmouseup; + /** + * placeholder of drag and drop mouse move event handle + * + * @private + * @memberof GridViewTag + */ + private _onmousemove; + /** + * Init the grid view before mounting. + * Reset all the placeholders to default values + * + * @protected + * @memberof GridViewTag + */ + protected init(): void; + /** + * This function does nothing + * + * @protected + * @param {*} [d] + * @memberof GridViewTag + */ + protected reload(d?: any): void; + /** + * set the cell select event callback + * + * @memberof GridViewTag + */ + set oncellselect(v: TagEventCallback); + /** + * set the row select event callback + * + * @memberof GridViewTag + */ + set onrowselect(v: TagEventCallback); + /** + * set the cell double click event callback + * + * @memberof GridViewTag + */ + set oncelldbclick(v: TagEventCallback); + /** + * Setter: set the tag name of the header cells + * + * Getter: get the grid header tag name + * + * @memberof GridViewTag + */ + set headeritem(v: string); + get headeritem(): string; + /** + * Setter: set the tag name of the grid cell + * + * Getter: get the tag name of the grid cell + * + * @memberof GridViewTag + */ + set cellitem(v: string); + get cellitem(): string; + /** + * Setter: set the header data + * + * Getter: get the header data placeholder + * + * @type {GenericObject[]} + * @memberof GridViewTag + */ + get header(): GenericObject[]; + set header(v: GenericObject[]); + /** + * Get all the selected rows + * + * @readonly + * @type {GridRowTag[]} + * @memberof GridViewTag + */ + get selectedRows(): GridRowTag[]; + /** + * Get the latest selected row + * + * @readonly + * @type {GridRowTag} + * @memberof GridViewTag + */ + get selectedRow(): GridRowTag; + /** + * Get the current selected cell + * + * @readonly + * @type {GridCellPrototype} + * @memberof GridViewTag + */ + get selectedCell(): GridCellPrototype; + /** + * Setter: set the rows data + * + * Getter: get the rows data + * + * @memberof GridViewTag + */ + set rows(rows: GenericObject[][]); + get rows(): GenericObject[][]; + /** + * Setter: activate deactivate multi-select + * + * Getter: check whether the `multiselect` option is activated + * + * @memberof GridViewTag + */ + set multiselect(v: boolean); + get multiselect(): boolean; + /** + * Set and Get the resizable attribute + * + * This allows to enable/disable column resize feature + * + * @memberof GridViewTag + */ + set resizable(v: boolean); + get resizable(): boolean; + /** + * Sort the grid using a sort function + * + * @param {context: any} context of the executed function + * @param {(a:GenericObject[], b:GenericObject[]) => boolean} a sort function that compares two rows data + * * @param {index: number} current header index + * @returns {void} + * @memberof GridViewTag + */ + sort(context: any, fn: (a: GenericObject[], b: GenericObject[], index?: number) => number): void; + /** + * Delete a grid rows + * + * @param {GridRowTag} row row DOM element + * @returns {void} + * @memberof GridViewTag + */ + delete(row: GridRowTag): void; + /** + * Push a row to the grid + * + * @param {GenericObject[]} row list of cell data + * @param {boolean} flag indicates where the row is add to beginning or end + * of the row + * @memberof GridViewTags + */ + push(row: GenericObject[], flag: boolean): void; + /** + * Unshift a row to the grid + * + * @param {GenericObject[]} row list of cell data in the row + * @memberof GridViewTag + */ + unshift(row: GenericObject[]): void; + /** + * This function triggers the cell select event + * + * @private + * @param {TagEventType} e event contains cell event data + * @param {boolean} flag indicates whether the event is double clicked + * @returns {void} + * @memberof GridViewTag + */ + private cellselect; + /** + * This function triggers the row select event, a cell select + * event will also trigger this event + * + * @param {TagEventType} e + * @returns {void} + * @memberof GridViewTag + */ + private rowselect; + /** + * Unselect all the selected rows in the grid + * + * @returns {void} + * @memberof GridViewTag + */ + unselect(): void; + /** + * Check whether the grid has header + * + * @private + * @returns {boolean} + * @memberof GridViewTag + */ + private has_header; + /** + * Calibrate the grid + * + * @protected + * @memberof GridViewTag + */ + protected calibrate(): void; + /** + * Recalculate the size of each header cell, changing + * in header cell size will also resize the entire + * related column + * + * @private + * @returns {void} + * @memberof GridViewTag + */ + private calibrate_header; + /** + * Mount the grid view tag + * + * @protected + * @returns {void} + * @memberof GridViewTag + */ + protected mount(): void; + /** + * Layout definition of the grid view + * + * @protected + * @returns {TagLayoutType[]} + * @memberof GridViewTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * A system panel contains the following elements: + * - Spotlight to access to applications menu + * - Current focused application menu + * - System tray for all running services running in background + * + * @export + * @class SystemPanelTag + * @extends {AFXTag} + */ + class SystemPanelTag extends AFXTag { + /** + * Reference to spotlight data + * + * @private + * @type {(GenericObject)} + * @memberof SystemPanelTag + */ + private _osmenu; + /** + * Placeholder indicates whether the spotlight is currently shown + * + * @private + * @type {boolean} + * @memberof SystemPanelTag + */ + private _view; + /** + * Store pending loading task + * + * @private + * @type {number[]} + * @memberof SystemPanelTag + */ + private _pending_task; + /** + * Loading animation check timeout + * + * @memberof SystemPanelTag + */ + private _loading_toh; + /** + * Place holder for a private callback function + * + * @private + * @memberof SystemPanelTag + */ + private _cb; + /** + * Place holder for system app list + * + * @private + * @type {GenericObject[]} + * @memberof SystemPanelTag + */ + private app_list; + /** + *Creates an instance of SystemPanelTag. + * @memberof SystemPanelTag + */ + constructor(); + /** + * Do nothing + * + * @protected + * @memberof SystemPanelTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof SystemPanelTag + */ + protected reload(d?: any): void; + /** + * Attach a service to the system tray on the pannel, + * this operation is performed when a service is started + * + * @param {BaseService} s + * @returns + * @memberof SystemPanelTag + */ + attachservice(s: application.BaseService): void; + /** + * Launch the selected application from the spotlight + * applications list + * + * @private + * @returns {void} + * @memberof SystemPanelTag + */ + private open; + /** + * Perform spotlight search operation on keyboard event + * + * @private + * @param {JQuery.KeyboardEventBase} e + * @returns {void} + * @memberof SystemPanelTag + */ + private search; + /** + * detach a service from the system tray of the panel. + * This function is called when the corresponding running + * service is killed + * + * @param {BaseService} s + * @memberof SystemPanelTag + */ + detachservice(s: application.BaseService): void; + /** + * Layout definition of the panel + * + * @protected + * @returns {TagLayoutType[]} + * @memberof SystemPanelTag + */ + protected layout(): TagLayoutType[]; + /** + * Refresh applications list on the spotlight widget + * from system packages meta-data + * + * @private + * @memberof SystemPanelTag + */ + private refreshAppList; + /** + * Show/hide the spotlight + * + * @private + * @param {boolean} flag + * @memberof SystemPanelTag + */ + private toggle; + /** + * Calibrate the spotlight widget + * + * @memberof SystemPanelTag + */ + calibrate(): void; + /** + * Refresh the pinned applications menu + * + * @private + * @memberof SystemPanelTag + */ + private RefreshPinnedApp; + /** + * Check if the loading tasks ended, + * if it the case, stop the animation + * + * @private + * @memberof SystemPanelTag + */ + private animation_check; + /** + * Mount the tag bind some basic event + * + * @protected + * @memberof SystemPanelTag + */ + protected mount(): void; + } + } + } +} +/// +declare namespace OS { + namespace GUI { + namespace tag { + /** + * This tag define a basic button and its behavior + * + * @export + * @class ButtonTag + * @extends {AFXTag} + */ + class ButtonTag extends AFXTag { + /** + * Variable hold the button click callback handle + * + * @private + * @type {TagEventCallback} + * @memberof ButtonTag + */ + private _onbtclick; + /** + * Custom user data + * + * @type {GenericObject} + * @memberof ButtonTag + */ + data: GenericObject; + /** + *Creates an instance of ButtonTag. + * @memberof ButtonTag + */ + constructor(); + /** + * Set the click callback handle for the target button + * + * @memberof ButtonTag + */ + set onbtclick(v: TagEventCallback); + /** + * Set the path to the button icon, the path should be + * a VFS file path + * + * @memberof ButtonTag + */ + set icon(v: string); + /** + * Set the icon class to the button, this property + * allows to style the button icon using CSS + * + * @memberof ButtonTag + */ + set iconclass(v: string); + /** + * Setter: Set the text of the button + * + * Getter: Get the current button test + * + * @memberof ButtonTag + */ + set text(v: string | FormattedString); + get text(): string | FormattedString; + /** + * Setter: Enable or disable the button + * + * Getter: Get the `enable` property of the button + * + * @memberof ButtonTag + */ + set enable(v: boolean); + get enable(): boolean; + /** + * Setter: set or remove the attribute `selected` of the button + * + * Getter: check whether the attribute `selected` of the button is set + * + * @memberof ButtonTag + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Setter: activate or deactivate the toggle mode of the button + * + * Getter: Check whether the button is in toggle mode + * + * @memberof ButtonTag + */ + set toggle(v: boolean); + get toggle(): boolean; + /** + * Mount the tag + * + * @protected + * @memberof ButtonTag + */ + protected mount(): void; + /** + * Init the tag before mounting + * + * @protected + * @memberof ButtonTag + */ + protected init(): void; + /** + * Re-calibrate the button, do nothing in this tag + * + * @protected + * @memberof ButtonTag + */ + protected calibrate(): void; + /** + * Update the current tag, do nothing in this tag + * + * @param {*} [d] + * @memberof ButtonTag + */ + reload(d?: any): void; + /** + * Button layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ButtonTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * A tile layout organize it child elements + * in a fixed horizontal or vertical direction. + * + * The size of each child element is attributed based + * on its configuration of automatically based on the + * remaining space in the layout + * + * + * @export + * @class TileLayoutTag + * @extends {AFXTag} + */ + class TileLayoutTag extends AFXTag { + /** + *C reates an instance of TileLayoutTag. + * @memberof TileLayoutTag + */ + constructor(); + /** + * Do nothing + * + * @protected + * @memberof TileLayoutTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof TileLayoutTag + */ + protected reload(d?: any): void; + /** + * Setter: Set the name of the tile container, should be: `hbox` or `vbox` + * + * Getter: Get the name of the tile container + * + * @memberof TileLayoutTag + */ + set name(v: string); + get name(): string; + /** + * Setter: + * + * SET the layout direction, should be: + * - `row`: horizontal direction + * - `column`: vertical direction + * + * Getter: + * + * Get layout direction + * + * @memberof TileLayoutTag + */ + set dir(v: "row" | "column"); + get dir(): "row" | "column"; + /** + * Mount the element + * + * @protected + * @returns {void} + * @memberof TileLayoutTag + */ + protected mount(): void; + /** + * re-organize the layout + * + * @returns {void} + * @memberof TileLayoutTag + */ + calibrate(): void; + /** + * Organize the layout in horizontal direction, only work when + * the layout direction set to horizontal + * + * @private + * @returns {void} + * @memberof TileLayoutTag + */ + private hcalibrate; + /** + * Organize the layout in vertical direction, only work when + * the layout direction set to vertical + * + * @private + * @returns {void} + * @memberof TileLayoutTag + */ + private vcalibrate; + /** + * Layout definition + * + * @returns + * @memberof TileLayoutTag + */ + layout(): { + el: string; + ref: string; + }[]; + } + /** + * A HBox organize its child elements in horizontal direction + * + * @export + * @class HBoxTag + * @extends {TileLayoutTag} + */ + class HBoxTag extends TileLayoutTag { + /** + * Creates an instance of HBoxTag. + * @memberof HBoxTag + */ + constructor(); + /** + * Mount the tag + * + * @protected + * @memberof HBoxTag + */ + protected mount(): void; + } + /** + * A VBox organize its child elements in vertical direction + * + * @export + * @class VBoxTag + * @extends {TileLayoutTag} + */ + class VBoxTag extends TileLayoutTag { + /** + *Creates an instance of VBoxTag. + * @memberof VBoxTag + */ + constructor(); + /** + * Mount the tag + * + * @protected + * @memberof VBoxTag + */ + protected mount(): void; } } } @@ -5975,7 +6749,7 @@ declare namespace OS { * Private data object passing between dragndrop mouse event * * @private - * @type {{ from: TreeViewTag; to: TreeViewTag }} + * @type {{ from: TreeViewTag[]; to: TreeViewTag }} * @memberof TreeViewTag */ private _dnd; @@ -6022,7 +6796,7 @@ declare namespace OS { * current tree. This function should return a promise on * a list of [[TreeViewDataType]] * - * @memberof TreeViewItemPrototype + * @memberof TreeViewTag */ fetch: (d: TreeViewItemPrototype) => Promise; /** @@ -6175,247 +6949,6 @@ declare namespace OS { } } } -declare namespace OS { - namespace GUI { - namespace tag { - /** - * An overlay tag is a layout tag that alway stay on top of - * the virtual desktop environment. Tile layout elements ([[VBoxTag]], [[HboxTag]]) - * can be used inside this tag to compose elements - * - * @export - * @class OverlayTag - * @extends {AFXTag} - */ - class OverlayTag extends AFXTag { - /** - * Tag width placeholder - * - * @private - * @type {string} - * @memberof OverlayTag - */ - private _width; - /** - * Tag height place holder - * - * @private - * @type {string} - * @memberof OverlayTag - */ - private _height; - /** - *Creates an instance of OverlayTag. - * @memberof OverlayTag - */ - constructor(); - /** - * Put the tag on top of the virtual desktop environment - * - * @protected - * @memberof OverlayTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @param {*} [d] - * @memberof OverlayTag - */ - protected reload(d?: any): void; - /** - * Setter: - * - * Set the width of the tag, the tag width should be in form of: - * `100px` of `80%` - * - * Getter: - * - * Get the tag width - * - * @memberof OverlayTag - */ - set width(v: string); - get width(): string; - /** - * Setter: - * - * Set the tag height, the tag height should be in form of: - * `100px` of `80%` - * - * Getter: - * - * Get the tag height - * - * @memberof OverlayTag - */ - set height(v: string); - get height(): string; - /** - * Calibrate the element when mounting - * - * @protected - * @returns {void} - * @memberof OverlayTag - */ - protected mount(): void; - /** - * Calibrate the width and height of the tag - * - * @returns {void} - * @memberof OverlayTag - */ - calibrate(): void; - /** - * Layout definition of the tag - * - * @protected - * @returns {TagLayoutType[]} - * @memberof OverlayTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - /** - * Color type used by AFX API - * - * @export - * @interface ColorType - */ - interface ColorType { - /** - * Red chanel - * - * @type {number} - * @memberof ColorType - */ - r: number; - /** - * Green chanel - * - * @type {number} - * @memberof ColorType - */ - g: number; - /** - * Blue chanel - * - * @type {number} - * @memberof ColorType - */ - b: number; - /** - * Alpha chanel - * - * @type {number} - * @memberof ColorType - */ - a?: number; - /** - * color text in CSS format - * - * @type {string} - * @memberof ColorType - */ - text?: string; - /** - * Color in hex format - * - * @type {string} - * @memberof ColorType - */ - hex?: string; - } - namespace tag { - /** - * Class definition of Color picker widget - * - * @export - * @class ColorPickerTag - * @extends {AFXTag} - */ - class ColorPickerTag extends AFXTag { - /** - * The current selected color object - * - * @private - * @type {ColorType} - * @memberof ColorPickerTag - */ - private _selectedColor; - /** - * placeholder for the color select event callback - * - * @private - * @type {TagEventCallback} - * @memberof ColorPickerTag - */ - private _oncolorselect; - /** - * Creates an instance of ColorPickerTag. - * @memberof ColorPickerTag - */ - constructor(); - /** - * Init tag before mounting, do nothing - * - * @protected - * @memberof ColorPickerTag - */ - protected init(): void; - /** - * Reload tag, do nothing - * - * @protected - * @param {*} [d] - * @memberof ColorPickerTag - */ - protected reload(d?: any): void; - /** - * Get selected color value - * - * @readonly - * @type {ColorType} - * @memberof ColorPickerTag - */ - get selectedColor(): ColorType; - /** - * Set the color select event handle - * - * @memberof ColorPickerTag - */ - set oncolorselect(v: TagEventCallback); - /** - * Mount the widget to DOM tree - * - * @protected - * @memberof ColorPickerTag - */ - protected mount(): void; - /** - * Build the color palette - * - * @private - * @memberof ColorPickerTag - */ - private build_palette; - /** - * layout definition of the widget - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ColorPickerTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} /// declare namespace OS { namespace GUI { @@ -6917,804 +7450,6 @@ declare namespace OS { } } } -declare namespace OS { - namespace GUI { - namespace tag { - /** - * Tag event data type definition - */ - type TabEventData = TagEventDataType; - /** - * a TabBar allows to control a collection of tabs - * - * @export - * @class TabBarTag - * @extends {AFXTag} - */ - export class TabBarTag extends AFXTag { - /** - * Placeholder of currently selected tab index - * - * @private - * @type {number} - * @memberof TabBarTag - */ - private _selected; - /** - * Placeholder of tab close event handle - * - * @private - * @memberof TabBarTag - */ - private _ontabclose; - /** - * Placeholder of tab select event handle - * - * @private - * @type {TagEventCallback} - * @memberof TabBarTag - */ - private _ontabselect; - /** - *Creates an instance of TabBarTag. - * @memberof TabBarTag - */ - constructor(); - /** - * Init the tag - * - * @protected - * @memberof TabBarTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @param {*} [d] - * @memberof TabBarTag - */ - protected reload(d?: any): void; - /** - * Setter: Enable/disable a tab to be closed - * - * Getter: Check whether tabs can be closed - * - * @memberof TabBarTag - */ - set closable(v: boolean); - get closable(): boolean; - /** - * Add a tab in the end of the tab bar - * - * @param {GenericObject} item tab data - * @memberof TabBarTag - */ - push(item: GenericObject): ListViewItemTag; - /** - * Delete a tab - * - * @param {ListViewItemTag} el reference to DOM element of a tab - * @memberof TabBarTag - */ - delete(el: ListViewItemTag): void; - /** - * Add a tab to the beginning of the tab bar - * - * @param {GenericObject} item tab data - * @memberof TabBarTag - */ - unshift(item: GenericObject): ListViewItemTag; - /** - * Setter: Set tabs data - * - * Getter: Get all tabs data - * - * @memberof TabBarTag - */ - set items(v: GenericObject[]); - get items(): GenericObject[]; - /** - * Setter: Select a tab by its index - * - * Getter: Get the currently selected tab - * - * @memberof TabBarTag - */ - set selected(v: number | number[]); - get selected(): number | number[]; - /** - * Set the tab close event handle - * - * @memberof TabBarTag - */ - set ontabclose(v: (e: TagEventType) => boolean); - /** - * Set the tab select event handle - * - * @memberof TabBarTag - */ - set ontabselect(v: TagEventCallback); - /** - * Mount the tab bar and bind some basic events - * - * @protected - * @memberof TabBarTag - */ - protected mount(): void; - /** - * TabBar layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof TabBarTag - */ - protected layout(): TagLayoutType[]; - } - export {}; - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A float list is a list of items in which each - * item can be moved (drag and drop) freely - * - * @export - * @class FloatListTag - * @extends {ListViewTag} - */ - class FloatListTag extends ListViewTag { - /** - * Update the current tag, do nothing - * - * @protected - * @param {*} [d] - * @memberof FloatListTag - */ - protected reload(d?: any): void; - /** - * Variable that hold the onready callback of - * the tag. This callback will be called after - * the tag is mounted - * - * @private - * @memberof FloatListTag - */ - private _onready; - /** - *Creates an instance of FloatListTag. - * @memberof FloatListTag - */ - constructor(); - /** - * set the onready callback function to the tag. - * This callback will be called after - * the tag is mounted - * - * @memberof FloatListTag - */ - set onready(v: (e: FloatListTag) => void); - /** - * Setter: - * - * Set the direction of the list item layout. - * Two directions are available: - * - `vertical` - * - `horizontal` - * - * This setter acts as a DOM attribute - * - * Getter: - * - * Get the currently set direction of list - * item layout - * - * @memberof FloatListTag - */ - set dir(v: string); - get dir(): string; - /** - * Disable the dropdown option in this list - * - * @memberof FloatListTag - */ - set dropdown(v: boolean); - /** - * Disable the list buttons configuration in this - * list - * - * @memberof FloatListTag - */ - set buttons(v: GenericObject[]); - /** - * Disable the `showlist` behavior in this list - * - * @protected - * @param {*} e - * @memberof FloatListTag - */ - protected showlist(e: any): void; - /** - * Disable the `dropoff` behavior in this list - * - * @protected - * @param {*} e - * @memberof FloatListTag - */ - protected dropoff(e: any): void; - /** - * Function called when the data of the list - * is changed - * - * @protected - * @memberof FloatListTag - */ - protected ondatachange(): void; - /** - * Mount the list to the DOM tree - * - * @protected - * @returns {void} - * @memberof FloatListTag - */ - protected mount(): void; - /** - * Push an element to the list - * - * @param {GenericObject} v an element data - * @returns - * @memberof FloatListTag - */ - push(v: GenericObject): ListViewItemTag; - /** - * Enable drag and drop on the list - * - * @private - * @param {ListViewItemTag} el the list item DOM element - * @memberof FloatListTag - */ - private enable_drag; - /** - * Calibrate the view of the list - * - * @memberof FloatListTag - */ - calibrate(): void; - } - } - } -} -/** - * Extend the Array interface with some - * property needed by AFX API - * - * @interface Array - * @template T - */ -interface Array { - /** - * Reference to a DOM element created by AFX API, - * this property is used by some AFX tags to refer - * to its child element in it data object - * - * @type {GenericObject} - * @memberof Array - */ - domel?: GenericObject; -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A grid Row is a simple element that - * contains a group of grid cell - * - * @export - * @class GridRowTag - * @extends {AFXTag} - */ - class GridRowTag extends AFXTag { - /** - * Data placeholder for a collection of cell data - * - * @type {GenericObject[]} - * @memberof GridRowTag - */ - data: GenericObject[]; - /** - *Creates an instance of GridRowTag. - * @memberof GridRowTag - */ - constructor(); - /** - * Mount the tag, do nothing - * - * @protected - * @memberof GridRowTag - */ - protected mount(): void; - /** - * Init the tag before mounting: reset the data placeholder - * - * @protected - * @memberof GridRowTag - */ - protected init(): void; - /** - * Empty layout - * - * @protected - * @returns {TagLayoutType[]} - * @memberof GridRowTag - */ - protected layout(): TagLayoutType[]; - /** - * This function does nothing in this tag - * - * @protected - * @memberof GridRowTag - */ - protected calibrate(): void; - /** - * This function does nothing in this tag - * - * @protected - * @param {*} [d] - * @memberof GridRowTag - */ - protected reload(d?: any): void; - } - /** - * Event data used by grid cell - */ - type CellEventData = TagEventDataType; - /** - * Prototype of any grid cell, custom grid cell - * definition should extend and implement this - * abstract prototype - * - * @export - * @abstract - * @class GridCellPrototype - * @extends {AFXTag} - */ - abstract class GridCellPrototype extends AFXTag { - /** - * placeholder for cell selected event callback - * - * @private - * @type {TagEventCallback} - * @memberof GridCellPrototype - */ - private _oncellselect; - /** - * placeholder for cell double click event callback - * - * @private - * @type {TagEventCallback} - * @memberof GridCellPrototype - */ - private _oncelldbclick; - /** - * Data placeholder of the current cell - * - * @private - * @type {GenericObject} - * @memberof GridCellPrototype - */ - private _data; - /** - *Creates an instance of GridCellPrototype. - * @memberof GridCellPrototype - */ - constructor(); - /** - * Set the cell selected event callback - * - * @memberof GridCellPrototype - */ - set oncellselect(v: TagEventCallback); - /** - * Set the cell double click event callback - * - * @memberof GridCellPrototype - */ - set oncelldbclick(v: TagEventCallback); - /** - * Setter: - * - * Set the data of the cell, this will trigger - * the [[ondatachange]] function - * - * Getter: - * - * Get the current cell data placeholder - * - * @memberof GridCellPrototype - */ - set data(v: GenericObject); - get data(): GenericObject; - /** - * Setter: - * - * Set/unset the current cell as selected. - * This will trigger the [[cellselect]] - * event - * - * Getter: - * - * Check whether the current cell is selected - * - * @memberof GridCellPrototype - */ - set selected(v: boolean); - get selected(): boolean; - /** - * Update the current cell. This will - * reset the cell data - * - * @protected - * @param {*} d - * @memberof GridCellPrototype - */ - protected reload(d: any): void; - /** - * Mount the current cell to the grid - * - * @protected - * @memberof GridCellPrototype - */ - protected mount(): void; - /** - * This function triggers the cell select - * event - * - * @private - * @param {TagEventType} e - * @param {boolean} flag - * @returns {void} - * @memberof GridCellPrototype - */ - private cellselect; - /** - * Abstract function called when the cell data changed. - * This should be implemented by subclasses - * - * @protected - * @abstract - * @memberof GridCellPrototype - */ - protected abstract ondatachange(): void; - } - /** - * Simple grid cell defines a grid cell with - * an [[LabelTag]] as it cell layout - * - * @export - * @class SimpleGridCellTag - * @extends {GridCellPrototype} - */ - class SimpleGridCellTag extends GridCellPrototype { - /** - *Creates an instance of SimpleGridCellTag. - * @memberof SimpleGridCellTag - */ - constructor(); - /** - * Reset the label of the cell with its data - * - * @protected - * @memberof SimpleGridCellTag - */ - protected ondatachange(): void; - /** - * This function do nothing in this tag - * - * @protected - * @memberof SimpleGridCellTag - */ - protected init(): void; - /** - * This function do nothing in this tag - * - * @protected - * @memberof SimpleGridCellTag - */ - protected calibrate(): void; - /** - * The layout of the cell with a simple [[LabelTag]] - * - * @returns - * @memberof SimpleGridCellTag - */ - layout(): { - el: string; - ref: string; - }[]; - } - /** - * A Grid contains a header and a collection grid rows - * which has the same number of cells as the number of - * the header elements - * - * @export - * @class GridViewTag - * @extends {AFXTag} - */ - class GridViewTag extends AFXTag { - /** - * Grid header definition - * - * @private - * @type {GenericObject[]} - * @memberof GridViewTag - */ - private _header; - /** - * Grid rows data placeholder - * - * @private - * @type {GenericObject[][]} - * @memberof GridViewTag - */ - private _rows; - /** - * Reference to the current selected row DOM element - * - * @private - * @type {GridRowTag} - * @memberof GridViewTag - */ - private _selectedRow; - /** - * A collection of selected grid rows DOM element - * - * @private - * @type {GridRowTag[]} - * @memberof GridViewTag - */ - private _selectedRows; - /** - * Reference to the current selected cell - * - * @private - * @type {GridCellPrototype} - * @memberof GridViewTag - */ - private _selectedCell; - /** - * Cell select event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof GridViewTag - */ - private _oncellselect; - /** - * Row select event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof GridViewTag - */ - private _onrowselect; - /** - * Cell double click event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof GridViewTag - */ - private _oncelldbclick; - /** - * Creates an instance of GridViewTag. - * @memberof GridViewTag - */ - constructor(); - /** - * Init the grid view before mounting. - * Reset all the placeholders to default values - * - * @protected - * @memberof GridViewTag - */ - protected init(): void; - /** - * This function does nothing - * - * @protected - * @param {*} [d] - * @memberof GridViewTag - */ - protected reload(d?: any): void; - /** - * set the cell select event callback - * - * @memberof GridViewTag - */ - set oncellselect(v: TagEventCallback); - /** - * set the row select event callback - * - * @memberof GridViewTag - */ - set onrowselect(v: TagEventCallback); - /** - * set the cell double click event callback - * - * @memberof GridViewTag - */ - set oncelldbclick(v: TagEventCallback); - /** - * Setter: set the tag name of the header cells - * - * Getter: get the grid header tag name - * - * @memberof GridViewTag - */ - set headeritem(v: string); - get headeritem(): string; - /** - * Setter: set the tag name of the grid cell - * - * Getter: get the tag name of the grid cell - * - * @memberof GridViewTag - */ - set cellitem(v: string); - get cellitem(): string; - /** - * Setter: set the header data - * - * Getter: get the header data placeholder - * - * @type {GenericObject[]} - * @memberof GridViewTag - */ - get header(): GenericObject[]; - set header(v: GenericObject[]); - /** - * Get all the selected rows - * - * @readonly - * @type {GridRowTag[]} - * @memberof GridViewTag - */ - get selectedRows(): GridRowTag[]; - /** - * Get the latest selected row - * - * @readonly - * @type {GridRowTag} - * @memberof GridViewTag - */ - get selectedRow(): GridRowTag; - /** - * Get the current selected cell - * - * @readonly - * @type {GridCellPrototype} - * @memberof GridViewTag - */ - get selectedCell(): GridCellPrototype; - /** - * Setter: set the rows data - * - * Getter: get the rows data - * - * @memberof GridViewTag - */ - set rows(rows: GenericObject[][]); - get rows(): GenericObject[][]; - /** - * Setter: activate deactivate multi-select - * - * Getter: check whether the `multiselect` option is activated - * - * @memberof GridViewTag - */ - set multiselect(v: boolean); - get multiselect(): boolean; - /** - * Set and Get the resizable attribute - * - * This allows to enable/disable column resize feature - * - * @memberof GridViewTag - */ - set resizable(v: boolean); - get resizable(): boolean; - /** - * Delete a grid rows - * - * @param {GridRowTag} row row DOM element - * @returns {void} - * @memberof GridViewTag - */ - delete(row: GridRowTag): void; - /** - * Push a row to the grid - * - * @param {GenericObject[]} row list of cell data - * @param {boolean} flag indicates where the row is add to beginning or end - * of the row - * @memberof GridViewTags - */ - push(row: GenericObject[], flag: boolean): void; - /** - * Unshift a row to the grid - * - * @param {GenericObject[]} row list of cell data in the row - * @memberof GridViewTag - */ - unshift(row: GenericObject[]): void; - /** - * This function triggers the cell select event - * - * @private - * @param {TagEventType} e event contains cell event data - * @param {boolean} flag indicates whether the event is double clicked - * @returns {void} - * @memberof GridViewTag - */ - private cellselect; - /** - * This function triggers the row select event, a cell select - * event will also trigger this event - * - * @param {TagEventType} e - * @returns {void} - * @memberof GridViewTag - */ - private rowselect; - /** - * Check whether the grid has header - * - * @private - * @returns {boolean} - * @memberof GridViewTag - */ - private has_header; - /** - * Calibrate the grid - * - * @protected - * @memberof GridViewTag - */ - protected calibrate(): void; - /** - * Recalculate the size of each header cell, changing - * in header cell size will also resize the entire - * related column - * - * @private - * @returns {void} - * @memberof GridViewTag - */ - private calibrate_header; - /** - * Mount the grid view tag - * - * @protected - * @returns {void} - * @memberof GridViewTag - */ - protected mount(): void; - /** - * Layout definition of the grid view - * - * @protected - * @returns {TagLayoutType[]} - * @memberof GridViewTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} declare namespace OS { namespace GUI { namespace tag { @@ -7855,456 +7590,621 @@ declare namespace OS { } } } -/// -/** - * - * Extend the HTMLElement interface with some utility function need - * by AFX API - * - * @interface HTMLElement - */ -interface HTMLElement { - /** - * Recursively update a tag and all its children - * - * @param {*} [d] data to send to all element in the DOM subtree - * @memberof HTMLElement - */ - update(d?: any): void; - /** - * - * AFX will automatically bind the context menu on an HTMLElement - * if this function is defined on that element. The function should - * define the content of the context menu and its action - * - * Once the context menu is bound to the element, all context menu handle - * defined on any child of this element will be ignored. - * - * @param {JQuery.MouseEventBase} e a mouse event - * @param {OS.GUI.tag.MenuTag} m The context menu element [[MenuTag]] - * @memberof HTMLElement - */ - contextmenuHandle(e: JQuery.MouseEventBase, m: OS.GUI.tag.MenuTag): void; - /** - * Mount the element and all the children on its DOM subtree. This action - * is performed in a top-down manner - * - * @memberof HTMLElement - */ - sync(): void; - /** - * - * This action allows to generated all the DOM nodes defined by all AFX tags - * in its hierarchy. - * It performs two operations, one top-down operation to generate all the - * necessary DOM nodes, another bottom-up operation to init all the AFX tag - * in the current element DOM hierarchy - * - * @param {OS.API.Announcer} o an AntOS observable object - * @memberof HTMLElement - */ - afxml(o: OS.API.Announcer): void; - /** - * Perform DOM generation ([[afxml]]) then mount ([[sync]]) all the - * elements. - * - * @param {OS.API.Announcer} o an AntOS observable object - * @param {boolean} [flag] indicates whether this is the top-most call of the operation - * @memberof HTMLElement - */ - uify(o: OS.API.Announcer, flag?: boolean): void; - /** - * - * - * @type {*} - * @memberof HTMLElement - */ - mozRequestFullScreen: any; - /** - * - * - * @type {*} - * @memberof HTMLElement - */ - webkitRequestFullscreen: any; - /** - * - * - * @type {*} - * @memberof HTMLElement - */ - msRequestFullscreen: any; +declare namespace OS { + namespace GUI { + namespace tag { + /** + * An overlay tag is a layout tag that alway stay on top of + * the virtual desktop environment. Tile layout elements ([[VBoxTag]], [[HboxTag]]) + * can be used inside this tag to compose elements + * + * @export + * @class OverlayTag + * @extends {AFXTag} + */ + class OverlayTag extends AFXTag { + /** + * Tag width placeholder + * + * @private + * @type {string} + * @memberof OverlayTag + */ + private _width; + /** + * Tag height place holder + * + * @private + * @type {string} + * @memberof OverlayTag + */ + private _height; + /** + *Creates an instance of OverlayTag. + * @memberof OverlayTag + */ + constructor(); + /** + * Put the tag on top of the virtual desktop environment + * + * @protected + * @memberof OverlayTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof OverlayTag + */ + protected reload(d?: any): void; + /** + * Setter: + * + * Set the width of the tag, the tag width should be in form of: + * `100px` of `80%` + * + * Getter: + * + * Get the tag width + * + * @memberof OverlayTag + */ + set width(v: string); + get width(): string; + /** + * Setter: + * + * Set the tag height, the tag height should be in form of: + * `100px` of `80%` + * + * Getter: + * + * Get the tag height + * + * @memberof OverlayTag + */ + set height(v: string); + get height(): string; + /** + * Calibrate the element when mounting + * + * @protected + * @returns {void} + * @memberof OverlayTag + */ + protected mount(): void; + /** + * Calibrate the width and height of the tag + * + * @returns {void} + * @memberof OverlayTag + */ + calibrate(): void; + /** + * Layout definition of the tag + * + * @protected + * @returns {TagLayoutType[]} + * @memberof OverlayTag + */ + protected layout(): TagLayoutType[]; + } + } + } } -/** - * - * - * @interface Document - */ -interface Document { - mozCancelFullScreen: any; - webkitExitFullscreen: any; - cancelFullScreen: any; +declare namespace OS { + namespace GUI { + namespace tag { + /** + * Meta tag that represents the virtual desktop environment. + * In near future, we may have multiple virtual desktop environments. + * Each desktop environment has a simple file manager and a window + * manager that render the window in a specific order. + * + * @export + * @class DesktopTag + * @extends {FloatListTag} + */ + class DesktopTag extends FloatListTag { + /** + * internal handle to the desktop file location + * + * @private + * @type {API.VFS.BaseFileHandle} + * @memberof DesktopTag + */ + private file; + /** + * local observer that detect if a new child element is + * added or removed + * + * @private + * @type {MutationObserver} + * @memberof DesktopTag + */ + private observer; + /** + * Internal list of the current opened window + * + * @private + * @type {Set} + * @memberof DesktopTag + */ + private window_list; + /** + * Creates an instance of DesktopTag. + * @memberof DesktopTag + */ + constructor(); + /** + * Mount the virtual desktop to the DOM tree + * + * @protected + * @memberof DesktopTag + */ + protected mount(): void; + /** + * Display all files and folders in the specific desktop location + * + * @return {*} {Promise} + * @memberof DesktopTag + */ + refresh(): Promise; + /** + * Remove this element from its parent + * + * @memberof DesktopTag + */ + remove(): void; + /** + * Active a window above all other windows + * + * @private + * @param {WindowTag} win + * @memberof DesktopTag + */ + private selectWindow; + /** + * Render all windows in order from bottom to top + * + * @private + * @memberof DesktopTag + */ + private render; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * A float list is a list of items in which each + * item can be moved (drag and drop) freely + * + * @export + * @class FloatListTag + * @extends {ListViewTag} + */ + class FloatListTag extends ListViewTag { + /** + * Update the current tag, do nothing + * + * @protected + * @param {*} [d] + * @memberof FloatListTag + */ + protected reload(d?: any): void; + /** + * Variable that hold the onready callback of + * the tag. This callback will be called after + * the tag is mounted + * + * @private + * @memberof FloatListTag + */ + private _onready; + /** + *Creates an instance of FloatListTag. + * @memberof FloatListTag + */ + constructor(); + /** + * set the onready callback function to the tag. + * This callback will be called after + * the tag is mounted + * + * @memberof FloatListTag + */ + set onready(v: (e: FloatListTag) => void); + /** + * Setter: + * + * Set the direction of the list item layout. + * Two directions are available: + * - `vertical` + * - `horizontal` + * + * This setter acts as a DOM attribute + * + * Getter: + * + * Get the currently set direction of list + * item layout + * + * @memberof FloatListTag + */ + set dir(v: string); + get dir(): string; + /** + * Disable the dropdown option in this list + * + * @memberof FloatListTag + */ + set dropdown(v: boolean); + /** + * Disable the list buttons configuration in this + * list + * + * @memberof FloatListTag + */ + set buttons(v: GenericObject[]); + /** + * Disable the `showlist` behavior in this list + * + * @protected + * @param {*} e + * @memberof FloatListTag + */ + protected showlist(e: any): void; + /** + * Disable the `dropoff` behavior in this list + * + * @protected + * @param {*} e + * @memberof FloatListTag + */ + protected dropoff(e: any): void; + /** + * Function called when the data of the list + * is changed + * + * @protected + * @memberof FloatListTag + */ + protected ondatachange(): void; + /** + * Mount the list to the DOM tree + * + * @protected + * @returns {void} + * @memberof FloatListTag + */ + protected mount(): void; + /** + * Push an element to the list + * + * @param {GenericObject} v an element data + * @returns + * @memberof FloatListTag + */ + push(v: GenericObject): ListViewItemTag; + /** + * Enable drag and drop on the list + * + * @private + * @param {ListViewItemTag} el the list item DOM element + * @memberof FloatListTag + */ + private enable_drag; + /** + * Calibrate the view of the list + * + * @memberof FloatListTag + */ + calibrate(): void; + } + } + } } declare namespace OS { namespace GUI { /** - * [[TagLayoutType]] interface using by AFX tags to defined - * its internal DOM hierarchy + * + * Interface for an application dock item * * @export - * @interface TagLayoutType + * @interface AppDockItemType */ - interface TagLayoutType { + interface AppDockItemType { /** - * Element tag name + * Reference to the application process represented + * by the dock item * - * @type {string} - * @memberof TagLayoutType + * @type {application.BaseApplication} + * @memberof AppDockItemType */ - el: string; + app: application.BaseApplication; /** - * Children layout of the current element + * Reference to the DOM element of + * the owner dock item * - * @type {TagLayoutType[]} - * @memberof TagLayoutType + * @type {AFXTag} + * @memberof AppDockItemType */ - children?: TagLayoutType[]; - /** - * Reference name of the element used by AFX Tag - * - * @type {string} - * @memberof TagLayoutType - */ - ref?: string; - /** - * CSS class of the element - * - * @type {string} - * @memberof TagLayoutType - */ - class?: string; - /** - * this is the `data-id` attribute of the element, - * can be query by the [[aid]] Tag API function. - * Not to be confused with the DOM `id` attribute - * - * @type {(string | number)} - * @memberof TagLayoutType - */ - id?: string | number; - /** - * Tooltip text of the element - * - * @type {(string | FormattedString)} - * @memberof TagLayoutType - */ - tooltip?: string | FormattedString; - /** - * `data-width` of the element, not to be confused with - * the `width` attribute of the DOM element - * - * @type {number|string} - * @memberof TagLayoutType - */ - width?: number | string; - /** - ** `data-height` of the element, not to be confused with - * the `height` attribute of the DOM element - * - * @type {number|string} - * @memberof TagLayoutType - */ - height?: number | string; - } - /** - * Data type for event issued by AFX tags - * - * @export - * @interface TagEventDataType - * @template T item template - */ - interface TagEventDataType { - /** - * Reference to the item involved in the event - * - * @type {T} - * @memberof TagEventDataType - */ - item?: T; + domel?: AFXTag; [propName: string]: any; } - /** - * Format of the event issued by AFX tags - * - * @export - * @interface TagEventType - * @template T data type - */ - interface TagEventType { - /** - * `data-id` of the tag that trigger the - * event - * - * @type {(number | string)} - * @memberof TagEventType - */ - id: number | string; - /** - * Data object of the event - * - * @type {T} - * @memberof TagEventType - */ - data: T; - } - /** - * Drag and Drop data type sent between mouse events - * - * @export - * @interface DnDEventDataType - * @template T - */ - interface DnDEventDataType { - /** - * Reference to the source DOM element - * - * @type {T} - * @memberof DnDEventDataType - */ - from: T; - /** - * Reference to the target DOM element - * - * @type {T} - * @memberof DnDEventDataType - */ - to: T; - } - /** - * Tag event callback type - */ - type TagEventCallback = (e: TagEventType) => void; - /** - * Base abstract class for tag implementation, any AFX tag should be - * subclass of this class - * - * @export - * @abstract - * @class AFXTag - * @extends {HTMLElement} - */ - abstract class AFXTag extends HTMLElement { - /** - * The announcer object of the tag - * - * @type {API.Announcer} - * @memberof AFXTag - */ - observable: API.Announcer; - /** - * Reference to some of the tag's children - * element. This reference object is built - * based on the `ref` property found in the - * tag layout [[TagLayoutType]] - * - * @protected - * @type {GenericObject} - * @memberof AFXTag - */ - protected refs: GenericObject; - /** - * boolean value indicated whether the tag - * is already mounted in the DOM tree - * - * @protected - * @type {boolean} - * @memberof AFXTag - */ - protected _mounted: boolean; - /** - *Creates an instance of AFXTag. - * @memberof AFXTag - */ - constructor(); - /** - * This function verifies if a property name of the input object - * corresponds to a setter of the current tag. If this is the - * case, it sets the value of that property to the setter - * - * @param {GenericObject} v input object - * @memberof AFXTag - */ - set(v: GenericObject): void; - /** - * Setter to set the tooltip text to the current tag. - * The text should be in the following format: - * ```text - * cr|cl|ct|cb: tooltip text - * ``` - * - * @memberof AFXTag - */ - set tooltip(v: string); - /** - * - * This function looking for a property name of the tag - * in its prototype chain. The descriptor of the property - * will be returned if it exists - * - * @private - * @param {string} k the property name to be queried - * @returns {PropertyDescriptor} the property descriptor or undefined - * @memberof AFXTag - */ - private descriptor_of; - /** - * Setter: set the id of the tag in string or number - * - * Getter: get the id of the current tag - * - * @memberof AFXTag - */ - set aid(v: string | number); - get aid(): string | number; - /** - * Implementation from HTMLElement interface, - * this function mount the current tag hierarchy - * - * @returns {void} - * @memberof AFXTag - */ - sync(): void; - /** - * Generate the DOM hierarchy of the current tag - * - * @param {API.Announcer} o observable object - * @memberof AFXTag - */ - afxml(o: API.Announcer): void; - /** - * Update the current tag hierarchy - * - * @param {*} d any data object - * @memberof AFXTag - */ - update(d: any): void; - /** - * Init the current tag, this function - * is called before the [[mount]] function - * - * @protected - * @abstract - * @memberof AFXTag - */ - protected abstract init(): void; - /** - * Mount only the current tag - * - * @protected - * @abstract - * @memberof AFXTag - */ - protected abstract mount(): void; - /** - * Layout definition of a tag - * - * @protected - * @abstract - * @returns {TagLayoutType[]} tag layout object - * @memberof AFXTag - */ - protected abstract layout(): TagLayoutType[]; - /** - * Update only the current tag, this function is - * called by [[update]] before chaining the - * update process to its children - * - * @protected - * @abstract - * @param {*} [d] - * @memberof AFXTag - */ - protected abstract reload(d?: any): void; - /** - * This function is used to re-render the current - * tag - * - * @protected - * @memberof AFXTag - */ - protected calibrate(): void; - /** - * This function parses the input layout object - * and generates all the elements defined by - * the tag - * - * @private - * @param {TagLayoutType} tag tag layout object - * @returns {Element} the DOM element specified by the tag layout - * @memberof AFXTag - */ - private mkui; - /** - * This function inserts or removes an attribute name - * to/from the target element based on the input `flag`. - * - * @protected - * @param {boolean} flag indicates whether the attribute name should be inserted o removed - * @param {string} v the attribute name - * @param {HTMLElement} [el] the target element - * @memberof AFXTag - */ - protected attsw(flag: boolean, v: string, el?: HTMLElement): void; - /** - * Insert the attribute name to the target element - * - * @protected - * @param {string} v the attribute name - * @param {HTMLElement} [el] the target element - * @memberof AFXTag - */ - protected atton(v: string, el?: HTMLElement): void; - /** - * Remove the attribute name from the target element - * - * @protected - * @param {string} v attribute name - * @param {HTMLElement} [el] the target element - * @memberof AFXTag - */ - protected attoff(v: string, el?: HTMLElement): void; - /** - * Verify if the target element has an attribute name - * - * @protected - * @param {string} v attribute name - * @param {HTMLElement} [el] target element - * @returns {boolean} - * @memberof AFXTag - */ - protected hasattr(v: string, el?: HTMLElement): boolean; - } - /** - * All the AFX tags are defined in this namespace, - * these tags are defined as custom DOM elements and will be - * stored in the `customElements` registry of the browser - */ namespace tag { /** - * Define an AFX tag as a custom element and add it to the - * global `customElements` registry. If the tag is redefined, i.e. - * the tag already exists, its behavior will be updated with the - * new definition + * This class define the AntOS system application dock tag * * @export - * @template T all classes that extends [[AFXTag]] - * @param {string} name name of the tag - * @param {{ new (): T }} cls the class that defines the tag - * @returns {void} + * @class AppDockTag + * @extends {AFXTag} */ - function define(name: string, cls: { - new (): T; - }): void; + class AppDockTag extends AFXTag { + /** + * variable holds the application select event + * callback handle + * + * @private + * @type {TagEventCallback} + * @memberof AppDockTag + */ + private _onappselect; + /** + * Items data of the dock + * + * @private + * @type {AppDockItemType[]} + * @memberof AppDockTag + */ + private _items; + /** + * Reference to the currently select application + * process in the dock + * + * @private + * @type {AppDockItemType} + * @memberof AppDockTag + */ + private _selectedItem; + /** + *Creates an instance of AppDockTag. + * @memberof AppDockTag + */ + constructor(); + /** + * Implementation of the abstract function: Update the current tag. + * It do nothing for this tag + * + * @protected + * @param {*} [d] + * @memberof AppDockTag + */ + protected reload(d?: any): void; + /** + * Init the tag before mounting + * + * @protected + * @memberof AppDockTag + */ + protected init(): void; + /** + * The tag layout, it is empty on creation but elements will + * be added automatically to it in operation + * + * @protected + * @returns {TagLayoutType[]} + * @memberof AppDockTag + */ + protected layout(): TagLayoutType[]; + /** + * getter to get the dock items + * + * @readonly + * @type {AppDockItemType[]} + * @memberof AppDockTag + */ + get items(): AppDockItemType[]; + /** + * Setter: + * + * set the selected application in the dock + * this will trigger two event: + * - `focus`: on the selected application + * - `blur`: on all other applications on the dock + * + * Getter: + * + * Get the current selected application + * on the dock + * + * @memberof AppDockTag + */ + set selectedApp(v: application.BaseApplication); + get selectedApp(): application.BaseApplication; + /** + * Get selected item of the dock + * + * @readonly + * @type {AppDockItemType} + * @memberof AppDockTag + */ + get selectedItem(): AppDockItemType; + /** + * When a new application process is created, this function + * will be called to add new application entry to the dock. + * The added application will becomes the current selected + * application + * + * @param {AppDockItemType} item an application dock item entry + * @memberof AppDockTag + */ + newapp(item: AppDockItemType): void; + /** + * Delete and application entry from the dock. + * This function will be called when an application + * is exit + * + * @param {BaseApplication} a the application to be removed from the dock + * @memberof AppDockTag + */ + removeapp(a: application.BaseApplication): void; + /** + * Mount the current dock tag + * + * @protected + * @memberof AppDockTag + */ + protected mount(): void; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * Tag that define system calendar widget + * + * @export + * @class CalendarTag + * @extends {AFXTag} + */ + class CalendarTag extends AFXTag { + /** + * The current selected day + * + * @private + * @type {number} + * @memberof CalendarTag + */ + private _day; + /** + * The current selected month + * + * @private + * @type {number} + * @memberof CalendarTag + */ + private _month; + /** + * The current selected year + * + * @private + * @type {number} + * @memberof CalendarTag + */ + private _year; + /** + * The current selected date object + * + * @private + * @type {Date} + * @memberof CalendarTag + */ + private _selectedDate; + /** + * placeholder for date select event callback + * + * @private + * @type {TagEventCallback} + * @memberof CalendarTag + */ + private _ondateselect; + /** + *Creates an instance of CalendarTag. + * @memberof CalendarTag + */ + constructor(); + /** + * Init the tag before mounting + * + * @protected + * @memberof CalendarTag + */ + protected init(): void; + /** + * Update the current tag, doing nothing in this tag + * + * @protected + * @param {*} [d] any data object + * @memberof CalendarTag + */ + protected reload(d?: any): void; + /** + * Get the current selected date in the widget + * + * @readonly + * @type {Date} + * @memberof CalendarTag + */ + get selectedDate(): Date; + /** + * Set the date select event callback handle for the widget + * + * @memberof CalendarTag + */ + set ondateselect(v: TagEventCallback); + /** + * Mount the current widget to the DOM tree + * + * @protected + * @memberof CalendarTag + */ + protected mount(): void; + /** + * This function triggers the date select event + * + * @private + * @param {TagEventType} e AFX tag event data [[TagEventType]] + * @returns {void} + * @memberof CalendarTag + */ + private dateselect; + /** + * Calibrate the layout of the tag + * + * @protected + * @memberof CalendarTag + */ + protected calibrate(): void; + /** + * Display the previous month of the current month + * + * @private + * @memberof CalendarTag + */ + private prevmonth; + /** + * Display the next month of the current month + * + * @private + * @returns + * @memberof CalendarTag + */ + private nextmonth; + /** + * Visualize the calendar base on input date + * + * @private + * @param {Date} date + * @memberof CalendarTag + */ + private calendar; + /** + * Layout definition of the widget + * + * @protected + * @returns {TagLayoutType[]} + * @memberof CalendarTag + */ + protected layout(): TagLayoutType[]; + } } } } @@ -8524,1719 +8424,2058 @@ declare namespace OS { } } } -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A tile layout organize it child elements - * in a fixed horizontal or vertical direction. - * - * The size of each child element is attributed based - * on its configuration of automatically based on the - * remaining space in the layout - * - * - * @export - * @class TileLayoutTag - * @extends {AFXTag} - */ - class TileLayoutTag extends AFXTag { - /** - *C reates an instance of TileLayoutTag. - * @memberof TileLayoutTag - */ - constructor(); - /** - * Do nothing - * - * @protected - * @memberof TileLayoutTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @param {*} [d] - * @memberof TileLayoutTag - */ - protected reload(d?: any): void; - /** - * Setter: Set the name of the tile container, should be: `hbox` or `vbox` - * - * Getter: Get the name of the tile container - * - * @memberof TileLayoutTag - */ - set name(v: string); - get name(): string; - /** - * Setter: - * - * SET the layout direction, should be: - * - `row`: horizontal direction - * - `column`: vertical direction - * - * Getter: - * - * Get layout direction - * - * @memberof TileLayoutTag - */ - set dir(v: "row" | "column"); - get dir(): "row" | "column"; - /** - * Mount the element - * - * @protected - * @returns {void} - * @memberof TileLayoutTag - */ - protected mount(): void; - /** - * re-organize the layout - * - * @returns {void} - * @memberof TileLayoutTag - */ - calibrate(): void; - /** - * Organize the layout in horizontal direction, only work when - * the layout direction set to horizontal - * - * @private - * @returns {void} - * @memberof TileLayoutTag - */ - private hcalibrate; - /** - * Organize the layout in vertical direction, only work when - * the layout direction set to vertical - * - * @private - * @returns {void} - * @memberof TileLayoutTag - */ - private vcalibrate; - /** - * Layout definition - * - * @returns - * @memberof TileLayoutTag - */ - layout(): { - el: string; - ref: string; - }[]; - } - /** - * A HBox organize its child elements in horizontal direction - * - * @export - * @class HBoxTag - * @extends {TileLayoutTag} - */ - class HBoxTag extends TileLayoutTag { - /** - * Creates an instance of HBoxTag. - * @memberof HBoxTag - */ - constructor(); - /** - * Mount the tag - * - * @protected - * @memberof HBoxTag - */ - protected mount(): void; - } - /** - * A VBox organize its child elements in vertical direction - * - * @export - * @class VBoxTag - * @extends {TileLayoutTag} - */ - class VBoxTag extends TileLayoutTag { - /** - *Creates an instance of VBoxTag. - * @memberof VBoxTag - */ - constructor(); - /** - * Mount the tag - * - * @protected - * @memberof VBoxTag - */ - protected mount(): void; - } - } - } -} -/// -declare namespace OS { - namespace GUI { - namespace tag { - /** - * This tag define a basic button and its behavior - * - * @export - * @class ButtonTag - * @extends {AFXTag} - */ - class ButtonTag extends AFXTag { - /** - * Variable hold the button click callback handle - * - * @private - * @type {TagEventCallback} - * @memberof ButtonTag - */ - private _onbtclick; - /** - * Custom user data - * - * @type {GenericObject} - * @memberof ButtonTag - */ - data: GenericObject; - /** - *Creates an instance of ButtonTag. - * @memberof ButtonTag - */ - constructor(); - /** - * Set the click callback handle for the target button - * - * @memberof ButtonTag - */ - set onbtclick(v: TagEventCallback); - /** - * Set the path to the button icon, the path should be - * a VFS file path - * - * @memberof ButtonTag - */ - set icon(v: string); - /** - * Set the icon class to the button, this property - * allows to style the button icon using CSS - * - * @memberof ButtonTag - */ - set iconclass(v: string); - /** - * Setter: Set the text of the button - * - * Getter: Get the current button test - * - * @memberof ButtonTag - */ - set text(v: string | FormattedString); - get text(): string | FormattedString; - /** - * Setter: Enable or disable the button - * - * Getter: Get the `enable` property of the button - * - * @memberof ButtonTag - */ - set enable(v: boolean); - get enable(): boolean; - /** - * Setter: set or remove the attribute `selected` of the button - * - * Getter: check whether the attribute `selected` of the button is set - * - * @memberof ButtonTag - */ - set selected(v: boolean); - get selected(): boolean; - /** - * Setter: activate or deactivate the toggle mode of the button - * - * Getter: Check whether the button is in toggle mode - * - * @memberof ButtonTag - */ - set toggle(v: boolean); - get toggle(): boolean; - /** - * Mount the tag - * - * @protected - * @memberof ButtonTag - */ - protected mount(): void; - /** - * Init the tag before mounting - * - * @protected - * @memberof ButtonTag - */ - protected init(): void; - /** - * Re-calibrate the button, do nothing in this tag - * - * @protected - * @memberof ButtonTag - */ - protected calibrate(): void; - /** - * Update the current tag, do nothing in this tag - * - * @param {*} [d] - * @memberof ButtonTag - */ - reload(d?: any): void; - /** - * Button layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ButtonTag - */ - protected layout(): TagLayoutType[]; - } - } - } +declare type VFSFileHandleClass = { + new (...args: any[]): OS.API.VFS.BaseFileHandle; +}; +interface String { + /** + * Convert a string to VFS file handle. + * + * This function will create a file handle object from the string + * with the help of [[VFS.findHandles]] + * + * @returns {OS.API.VFS.BaseFileHandle} + * @memberof String + */ + asFileHandle(): OS.API.VFS.BaseFileHandle; } declare namespace OS { - namespace GUI { - namespace tag { + namespace API { + /** + * User permission data type + * + * @export + * @interface UserPermissionType + */ + interface UserPermissionType { + read: boolean; + write: boolean; + exec: boolean; + } + /** + * VFS file meta-data data type + * + * @export + * @interface FileInfoType + */ + interface FileInfoType { /** - * Tag that define system calendar widget + * File mime type + * + * @type {string} + * @memberof FileInfoType + */ + mime: string; + /** + * File size + * + * @type {number} + * @memberof FileInfoType + */ + size: number; + /** + * File name + * + * @type {string} + * @memberof FileInfoType + */ + name: string; + /** + * File path + * + * @type {string} + * @memberof FileInfoType + */ + path: string; + /** + * File type: + * - `file` + * - `dir` + * - `app` + * + * @type {string} + * @memberof FileInfoType + */ + type: string; + /** + * File permission + * + * @type {{ + * group: UserPermissionType; + * owner: UserPermissionType; + * other: UserPermissionType; + * }} + * @memberof FileInfoType + */ + perm?: { + /** + * Group permission + * + * @type {UserPermissionType} + */ + group: UserPermissionType; + /** + * Owner permission + * + * @type {UserPermissionType} + */ + owner: UserPermissionType; + /** + * Other permission + * + * @type {UserPermissionType} + */ + other: UserPermissionType; + }; + /** + * Creation time + * + * @type {string} + * @memberof FileInfoType + */ + ctime?: string; + /** + * Modification time + * + * @type {string} + * @memberof FileInfoType + */ + mtime?: string; + /** + * Group id + * + * @type {number} + * @memberof FileInfoType + */ + gid?: number; + /** + * User id + * + * @type {number} + * @memberof FileInfoType + */ + uid?: number; + [propName: string]: any; + } + /** + * This namespace is dedicated to all APIs related to + * AntOS Virtual File System (VFS) + */ + namespace VFS { + /** + * Placeholder stores VFS file protocol patterns and its attached file handle class. + * + */ + const handles: GenericObject; + /** + * Register a protocol to a handle class * * @export - * @class CalendarTag - * @extends {AFXTag} + * @param {string} protos VFS protocol pattern + * @param {VFSFileHandleClass} cls handle class */ - class CalendarTag extends AFXTag { - /** - * The current selected day - * - * @private - * @type {number} - * @memberof CalendarTag - */ - private _day; - /** - * The current selected month - * - * @private - * @type {number} - * @memberof CalendarTag - */ - private _month; - /** - * The current selected year - * - * @private - * @type {number} - * @memberof CalendarTag - */ - private _year; - /** - * The current selected date object - * - * @private - * @type {Date} - * @memberof CalendarTag - */ - private _selectedDate; - /** - * placeholder for date select event callback - * - * @private - * @type {TagEventCallback} - * @memberof CalendarTag - */ - private _ondateselect; - /** - *Creates an instance of CalendarTag. - * @memberof CalendarTag - */ - constructor(); - /** - * Init the tag before mounting - * - * @protected - * @memberof CalendarTag - */ - protected init(): void; - /** - * Update the current tag, doing nothing in this tag - * - * @protected - * @param {*} [d] any data object - * @memberof CalendarTag - */ - protected reload(d?: any): void; - /** - * Get the current selected date in the widget - * - * @readonly - * @type {Date} - * @memberof CalendarTag - */ - get selectedDate(): Date; - /** - * Set the date select event callback handle for the widget - * - * @memberof CalendarTag - */ - set ondateselect(v: TagEventCallback); - /** - * Mount the current widget to the DOM tree - * - * @protected - * @memberof CalendarTag - */ - protected mount(): void; - /** - * This function triggers the date select event - * - * @private - * @param {TagEventType} e AFX tag event data [[TagEventType]] - * @returns {void} - * @memberof CalendarTag - */ - private dateselect; - /** - * Calibrate the layout of the tag - * - * @protected - * @memberof CalendarTag - */ - protected calibrate(): void; - /** - * Display the previous month of the current month - * - * @private - * @memberof CalendarTag - */ - private prevmonth; - /** - * Display the next month of the current month - * - * @private - * @returns - * @memberof CalendarTag - */ - private nextmonth; - /** - * Visualize the calendar base on input date - * - * @private - * @param {Date} date - * @memberof CalendarTag - */ - private calendar; - /** - * Layout definition of the widget - * - * @protected - * @returns {TagLayoutType[]} - * @memberof CalendarTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { + function register(protos: string, cls: VFSFileHandleClass): void; /** - * List item event data type - */ - type ListItemEventData = TagEventDataType; - /** - * A list item represent the individual view of an item in the [[ListView]]. - * This class is an abstract prototype class, implementation of any - * list view item should extend it + * Load custom VFS handles if the package vfsx available * + * @export + * @param {boolean} [force] force load the file + * @return {*} {Promise} + */ + function loadVFSX(force?: boolean): Promise; + /** + * Looking for a attached file handle class of a string protocol + * + * When converting a string to file handle, the system will look + * for a protocol pattern in the string, if the protocol found, + * its attached handle class (found in [[VFS.handles]]) will be + * used to initialize a file handle object from the string + * + * ```typescript + * "home://data/test.txt".asFileHandle() // -> an instance of RemoteFileHandle + * ``` + * @export + * @param {string} proto protocol string + * @returns {VFSFileHandleClass[]} + */ + function findHandles(proto: string): VFSFileHandleClass[]; + /** + * Abstract prototype of all all VFS file handle definition. + * + * This prototype provides a standardized interface to access + * to different underlay file systems such as remote file, + * cloud file (Dropbox, Google drive, etc.), URL or memory-based file * * @export * @abstract - * @class ListViewItemTag - * @extends {AFXTag} + * @class BaseFileHandle */ - abstract class ListViewItemTag extends AFXTag { + abstract class BaseFileHandle { /** - * Data placeholder for the list item + * Flag indicates whether the file is dirty * - * @private - * @type {GenericObject} - * @memberof ListViewItemTag - */ - private _data; - /** - * placeholder for the item select event callback - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onselect; - /** - * Context menu event callback handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onctxmenu; - /** - * Click event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onclick; - /** - * Double click event callback handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _ondbclick; - /** - * Item close event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onclose; - /** - *Creates an instance of ListViewItemTag. - * @memberof ListViewItemTag - */ - constructor(); - /** - * Setter: Turn on/off the `closable` feature of the list item - * - * Getter: Check whether the item is closable - * - * @memberof ListViewItemTag - */ - set closable(v: boolean); - get closable(): boolean; - /** - * Set item select event handle - * - * @memberof ListViewItemTag - */ - set onitemselect(v: TagEventCallback); - /** - * Setter: select/unselect the current item - * - * Getter: Check whether the current item is selected - * - * @memberof ListViewItemTag - */ - set selected(v: boolean); - get selected(): boolean; - /** - * Set the context menu event handle - * - * @memberof ListViewItemTag - */ - set onctxmenu(v: TagEventCallback); - /** - * Set the item click event handle - * - * @memberof ListViewItemTag - */ - set onitemclick(v: TagEventCallback); - /** - * Set the item double click event handle - * - * @memberof ListViewItemTag - */ - set onitemdbclick(v: TagEventCallback); - /** - * set the item close event handle - * - * @memberof ListViewItemTag - */ - set onitemclose(v: TagEventCallback); - /** - * Mount the tag and bind some events - * - * @protected - * @memberof ListViewItemTag - */ - protected mount(): void; - /** - * Layout definition of the item tag. - * This function define the outer layout of the item. - * Custom inner layout of each item implementation should - * be defined in [[itemlayout]] - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ListViewItemTag - */ - protected layout(): TagLayoutType[]; - /** - * Setter: - * - * Set the data of the list item. This will - * trigger the [[ondatachange]] function - * - * Getter: - * - * Get the data of the current list item - * - * @memberof ListViewItemTag - */ - set data(v: GenericObject); - get data(): GenericObject; - /** - * Any subclass of this class should implement this - * function to provide its custom item layout - * - * @protected - * @abstract - * @returns {TagLayoutType} - * @memberof ListViewItemTag - */ - protected abstract itemlayout(): TagLayoutType; - /** - * This function is called when the item data is changed. - * It should be implemented in all subclass of this class - * - * @protected - * @abstract - * @memberof ListViewItemTag - */ - protected abstract ondatachange(): void; - } - /** - * The layout of a simple list item contains only a - * AFX label - * - * @export - * @class SimpleListItemTag - * @extends {ListViewItemTag} - */ - class SimpleListItemTag extends ListViewItemTag { - /** - *Creates an instance of SimpleListItemTag. - * @memberof SimpleListItemTag - */ - constructor(); - /** - * Reset some property to default - * - * @protected - * @memberof SimpleListItemTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @memberof SimpleListItemTag - */ - protected calibrate(): void; - /** - * Refresh the inner label when the item data - * is changed - * - * @protected - * @returns {void} - * @memberof SimpleListItemTag - */ - protected ondatachange(): void; - /** - * Re-render the list item - * - * @protected - * @memberof SimpleListItemTag - */ - protected reload(): void; - /** - * List item custom layout definition - * - * @protected - * @returns {TagLayoutType} - * @memberof SimpleListItemTag - */ - protected itemlayout(): TagLayoutType; - } - /** - * This tag defines a traditional or a dropdown list widget. - * It contains a collection of list items in which layout - * of each item may be variable - * - * @export - * @class ListViewTag - * @extends {AFXTag} - */ - class ListViewTag extends AFXTag { - /** - * placeholder of list select event handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewTag - */ - private _onlistselect; - /** - * placeholder of list double click event handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewTag - */ - private _onlistdbclick; - /** - * placeholder of list drag and drop event handle - * - * @private - * @type {TagEventCallback>} - * @memberof ListViewTag - */ - private _ondragndrop; - /** - * placeholder of list item close event handle - * - * @private - * @memberof ListViewTag - */ - private _onitemclose; - /** - * placeholder of drag and drop mouse down event handle - * - * @private - * @memberof ListViewTag - */ - private _onmousedown; - /** - * placeholder of drag and drop mouse up event handle - * - * @private - * @memberof ListViewTag - */ - private _onmouseup; - /** - * placeholder of drag and drop mouse move event handle - * - * @private - * @memberof ListViewTag - */ - private _onmousemove; - /** - * Reference to the latest selected DOM item - * - * @private - * @type {ListViewItemTag} - * @memberof ListViewTag - */ - private _selectedItem; - /** - * A collection of selected items in the list. - * The maximum size of this collection is 1 if - * the [[multiselect]] feature is disabled - * - * @private - * @type {ListViewItemTag[]} - * @memberof ListViewTag - */ - private _selectedItems; - /** - * Data placeholder of the list - * - * @private - * @type {GenericObject[]} - * @memberof ListViewTag - */ - private _data; - /** - * Event data passing between mouse event when performing - * drag and drop on the list - * - * @private - * @type {{ from: ListViewItemTag; to: ListViewItemTag }} - * @memberof ListViewTag - */ - private _dnd; - /** - *Creates an instance of ListViewTag. - * @memberof ListViewTag - */ - constructor(); - /** - * Reset the tag's properties to the default values - * - * @protected - * @memberof ListViewTag - */ - protected init(): void; - /** - * This function does nothing - * - * @protected - * @param {*} [d] - * @memberof ListViewTag - */ - protected reload(d?: any): void; - /** - * Setter: toggle between dropdown and traditional list - * - * Getter: Check whether the list is dropdown or traditional list - * - * @memberof ListViewTag - */ - set dropdown(v: boolean); - /** - * Set drag and drop event handle - * - * @memberof ListViewTag - */ - set ondragndrop(v: TagEventCallback>); - /** - * Set list select event handle - * - * @memberof ListViewTag - */ - set onlistselect(v: TagEventCallback); - /** - * Set double click event handle - * - * @memberof ListViewTag - */ - set onlistdbclick(v: TagEventCallback); - /** - * Set item close event handle - * - * @memberof ListViewTag - */ - set onitemclose(v: (e: TagEventType) => boolean); - get dropdown(): boolean; - /** - * Setter: - * - * Set the default tag name of list's items. - * If the tag name is not specified in the - * data of a list item, this tag will be used - * - * Getter: - * - * Get the default tag name of list item - * - * @memberof ListViewTag - */ - set itemtag(v: string); - get itemtag(): string; - /** - * Setter: - * - * Turn on/off of the `multiselect` feature - * - * Getter: - * - * Check whether multi-select is allowed - * in this list - * - * @memberof ListViewTag - */ - set multiselect(v: boolean); - get multiselect(): boolean; - /** - * Setter: Enable/disable drag and drop event in the list - * - * Getter: Check whether the drag and drop event is enabled - * - * @memberof ListViewTag - */ - set dragndrop(v: boolean); - get dragndrop(): boolean; - /** - * Set the buttons layout of the list. - * Button layout allows to add some custom - * behaviors to the list. - * - * Each button data should define the [[onbtclick]] - * event handle to specify the custom behavior - * - * When the list is configured as dropdown. The buttons - * layout will be disabled - * - * Example of a button data: - * - * ``` - * { - * text: "Button text", - * icon: "home://path/to/icon.png", - * iconclass: "icon-class-name", - * onbtclick: (e) => console.log(e) - * } - * ``` - * - * @memberof ListViewTag - */ - set buttons(v: GenericObject[]); - /** - * Getter: Get data of the list - * - * Setter: Set data to the list - * - * @type {GenericObject[]} - * @memberof ListViewTag - */ - get data(): GenericObject[]; - set data(data: GenericObject[]); - /** - * Do nothing - * - * @protected - * @memberof ListViewTag - */ - protected ondatachange(): void; - /** - * Setter: Select list item(s) by their indexes - * - * Getter: Get the indexes of all selected items - * - * @memberof ListViewTag - */ - set selected(idx: number | number[]); - /** - * Get the latest selected item - * - * @readonly - * @type {ListViewItemTag} - * @memberof ListViewTag - */ - get selectedItem(): ListViewItemTag; - /** - * Get all the selected items - * - * @readonly - * @type {ListViewItemTag[]} - * @memberof ListViewTag - */ - get selectedItems(): ListViewItemTag[]; - get selected(): number | number[]; - /** - * Add an item to the beginning of the list - * - * @param {GenericObject} item - * @returns {ListViewItemTag} the added list item element - * @memberof ListViewTag - */ - unshift(item: GenericObject): ListViewItemTag; - /** - * check whether the list has data - * - * @private - * @param {GenericObject} v - * @returns - * @memberof ListViewTag - */ - private has_data; - /** - * Add an item to the beginning or end of the list - * - * @param {GenericObject} item list item data - * @param {boolean} [flag] indicates whether to add the item in the beginning of the list - * @returns {ListViewItemTag} the added list item element - * @memberof ListViewTag - */ - push(item: GenericObject, flag?: boolean): ListViewItemTag; - /** - * Delete an item - * - * @param {ListViewItemTag} item item DOM element - * @memberof ListViewTag - */ - delete(item: ListViewItemTag): void; - /** - * Select item next to the currently selected item. - * If there is no item selected, the first item will - * be selected - * - * @returns {void} - * @memberof ListViewTag - */ - selectNext(): void; - /** - * Select the previous item in the list. - * - * @returns {void} - * @memberof ListViewTag - */ - selectPrev(): void; - /** - * Unselect all the selected items in the list - * - * @returns {void} - * @memberof ListViewTag - */ - unselect(): void; - /** - * This function triggers the click event on an item - * - * @private - * @param {TagEventType} e tag event object - * @param {boolean} flag indicates whether this is a double click event - * @returns {void} - * @memberof ListViewTag - */ - private iclick; - /** - * This function triggers the double click event on an item - * - * @private - * @param {TagEventType} e tag event object - * @returns - * @memberof ListViewTag - */ - private idbclick; - /** - * This function triggers the list item select event - * - * @private - * @param {TagEventType} e tag event object - * @returns - * @memberof ListViewTag - */ - private iselect; - /** - * Mount the tag and bind some basic event - * - * @protected - * @returns {void} - * @memberof ListViewTag - */ - protected mount(): void; - /** - * This function triggers the item close event - * - * @private - * @param {TagEventType} e tag event object - * @returns {void} - * @memberof ListViewTag - */ - private iclose; - /** - * Show the dropdown list. - * This function is called only when the list is a dropdown - * list - * - * @protected - * @param {*} e - * @returns {void} - * @memberof ListViewTag - */ - protected showlist(e: any): void; - /** - * Hide the dropdown list. - * This function is called only when the list is a dropdown - * list - * - * @protected - * @param {*} e - * @memberof ListViewTag - */ - protected dropoff(e: any): void; - /** - * calibrate the list layout - * - * @protected - * @returns {void} - * @memberof ListViewTag - */ - protected calibrate(): void; - /** - * List view layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ListViewTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A system panel contains the following elements: - * - Spotlight to access to applications menu - * - Current focused application menu - * - System tray for all running services running in background - * - * @export - * @class SystemPanelTag - * @extends {AFXTag} - */ - class SystemPanelTag extends AFXTag { - /** - * Reference to spotlight data - * - * @private - * @type {(GenericObject)} - * @memberof SystemPanelTag - */ - private _osmenu; - /** - * Placeholder indicates whether the spotlight is currently shown - * - * @private * @type {boolean} - * @memberof SystemPanelTag + * @memberof BaseFileHandle */ - private _view; + dirty: boolean; /** - * Store pending loading task + * Once read, file content will be cached in this placeholder * * @private - * @type {number[]} - * @memberof SystemPanelTag + * @type {*} + * @memberof BaseFileHandle */ - private _pending_task; + private _cache; /** - * Loading animation check timeout + * Flag indicated whether the file meta-data is loaded * - * @memberof SystemPanelTag + * @type {boolean} + * @memberof BaseFileHandle */ - private _loading_toh; + ready: boolean; /** - * Place holder for a private callback function + * File path * - * @private - * @memberof SystemPanelTag + * @type {string} + * @memberof BaseFileHandle */ - private _cb; + path: string; /** - * Place holder for system app list + * File protocol e.g: + * - `os://` + * - `home://` * - * @private - * @type {GenericObject[]} - * @memberof SystemPanelTag + * @type {string} + * @memberof BaseFileHandle */ - private app_list; + protocol: string; /** - *Creates an instance of SystemPanelTag. - * @memberof SystemPanelTag + * List of path segments + * + * @type {string[]} + * @memberof BaseFileHandle */ - constructor(); + genealogy: string[]; /** - * Do nothing + * File base name + * + * @type {string} + * @memberof BaseFileHandle + */ + basename: string; + /** + * Once loaded, [[ready]] will be set to true and + * file meta-data will be stored in this place holder + * + * @type {FileInfoType} + * @memberof BaseFileHandle + */ + info: FileInfoType; + /** + * File extension + * + * @type {string} + * @memberof BaseFileHandle + */ + ext: string; + /** + * + * File type + * @type {string} + * @memberof BaseFileHandle + */ + type: string; + /** + *Creates an instance of BaseFileHandle. + * @param {string} path file path + * @memberof BaseFileHandle + */ + constructor(path: string); + /** + * Set a file path to the current file handle + * + * @param {string} p + * @returns {void} + * @memberof BaseFileHandle + */ + setPath(p: string): void; + /** + * Getter: Get the file basename + * Setter: set the file name + * + * @returns {string} + * @memberof BaseFileHandle + */ + get filename(): string; + set filename(v: string); + /** + * Getter: Get the file cache + * Setter: set the file cache + * + * @returns {any} + * @memberof BaseFileHandle + */ + get cache(): any; + set cache(v: any); + /** + * Set data to the file cache + * + * @param {*} v data object + * @returns {BaseFileHandle} + * @memberof BaseFileHandle + */ + setCache(v: any): BaseFileHandle; + /** + * Return the object itself + * + * @returns {BaseFileHandle} + * @memberof BaseFileHandle + */ + asFileHandle(): BaseFileHandle; + /** + * Check whether the current file is the root of the file tree + * + * @returns {boolean} + * @memberof BaseFileHandle + */ + isRoot(): boolean; + /** + * Check whether the current file is a hidden file + * + * @returns {boolean} + * @memberof BaseFileHandle + */ + isHidden(): boolean; + /** + * Get hash number of the current file path + * + * @returns {number} + * @memberof BaseFileHandle + */ + hash(): number; + /** + * Convert the current file cache to Base64 * * @protected - * @memberof SystemPanelTag + * @param {string} t type of the file cache: + * - `object` + * - `mime type` + * @returns {(Promise)} promise on the converted data + * @memberof BaseFileHandle */ - protected init(): void; + protected b64(t: string): Promise; /** - * Do nothing + * Get the parent file handle of the current file + * + * @returns {BaseFileHandle} + * @memberof BaseFileHandle + */ + parent(): BaseFileHandle; + /** + * Load the file meta-data before performing + * any task + * + * @returns {Promise} a promise on file meta-data + * @memberof BaseFileHandle + */ + onready(): Promise; + /** + * Public read operation + * + * This function calls the [[_rd]] function to perform the operation. + * + * If the current file is a directory, then the operation + * will return the meta-data of all files inside of the directory. + * Otherwise, file content will be returned + * + * @param {string} t data type + * - jsonp: the response is an json object + * - script: the response is a javascript code + * - xml, html: the response is a XML/HTML object + * - text: plain text + * - binary + * + * @returns {Promise} a promise on the file content + * @memberof BaseFileHandle + */ + read(t?: string): Promise; + /** + * Write the file cache to the actual file + * + * This function calls the [[_wr]] function to perform the operation + * + * @param {string} t data type + * - `base64` + * - `object` + * - `mime type` + * + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + write(t: string): Promise; + /** + * Sub-directory creation + * + * This function calls the [[_mk]] function to perform the operation + * + * @param {string} d sub directory name + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + mk(d: string): Promise; + /** + * Delete the file + * + * This function calls the [[_rm]] function to perform the operation + * + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + remove(): Promise; + /** + * Upload a file to the current directory + * + * Only work when the current file is a directory + * + * This function calls the [[_up]] function to perform the operation + * + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + upload(): Promise; + /** + * Share the file by publish it. + * + * Only work with file + * + * This function calls the [[_pub]] function to perform the operation + * + * @returns {Promise} promise on operation result + * @memberof BaseFileHandle + */ + publish(): Promise; + /** + * Download the file. + * + * Only work with file + * + * This function calls the [[_down]] function to perform the operation + * + * @returns {Promise} Promise on the operation result + * @memberof BaseFileHandle + */ + download(): Promise; + /** + * Move the current file to another location + * + * This function calls the [[_mv]] function to perform the operation + * + * @param {string} d destination location + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + move(d: string): Promise; + /** + * Execute the current file. + * + * This action depends on each file protocol + * + * This function calls the [[_exec]] function to perform the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + execute(): Promise; + /** + * Get an accessible link to the file + * that can be accessed from the browser + * + * @returns {string} + * @memberof BaseFileHandle + */ + getlink(): string; + /** + * Helper function returns a promise on unsupported action + * + * @param {string} t action name + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected unsupported(t: string): Promise; + /** + * trigger cache changed event + * + * This function triggered when the file cached changed * * @protected + * @memberof BaseFileHandle + */ + protected _cache_changed(): void; + /** + * Low level protocol-specific read operation + * + * This function should be overridden on the file handle class + * that supports the operation + * + * @protected + * @param {string} t data type, see [[read]] + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _rd(t: string): Promise; + /** + * Low level protocol-specific write operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @protected + * @param {string} t data type, see [[write]] * @param {*} [d] - * @memberof SystemPanelTag + * @returns {Promise} + * @memberof BaseFileHandle */ - protected reload(d?: any): void; + protected _wr(t: string, d?: any): Promise; /** - * Attach a service to the system tray on the pannel, - * this operation is performed when a service is started + * Low level protocol-specific sub-directory creation * - * @param {BaseService} s - * @returns - * @memberof SystemPanelTag - */ - attachservice(s: application.BaseService): void; - /** - * Launch the selected application from the spotlight - * applications list - * - * @private - * @returns {void} - * @memberof SystemPanelTag - */ - private open; - /** - * Perform spotlight search operation on keyboard event - * - * @private - * @param {JQuery.KeyboardEventBase} e - * @returns {void} - * @memberof SystemPanelTag - */ - private search; - /** - * detach a service from the system tray of the panel. - * This function is called when the corresponding running - * service is killed - * - * @param {BaseService} s - * @memberof SystemPanelTag - */ - detachservice(s: application.BaseService): void; - /** - * Layout definition of the panel + * This function should be overridden by the file handle class + * that supports the operation * * @protected - * @returns {TagLayoutType[]} - * @memberof SystemPanelTag + * @param {string} d sub directory name + * @returns {Promise} + * @memberof BaseFileHandle */ - protected layout(): TagLayoutType[]; + protected _mk(d: string): Promise; /** - * Refresh applications list on the spotlight widget - * from system packages meta-data + * Low level protocol-specific delete operation * - * @private - * @memberof SystemPanelTag - */ - private refreshAppList; - /** - * Show/hide the spotlight + * This function should be overridden by the file handle class + * that supports the operation * - * @private - * @param {boolean} flag - * @memberof SystemPanelTag + * @returns {Promise} + * @memberof BaseFileHandle */ - private toggle; + protected _rm(): Promise; /** - * Calibrate the spotlight widget + * Low level protocol-specific move operation * - * @memberof SystemPanelTag - */ - calibrate(): void; - /** - * Refresh the pinned applications menu - * - * @private - * @memberof SystemPanelTag - */ - private RefreshPinnedApp; - /** - * Check if the loading tasks ended, - * if it the case, stop the animation - * - * @private - * @memberof SystemPanelTag - */ - private animation_check; - /** - * Mount the tag bind some basic event + * This function should be overridden by the file handle class + * that supports the operation * * @protected - * @memberof SystemPanelTag + * @param {string} d + * @returns {Promise} + * @memberof BaseFileHandle */ - protected mount(): void; + protected _mv(d: string): Promise; + /** + * Low level protocol-specific upload operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _up(): Promise; + /** + * Low level protocol-specific download operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _down(): Promise; + /** + * Low level protocol-specific execute operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _exec(): Promise; + /** + * Low level protocol-specific share operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _pub(): Promise; + /** + * Read the current file meta-data + * + * should be implemented by subclasses + * + * @abstract + * @returns {Promise} + * @memberof BaseFileHandle + */ + abstract meta(): Promise; } + /** + * Remote file handle allows to perform file operation + * on AntOS remote server files. Its protocol is defined + * by the following pattern: + * + * ``` + * ^(home|desktop|os|Untitled)$ + * ``` + * + * @class RemoteFileHandle + * @extends {BaseFileHandle} + */ + class RemoteFileHandle extends BaseFileHandle { + /** + *Creates an instance of RemoteFileHandle. + * @param {string} path file path + * @memberof RemoteFileHandle + */ + constructor(path: string); + /** + * Read remote file meta-data + * + * @returns {Promise} + * @memberof RemoteFileHandle + */ + meta(): Promise; + /** + * Remote file access link + * + * @returns {string} + * @memberof RemoteFileHandle + */ + getlink(): string; + /** + * Read remote file content. + * + * If the current file is a directory, then the operation + * will return the meta-data of all files inside of the directory. + * Otherwise, file content will be returned + * + * @protected + * @param {string} t data type see [[read]] + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _rd(t: string): Promise; + /** + * Write file cache to the remote file + * + * @protected + * @param {string} t data type see [[write]] + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _wr(t: string): Promise; + /** + * Create sub directory + * + * Only work on directory file handle + * + * @protected + * @param {string} d sub directory name + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _mk(d: string): Promise; + /** + * Delete file/folder + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _rm(): Promise; + /** + * Move file/folder + * + * @protected + * @param {string} d + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _mv(d: string): Promise; + /** + * Upload a file + * + * Only work with directory file handle + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _up(): Promise; + /** + * Download a file + * + * only work with file + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _down(): Promise; + /** + * Publish a file + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _pub(): Promise; + } + /** + * Package file is remote file ([[RemoteFileHandle]]) located either in + * the local user packages location or system packages + * location, it should be in the following format: + * + * ``` + * pkg://PKG_NAME/path/to/file + * + * ``` + * + * The system will locale the package name PKG_NAME either in the system domain + * or in user domain and return the correct path to the package + * + * @export + * @class PackageFileHandle + * @extends {RemoteFileHandle} + */ + class PackageFileHandle extends RemoteFileHandle { + /** + *Creates an instance of PackageFileHandle. + * @param {string} pkg_path package path in string + * @memberof PackageFileHandle + */ + constructor(pkg_path: string); + } + /** + * Application file is an AntOS special file allowing to + * refer to an application as a regular file. Its protocol + * pattern is defined as: + * + * ```typescript + * "^app$" // e.g. app://Setting + * ``` + * + * @class ApplicationHandle + * @extends {BaseFileHandle} + */ + class ApplicationHandle extends BaseFileHandle { + /** + *Creates an instance of ApplicationHandle. + * @param {string} path file path + * @memberof ApplicationHandle + */ + constructor(path: string); + /** + * Read application meta-data + * + * @returns {Promise} + * @memberof ApplicationHandle + */ + meta(): Promise; + /** + * If the current file is root (e.g. `app://`), the operation + * will return all system packages meta-data. + * + * Otherwise, an error will be thrown + * + * @protected + * @param {string} t + * @returns {Promise} + * @memberof ApplicationHandle + */ + protected _rd(t: string): Promise; + } + /** + * A buffer file handle represents a virtual file that is stored + * on the system memory. Its protocol pattern is defined as: + * + * ```typescript + * "^mem$" // e.g. mem://test.txt + * ``` + * + * @class BufferFileHandle + * @extends {BaseFileHandle} + */ + class BufferFileHandle extends BaseFileHandle { + /** + *Creates an instance of BufferFileHandle. + * @param {string} path file path + * @param {string} mime file mime-type + * @param {*} data file data + * @memberof BufferFileHandle + */ + constructor(path: string, mime: string, data: any); + /** + * init the mem file tree if necessary + */ + private init_file_tree; + /** + * cache changed handle + */ + protected _cache_changed(): void; + /** + * Read the file meta-data + * + * @returns {Promise} + * @memberof BufferFileHandle + */ + meta(): Promise; + /** + * Load the file meta-data before performing + * any task + * + * @returns {Promise} a promise on file meta-data + * @memberof BufferFileHandle + */ + onready(): Promise; + /** + * Read file content stored in the file cached + * + * @protected + * @param {string} t data type see [[read]] + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _rd(t: string): Promise; + /** + * Write data to the file cache + * + * @protected + * @param {string} t data type, see [[write]] + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _wr(t: string): Promise; + /** + * Create sub directory + * + * Only work on directory file handle + * + * @protected + * @param {string} d sub directory name + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _mk(d: string): Promise; + /** + * Delete file/folder + * + * @protected + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _rm(): Promise; + setPath(p: string): void; + private updatePath; + /** + * Move file/folder + * + * @protected + * @param {string} d + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _mv(d: string): Promise; + /** + * Download the buffer file + * + * @protected + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _down(): Promise; + } + /** + * URL file handle represents a HTTP/HTTPs link url + * as an AntOS VFS file handle. Its protocol is defined as + * + * ``` + * ^(http|https|ftp)$ + * ``` + * + * @class URLFileHandle + * @extends {BaseFileHandle} + */ + class URLFileHandle extends BaseFileHandle { + /** + *Creates an instance of URLFileHandle. + * @param {string} path + * @memberof URLFileHandle + */ + constructor(path: string); + /** + * Read file meta-data + * + * @returns {Promise} + * @memberof URLFileHandle + */ + meta(): Promise; + /** + * Read URL content + * + * @protected + * @param {string} t data type see [[read]] + * @returns {Promise} + * @memberof URLFileHandle + */ + protected _rd(t: string): Promise; + } + /** + * Shared file handle represents all AntOS shared file. + * Its protocol is defined as: + * + * ``` + * ^shared$ + * ``` + * + * @class SharedFileHandle + * @extends {API.VFS.BaseFileHandle} + */ + class SharedFileHandle extends API.VFS.BaseFileHandle { + /** + *Creates an instance of SharedFileHandle. + * @param {string} path file path + * @memberof SharedFileHandle + */ + constructor(path: string); + /** + * Read file meta-data + * + * @returns {Promise} + * @memberof SharedFileHandle + */ + meta(): Promise; + /** + * Read file content + * + * @protected + * @param {string} t data type, see [[read]] + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _rd(t: string): Promise; + /** + * write data to shared file + * + * @protected + * @param {string} t data type, see [[write]] + * @param {string} d file data + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _wr(t: string, d: string): Promise; + /** + * Un-publish the file + * + * @protected + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _rm(): Promise; + /** + * Download shared file + * + * @protected + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _down(): Promise; + /** + * Un publish the file + * + * @protected + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _pub(): Promise; + } + /**Utilities global functions */ + /** + * Read a file content from a zip archive + * + * The content type should be: + * - base64 : the result will be a string, the binary in a base64 form. + * - text (or string): the result will be an unicode string. + * - binarystring: the result will be a string in “binary” form, using 1 byte per char (2 bytes). + * - array: the result will be an Array of bytes (numbers between 0 and 255). + * - uint8array : the result will be a Uint8Array. This requires a compatible browser. + * - arraybuffer : the result will be a ArrayBuffer. This requires a compatible browser. + * - blob : the result will be a Blob. This requires a compatible browser. * + * If file_name is not specified, the first file_name in the zip archive will be read + * @export + * @param {string} file zip file + * @param {string} type content type to read + * @param {string} [file_name] the file should be read from the zip archive + * @return {*} {Promise} + */ + function readFileFromZip(file: string, type: string, file_name?: string): Promise; + /** + * Cat all files to a single out-put + * + * @export + * @param {string[]} list list of VFS files + * @param {string} data input data string that will be cat to the files content + * @param {string} join_by join on files content by this string + * @return {*} {Promise} + */ + function cat(list: string[], data: string, join_by?: string): Promise; + /** + * Read all files content on the list + * + * @export + * @param {string[]} list list of VFS files + * @param {GenericObject[]} contents content array + * @return {void} + */ + function read_files(list: string[]): Promise[]>; + /** + * Copy files to a folder + * + * @export + * @param {string[]} files list of files + * @param {string} to destination folder + * @return {*} {Promise} + */ + function copy(files: string[], to: string): Promise; + /** + * Create a zip archive from a folder + * + * @export + * @param {string} src source file/folder + * @param {string} dest destination archive + * @return {*} {Promise} + */ + function mkar(src: string, dest: string): Promise; + /** + * Create a list of directories + * + * @export + * @param {string[]} list of directories to be created + * @param {boolen} sync sync/async of directory creation + * @return {*} {Promise} + */ + function mkdirAll(list: string[], sync?: boolean): Promise; + /** + * + * + * @export Extract a zip fle + * @param {string} zfile zip file to extract + * @param {(zip:any) => Promise} [dest_callback] a callback to get extraction destination + * @return {*} {Promise} + */ + function extractZip(zfile: string | API.VFS.BaseFileHandle, dest_callback: (zip: any) => Promise): Promise; + /** + * Make files from a set of template files + * + * @export + * @param {Array} list mapping paths between templates files and created files + * @param {string} path files destination + * @param {(data: string) => string} callback: pre-processing files content before writing to destination files + * @return {*} {Promise} + */ + function mktpl(list: Array, path: string, callback: (data: string) => string): Promise; } } } declare namespace OS { - namespace GUI { + /** + * This namespace is dedicated to everything related to the + * global system settings + */ + namespace setting { /** - * Tab container data type definition + * User setting type definition * * @export - * @interface TabContainerTabType + * @interface UserSettingType */ - interface TabContainerTabType { + interface UserSettingType { /** - * Reference to the DOM element of the current container + * User full name * - * @type {HTMLElement} - * @memberof TabContainerTabType + * @type {string} + * @memberof UserSettingType */ - container: HTMLElement; + name: string; + /** + * User name + * + * @type {string} + * @memberof UserSettingType + */ + username: string; + /** + * User id + * + * @type {number} + * @memberof UserSettingType + */ + id: number; + /** + * User groups + * + * @type {{ [index: number]: string }} + * @memberof UserSettingType + */ + group?: { + [index: number]: string; + }; [propName: string]: any; } - namespace tag { + /** + * Virtual desktop setting data type + * + * @export + * @interface DesktopSettingType + */ + interface DesktopSettingType { /** - * A tab container allows to attach each tab on a [[TabBarTag]] - * with a container widget. The attached container widget should be - * composed inside a [[HBoxTag]] + * Desktop VFS path * - * The tab bar in a tab container can be configured to display tabs - * in horizontal (row) or vertical (column) order. Default to vertical order - * - * Once a tab is selected, its attached container will be shown - * - * @export - * @class TabContainerTag - * @extends {AFXTag} + * @type {string} + * @memberof DesktopSettingType */ - class TabContainerTag extends AFXTag { + path: string; + /** + * Desktop menu, can be added automatically by applications + * + * @type {GUI.BasicItemType[]} + * @memberof DesktopSettingType + */ + menu: GUI.BasicItemType[]; + /** + * Show desktop hidden files + * + * @type {boolean} + * @memberof DesktopSettingType + */ + showhidden: boolean; + [propName: string]: any; + } + /** + * Wallpaper setting data type + * + * @export + * @interface WPSettingType + */ + interface WPSettingType { + /** + * Repeat wallpaper: + * - `repeat` + * - `repeat-x` + * - `repeat-y` + * - `no-repeat` + * + * @type {string} + * @memberof WPSettingType + */ + repeat: string; + /** + * Wallpaper size + * - `contain` + * - `cover` + * - `auto` + * + * @type {string} + * @memberof WPSettingType + */ + size: string; + /** + * VFS path to the wallpaper image + * + * @type {string} + * @memberof WPSettingType + */ + url: string; + } + /** + * Theme setting data type + * + * @export + * @interface ThemeSettingType + */ + interface ThemeSettingType { + /** + * Theme name, this value is used for looking + * theme file in system asset + * + * @type {string} + * @memberof ThemeSettingType + */ + name: string; + /** + * Theme user-friendly text + * + * @type {string} + * @memberof ThemeSettingType + */ + text: string; + } + /** + * Appearance setting data type + * + * @export + * @interface AppearanceSettingType + */ + interface AppearanceSettingType { + /** + * Current theme name + * + * @type {string} + * @memberof AppearanceSettingType + */ + theme: string; + /** + * All themes available in the system + * + * @type {ThemeSettingType[]} + * @memberof AppearanceSettingType + */ + themes: ThemeSettingType[]; + /** + * Current wallpaper setting + * + * @type {WPSettingType} + * @memberof AppearanceSettingType + */ + wp: WPSettingType; + /** + * All wallpapers available in the system + * + * @type {string[]} + * @memberof AppearanceSettingType + */ + wps: string[]; + } + /** + * VFS Mount points setting data type + * + * @export + * @interface VFSMountPointSettingType + */ + interface VFSMountPointSettingType { + /** + * Path to the mount point + * + * @type {string} + * @memberof VFSMountPointSettingType + */ + path: string; + /** + * User friendly mount point name + * + * @type {string} + * @memberof VFSMountPointSettingType + */ + text: string; + [propName: string]: any; + } + /** + * VFS setting data type + * + * @export + * @interface VFSSettingType + */ + interface VFSSettingType { + /** + * mount points setting + * + * @type {VFSMountPointSettingType[]} + * @memberof VFSSettingType + */ + mountpoints: VFSMountPointSettingType[]; + [propName: string]: any; + } + /** + * Global system setting data type + * + * @export + * @interface SystemSettingType + */ + interface SystemSettingType { + /** + * System error report URL + * + * @type {string} + * @memberof SystemSettingType + */ + error_report: string; + /** + * Current system locale e.g. `en_GB` + * + * @type {string} + * @memberof SystemSettingType + */ + locale: string; + /** + * System menus + * + * @type {API.PackageMetaType[]} + * @memberof API.PackageMetaType + */ + menu: API.PackageMetaType[]; + /** + * Packages meta-data + * + * @type {{ [index: string]: API.PackageMetaType }} + * @memberof SystemSettingType + */ + packages: { + [index: string]: API.PackageMetaType; + }; + /** + * Path to the installed packages + * + * @type {{ + * user: string; + * system: string; + * }} + * @memberof SystemSettingType + */ + pkgpaths: { /** - * Reference to the currently selected tab DOM element + * User specific packages install location * - * @private - * @type {TabContainerTabType} - * @memberof TabContainerTag + * @type {string} */ - private _selectedTab; + user: string; /** - * Placeholder of the tab select event handle + * System packages install location * - * @private - * @type {TagEventCallback} - * @memberof TabContainerTag + * @type {string} */ - private _ontabselect; + system: string; + }; + /** + * Package repositories setting. + * This configuration is used by [[MarketPlace]] + * for package management + * + * @type {{ + * text: string; + * url: string; + * }[]} + * @memberof SystemSettingType + */ + repositories: { /** - *Creates an instance of TabContainerTag. - * @memberof TabContainerTag + * Repository name + * + * @type {string} */ - constructor(); + text: string; /** - * Init the tab bar direction to vertical (column) + * Repository uri * - * @protected - * @memberof TabContainerTag + * @type {string} */ - protected init(): void; + url: string; + }[]; + /** + * Startup applications and services + * + * @type {{ + * apps: string[]; + * services: string[]; + * }} + * @memberof SystemSettingType + */ + startup: { /** - * Do nothing + * List of application names * - * @protected - * @param {*} [d] - * @memberof TabContainerTag + * @type {string[]} */ - protected reload(d?: any): void; + apps: string[]; /** - * Set the tab select event handle + * List of service names * - * @memberof TabContainerTag + * @type {string[]} */ - set ontabselect(f: TagEventCallback); + services: string[]; /** - * Get all tab items in the container + * List of pinned applications * - * @readonly - * @type {TabContainerTabType[]} - * @memberof TabContainerTag + * @type {string[]} */ - get tabs(): TabContainerTabType[]; - /** - * Select a tab by its index - * - * @memberof TabContainerTag - */ - set selectedIndex(i: number); - /** - * Setter: - * - * Set the tab bar direction: - * - `row`: horizontal direction - * - `column`: vertical direction - * - * Getter: - * - * Get the tab bar direction - * - * @memberof TabContainerTag - */ - set dir(v: "row" | "column"); - get dir(): "row" | "column"; - /** - * Setter: - * - * Select a tab using the its tab data type. - * This will show the attached container to the tab - * - * Getter: - * - * Get the tab data of the currently selected Tab - * - * @memberof TabContainerTag - */ - set selectedTab(v: TabContainerTabType); - get selectedTab(): TabContainerTabType; - /** - * Set the tab bar width, this function only - * works when the tab bar direction is set to - * `row` - * - * @memberof TabContainerTag - */ - set tabbarwidth(v: number); - /** - * Set the tab bar height, this function only works - * when the tab bar direction is set to `column` - * - * @memberof TabContainerTag - */ - set tabbarheight(v: number); - /** - * Add a new tab with container to the container - * - * item should be in the following format: - * - * ```ts - * { - * text: string, - * icon?: string, - * iconclass?: string, - * container: HTMLElement - * } - * ``` - * - * @param {GenericObject} item tab descriptor - * @param {boolean} insert insert the tab content to the container ? - * @returns {ListViewItemTag} the tab DOM element - * @memberof TabContainerTag - */ - addTab(item: GenericObject, insert: boolean): ListViewItemTag; - /** - * Remove a tab from the container - * - * @param {ListViewItemTag} tab the tab item to be removed - * @memberof TabContainerTag - */ - removeTab(tab: ListViewItemTag): void; - /** - * Mount the tag and bind basic events - * - * @protected - * @memberof TabContainerTag - */ - protected mount(): void; - /** - * calibrate the tab container - * - * @memberof TabContainerTag - */ - calibrate(): void; - /** - * Layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof TabContainerTag - */ - protected layout(): TagLayoutType[]; - } + pinned: string[]; + }; + } + /** + * User settings + */ + var user: UserSettingType; + /** + * Application settings + */ + var applications: GenericObject; + /** + * Desktop settings + */ + var desktop: DesktopSettingType; + /** + * Appearance settings + */ + var appearance: AppearanceSettingType; + /** + * VFS settings + */ + var VFS: VFSSettingType; + /** + * System settings + */ + var system: SystemSettingType; + } + /** + * Reset the system settings to default values + * + * @export + */ + function resetSetting(): void; + /** + * Apply the input parameter object to system settings. + * This object could be an object loaded from + * setting JSON file saved on the server. + * + * @export + * @param {*} conf + */ + function systemSetting(conf: any): void; +} +/// +declare namespace OS { + namespace application { + /** + * Services are processes that run in the background and + * are waken up in certain circumstances such as by global + * events or user interactions. + * + * Each service takes an entry in the system tray menu + * located on the system panel. This menu entry is used + * to access to service visual contents such as: options, + * task performing based on user interaction, etc. + * + * Services are singleton processes, there is only + * one process of a service at a time + * + * @export + * @abstract + * @class BaseService + * @extends {BaseModel} + */ + abstract class BaseService extends BaseModel { + /** + * The service icon shown in the system tray + * + * @type {string} + * @memberof BaseService + */ + icon: string; + /** + * CSS class of the service icon shown in the system tray + * + * @type {string} + * @memberof BaseService + */ + iconclass: string; + /** + * Text of the service shown in the system tray + * + * @type {string} + * @memberof BaseService + */ + text: string; + /** + * Reference to the menu entry DOM element attached + * to the service + * + * @type {HTMLElement} + * @memberof BaseService + */ + domel: HTMLElement; + /** + * Reference to the timer that periodically executes the callback + * defined in [[watch]]. + * + * @private + * @type {number} + * @memberof BaseService + */ + private timer; + /** + * Reference to the system tray menu + * + * @type {HTMLElement} + * @memberof BaseService + */ + holder: HTMLElement; + /** + * Placeholder for service select callback + * + * @memberof BaseService + */ + onmenuselect: (d: OS.GUI.TagEventType) => void; + /** + *Creates an instance of BaseService. + * @param {string} name service class name + * @param {AppArgumentsType[]} args service arguments + * @memberof BaseService + */ + constructor(name: string, args: AppArgumentsType[]); + /** + * Do nothing + * + * @memberof BaseService + */ + hide(): void; + /** + * Init the service before attaching it to + * the system tray: event subscribe, scheme + * loading. + * + * Should be implemented by all subclasses + * + * @abstract + * @memberof BaseService + */ + abstract init(): void; + /** + * Refresh the service menu entry in the + * system tray + * + * @memberof BaseService + */ + update(): void; + /** + * Get the service meta-data + * + * @returns {API.PackageMetaType} + * @memberof BaseService + */ + meta(): API.PackageMetaType; + /** + * Attach the service to a menu element + * such as the system tray menu + * + * @param {HTMLElement} h + * @memberof BaseService + */ + attach(h: HTMLElement): void; + /** + * Set the callback that will be called periodically + * after a period of time. + * + * Each service should only have at most one watcher + * + * @protected + * @param {number} t period time in seconds + * @param {() => void} f callback function + * @returns {number} + * @memberof BaseService + */ + protected watch(t: number, f: () => void): number; + /** + * This function is called when the service + * is exited + * + * @protected + * @param {BaseEvent} evt exit event + * @returns + * @memberof BaseService + */ + protected onexit(evt: BaseEvent): JQuery; + /** + * Do nothing + * + * @memberof BaseService + */ + main(): void; + /** + * Do nothing + * + * @memberof BaseService + */ + show(): void; + /** + * Awake the service, this function is usually called when + * the system tray menu entry attached to the service is + * selected. + * + * This function should be implemented by all subclasses + * + * @abstract + * @param {GUI.TagEventType} e + * @memberof BaseService + */ + abstract awake(e: GUI.TagEventType): void; + /** + * Do nothing + * + * @protected + * @param {BaseEvent} evt + * @memberof BaseService + */ + protected cleanup(evt: BaseEvent): void; } } } declare namespace OS { - namespace GUI { - namespace tag { + namespace API { + /** + * Data type exchanged via + * the global Announcement interface + * + * @export + * @interface AnnouncementDataType + */ + interface AnnouncementDataType { /** - * Definition of system file view widget + * message string * - * @export - * @class FileViewTag - * @extends {AFXTag} + * @type {string| FormattedString} + * @memberof AppAnnouncementDataType */ - class FileViewTag extends AFXTag { + message: string | FormattedString; + /** + * Process ID + * + * @type {number} + * @memberof AppAnnouncementDataType + */ + id: number; + /** + * App name + * + * @type {string | FormattedString} + * @memberof AppAnnouncementDataType + */ + name: string | FormattedString; + /** + * Icon file + * + * @type {string} + * @memberof AppAnnouncementDataType + */ + icon?: string; + /** + * App icon class + * + * @type {string} + * @memberof AppAnnouncementDataType + */ + iconclass?: string; + /** + * User specific data + * + * @type {*} + * @memberof AppAnnouncementDataType + */ + u_data?: T; + } + /** + * Observable entry type definition + * + * @export + * @interface ObservableEntryType + */ + interface ObservableEntryType { + /** + * A Set of callbacks that should be called only once. + * These callbacks will be removed after the first + * occurrence of the corresponding event + * + * @memberof ObservableEntryType + */ + one: Set<(d: any) => void>; + /** + * A Set of callbacks that should be called + * every time the corresponding event is triggered + * + * @memberof ObservableEntryType + */ + many: Set<(d: any) => void>; + } + /** + * Announcement listener type definition + * + * @export + * @interface AnnouncerListenerType + */ + interface AnnouncerListenerType { + [index: number]: { /** - * placeholder for file select event callback + * The event name * - * @private - * @type {TagEventCallback} - * @memberof FileViewTag - */ - private _onfileselect; - /** - * placeholder for file open event callback - * - * @private - * @type {TagEventCallback} - * @memberof FileViewTag - */ - private _onfileopen; - /** - * Reference to the currently selected file meta-data - * - * @private - * @type {API.FileInfoType} - * @memberof FileViewTag - */ - private _selectedFile; - /** - * Data placeholder of the current working directory - * - * @private - * @type {API.FileInfoType[]} - * @memberof FileViewTag - */ - private _data; - /** - * The path of the current working directory - * - * @private * @type {string} - * @memberof FileViewTag */ - private _path; + e: string; /** - * Header definition of the widget grid view + * The event callback * - * @private - * @type {(GenericObject[])} - * @memberof FileViewTag */ - private _header; - /** - * placeholder for the user-specified meta-data fetch function - * - * @private - * @memberof FileViewTag - */ - private _fetch; - /** - *Creates an instance of FileViewTag. - * @memberof FileViewTag - */ - constructor(); - /** - * Init the widget before mounting - * - * @protected - * @memberof FileViewTag - */ - protected init(): void; - /** - * Update the current widget, do nothing - * - * @protected - * @param {*} [d] - * @memberof FileViewTag - */ - protected reload(d?: any): void; - /** - * set the function that allows to fetch file entries. - * This handle function should return a promise on - * an arry of [[API.FileInfoType]] - * - * @memberof FileViewTag - */ - set fetch(v: (p: string) => Promise); - /** - * set the callback handle for the file select event. - * The parameter of the callback should be an object - * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] - * - * @memberof FileViewTag - */ - set onfileselect(e: TagEventCallback); - /** - set the callback handle for the file open event. - * The parameter of the callback should be an object - * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] - * - * @memberof FileViewTag - */ - set onfileopen(e: TagEventCallback); - /** - * Setter: - * - * chang the view of the widget, there are three different views - * - `icon` - * - `list` - * - `tree` - * - * Getter: - * - * Get the current view setting of the widget - * - * @memberof FileViewTag - */ - set view(v: string); - get view(): string; - /** - * Setter: - * - * Turn on/off the changing current working directory feature - * of the widget when a directory is double clicked. If enabled, - * the widget will use the configured [[fetch]] function to query - * the content of the selected directory - * - * Getter: - * - * check whether changing current working directory feature - * is enabled - * - * @memberof FileViewTag - */ - set chdir(v: boolean); - get chdir(): boolean; - /** - * Setter : Enable or disable the status bar of the widget - * - * Getter: Check whether the status bar is enabled - * - * @memberof FileViewTag - */ - set status(v: boolean); - get status(): boolean; - /** - * Setter: - * - * Allow the widget to show or hide hidden file - * - * Getter: - * - * Check whether the hidden file should be shown in - * the widget - * - * @memberof FileViewTag - */ - set showhidden(v: boolean); - get showhidden(): boolean; - /** - * Get the current selected file - * - * @readonly - * @type {API.FileInfoType} - * @memberof FileViewTag - */ - get selectedFile(): API.FileInfoType; - /** - * Setter: - * - * Set the path of the current working directory. - * When called the widget will refresh the current - * working directory using the configured [[fetch]] - * function - * - * Getter: - * - * Get the path of the current working directory - * - * @memberof FileViewTag - */ - set path(v: string); - get path(): string; - /** - * Setter: Set the data of the current working directory - * - * Getter: Get the data of the current working directory - * - * @memberof FileViewTag - */ - set data(v: API.FileInfoType[]); - get data(): API.FileInfoType[]; - /** - * Set the file drag and drop event handle. This allows application - * to define custom behavior of the event - * - * @memberof FileViewTag - */ - set ondragndrop(v: TagEventCallback>); - /** - * Sort file by its type - * - * @private - * @param {API.FileInfoType} a - * @param {API.FileInfoType} b - * @return {*} {number} - * @memberof FileViewTag - */ - private sortByType; - /** - * sort file by its name - * - * @private - * @param {API.FileInfoType} a first file meta-data - * @param {API.FileInfoType} b second file meta-data - * @returns {number} - * @memberof FileViewTag - */ - private sortByName; - /** - * calibrate the widget layout - * - * @memberof FileViewTag - */ - calibrate(): void; - /** - * Refresh the list view of the widget. This function - * is called when the view of the widget changed to `icon` - * - * @private - * @memberof FileViewTag - */ - private refreshList; - /** - * Refresh the grid view of the widget, this function is called - * when the view of the widget set to `list` - * - * @private - * @memberof FileViewTag - */ - private refreshGrid; - /** - * Refresh the Treeview of the widget, this function is called - * when the view of the widget set to `tree` - * - * @private - * @memberof FileViewTag - */ - private refreshTree; - /** - * Create the tree data from the list of input - * file meta-data - * - * @private - * @param {API.FileInfoType[]} data list of file meta-data - * @returns {TreeViewDataType[]} - * @memberof FileViewTag - */ - private getTreeData; - /** - * Refresh data of the current widget view - * - * @private - * @returns {void} - * @memberof FileViewTag - */ - private refreshData; - /** - * Switch between three view options - * - * @private - * @memberof FileViewTag - */ - private switchView; - /** - * This function triggers the file select event - * - * @private - * @param {API.FileInfoType} e selected file meta-data - * @memberof FileViewTag - */ - private fileselect; - /** - * This function triggers the file open event - * - * @private - * @param {API.FileInfoType} e selected file meta-data - * @memberof FileViewTag - */ - private filedbclick; - /** - * Mount the widget in the DOM tree - * - * @protected - * @memberof FileViewTag - */ - protected mount(): void; - /** - * Layout definition of the widget - * - * @protected - * @returns {TagLayoutType[]} - * @memberof FileViewTag - */ - protected layout(): TagLayoutType[]; - } + f: (d: any) => void; + }[]; + } + /** + * This class is the based class used in AntOS event + * announcement system. + * It implements the observer pattern using simple + * subscribe/publish mechanism + * @export + * @class Announcer + */ + class Announcer { + /** + * The observable object that stores event name + * and its corresponding callback in [[ObservableEntryType]] + * + * @type {GenericObject} + * @memberof Announcer + */ + observable: GenericObject; + /** + * Enable/disable the announcer + * + * @type {boolean} + * @memberof Announcer + */ + enable: boolean; + /** + *Creates an instance of Announcer. + * @memberof Announcer + */ + constructor(); + /** + * Disable the announcer, when this function is called + * all events and their callbacks will be removed + * + * @returns + * @memberof Announcer + */ + disable(): boolean; + /** + * Subscribe to an event, the callback will be called + * every time the corresponding event is trigged + * + * @param {string} evtName event name + * @param {(d: any) => void} callback The corresponding callback + * @returns {void} + * @memberof Announcer + */ + on(evtName: string, callback: (d: any) => void): void; + /** + * Subscribe to an event, the callback will + * be called only once and then removed from the announcer + * + * @param {string} evtName event name + * @param {(d: any) => void} callback the corresponding callback + * @returns {void} + * @memberof Announcer + */ + one(evtName: string, callback: (d: any) => void): void; + /** + * Unsubscribe the callback from an event + * + * @param {string} evtName event name + * @param {(d: any) => void} [callback] the callback to be unsubscribed. + * When the `callback` is `*`, all callbacks related to `evtName` will be + * removed + * @memberof Announcer + */ + off(evtName: string, callback?: (d: any) => void): void; + /** + * Trigger an event + * + * @param {string} evtName event name + * @param {*} data data object that will be send to all related callback + * @returns {void} + * @memberof Announcer + */ + trigger(evtName: string, data: any): void; + } + } + /** + * This namespace defines every thing related to the system announcement. + * + * The system announcement provides a global way to communicate between + * processes (applications/services) using the subscribe/publish + * mechanism + */ + namespace announcer { + /** + * The global announcer object that manages global events + * and callbacks + */ + var observable: API.Announcer; + /** + * This variable is used to allocate the `id` of all messages + * passing between publishers and subscribers in the + * system announcement + */ + var quota: 0; + /** + * Placeholder of all global events listeners + */ + var listeners: API.AnnouncerListenerType; + /** + * Subscribe to a global event + * + * @export + * @param {string} e event name + * @param {(d: API.AnnouncementDataType) => void} f event callback + * @param {GUI.BaseModel} a the process (Application/service) related to the callback + */ + function on(e: string, f: (d: API.AnnouncementDataType) => void, a: BaseModel): void; + /** + * Trigger a global event + * + * @export + * @param {string} e event name + * @param {*} d data passing to all related callback + */ + function trigger(e: string, d: any): void; + /** + * Report system fail. This will trigger the global `fail` + * event + * + * @export + * @param {(string | FormattedString)} m message string + * @param {Error} e error to be reported + */ + function osfail(m: string | FormattedString, e: Error): void; + /** + * Report system error. This will trigger the global `error` + * event + * + * @export + * @param {(string | FormattedString)} m message string + * @param {Error} e error to be reported + */ + function oserror(m: string | FormattedString, e: Error): void; + /** + * Trigger system notification (`info` event) + * + * @export + * @param {(string | FormattedString)} m notification message + */ + function osinfo(m: string | FormattedString): void; + /** + * + * + * @export + * @param {string} e event name + * @param {(string| FormattedString)} m event message + * @param {*} [d] user data + */ + function ostrigger(e: string, m: string | FormattedString, d?: any): void; + /** + * Unregister a process (application/service) from + * the global announcement system + * + * @export + * @param {GUI.BaseModel} app reference to the process + * @returns {void} + */ + function unregister(app: BaseModel): void; + /** + * Allocate message id + * + * @export + * @returns {number} + */ + function getMID(): number; + } +} +declare namespace OS { + namespace API { + /** + * Simple Virtual Database (VDB) application API. + * + * This API abstracts and provides a standard way to + * connect to a server-side relational database (e.g. sqlite). + * + * Each user when connected has their own database previously + * created. All VDB operations related to that user will be + * performed on this database. + * + * The creation of user database need to be managed by the server-side API. + * The VDB API assumes that the database already exist. All operations + * is performed in tables level + * + * @export + * @class DB + */ + class DB { + /** + * A table name on the user's database + * + * @private + * @type {string} + * @memberof DB + */ + private table; + /** + *Creates an instance of DB. + * @param {string} table table name + * @memberof DB + */ + constructor(table: string); + /** + * Save data to the current table. The input + * data must conform to the table record format. + * + * On the server side, if the table doest not + * exist yet, it should be created automatically + * by inferring the data structure of the input + * object + * + * @param {GenericObject} d data object represents a current table record + * @returns {Promise} + * @memberof DB + */ + save(d: GenericObject): Promise; + /** + * delete record(s) from the current table by + * a conditional object + * + * @param {*} c conditional object, c can be: + * + * * a `number`: the operation will delete the record with `id = c` + * * a `string`: The SQL string condition that selects record to delete + * * a conditional object represents a SQL condition statement as an object, + * example: `pid = 10 AND cid = 2` is represented by: + * + * ```typescript + * { + * exp: { + * "and": { + * pid: 10, + * cid: 2 + * } + * } + * ``` + * + * @returns {Promise} + * @memberof DB + */ + delete(c: GenericObject | number | string): Promise; + /** + * Get a record in the table by its primary key + * + * @param {number} id the primary key value + * @returns {Promise>} Promise on returned record data + * @memberof DB + */ + get(id: number): Promise>; + /** + * Find records by a condition + * + * @param {GenericObject} cond conditional object + * + * a conditional object represents a SQL condition statement as an object, + * example: `pid = 10 AND cid = 2 ORDER BY date DESC` is represented by: + * + * ```typescript + * { + * exp: { + * "and": { + * pid: 10, + * cid: 2 + * } + * }, + * order: { + * date: "DESC" + * } + * } + * ``` + * @returns {Promise[]>} + * @memberof DB + */ + find(cond: GenericObject): Promise[]>; } } } +declare namespace OS { + /** + * This namespace dedicated to all operations related to system + * process management + */ + namespace PM { + /** + * A process is either an instance of an application or a service + */ + type ProcessType = application.BaseApplication | application.BaseService; + /** + * Alias to all classes that extends [[BaseModel]] + */ + type ModelTypeClass = { + new (args: AppArgumentsType[]): T; + }; + /** + * Process id allocator, when a new process is created, the value of + * this variable is increased + */ + var pidalloc: number; + /** + * All running processes is stored in this variables + */ + /** + * Current active process ID + */ + var pidactive: number; + var processes: GenericObject; + /** + * Create a new process of application or service + * + * @export + * @param {string} app class name string + * @param {ProcessTypeClass} cls prototype class + * @param {GUI.AppArgumentsType[]} [args] process arguments + * @returns {Promise} a promise on the created process + */ + function createProcess(app: string, cls: ModelTypeClass, args?: AppArgumentsType[]): Promise; + /** + * Get the reference to a process using its id + * + * @export + * @param {number} pid + * @returns {BaseModel} + */ + function appByPid(pid: number): BaseModel; + /** + * Kill a process + * + * @export + * @param {OS.GUI.BaseModel} app reference to the process + * @returns {void} + */ + function kill(app: BaseModel): void; + /** + * Kill all process of an application or service + * + * @export + * @param {string} app process class name + * @param {boolean} force force exit all process + * @returns {void} + */ + function killAll(app: string, force: boolean): void; + /** + * Get the current active application + * @export + * @returns {BaseModel} + */ + function getActiveApp(): BaseModel; + } +} diff --git a/libantosdk/build/release/libantosdk.zip b/libantosdk/build/release/libantosdk.zip index 664ea9b..ebce638 100644 Binary files a/libantosdk/build/release/libantosdk.zip and b/libantosdk/build/release/libantosdk.zip differ diff --git a/libantosdk/core/ts/antos.d.ts b/libantosdk/core/ts/antos.d.ts index 02b393b..8daae6b 100644 --- a/libantosdk/core/ts/antos.d.ts +++ b/libantosdk/core/ts/antos.d.ts @@ -1,3 +1,338 @@ +declare namespace OS { + namespace API { + /** + * Interface for user login data + * + * @export + * @interface UserLoginType + */ + interface UserLoginType { + /** + * The user credential + * + * @type {string} + * @memberof UserLoginType + */ + username: string; + /** + * The user password + * + * @type {string} + * @memberof UserLoginType + */ + password: string; + } + /** + * Interface for a command sent to + * server side package manage, it contains two field: + * + * @export + * @interface PackageCommandType + */ + interface PackageCommandType { + /** + * Command name, should be: `init`, `cache`, `install`, + * `uninstall` or `list` + * + * @type {string} + * @memberof PackageCommandType + */ + command: string; + /** + * Parameter object of each command + * + * @type {GenericObject} + * @memberof PackageCommandType + */ + args: GenericObject; + } + /** + * + * Interface for basic request result returned + * from the server-side. A valid server-side response should + * be in the following format + * ```json + * { + * "error": boolean or string_err, + * "result": JSON result object + * } + * ``` + * + * @export + * @interface RequestResult + */ + interface RequestResult { + /** + * Indicate whether the response is error + * + * @type {(boolean | string)} + * @memberof RequestResult + */ + error: boolean | string; + /** + * The response result, this value must be + * set when `error` is false + * + * @type {(string + * | boolean + * | GenericObject + * | any[] + * | FileInfoType + * | FileInfoType[] + * | setting.UserSettingType)} + * @memberof RequestResult + */ + result: string | boolean | GenericObject | any[] | FileInfoType | FileInfoType[] | setting.UserSettingType; + } + /** + * The host name of the server-side + */ + var HOST: string; + /** + * The base URI of the server-side API + */ + var BASE_URI: string; + /** + * The base REST URI of the server-side API + */ + var REST: string; + /** + * The namespace `handle` contains some low level API to + * communicate with the server side API. It is the only + * API layer that communicate directly with the server. + * To make AntOS compatible with any server side API, + * all exported variable unctions defined in the `handle` + * namespace should be re-implemented + */ + namespace handle { + /** + * Base URI for reading content of VFS file + */ + var get: string; + /** + * Base URI for VFS file sharing + */ + var shared: string; + /** + * Send a request to the server-side API for a directory scanning + * operation + * + * @export + * @param {string} p a VFS file path e.g. home://test/ + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or a list of FileInfoType + */ + function scandir(p: string): Promise; + /** + * + * Send a request to the server-side API for directory creation + * + * @export + * @param {string} p VFS path of the directory to be created + * @returns {Promise} A promise on a RequestResult + * which contains an error or true on success + */ + function mkdir(p: string): Promise; + /** + * Send a request to the server-side API for sharing/unsharing a VFS file, + * once shared a VFS file will be publicly visible by everyone + * + * @export + * @param {string} p VFS file path to be shared + * @param {boolean} pub flag: share (true) or unshare (false) + * @returns {Promise} A promise on a RequestResult + * which contains an error or true on success + */ + function sharefile(p: string, pub: boolean): Promise; + /** + * Get VFS file meta-data + * + * @export + * @param {string} p VFS file path + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or an object of FileInfoType + */ + function fileinfo(p: string): Promise; + /** + * Read a VFS file content. There are many ways a VFS file can be read: + * - Read as a raw text content + * - Read as a javascript file, in this case the content of the + * file will be executed + * - Read as JSON object + * + * @export + * @param {string} p path of the VFS file + * @param {string} t return data type: + * - jsonp: the response is an json object + * - script: the response is a javascript code + * - xml, html: the response is a XML/HTML object + * - text: plain text + * + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or an object of [[FileInfoType]] + */ + function readfile(p: string, t: string): Promise; + /** + * Move a file to another location on server-side + * + * @export + * @param {string} s VFS source file path + * @param {string} d VFS destination file path + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or a success response + */ + function move(s: string, d: string): Promise; + /** + * Delete a VFS file on the server-side + * + * @export + * @param {string} p VFS file path + * @returns {Promise} A promise on a [[RequestResult]] + * which contains an error or a success response + */ + function remove(p: string): Promise; + /** + * Read the file as binary data + * + * @export + * @param {string} p VFS file to be read + * @returns {Promise} a Promise on an array buffer + */ + function fileblob(p: string): Promise; + /** + * Send a command to the serverside package manager + * + * @export + * @param {PackageCommandType} d a package command of type PackageCommandType + * @returns {Promise} a promise on a [[RequestResult]] + */ + function packages(d: PackageCommandType): Promise; + /** + * Upload file to the server via VFS interface + * + * @export + * @param {string} d VFS destination directory path + * @returns {Promise} a promise on a [[RequestResult]] + */ + function upload(d: string): Promise; + /** + * Write Base 64 encoded data to a VFS file + * + * @export + * @param {string} p path to the VFS file + * @param {string} d file data encoded in Base 64 + * @returns {Promise} a promise on a [[RequestResult]] + */ + function write(p: string, d: string): Promise; + /** + * An apigateway allows client side to execute a custom server-side + * script and get back the result. This gateway is particularly + * useful in case of performing a task that is not provided by the core + * API + * + * @export + * @param {GenericObject} d execution indication, provided only when ws is `false` + * otherwise, `d` should be written directly to the websocket stream as JSON object. + * Two possible formats of `d`: + * ```text + * execute an server-side script file: + * + * { + * path: [VFS path], + * parameters: [parameters of the server-side script] + * } + * + * or, execute directly a snippet of server-side script: + * + * { code: [server-side script code snippet as string] } + * + * ``` + * + * @param {boolean} ws flag indicate whether to use websocket for the connection + * to the gateway API. In case of streaming data, the websocket is preferred + * @returns {Promise} a promise on the result object (any) + */ + function apigateway(d: GenericObject, ws: boolean): Promise; + /** + * Check if a user is logged in + * + * @export + * @returns {Promise} a promise on a [[RequestResult]] that + * contains an error or a [[UserSettingType]] object + */ + function auth(): Promise; + /** + * Perform a login operation + * + * @export + * @param {UserLoginType} d user data [[UserLoginType]] + * @returns {Promise} a promise on a [[RequestResult]] that + * contains an error or a [[UserSettingType]] object + */ + function login(d: UserLoginType): Promise; + /** + * Perform a logout operation + * + * @export + * @returns {Promise} a promise on a [[RequestResult]] + */ + function logout(): Promise; + /** + * Save the current user settings + * + * @export + * @returns {Promise} a promise on a [[RequestResult]] + */ + function setting(): Promise; + /** + * This is the low level function of AntOS VDB API. + * It requests the server API to perform some simple + * SQL query. + * + * @export + * @param {string} cmd action to perform: save, delete, get, select + * @param {GenericObject} d data object of the request based on each action: + * - save: + * ``` + * { table: "table name", data: [record data object]} + * ``` + * - get: + * ``` + * { table: "table name", id: [record id]} + * ``` + * - delete: + * ``` + * { table: "table name", id: [record id]} + * or + * { table: "table name", cond: [conditional object]} + * ``` + * - select: + * ``` + * { table: "table name", cond: [conditional object]} + * ``` + * @returns {Promise} a promise of [[RequestResult]] on the + * query data + * + * A conditional object represents a SQL condition statement as an object, + * example: `pid = 10 AND cid = 2 ORDER BY date DESC` + * ``` + * { + * exp: { + * "and": { + * pid: 10, + * cid: 2 + * } + * }, + * order: { + * date: "DESC" + * } + * } + * ``` + */ + function dbquery(cmd: string, d: GenericObject): Promise; + } + } +} declare namespace OS { namespace GUI { /** @@ -45,10 +380,11 @@ declare namespace OS { * * Need to be implemented by subclasses * - * @abstract - * @memberof SubWindow + * + * @returns {void} + * @memberof BaseDialog */ - abstract init(): void; + init(): void; /** * Main entry point after rendering of the sub-window * @@ -77,6 +413,13 @@ declare namespace OS { * @memberof SubWindow */ hide(): void; + /** + * blur the sub-window + * + * @returns {void} + * @memberof SubWindow + */ + blur(): void; } /** * Abstract prototype of all AntOS dialogs widget @@ -925,2458 +1268,6 @@ declare namespace OS { const schemes: GenericObject; } } -declare namespace OS { - namespace API { - /** - * Data type exchanged via - * the global Announcement interface - * - * @export - * @interface AnnouncementDataType - */ - interface AnnouncementDataType { - /** - * message string - * - * @type {string| FormattedString} - * @memberof AppAnnouncementDataType - */ - message: string | FormattedString; - /** - * Process ID - * - * @type {number} - * @memberof AppAnnouncementDataType - */ - id: number; - /** - * App name - * - * @type {string | FormattedString} - * @memberof AppAnnouncementDataType - */ - name: string | FormattedString; - /** - * Icon file - * - * @type {string} - * @memberof AppAnnouncementDataType - */ - icon?: string; - /** - * App icon class - * - * @type {string} - * @memberof AppAnnouncementDataType - */ - iconclass?: string; - /** - * User specific data - * - * @type {*} - * @memberof AppAnnouncementDataType - */ - u_data?: T; - } - /** - * Observable entry type definition - * - * @export - * @interface ObservableEntryType - */ - interface ObservableEntryType { - /** - * A Set of callbacks that should be called only once. - * These callbacks will be removed after the first - * occurrence of the corresponding event - * - * @memberof ObservableEntryType - */ - one: Set<(d: any) => void>; - /** - * A Set of callbacks that should be called - * every time the corresponding event is triggered - * - * @memberof ObservableEntryType - */ - many: Set<(d: any) => void>; - } - /** - * Announcement listener type definition - * - * @export - * @interface AnnouncerListenerType - */ - interface AnnouncerListenerType { - [index: number]: { - /** - * The event name - * - * @type {string} - */ - e: string; - /** - * The event callback - * - */ - f: (d: any) => void; - }[]; - } - /** - * This class is the based class used in AntOS event - * announcement system. - * It implements the observer pattern using simple - * subscribe/publish mechanism - * @export - * @class Announcer - */ - class Announcer { - /** - * The observable object that stores event name - * and its corresponding callback in [[ObservableEntryType]] - * - * @type {GenericObject} - * @memberof Announcer - */ - observable: GenericObject; - /** - * Enable/disable the announcer - * - * @type {boolean} - * @memberof Announcer - */ - enable: boolean; - /** - *Creates an instance of Announcer. - * @memberof Announcer - */ - constructor(); - /** - * Disable the announcer, when this function is called - * all events and their callbacks will be removed - * - * @returns - * @memberof Announcer - */ - disable(): boolean; - /** - * Subscribe to an event, the callback will be called - * every time the corresponding event is trigged - * - * @param {string} evtName event name - * @param {(d: any) => void} callback The corresponding callback - * @returns {void} - * @memberof Announcer - */ - on(evtName: string, callback: (d: any) => void): void; - /** - * Subscribe to an event, the callback will - * be called only once and then removed from the announcer - * - * @param {string} evtName event name - * @param {(d: any) => void} callback the corresponding callback - * @returns {void} - * @memberof Announcer - */ - one(evtName: string, callback: (d: any) => void): void; - /** - * Unsubscribe the callback from an event - * - * @param {string} evtName event name - * @param {(d: any) => void} [callback] the callback to be unsubscribed. - * When the `callback` is `*`, all callbacks related to `evtName` will be - * removed - * @memberof Announcer - */ - off(evtName: string, callback?: (d: any) => void): void; - /** - * Trigger an event - * - * @param {string} evtName event name - * @param {*} data data object that will be send to all related callback - * @returns {void} - * @memberof Announcer - */ - trigger(evtName: string, data: any): void; - } - } - /** - * This namespace defines every thing related to the system announcement. - * - * The system announcement provides a global way to communicate between - * processes (applications/services) using the subscribe/publish - * mechanism - */ - namespace announcer { - /** - * The global announcer object that manages global events - * and callbacks - */ - var observable: API.Announcer; - /** - * This variable is used to allocate the `id` of all messages - * passing between publishers and subscribers in the - * system announcement - */ - var quota: 0; - /** - * Placeholder of all global events listeners - */ - var listeners: API.AnnouncerListenerType; - /** - * Subscribe to a global event - * - * @export - * @param {string} e event name - * @param {(d: API.AnnouncementDataType) => void} f event callback - * @param {GUI.BaseModel} a the process (Application/service) related to the callback - */ - function on(e: string, f: (d: API.AnnouncementDataType) => void, a: BaseModel): void; - /** - * Trigger a global event - * - * @export - * @param {string} e event name - * @param {*} d data passing to all related callback - */ - function trigger(e: string, d: any): void; - /** - * Report system fail. This will trigger the global `fail` - * event - * - * @export - * @param {(string | FormattedString)} m message string - * @param {Error} e error to be reported - */ - function osfail(m: string | FormattedString, e: Error): void; - /** - * Report system error. This will trigger the global `error` - * event - * - * @export - * @param {(string | FormattedString)} m message string - * @param {Error} e error to be reported - */ - function oserror(m: string | FormattedString, e: Error): void; - /** - * Trigger system notification (`info` event) - * - * @export - * @param {(string | FormattedString)} m notification message - */ - function osinfo(m: string | FormattedString): void; - /** - * - * - * @export - * @param {string} e event name - * @param {(string| FormattedString)} m event message - * @param {*} [d] user data - */ - function ostrigger(e: string, m: string | FormattedString, d?: any): void; - /** - * Unregister a process (application/service) from - * the global announcement system - * - * @export - * @param {GUI.BaseModel} app reference to the process - * @returns {void} - */ - function unregister(app: BaseModel): void; - /** - * Allocate message id - * - * @export - * @returns {number} - */ - function getMID(): number; - } -} -declare namespace OS { - /** - * This namespace dedicated to all operations related to system - * process management - */ - namespace PM { - /** - * A process is either an instance of an application or a service - */ - type ProcessType = application.BaseApplication | application.BaseService; - /** - * Alias to all classes that extends [[BaseModel]] - */ - type ModelTypeClass = { - new (args: AppArgumentsType[]): T; - }; - /** - * Process id allocator, when a new process is created, the value of - * this variable is increased - */ - var pidalloc: number; - /** - * All running processes is stored in this variables - */ - var processes: GenericObject; - /** - * Create a new process of application or service - * - * @export - * @param {string} app class name string - * @param {ProcessTypeClass} cls prototype class - * @param {GUI.AppArgumentsType[]} [args] process arguments - * @returns {Promise} a promise on the created process - */ - function createProcess(app: string, cls: ModelTypeClass, args?: AppArgumentsType[]): Promise; - /** - * Get the reference to a process using its id - * - * @export - * @param {number} pid - * @returns {BaseModel} - */ - function appByPid(pid: number): BaseModel; - /** - * Kill a process - * - * @export - * @param {OS.GUI.BaseModel} app reference to the process - * @returns {void} - */ - function kill(app: BaseModel): void; - /** - * Kill all process of an application or service - * - * @export - * @param {string} app process class name - * @param {boolean} force force exit all process - * @returns {void} - */ - function killAll(app: string, force: boolean): void; - } -} -declare namespace OS { - namespace API { - /** - * Interface for user login data - * - * @export - * @interface UserLoginType - */ - interface UserLoginType { - /** - * The user credential - * - * @type {string} - * @memberof UserLoginType - */ - username: string; - /** - * The user password - * - * @type {string} - * @memberof UserLoginType - */ - password: string; - } - /** - * Interface for a command sent to - * server side package manage, it contains two field: - * - * @export - * @interface PackageCommandType - */ - interface PackageCommandType { - /** - * Command name, should be: `init`, `cache`, `install`, - * `uninstall` or `list` - * - * @type {string} - * @memberof PackageCommandType - */ - command: string; - /** - * Parameter object of each command - * - * @type {GenericObject} - * @memberof PackageCommandType - */ - args: GenericObject; - } - /** - * - * Interface for basic request result returned - * from the server-side. A valid server-side response should - * be in the following format - * ```json - * { - * "error": boolean or string_err, - * "result": JSON result object - * } - * ``` - * - * @export - * @interface RequestResult - */ - interface RequestResult { - /** - * Indicate whether the response is error - * - * @type {(boolean | string)} - * @memberof RequestResult - */ - error: boolean | string; - /** - * The response result, this value must be - * set when `error` is false - * - * @type {(string - * | boolean - * | GenericObject - * | any[] - * | FileInfoType - * | FileInfoType[] - * | setting.UserSettingType)} - * @memberof RequestResult - */ - result: string | boolean | GenericObject | any[] | FileInfoType | FileInfoType[] | setting.UserSettingType; - } - /** - * The host name of the server-side - */ - var HOST: string; - /** - * The base URI of the server-side API - */ - var BASE_URI: string; - /** - * The base REST URI of the server-side API - */ - var REST: string; - /** - * The namespace `handle` contains some low level API to - * communicate with the server side API. It is the only - * API layer that communicate directly with the server. - * To make AntOS compatible with any server side API, - * all exported variable unctions defined in the `handle` - * namespace should be re-implemented - */ - namespace handle { - /** - * Base URI for reading content of VFS file - */ - var get: string; - /** - * Base URI for VFS file sharing - */ - var shared: string; - /** - * Send a request to the server-side API for a directory scanning - * operation - * - * @export - * @param {string} p a VFS file path e.g. home://test/ - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or a list of FileInfoType - */ - function scandir(p: string): Promise; - /** - * - * Send a request to the server-side API for directory creation - * - * @export - * @param {string} p VFS path of the directory to be created - * @returns {Promise} A promise on a RequestResult - * which contains an error or true on success - */ - function mkdir(p: string): Promise; - /** - * Send a request to the server-side API for sharing/unsharing a VFS file, - * once shared a VFS file will be publicly visible by everyone - * - * @export - * @param {string} p VFS file path to be shared - * @param {boolean} pub flag: share (true) or unshare (false) - * @returns {Promise} A promise on a RequestResult - * which contains an error or true on success - */ - function sharefile(p: string, pub: boolean): Promise; - /** - * Get VFS file meta-data - * - * @export - * @param {string} p VFS file path - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or an object of FileInfoType - */ - function fileinfo(p: string): Promise; - /** - * Read a VFS file content. There are many ways a VFS file can be read: - * - Read as a raw text content - * - Read as a javascript file, in this case the content of the - * file will be executed - * - Read as JSON object - * - * @export - * @param {string} p path of the VFS file - * @param {string} t return data type: - * - jsonp: the response is an json object - * - script: the response is a javascript code - * - xml, html: the response is a XML/HTML object - * - text: plain text - * - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or an object of [[FileInfoType]] - */ - function readfile(p: string, t: string): Promise; - /** - * Move a file to another location on server-side - * - * @export - * @param {string} s VFS source file path - * @param {string} d VFS destination file path - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or a success response - */ - function move(s: string, d: string): Promise; - /** - * Delete a VFS file on the server-side - * - * @export - * @param {string} p VFS file path - * @returns {Promise} A promise on a [[RequestResult]] - * which contains an error or a success response - */ - function remove(p: string): Promise; - /** - * Read the file as binary data - * - * @export - * @param {string} p VFS file to be read - * @returns {Promise} a Promise on an array buffer - */ - function fileblob(p: string): Promise; - /** - * Send a command to the serverside package manager - * - * @export - * @param {PackageCommandType} d a package command of type PackageCommandType - * @returns {Promise} a promise on a [[RequestResult]] - */ - function packages(d: PackageCommandType): Promise; - /** - * Upload file to the server via VFS interface - * - * @export - * @param {string} d VFS destination directory path - * @returns {Promise} a promise on a [[RequestResult]] - */ - function upload(d: string): Promise; - /** - * Write Base 64 encoded data to a VFS file - * - * @export - * @param {string} p path to the VFS file - * @param {string} d file data encoded in Base 64 - * @returns {Promise} a promise on a [[RequestResult]] - */ - function write(p: string, d: string): Promise; - /** - * An apigateway allows client side to execute a custom server-side - * script and get back the result. This gateway is particularly - * useful in case of performing a task that is not provided by the core - * API - * - * @export - * @param {GenericObject} d execution indication, provided only when ws is `false` - * otherwise, `d` should be written directly to the websocket stream as JSON object. - * Two possible formats of `d`: - * ```text - * execute an server-side script file: - * - * { - * path: [VFS path], - * parameters: [parameters of the server-side script] - * } - * - * or, execute directly a snippet of server-side script: - * - * { code: [server-side script code snippet as string] } - * - * ``` - * - * @param {boolean} ws flag indicate whether to use websocket for the connection - * to the gateway API. In case of streaming data, the websocket is preferred - * @returns {Promise} a promise on the result object (any) - */ - function apigateway(d: GenericObject, ws: boolean): Promise; - /** - * Check if a user is logged in - * - * @export - * @returns {Promise} a promise on a [[RequestResult]] that - * contains an error or a [[UserSettingType]] object - */ - function auth(): Promise; - /** - * Perform a login operation - * - * @export - * @param {UserLoginType} d user data [[UserLoginType]] - * @returns {Promise} a promise on a [[RequestResult]] that - * contains an error or a [[UserSettingType]] object - */ - function login(d: UserLoginType): Promise; - /** - * Perform a logout operation - * - * @export - * @returns {Promise} a promise on a [[RequestResult]] - */ - function logout(): Promise; - /** - * Save the current user settings - * - * @export - * @returns {Promise} a promise on a [[RequestResult]] - */ - function setting(): Promise; - /** - * This is the low level function of AntOS VDB API. - * It requests the server API to perform some simple - * SQL query. - * - * @export - * @param {string} cmd action to perform: save, delete, get, select - * @param {GenericObject} d data object of the request based on each action: - * - save: - * ``` - * { table: "table name", data: [record data object]} - * ``` - * - get: - * ``` - * { table: "table name", id: [record id]} - * ``` - * - delete: - * ``` - * { table: "table name", id: [record id]} - * or - * { table: "table name", cond: [conditional object]} - * ``` - * - select: - * ``` - * { table: "table name", cond: [conditional object]} - * ``` - * @returns {Promise} a promise of [[RequestResult]] on the - * query data - * - * A conditional object represents a SQL condition statement as an object, - * example: `pid = 10 AND cid = 2 ORDER BY date DESC` - * ``` - * { - * exp: { - * "and": { - * pid: 10, - * cid: 2 - * } - * }, - * order: { - * date: "DESC" - * } - * } - * ``` - */ - function dbquery(cmd: string, d: GenericObject): Promise; - } - } -} -declare namespace OS { - /** - * This namespace is dedicated to everything related to the - * global system settings - */ - namespace setting { - /** - * User setting type definition - * - * @export - * @interface UserSettingType - */ - interface UserSettingType { - /** - * User full name - * - * @type {string} - * @memberof UserSettingType - */ - name: string; - /** - * User name - * - * @type {string} - * @memberof UserSettingType - */ - username: string; - /** - * User id - * - * @type {number} - * @memberof UserSettingType - */ - id: number; - /** - * User groups - * - * @type {{ [index: number]: string }} - * @memberof UserSettingType - */ - group?: { - [index: number]: string; - }; - [propName: string]: any; - } - /** - * Virtual desktop setting data type - * - * @export - * @interface DesktopSettingType - */ - interface DesktopSettingType { - /** - * Desktop VFS path - * - * @type {string} - * @memberof DesktopSettingType - */ - path: string; - /** - * Desktop menu, can be added automatically by applications - * - * @type {GUI.BasicItemType[]} - * @memberof DesktopSettingType - */ - menu: GUI.BasicItemType[]; - /** - * Show desktop hidden files - * - * @type {boolean} - * @memberof DesktopSettingType - */ - showhidden: boolean; - [propName: string]: any; - } - /** - * Wallpaper setting data type - * - * @export - * @interface WPSettingType - */ - interface WPSettingType { - /** - * Repeat wallpaper: - * - `repeat` - * - `repeat-x` - * - `repeat-y` - * - `no-repeat` - * - * @type {string} - * @memberof WPSettingType - */ - repeat: string; - /** - * Wallpaper size - * - `contain` - * - `cover` - * - `auto` - * - * @type {string} - * @memberof WPSettingType - */ - size: string; - /** - * VFS path to the wallpaper image - * - * @type {string} - * @memberof WPSettingType - */ - url: string; - } - /** - * Theme setting data type - * - * @export - * @interface ThemeSettingType - */ - interface ThemeSettingType { - /** - * Theme name, this value is used for looking - * theme file in system asset - * - * @type {string} - * @memberof ThemeSettingType - */ - name: string; - /** - * Theme user-friendly text - * - * @type {string} - * @memberof ThemeSettingType - */ - text: string; - } - /** - * Appearance setting data type - * - * @export - * @interface AppearanceSettingType - */ - interface AppearanceSettingType { - /** - * Current theme name - * - * @type {string} - * @memberof AppearanceSettingType - */ - theme: string; - /** - * All themes available in the system - * - * @type {ThemeSettingType[]} - * @memberof AppearanceSettingType - */ - themes: ThemeSettingType[]; - /** - * Current wallpaper setting - * - * @type {WPSettingType} - * @memberof AppearanceSettingType - */ - wp: WPSettingType; - /** - * All wallpapers available in the system - * - * @type {string[]} - * @memberof AppearanceSettingType - */ - wps: string[]; - } - /** - * VFS Mount points setting data type - * - * @export - * @interface VFSMountPointSettingType - */ - interface VFSMountPointSettingType { - /** - * Path to the mount point - * - * @type {string} - * @memberof VFSMountPointSettingType - */ - path: string; - /** - * User friendly mount point name - * - * @type {string} - * @memberof VFSMountPointSettingType - */ - text: string; - [propName: string]: any; - } - /** - * VFS setting data type - * - * @export - * @interface VFSSettingType - */ - interface VFSSettingType { - /** - * mount points setting - * - * @type {VFSMountPointSettingType[]} - * @memberof VFSSettingType - */ - mountpoints: VFSMountPointSettingType[]; - [propName: string]: any; - } - /** - * Global system setting data type - * - * @export - * @interface SystemSettingType - */ - interface SystemSettingType { - /** - * System error report URL - * - * @type {string} - * @memberof SystemSettingType - */ - error_report: string; - /** - * Current system locale e.g. `en_GB` - * - * @type {string} - * @memberof SystemSettingType - */ - locale: string; - /** - * System menus - * - * @type {API.PackageMetaType[]} - * @memberof API.PackageMetaType - */ - menu: API.PackageMetaType[]; - /** - * Packages meta-data - * - * @type {{ [index: string]: API.PackageMetaType }} - * @memberof SystemSettingType - */ - packages: { - [index: string]: API.PackageMetaType; - }; - /** - * Path to the installed packages - * - * @type {{ - * user: string; - * system: string; - * }} - * @memberof SystemSettingType - */ - pkgpaths: { - /** - * User specific packages install location - * - * @type {string} - */ - user: string; - /** - * System packages install location - * - * @type {string} - */ - system: string; - }; - /** - * Package repositories setting. - * This configuration is used by [[MarketPlace]] - * for package management - * - * @type {{ - * text: string; - * url: string; - * }[]} - * @memberof SystemSettingType - */ - repositories: { - /** - * Repository name - * - * @type {string} - */ - text: string; - /** - * Repository uri - * - * @type {string} - */ - url: string; - }[]; - /** - * Startup applications and services - * - * @type {{ - * apps: string[]; - * services: string[]; - * }} - * @memberof SystemSettingType - */ - startup: { - /** - * List of application names - * - * @type {string[]} - */ - apps: string[]; - /** - * List of service names - * - * @type {string[]} - */ - services: string[]; - /** - * List of pinned applications - * - * @type {string[]} - */ - pinned: string[]; - }; - } - /** - * User settings - */ - var user: UserSettingType; - /** - * Application settings - */ - var applications: GenericObject; - /** - * Desktop settings - */ - var desktop: DesktopSettingType; - /** - * Appearance settings - */ - var appearance: AppearanceSettingType; - /** - * VFS settings - */ - var VFS: VFSSettingType; - /** - * System settings - */ - var system: SystemSettingType; - } - /** - * Reset the system settings to default values - * - * @export - */ - function resetSetting(): void; - /** - * Apply the input parameter object to system settings. - * This object could be an object loaded from - * setting JSON file saved on the server. - * - * @export - * @param {*} conf - */ - function systemSetting(conf: any): void; -} -/// -declare namespace OS { - namespace application { - /** - * Services are processes that run in the background and - * are waken up in certain circumstances such as by global - * events or user interactions. - * - * Each service takes an entry in the system tray menu - * located on the system panel. This menu entry is used - * to access to service visual contents such as: options, - * task performing based on user interaction, etc. - * - * Services are singleton processes, there is only - * one process of a service at a time - * - * @export - * @abstract - * @class BaseService - * @extends {BaseModel} - */ - abstract class BaseService extends BaseModel { - /** - * The service icon shown in the system tray - * - * @type {string} - * @memberof BaseService - */ - icon: string; - /** - * CSS class of the service icon shown in the system tray - * - * @type {string} - * @memberof BaseService - */ - iconclass: string; - /** - * Text of the service shown in the system tray - * - * @type {string} - * @memberof BaseService - */ - text: string; - /** - * Reference to the menu entry DOM element attached - * to the service - * - * @type {HTMLElement} - * @memberof BaseService - */ - domel: HTMLElement; - /** - * Reference to the timer that periodically executes the callback - * defined in [[watch]]. - * - * @private - * @type {number} - * @memberof BaseService - */ - private timer; - /** - * Reference to the system tray menu - * - * @type {HTMLElement} - * @memberof BaseService - */ - holder: HTMLElement; - /** - * Placeholder for service select callback - * - * @memberof BaseService - */ - onmenuselect: (d: OS.GUI.TagEventType) => void; - /** - *Creates an instance of BaseService. - * @param {string} name service class name - * @param {AppArgumentsType[]} args service arguments - * @memberof BaseService - */ - constructor(name: string, args: AppArgumentsType[]); - /** - * Do nothing - * - * @memberof BaseService - */ - hide(): void; - /** - * Init the service before attaching it to - * the system tray: event subscribe, scheme - * loading. - * - * Should be implemented by all subclasses - * - * @abstract - * @memberof BaseService - */ - abstract init(): void; - /** - * Refresh the service menu entry in the - * system tray - * - * @memberof BaseService - */ - update(): void; - /** - * Get the service meta-data - * - * @returns {API.PackageMetaType} - * @memberof BaseService - */ - meta(): API.PackageMetaType; - /** - * Attach the service to a menu element - * such as the system tray menu - * - * @param {HTMLElement} h - * @memberof BaseService - */ - attach(h: HTMLElement): void; - /** - * Set the callback that will be called periodically - * after a period of time. - * - * Each service should only have at most one watcher - * - * @protected - * @param {number} t period time in seconds - * @param {() => void} f callback function - * @returns {number} - * @memberof BaseService - */ - protected watch(t: number, f: () => void): number; - /** - * This function is called when the service - * is exited - * - * @protected - * @param {BaseEvent} evt exit event - * @returns - * @memberof BaseService - */ - protected onexit(evt: BaseEvent): JQuery; - /** - * Do nothing - * - * @memberof BaseService - */ - main(): void; - /** - * Do nothing - * - * @memberof BaseService - */ - show(): void; - /** - * Awake the service, this function is usually called when - * the system tray menu entry attached to the service is - * selected. - * - * This function should be implemented by all subclasses - * - * @abstract - * @param {GUI.TagEventType} e - * @memberof BaseService - */ - abstract awake(e: GUI.TagEventType): void; - /** - * Do nothing - * - * @protected - * @param {BaseEvent} evt - * @memberof BaseService - */ - protected cleanup(evt: BaseEvent): void; - } - } -} -declare type VFSFileHandleClass = { - new (...args: any[]): OS.API.VFS.BaseFileHandle; -}; -interface String { - /** - * Convert a string to VFS file handle. - * - * This function will create a file handle object from the string - * with the help of [[VFS.findHandles]] - * - * @returns {OS.API.VFS.BaseFileHandle} - * @memberof String - */ - asFileHandle(): OS.API.VFS.BaseFileHandle; -} -declare namespace OS { - namespace API { - /** - * User permission data type - * - * @export - * @interface UserPermissionType - */ - interface UserPermissionType { - read: boolean; - write: boolean; - exec: boolean; - } - /** - * VFS file meta-data data type - * - * @export - * @interface FileInfoType - */ - interface FileInfoType { - /** - * File mime type - * - * @type {string} - * @memberof FileInfoType - */ - mime: string; - /** - * File size - * - * @type {number} - * @memberof FileInfoType - */ - size: number; - /** - * File name - * - * @type {string} - * @memberof FileInfoType - */ - name: string; - /** - * File path - * - * @type {string} - * @memberof FileInfoType - */ - path: string; - /** - * File type: - * - `file` - * - `dir` - * - `app` - * - * @type {string} - * @memberof FileInfoType - */ - type: string; - /** - * File permission - * - * @type {{ - * group: UserPermissionType; - * owner: UserPermissionType; - * other: UserPermissionType; - * }} - * @memberof FileInfoType - */ - perm?: { - /** - * Group permission - * - * @type {UserPermissionType} - */ - group: UserPermissionType; - /** - * Owner permission - * - * @type {UserPermissionType} - */ - owner: UserPermissionType; - /** - * Other permission - * - * @type {UserPermissionType} - */ - other: UserPermissionType; - }; - /** - * Creation time - * - * @type {string} - * @memberof FileInfoType - */ - ctime?: string; - /** - * Modification time - * - * @type {string} - * @memberof FileInfoType - */ - mtime?: string; - /** - * Group id - * - * @type {number} - * @memberof FileInfoType - */ - gid?: number; - /** - * User id - * - * @type {number} - * @memberof FileInfoType - */ - uid?: number; - [propName: string]: any; - } - /** - * This namespace is dedicated to all APIs related to - * AntOS Virtual File System (VFS) - */ - namespace VFS { - /** - * Placeholder stores VFS file protocol patterns and its attached file handle class. - * - */ - const handles: GenericObject; - /** - * Register a protocol to a handle class - * - * @export - * @param {string} protos VFS protocol pattern - * @param {VFSFileHandleClass} cls handle class - */ - function register(protos: string, cls: VFSFileHandleClass): void; - /** - * Load custom VFS handles if the package vfsx available - * - * @export - * @param {boolean} [force] force load the file - * @return {*} {Promise} - */ - function loadVFSX(force?: boolean): Promise; - /** - * Looking for a attached file handle class of a string protocol - * - * When converting a string to file handle, the system will look - * for a protocol pattern in the string, if the protocol found, - * its attached handle class (found in [[VFS.handles]]) will be - * used to initialize a file handle object from the string - * - * ```typescript - * "home://data/test.txt".asFileHandle() // -> an instance of RemoteFileHandle - * ``` - * @export - * @param {string} proto protocol string - * @returns {VFSFileHandleClass[]} - */ - function findHandles(proto: string): VFSFileHandleClass[]; - /** - * Abstract prototype of all all VFS file handle definition. - * - * This prototype provides a standardized interface to access - * to different underlay file systems such as remote file, - * cloud file (Dropbox, Google drive, etc.), URL or memory-based file - * - * @export - * @abstract - * @class BaseFileHandle - */ - abstract class BaseFileHandle { - /** - * Flag indicates whether the file is dirty - * - * @type {boolean} - * @memberof BaseFileHandle - */ - dirty: boolean; - /** - * Once read, file content will be cached in this placeholder - * - * @type {*} - * @memberof BaseFileHandle - */ - cache: any; - /** - * Flag indicated whether the file meta-data is loaded - * - * @type {boolean} - * @memberof BaseFileHandle - */ - ready: boolean; - /** - * File path - * - * @type {string} - * @memberof BaseFileHandle - */ - path: string; - /** - * File protocol e.g: - * - `os://` - * - `home://` - * - * @type {string} - * @memberof BaseFileHandle - */ - protocol: string; - /** - * List of path segments - * - * @type {string[]} - * @memberof BaseFileHandle - */ - genealogy: string[]; - /** - * File base name - * - * @type {string} - * @memberof BaseFileHandle - */ - basename: string; - /** - * Once loaded, [[ready]] will be set to true and - * file meta-data will be stored in this place holder - * - * @type {FileInfoType} - * @memberof BaseFileHandle - */ - info: FileInfoType; - /** - * File extension - * - * @type {string} - * @memberof BaseFileHandle - */ - ext: string; - /** - * - * File type - * @type {string} - * @memberof BaseFileHandle - */ - type: string; - /** - *Creates an instance of BaseFileHandle. - * @param {string} path file path - * @memberof BaseFileHandle - */ - constructor(path: string); - /** - * Set a file path to the current file handle - * - * @param {string} p - * @returns {void} - * @memberof BaseFileHandle - */ - setPath(p: string): void; - /** - * Getter: Get the file basename - * Setter: set the file name - * - * @returns {string} - * @memberof BaseFileHandle - */ - get filename(): string; - set filename(v: string); - /** - * Set data to the file cache - * - * @param {*} v data object - * @returns {BaseFileHandle} - * @memberof BaseFileHandle - */ - setCache(v: any): BaseFileHandle; - /** - * Return the object itself - * - * @returns {BaseFileHandle} - * @memberof BaseFileHandle - */ - asFileHandle(): BaseFileHandle; - /** - * Check whether the current file is the root of the file tree - * - * @returns {boolean} - * @memberof BaseFileHandle - */ - isRoot(): boolean; - /** - * Check whether the current file is a hidden file - * - * @returns {boolean} - * @memberof BaseFileHandle - */ - isHidden(): boolean; - /** - * Get hash number of the current file path - * - * @returns {number} - * @memberof BaseFileHandle - */ - hash(): number; - /** - * Convert the current file cache to Base64 - * - * @protected - * @param {string} t type of the file cache: - * - `object` - * - `mime type` - * @returns {(Promise)} promise on the converted data - * @memberof BaseFileHandle - */ - protected b64(t: string): Promise; - /** - * Get the parent file handle of the current file - * - * @returns {BaseFileHandle} - * @memberof BaseFileHandle - */ - parent(): BaseFileHandle; - /** - * Load the file meta-data before performing - * any task - * - * @returns {Promise} a promise on file meta-data - * @memberof BaseFileHandle - */ - onready(): Promise; - /** - * Public read operation - * - * This function calls the [[_rd]] function to perform the operation. - * - * If the current file is a directory, then the operation - * will return the meta-data of all files inside of the directory. - * Otherwise, file content will be returned - * - * @param {string} t data type - * - jsonp: the response is an json object - * - script: the response is a javascript code - * - xml, html: the response is a XML/HTML object - * - text: plain text - * - binary - * - * @returns {Promise} a promise on the file content - * @memberof BaseFileHandle - */ - read(t?: string): Promise; - /** - * Write the file cache to the actual file - * - * This function calls the [[_wr]] function to perform the operation - * - * @param {string} t data type - * - `base64` - * - `object` - * - `mime type` - * - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - write(t: string): Promise; - /** - * Sub-directory creation - * - * This function calls the [[_mk]] function to perform the operation - * - * @param {string} d sub directory name - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - mk(d: string): Promise; - /** - * Delete the file - * - * This function calls the [[_rm]] function to perform the operation - * - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - remove(): Promise; - /** - * Upload a file to the current directory - * - * Only work when the current file is a directory - * - * This function calls the [[_up]] function to perform the operation - * - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - upload(): Promise; - /** - * Share the file by publish it. - * - * Only work with file - * - * This function calls the [[_pub]] function to perform the operation - * - * @returns {Promise} promise on operation result - * @memberof BaseFileHandle - */ - publish(): Promise; - /** - * Download the file. - * - * Only work with file - * - * This function calls the [[_down]] function to perform the operation - * - * @returns {Promise} Promise on the operation result - * @memberof BaseFileHandle - */ - download(): Promise; - /** - * Move the current file to another location - * - * This function calls the [[_mv]] function to perform the operation - * - * @param {string} d destination location - * @returns {Promise} promise on the operation result - * @memberof BaseFileHandle - */ - move(d: string): Promise; - /** - * Execute the current file. - * - * This action depends on each file protocol - * - * This function calls the [[_exec]] function to perform the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - execute(): Promise; - /** - * Get an accessible link to the file - * that can be accessed from the browser - * - * @returns {string} - * @memberof BaseFileHandle - */ - getlink(): string; - /** - * Helper function returns a promise on unsupported action - * - * @param {string} t action name - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected unsupported(t: string): Promise; - /** - * Low level protocol-specific read operation - * - * This function should be overridden on the file handle class - * that supports the operation - * - * @protected - * @param {string} t data type, see [[read]] - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _rd(t: string): Promise; - /** - * Low level protocol-specific write operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @protected - * @param {string} t data type, see [[write]] - * @param {*} [d] - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _wr(t: string, d?: any): Promise; - /** - * Low level protocol-specific sub-directory creation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @protected - * @param {string} d sub directory name - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _mk(d: string): Promise; - /** - * Low level protocol-specific delete operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _rm(): Promise; - /** - * Low level protocol-specific move operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @protected - * @param {string} d - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _mv(d: string): Promise; - /** - * Low level protocol-specific upload operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _up(): Promise; - /** - * Low level protocol-specific download operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _down(): Promise; - /** - * Low level protocol-specific execute operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _exec(): Promise; - /** - * Low level protocol-specific share operation - * - * This function should be overridden by the file handle class - * that supports the operation - * - * @returns {Promise} - * @memberof BaseFileHandle - */ - protected _pub(): Promise; - /** - * Read the current file meta-data - * - * should be implemented by subclasses - * - * @abstract - * @returns {Promise} - * @memberof BaseFileHandle - */ - abstract meta(): Promise; - } - /** - * Remote file handle allows to perform file operation - * on AntOS remote server files. Its protocol is defined - * by the following pattern: - * - * ``` - * ^(home|desktop|os|Untitled)$ - * ``` - * - * @class RemoteFileHandle - * @extends {BaseFileHandle} - */ - class RemoteFileHandle extends BaseFileHandle { - /** - *Creates an instance of RemoteFileHandle. - * @param {string} path file path - * @memberof RemoteFileHandle - */ - constructor(path: string); - /** - * Read remote file meta-data - * - * @returns {Promise} - * @memberof RemoteFileHandle - */ - meta(): Promise; - /** - * Remote file access link - * - * @returns {string} - * @memberof RemoteFileHandle - */ - getlink(): string; - /** - * Read remote file content. - * - * If the current file is a directory, then the operation - * will return the meta-data of all files inside of the directory. - * Otherwise, file content will be returned - * - * @protected - * @param {string} t data type see [[read]] - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _rd(t: string): Promise; - /** - * Write file cache to the remote file - * - * @protected - * @param {string} t data type see [[write]] - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _wr(t: string): Promise; - /** - * Create sub directory - * - * Only work on directory file handle - * - * @protected - * @param {string} d sub directory name - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _mk(d: string): Promise; - /** - * Delete file/folder - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _rm(): Promise; - /** - * Move file/folder - * - * @protected - * @param {string} d - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _mv(d: string): Promise; - /** - * Upload a file - * - * Only work with directory file handle - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _up(): Promise; - /** - * Download a file - * - * only work with file - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _down(): Promise; - /** - * Publish a file - * - * @protected - * @returns {Promise} - * @memberof RemoteFileHandle - */ - protected _pub(): Promise; - } - /** - * Package file is remote file ([[RemoteFileHandle]]) located either in - * the local user packages location or system packages - * location, it should be in the following format: - * - * ``` - * pkg://PKG_NAME/path/to/file - * - * ``` - * - * The system will locale the package name PKG_NAME either in the system domain - * or in user domain and return the correct path to the package - * - * @export - * @class PackageFileHandle - * @extends {RemoteFileHandle} - */ - class PackageFileHandle extends RemoteFileHandle { - /** - *Creates an instance of PackageFileHandle. - * @param {string} pkg_path package path in string - * @memberof PackageFileHandle - */ - constructor(pkg_path: string); - } - /** - * Application file is an AntOS special file allowing to - * refer to an application as a regular file. Its protocol - * pattern is defined as: - * - * ```typescript - * "^app$" // e.g. app://Setting - * ``` - * - * @class ApplicationHandle - * @extends {BaseFileHandle} - */ - class ApplicationHandle extends BaseFileHandle { - /** - *Creates an instance of ApplicationHandle. - * @param {string} path file path - * @memberof ApplicationHandle - */ - constructor(path: string); - /** - * Read application meta-data - * - * @returns {Promise} - * @memberof ApplicationHandle - */ - meta(): Promise; - /** - * If the current file is root (e.g. `app://`), the operation - * will return all system packages meta-data. - * - * Otherwise, an error will be thrown - * - * @protected - * @param {string} t - * @returns {Promise} - * @memberof ApplicationHandle - */ - protected _rd(t: string): Promise; - } - /** - * A buffer file handle represents a virtual file that is stored - * on the system memory. Its protocol pattern is defined as: - * - * ```typescript - * "^mem$" // e.g. mem://test.txt - * ``` - * - * @class BufferFileHandle - * @extends {BaseFileHandle} - */ - class BufferFileHandle extends BaseFileHandle { - /** - *Creates an instance of BufferFileHandle. - * @param {string} path file path - * @param {string} mime file mime-type - * @param {*} data file data - * @memberof BufferFileHandle - */ - constructor(path: string, mime: string, data: any); - /** - * Read the file meta-data - * - * @returns {Promise} - * @memberof BufferFileHandle - */ - meta(): Promise; - /** - * Read file content stored in the file cached - * - * @protected - * @param {string} t data type see [[read]] - * @returns {Promise} - * @memberof BufferFileHandle - */ - protected _rd(t: string): Promise; - /** - * Write data to the file cache - * - * @protected - * @param {string} t data type, see [[write]] - * @param {*} d data - * @returns {Promise} - * @memberof BufferFileHandle - */ - protected _wr(t: string, d: any): Promise; - /** - * Download the buffer file - * - * @protected - * @returns {Promise} - * @memberof BufferFileHandle - */ - protected _down(): Promise; - } - /** - * URL file handle represents a HTTP/HTTPs link url - * as an AntOS VFS file handle. Its protocol is defined as - * - * ``` - * ^(http|https|ftp)$ - * ``` - * - * @class URLFileHandle - * @extends {BaseFileHandle} - */ - class URLFileHandle extends BaseFileHandle { - /** - *Creates an instance of URLFileHandle. - * @param {string} path - * @memberof URLFileHandle - */ - constructor(path: string); - /** - * Read file meta-data - * - * @returns {Promise} - * @memberof URLFileHandle - */ - meta(): Promise; - /** - * Read URL content - * - * @protected - * @param {string} t data type see [[read]] - * @returns {Promise} - * @memberof URLFileHandle - */ - protected _rd(t: string): Promise; - } - /** - * Shared file handle represents all AntOS shared file. - * Its protocol is defined as: - * - * ``` - * ^shared$ - * ``` - * - * @class SharedFileHandle - * @extends {API.VFS.BaseFileHandle} - */ - class SharedFileHandle extends API.VFS.BaseFileHandle { - /** - *Creates an instance of SharedFileHandle. - * @param {string} path file path - * @memberof SharedFileHandle - */ - constructor(path: string); - /** - * Read file meta-data - * - * @returns {Promise} - * @memberof SharedFileHandle - */ - meta(): Promise; - /** - * Read file content - * - * @protected - * @param {string} t data type, see [[read]] - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _rd(t: string): Promise; - /** - * write data to shared file - * - * @protected - * @param {string} t data type, see [[write]] - * @param {string} d file data - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _wr(t: string, d: string): Promise; - /** - * Un-publish the file - * - * @protected - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _rm(): Promise; - /** - * Download shared file - * - * @protected - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _down(): Promise; - /** - * Un publish the file - * - * @protected - * @returns {Promise} - * @memberof SharedFileHandle - */ - protected _pub(): Promise; - } - /**Utilities global functions */ - /** - * Read a file content from a zip archive - * - * The content type should be: - * - base64 : the result will be a string, the binary in a base64 form. - * - text (or string): the result will be an unicode string. - * - binarystring: the result will be a string in “binary” form, using 1 byte per char (2 bytes). - * - array: the result will be an Array of bytes (numbers between 0 and 255). - * - uint8array : the result will be a Uint8Array. This requires a compatible browser. - * - arraybuffer : the result will be a ArrayBuffer. This requires a compatible browser. - * - blob : the result will be a Blob. This requires a compatible browser. * - * If file_name is not specified, the first file_name in the zip archive will be read - * @export - * @param {string} file zip file - * @param {string} type content type to read - * @param {string} [file_name] the file should be read from the zip archive - * @return {*} {Promise} - */ - function readFileFromZip(file: string, type: string, file_name?: string): Promise; - /** - * Cat all files to a single out-put - * - * @export - * @param {string[]} list list of VFS files - * @param {string} data input data string that will be cat to the files content - * @param {string} join_by join on files content by this string - * @return {*} {Promise} - */ - function cat(list: string[], data: string, join_by?: string): Promise; - /** - * Read all files content on the list - * - * @export - * @param {string[]} list list of VFS files - * @param {GenericObject[]} contents content array - * @return {void} - */ - function read_files(list: string[]): Promise[]>; - /** - * Copy files to a folder - * - * @export - * @param {string[]} files list of files - * @param {string} to destination folder - * @return {*} {Promise} - */ - function copy(files: string[], to: string): Promise; - /** - * Create a zip archive from a folder - * - * @export - * @param {string} src source file/folder - * @param {string} dest destination archive - * @return {*} {Promise} - */ - function mkar(src: string, dest: string): Promise; - /** - * Create a list of directories - * - * @export - * @param {string[]} list of directories to be created - * @param {boolen} sync sync/async of directory creation - * @return {*} {Promise} - */ - function mkdirAll(list: string[], sync?: boolean): Promise; - /** - * - * - * @export Extract a zip fle - * @param {string} zfile zip file to extract - * @param {(zip:any) => Promise} [dest_callback] a callback to get extraction destination - * @return {*} {Promise} - */ - function extractZip(zfile: string | API.VFS.BaseFileHandle, dest_callback: (zip: any) => Promise): Promise; - /** - * Make files from a set of template files - * - * @export - * @param {Array} list mapping paths between templates files and created files - * @param {string} path files destination - * @param {(data: string) => string} callback: pre-processing files content before writing to destination files - * @return {*} {Promise} - */ - function mktpl(list: Array, path: string, callback: (data: string) => string): Promise; - } - } -} -/// -declare namespace OS { - /** - * This namespace is dedicated to application and service definition. - * When an application is loaded, its prototype definition will be - * inserted to this namespace for reuse lately - */ - namespace application { - /** - * Abstract prototype of all AntOS applications. - * Any new application definition should extend - * this prototype - * - * @export - * @abstract - * @class BaseApplication - * @extends {BaseModel} - */ - abstract class BaseApplication extends BaseModel { - /** - * Placeholder of all settings specific to the application. - * The settings stored in this object will be saved to system - * setting when logout and can be reused in the next login session - * - * @type {GenericObject} - * @memberof BaseApplication - */ - setting: GenericObject; - /** - * Hotkeys (shortcuts) defined for this application - * - * @protected - * @type {GUI.ShortcutType} - * @memberof BaseApplication - */ - protected keycomb: GUI.ShortcutType; - /** - * Reference to the system dock - * - * @type {GUI.tag.AppDockTag} - * @memberof BaseApplication - */ - sysdock: GUI.tag.AppDockTag; - /** - * Reference to the system application menu located - * on the system panel - * - * @type {GUI.tag.MenuTag} - * @memberof BaseApplication - */ - appmenu: GUI.tag.MenuTag; - /** - *Creates an instance of BaseApplication. - * @param {string} name application name - * @param {AppArgumentsType[]} args application arguments - * @memberof BaseApplication - */ - constructor(name: string, args: AppArgumentsType[]); - /** - * Init the application, this function is called when the - * application process is created and docked in the application - * dock. - * - * The application UI will be rendered after the execution - * of this function. - * - * @returns {void} - * @memberof BaseApplication - */ - init(): void; - /** - * Render the application UI by first loading its scheme - * and then mount this scheme to the DOM tree - * - * @protected - * @returns {void} - * @memberof BaseApplication - */ - protected loadScheme(): void; - /** - * API function to perform an heavy task. - * This function will trigger the global `loading` - * event at the beginning of the task, and the `loaded` - * event after finishing the task - * - * @protected - * @param {Promise} promise the promise on a task to be performed - * @returns {Promise} - * @memberof BaseApplication - */ - protected load(promise: Promise): Promise; - /** - * Bind a hotkey to the application, this function - * is used to define application keyboard shortcut - * - * @protected - * @param {string} k the hotkey to bind, should be in the following - * format: `[ALT|SHIFT|CTRL|META]-KEY`, e.g. `CTRL-S` - * @param {(e: JQuery.KeyboardEventBase) => void} f the callback function - * @returns {void} - * @memberof BaseApplication - */ - protected bindKey(k: string, f: (e: JQuery.KeyboardEventBase) => void): void; - /** - * Update the application local from the system - * locale or application specific locale configuration - * - * @param {string} name locale name e.g. `en_GB` - * @returns {void} - * @memberof BaseApplication - */ - updateLocale(name: string): void; - /** - * Execute the callback subscribed to a - * keyboard shortcut - * - * @param {string} fnk meta or modifier key e.g. `CTRL`, `ALT`, `SHIFT` or `META` - * @param {string} c a regular key - * @param {JQuery.KeyDownEvent} e JQuery keyboard event - * @returns {boolean} return whether the shortcut is executed - * @memberof BaseApplication - */ - shortcut(fnk: string, c: string, e: JQuery.KeyDownEvent): boolean; - /** - * Apply a setting to the application - * - * @protected - * @param {string} k the setting name - * @memberof BaseApplication - */ - protected applySetting(k: string): void; - /** - * Apply all settings to the application - * - * @protected - * @memberof BaseApplication - */ - protected applyAllSetting(): void; - /** - * Set a setting value to the application setting - * registry - * - * @protected - * @param {string} k setting name - * @param {*} v setting value - * @returns {void} - * @memberof BaseApplication - */ - protected registry(k: string, v: any): void; - /** - * Show the appliation - * - * @returns {void} - * @memberof BaseApplication - */ - show(): void; - /** - * Blur the application - * - * @returns {void} - * @memberof BaseApplication - */ - blur(): void; - /** - * Hide the application - * - * @returns {void} - * @memberof BaseApplication - */ - hide(): void; - /** - * Maximize or restore the application window size - * and its position - * - * @returns {void} - * @memberof BaseApplication - */ - toggle(): void; - /** - * Get the application title - * - * @returns {(string| FormattedString)} - * @memberof BaseApplication - */ - title(): string | FormattedString; - /** - * Function called when the application exit. - * If the input exit event is prevented, the application - * process will not be killed - * - * - * @protected - * @param {BaseEvent} evt exit event - * @memberof BaseApplication - */ - protected onexit(evt: BaseEvent): void; - /** - * Get the application meta-data - * - * @returns {API.PackageMetaType} - * @memberof BaseApplication - */ - meta(): API.PackageMetaType; - /** - * Base menu definition. This function - * returns the based menu definition of all applications. - * Other application specific menu entries - * should be defined in [[menu]] function - * - * @protected - * @returns {GUI.BasicItemType[]} - * @memberof BaseApplication - */ - protected baseMenu(): GUI.BasicItemType[]; - /** - * The main application entry that is called after - * the application UI is rendered. This application - * must be implemented by all subclasses - * - * @abstract - * @memberof BaseApplication - */ - abstract main(): void; - /** - * Application specific menu definition - * - * @protected - * @returns {GUI.BasicItemType[]} - * @memberof BaseApplication - */ - protected menu(): GUI.BasicItemType[]; - /** - * The cleanup function that is called by [[onexit]] function. - * Application need to override this function to perform some - * specific task before exiting or to prevent the application - * to be exited - * - * @protected - * @param {BaseEvent} e - * @memberof BaseApplication - */ - protected cleanup(e: BaseEvent): void; - } - } -} /** * Reference to the global this */ @@ -3517,6 +1408,13 @@ interface Date { * @memberof Date */ timestamp(): number; + /** + * Covnert to GMTString + * + * @returns {number} + * @memberof Date + */ + toGMTString(): string; } /** * Generic key-value pair object interface @@ -4322,6 +2220,274 @@ declare namespace OS { } } /// +declare namespace OS { + /** + * This namespace is dedicated to application and service definition. + * When an application is loaded, its prototype definition will be + * inserted to this namespace for reuse lately + */ + namespace application { + /** + * Abstract prototype of all AntOS applications. + * Any new application definition should extend + * this prototype + * + * @export + * @abstract + * @class BaseApplication + * @extends {BaseModel} + */ + abstract class BaseApplication extends BaseModel { + /** + * Placeholder of all settings specific to the application. + * The settings stored in this object will be saved to system + * setting when logout and can be reused in the next login session + * + * @type {GenericObject} + * @memberof BaseApplication + */ + setting: GenericObject; + /** + * Hotkeys (shortcuts) defined for this application + * + * @protected + * @type {GUI.ShortcutType} + * @memberof BaseApplication + */ + protected keycomb: GUI.ShortcutType; + /** + * Reference to the system dock + * + * @type {GUI.tag.AppDockTag} + * @memberof BaseApplication + */ + sysdock: GUI.tag.AppDockTag; + /** + * Reference to the system application menu located + * on the system panel + * + * @type {GUI.tag.MenuTag} + * @memberof BaseApplication + */ + appmenu: GUI.tag.MenuTag; + /** + * Loading animation check timeout + * + * @private + * @memberof BaseApplication + */ + private _loading_toh; + /** + * Store pending loading task + * + * @private + * @type {number[]} + * @memberof BaseApplication + */ + private _pending_task; + /** + *Creates an instance of BaseApplication. + * @param {string} name application name + * @param {AppArgumentsType[]} args application arguments + * @memberof BaseApplication + */ + constructor(name: string, args: AppArgumentsType[]); + /** + * Init the application, this function is called when the + * application process is created and docked in the application + * dock. + * + * The application UI will be rendered after the execution + * of this function. + * + * @returns {void} + * @memberof BaseApplication + */ + init(): void; + /** + * Render the application UI by first loading its scheme + * and then mount this scheme to the DOM tree + * + * @protected + * @returns {void} + * @memberof BaseApplication + */ + protected loadScheme(): void; + /** + * API function to perform an heavy task. + * This function will trigger the global `loading` + * event at the beginning of the task, and the `loaded` + * event after finishing the task + * + * @protected + * @param {Promise} promise the promise on a task to be performed + * @returns {Promise} + * @memberof BaseApplication + */ + protected load(promise: Promise): Promise; + /** + * Bind a hotkey to the application, this function + * is used to define application keyboard shortcut + * + * @protected + * @param {string} k the hotkey to bind, should be in the following + * format: `[ALT|SHIFT|CTRL|META]-KEY`, e.g. `CTRL-S` + * @param {(e: JQuery.KeyboardEventBase) => void} f the callback function + * @returns {void} + * @memberof BaseApplication + */ + protected bindKey(k: string, f: (e: JQuery.KeyboardEventBase) => void): void; + /** + * Update the application local from the system + * locale or application specific locale configuration + * + * @param {string} name locale name e.g. `en_GB` + * @returns {void} + * @memberof BaseApplication + */ + updateLocale(name: string): void; + /** + * Execute the callback subscribed to a + * keyboard shortcut + * + * @param {string} fnk meta or modifier key e.g. `CTRL`, `ALT`, `SHIFT` or `META` + * @param {string} c a regular key + * @param {JQuery.KeyDownEvent} e JQuery keyboard event + * @returns {boolean} return whether the shortcut is executed + * @memberof BaseApplication + */ + shortcut(fnk: string, c: string, e: JQuery.KeyDownEvent): boolean; + /** + * Apply a setting to the application + * + * @protected + * @param {string} k the setting name + * @memberof BaseApplication + */ + protected applySetting(k: string): void; + /** + * Apply all settings to the application + * + * @protected + * @memberof BaseApplication + */ + protected applyAllSetting(): void; + /** + * Set a setting value to the application setting + * registry + * + * @protected + * @param {string} k setting name + * @param {*} v setting value + * @returns {void} + * @memberof BaseApplication + */ + protected registry(k: string, v: any): void; + /** + * Show the appliation + * + * @returns {void} + * @memberof BaseApplication + */ + show(): void; + /** + * Blur the application + * + * @returns {void} + * @memberof BaseApplication + */ + blur(): void; + /** + * Hide the application + * + * @returns {void} + * @memberof BaseApplication + */ + hide(): void; + /** + * Maximize or restore the application window size + * and its position + * + * @returns {void} + * @memberof BaseApplication + */ + toggle(): void; + /** + * Get the application title + * + * @returns {(string| FormattedString)} + * @memberof BaseApplication + */ + title(): string | FormattedString; + /** + * Function called when the application exit. + * If the input exit event is prevented, the application + * process will not be killed + * + * + * @protected + * @param {BaseEvent} evt exit event + * @memberof BaseApplication + */ + protected onexit(evt: BaseEvent): void; + /** + * Get the application meta-data + * + * @returns {API.PackageMetaType} + * @memberof BaseApplication + */ + meta(): API.PackageMetaType; + /** + * Base menu definition. This function + * returns the based menu definition of all applications. + * Other application specific menu entries + * should be defined in [[menu]] function + * + * @protected + * @returns {GUI.BasicItemType[]} + * @memberof BaseApplication + */ + protected baseMenu(): GUI.BasicItemType[]; + /** + * The main application entry that is called after + * the application UI is rendered. This application + * must be implemented by all subclasses + * + * @abstract + * @memberof BaseApplication + */ + abstract main(): void; + /** + * Application specific menu definition + * + * @protected + * @returns {GUI.BasicItemType[]} + * @memberof BaseApplication + */ + protected menu(): GUI.BasicItemType[]; + /** + * The cleanup function that is called by [[onexit]] function. + * Application need to override this function to perform some + * specific task before exiting or to prevent the application + * to be exited + * + * @protected + * @param {BaseEvent} e + * @memberof BaseApplication + */ + protected cleanup(e: BaseEvent): void; + /** + * Check if the loading tasks ended, + * if it the case, stop the animation + * + * @private + * @memberof BaseApplication + */ + private animation_check; + } + } +} +/// declare namespace OS { /** * Application argument type definition @@ -4835,266 +3001,1512 @@ declare namespace OS { } } declare namespace OS { - namespace API { - /** - * Simple Virtual Database (VDB) application API. - * - * This API abstracts and provides a standard way to - * connect to a server-side relational database (e.g. sqlite). - * - * Each user when connected has their own database previously - * created. All VDB operations related to that user will be - * performed on this database. - * - * The creation of user database need to be managed by the server-side API. - * The VDB API assumes that the database already exist. All operations - * is performed in tables level - * - * @export - * @class DB - */ - class DB { + namespace GUI { + namespace tag { /** - * A table name on the user's database + * A switch tag is basically used to visualize an boolean data value. * - * @private - * @type {string} - * @memberof DB + * @export + * @class SwitchTag + * @extends {AFXTag} */ - private table; - /** - *Creates an instance of DB. - * @param {string} table table name - * @memberof DB - */ - constructor(table: string); - /** - * Save data to the current table. The input - * data must conform to the table record format. - * - * On the server side, if the table doest not - * exist yet, it should be created automatically - * by inferring the data structure of the input - * object - * - * @param {GenericObject} d data object represents a current table record - * @returns {Promise} - * @memberof DB - */ - save(d: GenericObject): Promise; - /** - * delete record(s) from the current table by - * a conditional object - * - * @param {*} c conditional object, c can be: - * - * * a `number`: the operation will delete the record with `id = c` - * * a `string`: The SQL string condition that selects record to delete - * * a conditional object represents a SQL condition statement as an object, - * example: `pid = 10 AND cid = 2` is represented by: - * - * ```typescript - * { - * exp: { - * "and": { - * pid: 10, - * cid: 2 - * } - * } - * ``` - * - * @returns {Promise} - * @memberof DB - */ - delete(c: GenericObject | number | string): Promise; - /** - * Get a record in the table by its primary key - * - * @param {number} id the primary key value - * @returns {Promise>} Promise on returned record data - * @memberof DB - */ - get(id: number): Promise>; - /** - * Find records by a condition - * - * @param {GenericObject} cond conditional object - * - * a conditional object represents a SQL condition statement as an object, - * example: `pid = 10 AND cid = 2 ORDER BY date DESC` is represented by: - * - * ```typescript - * { - * exp: { - * "and": { - * pid: 10, - * cid: 2 - * } - * }, - * order: { - * date: "DESC" - * } - * } - * ``` - * @returns {Promise[]>} - * @memberof DB - */ - find(cond: GenericObject): Promise[]>; + class SwitchTag extends AFXTag { + /** + * Placeholder for the onchange event handle + * + * @private + * @type {TagEventCallback} + * @memberof SwitchTag + */ + private _onchange; + /** + * Setter: Turn on/off the switch + * + * Getter: Check whether the switch is turned on + * + * @memberof SwitchTag + */ + set swon(v: boolean); + get swon(): boolean; + /** + * Setter: Enable the switch + * + * Getter: Check whether the switch is enabled + * + * @memberof SwitchTag + */ + set enable(v: boolean); + get enable(): boolean; + /** + * Set the onchange event handle + * + * @memberof SwitchTag + */ + set onswchange(v: TagEventCallback); + /** + * Mount the tag and bind the click event to the switch + * + * @protected + * @memberof SwitchTag + */ + protected mount(): void; + /** + * This function will turn the switch (on/off) + * and trigger the onchange event + * + * @private + * @param {JQuery.ClickEvent} e + * @returns + * @memberof SwitchTag + */ + private makechange; + /** + * Tag layout definition + * + * @protected + * @returns + * @memberof SwitchTag + */ + protected layout(): { + el: string; + ref: string; + }[]; + /** + * Init the tag: + * - switch is turn off + * - switch is enabled + * + * @protected + * @memberof SwitchTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @memberof SwitchTag + */ + protected calibrate(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof SwitchTag + */ + protected reload(d?: any): void; + } } } } declare namespace OS { namespace GUI { - /** - * - * Interface for an application dock item - * - * @export - * @interface AppDockItemType - */ - interface AppDockItemType { - /** - * Reference to the application process represented - * by the dock item - * - * @type {application.BaseApplication} - * @memberof AppDockItemType - */ - app: application.BaseApplication; - /** - * Reference to the DOM element of - * the owner dock item - * - * @type {AFXTag} - * @memberof AppDockItemType - */ - domel?: AFXTag; - [propName: string]: any; - } namespace tag { /** - * This class define the AntOS system application dock tag + * Definition of system file view widget * * @export - * @class AppDockTag + * @class FileViewTag * @extends {AFXTag} */ - class AppDockTag extends AFXTag { + class FileViewTag extends AFXTag { /** - * variable holds the application select event - * callback handle + * placeholder for file select event callback * * @private - * @type {TagEventCallback} - * @memberof AppDockTag + * @type {TagEventCallback} + * @memberof FileViewTag */ - private _onappselect; + private _onfileselect; /** - * Items data of the dock + * placeholder for file open event callback * * @private - * @type {AppDockItemType[]} - * @memberof AppDockTag + * @type {TagEventCallback} + * @memberof FileViewTag */ - private _items; + private _onfileopen; /** - * Reference to the currently select application - * process in the dock + * Reference to the all selected files meta-datas * * @private - * @type {AppDockItemType} - * @memberof AppDockTag + * @type {API.FileInfoType[]} + * @memberof FileViewTag */ - private _selectedItem; + private _selectedFiles; /** - *Creates an instance of AppDockTag. - * @memberof AppDockTag + * Data placeholder of the current working directory + * + * @private + * @type {API.FileInfoType[]} + * @memberof FileViewTag + */ + private _data; + /** + * The path of the current working directory + * + * @private + * @type {string} + * @memberof FileViewTag + */ + private _path; + /** + * Header definition of the widget grid view + * + * @private + * @type {(GenericObject[])} + * @memberof FileViewTag + */ + private _header; + /** + * placeholder for the user-specified meta-data fetch function + * + * @private + * @memberof FileViewTag + */ + private _fetch; + /** + *Creates an instance of FileViewTag. + * @memberof FileViewTag */ constructor(); /** - * Implementation of the abstract function: Update the current tag. - * It do nothing for this tag + * Init the widget before mounting * * @protected - * @param {*} [d] - * @memberof AppDockTag - */ - protected reload(d?: any): void; - /** - * Init the tag before mounting - * - * @protected - * @memberof AppDockTag + * @memberof FileViewTag */ protected init(): void; /** - * The tag layout, it is empty on creation but elements will - * be added automatically to it in operation + * Update the current widget, do nothing * * @protected - * @returns {TagLayoutType[]} - * @memberof AppDockTag + * @param {*} [d] + * @memberof FileViewTag */ - protected layout(): TagLayoutType[]; + protected reload(d?: any): void; /** - * getter to get the dock items + * set the function that allows to fetch file entries. + * This handle function should return a promise on + * an arry of [[API.FileInfoType]] * - * @readonly - * @type {AppDockItemType[]} - * @memberof AppDockTag + * @memberof FileViewTag */ - get items(): AppDockItemType[]; + set fetch(v: (p: string) => Promise); + /** + * set the callback handle for the file select event. + * The parameter of the callback should be an object + * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] + * + * @memberof FileViewTag + */ + set onfileselect(e: TagEventCallback); + /** + set the callback handle for the file open event. + * The parameter of the callback should be an object + * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] + * + * @memberof FileViewTag + */ + set onfileopen(e: TagEventCallback); /** * Setter: * - * set the selected application in the dock - * this will trigger two event: - * - `focus`: on the selected application - * - `blur`: on all other applications on the dock + * chang the view of the widget, there are three different views + * - `icon` + * - `list` + * - `tree` * * Getter: * - * Get the current selected application - * on the dock + * Get the current view setting of the widget * - * @memberof AppDockTag + * @memberof FileViewTag */ - set selectedApp(v: application.BaseApplication); - get selectedApp(): application.BaseApplication; + set view(v: string); + get view(): string; /** - * Get selected item of the dock + * Setter: + * + * Turn on/off the changing current working directory feature + * of the widget when a directory is double clicked. If enabled, + * the widget will use the configured [[fetch]] function to query + * the content of the selected directory + * + * Getter: + * + * check whether changing current working directory feature + * is enabled + * + * @memberof FileViewTag + */ + set chdir(v: boolean); + get chdir(): boolean; + /** + * Setter : Enable or disable the status bar of the widget + * + * Getter: Check whether the status bar is enabled + * + * @memberof FileViewTag + */ + set status(v: boolean); + get status(): boolean; + /** + * Setter: + * + * Allow the widget to show or hide hidden file + * + * Getter: + * + * Check whether the hidden file should be shown in + * the widget + * + * @memberof FileViewTag + */ + set showhidden(v: boolean); + get showhidden(): boolean; + /** + * Setter: + * + * Allow multiple selection on file view + * + * Getter: + * + * Check whether the multiselection is actived + * + * @memberof FileViewTag + */ + set multiselect(v: boolean); + get multiselect(): boolean; + /** + * Get the current selected file * * @readonly - * @type {AppDockItemType} - * @memberof AppDockTag + * @type {API.FileInfoType} + * @memberof FileViewTag */ - get selectedItem(): AppDockItemType; + get selectedFile(): API.FileInfoType; /** - * When a new application process is created, this function - * will be called to add new application entry to the dock. - * The added application will becomes the current selected - * application + * Get all selected files * - * @param {AppDockItemType} item an application dock item entry - * @memberof AppDockTag + * @readonly + * @type {API.FileInfoType[]} + * @memberof FileViewTag */ - newapp(item: AppDockItemType): void; + get selectedFiles(): API.FileInfoType[]; /** - * Delete and application entry from the dock. - * This function will be called when an application - * is exit + * Setter: * - * @param {BaseApplication} a the application to be removed from the dock - * @memberof AppDockTag + * Set the path of the current working directory. + * When called the widget will refresh the current + * working directory using the configured [[fetch]] + * function + * + * Getter: + * + * Get the path of the current working directory + * + * @memberof FileViewTag */ - removeapp(a: application.BaseApplication): void; + set path(v: string); + get path(): string; /** - * Mount the current dock tag + * Setter: Set the data of the current working directory + * + * Getter: Get the data of the current working directory + * + * @memberof FileViewTag + */ + set data(v: API.FileInfoType[]); + get data(): API.FileInfoType[]; + /** + * Set the file drag and drop event handle. This allows application + * to define custom behavior of the event + * + * @memberof FileViewTag + */ + set ondragndrop(v: TagEventCallback>); + /** + * Sort file by its type + * + * @private + * @param {API.FileInfoType} a + * @param {API.FileInfoType} b + * @return {*} {number} + * @memberof FileViewTag + */ + private sortByType; + /** + * sort file by its name + * + * @private + * @param {API.FileInfoType} a first file meta-data + * @param {API.FileInfoType} b second file meta-data + * @returns {number} + * @memberof FileViewTag + */ + private sortByName; + /** + * calibrate the widget layout + * + * @memberof FileViewTag + */ + calibrate(): void; + /** + * Refresh the list view of the widget. This function + * is called when the view of the widget changed to `icon` + * + * @private + * @memberof FileViewTag + */ + private refreshList; + /** + * Refresh the grid view of the widget, this function is called + * when the view of the widget set to `list` + * + * @private + * @memberof FileViewTag + */ + private refreshGrid; + /** + * Refresh the Treeview of the widget, this function is called + * when the view of the widget set to `tree` + * + * @private + * @memberof FileViewTag + */ + private refreshTree; + /** + * Create the tree data from the list of input + * file meta-data + * + * @private + * @param {API.FileInfoType[]} data list of file meta-data + * @returns {TreeViewDataType[]} + * @memberof FileViewTag + */ + private getTreeData; + /** + * Refresh data of the current widget view + * + * @private + * @returns {void} + * @memberof FileViewTag + */ + private refreshData; + /** + * Switch between three view options + * + * @private + * @memberof FileViewTag + */ + private switchView; + /** + * This function triggers the file select event + * + * @private + * @param {API.FileInfoType} e selected file meta-data + * @memberof FileViewTag + */ + private fileselect; + /** + * This function triggers the file open event + * + * @private + * @param {API.FileInfoType} e selected file meta-data + * @memberof FileViewTag + */ + private filedbclick; + /** + * Mount the widget in the DOM tree * * @protected - * @memberof AppDockTag + * @memberof FileViewTag */ protected mount(): void; + /** + * Layout definition of the widget + * + * @protected + * @returns {TagLayoutType[]} + * @memberof FileViewTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +/// +/** + * + * Extend the HTMLElement interface with some utility function need + * by AFX API + * + * @interface HTMLElement + */ +interface HTMLElement { + /** + * Recursively update a tag and all its children + * + * @param {*} [d] data to send to all element in the DOM subtree + * @memberof HTMLElement + */ + update(d?: any): void; + /** + * + * AFX will automatically bind the context menu on an HTMLElement + * if this function is defined on that element. The function should + * define the content of the context menu and its action + * + * Once the context menu is bound to the element, all context menu handle + * defined on any child of this element will be ignored. + * + * @param {JQuery.MouseEventBase} e a mouse event + * @param {OS.GUI.tag.MenuTag} m The context menu element [[MenuTag]] + * @memberof HTMLElement + */ + contextmenuHandle(e: JQuery.MouseEventBase, m: OS.GUI.tag.MenuTag): void; + /** + * Mount the element and all the children on its DOM subtree. This action + * is performed in a top-down manner + * + * @memberof HTMLElement + */ + sync(): void; + /** + * + * This action allows to generated all the DOM nodes defined by all AFX tags + * in its hierarchy. + * It performs two operations, one top-down operation to generate all the + * necessary DOM nodes, another bottom-up operation to init all the AFX tag + * in the current element DOM hierarchy + * + * @param {OS.API.Announcer} o an AntOS observable object + * @memberof HTMLElement + */ + afxml(o: OS.API.Announcer): void; + /** + * Perform DOM generation ([[afxml]]) then mount ([[sync]]) all the + * elements. + * + * @param {OS.API.Announcer} o an AntOS observable object + * @param {boolean} [flag] indicates whether this is the top-most call of the operation + * @memberof HTMLElement + */ + uify(o: OS.API.Announcer, flag?: boolean): void; + /** + * + * + * @type {*} + * @memberof HTMLElement + */ + mozRequestFullScreen: any; + /** + * + * + * @type {*} + * @memberof HTMLElement + */ + webkitRequestFullscreen: any; + /** + * + * + * @type {*} + * @memberof HTMLElement + */ + msRequestFullscreen: any; +} +/** + * + * + * @interface Document + */ +interface Document { + mozCancelFullScreen: any; + webkitExitFullscreen: any; + cancelFullScreen: any; +} +declare namespace OS { + namespace GUI { + /** + * [[TagLayoutType]] interface using by AFX tags to defined + * its internal DOM hierarchy + * + * @export + * @interface TagLayoutType + */ + interface TagLayoutType { + /** + * Element tag name + * + * @type {string} + * @memberof TagLayoutType + */ + el: string; + /** + * Children layout of the current element + * + * @type {TagLayoutType[]} + * @memberof TagLayoutType + */ + children?: TagLayoutType[]; + /** + * Reference name of the element used by AFX Tag + * + * @type {string} + * @memberof TagLayoutType + */ + ref?: string; + /** + * CSS class of the element + * + * @type {string} + * @memberof TagLayoutType + */ + class?: string; + /** + * this is the `data-id` attribute of the element, + * can be query by the [[aid]] Tag API function. + * Not to be confused with the DOM `id` attribute + * + * @type {(string | number)} + * @memberof TagLayoutType + */ + id?: string | number; + /** + * Tooltip text of the element + * + * @type {(string | FormattedString)} + * @memberof TagLayoutType + */ + tooltip?: string | FormattedString; + /** + * `data-width` of the element, not to be confused with + * the `width` attribute of the DOM element + * + * @type {number|string} + * @memberof TagLayoutType + */ + width?: number | string; + /** + ** `data-height` of the element, not to be confused with + * the `height` attribute of the DOM element + * + * @type {number|string} + * @memberof TagLayoutType + */ + height?: number | string; + } + /** + * Data type for event issued by AFX tags + * + * @export + * @interface TagEventDataType + * @template T item template + */ + interface TagEventDataType { + /** + * Reference to the item involved in the event + * + * @type {T} + * @memberof TagEventDataType + */ + item?: T; + [propName: string]: any; + } + /** + * Format of the event issued by AFX tags + * + * @export + * @interface TagEventType + * @template T data type + */ + interface TagEventType { + /** + * `data-id` of the tag that trigger the + * event + * + * @type {(number | string)} + * @memberof TagEventType + */ + id: number | string; + /** + * Data object of the event + * + * @type {T} + * @memberof TagEventType + */ + data: T; + } + /** + * Drag and Drop data type sent between mouse events + * + * @export + * @interface DnDEventDataType + * @template T + */ + interface DnDEventDataType { + /** + * Reference to the source DOM element + * + * @type {T} + * @memberof DnDEventDataType + */ + from: T[]; + /** + * Reference to the target DOM element + * + * @type {T} + * @memberof DnDEventDataType + */ + to: T; + } + /** + * Tag event callback type + */ + type TagEventCallback = (e: TagEventType) => void; + /** + * Base abstract class for tag implementation, any AFX tag should be + * subclass of this class + * + * @export + * @abstract + * @class AFXTag + * @extends {HTMLElement} + */ + abstract class AFXTag extends HTMLElement { + /** + * The announcer object of the tag + * + * @type {API.Announcer} + * @memberof AFXTag + */ + observable: API.Announcer; + /** + * Reference to some of the tag's children + * element. This reference object is built + * based on the `ref` property found in the + * tag layout [[TagLayoutType]] + * + * @protected + * @type {GenericObject} + * @memberof AFXTag + */ + protected refs: GenericObject; + /** + * boolean value indicated whether the tag + * is already mounted in the DOM tree + * + * @protected + * @type {boolean} + * @memberof AFXTag + */ + protected _mounted: boolean; + /** + *Creates an instance of AFXTag. + * @memberof AFXTag + */ + constructor(); + /** + * This function verifies if a property name of the input object + * corresponds to a setter of the current tag. If this is the + * case, it sets the value of that property to the setter + * + * @param {GenericObject} v input object + * @memberof AFXTag + */ + set(v: GenericObject): void; + /** + * Setter to set the tooltip text to the current tag. + * The text should be in the following format: + * ```text + * cr|cl|ct|cb: tooltip text + * ``` + * + * @memberof AFXTag + */ + set tooltip(v: string); + /** + * + * This function looking for a property name of the tag + * in its prototype chain. The descriptor of the property + * will be returned if it exists + * + * @private + * @param {string} k the property name to be queried + * @returns {PropertyDescriptor} the property descriptor or undefined + * @memberof AFXTag + */ + private descriptor_of; + /** + * Setter: set the id of the tag in string or number + * + * Getter: get the id of the current tag + * + * @memberof AFXTag + */ + set aid(v: string | number); + get aid(): string | number; + /** + * Implementation from HTMLElement interface, + * this function mount the current tag hierarchy + * + * @returns {void} + * @memberof AFXTag + */ + sync(): void; + /** + * Generate the DOM hierarchy of the current tag + * + * @param {API.Announcer} o observable object + * @memberof AFXTag + */ + afxml(o: API.Announcer): void; + /** + * Update the current tag hierarchy + * + * @param {*} d any data object + * @memberof AFXTag + */ + update(d: any): void; + /** + * Init the current tag, this function + * is called before the [[mount]] function + * + * @protected + * @abstract + * @memberof AFXTag + */ + protected abstract init(): void; + /** + * Mount only the current tag + * + * @protected + * @abstract + * @memberof AFXTag + */ + protected abstract mount(): void; + /** + * Layout definition of a tag + * + * @protected + * @abstract + * @returns {TagLayoutType[]} tag layout object + * @memberof AFXTag + */ + protected abstract layout(): TagLayoutType[]; + /** + * Update only the current tag, this function is + * called by [[update]] before chaining the + * update process to its children + * + * @protected + * @abstract + * @param {*} [d] + * @memberof AFXTag + */ + protected abstract reload(d?: any): void; + /** + * This function is used to re-render the current + * tag + * + * @protected + * @memberof AFXTag + */ + protected calibrate(): void; + /** + * This function parses the input layout object + * and generates all the elements defined by + * the tag + * + * @private + * @param {TagLayoutType} tag tag layout object + * @returns {Element} the DOM element specified by the tag layout + * @memberof AFXTag + */ + private mkui; + /** + * This function inserts or removes an attribute name + * to/from the target element based on the input `flag`. + * + * @protected + * @param {boolean} flag indicates whether the attribute name should be inserted o removed + * @param {string} v the attribute name + * @param {HTMLElement} [el] the target element + * @memberof AFXTag + */ + protected attsw(flag: boolean, v: string, el?: HTMLElement): void; + /** + * Insert the attribute name to the target element + * + * @protected + * @param {string} v the attribute name + * @param {HTMLElement} [el] the target element + * @memberof AFXTag + */ + protected atton(v: string, el?: HTMLElement): void; + /** + * Remove the attribute name from the target element + * + * @protected + * @param {string} v attribute name + * @param {HTMLElement} [el] the target element + * @memberof AFXTag + */ + protected attoff(v: string, el?: HTMLElement): void; + /** + * Verify if the target element has an attribute name + * + * @protected + * @param {string} v attribute name + * @param {HTMLElement} [el] target element + * @returns {boolean} + * @memberof AFXTag + */ + protected hasattr(v: string, el?: HTMLElement): boolean; + } + /** + * All the AFX tags are defined in this namespace, + * these tags are defined as custom DOM elements and will be + * stored in the `customElements` registry of the browser + */ + namespace tag { + /** + * Define an AFX tag as a custom element and add it to the + * global `customElements` registry. If the tag is redefined, i.e. + * the tag already exists, its behavior will be updated with the + * new definition + * + * @export + * @template T all classes that extends [[AFXTag]] + * @param {string} name name of the tag + * @param {{ new (): T }} cls the class that defines the tag + * @returns {void} + */ + function define(name: string, cls: { + new (): T; + }): void; + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * List item event data type + */ + type ListItemEventData = TagEventDataType; + /** + * A list item represent the individual view of an item in the [[ListView]]. + * This class is an abstract prototype class, implementation of any + * list view item should extend it + * + * + * @export + * @abstract + * @class ListViewItemTag + * @extends {AFXTag} + */ + abstract class ListViewItemTag extends AFXTag { + /** + * Data placeholder for the list item + * + * @private + * @type {GenericObject} + * @memberof ListViewItemTag + */ + private _data; + /** + * placeholder for the item select event callback + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onselect; + /** + * Context menu event callback handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onctxmenu; + /** + * Click event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onclick; + /** + * Double click event callback handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _ondbclick; + /** + * Item close event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onclose; + /** + *Creates an instance of ListViewItemTag. + * @memberof ListViewItemTag + */ + constructor(); + /** + * Setter: Turn on/off the `closable` feature of the list item + * + * Getter: Check whether the item is closable + * + * @memberof ListViewItemTag + */ + set closable(v: boolean); + get closable(): boolean; + /** + * Set item select event handle + * + * @memberof ListViewItemTag + */ + set onitemselect(v: TagEventCallback); + /** + * Setter: select/unselect the current item + * + * Getter: Check whether the current item is selected + * + * @memberof ListViewItemTag + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Set the context menu event handle + * + * @memberof ListViewItemTag + */ + set onctxmenu(v: TagEventCallback); + /** + * Set the item click event handle + * + * @memberof ListViewItemTag + */ + set onitemclick(v: TagEventCallback); + /** + * Set the item double click event handle + * + * @memberof ListViewItemTag + */ + set onitemdbclick(v: TagEventCallback); + /** + * set the item close event handle + * + * @memberof ListViewItemTag + */ + set onitemclose(v: TagEventCallback); + /** + * Mount the tag and bind some events + * + * @protected + * @memberof ListViewItemTag + */ + protected mount(): void; + /** + * Layout definition of the item tag. + * This function define the outer layout of the item. + * Custom inner layout of each item implementation should + * be defined in [[itemlayout]] + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ListViewItemTag + */ + protected layout(): TagLayoutType[]; + /** + * Setter: + * + * Set the data of the list item. This will + * trigger the [[ondatachange]] function + * + * Getter: + * + * Get the data of the current list item + * + * @memberof ListViewItemTag + */ + set data(v: GenericObject); + get data(): GenericObject; + /** + * Any subclass of this class should implement this + * function to provide its custom item layout + * + * @protected + * @abstract + * @returns {TagLayoutType} + * @memberof ListViewItemTag + */ + protected abstract itemlayout(): TagLayoutType; + /** + * This function is called when the item data is changed. + * It should be implemented in all subclass of this class + * + * @protected + * @abstract + * @memberof ListViewItemTag + */ + protected abstract ondatachange(): void; + } + /** + * The layout of a simple list item contains only a + * AFX label + * + * @export + * @class SimpleListItemTag + * @extends {ListViewItemTag} + */ + class SimpleListItemTag extends ListViewItemTag { + /** + *Creates an instance of SimpleListItemTag. + * @memberof SimpleListItemTag + */ + constructor(); + /** + * Reset some property to default + * + * @protected + * @memberof SimpleListItemTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @memberof SimpleListItemTag + */ + protected calibrate(): void; + /** + * Refresh the inner label when the item data + * is changed + * + * @protected + * @returns {void} + * @memberof SimpleListItemTag + */ + protected ondatachange(): void; + /** + * Re-render the list item + * + * @protected + * @memberof SimpleListItemTag + */ + protected reload(): void; + /** + * List item custom layout definition + * + * @protected + * @returns {TagLayoutType} + * @memberof SimpleListItemTag + */ + protected itemlayout(): TagLayoutType; + } + /** + * This tag defines a traditional or a dropdown list widget. + * It contains a collection of list items in which layout + * of each item may be variable + * + * @export + * @class ListViewTag + * @extends {AFXTag} + */ + class ListViewTag extends AFXTag { + /** + * placeholder of list select event handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewTag + */ + private _onlistselect; + /** + * placeholder of list double click event handle + * + * @private + * @type {TagEventCallback} + * @memberof ListViewTag + */ + private _onlistdbclick; + /** + * placeholder of list drag and drop event handle + * + * @private + * @type {TagEventCallback>} + * @memberof ListViewTag + */ + private _ondragndrop; + /** + * placeholder of list item close event handle + * + * @private + * @memberof ListViewTag + */ + private _onitemclose; + /** + * placeholder of drag and drop mouse down event handle + * + * @private + * @memberof ListViewTag + */ + private _onmousedown; + /** + * placeholder of drag and drop mouse up event handle + * + * @private + * @memberof ListViewTag + */ + private _onmouseup; + /** + * placeholder of drag and drop mouse move event handle + * + * @private + * @memberof ListViewTag + */ + private _onmousemove; + /** + * Reference to the latest selected DOM item + * + * @private + * @type {ListViewItemTag} + * @memberof ListViewTag + */ + private _selectedItem; + /** + * A collection of selected items in the list. + * The maximum size of this collection is 1 if + * the [[multiselect]] feature is disabled + * + * @private + * @type {ListViewItemTag[]} + * @memberof ListViewTag + */ + private _selectedItems; + /** + * Data placeholder of the list + * + * @private + * @type {GenericObject[]} + * @memberof ListViewTag + */ + private _data; + /** + * Event data passing between mouse event when performing + * drag and drop on the list + * + * @private + * @type {{ from: ListViewItemTag[]; to: ListViewItemTag }} + * @memberof ListViewTag + */ + private _dnd; + /** + *Creates an instance of ListViewTag. + * @memberof ListViewTag + */ + constructor(); + /** + * Reset the tag's properties to the default values + * + * @protected + * @memberof ListViewTag + */ + protected init(): void; + /** + * This function does nothing + * + * @protected + * @param {*} [d] + * @memberof ListViewTag + */ + protected reload(d?: any): void; + /** + * Setter: toggle between dropdown and traditional list + * + * Getter: Check whether the list is dropdown or traditional list + * + * @memberof ListViewTag + */ + set dropdown(v: boolean); + /** + * Set drag and drop event handle + * + * @memberof ListViewTag + */ + set ondragndrop(v: TagEventCallback>); + /** + * Set list select event handle + * + * @memberof ListViewTag + */ + set onlistselect(v: TagEventCallback); + /** + * Set double click event handle + * + * @memberof ListViewTag + */ + set onlistdbclick(v: TagEventCallback); + /** + * Set item close event handle + * + * @memberof ListViewTag + */ + set onitemclose(v: (e: TagEventType) => boolean); + get dropdown(): boolean; + /** + * Setter: + * + * Set the default tag name of list's items. + * If the tag name is not specified in the + * data of a list item, this tag will be used + * + * Getter: + * + * Get the default tag name of list item + * + * @memberof ListViewTag + */ + set itemtag(v: string); + get itemtag(): string; + /** + * Setter: + * + * Turn on/off of the `multiselect` feature + * + * Getter: + * + * Check whether multi-select is allowed + * in this list + * + * @memberof ListViewTag + */ + set multiselect(v: boolean); + get multiselect(): boolean; + /** + * Setter: Enable/disable drag and drop event in the list + * + * Getter: Check whether the drag and drop event is enabled + * + * @memberof ListViewTag + */ + set dragndrop(v: boolean); + get dragndrop(): boolean; + /** + * Set the buttons layout of the list. + * Button layout allows to add some custom + * behaviors to the list. + * + * Each button data should define the [[onbtclick]] + * event handle to specify the custom behavior + * + * When the list is configured as dropdown. The buttons + * layout will be disabled + * + * Example of a button data: + * + * ``` + * { + * text: "Button text", + * icon: "home://path/to/icon.png", + * iconclass: "icon-class-name", + * onbtclick: (e) => console.log(e) + * } + * ``` + * + * @memberof ListViewTag + */ + set buttons(v: GenericObject[]); + /** + * Getter: Get data of the list + * + * Setter: Set data to the list + * + * @type {GenericObject[]} + * @memberof ListViewTag + */ + get data(): GenericObject[]; + set data(data: GenericObject[]); + /** + * Do nothing + * + * @protected + * @memberof ListViewTag + */ + protected ondatachange(): void; + /** + * Setter: Select list item(s) by their indexes + * + * Getter: Get the indexes of all selected items + * + * @memberof ListViewTag + */ + set selected(idx: number | number[]); + /** + * Get the latest selected item + * + * @readonly + * @type {ListViewItemTag} + * @memberof ListViewTag + */ + get selectedItem(): ListViewItemTag; + /** + * Get all the selected items + * + * @readonly + * @type {ListViewItemTag[]} + * @memberof ListViewTag + */ + get selectedItems(): ListViewItemTag[]; + get selected(): number | number[]; + /** + * Add an item to the beginning of the list + * + * @param {GenericObject} item + * @returns {ListViewItemTag} the added list item element + * @memberof ListViewTag + */ + unshift(item: GenericObject): ListViewItemTag; + /** + * check whether the list has data + * + * @private + * @param {GenericObject} v + * @returns + * @memberof ListViewTag + */ + private has_data; + /** + * Add an item to the beginning or end of the list + * + * @param {GenericObject} item list item data + * @param {boolean} [flag] indicates whether to add the item in the beginning of the list + * @returns {ListViewItemTag} the added list item element + * @memberof ListViewTag + */ + push(item: GenericObject, flag?: boolean): ListViewItemTag; + /** + * Delete an item + * + * @param {ListViewItemTag} item item DOM element + * @memberof ListViewTag + */ + delete(item: ListViewItemTag): void; + /** + * Select item next to the currently selected item. + * If there is no item selected, the first item will + * be selected + * + * @returns {void} + * @memberof ListViewTag + */ + selectNext(): void; + /** + * Select the previous item in the list. + * + * @returns {void} + * @memberof ListViewTag + */ + selectPrev(): void; + /** + * Unselect all the selected items in the list + * + * @returns {void} + * @memberof ListViewTag + */ + unselect(): void; + /** + * This function triggers the click event on an item + * + * @private + * @param {TagEventType} e tag event object + * @param {boolean} flag indicates whether this is a double click event + * @returns {void} + * @memberof ListViewTag + */ + private iclick; + /** + * This function triggers the double click event on an item + * + * @private + * @param {TagEventType} e tag event object + * @returns + * @memberof ListViewTag + */ + private idbclick; + /** + * This function triggers the list item select event + * + * @private + * @param {TagEventType} e tag event object + * @returns + * @memberof ListViewTag + */ + private iselect; + /** + * Mount the tag and bind some basic event + * + * @protected + * @returns {void} + * @memberof ListViewTag + */ + protected mount(): void; + /** + * This function triggers the item close event + * + * @private + * @param {TagEventType} e tag event object + * @returns {void} + * @memberof ListViewTag + */ + private iclose; + /** + * Show the dropdown list. + * This function is called only when the list is a dropdown + * list + * + * @protected + * @param {*} e + * @returns {void} + * @memberof ListViewTag + */ + protected showlist(e: any): void; + /** + * Hide the dropdown list. + * This function is called only when the list is a dropdown + * list + * + * @protected + * @param {*} e + * @memberof ListViewTag + */ + protected dropoff(e: any): void; + /** + * calibrate the list layout + * + * @protected + * @returns {void} + * @memberof ListViewTag + */ + protected calibrate(): void; + /** + * List view layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ListViewTag + */ + protected layout(): TagLayoutType[]; } } } @@ -5197,184 +4609,273 @@ declare namespace OS { namespace GUI { namespace tag { /** - * This class defines basic AFX label tag. - * A label contains a text and an icon (optional) + * Tag event data type definition + */ + type TabEventData = TagEventDataType; + /** + * a TabBar allows to control a collection of tabs * * @export - * @class LabelTag + * @class TabBarTag * @extends {AFXTag} */ - class LabelTag extends AFXTag { + export class TabBarTag extends AFXTag { /** - * placeholder of the text to be displayed + * Placeholder of currently selected tab index * * @private - * @type {(string | FormattedString)} - * @memberof LabelTag + * @type {number} + * @memberof TabBarTag */ - private _text; + private _selected; /** - *Creates an instance of LabelTag. - * @memberof LabelTag + * Placeholder of tab close event handle + * + * @private + * @memberof TabBarTag + */ + private _ontabclose; + /** + * Placeholder of tab select event handle + * + * @private + * @type {TagEventCallback} + * @memberof TabBarTag + */ + private _ontabselect; + /** + *Creates an instance of TabBarTag. + * @memberof TabBarTag */ constructor(); /** - * this implementation does nothing in this tag + * Init the tag * * @protected - * @memberof LabelTag - */ - protected mount(): void; - /** - * Refresh the text in the label - * - * @protected - * @param {*} d - * @memberof LabelTag - */ - protected reload(d: any): void; - /** - * Reset to default some property value - * - * @protected - * @memberof LabelTag + * @memberof TabBarTag */ protected init(): void; - /** - * This implementation of the function does nothing - * - * @protected - * @memberof LabelTag - */ - protected calibrate(): void; - /** - * Set the VFS path of the label icon - * - * @memberof LabelTag - */ - set icon(v: string); - /** - * Set the CSS class of the label icon - * - * @memberof LabelTag - */ - set iconclass(v: string); - /** - * Setter: Set the text of the label - * - * Getter: Get the text displayed on the label - * - * @memberof LabelTag - */ - set text(v: string | FormattedString); - get text(): string | FormattedString; - /** - * Lqbel layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof LabelTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A switch tag is basically used to visualize an boolean data value. - * - * @export - * @class SwitchTag - * @extends {AFXTag} - */ - class SwitchTag extends AFXTag { - /** - * Placeholder for the onchange event handle - * - * @private - * @type {TagEventCallback} - * @memberof SwitchTag - */ - private _onchange; - /** - * Setter: Turn on/off the switch - * - * Getter: Check whether the switch is turned on - * - * @memberof SwitchTag - */ - set swon(v: boolean); - get swon(): boolean; - /** - * Setter: Enable the switch - * - * Getter: Check whether the switch is enabled - * - * @memberof SwitchTag - */ - set enable(v: boolean); - get enable(): boolean; - /** - * Set the onchange event handle - * - * @memberof SwitchTag - */ - set onswchange(v: TagEventCallback); - /** - * Mount the tag and bind the click event to the switch - * - * @protected - * @memberof SwitchTag - */ - protected mount(): void; - /** - * This function will turn the switch (on/off) - * and trigger the onchange event - * - * @private - * @param {JQuery.ClickEvent} e - * @returns - * @memberof SwitchTag - */ - private makechange; - /** - * Tag layout definition - * - * @protected - * @returns - * @memberof SwitchTag - */ - protected layout(): { - el: string; - ref: string; - }[]; - /** - * Init the tag: - * - switch is turn off - * - switch is enabled - * - * @protected - * @memberof SwitchTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @memberof SwitchTag - */ - protected calibrate(): void; /** * Do nothing * * @protected * @param {*} [d] - * @memberof SwitchTag + * @memberof TabBarTag */ protected reload(d?: any): void; + /** + * Setter: Enable/disable a tab to be closed + * + * Getter: Check whether tabs can be closed + * + * @memberof TabBarTag + */ + set closable(v: boolean); + get closable(): boolean; + /** + * Add a tab in the end of the tab bar + * + * @param {GenericObject} item tab data + * @memberof TabBarTag + */ + push(item: GenericObject): ListViewItemTag; + /** + * Delete a tab + * + * @param {ListViewItemTag} el reference to DOM element of a tab + * @memberof TabBarTag + */ + delete(el: ListViewItemTag): void; + /** + * Add a tab to the beginning of the tab bar + * + * @param {GenericObject} item tab data + * @memberof TabBarTag + */ + unshift(item: GenericObject): ListViewItemTag; + /** + * Setter: Set tabs data + * + * Getter: Get all tabs data + * + * @memberof TabBarTag + */ + set items(v: GenericObject[]); + get items(): GenericObject[]; + /** + * Setter: Select a tab by its index + * + * Getter: Get the currently selected tab + * + * @memberof TabBarTag + */ + set selected(v: number | number[]); + get selected(): number | number[]; + /** + * Set the tab close event handle + * + * @memberof TabBarTag + */ + set ontabclose(v: (e: TagEventType) => boolean); + /** + * Set the tab select event handle + * + * @memberof TabBarTag + */ + set ontabselect(v: TagEventCallback); + /** + * Mount the tab bar and bind some basic events + * + * @protected + * @memberof TabBarTag + */ + protected mount(): void; + /** + * TabBar layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof TabBarTag + */ + protected layout(): TagLayoutType[]; + } + export {}; + } + } +} +declare namespace OS { + namespace GUI { + /** + * Color type used by AFX API + * + * @export + * @interface ColorType + */ + interface ColorType { + /** + * Red chanel + * + * @type {number} + * @memberof ColorType + */ + r: number; + /** + * Green chanel + * + * @type {number} + * @memberof ColorType + */ + g: number; + /** + * Blue chanel + * + * @type {number} + * @memberof ColorType + */ + b: number; + /** + * Alpha chanel + * + * @type {number} + * @memberof ColorType + */ + a?: number; + /** + * color text in CSS format + * + * @type {string} + * @memberof ColorType + */ + text?: string; + /** + * Color in hex format + * + * @type {string} + * @memberof ColorType + */ + hex?: string; + } + namespace tag { + /** + * Class definition of Color picker widget + * + * @export + * @class ColorPickerTag + * @extends {AFXTag} + */ + class ColorPickerTag extends AFXTag { + /** + * The current selected color object + * + * @private + * @type {ColorType} + * @memberof ColorPickerTag + */ + private _selectedColor; + /** + * placeholder for the color select event callback + * + * @private + * @type {TagEventCallback} + * @memberof ColorPickerTag + */ + private _oncolorselect; + /** + * Creates an instance of ColorPickerTag. + * @memberof ColorPickerTag + */ + constructor(); + /** + * Init tag before mounting, do nothing + * + * @protected + * @memberof ColorPickerTag + */ + protected init(): void; + /** + * Reload tag, do nothing + * + * @protected + * @param {*} [d] + * @memberof ColorPickerTag + */ + protected reload(d?: any): void; + /** + * Get selected color value + * + * @readonly + * @type {ColorType} + * @memberof ColorPickerTag + */ + get selectedColor(): ColorType; + /** + * Set the color select event handle + * + * @memberof ColorPickerTag + */ + set oncolorselect(v: TagEventCallback); + /** + * Mount the widget to DOM tree + * + * @protected + * @memberof ColorPickerTag + */ + protected mount(): void; + /** + * Build the color palette + * + * @private + * @memberof ColorPickerTag + */ + private build_palette; + /** + * layout definition of the widget + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ColorPickerTag + */ + protected layout(): TagLayoutType[]; } } } @@ -5543,81 +5044,1354 @@ declare namespace OS { namespace GUI { namespace tag { /** - * Meta tag that represents the virtual desktop environment. - * In near future, we may have multiple virtual desktop environments. - * Each desktop environment has a simple file manager and a window - * manager that render the window in a specific order. + * This class defines basic AFX label tag. + * A label contains a text and an icon (optional) * * @export - * @class DesktopTag - * @extends {FloatListTag} + * @class LabelTag + * @extends {AFXTag} */ - class DesktopTag extends FloatListTag { + class LabelTag extends AFXTag { /** - * internal handle to the desktop file location + * placeholder of the text to be displayed * * @private - * @type {API.VFS.BaseFileHandle} - * @memberof DesktopTag + * @type {(string | FormattedString)} + * @memberof LabelTag */ - private file; + private _text; /** - * local observer that detect if a new child element is - * added or removed - * - * @private - * @type {MutationObserver} - * @memberof DesktopTag - */ - private observer; - /** - * Internal list of the current opened window - * - * @private - * @type {Set} - * @memberof DesktopTag - */ - private window_list; - /** - * Creates an instance of DesktopTag. - * @memberof DesktopTag + *Creates an instance of LabelTag. + * @memberof LabelTag */ constructor(); /** - * Mount the virtual desktop to the DOM tree + * this implementation does nothing in this tag * * @protected - * @memberof DesktopTag + * @memberof LabelTag */ protected mount(): void; /** - * Display all files and folders in the specific desktop location + * Refresh the text in the label * - * @return {*} {Promise} - * @memberof DesktopTag + * @protected + * @param {*} d + * @memberof LabelTag */ - refresh(): Promise; + protected reload(d: any): void; /** - * Remove this element from its parent + * Reset to default some property value * - * @memberof DesktopTag + * @protected + * @memberof LabelTag */ - remove(): void; + protected init(): void; /** - * Active a window above all other windows + * This implementation of the function does nothing + * + * @protected + * @memberof LabelTag + */ + protected calibrate(): void; + /** + * Set the VFS path of the label icon + * + * @memberof LabelTag + */ + set icon(v: string); + /** + * Set the CSS class of the label icon + * + * @memberof LabelTag + */ + set iconclass(v: string); + /** + * Setter: Set the text of the label + * + * Getter: Get the text displayed on the label + * + * @memberof LabelTag + */ + set text(v: string | FormattedString); + get text(): string | FormattedString; + /** + * Setter: Turn on/off text selection + * + * Getter: Check whether the label is selectable + * + * @memberof LabelTag + */ + set selectable(v: boolean); + get swon(): boolean; + /** + * Lqbel layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof LabelTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +declare namespace OS { + namespace GUI { + /** + * Tab container data type definition + * + * @export + * @interface TabContainerTabType + */ + interface TabContainerTabType { + /** + * Reference to the DOM element of the current container + * + * @type {HTMLElement} + * @memberof TabContainerTabType + */ + container: HTMLElement; + [propName: string]: any; + } + namespace tag { + /** + * A tab container allows to attach each tab on a [[TabBarTag]] + * with a container widget. The attached container widget should be + * composed inside a [[HBoxTag]] + * + * The tab bar in a tab container can be configured to display tabs + * in horizontal (row) or vertical (column) order. Default to vertical order + * + * Once a tab is selected, its attached container will be shown + * + * @export + * @class TabContainerTag + * @extends {AFXTag} + */ + class TabContainerTag extends AFXTag { + /** + * Reference to the currently selected tab DOM element * * @private - * @param {WindowTag} win - * @memberof DesktopTag + * @type {TabContainerTabType} + * @memberof TabContainerTag */ - private selectWindow; + private _selectedTab; /** - * Render all windows in order from bottom to top + * Placeholder of the tab select event handle * * @private - * @memberof DesktopTag + * @type {TagEventCallback} + * @memberof TabContainerTag */ - private render; + private _ontabselect; + /** + *Creates an instance of TabContainerTag. + * @memberof TabContainerTag + */ + constructor(); + /** + * Init the tab bar direction to vertical (column) + * + * @protected + * @memberof TabContainerTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof TabContainerTag + */ + protected reload(d?: any): void; + /** + * Set the tab select event handle + * + * @memberof TabContainerTag + */ + set ontabselect(f: TagEventCallback); + /** + * Get all tab items in the container + * + * @readonly + * @type {TabContainerTabType[]} + * @memberof TabContainerTag + */ + get tabs(): TabContainerTabType[]; + /** + * Select a tab by its index + * + * @memberof TabContainerTag + */ + set selectedIndex(i: number); + /** + * Setter: + * + * Set the tab bar direction: + * - `row`: horizontal direction + * - `column`: vertical direction + * + * Getter: + * + * Get the tab bar direction + * + * @memberof TabContainerTag + */ + set dir(v: "row" | "column"); + get dir(): "row" | "column"; + /** + * Setter: + * + * Select a tab using the its tab data type. + * This will show the attached container to the tab + * + * Getter: + * + * Get the tab data of the currently selected Tab + * + * @memberof TabContainerTag + */ + set selectedTab(v: TabContainerTabType); + get selectedTab(): TabContainerTabType; + /** + * Set the tab bar width, this function only + * works when the tab bar direction is set to + * `row` + * + * @memberof TabContainerTag + */ + set tabbarwidth(v: number); + /** + * Set the tab bar height, this function only works + * when the tab bar direction is set to `column` + * + * @memberof TabContainerTag + */ + set tabbarheight(v: number); + /** + * Add a new tab with container to the container + * + * item should be in the following format: + * + * ```ts + * { + * text: string, + * icon?: string, + * iconclass?: string, + * container: HTMLElement + * } + * ``` + * + * @param {GenericObject} item tab descriptor + * @param {boolean} insert insert the tab content to the container ? + * @returns {ListViewItemTag} the tab DOM element + * @memberof TabContainerTag + */ + addTab(item: GenericObject, insert: boolean): ListViewItemTag; + /** + * Remove a tab from the container + * + * @param {ListViewItemTag} tab the tab item to be removed + * @memberof TabContainerTag + */ + removeTab(tab: ListViewItemTag): void; + /** + * Mount the tag and bind basic events + * + * @protected + * @memberof TabContainerTag + */ + protected mount(): void; + /** + * calibrate the tab container + * + * @memberof TabContainerTag + */ + calibrate(): void; + /** + * Layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof TabContainerTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +/** + * Extend the Array interface with some + * property needed by AFX API + * + * @interface Array + * @template T + */ +interface Array { + /** + * Reference to a DOM element created by AFX API, + * this property is used by some AFX tags to refer + * to its child element in it data object + * + * @type {GenericObject} + * @memberof Array + */ + domel?: GenericObject; +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * Row item event data type + */ + type GridRowEventData = TagEventDataType; + /** + * A grid Row is a simple element that + * contains a group of grid cell + * + * @export + * @class GridRowTag + * @extends {AFXTag} + */ + class GridRowTag extends AFXTag { + /** + * Data placeholder for a collection of cell data + * + * @type {GenericObject[]} + * @memberof GridRowTag + */ + data: GenericObject[]; + /** + * placeholder for the row select event callback + * + * @private + * @type {TagEventCallback} + * @memberof ListViewItemTag + */ + private _onselect; + /** + *Creates an instance of GridRowTag. + * @memberof GridRowTag + */ + constructor(); + /** + * Set item select event handle + * + * @memberof ListViewItemTag + */ + set onrowselect(v: TagEventCallback); + /** + * Setter: select/unselect the current item + * + * Getter: Check whether the current item is selected + * + * @memberof ListViewItemTag + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Mount the tag, do nothing + * + * @protected + * @memberof GridRowTag + */ + protected mount(): void; + /** + * Init the tag before mounting: reset the data placeholder + * + * @protected + * @memberof GridRowTag + */ + protected init(): void; + /** + * Empty layout + * + * @protected + * @returns {TagLayoutType[]} + * @memberof GridRowTag + */ + protected layout(): TagLayoutType[]; + /** + * This function does nothing in this tag + * + * @protected + * @memberof GridRowTag + */ + protected calibrate(): void; + /** + * This function does nothing in this tag + * + * @protected + * @param {*} [d] + * @memberof GridRowTag + */ + protected reload(d?: any): void; + } + /** + * Event data used by grid cell + */ + type CellEventData = TagEventDataType; + /** + * Prototype of any grid cell, custom grid cell + * definition should extend and implement this + * abstract prototype + * + * @export + * @abstract + * @class GridCellPrototype + * @extends {AFXTag} + */ + abstract class GridCellPrototype extends AFXTag { + /** + * placeholder for cell selected event callback + * + * @private + * @type {TagEventCallback} + * @memberof GridCellPrototype + */ + private _oncellselect; + /** + * placeholder for cell double click event callback + * + * @private + * @type {TagEventCallback} + * @memberof GridCellPrototype + */ + private _oncelldbclick; + /** + * Data placeholder of the current cell + * + * @private + * @type {GenericObject} + * @memberof GridCellPrototype + */ + private _data; + /** + *Creates an instance of GridCellPrototype. + * @memberof GridCellPrototype + */ + constructor(); + /** + * Set the cell selected event callback + * + * @memberof GridCellPrototype + */ + set oncellselect(v: TagEventCallback); + /** + * Set the cell double click event callback + * + * @memberof GridCellPrototype + */ + set oncelldbclick(v: TagEventCallback); + /** + * Setter: + * + * Set the data of the cell, this will trigger + * the [[ondatachange]] function + * + * Getter: + * + * Get the current cell data placeholder + * + * @memberof GridCellPrototype + */ + set data(v: GenericObject); + get data(): GenericObject; + /** + * Setter: + * + * Set/unset the current cell as selected. + * This will trigger the [[cellselect]] + * event + * + * Getter: + * + * Check whether the current cell is selected + * + * @memberof GridCellPrototype + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Update the current cell. This will + * reset the cell data + * + * @protected + * @param {*} d + * @memberof GridCellPrototype + */ + protected reload(d: any): void; + /** + * Mount the current cell to the grid + * + * @protected + * @memberof GridCellPrototype + */ + protected mount(): void; + /** + * This function triggers the cell select + * event + * + * @private + * @param {TagEventType} e + * @param {boolean} flag + * @returns {void} + * @memberof GridCellPrototype + */ + private cellselect; + /** + * Abstract function called when the cell data changed. + * This should be implemented by subclasses + * + * @protected + * @abstract + * @memberof GridCellPrototype + */ + protected abstract ondatachange(): void; + } + /** + * Simple grid cell defines a grid cell with + * an [[LabelTag]] as it cell layout + * + * @export + * @class SimpleGridCellTag + * @extends {GridCellPrototype} + */ + class SimpleGridCellTag extends GridCellPrototype { + /** + *Creates an instance of SimpleGridCellTag. + * @memberof SimpleGridCellTag + */ + constructor(); + /** + * Reset the label of the cell with its data + * + * @protected + * @memberof SimpleGridCellTag + */ + protected ondatachange(): void; + /** + * This function do nothing in this tag + * + * @protected + * @memberof SimpleGridCellTag + */ + protected init(): void; + /** + * This function do nothing in this tag + * + * @protected + * @memberof SimpleGridCellTag + */ + protected calibrate(): void; + /** + * The layout of the cell with a simple [[LabelTag]] + * + * @returns + * @memberof SimpleGridCellTag + */ + layout(): { + el: string; + ref: string; + }[]; + } + /** + * A Grid contains a header and a collection grid rows + * which has the same number of cells as the number of + * the header elements + * + * @export + * @class GridViewTag + * @extends {AFXTag} + */ + class GridViewTag extends AFXTag { + /** + * Grid header definition + * + * @private + * @type {GenericObject[]} + * @memberof GridViewTag + */ + private _header; + /** + * Grid rows data placeholder + * + * @private + * @type {GenericObject[][]} + * @memberof GridViewTag + */ + private _rows; + /** + * Reference to the current selected row DOM element + * + * @private + * @type {GridRowTag} + * @memberof GridViewTag + */ + private _selectedRow; + /** + * A collection of selected grid rows DOM element + * + * @private + * @type {GridRowTag[]} + * @memberof GridViewTag + */ + private _selectedRows; + /** + * Reference to the current selected cell + * + * @private + * @type {GridCellPrototype} + * @memberof GridViewTag + */ + private _selectedCell; + /** + * Cell select event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof GridViewTag + */ + private _oncellselect; + /** + * Row select event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof GridViewTag + */ + private _onrowselect; + /** + * Cell double click event callback placeholder + * + * @private + * @type {TagEventCallback} + * @memberof GridViewTag + */ + private _oncelldbclick; + /** + * Event data passing between mouse event when performing + * drag and drop on the list + * + * @private + * @type {{ from: GridRowTag[]; to: GridRowTag }} + * @memberof GridViewTag + */ + private _dnd; + /** + * placeholder of list drag and drop event handle + * + * @private + * @type {TagEventCallback>} + * @memberof GridViewTag + */ + private _ondragndrop; + /** + * Creates an instance of GridViewTag. + * @memberof GridViewTag + */ + constructor(); + /** + * Set drag and drop event handle + * + * @memberof GridViewTag + */ + set ondragndrop(v: TagEventCallback>); + /** + * Setter: Enable/disable drag and drop event in the list + * + * Getter: Check whether the drag and drop event is enabled + * + * @memberof GridViewTag + */ + set dragndrop(v: boolean); + get dragndrop(): boolean; + /** + * placeholder of drag and drop mouse down event handle + * + * @private + * @memberof GridViewTag + */ + private _onmousedown; + /** + * placeholder of drag and drop mouse up event handle + * + * @private + * @memberof GridViewTag + */ + private _onmouseup; + /** + * placeholder of drag and drop mouse move event handle + * + * @private + * @memberof GridViewTag + */ + private _onmousemove; + /** + * Init the grid view before mounting. + * Reset all the placeholders to default values + * + * @protected + * @memberof GridViewTag + */ + protected init(): void; + /** + * This function does nothing + * + * @protected + * @param {*} [d] + * @memberof GridViewTag + */ + protected reload(d?: any): void; + /** + * set the cell select event callback + * + * @memberof GridViewTag + */ + set oncellselect(v: TagEventCallback); + /** + * set the row select event callback + * + * @memberof GridViewTag + */ + set onrowselect(v: TagEventCallback); + /** + * set the cell double click event callback + * + * @memberof GridViewTag + */ + set oncelldbclick(v: TagEventCallback); + /** + * Setter: set the tag name of the header cells + * + * Getter: get the grid header tag name + * + * @memberof GridViewTag + */ + set headeritem(v: string); + get headeritem(): string; + /** + * Setter: set the tag name of the grid cell + * + * Getter: get the tag name of the grid cell + * + * @memberof GridViewTag + */ + set cellitem(v: string); + get cellitem(): string; + /** + * Setter: set the header data + * + * Getter: get the header data placeholder + * + * @type {GenericObject[]} + * @memberof GridViewTag + */ + get header(): GenericObject[]; + set header(v: GenericObject[]); + /** + * Get all the selected rows + * + * @readonly + * @type {GridRowTag[]} + * @memberof GridViewTag + */ + get selectedRows(): GridRowTag[]; + /** + * Get the latest selected row + * + * @readonly + * @type {GridRowTag} + * @memberof GridViewTag + */ + get selectedRow(): GridRowTag; + /** + * Get the current selected cell + * + * @readonly + * @type {GridCellPrototype} + * @memberof GridViewTag + */ + get selectedCell(): GridCellPrototype; + /** + * Setter: set the rows data + * + * Getter: get the rows data + * + * @memberof GridViewTag + */ + set rows(rows: GenericObject[][]); + get rows(): GenericObject[][]; + /** + * Setter: activate deactivate multi-select + * + * Getter: check whether the `multiselect` option is activated + * + * @memberof GridViewTag + */ + set multiselect(v: boolean); + get multiselect(): boolean; + /** + * Set and Get the resizable attribute + * + * This allows to enable/disable column resize feature + * + * @memberof GridViewTag + */ + set resizable(v: boolean); + get resizable(): boolean; + /** + * Sort the grid using a sort function + * + * @param {context: any} context of the executed function + * @param {(a:GenericObject[], b:GenericObject[]) => boolean} a sort function that compares two rows data + * * @param {index: number} current header index + * @returns {void} + * @memberof GridViewTag + */ + sort(context: any, fn: (a: GenericObject[], b: GenericObject[], index?: number) => number): void; + /** + * Delete a grid rows + * + * @param {GridRowTag} row row DOM element + * @returns {void} + * @memberof GridViewTag + */ + delete(row: GridRowTag): void; + /** + * Push a row to the grid + * + * @param {GenericObject[]} row list of cell data + * @param {boolean} flag indicates where the row is add to beginning or end + * of the row + * @memberof GridViewTags + */ + push(row: GenericObject[], flag: boolean): void; + /** + * Unshift a row to the grid + * + * @param {GenericObject[]} row list of cell data in the row + * @memberof GridViewTag + */ + unshift(row: GenericObject[]): void; + /** + * This function triggers the cell select event + * + * @private + * @param {TagEventType} e event contains cell event data + * @param {boolean} flag indicates whether the event is double clicked + * @returns {void} + * @memberof GridViewTag + */ + private cellselect; + /** + * This function triggers the row select event, a cell select + * event will also trigger this event + * + * @param {TagEventType} e + * @returns {void} + * @memberof GridViewTag + */ + private rowselect; + /** + * Unselect all the selected rows in the grid + * + * @returns {void} + * @memberof GridViewTag + */ + unselect(): void; + /** + * Check whether the grid has header + * + * @private + * @returns {boolean} + * @memberof GridViewTag + */ + private has_header; + /** + * Calibrate the grid + * + * @protected + * @memberof GridViewTag + */ + protected calibrate(): void; + /** + * Recalculate the size of each header cell, changing + * in header cell size will also resize the entire + * related column + * + * @private + * @returns {void} + * @memberof GridViewTag + */ + private calibrate_header; + /** + * Mount the grid view tag + * + * @protected + * @returns {void} + * @memberof GridViewTag + */ + protected mount(): void; + /** + * Layout definition of the grid view + * + * @protected + * @returns {TagLayoutType[]} + * @memberof GridViewTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * A system panel contains the following elements: + * - Spotlight to access to applications menu + * - Current focused application menu + * - System tray for all running services running in background + * + * @export + * @class SystemPanelTag + * @extends {AFXTag} + */ + class SystemPanelTag extends AFXTag { + /** + * Reference to spotlight data + * + * @private + * @type {(GenericObject)} + * @memberof SystemPanelTag + */ + private _osmenu; + /** + * Placeholder indicates whether the spotlight is currently shown + * + * @private + * @type {boolean} + * @memberof SystemPanelTag + */ + private _view; + /** + * Store pending loading task + * + * @private + * @type {number[]} + * @memberof SystemPanelTag + */ + private _pending_task; + /** + * Loading animation check timeout + * + * @memberof SystemPanelTag + */ + private _loading_toh; + /** + * Place holder for a private callback function + * + * @private + * @memberof SystemPanelTag + */ + private _cb; + /** + * Place holder for system app list + * + * @private + * @type {GenericObject[]} + * @memberof SystemPanelTag + */ + private app_list; + /** + *Creates an instance of SystemPanelTag. + * @memberof SystemPanelTag + */ + constructor(); + /** + * Do nothing + * + * @protected + * @memberof SystemPanelTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof SystemPanelTag + */ + protected reload(d?: any): void; + /** + * Attach a service to the system tray on the pannel, + * this operation is performed when a service is started + * + * @param {BaseService} s + * @returns + * @memberof SystemPanelTag + */ + attachservice(s: application.BaseService): void; + /** + * Launch the selected application from the spotlight + * applications list + * + * @private + * @returns {void} + * @memberof SystemPanelTag + */ + private open; + /** + * Perform spotlight search operation on keyboard event + * + * @private + * @param {JQuery.KeyboardEventBase} e + * @returns {void} + * @memberof SystemPanelTag + */ + private search; + /** + * detach a service from the system tray of the panel. + * This function is called when the corresponding running + * service is killed + * + * @param {BaseService} s + * @memberof SystemPanelTag + */ + detachservice(s: application.BaseService): void; + /** + * Layout definition of the panel + * + * @protected + * @returns {TagLayoutType[]} + * @memberof SystemPanelTag + */ + protected layout(): TagLayoutType[]; + /** + * Refresh applications list on the spotlight widget + * from system packages meta-data + * + * @private + * @memberof SystemPanelTag + */ + private refreshAppList; + /** + * Show/hide the spotlight + * + * @private + * @param {boolean} flag + * @memberof SystemPanelTag + */ + private toggle; + /** + * Calibrate the spotlight widget + * + * @memberof SystemPanelTag + */ + calibrate(): void; + /** + * Refresh the pinned applications menu + * + * @private + * @memberof SystemPanelTag + */ + private RefreshPinnedApp; + /** + * Check if the loading tasks ended, + * if it the case, stop the animation + * + * @private + * @memberof SystemPanelTag + */ + private animation_check; + /** + * Mount the tag bind some basic event + * + * @protected + * @memberof SystemPanelTag + */ + protected mount(): void; + } + } + } +} +/// +declare namespace OS { + namespace GUI { + namespace tag { + /** + * This tag define a basic button and its behavior + * + * @export + * @class ButtonTag + * @extends {AFXTag} + */ + class ButtonTag extends AFXTag { + /** + * Variable hold the button click callback handle + * + * @private + * @type {TagEventCallback} + * @memberof ButtonTag + */ + private _onbtclick; + /** + * Custom user data + * + * @type {GenericObject} + * @memberof ButtonTag + */ + data: GenericObject; + /** + *Creates an instance of ButtonTag. + * @memberof ButtonTag + */ + constructor(); + /** + * Set the click callback handle for the target button + * + * @memberof ButtonTag + */ + set onbtclick(v: TagEventCallback); + /** + * Set the path to the button icon, the path should be + * a VFS file path + * + * @memberof ButtonTag + */ + set icon(v: string); + /** + * Set the icon class to the button, this property + * allows to style the button icon using CSS + * + * @memberof ButtonTag + */ + set iconclass(v: string); + /** + * Setter: Set the text of the button + * + * Getter: Get the current button test + * + * @memberof ButtonTag + */ + set text(v: string | FormattedString); + get text(): string | FormattedString; + /** + * Setter: Enable or disable the button + * + * Getter: Get the `enable` property of the button + * + * @memberof ButtonTag + */ + set enable(v: boolean); + get enable(): boolean; + /** + * Setter: set or remove the attribute `selected` of the button + * + * Getter: check whether the attribute `selected` of the button is set + * + * @memberof ButtonTag + */ + set selected(v: boolean); + get selected(): boolean; + /** + * Setter: activate or deactivate the toggle mode of the button + * + * Getter: Check whether the button is in toggle mode + * + * @memberof ButtonTag + */ + set toggle(v: boolean); + get toggle(): boolean; + /** + * Mount the tag + * + * @protected + * @memberof ButtonTag + */ + protected mount(): void; + /** + * Init the tag before mounting + * + * @protected + * @memberof ButtonTag + */ + protected init(): void; + /** + * Re-calibrate the button, do nothing in this tag + * + * @protected + * @memberof ButtonTag + */ + protected calibrate(): void; + /** + * Update the current tag, do nothing in this tag + * + * @param {*} [d] + * @memberof ButtonTag + */ + reload(d?: any): void; + /** + * Button layout definition + * + * @protected + * @returns {TagLayoutType[]} + * @memberof ButtonTag + */ + protected layout(): TagLayoutType[]; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * A tile layout organize it child elements + * in a fixed horizontal or vertical direction. + * + * The size of each child element is attributed based + * on its configuration of automatically based on the + * remaining space in the layout + * + * + * @export + * @class TileLayoutTag + * @extends {AFXTag} + */ + class TileLayoutTag extends AFXTag { + /** + *C reates an instance of TileLayoutTag. + * @memberof TileLayoutTag + */ + constructor(); + /** + * Do nothing + * + * @protected + * @memberof TileLayoutTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof TileLayoutTag + */ + protected reload(d?: any): void; + /** + * Setter: Set the name of the tile container, should be: `hbox` or `vbox` + * + * Getter: Get the name of the tile container + * + * @memberof TileLayoutTag + */ + set name(v: string); + get name(): string; + /** + * Setter: + * + * SET the layout direction, should be: + * - `row`: horizontal direction + * - `column`: vertical direction + * + * Getter: + * + * Get layout direction + * + * @memberof TileLayoutTag + */ + set dir(v: "row" | "column"); + get dir(): "row" | "column"; + /** + * Mount the element + * + * @protected + * @returns {void} + * @memberof TileLayoutTag + */ + protected mount(): void; + /** + * re-organize the layout + * + * @returns {void} + * @memberof TileLayoutTag + */ + calibrate(): void; + /** + * Organize the layout in horizontal direction, only work when + * the layout direction set to horizontal + * + * @private + * @returns {void} + * @memberof TileLayoutTag + */ + private hcalibrate; + /** + * Organize the layout in vertical direction, only work when + * the layout direction set to vertical + * + * @private + * @returns {void} + * @memberof TileLayoutTag + */ + private vcalibrate; + /** + * Layout definition + * + * @returns + * @memberof TileLayoutTag + */ + layout(): { + el: string; + ref: string; + }[]; + } + /** + * A HBox organize its child elements in horizontal direction + * + * @export + * @class HBoxTag + * @extends {TileLayoutTag} + */ + class HBoxTag extends TileLayoutTag { + /** + * Creates an instance of HBoxTag. + * @memberof HBoxTag + */ + constructor(); + /** + * Mount the tag + * + * @protected + * @memberof HBoxTag + */ + protected mount(): void; + } + /** + * A VBox organize its child elements in vertical direction + * + * @export + * @class VBoxTag + * @extends {TileLayoutTag} + */ + class VBoxTag extends TileLayoutTag { + /** + *Creates an instance of VBoxTag. + * @memberof VBoxTag + */ + constructor(); + /** + * Mount the tag + * + * @protected + * @memberof VBoxTag + */ + protected mount(): void; } } } @@ -5975,7 +6749,7 @@ declare namespace OS { * Private data object passing between dragndrop mouse event * * @private - * @type {{ from: TreeViewTag; to: TreeViewTag }} + * @type {{ from: TreeViewTag[]; to: TreeViewTag }} * @memberof TreeViewTag */ private _dnd; @@ -6022,7 +6796,7 @@ declare namespace OS { * current tree. This function should return a promise on * a list of [[TreeViewDataType]] * - * @memberof TreeViewItemPrototype + * @memberof TreeViewTag */ fetch: (d: TreeViewItemPrototype) => Promise; /** @@ -6175,247 +6949,6 @@ declare namespace OS { } } } -declare namespace OS { - namespace GUI { - namespace tag { - /** - * An overlay tag is a layout tag that alway stay on top of - * the virtual desktop environment. Tile layout elements ([[VBoxTag]], [[HboxTag]]) - * can be used inside this tag to compose elements - * - * @export - * @class OverlayTag - * @extends {AFXTag} - */ - class OverlayTag extends AFXTag { - /** - * Tag width placeholder - * - * @private - * @type {string} - * @memberof OverlayTag - */ - private _width; - /** - * Tag height place holder - * - * @private - * @type {string} - * @memberof OverlayTag - */ - private _height; - /** - *Creates an instance of OverlayTag. - * @memberof OverlayTag - */ - constructor(); - /** - * Put the tag on top of the virtual desktop environment - * - * @protected - * @memberof OverlayTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @param {*} [d] - * @memberof OverlayTag - */ - protected reload(d?: any): void; - /** - * Setter: - * - * Set the width of the tag, the tag width should be in form of: - * `100px` of `80%` - * - * Getter: - * - * Get the tag width - * - * @memberof OverlayTag - */ - set width(v: string); - get width(): string; - /** - * Setter: - * - * Set the tag height, the tag height should be in form of: - * `100px` of `80%` - * - * Getter: - * - * Get the tag height - * - * @memberof OverlayTag - */ - set height(v: string); - get height(): string; - /** - * Calibrate the element when mounting - * - * @protected - * @returns {void} - * @memberof OverlayTag - */ - protected mount(): void; - /** - * Calibrate the width and height of the tag - * - * @returns {void} - * @memberof OverlayTag - */ - calibrate(): void; - /** - * Layout definition of the tag - * - * @protected - * @returns {TagLayoutType[]} - * @memberof OverlayTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - /** - * Color type used by AFX API - * - * @export - * @interface ColorType - */ - interface ColorType { - /** - * Red chanel - * - * @type {number} - * @memberof ColorType - */ - r: number; - /** - * Green chanel - * - * @type {number} - * @memberof ColorType - */ - g: number; - /** - * Blue chanel - * - * @type {number} - * @memberof ColorType - */ - b: number; - /** - * Alpha chanel - * - * @type {number} - * @memberof ColorType - */ - a?: number; - /** - * color text in CSS format - * - * @type {string} - * @memberof ColorType - */ - text?: string; - /** - * Color in hex format - * - * @type {string} - * @memberof ColorType - */ - hex?: string; - } - namespace tag { - /** - * Class definition of Color picker widget - * - * @export - * @class ColorPickerTag - * @extends {AFXTag} - */ - class ColorPickerTag extends AFXTag { - /** - * The current selected color object - * - * @private - * @type {ColorType} - * @memberof ColorPickerTag - */ - private _selectedColor; - /** - * placeholder for the color select event callback - * - * @private - * @type {TagEventCallback} - * @memberof ColorPickerTag - */ - private _oncolorselect; - /** - * Creates an instance of ColorPickerTag. - * @memberof ColorPickerTag - */ - constructor(); - /** - * Init tag before mounting, do nothing - * - * @protected - * @memberof ColorPickerTag - */ - protected init(): void; - /** - * Reload tag, do nothing - * - * @protected - * @param {*} [d] - * @memberof ColorPickerTag - */ - protected reload(d?: any): void; - /** - * Get selected color value - * - * @readonly - * @type {ColorType} - * @memberof ColorPickerTag - */ - get selectedColor(): ColorType; - /** - * Set the color select event handle - * - * @memberof ColorPickerTag - */ - set oncolorselect(v: TagEventCallback); - /** - * Mount the widget to DOM tree - * - * @protected - * @memberof ColorPickerTag - */ - protected mount(): void; - /** - * Build the color palette - * - * @private - * @memberof ColorPickerTag - */ - private build_palette; - /** - * layout definition of the widget - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ColorPickerTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} /// declare namespace OS { namespace GUI { @@ -6917,804 +7450,6 @@ declare namespace OS { } } } -declare namespace OS { - namespace GUI { - namespace tag { - /** - * Tag event data type definition - */ - type TabEventData = TagEventDataType; - /** - * a TabBar allows to control a collection of tabs - * - * @export - * @class TabBarTag - * @extends {AFXTag} - */ - export class TabBarTag extends AFXTag { - /** - * Placeholder of currently selected tab index - * - * @private - * @type {number} - * @memberof TabBarTag - */ - private _selected; - /** - * Placeholder of tab close event handle - * - * @private - * @memberof TabBarTag - */ - private _ontabclose; - /** - * Placeholder of tab select event handle - * - * @private - * @type {TagEventCallback} - * @memberof TabBarTag - */ - private _ontabselect; - /** - *Creates an instance of TabBarTag. - * @memberof TabBarTag - */ - constructor(); - /** - * Init the tag - * - * @protected - * @memberof TabBarTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @param {*} [d] - * @memberof TabBarTag - */ - protected reload(d?: any): void; - /** - * Setter: Enable/disable a tab to be closed - * - * Getter: Check whether tabs can be closed - * - * @memberof TabBarTag - */ - set closable(v: boolean); - get closable(): boolean; - /** - * Add a tab in the end of the tab bar - * - * @param {GenericObject} item tab data - * @memberof TabBarTag - */ - push(item: GenericObject): ListViewItemTag; - /** - * Delete a tab - * - * @param {ListViewItemTag} el reference to DOM element of a tab - * @memberof TabBarTag - */ - delete(el: ListViewItemTag): void; - /** - * Add a tab to the beginning of the tab bar - * - * @param {GenericObject} item tab data - * @memberof TabBarTag - */ - unshift(item: GenericObject): ListViewItemTag; - /** - * Setter: Set tabs data - * - * Getter: Get all tabs data - * - * @memberof TabBarTag - */ - set items(v: GenericObject[]); - get items(): GenericObject[]; - /** - * Setter: Select a tab by its index - * - * Getter: Get the currently selected tab - * - * @memberof TabBarTag - */ - set selected(v: number | number[]); - get selected(): number | number[]; - /** - * Set the tab close event handle - * - * @memberof TabBarTag - */ - set ontabclose(v: (e: TagEventType) => boolean); - /** - * Set the tab select event handle - * - * @memberof TabBarTag - */ - set ontabselect(v: TagEventCallback); - /** - * Mount the tab bar and bind some basic events - * - * @protected - * @memberof TabBarTag - */ - protected mount(): void; - /** - * TabBar layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof TabBarTag - */ - protected layout(): TagLayoutType[]; - } - export {}; - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A float list is a list of items in which each - * item can be moved (drag and drop) freely - * - * @export - * @class FloatListTag - * @extends {ListViewTag} - */ - class FloatListTag extends ListViewTag { - /** - * Update the current tag, do nothing - * - * @protected - * @param {*} [d] - * @memberof FloatListTag - */ - protected reload(d?: any): void; - /** - * Variable that hold the onready callback of - * the tag. This callback will be called after - * the tag is mounted - * - * @private - * @memberof FloatListTag - */ - private _onready; - /** - *Creates an instance of FloatListTag. - * @memberof FloatListTag - */ - constructor(); - /** - * set the onready callback function to the tag. - * This callback will be called after - * the tag is mounted - * - * @memberof FloatListTag - */ - set onready(v: (e: FloatListTag) => void); - /** - * Setter: - * - * Set the direction of the list item layout. - * Two directions are available: - * - `vertical` - * - `horizontal` - * - * This setter acts as a DOM attribute - * - * Getter: - * - * Get the currently set direction of list - * item layout - * - * @memberof FloatListTag - */ - set dir(v: string); - get dir(): string; - /** - * Disable the dropdown option in this list - * - * @memberof FloatListTag - */ - set dropdown(v: boolean); - /** - * Disable the list buttons configuration in this - * list - * - * @memberof FloatListTag - */ - set buttons(v: GenericObject[]); - /** - * Disable the `showlist` behavior in this list - * - * @protected - * @param {*} e - * @memberof FloatListTag - */ - protected showlist(e: any): void; - /** - * Disable the `dropoff` behavior in this list - * - * @protected - * @param {*} e - * @memberof FloatListTag - */ - protected dropoff(e: any): void; - /** - * Function called when the data of the list - * is changed - * - * @protected - * @memberof FloatListTag - */ - protected ondatachange(): void; - /** - * Mount the list to the DOM tree - * - * @protected - * @returns {void} - * @memberof FloatListTag - */ - protected mount(): void; - /** - * Push an element to the list - * - * @param {GenericObject} v an element data - * @returns - * @memberof FloatListTag - */ - push(v: GenericObject): ListViewItemTag; - /** - * Enable drag and drop on the list - * - * @private - * @param {ListViewItemTag} el the list item DOM element - * @memberof FloatListTag - */ - private enable_drag; - /** - * Calibrate the view of the list - * - * @memberof FloatListTag - */ - calibrate(): void; - } - } - } -} -/** - * Extend the Array interface with some - * property needed by AFX API - * - * @interface Array - * @template T - */ -interface Array { - /** - * Reference to a DOM element created by AFX API, - * this property is used by some AFX tags to refer - * to its child element in it data object - * - * @type {GenericObject} - * @memberof Array - */ - domel?: GenericObject; -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A grid Row is a simple element that - * contains a group of grid cell - * - * @export - * @class GridRowTag - * @extends {AFXTag} - */ - class GridRowTag extends AFXTag { - /** - * Data placeholder for a collection of cell data - * - * @type {GenericObject[]} - * @memberof GridRowTag - */ - data: GenericObject[]; - /** - *Creates an instance of GridRowTag. - * @memberof GridRowTag - */ - constructor(); - /** - * Mount the tag, do nothing - * - * @protected - * @memberof GridRowTag - */ - protected mount(): void; - /** - * Init the tag before mounting: reset the data placeholder - * - * @protected - * @memberof GridRowTag - */ - protected init(): void; - /** - * Empty layout - * - * @protected - * @returns {TagLayoutType[]} - * @memberof GridRowTag - */ - protected layout(): TagLayoutType[]; - /** - * This function does nothing in this tag - * - * @protected - * @memberof GridRowTag - */ - protected calibrate(): void; - /** - * This function does nothing in this tag - * - * @protected - * @param {*} [d] - * @memberof GridRowTag - */ - protected reload(d?: any): void; - } - /** - * Event data used by grid cell - */ - type CellEventData = TagEventDataType; - /** - * Prototype of any grid cell, custom grid cell - * definition should extend and implement this - * abstract prototype - * - * @export - * @abstract - * @class GridCellPrototype - * @extends {AFXTag} - */ - abstract class GridCellPrototype extends AFXTag { - /** - * placeholder for cell selected event callback - * - * @private - * @type {TagEventCallback} - * @memberof GridCellPrototype - */ - private _oncellselect; - /** - * placeholder for cell double click event callback - * - * @private - * @type {TagEventCallback} - * @memberof GridCellPrototype - */ - private _oncelldbclick; - /** - * Data placeholder of the current cell - * - * @private - * @type {GenericObject} - * @memberof GridCellPrototype - */ - private _data; - /** - *Creates an instance of GridCellPrototype. - * @memberof GridCellPrototype - */ - constructor(); - /** - * Set the cell selected event callback - * - * @memberof GridCellPrototype - */ - set oncellselect(v: TagEventCallback); - /** - * Set the cell double click event callback - * - * @memberof GridCellPrototype - */ - set oncelldbclick(v: TagEventCallback); - /** - * Setter: - * - * Set the data of the cell, this will trigger - * the [[ondatachange]] function - * - * Getter: - * - * Get the current cell data placeholder - * - * @memberof GridCellPrototype - */ - set data(v: GenericObject); - get data(): GenericObject; - /** - * Setter: - * - * Set/unset the current cell as selected. - * This will trigger the [[cellselect]] - * event - * - * Getter: - * - * Check whether the current cell is selected - * - * @memberof GridCellPrototype - */ - set selected(v: boolean); - get selected(): boolean; - /** - * Update the current cell. This will - * reset the cell data - * - * @protected - * @param {*} d - * @memberof GridCellPrototype - */ - protected reload(d: any): void; - /** - * Mount the current cell to the grid - * - * @protected - * @memberof GridCellPrototype - */ - protected mount(): void; - /** - * This function triggers the cell select - * event - * - * @private - * @param {TagEventType} e - * @param {boolean} flag - * @returns {void} - * @memberof GridCellPrototype - */ - private cellselect; - /** - * Abstract function called when the cell data changed. - * This should be implemented by subclasses - * - * @protected - * @abstract - * @memberof GridCellPrototype - */ - protected abstract ondatachange(): void; - } - /** - * Simple grid cell defines a grid cell with - * an [[LabelTag]] as it cell layout - * - * @export - * @class SimpleGridCellTag - * @extends {GridCellPrototype} - */ - class SimpleGridCellTag extends GridCellPrototype { - /** - *Creates an instance of SimpleGridCellTag. - * @memberof SimpleGridCellTag - */ - constructor(); - /** - * Reset the label of the cell with its data - * - * @protected - * @memberof SimpleGridCellTag - */ - protected ondatachange(): void; - /** - * This function do nothing in this tag - * - * @protected - * @memberof SimpleGridCellTag - */ - protected init(): void; - /** - * This function do nothing in this tag - * - * @protected - * @memberof SimpleGridCellTag - */ - protected calibrate(): void; - /** - * The layout of the cell with a simple [[LabelTag]] - * - * @returns - * @memberof SimpleGridCellTag - */ - layout(): { - el: string; - ref: string; - }[]; - } - /** - * A Grid contains a header and a collection grid rows - * which has the same number of cells as the number of - * the header elements - * - * @export - * @class GridViewTag - * @extends {AFXTag} - */ - class GridViewTag extends AFXTag { - /** - * Grid header definition - * - * @private - * @type {GenericObject[]} - * @memberof GridViewTag - */ - private _header; - /** - * Grid rows data placeholder - * - * @private - * @type {GenericObject[][]} - * @memberof GridViewTag - */ - private _rows; - /** - * Reference to the current selected row DOM element - * - * @private - * @type {GridRowTag} - * @memberof GridViewTag - */ - private _selectedRow; - /** - * A collection of selected grid rows DOM element - * - * @private - * @type {GridRowTag[]} - * @memberof GridViewTag - */ - private _selectedRows; - /** - * Reference to the current selected cell - * - * @private - * @type {GridCellPrototype} - * @memberof GridViewTag - */ - private _selectedCell; - /** - * Cell select event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof GridViewTag - */ - private _oncellselect; - /** - * Row select event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof GridViewTag - */ - private _onrowselect; - /** - * Cell double click event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof GridViewTag - */ - private _oncelldbclick; - /** - * Creates an instance of GridViewTag. - * @memberof GridViewTag - */ - constructor(); - /** - * Init the grid view before mounting. - * Reset all the placeholders to default values - * - * @protected - * @memberof GridViewTag - */ - protected init(): void; - /** - * This function does nothing - * - * @protected - * @param {*} [d] - * @memberof GridViewTag - */ - protected reload(d?: any): void; - /** - * set the cell select event callback - * - * @memberof GridViewTag - */ - set oncellselect(v: TagEventCallback); - /** - * set the row select event callback - * - * @memberof GridViewTag - */ - set onrowselect(v: TagEventCallback); - /** - * set the cell double click event callback - * - * @memberof GridViewTag - */ - set oncelldbclick(v: TagEventCallback); - /** - * Setter: set the tag name of the header cells - * - * Getter: get the grid header tag name - * - * @memberof GridViewTag - */ - set headeritem(v: string); - get headeritem(): string; - /** - * Setter: set the tag name of the grid cell - * - * Getter: get the tag name of the grid cell - * - * @memberof GridViewTag - */ - set cellitem(v: string); - get cellitem(): string; - /** - * Setter: set the header data - * - * Getter: get the header data placeholder - * - * @type {GenericObject[]} - * @memberof GridViewTag - */ - get header(): GenericObject[]; - set header(v: GenericObject[]); - /** - * Get all the selected rows - * - * @readonly - * @type {GridRowTag[]} - * @memberof GridViewTag - */ - get selectedRows(): GridRowTag[]; - /** - * Get the latest selected row - * - * @readonly - * @type {GridRowTag} - * @memberof GridViewTag - */ - get selectedRow(): GridRowTag; - /** - * Get the current selected cell - * - * @readonly - * @type {GridCellPrototype} - * @memberof GridViewTag - */ - get selectedCell(): GridCellPrototype; - /** - * Setter: set the rows data - * - * Getter: get the rows data - * - * @memberof GridViewTag - */ - set rows(rows: GenericObject[][]); - get rows(): GenericObject[][]; - /** - * Setter: activate deactivate multi-select - * - * Getter: check whether the `multiselect` option is activated - * - * @memberof GridViewTag - */ - set multiselect(v: boolean); - get multiselect(): boolean; - /** - * Set and Get the resizable attribute - * - * This allows to enable/disable column resize feature - * - * @memberof GridViewTag - */ - set resizable(v: boolean); - get resizable(): boolean; - /** - * Delete a grid rows - * - * @param {GridRowTag} row row DOM element - * @returns {void} - * @memberof GridViewTag - */ - delete(row: GridRowTag): void; - /** - * Push a row to the grid - * - * @param {GenericObject[]} row list of cell data - * @param {boolean} flag indicates where the row is add to beginning or end - * of the row - * @memberof GridViewTags - */ - push(row: GenericObject[], flag: boolean): void; - /** - * Unshift a row to the grid - * - * @param {GenericObject[]} row list of cell data in the row - * @memberof GridViewTag - */ - unshift(row: GenericObject[]): void; - /** - * This function triggers the cell select event - * - * @private - * @param {TagEventType} e event contains cell event data - * @param {boolean} flag indicates whether the event is double clicked - * @returns {void} - * @memberof GridViewTag - */ - private cellselect; - /** - * This function triggers the row select event, a cell select - * event will also trigger this event - * - * @param {TagEventType} e - * @returns {void} - * @memberof GridViewTag - */ - private rowselect; - /** - * Check whether the grid has header - * - * @private - * @returns {boolean} - * @memberof GridViewTag - */ - private has_header; - /** - * Calibrate the grid - * - * @protected - * @memberof GridViewTag - */ - protected calibrate(): void; - /** - * Recalculate the size of each header cell, changing - * in header cell size will also resize the entire - * related column - * - * @private - * @returns {void} - * @memberof GridViewTag - */ - private calibrate_header; - /** - * Mount the grid view tag - * - * @protected - * @returns {void} - * @memberof GridViewTag - */ - protected mount(): void; - /** - * Layout definition of the grid view - * - * @protected - * @returns {TagLayoutType[]} - * @memberof GridViewTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} declare namespace OS { namespace GUI { namespace tag { @@ -7855,456 +7590,621 @@ declare namespace OS { } } } -/// -/** - * - * Extend the HTMLElement interface with some utility function need - * by AFX API - * - * @interface HTMLElement - */ -interface HTMLElement { - /** - * Recursively update a tag and all its children - * - * @param {*} [d] data to send to all element in the DOM subtree - * @memberof HTMLElement - */ - update(d?: any): void; - /** - * - * AFX will automatically bind the context menu on an HTMLElement - * if this function is defined on that element. The function should - * define the content of the context menu and its action - * - * Once the context menu is bound to the element, all context menu handle - * defined on any child of this element will be ignored. - * - * @param {JQuery.MouseEventBase} e a mouse event - * @param {OS.GUI.tag.MenuTag} m The context menu element [[MenuTag]] - * @memberof HTMLElement - */ - contextmenuHandle(e: JQuery.MouseEventBase, m: OS.GUI.tag.MenuTag): void; - /** - * Mount the element and all the children on its DOM subtree. This action - * is performed in a top-down manner - * - * @memberof HTMLElement - */ - sync(): void; - /** - * - * This action allows to generated all the DOM nodes defined by all AFX tags - * in its hierarchy. - * It performs two operations, one top-down operation to generate all the - * necessary DOM nodes, another bottom-up operation to init all the AFX tag - * in the current element DOM hierarchy - * - * @param {OS.API.Announcer} o an AntOS observable object - * @memberof HTMLElement - */ - afxml(o: OS.API.Announcer): void; - /** - * Perform DOM generation ([[afxml]]) then mount ([[sync]]) all the - * elements. - * - * @param {OS.API.Announcer} o an AntOS observable object - * @param {boolean} [flag] indicates whether this is the top-most call of the operation - * @memberof HTMLElement - */ - uify(o: OS.API.Announcer, flag?: boolean): void; - /** - * - * - * @type {*} - * @memberof HTMLElement - */ - mozRequestFullScreen: any; - /** - * - * - * @type {*} - * @memberof HTMLElement - */ - webkitRequestFullscreen: any; - /** - * - * - * @type {*} - * @memberof HTMLElement - */ - msRequestFullscreen: any; +declare namespace OS { + namespace GUI { + namespace tag { + /** + * An overlay tag is a layout tag that alway stay on top of + * the virtual desktop environment. Tile layout elements ([[VBoxTag]], [[HboxTag]]) + * can be used inside this tag to compose elements + * + * @export + * @class OverlayTag + * @extends {AFXTag} + */ + class OverlayTag extends AFXTag { + /** + * Tag width placeholder + * + * @private + * @type {string} + * @memberof OverlayTag + */ + private _width; + /** + * Tag height place holder + * + * @private + * @type {string} + * @memberof OverlayTag + */ + private _height; + /** + *Creates an instance of OverlayTag. + * @memberof OverlayTag + */ + constructor(); + /** + * Put the tag on top of the virtual desktop environment + * + * @protected + * @memberof OverlayTag + */ + protected init(): void; + /** + * Do nothing + * + * @protected + * @param {*} [d] + * @memberof OverlayTag + */ + protected reload(d?: any): void; + /** + * Setter: + * + * Set the width of the tag, the tag width should be in form of: + * `100px` of `80%` + * + * Getter: + * + * Get the tag width + * + * @memberof OverlayTag + */ + set width(v: string); + get width(): string; + /** + * Setter: + * + * Set the tag height, the tag height should be in form of: + * `100px` of `80%` + * + * Getter: + * + * Get the tag height + * + * @memberof OverlayTag + */ + set height(v: string); + get height(): string; + /** + * Calibrate the element when mounting + * + * @protected + * @returns {void} + * @memberof OverlayTag + */ + protected mount(): void; + /** + * Calibrate the width and height of the tag + * + * @returns {void} + * @memberof OverlayTag + */ + calibrate(): void; + /** + * Layout definition of the tag + * + * @protected + * @returns {TagLayoutType[]} + * @memberof OverlayTag + */ + protected layout(): TagLayoutType[]; + } + } + } } -/** - * - * - * @interface Document - */ -interface Document { - mozCancelFullScreen: any; - webkitExitFullscreen: any; - cancelFullScreen: any; +declare namespace OS { + namespace GUI { + namespace tag { + /** + * Meta tag that represents the virtual desktop environment. + * In near future, we may have multiple virtual desktop environments. + * Each desktop environment has a simple file manager and a window + * manager that render the window in a specific order. + * + * @export + * @class DesktopTag + * @extends {FloatListTag} + */ + class DesktopTag extends FloatListTag { + /** + * internal handle to the desktop file location + * + * @private + * @type {API.VFS.BaseFileHandle} + * @memberof DesktopTag + */ + private file; + /** + * local observer that detect if a new child element is + * added or removed + * + * @private + * @type {MutationObserver} + * @memberof DesktopTag + */ + private observer; + /** + * Internal list of the current opened window + * + * @private + * @type {Set} + * @memberof DesktopTag + */ + private window_list; + /** + * Creates an instance of DesktopTag. + * @memberof DesktopTag + */ + constructor(); + /** + * Mount the virtual desktop to the DOM tree + * + * @protected + * @memberof DesktopTag + */ + protected mount(): void; + /** + * Display all files and folders in the specific desktop location + * + * @return {*} {Promise} + * @memberof DesktopTag + */ + refresh(): Promise; + /** + * Remove this element from its parent + * + * @memberof DesktopTag + */ + remove(): void; + /** + * Active a window above all other windows + * + * @private + * @param {WindowTag} win + * @memberof DesktopTag + */ + private selectWindow; + /** + * Render all windows in order from bottom to top + * + * @private + * @memberof DesktopTag + */ + private render; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * A float list is a list of items in which each + * item can be moved (drag and drop) freely + * + * @export + * @class FloatListTag + * @extends {ListViewTag} + */ + class FloatListTag extends ListViewTag { + /** + * Update the current tag, do nothing + * + * @protected + * @param {*} [d] + * @memberof FloatListTag + */ + protected reload(d?: any): void; + /** + * Variable that hold the onready callback of + * the tag. This callback will be called after + * the tag is mounted + * + * @private + * @memberof FloatListTag + */ + private _onready; + /** + *Creates an instance of FloatListTag. + * @memberof FloatListTag + */ + constructor(); + /** + * set the onready callback function to the tag. + * This callback will be called after + * the tag is mounted + * + * @memberof FloatListTag + */ + set onready(v: (e: FloatListTag) => void); + /** + * Setter: + * + * Set the direction of the list item layout. + * Two directions are available: + * - `vertical` + * - `horizontal` + * + * This setter acts as a DOM attribute + * + * Getter: + * + * Get the currently set direction of list + * item layout + * + * @memberof FloatListTag + */ + set dir(v: string); + get dir(): string; + /** + * Disable the dropdown option in this list + * + * @memberof FloatListTag + */ + set dropdown(v: boolean); + /** + * Disable the list buttons configuration in this + * list + * + * @memberof FloatListTag + */ + set buttons(v: GenericObject[]); + /** + * Disable the `showlist` behavior in this list + * + * @protected + * @param {*} e + * @memberof FloatListTag + */ + protected showlist(e: any): void; + /** + * Disable the `dropoff` behavior in this list + * + * @protected + * @param {*} e + * @memberof FloatListTag + */ + protected dropoff(e: any): void; + /** + * Function called when the data of the list + * is changed + * + * @protected + * @memberof FloatListTag + */ + protected ondatachange(): void; + /** + * Mount the list to the DOM tree + * + * @protected + * @returns {void} + * @memberof FloatListTag + */ + protected mount(): void; + /** + * Push an element to the list + * + * @param {GenericObject} v an element data + * @returns + * @memberof FloatListTag + */ + push(v: GenericObject): ListViewItemTag; + /** + * Enable drag and drop on the list + * + * @private + * @param {ListViewItemTag} el the list item DOM element + * @memberof FloatListTag + */ + private enable_drag; + /** + * Calibrate the view of the list + * + * @memberof FloatListTag + */ + calibrate(): void; + } + } + } } declare namespace OS { namespace GUI { /** - * [[TagLayoutType]] interface using by AFX tags to defined - * its internal DOM hierarchy + * + * Interface for an application dock item * * @export - * @interface TagLayoutType + * @interface AppDockItemType */ - interface TagLayoutType { + interface AppDockItemType { /** - * Element tag name + * Reference to the application process represented + * by the dock item * - * @type {string} - * @memberof TagLayoutType + * @type {application.BaseApplication} + * @memberof AppDockItemType */ - el: string; + app: application.BaseApplication; /** - * Children layout of the current element + * Reference to the DOM element of + * the owner dock item * - * @type {TagLayoutType[]} - * @memberof TagLayoutType + * @type {AFXTag} + * @memberof AppDockItemType */ - children?: TagLayoutType[]; - /** - * Reference name of the element used by AFX Tag - * - * @type {string} - * @memberof TagLayoutType - */ - ref?: string; - /** - * CSS class of the element - * - * @type {string} - * @memberof TagLayoutType - */ - class?: string; - /** - * this is the `data-id` attribute of the element, - * can be query by the [[aid]] Tag API function. - * Not to be confused with the DOM `id` attribute - * - * @type {(string | number)} - * @memberof TagLayoutType - */ - id?: string | number; - /** - * Tooltip text of the element - * - * @type {(string | FormattedString)} - * @memberof TagLayoutType - */ - tooltip?: string | FormattedString; - /** - * `data-width` of the element, not to be confused with - * the `width` attribute of the DOM element - * - * @type {number|string} - * @memberof TagLayoutType - */ - width?: number | string; - /** - ** `data-height` of the element, not to be confused with - * the `height` attribute of the DOM element - * - * @type {number|string} - * @memberof TagLayoutType - */ - height?: number | string; - } - /** - * Data type for event issued by AFX tags - * - * @export - * @interface TagEventDataType - * @template T item template - */ - interface TagEventDataType { - /** - * Reference to the item involved in the event - * - * @type {T} - * @memberof TagEventDataType - */ - item?: T; + domel?: AFXTag; [propName: string]: any; } - /** - * Format of the event issued by AFX tags - * - * @export - * @interface TagEventType - * @template T data type - */ - interface TagEventType { - /** - * `data-id` of the tag that trigger the - * event - * - * @type {(number | string)} - * @memberof TagEventType - */ - id: number | string; - /** - * Data object of the event - * - * @type {T} - * @memberof TagEventType - */ - data: T; - } - /** - * Drag and Drop data type sent between mouse events - * - * @export - * @interface DnDEventDataType - * @template T - */ - interface DnDEventDataType { - /** - * Reference to the source DOM element - * - * @type {T} - * @memberof DnDEventDataType - */ - from: T; - /** - * Reference to the target DOM element - * - * @type {T} - * @memberof DnDEventDataType - */ - to: T; - } - /** - * Tag event callback type - */ - type TagEventCallback = (e: TagEventType) => void; - /** - * Base abstract class for tag implementation, any AFX tag should be - * subclass of this class - * - * @export - * @abstract - * @class AFXTag - * @extends {HTMLElement} - */ - abstract class AFXTag extends HTMLElement { - /** - * The announcer object of the tag - * - * @type {API.Announcer} - * @memberof AFXTag - */ - observable: API.Announcer; - /** - * Reference to some of the tag's children - * element. This reference object is built - * based on the `ref` property found in the - * tag layout [[TagLayoutType]] - * - * @protected - * @type {GenericObject} - * @memberof AFXTag - */ - protected refs: GenericObject; - /** - * boolean value indicated whether the tag - * is already mounted in the DOM tree - * - * @protected - * @type {boolean} - * @memberof AFXTag - */ - protected _mounted: boolean; - /** - *Creates an instance of AFXTag. - * @memberof AFXTag - */ - constructor(); - /** - * This function verifies if a property name of the input object - * corresponds to a setter of the current tag. If this is the - * case, it sets the value of that property to the setter - * - * @param {GenericObject} v input object - * @memberof AFXTag - */ - set(v: GenericObject): void; - /** - * Setter to set the tooltip text to the current tag. - * The text should be in the following format: - * ```text - * cr|cl|ct|cb: tooltip text - * ``` - * - * @memberof AFXTag - */ - set tooltip(v: string); - /** - * - * This function looking for a property name of the tag - * in its prototype chain. The descriptor of the property - * will be returned if it exists - * - * @private - * @param {string} k the property name to be queried - * @returns {PropertyDescriptor} the property descriptor or undefined - * @memberof AFXTag - */ - private descriptor_of; - /** - * Setter: set the id of the tag in string or number - * - * Getter: get the id of the current tag - * - * @memberof AFXTag - */ - set aid(v: string | number); - get aid(): string | number; - /** - * Implementation from HTMLElement interface, - * this function mount the current tag hierarchy - * - * @returns {void} - * @memberof AFXTag - */ - sync(): void; - /** - * Generate the DOM hierarchy of the current tag - * - * @param {API.Announcer} o observable object - * @memberof AFXTag - */ - afxml(o: API.Announcer): void; - /** - * Update the current tag hierarchy - * - * @param {*} d any data object - * @memberof AFXTag - */ - update(d: any): void; - /** - * Init the current tag, this function - * is called before the [[mount]] function - * - * @protected - * @abstract - * @memberof AFXTag - */ - protected abstract init(): void; - /** - * Mount only the current tag - * - * @protected - * @abstract - * @memberof AFXTag - */ - protected abstract mount(): void; - /** - * Layout definition of a tag - * - * @protected - * @abstract - * @returns {TagLayoutType[]} tag layout object - * @memberof AFXTag - */ - protected abstract layout(): TagLayoutType[]; - /** - * Update only the current tag, this function is - * called by [[update]] before chaining the - * update process to its children - * - * @protected - * @abstract - * @param {*} [d] - * @memberof AFXTag - */ - protected abstract reload(d?: any): void; - /** - * This function is used to re-render the current - * tag - * - * @protected - * @memberof AFXTag - */ - protected calibrate(): void; - /** - * This function parses the input layout object - * and generates all the elements defined by - * the tag - * - * @private - * @param {TagLayoutType} tag tag layout object - * @returns {Element} the DOM element specified by the tag layout - * @memberof AFXTag - */ - private mkui; - /** - * This function inserts or removes an attribute name - * to/from the target element based on the input `flag`. - * - * @protected - * @param {boolean} flag indicates whether the attribute name should be inserted o removed - * @param {string} v the attribute name - * @param {HTMLElement} [el] the target element - * @memberof AFXTag - */ - protected attsw(flag: boolean, v: string, el?: HTMLElement): void; - /** - * Insert the attribute name to the target element - * - * @protected - * @param {string} v the attribute name - * @param {HTMLElement} [el] the target element - * @memberof AFXTag - */ - protected atton(v: string, el?: HTMLElement): void; - /** - * Remove the attribute name from the target element - * - * @protected - * @param {string} v attribute name - * @param {HTMLElement} [el] the target element - * @memberof AFXTag - */ - protected attoff(v: string, el?: HTMLElement): void; - /** - * Verify if the target element has an attribute name - * - * @protected - * @param {string} v attribute name - * @param {HTMLElement} [el] target element - * @returns {boolean} - * @memberof AFXTag - */ - protected hasattr(v: string, el?: HTMLElement): boolean; - } - /** - * All the AFX tags are defined in this namespace, - * these tags are defined as custom DOM elements and will be - * stored in the `customElements` registry of the browser - */ namespace tag { /** - * Define an AFX tag as a custom element and add it to the - * global `customElements` registry. If the tag is redefined, i.e. - * the tag already exists, its behavior will be updated with the - * new definition + * This class define the AntOS system application dock tag * * @export - * @template T all classes that extends [[AFXTag]] - * @param {string} name name of the tag - * @param {{ new (): T }} cls the class that defines the tag - * @returns {void} + * @class AppDockTag + * @extends {AFXTag} */ - function define(name: string, cls: { - new (): T; - }): void; + class AppDockTag extends AFXTag { + /** + * variable holds the application select event + * callback handle + * + * @private + * @type {TagEventCallback} + * @memberof AppDockTag + */ + private _onappselect; + /** + * Items data of the dock + * + * @private + * @type {AppDockItemType[]} + * @memberof AppDockTag + */ + private _items; + /** + * Reference to the currently select application + * process in the dock + * + * @private + * @type {AppDockItemType} + * @memberof AppDockTag + */ + private _selectedItem; + /** + *Creates an instance of AppDockTag. + * @memberof AppDockTag + */ + constructor(); + /** + * Implementation of the abstract function: Update the current tag. + * It do nothing for this tag + * + * @protected + * @param {*} [d] + * @memberof AppDockTag + */ + protected reload(d?: any): void; + /** + * Init the tag before mounting + * + * @protected + * @memberof AppDockTag + */ + protected init(): void; + /** + * The tag layout, it is empty on creation but elements will + * be added automatically to it in operation + * + * @protected + * @returns {TagLayoutType[]} + * @memberof AppDockTag + */ + protected layout(): TagLayoutType[]; + /** + * getter to get the dock items + * + * @readonly + * @type {AppDockItemType[]} + * @memberof AppDockTag + */ + get items(): AppDockItemType[]; + /** + * Setter: + * + * set the selected application in the dock + * this will trigger two event: + * - `focus`: on the selected application + * - `blur`: on all other applications on the dock + * + * Getter: + * + * Get the current selected application + * on the dock + * + * @memberof AppDockTag + */ + set selectedApp(v: application.BaseApplication); + get selectedApp(): application.BaseApplication; + /** + * Get selected item of the dock + * + * @readonly + * @type {AppDockItemType} + * @memberof AppDockTag + */ + get selectedItem(): AppDockItemType; + /** + * When a new application process is created, this function + * will be called to add new application entry to the dock. + * The added application will becomes the current selected + * application + * + * @param {AppDockItemType} item an application dock item entry + * @memberof AppDockTag + */ + newapp(item: AppDockItemType): void; + /** + * Delete and application entry from the dock. + * This function will be called when an application + * is exit + * + * @param {BaseApplication} a the application to be removed from the dock + * @memberof AppDockTag + */ + removeapp(a: application.BaseApplication): void; + /** + * Mount the current dock tag + * + * @protected + * @memberof AppDockTag + */ + protected mount(): void; + } + } + } +} +declare namespace OS { + namespace GUI { + namespace tag { + /** + * Tag that define system calendar widget + * + * @export + * @class CalendarTag + * @extends {AFXTag} + */ + class CalendarTag extends AFXTag { + /** + * The current selected day + * + * @private + * @type {number} + * @memberof CalendarTag + */ + private _day; + /** + * The current selected month + * + * @private + * @type {number} + * @memberof CalendarTag + */ + private _month; + /** + * The current selected year + * + * @private + * @type {number} + * @memberof CalendarTag + */ + private _year; + /** + * The current selected date object + * + * @private + * @type {Date} + * @memberof CalendarTag + */ + private _selectedDate; + /** + * placeholder for date select event callback + * + * @private + * @type {TagEventCallback} + * @memberof CalendarTag + */ + private _ondateselect; + /** + *Creates an instance of CalendarTag. + * @memberof CalendarTag + */ + constructor(); + /** + * Init the tag before mounting + * + * @protected + * @memberof CalendarTag + */ + protected init(): void; + /** + * Update the current tag, doing nothing in this tag + * + * @protected + * @param {*} [d] any data object + * @memberof CalendarTag + */ + protected reload(d?: any): void; + /** + * Get the current selected date in the widget + * + * @readonly + * @type {Date} + * @memberof CalendarTag + */ + get selectedDate(): Date; + /** + * Set the date select event callback handle for the widget + * + * @memberof CalendarTag + */ + set ondateselect(v: TagEventCallback); + /** + * Mount the current widget to the DOM tree + * + * @protected + * @memberof CalendarTag + */ + protected mount(): void; + /** + * This function triggers the date select event + * + * @private + * @param {TagEventType} e AFX tag event data [[TagEventType]] + * @returns {void} + * @memberof CalendarTag + */ + private dateselect; + /** + * Calibrate the layout of the tag + * + * @protected + * @memberof CalendarTag + */ + protected calibrate(): void; + /** + * Display the previous month of the current month + * + * @private + * @memberof CalendarTag + */ + private prevmonth; + /** + * Display the next month of the current month + * + * @private + * @returns + * @memberof CalendarTag + */ + private nextmonth; + /** + * Visualize the calendar base on input date + * + * @private + * @param {Date} date + * @memberof CalendarTag + */ + private calendar; + /** + * Layout definition of the widget + * + * @protected + * @returns {TagLayoutType[]} + * @memberof CalendarTag + */ + protected layout(): TagLayoutType[]; + } } } } @@ -8524,1719 +8424,2058 @@ declare namespace OS { } } } -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A tile layout organize it child elements - * in a fixed horizontal or vertical direction. - * - * The size of each child element is attributed based - * on its configuration of automatically based on the - * remaining space in the layout - * - * - * @export - * @class TileLayoutTag - * @extends {AFXTag} - */ - class TileLayoutTag extends AFXTag { - /** - *C reates an instance of TileLayoutTag. - * @memberof TileLayoutTag - */ - constructor(); - /** - * Do nothing - * - * @protected - * @memberof TileLayoutTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @param {*} [d] - * @memberof TileLayoutTag - */ - protected reload(d?: any): void; - /** - * Setter: Set the name of the tile container, should be: `hbox` or `vbox` - * - * Getter: Get the name of the tile container - * - * @memberof TileLayoutTag - */ - set name(v: string); - get name(): string; - /** - * Setter: - * - * SET the layout direction, should be: - * - `row`: horizontal direction - * - `column`: vertical direction - * - * Getter: - * - * Get layout direction - * - * @memberof TileLayoutTag - */ - set dir(v: "row" | "column"); - get dir(): "row" | "column"; - /** - * Mount the element - * - * @protected - * @returns {void} - * @memberof TileLayoutTag - */ - protected mount(): void; - /** - * re-organize the layout - * - * @returns {void} - * @memberof TileLayoutTag - */ - calibrate(): void; - /** - * Organize the layout in horizontal direction, only work when - * the layout direction set to horizontal - * - * @private - * @returns {void} - * @memberof TileLayoutTag - */ - private hcalibrate; - /** - * Organize the layout in vertical direction, only work when - * the layout direction set to vertical - * - * @private - * @returns {void} - * @memberof TileLayoutTag - */ - private vcalibrate; - /** - * Layout definition - * - * @returns - * @memberof TileLayoutTag - */ - layout(): { - el: string; - ref: string; - }[]; - } - /** - * A HBox organize its child elements in horizontal direction - * - * @export - * @class HBoxTag - * @extends {TileLayoutTag} - */ - class HBoxTag extends TileLayoutTag { - /** - * Creates an instance of HBoxTag. - * @memberof HBoxTag - */ - constructor(); - /** - * Mount the tag - * - * @protected - * @memberof HBoxTag - */ - protected mount(): void; - } - /** - * A VBox organize its child elements in vertical direction - * - * @export - * @class VBoxTag - * @extends {TileLayoutTag} - */ - class VBoxTag extends TileLayoutTag { - /** - *Creates an instance of VBoxTag. - * @memberof VBoxTag - */ - constructor(); - /** - * Mount the tag - * - * @protected - * @memberof VBoxTag - */ - protected mount(): void; - } - } - } -} -/// -declare namespace OS { - namespace GUI { - namespace tag { - /** - * This tag define a basic button and its behavior - * - * @export - * @class ButtonTag - * @extends {AFXTag} - */ - class ButtonTag extends AFXTag { - /** - * Variable hold the button click callback handle - * - * @private - * @type {TagEventCallback} - * @memberof ButtonTag - */ - private _onbtclick; - /** - * Custom user data - * - * @type {GenericObject} - * @memberof ButtonTag - */ - data: GenericObject; - /** - *Creates an instance of ButtonTag. - * @memberof ButtonTag - */ - constructor(); - /** - * Set the click callback handle for the target button - * - * @memberof ButtonTag - */ - set onbtclick(v: TagEventCallback); - /** - * Set the path to the button icon, the path should be - * a VFS file path - * - * @memberof ButtonTag - */ - set icon(v: string); - /** - * Set the icon class to the button, this property - * allows to style the button icon using CSS - * - * @memberof ButtonTag - */ - set iconclass(v: string); - /** - * Setter: Set the text of the button - * - * Getter: Get the current button test - * - * @memberof ButtonTag - */ - set text(v: string | FormattedString); - get text(): string | FormattedString; - /** - * Setter: Enable or disable the button - * - * Getter: Get the `enable` property of the button - * - * @memberof ButtonTag - */ - set enable(v: boolean); - get enable(): boolean; - /** - * Setter: set or remove the attribute `selected` of the button - * - * Getter: check whether the attribute `selected` of the button is set - * - * @memberof ButtonTag - */ - set selected(v: boolean); - get selected(): boolean; - /** - * Setter: activate or deactivate the toggle mode of the button - * - * Getter: Check whether the button is in toggle mode - * - * @memberof ButtonTag - */ - set toggle(v: boolean); - get toggle(): boolean; - /** - * Mount the tag - * - * @protected - * @memberof ButtonTag - */ - protected mount(): void; - /** - * Init the tag before mounting - * - * @protected - * @memberof ButtonTag - */ - protected init(): void; - /** - * Re-calibrate the button, do nothing in this tag - * - * @protected - * @memberof ButtonTag - */ - protected calibrate(): void; - /** - * Update the current tag, do nothing in this tag - * - * @param {*} [d] - * @memberof ButtonTag - */ - reload(d?: any): void; - /** - * Button layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ButtonTag - */ - protected layout(): TagLayoutType[]; - } - } - } +declare type VFSFileHandleClass = { + new (...args: any[]): OS.API.VFS.BaseFileHandle; +}; +interface String { + /** + * Convert a string to VFS file handle. + * + * This function will create a file handle object from the string + * with the help of [[VFS.findHandles]] + * + * @returns {OS.API.VFS.BaseFileHandle} + * @memberof String + */ + asFileHandle(): OS.API.VFS.BaseFileHandle; } declare namespace OS { - namespace GUI { - namespace tag { + namespace API { + /** + * User permission data type + * + * @export + * @interface UserPermissionType + */ + interface UserPermissionType { + read: boolean; + write: boolean; + exec: boolean; + } + /** + * VFS file meta-data data type + * + * @export + * @interface FileInfoType + */ + interface FileInfoType { /** - * Tag that define system calendar widget + * File mime type + * + * @type {string} + * @memberof FileInfoType + */ + mime: string; + /** + * File size + * + * @type {number} + * @memberof FileInfoType + */ + size: number; + /** + * File name + * + * @type {string} + * @memberof FileInfoType + */ + name: string; + /** + * File path + * + * @type {string} + * @memberof FileInfoType + */ + path: string; + /** + * File type: + * - `file` + * - `dir` + * - `app` + * + * @type {string} + * @memberof FileInfoType + */ + type: string; + /** + * File permission + * + * @type {{ + * group: UserPermissionType; + * owner: UserPermissionType; + * other: UserPermissionType; + * }} + * @memberof FileInfoType + */ + perm?: { + /** + * Group permission + * + * @type {UserPermissionType} + */ + group: UserPermissionType; + /** + * Owner permission + * + * @type {UserPermissionType} + */ + owner: UserPermissionType; + /** + * Other permission + * + * @type {UserPermissionType} + */ + other: UserPermissionType; + }; + /** + * Creation time + * + * @type {string} + * @memberof FileInfoType + */ + ctime?: string; + /** + * Modification time + * + * @type {string} + * @memberof FileInfoType + */ + mtime?: string; + /** + * Group id + * + * @type {number} + * @memberof FileInfoType + */ + gid?: number; + /** + * User id + * + * @type {number} + * @memberof FileInfoType + */ + uid?: number; + [propName: string]: any; + } + /** + * This namespace is dedicated to all APIs related to + * AntOS Virtual File System (VFS) + */ + namespace VFS { + /** + * Placeholder stores VFS file protocol patterns and its attached file handle class. + * + */ + const handles: GenericObject; + /** + * Register a protocol to a handle class * * @export - * @class CalendarTag - * @extends {AFXTag} + * @param {string} protos VFS protocol pattern + * @param {VFSFileHandleClass} cls handle class */ - class CalendarTag extends AFXTag { - /** - * The current selected day - * - * @private - * @type {number} - * @memberof CalendarTag - */ - private _day; - /** - * The current selected month - * - * @private - * @type {number} - * @memberof CalendarTag - */ - private _month; - /** - * The current selected year - * - * @private - * @type {number} - * @memberof CalendarTag - */ - private _year; - /** - * The current selected date object - * - * @private - * @type {Date} - * @memberof CalendarTag - */ - private _selectedDate; - /** - * placeholder for date select event callback - * - * @private - * @type {TagEventCallback} - * @memberof CalendarTag - */ - private _ondateselect; - /** - *Creates an instance of CalendarTag. - * @memberof CalendarTag - */ - constructor(); - /** - * Init the tag before mounting - * - * @protected - * @memberof CalendarTag - */ - protected init(): void; - /** - * Update the current tag, doing nothing in this tag - * - * @protected - * @param {*} [d] any data object - * @memberof CalendarTag - */ - protected reload(d?: any): void; - /** - * Get the current selected date in the widget - * - * @readonly - * @type {Date} - * @memberof CalendarTag - */ - get selectedDate(): Date; - /** - * Set the date select event callback handle for the widget - * - * @memberof CalendarTag - */ - set ondateselect(v: TagEventCallback); - /** - * Mount the current widget to the DOM tree - * - * @protected - * @memberof CalendarTag - */ - protected mount(): void; - /** - * This function triggers the date select event - * - * @private - * @param {TagEventType} e AFX tag event data [[TagEventType]] - * @returns {void} - * @memberof CalendarTag - */ - private dateselect; - /** - * Calibrate the layout of the tag - * - * @protected - * @memberof CalendarTag - */ - protected calibrate(): void; - /** - * Display the previous month of the current month - * - * @private - * @memberof CalendarTag - */ - private prevmonth; - /** - * Display the next month of the current month - * - * @private - * @returns - * @memberof CalendarTag - */ - private nextmonth; - /** - * Visualize the calendar base on input date - * - * @private - * @param {Date} date - * @memberof CalendarTag - */ - private calendar; - /** - * Layout definition of the widget - * - * @protected - * @returns {TagLayoutType[]} - * @memberof CalendarTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { + function register(protos: string, cls: VFSFileHandleClass): void; /** - * List item event data type - */ - type ListItemEventData = TagEventDataType; - /** - * A list item represent the individual view of an item in the [[ListView]]. - * This class is an abstract prototype class, implementation of any - * list view item should extend it + * Load custom VFS handles if the package vfsx available * + * @export + * @param {boolean} [force] force load the file + * @return {*} {Promise} + */ + function loadVFSX(force?: boolean): Promise; + /** + * Looking for a attached file handle class of a string protocol + * + * When converting a string to file handle, the system will look + * for a protocol pattern in the string, if the protocol found, + * its attached handle class (found in [[VFS.handles]]) will be + * used to initialize a file handle object from the string + * + * ```typescript + * "home://data/test.txt".asFileHandle() // -> an instance of RemoteFileHandle + * ``` + * @export + * @param {string} proto protocol string + * @returns {VFSFileHandleClass[]} + */ + function findHandles(proto: string): VFSFileHandleClass[]; + /** + * Abstract prototype of all all VFS file handle definition. + * + * This prototype provides a standardized interface to access + * to different underlay file systems such as remote file, + * cloud file (Dropbox, Google drive, etc.), URL or memory-based file * * @export * @abstract - * @class ListViewItemTag - * @extends {AFXTag} + * @class BaseFileHandle */ - abstract class ListViewItemTag extends AFXTag { + abstract class BaseFileHandle { /** - * Data placeholder for the list item + * Flag indicates whether the file is dirty * - * @private - * @type {GenericObject} - * @memberof ListViewItemTag - */ - private _data; - /** - * placeholder for the item select event callback - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onselect; - /** - * Context menu event callback handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onctxmenu; - /** - * Click event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onclick; - /** - * Double click event callback handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _ondbclick; - /** - * Item close event callback placeholder - * - * @private - * @type {TagEventCallback} - * @memberof ListViewItemTag - */ - private _onclose; - /** - *Creates an instance of ListViewItemTag. - * @memberof ListViewItemTag - */ - constructor(); - /** - * Setter: Turn on/off the `closable` feature of the list item - * - * Getter: Check whether the item is closable - * - * @memberof ListViewItemTag - */ - set closable(v: boolean); - get closable(): boolean; - /** - * Set item select event handle - * - * @memberof ListViewItemTag - */ - set onitemselect(v: TagEventCallback); - /** - * Setter: select/unselect the current item - * - * Getter: Check whether the current item is selected - * - * @memberof ListViewItemTag - */ - set selected(v: boolean); - get selected(): boolean; - /** - * Set the context menu event handle - * - * @memberof ListViewItemTag - */ - set onctxmenu(v: TagEventCallback); - /** - * Set the item click event handle - * - * @memberof ListViewItemTag - */ - set onitemclick(v: TagEventCallback); - /** - * Set the item double click event handle - * - * @memberof ListViewItemTag - */ - set onitemdbclick(v: TagEventCallback); - /** - * set the item close event handle - * - * @memberof ListViewItemTag - */ - set onitemclose(v: TagEventCallback); - /** - * Mount the tag and bind some events - * - * @protected - * @memberof ListViewItemTag - */ - protected mount(): void; - /** - * Layout definition of the item tag. - * This function define the outer layout of the item. - * Custom inner layout of each item implementation should - * be defined in [[itemlayout]] - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ListViewItemTag - */ - protected layout(): TagLayoutType[]; - /** - * Setter: - * - * Set the data of the list item. This will - * trigger the [[ondatachange]] function - * - * Getter: - * - * Get the data of the current list item - * - * @memberof ListViewItemTag - */ - set data(v: GenericObject); - get data(): GenericObject; - /** - * Any subclass of this class should implement this - * function to provide its custom item layout - * - * @protected - * @abstract - * @returns {TagLayoutType} - * @memberof ListViewItemTag - */ - protected abstract itemlayout(): TagLayoutType; - /** - * This function is called when the item data is changed. - * It should be implemented in all subclass of this class - * - * @protected - * @abstract - * @memberof ListViewItemTag - */ - protected abstract ondatachange(): void; - } - /** - * The layout of a simple list item contains only a - * AFX label - * - * @export - * @class SimpleListItemTag - * @extends {ListViewItemTag} - */ - class SimpleListItemTag extends ListViewItemTag { - /** - *Creates an instance of SimpleListItemTag. - * @memberof SimpleListItemTag - */ - constructor(); - /** - * Reset some property to default - * - * @protected - * @memberof SimpleListItemTag - */ - protected init(): void; - /** - * Do nothing - * - * @protected - * @memberof SimpleListItemTag - */ - protected calibrate(): void; - /** - * Refresh the inner label when the item data - * is changed - * - * @protected - * @returns {void} - * @memberof SimpleListItemTag - */ - protected ondatachange(): void; - /** - * Re-render the list item - * - * @protected - * @memberof SimpleListItemTag - */ - protected reload(): void; - /** - * List item custom layout definition - * - * @protected - * @returns {TagLayoutType} - * @memberof SimpleListItemTag - */ - protected itemlayout(): TagLayoutType; - } - /** - * This tag defines a traditional or a dropdown list widget. - * It contains a collection of list items in which layout - * of each item may be variable - * - * @export - * @class ListViewTag - * @extends {AFXTag} - */ - class ListViewTag extends AFXTag { - /** - * placeholder of list select event handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewTag - */ - private _onlistselect; - /** - * placeholder of list double click event handle - * - * @private - * @type {TagEventCallback} - * @memberof ListViewTag - */ - private _onlistdbclick; - /** - * placeholder of list drag and drop event handle - * - * @private - * @type {TagEventCallback>} - * @memberof ListViewTag - */ - private _ondragndrop; - /** - * placeholder of list item close event handle - * - * @private - * @memberof ListViewTag - */ - private _onitemclose; - /** - * placeholder of drag and drop mouse down event handle - * - * @private - * @memberof ListViewTag - */ - private _onmousedown; - /** - * placeholder of drag and drop mouse up event handle - * - * @private - * @memberof ListViewTag - */ - private _onmouseup; - /** - * placeholder of drag and drop mouse move event handle - * - * @private - * @memberof ListViewTag - */ - private _onmousemove; - /** - * Reference to the latest selected DOM item - * - * @private - * @type {ListViewItemTag} - * @memberof ListViewTag - */ - private _selectedItem; - /** - * A collection of selected items in the list. - * The maximum size of this collection is 1 if - * the [[multiselect]] feature is disabled - * - * @private - * @type {ListViewItemTag[]} - * @memberof ListViewTag - */ - private _selectedItems; - /** - * Data placeholder of the list - * - * @private - * @type {GenericObject[]} - * @memberof ListViewTag - */ - private _data; - /** - * Event data passing between mouse event when performing - * drag and drop on the list - * - * @private - * @type {{ from: ListViewItemTag; to: ListViewItemTag }} - * @memberof ListViewTag - */ - private _dnd; - /** - *Creates an instance of ListViewTag. - * @memberof ListViewTag - */ - constructor(); - /** - * Reset the tag's properties to the default values - * - * @protected - * @memberof ListViewTag - */ - protected init(): void; - /** - * This function does nothing - * - * @protected - * @param {*} [d] - * @memberof ListViewTag - */ - protected reload(d?: any): void; - /** - * Setter: toggle between dropdown and traditional list - * - * Getter: Check whether the list is dropdown or traditional list - * - * @memberof ListViewTag - */ - set dropdown(v: boolean); - /** - * Set drag and drop event handle - * - * @memberof ListViewTag - */ - set ondragndrop(v: TagEventCallback>); - /** - * Set list select event handle - * - * @memberof ListViewTag - */ - set onlistselect(v: TagEventCallback); - /** - * Set double click event handle - * - * @memberof ListViewTag - */ - set onlistdbclick(v: TagEventCallback); - /** - * Set item close event handle - * - * @memberof ListViewTag - */ - set onitemclose(v: (e: TagEventType) => boolean); - get dropdown(): boolean; - /** - * Setter: - * - * Set the default tag name of list's items. - * If the tag name is not specified in the - * data of a list item, this tag will be used - * - * Getter: - * - * Get the default tag name of list item - * - * @memberof ListViewTag - */ - set itemtag(v: string); - get itemtag(): string; - /** - * Setter: - * - * Turn on/off of the `multiselect` feature - * - * Getter: - * - * Check whether multi-select is allowed - * in this list - * - * @memberof ListViewTag - */ - set multiselect(v: boolean); - get multiselect(): boolean; - /** - * Setter: Enable/disable drag and drop event in the list - * - * Getter: Check whether the drag and drop event is enabled - * - * @memberof ListViewTag - */ - set dragndrop(v: boolean); - get dragndrop(): boolean; - /** - * Set the buttons layout of the list. - * Button layout allows to add some custom - * behaviors to the list. - * - * Each button data should define the [[onbtclick]] - * event handle to specify the custom behavior - * - * When the list is configured as dropdown. The buttons - * layout will be disabled - * - * Example of a button data: - * - * ``` - * { - * text: "Button text", - * icon: "home://path/to/icon.png", - * iconclass: "icon-class-name", - * onbtclick: (e) => console.log(e) - * } - * ``` - * - * @memberof ListViewTag - */ - set buttons(v: GenericObject[]); - /** - * Getter: Get data of the list - * - * Setter: Set data to the list - * - * @type {GenericObject[]} - * @memberof ListViewTag - */ - get data(): GenericObject[]; - set data(data: GenericObject[]); - /** - * Do nothing - * - * @protected - * @memberof ListViewTag - */ - protected ondatachange(): void; - /** - * Setter: Select list item(s) by their indexes - * - * Getter: Get the indexes of all selected items - * - * @memberof ListViewTag - */ - set selected(idx: number | number[]); - /** - * Get the latest selected item - * - * @readonly - * @type {ListViewItemTag} - * @memberof ListViewTag - */ - get selectedItem(): ListViewItemTag; - /** - * Get all the selected items - * - * @readonly - * @type {ListViewItemTag[]} - * @memberof ListViewTag - */ - get selectedItems(): ListViewItemTag[]; - get selected(): number | number[]; - /** - * Add an item to the beginning of the list - * - * @param {GenericObject} item - * @returns {ListViewItemTag} the added list item element - * @memberof ListViewTag - */ - unshift(item: GenericObject): ListViewItemTag; - /** - * check whether the list has data - * - * @private - * @param {GenericObject} v - * @returns - * @memberof ListViewTag - */ - private has_data; - /** - * Add an item to the beginning or end of the list - * - * @param {GenericObject} item list item data - * @param {boolean} [flag] indicates whether to add the item in the beginning of the list - * @returns {ListViewItemTag} the added list item element - * @memberof ListViewTag - */ - push(item: GenericObject, flag?: boolean): ListViewItemTag; - /** - * Delete an item - * - * @param {ListViewItemTag} item item DOM element - * @memberof ListViewTag - */ - delete(item: ListViewItemTag): void; - /** - * Select item next to the currently selected item. - * If there is no item selected, the first item will - * be selected - * - * @returns {void} - * @memberof ListViewTag - */ - selectNext(): void; - /** - * Select the previous item in the list. - * - * @returns {void} - * @memberof ListViewTag - */ - selectPrev(): void; - /** - * Unselect all the selected items in the list - * - * @returns {void} - * @memberof ListViewTag - */ - unselect(): void; - /** - * This function triggers the click event on an item - * - * @private - * @param {TagEventType} e tag event object - * @param {boolean} flag indicates whether this is a double click event - * @returns {void} - * @memberof ListViewTag - */ - private iclick; - /** - * This function triggers the double click event on an item - * - * @private - * @param {TagEventType} e tag event object - * @returns - * @memberof ListViewTag - */ - private idbclick; - /** - * This function triggers the list item select event - * - * @private - * @param {TagEventType} e tag event object - * @returns - * @memberof ListViewTag - */ - private iselect; - /** - * Mount the tag and bind some basic event - * - * @protected - * @returns {void} - * @memberof ListViewTag - */ - protected mount(): void; - /** - * This function triggers the item close event - * - * @private - * @param {TagEventType} e tag event object - * @returns {void} - * @memberof ListViewTag - */ - private iclose; - /** - * Show the dropdown list. - * This function is called only when the list is a dropdown - * list - * - * @protected - * @param {*} e - * @returns {void} - * @memberof ListViewTag - */ - protected showlist(e: any): void; - /** - * Hide the dropdown list. - * This function is called only when the list is a dropdown - * list - * - * @protected - * @param {*} e - * @memberof ListViewTag - */ - protected dropoff(e: any): void; - /** - * calibrate the list layout - * - * @protected - * @returns {void} - * @memberof ListViewTag - */ - protected calibrate(): void; - /** - * List view layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof ListViewTag - */ - protected layout(): TagLayoutType[]; - } - } - } -} -declare namespace OS { - namespace GUI { - namespace tag { - /** - * A system panel contains the following elements: - * - Spotlight to access to applications menu - * - Current focused application menu - * - System tray for all running services running in background - * - * @export - * @class SystemPanelTag - * @extends {AFXTag} - */ - class SystemPanelTag extends AFXTag { - /** - * Reference to spotlight data - * - * @private - * @type {(GenericObject)} - * @memberof SystemPanelTag - */ - private _osmenu; - /** - * Placeholder indicates whether the spotlight is currently shown - * - * @private * @type {boolean} - * @memberof SystemPanelTag + * @memberof BaseFileHandle */ - private _view; + dirty: boolean; /** - * Store pending loading task + * Once read, file content will be cached in this placeholder * * @private - * @type {number[]} - * @memberof SystemPanelTag + * @type {*} + * @memberof BaseFileHandle */ - private _pending_task; + private _cache; /** - * Loading animation check timeout + * Flag indicated whether the file meta-data is loaded * - * @memberof SystemPanelTag + * @type {boolean} + * @memberof BaseFileHandle */ - private _loading_toh; + ready: boolean; /** - * Place holder for a private callback function + * File path * - * @private - * @memberof SystemPanelTag + * @type {string} + * @memberof BaseFileHandle */ - private _cb; + path: string; /** - * Place holder for system app list + * File protocol e.g: + * - `os://` + * - `home://` * - * @private - * @type {GenericObject[]} - * @memberof SystemPanelTag + * @type {string} + * @memberof BaseFileHandle */ - private app_list; + protocol: string; /** - *Creates an instance of SystemPanelTag. - * @memberof SystemPanelTag + * List of path segments + * + * @type {string[]} + * @memberof BaseFileHandle */ - constructor(); + genealogy: string[]; /** - * Do nothing + * File base name + * + * @type {string} + * @memberof BaseFileHandle + */ + basename: string; + /** + * Once loaded, [[ready]] will be set to true and + * file meta-data will be stored in this place holder + * + * @type {FileInfoType} + * @memberof BaseFileHandle + */ + info: FileInfoType; + /** + * File extension + * + * @type {string} + * @memberof BaseFileHandle + */ + ext: string; + /** + * + * File type + * @type {string} + * @memberof BaseFileHandle + */ + type: string; + /** + *Creates an instance of BaseFileHandle. + * @param {string} path file path + * @memberof BaseFileHandle + */ + constructor(path: string); + /** + * Set a file path to the current file handle + * + * @param {string} p + * @returns {void} + * @memberof BaseFileHandle + */ + setPath(p: string): void; + /** + * Getter: Get the file basename + * Setter: set the file name + * + * @returns {string} + * @memberof BaseFileHandle + */ + get filename(): string; + set filename(v: string); + /** + * Getter: Get the file cache + * Setter: set the file cache + * + * @returns {any} + * @memberof BaseFileHandle + */ + get cache(): any; + set cache(v: any); + /** + * Set data to the file cache + * + * @param {*} v data object + * @returns {BaseFileHandle} + * @memberof BaseFileHandle + */ + setCache(v: any): BaseFileHandle; + /** + * Return the object itself + * + * @returns {BaseFileHandle} + * @memberof BaseFileHandle + */ + asFileHandle(): BaseFileHandle; + /** + * Check whether the current file is the root of the file tree + * + * @returns {boolean} + * @memberof BaseFileHandle + */ + isRoot(): boolean; + /** + * Check whether the current file is a hidden file + * + * @returns {boolean} + * @memberof BaseFileHandle + */ + isHidden(): boolean; + /** + * Get hash number of the current file path + * + * @returns {number} + * @memberof BaseFileHandle + */ + hash(): number; + /** + * Convert the current file cache to Base64 * * @protected - * @memberof SystemPanelTag + * @param {string} t type of the file cache: + * - `object` + * - `mime type` + * @returns {(Promise)} promise on the converted data + * @memberof BaseFileHandle */ - protected init(): void; + protected b64(t: string): Promise; /** - * Do nothing + * Get the parent file handle of the current file + * + * @returns {BaseFileHandle} + * @memberof BaseFileHandle + */ + parent(): BaseFileHandle; + /** + * Load the file meta-data before performing + * any task + * + * @returns {Promise} a promise on file meta-data + * @memberof BaseFileHandle + */ + onready(): Promise; + /** + * Public read operation + * + * This function calls the [[_rd]] function to perform the operation. + * + * If the current file is a directory, then the operation + * will return the meta-data of all files inside of the directory. + * Otherwise, file content will be returned + * + * @param {string} t data type + * - jsonp: the response is an json object + * - script: the response is a javascript code + * - xml, html: the response is a XML/HTML object + * - text: plain text + * - binary + * + * @returns {Promise} a promise on the file content + * @memberof BaseFileHandle + */ + read(t?: string): Promise; + /** + * Write the file cache to the actual file + * + * This function calls the [[_wr]] function to perform the operation + * + * @param {string} t data type + * - `base64` + * - `object` + * - `mime type` + * + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + write(t: string): Promise; + /** + * Sub-directory creation + * + * This function calls the [[_mk]] function to perform the operation + * + * @param {string} d sub directory name + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + mk(d: string): Promise; + /** + * Delete the file + * + * This function calls the [[_rm]] function to perform the operation + * + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + remove(): Promise; + /** + * Upload a file to the current directory + * + * Only work when the current file is a directory + * + * This function calls the [[_up]] function to perform the operation + * + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + upload(): Promise; + /** + * Share the file by publish it. + * + * Only work with file + * + * This function calls the [[_pub]] function to perform the operation + * + * @returns {Promise} promise on operation result + * @memberof BaseFileHandle + */ + publish(): Promise; + /** + * Download the file. + * + * Only work with file + * + * This function calls the [[_down]] function to perform the operation + * + * @returns {Promise} Promise on the operation result + * @memberof BaseFileHandle + */ + download(): Promise; + /** + * Move the current file to another location + * + * This function calls the [[_mv]] function to perform the operation + * + * @param {string} d destination location + * @returns {Promise} promise on the operation result + * @memberof BaseFileHandle + */ + move(d: string): Promise; + /** + * Execute the current file. + * + * This action depends on each file protocol + * + * This function calls the [[_exec]] function to perform the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + execute(): Promise; + /** + * Get an accessible link to the file + * that can be accessed from the browser + * + * @returns {string} + * @memberof BaseFileHandle + */ + getlink(): string; + /** + * Helper function returns a promise on unsupported action + * + * @param {string} t action name + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected unsupported(t: string): Promise; + /** + * trigger cache changed event + * + * This function triggered when the file cached changed * * @protected + * @memberof BaseFileHandle + */ + protected _cache_changed(): void; + /** + * Low level protocol-specific read operation + * + * This function should be overridden on the file handle class + * that supports the operation + * + * @protected + * @param {string} t data type, see [[read]] + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _rd(t: string): Promise; + /** + * Low level protocol-specific write operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @protected + * @param {string} t data type, see [[write]] * @param {*} [d] - * @memberof SystemPanelTag + * @returns {Promise} + * @memberof BaseFileHandle */ - protected reload(d?: any): void; + protected _wr(t: string, d?: any): Promise; /** - * Attach a service to the system tray on the pannel, - * this operation is performed when a service is started + * Low level protocol-specific sub-directory creation * - * @param {BaseService} s - * @returns - * @memberof SystemPanelTag - */ - attachservice(s: application.BaseService): void; - /** - * Launch the selected application from the spotlight - * applications list - * - * @private - * @returns {void} - * @memberof SystemPanelTag - */ - private open; - /** - * Perform spotlight search operation on keyboard event - * - * @private - * @param {JQuery.KeyboardEventBase} e - * @returns {void} - * @memberof SystemPanelTag - */ - private search; - /** - * detach a service from the system tray of the panel. - * This function is called when the corresponding running - * service is killed - * - * @param {BaseService} s - * @memberof SystemPanelTag - */ - detachservice(s: application.BaseService): void; - /** - * Layout definition of the panel + * This function should be overridden by the file handle class + * that supports the operation * * @protected - * @returns {TagLayoutType[]} - * @memberof SystemPanelTag + * @param {string} d sub directory name + * @returns {Promise} + * @memberof BaseFileHandle */ - protected layout(): TagLayoutType[]; + protected _mk(d: string): Promise; /** - * Refresh applications list on the spotlight widget - * from system packages meta-data + * Low level protocol-specific delete operation * - * @private - * @memberof SystemPanelTag - */ - private refreshAppList; - /** - * Show/hide the spotlight + * This function should be overridden by the file handle class + * that supports the operation * - * @private - * @param {boolean} flag - * @memberof SystemPanelTag + * @returns {Promise} + * @memberof BaseFileHandle */ - private toggle; + protected _rm(): Promise; /** - * Calibrate the spotlight widget + * Low level protocol-specific move operation * - * @memberof SystemPanelTag - */ - calibrate(): void; - /** - * Refresh the pinned applications menu - * - * @private - * @memberof SystemPanelTag - */ - private RefreshPinnedApp; - /** - * Check if the loading tasks ended, - * if it the case, stop the animation - * - * @private - * @memberof SystemPanelTag - */ - private animation_check; - /** - * Mount the tag bind some basic event + * This function should be overridden by the file handle class + * that supports the operation * * @protected - * @memberof SystemPanelTag + * @param {string} d + * @returns {Promise} + * @memberof BaseFileHandle */ - protected mount(): void; + protected _mv(d: string): Promise; + /** + * Low level protocol-specific upload operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _up(): Promise; + /** + * Low level protocol-specific download operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _down(): Promise; + /** + * Low level protocol-specific execute operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _exec(): Promise; + /** + * Low level protocol-specific share operation + * + * This function should be overridden by the file handle class + * that supports the operation + * + * @returns {Promise} + * @memberof BaseFileHandle + */ + protected _pub(): Promise; + /** + * Read the current file meta-data + * + * should be implemented by subclasses + * + * @abstract + * @returns {Promise} + * @memberof BaseFileHandle + */ + abstract meta(): Promise; } + /** + * Remote file handle allows to perform file operation + * on AntOS remote server files. Its protocol is defined + * by the following pattern: + * + * ``` + * ^(home|desktop|os|Untitled)$ + * ``` + * + * @class RemoteFileHandle + * @extends {BaseFileHandle} + */ + class RemoteFileHandle extends BaseFileHandle { + /** + *Creates an instance of RemoteFileHandle. + * @param {string} path file path + * @memberof RemoteFileHandle + */ + constructor(path: string); + /** + * Read remote file meta-data + * + * @returns {Promise} + * @memberof RemoteFileHandle + */ + meta(): Promise; + /** + * Remote file access link + * + * @returns {string} + * @memberof RemoteFileHandle + */ + getlink(): string; + /** + * Read remote file content. + * + * If the current file is a directory, then the operation + * will return the meta-data of all files inside of the directory. + * Otherwise, file content will be returned + * + * @protected + * @param {string} t data type see [[read]] + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _rd(t: string): Promise; + /** + * Write file cache to the remote file + * + * @protected + * @param {string} t data type see [[write]] + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _wr(t: string): Promise; + /** + * Create sub directory + * + * Only work on directory file handle + * + * @protected + * @param {string} d sub directory name + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _mk(d: string): Promise; + /** + * Delete file/folder + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _rm(): Promise; + /** + * Move file/folder + * + * @protected + * @param {string} d + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _mv(d: string): Promise; + /** + * Upload a file + * + * Only work with directory file handle + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _up(): Promise; + /** + * Download a file + * + * only work with file + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _down(): Promise; + /** + * Publish a file + * + * @protected + * @returns {Promise} + * @memberof RemoteFileHandle + */ + protected _pub(): Promise; + } + /** + * Package file is remote file ([[RemoteFileHandle]]) located either in + * the local user packages location or system packages + * location, it should be in the following format: + * + * ``` + * pkg://PKG_NAME/path/to/file + * + * ``` + * + * The system will locale the package name PKG_NAME either in the system domain + * or in user domain and return the correct path to the package + * + * @export + * @class PackageFileHandle + * @extends {RemoteFileHandle} + */ + class PackageFileHandle extends RemoteFileHandle { + /** + *Creates an instance of PackageFileHandle. + * @param {string} pkg_path package path in string + * @memberof PackageFileHandle + */ + constructor(pkg_path: string); + } + /** + * Application file is an AntOS special file allowing to + * refer to an application as a regular file. Its protocol + * pattern is defined as: + * + * ```typescript + * "^app$" // e.g. app://Setting + * ``` + * + * @class ApplicationHandle + * @extends {BaseFileHandle} + */ + class ApplicationHandle extends BaseFileHandle { + /** + *Creates an instance of ApplicationHandle. + * @param {string} path file path + * @memberof ApplicationHandle + */ + constructor(path: string); + /** + * Read application meta-data + * + * @returns {Promise} + * @memberof ApplicationHandle + */ + meta(): Promise; + /** + * If the current file is root (e.g. `app://`), the operation + * will return all system packages meta-data. + * + * Otherwise, an error will be thrown + * + * @protected + * @param {string} t + * @returns {Promise} + * @memberof ApplicationHandle + */ + protected _rd(t: string): Promise; + } + /** + * A buffer file handle represents a virtual file that is stored + * on the system memory. Its protocol pattern is defined as: + * + * ```typescript + * "^mem$" // e.g. mem://test.txt + * ``` + * + * @class BufferFileHandle + * @extends {BaseFileHandle} + */ + class BufferFileHandle extends BaseFileHandle { + /** + *Creates an instance of BufferFileHandle. + * @param {string} path file path + * @param {string} mime file mime-type + * @param {*} data file data + * @memberof BufferFileHandle + */ + constructor(path: string, mime: string, data: any); + /** + * init the mem file tree if necessary + */ + private init_file_tree; + /** + * cache changed handle + */ + protected _cache_changed(): void; + /** + * Read the file meta-data + * + * @returns {Promise} + * @memberof BufferFileHandle + */ + meta(): Promise; + /** + * Load the file meta-data before performing + * any task + * + * @returns {Promise} a promise on file meta-data + * @memberof BufferFileHandle + */ + onready(): Promise; + /** + * Read file content stored in the file cached + * + * @protected + * @param {string} t data type see [[read]] + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _rd(t: string): Promise; + /** + * Write data to the file cache + * + * @protected + * @param {string} t data type, see [[write]] + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _wr(t: string): Promise; + /** + * Create sub directory + * + * Only work on directory file handle + * + * @protected + * @param {string} d sub directory name + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _mk(d: string): Promise; + /** + * Delete file/folder + * + * @protected + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _rm(): Promise; + setPath(p: string): void; + private updatePath; + /** + * Move file/folder + * + * @protected + * @param {string} d + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _mv(d: string): Promise; + /** + * Download the buffer file + * + * @protected + * @returns {Promise} + * @memberof BufferFileHandle + */ + protected _down(): Promise; + } + /** + * URL file handle represents a HTTP/HTTPs link url + * as an AntOS VFS file handle. Its protocol is defined as + * + * ``` + * ^(http|https|ftp)$ + * ``` + * + * @class URLFileHandle + * @extends {BaseFileHandle} + */ + class URLFileHandle extends BaseFileHandle { + /** + *Creates an instance of URLFileHandle. + * @param {string} path + * @memberof URLFileHandle + */ + constructor(path: string); + /** + * Read file meta-data + * + * @returns {Promise} + * @memberof URLFileHandle + */ + meta(): Promise; + /** + * Read URL content + * + * @protected + * @param {string} t data type see [[read]] + * @returns {Promise} + * @memberof URLFileHandle + */ + protected _rd(t: string): Promise; + } + /** + * Shared file handle represents all AntOS shared file. + * Its protocol is defined as: + * + * ``` + * ^shared$ + * ``` + * + * @class SharedFileHandle + * @extends {API.VFS.BaseFileHandle} + */ + class SharedFileHandle extends API.VFS.BaseFileHandle { + /** + *Creates an instance of SharedFileHandle. + * @param {string} path file path + * @memberof SharedFileHandle + */ + constructor(path: string); + /** + * Read file meta-data + * + * @returns {Promise} + * @memberof SharedFileHandle + */ + meta(): Promise; + /** + * Read file content + * + * @protected + * @param {string} t data type, see [[read]] + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _rd(t: string): Promise; + /** + * write data to shared file + * + * @protected + * @param {string} t data type, see [[write]] + * @param {string} d file data + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _wr(t: string, d: string): Promise; + /** + * Un-publish the file + * + * @protected + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _rm(): Promise; + /** + * Download shared file + * + * @protected + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _down(): Promise; + /** + * Un publish the file + * + * @protected + * @returns {Promise} + * @memberof SharedFileHandle + */ + protected _pub(): Promise; + } + /**Utilities global functions */ + /** + * Read a file content from a zip archive + * + * The content type should be: + * - base64 : the result will be a string, the binary in a base64 form. + * - text (or string): the result will be an unicode string. + * - binarystring: the result will be a string in “binary” form, using 1 byte per char (2 bytes). + * - array: the result will be an Array of bytes (numbers between 0 and 255). + * - uint8array : the result will be a Uint8Array. This requires a compatible browser. + * - arraybuffer : the result will be a ArrayBuffer. This requires a compatible browser. + * - blob : the result will be a Blob. This requires a compatible browser. * + * If file_name is not specified, the first file_name in the zip archive will be read + * @export + * @param {string} file zip file + * @param {string} type content type to read + * @param {string} [file_name] the file should be read from the zip archive + * @return {*} {Promise} + */ + function readFileFromZip(file: string, type: string, file_name?: string): Promise; + /** + * Cat all files to a single out-put + * + * @export + * @param {string[]} list list of VFS files + * @param {string} data input data string that will be cat to the files content + * @param {string} join_by join on files content by this string + * @return {*} {Promise} + */ + function cat(list: string[], data: string, join_by?: string): Promise; + /** + * Read all files content on the list + * + * @export + * @param {string[]} list list of VFS files + * @param {GenericObject[]} contents content array + * @return {void} + */ + function read_files(list: string[]): Promise[]>; + /** + * Copy files to a folder + * + * @export + * @param {string[]} files list of files + * @param {string} to destination folder + * @return {*} {Promise} + */ + function copy(files: string[], to: string): Promise; + /** + * Create a zip archive from a folder + * + * @export + * @param {string} src source file/folder + * @param {string} dest destination archive + * @return {*} {Promise} + */ + function mkar(src: string, dest: string): Promise; + /** + * Create a list of directories + * + * @export + * @param {string[]} list of directories to be created + * @param {boolen} sync sync/async of directory creation + * @return {*} {Promise} + */ + function mkdirAll(list: string[], sync?: boolean): Promise; + /** + * + * + * @export Extract a zip fle + * @param {string} zfile zip file to extract + * @param {(zip:any) => Promise} [dest_callback] a callback to get extraction destination + * @return {*} {Promise} + */ + function extractZip(zfile: string | API.VFS.BaseFileHandle, dest_callback: (zip: any) => Promise): Promise; + /** + * Make files from a set of template files + * + * @export + * @param {Array} list mapping paths between templates files and created files + * @param {string} path files destination + * @param {(data: string) => string} callback: pre-processing files content before writing to destination files + * @return {*} {Promise} + */ + function mktpl(list: Array, path: string, callback: (data: string) => string): Promise; } } } declare namespace OS { - namespace GUI { + /** + * This namespace is dedicated to everything related to the + * global system settings + */ + namespace setting { /** - * Tab container data type definition + * User setting type definition * * @export - * @interface TabContainerTabType + * @interface UserSettingType */ - interface TabContainerTabType { + interface UserSettingType { /** - * Reference to the DOM element of the current container + * User full name * - * @type {HTMLElement} - * @memberof TabContainerTabType + * @type {string} + * @memberof UserSettingType */ - container: HTMLElement; + name: string; + /** + * User name + * + * @type {string} + * @memberof UserSettingType + */ + username: string; + /** + * User id + * + * @type {number} + * @memberof UserSettingType + */ + id: number; + /** + * User groups + * + * @type {{ [index: number]: string }} + * @memberof UserSettingType + */ + group?: { + [index: number]: string; + }; [propName: string]: any; } - namespace tag { + /** + * Virtual desktop setting data type + * + * @export + * @interface DesktopSettingType + */ + interface DesktopSettingType { /** - * A tab container allows to attach each tab on a [[TabBarTag]] - * with a container widget. The attached container widget should be - * composed inside a [[HBoxTag]] + * Desktop VFS path * - * The tab bar in a tab container can be configured to display tabs - * in horizontal (row) or vertical (column) order. Default to vertical order - * - * Once a tab is selected, its attached container will be shown - * - * @export - * @class TabContainerTag - * @extends {AFXTag} + * @type {string} + * @memberof DesktopSettingType */ - class TabContainerTag extends AFXTag { + path: string; + /** + * Desktop menu, can be added automatically by applications + * + * @type {GUI.BasicItemType[]} + * @memberof DesktopSettingType + */ + menu: GUI.BasicItemType[]; + /** + * Show desktop hidden files + * + * @type {boolean} + * @memberof DesktopSettingType + */ + showhidden: boolean; + [propName: string]: any; + } + /** + * Wallpaper setting data type + * + * @export + * @interface WPSettingType + */ + interface WPSettingType { + /** + * Repeat wallpaper: + * - `repeat` + * - `repeat-x` + * - `repeat-y` + * - `no-repeat` + * + * @type {string} + * @memberof WPSettingType + */ + repeat: string; + /** + * Wallpaper size + * - `contain` + * - `cover` + * - `auto` + * + * @type {string} + * @memberof WPSettingType + */ + size: string; + /** + * VFS path to the wallpaper image + * + * @type {string} + * @memberof WPSettingType + */ + url: string; + } + /** + * Theme setting data type + * + * @export + * @interface ThemeSettingType + */ + interface ThemeSettingType { + /** + * Theme name, this value is used for looking + * theme file in system asset + * + * @type {string} + * @memberof ThemeSettingType + */ + name: string; + /** + * Theme user-friendly text + * + * @type {string} + * @memberof ThemeSettingType + */ + text: string; + } + /** + * Appearance setting data type + * + * @export + * @interface AppearanceSettingType + */ + interface AppearanceSettingType { + /** + * Current theme name + * + * @type {string} + * @memberof AppearanceSettingType + */ + theme: string; + /** + * All themes available in the system + * + * @type {ThemeSettingType[]} + * @memberof AppearanceSettingType + */ + themes: ThemeSettingType[]; + /** + * Current wallpaper setting + * + * @type {WPSettingType} + * @memberof AppearanceSettingType + */ + wp: WPSettingType; + /** + * All wallpapers available in the system + * + * @type {string[]} + * @memberof AppearanceSettingType + */ + wps: string[]; + } + /** + * VFS Mount points setting data type + * + * @export + * @interface VFSMountPointSettingType + */ + interface VFSMountPointSettingType { + /** + * Path to the mount point + * + * @type {string} + * @memberof VFSMountPointSettingType + */ + path: string; + /** + * User friendly mount point name + * + * @type {string} + * @memberof VFSMountPointSettingType + */ + text: string; + [propName: string]: any; + } + /** + * VFS setting data type + * + * @export + * @interface VFSSettingType + */ + interface VFSSettingType { + /** + * mount points setting + * + * @type {VFSMountPointSettingType[]} + * @memberof VFSSettingType + */ + mountpoints: VFSMountPointSettingType[]; + [propName: string]: any; + } + /** + * Global system setting data type + * + * @export + * @interface SystemSettingType + */ + interface SystemSettingType { + /** + * System error report URL + * + * @type {string} + * @memberof SystemSettingType + */ + error_report: string; + /** + * Current system locale e.g. `en_GB` + * + * @type {string} + * @memberof SystemSettingType + */ + locale: string; + /** + * System menus + * + * @type {API.PackageMetaType[]} + * @memberof API.PackageMetaType + */ + menu: API.PackageMetaType[]; + /** + * Packages meta-data + * + * @type {{ [index: string]: API.PackageMetaType }} + * @memberof SystemSettingType + */ + packages: { + [index: string]: API.PackageMetaType; + }; + /** + * Path to the installed packages + * + * @type {{ + * user: string; + * system: string; + * }} + * @memberof SystemSettingType + */ + pkgpaths: { /** - * Reference to the currently selected tab DOM element + * User specific packages install location * - * @private - * @type {TabContainerTabType} - * @memberof TabContainerTag + * @type {string} */ - private _selectedTab; + user: string; /** - * Placeholder of the tab select event handle + * System packages install location * - * @private - * @type {TagEventCallback} - * @memberof TabContainerTag + * @type {string} */ - private _ontabselect; + system: string; + }; + /** + * Package repositories setting. + * This configuration is used by [[MarketPlace]] + * for package management + * + * @type {{ + * text: string; + * url: string; + * }[]} + * @memberof SystemSettingType + */ + repositories: { /** - *Creates an instance of TabContainerTag. - * @memberof TabContainerTag + * Repository name + * + * @type {string} */ - constructor(); + text: string; /** - * Init the tab bar direction to vertical (column) + * Repository uri * - * @protected - * @memberof TabContainerTag + * @type {string} */ - protected init(): void; + url: string; + }[]; + /** + * Startup applications and services + * + * @type {{ + * apps: string[]; + * services: string[]; + * }} + * @memberof SystemSettingType + */ + startup: { /** - * Do nothing + * List of application names * - * @protected - * @param {*} [d] - * @memberof TabContainerTag + * @type {string[]} */ - protected reload(d?: any): void; + apps: string[]; /** - * Set the tab select event handle + * List of service names * - * @memberof TabContainerTag + * @type {string[]} */ - set ontabselect(f: TagEventCallback); + services: string[]; /** - * Get all tab items in the container + * List of pinned applications * - * @readonly - * @type {TabContainerTabType[]} - * @memberof TabContainerTag + * @type {string[]} */ - get tabs(): TabContainerTabType[]; - /** - * Select a tab by its index - * - * @memberof TabContainerTag - */ - set selectedIndex(i: number); - /** - * Setter: - * - * Set the tab bar direction: - * - `row`: horizontal direction - * - `column`: vertical direction - * - * Getter: - * - * Get the tab bar direction - * - * @memberof TabContainerTag - */ - set dir(v: "row" | "column"); - get dir(): "row" | "column"; - /** - * Setter: - * - * Select a tab using the its tab data type. - * This will show the attached container to the tab - * - * Getter: - * - * Get the tab data of the currently selected Tab - * - * @memberof TabContainerTag - */ - set selectedTab(v: TabContainerTabType); - get selectedTab(): TabContainerTabType; - /** - * Set the tab bar width, this function only - * works when the tab bar direction is set to - * `row` - * - * @memberof TabContainerTag - */ - set tabbarwidth(v: number); - /** - * Set the tab bar height, this function only works - * when the tab bar direction is set to `column` - * - * @memberof TabContainerTag - */ - set tabbarheight(v: number); - /** - * Add a new tab with container to the container - * - * item should be in the following format: - * - * ```ts - * { - * text: string, - * icon?: string, - * iconclass?: string, - * container: HTMLElement - * } - * ``` - * - * @param {GenericObject} item tab descriptor - * @param {boolean} insert insert the tab content to the container ? - * @returns {ListViewItemTag} the tab DOM element - * @memberof TabContainerTag - */ - addTab(item: GenericObject, insert: boolean): ListViewItemTag; - /** - * Remove a tab from the container - * - * @param {ListViewItemTag} tab the tab item to be removed - * @memberof TabContainerTag - */ - removeTab(tab: ListViewItemTag): void; - /** - * Mount the tag and bind basic events - * - * @protected - * @memberof TabContainerTag - */ - protected mount(): void; - /** - * calibrate the tab container - * - * @memberof TabContainerTag - */ - calibrate(): void; - /** - * Layout definition - * - * @protected - * @returns {TagLayoutType[]} - * @memberof TabContainerTag - */ - protected layout(): TagLayoutType[]; - } + pinned: string[]; + }; + } + /** + * User settings + */ + var user: UserSettingType; + /** + * Application settings + */ + var applications: GenericObject; + /** + * Desktop settings + */ + var desktop: DesktopSettingType; + /** + * Appearance settings + */ + var appearance: AppearanceSettingType; + /** + * VFS settings + */ + var VFS: VFSSettingType; + /** + * System settings + */ + var system: SystemSettingType; + } + /** + * Reset the system settings to default values + * + * @export + */ + function resetSetting(): void; + /** + * Apply the input parameter object to system settings. + * This object could be an object loaded from + * setting JSON file saved on the server. + * + * @export + * @param {*} conf + */ + function systemSetting(conf: any): void; +} +/// +declare namespace OS { + namespace application { + /** + * Services are processes that run in the background and + * are waken up in certain circumstances such as by global + * events or user interactions. + * + * Each service takes an entry in the system tray menu + * located on the system panel. This menu entry is used + * to access to service visual contents such as: options, + * task performing based on user interaction, etc. + * + * Services are singleton processes, there is only + * one process of a service at a time + * + * @export + * @abstract + * @class BaseService + * @extends {BaseModel} + */ + abstract class BaseService extends BaseModel { + /** + * The service icon shown in the system tray + * + * @type {string} + * @memberof BaseService + */ + icon: string; + /** + * CSS class of the service icon shown in the system tray + * + * @type {string} + * @memberof BaseService + */ + iconclass: string; + /** + * Text of the service shown in the system tray + * + * @type {string} + * @memberof BaseService + */ + text: string; + /** + * Reference to the menu entry DOM element attached + * to the service + * + * @type {HTMLElement} + * @memberof BaseService + */ + domel: HTMLElement; + /** + * Reference to the timer that periodically executes the callback + * defined in [[watch]]. + * + * @private + * @type {number} + * @memberof BaseService + */ + private timer; + /** + * Reference to the system tray menu + * + * @type {HTMLElement} + * @memberof BaseService + */ + holder: HTMLElement; + /** + * Placeholder for service select callback + * + * @memberof BaseService + */ + onmenuselect: (d: OS.GUI.TagEventType) => void; + /** + *Creates an instance of BaseService. + * @param {string} name service class name + * @param {AppArgumentsType[]} args service arguments + * @memberof BaseService + */ + constructor(name: string, args: AppArgumentsType[]); + /** + * Do nothing + * + * @memberof BaseService + */ + hide(): void; + /** + * Init the service before attaching it to + * the system tray: event subscribe, scheme + * loading. + * + * Should be implemented by all subclasses + * + * @abstract + * @memberof BaseService + */ + abstract init(): void; + /** + * Refresh the service menu entry in the + * system tray + * + * @memberof BaseService + */ + update(): void; + /** + * Get the service meta-data + * + * @returns {API.PackageMetaType} + * @memberof BaseService + */ + meta(): API.PackageMetaType; + /** + * Attach the service to a menu element + * such as the system tray menu + * + * @param {HTMLElement} h + * @memberof BaseService + */ + attach(h: HTMLElement): void; + /** + * Set the callback that will be called periodically + * after a period of time. + * + * Each service should only have at most one watcher + * + * @protected + * @param {number} t period time in seconds + * @param {() => void} f callback function + * @returns {number} + * @memberof BaseService + */ + protected watch(t: number, f: () => void): number; + /** + * This function is called when the service + * is exited + * + * @protected + * @param {BaseEvent} evt exit event + * @returns + * @memberof BaseService + */ + protected onexit(evt: BaseEvent): JQuery; + /** + * Do nothing + * + * @memberof BaseService + */ + main(): void; + /** + * Do nothing + * + * @memberof BaseService + */ + show(): void; + /** + * Awake the service, this function is usually called when + * the system tray menu entry attached to the service is + * selected. + * + * This function should be implemented by all subclasses + * + * @abstract + * @param {GUI.TagEventType} e + * @memberof BaseService + */ + abstract awake(e: GUI.TagEventType): void; + /** + * Do nothing + * + * @protected + * @param {BaseEvent} evt + * @memberof BaseService + */ + protected cleanup(evt: BaseEvent): void; } } } declare namespace OS { - namespace GUI { - namespace tag { + namespace API { + /** + * Data type exchanged via + * the global Announcement interface + * + * @export + * @interface AnnouncementDataType + */ + interface AnnouncementDataType { /** - * Definition of system file view widget + * message string * - * @export - * @class FileViewTag - * @extends {AFXTag} + * @type {string| FormattedString} + * @memberof AppAnnouncementDataType */ - class FileViewTag extends AFXTag { + message: string | FormattedString; + /** + * Process ID + * + * @type {number} + * @memberof AppAnnouncementDataType + */ + id: number; + /** + * App name + * + * @type {string | FormattedString} + * @memberof AppAnnouncementDataType + */ + name: string | FormattedString; + /** + * Icon file + * + * @type {string} + * @memberof AppAnnouncementDataType + */ + icon?: string; + /** + * App icon class + * + * @type {string} + * @memberof AppAnnouncementDataType + */ + iconclass?: string; + /** + * User specific data + * + * @type {*} + * @memberof AppAnnouncementDataType + */ + u_data?: T; + } + /** + * Observable entry type definition + * + * @export + * @interface ObservableEntryType + */ + interface ObservableEntryType { + /** + * A Set of callbacks that should be called only once. + * These callbacks will be removed after the first + * occurrence of the corresponding event + * + * @memberof ObservableEntryType + */ + one: Set<(d: any) => void>; + /** + * A Set of callbacks that should be called + * every time the corresponding event is triggered + * + * @memberof ObservableEntryType + */ + many: Set<(d: any) => void>; + } + /** + * Announcement listener type definition + * + * @export + * @interface AnnouncerListenerType + */ + interface AnnouncerListenerType { + [index: number]: { /** - * placeholder for file select event callback + * The event name * - * @private - * @type {TagEventCallback} - * @memberof FileViewTag - */ - private _onfileselect; - /** - * placeholder for file open event callback - * - * @private - * @type {TagEventCallback} - * @memberof FileViewTag - */ - private _onfileopen; - /** - * Reference to the currently selected file meta-data - * - * @private - * @type {API.FileInfoType} - * @memberof FileViewTag - */ - private _selectedFile; - /** - * Data placeholder of the current working directory - * - * @private - * @type {API.FileInfoType[]} - * @memberof FileViewTag - */ - private _data; - /** - * The path of the current working directory - * - * @private * @type {string} - * @memberof FileViewTag */ - private _path; + e: string; /** - * Header definition of the widget grid view + * The event callback * - * @private - * @type {(GenericObject[])} - * @memberof FileViewTag */ - private _header; - /** - * placeholder for the user-specified meta-data fetch function - * - * @private - * @memberof FileViewTag - */ - private _fetch; - /** - *Creates an instance of FileViewTag. - * @memberof FileViewTag - */ - constructor(); - /** - * Init the widget before mounting - * - * @protected - * @memberof FileViewTag - */ - protected init(): void; - /** - * Update the current widget, do nothing - * - * @protected - * @param {*} [d] - * @memberof FileViewTag - */ - protected reload(d?: any): void; - /** - * set the function that allows to fetch file entries. - * This handle function should return a promise on - * an arry of [[API.FileInfoType]] - * - * @memberof FileViewTag - */ - set fetch(v: (p: string) => Promise); - /** - * set the callback handle for the file select event. - * The parameter of the callback should be an object - * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] - * - * @memberof FileViewTag - */ - set onfileselect(e: TagEventCallback); - /** - set the callback handle for the file open event. - * The parameter of the callback should be an object - * of type [[TagEventType]] with the data type `T` is [[API.FileInfoType]] - * - * @memberof FileViewTag - */ - set onfileopen(e: TagEventCallback); - /** - * Setter: - * - * chang the view of the widget, there are three different views - * - `icon` - * - `list` - * - `tree` - * - * Getter: - * - * Get the current view setting of the widget - * - * @memberof FileViewTag - */ - set view(v: string); - get view(): string; - /** - * Setter: - * - * Turn on/off the changing current working directory feature - * of the widget when a directory is double clicked. If enabled, - * the widget will use the configured [[fetch]] function to query - * the content of the selected directory - * - * Getter: - * - * check whether changing current working directory feature - * is enabled - * - * @memberof FileViewTag - */ - set chdir(v: boolean); - get chdir(): boolean; - /** - * Setter : Enable or disable the status bar of the widget - * - * Getter: Check whether the status bar is enabled - * - * @memberof FileViewTag - */ - set status(v: boolean); - get status(): boolean; - /** - * Setter: - * - * Allow the widget to show or hide hidden file - * - * Getter: - * - * Check whether the hidden file should be shown in - * the widget - * - * @memberof FileViewTag - */ - set showhidden(v: boolean); - get showhidden(): boolean; - /** - * Get the current selected file - * - * @readonly - * @type {API.FileInfoType} - * @memberof FileViewTag - */ - get selectedFile(): API.FileInfoType; - /** - * Setter: - * - * Set the path of the current working directory. - * When called the widget will refresh the current - * working directory using the configured [[fetch]] - * function - * - * Getter: - * - * Get the path of the current working directory - * - * @memberof FileViewTag - */ - set path(v: string); - get path(): string; - /** - * Setter: Set the data of the current working directory - * - * Getter: Get the data of the current working directory - * - * @memberof FileViewTag - */ - set data(v: API.FileInfoType[]); - get data(): API.FileInfoType[]; - /** - * Set the file drag and drop event handle. This allows application - * to define custom behavior of the event - * - * @memberof FileViewTag - */ - set ondragndrop(v: TagEventCallback>); - /** - * Sort file by its type - * - * @private - * @param {API.FileInfoType} a - * @param {API.FileInfoType} b - * @return {*} {number} - * @memberof FileViewTag - */ - private sortByType; - /** - * sort file by its name - * - * @private - * @param {API.FileInfoType} a first file meta-data - * @param {API.FileInfoType} b second file meta-data - * @returns {number} - * @memberof FileViewTag - */ - private sortByName; - /** - * calibrate the widget layout - * - * @memberof FileViewTag - */ - calibrate(): void; - /** - * Refresh the list view of the widget. This function - * is called when the view of the widget changed to `icon` - * - * @private - * @memberof FileViewTag - */ - private refreshList; - /** - * Refresh the grid view of the widget, this function is called - * when the view of the widget set to `list` - * - * @private - * @memberof FileViewTag - */ - private refreshGrid; - /** - * Refresh the Treeview of the widget, this function is called - * when the view of the widget set to `tree` - * - * @private - * @memberof FileViewTag - */ - private refreshTree; - /** - * Create the tree data from the list of input - * file meta-data - * - * @private - * @param {API.FileInfoType[]} data list of file meta-data - * @returns {TreeViewDataType[]} - * @memberof FileViewTag - */ - private getTreeData; - /** - * Refresh data of the current widget view - * - * @private - * @returns {void} - * @memberof FileViewTag - */ - private refreshData; - /** - * Switch between three view options - * - * @private - * @memberof FileViewTag - */ - private switchView; - /** - * This function triggers the file select event - * - * @private - * @param {API.FileInfoType} e selected file meta-data - * @memberof FileViewTag - */ - private fileselect; - /** - * This function triggers the file open event - * - * @private - * @param {API.FileInfoType} e selected file meta-data - * @memberof FileViewTag - */ - private filedbclick; - /** - * Mount the widget in the DOM tree - * - * @protected - * @memberof FileViewTag - */ - protected mount(): void; - /** - * Layout definition of the widget - * - * @protected - * @returns {TagLayoutType[]} - * @memberof FileViewTag - */ - protected layout(): TagLayoutType[]; - } + f: (d: any) => void; + }[]; + } + /** + * This class is the based class used in AntOS event + * announcement system. + * It implements the observer pattern using simple + * subscribe/publish mechanism + * @export + * @class Announcer + */ + class Announcer { + /** + * The observable object that stores event name + * and its corresponding callback in [[ObservableEntryType]] + * + * @type {GenericObject} + * @memberof Announcer + */ + observable: GenericObject; + /** + * Enable/disable the announcer + * + * @type {boolean} + * @memberof Announcer + */ + enable: boolean; + /** + *Creates an instance of Announcer. + * @memberof Announcer + */ + constructor(); + /** + * Disable the announcer, when this function is called + * all events and their callbacks will be removed + * + * @returns + * @memberof Announcer + */ + disable(): boolean; + /** + * Subscribe to an event, the callback will be called + * every time the corresponding event is trigged + * + * @param {string} evtName event name + * @param {(d: any) => void} callback The corresponding callback + * @returns {void} + * @memberof Announcer + */ + on(evtName: string, callback: (d: any) => void): void; + /** + * Subscribe to an event, the callback will + * be called only once and then removed from the announcer + * + * @param {string} evtName event name + * @param {(d: any) => void} callback the corresponding callback + * @returns {void} + * @memberof Announcer + */ + one(evtName: string, callback: (d: any) => void): void; + /** + * Unsubscribe the callback from an event + * + * @param {string} evtName event name + * @param {(d: any) => void} [callback] the callback to be unsubscribed. + * When the `callback` is `*`, all callbacks related to `evtName` will be + * removed + * @memberof Announcer + */ + off(evtName: string, callback?: (d: any) => void): void; + /** + * Trigger an event + * + * @param {string} evtName event name + * @param {*} data data object that will be send to all related callback + * @returns {void} + * @memberof Announcer + */ + trigger(evtName: string, data: any): void; + } + } + /** + * This namespace defines every thing related to the system announcement. + * + * The system announcement provides a global way to communicate between + * processes (applications/services) using the subscribe/publish + * mechanism + */ + namespace announcer { + /** + * The global announcer object that manages global events + * and callbacks + */ + var observable: API.Announcer; + /** + * This variable is used to allocate the `id` of all messages + * passing between publishers and subscribers in the + * system announcement + */ + var quota: 0; + /** + * Placeholder of all global events listeners + */ + var listeners: API.AnnouncerListenerType; + /** + * Subscribe to a global event + * + * @export + * @param {string} e event name + * @param {(d: API.AnnouncementDataType) => void} f event callback + * @param {GUI.BaseModel} a the process (Application/service) related to the callback + */ + function on(e: string, f: (d: API.AnnouncementDataType) => void, a: BaseModel): void; + /** + * Trigger a global event + * + * @export + * @param {string} e event name + * @param {*} d data passing to all related callback + */ + function trigger(e: string, d: any): void; + /** + * Report system fail. This will trigger the global `fail` + * event + * + * @export + * @param {(string | FormattedString)} m message string + * @param {Error} e error to be reported + */ + function osfail(m: string | FormattedString, e: Error): void; + /** + * Report system error. This will trigger the global `error` + * event + * + * @export + * @param {(string | FormattedString)} m message string + * @param {Error} e error to be reported + */ + function oserror(m: string | FormattedString, e: Error): void; + /** + * Trigger system notification (`info` event) + * + * @export + * @param {(string | FormattedString)} m notification message + */ + function osinfo(m: string | FormattedString): void; + /** + * + * + * @export + * @param {string} e event name + * @param {(string| FormattedString)} m event message + * @param {*} [d] user data + */ + function ostrigger(e: string, m: string | FormattedString, d?: any): void; + /** + * Unregister a process (application/service) from + * the global announcement system + * + * @export + * @param {GUI.BaseModel} app reference to the process + * @returns {void} + */ + function unregister(app: BaseModel): void; + /** + * Allocate message id + * + * @export + * @returns {number} + */ + function getMID(): number; + } +} +declare namespace OS { + namespace API { + /** + * Simple Virtual Database (VDB) application API. + * + * This API abstracts and provides a standard way to + * connect to a server-side relational database (e.g. sqlite). + * + * Each user when connected has their own database previously + * created. All VDB operations related to that user will be + * performed on this database. + * + * The creation of user database need to be managed by the server-side API. + * The VDB API assumes that the database already exist. All operations + * is performed in tables level + * + * @export + * @class DB + */ + class DB { + /** + * A table name on the user's database + * + * @private + * @type {string} + * @memberof DB + */ + private table; + /** + *Creates an instance of DB. + * @param {string} table table name + * @memberof DB + */ + constructor(table: string); + /** + * Save data to the current table. The input + * data must conform to the table record format. + * + * On the server side, if the table doest not + * exist yet, it should be created automatically + * by inferring the data structure of the input + * object + * + * @param {GenericObject} d data object represents a current table record + * @returns {Promise} + * @memberof DB + */ + save(d: GenericObject): Promise; + /** + * delete record(s) from the current table by + * a conditional object + * + * @param {*} c conditional object, c can be: + * + * * a `number`: the operation will delete the record with `id = c` + * * a `string`: The SQL string condition that selects record to delete + * * a conditional object represents a SQL condition statement as an object, + * example: `pid = 10 AND cid = 2` is represented by: + * + * ```typescript + * { + * exp: { + * "and": { + * pid: 10, + * cid: 2 + * } + * } + * ``` + * + * @returns {Promise} + * @memberof DB + */ + delete(c: GenericObject | number | string): Promise; + /** + * Get a record in the table by its primary key + * + * @param {number} id the primary key value + * @returns {Promise>} Promise on returned record data + * @memberof DB + */ + get(id: number): Promise>; + /** + * Find records by a condition + * + * @param {GenericObject} cond conditional object + * + * a conditional object represents a SQL condition statement as an object, + * example: `pid = 10 AND cid = 2 ORDER BY date DESC` is represented by: + * + * ```typescript + * { + * exp: { + * "and": { + * pid: 10, + * cid: 2 + * } + * }, + * order: { + * date: "DESC" + * } + * } + * ``` + * @returns {Promise[]>} + * @memberof DB + */ + find(cond: GenericObject): Promise[]>; } } } +declare namespace OS { + /** + * This namespace dedicated to all operations related to system + * process management + */ + namespace PM { + /** + * A process is either an instance of an application or a service + */ + type ProcessType = application.BaseApplication | application.BaseService; + /** + * Alias to all classes that extends [[BaseModel]] + */ + type ModelTypeClass = { + new (args: AppArgumentsType[]): T; + }; + /** + * Process id allocator, when a new process is created, the value of + * this variable is increased + */ + var pidalloc: number; + /** + * All running processes is stored in this variables + */ + /** + * Current active process ID + */ + var pidactive: number; + var processes: GenericObject; + /** + * Create a new process of application or service + * + * @export + * @param {string} app class name string + * @param {ProcessTypeClass} cls prototype class + * @param {GUI.AppArgumentsType[]} [args] process arguments + * @returns {Promise} a promise on the created process + */ + function createProcess(app: string, cls: ModelTypeClass, args?: AppArgumentsType[]): Promise; + /** + * Get the reference to a process using its id + * + * @export + * @param {number} pid + * @returns {BaseModel} + */ + function appByPid(pid: number): BaseModel; + /** + * Kill a process + * + * @export + * @param {OS.GUI.BaseModel} app reference to the process + * @returns {void} + */ + function kill(app: BaseModel): void; + /** + * Kill all process of an application or service + * + * @export + * @param {string} app process class name + * @param {boolean} force force exit all process + * @returns {void} + */ + function killAll(app: string, force: boolean): void; + /** + * Get the current active application + * @export + * @returns {BaseModel} + */ + function getActiveApp(): BaseModel; + } +}