Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to es2017 javascript #2725

Merged
merged 5 commits into from
Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/base-manager/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"compilerOptions": {
"types": ["mocha"],
"outDir": "build",
"rootDir": "src",
"lib": ["dom", "es5", "es2015.promise", "es2015.iterable"],
"target": "es5"
"rootDir": "src"
},
"include": ["src/*"],
"references": [
Expand Down
4 changes: 1 addition & 3 deletions packages/base-manager/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"extends": "../../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"lib": ["dom", "es5", "es2015.promise", "es2015.iterable"],
"target": "es5"
"rootDir": "src"
},
"include": ["src/*"],
"references": [
Expand Down
4 changes: 1 addition & 3 deletions packages/base/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"compilerOptions": {
"types": ["mocha"],
"outDir": "build",
"rootDir": "src",
"lib": ["dom", "es5", "es2015.promise", "es2015.iterable"],
"target": "es5"
"rootDir": "src"
},
"include": ["src/*"],
"references": [
Expand Down
4 changes: 1 addition & 3 deletions packages/base/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"extends": "../../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"lib": ["dom", "es5", "es2015.promise", "es2015.iterable"],
"target": "es5"
"rootDir": "src"
},
"include": ["src/*"]
}
4 changes: 1 addition & 3 deletions packages/controls/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"compilerOptions": {
"types": ["mocha"],
"outDir": "build",
"rootDir": "src",
"lib": ["dom", "es5", "es2015.promise", "es2015.iterable"],
"target": "es5"
"rootDir": "src"
},
"include": ["src/**/*"],
"references": [
Expand Down
4 changes: 1 addition & 3 deletions packages/controls/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"types": ["mathjax", "node"],
"lib": ["dom", "es5", "es2015.promise", "es2015.iterable"],
"target": "es5"
"types": ["mathjax", "node"]
},
"include": ["src/**/*"],
"references": [
Expand Down
4 changes: 1 addition & 3 deletions packages/output/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"extends": "../../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"lib": ["dom", "es5", "es2015.promise", "es2015.iterable"],
"target": "es5"
"rootDir": "src"
},
"include": ["src/**/*"],
"references": [
Expand Down
60 changes: 28 additions & 32 deletions widgetsnbextension/src/widget_output.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@

// This widget is strongly coupled to the notebook because of the outputarea
// dependency.
var widgets = require("@jupyter-widgets/controls");
var outputBase = require("@jupyter-widgets/output");
var _ = require("underscore");
require('./widget_output.css');

var outputArea = new Promise(function(resolve, reject) {
requirejs(["notebook/js/outputarea"], resolve, reject)
});

var OutputModel = outputBase.OutputModel.extend({
defaults: _.extend({}, outputBase.OutputModel.prototype.defaults(), {
msg_id: "",
outputs: []
}),
export class OutputModel extends outputBase.OutputModel {
defaults() {
return {
...super.defaults(),
msg_id: "",
outputs: []
}
}

initialize: function(attributes, options) {
OutputModel.__super__.initialize.apply(this, arguments);
initialize(attributes, options) {
super.initialize(attributes, options)
this.listenTo(this, 'change:msg_id', this.reset_msg_id);

if (this.comm && this.comm.kernel) {
Expand Down Expand Up @@ -50,14 +51,14 @@ var OutputModel = outputBase.OutputModel.extend({
that.listenTo(that, 'change:outputs', that.setOutputs);
that.setOutputs();
});
},
}

// make callbacks
callbacks: function() {
callbacks() {
// Merge our callbacks with the base class callbacks.
var cb = OutputModel.__super__.callbacks.apply(this, arguments);
var cb = super.callbacks();
var iopub = cb.iopub || {};
var iopubCallbacks = _.extend({}, iopub, {
var iopubCallbacks = {...iopub,
output: function(msg) {
this.trigger('new_message', msg);
if (iopub.output) {
Expand All @@ -70,11 +71,11 @@ var OutputModel = outputBase.OutputModel.extend({
iopub.clear_output.apply(this, arguments);
}
}.bind(this)
});
return _.extend({}, cb, {iopub: iopubCallbacks});
},
};
return {...cb, iopub: iopubCallbacks};
}

reset_msg_id: function() {
reset_msg_id() {
var kernel = this.kernel;
// Pop previous message id
var prev_msg_id = this.previous('msg_id');
Expand All @@ -88,21 +89,21 @@ var OutputModel = outputBase.OutputModel.extend({
if (msg_id && kernel) {
kernel.output_callback_overrides_push(msg_id, this.model_id);
}
},
}

setOutputs: function(model, value, options) {
setOutputs(model, value, options) {
if (!(options && options.newMessage)) {
// fromJSON does not clear the existing output
this.output_area.clear_output();
// fromJSON does not copy the message, so we make a deep copy
this.output_area.fromJSON(JSON.parse(JSON.stringify(this.get('outputs'))));
}
},
}

});
}

var OutputView = outputBase.OutputView.extend({
render: function(){
export class OutputView extends outputBase.OutputView {
render(){
var that = this;
this.el.classList.add('jupyter-widgets-output-area');
outputArea.then(function(outputArea) {
Expand All @@ -128,20 +129,15 @@ var OutputView = outputBase.OutputView.extend({
that.listenTo(that.model, 'change:outputs', that.setOutputs);
that.setOutputs();
});
OutputView.__super__.render.apply(this, arguments);
},
super.render();
}

setOutputs: function(model, value, options) {
setOutputs(model, value, options) {
if (!(options && options.newMessage)) {
// fromJSON does not clear the existing output
this.output_area.clear_output();
// fromJSON does not copy the message, so we make a deep copy
this.output_area.fromJSON(JSON.parse(JSON.stringify(this.model.get('outputs'))));
}
}
});

module.exports = {
OutputView: OutputView,
OutputModel: OutputModel,
};
}