@jupyterlab/services
Advanced tools
Comparing version 1.1.4 to 2.0.0
@@ -289,3 +289,3 @@ import { IDisposable } from '@phosphor/disposable'; | ||
*/ | ||
connectToComm(targetName: string, commId?: string): Kernel.IComm; | ||
connectToComm(targetName: string, commId?: string): Promise<Kernel.IComm>; | ||
/** | ||
@@ -358,3 +358,2 @@ * Handle a message with a display id. | ||
private _commPromises; | ||
private _comms; | ||
private _targetRegistry; | ||
@@ -361,0 +360,0 @@ private _info; |
@@ -201,3 +201,2 @@ "use strict"; | ||
this._commPromises = new Map(); | ||
this._comms = new Map(); | ||
this._createSocket(); | ||
@@ -388,4 +387,6 @@ Private.runningKernels.push(this); | ||
}); | ||
this._comms.forEach(function (comm, key) { | ||
comm.dispose(); | ||
this._commPromises.forEach(function (promise, key) { | ||
promise.then(function (comm) { | ||
comm.dispose(); | ||
}); | ||
}); | ||
@@ -774,5 +775,10 @@ this._displayIdToParentIds.clear(); | ||
var id = commId || coreutils_1.uuid(); | ||
var comm = this._comms.get(id) || new comm_1.CommHandler(targetName, id, this, function () { _this._unregisterComm(id); }); | ||
this._comms.set(id, comm); | ||
return comm; | ||
if (this._commPromises.has(id)) { | ||
return this._commPromises.get(id); | ||
} | ||
var promise = Promise.resolve(void 0).then(function () { | ||
return new comm_1.CommHandler(targetName, id, _this, function () { _this._unregisterComm(id); }); | ||
}); | ||
this._commPromises.set(id, promise); | ||
return promise; | ||
}; | ||
@@ -898,8 +904,9 @@ /** | ||
}); | ||
this._comms.forEach(function (comm, key) { | ||
comm.dispose(); | ||
this._commPromises.forEach(function (promise, key) { | ||
promise.then(function (comm) { | ||
comm.dispose(); | ||
}); | ||
}); | ||
this._futures = new Map(); | ||
this._commPromises = new Map(); | ||
this._comms = new Map(); | ||
this._displayIdToParentIds.clear(); | ||
@@ -932,4 +939,2 @@ this._msgIdToDisplayIds.clear(); | ||
} | ||
_this._commPromises.delete(comm.commId); | ||
_this._comms.set(comm.commId, comm); | ||
return comm; | ||
@@ -948,8 +953,4 @@ }); | ||
if (!promise) { | ||
var comm = this._comms.get(content.comm_id); | ||
if (!comm) { | ||
console.error('Comm not found for comm id ' + content.comm_id); | ||
return; | ||
} | ||
promise = Promise.resolve(comm); | ||
console.error('Comm not found for comm id ' + content.comm_id); | ||
return; | ||
} | ||
@@ -980,8 +981,10 @@ promise.then(function (comm) { | ||
if (!promise) { | ||
var comm = this._comms.get(content.comm_id); | ||
// We do have a registered comm for this comm id, ignore. | ||
return; | ||
} | ||
promise.then(function (comm) { | ||
if (!comm) { | ||
// We do have a registered comm for this comm id, ignore. | ||
return; | ||
} | ||
else { | ||
try { | ||
var onMsg = comm.onMsg; | ||
@@ -992,19 +995,6 @@ if (onMsg) { | ||
} | ||
} | ||
else { | ||
promise.then(function (comm) { | ||
if (!comm) { | ||
return; | ||
} | ||
try { | ||
var onMsg = comm.onMsg; | ||
if (onMsg) { | ||
onMsg(msg); | ||
} | ||
} | ||
catch (e) { | ||
console.error('Exception handling comm msg: ', e, e.stack, msg); | ||
} | ||
}); | ||
} | ||
catch (e) { | ||
console.error('Exception handling comm msg: ', e, e.stack, msg); | ||
} | ||
}); | ||
}; | ||
@@ -1015,3 +1005,2 @@ /** | ||
DefaultKernel.prototype._unregisterComm = function (commId) { | ||
this._comms.delete(commId); | ||
this._commPromises.delete(commId); | ||
@@ -1018,0 +1007,0 @@ }; |
@@ -255,8 +255,8 @@ import { IIterator } from '@phosphor/algorithm'; | ||
* | ||
* @returns A comm instance. | ||
* @returns A promise that resolves with a comm instance. | ||
* | ||
* #### Notes | ||
* If a client-side comm already exists, it is returned. | ||
* If a promise to client-side comm already exists, it is returned. | ||
*/ | ||
connectToComm(targetName: string, commId?: string): Kernel.IComm; | ||
connectToComm(targetName: string, commId?: string): Promise<Kernel.IComm>; | ||
/** | ||
@@ -263,0 +263,0 @@ * Register a comm target handler. |
@@ -46,5 +46,13 @@ "use strict"; | ||
this._modelsTimer = setInterval(function () { | ||
if (typeof document !== 'undefined' && document.hidden) { | ||
// Don't poll when nobody's looking. | ||
return; | ||
} | ||
_this._refreshRunning(); | ||
}, 10000); | ||
this._specsTimer = setInterval(function () { | ||
if (typeof document !== 'undefined' && document.hidden) { | ||
// Don't poll when nobody's looking. | ||
return; | ||
} | ||
_this._refreshSpecs(); | ||
@@ -51,0 +59,0 @@ }, 61000); |
@@ -46,5 +46,13 @@ "use strict"; | ||
this._modelsTimer = setInterval(function () { | ||
if (typeof document !== 'undefined' && document.hidden) { | ||
// Don't poll when nobody's looking. | ||
return; | ||
} | ||
_this._refreshRunning(); | ||
}, 10000); | ||
this._specsTimer = setInterval(function () { | ||
if (typeof document !== 'undefined' && document.hidden) { | ||
// Don't poll when nobody's looking. | ||
return; | ||
} | ||
_this._refreshSpecs(); | ||
@@ -51,0 +59,0 @@ }, 61000); |
@@ -41,2 +41,6 @@ "use strict"; | ||
this._refreshTimer = setInterval(function () { | ||
if (typeof document !== 'undefined' && document.hidden) { | ||
// Don't poll when nobody's looking. | ||
return; | ||
} | ||
_this._refreshRunning(); | ||
@@ -43,0 +47,0 @@ }, 10000); |
{ | ||
"name": "@jupyterlab/services", | ||
"version": "1.1.4", | ||
"version": "2.0.0", | ||
"description": "Client APIs for the Jupyter services REST APIs", | ||
@@ -47,4 +47,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@jupyterlab/coreutils": "^1.0.6", | ||
"@jupyterlab/observables": "^1.0.6", | ||
"@jupyterlab/coreutils": "^1.1.0", | ||
"@jupyterlab/observables": "^1.0.7", | ||
"@phosphor/algorithm": "^1.1.2", | ||
@@ -51,0 +51,0 @@ "@phosphor/coreutils": "^1.3.0", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
2919835
72116
4