@difizen/libro-lab 0.1.5 → 0.1.7

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 (37) hide show
  1. package/es/editor-viewer/code-editor-open-handler.d.ts +12 -0
  2. package/es/editor-viewer/code-editor-open-handler.d.ts.map +1 -0
  3. package/es/editor-viewer/code-editor-open-handler.js +101 -0
  4. package/es/editor-viewer/code-editor-viewer.d.ts +38 -0
  5. package/es/editor-viewer/code-editor-viewer.d.ts.map +1 -0
  6. package/es/editor-viewer/code-editor-viewer.js +235 -0
  7. package/es/editor-viewer/index.d.ts +3 -0
  8. package/es/editor-viewer/index.d.ts.map +1 -0
  9. package/es/editor-viewer/index.js +2 -0
  10. package/es/editor-viewer/index.less +3 -0
  11. package/es/editor-viewer/module.d.ts +3 -0
  12. package/es/editor-viewer/module.d.ts.map +1 -0
  13. package/es/editor-viewer/module.js +4 -0
  14. package/es/editor-viewer/protocol.d.ts +7 -0
  15. package/es/editor-viewer/protocol.d.ts.map +1 -0
  16. package/es/editor-viewer/protocol.js +1 -0
  17. package/es/index.d.ts +1 -0
  18. package/es/index.d.ts.map +1 -1
  19. package/es/index.js +2 -1
  20. package/es/layout/side-tab-view.d.ts +5 -0
  21. package/es/layout/side-tab-view.d.ts.map +1 -0
  22. package/es/layout/side-tab-view.js +35 -0
  23. package/es/module.d.ts.map +1 -1
  24. package/es/module.js +19 -14
  25. package/es/welcome/entry-point-view.d.ts.map +1 -1
  26. package/es/welcome/entry-point-view.js +6 -1
  27. package/package.json +8 -7
  28. package/src/editor-viewer/code-editor-open-handler.ts +42 -0
  29. package/src/editor-viewer/code-editor-viewer.tsx +183 -0
  30. package/src/editor-viewer/index.less +3 -0
  31. package/src/editor-viewer/index.ts +2 -0
  32. package/src/editor-viewer/module.ts +8 -0
  33. package/src/editor-viewer/protocol.ts +7 -0
  34. package/src/index.ts +1 -0
  35. package/src/layout/side-tab-view.tsx +11 -0
  36. package/src/module.tsx +16 -13
  37. package/src/welcome/entry-point-view.tsx +9 -1
