@lumino/signaling
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
import { find, ArrayExt } from '@lumino/algorithm'; | ||
import { PromiseDelegate } from '@lumino/coreutils'; | ||
import { AttachedProperty } from '@lumino/properties'; | ||
@@ -62,26 +61,5 @@ // Copyright (c) Jupyter Development Team. | ||
constructor(sender) { | ||
/** | ||
* If `blocked` is not `0`, the signal will not emit. | ||
*/ | ||
this.blocked = 0; | ||
this.sender = sender; | ||
} | ||
/** | ||
* Block the signal during the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param fn The callback during which the signal is blocked | ||
*/ | ||
block(fn) { | ||
this.blocked++; | ||
try { | ||
fn(); | ||
} | ||
finally { | ||
this.blocked--; | ||
} | ||
} | ||
/** | ||
* Connect a slot to the signal. | ||
@@ -123,5 +101,3 @@ * | ||
emit(args) { | ||
if (!this.blocked) { | ||
Private.emit(this, args); | ||
} | ||
Private.emit(this, args); | ||
} | ||
@@ -134,23 +110,2 @@ } | ||
/** | ||
* Block all signals emitted by an object during | ||
* the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param sender The signals sender | ||
* @param fn The callback during which all signals are blocked | ||
*/ | ||
function blockAll(sender, fn) { | ||
const { blockedProperty } = Private; | ||
blockedProperty.set(sender, blockedProperty.get(sender) + 1); | ||
try { | ||
fn(); | ||
} | ||
finally { | ||
blockedProperty.set(sender, blockedProperty.get(sender) - 1); | ||
} | ||
} | ||
Signal.blockAll = blockAll; | ||
/** | ||
* Remove all connections between a sender and receiver. | ||
@@ -321,8 +276,6 @@ * | ||
emit(args) { | ||
if (!this.blocked) { | ||
const pending = this._pending; | ||
const next = (this._pending = new PromiseDelegate()); | ||
pending.resolve({ args, next }); | ||
super.emit(args); | ||
} | ||
const pending = this._pending; | ||
const next = (this._pending = new PromiseDelegate()); | ||
pending.resolve({ args, next }); | ||
super.emit(args); | ||
} | ||
@@ -542,5 +495,2 @@ /** | ||
function emit(signal, args) { | ||
if (Private.blockedProperty.get(signal.sender) > 0) { | ||
return; | ||
} | ||
// If there are no receivers, there is nothing to do. | ||
@@ -646,9 +596,2 @@ let receivers = receiversForSender.get(signal.sender); | ||
} | ||
/** | ||
* A property indicating a sender has been blocked if its value is not 0. | ||
*/ | ||
Private.blockedProperty = new AttachedProperty({ | ||
name: 'blocked', | ||
create: () => 0 | ||
}); | ||
})(Private || (Private = {})); | ||
@@ -655,0 +598,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@lumino/algorithm'), require('@lumino/coreutils'), require('@lumino/properties')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@lumino/algorithm', '@lumino/coreutils', '@lumino/properties'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.lumino_signaling = {}, global.lumino_algorithm, global.lumino_coreutils, global.lumino_properties)); | ||
})(this, (function (exports, algorithm, coreutils, properties) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@lumino/algorithm'), require('@lumino/coreutils')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@lumino/algorithm', '@lumino/coreutils'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.lumino_signaling = {}, global.lumino_algorithm, global.lumino_coreutils)); | ||
})(this, (function (exports, algorithm, coreutils) { 'use strict'; | ||
@@ -64,26 +64,5 @@ // Copyright (c) Jupyter Development Team. | ||
constructor(sender) { | ||
/** | ||
* If `blocked` is not `0`, the signal will not emit. | ||
*/ | ||
this.blocked = 0; | ||
this.sender = sender; | ||
} | ||
/** | ||
* Block the signal during the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param fn The callback during which the signal is blocked | ||
*/ | ||
block(fn) { | ||
this.blocked++; | ||
try { | ||
fn(); | ||
} | ||
finally { | ||
this.blocked--; | ||
} | ||
} | ||
/** | ||
* Connect a slot to the signal. | ||
@@ -125,5 +104,3 @@ * | ||
emit(args) { | ||
if (!this.blocked) { | ||
Private.emit(this, args); | ||
} | ||
Private.emit(this, args); | ||
} | ||
@@ -136,23 +113,2 @@ } | ||
/** | ||
* Block all signals emitted by an object during | ||
* the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param sender The signals sender | ||
* @param fn The callback during which all signals are blocked | ||
*/ | ||
function blockAll(sender, fn) { | ||
const { blockedProperty } = Private; | ||
blockedProperty.set(sender, blockedProperty.get(sender) + 1); | ||
try { | ||
fn(); | ||
} | ||
finally { | ||
blockedProperty.set(sender, blockedProperty.get(sender) - 1); | ||
} | ||
} | ||
Signal.blockAll = blockAll; | ||
/** | ||
* Remove all connections between a sender and receiver. | ||
@@ -323,8 +279,6 @@ * | ||
emit(args) { | ||
if (!this.blocked) { | ||
const pending = this._pending; | ||
const next = (this._pending = new coreutils.PromiseDelegate()); | ||
pending.resolve({ args, next }); | ||
super.emit(args); | ||
} | ||
const pending = this._pending; | ||
const next = (this._pending = new coreutils.PromiseDelegate()); | ||
pending.resolve({ args, next }); | ||
super.emit(args); | ||
} | ||
@@ -544,5 +498,2 @@ /** | ||
function emit(signal, args) { | ||
if (Private.blockedProperty.get(signal.sender) > 0) { | ||
return; | ||
} | ||
// If there are no receivers, there is nothing to do. | ||
@@ -648,9 +599,2 @@ let receivers = receiversForSender.get(signal.sender); | ||
} | ||
/** | ||
* A property indicating a sender has been blocked if its value is not 0. | ||
*/ | ||
Private.blockedProperty = new properties.AttachedProperty({ | ||
name: 'blocked', | ||
create: () => 0 | ||
}); | ||
})(Private || (Private = {})); | ||
@@ -657,0 +601,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@lumino/algorithm"),require("@lumino/coreutils"),require("@lumino/properties")):"function"==typeof define&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils","@lumino/properties"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_signaling={},e.lumino_algorithm,e.lumino_coreutils,e.lumino_properties)}(this,(function(e,n,t,i){"use strict";class o{constructor(e){this.blocked=0,this.sender=e}block(e){this.blocked++;try{e()}finally{this.blocked--}}connect(e,n){return l.connect(this,e,n)}disconnect(e,n){return l.disconnect(this,e,n)}emit(e){this.blocked||l.emit(this,e)}}!function(e){e.blockAll=function(e,n){const{blockedProperty:t}=l;t.set(e,t.get(e)+1);try{n()}finally{t.set(e,t.get(e)-1)}},e.disconnectBetween=function(e,n){l.disconnectBetween(e,n)},e.disconnectSender=function(e){l.disconnectSender(e)},e.disconnectReceiver=function(e){l.disconnectReceiver(e)},e.disconnectAll=function(e){l.disconnectAll(e)},e.clearData=function(e){l.disconnectAll(e)},e.getExceptionHandler=function(){return l.exceptionHandler},e.setExceptionHandler=function(e){let n=l.exceptionHandler;return l.exceptionHandler=e,n}}(o||(o={}));class r extends o{constructor(){super(...arguments),this._pending=new t.PromiseDelegate}async*[Symbol.asyncIterator](){let e=this._pending;for(;;)try{const{args:n,next:t}=await e.promise;e=t,yield n}catch(e){return}}emit(e){if(!this.blocked){const n=this._pending,i=this._pending=new t.PromiseDelegate;n.resolve({args:e,next:i}),super.emit(e)}}stop(){this._pending.promise.catch((()=>{})),this._pending.reject("stop"),this._pending=new t.PromiseDelegate}}var l;!function(e){function t(e){let n=r.get(e);if(n&&0!==n.length){for(const e of n){if(!e.signal)continue;let n=e.thisArg||e.slot;e.signal=null,a(l.get(n))}a(n)}}function o(e){let n=l.get(e);if(n&&0!==n.length){for(const e of n){if(!e.signal)continue;let n=e.signal.sender;e.signal=null,a(r.get(n))}a(n)}}e.exceptionHandler=e=>{console.error(e)},e.connect=function(e,n,t){t=t||void 0;let i=r.get(e.sender);if(i||(i=[],r.set(e.sender,i)),u(i,e,n,t))return!1;let o=t||n,c=l.get(o);c||(c=[],l.set(o,c));let s={signal:e,slot:n,thisArg:t};return i.push(s),c.push(s),!0},e.disconnect=function(e,n,t){t=t||void 0;let i=r.get(e.sender);if(!i||0===i.length)return!1;let o=u(i,e,n,t);if(!o)return!1;let c=t||n,s=l.get(c);return o.signal=null,a(i),a(s),!0},e.disconnectBetween=function(e,n){let t=r.get(e);if(!t||0===t.length)return;let i=l.get(n);if(i&&0!==i.length){for(const n of i)n.signal&&n.signal.sender===e&&(n.signal=null);a(t),a(i)}},e.disconnectSender=t,e.disconnectReceiver=o,e.disconnectAll=function(e){t(e),o(e)},e.emit=function(n,t){if(e.blockedProperty.get(n.sender)>0)return;let i=r.get(n.sender);if(i&&0!==i.length)for(let e=0,o=i.length;e<o;++e){let o=i[e];o.signal===n&&d(o,t)}};const r=new WeakMap,l=new WeakMap,c=new Set,s="function"==typeof requestAnimationFrame?requestAnimationFrame:setImmediate;function u(e,t,i,o){return n.find(e,(e=>e.signal===t&&e.slot===i&&e.thisArg===o))}function d(n,t){let{signal:i,slot:o,thisArg:r}=n;try{o.call(r,i.sender,t)}catch(n){e.exceptionHandler(n)}}function a(e){0===c.size&&s(f),c.add(e)}function f(){c.forEach(g),c.clear()}function g(e){n.ArrayExt.removeAllWhere(e,p)}function p(e){return null===e.signal}e.blockedProperty=new i.AttachedProperty({name:"blocked",create:()=>0})}(l||(l={})),e.Signal=o,e.Stream=r})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@lumino/algorithm"),require("@lumino/coreutils")):"function"==typeof define&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_signaling={},e.lumino_algorithm,e.lumino_coreutils)}(this,(function(e,n,t){"use strict";class i{constructor(e){this.sender=e}connect(e,n){return c.connect(this,e,n)}disconnect(e,n){return c.disconnect(this,e,n)}emit(e){c.emit(this,e)}}!function(e){e.disconnectBetween=function(e,n){c.disconnectBetween(e,n)},e.disconnectSender=function(e){c.disconnectSender(e)},e.disconnectReceiver=function(e){c.disconnectReceiver(e)},e.disconnectAll=function(e){c.disconnectAll(e)},e.clearData=function(e){c.disconnectAll(e)},e.getExceptionHandler=function(){return c.exceptionHandler},e.setExceptionHandler=function(e){let n=c.exceptionHandler;return c.exceptionHandler=e,n}}(i||(i={}));class o extends i{constructor(){super(...arguments),this._pending=new t.PromiseDelegate}async*[Symbol.asyncIterator](){let e=this._pending;for(;;)try{const{args:n,next:t}=await e.promise;e=t,yield n}catch(e){return}}emit(e){const n=this._pending,i=this._pending=new t.PromiseDelegate;n.resolve({args:e,next:i}),super.emit(e)}stop(){this._pending.promise.catch((()=>{})),this._pending.reject("stop"),this._pending=new t.PromiseDelegate}}var c;!function(e){function t(e){let n=o.get(e);if(n&&0!==n.length){for(const e of n){if(!e.signal)continue;let n=e.thisArg||e.slot;e.signal=null,a(c.get(n))}a(n)}}function i(e){let n=c.get(e);if(n&&0!==n.length){for(const e of n){if(!e.signal)continue;let n=e.signal.sender;e.signal=null,a(o.get(n))}a(n)}}e.exceptionHandler=e=>{console.error(e)},e.connect=function(e,n,t){t=t||void 0;let i=o.get(e.sender);if(i||(i=[],o.set(e.sender,i)),l(i,e,n,t))return!1;let s=t||n,r=c.get(s);r||(r=[],c.set(s,r));let u={signal:e,slot:n,thisArg:t};return i.push(u),r.push(u),!0},e.disconnect=function(e,n,t){t=t||void 0;let i=o.get(e.sender);if(!i||0===i.length)return!1;let s=l(i,e,n,t);if(!s)return!1;let r=t||n,u=c.get(r);return s.signal=null,a(i),a(u),!0},e.disconnectBetween=function(e,n){let t=o.get(e);if(!t||0===t.length)return;let i=c.get(n);if(i&&0!==i.length){for(const n of i)n.signal&&n.signal.sender===e&&(n.signal=null);a(t),a(i)}},e.disconnectSender=t,e.disconnectReceiver=i,e.disconnectAll=function(e){t(e),i(e)},e.emit=function(e,n){let t=o.get(e.sender);if(t&&0!==t.length)for(let i=0,o=t.length;i<o;++i){let o=t[i];o.signal===e&&u(o,n)}};const o=new WeakMap,c=new WeakMap,s=new Set,r="function"==typeof requestAnimationFrame?requestAnimationFrame:setImmediate;function l(e,t,i,o){return n.find(e,(e=>e.signal===t&&e.slot===i&&e.thisArg===o))}function u(n,t){let{signal:i,slot:o,thisArg:c}=n;try{o.call(c,i.sender,t)}catch(n){e.exceptionHandler(n)}}function a(e){0===s.size&&r(d),s.add(e)}function d(){s.forEach(f),s.clear()}function f(e){n.ArrayExt.removeAllWhere(e,g)}function g(e){return null===e.signal}}(c||(c={})),e.Signal=i,e.Stream=o})); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@lumino/signaling", | ||
"version": "2.0.0-beta.0", | ||
"version": "2.0.0-beta.1", | ||
"description": "Lumino Signals and Slots", | ||
@@ -48,4 +48,3 @@ "homepage": "https://github.com/jupyterlab/lumino", | ||
"@lumino/algorithm": "^2.0.0-beta.0", | ||
"@lumino/coreutils": "^2.0.0-beta.0", | ||
"@lumino/properties": "^2.0.0-beta.0" | ||
"@lumino/coreutils": "^2.0.0-beta.0" | ||
}, | ||
@@ -52,0 +51,0 @@ "devDependencies": { |
@@ -12,3 +12,2 @@ // Copyright (c) Jupyter Development Team. | ||
import { PromiseDelegate } from '@lumino/coreutils'; | ||
import { AttachedProperty } from '@lumino/properties'; | ||
@@ -38,12 +37,2 @@ /** | ||
/** | ||
* Block the signal during the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param fn The callback during which the signal is blocked | ||
*/ | ||
block(fn: () => void): void; | ||
/** | ||
* Connect a slot to the signal. | ||
@@ -160,19 +149,2 @@ * | ||
/** | ||
* Block the signal during the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param fn The callback during which the signal is blocked | ||
*/ | ||
block(fn: () => void): void { | ||
this.blocked++; | ||
try { | ||
fn(); | ||
} finally { | ||
this.blocked--; | ||
} | ||
} | ||
/** | ||
* Connect a slot to the signal. | ||
@@ -216,11 +188,4 @@ * | ||
emit(args: U): void { | ||
if (!this.blocked) { | ||
Private.emit(this, args); | ||
} | ||
Private.emit(this, args); | ||
} | ||
/** | ||
* If `blocked` is not `0`, the signal will not emit. | ||
*/ | ||
protected blocked = 0; | ||
} | ||
@@ -233,22 +198,2 @@ | ||
/** | ||
* Block all signals emitted by an object during | ||
* the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param sender The signals sender | ||
* @param fn The callback during which all signals are blocked | ||
*/ | ||
export function blockAll(sender: unknown, fn: () => void): void { | ||
const { blockedProperty } = Private; | ||
blockedProperty.set(sender, blockedProperty.get(sender) + 1); | ||
try { | ||
fn(); | ||
} finally { | ||
blockedProperty.set(sender, blockedProperty.get(sender) - 1); | ||
} | ||
} | ||
/** | ||
* Remove all connections between a sender and receiver. | ||
@@ -422,8 +367,6 @@ * | ||
emit(args: U): void { | ||
if (!this.blocked) { | ||
const pending = this._pending; | ||
const next = (this._pending = new PromiseDelegate()); | ||
pending.resolve({ args, next }); | ||
super.emit(args); | ||
} | ||
const pending = this._pending; | ||
const next = (this._pending = new PromiseDelegate()); | ||
pending.resolve({ args, next }); | ||
super.emit(args); | ||
} | ||
@@ -686,6 +629,2 @@ | ||
export function emit<T, U>(signal: Signal<T, U>, args: U): void { | ||
if (Private.blockedProperty.get(signal.sender) > 0) { | ||
return; | ||
} | ||
// If there are no receivers, there is nothing to do. | ||
@@ -831,10 +770,2 @@ let receivers = receiversForSender.get(signal.sender); | ||
} | ||
/** | ||
* A property indicating a sender has been blocked if its value is not 0. | ||
*/ | ||
export const blockedProperty = new AttachedProperty<unknown, number>({ | ||
name: 'blocked', | ||
create: () => 0 | ||
}); | ||
} |
@@ -23,11 +23,2 @@ /** | ||
/** | ||
* Block the signal during the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param fn The callback during which the signal is blocked | ||
*/ | ||
block(fn: () => void): void; | ||
/** | ||
* Connect a slot to the signal. | ||
@@ -138,11 +129,2 @@ * | ||
/** | ||
* Block the signal during the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param fn The callback during which the signal is blocked | ||
*/ | ||
block(fn: () => void): void; | ||
/** | ||
* Connect a slot to the signal. | ||
@@ -180,6 +162,2 @@ * | ||
emit(args: U): void; | ||
/** | ||
* If `blocked` is not `0`, the signal will not emit. | ||
*/ | ||
protected blocked: number; | ||
} | ||
@@ -191,13 +169,2 @@ /** | ||
/** | ||
* Block all signals emitted by an object during | ||
* the execution of a callback. | ||
* | ||
* ### Notes | ||
* The callback function must be synchronous. | ||
* | ||
* @param sender The signals sender | ||
* @param fn The callback during which all signals are blocked | ||
*/ | ||
function blockAll(sender: unknown, fn: () => void): void; | ||
/** | ||
* Remove all connections between a sender and receiver. | ||
@@ -204,0 +171,0 @@ * |
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
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
2
161758
2195
- Removed@lumino/properties@^2.0.0-beta.0
- Removed@lumino/properties@2.0.2(transitive)