@jupyterlab/services
Advanced tools
Comparing version
@@ -28,2 +28,13 @@ import { JSONObject } from '@phosphor/coreutils'; | ||
/** | ||
* Handle comm messages | ||
* | ||
* #### Notes | ||
* The comm message protocol currently has implicit assumptions that only | ||
* one kernel connection is handling comm messages. This option allows a | ||
* kernel connection to opt out of handling comms. | ||
* | ||
* See https://github.com/jupyter/jupyter_client/issues/263 | ||
*/ | ||
readonly handleComms: boolean; | ||
/** | ||
* A signal emitted when the kernel status changes. | ||
@@ -110,3 +121,3 @@ */ | ||
*/ | ||
clone(): Kernel.IKernel; | ||
clone(options?: Kernel.IOptions): Kernel.IKernel; | ||
/** | ||
@@ -269,2 +280,13 @@ * Dispose of the resources held by the kernel. | ||
/** | ||
* Send an experimental `debug_request` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this function is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
requestDebug(content: KernelMessage.IDebugRequestMsg['content'], disposeOnDone?: boolean): Kernel.IControlFuture<KernelMessage.IDebugRequestMsg, KernelMessage.IDebugReplyMsg>; | ||
/** | ||
* Send an `is_complete_request` message. | ||
@@ -299,2 +321,3 @@ * | ||
* If a client-side comm already exists with the given commId, it is returned. | ||
* An error is thrown if the kernel does not handle comms. | ||
*/ | ||
@@ -329,3 +352,3 @@ connectToComm(targetName: string, commId?: string): Kernel.IComm; | ||
* #### Notes | ||
* The comm target is only removed the callback argument matches. | ||
* The comm target is only removed if the callback argument matches. | ||
*/ | ||
@@ -332,0 +355,0 @@ removeCommTarget(targetName: string, callback: (comm: Kernel.IComm, msg: KernelMessage.ICommOpenMsg) => void | PromiseLike<void>): void; |
@@ -188,2 +188,4 @@ "use strict"; | ||
this._username = options.username || ''; | ||
this.handleComms = | ||
options.handleComms === undefined ? true : options.handleComms; | ||
void this._readyPromise.promise.then(() => { | ||
@@ -319,8 +321,4 @@ this._sendPending(); | ||
*/ | ||
clone() { | ||
return new DefaultKernel({ | ||
name: this._name, | ||
username: this._username, | ||
serverSettings: this.serverSettings | ||
}, this._id); | ||
clone(options = {}) { | ||
return new DefaultKernel(Object.assign({ name: this._name, username: this._username, serverSettings: this.serverSettings, handleComms: this.handleComms }, options), this._id); | ||
} | ||
@@ -626,2 +624,22 @@ /** | ||
/** | ||
* Send an experimental `debug_request` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this function is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
requestDebug(content, disposeOnDone = true) { | ||
let msg = messages_1.KernelMessage.createMessage({ | ||
msgType: 'debug_request', | ||
channel: 'control', | ||
username: this._username, | ||
session: this._clientId, | ||
content | ||
}); | ||
return this.sendControlMessage(msg, true, disposeOnDone); | ||
} | ||
/** | ||
* Send an `is_complete_request` message. | ||
@@ -692,4 +710,8 @@ * | ||
* If a client-side comm already exists with the given commId, it is returned. | ||
* An error is thrown if the kernel does not handle comms. | ||
*/ | ||
connectToComm(targetName, commId = coreutils_2.UUID.uuid4()) { | ||
if (!this.handleComms) { | ||
throw new Error('Comms are disabled on this kernel connection'); | ||
} | ||
if (this._comms.has(commId)) { | ||
@@ -723,2 +745,5 @@ return this._comms.get(commId); | ||
registerCommTarget(targetName, callback) { | ||
if (!this.handleComms) { | ||
return; | ||
} | ||
this._targetRegistry[targetName] = callback; | ||
@@ -734,5 +759,8 @@ } | ||
* #### Notes | ||
* The comm target is only removed the callback argument matches. | ||
* The comm target is only removed if the callback argument matches. | ||
*/ | ||
removeCommTarget(targetName, callback) { | ||
if (!this.handleComms) { | ||
return; | ||
} | ||
if (!this.isDisposed && this._targetRegistry[targetName] === callback) { | ||
@@ -1078,9 +1106,15 @@ delete this._targetRegistry[targetName]; | ||
case 'comm_open': | ||
await this._handleCommOpen(msg); | ||
if (this.handleComms) { | ||
await this._handleCommOpen(msg); | ||
} | ||
break; | ||
case 'comm_msg': | ||
await this._handleCommMsg(msg); | ||
if (this.handleComms) { | ||
await this._handleCommMsg(msg); | ||
} | ||
break; | ||
case 'comm_close': | ||
await this._handleCommClose(msg); | ||
if (this.handleComms) { | ||
await this._handleCommClose(msg); | ||
} | ||
break; | ||
@@ -1355,3 +1389,9 @@ default: | ||
if (kernel) { | ||
return kernel.clone(); | ||
// If there is already a kernel connection handling comms, don't handle | ||
// them in our clone, since the comm message protocol has implicit | ||
// assumptions that only one connection is handling comm messages. | ||
// See https://github.com/jupyter/jupyter_client/issues/263 | ||
const handleComms = !algorithm_1.some(Private.runningKernels, k => k.id === model.id && k.handleComms); | ||
const newKernel = kernel.clone({ handleComms }); | ||
return newKernel; | ||
} | ||
@@ -1358,0 +1398,0 @@ return new DefaultKernel({ name: model.name, serverSettings }, model.id); |
@@ -74,2 +74,13 @@ import { IIterator } from '@phosphor/algorithm'; | ||
/** | ||
* Whether the kernel connection handles comm messages. | ||
* | ||
* #### Notes | ||
* The comm message protocol currently has implicit assumptions that only | ||
* one kernel connection is handling comm messages. This option allows a | ||
* kernel connection to opt out of handling comms. | ||
* | ||
* See https://github.com/jupyter/jupyter_client/issues/263 | ||
*/ | ||
handleComms: boolean; | ||
/** | ||
* Get the kernel spec. | ||
@@ -232,2 +243,19 @@ * | ||
/** | ||
* Send an experimental `debug_request` message. | ||
* | ||
* @hidden | ||
* | ||
* @param content - The content of the request. | ||
* | ||
* @param disposeOnDone - Whether to dispose of the future when done. | ||
* | ||
* @returns A kernel future. | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this function is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
requestDebug(content: KernelMessage.IDebugRequestMsg['content'], disposeOnDone?: boolean): Kernel.IControlFuture<KernelMessage.IDebugRequestMsg, KernelMessage.IDebugReplyMsg>; | ||
/** | ||
* Send an `is_complete_request` message. | ||
@@ -492,2 +520,13 @@ * | ||
/** | ||
* Whether the kernel connection should handle comm messages | ||
* | ||
* #### Notes | ||
* The comm message protocol currently has implicit assumptions that only | ||
* one kernel connection is handling comm messages. This option allows a | ||
* kernel connection to opt out of handling comms. | ||
* | ||
* See https://github.com/jupyter/jupyter_client/issues/263 | ||
*/ | ||
handleComms?: boolean; | ||
/** | ||
* The unique identifier for the kernel client. | ||
@@ -494,0 +533,0 @@ */ |
@@ -50,2 +50,26 @@ import { nbformat } from '@jupyterlab/coreutils'; | ||
/** | ||
* @hidden | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this function is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function createMessage<T extends IDebugRequestMsg>(options: IOptions<T>): T; | ||
/** | ||
* @hidden | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this function is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function createMessage<T extends IDebugReplyMsg>(options: IOptions<T>): T; | ||
/** | ||
* @hidden | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this function is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function createMessage<T extends IDebugEventMsg>(options: IOptions<T>): T; | ||
/** | ||
* Shell message types. | ||
@@ -56,8 +80,18 @@ */ | ||
* Control message types. | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, debug message types are *NOT* | ||
* considered part of the public API, and may change without notice. | ||
*/ | ||
type ControlMessageType = never; | ||
type ControlMessageType = 'debug_request' | 'debug_reply'; | ||
/** | ||
* IOPub message types. | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, debug message types are *NOT* | ||
* considered part of the public API, and may change without notice. | ||
*/ | ||
type IOPubMessageType = 'clear_output' | 'comm_close' | 'comm_msg' | 'comm_open' | 'display_data' | 'error' | 'execute_input' | 'execute_result' | 'status' | 'stream' | 'update_display_data'; | ||
type IOPubMessageType = 'clear_output' | 'comm_close' | 'comm_msg' | 'comm_open' | 'display_data' | 'error' | 'execute_input' | 'execute_result' | 'status' | 'stream' | 'update_display_data' | 'debug_event'; | ||
/** | ||
@@ -170,4 +204,12 @@ * Stdin message types. | ||
} | ||
type Message = IClearOutputMsg | ICommCloseMsg<'iopub'> | ICommCloseMsg<'shell'> | ICommInfoReplyMsg | ICommInfoRequestMsg | ICommMsgMsg<'iopub'> | ICommMsgMsg<'shell'> | ICommOpenMsg<'iopub'> | ICommOpenMsg<'shell'> | ICompleteReplyMsg | ICompleteRequestMsg | IDisplayDataMsg | IErrorMsg | IExecuteInputMsg | IExecuteReplyMsg | IExecuteRequestMsg | IExecuteResultMsg | IHistoryReplyMsg | IHistoryRequestMsg | IInfoReplyMsg | IInfoRequestMsg | IInputReplyMsg | IInputRequestMsg | IInspectReplyMsg | IInspectRequestMsg | IIsCompleteReplyMsg | IIsCompleteRequestMsg | IStatusMsg | IStreamMsg | IUpdateDisplayDataMsg; | ||
/** | ||
* Message types. | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, debug message types are *NOT* | ||
* considered part of the public API, and may change without notice. | ||
*/ | ||
type Message = IClearOutputMsg | ICommCloseMsg<'iopub'> | ICommCloseMsg<'shell'> | ICommInfoReplyMsg | ICommInfoRequestMsg | ICommMsgMsg<'iopub'> | ICommMsgMsg<'shell'> | ICommOpenMsg<'iopub'> | ICommOpenMsg<'shell'> | ICompleteReplyMsg | ICompleteRequestMsg | IDisplayDataMsg | IErrorMsg | IExecuteInputMsg | IExecuteReplyMsg | IExecuteRequestMsg | IExecuteResultMsg | IHistoryReplyMsg | IHistoryRequestMsg | IInfoReplyMsg | IInfoRequestMsg | IInputReplyMsg | IInputRequestMsg | IInspectReplyMsg | IInspectRequestMsg | IIsCompleteReplyMsg | IIsCompleteRequestMsg | IStatusMsg | IStreamMsg | IUpdateDisplayDataMsg | IDebugRequestMsg | IDebugReplyMsg | IDebugEventMsg; | ||
/** | ||
* A `'stream'` message on the `'iopub'` channel. | ||
@@ -300,2 +342,31 @@ * | ||
/** | ||
* An experimental `'debug_event'` message on the `'iopub'` channel | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
interface IDebugEventMsg extends IIOPubMessage<'debug_event'> { | ||
content: { | ||
seq: number; | ||
type: 'event'; | ||
event: string; | ||
body?: any; | ||
}; | ||
} | ||
/** | ||
* Test whether a kernel message is an experimental `'debug_event'` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function isDebugEventMsg(msg: IMessage): msg is IDebugEventMsg; | ||
/** | ||
* A `'comm_open'` message on the `'iopub'` channel. | ||
@@ -745,2 +816,63 @@ * | ||
/** | ||
* An experimental `'debug_request'` messsage on the `'control'` channel. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this function is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
interface IDebugRequestMsg extends IControlMessage<'debug_request'> { | ||
content: { | ||
seq: number; | ||
type: 'request'; | ||
command: string; | ||
arguments?: any; | ||
}; | ||
} | ||
/** | ||
* Test whether a kernel message is an experimental `'debug_request'` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function isDebugRequestMsg(msg: IMessage): msg is IDebugRequestMsg; | ||
/** | ||
* An experimental `'debug_reply'` messsage on the `'control'` channel. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
interface IDebugReplyMsg extends IControlMessage<'debug_reply'> { | ||
content: { | ||
seq: number; | ||
type: 'response'; | ||
request_seq: number; | ||
success: boolean; | ||
command: string; | ||
message?: string; | ||
body?: any; | ||
}; | ||
} | ||
/** | ||
* Test whether a kernel message is an experimental `'debug_reply'` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function isDebugReplyMsg(msg: IMessage): msg is IDebugReplyMsg; | ||
/** | ||
* An `'input_request'` message on the `'stdin'` channel. | ||
@@ -747,0 +879,0 @@ * |
@@ -86,2 +86,16 @@ "use strict"; | ||
/** | ||
* Test whether a kernel message is an experimental `'debug_event'` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function isDebugEventMsg(msg) { | ||
return msg.header.msg_type === 'debug_event'; | ||
} | ||
KernelMessage.isDebugEventMsg = isDebugEventMsg; | ||
/** | ||
* Test whether a kernel message is a `'comm_open'` message. | ||
@@ -122,2 +136,30 @@ */ | ||
/** | ||
* Test whether a kernel message is an experimental `'debug_request'` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function isDebugRequestMsg(msg) { | ||
return msg.header.msg_type === 'debug_request'; | ||
} | ||
KernelMessage.isDebugRequestMsg = isDebugRequestMsg; | ||
/** | ||
* Test whether a kernel message is an experimental `'debug_reply'` message. | ||
* | ||
* @hidden | ||
* | ||
* #### Notes | ||
* Debug messages are experimental messages that are not in the official | ||
* kernel message specification. As such, this is *NOT* considered | ||
* part of the public API, and may change without notice. | ||
*/ | ||
function isDebugReplyMsg(msg) { | ||
return msg.header.msg_type === 'debug_reply'; | ||
} | ||
KernelMessage.isDebugReplyMsg = isDebugReplyMsg; | ||
/** | ||
* Test whether a kernel message is an `'input_request'` message. | ||
@@ -124,0 +166,0 @@ */ |
{ | ||
"name": "@jupyterlab/services", | ||
"version": "4.0.2", | ||
"version": "4.1.0-alpha.0", | ||
"description": "Client APIs for the Jupyter services REST APIs", | ||
@@ -44,4 +44,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@jupyterlab/coreutils": "^3.0.0", | ||
"@jupyterlab/observables": "^2.2.0", | ||
"@jupyterlab/coreutils": "^3.1.0-alpha.0", | ||
"@jupyterlab/observables": "^2.3.0-alpha.0", | ||
"@phosphor/algorithm": "^1.1.3", | ||
@@ -67,3 +67,3 @@ "@phosphor/coreutils": "^1.3.1", | ||
}, | ||
"gitHead": "325e6244934e6e3b29c630e326953101f7ec172d" | ||
"gitHead": "e9d6c1c8cd4caca69a7b32359a27a6a336f94125" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1447309
0.92%15684
1.81%1
Infinity%