@monterosa/sdk-util 2.0.0-rc.2 → 2.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1185 -0
- package/dist/index.cjs.map +1 -0
- package/package.json +5 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* @monterosa/sdk-util
|
|
8
|
+
*
|
|
9
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
10
|
+
*
|
|
11
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*
|
|
16
|
+
* Event emitter. Provides subscribe/unsubscribe pattern used throughout
|
|
17
|
+
* the SDK for observable state changes.
|
|
18
|
+
*/
|
|
19
|
+
class Emitter {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.listeners = new Map();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Subscribes to an event.
|
|
25
|
+
*
|
|
26
|
+
* @param event - The event name
|
|
27
|
+
* @param handler - The callback function
|
|
28
|
+
* @returns A function that unsubscribes the handler when called
|
|
29
|
+
*/
|
|
30
|
+
on(event, handler) {
|
|
31
|
+
if (!this.listeners.has(event)) {
|
|
32
|
+
this.listeners.set(event, new Set());
|
|
33
|
+
}
|
|
34
|
+
this.listeners.get(event).add(handler);
|
|
35
|
+
return () => this.off(event, handler);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Unsubscribes from an event.
|
|
39
|
+
*
|
|
40
|
+
* @param event - The event name
|
|
41
|
+
* @param handler - The handler to remove. If omitted, all handlers for the event are removed.
|
|
42
|
+
*/
|
|
43
|
+
off(event, handler) {
|
|
44
|
+
var _a;
|
|
45
|
+
if (handler === undefined) {
|
|
46
|
+
this.listeners.delete(event);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
(_a = this.listeners.get(event)) === null || _a === void 0 ? void 0 : _a.delete(handler);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Emits an event with optional arguments.
|
|
53
|
+
*
|
|
54
|
+
* @param event - The event name
|
|
55
|
+
* @param args - Arguments to pass to handlers
|
|
56
|
+
*/
|
|
57
|
+
emit(event, ...args) {
|
|
58
|
+
var _a;
|
|
59
|
+
(_a = this.listeners.get(event)) === null || _a === void 0 ? void 0 : _a.forEach((handler) => handler(...args));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Subscribes to an event and automatically unsubscribes after the first call.
|
|
63
|
+
*
|
|
64
|
+
* @param event - The event name
|
|
65
|
+
* @param handler - The callback function
|
|
66
|
+
* @returns A function that unsubscribes the handler when called
|
|
67
|
+
*/
|
|
68
|
+
once(event, handler) {
|
|
69
|
+
const wrapper = (...args) => {
|
|
70
|
+
handler(...args);
|
|
71
|
+
this.off(event, wrapper);
|
|
72
|
+
};
|
|
73
|
+
return this.on(event, wrapper);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
const subscribe = (emitter, event, callback) => {
|
|
80
|
+
emitter.on(event, callback);
|
|
81
|
+
return () => emitter.off(event, callback);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @license
|
|
86
|
+
* @monterosa/sdk-util
|
|
87
|
+
*
|
|
88
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
89
|
+
*
|
|
90
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*
|
|
95
|
+
* Delays the execution of the code for a given number of milliseconds.
|
|
96
|
+
*
|
|
97
|
+
* @param timeout - The timeout in milliseconds.
|
|
98
|
+
*
|
|
99
|
+
* @returns A promise that resolves after the timeout.
|
|
100
|
+
*/
|
|
101
|
+
const delay = async (timeout) => {
|
|
102
|
+
await new Promise((resolve) => setTimeout(resolve, timeout));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @license
|
|
107
|
+
* @monterosa/sdk-util
|
|
108
|
+
*
|
|
109
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
110
|
+
*
|
|
111
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* Creates a function that memoizes the result of `func`.
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
117
|
+
*
|
|
118
|
+
* @param func - A function that returns a promise. The results of its work will be memoized.
|
|
119
|
+
* @param resolver - A function that determines the cache key.
|
|
120
|
+
* @param config - A configuration object with the following optional properties:
|
|
121
|
+
* `clearOnResolve` - Deletes memoized result upon promise resolve. Defaults to `false`.
|
|
122
|
+
* `clearOnReject` - Deletes memoized result upon promise reject. Defaults to `true`.
|
|
123
|
+
*/
|
|
124
|
+
const memoizePromise = (func, resolver, config = {}) => {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
const clearOnResolve = (_a = config.clearOnResolve) !== null && _a !== void 0 ? _a : false;
|
|
127
|
+
const clearOnReject = (_b = config.clearOnReject) !== null && _b !== void 0 ? _b : true;
|
|
128
|
+
const cache = new Map();
|
|
129
|
+
const memoized = (...args) => {
|
|
130
|
+
const key = resolver(...args);
|
|
131
|
+
if (cache.has(key)) {
|
|
132
|
+
return cache.get(key);
|
|
133
|
+
}
|
|
134
|
+
const promise = func(...args);
|
|
135
|
+
cache.set(key, promise);
|
|
136
|
+
promise
|
|
137
|
+
.then(() => clearOnResolve && cache.delete(key))
|
|
138
|
+
.catch(() => clearOnReject && cache.delete(key));
|
|
139
|
+
return promise;
|
|
140
|
+
};
|
|
141
|
+
memoized.cache = cache;
|
|
142
|
+
return memoized;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @license
|
|
147
|
+
* @monterosa/sdk-util
|
|
148
|
+
*
|
|
149
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
150
|
+
*
|
|
151
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
152
|
+
*/
|
|
153
|
+
/* eslint no-restricted-globals: "off" */
|
|
154
|
+
/**
|
|
155
|
+
* @preserve
|
|
156
|
+
* Global object polyfill.
|
|
157
|
+
* Based on MDN article: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
*
|
|
161
|
+
* @returns typeof globalThis
|
|
162
|
+
*/
|
|
163
|
+
function getGlobal() {
|
|
164
|
+
if (typeof self !== 'undefined') {
|
|
165
|
+
return self;
|
|
166
|
+
}
|
|
167
|
+
if (typeof globalThis !== 'undefined') {
|
|
168
|
+
return globalThis;
|
|
169
|
+
}
|
|
170
|
+
if (typeof window !== 'undefined') {
|
|
171
|
+
return window;
|
|
172
|
+
}
|
|
173
|
+
if (typeof global !== 'undefined') {
|
|
174
|
+
return global;
|
|
175
|
+
}
|
|
176
|
+
throw new Error('Unable to locate global object.');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @license
|
|
181
|
+
* @monterosa/sdk-util
|
|
182
|
+
*
|
|
183
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
184
|
+
*
|
|
185
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
186
|
+
*/
|
|
187
|
+
const PREFIX = 'monterosa_sdk_';
|
|
188
|
+
const BAIT = 'bait';
|
|
189
|
+
const globals = getGlobal();
|
|
190
|
+
/**
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
const getKey = (name) => `${PREFIX}${name}`;
|
|
194
|
+
/**
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
197
|
+
function getItem(key) {
|
|
198
|
+
return globals.localStorage.getItem(getKey(key));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
function setItem(key, value) {
|
|
204
|
+
return globals.localStorage.setItem(getKey(key), value);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
function removeItem(key) {
|
|
210
|
+
return globals.localStorage.removeItem(getKey(key));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
function clear() {
|
|
216
|
+
return globals.localStorage.clear();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Checks locastorage availability.
|
|
220
|
+
* Based on MDN article: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
|
|
221
|
+
* and Paul Irish gists: https://gist.github.com/paulirish/5558557
|
|
222
|
+
*
|
|
223
|
+
* @internal
|
|
224
|
+
*
|
|
225
|
+
* @returns boolean
|
|
226
|
+
*/
|
|
227
|
+
function checkAvailability() {
|
|
228
|
+
try {
|
|
229
|
+
setItem(BAIT, BAIT);
|
|
230
|
+
getItem(BAIT);
|
|
231
|
+
removeItem(BAIT);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
catch (e) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* @license
|
|
241
|
+
* @monterosa/sdk-util
|
|
242
|
+
*
|
|
243
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
244
|
+
*
|
|
245
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
246
|
+
*/
|
|
247
|
+
/* eslint max-classes-per-file: ["error", 2] */
|
|
248
|
+
/**
|
|
249
|
+
* MonterosaError extends the standard JavaScript `Error` object. It has
|
|
250
|
+
* an error code so that users can identify the error. It also has its
|
|
251
|
+
* own specific `name` "MonterosaError".
|
|
252
|
+
*/
|
|
253
|
+
class MonterosaError extends Error {
|
|
254
|
+
/**
|
|
255
|
+
* @param code - Error code string
|
|
256
|
+
* @param message - A descriptive message for the error
|
|
257
|
+
*/
|
|
258
|
+
constructor(code, message) {
|
|
259
|
+
super(message);
|
|
260
|
+
/**
|
|
261
|
+
* The name property represents a name for the type of error.
|
|
262
|
+
*/
|
|
263
|
+
this.name = 'MonterosaError';
|
|
264
|
+
this.code = code;
|
|
265
|
+
// Fix For ES5
|
|
266
|
+
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
267
|
+
Object.setPrototypeOf(this, MonterosaError.prototype);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* @internal
|
|
272
|
+
*/
|
|
273
|
+
function createError(code, messages, ...params) {
|
|
274
|
+
const message = messages[code](...params);
|
|
275
|
+
return new MonterosaError(code, message);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* @internal
|
|
279
|
+
*/
|
|
280
|
+
function getErrorMessage(err) {
|
|
281
|
+
if (err instanceof Error) {
|
|
282
|
+
return err.message;
|
|
283
|
+
}
|
|
284
|
+
if (typeof err === 'string') {
|
|
285
|
+
return err;
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
return JSON.stringify(err);
|
|
289
|
+
}
|
|
290
|
+
catch (_a) {
|
|
291
|
+
return 'Unknown error';
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @license
|
|
297
|
+
* @monterosa/sdk-util
|
|
298
|
+
*
|
|
299
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
300
|
+
*
|
|
301
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
302
|
+
*/
|
|
303
|
+
/* eslint-disable */
|
|
304
|
+
// @ts-nocheck
|
|
305
|
+
/**
|
|
306
|
+
* @copyright
|
|
307
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
308
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
309
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
310
|
+
* Released under MIT license <https://lodash.com/license>
|
|
311
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
312
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
313
|
+
*/
|
|
314
|
+
/** Used as the `TypeError` message for "Functions" methods. */
|
|
315
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
316
|
+
/** Used as references for various `Number` constants. */
|
|
317
|
+
var NAN = 0 / 0;
|
|
318
|
+
/** `Object#toString` result references. */
|
|
319
|
+
var symbolTag = '[object Symbol]';
|
|
320
|
+
/** Used to match leading and trailing whitespace. */
|
|
321
|
+
var reTrim = /^\s+|\s+$/g;
|
|
322
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
323
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
324
|
+
/** Used to detect binary string values. */
|
|
325
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
326
|
+
/** Used to detect octal string values. */
|
|
327
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
328
|
+
/** Built-in method references without a dependency on `root`. */
|
|
329
|
+
var freeParseInt = parseInt;
|
|
330
|
+
/** Detect free variable `global` from Node.js. */
|
|
331
|
+
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
332
|
+
/** Detect free variable `self`. */
|
|
333
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
334
|
+
/** Used as a reference to the global object. */
|
|
335
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
336
|
+
/** Used for built-in method references. */
|
|
337
|
+
var objectProto = Object.prototype;
|
|
338
|
+
/**
|
|
339
|
+
* Used to resolve the
|
|
340
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
341
|
+
* of values.
|
|
342
|
+
*/
|
|
343
|
+
var objectToString = objectProto.toString;
|
|
344
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
345
|
+
var nativeMax = Math.max, nativeMin = Math.min;
|
|
346
|
+
/**
|
|
347
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
348
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
349
|
+
*
|
|
350
|
+
* @static
|
|
351
|
+
* @memberOf _
|
|
352
|
+
* @since 2.4.0
|
|
353
|
+
* @category Date
|
|
354
|
+
* @returns {number} Returns the timestamp.
|
|
355
|
+
* @example
|
|
356
|
+
*
|
|
357
|
+
* _.defer(function(stamp) {
|
|
358
|
+
* console.log(_.now() - stamp);
|
|
359
|
+
* }, _.now());
|
|
360
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
361
|
+
*/
|
|
362
|
+
var now$1 = function () {
|
|
363
|
+
return root.Date.now();
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
367
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
368
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
369
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
370
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
371
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
372
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
373
|
+
* calls to the debounced function return the result of the last `func`
|
|
374
|
+
* invocation.
|
|
375
|
+
*
|
|
376
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
377
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
378
|
+
* is invoked more than once during the `wait` timeout.
|
|
379
|
+
*
|
|
380
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
381
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
382
|
+
*
|
|
383
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
384
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
385
|
+
*
|
|
386
|
+
* @static
|
|
387
|
+
* @memberOf _
|
|
388
|
+
* @since 0.1.0
|
|
389
|
+
* @category Function
|
|
390
|
+
* @param {Function} func The function to debounce.
|
|
391
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
392
|
+
* @param {Object} [options={}] The options object.
|
|
393
|
+
* @param {boolean} [options.leading=false]
|
|
394
|
+
* Specify invoking on the leading edge of the timeout.
|
|
395
|
+
* @param {number} [options.maxWait]
|
|
396
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
397
|
+
* @param {boolean} [options.trailing=true]
|
|
398
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
399
|
+
* @returns {Function} Returns the new debounced function.
|
|
400
|
+
* @example
|
|
401
|
+
*
|
|
402
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
403
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
404
|
+
*
|
|
405
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
406
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
407
|
+
* 'leading': true,
|
|
408
|
+
* 'trailing': false
|
|
409
|
+
* }));
|
|
410
|
+
*
|
|
411
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
412
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
413
|
+
* var source = new EventSource('/stream');
|
|
414
|
+
* jQuery(source).on('message', debounced);
|
|
415
|
+
*
|
|
416
|
+
* // Cancel the trailing debounced invocation.
|
|
417
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
418
|
+
*/
|
|
419
|
+
function debounce(func, wait, options) {
|
|
420
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
421
|
+
if (typeof func != 'function') {
|
|
422
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
423
|
+
}
|
|
424
|
+
wait = toNumber(wait) || 0;
|
|
425
|
+
if (isObject(options)) {
|
|
426
|
+
leading = !!options.leading;
|
|
427
|
+
maxing = 'maxWait' in options;
|
|
428
|
+
maxWait = maxing
|
|
429
|
+
? nativeMax(toNumber(options.maxWait) || 0, wait)
|
|
430
|
+
: maxWait;
|
|
431
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
432
|
+
}
|
|
433
|
+
function invokeFunc(time) {
|
|
434
|
+
var args = lastArgs, thisArg = lastThis;
|
|
435
|
+
lastArgs = lastThis = undefined;
|
|
436
|
+
lastInvokeTime = time;
|
|
437
|
+
result = func.apply(thisArg, args);
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
function leadingEdge(time) {
|
|
441
|
+
// Reset any `maxWait` timer.
|
|
442
|
+
lastInvokeTime = time;
|
|
443
|
+
// Start the timer for the trailing edge.
|
|
444
|
+
timerId = setTimeout(timerExpired, wait);
|
|
445
|
+
// Invoke the leading edge.
|
|
446
|
+
return leading ? invokeFunc(time) : result;
|
|
447
|
+
}
|
|
448
|
+
function remainingWait(time) {
|
|
449
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result = wait - timeSinceLastCall;
|
|
450
|
+
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
|
451
|
+
}
|
|
452
|
+
function shouldInvoke(time) {
|
|
453
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
|
454
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
455
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
456
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
457
|
+
return (lastCallTime === undefined ||
|
|
458
|
+
timeSinceLastCall >= wait ||
|
|
459
|
+
timeSinceLastCall < 0 ||
|
|
460
|
+
(maxing && timeSinceLastInvoke >= maxWait));
|
|
461
|
+
}
|
|
462
|
+
function timerExpired() {
|
|
463
|
+
var time = now$1();
|
|
464
|
+
if (shouldInvoke(time)) {
|
|
465
|
+
return trailingEdge(time);
|
|
466
|
+
}
|
|
467
|
+
// Restart the timer.
|
|
468
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
469
|
+
}
|
|
470
|
+
function trailingEdge(time) {
|
|
471
|
+
timerId = undefined;
|
|
472
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
473
|
+
// debounced at least once.
|
|
474
|
+
if (trailing && lastArgs) {
|
|
475
|
+
return invokeFunc(time);
|
|
476
|
+
}
|
|
477
|
+
lastArgs = lastThis = undefined;
|
|
478
|
+
return result;
|
|
479
|
+
}
|
|
480
|
+
function cancel() {
|
|
481
|
+
if (timerId !== undefined) {
|
|
482
|
+
clearTimeout(timerId);
|
|
483
|
+
}
|
|
484
|
+
lastInvokeTime = 0;
|
|
485
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
486
|
+
}
|
|
487
|
+
function flush() {
|
|
488
|
+
return timerId === undefined ? result : trailingEdge(now$1());
|
|
489
|
+
}
|
|
490
|
+
function debounced() {
|
|
491
|
+
var time = now$1(), isInvoking = shouldInvoke(time);
|
|
492
|
+
lastArgs = arguments;
|
|
493
|
+
lastThis = this;
|
|
494
|
+
lastCallTime = time;
|
|
495
|
+
if (isInvoking) {
|
|
496
|
+
if (timerId === undefined) {
|
|
497
|
+
return leadingEdge(lastCallTime);
|
|
498
|
+
}
|
|
499
|
+
if (maxing) {
|
|
500
|
+
// Handle invocations in a tight loop.
|
|
501
|
+
timerId = setTimeout(timerExpired, wait);
|
|
502
|
+
return invokeFunc(lastCallTime);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (timerId === undefined) {
|
|
506
|
+
timerId = setTimeout(timerExpired, wait);
|
|
507
|
+
}
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
debounced.cancel = cancel;
|
|
511
|
+
debounced.flush = flush;
|
|
512
|
+
return debounced;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Creates a throttled function that only invokes `func` at most once per
|
|
516
|
+
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
517
|
+
* method to cancel delayed `func` invocations and a `flush` method to
|
|
518
|
+
* immediately invoke them. Provide `options` to indicate whether `func`
|
|
519
|
+
* should be invoked on the leading and/or trailing edge of the `wait`
|
|
520
|
+
* timeout. The `func` is invoked with the last arguments provided to the
|
|
521
|
+
* throttled function. Subsequent calls to the throttled function return the
|
|
522
|
+
* result of the last `func` invocation.
|
|
523
|
+
*
|
|
524
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
525
|
+
* invoked on the trailing edge of the timeout only if the throttled function
|
|
526
|
+
* is invoked more than once during the `wait` timeout.
|
|
527
|
+
*
|
|
528
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
529
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
530
|
+
*
|
|
531
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
532
|
+
* for details over the differences between `_.throttle` and `_.debounce`.
|
|
533
|
+
*
|
|
534
|
+
* @internal
|
|
535
|
+
*
|
|
536
|
+
* @static
|
|
537
|
+
* @memberOf _
|
|
538
|
+
* @since 0.1.0
|
|
539
|
+
* @category Function
|
|
540
|
+
* @param {Function} func The function to throttle.
|
|
541
|
+
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
|
542
|
+
* @param {Object} [options={}] The options object.
|
|
543
|
+
* @param {boolean} [options.leading=true]
|
|
544
|
+
* Specify invoking on the leading edge of the timeout.
|
|
545
|
+
* @param {boolean} [options.trailing=true]
|
|
546
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
547
|
+
* @returns {Function} Returns the new throttled function.
|
|
548
|
+
* @example
|
|
549
|
+
*
|
|
550
|
+
* // Avoid excessively updating the position while scrolling.
|
|
551
|
+
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
|
552
|
+
*
|
|
553
|
+
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
554
|
+
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
|
|
555
|
+
* jQuery(element).on('click', throttled);
|
|
556
|
+
*
|
|
557
|
+
* // Cancel the trailing throttled invocation.
|
|
558
|
+
* jQuery(window).on('popstate', throttled.cancel);
|
|
559
|
+
*/
|
|
560
|
+
function throttle(func, wait, options) {
|
|
561
|
+
var leading = true, trailing = true;
|
|
562
|
+
if (typeof func != 'function') {
|
|
563
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
564
|
+
}
|
|
565
|
+
if (isObject(options)) {
|
|
566
|
+
leading = 'leading' in options ? !!options.leading : leading;
|
|
567
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
568
|
+
}
|
|
569
|
+
return debounce(func, wait, {
|
|
570
|
+
leading: leading,
|
|
571
|
+
maxWait: wait,
|
|
572
|
+
trailing: trailing,
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Checks if `value` is the
|
|
577
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
578
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
579
|
+
*
|
|
580
|
+
* @static
|
|
581
|
+
* @memberOf _
|
|
582
|
+
* @since 0.1.0
|
|
583
|
+
* @category Lang
|
|
584
|
+
* @param {*} value The value to check.
|
|
585
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
586
|
+
* @example
|
|
587
|
+
*
|
|
588
|
+
* _.isObject({});
|
|
589
|
+
* // => true
|
|
590
|
+
*
|
|
591
|
+
* _.isObject([1, 2, 3]);
|
|
592
|
+
* // => true
|
|
593
|
+
*
|
|
594
|
+
* _.isObject(_.noop);
|
|
595
|
+
* // => true
|
|
596
|
+
*
|
|
597
|
+
* _.isObject(null);
|
|
598
|
+
* // => false
|
|
599
|
+
*/
|
|
600
|
+
function isObject(value) {
|
|
601
|
+
var type = typeof value;
|
|
602
|
+
return !!value && (type == 'object' || type == 'function');
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
606
|
+
* and has a `typeof` result of "object".
|
|
607
|
+
*
|
|
608
|
+
* @static
|
|
609
|
+
* @memberOf _
|
|
610
|
+
* @since 4.0.0
|
|
611
|
+
* @category Lang
|
|
612
|
+
* @param {*} value The value to check.
|
|
613
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
614
|
+
* @example
|
|
615
|
+
*
|
|
616
|
+
* _.isObjectLike({});
|
|
617
|
+
* // => true
|
|
618
|
+
*
|
|
619
|
+
* _.isObjectLike([1, 2, 3]);
|
|
620
|
+
* // => true
|
|
621
|
+
*
|
|
622
|
+
* _.isObjectLike(_.noop);
|
|
623
|
+
* // => false
|
|
624
|
+
*
|
|
625
|
+
* _.isObjectLike(null);
|
|
626
|
+
* // => false
|
|
627
|
+
*/
|
|
628
|
+
function isObjectLike(value) {
|
|
629
|
+
return !!value && typeof value == 'object';
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
633
|
+
*
|
|
634
|
+
* @static
|
|
635
|
+
* @memberOf _
|
|
636
|
+
* @since 4.0.0
|
|
637
|
+
* @category Lang
|
|
638
|
+
* @param {*} value The value to check.
|
|
639
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
640
|
+
* @example
|
|
641
|
+
*
|
|
642
|
+
* _.isSymbol(Symbol.iterator);
|
|
643
|
+
* // => true
|
|
644
|
+
*
|
|
645
|
+
* _.isSymbol('abc');
|
|
646
|
+
* // => false
|
|
647
|
+
*/
|
|
648
|
+
function isSymbol(value) {
|
|
649
|
+
return (typeof value == 'symbol' ||
|
|
650
|
+
(isObjectLike(value) && objectToString.call(value) == symbolTag));
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Converts `value` to a number.
|
|
654
|
+
*
|
|
655
|
+
* @static
|
|
656
|
+
* @memberOf _
|
|
657
|
+
* @since 4.0.0
|
|
658
|
+
* @category Lang
|
|
659
|
+
* @param {*} value The value to process.
|
|
660
|
+
* @returns {number} Returns the number.
|
|
661
|
+
* @example
|
|
662
|
+
*
|
|
663
|
+
* _.toNumber(3.2);
|
|
664
|
+
* // => 3.2
|
|
665
|
+
*
|
|
666
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
667
|
+
* // => 5e-324
|
|
668
|
+
*
|
|
669
|
+
* _.toNumber(Infinity);
|
|
670
|
+
* // => Infinity
|
|
671
|
+
*
|
|
672
|
+
* _.toNumber('3.2');
|
|
673
|
+
* // => 3.2
|
|
674
|
+
*/
|
|
675
|
+
function toNumber(value) {
|
|
676
|
+
if (typeof value == 'number') {
|
|
677
|
+
return value;
|
|
678
|
+
}
|
|
679
|
+
if (isSymbol(value)) {
|
|
680
|
+
return NAN;
|
|
681
|
+
}
|
|
682
|
+
if (isObject(value)) {
|
|
683
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
684
|
+
value = isObject(other) ? other + '' : other;
|
|
685
|
+
}
|
|
686
|
+
if (typeof value != 'string') {
|
|
687
|
+
return value === 0 ? value : +value;
|
|
688
|
+
}
|
|
689
|
+
value = value.replace(reTrim, '');
|
|
690
|
+
var isBinary = reIsBinary.test(value);
|
|
691
|
+
return isBinary || reIsOctal.test(value)
|
|
692
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
693
|
+
: reIsBadHex.test(value)
|
|
694
|
+
? NAN
|
|
695
|
+
: +value;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* @license
|
|
700
|
+
* @monterosa/sdk-interact-kit
|
|
701
|
+
*
|
|
702
|
+
* Copyright © 2022 Monterosa Productions Limited. All rights reserved.
|
|
703
|
+
*
|
|
704
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
705
|
+
*/
|
|
706
|
+
const emitter = new Emitter();
|
|
707
|
+
let serverTimestamp = 0;
|
|
708
|
+
let lastTickTimestamp = 0;
|
|
709
|
+
let tickTimeoutId;
|
|
710
|
+
/**
|
|
711
|
+
* Returns local timestamp in seconds
|
|
712
|
+
*/
|
|
713
|
+
function getCurrentTimestamp() {
|
|
714
|
+
return Date.now() / 1000;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Normalizes the timestamp to reduce fluctuations due to `setTimeout` delays.
|
|
718
|
+
* Ensures the fractional part is around 0.5 to avoid skipping a second.
|
|
719
|
+
*
|
|
720
|
+
* Returns half-second timestamp. It is used to be sure that timestamp will not
|
|
721
|
+
* fluctuate more than in 1 second after each tick due to longer delays.
|
|
722
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#reasons_for_delays_longer_than_specified
|
|
723
|
+
*
|
|
724
|
+
* For example if the initial timestamp has a fractional part 0.9999 then with
|
|
725
|
+
* the setTimeout (tick) longer than specified we might jump over a one second.
|
|
726
|
+
* Lets imaging setTimeout took 1.0002 second, then our timestamp will be 2.0001.
|
|
727
|
+
* Thats why we are trying to keep fractional part in the middle of the second.
|
|
728
|
+
*/
|
|
729
|
+
function getMiddleTimestamp(timestamp) {
|
|
730
|
+
return Math.floor(timestamp) + 0.5;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Calculates the delay for the next tick to keep timestamps stable.
|
|
734
|
+
*/
|
|
735
|
+
function calculateNextTickDelay() {
|
|
736
|
+
const expectedNextTick = getMiddleTimestamp(serverTimestamp) + 1;
|
|
737
|
+
return (expectedNextTick - serverTimestamp) * 1000;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* @internal
|
|
741
|
+
*
|
|
742
|
+
* Main function that maintains current timestamp
|
|
743
|
+
*/
|
|
744
|
+
function tick() {
|
|
745
|
+
clearTimeout(tickTimeoutId);
|
|
746
|
+
const currentTimestamp = getCurrentTimestamp();
|
|
747
|
+
const timeSinceLastTick = currentTimestamp - lastTickTimestamp;
|
|
748
|
+
serverTimestamp += timeSinceLastTick;
|
|
749
|
+
lastTickTimestamp = currentTimestamp;
|
|
750
|
+
tickTimeoutId = setTimeout(tick, calculateNextTickDelay());
|
|
751
|
+
// In Node.js, a pending setTimeout keeps the process alive. This causes
|
|
752
|
+
// Jest worker processes to hang after tests complete, because tick()
|
|
753
|
+
// reschedules itself indefinitely. Calling unref() tells Node.js not to
|
|
754
|
+
// keep the process alive solely for this timer. In browsers, unref()
|
|
755
|
+
// does not exist and is not needed — tabs don't have this problem.
|
|
756
|
+
if (typeof tickTimeoutId === 'object' && 'unref' in tickTimeoutId) {
|
|
757
|
+
tickTimeoutId.unref();
|
|
758
|
+
}
|
|
759
|
+
emitter.emit('tick', serverTimestamp);
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* @internal
|
|
763
|
+
*
|
|
764
|
+
* Sets or updates current timestamp
|
|
765
|
+
*
|
|
766
|
+
* @param timestamp - Current timestamp in seconds
|
|
767
|
+
*/
|
|
768
|
+
function setTimestamp(timestamp) {
|
|
769
|
+
lastTickTimestamp = getCurrentTimestamp();
|
|
770
|
+
serverTimestamp = getMiddleTimestamp(timestamp);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Returns current timestamp that is preserved by `tick()` function
|
|
774
|
+
*
|
|
775
|
+
* @returns Current timestamp in seconds
|
|
776
|
+
*/
|
|
777
|
+
function now() {
|
|
778
|
+
return Math.floor(serverTimestamp);
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Subscribes listener to the timestamp increment
|
|
782
|
+
*
|
|
783
|
+
* @param callback - A handler that executes when the timestamp is incremented
|
|
784
|
+
*
|
|
785
|
+
* @returns A function that unsubscribes the listener
|
|
786
|
+
*/
|
|
787
|
+
function onTick(callback) {
|
|
788
|
+
return subscribe(emitter, 'tick', callback);
|
|
789
|
+
}
|
|
790
|
+
// Initially timestamp is set based on a local date
|
|
791
|
+
// Later on it can be overriden outside at any moment
|
|
792
|
+
// in our case it is populated with the server timestamp
|
|
793
|
+
// which comes from EnMasse session handshake message
|
|
794
|
+
setTimestamp(getCurrentTimestamp());
|
|
795
|
+
// Kicking in timestamp maintaining
|
|
796
|
+
tick();
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* @license
|
|
800
|
+
* fromentries.ts
|
|
801
|
+
* util
|
|
802
|
+
*
|
|
803
|
+
* Copyright © 2023 Monterosa Productions Limited. All rights reserved.
|
|
804
|
+
*
|
|
805
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
806
|
+
*/
|
|
807
|
+
/**
|
|
808
|
+
* @internal
|
|
809
|
+
*/
|
|
810
|
+
function fromEntries(entries) {
|
|
811
|
+
return entries.reduce((obj, [key, value]) => {
|
|
812
|
+
obj[key] = value;
|
|
813
|
+
return obj;
|
|
814
|
+
}, {});
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* @license
|
|
819
|
+
* @monterosa/sdk-util
|
|
820
|
+
*
|
|
821
|
+
* Copyright © 2025 Monterosa Productions Limited. All rights reserved.
|
|
822
|
+
*
|
|
823
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
824
|
+
*/
|
|
825
|
+
/**
|
|
826
|
+
* Calculate percentage of each value in the array.
|
|
827
|
+
*
|
|
828
|
+
* It uses Hamilton's method, also known as the method of largest remainder.
|
|
829
|
+
* It is a system used for distributing vote percentages among different
|
|
830
|
+
* options (like candidates or choices) based on their vote counts. It ensures
|
|
831
|
+
* that each option receives at least its lower quota of percentage points, and
|
|
832
|
+
* any remaining percentage points are allocated to those with the largest
|
|
833
|
+
* fractional remainders. This method is used in the US Electoral College.
|
|
834
|
+
*
|
|
835
|
+
* @param values - Array of number values to calculate percentage for
|
|
836
|
+
* @returns Array of percentages, where the sum of the array is 100%
|
|
837
|
+
*/
|
|
838
|
+
const calculatePercentage = (values) => {
|
|
839
|
+
// Calculate sum of all votes
|
|
840
|
+
const sum = values.reduce((memo, value) => memo + value, 0);
|
|
841
|
+
// create array of hashes
|
|
842
|
+
const results = values.map((value, idx) => {
|
|
843
|
+
const percentage = (100 * value) / sum || 0;
|
|
844
|
+
return {
|
|
845
|
+
idx,
|
|
846
|
+
votes: value,
|
|
847
|
+
percentage: Math.floor(percentage),
|
|
848
|
+
remainder: percentage % 1,
|
|
849
|
+
};
|
|
850
|
+
});
|
|
851
|
+
// Sum them all up - this can't be higher than 100%
|
|
852
|
+
let total = results.reduce((memo, { percentage }) => memo + percentage, 0);
|
|
853
|
+
total = total || 100;
|
|
854
|
+
// Calculate number of percent that we are missing
|
|
855
|
+
const delta = 100 - total;
|
|
856
|
+
// Order all options by remainder
|
|
857
|
+
results.sort((a, b) => {
|
|
858
|
+
if (a.remainder !== b.remainder) {
|
|
859
|
+
return b.remainder - a.remainder;
|
|
860
|
+
}
|
|
861
|
+
return a.idx - b.idx;
|
|
862
|
+
});
|
|
863
|
+
// Distribute delta to highest remainder options
|
|
864
|
+
for (let i = 0; i < delta; i++) {
|
|
865
|
+
results[i].percentage += 1;
|
|
866
|
+
}
|
|
867
|
+
// Restore options order
|
|
868
|
+
results.sort((a, b) => a.idx - b.idx);
|
|
869
|
+
return results.map((item) => item.percentage);
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* @license
|
|
874
|
+
* @monterosa/sdk-identify-kit
|
|
875
|
+
*
|
|
876
|
+
* Copyright © 2025 Monterosa Productions Limited. All rights reserved.
|
|
877
|
+
*
|
|
878
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
879
|
+
*/
|
|
880
|
+
/**
|
|
881
|
+
* @internal
|
|
882
|
+
*
|
|
883
|
+
* TaskQueue ensures that async tasks run sequentially (FIFO).
|
|
884
|
+
*
|
|
885
|
+
* Behavior:
|
|
886
|
+
* - Tasks run one at a time in the order they were enqueued.
|
|
887
|
+
* - If a task fails (throws/rejects), the queue is stopped
|
|
888
|
+
* and all pending tasks are cleared.
|
|
889
|
+
*/
|
|
890
|
+
class TaskQueue {
|
|
891
|
+
constructor() {
|
|
892
|
+
this.current = null;
|
|
893
|
+
this.queue = [];
|
|
894
|
+
this.paused = false;
|
|
895
|
+
}
|
|
896
|
+
enqueue(fn) {
|
|
897
|
+
this.queue.push(fn);
|
|
898
|
+
this.process();
|
|
899
|
+
}
|
|
900
|
+
enqueueFront(fn) {
|
|
901
|
+
this.queue.unshift(fn);
|
|
902
|
+
this.process();
|
|
903
|
+
}
|
|
904
|
+
pause() {
|
|
905
|
+
this.paused = true;
|
|
906
|
+
}
|
|
907
|
+
resume() {
|
|
908
|
+
this.paused = false;
|
|
909
|
+
this.process();
|
|
910
|
+
}
|
|
911
|
+
process() {
|
|
912
|
+
if (this.current || this.paused) {
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
const next = this.queue.shift();
|
|
916
|
+
if (!next) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
this.current = next()
|
|
920
|
+
.then(() => {
|
|
921
|
+
this.current = null;
|
|
922
|
+
this.process();
|
|
923
|
+
})
|
|
924
|
+
.catch(() => {
|
|
925
|
+
this.clear();
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
get length() {
|
|
929
|
+
return this.queue.length;
|
|
930
|
+
}
|
|
931
|
+
isEmpty() {
|
|
932
|
+
return this.queue.length === 0;
|
|
933
|
+
}
|
|
934
|
+
hasActiveTask() {
|
|
935
|
+
return this.current !== null;
|
|
936
|
+
}
|
|
937
|
+
clear() {
|
|
938
|
+
this.queue = [];
|
|
939
|
+
this.current = null;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* @license
|
|
945
|
+
* @monterosa/sdk-util
|
|
946
|
+
*
|
|
947
|
+
* Copyright © 2025 Monterosa Productions Limited. All rights reserved.
|
|
948
|
+
*
|
|
949
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
950
|
+
*/
|
|
951
|
+
/**
|
|
952
|
+
* Calculates the delay for a retry attempt based on the backoff strategy.
|
|
953
|
+
*
|
|
954
|
+
* @param backoffStrategy - The backoff strategy.
|
|
955
|
+
* @param attemptNumber - The current attempt number (0-indexed).
|
|
956
|
+
* @param baseDelay - The base delay in milliseconds.
|
|
957
|
+
* @param jitter - The maximum jitter to add in milliseconds.
|
|
958
|
+
* @param maxDelay - The maximum delay in milliseconds.
|
|
959
|
+
*
|
|
960
|
+
* @returns The calculated delay in milliseconds.
|
|
961
|
+
*/
|
|
962
|
+
function calculateRetryDelay(backoffStrategy, attemptNumber, baseDelay, jitter, maxDelay) {
|
|
963
|
+
let delayMs;
|
|
964
|
+
switch (backoffStrategy) {
|
|
965
|
+
case 'fixed':
|
|
966
|
+
delayMs = baseDelay;
|
|
967
|
+
break;
|
|
968
|
+
case 'incremental':
|
|
969
|
+
delayMs = baseDelay * (attemptNumber + 1);
|
|
970
|
+
break;
|
|
971
|
+
case 'exponential':
|
|
972
|
+
default:
|
|
973
|
+
delayMs = baseDelay * 2 ** attemptNumber;
|
|
974
|
+
}
|
|
975
|
+
// Add jitter (random value between 0 and jitter)
|
|
976
|
+
delayMs += Math.floor(Math.random() * jitter);
|
|
977
|
+
// Cap at maxDelay
|
|
978
|
+
return Math.min(delayMs, maxDelay);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* @internal
|
|
982
|
+
*
|
|
983
|
+
* Default configuration values for retry logic.
|
|
984
|
+
*/
|
|
985
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
986
|
+
backoffStrategy: 'exponential',
|
|
987
|
+
attempts: 3,
|
|
988
|
+
baseDelay: 500,
|
|
989
|
+
jitter: 500,
|
|
990
|
+
maxDelay: 10000,
|
|
991
|
+
};
|
|
992
|
+
/**
|
|
993
|
+
* @internal
|
|
994
|
+
*
|
|
995
|
+
* Wraps an async function with retry logic and configurable backoff strategies.
|
|
996
|
+
*
|
|
997
|
+
* @template TArgs - The argument types of the wrapped function.
|
|
998
|
+
* @template TResult - The return type of the wrapped function.
|
|
999
|
+
*
|
|
1000
|
+
* @param fn - The async function to wrap.
|
|
1001
|
+
* @param config - Configuration object for retry behaviour.
|
|
1002
|
+
* - backoffStrategy: BackoffStrategy (default: 'exponential')
|
|
1003
|
+
* - attempts: number of retry attempts (default: 3)
|
|
1004
|
+
* - baseDelay: base delay in ms (default: 500)
|
|
1005
|
+
* - jitter: max jitter in ms (default: 500)
|
|
1006
|
+
* - maxDelay: max delay in ms (default: 10_000)
|
|
1007
|
+
*
|
|
1008
|
+
* @returns A new function that retries the given async function up to the
|
|
1009
|
+
* specified number of attempts with the configured backoff strategy.
|
|
1010
|
+
*
|
|
1011
|
+
* @throws The last encountered error if all retry attempts fail.
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* const fetchDataWithRetry = withRetryAsync(fetchData, {
|
|
1015
|
+
* backoffStrategy: 'exponential',
|
|
1016
|
+
* attempts: 3,
|
|
1017
|
+
* baseDelay: 500
|
|
1018
|
+
* });
|
|
1019
|
+
*
|
|
1020
|
+
* // Will retry up to 3 times with exponential backoff
|
|
1021
|
+
* fetchDataWithRetry("https://api.example.com")
|
|
1022
|
+
* .then(data => console.log(data))
|
|
1023
|
+
* .catch(err => console.error("Failed after retries:", err));
|
|
1024
|
+
*/
|
|
1025
|
+
function withRetryAsync(fn, config = {}) {
|
|
1026
|
+
const { backoffStrategy = DEFAULT_RETRY_CONFIG.backoffStrategy, attempts = DEFAULT_RETRY_CONFIG.attempts, baseDelay = DEFAULT_RETRY_CONFIG.baseDelay, jitter = DEFAULT_RETRY_CONFIG.jitter, maxDelay = DEFAULT_RETRY_CONFIG.maxDelay, } = config;
|
|
1027
|
+
return async (...args) => {
|
|
1028
|
+
let lastError;
|
|
1029
|
+
for (let i = 0; i < attempts; i++) {
|
|
1030
|
+
try {
|
|
1031
|
+
return await fn(...args);
|
|
1032
|
+
}
|
|
1033
|
+
catch (error) {
|
|
1034
|
+
lastError = error;
|
|
1035
|
+
if (i < attempts - 1) {
|
|
1036
|
+
const delayMs = calculateRetryDelay(backoffStrategy, i, baseDelay, jitter, maxDelay);
|
|
1037
|
+
await delay(delayMs);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* @license
|
|
1047
|
+
* checksum.ts
|
|
1048
|
+
* util
|
|
1049
|
+
*
|
|
1050
|
+
* Copyright © 2025 Monterosa. All rights reserved.
|
|
1051
|
+
*
|
|
1052
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
1053
|
+
*/
|
|
1054
|
+
/* eslint no-bitwise: "off", global-require: "off" */
|
|
1055
|
+
/**
|
|
1056
|
+
* Detects if running in Node.js by checking for the 'process' object and
|
|
1057
|
+
* 'versions.node' property. Required because TextEncoder must be imported
|
|
1058
|
+
* from 'util' in Node.js, but is global in browsers.
|
|
1059
|
+
*
|
|
1060
|
+
* Cross-platform support is necessary primarily because Jest tests run in
|
|
1061
|
+
* Node.js environment, where TextEncoder is not available globally and must
|
|
1062
|
+
* be imported from the 'util' module. This ensures the code works correctly
|
|
1063
|
+
* in both test environments (Node.js) and production browser environments.
|
|
1064
|
+
*/
|
|
1065
|
+
const isNode = typeof process !== 'undefined' &&
|
|
1066
|
+
process.versions != null &&
|
|
1067
|
+
process.versions.node != null;
|
|
1068
|
+
/**
|
|
1069
|
+
* Reference to TextEncoder for UTF-8 string encoding. Initialised
|
|
1070
|
+
* conditionally: Node.js uses 'util'.TextEncoder, browsers use the global
|
|
1071
|
+
* TextEncoder.
|
|
1072
|
+
*/
|
|
1073
|
+
let TextEncoderRef;
|
|
1074
|
+
/**
|
|
1075
|
+
* Initialise TextEncoderRef based on runtime environment.
|
|
1076
|
+
* Node.js: imports from 'util' module via require().
|
|
1077
|
+
* Browser: uses the global TextEncoder API.
|
|
1078
|
+
*/
|
|
1079
|
+
if (isNode) {
|
|
1080
|
+
TextEncoderRef = require('util').TextEncoder;
|
|
1081
|
+
}
|
|
1082
|
+
else {
|
|
1083
|
+
TextEncoderRef = TextEncoder;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* @internal
|
|
1087
|
+
*
|
|
1088
|
+
* FNV-1a 32-bit hash function
|
|
1089
|
+
* Produces a fast, non-cryptographic checksum for strings
|
|
1090
|
+
*
|
|
1091
|
+
* @param str - The input string to hash
|
|
1092
|
+
*
|
|
1093
|
+
* @returns 8-character hexadecimal string representing the hash
|
|
1094
|
+
*/
|
|
1095
|
+
function checksum(str) {
|
|
1096
|
+
// FNV-1a constants for 32-bit hashing
|
|
1097
|
+
const FNV_PRIME = 0x01000193; // 16777619
|
|
1098
|
+
const OFFSET_BASIS = 0x811c9dc5; // 2166136261
|
|
1099
|
+
// initialise hash with the offset basis
|
|
1100
|
+
let hash = OFFSET_BASIS;
|
|
1101
|
+
// Convert string to UTF-8 bytes
|
|
1102
|
+
const bytes = new TextEncoderRef().encode(str);
|
|
1103
|
+
// Process each character in the input string
|
|
1104
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1105
|
+
// XOR with byte (0–255)
|
|
1106
|
+
hash ^= bytes[i];
|
|
1107
|
+
// Multiply by FNV prime and ensure 32-bit unsigned
|
|
1108
|
+
hash = Math.imul(hash, FNV_PRIME) >>> 0;
|
|
1109
|
+
}
|
|
1110
|
+
// Convert to unsigned 32-bit and format as hex
|
|
1111
|
+
return hash.toString(16).padStart(8, '0');
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* @license
|
|
1116
|
+
* @monterosa/sdk-util
|
|
1117
|
+
*
|
|
1118
|
+
* Copyright © 2026 Monterosa Productions Limited. All rights reserved.
|
|
1119
|
+
*
|
|
1120
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
1121
|
+
*/
|
|
1122
|
+
/* eslint-disable no-bitwise */
|
|
1123
|
+
const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
1124
|
+
/**
|
|
1125
|
+
* Generates a RFC 4122 version 4 UUID.
|
|
1126
|
+
*
|
|
1127
|
+
* Uses `crypto.randomUUID()` when available, falling back to
|
|
1128
|
+
* `crypto.getRandomValues()` for older browsers.
|
|
1129
|
+
*
|
|
1130
|
+
* @returns A UUID v4 string
|
|
1131
|
+
*
|
|
1132
|
+
* @internal
|
|
1133
|
+
*/
|
|
1134
|
+
function generateUUID() {
|
|
1135
|
+
if (typeof crypto.randomUUID === 'function') {
|
|
1136
|
+
return crypto.randomUUID();
|
|
1137
|
+
}
|
|
1138
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
1139
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
|
|
1140
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80; // variant 10
|
|
1141
|
+
const hex = Array.from(bytes)
|
|
1142
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
1143
|
+
.join('');
|
|
1144
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Validates whether a string is a valid UUID v4.
|
|
1148
|
+
*
|
|
1149
|
+
* @param value - The string to validate
|
|
1150
|
+
* @returns `true` if the string is a valid UUID v4
|
|
1151
|
+
*
|
|
1152
|
+
* @internal
|
|
1153
|
+
*/
|
|
1154
|
+
function isUUID(value) {
|
|
1155
|
+
return UUID_V4_REGEX.test(value);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
exports.DEFAULT_RETRY_CONFIG = DEFAULT_RETRY_CONFIG;
|
|
1159
|
+
exports.Emitter = Emitter;
|
|
1160
|
+
exports.MonterosaError = MonterosaError;
|
|
1161
|
+
exports.TaskQueue = TaskQueue;
|
|
1162
|
+
exports.calculatePercentage = calculatePercentage;
|
|
1163
|
+
exports.checkAvailability = checkAvailability;
|
|
1164
|
+
exports.checksum = checksum;
|
|
1165
|
+
exports.clear = clear;
|
|
1166
|
+
exports.createError = createError;
|
|
1167
|
+
exports.delay = delay;
|
|
1168
|
+
exports.fromEntries = fromEntries;
|
|
1169
|
+
exports.generateUUID = generateUUID;
|
|
1170
|
+
exports.getErrorMessage = getErrorMessage;
|
|
1171
|
+
exports.getGlobal = getGlobal;
|
|
1172
|
+
exports.getItem = getItem;
|
|
1173
|
+
exports.getKey = getKey;
|
|
1174
|
+
exports.isUUID = isUUID;
|
|
1175
|
+
exports.memoizePromise = memoizePromise;
|
|
1176
|
+
exports.now = now;
|
|
1177
|
+
exports.onTick = onTick;
|
|
1178
|
+
exports.removeItem = removeItem;
|
|
1179
|
+
exports.setItem = setItem;
|
|
1180
|
+
exports.setTimestamp = setTimestamp;
|
|
1181
|
+
exports.subscribe = subscribe;
|
|
1182
|
+
exports.throttle = throttle;
|
|
1183
|
+
exports.tick = tick;
|
|
1184
|
+
exports.withRetryAsync = withRetryAsync;
|
|
1185
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/emitter.ts","../src/delay.ts","../src/memoize-promise.ts","../src/global.ts","../src/storage.ts","../src/error.ts","../src/throttle.ts","../src/time.ts","../src/fromentries.ts","../src/calculate-percentage.ts","../src/task-queue.ts","../src/with-retry-async.ts","../src/checksum.ts","../src/uuid.ts"],"sourcesContent":["/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\ntype Handler = (...args: any[]) => void;\n\n/**\n * @internal\n *\n * Event emitter. Provides subscribe/unsubscribe pattern used throughout\n * the SDK for observable state changes.\n */\nexport class Emitter {\n private readonly listeners = new Map<string, Set<Handler>>();\n\n /**\n * Subscribes to an event.\n *\n * @param event - The event name\n * @param handler - The callback function\n * @returns A function that unsubscribes the handler when called\n */\n on(event: string, handler: Handler): Unsubscribe {\n if (!this.listeners.has(event)) {\n this.listeners.set(event, new Set());\n }\n\n this.listeners.get(event)!.add(handler);\n\n return () => this.off(event, handler);\n }\n\n /**\n * Unsubscribes from an event.\n *\n * @param event - The event name\n * @param handler - The handler to remove. If omitted, all handlers for the event are removed.\n */\n off(event: string, handler?: Handler): void {\n if (handler === undefined) {\n this.listeners.delete(event);\n return;\n }\n\n this.listeners.get(event)?.delete(handler);\n }\n\n /**\n * Emits an event with optional arguments.\n *\n * @param event - The event name\n * @param args - Arguments to pass to handlers\n */\n emit(event: string, ...args: any[]): void {\n this.listeners.get(event)?.forEach((handler) => handler(...args));\n }\n\n /**\n * Subscribes to an event and automatically unsubscribes after the first call.\n *\n * @param event - The event name\n * @param handler - The callback function\n * @returns A function that unsubscribes the handler when called\n */\n once(event: string, handler: Handler): Unsubscribe {\n const wrapper: Handler = (...args) => {\n handler(...args);\n this.off(event, wrapper);\n };\n\n return this.on(event, wrapper);\n }\n}\n\n/**\n * The unsubscribe function. When it is called, the previously set event\n * listener is removed. It is returned by every observer functions\n *\n * @example\n * ```typescript\n * const unsubscribe: Unsubscribe = onElementPublished((element) => {\n * console.log('Element published', element);\n * });\n *\n * unsubscribe();\n * ```\n */\nexport interface Unsubscribe {\n (): void;\n}\n\n/**\n * @internal\n */\nexport interface Subscribe {\n (\n emitter: Emitter,\n event: string,\n callback: (...args: any[]) => void,\n ): Unsubscribe;\n}\n\n/**\n * @internal\n */\nexport const subscribe: Subscribe = (emitter, event, callback) => {\n emitter.on(event, callback);\n\n return () => emitter.off(event, callback);\n};\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * @internal\n *\n * Delays the execution of the code for a given number of milliseconds.\n *\n * @param timeout - The timeout in milliseconds.\n *\n * @returns A promise that resolves after the timeout.\n */\nexport const delay = async (timeout: number): Promise<void> => {\n await new Promise((resolve) => setTimeout(resolve, timeout));\n};\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * Creates a function that memoizes the result of `func`.\n *\n * @internal\n *\n * @param func - A function that returns a promise. The results of its work will be memoized.\n * @param resolver - A function that determines the cache key.\n * @param config - A configuration object with the following optional properties:\n * `clearOnResolve` - Deletes memoized result upon promise resolve. Defaults to `false`.\n * `clearOnReject` - Deletes memoized result upon promise reject. Defaults to `true`.\n */\n\nexport const memoizePromise = <T>(\n func: (...args: any[]) => Promise<T>,\n resolver: (...args: any[]) => any,\n config: {\n clearOnResolve?: boolean;\n clearOnReject?: boolean;\n } = {},\n): ((...args: any[]) => Promise<T>) => {\n const clearOnResolve = config.clearOnResolve ?? false;\n const clearOnReject = config.clearOnReject ?? true;\n\n const cache: Map<any, Promise<T>> = new Map();\n\n const memoized = (...args: any[]) => {\n const key = resolver(...args);\n\n if (cache.has(key)) {\n return cache.get(key) as Promise<T>;\n }\n\n const promise = func(...args);\n\n cache.set(key, promise);\n\n promise\n .then(() => clearOnResolve && cache.delete(key))\n .catch(() => clearOnReject && cache.delete(key));\n\n return promise;\n };\n\n memoized.cache = cache;\n\n return memoized;\n};\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint no-restricted-globals: \"off\" */\n\n/**\n * @preserve\n * Global object polyfill.\n * Based on MDN article: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis\n *\n * @internal\n *\n * @returns typeof globalThis\n */\nexport function getGlobal(): typeof globalThis {\n if (typeof self !== 'undefined') {\n return self;\n }\n\n if (typeof globalThis !== 'undefined') {\n return globalThis;\n }\n\n if (typeof window !== 'undefined') {\n return window;\n }\n\n if (typeof global !== 'undefined') {\n return global;\n }\n\n throw new Error('Unable to locate global object.');\n}\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { getGlobal } from './global';\n\nconst PREFIX = 'monterosa_sdk_';\n\nconst BAIT = 'bait';\n\nconst globals = getGlobal();\n\n/**\n * @internal\n */\nexport const getKey = (name: string) => `${PREFIX}${name}`;\n\n/**\n * @internal\n */\nexport function getItem(key: string): string | null {\n return globals.localStorage.getItem(getKey(key));\n}\n\n/**\n * @internal\n */\nexport function setItem(key: string, value: string): void {\n return globals.localStorage.setItem(getKey(key), value);\n}\n\n/**\n * @internal\n */\nexport function removeItem(key: string): void {\n return globals.localStorage.removeItem(getKey(key));\n}\n\n/**\n * @internal\n */\nexport function clear(): void {\n return globals.localStorage.clear();\n}\n\n/**\n * Checks locastorage availability.\n * Based on MDN article: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API\n * and Paul Irish gists: https://gist.github.com/paulirish/5558557\n *\n * @internal\n *\n * @returns boolean\n */\nexport function checkAvailability() {\n try {\n setItem(BAIT, BAIT);\n getItem(BAIT);\n removeItem(BAIT);\n\n return true;\n } catch (e) {\n return false;\n }\n}\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint max-classes-per-file: [\"error\", 2] */\n\n/**\n * MonterosaError extends the standard JavaScript `Error` object. It has\n * an error code so that users can identify the error. It also has its\n * own specific `name` \"MonterosaError\".\n */\nexport class MonterosaError extends Error {\n /**\n * The name property represents a name for the type of error.\n */\n readonly name = 'MonterosaError';\n\n /**\n * Error code string\n */\n readonly code: string;\n\n /**\n * @param code - Error code string\n * @param message - A descriptive message for the error\n */\n constructor(code: string, message: string) {\n super(message);\n\n this.code = code;\n\n // Fix For ES5\n // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, MonterosaError.prototype);\n }\n}\n\ntype ErrorMap<ErrorCode extends string> = {\n readonly [K in ErrorCode]: (...rest: any[]) => string;\n};\n\n/**\n * @internal\n */\nexport function createError<ErrorCode extends string>(\n code: ErrorCode,\n messages: ErrorMap<ErrorCode>,\n ...params: any[]\n) {\n const message = messages[code](...params);\n\n return new MonterosaError(code, message);\n}\n\n/**\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (err instanceof Error) {\n return err.message;\n }\n\n if (typeof err === 'string') {\n return err;\n }\n\n try {\n return JSON.stringify(err);\n } catch {\n return 'Unknown error';\n }\n}\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint-disable */\n// @ts-nocheck\n\n/**\n * @copyright\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the `TypeError` message for \"Functions\" methods. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal =\n typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf =\n typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function () {\n return root.Date.now();\n};\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing\n ? nativeMax(toNumber(options.maxWait) || 0, wait)\n : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n result = wait - timeSinceLastCall;\n\n return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (\n lastCallTime === undefined ||\n timeSinceLastCall >= wait ||\n timeSinceLastCall < 0 ||\n (maxing && timeSinceLastInvoke >= maxWait)\n );\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\n/**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @internal\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\nexport function throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n leading: leading,\n maxWait: wait,\n trailing: trailing,\n });\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return (\n typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag)\n );\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? other + '' : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return isBinary || reIsOctal.test(value)\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : reIsBadHex.test(value)\n ? NAN\n : +value;\n}\n","/**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright © 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * Time service that maintains current timestamp.\n *\n * Timestamp is set either:\n * - initially with the local timestamp `Date.now()` when there is yet\n * communication with EnMasse server yet\n * - later with the accurate low-latency timestamp that comes in EnMasse\n * message handshake\n *\n * Thereafter the timestamp is maintained by `tick()` function and can be\n * retrieved in two ways:\n *\n * - subscribing to an event using `onTick(callback: () => void)` function\n * that pushes notification every second with the current timestamp\n * - or pulling data directly using function `now()`\n */\n\nimport { Emitter, subscribe, Unsubscribe } from './emitter';\n\nconst emitter = new Emitter();\n\nlet serverTimestamp: number = 0;\nlet lastTickTimestamp: number = 0;\nlet tickTimeoutId: ReturnType<typeof setTimeout>;\n\n/**\n * Returns local timestamp in seconds\n */\nfunction getCurrentTimestamp(): number {\n return Date.now() / 1000;\n}\n\n/**\n * Normalizes the timestamp to reduce fluctuations due to `setTimeout` delays.\n * Ensures the fractional part is around 0.5 to avoid skipping a second.\n *\n * Returns half-second timestamp. It is used to be sure that timestamp will not\n * fluctuate more than in 1 second after each tick due to longer delays.\n * https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#reasons_for_delays_longer_than_specified\n *\n * For example if the initial timestamp has a fractional part 0.9999 then with\n * the setTimeout (tick) longer than specified we might jump over a one second.\n * Lets imaging setTimeout took 1.0002 second, then our timestamp will be 2.0001.\n * Thats why we are trying to keep fractional part in the middle of the second.\n */\nfunction getMiddleTimestamp(timestamp: number): number {\n return Math.floor(timestamp) + 0.5;\n}\n\n/**\n * Calculates the delay for the next tick to keep timestamps stable.\n */\nfunction calculateNextTickDelay(): number {\n const expectedNextTick = getMiddleTimestamp(serverTimestamp) + 1;\n\n return (expectedNextTick - serverTimestamp) * 1000;\n}\n\n/**\n * @internal\n *\n * Main function that maintains current timestamp\n */\nexport function tick() {\n clearTimeout(tickTimeoutId);\n\n const currentTimestamp = getCurrentTimestamp();\n const timeSinceLastTick = currentTimestamp - lastTickTimestamp;\n\n serverTimestamp += timeSinceLastTick;\n lastTickTimestamp = currentTimestamp;\n\n tickTimeoutId = setTimeout(tick, calculateNextTickDelay());\n\n // In Node.js, a pending setTimeout keeps the process alive. This causes\n // Jest worker processes to hang after tests complete, because tick()\n // reschedules itself indefinitely. Calling unref() tells Node.js not to\n // keep the process alive solely for this timer. In browsers, unref()\n // does not exist and is not needed — tabs don't have this problem.\n if (typeof tickTimeoutId === 'object' && 'unref' in tickTimeoutId) {\n tickTimeoutId.unref();\n }\n\n emitter.emit('tick', serverTimestamp);\n}\n\n/**\n * @internal\n *\n * Sets or updates current timestamp\n *\n * @param timestamp - Current timestamp in seconds\n */\nexport function setTimestamp(timestamp: number): void {\n lastTickTimestamp = getCurrentTimestamp();\n serverTimestamp = getMiddleTimestamp(timestamp);\n}\n\n/**\n * Returns current timestamp that is preserved by `tick()` function\n *\n * @returns Current timestamp in seconds\n */\nexport function now(): number {\n return Math.floor(serverTimestamp);\n}\n\n/**\n * Subscribes listener to the timestamp increment\n *\n * @param callback - A handler that executes when the timestamp is incremented\n *\n * @returns A function that unsubscribes the listener\n */\nexport function onTick(callback: (timestamp: number) => void): Unsubscribe {\n return subscribe(emitter, 'tick', callback);\n}\n\n// Initially timestamp is set based on a local date\n// Later on it can be overriden outside at any moment\n// in our case it is populated with the server timestamp\n// which comes from EnMasse session handshake message\nsetTimestamp(getCurrentTimestamp());\n\n// Kicking in timestamp maintaining\ntick();\n","/**\n * @license\n * fromentries.ts\n * util\n *\n * Copyright © 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * @internal\n */\nexport function fromEntries(\n entries: [string | number | symbol, any][],\n): Record<string | number | symbol, any> {\n return entries.reduce((obj, [key, value]) => {\n obj[key] = value;\n\n return obj;\n }, {} as Record<string | number | symbol, any>);\n}\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * Calculate percentage of each value in the array.\n *\n * It uses Hamilton's method, also known as the method of largest remainder.\n * It is a system used for distributing vote percentages among different\n * options (like candidates or choices) based on their vote counts. It ensures\n * that each option receives at least its lower quota of percentage points, and\n * any remaining percentage points are allocated to those with the largest\n * fractional remainders. This method is used in the US Electoral College.\n *\n * @param values - Array of number values to calculate percentage for\n * @returns Array of percentages, where the sum of the array is 100%\n */\nexport const calculatePercentage = (values: number[]): number[] => {\n // Calculate sum of all votes\n const sum = values.reduce((memo, value) => memo + value, 0);\n\n // create array of hashes\n const results = values.map((value, idx) => {\n const percentage = (100 * value) / sum || 0;\n\n return {\n idx,\n votes: value,\n percentage: Math.floor(percentage),\n remainder: percentage % 1,\n };\n });\n\n // Sum them all up - this can't be higher than 100%\n let total = results.reduce((memo, { percentage }) => memo + percentage, 0);\n\n total = total || 100;\n\n // Calculate number of percent that we are missing\n const delta = 100 - total;\n\n // Order all options by remainder\n results.sort((a, b) => {\n if (a.remainder !== b.remainder) {\n return b.remainder - a.remainder;\n }\n\n return a.idx - b.idx;\n });\n\n // Distribute delta to highest remainder options\n for (let i = 0; i < delta; i++) {\n results[i].percentage += 1;\n }\n\n // Restore options order\n results.sort((a, b) => a.idx - b.idx);\n\n return results.map((item) => item.percentage);\n};\n","/**\n * @license\n * @monterosa/sdk-identify-kit\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\ntype AsyncTask = () => Promise<void>;\n\n/**\n * @internal\n *\n * TaskQueue ensures that async tasks run sequentially (FIFO).\n *\n * Behavior:\n * - Tasks run one at a time in the order they were enqueued.\n * - If a task fails (throws/rejects), the queue is stopped\n * and all pending tasks are cleared.\n */\nexport class TaskQueue {\n private current: Promise<void> | null = null;\n private queue: AsyncTask[] = [];\n private paused: boolean = false;\n\n enqueue(fn: AsyncTask): void {\n this.queue.push(fn);\n this.process();\n }\n\n enqueueFront(fn: AsyncTask): void {\n this.queue.unshift(fn);\n this.process();\n }\n\n pause(): void {\n this.paused = true;\n }\n\n resume(): void {\n this.paused = false;\n this.process();\n }\n\n private process(): void {\n if (this.current || this.paused) {\n return;\n }\n\n const next = this.queue.shift();\n\n if (!next) {\n return;\n }\n\n this.current = next()\n .then(() => {\n this.current = null;\n this.process();\n })\n .catch(() => {\n this.clear();\n });\n }\n\n get length(): number {\n return this.queue.length;\n }\n\n isEmpty(): boolean {\n return this.queue.length === 0;\n }\n\n hasActiveTask(): boolean {\n return this.current !== null;\n }\n\n clear(): void {\n this.queue = [];\n this.current = null;\n }\n}\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint-disable no-await-in-loop */\n\nimport { delay } from './delay';\n\n/**\n * @internal\n *\n * The backoff strategy to use for retry attempts.\n */\nexport type BackoffStrategy = 'fixed' | 'incremental' | 'exponential';\n\n/**\n * Calculates the delay for a retry attempt based on the backoff strategy.\n *\n * @param backoffStrategy - The backoff strategy.\n * @param attemptNumber - The current attempt number (0-indexed).\n * @param baseDelay - The base delay in milliseconds.\n * @param jitter - The maximum jitter to add in milliseconds.\n * @param maxDelay - The maximum delay in milliseconds.\n *\n * @returns The calculated delay in milliseconds.\n */\nfunction calculateRetryDelay(\n backoffStrategy: BackoffStrategy,\n attemptNumber: number,\n baseDelay: number,\n jitter: number,\n maxDelay: number,\n): number {\n let delayMs: number;\n\n switch (backoffStrategy) {\n case 'fixed':\n delayMs = baseDelay;\n break;\n case 'incremental':\n delayMs = baseDelay * (attemptNumber + 1);\n break;\n case 'exponential':\n default:\n delayMs = baseDelay * 2 ** attemptNumber;\n }\n\n // Add jitter (random value between 0 and jitter)\n delayMs += Math.floor(Math.random() * jitter);\n\n // Cap at maxDelay\n return Math.min(delayMs, maxDelay);\n}\n\n/**\n * @internal\n *\n * Configuration options for retry logic with backoff strategies.\n */\nexport interface RetryConfig {\n /**\n * The backoff strategy to use.\n *\n * @default 'exponential'\n */\n backoffStrategy?: BackoffStrategy;\n\n /**\n * The number of attempts before failing.\n *\n * @default 3\n */\n attempts?: number;\n\n /**\n * The base delay in milliseconds for retry attempts.\n *\n * @default 500\n */\n baseDelay?: number;\n\n /**\n * The maximum jitter to add to the delay in milliseconds.\n *\n * @default 500\n */\n jitter?: number;\n\n /**\n * The maximum delay in milliseconds for retry attempts.\n *\n * @default 10_000\n */\n maxDelay?: number;\n}\n\n/**\n * @internal\n *\n * Default configuration values for retry logic.\n */\nexport const DEFAULT_RETRY_CONFIG: Required<RetryConfig> = {\n backoffStrategy: 'exponential',\n attempts: 3,\n baseDelay: 500,\n jitter: 500,\n maxDelay: 10_000,\n} as const;\n\n/**\n * @internal\n *\n * Wraps an async function with retry logic and configurable backoff strategies.\n *\n * @template TArgs - The argument types of the wrapped function.\n * @template TResult - The return type of the wrapped function.\n *\n * @param fn - The async function to wrap.\n * @param config - Configuration object for retry behaviour.\n * - backoffStrategy: BackoffStrategy (default: 'exponential')\n * - attempts: number of retry attempts (default: 3)\n * - baseDelay: base delay in ms (default: 500)\n * - jitter: max jitter in ms (default: 500)\n * - maxDelay: max delay in ms (default: 10_000)\n *\n * @returns A new function that retries the given async function up to the\n * specified number of attempts with the configured backoff strategy.\n *\n * @throws The last encountered error if all retry attempts fail.\n *\n * @example\n * const fetchDataWithRetry = withRetryAsync(fetchData, {\n * backoffStrategy: 'exponential',\n * attempts: 3,\n * baseDelay: 500\n * });\n *\n * // Will retry up to 3 times with exponential backoff\n * fetchDataWithRetry(\"https://api.example.com\")\n * .then(data => console.log(data))\n * .catch(err => console.error(\"Failed after retries:\", err));\n */\nexport function withRetryAsync<TArgs extends any[], TResult>(\n fn: (...args: TArgs) => Promise<TResult>,\n config: RetryConfig = {},\n): (...args: TArgs) => Promise<TResult> {\n const {\n backoffStrategy = DEFAULT_RETRY_CONFIG.backoffStrategy,\n attempts = DEFAULT_RETRY_CONFIG.attempts,\n baseDelay = DEFAULT_RETRY_CONFIG.baseDelay,\n jitter = DEFAULT_RETRY_CONFIG.jitter,\n maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,\n } = config;\n\n return async (...args: TArgs): Promise<TResult> => {\n let lastError: unknown;\n\n for (let i = 0; i < attempts; i++) {\n try {\n return await fn(...args);\n } catch (error) {\n lastError = error;\n\n if (i < attempts - 1) {\n const delayMs = calculateRetryDelay(\n backoffStrategy,\n i,\n baseDelay,\n jitter,\n maxDelay,\n );\n\n await delay(delayMs);\n }\n }\n }\n\n throw lastError instanceof Error ? lastError : new Error(String(lastError));\n };\n}\n","/**\n * @license\n * checksum.ts\n * util\n *\n * Copyright © 2025 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint no-bitwise: \"off\", global-require: \"off\" */\n\n/**\n * Detects if running in Node.js by checking for the 'process' object and\n * 'versions.node' property. Required because TextEncoder must be imported\n * from 'util' in Node.js, but is global in browsers.\n *\n * Cross-platform support is necessary primarily because Jest tests run in\n * Node.js environment, where TextEncoder is not available globally and must\n * be imported from the 'util' module. This ensures the code works correctly\n * in both test environments (Node.js) and production browser environments.\n */\nconst isNode =\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null;\n\n/**\n * Reference to TextEncoder for UTF-8 string encoding. Initialised\n * conditionally: Node.js uses 'util'.TextEncoder, browsers use the global\n * TextEncoder.\n */\nlet TextEncoderRef: typeof TextEncoder;\n\n/**\n * Initialise TextEncoderRef based on runtime environment.\n * Node.js: imports from 'util' module via require().\n * Browser: uses the global TextEncoder API.\n */\nif (isNode) {\n TextEncoderRef = require('util').TextEncoder;\n} else {\n TextEncoderRef = TextEncoder;\n}\n\n/**\n * @internal\n *\n * FNV-1a 32-bit hash function\n * Produces a fast, non-cryptographic checksum for strings\n *\n * @param str - The input string to hash\n *\n * @returns 8-character hexadecimal string representing the hash\n */\nexport function checksum(str: string): string {\n // FNV-1a constants for 32-bit hashing\n const FNV_PRIME: number = 0x01000193; // 16777619\n const OFFSET_BASIS: number = 0x811c9dc5; // 2166136261\n\n // initialise hash with the offset basis\n let hash: number = OFFSET_BASIS;\n\n // Convert string to UTF-8 bytes\n const bytes = new TextEncoderRef().encode(str);\n\n // Process each character in the input string\n for (let i = 0; i < bytes.length; i++) {\n // XOR with byte (0–255)\n hash ^= bytes[i];\n\n // Multiply by FNV prime and ensure 32-bit unsigned\n hash = Math.imul(hash, FNV_PRIME) >>> 0;\n }\n\n // Convert to unsigned 32-bit and format as hex\n return hash.toString(16).padStart(8, '0');\n}\n","/**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint-disable no-bitwise */\n\nconst UUID_V4_REGEX =\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\n/**\n * Generates a RFC 4122 version 4 UUID.\n *\n * Uses `crypto.randomUUID()` when available, falling back to\n * `crypto.getRandomValues()` for older browsers.\n *\n * @returns A UUID v4 string\n *\n * @internal\n */\nexport function generateUUID(): string {\n if (typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n\n bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4\n bytes[8] = (bytes[8] & 0x3f) | 0x80; // variant 10\n\n const hex = Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(\n 12,\n 16,\n )}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\n/**\n * Validates whether a string is a valid UUID v4.\n *\n * @param value - The string to validate\n * @returns `true` if the string is a valid UUID v4\n *\n * @internal\n */\nexport function isUUID(value: string): boolean {\n return UUID_V4_REGEX.test(value);\n}\n"],"names":["now"],"mappings":";;;;AAAA;;;;;;;AAOG;AAIH;;;;;AAKG;MACU,OAAO,CAAA;AAApB,IAAA,WAAA,GAAA;AACmB,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;KA2D9D;AAzDC;;;;;;AAMG;IACH,EAAE,CAAC,KAAa,EAAE,OAAgB,EAAA;QAChC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACtC,SAAA;AAED,QAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAExC,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACvC;AAED;;;;;AAKG;IACH,GAAG,CAAC,KAAa,EAAE,OAAiB,EAAA;;QAClC,I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,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAA,EAAI,GAAG,CAAC,KAAK,CACxD,EAAE,EACF,EAAE,CACH,CAAA,CAAA,EAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA,CAAA,EAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;;;AAOG;AACG,SAAU,MAAM,CAAC,KAAa,EAAA;AAClC,IAAA,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monterosa/sdk-util",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.3",
|
|
4
4
|
"description": "Monterosa JS SDK / Utils",
|
|
5
5
|
"author": "Monterosa Productions Limited <hello@monterosa.co.uk> (https://www.monterosa.co/)",
|
|
6
|
-
"main": "./dist/index.
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
|
-
"
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"default": "./dist/index.cjs"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "d692ad26af0b5ea7cd7b664168bffa069f9ab911"
|
|
53
54
|
}
|