@lumino/polling
Advanced tools
Comparing version 2.0.0-alpha.7 to 2.0.0-beta.0
@@ -558,5 +558,3 @@ (function (global, factory) { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@lumino/coreutils"),require("@lumino/signaling")):"function"==typeof define&&define.amd?define(["exports","@lumino/coreutils","@lumino/signaling"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_polling={},e.lumino_coreutils,e.lumino_signaling)}(this,(function(e,t,i){"use strict";class s{constructor(e){var s;this._disposed=new i.Signal(this),this._lingered=0,this._tick=new t.PromiseDelegate,this._ticked=new i.Signal(this),this._factory=e.factory,this._linger=null!==(s=e.linger)&&void 0!==s?s:n.DEFAULT_LINGER,this._standby=e.standby||n.DEFAULT_STANDBY,this._state={...n.DEFAULT_STATE,timestamp:(new Date).getTime()};const a=e.frequency||{},r=Math.max(a.interval||0,a.max||0,n.DEFAULT_FREQUENCY.max);this.frequency={...n.DEFAULT_FREQUENCY,...a,max:r},this.name=e.name||n.DEFAULT_NAME,"auto"in e&&!e.auto||setTimeout((()=>this.start()))}get disposed(){return this._disposed}get frequency(){return this._frequency}set frequency(e){if(this.isDisposed||t.JSONExt.deepEqual(e,this.frequency||{}))return;let{backoff:i,interval:n,max:a}=e;if(n=Math.round(n),a=Math.round(a),"number"==typeof i&&i<1)throw new Error("Poll backoff growth factor must be at least 1");if((n<0||n>a)&&n!==s.NEVER)throw new Error("Poll interval must be between 0 and max");if(a>s.MAX_INTERVAL&&a!==s.NEVER)throw new Error(`Max interval must be less than ${s.MAX_INTERVAL}`);this._frequency={backoff:i,interval:n,max:a}}get isDisposed(){return"disposed"===this.state.phase}get standby(){return this._standby}set standby(e){this.isDisposed||this.standby===e||(this._standby=e)}get state(){return this._state}get tick(){return this._tick.promise}get ticked(){return this._ticked}async*[Symbol.asyncIterator](){for(;!this.isDisposed;)yield this.state,await this.tick.catch((()=>{}))}dispose(){this.isDisposed||(this._state={...n.DISPOSED_STATE,timestamp:(new Date).getTime()},this._tick.promise.catch((e=>{})),this._tick.reject(new Error(`Poll (${this.name}) is disposed.`)),this._disposed.emit(void 0),i.Signal.clearData(this))}refresh(){return this.schedule({cancel:({phase:e})=>"refreshed"===e,interval:s.IMMEDIATE,phase:"refreshed"})}async schedule(e={}){if(this.isDisposed)return;if(e.cancel&&e.cancel(this.state))return;const i=this._tick,n=new t.PromiseDelegate,a={interval:this.frequency.interval,payload:null,phase:"standby",timestamp:(new Date).getTime(),...e};if(this._state=a,this._tick=n,clearTimeout(this._timeout),this._ticked.emit(this.state),i.resolve(this),await i.promise,a.interval===s.NEVER)return void(this._timeout=void 0);this._timeout=setTimeout((()=>{this.isDisposed||this.tick!==n.promise||this._execute()}),a.interval)}start(){return this.schedule({cancel:({phase:e})=>"constructed"!==e&&"standby"!==e&&"stopped"!==e,interval:s.IMMEDIATE,phase:"started"})}stop(){return this.schedule({cancel:({phase:e})=>"stopped"===e,interval:s.NEVER,phase:"stopped"})}get hidden(){return n.hidden}_execute(){let e="function"==typeof this.standby?this.standby():this.standby;if("never"===e?e=!1:"when-hidden"===e&&(this.hidden?e=++this._lingered>this._linger:(this._lingered=0,e=!1)),e)return void this.schedule();const t=this.tick;this._factory(this.state).then((e=>{this.isDisposed||this.tick!==t||this.schedule({payload:e,phase:"rejected"===this.state.phase?"reconnected":"resolved"})})).catch((e=>{this.isDisposed||this.tick!==t||this.schedule({interval:n.sleep(this.frequency,this.state),payload:e,phase:"rejected"})}))}}var n;!function(e){e.IMMEDIATE=0,e.MAX_INTERVAL=2147483647,e.NEVER=1/0}(s||(s={})),function(e){e.DEFAULT_BACKOFF=3,e.DEFAULT_FREQUENCY={backoff:!0,interval:1e3,max:3e4},e.DEFAULT_LINGER=1,e.DEFAULT_NAME="unknown",e.DEFAULT_STANDBY="when-hidden",e.DEFAULT_STATE={interval:s.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},e.DISPOSED_STATE={interval:s.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()},e.sleep=function(t,i){const{backoff:n,interval:a,max:r}=t;if(a===s.NEVER)return a;const o=!0===n?e.DEFAULT_BACKOFF:!1===n?1:n,h=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}(a,i.interval*o);return Math.min(r,h)},e.hidden="undefined"!=typeof document&&(document.addEventListener("visibilitychange",(()=>{e.hidden="hidden"===document.visibilityState})),document.addEventListener("pagehide",(()=>{e.hidden="hidden"===document.visibilityState})),"hidden"===document.visibilityState)}(n||(n={}));class a{constructor(e,i=500){this.args=void 0,this.payload=null,this.limit=i,this.poll=new s({auto:!1,factory:async()=>{const{args:t}=this;return this.args=void 0,e(...t)},frequency:{backoff:!1,interval:s.NEVER,max:s.NEVER},standby:"never"}),this.payload=new t.PromiseDelegate,this.poll.ticked.connect(((e,i)=>{const{payload:s}=this;return"resolved"===i.phase?(this.payload=new t.PromiseDelegate,void s.resolve(i.payload)):"rejected"===i.phase||"stopped"===i.phase?(this.payload=new t.PromiseDelegate,s.promise.catch((e=>{})),void s.reject(i.payload)):void 0}),this)}get isDisposed(){return null===this.payload}dispose(){this.isDisposed||(this.args=void 0,this.payload=null,this.poll.dispose())}async stop(){return this.poll.stop()}}e.Debouncer=class extends a{invoke(...e){return this.args=e,this.poll.schedule({interval:this.limit,phase:"invoked"}),this.payload.promise}},e.Poll=s,e.RateLimiter=a,e.Throttler=class extends a{constructor(e,t){super(e,"number"==typeof t?t:t&&t.limit),this._trailing=!1,"number"!=typeof t&&t&&"trailing"===t.edge&&(this._trailing=!0),this._interval=this._trailing?this.limit:s.IMMEDIATE}invoke(...e){const t="invoked"!==this.poll.state.phase;return(t||this._trailing)&&(this.args=e),t&&this.poll.schedule({interval:this._interval,phase:"invoked"}),this.payload.promise}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@lumino/coreutils"),require("@lumino/signaling")):"function"==typeof define&&define.amd?define(["exports","@lumino/coreutils","@lumino/signaling"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_polling={},e.lumino_coreutils,e.lumino_signaling)}(this,(function(e,t,i){"use strict";class s{constructor(e){var s;this._disposed=new i.Signal(this),this._lingered=0,this._tick=new t.PromiseDelegate,this._ticked=new i.Signal(this),this._factory=e.factory,this._linger=null!==(s=e.linger)&&void 0!==s?s:n.DEFAULT_LINGER,this._standby=e.standby||n.DEFAULT_STANDBY,this._state={...n.DEFAULT_STATE,timestamp:(new Date).getTime()};const a=e.frequency||{},r=Math.max(a.interval||0,a.max||0,n.DEFAULT_FREQUENCY.max);this.frequency={...n.DEFAULT_FREQUENCY,...a,max:r},this.name=e.name||n.DEFAULT_NAME,"auto"in e&&!e.auto||setTimeout((()=>this.start()))}get disposed(){return this._disposed}get frequency(){return this._frequency}set frequency(e){if(this.isDisposed||t.JSONExt.deepEqual(e,this.frequency||{}))return;let{backoff:i,interval:n,max:a}=e;if(n=Math.round(n),a=Math.round(a),"number"==typeof i&&i<1)throw new Error("Poll backoff growth factor must be at least 1");if((n<0||n>a)&&n!==s.NEVER)throw new Error("Poll interval must be between 0 and max");if(a>s.MAX_INTERVAL&&a!==s.NEVER)throw new Error(`Max interval must be less than ${s.MAX_INTERVAL}`);this._frequency={backoff:i,interval:n,max:a}}get isDisposed(){return"disposed"===this.state.phase}get standby(){return this._standby}set standby(e){this.isDisposed||this.standby===e||(this._standby=e)}get state(){return this._state}get tick(){return this._tick.promise}get ticked(){return this._ticked}async*[Symbol.asyncIterator](){for(;!this.isDisposed;)yield this.state,await this.tick.catch((()=>{}))}dispose(){this.isDisposed||(this._state={...n.DISPOSED_STATE,timestamp:(new Date).getTime()},this._tick.promise.catch((e=>{})),this._tick.reject(new Error(`Poll (${this.name}) is disposed.`)),this._disposed.emit(void 0),i.Signal.clearData(this))}refresh(){return this.schedule({cancel:({phase:e})=>"refreshed"===e,interval:s.IMMEDIATE,phase:"refreshed"})}async schedule(e={}){if(this.isDisposed)return;if(e.cancel&&e.cancel(this.state))return;const i=this._tick,n=new t.PromiseDelegate,a={interval:this.frequency.interval,payload:null,phase:"standby",timestamp:(new Date).getTime(),...e};if(this._state=a,this._tick=n,clearTimeout(this._timeout),this._ticked.emit(this.state),i.resolve(this),await i.promise,a.interval===s.NEVER)return void(this._timeout=void 0);this._timeout=setTimeout((()=>{this.isDisposed||this.tick!==n.promise||this._execute()}),a.interval)}start(){return this.schedule({cancel:({phase:e})=>"constructed"!==e&&"standby"!==e&&"stopped"!==e,interval:s.IMMEDIATE,phase:"started"})}stop(){return this.schedule({cancel:({phase:e})=>"stopped"===e,interval:s.NEVER,phase:"stopped"})}get hidden(){return n.hidden}_execute(){let e="function"==typeof this.standby?this.standby():this.standby;if("never"===e?e=!1:"when-hidden"===e&&(this.hidden?e=++this._lingered>this._linger:(this._lingered=0,e=!1)),e)return void this.schedule();const t=this.tick;this._factory(this.state).then((e=>{this.isDisposed||this.tick!==t||this.schedule({payload:e,phase:"rejected"===this.state.phase?"reconnected":"resolved"})})).catch((e=>{this.isDisposed||this.tick!==t||this.schedule({interval:n.sleep(this.frequency,this.state),payload:e,phase:"rejected"})}))}}var n;!function(e){e.IMMEDIATE=0,e.MAX_INTERVAL=2147483647,e.NEVER=1/0}(s||(s={})),function(e){e.DEFAULT_BACKOFF=3,e.DEFAULT_FREQUENCY={backoff:!0,interval:1e3,max:3e4},e.DEFAULT_LINGER=1,e.DEFAULT_NAME="unknown",e.DEFAULT_STANDBY="when-hidden",e.DEFAULT_STATE={interval:s.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},e.DISPOSED_STATE={interval:s.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()},e.sleep=function(t,i){const{backoff:n,interval:a,max:r}=t;if(a===s.NEVER)return a;const o=!0===n?e.DEFAULT_BACKOFF:!1===n?1:n,h=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}(a,i.interval*o);return Math.min(r,h)},e.hidden="undefined"!=typeof document&&(document.addEventListener("visibilitychange",(()=>{e.hidden="hidden"===document.visibilityState})),document.addEventListener("pagehide",(()=>{e.hidden="hidden"===document.visibilityState})),"hidden"===document.visibilityState)}(n||(n={}));class a{constructor(e,i=500){this.args=void 0,this.payload=null,this.limit=i,this.poll=new s({auto:!1,factory:async()=>{const{args:t}=this;return this.args=void 0,e(...t)},frequency:{backoff:!1,interval:s.NEVER,max:s.NEVER},standby:"never"}),this.payload=new t.PromiseDelegate,this.poll.ticked.connect(((e,i)=>{const{payload:s}=this;return"resolved"===i.phase?(this.payload=new t.PromiseDelegate,void s.resolve(i.payload)):"rejected"===i.phase||"stopped"===i.phase?(this.payload=new t.PromiseDelegate,s.promise.catch((e=>{})),void s.reject(i.payload)):void 0}),this)}get isDisposed(){return null===this.payload}dispose(){this.isDisposed||(this.args=void 0,this.payload=null,this.poll.dispose())}async stop(){return this.poll.stop()}}e.Debouncer=class extends a{invoke(...e){return this.args=e,this.poll.schedule({interval:this.limit,phase:"invoked"}),this.payload.promise}},e.Poll=s,e.RateLimiter=a,e.Throttler=class extends a{constructor(e,t){super(e,"number"==typeof t?t:t&&t.limit),this._trailing=!1,"number"!=typeof t&&t&&"trailing"===t.edge&&(this._trailing=!0),this._interval=this._trailing?this.limit:s.IMMEDIATE}invoke(...e){const t="invoked"!==this.poll.state.phase;return(t||this._trailing)&&(this.args=e),t&&this.poll.schedule({interval:this._interval,phase:"invoked"}),this.payload.promise}}})); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@lumino/polling", | ||
"version": "2.0.0-alpha.7", | ||
"version": "2.0.0-beta.0", | ||
"description": "Lumino Polling", | ||
@@ -47,10 +47,10 @@ "homepage": "https://github.com/jupyterlab/lumino", | ||
"dependencies": { | ||
"@lumino/coreutils": "^2.0.0-alpha.7", | ||
"@lumino/disposable": "^2.0.0-alpha.7", | ||
"@lumino/signaling": "^2.0.0-alpha.7" | ||
"@lumino/coreutils": "^2.0.0-beta.0", | ||
"@lumino/disposable": "^2.0.0-beta.0", | ||
"@lumino/signaling": "^2.0.0-beta.0" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.6.0", | ||
"@rollup/plugin-commonjs": "^22.0.2", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"@rollup/plugin-commonjs": "^24.0.0", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"@types/chai": "^3.4.35", | ||
@@ -67,6 +67,6 @@ "@types/mocha": "^2.2.39", | ||
"mocha": "^9.0.3", | ||
"playwright": "^1.26.0", | ||
"playwright": "^1.29.0", | ||
"postcss": "^8.4.14", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.77.3", | ||
"rollup": "^3.9.1", | ||
"rollup-plugin-postcss": "^4.0.2", | ||
@@ -76,3 +76,3 @@ "rollup-plugin-sourcemaps": "^0.6.3", | ||
"tslib": "^2.4.0", | ||
"typescript": "~4.7.3" | ||
"typescript": "~4.9.4" | ||
}, | ||
@@ -79,0 +79,0 @@ "publishConfig": { |
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
186018
2435