@flamingo-stack/openframe-frontend-core 0.0.690 → 0.0.691-2504.7650.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.
Files changed (149) hide show
  1. package/dist/{chunk-22RSJ57Z.js → chunk-2YVTGPM7.js} +2 -2
  2. package/dist/{chunk-V5NOURSR.js → chunk-4HZXOQRM.js} +5 -5
  3. package/dist/{chunk-MDYTAKJ5.cjs → chunk-4N2JOPAQ.cjs} +22 -22
  4. package/dist/{chunk-MDYTAKJ5.cjs.map → chunk-4N2JOPAQ.cjs.map} +1 -1
  5. package/dist/{chunk-QNWQQ4RT.cjs → chunk-53O6PQ3F.cjs} +7 -7
  6. package/dist/{chunk-QNWQQ4RT.cjs.map → chunk-53O6PQ3F.cjs.map} +1 -1
  7. package/dist/{chunk-X4WBGDNW.cjs → chunk-5N2ZSB42.cjs} +18 -18
  8. package/dist/{chunk-X4WBGDNW.cjs.map → chunk-5N2ZSB42.cjs.map} +1 -1
  9. package/dist/{chunk-XRSJER2B.js → chunk-6Z26ZMR4.js} +4 -4
  10. package/dist/{chunk-HLEXYTOE.js → chunk-7EPGJOKN.js} +4 -4
  11. package/dist/{chunk-DOUG4UEZ.js → chunk-7WYWPELF.js} +11 -11
  12. package/dist/{chunk-ZBQZJAC7.cjs → chunk-BXAGR3PO.cjs} +7 -7
  13. package/dist/chunk-BXAGR3PO.cjs.map +1 -0
  14. package/dist/{chunk-QUGV2GT3.cjs → chunk-BXE2RZEV.cjs} +34 -34
  15. package/dist/{chunk-QUGV2GT3.cjs.map → chunk-BXE2RZEV.cjs.map} +1 -1
  16. package/dist/{chunk-DLRE5Y3G.js → chunk-C2SVJVEB.js} +2 -2
  17. package/dist/{chunk-OC3QH5WG.js → chunk-CMYDGVTZ.js} +2 -2
  18. package/dist/{chunk-VLWUKFQE.cjs → chunk-CWXRZVDI.cjs} +751 -710
  19. package/dist/chunk-CWXRZVDI.cjs.map +1 -0
  20. package/dist/{chunk-2PQKZWWP.js → chunk-DC3G4XGP.js} +6 -6
  21. package/dist/{chunk-KZXKT5AX.cjs → chunk-DDWLF2JV.cjs} +14 -14
  22. package/dist/{chunk-KZXKT5AX.cjs.map → chunk-DDWLF2JV.cjs.map} +1 -1
  23. package/dist/{chunk-NMXL34Z2.cjs → chunk-DVSPRY2V.cjs} +3 -3
  24. package/dist/{chunk-NMXL34Z2.cjs.map → chunk-DVSPRY2V.cjs.map} +1 -1
  25. package/dist/{chunk-OQVHGPHA.js → chunk-DZMDG7PC.js} +3 -3
  26. package/dist/{chunk-2MGTNYHW.cjs → chunk-ESFPY5FF.cjs} +100 -100
  27. package/dist/{chunk-2MGTNYHW.cjs.map → chunk-ESFPY5FF.cjs.map} +1 -1
  28. package/dist/{chunk-S5M5SEW2.js → chunk-FNMQ2J44.js} +5 -5
  29. package/dist/{chunk-UAKWSR3U.js → chunk-GDZ7IC5B.js} +2 -2
  30. package/dist/{chunk-OD2WMUAO.cjs → chunk-GZRU2A4L.cjs} +197 -197
  31. package/dist/{chunk-OD2WMUAO.cjs.map → chunk-GZRU2A4L.cjs.map} +1 -1
  32. package/dist/{chunk-3ZAIHRQH.cjs → chunk-H54RDLVC.cjs} +35 -35
  33. package/dist/{chunk-3ZAIHRQH.cjs.map → chunk-H54RDLVC.cjs.map} +1 -1
  34. package/dist/{chunk-Q76YVNCQ.js → chunk-HM7ZGABI.js} +2 -2
  35. package/dist/{chunk-YCKGUQA2.cjs → chunk-I27PWVWE.cjs} +17 -12
  36. package/dist/chunk-I27PWVWE.cjs.map +1 -0
  37. package/dist/{chunk-25X43LSD.js → chunk-JSG7WZKV.js} +4 -4
  38. package/dist/{chunk-AIXPQT3G.js → chunk-KMW2PXBU.js} +52 -11
  39. package/dist/chunk-KMW2PXBU.js.map +1 -0
  40. package/dist/{chunk-TBJWPNHU.js → chunk-KVDLL4LU.js} +4 -4
  41. package/dist/chunk-KVDLL4LU.js.map +1 -0
  42. package/dist/{chunk-54X75QTC.cjs → chunk-LCENRN2N.cjs} +14 -14
  43. package/dist/{chunk-54X75QTC.cjs.map → chunk-LCENRN2N.cjs.map} +1 -1
  44. package/dist/{chunk-BJHM2OEY.cjs → chunk-LNKLB7GM.cjs} +17 -17
  45. package/dist/{chunk-BJHM2OEY.cjs.map → chunk-LNKLB7GM.cjs.map} +1 -1
  46. package/dist/{chunk-JGVJRUGB.cjs → chunk-MIZU2OTO.cjs} +4 -4
  47. package/dist/{chunk-JGVJRUGB.cjs.map → chunk-MIZU2OTO.cjs.map} +1 -1
  48. package/dist/{chunk-TSENCZUL.js → chunk-MJI5GVT7.js} +11 -11
  49. package/dist/{chunk-BOM6MMWB.cjs → chunk-N3526CTH.cjs} +3 -3
  50. package/dist/{chunk-BOM6MMWB.cjs.map → chunk-N3526CTH.cjs.map} +1 -1
  51. package/dist/{chunk-D7BFS7N6.cjs → chunk-N4S7RBUM.cjs} +3 -3
  52. package/dist/{chunk-D7BFS7N6.cjs.map → chunk-N4S7RBUM.cjs.map} +1 -1
  53. package/dist/{chunk-4HBYEZ3I.cjs → chunk-SA4KQCNB.cjs} +82 -82
  54. package/dist/{chunk-4HBYEZ3I.cjs.map → chunk-SA4KQCNB.cjs.map} +1 -1
  55. package/dist/{chunk-RF2EYX3B.js → chunk-SC44YJCF.js} +2 -2
  56. package/dist/{chunk-2OD2PPNO.cjs → chunk-SDORFSFK.cjs} +37 -37
  57. package/dist/{chunk-2OD2PPNO.cjs.map → chunk-SDORFSFK.cjs.map} +1 -1
  58. package/dist/{chunk-42RQ4NIL.js → chunk-TSNGVWQO.js} +6 -6
  59. package/dist/{chunk-DMXI5D2Q.cjs → chunk-USKQURNF.cjs} +3 -3
  60. package/dist/{chunk-DMXI5D2Q.cjs.map → chunk-USKQURNF.cjs.map} +1 -1
  61. package/dist/{chunk-2KILTCND.js → chunk-UVUNBXS6.js} +6 -1
  62. package/dist/chunk-UVUNBXS6.js.map +1 -0
  63. package/dist/{chunk-5CBQBTGN.cjs → chunk-WZYIAKIH.cjs} +7 -7
  64. package/dist/{chunk-5CBQBTGN.cjs.map → chunk-WZYIAKIH.cjs.map} +1 -1
  65. package/dist/{chunk-2V4KPBNZ.js → chunk-XAOAYDGR.js} +3 -3
  66. package/dist/{chunk-U4OJCJTH.js → chunk-XBYF4SGD.js} +4 -4
  67. package/dist/{chunk-FCQR6VY4.cjs → chunk-Y3BC7TOJ.cjs} +26 -26
  68. package/dist/{chunk-FCQR6VY4.cjs.map → chunk-Y3BC7TOJ.cjs.map} +1 -1
  69. package/dist/{chunk-P27OGSQL.cjs → chunk-Y3Q76RAA.cjs} +37 -37
  70. package/dist/{chunk-P27OGSQL.cjs.map → chunk-Y3Q76RAA.cjs.map} +1 -1
  71. package/dist/{chunk-4BUPMSLY.js → chunk-Y7ZEVTLC.js} +3 -3
  72. package/dist/{chunk-Z622ACFD.js → chunk-Y7ZQZOE6.js} +5 -5
  73. package/dist/{chunk-5A3WSWZD.js → chunk-Z5FHXCXF.js} +8 -8
  74. package/dist/{chunk-UFXV64WQ.cjs → chunk-ZLYLHP64.cjs} +9 -9
  75. package/dist/{chunk-UFXV64WQ.cjs.map → chunk-ZLYLHP64.cjs.map} +1 -1
  76. package/dist/components/case-studies/index.cjs +20 -20
  77. package/dist/components/case-studies/index.js +7 -7
  78. package/dist/components/chat/index.cjs +4 -4
  79. package/dist/components/chat/index.js +3 -3
  80. package/dist/components/contact/index.cjs +8 -8
  81. package/dist/components/contact/index.js +7 -7
  82. package/dist/components/docs/index.cjs +11 -11
  83. package/dist/components/docs/index.js +10 -10
  84. package/dist/components/embeds/index.cjs +8 -8
  85. package/dist/components/embeds/index.js +7 -7
  86. package/dist/components/faq/index.cjs +9 -9
  87. package/dist/components/faq/index.js +8 -8
  88. package/dist/components/features/index.cjs +7 -7
  89. package/dist/components/features/index.js +6 -6
  90. package/dist/components/help-center-pages/index.cjs +101 -101
  91. package/dist/components/help-center-pages/index.js +21 -21
  92. package/dist/components/index.cjs +65 -65
  93. package/dist/components/index.js +21 -21
  94. package/dist/components/meeting-scheduler/index.cjs +58 -58
  95. package/dist/components/meeting-scheduler/index.js +8 -8
  96. package/dist/components/navigation/index.cjs +10 -10
  97. package/dist/components/navigation/index.js +9 -9
  98. package/dist/components/onboarding-guides/index.cjs +11 -11
  99. package/dist/components/onboarding-guides/index.js +10 -10
  100. package/dist/components/related-content/index.cjs +6 -6
  101. package/dist/components/related-content/index.js +5 -5
  102. package/dist/components/tickets/index.cjs +12 -12
  103. package/dist/components/tickets/index.js +11 -11
  104. package/dist/components/tickets/ticket-live-provider.d.ts.map +1 -1
  105. package/dist/components/ui/index.cjs +7 -7
  106. package/dist/components/ui/index.js +6 -6
  107. package/dist/hooks/index.cjs +4 -4
  108. package/dist/hooks/index.js +3 -3
  109. package/dist/index.cjs +12 -12
  110. package/dist/index.js +10 -10
  111. package/dist/utils/embed-authed-fetch.d.ts +18 -0
  112. package/dist/utils/embed-authed-fetch.d.ts.map +1 -1
  113. package/dist/utils/index.cjs +50 -6
  114. package/dist/utils/index.cjs.map +1 -1
  115. package/dist/utils/index.js +50 -6
  116. package/dist/utils/index.js.map +1 -1
  117. package/dist/utils/sse-subscription.d.ts +29 -11
  118. package/dist/utils/sse-subscription.d.ts.map +1 -1
  119. package/package.json +1 -1
  120. package/src/components/tickets/ticket-live-provider.tsx +14 -12
  121. package/src/utils/embed-authed-fetch.ts +21 -0
  122. package/src/utils/sse-subscription.ts +107 -20
  123. package/dist/chunk-2KILTCND.js.map +0 -1
  124. package/dist/chunk-AIXPQT3G.js.map +0 -1
  125. package/dist/chunk-TBJWPNHU.js.map +0 -1
  126. package/dist/chunk-VLWUKFQE.cjs.map +0 -1
  127. package/dist/chunk-YCKGUQA2.cjs.map +0 -1
  128. package/dist/chunk-ZBQZJAC7.cjs.map +0 -1
  129. /package/dist/{chunk-22RSJ57Z.js.map → chunk-2YVTGPM7.js.map} +0 -0
  130. /package/dist/{chunk-V5NOURSR.js.map → chunk-4HZXOQRM.js.map} +0 -0
  131. /package/dist/{chunk-XRSJER2B.js.map → chunk-6Z26ZMR4.js.map} +0 -0
  132. /package/dist/{chunk-HLEXYTOE.js.map → chunk-7EPGJOKN.js.map} +0 -0
  133. /package/dist/{chunk-DOUG4UEZ.js.map → chunk-7WYWPELF.js.map} +0 -0
  134. /package/dist/{chunk-DLRE5Y3G.js.map → chunk-C2SVJVEB.js.map} +0 -0
  135. /package/dist/{chunk-OC3QH5WG.js.map → chunk-CMYDGVTZ.js.map} +0 -0
  136. /package/dist/{chunk-2PQKZWWP.js.map → chunk-DC3G4XGP.js.map} +0 -0
  137. /package/dist/{chunk-OQVHGPHA.js.map → chunk-DZMDG7PC.js.map} +0 -0
  138. /package/dist/{chunk-S5M5SEW2.js.map → chunk-FNMQ2J44.js.map} +0 -0
  139. /package/dist/{chunk-UAKWSR3U.js.map → chunk-GDZ7IC5B.js.map} +0 -0
  140. /package/dist/{chunk-Q76YVNCQ.js.map → chunk-HM7ZGABI.js.map} +0 -0
  141. /package/dist/{chunk-25X43LSD.js.map → chunk-JSG7WZKV.js.map} +0 -0
  142. /package/dist/{chunk-TSENCZUL.js.map → chunk-MJI5GVT7.js.map} +0 -0
  143. /package/dist/{chunk-RF2EYX3B.js.map → chunk-SC44YJCF.js.map} +0 -0
  144. /package/dist/{chunk-42RQ4NIL.js.map → chunk-TSNGVWQO.js.map} +0 -0
  145. /package/dist/{chunk-2V4KPBNZ.js.map → chunk-XAOAYDGR.js.map} +0 -0
  146. /package/dist/{chunk-U4OJCJTH.js.map → chunk-XBYF4SGD.js.map} +0 -0
  147. /package/dist/{chunk-4BUPMSLY.js.map → chunk-Y7ZEVTLC.js.map} +0 -0
  148. /package/dist/{chunk-Z622ACFD.js.map → chunk-Y7ZQZOE6.js.map} +0 -0
  149. /package/dist/{chunk-5A3WSWZD.js.map → chunk-Z5FHXCXF.js.map} +0 -0
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  SoftwareInfo,
10
10
  SoftwareSourceBadge,
