@difizen/libro-widget 0.1.33 → 0.1.35
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/index.d.ts +3 -4
- package/es/index.d.ts.map +1 -1
- package/es/index.js +3 -4
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +5 -0
- package/es/slider/contribution.d.ts +10 -0
- package/es/slider/contribution.d.ts.map +1 -0
- package/es/{widgets/instances-progress-widget-view-contribution.js → slider/contribution.js} +15 -9
- package/es/slider/index.d.ts +3 -0
- package/es/slider/index.d.ts.map +1 -0
- package/es/slider/index.js +2 -0
- package/es/slider/index.less +3 -0
- package/es/slider/view.d.ts +23 -0
- package/es/slider/view.d.ts.map +1 -0
- package/es/{widgets/progress-widget-view.js → slider/view.js} +62 -68
- package/es/text/contribution.d.ts +10 -0
- package/es/text/contribution.d.ts.map +1 -0
- package/es/{widgets/text-widget-view-contribution.js → text/contribution.js} +3 -3
- package/es/text/index.d.ts +3 -0
- package/es/text/index.d.ts.map +1 -0
- package/es/text/index.js +2 -0
- package/es/{widgets/text-widget-view.d.ts → text/view.d.ts} +5 -6
- package/es/text/view.d.ts.map +1 -0
- package/es/{widgets/text-widget-view.js → text/view.js} +11 -12
- package/package.json +6 -5
- package/src/index.spec.ts +2 -3
- package/src/index.ts +3 -4
- package/src/module.ts +15 -0
- package/src/slider/contribution.ts +25 -0
- package/src/slider/index.less +3 -0
- package/src/slider/index.ts +2 -0
- package/src/slider/view.tsx +92 -0
- package/src/{widgets/text-widget-view-contribution.ts → text/contribution.ts} +4 -5
- package/src/text/index.ts +2 -0
- package/src/{widgets/text-widget-view.tsx → text/view.tsx} +7 -10
- package/es/base/comm.d.ts +0 -65
- package/es/base/comm.d.ts.map +0 -1
- package/es/base/comm.js +0 -151
- package/es/base/index.d.ts +0 -7
- package/es/base/index.d.ts.map +0 -1
- package/es/base/index.js +0 -6
- package/es/base/libro-widgets.d.ts +0 -79
- package/es/base/libro-widgets.d.ts.map +0 -1
- package/es/base/libro-widgets.js +0 -286
- package/es/base/protocal.d.ts +0 -171
- package/es/base/protocal.d.ts.map +0 -1
- package/es/base/protocal.js +0 -21
- package/es/base/utils.d.ts +0 -27
- package/es/base/utils.d.ts.map +0 -1
- package/es/base/utils.js +0 -59
- package/es/base/version.d.ts +0 -3
- package/es/base/version.d.ts.map +0 -1
- package/es/base/version.js +0 -2
- package/es/base/widget-manager.d.ts +0 -18
- package/es/base/widget-manager.d.ts.map +0 -1
- package/es/base/widget-manager.js +0 -68
- package/es/base/widget-view-contribution.d.ts +0 -10
- package/es/base/widget-view-contribution.d.ts.map +0 -1
- package/es/base/widget-view-contribution.js +0 -36
- package/es/base/widget-view.d.ts +0 -52
- package/es/base/widget-view.d.ts.map +0 -1
- package/es/base/widget-view.js +0 -137
- package/es/components/index.d.ts +0 -3
- package/es/components/index.d.ts.map +0 -1
- package/es/components/index.js +0 -2
- package/es/components/progressBar.d.ts +0 -15
- package/es/components/progressBar.d.ts.map +0 -1
- package/es/components/progressBar.js +0 -20
- package/es/components/progressCircle.d.ts +0 -11
- package/es/components/progressCircle.d.ts.map +0 -1
- package/es/components/progressCircle.js +0 -16
- package/es/widget-module.d.ts +0 -3
- package/es/widget-module.d.ts.map +0 -1
- package/es/widget-module.js +0 -39
- package/es/widgets/hbox-widget-view-contribution.d.ts +0 -10
- package/es/widgets/hbox-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/hbox-widget-view-contribution.js +0 -39
- package/es/widgets/hbox-widget-view.d.ts +0 -17
- package/es/widgets/hbox-widget-view.d.ts.map +0 -1
- package/es/widgets/hbox-widget-view.js +0 -69
- package/es/widgets/index.d.ts +0 -9
- package/es/widgets/index.d.ts.map +0 -1
- package/es/widgets/index.js +0 -8
- package/es/widgets/index.less +0 -3
- package/es/widgets/instances-progress-widget-view-contribution.d.ts +0 -10
- package/es/widgets/instances-progress-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/instances-progress-widget-view.d.ts +0 -31
- package/es/widgets/instances-progress-widget-view.d.ts.map +0 -1
- package/es/widgets/instances-progress-widget-view.js +0 -181
- package/es/widgets/progress-widget-view-contribution.d.ts +0 -10
- package/es/widgets/progress-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/progress-widget-view-contribution.js +0 -39
- package/es/widgets/progress-widget-view.d.ts +0 -25
- package/es/widgets/progress-widget-view.d.ts.map +0 -1
- package/es/widgets/text-widget-view-contribution.d.ts +0 -10
- package/es/widgets/text-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/text-widget-view.d.ts.map +0 -1
- package/src/base/comm.ts +0 -152
- package/src/base/index.ts +0 -6
- package/src/base/libro-widgets.ts +0 -207
- package/src/base/protocal.ts +0 -218
- package/src/base/utils.ts +0 -67
- package/src/base/version.ts +0 -2
- package/src/base/widget-manager.ts +0 -41
- package/src/base/widget-view-contribution.ts +0 -14
- package/src/base/widget-view.tsx +0 -146
- package/src/components/index.ts +0 -3
- package/src/components/progressBar.tsx +0 -29
- package/src/components/progressCircle.tsx +0 -18
- package/src/widget-module.ts +0 -68
- package/src/widgets/hbox-widget-view-contribution.ts +0 -20
- package/src/widgets/hbox-widget-view.tsx +0 -64
- package/src/widgets/index.less +0 -3
- package/src/widgets/index.ts +0 -8
- package/src/widgets/instances-progress-widget-view-contribution.ts +0 -20
- package/src/widgets/instances-progress-widget-view.tsx +0 -160
- package/src/widgets/progress-widget-view-contribution.ts +0 -24
- package/src/widgets/progress-widget-view.tsx +0 -85
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { JSONObject } from '@difizen/libro-common';
|
|
2
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
3
|
+
import type { IWidgetViewProps } from '@difizen/libro-jupyter';
|
|
4
|
+
import type { OrientableState, WidgetState } from '@difizen/libro-jupyter';
|
|
5
|
+
import { WidgetView } from '@difizen/libro-jupyter';
|
|
6
|
+
import { defaultWidgetState } from '@difizen/libro-jupyter';
|
|
7
|
+
import {
|
|
8
|
+
view,
|
|
9
|
+
transient,
|
|
10
|
+
useInject,
|
|
11
|
+
ViewInstance,
|
|
12
|
+
prop,
|
|
13
|
+
inject,
|
|
14
|
+
ViewOption,
|
|
15
|
+
} from '@difizen/mana-app';
|
|
16
|
+
import { Slider } from 'antd';
|
|
17
|
+
import { forwardRef } from 'react';
|
|
18
|
+
|
|
19
|
+
import './index.less';
|
|
20
|
+
|
|
21
|
+
export const LibroWidgetIntSliderComponent = forwardRef<HTMLDivElement>(
|
|
22
|
+
function LibroWidgetIntSliderComponent(props, ref) {
|
|
23
|
+
const widget = useInject<SliderWidget>(ViewInstance);
|
|
24
|
+
|
|
25
|
+
if (widget.isCommClosed) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="libro-widget-slider" ref={ref}>
|
|
31
|
+
<Slider
|
|
32
|
+
max={widget.state.max}
|
|
33
|
+
min={widget.state.min}
|
|
34
|
+
vertical={widget.state.orientation === 'vertical'}
|
|
35
|
+
disabled={widget.state.disabled}
|
|
36
|
+
onChange={widget.handleChange}
|
|
37
|
+
value={widget.state.value}
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
interface SliderState extends WidgetState, OrientableState {
|
|
45
|
+
max?: number;
|
|
46
|
+
min?: number;
|
|
47
|
+
step: number;
|
|
48
|
+
value: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@transient()
|
|
52
|
+
@view('libro-widget-slider-view')
|
|
53
|
+
export class SliderWidget extends WidgetView {
|
|
54
|
+
override view = LibroWidgetIntSliderComponent;
|
|
55
|
+
|
|
56
|
+
@prop()
|
|
57
|
+
override state: JSONObject & SliderState = {
|
|
58
|
+
...defaultWidgetState,
|
|
59
|
+
orientation: 'horizontal',
|
|
60
|
+
step: 1,
|
|
61
|
+
value: 0,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
constructor(
|
|
65
|
+
@inject(ViewOption) props: IWidgetViewProps,
|
|
66
|
+
@inject(LibroContextKey) libroContextKey: LibroContextKey,
|
|
67
|
+
) {
|
|
68
|
+
super(props, libroContextKey);
|
|
69
|
+
this.initialize(props);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected initialize(props: IWidgetViewProps): void {
|
|
73
|
+
if (this.model_name === 'FloatSliderModel') {
|
|
74
|
+
if (!this.state.step) {
|
|
75
|
+
this.state.step === 0.01;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const attributes = props.attributes;
|
|
79
|
+
this.state.max = attributes.max;
|
|
80
|
+
this.state.min = attributes.min;
|
|
81
|
+
this.setState(attributes);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
handleChange = (value: number) => {
|
|
85
|
+
const data = {
|
|
86
|
+
buffer_paths: [],
|
|
87
|
+
method: 'update',
|
|
88
|
+
state: { value: value },
|
|
89
|
+
};
|
|
90
|
+
this.send(data);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type { IWidgetViewProps } from '@difizen/libro-jupyter';
|
|
2
|
+
import { WidgetViewContribution } from '@difizen/libro-jupyter';
|
|
1
3
|
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
2
4
|
|
|
3
|
-
import
|
|
4
|
-
import { WidgetViewContribution } from '../base/protocal.js';
|
|
5
|
-
|
|
6
|
-
import { LibroTextWidget } from './text-widget-view.js';
|
|
5
|
+
import { TextWidget } from './view.js';
|
|
7
6
|
|
|
8
7
|
@singleton({ contrib: WidgetViewContribution })
|
|
9
8
|
export class TextModelContribution implements WidgetViewContribution {
|
|
@@ -15,6 +14,6 @@ export class TextModelContribution implements WidgetViewContribution {
|
|
|
15
14
|
return 1;
|
|
16
15
|
};
|
|
17
16
|
factory(props: IWidgetViewProps) {
|
|
18
|
-
return this.viewManager.getOrCreateView(
|
|
17
|
+
return this.viewManager.getOrCreateView(TextWidget, props);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { LibroContextKey } from '@difizen/libro-core';
|
|
2
|
+
import type { IWidgetViewProps } from '@difizen/libro-jupyter';
|
|
3
|
+
import { WidgetView } from '@difizen/libro-jupyter';
|
|
2
4
|
import {
|
|
3
5
|
view,
|
|
4
6
|
ViewOption,
|
|
@@ -11,14 +13,9 @@ import {
|
|
|
11
13
|
import { Input } from 'antd';
|
|
12
14
|
import { forwardRef } from 'react';
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import './index.less';
|
|
18
|
-
|
|
19
|
-
export const LibroTextWidgetComponent = forwardRef<HTMLDivElement>(
|
|
20
|
-
function LibroTextWidgetComponent(_props, ref) {
|
|
21
|
-
const widgetView = useInject<LibroTextWidget>(ViewInstance);
|
|
16
|
+
export const TextWidgetComponent = forwardRef<HTMLDivElement>(
|
|
17
|
+
function TextWidgetComponent(_props, ref) {
|
|
18
|
+
const widgetView = useInject<TextWidget>(ViewInstance);
|
|
22
19
|
if (widgetView.isCommClosed) {
|
|
23
20
|
return null;
|
|
24
21
|
}
|
|
@@ -55,8 +52,8 @@ export const LibroTextWidgetComponent = forwardRef<HTMLDivElement>(
|
|
|
55
52
|
);
|
|
56
53
|
@transient()
|
|
57
54
|
@view('libro-widget-text-view')
|
|
58
|
-
export class
|
|
59
|
-
override view =
|
|
55
|
+
export class TextWidget extends WidgetView {
|
|
56
|
+
override view = TextWidgetComponent;
|
|
60
57
|
bar_style: string;
|
|
61
58
|
description: string;
|
|
62
59
|
description_tooltip: null;
|
package/es/base/comm.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { JSONObject } from '@difizen/libro-common';
|
|
2
|
-
import type { IComm, IKernelConnection, IShellFuture } from '@difizen/libro-kernel';
|
|
3
|
-
import type { ICallbacks, IClassicComm } from './protocal.js';
|
|
4
|
-
import { WidgetCommOption } from './protocal.js';
|
|
5
|
-
/**
|
|
6
|
-
* Public constructor
|
|
7
|
-
* @param {IComm} jsServicesComm - @jupyterlab/services IComm instance
|
|
8
|
-
*/
|
|
9
|
-
export declare class Comm implements IClassicComm {
|
|
10
|
-
constructor(options: WidgetCommOption);
|
|
11
|
-
/**
|
|
12
|
-
* Comm id
|
|
13
|
-
* @return {string}
|
|
14
|
-
*/
|
|
15
|
-
get comm_id(): string;
|
|
16
|
-
/**
|
|
17
|
-
* Target name
|
|
18
|
-
* @return {string}
|
|
19
|
-
*/
|
|
20
|
-
get target_name(): string;
|
|
21
|
-
/**
|
|
22
|
-
* Opens a sibling comm in the backend
|
|
23
|
-
* @param data
|
|
24
|
-
* @param callbacks
|
|
25
|
-
* @param metadata
|
|
26
|
-
* @return msg id
|
|
27
|
-
*/
|
|
28
|
-
open(data: JSONObject, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
|
|
29
|
-
/**
|
|
30
|
-
* Sends a message to the sibling comm in the backend
|
|
31
|
-
* @param data
|
|
32
|
-
* @param callbacks
|
|
33
|
-
* @param metadata
|
|
34
|
-
* @param buffers
|
|
35
|
-
* @return message id
|
|
36
|
-
*/
|
|
37
|
-
send(data: JSONObject, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
|
|
38
|
-
/**
|
|
39
|
-
* Closes the sibling comm in the backend
|
|
40
|
-
* @param data
|
|
41
|
-
* @param callbacks
|
|
42
|
-
* @param metadata
|
|
43
|
-
* @return msg id
|
|
44
|
-
*/
|
|
45
|
-
close(data?: JSONObject, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
|
|
46
|
-
/**
|
|
47
|
-
* Register a message handler
|
|
48
|
-
* @param callback, which is given a message
|
|
49
|
-
*/
|
|
50
|
-
on_msg(callback: (x: any) => void): void;
|
|
51
|
-
/**
|
|
52
|
-
* Register a handler for when the comm is closed by the backend
|
|
53
|
-
* @param callback, which is given a message
|
|
54
|
-
*/
|
|
55
|
-
on_close(callback: (x: any) => void): void;
|
|
56
|
-
/**
|
|
57
|
-
* Hooks callback object up with @jupyterlab/services IKernelFuture
|
|
58
|
-
* @param @jupyterlab/services IKernelFuture instance
|
|
59
|
-
* @param callbacks
|
|
60
|
-
*/
|
|
61
|
-
_hookupCallbacks(future: IShellFuture, callbacks?: ICallbacks): void;
|
|
62
|
-
jsServicesComm: IComm;
|
|
63
|
-
kernel: IKernelConnection;
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=comm.d.ts.map
|
package/es/base/comm.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"comm.d.ts","sourceRoot":"","sources":["../../src/base/comm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGpF,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;GAGG;AACH,qBACa,IAAK,YAAW,YAAY;gBACD,OAAO,EAAE,gBAAgB;IAI/D;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;;;;OAMG;IACH,IAAI,CACF,IAAI,EAAE,UAAU,EAChB,SAAS,CAAC,EAAE,UAAU,EACtB,QAAQ,CAAC,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,GAC1C,MAAM;IAMT;;;;;;;OAOG;IACH,IAAI,CACF,IAAI,EAAE,UAAU,EAChB,SAAS,CAAC,EAAE,UAAU,EACtB,QAAQ,CAAC,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,GAC1C,MAAM;IAMT;;;;;;OAMG;IACH,KAAK,CACH,IAAI,CAAC,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,UAAU,EACtB,QAAQ,CAAC,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,GAC1C,MAAM;IAMT;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAIxC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAI1C;;;;OAIG;IACH,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI;IAwCpE,cAAc,EAAE,KAAK,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;CAC3B"}
|
package/es/base/comm.js
DELETED
|
@@ -1,151 +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, _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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
-
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); }
|
|
8
|
-
import { inject, transient } from '@difizen/mana-app';
|
|
9
|
-
import { WidgetCommOption } from "./protocal.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Public constructor
|
|
13
|
-
* @param {IComm} jsServicesComm - @jupyterlab/services IComm instance
|
|
14
|
-
*/
|
|
15
|
-
export var Comm = (_dec = transient(), _dec(_class = /*#__PURE__*/function () {
|
|
16
|
-
function Comm(options) {
|
|
17
|
-
_classCallCheck(this, Comm);
|
|
18
|
-
this.jsServicesComm = options.comm;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Comm id
|
|
23
|
-
* @return {string}
|
|
24
|
-
*/
|
|
25
|
-
Comm = inject(WidgetCommOption)(Comm, undefined, 0) || Comm;
|
|
26
|
-
_createClass(Comm, [{
|
|
27
|
-
key: "comm_id",
|
|
28
|
-
get: function get() {
|
|
29
|
-
return this.jsServicesComm.commId;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Target name
|
|
34
|
-
* @return {string}
|
|
35
|
-
*/
|
|
36
|
-
}, {
|
|
37
|
-
key: "target_name",
|
|
38
|
-
get: function get() {
|
|
39
|
-
return this.jsServicesComm.targetName;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Opens a sibling comm in the backend
|
|
44
|
-
* @param data
|
|
45
|
-
* @param callbacks
|
|
46
|
-
* @param metadata
|
|
47
|
-
* @return msg id
|
|
48
|
-
*/
|
|
49
|
-
}, {
|
|
50
|
-
key: "open",
|
|
51
|
-
value: function open(data, callbacks, metadata, buffers) {
|
|
52
|
-
var future = this.jsServicesComm.open(data, metadata, buffers);
|
|
53
|
-
this._hookupCallbacks(future, callbacks);
|
|
54
|
-
return future.msg.header.msg_id;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Sends a message to the sibling comm in the backend
|
|
59
|
-
* @param data
|
|
60
|
-
* @param callbacks
|
|
61
|
-
* @param metadata
|
|
62
|
-
* @param buffers
|
|
63
|
-
* @return message id
|
|
64
|
-
*/
|
|
65
|
-
}, {
|
|
66
|
-
key: "send",
|
|
67
|
-
value: function send(data, callbacks, metadata, buffers) {
|
|
68
|
-
var future = this.jsServicesComm.send(data, metadata, buffers);
|
|
69
|
-
this._hookupCallbacks(future, callbacks);
|
|
70
|
-
return future.msg.header.msg_id;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Closes the sibling comm in the backend
|
|
75
|
-
* @param data
|
|
76
|
-
* @param callbacks
|
|
77
|
-
* @param metadata
|
|
78
|
-
* @return msg id
|
|
79
|
-
*/
|
|
80
|
-
}, {
|
|
81
|
-
key: "close",
|
|
82
|
-
value: function close(data, callbacks, metadata, buffers) {
|
|
83
|
-
var future = this.jsServicesComm.close(data, metadata, buffers);
|
|
84
|
-
this._hookupCallbacks(future, callbacks);
|
|
85
|
-
return future.msg.header.msg_id;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Register a message handler
|
|
90
|
-
* @param callback, which is given a message
|
|
91
|
-
*/
|
|
92
|
-
}, {
|
|
93
|
-
key: "on_msg",
|
|
94
|
-
value: function on_msg(callback) {
|
|
95
|
-
this.jsServicesComm.onMsg = callback.bind(this);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Register a handler for when the comm is closed by the backend
|
|
100
|
-
* @param callback, which is given a message
|
|
101
|
-
*/
|
|
102
|
-
}, {
|
|
103
|
-
key: "on_close",
|
|
104
|
-
value: function on_close(callback) {
|
|
105
|
-
this.jsServicesComm.onClose = callback.bind(this);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Hooks callback object up with @jupyterlab/services IKernelFuture
|
|
110
|
-
* @param @jupyterlab/services IKernelFuture instance
|
|
111
|
-
* @param callbacks
|
|
112
|
-
*/
|
|
113
|
-
}, {
|
|
114
|
-
key: "_hookupCallbacks",
|
|
115
|
-
value: function _hookupCallbacks(future, callbacks) {
|
|
116
|
-
if (callbacks) {
|
|
117
|
-
future.onReply = function (msg) {
|
|
118
|
-
if (callbacks.shell && callbacks.shell['reply']) {
|
|
119
|
-
callbacks.shell['reply'](msg);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
future.onStdin = function (msg) {
|
|
123
|
-
if (callbacks.input) {
|
|
124
|
-
callbacks.input(msg);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
future.onIOPub = function (msg) {
|
|
128
|
-
if (callbacks.iopub) {
|
|
129
|
-
if (callbacks.iopub['status'] && msg.header.msg_type === 'status') {
|
|
130
|
-
callbacks.iopub['status'](msg);
|
|
131
|
-
} else if (callbacks.iopub['clear_output'] && msg.header.msg_type === 'clear_output') {
|
|
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
|
-
return Comm;
|
|
151
|
-
}()) || _class);
|
package/es/base/index.d.ts
DELETED
package/es/base/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,+BAA+B,CAAC"}
|
package/es/base/index.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { JSONObject } from '@difizen/libro-common';
|
|
2
|
-
import type { IKernelConnection, KernelMessage } from '@difizen/libro-kernel';
|
|
3
|
-
import type { Contribution } from '@difizen/mana-app';
|
|
4
|
-
import { Emitter } from '@difizen/mana-app';
|
|
5
|
-
import type { Comm } from './comm.js';
|
|
6
|
-
import type { IWidgets, IWidgetViewOptions, IClassicComm, WidgetCommOption } from './protocal.js';
|
|
7
|
-
import { WidgetsOption, WidgetViewContribution } from './protocal.js';
|
|
8
|
-
import type { WidgetView } from './widget-view.js';
|
|
9
|
-
export declare class LibroWidgets implements IWidgets {
|
|
10
|
-
WidgetViewProvider: Contribution.Provider<WidgetViewContribution>;
|
|
11
|
-
widgetEmitter: Emitter<{
|
|
12
|
-
WidgetViewName: string;
|
|
13
|
-
}>;
|
|
14
|
-
widgetCommFactory: (options: WidgetCommOption) => Comm;
|
|
15
|
-
kernelConnection: IKernelConnection;
|
|
16
|
-
constructor(options: WidgetsOption, widgetCommFactory: (options: WidgetCommOption) => Comm);
|
|
17
|
-
get onWidgetRender(): import("@difizen/mana-app").Event<{
|
|
18
|
-
WidgetViewName: string;
|
|
19
|
-
}>;
|
|
20
|
-
protected findProvider(attributes: any): WidgetViewContribution;
|
|
21
|
-
/**
|
|
22
|
-
* Create a comm which can be used for communication for a widget.
|
|
23
|
-
*
|
|
24
|
-
* If the data/metadata is passed in, open the comm before returning (i.e.,
|
|
25
|
-
* send the comm_open message). If the data and metadata is undefined, we
|
|
26
|
-
* want to reconstruct a comm that already exists in the kernel, so do not
|
|
27
|
-
* open the comm by sending the comm_open message.
|
|
28
|
-
*
|
|
29
|
-
* @param comm_target_name Comm target name
|
|
30
|
-
* @param model_id The comm id
|
|
31
|
-
* @param data The initial data for the comm
|
|
32
|
-
* @param metadata The metadata in the open message
|
|
33
|
-
*/
|
|
34
|
-
createComm(comm_target_name: string, model_id?: string, data?: JSONObject, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): Promise<IClassicComm>;
|
|
35
|
-
/**
|
|
36
|
-
* Get a model by model id.
|
|
37
|
-
*
|
|
38
|
-
* #### Notes
|
|
39
|
-
* If the model is not found, throw error.
|
|
40
|
-
*
|
|
41
|
-
* If you would like to synchronously test if a model exists, use .hasModel().
|
|
42
|
-
*/
|
|
43
|
-
getModel(model_id: string): WidgetView;
|
|
44
|
-
/**
|
|
45
|
-
* Returns true if the given model is registered, otherwise false.
|
|
46
|
-
*
|
|
47
|
-
* #### Notes
|
|
48
|
-
* This is a synchronous way to check if a model is registered.
|
|
49
|
-
*/
|
|
50
|
-
hasModel(model_id: string): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Handle when a comm is opened.
|
|
53
|
-
*/
|
|
54
|
-
handleCommOpen(comm: IClassicComm, msg: KernelMessage.ICommOpenMsg): Promise<WidgetView>;
|
|
55
|
-
registerWidgetView(model_id: string, model: Promise<WidgetView>): void;
|
|
56
|
-
handleCommClose(msg: KernelMessage.ICommCloseMsg): void;
|
|
57
|
-
unregisterWidgetView(model_id: string): void;
|
|
58
|
-
newWidgetView(attributes: any, options: IWidgetViewOptions): Promise<WidgetView>;
|
|
59
|
-
/**
|
|
60
|
-
* Close all widgets and empty the widget state.
|
|
61
|
-
* @return Promise that resolves when the widget state is cleared.
|
|
62
|
-
*/
|
|
63
|
-
clearState(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Disconnect the widget manager from the kernel, setting each model's comm
|
|
66
|
-
* as dead.
|
|
67
|
-
*/
|
|
68
|
-
disconnect(): void;
|
|
69
|
-
/**
|
|
70
|
-
* Dictionary of model ids and model instance promises
|
|
71
|
-
*/
|
|
72
|
-
protected models: Map<string, WidgetView>;
|
|
73
|
-
/**
|
|
74
|
-
* The comm target name to register
|
|
75
|
-
*/
|
|
76
|
-
id: string;
|
|
77
|
-
readonly commTargetName = "jupyter.widget";
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=libro-widgets.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"libro-widgets.d.ts","sourceRoot":"","sources":["../../src/base/libro-widgets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAEV,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,aAAa,EACb,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,qBACa,YAAa,YAAW,QAAQ;IAE3C,kBAAkB,EAAE,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;IAClE,aAAa,EAAE,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC,CAAiB;IACnE,iBAAiB,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACvD,gBAAgB,EAAE,iBAAiB,CAAC;gBAGX,OAAO,EAAE,aAAa,EAE7C,iBAAiB,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI;IAUxD,IAAI,cAAc;;OAEjB;IAED,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,GAAG,sBAAsB;IAS/D;;;;;;;;;;;;OAYG;IACG,UAAU,CACd,gBAAgB,EAAE,MAAM,EACxB,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,UAAU,EACjB,QAAQ,CAAC,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,GAC1C,OAAO,CAAC,YAAY,CAAC;IAYxB;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU;IAQtC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAInC;;OAEG;IACG,cAAc,CAClB,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,aAAa,CAAC,YAAY,GAC9B,OAAO,CAAC,UAAU,CAAC;IAkBtB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI;IAYtE,eAAe,CAAC,GAAG,EAAE,aAAa,CAAC,aAAa;IAMhD,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMtC,aAAa,CACjB,UAAU,EAAE,GAAG,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,UAAU,CAAC;IActB;;;OAGG;IACH,UAAU;IAGV;;;OAGG;IACH,UAAU,IAAI,IAAI;IAGlB;;OAEG;IAEH,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAa;IAEtD;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,cAAc,oBAAoB;CAC5C"}
|