@@ -0,0 +1,12 @@
1
+ import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
2
+ import { ConfigurationService } from '@difizen/mana-app';
3
+ import { Priority } from '@difizen/mana-app';
4
+ import { NavigatableViewOpenHandler } from '@difizen/mana-app';
5
+ import type { CodeEditorViewer } from './code-editor-viewer.js';
6
+ export declare class CodeEditorViewerOpenHandler extends NavigatableViewOpenHandler<CodeEditorViewer> {
7
+ protected configurationService: ConfigurationService;
8
+ id: string;
9
+ canHandle(uri: URI, options?: ViewOpenHandlerOptions): 100 | Priority.IDLE;
10
+ open(uri: URI, options?: ViewOpenHandlerOptions): Promise<CodeEditorViewer>;
11
+ }
12
+ //# sourceMappingURL=code-editor-open-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-editor-open-handler.d.ts","sourceRoot":"","sources":["../../src/editor-viewer/code-editor-open-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAU,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAA0B,MAAM,mBAAmB,CAAC;AAEvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,qBACa,2BAA4B,SAAQ,0BAA0B,CAAC,gBAAgB,CAAC;IAC7D,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAEnF,EAAE,SAA2B;IAE7B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAUrC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,sBAA2B;CAgBnE"}
@@ -0,0 +1,101 @@
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 _excluded = ["viewOptions"];
3
+ var _dec, _dec2, _class, _class2, _descriptor;
4
+ 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; }
5
+ 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; }
6
+ 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; }
7
+ 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; }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+ 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); } }
11
+ 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); }); }; }
12
+ 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 }); }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ 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); } }
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
+ 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); }
18
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
19
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
20
+ 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); }
21
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
+ 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); }; }
23
+ 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); }
24
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
+ 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; } }
26
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
+ 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; }
28
+ 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.'); }
29
+ import { LibroJupyterConfiguration } from '@difizen/libro-jupyter';
30
+ import { ConfigurationService, inject } from '@difizen/mana-app';
31
+ import { Priority } from '@difizen/mana-app';
32
+ import { NavigatableViewOpenHandler, OpenHandler, singleton } from '@difizen/mana-app';
33
+ import { CodeEditorViewerFactory } from "./protocol.js";
34
+ export var CodeEditorViewerOpenHandler = (_dec = singleton({
35
+ contrib: OpenHandler
36
+ }), _dec2 = inject(ConfigurationService), _dec(_class = (_class2 = /*#__PURE__*/function (_NavigatableViewOpenH) {
37
+ _inherits(CodeEditorViewerOpenHandler, _NavigatableViewOpenH);
38
+ var _super = _createSuper(CodeEditorViewerOpenHandler);
39
+ function CodeEditorViewerOpenHandler() {
40
+ var _this;
41
+ _classCallCheck(this, CodeEditorViewerOpenHandler);
42
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
+ args[_key] = arguments[_key];
44
+ }
45
+ _this = _super.call.apply(_super, [this].concat(args));
46
+ _initializerDefineProperty(_this, "configurationService", _descriptor, _assertThisInitialized(_this));
47
+ _this.id = CodeEditorViewerFactory;
48
+ return _this;
49
+ }
50
+ _createClass(CodeEditorViewerOpenHandler, [{
51
+ key: "canHandle",
52
+ value: function canHandle(uri, options) {
53
+ if (uri.scheme === 'file' && !['.tar', '.zip', '.7z', '.gz', 'rar'].includes(uri.path.ext)) {
54
+ return 100;
55
+ }
56
+ return Priority.IDLE;
57
+ }
58
+ }, {
59
+ key: "open",
60
+ value: function () {
61
+ var _open = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(uri) {
62
+ var options,
63
+ viewOptions,
64
+ extra,
65
+ slot,
66
+ _args = arguments;
67
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
71
+ viewOptions = options.viewOptions, extra = _objectWithoutProperties(options, _excluded);
72
+ _context.next = 4;
73
+ return this.configurationService.get(LibroJupyterConfiguration['OpenSlot']);
74
+ case 4:
75
+ slot = _context.sent;
76
+ return _context.abrupt("return", _get(_getPrototypeOf(CodeEditorViewerOpenHandler.prototype), "open", this).call(this, uri, _objectSpread({
77
+ slot: slot,
78
+ viewOptions: _objectSpread({
79
+ path: uri.path.toString()
80
+ }, viewOptions),
81
+ reveal: true
82
+ }, extra)));
83
+ case 6:
84
+ case "end":
85
+ return _context.stop();
86
+ }
87
+ }, _callee, this);
88
+ }));
89
+ function open(_x) {
90
+ return _open.apply(this, arguments);
91
+ }
92
+ return open;
93
+ }()
94
+ }]);
95
+ return CodeEditorViewerOpenHandler;
96
+ }(NavigatableViewOpenHandler), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec2], {
97
+ configurable: true,
98
+ enumerable: true,
99
+ writable: true,
100
+ initializer: null
101
+ })), _class2)) || _class);
@@ -0,0 +1,38 @@
1
+ import { EditorProvider } from '@difizen/libro-cofine-editor-core';
2
+ import type { LanguageSpec } from '@difizen/libro-jupyter';
3
+ import { JupyterFileService, LanguageSpecRegistry } from '@difizen/libro-jupyter';
4
+ import type { NavigatableView, Saveable } from '@difizen/mana-app';
5
+ import { ConfigurationService } from '@difizen/mana-app';
6
+ import { DisposableCollection, Emitter, LabelProvider, URI } from '@difizen/mana-app';
7
+ import { BaseView } from '@difizen/mana-app';
8
+ import React from 'react';
9
+ import './index.less';
10
+ import type { EditorOption } from './protocol.js';
11
+ type EditorType = ReturnType<EditorProvider['create']>;
12
+ export declare const LibroLabE2URIScheme = "libro-lab-e2";
13
+ export declare class CodeEditorViewer extends BaseView implements NavigatableView, Saveable {
14
+ view: React.FC<{}>;
15
+ codeRef: React.RefObject<HTMLDivElement>;
16
+ protected e2Editor?: EditorType;
17
+ dirty: boolean;
18
+ language: string;
19
+ value: string;
20
+ filePath?: string;
21
+ autoSaveDelay: number;
22
+ dirtyEmitter: Emitter<void>;
23
+ languageSpecRegistry: LanguageSpecRegistry;
24
+ get onDirtyChanged(): import("@difizen/mana-app").Event<void>;
25
+ autoSave: 'on' | 'off';
26
+ protected readonly toDisposeOnAutoSave: DisposableCollection;
27
+ languageSpec?: LanguageSpec;
28
+ fileService: JupyterFileService;
29
+ constructor(options: EditorOption, labelProvider: LabelProvider, fileService: JupyterFileService, languageSpecRegistry: LanguageSpecRegistry, configurationService: ConfigurationService);
30
+ onViewMount(): Promise<void>;
31
+ protected doAutoSave: () => void;
32
+ save: () => Promise<void>;
33
+ getResourceUri(): URI | undefined;
34
+ createMoveToUri(resourceUri: URI): URI | undefined;
35
+ dispose(): void;
36
+ }
37
+ export {};
38
+ //# sourceMappingURL=code-editor-viewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-editor-viewer.d.ts","sourceRoot":"","sources":["../../src/editor-viewer/code-editor-viewer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAqB,MAAM,mCAAmC,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,wBAAwB,CAAC;AAGhF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EACL,oBAAoB,EACpB,OAAO,EAGP,aAAa,EAEb,GAAG,EAGJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAA4C,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAQlD,KAAK,UAAU,GAAG,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvD,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAElD,qBAEa,gBAAiB,SAAQ,QAAS,YAAW,eAAe,EAAE,QAAQ;IACxE,IAAI,eAAmB;IAEhC,OAAO,kCAAqC;IAE5C,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAGhC,KAAK,UAAS;IAEd,QAAQ,SAAU;IAElB,KAAK,EAAE,MAAM,CAAC;IAEN,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE1B,aAAa,SAAQ;IAErB,YAAY,gBAAuB;IAEnC,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C,IAAI,cAAc,4CAEjB;IAED,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAS;IAE/B,SAAS,CAAC,QAAQ,CAAC,mBAAmB,uBAA8B;IAEpE,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B,WAAW,EAAE,kBAAkB,CAAC;gBAI9B,OAAO,EAAE,YAAY,EACE,aAAa,EAAE,aAAa,EACvB,WAAW,EAAE,kBAAkB,EAE3D,oBAAoB,EAAE,oBAAoB,EACZ,oBAAoB,EAAE,oBAAoB;IA+B3D,WAAW;IA2C1B,SAAS,CAAC,UAAU,aASlB;IAEF,IAAI,sBAIF;IAEF,cAAc,IAAI,GAAG,GAAG,SAAS;IAIjC,eAAe,CAAC,WAAW,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS;IAKzC,OAAO,IAAI,IAAI;CAKzB"}
@@ -0,0 +1,235 @@
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, _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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ 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); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ 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); }
12
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
13
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
14
+ 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); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ 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); }; }
17
+ 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); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ 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; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ 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; }
22
+ 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.'); }
23
+ import { EditorProvider, MonacoEnvironment } from '@difizen/libro-cofine-editor-core';
24
+ import { LibroConfigAutoSave } from '@difizen/libro-jupyter';
25
+ import { MonacoUri } from '@difizen/libro-jupyter';
26
+ import { JupyterFileService, LanguageSpecRegistry } from '@difizen/libro-jupyter';
27
+ import { ConfigurationService } from '@difizen/mana-app';
28
+ import { Disposable } from '@difizen/mana-app';
29
+ import { DisposableCollection, Emitter, getOrigin, inject, LabelProvider, prop, URI, URIIconReference, ViewOption } from '@difizen/mana-app';
30
+ import { BaseView, transient, useInject, view, ViewInstance } from '@difizen/mana-app';
31
+ import React from 'react';
32
+ import "./index.less";
33
+ import { CodeEditorViewerFactory } from "./protocol.js";
34
+ import { jsx as _jsx } from "react/jsx-runtime";
35
+ var EditorComponent = function EditorComponent() {
36
+ var viewInstance = useInject(ViewInstance);
37
+ return /*#__PURE__*/_jsx("div", {
38
+ className: "libro-lab-editor-viewer",
39
+ ref: viewInstance.codeRef
40
+ });
41
+ };
42
+ export var LibroLabE2URIScheme = 'libro-lab-e2';
43
+ export var CodeEditorViewer = (_dec = transient(), _dec2 = view(CodeEditorViewerFactory), _dec3 = prop(), _dec4 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
44
+ _inherits(CodeEditorViewer, _BaseView);
45
+ var _super = _createSuper(CodeEditorViewer);
46
+ function CodeEditorViewer(options, labelProvider, fileService, languageSpecRegistry, configurationService) {
47
+ var _this;
48
+ _classCallCheck(this, CodeEditorViewer);
49
+ _this = _super.call(this);
50
+ _this.view = EditorComponent;
51
+ _this.codeRef = /*#__PURE__*/React.createRef();
52
+ _initializerDefineProperty(_this, "dirty", _descriptor, _assertThisInitialized(_this));
53
+ _this.language = 'text';
54
+ _initializerDefineProperty(_this, "filePath", _descriptor2, _assertThisInitialized(_this));
55
+ _this.autoSaveDelay = 1000;
56
+ _this.dirtyEmitter = new Emitter();
57
+ _this.autoSave = 'off';
58
+ _this.toDisposeOnAutoSave = new DisposableCollection();
59
+ _this.doAutoSave = function () {
60
+ _this.toDisposeOnAutoSave.dispose();
61
+ if (!_this.e2Editor) {
62
+ return;
63
+ }
64
+ var handle = window.setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
65
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
66
+ while (1) switch (_context.prev = _context.next) {
67
+ case 0:
68
+ _this.save();
69
+ case 1:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }, _callee);
74
+ })), _this.autoSaveDelay);
75
+ _this.toDisposeOnAutoSave.push(Disposable.create(function () {
76
+ return window.clearTimeout(handle);
77
+ }));
78
+ };
79
+ _this.save = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
80
+ var _this$e2Editor;
81
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
82
+ while (1) switch (_context2.prev = _context2.next) {
83
+ case 0:
84
+ _this.value = ((_this$e2Editor = _this.e2Editor) === null || _this$e2Editor === void 0 ? void 0 : _this$e2Editor.codeEditor.getValue()) || '';
85
+ _context2.next = 3;
86
+ return _this.fileService.write(_this.filePath, _this.value);
87
+ case 3:
88
+ _this.dirty = false;
89
+ case 4:
90
+ case "end":
91
+ return _context2.stop();
92
+ }
93
+ }, _callee2);
94
+ }));
95
+ _this.filePath = options.path;
96
+ _this.title.caption = options.path;
97
+ var uri = new URI(options.path);
98
+ var uriRef = URIIconReference.create('file', new URI(options.path));
99
+ var iconClass = labelProvider.getIcon(uriRef);
100
+ _this.fileService = fileService;
101
+ _this.title.icon = /*#__PURE__*/_jsx("div", {
102
+ className: iconClass
103
+ });
104
+ _this.title.label = uri.path.base;
105
+ _this.languageSpecRegistry = languageSpecRegistry;
106
+ _this.languageSpec = _this.languageSpecRegistry.languageSpecs.find(function (item) {
107
+ return item.ext.includes(uri.path.ext);
108
+ });
109
+ configurationService.get(LibroConfigAutoSave).then(function (value) {
110
+ if (value) {
111
+ _this.autoSave = 'on';
112
+ return;
113
+ } else {
114
+ _this.autoSave = 'off';
115
+ return;
116
+ }
117
+ }).catch(function () {
118
+ //
119
+ });
120
+ return _this;
121
+ }
122
+ CodeEditorViewer = inject(ConfigurationService)(CodeEditorViewer, undefined, 4) || CodeEditorViewer;
123
+ CodeEditorViewer = inject(LanguageSpecRegistry)(CodeEditorViewer, undefined, 3) || CodeEditorViewer;
124
+ CodeEditorViewer = inject(JupyterFileService)(CodeEditorViewer, undefined, 2) || CodeEditorViewer;
125
+ CodeEditorViewer = inject(LabelProvider)(CodeEditorViewer, undefined, 1) || CodeEditorViewer;
126
+ CodeEditorViewer = inject(ViewOption)(CodeEditorViewer, undefined, 0) || CodeEditorViewer;
127
+ _createClass(CodeEditorViewer, [{
128
+ key: "onDirtyChanged",
129
+ get: function get() {
130
+ return this.dirtyEmitter.event;
131
+ }
132
+ }, {
133
+ key: "onViewMount",
134
+ value: function () {
135
+ var _onViewMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
136
+ var _this$languageSpec$be,
137
+ _this$languageSpec,
138
+ _this2 = this;
139
+ var content, editorPorvider, uri, options;
140
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
141
+ while (1) switch (_context3.prev = _context3.next) {
142
+ case 0:
143
+ if (this.filePath) {
144
+ _context3.next = 2;
145
+ break;
146
+ }
147
+ return _context3.abrupt("return");
148
+ case 2:
149
+ _context3.next = 4;
150
+ return getOrigin(this.fileService).read(this.filePath);
151
+ case 4:
152
+ content = _context3.sent;
153
+ if (!(typeof content !== 'string' || !this.languageSpec)) {
154
+ _context3.next = 7;
155
+ break;
156
+ }
157
+ return _context3.abrupt("return");
158
+ case 7:
159
+ if (!(!this.codeRef || !this.codeRef.current)) {
160
+ _context3.next = 9;
161
+ break;
162
+ }
163
+ return _context3.abrupt("return");
164
+ case 9:
165
+ _context3.next = 11;
166
+ return MonacoEnvironment.init();
167
+ case 11:
168
+ _context3.next = 13;
169
+ return (_this$languageSpec$be = (_this$languageSpec = this.languageSpec).beforeEditorInit) === null || _this$languageSpec$be === void 0 ? void 0 : _this$languageSpec$be.call(_this$languageSpec);
170
+ case 13:
171
+ editorPorvider = MonacoEnvironment.container.get(EditorProvider);
172
+ uri = MonacoUri.from({
173
+ scheme: LibroLabE2URIScheme,
174
+ path: "".concat(this.filePath).concat(this.languageSpec.ext[0])
175
+ });
176
+ options = {
177
+ /**
178
+ * language ia an uri:
179
+ */
180
+ theme: 'libro-light',
181
+ language: this.languageSpec.language,
182
+ uri: uri,
183
+ value: content
184
+ };
185
+ this.e2Editor = editorPorvider.create(this.codeRef.current, options);
186
+ this.toDispose.push(getOrigin(this.e2Editor.codeEditor).onDidChangeModelContent(function () {
187
+ _this2.dirty = true;
188
+ if (_this2.autoSave === 'on') {
189
+ _this2.doAutoSave();
190
+ }
191
+ }));
192
+ case 18:
193
+ case "end":
194
+ return _context3.stop();
195
+ }
196
+ }, _callee3, this);
197
+ }));
198
+ function onViewMount() {
199
+ return _onViewMount.apply(this, arguments);
200
+ }
201
+ return onViewMount;
202
+ }()
203
+ }, {
204
+ key: "getResourceUri",
205
+ value: function getResourceUri() {
206
+ return new URI(this.filePath);
207
+ }
208
+ }, {
209
+ key: "createMoveToUri",
210
+ value: function createMoveToUri(resourceUri) {
211
+ this.filePath = resourceUri.path.toString();
212
+ return resourceUri;
213
+ }
214
+ }, {
215
+ key: "dispose",
216
+ value: function dispose() {
217
+ this.toDispose.dispose();
218
+ this.toDisposeOnAutoSave.dispose();
219
+ _get(_getPrototypeOf(CodeEditorViewer.prototype), "dispose", this).call(this);
220
+ }
221
+ }]);
222
+ return CodeEditorViewer;
223
+ }(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "dirty", [_dec3], {
224
+ configurable: true,
225
+ enumerable: true,
226
+ writable: true,
227
+ initializer: function initializer() {
228
+ return false;
229
+ }
230
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "filePath", [_dec4], {
231
+ configurable: true,
232
+ enumerable: true,
233
+ writable: true,
234
+ initializer: null
235
+ })), _class2)) || _class) || _class);
@@ -0,0 +1,3 @@
1
+ export * from './module.js';
2
+ export * from './code-editor-viewer.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editor-viewer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./module.js";
2
+ export * from "./code-editor-viewer.js";
@@ -0,0 +1,3 @@
1
+ .libro-lab-editor-viewer {
2
+ height: 100%;
3
+ }
@@ -0,0 +1,3 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ export declare const CodeEditorViewerModule: ManaModule;
3
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/editor-viewer/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,sBAAsB,YAEsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ import { CodeEditorViewerOpenHandler } from "./code-editor-open-handler.js";
3
+ import { CodeEditorViewer } from "./code-editor-viewer.js";
4
+ export var CodeEditorViewerModule = ManaModule.create('CodeEditorViewerModule').register(CodeEditorViewer, CodeEditorViewerOpenHandler);
@@ -0,0 +1,7 @@
1
+ export declare const CodeEditorViewerFactory = "libro-lab-editor-viewer";
2
+ export interface EditorOption {
3
+ path: string;
4
+ loadType?: string;
5
+ name?: string;
6
+ }
7
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/editor-viewer/protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1 @@
1
+ export var CodeEditorViewerFactory = 'libro-lab-editor-viewer';
package/es/index.d.ts CHANGED
@@ -9,4 +9,5 @@ export * from './welcome/index.js';
9
9
  export * from './kernel-manager/index.js';
