@atsignal/js-core 0.1.2 → 0.2.0
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 +34 -36
- package/dist/index.d.cts +6 -16
- package/dist/index.d.ts +6 -16
- package/dist/index.js +34 -36
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -188,14 +188,17 @@ var SnapshotQueueStorage = class {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
// src/timers.ts
|
|
191
|
-
function resolveTimerApi(
|
|
192
|
-
const timers =
|
|
191
|
+
function resolveTimerApi() {
|
|
192
|
+
const timers = globalThis;
|
|
193
193
|
const maybeSetTimeout = timers == null ? void 0 : timers.setTimeout;
|
|
194
194
|
const maybeClearTimeout = timers == null ? void 0 : timers.clearTimeout;
|
|
195
195
|
if (typeof maybeSetTimeout !== "function" || typeof maybeClearTimeout !== "function") {
|
|
196
196
|
return null;
|
|
197
197
|
}
|
|
198
|
-
return
|
|
198
|
+
return {
|
|
199
|
+
setTimeout: maybeSetTimeout.bind(timers),
|
|
200
|
+
clearTimeout: maybeClearTimeout.bind(timers)
|
|
201
|
+
};
|
|
199
202
|
}
|
|
200
203
|
function scheduleTask(callback, delayMs, timers) {
|
|
201
204
|
const handle = timers.setTimeout(callback, delayMs);
|
|
@@ -223,11 +226,12 @@ function createTimeoutController(timeoutMs, createTimeoutValue, timers) {
|
|
|
223
226
|
|
|
224
227
|
// src/transport.ts
|
|
225
228
|
function resolveGlobalFetch() {
|
|
226
|
-
const
|
|
229
|
+
const globalObject = globalThis;
|
|
230
|
+
const candidate = globalObject.fetch;
|
|
227
231
|
if (typeof candidate !== "function") {
|
|
228
232
|
return null;
|
|
229
233
|
}
|
|
230
|
-
return candidate;
|
|
234
|
+
return candidate.bind(globalObject);
|
|
231
235
|
}
|
|
232
236
|
function encodeRequestBody(request) {
|
|
233
237
|
const parts = [
|
|
@@ -254,12 +258,16 @@ function encodeRequestBody(request) {
|
|
|
254
258
|
return parts.join("&");
|
|
255
259
|
}
|
|
256
260
|
var FetchTransport = class {
|
|
257
|
-
constructor(
|
|
261
|
+
constructor(options = {}) {
|
|
258
262
|
var _a, _b, _c;
|
|
259
263
|
const fetchImpl = (_a = options.fetch) != null ? _a : resolveGlobalFetch();
|
|
264
|
+
const timers = resolveTimerApi();
|
|
260
265
|
if (!fetchImpl) {
|
|
261
266
|
throw new Error("No fetch implementation found for FetchTransport");
|
|
262
267
|
}
|
|
268
|
+
if (!timers) {
|
|
269
|
+
throw new Error("No timer implementation found for FetchTransport");
|
|
270
|
+
}
|
|
263
271
|
this._fetch = fetchImpl;
|
|
264
272
|
this._keepalive = (_b = options.keepalive) != null ? _b : false;
|
|
265
273
|
this._headers = (_c = options.headers) != null ? _c : {};
|
|
@@ -311,7 +319,7 @@ var FetchTransport = class {
|
|
|
311
319
|
}
|
|
312
320
|
};
|
|
313
321
|
function createFetchTransport(options = {}) {
|
|
314
|
-
return
|
|
322
|
+
return new FetchTransport(options);
|
|
315
323
|
}
|
|
316
324
|
|
|
317
325
|
// src/client-config.ts
|
|
@@ -420,38 +428,28 @@ function createQueueStorage(storage) {
|
|
|
420
428
|
}
|
|
421
429
|
return new SnapshotQueueStorage(storage, QUEUE_STORAGE_KEY);
|
|
422
430
|
}
|
|
423
|
-
function
|
|
424
|
-
const timers = resolveTimerApi(runtime == null ? void 0 : runtime.timers);
|
|
425
|
-
if (!timers) {
|
|
426
|
-
throw new Error("Signal client requires a timer implementation");
|
|
427
|
-
}
|
|
428
|
-
return {
|
|
429
|
-
timers
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
function normalizeConfig(apiKey, config, runtime) {
|
|
431
|
+
function normalizeConfig(apiKey, config) {
|
|
433
432
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
434
433
|
if (!apiKey) {
|
|
435
434
|
throw new Error("Signal client requires apiKey");
|
|
436
435
|
}
|
|
437
|
-
const persistQueue = (_a = config.persistQueue) != null ? _a :
|
|
436
|
+
const persistQueue = (_a = config.persistQueue) != null ? _a : false;
|
|
438
437
|
const initialIdentityOverrides = {
|
|
439
438
|
userId: resolveInitialUserId(config.userId),
|
|
440
439
|
deviceId: resolveInitialDeviceId(config.deviceId)
|
|
441
440
|
};
|
|
442
|
-
const transportFactory = (_b = config.transportFactory) != null ? _b : createFetchTransport();
|
|
443
441
|
return {
|
|
444
442
|
apiKey,
|
|
445
443
|
resolvedConfig: {
|
|
446
|
-
endpoint: (
|
|
444
|
+
endpoint: (_b = config.endpoint) != null ? _b : DEFAULT_ENDPOINT,
|
|
447
445
|
flushIntervalMs: toInteger(config.flushIntervalMs, DEFAULT_FLUSH_INTERVAL_MS),
|
|
448
446
|
maxBatchSize: toInteger(config.maxBatchSize, DEFAULT_MAX_BATCH_SIZE),
|
|
449
447
|
maxQueueSize: toInteger(config.maxQueueSize, DEFAULT_MAX_QUEUE_SIZE),
|
|
450
448
|
retry: {
|
|
451
|
-
baseMs: toInteger((
|
|
452
|
-
maxMs: toInteger((
|
|
453
|
-
maxAttempts: toInteger((
|
|
454
|
-
jitter: typeof ((
|
|
449
|
+
baseMs: toInteger((_c = config.retry) == null ? void 0 : _c.baseMs, DEFAULT_RETRY_BASE_MS),
|
|
450
|
+
maxMs: toInteger((_d = config.retry) == null ? void 0 : _d.maxMs, DEFAULT_RETRY_MAX_MS),
|
|
451
|
+
maxAttempts: toInteger((_e = config.retry) == null ? void 0 : _e.maxAttempts, DEFAULT_RETRY_ATTEMPTS),
|
|
452
|
+
jitter: typeof ((_f = config.retry) == null ? void 0 : _f.jitter) === "number" ? config.retry.jitter : DEFAULT_RETRY_JITTER
|
|
455
453
|
},
|
|
456
454
|
persistQueue,
|
|
457
455
|
locationFromIp: resolveLocationFromIp(config.locationFromIp),
|
|
@@ -461,10 +459,10 @@ function normalizeConfig(apiKey, config, runtime) {
|
|
|
461
459
|
blockedProperties: resolveBlockedProperties(config.blockedProperties)
|
|
462
460
|
},
|
|
463
461
|
storage: {
|
|
464
|
-
identity: createIdentityStorage((
|
|
465
|
-
queue: persistQueue ? createQueueStorage((
|
|
462
|
+
identity: createIdentityStorage((_g = config.storage) == null ? void 0 : _g.identity),
|
|
463
|
+
queue: persistQueue ? createQueueStorage((_h = config.storage) == null ? void 0 : _h.queue) : NOOP_QUEUE_STORAGE
|
|
466
464
|
},
|
|
467
|
-
transport:
|
|
465
|
+
transport: (_i = config.transport) != null ? _i : createFetchTransport(),
|
|
468
466
|
plugins: (_j = config.plugins) != null ? _j : [],
|
|
469
467
|
initialIdentityOverrides
|
|
470
468
|
};
|
|
@@ -988,10 +986,12 @@ var SignalClient = class {
|
|
|
988
986
|
}
|
|
989
987
|
this._state = "initializing";
|
|
990
988
|
try {
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
989
|
+
const timers = resolveTimerApi();
|
|
990
|
+
if (!timers) {
|
|
991
|
+
throw new Error("Signal client requires a timer implementation");
|
|
992
|
+
}
|
|
993
|
+
const normalized = normalizeConfig(apiKey, this.resolveInitConfig(options));
|
|
994
|
+
this._timers = timers;
|
|
995
995
|
this._applyNormalizedConfig(normalized);
|
|
996
996
|
this._ready = this._initialize(normalized.initialIdentityOverrides);
|
|
997
997
|
await this._ready;
|
|
@@ -1426,7 +1426,6 @@ var SignalClient = class {
|
|
|
1426
1426
|
const dropped = this._enqueue(entry);
|
|
1427
1427
|
queuedResults.push({
|
|
1428
1428
|
entry,
|
|
1429
|
-
queuedEvents: this._queue.length,
|
|
1430
1429
|
request
|
|
1431
1430
|
});
|
|
1432
1431
|
if (dropped) {
|
|
@@ -1438,11 +1437,10 @@ var SignalClient = class {
|
|
|
1438
1437
|
if (droppedIds.length > 0) {
|
|
1439
1438
|
await this._removeQueueEntries(droppedIds);
|
|
1440
1439
|
}
|
|
1441
|
-
for (const { entry,
|
|
1440
|
+
for (const { entry, request } of queuedResults) {
|
|
1442
1441
|
await this._hooks.emitEventQueued({
|
|
1443
1442
|
event: entry.event,
|
|
1444
|
-
options: entry.options
|
|
1445
|
-
queuedEvents
|
|
1443
|
+
options: entry.options
|
|
1446
1444
|
});
|
|
1447
1445
|
if (!request.waitForImmediateFlush) {
|
|
1448
1446
|
request.completion.resolve(void 0);
|
|
@@ -1665,7 +1663,7 @@ var SignalClient = class {
|
|
|
1665
1663
|
enqueueAutomaticFlush();
|
|
1666
1664
|
},
|
|
1667
1665
|
delayMs,
|
|
1668
|
-
this.
|
|
1666
|
+
this._timers
|
|
1669
1667
|
);
|
|
1670
1668
|
this._flushTask = task;
|
|
1671
1669
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -95,14 +95,6 @@ interface Transport {
|
|
|
95
95
|
flush?(): Promise<void>;
|
|
96
96
|
shutdown?(): Promise<void>;
|
|
97
97
|
}
|
|
98
|
-
interface TimerApi {
|
|
99
|
-
setTimeout(callback: () => void, delayMs: number): unknown;
|
|
100
|
-
clearTimeout(handle: unknown): void;
|
|
101
|
-
}
|
|
102
|
-
interface ClientRuntime {
|
|
103
|
-
timers: TimerApi;
|
|
104
|
-
}
|
|
105
|
-
type TransportFactory = (runtime: Readonly<ClientRuntime>) => Transport;
|
|
106
98
|
interface ClientIdentity {
|
|
107
99
|
userId: string | null;
|
|
108
100
|
deviceId: string;
|
|
@@ -147,7 +139,6 @@ interface BeforeEnqueueHookContext {
|
|
|
147
139
|
interface EventQueuedHookContext {
|
|
148
140
|
event: Readonly<TrackedEvent>;
|
|
149
141
|
options: Readonly<ResolvedTrackOptions>;
|
|
150
|
-
queuedEvents: number;
|
|
151
142
|
}
|
|
152
143
|
interface BeforeFlushHookContext {
|
|
153
144
|
reason: FlushReason;
|
|
@@ -242,8 +233,8 @@ interface ClientConfig {
|
|
|
242
233
|
retry?: RetryConfig;
|
|
243
234
|
/**
|
|
244
235
|
* Queue durability toggle.
|
|
245
|
-
* `true
|
|
246
|
-
* `false
|
|
236
|
+
* `true`: persist queue using configured `storage.queue`.
|
|
237
|
+
* `false` (default): keep queue in memory only.
|
|
247
238
|
*/
|
|
248
239
|
persistQueue?: boolean;
|
|
249
240
|
partId?: string;
|
|
@@ -254,8 +245,7 @@ interface ClientConfig {
|
|
|
254
245
|
blockedProperties?: readonly string[];
|
|
255
246
|
plugins?: ClientPlugin[];
|
|
256
247
|
storage?: Partial<ClientStorageConfig>;
|
|
257
|
-
|
|
258
|
-
transportFactory?: TransportFactory;
|
|
248
|
+
transport?: Transport;
|
|
259
249
|
}
|
|
260
250
|
|
|
261
251
|
declare class SignalClient<TInitOptions extends object = ClientConfig> {
|
|
@@ -263,7 +253,7 @@ declare class SignalClient<TInitOptions extends object = ClientConfig> {
|
|
|
263
253
|
private _config;
|
|
264
254
|
private _storage;
|
|
265
255
|
private _transport;
|
|
266
|
-
private
|
|
256
|
+
private _timers;
|
|
267
257
|
private _hooks;
|
|
268
258
|
private _insertIdGenerator;
|
|
269
259
|
private _pluginRuntime;
|
|
@@ -406,6 +396,6 @@ interface FetchTransportOptions {
|
|
|
406
396
|
keepalive?: boolean;
|
|
407
397
|
headers?: Record<string, string>;
|
|
408
398
|
}
|
|
409
|
-
declare function createFetchTransport(options?: FetchTransportOptions):
|
|
399
|
+
declare function createFetchTransport(options?: FetchTransportOptions): Transport;
|
|
410
400
|
|
|
411
|
-
export { type ClientConfig, type ClientHooks, type ClientIdentity, type ClientPlugin, type
|
|
401
|
+
export { type ClientConfig, type ClientHooks, type ClientIdentity, type ClientPlugin, type FlushMode, type FlushReason, HookRegistry, InMemoryStorage, type KeyValueStorage, type PersistedQueueEntry, type PluginSetupContext, type QueueStorage, type QueueStorageInput, type ResolvedClientConfig, type RetryConfig, SignalClient, type TrackOptions, type TrackProperties, type TrackedEvent, type Transport, type TransportEventGroup, type TransportRequest, type TransportResult, createFetchTransport };
|
package/dist/index.d.ts
CHANGED
|
@@ -95,14 +95,6 @@ interface Transport {
|
|
|
95
95
|
flush?(): Promise<void>;
|
|
96
96
|
shutdown?(): Promise<void>;
|
|
97
97
|
}
|
|
98
|
-
interface TimerApi {
|
|
99
|
-
setTimeout(callback: () => void, delayMs: number): unknown;
|
|
100
|
-
clearTimeout(handle: unknown): void;
|
|
101
|
-
}
|
|
102
|
-
interface ClientRuntime {
|
|
103
|
-
timers: TimerApi;
|
|
104
|
-
}
|
|
105
|
-
type TransportFactory = (runtime: Readonly<ClientRuntime>) => Transport;
|
|
106
98
|
interface ClientIdentity {
|
|
107
99
|
userId: string | null;
|
|
108
100
|
deviceId: string;
|
|
@@ -147,7 +139,6 @@ interface BeforeEnqueueHookContext {
|
|
|
147
139
|
interface EventQueuedHookContext {
|
|
148
140
|
event: Readonly<TrackedEvent>;
|
|
149
141
|
options: Readonly<ResolvedTrackOptions>;
|
|
150
|
-
queuedEvents: number;
|
|
151
142
|
}
|
|
152
143
|
interface BeforeFlushHookContext {
|
|
153
144
|
reason: FlushReason;
|
|
@@ -242,8 +233,8 @@ interface ClientConfig {
|
|
|
242
233
|
retry?: RetryConfig;
|
|
243
234
|
/**
|
|
244
235
|
* Queue durability toggle.
|
|
245
|
-
* `true
|
|
246
|
-
* `false
|
|
236
|
+
* `true`: persist queue using configured `storage.queue`.
|
|
237
|
+
* `false` (default): keep queue in memory only.
|
|
247
238
|
*/
|
|
248
239
|
persistQueue?: boolean;
|
|
249
240
|
partId?: string;
|
|
@@ -254,8 +245,7 @@ interface ClientConfig {
|
|
|
254
245
|
blockedProperties?: readonly string[];
|
|
255
246
|
plugins?: ClientPlugin[];
|
|
256
247
|
storage?: Partial<ClientStorageConfig>;
|
|
257
|
-
|
|
258
|
-
transportFactory?: TransportFactory;
|
|
248
|
+
transport?: Transport;
|
|
259
249
|
}
|
|
260
250
|
|
|
261
251
|
declare class SignalClient<TInitOptions extends object = ClientConfig> {
|
|
@@ -263,7 +253,7 @@ declare class SignalClient<TInitOptions extends object = ClientConfig> {
|
|
|
263
253
|
private _config;
|
|
264
254
|
private _storage;
|
|
265
255
|
private _transport;
|
|
266
|
-
private
|
|
256
|
+
private _timers;
|
|
267
257
|
private _hooks;
|
|
268
258
|
private _insertIdGenerator;
|
|
269
259
|
private _pluginRuntime;
|
|
@@ -406,6 +396,6 @@ interface FetchTransportOptions {
|
|
|
406
396
|
keepalive?: boolean;
|
|
407
397
|
headers?: Record<string, string>;
|
|
408
398
|
}
|
|
409
|
-
declare function createFetchTransport(options?: FetchTransportOptions):
|
|
399
|
+
declare function createFetchTransport(options?: FetchTransportOptions): Transport;
|
|
410
400
|
|
|
411
|
-
export { type ClientConfig, type ClientHooks, type ClientIdentity, type ClientPlugin, type
|
|
401
|
+
export { type ClientConfig, type ClientHooks, type ClientIdentity, type ClientPlugin, type FlushMode, type FlushReason, HookRegistry, InMemoryStorage, type KeyValueStorage, type PersistedQueueEntry, type PluginSetupContext, type QueueStorage, type QueueStorageInput, type ResolvedClientConfig, type RetryConfig, SignalClient, type TrackOptions, type TrackProperties, type TrackedEvent, type Transport, type TransportEventGroup, type TransportRequest, type TransportResult, createFetchTransport };
|
package/dist/index.js
CHANGED
|
@@ -159,14 +159,17 @@ var SnapshotQueueStorage = class {
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
// src/timers.ts
|
|
162
|
-
function resolveTimerApi(
|
|
163
|
-
const timers =
|
|
162
|
+
function resolveTimerApi() {
|
|
163
|
+
const timers = globalThis;
|
|
164
164
|
const maybeSetTimeout = timers == null ? void 0 : timers.setTimeout;
|
|
165
165
|
const maybeClearTimeout = timers == null ? void 0 : timers.clearTimeout;
|
|
166
166
|
if (typeof maybeSetTimeout !== "function" || typeof maybeClearTimeout !== "function") {
|
|
167
167
|
return null;
|
|
168
168
|
}
|
|
169
|
-
return
|
|
169
|
+
return {
|
|
170
|
+
setTimeout: maybeSetTimeout.bind(timers),
|
|
171
|
+
clearTimeout: maybeClearTimeout.bind(timers)
|
|
172
|
+
};
|
|
170
173
|
}
|
|
171
174
|
function scheduleTask(callback, delayMs, timers) {
|
|
172
175
|
const handle = timers.setTimeout(callback, delayMs);
|
|
@@ -194,11 +197,12 @@ function createTimeoutController(timeoutMs, createTimeoutValue, timers) {
|
|
|
194
197
|
|
|
195
198
|
// src/transport.ts
|
|
196
199
|
function resolveGlobalFetch() {
|
|
197
|
-
const
|
|
200
|
+
const globalObject = globalThis;
|
|
201
|
+
const candidate = globalObject.fetch;
|
|
198
202
|
if (typeof candidate !== "function") {
|
|
199
203
|
return null;
|
|
200
204
|
}
|
|
201
|
-
return candidate;
|
|
205
|
+
return candidate.bind(globalObject);
|
|
202
206
|
}
|
|
203
207
|
function encodeRequestBody(request) {
|
|
204
208
|
const parts = [
|
|
@@ -225,12 +229,16 @@ function encodeRequestBody(request) {
|
|
|
225
229
|
return parts.join("&");
|
|
226
230
|
}
|
|
227
231
|
var FetchTransport = class {
|
|
228
|
-
constructor(
|
|
232
|
+
constructor(options = {}) {
|
|
229
233
|
var _a, _b, _c;
|
|
230
234
|
const fetchImpl = (_a = options.fetch) != null ? _a : resolveGlobalFetch();
|
|
235
|
+
const timers = resolveTimerApi();
|
|
231
236
|
if (!fetchImpl) {
|
|
232
237
|
throw new Error("No fetch implementation found for FetchTransport");
|
|
233
238
|
}
|
|
239
|
+
if (!timers) {
|
|
240
|
+
throw new Error("No timer implementation found for FetchTransport");
|
|
241
|
+
}
|
|
234
242
|
this._fetch = fetchImpl;
|
|
235
243
|
this._keepalive = (_b = options.keepalive) != null ? _b : false;
|
|
236
244
|
this._headers = (_c = options.headers) != null ? _c : {};
|
|
@@ -282,7 +290,7 @@ var FetchTransport = class {
|
|
|
282
290
|
}
|
|
283
291
|
};
|
|
284
292
|
function createFetchTransport(options = {}) {
|
|
285
|
-
return
|
|
293
|
+
return new FetchTransport(options);
|
|
286
294
|
}
|
|
287
295
|
|
|
288
296
|
// src/client-config.ts
|
|
@@ -391,38 +399,28 @@ function createQueueStorage(storage) {
|
|
|
391
399
|
}
|
|
392
400
|
return new SnapshotQueueStorage(storage, QUEUE_STORAGE_KEY);
|
|
393
401
|
}
|
|
394
|
-
function
|
|
395
|
-
const timers = resolveTimerApi(runtime == null ? void 0 : runtime.timers);
|
|
396
|
-
if (!timers) {
|
|
397
|
-
throw new Error("Signal client requires a timer implementation");
|
|
398
|
-
}
|
|
399
|
-
return {
|
|
400
|
-
timers
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
function normalizeConfig(apiKey, config, runtime) {
|
|
402
|
+
function normalizeConfig(apiKey, config) {
|
|
404
403
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
405
404
|
if (!apiKey) {
|
|
406
405
|
throw new Error("Signal client requires apiKey");
|
|
407
406
|
}
|
|
408
|
-
const persistQueue = (_a = config.persistQueue) != null ? _a :
|
|
407
|
+
const persistQueue = (_a = config.persistQueue) != null ? _a : false;
|
|
409
408
|
const initialIdentityOverrides = {
|
|
410
409
|
userId: resolveInitialUserId(config.userId),
|
|
411
410
|
deviceId: resolveInitialDeviceId(config.deviceId)
|
|
412
411
|
};
|
|
413
|
-
const transportFactory = (_b = config.transportFactory) != null ? _b : createFetchTransport();
|
|
414
412
|
return {
|
|
415
413
|
apiKey,
|
|
416
414
|
resolvedConfig: {
|
|
417
|
-
endpoint: (
|
|
415
|
+
endpoint: (_b = config.endpoint) != null ? _b : DEFAULT_ENDPOINT,
|
|
418
416
|
flushIntervalMs: toInteger(config.flushIntervalMs, DEFAULT_FLUSH_INTERVAL_MS),
|
|
419
417
|
maxBatchSize: toInteger(config.maxBatchSize, DEFAULT_MAX_BATCH_SIZE),
|
|
420
418
|
maxQueueSize: toInteger(config.maxQueueSize, DEFAULT_MAX_QUEUE_SIZE),
|
|
421
419
|
retry: {
|
|
422
|
-
baseMs: toInteger((
|
|
423
|
-
maxMs: toInteger((
|
|
424
|
-
maxAttempts: toInteger((
|
|
425
|
-
jitter: typeof ((
|
|
420
|
+
baseMs: toInteger((_c = config.retry) == null ? void 0 : _c.baseMs, DEFAULT_RETRY_BASE_MS),
|
|
421
|
+
maxMs: toInteger((_d = config.retry) == null ? void 0 : _d.maxMs, DEFAULT_RETRY_MAX_MS),
|
|
422
|
+
maxAttempts: toInteger((_e = config.retry) == null ? void 0 : _e.maxAttempts, DEFAULT_RETRY_ATTEMPTS),
|
|
423
|
+
jitter: typeof ((_f = config.retry) == null ? void 0 : _f.jitter) === "number" ? config.retry.jitter : DEFAULT_RETRY_JITTER
|
|
426
424
|
},
|
|
427
425
|
persistQueue,
|
|
428
426
|
locationFromIp: resolveLocationFromIp(config.locationFromIp),
|
|
@@ -432,10 +430,10 @@ function normalizeConfig(apiKey, config, runtime) {
|
|
|
432
430
|
blockedProperties: resolveBlockedProperties(config.blockedProperties)
|
|
433
431
|
},
|
|
434
432
|
storage: {
|
|
435
|
-
identity: createIdentityStorage((
|
|
436
|
-
queue: persistQueue ? createQueueStorage((
|
|
433
|
+
identity: createIdentityStorage((_g = config.storage) == null ? void 0 : _g.identity),
|
|
434
|
+
queue: persistQueue ? createQueueStorage((_h = config.storage) == null ? void 0 : _h.queue) : NOOP_QUEUE_STORAGE
|
|
437
435
|
},
|
|
438
|
-
transport:
|
|
436
|
+
transport: (_i = config.transport) != null ? _i : createFetchTransport(),
|
|
439
437
|
plugins: (_j = config.plugins) != null ? _j : [],
|
|
440
438
|
initialIdentityOverrides
|
|
441
439
|
};
|
|
@@ -959,10 +957,12 @@ var SignalClient = class {
|
|
|
959
957
|
}
|
|
960
958
|
this._state = "initializing";
|
|
961
959
|
try {
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
960
|
+
const timers = resolveTimerApi();
|
|
961
|
+
if (!timers) {
|
|
962
|
+
throw new Error("Signal client requires a timer implementation");
|
|
963
|
+
}
|
|
964
|
+
const normalized = normalizeConfig(apiKey, this.resolveInitConfig(options));
|
|
965
|
+
this._timers = timers;
|
|
966
966
|
this._applyNormalizedConfig(normalized);
|
|
967
967
|
this._ready = this._initialize(normalized.initialIdentityOverrides);
|
|
968
968
|
await this._ready;
|
|
@@ -1397,7 +1397,6 @@ var SignalClient = class {
|
|
|
1397
1397
|
const dropped = this._enqueue(entry);
|
|
1398
1398
|
queuedResults.push({
|
|
1399
1399
|
entry,
|
|
1400
|
-
queuedEvents: this._queue.length,
|
|
1401
1400
|
request
|
|
1402
1401
|
});
|
|
1403
1402
|
if (dropped) {
|
|
@@ -1409,11 +1408,10 @@ var SignalClient = class {
|
|
|
1409
1408
|
if (droppedIds.length > 0) {
|
|
1410
1409
|
await this._removeQueueEntries(droppedIds);
|
|
1411
1410
|
}
|
|
1412
|
-
for (const { entry,
|
|
1411
|
+
for (const { entry, request } of queuedResults) {
|
|
1413
1412
|
await this._hooks.emitEventQueued({
|
|
1414
1413
|
event: entry.event,
|
|
1415
|
-
options: entry.options
|
|
1416
|
-
queuedEvents
|
|
1414
|
+
options: entry.options
|
|
1417
1415
|
});
|
|
1418
1416
|
if (!request.waitForImmediateFlush) {
|
|
1419
1417
|
request.completion.resolve(void 0);
|
|
@@ -1636,7 +1634,7 @@ var SignalClient = class {
|
|
|
1636
1634
|
enqueueAutomaticFlush();
|
|
1637
1635
|
},
|
|
1638
1636
|
delayMs,
|
|
1639
|
-
this.
|
|
1637
|
+
this._timers
|
|
1640
1638
|
);
|
|
1641
1639
|
this._flushTask = task;
|
|
1642
1640
|
}
|