@difizen/libro-jupyter 0.1.32 → 0.1.34
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/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 +9 -0
- package/es/components/icons.js +1 -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 +0 -5
- package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -1
- package/es/keybind-instructions/keybind-instructions-view.js +67 -61
- package/es/module.d.ts.map +1 -1
- package/es/module.js +2 -3
- 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 +7 -0
- package/es/widget/index.d.ts.map +1 -1
- package/es/widget/index.js +8 -1
- 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.map +1 -1
- package/es/widget/widget-render.js +7 -3
- package/es/widget/widget-rendermime-contribution.d.ts +2 -1
- package/es/widget/widget-rendermime-contribution.d.ts.map +1 -1
- package/es/widget/widget-rendermime-contribution.js +2 -1
- 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 +17 -18
- package/src/cell/jupyter-code-cell-view.tsx +10 -1
- package/src/components/icons.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/keybind-instructions/index.less +0 -5
- package/src/keybind-instructions/keybind-instructions-view.tsx +70 -60
- package/src/module.ts +1 -3
- 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.ts +7 -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 +10 -5
- package/src/widget/widget-rendermime-contribution.ts +2 -1
- package/src/widget/widget-view-contribution.ts +14 -0
- package/src/widget/widget-view.tsx +259 -0
|
@@ -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);
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { JSONObject, JSONValue } from '@difizen/libro-common';
|
|
2
|
+
import type { IComm, IKernelConnection, KernelMessage } from '@difizen/libro-kernel';
|
|
3
|
+
import { Syringe } from '@difizen/mana-app';
|
|
4
|
+
import type { WidgetView } from './widget-view.js';
|
|
5
|
+
export interface IWidgetViewOptions {
|
|
6
|
+
model_id: string;
|
|
7
|
+
comm: IClassicComm;
|
|
8
|
+
}
|
|
9
|
+
export interface IWidgetViewProps {
|
|
10
|
+
attributes: any;
|
|
11
|
+
options: IWidgetViewOptions;
|
|
12
|
+
widgetsId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A simple dictionary type.
|
|
16
|
+
*/
|
|
17
|
+
export type Dict<T> = Record<string, T>;
|
|
18
|
+
export type BufferJSON = {
|
|
19
|
+
[property: string]: BufferJSON;
|
|
20
|
+
} | BufferJSON[] | string | number | boolean | null | ArrayBuffer | DataView;
|
|
21
|
+
export interface ISerializedState {
|
|
22
|
+
state: JSONObject;
|
|
23
|
+
buffers: ArrayBuffer[];
|
|
24
|
+
buffer_paths: (string | number)[][];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The widget manager interface exposed on the Widget instances
|
|
28
|
+
*/
|
|
29
|
+
export interface IWidgets {
|
|
30
|
+
getModel: (model_id: string) => WidgetView;
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if the given model is registered, otherwise false.
|
|
33
|
+
*
|
|
34
|
+
* #### Notes
|
|
35
|
+
* This is a synchronous way to check if a model is registered.
|
|
36
|
+
*/
|
|
37
|
+
hasModel: (model_id: string) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Register a model instance promise with the manager.
|
|
40
|
+
*
|
|
41
|
+
* By registering the model, it can later be retrieved with `getModel`.
|
|
42
|
+
*/
|
|
43
|
+
registerWidgetView: (model_id: string, model: Promise<WidgetView>) => void;
|
|
44
|
+
newWidgetView: (attributes: any, options: IWidgetViewOptions) => Promise<WidgetView>;
|
|
45
|
+
}
|
|
46
|
+
export declare const LibroWidgetsFactory: unique symbol;
|
|
47
|
+
export type LibroWidgetsFactory = (options: WidgetsOption) => IWidgets;
|
|
48
|
+
export declare const WidgetsOption: unique symbol;
|
|
49
|
+
export interface WidgetsOption {
|
|
50
|
+
kc: IKernelConnection;
|
|
51
|
+
id: string;
|
|
52
|
+
}
|
|
53
|
+
export interface IWidgetView {
|
|
54
|
+
toJSON: () => string;
|
|
55
|
+
setState: (state: Dict<unknown>) => void;
|
|
56
|
+
handleCommMsg: (msg: KernelMessage.ICommMsgMsg) => Promise<void>;
|
|
57
|
+
model_id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
module: string;
|
|
60
|
+
model_module: string;
|
|
61
|
+
model_name: string;
|
|
62
|
+
model_module_version: string;
|
|
63
|
+
view_module: string;
|
|
64
|
+
view_name: string | null;
|
|
65
|
+
view_module_version: string;
|
|
66
|
+
view_count: number | null;
|
|
67
|
+
}
|
|
68
|
+
export declare const IWidgetView: unique symbol;
|
|
69
|
+
export declare const WidgetViewContribution: Syringe.DefinedToken;
|
|
70
|
+
export interface WidgetViewContribution {
|
|
71
|
+
canHandle: (attributes: any) => number;
|
|
72
|
+
factory: (props: IWidgetViewProps) => Promise<WidgetView>;
|
|
73
|
+
}
|
|
74
|
+
export interface InstanceRecord {
|
|
75
|
+
startDate: number;
|
|
76
|
+
endDate: number;
|
|
77
|
+
}
|
|
78
|
+
interface Stage {
|
|
79
|
+
name: string;
|
|
80
|
+
backup_workers: number;
|
|
81
|
+
terminated_workers: number;
|
|
82
|
+
running_workers: number;
|
|
83
|
+
total_workers: number;
|
|
84
|
+
input_records: number;
|
|
85
|
+
output_records: number;
|
|
86
|
+
finished_percentage: number;
|
|
87
|
+
}
|
|
88
|
+
export interface Task {
|
|
89
|
+
name: string;
|
|
90
|
+
status: 'WAITING' | 'RUNNING' | 'SUCCESS' | 'FAILED' | 'SUSPENDED' | 'CANCELLED';
|
|
91
|
+
stages: Stage[];
|
|
92
|
+
}
|
|
93
|
+
export interface ProgressInstance {
|
|
94
|
+
id: string;
|
|
95
|
+
status: 'Running' | 'Suspended' | 'Terminated';
|
|
96
|
+
logview: string;
|
|
97
|
+
tasks: Task[];
|
|
98
|
+
}
|
|
99
|
+
export interface ProgressItem {
|
|
100
|
+
name: string;
|
|
101
|
+
key: string;
|
|
102
|
+
gen_time: string;
|
|
103
|
+
logView: string;
|
|
104
|
+
instances?: ProgressInstance[];
|
|
105
|
+
}
|
|
106
|
+
export type InstancesRecords = Record<string, InstanceRecord>;
|
|
107
|
+
/**
|
|
108
|
+
* Callbacks for services shim comms.
|
|
109
|
+
*/
|
|
110
|
+
export interface ICallbacks {
|
|
111
|
+
shell?: Record<string, (msg: KernelMessage.IShellMessage) => void>;
|
|
112
|
+
iopub?: Record<string, (msg: KernelMessage.IIOPubMessage) => void>;
|
|
113
|
+
input?: (msg: KernelMessage.IStdinMessage) => void;
|
|
114
|
+
}
|
|
115
|
+
export declare const LibroWidgetCommFactory: unique symbol;
|
|
116
|
+
export type LibroWidgetCommFactory = (options: WidgetCommOption) => IClassicComm;
|
|
117
|
+
export declare const WidgetCommOption: unique symbol;
|
|
118
|
+
export interface WidgetCommOption {
|
|
119
|
+
comm: IComm;
|
|
120
|
+
}
|
|
121
|
+
export interface IClassicComm {
|
|
122
|
+
/**
|
|
123
|
+
* Comm id
|
|
124
|
+
* @return {string}
|
|
125
|
+
*/
|
|
126
|
+
comm_id: string;
|
|
127
|
+
/**
|
|
128
|
+
* Target name
|
|
129
|
+
* @return {string}
|
|
130
|
+
*/
|
|
131
|
+
target_name: string;
|
|
132
|
+
/**
|
|
133
|
+
* Opens a sibling comm in the backend
|
|
134
|
+
* @param data
|
|
135
|
+
* @param callbacks
|
|
136
|
+
* @param metadata
|
|
137
|
+
* @param buffers
|
|
138
|
+
* @return msg id
|
|
139
|
+
*/
|
|
140
|
+
open(data: JSONValue, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
|
|
141
|
+
/**
|
|
142
|
+
* Sends a message to the sibling comm in the backend
|
|
143
|
+
* @param data
|
|
144
|
+
* @param callbacks
|
|
145
|
+
* @param metadata
|
|
146
|
+
* @param buffers
|
|
147
|
+
* @return message id
|
|
148
|
+
*/
|
|
149
|
+
send(data: JSONValue, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
|
|
150
|
+
/**
|
|
151
|
+
* Closes the sibling comm in the backend
|
|
152
|
+
* @param data
|
|
153
|
+
* @param callbacks
|
|
154
|
+
* @param metadata
|
|
155
|
+
* @param buffers
|
|
156
|
+
* @return msg id
|
|
157
|
+
*/
|
|
158
|
+
close(data?: JSONValue, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
|
|
159
|
+
/**
|
|
160
|
+
* Register a message handler
|
|
161
|
+
* @param callback, which is given a message
|
|
162
|
+
*/
|
|
163
|
+
onMsg(callback: (x: any) => void): void;
|
|
164
|
+
/**
|
|
165
|
+
* Register a handler for when the comm is closed by the backend
|
|
166
|
+
* @param callback, which is given a message
|
|
167
|
+
*/
|
|
168
|
+
onClose(callback: (x: any) => void): void;
|
|
169
|
+
}
|
|
170
|
+
export interface WidgetState {
|
|
171
|
+
msg_id?: string;
|
|
172
|
+
behavior?: string;
|
|
173
|
+
continuous_update: boolean;
|
|
174
|
+
description: string;
|
|
175
|
+
description_allow_html: boolean;
|
|
176
|
+
disabled: boolean;
|
|
177
|
+
layout?: string;
|
|
178
|
+
readout: boolean;
|
|
179
|
+
readout_format: string;
|
|
180
|
+
style?: string;
|
|
181
|
+
[key: string]: any;
|
|
182
|
+
}
|
|
183
|
+
export declare const defaultWidgetState: WidgetState;
|
|
184
|
+
export interface FormattableState {
|
|
185
|
+
readout: boolean;
|
|
186
|
+
readout_format: string;
|
|
187
|
+
}
|
|
188
|
+
export declare const defaultFormattableState: FormattableState;
|
|
189
|
+
export interface OrientableState {
|
|
190
|
+
orientation: 'horizontal' | 'vertical';
|
|
191
|
+
}
|
|
192
|
+
export {};
|
|
193
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/widget/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAExC,MAAM,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+1,33 @@
|
|
|
1
|
+
import { Syringe } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simple dictionary type.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The widget manager interface exposed on the Widget instances
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export var LibroWidgetsFactory = Symbol('LibroWidgetsFactory');
|
|
12
|
+
export var WidgetsOption = Symbol('WidgetsOption');
|
|
13
|
+
export var IWidgetView = Symbol('IWidgetView');
|
|
14
|
+
export var WidgetViewContribution = Syringe.defineToken('WidgetViewContribution');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Callbacks for services shim comms.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export var LibroWidgetCommFactory = Symbol('LibroWidgetCommFactory');
|
|
21
|
+
export var WidgetCommOption = Symbol('WidgetCommOption');
|
|
22
|
+
export var defaultWidgetState = {
|
|
23
|
+
continuous_update: false,
|
|
24
|
+
description_allow_html: false,
|
|
25
|
+
description: '',
|
|
26
|
+
disabled: false,
|
|
27
|
+
readout: true,
|
|
28
|
+
readout_format: 'd'
|
|
29
|
+
};
|
|
30
|
+
export var defaultFormattableState = {
|
|
31
|
+
readout: true,
|
|
32
|
+
readout_format: 'd'
|
|
33
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BufferJSON, Dict } from './protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* Takes an object 'state' and fills in buffer[i] at 'path' buffer_paths[i]
|
|
4
|
+
* where buffer_paths[i] is a list indicating where in the object buffer[i] should
|
|
5
|
+
* be placed
|
|
6
|
+
* Example: state = {a: 1, b: {}, c: [0, null]}
|
|
7
|
+
* buffers = [array1, array2]
|
|
8
|
+
* buffer_paths = [['b', 'data'], ['c', 1]]
|
|
9
|
+
* Will lead to {a: 1, b: {data: array1}, c: [0, array2]}
|
|
10
|
+
*/
|
|
11
|
+
export declare function put_buffers(state: Dict<BufferJSON>, buffer_paths: (string | number)[][], buffers: (DataView | ArrayBuffer | ArrayBufferView | {
|
|
12
|
+
buffer: ArrayBuffer;
|
|
13
|
+
})[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a wrappable Promise rejection function.
|
|
16
|
+
*
|
|
17
|
+
* Creates a function that logs an error message before rethrowing
|
|
18
|
+
* the original error that caused the promise to reject.
|
|
19
|
+
*/
|
|
20
|
+
export declare function reject(message: string, log: boolean): (error: Error) => never;
|
|
21
|
+
/**
|
|
22
|
+
* A polyfill for Object.assign
|
|
23
|
+
*
|
|
24
|
+
* This is from code that Typescript 2.4 generates for a polyfill.
|
|
25
|
+
*/
|
|
26
|
+
export declare const assign: any;
|
|
27
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/widget/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EACvB,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,EACnC,OAAO,EAAE,CAAC,QAAQ,GAAG,WAAW,GAAG,eAAe,GAAG;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC,EAAE,GAC9E,IAAI,CAiBN;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,WACV,KAAK,KAAG,KAAK,CAMtD;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,KAYhB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes an object 'state' and fills in buffer[i] at 'path' buffer_paths[i]
|
|
3
|
+
* where buffer_paths[i] is a list indicating where in the object buffer[i] should
|
|
4
|
+
* be placed
|
|
5
|
+
* Example: state = {a: 1, b: {}, c: [0, null]}
|
|
6
|
+
* buffers = [array1, array2]
|
|
7
|
+
* buffer_paths = [['b', 'data'], ['c', 1]]
|
|
8
|
+
* Will lead to {a: 1, b: {data: array1}, c: [0, array2]}
|
|
9
|
+
*/
|
|
10
|
+
export function put_buffers(state, buffer_paths, buffers) {
|
|
11
|
+
for (var i = 0; i < buffer_paths.length; i++) {
|
|
12
|
+
var buffer_path = buffer_paths[i];
|
|
13
|
+
// make sure the buffers are DataViews
|
|
14
|
+
var buffer = buffers[i];
|
|
15
|
+
if (!(buffer instanceof DataView)) {
|
|
16
|
+
buffer = new DataView(buffer instanceof ArrayBuffer ? buffer : buffer.buffer);
|
|
17
|
+
}
|
|
18
|
+
// say we want to set state[x][y][z] = buffer
|
|
19
|
+
var obj = state;
|
|
20
|
+
// we first get obj = state[x][y]
|
|
21
|
+
for (var j = 0; j < buffer_path.length - 1; j++) {
|
|
22
|
+
obj = obj[buffer_path[j]];
|
|
23
|
+
}
|
|
24
|
+
// and then set: obj[z] = buffer
|
|
25
|
+
obj[buffer_path[buffer_path.length - 1]] = buffer;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates a wrappable Promise rejection function.
|
|
31
|
+
*
|
|
32
|
+
* Creates a function that logs an error message before rethrowing
|
|
33
|
+
* the original error that caused the promise to reject.
|
|
34
|
+
*/
|
|
35
|
+
export function reject(message, log) {
|
|
36
|
+
return function promiseRejection(error) {
|
|
37
|
+
if (log) {
|
|
38
|
+
console.error(new Error(message));
|
|
39
|
+
}
|
|
40
|
+
throw error;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A polyfill for Object.assign
|
|
46
|
+
*
|
|
47
|
+
* This is from code that Typescript 2.4 generates for a polyfill.
|
|
48
|
+
*/
|
|
49
|
+
export var assign = Object.assign || function (t) {
|
|
50
|
+
for (var i = 1; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
|
51
|
+
var s = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
|
|
52
|
+
for (var p in s) {
|
|
53
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) {
|
|
54
|
+
t[p] = s[p];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/widget/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAC7C,eAAO,MAAM,gBAAgB,UAAU,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LibroService } from '@difizen/libro-core';
|
|
2
|
+
import type { IKernelConnection } from '@difizen/libro-kernel';
|
|
3
|
+
import { LibroKernelManager } from '@difizen/libro-kernel';
|
|
4
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
5
|
+
import type { LibroWidgets } from './libro-widgets.js';
|
|
6
|
+
import type { WidgetsOption } from './protocol.js';
|
|
7
|
+
export declare class LibroWidgetManager implements ApplicationContribution {
|
|
8
|
+
widgetsFactory: (options: WidgetsOption) => LibroWidgets;
|
|
9
|
+
kernelManager: LibroKernelManager;
|
|
10
|
+
libroService: LibroService;
|
|
11
|
+
initialize: () => void;
|
|
12
|
+
getOrCreateWidgets: (kc: IKernelConnection) => LibroWidgets;
|
|
13
|
+
getWidgets(id: string): LibroWidgets | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Dictionary of model ids and model instance promises
|
|
16
|
+
*/
|
|
17
|
+
protected widgets: Map<string, LibroWidgets>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=widget-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-manager.d.ts","sourceRoot":"","sources":["../../src/widget/widget-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAoB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAA2B,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,qBACa,kBAAmB,YAAW,uBAAuB;IACnC,cAAc,EAAG,CAC5C,OAAO,EAAE,aAAa,KACnB,YAAY,CAAC;IACU,aAAa,EAAE,kBAAkB,CAAC;IACxC,YAAY,EAAE,YAAY,CAAC;IAEjD,UAAU,aAMR;IAEF,kBAAkB,OAAQ,iBAAiB,kBAQzC;IAEF,UAAU,CAAC,EAAE,EAAE,MAAM;IAIrB;;OAEG;IAEH,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAa;CAC1D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
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 { LibroService } from '@difizen/libro-core';
|
|
12
|
+
import { KernelConnection, LibroKernelManager } from '@difizen/libro-kernel';
|
|
13
|
+
import { inject, prop, singleton, ApplicationContribution } from '@difizen/mana-app';
|
|
14
|
+
import { LibroWidgetsFactory } from "./protocol.js";
|
|
15
|
+
export var LibroWidgetManager = (_dec = singleton({
|
|
16
|
+
contrib: ApplicationContribution
|
|
17
|
+
}), _dec2 = inject(LibroWidgetsFactory), _dec3 = inject(LibroKernelManager), _dec4 = inject(LibroService), _dec5 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
18
|
+
function LibroWidgetManager() {
|
|
19
|
+
var _this = this;
|
|
20
|
+
_classCallCheck(this, LibroWidgetManager);
|
|
21
|
+
_initializerDefineProperty(this, "widgetsFactory", _descriptor, this);
|
|
22
|
+
_initializerDefineProperty(this, "kernelManager", _descriptor2, this);
|
|
23
|
+
_initializerDefineProperty(this, "libroService", _descriptor3, this);
|
|
24
|
+
this.initialize = function () {
|
|
25
|
+
_this.kernelManager.onConnectToKernel(function (kc) {
|
|
26
|
+
if (kc instanceof KernelConnection) {
|
|
27
|
+
_this.getOrCreateWidgets(kc);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
this.getOrCreateWidgets = function (kc) {
|
|
32
|
+
var widgets = _this.widgets.get(kc.id);
|
|
33
|
+
if (widgets) {
|
|
34
|
+
return widgets;
|
|
35
|
+
}
|
|
36
|
+
var newWidgets = _this.widgetsFactory({
|
|
37
|
+
kc: kc,
|
|
38
|
+
id: kc.id
|
|
39
|
+
});
|
|
40
|
+
_this.widgets.set(kc.id, newWidgets);
|
|
41
|
+
return newWidgets;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Dictionary of model ids and model instance promises
|
|
45
|
+
*/
|
|
46
|
+
_initializerDefineProperty(this, "widgets", _descriptor4, this);
|
|
47
|
+
}
|
|
48
|
+
_createClass(LibroWidgetManager, [{
|
|
49
|
+
key: "getWidgets",
|
|
50
|
+
value: function getWidgets(id) {
|
|
51
|
+
return this.widgets.get(id);
|
|
52
|
+
}
|
|
53
|
+
}]);
|
|
54
|
+
return LibroWidgetManager;
|
|
55
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "widgetsFactory", [_dec2], {
|
|
56
|
+
configurable: true,
|
|
57
|
+
enumerable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
initializer: null
|
|
60
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "kernelManager", [_dec3], {
|
|
61
|
+
configurable: true,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
initializer: null
|
|
65
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "libroService", [_dec4], {
|
|
66
|
+
configurable: true,
|
|
67
|
+
enumerable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
initializer: null
|
|
70
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "widgets", [_dec5], {
|
|
71
|
+
configurable: true,
|
|
72
|
+
enumerable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
initializer: function initializer() {
|
|
75
|
+
return new Map();
|
|
76
|
+
}
|
|
77
|
+
})), _class2)) || _class);
|