@difizen/libro-jupyter 0.1.27 → 0.1.29

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.
@@ -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 +1 @@
1
- {"version":3,"file":"file-create-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnE,OAAO,cAAc,CAAC;AAWtB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,KAAK,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CA0J5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
1
+ {"version":3,"file":"file-create-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAMnE,OAAO,cAAc,CAAC;AAWtB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,KAAK,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAkK5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
@@ -8,6 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import { CommandRegistry } from '@difizen/mana-app';
11
12
  import { URI, useInject, ViewManager } from '@difizen/mana-app';
12
13
  import { Col, Form, message, Row, Input, Modal } from 'antd';
13
14
  import { useEffect, useRef, useState } from 'react';
@@ -20,6 +21,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
20
21
  close = _ref.close,
21
22
  data = _ref.data;
22
23
  var fileService = useInject(JupyterFileService);
24
+ var commands = useInject(CommandRegistry);
23
25
  var viewManager = useInject(ViewManager);
24
26
  var _useState = useState(data === null || data === void 0 ? void 0 : data.fileType),
25
27
  _useState2 = _slicedToArray(_useState, 2),
@@ -35,6 +37,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
35
37
  form = _Form$useForm2[0];
36
38
  var onFinish = /*#__PURE__*/function () {
37
39
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
40
+ var stat;
38
41
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
42
  while (1) switch (_context.prev = _context.next) {
40
43
  case 0:
@@ -46,20 +49,28 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
46
49
  _context.next = 6;
47
50
  return fileService.newFile(values.fileName + (fileType || ''), new URI(data === null || data === void 0 ? void 0 : data.path));
48
51
  case 6:
52
+ stat = _context.sent;
49
53
  if (fileView) {
50
54
  fileView.model.refresh();
51
55
  }
52
- _context.next = 12;
56
+ if (stat.isFile) {
57
+ commands.executeCommand('fileTree.command.openfile', {
58
+ fileStat: stat,
59
+ uri: stat.resource
60
+ });
61
+ }
62
+ // message.success('新建文件成功');
63
+ _context.next = 14;
53
64
  break;
54
- case 9:
55
- _context.prev = 9;
65
+ case 11:
66
+ _context.prev = 11;
56
67
  _context.t0 = _context["catch"](3);
57
68
  message.error('新建文件失败');
58
- case 12:
69
+ case 14:
59
70
  case "end":
60
71
  return _context.stop();
61
72
  }
62
- }, _callee, null, [[3, 9]]);
73
+ }, _callee, null, [[3, 11]]);
63
74
  }));