10
10
  export * from './common/index.js';
11
11
  export * from './image-viewer/index.js';
12
+ export * from './editor-viewer/index.js';
12
13
  //# sourceMappingURL=index.d.ts.map
package/es/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC"}
package/es/index.js CHANGED
@@ -8,4 +8,5 @@ export * from "./toc/index.js";
8
8
  export * from "./welcome/index.js";
9
9
  export * from "./kernel-manager/index.js";
10
10
  export * from "./common/index.js";
11
- export * from "./image-viewer/index.js";
11
+ export * from "./image-viewer/index.js";
12
+ export * from "./editor-viewer/index.js";
@@ -0,0 +1,5 @@
1
+ import { SideTabView } from '@difizen/mana-app';
2
+ export declare class LibroLabSideTabView extends SideTabView {
3
+ renderTabToolbar(): JSX.Element;
4
+ }
5
+ //# sourceMappingURL=side-tab-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"side-tab-view.d.ts","sourceRoot":"","sources":["../../src/layout/side-tab-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAI/D,qBAEa,mBAAoB,SAAQ,WAAW;IACzC,gBAAgB,IAAI,GAAG,CAAC,OAAO;CAGzC"}
@@ -0,0 +1,35 @@
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;
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
+ 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); }
9
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10
+ 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); }; }
11
+ 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); }
12
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
+ 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; } }
14
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
+ import { SideTabView, ToolbarRender } from '@difizen/mana-app';
16
+ import { view } from '@difizen/mana-app';
17
+ import { transient } from '@difizen/mana-app';
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ export var LibroLabSideTabView = (_dec = transient(), _dec2 = view('libro-lab-side-tab'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_SideTabView) {
20
+ _inherits(LibroLabSideTabView, _SideTabView);
21
+ var _super = _createSuper(LibroLabSideTabView);
22
+ function LibroLabSideTabView() {
23
+ _classCallCheck(this, LibroLabSideTabView);
24
+ return _super.apply(this, arguments);
25
+ }
26
+ _createClass(LibroLabSideTabView, [{
27
+ key: "renderTabToolbar",
28
+ value: function renderTabToolbar() {
29
+ return /*#__PURE__*/_jsx(ToolbarRender, {
30
+ data: [this]
31
+ });
32
+ }
33
+ }]);
34
+ return LibroLabSideTabView;
35
+ }(SideTabView)) || _class) || _class);
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EAMX,MAAM,mBAAmB,CAAC;AAc3B,OAAO,cAAc,CAAC;AAMtB,eAAO,MAAM,cAAc,YAwExB,CAAC"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EAKX,MAAM,mBAAmB,CAAC;AAe3B,OAAO,cAAc,CAAC;AAOtB,eAAO,MAAM,cAAc,YA0ExB,CAAC"}
package/es/module.js CHANGED
@@ -1,36 +1,41 @@
1
1
  import { FileView, LibroJupyterModule } from '@difizen/libro-jupyter';
