@posthog/core 1.0.0 → 1.0.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.
@@ -0,0 +1,45 @@
1
+ import { clampToRange } from "./number-utils.mjs";
2
+ class BucketedRateLimiter {
3
+ stop() {
4
+ if (this._removeInterval) {
5
+ clearInterval(this._removeInterval);
6
+ this._removeInterval = void 0;
7
+ }
8
+ }
9
+ constructor(_options){
10
+ this._options = _options;
11
+ this._buckets = {};
12
+ this._refillBuckets = ()=>{
13
+ Object.keys(this._buckets).forEach((key)=>{
14
+ const newTokens = this._getBucket(key) + this._refillRate;
15
+ if (newTokens >= this._bucketSize) delete this._buckets[key];
16
+ else this._setBucket(key, newTokens);
17
+ });
18
+ };
19
+ this._getBucket = (key)=>this._buckets[String(key)];
20
+ this._setBucket = (key, value)=>{
21
+ this._buckets[String(key)] = value;
22
+ };
23
+ this.consumeRateLimit = (key)=>{
24
+ var _this__getBucket;
25
+ let tokens = null != (_this__getBucket = this._getBucket(key)) ? _this__getBucket : this._bucketSize;
26
+ tokens = Math.max(tokens - 1, 0);
27
+ if (0 === tokens) return true;
28
+ this._setBucket(key, tokens);
29
+ const hasReachedZero = 0 === tokens;
30
+ if (hasReachedZero) {
31
+ var _this__onBucketRateLimited, _this;
32
+ null == (_this__onBucketRateLimited = (_this = this)._onBucketRateLimited) || _this__onBucketRateLimited.call(_this, key);
33
+ }
34
+ return hasReachedZero;
35
+ };
36
+ this._onBucketRateLimited = this._options._onBucketRateLimited;
37
+ this._bucketSize = clampToRange(this._options.bucketSize, 0, 100, this._options._logger);
38
+ this._refillRate = clampToRange(this._options.refillRate, 0, this._bucketSize, this._options._logger);
39
+ this._refillInterval = clampToRange(this._options.refillInterval, 0, 86400000, this._options._logger);
40
+ this._removeInterval = setInterval(()=>{
41
+ this._refillBuckets();
42
+ }, this._refillInterval);
43
+ }
44
+ }
45
+ export { BucketedRateLimiter };
@@ -1,4 +1,9 @@
1
- import { FetchLike } from './types';
1
+ import { FetchLike } from '../types';
2
+ export * from './bucketed-rate-limiter';
3
+ export * from './number-utils';
4
+ export * from './string-utils';
5
+ export * from './type-utils';
6
+ export * from './promise-queue';
2
7
  export declare const STRING_FORMAT = "utf8";
3
8
  export declare function assert(truthyValue: any, message: string): void;
4
9
  export declare function removeTrailingSlash(url: string): string;
@@ -21,4 +26,4 @@ export declare function allSettled<T>(promises: (Promise<T> | null | undefined)[
21
26
  status: 'rejected';
22
27
  reason: any;
23
28
  })[]>;
