@utk09/ui-observability 0.12.0 → 1.1.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 (523) hide show
  1. package/CHANGELOG.md +280 -10
  2. package/README.md +70 -839
  3. package/dist/{batch-BjQUwjA6.js → batch-D3NHhF9L.js} +4 -4
  4. package/dist/{batch-BjQUwjA6.js.map → batch-D3NHhF9L.js.map} +1 -1
  5. package/dist/{batch-D5LlU4Q9.cjs → batch-DnYRJqhU.cjs} +2 -2
  6. package/dist/{batch-D5LlU4Q9.cjs.map → batch-DnYRJqhU.cjs.map} +1 -1
  7. package/dist/bus/bus.d.cts +355 -0
  8. package/dist/bus/bus.d.ts +86 -12
  9. package/dist/bus/links.d.cts +132 -0
  10. package/dist/bus/links.d.ts +18 -3
  11. package/dist/bus/validation.d.cts +16 -0
  12. package/dist/bus/validation.d.ts +10 -1
  13. package/dist/bus-B__467mL.cjs +2 -0
  14. package/dist/bus-B__467mL.cjs.map +1 -0
  15. package/dist/bus-dw7T92sO.js +788 -0
  16. package/dist/bus-dw7T92sO.js.map +1 -0
  17. package/dist/capture/console.d.cts +37 -0
  18. package/dist/capture/console.d.ts +1 -1
  19. package/dist/capture/errors.d.cts +32 -0
  20. package/dist/capture/errors.d.ts +1 -1
  21. package/dist/capture/interactions.d.cts +80 -0
  22. package/dist/capture/interactions.d.ts +36 -4
  23. package/dist/capture/lifecycle.d.cts +20 -0
  24. package/dist/capture/lifecycle.d.ts +1 -1
  25. package/dist/capture/long-frames.d.cts +31 -0
  26. package/dist/capture/long-frames.d.ts +1 -1
  27. package/dist/capture/network.d.cts +57 -0
  28. package/dist/capture/network.d.ts +1 -1
  29. package/dist/capture/observed-windows.d.cts +51 -0
  30. package/dist/capture/observed-windows.d.ts +51 -0
  31. package/dist/capture/profiler-frames.d.cts +44 -0
  32. package/dist/capture/profiler-frames.d.ts +1 -1
  33. package/dist/capture/replay-buffer.d.cts +45 -0
  34. package/dist/capture/replay-buffer.d.ts +9 -10
  35. package/dist/capture/replay-upload.d.cts +79 -0
  36. package/dist/capture/replay-upload.d.ts +7 -2
  37. package/dist/capture/replay.d.cts +114 -0
  38. package/dist/capture/replay.d.ts +1 -1
  39. package/dist/capture/reports.d.cts +17 -0
  40. package/dist/capture/reports.d.ts +1 -1
  41. package/dist/capture/resource-timing.d.cts +14 -0
  42. package/dist/capture/resource-timing.d.ts +1 -1
  43. package/dist/capture/server-timing.d.cts +19 -0
  44. package/dist/capture/storm.d.cts +13 -0
  45. package/dist/capture/storm.d.ts +5 -5
  46. package/dist/capture/types.d.cts +128 -0
  47. package/dist/capture/types.d.ts +10 -9
  48. package/dist/capture/unclean-exit.d.cts +31 -0
  49. package/dist/capture/unclean-exit.d.ts +1 -1
  50. package/dist/capture/user-timing.d.cts +22 -0
  51. package/dist/capture/user-timing.d.ts +2 -2
  52. package/dist/capture/web-socket.d.cts +40 -0
  53. package/dist/capture/web-socket.d.ts +3 -3
  54. package/dist/capture/web-vitals.d.cts +40 -0
  55. package/dist/capture/web-vitals.d.ts +1 -1
  56. package/dist/{compression-lD9abCcO.cjs → compression-C0hUHKR-.cjs} +2 -2
  57. package/dist/{compression-lD9abCcO.cjs.map → compression-C0hUHKR-.cjs.map} +1 -1
  58. package/dist/{compression-AJJCMBOa.js → compression-SHPAvS4U.js} +2 -2
  59. package/dist/{compression-AJJCMBOa.js.map → compression-SHPAvS4U.js.map} +1 -1
  60. package/dist/config-CSNcS7OZ.js +558 -0
  61. package/dist/config-CSNcS7OZ.js.map +1 -0
  62. package/dist/config-CybPP5VM.cjs +2 -0
  63. package/dist/config-CybPP5VM.cjs.map +1 -0
  64. package/dist/console-BsM-fSCQ.js +81 -0
  65. package/dist/console-BsM-fSCQ.js.map +1 -0
  66. package/dist/console-Dkxs6IVQ.cjs +2 -0
  67. package/dist/console-Dkxs6IVQ.cjs.map +1 -0
  68. package/dist/constants-BwJDXzj6.js +357 -0
  69. package/dist/constants-BwJDXzj6.js.map +1 -0
  70. package/dist/constants-CtF52hIV.cjs +2 -0
  71. package/dist/constants-CtF52hIV.cjs.map +1 -0
  72. package/dist/constants.d.cts +763 -0
  73. package/dist/constants.d.ts +100 -20
  74. package/dist/core/breadcrumbs.d.cts +54 -0
  75. package/dist/core/breadcrumbs.d.ts +5 -0
  76. package/dist/core/config.d.cts +45 -0
  77. package/dist/core/config.d.ts +30 -2
  78. package/dist/core/context.d.cts +24 -0
  79. package/dist/core/context.d.ts +3 -8
  80. package/dist/core/debug-buffer.d.cts +34 -0
  81. package/dist/core/debug-buffer.d.ts +3 -3
  82. package/dist/core/debug-bundle.d.cts +12 -0
  83. package/dist/core/debug-bundle.d.ts +3 -3
  84. package/dist/core/deferred.d.cts +7 -0
  85. package/dist/core/deferred.d.ts +2 -2
  86. package/dist/core/diagnostics.d.cts +86 -0
  87. package/dist/core/diagnostics.d.ts +1 -1
  88. package/dist/core/drops.d.cts +39 -0
  89. package/dist/core/drops.d.ts +16 -6
  90. package/dist/core/hold-buffer.d.cts +36 -0
  91. package/dist/core/hold-buffer.d.ts +16 -7
  92. package/dist/core/journey.d.cts +148 -0
  93. package/dist/core/journey.d.ts +7 -7
  94. package/dist/core/logger.d.cts +141 -0
  95. package/dist/core/logger.d.ts +23 -30
  96. package/dist/core/measure.d.cts +30 -0
  97. package/dist/core/measure.d.ts +14 -3
  98. package/dist/core/meter.d.cts +78 -0
  99. package/dist/core/meter.d.ts +14 -8
  100. package/dist/core/pipeline.d.cts +227 -0
  101. package/dist/core/pipeline.d.ts +73 -10
  102. package/dist/core/profile-buckets.d.cts +31 -0
  103. package/dist/core/profiler.d.cts +218 -0
  104. package/dist/core/profiler.d.ts +2 -2
  105. package/dist/core/record.d.cts +190 -0
  106. package/dist/core/record.d.ts +44 -12
  107. package/dist/core/remote-rules.d.cts +17 -0
  108. package/dist/core/remote-rules.d.ts +3 -3
  109. package/dist/core/remote-sampling.d.cts +74 -0
  110. package/dist/core/remote-sampling.d.ts +3 -3
  111. package/dist/core/rotation.d.cts +99 -0
  112. package/dist/core/rotation.d.ts +99 -0
  113. package/dist/core/runtime.d.cts +774 -0
  114. package/dist/core/runtime.d.ts +254 -70
  115. package/dist/core/sampling.d.cts +86 -0
  116. package/dist/core/sampling.d.ts +5 -5
  117. package/dist/core/sender.d.cts +161 -0
  118. package/dist/core/sender.d.ts +59 -15
  119. package/dist/core/spans.d.cts +39 -0
  120. package/dist/core/spans.d.ts +1 -1
  121. package/dist/debug-bundle-B2v6Cym-.cjs +2 -0
  122. package/dist/debug-bundle-B2v6Cym-.cjs.map +1 -0
  123. package/dist/debug-bundle-Cs_YWzTa.js +35 -0
  124. package/dist/debug-bundle-Cs_YWzTa.js.map +1 -0
  125. package/dist/defineProperty-X1c4tIPD.cjs +1 -0
  126. package/dist/defineProperty-s2S8BXUc.js +35 -0
  127. package/dist/doctor.cjs +1 -1
  128. package/dist/doctor.cjs.map +1 -1
  129. package/dist/doctor.d.cts +36 -0
  130. package/dist/doctor.d.ts +5 -2
  131. package/dist/doctor.js +119 -87
  132. package/dist/doctor.js.map +1 -1
  133. package/dist/errors-DP2RUm4V.cjs +3 -0
  134. package/dist/errors-DP2RUm4V.cjs.map +1 -0
  135. package/dist/errors-Q3Ng1ciC.js +86 -0
  136. package/dist/errors-Q3Ng1ciC.js.map +1 -0
  137. package/dist/factory-DV17sm2p.js +404 -0
  138. package/dist/factory-DV17sm2p.js.map +1 -0
  139. package/dist/factory-K8O6gpux.cjs +2 -0
  140. package/dist/factory-K8O6gpux.cjs.map +1 -0
  141. package/dist/guards-BlYGRK4l.js +10 -0
  142. package/dist/guards-BlYGRK4l.js.map +1 -0
  143. package/dist/guards-EjG3ahFp.cjs +2 -0
  144. package/dist/guards-EjG3ahFp.cjs.map +1 -0
  145. package/dist/{identity-BrQp_5J5.js → identity-BgtHyY4u.js} +33 -26
  146. package/dist/identity-BgtHyY4u.js.map +1 -0
  147. package/dist/identity-CvuyqZk7.cjs +2 -0
  148. package/dist/identity-CvuyqZk7.cjs.map +1 -0
  149. package/dist/index.cjs +1 -1
  150. package/dist/index.cjs.map +1 -1
  151. package/dist/index.d.cts +301 -0
  152. package/dist/index.d.ts +90 -98
  153. package/dist/index.js +1253 -1555
  154. package/dist/index.js.map +1 -1
  155. package/dist/indexeddb-storage-D4KVcqdD.cjs +2 -0
  156. package/dist/indexeddb-storage-D4KVcqdD.cjs.map +1 -0
  157. package/dist/{indexeddb-storage-DLXQzAGh.js → indexeddb-storage-e-13ZLWm.js} +61 -57
  158. package/dist/indexeddb-storage-e-13ZLWm.js.map +1 -0
  159. package/dist/interactions-Byxf1C82.js +207 -0
  160. package/dist/interactions-Byxf1C82.js.map +1 -0
  161. package/dist/interactions-OK85T-Dk.cjs +2 -0
  162. package/dist/interactions-OK85T-Dk.cjs.map +1 -0
  163. package/dist/{journey-35yCMNFo.js → journey-C93FTYcs.js} +46 -49
  164. package/dist/journey-C93FTYcs.js.map +1 -0
  165. package/dist/journey-nMbob3OB.cjs +2 -0
  166. package/dist/journey-nMbob3OB.cjs.map +1 -0
  167. package/dist/{library-console-BFWEuQsl.cjs → library-console-DJUQzcgM.cjs} +2 -2
  168. package/dist/{library-console-BFWEuQsl.cjs.map → library-console-DJUQzcgM.cjs.map} +1 -1
  169. package/dist/{library-console-Dl_Ly6DQ.js → library-console-DklSmucS.js} +2 -2
  170. package/dist/{library-console-Dl_Ly6DQ.js.map → library-console-DklSmucS.js.map} +1 -1
  171. package/dist/{library-request-nI6pvI6I.js → library-request-UGEwOHpf.js} +2 -2
  172. package/dist/{library-request-nI6pvI6I.js.map → library-request-UGEwOHpf.js.map} +1 -1
  173. package/dist/{library-request-Da-CHKzT.cjs → library-request-kY9iTpIF.cjs} +2 -2
  174. package/dist/{library-request-Da-CHKzT.cjs.map → library-request-kY9iTpIF.cjs.map} +1 -1
  175. package/dist/{lifecycle-CZ6RRXc6.js → lifecycle-B2PlIuQu.js} +21 -29
  176. package/dist/lifecycle-B2PlIuQu.js.map +1 -0
  177. package/dist/lifecycle-DaMdH_X7.cjs +2 -0
  178. package/dist/lifecycle-DaMdH_X7.cjs.map +1 -0
  179. package/dist/log-record-Bmx6etMh.cjs +2 -0
  180. package/dist/log-record-Bmx6etMh.cjs.map +1 -0
  181. package/dist/{log-record-DIA6McNr.js → log-record-DSt2P-Sr.js} +8 -7
  182. package/dist/log-record-DSt2P-Sr.js.map +1 -0
  183. package/dist/{long-frames-430_85Da.js → long-frames-Bamjs1WV.js} +18 -22
  184. package/dist/long-frames-Bamjs1WV.js.map +1 -0
  185. package/dist/long-frames-lhtONgGt.cjs +2 -0
  186. package/dist/long-frames-lhtONgGt.cjs.map +1 -0
  187. package/dist/models/batch.d.cts +57 -0
  188. package/dist/models/batch.d.ts +2 -2
  189. package/dist/models/bus.d.cts +163 -0
  190. package/dist/models/bus.d.ts +28 -3
  191. package/dist/models/config.d.cts +1555 -0
  192. package/dist/models/config.d.ts +377 -261
  193. package/dist/models/drop.d.cts +54 -0
  194. package/dist/models/drop.d.ts +16 -3
  195. package/dist/models/health.d.cts +148 -0
  196. package/dist/models/health.d.ts +108 -12
  197. package/dist/models/log-record.d.cts +61 -0
  198. package/dist/models/metric.d.cts +139 -0
  199. package/dist/models/metric.d.ts +13 -2
  200. package/dist/models/plugin.d.cts +47 -0
  201. package/dist/models/plugin.d.ts +3 -3
  202. package/dist/models/replay.d.cts +60 -0
  203. package/dist/models/serializer.d.cts +25 -0
  204. package/dist/models/serializer.d.ts +4 -2
  205. package/dist/models/storage.d.cts +95 -0
  206. package/dist/models/storage.d.ts +7 -5
  207. package/dist/network-BCn8Gn47.cjs +2 -0
  208. package/dist/network-BCn8Gn47.cjs.map +1 -0
  209. package/dist/{network-C7SkLf4v.js → network-Cg1L2w2r.js} +57 -57
  210. package/dist/network-Cg1L2w2r.js.map +1 -0
  211. package/dist/observed-windows-B3gJkdql.cjs +2 -0
  212. package/dist/observed-windows-B3gJkdql.cjs.map +1 -0
  213. package/dist/observed-windows-BrwaJNlj.js +64 -0
  214. package/dist/observed-windows-BrwaJNlj.js.map +1 -0
  215. package/dist/{otlp-2MCrC3kd.cjs → otlp-CrAWkQdO.cjs} +2 -2
  216. package/dist/{otlp-2MCrC3kd.cjs.map → otlp-CrAWkQdO.cjs.map} +1 -1
  217. package/dist/{otlp-COq033e3.js → otlp-D6dRZyB8.js} +9 -9
  218. package/dist/{otlp-COq033e3.js.map → otlp-D6dRZyB8.js.map} +1 -1
  219. package/dist/{platform-CVewe4wQ.js → platform-8DLhjddo.js} +9 -9
  220. package/dist/{platform-CVewe4wQ.js.map → platform-8DLhjddo.js.map} +1 -1
  221. package/dist/{platform-12uR7kBQ.cjs → platform-BqRc-7RO.cjs} +2 -2
  222. package/dist/{platform-12uR7kBQ.cjs.map → platform-BqRc-7RO.cjs.map} +1 -1
  223. package/dist/{profiler-BVWIOgnq.js → profiler-BaXSqCfz.js} +78 -96
  224. package/dist/profiler-BaXSqCfz.js.map +1 -0
  225. package/dist/profiler-BvWW2kNM.cjs +2 -0
  226. package/dist/profiler-BvWW2kNM.cjs.map +1 -0
  227. package/dist/{profiler-frames-CLXlT_xL.js → profiler-frames-C4ySHN0X.js} +21 -29
  228. package/dist/profiler-frames-C4ySHN0X.js.map +1 -0
  229. package/dist/profiler-frames-DeaBiB-5.cjs +2 -0
  230. package/dist/profiler-frames-DeaBiB-5.cjs.map +1 -0
  231. package/dist/remote-rules-D7L6D_D2.cjs +2 -0
  232. package/dist/remote-rules-D7L6D_D2.cjs.map +1 -0
  233. package/dist/remote-rules-Dq9xe7Qn.js +95 -0
  234. package/dist/remote-rules-Dq9xe7Qn.js.map +1 -0
  235. package/dist/replay-B0M8kWz_.js +310 -0
  236. package/dist/replay-B0M8kWz_.js.map +1 -0
  237. package/dist/replay-QOFBpAXh.cjs +2 -0
  238. package/dist/replay-QOFBpAXh.cjs.map +1 -0
  239. package/dist/{reports-BuXekPOS.js → reports--8APRLa-.js} +25 -30
  240. package/dist/reports--8APRLa-.js.map +1 -0
  241. package/dist/reports-ojuMKGO7.cjs +2 -0
  242. package/dist/reports-ojuMKGO7.cjs.map +1 -0
  243. package/dist/{resource-timing-CXGHwFRD.js → resource-timing-BzR05rE-.js} +20 -23
  244. package/dist/resource-timing-BzR05rE-.js.map +1 -0
  245. package/dist/resource-timing-pAG3ZhB5.cjs +2 -0
  246. package/dist/resource-timing-pAG3ZhB5.cjs.map +1 -0
  247. package/dist/response-body-BWvwKQ2p.js +331 -0
  248. package/dist/response-body-BWvwKQ2p.js.map +1 -0
  249. package/dist/response-body-CKEJ5itk.cjs +3 -0
  250. package/dist/response-body-CKEJ5itk.cjs.map +1 -0
  251. package/dist/rotation-BylN1B9e.js +93 -0
  252. package/dist/rotation-BylN1B9e.js.map +1 -0
  253. package/dist/rotation-E2eKClIs.cjs +2 -0
  254. package/dist/rotation-E2eKClIs.cjs.map +1 -0
  255. package/dist/sampling-B46LW0cy.cjs +2 -0
  256. package/dist/sampling-B46LW0cy.cjs.map +1 -0
  257. package/dist/sampling-zXA6r-Nw.js +63 -0
  258. package/dist/sampling-zXA6r-Nw.js.map +1 -0
  259. package/dist/{sanitize-CNmsD9r3.js → sanitize-DjnR6RXR.js} +2 -2
  260. package/dist/sanitize-DjnR6RXR.js.map +1 -0
  261. package/dist/{sanitize-ChLn97Ch.cjs → sanitize-Qj6LuZqp.cjs} +2 -2
  262. package/dist/sanitize-Qj6LuZqp.cjs.map +1 -0
  263. package/dist/sender-Bdp-TAS4.js +979 -0
  264. package/dist/sender-Bdp-TAS4.js.map +1 -0
  265. package/dist/sender-DR7ZycZY.cjs +2 -0
  266. package/dist/sender-DR7ZycZY.cjs.map +1 -0
  267. package/dist/storage/context-storage.d.cts +90 -0
  268. package/dist/storage/context-storage.d.ts +5 -5
  269. package/dist/storage/emergency-queue.d.cts +27 -0
  270. package/dist/storage/emergency-queue.d.ts +4 -4
  271. package/dist/storage/eviction.d.cts +40 -0
  272. package/dist/storage/eviction.d.ts +1 -1
  273. package/dist/storage/factory.d.cts +21 -0
  274. package/dist/storage/factory.d.ts +3 -3
  275. package/dist/storage/gap.d.cts +20 -0
  276. package/dist/storage/gap.d.ts +3 -3
  277. package/dist/storage/idb-driver.d.cts +93 -0
  278. package/dist/storage/idb-driver.d.ts +1 -1
  279. package/dist/storage/indexeddb-storage.d.cts +97 -0
  280. package/dist/storage/indexeddb-storage.d.ts +12 -4
  281. package/dist/storage/keys.d.cts +17 -0
  282. package/dist/storage/keys.d.ts +2 -2
  283. package/dist/storage/local-storage.d.cts +139 -0
  284. package/dist/storage/local-storage.d.ts +11 -4
  285. package/dist/storage/memory-storage.d.cts +73 -0
  286. package/dist/storage/memory-storage.d.ts +4 -3
  287. package/dist/storage/persistence.d.cts +8 -0
  288. package/dist/storage/persistence.d.ts +2 -2
  289. package/dist/storage/stored-context.d.cts +34 -0
  290. package/dist/storage/stored-context.d.ts +34 -0
  291. package/dist/stored-context-BOu54M8Y.cjs +2 -0
  292. package/dist/stored-context-BOu54M8Y.cjs.map +1 -0
  293. package/dist/stored-context-CSttrAsw.js +51 -0
  294. package/dist/stored-context-CSttrAsw.js.map +1 -0
  295. package/dist/storm-BHgI12iS.cjs +2 -0
  296. package/dist/storm-BHgI12iS.cjs.map +1 -0
  297. package/dist/storm-DKlpv0FL.js +9 -0
  298. package/dist/storm-DKlpv0FL.js.map +1 -0
  299. package/dist/transport/compression.d.cts +7 -0
  300. package/dist/transport/custom-transport.d.cts +22 -0
  301. package/dist/transport/custom-transport.d.ts +6 -5
  302. package/dist/transport/errors.d.cts +31 -0
  303. package/dist/transport/exit-flush.d.cts +135 -0
  304. package/dist/transport/exit-flush.d.ts +30 -13
  305. package/dist/transport/headers.d.cts +8 -0
  306. package/dist/transport/headers.d.ts +2 -2
  307. package/dist/transport/http-transport.d.cts +116 -0
  308. package/dist/transport/http-transport.d.ts +20 -8
  309. package/dist/transport/memory-transport.d.cts +30 -0
  310. package/dist/transport/memory-transport.d.ts +2 -2
  311. package/dist/transport/response-body.d.cts +49 -0
  312. package/dist/transport/response-body.d.ts +49 -0
  313. package/dist/transport/retry-engine.d.cts +129 -0
  314. package/dist/transport/retry-engine.d.ts +27 -9
  315. package/dist/transport/serializers/ecs.d.cts +3 -0
  316. package/dist/transport/serializers/ecs.d.ts +1 -1
  317. package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
  318. package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
  319. package/dist/transport/serializers/otlp-traces.d.cts +3 -0
  320. package/dist/transport/serializers/otlp-traces.d.ts +1 -1
  321. package/dist/transport/serializers/otlp.d.cts +47 -0
  322. package/dist/transport/serializers/otlp.d.ts +2 -2
  323. package/dist/transport/serializers/select.d.cts +38 -0
  324. package/dist/transport/serializers/select.d.ts +5 -5
  325. package/dist/transport/status-transport.d.cts +129 -0
  326. package/dist/transport/status-transport.d.ts +25 -8
  327. package/dist/transport/worker-client.d.cts +23 -0
  328. package/dist/transport/worker-client.d.ts +12 -3
  329. package/dist/transport/worker-entry.d.cts +5 -0
  330. package/dist/transport/worker-entry.d.ts +1 -1
  331. package/dist/transport/worker-protocol.d.cts +38 -0
  332. package/dist/transport/worker-protocol.d.ts +4 -2
  333. package/dist/transport/worker-server.d.cts +3 -0
  334. package/dist/transport/worker-server.d.ts +1 -1
  335. package/dist/transport/worker-transport.d.cts +10 -0
  336. package/dist/transport/worker-transport.d.ts +5 -4
  337. package/dist/types-BAerHgCq.js.map +1 -1
  338. package/dist/types-C7WNpnG1.cjs.map +1 -1
  339. package/dist/unclean-exit-BYPYYkQ5.cjs +2 -0
  340. package/dist/unclean-exit-BYPYYkQ5.cjs.map +1 -0
  341. package/dist/{unclean-exit-Cob_jyTv.js → unclean-exit-BcOB8A2e.js} +23 -30
  342. package/dist/unclean-exit-BcOB8A2e.js.map +1 -0
  343. package/dist/{user-timing-DgHubxCI.js → user-timing-4KIJ74Vi.js} +15 -17
  344. package/dist/user-timing-4KIJ74Vi.js.map +1 -0
  345. package/dist/user-timing-BsU2wQKE.cjs +2 -0
  346. package/dist/user-timing-BsU2wQKE.cjs.map +1 -0
  347. package/dist/utils/console.d.cts +36 -0
  348. package/dist/utils/console.d.ts +4 -4
  349. package/dist/utils/deadline.d.cts +14 -0
  350. package/dist/utils/error-like.d.cts +25 -0
  351. package/dist/utils/fixed-window.d.cts +25 -0
  352. package/dist/utils/global-scope.d.cts +20 -0
  353. package/dist/utils/guards.d.cts +14 -0
  354. package/dist/utils/guards.d.ts +8 -0
  355. package/dist/utils/identity.d.cts +114 -0
  356. package/dist/utils/identity.d.ts +8 -4
  357. package/dist/utils/library-console.d.cts +11 -0
  358. package/dist/utils/library-request.d.cts +24 -0
  359. package/dist/utils/lock.d.cts +24 -0
  360. package/dist/utils/lock.d.ts +1 -1
  361. package/dist/utils/openfin.d.cts +48 -0
  362. package/dist/utils/patch.d.cts +9 -0
  363. package/dist/utils/platform.d.cts +62 -0
  364. package/dist/utils/platform.d.ts +2 -2
  365. package/dist/utils/sanitize.d.cts +52 -0
  366. package/dist/utils/sanitize.d.ts +1 -1
  367. package/dist/utils/sequence.d.cts +10 -0
  368. package/dist/utils/tracing.d.cts +158 -0
  369. package/dist/utils/tracing.d.ts +11 -4
  370. package/dist/utils/unref.d.cts +9 -0
  371. package/dist/web-socket-Cs1ZbmmN.cjs +2 -0
  372. package/dist/{web-socket-DthJuSAg.js.map → web-socket-Cs1ZbmmN.cjs.map} +1 -1
  373. package/dist/{web-socket-DthJuSAg.js → web-socket-Zg0hj1LB.js} +23 -28
  374. package/dist/web-socket-Zg0hj1LB.js.map +1 -0
  375. package/dist/{web-vitals-CsGCWnUr.js → web-vitals-4pWACwaR.js} +15 -21
  376. package/dist/web-vitals-4pWACwaR.js.map +1 -0
  377. package/dist/web-vitals-__X7t4pj.cjs +2 -0
  378. package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
  379. package/dist/{worker-protocol-B0_8rWy5.js → worker-protocol-CYpAbrVl.js} +14 -11
  380. package/dist/worker-protocol-CYpAbrVl.js.map +1 -0
  381. package/dist/worker-protocol-DFYXIFus.cjs +2 -0
  382. package/dist/worker-protocol-DFYXIFus.cjs.map +1 -0
  383. package/dist/worker-server--yGTadTA.cjs +2 -0
  384. package/dist/worker-server--yGTadTA.cjs.map +1 -0
  385. package/dist/worker-server-BokySIII.js +94 -0
  386. package/dist/worker-server-BokySIII.js.map +1 -0
  387. package/dist/worker-transport-BdEvh_-a.cjs +2 -0
  388. package/dist/worker-transport-BdEvh_-a.cjs.map +1 -0
  389. package/dist/worker-transport-JK-Fby9J.js +194 -0
  390. package/dist/worker-transport-JK-Fby9J.js.map +1 -0
  391. package/llms.txt +400 -0
  392. package/package.json +65 -49
  393. package/dist/bus-D_7pd7RN.cjs +0 -2
  394. package/dist/bus-D_7pd7RN.cjs.map +0 -1
  395. package/dist/bus-ecxUNTja.js +0 -660
  396. package/dist/bus-ecxUNTja.js.map +0 -1
  397. package/dist/console-CLz_PvFn.cjs +0 -2
  398. package/dist/console-CLz_PvFn.cjs.map +0 -1
  399. package/dist/console-cwgHKXvM.js +0 -82
  400. package/dist/console-cwgHKXvM.js.map +0 -1
  401. package/dist/constants-Bwl_YtQi.js +0 -349
  402. package/dist/constants-Bwl_YtQi.js.map +0 -1
  403. package/dist/constants-DakMxVB2.cjs +0 -2
  404. package/dist/constants-DakMxVB2.cjs.map +0 -1
  405. package/dist/context-storage-BjzeBSxH.cjs +0 -2
  406. package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
  407. package/dist/context-storage-BzkoHzkQ.js +0 -51
  408. package/dist/context-storage-BzkoHzkQ.js.map +0 -1
  409. package/dist/debug-bundle-BOdYmCeV.js +0 -32
  410. package/dist/debug-bundle-BOdYmCeV.js.map +0 -1
  411. package/dist/debug-bundle-Ex4L_LSP.cjs +0 -2
  412. package/dist/debug-bundle-Ex4L_LSP.cjs.map +0 -1
  413. package/dist/emergency-queue-B9WZxanZ.js +0 -67
  414. package/dist/emergency-queue-B9WZxanZ.js.map +0 -1
  415. package/dist/emergency-queue-HBpL5r3V.cjs +0 -2
  416. package/dist/emergency-queue-HBpL5r3V.cjs.map +0 -1
  417. package/dist/errors-D6bwgJtO.js +0 -92
  418. package/dist/errors-D6bwgJtO.js.map +0 -1
  419. package/dist/errors-DCOCRdSi.cjs +0 -3
  420. package/dist/errors-DCOCRdSi.cjs.map +0 -1
  421. package/dist/factory-DLFDjdLv.cjs +0 -2
  422. package/dist/factory-DLFDjdLv.cjs.map +0 -1
  423. package/dist/factory-e9Qo3K0z.js +0 -276
  424. package/dist/factory-e9Qo3K0z.js.map +0 -1
  425. package/dist/guards-Cidk71ME.js +0 -7
  426. package/dist/guards-Cidk71ME.js.map +0 -1
  427. package/dist/guards-nJ70syPt.cjs +0 -2
  428. package/dist/guards-nJ70syPt.cjs.map +0 -1
  429. package/dist/identity-BlvlgjrU.cjs +0 -2
  430. package/dist/identity-BlvlgjrU.cjs.map +0 -1
  431. package/dist/identity-BrQp_5J5.js.map +0 -1
  432. package/dist/indexeddb-storage-CtLvZH1r.cjs +0 -2
  433. package/dist/indexeddb-storage-CtLvZH1r.cjs.map +0 -1
  434. package/dist/indexeddb-storage-DLXQzAGh.js.map +0 -1
  435. package/dist/interactions-B6z2I4tU.js +0 -119
  436. package/dist/interactions-B6z2I4tU.js.map +0 -1
  437. package/dist/interactions-P6pz08Jn.cjs +0 -2
  438. package/dist/interactions-P6pz08Jn.cjs.map +0 -1
  439. package/dist/journey-35yCMNFo.js.map +0 -1
  440. package/dist/journey-DAGh5h9k.cjs +0 -2
  441. package/dist/journey-DAGh5h9k.cjs.map +0 -1
  442. package/dist/keys-BHhw_0Wh.cjs +0 -2
  443. package/dist/keys-BHhw_0Wh.cjs.map +0 -1
  444. package/dist/keys-BU9j5YqW.js +0 -16
  445. package/dist/keys-BU9j5YqW.js.map +0 -1
  446. package/dist/lifecycle-BGGOcN4N.cjs +0 -2
  447. package/dist/lifecycle-BGGOcN4N.cjs.map +0 -1
  448. package/dist/lifecycle-CZ6RRXc6.js.map +0 -1
  449. package/dist/log-record-D7bA1RPb.cjs +0 -2
  450. package/dist/log-record-D7bA1RPb.cjs.map +0 -1
  451. package/dist/log-record-DIA6McNr.js.map +0 -1
  452. package/dist/long-frames-430_85Da.js.map +0 -1
  453. package/dist/long-frames-Dd8tsi2U.cjs +0 -2
  454. package/dist/long-frames-Dd8tsi2U.cjs.map +0 -1
  455. package/dist/models/stats.d.ts +0 -11
  456. package/dist/network-C7SkLf4v.js.map +0 -1
  457. package/dist/network-pEX3PAJv.cjs +0 -2
  458. package/dist/network-pEX3PAJv.cjs.map +0 -1
  459. package/dist/profiler-BVWIOgnq.js.map +0 -1
  460. package/dist/profiler-eVCknCzS.cjs +0 -2
  461. package/dist/profiler-eVCknCzS.cjs.map +0 -1
  462. package/dist/profiler-frames-CLXlT_xL.js.map +0 -1
  463. package/dist/profiler-frames-Dg2OebB2.cjs +0 -2
  464. package/dist/profiler-frames-Dg2OebB2.cjs.map +0 -1
  465. package/dist/remote-rules-BJGDJGwA.js +0 -98
  466. package/dist/remote-rules-BJGDJGwA.js.map +0 -1
  467. package/dist/remote-rules-CJD3ToVk.cjs +0 -2
  468. package/dist/remote-rules-CJD3ToVk.cjs.map +0 -1
  469. package/dist/replay-0zAJv9T3.js +0 -338
  470. package/dist/replay-0zAJv9T3.js.map +0 -1
  471. package/dist/replay-DomJpXqW.cjs +0 -2
  472. package/dist/replay-DomJpXqW.cjs.map +0 -1
  473. package/dist/reports-BsbqmP8h.cjs +0 -2
  474. package/dist/reports-BsbqmP8h.cjs.map +0 -1
  475. package/dist/reports-BuXekPOS.js.map +0 -1
  476. package/dist/resource-timing-CXGHwFRD.js.map +0 -1
  477. package/dist/resource-timing-DkycFGDa.cjs +0 -2
  478. package/dist/resource-timing-DkycFGDa.cjs.map +0 -1
  479. package/dist/sampling-Dd0wllyq.cjs +0 -2
  480. package/dist/sampling-Dd0wllyq.cjs.map +0 -1
  481. package/dist/sampling-UUDbi3K0.js +0 -60
  482. package/dist/sampling-UUDbi3K0.js.map +0 -1
  483. package/dist/sanitize-CNmsD9r3.js.map +0 -1
  484. package/dist/sanitize-ChLn97Ch.cjs.map +0 -1
  485. package/dist/select-CTk-K5mG.cjs +0 -3
  486. package/dist/select-CTk-K5mG.cjs.map +0 -1
  487. package/dist/select-DPv_j6wq.js +0 -270
  488. package/dist/select-DPv_j6wq.js.map +0 -1
  489. package/dist/sender-15zEsZpr.js +0 -857
  490. package/dist/sender-15zEsZpr.js.map +0 -1
  491. package/dist/sender-Bfpv9tad.cjs +0 -2
  492. package/dist/sender-Bfpv9tad.cjs.map +0 -1
  493. package/dist/storage-BA9RqRO-.cjs +0 -2
  494. package/dist/storage-BA9RqRO-.cjs.map +0 -1
  495. package/dist/storage-DZwed89z.js +0 -16
  496. package/dist/storage-DZwed89z.js.map +0 -1
  497. package/dist/storm-BTSNTIWI.js +0 -9
  498. package/dist/storm-BTSNTIWI.js.map +0 -1
  499. package/dist/storm-D0_qZOEg.cjs +0 -2
  500. package/dist/storm-D0_qZOEg.cjs.map +0 -1
  501. package/dist/unclean-exit-ClGzrc2A.cjs +0 -2
  502. package/dist/unclean-exit-ClGzrc2A.cjs.map +0 -1
  503. package/dist/unclean-exit-Cob_jyTv.js.map +0 -1
  504. package/dist/user-timing-CdYqx3PF.cjs +0 -2
  505. package/dist/user-timing-CdYqx3PF.cjs.map +0 -1
  506. package/dist/user-timing-DgHubxCI.js.map +0 -1
  507. package/dist/utils/timer.d.ts +0 -19
  508. package/dist/web-socket-BTuvYoJI.cjs +0 -2
  509. package/dist/web-socket-BTuvYoJI.cjs.map +0 -1
  510. package/dist/web-vitals-Ch5BpDmo.cjs +0 -2
  511. package/dist/web-vitals-Ch5BpDmo.cjs.map +0 -1
  512. package/dist/web-vitals-CsGCWnUr.js.map +0 -1
  513. package/dist/worker-protocol-B0_8rWy5.js.map +0 -1
  514. package/dist/worker-protocol-BjzFORfq.cjs +0 -2
  515. package/dist/worker-protocol-BjzFORfq.cjs.map +0 -1
  516. package/dist/worker-server-4en-Lt-3.cjs +0 -2
  517. package/dist/worker-server-4en-Lt-3.cjs.map +0 -1
  518. package/dist/worker-server-Cne9MX9I.js +0 -83
  519. package/dist/worker-server-Cne9MX9I.js.map +0 -1
  520. package/dist/worker-transport-B-GF4Aqn.cjs +0 -2
  521. package/dist/worker-transport-B-GF4Aqn.cjs.map +0 -1
  522. package/dist/worker-transport-C3SjJAEC.js +0 -200
  523. package/dist/worker-transport-C3SjJAEC.js.map +0 -1
