@utk09/ui-observability 0.10.0 → 0.11.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.
Files changed (186) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/README.md +50 -11
  3. package/dist/{batch-BHXypM1j.cjs → batch-C8OcWR2L.cjs} +2 -2
  4. package/dist/{batch-BHXypM1j.cjs.map → batch-C8OcWR2L.cjs.map} +1 -1
  5. package/dist/{batch-BMdT9mKm.js → batch-CL9uWYY3.js} +4 -5
  6. package/dist/{batch-BMdT9mKm.js.map → batch-CL9uWYY3.js.map} +1 -1
  7. package/dist/{bus-DKfBaica.js → bus-BZ0GldpT.js} +23 -27
  8. package/dist/{bus-DKfBaica.js.map → bus-BZ0GldpT.js.map} +1 -1
  9. package/dist/{bus-Dea9rVhy.cjs → bus-VWlmM5xs.cjs} +2 -2
  10. package/dist/{bus-Dea9rVhy.cjs.map → bus-VWlmM5xs.cjs.map} +1 -1
  11. package/dist/console-BPZCuSLc.cjs +2 -0
  12. package/dist/{console-DZEcs7FL.cjs.map → console-BPZCuSLc.cjs.map} +1 -1
  13. package/dist/{console-BX_0UCV7.js → console-BeCF7n59.js} +14 -15
  14. package/dist/{console-BX_0UCV7.js.map → console-BeCF7n59.js.map} +1 -1
  15. package/dist/{constants-CL0ZdI2f.cjs → constants-DqKJH_MP.cjs} +2 -2
  16. package/dist/{constants-CL0ZdI2f.cjs.map → constants-DqKJH_MP.cjs.map} +1 -1
  17. package/dist/{constants-CU60FG4w.js → constants-zyrqveN4.js} +3 -4
  18. package/dist/{constants-CU60FG4w.js.map → constants-zyrqveN4.js.map} +1 -1
  19. package/dist/context-storage-BjzeBSxH.cjs.map +1 -1
  20. package/dist/{context-storage-DxZf4Gfh.js → context-storage-BzkoHzkQ.js} +2 -3
  21. package/dist/{context-storage-DxZf4Gfh.js.map → context-storage-BzkoHzkQ.js.map} +1 -1
  22. package/dist/{deadline-5_PecIl5.js → deadline-BOjOxNHj.js} +3 -5
  23. package/dist/{deadline-5_PecIl5.js.map → deadline-BOjOxNHj.js.map} +1 -1
  24. package/dist/deadline-XSnm95pg.cjs.map +1 -1
  25. package/dist/{debug-bundle-yRkrU1ny.cjs → debug-bundle-BzJNpbF0.cjs} +2 -2
  26. package/dist/{debug-bundle-yRkrU1ny.cjs.map → debug-bundle-BzJNpbF0.cjs.map} +1 -1
  27. package/dist/{debug-bundle-CZZ6SQQh.js → debug-bundle-C7UkHZ-q.js} +5 -6
  28. package/dist/{debug-bundle-CZZ6SQQh.js.map → debug-bundle-C7UkHZ-q.js.map} +1 -1
  29. package/dist/doctor.cjs +1 -1
  30. package/dist/doctor.cjs.map +1 -1
  31. package/dist/doctor.js +3 -4
  32. package/dist/{emergency-queue-CQ-9acZf.cjs → emergency-queue-CNTRui5t.cjs} +2 -2
  33. package/dist/{emergency-queue-CQ-9acZf.cjs.map → emergency-queue-CNTRui5t.cjs.map} +1 -1
  34. package/dist/{emergency-queue-Cs8-i2xw.js → emergency-queue-Zy6lNafo.js} +15 -17
  35. package/dist/{emergency-queue-Cs8-i2xw.js.map → emergency-queue-Zy6lNafo.js.map} +1 -1
  36. package/dist/{error-like-Ywo5uRHo.js → error-like-B11pB4aL.js} +2 -3
  37. package/dist/{error-like-Ywo5uRHo.js.map → error-like-B11pB4aL.js.map} +1 -1
  38. package/dist/error-like-gGRx2s36.cjs.map +1 -1
  39. package/dist/{errors-oyxrpHjY.js → errors-Dh7kef0i.js} +5 -6
  40. package/dist/{errors-oyxrpHjY.js.map → errors-Dh7kef0i.js.map} +1 -1
  41. package/dist/{errors-CigX45pL.cjs → errors-tfEr48bS.cjs} +2 -2
  42. package/dist/{errors-CigX45pL.cjs.map → errors-tfEr48bS.cjs.map} +1 -1
  43. package/dist/{factory-Bgsky_e0.js → factory-BonqI3NL.js} +9 -13
  44. package/dist/{factory-Bgsky_e0.js.map → factory-BonqI3NL.js.map} +1 -1
  45. package/dist/{factory-BkjNzPYL.cjs → factory-CJXVYp0R.cjs} +2 -2
  46. package/dist/{factory-BkjNzPYL.cjs.map → factory-CJXVYp0R.cjs.map} +1 -1
  47. package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
  48. package/dist/{fixed-window-CtaFHanJ.js → fixed-window-Dq3MLUUv.js} +2 -3
  49. package/dist/{fixed-window-CtaFHanJ.js.map → fixed-window-Dq3MLUUv.js.map} +1 -1
  50. package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
  51. package/dist/{global-scope-dp2jADRl.js → global-scope-D9I8s-oN.js} +2 -3
  52. package/dist/{global-scope-dp2jADRl.js.map → global-scope-D9I8s-oN.js.map} +1 -1
  53. package/dist/{guards-CpvOpJL6.js → guards-Cidk71ME.js} +2 -3
  54. package/dist/{guards-CpvOpJL6.js.map → guards-Cidk71ME.js.map} +1 -1
  55. package/dist/guards-nJ70syPt.cjs.map +1 -1
  56. package/dist/{identity-BMlKGHUM.cjs → identity-Cxgj6pZX.cjs} +2 -2
  57. package/dist/{identity-BMlKGHUM.cjs.map → identity-Cxgj6pZX.cjs.map} +1 -1
  58. package/dist/{identity-DOaHdfhT.js → identity-DT5VmvXy.js} +3 -4
  59. package/dist/{identity-DOaHdfhT.js.map → identity-DT5VmvXy.js.map} +1 -1
  60. package/dist/index.cjs +1 -1
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.js +46 -56
  63. package/dist/index.js.map +1 -1
  64. package/dist/{indexeddb-storage-D-lUW_5P.js → indexeddb-storage-BJVtiQKm.js} +5 -6
  65. package/dist/{indexeddb-storage-D-lUW_5P.js.map → indexeddb-storage-BJVtiQKm.js.map} +1 -1
  66. package/dist/{indexeddb-storage-CaXGJqDD.cjs → indexeddb-storage-CIoW21Xd.cjs} +2 -2
  67. package/dist/{indexeddb-storage-CaXGJqDD.cjs.map → indexeddb-storage-CIoW21Xd.cjs.map} +1 -1
  68. package/dist/{interactions-CqDNrtIR.js → interactions-DTgKy_6K.js} +10 -11
  69. package/dist/{interactions-CqDNrtIR.js.map → interactions-DTgKy_6K.js.map} +1 -1
  70. package/dist/{interactions-8DgxtmgO.cjs → interactions-fEN6FbVo.cjs} +2 -2
  71. package/dist/{interactions-8DgxtmgO.cjs.map → interactions-fEN6FbVo.cjs.map} +1 -1
  72. package/dist/{journey-DgIjhrIc.js → journey-CuJrHzEg.js} +9 -10
  73. package/dist/{journey-DgIjhrIc.js.map → journey-CuJrHzEg.js.map} +1 -1
  74. package/dist/{journey-5tcxEbnG.cjs → journey-pffMVMfa.cjs} +2 -2
  75. package/dist/{journey-5tcxEbnG.cjs.map → journey-pffMVMfa.cjs.map} +1 -1
  76. package/dist/keys-BHhw_0Wh.cjs.map +1 -1
  77. package/dist/{keys-D5r_GH9q.js → keys-BU9j5YqW.js} +2 -3
  78. package/dist/{keys-D5r_GH9q.js.map → keys-BU9j5YqW.js.map} +1 -1
  79. package/dist/library-console-C1m6g1BR.js +13 -0
  80. package/dist/{library-console-CabK2j2-.js.map → library-console-C1m6g1BR.js.map} +1 -1
  81. package/dist/{library-console-g_VU-wzP.cjs → library-console-D2GY9Or6.cjs} +2 -2
  82. package/dist/{library-console-g_VU-wzP.cjs.map → library-console-D2GY9Or6.cjs.map} +1 -1
  83. package/dist/{library-request-FQaiWjCP.cjs → library-request-1BX_UlaX.cjs} +2 -2
  84. package/dist/{library-request-FQaiWjCP.cjs.map → library-request-1BX_UlaX.cjs.map} +1 -1
  85. package/dist/{library-request-CyC-9IOk.js → library-request-BQBT9N9Q.js} +4 -5
  86. package/dist/{library-request-CyC-9IOk.js.map → library-request-BQBT9N9Q.js.map} +1 -1
  87. package/dist/{lifecycle-C2z_d8OX.cjs → lifecycle-2EtUaRpo.cjs} +2 -2
  88. package/dist/{lifecycle-C2z_d8OX.cjs.map → lifecycle-2EtUaRpo.cjs.map} +1 -1
  89. package/dist/{lifecycle-BLC4VU7c.js → lifecycle-BaKx_-32.js} +3 -4
  90. package/dist/{lifecycle-BLC4VU7c.js.map → lifecycle-BaKx_-32.js.map} +1 -1
  91. package/dist/{log-record-CndanC-p.js → log-record-CAoGBBf3.js} +3 -4
  92. package/dist/{log-record-CndanC-p.js.map → log-record-CAoGBBf3.js.map} +1 -1
  93. package/dist/{log-record-DKvo-B-d.cjs → log-record-i9zOTkpQ.cjs} +2 -2
  94. package/dist/{log-record-DKvo-B-d.cjs.map → log-record-i9zOTkpQ.cjs.map} +1 -1
  95. package/dist/{long-frames-CV5ZG2cx.cjs → long-frames-BVg4i5SC.cjs} +2 -2
  96. package/dist/{long-frames-CV5ZG2cx.cjs.map → long-frames-BVg4i5SC.cjs.map} +1 -1
  97. package/dist/{long-frames-BQef9rXR.js → long-frames-Czk7IupC.js} +4 -5
  98. package/dist/{long-frames-BQef9rXR.js.map → long-frames-Czk7IupC.js.map} +1 -1
  99. package/dist/{network-CvkvYzRU.js → network-DBNwApoF.js} +22 -24
  100. package/dist/{network-CvkvYzRU.js.map → network-DBNwApoF.js.map} +1 -1
  101. package/dist/{network-CqnQOqon.cjs → network-xbbuvG_6.cjs} +2 -2
  102. package/dist/{network-CqnQOqon.cjs.map → network-xbbuvG_6.cjs.map} +1 -1
  103. package/dist/openfin-Bxelt0yg.js +7 -0
  104. package/dist/{openfin-BwEN0uj4.js.map → openfin-Bxelt0yg.js.map} +1 -1
  105. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  106. package/dist/{otlp-RVbkNQRh.cjs → otlp-BDvFrLnc.cjs} +2 -2
  107. package/dist/{otlp-RVbkNQRh.cjs.map → otlp-BDvFrLnc.cjs.map} +1 -1
  108. package/dist/{otlp-CYIL7MOE.js → otlp-BTJdIa6F.js} +4 -6
  109. package/dist/{otlp-CYIL7MOE.js.map → otlp-BTJdIa6F.js.map} +1 -1
  110. package/dist/patch-BX8KrPCT.cjs.map +1 -1
  111. package/dist/{patch-CCWfuEY7.js → patch-UdPz1ea8.js} +2 -3
  112. package/dist/{patch-CCWfuEY7.js.map → patch-UdPz1ea8.js.map} +1 -1
  113. package/dist/{platform-KMWkoI-v.cjs → platform-C2Ez5kDc.cjs} +2 -2
  114. package/dist/{platform-KMWkoI-v.cjs.map → platform-C2Ez5kDc.cjs.map} +1 -1
  115. package/dist/{platform-wcAkkv9F.js → platform-DkcuXwe-.js} +4 -5
  116. package/dist/{platform-wcAkkv9F.js.map → platform-DkcuXwe-.js.map} +1 -1
  117. package/dist/{remote-rules-CH_7PphT.js → remote-rules-Cfb4K-Nl.js} +5 -6
  118. package/dist/{remote-rules-CH_7PphT.js.map → remote-rules-Cfb4K-Nl.js.map} +1 -1
  119. package/dist/{remote-rules-BL8km4xk.cjs → remote-rules-vzvk7aKf.cjs} +2 -2
  120. package/dist/{remote-rules-BL8km4xk.cjs.map → remote-rules-vzvk7aKf.cjs.map} +1 -1
  121. package/dist/{reports-Bh_-KpZ2.cjs → reports-Dk2YhKIh.cjs} +2 -2
  122. package/dist/{reports-Bh_-KpZ2.cjs.map → reports-Dk2YhKIh.cjs.map} +1 -1
  123. package/dist/{reports-BOKyY3_A.js → reports-TA-zInnq.js} +4 -5
  124. package/dist/{reports-BOKyY3_A.js.map → reports-TA-zInnq.js.map} +1 -1
  125. package/dist/{resource-timing-BROnEJ0E.js → resource-timing-BLv3EA2A.js} +6 -7
  126. package/dist/{resource-timing-BROnEJ0E.js.map → resource-timing-BLv3EA2A.js.map} +1 -1
  127. package/dist/{resource-timing-CbgwNpog.cjs → resource-timing-Cysw1S1f.cjs} +2 -2
  128. package/dist/{resource-timing-CbgwNpog.cjs.map → resource-timing-Cysw1S1f.cjs.map} +1 -1
  129. package/dist/{sampling-BLO_pcV4.js → sampling-C4VV-1MS.js} +4 -5
  130. package/dist/{sampling-BLO_pcV4.js.map → sampling-C4VV-1MS.js.map} +1 -1
  131. package/dist/{sampling-ECGVYiDD.cjs → sampling-Ckh2yW9k.cjs} +2 -2
  132. package/dist/{sampling-ECGVYiDD.cjs.map → sampling-Ckh2yW9k.cjs.map} +1 -1
  133. package/dist/{sanitize-DS0G4_ea.js → sanitize-6ymPlVvP.js} +4 -5
  134. package/dist/{sanitize-DS0G4_ea.js.map → sanitize-6ymPlVvP.js.map} +1 -1
  135. package/dist/{sanitize-Bsn8HQWC.cjs → sanitize-BAWzkZt0.cjs} +2 -2
  136. package/dist/{sanitize-Bsn8HQWC.cjs.map → sanitize-BAWzkZt0.cjs.map} +1 -1
  137. package/dist/{select-DWO0-w8_.cjs → select-ZF4by-lF.cjs} +2 -2
  138. package/dist/{select-DWO0-w8_.cjs.map → select-ZF4by-lF.cjs.map} +1 -1
  139. package/dist/{select-wqt9Wxio.js → select-xtQaenIi.js} +7 -10
  140. package/dist/{select-wqt9Wxio.js.map → select-xtQaenIi.js.map} +1 -1
  141. package/dist/{sender-BkAVt-Rq.js → sender-CiMHC9YG.js} +92 -96
  142. package/dist/{sender-BkAVt-Rq.js.map → sender-CiMHC9YG.js.map} +1 -1
  143. package/dist/{sender-D82PxlCY.cjs → sender-D5wBoXA8.cjs} +2 -2
  144. package/dist/{sender-D82PxlCY.cjs.map → sender-D5wBoXA8.cjs.map} +1 -1
  145. package/dist/storage-BA9RqRO-.cjs.map +1 -1
  146. package/dist/{storage-w7Tslvlq.js → storage-DZwed89z.js} +2 -3
  147. package/dist/{storage-w7Tslvlq.js.map → storage-DZwed89z.js.map} +1 -1
  148. package/dist/{storm-DCEsqViG.cjs → storm-CYi9Swpx.cjs} +2 -2
  149. package/dist/{storm-DCEsqViG.cjs.map → storm-CYi9Swpx.cjs.map} +1 -1
  150. package/dist/{storm-DD4cUkoL.js → storm-VR024_QN.js} +4 -5
  151. package/dist/{storm-DD4cUkoL.js.map → storm-VR024_QN.js.map} +1 -1
  152. package/dist/{types-BR9t_w28.js → types-BAerHgCq.js} +2 -3
  153. package/dist/{types-BR9t_w28.js.map → types-BAerHgCq.js.map} +1 -1
  154. package/dist/types-C7WNpnG1.cjs.map +1 -1
  155. package/dist/{unclean-exit-BYZ5yaSI.js → unclean-exit-CwcUhFOn.js} +3 -4
  156. package/dist/{unclean-exit-BYZ5yaSI.js.map → unclean-exit-CwcUhFOn.js.map} +1 -1
  157. package/dist/{unclean-exit-CwdpbUDg.cjs → unclean-exit-DFUN57wY.cjs} +2 -2
  158. package/dist/{unclean-exit-CwdpbUDg.cjs.map → unclean-exit-DFUN57wY.cjs.map} +1 -1
  159. package/dist/{user-timing-C1kB3JEg.cjs → user-timing-C9kfRq3J.cjs} +2 -2
  160. package/dist/{user-timing-C1kB3JEg.cjs.map → user-timing-C9kfRq3J.cjs.map} +1 -1
  161. package/dist/{user-timing-Di2ra5DB.js → user-timing-_jZIhDKI.js} +4 -5
  162. package/dist/{user-timing-Di2ra5DB.js.map → user-timing-_jZIhDKI.js.map} +1 -1
  163. package/dist/{web-socket-DwBNhgre.cjs → web-socket-BWUoqBh8.cjs} +2 -2
  164. package/dist/{web-socket-DwBNhgre.cjs.map → web-socket-BWUoqBh8.cjs.map} +1 -1
  165. package/dist/{web-socket-B-5qqPy7.js → web-socket-CV7yIMnm.js} +14 -15
  166. package/dist/{web-socket-B-5qqPy7.js.map → web-socket-CV7yIMnm.js.map} +1 -1
  167. package/dist/{web-vitals-Bflr5jSA.js → web-vitals-Bq4WFHQo.js} +2 -3
  168. package/dist/{web-vitals-Bflr5jSA.js.map → web-vitals-Bq4WFHQo.js.map} +1 -1
  169. package/dist/web-vitals-DFuoTQbZ.cjs.map +1 -1
  170. package/dist/{worker-protocol-DXekoADQ.cjs → worker-protocol-Bai7GAIA.cjs} +2 -2
  171. package/dist/{worker-protocol-DXekoADQ.cjs.map → worker-protocol-Bai7GAIA.cjs.map} +1 -1
  172. package/dist/{worker-protocol-0HMf4-kY.js → worker-protocol-CrsdSDLn.js} +6 -7
  173. package/dist/{worker-protocol-0HMf4-kY.js.map → worker-protocol-CrsdSDLn.js.map} +1 -1
  174. package/dist/worker-server-BrIYkfoa.cjs +2 -0
  175. package/dist/{worker-server-BQK5z2yl.cjs.map → worker-server-BrIYkfoa.cjs.map} +1 -1
  176. package/dist/{worker-server-CKcmX5m5.js → worker-server-Dp5HYm4b.js} +25 -26
  177. package/dist/{worker-server-CKcmX5m5.js.map → worker-server-Dp5HYm4b.js.map} +1 -1
  178. package/dist/{worker-transport-Dj2yCQN5.cjs → worker-transport-Bwej4N2e.cjs} +2 -2
  179. package/dist/{worker-transport-Dj2yCQN5.cjs.map → worker-transport-Bwej4N2e.cjs.map} +1 -1
  180. package/dist/{worker-transport-2220ghFZ.js → worker-transport-D6jtgpqN.js} +9 -11
  181. package/dist/{worker-transport-2220ghFZ.js.map → worker-transport-D6jtgpqN.js.map} +1 -1
  182. package/package.json +27 -41
  183. package/dist/console-DZEcs7FL.cjs +0 -2
  184. package/dist/library-console-CabK2j2-.js +0 -14
  185. package/dist/openfin-BwEN0uj4.js +0 -8
  186. package/dist/worker-server-BQK5z2yl.cjs +0 -2
