diff --git a/docs/source/contribute.rst b/docs/source/contribute.rst index 62854d4f7..e7157a0d7 100755 --- a/docs/source/contribute.rst +++ b/docs/source/contribute.rst @@ -194,7 +194,7 @@ About the Voila Frontend The Voila frontend is built as a JupyterLab-based application using JupyterLab components. -This makes it possible to reuse existing plugins and extensions for Jupyterlab such as core JupyterLab plugin like the JSON viewer, +This makes it possible to reuse existing plugins and extensions for Jupyterlab such as core JupyterLab plugins like the JSON viewer, as well as third-party mime renderers like the `FASTA viewer `_. The Voila frontend is able to load existing JupyterLab extensions installed as prebuilt extensions under ``${PREFIX}/share/labextensions``, diff --git a/packages/voila/package.json b/packages/voila/package.json index 04b6ca682..2d019628e 100644 --- a/packages/voila/package.json +++ b/packages/voila/package.json @@ -9,22 +9,22 @@ "dependencies": { "@jupyter-widgets/base": "^6.0.1", "@jupyter-widgets/controls": "^5.0.1", - "@jupyter-widgets/output": "^6.0.1", "@jupyter-widgets/jupyterlab-manager": "^5.0.3", - "@jupyterlab/json-extension": "^3.0.0", - "@jupyterlab/markdownviewer-extension": "^3.0.0", - "@jupyterlab/mathjax2-extension": "^3.0.0", - "@jupyterlab/rendermime-extension": "^3.0.0", + "@jupyter-widgets/output": "^6.0.1", "@jupyterlab/application": "^3.0.0", "@jupyterlab/apputils": "^3.0.0", "@jupyterlab/coreutils": "^5.0.0", "@jupyterlab/docregistry": "^3.0.0", + "@jupyterlab/json-extension": "^3.0.0", "@jupyterlab/logconsole": "^3.0.0", "@jupyterlab/mainmenu": "^3.0.0", + "@jupyterlab/markdownviewer-extension": "^3.0.0", + "@jupyterlab/mathjax2-extension": "^3.0.0", "@jupyterlab/nbformat": "^3.0.0", "@jupyterlab/notebook": "^3.0.0", "@jupyterlab/outputarea": "^3.0.0", "@jupyterlab/rendermime": "^3.0.0", + "@jupyterlab/rendermime-extension": "^3.0.0", "@jupyterlab/services": "^6.1.8", "@jupyterlab/settingregistry": "^3.0.0", "@jupyterlab/translation": "^3.0.0", @@ -46,24 +46,25 @@ "@babel/core": "^7.2.2", "@babel/preset-env": "^7.3.1", "@jupyterlab/builder": "^3.0.0", + "@types/node": "^18.8.3", "babel-loader": "^8.0.5", "css-loader": "~5.0.2", "file-loader": "^6.2.0", - "npm-run-all": "^4.1.5", - "p-limit": "^2.2.2", - "style-loader": "^2.0.0", - "typescript": "~4.1.3", - "url-loader": "^4.1.1", - "webpack": "^5.24.1", - "webpack-cli": "^4.5.0", "fs-extra": "^9.1.0", "glob": "~7.1.6", "mini-css-extract-plugin": "~0.9.0", + "npm-run-all": "^4.1.5", + "p-limit": "^2.2.2", "raw-loader": "^4.0.2", "rimraf": "^3.0.2", + "style-loader": "^2.0.0", "svg-url-loader": "^7.1.1", + "typescript": "~4.1.3", + "url-loader": "^4.1.1", "watch": "^1.0.2", + "webpack": "^5.24.1", "webpack-bundle-analyzer": "^4.4.0", + "webpack-cli": "^4.5.0", "webpack-merge": "^5.7.3", "whatwg-fetch": "^3.0.0" }, diff --git a/packages/voila/src/app.ts b/packages/voila/src/app.ts index 8e8283f45..dc2408357 100644 --- a/packages/voila/src/app.ts +++ b/packages/voila/src/app.ts @@ -10,6 +10,8 @@ import { IRenderMime } from '@jupyterlab/rendermime'; import { IShell, VoilaShell } from './shell'; +const PACKAGE = require('../package.json'); + /** * App is the main application class. It is instantiated once and shared. */ @@ -19,12 +21,11 @@ export class VoilaApp extends JupyterFrontEnd { * * @param options The instantiation options for an application. */ - constructor(options: App.IOptions = { shell: new VoilaShell() }) { + constructor(options: App.IOptions) { super({ ...options, shell: options.shell ?? new VoilaShell() }); - if (options.mimeExtensions) { for (const plugin of createRendermimePlugins(options.mimeExtensions)) { this.registerPlugin(plugin); @@ -45,7 +46,7 @@ export class VoilaApp extends JupyterFrontEnd { /** * The version of the application. */ - readonly version = 'unknown'; + readonly version = PACKAGE['version']; /** * The JupyterLab application paths dictionary. diff --git a/packages/voila/src/output.ts b/packages/voila/src/output.ts index 58aeb94d6..8436358e8 100644 --- a/packages/voila/src/output.ts +++ b/packages/voila/src/output.ts @@ -1,11 +1,8 @@ +import { IBackboneModelOptions } from '@jupyter-widgets/base'; import { LabWidgetManager } from '@jupyter-widgets/jupyterlab-manager'; - import * as outputBase from '@jupyter-widgets/output'; - import * as nbformat from '@jupyterlab/nbformat'; - import { OutputAreaModel } from '@jupyterlab/outputarea'; - import { KernelMessage } from '@jupyterlab/services'; /** @@ -19,14 +16,13 @@ export class OutputModel extends outputBase.OutputModel { return { ...super.defaults(), msg_id: '', outputs: [] }; } - initialize(attributes: any, options: any): void { + initialize( + attributes: Backbone.ObjectHash, + options: IBackboneModelOptions + ): void { super.initialize(attributes, options); // The output area model is trusted since widgets are only rendered in trusted contexts. this._outputs = new OutputAreaModel({ trusted: true }); - this._msgHook = (msg): boolean => { - this.add(msg); - return false; - }; this.listenTo(this, 'change:msg_id', this.reset_msg_id); this.listenTo(this, 'change:outputs', this.setOutputs); @@ -93,6 +89,10 @@ export class OutputModel extends outputBase.OutputModel { widget_manager!: LabWidgetManager; - private _msgHook!: (msg: KernelMessage.IIOPubMessage) => boolean; + private _msgHook = (msg: KernelMessage.IIOPubMessage): boolean => { + this.add(msg); + return false; + }; + private _outputs!: OutputAreaModel; } diff --git a/packages/voila/tsconfig.json b/packages/voila/tsconfig.json index 399b75b7a..b3e424fbf 100644 --- a/packages/voila/tsconfig.json +++ b/packages/voila/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfigbase", "compilerOptions": { "outDir": "lib", - "rootDir": "src" + "rootDir": "src", + "types": ["node"] }, "include": ["src/**/*"] } diff --git a/yarn.lock b/yarn.lock index 4318552c2..fbc1890b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3190,6 +3190,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.18.tgz#633184f55c322e4fb08612307c274ee6d5ed3154" integrity sha512-m+6nTEOadJZuTPkKR/SYK3A2d7FZrgElol9UP1Kae90VVU4a6mxnPuLiIW1m4Cq4gZ/nWb9GrdVXJCoCazDAbg== +"@types/node@^18.8.3": + version "18.8.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.8.3.tgz#ce750ab4017effa51aed6a7230651778d54e327c" + integrity sha512-0os9vz6BpGwxGe9LOhgP/ncvYN5Tx1fNcd2TM3rD/aCGBkysb+ZWpXEocG24h6ZzOi13+VB8HndAQFezsSOw1w== + "@types/normalize-package-data@^2.4.0": version "2.4.1" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"