@difizen/libro-widget 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.
Files changed (120) hide show
  1. package/es/index.d.ts +3 -4
  2. package/es/index.d.ts.map +1 -1
  3. package/es/index.js +3 -4
  4. package/es/module.d.ts +3 -0
  5. package/es/module.d.ts.map +1 -0
  6. package/es/module.js +5 -0
  7. package/es/slider/contribution.d.ts +10 -0
  8. package/es/slider/contribution.d.ts.map +1 -0
  9. package/es/{widgets/instances-progress-widget-view-contribution.js → slider/contribution.js} +15 -9
  10. package/es/slider/index.d.ts +3 -0
  11. package/es/slider/index.d.ts.map +1 -0
  12. package/es/slider/index.js +2 -0
  13. package/es/slider/index.less +3 -0
  14. package/es/slider/view.d.ts +23 -0
  15. package/es/slider/view.d.ts.map +1 -0
  16. package/es/{widgets/progress-widget-view.js → slider/view.js} +64 -70
  17. package/es/text/contribution.d.ts +10 -0
  18. package/es/text/contribution.d.ts.map +1 -0
  19. package/es/{widgets/text-widget-view-contribution.js → text/contribution.js} +3 -3
  20. package/es/text/index.d.ts +3 -0
  21. package/es/text/index.d.ts.map +1 -0
  22. package/es/text/index.js +2 -0
  23. package/es/text/view.d.ts +18 -0
  24. package/es/text/view.d.ts.map +1 -0
  25. package/es/{widgets/text-widget-view.js → text/view.js} +13 -14
  26. package/package.json +7 -6
  27. package/src/index.spec.ts +2 -3
  28. package/src/index.ts +3 -4
  29. package/src/module.ts +15 -0
  30. package/src/slider/contribution.ts +25 -0
  31. package/src/slider/index.less +3 -0
  32. package/src/slider/index.ts +2 -0
  33. package/src/slider/view.tsx +92 -0
  34. package/src/{widgets/text-widget-view-contribution.ts → text/contribution.ts} +4 -5
  35. package/src/text/index.ts +2 -0
  36. package/src/{widgets/text-widget-view.tsx → text/view.tsx} +10 -13
  37. package/es/base/comm.d.ts +0 -65
  38. package/es/base/comm.d.ts.map +0 -1
  39. package/es/base/comm.js +0 -151
  40. package/es/base/index.d.ts +0 -7
  41. package/es/base/index.d.ts.map +0 -1
  42. package/es/base/index.js +0 -6
  43. package/es/base/libro-widgets.d.ts +0 -79
  44. package/es/base/libro-widgets.d.ts.map +0 -1
  45. package/es/base/libro-widgets.js +0 -286
  46. package/es/base/protocal.d.ts +0 -171
  47. package/es/base/protocal.d.ts.map +0 -1
  48. package/es/base/protocal.js +0 -21
  49. package/es/base/utils.d.ts +0 -27
  50. package/es/base/utils.d.ts.map +0 -1
  51. package/es/base/utils.js +0 -59
  52. package/es/base/version.d.ts +0 -3
  53. package/es/base/version.d.ts.map +0 -1
  54. package/es/base/version.js +0 -2
  55. package/es/base/widget-manager.d.ts +0 -18
  56. package/es/base/widget-manager.d.ts.map +0 -1
  57. package/es/base/widget-manager.js +0 -68
  58. package/es/base/widget-view-contribution.d.ts +0 -10
  59. package/es/base/widget-view-contribution.d.ts.map +0 -1
  60. package/es/base/widget-view-contribution.js +0 -36
  61. package/es/base/widget-view.d.ts +0 -52
  62. package/es/base/widget-view.d.ts.map +0 -1
  63. package/es/base/widget-view.js +0 -137
  64. package/es/components/index.d.ts +0 -3
  65. package/es/components/index.d.ts.map +0 -1
  66. package/es/components/index.js +0 -2
  67. package/es/components/progressBar.d.ts +0 -15
  68. package/es/components/progressBar.d.ts.map +0 -1
  69. package/es/components/progressBar.js +0 -20
  70. package/es/components/progressCircle.d.ts +0 -11
  71. package/es/components/progressCircle.d.ts.map +0 -1
  72. package/es/components/progressCircle.js +0 -16
  73. package/es/widget-module.d.ts +0 -3
  74. package/es/widget-module.d.ts.map +0 -1
  75. package/es/widget-module.js +0 -39
  76. package/es/widgets/hbox-widget-view-contribution.d.ts +0 -10
  77. package/es/widgets/hbox-widget-view-contribution.d.ts.map +0 -1
  78. package/es/widgets/hbox-widget-view-contribution.js +0 -39
  79. package/es/widgets/hbox-widget-view.d.ts +0 -17
  80. package/es/widgets/hbox-widget-view.d.ts.map +0 -1
  81. package/es/widgets/hbox-widget-view.js +0 -69
  82. package/es/widgets/index.d.ts +0 -9
  83. package/es/widgets/index.d.ts.map +0 -1
  84. package/es/widgets/index.js +0 -8
  85. package/es/widgets/index.less +0 -3
  86. package/es/widgets/instances-progress-widget-view-contribution.d.ts +0 -10
  87. package/es/widgets/instances-progress-widget-view-contribution.d.ts.map +0 -1
  88. package/es/widgets/instances-progress-widget-view.d.ts +0 -31
  89. package/es/widgets/instances-progress-widget-view.d.ts.map +0 -1
  90. package/es/widgets/instances-progress-widget-view.js +0 -181
  91. package/es/widgets/progress-widget-view-contribution.d.ts +0 -10
  92. package/es/widgets/progress-widget-view-contribution.d.ts.map +0 -1
  93. package/es/widgets/progress-widget-view-contribution.js +0 -39
  94. package/es/widgets/progress-widget-view.d.ts +0 -25
  95. package/es/widgets/progress-widget-view.d.ts.map +0 -1
  96. package/es/widgets/text-widget-view-contribution.d.ts +0 -10
  97. package/es/widgets/text-widget-view-contribution.d.ts.map +0 -1
  98. package/es/widgets/text-widget-view.d.ts +0 -19
  99. package/es/widgets/text-widget-view.d.ts.map +0 -1
  100. package/src/base/comm.ts +0 -152
  101. package/src/base/index.ts +0 -6
  102. package/src/base/libro-widgets.ts +0 -207
  103. package/src/base/protocal.ts +0 -218
  104. package/src/base/utils.ts +0 -67
  105. package/src/base/version.ts +0 -2
  106. package/src/base/widget-manager.ts +0 -41
  107. package/src/base/widget-view-contribution.ts +0 -14
  108. package/src/base/widget-view.tsx +0 -146
  109. package/src/components/index.ts +0 -3
  110. package/src/components/progressBar.tsx +0 -29
  111. package/src/components/progressCircle.tsx +0 -18
  112. package/src/widget-module.ts +0 -68
  113. package/src/widgets/hbox-widget-view-contribution.ts +0 -20
  114. package/src/widgets/hbox-widget-view.tsx +0 -64
  115. package/src/widgets/index.less +0 -3
  116. package/src/widgets/index.ts +0 -8
  117. package/src/widgets/instances-progress-widget-view-contribution.ts +0 -20
  118. package/src/widgets/instances-progress-widget-view.tsx +0 -160
  119. package/src/widgets/progress-widget-view-contribution.ts +0 -24
  120. package/src/widgets/progress-widget-view.tsx +0 -85
