@difizen/libro-jupyter 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/add-between-cell/add-between-cell.js +1 -1
- package/es/cell/jupyter-code-cell-view.d.ts +3 -1
- package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
- package/es/cell/jupyter-code-cell-view.js +12 -5
- package/es/command/command-contribution.d.ts.map +1 -1
- package/es/command/command-contribution.js +5 -5
- package/es/components/icons.js +1 -1
- package/es/contents/content-contribution.js +1 -1
- package/es/contents/save-content-contribution.d.ts +10 -0
- package/es/contents/save-content-contribution.d.ts.map +1 -0
- package/es/contents/save-content-contribution.js +110 -0
- package/es/file/file-create-modal.d.ts.map +1 -1
- package/es/file/file-create-modal.js +16 -5
- package/es/file/file-service.js +1 -1
- package/es/file/index.d.ts +1 -0
- package/es/file/index.d.ts.map +1 -1
- package/es/file/index.js +2 -1
- package/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +2 -1
- package/es/keybind-instructions/index.less +9 -9
- package/es/keybind-instructions/keybind-instructions-view.d.ts +2 -2
- package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -1
- package/es/keybind-instructions/keybind-instructions-view.js +69 -63
- package/es/libro-jupyter-model.d.ts +2 -4
- package/es/libro-jupyter-model.d.ts.map +1 -1
- package/es/libro-jupyter-model.js +35 -120
- package/es/libro-jupyter-workspace.d.ts +18 -0
- package/es/libro-jupyter-workspace.d.ts.map +1 -0
- package/es/libro-jupyter-workspace.js +108 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +5 -2
- package/es/output/libro-jupyter-outputarea.d.ts.map +1 -1
- package/es/output/libro-jupyter-outputarea.js +60 -56
- package/es/toolbar/save-file-error.d.ts.map +1 -1
- package/es/toolbar/save-file-error.js +20 -13
- package/es/widget/box/contribution.d.ts +10 -0
- package/es/widget/box/contribution.d.ts.map +1 -0
- package/es/widget/box/contribution.js +48 -0
- package/es/widget/box/index.d.ts +3 -0
- package/es/widget/box/index.d.ts.map +1 -0
- package/es/widget/box/index.js +2 -0
- package/es/widget/box/index.less +3 -0
- package/es/widget/box/view.d.ts +19 -0
- package/es/widget/box/view.d.ts.map +1 -0
- package/es/widget/box/view.js +114 -0
- package/es/widget/comm.d.ts +65 -0
- package/es/widget/comm.d.ts.map +1 -0
- package/es/widget/comm.js +153 -0
- package/es/widget/index.d.ts +10 -0
- package/es/widget/index.d.ts.map +1 -0
- package/es/widget/index.js +9 -0
- package/es/widget/index.less +7 -0
- package/es/widget/instance-progress/contribution.d.ts +10 -0
- package/es/widget/instance-progress/contribution.d.ts.map +1 -0
- package/es/widget/instance-progress/contribution.js +39 -0
- package/es/widget/instance-progress/index.d.ts +3 -0
- package/es/widget/instance-progress/index.d.ts.map +1 -0
- package/es/widget/instance-progress/index.js +2 -0
- package/es/widget/instance-progress/view.d.ts +30 -0
- package/es/widget/instance-progress/view.d.ts.map +1 -0
- package/es/widget/instance-progress/view.js +180 -0
- package/es/widget/libro-widgets.d.ts +84 -0
- package/es/widget/libro-widgets.d.ts.map +1 -0
- package/es/widget/libro-widgets.js +307 -0
- package/es/widget/module.d.ts +4 -0
- package/es/widget/module.d.ts.map +1 -0
- package/es/widget/module.js +38 -0
- package/es/widget/progress/contribution.d.ts +10 -0
- package/es/widget/progress/contribution.d.ts.map +1 -0
- package/es/widget/progress/contribution.js +39 -0
- package/es/widget/progress/index.d.ts +3 -0
- package/es/widget/progress/index.d.ts.map +1 -0
- package/es/widget/progress/index.js +2 -0
- package/es/widget/progress/progressBar.d.ts +15 -0
- package/es/widget/progress/progressBar.d.ts.map +1 -0
- package/es/widget/progress/progressBar.js +20 -0
- package/es/widget/progress/view.d.ts +19 -0
- package/es/widget/progress/view.d.ts.map +1 -0
- package/es/widget/progress/view.js +74 -0
- package/es/widget/protocol.d.ts +193 -0
- package/es/widget/protocol.d.ts.map +1 -0
- package/es/widget/protocol.js +33 -0
- package/es/widget/utils.d.ts +27 -0
- package/es/widget/utils.d.ts.map +1 -0
- package/es/widget/utils.js +59 -0
- package/es/widget/version.d.ts +3 -0
- package/es/widget/version.d.ts.map +1 -0
- package/es/widget/version.js +2 -0
- package/es/widget/widget-manager.d.ts +19 -0
- package/es/widget/widget-manager.d.ts.map +1 -0
- package/es/widget/widget-manager.js +77 -0
- package/es/widget/widget-render.d.ts +7 -0
- package/es/widget/widget-render.d.ts.map +1 -0
- package/es/widget/widget-render.js +46 -0
- package/es/widget/widget-rendermime-contribution.d.ts +16 -0
- package/es/widget/widget-rendermime-contribution.d.ts.map +1 -0
- package/es/widget/widget-rendermime-contribution.js +50 -0
- package/es/widget/widget-view-contribution.d.ts +10 -0
- package/es/widget/widget-view-contribution.d.ts.map +1 -0
- package/es/widget/widget-view-contribution.js +36 -0
- package/es/widget/widget-view.d.ts +71 -0
- package/es/widget/widget-view.d.ts.map +1 -0
- package/es/widget/widget-view.js +273 -0
- package/package.json +18 -18
- package/src/add-between-cell/add-between-cell.tsx +1 -1
- package/src/cell/jupyter-code-cell-view.tsx +14 -6
- package/src/command/command-contribution.ts +11 -10
- package/src/components/icons.tsx +1 -1
- package/src/contents/content-contribution.ts +1 -1
- package/src/contents/save-content-contribution.ts +67 -0
- package/src/file/file-create-modal.tsx +10 -1
- package/src/file/file-service.ts +1 -1
- package/src/file/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/keybind-instructions/index.less +9 -9
- package/src/keybind-instructions/keybind-instructions-view.tsx +72 -62
- package/src/libro-jupyter-model.ts +1 -69
- package/src/libro-jupyter-workspace.ts +49 -0
- package/src/module.ts +6 -0
- package/src/output/libro-jupyter-outputarea.tsx +56 -49
- package/src/toolbar/save-file-error.tsx +25 -15
- package/src/widget/box/contribution.ts +29 -0
- package/src/widget/box/index.less +3 -0
- package/src/widget/box/index.ts +2 -0
- package/src/widget/box/view.tsx +112 -0
- package/src/widget/comm.ts +152 -0
- package/src/widget/index.less +7 -0
- package/src/widget/index.ts +9 -0
- package/src/widget/instance-progress/contribution.ts +20 -0
- package/src/widget/instance-progress/index.ts +2 -0
- package/src/widget/instance-progress/view.tsx +155 -0
- package/src/widget/libro-widgets.ts +223 -0
- package/src/widget/module.ts +73 -0
- package/src/widget/progress/contribution.ts +24 -0
- package/src/widget/progress/index.ts +2 -0
- package/src/widget/progress/progressBar.tsx +29 -0
- package/src/widget/progress/view.tsx +70 -0
- package/src/widget/protocol.ts +255 -0
- package/src/widget/utils.ts +67 -0
- package/src/widget/version.ts +2 -0
- package/src/widget/widget-manager.ts +45 -0
- package/src/widget/widget-render.tsx +52 -0
- package/src/widget/widget-rendermime-contribution.ts +36 -0
- package/src/widget/widget-view-contribution.ts +14 -0
- package/src/widget/widget-view.tsx +259 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
function _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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
13
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
14
|
+
import { contrib, inject, Priority, prop, transient } from '@difizen/mana-app';
|
|
15
|
+
import { Emitter } from '@difizen/mana-app';
|
|
16
|
+
import { LibroWidgetCommFactory, WidgetsOption, WidgetViewContribution } from "./protocol.js";
|
|
17
|
+
import { put_buffers, reject } from "./utils.js";
|
|
18
|
+
import { PROTOCOL_VERSION } from "./version.js";
|
|
19
|
+
var PROTOCOL_MAJOR_VERSION = PROTOCOL_VERSION.split('.', 1)[0];
|
|
20
|
+
export var LibroWidgets = (_dec = transient(), _dec2 = contrib(WidgetViewContribution), _dec3 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
21
|
+
function LibroWidgets(options, widgetCommFactory) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
_classCallCheck(this, LibroWidgets);
|
|
24
|
+
_initializerDefineProperty(this, "WidgetViewProvider", _descriptor, this);
|
|
25
|
+
this.widgetEmitter = new Emitter();
|
|
26
|
+
this.widgetCommFactory = void 0;
|
|
27
|
+
this.kernelConnection = void 0;
|
|
28
|
+
/**
|
|
29
|
+
* Dictionary of model ids and model instance promises
|
|
30
|
+
*/
|
|
31
|
+
_initializerDefineProperty(this, "models", _descriptor2, this);
|
|
32
|
+
/**
|
|
33
|
+
* The comm target name to register
|
|
34
|
+
*/
|
|
35
|
+
this.id = void 0;
|
|
36
|
+
this.commTargetName = 'jupyter.widget';
|
|
37
|
+
this.kernelConnection = options.kc;
|
|
38
|
+
this.id = options.id;
|
|
39
|
+
this.widgetCommFactory = widgetCommFactory;
|
|
40
|
+
this.kernelConnection.registerCommTarget(this.commTargetName, /*#__PURE__*/function () {
|
|
41
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(comm, msg) {
|
|
42
|
+
var widgetComm;
|
|
43
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
44
|
+
while (1) switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
widgetComm = _this.widgetCommFactory({
|
|
47
|
+
comm: comm
|
|
48
|
+
});
|
|
49
|
+
_context.next = 3;
|
|
50
|
+
return _this.handleCommOpen(widgetComm, msg);
|
|
51
|
+
case 3:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee);
|
|
56
|
+
}));
|
|
57
|
+
return function (_x, _x2) {
|
|
58
|
+
return _ref.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
}());
|
|
61
|
+
}
|
|
62
|
+
LibroWidgets = inject(LibroWidgetCommFactory)(LibroWidgets, undefined, 1) || LibroWidgets;
|
|
63
|
+
LibroWidgets = inject(WidgetsOption)(LibroWidgets, undefined, 0) || LibroWidgets;
|
|
64
|
+
_createClass(LibroWidgets, [{
|
|
65
|
+
key: "onWidgetRender",
|
|
66
|
+
get: function get() {
|
|
67
|
+
return this.widgetEmitter.event;
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "findProvider",
|
|
71
|
+
value: function findProvider(attributes) {
|
|
72
|
+
var prioritized = Priority.sortSync(this.WidgetViewProvider.getContributions(), function (contribution) {
|
|
73
|
+
return contribution.canHandle(attributes);
|
|
74
|
+
});
|
|
75
|
+
var sorted = prioritized.map(function (c) {
|
|
76
|
+
return c.value;
|
|
77
|
+
});
|
|
78
|
+
return sorted[0];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Create a comm which can be used for communication for a widget.
|
|
83
|
+
*
|
|
84
|
+
* If the data/metadata is passed in, open the comm before returning (i.e.,
|
|
85
|
+
* send the comm_open message). If the data and metadata is undefined, we
|
|
86
|
+
* want to reconstruct a comm that already exists in the kernel, so do not
|
|
87
|
+
* open the comm by sending the comm_open message.
|
|
88
|
+
*
|
|
89
|
+
* @param comm_target_name Comm target name
|
|
90
|
+
* @param model_id The comm id
|
|
91
|
+
* @param data The initial data for the comm
|
|
92
|
+
* @param metadata The metadata in the open message
|
|
93
|
+
*/
|
|
94
|
+
}, {
|
|
95
|
+
key: "createComm",
|
|
96
|
+
value: (function () {
|
|
97
|
+
var _createComm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(comm_target_name, model_id, data, metadata, buffers) {
|
|
98
|
+
var kernel, comm;
|
|
99
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
100
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
kernel = this.kernelConnection;
|
|
103
|
+
if (kernel) {
|
|
104
|
+
_context2.next = 3;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
throw new Error('No current kernel');
|
|
108
|
+
case 3:
|
|
109
|
+
comm = kernel.createComm(comm_target_name, model_id);
|
|
110
|
+
if (data || metadata) {
|
|
111
|
+
comm.open(data, metadata, buffers);
|
|
112
|
+
}
|
|
113
|
+
return _context2.abrupt("return", this.widgetCommFactory({
|
|
114
|
+
comm: comm
|
|
115
|
+
}));
|
|
116
|
+
case 6:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context2.stop();
|
|
119
|
+
}
|
|
120
|
+
}, _callee2, this);
|
|
121
|
+
}));
|
|
122
|
+
function createComm(_x3, _x4, _x5, _x6, _x7) {
|
|
123
|
+
return _createComm.apply(this, arguments);
|
|
124
|
+
}
|
|
125
|
+
return createComm;
|
|
126
|
+
}()
|
|
127
|
+
/**
|
|
128
|
+
* Get a model by model id.
|
|
129
|
+
*
|
|
130
|
+
* #### Notes
|
|
131
|
+
* If the model is not found, throw error.
|
|
132
|
+
*
|
|
133
|
+
* If you would like to synchronously test if a model exists, use .hasModel().
|
|
134
|
+
*/
|
|
135
|
+
)
|
|
136
|
+
}, {
|
|
137
|
+
key: "getModel",
|
|
138
|
+
value: function getModel(model_id) {
|
|
139
|
+
var model = this.models.get(model_id);
|
|
140
|
+
if (model === undefined) {
|
|
141
|
+
throw new Error('widget model not found');
|
|
142
|
+
}
|
|
143
|
+
return model;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Returns true if the given model is registered, otherwise false.
|
|
148
|
+
*
|
|
149
|
+
* #### Notes
|
|
150
|
+
* This is a synchronous way to check if a model is registered.
|
|
151
|
+
*/
|
|
152
|
+
}, {
|
|
153
|
+
key: "hasModel",
|
|
154
|
+
value: function hasModel(model_id) {
|
|
155
|
+
return this.models.get(model_id) !== undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Handle when a comm is opened.
|
|
160
|
+
*/
|
|
161
|
+
}, {
|
|
162
|
+
key: "handleCommOpen",
|
|
163
|
+
value: (function () {
|
|
164
|
+
var _handleCommOpen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(comm, msg) {
|
|
165
|
+
var protocolVersion, error, data, buffer_paths, buffers;
|
|
166
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
167
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
168
|
+
case 0:
|
|
169
|
+
protocolVersion = (msg.metadata || {})['version'] || '';
|
|
170
|
+
if (!(protocolVersion.split('.', 1)[0] !== PROTOCOL_MAJOR_VERSION)) {
|
|
171
|
+
_context3.next = 5;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
error = "Wrong widget protocol version: received protocol version '".concat(protocolVersion, "', but was expecting major version '").concat(PROTOCOL_MAJOR_VERSION, "'");
|
|
175
|
+
console.error(error);
|
|
176
|
+
return _context3.abrupt("return", Promise.reject(error));
|
|
177
|
+
case 5:
|
|
178
|
+
data = msg.content.data;
|
|
179
|
+
buffer_paths = data.buffer_paths || [];
|
|
180
|
+
buffers = msg.buffers || [];
|
|
181
|
+
put_buffers(data.state, buffer_paths, buffers);
|
|
182
|
+
// this.createComm(msg.content.target_name, msg.content.comm_id, msg.content.data, msg.metadata);
|
|
183
|
+
return _context3.abrupt("return", this.newWidgetView(data.state, {
|
|
184
|
+
model_id: msg.content.comm_id,
|
|
185
|
+
comm: comm
|
|
186
|
+
}).catch(reject('Could not create a model.', true)));
|
|
187
|
+
case 10:
|
|
188
|
+
case "end":
|
|
189
|
+
return _context3.stop();
|
|
190
|
+
}
|
|
191
|
+
}, _callee3, this);
|
|
192
|
+
}));
|
|
193
|
+
function handleCommOpen(_x8, _x9) {
|
|
194
|
+
return _handleCommOpen.apply(this, arguments);
|
|
195
|
+
}
|
|
196
|
+
return handleCommOpen;
|
|
197
|
+
}())
|
|
198
|
+
}, {
|
|
199
|
+
key: "registerWidgetView",
|
|
200
|
+
value: function registerWidgetView(model_id, model) {
|
|
201
|
+
var _this2 = this;
|
|
202
|
+
model.then(function (model) {
|
|
203
|
+
_this2.models.set(model_id, model);
|
|
204
|
+
_this2.models.set(model.toModelKey(), model);
|
|
205
|
+
_this2.widgetEmitter.fire({
|
|
206
|
+
WidgetViewName: model.model_name
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}).catch(function () {
|
|
210
|
+
//
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "handleCommClose",
|
|
215
|
+
value: function handleCommClose(msg) {
|
|
216
|
+
var comm_id = msg.content.comm_id;
|
|
217
|
+
var model = this.getModel(comm_id);
|
|
218
|
+
model.isCommClosed = true;
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "unregisterWidgetView",
|
|
222
|
+
value: function unregisterWidgetView(model_id) {
|
|
223
|
+
var model = this.models.get(model_id);
|
|
224
|
+
model === null || model === void 0 || model.dispose();
|
|
225
|
+
this.models.delete(model_id);
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
key: "newWidgetView",
|
|
229
|
+
value: function () {
|
|
230
|
+
var _newWidgetView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(attributes, options) {
|
|
231
|
+
var model_id, provider, WidgetView;
|
|
232
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
233
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
234
|
+
case 0:
|
|
235
|
+
model_id = options.model_id;
|
|
236
|
+
if (model_id) {
|
|
237
|
+
_context4.next = 3;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
throw new Error('Neither comm nor model_id provided in options object. At least one must exist.');
|
|
241
|
+
case 3:
|
|
242
|
+
options.model_id = model_id;
|
|
243
|
+
provider = this.findProvider(attributes);
|
|
244
|
+
WidgetView = provider.factory({
|
|
245
|
+
attributes: attributes,
|
|
246
|
+
options: options,
|
|
247
|
+
widgetsId: this.id
|
|
248
|
+
});
|
|
249
|
+
this.registerWidgetView(model_id, WidgetView);
|
|
250
|
+
return _context4.abrupt("return", WidgetView);
|
|
251
|
+
case 8:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context4.stop();
|
|
254
|
+
}
|
|
255
|
+
}, _callee4, this);
|
|
256
|
+
}));
|
|
257
|
+
function newWidgetView(_x10, _x11) {
|
|
258
|
+
return _newWidgetView.apply(this, arguments);
|
|
259
|
+
}
|
|
260
|
+
return newWidgetView;
|
|
261
|
+
}()
|
|
262
|
+
/**
|
|
263
|
+
* Close all widgets and empty the widget state.
|
|
264
|
+
* @return Promise that resolves when the widget state is cleared.
|
|
265
|
+
*/
|
|
266
|
+
}, {
|
|
267
|
+
key: "clearState",
|
|
268
|
+
value: function clearState() {
|
|
269
|
+
this.models.clear();
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Disconnect the widget manager from the kernel, setting each model's comm
|
|
273
|
+
* as dead.
|
|
274
|
+
*/
|
|
275
|
+
}, {
|
|
276
|
+
key: "disconnect",
|
|
277
|
+
value: function disconnect() {
|
|
278
|
+
// this.models.forEach(model => model.clear());
|
|
279
|
+
}
|
|
280
|
+
}, {
|
|
281
|
+
key: "toJSON",
|
|
282
|
+
value:
|
|
283
|
+
/**
|
|
284
|
+
* Serialize the model. See the deserialization function at the top of this file
|
|
285
|
+
* and the kernel-side serializer/deserializer.
|
|
286
|
+
*/
|
|
287
|
+
function toJSON() {
|
|
288
|
+
return JSON.stringify({
|
|
289
|
+
kc_id: this.kernelConnection.id,
|
|
290
|
+
id: this.id
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}]);
|
|
294
|
+
return LibroWidgets;
|
|
295
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "WidgetViewProvider", [_dec2], {
|
|
296
|
+
configurable: true,
|
|
297
|
+
enumerable: true,
|
|
298
|
+
writable: true,
|
|
299
|
+
initializer: null
|
|
300
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "models", [_dec3], {
|
|
301
|
+
configurable: true,
|
|
302
|
+
enumerable: true,
|
|
303
|
+
writable: true,
|
|
304
|
+
initializer: function initializer() {
|
|
305
|
+
return new Map();
|
|
306
|
+
}
|
|
307
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/widget/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAsB/C,eAAO,MAAM,gBAAgB,YAoCO,CAAC;AAErC,eAAO,MAAM,YAAY,YAWI,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LibroKernelManageModule } from '@difizen/libro-kernel';
|
|
2
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
3
|
+
import { VBoxWidget, VBoxWidgetContribution } from "./box/index.js";
|
|
4
|
+
import { Comm } from "./comm.js";
|
|
5
|
+
import { InstancesProgressWidget, InstancesProgressWidgetViewContribution } from "./instance-progress/index.js";
|
|
6
|
+
import { LibroWidgets } from "./libro-widgets.js";
|
|
7
|
+
import { ProgressWidget, ProgressWidgetViewContribution } from "./progress/index.js";
|
|
8
|
+
import { LibroWidgetCommFactory, LibroWidgetsFactory, WidgetCommOption, WidgetsOption, WidgetViewContribution } from "./protocol.js";
|
|
9
|
+
import { LibroWidgetManager } from "./widget-manager.js";
|
|
10
|
+
import { LibroWidgetMimeContribution } from "./widget-rendermime-contribution.js";
|
|
11
|
+
import { DefaultWidgetViewContribution } from "./widget-view-contribution.js";
|
|
12
|
+
import { WidgetView } from "./widget-view.js";
|
|
13
|
+
export var BaseWidgetModule = ManaModule.create().contribution(WidgetViewContribution).register(Comm, {
|
|
14
|
+
token: LibroWidgetCommFactory,
|
|
15
|
+
useFactory: function useFactory(ctx) {
|
|
16
|
+
return function (options) {
|
|
17
|
+
var child = ctx.container.createChild();
|
|
18
|
+
child.register({
|
|
19
|
+
token: WidgetCommOption,
|
|
20
|
+
useValue: options
|
|
21
|
+
});
|
|
22
|
+
return child.get(Comm);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}, LibroWidgets, {
|
|
26
|
+
token: LibroWidgetsFactory,
|
|
27
|
+
useFactory: function useFactory(ctx) {
|
|
28
|
+
return function (options) {
|
|
29
|
+
var child = ctx.container.createChild();
|
|
30
|
+
child.register({
|
|
31
|
+
token: WidgetsOption,
|
|
32
|
+
useValue: options
|
|
33
|
+
});
|
|
34
|
+
return child.get(LibroWidgets);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}, LibroWidgetManager, WidgetView, DefaultWidgetViewContribution, LibroWidgetMimeContribution).dependOn(LibroKernelManageModule);
|
|
38
|
+
export var WidgetModule = ManaModule.create().register(VBoxWidget, VBoxWidgetContribution, ProgressWidget, ProgressWidgetViewContribution, InstancesProgressWidget, InstancesProgressWidgetViewContribution).dependOn(BaseWidgetModule);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
2
|
+
import type { IWidgetViewProps } from '../protocol.js';
|
|
3
|
+
import { WidgetViewContribution } from '../protocol.js';
|
|
4
|
+
import { ProgressWidget } from './view.js';
|
|
5
|
+
export declare class ProgressWidgetViewContribution implements WidgetViewContribution {
|
|
6
|
+
viewManager: ViewManager;
|
|
7
|
+
canHandle: (attributes: any) => 1 | 100;
|
|
8
|
+
factory(props: IWidgetViewProps): Promise<ProgressWidget>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../../../src/widget/progress/contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBACa,8BAA+B,YAAW,sBAAsB;IACtD,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAgB,GAAG,aAS1B;IACF,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function _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 }); }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
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); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
+
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; }
|
|
10
|
+
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.'); }
|
|
11
|
+
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
12
|
+
import { WidgetViewContribution } from "../protocol.js";
|
|
13
|
+
import { ProgressWidget } from "./view.js";
|
|
14
|
+
export var ProgressWidgetViewContribution = (_dec = singleton({
|
|
15
|
+
contrib: WidgetViewContribution
|
|
16
|
+
}), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
17
|
+
function ProgressWidgetViewContribution() {
|
|
18
|
+
_classCallCheck(this, ProgressWidgetViewContribution);
|
|
19
|
+
_initializerDefineProperty(this, "viewManager", _descriptor, this);
|
|
20
|
+
this.canHandle = function (attributes) {
|
|
21
|
+
if (attributes._model_name === 'FloatProgressModel' || attributes._model_name === 'IntProgressModel' || attributes._model_name === 'TransientProgressModel') {
|
|
22
|
+
return 100;
|
|
23
|
+
}
|
|
24
|
+
return 1;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
_createClass(ProgressWidgetViewContribution, [{
|
|
28
|
+
key: "factory",
|
|
29
|
+
value: function factory(props) {
|
|
30
|
+
return this.viewManager.getOrCreateView(ProgressWidget, props);
|
|
31
|
+
}
|
|
32
|
+
}]);
|
|
33
|
+
return ProgressWidgetViewContribution;
|
|
34
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec2], {
|
|
35
|
+
configurable: true,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
initializer: null
|
|
39
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/widget/progress/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the ProgressBar.
|
|
3
|
+
*/
|
|
4
|
+
export interface IProgressBarProps {
|
|
5
|
+
/**
|
|
6
|
+
* The current progress percentage, from 0 to 100
|
|
7
|
+
*/
|
|
8
|
+
percent: number;
|
|
9
|
+
/**
|
|
10
|
+
* Width of progress bar in pixel.
|
|
11
|
+
*/
|
|
12
|
+
width?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function ProgressBar(props: IProgressBarProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=progressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressBar.d.ts","sourceRoot":"","sources":["../../../src/widget/progress/progressBar.tsx"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,2CAYnD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Progress } from 'antd';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for the ProgressBar.
|
|
5
|
+
*/
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
+
export function ProgressBar(props) {
|
|
9
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
10
|
+
children: /*#__PURE__*/_jsx(Progress, {
|
|
11
|
+
strokeLinecap: "butt",
|
|
12
|
+
percent: props.percent,
|
|
13
|
+
strokeWidth: 18,
|
|
14
|
+
showInfo: false,
|
|
15
|
+
style: {
|
|
16
|
+
width: '200px'
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { JSONObject } from '@difizen/libro-common';
|
|
3
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
4
|
+
import type { IWidgetViewProps, WidgetState } from '../protocol.js';
|
|
5
|
+
import { WidgetView } from '../widget-view.js';
|
|
6
|
+
export declare const LibroProgressWidgetComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
interface ProgressState extends WidgetState {
|
|
8
|
+
max?: number;
|
|
9
|
+
min?: number;
|
|
10
|
+
bar_style?: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class ProgressWidget extends WidgetView {
|
|
14
|
+
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
state: JSONObject & ProgressState;
|
|
16
|
+
constructor(props: IWidgetViewProps, libroContextKey: LibroContextKey);
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/widget/progress/view.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAYtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,eAAO,MAAM,4BAA4B,0FAmBxC,CAAC;AAEF,UAAU,aAAc,SAAQ,WAAW;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AACD,qBAEa,cAAe,SAAQ,UAAU;IACnC,IAAI,2FAAgC;IAGpC,KAAK,EAAE,UAAU,GAAG,aAAa,CAKxC;gBAEoB,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe;CAS5D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _class, _class2, _descriptor;
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _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); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
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); }; }
|
|
15
|
+
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); }
|
|
16
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
17
|
+
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; } }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
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; }
|
|
20
|
+
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.'); }
|
|
21
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
22
|
+
import { view, ViewOption, transient, useInject, ViewInstance, inject, prop } from '@difizen/mana-app';
|
|
23
|
+
import { forwardRef } from 'react';
|
|
24
|
+
import { defaultWidgetState } from "../protocol.js";
|
|
25
|
+
import { WidgetView } from "../widget-view.js";
|
|
26
|
+
import { ProgressBar } from "./progressBar.js";
|
|
27
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
|
+
export var LibroProgressWidgetComponent = /*#__PURE__*/forwardRef(function LibroProgressWidgetComponent() {
|
|
30
|
+
var widgetView = useInject(ViewInstance);
|
|
31
|
+
var percent = widgetView.state.max && widgetView.state.min ? widgetView.state.value / ((widgetView.state.max - widgetView.state.min) / 100) : 0;
|
|
32
|
+
if (widgetView.isCommClosed) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
36
|
+
className: "libro-progress-widget",
|
|
37
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
38
|
+
className: "libro-progress-widget-description",
|
|
39
|
+
children: widgetView.state.description
|
|
40
|
+
}), /*#__PURE__*/_jsx(ProgressBar, {
|
|
41
|
+
percent: percent
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
export var ProgressWidget = (_dec = transient(), _dec2 = view('libro-widget-progress-view'), _dec3 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_WidgetView) {
|
|
46
|
+
_inherits(ProgressWidget, _WidgetView);
|
|
47
|
+
var _super = _createSuper(ProgressWidget);
|
|
48
|
+
function ProgressWidget(props, libroContextKey) {
|
|
49
|
+
var _this;
|
|
50
|
+
_classCallCheck(this, ProgressWidget);
|
|
51
|
+
_this = _super.call(this, props, libroContextKey);
|
|
52
|
+
_this.view = LibroProgressWidgetComponent;
|
|
53
|
+
_initializerDefineProperty(_this, "state", _descriptor, _assertThisInitialized(_this));
|
|
54
|
+
var attributes = props.attributes;
|
|
55
|
+
_this.state.max = attributes.max;
|
|
56
|
+
_this.state.min = attributes.min;
|
|
57
|
+
_this.setState(attributes);
|
|
58
|
+
return _this;
|
|
59
|
+
}
|
|
60
|
+
ProgressWidget = inject(LibroContextKey)(ProgressWidget, undefined, 1) || ProgressWidget;
|
|
61
|
+
ProgressWidget = inject(ViewOption)(ProgressWidget, undefined, 0) || ProgressWidget;
|
|
62
|
+
return _createClass(ProgressWidget);
|
|
63
|
+
}(WidgetView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "state", [_dec3], {
|
|
64
|
+
configurable: true,
|
|
65
|
+
enumerable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
initializer: function initializer() {
|
|
68
|
+
return _objectSpread(_objectSpread({}, defaultWidgetState), {}, {
|
|
69
|
+
max: 1,
|
|
70
|
+
min: 0,
|
|
71
|
+
value: 0
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
})), _class2)) || _class) || _class);
|