@difizen/libro-kernel 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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/es/basemanager.d.ts +94 -0
- package/es/basemanager.d.ts.map +1 -0
- package/es/basemanager.js +110 -0
- package/es/contents/contents-drive.d.ts +189 -0
- package/es/contents/contents-drive.d.ts.map +1 -0
- package/es/contents/contents-drive.js +792 -0
- package/es/contents/contents-manager.d.ts +229 -0
- package/es/contents/contents-manager.d.ts.map +1 -0
- package/es/contents/contents-manager.js +551 -0
- package/es/contents/contents-module.d.ts +3 -0
- package/es/contents/contents-module.d.ts.map +1 -0
- package/es/contents/contents-module.js +4 -0
- package/es/contents/contents-protocol.d.ts +487 -0
- package/es/contents/contents-protocol.d.ts.map +1 -0
- package/es/contents/contents-protocol.js +1 -0
- package/es/contents/index.d.ts +6 -0
- package/es/contents/index.d.ts.map +1 -0
- package/es/contents/index.js +5 -0
- package/es/contents/validate.d.ts +10 -0
- package/es/contents/validate.d.ts.map +1 -0
- package/es/contents/validate.js +22 -0
- package/es/index.d.ts +10 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +9 -0
- package/es/index.less +0 -0
- package/es/kernel/comm.d.ts +92 -0
- package/es/kernel/comm.d.ts.map +1 -0
- package/es/kernel/comm.js +216 -0
- package/es/kernel/future.d.ts +178 -0
- package/es/kernel/future.d.ts.map +1 -0
- package/es/kernel/future.js +587 -0
- package/es/kernel/index.d.ts +8 -0
- package/es/kernel/index.d.ts.map +1 -0
- package/es/kernel/index.js +8 -0
- package/es/kernel/kernel-connection.d.ts +550 -0
- package/es/kernel/kernel-connection.d.ts.map +1 -0
- package/es/kernel/kernel-connection.js +1957 -0
- package/es/kernel/kernel-module.d.ts +3 -0
- package/es/kernel/kernel-module.d.ts.map +1 -0
- package/es/kernel/kernel-module.js +32 -0
- package/es/kernel/libro-kernel-manager.d.ts +69 -0
- package/es/kernel/libro-kernel-manager.d.ts.map +1 -0
- package/es/kernel/libro-kernel-manager.js +349 -0
- package/es/kernel/libro-kernel-protocol.d.ts +675 -0
- package/es/kernel/libro-kernel-protocol.d.ts.map +1 -0
- package/es/kernel/libro-kernel-protocol.js +60 -0
- package/es/kernel/libro-kernel-utils.d.ts +95 -0
- package/es/kernel/libro-kernel-utils.d.ts.map +1 -0
- package/es/kernel/libro-kernel-utils.js +130 -0
- package/es/kernel/libro-kernel.d.ts +14 -0
- package/es/kernel/libro-kernel.d.ts.map +1 -0
- package/es/kernel/libro-kernel.js +54 -0
- package/es/kernel/messages.d.ts +845 -0
- package/es/kernel/messages.d.ts.map +1 -0
- package/es/kernel/messages.js +457 -0
- package/es/kernel/restapi.d.ts +78 -0
- package/es/kernel/restapi.d.ts.map +1 -0
- package/es/kernel/restapi.js +367 -0
- package/es/kernel/serialize.d.ts +10 -0
- package/es/kernel/serialize.d.ts.map +1 -0
- package/es/kernel/serialize.js +214 -0
- package/es/kernel/validate.d.ts +15 -0
- package/es/kernel/validate.d.ts.map +1 -0
- package/es/kernel/validate.js +125 -0
- package/es/kernelspec/index.d.ts +5 -0
- package/es/kernelspec/index.d.ts.map +1 -0
- package/es/kernelspec/index.js +4 -0
- package/es/kernelspec/kernelspec-module.d.ts +3 -0
- package/es/kernelspec/kernelspec-module.d.ts.map +1 -0
- package/es/kernelspec/kernelspec-module.js +4 -0
- package/es/kernelspec/kernelspec.d.ts +33 -0
- package/es/kernelspec/kernelspec.d.ts.map +1 -0
- package/es/kernelspec/kernelspec.js +1 -0
- package/es/kernelspec/manager.d.ts +81 -0
- package/es/kernelspec/manager.d.ts.map +1 -0
- package/es/kernelspec/manager.js +248 -0
- package/es/kernelspec/restapi.d.ts +71 -0
- package/es/kernelspec/restapi.d.ts.map +1 -0
- package/es/kernelspec/restapi.js +107 -0
- package/es/kernelspec/validate.d.ts +10 -0
- package/es/kernelspec/validate.d.ts.map +1 -0
- package/es/kernelspec/validate.js +69 -0
- package/es/libro-kernel-connection-manager.d.ts +19 -0
- package/es/libro-kernel-connection-manager.d.ts.map +1 -0
- package/es/libro-kernel-connection-manager.js +142 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +9 -0
- package/es/page-config.d.ts +36 -0
- package/es/page-config.d.ts.map +1 -0
- package/es/page-config.js +129 -0
- package/es/protocol.d.ts +13 -0
- package/es/protocol.d.ts.map +1 -0
- package/es/protocol.js +8 -0
- package/es/server/connection-error.d.ts +36 -0
- package/es/server/connection-error.d.ts.map +1 -0
- package/es/server/connection-error.js +109 -0
- package/es/server/index.d.ts +6 -0
- package/es/server/index.d.ts.map +1 -0
- package/es/server/index.js +5 -0
- package/es/server/server-connection-protocol.d.ts +49 -0
- package/es/server/server-connection-protocol.d.ts.map +1 -0
- package/es/server/server-connection-protocol.js +0 -0
- package/es/server/server-connection.d.ts +25 -0
- package/es/server/server-connection.d.ts.map +1 -0
- package/es/server/server-connection.js +159 -0
- package/es/server/server-manager.d.ts +22 -0
- package/es/server/server-manager.d.ts.map +1 -0
- package/es/server/server-manager.js +163 -0
- package/es/server/server-module.d.ts +3 -0
- package/es/server/server-module.d.ts.map +1 -0
- package/es/server/server-module.js +4 -0
- package/es/session/index.d.ts +5 -0
- package/es/session/index.d.ts.map +1 -0
- package/es/session/index.js +4 -0
- package/es/session/libro-session-manager.d.ts +71 -0
- package/es/session/libro-session-manager.d.ts.map +1 -0
- package/es/session/libro-session-manager.js +539 -0
- package/es/session/libro-session-protocol.d.ts +50 -0
- package/es/session/libro-session-protocol.d.ts.map +1 -0
- package/es/session/libro-session-protocol.js +21 -0
- package/es/session/libro-session.d.ts +12 -0
- package/es/session/libro-session.d.ts.map +1 -0
- package/es/session/libro-session.js +19 -0
- package/es/session/restapi.d.ts +28 -0
- package/es/session/restapi.d.ts.map +1 -0
- package/es/session/restapi.js +214 -0
- package/es/session/session-module.d.ts +3 -0
- package/es/session/session-module.d.ts.map +1 -0
- package/es/session/session-module.js +18 -0
- package/es/session/validate.d.ts +14 -0
- package/es/session/validate.d.ts.map +1 -0
- package/es/session/validate.js +37 -0
- package/es/utils.d.ts +4 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +29 -0
- package/es/validate-property.d.ts +2 -0
- package/es/validate-property.d.ts.map +1 -0
- package/es/validate-property.js +35 -0
- package/package.json +62 -0
- package/src/basemanager.ts +133 -0
- package/src/contents/contents-drive.ts +495 -0
- package/src/contents/contents-manager.ts +465 -0
- package/src/contents/contents-module.ts +6 -0
- package/src/contents/contents-protocol.ts +604 -0
- package/src/contents/index.ts +5 -0
- package/src/contents/validate.ts +29 -0
- package/src/index.tsx +9 -0
- package/src/kernel/comm.ts +220 -0
- package/src/kernel/future.ts +474 -0
- package/src/kernel/index.ts +7 -0
- package/src/kernel/kernel-connection.ts +1770 -0
- package/src/kernel/kernel-module.ts +50 -0
- package/src/kernel/libro-kernel-manager.ts +199 -0
- package/src/kernel/libro-kernel-protocol.ts +858 -0
- package/src/kernel/libro-kernel-utils.ts +152 -0
- package/src/kernel/libro-kernel.ts +39 -0
- package/src/kernel/messages.ts +1104 -0
- package/src/kernel/restapi.ts +183 -0
- package/src/kernel/serialize.ts +262 -0
- package/src/kernel/validate.ts +101 -0
- package/src/kernelspec/index.ts +5 -0
- package/src/kernelspec/kernelspec-module.ts +9 -0
- package/src/kernelspec/kernelspec.ts +37 -0
- package/src/kernelspec/manager.ts +173 -0
- package/src/kernelspec/restapi.ts +104 -0
- package/src/kernelspec/validate.ts +80 -0
- package/src/libro-kernel-connection-manager.ts +73 -0
- package/src/module.ts +19 -0
- package/src/page-config.ts +106 -0
- package/src/protocol.ts +24 -0
- package/src/server/connection-error.ts +60 -0
- package/src/server/index.ts +5 -0
- package/src/server/server-connection-protocol.ts +57 -0
- package/src/server/server-connection.ts +144 -0
- package/src/server/server-manager.ts +76 -0
- package/src/server/server-module.ts +9 -0
- package/src/session/index.ts +4 -0
- package/src/session/libro-session-manager.ts +377 -0
- package/src/session/libro-session-protocol.ts +61 -0
- package/src/session/libro-session.ts +33 -0
- package/src/session/restapi.ts +126 -0
- package/src/session/session-module.ts +26 -0
- package/src/session/validate.ts +39 -0
- package/src/utils.ts +28 -0
- package/src/validate-property.ts +38 -0
|
@@ -0,0 +1,216 @@
|
|
|
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
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
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); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
|
+
import * as KernelMessage from "./messages.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Comm channel handler.
|
|
11
|
+
*/
|
|
12
|
+
export var CommHandler = /*#__PURE__*/function () {
|
|
13
|
+
/**
|
|
14
|
+
* Construct a new comm channel.
|
|
15
|
+
*/
|
|
16
|
+
function CommHandler(target, id, kernel, disposeCb) {
|
|
17
|
+
_classCallCheck(this, CommHandler);
|
|
18
|
+
this._target = '';
|
|
19
|
+
this._id = '';
|
|
20
|
+
this.disposed = false;
|
|
21
|
+
this.disposeCb = disposeCb;
|
|
22
|
+
this._id = id;
|
|
23
|
+
this._target = target;
|
|
24
|
+
this._kernel = kernel;
|
|
25
|
+
}
|
|
26
|
+
_createClass(CommHandler, [{
|
|
27
|
+
key: "dispose",
|
|
28
|
+
value: function dispose() {
|
|
29
|
+
this.disposeCb();
|
|
30
|
+
this.disposed = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The unique id for the comm channel.
|
|
35
|
+
*/
|
|
36
|
+
}, {
|
|
37
|
+
key: "commId",
|
|
38
|
+
get: function get() {
|
|
39
|
+
return this._id;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The target name for the comm channel.
|
|
44
|
+
*/
|
|
45
|
+
}, {
|
|
46
|
+
key: "targetName",
|
|
47
|
+
get: function get() {
|
|
48
|
+
return this._target;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get the callback for a comm close event.
|
|
53
|
+
*
|
|
54
|
+
* #### Notes
|
|
55
|
+
* This is called when the comm is closed from either the server or client.
|
|
56
|
+
*
|
|
57
|
+
* **See also:** [[ICommClose]], [[close]]
|
|
58
|
+
*/
|
|
59
|
+
}, {
|
|
60
|
+
key: "onClose",
|
|
61
|
+
get: function get() {
|
|
62
|
+
return this._onClose;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Set the callback for a comm close event.
|
|
67
|
+
*
|
|
68
|
+
* #### Notes
|
|
69
|
+
* This is called when the comm is closed from either the server or client. If
|
|
70
|
+
* the function returns a promise, and the kernel was closed from the server,
|
|
71
|
+
* kernel message processing will pause until the returned promise is
|
|
72
|
+
* fulfilled.
|
|
73
|
+
*
|
|
74
|
+
* **See also:** [[close]]
|
|
75
|
+
*/,
|
|
76
|
+
set: function set(cb) {
|
|
77
|
+
this._onClose = cb;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get the callback for a comm message received event.
|
|
82
|
+
*/
|
|
83
|
+
}, {
|
|
84
|
+
key: "onMsg",
|
|
85
|
+
get: function get() {
|
|
86
|
+
return this._onMsg;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Set the callback for a comm message received event.
|
|
91
|
+
*
|
|
92
|
+
* #### Notes
|
|
93
|
+
* This is called when a comm message is received. If the function returns a
|
|
94
|
+
* promise, kernel message processing will pause until it is fulfilled.
|
|
95
|
+
*/,
|
|
96
|
+
set: function set(cb) {
|
|
97
|
+
this._onMsg = cb;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Open a comm with optional data and metadata.
|
|
102
|
+
*
|
|
103
|
+
* #### Notes
|
|
104
|
+
* This sends a `comm_open` message to the server.
|
|
105
|
+
*
|
|
106
|
+
* **See also:** [[ICommOpen]]
|
|
107
|
+
*/
|
|
108
|
+
}, {
|
|
109
|
+
key: "open",
|
|
110
|
+
value: function open(data, metadata) {
|
|
111
|
+
var buffers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
112
|
+
if (this.disposed || this._kernel.disposed) {
|
|
113
|
+
throw new Error('Cannot open');
|
|
114
|
+
}
|
|
115
|
+
var msg = KernelMessage.createMessage({
|
|
116
|
+
msgType: 'comm_open',
|
|
117
|
+
channel: 'shell',
|
|
118
|
+
username: this._kernel.username,
|
|
119
|
+
session: this._kernel.clientId,
|
|
120
|
+
content: {
|
|
121
|
+
comm_id: this._id,
|
|
122
|
+
target_name: this._target,
|
|
123
|
+
data: data !== null && data !== void 0 ? data : {}
|
|
124
|
+
},
|
|
125
|
+
metadata: metadata,
|
|
126
|
+
buffers: buffers
|
|
127
|
+
});
|
|
128
|
+
return this._kernel.sendShellMessage(msg, false, true);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Send a `comm_msg` message to the kernel.
|
|
133
|
+
*
|
|
134
|
+
* #### Notes
|
|
135
|
+
* This is a no-op if the comm has been closed.
|
|
136
|
+
*
|
|
137
|
+
* **See also:** [[ICommMsg]]
|
|
138
|
+
*/
|
|
139
|
+
}, {
|
|
140
|
+
key: "send",
|
|
141
|
+
value: function send(data, metadata) {
|
|
142
|
+
var buffers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
143
|
+
var disposeOnDone = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
144
|
+
if (this.disposed || this._kernel.disposed) {
|
|
145
|
+
throw new Error('Cannot send');
|
|
146
|
+
}
|
|
147
|
+
var msg = KernelMessage.createMessage({
|
|
148
|
+
msgType: 'comm_msg',
|
|
149
|
+
channel: 'shell',
|
|
150
|
+
username: this._kernel.username,
|
|
151
|
+
session: this._kernel.clientId,
|
|
152
|
+
content: {
|
|
153
|
+
comm_id: this._id,
|
|
154
|
+
data: data
|
|
155
|
+
},
|
|
156
|
+
metadata: metadata,
|
|
157
|
+
buffers: buffers
|
|
158
|
+
});
|
|
159
|
+
return this._kernel.sendShellMessage(msg, false, disposeOnDone);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Close the comm.
|
|
164
|
+
*
|
|
165
|
+
* #### Notes
|
|
166
|
+
* This will send a `comm_close` message to the kernel, and call the
|
|
167
|
+
* `onClose` callback if set.
|
|
168
|
+
*
|
|
169
|
+
* This is a no-op if the comm is already closed.
|
|
170
|
+
*
|
|
171
|
+
* **See also:** [[ICommClose]], [[onClose]]
|
|
172
|
+
*/
|
|
173
|
+
}, {
|
|
174
|
+
key: "close",
|
|
175
|
+
value: function close(data, metadata) {
|
|
176
|
+
var buffers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
177
|
+
if (this.disposed || this._kernel.disposed) {
|
|
178
|
+
throw new Error('Cannot close');
|
|
179
|
+
}
|
|
180
|
+
var msg = KernelMessage.createMessage({
|
|
181
|
+
msgType: 'comm_close',
|
|
182
|
+
channel: 'shell',
|
|
183
|
+
username: this._kernel.username,
|
|
184
|
+
session: this._kernel.clientId,
|
|
185
|
+
content: {
|
|
186
|
+
comm_id: this._id,
|
|
187
|
+
data: data !== null && data !== void 0 ? data : {}
|
|
188
|
+
},
|
|
189
|
+
metadata: metadata,
|
|
190
|
+
buffers: buffers
|
|
191
|
+
});
|
|
192
|
+
var future = this._kernel.sendShellMessage(msg, false, true);
|
|
193
|
+
var onClose = this._onClose;
|
|
194
|
+
if (onClose) {
|
|
195
|
+
var ioMsg = KernelMessage.createMessage({
|
|
196
|
+
msgType: 'comm_close',
|
|
197
|
+
channel: 'iopub',
|
|
198
|
+
username: this._kernel.username,
|
|
199
|
+
session: this._kernel.clientId,
|
|
200
|
+
content: {
|
|
201
|
+
comm_id: this._id,
|
|
202
|
+
data: data !== null && data !== void 0 ? data : {}
|
|
203
|
+
},
|
|
204
|
+
metadata: metadata,
|
|
205
|
+
buffers: buffers
|
|
206
|
+
});
|
|
207
|
+
// In the future, we may want to communicate back to the user the possible
|
|
208
|
+
// promise returned from onClose.
|
|
209
|
+
void onClose(ioMsg);
|
|
210
|
+
}
|
|
211
|
+
this.dispose();
|
|
212
|
+
return future;
|
|
213
|
+
}
|
|
214
|
+
}]);
|
|
215
|
+
return CommHandler;
|
|
216
|
+
}();
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { Disposable } from '@difizen/mana-app';
|
|
2
|
+
import { Deferred } from '@difizen/mana-app';
|
|
3
|
+
import type { IKernelConnection, IControlFuture, IShellFuture, IFuture } from './libro-kernel-protocol.js';
|
|
4
|
+
import type * as KernelMessage from './messages.js';
|
|
5
|
+
declare namespace Private {
|
|
6
|
+
/**
|
|
7
|
+
* A no-op function.
|
|
8
|
+
*/
|
|
9
|
+
const noOp: () => void;
|
|
10
|
+
class HookList<T> {
|
|
11
|
+
/**
|
|
12
|
+
* Register a hook.
|
|
13
|
+
*
|
|
14
|
+
* @param hook - The callback to register.
|
|
15
|
+
*/
|
|
16
|
+
add(hook: (msg: T) => boolean | PromiseLike<boolean>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Remove a hook, if it exists in the hook list.
|
|
19
|
+
*
|
|
20
|
+
* @param hook - The callback to remove.
|
|
21
|
+
*/
|
|
22
|
+
remove(hook: (msg: T) => boolean | PromiseLike<boolean>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Process a message through the hooks.
|
|
25
|
+
*
|
|
26
|
+
* @returns a promise resolving to false if any hook resolved as false,
|
|
27
|
+
* otherwise true
|
|
28
|
+
*
|
|
29
|
+
* #### Notes
|
|
30
|
+
* The most recently registered hook is run first. A hook can return a
|
|
31
|
+
* boolean or a promise to a boolean, in which case processing pauses until
|
|
32
|
+
* the promise is fulfilled. If a hook return value resolves to false, any
|
|
33
|
+
* later hooks will not run and the function will return a promise resolving
|
|
34
|
+
* to false. If a hook throws an error, the error is logged to the console
|
|
35
|
+
* and the next hook is run. If a hook is registered during the hook
|
|
36
|
+
* processing, it will not run until the next message. If a hook is removed
|
|
37
|
+
* during the hook processing, it will be deactivated immediately.
|
|
38
|
+
*/
|
|
39
|
+
process(msg: T): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Schedule a cleanup of the list, removing any hooks that have been nulled out.
|
|
42
|
+
*/
|
|
43
|
+
protected _scheduleCompact(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Compact the list, removing any nulls.
|
|
46
|
+
*/
|
|
47
|
+
protected _compact(): void;
|
|
48
|
+
protected _hooks: (((msg: T) => boolean | PromiseLike<boolean>) | null)[];
|
|
49
|
+
protected _compactScheduled: boolean;
|
|
50
|
+
protected _processing: Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Bit flags for the kernel future state.
|
|
54
|
+
*/
|
|
55
|
+
enum KernelFutureFlag {
|
|
56
|
+
GotReply = 1,
|
|
57
|
+
GotIdle = 2,
|
|
58
|
+
IsDone = 4,
|
|
59
|
+
DisposeOnDone = 8
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Implementation of a kernel future.
|
|
64
|
+
*
|
|
65
|
+
* If a reply is expected, the Future is considered done when both a `reply`
|
|
66
|
+
* message and an `idle` iopub status message have been received. Otherwise, it
|
|
67
|
+
* is considered done when the `idle` status is received.
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
export declare abstract class KernelFutureHandler<REQUEST extends KernelMessage.IShellControlMessage, REPLY extends KernelMessage.IShellControlMessage> implements Disposable, IFuture<REQUEST, REPLY> {
|
|
71
|
+
protected disposeCb: () => void;
|
|
72
|
+
disposed: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Construct a new KernelFutureHandler.
|
|
75
|
+
*/
|
|
76
|
+
constructor(cb: () => void, msg: REQUEST, expectReply: boolean, disposeOnDone: boolean, kernel: IKernelConnection);
|
|
77
|
+
/**
|
|
78
|
+
* Get the original outgoing message.
|
|
79
|
+
*/
|
|
80
|
+
get msg(): REQUEST;
|
|
81
|
+
/**
|
|
82
|
+
* A promise that resolves when the future is done.
|
|
83
|
+
*/
|
|
84
|
+
get done(): Promise<REPLY>;
|
|
85
|
+
/**
|
|
86
|
+
* Get the reply handler.
|
|
87
|
+
*/
|
|
88
|
+
get onReply(): (msg: REPLY) => void | PromiseLike<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Set the reply handler.
|
|
91
|
+
*/
|
|
92
|
+
set onReply(cb: (msg: REPLY) => void | PromiseLike<void>);
|
|
93
|
+
/**
|
|
94
|
+
* Get the iopub handler.
|
|
95
|
+
*/
|
|
96
|
+
get onIOPub(): (msg: KernelMessage.IIOPubMessage) => void | PromiseLike<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Set the iopub handler.
|
|
99
|
+
*/
|
|
100
|
+
set onIOPub(cb: (msg: KernelMessage.IIOPubMessage) => void | PromiseLike<void>);
|
|
101
|
+
/**
|
|
102
|
+
* Get the stdin handler.
|
|
103
|
+
*/
|
|
104
|
+
get onStdin(): (msg: KernelMessage.IStdinMessage) => void | PromiseLike<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Set the stdin handler.
|
|
107
|
+
*/
|
|
108
|
+
set onStdin(cb: (msg: KernelMessage.IStdinMessage) => void | PromiseLike<void>);
|
|
109
|
+
/**
|
|
110
|
+
* Register hook for IOPub messages.
|
|
111
|
+
*
|
|
112
|
+
* @param hook - The callback invoked for an IOPub message.
|
|
113
|
+
*
|
|
114
|
+
* #### Notes
|
|
115
|
+
* The IOPub hook system allows you to preempt the handlers for IOPub
|
|
116
|
+
* messages handled by the future.
|
|
117
|
+
*
|
|
118
|
+
* The most recently registered hook is run first. A hook can return a
|
|
119
|
+
* boolean or a promise to a boolean, in which case all kernel message
|
|
120
|
+
* processing pauses until the promise is fulfilled. If a hook return value
|
|
121
|
+
* resolves to false, any later hooks will not run and the function will
|
|
122
|
+
* return a promise resolving to false. If a hook throws an error, the error
|
|
123
|
+
* is logged to the console and the next hook is run. If a hook is
|
|
124
|
+
* registered during the hook processing, it will not run until the next
|
|
125
|
+
* message. If a hook is removed during the hook processing, it will be
|
|
126
|
+
* deactivated immediately.
|
|
127
|
+
*/
|
|
128
|
+
registerMessageHook(hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>): void;
|
|
129
|
+
/**
|
|
130
|
+
* Remove a hook for IOPub messages.
|
|
131
|
+
*
|
|
132
|
+
* @param hook - The hook to remove.
|
|
133
|
+
*
|
|
134
|
+
* #### Notes
|
|
135
|
+
* If a hook is removed during the hook processing, it will be deactivated immediately.
|
|
136
|
+
*/
|
|
137
|
+
removeMessageHook(hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>): void;
|
|
138
|
+
/**
|
|
139
|
+
* Send an `input_reply` message.
|
|
140
|
+
*/
|
|
141
|
+
sendInputReply(content: KernelMessage.IInputReplyMsg['content'], parent_header: KernelMessage.IInputReplyMsg['parent_header']): void;
|
|
142
|
+
/**
|
|
143
|
+
* Dispose and unregister the future.
|
|
144
|
+
*/
|
|
145
|
+
dispose(): void;
|
|
146
|
+
/**
|
|
147
|
+
* Handle an incoming kernel message.
|
|
148
|
+
*/
|
|
149
|
+
handleMsg(msg: KernelMessage.IMessage): Promise<void>;
|
|
150
|
+
protected _handleReply(msg: REPLY): Promise<void>;
|
|
151
|
+
protected _handleStdin(msg: KernelMessage.IStdinMessage): Promise<void>;
|
|
152
|
+
protected _handleIOPub(msg: KernelMessage.IIOPubMessage): Promise<void>;
|
|
153
|
+
protected _handleDone(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Test whether the given future flag is set.
|
|
156
|
+
*/
|
|
157
|
+
protected _testFlag(flag: Private.KernelFutureFlag): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Set the given future flag.
|
|
160
|
+
*/
|
|
161
|
+
protected _setFlag(flag: Private.KernelFutureFlag): void;
|
|
162
|
+
protected _msg: REQUEST;
|
|
163
|
+
protected _status: number;
|
|
164
|
+
protected _stdin: (msg: KernelMessage.IStdinMessage) => void | PromiseLike<void>;
|
|
165
|
+
protected _iopub: (msg: KernelMessage.IIOPubMessage) => void | PromiseLike<void>;
|
|
166
|
+
protected _reply: (msg: REPLY) => void | PromiseLike<void>;
|
|
167
|
+
protected _done: Deferred<REPLY>;
|
|
168
|
+
protected _replyMsg: REPLY;
|
|
169
|
+
protected _hooks: Private.HookList<KernelMessage.IIOPubMessage<KernelMessage.IOPubMessageType>>;
|
|
170
|
+
protected _disposeOnDone: boolean;
|
|
171
|
+
protected _kernel: IKernelConnection;
|
|
172
|
+
}
|
|
173
|
+
export declare class KernelControlFutureHandler<REQUEST extends KernelMessage.IControlMessage = KernelMessage.IControlMessage, REPLY extends KernelMessage.IControlMessage = KernelMessage.IControlMessage> extends KernelFutureHandler<REQUEST, REPLY> implements IControlFuture<REQUEST, REPLY> {
|
|
174
|
+
}
|
|
175
|
+
export declare class KernelShellFutureHandler<REQUEST extends KernelMessage.IShellMessage = KernelMessage.IShellMessage, REPLY extends KernelMessage.IShellMessage = KernelMessage.IShellMessage> extends KernelFutureHandler<REQUEST, REPLY> implements IShellFuture<REQUEST, REPLY> {
|
|
176
|
+
}
|
|
177
|
+
export {};
|
|
178
|
+
//# sourceMappingURL=future.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"future.d.ts","sourceRoot":"","sources":["../../src/kernel/future.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,OAAO,EACR,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,KAAK,aAAa,MAAM,eAAe,CAAC;AAIpD,kBAAU,OAAO,CAAC;IAChB;;OAEG;IACI,MAAM,IAAI,QAAO,IAEvB,CAAC;IAeF,MAAa,QAAQ,CAAC,CAAC;QACrB;;;;WAIG;QACH,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;QAK3D;;;;WAIG;QACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;QAQ9D;;;;;;;;;;;;;;;WAeG;QACG,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;QA0CvC;;WAEG;QACH,SAAS,CAAC,gBAAgB,IAAI,IAAI;QAkBlC;;WAEG;QACH,SAAS,CAAC,QAAQ,IAAI,IAAI;QAa1B,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,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