index.min.js.map 39 KB

1
  1. {"version":3,"sources":["../../../node_modules/tslib/tslib.es6.js","../src/poll.ts","../src/ratelimiter.ts"],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","this","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","apply","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","__generator","body","f","y","g","_","label","sent","trys","ops","verb","throw","return","Symbol","iterator","v","op","TypeError","pop","push","Poll","Private","defer","requestAnimationFrame","setImmediate","cancel","cancelAnimationFrame","clearImmediate","options","_this","_disposed","Signal","_tick","PromiseDelegate","_ticked","_timeout","_factory","factory","_standby","standby","DEFAULT_STANDBY","_state","DEFAULT_STATE","timestamp","Date","getTime","frequency","max","Math","interval","DEFAULT_FREQUENCY","name","DEFAULT_NAME","auto","start","defineProperty","_frequency","isDisposed","JSONExt","deepEqual","backoff","round","Error","NEVER","MAX_INTERVAL","state","phase","promise","dispose","DISPOSED_STATE","catch","emit","undefined","clearData","refresh","schedule","_a","IMMEDIATE","last","pending","scheduled","payload","clearTimeout","execute","tick","_execute","setTimeout","stop","document","hidden","resolved","sleep","Infinity","DEFAULT_BACKOFF","growth","random","min","ceil","floor","getRandomIntInclusive","RateLimiter","fn","limit","poll","ticked","connect","Debouncer","_super","invoke","Throttler","edge","_interval"],"mappings":";;;;;;;;;;;;;;oFAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOA,EAAEM,eAAeD,KAAIN,EAAEM,GAAKL,EAAEK,MACpDN,EAAGC,IAGrB,SAASO,EAAUR,EAAGC,GAEzB,SAASQ,IAAOC,KAAKC,YAAcX,EADnCD,EAAcC,EAAGC,GAEjBD,EAAEY,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F,QAAQ4E,EAAMgB,UAIL,aAAhBhB,EAAMC,OAAwC,YAAhBD,EAAMC,OACtCrC,EAAKoD,QAAU,IAAIhD,EAAAA,gBACnBgD,EAASd,QAAQG,OAAM,SAAAjE,YACvB4E,EAAS3F,OAAO2E,EAAMgB,eAHxB,IAMChH,MA+CP,OAzCER,OAAA8F,eAAI6C,EAAAjI,UAAA,aAAU,KAAd,WACE,OAAwB,OAAjBF,KAAKgH,yCAMdmB,EAAAjI,UAAAiG,QAAA,WACMnG,KAAKwF,aAGTxF,KAAKgH,QAAU,KACfhH,KAAKsI,KAAKnC,YAgBNgC,EAAAjI,UAAAoH,KAAN,8EACE,MAAA,CAAA,EAAOtH,KAAKsI,KAAKhB,eAYrBa,mBAUA,SAAAM,mDASA,OATiD3I,EAAA2I,EAAAC,GAK/CD,EAAAvI,UAAAyI,OAAA,WAEE,OADK3I,KAAKsI,KAAK5B,SAAS,CAAE1B,SAAUhF,KAAKqI,MAAOpC,MAAO,YAChDjG,KAAKgH,QAASd,SAEzBuC,GATiDN,2BA8B/C,SAAAS,EAAYR,EAA0BzE,GAAtC,IAAAC,EACE8E,EAAA9H,KAAAZ,KAAMoI,EAAuB,iBAAZzE,EAAuBA,EAAUA,GAAWA,EAAQ0E,QAAMrI,KACvE6I,EAA+B,gBACZ,iBAAZlF,IAETkF,EAAO,SADPlF,EAAUA,GAAW,IACMA,EAAQkF,KAAQA,GAE7CjF,EAAKkF,UAAqB,aAATD,EAAsBjF,EAAKyE,MAAQlF,EAAAA,KAAKyD,YAc7D,OAhCiD9G,EAAA8I,EAAAF,GAwB/CE,EAAA1I,UAAAyI,OAAA,WAIE,MAH8B,YAA1B3I,KAAKsI,KAAKtC,MAAMC,OACbjG,KAAKsI,KAAK5B,SAAS,CAAE1B,SAAUhF,KAAK8I,UAAW7C,MAAO,YAEtDjG,KAAKgH,QAASd,SAIzB0C,GAhCiDT,GAqChCS,EAAAA,YAAAA,EAAAA,UAAS","sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport { JSONExt, PromiseDelegate } from '@lumino/coreutils';\n\nimport { IObservableDisposable } from '@lumino/disposable';\n\nimport { ISignal, Signal } from '@lumino/signaling';\n\nimport { IPoll } from './index';\n\n/**\n * A function to defer an action immediately.\n */\nconst defer =\n typeof requestAnimationFrame === 'function'\n ? requestAnimationFrame\n : setImmediate;\n\n/**\n * A function to cancel a deferred action.\n */\nconst cancel: (timeout: any) => void =\n typeof cancelAnimationFrame === 'function'\n ? cancelAnimationFrame\n : clearImmediate;\n\n/**\n * A class that wraps an asynchronous function to poll at a regular interval\n * with exponential increases to the interval length if the poll fails.\n *\n * @typeparam T - The resolved type of the factory's promises.\n * Defaults to `any`.\n *\n * @typeparam U - The rejected type of the factory's promises.\n * Defaults to `any`.\n *\n * @typeparam V - An optional type to extend the phases supported by a poll.\n * Defaults to `standby`, which already exists in the `Phase` type.\n */\nexport class Poll<T = any, U = any, V extends string = 'standby'>\n implements IObservableDisposable, IPoll<T, U, V> {\n /**\n * Instantiate a new poll with exponential backoff in case of failure.\n *\n * @param options - The poll instantiation options.\n */\n constructor(options: Poll.IOptions<T, U, V>) {\n this._factory = options.factory;\n this._standby = options.standby || Private.DEFAULT_STANDBY;\n this._state = { ...Private.DEFAULT_STATE, timestamp: new Date().getTime() };\n\n // Normalize poll frequency `max` to be the greater of\n // default `max`, `options.frequency.max`, or `options.frequency.interval`.\n const frequency = options.frequency || {};\n const max = Math.max(\n frequency.interval || 0,\n frequency.max || 0,\n Private.DEFAULT_FREQUENCY.max\n );\n this.frequency = { ...Private.DEFAULT_FREQUENCY, ...frequency, ...{ max } };\n\n this.name = options.name || Private.DEFAULT_NAME;\n\n if ('auto' in options ? options.auto : true) {\n defer(() => void this.start());\n }\n }\n\n /**\n * The name of the poll.\n */\n readonly name: string;\n\n /**\n * A signal emitted when the poll is disposed.\n */\n get disposed(): ISignal<this, void> {\n return this._disposed;\n }\n\n /**\n * The polling frequency parameters.\n */\n get frequency(): IPoll.Frequency {\n return this._frequency;\n }\n set frequency(frequency: IPoll.Frequency) {\n if (this.isDisposed || JSONExt.deepEqual(frequency, this.frequency || {})) {\n return;\n }\n\n let { backoff, interval, max } = frequency;\n\n interval = Math.round(interval);\n max = Math.round(max);\n\n if (typeof backoff === 'number' && backoff < 1) {\n throw new Error('Poll backoff growth factor must be at least 1');\n }\n\n if ((interval < 0 || interval > max) && interval !== Poll.NEVER) {\n throw new Error('Poll interval must be between 0 and max');\n }\n\n if (max > Poll.MAX_INTERVAL && max !== Poll.NEVER) {\n throw new Error(`Max interval must be less than ${Poll.MAX_INTERVAL}`);\n }\n\n this._frequency = { backoff, interval, max };\n }\n\n /**\n * Whether the poll is disposed.\n */\n get isDisposed(): boolean {\n return this.state.phase === 'disposed';\n }\n\n /**\n * Indicates when the poll switches to standby.\n */\n get standby(): Poll.Standby | (() => boolean | Poll.Standby) {\n return this._standby;\n }\n set standby(standby: Poll.Standby | (() => boolean | Poll.Standby)) {\n if (this.isDisposed || this.standby === standby) {\n return;\n }\n\n this._standby = standby;\n }\n\n /**\n * The poll state, which is the content of the current poll tick.\n */\n get state(): IPoll.State<T, U, V> {\n return this._state;\n }\n\n /**\n * A promise that resolves when the poll next ticks.\n */\n get tick(): Promise<this> {\n return this._tick.promise;\n }\n\n /**\n * A signal emitted when the poll ticks and fires off a new request.\n */\n get ticked(): ISignal<this, IPoll.State<T, U, V>> {\n return this._ticked;\n }\n\n /**\n * Dispose the poll.\n */\n dispose(): void {\n if (this.isDisposed) {\n return;\n }\n\n this._state = {\n ...Private.DISPOSED_STATE,\n timestamp: new Date().getTime()\n };\n this._tick.promise.catch(_ => undefined);\n this._tick.reject(new Error(`Poll (${this.name}) is disposed.`));\n this._disposed.emit(undefined);\n Signal.clearData(this);\n }\n\n /**\n * Refreshes the poll. Schedules `refreshed` tick if necessary.\n *\n * @returns A promise that resolves after tick is scheduled and never rejects.\n *\n * #### Notes\n * The returned promise resolves after the tick is scheduled, but before\n * the polling action is run. To wait until after the poll action executes,\n * await the `poll.tick` promise: `await poll.refresh(); await poll.tick;`\n */\n refresh(): Promise<void> {\n return this.schedule({\n cancel: ({ phase }) => phase === 'refreshed',\n interval: Poll.IMMEDIATE,\n phase: 'refreshed'\n });\n }\n\n /**\n * Schedule the next poll tick.\n *\n * @param next - The next poll state data to schedule. Defaults to standby.\n *\n * @param next.cancel - Cancels state transition if function returns `true`.\n *\n * @returns A promise that resolves when the next poll state is active.\n *\n * #### Notes\n * This method is not meant to be invoked by user code typically. It is public\n * to allow poll instances to be composed into classes that schedule ticks.\n */\n async schedule(\n next: Partial<\n IPoll.State<T, U, V> & { cancel: (last: IPoll.State<T, U, V>) => boolean }\n > = {}\n ): Promise<void> {\n if (this.isDisposed) {\n return;\n }\n\n // Check if the phase transition should be canceled.\n if (next.cancel && next.cancel(this.state)) {\n return;\n }\n\n // Update poll state.\n const last = this.state;\n const pending = this._tick;\n const scheduled = new PromiseDelegate<this>();\n const state = {\n interval: this.frequency.interval,\n payload: null,\n phase: 'standby',\n timestamp: new Date().getTime(),\n ...next\n } as IPoll.State<T, U, V>;\n this._state = state;\n this._tick = scheduled;\n\n // Clear the schedule if possible.\n if (last.interval === Poll.IMMEDIATE) {\n cancel(this._timeout);\n } else {\n clearTimeout(this._timeout);\n }\n\n // Emit ticked signal, resolve pending promise, and await its settlement.\n this._ticked.emit(this.state);\n pending.resolve(this);\n await pending.promise;\n\n // Schedule next execution and cache its timeout handle.\n const execute = () => {\n if (this.isDisposed || this.tick !== scheduled.promise) {\n return;\n }\n\n this._execute();\n };\n this._timeout =\n state.interval === Poll.IMMEDIATE\n ? defer(execute)\n : state.interval === Poll.NEVER\n ? -1\n : setTimeout(execute, state.interval);\n }\n\n /**\n * Starts the poll. Schedules `started` tick if necessary.\n *\n * @returns A promise that resolves after tick is scheduled and never rejects.\n */\n start(): Promise<void> {\n return this.schedule({\n cancel: ({ phase }) =>\n phase !== 'constructed' && phase !== 'standby' && phase !== 'stopped',\n interval: Poll.IMMEDIATE,\n phase: 'started'\n });\n }\n\n /**\n * Stops the poll. Schedules `stopped` tick if necessary.\n *\n * @returns A promise that resolves after tick is scheduled and never rejects.\n */\n stop(): Promise<void> {\n return this.schedule({\n cancel: ({ phase }) => phase === 'stopped',\n interval: Poll.NEVER,\n phase: 'stopped'\n });\n }\n\n /**\n * Execute a new poll factory promise or stand by if necessary.\n */\n private _execute(): void {\n let standby =\n typeof this.standby === 'function' ? this.standby() : this.standby;\n standby =\n standby === 'never'\n ? false\n : standby === 'when-hidden'\n ? !!(typeof document !== 'undefined' && document && document.hidden)\n : standby;\n\n // If in standby mode schedule next tick without calling the factory.\n if (standby) {\n void this.schedule();\n return;\n }\n\n const pending = this.tick;\n\n this._factory(this.state)\n .then((resolved: T) => {\n if (this.isDisposed || this.tick !== pending) {\n return;\n }\n\n void this.schedule({\n payload: resolved,\n phase: this.state.phase === 'rejected' ? 'reconnected' : 'resolved'\n });\n })\n .catch((rejected: U) => {\n if (this.isDisposed || this.tick !== pending) {\n return;\n }\n\n void this.schedule({\n interval: Private.sleep(this.frequency, this.state),\n payload: rejected,\n phase: 'rejected'\n });\n });\n }\n\n private _disposed = new Signal<this, void>(this);\n private _factory: Poll.Factory<T, U, V>;\n private _frequency: IPoll.Frequency;\n private _standby: Poll.Standby | (() => boolean | Poll.Standby);\n private _state: IPoll.State<T, U, V>;\n private _tick = new PromiseDelegate<this>();\n private _ticked = new Signal<this, IPoll.State<T, U, V>>(this);\n private _timeout: any = -1;\n}\n\n/**\n * A namespace for `Poll` types, interfaces, and statics.\n */\nexport namespace Poll {\n /**\n * A promise factory that returns an individual poll request.\n *\n * @typeparam T - The resolved type of the factory's promises.\n *\n * @typeparam U - The rejected type of the factory's promises.\n *\n * @typeparam V - The type to extend the phases supported by a poll.\n */\n export type Factory<T, U, V extends string> = (\n state: IPoll.State<T, U, V>\n ) => Promise<T>;\n\n /**\n * Indicates when the poll switches to standby.\n */\n export type Standby = 'never' | 'when-hidden';\n\n /**\n * Instantiation options for polls.\n *\n * @typeparam T - The resolved type of the factory's promises.\n *\n * @typeparam U - The rejected type of the factory's promises.\n *\n * @typeparam V - The type to extend the phases supported by a poll.\n */\n export interface IOptions<T, U, V extends string> {\n /**\n * Whether to begin polling automatically; defaults to `true`.\n */\n auto?: boolean;\n\n /**\n * A factory function that is passed a poll tick and returns a poll promise.\n */\n factory: Factory<T, U, V>;\n\n /**\n * The polling frequency parameters.\n */\n frequency?: Partial<IPoll.Frequency>;\n\n /**\n * The name of the poll.\n * Defaults to `'unknown'`.\n */\n name?: string;\n\n /**\n * Indicates when the poll switches to standby or a function that returns\n * a boolean or a `Poll.Standby` value to indicate whether to stand by.\n * Defaults to `'when-hidden'`.\n *\n * #### Notes\n * If a function is passed in, for any given context, it should be\n * idempotent and safe to call multiple times. It will be called before each\n * tick execution, but may be called by clients as well.\n */\n standby?: Standby | (() => boolean | Standby);\n }\n /**\n * An interval value that indicates the poll should tick immediately.\n */\n export const IMMEDIATE = 0;\n\n /**\n * Delays are 32-bit integers in many browsers so intervals need to be capped.\n *\n * #### Notes\n * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value\n */\n export const MAX_INTERVAL = 2147483647;\n\n /**\n * An interval value that indicates the poll should never tick.\n */\n export const NEVER = Infinity;\n}\n\n/**\n * A namespace for private module data.\n */\nnamespace Private {\n /**\n * The default backoff growth rate if `backoff` is `true`.\n */\n export const DEFAULT_BACKOFF = 3;\n\n /**\n * The default polling frequency.\n */\n export const DEFAULT_FREQUENCY: IPoll.Frequency = {\n backoff: true,\n interval: 1000,\n max: 30 * 1000\n };\n\n /**\n * The default poll name.\n */\n export const DEFAULT_NAME = 'unknown';\n\n /**\n * The default poll standby behavior.\n */\n export const DEFAULT_STANDBY: Poll.Standby = 'when-hidden';\n\n /**\n * The first poll tick state's default values superseded in constructor.\n */\n export const DEFAULT_STATE: IPoll.State<any, any, any> = {\n interval: Poll.NEVER,\n payload: null,\n phase: 'constructed',\n timestamp: new Date(0).getTime()\n };\n\n /**\n * The disposed tick state values.\n */\n export const DISPOSED_STATE: IPoll.State<any, any, any> = {\n interval: Poll.NEVER,\n payload: null,\n phase: 'disposed',\n timestamp: new Date(0).getTime()\n };\n\n /**\n * Get a random integer between min and max, inclusive of both.\n *\n * #### Notes\n * From\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#Getting_a_random_integer_between_two_values_inclusive\n *\n * From the MDN page: It might be tempting to use Math.round() to accomplish\n * that, but doing so would cause your random numbers to follow a non-uniform\n * distribution, which may not be acceptable for your needs.\n */\n function getRandomIntInclusive(min: number, max: number) {\n min = Math.ceil(min);\n max = Math.floor(max);\n return Math.floor(Math.random() * (max - min + 1)) + min;\n }\n\n /**\n * Returns the number of milliseconds to sleep before the next tick.\n *\n * @param frequency - The poll's base frequency.\n * @param last - The poll's last tick.\n */\n export function sleep(\n frequency: IPoll.Frequency,\n last: IPoll.State<any, any, any>\n ): number {\n const { backoff, interval, max } = frequency;\n\n if (interval === Poll.NEVER) {\n return interval;\n }\n\n const growth =\n backoff === true ? DEFAULT_BACKOFF : backoff === false ? 1 : backoff;\n const random = getRandomIntInclusive(interval, last.interval * growth);\n\n return Math.min(max, random);\n }\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport { PromiseDelegate } from '@lumino/coreutils';\n\nimport { IRateLimiter } from './index';\n\nimport { Poll } from './poll';\n\n/**\n * A base class to implement rate limiters with different invocation strategies.\n *\n * @typeparam T - The resolved type of the underlying function.\n *\n * @typeparam U - The rejected type of the underlying function.\n */\nexport abstract class RateLimiter<T, U> implements IRateLimiter<T, U> {\n /**\n * Instantiate a rate limiter.\n *\n * @param fn - The function to rate limit.\n *\n * @param limit - The rate limit; defaults to 500ms.\n */\n constructor(fn: () => T | Promise<T>, limit = 500) {\n this.limit = limit;\n this.poll = new Poll({\n auto: false,\n factory: async () => await fn(),\n frequency: { backoff: false, interval: Poll.NEVER, max: Poll.NEVER },\n standby: 'never'\n });\n this.payload = new PromiseDelegate();\n this.poll.ticked.connect((_, state) => {\n const { payload } = this;\n\n if (state.phase === 'resolved') {\n this.payload = new PromiseDelegate();\n payload!.resolve(state.payload as T);\n return;\n }\n\n if (state.phase === 'rejected' || state.phase === 'stopped') {\n this.payload = new PromiseDelegate();\n payload!.promise.catch(_ => undefined);\n payload!.reject(state.payload as U);\n return;\n }\n }, this);\n }\n\n /**\n * Whether the rate limiter is disposed.\n */\n get isDisposed(): boolean {\n return this.payload === null;\n }\n\n /**\n * Disposes the rate limiter.\n */\n dispose(): void {\n if (this.isDisposed) {\n return;\n }\n this.payload = null;\n this.poll.dispose();\n }\n\n /**\n * The rate limit in milliseconds.\n */\n readonly limit: number;\n\n /**\n * Invoke the rate limited function.\n */\n abstract invoke(): Promise<T>;\n\n /**\n * Stop the function if it is mid-flight.\n */\n async stop(): Promise<void> {\n return this.poll.stop();\n }\n\n /**\n * A promise that resolves on each successful invocation.\n */\n protected payload: PromiseDelegate<T> | null = null;\n\n /**\n * The underlying poll instance used by the rate limiter.\n */\n protected poll: Poll<T, U, 'invoked'>;\n}\n\n/**\n * Wraps and debounces a function that can be called multiple times and only\n * executes the underlying function one `interval` after the last invocation.\n *\n * @typeparam T - The resolved type of the underlying function. Defaults to any.\n *\n * @typeparam U - The rejected type of the underlying function. Defaults to any.\n */\nexport class Debouncer<T = any, U = any> extends RateLimiter<T, U> {\n /**\n * Invokes the function and only executes after rate limit has elapsed.\n * Each invocation resets the timer.\n */\n invoke(): Promise<T> {\n void this.poll.schedule({ interval: this.limit, phase: 'invoked' });\n return this.payload!.promise;\n }\n}\n\n/**\n * Wraps and throttles a function that can be called multiple times and only\n * executes the underlying function once per `interval`.\n *\n * @typeparam T - The resolved type of the underlying function. Defaults to any.\n *\n * @typeparam U - The rejected type of the underlying function. Defaults to any.\n */\nexport class Throttler<T = any, U = any> extends RateLimiter<T, U> {\n /**\n * Instantiate a throttler.\n *\n * @param fn - The function being throttled.\n *\n * @param options - Throttling configuration or throttling limit in ms.\n *\n * #### Notes\n * The `edge` defaults to `leading`; the `limit` defaults to `500`.\n */\n constructor(fn: () => T | Promise<T>, options?: Throttler.IOptions | number) {\n super(fn, typeof options === 'number' ? options : options && options.limit);\n let edge: 'leading' | 'trailing' = 'leading';\n if (typeof options !== 'number') {\n options = options || {};\n edge = 'edge' in options ? options.edge! : edge;\n }\n this._interval = edge === 'trailing' ? this.limit : Poll.IMMEDIATE;\n }\n\n /**\n * Throttles function invocations if one is currently in flight.\n */\n invoke(): Promise<T> {\n if (this.poll.state.phase !== 'invoked') {\n void this.poll.schedule({ interval: this._interval, phase: 'invoked' });\n }\n return this.payload!.promise;\n }\n\n private _interval: number;\n}\n\n/**\n * A namespace for `Throttler` interfaces.\n */\nexport namespace Throttler {\n /**\n * Instantiation options for a `Throttler`.\n */\n export interface IOptions {\n /**\n * The throttling limit; defaults to 500ms.\n */\n limit?: number;\n\n /**\n * Whether to invoke at the leading or trailing edge of throttle cycle.\n * Defaults to `leading`.\n */\n edge?: 'leading' | 'trailing';\n };\n}\n"]}