64
75
  return function onFinish(_x) {
65
76
  return _ref2.apply(this, arguments);
@@ -390,7 +390,7 @@ export var JupyterFileService = (_dec = singleton({
390
390
  _context10.next = 13;
391
391
  return this.rename(new URI(res.path.toString()), fileName);
392
392
  case 13:
393
- return _context10.abrupt("return", this.resolve(target));
393
+ return _context10.abrupt("return", this.resolve(targetFileUri));
394
394
  case 14:
395
395
  case "end":
396
396
  return _context10.stop();
@@ -7,4 +7,5 @@ export * from './file-protocol.js';
7
7
  export * from './file-icon.js';
8
8
  export * from './file-create-modal.js';
9
9
  export * from './file-createdir-modal.js';
10
+ export * from './file-command.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC"}
package/es/file/index.js CHANGED
@@ -6,4 +6,5 @@ export * from "./file-service.js";
6
6
  export * from "./file-protocol.js";
7
7
  export * from "./file-icon.js";
8
8
  export * from "./file-create-modal.js";
9
- export * from "./file-createdir-modal.js";
9
+ export * from "./file-createdir-modal.js";
10
+ export * from "./file-command.js";
@@ -40,7 +40,6 @@ export declare class LibroJupyterModel extends LibroModel implements ExecutableN
40
40
  restoreCheckpoint(checkpointID: string): Promise<void>;
41
41
  deleteCheckpoint(checkpointID: string): Promise<void>;
42
42
  startKernelConnection(): void;
43
- saveNotebookContent(): Promise<void>;
44
43
  canRun(): boolean;
45
44
  interrupt(): Promise<void>;
46
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,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;AAIrC,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;IA2BN,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuD1C,MAAM;IAcT,SAAS;IAQT,QAAQ;IAUR,OAAO;IAkBP,SAAS;IAQf,eAAe;CAYhB"}
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"}
@@ -28,7 +28,6 @@ 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
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);
@@ -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 _callee7() {
352
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
353
- while (1) switch (_context7.prev = _context7.next) {
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
- _context7.next = 3;
273
+ _context6.next = 3;
357
274
  break;
358
275
  }
359
276
  alert(l10n.t('Kernel Connection 还没有建立'));
360
- return _context7.abrupt("return");
277
+ return _context6.abrupt("return");
361
278
  case 3:
362
- _context7.next = 5;
279
+ _context6.next = 5;
363
280
  return this.kernelConnection.interrupt();
364
281
  case 5:
365
282
  case "end":
366
- return _context7.stop();
283
+ return _context6.stop();
367
284
  }
368
- }, _callee7, this);
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 _callee8() {
379
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
380
- while (1) switch (_context8.prev = _context8.next) {
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
- _context8.next = 3;
300
+ _context7.next = 3;
384
301
  break;
385
302
  }
386
303
  alert(l10n.t('Kernel Connection 还没有建立'));
387
- return _context8.abrupt("return");
304
+ return _context7.abrupt("return");
388
305
  case 3:
389
- _context8.next = 5;
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 _context8.stop();
312
+ return _context7.stop();
396
313
  }
397
- }, _callee8, this);
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 _callee9() {
324
+ var _restart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
408
325
  var _this3 = this;
409
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
410
- while (1) switch (_context9.prev = _context9.next) {
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
- _context9.next = 4;
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 _context9.abrupt("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 _context9.stop();
346
+ return _context8.stop();
430
347
  }
431
- }, _callee9, this);
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 _callee10() {
442
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
443
- while (1) switch (_context10.prev = _context10.next) {
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
- _context10.next = 3;
363
+ _context9.next = 3;
447
364
  break;
448
365
  }
449
366
  alert(l10n.t('Kernel Connection 还没有建立'));
450
- return _context10.abrupt("return");
367
+ return _context9.abrupt("return");
451
368
  case 3:
452
- _context10.next = 5;
369
+ _context9.next = 5;
453
370
  return this.kernelConnection.reconnect();
454
371
  case 5:
455
372
  case "end":
456
- return _context10.stop();
373
+ return _context9.stop();
457
374
  }
458
- }, _callee10, this);
375
+ }, _callee9, this);
459
376
  }));