11
11
  ToolBadge
12
- } from "./chunk-Z622ACFD.js";
12
+ } from "./chunk-Y7ZQZOE6.js";
13
13
  import {
14
14
  AppHeader,
15
15
  AppLayout,
@@ -29,14 +29,14 @@ import {
29
29
  SlidingSidebar,
30
30
  TicketAlertsButton,
31
31
  TopNavigation
32
- } from "./chunk-2PQKZWWP.js";
32
+ } from "./chunk-DC3G4XGP.js";
33
33
  import {
34
34
  MobileNavigationDropdown,
35
35
  MultiLevelNavigation,
36
36
  StickySectionNav,
37
37
  useSectionNavigation
38
- } from "./chunk-OC3QH5WG.js";
39
- import "./chunk-TBJWPNHU.js";
38
+ } from "./chunk-CMYDGVTZ.js";
39
+ import "./chunk-KVDLL4LU.js";
40
40
  import {
41
41
  AIEnrichButton,
42
42
  AIEnrichSection,
@@ -617,7 +617,7 @@ import {
617
617
  withFirstTouchAttribution,
618
618
  withWalkthroughOpenParam,
619
619
  writeDismissCookie
620
- } from "./chunk-AIXPQT3G.js";
620
+ } from "./chunk-KMW2PXBU.js";
621
621
  import "./chunk-L2SLFCXP.js";
