@forgeroute/ui 0.5.11 → 0.5.13

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.
@@ -177,6 +177,7 @@ function generateUuid() {
177
177
  }
178
178
  const ONLINE_DEBOUNCE_MS = 300;
179
179
  const PROBE_TIMEOUT_MS = 5e3;
180
+ const SLOW_RECOVERY_FAST_COUNT = 2;
180
181
  var ConnectionStateService = class ConnectionStateService {
181
182
  constructor() {
182
183
  this.cfg = resolveConfig(inject(OFFLINE_SUPPORT_CONFIG, { optional: true }) ?? { getUserId: () => null });
@@ -198,6 +199,7 @@ var ConnectionStateService = class ConnectionStateService {
198
199
  this.recovered$ = new Subject();
199
200
  this.failures = [];
200
201
  this.slowTimes = [];
202
+ this.fastStreak = 0;
201
203
  this.quietTimer = null;
202
204
  this.onlineTimer = null;
203
205
  this.probeTimer = null;
@@ -229,7 +231,12 @@ var ConnectionStateService = class ConnectionStateService {
229
231
  this.failures = [];
230
232
  if (this.unreachable()) this.clearUnreachable("online");
231
233
  if (info.long) return;
234
+ if (info.durationMs < this.cfg.slow.slowMs) {
235
+ this.fastStreak++;
236
+ if (this.slowFlag() && this.fastStreak >= SLOW_RECOVERY_FAST_COUNT) this.resetSlow();
237
+ }
232
238
  if (info.durationMs >= this.cfg.slow.slowMs) {
239
+ this.fastStreak = 0;
233
240
  this.slowTimes = this.slowTimes.filter((t) => now - t <= this.cfg.slow.windowMs);
234
241
  this.slowTimes.push(now);
235
242
  if (this.slowTimes.length >= this.cfg.slow.slowCount || this.slowFlag()) this.markSlow();
@@ -325,6 +332,7 @@ var ConnectionStateService = class ConnectionStateService {
325
332
  if (!this.unreachable()) return;
326
333
  this.unreachable.set(false);
327
334
  this.stopRecoveryTimers();
335
+ this.resetSlow();
328
336
  this.recompute();
329
337
  if (this.browserOnline()) this.recovered$.next(trigger);
330
338
  }
@@ -338,6 +346,17 @@ var ConnectionStateService = class ConnectionStateService {
338
346
  this.optimisticTimer = null;
339
347
  }
340
348
  }
349
+ resetSlow() {
350
+ this.fastStreak = 0;
351
+ this.slowTimes = [];
352
+ if (this.quietTimer) {
353
+ clearTimeout(this.quietTimer);
354
+ this.quietTimer = null;
355
+ }
356
+ if (!this.slowFlag()) return;
357
+ this.slowFlag.set(false);
358
+ this.recompute();
359
+ }
341
360
  markSlow() {
342
361
  this.slowFlag.set(true);
343
362
  if (this.quietTimer) clearTimeout(this.quietTimer);
@@ -371,6 +390,7 @@ var ConnectionStateService = class ConnectionStateService {
371
390
  this.unreachable.set(false);
372
391
  this.stopRecoveryTimers();
373
392
  }
393
+ this.resetSlow();
374
394
  this.recompute();
375
395
  this.recovered$.next("online");
376
396
  } else this.recompute();