v1.0.0a ready

This commit is contained in:
lxsang 2020-06-22 11:28:44 +02:00
parent 4a941f0467
commit a2acafa3d0
6 changed files with 226 additions and 55 deletions

View File

@ -12,6 +12,8 @@ development and deployment of user specific applications.
This repository contains only the front-end API. To have fully functional VDE, AntOS need to connect This repository contains only the front-end API. To have fully functional VDE, AntOS need to connect
to the corresponding server side API. to the corresponding server side API.
![https://os.lxsang.me/VFS/shared/d4645d65b3e4bb348f1bde0d42598ad9b99367f5](https://os.lxsang.me/VFS/shared/d4645d65b3e4bb348f1bde0d42598ad9b99367f5)
## Demo ## Demo
A demo of the VDE is available at my page [https://os.iohub.dev](https://os.iohub.dev) using username: demo and password: demo A demo of the VDE is available at my page [https://os.iohub.dev](https://os.iohub.dev) using username: demo and password: demo
@ -22,7 +24,7 @@ A demo of the VDE is available at my page [https://os.iohub.dev](https://os.ioh
## Documentation ## Documentation
- API documentation: [https://doc.iohuv.dev/antos/api/](https://doc.iohuv.dev/antos/api/) - API documentation: [https://doc.iohub.dev/antos/api/](https://doc.iohub.dev/antos/api/)
## Licence ## Licence

View File

@ -148,7 +148,7 @@ namespace OS {
try { try {
await this.mkfileAll(files, path, name); await this.mkfileAll(files, path, name);
this.app.currdir = rpath.asFileHandle(); this.app.currdir = rpath.asFileHandle();
this.app.initSideBar(); this.app.toggleSideBar();
return this.app.openFile( return this.app.openFile(
`${rpath}/README.md`.asFileHandle() as application.CodePadFileHandle `${rpath}/README.md`.asFileHandle() as application.CodePadFileHandle
); );

View File

@ -1,9 +1,4 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
namespace OS { namespace OS {
const CodePad = OS.application.CodePad; const CodePad = OS.application.CodePad;
declare var JSZip: any; declare var JSZip: any;

View File

@ -130,7 +130,7 @@ namespace OS {
try { try {
await this.mkfileAll(files, path, name); await this.mkfileAll(files, path, name);
this.app.currdir = rpath.asFileHandle(); this.app.currdir = rpath.asFileHandle();
this.app.initSideBar(); this.app.toggleSideBar();
return this.app.openFile( return this.app.openFile(
`${rpath}/${name}.coffee`.asFileHandle() as application.CodePadFileHandle `${rpath}/${name}.coffee`.asFileHandle() as application.CodePadFileHandle
); );

View File

@ -1,50 +1,219 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS205: Consider reworking code to avoid use of IIFEs
* DS208: Avoid top-level this
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
var ace: any; var ace: any;
namespace OS { namespace OS {
export namespace application { export namespace application {
/**
* Extends the [[RemoteFileHandle]] interface with some useful
* properties used by [[CodePad]]
*/
export type CodePadFileHandle = API.VFS.RemoteFileHandle & { export type CodePadFileHandle = API.VFS.RemoteFileHandle & {
/**
* The text will be displayed on the tab bar when opened
*
* @type {string}
*/
text: string; text: string;
/**
* ACE Undo manager of the current file, stores the
* modification history of the file
*
* @type {GenericObject<any>}
*/
um: GenericObject<any>; um: GenericObject<any>;
/**
* Indicate whether the file is selected
*
* @type {boolean}
*/
selected: boolean; selected: boolean;
/**
* Store the latest cursor position on the editor
* when editing the file
*
* @type {GenericObject<any>}
*/
cursor: GenericObject<any>; cursor: GenericObject<any>;
/**
* Language mode setting of the file
*
* @type {GenericObject<string>}
*/
langmode: GenericObject<string>; langmode: GenericObject<string>;
}; };
/**
* [[CodePad]]'s [[CommandPalette]] action type definition
*/
type ActionType = CMDMenu | GenericObject<any>; type ActionType = CMDMenu | GenericObject<any>;
/** /**
* A simple yet powerful code/text editor.
* *
* CodePad is the default text editor shipped with
* AntOS base system. It is based on the ACE editor.
*
* Features:
*
* - It includes all the features of the ACE editor
* - Text manipulation can be extended using the CodePad extension mechanism.
* - All extension actions can be accessed via the [[CommandPalette]] which
* is inspired by MS Visual Studio Code.
* - Default extensions shipped with CodePad:
* - AntOSDK: allowing to create/develop/build/release an AntOS application
* - CodePad extension maker: allowing to develop/release/install CodePad extensions.
* *
* @export * @export
* @class CodePad * @class CodePad
* @extends {BaseApplication} * @extends {BaseApplication}
*/ */
export class CodePad extends BaseApplication { export class CodePad extends BaseApplication {
/**
* Reference to the current editing file handle
*
* @private
* @type {CodePadFileHandle}
* @memberof CodePad
*/
private currfile: CodePadFileHandle; private currfile: CodePadFileHandle;
/**
* Reference to the current working directory
*
* @type {API.VFS.BaseFileHandle}
* @memberof CodePad
*/
currdir: API.VFS.BaseFileHandle; currdir: API.VFS.BaseFileHandle;
/**
* Placeholder stores all extension actions loaded from
* extensions.json
*
* @type {GenericObject<any>}
* @memberof CodePad
*/
extensions: GenericObject<any>; extensions: GenericObject<any>;
/**
* Reference to the sidebar file view UI
*
* @private
* @type {GUI.tag.FileViewTag}
* @memberof CodePad
*/
private fileview: GUI.tag.FileViewTag; private fileview: GUI.tag.FileViewTag;
/**
* Reference to the sidebar
*
* @private
* @type {GUI.tag.VBoxTag}
* @memberof CodePad
*/
private sidebar: GUI.tag.VBoxTag; private sidebar: GUI.tag.VBoxTag;
/**
* Reference to the editor tab bar UI
*
* @private
* @type {GUI.tag.TabBarTag}
* @memberof CodePad
*/
private tabbar: GUI.tag.TabBarTag; private tabbar: GUI.tag.TabBarTag;
/**
* Reference to the language status bar
*
* @private
* @type {GUI.tag.LabelTag}
* @memberof CodePad
*/
private langstat: GUI.tag.LabelTag; private langstat: GUI.tag.LabelTag;
/**
* Reference to the editor status bar
*
* @private
* @type {GUI.tag.LabelTag}
* @memberof CodePad
*/
private editorstat: GUI.tag.LabelTag; private editorstat: GUI.tag.LabelTag;
/**
* Reference to the editor instance
*
* @private
* @type {GenericObject<any>}
* @memberof CodePad
*/
private editor: GenericObject<any>; private editor: GenericObject<any>;
/**
* Editor language modes
*
* @private
* @type {GenericObject<any>}
* @memberof CodePad
*/
private modes: GenericObject<any>; private modes: GenericObject<any>;
/**
* Editor mutex
*
* @private
* @type {boolean}
* @memberof CodePad
*/
private editormux: boolean; private editormux: boolean;
/**
* Reference to the CommandPalette's spotlight
*
* @type {CMDMenu}
* @memberof CodePad
*/
spotlight: CMDMenu; spotlight: CMDMenu;
/**
* Extension prototype definition will be stored
* in this class variable
*
* @static
* @type {GenericObject<any>}
* @memberof CodePad
*/
static extensions: GenericObject<any>; static extensions: GenericObject<any>;
/**
* Prototype definition of a [[CommandPalette]] action
*
* @static
* @type {typeof CMDMenu}
* @memberof CodePad
*/
static CMDMenu: typeof CMDMenu; static CMDMenu: typeof CMDMenu;
/**
* Prototype definition of CodePad CommandPalette
*
* @static
* @type {typeof CommandPalette}
* @memberof CodePad
*/
static CommandPalette: typeof CommandPalette; static CommandPalette: typeof CommandPalette;
/**
* Base abstract prototype of a CodePad extension
*
* @static
* @type {CodePadBaseExtension}
* @memberof CodePad
*/
static BaseExtension: CodePadBaseExtension; static BaseExtension: CodePadBaseExtension;
/** /**
*Creates an instance of CodePad. *Creates an instance of CodePad.
* @param {AppArgumentsType[]} args * @param {AppArgumentsType[]} args application arguments
* @memberof CodePad * @memberof CodePad
*/ */
constructor(args: AppArgumentsType[]) { constructor(args: AppArgumentsType[]) {
@ -62,7 +231,7 @@ namespace OS {
} }
/** /**
* * Main application entry point
* *
* @returns {void} * @returns {void}
* @memberof CodePad * @memberof CodePad
@ -97,7 +266,7 @@ namespace OS {
} }
/** /**
* * Set up the text editor
* *
* @private * @private
* @returns {void} * @returns {void}
@ -272,14 +441,16 @@ namespace OS {
this.loadExtensionMetaData(); this.loadExtensionMetaData();
this.initCommandPalete(); this.initCommandPalete();
this.initSideBar(); this.toggleSideBar();
return this.openFile(this.currfile); return this.openFile(this.currfile);
} }
/** /**
* Open a file in new tab. If the file is already opened,
* the just select the tab
* *
* *
* @param {CodePadFileHandle} file * @param {CodePadFileHandle} file file to open
* @returns {void} * @returns {void}
* @memberof CodePad * @memberof CodePad
*/ */
@ -309,10 +480,10 @@ namespace OS {
} }
/** /**
* * Find a tab on the tabbar corresponding to a file handle
* *
* @private * @private
* @param {CodePadFileHandle} file * @param {CodePadFileHandle} file then file handle to search
* @returns {number} * @returns {number}
* @memberof CodePad * @memberof CodePad
*/ */
@ -335,7 +506,7 @@ namespace OS {
} }
/** /**
* * Create new tab when opening a file
* *
* @private * @private
* @param {CodePadFileHandle} file * @param {CodePadFileHandle} file
@ -354,10 +525,10 @@ namespace OS {
} }
/** /**
* * Close a tab when a file is closed
* *
* @private * @private
* @param {GUI.tag.ListViewItemTag} it * @param {GUI.tag.ListViewItemTag} it reference to the tab to close
* @returns {boolean} * @returns {boolean}
* @memberof CodePad * @memberof CodePad
*/ */
@ -376,10 +547,10 @@ namespace OS {
} }
/** /**
* * Select a tab by its index
* *
* @private * @private
* @param {number} i * @param {number} i tab index
* @returns {void} * @returns {void}
* @memberof CodePad * @memberof CodePad
*/ */
@ -433,7 +604,7 @@ namespace OS {
} }
/** /**
* * Update the editor status bar
* *
* @private * @private
* @memberof CodePad * @memberof CodePad
@ -451,11 +622,11 @@ namespace OS {
} }
/** /**
* * Show or hide the SideBar
* *
* @memberof CodePad * @memberof CodePad
*/ */
initSideBar(): void { toggleSideBar(): void {
if (this.currdir) { if (this.currdir) {
$(this.sidebar).show(); $(this.sidebar).show();
this.fileview.path = this.currdir.path; this.fileview.path = this.currdir.path;
@ -466,7 +637,7 @@ namespace OS {
} }
/** /**
* * Add an action to the [[CommandPalette]]'s spotlight
* *
* @private * @private
* @param {ActionType} action * @param {ActionType} action
@ -479,7 +650,7 @@ namespace OS {
} }
/** /**
* * Add a list of actions to the [[CommandPalette]]'s spotlight
* *
* @private * @private
* @param {ActionType[]} list * @param {ActionType[]} list
@ -492,7 +663,7 @@ namespace OS {
} }
/** /**
* * Init the editor command palette
* *
* @private * @private
* @memberof CodePad * @memberof CodePad
@ -536,7 +707,7 @@ namespace OS {
} }
/** /**
* * Load the extension meta data from `extension.json` file
* *
* @memberof CodePad * @memberof CodePad
*/ */
@ -585,11 +756,11 @@ namespace OS {
} }
/** /**
* * Run an extension action from the command palette
* *
* @private * @private
* @param {string} name * @param {string} name extension name
* @param {string} action * @param {string} action action name
* @returns {void} * @returns {void}
* @memberof CodePad * @memberof CodePad
*/ */
@ -611,7 +782,7 @@ namespace OS {
} }
/** /**
* * Load extension then run an action
* *
* @param {{ * @param {{
* parent: { name: any }; * parent: { name: any };
@ -620,7 +791,18 @@ namespace OS {
* @memberof CodePad * @memberof CodePad
*/ */
loadAndRunExtensionAction(data: { loadAndRunExtensionAction(data: {
/**
* Parent context of the current action
*
* @type {{ name: any }}
*/
parent: { name: any }; parent: { name: any };
/**
* Action name
*
* @type {*}
*/
name: any; name: any;
}): void { }): void {
const { name } = data.parent; const { name } = data.parent;
@ -644,7 +826,7 @@ namespace OS {
} }
/** /**
* * File menu definition
* *
* @private * @private
* @returns {GUI.BasicItemType} * @returns {GUI.BasicItemType}
@ -678,7 +860,7 @@ namespace OS {
} }
/** /**
* * Context menu definition
* *
* @private * @private
* @param {GUI.TagEventType} e * @param {GUI.TagEventType} e
@ -807,7 +989,7 @@ namespace OS {
} }
/** /**
* * Save a file
* *
* @private * @private
* @param {CodePadFileHandle} file * @param {CodePadFileHandle} file
@ -828,7 +1010,7 @@ namespace OS {
} }
/** /**
* * Save the current file as another file
* *
* @private * @private
* @memberof CodePad * @memberof CodePad
@ -848,7 +1030,7 @@ namespace OS {
} }
/** /**
* * Menu action definition
* *
* @private * @private
* @param {string} dataid * @param {string} dataid
@ -900,7 +1082,7 @@ namespace OS {
} }
/** /**
* * Cleanup the editor before exiting.
* *
* @param {BaseEvent} evt * @param {BaseEvent} evt
* @returns {void} * @returns {void}
@ -944,7 +1126,7 @@ namespace OS {
} }
/** /**
* * Application menu definition
* *
* @returns {GUI.BasicItemType[]} * @returns {GUI.BasicItemType[]}
* @memberof CodePad * @memberof CodePad

View File

@ -1,11 +1,3 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS205: Consider reworking code to avoid use of IIFEs
* DS208: Avoid top-level this
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com> // Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
// AnTOS Web desktop is is licensed under the GNU General Public // AnTOS Web desktop is is licensed under the GNU General Public