@@ -1,8 +1,8 @@
1
- import { Bt as e, C as t, S as n, St as r, T as i, bt as a, w as o, x as s, xt as c, yt as l, zt as u } from "./constants-CU60FG4w.js";
2
- import { n as d, r as f } from "./deadline-5_PecIl5.js";
3
- import { t as p } from "./openfin-BwEN0uj4.js";
4
- import { i as m, t as h } from "./identity-DOaHdfhT.js";
5
- //#region src/core/journey.ts
1
+ import { Bt as e, C as t, S as n, St as r, T as i, bt as a, w as o, x as s, xt as c, yt as l, zt as u } from "./constants-zyrqveN4.js";
2
+ import { n as d, r as f } from "./deadline-BOjOxNHj.js";
3
+ import { i as p, t as m } from "./identity-DT5VmvXy.js";
4
+ import { t as h } from "./openfin-Bxelt0yg.js";
5
+ // src/core/journey.ts
6
6
  var g = {
7
7
  maxAgeMs: a,
8
8
  endOnOwnerClose: !1,
@@ -55,7 +55,7 @@ var S = class {
55
55
  stores;
56
56
  journey = null;
57
57
  expiryTimer = null;
58
- constructor(e, t, n, r, i = h) {
58
+ constructor(e, t, n, r, i = m) {
59
59
  this.options = e, this.diagnostics = t, this.contextId = n, this.onLocalChange = r, this.stores = i;
60
60
  }
61
61
  current() {
@@ -83,7 +83,7 @@ var S = class {
83
83
  return this.setJourney(n), this.onLocalChange(n), n;
84
84
  }
85
85
  journeyId(e) {
86
- return e === void 0 ? m(this.diagnostics) : typeof e == "string" && l.test(e) ? e : (this.diagnostics.report("config.invalid", "startJourney() needs an id of 1 to 64 letters, digits, \"_\", \".\", \":\" or \"-\". The library uses a new id."), m(this.diagnostics));
86
+ return e === void 0 ? p(this.diagnostics) : typeof e == "string" && l.test(e) ? e : (this.diagnostics.report("config.invalid", "startJourney() needs an id of 1 to 64 letters, digits, \"_\", \".\", \":\" or \"-\". The library uses a new id."), p(this.diagnostics));
87
87
  }
88
88
  end() {
89
89
  this.journey !== null && (this.setJourney(null), this.onLocalChange(null));
@@ -155,13 +155,12 @@ var S = class {
155
155
  });
156
156
  }
157
157
  async readOpenFinToken() {
158
- let t = p()?.me, n = t?.getOptions;
158
+ let t = h()?.me, n = t?.getOptions;
159
159
  if (n === void 0) return null;
160
160
  let r = (await this.diagnostics.guardAsync("openfin.unavailable", "The library could not read fin.me.getOptions().", () => d(n.call(t), e)))?.customData?.[u];
161
161
  return typeof r == "string" ? r : null;
162
162
  }
163
163
  };
164
- //#endregion
165
164
  export { S as n, y as r, g as t };
166
165
 
167
- //# sourceMappingURL=journey-DgIjhrIc.js.map
166
+ //# sourceMappingURL=journey-CuJrHzEg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"journey-DgIjhrIc.js","names":["OPENFIN_OPTIONS_TIMEOUT_MS","BASE64_PADDING_PATTERN","BASE64URL_UNDERSCORE_PATTERN","JOURNEY_URL_PARAM","BASE64_SLASH_PATTERN","JOURNEY_MAX_AGE_MS","BASE64_PLUS_PATTERN","BASE64URL_DASH_PATTERN","JOURNEY_STORAGE_KEY","JOURNEY_ID_PATTERN","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","withDeadline","unrefTimer","getFin","newId","BROWSER_STORES","JOURNEY_OPTIONS","readString","value","source","key","readNumber","parseJourney","id","name","startedAt","journeyFromTokenPayload","future","encodeToken","json","journey","bytes","binary","byte","JourneyEngine","options","diagnostics","contextId","onLocalChange","stores","fromUrl","fromStorage","fromOpenFin","opts","requested","current","token","decoded","broadcast","ownerContextId","raw","standard","missing","padding","c","remaining","timer","url","me","getOptions"],"sources":["../src/core/journey.ts"],"sourcesContent":["// src/core/journey.ts\n//\n// This module manages the lifecycle of a user journey across windows. It encodes tokens,\n// stores the journey and ends it at expiry. Do not trust a value from storage or a token.\n// Any code on the origin can write to both.\n\nimport {\n BASE64_GROUP_CHARS,\n BASE64_PADDING_PATTERN,\n BASE64_PLUS_PATTERN,\n BASE64_SLASH_PATTERN,\n BASE64URL_DASH_PATTERN,\n BASE64URL_UNDERSCORE_PATTERN,\n JOURNEY_END_ON_OWNER_CLOSE,\n JOURNEY_CLOCK_SKEW_MS,\n JOURNEY_ID_MAX_CHARS,\n JOURNEY_ID_PATTERN,\n JOURNEY_MAX_AGE_MS,\n JOURNEY_STORAGE_KEY,\n JOURNEY_TOKEN_MAX_CHARS,\n JOURNEY_TOKEN_NAME_MAX_CHARS,\n OPENFIN_JOURNEY_CUSTOM_DATA_KEY,\n JOURNEY_URL_PARAM,\n OPENFIN_OPTIONS_TIMEOUT_MS,\n} from \"../constants\";\nimport { withDeadline } from \"../utils/deadline\";\nimport { BROWSER_STORES, type IdentityStores, newId } from \"../utils/identity\";\nimport { getFin } from \"../utils/openfin\";\nimport { unrefTimer } from \"../utils/unref\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/** Lifetime rules for a journey. A journey is one user task across several contexts. */\nexport interface JourneyOptions {\n /** Maximum open time of a journey, in milliseconds. After this time, the engine ends it. */\n maxAgeMs: number;\n /** True if the journey ends for all contexts when the owning context closes. */\n endOnOwnerClose: boolean;\n /** Query parameter checked at boot for a seeded journey token. */\n urlParam: string;\n}\n\n/** Journey lifetime policy in force. Tests build an engine with shorter values. */\nexport const JOURNEY_OPTIONS: JourneyOptions = {\n maxAgeMs: JOURNEY_MAX_AGE_MS,\n endOnOwnerClose: JOURNEY_END_ON_OWNER_CLOSE,\n urlParam: JOURNEY_URL_PARAM,\n};\n\n/** User journey workflow context shared across windows and applications. */\nexport interface Journey {\n /** Unique journey correlation identifier. */\n id: string;\n /** Journey workflow name for a person to read. */\n name: string;\n /** Journey start timestamp in epoch milliseconds. */\n startedAt: number;\n /** Optional parent journey ID when the journey branches from an earlier journey. */\n parentId?: string;\n /** Context identifier of the document that started the journey. */\n ownerContextId: string;\n}\n\n/**\n * Reads a non-empty string property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Non-empty string value or undefined.\n */\nfunction readString(source: object, key: string): string | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\n/**\n * Reads a finite number property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Finite number value or undefined.\n */\nfunction readNumber(source: object, key: string): number | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n}\n\n/**\n * Parses and validates an unknown value into a Journey object. The value comes from\n * sessionStorage or from a bus message of another realm.\n * @param value Unverified parsed JSON value.\n * @returns Validated Journey instance or null.\n */\nexport function parseJourney(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"id\");\n const name = readString(value, \"name\");\n const startedAt = readNumber(value, \"startedAt\");\n if (id === undefined || name === undefined || startedAt === undefined) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: readString(value, \"parentId\"),\n ownerContextId: readString(value, \"ownerContextId\") ?? \"\",\n };\n}\n\n/**\n * Parses and validates decoded token payload into a Journey object.\n * @param value Unverified parsed token payload.\n * @returns Validated Journey instance or null.\n */\nfunction journeyFromTokenPayload(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"i\");\n const name = readString(value, \"n\");\n const startedAt = readNumber(value, \"s\");\n // The library always writes a start time. A token without one, or from the future, never expires.\n const future = startedAt !== undefined && startedAt > Date.now() + JOURNEY_CLOCK_SKEW_MS;\n if (id === undefined || name === undefined || startedAt === undefined || future) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: undefined,\n ownerContextId: \"\",\n };\n}\n\n/**\n * Encodes journey metadata into a compact, URL-safe base64 string.\n * @param journey Journey instance to serialize.\n * @returns Unpadded base64url encoded token string.\n */\nfunction encodeToken(journey: Journey): string {\n const json = JSON.stringify({\n i: journey.id,\n n: journey.name.slice(0, JOURNEY_TOKEN_NAME_MAX_CHARS),\n s: journey.startedAt,\n });\n // Convert the UTF-8 bytes to a binary string before btoa. btoa throws above U+00FF.\n // Without this step, a name in a non-Latin script fails.\n const bytes = new TextEncoder().encode(json);\n let binary = \"\";\n for (const byte of bytes) {\n binary += String.fromCharCode(byte);\n }\n return btoa(binary)\n .replace(BASE64_PLUS_PATTERN, \"-\")\n .replace(BASE64_SLASH_PATTERN, \"_\")\n .replace(BASE64_PADDING_PATTERN, \"\");\n}\n\n/** Manages journey lifecycle, cross-window adoption, storage synchronization, and expiration. */\nexport class JourneyEngine {\n /** Active journey context, or null if none is in progress. */\n private journey: Journey | null = null;\n\n /** Active expiration timer handle. */\n private expiryTimer: ReturnType<typeof setTimeout> | null = null;\n\n /**\n * @param options Journey configuration thresholds.\n * @param diagnostics Diagnostics reporter.\n * @param contextId Unique context identifier for this document.\n * @param onLocalChange Callback invoked when journey state changes locally.\n * @param stores Identity stores that hold the journey.\n */\n constructor(\n private readonly options: JourneyOptions,\n private readonly diagnostics: Diagnostics,\n private readonly contextId: string,\n private readonly onLocalChange: (journey: Journey | null) => void,\n private readonly stores: IdentityStores = BROWSER_STORES,\n ) {}\n\n /** Returns the active journey instance or null. */\n current(): Journey | null {\n return this.journey;\n }\n\n /**\n * Finds and adopts the initial journey. It checks the URL query, then sessionStorage,\n * then OpenFin customData.\n * @returns Promise that resolves when journey initialization completes.\n */\n async bootstrap(): Promise<void> {\n const fromUrl = this.readUrlToken();\n if (fromUrl && this.adopt(fromUrl, \"url\")) {\n this.removeUrlToken();\n return;\n }\n\n const fromStorage = this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the persisted journey.\",\n () => this.stores.session().getItem(JOURNEY_STORAGE_KEY),\n );\n if (fromStorage && this.restore(fromStorage)) {\n return;\n }\n\n const fromOpenFin = await this.readOpenFinToken();\n if (fromOpenFin !== null) {\n this.adopt(fromOpenFin, \"openfin.customData\");\n }\n }\n\n /**\n * Starts a new journey. It replaces the active journey and tells connected peers.\n * @param name Human-readable workflow name.\n * @param opts Optional parent linkage and pre-assigned identifier.\n * @returns Started Journey instance.\n */\n start(name: string, opts: { parent?: boolean; id?: string } = {}): Journey {\n const journey: Journey = {\n id: this.journeyId(opts.id),\n name,\n startedAt: Date.now(),\n parentId: opts.parent ? this.journey?.id : undefined,\n ownerContextId: this.contextId,\n };\n this.setJourney(journey);\n this.onLocalChange(journey);\n return journey;\n }\n\n /**\n * Gives the id of a new journey. A longer id, or an id with multibyte characters, makes the\n * journey token too long for adoptJourney().\n * @param requested Id from the app, or undefined.\n * @returns The requested id when it matches JOURNEY_ID_PATTERN, else a new id.\n */\n private journeyId(requested: unknown): string {\n if (requested === undefined) {\n return newId(this.diagnostics);\n }\n\n if (typeof requested === \"string\" && JOURNEY_ID_PATTERN.test(requested)) {\n return requested;\n }\n\n this.diagnostics.report(\n \"config.invalid\",\n `startJourney() needs an id of 1 to ${String(JOURNEY_ID_MAX_CHARS)} letters, digits, \"_\", \".\", \":\" or \"-\". The library uses a new id.`,\n );\n return newId(this.diagnostics);\n }\n\n /** Ends the active journey and broadcasts the change. */\n end(): void {\n if (this.journey === null) {\n return;\n }\n this.setJourney(null);\n this.onLocalChange(null);\n }\n\n /**\n * Applies a journey update from a bus peer. It does not broadcast the update again.\n * An echo makes two windows send the change back and forth without end.\n * It ignores a journey with the same ID as the active journey. Thus an echo cannot\n * restart the timer.\n * @param journey Updated Journey instance or null.\n */\n applyRemote(journey: Journey | null): void {\n const current = this.journey;\n if (journey !== null && current !== null && journey.id === current.id) {\n return;\n }\n this.setJourney(journey);\n }\n\n /**\n * Serializes the active journey into a compact token for URL or intent transfer.\n * @returns Base64url token, or undefined when no journey is active or the token exceeds\n * the size limit.\n */\n getToken(): string | undefined {\n const journey = this.journey;\n if (journey === null) {\n return undefined;\n }\n const token = encodeToken(journey);\n if (token.length > JOURNEY_TOKEN_MAX_CHARS) {\n this.diagnostics.report(\n \"journey.token_too_large\",\n \"The journey token is larger than the size limit. The library does not issue it.\",\n { length: token.length },\n );\n return undefined;\n }\n return token;\n }\n\n /**\n * Validates and adopts a serialized journey token.\n * @param token Base64url journey token.\n * @param source Originating source description for diagnostics.\n * @param broadcast True to send the adoption to the connected bus peers.\n * @returns True if the token was valid, unexpired, and adopted.\n */\n adopt(token: string, source: string, broadcast = false): boolean {\n const decoded = this.decodeToken(token);\n if (decoded === null) {\n return false;\n }\n if (Date.now() - decoded.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a seeded journey older than maxAgeMs.\",\n {\n source,\n name: decoded.name,\n },\n );\n return false;\n }\n\n this.setJourney(decoded);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library adopted the journey \"${decoded.name}\".`,\n {\n source,\n journeyId: decoded.id,\n },\n );\n if (broadcast) {\n this.onLocalChange(decoded);\n }\n return true;\n }\n\n /**\n * Ends the journey when endOnOwnerClose is on and the closed context owns the journey.\n * @param ownerContextId Context identifier of the closed window.\n */\n ownerClosed(ownerContextId: string): void {\n if (!this.options.endOnOwnerClose) {\n return;\n }\n if (this.journey?.ownerContextId === ownerContextId) {\n this.end();\n }\n }\n\n /** Clears pending expiration timers and releases resources on shutdown. */\n destroy(): void {\n this.clearTimer();\n }\n\n /**\n * Resumes a persisted journey from raw sessionStorage data.\n * @param raw Serialized JSON string from storage.\n * @returns True if the engine restored the journey.\n */\n private restore(raw: string): boolean {\n const parsed = this.diagnostics.guard(\n \"storage.degraded\",\n \"The library could not parse the persisted journey.\",\n () => JSON.parse(raw) as unknown,\n );\n const journey = parseJourney(parsed);\n if (journey === null) {\n return false;\n }\n\n if (Date.now() - journey.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a persisted journey older than maxAgeMs.\",\n { name: journey.name },\n );\n this.clearStored();\n return false;\n }\n\n this.setJourney(journey);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library resumed the journey \"${journey.name}\".`,\n {\n source: \"sessionStorage\",\n journeyId: journey.id,\n },\n );\n return true;\n }\n\n /**\n * Decodes a base64url token into a validated Journey object. Anyone can edit the URL\n * that holds a token. Each step throws on bad input. The guard reports the failure\n * and does not throw it.\n * @param token Encoded token string.\n * @returns Decoded Journey instance or null on decode error.\n */\n private decodeToken(token: string): Journey | null {\n const decoded = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not decode a seeded journey token.\",\n () => {\n const standard = token\n .replace(BASE64URL_DASH_PATTERN, \"+\")\n .replace(BASE64URL_UNDERSCORE_PATTERN, \"/\");\n const missing =\n (BASE64_GROUP_CHARS - (standard.length % BASE64_GROUP_CHARS)) % BASE64_GROUP_CHARS;\n const padding = \"=\".repeat(missing);\n const bytes = Uint8Array.from(atob(standard + padding), (c) => c.charCodeAt(0));\n return journeyFromTokenPayload(JSON.parse(new TextDecoder().decode(bytes)) as unknown);\n },\n );\n return decoded ?? null;\n }\n\n /**\n * Sets the active journey, updates sessionStorage, and schedules expiration.\n * @param journey Target Journey instance or null.\n */\n private setJourney(journey: Journey | null): void {\n this.journey = journey;\n this.clearTimer();\n\n this.diagnostics.guard(\"storage.unavailable\", \"The library could not save the journey.\", () => {\n if (journey !== null) {\n this.stores.session().setItem(JOURNEY_STORAGE_KEY, JSON.stringify(journey));\n } else {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n }\n });\n\n if (journey === null) {\n return;\n }\n\n const remaining = Math.max(this.options.maxAgeMs - (Date.now() - journey.startedAt), 0);\n const timer = setTimeout(() => {\n this.diagnostics.report(\n \"journey.expired\",\n `The journey \"${journey.name}\" reached maxAgeMs. The library ended it.`,\n { journeyId: journey.id },\n );\n this.journey = null;\n this.expiryTimer = null;\n this.clearStored();\n }, remaining);\n this.expiryTimer = timer;\n unrefTimer(timer);\n }\n\n /** Removes journey data from the session store. */\n private clearStored(): void {\n this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not clear the persisted journey.\",\n () => {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n },\n );\n }\n\n /** Cancels any active expiration timer. */\n private clearTimer(): void {\n if (this.expiryTimer !== null) {\n clearTimeout(this.expiryTimer);\n this.expiryTimer = null;\n }\n }\n\n /**\n * Extracts the journey token from the current window location search parameters.\n * @returns Token string or null.\n */\n private readUrlToken(): string | null {\n const token = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not read the journey token from the URL.\",\n () => {\n if (typeof location === \"undefined\") {\n return null;\n }\n return new URL(location.href).searchParams.get(this.options.urlParam);\n },\n );\n return token ?? null;\n }\n\n /**\n * Removes the journey token from the address bar after the engine adopts it.\n * If not, a copy or a bookmark of the link starts the same journey in another session.\n */\n private removeUrlToken(): void {\n this.diagnostics.guard(\n \"platform.api_blocked\",\n \"The library could not remove the journey token from the URL.\",\n () => {\n const url = new URL(location.href);\n url.searchParams.delete(this.options.urlParam);\n // Keep history.state. A router stores its own state there.\n history.replaceState(history.state, \"\", url.href);\n },\n );\n }\n\n /**\n * Reads the journey token from the customData of the OpenFin window options.\n * OPENFIN_OPTIONS_TIMEOUT_MS limits the wait. At the deadline, it reports\n * openfin.unavailable and returns no token. A window without a token gives the same result.\n * @returns Promise that resolves to token string or null.\n */\n private async readOpenFinToken(): Promise<string | null> {\n const me = getFin()?.me;\n const getOptions = me?.getOptions;\n if (getOptions === undefined) {\n return null;\n }\n\n // Use call to keep the receiver of the native OpenFin method. A detached copy\n // throws when called.\n const options = await this.diagnostics.guardAsync(\n \"openfin.unavailable\",\n \"The library could not read fin.me.getOptions().\",\n () => withDeadline(getOptions.call(me), OPENFIN_OPTIONS_TIMEOUT_MS),\n );\n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UNDERSCORE_PATTERN","JOURNEY_URL_PARAM","BASE64_SLASH_PATTERN","JOURNEY_MAX_AGE_MS","BASE64_PLUS_PATTERN","BASE64URL_DASH_PATTERN","JOURNEY_STORAGE_KEY","JOURNEY_ID_PATTERN","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","withDeadline","unrefTimer","newId","BROWSER_STORES","getFin","JOURNEY_OPTIONS","readString","value","source","key","readNumber","parseJourney","id","name","startedAt","journeyFromTokenPayload","future","encodeToken","json","journey","bytes","binary","byte","JourneyEngine","options","diagnostics","contextId","onLocalChange","stores","fromUrl","fromStorage","fromOpenFin","opts","requested","current","token","decoded","broadcast","ownerContextId","raw","standard","missing","padding","c","remaining","timer","url","me","getOptions"],"sources":["../src/core/journey.ts"],"sourcesContent":["// src/core/journey.ts\n//\n// This module manages the lifecycle of a user journey across windows. It encodes tokens,\n// stores the journey and ends it at expiry. Do not trust a value from storage or a token.\n// Any code on the origin can write to both.\n\nimport {\n BASE64_GROUP_CHARS,\n BASE64_PADDING_PATTERN,\n BASE64_PLUS_PATTERN,\n BASE64_SLASH_PATTERN,\n BASE64URL_DASH_PATTERN,\n BASE64URL_UNDERSCORE_PATTERN,\n JOURNEY_END_ON_OWNER_CLOSE,\n JOURNEY_CLOCK_SKEW_MS,\n JOURNEY_ID_MAX_CHARS,\n JOURNEY_ID_PATTERN,\n JOURNEY_MAX_AGE_MS,\n JOURNEY_STORAGE_KEY,\n JOURNEY_TOKEN_MAX_CHARS,\n JOURNEY_TOKEN_NAME_MAX_CHARS,\n OPENFIN_JOURNEY_CUSTOM_DATA_KEY,\n JOURNEY_URL_PARAM,\n OPENFIN_OPTIONS_TIMEOUT_MS,\n} from \"../constants\";\nimport { withDeadline } from \"../utils/deadline\";\nimport { BROWSER_STORES, type IdentityStores, newId } from \"../utils/identity\";\nimport { getFin } from \"../utils/openfin\";\nimport { unrefTimer } from \"../utils/unref\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/** Lifetime rules for a journey. A journey is one user task across several contexts. */\nexport interface JourneyOptions {\n /** Maximum open time of a journey, in milliseconds. After this time, the engine ends it. */\n maxAgeMs: number;\n /** True if the journey ends for all contexts when the owning context closes. */\n endOnOwnerClose: boolean;\n /** Query parameter checked at boot for a seeded journey token. */\n urlParam: string;\n}\n\n/** Journey lifetime policy in force. Tests build an engine with shorter values. */\nexport const JOURNEY_OPTIONS: JourneyOptions = {\n maxAgeMs: JOURNEY_MAX_AGE_MS,\n endOnOwnerClose: JOURNEY_END_ON_OWNER_CLOSE,\n urlParam: JOURNEY_URL_PARAM,\n};\n\n/** User journey workflow context shared across windows and applications. */\nexport interface Journey {\n /** Unique journey correlation identifier. */\n id: string;\n /** Journey workflow name for a person to read. */\n name: string;\n /** Journey start timestamp in epoch milliseconds. */\n startedAt: number;\n /** Optional parent journey ID when the journey branches from an earlier journey. */\n parentId?: string;\n /** Context identifier of the document that started the journey. */\n ownerContextId: string;\n}\n\n/**\n * Reads a non-empty string property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Non-empty string value or undefined.\n */\nfunction readString(source: object, key: string): string | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\n/**\n * Reads a finite number property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Finite number value or undefined.\n */\nfunction readNumber(source: object, key: string): number | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n}\n\n/**\n * Parses and validates an unknown value into a Journey object. The value comes from\n * sessionStorage or from a bus message of another realm.\n * @param value Unverified parsed JSON value.\n * @returns Validated Journey instance or null.\n */\nexport function parseJourney(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"id\");\n const name = readString(value, \"name\");\n const startedAt = readNumber(value, \"startedAt\");\n if (id === undefined || name === undefined || startedAt === undefined) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: readString(value, \"parentId\"),\n ownerContextId: readString(value, \"ownerContextId\") ?? \"\",\n };\n}\n\n/**\n * Parses and validates decoded token payload into a Journey object.\n * @param value Unverified parsed token payload.\n * @returns Validated Journey instance or null.\n */\nfunction journeyFromTokenPayload(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"i\");\n const name = readString(value, \"n\");\n const startedAt = readNumber(value, \"s\");\n // The library always writes a start time. A token without one, or from the future, never expires.\n const future = startedAt !== undefined && startedAt > Date.now() + JOURNEY_CLOCK_SKEW_MS;\n if (id === undefined || name === undefined || startedAt === undefined || future) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: undefined,\n ownerContextId: \"\",\n };\n}\n\n/**\n * Encodes journey metadata into a compact, URL-safe base64 string.\n * @param journey Journey instance to serialize.\n * @returns Unpadded base64url encoded token string.\n */\nfunction encodeToken(journey: Journey): string {\n const json = JSON.stringify({\n i: journey.id,\n n: journey.name.slice(0, JOURNEY_TOKEN_NAME_MAX_CHARS),\n s: journey.startedAt,\n });\n // Convert the UTF-8 bytes to a binary string before btoa. btoa throws above U+00FF.\n // Without this step, a name in a non-Latin script fails.\n const bytes = new TextEncoder().encode(json);\n let binary = \"\";\n for (const byte of bytes) {\n binary += String.fromCharCode(byte);\n }\n return btoa(binary)\n .replace(BASE64_PLUS_PATTERN, \"-\")\n .replace(BASE64_SLASH_PATTERN, \"_\")\n .replace(BASE64_PADDING_PATTERN, \"\");\n}\n\n/** Manages journey lifecycle, cross-window adoption, storage synchronization, and expiration. */\nexport class JourneyEngine {\n /** Active journey context, or null if none is in progress. */\n private journey: Journey | null = null;\n\n /** Active expiration timer handle. */\n private expiryTimer: ReturnType<typeof setTimeout> | null = null;\n\n /**\n * @param options Journey configuration thresholds.\n * @param diagnostics Diagnostics reporter.\n * @param contextId Unique context identifier for this document.\n * @param onLocalChange Callback invoked when journey state changes locally.\n * @param stores Identity stores that hold the journey.\n */\n constructor(\n private readonly options: JourneyOptions,\n private readonly diagnostics: Diagnostics,\n private readonly contextId: string,\n private readonly onLocalChange: (journey: Journey | null) => void,\n private readonly stores: IdentityStores = BROWSER_STORES,\n ) {}\n\n /** Returns the active journey instance or null. */\n current(): Journey | null {\n return this.journey;\n }\n\n /**\n * Finds and adopts the initial journey. It checks the URL query, then sessionStorage,\n * then OpenFin customData.\n * @returns Promise that resolves when journey initialization completes.\n */\n async bootstrap(): Promise<void> {\n const fromUrl = this.readUrlToken();\n if (fromUrl && this.adopt(fromUrl, \"url\")) {\n this.removeUrlToken();\n return;\n }\n\n const fromStorage = this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the persisted journey.\",\n () => this.stores.session().getItem(JOURNEY_STORAGE_KEY),\n );\n if (fromStorage && this.restore(fromStorage)) {\n return;\n }\n\n const fromOpenFin = await this.readOpenFinToken();\n if (fromOpenFin !== null) {\n this.adopt(fromOpenFin, \"openfin.customData\");\n }\n }\n\n /**\n * Starts a new journey. It replaces the active journey and tells connected peers.\n * @param name Human-readable workflow name.\n * @param opts Optional parent linkage and pre-assigned identifier.\n * @returns Started Journey instance.\n */\n start(name: string, opts: { parent?: boolean; id?: string } = {}): Journey {\n const journey: Journey = {\n id: this.journeyId(opts.id),\n name,\n startedAt: Date.now(),\n parentId: opts.parent ? this.journey?.id : undefined,\n ownerContextId: this.contextId,\n };\n this.setJourney(journey);\n this.onLocalChange(journey);\n return journey;\n }\n\n /**\n * Gives the id of a new journey. A longer id, or an id with multibyte characters, makes the\n * journey token too long for adoptJourney().\n * @param requested Id from the app, or undefined.\n * @returns The requested id when it matches JOURNEY_ID_PATTERN, else a new id.\n */\n private journeyId(requested: unknown): string {\n if (requested === undefined) {\n return newId(this.diagnostics);\n }\n\n if (typeof requested === \"string\" && JOURNEY_ID_PATTERN.test(requested)) {\n return requested;\n }\n\n this.diagnostics.report(\n \"config.invalid\",\n `startJourney() needs an id of 1 to ${String(JOURNEY_ID_MAX_CHARS)} letters, digits, \"_\", \".\", \":\" or \"-\". The library uses a new id.`,\n );\n return newId(this.diagnostics);\n }\n\n /** Ends the active journey and broadcasts the change. */\n end(): void {\n if (this.journey === null) {\n return;\n }\n this.setJourney(null);\n this.onLocalChange(null);\n }\n\n /**\n * Applies a journey update from a bus peer. It does not broadcast the update again.\n * An echo makes two windows send the change back and forth without end.\n * It ignores a journey with the same ID as the active journey. Thus an echo cannot\n * restart the timer.\n * @param journey Updated Journey instance or null.\n */\n applyRemote(journey: Journey | null): void {\n const current = this.journey;\n if (journey !== null && current !== null && journey.id === current.id) {\n return;\n }\n this.setJourney(journey);\n }\n\n /**\n * Serializes the active journey into a compact token for URL or intent transfer.\n * @returns Base64url token, or undefined when no journey is active or the token exceeds\n * the size limit.\n */\n getToken(): string | undefined {\n const journey = this.journey;\n if (journey === null) {\n return undefined;\n }\n const token = encodeToken(journey);\n if (token.length > JOURNEY_TOKEN_MAX_CHARS) {\n this.diagnostics.report(\n \"journey.token_too_large\",\n \"The journey token is larger than the size limit. The library does not issue it.\",\n { length: token.length },\n );\n return undefined;\n }\n return token;\n }\n\n /**\n * Validates and adopts a serialized journey token.\n * @param token Base64url journey token.\n * @param source Originating source description for diagnostics.\n * @param broadcast True to send the adoption to the connected bus peers.\n * @returns True if the token was valid, unexpired, and adopted.\n */\n adopt(token: string, source: string, broadcast = false): boolean {\n const decoded = this.decodeToken(token);\n if (decoded === null) {\n return false;\n }\n if (Date.now() - decoded.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a seeded journey older than maxAgeMs.\",\n {\n source,\n name: decoded.name,\n },\n );\n return false;\n }\n\n this.setJourney(decoded);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library adopted the journey \"${decoded.name}\".`,\n {\n source,\n journeyId: decoded.id,\n },\n );\n if (broadcast) {\n this.onLocalChange(decoded);\n }\n return true;\n }\n\n /**\n * Ends the journey when endOnOwnerClose is on and the closed context owns the journey.\n * @param ownerContextId Context identifier of the closed window.\n */\n ownerClosed(ownerContextId: string): void {\n if (!this.options.endOnOwnerClose) {\n return;\n }\n if (this.journey?.ownerContextId === ownerContextId) {\n this.end();\n }\n }\n\n /** Clears pending expiration timers and releases resources on shutdown. */\n destroy(): void {\n this.clearTimer();\n }\n\n /**\n * Resumes a persisted journey from raw sessionStorage data.\n * @param raw Serialized JSON string from storage.\n * @returns True if the engine restored the journey.\n */\n private restore(raw: string): boolean {\n const parsed = this.diagnostics.guard(\n \"storage.degraded\",\n \"The library could not parse the persisted journey.\",\n () => JSON.parse(raw) as unknown,\n );\n const journey = parseJourney(parsed);\n if (journey === null) {\n return false;\n }\n\n if (Date.now() - journey.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a persisted journey older than maxAgeMs.\",\n { name: journey.name },\n );\n this.clearStored();\n return false;\n }\n\n this.setJourney(journey);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library resumed the journey \"${journey.name}\".`,\n {\n source: \"sessionStorage\",\n journeyId: journey.id,\n },\n );\n return true;\n }\n\n /**\n * Decodes a base64url token into a validated Journey object. Anyone can edit the URL\n * that holds a token. Each step throws on bad input. The guard reports the failure\n * and does not throw it.\n * @param token Encoded token string.\n * @returns Decoded Journey instance or null on decode error.\n */\n private decodeToken(token: string): Journey | null {\n const decoded = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not decode a seeded journey token.\",\n () => {\n const standard = token\n .replace(BASE64URL_DASH_PATTERN, \"+\")\n .replace(BASE64URL_UNDERSCORE_PATTERN, \"/\");\n const missing =\n (BASE64_GROUP_CHARS - (standard.length % BASE64_GROUP_CHARS)) % BASE64_GROUP_CHARS;\n const padding = \"=\".repeat(missing);\n const bytes = Uint8Array.from(atob(standard + padding), (c) => c.charCodeAt(0));\n return journeyFromTokenPayload(JSON.parse(new TextDecoder().decode(bytes)) as unknown);\n },\n );\n return decoded ?? null;\n }\n\n /**\n * Sets the active journey, updates sessionStorage, and schedules expiration.\n * @param journey Target Journey instance or null.\n */\n private setJourney(journey: Journey | null): void {\n this.journey = journey;\n this.clearTimer();\n\n this.diagnostics.guard(\"storage.unavailable\", \"The library could not save the journey.\", () => {\n if (journey !== null) {\n this.stores.session().setItem(JOURNEY_STORAGE_KEY, JSON.stringify(journey));\n } else {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n }\n });\n\n if (journey === null) {\n return;\n }\n\n const remaining = Math.max(this.options.maxAgeMs - (Date.now() - journey.startedAt), 0);\n const timer = setTimeout(() => {\n this.diagnostics.report(\n \"journey.expired\",\n `The journey \"${journey.name}\" reached maxAgeMs. The library ended it.`,\n { journeyId: journey.id },\n );\n this.journey = null;\n this.expiryTimer = null;\n this.clearStored();\n }, remaining);\n this.expiryTimer = timer;\n unrefTimer(timer);\n }\n\n /** Removes journey data from the session store. */\n private clearStored(): void {\n this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not clear the persisted journey.\",\n () => {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n },\n );\n }\n\n /** Cancels any active expiration timer. */\n private clearTimer(): void {\n if (this.expiryTimer !== null) {\n clearTimeout(this.expiryTimer);\n this.expiryTimer = null;\n }\n }\n\n /**\n * Extracts the journey token from the current window location search parameters.\n * @returns Token string or null.\n */\n private readUrlToken(): string | null {\n const token = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not read the journey token from the URL.\",\n () => {\n if (typeof location === \"undefined\") {\n return null;\n }\n return new URL(location.href).searchParams.get(this.options.urlParam);\n },\n );\n return token ?? null;\n }\n\n /**\n * Removes the journey token from the address bar after the engine adopts it.\n * If not, a copy or a bookmark of the link starts the same journey in another session.\n */\n private removeUrlToken(): void {\n this.diagnostics.guard(\n \"platform.api_blocked\",\n \"The library could not remove the journey token from the URL.\",\n () => {\n const url = new URL(location.href);\n url.searchParams.delete(this.options.urlParam);\n // Keep history.state. A router stores its own state there.\n history.replaceState(history.state, \"\", url.href);\n },\n );\n }\n\n /**\n * Reads the journey token from the customData of the OpenFin window options.\n * OPENFIN_OPTIONS_TIMEOUT_MS limits the wait. At the deadline, it reports\n * openfin.unavailable and returns no token. A window without a token gives the same result.\n * @returns Promise that resolves to token string or null.\n */\n private async readOpenFinToken(): Promise<string | null> {\n const me = getFin()?.me;\n const getOptions = me?.getOptions;\n if (getOptions === undefined) {\n return null;\n }\n\n // Use call to keep the receiver of the native OpenFin method. A detached copy\n // throws when called.\n const options = await this.diagnostics.guardAsync(\n \"openfin.unavailable\",\n \"The library could not read fin.me.getOptions().\",\n () => withDeadline(getOptions.call(me), OPENFIN_OPTIONS_TIMEOUT_MS),\n );\n const token = options?.customData?.[OPENFIN_JOURNEY_CUSTOM_DATA_KEY];\n return typeof token === \"string\" ? token : null;\n }\n}\n"],"mappings":";;;;;AA0CA,IAAagB,IAAkC;CAC7C,UAAUX;CACV,iBAAA;CACA,UAAUF;AACZ;AAsBA,SAASc,EAAW,GAAgB,GAAiC;CACnE,IAAMC,IAAiB,QAAQ,IAAIC,GAAQC,CAAG;CAC9C,OAAO,OAAOF,KAAU,YAAYA,MAAU,KAAKA,IAAQ,KAAA;AAC7D;AAQA,SAASG,EAAW,GAAgB,GAAiC;CACnE,IAAMH,IAAiB,QAAQ,IAAIC,GAAQC,CAAG;CAC9C,OAAO,OAAOF,KAAU,YAAY,OAAO,SAASA,CAAK,IAAIA,IAAQ,KAAA;AACvE;AAQA,SAAgBI,EAAa,GAAgC;CAC3D,IAAI,OAAOJ,KAAU,aAAYA,GAC/B,OAAO;CAET,IAAMK,IAAKN,EAAWC,GAAO,IAAI,GAC3BM,IAAOP,EAAWC,GAAO,MAAM,GAC/BO,IAAYJ,EAAWH,GAAO,WAAW;CAI/C,OAHIK,MAAO,KAAA,KAAaC,MAAS,KAAA,KAAaC,MAAc,KAAA,IACnD,OAEF;EACL;EACA;EACA;EACA,UAAUR,EAAWC,GAAO,UAAU;EACtC,gBAAgBD,EAAWC,GAAO,gBAAgB,KAAK;CACzD;AACF;AAOA,SAASQ,EAAwB,GAAgC;CAC/D,IAAI,OAAOR,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,EAAO,CAAC,EAAE,IACf4C,IAAaD,GAAI;EACvB,IAAIC,MAAe,KAAA,GACjB,OAAO;EAUT,IAAMb,KAAQ,MALQ,KAAK,YAAY,WACrC,uBACA,yDACMnC,EAAagD,EAAW,KAAKD,CAAE,GAAG1D,CAA0B,CACpE,EAAA,EACuB,aAAaU;EACpC,OAAO,OAAOoC,KAAU,WAAWA,IAAQ;CAC7C;AACF"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants-CL0ZdI2f.cjs"),t=require("./deadline-XSnm95pg.cjs"),n=require("./openfin-DtH2f7zX.cjs"),r=require("./identity-BMlKGHUM.cjs");var i={maxAgeMs:e.bt,endOnOwnerClose:!1,urlParam:e.St};function a(e,t){let n=Reflect.get(e,t);return typeof n==`string`&&n!==``?n:void 0}function o(e,t){let n=Reflect.get(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function s(e){if(typeof e!=`object`||!e)return null;let t=a(e,`id`),n=a(e,`name`),r=o(e,`startedAt`);return t===void 0||n===void 0||r===void 0?null:{id:t,name:n,startedAt:r,parentId:a(e,`parentId`),ownerContextId:a(e,`ownerContextId`)??``}}function c(e){if(typeof e!=`object`||!e)return null;let t=a(e,`i`),n=a(e,`n`),r=o(e,`s`),i=r!==void 0&&r>Date.now()+3e5;return t===void 0||n===void 0||r===void 0||i?null:{id:t,name:n,startedAt:r,parentId:void 0,ownerContextId:``}}function l(t){let n=JSON.stringify({i:t.id,n:t.name.slice(0,64),s:t.startedAt}),r=new TextEncoder().encode(n),i=``;for(let e of r)i+=String.fromCharCode(e);return btoa(i).replace(e.w,`-`).replace(e.T,`_`).replace(e.C,``)}var u=class{options;diagnostics;contextId;onLocalChange;stores;journey=null;expiryTimer=null;constructor(e,t,n,i,a=r.t){this.options=e,this.diagnostics=t,this.contextId=n,this.onLocalChange=i,this.stores=a}current(){return this.journey}async bootstrap(){let t=this.readUrlToken();if(t&&this.adopt(t,`url`)){this.removeUrlToken();return}let n=this.diagnostics.guard(`storage.unavailable`,`The library could not read the persisted journey.`,()=>this.stores.session().getItem(e.xt));if(n&&this.restore(n))return;let r=await this.readOpenFinToken();r!==null&&this.adopt(r,`openfin.customData`)}start(e,t={}){let n={id:this.journeyId(t.id),name:e,startedAt:Date.now(),parentId:t.parent?this.journey?.id:void 0,ownerContextId:this.contextId};return this.setJourney(n),this.onLocalChange(n),n}journeyId(t){return t===void 0?r.i(this.diagnostics):typeof t==`string`&&e.yt.test(t)?t:(this.diagnostics.report(`config.invalid`,`startJourney() needs an id of 1 to 64 letters, digits, "_", ".", ":" or "-". The library uses a new id.`),r.i(this.diagnostics))}end(){this.journey!==null&&(this.setJourney(null),this.onLocalChange(null))}applyRemote(e){let t=this.journey;(e===null||t===null||e.id!==t.id)&&this.setJourney(e)}getToken(){let e=this.journey;if(e===null)return;let t=l(e);if(t.length>256)this.diagnostics.report(`journey.token_too_large`,`The journey token is larger than the size limit. The library does not issue it.`,{length:t.length});else return t}adopt(e,t,n=!1){let r=this.decodeToken(e);return r===null?!1:Date.now()-r.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`The library discarded a seeded journey older than maxAgeMs.`,{source:t,name:r.name}),!1):(this.setJourney(r),this.diagnostics.report(`journey.adopted`,`The library adopted the journey "${r.name}".`,{source:t,journeyId:r.id}),n&&this.onLocalChange(r),!0)}ownerClosed(e){this.options.endOnOwnerClose&&this.journey?.ownerContextId===e&&this.end()}destroy(){this.clearTimer()}restore(e){let t=s(this.diagnostics.guard(`storage.degraded`,`The library could not parse the persisted journey.`,()=>JSON.parse(e)));return t===null?!1:Date.now()-t.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`The library discarded a persisted journey older than maxAgeMs.`,{name:t.name}),this.clearStored(),!1):(this.setJourney(t),this.diagnostics.report(`journey.adopted`,`The library resumed the journey "${t.name}".`,{source:`sessionStorage`,journeyId:t.id}),!0)}decodeToken(t){return this.diagnostics.guard(`config.invalid`,`The library could not decode a seeded journey token.`,()=>{let n=t.replace(e.x,`+`).replace(e.S,`/`),r=(4-n.length%4)%4,i=`=`.repeat(r),a=Uint8Array.from(atob(n+i),e=>e.charCodeAt(0));return c(JSON.parse(new TextDecoder().decode(a)))})??null}setJourney(n){if(this.journey=n,this.clearTimer(),this.diagnostics.guard(`storage.unavailable`,`The library could not save the journey.`,()=>{n===null?this.stores.session().removeItem(e.xt):this.stores.session().setItem(e.xt,JSON.stringify(n))}),n===null)return;let r=Math.max(this.options.maxAgeMs-(Date.now()-n.startedAt),0),i=setTimeout(()=>{this.diagnostics.report(`journey.expired`,`The journey "${n.name}" reached maxAgeMs. The library ended it.`,{journeyId:n.id}),this.journey=null,this.expiryTimer=null,this.clearStored()},r);this.expiryTimer=i,t.r(i)}clearStored(){this.diagnostics.guard(`storage.unavailable`,`The library could not clear the persisted journey.`,()=>{this.stores.session().removeItem(e.xt)})}clearTimer(){this.expiryTimer!==null&&(clearTimeout(this.expiryTimer),this.expiryTimer=null)}readUrlToken(){return this.diagnostics.guard(`config.invalid`,`The library could not read the journey token from the URL.`,()=>typeof location>`u`?null:new URL(location.href).searchParams.get(this.options.urlParam))??null}removeUrlToken(){this.diagnostics.guard(`platform.api_blocked`,`The library could not remove the journey token from the URL.`,()=>{let e=new URL(location.href);e.searchParams.delete(this.options.urlParam),history.replaceState(history.state,``,e.href)})}async readOpenFinToken(){let r=n.t()?.me,i=r?.getOptions;if(i===void 0)return null;let a=(await this.diagnostics.guardAsync(`openfin.unavailable`,`The library could not read fin.me.getOptions().`,()=>t.n(i.call(r),e.Bt)))?.customData?.[e.zt];return typeof a==`string`?a:null}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
2
- //# sourceMappingURL=journey-5tcxEbnG.cjs.map
1
+ const e=require("./constants-DqKJH_MP.cjs"),t=require("./deadline-XSnm95pg.cjs"),n=require("./identity-Cxgj6pZX.cjs"),r=require("./openfin-DtH2f7zX.cjs");var i={maxAgeMs:e.bt,endOnOwnerClose:!1,urlParam:e.St};function a(e,t){let n=Reflect.get(e,t);return typeof n==`string`&&n!==``?n:void 0}function o(e,t){let n=Reflect.get(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function s(e){if(typeof e!=`object`||!e)return null;let t=a(e,`id`),n=a(e,`name`),r=o(e,`startedAt`);return t===void 0||n===void 0||r===void 0?null:{id:t,name:n,startedAt:r,parentId:a(e,`parentId`),ownerContextId:a(e,`ownerContextId`)??``}}function c(e){if(typeof e!=`object`||!e)return null;let t=a(e,`i`),n=a(e,`n`),r=o(e,`s`),i=r!==void 0&&r>Date.now()+3e5;return t===void 0||n===void 0||r===void 0||i?null:{id:t,name:n,startedAt:r,parentId:void 0,ownerContextId:``}}function l(t){let n=JSON.stringify({i:t.id,n:t.name.slice(0,64),s:t.startedAt}),r=new TextEncoder().encode(n),i=``;for(let e of r)i+=String.fromCharCode(e);return btoa(i).replace(e.w,`-`).replace(e.T,`_`).replace(e.C,``)}var u=class{options;diagnostics;contextId;onLocalChange;stores;journey=null;expiryTimer=null;constructor(e,t,r,i,a=n.t){this.options=e,this.diagnostics=t,this.contextId=r,this.onLocalChange=i,this.stores=a}current(){return this.journey}async bootstrap(){let t=this.readUrlToken();if(t&&this.adopt(t,`url`)){this.removeUrlToken();return}let n=this.diagnostics.guard(`storage.unavailable`,`The library could not read the persisted journey.`,()=>this.stores.session().getItem(e.xt));if(n&&this.restore(n))return;let r=await this.readOpenFinToken();r!==null&&this.adopt(r,`openfin.customData`)}start(e,t={}){let n={id:this.journeyId(t.id),name:e,startedAt:Date.now(),parentId:t.parent?this.journey?.id:void 0,ownerContextId:this.contextId};return this.setJourney(n),this.onLocalChange(n),n}journeyId(t){return t===void 0?n.i(this.diagnostics):typeof t==`string`&&e.yt.test(t)?t:(this.diagnostics.report(`config.invalid`,`startJourney() needs an id of 1 to 64 letters, digits, "_", ".", ":" or "-". The library uses a new id.`),n.i(this.diagnostics))}end(){this.journey!==null&&(this.setJourney(null),this.onLocalChange(null))}applyRemote(e){let t=this.journey;(e===null||t===null||e.id!==t.id)&&this.setJourney(e)}getToken(){let e=this.journey;if(e===null)return;let t=l(e);if(t.length>256)this.diagnostics.report(`journey.token_too_large`,`The journey token is larger than the size limit. The library does not issue it.`,{length:t.length});else return t}adopt(e,t,n=!1){let r=this.decodeToken(e);return r===null?!1:Date.now()-r.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`The library discarded a seeded journey older than maxAgeMs.`,{source:t,name:r.name}),!1):(this.setJourney(r),this.diagnostics.report(`journey.adopted`,`The library adopted the journey "${r.name}".`,{source:t,journeyId:r.id}),n&&this.onLocalChange(r),!0)}ownerClosed(e){this.options.endOnOwnerClose&&this.journey?.ownerContextId===e&&this.end()}destroy(){this.clearTimer()}restore(e){let t=s(this.diagnostics.guard(`storage.degraded`,`The library could not parse the persisted journey.`,()=>JSON.parse(e)));return t===null?!1:Date.now()-t.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`The library discarded a persisted journey older than maxAgeMs.`,{name:t.name}),this.clearStored(),!1):(this.setJourney(t),this.diagnostics.report(`journey.adopted`,`The library resumed the journey "${t.name}".`,{source:`sessionStorage`,journeyId:t.id}),!0)}decodeToken(t){return this.diagnostics.guard(`config.invalid`,`The library could not decode a seeded journey token.`,()=>{let n=t.replace(e.x,`+`).replace(e.S,`/`),r=(4-n.length%4)%4,i=`=`.repeat(r),a=Uint8Array.from(atob(n+i),e=>e.charCodeAt(0));return c(JSON.parse(new TextDecoder().decode(a)))})??null}setJourney(n){if(this.journey=n,this.clearTimer(),this.diagnostics.guard(`storage.unavailable`,`The library could not save the journey.`,()=>{n===null?this.stores.session().removeItem(e.xt):this.stores.session().setItem(e.xt,JSON.stringify(n))}),n===null)return;let r=Math.max(this.options.maxAgeMs-(Date.now()-n.startedAt),0),i=setTimeout(()=>{this.diagnostics.report(`journey.expired`,`The journey "${n.name}" reached maxAgeMs. The library ended it.`,{journeyId:n.id}),this.journey=null,this.expiryTimer=null,this.clearStored()},r);this.expiryTimer=i,t.r(i)}clearStored(){this.diagnostics.guard(`storage.unavailable`,`The library could not clear the persisted journey.`,()=>{this.stores.session().removeItem(e.xt)})}clearTimer(){this.expiryTimer!==null&&(clearTimeout(this.expiryTimer),this.expiryTimer=null)}readUrlToken(){return this.diagnostics.guard(`config.invalid`,`The library could not read the journey token from the URL.`,()=>typeof location>`u`?null:new URL(location.href).searchParams.get(this.options.urlParam))??null}removeUrlToken(){this.diagnostics.guard(`platform.api_blocked`,`The library could not remove the journey token from the URL.`,()=>{let e=new URL(location.href);e.searchParams.delete(this.options.urlParam),history.replaceState(history.state,``,e.href)})}async readOpenFinToken(){let n=r.t()?.me,i=n?.getOptions;if(i===void 0)return null;let a=(await this.diagnostics.guardAsync(`openfin.unavailable`,`The library could not read fin.me.getOptions().`,()=>t.n(i.call(n),e.Bt)))?.customData?.[e.zt];return typeof a==`string`?a:null}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
2
+ //# sourceMappingURL=journey-pffMVMfa.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"journey-5tcxEbnG.cjs","names":["JOURNEY_MAX_AGE_MS","JOURNEY_URL_PARAM","BASE64_PLUS_PATTERN","BASE64_SLASH_PATTERN","BASE64_PADDING_PATTERN","BROWSER_STORES","JOURNEY_STORAGE_KEY","newId","JOURNEY_ID_PATTERN","BASE64URL_DASH_PATTERN","BASE64URL_UNDERSCORE_PATTERN","getFin","withDeadline","OPENFIN_OPTIONS_TIMEOUT_MS","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","require_constants","require_deadline","require_openfin","require_identity","JOURNEY_OPTIONS","readString","value","source","key","readNumber","parseJourney","id","name","startedAt","journeyFromTokenPayload","future","encodeToken","json","journey","bytes","binary","byte","JourneyEngine","options","diagnostics","contextId","onLocalChange","stores","fromUrl","fromStorage","fromOpenFin","opts","requested","current","token","decoded","broadcast","ownerContextId","raw","standard","missing","padding","c","remaining","timer","url","me","getOptions"],"sources":["../src/core/journey.ts"],"sourcesContent":["// src/core/journey.ts\n//\n// This module manages the lifecycle of a user journey across windows. It encodes tokens,\n// stores the journey and ends it at expiry. Do not trust a value from storage or a token.\n// Any code on the origin can write to both.\n\nimport {\n BASE64_GROUP_CHARS,\n BASE64_PADDING_PATTERN,\n BASE64_PLUS_PATTERN,\n BASE64_SLASH_PATTERN,\n BASE64URL_DASH_PATTERN,\n BASE64URL_UNDERSCORE_PATTERN,\n JOURNEY_END_ON_OWNER_CLOSE,\n JOURNEY_CLOCK_SKEW_MS,\n JOURNEY_ID_MAX_CHARS,\n JOURNEY_ID_PATTERN,\n JOURNEY_MAX_AGE_MS,\n JOURNEY_STORAGE_KEY,\n JOURNEY_TOKEN_MAX_CHARS,\n JOURNEY_TOKEN_NAME_MAX_CHARS,\n OPENFIN_JOURNEY_CUSTOM_DATA_KEY,\n JOURNEY_URL_PARAM,\n OPENFIN_OPTIONS_TIMEOUT_MS,\n} from \"../constants\";\nimport { withDeadline } from \"../utils/deadline\";\nimport { BROWSER_STORES, type IdentityStores, newId } from \"../utils/identity\";\nimport { getFin } from \"../utils/openfin\";\nimport { unrefTimer } from \"../utils/unref\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/** Lifetime rules for a journey. A journey is one user task across several contexts. */\nexport interface JourneyOptions {\n /** Maximum open time of a journey, in milliseconds. After this time, the engine ends it. */\n maxAgeMs: number;\n /** True if the journey ends for all contexts when the owning context closes. */\n endOnOwnerClose: boolean;\n /** Query parameter checked at boot for a seeded journey token. */\n urlParam: string;\n}\n\n/** Journey lifetime policy in force. Tests build an engine with shorter values. */\nexport const JOURNEY_OPTIONS: JourneyOptions = {\n maxAgeMs: JOURNEY_MAX_AGE_MS,\n endOnOwnerClose: JOURNEY_END_ON_OWNER_CLOSE,\n urlParam: JOURNEY_URL_PARAM,\n};\n\n/** User journey workflow context shared across windows and applications. */\nexport interface Journey {\n /** Unique journey correlation identifier. */\n id: string;\n /** Journey workflow name for a person to read. */\n name: string;\n /** Journey start timestamp in epoch milliseconds. */\n startedAt: number;\n /** Optional parent journey ID when the journey branches from an earlier journey. */\n parentId?: string;\n /** Context identifier of the document that started the journey. */\n ownerContextId: string;\n}\n\n/**\n * Reads a non-empty string property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Non-empty string value or undefined.\n */\nfunction readString(source: object, key: string): string | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\n/**\n * Reads a finite number property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Finite number value or undefined.\n */\nfunction readNumber(source: object, key: string): number | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n}\n\n/**\n * Parses and validates an unknown value into a Journey object. The value comes from\n * sessionStorage or from a bus message of another realm.\n * @param value Unverified parsed JSON value.\n * @returns Validated Journey instance or null.\n */\nexport function parseJourney(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"id\");\n const name = readString(value, \"name\");\n const startedAt = readNumber(value, \"startedAt\");\n if (id === undefined || name === undefined || startedAt === undefined) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: readString(value, \"parentId\"),\n ownerContextId: readString(value, \"ownerContextId\") ?? \"\",\n };\n}\n\n/**\n * Parses and validates decoded token payload into a Journey object.\n * @param value Unverified parsed token payload.\n * @returns Validated Journey instance or null.\n */\nfunction journeyFromTokenPayload(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"i\");\n const name = readString(value, \"n\");\n const startedAt = readNumber(value, \"s\");\n // The library always writes a start time. A token without one, or from the future, never expires.\n const future = startedAt !== undefined && startedAt > Date.now() + JOURNEY_CLOCK_SKEW_MS;\n if (id === undefined || name === undefined || startedAt === undefined || future) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: undefined,\n ownerContextId: \"\",\n };\n}\n\n/**\n * Encodes journey metadata into a compact, URL-safe base64 string.\n * @param journey Journey instance to serialize.\n * @returns Unpadded base64url encoded token string.\n */\nfunction encodeToken(journey: Journey): string {\n const json = JSON.stringify({\n i: journey.id,\n n: journey.name.slice(0, JOURNEY_TOKEN_NAME_MAX_CHARS),\n s: journey.startedAt,\n });\n // Convert the UTF-8 bytes to a binary string before btoa. btoa throws above U+00FF.\n // Without this step, a name in a non-Latin script fails.\n const bytes = new TextEncoder().encode(json);\n let binary = \"\";\n for (const byte of bytes) {\n binary += String.fromCharCode(byte);\n }\n return btoa(binary)\n .replace(BASE64_PLUS_PATTERN, \"-\")\n .replace(BASE64_SLASH_PATTERN, \"_\")\n .replace(BASE64_PADDING_PATTERN, \"\");\n}\n\n/** Manages journey lifecycle, cross-window adoption, storage synchronization, and expiration. */\nexport class JourneyEngine {\n /** Active journey context, or null if none is in progress. */\n private journey: Journey | null = null;\n\n /** Active expiration timer handle. */\n private expiryTimer: ReturnType<typeof setTimeout> | null = null;\n\n /**\n * @param options Journey configuration thresholds.\n * @param diagnostics Diagnostics reporter.\n * @param contextId Unique context identifier for this document.\n * @param onLocalChange Callback invoked when journey state changes locally.\n * @param stores Identity stores that hold the journey.\n */\n constructor(\n private readonly options: JourneyOptions,\n private readonly diagnostics: Diagnostics,\n private readonly contextId: string,\n private readonly onLocalChange: (journey: Journey | null) => void,\n private readonly stores: IdentityStores = BROWSER_STORES,\n ) {}\n\n /** Returns the active journey instance or null. */\n current(): Journey | null {\n return this.journey;\n }\n\n /**\n * Finds and adopts the initial journey. It checks the URL query, then sessionStorage,\n * then OpenFin customData.\n * @returns Promise that resolves when journey initialization completes.\n */\n async bootstrap(): Promise<void> {\n const fromUrl = this.readUrlToken();\n if (fromUrl && this.adopt(fromUrl, \"url\")) {\n this.removeUrlToken();\n return;\n }\n\n const fromStorage = this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the persisted journey.\",\n () => this.stores.session().getItem(JOURNEY_STORAGE_KEY),\n );\n if (fromStorage && this.restore(fromStorage)) {\n return;\n }\n\n const fromOpenFin = await this.readOpenFinToken();\n if (fromOpenFin !== null) {\n this.adopt(fromOpenFin, \"openfin.customData\");\n }\n }\n\n /**\n * Starts a new journey. It replaces the active journey and tells connected peers.\n * @param name Human-readable workflow name.\n * @param opts Optional parent linkage and pre-assigned identifier.\n * @returns Started Journey instance.\n */\n start(name: string, opts: { parent?: boolean; id?: string } = {}): Journey {\n const journey: Journey = {\n id: this.journeyId(opts.id),\n name,\n startedAt: Date.now(),\n parentId: opts.parent ? this.journey?.id : undefined,\n ownerContextId: this.contextId,\n };\n this.setJourney(journey);\n this.onLocalChange(journey);\n return journey;\n }\n\n /**\n * Gives the id of a new journey. A longer id, or an id with multibyte characters, makes the\n * journey token too long for adoptJourney().\n * @param requested Id from the app, or undefined.\n * @returns The requested id when it matches JOURNEY_ID_PATTERN, else a new id.\n */\n private journeyId(requested: unknown): string {\n if (requested === undefined) {\n return newId(this.diagnostics);\n }\n\n if (typeof requested === \"string\" && JOURNEY_ID_PATTERN.test(requested)) {\n return requested;\n }\n\n this.diagnostics.report(\n \"config.invalid\",\n `startJourney() needs an id of 1 to ${String(JOURNEY_ID_MAX_CHARS)} letters, digits, \"_\", \".\", \":\" or \"-\". The library uses a new id.`,\n );\n return newId(this.diagnostics);\n }\n\n /** Ends the active journey and broadcasts the change. */\n end(): void {\n if (this.journey === null) {\n return;\n }\n this.setJourney(null);\n this.onLocalChange(null);\n }\n\n /**\n * Applies a journey update from a bus peer. It does not broadcast the update again.\n * An echo makes two windows send the change back and forth without end.\n * It ignores a journey with the same ID as the active journey. Thus an echo cannot\n * restart the timer.\n * @param journey Updated Journey instance or null.\n */\n applyRemote(journey: Journey | null): void {\n const current = this.journey;\n if (journey !== null && current !== null && journey.id === current.id) {\n return;\n }\n this.setJourney(journey);\n }\n\n /**\n * Serializes the active journey into a compact token for URL or intent transfer.\n * @returns Base64url token, or undefined when no journey is active or the token exceeds\n * the size limit.\n */\n getToken(): string | undefined {\n const journey = this.journey;\n if (journey === null) {\n return undefined;\n }\n const token = encodeToken(journey);\n if (token.length > JOURNEY_TOKEN_MAX_CHARS) {\n this.diagnostics.report(\n \"journey.token_too_large\",\n \"The journey token is larger than the size limit. The library does not issue it.\",\n { length: token.length },\n );\n return undefined;\n }\n return token;\n }\n\n /**\n * Validates and adopts a serialized journey token.\n * @param token Base64url journey token.\n * @param source Originating source description for diagnostics.\n * @param broadcast True to send the adoption to the connected bus peers.\n * @returns True if the token was valid, unexpired, and adopted.\n */\n adopt(token: string, source: string, broadcast = false): boolean {\n const decoded = this.decodeToken(token);\n if (decoded === null) {\n return false;\n }\n if (Date.now() - decoded.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a seeded journey older than maxAgeMs.\",\n {\n source,\n name: decoded.name,\n },\n );\n return false;\n }\n\n this.setJourney(decoded);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library adopted the journey \"${decoded.name}\".`,\n {\n source,\n journeyId: decoded.id,\n },\n );\n if (broadcast) {\n this.onLocalChange(decoded);\n }\n return true;\n }\n\n /**\n * Ends the journey when endOnOwnerClose is on and the closed context owns the journey.\n * @param ownerContextId Context identifier of the closed window.\n */\n ownerClosed(ownerContextId: string): void {\n if (!this.options.endOnOwnerClose) {\n return;\n }\n if (this.journey?.ownerContextId === ownerContextId) {\n this.end();\n }\n }\n\n /** Clears pending expiration timers and releases resources on shutdown. */\n destroy(): void {\n this.clearTimer();\n }\n\n /**\n * Resumes a persisted journey from raw sessionStorage data.\n * @param raw Serialized JSON string from storage.\n * @returns True if the engine restored the journey.\n */\n private restore(raw: string): boolean {\n const parsed = this.diagnostics.guard(\n \"storage.degraded\",\n \"The library could not parse the persisted journey.\",\n () => JSON.parse(raw) as unknown,\n );\n const journey = parseJourney(parsed);\n if (journey === null) {\n return false;\n }\n\n if (Date.now() - journey.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a persisted journey older than maxAgeMs.\",\n { name: journey.name },\n );\n this.clearStored();\n return false;\n }\n\n this.setJourney(journey);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library resumed the journey \"${journey.name}\".`,\n {\n source: \"sessionStorage\",\n journeyId: journey.id,\n },\n );\n return true;\n }\n\n /**\n * Decodes a base64url token into a validated Journey object. Anyone can edit the URL\n * that holds a token. Each step throws on bad input. The guard reports the failure\n * and does not throw it.\n * @param token Encoded token string.\n * @returns Decoded Journey instance or null on decode error.\n */\n private decodeToken(token: string): Journey | null {\n const decoded = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not decode a seeded journey token.\",\n () => {\n const standard = token\n .replace(BASE64URL_DASH_PATTERN, \"+\")\n .replace(BASE64URL_UNDERSCORE_PATTERN, \"/\");\n const missing =\n (BASE64_GROUP_CHARS - (standard.length % BASE64_GROUP_CHARS)) % BASE64_GROUP_CHARS;\n const padding = \"=\".repeat(missing);\n const bytes = Uint8Array.from(atob(standard + padding), (c) => c.charCodeAt(0));\n return journeyFromTokenPayload(JSON.parse(new TextDecoder().decode(bytes)) as unknown);\n },\n );\n return decoded ?? null;\n }\n\n /**\n * Sets the active journey, updates sessionStorage, and schedules expiration.\n * @param journey Target Journey instance or null.\n */\n private setJourney(journey: Journey | null): void {\n this.journey = journey;\n this.clearTimer();\n\n this.diagnostics.guard(\"storage.unavailable\", \"The library could not save the journey.\", () => {\n if (journey !== null) {\n this.stores.session().setItem(JOURNEY_STORAGE_KEY, JSON.stringify(journey));\n } else {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n }\n });\n\n if (journey === null) {\n return;\n }\n\n const remaining = Math.max(this.options.maxAgeMs - (Date.now() - journey.startedAt), 0);\n const timer = setTimeout(() => {\n this.diagnostics.report(\n \"journey.expired\",\n `The journey \"${journey.name}\" reached maxAgeMs. The library ended it.`,\n { journeyId: journey.id },\n );\n this.journey = null;\n this.expiryTimer = null;\n this.clearStored();\n }, remaining);\n this.expiryTimer = timer;\n unrefTimer(timer);\n }\n\n /** Removes journey data from the session store. */\n private clearStored(): void {\n this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not clear the persisted journey.\",\n () => {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n },\n );\n }\n\n /** Cancels any active expiration timer. */\n private clearTimer(): void {\n if (this.expiryTimer !== null) {\n clearTimeout(this.expiryTimer);\n this.expiryTimer = null;\n }\n }\n\n /**\n * Extracts the journey token from the current window location search parameters.\n * @returns Token string or null.\n */\n private readUrlToken(): string | null {\n const token = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not read the journey token from the URL.\",\n () => {\n if (typeof location === \"undefined\") {\n return null;\n }\n return new URL(location.href).searchParams.get(this.options.urlParam);\n },\n );\n return token ?? null;\n }\n\n /**\n * Removes the journey token from the address bar after the engine adopts it.\n * If not, a copy or a bookmark of the link starts the same journey in another session.\n */\n private removeUrlToken(): void {\n this.diagnostics.guard(\n \"platform.api_blocked\",\n \"The library could not remove the journey token from the URL.\",\n () => {\n const url = new URL(location.href);\n url.searchParams.delete(this.options.urlParam);\n // Keep history.state. A router stores its own state there.\n history.replaceState(history.state, \"\", url.href);\n },\n );\n }\n\n /**\n * Reads the journey token from the customData of the OpenFin window options.\n * OPENFIN_OPTIONS_TIMEOUT_MS limits the wait. At the deadline, it reports\n * openfin.unavailable and returns no token. A window without a token gives the same result.\n * @returns Promise that resolves to token string or null.\n */\n private async readOpenFinToken(): Promise<string | null> {\n const me = getFin()?.me;\n const getOptions = me?.getOptions;\n if (getOptions === undefined) {\n return null;\n }\n\n // Use call to keep the receiver of the native OpenFin method. A detached copy\n // throws when called.\n const options = await this.diagnostics.guardAsync(\n \"openfin.unavailable\",\n \"The library could not read fin.me.getOptions().\",\n () => withDeadline(getOptions.call(me), OPENFIN_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F"}
1
+ {"version":3,"file":"journey-pffMVMfa.cjs","names":["JOURNEY_MAX_AGE_MS","JOURNEY_URL_PARAM","BASE64_PLUS_PATTERN","BASE64_SLASH_PATTERN","BASE64_PADDING_PATTERN","BROWSER_STORES","JOURNEY_STORAGE_KEY","newId","JOURNEY_ID_PATTERN","BASE64URL_DASH_PATTERN","BASE64URL_UNDERSCORE_PATTERN","getFin","withDeadline","OPENFIN_OPTIONS_TIMEOUT_MS","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","require_constants","require_deadline","require_identity","require_openfin","JOURNEY_OPTIONS","readString","value","source","key","readNumber","parseJourney","id","name","startedAt","journeyFromTokenPayload","future","encodeToken","json","journey","bytes","binary","byte","JourneyEngine","options","diagnostics","contextId","onLocalChange","stores","fromUrl","fromStorage","fromOpenFin","opts","requested","current","token","decoded","broadcast","ownerContextId","raw","standard","missing","padding","c","remaining","timer","url","me","getOptions"],"sources":["../src/core/journey.ts"],"sourcesContent":["// src/core/journey.ts\n//\n// This module manages the lifecycle of a user journey across windows. It encodes tokens,\n// stores the journey and ends it at expiry. Do not trust a value from storage or a token.\n// Any code on the origin can write to both.\n\nimport {\n BASE64_GROUP_CHARS,\n BASE64_PADDING_PATTERN,\n BASE64_PLUS_PATTERN,\n BASE64_SLASH_PATTERN,\n BASE64URL_DASH_PATTERN,\n BASE64URL_UNDERSCORE_PATTERN,\n JOURNEY_END_ON_OWNER_CLOSE,\n JOURNEY_CLOCK_SKEW_MS,\n JOURNEY_ID_MAX_CHARS,\n JOURNEY_ID_PATTERN,\n JOURNEY_MAX_AGE_MS,\n JOURNEY_STORAGE_KEY,\n JOURNEY_TOKEN_MAX_CHARS,\n JOURNEY_TOKEN_NAME_MAX_CHARS,\n OPENFIN_JOURNEY_CUSTOM_DATA_KEY,\n JOURNEY_URL_PARAM,\n OPENFIN_OPTIONS_TIMEOUT_MS,\n} from \"../constants\";\nimport { withDeadline } from \"../utils/deadline\";\nimport { BROWSER_STORES, type IdentityStores, newId } from \"../utils/identity\";\nimport { getFin } from \"../utils/openfin\";\nimport { unrefTimer } from \"../utils/unref\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/** Lifetime rules for a journey. A journey is one user task across several contexts. */\nexport interface JourneyOptions {\n /** Maximum open time of a journey, in milliseconds. After this time, the engine ends it. */\n maxAgeMs: number;\n /** True if the journey ends for all contexts when the owning context closes. */\n endOnOwnerClose: boolean;\n /** Query parameter checked at boot for a seeded journey token. */\n urlParam: string;\n}\n\n/** Journey lifetime policy in force. Tests build an engine with shorter values. */\nexport const JOURNEY_OPTIONS: JourneyOptions = {\n maxAgeMs: JOURNEY_MAX_AGE_MS,\n endOnOwnerClose: JOURNEY_END_ON_OWNER_CLOSE,\n urlParam: JOURNEY_URL_PARAM,\n};\n\n/** User journey workflow context shared across windows and applications. */\nexport interface Journey {\n /** Unique journey correlation identifier. */\n id: string;\n /** Journey workflow name for a person to read. */\n name: string;\n /** Journey start timestamp in epoch milliseconds. */\n startedAt: number;\n /** Optional parent journey ID when the journey branches from an earlier journey. */\n parentId?: string;\n /** Context identifier of the document that started the journey. */\n ownerContextId: string;\n}\n\n/**\n * Reads a non-empty string property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Non-empty string value or undefined.\n */\nfunction readString(source: object, key: string): string | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\n/**\n * Reads a finite number property from an unverified object.\n * @param source Object to read from.\n * @param key Property name.\n * @returns Finite number value or undefined.\n */\nfunction readNumber(source: object, key: string): number | undefined {\n const value: unknown = Reflect.get(source, key);\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n}\n\n/**\n * Parses and validates an unknown value into a Journey object. The value comes from\n * sessionStorage or from a bus message of another realm.\n * @param value Unverified parsed JSON value.\n * @returns Validated Journey instance or null.\n */\nexport function parseJourney(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"id\");\n const name = readString(value, \"name\");\n const startedAt = readNumber(value, \"startedAt\");\n if (id === undefined || name === undefined || startedAt === undefined) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: readString(value, \"parentId\"),\n ownerContextId: readString(value, \"ownerContextId\") ?? \"\",\n };\n}\n\n/**\n * Parses and validates decoded token payload into a Journey object.\n * @param value Unverified parsed token payload.\n * @returns Validated Journey instance or null.\n */\nfunction journeyFromTokenPayload(value: unknown): Journey | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const id = readString(value, \"i\");\n const name = readString(value, \"n\");\n const startedAt = readNumber(value, \"s\");\n // The library always writes a start time. A token without one, or from the future, never expires.\n const future = startedAt !== undefined && startedAt > Date.now() + JOURNEY_CLOCK_SKEW_MS;\n if (id === undefined || name === undefined || startedAt === undefined || future) {\n return null;\n }\n return {\n id,\n name,\n startedAt,\n parentId: undefined,\n ownerContextId: \"\",\n };\n}\n\n/**\n * Encodes journey metadata into a compact, URL-safe base64 string.\n * @param journey Journey instance to serialize.\n * @returns Unpadded base64url encoded token string.\n */\nfunction encodeToken(journey: Journey): string {\n const json = JSON.stringify({\n i: journey.id,\n n: journey.name.slice(0, JOURNEY_TOKEN_NAME_MAX_CHARS),\n s: journey.startedAt,\n });\n // Convert the UTF-8 bytes to a binary string before btoa. btoa throws above U+00FF.\n // Without this step, a name in a non-Latin script fails.\n const bytes = new TextEncoder().encode(json);\n let binary = \"\";\n for (const byte of bytes) {\n binary += String.fromCharCode(byte);\n }\n return btoa(binary)\n .replace(BASE64_PLUS_PATTERN, \"-\")\n .replace(BASE64_SLASH_PATTERN, \"_\")\n .replace(BASE64_PADDING_PATTERN, \"\");\n}\n\n/** Manages journey lifecycle, cross-window adoption, storage synchronization, and expiration. */\nexport class JourneyEngine {\n /** Active journey context, or null if none is in progress. */\n private journey: Journey | null = null;\n\n /** Active expiration timer handle. */\n private expiryTimer: ReturnType<typeof setTimeout> | null = null;\n\n /**\n * @param options Journey configuration thresholds.\n * @param diagnostics Diagnostics reporter.\n * @param contextId Unique context identifier for this document.\n * @param onLocalChange Callback invoked when journey state changes locally.\n * @param stores Identity stores that hold the journey.\n */\n constructor(\n private readonly options: JourneyOptions,\n private readonly diagnostics: Diagnostics,\n private readonly contextId: string,\n private readonly onLocalChange: (journey: Journey | null) => void,\n private readonly stores: IdentityStores = BROWSER_STORES,\n ) {}\n\n /** Returns the active journey instance or null. */\n current(): Journey | null {\n return this.journey;\n }\n\n /**\n * Finds and adopts the initial journey. It checks the URL query, then sessionStorage,\n * then OpenFin customData.\n * @returns Promise that resolves when journey initialization completes.\n */\n async bootstrap(): Promise<void> {\n const fromUrl = this.readUrlToken();\n if (fromUrl && this.adopt(fromUrl, \"url\")) {\n this.removeUrlToken();\n return;\n }\n\n const fromStorage = this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the persisted journey.\",\n () => this.stores.session().getItem(JOURNEY_STORAGE_KEY),\n );\n if (fromStorage && this.restore(fromStorage)) {\n return;\n }\n\n const fromOpenFin = await this.readOpenFinToken();\n if (fromOpenFin !== null) {\n this.adopt(fromOpenFin, \"openfin.customData\");\n }\n }\n\n /**\n * Starts a new journey. It replaces the active journey and tells connected peers.\n * @param name Human-readable workflow name.\n * @param opts Optional parent linkage and pre-assigned identifier.\n * @returns Started Journey instance.\n */\n start(name: string, opts: { parent?: boolean; id?: string } = {}): Journey {\n const journey: Journey = {\n id: this.journeyId(opts.id),\n name,\n startedAt: Date.now(),\n parentId: opts.parent ? this.journey?.id : undefined,\n ownerContextId: this.contextId,\n };\n this.setJourney(journey);\n this.onLocalChange(journey);\n return journey;\n }\n\n /**\n * Gives the id of a new journey. A longer id, or an id with multibyte characters, makes the\n * journey token too long for adoptJourney().\n * @param requested Id from the app, or undefined.\n * @returns The requested id when it matches JOURNEY_ID_PATTERN, else a new id.\n */\n private journeyId(requested: unknown): string {\n if (requested === undefined) {\n return newId(this.diagnostics);\n }\n\n if (typeof requested === \"string\" && JOURNEY_ID_PATTERN.test(requested)) {\n return requested;\n }\n\n this.diagnostics.report(\n \"config.invalid\",\n `startJourney() needs an id of 1 to ${String(JOURNEY_ID_MAX_CHARS)} letters, digits, \"_\", \".\", \":\" or \"-\". The library uses a new id.`,\n );\n return newId(this.diagnostics);\n }\n\n /** Ends the active journey and broadcasts the change. */\n end(): void {\n if (this.journey === null) {\n return;\n }\n this.setJourney(null);\n this.onLocalChange(null);\n }\n\n /**\n * Applies a journey update from a bus peer. It does not broadcast the update again.\n * An echo makes two windows send the change back and forth without end.\n * It ignores a journey with the same ID as the active journey. Thus an echo cannot\n * restart the timer.\n * @param journey Updated Journey instance or null.\n */\n applyRemote(journey: Journey | null): void {\n const current = this.journey;\n if (journey !== null && current !== null && journey.id === current.id) {\n return;\n }\n this.setJourney(journey);\n }\n\n /**\n * Serializes the active journey into a compact token for URL or intent transfer.\n * @returns Base64url token, or undefined when no journey is active or the token exceeds\n * the size limit.\n */\n getToken(): string | undefined {\n const journey = this.journey;\n if (journey === null) {\n return undefined;\n }\n const token = encodeToken(journey);\n if (token.length > JOURNEY_TOKEN_MAX_CHARS) {\n this.diagnostics.report(\n \"journey.token_too_large\",\n \"The journey token is larger than the size limit. The library does not issue it.\",\n { length: token.length },\n );\n return undefined;\n }\n return token;\n }\n\n /**\n * Validates and adopts a serialized journey token.\n * @param token Base64url journey token.\n * @param source Originating source description for diagnostics.\n * @param broadcast True to send the adoption to the connected bus peers.\n * @returns True if the token was valid, unexpired, and adopted.\n */\n adopt(token: string, source: string, broadcast = false): boolean {\n const decoded = this.decodeToken(token);\n if (decoded === null) {\n return false;\n }\n if (Date.now() - decoded.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a seeded journey older than maxAgeMs.\",\n {\n source,\n name: decoded.name,\n },\n );\n return false;\n }\n\n this.setJourney(decoded);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library adopted the journey \"${decoded.name}\".`,\n {\n source,\n journeyId: decoded.id,\n },\n );\n if (broadcast) {\n this.onLocalChange(decoded);\n }\n return true;\n }\n\n /**\n * Ends the journey when endOnOwnerClose is on and the closed context owns the journey.\n * @param ownerContextId Context identifier of the closed window.\n */\n ownerClosed(ownerContextId: string): void {\n if (!this.options.endOnOwnerClose) {\n return;\n }\n if (this.journey?.ownerContextId === ownerContextId) {\n this.end();\n }\n }\n\n /** Clears pending expiration timers and releases resources on shutdown. */\n destroy(): void {\n this.clearTimer();\n }\n\n /**\n * Resumes a persisted journey from raw sessionStorage data.\n * @param raw Serialized JSON string from storage.\n * @returns True if the engine restored the journey.\n */\n private restore(raw: string): boolean {\n const parsed = this.diagnostics.guard(\n \"storage.degraded\",\n \"The library could not parse the persisted journey.\",\n () => JSON.parse(raw) as unknown,\n );\n const journey = parseJourney(parsed);\n if (journey === null) {\n return false;\n }\n\n if (Date.now() - journey.startedAt > this.options.maxAgeMs) {\n this.diagnostics.report(\n \"journey.expired\",\n \"The library discarded a persisted journey older than maxAgeMs.\",\n { name: journey.name },\n );\n this.clearStored();\n return false;\n }\n\n this.setJourney(journey);\n this.diagnostics.report(\n \"journey.adopted\",\n `The library resumed the journey \"${journey.name}\".`,\n {\n source: \"sessionStorage\",\n journeyId: journey.id,\n },\n );\n return true;\n }\n\n /**\n * Decodes a base64url token into a validated Journey object. Anyone can edit the URL\n * that holds a token. Each step throws on bad input. The guard reports the failure\n * and does not throw it.\n * @param token Encoded token string.\n * @returns Decoded Journey instance or null on decode error.\n */\n private decodeToken(token: string): Journey | null {\n const decoded = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not decode a seeded journey token.\",\n () => {\n const standard = token\n .replace(BASE64URL_DASH_PATTERN, \"+\")\n .replace(BASE64URL_UNDERSCORE_PATTERN, \"/\");\n const missing =\n (BASE64_GROUP_CHARS - (standard.length % BASE64_GROUP_CHARS)) % BASE64_GROUP_CHARS;\n const padding = \"=\".repeat(missing);\n const bytes = Uint8Array.from(atob(standard + padding), (c) => c.charCodeAt(0));\n return journeyFromTokenPayload(JSON.parse(new TextDecoder().decode(bytes)) as unknown);\n },\n );\n return decoded ?? null;\n }\n\n /**\n * Sets the active journey, updates sessionStorage, and schedules expiration.\n * @param journey Target Journey instance or null.\n */\n private setJourney(journey: Journey | null): void {\n this.journey = journey;\n this.clearTimer();\n\n this.diagnostics.guard(\"storage.unavailable\", \"The library could not save the journey.\", () => {\n if (journey !== null) {\n this.stores.session().setItem(JOURNEY_STORAGE_KEY, JSON.stringify(journey));\n } else {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n }\n });\n\n if (journey === null) {\n return;\n }\n\n const remaining = Math.max(this.options.maxAgeMs - (Date.now() - journey.startedAt), 0);\n const timer = setTimeout(() => {\n this.diagnostics.report(\n \"journey.expired\",\n `The journey \"${journey.name}\" reached maxAgeMs. The library ended it.`,\n { journeyId: journey.id },\n );\n this.journey = null;\n this.expiryTimer = null;\n this.clearStored();\n }, remaining);\n this.expiryTimer = timer;\n unrefTimer(timer);\n }\n\n /** Removes journey data from the session store. */\n private clearStored(): void {\n this.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not clear the persisted journey.\",\n () => {\n this.stores.session().removeItem(JOURNEY_STORAGE_KEY);\n },\n );\n }\n\n /** Cancels any active expiration timer. */\n private clearTimer(): void {\n if (this.expiryTimer !== null) {\n clearTimeout(this.expiryTimer);\n this.expiryTimer = null;\n }\n }\n\n /**\n * Extracts the journey token from the current window location search parameters.\n * @returns Token string or null.\n */\n private readUrlToken(): string | null {\n const token = this.diagnostics.guard(\n \"config.invalid\",\n \"The library could not read the journey token from the URL.\",\n () => {\n if (typeof location === \"undefined\") {\n return null;\n }\n return new URL(location.href).searchParams.get(this.options.urlParam);\n },\n );\n return token ?? null;\n }\n\n /**\n * Removes the journey token from the address bar after the engine adopts it.\n * If not, a copy or a bookmark of the link starts the same journey in another session.\n */\n private removeUrlToken(): void {\n this.diagnostics.guard(\n \"platform.api_blocked\",\n \"The library could not remove the journey token from the URL.\",\n () => {\n const url = new URL(location.href);\n url.searchParams.delete(this.options.urlParam);\n // Keep history.state. A router stores its own state there.\n history.replaceState(history.state, \"\", url.href);\n },\n );\n }\n\n /**\n * Reads the journey token from the customData of the OpenFin window options.\n * OPENFIN_OPTIONS_TIMEOUT_MS limits the wait. At the deadline, it reports\n * openfin.unavailable and returns no token. A window without a token gives the same result.\n * @returns Promise that resolves to token string or null.\n */\n private async readOpenFinToken(): Promise<string | null> {\n const me = getFin()?.me;\n const getOptions = me?.getOptions;\n if (getOptions === undefined) {\n return null;\n }\n\n // Use call to keep the receiver of the native OpenFin method. A detached copy\n // throws when called.\n const options = await this.diagnostics.guardAsync(\n \"openfin.unavailable\",\n \"The library could not read fin.me.getOptions().\",\n () => withDeadline(getOptions.call(me), OPENFIN_OPTIONS_TIMEOUT_MS),\n );\n const token = options?.customData?.[OPENFIN_JOURNEY_CUSTOM_DATA_KEY];\n return typeof token === \"string\" ? token : null;\n }\n}\n"],"mappings":"A,0JA0CA,IAAamB,EAAkC,CAC7C,SAAUnB,EAAAA,GACV,gBAAA,GACA,SAAUC,EAAAA,EACZ,EAsBA,SAASmB,EAAW,EAAgB,EAAiC,CACnE,IAAMC,EAAiB,QAAQ,IAAIC,EAAQC,CAAG,EAC9C,OAAO,OAAOF,GAAU,UAAYA,IAAU,GAAKA,EAAQ,IAAA,EAC7D,CAQA,SAASG,EAAW,EAAgB,EAAiC,CACnE,IAAMH,EAAiB,QAAQ,IAAIC,EAAQC,CAAG,EAC9C,OAAO,OAAOF,GAAU,UAAY,OAAO,SAASA,CAAK,EAAIA,EAAQ,IAAA,EACvE,CAQA,SAAgBI,EAAa,EAAgC,CAC3D,GAAI,OAAOJ,GAAU,WAAYA,EAC/B,OAAO,KAET,IAAMK,EAAKN,EAAWC,EAAO,IAAI,EAC3BM,EAAOP,EAAWC,EAAO,MAAM,EAC/BO,EAAYJ,EAAWH,EAAO,WAAW,EAI/C,OAHIK,IAAO,IAAA,IAAaC,IAAS,IAAA,IAAaC,IAAc,IAAA,GACnD,KAEF,CACL,KACA,OACA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AS,IAAI,EACjCA,EAAI,aAAa,OAAO,KAAK,QAAQ,QAAQ,EAE7C,QAAQ,aAAa,QAAQ,MAAO,GAAIA,EAAI,IAAI,CAClD,CACF,CACF,CAQA,MAAc,kBAA2C,CACvD,IAAMC,EAAKlD,EAAAA,EAAO,CAAC,EAAE,GACfmD,EAAaD,GAAI,WACvB,GAAIC,IAAe,IAAA,GACjB,OAAO,KAUT,IAAMb,GAAQ,MALQ,KAAK,YAAY,WACrC,sBACA,sDACMrC,EAAAA,EAAakD,EAAW,KAAKD,CAAE,EAAGhD,EAAAA,EAA0B,CACpE,EAAA,EACuB,aAAaC,EAAAA,IACpC,OAAO,OAAOmC,GAAU,SAAWA,EAAQ,IAC7C,CACF,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"keys-BHhw_0Wh.cjs","names":["batchKey","prefix","batch","keysWithPrefix","out","diagnostics","i","key"],"sources":["../src/storage/keys.ts"],"sourcesContent":["// src/storage/keys.ts\n//\n// This module builds the localStorage key of a batch. It also returns the sorted keys that start\n// with a prefix. A sandboxed frame and private mode throw on first access. They do not return null.\n\nimport { BATCH_KEY_TIME_WIDTH } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\n\n/**\n * Formats a storage key with a zero-padded creation time. The keys sort in FIFO order. Always use\n * batch.createdAt, never Date.now(). A key from Date.now() does not match the written key.\n * @param prefix Storage key prefix.\n * @param batch Target log batch.\n * @returns Prefixed, timestamp-ordered storage key.\n */\nexport function batchKey(prefix: string, batch: LogBatch): string {\n const at = String(batch.createdAt).padStart(BATCH_KEY_TIME_WIDTH, \"0\");\n return `${prefix}${at}.${batch.id}`;\n}\n\n/**\n * Returns all localStorage keys that start with the prefix, in sorted order.\n * @param prefix Storage key prefix to filter by.\n * @param diagnostics Diagnostics reporter.\n * @returns Sorted array of matching storage keys.\n */\nexport function keysWithPrefix(prefix: string, diagnostics: Diagnostics): string[] {\n const out: string[] = [];\n\n diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not list the localStorage keys.\",\n () => {\n for (let i = 0; i < localStorage.length; i++) {\n // localStorage.key(i) has the type string | null. It cannot be null below length. A\n // null check here adds a branch that no test can reach.\n const key = String(localStorage.key(i));\n if (key.startsWith(prefix)) {\n out.push(key);\n }\n }\n },\n );\n\n return out.sort();\n}\n"],"mappings":"AAgBA,SAAgBA,EAAS,EAAgB,EAAyB,CAEhE,MAAO,GAAGC,IADC,OAAOC,EAAM,SAAS,CAAC,CAAC,SAAA,GAA+B,GAC/C,EAAG,GAAGA,EAAM,IACjC,CAQA,SAAgBC,EAAe,EAAgB,EAAoC,CACjF,IAAMC,EAAgB,CAAC,EAiBvB,OAfAC,EAAY,MACV,sBACA,wDACM,CACJ,IAAK,IAAIC,EAAI,EAAGA,EAAI,aAAa,OAAQ,IAAK,CAG5C,IAAMC,EAAM,OAAO,aAAa,IAAID,CAAC,CAAC,EAClCC,EAAI,WAAWN,CAAM,GACvBG,EAAI,KAAKG,CAAG,CAEhB,CACF,CACF,EAEOH,EAAI,KAAK,CAClB"}
1
+ {"version":3,"file":"keys-BHhw_0Wh.cjs","names":["batchKey","prefix","batch","keysWithPrefix","out","diagnostics","i","key"],"sources":["../src/storage/keys.ts"],"sourcesContent":["// src/storage/keys.ts\n//\n// This module builds the localStorage key of a batch. It also returns the sorted keys that start\n// with a prefix. A sandboxed frame and private mode throw on first access. They do not return null.\n\nimport { BATCH_KEY_TIME_WIDTH } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\n\n/**\n * Formats a storage key with a zero-padded creation time. The keys sort in FIFO order. Always use\n * batch.createdAt, never Date.now(). A key from Date.now() does not match the written key.\n * @param prefix Storage key prefix.\n * @param batch Target log batch.\n * @returns Prefixed, timestamp-ordered storage key.\n */\nexport function batchKey(prefix: string, batch: LogBatch): string {\n const at = String(batch.createdAt).padStart(BATCH_KEY_TIME_WIDTH, \"0\");\n return `${prefix}${at}.${batch.id}`;\n}\n\n/**\n * Returns all localStorage keys that start with the prefix, in sorted order.\n * @param prefix Storage key prefix to filter by.\n * @param diagnostics Diagnostics reporter.\n * @returns Sorted array of matching storage keys.\n */\nexport function keysWithPrefix(prefix: string, diagnostics: Diagnostics): string[] {\n const out: string[] = [];\n\n diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not list the localStorage keys.\",\n () => {\n for (let i = 0; i < localStorage.length; i++) {\n // localStorage.key(i) has the type string | null. It cannot be null below length. A\n // null check here adds a branch that no test can reach.\n const key = String(localStorage.key(i));\n if (key.startsWith(prefix)) {\n out.push(key);\n }\n }\n },\n );\n\n return out.sort();\n}\n"],"mappings":"AAgBA,SAAgBA,EAAS,EAAgB,EAAyB,CAEhE,MAAO,GAAGC,IADC,OAAOC,EAAM,SAAS,CAAC,CAAC,SAAA,GAA+B,GAC/C,EAAG,GAAGA,EAAM,IACjC,CAQA,SAAgBC,EAAe,EAAgB,EAAoC,CACjF,IAAMC,EAAgB,CAAC,EAiBvB,OAfAC,EAAY,MACV,sBACA,wDACM,CACJ,IAAK,IAAIC,EAAI,EAAGA,EAAI,aAAa,OAAQ,IAAK,CAG5C,IAAMC,EAAM,OAAO,aAAa,IAAID,CAAC,CAAC,EAClCC,EAAI,WAAWN,CAAM,GACvBG,EAAI,KAAKG,CAAG,CAEhB,CACF,CACF,EAEOH,EAAI,KAAK,CAClB,C"}
@@ -1,4 +1,4 @@
1
- //#region src/storage/keys.ts
1
+ // src/storage/keys.ts
2
2
  function e(e, t) {
3
3
  return `${e}${String(t.createdAt).padStart(14, "0")}.${t.id}`;
4
4
  }
@@ -11,7 +11,6 @@ function t(e, t) {
11
11
  }
12
12
  }), n.sort();