2
2
  import { LibroPromptCellModule } from '@difizen/libro-prompt-cell';
3
3
  import { TerminalModule } from '@difizen/libro-terminal';
4
- import { ManaModule, createSlotPreference, RootSlotId, SideTabView, createViewPreference, HeaderArea } from '@difizen/mana-app';
4
+ import { ManaModule, createSlotPreference, RootSlotId, createViewPreference, HeaderArea } from '@difizen/mana-app';
5
5
  import { LabConfigAppContribution } from "./config/config-contribution.js";
6
+ import { CodeEditorViewerModule } from "./editor-viewer/index.js";
6
7
  import { GithubLinkView } from "./github-link/index.js";
7
8
  import { ImageViewerModule } from "./image-viewer/index.js";
8
- import { KernelManagerView } from "./kernel-manager/index.js";
9
+ // import { KernelManagerView } from './kernel-manager/index.js';
9
10
  import { LibroLabApp } from "./lab-app.js";
10
11
  import { ContentBottomTabView } from "./layout/content-bottom-tab-view.js";
11
12
  import { LibroLabLayoutModule, LibroLabLayoutSlots, LibroLabLayoutView } from "./layout/index.js";
12
13
  import { SaveableTabView } from "./layout/saveable-tab-view.js";
13
14
  import "./index.less";