460
377
  function reconnect() {
461
378
  return _reconnect.apply(this, arguments);
@@ -1 +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;IAgBX,IAAa,aAAa,QAEzB;IACD,IAAa,SAAS,YAErB;IACD,IAAa,KAAK,YAEjB;CACF"}
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"}
@@ -48,9 +48,9 @@ export var JupyterWorkspaceService = (_dec = singleton({
48
48
  key: "onViewStart",
49
49
  value: function onViewStart() {
50
50
  var _this2 = this;
51
- var settings = _objectSpread({}, this.serverConnection.settings);
52
- var url = URL.join(settings.baseUrl, '/libro/api/workspace');
53
51
  this.serverManager.ready.then(function () {
52
+ var settings = _objectSpread({}, _this2.serverConnection.settings);
53
+ var url = URL.join(settings.baseUrl, '/libro/api/workspace');
54
54
  return _this2.serverConnection.makeRequest(url, {});
55
55
  }).then( /*#__PURE__*/function () {
56
56
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA+B/C,eAAO,MAAM,kBAAkB,YAwD5B,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";
@@ -28,7 +29,7 @@ import { LibroJupyterOutputArea } from "./output/index.js";
28
29
  import { PlotlyModule } from "./rendermime/index.js";
29
30
  import { LibroJupyterColorContribution } from "./theme/index.js";
30
31
  import { KernelStatusSelector, LibroJupyterToolbarContribution, SaveFileErrorContribution } from "./toolbar/index.js";
31
- export var LibroJupyterModule = ManaModule.create().register(JupyterWorkspaceService, 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, {
32
33
  token: CellExecutionTimeProvider,
33
34
  useValue: CellExecutionTip
34
35
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-jupyter",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
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.27",
35
- "@difizen/libro-code-editor": "^0.1.27",
36
- "@difizen/libro-code-cell": "^0.1.27",
37
- "@difizen/libro-codemirror": "^0.1.27",
38
- "@difizen/libro-rendermime": "^0.1.27",
39
- "@difizen/libro-common": "^0.1.27",
40
- "@difizen/libro-core": "^0.1.27",
41
- "@difizen/libro-kernel": "^0.1.27",
42
- "@difizen/libro-l10n": "^0.1.27",
43
- "@difizen/libro-output": "^0.1.27",
44
- "@difizen/libro-search": "^0.1.27",
45
- "@difizen/libro-search-code-cell": "^0.1.27",
46
- "@difizen/libro-lsp": "^0.1.27",
47
- "@difizen/libro-markdown-cell": "^0.1.27",
48
- "@difizen/libro-raw-cell": "^0.1.27",
49
- "@difizen/libro-language-client": "^0.1.27",
34
+ "@difizen/libro-cofine-editor": "^0.1.29",
35
+ "@difizen/libro-code-editor": "^0.1.29",
36
+ "@difizen/libro-code-cell": "^0.1.29",
37
+ "@difizen/libro-codemirror": "^0.1.29",
38
+ "@difizen/libro-rendermime": "^0.1.29",
39
+ "@difizen/libro-common": "^0.1.29",
40
+ "@difizen/libro-core": "^0.1.29",
41
+ "@difizen/libro-kernel": "^0.1.29",
42
+ "@difizen/libro-l10n": "^0.1.29",
43
+ "@difizen/libro-output": "^0.1.29",
44
+ "@difizen/libro-search": "^0.1.29",
45
+ "@difizen/libro-search-code-cell": "^0.1.29",
46
+ "@difizen/libro-lsp": "^0.1.29",
47
+ "@difizen/libro-markdown-cell": "^0.1.29",
48
+ "@difizen/libro-raw-cell": "^0.1.29",
49
+ "@difizen/libro-language-client": "^0.1.29",
50
50
  "@difizen/mana-app": "latest",
51
51
  "@difizen/mana-l10n": "latest",
52
52
  "@ant-design/colors": "^7.0.0",
@@ -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
+ }
@@ -1,4 +1,5 @@
1
1
  import type { ModalItemProps, ModalItem } from '@difizen/mana-app';
2
+ import { CommandRegistry } from '@difizen/mana-app';
2
3
  import { URI, useInject, ViewManager } from '@difizen/mana-app';
3
4
  import { Col, Form, message, Row, Input, Modal } from 'antd';
4
5
  import type { InputRef } from 'antd';
@@ -27,6 +28,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
27
28
  data,
28
29
  }: ModalItemProps<ModalItemType>) => {
29
30
  const fileService = useInject(JupyterFileService);
31
+ const commands = useInject(CommandRegistry);
30
32
  const viewManager = useInject(ViewManager);
31
33
  const [fileType, setFileType] = useState<FileType>(data?.fileType);
32
34
  const [fileView, setFileView] = useState<FileView>();
@@ -37,13 +39,20 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
37
39
  await form.validateFields();
38
40
  close();
39
41
  try {
40
- await fileService.newFile(
42
+ const stat = await fileService.newFile(
41
43
  values.fileName + (fileType || ''),
42
44
  new URI(data?.path),
43
45
  );
44
46
  if (fileView) {
45
47
  fileView.model.refresh();
46
48
  }
49
+ if (stat.isFile) {
50
+ commands.executeCommand('fileTree.command.openfile', {
51
+ fileStat: stat,
52
+ uri: stat.resource,
53
+ });
54
+ }
55
+ // message.success('新建文件成功');
47
56
  } catch {
48
57
  message.error('新建文件失败');
49
58
  }
@@ -205,7 +205,7 @@ export class JupyterFileService extends FileService {
205
205
  ext,
206
206
  });
207
207
  await this.rename(new URI(res.path.toString()), fileName);
208
- return this.resolve(target);
208
+ return this.resolve(targetFileUri);
209
209
  }
210
210
 
211
211
  async newFileDir(dirName: string, target: URI): Promise<FileStatWithMetadata> {
package/src/file/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from './file-protocol.js';
7
7
  export * from './file-icon.js';
8
8
  export * from './file-create-modal.js';
9
9
  export * from './file-createdir-modal.js';
10
+ export * from './file-command.js';
@@ -19,7 +19,6 @@ import {
19
19
  libroArgsMimetype,
20
20
  LibroFileService,
21
21
  } from './libro-jupyter-protocol.js';
22
- import { SaveFileErrorModal } from './toolbar/save-file-error.js';
23
22
  import { getDefaultKernel } from './utils/index.js';
24
23
 
25
24
  type IModel = IContentsModel;
@@ -175,61 +174,6 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
175
174
  .catch(console.error);
176
175
  }
177
176
 
178
- override async saveNotebookContent(): Promise<void> {
179
- const notebookContent = this.toJSON();
180
- if (!this.currentFileContents) {
181
- throw new Error('currentFileContents is undefined');
182
- }
183
-
184
- let res = {} as IModel | undefined;
185
-
186
- try {
187
- res = await this.libroFileService.write(
188
- notebookContent,
189
- this.currentFileContents,
190
- );
191
- if (!res) {
192
- return;
193
- }
194
- // 文件保存失败
195
- if (res.last_modified === this.last_modified || res.size === 0) {
196
- const errorMsg = `File Save Error: ${res?.message} `;
197
- this.libroFileService.fileSaveErrorEmitter.fire({
198
- cause: res.message,
199
- msg: errorMsg,
200
- name: res.name,
201
- path: res.path,
202
- created: res.created,
203
- last_modified: res.last_modified,
204
- size: res.size,
205
- type: res.type,
206
- });
207
- this.modalService.openModal(SaveFileErrorModal);
208
-
209
- throw new Error(errorMsg);
210
- }
211
- } catch (e: any) {
212
- if (!res) {
213
- return;
214
- }
215
- this.libroFileService.fileSaveErrorEmitter.fire({
216
- cause: e.errorCause,
217
- msg: e.message,
218
- name: res.name || this.currentFileContents.name,
219
- path: res.path || this.currentFileContents.path,
220
- created: res.created || this.currentFileContents.created,
221
- last_modified: res.last_modified || this.currentFileContents.last_modified,
222
- size: res.size || this.currentFileContents.size,
223
- type: res.type || this.currentFileContents.type,
224
- });
225
- this.modalService.openModal(SaveFileErrorModal);
226
-
227
- throw new Error('File Save Error');
228
- }
229
-
230
- await this.createCheckpoint();
231
- }
232
-
233
177
  override canRun() {
234
178
  if (!this.kernelConnection) {
235
179
  alert(l10n.t('Kernel Connection 还没有建立'));
@@ -20,10 +20,12 @@ export class JupyterWorkspaceService
20
20
  protected workspaceData: JupyterWorkspaceData;
21
21
 
22
22
  onViewStart() {
23
- const settings = { ...this.serverConnection.settings };
24
- const url = URL.join(settings.baseUrl, '/libro/api/workspace');
25
23
  this.serverManager.ready
26
- .then(() => this.serverConnection.makeRequest(url, {}))
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
+ })
27
29
  .then(async (res) => {
28
30
  const data = await res.json();
29
31
  this.workspaceData = data;
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';
@@ -67,6 +68,7 @@ export const LibroJupyterModule = ManaModule.create()
67
68
  SaveFileErrorContribution,
68
69
  LibroKeybindRegistry,
69
70
  LibroJupyterContentContribution,
71
+ LibroJupyterContentSaveContribution,
70
72
  LibroJupyterOutputArea,
71
73
  LibroJupyterColorContribution,
72
74
  LibroJupyterSettingContribution,