@jupyterlab/services
Advanced tools
Comparing version 0.32.0 to 0.33.0
@@ -48,2 +48,6 @@ import { JSONObject, JSONValue } from 'phosphor/lib/algorithm/json'; | ||
/** | ||
* The authentication token for the API. | ||
*/ | ||
token?: string; | ||
/** | ||
* The default ajax settings. | ||
@@ -50,0 +54,0 @@ */ |
@@ -39,3 +39,3 @@ // Copyright (c) Jupyter Development Team. | ||
var baseUrl = options.baseUrl || utils.getBaseUrl(); | ||
this.ajaxSettings = options.ajaxSettings || {}; | ||
this.ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
this._url = utils.urlPathJoin(baseUrl, SERVICE_CONFIG_URL, encodeURIComponent(options.name)); | ||
@@ -42,0 +42,0 @@ } |
@@ -459,2 +459,6 @@ import { JSONObject } from 'phosphor/lib/algorithm/json'; | ||
/** | ||
* The authentication token for the API. | ||
*/ | ||
token?: string; | ||
/** | ||
* The default ajax settings to use for the kernel. | ||
@@ -461,0 +465,0 @@ */ |
@@ -33,4 +33,3 @@ // Copyright (c) Jupyter Development Team. | ||
this._baseUrl = options.baseUrl || utils.getBaseUrl(); | ||
options.ajaxSettings = options.ajaxSettings || {}; | ||
this._ajaxSettings = utils.copy(options.ajaxSettings); | ||
this._ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
} | ||
@@ -37,0 +36,0 @@ Object.defineProperty(ContentsManager.prototype, "isDisposed", { |
@@ -81,2 +81,6 @@ import { IDisposable } from 'phosphor/lib/core/disposable'; | ||
/** | ||
* A promise that is fulfilled when the kernel is ready. | ||
*/ | ||
readonly ready: Promise<void>; | ||
/** | ||
* Get the kernel spec. | ||
@@ -86,8 +90,4 @@ * | ||
*/ | ||
spec(): Promise<Kernel.ISpecModel>; | ||
getSpec(): Promise<Kernel.ISpecModel>; | ||
/** | ||
* A promise that is fulfilled when the kernel is ready. | ||
*/ | ||
ready(): Promise<void>; | ||
/** | ||
* Clone the current kernel with a new clientId. | ||
@@ -339,2 +339,3 @@ */ | ||
private _id; | ||
private _token; | ||
private _name; | ||
@@ -358,2 +359,3 @@ private _baseUrl; | ||
private _connectionPromise; | ||
private _specPromise; | ||
} | ||
@@ -360,0 +362,0 @@ /** |
@@ -32,2 +32,3 @@ // Copyright (c) Jupyter Development Team. | ||
this._id = ''; | ||
this._token = ''; | ||
this._name = ''; | ||
@@ -51,2 +52,3 @@ this._baseUrl = ''; | ||
this._connectionPromise = null; | ||
this._specPromise = null; | ||
this._name = options.name; | ||
@@ -56,3 +58,4 @@ this._id = id; | ||
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl); | ||
this._ajaxSettings = JSON.stringify(options.ajaxSettings || {}); | ||
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings, options.token)); | ||
this._token = options.token || utils.getConfigOption('token'); | ||
this._clientId = options.clientId || utils.uuid(); | ||
@@ -185,2 +188,12 @@ this._username = options.username || ''; | ||
}); | ||
Object.defineProperty(DefaultKernel.prototype, "ready", { | ||
/** | ||
* A promise that is fulfilled when the kernel is ready. | ||
*/ | ||
get: function () { | ||
return this._connectionPromise.promise; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
@@ -191,4 +204,7 @@ * Get the kernel spec. | ||
*/ | ||
DefaultKernel.prototype.spec = function () { | ||
DefaultKernel.prototype.getSpec = function () { | ||
var _this = this; | ||
if (this._specPromise) { | ||
return this._specPromise; | ||
} | ||
var options = { | ||
@@ -198,13 +214,8 @@ baseUrl: this._baseUrl, | ||
}; | ||
return Private.findSpecs(options).then(function (specs) { | ||
this._specPromise = Private.findSpecs(options).then(function (specs) { | ||
return specs.kernelspecs[_this._name]; | ||
}); | ||
return this._specPromise; | ||
}; | ||
/** | ||
* A promise that is fulfilled when the kernel is ready. | ||
*/ | ||
DefaultKernel.prototype.ready = function () { | ||
return this._connectionPromise.promise; | ||
}; | ||
/** | ||
* Clone the current kernel with a new clientId. | ||
@@ -218,2 +229,3 @@ */ | ||
username: this._username, | ||
token: this._token, | ||
ajaxSettings: this.ajaxSettings | ||
@@ -619,4 +631,8 @@ }; | ||
var display = partialUrl.replace(parsed.auth, ''); | ||
console.log('Starting WebSocket:', display); | ||
var url = utils.urlPathJoin(partialUrl, 'channels?session_id=' + encodeURIComponent(this._clientId)); | ||
// if token authentication is in use | ||
if (this._token !== '') { | ||
url = url + ("&token=" + encodeURIComponent(this._token)); | ||
} | ||
console.log("new websocket", url); | ||
this._connectionPromise = new utils.PromiseDelegate(); | ||
@@ -1020,3 +1036,3 @@ this._ws = new WebSocket(url); | ||
var url = utils.urlPathJoin(baseUrl, KERNELSPEC_SERVICE_URL); | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'GET'; | ||
@@ -1051,3 +1067,3 @@ ajaxSettings.dataType = 'json'; | ||
var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL); | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'GET'; | ||
@@ -1101,3 +1117,3 @@ ajaxSettings.dataType = 'json'; | ||
var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL); | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'POST'; | ||
@@ -1156,3 +1172,3 @@ ajaxSettings.data = JSON.stringify({ name: options.name }); | ||
var baseUrl = options.baseUrl || utils.getBaseUrl(); | ||
var ajaxSettings = options.ajaxSettings || {}; | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
return shutdownKernel(id, baseUrl, ajaxSettings); | ||
@@ -1220,12 +1236,27 @@ } | ||
} | ||
iteration_1.each(iteration_1.toArray(Private.runningKernels), function (kernel) { | ||
if (kernel.id === id) { | ||
kernel.terminated.emit(void 0); | ||
kernel.dispose(); | ||
} | ||
}); | ||
}, onKernelError); | ||
killKernels(id); | ||
}, function (error) { | ||
if (error.xhr.status === 404) { | ||
var response = JSON.parse(error.xhr.responseText); | ||
console.warn(response['message']); | ||
killKernels(id); | ||
} | ||
else { | ||
return onKernelError(error); | ||
} | ||
}); | ||
} | ||
Private.shutdownKernel = shutdownKernel; | ||
/** | ||
* Kill the kernels by id. | ||
*/ | ||
function killKernels(id) { | ||
iteration_1.each(iteration_1.toArray(Private.runningKernels), function (kernel) { | ||
if (kernel.id === id) { | ||
kernel.terminated.emit(void 0); | ||
kernel.dispose(); | ||
} | ||
}); | ||
} | ||
/** | ||
* Get a full kernel model from the server by kernel id string. | ||
@@ -1237,3 +1268,3 @@ */ | ||
var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(id)); | ||
var ajaxSettings = options.ajaxSettings || {}; | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'GET'; | ||
@@ -1240,0 +1271,0 @@ ajaxSettings.dataType = 'json'; |
@@ -82,5 +82,5 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
/** | ||
* A promise that is fulfilled when the kernel is initially ready. | ||
* A promise that resolves when the kernel is initially ready. | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -91,3 +91,3 @@ * Get the kernel spec. | ||
*/ | ||
spec(): Promise<Kernel.ISpecModel>; | ||
getSpec(): Promise<Kernel.ISpecModel>; | ||
/** | ||
@@ -429,2 +429,6 @@ * Send a shell message to the kernel. | ||
/** | ||
* The authentication token for the API. | ||
*/ | ||
token?: string; | ||
/** | ||
* The default ajax settings to use for the kernel. | ||
@@ -470,9 +474,9 @@ */ | ||
/** | ||
* A promise that is fulfilled when the kernel is initially ready. | ||
* Whether the manager is ready. | ||
*/ | ||
ready(): Promise<void>; | ||
readonly isReady: boolean; | ||
/** | ||
* A promise that fulfills when the manager is initially ready. | ||
* A promise that resolves when the manager is initially ready. | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -479,0 +483,0 @@ * Create an iterator over the known running kernels. |
@@ -57,3 +57,3 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -135,2 +135,3 @@ * Create an iterator over the most recent running kernels. | ||
private _wsUrl; | ||
private _token; | ||
private _ajaxSettings; | ||
@@ -137,0 +138,0 @@ private _running; |
@@ -24,2 +24,3 @@ // Copyright (c) Jupyter Development Team. | ||
this._wsUrl = ''; | ||
this._token = ''; | ||
this._ajaxSettings = ''; | ||
@@ -34,3 +35,4 @@ this._running = []; | ||
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl); | ||
this._ajaxSettings = JSON.stringify(options.ajaxSettings || {}); | ||
this._token = options.token || utils.getConfigOption('token'); | ||
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings, options.token)); | ||
// Initialize internal data. | ||
@@ -128,9 +130,13 @@ this._readyPromise = this._refreshSpecs().then(function () { | ||
}); | ||
Object.defineProperty(KernelManager.prototype, "ready", { | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
get: function () { | ||
return this._readyPromise; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
KernelManager.prototype.ready = function () { | ||
return this._readyPromise; | ||
}; | ||
/** | ||
* Create an iterator over the most recent running kernels. | ||
@@ -246,2 +252,3 @@ * | ||
baseUrl: this._baseUrl, | ||
token: this._token, | ||
ajaxSettings: this.ajaxSettings | ||
@@ -276,2 +283,3 @@ }; | ||
options.wsUrl = this._wsUrl; | ||
options.token = this._token; | ||
options.ajaxSettings = options.ajaxSettings || this.ajaxSettings; | ||
@@ -278,0 +286,0 @@ return options; |
@@ -56,3 +56,3 @@ import { JSONObject } from 'phosphor/lib/algorithm/json'; | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
private _sessionManager; | ||
@@ -103,3 +103,3 @@ private _contentsManager; | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
} | ||
@@ -119,2 +119,6 @@ /** | ||
/** | ||
* The authentication token for the API. | ||
*/ | ||
token?: string; | ||
/** | ||
* The ajax settings for the manager. | ||
@@ -121,0 +125,0 @@ */ |
@@ -25,3 +25,3 @@ // Copyright (c) Jupyter Development Team. | ||
options.baseUrl = options.baseUrl || utils_1.getBaseUrl(); | ||
options.ajaxSettings = options.ajaxSettings || {}; | ||
options.ajaxSettings = utils_1.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
this._sessionManager = new session_1.SessionManager(options); | ||
@@ -33,4 +33,4 @@ this._contentsManager = new contents_1.ContentsManager(options); | ||
}); | ||
this._readyPromise = this._sessionManager.ready().then(function () { | ||
return _this._terminalManager.ready(); | ||
this._readyPromise = this._sessionManager.ready.then(function () { | ||
return _this._terminalManager.ready; | ||
}); | ||
@@ -121,8 +121,12 @@ } | ||
}); | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
ServiceManager.prototype.ready = function () { | ||
return this._readyPromise; | ||
}; | ||
Object.defineProperty(ServiceManager.prototype, "ready", { | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
get: function () { | ||
return this._readyPromise; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return ServiceManager; | ||
@@ -129,0 +133,0 @@ }()); |
@@ -151,2 +151,3 @@ import { ISignal } from 'phosphor/lib/core/signaling'; | ||
private _ajaxSettings; | ||
private _token; | ||
private _kernel; | ||
@@ -153,0 +154,0 @@ private _uuid; |
@@ -28,2 +28,3 @@ // Copyright (c) Jupyter Development Team. | ||
this._ajaxSettings = ''; | ||
this._token = ''; | ||
this._kernel = null; | ||
@@ -38,3 +39,5 @@ this._uuid = ''; | ||
this._uuid = utils.uuid(); | ||
this._ajaxSettings = JSON.stringify(options.ajaxSettings || {}); | ||
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings || {}, options.token)); | ||
console.log(this._ajaxSettings); | ||
this._token = options.token || utils.getConfigOption('token'); | ||
Private.runningSessions.pushBack(this); | ||
@@ -391,3 +394,3 @@ this.setupKernel(kernel); | ||
var url = utils.urlPathJoin(baseUrl, SESSION_SERVICE_URL); | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'GET'; | ||
@@ -487,3 +490,3 @@ ajaxSettings.dataType = 'json'; | ||
var baseUrl = options.baseUrl || utils.getBaseUrl(); | ||
var ajaxSettings = options.ajaxSettings || {}; | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
return shutdownSession(id, baseUrl, ajaxSettings); | ||
@@ -503,3 +506,3 @@ } | ||
}; | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'POST'; | ||
@@ -535,2 +538,3 @@ ajaxSettings.dataType = 'json'; | ||
clientId: options.clientId, | ||
token: options.token, | ||
ajaxSettings: options.ajaxSettings | ||
@@ -563,3 +567,3 @@ }; | ||
var url = getSessionUrl(baseUrl, id); | ||
var ajaxSettings = options.ajaxSettings || {}; | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'GET'; | ||
@@ -629,9 +633,10 @@ ajaxSettings.dataType = 'json'; | ||
} | ||
iteration_1.each(iteration_1.toArray(Private.runningSessions), function (session) { | ||
if (session.id === id) { | ||
session.terminated.emit(void 0); | ||
session.dispose(); | ||
} | ||
}); | ||
killSessions(id); | ||
}, function (err) { | ||
if (err.xhr.status === 404) { | ||
var response = JSON.parse(err.xhr.responseText); | ||
console.warn(response['message']); | ||
killSessions(id); | ||
return; | ||
} | ||
if (err.xhr.status === 410) { | ||
@@ -645,2 +650,13 @@ err.throwError = 'The kernel was deleted but the session was not'; | ||
/** | ||
* Kill the sessions by id. | ||
*/ | ||
function killSessions(id) { | ||
iteration_1.each(iteration_1.toArray(Private.runningSessions), function (session) { | ||
if (session.id === id) { | ||
session.terminated.emit(void 0); | ||
session.dispose(); | ||
} | ||
}); | ||
} | ||
/** | ||
* Get a session url. | ||
@@ -647,0 +663,0 @@ */ |
@@ -58,3 +58,3 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -61,0 +61,0 @@ * Create an iterator over the most recent running sessions. |
@@ -125,9 +125,13 @@ // Copyright (c) Jupyter Development Team. | ||
}); | ||
Object.defineProperty(SessionManager.prototype, "ready", { | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
get: function () { | ||
return this._readyPromise; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
SessionManager.prototype.ready = function () { | ||
return this._readyPromise; | ||
}; | ||
/** | ||
* Create an iterator over the most recent running sessions. | ||
@@ -134,0 +138,0 @@ * |
@@ -253,2 +253,6 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
/** | ||
* The authentication token for the API. | ||
*/ | ||
token?: string; | ||
/** | ||
* The default ajax settings to use for the session. | ||
@@ -300,3 +304,3 @@ */ | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -303,0 +307,0 @@ * Create an iterator over the known running sessions. |
@@ -44,2 +44,6 @@ import { ISignal } from 'phosphor/lib/core/signaling'; | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
readonly ready: Promise<void>; | ||
/** | ||
* Test whether the session is disposed. | ||
@@ -53,6 +57,2 @@ */ | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
ready(): Promise<void>; | ||
/** | ||
* Send a message to the terminal session. | ||
@@ -73,2 +73,3 @@ */ | ||
private _url; | ||
private _token; | ||
private _ajaxSettings; | ||
@@ -75,0 +76,0 @@ private _ws; |
@@ -20,2 +20,3 @@ // Copyright (c) Jupyter Development Team. | ||
if (options === void 0) { options = {}; } | ||
this._token = ''; | ||
this._ajaxSettings = ''; | ||
@@ -27,3 +28,4 @@ this._ws = null; | ||
this._baseUrl = options.baseUrl || utils.getBaseUrl(); | ||
this._ajaxSettings = JSON.stringify(options.ajaxSettings || {}); | ||
this._token = options.token || utils.getConfigOption('token'); | ||
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings, this._token)); | ||
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl); | ||
@@ -88,2 +90,12 @@ this._readyPromise = this._initializeSocket(); | ||
}); | ||
Object.defineProperty(DefaultTerminalSession.prototype, "ready", { | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
get: function () { | ||
return this._readyPromise; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(DefaultTerminalSession.prototype, "isDisposed", { | ||
@@ -116,8 +128,2 @@ /** | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
DefaultTerminalSession.prototype.ready = function () { | ||
return this._readyPromise; | ||
}; | ||
/** | ||
* Send a message to the terminal session. | ||
@@ -134,3 +140,3 @@ */ | ||
} | ||
this.ready().then(function () { | ||
this.ready.then(function () { | ||
_this._ws.send(value); | ||
@@ -143,12 +149,7 @@ }); | ||
DefaultTerminalSession.prototype.shutdown = function () { | ||
var _this = this; | ||
var ajaxSettings = this.ajaxSettings; | ||
ajaxSettings.method = 'DELETE'; | ||
return utils.ajaxRequest(this._url, ajaxSettings).then(function (success) { | ||
if (success.xhr.status !== 204) { | ||
return utils.makeAjaxError(success); | ||
} | ||
_this.terminated.emit(void 0); | ||
_this.dispose(); | ||
}); | ||
var options = { | ||
baseUrl: this._baseUrl, | ||
ajaxSettings: this.ajaxSettings | ||
}; | ||
return DefaultTerminalSession.shutdown(this.name, options); | ||
}; | ||
@@ -164,2 +165,5 @@ /** | ||
var wsUrl = utils.urlPathJoin(this._wsUrl, "terminals/websocket/" + name); | ||
if (this._token) { | ||
wsUrl = wsUrl + ("?token=" + this._token); | ||
} | ||
this._ws = new WebSocket(wsUrl); | ||
@@ -202,3 +206,3 @@ this._ws.onmessage = function (event) { | ||
var url = Private.getBaseUrl(baseUrl); | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'POST'; | ||
@@ -257,3 +261,3 @@ ajaxSettings.dataType = 'json'; | ||
var url = Private.getBaseUrl(options.baseUrl); | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'GET'; | ||
@@ -296,3 +300,3 @@ ajaxSettings.dataType = 'json'; | ||
var url = Private.getTermUrl(options.baseUrl, name); | ||
var ajaxSettings = utils.copy(options.ajaxSettings || {}); | ||
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token); | ||
ajaxSettings.method = 'DELETE'; | ||
@@ -303,8 +307,11 @@ return utils.ajaxRequest(url, ajaxSettings).then(function (success) { | ||
} | ||
// Update the local data store. | ||
if (Private.running[url]) { | ||
var session = Private.running[url]; | ||
session.terminated.emit(void 0); | ||
session.dispose(); | ||
Private.killTerminal(url); | ||
}, function (err) { | ||
if (err.xhr.status === 404) { | ||
var response = JSON.parse(err.xhr.responseText); | ||
console.warn(response['message']); | ||
Private.killTerminal(url); | ||
return; | ||
} | ||
return Promise.reject(err); | ||
}); | ||
@@ -340,2 +347,14 @@ } | ||
Private.getBaseUrl = getBaseUrl; | ||
/** | ||
* Kill a terminal by url. | ||
*/ | ||
function killTerminal(url) { | ||
// Update the local data store. | ||
if (Private.running[url]) { | ||
var session = Private.running[url]; | ||
session.terminated.emit(void 0); | ||
session.dispose(); | ||
} | ||
} | ||
Private.killTerminal = killTerminal; | ||
})(Private || (Private = {})); |
@@ -48,3 +48,3 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -127,2 +127,6 @@ * Create an iterator over the most recent running terminals. | ||
/** | ||
* The authentication token for the API. | ||
*/ | ||
token?: string; | ||
/** | ||
* The Ajax settings used for server requests. | ||
@@ -129,0 +133,0 @@ */ |
@@ -105,9 +105,13 @@ // Copyright (c) Jupyter Development Team. | ||
}; | ||
Object.defineProperty(TerminalManager.prototype, "ready", { | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
get: function () { | ||
return this._readyPromise; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* A promise that fulfills when the manager is ready. | ||
*/ | ||
TerminalManager.prototype.ready = function () { | ||
return this._readyPromise; | ||
}; | ||
/** | ||
* Create an iterator over the most recent running terminals. | ||
@@ -114,0 +118,0 @@ * |
@@ -46,3 +46,3 @@ import { IIterator } from 'phosphor/lib/algorithm/iteration'; | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -97,2 +97,6 @@ * Send a message to the terminal session. | ||
/** | ||
* The authentication token for the API. | ||
*/ | ||
token?: string; | ||
/** | ||
* The Ajax settings used for server requests. | ||
@@ -159,3 +163,3 @@ */ | ||
*/ | ||
ready(): Promise<void>; | ||
readonly ready: Promise<void>; | ||
/** | ||
@@ -162,0 +166,0 @@ * Create an iterator over the known running terminals. |
@@ -250,1 +250,6 @@ import { JSONObject } from 'phosphor/lib/algorithm/json'; | ||
export declare function getWsUrl(baseUrl?: string): string; | ||
/** | ||
* Add token to ajaxSettings.requestHeaders if defined. | ||
* Always returns a copy of ajaxSettings, and a dict. | ||
*/ | ||
export declare function ajaxSettingsWithToken(ajaxSettings?: IAjaxSettings, token?: string): IAjaxSettings; |
@@ -344,1 +344,25 @@ // Copyright (c) Jupyter Development Team. | ||
exports.getWsUrl = getWsUrl; | ||
/** | ||
* Add token to ajaxSettings.requestHeaders if defined. | ||
* Always returns a copy of ajaxSettings, and a dict. | ||
*/ | ||
function ajaxSettingsWithToken(ajaxSettings, token) { | ||
if (!ajaxSettings) { | ||
ajaxSettings = {}; | ||
} | ||
else { | ||
ajaxSettings = copy(ajaxSettings); | ||
} | ||
if (!token) { | ||
token = getConfigOption('token'); | ||
} | ||
if (!token || token == '') { | ||
return ajaxSettings; | ||
} | ||
if (!ajaxSettings.requestHeaders) { | ||
ajaxSettings.requestHeaders = {}; | ||
} | ||
ajaxSettings.requestHeaders['Authorization'] = "token " + token; | ||
return ajaxSettings; | ||
} | ||
exports.ajaxSettingsWithToken = ajaxSettingsWithToken; |
{ | ||
"name": "@jupyterlab/services", | ||
"version": "0.32.0", | ||
"version": "0.33.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
727356
21343