15
+ import { LibroLabSideTabView } from "./layout/side-tab-view.js";
14
16
  import { LibroLabHeaderMenuModule } from "./menu/module.js";
15
17
  import { LibroLabTocModule } from "./toc/module.js";
16
18
  import { EntryPointView } from "./welcome/entry-point-view.js";
17
19
  import { WelcomeView } from "./welcome/index.js";
18
- export var LibroLabModule = ManaModule.create().register(LibroLabApp, LibroLabLayoutView, GithubLinkView, LabConfigAppContribution, createViewPreference({
20
+ export var LibroLabModule = ManaModule.create().register(LibroLabApp, LibroLabLayoutView, GithubLinkView, LabConfigAppContribution, LibroLabSideTabView, createViewPreference({
19
21
  view: GithubLinkView,
20
22
  slot: HeaderArea.right,
21
23
  openOptions: {
22
24
  order: 'github'
23
25
  },
24
26
  autoCreate: true
25
- }), KernelManagerView, createViewPreference({
26
- view: KernelManagerView,
27
- slot: LibroLabLayoutSlots.navigator,
28
- openOptions: {
29
- reveal: false,
30
- order: 'kernel-manager'
31
- },
32
- autoCreate: true
33
- }), createSlotPreference({
27
+ }),
28
+ // KernelManagerView,
29
+ // createViewPreference({
30
+ // view: KernelManagerView,
31
+ // slot: LibroLabLayoutSlots.navigator,
32
+ // openOptions: {
33
+ // reveal: false,
34
+ // order: 'kernel-manager',
35
+ // },
36
+ // autoCreate: true,
37
+ // }),
38
+ createSlotPreference({
34
39
  view: LibroLabLayoutView,
35
40
  slot: RootSlotId
36
41
  }), createSlotPreference({
@@ -40,7 +45,7 @@ export var LibroLabModule = ManaModule.create().register(LibroLabApp, LibroLabLa
40
45
  view: ContentBottomTabView,
41
46
  slot: LibroLabLayoutSlots.contentBottom
42
47
  }), createSlotPreference({
43
- view: SideTabView,
48
+ view: LibroLabSideTabView,
44
49
  slot: LibroLabLayoutSlots.navigator,
45
50
  options: {
46
51
  sort: true
@@ -61,4 +66,4 @@ export var LibroLabModule = ManaModule.create().register(LibroLabApp, LibroLabLa
61
66
  reveal: true,
62
67
  order: 'welcome'
63
68
  }
64
- }), EntryPointView).dependOn(LibroJupyterModule, LibroLabLayoutModule, LibroLabHeaderMenuModule, LibroLabTocModule, LibroPromptCellModule, TerminalModule, ImageViewerModule);
69
+ }), EntryPointView).dependOn(LibroJupyterModule, LibroLabLayoutModule, LibroLabHeaderMenuModule, LibroLabTocModule, LibroPromptCellModule, TerminalModule, ImageViewerModule, CodeEditorViewerModule);
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point-view.d.ts","sourceRoot":"","sources":["../../src/welcome/entry-point-view.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAM7C,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,mBAAmB,mFA2I9B,CAAC;AAEH,qBAEa,cAAe,SAAQ,QAAQ;IACjC,IAAI,oFAAuB;CACrC"}
1
+ {"version":3,"file":"entry-point-view.d.ts","sourceRoot":"","sources":["../../src/welcome/entry-point-view.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,mBAAmB,mFAiJ9B,CAAC;AAEH,qBAEa,cAAe,SAAQ,QAAQ;IACjC,IAAI,oFAAuB;CACrC"}
@@ -19,17 +19,19 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
19
19
  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; } }
20
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
21
  import { NotebookIcon, PythonIcon, JSONIcon, MoreIcon, FileCreateModal, FileView } from '@difizen/libro-jupyter';
22
- import { ModalService, singleton, useInject, view, ViewManager } from '@difizen/mana-app';
22
+ import { CommandRegistry, ModalService, singleton, useInject, view, ViewManager } from '@difizen/mana-app';
23
23
  import { BaseView } from '@difizen/mana-app';
24
24
  import { Col, Row } from 'antd';
25
25
  import { forwardRef, useEffect, useState } from 'react';
26
26
  import { KeybindIcon, PreferenceIcon, TerminalIcon } from "../common/icon.js";
27
+ import { MenuCommands } from "../menu/index.js";
27
28
  import "./index.less";
28
29
  import { jsx as _jsx } from "react/jsx-runtime";
29
30
  import { jsxs as _jsxs } from "react/jsx-runtime";
30
31
  export var EntryPointComponent = /*#__PURE__*/forwardRef(function EntryPointComponent() {
31
32
  var modalService = useInject(ModalService);
32
33
  var viewManager = useInject(ViewManager);
34
+ var commandRegistry = useInject(CommandRegistry);
33
35
  var _useState = useState(),
34
36
  _useState2 = _slicedToArray(_useState, 2),
35
37
  fileView = _useState2[0],
@@ -143,6 +145,9 @@ export var EntryPointComponent = /*#__PURE__*/forwardRef(function EntryPointComp
143
145
  },
144
146
  children: /*#__PURE__*/_jsxs("div", {
145
147
  className: "libro-lab-entry-point-item",
148
+ onClick: function onClick() {
149
+ commandRegistry.executeCommand(MenuCommands.OpenTerminal.id);
150
+ },
146
151
  children: [/*#__PURE__*/_jsx(TerminalIcon, {}), /*#__PURE__*/_jsx("span", {
147
152
  className: "libro-lab-entry-point-item-text",
148
153
  children: "Terminal"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-lab",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -34,12 +34,13 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@ant-design/icons": "^5.1.0",
37
- "@difizen/libro-core": "^0.1.5",
38
- "@difizen/libro-jupyter": "^0.1.5",
39
- "@difizen/libro-kernel": "^0.1.5",
40
- "@difizen/libro-prompt-cell": "^0.1.5",
41
- "@difizen/libro-terminal": "^0.1.5",
42
- "@difizen/libro-toc": "^0.1.5",
37
+ "@difizen/libro-core": "^0.1.7",
38
+ "@difizen/libro-jupyter": "^0.1.7",
39
+ "@difizen/libro-kernel": "^0.1.7",
40
+ "@difizen/libro-prompt-cell": "^0.1.7",
41
+ "@difizen/libro-terminal": "^0.1.7",
42
+ "@difizen/libro-toc": "^0.1.7",
43
+ "@difizen/libro-cofine-editor-core": "^0.1.7",
43
44
  "@difizen/mana-app": "latest",
44
45
  "@difizen/mana-react": "latest",
45
46
  "classnames": "^2.3.2",
@@ -0,0 +1,42 @@
1
+ import { LibroJupyterConfiguration } from '@difizen/libro-jupyter';
2
+ import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
3
+ import { ConfigurationService, inject } from '@difizen/mana-app';
4
+ import { Priority } from '@difizen/mana-app';
5
+ import { NavigatableViewOpenHandler, OpenHandler, singleton } from '@difizen/mana-app';
6
+
7
+ import type { CodeEditorViewer } from './code-editor-viewer.js';
8
+ import { CodeEditorViewerFactory } from './protocol.js';
9
+
10
+ @singleton({ contrib: OpenHandler })
11
+ export class CodeEditorViewerOpenHandler extends NavigatableViewOpenHandler<CodeEditorViewer> {
12
+ @inject(ConfigurationService) protected configurationService: ConfigurationService;
13
+
14
+ id = CodeEditorViewerFactory;
15
+
16
+ canHandle(uri: URI, options?: ViewOpenHandlerOptions) {
17
+ if (
18
+ uri.scheme === 'file' &&
19
+ !['.tar', '.zip', '.7z', '.gz', 'rar'].includes(uri.path.ext)
20
+ ) {
21
+ return 100;
22
+ }
23
+ return Priority.IDLE;
24
+ }
25
+
26
+ override async open(uri: URI, options: ViewOpenHandlerOptions = {}) {
27
+ const { viewOptions, ...extra } = options;
28
+ const slot = await this.configurationService.get(
29
+ LibroJupyterConfiguration['OpenSlot'],
30
+ );
31
+
32
+ return super.open(uri, {
33
+ slot,
34
+ viewOptions: {
35
+ path: uri.path.toString(),
36
+ ...viewOptions,
37
+ },
38
+ reveal: true,
39
+ ...extra,
40
+ });
41
+ }
42
+ }
@@ -0,0 +1,183 @@
1
+ import { EditorProvider, MonacoEnvironment } from '@difizen/libro-cofine-editor-core';
2
+ import type { LanguageSpec, MonacoEditorOptions } from '@difizen/libro-jupyter';
3
+ import { LibroConfigAutoSave } from '@difizen/libro-jupyter';
4
+ import { MonacoUri } from '@difizen/libro-jupyter';
5
+ import { JupyterFileService, LanguageSpecRegistry } from '@difizen/libro-jupyter';
6
+ import type { NavigatableView, Saveable } from '@difizen/mana-app';
7
+ import { ConfigurationService } from '@difizen/mana-app';
8
+ import { Disposable } from '@difizen/mana-app';
9
+ import {
10
+ DisposableCollection,
11
+ Emitter,
12
+ getOrigin,
13
+ inject,
14
+ LabelProvider,
15
+ prop,
16
+ URI,
17
+ URIIconReference,
18
+ ViewOption,
19
+ } from '@difizen/mana-app';
20
+ import { BaseView, transient, useInject, view, ViewInstance } from '@difizen/mana-app';
21
+ import React from 'react';
22
+ import './index.less';
23
+
24
+ import type { EditorOption } from './protocol.js';
25
+ import { CodeEditorViewerFactory } from './protocol.js';
26
+
27
+ const EditorComponent: React.FC = () => {
28
+ const viewInstance = useInject<CodeEditorViewer>(ViewInstance);
29
+ return <div className="libro-lab-editor-viewer" ref={viewInstance.codeRef}></div>;
30
+ };
31
+
32
+ type EditorType = ReturnType<EditorProvider['create']>;
33
+ export const LibroLabE2URIScheme = 'libro-lab-e2';
34
+
35
+ @transient()
36
+ @view(CodeEditorViewerFactory)
37
+ export class CodeEditorViewer extends BaseView implements NavigatableView, Saveable {
38
+ override view = EditorComponent;
39
+
40
+ codeRef = React.createRef<HTMLDivElement>();
41
+
42
+ protected e2Editor?: EditorType;
43
+
44
+ @prop()
45
+ dirty = false;
46
+
47
+ language = 'text';
48
+
49
+ value: string;
50
+
51
+ @prop() filePath?: string;
52
+
53
+ autoSaveDelay = 1000;
54
+
55
+ dirtyEmitter = new Emitter<void>();
56
+
57
+ languageSpecRegistry: LanguageSpecRegistry;
58
+
59
+ get onDirtyChanged() {
60
+ return this.dirtyEmitter.event;
61
+ }
62
+
63
+ autoSave: 'on' | 'off' = 'off';
64
+
65
+ protected readonly toDisposeOnAutoSave = new DisposableCollection();
66
+
67
+ languageSpec?: LanguageSpec;
68
+
69
+ fileService: JupyterFileService;
70
+
71
+ constructor(
72
+ @inject(ViewOption)
73
+ options: EditorOption,
74
+ @inject(LabelProvider) labelProvider: LabelProvider,
75
+ @inject(JupyterFileService) fileService: JupyterFileService,
76
+ @inject(LanguageSpecRegistry)
77
+ languageSpecRegistry: LanguageSpecRegistry,
78
+ @inject(ConfigurationService) configurationService: ConfigurationService,
79
+ ) {
80
+ super();
81
+ this.filePath = options.path;
82
+ this.title.caption = options.path;
83
+ const uri = new URI(options.path);
84
+ const uriRef = URIIconReference.create('file', new URI(options.path));
85
+ const iconClass = labelProvider.getIcon(uriRef);
86
+ this.fileService = fileService;
87
+ this.title.icon = <div className={iconClass} />;
88
+ this.title.label = uri.path.base;
89
+ this.languageSpecRegistry = languageSpecRegistry;
90
+ this.languageSpec = this.languageSpecRegistry.languageSpecs.find((item) =>
91
+ item.ext.includes(uri.path.ext),
92
+ );
93
+ configurationService
94
+ .get(LibroConfigAutoSave)
95
+ .then((value) => {
96
+ if (value) {
97
+ this.autoSave = 'on';
98
+ return;
99
+ } else {
100
+ this.autoSave = 'off';
101
+ return;
102
+ }
103
+ })
104
+ .catch(() => {
105
+ //
106
+ });
107
+ }
108
+
109
+ override async onViewMount() {
110
+ if (!this.filePath) {
111
+ return;
112
+ }
113
+ const content = await getOrigin(this.fileService).read(this.filePath);
114
+ if (typeof content !== 'string' || !this.languageSpec) {
115
+ return;
116
+ }
117
+ if (!this.codeRef || !this.codeRef.current) {
118
+ return;
119
+ }
120
+
121
+ await MonacoEnvironment.init();
122
+ await this.languageSpec.beforeEditorInit?.();
123
+ const editorPorvider =
124
+ MonacoEnvironment.container.get<EditorProvider>(EditorProvider);
125
+
126
+ const uri = MonacoUri.from({
127
+ scheme: LibroLabE2URIScheme,
128
+ path: `${this.filePath}${this.languageSpec.ext[0]}`,
129
+ });
130
+
131
+ const options: MonacoEditorOptions = {
132
+ /**
133
+ * language ia an uri:
134
+ */
135
+ theme: 'libro-light',
136
+ language: this.languageSpec.language,
137
+ uri,
138
+ value: content,
139
+ };
140
+
141
+ this.e2Editor = editorPorvider.create(this.codeRef.current, options);
142
+ this.toDispose.push(
143
+ getOrigin(this.e2Editor.codeEditor).onDidChangeModelContent(() => {
144
+ this.dirty = true;
145
+ if (this.autoSave === 'on') {
146
+ this.doAutoSave();
147
+ }
148
+ }),
149
+ );
150
+ }
151
+
152
+ protected doAutoSave = () => {
153
+ this.toDisposeOnAutoSave.dispose();
154
+ if (!this.e2Editor) {
155
+ return;
156
+ }
157
+ const handle = window.setTimeout(async () => {
158
+ this.save();
159
+ }, this.autoSaveDelay);
160
+ this.toDisposeOnAutoSave.push(Disposable.create(() => window.clearTimeout(handle)));
161
+ };
162
+
163
+ save = async () => {
164
+ this.value = this.e2Editor?.codeEditor.getValue() || '';
165
+ await this.fileService.write(this.filePath!, this.value);
166
+ this.dirty = false;
167
+ };
168
+
169
+ getResourceUri(): URI | undefined {
170
+ return new URI(this.filePath);
171
+ }
172
+
173
+ createMoveToUri(resourceUri: URI): URI | undefined {
174
+ this.filePath = resourceUri.path.toString();
175
+ return resourceUri;
176
+ }
177
+
178
+ override dispose(): void {
179
+ this.toDispose.dispose();
180
+ this.toDisposeOnAutoSave.dispose();
181
+ super.dispose();
182
+ }
183
+ }
@@ -0,0 +1,3 @@
1
+ .libro-lab-editor-viewer {
2
+ height: 100%;
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from './module.js';
2
+ export * from './code-editor-viewer.js';
@@ -0,0 +1,8 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+
3
+ import { CodeEditorViewerOpenHandler } from './code-editor-open-handler.js';
4
+ import { CodeEditorViewer } from './code-editor-viewer.js';
5
+
6
+ export const CodeEditorViewerModule = ManaModule.create(
7
+ 'CodeEditorViewerModule',
8
+ ).register(CodeEditorViewer, CodeEditorViewerOpenHandler);
@@ -0,0 +1,7 @@
1
+ export const CodeEditorViewerFactory = 'libro-lab-editor-viewer';
2
+
3
+ export interface EditorOption {
4
+ path: string;
5
+ loadType?: string;
6
+ name?: string;
7
+ }
package/src/index.ts CHANGED
@@ -9,3 +9,4 @@ export * from './welcome/index.js';
9
9
  export * from './kernel-manager/index.js';
10
10
  export * from './common/index.js';
11
11
  export * from './image-viewer/index.js';
12
+ export * from './editor-viewer/index.js';
@@ -0,0 +1,11 @@
1
+ import { SideTabView, ToolbarRender } from '@difizen/mana-app';
2
+ import { view } from '@difizen/mana-app';
3
+ import { transient } from '@difizen/mana-app';
4
+
5
+ @transient()
6
+ @view('libro-lab-side-tab')
7
+ export class LibroLabSideTabView extends SideTabView {
8
+ override renderTabToolbar(): JSX.Element {
9
+ return <ToolbarRender data={[this]} />;
10
+ }
11
+ }
package/src/module.tsx CHANGED
@@ -5,15 +5,15 @@ import {
5
5
  ManaModule,
6
6
  createSlotPreference,
7
7
  RootSlotId,
8
- SideTabView,
9
8
  createViewPreference,
10
9
  HeaderArea,
11
10
  } from '@difizen/mana-app';
12
11
 
13
12
  import { LabConfigAppContribution } from './config/config-contribution.js';
13
+ import { CodeEditorViewerModule } from './editor-viewer/index.js';
14
14
  import { GithubLinkView } from './github-link/index.js';
15
15
  import { ImageViewerModule } from './image-viewer/index.js';
16
- import { KernelManagerView } from './kernel-manager/index.js';
16
+ // import { KernelManagerView } from './kernel-manager/index.js';
17
17
  import { LibroLabApp } from './lab-app.js';
18
18
  import { ContentBottomTabView } from './layout/content-bottom-tab-view.js';
19
19
  import {
@@ -23,6 +23,7 @@ import {
23
23
  } from './layout/index.js';
24
24
  import { SaveableTabView } from './layout/saveable-tab-view.js';
25
25
  import './index.less';
26
+ import { LibroLabSideTabView } from './layout/side-tab-view.js';
26
27
  import { LibroLabHeaderMenuModule } from './menu/module.js';
27
28
  import { LibroLabTocModule } from './toc/module.js';
28
29
  import { EntryPointView } from './welcome/entry-point-view.js';
@@ -34,6 +35,7 @@ export const LibroLabModule = ManaModule.create()
34
35
  LibroLabLayoutView,
35
36
  GithubLinkView,
36
37
  LabConfigAppContribution,
38
+ LibroLabSideTabView,
37
39
  createViewPreference({
38
40
  view: GithubLinkView,
39
41
  slot: HeaderArea.right,
@@ -42,16 +44,16 @@ export const LibroLabModule = ManaModule.create()
42
44
  },
43
45
  autoCreate: true,
44
46
  }),
45
- KernelManagerView,
46
- createViewPreference({
47
- view: KernelManagerView,
48
- slot: LibroLabLayoutSlots.navigator,
49
- openOptions: {
50
- reveal: false,
51
- order: 'kernel-manager',
52
- },
53
- autoCreate: true,
54
- }),
47
+ // KernelManagerView,
48
+ // createViewPreference({
49
+ // view: KernelManagerView,
50
+ // slot: LibroLabLayoutSlots.navigator,
51
+ // openOptions: {
52
+ // reveal: false,
53
+ // order: 'kernel-manager',
54
+ // },
55
+ // autoCreate: true,
56
+ // }),
55
57
  createSlotPreference({
56
58
  view: LibroLabLayoutView,
57
59
  slot: RootSlotId,
@@ -65,7 +67,7 @@ export const LibroLabModule = ManaModule.create()
65
67
  slot: LibroLabLayoutSlots.contentBottom,
66
68
  }),
67
69
  createSlotPreference({
68
- view: SideTabView,
70
+ view: LibroLabSideTabView,
69
71
  slot: LibroLabLayoutSlots.navigator,
70
72
  options: {
71
73
  sort: true,
@@ -100,4 +102,5 @@ export const LibroLabModule = ManaModule.create()
100
102
  LibroPromptCellModule,
101
103
  TerminalModule,
102
104
  ImageViewerModule,
105
+ CodeEditorViewerModule,
103
106
  );
@@ -7,6 +7,7 @@ import {
7
7
  FileView,
8
8
  } from '@difizen/libro-jupyter';
9
9
  import {
10
+ CommandRegistry,
10
11
  ModalService,
11
12
  singleton,
12
13
  useInject,
@@ -18,12 +19,14 @@ import { Col, Row } from 'antd';
18
19
  import { forwardRef, useEffect, useState } from 'react';
19
20
 
20
21
  import { KeybindIcon, PreferenceIcon, TerminalIcon } from '../common/icon.js';
22
+ import { MenuCommands } from '../menu/index.js';
21
23
 
22
24
  import './index.less';
23
25
 
24
26
  export const EntryPointComponent = forwardRef(function EntryPointComponent() {
25
27
  const modalService = useInject(ModalService);
26
28
  const viewManager = useInject(ViewManager);
29
+ const commandRegistry = useInject(CommandRegistry);
27
30
  const [fileView, setFileView] = useState<FileView>();
28
31
 
29
32
  useEffect(() => {
@@ -117,7 +120,12 @@ export const EntryPointComponent = forwardRef(function EntryPointComponent() {
117
120
  className="gutter-row"
118
121
  style={{ paddingLeft: 'unset', paddingRight: '32px' }}
119
122
  >
120
- <div className="libro-lab-entry-point-item">
123
+ <div
124
+ className="libro-lab-entry-point-item"
125
+ onClick={() => {
126
+ commandRegistry.executeCommand(MenuCommands.OpenTerminal.id);
127
+ }}
128
+ >
121
129
  <TerminalIcon />
122
130
  <span className="libro-lab-entry-point-item-text">Terminal</span>
123
131
  </div>