@@ -1,8 +0,0 @@
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";
@@ -1,3 +0,0 @@
1
- .libro-input-widget {
2
- display: flex;
3
- }
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,31 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,181 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2;
3
- function _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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
- 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); }
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);
@@ -1,10 +0,0 @@
1
- import { ViewManager } from '@difizen/mana-app';
2
- import type { IWidgetViewProps } from '../base/protocal.js';
3
- import { WidgetViewContribution } from '../base/protocal.js';
4
- import { ProgressWidget } from './progress-widget-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=progress-widget-view-contribution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"progress-widget-view-contribution.d.ts","sourceRoot":"","sources":["../../src/widgets/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,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,qBACa,8BAA+B,YAAW,sBAAsB;IACtD,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAgB,GAAG,aAS1B;IACF,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -1,39 +0,0 @@
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 "../base/protocal.js";
13
- import { ProgressWidget } from "./progress-widget-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);
@@ -1,25 +0,0 @@
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 { IWidgetViewProps } from '../base/protocal.js';
5
- import { WidgetView } from '../base/widget-view.js';
6
- import './index.less';
7
- export declare const LibroProgressWidgetComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
8
- export declare class ProgressWidget extends WidgetView {
9
- view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
10
- bar_style: string;
11
- description: string;
12
- description_tooltip: null;
13
- layout: string;
14
- max: number;
15
- min: number;
16
- orientation: string;
17
- style: string;
18
- value: number;
19
- constructor(props: IWidgetViewProps, lirboContextKey: LirboContextKey);
20
- /**
21
- * Handle incoming comm msg.
22
- */
23
- handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void>;
24
- }
25
- //# sourceMappingURL=progress-widget-view.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"progress-widget-view.d.ts","sourceRoot":"","sources":["../../src/widgets/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,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,4BAA4B,0FAgBxC,CAAC;AACF,qBAEa,cAAe,SAAQ,UAAU;IACnC,IAAI,2FAAgC;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IAEf,GAAG,EAAE,MAAM,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;gBAEQ,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe;IAa3D;;OAEG;IACM,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAetE"}
@@ -1,10 +0,0 @@
1
- import { ViewManager } from '@difizen/mana-app';
2
- import type { IWidgetViewProps } from '../base/protocal.js';
3
- import { WidgetViewContribution } from '../base/protocal.js';
4
- import { LibroTextWidget } from './text-widget-view.js';
5
- export declare class TextModelContribution implements WidgetViewContribution {
6
- viewManager: ViewManager;
7
- canHandle: (attributes: any) => 1 | 100;
8
- factory(props: IWidgetViewProps): Promise<LibroTextWidget>;
9
- }
10
- //# sourceMappingURL=text-widget-view-contribution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text-widget-view-contribution.d.ts","sourceRoot":"","sources":["../../src/widgets/text-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,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,qBACa,qBAAsB,YAAW,sBAAsB;IAC7C,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAgB,GAAG,aAK1B;IACF,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -1,19 +0,0 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
- import { LirboContextKey } from '@difizen/libro-core';
3
- import type { IWidgetViewProps } from '../base/protocal.js';
4
- import { WidgetView } from '../base/widget-view.js';
5
- import './index.less';
6
- export declare const LibroTextWidgetComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
7
- export declare class LibroTextWidget extends WidgetView {
8
- view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
9
- bar_style: string;
10
- description: string;
11
- description_tooltip: null;
12
- layout: string;
13
- orientation: string;
14
- style: string;
15
- placeholder: string;
16
- value: number;
17
- constructor(props: IWidgetViewProps, lirboContextKey: LirboContextKey);
18
- }
19
- //# sourceMappingURL=text-widget-view.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text-widget-view.d.ts","sourceRoot":"","sources":["../../src/widgets/text-widget-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAatD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,wBAAwB,0FAoCpC,CAAC;AACF,qBAEa,eAAgB,SAAQ,UAAU;IACpC,IAAI,2FAA4B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC;gBAEQ,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe;CAY5D"}
package/src/base/comm.ts DELETED
@@ -1,152 +0,0 @@
1
- import type { JSONObject } from '@difizen/libro-common';
2
- import type { IComm, IKernelConnection, IShellFuture } from '@difizen/libro-kernel';
3
- import { inject, transient } from '@difizen/mana-app';
4
-
5
- import type { ICallbacks, IClassicComm } from './protocal.js';
6
- import { WidgetCommOption } from './protocal.js';
7
-
8
- /**
9
- * Public constructor
10
- * @param {IComm} jsServicesComm - @jupyterlab/services IComm instance
11
- */
12
- @transient()
13
- export class Comm implements IClassicComm {
14
- constructor(@inject(WidgetCommOption) options: WidgetCommOption) {
15
- this.jsServicesComm = options.comm;
16
- }
17
-
18
- /**
19
- * Comm id
20
- * @return {string}
21
- */
22
- get comm_id(): string {
23
- return this.jsServicesComm.commId;
24
- }
25
-
26
- /**
27
- * Target name
28
- * @return {string}
29
- */
30
- get target_name(): string {
31
- return this.jsServicesComm.targetName;
32
- }
33
-
34
- /**
35
- * Opens a sibling comm in the backend
36
- * @param data
37
- * @param callbacks
38
- * @param metadata
39
- * @return msg id
40
- */
41
- open(
42
- data: JSONObject,
43
- callbacks?: ICallbacks,
44
- metadata?: JSONObject,
45
- buffers?: ArrayBuffer[] | ArrayBufferView[],
46
- ): string {
47
- const future = this.jsServicesComm.open(data, metadata, buffers);
48
- this._hookupCallbacks(future, callbacks);
49
- return future.msg.header.msg_id;
50
- }
51
-
52
- /**
53
- * Sends a message to the sibling comm in the backend
54
- * @param data
55
- * @param callbacks
56
- * @param metadata
57
- * @param buffers
58
- * @return message id
59
- */
60
- send(
61
- data: JSONObject,
62
- callbacks?: ICallbacks,
63
- metadata?: JSONObject,
64
- buffers?: ArrayBuffer[] | ArrayBufferView[],
65
- ): string {
66
- const future = this.jsServicesComm.send(data, metadata, buffers);
67
- this._hookupCallbacks(future, callbacks);
68
- return future.msg.header.msg_id;
69
- }
70
-
71
- /**
72
- * Closes the sibling comm in the backend
73
- * @param data
74
- * @param callbacks
75
- * @param metadata
76
- * @return msg id
77
- */
78
- close(
79
- data?: JSONObject,
80
- callbacks?: ICallbacks,
81
- metadata?: JSONObject,
82
- buffers?: ArrayBuffer[] | ArrayBufferView[],
83
- ): string {
84
- const future = this.jsServicesComm.close(data, metadata, buffers);
85
- this._hookupCallbacks(future, callbacks);
86
- return future.msg.header.msg_id;
87
- }
88
-
89
- /**
90
- * Register a message handler
91
- * @param callback, which is given a message
92
- */
93
- on_msg(callback: (x: any) => void): void {
94
- this.jsServicesComm.onMsg = callback.bind(this);
95
- }
96
-
97
- /**
98
- * Register a handler for when the comm is closed by the backend
99
- * @param callback, which is given a message
100
- */
101
- on_close(callback: (x: any) => void): void {
102
- this.jsServicesComm.onClose = callback.bind(this);
103
- }
104
-
105
- /**
106
- * Hooks callback object up with @jupyterlab/services IKernelFuture
107
- * @param @jupyterlab/services IKernelFuture instance
108
- * @param callbacks
109
- */
110
- _hookupCallbacks(future: IShellFuture, callbacks?: ICallbacks): void {
111
- if (callbacks) {
112
- future.onReply = function (msg): void {
113
- if (callbacks.shell && callbacks.shell['reply']) {
114
- callbacks.shell['reply'](msg);
115
- }
116
- };
117
-
118
- future.onStdin = function (msg): void {
119
- if (callbacks.input) {
120
- callbacks.input(msg);
121
- }
122
- };
123
-
124
- future.onIOPub = function (msg): void {
125
- if (callbacks.iopub) {
126
- if (callbacks.iopub['status'] && msg.header.msg_type === 'status') {
127
- callbacks.iopub['status'](msg);
128
- } else if (
129
- callbacks.iopub['clear_output'] &&
130
- msg.header.msg_type === 'clear_output'
131
- ) {
132
- callbacks.iopub['clear_output'](msg);
133
- } else if (callbacks.iopub['output']) {
134
- switch (msg.header.msg_type) {
135
- case 'display_data':
136
- case 'execute_result':
137
- case 'stream':
138
- case 'error':
139
- callbacks.iopub['output'](msg);
140
- break;
141
- default:
142
- break;
143
- }
144
- }
145
- }
146
- };
147
- }
148
- }
149
-
150
- jsServicesComm: IComm;
151
- kernel: IKernelConnection;
152
- }
package/src/base/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './libro-widgets.js';
2
- export * from './widget-view.js';
3
- export * from './protocal.js';
4
- export * from './widget-manager.js';
5
- export * from './comm.js';
6
- export * from './widget-view-contribution.js';