diff --git a/js/notebook/src/extension.js b/js/notebook/src/extension.js
deleted file mode 100644
index 5494b8f82c..0000000000
--- a/js/notebook/src/extension.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This file contains the javascript that is run when the notebook is loaded.
-// It contains some requirejs configuration and the `load_ipython_extension`
-// which is required for any notebook extension.
-
-// Configure requirejs
-if (window.require) {
- window.require.config({
- map: {
- "*": {
- "beakerx": "nbextensions/beakerx/index",
- "jupyter-js-widgets": "nbextensions/jupyter-js-widgets/extension",
- "@jupyter-widgets/base": "nbextensions/jupyter-js-widgets/extension",
- "@jupyter-widgets/controls": "nbextensions/jupyter-js-widgets/extension"
- }
- }
- });
-}
-__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/beakerx/';
-
-require('./shared/style/beakerx.scss');
-require('./plot/bko-combinedplot.css');
-require('./plot/bko-plot.css');
-require('./extension/dataBrowser/dataBrowser.css');
-require('./extension/tableOfContents/toc.css');
-
-define([
- 'services/config',
- 'services/kernels/comm',
- 'base/js/utils',
- 'base/js/namespace',
- 'base/js/events',
- 'require',
- 'underscore',
- './plot/plotApi',
- 'big.js',
- './extension/UIOptionsHelper',
- './extension/tableOfContents/index'
-], function (
- configmod,
- comm,
- utils,
- Jupyter,
- events,
- require,
- _,
- plotApi,
- big,
- UIOptionsHelper,
- tocUtils
-) {
- "use strict";
-
- window.Big = big;
-
- var base_url = utils.get_body_data('baseUrl');
- var config = new configmod.ConfigSection('notebook', {base_url: base_url});
- var initCellUtils = require('./extension/initializationCells');
- var GroovyMode = require('./extension/groovyModeExtension').GroovyMode;
- var htmlOutput = require('./htmlOutput/htmlOutput').default;
- var Autotranslation = require('./extension/autotranslation').Autotranslation;
- var BeakerXKernel = require('./extension/kernel').BeakerXKernel;
- var bkCoreManager = require('./shared/bkCoreManager').default;
-
- var inNotebook = !Jupyter.NotebookList;
- var mod_name = 'init_cell';
- var log_prefix = '[' + mod_name + ']';
- var options = { // updated from server's config & nb metadata
- run_on_kernel_ready: true
- };
-
- UIOptionsHelper.registerFeature(base_url);
-
- function callback_notebook_loaded() {
- initCellUtils.enableInitializationCellsFeature(options);
- tocUtils.toc_init();
- BeakerXKernel.installHandler();
- }
-
- var load_ipython_extension = function () {
-
- // assign Beaker methods to window
- if (window) {
- var plotApiList = plotApi.list();
- var bkApp = bkCoreManager.getBkApp();
- var bkObject = bkApp.getBeakerObject();
- var beakerxInstance = { prefs: bkObject.beakerObj.prefs };
-
- _.extend(beakerxInstance, plotApiList);
- _.extend(beakerxInstance, htmlOutput);
-
- if (!window.beakerx) {
- window.beakerx = Autotranslation.proxify(beakerxInstance);
- }
- }
-
- if (inNotebook) {
- // setup things to run on loading config/notebook
- Jupyter.notebook.config.loaded
- .then(function update_options_from_config() {
- $.extend(true, options, Jupyter.notebook.config.data[mod_name]);
- }, function (reason) {
- console.warn(log_prefix, 'error loading config:', reason);
- })
- .then(function () {
- Jupyter.notebook._fully_loaded ?
- callback_notebook_loaded() :
- events.on('notebook_loaded.Notebook', callback_notebook_loaded);
- }).catch(function (reason) {
- console.error(log_prefix, 'unhandled error:', reason);
- });
-
- GroovyMode.extendWithLineComment(Jupyter, CodeMirror);
- }
- };
-
- return {
- load_ipython_extension: load_ipython_extension
- };
-});
diff --git a/js/notebook/src/extension.ts b/js/notebook/src/extension.ts
new file mode 100644
index 0000000000..f28e2efcb3
--- /dev/null
+++ b/js/notebook/src/extension.ts
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// This file contains the javascript that is run when the notebook is loaded.
+// It contains some requirejs configuration and the `load_ipython_extension`
+// which is required for any notebook extension.
+
+///
+
+"use strict";
+
+// Configure requirejs
+if (window.require) {
+ window.require.config({
+ map: {
+ "*": {
+ "beakerx": "nbextensions/beakerx/index",
+ "jupyter-js-widgets": "nbextensions/jupyter-js-widgets/extension",
+ "@jupyter-widgets/base": "nbextensions/jupyter-js-widgets/extension",
+ "@jupyter-widgets/controls": "nbextensions/jupyter-js-widgets/extension"
+ }
+ }
+ });
+}
+
+__webpack_public_path__ = `${document.querySelector('body').getAttribute('data-base-url')}nbextensions/beakerx/`;
+
+import {registerFeature} from './extension/UIOptionsHelper';
+import {enableInitializationCellsFeature} from './extension/initializationCells';
+import {GroovyMode} from './extension/groovyModeExtension';
+import {Autotranslation} from './extension/autotranslation';
+import {BeakerXKernel} from './extension/kernel';
+import {displayHTML as htmlOutput} from './htmlOutput/htmlOutput';
+import bkCoreManager from './shared/bkCoreManager';
+
+import './shared/style/beakerx.scss';
+import './plot/bko-combinedplot.css';
+import './plot/bko-plot.css';
+import './extension/dataBrowser/dataBrowser.css';
+import './extension/tableOfContents/toc.css';
+
+const configmod = require('services/config');
+const comm = require('services/kernels/comm');
+const utils = require('base/js/utils');
+const Jupyter = require('base/js/namespace');
+const events = require('base/js/events');
+const plotApi = require('./plot/plotApi');
+const big = require('big.js');
+const tocUtils = require('./extension/tableOfContents/index');
+
+window['Big'] = big;
+
+const base_url = utils.get_body_data('baseUrl');
+const config = new configmod.ConfigSection('notebook', { base_url: base_url });
+
+const MOD_NAME = 'init_cell';
+const log_prefix = `[${MOD_NAME}]`;
+let options = { // updated from server's config & nb metadata
+ run_on_kernel_ready: true
+};
+
+registerFeature(base_url);
+
+function callback_notebook_loaded() {
+ enableInitializationCellsFeature(options);
+ tocUtils.toc_init();
+ BeakerXKernel.installHandler();
+}
+
+function extendWindowObject() {
+ if (!window) {
+ return;
+ }
+
+ const plotApiList = plotApi.list();
+ const bkApp = bkCoreManager.getBkApp();
+ const bkObject = bkApp.getBeakerObject();
+ const beakerxInstance = {
+ ...plotApiList,
+ ...htmlOutput,
+ prefs: bkObject.beakerObj.prefs
+ };
+
+ if (!window.beakerx) {
+ window.beakerx = Autotranslation.proxify(beakerxInstance);
+ }
+}
+
+function setupNotebook() {
+ if (Jupyter.NotebookList) {
+ return; // Notebook not loaded
+ }
+
+ Jupyter.notebook.config.loaded
+ .then(
+ () => { options = { ...options, ...Jupyter.notebook.config.data[MOD_NAME] }; },
+ (reason) => { console.warn(log_prefix, 'error loading config:', reason); }
+ )
+ .then(() => {
+ Jupyter.notebook._fully_loaded
+ ? callback_notebook_loaded()
+ : events.on('notebook_loaded.Notebook', callback_notebook_loaded);
+ })
+ .catch((reason) => { console.error(log_prefix, 'unhandled error:', reason); });
+
+ GroovyMode.extendWithLineComment(Jupyter, CodeMirror);
+}
+
+function load_ipython_extension() {
+ extendWindowObject();
+ setupNotebook();
+}
+
+export default {
+ load_ipython_extension
+};
diff --git a/js/notebook/src/tree/Models/TreeWidgetModel.ts b/js/notebook/src/tree/Models/TreeWidgetModel.ts
index 27ba1c7e3f..f8a29a5efc 100644
--- a/js/notebook/src/tree/Models/TreeWidgetModel.ts
+++ b/js/notebook/src/tree/Models/TreeWidgetModel.ts
@@ -125,9 +125,10 @@ export default class TreeWidgetModel {
result += `${other} `
}
- for (let property of options.properties) {
- result += `-D${property.name}=${property.value} `;
+ for (let property in options.properties) {
+ result += `-D${options.properties[property].name}=${options.properties[property].value} `;
}
+
return result;
};
}
diff --git a/js/notebook/src/tree/Widgets/JVMOptions/PropertiesWidget.ts b/js/notebook/src/tree/Widgets/JVMOptions/PropertiesWidget.ts
index abea983bd7..be6bbeed35 100644
--- a/js/notebook/src/tree/Widgets/JVMOptions/PropertiesWidget.ts
+++ b/js/notebook/src/tree/Widgets/JVMOptions/PropertiesWidget.ts
@@ -66,8 +66,8 @@ export default class PropertiesWidget extends Widget {
public onLoad(properties: IPropertiesJVMOptions) {
this.clear();
- for (let property of properties) {
- this.addPropertyElement(property.name, property.value);
+ for (let property in properties) {
+ this.addPropertyElement(properties[property].name, properties[property].value);
}
}
diff --git a/js/notebook/src/types/global.env.d.ts b/js/notebook/src/types/global.env.d.ts
index a924f45f39..76896783cd 100644
--- a/js/notebook/src/types/global.env.d.ts
+++ b/js/notebook/src/types/global.env.d.ts
@@ -31,6 +31,7 @@ interface MapConstructor {
}
declare var Map: MapConstructor;
+declare var CodeMirror: any;
declare interface NumberConstructor {
isNaN: (number: number) => boolean,
@@ -55,7 +56,8 @@ declare interface Array {
declare interface Window {
beakerx: any,
- chrome?: any
+ chrome?: any,
+ require: any
}
interface GlobalEnvironment {
diff --git a/js/notebook/webpack.config.js b/js/notebook/webpack.config.js
index 55d9852336..1f22f86e75 100644
--- a/js/notebook/webpack.config.js
+++ b/js/notebook/webpack.config.js
@@ -85,7 +85,7 @@ module.exports = [
// "load_ipython_extension" function which is required for any notebook
// extension.
//
- entry: './src/extension.js',
+ entry: './src/extension.ts',
output: {
filename: 'extension.js',
path: path.resolve(__dirname, '../../beakerx/beakerx/static'),