@difizen/libro-widget 0.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/es/base/comm.d.ts +65 -0
  4. package/es/base/comm.d.ts.map +1 -0
  5. package/es/base/comm.js +151 -0
  6. package/es/base/index.d.ts +7 -0
  7. package/es/base/index.d.ts.map +1 -0
  8. package/es/base/index.js +6 -0
  9. package/es/base/libro-widgets.d.ts +79 -0
  10. package/es/base/libro-widgets.d.ts.map +1 -0
  11. package/es/base/libro-widgets.js +285 -0
  12. package/es/base/protocal.d.ts +171 -0
  13. package/es/base/protocal.d.ts.map +1 -0
  14. package/es/base/protocal.js +21 -0
  15. package/es/base/utils.d.ts +27 -0
  16. package/es/base/utils.d.ts.map +1 -0
  17. package/es/base/utils.js +59 -0
  18. package/es/base/version.d.ts +3 -0
  19. package/es/base/version.d.ts.map +1 -0
  20. package/es/base/version.js +2 -0
  21. package/es/base/widget-manager.d.ts +18 -0
  22. package/es/base/widget-manager.d.ts.map +1 -0
  23. package/es/base/widget-manager.js +68 -0
  24. package/es/base/widget-view-contribution.d.ts +10 -0
  25. package/es/base/widget-view-contribution.d.ts.map +1 -0
  26. package/es/base/widget-view-contribution.js +36 -0
  27. package/es/base/widget-view.d.ts +52 -0
  28. package/es/base/widget-view.d.ts.map +1 -0
  29. package/es/base/widget-view.js +137 -0
  30. package/es/components/index.d.ts +3 -0
  31. package/es/components/index.d.ts.map +1 -0
  32. package/es/components/index.js +2 -0
  33. package/es/components/progressBar.d.ts +15 -0
  34. package/es/components/progressBar.d.ts.map +1 -0
  35. package/es/components/progressBar.js +20 -0
  36. package/es/components/progressCircle.d.ts +11 -0
  37. package/es/components/progressCircle.d.ts.map +1 -0
  38. package/es/components/progressCircle.js +16 -0
  39. package/es/index.d.ts +5 -0
  40. package/es/index.d.ts.map +1 -0
  41. package/es/index.js +4 -0
  42. package/es/widget-module.d.ts +3 -0
  43. package/es/widget-module.d.ts.map +1 -0
  44. package/es/widget-module.js +39 -0
  45. package/es/widgets/hbox-widget-view-contribution.d.ts +10 -0
  46. package/es/widgets/hbox-widget-view-contribution.d.ts.map +1 -0
  47. package/es/widgets/hbox-widget-view-contribution.js +39 -0
  48. package/es/widgets/hbox-widget-view.d.ts +17 -0
  49. package/es/widgets/hbox-widget-view.d.ts.map +1 -0
  50. package/es/widgets/hbox-widget-view.js +69 -0
  51. package/es/widgets/index.d.ts +9 -0
  52. package/es/widgets/index.d.ts.map +1 -0
  53. package/es/widgets/index.js +8 -0
  54. package/es/widgets/index.less +3 -0
  55. package/es/widgets/instances-progress-widget-view-contribution.d.ts +10 -0
  56. package/es/widgets/instances-progress-widget-view-contribution.d.ts.map +1 -0
  57. package/es/widgets/instances-progress-widget-view-contribution.js +39 -0
  58. package/es/widgets/instances-progress-widget-view.d.ts +31 -0
  59. package/es/widgets/instances-progress-widget-view.d.ts.map +1 -0
  60. package/es/widgets/instances-progress-widget-view.js +181 -0
  61. package/es/widgets/progress-widget-view-contribution.d.ts +10 -0
  62. package/es/widgets/progress-widget-view-contribution.d.ts.map +1 -0
  63. package/es/widgets/progress-widget-view-contribution.js +39 -0
  64. package/es/widgets/progress-widget-view.d.ts +25 -0
  65. package/es/widgets/progress-widget-view.d.ts.map +1 -0
  66. package/es/widgets/progress-widget-view.js +103 -0
  67. package/es/widgets/text-widget-view-contribution.d.ts +10 -0
  68. package/es/widgets/text-widget-view-contribution.d.ts.map +1 -0
  69. package/es/widgets/text-widget-view-contribution.js +39 -0
  70. package/es/widgets/text-widget-view.d.ts +19 -0
  71. package/es/widgets/text-widget-view.d.ts.map +1 -0
  72. package/es/widgets/text-widget-view.js +91 -0
  73. package/package.json +60 -0
  74. package/src/base/comm.ts +152 -0
  75. package/src/base/index.ts +6 -0
  76. package/src/base/libro-widgets.ts +207 -0
  77. package/src/base/protocal.ts +218 -0
  78. package/src/base/utils.ts +67 -0
  79. package/src/base/version.ts +2 -0
  80. package/src/base/widget-manager.ts +41 -0
  81. package/src/base/widget-view-contribution.ts +14 -0
  82. package/src/base/widget-view.tsx +146 -0
  83. package/src/components/index.ts +3 -0
  84. package/src/components/progressBar.tsx +29 -0
  85. package/src/components/progressCircle.tsx +18 -0
  86. package/src/index.ts +4 -0
  87. package/src/widget-module.ts +68 -0
  88. package/src/widgets/hbox-widget-view-contribution.ts +20 -0
  89. package/src/widgets/hbox-widget-view.tsx +64 -0
  90. package/src/widgets/index.less +3 -0
  91. package/src/widgets/index.ts +8 -0
  92. package/src/widgets/instances-progress-widget-view-contribution.ts +20 -0
  93. package/src/widgets/instances-progress-widget-view.tsx +160 -0
  94. package/src/widgets/progress-widget-view-contribution.ts +24 -0
  95. package/src/widgets/progress-widget-view.tsx +85 -0
  96. package/src/widgets/text-widget-view-contribution.ts +20 -0
  97. package/src/widgets/text-widget-view.tsx +83 -0