13
13
  }
14
- //#endregion
15
14
  export { t as n, e as t };
16
15
 
17
- //# sourceMappingURL=keys-D5r_GH9q.js.map
16
+ //# sourceMappingURL=keys-BU9j5YqW.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keys-D5r_GH9q.js","names":["batchKey","prefix","batch","keysWithPrefix","out","diagnostics","i","key"],"sources":["../src/storage/keys.ts"],"sourcesContent":["// src/storage/keys.ts\n//\n// This module builds the localStorage key of a batch. It also returns the sorted keys that start\n// with a prefix. A sandboxed frame and private mode throw on first access. They do not return null.\n\nimport { BATCH_KEY_TIME_WIDTH } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\n\n/**\n * Formats a storage key with a zero-padded creation time. The keys sort in FIFO order. Always use\n * batch.createdAt, never Date.now(). A key from Date.now() does not match the written key.\n * @param prefix Storage key prefix.\n * @param batch Target log batch.\n * @returns Prefixed, timestamp-ordered storage key.\n */\nexport function batchKey(prefix: string, batch: LogBatch): string {\n const at = String(batch.createdAt).padStart(BATCH_KEY_TIME_WIDTH, \"0\");\n return `${prefix}${at}.${batch.id}`;\n}\n\n/**\n * Returns all localStorage keys that start with the prefix, in sorted order.\n * @param prefix Storage key prefix to filter by.\n * @param diagnostics Diagnostics reporter.\n * @returns Sorted array of matching storage keys.\n */\nexport function keysWithPrefix(prefix: string, diagnostics: Diagnostics): string[] {\n const out: string[] = [];\n\n diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not list the localStorage keys.\",\n () => {\n for (let i = 0; i < localStorage.length; i++) {\n // localStorage.key(i) has the type string | null. It cannot be null below length. A\n // null check here adds a branch that no test can reach.\n const key = String(localStorage.key(i));\n if (key.startsWith(prefix)) {\n out.push(key);\n }\n }\n },\n );\n\n return out.sort();\n}\n"],"mappings":";AAgBA,SAAgBA,EAAS,GAAgB,GAAyB;CAEhE,OAAO,GAAGC,IADC,OAAOC,EAAM,SAAS,CAAC,CAAC,SAAA,IAA+B,GAC/C,EAAG,GAAGA,EAAM;AACjC;AAQA,SAAgBC,EAAe,GAAgB,GAAoC;CACjF,IAAMC,IAAgB,CAAC;CAiBvB,OAfAC,EAAY,MACV,uBACA,2DACM;EACJ,KAAK,IAAIC,IAAI,GAAGA,IAAI,aAAa,QAAQ,KAAK;GAG5C,IAAMC,IAAM,OAAO,aAAa,IAAID,CAAC,CAAC;GACtC,AAAIC,EAAI,WAAWN,CAAM,KACvBG,EAAI,KAAKG,CAAG;EAEhB;CACF,CACF,GAEOH,EAAI,KAAK;AAClB"}
1
+ {"version":3,"file":"keys-BU9j5YqW.js","names":["batchKey","prefix","batch","keysWithPrefix","out","diagnostics","i","key"],"sources":["../src/storage/keys.ts"],"sourcesContent":["// src/storage/keys.ts\n//\n// This module builds the localStorage key of a batch. It also returns the sorted keys that start\n// with a prefix. A sandboxed frame and private mode throw on first access. They do not return null.\n\nimport { BATCH_KEY_TIME_WIDTH } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\n\n/**\n * Formats a storage key with a zero-padded creation time. The keys sort in FIFO order. Always use\n * batch.createdAt, never Date.now(). A key from Date.now() does not match the written key.\n * @param prefix Storage key prefix.\n * @param batch Target log batch.\n * @returns Prefixed, timestamp-ordered storage key.\n */\nexport function batchKey(prefix: string, batch: LogBatch): string {\n const at = String(batch.createdAt).padStart(BATCH_KEY_TIME_WIDTH, \"0\");\n return `${prefix}${at}.${batch.id}`;\n}\n\n/**\n * Returns all localStorage keys that start with the prefix, in sorted order.\n * @param prefix Storage key prefix to filter by.\n * @param diagnostics Diagnostics reporter.\n * @returns Sorted array of matching storage keys.\n */\nexport function keysWithPrefix(prefix: string, diagnostics: Diagnostics): string[] {\n const out: string[] = [];\n\n diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not list the localStorage keys.\",\n () => {\n for (let i = 0; i < localStorage.length; i++) {\n // localStorage.key(i) has the type string | null. It cannot be null below length. A\n // null check here adds a branch that no test can reach.\n const key = String(localStorage.key(i));\n if (key.startsWith(prefix)) {\n out.push(key);\n }\n }\n },\n );\n\n return out.sort();\n}\n"],"mappings":";AAgBA,SAAgBA,EAAS,GAAgB,GAAyB;CAEhE,OAAO,GAAGC,IADC,OAAOC,EAAM,SAAS,CAAC,CAAC,SAAA,IAA+B,GAC/C,EAAG,GAAGA,EAAM;AACjC;AAQA,SAAgBC,EAAe,GAAgB,GAAoC;CACjF,IAAMC,IAAgB,CAAC;CAiBvB,OAfAC,EAAY,MACV,uBACA,2DACM;EACJ,KAAK,IAAIC,IAAI,GAAGA,IAAI,aAAa,QAAQ,KAAK;GAG5C,IAAMC,IAAM,OAAO,aAAa,IAAID,CAAC,CAAC;GACtC,AAAIC,EAAI,WAAWN,CAAM,KACvBG,EAAI,KAAKG,CAAG;EAEhB;CACF,CACF,GAEOH,EAAI,KAAK;AAClB"}
@@ -0,0 +1,13 @@
1
+ import { Tt as e } from "./constants-zyrqveN4.js";
2
+ import { t } from "./global-scope-D9I8s-oN.js";
3
+ // src/utils/library-console.ts
4
+ var n = t(e);
5
+ function r(e) {
6
+ return n.run(e);
7
+ }
8
+ function i() {
9
+ return n.open();
10
+ }
11
+ export { r as n, i as t };
12
+
13
+ //# sourceMappingURL=library-console-C1m6g1BR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-console-CabK2j2-.js","names":["LIBRARY_CONSOLE_KEY","scope","globalScope","runAsLibraryConsole","fn","isLibraryConsole"],"sources":["../src/utils/library-console.ts"],"sourcesContent":["// src/utils/library-console.ts\n//\n// Marks the console calls that the library makes itself. The console capture skips a call inside\n// this scope. Without the scope, the capture records each mirrored line again, and the loop does\n// not stop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn Function that writes to the console.\n * @returns The return value of the function.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library console scope is open.\n * @returns True while the library writes to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":";;;AAUA,IAAMC,IAAQC,EAAYF,CAAmB;AAO7C,SAAgBG,EAAuB,GAAgB;CACrD,OAAOF,EAAM,IAAIG,CAAE;AACrB;AAMA,SAAgBC,IAA4B;CAC1C,OAAOJ,EAAM,KAAK;AACpB"}
1
+ {"version":3,"file":"library-console-C1m6g1BR.js","names":["LIBRARY_CONSOLE_KEY","scope","globalScope","runAsLibraryConsole","fn","isLibraryConsole"],"sources":["../src/utils/library-console.ts"],"sourcesContent":["// src/utils/library-console.ts\n//\n// Marks the console calls that the library makes itself. The console capture skips a call inside\n// this scope. Without the scope, the capture records each mirrored line again, and the loop does\n// not stop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn Function that writes to the console.\n * @returns The return value of the function.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library console scope is open.\n * @returns True while the library writes to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":";;;AAUA,IAAMC,IAAQC,EAAYF,CAAmB;AAO7C,SAAgBG,EAAuB,GAAgB;CACrD,OAAOF,EAAM,IAAIG,CAAE;AACrB;AAMA,SAAgBC,IAA4B;CAC1C,OAAOJ,EAAM,KAAK;AACpB"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants-CL0ZdI2f.cjs");var t=require("./global-scope-BN-Io_yv.cjs").t(e.Tt);function n(e){return t.run(e)}function r(){return t.open()}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
2
- //# sourceMappingURL=library-console-g_VU-wzP.cjs.map
1
+ const e=require("./constants-DqKJH_MP.cjs");var t=require("./global-scope-BN-Io_yv.cjs").t(e.Tt);function n(e){return t.run(e)}function r(){return t.open()}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
2
+ //# sourceMappingURL=library-console-D2GY9Or6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-console-g_VU-wzP.cjs","names":["globalScope","LIBRARY_CONSOLE_KEY","require_constants","scope","runAsLibraryConsole","fn","isLibraryConsole"],"sources":["../src/utils/library-console.ts"],"sourcesContent":["// src/utils/library-console.ts\n//\n// Marks the console calls that the library makes itself. The console capture skips a call inside\n// this scope. Without the scope, the capture records each mirrored line again, and the loop does\n// not stop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn Function that writes to the console.\n * @returns The return value of the function.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library console scope is open.\n * @returns True while the library writes to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":"4CAUA,IAAMG,uCAAQH,CAAAA,CAAAA,EAAYC,EAAAA,EAAmB,EAO7C,SAAgBG,EAAuB,EAAgB,CACrD,OAAOD,EAAM,IAAIE,CAAE,CACrB,CAMA,SAAgBC,GAA4B,CAC1C,OAAOH,EAAM,KAAK,CACpB"}
1
+ {"version":3,"file":"library-console-D2GY9Or6.cjs","names":["globalScope","LIBRARY_CONSOLE_KEY","require_constants","scope","runAsLibraryConsole","fn","isLibraryConsole"],"sources":["../src/utils/library-console.ts"],"sourcesContent":["// src/utils/library-console.ts\n//\n// Marks the console calls that the library makes itself. The console capture skips a call inside\n// this scope. Without the scope, the capture records each mirrored line again, and the loop does\n// not stop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn Function that writes to the console.\n * @returns The return value of the function.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library console scope is open.\n * @returns True while the library writes to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":"A,4CAUA,IAAMG,E,qCAAQH,CAAAA,CAAAA,EAAYC,EAAAA,EAAmB,EAO7C,SAAgBG,EAAuB,EAAgB,CACrD,OAAOD,EAAM,IAAIE,CAAE,CACrB,CAMA,SAAgBC,GAA4B,CAC1C,OAAOH,EAAM,KAAK,CACpB,C"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants-CL0ZdI2f.cjs");var t=require("./global-scope-BN-Io_yv.cjs").t(e.Dt),n=Symbol.for(e.Ln),r=globalThis,i=()=>r[n]??0;function a(e){return t.run(e)}function o(){return t.open()}async function s(e){r[n]=i()+1;try{return await e()}finally{r[n]=i()-1}}function c(){return i()>0}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
2
- //# sourceMappingURL=library-request-FQaiWjCP.cjs.map
1
+ const e=require("./constants-DqKJH_MP.cjs");var t=require("./global-scope-BN-Io_yv.cjs").t(e.Dt),n=Symbol.for(e.Ln),r=globalThis,i=()=>r[n]??0;function a(e){return t.run(e)}function o(){return t.open()}async function s(e){r[n]=i()+1;try{return await e()}finally{r[n]=i()-1}}function c(){return i()>0}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
2
+ //# sourceMappingURL=library-request-1BX_UlaX.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-request-FQaiWjCP.cjs","names":["globalScope","LIBRARY_REQUEST_KEY","TRANSPORT_CALL_KEY","require_constants","scope","calls","store","pending","runAsLibraryRequest","fn","isLibraryRequest","trackTransportCall","isTransportPending"],"sources":["../src/utils/library-request.ts"],"sourcesContent":["// src/utils/library-request.ts\n//\n// Marks the requests that the library starts itself. Network capture skips a request that starts\n// inside this scope. A captured library request logs a record. The library then sends that record\n// with another request. The loop does not stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of the custom transport calls that wait for an answer. */\nconst calls = Symbol.for(TRANSPORT_CALL_KEY);\nconst store = globalThis as unknown as Record<symbol, number | undefined>;\nconst pending = (): number => store[calls] ?? 0;\n\n/**\n * Runs a function inside the library request scope. The scope covers only the synchronous part\n * of the function. A request that starts after an await is outside the scope.\n * @param fn Function that starts the request.\n * @returns The return value of the function.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library request scope is open.\n * @returns True while the library starts a request.\n */\nexport function isLibraryRequest(): boolean {\n return scope.open();\n}\n\n/**\n * Runs a custom transport call and counts it until it settles. The count includes the time after\n * each await, which the library request scope does not cover.\n * @param fn Function that calls the custom transport.\n * @returns Promise that settles with the result of the call.\n */\nexport async function trackTransportCall<T>(fn: () => T | PromiseLike<T>): Promise<T> {\n store[calls] = pending() + 1;\n\n try {\n return await fn();\n } finally {\n store[calls] = pending() - 1;\n }\n}\n\n/**\n * Tests if a custom transport call waits for an answer.\n * @returns True while a call has not settled.\n */\nexport function isTransportPending(): boolean {\n return pending() > 0;\n}\n"],"mappings":"4CAUA,IAAMI,uCAAQJ,CAAAA,CAAAA,EAAYC,EAAAA,EAAmB,EAGvCI,EAAQ,OAAO,IAAIH,EAAAA,EAAkB,EACrCI,EAAQ,WACRC,MAAwBD,EAAMD,IAAU,EAQ9C,SAAgBG,EAAuB,EAAgB,CACrD,OAAOJ,EAAM,IAAIK,CAAE,CACrB,CAMA,SAAgBC,GAA4B,CAC1C,OAAON,EAAM,KAAK,CACpB,CAQA,eAAsBO,EAAsB,EAA0C,CACpF,EAAMN,GAASE,EAAQ,EAAI,EAE3B,GAAI,CACF,OAAO,MAAME,EAAG,CAClB,QAAU,CACR,EAAMJ,GAASE,EAAQ,EAAI,CAC7B,CACF,CAMA,SAAgBK,GAA8B,CAC5C,OAAOL,EAAQ,EAAI,CACrB"}
1
+ {"version":3,"file":"library-request-1BX_UlaX.cjs","names":["globalScope","LIBRARY_REQUEST_KEY","TRANSPORT_CALL_KEY","require_constants","scope","calls","store","pending","runAsLibraryRequest","fn","isLibraryRequest","trackTransportCall","isTransportPending"],"sources":["../src/utils/library-request.ts"],"sourcesContent":["// src/utils/library-request.ts\n//\n// Marks the requests that the library starts itself. Network capture skips a request that starts\n// inside this scope. A captured library request logs a record. The library then sends that record\n// with another request. The loop does not stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of the custom transport calls that wait for an answer. */\nconst calls = Symbol.for(TRANSPORT_CALL_KEY);\nconst store = globalThis as unknown as Record<symbol, number | undefined>;\nconst pending = (): number => store[calls] ?? 0;\n\n/**\n * Runs a function inside the library request scope. The scope covers only the synchronous part\n * of the function. A request that starts after an await is outside the scope.\n * @param fn Function that starts the request.\n * @returns The return value of the function.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library request scope is open.\n * @returns True while the library starts a request.\n */\nexport function isLibraryRequest(): boolean {\n return scope.open();\n}\n\n/**\n * Runs a custom transport call and counts it until it settles. The count includes the time after\n * each await, which the library request scope does not cover.\n * @param fn Function that calls the custom transport.\n * @returns Promise that settles with the result of the call.\n */\nexport async function trackTransportCall<T>(fn: () => T | PromiseLike<T>): Promise<T> {\n store[calls] = pending() + 1;\n\n try {\n return await fn();\n } finally {\n store[calls] = pending() - 1;\n }\n}\n\n/**\n * Tests if a custom transport call waits for an answer.\n * @returns True while a call has not settled.\n */\nexport function isTransportPending(): boolean {\n return pending() > 0;\n}\n"],"mappings":"A,4CAUA,IAAMI,E,qCAAQJ,CAAAA,CAAAA,EAAYC,EAAAA,EAAmB,EAGvCI,EAAQ,OAAO,IAAIH,EAAAA,EAAkB,EACrCI,EAAQ,WACRC,MAAwBD,EAAMD,IAAU,EAQ9C,SAAgBG,EAAuB,EAAgB,CACrD,OAAOJ,EAAM,IAAIK,CAAE,CACrB,CAMA,SAAgBC,GAA4B,CAC1C,OAAON,EAAM,KAAK,CACpB,CAQA,eAAsBO,EAAsB,EAA0C,CACpF,EAAMN,GAASE,EAAQ,EAAI,EAE3B,GAAI,CACF,OAAO,MAAME,EAAG,CAClB,QAAU,CACR,EAAMJ,GAASE,EAAQ,EAAI,CAC7B,CACF,CAMA,SAAgBK,GAA8B,CAC5C,OAAOL,EAAQ,EAAI,CACrB,C"}
@@ -1,6 +1,6 @@
1
- import { Dt as e, Ln as t } from "./constants-CU60FG4w.js";
2
- import { t as n } from "./global-scope-dp2jADRl.js";
3
- //#region src/utils/library-request.ts
1
+ import { Dt as e, Ln as t } from "./constants-zyrqveN4.js";
2
+ import { t as n } from "./global-scope-D9I8s-oN.js";
3
+ // src/utils/library-request.ts
4
4
  var r = n(e), i = Symbol.for(t), a = globalThis, o = () => a[i] ?? 0;
5
5
  function s(e) {
6
6
  return r.run(e);
@@ -19,7 +19,6 @@ async function l(e) {
19
19
  function u() {
20
20
  return o() > 0;
21
21
  }
22
- //#endregion
23
22
  export { l as i, u as n, s as r, c as t };
24
23
 
25
- //# sourceMappingURL=library-request-CyC-9IOk.js.map
24
+ //# sourceMappingURL=library-request-BQBT9N9Q.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-request-CyC-9IOk.js","names":["LIBRARY_REQUEST_KEY","TRANSPORT_CALL_KEY","globalScope","scope","calls","store","pending","runAsLibraryRequest","fn","isLibraryRequest","trackTransportCall","isTransportPending"],"sources":["../src/utils/library-request.ts"],"sourcesContent":["// src/utils/library-request.ts\n//\n// Marks the requests that the library starts itself. Network capture skips a request that starts\n// inside this scope. A captured library request logs a record. The library then sends that record\n// with another request. The loop does not stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of the custom transport calls that wait for an answer. */\nconst calls = Symbol.for(TRANSPORT_CALL_KEY);\nconst store = globalThis as unknown as Record<symbol, number | undefined>;\nconst pending = (): number => store[calls] ?? 0;\n\n/**\n * Runs a function inside the library request scope. The scope covers only the synchronous part\n * of the function. A request that starts after an await is outside the scope.\n * @param fn Function that starts the request.\n * @returns The return value of the function.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library request scope is open.\n * @returns True while the library starts a request.\n */\nexport function isLibraryRequest(): boolean {\n return scope.open();\n}\n\n/**\n * Runs a custom transport call and counts it until it settles. The count includes the time after\n * each await, which the library request scope does not cover.\n * @param fn Function that calls the custom transport.\n * @returns Promise that settles with the result of the call.\n */\nexport async function trackTransportCall<T>(fn: () => T | PromiseLike<T>): Promise<T> {\n store[calls] = pending() + 1;\n\n try {\n return await fn();\n } finally {\n store[calls] = pending() - 1;\n }\n}\n\n/**\n * Tests if a custom transport call waits for an answer.\n * @returns True while a call has not settled.\n */\nexport function isTransportPending(): boolean {\n return pending() > 0;\n}\n"],"mappings":";;;AAUA,IAAMG,IAAQD,EAAYF,CAAmB,GAGvCI,IAAQ,OAAO,IAAIH,CAAkB,GACrCI,IAAQ,YACRC,UAAwBD,EAAMD,MAAU;AAQ9C,SAAgBG,EAAuB,GAAgB;CACrD,OAAOJ,EAAM,IAAIK,CAAE;AACrB;AAMA,SAAgBC,IAA4B;CAC1C,OAAON,EAAM,KAAK;AACpB;AAQA,eAAsBO,EAAsB,GAA0C;CACpF,EAAMN,KAASE,EAAQ,IAAI;CAE3B,IAAI;EACF,OAAO,MAAME,EAAG;CAClB,UAAU;EACR,EAAMJ,KAASE,EAAQ,IAAI;CAC7B;AACF;AAMA,SAAgBK,IAA8B;CAC5C,OAAOL,EAAQ,IAAI;AACrB"}
1
+ {"version":3,"file":"library-request-BQBT9N9Q.js","names":["LIBRARY_REQUEST_KEY","TRANSPORT_CALL_KEY","globalScope","scope","calls","store","pending","runAsLibraryRequest","fn","isLibraryRequest","trackTransportCall","isTransportPending"],"sources":["../src/utils/library-request.ts"],"sourcesContent":["// src/utils/library-request.ts\n//\n// Marks the requests that the library starts itself. Network capture skips a request that starts\n// inside this scope. A captured library request logs a record. The library then sends that record\n// with another request. The loop does not stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** Scope of the library requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of the custom transport calls that wait for an answer. */\nconst calls = Symbol.for(TRANSPORT_CALL_KEY);\nconst store = globalThis as unknown as Record<symbol, number | undefined>;\nconst pending = (): number => store[calls] ?? 0;\n\n/**\n * Runs a function inside the library request scope. The scope covers only the synchronous part\n * of the function. A request that starts after an await is outside the scope.\n * @param fn Function that starts the request.\n * @returns The return value of the function.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Tests if a library request scope is open.\n * @returns True while the library starts a request.\n */\nexport function isLibraryRequest(): boolean {\n return scope.open();\n}\n\n/**\n * Runs a custom transport call and counts it until it settles. The count includes the time after\n * each await, which the library request scope does not cover.\n * @param fn Function that calls the custom transport.\n * @returns Promise that settles with the result of the call.\n */\nexport async function trackTransportCall<T>(fn: () => T | PromiseLike<T>): Promise<T> {\n store[calls] = pending() + 1;\n\n try {\n return await fn();\n } finally {\n store[calls] = pending() - 1;\n }\n}\n\n/**\n * Tests if a custom transport call waits for an answer.\n * @returns True while a call has not settled.\n */\nexport function isTransportPending(): boolean {\n return pending() > 0;\n}\n"],"mappings":";;;AAUA,IAAMG,IAAQD,EAAYF,CAAmB,GAGvCI,IAAQ,OAAO,IAAIH,CAAkB,GACrCI,IAAQ,YACRC,UAAwBD,EAAMD,MAAU;AAQ9C,SAAgBG,EAAuB,GAAgB;CACrD,OAAOJ,EAAM,IAAIK,CAAE;AACrB;AAMA,SAAgBC,IAA4B;CAC1C,OAAON,EAAM,KAAK;AACpB;AAQA,eAAsBO,EAAsB,GAA0C;CACpF,EAAMN,KAASE,EAAQ,IAAI;CAE3B,IAAI;EACF,OAAO,MAAME,EAAG;CAClB,UAAU;EACR,EAAMJ,KAASE,EAAQ,IAAI;CAC7B;AACF;AAMA,SAAgBK,IAA8B;CAC5C,OAAOL,EAAQ,IAAI;AACrB"}
@@ -1,2 +1,2 @@
1
- const e=require("./storm-DCEsqViG.cjs");var t=class{ctx;name=`lifecycle`;installed=!1;phase={state:``,enteredAt:0};window={start:0,count:0};constructor(e){this.ctx=e}install(){this.installed||(this.installed=!0,this.ctx.once.lifecycle??={state:``,enteredAt:performance.now()},this.phase=this.ctx.once.lifecycle,document.addEventListener(`visibilitychange`,this.onVisibility),document.addEventListener(`freeze`,this.onFreeze),document.addEventListener(`resume`,this.onResume),addEventListener(`pageshow`,this.onPageShow),this.onVisibility())}uninstall(){this.installed=!1,document.removeEventListener(`visibilitychange`,this.onVisibility),document.removeEventListener(`freeze`,this.onFreeze),document.removeEventListener(`resume`,this.onResume),removeEventListener(`pageshow`,this.onPageShow)}onVisibility=()=>{this.transition(document.visibilityState===`hidden`?`hidden`:`visible`)};onFreeze=()=>{this.transition(`frozen`)};onResume=()=>{this.transition(`resumed`)};onPageShow=e=>{e.persisted&&this.transition(`restored`)};transition(t){if(!this.installed||t===this.phase.state)return;let n=performance.now(),r=this.phase.state,i=Math.max(0,n-this.phase.enteredAt);this.phase.state=t,this.phase.enteredAt=n;let{capturePolicy:a}=this.ctx.config;this.ctx.isActive?.()!==!1&&e.t(this.window,a.lifecyclePerWindow,this.ctx.diagnostics,`lifecycle events`,a.windowMs)&&this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a lifecycle event.`,()=>{this.ctx.logger.logEvent(`ui.lifecycle`,{"lifecycle.state":t,"lifecycle.previous_state":r,"lifecycle.duration_ms":i})})}};exports.LifecycleCapture=t;
2
- //# sourceMappingURL=lifecycle-C2z_d8OX.cjs.map
1
+ const e=require("./storm-CYi9Swpx.cjs");var t=class{ctx;name=`lifecycle`;installed=!1;phase={state:``,enteredAt:0};window={start:0,count:0};constructor(e){this.ctx=e}install(){this.installed||(this.installed=!0,this.ctx.once.lifecycle??={state:``,enteredAt:performance.now()},this.phase=this.ctx.once.lifecycle,document.addEventListener(`visibilitychange`,this.onVisibility),document.addEventListener(`freeze`,this.onFreeze),document.addEventListener(`resume`,this.onResume),addEventListener(`pageshow`,this.onPageShow),this.onVisibility())}uninstall(){this.installed=!1,document.removeEventListener(`visibilitychange`,this.onVisibility),document.removeEventListener(`freeze`,this.onFreeze),document.removeEventListener(`resume`,this.onResume),removeEventListener(`pageshow`,this.onPageShow)}onVisibility=()=>{this.transition(document.visibilityState===`hidden`?`hidden`:`visible`)};onFreeze=()=>{this.transition(`frozen`)};onResume=()=>{this.transition(`resumed`)};onPageShow=e=>{e.persisted&&this.transition(`restored`)};transition(t){if(!this.installed||t===this.phase.state)return;let n=performance.now(),r=this.phase.state,i=Math.max(0,n-this.phase.enteredAt);this.phase.state=t,this.phase.enteredAt=n;let{capturePolicy:a}=this.ctx.config;this.ctx.isActive?.()!==!1&&e.t(this.window,a.lifecyclePerWindow,this.ctx.diagnostics,`lifecycle events`,a.windowMs)&&this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a lifecycle event.`,()=>{this.ctx.logger.logEvent(`ui.lifecycle`,{"lifecycle.state":t,"lifecycle.previous_state":r,"lifecycle.duration_ms":i})})}};exports.LifecycleCapture=t;
2
+ //# sourceMappingURL=lifecycle-2EtUaRpo.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-C2z_d8OX.cjs","names":["allowInWindow","require_storm","LifecycleCapture","ctx","event","state","now","previous","duration","capturePolicy"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page states with the duration of the previous state. */\nexport class LifecycleCapture implements Capture {\n readonly name = \"lifecycle\";\n\n private installed = false;\n\n private phase: NonNullable<CaptureOnce[\"lifecycle\"]> = { state: \"\", enteredAt: 0 };\n\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Installs document and back-forward cache listeners. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n this.ctx.once.lifecycle ??= { state: \"\", enteredAt: performance.now() };\n this.phase = this.ctx.once.lifecycle;\n document.addEventListener(\"visibilitychange\", this.onVisibility);\n document.addEventListener(\"freeze\", this.onFreeze);\n document.addEventListener(\"resume\", this.onResume);\n addEventListener(\"pageshow\", this.onPageShow);\n this.onVisibility();\n }\n\n /** Removes all listeners. */\n uninstall(): void {\n this.installed = false;\n document.removeEventListener(\"visibilitychange\", this.onVisibility);\n document.removeEventListener(\"freeze\", this.onFreeze);\n document.removeEventListener(\"resume\", this.onResume);\n removeEventListener(\"pageshow\", this.onPageShow);\n }\n\n private readonly onVisibility = (): void => {\n this.transition(document.visibilityState === \"hidden\" ? \"hidden\" : \"visible\");\n };\n\n private readonly onFreeze = (): void => {\n this.transition(\"frozen\");\n };\n\n private readonly onResume = (): void => {\n this.transition(\"resumed\");\n };\n\n private readonly onPageShow = (event: PageTransitionEvent): void => {\n if (event.persisted) {\n this.transition(\"restored\");\n }\n };\n\n /** Updates the state even when its event exceeds the rate limit. */\n private transition(state: string): void {\n if (!this.installed || state === this.phase.state) {\n return;\n }\n\n const now = performance.now();\n const previous = this.phase.state;\n const duration = Math.max(0, now - this.phase.enteredAt);\n this.phase.state = state;\n this.phase.enteredAt = now;\n\n const { capturePolicy } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n capturePolicy.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a lifecycle event.\",\n () => {\n this.ctx.logger.logEvent(\"ui.lifecycle\", {\n \"lifecycle.state\": state,\n \"lifecycle.previous_state\": previous,\n \"lifecycle.duration_ms\": duration,\n });\n },\n );\n }\n}\n"],"mappings":"wCAIA,IAAaE,EAAb,KAAiD,CASlB,IAR7B,KAAgB,YAEhB,UAAoB,GAEpB,MAAuD,CAAE,MAAO,GAAI,UAAW,CAAE,EAEjF,OAAuC,CAAE,MAAO,EAAG,MAAO,CAAE,EAE5D,YAAY,EAAsC,CAArB,KAAA,IAAAC,CAAsB,CAGnD,SAAgB,CACV,KAAK,YAGT,KAAK,UAAY,GACjB,KAAK,IAAI,KAAK,YAAc,CAAE,MAAO,GAAI,UAAW,YAAY,IAAI,CAAE,EACtE,KAAK,MAAQ,KAAK,IAAI,KAAK,UAC3B,SAAS,iBAAiB,mBAAoB,KAAK,YAAY,EAC/D,SAAS,iBAAiB,SAAU,KAAK,QAAQ,EACjD,SAAS,iBAAiB,SAAU,KAAK,QAAQ,EACjD,iBAAiB,WAAY,KAAK,UAAU,EAC5C,KAAK,aAAa,EACpB,CAGA,WAAkB,CAChB,KAAK,UAAY,GACjB,SAAS,oBAAoB,mBAAoB,KAAK,YAAY,EAClE,SAAS,oBAAoB,SAAU,KAAK,QAAQ,EACpD,SAAS,oBAAoB,SAAU,KAAK,QAAQ,EACpD,oBAAoB,WAAY,KAAK,UAAU,CACjD,CAEA,iBAA4C,CAC1C,KAAK,WAAW,SAAS,kBAAoB,SAAW,SAAW,SAAS,CAC9E,EAEA,aAAwC,CACtC,KAAK,WAAW,QAAQ,CAC1B,EAEA,aAAwC,CACtC,KAAK,WAAW,SAAS,CAC3B,EAEA,WAA+B,GAAqC,CAC9DC,EAAM,WACR,KAAK,WAAW,UAAU,CAE9B,EAGA,WAAmB,EAAqB,CACtC,GAAI,CAAC,KAAK,WAAaC,IAAU,KAAK,MAAM,MAC1C,OAGF,IAAMC,EAAM,YAAY,IAAI,EACtBC,EAAW,KAAK,MAAM,MACtBC,EAAW,KAAK,IAAI,EAAGF,EAAM,KAAK,MAAM,SAAS,EACvD,KAAK,MAAM,MAAQD,EACnB,KAAK,MAAM,UAAYC,EAEvB,GAAM,CAAE,iBAAkB,KAAK,IAAI,OAEjC,KAAK,IAAI,WAAW,IAAM,IACzBN,EAAAA,EACC,KAAK,OACLS,EAAc,mBACd,KAAK,IAAI,YACT,mBACAA,EAAc,QAChB,GAKF,KAAK,IAAI,YAAY,MACnB,wBACA,sDACM,CACJ,KAAK,IAAI,OAAO,SAAS,eAAgB,CACvC,kBAAmBJ,EACnB,2BAA4BE,EAC5B,wBAAyBC,CAC3B,CAAC,CACH,CACF,CACF,CACF"}
1
+ {"version":3,"file":"lifecycle-2EtUaRpo.cjs","names":["allowInWindow","require_storm","LifecycleCapture","ctx","event","state","now","previous","duration","capturePolicy"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page states with the duration of the previous state. */\nexport class LifecycleCapture implements Capture {\n readonly name = \"lifecycle\";\n\n private installed = false;\n\n private phase: NonNullable<CaptureOnce[\"lifecycle\"]> = { state: \"\", enteredAt: 0 };\n\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Installs document and back-forward cache listeners. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n this.ctx.once.lifecycle ??= { state: \"\", enteredAt: performance.now() };\n this.phase = this.ctx.once.lifecycle;\n document.addEventListener(\"visibilitychange\", this.onVisibility);\n document.addEventListener(\"freeze\", this.onFreeze);\n document.addEventListener(\"resume\", this.onResume);\n addEventListener(\"pageshow\", this.onPageShow);\n this.onVisibility();\n }\n\n /** Removes all listeners. */\n uninstall(): void {\n this.installed = false;\n document.removeEventListener(\"visibilitychange\", this.onVisibility);\n document.removeEventListener(\"freeze\", this.onFreeze);\n document.removeEventListener(\"resume\", this.onResume);\n removeEventListener(\"pageshow\", this.onPageShow);\n }\n\n private readonly onVisibility = (): void => {\n this.transition(document.visibilityState === \"hidden\" ? \"hidden\" : \"visible\");\n };\n\n private readonly onFreeze = (): void => {\n this.transition(\"frozen\");\n };\n\n private readonly onResume = (): void => {\n this.transition(\"resumed\");\n };\n\n private readonly onPageShow = (event: PageTransitionEvent): void => {\n if (event.persisted) {\n this.transition(\"restored\");\n }\n };\n\n /** Updates the state even when its event exceeds the rate limit. */\n private transition(state: string): void {\n if (!this.installed || state === this.phase.state) {\n return;\n }\n\n const now = performance.now();\n const previous = this.phase.state;\n const duration = Math.max(0, now - this.phase.enteredAt);\n this.phase.state = state;\n this.phase.enteredAt = now;\n\n const { capturePolicy } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n capturePolicy.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a lifecycle event.\",\n () => {\n this.ctx.logger.logEvent(\"ui.lifecycle\", {\n \"lifecycle.state\": state,\n \"lifecycle.previous_state\": previous,\n \"lifecycle.duration_ms\": duration,\n });\n },\n );\n }\n}\n"],"mappings":"A,wCAIA,IAAaE,EAAb,KAAiD,CASlB,IAR7B,KAAgB,YAEhB,UAAoB,GAEpB,MAAuD,CAAE,MAAO,GAAI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AA,EAAc,QAChB,GAKF,KAAK,IAAI,YAAY,MACnB,wBACA,sDACM,CACJ,KAAK,IAAI,OAAO,SAAS,eAAgB,CACvC,kBAAmBJ,EACnB,2BAA4BE,EAC5B,wBAAyBC,CAC3B,CAAC,CACH,CACF,CACF,CACF,E"}
@@ -1,5 +1,5 @@
1
- import { t as e } from "./storm-DD4cUkoL.js";
2
- //#region src/capture/lifecycle.ts
1
+ import { t as e } from "./storm-VR024_QN.js";
2
+ // src/capture/lifecycle.ts
3
3
  var t = class {
4
4
  ctx;
5
5
  name = "lifecycle";
@@ -50,7 +50,6 @@ var t = class {
50
50
  });
51
51
  }
52
52
  };
53
- //#endregion
54
53
  export { t as LifecycleCapture };
55
54
 
56
- //# sourceMappingURL=lifecycle-BLC4VU7c.js.map
55
+ //# sourceMappingURL=lifecycle-BaKx_-32.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-BLC4VU7c.js","names":["allowInWindow","LifecycleCapture","ctx","event","state","now","previous","duration","capturePolicy"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page states with the duration of the previous state. */\nexport class LifecycleCapture implements Capture {\n readonly name = \"lifecycle\";\n\n private installed = false;\n\n private phase: NonNullable<CaptureOnce[\"lifecycle\"]> = { state: \"\", enteredAt: 0 };\n\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Installs document and back-forward cache listeners. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n this.ctx.once.lifecycle ??= { state: \"\", enteredAt: performance.now() };\n this.phase = this.ctx.once.lifecycle;\n document.addEventListener(\"visibilitychange\", this.onVisibility);\n document.addEventListener(\"freeze\", this.onFreeze);\n document.addEventListener(\"resume\", this.onResume);\n addEventListener(\"pageshow\", this.onPageShow);\n this.onVisibility();\n }\n\n /** Removes all listeners. */\n uninstall(): void {\n this.installed = false;\n document.removeEventListener(\"visibilitychange\", this.onVisibility);\n document.removeEventListener(\"freeze\", this.onFreeze);\n document.removeEventListener(\"resume\", this.onResume);\n removeEventListener(\"pageshow\", this.onPageShow);\n }\n\n private readonly onVisibility = (): void => {\n this.transition(document.visibilityState === \"hidden\" ? \"hidden\" : \"visible\");\n };\n\n private readonly onFreeze = (): void => {\n this.transition(\"frozen\");\n };\n\n private readonly onResume = (): void => {\n this.transition(\"resumed\");\n };\n\n private readonly onPageShow = (event: PageTransitionEvent): void => {\n if (event.persisted) {\n this.transition(\"restored\");\n }\n };\n\n /** Updates the state even when its event exceeds the rate limit. */\n private transition(state: string): void {\n if (!this.installed || state === this.phase.state) {\n return;\n }\n\n const now = performance.now();\n const previous = this.phase.state;\n const duration = Math.max(0, now - this.phase.enteredAt);\n this.phase.state = state;\n this.phase.enteredAt = now;\n\n const { capturePolicy } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n capturePolicy.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a lifecycle event.\",\n () => {\n this.ctx.logger.logEvent(\"ui.lifecycle\", {\n \"lifecycle.state\": state,\n \"lifecycle.previous_state\": previous,\n \"lifecycle.duration_ms\": duration,\n });\n },\n );\n }\n}\n"],"mappings":";;AAIA,IAAaC,IAAb,MAAiD;CASlB;CAR7B,OAAgB;CAEhB,YAAoB;CAEpB,QAAuD;EAAE,OAAO;EAAI,WAAW;CAAE;CAEjF,SAAuC;EAAE,OAAO;EAAG,OAAO;CAAE;CAE5D,YAAY,GAAsC;EAArB,KAAA,MAAAC;CAAsB;CAGnD,UAAgB;EACd,AAAI,KAAK,cAGT,KAAK,YAAY,IACjB,KAAK,IAAI,KAAK,cAAc;GAAE,OAAO;GAAI,WAAW,YAAY,IAAI;EAAE,GACtE,KA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-32.js","names":["allowInWindow","LifecycleCapture","ctx","event","state","now","previous","duration","capturePolicy"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page states with the duration of the previous state. */\nexport class LifecycleCapture implements Capture {\n readonly name = \"lifecycle\";\n\n private installed = false;\n\n private phase: NonNullable<CaptureOnce[\"lifecycle\"]> = { state: \"\", enteredAt: 0 };\n\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Installs document and back-forward cache listeners. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n this.ctx.once.lifecycle ??= { state: \"\", enteredAt: performance.now() };\n this.phase = this.ctx.once.lifecycle;\n document.addEventListener(\"visibilitychange\", this.onVisibility);\n document.addEventListener(\"freeze\", this.onFreeze);\n document.addEventListener(\"resume\", this.onResume);\n addEventListener(\"pageshow\", this.onPageShow);\n this.onVisibility();\n }\n\n /** Removes all listeners. */\n uninstall(): void {\n this.installed = false;\n document.removeEventListener(\"visibilitychange\", this.onVisibility);\n document.removeEventListener(\"freeze\", this.onFreeze);\n document.removeEventListener(\"resume\", this.onResume);\n removeEventListener(\"pageshow\", this.onPageShow);\n }\n\n private readonly onVisibility = (): void => {\n this.transition(document.visibilityState === \"hidden\" ? \"hidden\" : \"visible\");\n };\n\n private readonly onFreeze = (): void => {\n this.transition(\"frozen\");\n };\n\n private readonly onResume = (): void => {\n this.transition(\"resumed\");\n };\n\n private readonly onPageShow = (event: PageTransitionEvent): void => {\n if (event.persisted) {\n this.transition(\"restored\");\n }\n };\n\n /** Updates the state even when its event exceeds the rate limit. */\n private transition(state: string): void {\n if (!this.installed || state === this.phase.state) {\n return;\n }\n\n const now = performance.now();\n const previous = this.phase.state;\n const duration = Math.max(0, now - this.phase.enteredAt);\n this.phase.state = state;\n this.phase.enteredAt = now;\n\n const { capturePolicy } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n capturePolicy.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a lifecycle event.\",\n () => {\n this.ctx.logger.logEvent(\"ui.lifecycle\", {\n \"lifecycle.state\": state,\n \"lifecycle.previous_state\": previous,\n \"lifecycle.duration_ms\": duration,\n });\n },\n );\n }\n}\n"],"mappings":";;AAIA,IAAaC,IAAb,MAAiD;CASlB;CAR7B,OAAgB;CAEhB,YAAoB;CAEpB,QAAuD;EAAE,OAAO;EAAI,WAAW;CAAE;CAEjF,SAAuC;EAAE,OAAO;EAAG,OAAO;CAAE;CAE5D,YAAY,GAAsC;EAArB,KAAA,MAAAC;CAAsB;CAGnD,UAAgB;EACd,AAAI,KAAK,cAGT,KAAK,YAAY,IACjB,KAAK,IAAI,KAAK,cAAc;GAAE,OAAO;GAAI,WAAW,YAAY,IAAI;EAAE,GACtE,KAAK,QAAQ,KAAK,IAAI,KAAK,WAC3B,SAAS,iBAAiB,oBAAoB,KAAK,YAAY,GAC/D,SAAS,iBAAiB,UAAU,KAAK,QAAQ,GACjD,SAAS,iBAAiB,UAAU,KAAK,QAAQ,GACjD,iBAAiB,YAAY,KAAK,UAAU,GAC5C,KAAK,aAAa;CACpB;CAGA,YAAkB;EAKhB,AAJA,KAAK,YAAY,IACjB,SAAS,oBAAoB,oBAAoB,KAAK,YAAY,GAClE,SAAS,oBAAoB,UAAU,KAAK,QAAQ,GACpD,SAAS,oBAAoB,UAAU,KAAK,QAAQ,GACpD,oBAAoB,YAAY,KAAK,UAAU;CACjD;CAEA,qBAA4C;EAC1C,KAAK,WAAW,SAAS,oBAAoB,WAAW,WAAW,SAAS;CAC9E;CAEA,iBAAwC;EACtC,KAAK,WAAW,QAAQ;CAC1B;CAEA,iBAAwC;EACtC,KAAK,WAAW,SAAS;CAC3B;CAEA,cAA+B,MAAqC;EAClE,AAAIC,EAAM,aACR,KAAK,WAAW,UAAU;CAE9B;CAGA,WAAmB,GAAqB;EACtC,IAAI,CAAC,KAAK,aAAaC,MAAU,KAAK,MAAM,OAC1C;EAGF,IAAMC,IAAM,YAAY,IAAI,GACtBC,IAAW,KAAK,MAAM,OACtBC,IAAW,KAAK,IAAI,GAAGF,IAAM,KAAK,MAAM,SAAS;EAEvD,AADA,KAAK,MAAM,QAAQD,GACnB,KAAK,MAAM,YAAYC;EAEvB,IAAM,EAAE,qBAAkB,KAAK,IAAI;EACnC,AACE,KAAK,IAAI,WAAW,MAAM,MACzBL,EACC,KAAK,QACLQ,EAAc,oBACd,KAAK,IAAI,aACT,oBACAA,EAAc,QAChB,KAKF,KAAK,IAAI,YAAY,MACnB,yBACA,yDACM;GACJ,KAAK,IAAI,OAAO,SAAS,gBAAgB;IACvC,mBAAmBJ;IACnB,4BAA4BE;IAC5B,yBAAyBC;GAC3B,CAAC;EACH,CACF;CACF;AACF"}
@@ -1,5 +1,5 @@
1
- import { wt as e } from "./constants-CU60FG4w.js";
2
- //#region src/models/log-record.ts
1
+ import { wt as e } from "./constants-zyrqveN4.js";
2
+ // src/models/log-record.ts
3
3
  function t() {
4
4
  return `${String(Date.now())}000000`;
5
5
  }
@@ -11,7 +11,6 @@ function r(e) {
11
11
  let t = e;
12
12
  return typeof t.body == "string" && typeof t.severityText == "string" && typeof t.timeUnixNano == "string" && typeof t.attributes == "object" && t.attributes !== null && typeof t.resource == "object" && t.resource !== null;
13
13
  }
14
- //#endregion
15
14
  export { r as n, t as r, n as t };
16
15
 
17
- //# sourceMappingURL=log-record-CndanC-p.js.map
16
+ //# sourceMappingURL=log-record-CAoGBBf3.js.map