622
622
  import "./chunk-BJXDHKUX.js";
623
623
  import {
@@ -734,7 +734,7 @@ import {
734
734
  validateSchema,
735
735
  validateVariables,
736
736
  variablesToUrlParams
737
- } from "./chunk-2V4KPBNZ.js";
737
+ } from "./chunk-XAOAYDGR.js";
738
738
  import "./chunk-JD5TKRCU.js";
739
739
  import {
740
740
  CONTENT_REF_GROUPS,
@@ -756,7 +756,7 @@ import {
756
756
  serializeSchemaParams,
757
757
  shouldIncludeInUrl,
758
758
  withQuery
759
- } from "./chunk-UAKWSR3U.js";
759
+ } from "./chunk-GDZ7IC5B.js";
760
760
  import {
761
761
  Checkbox
762
762
  } from "./chunk-HLCJPRXP.js";
@@ -1158,7 +1158,7 @@ import {
1158
1158
  useVideoOriginPreconnect,
1159
1159
  useVideoWarmup,
1160
1160
  usesCanonicalStatusStyle
1161
- } from "./chunk-4BUPMSLY.js";
1161
+ } from "./chunk-Y7ZEVTLC.js";
1162
1162
  import {
1163
1163
  HEADING_EMOJI_RE,
1164
1164
  HUB_HEADER_OFFSET_PX,
@@ -1541,7 +1541,7 @@ import {
1541
1541
  urlPathLooksLikeSvg,
1542
1542
  useCoverImageFallback,
1543
1543
  webinarTiming
1544
- } from "./chunk-22RSJ57Z.js";
1544
+ } from "./chunk-2YVTGPM7.js";
1545
1545
  import "./chunk-MDKCTSDS.js";