@@ -0,0 +1,788 @@
1
+ import { A as e, Fn as t, M as n, N as r, O as i, Wn as a, at as o, k as s, pn as c } from "./constants-BwJDXzj6.js";
2
+ import { r as l } from "./journey-C93FTYcs.js";
3
+ import { n as u, t as d } from "./remote-rules-Dq9xe7Qn.js";
4
+ import { n as f, t as p } from "./log-record-DSt2P-Sr.js";
5
+ import { n as m } from "./guards-BlYGRK4l.js";
6
+ import { i as h } from "./identity-BgtHyY4u.js";
7
+ import { t as g } from "./openfin-Bxelt0yg.js";
8
+ import { n as _, t as v } from "./fixed-window-Dq3MLUUv.js";
9
+ import { t as y } from "./unref-DgHPQeWv.js";
10
+ import { t as b } from "./defineProperty-s2S8BXUc.js";
11
+ // src/bus/validation.ts
12
+ var x = [
13
+ "complete",
14
+ "timeout",
15
+ "inactive"
16
+ ];
17
+ function S(e) {
18
+ if (typeof e != "object" || !e) return !1;
19
+ let t = e;
20
+ if (typeof t.from != "string" || !t.from || typeof t.t != "string") return !1;
21
+ let n = (e) => typeof t[e] == "string";
22
+ switch (t.t) {
23
+ case r.hello: return n("tabId");
24
+ case r.tab: return n("tabId") && (t.since === void 0 || Number.isFinite(t.since));
25
+ case r.welcome: return n("to") && n("tabId") && (t.routingContextId === void 0 || n("routingContextId"));
26
+ case r.journeyRequest:
27
+ case r.samplingRequest: return !0;
28
+ case r.securityContext: return n("id") && t.id !== "";
29
+ case r.journey: return (t.to === void 0 || n("to")) && "journey" in t;
30
+ case r.sampling: return n("to") && "rules" in t;
31
+ case r.flushRequest: return n("id") && typeof t.timeoutMs == "number";
32
+ case r.flushResult: return n("id") && "result" in t;
33
+ case r.records: return Array.isArray(t.records) && (t.routingContextId === void 0 || n("routingContextId")) && t.records.every((e) => !f(e) || !p(e.severityText) ? !1 : !Array.isArray(e.attributes) && !Array.isArray(e.resource) && /^\d+$/.test(e.timeUnixNano) && (e.observedTimeUnixNano === void 0 || /^\d+$/.test(e.observedTimeUnixNano)) && typeof e.traceId == "string" && /^(?:[a-f\d]{32})?$/.test(e.traceId) && typeof e.spanId == "string" && /^(?:[a-f\d]{16})?$/.test(e.spanId) && Number.isInteger(e.traceFlags) && e.traceFlags >= 0 && e.traceFlags <= 255 && e.severityNumber === a[e.severityText]);
34
+ default: return !1;
35
+ }
36
+ }
37
+ function C(e) {
38
+ if (!m(e)) return null;
39
+ let { status: t, accepted: n, stored: r, dropped: i, forwarded: a, pending: o } = e;
40
+ return ![
41
+ n,
42
+ r,
43
+ i,
44
+ a,
45
+ o
46
+ ].every((e) => Number.isSafeInteger(e) && e >= 0) || !x.includes(t) || t === "complete" && o !== 0 ? null : {
47
+ status: t,
48
+ accepted: n,
49
+ stored: r,
50
+ dropped: i,
51
+ forwarded: a,
52
+ pending: o
53
+ };
54
+ }
55
+ // src/models/bus.ts
56
+ function w(e) {
57
+ return {
58
+ p: n,
59
+ m: e
60
+ };
61
+ }
62
+ function T(e) {
63
+ if (typeof e != "object" || !e) return null;
64
+ let t = e;
65
+ if (t.p !== "ui-observability/2" || typeof t.m != "object" || t.m === null) return null;
66
+ let n = t.m;
67
+ return typeof n.t == "string" ? n : null;
68
+ }
69
+ // src/bus/links.ts
70
+ var E = Symbol.for(t), D = "null", O = "ui-observability/2";
71
+ function k(e, t) {
72
+ return e === D ? `The bus ignored ${t} from a sandboxed frame. The frame has an opaque origin. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.` : `The bus ignored ${t} from ${e}. If you own this origin, add it to bus.trustedOrigins.`;
73
+ }
74
+ function A(e) {
75
+ let t = location.ancestorOrigins;
76
+ return t && t.length > 0 ? t.item(0) : j() ?? M(e);
77
+ }
78
+ function j() {
79
+ let e = document.referrer;
80
+ if (e === "") return null;
81
+ try {
82
+ return new URL(e).origin;
83
+ } catch {
84
+ return null;
85
+ }
86
+ }
87
+ function M(e) {
88
+ let t;
89
+ try {
90
+ t = window.parent.origin;
91
+ } catch {
92
+ return e.count("platform.api_blocked"), null;
93
+ }
94
+ return typeof t != "string" || t === D ? null : t;
95
+ }
96
+ function N() {
97
+ if (location.origin !== D) return location.origin;
98
+ let e = globalThis.origin;
99
+ return typeof e == "string" ? e : D;
100
+ }
101
+ function P(e, t) {
102
+ if (typeof window > "u" || window.parent === window) return null;
103
+ let r;
104
+ try {
105
+ r = window.parent[E];
106
+ } catch {
107
+ return null;
108
+ }
109
+ if (typeof r?.busAccept != "function") return null;
110
+ let i = r.protocol, a = r.busCanAccept, o = typeof a == "function", s = i === void 0 && o ? O : i;
111
+ if (s !== "ui-observability/2") {
112
+ let e = typeof s == "string" ? s.slice(0, 48) : "none";
113
+ return t.report("bus.protocol_mismatch", "The same-origin parent runtime uses another bus protocol. This context tries a message link instead of a direct call.", {
114
+ found: e,
115
+ own: n
116
+ }), null;
117
+ }
118
+ let c = N();
119
+ if (o && !a.call(r, window, c)) return null;
120
+ let l = r, u = !0;
121
+ return {
122
+ kind: "direct",
123
+ post(n) {
124
+ u && t.guard("bus.send_failed", "The direct call into the parent runtime failed.", () => {
125
+ l.busAccept(n, e, window);
126
+ });
127
+ },
128
+ close() {
129
+ u = !1;
130
+ }
131
+ };
132
+ }
133
+ function F(e, t, n) {
134
+ if (typeof window > "u" || window.parent === window) return null;
135
+ let r = N();
136
+ if (r === D) return n.report("bus.untrusted_origin", "This frame reports the origin \"null\". No parent can trust that origin. This context sends its own records. A frame that is sandboxed without allow-same-origin has this origin. Set bus.mode: \"sender\" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.", {
137
+ origin: r,
138
+ type: "parent"
139
+ }), null;
140
+ let i = /* @__PURE__ */ new Set([r, ...t]), a = A(n);
141
+ if (a === null || !i.has(a)) return n.report("bus.untrusted_origin", a === null ? "The origin of the parent frame is unknown. This context sends its own records." : `The parent frame is on ${a}. This origin is not in bus.trustedOrigins. This context sends its own records.`, {
142
+ origin: a ?? "",
143
+ type: "parent"
144
+ }), null;
145
+ let o = /* @__PURE__ */ new Set(), s = (t) => {
146
+ let r = T(t.data);
147
+ r && t.source === window.parent && (i.has(t.origin) ? e(r, {
148
+ link: "parent",
149
+ origin: t.origin,
150
+ peer: t.source
151
+ }) : o.has(t.origin) || (o.add(t.origin), n.report("bus.untrusted_origin", k(t.origin, "a message"), {
152
+ origin: t.origin,
153
+ type: r.t.slice(0, 48)
154
+ })));
155
+ };
156
+ return addEventListener("message", s), {
157
+ kind: "parent",
158
+ post(e) {
159
+ n.guard("bus.send_failed", "The postMessage call to the parent failed.", () => {
160
+ window.parent.postMessage(w(e), a);
161
+ });
162
+ },
163
+ close() {
164
+ removeEventListener("message", s);
165
+ }
166
+ };
167
+ }
168
+ function I(e, t, n, r, i) {
169
+ if (typeof window > "u") return null;
170
+ let a = /* @__PURE__ */ new Set([location.origin, ...t]);
171
+ a.delete(D);
172
+ let o = /* @__PURE__ */ new Map(), s = (e, t, a) => {
173
+ if (r && !r(e, t)) {
174
+ o.delete(e);
175
+ return;
176
+ }
177
+ if (i && !i(a, e)) return;
178
+ let s = e;
179
+ s.closed ? o.delete(e) : n.guard("bus.send_failed", "The postMessage call to a child frame failed.", () => {
180
+ s.postMessage(w(a), t);
181
+ });
182
+ }, c = (t) => {
183
+ let i = T(t.data);
184
+ if (!i || window.parent !== window && t.source === window.parent) return;
185
+ if (!r && !a.has(t.origin)) {
186
+ n.report("bus.untrusted_origin", k(t.origin, "a message"), {
187
+ origin: t.origin,
188
+ type: i.t.slice(0, 48)
189
+ });
190
+ return;
191
+ }
192
+ if (r && !r(t.source, t.origin)) return;
193
+ let { source: c, origin: l } = t;
194
+ c && o.set(c, l), e(i, {
195
+ link: "children",
196
+ origin: l,
197
+ peer: c ?? void 0,
198
+ reply: c ? (e) => {
199
+ s(c, l, e);
200
+ } : void 0
201
+ });
202
+ };
203
+ return addEventListener("message", c), {
204
+ kind: "children",
205
+ post(e) {
206
+ for (let [t, n] of o) s(t, n, e);
207
+ },
208
+ close() {
209
+ removeEventListener("message", c), o.clear();
210
+ }
211
+ };
212
+ }
213
+ function L(e, t, n) {
214
+ let r = globalThis.BroadcastChannel;
215
+ if (r === void 0) return null;
216
+ let i = n.guard("bus.send_failed", "The library could not open the BroadcastChannel.", () => new r(e));
217
+ return i ? (i.onmessage = (e) => {
218
+ let n = T(e.data);
219
+ n && t(n, {
220
+ link: "broadcast",
221
+ origin: "same-origin"
222
+ });
223
+ }, {
224
+ kind: "broadcast",
225
+ post(e) {
226
+ n.guard("bus.send_failed", "The BroadcastChannel.postMessage call failed.", () => {
227
+ i.postMessage(w(e));
228
+ });
229
+ },
230
+ close() {
231
+ n.guard("bus.send_failed", "The library could not close the BroadcastChannel.", () => {
232
+ i.close();
233
+ });
234
+ }
235
+ }) : null;
236
+ }
237
+ function R(e, t, n, r) {
238
+ let i = g()?.InterApplicationBus;
239
+ if (!i) return null;
240
+ if (!t) return r.report("openfin.unavailable", "OpenFin gives no application uuid. The InterApplicationBus link stays closed."), null;
241
+ let a = `${e}.${t}`;
242
+ return r.guardAsync("bus.send_failed", "The InterApplicationBus.subscribe call failed.", () => i.subscribe({ uuid: t }, a, (e, t, r) => {
243
+ let i = T(e);
244
+ i && n(i, {
245
+ link: "openfin",
246
+ origin: "openfin",
247
+ peer: t && r ? `${t}:${r}` : void 0
248
+ });
249
+ })), {
250
+ kind: "openfin",
251
+ post(e) {
252
+ r.guardAsync("bus.send_failed", "The InterApplicationBus.publish call failed.", () => i.publish(a, w(e)));
253
+ },
254
+ close() {}
255
+ };
256
+ }
257
+ function z(e, t) {
258
+ let n = globalThis, r = n.postMessage;
259
+ return n.WorkerGlobalScope === void 0 || !r ? null : (n.addEventListener?.("message", (t) => {
260
+ let n = T(t.data);
261
+ n && e(n, {
262
+ link: "owner",
263
+ origin: "same-origin"
264
+ });
265
+ }), {
266
+ kind: "owner",
267
+ post(e) {
268
+ t.guard("bus.send_failed", "The postMessage call of the worker failed.", () => {
269
+ r(w(e));
270
+ });
271
+ },
272
+ close() {}
273
+ });
274
+ }
275
+ function B(e, t, n) {
276
+ let r = (n) => {
277
+ let r = T(n.data);
278
+ r && t(r, {
279
+ link: "worker",
280
+ origin: "same-origin",
281
+ peer: e
282
+ });
283
+ };
284
+ return e.addEventListener("message", r), e.start?.(), {
285
+ kind: "worker",
286
+ post(t) {
287
+ n.guard("bus.send_failed", "The postMessage call to a worker failed.", () => {
288
+ e.postMessage(w(t));
289
+ });
290
+ },
291
+ close() {
292
+ e.removeEventListener("message", r);
293
+ }
294
+ };
295
+ }
296
+ // src/bus/bus.ts
297
+ var V = {
298
+ timeoutMs: e,
299
+ maxAttempts: 3
300
+ }, H = [
301
+ "children",
302
+ "direct",
303
+ "worker"
304
+ ], U = class {
305
+ mayPost(e, t) {
306
+ let n = this.sources.get(t)?.permissions;
307
+ return n ? e.t === r.journey ? n.includes("journey:read") : e.t === r.journeyRequest ? n.includes("journey:write") : e.t !== r.sampling || n.includes("sampling:read") : this.config.bus.sourcePolicy === "trusted-origin";
308
+ }
309
+ registerFrame(e, t) {
310
+ let n = typeof HTMLIFrameElement > "u" ? void 0 : HTMLIFrameElement, r = n && e instanceof n ? e.contentWindow : e;
311
+ if (!r || new URL(t.origin).origin !== t.origin || t.origin === "null") throw Error("A frame registration requires a window and an exact origin.");
312
+ let i = {
313
+ ...t,
314
+ permissions: [...t.permissions ?? ["records"]]
315
+ };
316
+ return this.sources.set(r, i), this.ensureChildrenLink(), () => {
317
+ this.sources.get(r) === i && this.sources.delete(r);
318
+ };
319
+ }
320
+ isRegistered(e, t) {
321
+ if (!e) return !1;
322
+ let n = this.sources.get(e);
323
+ return n ? n.origin === t : this.config.bus.sourcePolicy !== "registered" && t !== "null" && (t === N() || this.config.bus.trustedOrigins.includes(t));
324
+ }
325
+ rotateContext() {
326
+ this.passContext(this.role === "sender");
327
+ }
328
+ setTabId(e) {
329
+ this.tabId = e;
330
+ }
331
+ passContext(e) {
332
+ let t = {
333
+ t: r.securityContext,
334
+ from: this.contextId,
335
+ id: this.config.securityContext.id
336
+ };
337
+ this.postOver("children", t), this.postOver("worker", t), this.postToDirectChildren(t), e && this.postOver("openfin", t);
338
+ }
339
+ postToDirectChildren(e) {
340
+ let t = N();
341
+ for (let [n, r] of this.directReplies) {
342
+ let i = r.deref();
343
+ !i || n.closed || !this.isRegistered(n, t) ? this.directReplies.delete(n) : this.diagnostics.guard("bus.send_failed", "The reply to a direct child failed.", () => {
344
+ i(e, {
345
+ link: "direct",
346
+ origin: "same-origin",
347
+ peer: n
348
+ });
349
+ });
350
+ }
351
+ }
352
+ keepDirectReply(e, t) {
353
+ for (let e of this.directReplies.keys()) e.closed && this.directReplies.delete(e);
354
+ this.directReplies.set(e, new WeakRef(t));
355
+ }
356
+ constructor(e, t, n, r, i, a, o = V) {
357
+ b(this, "config", void 0), b(this, "diagnostics", void 0), b(this, "platform", void 0), b(this, "contextId", void 0), b(this, "tabId", void 0), b(this, "handlers", void 0), b(this, "handshakeOptions", void 0), b(this, "sources", /* @__PURE__ */ new Map()), b(this, "rates", /* @__PURE__ */ new WeakMap()), b(this, "channelRates", /* @__PURE__ */ new Map()), b(this, "directReplies", /* @__PURE__ */ new Map()), b(this, "role", "sender"), b(this, "upstream", null), b(this, "links", []), b(this, "openFinLink", null), b(this, "isOpenFinProvider", !1), b(this, "rulesPoll", void 0), b(this, "destroyed", !1), b(this, "ownerId", null), b(this, "ownerPeer", void 0), b(this, "awaitingWelcome", null), b(this, "flushAnswers", /* @__PURE__ */ new Map()), b(this, "flushQueue", []), b(this, "flushing", !1), b(this, "flushedAt", 0), b(this, "since", void 0), b(this, "receive", (e, t) => {
358
+ let n = t.link === "children" || t.link === "worker";
359
+ this.acceptsMessage(e, t, n) && this.routeMessage(e, t);
360
+ }), this.config = e, this.diagnostics = t, this.platform = n, this.contextId = r, this.tabId = i, this.handlers = a, this.handshakeOptions = o;
361
+ let s = performance.timeOrigin;
362
+ this.since = Number.isFinite(s) ? s : void 0;
363
+ }
364
+ getRole() {
365
+ return this.role;
366
+ }
367
+ async start() {
368
+ let { bus: e } = this.config;
369
+ if (e.mode === "off") return this.role = "sender", this.role;
370
+ if (this.isOpenFinProvider = this.resolveOpenFinProvider(), e.mode === "sender" || e.mode === "forwarder") return this.role = e.mode, this.openControlLinks(), this.role === "forwarder" && (this.upstream = this.candidateUpstream(), this.upstream || this.diagnostics.report("bus.no_owner", "bus.mode is \"forwarder\". No owner exists. The library drops the records of this context.")), this.announce(), this.role;
371
+ this.openControlLinks();
372
+ let t = P(this.receive, this.diagnostics);
373
+ if (t) return this.role = "forwarder", this.upstream = t, await this.handshake(t), this.diagnostics.report("bus.role_resolved", "This context attached directly to the runtime of its same-origin parent.", {
374
+ role: "forwarder",
375
+ via: "direct"
376
+ }), this.announce(), this.role;
377
+ let n = this.candidateUpstream();
378
+ if (!n) return this.role = "sender", this.diagnostics.report("bus.role_resolved", "No owner exists. This context sends its own records.", { role: "sender" }), this.announce(), this.role;
379
+ let r = this.orphanPolicy() === "retry" ? this.handshakeOptions.maxAttempts : 1, i = !1;
380
+ for (let e = 0; e < r && !i; e++) i = await this.handshake(n);
381
+ return this.role = i ? "forwarder" : "sender", this.upstream = i ? n : null, i || (n !== this.openFinLink && n.close(), this.diagnostics.report("bus.handshake_timeout", `No owner answered after ${String(r)} attempt(s) of ${String(this.handshakeOptions.timeoutMs)} ms. This context becomes the sender.`, {
382
+ via: n.kind,
383
+ crossOrigin: this.isCrossOriginFrame()
384
+ })), this.diagnostics.report("bus.role_resolved", `The bus role is ${this.role}.`, {
385
+ role: this.role,
386
+ via: i ? n.kind : "none"
387
+ }), this.announce(), this.role;
388
+ }
389
+ sendRecords(e) {
390
+ let { maxRecordsPerMessage: t, maxMessageBytes: n } = this.config.bus, i = new TextEncoder(), a = (e) => n === null ? 0 : i.encode(JSON.stringify(e)).length, o = (e) => ({
391
+ t: r.records,
392
+ from: this.contextId,
393
+ records: e,
394
+ routingContextId: this.config.securityContext.id || void 0
395
+ }), s = a(o([])), c = [], l = s, u = 0;
396
+ for (let r of e) {
397
+ let e = a(r);
398
+ if (n !== null && s + e > n) {
399
+ this.diagnostics.count("bus.rejected_message"), u++;
400
+ continue;
401
+ }
402
+ let i = +(c.length > 0);
403
+ (t !== null && c.length >= t || n !== null && l + i + e > n) && (this.upstream?.post(o(c)), c = [], l = s), l += +(c.length > 0) + e, c.push(r);
404
+ }
405
+ return c.length > 0 && this.upstream?.post(o(c)), this.upstream ? e.length - u : 0;
406
+ }
407
+ async requestFlush(e, t) {
408
+ let { upstream: n } = this;
409
+ if (!n) return null;
410
+ let i = h(this.diagnostics), a, o = new Promise((e) => {
411
+ a = e;
412
+ });
413
+ this.flushAnswers.set(i, a), n.post({
414
+ t: r.flushRequest,
415
+ from: this.contextId,
416
+ id: i,
417
+ timeoutMs: e
418
+ });
419
+ try {
420
+ return await Promise.race([o, t.then(() => null)]);
421
+ } finally {
422
+ this.flushAnswers.delete(i);
423
+ }
424
+ }
425
+ acceptDirect(e, t, n) {
426
+ let i = {
427
+ link: "direct",
428
+ origin: "same-origin",
429
+ peer: n
430
+ }, a = {
431
+ ...i,
432
+ reply: (e) => {
433
+ t(e, i);
434
+ }
435
+ };
436
+ this.acceptsMessage(e, a, !0) && e.from !== this.contextId && (n && this.keepDirectReply(n, t), e.t === r.samplingRequest ? t(this.rulesAnswer(e.from), i) : (e.t === r.records && !this.awaitingWelcome && e.routingContextId !== this.config.securityContext.id && t({
437
+ t: r.securityContext,
438
+ from: this.contextId,
439
+ id: this.config.securityContext.id
440
+ }, i), this.routeMessage(e, a)));
441
+ }
442
+ attachWorker(e, t = {}) {
443
+ let n = {
444
+ ...t,
445
+ permissions: [...t.permissions ?? ["records"]]
446
+ };
447
+ this.sources.set(e, n);
448
+ let r = B(e, (e, t) => {
449
+ this.receive(e, {
450
+ ...t,
451
+ reply: (e) => {
452
+ i.post(e);
453
+ }
454
+ });
455
+ }, this.diagnostics), i = {
456
+ ...r,
457
+ post: (t) => {
458
+ this.mayPost(t, e) && r.post(t);
459
+ }
460
+ };
461
+ return this.links.push(i), () => {
462
+ i.close();
463
+ let t = this.links.indexOf(i);
464
+ t >= 0 && this.links.splice(t, 1), this.sources.get(e) === n && this.sources.delete(e);
465
+ };
466
+ }
467
+ broadcastJourney(e) {
468
+ this.postJourney({
469
+ t: r.journey,
470
+ from: this.contextId,
471
+ journey: e
472
+ });
473
+ }
474
+ destroy() {
475
+ this.sources.clear(), this.directReplies.clear(), this.flushQueue = [], this.destroyed = !0, clearInterval(this.rulesPoll), this.rulesPoll = void 0;
476
+ for (let e of this.allLinks()) e.close();
477
+ this.links.length = 0, this.upstream = null, this.ownerId = null, this.openFinLink = null;
478
+ }
479
+ allLinks() {
480
+ return !this.upstream || this.links.includes(this.upstream) ? this.links : [...this.links, this.upstream];
481
+ }
482
+ postOver(e, t) {
483
+ for (let n of this.allLinks()) n.kind === e && n.post(t);
484
+ }
485
+ postJourney(e) {
486
+ for (let t of this.allLinks()) this.journeyLink(t.kind) && t.post(e);
487
+ }
488
+ acceptsMessage(e, t, n) {
489
+ if (this.destroyed) return !1;
490
+ let r;
491
+ try {
492
+ r = this.passesChecks(e, t, n);
493
+ } catch {
494
+ r = !1;
495
+ }
496
+ return r === "journey_denied" ? (this.diagnostics.count("bus.journey_denied"), !1) : (r || this.diagnostics.count("bus.rejected_message"), r);
497
+ }
498
+ passesChecks(e, t, n) {
499
+ let { bus: i } = this.config, a = typeof t.peer == "object" ? this.sources.get(t.peer) : void 0;
500
+ if (n && i.sourcePolicy === "registered" && !a) return !1;
501
+ let o = typeof t.peer == "object" ? t.peer : void 0, s = typeof t.peer == "string" ? t.peer : t.link, c = Date.now(), l = (o ? this.rates.get(o) : this.channelRates.get(s)) ?? {
502
+ start: c,
503
+ count: 0
504
+ };
505
+ if (o) this.rates.set(o, l);
506
+ else {
507
+ for (let [e, t] of this.channelRates) _(t, 1e3, c) && this.channelRates.delete(e);
508
+ if (this.channelRates.size >= 256 && !this.channelRates.has(s)) return !1;
509
+ this.channelRates.set(s, l);
510
+ }
511
+ if (!v(l, i.maxMessagesPerSecond ?? Infinity, 1e3)) return !1;
512
+ let u = JSON.stringify(e, (e, t) => {
513
+ if (typeof t == "number" && !Number.isFinite(t)) throw Error("Non-finite value");
514
+ return t;
515
+ });
516
+ if (i.maxMessageBytes !== null && new TextEncoder().encode(u).length > i.maxMessageBytes || !S(e) || e.t === r.records && i.maxRecordsPerMessage !== null && e.records.length > i.maxRecordsPerMessage) return !1;
517
+ if (a) {
518
+ let t = e.t === r.records || e.t === r.flushRequest ? "records" : e.t === r.journey ? "journey:write" : e.t === r.journeyRequest ? "journey:read" : e.t === r.samplingRequest ? "sampling:read" : void 0;
519
+ if (t && !a.permissions?.includes(t)) return t === "journey:read" && "journey_denied";
520
+ }
521
+ return n && (e.t === r.sampling || e.t === r.securityContext || e.t === r.flushResult) || t.link === "broadcast" && e.t === r.flushRequest ? !1 : i.sourcePolicy !== "registered" || t.link !== "broadcast" || e.t !== r.records;
522
+ }
523
+ routeMessage(e, t) {
524
+ if (e.from !== this.contextId) switch (e.t) {
525
+ case r.hello:
526
+ this.canOwn(t.link) && this.answer(t, {
527
+ t: r.welcome,
528
+ from: this.contextId,
529
+ to: e.from,
530
+ tabId: this.tabId,
531
+ routingContextId: this.awaitingWelcome ? void 0 : this.config.securityContext.id || void 0
532
+ });
533
+ break;
534
+ case r.welcome:
535
+ if (e.to !== this.contextId) break;
536
+ if (this.awaitingWelcome?.link === t.link || this.upstream?.kind === t.link && this.ownerId === null) {
537
+ this.ownerId = e.from, this.ownerPeer = t.peer;
538
+ let n = this.config.securityContext.id;
539
+ if (e.routingContextId && this.handlers.onSecurityContext?.(e.routingContextId) === !1) break;
540
+ this.config.securityContext.id !== n && this.passContext(!1), this.awaitingWelcome?.settle(!0);
541
+ }
542
+ break;
543
+ case r.records:
544
+ if (this.config.securityContext.isolation && this.config.securityContext.id && e.routingContextId !== this.config.securityContext.id) {
545
+ this.diagnostics.count("security.context_mismatch");
546
+ break;
547
+ }
548
+ this.role === "sender" || this.handlers.paused?.() && this.canRelay(t.link) ? this.handlers.onRecords(e.records) : this.upstream && this.canRelay(t.link) && this.upstream.post(e);
549
+ break;
550
+ case r.securityContext:
551
+ t.link === this.upstream?.kind && this.ownerId === e.from && this.ownerPeer === t.peer && this.handlers.onSecurityContext?.(e.id) !== !1 && this.rotateContext();
552
+ break;
553
+ case r.journey:
554
+ this.acceptsJourney(e, t) && this.applyJourney(e.journey);
555
+ break;
556
+ case r.journeyRequest: {
557
+ let n = this.handlers.onJourneyRequest();
558
+ n && this.journeyLink(t.link) && this.answer(t, {
559
+ t: r.journey,
560
+ from: this.contextId,
561
+ to: e.from,
562
+ journey: n
563
+ });
564
+ break;
565
+ }
566
+ case r.samplingRequest:
567
+ (this.role === "forwarder" ? t.link !== this.upstream?.kind : this.canOwn(t.link)) && this.answer(t, this.rulesAnswer(e.from));
568
+ break;
569
+ case r.sampling:
570
+ this.acceptsRules(e.to, t) && this.applyRules(e.rules);
571
+ break;
572
+ case r.flushRequest:
573
+ (this.role === "sender" || this.canRelay(t.link)) && this.queueFlush(e, t);
574
+ break;
575
+ case r.flushResult:
576
+ this.settleFlush(e, t);
577
+ break;
578
+ case r.tab: t.link === "broadcast" && e.tabId === this.tabId && this.settleTabClaim(e);
579
+ }
580
+ }
581
+ settleTabClaim(e) {
582
+ let { since: t } = e;
583
+ t === void 0 || this.since === void 0 || t === this.since ? this.contextId > e.from && this.handlers.onTabConflict() : t < this.since ? this.handlers.onTabConflict() : this.postOver("broadcast", this.tabClaim());
584
+ }
585
+ queueFlush(e, t) {
586
+ let n = t.peer ?? t.link, i = this.flushQueue.filter((e) => e.source === n).length;
587
+ if (this.flushQueue.length >= 100 || i >= 4) {
588
+ this.diagnostics.count("bus.rejected_message");
589
+ return;
590
+ }
591
+ let a = Math.min(Math.max(e.timeoutMs, 0), o);
592
+ this.flushQueue.push({
593
+ source: n,
594
+ ends: Date.now() + a,
595
+ answer: (n) => {
596
+ this.answer(t, {
597
+ t: r.flushResult,
598
+ from: this.contextId,
599
+ id: e.id,
600
+ result: n
601
+ });
602
+ }
603
+ }), this.flushing || this.runFlushes();
604
+ }
605
+ async runFlushes() {
606
+ this.flushing = !0;
607
+ try {
608
+ for (; this.flushQueue.length > 0;) {
609
+ let e = this.flushedAt + s - Date.now();
610
+ if (e > 0 && await new Promise((t) => {
611
+ y(setTimeout(t, e));
612
+ }), this.flushQueue.length === 0) return;
613
+ this.flushedAt = Date.now();
614
+ let t = this.flushQueue;
615
+ this.flushQueue = [];
616
+ let n = Math.max(...t.map((e) => e.ends)), r = await this.diagnostics.guardAsync("pipeline.crashed", "The flush that a child context asked for failed. The child gets no answer.", async () => this.handlers.onFlush?.(Math.max(0, n - Date.now())));
617
+ if (r && !this.destroyed) for (let e of t) this.diagnostics.guard("bus.send_failed", "The answer to a flush request failed.", () => {
618
+ e.answer(r);
619
+ });
620
+ }
621
+ } finally {
622
+ this.flushing = !1;
623
+ }
624
+ }
625
+ settleFlush(e, t) {
626
+ let n = this.flushAnswers.get(e.id), r = this.ownerPeer === void 0 ? t.link !== "openfin" : this.ownerPeer === t.peer;
627
+ if (!n || !r || !this.fromOwner(e.from, t.link)) return;
628
+ let i;
629
+ try {
630
+ i = C(e.result);
631
+ } catch {
632
+ i = null;
633
+ }
634
+ i ? n(i) : this.diagnostics.count("bus.rejected_message");
635
+ }
636
+ answer(e, t) {
637
+ e.reply ? e.reply(t) : this.postOver(e.link, t);
638
+ }
639
+ canRelay(e) {
640
+ return e === "direct" || e !== this.upstream?.kind;
641
+ }
642
+ canOwn(e) {
643
+ return this.role !== "sender" && this.ownerId === null ? !1 : e === "openfin" ? this.role === "sender" && this.isOpenFinProvider : H.includes(e);
644
+ }
645
+ resolveOpenFinProvider() {
646
+ let e = this.config.bus.openFinRole;
647
+ if (e !== "auto") return e === "provider";
648
+ if (this.platform.platform !== "openfin" && this.platform.platform !== "openfin_web") return !1;
649
+ let t = g()?.me;
650
+ return !t?.identity || t.isView ? !1 : !!(t.identity.name && t.identity.name === t.identity.uuid);
651
+ }
652
+ orphanPolicy() {
653
+ return this.isCrossOriginFrame() ? "retry" : "promote";
654
+ }
655
+ isCrossOriginFrame() {
656
+ if (typeof window > "u" || window.parent === window) return !1;
657
+ try {
658
+ return Reflect.get(window.parent, "location"), !1;
659
+ } catch {
660
+ return !0;
661
+ }
662
+ }
663
+ candidateUpstream() {
664
+ return this.platform.isWorker ? z(this.receive, this.diagnostics) : this.platform.isTopLevelDocument ? this.platform.platform === "openfin" && !this.isOpenFinProvider ? this.ensureOpenFinLink() : null : F(this.receive, this.config.bus.trustedOrigins, this.diagnostics);
665
+ }
666
+ openControlLinks() {
667
+ let e = (e) => {
668
+ e && this.links.push(e);
669
+ };
670
+ this.platform.isWorker || this.ensureChildrenLink(), this.platform.isTopLevelDocument && e(L(i, this.receive, this.diagnostics)), (this.platform.platform === "openfin" || this.platform.platform === "openfin_web") && e(this.ensureOpenFinLink());
671
+ }
672
+ ensureChildrenLink() {
673
+ if (this.links.some((e) => e.kind === "children")) return;
674
+ let e = I(this.receive, this.config.bus.trustedOrigins, this.diagnostics, (e, t) => {
675
+ let n = this.isRegistered(e, t);
676
+ if (!n) {
677
+ this.diagnostics.count("bus.rejected_message");
678
+ let n = e !== null && this.sources.has(e), r = t === N() || this.config.bus.trustedOrigins.includes(t);
679
+ (n || !r) && this.diagnostics.report("bus.untrusted_origin", "The bus rejected a message from an untrusted origin.");
680
+ }
681
+ return n;
682
+ }, (e, t) => this.mayPost(e, t));
683
+ e && this.links.push(e);
684
+ }
685
+ ensureOpenFinLink() {
686
+ return this.openFinLink ??= R(i, this.platform.openfinUuid, this.receive, this.diagnostics), this.openFinLink;
687
+ }
688
+ handshake(e) {
689
+ return new Promise((t) => {
690
+ let n = !1, i = (e) => {
691
+ n || (n = !0, this.awaitingWelcome = null, clearTimeout(a), t(e));
692
+ };
693
+ this.awaitingWelcome = {
694
+ link: e.kind,
695
+ settle: i
696
+ };
697
+ let a = setTimeout(() => {
698
+ i(!1);
699
+ }, this.handshakeOptions.timeoutMs);
700
+ y(a), e.post({
701
+ t: r.hello,
702
+ from: this.contextId,
703
+ tabId: this.tabId
704
+ });
705
+ });
706
+ }
707
+ tabClaim() {
708
+ return {
709
+ t: r.tab,
710
+ from: this.contextId,
711
+ tabId: this.tabId,
712
+ ...this.since === void 0 ? {} : { since: this.since }
713
+ };
714
+ }
715
+ announce() {
716
+ this.postOver("broadcast", this.tabClaim()), this.upstream && this.ownerId === null && this.upstream.post({
717
+ t: r.hello,
718
+ from: this.contextId,
719
+ tabId: this.tabId
720
+ }), this.postJourney({
721
+ t: r.journeyRequest,
722
+ from: this.contextId
723
+ }), this.pollRules(), this.passContext(!1);
724
+ }
725
+ journeyScope() {
726
+ let { scope: e } = this.config.journey;
727
+ if (e !== "auto") return e;
728
+ let { platform: t } = this.platform;
729
+ return t === "openfin" || t === "openfin_web" ? "origin" : "tab";
730
+ }
731
+ journeyLink(e) {
732
+ let t = this.journeyScope();
733
+ return t === "context" ? !1 : t === "origin" || e !== "broadcast";
734
+ }
735
+ acceptsJourney(e, t) {
736
+ return !this.journeyLink(t.link) || e.to !== void 0 && e.to !== this.contextId ? !1 : this.journeyScope() === "origin" || this.fromOwner(e.from, t.link) && (this.ownerPeer === void 0 || this.ownerPeer === t.peer);
737
+ }
738
+ fromOwner(e, t) {
739
+ return this.role !== "forwarder" || t !== this.upstream?.kind ? !1 : this.ownerId === null || e === this.ownerId;
740
+ }
741
+ applyJourney(e) {
742
+ if (e === null) {
743
+ this.handlers.onJourney(null);
744
+ return;
745
+ }
746
+ let t = l(e);
747
+ t === null ? this.diagnostics.report("record.dropped_malformed", "The bus dropped a journey message. Its payload is not a journey.", { type: "journey" }) : this.handlers.onJourney(t);
748
+ }
749
+ rulesAnswer(e) {
750
+ let t = this.handlers.remote.sampling?.wire() ?? null;
751
+ return {
752
+ t: r.sampling,
753
+ from: this.contextId,
754
+ to: e,
755
+ rules: t
756
+ };
757
+ }
758
+ acceptsRules(e, t) {
759
+ if (this.role !== "forwarder" || e !== this.contextId || t.link !== this.upstream?.kind) return !1;
760
+ let { origin: n } = t;
761
+ return t.link === "parent" && n !== N() && !this.config.bus.trustedOrigins.includes(n) ? (this.diagnostics.report("bus.untrusted_origin", `The bus ignored sampling rules from ${n}. If you own this origin, add it to bus.trustedOrigins.`, {
762
+ origin: n,
763
+ type: "sampling"
764
+ }), !1) : this.ownerPeer === void 0 || this.ownerPeer === t.peer;
765
+ }
766
+ applyRules(e) {
767
+ if (e === null) {
768
+ d(this.handlers.remote, this.config, null);
769
+ return;
770
+ }
771
+ let t = u(e, this.diagnostics);
772
+ t && d(this.handlers.remote, this.config, t);
773
+ }
774
+ pollRules() {
775
+ let { upstream: e } = this;
776
+ if (this.destroyed || this.role !== "forwarder" || !e) return;
777
+ let t = () => {
778
+ this.config.sampling.remote && e.post({
779
+ t: r.samplingRequest,
780
+ from: this.contextId
781
+ });
782
+ };
783
+ t(), this.rulesPoll = setInterval(t, c), y(this.rulesPoll);
784
+ }
785
+ };
786
+ export { U as Bus };
787
+
788
+ //# sourceMappingURL=bus-dw7T92sO.js.map