@jupyterlab/services
Advanced tools
Comparing version 0.23.0 to 0.24.0
@@ -1,2 +0,1 @@ | ||
import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
import { JSONObject } from 'phosphor/lib/algorithm/json'; | ||
@@ -208,3 +207,3 @@ import { IAjaxSettings } from '../utils'; | ||
*/ | ||
listCheckpoints(path: string): Promise<IIterator<ICheckpointModel>>; | ||
listCheckpoints(path: string): Promise<ICheckpointModel[]>; | ||
/** | ||
@@ -370,3 +369,3 @@ * Restore a file to a known checkpoint state. | ||
*/ | ||
listCheckpoints(path: string): Promise<IIterator<Contents.ICheckpointModel>>; | ||
listCheckpoints(path: string): Promise<Contents.ICheckpointModel[]>; | ||
/** | ||
@@ -373,0 +372,0 @@ * Restore a file to a known checkpoint state. |
@@ -5,3 +5,2 @@ // Copyright (c) Jupyter Development Team. | ||
var posix = require('path-posix'); | ||
var iteration_1 = require('phosphor/lib/algorithm/iteration'); | ||
var utils = require('../utils'); | ||
@@ -340,3 +339,3 @@ var validate = require('./validate'); | ||
} | ||
return iteration_1.iter(success.data); | ||
return success.data; | ||
}); | ||
@@ -343,0 +342,0 @@ }; |
import { JSONObject, JSONValue } from 'phosphor/lib/algorithm/json'; | ||
import { DisposableDelegate } from 'phosphor/lib/core/disposable'; | ||
import { IKernel, Kernel } from './kernel'; | ||
import { Kernel } from './kernel'; | ||
import { KernelMessage } from './messages'; | ||
@@ -12,3 +12,3 @@ /** | ||
*/ | ||
constructor(target: string, id: string, kernel: IKernel, disposeCb: () => void); | ||
constructor(target: string, id: string, kernel: Kernel.IKernel, disposeCb: () => void); | ||
/** | ||
@@ -15,0 +15,0 @@ * The unique id for the comm channel. |
@@ -1,5 +0,4 @@ | ||
import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
import { IDisposable } from 'phosphor/lib/core/disposable'; | ||
import { ISignal } from 'phosphor/lib/core/signaling'; | ||
import { IKernel, Kernel } from './kernel'; | ||
import { Kernel } from './kernel'; | ||
import { KernelMessage } from './messages'; | ||
@@ -10,3 +9,3 @@ import { IAjaxSettings } from '../utils'; | ||
*/ | ||
export declare class DefaultKernel implements IKernel { | ||
export declare class DefaultKernel implements Kernel.IKernel { | ||
/** | ||
@@ -19,11 +18,11 @@ * Construct a kernel object. | ||
*/ | ||
statusChanged: ISignal<IKernel, Kernel.Status>; | ||
statusChanged: ISignal<Kernel.IKernel, Kernel.Status>; | ||
/** | ||
* A signal emitted for iopub kernel messages. | ||
*/ | ||
iopubMessage: ISignal<IKernel, KernelMessage.IIOPubMessage>; | ||
iopubMessage: ISignal<Kernel.IKernel, KernelMessage.IIOPubMessage>; | ||
/** | ||
* A signal emitted for unhandled kernel message. | ||
*/ | ||
unhandledMessage: ISignal<IKernel, KernelMessage.IMessage>; | ||
unhandledMessage: ISignal<Kernel.IKernel, KernelMessage.IMessage>; | ||
/** | ||
@@ -83,3 +82,3 @@ * The id of the server-side kernel. | ||
*/ | ||
clone(): IKernel; | ||
clone(): Kernel.IKernel; | ||
/** | ||
@@ -387,3 +386,3 @@ * Dispose of the resources held by the kernel. | ||
*/ | ||
function listRunning(options?: Kernel.IOptions): Promise<IIterator<Kernel.IModel>>; | ||
function listRunning(options?: Kernel.IOptions): Promise<Kernel.IModel[]>; | ||
/** | ||
@@ -401,3 +400,3 @@ * Start a new kernel. | ||
*/ | ||
function startNew(options?: Kernel.IOptions): Promise<IKernel>; | ||
function startNew(options?: Kernel.IOptions): Promise<Kernel.IKernel>; | ||
/** | ||
@@ -418,3 +417,3 @@ * Connect to a running kernel. | ||
*/ | ||
function connectTo(id: string, options?: Kernel.IOptions): Promise<IKernel>; | ||
function connectTo(id: string, options?: Kernel.IOptions): Promise<Kernel.IKernel>; | ||
/** | ||
@@ -421,0 +420,0 @@ * Shut down a kernel by id. |
@@ -5,2 +5,4 @@ // Copyright (c) Jupyter Development Team. | ||
var iteration_1 = require('phosphor/lib/algorithm/iteration'); | ||
var searching_1 = require('phosphor/lib/algorithm/searching'); | ||
var vector_1 = require('phosphor/lib/collections/vector'); | ||
var disposable_1 = require('phosphor/lib/core/disposable'); | ||
@@ -61,3 +63,3 @@ var signaling_1 = require('phosphor/lib/core/signaling'); | ||
this._createSocket(); | ||
Private.runningKernels[this._clientId] = this; | ||
Private.runningKernels.pushBack(this); | ||
} | ||
@@ -214,3 +216,3 @@ Object.defineProperty(DefaultKernel.prototype, "id", { | ||
this._targetRegistry = null; | ||
delete Private.runningKernels[this._clientId]; | ||
Private.runningKernels.remove(this); | ||
}; | ||
@@ -960,3 +962,3 @@ /** | ||
*/ | ||
Private.runningKernels = Object.create(null); | ||
Private.runningKernels = new vector_1.Vector(); | ||
/** | ||
@@ -966,9 +968,7 @@ * Find a kernel by id. | ||
function findById(id, options) { | ||
var kernels = Private.runningKernels; | ||
for (var clientId in kernels) { | ||
var kernel = kernels[clientId]; | ||
if (kernel.id === id) { | ||
var result = { id: kernel.id, name: kernel.name }; | ||
return Promise.resolve(result); | ||
} | ||
var kernel = searching_1.find(Private.runningKernels, function (value) { | ||
return (value.id === id); | ||
}); | ||
if (kernel) { | ||
return Promise.resolve(kernel.model); | ||
} | ||
@@ -1039,3 +1039,3 @@ return getKernelModel(id, options).catch(function () { | ||
} | ||
return iteration_1.iter(success.data); | ||
return success.data; | ||
}, onKernelError); | ||
@@ -1083,7 +1083,7 @@ } | ||
function connectTo(id, options) { | ||
for (var clientId in Private.runningKernels) { | ||
var kernel = Private.runningKernels[clientId]; | ||
if (kernel.id === id) { | ||
return Promise.resolve(kernel.clone()); | ||
} | ||
var kernel = searching_1.find(Private.runningKernels, function (value) { | ||
return value.id === id; | ||
}); | ||
if (kernel) { | ||
return Promise.resolve(kernel.clone()); | ||
} | ||
@@ -1166,8 +1166,7 @@ return getKernelModel(id, options).then(function (model) { | ||
} | ||
for (var uuid in Private.runningKernels) { | ||
var kernel = Private.runningKernels[uuid]; | ||
iteration_1.each(iteration_1.toArray(Private.runningKernels), function (kernel) { | ||
if (kernel.id === id) { | ||
kernel.dispose(); | ||
} | ||
} | ||
}); | ||
}, onKernelError); | ||
@@ -1174,0 +1173,0 @@ } |
@@ -1,4 +0,2 @@ | ||
import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
import { JSONObject, JSONValue } from 'phosphor/lib/algorithm/json'; | ||
import { ISequence } from 'phosphor/lib/algorithm/sequence'; | ||
import { IDisposable } from 'phosphor/lib/core/disposable'; | ||
@@ -9,271 +7,271 @@ import { ISignal } from 'phosphor/lib/core/signaling'; | ||
/** | ||
* Interface of a Kernel object. | ||
* | ||
* #### Notes | ||
* The Kernel object is tied to the lifetime of the Kernel id, which is | ||
* a unique id for the Kernel session on the server. The Kernel object | ||
* manages a websocket connection internally, and will auto-restart if the | ||
* websocket temporarily loses connection. Restarting creates a new Kernel | ||
* process on the server, but preserves the Kernel id. | ||
* A namespace for kernel types, interfaces, and type checker functions. | ||
*/ | ||
export interface IKernel extends IDisposable { | ||
export declare namespace Kernel { | ||
/** | ||
* A signal emitted when the kernel status changes. | ||
*/ | ||
statusChanged: ISignal<IKernel, Kernel.Status>; | ||
/** | ||
* A signal emitted for iopub kernel messages. | ||
*/ | ||
iopubMessage: ISignal<IKernel, KernelMessage.IIOPubMessage>; | ||
/** | ||
* A signal emitted for unhandled kernel message. | ||
*/ | ||
unhandledMessage: ISignal<IKernel, KernelMessage.IMessage>; | ||
/** | ||
* The id of the server-side kernel. | ||
*/ | ||
readonly id: string; | ||
/** | ||
* The name of the server-side kernel. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The model associated with the kernel. | ||
*/ | ||
readonly model: Kernel.IModel; | ||
/** | ||
* The client username. | ||
*/ | ||
readonly username: string; | ||
/** | ||
* The client unique id. | ||
*/ | ||
readonly clientId: string; | ||
/** | ||
* The current status of the kernel. | ||
*/ | ||
readonly status: Kernel.Status; | ||
/** | ||
* The cached info for the kernel. | ||
* Interface of a Kernel object. | ||
* | ||
* #### Notes | ||
* If `null`, call [[kernelInfo]] to get the value, | ||
* which will populate this value. | ||
* The Kernel object is tied to the lifetime of the Kernel id, which is | ||
* a unique id for the Kernel session on the server. The Kernel object | ||
* manages a websocket connection internally, and will auto-restart if the | ||
* websocket temporarily loses connection. Restarting creates a new Kernel | ||
* process on the server, but preserves the Kernel id. | ||
*/ | ||
readonly info: KernelMessage.IInfoReply; | ||
interface IKernel extends IDisposable { | ||
/** | ||
* A signal emitted when the kernel status changes. | ||
*/ | ||
statusChanged: ISignal<IKernel, Kernel.Status>; | ||
/** | ||
* A signal emitted for iopub kernel messages. | ||
*/ | ||
iopubMessage: ISignal<IKernel, KernelMessage.IIOPubMessage>; | ||
/** | ||
* A signal emitted for unhandled kernel message. | ||
*/ | ||
unhandledMessage: ISignal<IKernel, KernelMessage.IMessage>; | ||
/** | ||
* The id of the server-side kernel. | ||
*/ | ||
readonly id: string; | ||
/** | ||
* The name of the server-side kernel. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The model associated with the kernel. | ||
*/ | ||
readonly model: Kernel.IModel; | ||
/** | ||
* The client username. | ||
*/ | ||
readonly username: string; | ||
/** | ||
* The client unique id. | ||
*/ | ||
readonly clientId: string; | ||
/** | ||
* The current status of the kernel. | ||
*/ | ||
readonly status: Kernel.Status; | ||
/** | ||
* The cached info for the kernel. | ||
* | ||
* #### Notes | ||
* If `null`, call [[kernelInfo]] to get the value, | ||
* which will populate this value. | ||
*/ | ||
readonly info: KernelMessage.IInfoReply; | ||
/** | ||
* The cached spec for the kernel. | ||
* | ||
* #### Notes | ||
* If `null`, call [[getKernelSpecs]] to get the value, | ||
* which will populate this value. | ||
*/ | ||
readonly spec: Kernel.ISpec; | ||
/** | ||
* Send a shell message to the kernel. | ||
* | ||
* #### Notes | ||
* Send a message to the kernel's shell channel, yielding a future object | ||
* for accepting replies. | ||
* | ||
* If `expectReply` is given and `true`, the future is disposed when both a | ||
* shell reply and an idle status message are received. If `expectReply` | ||
* is not given or is `false`, the future is disposed when an idle status | ||
* message is received. | ||
* | ||
* If `disposeOnDone` is given and `false`, the future will not be disposed | ||
* of when the future is done, instead relying on the caller to dispose of it. | ||
* This allows for the handling of out-of-order output from ill-behaved kernels. | ||
* | ||
* All replies are validated as valid kernel messages. | ||
* | ||
* If the kernel status is `'dead'`, this will throw an error. | ||
*/ | ||
sendShellMessage(msg: KernelMessage.IShellMessage, expectReply?: boolean, disposeOnDone?: boolean): Kernel.IFuture; | ||
/** | ||
* Interrupt a kernel. | ||
* | ||
* #### Notes | ||
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels). | ||
* | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
* | ||
* It is assumed that the API call does not mutate the kernel id or name. | ||
* | ||
* The promise will be rejected if the kernel status is `'dead'` or if the | ||
* request fails or the response is invalid. | ||
*/ | ||
interrupt(): Promise<void>; | ||
/** | ||
* Restart a kernel. | ||
* | ||
* #### Notes | ||
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model. | ||
* | ||
* Any existing Future or Comm objects are cleared. | ||
* | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
* | ||
* It is assumed that the API call does not mutate the kernel id or name. | ||
* | ||
* The promise will be rejected if the kernel status is `'dead'` or if the | ||
* request fails or the response is invalid. | ||
*/ | ||
restart(): Promise<void>; | ||
/** | ||
* Reconnect to a disconnected kernel. This is not actually a | ||
* standard HTTP request, but useful function nonetheless for | ||
* reconnecting to the kernel if the connection is somehow lost. | ||
*/ | ||
reconnect(): Promise<void>; | ||
/** | ||
* Shutdown a kernel. | ||
* | ||
* #### Notes | ||
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels). | ||
* | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
* | ||
* On a valid response, closes the websocket and disposes of the kernel | ||
* object, and fulfills the promise. | ||
* | ||
* The promise will be rejected if the kernel status is `'dead'` or if the | ||
* request fails or the response is invalid. | ||
*/ | ||
shutdown(): Promise<void>; | ||
/** | ||
* Send a `kernel_info_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info). | ||
* | ||
* Fulfills with the `kernel_info_response` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
kernelInfo(): Promise<KernelMessage.IInfoReplyMsg>; | ||
/** | ||
* Send a `complete_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion). | ||
* | ||
* Fulfills with the `complete_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
complete(content: KernelMessage.ICompleteRequest): Promise<KernelMessage.ICompleteReplyMsg>; | ||
/** | ||
* Send an `inspect_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection). | ||
* | ||
* Fulfills with the `inspect_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
inspect(content: KernelMessage.IInspectRequest): Promise<KernelMessage.IInspectReplyMsg>; | ||
/** | ||
* Send a `history_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history). | ||
* | ||
* Fulfills with the `history_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
history(content: KernelMessage.IHistoryRequest): Promise<KernelMessage.IHistoryReplyMsg>; | ||
/** | ||
* Send an `execute_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute). | ||
* | ||
* Future `onReply` is called with the `execute_reply` content when the | ||
* shell reply is received and validated. | ||
* | ||
* **See also:** [[IExecuteReply]] | ||
*/ | ||
execute(content: KernelMessage.IExecuteRequest, disposeOnDone?: boolean): Kernel.IFuture; | ||
/** | ||
* Send an `is_complete_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness). | ||
* | ||
* Fulfills with the `is_complete_response` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
isComplete(content: KernelMessage.IIsCompleteRequest): Promise<KernelMessage.IIsCompleteReplyMsg>; | ||
/** | ||
* Send a `comm_info_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm_info). | ||
* | ||
* Fulfills with the `comm_info_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
commInfo(content: KernelMessage.ICommInfoRequest): Promise<KernelMessage.ICommInfoReplyMsg>; | ||
/** | ||
* Send an `input_reply` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets). | ||
*/ | ||
sendInputReply(content: KernelMessage.IInputReply): void; | ||
/** | ||
* Connect to a comm, or create a new one. | ||
* | ||
* #### Notes | ||
* If a client-side comm already exists, it is returned. | ||
*/ | ||
connectToComm(targetName: string, commId?: string): Kernel.IComm; | ||
/** | ||
* Register a comm target handler. | ||
* | ||
* @param targetName - The name of the comm target. | ||
* | ||
* @param callback - The callback invoked for a comm open message. | ||
* | ||
* @returns A disposable used to unregister the comm target. | ||
* | ||
* #### Notes | ||
* Only one comm target can be registered at a time, an existing | ||
* callback will be overidden. A registered comm target handler will take | ||
* precedence over a comm which specifies a `target_module`. | ||
*/ | ||
registerCommTarget(targetName: string, callback: (comm: Kernel.IComm, msg: KernelMessage.ICommOpenMsg) => void): IDisposable; | ||
/** | ||
* Register an IOPub message hook. | ||
* | ||
* @param msg_id - The parent_header message id in messages the hook should intercept. | ||
* | ||
* @param hook - The callback invoked for the message. | ||
* | ||
* @returns A disposable used to unregister the message hook. | ||
* | ||
* #### Notes | ||
* The IOPub hook system allows you to preempt the handlers for IOPub messages with a | ||
* given parent_header message id. The most recently registered hook is run first. | ||
* If the hook returns false, any later hooks and the future's onIOPub handler will not run. | ||
* If a hook throws an error, the error is logged to the console and the next hook is run. | ||
* If a hook is registered during the hook processing, it won't run until the next message. | ||
* If a hook is disposed during the hook processing, it will be deactivated immediately. | ||
* | ||
* See also [[IFuture.registerMessageHook]]. | ||
*/ | ||
registerMessageHook(msgId: string, hook: (msg: KernelMessage.IIOPubMessage) => boolean): IDisposable; | ||
/** | ||
* Get the kernel spec associated with the kernel. | ||
*/ | ||
getSpec(): Promise<Kernel.ISpec>; | ||
/** | ||
* Optional default settings for ajax requests, if applicable. | ||
*/ | ||
ajaxSettings?: IAjaxSettings; | ||
} | ||
/** | ||
* The cached spec for the kernel. | ||
* | ||
* #### Notes | ||
* If `null`, call [[getKernelSpecs]] to get the value, | ||
* which will populate this value. | ||
*/ | ||
readonly spec: Kernel.ISpec; | ||
/** | ||
* Send a shell message to the kernel. | ||
* | ||
* #### Notes | ||
* Send a message to the kernel's shell channel, yielding a future object | ||
* for accepting replies. | ||
* | ||
* If `expectReply` is given and `true`, the future is disposed when both a | ||
* shell reply and an idle status message are received. If `expectReply` | ||
* is not given or is `false`, the future is disposed when an idle status | ||
* message is received. | ||
* | ||
* If `disposeOnDone` is given and `false`, the Future will not be disposed | ||
* of when the future is done, instead relying on the caller to dispose of it. | ||
* This allows for the handling of out-of-order output from ill-behaved kernels. | ||
* | ||
* All replies are validated as valid kernel messages. | ||
* | ||
* If the kernel status is `Dead`, this will throw an error. | ||
*/ | ||
sendShellMessage(msg: KernelMessage.IShellMessage, expectReply?: boolean, disposeOnDone?: boolean): Kernel.IFuture; | ||
/** | ||
* Interrupt a kernel. | ||
* | ||
* #### Notes | ||
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels). | ||
* | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
* | ||
* It is assumed that the API call does not mutate the kernel id or name. | ||
* | ||
* The promise will be rejected if the kernel status is `Dead` or if the | ||
* request fails or the response is invalid. | ||
*/ | ||
interrupt(): Promise<void>; | ||
/** | ||
* Restart a kernel. | ||
* | ||
* #### Notes | ||
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model. | ||
* | ||
* Any existing Future or Comm objects are cleared. | ||
* | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
* | ||
* It is assumed that the API call does not mutate the kernel id or name. | ||
* | ||
* The promise will be rejected if the kernel status is `Dead` or if the | ||
* request fails or the response is invalid. | ||
*/ | ||
restart(): Promise<void>; | ||
/** | ||
* Reconnect to a disconnected kernel. This is not actually a | ||
* standard HTTP request, but useful function nonetheless for | ||
* reconnecting to the kernel if the connection is somehow lost. | ||
*/ | ||
reconnect(): Promise<void>; | ||
/** | ||
* Shutdown a kernel. | ||
* | ||
* #### Notes | ||
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels). | ||
* | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
* | ||
* On a valid response, closes the websocket and disposes of the kernel | ||
* object, and fulfills the promise. | ||
* | ||
* The promise will be rejected if the kernel status is `Dead` or if the | ||
* request fails or the response is invalid. | ||
*/ | ||
shutdown(): Promise<void>; | ||
/** | ||
* Send a `kernel_info_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info). | ||
* | ||
* Fulfills with the `kernel_info_response` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
kernelInfo(): Promise<KernelMessage.IInfoReplyMsg>; | ||
/** | ||
* Send a `complete_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion). | ||
* | ||
* Fulfills with the `complete_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
complete(content: KernelMessage.ICompleteRequest): Promise<KernelMessage.ICompleteReplyMsg>; | ||
/** | ||
* Send an `inspect_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection). | ||
* | ||
* Fulfills with the `inspect_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
inspect(content: KernelMessage.IInspectRequest): Promise<KernelMessage.IInspectReplyMsg>; | ||
/** | ||
* Send a `history_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history). | ||
* | ||
* Fulfills with the `history_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
history(content: KernelMessage.IHistoryRequest): Promise<KernelMessage.IHistoryReplyMsg>; | ||
/** | ||
* Send an `execute_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute). | ||
* | ||
* Future `onReply` is called with the `execute_reply` content when the | ||
* shell reply is received and validated. | ||
* | ||
* **See also:** [[IExecuteReply]] | ||
*/ | ||
execute(content: KernelMessage.IExecuteRequest, disposeOnDone?: boolean): Kernel.IFuture; | ||
/** | ||
* Send an `is_complete_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness). | ||
* | ||
* Fulfills with the `is_complete_response` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
isComplete(content: KernelMessage.IIsCompleteRequest): Promise<KernelMessage.IIsCompleteReplyMsg>; | ||
/** | ||
* Send a `comm_info_request` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm_info). | ||
* | ||
* Fulfills with the `comm_info_reply` content when the shell reply is | ||
* received and validated. | ||
*/ | ||
commInfo(content: KernelMessage.ICommInfoRequest): Promise<KernelMessage.ICommInfoReplyMsg>; | ||
/** | ||
* Send an `input_reply` message. | ||
* | ||
* #### Notes | ||
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets). | ||
*/ | ||
sendInputReply(content: KernelMessage.IInputReply): void; | ||
/** | ||
* Connect to a comm, or create a new one. | ||
* | ||
* #### Notes | ||
* If a client-side comm already exists, it is returned. | ||
*/ | ||
connectToComm(targetName: string, commId?: string): Kernel.IComm; | ||
/** | ||
* Register a comm target handler. | ||
* | ||
* @param targetName - The name of the comm target. | ||
* | ||
* @param callback - The callback invoked for a comm open message. | ||
* | ||
* @returns A disposable used to unregister the comm target. | ||
* | ||
* #### Notes | ||
* Only one comm target can be registered at a time, an existing | ||
* callback will be overidden. A registered comm target handler will take | ||
* precedence over a comm which specifies a `target_module`. | ||
*/ | ||
registerCommTarget(targetName: string, callback: (comm: Kernel.IComm, msg: KernelMessage.ICommOpenMsg) => void): IDisposable; | ||
/** | ||
* Register an IOPub message hook. | ||
* | ||
* @param msg_id - The parent_header message id in messages the hook should intercept. | ||
* | ||
* @param hook - The callback invoked for the message. | ||
* | ||
* @returns A disposable used to unregister the message hook. | ||
* | ||
* #### Notes | ||
* The IOPub hook system allows you to preempt the handlers for IOPub messages with a | ||
* given parent_header message id. The most recently registered hook is run first. | ||
* If the hook returns false, any later hooks and the future's onIOPub handler will not run. | ||
* If a hook throws an error, the error is logged to the console and the next hook is run. | ||
* If a hook is registered during the hook processing, it won't run until the next message. | ||
* If a hook is disposed during the hook processing, it will be deactivated immediately. | ||
* | ||
* See also [[IFuture.registerMessageHook]]. | ||
*/ | ||
registerMessageHook(msgId: string, hook: (msg: KernelMessage.IIOPubMessage) => boolean): IDisposable; | ||
/** | ||
* Get the kernel spec associated with the kernel. | ||
*/ | ||
getSpec(): Promise<Kernel.ISpec>; | ||
/** | ||
* Optional default settings for ajax requests, if applicable. | ||
*/ | ||
ajaxSettings?: IAjaxSettings; | ||
} | ||
/** | ||
* A namespace for kernel types, interfaces, and type checker functions. | ||
*/ | ||
export declare namespace Kernel { | ||
/** | ||
* Find a kernel by id. | ||
@@ -306,3 +304,3 @@ * | ||
*/ | ||
function listRunning(options?: Kernel.IOptions): Promise<IIterator<Kernel.IModel>>; | ||
function listRunning(options?: Kernel.IOptions): Promise<Kernel.IModel[]>; | ||
/** | ||
@@ -382,3 +380,3 @@ * Start a new kernel. | ||
*/ | ||
runningChanged: ISignal<IManager, ISequence<IModel>>; | ||
runningChanged: ISignal<IManager, IModel[]>; | ||
/** | ||
@@ -399,3 +397,3 @@ * Get the available kernel specs. | ||
*/ | ||
listRunning(options?: IOptions): Promise<IIterator<IModel>>; | ||
listRunning(options?: IOptions): Promise<IModel[]>; | ||
/** | ||
@@ -402,0 +400,0 @@ * Start a new kernel. |
@@ -1,4 +0,3 @@ | ||
import { ISequence } from 'phosphor/lib/algorithm/sequence'; | ||
import { ISignal } from 'phosphor/lib/core/signaling'; | ||
import { IKernel, Kernel } from './kernel'; | ||
import { Kernel } from './kernel'; | ||
/** | ||
@@ -21,3 +20,3 @@ * An implementation of a kernel manager. | ||
*/ | ||
runningChanged: ISignal<this, ISequence<Kernel.IModel>>; | ||
runningChanged: ISignal<this, Kernel.IModel[]>; | ||
/** | ||
@@ -42,3 +41,3 @@ * Test whether the terminal manager is disposed. | ||
*/ | ||
listRunning(options?: Kernel.IOptions): Promise<ISequence<Kernel.IModel>>; | ||
listRunning(options?: Kernel.IOptions): Promise<Kernel.IModel[]>; | ||
/** | ||
@@ -53,3 +52,3 @@ * Start a new kernel. See also [[startNewKernel]]. | ||
*/ | ||
startNew(options?: Kernel.IOptions): Promise<IKernel>; | ||
startNew(options?: Kernel.IOptions): Promise<Kernel.IKernel>; | ||
/** | ||
@@ -66,3 +65,3 @@ * Find a kernel by id. | ||
*/ | ||
connectTo(id: string, options?: Kernel.IOptions): Promise<IKernel>; | ||
connectTo(id: string, options?: Kernel.IOptions): Promise<Kernel.IKernel>; | ||
/** | ||
@@ -69,0 +68,0 @@ * Shut down a kernel by id. |
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
"use strict"; | ||
var iteration_1 = require('phosphor/lib/algorithm/iteration'); | ||
var json_1 = require('phosphor/lib/algorithm/json'); | ||
var vector_1 = require('phosphor/lib/collections/vector'); | ||
var signaling_1 = require('phosphor/lib/core/signaling'); | ||
@@ -70,9 +68,8 @@ var utils = require('../utils'); | ||
var _this = this; | ||
return kernel_1.Kernel.listRunning(this._getOptions(options)).then(function (it) { | ||
var running = iteration_1.toArray(it); | ||
return kernel_1.Kernel.listRunning(this._getOptions(options)).then(function (running) { | ||
if (!json_1.deepEqual(running, _this._running)) { | ||
_this._running = running; | ||
_this.runningChanged.emit(new vector_1.Vector(_this._running)); | ||
_this._running = running.slice(); | ||
_this.runningChanged.emit(running); | ||
} | ||
return iteration_1.iter(running); | ||
return running; | ||
}); | ||
@@ -79,0 +76,0 @@ }; |
@@ -9,35 +9,35 @@ import { IDisposable } from 'phosphor/lib/core/disposable'; | ||
/** | ||
* A service manager interface. | ||
* The namespace for `ServiceManager` statics. | ||
*/ | ||
export interface IServiceManager extends IDisposable { | ||
export declare namespace ServiceManager { | ||
/** | ||
* A signal emitted when the specs change on the service manager. | ||
* A service manager interface. | ||
*/ | ||
specsChanged: ISignal<IServiceManager, Kernel.ISpecModels>; | ||
interface IManager extends IDisposable { | ||
/** | ||
* A signal emitted when the specs change on the service manager. | ||
*/ | ||
specsChanged: ISignal<IManager, Kernel.ISpecModels>; | ||
/** | ||
* The kernel specs for the manager. | ||
*/ | ||
readonly kernelspecs: Kernel.ISpecModels; | ||
/** | ||
* The kernel manager for the manager. | ||
*/ | ||
readonly kernels: Kernel.IManager; | ||
/** | ||
* The session manager for the manager. | ||
*/ | ||
readonly sessions: Session.IManager; | ||
/** | ||
* The contents manager for the manager. | ||
*/ | ||
readonly contents: Contents.IManager; | ||
/** | ||
* The terminals manager for the manager. | ||
*/ | ||
readonly terminals: TerminalSession.IManager; | ||
} | ||
/** | ||
* The kernel specs for the manager. | ||
*/ | ||
readonly kernelspecs: Kernel.ISpecModels; | ||
/** | ||
* The kernel manager for the manager. | ||
*/ | ||
readonly kernels: Kernel.IManager; | ||
/** | ||
* The session manager for the manager. | ||
*/ | ||
readonly sessions: Session.IManager; | ||
/** | ||
* The contents manager for the manager. | ||
*/ | ||
readonly contents: Contents.IManager; | ||
/** | ||
* The terminals manager for the manager. | ||
*/ | ||
readonly terminals: TerminalSession.IManager; | ||
} | ||
/** | ||
* The namespace for `ServiceManager` statics. | ||
*/ | ||
export declare namespace ServiceManager { | ||
/** | ||
* Create a new service manager. | ||
@@ -49,3 +49,3 @@ * | ||
*/ | ||
function create(options?: IOptions): Promise<IServiceManager>; | ||
function create(options?: IOptions): Promise<IManager>; | ||
/** | ||
@@ -52,0 +52,0 @@ * The options used to create a service manager. |
@@ -1,6 +0,5 @@ | ||
import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
import { ISignal } from 'phosphor/lib/core/signaling'; | ||
import { IKernel, Kernel, KernelMessage } from '../kernel'; | ||
import { Kernel, KernelMessage } from '../kernel'; | ||
import { IAjaxSettings } from '../utils'; | ||
import { ISession, Session } from './session'; | ||
import { Session } from './session'; | ||
/** | ||
@@ -11,31 +10,31 @@ * Session object for accessing the session REST api. The session | ||
*/ | ||
export declare class DefaultSession implements ISession { | ||
export declare class DefaultSession implements Session.ISession { | ||
/** | ||
* Construct a new session. | ||
*/ | ||
constructor(options: Session.IOptions, id: string, kernel: IKernel); | ||
constructor(options: Session.IOptions, id: string, kernel: Kernel.IKernel); | ||
/** | ||
* A signal emitted when the session dies. | ||
*/ | ||
sessionDied: ISignal<ISession, void>; | ||
sessionDied: ISignal<Session.ISession, void>; | ||
/** | ||
* A signal emitted when the kernel changes. | ||
*/ | ||
kernelChanged: ISignal<ISession, IKernel>; | ||
kernelChanged: ISignal<Session.ISession, Kernel.IKernel>; | ||
/** | ||
* A signal emitted when the kernel status changes. | ||
*/ | ||
statusChanged: ISignal<ISession, Kernel.Status>; | ||
statusChanged: ISignal<Session.ISession, Kernel.Status>; | ||
/** | ||
* A signal emitted for a kernel messages. | ||
*/ | ||
iopubMessage: ISignal<ISession, KernelMessage.IMessage>; | ||
iopubMessage: ISignal<Session.ISession, KernelMessage.IMessage>; | ||
/** | ||
* A signal emitted for an unhandled kernel message. | ||
*/ | ||
unhandledMessage: ISignal<ISession, KernelMessage.IMessage>; | ||
unhandledMessage: ISignal<Session.ISession, KernelMessage.IMessage>; | ||
/** | ||
* A signal emitted when the session path changes. | ||
*/ | ||
pathChanged: ISignal<ISession, string>; | ||
pathChanged: ISignal<Session.ISession, string>; | ||
/** | ||
@@ -53,3 +52,3 @@ * Get the session id. | ||
*/ | ||
readonly kernel: IKernel; | ||
readonly kernel: Kernel.IKernel; | ||
/** | ||
@@ -84,3 +83,3 @@ * Get the session path. | ||
*/ | ||
clone(): Promise<ISession>; | ||
clone(): Promise<Session.ISession>; | ||
/** | ||
@@ -113,3 +112,3 @@ * Update the session based on a session model from the server. | ||
*/ | ||
changeKernel(options: Kernel.IModel): Promise<IKernel>; | ||
changeKernel(options: Kernel.IModel): Promise<Kernel.IKernel>; | ||
/** | ||
@@ -128,15 +127,15 @@ * Kill the kernel and shutdown the session. | ||
*/ | ||
protected setupKernel(kernel: IKernel): void; | ||
protected setupKernel(kernel: Kernel.IKernel): void; | ||
/** | ||
* Handle to changes in the Kernel status. | ||
*/ | ||
protected onKernelStatus(sender: IKernel, state: Kernel.Status): void; | ||
protected onKernelStatus(sender: Kernel.IKernel, state: Kernel.Status): void; | ||
/** | ||
* Handle iopub kernel messages. | ||
*/ | ||
protected onIOPubMessage(sender: IKernel, msg: KernelMessage.IIOPubMessage): void; | ||
protected onIOPubMessage(sender: Kernel.IKernel, msg: KernelMessage.IIOPubMessage): void; | ||
/** | ||
* Handle unhandled kernel messages. | ||
*/ | ||
protected onUnhandledMessage(sender: IKernel, msg: KernelMessage.IMessage): void; | ||
protected onUnhandledMessage(sender: Kernel.IKernel, msg: KernelMessage.IMessage): void; | ||
/** | ||
@@ -166,7 +165,7 @@ * Get the options used to create a new kernel. | ||
*/ | ||
function listRunning(options?: Session.IOptions): Promise<IIterator<Session.IModel>>; | ||
function listRunning(options?: Session.IOptions): Promise<Session.IModel[]>; | ||
/** | ||
* Start a new session. | ||
*/ | ||
function startNew(options: Session.IOptions): Promise<ISession>; | ||
function startNew(options: Session.IOptions): Promise<Session.ISession>; | ||
/** | ||
@@ -183,3 +182,3 @@ * Find a session by id. | ||
*/ | ||
function connectTo(id: string, options?: Session.IOptions): Promise<ISession>; | ||
function connectTo(id: string, options?: Session.IOptions): Promise<Session.ISession>; | ||
/** | ||
@@ -186,0 +185,0 @@ * Shut down a session by id. |
@@ -6,2 +6,3 @@ // Copyright (c) Jupyter Development Team. | ||
var searching_1 = require('phosphor/lib/algorithm/searching'); | ||
var vector_1 = require('phosphor/lib/collections/vector'); | ||
var signaling_1 = require('phosphor/lib/core/signaling'); | ||
@@ -38,3 +39,3 @@ var kernel_1 = require('../kernel'); | ||
this._uuid = utils.uuid(); | ||
Private.runningSessions[this._uuid] = this; | ||
Private.runningSessions.pushBack(this); | ||
this.setupKernel(kernel); | ||
@@ -180,3 +181,3 @@ this._options = utils.copy(options); | ||
this._options = null; | ||
delete Private.runningSessions[this._uuid]; | ||
Private.runningSessions.remove(this); | ||
this._kernel = null; | ||
@@ -374,3 +375,3 @@ signaling_1.clearSignalData(this); | ||
*/ | ||
Private.runningSessions = Object.create(null); | ||
Private.runningSessions = new vector_1.Vector(); | ||
/** | ||
@@ -391,8 +392,9 @@ * List the running sessions. | ||
} | ||
var data = success.data; | ||
if (!Array.isArray(success.data)) { | ||
return utils.makeAjaxError(success, 'Invalid Session list'); | ||
} | ||
for (var i = 0; i < success.data.length; i++) { | ||
for (var i = 0; i < data.length; i++) { | ||
try { | ||
validate.validateModel(success.data[i]); | ||
validate.validateModel(data[i]); | ||
} | ||
@@ -403,3 +405,3 @@ catch (err) { | ||
} | ||
return updateRunningSessions(success.data); | ||
return updateRunningSessions(data); | ||
}, Private.onSessionError); | ||
@@ -425,13 +427,5 @@ } | ||
if (options === void 0) { options = {}; } | ||
var sessions = Private.runningSessions; | ||
for (var clientId in sessions) { | ||
var session = sessions[clientId]; | ||
if (session.id === id) { | ||
var model = { | ||
id: id, | ||
notebook: { path: session.path }, | ||
kernel: { name: session.kernel.name, id: session.kernel.id } | ||
}; | ||
return Promise.resolve(model); | ||
} | ||
var session = searching_1.find(Private.runningSessions, function (value) { return value.id === id; }); | ||
if (session) { | ||
return Promise.resolve(session.model); | ||
} | ||
@@ -449,13 +443,5 @@ return getSessionModel(id, options).catch(function () { | ||
if (options === void 0) { options = {}; } | ||
var sessions = Private.runningSessions; | ||
for (var clientId in sessions) { | ||
var session = sessions[clientId]; | ||
if (session.path === path) { | ||
var model = { | ||
id: session.id, | ||
notebook: { path: session.path }, | ||
kernel: { name: session.kernel.name, id: session.kernel.id } | ||
}; | ||
return Promise.resolve(model); | ||
} | ||
var session = searching_1.find(Private.runningSessions, function (value) { return value.path === path; }); | ||
if (session) { | ||
return Promise.resolve(session.model); | ||
} | ||
@@ -479,7 +465,5 @@ return listRunning(options).then(function (models) { | ||
if (options === void 0) { options = {}; } | ||
for (var clientId in Private.runningSessions) { | ||
var session = Private.runningSessions[clientId]; | ||
if (session.id === id) { | ||
return session.clone(); | ||
} | ||
var session = searching_1.find(Private.runningSessions, function (value) { return value.id === id; }); | ||
if (session) { | ||
return Promise.resolve(session.clone()); | ||
} | ||
@@ -597,13 +581,9 @@ return getSessionModel(id, options).then(function (model) { | ||
var promises = []; | ||
for (var uuid in Private.runningSessions) { | ||
var session = Private.runningSessions[uuid]; | ||
var updated = false; | ||
for (var _i = 0, sessions_1 = sessions; _i < sessions_1.length; _i++) { | ||
var sId = sessions_1[_i]; | ||
iteration_1.each(Private.runningSessions, function (session) { | ||
var updated = searching_1.find(sessions, function (sId) { | ||
if (session.id === sId.id) { | ||
promises.push(session.update(sId)); | ||
updated = true; | ||
break; | ||
return true; | ||
} | ||
} | ||
}); | ||
// If session is no longer running on disk, emit dead signal. | ||
@@ -613,4 +593,4 @@ if (!updated && session.status !== 'dead') { | ||
} | ||
} | ||
return Promise.all(promises).then(function () { return iteration_1.iter(sessions); }); | ||
}); | ||
return Promise.all(promises).then(function () { return sessions; }); | ||
} | ||
@@ -623,8 +603,7 @@ Private.updateRunningSessions = updateRunningSessions; | ||
var promises = []; | ||
for (var uuid in Private.runningSessions) { | ||
var session = Private.runningSessions[uuid]; | ||
iteration_1.each(Private.runningSessions, function (session) { | ||
if (session.id === model.id) { | ||
promises.push(session.update(model)); | ||
} | ||
} | ||
}); | ||
return Promise.all(promises).then(function () { return model; }); | ||
@@ -646,8 +625,7 @@ } | ||
} | ||
for (var uuid in Private.runningSessions) { | ||
var session = Private.runningSessions[uuid]; | ||
iteration_1.each(iteration_1.toArray(Private.runningSessions), function (session) { | ||
if (session.id === id) { | ||
session.dispose(); | ||
} | ||
} | ||
}); | ||
}, function (err) { | ||
@@ -654,0 +632,0 @@ if (err.xhr.status === 410) { |
@@ -1,6 +0,4 @@ | ||
import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
import { ISequence } from 'phosphor/lib/algorithm/sequence'; | ||
import { ISignal } from 'phosphor/lib/core/signaling'; | ||
import { Kernel } from '../kernel'; | ||
import { ISession, Session } from './session'; | ||
import { Session } from './session'; | ||
/** | ||
@@ -23,3 +21,3 @@ * An implementation of a session manager. | ||
*/ | ||
runningChanged: ISignal<SessionManager, ISequence<Session.IModel>>; | ||
runningChanged: ISignal<SessionManager, Session.IModel[]>; | ||
/** | ||
@@ -44,3 +42,3 @@ * Test whether the terminal manager is disposed. | ||
*/ | ||
listRunning(options?: Session.IOptions): Promise<IIterator<Session.IModel>>; | ||
listRunning(options?: Session.IOptions): Promise<Session.IModel[]>; | ||
/** | ||
@@ -56,3 +54,3 @@ * Start a new session. See also [[startNewSession]]. | ||
*/ | ||
startNew(options: Session.IOptions): Promise<ISession>; | ||
startNew(options: Session.IOptions): Promise<Session.ISession>; | ||
/** | ||
@@ -66,3 +64,3 @@ * Find a session by id. | ||
findByPath(path: string, options?: Session.IOptions): Promise<Session.IModel>; | ||
connectTo(id: string, options?: Session.IOptions): Promise<ISession>; | ||
connectTo(id: string, options?: Session.IOptions): Promise<Session.ISession>; | ||
/** | ||
@@ -69,0 +67,0 @@ * Shut down a session by id. |
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
"use strict"; | ||
var iteration_1 = require('phosphor/lib/algorithm/iteration'); | ||
var json_1 = require('phosphor/lib/algorithm/json'); | ||
var vector_1 = require('phosphor/lib/collections/vector'); | ||
var signaling_1 = require('phosphor/lib/core/signaling'); | ||
@@ -70,9 +68,8 @@ var kernel_1 = require('../kernel'); | ||
var _this = this; | ||
return session_1.Session.listRunning(this._getOptions(options)).then(function (it) { | ||
var running = iteration_1.toArray(it); | ||
return session_1.Session.listRunning(this._getOptions(options)).then(function (running) { | ||
if (!json_1.deepEqual(running, _this._running)) { | ||
_this._running = running; | ||
_this.runningChanged.emit(new vector_1.Vector(running)); | ||
_this._running = running.slice(); | ||
_this.runningChanged.emit(running); | ||
} | ||
return iteration_1.iter(running); | ||
return running; | ||
}); | ||
@@ -79,0 +76,0 @@ }; |
@@ -1,102 +0,100 @@ | ||
import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
import { JSONObject } from 'phosphor/lib/algorithm/json'; | ||
import { ISequence } from 'phosphor/lib/algorithm/sequence'; | ||
import { IDisposable } from 'phosphor/lib/core/disposable'; | ||
import { ISignal } from 'phosphor/lib/core/signaling'; | ||
import { IKernel, Kernel, KernelMessage } from '../kernel'; | ||
import { Kernel, KernelMessage } from '../kernel'; | ||
import { IAjaxSettings } from '../utils'; | ||
/** | ||
* Interface of a session object. | ||
* A namespace for session interfaces and factory functions. | ||
*/ | ||
export interface ISession extends IDisposable { | ||
export declare namespace Session { | ||
/** | ||
* A signal emitted when the session is shut down. | ||
* Interface of a session object. | ||
*/ | ||
sessionDied: ISignal<ISession, void>; | ||
interface ISession extends IDisposable { | ||
/** | ||
* A signal emitted when the session is shut down. | ||
*/ | ||
sessionDied: ISignal<ISession, void>; | ||
/** | ||
* A signal emitted when the kernel changes. | ||
*/ | ||
kernelChanged: ISignal<ISession, Kernel.IKernel>; | ||
/** | ||
* A signal emitted when the session status changes. | ||
*/ | ||
statusChanged: ISignal<ISession, Kernel.Status>; | ||
/** | ||
* A signal emitted when the session path changes. | ||
*/ | ||
pathChanged: ISignal<ISession, string>; | ||
/** | ||
* A signal emitted for iopub kernel messages. | ||
*/ | ||
iopubMessage: ISignal<ISession, KernelMessage.IIOPubMessage>; | ||
/** | ||
* A signal emitted for unhandled kernel message. | ||
*/ | ||
unhandledMessage: ISignal<ISession, KernelMessage.IMessage>; | ||
/** | ||
* Unique id of the session. | ||
*/ | ||
readonly id: string; | ||
/** | ||
* The path associated with the session. | ||
*/ | ||
readonly path: string; | ||
/** | ||
* The model associated with the session. | ||
*/ | ||
readonly model: Session.IModel; | ||
/** | ||
* The kernel. | ||
* | ||
* #### Notes | ||
* This is a read-only property, and can be altered by [changeKernel]. | ||
* Use the [statusChanged] and [unhandledMessage] signals on the session | ||
* instead of the ones on the kernel. | ||
*/ | ||
readonly kernel: Kernel.IKernel; | ||
/** | ||
* The current status of the session. | ||
* | ||
* #### Notes | ||
* This is a delegate to the kernel status. | ||
*/ | ||
readonly status: Kernel.Status; | ||
/** | ||
* Optional default settings for ajax requests, if applicable. | ||
*/ | ||
ajaxSettings?: IAjaxSettings; | ||
/** | ||
* Change the session path. | ||
* | ||
* @param path - The new session path. | ||
* | ||
* #### Notes | ||
* This uses the Jupyter REST API, and the response is validated. | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
*/ | ||
rename(path: string): Promise<void>; | ||
/** | ||
* Change the kernel. | ||
* | ||
* @param options - The name or id of the new kernel. | ||
* | ||
* #### Notes | ||
* This shuts down the existing kernel and creates a new kernel, | ||
* keeping the existing session ID and path. | ||
*/ | ||
changeKernel(options: Kernel.IModel): Promise<Kernel.IKernel>; | ||
/** | ||
* Kill the kernel and shutdown the session. | ||
* | ||
* #### Notes | ||
* This uses the Jupyter REST API, and the response is validated. | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
*/ | ||
shutdown(): Promise<void>; | ||
} | ||
/** | ||
* A signal emitted when the kernel changes. | ||
*/ | ||
kernelChanged: ISignal<ISession, IKernel>; | ||
/** | ||
* A signal emitted when the session status changes. | ||
*/ | ||
statusChanged: ISignal<ISession, Kernel.Status>; | ||
/** | ||
* A signal emitted when the session path changes. | ||
*/ | ||
pathChanged: ISignal<ISession, string>; | ||
/** | ||
* A signal emitted for iopub kernel messages. | ||
*/ | ||
iopubMessage: ISignal<ISession, KernelMessage.IIOPubMessage>; | ||
/** | ||
* A signal emitted for unhandled kernel message. | ||
*/ | ||
unhandledMessage: ISignal<ISession, KernelMessage.IMessage>; | ||
/** | ||
* Unique id of the session. | ||
*/ | ||
readonly id: string; | ||
/** | ||
* The path associated with the session. | ||
*/ | ||
readonly path: string; | ||
/** | ||
* The model associated with the session. | ||
*/ | ||
readonly model: Session.IModel; | ||
/** | ||
* The kernel. | ||
* | ||
* #### Notes | ||
* This is a read-only property, and can be altered by [changeKernel]. | ||
* Use the [statusChanged] and [unhandledMessage] signals on the session | ||
* instead of the ones on the kernel. | ||
*/ | ||
readonly kernel: IKernel; | ||
/** | ||
* The current status of the session. | ||
* | ||
* #### Notes | ||
* This is a delegate to the kernel status. | ||
*/ | ||
readonly status: Kernel.Status; | ||
/** | ||
* Optional default settings for ajax requests, if applicable. | ||
*/ | ||
ajaxSettings?: IAjaxSettings; | ||
/** | ||
* Change the session path. | ||
* | ||
* @param path - The new session path. | ||
* | ||
* #### Notes | ||
* This uses the Jupyter REST API, and the response is validated. | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
*/ | ||
rename(path: string): Promise<void>; | ||
/** | ||
* Change the kernel. | ||
* | ||
* @params options - The name or id of the new kernel. | ||
* | ||
* #### Notes | ||
* This shuts down the existing kernel and creates a new kernel, | ||
* keeping the existing session ID and path. | ||
*/ | ||
changeKernel(options: Kernel.IModel): Promise<IKernel>; | ||
/** | ||
* Kill the kernel and shutdown the session. | ||
* | ||
* #### Notes | ||
* This uses the Jupyter REST API, and the response is validated. | ||
* The promise is fulfilled on a valid response and rejected otherwise. | ||
*/ | ||
shutdown(): Promise<void>; | ||
} | ||
/** | ||
* A namespace for session interfaces and factory functions. | ||
*/ | ||
export declare namespace Session { | ||
/** | ||
* List the running sessions. | ||
@@ -111,3 +109,3 @@ * | ||
*/ | ||
function listRunning(options?: Session.IOptions): Promise<IIterator<Session.IModel>>; | ||
function listRunning(options?: Session.IOptions): Promise<Session.IModel[]>; | ||
/** | ||
@@ -227,3 +225,3 @@ * Start a new session. | ||
*/ | ||
runningChanged: ISignal<IManager, ISequence<IModel>>; | ||
runningChanged: ISignal<IManager, IModel[]>; | ||
/** | ||
@@ -237,3 +235,3 @@ * Get the available kernel specs. | ||
getSpecs(options?: IOptions): Promise<Kernel.ISpecModels>; | ||
listRunning(options?: IOptions): Promise<IIterator<IModel>>; | ||
listRunning(options?: IOptions): Promise<IModel[]>; | ||
/** | ||
@@ -240,0 +238,0 @@ * Start a new session. |
@@ -1,4 +0,2 @@ | ||
import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
import { JSONPrimitive, JSONObject } from 'phosphor/lib/algorithm/json'; | ||
import { ISequence } from 'phosphor/lib/algorithm/sequence'; | ||
import { IDisposable } from 'phosphor/lib/core/disposable'; | ||
@@ -8,27 +6,27 @@ import { ISignal } from 'phosphor/lib/core/signaling'; | ||
/** | ||
* An interface for a terminal session. | ||
* The namespace for TerminalSession.ISession statics. | ||
*/ | ||
export interface ITerminalSession extends IDisposable { | ||
export declare namespace TerminalSession { | ||
/** | ||
* A signal emitted when a message is received from the server. | ||
* An interface for a terminal session. | ||
*/ | ||
messageReceived: ISignal<ITerminalSession, TerminalSession.IMessage>; | ||
interface ISession extends IDisposable { | ||
/** | ||
* A signal emitted when a message is received from the server. | ||
*/ | ||
messageReceived: ISignal<ISession, TerminalSession.IMessage>; | ||
/** | ||
* Get the name of the terminal session. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* Send a message to the terminal session. | ||
*/ | ||
send(message: TerminalSession.IMessage): void; | ||
/** | ||
* Shut down the terminal session. | ||
*/ | ||
shutdown(): Promise<void>; | ||
} | ||
/** | ||
* Get the name of the terminal session. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* Send a message to the terminal session. | ||
*/ | ||
send(message: TerminalSession.IMessage): void; | ||
/** | ||
* Shut down the terminal session. | ||
*/ | ||
shutdown(): Promise<void>; | ||
} | ||
/** | ||
* The namespace for ITerminalSession statics. | ||
*/ | ||
export declare namespace TerminalSession { | ||
/** | ||
* Create a terminal session or connect to an existing session. | ||
@@ -40,3 +38,3 @@ * | ||
*/ | ||
function open(options?: TerminalSession.IOptions): Promise<ITerminalSession>; | ||
function open(options?: TerminalSession.IOptions): Promise<TerminalSession.ISession>; | ||
/** | ||
@@ -83,3 +81,3 @@ * The options for intializing a terminal session object. | ||
*/ | ||
readonly content?: ISequence<JSONPrimitive>; | ||
readonly content?: JSONPrimitive[]; | ||
} | ||
@@ -97,3 +95,3 @@ /** | ||
*/ | ||
runningChanged: ISignal<IManager, ISequence<IModel>>; | ||
runningChanged: ISignal<IManager, IModel[]>; | ||
/** | ||
@@ -106,3 +104,3 @@ * Create a new terminal session or connect to an existing session. | ||
*/ | ||
create(options?: TerminalSession.IOptions): Promise<ITerminalSession>; | ||
create(options?: TerminalSession.IOptions): Promise<TerminalSession.ISession>; | ||
/** | ||
@@ -119,3 +117,3 @@ * Shut down a terminal session by name. | ||
*/ | ||
listRunning(): Promise<IIterator<IModel>>; | ||
listRunning(): Promise<IModel[]>; | ||
} | ||
@@ -134,3 +132,3 @@ } | ||
*/ | ||
runningChanged: ISignal<this, ISequence<TerminalSession.IModel>>; | ||
runningChanged: ISignal<this, TerminalSession.IModel[]>; | ||
/** | ||
@@ -147,3 +145,3 @@ * Test whether the terminal manager is disposed. | ||
*/ | ||
create(options?: TerminalSession.IOptions): Promise<ITerminalSession>; | ||
create(options?: TerminalSession.IOptions): Promise<TerminalSession.ISession>; | ||
/** | ||
@@ -156,3 +154,3 @@ * Shut down a terminal session by name. | ||
*/ | ||
listRunning(): Promise<IIterator<TerminalSession.IModel>>; | ||
listRunning(): Promise<TerminalSession.IModel[]>; | ||
private _baseUrl; | ||
@@ -159,0 +157,0 @@ private _wsUrl; |
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
"use strict"; | ||
var iteration_1 = require('phosphor/lib/algorithm/iteration'); | ||
var json_1 = require('phosphor/lib/algorithm/json'); | ||
var vector_1 = require('phosphor/lib/collections/vector'); | ||
var signaling_1 = require('phosphor/lib/core/signaling'); | ||
@@ -14,3 +12,3 @@ var utils = require('../utils'); | ||
/** | ||
* The namespace for ITerminalSession statics. | ||
* The namespace for TerminalSession.ISession statics. | ||
*/ | ||
@@ -116,5 +114,5 @@ var TerminalSession; | ||
_this._running = data; | ||
_this.runningChanged.emit(new vector_1.Vector(data)); | ||
_this.runningChanged.emit(data); | ||
} | ||
return iteration_1.iter(data); | ||
return data; | ||
}); | ||
@@ -195,3 +193,3 @@ }; | ||
var msg = [message.type]; | ||
msg.push.apply(msg, iteration_1.toArray(message.content)); | ||
msg.push.apply(msg, message.content); | ||
this._ws.send(JSON.stringify(msg)); | ||
@@ -255,3 +253,3 @@ }; | ||
type: data[0], | ||
content: new vector_1.Vector(data.slice(1)) | ||
content: data.slice(1) | ||
}); | ||
@@ -258,0 +256,0 @@ }; |
{ | ||
"name": "@jupyterlab/services", | ||
"version": "0.23.0", | ||
"version": "0.24.0", | ||
"description": "Client APIs for the Jupyter services REST APIs", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
625607
18111