antosdk-apps/libantosdk/build/debug/core/ts/antos.d.ts

10504 lines
346 KiB
TypeScript
Raw Normal View History

2021-04-21 11:37:58 +02:00
declare namespace OS {
2022-07-17 14:13:44 +02:00
namespace API {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Interface for user login data
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @interface UserLoginType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
interface UserLoginType {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The user credential
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof UserLoginType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
username: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The user password
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof UserLoginType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
password: string;
2021-04-21 11:37:58 +02:00
}
/**
2022-07-17 14:13:44 +02:00
* Interface for a command sent to
* server side package manage, it contains two field:
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @interface PackageCommandType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
interface PackageCommandType {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Command name, should be: `init`, `cache`, `install`,
* `uninstall` or `list`
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof PackageCommandType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
command: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Parameter object of each command
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @type {GenericObject<any>}
2022-07-17 14:13:44 +02:00
* @memberof PackageCommandType
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
args: GenericObject<any>;
2021-04-21 11:37:58 +02:00
}
/**
2022-07-17 14:13:44 +02:00
*
* 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
* }
* ```
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @interface RequestResult
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
interface RequestResult {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Indicate whether the response is error
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {(boolean | string)}
* @memberof RequestResult
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
error: boolean | string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The response result, this value must be
* set when `error` is false
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {(string
* | boolean
* | GenericObject<any>
* | any[]
* | FileInfoType
* | FileInfoType[]
* | setting.UserSettingType)}
* @memberof RequestResult
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
result: string | boolean | GenericObject<any> | 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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Base URI for reading content of VFS file
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
var get: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Base URI for VFS file sharing
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
var shared: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Send a request to the server-side API for a directory scanning
* operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {string} p a VFS file path e.g. home://test/
* @returns {Promise<RequestResult>} A promise on a [[RequestResult]]
* which contains an error or a list of FileInfoType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function scandir(p: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
*
2022-07-17 14:13:44 +02:00
* Send a request to the server-side API for directory creation
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {string} p VFS path of the directory to be created
* @returns {Promise<RequestResult>} A promise on a RequestResult
* which contains an error or true on success
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function mkdir(p: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {string} p VFS file path to be shared
* @param {boolean} pub flag: share (true) or unshare (false)
* @returns {Promise<RequestResult>} A promise on a RequestResult
* which contains an error or true on success
*/
function sharefile(p: string, pub: boolean): Promise<RequestResult>;
/**
* Get VFS file meta-data
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {string} p VFS file path
* @returns {Promise<RequestResult>} A promise on a [[RequestResult]]
* which contains an error or an object of FileInfoType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function fileinfo(p: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @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
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<any>} A promise on a [[RequestResult]]
* which contains an error or an object of [[FileInfoType]]
*/
function readfile(p: string, t: string): Promise<any>;
/**
* Move a file to another location on server-side
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} s VFS source file path
* @param {string} d VFS destination file path
* @returns {Promise<RequestResult>} A promise on a [[RequestResult]]
* which contains an error or a success response
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function move(s: string, d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Delete a VFS file on the server-side
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} p VFS file path
* @returns {Promise<RequestResult>} A promise on a [[RequestResult]]
* which contains an error or a success response
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function remove(p: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Read the file as binary data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {string} p VFS file to be read
* @returns {Promise<ArrayBuffer>} a Promise on an array buffer
*/
function fileblob(p: string): Promise<ArrayBuffer>;
/**
* Send a command to the serverside package manager
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {PackageCommandType} d a package command of type PackageCommandType
* @returns {Promise<RequestResult>} a promise on a [[RequestResult]]
*/
function packages(d: PackageCommandType): Promise<RequestResult>;
/**
* Upload file to the server via VFS interface
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {string} d VFS destination directory path
* @returns {Promise<RequestResult>} a promise on a [[RequestResult]]
*/
function upload(d: string): Promise<RequestResult>;
/**
* Write Base 64 encoded data to a VFS file
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} p path to the VFS file
* @param {string} d file data encoded in Base 64
* @returns {Promise<RequestResult>} a promise on a [[RequestResult]]
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function write(p: string, d: string): Promise<RequestResult>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {GenericObject<any>} 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:
2021-11-24 22:47:49 +01:00
*
* {
2022-07-17 14:13:44 +02:00
* path: [VFS path],
* parameters: [parameters of the server-side script]
2021-11-24 22:47:49 +01:00
* }
*
2022-07-17 14:13:44 +02:00
* or, execute directly a snippet of server-side script:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* { code: [server-side script code snippet as string] }
2021-11-24 22:47:49 +01:00
*
* ```
*
2022-07-17 14:13:44 +02:00
* @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<any>} a promise on the result object (any)
*/
function apigateway(d: GenericObject<any>, ws: boolean): Promise<any>;
/**
* Check if a user is logged in
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>} a promise on a [[RequestResult]] that
* contains an error or a [[UserSettingType]] object
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function auth(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Perform a login operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {UserLoginType} d user data [[UserLoginType]]
* @returns {Promise<RequestResult>} a promise on a [[RequestResult]] that
* contains an error or a [[UserSettingType]] object
*/
function login(d: UserLoginType): Promise<RequestResult>;
/**
* Perform a logout operation
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>} a promise on a [[RequestResult]]
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function logout(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Save the current user settings
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>} a promise on a [[RequestResult]]
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function setting(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This is the low level function of AntOS VDB API.
* It requests the server API to perform some simple
* SQL query.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @param {string} cmd action to perform: save, delete, get, select
* @param {GenericObject<any>} d data object of the request based on each action:
* - save:
2021-04-21 11:37:58 +02:00
* ```
2022-07-17 14:13:44 +02:00
* { table: "table name", data: [record data object]}
2021-11-24 22:47:49 +01:00
* ```
2022-07-17 14:13:44 +02:00
* - get:
2021-11-24 22:47:49 +01:00
* ```
2022-07-17 14:13:44 +02:00
* { table: "table name", id: [record id]}
2021-11-24 22:47:49 +01:00
* ```
2022-07-17 14:13:44 +02:00
* - delete:
* ```
* { table: "table name", id: [record id]}
* or
* { table: "table name", cond: [conditional object]}
* ```
* - select:
* ```
* { table: "table name", cond: [conditional object]}
* ```
* @returns {Promise<RequestResult>} a promise of [[RequestResult]] on the
* query data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* 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"
* }
* }
* ```
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function dbquery(cmd: string, d: GenericObject<any>): Promise<RequestResult>;
2021-11-24 22:47:49 +01:00
}
}
}
declare namespace OS {
namespace GUI {
/**
2022-07-17 14:13:44 +02:00
* the SubWindow class is the abstract prototype of all
* modal windows or dialogs definition in AntOS
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @abstract
* @class SubWindow
* @extends {BaseModel}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
abstract class SubWindow extends BaseModel {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder indicates whether the sub window is in
* modal mode. This value is reserver for future use
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {boolean}
* @memberof SubWindow
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
modal: boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the parent of the current sub-window
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {(BaseModel | typeof GUI)}
* @memberof SubWindow
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
parent: BaseModel | typeof GUI;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of SubWindow.
* @param {string} name SubWindow (class) name
* @memberof SubWindow
*/
constructor(name: string);
/**
* Exit the sub-window
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof SubWindow
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
quit(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Init the sub-window, this function is called
* on creation of the sub-window object. It is used
* to render the sub-window UI.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Need to be implemented by subclasses
*
*
* @returns {void}
* @memberof BaseDialog
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
init(): void;
/**
* Main entry point after rendering of the sub-window
*
* @abstract
* @memberof SubWindow
*/
abstract main(): void;
/**
* Return the parent meta-data of the current
* sub-window
*
* @returns {API.PackageMetaType}
* @memberof SubWindow
*/
meta(): API.PackageMetaType;
/**
* Show the sub-window
*
* @memberof SubWindow
*/
show(): void;
/**
* Hide the sub-window
*
* @returns {void}
* @memberof SubWindow
*/
hide(): void;
/**
* blur the sub-window
*
* @returns {void}
* @memberof SubWindow
*/
blur(): void;
2021-04-21 11:37:58 +02:00
}
/**
2022-07-17 14:13:44 +02:00
* Abstract prototype of all AntOS dialogs widget
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @abstract
* @class BaseDialog
* @extends {SubWindow}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
abstract class BaseDialog extends SubWindow {
/**
* Placeholder for the dialog callback on exit
*
* @memberof BaseDialog
*/
handle: (d: any) => void;
/**
* Placeholder of the dialog input data
*
* @type {GenericObject<any>}
* @memberof BaseDialog
*/
data: GenericObject<any>;
/**
*Creates an instance of BaseDialog.
* @param {string} name Dialog (class) name
* @memberof BaseDialog
*/
constructor(name: string);
/**
* Function called when dialog exits
*
* @protected
* @param {BaseEvent} _e
* @returns {void}
* @memberof BaseDialog
*/
protected onexit(_e: BaseEvent): void;
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* A basic dialog renders a dialog widget using the UI
* scheme provided in it constructor or defined in its
* class variable `scheme`
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class BasicDialog
* @extends {BaseDialog}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
class BasicDialog extends BaseDialog {
/**
* Placeholder for the UI scheme to be rendered. This can
* be either the string definition of the scheme or
* the VFS file handle of the scheme file
*
* @protected
* @type {(string | OS.API.VFS.BaseFileHandle)}
* @memberof BasicDialog
*/
protected markup: string | OS.API.VFS.BaseFileHandle;
/**
* If the `markup` variable is not provided, then
* the [[init]] function will find the scheme definition
* in this class variable
*
* @static
* @type {string}
* @memberof BasicDialog
*/
static scheme: string;
/**
*Creates an instance of BasicDialog.
* @param {string} name dialog name
* @param {(string | OS.API.VFS.BaseFileHandle)} [markup] UI scheme definition
* @memberof BasicDialog
*/
constructor(name: string, markup?: string | OS.API.VFS.BaseFileHandle);
/**
* Render the dialog using the UI scheme provided by either
* the `markup` instance variable or the `scheme` class variable
*
* @returns {void}
* @memberof BasicDialog
*/
init(): void;
/**
* Main entry point for the dialog
*
* @memberof BasicDialog
*/
main(): void;
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The namespace `dialogs` is dedicated to all Dialog definition
* in AntOS
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
namespace dialogs {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Simple prompt dialog to get user input text.
* The input data of the dialog:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* ```typescript
* {
* title: string, // window title
* label: string, // label text
* value: string, // user input text
* type: string // input type: text or password
* }
* ```
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* The data passing from the dialog to the callback function is
* in the string text of the user input value
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class PromptDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class PromptDialog extends BasicDialog {
/**
*Creates an instance of PromptDialog.
* @memberof PromptDialog
*/
constructor();
/**
* Main entry point
*
* @memberof PromptDialog
*/
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A text dialog is similar to a [[PromptDialog]] nut allows
* user to input multi-line text.
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Refer to [[PromptDialog]] for the definition of input and callback data
* of the dialog
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class TextDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class TextDialog extends BasicDialog {
/**
*Creates an instance of TextDialog.
* @memberof TextDialog
*/
constructor();
/**
* Main entry point
*
* @memberof TextDialog
*/
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A Calendar dialog allows user to select a date
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Input data:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* ```typescript
* {
* title: string // window title
* }
* ```
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class CalendarDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class CalendarDialog extends BasicDialog {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Creates an instance of CalendarDialog.
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Callback data: a Date object represent the selected date
*
*
* @memberof CalendarDialog
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
constructor();
2021-11-24 22:47:49 +01:00
/**
*
2022-07-17 14:13:44 +02:00
*
* @memberof CalendarDialog
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Color picker dialog
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Input data:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* ```typescript
* {
* title: string // window title
* }
* ```
* Callback data: [[ColorType]] object
*
* @export
* @class ColorPickerDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class ColorPickerDialog extends BasicDialog {
/**
*Creates an instance of ColorPickerDialog.
* @memberof ColorPickerDialog
*/
constructor();
/**
*
*
* @memberof ColorPickerDialog
*/
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Show key-value pair of the input object
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Input data:
*
* ```typescript
* {
* title: string, // window title
* [propName:string]: any
* }
* ```
*
* No data for callback
*
* @export
* @class InfoDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class InfoDialog extends BasicDialog {
/**
*Creates an instance of InfoDialog.
* @memberof InfoDialog
*/
constructor();
/**
*
*
* @memberof InfoDialog
*/
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A simple confirm dialog
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Input data:
*
* ```typescript
* {
* title: string, // window title
* icon?: string, // label icon
* iconclass?: string, // label iconclass
* text: string // label text
* }
* ```
*
* Callback data: `boolean`
*
* @export
* @class YesNoDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class YesNoDialog extends BasicDialog {
/**
*Creates an instance of YesNoDialog.
* @memberof YesNoDialog
*/
constructor();
/**
* Main entry point
*
* @memberof YesNoDialog
*/
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A selection dialog provide user with a list of options to
* select.
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Input data:
*
* ```typescript
* {
* title: string, // window title
* data:
* {
* text: string,
* [propName:string]: any
* } [] // list data
* ```
*
* Callback data: the selected data in the input list
*
* @export
* @class SelectionDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class SelectionDialog extends BasicDialog {
/**
*Creates an instance of SelectionDialog.
* @memberof SelectionDialog
*/
constructor();
/**
* Main entry
*
* @memberof SelectionDialog
*/
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* An About dialog is dedicated to show the parent
* application meta-data
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Input data: no
*
* Callback data: no
*
* @export
* @class AboutDialog
* @extends {BasicDialog}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class AboutDialog extends BasicDialog {
/**
*Creates an instance of AboutDialog.
* @memberof AboutDialog
*/
constructor();
/**
* Main entry point
*
* @returns {void}
* @memberof AboutDialog
*/
main(): void;
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* File dialog allows user to select a file/folder
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Input data:
*
* ```typescript
* {
* title: string, // window title
* root?: string, // the root path folder of the file view
* type?: "file"|"dir"|"app", // file type to be selected
* mimes?: string[], // mime types of file to be selected
* hidden?: boolean, // show/hide hidden file
* file?: string // file name
*
* }
* ```
*
* Callback data:
*
* ```typescript
* {
* file: string, // selected file path
* name: string // user input file name
* }
* ```
*
* @export
* @class FileDialog
* @extends {BasicDialog}
*/
class FileDialog extends BasicDialog {
/**
*Creates an instance of FileDialog.
* @memberof FileDialog
*/
constructor();
/**
* Store the last opened directory
*
* @static
* @type {string}
* @memberof FileDialog
*/
static last_opened: string;
/**
*
*
* @returns {void}
* @memberof FileDialog
*/
main(): void;
}
/**
* Generic & dynamic key-value dialog. The content
* of the dialog consist of an array of label and input elements
* which are generated based on the input model
*
* The input data of the dialog should be:
*
* ```typescript
* {
* title: string, // window title
* model: {
* [propName:string]: string
* },
* data: {
* [propName:string]: string
* },
* allow_empty: boolean
* }
* ```
* Where:
* - keys of `model` are data fields, each key correspond to an input element
* - values of `model` are description texts of fields, each value correspond to a label text
* - data is the input data object in the format of model (optional)
*
* ```
* Example:
* {
* title: "Greeting",
* model: {
* name: "Your name",
* email: "Your email"
* },
* allow_empty: false
* }
*```
* The data passing from the dialog to the callback function is
* the user input data corresponding to the input model
*
* Example of callback data for the above model:
*
* ```
* {
* name: "John Doe",
* email: "jd@mail.com"
* }
* ```
*
* @export
* @class MultiInputDialog
* @extends {BasicDialog}
*/
class MultiInputDialog extends BasicDialog {
/**
* References to all the input fields in the
* dialog
*
* @private
* @type {HTMLElement[]}
* @memberof MultiInputDialog
*/
private inputs;
/**
*Creates an instance of MultiInputDialog.
* @memberof MultiInputDialog
*/
constructor();
/**
* Generate the scheme before rendering
*
* @memberof MultiInputDialog
*/
init(): void;
/**
* Main entry point
*
* @memberof MultiInputDialog
*/
main(): void;
}
/**
* Generic dynamic key-value dialog
*
* Allow user to input any data key-value based object:
*
* {
* [prop:string]: string;
* }
*
* @export
* @class KeyValueDialog
* @extends {BasicDialog}
*/
class KeyValueDialog extends BasicDialog {
/**
* Reference to the form container
*
* @private
* @type {HTMLDivElement}
* @memberof KeyValueDialog
*/
private container;
/**
* Creates an instance of KeyValueDialog.
* @memberof KeyValueDialog
*/
constructor();
/**
* Main entry point
*
* @memberof KeyValueDialog
*/
main(): void;
/**
* Add new input key-value field to the dialog
*
* @private
* @memberof KeyValueDialog
*/
private addField;
}
}
}
}
/// <reference types="jquery" />
declare namespace OS {
/**
* This namespace is dedicated to all APIs related to AntOS UI system,
* these API are called AFX APIs which handle:
* - The mouse and keyboard interaction with the UI system
* - UI rendering
* - Custom tags definition
* - Load/unload system, applications and services UI
* - System dialogs definition
*/
namespace GUI {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* AntOS keyboard shortcut type definition
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @interface ShortcutType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
interface ShortcutType {
/**
* Placeholder for all shortcut callbacks, example:
* ```typescript
* fn_193462204.c = function() {..}
* // this function will be called when the hotkey `ALT-C` is triggered
* // fn_${"ALT".hash()} is fn_193462204
* ```
*
* @memberof ShortcutType
*/
[propName: string]: GenericObject<(e: JQuery.KeyDownEvent) => void>;
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Basic item type definition which is usually used by some UI element
* such as list view, tree view, menu and grid view
2021-04-21 11:37:58 +02:00
*
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @interface BasicItemType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
interface BasicItemType {
/**
* Item text
*
* @type {(string | FormattedString)}
* @memberof BasicItemType
*/
text: string | FormattedString;
/**
* Item children, usually used by tree view or menu item
* This property is keep for compatibility purposes only.
* Otherwise, the [[nodes]] property should be used
*
* @type {BasicItemType[]}
* @memberof BasicItemType
*/
children?: BasicItemType[];
/**
* Item children, usually used by tree view or menu item
*
* @type {BasicItemType[]}
* @memberof BasicItemType
*/
nodes?: BasicItemType[];
[propName: string]: any;
}
/**
* Element id of the virtual desktop, used by JQuery
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
var workspace: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Indicate whether the system is in fullscreen mode
*/
var fullscreen: boolean;
/**
* Reference to the current system dialog, only one dialog
* is allowed at a time. A dialog may have sub dialog
*/
var dialog: BaseDialog;
/**
* Convert an application html scheme to
* UI elements, then insert this UI scheme to the DOM tree.
*
* This function renders the UI of the application before calling the
* application's [[main]] function
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {string} html html scheme string
* @param {BaseModel} app reference to the target application
* @param {(Element | string)} parent
* The parent HTML element where the application is rendered.
* This is usually the reference to the virtual desktop element.
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function htmlToScheme(html: string, app: BaseModel, parent: Element | string): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Load an application scheme file then render
* it with [[htmlToScheme]]
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {string} path VFS path to the scheme file
* @param {BaseModel} app the target application
* @param {(HTMLElement | string)} parent The parent HTML element where the application is rendered.
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function loadScheme(path: string, app: BaseModel, parent: HTMLElement | string): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Clear the current system theme
*
* @export
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function clearTheme(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Load a theme based on its name, then refresh the
* system UI theme
*
* @export
* @param {string} name name of the theme e.g. `antos_dark`
* @param {boolean} force force to clear the system theme before applying the new one
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function loadTheme(name: string, force: boolean): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get the system dock tag
*
* @export
* @return {*} {GUI.tag.AppDockTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function systemDock(): GUI.tag.AppDockTag;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get the current virtual desktop
*
* @export
* @return {*} {GUI.tag.DesktopTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function desktop(): GUI.tag.DesktopTag;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Open a system dialog.
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {(BaseDialog | string)} d a dialog object or a dialog class name
* @param {GenericObject<any>} [data] input data of the dialog, refer to each
* dialog definition for the format of the input data
* @returns {Promise<any>} A promise on the callback data of the dialog, refer
* to each dialog definition for the format of the callback data
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function openDialog(d: string | BaseDialog, data: GenericObject<any>): Promise<any>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Find a list of applications that support a specific mime
* type in the system packages meta-data
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {string} mime the mime type
* @returns {API.PackageMetaType[]}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function appsByMime(mime: string): API.PackageMetaType[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Find all applications that have services attached to it.
* This function allows to collect all the services available
* on the system. These services may or may not be running.
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @returns {GenericObject<API.PackageMetaType>} result in forme of:
* `service_name:service-meta-data` key-value pairs
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function appsWithServices(): GenericObject<API.PackageMetaType>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Find an launch an application using input application argument
* such as VFS file meta-data.
*
* Based on the input application argument, the function will try
* to find all applications that is compatible with that argument.
* Three cases possible:
* - There is no application that can handle the argument, a message will
* be notified to user.
* - There is one application that can handle the argument, the application
* will be launched with the argument
* - There are many applications that can handle the arguments, a selection
* dialog will be popped up and allows user to select an application to launch.
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {AppArgumentsType} it application argument
2021-04-21 11:37:58 +02:00
* @returns {void}
*/
2022-07-17 14:13:44 +02:00
function openWith(it: AppArgumentsType): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Kil all processes related to an application, reload the application
* prototype definition and launch a new process of this application.
*
* This function is used only for debug purpose or used by
* AntOSDK during in-browser application development
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {string} app the application class name
* @param {AppArgumentsType[]} args application arguments
* @returns {void}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function forceLaunch(app: string, args: AppArgumentsType[]): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Kill an running processes of an application, then
* unregister the application prototype definition
* from the [[application]] namespace.
*
* This process is similar to uninstall the application
* from the current system state
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @param {string} app
2021-04-21 11:37:58 +02:00
*/
2022-08-25 01:36:48 +02:00
function unloadApp(app: string, save?: boolean): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Create a service process.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Services are singleton processes, there is only
* one process of a service at a time
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} ph
* @returns {Promise<PM.ProcessType>}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function pushService(ph: string): Promise<PM.ProcessType>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Synchronously start a list of services
*
* @export
* @param {string[]} srvs list of service class names
* @returns {Promise<void>}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function pushServices(srvs: string[]): Promise<void>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Launch an application with arguments
*
* @export
* @param {string} app application class name
* @param {AppArgumentsType[]} args application arguments
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function launch(app: string, args: AppArgumentsType[]): Promise<OS.PM.ProcessType>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Dock an application to the system application dock
*
* @export
* @param {BaseApplication} app reference to the application process
* @param {API.PackageMetaType} meta Application meta-data
* @returns {void}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function dock(app: OS.application.BaseApplication, meta: API.PackageMetaType): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Toggle system fullscreen
*
* @export
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function toggleFullscreen(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Remove an application process from the system application
* dock. This action will also exit the process
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {BaseApplication} app
* @returns
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function undock(app: application.BaseApplication): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Attach a running service process to the system tray
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {BaseService} srv reference to the running service process
* @returns {void}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function attachservice(srv: application.BaseService): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Detach a running process from the system tray
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {BaseService} srv reference to the running service process
* @returns {void}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function detachservice(srv: application.BaseService): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Register a hot key and its handle in the
* system shortcut
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} k the hotkey e.g. `ALT-C`
* @param {(e: JQuery.KeyPressEvent) => void} f handle function
* @param {boolean} force force to rebind the hotkey
* @returns {void}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function bindKey(k: string, f: (e: JQuery.KeyDownEvent) => void, force?: boolean): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Load and apply system wallpaper from the setting object
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {setting.WPSettingType} obj wallpaper setting object
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function wallpaper(obj?: setting.WPSettingType): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Refresh the virtual desktop
2021-04-21 11:37:58 +02:00
*
* @export
*/
2022-07-17 14:13:44 +02:00
function refreshDesktop(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Show the login screen and perform the login operation.
*
* Once login successfully, the [[startAntOS]] will be called
2021-04-21 11:37:58 +02:00
*
* @export
*/
2022-07-17 14:13:44 +02:00
function login(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Start AntOS after a successful login.
*
* This function performs the following operations:
*
* - System cleanup
* - Apply system setting
* - Load desktop wallpaper and the current theme from the system setting
* - Load system package meta-data
* - Load and apply system locale and language
*
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {*} conf
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function startAntOS(conf: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* HTML schemes used by the system:
* - The login screen scheme
* - The workspace including:
* - System panel
* - Virtual desktop
* - Context menu
* - System tooltip
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
const schemes: GenericObject<string>;
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
}
/**
* Reference to the global this
*/
declare const Ant: typeof globalThis;
/**
* Extend the String prototype with some API
* functions used by AntOS API
*
* @interface String
*/
interface String {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Simple string hash function
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {number}
* @memberof String
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
hash(): number;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Parse the current string and convert it
* to an object of type [[Version]] if the string
* is in the format recognized by [[Version]],
* e.g.: `1.0.1-a`
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {OS.Version}
* @memberof String
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
__v(): OS.Version;
/**
* Convert the current string to base 64 string
*
* @returns {string}
* @memberof String
*/
asBase64(): string;
/**
* Unescape all escaped characters on the
* string using `\`
*
* @returns {string}
* @memberof String
*/
unescape(): string;
/**
* Escape the current string using backslash
*
* @returns {string}
* @memberof String
*/
escape(): string;
/**
* Convert the current string to uint8 array
*
* @returns {Uint8Array}
* @memberof String
*/
asUint8Array(): Uint8Array;
/**
* Format the current using input parameters.
* The current string should be a formatted string
* in the following form:
*
* ```typescript
* "example string: {0} and {1}".format("hello", "world")
* // return "example string: hello and world"
* ```
*
* @param {...any[]} args
* @returns {string}
* @memberof String
*/
format(...args: any[]): string;
/**
* Create a [[FormattedString]] object using the current
* string and the input parameters
*
* @param {...any[]} args
* @returns {OS.FormattedString}
* @memberof String
*/
f(...args: any[]): OS.FormattedString;
/**
* Check if the current string is translatable, if it
* is the case, translate the string to the language specified
* in the current system locale setting.
*
* A translatable string is a string in the following
* form: `"__(example string)"`
*
* @returns {string}
* @memberof String
*/
__(): string;
/**
* Translate current string to the language specified
* by the system locale setting
*
* @returns {string}
* @memberof String
*/
l(): string;
/**
* Trim left of a string by a mask string
*
* @param {string} arg specifies a sub-string to be removed
* @returns {string}
* @memberof String
*/
trimFromLeft(arg: string): string;
/**
* Trim right of a string by a mask string
*
* @param {string} arg specifies a sub-string to be removed
* @returns {string}
* @memberof String
*/
trimFromRight(arg: string): string;
/**
* Trim both left and right of a string by a mask string
*
* @param {string} arg specifies a sub-string to be removed
* @returns {string}
* @memberof String
*/
trimBy(arg: string): string;
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
/**
* Extend the Data prototype with the
* [[timestamp]] function
*
* @interface Date
*/
interface Date {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Return the timestamp of the current Date object
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @returns {number}
* @memberof Date
*/
timestamp(): number;
/**
* Covnert to GMTString
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @returns {number}
* @memberof Date
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
toGMTString(): string;
}
/**
* Generic key-value pair object interface
*
* @interface GenericObject
* @template T
*/
interface GenericObject<T> {
[index: string]: T;
2021-11-24 22:47:49 +01:00
}
2022-07-17 14:13:44 +02:00
/**
* Global function to create a [[FormattedString]] from
* a formatted string and a list of parameters. Example
*
* ```typescript
* __("hello {0}", world) // return a FormattedString object
* ```
*
* @param {...any[]} args
* @returns {(OS.FormattedString | string)}
*/
declare function __(...args: any[]): OS.FormattedString | string;
/**
* This global function allow chaining stack trace from one error to
* another. It is particular helping when tracking the source of
* the error in promises chain which results in some obfuscated stack
* traces as the stack resets on every new promise.
*
* @param {Error} e
* @returns {Error}
*/
declare function __e(e: Error): Error;
/**
* This namespace is the main entry point of AntOS
* API
*/
2021-11-24 22:47:49 +01:00
declare namespace OS {
2022-07-17 14:13:44 +02:00
/**
* Represent a translatable formatted string
*
* @export
* @class FormattedString
*/
class FormattedString {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Format string in the following form
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* ```typescript
* "format string with {0} and {1}"
* // {[0-9]} is the format pattern
* ```
*
* @type {string}
* @memberof FormattedString
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
fs: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The value of the format pattern represented
* in [[fs]]
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {any[]}
* @memberof FormattedString
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
values: any[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Creates an instance of FormattedString.
* @param {string} fs format string
* @param {any[]} args input values of the format patterns
* @memberof FormattedString
2021-11-24 22:47:49 +01:00
*/
constructor(fs: string, args: any[]);
/**
* Convert FormattedString to String
*
* @returns {string}
* @memberof FormattedString
*/
toString(): string;
/**
* Translate the format string to the current system
* locale language, format the string with values and
* then converted it to normal `string`
*
* @returns {string}
* @memberof FormattedString
*/
__(): string;
/**
* Return the hash number of the formatted string
*
* @returns {number}
* @memberof FormattedString
*/
hash(): number;
/**
* Match the formatted string against a regular expression
* a string pattern
*
* @param {(string | RegExp)} t string or regular expression
* @returns {RegExpMatchArray}
* @memberof FormattedString
*/
match(t: string | RegExp): RegExpMatchArray;
/**
* Convert the formatted string to Base^$
*
* @returns {string}
* @memberof FormattedString
*/
asBase64(): string;
/**
* Un escape the formatted string
*
* @returns {string}
* @memberof FormattedString
*/
unescape(): string;
/**
* Escape the formatted string
*
* @returns {string}
* @memberof FormattedString
*/
escape(): string;
/**
* Convert the formatted string to uint8 array
*
* @returns {Uint8Array}
* @memberof FormattedString
*/
asUint8Array(): Uint8Array;
/**
* Input values for the format string
*
* @param {...any[]} args
* @memberof FormattedString
*/
format(...args: any[]): void;
}
/**
* This class represents the Version number format used by AntOS. A typical
* AntOS version number is in the following format:
*
* ```
2022-08-25 01:36:48 +02:00
* [major_number].[minor_number].[patch]-[branch]-[build ID])
2021-11-24 22:47:49 +01:00
*
2022-08-25 01:36:48 +02:00
* e.g.: 1.2.3-r-b means that:
2021-11-24 22:47:49 +01:00
* - version major number is 1
* - version minor number is 2
* - patch version is 3
* - the current branch is release `r`
2022-08-25 01:36:48 +02:00
* - build ID (optional)
2021-11-24 22:47:49 +01:00
* ```
*
* @export
* @class Version
*/
class Version {
/**
* The version string
*
2022-08-25 01:36:48 +02:00
* @private
2021-11-24 22:47:49 +01:00
* @type {string}
* @memberof Version
*/
2022-08-25 01:36:48 +02:00
private string;
2021-11-24 22:47:49 +01:00
/**
* The current branch
* - 1: `a` - alpha branch
* - 2: `b` - beta branch
* - 3: `r` - release branch
*
* @private
* @type {number}
* @memberof Version
*/
private branch;
/**
* Version major number
*
* @type {number}
* @memberof Version
*/
major: number;
/**
* Version minor number
*
* @type {number}
* @memberof Version
*/
minor: number;
/**
* Version patch number
*
* @type {number}
* @memberof Version
*/
patch: number;
2022-08-25 01:36:48 +02:00
/**
* Version build ID (optional): usually the current git commit hash
*
* @type {number}
* @memberof Version
*/
build_id: string;
2021-11-24 22:47:49 +01:00
/**
*Creates an instance of Version.
2022-08-25 01:36:48 +02:00
*
2021-11-24 22:47:49 +01:00
* @param {string} string string represents the version
* @memberof Version
*/
constructor(string: string);
2022-08-25 01:36:48 +02:00
/**
* Setter/getter to set the version string to the object
*
* @memberof Version
*/
set version_string(v: string);
get version_string(): string;
2021-11-24 22:47:49 +01:00
/**
* Compare the current version with another version.
*
* The comparison priority is `branch>major>minor>patch`.
*
* For the branch, the priority is `r>b>a`
*
* @param {(string | Version)} o version string or object
* @returns {(0 | 1 | -1)}
* Return 0 if the two versions are the same, 1 if
* the current version is newer than the input version,
* otherwise return -1
* @memberof Version
*/
compare(o: string | Version): 0 | 1 | -1;
/**
* Check if the current version is newer than
* the input version
*
* @param {(string | Version)} o version string or object
* @returns {boolean}
* @memberof Version
*/
nt(o: string | Version): boolean;
/**
* Check if the current version is older than
* the input version
*
* @param {(string | Version)} o version string or object
* @returns {boolean}
* @memberof Version
*/
ot(o: string | Version): boolean;
/**
* Return itself
*
* @returns {Version}
* @memberof Version
*/
__v(): Version;
/**
* Convert Version object to string
*
* @returns {string}
* @memberof Version
*/
toString(): string;
}
/**
* Variable represents the current AntOS version, it
* is an instance of [[Version]]
*/
const VERSION: Version;
2022-08-25 01:36:48 +02:00
/**
* Variable represents the current AntOS source code repository
* is an instance of [[string]]
*/
const REPOSITORY: string;
2021-11-24 22:47:49 +01:00
/**
* Register a model prototype to the system namespace.
* There are two types of model to be registered, if the model
* is of type [[SubWindow]], its prototype will be registered
* in the [[dialogs]] namespace, otherwise, if the model type
* is [[Application]] or [[Service]], its prototype will be
* registered in the [[application]] namespace.
*
* When a model is loaded in the system, its prototype is registered
* for later uses
*
* @export
* @param {string} name class name
* @param {*} x the corresponding class
* @returns {*}
*/
function register(name: string, x: PM.ModelTypeClass): void;
/**
* This function cleans up the entire system and
* makes sure the system is in a new and clean session.
* It performs the following operations:
*
* - Kill all running processes
* - Unregister all global events and reset the global
* announcement system
* - Clear the current theme
* - Reset process manager and all system settings
*
* @export
*/
function cleanup(): void;
/**
* Booting up AntOS. This function checks whether the user
* is successfully logged in, then call [[startAntOS]], otherwise
* it shows the login screen
*
* @export
*/
function boot(): void;
/**
* Placeholder for all the callbacks that are called when the system
* exits. These callbacks are useful when an application or service wants
* to perform a particular task before shuting down the system
*/
const cleanupHandles: {
[index: string]: () => Promise<any>;
};
/**
* Perform the system shutdown operation. This function calls all
* clean up handles in [[cleanupHandles]], then save the system setting
* before exiting
*
* @export
*/
function exit(): void;
/**
* Register a callback to the system [[cleanupHandles]]
*
* @export
* @param {string} n callback string name
* @param {() => void} f the callback handle
* @returns
*/
function onexit(n: string, f: () => Promise<any>): () => Promise<any>;
/**
* The namespace API is dedicated to the definition of the core system APIs
* used by AntOS and its applications. The following core APIs are defined:
*
* - The AntOS announcement system
* - Virtual File system
* - Virtual Database
* - Low-level REST based client-server communication
* - Dependencies management
* - System utilities
*
* These APIs are considered as middle-ware that abstracts the client-server
* communication and provide the application layer with a standardized APIs
* for file/database access, system events handling (announcement), automatic
* dependencies resolving, etc.
*/
namespace API {
/**
* AntOS package meta-data type definition
*
* @export
* @interface PackageMetaType
*/
interface PackageMetaType {
/**
* The application class name, if the package has only services
* this property is ignored and [[pkgname]] should be specified
*
* @type {string}
* @memberof PackageMetaType
*/
app?: string;
/**
* Package name, in case of [[app]] being undefined, this property
* need to be specified
*
* @type {string}
* @memberof PackageMetaType
*/
pkgname?: string;
/**
* Package category
*
* @type {string}
* @memberof PackageMetaType
*/
category: string;
/**
* Package description string
*
* @type {string}
* @memberof PackageMetaType
*/
description: string;
/**
* List of services that is attached to the
* package
*
* @type {string[]}
* @memberof PackageMetaType
*/
services?: string[];
/**
* CSS icon class of the package
*
* @type {string}
* @memberof PackageMetaType
*/
iconclass?: string;
/**
* VFS application icon path
*
* @type {string}
* @memberof PackageMetaType
*/
icon?: string;
/**
* Package information
*
* @type {{
* author: string;
* email: string;
* [propName: string]: any;
* }}
* @memberof PackageMetaType
*/
info: {
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Author of the package
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @type {string}
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
author: string;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Author's email
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @type {string}
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
email: string;
[propName: string]: any;
};
/**
* Application-specific locale definition. When the system locale changes,
* translatable texts inside the application will be first translated using
* the locale dictionary defined in the package meta-data. If no translation
* found, the system locale dictionary is used instead.
*
* A local dictionary definition should be in the following format:
*
* ```typescript
* {
* [locale_name: string]: {
* [origin_string]: string // translation string
* }
* }
* ```
*
* Example of locale dictionaries:
*
* ```typescript
* {
* "en_GB": {
* "Cancel": "Cancel",
* "Modify": "Modify"
* },
* "fr_FR": {
* "Cancel": "Annuler",
* "Modify": "Modifier"
* }
* }
* ```
*
* @type {{ [index: string]: GenericObject<string> }} locale dictionaries
* @memberof PackageMetaType
*/
locales: {
[index: string]: GenericObject<string>;
};
/**
* Mime types supported by the packages, regular expression can be used
* to specified a range of mimes in common
*
* @type {string[]}
* @memberof PackageMetaType
*/
mimes: string[];
/**
* Package (application) name
*
* @type {string}
* @memberof PackageMetaType
*/
name: string;
/**
* VFS path to package installation location
*
* @type {string}
* @memberof PackageMetaType
*/
path: string;
/**
* Package version, should be in a format conforming
* to the version definition in [[Version]] class
*
* @type {string}
* @memberof PackageMetaType
*/
version: string;
/**
* Package dependencies, each entry is in the following format
*
* `package_name@version`
*
* Example:
*
* ```json
* [
* "File@0.1.5-b"
* ]
* ```
*
* @type {string[]}
* @memberof PackageMetaType
*/
dependencies: string[];
[propName: string]: any;
}
/**
* Placeholder to store all loaded shared libraries. Once
* a shared library is firstly loaded, its identity will be
* stored in this variable. Based on this information, in
* the next use of the library, the system knows that the
* library is already loaded and ready to use.
*
* A shared library can be a javascript or a CSS file.
*/
const shared: GenericObject<boolean>;
/**
* Placeholder for all global search handles registered to the system.
* These callbacks will be called when user performs the search operation
* in the spotlight UI.
*
* Applications can define their own search handle to provide the spotlight UI
* with additional search results
*
*/
const searchHandle: GenericObject<(text: string) => any[]>;
/**
* Placeholder of the current system locale dictionary, the system uses
* this dictionary to translate all translatable texts to the current
* locale language
*/
var lang: GenericObject<string>;
/**
* Re-export the system announcement [[getMID]] function to the
* core API
*
* @export
* @returns {number}
*/
function mid(): number;
/**
* REST-based API.
*
* Perform a POST request to the server. Data exchanged
* is in `application/json`
*
* @export
* @param {string} p the server URI
* @param {*} d data object that will be converted to JSON
* @returns {Promise<any>} a promise on the result data
*/
function post(p: string, d: any): Promise<any>;
/**
* REST-based API.
*
* Perform a GET request and read back the data in
* `ArrayBuffer` (binary) format. This is useful for
* binary data reading
*
* @export
* @param {string} p resource URI
* @returns {Promise<ArrayBuffer>} a promise on the returned binary data
*/
function blob(p: string): Promise<ArrayBuffer>;
/**
2022-07-17 14:13:44 +02:00
* REST-based API.
*
* Send file to server
*
* @export
* @param {string} p resource URI
* @param {string} d VFS path of the destination file
* @returns {Promise<any>}
*/
function upload(p: string, d: string): Promise<any>;
/**
* REST-based API.
*
* Download a file
*
* @export
* @param {string} name file name
* @param {*} b file content
*/
function saveblob(name: string, b: any): void;
/**
* Helper function to trigger the global `loading`
* event. This event should be triggered in the
* beginning of a heavy task
*
* @export
* @param {number} q message id, see [[mid]]
* @param {string} p message string
*/
function loading(q: number, p: string): void;
/**
* Helper function to trigger the global `loaded`
* event: This event should be triggered in the
* end of a heavy task that has previously triggered
* the `loading` event
*
* @export
* @param {number} q the message id of the corresponding `loading` event
* @param {string} p the message string
* @param {string} m message status (`OK` of `FAIL`)
*/
function loaded(q: number, p: string, m: string): void;
/**
* Perform an REST GET request
*
* @export
* @param {string} p the URI of the request
* @param {string} [t=undefined] the response data type:
* - jsonp: the response is an json object
* - script: the response is a javascript code
* - xm, html: the response is a XML/HTML object
* - text: plain text
* @returns {Promise<any>} a Promise on the requested data
*/
function get(p: string, t?: string): Promise<any>;
/**
* REST-based API
*
* Perform a GET operation and executed the returned
* content as javascript
*
* @export
* @param {string} p URI resource
* @returns {Promise<any>} promise on the executed content
*/
function script(p: string): Promise<any>;
/**
* REST-based API
*
* Get the content of a global asset resource stored
* in `os://resources/`
*
* @export
* @param {string} r relative path to the resource
* @returns {Promise<any>} promise on the returned content
*/
function resource(r: string): Promise<any>;
/**
* Helper function to verify whether a shared library
* is loaded and ready to use
*
* @export
* @param {string} l path to the library
* @returns {boolean}
*/
function libready(l: string): boolean;
/**
* Load a shared library if not ready
*
* @export
* @param {string} l VFS path to the library
* @param {string} force force reload library
* @returns {Promise<void>} a promise on the result data
*/
function requires(l: string, force?: boolean): Promise<void>;
/**
* Synchronously load a list of shared libraries
*
* @export
* @param {string[]} libs list of shared libraries
* @returns {Promise<void>}
*/
function require(libs: string[]): Promise<void>;
/**
* The namespace packages is dedicated to all package management
* related APIs.
*/
namespace packages {
/**
* Fetch the package meta-data from the server
*
* @export
* @returns {Promise<RequestResult>} Promise on a [[RequestResult]].
* A success request result should contain a list of [[PackageMetaType]]
*/
function fetch(): Promise<RequestResult>;
/**
* Request the server to regenerate the package
* caches
*
* @export
* @returns {Promise<RequestResult>}
*/
function cache(): Promise<RequestResult>;
}
/**
* Save the current user setting
*
* @export
* @returns {Promise<RequestResult>} promise on a [[RequestResult]]
*/
function setting(): Promise<RequestResult>;
/**
* 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<any>} 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<any>} a promise on the result object (any)
*/
function apigateway(d: GenericObject<any>, ws: boolean): Promise<any>;
/**
* Perform the global search operation when user enter
* text in spotlight.
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* This function will call all the search handles stored
* in [[searchHandle]] and build the search result based
* on output of these handle
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} text text to search
* @returns {any[]}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function search(text: string): any[];
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Register a search handle to the global [[searchHandle]]
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} name handle name string
* @param {(text: string) => any[]} fn search handle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function onsearch(name: string, fn: (text: string) => any[]): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set the current system locale: This function will
* find and load the locale dictionary definition file in the
* system asset resource, then trigger the global event
* `systemlocalechange` to translated all translatable text
* to the target language
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} name locale name, e.g. `en_GB`
* @returns {Promise<any>}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function setLocale(name: string): Promise<any>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Return an error Object: AntOS use this function to
* collect information (stack trace) from user reported
* error.
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {(string | FormattedString)} n error string
* @returns {Error}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function throwe(n: string | FormattedString): Error;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set value to the system clipboard
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @param {string} v clipboard value
* @returns {boolean}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function setClipboard(v: string): boolean;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Get the clipboard data
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @returns {Promise<any>} Promise on the clipboard data
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function getClipboard(): Promise<any>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A switcher object is a special object in which
* each object's property is a boolean option. All object's
* properties are mutual exclusive. It means that when a property
* is set to true, all other properties will be reset to false.
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Example:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* ```typescript
* let view = API.switcher("tree", "list", "icon")
* view.tree = true // view.list = false and view.icon = false
* view.list = true // view.tree = false and view.icon = false
* ```
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @returns {*}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
function switcher(...args: string[]): any;
}
}
/// <reference types="jquery" />
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 {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Abstract prototype of all AntOS applications.
* Any new application definition should extend
* this prototype
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @abstract
* @class BaseApplication
* @extends {BaseModel}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
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<any>}
* @memberof BaseApplication
*/
setting: GenericObject<any>;
/**
* 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
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {number[]}
* @memberof BaseApplication
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
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<any>} promise the promise on a task to be performed
* @returns {Promise<void>}
* @memberof BaseApplication
*/
protected load(promise: Promise<any>): Promise<void>;
/**
* 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;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set a setting value to the application setting
* registry
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} k setting name
* @param {*} v setting value
* @returns {void}
* @memberof BaseApplication
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected registry(k: string, v: any): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Show the appliation
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof BaseApplication
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
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;
2021-04-21 11:37:58 +02:00
}
2021-11-24 22:47:49 +01:00
}
}
/// <reference types="jquery" />
declare namespace OS {
/**
* Application argument type definition
*
* @export
* @interface AppArgumentsType
*/
interface AppArgumentsType {
/**
* File type to be open by the app
*
* @type {string}
* @memberof AppArgumentsType
*/
type?: string;
/**
* File path to be opened
*
* @type {string}
* @memberof AppArgumentsType
*/
path: string;
/**
* Any other object
*/
[propName: string]: any;
}
/**
* Enum definition of different model types
*
* @export
* @enum {number}
*/
enum ModelType {
/**
* Applications
*/
Application = 0,
/**
* Services
*/
Service = 1,
/**
* Sub-window such as dialogs
*/
SubWindow = 2
}
/**
* Base AntOS event definition
*
* @export
* @class BaseEvent
*/
class BaseEvent {
/**
* The event name placeholder
*
* @type {string}
* @memberof BaseEvent
*/
name: string;
/**
* Placeholder indicates whether the event is forced to
* be happen
*
* @private
* @type {boolean}
* @memberof BaseEvent
*/
private force;
/**
* Placeholder indicates whether the event is prevented.
* This value has not effect if `force` is set to `true`
*
* @type {boolean}
* @memberof BaseEvent
*/
prevent: boolean;
/**
*Creates an instance of BaseEvent.
* @param {string} name event name
* @param {boolean} force indicates whether the event is forced
* @memberof BaseEvent
*/
constructor(name: string, force: boolean);
/**
* Prevent the current event. This function
* has no effect if `force` is set to true
*
* @memberof BaseEvent
*/
preventDefault(): void;
}
/**
* The root model of all applications, dialogs or services
* in the system
*
* @export
* @abstract
* @class BaseModel
*/
abstract class BaseModel {
/**
* The class name
*
* @type {string}
* @memberof BaseModel
*/
name: string;
/**
* The argument of the model
*
* @type {AppArgumentsType[]}
* @memberof BaseModel
*/
args: AppArgumentsType[];
/**
* Each model has its own local announcement system
* to handle all local events inside that model.
*
* This observable object is propagate to all the
* UI elements ([[AFXTag]]) inside the model
*
* @protected
* @type {API.Announcer}
* @memberof BaseModel
*/
protected _observable: API.Announcer;
/**
* Reference to the core API namespace
*
* @protected
* @type {typeof API}
* @memberof BaseModel
*/
protected _api: typeof API;
/**
* Reference to the core GUI namespace
*
* @protected
* @type {typeof GUI}
* @memberof BaseModel
*/
protected _gui: typeof GUI;
/**
* Reference to the model's dialog
*
* @type {GUI.BaseDialog}
* @memberof BaseModel
*/
dialog: GUI.BaseDialog;
/**
* The HTML element ID of the virtual desktop
*
* @protected
2021-11-26 00:06:03 +01:00
* @type {HTMLElement}
2021-11-24 22:47:49 +01:00
* @memberof BaseModel
*/
2021-11-26 00:06:03 +01:00
protected host: HTMLElement;
2021-11-24 22:47:49 +01:00
/**
* The process number of the current model.
* For sub-window this number is the number
* of the parent window
*
* @type {number}
* @memberof BaseModel
*/
pid: number;
/**
* Reference the DOM element of the UI scheme belong to
* this model
*
* @type {HTMLElement}
* @memberof BaseModel
*/
scheme: HTMLElement;
/**
* Reference to the system setting
*
* @protected
* @type {typeof setting}
* @memberof BaseModel
*/
protected systemsetting: typeof setting;
/**
* Placeholder for the process creation timestamp
*
* @type {number}
* @memberof BaseModel
*/
birth: number;
/**
* Different model type
*
* @static
* @type {ModelType}
* @memberof BaseModel
*/
static type: ModelType;
/**
* Allow singleton on this model
*
* @static
* @type {boolean}
* @memberof BaseModel
*/
static singleton: boolean;
/**
* The javascript or css files that the model depends on. All dependencies
* will be loaded before the model is rendered
*
* @static
* @type {string[]} list of VFS paths of dependencies
* @memberof BaseModel
*/
static dependencies: string[];
/**
* Reference to the CSS Element of the model
*
* @static
* @type {(HTMLElement | string)}
* @memberof BaseModel
*/
static style: HTMLElement | string;
/**
* Place holder for model meta-data
*
* @static
* @type {API.PackageMetaType}
* @memberof BaseModel
*/
static meta: API.PackageMetaType;
/**
*Creates an instance of BaseModel.
* @param {string} name class name
* @param {AppArgumentsType[]} args arguments
* @memberof BaseModel
*/
constructor(name: string, args: AppArgumentsType[]);
/**
* Getter: get the local announcer object
*
* @readonly
* @type {API.Announcer}
* @memberof BaseModel
*/
get observable(): API.Announcer;
/**
* Update the model locale
*
* @param {string} name
* @memberof BaseModel
*/
2021-11-26 00:06:03 +01:00
updateLocale(name: string): void;
2021-11-24 22:47:49 +01:00
/**
* Render the model's UI
*
* @protected
* @param {string} p VFS path to the UI scheme definition
* @returns {void}
* @memberof BaseModel
*/
protected render(p: string): void;
/**
* Exit the model
*
* @param {boolean} force set this value to `true` will bypass the prevented exit event by user
* @returns {void}
* @memberof BaseModel
*/
quit(force: boolean): void;
/**
* Model meta data, need to be implemented by
* subclasses
*
* @abstract
* @returns {API.PackageMetaType}
* @memberof BaseModel
*/
abstract meta(): API.PackageMetaType;
/**
* VFS path to the model asset
*
* @returns {string}
* @memberof BaseModel
*/
path(): string;
/**
* Execute a server side script and get back the result
*
* @protected
* @param {GenericObject<any>} cmd execution indication, should be:
*
* ```
* {
* path?: string, // VFS path to the server side script
* code: string, // or server side code to be executed
* parameters: any // the parameters of the server side execution
* }
* ```
*
* @returns {Promise<any>}
* @memberof BaseModel
*/
protected call(cmd: GenericObject<any>): Promise<any>;
/**
* Connect to the server side api using a websocket connection
*
* Server side script can be execute inside the stream by writing
* data in JSON format with the following interface
*
* ```
* {
* path?: string, // VFS path to the server side script
* code: string, // or server side code to be executed
* parameters: any // the parameters of the server side execution
* }
* ```
*
* @protected
* @returns {Promise<WebSocket>}
* @memberof BaseModel
*/
protected stream(): Promise<WebSocket>;
/**
* Init the model before UI rendering
*
* @abstract
* @memberof BaseModel
*/
abstract init(): void;
/**
* Main entry point after UI rendering
*
* @abstract
* @memberof BaseModel
*/
abstract main(): void;
/**
* Show the model
*
* @abstract
* @memberof BaseModel
*/
abstract show(): void;
/**
* Hide the model
*
* @abstract
* @memberof BaseModel
*/
abstract hide(): void;
/**
* Function called when the model exits
*
* @protected
* @abstract
* @param {BaseEvent} e exit event
* @memberof BaseModel
*/
protected abstract onexit(e: BaseEvent): void;
/**
* subscribe once to a local event
*
* @protected
* @param {string} e name of the event
* @param {(d: any) => void} f event callback
* @returns {void}
* @memberof BaseModel
*/
protected one(e: string, f: (d: any) => void): void;
/**
* Subscribe to a local event
*
* @protected
* @param {string} e event name
* @param {(d: any) => void} f event callback
* @returns {void}
* @memberof BaseModel
*/
protected on(e: string, f: (d: any) => void): void;
/**
* Unsubscribe an event
*
* @protected
* @param {string} e event name or `*` (all events)
* @param {(d: any) => void} [f] callback to be unsubscribed, can be `undefined`
* @returns {void}
* @memberof BaseModel
*/
protected off(e: string, f?: (d: any) => void): void;
/**
* trigger a local event
*
* @param {string} e event name
* @param {*} [d] event data
* @returns {void}
* @memberof BaseModel
*/
trigger(e: string, d?: any): void;
/**
* subscribe to an event on the global announcement system
*
* @protected
* @param {string} e event name
* @param {(d: API.AnnouncementDataType<any>) => void} f event callback
* @returns {void}
* @memberof BaseModel
*/
subscribe(e: string, f: (d: API.AnnouncementDataType<any>) => void): void;
/**
* Open a dialog
*
* @param {(GUI.BaseDialog | string)} d a dialog object or a dialog class name
* @param {GenericObject<any>} [data] input data of the dialog, refer to each
* dialog definition for the format of the input data
* @returns {Promise<any>} A promise on the callback data of the dialog, refer
* to each dialog definition for the format of the callback data
* @memberof BaseModel
*/
openDialog(d: GUI.BaseDialog | string, data?: GenericObject<any>): Promise<any>;
/**
* Open a [[YesNoDialog]] to confirm a task
*
* @protected
* @param {GenericObject<any>} data [[YesNoDialog]] input data
* @returns {Promise<boolean>}
* @memberof BaseModel
*/
protected ask(data: GenericObject<any>): Promise<boolean>;
/**
* Trigger a global event
*
* @protected
* @param {string} t event name
* @param {(string | FormattedString)} m event message
* @param {any} u_data user data object if any
* @returns {void}
* @memberof BaseModel
*/
protected publish(t: string, m: string | FormattedString, u_data?: any): void;
/**
* Publish a global notification
*
* @param {(string | FormattedString)} m notification string
* @param {any} u_data user data object if any
* @returns {void}
* @memberof BaseModel
*/
notify(m: string | FormattedString, data?: any): void;
/**
* Publish a global warning
*
* @param {(string | FormattedString)} m warning string
* @returns {void}
* @memberof BaseModel
*/
warn(m: string | FormattedString): void;
/**
* Report a global error
*
* @param {(string | FormattedString)} m error message
* @param {Error} [e] error object if any
* @returns
* @memberof BaseModel
*/
error(m: string | FormattedString, e?: Error): void;
/**
* Report a global fail event
*
* @param {string} m fail message
* @param {Error} [e] error object if any
* @returns
* @memberof BaseModel
*/
fail(m: string, e?: Error): void;
/**
* Throw an error inside the model
*
* @returns {Error}
* @memberof BaseModel
*/
throwe(): Error;
/**
* Update the model, this will update all its UI elements
*
* @returns {void}
* @memberof BaseModel
*/
update(): void;
/**
* Find a HTMLElement in the UI of the model
* using the `data-id` attribute of the element
*
* @protected
* @param {string} id
* @returns {HTMLElement}
* @memberof BaseModel
*/
protected find(id: string): HTMLElement;
/**
* Select all DOM Element inside the UI of the model
* using JQuery selector
2022-07-17 14:13:44 +02:00
*
* @protected
* @param {string} sel
* @returns {HTMLElement}
* @memberof BaseModel
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected select(sel: string): JQuery<HTMLElement>;
2021-11-24 22:47:49 +01:00
}
}
declare namespace OS {
namespace GUI {
2022-07-17 14:13:44 +02:00
namespace tag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* A switch tag is basically used to visualize an boolean data value.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class SwitchTag
* @extends {AFXTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class SwitchTag extends AFXTag {
/**
* Placeholder for the onchange event handle
*
* @private
* @type {TagEventCallback<boolean>}
* @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<boolean>);
/**
* 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;
}
2021-11-24 22:47:49 +01:00
}
2022-07-17 14:13:44 +02:00
}
}
declare namespace OS {
namespace GUI {
2021-11-24 22:47:49 +01:00
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* Definition of system file view widget
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class FileViewTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
class FileViewTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder for file select event callback
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<API.FileInfoType>}
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onfileselect;
/**
* placeholder for file open event callback
*
* @private
* @type {TagEventCallback<API.FileInfoType>}
* @memberof FileViewTag
*/
private _onfileopen;
/**
* Reference to the all selected files meta-datas
*
* @private
* @type {API.FileInfoType[]}
* @memberof FileViewTag
*/
private _selectedFiles;
/**
* 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;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Header definition of the widget grid view
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {(GenericObject<any>[])}
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _header;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder for the user-specified meta-data fetch function
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _fetch;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of FileViewTag.
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
constructor();
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Init the widget before mounting
*
* @protected
* @memberof FileViewTag
*/
protected init(): void;
/**
* Update the current widget, do nothing
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @param {*} [d]
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* set the function that allows to fetch file entries.
* This handle function should return a promise on
* an arry of [[API.FileInfoType]]
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set fetch(v: (p: string) => Promise<API.FileInfoType[]>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* set the callback handle for the file select event.
* The parameter of the callback should be an object
* of type [[TagEventType]]<T> with the data type `T` is [[API.FileInfoType]]
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onfileselect(e: TagEventCallback<API.FileInfoType>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
set the callback handle for the file open event.
* The parameter of the callback should be an object
* of type [[TagEventType]]<T> with the data type `T` is [[API.FileInfoType]]
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onfileopen(e: TagEventCallback<API.FileInfoType>);
2021-04-21 11:37:58 +02:00
/**
* Setter:
*
2022-07-17 14:13:44 +02:00
* chang the view of the widget, there are three different views
* - `icon`
* - `list`
* - `tree`
2021-04-21 11:37:58 +02:00
*
* Getter:
*
2022-07-17 14:13:44 +02:00
* Get the current view setting of the widget
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set view(v: string);
get view(): string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @readonly
2022-07-17 14:13:44 +02:00
* @type {API.FileInfoType}
* @memberof FileViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
get selectedFile(): API.FileInfoType;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get all selected files
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @readonly
* @type {API.FileInfoType[]}
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
get selectedFiles(): API.FileInfoType[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter:
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set path(v: string);
get path(): string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Set the data of the current working directory
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: Get the data of the current working directory
*
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set data(v: API.FileInfoType[]);
get data(): API.FileInfoType[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the file drag and drop event handle. This allows application
* to define custom behavior of the event
*
* @memberof FileViewTag
*/
set ondragndrop(v: TagEventCallback<DnDEventDataType<TreeViewTag | ListViewItemTag | GridCellPrototype>>);
/**
* Sort file by its type
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @param {API.FileInfoType} a
* @param {API.FileInfoType} b
* @return {*} {number}
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private sortByType;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* sort file by its name
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @param {API.FileInfoType} a first file meta-data
* @param {API.FileInfoType} b second file meta-data
* @returns {number}
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private sortByName;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* calibrate the widget layout
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
calibrate(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Refresh the list view of the widget. This function
* is called when the view of the widget changed to `icon`
*
* @private
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private refreshList;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Refresh the grid view of the widget, this function is called
* when the view of the widget set to `list`
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @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
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private getTreeData;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Refresh data of the current widget view
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @returns {void}
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private refreshData;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Switch between three view options
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private switchView;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function triggers the file select event
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {API.FileInfoType} e selected file meta-data
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private fileselect;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function triggers the file open event
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {API.FileInfoType} e selected file meta-data
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private filedbclick;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the widget in the DOM tree
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Layout definition of the widget
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof FileViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected layout(): TagLayoutType[];
}
}
}
}
2022-07-17 14:13:44 +02:00
/// <reference types="jquery" />
/**
*
* 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;
}
2021-11-24 22:47:49 +01:00
declare namespace OS {
namespace GUI {
2022-07-17 14:13:44 +02:00
/**
* [[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<T> {
/**
* 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<T> {
/**
* `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<T> {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the source DOM element
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @type {T}
* @memberof DnDEventDataType
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
from: T[];
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the target DOM element
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @type {T}
* @memberof DnDEventDataType
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
to: T;
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
/**
* Tag event callback type
*/
type TagEventCallback<T> = (e: TagEventType<T>) => 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<HTMLElement>}
* @memberof AFXTag
*/
protected refs: GenericObject<HTMLElement>;
/**
* 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<any>} v input object
* @memberof AFXTag
*/
set(v: GenericObject<any>): 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);
2021-04-21 11:37:58 +02:00
/**
*
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @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
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: get the id of the current tag
*
* @memberof AFXTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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;
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
/**
* 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
*/
2021-11-26 00:06:03 +01:00
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* 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
2021-11-26 00:06:03 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @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}
2021-11-26 00:06:03 +01:00
*/
2022-07-17 14:13:44 +02:00
function define<T extends AFXTag>(name: string, cls: {
new (): T;
}): void;
2021-11-26 00:06:03 +01:00
}
}
}
2021-04-21 11:37:58 +02:00
declare namespace OS {
namespace GUI {
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* List item event data type
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
type ListItemEventData = TagEventDataType<ListViewItemTag>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
*
* @export
* @abstract
* @class ListViewItemTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
abstract class ListViewItemTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Data placeholder for the list item
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {GenericObject<any>}
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _data;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder for the item select event callback
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<ListItemEventData>}
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onselect;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Context menu event callback handle
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<ListItemEventData>}
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onctxmenu;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Click event callback placeholder
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<ListItemEventData>}
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onclick;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Double click event callback handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<ListItemEventData>}
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _ondbclick;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Item close event callback placeholder
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<ListItemEventData>}
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onclose;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of ListViewItemTag.
* @memberof ListViewItemTag
*/
constructor();
/**
* Setter: Turn on/off the `closable` feature of the list item
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether the item is closable
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
*/
set closable(v: boolean);
get closable(): boolean;
/**
* Set item select event handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set onitemselect(v: TagEventCallback<ListViewItemTag>);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter: select/unselect the current item
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether the current item is selected
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set selected(v: boolean);
get selected(): boolean;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set the context menu event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onctxmenu(v: TagEventCallback<ListViewItemTag>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the item click event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
*/
set onitemclick(v: TagEventCallback<ListViewItemTag>);
/**
* Set the item double click event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onitemdbclick(v: TagEventCallback<ListViewItemTag>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* set the item close event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onitemclose(v: TagEventCallback<ListViewItemTag>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the tag and bind some events
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* 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]]
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected layout(): TagLayoutType[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* 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<any>);
get data(): GenericObject<any>;
/**
* Any subclass of this class should implement this
* function to provide its custom item layout
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @abstract
2022-07-17 14:13:44 +02:00
* @returns {TagLayoutType}
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected abstract itemlayout(): TagLayoutType;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function is called when the item data is changed.
* It should be implemented in all subclass of this class
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @abstract
2022-07-17 14:13:44 +02:00
* @memberof ListViewItemTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected abstract ondatachange(): void;
}
/**
2022-07-17 14:13:44 +02:00
* The layout of a simple list item contains only a
* AFX label
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class SimpleListItemTag
* @extends {ListViewItemTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class SimpleListItemTag extends ListViewItemTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of SimpleListItemTag.
* @memberof SimpleListItemTag
2021-11-24 22:47:49 +01:00
*/
constructor();
/**
2022-07-17 14:13:44 +02:00
* Reset some property to default
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
2022-07-17 14:13:44 +02:00
* @memberof SimpleListItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected init(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Do nothing
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof SimpleListItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected calibrate(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Refresh the inner label when the item data
* is changed
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {void}
* @memberof SimpleListItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected ondatachange(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Re-render the list item
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof SimpleListItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected reload(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* List item custom layout definition
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {TagLayoutType}
* @memberof SimpleListItemTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of list select event handle
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<ListItemEventData>}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onlistselect;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of list double click event handle
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<ListItemEventData>}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onlistdbclick;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of list drag and drop event handle
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<DnDEventDataType<ListViewItemTag>>}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _ondragndrop;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of list item close event handle
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onitemclose;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of drag and drop mouse down event handle
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _onmousedown;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of drag and drop mouse up event handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _onmouseup;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of drag and drop mouse move event handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _onmousemove;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the latest selected DOM item
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {ListViewItemTag}
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _selectedItem;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A collection of selected items in the list.
* The maximum size of this collection is 1 if
* the [[multiselect]] feature is disabled
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {ListViewItemTag[]}
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _selectedItems;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Data placeholder of the list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {GenericObject<any>[]}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _data;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Event data passing between mouse event when performing
* drag and drop on the list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {{ from: ListViewItemTag[]; to: ListViewItemTag }}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _dnd;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of ListViewTag.
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
constructor();
/**
2022-07-17 14:13:44 +02:00
* Reset the tag's properties to the default values
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected init(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function does nothing
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
2022-07-17 14:13:44 +02:00
* @param {*} [d]
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: toggle between dropdown and traditional list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether the list is dropdown or traditional list
*
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set dropdown(v: boolean);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set drag and drop event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
*/
set ondragndrop(v: TagEventCallback<DnDEventDataType<ListViewItemTag>>);
/**
* Set list select event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set onlistselect(v: TagEventCallback<ListItemEventData>);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set double click event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onlistdbclick(v: TagEventCallback<ListItemEventData>);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set item close event handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set onitemclose(v: (e: TagEventType<ListItemEventData>) => boolean);
get dropdown(): boolean;
2021-04-21 11:37:58 +02:00
/**
* Setter:
*
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*
* Getter:
*
2022-07-17 14:13:44 +02:00
* Get the default tag name of list item
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set itemtag(v: string);
get itemtag(): string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter:
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Turn on/off of the `multiselect` feature
*
* Getter:
*
* Check whether multi-select is allowed
* in this list
*
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set multiselect(v: boolean);
get multiselect(): boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Enable/disable drag and drop event in the list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether the drag and drop event is enabled
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set dragndrop(v: boolean);
get dragndrop(): boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the buttons layout of the list.
* Button layout allows to add some custom
* behaviors to the list.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set buttons(v: GenericObject<any>[]);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Getter: Get data of the list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Setter: Set data to the list
*
* @type {GenericObject<any>[]}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
get data(): GenericObject<any>[];
set data(data: GenericObject<any>[]);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Do nothing
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected ondatachange(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Select list item(s) by their indexes
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: Get the indexes of all selected items
*
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set selected(idx: number | number[]);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get the latest selected item
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @readonly
* @type {ListViewItemTag}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
get selectedItem(): ListViewItemTag;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get all the selected items
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @readonly
* @type {ListViewItemTag[]}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
get selectedItems(): ListViewItemTag[];
get selected(): number | number[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Add an item to the beginning of the list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {GenericObject<any>} item
* @returns {ListViewItemTag} the added list item element
* @memberof ListViewTag
*/
unshift(item: GenericObject<any>): ListViewItemTag;
/**
* check whether the list has data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {GenericObject<any>} v
* @returns
* @memberof ListViewTag
*/
private has_data;
/**
* Add an item to the beginning or end of the list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {GenericObject<any>} 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<any>, 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
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
selectNext(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Select the previous item in the list.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
selectPrev(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Unselect all the selected items in the list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
unselect(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function triggers the click event on an item
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @param {TagEventType} e tag event object
* @param {boolean} flag indicates whether this is a double click event
* @returns {void}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private iclick;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function triggers the double click event on an item
*
* @private
* @param {TagEventType} e tag event object
* @returns
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private idbclick;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function triggers the list item select event
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {TagEventType} e tag event object
* @returns
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private iselect;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the tag and bind some basic event
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This function triggers the item close event
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {TagEventType} e tag event object
* @returns {void}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private iclose;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Show the dropdown list.
* This function is called only when the list is a dropdown
* list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {*} e
* @returns {void}
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected showlist(e: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Hide the dropdown list.
* This function is called only when the list is a dropdown
* list
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
2022-07-17 14:13:44 +02:00
* @param {*} e
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected dropoff(e: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* calibrate the list layout
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
2021-04-21 11:37:58 +02:00
* @returns {void}
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected calibrate(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* List view layout definition
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof ListViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected layout(): TagLayoutType[];
}
}
}
}
declare namespace OS {
namespace GUI {
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* A simple number sinner tag
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class NSpinnerTag
2021-11-24 22:47:49 +01:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
class NSpinnerTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder for value change event handle
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<number>}
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onchange;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder for the spinner data
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {number}
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _value;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Place holder for the spinner step
*
* @type {number}
* @memberof NSpinnerTag
*/
step: number;
/**
*Creates an instance of NSpinnerTag.
* @memberof NSpinnerTag
2021-11-24 22:47:49 +01:00
*/
constructor();
/**
2022-07-17 14:13:44 +02:00
* Init the spinner value to `0` and step to `1`
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
2022-07-17 14:13:44 +02:00
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected init(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Do nothing
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @param {*} [d]
2022-07-17 14:13:44 +02:00
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the value change event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onvaluechange(f: TagEventCallback<number>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the tag and bind basic events
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Calibrate the layout of the spinner
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
calibrate(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Set the spinner value
*
* Getter: Get the spinner value
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof NSpinnerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set value(v: number);
get value(): number;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Spinner layout definition
2021-04-21 11:37:58 +02:00
*
* @protected
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof NSpinnerTag
2021-04-21 11:37:58 +02:00
*/
protected layout(): TagLayoutType[];
}
}
}
}
declare namespace OS {
namespace GUI {
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* Tag event data type definition
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
type TabEventData = TagEventDataType<ListViewItemTag>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* a TabBar allows to control a collection of tabs
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class TabBarTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
export class TabBarTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder of currently selected tab index
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {number}
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _selected;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder of tab close event handle
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _ontabclose;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder of tab select event handle
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {TagEventCallback<TabEventData>}
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _ontabselect;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of TabBarTag.
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
constructor();
/**
2022-07-17 14:13:44 +02:00
* Init the tag
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
protected init(): void;
/**
2022-07-17 14:13:44 +02:00
* Do nothing
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {*} [d]
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Enable/disable a tab to be closed
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether tabs can be closed
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set closable(v: boolean);
get closable(): boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Add a tab in the end of the tab bar
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {GenericObject<any>} item tab data
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
push(item: GenericObject<any>): ListViewItemTag;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Delete a tab
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {ListViewItemTag} el reference to DOM element of a tab
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
delete(el: ListViewItemTag): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Add a tab to the beginning of the tab bar
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {GenericObject<any>} item tab data
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
unshift(item: GenericObject<any>): ListViewItemTag;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Set tabs data
*
* Getter: Get all tabs data
*
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set items(v: GenericObject<any>[]);
get items(): GenericObject<any>[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Select a tab by its index
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: Get the currently selected tab
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set selected(v: number | number[]);
get selected(): number | number[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the tab close event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set ontabclose(v: (e: TagEventType<TabEventData>) => boolean);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the tab select event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set ontabselect(v: TagEventCallback<TabEventData>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the tab bar and bind some basic events
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* TabBar layout definition
2021-04-21 11:37:58 +02:00
*
* @protected
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof TabBarTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected layout(): TagLayoutType[];
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
export {};
}
}
}
declare namespace OS {
namespace GUI {
/**
* Color type used by AFX API
*
* @export
* @interface ColorType
*/
interface ColorType {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Red chanel
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {number}
* @memberof ColorType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The current selected color object
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {ColorType}
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _selectedColor;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder for the color select event callback
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<ColorType>}
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _oncolorselect;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Creates an instance of ColorPickerTag.
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
constructor();
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Init tag before mounting, do nothing
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected init(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Reload tag, do nothing
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {*} [d]
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get selected color value
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @readonly
* @type {ColorType}
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
get selectedColor(): ColorType;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the color select event handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set oncolorselect(v: TagEventCallback<ColorType>);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the widget to DOM tree
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
protected mount(): void;
/**
2022-07-17 14:13:44 +02:00
* Build the color palette
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private build_palette;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* layout definition of the widget
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {TagLayoutType[]}
* @memberof ColorPickerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected layout(): TagLayoutType[];
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
}
}
}
/// <reference types="jquery" />
declare namespace OS {
namespace GUI {
namespace tag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* A `resizer` tag is basically used to dynamically resize an element using mouse.
* It is usually put inside a [[TileLayoutTag]] an can be attached to any element. Example:
*
* The resizer tag in the following example will be attached to the first `afx-vbox`,
* and allows to resize this element using mouse
*
* ```xml
* <afx-hbox>
* <afx-vbox>...</afx-vbox>
* <afx-resizer></afx-resizer>
* <afx-vbox>...</afx-vbox>
* </afx-hbox>
* ```
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class ResizerTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
class ResizerTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the element that this tag is attached to
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {*}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _resizable_el;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the resize event callback
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<any>}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _onresize;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the parent tag of the current tag.
* The parent tag should be an instance of a [[TileLayoutTag]]
* such as [[VBoxTag]] or [[HBoxTag]]
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {*}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _parent;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder of the minimum value that
* the attached element can be resized
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {number}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _minsize;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of ResizerTag.
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
constructor();
/**
2022-07-17 14:13:44 +02:00
* Set the properties of the tag to default values
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
protected init(): void;
/**
* Do nothing
*
* @protected
* @param {*} [d]
2022-07-17 14:13:44 +02:00
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter:
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Set resize direction, two possible values:
* - `hz` - horizontal direction, resize by width
* - `ve` - vertical direction, resize by height
*
* Getter:
*
* Get the resize direction
*
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set dir(v: string);
get dir(): string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Getter : Check whether the resizer should attach to its next or previous element
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Setter: if `v=true` select next element as attached element of the resizer, otherwise
* select the previous element
* @readonly
* @type {boolean}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
get attachnext(): boolean;
set attachnext(v: boolean);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter:
* - set the resize event callback
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter:
* - get the resize event callback
*
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set onelresize(v: TagEventCallback<any>);
get onelresize(): TagEventCallback<any>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the tag to the DOM tree
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
protected mount(): void;
/**
2022-07-17 14:13:44 +02:00
* Enable draggable on the element
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private make_draggable;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Resize the attached element in the horizontal direction (width)
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {JQuery.MouseEventBase} e JQuery mouse event
* @returns {void}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private horizontalResize;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Resize the attached element in the vertical direction (height)
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {JQuery.MouseEventBase} e JQuery mouse event
* @returns {void}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected verticalResize(e: JQuery.MouseEventBase): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Layout definition of the tag, empty layout
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {TagLayoutType[]}
* @memberof ResizerTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected layout(): TagLayoutType[];
2021-04-21 11:37:58 +02:00
}
}
}
}
declare namespace OS {
namespace GUI {
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* This class defines basic AFX label tag.
* A label contains a text and an icon (optional)
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class LabelTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
class LabelTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* placeholder of the text to be displayed
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {(string | FormattedString)}
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _text;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of LabelTag.
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
constructor();
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* this implementation does nothing in this tag
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Refresh the text in the label
*
* @protected
* @param {*} d
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected reload(d: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Reset to default some property value
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
protected init(): void;
/**
2022-07-17 14:13:44 +02:00
* This implementation of the function does nothing
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected calibrate(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the VFS path of the label icon
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set icon(v: string);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set the CSS class of the label icon
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @memberof LabelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
set iconclass(v: string);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Set the text of the label
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Getter: Get the text displayed on the label
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof LabelTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set text(v: string | FormattedString);
get text(): string | FormattedString;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Turn on/off text selection
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether the label is selectable
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof LabelTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set selectable(v: boolean);
get swon(): boolean;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Lqbel layout definition
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {TagLayoutType[]}
* @memberof LabelTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
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 {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the currently selected tab DOM element
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TabContainerTabType}
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _selectedTab;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder of the tab select event handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<TabContainerTabType>}
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _ontabselect;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of TabContainerTag.
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
constructor();
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Init the tab bar direction to vertical (column)
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected init(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Do nothing
2021-11-24 22:47:49 +01:00
*
* @protected
* @param {*} [d]
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
protected reload(d?: any): void;
/**
2022-07-17 14:13:44 +02:00
* Set the tab select event handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set ontabselect(f: TagEventCallback<TabContainerTabType>);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Get all tab items in the container
*
* @readonly
* @type {TabContainerTabType[]}
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
get tabs(): TabContainerTabType[];
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Select a tab by its index
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set selectedIndex(i: number);
2021-11-24 22:47:49 +01:00
/**
* Setter:
*
2022-07-17 14:13:44 +02:00
* Set the tab bar direction:
* - `row`: horizontal direction
* - `column`: vertical direction
2021-11-24 22:47:49 +01:00
*
* Getter:
*
2022-07-17 14:13:44 +02:00
* Get the tab bar direction
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set dir(v: "row" | "column");
get dir(): "row" | "column";
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set selectedTab(v: TabContainerTabType);
get selectedTab(): TabContainerTabType;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set the tab bar width, this function only
* works when the tab bar direction is set to
* `row`
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set tabbarwidth(v: number);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set the tab bar height, this function only works
* when the tab bar direction is set to `column`
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set tabbarheight(v: number);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Add a new tab with container to the container
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* item should be in the following format:
*
* ```ts
* {
* text: string,
* icon?: string,
* iconclass?: string,
* container: HTMLElement
* }
* ```
*
* @param {GenericObject<any>} item tab descriptor
* @param {boolean} insert insert the tab content to the container ?
* @returns {ListViewItemTag} the tab DOM element
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
addTab(item: GenericObject<any>, insert: boolean): ListViewItemTag;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Remove a tab from the container
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @param {ListViewItemTag} tab the tab item to be removed
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
removeTab(tab: ListViewItemTag): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Mount the tag and bind basic events
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
protected mount(): void;
/**
2022-07-17 14:13:44 +02:00
* calibrate the tab container
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
calibrate(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Layout definition
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {TagLayoutType[]}
* @memberof TabContainerTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected layout(): TagLayoutType[];
2021-11-24 22:47:49 +01:00
}
}
}
}
/**
* Extend the Array interface with some
* property needed by AFX API
*
* @interface Array
* @template T
*/
interface Array<T> {
/**
* 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<any>}
* @memberof Array
*/
domel?: GenericObject<any>;
}
declare namespace OS {
namespace GUI {
namespace tag {
2022-07-17 14:13:44 +02:00
/**
* Row item event data type
*/
type GridRowEventData = TagEventDataType<GridRowTag>;
2021-11-24 22:47:49 +01:00
/**
* 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
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @type {GenericObject<any>[]}
* @memberof GridRowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
data: GenericObject<any>[];
2022-07-17 14:13:44 +02:00
/**
* placeholder for the row select event callback
*
* @private
* @type {TagEventCallback<GridRowEventData>}
* @memberof ListViewItemTag
*/
private _onselect;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
*Creates an instance of GridRowTag.
* @memberof GridRowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
constructor();
2022-07-17 14:13:44 +02:00
/**
* Set item select event handle
*
* @memberof ListViewItemTag
*/
set onrowselect(v: TagEventCallback<GridRowEventData>);
/**
* Setter: select/unselect the current item
*
* Getter: Check whether the current item is selected
*
* @memberof ListViewItemTag
*/
set selected(v: boolean);
get selected(): boolean;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Mount the tag, do nothing
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @memberof GridRowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Init the tag before mounting: reset the data placeholder
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @memberof GridRowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected init(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Empty layout
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @returns {TagLayoutType[]}
* @memberof GridRowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected layout(): TagLayoutType[];
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* This function does nothing in this tag
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @memberof GridRowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected calibrate(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* This function does nothing in this tag
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @param {*} [d]
* @memberof GridRowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
}
/**
2021-11-24 22:47:49 +01:00
* Event data used by grid cell
*/
type CellEventData = TagEventDataType<GridCellPrototype>;
/**
* Prototype of any grid cell, custom grid cell
* definition should extend and implement this
* abstract prototype
2021-04-21 11:37:58 +02:00
*
* @export
2021-11-24 22:47:49 +01:00
* @abstract
* @class GridCellPrototype
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2021-11-24 22:47:49 +01:00
abstract class GridCellPrototype extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* placeholder for cell selected event callback
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {TagEventCallback<CellEventData>}
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _oncellselect;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* placeholder for cell double click event callback
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {TagEventCallback<CellEventData>}
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _oncelldbclick;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Data placeholder of the current cell
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
* @type {GenericObject<any>}
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _data;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
*Creates an instance of GridCellPrototype.
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
constructor();
/**
2021-11-24 22:47:49 +01:00
* Set the cell selected event callback
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set oncellselect(v: TagEventCallback<CellEventData>);
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Set the cell double click event callback
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set oncelldbclick(v: TagEventCallback<CellEventData>);
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Setter:
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Set the data of the cell, this will trigger
* the [[ondatachange]] function
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Getter:
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Get the current cell data placeholder
*
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set data(v: GenericObject<any>);
get data(): GenericObject<any>;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Setter:
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Set/unset the current cell as selected.
* This will trigger the [[cellselect]]
* event
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Getter:
*
* Check whether the current cell is selected
*
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set selected(v: boolean);
get selected(): boolean;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Update the current cell. This will
* reset the cell data
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @param {*} d
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected reload(d: any): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Mount the current cell to the grid
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected mount(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* This function triggers the cell select
* event
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @param {TagEventType<GridCellPrototype>} e
* @param {boolean} flag
* @returns {void}
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private cellselect;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Abstract function called when the cell data changed.
* This should be implemented by subclasses
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @abstract
* @memberof GridCellPrototype
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
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 {
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
*Creates an instance of SimpleGridCellTag.
* @memberof SimpleGridCellTag
2021-04-21 11:37:58 +02:00
*/
constructor();
/**
2021-11-24 22:47:49 +01:00
* Reset the label of the cell with its data
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @memberof SimpleGridCellTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected ondatachange(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* This function do nothing in this tag
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @memberof SimpleGridCellTag
2021-04-21 11:37:58 +02:00
*/
protected init(): void;
/**
2021-11-24 22:47:49 +01:00
* This function do nothing in this tag
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @memberof SimpleGridCellTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected calibrate(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* The layout of the cell with a simple [[LabelTag]]
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @returns
* @memberof SimpleGridCellTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
layout(): {
el: string;
ref: string;
}[];
2021-04-21 11:37:58 +02:00
}
/**
2021-11-24 22:47:49 +01:00
* A Grid contains a header and a collection grid rows
* which has the same number of cells as the number of
* the header elements
2021-04-21 11:37:58 +02:00
*
* @export
2021-11-24 22:47:49 +01:00
* @class GridViewTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2021-11-24 22:47:49 +01:00
class GridViewTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Grid header definition
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {GenericObject<any>[]}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _header;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Grid rows data placeholder
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {GenericObject<any>[][]}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _rows;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Reference to the current selected row DOM element
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {GridRowTag}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _selectedRow;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* A collection of selected grid rows DOM element
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {GridRowTag[]}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _selectedRows;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Reference to the current selected cell
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {GridCellPrototype}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _selectedCell;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Cell select event callback placeholder
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
* @type {TagEventCallback<CellEventData>}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _oncellselect;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Row select event callback placeholder
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
* @type {TagEventCallback<CellEventData>}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _onrowselect;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Cell double click event callback placeholder
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
* @type {TagEventCallback<CellEventData>}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private _oncelldbclick;
2022-07-17 14:13:44 +02:00
/**
* 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<DnDEventDataType<GridRowTag>>}
* @memberof GridViewTag
*/
private _ondragndrop;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Creates an instance of GridViewTag.
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
constructor();
2022-07-17 14:13:44 +02:00
/**
* Set drag and drop event handle
*
* @memberof GridViewTag
*/
set ondragndrop(v: TagEventCallback<DnDEventDataType<GridRowTag>>);
/**
* 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;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Init the grid view before mounting.
* Reset all the placeholders to default values
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected init(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* This function does nothing
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @param {*} [d]
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* set the cell select event callback
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set oncellselect(v: TagEventCallback<CellEventData>);
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* set the row select event callback
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set onrowselect(v: TagEventCallback<CellEventData>);
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* set the cell double click event callback
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set oncelldbclick(v: TagEventCallback<CellEventData>);
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Setter: set the tag name of the header cells
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Getter: get the grid header tag name
*
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set headeritem(v: string);
get headeritem(): string;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Setter: set the tag name of the grid cell
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Getter: get the tag name of the grid cell
*
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set cellitem(v: string);
get cellitem(): string;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Setter: set the header data
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Getter: get the header data placeholder
*
* @type {GenericObject<any>[]}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
get header(): GenericObject<any>[];
set header(v: GenericObject<any>[]);
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Get all the selected rows
*
* @readonly
* @type {GridRowTag[]}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
get selectedRows(): GridRowTag[];
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Get the latest selected row
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @readonly
* @type {GridRowTag}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
get selectedRow(): GridRowTag;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Get the current selected cell
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @readonly
* @type {GridCellPrototype}
* @memberof GridViewTag
*/
get selectedCell(): GridCellPrototype;
/**
* Setter: set the rows data
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Getter: get the rows data
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @memberof GridViewTag
*/
set rows(rows: GenericObject<any>[][]);
get rows(): GenericObject<any>[][];
/**
* Setter: activate deactivate multi-select
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* Getter: check whether the `multiselect` option is activated
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set multiselect(v: boolean);
get multiselect(): boolean;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Set and Get the resizable attribute
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* This allows to enable/disable column resize feature
*
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
set resizable(v: boolean);
get resizable(): boolean;
2022-07-17 14:13:44 +02:00
/**
* Sort the grid using a sort function
*
* @param {context: any} context of the executed function
* @param {(a:GenericObject<any>[], b:GenericObject<any>[]) => 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<any>[], b: GenericObject<any>[], index?: number) => number): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Delete a grid rows
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @param {GridRowTag} row row DOM element
* @returns {void}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
delete(row: GridRowTag): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Push a row to the grid
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @param {GenericObject<any>[]} row list of cell data
* @param {boolean} flag indicates where the row is add to beginning or end
* of the row
* @memberof GridViewTags
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
push(row: GenericObject<any>[], flag: boolean): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Unshift a row to the grid
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @param {GenericObject<any>[]} row list of cell data in the row
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
unshift(row: GenericObject<any>[]): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* This function triggers the cell select event
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
* @param {TagEventType<CellEventData>} e event contains cell event data
* @param {boolean} flag indicates whether the event is double clicked
* @returns {void}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private cellselect;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* This function triggers the row select event, a cell select
* event will also trigger this event
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {TagEventType<GridRowEventData>} e
2021-04-21 11:37:58 +02:00
* @returns {void}
2021-11-24 22:47:49 +01:00
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private rowselect;
2022-07-17 14:13:44 +02:00
/**
* Unselect all the selected rows in the grid
*
* @returns {void}
* @memberof GridViewTag
*/
unselect(): void;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Check whether the grid has header
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
* @returns {boolean}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private has_header;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* 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
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @returns {void}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
private calibrate_header;
2021-04-21 11:37:58 +02:00
/**
2021-11-24 22:47:49 +01:00
* Mount the grid view tag
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @protected
* @returns {void}
* @memberof GridViewTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected mount(): void;
/**
* Layout definition of the grid view
*
* @protected
* @returns {TagLayoutType[]}
* @memberof GridViewTag
*/
protected layout(): TagLayoutType[];
2021-04-21 11:37:58 +02:00
}
}
}
}
declare namespace OS {
namespace GUI {
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class SystemPanelTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
class SystemPanelTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Reference to spotlight data
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {(GenericObject<string | FormattedString>)}
* @memberof SystemPanelTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _osmenu;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder indicates whether the spotlight is currently shown
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {boolean}
* @memberof SystemPanelTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _view;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Store pending loading task
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {number[]}
* @memberof SystemPanelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _pending_task;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Loading animation check timeout
*
* @memberof SystemPanelTag
*/
private _loading_toh;
/**
* Place holder for a private callback function
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @memberof SystemPanelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _cb;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Place holder for system app list
*
* @private
* @type {GenericObject<any>[]}
* @memberof SystemPanelTag
*/
private app_list;
/**
*Creates an instance of SystemPanelTag.
* @memberof SystemPanelTag
2021-04-21 11:37:58 +02:00
*/
constructor();
/**
2022-07-17 14:13:44 +02:00
* Do nothing
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof SystemPanelTag
2021-04-21 11:37:58 +02:00
*/
protected init(): void;
/**
2021-11-24 22:47:49 +01:00
* Do nothing
2021-04-21 11:37:58 +02:00
*
* @protected
* @param {*} [d]
2022-07-17 14:13:44 +02:00
* @memberof SystemPanelTag
2021-04-21 11:37:58 +02:00
*/
protected reload(d?: any): void;
/**
2022-07-17 14:13:44 +02:00
* Attach a service to the system tray on the pannel,
* this operation is performed when a service is started
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {BaseService} s
* @returns
* @memberof SystemPanelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
attachservice(s: application.BaseService): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Launch the selected application from the spotlight
* applications list
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @private
* @returns {void}
* @memberof SystemPanelTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private open;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Perform spotlight search operation on keyboard event
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @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
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @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;
}
}
}
}
/// <reference types="jquery" />
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<JQuery.MouseEventBase>}
* @memberof ButtonTag
*/
private _onbtclick;
/**
* Custom user data
*
* @type {GenericObject<any>}
* @memberof ButtonTag
*/
data: GenericObject<any>;
/**
*Creates an instance of ButtonTag.
* @memberof ButtonTag
*/
constructor();
/**
* Set the click callback handle for the target button
*
* @memberof ButtonTag
*/
set onbtclick(v: TagEventCallback<JQuery.MouseEventBase>);
/**
* 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
2021-11-24 22:47:49 +01:00
*/
set enable(v: boolean);
get enable(): boolean;
/**
2022-07-17 14:13:44 +02:00
* Setter: set or remove the attribute `selected` of the button
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Getter: check whether the attribute `selected` of the button is set
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof ButtonTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set selected(v: boolean);
get selected(): boolean;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter: activate or deactivate the toggle mode of the button
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether the button is in toggle mode
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof ButtonTag
*/
set toggle(v: boolean);
get toggle(): boolean;
/**
* Mount the tag
*
* @protected
* @memberof ButtonTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Init the tag before mounting
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof ButtonTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected init(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Re-calibrate the button, do nothing in this tag
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof ButtonTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected calibrate(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Update the current tag, do nothing in this tag
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {*} [d]
* @memberof ButtonTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
reload(d?: any): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Button layout definition
2021-04-21 11:37:58 +02:00
*
* @protected
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof ButtonTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected layout(): TagLayoutType[];
}
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
}
}
declare namespace OS {
namespace GUI {
namespace tag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* A tile layout organize it child elements
* in a fixed horizontal or vertical direction.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* The size of each child element is attributed based
* on its configuration of automatically based on the
* remaining space in the layout
2021-04-21 11:37:58 +02:00
*
*
2022-07-17 14:13:44 +02:00
* @export
* @class TileLayoutTag
* @extends {AFXTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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;
}[];
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* A HBox organize its child elements in horizontal direction
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class HBoxTag
* @extends {TileLayoutTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
class HBoxTag extends TileLayoutTag {
/**
* Creates an instance of HBoxTag.
* @memberof HBoxTag
*/
constructor();
/**
* Mount the tag
*
* @protected
* @memberof HBoxTag
*/
protected mount(): void;
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* A VBox organize its child elements in vertical direction
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class VBoxTag
* @extends {TileLayoutTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Tree view data type definition
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @interface TreeViewDataType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
interface TreeViewDataType {
/**
* The child nodes data of the current tree node
*
* @type {TreeViewDataType[]}
* @memberof TreeViewDataType
*/
nodes?: TreeViewDataType[];
/**
* Boolean indicates whether the current node is opened.
* Only work when the current node is not a leaf node
*
* @type {boolean}
* @memberof TreeViewDataType
*/
open?: boolean;
/**
* The node's path from the root node
*
* @type {string}
* @memberof TreeViewDataType
*/
path?: string;
/**
* Indicates whether this node should be selected
*
* @type {boolean}
* @memberof TreeViewDataType
*/
selected?: boolean;
[propName: string]: any;
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Tree node event data type definition
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
type TreeItemEventData = TagEventDataType<TreeViewItemPrototype>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Abstract prototype of a tree node. All tree node definition should
* extend this class
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @class TreeViewItemPrototype
* @extends {AFXTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
abstract class TreeViewItemPrototype extends AFXTag {
/**
* Node data placeholder
*
* @private
* @type {TreeViewDataType}
* @memberof TreeViewItemPrototype
*/
private _data;
/**
* Placeholder for the indent level of the current node from root node
*
* @private
* @type {number}
* @memberof TreeViewItemPrototype
*/
private _indent;
/**
* private event object used by current node event
*
* @private
* @type {TagEventType<TreeItemEventData>}
* @memberof TreeViewItemPrototype
*/
private _evt;
/**
* Reference to the root node
*
* @type {TreeViewTag}
* @memberof TreeViewItemPrototype
*/
treeroot: TreeViewTag;
/**
* The tree path from the root node
*
* @type {string}
* @memberof TreeViewItemPrototype
*/
treepath: string;
/**
* Reference to the parent node of the current node
*
* @type {TreeViewTag}
* @memberof TreeViewItemPrototype
*/
parent: TreeViewTag;
/**
* Placeholder for the `fetch` function of the node.
* This function is used to fetch the child nodes of the
* current nodes. This function should return a promise on
* a list of [[TreeViewDataType]]
*
* @memberof TreeViewItemPrototype
*/
fetch: (d: TreeViewItemPrototype) => Promise<TreeViewDataType[]>;
/**
*Creates an instance of TreeViewItemPrototype.
* @memberof TreeViewItemPrototype
*/
constructor();
/**
* Update the tree, this function
* is used to refresh/expand/collapse the
* current node based on the input parameter
*
* @protected
* @param {*} p string indication, the value should be:
* - `expand`: expand the current node
* - `collapse`: collapse the current node
* - other string: this string is considered as a tree path of a node. If this value
* is the value of current node tree path, the node will be refreshed. Otherwise, nothing
* happens
* @returns {void}
* @memberof TreeViewItemPrototype
*/
protected reload(p: any): void;
/**
* Setter:
*
* Set the data of the current node. This will trigger the
* [[ondatachange]] function
*
* Getter:
*
* Get the current node's data
*
* @memberof TreeViewItemPrototype
*/
set data(v: TreeViewDataType);
get data(): TreeViewDataType;
/**
* Setter:
*
* Select or unselect the current node.
* This will trigger the item select event
* on the tree root if the parameter is `true`
*
* Getter:
*
* Check whether the current node is selected
*
* @memberof TreeViewItemPrototype
*/
set selected(v: boolean);
get selected(): boolean;
/**
* Setter:
*
* Refresh the current node and expands its sub tree.
* This function only works if the current node is not
* a leaf node
*
* Getter:
*
* Check whether the current node is expanded
*
* @memberof TreeViewItemPrototype
*/
set open(v: boolean);
get open(): boolean;
/**
* Setter: Set the current indent level of this node from the root node
*
* Getter: Get the current indent level
*
* @type {number}
* @memberof TreeViewItemPrototype
*/
get indent(): number;
set indent(v: number);
/**
* Check whether the current node is not a leaf node
*
* @private
* @returns {boolean}
* @memberof TreeViewItemPrototype
*/
private is_folder;
/**
* Getter: Get the child nodes data of the current node
*
* Setter: Set the child nodes data of the current node
*
* @type {TreeViewDataType[]}
* @memberof TreeViewItemPrototype
*/
get nodes(): TreeViewDataType[];
set nodes(nodes: TreeViewDataType[]);
/**
* Init the tag with default properties data
*
* @protected
* @memberof TreeViewItemPrototype
*/
protected init(): void;
/**
* Mount the tag and bind basic events
*
* @protected
* @memberof TreeViewItemPrototype
*/
protected mount(): void;
/**
* Layout definition of a node. This function
* returns the definition of the base outer layout
* of a node. Custom inner layout of the node should
* be defined in the [[itemlayout]] function
*
* @protected
* @returns {TagLayoutType[]}
* @memberof TreeViewItemPrototype
*/
protected layout(): TagLayoutType[];
/**
* This function need to be implemented by all subclasses
* to define the inner layout of the node
*
* @protected
* @abstract
* @returns {TagLayoutType[]}
* @memberof TreeViewItemPrototype
*/
protected abstract itemlayout(): TagLayoutType[];
/**
* This function is called when the node data change.
* It needs to be implemented on all subclasses of this
* class
*
* @protected
* @abstract
* @memberof TreeViewItemPrototype
*/
protected abstract ondatachange(): void;
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* SimpleTreeViewItem extends [[TreeViewItemPrototype]] and
* define it inner layout using a [[LabelTag]]
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class SimpleTreeViewItem
* @extends {TreeViewItemPrototype}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
class SimpleTreeViewItem extends TreeViewItemPrototype {
/**
*Creates an instance of SimpleTreeViewItem.
* @memberof SimpleTreeViewItem
*/
constructor();
/**
* Refresh the label when data changed
*
* @protected
* @returns {void}
* @memberof SimpleTreeViewItem
*/
protected ondatachange(): void;
/**
* Inner layout definition
*
* @protected
* @returns
* @memberof SimpleTreeViewItem
*/
protected itemlayout(): {
el: string;
ref: string;
}[];
}
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* A tree view widget presents a hierarchical list of nodes.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class TreeViewTag
* @extends {AFXTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
class TreeViewTag extends AFXTag {
/**
* Reference to the selected node
*
* @private
* @type {TreeViewItemPrototype}
* @memberof TreeViewTag
*/
private _selectedItem;
/**
* Placeholder for tree select event handle
*
* @private
* @type {TagEventCallback<TreeItemEventData>}
* @memberof TreeViewTag
*/
private _ontreeselect;
/**
* Place holder for tree double click event handle
*
* @private
* @type {TagEventCallback<TreeItemEventData>}
* @memberof TreeViewTag
*/
private _ontreedbclick;
/**
* Placeholder for drag and drop event handle
*
* @private
* @type {TagEventCallback<DnDEventDataType<TreeViewTag>>}
* @memberof TreeViewTag
*/
private _ondragndrop;
/**
* Tree data placeholder
*
* @private
* @type {TreeViewDataType}
* @memberof TreeViewTag
*/
private _data;
/**
* Placeholder for private dragndrop mouse down event handle
*
* @private
* @memberof TreeViewTag
*/
private _treemousedown;
/**
* Placeholder for private dragndrop mouse up event handle
*
* @private
* @memberof TreeViewTag
*/
private _treemouseup;
/**
* Placeholder for private dragndrop mouse move event handle
*
* @private
* @memberof TreeViewTag
*/
private _treemousemove;
/**
* Private data object passing between dragndrop mouse event
*
* @private
* @type {{ from: TreeViewTag[]; to: TreeViewTag }}
* @memberof TreeViewTag
*/
private _dnd;
/**
* Reference to parent tree of the current tree.
* This value is undefined if the current tree is the root
*
* @type {TreeViewTag}
* @memberof TreeViewTag
*/
parent: TreeViewTag;
/**
* Reference to the root tree, this value is undefined
* if the curent tree is root
*
* @type {TreeViewTag}
* @memberof TreeViewTag
*/
treeroot: TreeViewTag;
/**
* tree path of the current tree from the root
*
* @type {string}
* @memberof TreeViewTag
*/
treepath: string;
/**
* Indent level of the current tree
*
* @type {number}
* @memberof TreeViewTag
*/
indent: number;
/**
* Indicates whether the tree should be expanded
*
* @type {boolean}
* @memberof TreeViewTag
*/
open: boolean;
/**
* Placeholder for the `fetch` function of the tree.
* This function is used to fetch the child nodes of the
* current tree. This function should return a promise on
* a list of [[TreeViewDataType]]
*
* @memberof TreeViewTag
*/
fetch: (d: TreeViewItemPrototype) => Promise<TreeViewDataType[]>;
/**
*Creates an instance of TreeViewTag.
* @memberof TreeViewTag
*/
constructor();
/**
* Init the tree view before mounting:
*
* @protected
* @memberof TreeViewTag
*/
protected init(): void;
/**
* Layout definition
*
* @protected
* @returns {TagLayoutType[]}
* @memberof TreeViewTag
*/
protected layout(): TagLayoutType[];
/**
* Do nothing
*
* @protected
* @param {*} [d]
* @memberof TreeViewTag
*/
protected reload(d?: any): void;
/**
* Setter: Enable/disable drag and drop event on the tree
*
* Getter: Check whether the drag and drop event is enabled
*
* @memberof TreeViewTag
*/
set dragndrop(v: boolean);
get dragndrop(): boolean;
/**
* Set the tree select event handle
*
* @memberof TreeViewTag
*/
set ontreeselect(v: TagEventCallback<TreeItemEventData>);
/**
* Set the tree double click event handle
*
* @memberof TreeViewTag
*/
set ontreedbclick(v: TagEventCallback<TreeItemEventData>);
/**
* Setter:
*
* Set the default tag name of the tree node.
* If there is no tag name in the node data,
* this value will be used when creating node.
*
* Defaut to `afx-tree-view-item`
*
* Getter:
*
* Get the default node tag name
*
* @memberof TreeViewTag
*/
set itemtag(v: string);
get itemtag(): string;
/**
* Unselect the selected element in the tree
*
* @memberof TreeViewTag
*/
unselect(): void;
/**
* Setter: Set the selected node using its DOM element
*
* Getter: Get the DOM element of the selected node
*
* @type {TreeViewItemPrototype}
* @memberof TreeViewTag
*/
get selectedItem(): TreeViewItemPrototype;
set selectedItem(v: TreeViewItemPrototype);
/**
* Expand all nodes in the tree
*
* @returns {void}
* @memberof TreeViewTag
*/
expandAll(): void;
/**
* Collapse all nodes in the tree
*
* @returns {void}
* @memberof TreeViewTag
*/
collapseAll(): void;
/**
* This function will trigger the tree select or tree double click
* event
*
* @param {TagEventType} e
* @returns {void}
* @memberof TreeViewTag
*/
itemclick(e: TagEventType<TreeItemEventData>): void;
/**
* Check whether the current tree is a root tree
*
* @returns {boolean}
* @memberof TreeViewTag
*/
is_root(): boolean;
/**
* Check whether the current tree tag is a leaf
*
* @returns {boolean}
* @memberof TreeViewTag
*/
is_leaf(): boolean;
/**
* Set drag and drop event handle
*
* @memberof TreeViewTag
*/
set ondragndrop(v: TagEventCallback<DnDEventDataType<TreeViewTag>>);
/**
* Setter:
*
* Set the tree data. This operation will create
* all tree node elements of the current tree
*
* Getter:
*
* Get the tree data
*
* @memberof TreeViewTag
*/
set data(v: TreeViewDataType);
get data(): TreeViewDataType;
/**
* Mount the tree view
*
* @protected
* @memberof TreeViewTag
*/
protected mount(): void;
}
}
}
}
/// <reference types="jquery" />
declare namespace OS {
namespace GUI {
namespace tag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Menu event data interface definition
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
type MenuEventData = TagEventDataType<MenuEntryTag>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This class defines the abstract prototype of an menu entry.
* Any implementation of menu entry tag should extend this class
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @export
2021-04-21 11:37:58 +02:00
* @abstract
2022-07-17 14:13:44 +02:00
* @class MenuEntryTag
* @extends {AFXTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
abstract class MenuEntryTag extends AFXTag {
/**
* Data placeholder of the menu entry
*
* @private
* @type {GenericObject<any>}
* @memberof MenuEntryTag
*/
private _data;
/**
* placeholder of `menu entry select` event handle
*
* @private
* @type {TagEventCallback<MenuEventData>}
* @memberof MenuEntryTag
*/
private _onmenuselect;
/**
* placeholder of `sub-menu entry select event` handle
*
* @private
* @type {TagEventCallback<MenuEventData>}
* @memberof MenuEntryTag
*/
private _onchildselect;
/**
* Reference to the parent menu entry of current one
*
* @type {MenuEntryTag}
* @memberof MenuEntryTag
*/
parent: MenuEntryTag;
/**
* Reference to the root menu entry
*
* @type {MenuTag}
* @memberof MenuEntryTag
*/
root: MenuTag;
/**
*Creates an instance of MenuEntryTag.
* @memberof MenuEntryTag
*/
constructor();
/**
* Init the tag before mounting
*
* @protected
* @memberof MenuEntryTag
*/
protected init(): void;
/**
* Set the `menu entry select` event handle
*
* @memberof MenuEntryTag
*/
set onmenuselect(v: TagEventCallback<MenuEventData>);
/**
* Setter: Set the `sub menu entry select` event handle
*
* Getter: get the current `sub menu entry select` event handle
*
* @memberof MenuEntryTag
*/
set onchildselect(v: TagEventCallback<MenuEventData>);
get onchildselect(): TagEventCallback<MenuEventData>;
/**
* Setter: Set data to the entry
*
* Getter: Get data of the current menu entry
*
* @memberof MenuEntryTag
*/
set data(data: GenericObject<any>);
get data(): GenericObject<any>;
/**
* Check whether the current menu entry has sub-menu
*
* @protected
* @returns {boolean}
* @memberof MenuEntryTag
*/
protected has_nodes(): boolean;
/**
* Check whether the current menu entry is the root entry
*
* @protected
* @returns
* @memberof MenuEntryTag
*/
protected is_root(): boolean;
/**
* Layout definition of the menu entry
* This function define the outer layout of the menu entry.
* Custom inner layout of each item implementation should
* be defined in [[itemlayout]]
* @protected
* @returns {TagLayoutType[]}
* @memberof MenuEntryTag
*/
protected layout(): TagLayoutType[];
/**
* Setter: Set the sub-menu data
*
* Getter: Get the sub-menu data
*
* @memberof MenuEntryTag
*/
set nodes(v: GenericObject<any>[]);
get nodes(): GenericObject<any>[];
/**
* Bind some base event to the menu entry
*
* @protected
* @memberof MenuEntryTag
*/
protected mount(): void;
/**
* Hide the sub-menu of the current menu entry
*
* @private
* @returns {void}
* @memberof MenuEntryTag
*/
private submenuoff;
/**
* This function trigger two event:
* - the `onmenuselect` event on the current entry
* - the `onchildselect` event on the parent of the current entry
*
* @protected
* @param {JQuery.ClickEvent} e
* @memberof MenuEntryTag
*/
protected select(e: JQuery.ClickEvent): void;
/**
* custom inner layout of a menu entry
*
* @protected
* @abstract
* @returns {TagLayoutType[]}
* @memberof MenuEntryTag
*/
protected abstract itemlayout(): TagLayoutType[];
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* This class extends the [[MenuEntryTag]] prototype. It inner layout is
* defined with the following elements:
* - a [[SwitchTag]] acts as checker or radio
* - a [[LabelTag]] to display the content of the menu entry
* - a `span` element that display the keyboard shortcut of the entry
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @class SimpleMenuEntryTag
* @extends {MenuEntryTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class SimpleMenuEntryTag extends MenuEntryTag {
/**
*Creates an instance of SimpleMenuEntryTag.
* @memberof SimpleMenuEntryTag
*/
constructor();
/**
* Reset some properties to default value
*
* @protected
* @memberof SimpleMenuEntryTag
*/
protected init(): void;
/**
* Do nothing
*
* @protected
* @memberof SimpleMenuEntryTag
*/
protected calibrate(): void;
/**
* Do nothing
*
* @protected
* @param {*} [d]
* @memberof SimpleMenuEntryTag
*/
protected reload(d?: any): void;
/**
* Setter: Turn on/off the checker feature of the menu entry
*
* Getter: Check whether the checker feature is enabled on this menu entry
*
* @memberof SimpleMenuEntryTag
*/
set switch(v: boolean);
get switch(): boolean;
/**
* Setter: Turn on/off the radio feature of the menu entry
*
* Getter: Check whether the radio feature is enabled
*
* @memberof SimpleMenuEntryTag
*/
set radio(v: boolean);
get radio(): boolean;
/**
* Setter:
*
* Toggle the switch on the menu entry, this setter
* only works when the `checker` or `radio` feature is
* enabled
*
* Getter:
*
* Check whether the switch is turned on
*
* @memberof SimpleMenuEntryTag
*/
set checked(v: boolean);
get checked(): boolean;
/**
* Set the label icon using a VFS path
*
* @memberof SimpleMenuEntryTag
*/
set icon(v: string);
/**
* Set the label CSS icon class
*
* @memberof SimpleMenuEntryTag
*/
set iconclass(v: string);
/**
* Set the label text
*
* @memberof SimpleMenuEntryTag
*/
set text(v: string);
/**
* Set the keyboard shortcut text
*
* @memberof SimpleMenuEntryTag
*/
set shortcut(v: string);
/**
* Uncheck all sub-menu items of the current menu entry
* that have the radio feature enabled
*
* @returns {void}
* @memberof SimpleMenuEntryTag
*/
protected reset_radio(): void;
/**
* Mount the current tag
*
* @protected
* @memberof SimpleMenuEntryTag
*/
protected mount(): void;
/**
* Trigger the onmenuselect and onchildselect events
*
* @protected
* @param {JQuery.ClickEvent} e Mouse click event
* @returns {void}
* @memberof SimpleMenuEntryTag
*/
protected select(e: JQuery.ClickEvent): void;
/**
* Inner item layout of the menu entry
*
* @returns
* @memberof SimpleMenuEntryTag
*/
itemlayout(): ({
el: string;
ref: string;
class?: undefined;
} | {
el: string;
class: string;
ref: string;
})[];
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A menu tag contains a collection of menu entries in which each
* entry maybe a leaf entry or may contain a submenu
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @export
* @class MenuTag
* @extends {AFXTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class MenuTag extends AFXTag {
/**
* Reference to the parent menu entry of the current value.
* This value is `undefined` in case of the current menu is
* the root menu
*
* @type {MenuEntryTag}
* @memberof MenuTag
*/
parent: MenuEntryTag;
/**
* Reference to the root menu
*
* @type {MenuTag}
* @memberof MenuTag
*/
root: MenuTag;
/**
* The `pid` of the application that attached to this menu.
* This value is optional
*
* @type {number}
* @memberof MenuTag
*/
pid?: number;
/**
* placeholder for menu select event handle
*
* @private
* @type {TagEventCallback<MenuEventData>}
* @memberof MenuTag
*/
private _onmenuselect;
/**
* Menu data placeholder
*
* @private
* @type {GenericObject<any>[]}
* @memberof MenuTag
*/
private _items;
/**
*Creates an instance of MenuTag.
* @memberof MenuTag
*/
constructor();
/**
* Reset some properties to default value
*
* @protected
* @memberof MenuTag
*/
protected init(): void;
/**
* Do nothing
*
* @protected
* @memberof MenuTag
*/
protected calibrate(): void;
/**
* Do nothing
*
* @protected
* @param {*} [d]
* @memberof MenuTag
*/
protected reload(d?: any): void;
/**
* Setter: Set the menu items data
*
* Getter: Get menu items data
*
* @memberof MenuTag
*/
set items(data: GenericObject<any>[]);
get items(): GenericObject<any>[];
/**
* Setter: Set whether the current menu is a context menu
*
* Getter: Check whether the current menu is a context menu
*
* @memberof MenuTag
*/
set context(v: boolean);
get context(): boolean;
/**
* Set menu select event handle
*
* @memberof MenuTag
*/
set onmenuselect(v: TagEventCallback<MenuEventData>);
/**
* Setter:
*
* Set the default tag name of the menu item.
* If the tag is not specified in an item data,
* this value will be used
*
* Getter:
*
* Get the default menu entry tag name
*
* @memberof MenuTag
*/
set contentag(v: string);
get contentag(): string;
/**
* Get the reference to the function that triggers
* the menu select event
*
* @readonly
* @type {TagEventCallback}
* @memberof MenuTag
*/
get onmenuitemselect(): TagEventCallback<MenuEventData>;
/**
* This function triggers the menu select event
*
* @private
* @param {TagEventType} e
* @memberof MenuTag
*/
private handleselect;
/**
* Show the current menu. This function is called
* only if the current menu is a context menu
*
* @param {JQuery.MouseEventBase} e JQuery mouse event
* @returns {void}
* @memberof MenuTag
*/
show(e: JQuery.MouseEventBase): void;
/**
* Test whether the current menu is the root menu
*
* @private
* @returns {boolean}
* @memberof MenuTag
*/
private is_root;
/**
* Mount the menu tag and bind some basic events
*
* @protected
* @returns {void}
* @memberof MenuTag
*/
protected mount(): void;
/**
* Add a menu entry to the beginning of the current
* menu
*
* @param {GenericObject<any>} item menu entry data
* @memberof MenuTag
*/
unshift(item: GenericObject<any>): void;
/**
* Delete a menu entry
*
* @param {MenuEntryTag} item reference to the DOM element of an menu entry
* @memberof MenuTag
*/
delete(item: MenuEntryTag): void;
/**
* Add an menu entry to the beginning or end of the menu
*
* @param {GenericObject<any>} item menu entry data
* @param {boolean} flag indicates whether the entry should be added to the beginning of the menu
* @returns {MenuEntryTag}
* @memberof MenuTag
*/
push(item: GenericObject<any>, flag: boolean): MenuEntryTag;
/**
* Menu tag layout definition
*
* @returns
* @memberof MenuTag
*/
layout(): {
el: string;
ref: string;
children: ({
el: string;
class: string;
ref?: undefined;
} | {
el: string;
ref: string;
class?: undefined;
})[];
}[];
}
}
}
}
declare namespace OS {
namespace GUI {
namespace tag {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* A slider or track bar is a graphical control element with which
* a user may set a value by moving an indicator, usually horizontally
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @class SliderTag
* @extends {AFXTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class SliderTag extends AFXTag {
/**
* Slider max value placeholder
*
* @private
* @type {number}
* @memberof SliderTag
*/
private _max;
/**
* Current slider value placeholder
*
* @private
* @type {number}
* @memberof SliderTag
*/
private _value;
/**
* Placeholder of the on change event handle
*
* @private
* @type {TagEventCallback<number>}
* @memberof SliderTag
*/
private _onchange;
/**
* Placeholder of the on changing event handle
*
* @private
* @type {TagEventCallback<number>}
* @memberof SliderTag
*/
private _onchanging;
/**
* Creates an instance of SliderTag.
* @memberof SliderTag
*/
constructor();
/**
* Init the default value of the slider:
* - `max`: 100
* - `value`: 0
*
* @protected
* @memberof SliderTag
*/
protected init(): void;
/**
* Do nothing
*
* @protected
* @param {*} [d]
* @memberof SliderTag
*/
protected reload(d?: any): void;
/**
* Set value change event handle.
* This handle will be triggered when the
* slider indicator is released
*
* @memberof SliderTag
*/
set onvaluechange(f: TagEventCallback<number>);
/**
* Set value changing event handle.
* This handle is triggered when moving the
* slider indicator
*
* @memberof SliderTag
*/
set onvaluechanging(f: TagEventCallback<number>);
/**
* Setter: Enable/disable the slider
*
* Getter: Check whether the slider is enabled
*
* @memberof SliderTag
*/
set enable(v: boolean);
get enable(): boolean;
/**
* Setter: Set the slider value
*
* Getter: Get the current slider value
*
* @memberof SliderTag
*/
set value(v: number);
get value(): number;
/**
* Setter: Set the maximum value of the slider
*
* Getter: Get the maximum value of the slider
*
* @memberof SliderTag
*/
set max(v: number);
get max(): number;
/**
* Mount the tag and bind some basic events
*
* @protected
* @memberof SliderTag
*/
protected mount(): void;
/**
* Calibrate the slide based on its value and max value
*
* @memberof SliderTag
*/
calibrate(): void;
/**
* enable dragging on the slider indicator
*
* @private
* @memberof SliderTag
*/
private enable_dragging;
/**
* Layout definition
*
* @protected
* @returns {TagLayoutType[]}
* @memberof SliderTag
*/
protected layout(): TagLayoutType[];
}
2021-11-24 22:47:49 +01:00
}
2022-07-17 14:13:44 +02:00
}
}
declare namespace OS {
namespace GUI {
2021-11-24 22:47:49 +01:00
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class OverlayTag
* @extends {AFXTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
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[];
}
2021-11-24 22:47:49 +01:00
}
}
}
declare namespace OS {
namespace GUI {
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* 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.
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class DesktopTag
* @extends {FloatListTag}
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
class DesktopTag extends FloatListTag {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* internal handle to the desktop file location
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {API.VFS.BaseFileHandle}
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private file;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* local observer that detect if a new child element is
* added or removed
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {MutationObserver}
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private observer;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Internal list of the current opened window
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {Set<WindowTag>}
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private window_list;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Creates an instance of DesktopTag.
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
constructor();
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Mount the virtual desktop to the DOM tree
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Display all files and folders in the specific desktop location
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @return {*} {Promise<any>}
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
refresh(): Promise<any>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Remove this element from its parent
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
remove(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Active a window above all other windows
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {WindowTag} win
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private selectWindow;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Render all windows in order from bottom to top
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof DesktopTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
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 {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Update the current tag, do nothing
2021-11-24 22:47:49 +01:00
*
* @protected
* @param {*} [d]
2022-07-17 14:13:44 +02:00
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
protected reload(d?: any): void;
/**
2022-07-17 14:13:44 +02:00
* Variable that hold the onready callback of
* the tag. This callback will be called after
* the tag is mounted
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _onready;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
*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
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set onready(v: (e: FloatListTag) => void);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Set the direction of the list item layout.
* Two directions are available:
* - `vertical`
* - `horizontal`
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* This setter acts as a DOM attribute
*
* Getter:
*
* Get the currently set direction of list
* item layout
*
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set dir(v: string);
get dir(): string;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Disable the dropdown option in this list
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set dropdown(v: boolean);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Disable the list buttons configuration in this
* list
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof FloatListTag
*/
set buttons(v: GenericObject<any>[]);
/**
* Disable the `showlist` behavior in this list
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {*} e
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected showlist(e: any): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Disable the `dropoff` behavior in this list
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {*} e
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected dropoff(e: any): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Function called when the data of the list
* is changed
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected ondatachange(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Mount the list to the DOM tree
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
2021-11-24 22:47:49 +01:00
* @returns {void}
2022-07-17 14:13:44 +02:00
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected mount(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Push an element to the list
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @param {GenericObject<any>} v an element data
* @returns
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
push(v: GenericObject<any>): ListViewItemTag;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Enable drag and drop on the list
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @param {ListViewItemTag} el the list item DOM element
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private enable_drag;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Calibrate the view of the list
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof FloatListTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
calibrate(): void;
2021-11-24 22:47:49 +01:00
}
}
}
}
declare namespace OS {
namespace GUI {
2022-07-17 14:13:44 +02:00
/**
*
* Interface for an application dock item
*
* @export
* @interface AppDockItemType
*/
interface AppDockItemType {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the application process represented
* by the dock item
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {application.BaseApplication}
* @memberof AppDockItemType
*/
app: application.BaseApplication;
/**
* Reference to the DOM element of
* the owner dock item
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {AFXTag}
* @memberof AppDockItemType
*/
domel?: AFXTag;
[propName: string]: any;
}
namespace tag {
/**
* This class define the AntOS system application dock tag
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @export
2022-07-17 14:13:44 +02:00
* @class AppDockTag
2021-11-24 22:47:49 +01:00
* @extends {AFXTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
class AppDockTag extends AFXTag {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* variable holds the application select event
* callback handle
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<any>}
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _onappselect;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Items data of the dock
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {AppDockItemType[]}
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _items;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Reference to the currently select application
* process in the dock
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {AppDockItemType}
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _selectedItem;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of AppDockTag.
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
constructor();
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Implementation of the abstract function: Update the current tag.
* It do nothing for this tag
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @param {*} [d]
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected reload(d?: any): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Init the tag before mounting
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected init(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* The tag layout, it is empty on creation but elements will
* be added automatically to it in operation
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {TagLayoutType[]}
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected layout(): TagLayoutType[];
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* getter to get the dock items
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @readonly
* @type {AppDockItemType[]}
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
get items(): AppDockItemType[];
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter:
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set selectedApp(v: application.BaseApplication);
get selectedApp(): application.BaseApplication;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Get selected item of the dock
*
* @readonly
* @type {AppDockItemType}
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
get selectedItem(): AppDockItemType;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @param {AppDockItemType} item an application dock item entry
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
newapp(item: AppDockItemType): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
removeapp(a: application.BaseApplication): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Mount the current dock tag
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof AppDockTag
2021-11-24 22:47:49 +01:00
*/
protected mount(): void;
}
2021-04-21 11:37:58 +02:00
}
2021-11-24 22:47:49 +01:00
}
}
declare namespace OS {
namespace GUI {
2021-04-21 11:37:58 +02:00
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* Tag that define system calendar widget
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class CalendarTag
2021-11-24 22:47:49 +01:00
* @extends {AFXTag}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
class CalendarTag extends AFXTag {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* The current selected day
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {number}
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _day;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* The current selected month
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {number}
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _month;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* The current selected year
*
* @private
* @type {number}
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _year;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* The current selected date object
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {Date}
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _selectedDate;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* placeholder for date select event callback
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @type {TagEventCallback<Date>}
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _ondateselect;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of CalendarTag.
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
constructor();
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Init the tag before mounting
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected init(): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Update the current tag, doing nothing in this tag
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {*} [d] any data object
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected reload(d?: any): void;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Get the current selected date in the widget
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @readonly
* @type {Date}
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
get selectedDate(): Date;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Set the date select event callback handle for the widget
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set ondateselect(v: TagEventCallback<Date>);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Mount the current widget to the DOM tree
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
protected mount(): void;
/**
2022-07-17 14:13:44 +02:00
* This function triggers the date select event
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @param {TagEventType} e AFX tag event data [[TagEventType]]
* @returns {void}
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private dateselect;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Calibrate the layout of the tag
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
protected calibrate(): void;
/**
2022-07-17 14:13:44 +02:00
* Display the previous month of the current month
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private prevmonth;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* 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
2021-11-24 22:47:49 +01:00
*
* @protected
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof CalendarTag
2021-11-24 22:47:49 +01:00
*/
protected layout(): TagLayoutType[];
}
2021-04-21 11:37:58 +02:00
}
}
}
declare namespace OS {
namespace GUI {
namespace tag {
/**
2022-07-17 14:13:44 +02:00
* A WindowTag represents a virtual window element
* used by AntOS applications and dialogs.
2021-04-21 11:37:58 +02:00
*
* @export
2022-07-17 14:13:44 +02:00
* @class WindowTag
2021-04-21 11:37:58 +02:00
* @extends {AFXTag}
*/
2022-07-17 14:13:44 +02:00
class WindowTag extends AFXTag {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The element ID of the virtual desktop element
*
* @type {string}
* @memberof WindowTag
*/
desktop: string;
/**
* Window width placeholder
2021-04-21 11:37:58 +02:00
*
* @private
2021-11-24 22:47:49 +01:00
* @type {number}
2022-07-17 14:13:44 +02:00
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _width;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Window height placeholder
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
* @type {number}
2022-07-17 14:13:44 +02:00
* @memberof WindowTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _height;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder indicates whether the current window is shown
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {boolean}
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _shown;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Placeholder indicates whether the current window is maximized
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {boolean}
* @memberof WindowTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private _isMaxi;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* This placeholder stores the latest offset of the current window.
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @type {GenericObject<any>}
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _history;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* This placeholder stores the offset of the virtual desktop element
*
* @private
* @type {GenericObject<any>}
* @memberof WindowTag
*/
private _desktop_pos;
/**
* Creates an instance of WindowTag.
* @memberof WindowTag
*/
constructor();
/**
* blur overlay: If active the window overlay will be shown
* on inactive (blur event)
*
* Setter: Enable the switch
*
* Getter: Check whether the switch is enabled
*
* @memberof WindowTag
*/
set blur_overlay(v: boolean);
get blur_overlay(): boolean;
/**
* Init window tag
* - `shown`: false
* - `isMaxi`: false
* - `minimizable`: false
* - `resizable`: true
* - `apptitle`: Untitled
*
* @protected
* @memberof WindowTag
*/
protected init(): void;
/**
* Do nothing
*
* @protected
* @memberof WindowTag
*/
protected calibrate(): void;
/**
* Do nothing
*
* @protected
* @param {*} [d]
* @memberof WindowTag
*/
protected reload(d?: any): void;
/**
* Setter: Set the window width
*
* Getter: Get the window width
*
* @memberof WindowTag
*/
set width(v: number);
get width(): number;
/**
* Setter: Set the window height
*
* Getter: Get the window height
*
* @memberof WindowTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set height(v: number);
get height(): number;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter: enable/disable window minimizable
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* getter: Check whether the window is minimizable
*
* @memberof WindowTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set minimizable(v: boolean);
get minimizable(): boolean;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter: enable/disable widow resizable
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Getter: Check whether the current window is resizable
*
* @memberof WindowTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set resizable(v: boolean);
get resizable(): boolean;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Setter: Set the window title
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* Getter: Get window title
*
* @memberof WindowTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
set apptitle(v: string | FormattedString);
get apptitle(): string | FormattedString;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Resize all the children of the window based on its width and height
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @private
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private resize;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Mount the window tag and bind basic events
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
protected mount(): void;
/**
2022-07-17 14:13:44 +02:00
* Set the window size
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @param {GenericObject<any>} o format: `{ w: window_width, h: window_height }`
2021-11-24 22:47:49 +01:00
* @returns {void}
2022-07-17 14:13:44 +02:00
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private setsize;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Enable to drag window on the virtual desktop
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private enable_dragging;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Enable window resize, this only works if the window
* is resizable
2021-04-21 11:37:58 +02:00
*
2021-11-24 22:47:49 +01:00
* @private
2022-07-17 14:13:44 +02:00
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private enable_resize;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Maximize the window or restore its previous width, height,
* and position
2021-11-24 22:47:49 +01:00
*
* @private
2022-07-17 14:13:44 +02:00
* @returns {void}
* @memberof WindowTag
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
private toggle_window;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Layout definition of the window tag
2021-04-21 11:37:58 +02:00
*
* @protected
2021-11-24 22:47:49 +01:00
* @returns {TagLayoutType[]}
2022-07-17 14:13:44 +02:00
* @memberof WindowTag
2021-04-21 11:37:58 +02:00
*/
2021-11-24 22:47:49 +01:00
protected layout(): TagLayoutType[];
2021-04-21 11:37:58 +02:00
}
}
}
}
2022-07-17 14:13:44 +02:00
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;
}
2021-04-21 11:37:58 +02:00
declare namespace OS {
2022-07-17 14:13:44 +02:00
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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* 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<VFSFileHandleClass>;
/**
* 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<any>}
*/
function loadVFSX(force?: boolean): Promise<any>;
/**
* 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[]}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
function findHandles(proto: string): VFSFileHandleClass[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Abstract prototype of all all VFS file handle definition.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* 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
2021-04-21 11:37:58 +02:00
*
* @export
* @abstract
2022-07-17 14:13:44 +02:00
* @class BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
abstract class BaseFileHandle {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Flag indicates whether the file is dirty
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {boolean}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
dirty: boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Once read, file content will be cached in this placeholder
2021-04-21 11:37:58 +02:00
*
* @private
2022-07-17 14:13:44 +02:00
* @type {*}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private _cache;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Flag indicated whether the file meta-data is loaded
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {boolean}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
ready: boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* File path
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
path: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* File protocol e.g:
* - `os://`
* - `home://`
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protocol: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* List of path segments
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string[]}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
genealogy: string[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* File base name
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
basename: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Once loaded, [[ready]] will be set to true and
* file meta-data will be stored in this place holder
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {FileInfoType}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
info: FileInfoType;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* File extension
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
ext: string;
2021-04-21 11:37:58 +02:00
/**
*
2022-07-17 14:13:44 +02:00
* File type
* @type {string}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
type: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of BaseFileHandle.
* @param {string} path file path
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
constructor(path: string);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set a file path to the current file handle
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {string} p
2021-04-21 11:37:58 +02:00
* @returns {void}
2022-07-17 14:13:44 +02:00
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
setPath(p: string): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Getter: Get the file basename
* Setter: set the file name
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {string}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
get filename(): string;
set filename(v: string);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Getter: Get the file cache
* Setter: set the file cache
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {any}
* @memberof BaseFileHandle
*/
get cache(): any;
set cache(v: any);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Set data to the file cache
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {*} v data object
* @returns {BaseFileHandle}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
setCache(v: any): BaseFileHandle;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Return the object itself
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {BaseFileHandle}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
asFileHandle(): BaseFileHandle;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Check whether the current file is the root of the file tree
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {boolean}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
isRoot(): boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Check whether the current file is a hidden file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {boolean}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
isHidden(): boolean;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get hash number of the current file path
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {number}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
hash(): number;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Convert the current file cache to Base64
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} t type of the file cache:
* - `object`
* - `mime type`
* @returns {(Promise<string | ArrayBuffer>)} promise on the converted data
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected b64(t: string): Promise<string | ArrayBuffer>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get the parent file handle of the current file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {BaseFileHandle}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
parent(): BaseFileHandle;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Load the file meta-data before performing
* any task
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<FileInfoType>} a promise on file meta-data
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
onready(): Promise<FileInfoType>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Public read operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* 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<any>} a promise on the file content
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
read(t?: string): Promise<any>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Write the file cache to the actual file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function calls the [[_wr]] function to perform the operation
*
* @param {string} t data type
* - `base64`
* - `object`
* - `mime type`
*
* @returns {Promise<RequestResult>} promise on the operation result
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
write(t: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Sub-directory creation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function calls the [[_mk]] function to perform the operation
*
* @param {string} d sub directory name
* @returns {Promise<RequestResult>} promise on the operation result
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
mk(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Delete the file
*
* This function calls the [[_rm]] function to perform the operation
*
* @returns {Promise<RequestResult>} promise on the operation result
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
remove(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Upload a file to the current directory
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Only work when the current file is a directory
*
* This function calls the [[_up]] function to perform the operation
*
* @returns {Promise<RequestResult>} promise on the operation result
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
upload(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Share the file by publish it.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Only work with file
*
* This function calls the [[_pub]] function to perform the operation
*
* @returns {Promise<RequestResult>} promise on operation result
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
publish(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Download the file.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Only work with file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function calls the [[_down]] function to perform the operation
*
* @returns {Promise<any>} Promise on the operation result
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
download(): Promise<any>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Move the current file to another location
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function calls the [[_mv]] function to perform the operation
*
* @param {string} d destination location
* @returns {Promise<RequestResult>} promise on the operation result
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
move(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Execute the current file.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This action depends on each file protocol
*
* This function calls the [[_exec]] function to perform the operation
*
* @returns {Promise<any>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
execute(): Promise<any>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Get an accessible link to the file
* that can be accessed from the browser
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {string}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
getlink(): string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Helper function returns a promise on unsupported action
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @param {string} t action name
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected unsupported(t: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* trigger cache changed event
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function triggered when the file cached changed
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @memberof BaseFileHandle
*/
protected _cache_changed(): void;
/**
* Low level protocol-specific read operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden on the file handle class
* that supports the operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} t data type, see [[read]]
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _rd(t: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Low level protocol-specific write operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} t data type, see [[write]]
* @param {*} [d]
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
*/
protected _wr(t: string, d?: any): Promise<RequestResult>;
/**
* Low level protocol-specific sub-directory creation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} d sub directory name
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _mk(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Low level protocol-specific delete operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _rm(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Low level protocol-specific move operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} d
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _mv(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Low level protocol-specific upload operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _up(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Low level protocol-specific download operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
*
* @returns {Promise<any>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _down(): Promise<any>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Low level protocol-specific execute operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _exec(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Low level protocol-specific share operation
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* This function should be overridden by the file handle class
* that supports the operation
*
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _pub(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Read the current file meta-data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* should be implemented by subclasses
*
* @abstract
* @returns {Promise<RequestResult>}
* @memberof BaseFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
abstract meta(): Promise<RequestResult>;
}
/**
* 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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of RemoteFileHandle.
* @param {string} path file path
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
constructor(path: string);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Read remote file meta-data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
meta(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Remote file access link
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {string}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
getlink(): string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Read remote file content.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* 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<any>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _rd(t: string): Promise<any>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Write file cache to the remote file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} t data type see [[write]]
* @returns {Promise<RequestResult>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _wr(t: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Create sub directory
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Only work on directory file handle
*
* @protected
* @param {string} d sub directory name
* @returns {Promise<RequestResult>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _mk(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Delete file/folder
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {Promise<RequestResult>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _rm(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Move file/folder
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} d
* @returns {Promise<RequestResult>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _mv(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Upload a file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Only work with directory file handle
*
* @protected
* @returns {Promise<RequestResult>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _up(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Download a file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* only work with file
*
* @protected
* @returns {Promise<void>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _down(): Promise<void>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Publish a file
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof RemoteFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _pub(): Promise<RequestResult>;
}
/**
* 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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of PackageFileHandle.
* @param {string} pkg_path package path in string
* @memberof PackageFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of ApplicationHandle.
* @param {string} path file path
* @memberof ApplicationHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
constructor(path: string);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Read application meta-data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof ApplicationHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
meta(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* If the current file is root (e.g. `app://`), the operation
* will return all system packages meta-data.
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* Otherwise, an error will be thrown
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @param {string} t
* @returns {Promise<any>}
* @memberof ApplicationHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _rd(t: string): Promise<any>;
2021-04-21 11:37:58 +02:00
}
/**
2022-07-17 14:13:44 +02:00
* A buffer file handle represents a virtual file that is stored
* on the system memory. Its protocol pattern is defined as:
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* ```typescript
* "^mem$" // e.g. mem://test.txt
* ```
*
* @class BufferFileHandle
* @extends {BaseFileHandle}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
class BufferFileHandle extends BaseFileHandle {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of BufferFileHandle.
* @param {string} path file path
* @param {string} mime file mime-type
* @param {*} data file data
* @memberof BufferFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
constructor(path: string, mime: string, data: any);
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* init the mem file tree if necessary
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
private init_file_tree;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* cache changed handle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _cache_changed(): void;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Read the file meta-data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof BufferFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
meta(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Load the file meta-data before performing
* any task
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<FileInfoType>} a promise on file meta-data
* @memberof BufferFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
onready(): Promise<FileInfoType>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Read file content stored in the file cached
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} t data type see [[read]]
* @returns {Promise<any>}
* @memberof BufferFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected _rd(t: string): Promise<any>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Write data to the file cache
*
* @protected
* @param {string} t data type, see [[write]]
* @returns {Promise<RequestResult>}
* @memberof BufferFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected _wr(t: string): Promise<RequestResult>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Create sub directory
*
* Only work on directory file handle
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @param {string} d sub directory name
* @returns {Promise<RequestResult>}
* @memberof BufferFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _mk(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Delete file/folder
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof BufferFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _rm(): Promise<RequestResult>;
setPath(p: string): void;
private updatePath;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Move file/folder
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} d
* @returns {Promise<RequestResult>}
* @memberof BufferFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _mv(d: string): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Download the buffer file
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {Promise<void>}
* @memberof BufferFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
protected _down(): Promise<void>;
}
/**
* 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 {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
*Creates an instance of URLFileHandle.
* @param {string} path
* @memberof URLFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
constructor(path: string);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Read file meta-data
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof URLFileHandle
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
meta(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Read URL content
2021-04-21 11:37:58 +02:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @param {string} t data type see [[read]]
* @returns {Promise<any>}
* @memberof URLFileHandle
*/
protected _rd(t: string): Promise<any>;
}
/**
* 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
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
constructor(path: string);
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Read file meta-data
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof SharedFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
meta(): Promise<RequestResult>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Read file content
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} t data type, see [[read]]
* @returns {Promise<any>}
* @memberof SharedFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected _rd(t: string): Promise<any>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* write data to shared file
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @param {string} t data type, see [[write]]
* @param {string} d file data
* @returns {Promise<RequestResult>}
* @memberof SharedFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected _wr(t: string, d: string): Promise<RequestResult>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Un-publish the file
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {Promise<RequestResult>}
* @memberof SharedFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected _rm(): Promise<RequestResult>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Download shared file
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @protected
* @returns {Promise<void>}
* @memberof SharedFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected _down(): Promise<void>;
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Un publish the file
2021-11-24 22:47:49 +01:00
*
* @protected
2022-07-17 14:13:44 +02:00
* @returns {Promise<RequestResult>}
* @memberof SharedFileHandle
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
protected _pub(): Promise<RequestResult>;
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
/**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<any>}
*/
function readFileFromZip(file: string, type: string, file_name?: string): Promise<any>;
/**
* 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<string>}
*/
function cat(list: string[], data: string, join_by?: string): Promise<string>;
/**
* Read all files content on the list
*
* @export
* @param {string[]} list list of VFS files
* @param {GenericObject<string>[]} contents content array
* @return {void}
*/
function read_files(list: string[]): Promise<GenericObject<string>[]>;
/**
* Copy files to a folder
*
* @export
* @param {string[]} files list of files
* @param {string} to destination folder
* @return {*} {Promise<any[]>}
*/
function copy(files: string[], to: string): Promise<any[]>;
/**
* Create a zip archive from a folder
*
* @export
* @param {string} src source file/folder
* @param {string} dest destination archive
* @return {*} {Promise<void>}
*/
function mkar(src: string, dest: string): Promise<void>;
/**
* Create a list of directories
*
* @export
* @param {string[]} list of directories to be created
* @param {boolen} sync sync/async of directory creation
* @return {*} {Promise<any>}
*/
function mkdirAll(list: string[], sync?: boolean): Promise<any>;
/**
*
*
* @export Extract a zip fle
* @param {string} zfile zip file to extract
* @param {(zip:any) => Promise<string>} [dest_callback] a callback to get extraction destination
* @return {*} {Promise<void>}
*/
function extractZip(zfile: string | API.VFS.BaseFileHandle, dest_callback: (zip: any) => Promise<string>): Promise<void>;
/**
* Make files from a set of template files
*
* @export
* @param {Array<string[]>} 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<any[]>}
*/
function mktpl(list: Array<string[]>, path: string, callback: (data: string) => string): Promise<any[]>;
}
}
}
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;
2021-04-21 11:37:58 +02:00
}
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Theme setting data type
2021-11-24 22:47:49 +01:00
*
* @export
2022-07-17 14:13:44 +02:00
* @interface ThemeSettingType
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
interface ThemeSettingType {
2021-11-24 22:47:49 +01:00
/**
2022-07-17 14:13:44 +02:00
* Theme name, this value is used for looking
* theme file in system asset
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof ThemeSettingType
2021-11-24 22:47:49 +01:00
*/
2022-07-17 14:13:44 +02:00
name: string;
/**
* Theme user-friendly text
*
* @type {string}
* @memberof ThemeSettingType
*/
text: string;
2021-11-24 22:47:49 +01:00
}
2022-07-17 14:13:44 +02:00
/**
* Appearance setting data type
*
* @export
* @interface AppearanceSettingType
*/
interface AppearanceSettingType {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Current theme name
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof AppearanceSettingType
*/
theme: string;
/**
* All themes available in the system
2021-11-24 22:47:49 +01:00
*
2022-07-17 14:13:44 +02:00
* @type {ThemeSettingType[]}
* @memberof AppearanceSettingType
*/
themes: ThemeSettingType[];
/**
* Current wallpaper setting
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {WPSettingType}
* @memberof AppearanceSettingType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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;
2021-04-21 11:37:58 +02:00
}
2022-07-17 14:13:44 +02:00
/**
* Global system setting data type
*
* @export
* @interface SystemSettingType
*/
interface SystemSettingType {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* System error report URL
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
* @memberof SystemSettingType
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
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: {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* User specific packages install location
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
user: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* System packages install location
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
system: string;
};
/**
* Package repositories setting.
* This configuration is used by [[MarketPlace]]
* for package management
*
* @type {{
* text: string;
* url: string;
* }[]}
* @memberof SystemSettingType
*/
repositories: {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Repository name
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
text: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* Repository uri
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
url: string;
}[];
/**
* Startup applications and services
*
* @type {{
* apps: string[];
* services: string[];
* }}
* @memberof SystemSettingType
*/
startup: {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* List of application names
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string[]}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
apps: string[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* List of service names
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string[]}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
services: string[];
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* List of pinned applications
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string[]}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
pinned: string[];
};
}
/**
* User settings
*/
var user: UserSettingType;
/**
* Application settings
*/
var applications: GenericObject<any>;
/**
* 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;
}
/// <reference types="jquery" />
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<GUI.tag.MenuEventData>) => 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<HTMLElement>;
/**
* 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<GUI.tag.MenuEventData>): void;
/**
* Do nothing
*
* @protected
* @param {BaseEvent} evt
* @memberof BaseService
*/
protected cleanup(evt: BaseEvent): void;
}
}
}
declare namespace OS {
namespace API {
/**
* Data type exchanged via
* the global Announcement interface
*
* @export
* @interface AnnouncementDataType
*/
interface AnnouncementDataType<T> {
/**
* 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]: {
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The event name
2021-04-21 11:37:58 +02:00
*
2022-07-17 14:13:44 +02:00
* @type {string}
2021-04-21 11:37:58 +02:00
*/
2022-07-17 14:13:44 +02:00
e: string;
2021-04-21 11:37:58 +02:00
/**
2022-07-17 14:13:44 +02:00
* The event callback
2021-04-21 11:37:58 +02:00
*
*/
2022-07-17 14:13:44 +02:00
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<ObservableEntryType>}
* @memberof Announcer
*/
observable: GenericObject<ObservableEntryType>;
/**
* 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<any>) => void} f event callback
* @param {GUI.BaseModel} a the process (Application/service) related to the callback
*/
function on(e: string, f: (d: API.AnnouncementDataType<any>) => 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<any>} d data object represents a current table record
* @returns {Promise<API.RequestResult>}
* @memberof DB
*/
save(d: GenericObject<any>): Promise<API.RequestResult>;
/**
* 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<API.RequestResult>}
* @memberof DB
*/
delete(c: GenericObject<any> | number | string): Promise<API.RequestResult>;
/**
* Get a record in the table by its primary key
*
* @param {number} id the primary key value
* @returns {Promise<GenericObject<any>>} Promise on returned record data
* @memberof DB
*/
get(id: number): Promise<GenericObject<any>>;
/**
* Find records by a condition
*
* @param {GenericObject<any>} 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<GenericObject<any>[]>}
* @memberof DB
*/
find(cond: GenericObject<any>): Promise<GenericObject<any>[]>;
2021-04-21 11:37:58 +02:00
}
}
}
2022-07-17 14:13:44 +02:00
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 <T extends BaseModel>(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<BaseModel[]>;
/**
* 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<ProcessType>} a promise on the created process
*/
function createProcess(app: string, cls: ModelTypeClass, args?: AppArgumentsType[]): Promise<ProcessType>;
/**
* 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;
}
}