@difizen/libro-jupyter 0.0.2-alpha.0 → 0.1.1

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.
Files changed (103) hide show
  1. package/es/add-between-cell/add-between-cell-command-contribution.js +2 -2
  2. package/es/add-between-cell/add-between-cell.js +5 -5
  3. package/es/cell/jupyter-code-cell-model.js +1 -1
  4. package/es/cell/jupyter-code-cell-view.js +6 -6
  5. package/es/command/command-contribution.js +2 -2
  6. package/es/command/keybinding-contribution.js +1 -1
  7. package/es/components/index.less +1 -0
  8. package/es/config/config-contribution.js +1 -1
  9. package/es/configuration/libro-configuration-contribution.js +1 -1
  10. package/es/contents/content-contribution.js +2 -2
  11. package/es/file/file-command.d.ts +21 -0
  12. package/es/file/file-command.d.ts.map +1 -0
  13. package/es/file/file-command.js +469 -0
  14. package/es/file/file-create-modal-contribution.d.ts +5 -0
  15. package/es/file/file-create-modal-contribution.d.ts.map +1 -0
  16. package/es/file/file-create-modal-contribution.js +23 -0
  17. package/es/file/file-create-modal.d.ts +12 -0
  18. package/es/file/file-create-modal.d.ts.map +1 -0
  19. package/es/file/file-create-modal.js +223 -0
  20. package/es/file/file-createdir-modal-contribution.d.ts +5 -0
  21. package/es/file/file-createdir-modal-contribution.d.ts.map +1 -0
  22. package/es/file/file-createdir-modal-contribution.js +23 -0
  23. package/es/file/file-createdir-modal.d.ts +9 -0
  24. package/es/file/file-createdir-modal.d.ts.map +1 -0
  25. package/es/file/file-createdir-modal.js +168 -0
  26. package/es/file/file-icon.d.ts +11 -0
  27. package/es/file/file-icon.d.ts.map +1 -0
  28. package/es/file/file-icon.js +475 -0
  29. package/es/file/file-name-alias.js +1 -1
  30. package/es/file/file-protocol.d.ts +6 -0
  31. package/es/file/file-protocol.d.ts.map +1 -1
  32. package/es/file/file-protocol.js +7 -1
  33. package/es/file/file-rename-modal-contribution.d.ts +5 -0
  34. package/es/file/file-rename-modal-contribution.d.ts.map +1 -0
  35. package/es/file/file-rename-modal-contribution.js +23 -0
  36. package/es/file/file-rename-modal.d.ts +10 -0
  37. package/es/file/file-rename-modal.d.ts.map +1 -0
  38. package/es/file/file-rename-modal.js +150 -0
  39. package/es/file/file-service.d.ts +7 -3
  40. package/es/file/file-service.d.ts.map +1 -1
  41. package/es/file/file-service.js +155 -40
  42. package/es/file/file-tree-label-provider.js +1 -1
  43. package/es/file/file-view/index.d.ts +1 -1
  44. package/es/file/file-view/index.d.ts.map +1 -1
  45. package/es/file/file-view/index.js +7 -2
  46. package/es/file/index.d.ts +3 -0
  47. package/es/file/index.d.ts.map +1 -1
  48. package/es/file/index.js +4 -1
  49. package/es/file/index.less +98 -0
  50. package/es/file/module.d.ts.map +1 -1
  51. package/es/file/module.js +5 -1
  52. package/es/file/navigatable-view.d.ts +9 -3
  53. package/es/file/navigatable-view.d.ts.map +1 -1
  54. package/es/file/navigatable-view.js +46 -13
  55. package/es/file/open-handler-contribution.js +4 -4
  56. package/es/file/utils.d.ts +2 -0
  57. package/es/file/utils.d.ts.map +1 -0
  58. package/es/file/utils.js +43 -0
  59. package/es/index.d.ts +1 -0
  60. package/es/index.d.ts.map +1 -1
  61. package/es/index.js +1 -0
  62. package/es/keybind-instructions/keybind-instructions-contribution.js +2 -2
  63. package/es/keybind-instructions/keybind-instructions-items.js +1 -1
  64. package/es/keybind-instructions/keybind-instructions-view.js +2 -2
  65. package/es/libro-jupyter-file-service.js +3 -3
  66. package/es/libro-jupyter-model.js +2 -2
  67. package/es/libro-jupyter-protocol.d.ts +0 -4
  68. package/es/libro-jupyter-protocol.d.ts.map +1 -1
  69. package/es/libro-jupyter-protocol.js +1 -2
  70. package/es/libro-jupyter-server-launch-manager.d.ts +1 -3
  71. package/es/libro-jupyter-server-launch-manager.d.ts.map +1 -1
  72. package/es/libro-jupyter-server-launch-manager.js +4 -11
  73. package/es/libro-jupyter-view.js +1 -1
  74. package/es/output/libro-jupyter-outputarea.js +3 -3
  75. package/es/rendermime/index.less +1 -10
  76. package/es/rendermime/plotly-renderers.js +4 -4
  77. package/es/rendermime/plotly-rendermime-contribution.js +1 -1
  78. package/es/theme/color-registry.js +1 -1
  79. package/es/toolbar/kernel-selector-dropdown.js +3 -3
  80. package/es/toolbar/save-file-error-contribution.js +1 -1
  81. package/es/toolbar/toolbar-contribution.js +1 -1
  82. package/package.json +16 -16
  83. package/src/components/index.less +1 -0
  84. package/src/file/file-command.tsx +325 -0
  85. package/src/file/file-create-modal-contribution.ts +10 -0
  86. package/src/file/file-create-modal.tsx +176 -0
  87. package/src/file/file-createdir-modal-contribution.ts +10 -0
  88. package/src/file/file-createdir-modal.tsx +108 -0
  89. package/src/file/file-icon.tsx +502 -0
  90. package/src/file/file-protocol.ts +17 -0
  91. package/src/file/file-rename-modal-contribution.ts +10 -0
  92. package/src/file/file-rename-modal.tsx +103 -0
  93. package/src/file/file-service.ts +69 -33
  94. package/src/file/file-view/index.tsx +4 -1
  95. package/src/file/index.less +98 -0
  96. package/src/file/index.ts +3 -0
  97. package/src/file/module.ts +8 -0
  98. package/src/file/navigatable-view.tsx +39 -3
  99. package/src/file/utils.ts +51 -0
  100. package/src/index.spec.ts +11 -0
  101. package/src/index.ts +1 -0
  102. package/src/libro-jupyter-protocol.ts +0 -5
  103. package/src/libro-jupyter-server-launch-manager.ts +2 -11
