@flamingo-stack/openframe-frontend-core 0.0.809 → 0.0.811
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/{case-study-card-MEWJNF4N.cjs → case-study-card-AMINZROX.cjs} +5 -5
- package/dist/{chunk-FRS2VO22.cjs → chunk-243TS7YL.cjs} +38 -38
- package/dist/{chunk-GAHXURKJ.cjs → chunk-5QLDHPPU.cjs} +2 -2
- package/dist/{chunk-WDL3GFH2.cjs → chunk-66J7ZSI5.cjs} +34 -34
- package/dist/{chunk-VKAFZCFV.cjs → chunk-6GT3ZL27.cjs} +28 -28
- package/dist/{chunk-PRCGRDHV.cjs → chunk-7Y6M4FW4.cjs} +5 -5
- package/dist/{chunk-TOWVMBAP.cjs → chunk-ACCZCRXT.cjs} +14 -14
- package/dist/{chunk-VXAKQRV7.cjs → chunk-APOMNC7H.cjs} +5 -5
- package/dist/{chunk-KS5V55HN.cjs → chunk-CB77J5L7.cjs} +864 -670
- package/dist/{chunk-VHX4A4SA.cjs → chunk-CC3Q3MQG.cjs} +2 -2
- package/dist/{chunk-WV44WJKR.cjs → chunk-CJ7W2SY4.cjs} +8 -8
- package/dist/{chunk-DDFT6VQ3.cjs → chunk-CLU2KJFB.cjs} +3 -3
- package/dist/{chunk-OJZBZH56.cjs → chunk-CNTBGJA7.cjs} +3 -3
- package/dist/{chunk-Q3C6UJJ7.cjs → chunk-CPP2APON.cjs} +89 -89
- package/dist/{chunk-TT64NRFU.cjs → chunk-ERLMCSGF.cjs} +3 -3
- package/dist/{chunk-5UTJARDM.cjs → chunk-FK2WFU7R.cjs} +17 -17
- package/dist/{chunk-7PNRXJX2.cjs → chunk-FX35L4Y6.cjs} +3 -3
- package/dist/{chunk-5GJM7VRR.cjs → chunk-GI3MMBP3.cjs} +91 -26
- package/dist/{chunk-AZJYMTBS.cjs → chunk-GU3GJ5DH.cjs} +50 -50
- package/dist/{chunk-VUKN6KEE.cjs → chunk-IQLXO6EI.cjs} +97 -97
- package/dist/{chunk-BT53NHR7.cjs → chunk-J6C7F63P.cjs} +120 -120
- package/dist/{chunk-PIKHEBG5.cjs → chunk-JNWJB4Z5.cjs} +52 -52
- package/dist/{chunk-5MTYKS2Q.cjs → chunk-KVDUWXVZ.cjs} +4 -4
- package/dist/{chunk-V4FXUIMH.cjs → chunk-LC65AC6M.cjs} +4 -4
- package/dist/{chunk-RZNRKWG5.cjs → chunk-MDBOYMCW.cjs} +22 -22
- package/dist/{chunk-AQXKXZWB.cjs → chunk-MG3HJIGG.cjs} +4 -4
- package/dist/{chunk-KVJKKVB3.cjs → chunk-NZSWROGM.cjs} +7 -7
- package/dist/{chunk-OAJ3AL4V.cjs → chunk-O32RLIN4.cjs} +6 -6
- package/dist/{chunk-ZAXGW4KT.cjs → chunk-O4MEG2ZS.cjs} +21 -21
- package/dist/{chunk-4W77VLQV.cjs → chunk-OQDPZOGC.cjs} +6 -6
- package/dist/{chunk-LUICXMHC.cjs → chunk-PCVY63WQ.cjs} +17 -17
- package/dist/{chunk-ML3DG4SS.cjs → chunk-PMOMZSCX.cjs} +5 -5
- package/dist/{chunk-TUZV2ZQY.cjs → chunk-Q7QYAINS.cjs} +2 -2
- package/dist/{chunk-KHKPLOU4.cjs → chunk-QDB2JO55.cjs} +144 -36
- package/dist/{chunk-KCB72H7A.cjs → chunk-R55KNVPR.cjs} +71 -71
- package/dist/{chunk-NG3RKTQU.cjs → chunk-SFUNXMY3.cjs} +8 -8
- package/dist/{chunk-3B76QFXV.cjs → chunk-TKK66KHU.cjs} +6 -6
- package/dist/{chunk-TGOJHOQR.cjs → chunk-U2MHQBL4.cjs} +3 -3
- package/dist/{chunk-I3RJLXEL.cjs → chunk-UP3TLY2V.cjs} +131 -131
- package/dist/{chunk-KITOT3DS.cjs → chunk-VXMPVDOS.cjs} +26 -26
- package/dist/{chunk-UVLTUSH3.cjs → chunk-WX5WDSKV.cjs} +583 -582
- package/dist/{chunk-OFGYPMTE.cjs → chunk-XLEWM5X5.cjs} +53 -53
- package/dist/{chunk-SZHDXXMK.cjs → chunk-YSDB6HGQ.cjs} +3 -3
- package/dist/{chunk-JLKGLPDC.cjs → chunk-ZW25QUJK.cjs} +16 -16
- package/dist/{chunk-FLW2VL5W.cjs → chunk-ZZO3FGPM.cjs} +24 -24
- package/dist/{cloud-tenants-DJAA23GR.cjs → cloud-tenants-XGGQG7SO.cjs} +25 -25
- package/dist/components/case-studies/index.cjs +41 -41
- package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/dispatch.js +4 -1
- package/dist/components/chat/hooks/use-jetstream-dialog-subscription.js +1 -1
- package/dist/components/chat/hooks/use-nats-dialog-subscription.js +1 -1
- package/dist/components/chat/index.cjs +19 -19
- package/dist/components/chat/types/api.types.d.ts +8 -4
- package/dist/components/chat/types/api.types.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +26 -26
- package/dist/components/docs/index.cjs +29 -29
- package/dist/components/embeds/index.cjs +26 -26
- package/dist/components/faq/index.cjs +27 -27
- package/dist/components/features/index.cjs +25 -25
- package/dist/components/help-center-pages/index.cjs +130 -130
- package/dist/components/index.cjs +90 -90
- package/dist/components/meeting-scheduler/index.cjs +94 -94
- package/dist/components/navigation/index.cjs +28 -28
- package/dist/components/onboarding-guides/index.cjs +28 -28
- package/dist/components/product-demo/index.cjs +36 -36
- package/dist/components/related-content/index.cjs +14 -14
- package/dist/components/tickets/index.cjs +32 -32
- package/dist/components/ui/index.cjs +25 -25
- package/dist/components/ui/markdown/base-components.d.ts.map +1 -1
- package/dist/components/ui/markdown/base-components.js +6 -7
- package/dist/components/ui/markdown/engine.d.ts +7 -0
- package/dist/components/ui/markdown/engine.d.ts.map +1 -1
- package/dist/components/ui/markdown/engine.js +12 -3
- package/dist/components/ui/markdown/external-media-notice.d.ts +33 -0
- package/dist/components/ui/markdown/external-media-notice.d.ts.map +1 -0
- package/dist/components/ui/markdown/external-media-notice.js +56 -0
- package/dist/components/ui/markdown/mermaid-diagram.d.ts +24 -2
- package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -1
- package/dist/components/ui/markdown/mermaid-diagram.js +66 -6
- package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts +4 -4
- package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts.map +1 -1
- package/dist/components/ui/markdown/rich/rich-markdown-renderer.js +2 -1
- package/dist/components/ui/markdown/sanitize.d.ts +28 -3
- package/dist/components/ui/markdown/sanitize.d.ts.map +1 -1
- package/dist/components/ui/markdown/sanitize.js +84 -12
- package/dist/components/ui/markdown/simple-markdown-renderer.d.ts +3 -2
- package/dist/components/ui/markdown/simple-markdown-renderer.d.ts.map +1 -1
- package/dist/{devices-AIDQW4HB.cjs → devices-H5Y4DBVC.cjs} +26 -26
- package/dist/{embeddable-chat-XT6GMSBX.cjs → embeddable-chat-77ZOLCCK.cjs} +89 -89
- package/dist/hooks/index.cjs +11 -11
- package/dist/index.cjs +30 -30
- package/dist/{knowledge-JWCFM3GO.cjs → knowledge-MGH65HXM.cjs} +26 -26
- package/dist/{logs-ZNIXPJXA.cjs → logs-OL7ETVK6.cjs} +33 -33
- package/dist/nats/index.cjs +2 -2
- package/dist/nats/nats-provider.d.ts +9 -3
- package/dist/nats/nats-provider.d.ts.map +1 -1
- package/dist/nats/nats-provider.js +7 -3
- package/dist/nats/shared-connection.d.ts +44 -1
- package/dist/nats/shared-connection.d.ts.map +1 -1
- package/dist/nats/shared-connection.js +126 -22
- package/dist/{policies-Z4NGPLA2.cjs → policies-BCECWQ3F.cjs} +29 -29
- package/dist/{remote-session-LMUFV2RZ.cjs → remote-session-HML4UF7W.cjs} +11 -11
- package/dist/{scripts-G4Y5SPOW.cjs → scripts-XCD6V2JB.cjs} +32 -32
- package/dist/{software-update-VAOKDA76.cjs → software-update-U5ESXRG5.cjs} +29 -29
- package/dist/{tickets-board-QF5JNSH2.cjs → tickets-board-EICQ5VLE.cjs} +14 -14
- package/dist/utils/app-origins.d.ts +41 -0
- package/dist/utils/app-origins.d.ts.map +1 -0
- package/dist/utils/app-origins.js +51 -0
- package/dist/utils/embed-auth-adapter-registry.d.ts +7 -0
- package/dist/utils/embed-auth-adapter-registry.d.ts.map +1 -0
- package/dist/utils/embed-auth-adapter-registry.js +34 -0
- package/dist/utils/embed-authed-fetch.d.ts.map +1 -1
- package/dist/utils/embed-authed-fetch.js +6 -19
- package/dist/utils/index.cjs +28 -12
- package/dist/{video-file-player-2FMFCGXE.cjs → video-file-player-4QMVTOBE.cjs} +3 -3
- package/package.json +1 -1
- package/src/components/chat/entity-cards/dispatch.tsx +12 -1
- package/src/components/chat/hooks/use-jetstream-dialog-subscription.ts +1 -1
- package/src/components/chat/hooks/use-nats-dialog-subscription.ts +1 -1
- package/src/components/chat/types/api.types.ts +8 -4
- package/src/components/ui/markdown/base-components.tsx +6 -7
- package/src/components/ui/markdown/engine.tsx +29 -5
- package/src/components/ui/markdown/external-media-notice.tsx +84 -0
- package/src/components/ui/markdown/mermaid-diagram.tsx +107 -5
- package/src/components/ui/markdown/rich/rich-markdown-renderer.tsx +11 -5
- package/src/components/ui/markdown/sanitize.ts +162 -15
- package/src/components/ui/markdown/simple-markdown-renderer.tsx +6 -2
- package/src/nats/nats-provider.tsx +15 -4
- package/src/nats/shared-connection.ts +199 -25
- package/src/utils/app-origins.ts +95 -0
- package/src/utils/embed-auth-adapter-registry.ts +49 -0
- package/src/utils/embed-authed-fetch.ts +7 -35
|
@@ -422,7 +422,13 @@ var NATS_DEFAULTS = {
|
|
|
422
422
|
MAX_PING_OUT: 3,
|
|
423
423
|
RETRY_INITIAL_DELAY_MS: 1e3,
|
|
424
424
|
RETRY_MAX_DELAY_MS: 3e4,
|
|
425
|
-
RETRY_MULTIPLIER: 2
|
|
425
|
+
RETRY_MULTIPLIER: 2,
|
|
426
|
+
/** Failed dials in a row after which the lifecycle stops dialling for a while. */
|
|
427
|
+
PAUSE_AFTER_FAILURES: 5,
|
|
428
|
+
/** Length of a pause, plus up to 20% jitter so clients paused by one outage do not wake together. */
|
|
429
|
+
PAUSE_MS: 3e5,
|
|
430
|
+
/** A pause ignores visibility/online resume triggers for this long, so toggling tabs is not a retry button. */
|
|
431
|
+
PAUSE_MIN_RESUME_MS: 3e4
|
|
426
432
|
};
|
|
427
433
|
var connections = /* @__PURE__ */ new Map();
|
|
428
434
|
function getSharedConnection() {
|
|
@@ -457,9 +463,19 @@ function acquireClient(url, opts) {
|
|
|
457
463
|
closeTimer: null,
|
|
458
464
|
retryTimer: null,
|
|
459
465
|
retryOwner: null,
|
|
460
|
-
retrySchedulers: /* @__PURE__ */ new Set()
|
|
466
|
+
retrySchedulers: /* @__PURE__ */ new Set(),
|
|
467
|
+
failedDials: 0,
|
|
468
|
+
lastDialError: void 0,
|
|
469
|
+
terminal: false,
|
|
470
|
+
pause: null,
|
|
471
|
+
terminalListeners: /* @__PURE__ */ new Set()
|
|
461
472
|
};
|
|
462
473
|
connections.set(url, conn);
|
|
474
|
+
} else if (conn.refCount === 0) {
|
|
475
|
+
conn.failedDials = 0;
|
|
476
|
+
conn.terminal = false;
|
|
477
|
+
_optionalChain([conn, 'access', _21 => _21.pause, 'optionalAccess', _22 => _22.dispose, 'call', _23 => _23()]);
|
|
478
|
+
conn.pause = null;
|
|
463
479
|
}
|
|
464
480
|
conn.refCount += 1;
|
|
465
481
|
if (conn.closeTimer) {
|
|
@@ -473,7 +489,7 @@ function releaseClient(url, opts) {
|
|
|
473
489
|
if (!conn) return;
|
|
474
490
|
conn.refCount = Math.max(0, conn.refCount - 1);
|
|
475
491
|
if (conn.refCount > 0) return;
|
|
476
|
-
const delay = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
492
|
+
const delay = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _24 => _24.delayMs]), () => ( NATS_DEFAULTS.SHARED_CLOSE_DELAY_MS));
|
|
477
493
|
conn.closeTimer = setTimeout(() => {
|
|
478
494
|
conn.closeTimer = null;
|
|
479
495
|
if (conn.refCount > 0) return;
|
|
@@ -484,6 +500,8 @@ function releaseClient(url, opts) {
|
|
|
484
500
|
clearTimeout(conn.retryTimer);
|
|
485
501
|
conn.retryTimer = null;
|
|
486
502
|
}
|
|
503
|
+
_optionalChain([conn, 'access', _25 => _25.pause, 'optionalAccess', _26 => _26.dispose, 'call', _27 => _27()]);
|
|
504
|
+
conn.pause = null;
|
|
487
505
|
void conn.client.close().catch(() => {
|
|
488
506
|
});
|
|
489
507
|
}, delay);
|
|
@@ -502,18 +520,78 @@ function handOffRetry(conn) {
|
|
|
502
520
|
function startConnectionLifecycle(options) {
|
|
503
521
|
const { conn, wsUrl } = options;
|
|
504
522
|
let closed = false;
|
|
505
|
-
|
|
523
|
+
function endPause() {
|
|
524
|
+
_optionalChain([conn, 'access', _28 => _28.pause, 'optionalAccess', _29 => _29.dispose, 'call', _30 => _30()]);
|
|
525
|
+
conn.pause = null;
|
|
526
|
+
}
|
|
527
|
+
function startPause() {
|
|
528
|
+
if (conn.pause) return;
|
|
529
|
+
const now = Date.now();
|
|
530
|
+
const until = now + NATS_DEFAULTS.PAUSE_MS * (1 + Math.random() * 0.2);
|
|
531
|
+
const resume = () => {
|
|
532
|
+
if (!conn.pause) return;
|
|
533
|
+
if (Date.now() - conn.pause.startedAt < NATS_DEFAULTS.PAUSE_MIN_RESUME_MS) return;
|
|
534
|
+
endPause();
|
|
535
|
+
if (conn.terminal || conn.client.isConnected()) return;
|
|
536
|
+
if (conn.retryTimer) {
|
|
537
|
+
clearTimeout(conn.retryTimer);
|
|
538
|
+
conn.retryTimer = null;
|
|
539
|
+
}
|
|
540
|
+
if (conn.retryOwner) conn.retryOwner();
|
|
541
|
+
else handOffRetry(conn);
|
|
542
|
+
};
|
|
543
|
+
const onVisibility = () => {
|
|
544
|
+
if (document.visibilityState === "visible") resume();
|
|
545
|
+
};
|
|
546
|
+
const hasDom = typeof document !== "undefined" && typeof window !== "undefined";
|
|
547
|
+
if (hasDom) {
|
|
548
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
549
|
+
window.addEventListener("online", resume);
|
|
550
|
+
}
|
|
551
|
+
conn.failedDials = Math.min(conn.failedDials, NATS_DEFAULTS.PAUSE_AFTER_FAILURES - 1);
|
|
552
|
+
conn.pause = {
|
|
553
|
+
until,
|
|
554
|
+
startedAt: now,
|
|
555
|
+
dispose: () => {
|
|
556
|
+
if (!hasDom) return;
|
|
557
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
558
|
+
window.removeEventListener("online", resume);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function markHealthy() {
|
|
563
|
+
endPause();
|
|
564
|
+
conn.failedDials = 0;
|
|
565
|
+
}
|
|
566
|
+
function countFailedDial(err) {
|
|
567
|
+
if (err === conn.lastDialError) return;
|
|
568
|
+
conn.lastDialError = err;
|
|
569
|
+
conn.failedDials++;
|
|
570
|
+
}
|
|
571
|
+
function markTerminal() {
|
|
572
|
+
endPause();
|
|
573
|
+
if (conn.retryTimer) clearTimeout(conn.retryTimer);
|
|
574
|
+
conn.terminal = true;
|
|
575
|
+
conn.retryOwner = null;
|
|
576
|
+
conn.retryTimer = null;
|
|
577
|
+
for (const listener of conn.terminalListeners) listener();
|
|
578
|
+
}
|
|
506
579
|
function emitSynthetic(status) {
|
|
507
580
|
if (closed) return;
|
|
508
|
-
_optionalChain([options, 'access',
|
|
581
|
+
_optionalChain([options, 'access', _31 => _31.onStatusChange, 'optionalCall', _32 => _32(status, { status })]);
|
|
509
582
|
if (status === "connected") {
|
|
510
|
-
|
|
583
|
+
markHealthy();
|
|
511
584
|
}
|
|
512
585
|
}
|
|
586
|
+
const notifyTerminal = () => {
|
|
587
|
+
if (!closed) _optionalChain([options, 'access', _33 => _33.onTerminal, 'optionalCall', _34 => _34()]);
|
|
588
|
+
};
|
|
589
|
+
conn.terminalListeners.add(notifyTerminal);
|
|
513
590
|
conn.retrySchedulers.add(scheduleRetry);
|
|
514
591
|
if (!conn.retryOwner) conn.retryOwner = scheduleRetry;
|
|
515
592
|
function scheduleRetry() {
|
|
516
593
|
if (closed) return;
|
|
594
|
+
if (conn.terminal) return;
|
|
517
595
|
if (getSharedConnectionFor(wsUrl) !== conn) return;
|
|
518
596
|
if (options.getFreshUrl() !== wsUrl) return;
|
|
519
597
|
if (!conn.retryOwner) conn.retryOwner = scheduleRetry;
|
|
@@ -525,23 +603,34 @@ function startConnectionLifecycle(options) {
|
|
|
525
603
|
const baseDelay = _nullishCoalesce(cfg.initialDelayMs, () => ( NATS_DEFAULTS.RETRY_INITIAL_DELAY_MS));
|
|
526
604
|
const maxDelay = _nullishCoalesce(cfg.maxDelayMs, () => ( NATS_DEFAULTS.RETRY_MAX_DELAY_MS));
|
|
527
605
|
const multiplier = _nullishCoalesce(cfg.multiplier, () => ( NATS_DEFAULTS.RETRY_MULTIPLIER));
|
|
528
|
-
const
|
|
529
|
-
const
|
|
530
|
-
|
|
606
|
+
const attempt = conn.failedDials;
|
|
607
|
+
const delay = attempt < fastRetries ? fastDelay : Math.min(baseDelay * multiplier ** (attempt - fastRetries), maxDelay);
|
|
608
|
+
const wait = Math.max(delay * (0.5 + Math.random() * 0.5), conn.pause ? conn.pause.until - Date.now() : 0);
|
|
531
609
|
const runRetry = async () => {
|
|
532
610
|
conn.retryTimer = null;
|
|
533
611
|
if (closed) return;
|
|
612
|
+
if (conn.terminal) return;
|
|
534
613
|
if (getSharedConnectionFor(wsUrl) !== conn) return;
|
|
535
614
|
if (conn.client.isConnected()) {
|
|
536
|
-
|
|
615
|
+
markHealthy();
|
|
537
616
|
return;
|
|
538
617
|
}
|
|
618
|
+
if (conn.pause && conn.pause.until <= Date.now()) endPause();
|
|
619
|
+
let verdict = void 0;
|
|
539
620
|
try {
|
|
540
|
-
await _optionalChain([options, 'access',
|
|
621
|
+
verdict = await _optionalChain([options, 'access', _35 => _35.onBeforeReconnect, 'optionalCall', _36 => _36({ consecutiveFailures: conn.failedDials })]);
|
|
541
622
|
} catch (e11) {
|
|
542
623
|
}
|
|
543
624
|
if (closed) return;
|
|
544
625
|
if (getSharedConnectionFor(wsUrl) !== conn) return;
|
|
626
|
+
if (conn.terminal) return;
|
|
627
|
+
if (verdict === "terminal") {
|
|
628
|
+
markTerminal();
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (verdict === "pause" || conn.failedDials >= NATS_DEFAULTS.PAUSE_AFTER_FAILURES) {
|
|
632
|
+
startPause();
|
|
633
|
+
}
|
|
545
634
|
const freshUrl = options.getFreshUrl();
|
|
546
635
|
if (freshUrl !== wsUrl) {
|
|
547
636
|
if (conn.retryOwner === scheduleRetry) {
|
|
@@ -554,13 +643,18 @@ function startConnectionLifecycle(options) {
|
|
|
554
643
|
}
|
|
555
644
|
return;
|
|
556
645
|
}
|
|
646
|
+
if (conn.pause) {
|
|
647
|
+
scheduleRetry();
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
557
650
|
try {
|
|
558
651
|
await conn.client.connect();
|
|
559
652
|
if (!closed && getSharedConnectionFor(wsUrl) === conn) {
|
|
560
|
-
|
|
653
|
+
markHealthy();
|
|
561
654
|
}
|
|
562
|
-
} catch (
|
|
655
|
+
} catch (err) {
|
|
563
656
|
if (!closed && getSharedConnectionFor(wsUrl) === conn) {
|
|
657
|
+
countFailedDial(err);
|
|
564
658
|
scheduleRetry();
|
|
565
659
|
}
|
|
566
660
|
}
|
|
@@ -569,14 +663,14 @@ function startConnectionLifecycle(options) {
|
|
|
569
663
|
runRetry().catch((err) => {
|
|
570
664
|
console.warn("[nats] retry attempt threw:", err);
|
|
571
665
|
});
|
|
572
|
-
},
|
|
666
|
+
}, wait);
|
|
573
667
|
}
|
|
574
668
|
const shouldRetryOn = _nullishCoalesce(options.shouldRetryOn, () => ( defaultShouldRetryOn));
|
|
575
669
|
const unsubStatus = conn.client.onStatus((evt) => {
|
|
576
670
|
if (closed) return;
|
|
577
|
-
_optionalChain([options, 'access',
|
|
671
|
+
_optionalChain([options, 'access', _37 => _37.onStatusChange, 'optionalCall', _38 => _38(evt.status, evt)]);
|
|
578
672
|
if (evt.status === "connected") {
|
|
579
|
-
|
|
673
|
+
markHealthy();
|
|
580
674
|
}
|
|
581
675
|
if (shouldRetryOn(evt.status)) {
|
|
582
676
|
scheduleRetry();
|
|
@@ -585,20 +679,30 @@ function startConnectionLifecycle(options) {
|
|
|
585
679
|
if (conn.client.isConnected()) {
|
|
586
680
|
emitSynthetic("connected");
|
|
587
681
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
682
|
+
if (conn.terminal) {
|
|
683
|
+
emitSynthetic("disconnected");
|
|
684
|
+
_optionalChain([options, 'access', _39 => _39.onTerminal, 'optionalCall', _40 => _40()]);
|
|
685
|
+
} else if (!conn.client.isConnected() && (conn.failedDials > 0 || conn.pause || conn.retryTimer)) {
|
|
686
|
+
emitSynthetic("disconnected");
|
|
687
|
+
scheduleRetry();
|
|
688
|
+
} else {
|
|
689
|
+
void (async () => {
|
|
690
|
+
try {
|
|
691
|
+
await conn.client.connect();
|
|
692
|
+
} catch (err) {
|
|
693
|
+
if (closed) return;
|
|
694
|
+
countFailedDial(err);
|
|
695
|
+
emitSynthetic("disconnected");
|
|
696
|
+
scheduleRetry();
|
|
697
|
+
}
|
|
698
|
+
})();
|
|
699
|
+
}
|
|
597
700
|
return {
|
|
598
701
|
stop() {
|
|
599
702
|
closed = true;
|
|
600
703
|
unsubStatus();
|
|
601
704
|
conn.retrySchedulers.delete(scheduleRetry);
|
|
705
|
+
conn.terminalListeners.delete(notifyTerminal);
|
|
602
706
|
if (conn.retryOwner !== scheduleRetry) {
|
|
603
707
|
return;
|
|
604
708
|
}
|
|
@@ -629,6 +733,7 @@ function NatsProvider({
|
|
|
629
733
|
const [client, setClient] = _react.useState.call(void 0, null);
|
|
630
734
|
const [status, setStatus] = _react.useState.call(void 0, "closed");
|
|
631
735
|
const [reconnectionCount, setReconnectionCount] = _react.useState.call(void 0, 0);
|
|
736
|
+
const [terminal, setTerminal] = _react.useState.call(void 0, false);
|
|
632
737
|
const getWsUrlRef = _react.useRef.call(void 0, getWsUrl);
|
|
633
738
|
_react.useEffect.call(void 0, () => {
|
|
634
739
|
getWsUrlRef.current = getWsUrl;
|
|
@@ -669,9 +774,10 @@ function NatsProvider({
|
|
|
669
774
|
const lifecycle = startConnectionLifecycle({
|
|
670
775
|
conn,
|
|
671
776
|
wsUrl,
|
|
672
|
-
onBeforeReconnect: () => _optionalChain([onBeforeReconnectRef, 'access',
|
|
777
|
+
onBeforeReconnect: (ctx) => _optionalChain([onBeforeReconnectRef, 'access', _41 => _41.current, 'optionalCall', _42 => _42(ctx)]),
|
|
673
778
|
backoff: reconnectionBackoffRef.current,
|
|
674
779
|
getFreshUrl: () => getWsUrlRef.current(),
|
|
780
|
+
onTerminal: () => setTerminal(true),
|
|
675
781
|
onStatusChange: (newStatus) => {
|
|
676
782
|
if (newStatus === "error") return;
|
|
677
783
|
setStatus(newStatus);
|
|
@@ -691,6 +797,7 @@ function NatsProvider({
|
|
|
691
797
|
}
|
|
692
798
|
setClient(null);
|
|
693
799
|
setStatus("closed");
|
|
800
|
+
setTerminal(false);
|
|
694
801
|
};
|
|
695
802
|
}, [urlRevision]);
|
|
696
803
|
const value = _react.useMemo.call(void 0,
|
|
@@ -698,9 +805,10 @@ function NatsProvider({
|
|
|
698
805
|
client,
|
|
699
806
|
status,
|
|
700
807
|
isReady: status === "connected" && client !== null,
|
|
701
|
-
reconnectionCount
|
|
808
|
+
reconnectionCount,
|
|
809
|
+
terminal
|
|
702
810
|
}),
|
|
703
|
-
[client, status, reconnectionCount]
|
|
811
|
+
[client, status, reconnectionCount, terminal]
|
|
704
812
|
);
|
|
705
813
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NatsContext.Provider, { value, children });
|
|
706
814
|
}
|
|
@@ -721,12 +829,12 @@ function useNatsSubscription(subject, onMessage, options) {
|
|
|
721
829
|
_react.useEffect.call(void 0, () => {
|
|
722
830
|
handlerRef.current = onMessage;
|
|
723
831
|
}, [onMessage]);
|
|
724
|
-
const enabled = _optionalChain([options, 'optionalAccess',
|
|
725
|
-
const queue = _optionalChain([options, 'optionalAccess',
|
|
726
|
-
const max = _optionalChain([options, 'optionalAccess',
|
|
727
|
-
const reconnectionCount = _nullishCoalesce(_optionalChain([nats, 'optionalAccess',
|
|
728
|
-
const isReady = !!_optionalChain([nats, 'optionalAccess',
|
|
729
|
-
const client = _nullishCoalesce(_optionalChain([nats, 'optionalAccess',
|
|
832
|
+
const enabled = _optionalChain([options, 'optionalAccess', _43 => _43.enabled]) !== false;
|
|
833
|
+
const queue = _optionalChain([options, 'optionalAccess', _44 => _44.queue]);
|
|
834
|
+
const max = _optionalChain([options, 'optionalAccess', _45 => _45.max]);
|
|
835
|
+
const reconnectionCount = _nullishCoalesce(_optionalChain([nats, 'optionalAccess', _46 => _46.reconnectionCount]), () => ( 0));
|
|
836
|
+
const isReady = !!_optionalChain([nats, 'optionalAccess', _47 => _47.isReady]);
|
|
837
|
+
const client = _nullishCoalesce(_optionalChain([nats, 'optionalAccess', _48 => _48.client]), () => ( null));
|
|
730
838
|
const isSubscribed = Boolean(client) && isReady && Boolean(subject) && enabled;
|
|
731
839
|
_react.useEffect.call(void 0, () => {
|
|
732
840
|
if (!client || !isReady || !subject || !enabled) return void 0;
|
|
@@ -734,7 +842,7 @@ function useNatsSubscription(subject, onMessage, options) {
|
|
|
734
842
|
return () => {
|
|
735
843
|
try {
|
|
736
844
|
sub.unsubscribe();
|
|
737
|
-
} catch (
|
|
845
|
+
} catch (e12) {
|
|
738
846
|
}
|
|
739
847
|
};
|
|
740
848
|
}, [client, isReady, subject, enabled, queue, max, reconnectionCount]);
|
|
@@ -752,7 +860,7 @@ function useNatsJsonSubscription(subject, onPayload, options) {
|
|
|
752
860
|
try {
|
|
753
861
|
const parsed = JSON.parse(decoder.decode(msg.data));
|
|
754
862
|
await handlerRef.current(parsed, msg);
|
|
755
|
-
} catch (
|
|
863
|
+
} catch (e13) {
|
|
756
864
|
}
|
|
757
865
|
},
|
|
758
866
|
[decoder]
|