Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:sagemathinc/cocalc

  • Loading branch information...
williamstein committed May 4, 2019
2 parents 5b8515a + 8d0ad41 commit 24605119472db2f97b3c4f02704fe36539600a8e
@@ -1032,9 +1032,11 @@ class exports.Client extends EventEmitter
project.read_file
path : mesg.path
cb : (err, content) =>
if not err
v.push(content.blob.toString())
cb(err)
if err
v.push({path:mesg.path, project_id:mesg.project_id, error:err})
else
v.push({path:mesg.path, project_id:mesg.project_id, content:content.blob.toString()})
cb()
paths = []
for i in [0...mesg.project_id.length]
paths.push({id:mesg.id, path:mesg.path[i], project_id:mesg.project_id[i]})
@@ -1093,8 +1093,8 @@ message({
url: required
});

// The client sends this message to the hub in order to write (or
// create) a plain text file (binary files not allowed, since sending
// The client sends this message to the hub in order to read
// a plain text file (binary files not allowed, since sending
// them via JSON makes no sense).
// client --> hub
API(
@@ -1123,10 +1123,10 @@ and containing directories if they do not already exist.
You can also read multiple project_id/path's at once by
making project_id and path arrays (of the same length).
In that case, the resulting content will be an array
of the resulting content strings, in the same order
in which they were requested.
In that case, the result will be an array
of {project_id, path, content} objects, in some
random order. If there is an error reading a particular
file, instead {project_id, path, error} is included.
Example:
@@ -303,6 +303,7 @@ export class Widget0 extends Component<WidgetProps, WidgetState> {
case "HBoxModel":
case "VBoxModel":
case "GridBoxView":
case "BoxModel":
return this.render_react_box_view();
default:
// better than nothing.
@@ -382,6 +383,9 @@ export class Widget0 extends Component<WidgetProps, WidgetState> {
// todo -- this is hackish; fix later.
let cls = "jupyter-widgets widget-container";
switch (this.model.name) {
case "BoxModel":
cls += " widget-box";
break;
case "HBoxModel":
cls += " widget-box widget-hbox";
break;
@@ -174,6 +174,38 @@ export class WidgetManager extends base.ManagerBase<HTMLElement> {
}
}

deserialize_state(model: base.DOMWidgetModel, state: ModelState): ModelState {
// NOTE: this is a reimplementation of soemthing in
// ipywidgets/packages/base/src/widget.ts
// but we untagle unpacking and deserializing, which is
// mixed up there.
// This is used in an interesting way for the date picker, see:
// ipywidgets/packages/controls/src/widget_date.ts
// in particular for when a date is set in the kernel.
const serializers = (model.constructor as any).serializers;
if (serializers == null) return state;
const deserialized: ModelState = {};
for (let k in state) {
// HACK/warning - in ipywidgets/packages/base/src/widget.ts,
// the layout and style deserializers are unpack_model, which
// blows up everything and leads to an infinite loop, since
// we use a completely different unpack approach. So we have
// to cross our fingers that nothing those keys can be ignored,
// and also that they are the only ones that use unpack_model.
if (
k !== "layout" &&
k !== "style" &&
serializers[k] &&
serializers[k].deserialize
) {
deserialized[k] = serializers[k].deserialize(state[k]);
} else {
deserialized[k] = state[k];
}
}
return deserialized;
}

private async update_model(
model_id: string,
change: ModelState
@@ -193,7 +225,7 @@ export class WidgetManager extends base.ManagerBase<HTMLElement> {
);
return;
}
model.set_state(change);
model.set_state(this.deserialize_state(model, change));
// } else {
// console.warn(`WARNING: update_model -- unknown model ${model_id}`);
}
@@ -242,6 +274,7 @@ export class WidgetManager extends base.ManagerBase<HTMLElement> {
});

// Initialize the model
state = this.deserialize_state(model, state);
model.set(state);

// Start listing to model changes.
@@ -307,7 +340,7 @@ export class WidgetManager extends base.ManagerBase<HTMLElement> {
);*/
return;
}
const changed: any = copy(model.changed);
let changed: any = copy(model.serialize(model.changed));
delete changed.children; // sometimes they are in there, but shouldn't be sync'ed.
// console.log("handle_model_change (frontend)", changed);
let last_changed = changed.last_changed;

0 comments on commit 2460511

Please sign in to comment.
You can’t perform that action at this time.