@@ -1,4 +1,4 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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
2
  var _dec, _class;
3
3
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
4
  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); } }
@@ -5,4 +5,10 @@ export declare enum FileType {
5
5
  SymbolicLink = 64
6
6
  }
7
7
  export type DirItem = [string, FileType];
8
+ export interface EditorView {
9
+ dirty: boolean;
10
+ }
11
+ export declare const EditorView: {
12
+ is: (data?: Record<string, any>) => data is EditorView;
13
+ };
8
14
  //# sourceMappingURL=file-protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-protocol.d.ts","sourceRoot":"","sources":["../../src/file/file-protocol.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,IAAI,IAAI;IACR,SAAS,IAAI;IACb,YAAY,KAAK;CAClB;AACD,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"file-protocol.d.ts","sourceRoot":"","sources":["../../src/file/file-protocol.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,IAAI,IAAI;IACR,SAAS,IAAI;IACb,YAAY,KAAK;CAClB;AACD,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEzC,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,UAAU;gBACT,OAAO,MAAM,EAAE,GAAG,CAAC;CAUhC,CAAC"}
@@ -1,7 +1,13 @@
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); }
1
2
  export var FileType = /*#__PURE__*/function (FileType) {
2
3
  FileType[FileType["Unknown"] = 0] = "Unknown";
3
4
  FileType[FileType["File"] = 1] = "File";
4
5
  FileType[FileType["Directory"] = 2] = "Directory";
5
6
  FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
6
7
  return FileType;
7
- }({});
8
+ }({});
9
+ export var EditorView = {
10
+ is: function is(data) {
11
+ return !!data && _typeof(data) === 'object' && 'id' in data && 'view' in data && 'dirty' in data && typeof data['view'] === 'function';
12
+ }
13
+ };
@@ -0,0 +1,5 @@
1
+ import { ModalContribution } from '@difizen/mana-app';
2
+ export declare class FileRenameModalContribution implements ModalContribution {
3
+ registerModal(): import("@difizen/mana-app").ModalItem<import("./file-rename-modal.js").ModalItemType>;
4
+ }
5
+ //# sourceMappingURL=file-rename-modal-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-rename-modal-contribution.d.ts","sourceRoot":"","sources":["../../src/file/file-rename-modal-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAa,MAAM,mBAAmB,CAAC;AAIjE,qBACa,2BAA4B,YAAW,iBAAiB;IACnE,aAAa;CAGd"}
@@ -0,0 +1,23 @@
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, _class;
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+ 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); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ import { ModalContribution, singleton } from '@difizen/mana-app';
9
+ import { FileRenameModal } from "./file-rename-modal.js";
10
+ export var FileRenameModalContribution = (_dec = singleton({
11
+ contrib: ModalContribution
12
+ }), _dec(_class = /*#__PURE__*/function () {
13
+ function FileRenameModalContribution() {
14
+ _classCallCheck(this, FileRenameModalContribution);
15
+ }
16
+ _createClass(FileRenameModalContribution, [{
17
+ key: "registerModal",
18
+ value: function registerModal() {
19
+ return FileRenameModal;
20
+ }
21
+ }]);
22
+ return FileRenameModalContribution;
23
+ }()) || _class);
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import type { ModalItem, ModalItemProps, URI } from '@difizen/mana-app';
3
+ import './index.less';
4
+ export interface ModalItemType {
5
+ resource: URI;
6
+ fileName: string;
7
+ }
8
+ export declare const FileRenameModalComponent: React.FC<ModalItemProps<ModalItemType>>;
9
+ export declare const FileRenameModal: ModalItem<ModalItemType>;
10
+ //# sourceMappingURL=file-rename-modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-rename-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-rename-modal.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAOxE,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAkF5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
@@ -0,0 +1,150 @@
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
+ 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; }
3
+ 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); } }
4
+ 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); }); }; }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import { useInject, ViewManager } from '@difizen/mana-app';
12
+ import { Form, message, Input, Modal } from 'antd';
13
+ import { useEffect, useRef, useState } from 'react';
14
+ import { JupyterFileService } from "./file-service.js";
15
+ import { FileView } from "./file-view/index.js";
16
+ import "./index.less";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ export var FileRenameModalComponent = function FileRenameModalComponent(_ref) {
19
+ var visible = _ref.visible,
20
+ close = _ref.close,
21
+ data = _ref.data;
22
+ var fileService = useInject(JupyterFileService);
23
+ var viewManager = useInject(ViewManager);
24
+ var inputRef = useRef(null);
25
+ var _Form$useForm = Form.useForm(),
26
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
27
+ form = _Form$useForm2[0];
28
+ var _useState = useState(),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ fileView = _useState2[0],
31
+ setFileView = _useState2[1];
32
+ useEffect(function () {
33
+ var _inputRef$current;
34
+ viewManager.getOrCreateView(FileView).then(function (view) {
35
+ setFileView(view);
36
+ return;
37
+ }).catch(function () {
38
+ //
39
+ });
40
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
41
+ });
42
+ var onFinish = /*#__PURE__*/function () {
43
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
44
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
45
+ while (1) switch (_context.prev = _context.next) {
46
+ case 0:
47
+ _context.next = 2;
48
+ return form.validateFields();
49
+ case 2:
50
+ close();
51
+ _context.prev = 3;
52
+ _context.next = 6;
53
+ return fileService.rename(data.resource, values.rename);
54
+ case 6:
55
+ if (fileView) {
56
+ fileView.model.refresh();
57
+ }
58
+ _context.next = 12;
59
+ break;
60
+ case 9:
61
+ _context.prev = 9;
62
+ _context.t0 = _context["catch"](3);
63
+ message.error('重命名文件/文件夹失败');
64
+ case 12:
65
+ case "end":
66
+ return _context.stop();
67
+ }
68
+ }, _callee, null, [[3, 9]]);
69
+ }));
70
+ return function onFinish(_x) {
71
+ return _ref2.apply(this, arguments);
72
+ };
73
+ }();
74
+ var validateRename = /*#__PURE__*/function () {
75
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(rule, value, callback) {
76
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
77
+ while (1) switch (_context2.prev = _context2.next) {
78
+ case 0:
79
+ if (!(!value || !value.length)) {
80
+ _context2.next = 4;
81
+ break;
82
+ }
83
+ throw new Error('请输入文件夹名');
84
+ case 4:
85
+ if (!(value === data.fileName)) {
86
+ _context2.next = 6;
87
+ break;
88
+ }
89
+ throw new Error('文件/文件夹名称已存在,请重新输入');
90
+ case 6:
91
+ case "end":
92
+ return _context2.stop();
93
+ }
94
+ }, _callee2);
95
+ }));
96
+ return function validateRename(_x2, _x3, _x4) {
97
+ return _ref3.apply(this, arguments);
98
+ };
99
+ }();
100
+ return /*#__PURE__*/_jsx(Modal, {
101
+ title: "\u6587\u4EF6\u91CD\u547D\u540D",
102
+ open: visible,
103
+ onCancel: close,
104
+ onOk: function onOk() {
105
+ form.submit();
106
+ },
107
+ wrapClassName: "libro-rename-file-modal",
108
+ children: /*#__PURE__*/_jsx(Form, {
109
+ layout: "vertical",
110
+ autoComplete: "off",
111
+ form: form,
112
+ onFinish: onFinish,
113
+ className: "libro-rename-file-form",
114
+ children: /*#__PURE__*/_jsx(Form.Item, {
115
+ name: "rename",
116
+ label: "\u6587\u4EF6/\u6587\u4EF6\u5939\u540D\u79F0",
117
+ rules: [{
118
+ required: true,
119
+ validator: validateRename
120
+ }],
121
+ initialValue: data.fileName,
122
+ children: /*#__PURE__*/_jsx(Input, {
123
+ ref: inputRef,
124
+ onKeyDown: /*#__PURE__*/function () {
125
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e) {
126
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
127
+ while (1) switch (_context3.prev = _context3.next) {
128
+ case 0:
129
+ if (e.keyCode === 13) {
130
+ form.submit();
131
+ }
132
+ case 1:
133
+ case "end":
134
+ return _context3.stop();
135
+ }
136
+ }, _callee3);
137
+ }));
138
+ return function (_x5) {
139
+ return _ref4.apply(this, arguments);
140
+ };
141
+ }()
142
+ })
143
+ })
144
+ })
145
+ });
146
+ };
147
+ export var FileRenameModal = {
148
+ id: 'file.rename.modal',
149
+ component: FileRenameModalComponent
150
+ };
@@ -22,10 +22,14 @@ export declare class JupyterFileService extends FileService {
22
22
  protected doResolve(filePath: string): Promise<FileMeta | undefined>;
23
23
  protected isDirectory(model: IContentsModel): model is DirectoryModel;
24
24
  protected toFileMeta(model: IContentsModel): FileMeta;
25
- copy(source: URI, target: URI, options?: CopyFileOptions): Promise<FileStatWithMetadata>;
26
- move(source: URI, target: URI, options?: MoveFileOptions): Promise<FileStatWithMetadata>;
25
+ copy(source: URI, _target: URI, _options?: CopyFileOptions): Promise<FileStatWithMetadata>;
26
+ move(source: URI, _target: URI, _options?: MoveFileOptions): Promise<FileStatWithMetadata>;
27
27
  toFileStatMeta(meta: FileMeta): FileStatWithMetadata;
28
- resolve(resource: URI, options?: ResolveFileOptions | undefined): Promise<FileStatWithMetadata>;
28
+ resolve(resource: URI, _options?: ResolveFileOptions | undefined): Promise<FileStatWithMetadata>;
29
+ delete(resource: URI, _options?: ResolveFileOptions | undefined): Promise<FileStatWithMetadata>;
30
+ rename(resource: URI, newName: string): Promise<FileStatWithMetadata>;
31
+ newFile(fileName: string, target: URI): Promise<FileStatWithMetadata>;
32
+ newFileDir(dirName: string, target: URI): Promise<FileStatWithMetadata>;
29
33
  }
30
34
  export {};
31
35
  //# sourceMappingURL=file-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-service.d.ts","sourceRoot":"","sources":["../../src/file/file-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,GAAG,EAAqB,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,UAAU,QAAS,SAAQ,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,UAAU,CAAC;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,UAAU,cAAe,SAAQ,cAAc;IAC7C,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED,qBACa,kBAAmB,SAAQ,WAAW;IACxB,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAe7E,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;gBAIrC,aAAa,EAAE,aAAa;IAOxB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAYrE,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,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