1546
1546
  import {
1547
1547
  EMBED_PROXY_OPTIONAL_HEADERS,
@@ -1588,7 +1588,7 @@ import {
1588
1588
  useAuthedImageSrc,
1589
1589
  useImageEdgeColor,
1590
1590
  useOgPlaceholderUrl
1591
- } from "./chunk-2KILTCND.js";
1591
+ } from "./chunk-UVUNBXS6.js";
1592
1592
  import {
1593
1593
  FigmaIcon,
1594
1594
  ImageIcon,
@@ -71,6 +71,16 @@ export interface EmbedAuthAdapter {
71
71
  * remains the rule, this is the narrow exception.
72
72
  */
73
73
  allowedOrigins?: string[];
74
+ /**
75
+ * Optional: call `listener` whenever `getHeaders()` starts returning a NEW
76
+ * credential (a rotation the host ran on its own — e.g. a native shell's
77
+ * background refresh). Returns an unsubscribe. Lets a long-lived surface
78
+ * that stopped after a 401 retry as soon as a usable credential exists,
79
+ * instead of on its next backoff step. Fire only on a real change: a
80
+ * listener may respond with a request, and through `refresh` that request
81
+ * can lead the host to notify again.
82
+ */
83
+ subscribe?: (listener: () => void) => () => void;
74
84
  }
75
85
  /**
76
86
  * Register a host-owned auth adapter for `embedAuthedFetch`. Pass `null`
@@ -90,6 +100,14 @@ export declare function setEmbedAuthAdapter(adapter: EmbedAuthAdapter | null): v
90
100
  * single auth knob (the adapter), not a second content-fetch registration.
91
101
  */
92
102
  export declare function hasEmbedAuthAdapter(): boolean;
103
+ /**
104
+ * Subscribe to the registered adapter's credential changes
105
+ * (`EmbedAuthAdapter.subscribe`). A no-op when no adapter is registered, or
106
+ * the adapter doesn't report changes. Reads the adapter once, at call time:
107
+ * an adapter registered (or replaced) after a subscriber starts is not
108
+ * picked up — register it before the surfaces that need it mount.
109
+ */
110
+ export declare function subscribeEmbedCredentialChange(listener: () => void): () => void;
93
111
  /**
94
112
  * Whether `url` is an asset the browser CANNOT load natively because its
95
113
  * auth rides in request headers.
@@ -1 +1 @@
1
- {"version":3,"file":"embed-authed-fetch.d.ts","sourceRoot":"","sources":["../../src/utils/embed-authed-fetch.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;4EAMwE;IACxE,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACtD;;6EAEyE;IACzE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAS1E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAiB1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkCvF"}
1
+ {"version":3,"file":"embed-authed-fetch.d.ts","sourceRoot":"","sources":["../../src/utils/embed-authed-fetch.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;4EAMwE;IACxE,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACtD;;6EAEyE;IACzE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CAClD;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAS1E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAE/E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAiB1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkCvF"}
@@ -3772,6 +3772,10 @@ function setEmbedAuthAdapter(adapter2) {
3772
3772
  }
3773
3773
  storeRegisteredAuthAdapter(adapter2);
3774
3774
  }
3775
+ function subscribeEmbedCredentialChange(listener) {
3776
+ return getRegisteredAuthAdapter()?.subscribe?.(listener) ?? (() => {
3777
+ });
3778
+ }
3775
3779
  function embedAuthedFetch(url, init = {}) {
3776
3780
  assertSameOrigin(url);
3777
3781
  let baseHeaders;
@@ -3879,6 +3883,9 @@ var SUBSCRIBE_CONFIRM_TIMEOUT_MS = 15e3;
3879
3883
  var SERVER_RETRY_GRACE_MS = 9e4;
3880
3884
  var FAILED_RECONNECT_DELAY_MS = 3e4;
3881
3885
  var HIDDEN_GRACE_MS = 45e3;
3886
+ var AUTH_RETRY_INITIAL_MS = 3e4;
3887
+ var AUTH_RETRY_MAX_MS = 3e5;
3888
+ var PRESENCE_RETRY_MIN_INTERVAL_MS = 3e4;
3882
3889
  function createSseSubscription(options) {
3883
3890
  const {
3884
3891
  url,
@@ -3894,6 +3901,10 @@ function createSseSubscription(options) {
3894
3901
  let closed = false;
3895
3902
  let suspended = false;
3896
3903
  let attempt = 0;
3904
+ let authAttempt = 0;
3905
+ let stalled = false;
3906
+ let awaitingAuth = false;
3907
+ let lastConnectAt = 0;
3897
3908
  let generation = 0;
3898
3909
  let abortController = null;
3899
3910
  let retryTimerId = null;
@@ -3970,7 +3981,6 @@ function createSseSubscription(options) {
3970
3981
  confirmTimerId = clearLifecycleTimer(confirmTimerId);
3971
3982
  serverGraceTimerId = clearLifecycleTimer(serverGraceTimerId);
3972
3983
  failedDelayTimerId = clearLifecycleTimer(failedDelayTimerId);
3973
- hiddenGraceTimerId = clearLifecycleTimer(hiddenGraceTimerId);
3974
3984
  };
3975
3985
  const armSilenceTimer = () => {
3976
3986
  if (silenceTimerId) clearTimeout(silenceTimerId);
@@ -3978,16 +3988,23 @@ function createSseSubscription(options) {
3978
3988
  abortController?.abort();
3979
3989
  }, silenceTimeoutMs);
3980
3990
  };
3981
- const scheduleReconnect = () => {
3991
+ const scheduleReconnect = (delayMs) => {
3982
3992
  if (closed || suspended || retryTimerId) return;
3983
- setStatus("reconnecting");
3984
- const backoff = Math.min(maxBackoffMs, initialBackoffMs * 2 ** attempt);
3993
+ if (failedDelayTimerId) {
3994
+ setStatus("reconnecting");
3995
+ return;
3996
+ }
3997
+ let backoff = delayMs;
3998
+ if (backoff === void 0) {
3999
+ backoff = Math.min(maxBackoffMs, initialBackoffMs * 2 ** attempt);
4000
+ attempt += 1;
4001
+ }
3985
4002
  const jitter = backoff * 0.25 * Math.random();
3986
- attempt += 1;
3987
4003
  retryTimerId = setTimeout(() => {
3988
4004
  retryTimerId = null;
3989
4005
  void connect();
3990
4006
  }, backoff + jitter);
4007
+ setStatus("reconnecting");
3991
4008
  };
3992
4009
  const parseFrame = (rawFrame) => {
3993
4010
  let eventName = "message";
@@ -4019,6 +4036,9 @@ function createSseSubscription(options) {
4019
4036
  async function connect() {
4020
4037
  if (closed || suspended) return;
4021
4038
  const gen = ++generation;
4039
+ stalled = false;
4040
+ awaitingAuth = false;
4041
+ lastConnectAt = Date.now();
4022
4042
  setStatus("connecting");
4023
4043
  abortController = new AbortController();
4024
4044
  let response;
@@ -4046,9 +4066,19 @@ function createSseSubscription(options) {
4046
4066
  return;
4047
4067
  }
4048
4068
  const blockLayer = response.headers.get("x-block-layer");
4069
+ const blockNote = blockLayer ? ` (x-block-layer: ${blockLayer})` : "";
4070
+ if (response.status === 401 && pauseWhenHidden) {
4071
+ const delayMs = Math.min(AUTH_RETRY_MAX_MS, AUTH_RETRY_INITIAL_MS * 2 ** authAttempt);
4072
+ authAttempt += 1;
4073
+ console.warn(`[sse-subscription] 401 for ${url}${blockNote} \u2014 retrying in ~${Math.round(delayMs / 1e3)}s`);
4074
+ awaitingAuth = true;
4075
+ scheduleReconnect(delayMs);
4076
+ return;
4077
+ }
4049
4078
  console.warn(
4050
- `[sse-subscription] terminal ${response.status} for ${url}${blockLayer ? ` (x-block-layer: ${blockLayer})` : ""} \u2014 not retrying`
4079
+ `[sse-subscription] terminal ${response.status} for ${url}${blockNote} \u2014 ${pauseWhenHidden ? "retrying on presence" : "not retrying"}`
4051
4080
  );
4081
+ stalled = pauseWhenHidden;
4052
4082
  setStatus("terminal");
4053
4083
  return;
4054
4084
  }
@@ -4057,6 +4087,7 @@ function createSseSubscription(options) {
4057
4087
  return;
4058
4088
  }
4059
4089
  attempt = 0;
4090
+ authAttempt = 0;
4060
4091
  setStatus("open");
4061
4092
  armSilenceTimer();
4062
4093
  confirmTimerId = clearLifecycleTimer(confirmTimerId);
@@ -4118,6 +4149,10 @@ function createSseSubscription(options) {
4118
4149
  abortController?.abort();
4119
4150
  setStatus("suspended");
4120
4151
  };
4152
+ const retryIfStalled = () => {
4153
+ if (!stalled || Date.now() - lastConnectAt < PRESENCE_RETRY_MIN_INTERVAL_MS) return;
4154
+ doReconnect();
4155
+ };
4121
4156
  const onVisibilityChange = () => {
4122
4157
  if (document.visibilityState === "hidden") {
4123
4158
  if (!hiddenGraceTimerId) {
@@ -4132,15 +4167,21 @@ function createSseSubscription(options) {
4132
4167
  if (suspended) {
4133
4168
  suspended = false;
4134
4169
  void connect();
4170
+ return;
4135
4171
  }
4172
+ retryIfStalled();
4136
4173
  };
4137
4174
  const onOnline = () => {
4138
4175
  if (!suspended) doReconnect();
4139
4176
  };
4177
+ const unsubscribeCredentials = pauseWhenHidden && fetchImpl === embedAuthedFetch ? subscribeEmbedCredentialChange(() => {
4178
+ if (awaitingAuth) doReconnect();
4179
+ }) : null;
4140
4180
  const listenersActive = pauseWhenHidden && typeof document !== "undefined" && typeof window !== "undefined";
4141
4181
  if (listenersActive) {
4142
4182
  document.addEventListener("visibilitychange", onVisibilityChange);
4143
4183
  window.addEventListener("online", onOnline);
4184
+ window.addEventListener("focus", retryIfStalled);
4144
4185
  }
4145
4186
  void connect();
4146
4187
  return {
@@ -4149,11 +4190,14 @@ function createSseSubscription(options) {
4149
4190
  closed = true;
4150
4191
  generation += 1;
4151
4192
  clearTimers();
4193
+ hiddenGraceTimerId = clearLifecycleTimer(hiddenGraceTimerId);
4152
4194
  abortController?.abort();
4153
4195
  if (listenersActive) {
4154
4196
  document.removeEventListener("visibilitychange", onVisibilityChange);
4155
4197
  window.removeEventListener("online", onOnline);
4198
+ window.removeEventListener("focus", retryIfStalled);
4156
4199
  }
4200
+ unsubscribeCredentials?.();
4157
4201
  setConnected(false);
4158
4202
  onStatusChange?.("closed");
4159
4203
  },