@monterosa/sdk-util 2.0.0-rc.1 → 2.0.0-rc.2
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/checksum.d.ts +2 -0
- package/dist/emitter.d.ts +33 -3
- package/dist/error.d.ts +2 -2
- package/dist/fromentries.d.ts +3 -0
- package/dist/index.d.ts +6 -5
- package/dist/{index.esm.js → index.js} +116 -27
- package/dist/index.js.map +1 -0
- package/dist/task-queue.d.ts +2 -0
- package/dist/time.d.ts +2 -0
- package/dist/uuid.d.ts +28 -0
- package/dist/with-retry-async.d.ts +9 -1
- package/package.json +17 -11
- package/dist/index.cjs.js +0 -1231
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js.map +0 -1
package/dist/checksum.d.ts
CHANGED
package/dist/emitter.d.ts
CHANGED
|
@@ -7,13 +7,43 @@
|
|
|
7
7
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
8
8
|
*/
|
|
9
9
|
type Handler = (...args: any[]) => void;
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*
|
|
13
|
+
* Event emitter. Provides subscribe/unsubscribe pattern used throughout
|
|
14
|
+
* the SDK for observable state changes.
|
|
15
|
+
*/
|
|
10
16
|
export declare class Emitter {
|
|
11
|
-
private readonly
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
private readonly listeners;
|
|
18
|
+
/**
|
|
19
|
+
* Subscribes to an event.
|
|
20
|
+
*
|
|
21
|
+
* @param event - The event name
|
|
22
|
+
* @param handler - The callback function
|
|
23
|
+
* @returns A function that unsubscribes the handler when called
|
|
24
|
+
*/
|
|
14
25
|
on(event: string, handler: Handler): Unsubscribe;
|
|
26
|
+
/**
|
|
27
|
+
* Unsubscribes from an event.
|
|
28
|
+
*
|
|
29
|
+
* @param event - The event name
|
|
30
|
+
* @param handler - The handler to remove. If omitted, all handlers for the event are removed.
|
|
31
|
+
*/
|
|
15
32
|
off(event: string, handler?: Handler): void;
|
|
33
|
+
/**
|
|
34
|
+
* Emits an event with optional arguments.
|
|
35
|
+
*
|
|
36
|
+
* @param event - The event name
|
|
37
|
+
* @param args - Arguments to pass to handlers
|
|
38
|
+
*/
|
|
16
39
|
emit(event: string, ...args: any[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* Subscribes to an event and automatically unsubscribes after the first call.
|
|
42
|
+
*
|
|
43
|
+
* @param event - The event name
|
|
44
|
+
* @param handler - The callback function
|
|
45
|
+
* @returns A function that unsubscribes the handler when called
|
|
46
|
+
*/
|
|
17
47
|
once(event: string, handler: Handler): Unsubscribe;
|
|
18
48
|
}
|
|
19
49
|
/**
|
package/dist/error.d.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* MonterosaError extends the standard JavaScript `Error` object. It has
|
|
11
|
-
* an error code so that
|
|
12
|
-
* specific `name` "MonterosaError"
|
|
11
|
+
* an error code so that users can identify the error. It also has its
|
|
12
|
+
* own specific `name` "MonterosaError".
|
|
13
13
|
*/
|
|
14
14
|
export declare class MonterosaError extends Error {
|
|
15
15
|
/**
|
package/dist/fromentries.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities including emitters, error handling, and storage helpers.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
1
6
|
/**
|
|
2
7
|
* @license
|
|
3
8
|
* @monterosa/sdk-util
|
|
@@ -6,11 +11,6 @@
|
|
|
6
11
|
*
|
|
7
12
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
8
13
|
*/
|
|
9
|
-
/**
|
|
10
|
-
* Monterosa SDK / Util
|
|
11
|
-
*
|
|
12
|
-
* @packageDocumentation
|
|
13
|
-
*/
|
|
14
14
|
export * from './emitter';
|
|
15
15
|
export * from './delay';
|
|
16
16
|
export * from './memoize-promise';
|
|
@@ -24,3 +24,4 @@ export * from './calculate-percentage';
|
|
|
24
24
|
export * from './task-queue';
|
|
25
25
|
export * from './with-retry-async';
|
|
26
26
|
export * from './checksum';
|
|
27
|
+
export * from './uuid';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import mitt from 'mitt';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @license
|
|
5
3
|
* @monterosa/sdk-util
|
|
@@ -8,41 +6,67 @@ import mitt from 'mitt';
|
|
|
8
6
|
*
|
|
9
7
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
10
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*
|
|
12
|
+
* Event emitter. Provides subscribe/unsubscribe pattern used throughout
|
|
13
|
+
* the SDK for observable state changes.
|
|
14
|
+
*/
|
|
11
15
|
class Emitter {
|
|
12
16
|
constructor() {
|
|
13
|
-
this.
|
|
14
|
-
this.emitter = mitt();
|
|
17
|
+
this.listeners = new Map();
|
|
15
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Subscribes to an event.
|
|
21
|
+
*
|
|
22
|
+
* @param event - The event name
|
|
23
|
+
* @param handler - The callback function
|
|
24
|
+
* @returns A function that unsubscribes the handler when called
|
|
25
|
+
*/
|
|
16
26
|
on(event, handler) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
this.
|
|
21
|
-
this.emitter.on(event, mittHandler);
|
|
27
|
+
if (!this.listeners.has(event)) {
|
|
28
|
+
this.listeners.set(event, new Set());
|
|
29
|
+
}
|
|
30
|
+
this.listeners.get(event).add(handler);
|
|
22
31
|
return () => this.off(event, handler);
|
|
23
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Unsubscribes from an event.
|
|
35
|
+
*
|
|
36
|
+
* @param event - The event name
|
|
37
|
+
* @param handler - The handler to remove. If omitted, all handlers for the event are removed.
|
|
38
|
+
*/
|
|
24
39
|
off(event, handler) {
|
|
40
|
+
var _a;
|
|
25
41
|
if (handler === undefined) {
|
|
26
|
-
this.
|
|
42
|
+
this.listeners.delete(event);
|
|
27
43
|
return;
|
|
28
44
|
}
|
|
29
|
-
|
|
30
|
-
if (mittHandler) {
|
|
31
|
-
this.emitter.off(event, mittHandler);
|
|
32
|
-
this.handlers.delete(handler);
|
|
33
|
-
}
|
|
45
|
+
(_a = this.listeners.get(event)) === null || _a === void 0 ? void 0 : _a.delete(handler);
|
|
34
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Emits an event with optional arguments.
|
|
49
|
+
*
|
|
50
|
+
* @param event - The event name
|
|
51
|
+
* @param args - Arguments to pass to handlers
|
|
52
|
+
*/
|
|
35
53
|
emit(event, ...args) {
|
|
36
|
-
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = this.listeners.get(event)) === null || _a === void 0 ? void 0 : _a.forEach((handler) => handler(...args));
|
|
37
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Subscribes to an event and automatically unsubscribes after the first call.
|
|
59
|
+
*
|
|
60
|
+
* @param event - The event name
|
|
61
|
+
* @param handler - The callback function
|
|
62
|
+
* @returns A function that unsubscribes the handler when called
|
|
63
|
+
*/
|
|
38
64
|
once(event, handler) {
|
|
39
|
-
const
|
|
40
|
-
handler(...
|
|
41
|
-
this.off(event,
|
|
65
|
+
const wrapper = (...args) => {
|
|
66
|
+
handler(...args);
|
|
67
|
+
this.off(event, wrapper);
|
|
42
68
|
};
|
|
43
|
-
this.
|
|
44
|
-
this.emitter.on(event, mittHandler);
|
|
45
|
-
return () => this.off(event, handler);
|
|
69
|
+
return this.on(event, wrapper);
|
|
46
70
|
}
|
|
47
71
|
}
|
|
48
72
|
/**
|
|
@@ -219,8 +243,8 @@ function checkAvailability() {
|
|
|
219
243
|
/* eslint max-classes-per-file: ["error", 2] */
|
|
220
244
|
/**
|
|
221
245
|
* MonterosaError extends the standard JavaScript `Error` object. It has
|
|
222
|
-
* an error code so that
|
|
223
|
-
* specific `name` "MonterosaError"
|
|
246
|
+
* an error code so that users can identify the error. It also has its
|
|
247
|
+
* own specific `name` "MonterosaError".
|
|
224
248
|
*/
|
|
225
249
|
class MonterosaError extends Error {
|
|
226
250
|
/**
|
|
@@ -709,6 +733,8 @@ function calculateNextTickDelay() {
|
|
|
709
733
|
return (expectedNextTick - serverTimestamp) * 1000;
|
|
710
734
|
}
|
|
711
735
|
/**
|
|
736
|
+
* @internal
|
|
737
|
+
*
|
|
712
738
|
* Main function that maintains current timestamp
|
|
713
739
|
*/
|
|
714
740
|
function tick() {
|
|
@@ -718,6 +744,14 @@ function tick() {
|
|
|
718
744
|
serverTimestamp += timeSinceLastTick;
|
|
719
745
|
lastTickTimestamp = currentTimestamp;
|
|
720
746
|
tickTimeoutId = setTimeout(tick, calculateNextTickDelay());
|
|
747
|
+
// In Node.js, a pending setTimeout keeps the process alive. This causes
|
|
748
|
+
// Jest worker processes to hang after tests complete, because tick()
|
|
749
|
+
// reschedules itself indefinitely. Calling unref() tells Node.js not to
|
|
750
|
+
// keep the process alive solely for this timer. In browsers, unref()
|
|
751
|
+
// does not exist and is not needed — tabs don't have this problem.
|
|
752
|
+
if (typeof tickTimeoutId === 'object' && 'unref' in tickTimeoutId) {
|
|
753
|
+
tickTimeoutId.unref();
|
|
754
|
+
}
|
|
721
755
|
emitter.emit('tick', serverTimestamp);
|
|
722
756
|
}
|
|
723
757
|
/**
|
|
@@ -766,6 +800,9 @@ tick();
|
|
|
766
800
|
*
|
|
767
801
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
768
802
|
*/
|
|
803
|
+
/**
|
|
804
|
+
* @internal
|
|
805
|
+
*/
|
|
769
806
|
function fromEntries(entries) {
|
|
770
807
|
return entries.reduce((obj, [key, value]) => {
|
|
771
808
|
obj[key] = value;
|
|
@@ -837,6 +874,8 @@ const calculatePercentage = (values) => {
|
|
|
837
874
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
838
875
|
*/
|
|
839
876
|
/**
|
|
877
|
+
* @internal
|
|
878
|
+
*
|
|
840
879
|
* TaskQueue ensures that async tasks run sequentially (FIFO).
|
|
841
880
|
*
|
|
842
881
|
* Behavior:
|
|
@@ -935,6 +974,8 @@ function calculateRetryDelay(backoffStrategy, attemptNumber, baseDelay, jitter,
|
|
|
935
974
|
return Math.min(delayMs, maxDelay);
|
|
936
975
|
}
|
|
937
976
|
/**
|
|
977
|
+
* @internal
|
|
978
|
+
*
|
|
938
979
|
* Default configuration values for retry logic.
|
|
939
980
|
*/
|
|
940
981
|
const DEFAULT_RETRY_CONFIG = {
|
|
@@ -945,13 +986,15 @@ const DEFAULT_RETRY_CONFIG = {
|
|
|
945
986
|
maxDelay: 10000,
|
|
946
987
|
};
|
|
947
988
|
/**
|
|
989
|
+
* @internal
|
|
990
|
+
*
|
|
948
991
|
* Wraps an async function with retry logic and configurable backoff strategies.
|
|
949
992
|
*
|
|
950
993
|
* @template TArgs - The argument types of the wrapped function.
|
|
951
994
|
* @template TResult - The return type of the wrapped function.
|
|
952
995
|
*
|
|
953
996
|
* @param fn - The async function to wrap.
|
|
954
|
-
* @param config - Configuration object for retry
|
|
997
|
+
* @param config - Configuration object for retry behaviour.
|
|
955
998
|
* - backoffStrategy: BackoffStrategy (default: 'exponential')
|
|
956
999
|
* - attempts: number of retry attempts (default: 3)
|
|
957
1000
|
* - baseDelay: base delay in ms (default: 500)
|
|
@@ -1036,6 +1079,8 @@ else {
|
|
|
1036
1079
|
TextEncoderRef = TextEncoder;
|
|
1037
1080
|
}
|
|
1038
1081
|
/**
|
|
1082
|
+
* @internal
|
|
1083
|
+
*
|
|
1039
1084
|
* FNV-1a 32-bit hash function
|
|
1040
1085
|
* Produces a fast, non-cryptographic checksum for strings
|
|
1041
1086
|
*
|
|
@@ -1062,5 +1107,49 @@ function checksum(str) {
|
|
|
1062
1107
|
return hash.toString(16).padStart(8, '0');
|
|
1063
1108
|
}
|
|
1064
1109
|
|
|
1065
|
-
|
|
1066
|
-
|
|
1110
|
+
/**
|
|
1111
|
+
* @license
|
|
1112
|
+
* @monterosa/sdk-util
|
|
1113
|
+
*
|
|
1114
|
+
* Copyright © 2026 Monterosa Productions Limited. All rights reserved.
|
|
1115
|
+
*
|
|
1116
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
1117
|
+
*/
|
|
1118
|
+
/* eslint-disable no-bitwise */
|
|
1119
|
+
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;
|
|
1120
|
+
/**
|
|
1121
|
+
* Generates a RFC 4122 version 4 UUID.
|
|
1122
|
+
*
|
|
1123
|
+
* Uses `crypto.randomUUID()` when available, falling back to
|
|
1124
|
+
* `crypto.getRandomValues()` for older browsers.
|
|
1125
|
+
*
|
|
1126
|
+
* @returns A UUID v4 string
|
|
1127
|
+
*
|
|
1128
|
+
* @internal
|
|
1129
|
+
*/
|
|
1130
|
+
function generateUUID() {
|
|
1131
|
+
if (typeof crypto.randomUUID === 'function') {
|
|
1132
|
+
return crypto.randomUUID();
|
|
1133
|
+
}
|
|
1134
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
1135
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
|
|
1136
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80; // variant 10
|
|
1137
|
+
const hex = Array.from(bytes)
|
|
1138
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
1139
|
+
.join('');
|
|
1140
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Validates whether a string is a valid UUID v4.
|
|
1144
|
+
*
|
|
1145
|
+
* @param value - The string to validate
|
|
1146
|
+
* @returns `true` if the string is a valid UUID v4
|
|
1147
|
+
*
|
|
1148
|
+
* @internal
|
|
1149
|
+
*/
|
|
1150
|
+
function isUUID(value) {
|
|
1151
|
+
return UUID_V4_REGEX.test(value);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
export { DEFAULT_RETRY_CONFIG, Emitter, MonterosaError, TaskQueue, calculatePercentage, checkAvailability, checksum, clear, createError, delay, fromEntries, generateUUID, getErrorMessage, getGlobal, getItem, getKey, isUUID, memoizePromise, now, onTick, removeItem, setItem, setTimestamp, subscribe, throttle, tick, withRetryAsync };
|
|
1155
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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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CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AACpC,IAAA,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAEpC,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AAC1B,SAAA,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,OAAO,CAAA,EAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAA,EAAI,GAAG,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/dist/task-queue.d.ts
CHANGED
package/dist/time.d.ts
CHANGED
package/dist/uuid.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* @monterosa/sdk-util
|
|
4
|
+
*
|
|
5
|
+
* Copyright © 2026 Monterosa Productions Limited. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generates a RFC 4122 version 4 UUID.
|
|
11
|
+
*
|
|
12
|
+
* Uses `crypto.randomUUID()` when available, falling back to
|
|
13
|
+
* `crypto.getRandomValues()` for older browsers.
|
|
14
|
+
*
|
|
15
|
+
* @returns A UUID v4 string
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateUUID(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Validates whether a string is a valid UUID v4.
|
|
22
|
+
*
|
|
23
|
+
* @param value - The string to validate
|
|
24
|
+
* @returns `true` if the string is a valid UUID v4
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function isUUID(value: string): boolean;
|
|
@@ -7,10 +7,14 @@
|
|
|
7
7
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*
|
|
10
12
|
* The backoff strategy to use for retry attempts.
|
|
11
13
|
*/
|
|
12
14
|
export type BackoffStrategy = 'fixed' | 'incremental' | 'exponential';
|
|
13
15
|
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*
|
|
14
18
|
* Configuration options for retry logic with backoff strategies.
|
|
15
19
|
*/
|
|
16
20
|
export interface RetryConfig {
|
|
@@ -46,17 +50,21 @@ export interface RetryConfig {
|
|
|
46
50
|
maxDelay?: number;
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*
|
|
49
55
|
* Default configuration values for retry logic.
|
|
50
56
|
*/
|
|
51
57
|
export declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>;
|
|
52
58
|
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*
|
|
53
61
|
* Wraps an async function with retry logic and configurable backoff strategies.
|
|
54
62
|
*
|
|
55
63
|
* @template TArgs - The argument types of the wrapped function.
|
|
56
64
|
* @template TResult - The return type of the wrapped function.
|
|
57
65
|
*
|
|
58
66
|
* @param fn - The async function to wrap.
|
|
59
|
-
* @param config - Configuration object for retry
|
|
67
|
+
* @param config - Configuration object for retry behaviour.
|
|
60
68
|
* - backoffStrategy: BackoffStrategy (default: 'exponential')
|
|
61
69
|
* - attempts: number of retry attempts (default: 3)
|
|
62
70
|
* - baseDelay: base delay in ms (default: 500)
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monterosa/sdk-util",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
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.
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
11
15
|
"files": [
|
|
12
16
|
"dist"
|
|
13
17
|
],
|
|
@@ -19,11 +23,13 @@
|
|
|
19
23
|
"test:ci": "jest --color --ci --reporters=jest-junit --coverage",
|
|
20
24
|
"api-report": "api-extractor run --local --verbose"
|
|
21
25
|
},
|
|
22
|
-
"keywords": [
|
|
26
|
+
"keywords": [
|
|
27
|
+
"monterosa",
|
|
28
|
+
"sdk",
|
|
29
|
+
"interaction-cloud",
|
|
30
|
+
"util"
|
|
31
|
+
],
|
|
23
32
|
"license": "MIT",
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"mitt": "^3.0.1"
|
|
26
|
-
},
|
|
27
33
|
"devDependencies": {
|
|
28
34
|
"@rollup/plugin-json": "^4.1.0",
|
|
29
35
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -43,5 +49,5 @@
|
|
|
43
49
|
"publishConfig": {
|
|
44
50
|
"access": "public"
|
|
45
51
|
},
|
|
46
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "0e2d4cd71055bf0ab38ec5a73d6040c55151da1c"
|
|
47
53
|
}
|