@difizen/libro-lab 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/editor-viewer/code-editor-open-handler.d.ts +12 -0
- package/es/editor-viewer/code-editor-open-handler.d.ts.map +1 -0
- package/es/editor-viewer/code-editor-open-handler.js +101 -0
- package/es/editor-viewer/code-editor-viewer.d.ts +38 -0
- package/es/editor-viewer/code-editor-viewer.d.ts.map +1 -0
- package/es/editor-viewer/code-editor-viewer.js +235 -0
- package/es/editor-viewer/index.d.ts +3 -0
- package/es/editor-viewer/index.d.ts.map +1 -0
- package/es/editor-viewer/index.js +2 -0
- package/es/editor-viewer/index.less +3 -0
- package/es/editor-viewer/module.d.ts +3 -0
- package/es/editor-viewer/module.d.ts.map +1 -0
- package/es/editor-viewer/module.js +4 -0
- package/es/editor-viewer/protocol.d.ts +7 -0
- package/es/editor-viewer/protocol.d.ts.map +1 -0
- package/es/editor-viewer/protocol.js +1 -0
- package/es/image-viewer/index.d.ts +3 -0
- package/es/image-viewer/index.d.ts.map +1 -0
- package/es/image-viewer/index.js +2 -0
- package/es/image-viewer/index.less +3 -0
- package/es/image-viewer/module.d.ts +3 -0
- package/es/image-viewer/module.d.ts.map +1 -0
- package/es/image-viewer/module.js +4 -0
- package/es/image-viewer/open-handler.d.ts +11 -0
- package/es/image-viewer/open-handler.d.ts.map +1 -0
- package/es/image-viewer/open-handler.js +106 -0
- package/es/image-viewer/protocol.d.ts +10 -0
- package/es/image-viewer/protocol.d.ts.map +1 -0
- package/es/image-viewer/protocol.js +27 -0
- package/es/image-viewer/viewer.d.ts +29 -0
- package/es/image-viewer/viewer.d.ts.map +1 -0
- package/es/image-viewer/viewer.js +185 -0
- package/es/index.d.ts +11 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +12 -1
- package/es/layout/brand/{index.d.ts → brand.d.ts} +1 -1
- package/es/layout/brand/{index.d.ts.map → brand.d.ts.map} +1 -1
- package/es/layout/index.d.ts +8 -0
- package/es/layout/index.d.ts.map +1 -1
- package/es/layout/index.js +9 -1
- package/es/layout/layout.d.ts +1 -1
- package/es/layout/layout.d.ts.map +1 -1
- package/es/layout/layout.js +2 -2
- package/es/layout/module.js +1 -1
- package/es/menu/index.d.ts +5 -0
- package/es/menu/index.d.ts.map +1 -0
- package/es/menu/index.js +4 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +3 -1
- package/es/toc/index.d.ts +3 -0
- package/es/toc/index.d.ts.map +1 -0
- package/es/toc/index.js +2 -0
- package/es/welcome/index.d.ts +2 -12
- package/es/welcome/index.d.ts.map +1 -1
- package/es/welcome/index.js +2 -70
- package/es/welcome/welcome-view.d.ts +13 -0
- package/es/welcome/welcome-view.d.ts.map +1 -0
- package/es/welcome/welcome-view.js +70 -0
- package/package.json +13 -9
- package/src/editor-viewer/code-editor-open-handler.ts +42 -0
- package/src/editor-viewer/code-editor-viewer.tsx +183 -0
- package/src/editor-viewer/index.less +3 -0
- package/src/editor-viewer/index.ts +2 -0
- package/src/editor-viewer/module.ts +8 -0
- package/src/editor-viewer/protocol.ts +7 -0
- package/src/image-viewer/index.less +3 -0
- package/src/image-viewer/index.ts +2 -0
- package/src/image-viewer/module.ts +9 -0
- package/src/image-viewer/open-handler.ts +47 -0
- package/src/image-viewer/protocol.ts +43 -0
- package/src/image-viewer/viewer.tsx +131 -0
- package/src/index.ts +11 -0
- package/src/layout/index.tsx +8 -0
- package/src/layout/layout.tsx +3 -3
- package/src/layout/module.ts +1 -1
- package/src/menu/index.ts +4 -0
- package/src/module.tsx +4 -0
- package/src/toc/index.ts +2 -0
- package/src/welcome/index.ts +2 -0
- /package/es/layout/brand/{index.js → brand.js} +0 -0
- /package/src/layout/brand/{index.tsx → brand.tsx} +0 -0
- /package/src/welcome/{index.tsx → welcome-view.tsx} +0 -0
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/image-viewer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/image-viewer/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,iBAAiB,YAG7B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
import { ImageViewerOpenHandler } from "./open-handler.js";
|
|
3
|
+
import { NavigatableImageViewerView } from "./viewer.js";
|
|
4
|
+
export var ImageViewerModule = ManaModule.create('ImageViewerModule').register(NavigatableImageViewerView, ImageViewerOpenHandler);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
|
|
2
|
+
import { ConfigurationService } from '@difizen/mana-app';
|
|
3
|
+
import { NavigatableViewOpenHandler, Priority } from '@difizen/mana-app';
|
|
4
|
+
import type { NavigatableImageViewerView } from './viewer.js';
|
|
5
|
+
export declare class ImageViewerOpenHandler extends NavigatableViewOpenHandler<NavigatableImageViewerView> {
|
|
6
|
+
protected configurationService: ConfigurationService;
|
|
7
|
+
id: string;
|
|
8
|
+
canHandle(uri: URI, _options?: ViewOpenHandlerOptions): 100 | Priority.IDLE;
|
|
9
|
+
open(uri: URI, options?: ViewOpenHandlerOptions): Promise<NavigatableImageViewerView>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=open-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-handler.d.ts","sourceRoot":"","sources":["../../src/image-viewer/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,EACL,0BAA0B,EAG1B,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D,qBACa,sBAAuB,SAAQ,0BAA0B,CAAC,0BAA0B,CAAC;IAClE,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAEnF,EAAE,SAAuC;IAGzC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,sBAAsB;IAUtC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,sBAA2B;CAenE"}
|