@rdlabo/ionic-angular-kit 21.6.0 → 21.6.1
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/fesm2022/rdlabo-ionic-angular-kit-app-update.mjs +7 -11
- package/fesm2022/rdlabo-ionic-angular-kit-app-update.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs +31 -44
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase.mjs +28 -32
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +145 -142
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs +40 -27
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +131 -150
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -281,8 +281,7 @@ function findVisibleBottomTabBar() {
|
|
|
281
281
|
if (rect.height <= 0)
|
|
282
282
|
continue;
|
|
283
283
|
const slot = tabBar.getAttribute('slot');
|
|
284
|
-
const isBottom = slot === 'bottom' ||
|
|
285
|
-
(slot === null && rect.bottom >= window.innerHeight - BOTTOM_TAB_BAR_VIEWPORT_MARGIN_PX);
|
|
284
|
+
const isBottom = slot === 'bottom' || (slot === null && rect.bottom >= window.innerHeight - BOTTOM_TAB_BAR_VIEWPORT_MARGIN_PX);
|
|
286
285
|
if (!isBottom)
|
|
287
286
|
continue;
|
|
288
287
|
if (rect.bottom > bestBottom) {
|
|
@@ -433,7 +432,7 @@ class KitOverlayController {
|
|
|
433
432
|
return;
|
|
434
433
|
}
|
|
435
434
|
this.#alertPresenting = true;
|
|
436
|
-
|
|
435
|
+
const present = async () => {
|
|
437
436
|
const alert = await this.#alertCtrl.create({
|
|
438
437
|
header: options.header,
|
|
439
438
|
subHeader: options.subHeader,
|
|
@@ -442,10 +441,8 @@ class KitOverlayController {
|
|
|
442
441
|
});
|
|
443
442
|
await alert.present();
|
|
444
443
|
await alert.onWillDismiss();
|
|
445
|
-
}
|
|
446
|
-
finally
|
|
447
|
-
this.#alertPresenting = false;
|
|
448
|
-
}
|
|
444
|
+
};
|
|
445
|
+
await present().finally(() => (this.#alertPresenting = false));
|
|
449
446
|
}
|
|
450
447
|
/**
|
|
451
448
|
* Present a confirmation alert with cancel and OK buttons.
|
|
@@ -472,7 +469,7 @@ class KitOverlayController {
|
|
|
472
469
|
return false;
|
|
473
470
|
}
|
|
474
471
|
this.#alertPresenting = true;
|
|
475
|
-
|
|
472
|
+
const present = async () => {
|
|
476
473
|
const alert = await this.#alertCtrl.create({
|
|
477
474
|
header: options.header,
|
|
478
475
|
subHeader: options.subHeader,
|
|
@@ -485,10 +482,8 @@ class KitOverlayController {
|
|
|
485
482
|
await alert.present();
|
|
486
483
|
const { role } = await alert.onWillDismiss();
|
|
487
484
|
return role === 'confirm';
|
|
488
|
-
}
|
|
489
|
-
finally
|
|
490
|
-
this.#alertPresenting = false;
|
|
491
|
-
}
|
|
485
|
+
};
|
|
486
|
+
return present().finally(() => (this.#alertPresenting = false));
|
|
492
487
|
}
|
|
493
488
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: KitOverlayController, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
494
489
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: KitOverlayController, providedIn: 'root' }); }
|
|
@@ -500,6 +495,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
500
495
|
}]
|
|
501
496
|
}] });
|
|
502
497
|
|
|
498
|
+
const settledLoadingOperation = async () => undefined;
|
|
503
499
|
/**
|
|
504
500
|
* Reference-counted wrapper around Ionic's `LoadingController` that keeps at most one loading
|
|
505
501
|
* indicator on screen across concurrent async work.
|
|
@@ -542,7 +538,7 @@ class KitLoadingController {
|
|
|
542
538
|
* Serializes present/dismiss operations. Each call chains onto this promise, runs after the
|
|
543
539
|
* previous operation has fully settled, then reads {@link #count} and acts accordingly.
|
|
544
540
|
*/
|
|
545
|
-
#queue =
|
|
541
|
+
#queue = settledLoadingOperation();
|
|
546
542
|
/**
|
|
547
543
|
* Show the loading indicator, or join the one already on screen.
|
|
548
544
|
*
|
|
@@ -550,25 +546,22 @@ class KitLoadingController {
|
|
|
550
546
|
* indicator (the `0 → 1` transition). Ignored while an indicator is already present.
|
|
551
547
|
* @returns a Promise that resolves once the indicator is on screen (or immediately when one already is)
|
|
552
548
|
*/
|
|
553
|
-
|
|
549
|
+
presentLoading(options = {}) {
|
|
554
550
|
this.#count++;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
catch (error) {
|
|
551
|
+
return this.#enqueue(async () => {
|
|
552
|
+
// Create only on the transition into "something is loading"; concurrent callers ride the same
|
|
553
|
+
// element. Re-check the count in case a dismiss already balanced this call while queued.
|
|
554
|
+
if (this.#count > 0 && this.#loading === null) {
|
|
555
|
+
const loading = await this.#loadingCtrl.create(options);
|
|
556
|
+
await loading.present();
|
|
557
|
+
this.#loading = loading;
|
|
558
|
+
}
|
|
559
|
+
}).catch((error) => {
|
|
567
560
|
// Roll back the reference this call took: a failed create/present must not leave the counter
|
|
568
561
|
// elevated, otherwise a later cycle never reaches N → 0 and the spinner stays stuck on screen.
|
|
569
562
|
this.#count--;
|
|
570
563
|
throw error;
|
|
571
|
-
}
|
|
564
|
+
});
|
|
572
565
|
}
|
|
573
566
|
/**
|
|
574
567
|
* Release one reference; dismiss the indicator once the last reference is gone.
|
|
@@ -1335,13 +1328,11 @@ class KitAuthRecoveryService {
|
|
|
1335
1328
|
}));
|
|
1336
1329
|
}
|
|
1337
1330
|
/** Run one ordered remote recovery attempt, coalescing concurrent triggers. */
|
|
1338
|
-
recover() {
|
|
1331
|
+
async recover() {
|
|
1339
1332
|
if (this.#destroyed)
|
|
1340
|
-
return
|
|
1333
|
+
return;
|
|
1341
1334
|
if (this.#recovery) {
|
|
1342
|
-
if (this.#access.mode === 'local' &&
|
|
1343
|
-
this.#recoveryRevision !== null &&
|
|
1344
|
-
this.#access.revision > this.#recoveryRevision) {
|
|
1335
|
+
if (this.#access.mode === 'local' && this.#recoveryRevision !== null && this.#access.revision > this.#recoveryRevision) {
|
|
1345
1336
|
this.#retryRequested = true;
|
|
1346
1337
|
}
|
|
1347
1338
|
return this.#recovery;
|
|
@@ -1377,7 +1368,7 @@ class KitAuthRecoveryService {
|
|
|
1377
1368
|
const lease = this.#access.beginTransition();
|
|
1378
1369
|
let currentLease = lease;
|
|
1379
1370
|
const isCurrent = () => currentLease.isCurrent();
|
|
1380
|
-
|
|
1371
|
+
const executeRecovery = async () => {
|
|
1381
1372
|
const result = await recovery.reauthenticate(lease);
|
|
1382
1373
|
if (this.#destroyed || !isCurrent() || this.#access.mode !== 'local')
|
|
1383
1374
|
return;
|
|
@@ -1386,10 +1377,7 @@ class KitAuthRecoveryService {
|
|
|
1386
1377
|
this.#access.clear();
|
|
1387
1378
|
return;
|
|
1388
1379
|
}
|
|
1389
|
-
if (!(await result.activate(lease)) ||
|
|
1390
|
-
this.#destroyed ||
|
|
1391
|
-
!isCurrent() ||
|
|
1392
|
-
this.#access.mode !== 'local') {
|
|
1380
|
+
if (!(await result.activate(lease)) || this.#destroyed || !isCurrent() || this.#access.mode !== 'local') {
|
|
1393
1381
|
return;
|
|
1394
1382
|
}
|
|
1395
1383
|
this.#clearRetry();
|
|
@@ -1397,8 +1385,8 @@ class KitAuthRecoveryService {
|
|
|
1397
1385
|
if (!currentLease.isCurrent())
|
|
1398
1386
|
return;
|
|
1399
1387
|
await result.resume(currentLease);
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1388
|
+
};
|
|
1389
|
+
await executeRecovery().catch((error) => {
|
|
1402
1390
|
if (this.#destroyed || !isCurrent())
|
|
1403
1391
|
return;
|
|
1404
1392
|
if (isExplicitAuthDenial(error)) {
|
|
@@ -1411,7 +1399,7 @@ class KitAuthRecoveryService {
|
|
|
1411
1399
|
else {
|
|
1412
1400
|
this.#errorHandler.handleError(error);
|
|
1413
1401
|
}
|
|
1414
|
-
}
|
|
1402
|
+
});
|
|
1415
1403
|
}
|
|
1416
1404
|
#scheduleRetry() {
|
|
1417
1405
|
const recovery = this.#config.remoteRecovery;
|
|
@@ -1600,7 +1588,7 @@ const kitRequireAuthorizedGuard = (_route, state) => {
|
|
|
1600
1588
|
return false;
|
|
1601
1589
|
};
|
|
1602
1590
|
const resolveUnavailable = async (error) => {
|
|
1603
|
-
|
|
1591
|
+
const resolveFallback = async () => {
|
|
1604
1592
|
const fallback = onUnavailable ? await onUnavailable(state, error, lease) : false;
|
|
1605
1593
|
if (!lease.isCurrent())
|
|
1606
1594
|
return false;
|
|
@@ -1612,13 +1600,13 @@ const kitRequireAuthorizedGuard = (_route, state) => {
|
|
|
1612
1600
|
return redirectUnauthorized();
|
|
1613
1601
|
access.clear();
|
|
1614
1602
|
return fallback;
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1603
|
+
};
|
|
1604
|
+
return resolveFallback().catch((fallbackError) => {
|
|
1617
1605
|
if (!lease.isCurrent())
|
|
1618
1606
|
return false;
|
|
1619
1607
|
access.clear();
|
|
1620
1608
|
throw fallbackError;
|
|
1621
|
-
}
|
|
1609
|
+
});
|
|
1622
1610
|
};
|
|
1623
1611
|
const resolveRemote = async (result) => {
|
|
1624
1612
|
if (!lease.isCurrent())
|
|
@@ -1629,19 +1617,18 @@ const kitRequireAuthorizedGuard = (_route, state) => {
|
|
|
1629
1617
|
const resumeLease = access.grantRemote();
|
|
1630
1618
|
if (!resumeLease.isCurrent())
|
|
1631
1619
|
return false;
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
}
|
|
1635
|
-
catch (error) {
|
|
1620
|
+
const resume = async () => result.resume(resumeLease);
|
|
1621
|
+
await resume().catch((error) => {
|
|
1636
1622
|
if (!resumeLease.isCurrent())
|
|
1637
|
-
return
|
|
1623
|
+
return;
|
|
1638
1624
|
if (isExplicitAuthDenial(error)) {
|
|
1639
1625
|
access.clear();
|
|
1640
1626
|
throw error;
|
|
1641
1627
|
}
|
|
1642
1628
|
if (!isUnavailableError?.(error))
|
|
1643
1629
|
throw error;
|
|
1644
|
-
|
|
1630
|
+
return;
|
|
1631
|
+
});
|
|
1645
1632
|
return resumeLease.isCurrent();
|
|
1646
1633
|
}
|
|
1647
1634
|
if (result === true)
|
|
@@ -1669,13 +1656,13 @@ const kitRequireAuthorizedGuard = (_route, state) => {
|
|
|
1669
1656
|
access.grantRemote();
|
|
1670
1657
|
return true;
|
|
1671
1658
|
}
|
|
1672
|
-
|
|
1659
|
+
const resolveAuthorized = async () => {
|
|
1673
1660
|
const result = await onAuthorized(state, lease);
|
|
1674
1661
|
if (!lease.isCurrent())
|
|
1675
1662
|
return false;
|
|
1676
|
-
return
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1663
|
+
return resolveRemote(result);
|
|
1664
|
+
};
|
|
1665
|
+
return resolveAuthorized().catch((error) => {
|
|
1679
1666
|
if (!lease.isCurrent())
|
|
1680
1667
|
return false;
|
|
1681
1668
|
if (isExplicitAuthDenial(error)) {
|
|
@@ -1685,7 +1672,7 @@ const kitRequireAuthorizedGuard = (_route, state) => {
|
|
|
1685
1672
|
if (!isUnavailableError?.(error))
|
|
1686
1673
|
throw error;
|
|
1687
1674
|
return resolveUnavailable(error);
|
|
1688
|
-
}
|
|
1675
|
+
});
|
|
1689
1676
|
}
|
|
1690
1677
|
if (data === 'anonymous') {
|
|
1691
1678
|
if (!lease.isCurrent())
|
|
@@ -1857,12 +1844,10 @@ const tryRecoverAuthAccess = async (config, request, error) => {
|
|
|
1857
1844
|
if (!config.recoverAuthAccess) {
|
|
1858
1845
|
return false;
|
|
1859
1846
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
return false;
|
|
1865
|
-
}
|
|
1847
|
+
const recover = async () => config.recoverAuthAccess?.(request, error);
|
|
1848
|
+
return recover()
|
|
1849
|
+
.then((recovered) => recovered === true)
|
|
1850
|
+
.catch(() => false);
|
|
1866
1851
|
};
|
|
1867
1852
|
/**
|
|
1868
1853
|
* Final error handling after retries and optional auth recovery have been exhausted.
|
|
@@ -1979,7 +1964,7 @@ const kitAuthInterceptor = (request, next) => {
|
|
|
1979
1964
|
}
|
|
1980
1965
|
return throwError(() => error);
|
|
1981
1966
|
}
|
|
1982
|
-
const sendAuthenticated = (outgoing, allowAuthRecovery) => from(
|
|
1967
|
+
const sendAuthenticated = (outgoing, allowAuthRecovery) => from(config.getAuthHeaders(outgoing)).pipe(catchError((headerError) => {
|
|
1983
1968
|
// getAuthHeaders failed → the request is never sent; classify it instead of failing silently.
|
|
1984
1969
|
if (config.enforceAuthAccessMode && isExplicitAuthDenial(headerError) && shouldRevokeAuthAccess(config, outgoing, headerError)) {
|
|
1985
1970
|
access.clear();
|
|
@@ -2022,7 +2007,10 @@ const kitAuthInterceptor = (request, next) => {
|
|
|
2022
2007
|
config.onResponse?.(event);
|
|
2023
2008
|
}
|
|
2024
2009
|
}), catchError((error) => {
|
|
2025
|
-
const mayRecover = allowAuthRecovery &&
|
|
2010
|
+
const mayRecover = allowAuthRecovery &&
|
|
2011
|
+
isExplicitAuthDenial(error) &&
|
|
2012
|
+
!outgoing.context.get(KIT_AUTH_RECOVERY_REPLAY) &&
|
|
2013
|
+
config.recoverAuthAccess;
|
|
2026
2014
|
if (mayRecover) {
|
|
2027
2015
|
return from(tryRecoverAuthAccess(config, outgoing, error)).pipe(mergeMap((recovered) => {
|
|
2028
2016
|
if (recovered) {
|
|
@@ -2215,8 +2203,8 @@ class KitRealtimeConnection {
|
|
|
2215
2203
|
return this.shouldConnect && this.#isAppActive && this.#isNetworkConnected && hasRemoteAccess;
|
|
2216
2204
|
}
|
|
2217
2205
|
/** Hook used by authenticated clients to invalidate a token after handshake failure. */
|
|
2218
|
-
handleConnectionFailure() {
|
|
2219
|
-
return
|
|
2206
|
+
async handleConnectionFailure() {
|
|
2207
|
+
return;
|
|
2220
2208
|
}
|
|
2221
2209
|
/** Parse a text WebSocket message into one or more domain events. */
|
|
2222
2210
|
parseMessage(data) {
|
|
@@ -2274,12 +2262,9 @@ class KitRealtimeConnection {
|
|
|
2274
2262
|
}
|
|
2275
2263
|
this.listeners.push(networkHandle);
|
|
2276
2264
|
})();
|
|
2277
|
-
|
|
2278
|
-
await this.#lifecycleRegistration;
|
|
2279
|
-
}
|
|
2280
|
-
finally {
|
|
2265
|
+
await this.#lifecycleRegistration.finally(() => {
|
|
2281
2266
|
this.#lifecycleRegistration = null;
|
|
2282
|
-
}
|
|
2267
|
+
});
|
|
2283
2268
|
}
|
|
2284
2269
|
/** Remove all lifecycle listeners, including listeners whose async registration has not completed yet. */
|
|
2285
2270
|
removeLifecycleListeners() {
|
|
@@ -2331,85 +2316,82 @@ class KitRealtimeConnection {
|
|
|
2331
2316
|
this.#clearReconnectTimer();
|
|
2332
2317
|
this.#opening = true;
|
|
2333
2318
|
const generation = this.#generation;
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
this.#clearPingTimer();
|
|
2319
|
+
await this.#openGeneration(generation)
|
|
2320
|
+
.catch(() => this.#requestReconnect())
|
|
2321
|
+
.finally(() => {
|
|
2322
|
+
if (generation === this.#generation)
|
|
2323
|
+
this.#opening = false;
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
/** Build and attach the sockets for one lifecycle generation. */
|
|
2327
|
+
async #openGeneration(generation) {
|
|
2328
|
+
const targets = await this.buildSocketTargets();
|
|
2329
|
+
if (!this.#canOpen || generation !== this.#generation) {
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
const nextTargets = new Map(targets.map((target) => [toKitWebSocketUrl(target.url), target]));
|
|
2333
|
+
for (const [key, socket] of this.#sockets) {
|
|
2334
|
+
if (nextTargets.has(key)) {
|
|
2335
|
+
continue;
|
|
2352
2336
|
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
continue;
|
|
2357
|
-
}
|
|
2358
|
-
const socket = this.createWebSocket(key, target.protocols);
|
|
2359
|
-
const health = {
|
|
2360
|
-
key,
|
|
2361
|
-
lastActivityAt: 0,
|
|
2362
|
-
openTimer: null,
|
|
2363
|
-
watchdog: new KitRealtimeLivenessWatchdog(this.#options.livenessTimeoutMs, () => this.#connectionFailed(generation, socket)),
|
|
2364
|
-
};
|
|
2365
|
-
this.#sockets.set(key, socket);
|
|
2366
|
-
this.#health.set(socket, health);
|
|
2367
|
-
health.openTimer = setTimeout(() => this.#connectionFailed(generation, socket), this.#options.openTimeoutMs);
|
|
2368
|
-
socket.onopen = () => {
|
|
2369
|
-
if (generation !== this.#generation || this.#sockets.get(key) !== socket) {
|
|
2370
|
-
return;
|
|
2371
|
-
}
|
|
2372
|
-
this.#clearOpenTimer(health);
|
|
2373
|
-
this.#markActivity(health);
|
|
2374
|
-
this.#startPing();
|
|
2375
|
-
if (this.isStreamOpen) {
|
|
2376
|
-
this.#reconnectAttempt = 0;
|
|
2377
|
-
this.#reconnected$.next();
|
|
2378
|
-
}
|
|
2379
|
-
};
|
|
2380
|
-
socket.onmessage = ({ data }) => {
|
|
2381
|
-
if (generation !== this.#generation || this.#sockets.get(key) !== socket || typeof data !== 'string') {
|
|
2382
|
-
return;
|
|
2383
|
-
}
|
|
2384
|
-
this.#markActivity(health);
|
|
2385
|
-
if (data === this.#options.pong) {
|
|
2386
|
-
return;
|
|
2387
|
-
}
|
|
2388
|
-
let events;
|
|
2389
|
-
try {
|
|
2390
|
-
events = this.parseMessage(data);
|
|
2391
|
-
}
|
|
2392
|
-
catch {
|
|
2393
|
-
// Ignore malformed application messages while retaining the healthy socket.
|
|
2394
|
-
return;
|
|
2395
|
-
}
|
|
2396
|
-
for (const event of events) {
|
|
2397
|
-
this.#events$.next({ ...event, isSelf: event.originId === this.id });
|
|
2398
|
-
}
|
|
2399
|
-
};
|
|
2400
|
-
socket.onerror = () => this.#connectionFailed(generation, socket);
|
|
2401
|
-
socket.onclose = () => this.#connectionFailed(generation, socket);
|
|
2337
|
+
const health = this.#health.get(socket);
|
|
2338
|
+
if (health) {
|
|
2339
|
+
this.#removeSocket(socket, health);
|
|
2402
2340
|
}
|
|
2403
|
-
this.#opening = false;
|
|
2404
2341
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
this.#
|
|
2342
|
+
this.#targets = nextTargets;
|
|
2343
|
+
if (this.#sockets.size === 0) {
|
|
2344
|
+
this.#clearPingTimer();
|
|
2408
2345
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2346
|
+
for (const target of targets) {
|
|
2347
|
+
const key = toKitWebSocketUrl(target.url);
|
|
2348
|
+
if (this.#sockets.has(key)) {
|
|
2349
|
+
continue;
|
|
2412
2350
|
}
|
|
2351
|
+
const socket = this.createWebSocket(key, target.protocols);
|
|
2352
|
+
const health = {
|
|
2353
|
+
key,
|
|
2354
|
+
lastActivityAt: 0,
|
|
2355
|
+
openTimer: null,
|
|
2356
|
+
watchdog: new KitRealtimeLivenessWatchdog(this.#options.livenessTimeoutMs, () => this.#connectionFailed(generation, socket)),
|
|
2357
|
+
};
|
|
2358
|
+
this.#sockets.set(key, socket);
|
|
2359
|
+
this.#health.set(socket, health);
|
|
2360
|
+
health.openTimer = setTimeout(() => this.#connectionFailed(generation, socket), this.#options.openTimeoutMs);
|
|
2361
|
+
socket.onopen = () => {
|
|
2362
|
+
if (generation !== this.#generation || this.#sockets.get(key) !== socket) {
|
|
2363
|
+
return;
|
|
2364
|
+
}
|
|
2365
|
+
this.#clearOpenTimer(health);
|
|
2366
|
+
this.#markActivity(health);
|
|
2367
|
+
this.#startPing();
|
|
2368
|
+
if (this.isStreamOpen) {
|
|
2369
|
+
this.#reconnectAttempt = 0;
|
|
2370
|
+
this.#reconnected$.next();
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
socket.onmessage = ({ data }) => {
|
|
2374
|
+
if (generation !== this.#generation || this.#sockets.get(key) !== socket || typeof data !== 'string') {
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2377
|
+
this.#markActivity(health);
|
|
2378
|
+
if (data === this.#options.pong) {
|
|
2379
|
+
return;
|
|
2380
|
+
}
|
|
2381
|
+
let events;
|
|
2382
|
+
try {
|
|
2383
|
+
events = this.parseMessage(data);
|
|
2384
|
+
}
|
|
2385
|
+
catch {
|
|
2386
|
+
// Ignore malformed application messages while retaining the healthy socket.
|
|
2387
|
+
return;
|
|
2388
|
+
}
|
|
2389
|
+
for (const event of events) {
|
|
2390
|
+
this.#events$.next({ ...event, isSelf: event.originId === this.id });
|
|
2391
|
+
}
|
|
2392
|
+
};
|
|
2393
|
+
socket.onerror = () => this.#connectionFailed(generation, socket);
|
|
2394
|
+
socket.onclose = () => this.#connectionFailed(generation, socket);
|
|
2413
2395
|
}
|
|
2414
2396
|
}
|
|
2415
2397
|
#registerAccessListener() {
|
|
@@ -2713,18 +2695,17 @@ const getDisableTargets = (event) => {
|
|
|
2713
2695
|
* <ion-button type="submit" [form]="formRef">Save</ion-button>
|
|
2714
2696
|
* ```
|
|
2715
2697
|
*/
|
|
2716
|
-
const disableHandler =
|
|
2698
|
+
const disableHandler = (event, work) => {
|
|
2717
2699
|
if (event.type === 'submit')
|
|
2718
2700
|
event.preventDefault();
|
|
2719
2701
|
const targets = getDisableTargets(event);
|
|
2720
2702
|
const disabledStates = targets.map((target) => target.disabled);
|
|
2721
2703
|
targets.forEach((target) => (target.disabled = true));
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
finally {
|
|
2704
|
+
return work
|
|
2705
|
+
.then(() => undefined, () => undefined)
|
|
2706
|
+
.finally(() => {
|
|
2726
2707
|
targets.forEach((target, index) => (target.disabled = disabledStates[index]));
|
|
2727
|
-
}
|
|
2708
|
+
});
|
|
2728
2709
|
};
|
|
2729
2710
|
|
|
2730
2711
|
/**
|