@utk09/ui-observability 1.0.0 → 1.2.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 (298) hide show
  1. package/CHANGELOG.md +111 -219
  2. package/README.md +24 -26
  3. package/dist/{batch-CXmPmTse.js → batch-120Kc9jr.js} +3 -3
  4. package/dist/{batch-CXmPmTse.js.map → batch-120Kc9jr.js.map} +1 -1
  5. package/dist/{batch-mmPigCpi.cjs → batch-C3uNp5kU.cjs} +2 -2
  6. package/dist/{batch-mmPigCpi.cjs.map → batch-C3uNp5kU.cjs.map} +1 -1
  7. package/dist/bus/bus.d.cts +31 -2
  8. package/dist/bus/bus.d.ts +31 -2
  9. package/dist/bus-Dj8IEVcC.cjs +2 -0
  10. package/dist/bus-Dj8IEVcC.cjs.map +1 -0
  11. package/dist/{bus-C39wspFV.js → bus-DyNafxZN.js} +127 -104
  12. package/dist/bus-DyNafxZN.js.map +1 -0
  13. package/dist/capture/errors.d.cts +10 -0
  14. package/dist/capture/errors.d.ts +10 -0
  15. package/dist/capture/interactions.d.cts +35 -3
  16. package/dist/capture/interactions.d.ts +35 -3
  17. package/dist/capture/observed-windows.d.cts +51 -0
  18. package/dist/capture/observed-windows.d.ts +51 -0
  19. package/dist/capture/replay.d.cts +1 -1
  20. package/dist/capture/replay.d.ts +1 -1
  21. package/dist/capture/types.d.cts +5 -0
  22. package/dist/capture/types.d.ts +5 -0
  23. package/dist/capture/web-vitals.d.cts +1 -0
  24. package/dist/capture/web-vitals.d.ts +1 -0
  25. package/dist/{compression-tVtXwVjX.js → compression-BWkDWY3v.js} +2 -2
  26. package/dist/{compression-tVtXwVjX.js.map → compression-BWkDWY3v.js.map} +1 -1
  27. package/dist/{compression-CvED_Jel.cjs → compression-CEVe7NPX.cjs} +2 -2
  28. package/dist/{compression-CvED_Jel.cjs.map → compression-CEVe7NPX.cjs.map} +1 -1
  29. package/dist/config-C0PtemvC.cjs +2 -0
  30. package/dist/config-C0PtemvC.cjs.map +1 -0
  31. package/dist/config-DK1Zf7jn.js +556 -0
  32. package/dist/config-DK1Zf7jn.js.map +1 -0
  33. package/dist/{console-BGgGnjSi.js → console-CAyCQOpm.js} +5 -5
  34. package/dist/{console-BGgGnjSi.js.map → console-CAyCQOpm.js.map} +1 -1
  35. package/dist/{console-CSZ5_Vx5.cjs → console-Dk6GH4yj.cjs} +2 -2
  36. package/dist/{console-CSZ5_Vx5.cjs.map → console-Dk6GH4yj.cjs.map} +1 -1
  37. package/dist/{constants-CUyd9cTZ.js → constants-CEHN6KuY.js} +46 -25
  38. package/dist/constants-CEHN6KuY.js.map +1 -0
  39. package/dist/constants-NtiQDWL_.cjs +2 -0
  40. package/dist/constants-NtiQDWL_.cjs.map +1 -0
  41. package/dist/constants.d.cts +23 -0
  42. package/dist/constants.d.ts +23 -0
  43. package/dist/core/config.d.cts +9 -3
  44. package/dist/core/config.d.ts +9 -3
  45. package/dist/core/diagnostics.d.cts +1 -1
  46. package/dist/core/diagnostics.d.ts +1 -1
  47. package/dist/core/pipeline.d.cts +11 -0
  48. package/dist/core/pipeline.d.ts +11 -0
  49. package/dist/core/record.d.cts +2 -2
  50. package/dist/core/record.d.ts +2 -2
  51. package/dist/core/rotation.d.cts +26 -2
  52. package/dist/core/rotation.d.ts +26 -2
  53. package/dist/core/runtime.d.cts +9 -0
  54. package/dist/core/runtime.d.ts +9 -0
  55. package/dist/core/sender.d.cts +3 -2
  56. package/dist/core/sender.d.ts +3 -2
  57. package/dist/{debug-bundle-BXIlwDKM.cjs → debug-bundle-DMzUfiQc.cjs} +2 -2
  58. package/dist/{debug-bundle-BXIlwDKM.cjs.map → debug-bundle-DMzUfiQc.cjs.map} +1 -1
  59. package/dist/{debug-bundle-CRpYV_ui.js → debug-bundle-w78W46zr.js} +4 -4
  60. package/dist/{debug-bundle-CRpYV_ui.js.map → debug-bundle-w78W46zr.js.map} +1 -1
  61. package/dist/doctor.cjs +1 -1
  62. package/dist/doctor.js +36 -36
  63. package/dist/doctor.js.map +1 -1
  64. package/dist/errors-07pmZ7VY.cjs +3 -0
  65. package/dist/errors-07pmZ7VY.cjs.map +1 -0
  66. package/dist/{errors-BE_EZV7Q.js → errors-C-LYbqyB.js} +27 -24
  67. package/dist/errors-C-LYbqyB.js.map +1 -0
  68. package/dist/{factory-CTi0Is3F.js → factory-BHYrcSaU.js} +39 -28
  69. package/dist/factory-BHYrcSaU.js.map +1 -0
  70. package/dist/factory-DsaNdcXp.cjs +2 -0
  71. package/dist/factory-DsaNdcXp.cjs.map +1 -0
  72. package/dist/{identity-DdhKgrpk.js → identity-Byh3gCdT.js} +35 -24
  73. package/dist/identity-Byh3gCdT.js.map +1 -0
  74. package/dist/identity-BzAzdQyv.cjs +2 -0
  75. package/dist/identity-BzAzdQyv.cjs.map +1 -0
  76. package/dist/index.cjs +1 -1
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +1 -0
  79. package/dist/index.d.ts +1 -0
  80. package/dist/index.js +453 -417
  81. package/dist/index.js.map +1 -1
  82. package/dist/{indexeddb-storage-GHdl0t8A.js → indexeddb-storage-BYywz-v6.js} +17 -17
  83. package/dist/{indexeddb-storage-GHdl0t8A.js.map → indexeddb-storage-BYywz-v6.js.map} +1 -1
  84. package/dist/{indexeddb-storage-CL9uqBCy.cjs → indexeddb-storage-BfqGkLFe.cjs} +2 -2
  85. package/dist/{indexeddb-storage-CL9uqBCy.cjs.map → indexeddb-storage-BfqGkLFe.cjs.map} +1 -1
  86. package/dist/interactions-BXzEel4F.cjs +2 -0
  87. package/dist/interactions-BXzEel4F.cjs.map +1 -0
  88. package/dist/interactions-DdKPMWIN.js +207 -0
  89. package/dist/interactions-DdKPMWIN.js.map +1 -0
  90. package/dist/{journey-B4Adltjm.cjs → journey-BUmsrgaw.cjs} +2 -2
  91. package/dist/{journey-B4Adltjm.cjs.map → journey-BUmsrgaw.cjs.map} +1 -1
  92. package/dist/{journey-D2_sia57.js → journey-Nu655gEO.js} +14 -14
  93. package/dist/{journey-D2_sia57.js.map → journey-Nu655gEO.js.map} +1 -1
  94. package/dist/{library-console-CPW6bvZH.cjs → library-console-DdIlzzph.cjs} +2 -2
  95. package/dist/{library-console-CPW6bvZH.cjs.map → library-console-DdIlzzph.cjs.map} +1 -1
  96. package/dist/{library-console-Btrzt814.js → library-console-amePMnP8.js} +2 -2
  97. package/dist/{library-console-Btrzt814.js.map → library-console-amePMnP8.js.map} +1 -1
  98. package/dist/{library-request-BJ9PLRaD.js → library-request-Cv7C05jf.js} +2 -2
  99. package/dist/{library-request-BJ9PLRaD.js.map → library-request-Cv7C05jf.js.map} +1 -1
  100. package/dist/{library-request-D7OvTxZV.cjs → library-request-DO3Ec7KE.cjs} +2 -2
  101. package/dist/{library-request-D7OvTxZV.cjs.map → library-request-DO3Ec7KE.cjs.map} +1 -1
  102. package/dist/{lifecycle-IaAm1mOC.cjs → lifecycle-B5yfH5is.cjs} +2 -2
  103. package/dist/{lifecycle-IaAm1mOC.cjs.map → lifecycle-B5yfH5is.cjs.map} +1 -1
  104. package/dist/{lifecycle-22CUCrc9.js → lifecycle-CMHz2Zbs.js} +2 -2
  105. package/dist/{lifecycle-22CUCrc9.js.map → lifecycle-CMHz2Zbs.js.map} +1 -1
  106. package/dist/{log-record-BNiLfqtL.js → log-record-B_nSqxoe.js} +2 -2
  107. package/dist/{log-record-BNiLfqtL.js.map → log-record-B_nSqxoe.js.map} +1 -1
  108. package/dist/{log-record-CkivuiEl.cjs → log-record-Bdywwg0k.cjs} +2 -2
  109. package/dist/{log-record-CkivuiEl.cjs.map → log-record-Bdywwg0k.cjs.map} +1 -1
  110. package/dist/{long-frames-DNFaRnC3.js → long-frames-6NGl1-uN.js} +3 -3
  111. package/dist/{long-frames-DNFaRnC3.js.map → long-frames-6NGl1-uN.js.map} +1 -1
  112. package/dist/{long-frames-BUUbXd-B.cjs → long-frames-D9DfSWqv.cjs} +2 -2
  113. package/dist/{long-frames-BUUbXd-B.cjs.map → long-frames-D9DfSWqv.cjs.map} +1 -1
  114. package/dist/models/bus.d.cts +6 -1
  115. package/dist/models/bus.d.ts +6 -1
  116. package/dist/models/config.d.cts +27 -11
  117. package/dist/models/config.d.ts +27 -11
  118. package/dist/models/serializer.d.cts +3 -1
  119. package/dist/models/serializer.d.ts +3 -1
  120. package/dist/{network-CGMLQ-mA.cjs → network-BNHBI0Fc.cjs} +2 -2
  121. package/dist/{network-CGMLQ-mA.cjs.map → network-BNHBI0Fc.cjs.map} +1 -1
  122. package/dist/{network-on2zZT6H.js → network-Cc3tSB7e.js} +5 -5
  123. package/dist/{network-on2zZT6H.js.map → network-Cc3tSB7e.js.map} +1 -1
  124. package/dist/observed-windows-8JtCsIr1.js +64 -0
  125. package/dist/observed-windows-8JtCsIr1.js.map +1 -0
  126. package/dist/observed-windows-BlE25nrn.cjs +2 -0
  127. package/dist/observed-windows-BlE25nrn.cjs.map +1 -0
  128. package/dist/openfin-Bxelt0yg.js.map +1 -1
  129. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  130. package/dist/{otlp-DimfrRor.js → otlp-Btix3EBa.js} +7 -7
  131. package/dist/{otlp-DimfrRor.js.map → otlp-Btix3EBa.js.map} +1 -1
  132. package/dist/{otlp-BENHf3g9.cjs → otlp-CFSW-Dno.cjs} +2 -2
  133. package/dist/{otlp-BENHf3g9.cjs.map → otlp-CFSW-Dno.cjs.map} +1 -1
  134. package/dist/patch-DlcKzIi-.cjs +2 -0
  135. package/dist/patch-DlcKzIi-.cjs.map +1 -0
  136. package/dist/patch-Sr1wKg7W.js +9 -0
  137. package/dist/patch-Sr1wKg7W.js.map +1 -0
  138. package/dist/platform-BZjp9wp1.cjs +2 -0
  139. package/dist/platform-BZjp9wp1.cjs.map +1 -0
  140. package/dist/platform-Dba6R3Hp.js +75 -0
  141. package/dist/platform-Dba6R3Hp.js.map +1 -0
  142. package/dist/{profiler-BAZoh7A4.js → profiler-DNKcqu09.js} +60 -60
  143. package/dist/{profiler-BAZoh7A4.js.map → profiler-DNKcqu09.js.map} +1 -1
  144. package/dist/{profiler-D4tJpDRc.cjs → profiler-DpoPi1hH.cjs} +2 -2
  145. package/dist/{profiler-D4tJpDRc.cjs.map → profiler-DpoPi1hH.cjs.map} +1 -1
  146. package/dist/{profiler-frames-C4xr7KfH.cjs → profiler-frames-C9zJNd8_.cjs} +2 -2
  147. package/dist/{profiler-frames-C4xr7KfH.cjs.map → profiler-frames-C9zJNd8_.cjs.map} +1 -1
  148. package/dist/{profiler-frames-cJMx9wNM.js → profiler-frames-CGXZeZ_3.js} +16 -16
  149. package/dist/{profiler-frames-cJMx9wNM.js.map → profiler-frames-CGXZeZ_3.js.map} +1 -1
  150. package/dist/{remote-rules-Dz9MRAsB.js → remote-rules-DNK96vLa.js} +25 -25
  151. package/dist/{remote-rules-Dz9MRAsB.js.map → remote-rules-DNK96vLa.js.map} +1 -1
  152. package/dist/{remote-rules-_tY0zj5o.cjs → remote-rules-DuMFRlit.cjs} +2 -2
  153. package/dist/{remote-rules-_tY0zj5o.cjs.map → remote-rules-DuMFRlit.cjs.map} +1 -1
  154. package/dist/replay-Cab-lSit.cjs +2 -0
  155. package/dist/replay-Cab-lSit.cjs.map +1 -0
  156. package/dist/{replay-Ds-ANH34.js → replay-Dy6OiaOZ.js} +104 -77
  157. package/dist/replay-Dy6OiaOZ.js.map +1 -0
  158. package/dist/{reports-BDSe4dFH.cjs → reports-CGK9YQch.cjs} +2 -2
  159. package/dist/{reports-BDSe4dFH.cjs.map → reports-CGK9YQch.cjs.map} +1 -1
  160. package/dist/{reports-C-thq-bk.js → reports-CX57-S9s.js} +3 -3
  161. package/dist/{reports-C-thq-bk.js.map → reports-CX57-S9s.js.map} +1 -1
  162. package/dist/{resource-timing-eUl2dNgC.js → resource-timing-CWVDCbrY.js} +4 -4
  163. package/dist/{resource-timing-eUl2dNgC.js.map → resource-timing-CWVDCbrY.js.map} +1 -1
  164. package/dist/{resource-timing-C576gFIQ.cjs → resource-timing-DalulXiR.cjs} +2 -2
  165. package/dist/{resource-timing-C576gFIQ.cjs.map → resource-timing-DalulXiR.cjs.map} +1 -1
  166. package/dist/response-body-Cpz5__4g.cjs +3 -0
  167. package/dist/response-body-Cpz5__4g.cjs.map +1 -0
  168. package/dist/{response-body-eoSQpLiH.js → response-body-yi92Rpvo.js} +109 -109
  169. package/dist/response-body-yi92Rpvo.js.map +1 -0
  170. package/dist/{rotation-Cwct4ckk.js → rotation-ChBbNDE2.js} +27 -28
  171. package/dist/rotation-ChBbNDE2.js.map +1 -0
  172. package/dist/rotation-fTnNJcfH.cjs +2 -0
  173. package/dist/rotation-fTnNJcfH.cjs.map +1 -0
  174. package/dist/{sampling-BlrI8jor.js → sampling-DZTOD28D.js} +16 -16
  175. package/dist/{sampling-BlrI8jor.js.map → sampling-DZTOD28D.js.map} +1 -1
  176. package/dist/{sampling-mXt4dstx.cjs → sampling-wAVJIZXp.cjs} +2 -2
  177. package/dist/{sampling-mXt4dstx.cjs.map → sampling-wAVJIZXp.cjs.map} +1 -1
  178. package/dist/{sanitize-Ba0KqU06.js → sanitize-B2GKlSFp.js} +2 -2
  179. package/dist/{sanitize-Ba0KqU06.js.map → sanitize-B2GKlSFp.js.map} +1 -1
  180. package/dist/{sanitize-DQyiI_KY.cjs → sanitize-BZdhoghq.cjs} +2 -2
  181. package/dist/{sanitize-DQyiI_KY.cjs.map → sanitize-BZdhoghq.cjs.map} +1 -1
  182. package/dist/{sender-Dv8rAmpV.js → sender-BRSpc7R8.js} +192 -178
  183. package/dist/sender-BRSpc7R8.js.map +1 -0
  184. package/dist/sender-CFu98DAB.cjs +2 -0
  185. package/dist/sender-CFu98DAB.cjs.map +1 -0
  186. package/dist/storage/emergency-queue.d.cts +3 -1
  187. package/dist/storage/emergency-queue.d.ts +3 -1
  188. package/dist/storage/stored-context.d.cts +3 -2
  189. package/dist/storage/stored-context.d.ts +3 -2
  190. package/dist/stored-context-CPLlzgpm.cjs +2 -0
  191. package/dist/stored-context-CPLlzgpm.cjs.map +1 -0
  192. package/dist/{stored-context-B2EzVuYm.js → stored-context-df1dEnht.js} +12 -10
  193. package/dist/stored-context-df1dEnht.js.map +1 -0
  194. package/dist/{storm-DjKetLKZ.js → storm-U3_ek1nA.js} +2 -2
  195. package/dist/{storm-DjKetLKZ.js.map → storm-U3_ek1nA.js.map} +1 -1
  196. package/dist/{storm-C-zYSdDX.cjs → storm-qiE_AMC7.cjs} +2 -2
  197. package/dist/{storm-C-zYSdDX.cjs.map → storm-qiE_AMC7.cjs.map} +1 -1
  198. package/dist/transport/exit-flush.d.cts +23 -0
  199. package/dist/transport/exit-flush.d.ts +23 -0
  200. package/dist/transport/http-transport.d.cts +3 -2
  201. package/dist/transport/http-transport.d.ts +3 -2
  202. package/dist/transport/retry-engine.d.cts +11 -3
  203. package/dist/transport/retry-engine.d.ts +11 -3
  204. package/dist/types-BAerHgCq.js.map +1 -1
  205. package/dist/types-C7WNpnG1.cjs.map +1 -1
  206. package/dist/{unclean-exit-DQD1cT7c.js → unclean-exit-Bj6gYHeL.js} +2 -2
  207. package/dist/{unclean-exit-DQD1cT7c.js.map → unclean-exit-Bj6gYHeL.js.map} +1 -1
  208. package/dist/{unclean-exit-py99ApzT.cjs → unclean-exit-CuBh-ee5.cjs} +2 -2
  209. package/dist/{unclean-exit-py99ApzT.cjs.map → unclean-exit-CuBh-ee5.cjs.map} +1 -1
  210. package/dist/{user-timing-D6XTmpuM.cjs → user-timing-BWqzYF2Q.cjs} +2 -2
  211. package/dist/{user-timing-D6XTmpuM.cjs.map → user-timing-BWqzYF2Q.cjs.map} +1 -1
  212. package/dist/{user-timing-BePqb1uN.js → user-timing-Duz0d-OA.js} +2 -2
  213. package/dist/{user-timing-BePqb1uN.js.map → user-timing-Duz0d-OA.js.map} +1 -1
  214. package/dist/utils/identity.d.cts +5 -0
  215. package/dist/utils/identity.d.ts +5 -0
  216. package/dist/utils/lock.d.cts +3 -2
  217. package/dist/utils/lock.d.ts +3 -2
  218. package/dist/utils/openfin.d.cts +18 -6
  219. package/dist/utils/openfin.d.ts +18 -6
  220. package/dist/utils/patch.d.cts +1 -1
  221. package/dist/utils/patch.d.ts +1 -1
  222. package/dist/utils/platform.d.cts +6 -0
  223. package/dist/utils/platform.d.ts +6 -0
  224. package/dist/{web-socket-DSHgDiZ6.js → web-socket-CE_9Q22z.js} +5 -5
  225. package/dist/{web-socket-DSHgDiZ6.js.map → web-socket-CE_9Q22z.js.map} +1 -1
  226. package/dist/{web-socket-CoIUBM3C.cjs → web-socket-sm3rD-A_.cjs} +2 -2
  227. package/dist/{web-socket-CoIUBM3C.cjs.map → web-socket-sm3rD-A_.cjs.map} +1 -1
  228. package/dist/{web-vitals-4pWACwaR.js → web-vitals-CGwXGF-M.js} +4 -4
  229. package/dist/web-vitals-CGwXGF-M.js.map +1 -0
  230. package/dist/web-vitals-Df4Wsfx9.cjs +2 -0
  231. package/dist/web-vitals-Df4Wsfx9.cjs.map +1 -0
  232. package/dist/{worker-protocol-QbvqNazn.cjs → worker-protocol-D5VnCdWY.cjs} +2 -2
  233. package/dist/{worker-protocol-QbvqNazn.cjs.map → worker-protocol-D5VnCdWY.cjs.map} +1 -1
  234. package/dist/{worker-protocol-x074Rpet.js → worker-protocol-h4-tRWqy.js} +6 -6
  235. package/dist/{worker-protocol-x074Rpet.js.map → worker-protocol-h4-tRWqy.js.map} +1 -1
  236. package/dist/{worker-server-CFe4nvos.cjs → worker-server-CF1yatXq.cjs} +2 -2
  237. package/dist/{worker-server-CFe4nvos.cjs.map → worker-server-CF1yatXq.cjs.map} +1 -1
  238. package/dist/worker-server-FYfKHQhJ.js +94 -0
  239. package/dist/{worker-server-iUVSjH8L.js.map → worker-server-FYfKHQhJ.js.map} +1 -1
  240. package/dist/worker-transport-COgY4RX8.cjs +2 -0
  241. package/dist/worker-transport-COgY4RX8.cjs.map +1 -0
  242. package/dist/{worker-transport-Dy1KMA7t.js → worker-transport-jzX1IusG.js} +49 -45
  243. package/dist/worker-transport-jzX1IusG.js.map +1 -0
  244. package/llms.txt +14 -12
  245. package/package.json +13 -5
  246. package/dist/bus-C39wspFV.js.map +0 -1
  247. package/dist/bus-_EaOVPGq.cjs +0 -2
  248. package/dist/bus-_EaOVPGq.cjs.map +0 -1
  249. package/dist/config-DUs7uHHt.cjs +0 -2
  250. package/dist/config-DUs7uHHt.cjs.map +0 -1
  251. package/dist/config-SgQcCP1_.js +0 -560
  252. package/dist/config-SgQcCP1_.js.map +0 -1
  253. package/dist/constants-CUyd9cTZ.js.map +0 -1
  254. package/dist/constants-CqdJhTxH.cjs +0 -2
  255. package/dist/constants-CqdJhTxH.cjs.map +0 -1
  256. package/dist/errors-BE_EZV7Q.js.map +0 -1
  257. package/dist/errors-CNPbesMs.cjs +0 -3
  258. package/dist/errors-CNPbesMs.cjs.map +0 -1
  259. package/dist/factory-CTi0Is3F.js.map +0 -1
  260. package/dist/factory-hRrH32v5.cjs +0 -2
  261. package/dist/factory-hRrH32v5.cjs.map +0 -1
  262. package/dist/identity-DdhKgrpk.js.map +0 -1
  263. package/dist/identity-DlWRIuwy.cjs +0 -2
  264. package/dist/identity-DlWRIuwy.cjs.map +0 -1
  265. package/dist/interactions-CUkzK8sR.cjs +0 -2
  266. package/dist/interactions-CUkzK8sR.cjs.map +0 -1
  267. package/dist/interactions-DiFvCosX.js +0 -111
  268. package/dist/interactions-DiFvCosX.js.map +0 -1
  269. package/dist/patch-BX8KrPCT.cjs +0 -2
  270. package/dist/patch-BX8KrPCT.cjs.map +0 -1
  271. package/dist/patch-UdPz1ea8.js +0 -8
  272. package/dist/patch-UdPz1ea8.js.map +0 -1
  273. package/dist/platform-BaaFIPCU.js +0 -62
  274. package/dist/platform-BaaFIPCU.js.map +0 -1
  275. package/dist/platform-CfA3-7sJ.cjs +0 -2
  276. package/dist/platform-CfA3-7sJ.cjs.map +0 -1
  277. package/dist/replay-B3gFXIZd.cjs +0 -2
  278. package/dist/replay-B3gFXIZd.cjs.map +0 -1
  279. package/dist/replay-Ds-ANH34.js.map +0 -1
  280. package/dist/response-body-YdNl-HkR.cjs +0 -3
  281. package/dist/response-body-YdNl-HkR.cjs.map +0 -1
  282. package/dist/response-body-eoSQpLiH.js.map +0 -1
  283. package/dist/rotation-Cwct4ckk.js.map +0 -1
  284. package/dist/rotation-D4qUAHAu.cjs +0 -2
  285. package/dist/rotation-D4qUAHAu.cjs.map +0 -1
  286. package/dist/sender-BdRuNVhF.cjs +0 -2
  287. package/dist/sender-BdRuNVhF.cjs.map +0 -1
  288. package/dist/sender-Dv8rAmpV.js.map +0 -1
  289. package/dist/stored-context-B2EzVuYm.js.map +0 -1
  290. package/dist/stored-context-CXt7eHZL.cjs +0 -2
  291. package/dist/stored-context-CXt7eHZL.cjs.map +0 -1
  292. package/dist/web-vitals-4pWACwaR.js.map +0 -1
  293. package/dist/web-vitals-__X7t4pj.cjs +0 -2
  294. package/dist/web-vitals-__X7t4pj.cjs.map +0 -1
  295. package/dist/worker-server-iUVSjH8L.js +0 -94
  296. package/dist/worker-transport-CRAX-09c.cjs +0 -2
  297. package/dist/worker-transport-CRAX-09c.cjs.map +0 -1
  298. package/dist/worker-transport-Dy1KMA7t.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"journey-D2_sia57.js","names":["BASE64_PADDING_PATTERN","JOURNEY_URL_PARAM","JOURNEY_STORAGE_KEY","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","OPENFIN_OPTIONS_TIMEOUT_MS","BASE64URL_UNDERSCORE_PATTERN","BASE64_SLASH_PATTERN","JOURNEY_MAX_AGE_MS","BASE64_PLUS_PATTERN","JOURNEY_ID_PATTERN","BASE64URL_DASH_PATTERN","withDeadline","newId","BROWSER_STORES","getFin","unrefTimer","_defineProperty","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// Manages a user journey's lifecycle across windows: encodes tokens, stores the journey and\n// ends it at expiry. Never trust a value from storage or a token, because any code on the\n// 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, which is one user task spanning several contexts. */\nexport interface JourneyOptions {\n /** Maximum time a journey stays open, in milliseconds. After that 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/** The journey lifetime policy in effect. 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 /** Human-readable name of the journey's workflow. */\n name: string;\n /** Journey start timestamp in epoch milliseconds. */\n startedAt: number;\n /** Parent journey ID, set when the journey branches from an earlier one. */\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 another realm's bus message.\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 a 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 // We always write a start time. A token without one, or with one from the future, would\n // never expire.\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, which throws above U+00FF.\n // Without this step, a name in a non-Latin script would fail.\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. Keeps an active journey. Otherwise checks the URL\n * query first, then sessionStorage, then OpenFin customData.\n * @returns Promise that resolves when journey initialization completes.\n */\n async bootstrap(): Promise<void> {\n const fromUrl = this.readUrlToken();\n // A journey that the app started before configure() wins, and it moves to the stores that\n // configure() chose. Otherwise a stored journey from an earlier page would replace it. The\n // token still leaves the address bar, or a copied link would carry it to another session.\n if (this.journey) {\n if (fromUrl) {\n this.removeUrlToken();\n }\n this.setJourney(this.journey);\n return;\n }\n\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, replacing the active one and telling 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 * Picks the id for a new journey. A longer id, or one with multibyte characters, would make\n * the 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, otherwise 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 without broadcasting it again. An echo would\n * make two windows send the change back and forth forever. A journey with the same ID as\n * the active one is ignored, so an echo can't 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 null when no journey is active or the token exceeds the size\n * limit.\n */\n getToken(): string | null {\n const journey = this.journey;\n if (journey === null) {\n return null;\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 null;\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, and every step throws on bad input. The guard reports the failure\n * instead of letting it throw.\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 once the engine has adopted it.\n * Otherwise a copied or bookmarked link would start 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, because 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 customData in the OpenFin window options. The wait is\n * capped by OPENFIN_OPTIONS_TIMEOUT_MS. At the deadline we report openfin.unavailable and\n * return no token. A window with no token gives the same result.\n * @returns Promise that resolves to the 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 so the native OpenFin method keeps its receiver. A detached copy throws when\n // 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,IAAaiB,IAAkC;CAC7C,UAAUV;CACV,iBAAA;CACA,UAAUN;AACZ;AAsBA,SAASiB,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,KAAU,aAAYA,GAC/B,OAAO;CAET,IAAMK,IAAKN,EAAWC,GAAO,GAAG,GAC1BM,IAAOP,EAAWC,GAAO,GAAG,GAC5BO,IAAYJ,EAAWH,GAAO,GAAG,GAGjCS,IAASF,MAAc,KAAA,KAAaA,IAAY,KAAK,IAAI,IAAA;CAI/D,OAHIF,MAAO,KAAA,KAAaC,MAAS,KAAA,KAAaC,MAAc,KAAA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QA,MAAc,mBAA2C;EACvD,IAAMC,IAAK7C,EAAO,CAAC,EAAE,IACf8C,IAAaD,GAAI;EACvB,IAAIC,MAAe,KAAA,GACjB,OAAO;EAUT,IAAMb,KAAQ,MALQ,KAAK,YAAY,WACrC,uBACA,yDACMpC,EAAaiD,EAAW,KAAKD,CAAE,GAAGvD,CAA0B,CACpE,EAAA,EACuB,aAAaD;EACpC,OAAO,OAAO4C,KAAU,WAAWA,IAAQ;CAC7C;AACF"}