@@ -0,0 +1,3 @@
1
+ export * from './progressBar.js';
2
+ export * from './progressCircle.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAEjC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./progressBar.js";
2
+ export * from "./progressCircle.js";
@@ -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/components/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,11 @@
1
+ /**
2
+ * Props for the ProgressBar.
3
+ */
4
+ export interface IProgressCircleProps {
5
+ /**
6
+ * The current progress percentage, from 0 to 100
7
+ */
8
+ percent: number;
9
+ }
10
+ export declare function ProgressCircle(props: IProgressCircleProps): import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=progressCircle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progressCircle.d.ts","sourceRoot":"","sources":["../../src/components/progressCircle.tsx"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,oBAAoB,2CAMzD"}
@@ -0,0 +1,16 @@
1
+ import { Progress } from 'antd';
2
+ /**
3
+ * Props for the ProgressBar.
4
+ */
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { Fragment as _Fragment } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ export function ProgressCircle(props) {
9
+ return /*#__PURE__*/_jsxs(_Fragment, {
10
+ children: [/*#__PURE__*/_jsx(Progress, {
11
+ strokeLinecap: "butt",
12
+ type: "circle",
13
+ percent: props.percent
14
+ }), ";"]
15
+ });
16
+ }
package/es/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './components/index.js';
2
+ export * from './base/index.js';
3
+ export * from './widget-module.js';
4
+ export * from './widgets/index.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
package/es/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./components/index.js";
2
+ export * from "./base/index.js";
3
+ export * from "./widget-module.js";
4
+ export * from "./widgets/index.js";
@@ -0,0 +1,3 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ export declare const WidgetModule: ManaModule;
3
+ //# sourceMappingURL=widget-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-module.d.ts","sourceRoot":"","sources":["../src/widget-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAuB/C,eAAO,MAAM,YAAY,YA2CW,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { LibroKernelManageModule } from '@difizen/libro-kernel';
2
+ import { ManaModule } from '@difizen/mana-app';
3
+ import { Comm } from "./base/comm.js";
4
+ import { WidgetsOption, LibroWidgetCommFactory, WidgetCommOption, LibroWidgets, LibroWidgetsFactory, WidgetView, WidgetViewContribution } from "./base/index.js";
5
+ import { LibroWidgetManager } from "./base/widget-manager.js";
6
+ import { DefaultWidgetViewContribution } from "./base/widget-view-contribution.js";
7
+ import { HBoxModelContribution } from "./widgets/hbox-widget-view-contribution.js";
8
+ import { HBoxWidget } from "./widgets/hbox-widget-view.js";
9
+ import { ProgressWidget } from "./widgets/index.js";
10
+ import { InstancesProgressWidgetViewContribution } from "./widgets/instances-progress-widget-view-contribution.js";
11
+ import { InstancesProgressWidget } from "./widgets/instances-progress-widget-view.js";
12
+ import { ProgressWidgetViewContribution } from "./widgets/progress-widget-view-contribution.js";
13
+ import { TextModelContribution } from "./widgets/text-widget-view-contribution.js";
14
+ import { LibroTextWidget } from "./widgets/text-widget-view.js";
15
+ export var WidgetModule = ManaModule.create().contribution(WidgetViewContribution).register(Comm, {
16
+ token: LibroWidgetCommFactory,
17
+ useFactory: function useFactory(ctx) {
18
+ return function (options) {
19
+ var child = ctx.container.createChild();
20
+ child.register({
21
+ token: WidgetCommOption,
22
+ useValue: options
23
+ });
24
+ return child.get(Comm);
25
+ };
26
+ }
27
+ }, LibroWidgets, {
28
+ token: LibroWidgetsFactory,
29
+ useFactory: function useFactory(ctx) {
30
+ return function (options) {
31
+ var child = ctx.container.createChild();
32
+ child.register({
33
+ token: WidgetsOption,
34
+ useValue: options
35
+ });
36
+ return child.get(LibroWidgets);
37
+ };
38
+ }
39
+ }, LibroWidgetManager, WidgetView, ProgressWidget, DefaultWidgetViewContribution, ProgressWidgetViewContribution, InstancesProgressWidgetViewContribution, InstancesProgressWidget, HBoxModelContribution, HBoxWidget, LibroTextWidget, TextModelContribution).dependOn(LibroKernelManageModule);
@@ -0,0 +1,10 @@
1
+ import { ViewManager } from '@difizen/mana-app';
2
+ import type { IWidgetViewProps } from '../base/protocal.js';
3
+ import { WidgetViewContribution } from '../base/protocal.js';
4
+ import { HBoxWidget } from './hbox-widget-view.js';
5
+ export declare class HBoxModelContribution implements WidgetViewContribution {
6
+ viewManager: ViewManager;
7
+ canHandle: (attributes: any) => 1 | 100;
8
+ factory(props: IWidgetViewProps): Promise<HBoxWidget>;
9
+ }
10
+ //# sourceMappingURL=hbox-widget-view-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hbox-widget-view-contribution.d.ts","sourceRoot":"","sources":["../../src/widgets/hbox-widget-view-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,qBACa,qBAAsB,YAAW,sBAAsB;IAC7C,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAgB,GAAG,aAK1B;IACF,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -0,0 +1,39 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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 "../base/protocal.js";
13
+ import { HBoxWidget } from "./hbox-widget-view.js";
14
+ export var HBoxModelContribution = (_dec = singleton({
15
+ contrib: WidgetViewContribution
16
+ }), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
17
+ function HBoxModelContribution() {
18
+ _classCallCheck(this, HBoxModelContribution);
19
+ _initializerDefineProperty(this, "viewManager", _descriptor, this);
20
+ this.canHandle = function (attributes) {
21
+ if (attributes._model_name === 'HBoxModel') {
22
+ return 100;
23
+ }
24
+ return 1;
25
+ };
26
+ }
27
+ _createClass(HBoxModelContribution, [{
28
+ key: "factory",
29
+ value: function factory(props) {
30
+ return this.viewManager.getOrCreateView(HBoxWidget, props);
31
+ }
32
+ }]);
33
+ return HBoxModelContribution;
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,17 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import type { IWidgetViewProps } from '../base/protocal.js';
3
+ import { WidgetView } from '../base/widget-view.js';
4
+ import './index.less';
5
+ import { LibroWidgets } from '../base/libro-widgets.js';
6
+ import { LirboContextKey } from '@difizen/libro-core';
7
+ export declare const HBoxWidgetComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
8
+ export declare class HBoxWidget extends WidgetView {
9
+ view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
10
+ children: string[];
11
+ layout: string;
12
+ box_style: string;
13
+ libroWidgets: LibroWidgets;
14
+ constructor(props: IWidgetViewProps, lirboContextKey: LirboContextKey, libroWidgets: LibroWidgets);
15
+ get_child_model(): WidgetView[];
16
+ }
17
+ //# sourceMappingURL=hbox-widget-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hbox-widget-view.d.ts","sourceRoot":"","sources":["../../src/widgets/hbox-widget-view.tsx"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,mBAAmB,0FAe/B,CAAC;AACF,qBAEa,UAAW,SAAQ,UAAU;IAC/B,IAAI,2FAAuB;IACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IACT,YAAY,EAAE,YAAY,CAAC;gBAEd,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe,EACnC,YAAY,EAAE,YAAY;IAUlD,eAAe,IAAI,UAAU,EAAE;CAShC"}
@@ -0,0 +1,69 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _dec, _dec2, _class;
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
9
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
12
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
+ import { view, ViewOption, ViewRender, transient, useInject, ViewInstance, inject } from '@difizen/mana-app';
16
+ import { forwardRef } from 'react';
17
+ import { WidgetView } from "../base/widget-view.js";
18
+ import "./index.less";
19
+ import { LibroWidgets } from "../base/libro-widgets.js";
20
+ import { LirboContextKey } from '@difizen/libro-core';
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ export var HBoxWidgetComponent = /*#__PURE__*/forwardRef(function HBoxWidgetComponent() {
23
+ var widgetView = useInject(ViewInstance);
24
+ if (widgetView.isCommClosed) {
25
+ return null;
26
+ }
27
+ var hboxChildrenWidget = widgetView.get_child_model();
28
+ return /*#__PURE__*/_jsx("div", {
29
+ className: "libro-hbox-widget",
30
+ children: hboxChildrenWidget.map(function (childrenWidgets) {
31
+ return /*#__PURE__*/_jsx(ViewRender, {
32
+ view: childrenWidgets
33
+ }, childrenWidgets.id);
34
+ })
35
+ });
36
+ });
37
+ export var HBoxWidget = (_dec = transient(), _dec2 = view('libro-hbox-widget-view'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_WidgetView) {
38
+ _inherits(HBoxWidget, _WidgetView);
39
+ var _super = _createSuper(HBoxWidget);
40
+ function HBoxWidget(props, lirboContextKey, libroWidgets) {
41
+ var _this;
42
+ _classCallCheck(this, HBoxWidget);
43
+ _this = _super.call(this, props, lirboContextKey);
44
+ _this.view = HBoxWidgetComponent;
45
+ _this.box_style = props.attributes.bar_style;
46
+ _this.layout = props.attributes.layout;
47
+ _this.children = props.attributes.children;
48
+ _this.lirboContextKey = lirboContextKey;
49
+ _this.libroWidgets = libroWidgets;
50
+ return _this;
51
+ }
52
+ HBoxWidget = inject(LibroWidgets)(HBoxWidget, undefined, 2) || HBoxWidget;
53
+ HBoxWidget = inject(LirboContextKey)(HBoxWidget, undefined, 1) || HBoxWidget;
54
+ HBoxWidget = inject(ViewOption)(HBoxWidget, undefined, 0) || HBoxWidget;
55
+ _createClass(HBoxWidget, [{
56
+ key: "get_child_model",
57
+ value: function get_child_model() {
58
+ var _this2 = this;
59
+ var childrenWidgets = [];
60
+ this.children.forEach(function (child) {
61
+ if (_this2.libroWidgets.hasModel(child.substring(10))) {
62
+ childrenWidgets.push(_this2.libroWidgets.getModel(child.substring(10)));
63
+ }
64
+ });
65
+ return childrenWidgets;
66
+ }
67
+ }]);
68
+ return HBoxWidget;
69
+ }(WidgetView)) || _class) || _class);
@@ -0,0 +1,9 @@
1
+ export * from './hbox-widget-view.js';
2
+ export * from './hbox-widget-view-contribution.js';
3
+ export * from './instances-progress-widget-view.js';
4
+ export * from './instances-progress-widget-view-contribution.js';
5
+ export * from './progress-widget-view.js';
6
+ export * from './progress-widget-view-contribution.js';
7
+ export * from './text-widget-view.js';
8
+ export * from './text-widget-view-contribution.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/widgets/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kDAAkD,CAAC;AACjE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wCAAwC,CAAC;AACvD,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./hbox-widget-view.js";
2
+ export * from "./hbox-widget-view-contribution.js";
3
+ export * from "./instances-progress-widget-view.js";
4
+ export * from "./instances-progress-widget-view-contribution.js";
5
+ export * from "./progress-widget-view.js";
6
+ export * from "./progress-widget-view-contribution.js";
7
+ export * from "./text-widget-view.js";
8
+ export * from "./text-widget-view-contribution.js";
@@ -0,0 +1,3 @@
1
+ .libro-input-widget {
2
+ display: flex;
3
+ }
@@ -0,0 +1,10 @@
1
+ import { ViewManager } from '@difizen/mana-app';
2
+ import type { IWidgetViewProps } from '../base/protocal.js';
3
+ import { WidgetViewContribution } from '../base/protocal.js';
4
+ import { InstancesProgressWidget } from './instances-progress-widget-view.js';
5
+ export declare class InstancesProgressWidgetViewContribution implements WidgetViewContribution {
6
+ viewManager: ViewManager;
7
+ canHandle: (attributes: any) => 1 | 100;
8
+ factory(props: IWidgetViewProps): Promise<InstancesProgressWidget>;
9
+ }
10
+ //# sourceMappingURL=instances-progress-widget-view-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances-progress-widget-view-contribution.d.ts","sourceRoot":"","sources":["../../src/widgets/instances-progress-widget-view-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,qBACa,uCAAwC,YAAW,sBAAsB;IAC/D,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAgB,GAAG,aAK1B;IACF,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -0,0 +1,39 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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 "../base/protocal.js";
13
+ import { InstancesProgressWidget } from "./instances-progress-widget-view.js";
14
+ export var InstancesProgressWidgetViewContribution = (_dec = singleton({
15
+ contrib: WidgetViewContribution
16
+ }), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
17
+ function InstancesProgressWidgetViewContribution() {
18
+ _classCallCheck(this, InstancesProgressWidgetViewContribution);
19
+ _initializerDefineProperty(this, "viewManager", _descriptor, this);
20
+ this.canHandle = function (attributes) {
21
+ if (attributes._model_name === 'InstancesProgressModel') {
22
+ return 100;
23
+ }
24
+ return 1;
25
+ };
26
+ }
27
+ _createClass(InstancesProgressWidgetViewContribution, [{
28
+ key: "factory",
29
+ value: function factory(props) {
30
+ return this.viewManager.getOrCreateView(InstancesProgressWidget, props);
31
+ }
32
+ }]);
33
+ return InstancesProgressWidgetViewContribution;
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,31 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import { LirboContextKey } from '@difizen/libro-core';
3
+ import type { KernelMessage } from '@difizen/libro-kernel';
4
+ import type { InstancesRecords, ProgressItem } from '../base/protocal.js';
5
+ import type { IWidgetViewProps } from '../base/protocal.js';
6
+ import { WidgetView } from '../base/widget-view.js';
7
+ import './index.less';
8
+ export interface ProgressOverviewProps {
9
+ progressMap: Record<string, ProgressItem>;
10
+ workingProgressKeys: string[];
11
+ prefix: string;
12
+ suffix: string;
13
+ }
14
+ export declare const LibroInstancesProgressWidgetViewComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
15
+ export declare class InstancesProgressWidget extends WidgetView {
16
+ view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
17
+ prefix: string;
18
+ suffix: string;
19
+ progressMap: Record<string, ProgressItem>;
20
+ workingProgressKeys: string[];
21
+ instanceRecords: InstancesRecords;
22
+ modalVisible: boolean;
23
+ modalProgressItemKey: string;
24
+ constructor(props: IWidgetViewProps, lirboContextKey: LirboContextKey);
25
+ updateRecords(progressKey: string): void;
26
+ /**
27
+ * Handle incoming comm msg.
28
+ */
29
+ handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void>;
30
+ }
31
+ //# sourceMappingURL=instances-progress-widget-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances-progress-widget-view.d.ts","sourceRoot":"","sources":["../../src/widgets/instances-progress-widget-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAY3D,OAAO,KAAK,EAEV,gBAAgB,EAChB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,yCAAyC,0FA2BrD,CAAC;AACF,qBAEa,uBAAwB,SAAQ,UAAU;IAC5C,IAAI,2FAA6C;IAE1D,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;IAC/C,mBAAmB,EAAE,MAAM,EAAE,CAAM;IACnC,eAAe,EAAE,gBAAgB,CAAM;IACvC,YAAY,UAAS;IACrB,oBAAoB,SAAM;gBAEJ,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe;IAM3D,aAAa,CAAC,WAAW,EAAE,MAAM;IAmBjC;;OAEG;IACM,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CA2DtE"}
@@ -0,0 +1,181 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2;
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _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 }); }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ 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); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ 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); }
16
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17
+ 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); }; }
18
+ 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); }
19
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
+ 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; } }
21
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
+ 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; }
23
+ 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.'); }
24
+ import { LirboContextKey } from '@difizen/libro-core';
25
+ import { useInject, view, ViewInstance, ViewOption, transient, inject, prop } from '@difizen/mana-app';
26
+ import { forwardRef } from 'react';
27
+ import { WidgetView } from "../base/widget-view.js";
28
+ import "./index.less";
29
+ import { jsx as _jsx } from "react/jsx-runtime";
30
+ import { jsxs as _jsxs } from "react/jsx-runtime";
31
+ export var LibroInstancesProgressWidgetViewComponent = /*#__PURE__*/forwardRef(function LibroInstancesProgressWidgetViewComponent(_props, ref) {
32
+ var widgetView = useInject(ViewInstance);
33
+ if (widgetView.isCommClosed) {
34
+ return null;
35
+ }
36
+ return /*#__PURE__*/_jsxs("div", {
37
+ ref: ref,
38
+ className: "libro-instances-progress-widget",
39
+ children: [/*#__PURE__*/_jsx("span", {
40
+ style: {
41
+ paddingRight: 5
42
+ },
43
+ children: widgetView.prefix
44
+ }), /*#__PURE__*/_jsx("span", {
45
+ children: widgetView.workingProgressKeys.map(function (progressKey) {
46
+ var progressItem = widgetView.progressMap[progressKey];
47
+ return /*#__PURE__*/_jsx("a", {
48
+ className: "pyodps-progress-launcher",
49
+ style: {
50
+ marginRight: 5
51
+ },
52
+ children: progressItem && progressItem.name
53
+ }, progressKey);
54
+ })
55
+ }), /*#__PURE__*/_jsx("span", {
56
+ children: widgetView.suffix
57
+ })]
58
+ });
59
+ });
60
+ export var InstancesProgressWidget = (_dec = transient(), _dec2 = view('libro-widget-instances-progress-view'), _dec3 = prop(), _dec4 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_WidgetView) {
61
+ _inherits(InstancesProgressWidget, _WidgetView);
62
+ var _super = _createSuper(InstancesProgressWidget);
63
+ function InstancesProgressWidget(props, lirboContextKey) {
64
+ var _this;
65
+ _classCallCheck(this, InstancesProgressWidget);
66
+ _this = _super.call(this, props, lirboContextKey);
67
+ _this.view = LibroInstancesProgressWidgetViewComponent;
68
+ _initializerDefineProperty(_this, "prefix", _descriptor, _assertThisInitialized(_this));
69
+ _initializerDefineProperty(_this, "suffix", _descriptor2, _assertThisInitialized(_this));
70
+ _this.progressMap = {};
71
+ _this.workingProgressKeys = [];
72
+ // Order of groups by time of insertion
73
+ _this.instanceRecords = {};
74
+ _this.modalVisible = false;
75
+ _this.modalProgressItemKey = '';
76
+ _this.prefix = props.attributes.prefix;
77
+ _this.suffix = props.attributes.suffix;
78
+ return _this;
79
+ }
80
+ InstancesProgressWidget = inject(LirboContextKey)(InstancesProgressWidget, undefined, 1) || InstancesProgressWidget;
81
+ InstancesProgressWidget = inject(ViewOption)(InstancesProgressWidget, undefined, 0) || InstancesProgressWidget;
82
+ _createClass(InstancesProgressWidget, [{
83
+ key: "updateRecords",
84
+ value: function updateRecords(progressKey) {
85
+ var _this2 = this;
86
+ var progressItem = this.progressMap[progressKey];
87
+ if (progressItem) {
88
+ var _progressItem$instanc = progressItem.instances,
89
+ instances = _progressItem$instanc === void 0 ? [] : _progressItem$instanc;
90
+ instances.forEach(function (instance) {
91
+ var id = instance.id,
92
+ status = instance.status;
93
+ if (!_this2.instanceRecords[id]) {
94
+ _this2.instanceRecords[id] = {
95
+ startDate: Date.now()
96
+ };
97
+ }
98
+ if (status === 'Terminated') {
99
+ if (!_this2.instanceRecords[id].endDate) {
100
+ _this2.instanceRecords[id].endDate = Date.now();
101
+ }
102
+ }
103
+ });
104
+ }
105
+ }
106
+ /**
107
+ * Handle incoming comm msg.
108
+ */
109
+ }, {
110
+ key: "handleCommMsg",
111
+ value: function handleCommMsg(msg) {
112
+ var _this3 = this;
113
+ var data = msg.content.data;
114
+ var method = data.method;
115
+ switch (method) {
116
+ case 'update':
117
+ if (data.state.prefix) {
118
+ this.prefix = data.state.prefix;
119
+ }
120
+ if (data.state.suffix) {
121
+ this.suffix = data.state.suffix;
122
+ }
123
+ // eslint-disable-next-line no-fallthrough
124
+ case 'custom':
125
+ // eslint-disable-next-line no-case-declarations
126
+ var customMsg = data.content;
127
+ if (customMsg) {
128
+ // message format: '{"action": "action", content: ["content1", "content2"]}'
129
+ var msgObj = JSON.parse(customMsg);
130
+ var action = msgObj.action;
131
+ var content = [];
132
+ if (msgObj.content) {
133
+ content.push.apply(content, _toConsumableArray(msgObj.content));
134
+ }
135
+ switch (action) {
136
+ case 'update':
137
+ content.forEach(function (groupJson) {
138
+ var parsedProgressItem = JSON.parse(groupJson);
139
+ if (!_this3.progressMap[parsedProgressItem.key]) {
140
+ _this3.workingProgressKeys.push(parsedProgressItem.key);
141
+ }
142
+ _this3.progressMap[parsedProgressItem.key] = parsedProgressItem;
143
+ _this3.updateRecords(parsedProgressItem.key);
144
+ });
145
+ // ? TODO: 发出一个更新 modal signal 的信号,这里需要取到之前的 key
146
+ break;
147
+ case 'delete':
148
+ content.forEach(function (groupKey) {
149
+ if (!_this3.progressMap[groupKey]) {
150
+ return;
151
+ }
152
+ var i = _this3.workingProgressKeys.indexOf(groupKey);
153
+ if (i >= 0) {
154
+ _this3.workingProgressKeys.splice(i, 1);
155
+ }
156
+ });
157
+ break;
158
+ case 'clear':
159
+ this.progressMap = {};
160
+ this.workingProgressKeys = [];
161
+ // ? TODO: 发出更新 overview 以及 modal 的 signal
162
+ break;
163
+ default:
164
+ }
165
+ }
166
+ }
167
+ return Promise.resolve();
168
+ }
169
+ }]);
170
+ return InstancesProgressWidget;
171
+ }(WidgetView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "prefix", [_dec3], {
172
+ configurable: true,
173
+ enumerable: true,
174
+ writable: true,
175
+ initializer: null
176
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "suffix", [_dec4], {
177
+ configurable: true,
178
+ enumerable: true,
179
+ writable: true,
180
+ initializer: null
181
+ })), _class2)) || _class) || _class);