24
- //# sourceMappingURL=utils.d.ts.map
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAE/B,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,wBAAgB,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI9D;AASD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;CACtC;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAqB5F;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAOnE;AAGD,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAEtD,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAEzC,CAAA;AAED,wBAAgB,QAAQ,IAAI,SAAS,GAAG,SAAS,CAEhD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,OAAO,CAAC,CAAC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,CAAC,CAStF"}
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./bucketed-rate-limiter": function(module) {
4
+ module.exports = require("./bucketed-rate-limiter.js");
5
+ },
6
+ "./number-utils": function(module) {
7
+ module.exports = require("./number-utils.js");
8
+ },
9
+ "./promise-queue": function(module) {
10
+ module.exports = require("./promise-queue.js");
11
+ },
12
+ "./string-utils": function(module) {
13
+ module.exports = require("./string-utils.js");
14
+ },
15
+ "./type-utils": function(module) {
16
+ module.exports = require("./type-utils.js");
17
+ }
18
+ };
19
+ var __webpack_module_cache__ = {};
20
+ function __webpack_require__(moduleId) {
21
+ var cachedModule = __webpack_module_cache__[moduleId];
22
+ if (void 0 !== cachedModule) return cachedModule.exports;
23
+ var module = __webpack_module_cache__[moduleId] = {
24
+ exports: {}
25
+ };
26
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
27
+ return module.exports;
28
+ }
29
+ (()=>{
30
+ __webpack_require__.n = (module)=>{
31
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
32
+ __webpack_require__.d(getter, {
33
+ a: getter
34
+ });
35
+ return getter;
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.d = (exports1, definition)=>{
40
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
41
+ enumerable: true,
42
+ get: definition[key]
43
+ });
44
+ };
45
+ })();
46
+ (()=>{
47
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
48
+ })();
49
+ (()=>{
50
+ __webpack_require__.r = (exports1)=>{
51
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
52
+ value: 'Module'
53
+ });
54
+ Object.defineProperty(exports1, '__esModule', {
55
+ value: true
56
+ });
57
+ };
58
+ })();
59
+ var __webpack_exports__ = {};
60
+ (()=>{
61
+ __webpack_require__.r(__webpack_exports__);
62
+ __webpack_require__.d(__webpack_exports__, {
63
+ STRING_FORMAT: ()=>STRING_FORMAT,
64
+ allSettled: ()=>allSettled,
65
+ assert: ()=>assert,
66
+ currentISOTime: ()=>currentISOTime,
67
+ currentTimestamp: ()=>currentTimestamp,
68
+ getFetch: ()=>getFetch,
69
+ isError: ()=>isError,
70
+ isPromise: ()=>isPromise,
71
+ removeTrailingSlash: ()=>removeTrailingSlash,
72
+ retriable: ()=>retriable,
73
+ safeSetTimeout: ()=>safeSetTimeout
74
+ });
75
+ var _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./bucketed-rate-limiter");
76
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
77
+ for(var __WEBPACK_IMPORT_KEY__ in _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_0__)if ([
78
+ "removeTrailingSlash",
79
+ "retriable",
80
+ "default",
81
+ "currentISOTime",
82
+ "currentTimestamp",
83
+ "STRING_FORMAT",
84
+ "isError",
85
+ "safeSetTimeout",
86
+ "getFetch",
87
+ "isPromise",
88
+ "assert",
89
+ "allSettled"
90
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
91
+ return _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_0__[key];
92
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
93
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
94
+ var _number_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./number-utils");
95
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
96
+ for(var __WEBPACK_IMPORT_KEY__ in _number_utils__WEBPACK_IMPORTED_MODULE_1__)if ([
97
+ "removeTrailingSlash",
98
+ "retriable",
99
+ "default",
100
+ "currentISOTime",
101
+ "currentTimestamp",
102
+ "STRING_FORMAT",
103
+ "isError",
104
+ "safeSetTimeout",
105
+ "getFetch",
106
+ "isPromise",
107
+ "assert",
108
+ "allSettled"
109
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
110
+ return _number_utils__WEBPACK_IMPORTED_MODULE_1__[key];
111
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
112
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
113
+ var _string_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./string-utils");
114
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
115
+ for(var __WEBPACK_IMPORT_KEY__ in _string_utils__WEBPACK_IMPORTED_MODULE_2__)if ([
116
+ "removeTrailingSlash",
117
+ "retriable",
118
+ "default",
119
+ "currentISOTime",
120
+ "currentTimestamp",
121
+ "STRING_FORMAT",
122
+ "isError",
123
+ "safeSetTimeout",
124
+ "getFetch",
125
+ "isPromise",
126
+ "assert",
127
+ "allSettled"
128
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
129
+ return _string_utils__WEBPACK_IMPORTED_MODULE_2__[key];
130
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
131
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
132
+ var _type_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./type-utils");
133
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
134
+ for(var __WEBPACK_IMPORT_KEY__ in _type_utils__WEBPACK_IMPORTED_MODULE_3__)if ([
135
+ "removeTrailingSlash",
136
+ "retriable",
137
+ "default",
138
+ "currentISOTime",
139
+ "currentTimestamp",
140
+ "STRING_FORMAT",
141
+ "isError",
142
+ "safeSetTimeout",
143
+ "getFetch",
144
+ "isPromise",
145
+ "assert",
146
+ "allSettled"
147
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
148
+ return _type_utils__WEBPACK_IMPORTED_MODULE_3__[key];
149
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
150
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
151
+ var _promise_queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./promise-queue");
152
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
153
+ for(var __WEBPACK_IMPORT_KEY__ in _promise_queue__WEBPACK_IMPORTED_MODULE_4__)if ([
154
+ "removeTrailingSlash",
155
+ "retriable",
156
+ "default",
157
+ "currentISOTime",
158
+ "currentTimestamp",
159
+ "STRING_FORMAT",
160
+ "isError",
161
+ "safeSetTimeout",
162
+ "getFetch",
163
+ "isPromise",
164
+ "assert",
165
+ "allSettled"
166
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
167
+ return _promise_queue__WEBPACK_IMPORTED_MODULE_4__[key];
168
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
169
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
170
+ const STRING_FORMAT = 'utf8';
171
+ function assert(truthyValue, message) {
172
+ if (!truthyValue || 'string' != typeof truthyValue || isEmpty(truthyValue)) throw new Error(message);
173
+ }
174
+ function isEmpty(truthyValue) {
175
+ if (0 === truthyValue.trim().length) return true;
176
+ return false;
177
+ }
178
+ function removeTrailingSlash(url) {
179
+ return null == url ? void 0 : url.replace(/\/+$/, '');
180
+ }
181
+ async function retriable(fn, props) {
182
+ let lastError = null;
183
+ for(let i = 0; i < props.retryCount + 1; i++){
184
+ if (i > 0) await new Promise((r)=>setTimeout(r, props.retryDelay));
185
+ try {
186
+ const res = await fn();
187
+ return res;
188
+ } catch (e) {
189
+ lastError = e;
190
+ if (!props.retryCheck(e)) throw e;
191
+ }
192
+ }
193
+ throw lastError;
194
+ }
195
+ function currentTimestamp() {
196
+ return new Date().getTime();
197
+ }
198
+ function currentISOTime() {
199
+ return new Date().toISOString();
200
+ }
201
+ function safeSetTimeout(fn, timeout) {
202
+ const t = setTimeout(fn, timeout);
203
+ (null == t ? void 0 : t.unref) && (null == t || t.unref());
204
+ return t;
205
+ }
206
+ const isPromise = (obj)=>obj && 'function' == typeof obj.then;
207
+ const isError = (x)=>x instanceof Error;
208
+ function getFetch() {
209
+ return 'undefined' != typeof fetch ? fetch : void 0 !== globalThis.fetch ? globalThis.fetch : void 0;
210
+ }
211
+ function allSettled(promises) {
212
+ return Promise.all(promises.map((p)=>(null != p ? p : Promise.resolve()).then((value)=>({
213
+ status: 'fulfilled',
214
+ value
215
+ }), (reason)=>({
216
+ status: 'rejected',
217
+ reason
218
+ }))));
219
+ }
220
+ })();
221
+ exports.STRING_FORMAT = __webpack_exports__.STRING_FORMAT;
222
+ exports.allSettled = __webpack_exports__.allSettled;
223
+ exports.assert = __webpack_exports__.assert;
224
+ exports.currentISOTime = __webpack_exports__.currentISOTime;
225
+ exports.currentTimestamp = __webpack_exports__.currentTimestamp;
226
+ exports.getFetch = __webpack_exports__.getFetch;
227
+ exports.isError = __webpack_exports__.isError;
228
+ exports.isPromise = __webpack_exports__.isPromise;
229
+ exports.removeTrailingSlash = __webpack_exports__.removeTrailingSlash;
230
+ exports.retriable = __webpack_exports__.retriable;
231
+ exports.safeSetTimeout = __webpack_exports__.safeSetTimeout;
232
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
233
+ "STRING_FORMAT",
234
+ "allSettled",
235
+ "assert",
236
+ "currentISOTime",
237
+ "currentTimestamp",
238
+ "getFetch",
239
+ "isError",
240
+ "isPromise",
241
+ "removeTrailingSlash",
242
+ "retriable",
243
+ "safeSetTimeout"
244
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
245
+ Object.defineProperty(exports, '__esModule', {
246
+ value: true
247
+ });
@@ -1,3 +1,8 @@
1
+ export * from "./bucketed-rate-limiter.mjs";
2
+ export * from "./number-utils.mjs";
3
+ export * from "./string-utils.mjs";
4
+ export * from "./type-utils.mjs";
5
+ export * from "./promise-queue.mjs";
1
6
  const STRING_FORMAT = 'utf8';
2
7
  function assert(truthyValue, message) {
3
8
  if (!truthyValue || 'string' != typeof truthyValue || isEmpty(truthyValue)) throw new Error(message);
@@ -0,0 +1,11 @@
1
+ import { Logger } from '../types';
2
+ /**
3
+ * Clamps a value to a range.
4
+ * @param value the value to clamp
5
+ * @param min the minimum value
6
+ * @param max the maximum value
7
+ * @param label if provided then enables logging and prefixes all logs with labels
8
+ * @param fallbackValue if provided then returns this value if the value is not a valid number
9
+ */
10
+ export declare function clampToRange(value: unknown, min: number, max: number, logger: Logger, fallbackValue?: number): number;
11
+ //# sourceMappingURL=number-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-utils.d.ts","sourceRoot":"","sources":["../../src/utils/number-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAG9B;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBrH"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ clampToRange: ()=>clampToRange
28
+ });
29
+ const external_type_utils_js_namespaceObject = require("./type-utils.js");
30
+ function clampToRange(value, min, max, logger, fallbackValue) {
31
+ if (min > max) {
32
+ logger.warn('min cannot be greater than max.');
33
+ min = max;
34
+ }
35
+ if ((0, external_type_utils_js_namespaceObject.isNumber)(value)) if (value > max) {
36
+ logger.warn(' cannot be greater than max: ' + max + '. Using max value instead.');
37
+ return max;
38
+ } else {
39
+ if (!(value < min)) return value;
40
+ logger.warn(' cannot be less than min: ' + min + '. Using min value instead.');
41
+ return min;
42
+ }
43
+ logger.warn(' must be a number. using max or fallback. max: ' + max + ', fallback: ' + fallbackValue);
44
+ return clampToRange(fallbackValue || max, min, max, logger);
45
+ }
46
+ exports.clampToRange = __webpack_exports__.clampToRange;
47
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
48
+ "clampToRange"
49
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
50
+ Object.defineProperty(exports, '__esModule', {
51
+ value: true
52
+ });
@@ -0,0 +1,18 @@
1
+ import { isNumber } from "./type-utils.mjs";
2
+ function clampToRange(value, min, max, logger, fallbackValue) {
3
+ if (min > max) {
4
+ logger.warn('min cannot be greater than max.');
5
+ min = max;
6
+ }
7
+ if (isNumber(value)) if (value > max) {
8
+ logger.warn(' cannot be greater than max: ' + max + '. Using max value instead.');
9
+ return max;
10
+ } else {
11
+ if (!(value < min)) return value;
12
+ logger.warn(' cannot be less than min: ' + min + '. Using min value instead.');
13
+ return min;
14
+ }
15
+ logger.warn(' must be a number. using max or fallback. max: ' + max + ', fallback: ' + fallbackValue);
16
+ return clampToRange(fallbackValue || max, min, max, logger);
17
+ }
18
+ export { clampToRange };
@@ -0,0 +1,7 @@
1
+ export declare class PromiseQueue {
2
+ private promiseByIds;
3
+ add(promise: Promise<any>): Promise<any>;
4
+ join(): Promise<void>;
5
+ get length(): number;
6
+ }
7
+ //# sourceMappingURL=promise-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise-queue.d.ts","sourceRoot":"","sources":["../../src/utils/promise-queue.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAmC;IAEhD,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAWlC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlC,IAAW,MAAM,IAAI,MAAM,CAE1B;CACF"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ PromiseQueue: ()=>PromiseQueue
28
+ });
29
+ const uuidv7_js_namespaceObject = require("../vendor/uuidv7.js");
30
+ class PromiseQueue {
31
+ add(promise) {
32
+ const promiseUUID = (0, uuidv7_js_namespaceObject.uuidv7)();
33
+ this.promiseByIds[promiseUUID] = promise;
34
+ promise.catch(()=>{}).finally(()=>{
35
+ delete this.promiseByIds[promiseUUID];
36
+ });
37
+ return promise;
38
+ }
39
+ async join() {
40
+ let promises = Object.values(this.promiseByIds);
41
+ let length = promises.length;
42
+ while(length > 0){
43
+ await Promise.all(promises);
44
+ promises = Object.values(this.promiseByIds);
45
+ length = promises.length;
46
+ }
47
+ }
48
+ get length() {
49
+ return Object.keys(this.promiseByIds).length;
50
+ }
51
+ constructor(){
52
+ this.promiseByIds = {};
53
+ }
54
+ }
55
+ exports.PromiseQueue = __webpack_exports__.PromiseQueue;
56
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
57
+ "PromiseQueue"
58
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
59
+ Object.defineProperty(exports, '__esModule', {
60
+ value: true
61
+ });
@@ -0,0 +1,27 @@
1
+ import { uuidv7 } from "../vendor/uuidv7.mjs";
2
+ class PromiseQueue {
3
+ add(promise) {
4
+ const promiseUUID = uuidv7();
5
+ this.promiseByIds[promiseUUID] = promise;
6
+ promise.catch(()=>{}).finally(()=>{
7
+ delete this.promiseByIds[promiseUUID];
8
+ });
9
+ return promise;
10
+ }
11
+ async join() {
12
+ let promises = Object.values(this.promiseByIds);
13
+ let length = promises.length;
14
+ while(length > 0){
15
+ await Promise.all(promises);
16
+ promises = Object.values(this.promiseByIds);
17
+ length = promises.length;
18
+ }
19
+ }
20
+ get length() {
21
+ return Object.keys(this.promiseByIds).length;
22
+ }
23
+ constructor(){
24
+ this.promiseByIds = {};
25
+ }
26
+ }
27
+ export { PromiseQueue };
@@ -0,0 +1,6 @@
1
+ export declare function includes(str: string, needle: string): boolean;
2
+ export declare function includes<T>(arr: T[], needle: T): boolean;
3
+ export declare const trim: (str: string) => string;
4
+ export declare const stripLeadingDollar: (s: string) => string;
5
+ export declare function isDistinctIdStringLike(value: string): boolean;
6
+ //# sourceMappingURL=string-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../src/utils/string-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;AAC9D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAA;AAKzD,eAAO,MAAM,IAAI,GAAa,KAAK,MAAM,KAAG,MAM3C,CAAA;AAID,eAAO,MAAM,kBAAkB,GAAa,GAAG,MAAM,KAAG,MAEvD,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ includes: ()=>includes,
28
+ isDistinctIdStringLike: ()=>isDistinctIdStringLike,
29
+ stripLeadingDollar: ()=>stripLeadingDollar,
30
+ trim: ()=>trim
31
+ });
32
+ function includes(str, needle) {
33
+ return -1 !== str.indexOf(needle);
34
+ }
35
+ const trim = function(str) {
36
+ return str.trim();
37
+ };
38
+ const stripLeadingDollar = function(s) {
39
+ return s.replace(/^\$/, '');
40
+ };
41
+ function isDistinctIdStringLike(value) {
42
+ return [
43
+ 'distinct_id',
44
+ 'distinctid'
45
+ ].includes(value.toLowerCase());
46
+ }
47
+ exports.includes = __webpack_exports__.includes;
48
+ exports.isDistinctIdStringLike = __webpack_exports__.isDistinctIdStringLike;
49
+ exports.stripLeadingDollar = __webpack_exports__.stripLeadingDollar;
50
+ exports.trim = __webpack_exports__.trim;
51
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
52
+ "includes",
53
+ "isDistinctIdStringLike",
54
+ "stripLeadingDollar",
55
+ "trim"
56
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
57
+ Object.defineProperty(exports, '__esModule', {
58
+ value: true
59
+ });
@@ -0,0 +1,16 @@
1
+ function includes(str, needle) {
2
+ return -1 !== str.indexOf(needle);
3
+ }
4
+ const trim = function(str) {
5
+ return str.trim();
6
+ };
7
+ const stripLeadingDollar = function(s) {
8
+ return s.replace(/^\$/, '');
9
+ };
10
+ function isDistinctIdStringLike(value) {
11
+ return [
12
+ 'distinct_id',
13
+ 'distinctid'
14
+ ].includes(value.toLowerCase());
15
+ }
16
+ export { includes, isDistinctIdStringLike, stripLeadingDollar, trim };
@@ -0,0 +1,23 @@
1
+ import { KnownUnsafeEditableEvent } from '../types';
2
+ export declare const hasOwnProperty: (v: PropertyKey) => boolean;
3
+ export declare const isArray: (arg: any) => arg is any[];
4
+ export declare const isFunction: (x: unknown) => x is (...args: any[]) => any;
5
+ export declare const isNativeFunction: (x: unknown) => x is (...args: any[]) => any;
6
+ export declare const isObject: (x: unknown) => x is Record<string, any>;
7
+ export declare const isEmptyObject: (x: unknown) => boolean;
8
+ export declare const isUndefined: (x: unknown) => x is undefined;
9
+ export declare const isString: (x: unknown) => x is string;
10
+ export declare const isEmptyString: (x: unknown) => boolean;
11
+ export declare const isNull: (x: unknown) => x is null;
12
+ export declare const isNullish: (x: unknown) => x is null | undefined;
13
+ export declare const isNumber: (x: unknown) => x is number;
14
+ export declare const isBoolean: (x: unknown) => x is boolean;
15
+ export declare const isFormData: (x: unknown) => x is FormData;
16
+ export declare const isFile: (x: unknown) => x is File;
17
+ export declare const isError: (x: unknown) => x is Error;
18
+ export declare const isKnownUnsafeEditableEvent: (x: unknown) => x is KnownUnsafeEditableEvent;
19
+ export declare const yesLikeValues: (string | number | boolean)[];
20
+ export declare const isYesLike: (val: string | boolean | number) => boolean;
21
+ export declare const noLikeValues: (string | number | boolean)[];
22
+ export declare const isNoLike: (val: string | boolean | number) => boolean;
23
+ //# sourceMappingURL=type-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../src/utils/type-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAM7E,eAAO,MAAM,cAAc,6BAA0B,CAAA;AAGrD,eAAO,MAAM,OAAO,4BAIjB,CAAA;AAKH,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAGhE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GACR,CAAA;AAG/D,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAG5D,CAAA;AACD,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,YAUvC,CAAA;AACD,eAAO,MAAM,WAAW,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,SAAyB,CAAA;AAEvE,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAG1C,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,OAA+C,CAAA;AAE1F,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,IAGxC,CAAA;AAMD,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,IAAI,GAAG,SAAwC,CAAA;AAE3F,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAG1C,CAAA;AACD,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,OAG3C,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,QAG5C,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,IAGxC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAEzC,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,wBAE5D,CAAA;AAED,eAAO,MAAM,aAAa,+BAAgC,CAAA;AAC1D,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,OAAO,GAAG,MAAM,KAAG,OAAuC,CAAA;AAClG,eAAO,MAAM,YAAY,+BAAiC,CAAA;AAC1D,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,GAAG,OAAO,GAAG,MAAM,KAAG,OAAsC,CAAA"}