1
+ {"version":3,"file":"journey-Nu655gEO.js","names":["BASE64_PADDING_PATTERN","JOURNEY_STORAGE_KEY","JOURNEY_MAX_AGE_MS","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","JOURNEY_URL_PARAM","BASE64URL_UNDERSCORE_PATTERN","BASE64_SLASH_PATTERN","JOURNEY_ID_PATTERN","OPENFIN_OPTIONS_TIMEOUT_MS","BASE64_PLUS_PATTERN","BASE64URL_DASH_PATTERN","withDeadline","newId","BROWSER_STORES","getFin","unrefTimer","_defineProperty","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// Manages a user journey's lifecycle across windows: encodes tokens, stores the journey and\n// ends it at expiry. Never trust a value from storage or a token, because any code on the\n// 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, which is one user task spanning several contexts. */\nexport interface JourneyOptions {\n /** Maximum time a journey stays open, in milliseconds. After that 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/** The journey lifetime policy in effect. 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 /** Human-readable name of the journey's workflow. */\n name: string;\n /** Journey start timestamp in epoch milliseconds. */\n startedAt: number;\n /** Parent journey ID, set when the journey branches from an earlier one. */\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 another realm's bus message.\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 a 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 // We always write a start time. A token without one, or with one from the future, would\n // never expire.\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, which throws above U+00FF.\n // Without this step, a name in a non-Latin script would fail.\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. Keeps an active journey. Otherwise checks the URL\n * query first, then sessionStorage, then OpenFin customData.\n * @returns Promise that resolves when journey initialization completes.\n */\n async bootstrap(): Promise<void> {\n const fromUrl = this.readUrlToken();\n // A journey that the app started before configure() wins, and it moves to the stores that\n // configure() chose. Otherwise a stored journey from an earlier page would replace it. The\n // token still leaves the address bar, or a copied link would carry it to another session.\n if (this.journey) {\n if (fromUrl) {\n this.removeUrlToken();\n }\n this.setJourney(this.journey);\n return;\n }\n\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, replacing the active one and telling 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 * Picks the id for a new journey. A longer id, or one with multibyte characters, would make\n * the 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, otherwise 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 without broadcasting it again. An echo would\n * make two windows send the change back and forth forever. A journey with the same ID as\n * the active one is ignored, so an echo can't 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 null when no journey is active or the token exceeds the size\n * limit.\n */\n getToken(): string | null {\n const journey = this.journey;\n if (journey === null) {\n return null;\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 null;\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, and every step throws on bad input. The guard reports the failure\n * instead of letting it throw.\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 once the engine has adopted it.\n * Otherwise a copied or bookmarked link would start 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, because 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 customData in the OpenFin window options. The wait is\n * capped by OPENFIN_OPTIONS_TIMEOUT_MS. At the deadline we report openfin.unavailable and\n * return no token. A window with no token gives the same result.\n * @returns Promise that resolves to the 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 so the native OpenFin method keeps its receiver. A detached copy throws when\n // 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,IAAaiB,IAAkC;CAC7C,UAAUf;CACV,iBAAA;CACA,UAAUE;AACZ;AAsBA,SAASc,EAAW,GAAgB,GAAiC;CACnE,IAAMC,IAAiB,QAAQ,IAAIC,GAAQC,CAAG;CAC9C,OAAO,OAAOF,KAAU,YAAYA,MAAU,KAAKA,IAAQ,KAAA;A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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-CPW6bvZH.cjs.map
1
+ const e=require("./constants-NtiQDWL_.cjs");var t=require("./global-scope-BN-Io_yv.cjs").t(e.jt);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-DdIlzzph.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-console-CPW6bvZH.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, so the console capture can skip them.\n// Without the scope, the capture would record every mirrored line again in an endless loop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn The function that writes to the console.\n * @returns The function's return value.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library console scope is open.\n * @returns True while the library is writing to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":"A,4CASA,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
+ {"version":3,"file":"library-console-DdIlzzph.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, so the console capture can skip them.\n// Without the scope, the capture would record every mirrored line again in an endless loop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn The function that writes to the console.\n * @returns The function's return value.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library console scope is open.\n * @returns True while the library is writing to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":"A,4CASA,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,4 +1,4 @@
1
- import { At as e } from "./constants-CUyd9cTZ.js";
1
+ import { jt as e } from "./constants-CEHN6KuY.js";
2
2
  import { t } from "./global-scope-D9I8s-oN.js";
3
3
  // src/utils/library-console.ts
4
4
  var n = t(e);
@@ -10,4 +10,4 @@ function i() {
10
10
  }
11
11
  export { r as n, i as t };
12
12
 
13
- //# sourceMappingURL=library-console-Btrzt814.js.map
13
+ //# sourceMappingURL=library-console-amePMnP8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-console-Btrzt814.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, so the console capture can skip them.\n// Without the scope, the capture would record every mirrored line again in an endless loop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn The function that writes to the console.\n * @returns The function's return value.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library console scope is open.\n * @returns True while the library is writing to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":";;;AASA,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-amePMnP8.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, so the console capture can skip them.\n// Without the scope, the capture would record every mirrored line again in an endless loop.\n\nimport { LIBRARY_CONSOLE_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own console calls. */\nconst scope = globalScope(LIBRARY_CONSOLE_KEY);\n\n/**\n * Runs a function inside the library console scope.\n * @param fn The function that writes to the console.\n * @returns The function's return value.\n */\nexport function runAsLibraryConsole<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library console scope is open.\n * @returns True while the library is writing to the console.\n */\nexport function isLibraryConsole(): boolean {\n return scope.open();\n}\n"],"mappings":";;;AASA,IAAMC,IAAQC,EAAYF,CAAmB;AAO7C,SAAgBG,EAAuB,GAAgB;CACrD,OAAOF,EAAM,IAAIG,CAAE;AACrB;AAMA,SAAgBC,IAA4B;CAC1C,OAAOJ,EAAM,KAAK;AACpB"}
@@ -1,4 +1,4 @@
1
- import { Mt as e, ir as t } from "./constants-CUyd9cTZ.js";
1
+ import { Nt as e, cr as t } from "./constants-CEHN6KuY.js";
2
2
  import { t as n } from "./global-scope-D9I8s-oN.js";
3
3
  // src/utils/library-request.ts
4
4
  var r = n(e), i = Symbol.for(t), a = globalThis, o = () => a[i] ?? 0;
@@ -21,4 +21,4 @@ function u() {
21
21
  }
22
22
  export { l as i, u as n, s as r, c as t };
23
23
 
24
- //# sourceMappingURL=library-request-BJ9PLRaD.js.map
24
+ //# sourceMappingURL=library-request-Cv7C05jf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-request-BJ9PLRaD.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, so network capture can skip them. A\n// captured library request would log a record, the library would send that record with\n// another request, and the loop would never stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of custom transport calls that are still waiting 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. Only the synchronous part of the function\n * is covered, so a request that starts after an await is outside the scope.\n * @param fn The function that starts the request.\n * @returns The function's return value.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library request scope is open.\n * @returns True while the library is starting 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 The function that calls the custom transport.\n * @returns A promise that settles with the call's result.\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 * Checks whether a custom transport call is still waiting for an answer.\n * @returns True while a call hasn't 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-Cv7C05jf.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, so network capture can skip them. A\n// captured library request would log a record, the library would send that record with\n// another request, and the loop would never stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of custom transport calls that are still waiting 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. Only the synchronous part of the function\n * is covered, so a request that starts after an await is outside the scope.\n * @param fn The function that starts the request.\n * @returns The function's return value.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library request scope is open.\n * @returns True while the library is starting 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 The function that calls the custom transport.\n * @returns A promise that settles with the call's result.\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 * Checks whether a custom transport call is still waiting for an answer.\n * @returns True while a call hasn't 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("./constants-CqdJhTxH.cjs");var t=require("./global-scope-BN-Io_yv.cjs").t(e.Mt),n=Symbol.for(e.ir),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-D7OvTxZV.cjs.map
1
+ const e=require("./constants-NtiQDWL_.cjs");var t=require("./global-scope-BN-Io_yv.cjs").t(e.Nt),n=Symbol.for(e.cr),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-DO3Ec7KE.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-request-D7OvTxZV.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, so network capture can skip them. A\n// captured library request would log a record, the library would send that record with\n// another request, and the loop would never stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of custom transport calls that are still waiting 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. Only the synchronous part of the function\n * is covered, so a request that starts after an await is outside the scope.\n * @param fn The function that starts the request.\n * @returns The function's return value.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library request scope is open.\n * @returns True while the library is starting 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 The function that calls the custom transport.\n * @returns A promise that settles with the call's result.\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 * Checks whether a custom transport call is still waiting for an answer.\n * @returns True while a call hasn't 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
+ {"version":3,"file":"library-request-DO3Ec7KE.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, so network capture can skip them. A\n// captured library request would log a record, the library would send that record with\n// another request, and the loop would never stop.\n\nimport { LIBRARY_REQUEST_KEY, TRANSPORT_CALL_KEY } from \"../constants\";\nimport { globalScope } from \"./global-scope\";\n\n/** The scope for the library's own requests. */\nconst scope = globalScope(LIBRARY_REQUEST_KEY);\n\n/** Global count of custom transport calls that are still waiting 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. Only the synchronous part of the function\n * is covered, so a request that starts after an await is outside the scope.\n * @param fn The function that starts the request.\n * @returns The function's return value.\n */\nexport function runAsLibraryRequest<T>(fn: () => T): T {\n return scope.run(fn);\n}\n\n/**\n * Checks whether a library request scope is open.\n * @returns True while the library is starting 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 The function that calls the custom transport.\n * @returns A promise that settles with the call's result.\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 * Checks whether a custom transport call is still waiting for an answer.\n * @returns True while a call hasn't 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,2 +1,2 @@
1
- const e=require("./storm-C-zYSdDX.cjs"),t=require("./defineProperty-X1c4tIPD.cjs");var n=class{constructor(e){t.t(this,`ctx`,void 0),t.t(this,`name`,`lifecycle`),t.t(this,`installed`,!1),t.t(this,`phase`,{state:``,enteredAt:0}),t.t(this,`window`,{start:0,count:0}),t.t(this,`onVisibility`,()=>{this.transition(document.visibilityState===`hidden`?`hidden`:`visible`)}),t.t(this,`onFreeze`,()=>{this.transition(`frozen`)}),t.t(this,`onResume`,()=>{this.transition(`resumed`)}),t.t(this,`onPageShow`,e=>{e.persisted&&this.transition(`restored`)}),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)}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{captureLimits: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=n;
2
- //# sourceMappingURL=lifecycle-IaAm1mOC.cjs.map
1
+ const e=require("./storm-qiE_AMC7.cjs"),t=require("./defineProperty-X1c4tIPD.cjs");var n=class{constructor(e){t.t(this,`ctx`,void 0),t.t(this,`name`,`lifecycle`),t.t(this,`installed`,!1),t.t(this,`phase`,{state:``,enteredAt:0}),t.t(this,`window`,{start:0,count:0}),t.t(this,`onVisibility`,()=>{this.transition(document.visibilityState===`hidden`?`hidden`:`visible`)}),t.t(this,`onFreeze`,()=>{this.transition(`frozen`)}),t.t(this,`onResume`,()=>{this.transition(`resumed`)}),t.t(this,`onPageShow`,e=>{e.persisted&&this.transition(`restored`)}),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)}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{captureLimits: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=n;
2
+ //# sourceMappingURL=lifecycle-B5yfH5is.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-IaAm1mOC.cjs","names":["allowInWindow","require_storm","require_defineProperty","LifecycleCapture","event","ctx","state","now","previous","duration","captureLimits"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page state changes, each with how long the previous state lasted. */\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 the 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 the rate limit drops its event. */\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 { captureLimits } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n captureLimits.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n captureLimits.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,mFAIA,IAAaG,EAAb,KAAiD,CAS/C,YAAY,EAAsC,CAArBD,EAAA,EAAA,KAAA,MAAA,IAAA,EAAA,EAR7BA,EAAA,EAAA,KAAA,OAAgB,WAAA,EAEhBA,EAAA,EAAA,KAAA,YAAoB,EAAA,EAEpBA,EAAA,EAAA,KAAA,QAAuD,CAAE,MAAO,GAAI,UAAW,CAAE,CAAA,EAEjFA,EAAA,EAAA,KAAA,SAAuC,CAAE,MAAO,EAAG,MAAO,CAAE,CAAA,EA4B5DA,EAAA,EAAA,KAAA,mBAA4C,CAC1C,KAAK,WAAW,SAAS,kBAAoB,SAAW,SAAW,SAAS,CAC9E,CAAA,EAEAA,EAAA,EAAA,KAAA,eAAwC,CACtC,KAAK,WAAW,QAAQ,CAC1B,CAAA,EAEAA,EAAA,EAAA,KAAA,eAAwC,CACtC,KAAK,WAAW,SAAS,CAC3B,CAAA,EAEAA,EAAA,EAAA,KAAA,aAA+B,GAAqC,CAC9DE,EAAM,WACR,KAAK,WAAW,UAAU,CAE9B,CAAA,EA1C6B,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,CAqBA,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,IACzBP,EAAAA,EACC,KAAK,OACLU,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,E"}
1
+ {"version":3,"file":"lifecycle-B5yfH5is.cjs","names":["allowInWindow","require_storm","require_defineProperty","LifecycleCapture","event","ctx","state","now","previous","duration","captureLimits"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page state changes, each with how long the previous state lasted. */\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 the 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 the rate limit drops its event. */\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 { captureLimits } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n captureLimits.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n captureLimits.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,mFAIA,IAAaG,EAAb,KAAiD,CAS/C,YAAY,EAAsC,CAArBD,EAAA,EAAA,KAAA,MAAA,IAAA,EAAA,EAR7BA,EAAA,EAAA,KAAA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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,IACzBP,EAAAA,EACC,KAAK,OACLU,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,E"}
@@ -1,4 +1,4 @@
1
- import { t as e } from "./storm-DjKetLKZ.js";
1
+ import { t as e } from "./storm-U3_ek1nA.js";
2
2
  import { t } from "./defineProperty-s2S8BXUc.js";
3
3
  // src/capture/lifecycle.ts
4
4
  var n = class {
@@ -44,4 +44,4 @@ var n = class {
44
44
  };
45
45
  export { n as LifecycleCapture };
46
46
 
47
- //# sourceMappingURL=lifecycle-22CUCrc9.js.map
47
+ //# sourceMappingURL=lifecycle-CMHz2Zbs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-22CUCrc9.js","names":["allowInWindow","LifecycleCapture","_defineProperty","event","ctx","state","now","previous","duration","captureLimits"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page state changes, each with how long the previous state lasted. */\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 the 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 the rate limit drops its event. */\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 { captureLimits } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n captureLimits.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n captureLimits.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;CAS/C,YAAY,GAAsC;EAArB,AAAAC,EAAA,MAAA,OAAA,KAAA,CAAA,GAR7BA,EAAA,MAAA,QAAgB,WAAA,GAEhBA,EAAA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KAAK,MAAM,QAAQD,GACnB,KAAK,MAAM,YAAYC;EAEvB,IAAM,EAAE,qBAAkB,KAAK,IAAI;EACnC,AACE,KAAK,IAAI,WAAW,MAAM,MACzBN,EACC,KAAK,QACLS,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
+ {"version":3,"file":"lifecycle-CMHz2Zbs.js","names":["allowInWindow","LifecycleCapture","_defineProperty","event","ctx","state","now","previous","duration","captureLimits"],"sources":["../src/capture/lifecycle.ts"],"sourcesContent":["import { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext, CaptureOnce } from \"./types\";\n\n/** Records page state changes, each with how long the previous state lasted. */\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 the 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 the rate limit drops its event. */\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 { captureLimits } = this.ctx.config;\n if (\n this.ctx.isActive?.() === false ||\n !allowInWindow(\n this.window,\n captureLimits.lifecyclePerWindow,\n this.ctx.diagnostics,\n \"lifecycle events\",\n captureLimits.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;CAS/C,YAAY,GAAsC;EAArB,AAAAC,EAAA,MAAA,OAAA,KAAA,CAAA,GAR7BA,EAAA,MAAA,QAAgB,WAAA,GAEhBA,EAAA,MAAA,aAAoB,EAAA,GAEpBA,EAAA,MAAA,SAAuD;GAAE,OAAO;GAAI,WAAW;EAAE,CAAA,GAEjFA,EAAA,MAAA,UAAuC;GAAE,OAAO;GAAG,OAAO;EAAE,CAAA,GA4B5DA,EAAA,MAAA,sBAA4C;GAC1C,KAAK,WAAW,SAAS,oBAAoB,WAAW,WAAW,SAAS;EAC9E,CAAA,GAEAA,EAAA,MAAA,kBAAwC;GACtC,KAAK,WAAW,QAAQ;EAC1B,CAAA,GAEAA,EAAA,MAAA,kBAAwC;GACtC,KAAK,WAAW,SAAS;EA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4 +1,4 @@
1
- import { kt as e } from "./constants-CUyd9cTZ.js";
1
+ import { At as e } from "./constants-CEHN6KuY.js";
2
2
  import { t } from "./guards-BlYGRK4l.js";
3
3
  // src/models/log-record.ts
4
4
  function n() {
@@ -14,4 +14,4 @@ function i(e) {
14
14
  }
15
15
  export { i as n, n as r, r as t };
16
16
 
17
- //# sourceMappingURL=log-record-BNiLfqtL.js.map
17
+ //# sourceMappingURL=log-record-B_nSqxoe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"log-record-BNiLfqtL.js","names":["LEVEL_ORDER","nowUnixNano","isLogLevel","value","hasOwn","isLogRecord","record"],"sources":["../src/models/log-record.ts"],"sourcesContent":["// src/models/log-record.ts\n//\n// Shape of one log record, plus helpers for building and validating it.\n//\n// The severity tables live in `src/constants.ts`.\n\nimport { LEVEL_ORDER } from \"../constants\";\nimport { hasOwn } from \"../utils/guards\";\n\n/** OpenTelemetry severity levels, in ascending order. */\nexport type LogLevel = \"TRACE\" | \"DEBUG\" | \"INFO\" | \"WARN\" | \"ERROR\" | \"FATAL\";\n\n/**\n * What a record is about. `action` is something a person did, `event` is something the\n * application did, and `metric` is a measurement. `log` is an application log call,\n * `system` is this library's own output and `span` is one span of a trace.\n */\nexport type LogType = \"action\" | \"event\" | \"metric\" | \"log\" | \"system\" | \"span\";\n\n/** Metric value type: level, running total, or distribution. */\nexport type MetricType = \"gauge\" | \"counter\" | \"histogram\";\n\n/** Internal record shape. A serializer converts it to the payload format. */\nexport interface LogRecord {\n /**\n * Event time, nanoseconds since epoch, as a decimal string.\n * @see {@link nowUnixNano}\n */\n timeUnixNano: string;\n /**\n * When this library received the event, if that differs from `timeUnixNano`. A forwarded\n * record, for example, can have a different time.\n */\n observedTimeUnixNano?: string;\n /** Distributed trace id. */\n traceId: string;\n /** Span id within the trace. */\n spanId: string;\n /** OpenTelemetry trace flags. The library uses only the sampled bit. */\n traceFlags: number;\n /** OpenTelemetry severity number for `severityText`. */\n severityNumber: number;\n /** Log level. */\n severityText: LogLevel;\n /** Log message. */\n body: string;\n /** Structured attributes, sanitized and size-capped. */\n attributes: Record<string, unknown>;\n /** Resource attributes, shared by every record from one context. */\n resource: Record<string, unknown>;\n}\n\n/**\n * Returns the current time as a Unix nanosecond timestamp. Appends zeros instead of\n * multiplying, because `Date.now() * 1e6` exceeds `Number.MAX_SAFE_INTEGER` and corrupts\n * digits without an error. The trailing zeros mean unknown precision, not measured digits.\n * @returns Epoch timestamp in nanoseconds, as a decimal string.\n */\nexport function nowUnixNano(): string {\n return `${String(Date.now())}000000`;\n}\n\n/**\n * Checks whether a value is a known log level. The own-key check rejects \"toString\".\n * @param value The value to check.\n * @returns True if `value` is a key of the severity table.\n */\nexport function isLogLevel(value: unknown): value is LogLevel {\n return typeof value === \"string\" && hasOwn(LEVEL_ORDER, value);\n}\n\n/**\n * Checks whether a value has the shape `LogRecord` requires. Use it to validate records from\n * another realm, because a malformed record throws during serialization. Any string is\n * accepted as `severityText`, not only a known level, so an unknown level from a newer\n * version still passes.\n * @param value The value to check.\n * @returns True if `value` has the shape `LogRecord` requires.\n */\nexport function isLogRecord(value: unknown): value is LogRecord {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n // Cast to `Record<string, unknown>`, not `Partial<LogRecord>`. With the partial type the\n // compiler treats these fields as never null, so the checks below would look unnecessary.\n const record = value as Record<string, unknown>;\n return (\n typeof record.body === \"string\" &&\n typeof record.severityText === \"string\" &&\n typeof record.timeUnixNano === \"string\" &&\n typeof record.attributes === \"object\" &&\n record.attributes !== null &&\n typeof record.resource === \"object\" &&\n record.resource !== null\n );\n}\n"],"mappings":";;;AA0DA,SAAgBC,IAAsB;CACpC,OAAO,GAAG,OAAO,KAAK,IAAI,CAAC,EAAE;AAC/B;AAOA,SAAgBC,EAAW,GAAmC;CAC5D,OAAO,OAAOC,KAAU,YAAYC,EAAOJ,GAAaG,CAAK;AAC/D;AAUA,SAAgBE,EAAY,GAAoC;CAC9D,IAAI,OAAOF,KAAU,aAAYA,GAC/B,OAAO;CAIT,IAAMG,IAASH;CACf,OACE,OAAOG,EAAO,QAAS,YACvB,OAAOA,EAAO,gBAAiB,YAC/B,OAAOA,EAAO,gBAAiB,YAC/B,OAAOA,EAAO,cAAe,YAC7BA,EAAO,eAAe,QACtB,OAAOA,EAAO,YAAa,YAC3BA,EAAO,aAAa;AAExB"}
1
+ {"version":3,"file":"log-record-B_nSqxoe.js","names":["LEVEL_ORDER","nowUnixNano","isLogLevel","value","hasOwn","isLogRecord","record"],"sources":["../src/models/log-record.ts"],"sourcesContent":["// src/models/log-record.ts\n//\n// Shape of one log record, plus helpers for building and validating it.\n//\n// The severity tables live in `src/constants.ts`.\n\nimport { LEVEL_ORDER } from \"../constants\";\nimport { hasOwn } from \"../utils/guards\";\n\n/** OpenTelemetry severity levels, in ascending order. */\nexport type LogLevel = \"TRACE\" | \"DEBUG\" | \"INFO\" | \"WARN\" | \"ERROR\" | \"FATAL\";\n\n/**\n * What a record is about. `action` is something a person did, `event` is something the\n * application did, and `metric` is a measurement. `log` is an application log call,\n * `system` is this library's own output and `span` is one span of a trace.\n */\nexport type LogType = \"action\" | \"event\" | \"metric\" | \"log\" | \"system\" | \"span\";\n\n/** Metric value type: level, running total, or distribution. */\nexport type MetricType = \"gauge\" | \"counter\" | \"histogram\";\n\n/** Internal record shape. A serializer converts it to the payload format. */\nexport interface LogRecord {\n /**\n * Event time, nanoseconds since epoch, as a decimal string.\n * @see {@link nowUnixNano}\n */\n timeUnixNano: string;\n /**\n * When this library received the event, if that differs from `timeUnixNano`. A forwarded\n * record, for example, can have a different time.\n */\n observedTimeUnixNano?: string;\n /** Distributed trace id. */\n traceId: string;\n /** Span id within the trace. */\n spanId: string;\n /** OpenTelemetry trace flags. The library uses only the sampled bit. */\n traceFlags: number;\n /** OpenTelemetry severity number for `severityText`. */\n severityNumber: number;\n /** Log level. */\n severityText: LogLevel;\n /** Log message. */\n body: string;\n /** Structured attributes, sanitized and size-capped. */\n attributes: Record<string, unknown>;\n /** Resource attributes, shared by every record from one context. */\n resource: Record<string, unknown>;\n}\n\n/**\n * Returns the current time as a Unix nanosecond timestamp. Appends zeros instead of\n * multiplying, because `Date.now() * 1e6` exceeds `Number.MAX_SAFE_INTEGER` and corrupts\n * digits without an error. The trailing zeros mean unknown precision, not measured digits.\n * @returns Epoch timestamp in nanoseconds, as a decimal string.\n */\nexport function nowUnixNano(): string {\n return `${String(Date.now())}000000`;\n}\n\n/**\n * Checks whether a value is a known log level. The own-key check rejects \"toString\".\n * @param value The value to check.\n * @returns True if `value` is a key of the severity table.\n */\nexport function isLogLevel(value: unknown): value is LogLevel {\n return typeof value === \"string\" && hasOwn(LEVEL_ORDER, value);\n}\n\n/**\n * Checks whether a value has the shape `LogRecord` requires. Use it to validate records from\n * another realm, because a malformed record throws during serialization. Any string is\n * accepted as `severityText`, not only a known level, so an unknown level from a newer\n * version still passes.\n * @param value The value to check.\n * @returns True if `value` has the shape `LogRecord` requires.\n */\nexport function isLogRecord(value: unknown): value is LogRecord {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n // Cast to `Record<string, unknown>`, not `Partial<LogRecord>`. With the partial type the\n // compiler treats these fields as never null, so the checks below would look unnecessary.\n const record = value as Record<string, unknown>;\n return (\n typeof record.body === \"string\" &&\n typeof record.severityText === \"string\" &&\n typeof record.timeUnixNano === \"string\" &&\n typeof record.attributes === \"object\" &&\n record.attributes !== null &&\n typeof record.resource === \"object\" &&\n record.resource !== null\n );\n}\n"],"mappings":";;;AA0DA,SAAgBC,IAAsB;CACpC,OAAO,GAAG,OAAO,KAAK,IAAI,CAAC,EAAE;AAC/B;AAOA,SAAgBC,EAAW,GAAmC;CAC5D,OAAO,OAAOC,KAAU,YAAYC,EAAOJ,GAAaG,CAAK;AAC/D;AAUA,SAAgBE,EAAY,GAAoC;CAC9D,IAAI,OAAOF,KAAU,aAAYA,GAC/B,OAAO;CAIT,IAAMG,IAASH;CACf,OACE,OAAOG,EAAO,QAAS,YACvB,OAAOA,EAAO,gBAAiB,YAC/B,OAAOA,EAAO,gBAAiB,YAC/B,OAAOA,EAAO,cAAe,YAC7BA,EAAO,eAAe,QACtB,OAAOA,EAAO,YAAa,YAC3BA,EAAO,aAAa;AAExB"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants-CqdJhTxH.cjs"),t=require("./guards-EjG3ahFp.cjs");function n(){return`${String(Date.now())}000000`}function r(n){return typeof n==`string`&&t.t(e.kt,n)}function i(e){if(typeof e!=`object`||!e)return!1;let t=e;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}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
2
- //# sourceMappingURL=log-record-CkivuiEl.cjs.map
1
+ const e=require("./constants-NtiQDWL_.cjs"),t=require("./guards-EjG3ahFp.cjs");function n(){return`${String(Date.now())}000000`}function r(n){return typeof n==`string`&&t.t(e.At,n)}function i(e){if(typeof e!=`object`||!e)return!1;let t=e;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}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
2
+ //# sourceMappingURL=log-record-Bdywwg0k.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"log-record-CkivuiEl.cjs","names":["hasOwn","LEVEL_ORDER","require_constants","require_guards","nowUnixNano","isLogLevel","value","isLogRecord","record"],"sources":["../src/models/log-record.ts"],"sourcesContent":["// src/models/log-record.ts\n//\n// Shape of one log record, plus helpers for building and validating it.\n//\n// The severity tables live in `src/constants.ts`.\n\nimport { LEVEL_ORDER } from \"../constants\";\nimport { hasOwn } from \"../utils/guards\";\n\n/** OpenTelemetry severity levels, in ascending order. */\nexport type LogLevel = \"TRACE\" | \"DEBUG\" | \"INFO\" | \"WARN\" | \"ERROR\" | \"FATAL\";\n\n/**\n * What a record is about. `action` is something a person did, `event` is something the\n * application did, and `metric` is a measurement. `log` is an application log call,\n * `system` is this library's own output and `span` is one span of a trace.\n */\nexport type LogType = \"action\" | \"event\" | \"metric\" | \"log\" | \"system\" | \"span\";\n\n/** Metric value type: level, running total, or distribution. */\nexport type MetricType = \"gauge\" | \"counter\" | \"histogram\";\n\n/** Internal record shape. A serializer converts it to the payload format. */\nexport interface LogRecord {\n /**\n * Event time, nanoseconds since epoch, as a decimal string.\n * @see {@link nowUnixNano}\n */\n timeUnixNano: string;\n /**\n * When this library received the event, if that differs from `timeUnixNano`. A forwarded\n * record, for example, can have a different time.\n */\n observedTimeUnixNano?: string;\n /** Distributed trace id. */\n traceId: string;\n /** Span id within the trace. */\n spanId: string;\n /** OpenTelemetry trace flags. The library uses only the sampled bit. */\n traceFlags: number;\n /** OpenTelemetry severity number for `severityText`. */\n severityNumber: number;\n /** Log level. */\n severityText: LogLevel;\n /** Log message. */\n body: string;\n /** Structured attributes, sanitized and size-capped. */\n attributes: Record<string, unknown>;\n /** Resource attributes, shared by every record from one context. */\n resource: Record<string, unknown>;\n}\n\n/**\n * Returns the current time as a Unix nanosecond timestamp. Appends zeros instead of\n * multiplying, because `Date.now() * 1e6` exceeds `Number.MAX_SAFE_INTEGER` and corrupts\n * digits without an error. The trailing zeros mean unknown precision, not measured digits.\n * @returns Epoch timestamp in nanoseconds, as a decimal string.\n */\nexport function nowUnixNano(): string {\n return `${String(Date.now())}000000`;\n}\n\n/**\n * Checks whether a value is a known log level. The own-key check rejects \"toString\".\n * @param value The value to check.\n * @returns True if `value` is a key of the severity table.\n */\nexport function isLogLevel(value: unknown): value is LogLevel {\n return typeof value === \"string\" && hasOwn(LEVEL_ORDER, value);\n}\n\n/**\n * Checks whether a value has the shape `LogRecord` requires. Use it to validate records from\n * another realm, because a malformed record throws during serialization. Any string is\n * accepted as `severityText`, not only a known level, so an unknown level from a newer\n * version still passes.\n * @param value The value to check.\n * @returns True if `value` has the shape `LogRecord` requires.\n */\nexport function isLogRecord(value: unknown): value is LogRecord {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n // Cast to `Record<string, unknown>`, not `Partial<LogRecord>`. With the partial type the\n // compiler treats these fields as never null, so the checks below would look unnecessary.\n const record = value as Record<string, unknown>;\n return (\n typeof record.body === \"string\" &&\n typeof record.severityText === \"string\" &&\n typeof record.timeUnixNano === \"string\" &&\n typeof record.attributes === \"object\" &&\n record.attributes !== null &&\n typeof record.resource === \"object\" &&\n record.resource !== null\n );\n}\n"],"mappings":"A,+EA0DA,SAAgBI,GAAsB,CACpC,MAAO,GAAG,OAAO,KAAK,IAAI,CAAC,EAAE,OAC/B,CAOA,SAAgBC,EAAW,EAAmC,CAC5D,OAAO,OAAOC,GAAU,UAAYN,EAAAA,EAAOC,EAAAA,GAAaK,CAAK,CAC/D,CAUA,SAAgBC,EAAY,EAAoC,CAC9D,GAAI,OAAOD,GAAU,WAAYA,EAC/B,MAAO,GAIT,IAAME,EAASF,EACf,OACE,OAAOE,EAAO,MAAS,UACvB,OAAOA,EAAO,cAAiB,UAC/B,OAAOA,EAAO,cAAiB,UAC/B,OAAOA,EAAO,YAAe,UAC7BA,EAAO,aAAe,MACtB,OAAOA,EAAO,UAAa,UAC3BA,EAAO,WAAa,IAExB,C"}
1
+ {"version":3,"file":"log-record-Bdywwg0k.cjs","names":["hasOwn","LEVEL_ORDER","require_constants","require_guards","nowUnixNano","isLogLevel","value","isLogRecord","record"],"sources":["../src/models/log-record.ts"],"sourcesContent":["// src/models/log-record.ts\n//\n// Shape of one log record, plus helpers for building and validating it.\n//\n// The severity tables live in `src/constants.ts`.\n\nimport { LEVEL_ORDER } from \"../constants\";\nimport { hasOwn } from \"../utils/guards\";\n\n/** OpenTelemetry severity levels, in ascending order. */\nexport type LogLevel = \"TRACE\" | \"DEBUG\" | \"INFO\" | \"WARN\" | \"ERROR\" | \"FATAL\";\n\n/**\n * What a record is about. `action` is something a person did, `event` is something the\n * application did, and `metric` is a measurement. `log` is an application log call,\n * `system` is this library's own output and `span` is one span of a trace.\n */\nexport type LogType = \"action\" | \"event\" | \"metric\" | \"log\" | \"system\" | \"span\";\n\n/** Metric value type: level, running total, or distribution. */\nexport type MetricType = \"gauge\" | \"counter\" | \"histogram\";\n\n/** Internal record shape. A serializer converts it to the payload format. */\nexport interface LogRecord {\n /**\n * Event time, nanoseconds since epoch, as a decimal string.\n * @see {@link nowUnixNano}\n */\n timeUnixNano: string;\n /**\n * When this library received the event, if that differs from `timeUnixNano`. A forwarded\n * record, for example, can have a different time.\n */\n observedTimeUnixNano?: string;\n /** Distributed trace id. */\n traceId: string;\n /** Span id within the trace. */\n spanId: string;\n /** OpenTelemetry trace flags. The library uses only the sampled bit. */\n traceFlags: number;\n /** OpenTelemetry severity number for `severityText`. */\n severityNumber: number;\n /** Log level. */\n severityText: LogLevel;\n /** Log message. */\n body: string;\n /** Structured attributes, sanitized and size-capped. */\n attributes: Record<string, unknown>;\n /** Resource attributes, shared by every record from one context. */\n resource: Record<string, unknown>;\n}\n\n/**\n * Returns the current time as a Unix nanosecond timestamp. Appends zeros instead of\n * multiplying, because `Date.now() * 1e6` exceeds `Number.MAX_SAFE_INTEGER` and corrupts\n * digits without an error. The trailing zeros mean unknown precision, not measured digits.\n * @returns Epoch timestamp in nanoseconds, as a decimal string.\n */\nexport function nowUnixNano(): string {\n return `${String(Date.now())}000000`;\n}\n\n/**\n * Checks whether a value is a known log level. The own-key check rejects \"toString\".\n * @param value The value to check.\n * @returns True if `value` is a key of the severity table.\n */\nexport function isLogLevel(value: unknown): value is LogLevel {\n return typeof value === \"string\" && hasOwn(LEVEL_ORDER, value);\n}\n\n/**\n * Checks whether a value has the shape `LogRecord` requires. Use it to validate records from\n * another realm, because a malformed record throws during serialization. Any string is\n * accepted as `severityText`, not only a known level, so an unknown level from a newer\n * version still passes.\n * @param value The value to check.\n * @returns True if `value` has the shape `LogRecord` requires.\n */\nexport function isLogRecord(value: unknown): value is LogRecord {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n // Cast to `Record<string, unknown>`, not `Partial<LogRecord>`. With the partial type the\n // compiler treats these fields as never null, so the checks below would look unnecessary.\n const record = value as Record<string, unknown>;\n return (\n typeof record.body === \"string\" &&\n typeof record.severityText === \"string\" &&\n typeof record.timeUnixNano === \"string\" &&\n typeof record.attributes === \"object\" &&\n record.attributes !== null &&\n typeof record.resource === \"object\" &&\n record.resource !== null\n );\n}\n"],"mappings":"A,+EA0DA,SAAgBI,GAAsB,CACpC,MAAO,GAAG,OAAO,KAAK,IAAI,CAAC,EAAE,OAC/B,CAOA,SAAgBC,EAAW,EAAmC,CAC5D,OAAO,OAAOC,GAAU,UAAYN,EAAAA,EAAOC,EAAAA,GAAaK,CAAK,CAC/D,CAUA,SAAgBC,EAAY,EAAoC,CAC9D,GAAI,OAAOD,GAAU,WAAYA,EAC/B,MAAO,GAIT,IAAME,EAASF,EACf,OACE,OAAOE,EAAO,MAAS,UACvB,OAAOA,EAAO,cAAiB,UAC/B,OAAOA,EAAO,cAAiB,UAC/B,OAAOA,EAAO,YAAe,UAC7BA,EAAO,aAAe,MACtB,OAAOA,EAAO,UAAa,UAC3BA,EAAO,WAAa,IAExB,C"}
@@ -1,5 +1,5 @@
1
- import { i as e } from "./platform-BaaFIPCU.js";
2
- import { t } from "./storm-DjKetLKZ.js";
1
+ import { a as e } from "./platform-Dba6R3Hp.js";
2
+ import { t } from "./storm-U3_ek1nA.js";
3
3
  import { t as n } from "./defineProperty-s2S8BXUc.js";
4
4
  // src/capture/long-frames.ts
5
5
  var r = ["long-animation-frame", "longtask"];
@@ -59,4 +59,4 @@ var a = class {
59
59
  };
60
60
  export { a as LongFrameCapture };
61
61
 
62
- //# sourceMappingURL=long-frames-DNFaRnC3.js.map
62
+ //# sourceMappingURL=long-frames-6NGl1-uN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"long-frames-DNFaRnC3.js","names":["recordedUrl","_defineProperty","FRAME_TYPES","longestScript","longest","script","scripts","LongFrameCapture","ctx","first","once","supported","type","name","entry","list","value","longFrames","allowInWindow","diagnostics","duration","attrs","url","invoker"],"sources":["../src/capture/long-frames.ts"],"sourcesContent":["// src/capture/long-frames.ts\n//\n// Reports long animation frames. A long frame can freeze the page with no user input involved,\n// for example a grid that re-renders 5,000 rows, and INP never shows that.\n\nimport { LONG_FRAME_THRESHOLD_MS } from \"../constants\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** The entry types this capture can observe, best first. */\nconst FRAME_TYPES = [\"long-animation-frame\", \"longtask\"];\n\n/** One script in a long animation frame. Some versions of the DOM types don't declare it. */\ninterface FrameScript {\n /** How long the script ran, in milliseconds. */\n duration: number;\n /** What called the script, for example an event listener or a timer. */\n invoker?: string;\n /** URL of the script's source. */\n sourceURL?: string;\n}\n\n/** A long animation frame or a long task. A long task has no blocking time and no scripts. */\ninterface FrameEntry extends PerformanceEntry {\n /** How long the frame blocked input, in milliseconds. */\n blockingDuration?: number;\n /** Scripts that ran in the frame. */\n scripts?: FrameScript[];\n}\n\n/**\n * Finds the script that ran longest in a frame.\n * @param scripts The frame's scripts.\n * @returns The longest script, or undefined if the frame has none.\n */\nfunction longestScript(scripts: FrameScript[] | undefined): FrameScript | undefined {\n let longest: FrameScript | undefined;\n\n for (const script of scripts ?? []) {\n if (!longest || script.duration > longest.duration) {\n longest = script;\n }\n }\n\n return longest;\n}\n\n/** Records every long animation frame as a histogram metric and a breadcrumb. */\nexport class LongFrameCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"long-frames\";\n\n /** Active observer. Undefined while the capture isn't installed. */\n private observer: PerformanceObserver | undefined;\n\n /** This capture's own rate limit, so a frozen tab can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /** Minimum frame duration to record, in milliseconds. */\n private threshold = LONG_FRAME_THRESHOLD_MS;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Observes the best entry type the browser supports. */\n install(): void {\n if (this.observer) {\n return;\n }\n\n // Only the first install in a document reads buffered frames or reports missing support,\n // so a reinstall after configure() doesn't repeat either.\n const { once } = this.ctx;\n const first = !once.longFrames;\n once.longFrames = true;\n\n // Older browsers have no supportedEntryTypes, and the capture stays off there.\n const supported: readonly string[] | undefined =\n typeof PerformanceObserver === \"undefined\"\n ? undefined\n : PerformanceObserver.supportedEntryTypes;\n const type = FRAME_TYPES.find((name) => supported?.includes(name));\n\n if (type === undefined) {\n if (!first) {\n return;\n }\n\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not report long frames. The long frame capture is off.\",\n );\n return;\n }\n\n this.threshold = this.readThreshold();\n this.observer = new PerformanceObserver((list) => {\n // The browser calls this directly, so anything we throw is an uncaught error on the page.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a long frame.\",\n () => {\n for (const entry of list.getEntries()) {\n this.record(entry);\n }\n },\n );\n });\n\n // Buffered frames include the first render, which happens before this chunk loads.\n this.observer.observe({ type, buffered: first });\n }\n\n /** Disconnects the observer. */\n uninstall(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n /**\n * Reads the threshold from the configuration and reports a value it can't use.\n * @returns Minimum frame duration to record, in milliseconds.\n */\n private readThreshold(): number {\n const { longFrames } = this.ctx.config.capture;\n const value: unknown =\n typeof longFrames === \"object\" ? longFrames.thresholdMs : LONG_FRAME_THRESHOLD_MS;\n\n if (typeof value === \"number\" && Number.isFinite(value) && value >= 0) {\n return value;\n }\n\n this.ctx.diagnostics.report(\n \"config.invalid\",\n `capture.longFrames.thresholdMs must be a number of 0 or more. The library uses ${String(LONG_FRAME_THRESHOLD_MS)}.`,\n );\n return LONG_FRAME_THRESHOLD_MS;\n }\n\n /**\n * Records one frame at or above the threshold.\n * @param entry Long animation frame or long task entry.\n */\n private record(entry: FrameEntry): void {\n if (entry.duration < this.threshold) {\n return;\n }\n\n const { diagnostics } = this.ctx;\n\n if (\n !allowInWindow(\n this.window,\n this.ctx.config.captureLimits.longFramesPerWindow,\n diagnostics,\n \"long frames\",\n this.ctx.config.captureLimits.windowMs,\n )\n ) {\n return;\n }\n\n const duration = Math.round(entry.duration);\n const attrs: Record<string, unknown> = { \"frame.type\": entry.entryType };\n\n if (entry.blockingDuration !== undefined) {\n attrs[\"frame.blocking_ms\"] = Math.round(entry.blockingDuration);\n }\n\n const script = longestScript(entry.scripts);\n\n // A signed URL is a credential. Only keep the query when fullUrls is on.\n const url = (value: string): string =>\n recordedUrl(\n value,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n diagnostics,\n );\n\n if (script?.invoker) {\n // A script entry's invoker is the script URL. Other invokers, for example\n // \"IMG#hero.onload\", contain a \"#\" that isn't a fragment.\n const { invoker } = script;\n attrs[\"frame.script.invoker\"] = invoker.includes(\"://\") ? url(invoker) : invoker;\n }\n\n if (script?.sourceURL) {\n attrs[\"frame.script.source\"] = url(script.sourceURL);\n }\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"frame\",\n message: `long frame ${String(duration)} ms`,\n });\n this.ctx.logger.logMetric(\"ui.long_frame.duration\", duration, \"ms\", \"histogram\", attrs);\n }\n}\n"],"mappings":";;;;AAWA,IAAME,IAAc,CAAC,wBAAwB,UAAU;AAyBvD,SAASC,EAAc,GAA6D;CAClF,IAAIC;CAEJ,KAAK,IAAMC,KAAUC,KAAW,CAAC,GAC/B,CAAI,CAACF,KAAWC,EAAO,WAAWD,EAAQ,cACxC,IAAUC;CAId,OAAOD;AACT;AAGA,IAAaG,IAAb,MAAiD;CAgB/C,YAAY,GAAsC;EAArB,AAAAN,EAAA,M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AK,QACL,KAAK,IAAI,OAAO,cAAc,qBAC9BC,GACA,eACA,KAAK,IAAI,OAAO,cAAc,QAChC,GAEA;EAGF,IAAMC,IAAW,KAAK,MAAMN,EAAM,QAAQ,GACpCO,IAAiC,EAAE,cAAcP,EAAM,UAAU;EAEvE,AAAIA,EAAM,qBAAqB,KAAA,MAC7B,EAAM,uBAAuB,KAAK,MAAMA,EAAM,gBAAgB;EAGhE,IAAMT,IAASF,EAAcW,EAAM,OAAO,GAGpCQ,KAAO,MACXtB,EACEgB,GACA,KAAK,IAAI,OAAO,QAAQ,UACxB,KAAK,IAAI,OAAO,QAAQ,cACxBG,CACF;EAEF,IAAId,GAAQ,SAAS;GAGnB,IAAM,EAAE,eAAYA;GACpB,EAAM,0BAA0BkB,EAAQ,SAAS,KAAK,IAAID,EAAIC,CAAO,IAAIA;EAC3E;EAWA,AATIlB,GAAQ,cACV,EAAM,yBAAyBiB,EAAIjB,EAAO,SAAS,IAGrD,KAAK,IAAI,YAAY,KAAK;GACxB,GAAG,KAAK,IAAI;GACZ,UAAU;GACV,SAAS,cAAc,OAAOe,CAAQ,EAAE;EAC1C,CAAC,GACD,KAAK,IAAI,OAAO,UAAU,0BAA0BA,GAAU,MAAM,aAAaC,CAAK;CACxF;AACF"}
1
+ {"version":3,"file":"long-frames-6NGl1-uN.js","names":["recordedUrl","_defineProperty","FRAME_TYPES","longestScript","longest","script","scripts","LongFrameCapture","ctx","first","once","supported","type","name","entry","list","value","longFrames","allowInWindow","diagnostics","duration","attrs","url","invoker"],"sources":["../src/capture/long-frames.ts"],"sourcesContent":["// src/capture/long-frames.ts\n//\n// Reports long animation frames. A long frame can freeze the page with no user input involved,\n// for example a grid that re-renders 5,000 rows, and INP never shows that.\n\nimport { LONG_FRAME_THRESHOLD_MS } from \"../constants\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** The entry types this capture can observe, best first. */\nconst FRAME_TYPES = [\"long-animation-frame\", \"longtask\"];\n\n/** One script in a long animation frame. Some versions of the DOM types don't declare it. */\ninterface FrameScript {\n /** How long the script ran, in milliseconds. */\n duration: number;\n /** What called the script, for example an event listener or a timer. */\n invoker?: string;\n /** URL of the script's source. */\n sourceURL?: string;\n}\n\n/** A long animation frame or a long task. A long task has no blocking time and no scripts. */\ninterface FrameEntry extends PerformanceEntry {\n /** How long the frame blocked input, in milliseconds. */\n blockingDuration?: number;\n /** Scripts that ran in the frame. */\n scripts?: FrameScript[];\n}\n\n/**\n * Finds the script that ran longest in a frame.\n * @param scripts The frame's scripts.\n * @returns The longest script, or undefined if the frame has none.\n */\nfunction longestScript(scripts: FrameScript[] | undefined): FrameScript | undefined {\n let longest: FrameScript | undefined;\n\n for (const script of scripts ?? []) {\n if (!longest || script.duration > longest.duration) {\n longest = script;\n }\n }\n\n return longest;\n}\n\n/** Records every long animation frame as a histogram metric and a breadcrumb. */\nexport class LongFrameCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"long-frames\";\n\n /** Active observer. Undefined while the capture isn't installed. */\n private observer: PerformanceObserver | undefined;\n\n /** This capture's own rate limit, so a frozen tab can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /** Minimum frame duration to record, in milliseconds. */\n private threshold = LONG_FRAME_THRESHOLD_MS;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Observes the best entry type the browser supports. */\n install(): void {\n if (this.observer) {\n return;\n }\n\n // Only the first install in a document reads buffered frames or reports missing support,\n // so a reinstall after configure() doesn't repeat either.\n const { once } = this.ctx;\n const first = !once.longFrames;\n once.longFrames = true;\n\n // Older browsers have no supportedEntryTypes, and the capture stays off there.\n const supported: readonly string[] | undefined =\n typeof PerformanceObserver === \"undefined\"\n ? undefined\n : PerformanceObserver.supportedEntryTypes;\n const type = FRAME_TYPES.find((name) => supported?.includes(name));\n\n if (type === undefined) {\n if (!first) {\n return;\n }\n\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not report long frames. The long frame capture is off.\",\n );\n return;\n }\n\n this.threshold = this.readThreshold();\n this.observer = new PerformanceObserver((list) => {\n // The browser calls this directly, so anything we throw is an uncaught error on the page.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a long frame.\",\n () => {\n for (const entry of list.getEntries()) {\n this.record(entry);\n }\n },\n );\n });\n\n // Buffered frames include the first render, which happens before this chunk loads.\n this.observer.observe({ type, buffered: first });\n }\n\n /** Disconnects the observer. */\n uninstall(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n /**\n * Reads the threshold from the configuration and reports a value it can't use.\n * @returns Minimum frame duration to record, in milliseconds.\n */\n private readThreshold(): number {\n const { longFrames } = this.ctx.config.capture;\n const value: unknown =\n typeof longFrames === \"object\" ? longFrames.thresholdMs : LONG_FRAME_THRESHOLD_MS;\n\n if (typeof value === \"number\" && Number.isFinite(value) && value >= 0) {\n return value;\n }\n\n this.ctx.diagnostics.report(\n \"config.invalid\",\n `capture.longFrames.thresholdMs must be a number of 0 or more. The library uses ${String(LONG_FRAME_THRESHOLD_MS)}.`,\n );\n return LONG_FRAME_THRESHOLD_MS;\n }\n\n /**\n * Records one frame at or above the threshold.\n * @param entry Long animation frame or long task entry.\n */\n private record(entry: FrameEntry): void {\n if (entry.duration < this.threshold) {\n return;\n }\n\n const { diagnostics } = this.ctx;\n\n if (\n !allowInWindow(\n this.window,\n this.ctx.config.captureLimits.longFramesPerWindow,\n diagnostics,\n \"long frames\",\n this.ctx.config.captureLimits.windowMs,\n )\n ) {\n return;\n }\n\n const duration = Math.round(entry.duration);\n const attrs: Record<string, unknown> = { \"frame.type\": entry.entryType };\n\n if (entry.blockingDuration !== undefined) {\n attrs[\"frame.blocking_ms\"] = Math.round(entry.blockingDuration);\n }\n\n const script = longestScript(entry.scripts);\n\n // A signed URL is a credential. Only keep the query when fullUrls is on.\n const url = (value: string): string =>\n recordedUrl(\n value,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n diagnostics,\n );\n\n if (script?.invoker) {\n // A script entry's invoker is the script URL. Other invokers, for example\n // \"IMG#hero.onload\", contain a \"#\" that isn't a fragment.\n const { invoker } = script;\n attrs[\"frame.script.invoker\"] = invoker.includes(\"://\") ? url(invoker) : invoker;\n }\n\n if (script?.sourceURL) {\n attrs[\"frame.script.source\"] = url(script.sourceURL);\n }\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"frame\",\n message: `long frame ${String(duration)} ms`,\n });\n this.ctx.logger.logMetric(\"ui.long_frame.duration\", duration, \"ms\", \"histogram\", attrs);\n }\n}\n"],"mappings":";;;;AAWA,IAAME,IAAc,CAAC,wBAAwB,UAAU;AAyBvD,SAASC,EAAc,GAA6D;CAClF,IAAIC;CAEJ,KAAK,IAAMC,KAAUC,KAAW,CAAC,GAC/B,CAAI,CAACF,KAAWC,EAAO,WAAWD,EAAQ,cACxC,IAAUC;CAId,OAAOD;AACT;AAGA,IAAaG,IAAb,MAAiD;CAgB/C,YAAY,GAAsC;EAArB,AAAAN,EAAA,MAAA,OAAA,KAAA,CAAA,GAd7BA,EAAA,MAAA,QAAgB,aAAA,GAGhBA,EAAA,MAAA,YAAA,KAAA,CAAA,GAGAA,EAAA,MAAA,UAAuC;GAAE,OAAO;GAAG,OAAO;EAAE,CAAA,GAG5DA,EAAA,MAAA,aAAA,GAAA,GAK6B,KAAA,MAAAO;CAAsB;CAGnD,UAAgB;EACd,IAAI,KAAK,UACP;EAKF,IAAM,EAAE,YAAS,KAAK,KAChBC,IAAQ,CAACC,EAAK;EACpB,EAAK,aAAa;EAGlB,IAAMC,IACJ,OAAO,sBAAwB,MAC3B,KAAA,IACA,oBAAoB,qBACpBC,IAAOV,EAAY,MAAM,MAASS,GAAW,SAASE,CAAI,CAAC;EAEjE,IAAID,MAAS,KAAA,GAAW;GACtB,IAAI,CAACH,GACH;GA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IC,CAAO,IAAIA;EAC3E;EAWA,AATIlB,GAAQ,cACV,EAAM,yBAAyBiB,EAAIjB,EAAO,SAAS,IAGrD,KAAK,IAAI,YAAY,KAAK;GACxB,GAAG,KAAK,IAAI;GACZ,UAAU;GACV,SAAS,cAAc,OAAOe,CAAQ,EAAE;EAC1C,CAAC,GACD,KAAK,IAAI,OAAO,UAAU,0BAA0BA,GAAU,MAAM,aAAaC,CAAK;CACxF;AACF"}
@@ -1,2 +1,2 @@
1
- const e=require("./platform-CfA3-7sJ.cjs"),t=require("./storm-C-zYSdDX.cjs"),n=require("./defineProperty-X1c4tIPD.cjs");var r=[`long-animation-frame`,`longtask`];function i(e){let t;for(let n of e??[])(!t||n.duration>t.duration)&&(t=n);return t}var a=class{constructor(e){n.t(this,`ctx`,void 0),n.t(this,`name`,`long-frames`),n.t(this,`observer`,void 0),n.t(this,`window`,{start:0,count:0}),n.t(this,`threshold`,100),this.ctx=e}install(){if(this.observer)return;let{once:e}=this.ctx,t=!e.longFrames;e.longFrames=!0;let n=typeof PerformanceObserver>`u`?void 0:PerformanceObserver.supportedEntryTypes,i=r.find(e=>n?.includes(e));if(i===void 0){if(!t)return;this.ctx.diagnostics.report(`capture.install_failed`,`The browser does not report long frames. The long frame capture is off.`)}else this.threshold=this.readThreshold(),this.observer=new PerformanceObserver(e=>{this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a long frame.`,()=>{for(let t of e.getEntries())this.record(t)})}),this.observer.observe({type:i,buffered:t})}uninstall(){this.observer?.disconnect(),this.observer=void 0}readThreshold(){let{longFrames:e}=this.ctx.config.capture,t=typeof e==`object`?e.thresholdMs:100;return typeof t==`number`&&Number.isFinite(t)&&t>=0?t:(this.ctx.diagnostics.report(`config.invalid`,`capture.longFrames.thresholdMs must be a number of 0 or more. The library uses 100.`),100)}record(n){if(n.duration<this.threshold)return;let{diagnostics:r}=this.ctx;if(!t.t(this.window,this.ctx.config.captureLimits.longFramesPerWindow,r,`long frames`,this.ctx.config.captureLimits.windowMs))return;let a=Math.round(n.duration),o={"frame.type":n.entryType};n.blockingDuration!==void 0&&(o[`frame.blocking_ms`]=Math.round(n.blockingDuration));let s=i(n.scripts),c=t=>e.i(t,this.ctx.config.capture.fullUrls,this.ctx.config.capture.urlTransform,r);if(s?.invoker){let{invoker:e}=s;o[`frame.script.invoker`]=e.includes(`://`)?c(e):e}s?.sourceURL&&(o[`frame.script.source`]=c(s.sourceURL)),this.ctx.breadcrumbs.push({t:Date.now(),category:`frame`,message:`long frame ${String(a)} ms`}),this.ctx.logger.logMetric(`ui.long_frame.duration`,a,`ms`,`histogram`,o)}};exports.LongFrameCapture=a;
2
- //# sourceMappingURL=long-frames-BUUbXd-B.cjs.map
1
+ const e=require("./platform-BZjp9wp1.cjs"),t=require("./storm-qiE_AMC7.cjs"),n=require("./defineProperty-X1c4tIPD.cjs");var r=[`long-animation-frame`,`longtask`];function i(e){let t;for(let n of e??[])(!t||n.duration>t.duration)&&(t=n);return t}var a=class{constructor(e){n.t(this,`ctx`,void 0),n.t(this,`name`,`long-frames`),n.t(this,`observer`,void 0),n.t(this,`window`,{start:0,count:0}),n.t(this,`threshold`,100),this.ctx=e}install(){if(this.observer)return;let{once:e}=this.ctx,t=!e.longFrames;e.longFrames=!0;let n=typeof PerformanceObserver>`u`?void 0:PerformanceObserver.supportedEntryTypes,i=r.find(e=>n?.includes(e));if(i===void 0){if(!t)return;this.ctx.diagnostics.report(`capture.install_failed`,`The browser does not report long frames. The long frame capture is off.`)}else this.threshold=this.readThreshold(),this.observer=new PerformanceObserver(e=>{this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a long frame.`,()=>{for(let t of e.getEntries())this.record(t)})}),this.observer.observe({type:i,buffered:t})}uninstall(){this.observer?.disconnect(),this.observer=void 0}readThreshold(){let{longFrames:e}=this.ctx.config.capture,t=typeof e==`object`?e.thresholdMs:100;return typeof t==`number`&&Number.isFinite(t)&&t>=0?t:(this.ctx.diagnostics.report(`config.invalid`,`capture.longFrames.thresholdMs must be a number of 0 or more. The library uses 100.`),100)}record(n){if(n.duration<this.threshold)return;let{diagnostics:r}=this.ctx;if(!t.t(this.window,this.ctx.config.captureLimits.longFramesPerWindow,r,`long frames`,this.ctx.config.captureLimits.windowMs))return;let a=Math.round(n.duration),o={"frame.type":n.entryType};n.blockingDuration!==void 0&&(o[`frame.blocking_ms`]=Math.round(n.blockingDuration));let s=i(n.scripts),c=t=>e.a(t,this.ctx.config.capture.fullUrls,this.ctx.config.capture.urlTransform,r);if(s?.invoker){let{invoker:e}=s;o[`frame.script.invoker`]=e.includes(`://`)?c(e):e}s?.sourceURL&&(o[`frame.script.source`]=c(s.sourceURL)),this.ctx.breadcrumbs.push({t:Date.now(),category:`frame`,message:`long frame ${String(a)} ms`}),this.ctx.logger.logMetric(`ui.long_frame.duration`,a,`ms`,`histogram`,o)}};exports.LongFrameCapture=a;
2
+ //# sourceMappingURL=long-frames-D9DfSWqv.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"long-frames-BUUbXd-B.cjs","names":["allowInWindow","recordedUrl","require_platform","require_storm","require_defineProperty","FRAME_TYPES","longestScript","longest","script","scripts","LongFrameCapture","ctx","first","once","supported","type","name","entry","list","value","longFrames","diagnostics","duration","attrs","url","invoker"],"sources":["../src/capture/long-frames.ts"],"sourcesContent":["// src/capture/long-frames.ts\n//\n// Reports long animation frames. A long frame can freeze the page with no user input involved,\n// for example a grid that re-renders 5,000 rows, and INP never shows that.\n\nimport { LONG_FRAME_THRESHOLD_MS } from \"../constants\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** The entry types this capture can observe, best first. */\nconst FRAME_TYPES = [\"long-animation-frame\", \"longtask\"];\n\n/** One script in a long animation frame. Some versions of the DOM types don't declare it. */\ninterface FrameScript {\n /** How long the script ran, in milliseconds. */\n duration: number;\n /** What called the script, for example an event listener or a timer. */\n invoker?: string;\n /** URL of the script's source. */\n sourceURL?: string;\n}\n\n/** A long animation frame or a long task. A long task has no blocking time and no scripts. */\ninterface FrameEntry extends PerformanceEntry {\n /** How long the frame blocked input, in milliseconds. */\n blockingDuration?: number;\n /** Scripts that ran in the frame. */\n scripts?: FrameScript[];\n}\n\n/**\n * Finds the script that ran longest in a frame.\n * @param scripts The frame's scripts.\n * @returns The longest script, or undefined if the frame has none.\n */\nfunction longestScript(scripts: FrameScript[] | undefined): FrameScript | undefined {\n let longest: FrameScript | undefined;\n\n for (const script of scripts ?? []) {\n if (!longest || script.duration > longest.duration) {\n longest = script;\n }\n }\n\n return longest;\n}\n\n/** Records every long animation frame as a histogram metric and a breadcrumb. */\nexport class LongFrameCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"long-frames\";\n\n /** Active observer. Undefined while the capture isn't installed. */\n private observer: PerformanceObserver | undefined;\n\n /** This capture's own rate limit, so a frozen tab can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /** Minimum frame duration to record, in milliseconds. */\n private threshold = LONG_FRAME_THRESHOLD_MS;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Observes the best entry type the browser supports. */\n install(): void {\n if (this.observer) {\n return;\n }\n\n // Only the first install in a document reads buffered frames or reports missing support,\n // so a reinstall after configure() doesn't repeat either.\n const { once } = this.ctx;\n const first = !once.longFrames;\n once.longFrames = true;\n\n // Older browsers have no supportedEntryTypes, and the capture stays off there.\n const supported: readonly string[] | undefined =\n typeof PerformanceObserver === \"undefined\"\n ? undefined\n : PerformanceObserver.supportedEntryTypes;\n const type = FRAME_TYPES.find((name) => supported?.includes(name));\n\n if (type === undefined) {\n if (!first) {\n return;\n }\n\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not report long frames. The long frame capture is off.\",\n );\n return;\n }\n\n this.threshold = this.readThreshold();\n this.observer = new PerformanceObserver((list) => {\n // The browser calls this directly, so anything we throw is an uncaught error on the page.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a long frame.\",\n () => {\n for (const entry of list.getEntries()) {\n this.record(entry);\n }\n },\n );\n });\n\n // Buffered frames include the first render, which happens before this chunk loads.\n this.observer.observe({ type, buffered: first });\n }\n\n /** Disconnects the observer. */\n uninstall(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n /**\n * Reads the threshold from the configuration and reports a value it can't use.\n * @returns Minimum frame duration to record, in milliseconds.\n */\n private readThreshold(): number {\n const { longFrames } = this.ctx.config.capture;\n const value: unknown =\n typeof longFrames === \"object\" ? longFrames.thresholdMs : LONG_FRAME_THRESHOLD_MS;\n\n if (typeof value === \"number\" && Number.isFinite(value) && value >= 0) {\n return value;\n }\n\n this.ctx.diagnostics.report(\n \"config.invalid\",\n `capture.longFrames.thresholdMs must be a number of 0 or more. The library uses ${String(LONG_FRAME_THRESHOLD_MS)}.`,\n );\n return LONG_FRAME_THRESHOLD_MS;\n }\n\n /**\n * Records one frame at or above the threshold.\n * @param entry Long animation frame or long task entry.\n */\n private record(entry: FrameEntry): void {\n if (entry.duration < this.threshold) {\n return;\n }\n\n const { diagnostics } = this.ctx;\n\n if (\n !allowInWindow(\n this.window,\n this.ctx.config.captureLimits.longFramesPerWindow,\n diagnostics,\n \"long frames\",\n this.ctx.config.captureLimits.windowMs,\n )\n ) {\n return;\n }\n\n const duration = Math.round(entry.duration);\n const attrs: Record<string, unknown> = { \"frame.type\": entry.entryType };\n\n if (entry.blockingDuration !== undefined) {\n attrs[\"frame.blocking_ms\"] = Math.round(entry.blockingDuration);\n }\n\n const script = longestScript(entry.scripts);\n\n // A signed URL is a credential. Only keep the query when fullUrls is on.\n const url = (value: string): string =>\n recordedUrl(\n value,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n diagnostics,\n );\n\n if (script?.invoker) {\n // A script entry's invoker is the script URL. Other invokers, for example\n // \"IMG#hero.onload\", contain a \"#\" that isn't a fragment.\n const { invoker } = script;\n attrs[\"frame.script.invoker\"] = invoker.includes(\"://\") ? url(invoker) : invoker;\n }\n\n if (script?.sourceURL) {\n attrs[\"frame.script.source\"] = url(script.sourceURL);\n }\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"frame\",\n message: `long frame ${String(duration)} ms`,\n });\n this.ctx.logger.logMetric(\"ui.long_frame.duration\", duration, \"ms\", \"histogram\", attrs);\n }\n}\n"],"mappings":"A,wHAWA,IAAMK,EAAc,CAAC,uBAAwB,UAAU,EAyBvD,SAASC,EAAc,EAA6D,CAClF,IAAIC,EAEJ,IAAK,IAAMC,KAAUC,GAAW,CAAC,GAC3B,CAACF,GAAWC,EAAO,SAAWD,EAAQ,YACxC,EAAUC,GAId,OAAOD,CACT,CAGA,IAAaG,EAAb,KAAiD,CAgB/C,YAAY,EAAsC,CAArBN,EAAA,EAAA,KAAA,MAAA,IAAA,EAAA,EAd7BA,EAAA,EAAA,KAAA,OAAgB,aAAA,EAGhBA,EAAA,EAAA,KAAA,WAAA,IAAA,EAAA,EAGAA,EAAA,EAAA,KAAA,SAAuC,CAAE,MAAO,EAAG,MAAO,CAAE,CAAA,EAG5DA,EAAA,EAAA,KAAA,YAAA,GAAA,EAK6B,KAAA,IAAAO,CAAsB,CAGnD,SAAgB,CACd,GAAI,KAAK,SACP,OAKF,GAAM,CAAE,QAAS,KAAK,IAChBC,EAAQ,CAACC,EAAK,WACpB,EAAK,WAAa,GAGlB,IAAMC,EACJ,OAAO,oBAAwB,IAC3B,IAAA,GACA,oBAAoB,oBACpBC,EAAOV,EAAY,KAAM,GAASS,GAAW,SAASE,CAAI,CAAC,EAEjE,GAAID,IAAS,IAAA,GAAW,CACtB,GAAI,CAACH,EACH,OAGF,KAAK,IAAI,YAAY,OACnB,yBACA,yEACF,CAEF,KAEA,MAAK,UAAY,KAAK,cAAc,EACpC,KAAK,SAAW,IAAI,oBAAqB,GAAS,CAEhD,KAAK,IAAI,YAAY,MACnB,wBACA,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,cAAc,OAAOc,CAAQ,EAAE,IAC1C,CAAC,EACD,KAAK,IAAI,OAAO,UAAU,yBAA0BA,EAAU,KAAM,YAAaC,CAAK,CACxF,CACF,E"}
1
+ {"version":3,"file":"long-frames-D9DfSWqv.cjs","names":["allowInWindow","recordedUrl","require_platform","require_storm","require_defineProperty","FRAME_TYPES","longestScript","longest","script","scripts","LongFrameCapture","ctx","first","once","supported","type","name","entry","list","value","longFrames","diagnostics","duration","attrs","url","invoker"],"sources":["../src/capture/long-frames.ts"],"sourcesContent":["// src/capture/long-frames.ts\n//\n// Reports long animation frames. A long frame can freeze the page with no user input involved,\n// for example a grid that re-renders 5,000 rows, and INP never shows that.\n\nimport { LONG_FRAME_THRESHOLD_MS } from \"../constants\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** The entry types this capture can observe, best first. */\nconst FRAME_TYPES = [\"long-animation-frame\", \"longtask\"];\n\n/** One script in a long animation frame. Some versions of the DOM types don't declare it. */\ninterface FrameScript {\n /** How long the script ran, in milliseconds. */\n duration: number;\n /** What called the script, for example an event listener or a timer. */\n invoker?: string;\n /** URL of the script's source. */\n sourceURL?: string;\n}\n\n/** A long animation frame or a long task. A long task has no blocking time and no scripts. */\ninterface FrameEntry extends PerformanceEntry {\n /** How long the frame blocked input, in milliseconds. */\n blockingDuration?: number;\n /** Scripts that ran in the frame. */\n scripts?: FrameScript[];\n}\n\n/**\n * Finds the script that ran longest in a frame.\n * @param scripts The frame's scripts.\n * @returns The longest script, or undefined if the frame has none.\n */\nfunction longestScript(scripts: FrameScript[] | undefined): FrameScript | undefined {\n let longest: FrameScript | undefined;\n\n for (const script of scripts ?? []) {\n if (!longest || script.duration > longest.duration) {\n longest = script;\n }\n }\n\n return longest;\n}\n\n/** Records every long animation frame as a histogram metric and a breadcrumb. */\nexport class LongFrameCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"long-frames\";\n\n /** Active observer. Undefined while the capture isn't installed. */\n private observer: PerformanceObserver | undefined;\n\n /** This capture's own rate limit, so a frozen tab can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /** Minimum frame duration to record, in milliseconds. */\n private threshold = LONG_FRAME_THRESHOLD_MS;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Observes the best entry type the browser supports. */\n install(): void {\n if (this.observer) {\n return;\n }\n\n // Only the first install in a document reads buffered frames or reports missing support,\n // so a reinstall after configure() doesn't repeat either.\n const { once } = this.ctx;\n const first = !once.longFrames;\n once.longFrames = true;\n\n // Older browsers have no supportedEntryTypes, and the capture stays off there.\n const supported: readonly string[] | undefined =\n typeof PerformanceObserver === \"undefined\"\n ? undefined\n : PerformanceObserver.supportedEntryTypes;\n const type = FRAME_TYPES.find((name) => supported?.includes(name));\n\n if (type === undefined) {\n if (!first) {\n return;\n }\n\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not report long frames. The long frame capture is off.\",\n );\n return;\n }\n\n this.threshold = this.readThreshold();\n this.observer = new PerformanceObserver((list) => {\n // The browser calls this directly, so anything we throw is an uncaught error on the page.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a long frame.\",\n () => {\n for (const entry of list.getEntries()) {\n this.record(entry);\n }\n },\n );\n });\n\n // Buffered frames include the first render, which happens before this chunk loads.\n this.observer.observe({ type, buffered: first });\n }\n\n /** Disconnects the observer. */\n uninstall(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n /**\n * Reads the threshold from the configuration and reports a value it can't use.\n * @returns Minimum frame duration to record, in milliseconds.\n */\n private readThreshold(): number {\n const { longFrames } = this.ctx.config.capture;\n const value: unknown =\n typeof longFrames === \"object\" ? longFrames.thresholdMs : LONG_FRAME_THRESHOLD_MS;\n\n if (typeof value === \"number\" && Number.isFinite(value) && value >= 0) {\n return value;\n }\n\n this.ctx.diagnostics.report(\n \"config.invalid\",\n `capture.longFrames.thresholdMs must be a number of 0 or more. The library uses ${String(LONG_FRAME_THRESHOLD_MS)}.`,\n );\n return LONG_FRAME_THRESHOLD_MS;\n }\n\n /**\n * Records one frame at or above the threshold.\n * @param entry Long animation frame or long task entry.\n */\n private record(entry: FrameEntry): void {\n if (entry.duration < this.threshold) {\n return;\n }\n\n const { diagnostics } = this.ctx;\n\n if (\n !allowInWindow(\n this.window,\n this.ctx.config.captureLimits.longFramesPerWindow,\n diagnostics,\n \"long frames\",\n this.ctx.config.captureLimits.windowMs,\n )\n ) {\n return;\n }\n\n const duration = Math.round(entry.duration);\n const attrs: Record<string, unknown> = { \"frame.type\": entry.entryType };\n\n if (entry.blockingDuration !== undefined) {\n attrs[\"frame.blocking_ms\"] = Math.round(entry.blockingDuration);\n }\n\n const script = longestScript(entry.scripts);\n\n // A signed URL is a credential. Only keep the query when fullUrls is on.\n const url = (value: string): string =>\n recordedUrl(\n value,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n diagnostics,\n );\n\n if (script?.invoker) {\n // A script entry's invoker is the script URL. Other invokers, for example\n // \"IMG#hero.onload\", contain a \"#\" that isn't a fragment.\n const { invoker } = script;\n attrs[\"frame.script.invoker\"] = invoker.includes(\"://\") ? url(invoker) : invoker;\n }\n\n if (script?.sourceURL) {\n attrs[\"frame.script.source\"] = url(script.sourceURL);\n }\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"frame\",\n message: `long frame ${String(duration)} ms`,\n });\n this.ctx.logger.logMetric(\"ui.long_frame.duration\", duration, \"ms\", \"histogram\", attrs);\n }\n}\n"],"mappings":"A,wHAWA,IAAMK,EAAc,CAAC,uBAAwB,UAAU,EAyBvD,SAASC,EAAc,EAA6D,CAClF,IAAIC,EAEJ,IAAK,IAAMC,KAAUC,GAAW,CAAC,GAC3B,CAACF,GAAWC,EAAO,SAAWD,EAAQ,YACxC,EAAUC,GAId,OAAOD,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EAAM,SAAW,KAAK,UACxB,OAGF,GAAM,CAAE,eAAgB,KAAK,IAE7B,GACE,CAACjB,EAAAA,EACC,KAAK,OACL,KAAK,IAAI,OAAO,cAAc,oBAC9BqB,EACA,cACA,KAAK,IAAI,OAAO,cAAc,QAChC,EAEA,OAGF,IAAMC,EAAW,KAAK,MAAML,EAAM,QAAQ,EACpCM,EAAiC,CAAE,aAAcN,EAAM,SAAU,EAEnEA,EAAM,mBAAqB,IAAA,KAC7B,EAAM,qBAAuB,KAAK,MAAMA,EAAM,gBAAgB,GAGhE,IAAMT,EAASF,EAAcW,EAAM,OAAO,EAGpCO,EAAO,GACXvB,EAAAA,EACEkB,EACA,KAAK,IAAI,OAAO,QAAQ,SACxB,KAAK,IAAI,OAAO,QAAQ,aACxBE,CACF,EAEF,GAAIb,GAAQ,QAAS,CAGnB,GAAM,CAAE,WAAYA,EACpB,EAAM,wBAA0BiB,EAAQ,SAAS,KAAK,EAAID,EAAIC,CAAO,EAAIA,CAC3E,CAEIjB,GAAQ,YACV,EAAM,uBAAyBgB,EAAIhB,EAAO,SAAS,GAGrD,KAAK,IAAI,YAAY,KAAK,CACxB,EAAG,KAAK,IAAI,EACZ,SAAU,QACV,QAAS,cAAc,OAAOc,CAAQ,EAAE,IAC1C,CAAC,EACD,KAAK,IAAI,OAAO,UAAU,yBAA0BA,EAAU,KAAM,YAAaC,CAAK,CACxF,CACF,E"}
@@ -92,11 +92,16 @@ export type BusMessage =
92
92
  t: typeof BUS_TYPE.journeyRequest;
93
93
  from: string;
94
94
  }
95
- /** Tab identifier claim broadcast to detect collisions across windows. */
95
+ /**
96
+ * Tab identifier claim broadcast to detect collisions across windows. `since` is the
97
+ * document's `performance.timeOrigin`, so the older document keeps the id. An older library
98
+ * sends none.
99
+ */
96
100
  | {
97
101
  t: typeof BUS_TYPE.tab;
98
102
  from: string;
99
103
  tabId: string;
104
+ since?: number;
100
105
  }
101
106
  /** A forwarder's request for the current remote sampling rules. */
102
107
  | {
@@ -92,11 +92,16 @@ export type BusMessage =
92
92
  t: typeof BUS_TYPE.journeyRequest;
93
93
  from: string;
94
94
  }
95
- /** Tab identifier claim broadcast to detect collisions across windows. */
95
+ /**
96
+ * Tab identifier claim broadcast to detect collisions across windows. `since` is the
97
+ * document's `performance.timeOrigin`, so the older document keeps the id. An older library
98
+ * sends none.
99
+ */
96
100
  | {
97
101
  t: typeof BUS_TYPE.tab;
98
102
  from: string;
99
103
  tabId: string;
104
+ since?: number;
100
105
  }
101
106
  /** A forwarder's request for the current remote sampling rules. */
102
107
  | {