@difizen/libro-jupyter 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
- package/es/cell/jupyter-code-cell-view.js +3 -5
- package/es/contents/save-content-contribution.d.ts +10 -0
- package/es/contents/save-content-contribution.d.ts.map +1 -0
- package/es/contents/save-content-contribution.js +110 -0
- package/es/libro-jupyter-model.d.ts +2 -4
- package/es/libro-jupyter-model.d.ts.map +1 -1
- package/es/libro-jupyter-model.js +35 -120
- package/es/libro-jupyter-workspace.d.ts +18 -0
- package/es/libro-jupyter-workspace.d.ts.map +1 -0
- package/es/libro-jupyter-workspace.js +108 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +3 -1
- package/package.json +17 -17
- package/src/cell/jupyter-code-cell-view.tsx +4 -5
- package/src/contents/save-content-contribution.ts +67 -0
- package/src/libro-jupyter-model.ts +1 -69
- package/src/libro-jupyter-workspace.ts +49 -0
- package/src/module.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jupyter-code-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/jupyter-code-cell-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAElB,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAkBzE,qBAEa,mBAAoB,SAAQ,iBAAiB;IAChD,MAAM,EAAE,gBAAgB,CAAC;IACxB,IAAI,2FAA4B;IACjC,KAAK,EAAE,oBAAoB,CAAC;IAE3B,cAAc,aAQrB;cAEiB,eAAe,IAAI,qBAAqB;
|
|
1
|
+
{"version":3,"file":"jupyter-code-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/jupyter-code-cell-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAElB,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAkBzE,qBAEa,mBAAoB,SAAQ,iBAAiB;IAChD,MAAM,EAAE,gBAAgB,CAAC;IACxB,IAAI,2FAA4B;IACjC,KAAK,EAAE,oBAAoB,CAAC;IAE3B,cAAc,aAQrB;cAEiB,eAAe,IAAI,qBAAqB;IAe3D,eAAe,EAAE,eAAe,CAqB9B;IAEF,kBAAkB,EAAE,kBAAkB,CA8BpC;IAEa,GAAG;CA8EnB"}
|
|
@@ -22,8 +22,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
23
|
import { CellEditorMemo, LibroCodeCellView } from '@difizen/libro-code-cell';
|
|
24
24
|
import { KernelError } from '@difizen/libro-kernel';
|
|
25
|
-
import {
|
|
26
|
-
import { transient
|
|
25
|
+
import { getCellURI } from '@difizen/libro-language-client';
|
|
26
|
+
import { transient } from '@difizen/mana-app';
|
|
27
27
|
import { view, ViewInstance } from '@difizen/mana-app';
|
|
28
28
|
import { getOrigin, useInject } from '@difizen/mana-app';
|
|
29
29
|
import { l10n } from '@difizen/mana-l10n';
|
|
@@ -156,9 +156,7 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
|
|
|
156
156
|
key: "getEditorOption",
|
|
157
157
|
value: function getEditorOption() {
|
|
158
158
|
var options = _get(_getPrototypeOf(JupyterCodeCellView.prototype), "getEditorOption", this).call(this);
|
|
159
|
-
var uri =
|
|
160
|
-
uri = URI.withScheme(uri, LibroCellURIScheme);
|
|
161
|
-
uri = URI.withQuery(uri, "cellid=".concat(this.model.id));
|
|
159
|
+
var uri = getCellURI(this.parent.model, this.model);
|
|
162
160
|
return _objectSpread(_objectSpread({}, options), {}, {
|
|
163
161
|
uuid: uri.toString(),
|
|
164
162
|
tooltipProvider: this.tooltipProvider,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NotebookOption } from '@difizen/libro-core';
|
|
2
|
+
import { ContentSaveContribution } from '@difizen/libro-core';
|
|
3
|
+
import { ModalService } from '@difizen/mana-app';
|
|
4
|
+
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
5
|
+
export declare class LibroJupyterContentSaveContribution implements ContentSaveContribution {
|
|
6
|
+
protected readonly modalService: ModalService;
|
|
7
|
+
canHandle: () => number;
|
|
8
|
+
saveContent: (options: NotebookOption, model: LibroJupyterModel) => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=save-content-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-content-contribution.d.ts","sourceRoot":"","sources":["../../src/contents/save-content-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,qBACa,mCAAoC,YAAW,uBAAuB;IAC3D,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpE,SAAS,eAEP;IACF,WAAW,YAAmB,cAAc,SAAS,iBAAiB,mBAkDpE;CACH"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
13
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
14
|
+
import { ContentSaveContribution } from '@difizen/libro-core';
|
|
15
|
+
import { ModalService, inject, singleton } from '@difizen/mana-app';
|
|
16
|
+
import { SaveFileErrorModal } from "../toolbar/save-file-error.js";
|
|
17
|
+
export var LibroJupyterContentSaveContribution = (_dec = singleton({
|
|
18
|
+
contrib: ContentSaveContribution
|
|
19
|
+
}), _dec2 = inject(ModalService), _dec(_class = (_class2 = /*#__PURE__*/_createClass(function LibroJupyterContentSaveContribution() {
|
|
20
|
+
var _this = this;
|
|
21
|
+
_classCallCheck(this, LibroJupyterContentSaveContribution);
|
|
22
|
+
_initializerDefineProperty(this, "modalService", _descriptor, this);
|
|
23
|
+
this.canHandle = function () {
|
|
24
|
+
return 2;
|
|
25
|
+
};
|
|
26
|
+
this.saveContent = /*#__PURE__*/function () {
|
|
27
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, model) {
|
|
28
|
+
var notebookContent, res, _res, errorMsg;
|
|
29
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
notebookContent = model.toJSON();
|
|
33
|
+
if (model.currentFileContents) {
|
|
34
|
+
_context.next = 3;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
throw new Error('currentFileContents is undefined');
|
|
38
|
+
case 3:
|
|
39
|
+
res = {};
|
|
40
|
+
_context.prev = 4;
|
|
41
|
+
_context.next = 7;
|
|
42
|
+
return model.fileService.write(notebookContent, model.currentFileContents);
|
|
43
|
+
case 7:
|
|
44
|
+
res = _context.sent;
|
|
45
|
+
if (res) {
|
|
46
|
+
_context.next = 10;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return _context.abrupt("return");
|
|
50
|
+
case 10:
|
|
51
|
+
if (!(res.last_modified === model.lastModified || res.size === 0)) {
|
|
52
|
+
_context.next = 15;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
errorMsg = "File Save Error: ".concat((_res = res) === null || _res === void 0 ? void 0 : _res.message, " ");
|
|
56
|
+
model.fileService.fileSaveErrorEmitter.fire({
|
|
57
|
+
cause: res.message,
|
|
58
|
+
msg: errorMsg,
|
|
59
|
+
name: res.name,
|
|
60
|
+
path: res.path,
|
|
61
|
+
created: res.created,
|
|
62
|
+
last_modified: res.last_modified,
|
|
63
|
+
size: res.size,
|
|
64
|
+
type: res.type
|
|
65
|
+
});
|
|
66
|
+
_this.modalService.openModal(SaveFileErrorModal);
|
|
67
|
+
throw new Error(errorMsg);
|
|
68
|
+
case 15:
|
|
69
|
+
_context.next = 24;
|
|
70
|
+
break;
|
|
71
|
+
case 17:
|
|
72
|
+
_context.prev = 17;
|
|
73
|
+
_context.t0 = _context["catch"](4);
|
|
74
|
+
if (res) {
|
|
75
|
+
_context.next = 21;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
return _context.abrupt("return");
|
|
79
|
+
case 21:
|
|
80
|
+
model.fileService.fileSaveErrorEmitter.fire({
|
|
81
|
+
cause: _context.t0.errorCause,
|
|
82
|
+
msg: _context.t0.message,
|
|
83
|
+
name: res.name || model.currentFileContents.name,
|
|
84
|
+
path: res.path || model.currentFileContents.path,
|
|
85
|
+
created: res.created || model.currentFileContents.created,
|
|
86
|
+
last_modified: res.last_modified || model.currentFileContents.last_modified,
|
|
87
|
+
size: res.size || model.currentFileContents.size,
|
|
88
|
+
type: res.type || model.currentFileContents.type
|
|
89
|
+
});
|
|
90
|
+
_this.modalService.openModal(SaveFileErrorModal);
|
|
91
|
+
throw new Error('File Save Error');
|
|
92
|
+
case 24:
|
|
93
|
+
_context.next = 26;
|
|
94
|
+
return model.createCheckpoint();
|
|
95
|
+
case 26:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee, null, [[4, 17]]);
|
|
100
|
+
}));
|
|
101
|
+
return function (_x, _x2) {
|
|
102
|
+
return _ref.apply(this, arguments);
|
|
103
|
+
};
|
|
104
|
+
}();
|
|
105
|
+
}), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "modalService", [_dec2], {
|
|
106
|
+
configurable: true,
|
|
107
|
+
enumerable: true,
|
|
108
|
+
writable: true,
|
|
109
|
+
initializer: null
|
|
110
|
+
})), _class2)) || _class);
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { VirtualizedManager } from '@difizen/libro-core';
|
|
2
2
|
import { LibroModel, VirtualizedManagerHelper } from '@difizen/libro-core';
|
|
3
|
-
import { ContentsManager,
|
|
4
|
-
import type { IKernelConnection } from '@difizen/libro-kernel';
|
|
3
|
+
import { ContentsManager, LibroKernelConnectionManager, ServerConnection, ServerManager } from '@difizen/libro-kernel';
|
|
4
|
+
import type { IKernelConnection, ExecutableNotebookModel } from '@difizen/libro-kernel';
|
|
5
5
|
import type { IContentsCheckpointModel, IContentsModel } from '@difizen/libro-kernel';
|
|
6
6
|
import { ModalService } from '@difizen/mana-app';
|
|
7
7
|
import { Deferred } from '@difizen/mana-app';
|
|
8
8
|
import { LibroFileService } from './libro-jupyter-protocol.js';
|
|
9
9
|
type IModel = IContentsModel;
|
|
10
10
|
export declare class LibroJupyterModel extends LibroModel implements ExecutableNotebookModel {
|
|
11
|
-
static is: (arg: Record<any, any> | undefined) => arg is LibroJupyterModel;
|
|
12
11
|
protected libroFileService: LibroFileService;
|
|
13
12
|
protected virtualizedManager: VirtualizedManager;
|
|
14
13
|
get fileService(): LibroFileService;
|
|
@@ -41,7 +40,6 @@ export declare class LibroJupyterModel extends LibroModel implements ExecutableN
|
|
|
41
40
|
restoreCheckpoint(checkpointID: string): Promise<void>;
|
|
42
41
|
deleteCheckpoint(checkpointID: string): Promise<void>;
|
|
43
42
|
startKernelConnection(): void;
|
|
44
|
-
saveNotebookContent(): Promise<void>;
|
|
45
43
|
canRun(): boolean;
|
|
46
44
|
interrupt(): Promise<void>;
|
|
47
45
|
shutdown(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-jupyter-model.d.ts","sourceRoot":"","sources":["../src/libro-jupyter-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"libro-jupyter-model.d.ts","sourceRoot":"","sources":["../src/libro-jupyter-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACL,eAAe,EAEf,4BAA4B,EAC5B,gBAAgB,EAChB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAa,YAAY,EAAQ,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAGL,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAGrC,KAAK,MAAM,GAAG,cAAc,CAAC;AAC7B,qBACa,iBAAkB,SAAQ,UAAW,YAAW,uBAAuB;IAClF,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC7C,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAEjD,IAAI,WAAW,qBAEd;IAGD,mBAAmB,EAAE,MAAM,CAAC;IAE5B,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAE/B,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAE/B,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IAGrC,UAAU,UAAQ;IAElB,SAAS,CAAC,uBAAuB,EAAE,4BAA4B,CAAC;IAChE,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IACvC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IACpD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;gBAGlB,gBAAgB,EAAE,gBAAgB,EAE5D,uBAAuB,EAAE,4BAA4B,EAC9B,aAAa,EAAE,aAAa,EACzB,gBAAgB,EAAE,gBAAgB,EACnC,eAAe,EAAE,eAAe,EACnC,YAAY,EAAE,YAAY,EAEhD,wBAAwB,EAAE,wBAAwB;IA6BpD,IAAI,YAAY,wBAEf;IAED,IAAI,eAAe,IAIQ,MAAM,CAFhC;IAED,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,EAEhC;IAED,IAAI,mBAAmB,IAIQ,MAAM,CAFpC;IAED,IAAI,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAEpC;IACD,SAAS,CAAC,UAAU,8BAAqC;IACzD,IAAI,OAAO,+BAEV;IAGD,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAC;IAGtC,QAAQ,SAAM;IAEd,SAAS,CAAC,aAAa,SAAM;IAE7B,IAAI,YAAY,IAIQ,MAAM,CAF7B;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,qBAAqB,EAAE,wBAAwB,CAAC;IAE1C,gBAAgB;IAMhB,eAAe;IAIf,iBAAiB,CAAC,YAAY,EAAE,MAAM;IAItC,gBAAgB,CAAC,YAAY,EAAE,MAAM;IAI3C,qBAAqB;IA2BZ,MAAM;IAcT,SAAS;IAQT,QAAQ;IAUR,OAAO;IAkBP,SAAS;IAQf,eAAe;CAYhB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _LibroJupyterModel;
|
|
2
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;
|
|
3
3
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
4
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
5
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -22,15 +22,14 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
22
22
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
23
23
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
24
24
|
import { LibroModel, VirtualizedManagerHelper } from '@difizen/libro-core';
|
|
25
|
-
import { ContentsManager,
|
|
25
|
+
import { ContentsManager, isDisplayDataMsg, LibroKernelConnectionManager, ServerConnection, ServerManager } from '@difizen/libro-kernel';
|
|
26
26
|
import { getOrigin, ModalService, prop } from '@difizen/mana-app';
|
|
27
27
|
import { Deferred } from '@difizen/mana-app';
|
|
28
28
|
import { inject, transient } from '@difizen/mana-app';
|
|
29
29
|
import { l10n } from '@difizen/mana-l10n';
|
|
30
30
|
import { ExecutedWithKernelCellModel, libroArgsMimetype, LibroFileService } from "./libro-jupyter-protocol.js";
|
|
31
|
-
import { SaveFileErrorModal } from "./toolbar/save-file-error.js";
|
|
32
31
|
import { getDefaultKernel } from "./utils/index.js";
|
|
33
|
-
export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec(_class = (_class2 =
|
|
32
|
+
export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_LibroModel) {
|
|
34
33
|
_inherits(LibroJupyterModel, _LibroModel);
|
|
35
34
|
var _super = _createSuper(LibroJupyterModel);
|
|
36
35
|
function LibroJupyterModel(libroFileService, kernelConnectionManager, serverManager, serverConnection, contentsManager, modalService, virtualizedManagerHelper) {
|
|
@@ -250,88 +249,6 @@ export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop
|
|
|
250
249
|
}, _callee5);
|
|
251
250
|
}))).catch(console.error);
|
|
252
251
|
}
|
|
253
|
-
}, {
|
|
254
|
-
key: "saveNotebookContent",
|
|
255
|
-
value: function () {
|
|
256
|
-
var _saveNotebookContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
257
|
-
var notebookContent, res, _res, errorMsg;
|
|
258
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
259
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
260
|
-
case 0:
|
|
261
|
-
notebookContent = this.toJSON();
|
|
262
|
-
if (this.currentFileContents) {
|
|
263
|
-
_context6.next = 3;
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
throw new Error('currentFileContents is undefined');
|
|
267
|
-
case 3:
|
|
268
|
-
res = {};
|
|
269
|
-
_context6.prev = 4;
|
|
270
|
-
_context6.next = 7;
|
|
271
|
-
return this.libroFileService.write(notebookContent, this.currentFileContents);
|
|
272
|
-
case 7:
|
|
273
|
-
res = _context6.sent;
|
|
274
|
-
if (res) {
|
|
275
|
-
_context6.next = 10;
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
return _context6.abrupt("return");
|
|
279
|
-
case 10:
|
|
280
|
-
if (!(res.last_modified === this.last_modified || res.size === 0)) {
|
|
281
|
-
_context6.next = 15;
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
errorMsg = "File Save Error: ".concat((_res = res) === null || _res === void 0 ? void 0 : _res.message, " ");
|
|
285
|
-
this.libroFileService.fileSaveErrorEmitter.fire({
|
|
286
|
-
cause: res.message,
|
|
287
|
-
msg: errorMsg,
|
|
288
|
-
name: res.name,
|
|
289
|
-
path: res.path,
|
|
290
|
-
created: res.created,
|
|
291
|
-
last_modified: res.last_modified,
|
|
292
|
-
size: res.size,
|
|
293
|
-
type: res.type
|
|
294
|
-
});
|
|
295
|
-
this.modalService.openModal(SaveFileErrorModal);
|
|
296
|
-
throw new Error(errorMsg);
|
|
297
|
-
case 15:
|
|
298
|
-
_context6.next = 24;
|
|
299
|
-
break;
|
|
300
|
-
case 17:
|
|
301
|
-
_context6.prev = 17;
|
|
302
|
-
_context6.t0 = _context6["catch"](4);
|
|
303
|
-
if (res) {
|
|
304
|
-
_context6.next = 21;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
return _context6.abrupt("return");
|
|
308
|
-
case 21:
|
|
309
|
-
this.libroFileService.fileSaveErrorEmitter.fire({
|
|
310
|
-
cause: _context6.t0.errorCause,
|
|
311
|
-
msg: _context6.t0.message,
|
|
312
|
-
name: res.name || this.currentFileContents.name,
|
|
313
|
-
path: res.path || this.currentFileContents.path,
|
|
314
|
-
created: res.created || this.currentFileContents.created,
|
|
315
|
-
last_modified: res.last_modified || this.currentFileContents.last_modified,
|
|
316
|
-
size: res.size || this.currentFileContents.size,
|
|
317
|
-
type: res.type || this.currentFileContents.type
|
|
318
|
-
});
|
|
319
|
-
this.modalService.openModal(SaveFileErrorModal);
|
|
320
|
-
throw new Error('File Save Error');
|
|
321
|
-
case 24:
|
|
322
|
-
_context6.next = 26;
|
|
323
|
-
return this.createCheckpoint();
|
|
324
|
-
case 26:
|
|
325
|
-
case "end":
|
|
326
|
-
return _context6.stop();
|
|
327
|
-
}
|
|
328
|
-
}, _callee6, this, [[4, 17]]);
|
|
329
|
-
}));
|
|
330
|
-
function saveNotebookContent() {
|
|
331
|
-
return _saveNotebookContent.apply(this, arguments);
|
|
332
|
-
}
|
|
333
|
-
return saveNotebookContent;
|
|
334
|
-
}()
|
|
335
252
|
}, {
|
|
336
253
|
key: "canRun",
|
|
337
254
|
value: function canRun() {
|
|
@@ -348,24 +265,24 @@ export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop
|
|
|
348
265
|
}, {
|
|
349
266
|
key: "interrupt",
|
|
350
267
|
value: function () {
|
|
351
|
-
var _interrupt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
352
|
-
return _regeneratorRuntime().wrap(function
|
|
353
|
-
while (1) switch (
|
|
268
|
+
var _interrupt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
269
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
270
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
354
271
|
case 0:
|
|
355
272
|
if (this.kernelConnection) {
|
|
356
|
-
|
|
273
|
+
_context6.next = 3;
|
|
357
274
|
break;
|
|
358
275
|
}
|
|
359
276
|
alert(l10n.t('Kernel Connection 还没有建立'));
|
|
360
|
-
return
|
|
277
|
+
return _context6.abrupt("return");
|
|
361
278
|
case 3:
|
|
362
|
-
|
|
279
|
+
_context6.next = 5;
|
|
363
280
|
return this.kernelConnection.interrupt();
|
|
364
281
|
case 5:
|
|
365
282
|
case "end":
|
|
366
|
-
return
|
|
283
|
+
return _context6.stop();
|
|
367
284
|
}
|
|
368
|
-
},
|
|
285
|
+
}, _callee6, this);
|
|
369
286
|
}));
|
|
370
287
|
function interrupt() {
|
|
371
288
|
return _interrupt.apply(this, arguments);
|
|
@@ -375,26 +292,26 @@ export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop
|
|
|
375
292
|
}, {
|
|
376
293
|
key: "shutdown",
|
|
377
294
|
value: function () {
|
|
378
|
-
var _shutdown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
379
|
-
return _regeneratorRuntime().wrap(function
|
|
380
|
-
while (1) switch (
|
|
295
|
+
var _shutdown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
297
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
381
298
|
case 0:
|
|
382
299
|
if (this.kernelConnection) {
|
|
383
|
-
|
|
300
|
+
_context7.next = 3;
|
|
384
301
|
break;
|
|
385
302
|
}
|
|
386
303
|
alert(l10n.t('Kernel Connection 还没有建立'));
|
|
387
|
-
return
|
|
304
|
+
return _context7.abrupt("return");
|
|
388
305
|
case 3:
|
|
389
|
-
|
|
306
|
+
_context7.next = 5;
|
|
390
307
|
return this.kernelConnectionManager.shutdownKC(this.currentFileContents);
|
|
391
308
|
case 5:
|
|
392
309
|
this.kernelConnection = undefined;
|
|
393
310
|
case 6:
|
|
394
311
|
case "end":
|
|
395
|
-
return
|
|
312
|
+
return _context7.stop();
|
|
396
313
|
}
|
|
397
|
-
},
|
|
314
|
+
}, _callee7, this);
|
|
398
315
|
}));
|
|
399
316
|
function shutdown() {
|
|
400
317
|
return _shutdown.apply(this, arguments);
|
|
@@ -404,13 +321,13 @@ export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop
|
|
|
404
321
|
}, {
|
|
405
322
|
key: "restart",
|
|
406
323
|
value: function () {
|
|
407
|
-
var _restart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
324
|
+
var _restart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
408
325
|
var _this3 = this;
|
|
409
|
-
return _regeneratorRuntime().wrap(function
|
|
410
|
-
while (1) switch (
|
|
326
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
327
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
411
328
|
case 0:
|
|
412
329
|
if (!(!this.kernelConnection || this.kernelConnection.isDisposed)) {
|
|
413
|
-
|
|
330
|
+
_context8.next = 4;
|
|
414
331
|
break;
|
|
415
332
|
}
|
|
416
333
|
this.startKernelConnection();
|
|
@@ -421,14 +338,14 @@ export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop
|
|
|
421
338
|
}
|
|
422
339
|
return;
|
|
423
340
|
}).catch(console.error);
|
|
424
|
-
return
|
|
341
|
+
return _context8.abrupt("return");
|
|
425
342
|
case 4:
|
|
426
343
|
this.kernelConnection.restart();
|
|
427
344
|
case 5:
|
|
428
345
|
case "end":
|
|
429
|
-
return
|
|
346
|
+
return _context8.stop();
|
|
430
347
|
}
|
|
431
|
-
},
|
|
348
|
+
}, _callee8, this);
|
|
432
349
|
}));
|
|
433
350
|
function restart() {
|
|
434
351
|
return _restart.apply(this, arguments);
|
|
@@ -438,24 +355,24 @@ export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop
|
|
|
438
355
|
}, {
|
|
439
356
|
key: "reconnect",
|
|
440
357
|
value: function () {
|
|
441
|
-
var _reconnect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
442
|
-
return _regeneratorRuntime().wrap(function
|
|
443
|
-
while (1) switch (
|
|
358
|
+
var _reconnect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
359
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
360
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
444
361
|
case 0:
|
|
445
362
|
if (this.kernelConnection) {
|
|
446
|
-
|
|
363
|
+
_context9.next = 3;
|
|
447
364
|
break;
|
|
448
365
|
}
|
|
449
366
|
alert(l10n.t('Kernel Connection 还没有建立'));
|
|
450
|
-
return
|
|
367
|
+
return _context9.abrupt("return");
|
|
451
368
|
case 3:
|
|
452
|
-
|
|
369
|
+
_context9.next = 5;
|
|
453
370
|
return this.kernelConnection.reconnect();
|
|
454
371
|
case 5:
|
|
455
372
|
case "end":
|
|
456
|
-
return
|
|
373
|
+
return _context9.stop();
|
|
457
374
|
}
|
|
458
|
-
},
|
|
375
|
+
}, _callee9, this);
|
|
459
376
|
}));
|
|
460
377
|
function reconnect() {
|
|
461
378
|
return _reconnect.apply(this, arguments);
|
|
@@ -478,9 +395,7 @@ export var LibroJupyterModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop
|
|
|
478
395
|
}
|
|
479
396
|
}]);
|
|
480
397
|
return LibroJupyterModel;
|
|
481
|
-
}(LibroModel),
|
|
482
|
-
return !!arg && ExecutableNotebookModel.is(arg) && 'kernelConnection' in arg && _typeof(arg.kernelConnection) === 'object' && 'lspEnabled' in arg && typeof arg.lspEnabled === 'boolean';
|
|
483
|
-
}, _LibroJupyterModel), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "currentFileContents", [_dec2], {
|
|
398
|
+
}(LibroModel), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "currentFileContents", [_dec2], {
|
|
484
399
|
configurable: true,
|
|
485
400
|
enumerable: true,
|
|
486
401
|
writable: true,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseWorkspaceService, ILibroWorkspaceService } from '@difizen/libro-core';
|
|
2
|
+
import { ServerConnection, ServerManager } from '@difizen/libro-kernel';
|
|
3
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
4
|
+
import { URI } from '@difizen/mana-app';
|
|
5
|
+
interface JupyterWorkspaceData {
|
|
6
|
+
rootUri: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class JupyterWorkspaceService extends BaseWorkspaceService implements ILibroWorkspaceService, ApplicationContribution {
|
|
9
|
+
serverConnection: ServerConnection;
|
|
10
|
+
serverManager: ServerManager;
|
|
11
|
+
protected workspaceData: JupyterWorkspaceData;
|
|
12
|
+
onViewStart(): void;
|
|
13
|
+
get workspaceRoot(): URI;
|
|
14
|
+
get notebooks(): never[];
|
|
15
|
+
get files(): never[];
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=libro-jupyter-workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-jupyter-workspace.d.ts","sourceRoot":"","sources":["../src/libro-jupyter-workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGxC,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBACa,uBACX,SAAQ,oBACR,YAAW,sBAAsB,EAAE,uBAAuB;IAEhC,gBAAgB,EAAE,gBAAgB,CAAC;IACtC,aAAa,EAAE,aAAa,CAAC;IAEpD,SAAS,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAE9C,WAAW;IAkBX,IAAa,aAAa,QAEzB;IACD,IAAa,SAAS,YAErB;IACD,IAAa,KAAK,YAEjB;CACF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
19
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
23
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
24
|
+
import { URL } from '@difizen/libro-common';
|
|
25
|
+
import { BaseWorkspaceService, ILibroWorkspaceService } from '@difizen/libro-core';
|
|
26
|
+
import { ServerConnection, ServerManager } from '@difizen/libro-kernel';
|
|
27
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
28
|
+
import { URI } from '@difizen/mana-app';
|
|
29
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
30
|
+
export var JupyterWorkspaceService = (_dec = singleton({
|
|
31
|
+
contrib: [ILibroWorkspaceService, ApplicationContribution]
|
|
32
|
+
}), _dec2 = inject(ServerConnection), _dec3 = inject(ServerManager), _dec(_class = (_class2 = /*#__PURE__*/function (_BaseWorkspaceService) {
|
|
33
|
+
_inherits(JupyterWorkspaceService, _BaseWorkspaceService);
|
|
34
|
+
var _super = _createSuper(JupyterWorkspaceService);
|
|
35
|
+
function JupyterWorkspaceService() {
|
|
36
|
+
var _this;
|
|
37
|
+
_classCallCheck(this, JupyterWorkspaceService);
|
|
38
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
39
|
+
args[_key] = arguments[_key];
|
|
40
|
+
}
|
|
41
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
42
|
+
_initializerDefineProperty(_this, "serverConnection", _descriptor, _assertThisInitialized(_this));
|
|
43
|
+
_initializerDefineProperty(_this, "serverManager", _descriptor2, _assertThisInitialized(_this));
|
|
44
|
+
_this.workspaceData = void 0;
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
_createClass(JupyterWorkspaceService, [{
|
|
48
|
+
key: "onViewStart",
|
|
49
|
+
value: function onViewStart() {
|
|
50
|
+
var _this2 = this;
|
|
51
|
+
this.serverManager.ready.then(function () {
|
|
52
|
+
var settings = _objectSpread({}, _this2.serverConnection.settings);
|
|
53
|
+
var url = URL.join(settings.baseUrl, '/libro/api/workspace');
|
|
54
|
+
return _this2.serverConnection.makeRequest(url, {});
|
|
55
|
+
}).then( /*#__PURE__*/function () {
|
|
56
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
|
|
57
|
+
var data;
|
|
58
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
59
|
+
while (1) switch (_context.prev = _context.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
_context.next = 2;
|
|
62
|
+
return res.json();
|
|
63
|
+
case 2:
|
|
64
|
+
data = _context.sent;
|
|
65
|
+
_this2.workspaceData = data;
|
|
66
|
+
_this2.deferred.resolve();
|
|
67
|
+
return _context.abrupt("return");
|
|
68
|
+
case 6:
|
|
69
|
+
case "end":
|
|
70
|
+
return _context.stop();
|
|
71
|
+
}
|
|
72
|
+
}, _callee);
|
|
73
|
+
}));
|
|
74
|
+
return function (_x) {
|
|
75
|
+
return _ref.apply(this, arguments);
|
|
76
|
+
};
|
|
77
|
+
}()).catch(function () {
|
|
78
|
+
return;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "workspaceRoot",
|
|
83
|
+
get: function get() {
|
|
84
|
+
return new URI(this.workspaceData.rootUri);
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "notebooks",
|
|
88
|
+
get: function get() {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "files",
|
|
93
|
+
get: function get() {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}]);
|
|
97
|
+
return JupyterWorkspaceService;
|
|
98
|
+
}(BaseWorkspaceService), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "serverConnection", [_dec2], {
|
|
99
|
+
configurable: true,
|
|
100
|
+
enumerable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
initializer: null
|
|
103
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "serverManager", [_dec3], {
|
|
104
|
+
configurable: true,
|
|
105
|
+
enumerable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
initializer: null
|
|
108
|
+
})), _class2)) || _class);
|
package/es/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgC/C,eAAO,MAAM,kBAAkB,YAyD5B,CAAC"}
|
package/es/module.js
CHANGED
|
@@ -16,6 +16,7 @@ import { LibroJupyterCommandContribution, LibroJupyterKeybindingContribution } f
|
|
|
16
16
|
import { CellExecutionTip, CellInputBottomBlank } from "./components/index.js";
|
|
17
17
|
import { ConfigAppContribution, LibroJupyterSettingContribution } from "./config/index.js";
|
|
18
18
|
import { LibroJupyterContentContribution } from "./contents/index.js";
|
|
19
|
+
import { LibroJupyterContentSaveContribution } from "./contents/save-content-contribution.js";
|
|
19
20
|
import { LibroJupyterFileModule } from "./file/index.js";
|
|
20
21
|
import { KeybindInstructionsModule } from "./keybind-instructions/index.js";
|
|
21
22
|
import { LibroJupyterFileService } from "./libro-jupyter-file-service.js";
|
|
@@ -23,11 +24,12 @@ import { LibroJupyterModel } from "./libro-jupyter-model.js";
|
|
|
23
24
|
import { KernelStatusAndSelectorProvider } from "./libro-jupyter-protocol.js";
|
|
24
25
|
import { JupyterServerLaunchManager } from "./libro-jupyter-server-launch-manager.js";
|
|
25
26
|
import { LibroJupyterView } from "./libro-jupyter-view.js";
|
|
27
|
+
import { JupyterWorkspaceService } from "./libro-jupyter-workspace.js";
|
|
26
28
|
import { LibroJupyterOutputArea } from "./output/index.js";
|
|
27
29
|
import { PlotlyModule } from "./rendermime/index.js";
|
|
28
30
|
import { LibroJupyterColorContribution } from "./theme/index.js";
|
|
29
31
|
import { KernelStatusSelector, LibroJupyterToolbarContribution, SaveFileErrorContribution } from "./toolbar/index.js";
|
|
30
|
-
export var LibroJupyterModule = ManaModule.create().register(LibroJupyterFileService, LibroJupyterCommandContribution, LibroJupyterKeybindingContribution, LibroJupyterToolbarContribution, ConfigAppContribution, SaveFileErrorContribution, LibroKeybindRegistry, LibroJupyterContentContribution, LibroJupyterOutputArea, LibroJupyterColorContribution, LibroJupyterSettingContribution, JupyterServerLaunchManager, LibroJupyterView, {
|
|
32
|
+
export var LibroJupyterModule = ManaModule.create().register(JupyterWorkspaceService, LibroJupyterFileService, LibroJupyterCommandContribution, LibroJupyterKeybindingContribution, LibroJupyterToolbarContribution, ConfigAppContribution, SaveFileErrorContribution, LibroKeybindRegistry, LibroJupyterContentContribution, LibroJupyterContentSaveContribution, LibroJupyterOutputArea, LibroJupyterColorContribution, LibroJupyterSettingContribution, JupyterServerLaunchManager, LibroJupyterView, {
|
|
31
33
|
token: CellExecutionTimeProvider,
|
|
32
34
|
useValue: CellExecutionTip
|
|
33
35
|
}, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-jupyter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro"
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
"src"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@difizen/libro-cofine-editor": "^0.1.
|
|
35
|
-
"@difizen/libro-code-editor": "^0.1.
|
|
36
|
-
"@difizen/libro-code-cell": "^0.1.
|
|
37
|
-
"@difizen/libro-codemirror": "^0.1.
|
|
38
|
-
"@difizen/libro-rendermime": "^0.1.
|
|
39
|
-
"@difizen/libro-common": "^0.1.
|
|
40
|
-
"@difizen/libro-core": "^0.1.
|
|
41
|
-
"@difizen/libro-kernel": "^0.1.
|
|
42
|
-
"@difizen/libro-l10n": "^0.1.
|
|
43
|
-
"@difizen/libro-output": "^0.1.
|
|
44
|
-
"@difizen/libro-search": "^0.1.
|
|
45
|
-
"@difizen/libro-search-code-cell": "^0.1.
|
|
46
|
-
"@difizen/libro-lsp": "^0.1.
|
|
47
|
-
"@difizen/libro-markdown-cell": "^0.1.
|
|
48
|
-
"@difizen/libro-raw-cell": "^0.1.
|
|
49
|
-
"@difizen/libro-language-client": "^0.1.
|
|
34
|
+
"@difizen/libro-cofine-editor": "^0.1.28",
|
|
35
|
+
"@difizen/libro-code-editor": "^0.1.28",
|
|
36
|
+
"@difizen/libro-code-cell": "^0.1.28",
|
|
37
|
+
"@difizen/libro-codemirror": "^0.1.28",
|
|
38
|
+
"@difizen/libro-rendermime": "^0.1.28",
|
|
39
|
+
"@difizen/libro-common": "^0.1.28",
|
|
40
|
+
"@difizen/libro-core": "^0.1.28",
|
|
41
|
+
"@difizen/libro-kernel": "^0.1.28",
|
|
42
|
+
"@difizen/libro-l10n": "^0.1.28",
|
|
43
|
+
"@difizen/libro-output": "^0.1.28",
|
|
44
|
+
"@difizen/libro-search": "^0.1.28",
|
|
45
|
+
"@difizen/libro-search-code-cell": "^0.1.28",
|
|
46
|
+
"@difizen/libro-lsp": "^0.1.28",
|
|
47
|
+
"@difizen/libro-markdown-cell": "^0.1.28",
|
|
48
|
+
"@difizen/libro-raw-cell": "^0.1.28",
|
|
49
|
+
"@difizen/libro-language-client": "^0.1.28",
|
|
50
50
|
"@difizen/mana-app": "latest",
|
|
51
51
|
"@difizen/mana-l10n": "latest",
|
|
52
52
|
"@ant-design/colors": "^7.0.0",
|
|
@@ -7,8 +7,8 @@ import type {
|
|
|
7
7
|
TooltipProviderOption,
|
|
8
8
|
} from '@difizen/libro-code-editor';
|
|
9
9
|
import { KernelError } from '@difizen/libro-kernel';
|
|
10
|
-
import {
|
|
11
|
-
import { transient
|
|
10
|
+
import { getCellURI } from '@difizen/libro-language-client';
|
|
11
|
+
import { transient } from '@difizen/mana-app';
|
|
12
12
|
import { view, ViewInstance } from '@difizen/mana-app';
|
|
13
13
|
import { getOrigin, useInject } from '@difizen/mana-app';
|
|
14
14
|
import { l10n } from '@difizen/mana-l10n';
|
|
@@ -55,9 +55,8 @@ export class JupyterCodeCellView extends LibroCodeCellView {
|
|
|
55
55
|
|
|
56
56
|
protected override getEditorOption(): CodeEditorViewOptions {
|
|
57
57
|
const options = super.getEditorOption();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
uri = URI.withQuery(uri, `cellid=${this.model.id}`);
|
|
58
|
+
const uri = getCellURI(this.parent.model, this.model);
|
|
59
|
+
|
|
61
60
|
return {
|
|
62
61
|
...options,
|
|
63
62
|
uuid: uri.toString(),
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { NotebookOption } from '@difizen/libro-core';
|
|
2
|
+
import { ContentSaveContribution } from '@difizen/libro-core';
|
|
3
|
+
import type { IContentsModel } from '@difizen/libro-kernel';
|
|
4
|
+
import { ModalService, inject, singleton } from '@difizen/mana-app';
|
|
5
|
+
|
|
6
|
+
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
7
|
+
import { SaveFileErrorModal } from '../toolbar/save-file-error.js';
|
|
8
|
+
|
|
9
|
+
@singleton({ contrib: ContentSaveContribution })
|
|
10
|
+
export class LibroJupyterContentSaveContribution implements ContentSaveContribution {
|
|
11
|
+
@inject(ModalService) protected readonly modalService: ModalService;
|
|
12
|
+
|
|
13
|
+
canHandle = () => {
|
|
14
|
+
return 2;
|
|
15
|
+
};
|
|
16
|
+
saveContent = async (options: NotebookOption, model: LibroJupyterModel) => {
|
|
17
|
+
const notebookContent = model.toJSON();
|
|
18
|
+
if (!model.currentFileContents) {
|
|
19
|
+
throw new Error('currentFileContents is undefined');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let res = {} as IContentsModel | undefined;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
res = await model.fileService.write(notebookContent, model.currentFileContents);
|
|
26
|
+
if (!res) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// 文件保存失败
|
|
30
|
+
if (res.last_modified === model.lastModified || res.size === 0) {
|
|
31
|
+
const errorMsg = `File Save Error: ${res?.message} `;
|
|
32
|
+
model.fileService.fileSaveErrorEmitter.fire({
|
|
33
|
+
cause: res.message,
|
|
34
|
+
msg: errorMsg,
|
|
35
|
+
name: res.name,
|
|
36
|
+
path: res.path,
|
|
37
|
+
created: res.created,
|
|
38
|
+
last_modified: res.last_modified,
|
|
39
|
+
size: res.size,
|
|
40
|
+
type: res.type,
|
|
41
|
+
});
|
|
42
|
+
this.modalService.openModal(SaveFileErrorModal);
|
|
43
|
+
|
|
44
|
+
throw new Error(errorMsg);
|
|
45
|
+
}
|
|
46
|
+
} catch (e: any) {
|
|
47
|
+
if (!res) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
model.fileService.fileSaveErrorEmitter.fire({
|
|
51
|
+
cause: e.errorCause,
|
|
52
|
+
msg: e.message,
|
|
53
|
+
name: res.name || model.currentFileContents.name,
|
|
54
|
+
path: res.path || model.currentFileContents.path,
|
|
55
|
+
created: res.created || model.currentFileContents.created,
|
|
56
|
+
last_modified: res.last_modified || model.currentFileContents.last_modified,
|
|
57
|
+
size: res.size || model.currentFileContents.size,
|
|
58
|
+
type: res.type || model.currentFileContents.type,
|
|
59
|
+
});
|
|
60
|
+
this.modalService.openModal(SaveFileErrorModal);
|
|
61
|
+
|
|
62
|
+
throw new Error('File Save Error');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await model.createCheckpoint();
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -2,13 +2,12 @@ import type { VirtualizedManager } from '@difizen/libro-core';
|
|
|
2
2
|
import { LibroModel, VirtualizedManagerHelper } from '@difizen/libro-core';
|
|
3
3
|
import {
|
|
4
4
|
ContentsManager,
|
|
5
|
-
ExecutableNotebookModel,
|
|
6
5
|
isDisplayDataMsg,
|
|
7
6
|
LibroKernelConnectionManager,
|
|
8
7
|
ServerConnection,
|
|
9
8
|
ServerManager,
|
|
10
9
|
} from '@difizen/libro-kernel';
|
|
11
|
-
import type { IKernelConnection } from '@difizen/libro-kernel';
|
|
10
|
+
import type { IKernelConnection, ExecutableNotebookModel } from '@difizen/libro-kernel';
|
|
12
11
|
import type { IContentsCheckpointModel, IContentsModel } from '@difizen/libro-kernel';
|
|
13
12
|
import { getOrigin, ModalService, prop } from '@difizen/mana-app';
|
|
14
13
|
import { Deferred } from '@difizen/mana-app';
|
|
@@ -20,23 +19,11 @@ import {
|
|
|
20
19
|
libroArgsMimetype,
|
|
21
20
|
LibroFileService,
|
|
22
21
|
} from './libro-jupyter-protocol.js';
|
|
23
|
-
import { SaveFileErrorModal } from './toolbar/save-file-error.js';
|
|
24
22
|
import { getDefaultKernel } from './utils/index.js';
|
|
25
23
|
|
|
26
24
|
type IModel = IContentsModel;
|
|
27
25
|
@transient()
|
|
28
26
|
export class LibroJupyterModel extends LibroModel implements ExecutableNotebookModel {
|
|
29
|
-
static is = (arg: Record<any, any> | undefined): arg is LibroJupyterModel => {
|
|
30
|
-
return (
|
|
31
|
-
!!arg &&
|
|
32
|
-
ExecutableNotebookModel.is(arg) &&
|
|
33
|
-
'kernelConnection' in arg &&
|
|
34
|
-
typeof (arg as any).kernelConnection === 'object' &&
|
|
35
|
-
'lspEnabled' in arg &&
|
|
36
|
-
typeof (arg as any).lspEnabled === 'boolean'
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
27
|
protected libroFileService: LibroFileService;
|
|
41
28
|
protected virtualizedManager: VirtualizedManager;
|
|
42
29
|
|
|
@@ -187,61 +174,6 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
187
174
|
.catch(console.error);
|
|
188
175
|
}
|
|
189
176
|
|
|
190
|
-
override async saveNotebookContent(): Promise<void> {
|
|
191
|
-
const notebookContent = this.toJSON();
|
|
192
|
-
if (!this.currentFileContents) {
|
|
193
|
-
throw new Error('currentFileContents is undefined');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
let res = {} as IModel | undefined;
|
|
197
|
-
|
|
198
|
-
try {
|
|
199
|
-
res = await this.libroFileService.write(
|
|
200
|
-
notebookContent,
|
|
201
|
-
this.currentFileContents,
|
|
202
|
-
);
|
|
203
|
-
if (!res) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
// 文件保存失败
|
|
207
|
-
if (res.last_modified === this.last_modified || res.size === 0) {
|
|
208
|
-
const errorMsg = `File Save Error: ${res?.message} `;
|
|
209
|
-
this.libroFileService.fileSaveErrorEmitter.fire({
|
|
210
|
-
cause: res.message,
|
|
211
|
-
msg: errorMsg,
|
|
212
|
-
name: res.name,
|
|
213
|
-
path: res.path,
|
|
214
|
-
created: res.created,
|
|
215
|
-
last_modified: res.last_modified,
|
|
216
|
-
size: res.size,
|
|
217
|
-
type: res.type,
|
|
218
|
-
});
|
|
219
|
-
this.modalService.openModal(SaveFileErrorModal);
|
|
220
|
-
|
|
221
|
-
throw new Error(errorMsg);
|
|
222
|
-
}
|
|
223
|
-
} catch (e: any) {
|
|
224
|
-
if (!res) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
this.libroFileService.fileSaveErrorEmitter.fire({
|
|
228
|
-
cause: e.errorCause,
|
|
229
|
-
msg: e.message,
|
|
230
|
-
name: res.name || this.currentFileContents.name,
|
|
231
|
-
path: res.path || this.currentFileContents.path,
|
|
232
|
-
created: res.created || this.currentFileContents.created,
|
|
233
|
-
last_modified: res.last_modified || this.currentFileContents.last_modified,
|
|
234
|
-
size: res.size || this.currentFileContents.size,
|
|
235
|
-
type: res.type || this.currentFileContents.type,
|
|
236
|
-
});
|
|
237
|
-
this.modalService.openModal(SaveFileErrorModal);
|
|
238
|
-
|
|
239
|
-
throw new Error('File Save Error');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
await this.createCheckpoint();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
177
|
override canRun() {
|
|
246
178
|
if (!this.kernelConnection) {
|
|
247
179
|
alert(l10n.t('Kernel Connection 还没有建立'));
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { URL } from '@difizen/libro-common';
|
|
2
|
+
import { BaseWorkspaceService, ILibroWorkspaceService } from '@difizen/libro-core';
|
|
3
|
+
import { ServerConnection, ServerManager } from '@difizen/libro-kernel';
|
|
4
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
5
|
+
import { URI } from '@difizen/mana-app';
|
|
6
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
7
|
+
|
|
8
|
+
interface JupyterWorkspaceData {
|
|
9
|
+
rootUri: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@singleton({ contrib: [ILibroWorkspaceService, ApplicationContribution] })
|
|
13
|
+
export class JupyterWorkspaceService
|
|
14
|
+
extends BaseWorkspaceService
|
|
15
|
+
implements ILibroWorkspaceService, ApplicationContribution
|
|
16
|
+
{
|
|
17
|
+
@inject(ServerConnection) serverConnection: ServerConnection;
|
|
18
|
+
@inject(ServerManager) serverManager: ServerManager;
|
|
19
|
+
|
|
20
|
+
protected workspaceData: JupyterWorkspaceData;
|
|
21
|
+
|
|
22
|
+
onViewStart() {
|
|
23
|
+
this.serverManager.ready
|
|
24
|
+
.then(() => {
|
|
25
|
+
const settings = { ...this.serverConnection.settings };
|
|
26
|
+
const url = URL.join(settings.baseUrl, '/libro/api/workspace');
|
|
27
|
+
return this.serverConnection.makeRequest(url, {});
|
|
28
|
+
})
|
|
29
|
+
.then(async (res) => {
|
|
30
|
+
const data = await res.json();
|
|
31
|
+
this.workspaceData = data;
|
|
32
|
+
this.deferred.resolve();
|
|
33
|
+
return;
|
|
34
|
+
})
|
|
35
|
+
.catch(() => {
|
|
36
|
+
return;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override get workspaceRoot() {
|
|
41
|
+
return new URI(this.workspaceData.rootUri);
|
|
42
|
+
}
|
|
43
|
+
override get notebooks() {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
override get files() {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/module.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
LibroJupyterSettingContribution,
|
|
40
40
|
} from './config/index.js';
|
|
41
41
|
import { LibroJupyterContentContribution } from './contents/index.js';
|
|
42
|
+
import { LibroJupyterContentSaveContribution } from './contents/save-content-contribution.js';
|
|
42
43
|
import { LibroJupyterFileModule } from './file/index.js';
|
|
43
44
|
import { KeybindInstructionsModule } from './keybind-instructions/index.js';
|
|
44
45
|
import { LibroJupyterFileService } from './libro-jupyter-file-service.js';
|
|
@@ -46,6 +47,7 @@ import { LibroJupyterModel } from './libro-jupyter-model.js';
|
|
|
46
47
|
import { KernelStatusAndSelectorProvider } from './libro-jupyter-protocol.js';
|
|
47
48
|
import { JupyterServerLaunchManager } from './libro-jupyter-server-launch-manager.js';
|
|
48
49
|
import { LibroJupyterView } from './libro-jupyter-view.js';
|
|
50
|
+
import { JupyterWorkspaceService } from './libro-jupyter-workspace.js';
|
|
49
51
|
import { LibroJupyterOutputArea } from './output/index.js';
|
|
50
52
|
import { PlotlyModule } from './rendermime/index.js';
|
|
51
53
|
import { LibroJupyterColorContribution } from './theme/index.js';
|
|
@@ -57,6 +59,7 @@ import {
|
|
|
57
59
|
|
|
58
60
|
export const LibroJupyterModule = ManaModule.create()
|
|
59
61
|
.register(
|
|
62
|
+
JupyterWorkspaceService,
|
|
60
63
|
LibroJupyterFileService,
|
|
61
64
|
LibroJupyterCommandContribution,
|
|
62
65
|
LibroJupyterKeybindingContribution,
|
|
@@ -65,6 +68,7 @@ export const LibroJupyterModule = ManaModule.create()
|
|
|
65
68
|
SaveFileErrorContribution,
|
|
66
69
|
LibroKeybindRegistry,
|
|
67
70
|
LibroJupyterContentContribution,
|
|
71
|
+
LibroJupyterContentSaveContribution,
|
|
68
72
|
LibroJupyterOutputArea,
|
|
69
73
|
LibroJupyterColorContribution,
|
|
70
74
|
LibroJupyterSettingContribution,
|