@sentry/replay 0.6.14-6 → 7.24.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 (340) hide show
  1. package/README.md +114 -30
  2. package/cjs/constants.js +39 -0
  3. package/cjs/constants.js.map +1 -0
  4. package/cjs/coreHandlers/breadcrumbHandler.js +15 -0
  5. package/cjs/coreHandlers/breadcrumbHandler.js.map +1 -0
  6. package/cjs/coreHandlers/handleDom.js +49 -0
  7. package/cjs/coreHandlers/handleDom.js.map +1 -0
  8. package/cjs/coreHandlers/handleFetch.js +30 -0
  9. package/cjs/coreHandlers/handleFetch.js.map +1 -0
  10. package/cjs/coreHandlers/handleHistory.js +20 -0
  11. package/cjs/coreHandlers/handleHistory.js.map +1 -0
  12. package/cjs/coreHandlers/handleScope.js +38 -0
  13. package/cjs/coreHandlers/handleScope.js.map +1 -0
  14. package/cjs/coreHandlers/handleXhr.js +49 -0
  15. package/cjs/coreHandlers/handleXhr.js.map +1 -0
  16. package/cjs/coreHandlers/spanHandler.js +20 -0
  17. package/cjs/coreHandlers/spanHandler.js.map +1 -0
  18. package/cjs/createPerformanceEntry.js +147 -0
  19. package/cjs/createPerformanceEntry.js.map +1 -0
  20. package/cjs/eventBuffer.js +189 -0
  21. package/cjs/eventBuffer.js.map +1 -0
  22. package/cjs/index.js +191 -0
  23. package/cjs/index.js.map +1 -0
  24. package/cjs/node_modules/rrweb/es/rrweb/ext/@xstate/fsm/es/index.js +22 -0
  25. package/cjs/node_modules/rrweb/es/rrweb/ext/@xstate/fsm/es/index.js.map +1 -0
  26. package/cjs/node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +53 -0
  27. package/cjs/node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js.map +1 -0
  28. package/cjs/node_modules/rrweb/es/rrweb/ext/fflate/esm/browser.js +783 -0
  29. package/cjs/node_modules/rrweb/es/rrweb/ext/fflate/esm/browser.js.map +1 -0
  30. package/cjs/node_modules/rrweb/es/rrweb/ext/mitt/dist/mitt.es.js +59 -0
  31. package/cjs/node_modules/rrweb/es/rrweb/ext/mitt/dist/mitt.es.js.map +1 -0
  32. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +84 -0
  33. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js.map +1 -0
  34. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js +45 -0
  35. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js.map +1 -0
  36. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/index.js +36 -0
  37. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/index.js.map +1 -0
  38. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/base.js +6 -0
  39. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/base.js.map +1 -0
  40. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/pack.js +13 -0
  41. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/pack.js.map +1 -0
  42. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/unpack.js +32 -0
  43. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/unpack.js.map +1 -0
  44. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +183 -0
  45. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js.map +1 -0
  46. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +138 -0
  47. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js.map +1 -0
  48. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +144 -0
  49. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js.map +1 -0
  50. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +114 -0
  51. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js.map +1 -0
  52. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js +35 -0
  53. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js.map +1 -0
  54. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js +385 -0
  55. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js.map +1 -0
  56. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js +519 -0
  57. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js.map +1 -0
  58. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js +671 -0
  59. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js.map +1 -0
  60. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +81 -0
  61. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js.map +1 -0
  62. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +96 -0
  63. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js.map +1 -0
  64. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +33 -0
  65. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js.map +1 -0
  66. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +123 -0
  67. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js.map +1 -0
  68. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +81 -0
  69. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js.map +1 -0
  70. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +48 -0
  71. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js.map +1 -0
  72. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +28 -0
  73. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/2d.js.map +1 -0
  74. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/index.js +38 -0
  75. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/index.js.map +1 -0
  76. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +128 -0
  77. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js.map +1 -0
  78. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/index.js +1716 -0
  79. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/index.js.map +1 -0
  80. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/machine.js +279 -0
  81. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/machine.js.map +1 -0
  82. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +224 -0
  83. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/smoothscroll.js.map +1 -0
  84. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +9 -0
  85. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js.map +1 -0
  86. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/timer.js +94 -0
  87. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/timer.js.map +1 -0
  88. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +127 -0
  89. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/virtual-styles.js.map +1 -0
  90. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/types.js +76 -0
  91. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/types.js.map +1 -0
  92. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js +518 -0
  93. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js.map +1 -0
  94. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1648 -0
  95. package/cjs/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js.map +1 -0
  96. package/cjs/replay.js +1269 -0
  97. package/cjs/replay.js.map +1 -0
  98. package/cjs/session/Session.js +36 -0
  99. package/cjs/session/Session.js.map +1 -0
  100. package/cjs/session/createSession.js +28 -0
  101. package/cjs/session/createSession.js.map +1 -0
  102. package/cjs/session/deleteSession.js +23 -0
  103. package/cjs/session/deleteSession.js.map +1 -0
  104. package/cjs/session/fetchSession.js +33 -0
  105. package/cjs/session/fetchSession.js.map +1 -0
  106. package/cjs/session/getSession.js +45 -0
  107. package/cjs/session/getSession.js.map +1 -0
  108. package/cjs/session/saveSession.js +19 -0
  109. package/cjs/session/saveSession.js.map +1 -0
  110. package/cjs/util/addInternalBreadcrumb.js +25 -0
  111. package/cjs/util/addInternalBreadcrumb.js.map +1 -0
  112. package/cjs/util/captureInternalException.js +18 -0
  113. package/cjs/util/captureInternalException.js.map +1 -0
  114. package/cjs/util/createBreadcrumb.js +14 -0
  115. package/cjs/util/createBreadcrumb.js.map +1 -0
  116. package/cjs/util/createPayload.js +31 -0
  117. package/cjs/util/createPayload.js.map +1 -0
  118. package/cjs/util/dedupePerformanceEntries.js +95 -0
  119. package/cjs/util/dedupePerformanceEntries.js.map +1 -0
  120. package/cjs/util/isBrowser.js +11 -0
  121. package/cjs/util/isBrowser.js.map +1 -0
  122. package/cjs/util/isExpired.js +26 -0
  123. package/cjs/util/isExpired.js.map +1 -0
  124. package/cjs/util/isIngestHost.js +26 -0
  125. package/cjs/util/isIngestHost.js.map +1 -0
  126. package/cjs/util/isInternal.js +15 -0
  127. package/cjs/util/isInternal.js.map +1 -0
  128. package/cjs/util/isSampled.js +19 -0
  129. package/cjs/util/isSampled.js.map +1 -0
  130. package/cjs/util/isSessionExpired.js +24 -0
  131. package/cjs/util/isSessionExpired.js.map +1 -0
  132. package/cjs/worker/worker.js +7 -0
  133. package/cjs/worker/worker.js.map +1 -0
  134. package/esm/constants.js +29 -0
  135. package/esm/constants.js.map +1 -0
  136. package/esm/coreHandlers/breadcrumbHandler.js +13 -0
  137. package/esm/coreHandlers/breadcrumbHandler.js.map +1 -0
  138. package/esm/coreHandlers/handleDom.js +47 -0
  139. package/esm/coreHandlers/handleDom.js.map +1 -0
  140. package/esm/coreHandlers/handleFetch.js +28 -0
  141. package/esm/coreHandlers/handleFetch.js.map +1 -0
  142. package/esm/coreHandlers/handleHistory.js +18 -0
  143. package/esm/coreHandlers/handleHistory.js.map +1 -0
  144. package/esm/coreHandlers/handleScope.js +33 -0
  145. package/esm/coreHandlers/handleScope.js.map +1 -0
  146. package/esm/coreHandlers/handleXhr.js +44 -0
  147. package/esm/coreHandlers/handleXhr.js.map +1 -0
  148. package/esm/coreHandlers/spanHandler.js +18 -0
  149. package/esm/coreHandlers/spanHandler.js.map +1 -0
  150. package/esm/createPerformanceEntry.js +144 -0
  151. package/esm/createPerformanceEntry.js.map +1 -0
  152. package/esm/eventBuffer.js +183 -0
  153. package/esm/eventBuffer.js.map +1 -0
  154. package/esm/index.js +189 -0
  155. package/esm/index.js.map +1 -0
  156. package/esm/node_modules/rrweb/es/rrweb/ext/@xstate/fsm/es/index.js +18 -0
  157. package/esm/node_modules/rrweb/es/rrweb/ext/@xstate/fsm/es/index.js.map +1 -0
  158. package/esm/node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +50 -0
  159. package/esm/node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js.map +1 -0
  160. package/esm/node_modules/rrweb/es/rrweb/ext/fflate/esm/browser.js +778 -0
  161. package/esm/node_modules/rrweb/es/rrweb/ext/fflate/esm/browser.js.map +1 -0
  162. package/esm/node_modules/rrweb/es/rrweb/ext/mitt/dist/mitt.es.js +57 -0
  163. package/esm/node_modules/rrweb/es/rrweb/ext/mitt/dist/mitt.es.js.map +1 -0
  164. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +79 -0
  165. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js.map +1 -0
  166. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js +12 -0
  167. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js.map +1 -0
  168. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/index.js +13 -0
  169. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/index.js.map +1 -0
  170. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/base.js +4 -0
  171. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/base.js.map +1 -0
  172. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/pack.js +11 -0
  173. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/pack.js.map +1 -0
  174. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/unpack.js +30 -0
  175. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/packer/unpack.js.map +1 -0
  176. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +180 -0
  177. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js.map +1 -0
  178. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +135 -0
  179. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/index.js.map +1 -0
  180. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +142 -0
  181. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js.map +1 -0
  182. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +112 -0
  183. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js.map +1 -0
  184. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js +33 -0
  185. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js.map +1 -0
  186. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js +383 -0
  187. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js.map +1 -0
  188. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js +517 -0
  189. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js.map +1 -0
  190. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js +665 -0
  191. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js.map +1 -0
  192. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +79 -0
  193. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js.map +1 -0
  194. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +94 -0
  195. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js.map +1 -0
  196. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +31 -0
  197. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js.map +1 -0
  198. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +117 -0
  199. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js.map +1 -0
  200. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +79 -0
  201. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js.map +1 -0
  202. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +46 -0
  203. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js.map +1 -0
  204. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +26 -0
  205. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/2d.js.map +1 -0
  206. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/index.js +36 -0
  207. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/index.js.map +1 -0
  208. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +124 -0
  209. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js.map +1 -0
  210. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/index.js +1715 -0
  211. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/index.js.map +1 -0
  212. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/machine.js +275 -0
  213. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/machine.js.map +1 -0
  214. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +222 -0
  215. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/smoothscroll.js.map +1 -0
  216. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +7 -0
  217. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js.map +1 -0
  218. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/timer.js +91 -0
  219. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/timer.js.map +1 -0
  220. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +122 -0
  221. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/replay/virtual-styles.js.map +1 -0
  222. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/types.js +76 -0
  223. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/types.js.map +1 -0
  224. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js +499 -0
  225. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js.map +1 -0
  226. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1634 -0
  227. package/esm/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js.map +1 -0
  228. package/esm/replay.js +1264 -0
  229. package/esm/replay.js.map +1 -0
  230. package/esm/session/Session.js +33 -0
  231. package/esm/session/Session.js.map +1 -0
  232. package/esm/session/createSession.js +26 -0
  233. package/esm/session/createSession.js.map +1 -0
  234. package/esm/session/deleteSession.js +21 -0
  235. package/esm/session/deleteSession.js.map +1 -0
  236. package/esm/session/fetchSession.js +31 -0
  237. package/esm/session/fetchSession.js.map +1 -0
  238. package/esm/session/getSession.js +43 -0
  239. package/esm/session/getSession.js.map +1 -0
  240. package/esm/session/saveSession.js +17 -0
  241. package/esm/session/saveSession.js.map +1 -0
  242. package/esm/util/addInternalBreadcrumb.js +23 -0
  243. package/esm/util/addInternalBreadcrumb.js.map +1 -0
  244. package/esm/util/captureInternalException.js +16 -0
  245. package/esm/util/captureInternalException.js.map +1 -0
  246. package/esm/util/createBreadcrumb.js +12 -0
  247. package/esm/util/createBreadcrumb.js.map +1 -0
  248. package/esm/util/createPayload.js +29 -0
  249. package/esm/util/createPayload.js.map +1 -0
  250. package/esm/util/dedupePerformanceEntries.js +93 -0
  251. package/esm/util/dedupePerformanceEntries.js.map +1 -0
  252. package/esm/util/isBrowser.js +9 -0
  253. package/esm/util/isBrowser.js.map +1 -0
  254. package/esm/util/isExpired.js +24 -0
  255. package/esm/util/isExpired.js.map +1 -0
  256. package/esm/util/isIngestHost.js +21 -0
  257. package/esm/util/isIngestHost.js.map +1 -0
  258. package/esm/util/isInternal.js +13 -0
  259. package/esm/util/isInternal.js.map +1 -0
  260. package/esm/util/isSampled.js +17 -0
  261. package/esm/util/isSampled.js.map +1 -0
  262. package/esm/util/isSessionExpired.js +19 -0
  263. package/esm/util/isSessionExpired.js.map +1 -0
  264. package/esm/worker/worker.js +5 -0
  265. package/esm/worker/worker.js.map +1 -0
  266. package/package.json +16 -64
  267. package/{dist/types/src/session → types}/constants.d.ts +2 -0
  268. package/types/constants.d.ts.map +1 -0
  269. package/types/coreHandlers/breadcrumbHandler.d.ts +4 -0
  270. package/types/coreHandlers/breadcrumbHandler.d.ts.map +1 -0
  271. package/types/coreHandlers/handleDom.d.ts +9 -0
  272. package/types/coreHandlers/handleDom.d.ts.map +1 -0
  273. package/{dist/types/src → types}/coreHandlers/handleFetch.d.ts +2 -2
  274. package/types/coreHandlers/handleFetch.d.ts.map +1 -0
  275. package/{dist/types/src → types}/coreHandlers/handleHistory.d.ts +2 -2
  276. package/types/coreHandlers/handleHistory.d.ts.map +1 -0
  277. package/{dist/types/src → types}/coreHandlers/handleScope.d.ts +1 -0
  278. package/types/coreHandlers/handleScope.d.ts.map +1 -0
  279. package/{dist/types/src → types}/coreHandlers/handleXhr.d.ts +3 -2
  280. package/types/coreHandlers/handleXhr.d.ts.map +1 -0
  281. package/types/coreHandlers/spanHandler.d.ts +4 -0
  282. package/types/coreHandlers/spanHandler.d.ts.map +1 -0
  283. package/{dist/types/src → types}/createPerformanceEntry.d.ts +4 -10
  284. package/types/createPerformanceEntry.d.ts.map +1 -0
  285. package/types/eventBuffer.d.ts +34 -0
  286. package/types/eventBuffer.d.ts.map +1 -0
  287. package/types/index.d.ts +48 -0
  288. package/types/index.d.ts.map +1 -0
  289. package/{dist/types/src/index.d.ts → types/replay.d.ts} +49 -53
  290. package/types/replay.d.ts.map +1 -0
  291. package/types/session/Session.d.ts +37 -0
  292. package/types/session/Session.d.ts.map +1 -0
  293. package/{dist/types/src → types}/session/createSession.d.ts +2 -1
  294. package/types/session/createSession.d.ts.map +1 -0
  295. package/{dist/types/src → types}/session/deleteSession.d.ts +1 -0
  296. package/types/session/deleteSession.d.ts.map +1 -0
  297. package/types/session/fetchSession.d.ts +6 -0
  298. package/types/session/fetchSession.d.ts.map +1 -0
  299. package/{dist/types/src → types}/session/getSession.d.ts +2 -1
  300. package/types/session/getSession.d.ts.map +1 -0
  301. package/types/session/index.d.ts +2 -0
  302. package/types/session/index.d.ts.map +1 -0
  303. package/{dist/types/src → types}/session/saveSession.d.ts +1 -0
  304. package/types/session/saveSession.d.ts.map +1 -0
  305. package/{dist/types/src → types}/types.d.ts +8 -15
  306. package/types/types.d.ts.map +1 -0
  307. package/{dist/types/src → types}/util/addInternalBreadcrumb.d.ts +1 -0
  308. package/types/util/addInternalBreadcrumb.d.ts.map +1 -0
  309. package/{dist/types/src → types}/util/captureInternalException.d.ts +1 -0
  310. package/types/util/captureInternalException.d.ts.map +1 -0
  311. package/{dist/types/src → types}/util/createBreadcrumb.d.ts +1 -0
  312. package/types/util/createBreadcrumb.d.ts.map +1 -0
  313. package/{dist/types/src → types}/util/createPayload.d.ts +2 -1
  314. package/types/util/createPayload.d.ts.map +1 -0
  315. package/{dist/types/src → types}/util/dedupePerformanceEntries.d.ts +2 -1
  316. package/types/util/dedupePerformanceEntries.d.ts.map +1 -0
  317. package/types/util/isBrowser.d.ts +2 -0
  318. package/types/util/isBrowser.d.ts.map +1 -0
  319. package/{dist/types/src → types}/util/isExpired.d.ts +1 -0
  320. package/types/util/isExpired.d.ts.map +1 -0
  321. package/{dist/types/src → types}/util/isIngestHost.d.ts +1 -0
  322. package/types/util/isIngestHost.d.ts.map +1 -0
  323. package/{dist/types/src → types}/util/isInternal.d.ts +1 -0
  324. package/types/util/isInternal.d.ts.map +1 -0
  325. package/{dist/types/src → types}/util/isSampled.d.ts +1 -0
  326. package/types/util/isSampled.d.ts.map +1 -0
  327. package/{dist/types/src → types}/util/isSessionExpired.d.ts +1 -0
  328. package/types/util/isSessionExpired.d.ts.map +1 -0
  329. package/dist/index.es.js +0 -2085
  330. package/dist/index.js +0 -2094
  331. package/dist/index.js.map +0 -1
  332. package/dist/types/src/coreHandlers/getBreadcrumbHandler.d.ts +0 -3
  333. package/dist/types/src/coreHandlers/getSpanHandler.d.ts +0 -5
  334. package/dist/types/src/coreHandlers/handleDom.d.ts +0 -1
  335. package/dist/types/src/eventBuffer.d.ts +0 -45
  336. package/dist/types/src/flags.d.ts +0 -2
  337. package/dist/types/src/session/Session.d.ts +0 -63
  338. package/dist/types/src/session/fetchSession.d.ts +0 -6
  339. package/dist/types/src/session/index.d.ts +0 -1
  340. package/dist/types/src/util/logger.d.ts +0 -12
package/dist/index.js DELETED
@@ -1,2094 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@sentry/core');
6
- var utils = require('@sentry/utils');
7
- var debounce = require('lodash.debounce');
8
- var rrweb = require('rrweb');
9
-
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
13
-
14
- /******************************************************************************
15
- Copyright (c) Microsoft Corporation.
16
-
17
- Permission to use, copy, modify, and/or distribute this software for any
18
- purpose with or without fee is hereby granted.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
- PERFORMANCE OF THIS SOFTWARE.
27
- ***************************************************************************** */
28
-
29
- var __assign = function() {
30
- __assign = Object.assign || function __assign(t) {
31
- for (var s, i = 1, n = arguments.length; i < n; i++) {
32
- s = arguments[i];
33
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34
- }
35
- return t;
36
- };
37
- return __assign.apply(this, arguments);
38
- };
39
-
40
- function __rest(s, e) {
41
- var t = {};
42
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
43
- t[p] = s[p];
44
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
45
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
46
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
47
- t[p[i]] = s[p[i]];
48
- }
49
- return t;
50
- }
51
-
52
- function __awaiter(thisArg, _arguments, P, generator) {
53
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
54
- return new (P || (P = Promise))(function (resolve, reject) {
55
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
56
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
57
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
58
- step((generator = generator.apply(thisArg, _arguments || [])).next());
59
- });
60
- }
61
-
62
- function __generator(thisArg, body) {
63
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
64
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
65
- function verb(n) { return function (v) { return step([n, v]); }; }
66
- function step(op) {
67
- if (f) throw new TypeError("Generator is already executing.");
68
- while (_) try {
69
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
70
- if (y = 0, t) op = [op[0] & 2, t.value];
71
- switch (op[0]) {
72
- case 0: case 1: t = op; break;
73
- case 4: _.label++; return { value: op[1], done: false };
74
- case 5: _.label++; y = op[1]; op = [0]; continue;
75
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
76
- default:
77
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
78
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
79
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
80
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
81
- if (t[2]) _.ops.pop();
82
- _.trys.pop(); continue;
83
- }
84
- op = body.call(thisArg, _);
85
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
86
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
87
- }
88
- }
89
-
90
- function __spreadArray(to, from, pack) {
91
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
92
- if (ar || !(i in from)) {
93
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
94
- ar[i] = from[i];
95
- }
96
- }
97
- return to.concat(ar || Array.prototype.slice.call(from));
98
- }
99
-
100
- function createBreadcrumb(breadcrumb) {
101
- return __assign({ timestamp: new Date().getTime() / 1000, type: 'default' }, breadcrumb);
102
- }
103
-
104
- function handleDom(handlerData) {
105
- // Taken from https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L112
106
- var target;
107
- var targetNode;
108
- // Accessing event.target can throw (see getsentry/raven-js#838, #768)
109
- try {
110
- targetNode =
111
- handlerData.event.target ||
112
- handlerData.event;
113
- target = utils.htmlTreeAsString(targetNode);
114
- }
115
- catch (e) {
116
- target = '<unknown>';
117
- }
118
- if (target.length === 0) {
119
- return null;
120
- }
121
- return createBreadcrumb({
122
- category: "ui.".concat(handlerData.name),
123
- message: target,
124
- data: __assign({}, (targetNode ? { nodeId: rrweb.record.mirror.getId(targetNode) } : {})),
125
- });
126
- }
127
-
128
- var _LAST_BREADCRUMB = null;
129
- function handleScope(scope) {
130
- var _a;
131
- //@ts-expect-error using private val
132
- var newBreadcrumb = scope._breadcrumbs[scope._breadcrumbs.length - 1];
133
- // Listener can be called when breadcrumbs have not changed, so we store the
134
- // reference to the last crumb and only return a crumb if it has changed
135
- if (_LAST_BREADCRUMB === newBreadcrumb || !newBreadcrumb) {
136
- return null;
137
- }
138
- _LAST_BREADCRUMB = newBreadcrumb;
139
- if (['fetch', 'xhr', 'sentry.event', 'sentry.transaction'].includes(newBreadcrumb.category) ||
140
- ((_a = newBreadcrumb.category) === null || _a === void 0 ? void 0 : _a.startsWith('ui.'))) {
141
- return null;
142
- }
143
- return createBreadcrumb(newBreadcrumb);
144
- }
145
-
146
- function getBreadcrumbHandler(type) {
147
- if (type === 'scope') {
148
- return handleScope;
149
- }
150
- return handleDom;
151
- }
152
-
153
- var isBrowser$1 = typeof window !== 'undefined';
154
- /**
155
- * Returns true if we are currently recording an internal to Sentry replay
156
- * (e.g. on https://sentry.io )
157
- */
158
- function isInternal() {
159
- return (isBrowser$1 &&
160
- ['sentry.io', 'dev.getsentry.net'].includes(window.location.host));
161
- }
162
-
163
- /**
164
- * Checks is `targetHost` is a Sentry ingestion host
165
- */
166
- function isIngestHost(targetHost) {
167
- var _a;
168
- var _b = ((_a = core.getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getDsn()) || {}, protocol = _b.protocol, host = _b.host;
169
- // XXX: Special case when this integration is used by Sentry on `sentry.io`
170
- // We would like to capture network requests made to our ingest endpoints for debugging
171
- if (isInternal()) {
172
- return false;
173
- }
174
- return targetHost.startsWith("".concat(protocol, "://").concat(host));
175
- }
176
-
177
- function handleFetch(handlerData) {
178
- if (!handlerData.endTimestamp) {
179
- return null;
180
- }
181
- var startTimestamp = handlerData.startTimestamp, endTimestamp = handlerData.endTimestamp, fetchData = handlerData.fetchData, response = handlerData.response;
182
- // Do not capture fetches to Sentry ingestion endpoint
183
- if (isIngestHost(fetchData.url)) {
184
- return null;
185
- }
186
- return {
187
- type: 'resource.fetch',
188
- start: startTimestamp / 1000,
189
- end: endTimestamp / 1000,
190
- name: fetchData.url,
191
- data: {
192
- method: fetchData.method,
193
- statusCode: response.status,
194
- },
195
- };
196
- }
197
-
198
- function handleHistory(handlerData) {
199
- var from = handlerData.from, to = handlerData.to;
200
- var now = new Date().getTime() / 1000;
201
- return {
202
- type: 'navigation.push',
203
- start: now,
204
- end: now,
205
- name: to,
206
- data: {
207
- previous: from,
208
- },
209
- };
210
- }
211
-
212
- function handleXhr(handlerData) {
213
- var _a;
214
- if (handlerData.xhr.__sentry_own_request__) {
215
- // Taken from sentry-javascript
216
- // Only capture non-sentry requests
217
- return null;
218
- }
219
- if (handlerData.startTimestamp) {
220
- // TODO: See if this is still needed
221
- handlerData.xhr.__sentry_xhr__ = handlerData.xhr.__sentry_xhr__ || {};
222
- handlerData.xhr.__sentry_xhr__.startTimestamp = handlerData.startTimestamp;
223
- }
224
- if (!handlerData.endTimestamp) {
225
- return null;
226
- }
227
- var _b = handlerData.xhr.__sentry_xhr__ || {}, method = _b.method, url = _b.url, statusCode = _b.status_code;
228
- // Do not capture fetches to Sentry ingestion endpoint
229
- if (url === undefined || isIngestHost(url)) {
230
- return null;
231
- }
232
- return {
233
- type: 'resource.xhr',
234
- name: url,
235
- start: (((_a = handlerData.xhr.__sentry_xhr__) === null || _a === void 0 ? void 0 : _a.startTimestamp) || 0) / 1000 ||
236
- handlerData.endTimestamp / 1000.0,
237
- end: handlerData.endTimestamp / 1000.0,
238
- data: {
239
- method: method,
240
- statusCode: statusCode,
241
- },
242
- };
243
- }
244
-
245
- function getSpanHandler(type) {
246
- if (type === 'fetch') {
247
- return handleFetch;
248
- }
249
- if (type === 'xhr') {
250
- return handleXhr;
251
- }
252
- return handleHistory;
253
- }
254
-
255
- var REPLAY_SESSION_KEY = 'sentryReplaySession';
256
- var REPLAY_EVENT_NAME = 'replay_event';
257
- // The idle limit for a session
258
- var SESSION_IDLE_DURATION = 300000; // 5 minutes in ms
259
- // Grace period to keep a session when a user changes tabs or hides window
260
- var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
261
- // The maximum length of a session
262
- var MAX_SESSION_LIFE = 1800000; // 30 minutes
263
- /**
264
- * Defaults for sampling rates
265
- */
266
- var DEFAULT_SESSION_SAMPLE_RATE = 0.1;
267
- var DEFAULT_ERROR_SAMPLE_RATE = 1.0;
268
-
269
- /**
270
- * Deletes a session from storage
271
- */
272
- function deleteSession() {
273
- var hasSessionStorage = 'sessionStorage' in window;
274
- if (!hasSessionStorage) {
275
- return;
276
- }
277
- try {
278
- window.sessionStorage.removeItem(REPLAY_SESSION_KEY);
279
- }
280
- catch (_a) {
281
- // Ignore potential SecurityError exceptions
282
- }
283
- }
284
-
285
- /**
286
- * Given an initial timestamp and an expiry duration, checks to see if current
287
- * time should be considered as expired.
288
- */
289
- function isExpired(initialTime, expiry, targetTime) {
290
- if (targetTime === void 0) { targetTime = +new Date(); }
291
- // Always expired if < 0
292
- if (initialTime === null || expiry === undefined || expiry < 0) {
293
- return true;
294
- }
295
- // Never expires if == 0
296
- if (expiry === 0) {
297
- return false;
298
- }
299
- return initialTime + expiry <= targetTime;
300
- }
301
-
302
- /**
303
- * Checks to see if session is expired
304
- */
305
- function isSessionExpired(session, idleTimeout, targetTime) {
306
- if (targetTime === void 0) { targetTime = +new Date(); }
307
- return (
308
- // First, check that maximum session length has not been exceeded
309
- isExpired(session.started, MAX_SESSION_LIFE, targetTime) ||
310
- // check that the idle timeout has not been exceeded (i.e. user has
311
- // performed an action within the last `idleTimeout` ms)
312
- isExpired(session === null || session === void 0 ? void 0 : session.lastActivity, idleTimeout, targetTime));
313
- }
314
-
315
- function wrapLogger(logFn) {
316
- return function wrappedLog() {
317
- var args = [];
318
- for (var _i = 0; _i < arguments.length; _i++) {
319
- args[_i] = arguments[_i];
320
- }
321
- return logFn.call.apply(logFn, __spreadArray([utils.logger, '[Replay]'], args, false));
322
- };
323
- }
324
- var logger = __assign(__assign({}, utils.logger), { error: wrapLogger(utils.logger.error), warn: wrapLogger(utils.logger.warn), log: wrapLogger(utils.logger.log) });
325
-
326
- function saveSession(session) {
327
- var hasSessionStorage = 'sessionStorage' in window;
328
- if (!hasSessionStorage) {
329
- return;
330
- }
331
- try {
332
- window.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
333
- }
334
- catch (_a) {
335
- // Ignore potential SecurityError exceptions
336
- }
337
- }
338
-
339
- /**
340
- * Given a sample rate, returns true if replay should be sampled.
341
- *
342
- * 1.0 = 100% sampling
343
- * 0.0 = 0% sampling
344
- */
345
- function isSampled(sampleRate) {
346
- if (sampleRate === undefined) {
347
- return false;
348
- }
349
- // Math.random() returns a number in range of 0 to 1 (inclusive of 0, but not 1)
350
- return Math.random() < sampleRate;
351
- }
352
-
353
- var Session = /** @class */ (function () {
354
- function Session(session, _a) {
355
- if (session === void 0) { session = {}; }
356
- var stickySession = _a.stickySession, sessionSampleRate = _a.sessionSampleRate, errorSampleRate = _a.errorSampleRate;
357
- var _b, _c, _d, _e;
358
- var now = new Date().getTime();
359
- this._id = session.id || utils.uuid4();
360
- this._started = (_b = session.started) !== null && _b !== void 0 ? _b : now;
361
- this._lastActivity = (_c = session.lastActivity) !== null && _c !== void 0 ? _c : now;
362
- this._segmentId = (_d = session.segmentId) !== null && _d !== void 0 ? _d : 0;
363
- this._sampled =
364
- (_e = session.sampled) !== null && _e !== void 0 ? _e : (isSampled(sessionSampleRate)
365
- ? 'session'
366
- : isSampled(errorSampleRate)
367
- ? 'error'
368
- : false);
369
- this.options = {
370
- stickySession: stickySession,
371
- };
372
- }
373
- Object.defineProperty(Session.prototype, "id", {
374
- get: function () {
375
- return this._id;
376
- },
377
- enumerable: false,
378
- configurable: true
379
- });
380
- Object.defineProperty(Session.prototype, "started", {
381
- get: function () {
382
- return this._started;
383
- },
384
- set: function (newDate) {
385
- this._started = newDate;
386
- if (this.options.stickySession) {
387
- saveSession(this);
388
- }
389
- },
390
- enumerable: false,
391
- configurable: true
392
- });
393
- Object.defineProperty(Session.prototype, "lastActivity", {
394
- get: function () {
395
- return this._lastActivity;
396
- },
397
- set: function (newDate) {
398
- this._lastActivity = newDate;
399
- if (this.options.stickySession) {
400
- saveSession(this);
401
- }
402
- },
403
- enumerable: false,
404
- configurable: true
405
- });
406
- Object.defineProperty(Session.prototype, "segmentId", {
407
- get: function () {
408
- return this._segmentId;
409
- },
410
- set: function (id) {
411
- this._segmentId = id;
412
- if (this.options.stickySession) {
413
- saveSession(this);
414
- }
415
- },
416
- enumerable: false,
417
- configurable: true
418
- });
419
- Object.defineProperty(Session.prototype, "previousSessionId", {
420
- get: function () {
421
- return this._previousSessionId;
422
- },
423
- set: function (id) {
424
- this._previousSessionId = id;
425
- },
426
- enumerable: false,
427
- configurable: true
428
- });
429
- Object.defineProperty(Session.prototype, "sampled", {
430
- get: function () {
431
- return this._sampled;
432
- },
433
- set: function (_isSampled) {
434
- throw new Error('Unable to change sampled value');
435
- },
436
- enumerable: false,
437
- configurable: true
438
- });
439
- Session.prototype.toJSON = function () {
440
- return {
441
- id: this.id,
442
- started: this.started,
443
- lastActivity: this.lastActivity,
444
- segmentId: this._segmentId,
445
- sampled: this._sampled,
446
- };
447
- };
448
- return Session;
449
- }());
450
-
451
- /**
452
- * Create a new session, which in its current implementation is a Sentry event
453
- * that all replays will be saved to as attachments. Currently, we only expect
454
- * one of these Sentry events per "replay session".
455
- */
456
- function createSession(_a) {
457
- var sessionSampleRate = _a.sessionSampleRate, errorSampleRate = _a.errorSampleRate, _b = _a.stickySession, stickySession = _b === void 0 ? false : _b;
458
- var session = new Session(undefined, {
459
- stickySession: stickySession,
460
- errorSampleRate: errorSampleRate,
461
- sessionSampleRate: sessionSampleRate,
462
- });
463
- logger.log("Creating new session: ".concat(session.id));
464
- if (stickySession) {
465
- saveSession(session);
466
- }
467
- return session;
468
- }
469
-
470
- /**
471
- * Fetches a session from storage
472
- */
473
- function fetchSession(_a) {
474
- var sessionSampleRate = _a.sessionSampleRate, errorSampleRate = _a.errorSampleRate;
475
- var hasSessionStorage = 'sessionStorage' in window;
476
- if (!hasSessionStorage) {
477
- return null;
478
- }
479
- try {
480
- // This can throw if cookies are disabled
481
- var sessionStringFromStorage = window.sessionStorage.getItem(REPLAY_SESSION_KEY);
482
- if (!sessionStringFromStorage) {
483
- return null;
484
- }
485
- var sessionObj = JSON.parse(sessionStringFromStorage);
486
- return new Session(sessionObj,
487
- // We are assuming that if there is a saved item, then the session is sticky,
488
- // however this could break down if we used a different storage mechanism (e.g. localstorage)
489
- { stickySession: true, sessionSampleRate: sessionSampleRate, errorSampleRate: errorSampleRate });
490
- }
491
- catch (_b) {
492
- return null;
493
- }
494
- }
495
-
496
- /**
497
- * Get or create a session
498
- */
499
- function getSession(_a) {
500
- var expiry = _a.expiry, currentSession = _a.currentSession, stickySession = _a.stickySession, sessionSampleRate = _a.sessionSampleRate, errorSampleRate = _a.errorSampleRate;
501
- // If session exists and is passed, use it instead of always hitting session storage
502
- var session = currentSession ||
503
- (stickySession && fetchSession({ sessionSampleRate: sessionSampleRate, errorSampleRate: errorSampleRate }));
504
- if (session) {
505
- // If there is a session, check if it is valid (e.g. "last activity" time
506
- // should be within the "session idle time", and "session started" time is
507
- // within "max session time").
508
- var isExpired = isSessionExpired(session, expiry);
509
- if (!isExpired) {
510
- return { type: 'saved', session: session };
511
- }
512
- else {
513
- logger.log("Session has expired");
514
- }
515
- // Otherwise continue to create a new session
516
- }
517
- var newSession = createSession({
518
- stickySession: stickySession,
519
- sessionSampleRate: sessionSampleRate,
520
- errorSampleRate: errorSampleRate,
521
- });
522
- return { type: 'new', session: newSession };
523
- }
524
-
525
- /**
526
- * Wrapper for core SDK's `addBreadcrumb` only when used on `sentry.io`
527
- */
528
- function addInternalBreadcrumb(arg) {
529
- if (!isInternal()) {
530
- return;
531
- }
532
- var category = arg.category, level = arg.level, message = arg.message, rest = __rest(arg, ["category", "level", "message"]);
533
- core.addBreadcrumb(__assign({ category: category || 'console', level: level || 'debug', message: "[debug]: ".concat(message) }, rest));
534
- }
535
-
536
- /**
537
- * Captures exceptions to Sentry only when it occurs on sentry.io
538
- */
539
- function captureInternalException(err) {
540
- if (!isInternal()) {
541
- return;
542
- }
543
- core.captureException(err);
544
- }
545
-
546
- function createPayload(_a) {
547
- var events = _a.events, headers = _a.headers;
548
- var payloadWithSequence;
549
- // XXX: newline is needed to separate sequence id from events
550
- var replayHeaders = "".concat(JSON.stringify(headers), "\n");
551
- if (typeof events === 'string') {
552
- payloadWithSequence = "".concat(replayHeaders).concat(events);
553
- }
554
- else {
555
- var enc = new TextEncoder();
556
- // XXX: newline is needed to separate sequence id from events
557
- var sequence = enc.encode(replayHeaders);
558
- // Merge the two Uint8Arrays
559
- payloadWithSequence = new Uint8Array(sequence.length + events.length);
560
- payloadWithSequence.set(sequence);
561
- payloadWithSequence.set(events, sequence.length);
562
- }
563
- return payloadWithSequence;
564
- }
565
-
566
- var NAVIGATION_ENTRY_KEYS = [
567
- 'name',
568
- 'type',
569
- 'startTime',
570
- 'transferSize',
571
- 'duration',
572
- ];
573
- function isNavigationEntryEqual(a) {
574
- return function (b) {
575
- return NAVIGATION_ENTRY_KEYS.every(function (key) { return a[key] === b[key]; });
576
- };
577
- }
578
- /**
579
- * There are some difficulties diagnosing why there are duplicate navigation
580
- * entries. We've witnessed several intermittent results:
581
- * - duplicate entries have duration = 0
582
- * - duplicate entries are the same object reference
583
- * - none of the above
584
- *
585
- * Compare the values of several keys to determine if the entries are duplicates or not.
586
- */
587
- function dedupePerformanceEntries(currentList, newList) {
588
- // Partition `currentList` into 3 different lists based on entryType
589
- var _a = currentList.reduce(function (acc, entry) {
590
- if (entry.entryType === 'navigation') {
591
- acc[0].push(entry);
592
- }
593
- else if (entry.entryType === 'largest-contentful-paint') {
594
- acc[1].push(entry);
595
- }
596
- else {
597
- acc[2].push(entry);
598
- }
599
- return acc;
600
- }, [[], [], []]), existingNavigationEntries = _a[0], existingLcpEntries = _a[1], existingEntries = _a[2];
601
- var newEntries = [];
602
- var newNavigationEntries = [];
603
- var newLcpEntry = existingLcpEntries.length
604
- ? existingLcpEntries[existingLcpEntries.length - 1] // Take the last element as list is sorted
605
- : undefined;
606
- newList.forEach(function (entry) {
607
- if (entry.entryType === 'largest-contentful-paint') {
608
- // We want the latest LCP event only
609
- if (!newLcpEntry || newLcpEntry.startTime < entry.startTime) {
610
- newLcpEntry = entry;
611
- }
612
- return;
613
- }
614
- if (entry.entryType === 'navigation') {
615
- var navigationEntry = entry;
616
- // Check if the navigation entry is contained in currentList or newList
617
- if (
618
- // Ignore any navigation entries with duration 0, as they are likely duplicates
619
- entry.duration > 0 &&
620
- // Ensure new entry does not already exist in existing entries
621
- !existingNavigationEntries.find(isNavigationEntryEqual(navigationEntry)) &&
622
- // Ensure new entry does not already exist in new list of navigation entries
623
- !newNavigationEntries.find(isNavigationEntryEqual(navigationEntry))) {
624
- newNavigationEntries.push(navigationEntry);
625
- }
626
- // Otherwise this navigation entry is considered a duplicate and is thrown away
627
- return;
628
- }
629
- newEntries.push(entry);
630
- });
631
- // Re-combine and sort by startTime
632
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], (newLcpEntry ? [newLcpEntry] : []), true), existingNavigationEntries, true), existingEntries, true), newEntries, true), newNavigationEntries, true).sort(function (a, b) { return a.startTime - b.startTime; });
633
- }
634
-
635
- var _a;
636
- // Map entryType -> function to normalize data for event
637
- var ENTRY_TYPES = (_a = {
638
- resource: createResourceEntry,
639
- paint: createPaintEntry,
640
- navigation: createNavigationEntry
641
- },
642
- _a['largest-contentful-paint'] = createLargestContentfulPaint,
643
- _a);
644
- function createPerformanceEntries(entries) {
645
- return entries
646
- .map(createPerformanceEntry)
647
- .filter(Boolean);
648
- }
649
- function createPerformanceEntry(entry) {
650
- if (ENTRY_TYPES[entry.entryType] === undefined) {
651
- return null;
652
- }
653
- return ENTRY_TYPES[entry.entryType](entry);
654
- }
655
- function getAbsoluteTime(time) {
656
- // browserPerformanceTimeOrigin can be undefined if `performance` or
657
- // `performance.now` doesn't exist, but this is already checked by this integration
658
- return (((utils.browserPerformanceTimeOrigin || window.performance.timeOrigin) + time) /
659
- 1000);
660
- }
661
- function createPaintEntry(entry) {
662
- var duration = entry.duration, entryType = entry.entryType, name = entry.name, startTime = entry.startTime;
663
- var start = getAbsoluteTime(startTime);
664
- return {
665
- type: entryType,
666
- name: name,
667
- start: start,
668
- end: start + duration,
669
- };
670
- }
671
- function createNavigationEntry(entry) {
672
- // TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)
673
- var entryType = entry.entryType, name = entry.name, duration = entry.duration, domComplete = entry.domComplete, startTime = entry.startTime, transferSize = entry.transferSize, type = entry.type;
674
- // Ignore entries with no duration, they do not seem to be useful and cause dupes
675
- if (duration === 0) {
676
- return null;
677
- }
678
- return {
679
- type: "".concat(entryType, ".").concat(type),
680
- start: getAbsoluteTime(startTime),
681
- end: getAbsoluteTime(domComplete),
682
- name: name,
683
- data: {
684
- size: transferSize,
685
- duration: duration,
686
- },
687
- };
688
- }
689
- function createResourceEntry(entry) {
690
- var entryType = entry.entryType, initiatorType = entry.initiatorType, name = entry.name, responseEnd = entry.responseEnd, startTime = entry.startTime, encodedBodySize = entry.encodedBodySize, transferSize = entry.transferSize;
691
- // Do not capture fetches to Sentry ingestion endpoint
692
- if (isIngestHost(name)) {
693
- return null;
694
- }
695
- // Core SDK handles these
696
- if (['fetch', 'xmlhttprequest'].includes(initiatorType)) {
697
- return null;
698
- }
699
- return {
700
- type: "".concat(entryType, ".").concat(initiatorType),
701
- start: getAbsoluteTime(startTime),
702
- end: getAbsoluteTime(responseEnd),
703
- name: name,
704
- data: {
705
- size: transferSize,
706
- encodedBodySize: encodedBodySize,
707
- },
708
- };
709
- }
710
- function createLargestContentfulPaint(entry) {
711
- var duration = entry.duration, entryType = entry.entryType, startTime = entry.startTime, size = entry.size;
712
- var start = getAbsoluteTime(startTime);
713
- return {
714
- type: entryType,
715
- name: entryType,
716
- start: start,
717
- end: start + duration,
718
- data: {
719
- duration: duration,
720
- size: size,
721
- // Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
722
- nodeId: rrweb.record.mirror.getId(entry.element),
723
- },
724
- };
725
- }
726
- function createMemoryEntry(memoryEntry) {
727
- var jsHeapSizeLimit = memoryEntry.jsHeapSizeLimit, totalJSHeapSize = memoryEntry.totalJSHeapSize, usedJSHeapSize = memoryEntry.usedJSHeapSize;
728
- // we don't want to use `getAbsoluteTime` because it adds the event time to the
729
- // time origin, so we get the current timestamp instead
730
- var time = new Date().getTime() / 1000;
731
- return {
732
- type: 'memory',
733
- name: 'memory',
734
- start: time,
735
- end: time,
736
- data: {
737
- memory: {
738
- jsHeapSizeLimit: jsHeapSizeLimit,
739
- totalJSHeapSize: totalJSHeapSize,
740
- usedJSHeapSize: usedJSHeapSize,
741
- },
742
- },
743
- };
744
- }
745
-
746
- var workerString = `/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */
747
- function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),a=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),i=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Array(576);t(s);const r=new Array(60);t(r);const o=new Array(512);t(o);const l=new Array(256);t(l);const h=new Array(29);t(h);const d=new Array(30);function _(t,e,a,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let f,c,u;function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);const b=t=>t<256?o[t]:o[256+(t>>>7)],g=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},p=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,g(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=a)},m=(t,e,a)=>{p(t,a[2*e],a[2*e+1])},k=(t,e)=>{let a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},v=(t,e,a)=>{const i=new Array(16);let n,s,r=0;for(n=1;n<=15;n++)i[n]=r=r+a[n-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=k(i[e]++,e))}},y=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},x=t=>{t.bi_valid>8?g(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},z=(t,e,a,i)=>{const n=2*e,s=2*a;return t[n]<t[s]||t[n]===t[s]&&i[e]<=i[a]},A=(t,e,a)=>{const i=t.heap[a];let n=a<<1;for(;n<=t.heap_len&&(n<t.heap_len&&z(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!z(e,i,t.heap[n],t.depth));)t.heap[a]=t.heap[n],a=n,n<<=1;t.heap[a]=i},E=(t,i,n)=>{let s,r,o,_,f=0;if(0!==t.last_lit)do{s=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],r=t.pending_buf[t.l_buf+f],f++,0===s?m(t,r,i):(o=l[r],m(t,o+256+1,i),_=e[o],0!==_&&(r-=h[o],p(t,r,_)),s--,o=b(s),m(t,o,n),_=a[o],0!==_&&(s-=d[o],p(t,s,_)))}while(f<t.last_lit);m(t,256,i)},R=(t,e)=>{const a=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,s=e.stat_desc.elems;let r,o,l,h=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<s;r++)0!==a[2*r]?(t.heap[++t.heap_len]=h=r,t.depth[r]=0):a[2*r+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=h<2?++h:0,a[2*l]=1,t.depth[l]=0,t.opt_len--,n&&(t.static_len-=i[2*l+1]);for(e.max_code=h,r=t.heap_len>>1;r>=1;r--)A(t,a,r);l=s;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],A(t,a,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,a[2*l]=a[2*r]+a[2*o],t.depth[l]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,a[2*r+1]=a[2*o+1]=l,t.heap[1]=l++,A(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const a=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,s=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,l=e.stat_desc.max_length;let h,d,_,f,c,u,w=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(a[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)d=t.heap[h],f=a[2*a[2*d+1]+1]+1,f>l&&(f=l,w++),a[2*d+1]=f,d>i||(t.bl_count[f]++,c=0,d>=o&&(c=r[d-o]),u=a[2*d],t.opt_len+=u*(f+c),s&&(t.static_len+=u*(n[2*d+1]+c)));if(0!==w){do{for(f=l-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[l]--,w-=2}while(w>0);for(f=l;0!==f;f--)for(d=t.bl_count[f];0!==d;)_=t.heap[--h],_>i||(a[2*_+1]!==f&&(t.opt_len+=(f-a[2*_+1])*a[2*_],a[2*_+1]=f),d--)}})(t,e),v(a,h,t.bl_count)},Z=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),e[2*(a+1)+1]=65535,i=0;i<=a;i++)n=r,r=e[2*(i+1)+1],++o<l&&n===r||(o<h?t.bl_tree[2*n]+=o:0!==n?(n!==s&&t.bl_tree[2*n]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4))},S=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),i=0;i<=a;i++)if(n=r,r=e[2*(i+1)+1],!(++o<l&&n===r)){if(o<h)do{m(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(m(t,n,t.bl_tree),o--),m(t,16,t.bl_tree),p(t,o-3,2)):o<=10?(m(t,17,t.bl_tree),p(t,o-3,3)):(m(t,18,t.bl_tree),p(t,o-11,7));o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4)}};let U=!1;const D=(t,e,a,i)=>{p(t,0+(i?1:0),3),((t,e,a,i)=>{x(t),i&&(g(t,a),g(t,~a)),t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a})(t,e,a,!0)};var O=(t,e,a,i)=>{let o,l,h=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,a=4093624447;for(e=0;e<=31;e++,a>>>=1)if(1&a&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),R(t,t.l_desc),R(t,t.d_desc),h=(t=>{let e;for(Z(t,t.dyn_ltree,t.l_desc.max_code),Z(t,t.dyn_dtree,t.d_desc.max_code),R(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*n[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),o=t.opt_len+3+7>>>3,l=t.static_len+3+7>>>3,l<=o&&(o=l)):o=l=a+5,a+4<=o&&-1!==e?D(t,e,a,i):4===t.strategy||l===o?(p(t,2+(i?1:0),3),E(t,s,r)):(p(t,4+(i?1:0),3),((t,e,a,i)=>{let s;for(p(t,e-257,5),p(t,a-1,5),p(t,i-4,4),s=0;s<i;s++)p(t,t.bl_tree[2*n[s]+1],3);S(t,t.dyn_ltree,e-1),S(t,t.dyn_dtree,a-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,h+1),E(t,t.dyn_ltree,t.dyn_dtree)),y(t),i&&x(t)},T={_tr_init:t=>{U||((()=>{let t,n,w,b,g;const p=new Array(16);for(w=0,b=0;b<28;b++)for(h[b]=w,t=0;t<1<<e[b];t++)l[w++]=b;for(l[w-1]=b,g=0,b=0;b<16;b++)for(d[b]=g,t=0;t<1<<a[b];t++)o[g++]=b;for(g>>=7;b<30;b++)for(d[b]=g<<7,t=0;t<1<<a[b]-7;t++)o[256+g++]=b;for(n=0;n<=15;n++)p[n]=0;for(t=0;t<=143;)s[2*t+1]=8,t++,p[8]++;for(;t<=255;)s[2*t+1]=9,t++,p[9]++;for(;t<=279;)s[2*t+1]=7,t++,p[7]++;for(;t<=287;)s[2*t+1]=8,t++,p[8]++;for(v(s,287,p),t=0;t<30;t++)r[2*t+1]=5,r[2*t]=k(t,5);f=new _(s,e,257,286,15),c=new _(r,a,0,30,15),u=new _(new Array(0),i,0,19,7)})(),U=!0),t.l_desc=new w(t.dyn_ltree,f),t.d_desc=new w(t.dyn_dtree,c),t.bl_desc=new w(t.bl_tree,u),t.bi_buf=0,t.bi_valid=0,y(t)},_tr_stored_block:D,_tr_flush_block:O,_tr_tally:(t,e,a)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&a,t.last_lit++,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(l[a]+256+1)]++,t.dyn_dtree[2*b(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{p(t,2,3),m(t,256,s),(t=>{16===t.bi_valid?(g(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var N=(t,e,a,i)=>{let n=65535&t|0,s=t>>>16&65535|0,r=0;for(;0!==a;){r=a>2e3?2e3:a,a-=r;do{n=n+e[i++]|0,s=s+n|0}while(--r);n%=65521,s%=65521}return n|s<<16|0};const F=new Uint32Array((()=>{let t,e=[];for(var a=0;a<256;a++){t=a;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e})());var L=(t,e,a,i)=>{const n=F,s=i+a;t^=-1;for(let a=i;a<s;a++)t=t>>>8^n[255&(t^e[a])];return-1^t},I={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},B={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:C,_tr_stored_block:H,_tr_flush_block:M,_tr_tally:j,_tr_align:K}=T,{Z_NO_FLUSH:P,Z_PARTIAL_FLUSH:Y,Z_FULL_FLUSH:G,Z_FINISH:X,Z_BLOCK:J,Z_OK:W,Z_STREAM_END:q,Z_STREAM_ERROR:Q,Z_DATA_ERROR:V,Z_BUF_ERROR:$,Z_DEFAULT_COMPRESSION:tt,Z_FILTERED:et,Z_HUFFMAN_ONLY:at,Z_RLE:it,Z_FIXED:nt,Z_DEFAULT_STRATEGY:st,Z_UNKNOWN:rt,Z_DEFLATED:ot}=B,lt=(t,e)=>(t.msg=I[e],e),ht=t=>(t<<1)-(t>4?9:0),dt=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let _t=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const ft=t=>{const e=t.state;let a=e.pending;a>t.avail_out&&(a=t.avail_out),0!==a&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+a),t.next_out),t.next_out+=a,e.pending_out+=a,t.total_out+=a,t.avail_out-=a,e.pending-=a,0===e.pending&&(e.pending_out=0))},ct=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ft(t.strm)},ut=(t,e)=>{t.pending_buf[t.pending++]=e},wt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},bt=(t,e,a,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),a),1===t.state.wrap?t.adler=N(t.adler,e,n,a):2===t.state.wrap&&(t.adler=L(t.adler,e,n,a)),t.next_in+=n,t.total_in+=n,n)},gt=(t,e)=>{let a,i,n=t.max_chain_length,s=t.strstart,r=t.prev_length,o=t.nice_match;const l=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,h=t.window,d=t.w_mask,_=t.prev,f=t.strstart+258;let c=h[s+r-1],u=h[s+r];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(a=e,h[a+r]===u&&h[a+r-1]===c&&h[a]===h[s]&&h[++a]===h[s+1]){s+=2,a++;do{}while(h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&s<f);if(i=258-(f-s),s=f-258,i>r){if(t.match_start=e,r=i,i>=o)break;c=h[s+r-1],u=h[s+r]}}}while((e=_[e&d])>l&&0!=--n);return r<=t.lookahead?r:t.lookahead},pt=t=>{const e=t.w_size;let a,i,n,s,r;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,i=t.hash_size,a=i;do{n=t.head[--a],t.head[a]=n>=e?n-e:0}while(--i);i=e,a=i;do{n=t.prev[--a],t.prev[a]=n>=e?n-e:0}while(--i);s+=e}if(0===t.strm.avail_in)break;if(i=bt(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=i,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=_t(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=_t(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},mt=(t,e)=>{let a,i;for(;;){if(t.lookahead<262){if(pt(t),t.lookahead<262&&e===P)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=_t(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==a&&t.strstart-a<=t.w_size-262&&(t.match_length=gt(t,a)),t.match_length>=3)if(i=j(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=_t(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=_t(t,t.ins_h,t.window[t.strstart+1]);else i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2},kt=(t,e)=>{let a,i,n;for(;;){if(t.lookahead<262){if(pt(t),t.lookahead<262&&e===P)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=_t(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==a&&t.prev_length<t.max_lazy_match&&t.strstart-a<=t.w_size-262&&(t.match_length=gt(t,a),t.match_length<=5&&(t.strategy===et||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=j(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=_t(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(ct(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=j(t,0,t.window[t.strstart-1]),i&&ct(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=j(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2};function vt(t,e,a,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=i,this.func=n}const yt=[new vt(0,0,0,0,((t,e)=>{let a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(pt(t),0===t.lookahead&&e===P)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const i=t.block_start+a;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,ct(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(ct(t,!1),t.strm.avail_out),1)})),new vt(4,4,8,4,mt),new vt(4,5,16,8,mt),new vt(4,6,32,32,mt),new vt(4,4,16,16,kt),new vt(8,16,32,32,kt),new vt(8,16,128,128,kt),new vt(8,32,128,256,kt),new vt(32,128,258,1024,kt),new vt(32,258,258,4096,kt)];function xt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ot,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),dt(this.dyn_ltree),dt(this.dyn_dtree),dt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),dt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),dt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const zt=t=>{if(!t||!t.state)return lt(t,Q);t.total_in=t.total_out=0,t.data_type=rt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=P,C(e),W},At=t=>{const e=zt(t);var a;return e===W&&((a=t.state).window_size=2*a.w_size,dt(a.head),a.max_lazy_match=yt[a.level].max_lazy,a.good_match=yt[a.level].good_length,a.nice_match=yt[a.level].nice_length,a.max_chain_length=yt[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=2,a.match_available=0,a.ins_h=0),e},Et=(t,e,a,i,n,s)=>{if(!t)return Q;let r=1;if(e===tt&&(e=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||a!==ot||i<8||i>15||e<0||e>9||s<0||s>nt)return lt(t,Q);8===i&&(i=9);const o=new xt;return t.state=o,o.strm=t,o.wrap=r,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=s,o.method=a,At(t)};var Rt={deflateInit:(t,e)=>Et(t,e,ot,15,8,st),deflateInit2:Et,deflateReset:At,deflateResetKeep:zt,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Q:(t.state.gzhead=e,W):Q,deflate:(t,e)=>{let a,i;if(!t||!t.state||e>J||e<0)return t?lt(t,Q):Q;const n=t.state;if(!t.output||!t.input&&0!==t.avail_in||666===n.status&&e!==X)return lt(t,0===t.avail_out?$:Q);n.strm=t;const s=n.last_flush;if(n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,ut(n,31),ut(n,139),ut(n,8),n.gzhead?(ut(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),ut(n,255&n.gzhead.time),ut(n,n.gzhead.time>>8&255),ut(n,n.gzhead.time>>16&255),ut(n,n.gzhead.time>>24&255),ut(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),ut(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(ut(n,255&n.gzhead.extra.length),ut(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=L(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(ut(n,0),ut(n,0),ut(n,0),ut(n,0),ut(n,0),ut(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),ut(n,3),n.status=113);else{let e=ot+(n.w_bits-8<<4)<<8,a=-1;a=n.strategy>=at||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=a<<6,0!==n.strstart&&(e|=32),e+=31-e%31,n.status=113,wt(n,e),0!==n.strstart&&(wt(n,t.adler>>>16),wt(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(t.adler=L(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending!==n.pending_buf_size));)ut(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=L(t.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=L(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,ut(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>a&&(t.adler=L(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=L(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,ut(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>a&&(t.adler=L(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&ft(t),n.pending+2<=n.pending_buf_size&&(ut(n,255&t.adler),ut(n,t.adler>>8&255),t.adler=0,n.status=113)):n.status=113),0!==n.pending){if(ft(t),0===t.avail_out)return n.last_flush=-1,W}else if(0===t.avail_in&&ht(e)<=ht(s)&&e!==X)return lt(t,$);if(666===n.status&&0!==t.avail_in)return lt(t,$);if(0!==t.avail_in||0!==n.lookahead||e!==P&&666!==n.status){let a=n.strategy===at?((t,e)=>{let a;for(;;){if(0===t.lookahead&&(pt(t),0===t.lookahead)){if(e===P)return 1;break}if(t.match_length=0,a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===it?((t,e)=>{let a,i,n,s;const r=t.window;for(;;){if(t.lookahead<=258){if(pt(t),t.lookahead<=258&&e===P)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=r[n],i===r[++n]&&i===r[++n]&&i===r[++n])){s=t.strstart+258;do{}while(i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&n<s);t.match_length=258-(s-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=j(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2})(n,e):yt[n.level].func(n,e);if(3!==a&&4!==a||(n.status=666),1===a||3===a)return 0===t.avail_out&&(n.last_flush=-1),W;if(2===a&&(e===Y?K(n):e!==J&&(H(n,0,0,!1),e===G&&(dt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ft(t),0===t.avail_out))return n.last_flush=-1,W}return e!==X?W:n.wrap<=0?q:(2===n.wrap?(ut(n,255&t.adler),ut(n,t.adler>>8&255),ut(n,t.adler>>16&255),ut(n,t.adler>>24&255),ut(n,255&t.total_in),ut(n,t.total_in>>8&255),ut(n,t.total_in>>16&255),ut(n,t.total_in>>24&255)):(wt(n,t.adler>>>16),wt(n,65535&t.adler)),ft(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?W:q)},deflateEnd:t=>{if(!t||!t.state)return Q;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?lt(t,Q):(t.state=null,113===e?lt(t,V):W)},deflateSetDictionary:(t,e)=>{let a=e.length;if(!t||!t.state)return Q;const i=t.state,n=i.wrap;if(2===n||1===n&&42!==i.status||i.lookahead)return Q;if(1===n&&(t.adler=N(t.adler,e,a,0)),i.wrap=0,a>=i.w_size){0===n&&(dt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(a-i.w_size,a),0),e=t,a=i.w_size}const s=t.avail_in,r=t.next_in,o=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,pt(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=_t(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,pt(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=r,t.input=o,t.avail_in=s,i.wrap=n,W},deflateInfo:"pako deflate (from Nodeca project)"};const Zt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var St=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const a=e.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(const e in a)Zt(a,e)&&(t[e]=a[e])}}return t},Ut=t=>{let e=0;for(let a=0,i=t.length;a<i;a++)e+=t[a].length;const a=new Uint8Array(e);for(let e=0,i=0,n=t.length;e<n;e++){let n=t[e];a.set(n,i),i+=n.length}return a};let Dt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Dt=!1}const Ot=new Uint8Array(256);for(let t=0;t<256;t++)Ot[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ot[254]=Ot[254]=1;var Tt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,i,n,s,r=t.length,o=0;for(n=0;n<r;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),o+=a<128?1:a<2048?2:a<65536?3:4;for(e=new Uint8Array(o),s=0,n=0;s<o;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),a<128?e[s++]=a:a<2048?(e[s++]=192|a>>>6,e[s++]=128|63&a):a<65536?(e[s++]=224|a>>>12,e[s++]=128|a>>>6&63,e[s++]=128|63&a):(e[s++]=240|a>>>18,e[s++]=128|a>>>12&63,e[s++]=128|a>>>6&63,e[s++]=128|63&a);return e},Nt=(t,e)=>{const a=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const s=new Array(2*a);for(n=0,i=0;i<a;){let e=t[i++];if(e<128){s[n++]=e;continue}let r=Ot[e];if(r>4)s[n++]=65533,i+=r-1;else{for(e&=2===r?31:3===r?15:7;r>1&&i<a;)e=e<<6|63&t[i++],r--;r>1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Dt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let a="";for(let i=0;i<e;i++)a+=String.fromCharCode(t[i]);return a})(s,n)},Ft=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let a=e-1;for(;a>=0&&128==(192&t[a]);)a--;return a<0||0===a?e:a+Ot[t[a]]>e?a:e};var Lt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const It=Object.prototype.toString,{Z_NO_FLUSH:Bt,Z_SYNC_FLUSH:Ct,Z_FULL_FLUSH:Ht,Z_FINISH:Mt,Z_OK:jt,Z_STREAM_END:Kt,Z_DEFAULT_COMPRESSION:Pt,Z_DEFAULT_STRATEGY:Yt,Z_DEFLATED:Gt}=B;function Xt(t){this.options=St({level:Pt,method:Gt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yt},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Lt,this.strm.avail_out=0;let a=Rt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==jt)throw new Error(I[a]);if(e.header&&Rt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Tt(e.dictionary):"[object ArrayBuffer]"===It.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Rt.deflateSetDictionary(this.strm,t),a!==jt)throw new Error(I[a]);this._dict_set=!0}}function Jt(t,e){const a=new Xt(e);if(a.push(t,!0),a.err)throw a.msg||I[a.err];return a.result}Xt.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Mt:Bt,"string"==typeof t?a.input=Tt(t):"[object ArrayBuffer]"===It.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;)if(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),(s===Ct||s===Ht)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Rt.deflate(a,s),n===Kt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Rt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===jt;if(0!==a.avail_out){if(s>0&&a.next_out>0)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else if(0===a.avail_in)break}else this.onData(a.output)}return!0},Xt.prototype.onData=function(t){this.chunks.push(t)},Xt.prototype.onEnd=function(t){t===jt&&(this.result=Ut(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Wt={Deflate:Xt,deflate:Jt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Jt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Jt(t,e)},constants:B};var qt=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z,A;const E=t.state;a=t.next_in,z=t.input,i=a+(t.avail_in-5),n=t.next_out,A=t.output,s=n-(e-t.avail_out),r=n+(t.avail_out-257),o=E.dmax,l=E.wsize,h=E.whave,d=E.wnext,_=E.window,f=E.hold,c=E.bits,u=E.lencode,w=E.distcode,b=(1<<E.lenbits)-1,g=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),p=u[f&b];e:for(;;){if(m=p>>>24,f>>>=m,c-=m,m=p>>>16&255,0===m)A[n++]=65535&p;else{if(!(16&m)){if(0==(64&m)){p=u[(65535&p)+(f&(1<<m)-1)];continue e}if(32&m){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}k=65535&p,m&=15,m&&(c<m&&(f+=z[a++]<<c,c+=8),k+=f&(1<<m)-1,f>>>=m,c-=m),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),p=w[f&g];a:for(;;){if(m=p>>>24,f>>>=m,c-=m,m=p>>>16&255,!(16&m)){if(0==(64&m)){p=w[(65535&p)+(f&(1<<m)-1)];continue a}t.msg="invalid distance code",E.mode=30;break t}if(v=65535&p,m&=15,c<m&&(f+=z[a++]<<c,c+=8,c<m&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<m)-1,v>o){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=m,c-=m,m=n-s,v>m){if(m=v-m,m>h&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(y=0,x=_,0===d){if(y+=l-m,m<k){k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}}else if(d<m){if(y+=l+d-m,m-=d,m<k){k-=m;do{A[n++]=_[y++]}while(--m);if(y=0,d<k){m=d,k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}}}else if(y+=d-m,m<k){k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}for(;k>2;)A[n++]=x[y++],A[n++]=x[y++],A[n++]=x[y++],k-=3;k&&(A[n++]=x[y++],k>1&&(A[n++]=x[y++]))}else{y=n-v;do{A[n++]=A[y++],A[n++]=A[y++],A[n++]=A[y++],k-=3}while(k>2);k&&(A[n++]=A[y++],k>1&&(A[n++]=A[y++]))}break}}break}}while(a<i&&n<r);k=c>>3,a-=k,c-=k<<3,f&=(1<<c)-1,t.next_in=a,t.next_out=n,t.avail_in=a<i?i-a+5:5-(a-i),t.avail_out=n<r?r-n+257:257-(n-r),E.hold=f,E.bits=c};const Qt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Vt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),$t=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),te=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ee=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,b=0,g=0,p=0,m=0,k=0,v=0,y=0,x=0,z=0,A=null,E=0;const R=new Uint16Array(16),Z=new Uint16Array(16);let S,U,D,O=null,T=0;for(w=0;w<=15;w++)R[w]=0;for(b=0;b<i;b++)R[e[a+b]]++;for(m=l,p=15;p>=1&&0===R[p];p--);if(m>p&&(m=p),0===p)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(g=1;g<p&&0===R[g];g++);for(m<g&&(m=g),y=1,w=1;w<=15;w++)if(y<<=1,y-=R[w],y<0)return-1;if(y>0&&(0===t||1!==p))return-1;for(Z[1]=0,w=1;w<15;w++)Z[w+1]=Z[w]+R[w];for(b=0;b<i;b++)0!==e[a+b]&&(r[Z[e[a+b]]++]=b);if(0===t?(A=O=r,u=19):1===t?(A=Qt,E-=257,O=Vt,T-=257,u=256):(A=$t,O=te,u=-1),z=0,b=0,w=g,c=s,k=m,v=0,_=-1,x=1<<m,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){S=w-v,r[b]<u?(U=0,D=r[b]):r[b]>u?(U=O[T+r[b]],D=A[E+r[b]]):(U=96,D=0),h=1<<w-v,d=1<<k,g=d;do{d-=h,n[c+(z>>v)+d]=S<<24|U<<16|D|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,b++,0==--R[w]){if(w===p)break;w=e[a+r[b]]}if(w>m&&(z&f)!==_){for(0===v&&(v=m),c+=g,k=w-v,y=1<<k;k+v<p&&(y-=R[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=m<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ae,Z_BLOCK:ie,Z_TREES:ne,Z_OK:se,Z_STREAM_END:re,Z_NEED_DICT:oe,Z_STREAM_ERROR:le,Z_DATA_ERROR:he,Z_MEM_ERROR:de,Z_BUF_ERROR:_e,Z_DEFLATED:fe}=B,ce=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ue(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const we=t=>{if(!t||!t.state)return le;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,se},be=t=>{if(!t||!t.state)return le;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,we(t)},ge=(t,e)=>{let a;if(!t||!t.state)return le;const i=t.state;return e<0?(a=0,e=-e):(a=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?le:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,be(t))},pe=(t,e)=>{if(!t)return le;const a=new ue;t.state=a,a.window=null;const i=ge(t,e);return i!==se&&(t.state=null),i};let me,ke,ve=!0;const ye=t=>{if(ve){me=new Int32Array(512),ke=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ee(1,t.lens,0,288,me,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ee(2,t.lens,0,32,ke,0,t.work,{bits:5}),ve=!1}t.lencode=me,t.lenbits=9,t.distcode=ke,t.distbits=5},xe=(t,e,a,i)=>{let n;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(a-s.wsize,a),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(e.subarray(a-i,a-i+n),s.wnext),(i-=n)?(s.window.set(e.subarray(a-i,a),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var ze={inflateReset:be,inflateReset2:ge,inflateResetKeep:we,inflateInit:t=>pe(t,15),inflateInit2:pe,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z=0;const A=new Uint8Array(4);let E,R;const Z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return le;a=t.state,12===a.mode&&(a.mode=13),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,_=o,f=l,x=se;t:for(;;)switch(a.mode){case 1:if(0===a.wrap){a.mode=13;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){a.check=0,A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0),h=0,d=0,a.mode=2;break}if(a.flags=0,a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=30;break}if((15&h)!==fe){t.msg="unknown compression method",a.mode=30;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits)a.wbits=y;else if(y>a.wbits){t.msg="invalid window size",a.mode=30;break}a.dmax=1<<a.wbits,t.adler=a.check=1,a.mode=512&h?10:12,h=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==fe){t.msg="unknown compression method",a.mode=30;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=30;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,a.check=L(a.check,A,4,0)),h=0,d=0,a.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.xflags=255&h,a.head.os=h>>8),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=5;case 5:if(1024&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length=h,a.head&&(a.head.extra_len=h),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0}else a.head&&(a.head.extra=null);a.mode=6;case 6:if(1024&a.flags&&(c=a.length,c>o&&(c=o),c&&(a.head&&(y=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(i.subarray(s,s+c),y)),512&a.flags&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=7;case 7:if(2048&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.name+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.name=null);a.length=0,a.mode=8;case 8:if(4096&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.comment+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=9;case 9:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=30;break}h=0,d=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),t.adler=a.check=0,a.mode=12;break;case 10:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=ce(h),h=0,d=0,a.mode=11;case 11:if(0===a.havedict)return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,oe;t.adler=a.check=1,a.mode=12;case 12:if(e===ie||e===ne)break t;case 13:if(a.last){h>>>=7&d,d-=7&d,a.mode=27;break}for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}switch(a.last=1&h,h>>>=1,d-=1,3&h){case 0:a.mode=14;break;case 1:if(ye(a),a.mode=20,e===ne){h>>>=2,d-=2;break t}break;case 2:a.mode=17;break;case 3:t.msg="invalid block type",a.mode=30}h>>>=2,d-=2;break;case 14:for(h>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if((65535&h)!=(h>>>16^65535)){t.msg="invalid stored block lengths",a.mode=30;break}if(a.length=65535&h,h=0,d=0,a.mode=15,e===ne)break t;case 15:a.mode=16;case 16:if(c=a.length,c){if(c>o&&(c=o),c>l&&(c=l),0===c)break t;n.set(i.subarray(s,s+c),r),o-=c,s+=c,l-=c,r+=c,a.length-=c;break}a.mode=12;break;case 17:for(;d<14;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.nlen=257+(31&h),h>>>=5,d-=5,a.ndist=1+(31&h),h>>>=5,d-=5,a.ncode=4+(15&h),h>>>=4,d-=4,a.nlen>286||a.ndist>30){t.msg="too many length or distance symbols",a.mode=30;break}a.have=0,a.mode=18;case 18:for(;a.have<a.ncode;){for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.lens[Z[a.have++]]=7&h,h>>>=3,d-=3}for(;a.have<19;)a.lens[Z[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,E={bits:a.lenbits},x=ee(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=30;break}a.have=0,a.mode=19;case 19:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(p<16)h>>>=b,d-=b,a.lens[a.have++]=p;else{if(16===p){for(R=b+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=b,d-=b,0===a.have){t.msg="invalid bit length repeat",a.mode=30;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===p){for(R=b+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=b,d-=b,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=b+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=b,d-=b,y=0,c=11+(127&h),h>>>=7,d-=7}if(a.have+c>a.nlen+a.ndist){t.msg="invalid bit length repeat",a.mode=30;break}for(;c--;)a.lens[a.have++]=y}}if(30===a.mode)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=30;break}if(a.lenbits=9,E={bits:a.lenbits},x=ee(1,a.lens,0,a.nlen,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid literal/lengths set",a.mode=30;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=ee(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,E),a.distbits=E.bits,x){t.msg="invalid distances set",a.mode=30;break}if(a.mode=20,e===ne)break t;case 20:a.mode=21;case 21:if(o>=6&&l>=258){t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,qt(t,f),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,12===a.mode&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g&&0==(240&g)){for(m=b,k=g,v=p;z=a.lencode[v+((h&(1<<m+k)-1)>>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,a.length=p,0===g){a.mode=26;break}if(32&g){a.back=-1,a.mode=12;break}if(64&g){t.msg="invalid literal/length code",a.mode=30;break}a.extra=15&g,a.mode=22;case 22:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=23;case 23:for(;z=a.distcode[h&(1<<a.distbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&g)){for(m=b,k=g,v=p;z=a.distcode[v+((h&(1<<m+k)-1)>>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,64&g){t.msg="invalid distance code",a.mode=30;break}a.offset=p,a.extra=15&g,a.mode=24;case 24:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.offset+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){t.msg="invalid distance too far back",a.mode=30;break}a.mode=25;case 25:if(0===l)break t;if(c=f-l,a.offset>c){if(c=a.offset-c,c>a.whave&&a.sane){t.msg="invalid distance too far back",a.mode=30;break}c>a.wnext?(c-=a.wnext,u=a.wsize-c):u=a.wnext-c,c>a.length&&(c=a.length),w=a.window}else w=n,u=r-a.offset,c=a.length;c>l&&(c=l),l-=c,a.length-=c;do{n[r++]=w[u++]}while(--c);0===a.length&&(a.mode=21);break;case 26:if(0===l)break t;n[r++]=a.length,l--,a.mode=21;break;case 27:if(a.wrap){for(;d<32;){if(0===o)break t;o--,h|=i[s++]<<d,d+=8}if(f-=l,t.total_out+=f,a.total+=f,f&&(t.adler=a.check=a.flags?L(a.check,n,f,r-f):N(a.check,n,f,r-f)),f=l,(a.flags?h:ce(h))!==a.check){t.msg="incorrect data check",a.mode=30;break}h=0,d=0}a.mode=28;case 28:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=30;break}h=0,d=0}a.mode=29;case 29:x=re;break t;case 30:x=he;break t;case 31:return de;default:return le}return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,(a.wsize||f!==t.avail_out&&a.mode<30&&(a.mode<27||e!==ae))&&xe(t,t.output,t.next_out,f-t.avail_out),_-=t.avail_in,f-=t.avail_out,t.total_in+=_,t.total_out+=f,a.total+=f,a.wrap&&f&&(t.adler=a.check=a.flags?L(a.check,n,f,t.next_out-f):N(a.check,n,f,t.next_out-f)),t.data_type=a.bits+(a.last?64:0)+(12===a.mode?128:0)+(20===a.mode||15===a.mode?256:0),(0===_&&0===f||e===ae)&&x===se&&(x=_e),x},inflateEnd:t=>{if(!t||!t.state)return le;let e=t.state;return e.window&&(e.window=null),t.state=null,se},inflateGetHeader:(t,e)=>{if(!t||!t.state)return le;const a=t.state;return 0==(2&a.wrap)?le:(a.head=e,e.done=!1,se)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return t&&t.state?(i=t.state,0!==i.wrap&&11!==i.mode?le:11===i.mode&&(n=1,n=N(n,e,a,0),n!==i.check)?he:(s=xe(t,e,a,a),s?(i.mode=31,de):(i.havedict=1,se))):le},inflateInfo:"pako inflate (from Nodeca project)"};var Ae=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ee=Object.prototype.toString,{Z_NO_FLUSH:Re,Z_FINISH:Ze,Z_OK:Se,Z_STREAM_END:Ue,Z_NEED_DICT:De,Z_STREAM_ERROR:Oe,Z_DATA_ERROR:Te,Z_MEM_ERROR:Ne}=B;function Fe(t){this.options=St({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Lt,this.strm.avail_out=0;let a=ze.inflateInit2(this.strm,e.windowBits);if(a!==Se)throw new Error(I[a]);if(this.header=new Ae,ze.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Tt(e.dictionary):"[object ArrayBuffer]"===Ee.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=ze.inflateSetDictionary(this.strm,e.dictionary),a!==Se)))throw new Error(I[a])}Fe.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,r,o;if(this.ended)return!1;for(r=e===~~e?e:!0===e?Ze:Re,"[object ArrayBuffer]"===Ee.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),s=ze.inflate(a,r),s===De&&n&&(s=ze.inflateSetDictionary(a,n),s===Se?s=ze.inflate(a,r):s===Te&&(s=De));a.avail_in>0&&s===Ue&&a.state.wrap>0&&0!==t[a.next_in];)ze.inflateReset(a),s=ze.inflate(a,r);switch(s){case Oe:case Te:case De:case Ne:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===Ue))if("string"===this.options.to){let t=Ft(a.output,a.next_out),e=a.next_out-t,n=Nt(a.output,t);a.next_out=e,a.avail_out=i-e,e&&a.output.set(a.output.subarray(t,t+e),0),this.onData(n)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(s!==Se||0!==o){if(s===Ue)return s=ze.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Fe.prototype.onData=function(t){this.chunks.push(t)},Fe.prototype.onEnd=function(t){t===Se&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ut(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const{Deflate:Le,deflate:Ie,deflateRaw:Be,gzip:Ce}=Wt;var He=Le,Me=B,je=new(function(){function t(){this.init()}return t.prototype.init=function(){this.added=0,this.deflate=new He,this.deflate.push("[",Me.Z_NO_FLUSH)},t.prototype.addEvent=function(t){if(t){var e=this.added>0?",":"";this.deflate.push(e+JSON.stringify(t),Me.Z_NO_FLUSH),this.added++}},t.prototype.finish=function(){if(this.deflate.push("]",Me.Z_FINISH),this.deflate.err)throw this.deflate.err;var t=this.deflate.result;return this.init(),t},t}()),Ke={init:function(){return je.init(),""},addEvent:function(t){return je.addEvent(t),""},finish:function(){return je.finish()}};addEventListener("message",(function(t){var e=t.data.method,a=t.data.id,i=(t.data.args?JSON.parse(t.data.args):[])[0];if(e in Ke&&"function"==typeof Ke[e])try{var n=Ke[e](i);postMessage({id:a,method:e,success:!0,response:n})}catch(t){postMessage({id:a,method:e,success:!1,response:t}),console.error(t)}}));`;
748
-
749
- function createEventBuffer(_a) {
750
- var useCompression = _a.useCompression;
751
- if (useCompression && window.Worker) {
752
- var workerBlob = new Blob([workerString]);
753
- var workerUrl = URL.createObjectURL(workerBlob);
754
- try {
755
- logger.log('Using compression worker');
756
- var worker = new Worker(workerUrl);
757
- if (worker) {
758
- return new EventBufferCompressionWorker(worker);
759
- }
760
- else {
761
- core.captureException(new Error('Unable to create compression worker'));
762
- }
763
- }
764
- catch (_b) {
765
- // catch and ignore, fallback to simple event buffer
766
- }
767
- logger.log('Falling back to simple event buffer');
768
- }
769
- logger.log('Using simple buffer');
770
- return new EventBufferArray();
771
- }
772
- var EventBufferArray = /** @class */ (function () {
773
- function EventBufferArray() {
774
- this.events = [];
775
- }
776
- EventBufferArray.prototype.destroy = function () {
777
- this.events = [];
778
- };
779
- Object.defineProperty(EventBufferArray.prototype, "length", {
780
- get: function () {
781
- return this.events.length;
782
- },
783
- enumerable: false,
784
- configurable: true
785
- });
786
- EventBufferArray.prototype.addEvent = function (event, isCheckout) {
787
- if (isCheckout) {
788
- this.events = [event];
789
- return;
790
- }
791
- this.events.push(event);
792
- };
793
- EventBufferArray.prototype.finish = function () {
794
- var _this = this;
795
- return new Promise(function (resolve) {
796
- // Make a copy of the events array reference and immediately clear the
797
- // events member so that we do not lose new events while uploading
798
- // attachment.
799
- var eventsRet = _this.events;
800
- _this.events = [];
801
- resolve(JSON.stringify(eventsRet));
802
- });
803
- };
804
- return EventBufferArray;
805
- }());
806
- // exporting for testing
807
- var EventBufferCompressionWorker = /** @class */ (function () {
808
- function EventBufferCompressionWorker(worker) {
809
- var _this = this;
810
- this.eventBufferItemLength = 0;
811
- this._id = 0;
812
- this.sendEventToWorker = function (event) {
813
- var promise = _this.postMessage({
814
- id: _this.id,
815
- method: 'addEvent',
816
- args: [event],
817
- });
818
- // XXX: See note in `get length()`
819
- _this.eventBufferItemLength++;
820
- return promise;
821
- };
822
- this.finishRequest = function (id) { return __awaiter(_this, void 0, void 0, function () {
823
- var promise;
824
- return __generator(this, function (_a) {
825
- promise = this.postMessage({ id: id, method: 'finish', args: [] });
826
- // XXX: See note in `get length()`
827
- this.eventBufferItemLength = 0;
828
- return [2 /*return*/, promise];
829
- });
830
- }); };
831
- this.worker = worker;
832
- }
833
- Object.defineProperty(EventBufferCompressionWorker.prototype, "id", {
834
- /**
835
- * Read-only incrementing counter
836
- */
837
- get: function () {
838
- return this._id++;
839
- },
840
- enumerable: false,
841
- configurable: true
842
- });
843
- /**
844
- * Post message to worker and wait for response before resolving promise.
845
- */
846
- EventBufferCompressionWorker.prototype.postMessage = function (_a) {
847
- var _this = this;
848
- var id = _a.id, method = _a.method, args = _a.args;
849
- return new Promise(function (resolve, reject) {
850
- var _a, _b;
851
- var listener = function (_a) {
852
- var _b;
853
- var data = _a.data;
854
- if (data.method !== method) {
855
- return;
856
- }
857
- // There can be multiple listeners for a single method, the id ensures
858
- // that the response matches the caller.
859
- if (data.id !== id) {
860
- return;
861
- }
862
- // At this point, we'll always want to remove listener regardless of result status
863
- (_b = _this.worker) === null || _b === void 0 ? void 0 : _b.removeEventListener('message', listener);
864
- if (!data.success) {
865
- // TODO: Do some error handling, not sure what
866
- logger.error(data.response);
867
- reject(new Error('Error in compression worker'));
868
- return;
869
- }
870
- resolve(data.response);
871
- };
872
- var stringifiedArgs;
873
- try {
874
- stringifiedArgs = JSON.stringify(args);
875
- }
876
- catch (err) {
877
- console.error(err);
878
- stringifiedArgs = '[]';
879
- }
880
- // Note: we can't use `once` option because it's possible it needs to
881
- // listen to multiple messages
882
- (_a = _this.worker) === null || _a === void 0 ? void 0 : _a.addEventListener('message', listener);
883
- (_b = _this.worker) === null || _b === void 0 ? void 0 : _b.postMessage({ id: id, method: method, args: stringifiedArgs });
884
- });
885
- };
886
- EventBufferCompressionWorker.prototype.init = function () {
887
- this.postMessage({ id: this.id, method: 'init', args: [] });
888
- logger.log('Initialized compression worker');
889
- };
890
- EventBufferCompressionWorker.prototype.destroy = function () {
891
- var _a;
892
- logger.log('Destroying compression worker');
893
- (_a = this.worker) === null || _a === void 0 ? void 0 : _a.terminate();
894
- this.worker = null;
895
- };
896
- Object.defineProperty(EventBufferCompressionWorker.prototype, "length", {
897
- /**
898
- * Note that this may not reflect what is actually in the event buffer. This
899
- * is only a local count of the buffer size since `addEvent` is async.
900
- */
901
- get: function () {
902
- return this.eventBufferItemLength;
903
- },
904
- enumerable: false,
905
- configurable: true
906
- });
907
- EventBufferCompressionWorker.prototype.addEvent = function (event, isCheckout) {
908
- return __awaiter(this, void 0, void 0, function () {
909
- return __generator(this, function (_a) {
910
- switch (_a.label) {
911
- case 0:
912
- if (!isCheckout) return [3 /*break*/, 2];
913
- // This event is a checkout, make sure worker buffer is cleared before
914
- // proceeding.
915
- return [4 /*yield*/, this.postMessage({
916
- id: this.id,
917
- method: 'init',
918
- args: [],
919
- })];
920
- case 1:
921
- // This event is a checkout, make sure worker buffer is cleared before
922
- // proceeding.
923
- _a.sent();
924
- _a.label = 2;
925
- case 2: return [2 /*return*/, this.sendEventToWorker(event)];
926
- }
927
- });
928
- });
929
- };
930
- EventBufferCompressionWorker.prototype.finish = function () {
931
- return this.finishRequest(this.id);
932
- };
933
- return EventBufferCompressionWorker;
934
- }());
935
-
936
- var BASE_RETRY_INTERVAL = 5000;
937
- var MAX_RETRY_COUNT = 3;
938
- var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
939
- var MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
940
- var _initialized = false;
941
- var isBrowser = typeof window !== 'undefined';
942
- var Replay = /** @class */ (function () {
943
- function Replay(_a) {
944
- if (_a === void 0) { _a = {}; }
945
- var _this = this;
946
- var _b = _a.flushMinDelay, flushMinDelay = _b === void 0 ? 5000 : _b, _c = _a.flushMaxDelay, flushMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.initialFlushDelay, initialFlushDelay = _d === void 0 ? 5000 : _d, _e = _a.stickySession, stickySession = _e === void 0 ? true : _e, _f = _a.useCompression, useCompression = _f === void 0 ? true : _f, _g = _a.sessionSampleRate, sessionSampleRate = _g === void 0 ? DEFAULT_SESSION_SAMPLE_RATE : _g, _h = _a.errorSampleRate, errorSampleRate = _h === void 0 ? DEFAULT_ERROR_SAMPLE_RATE : _h, _j = _a.maskAllText, maskAllText = _j === void 0 ? true : _j, _k = _a.maskAllInputs, maskAllInputs = _k === void 0 ? true : _k, _l = _a.blockAllMedia, blockAllMedia = _l === void 0 ? true : _l, _m = _a.blockClass, blockClass = _m === void 0 ? 'sentry-block' : _m, _o = _a.ignoreClass, ignoreClass = _o === void 0 ? 'sentry-ignore' : _o, _p = _a.maskTextClass, maskTextClass = _p === void 0 ? 'sentry-mask' : _p, _q = _a.blockSelector, blockSelector = _q === void 0 ? '[data-sentry-block]' : _q, replaysSamplingRate = _a.replaysSamplingRate, captureOnlyOnError = _a.captureOnlyOnError, recordingOptions = __rest(_a, ["flushMinDelay", "flushMaxDelay", "initialFlushDelay", "stickySession", "useCompression", "sessionSampleRate", "errorSampleRate", "maskAllText", "maskAllInputs", "blockAllMedia", "blockClass", "ignoreClass", "maskTextClass", "blockSelector", "replaysSamplingRate", "captureOnlyOnError"]);
947
- /**
948
- * @inheritDoc
949
- */
950
- this.name = Replay.id;
951
- /**
952
- * List of PerformanceEntry from PerformanceObserver
953
- */
954
- this.performanceEvents = [];
955
- this.performanceObserver = null;
956
- this.retryCount = 0;
957
- this.retryInterval = BASE_RETRY_INTERVAL;
958
- this.flushLock = null;
959
- /**
960
- * Timestamp of the last user activity. This lives across sessions.
961
- */
962
- this.lastActivity = new Date().getTime();
963
- /**
964
- * Is the integration currently active?
965
- */
966
- this.isEnabled = false;
967
- /**
968
- * Paused is a state where:
969
- * - DOM Recording is not listening at all
970
- * - Nothing will be added to event buffer (e.g. core SDK events)
971
- */
972
- this.isPaused = false;
973
- /**
974
- * Integration will wait until an error occurs before creating and sending a
975
- * replay.
976
- */
977
- this.waitForError = false;
978
- /**
979
- * Have we attached listeners to the core SDK?
980
- * Note we have to track this as there is no way to remove instrumentation handlers.
981
- */
982
- this.hasInitializedCoreListeners = false;
983
- /**
984
- * Function to stop recording
985
- */
986
- this.stopRecording = null;
987
- this.context = {
988
- errorIds: new Set(),
989
- traceIds: new Set(),
990
- urls: [],
991
- earliestEvent: null,
992
- initialTimestamp: new Date().getTime(),
993
- initialUrl: '',
994
- };
995
- /**
996
- * Core Sentry SDK global event handler. Attaches `replayId` to all [non-replay]
997
- * events as a tag. Also handles the case where we only want to capture a reply
998
- * when an error occurs.
999
- **/
1000
- this.handleGlobalEvent = function (event) {
1001
- var _a, _b, _c, _d, _e;
1002
- // Do not apply replayId to the root event
1003
- if (
1004
- // @ts-expect-error new event type
1005
- event.type === REPLAY_EVENT_NAME) {
1006
- // Replays have separate set of breadcrumbs, do not include breadcrumbs
1007
- // from core SDK
1008
- delete event.breadcrumbs;
1009
- return event;
1010
- }
1011
- // Only tag transactions with replayId if not waiting for an error
1012
- if (event.type !== 'transaction' || !_this.waitForError) {
1013
- event.tags = __assign(__assign({}, event.tags), { replayId: (_a = _this.session) === null || _a === void 0 ? void 0 : _a.id });
1014
- }
1015
- // Collect traceIds in context regardless of `waitForError` - if it's true,
1016
- // context gets cleared on every checkout
1017
- if (event.type === 'transaction') {
1018
- _this.context.traceIds.add(String(((_c = (_b = event.contexts) === null || _b === void 0 ? void 0 : _b.trace) === null || _c === void 0 ? void 0 : _c.trace_id) || ''));
1019
- return event;
1020
- }
1021
- // XXX: Is it safe to assume that all other events are error events?
1022
- // @ts-expect-error: Type 'undefined' is not assignable to type 'string'.ts(2345)
1023
- _this.context.errorIds.add(event.event_id);
1024
- var exc = (_e = (_d = event.exception) === null || _d === void 0 ? void 0 : _d.values) === null || _e === void 0 ? void 0 : _e[0];
1025
- addInternalBreadcrumb({
1026
- message: "Tagging event (".concat(event.event_id, ") - ").concat(event.message, " - ").concat((exc === null || exc === void 0 ? void 0 : exc.type) || 'Unknown', ": ").concat((exc === null || exc === void 0 ? void 0 : exc.value) || 'n/a'),
1027
- });
1028
- // Need to be very careful that this does not cause an infinite loop
1029
- if (_this.waitForError &&
1030
- event.exception &&
1031
- event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because otherwise we could loop indefinitely with trying to capture replay and failing
1032
- ) {
1033
- setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
1034
- return __generator(this, function (_a) {
1035
- switch (_a.label) {
1036
- case 0:
1037
- // Allow flush to complete before resuming as a session recording, otherwise
1038
- // the checkout from `startRecording` may be included in the payload.
1039
- // Prefer to keep the error replay as a separate (and smaller) segment
1040
- // than the session replay.
1041
- return [4 /*yield*/, this.flushImmediate()];
1042
- case 1:
1043
- // Allow flush to complete before resuming as a session recording, otherwise
1044
- // the checkout from `startRecording` may be included in the payload.
1045
- // Prefer to keep the error replay as a separate (and smaller) segment
1046
- // than the session replay.
1047
- _a.sent();
1048
- if (this.stopRecording) {
1049
- this.stopRecording();
1050
- // Reset all "capture on error" configuration before
1051
- // starting a new recording
1052
- delete this.recordingOptions.checkoutEveryNms;
1053
- this.waitForError = false;
1054
- this.startRecording();
1055
- }
1056
- return [2 /*return*/];
1057
- }
1058
- });
1059
- }); });
1060
- }
1061
- return event;
1062
- };
1063
- /**
1064
- * Handler for recording events.
1065
- *
1066
- * Adds to event buffer, and has varying flushing behaviors if the event was a checkout.
1067
- */
1068
- this.handleRecordingEmit = function (event, isCheckout) {
1069
- // If this is false, it means session is expired, create and a new session and wait for checkout
1070
- if (!_this.checkAndHandleExpiredSession()) {
1071
- logger.error(new Error('Received replay event after session expired.'));
1072
- return;
1073
- }
1074
- _this.addUpdate(function () {
1075
- var _a, _b;
1076
- // The session is always started immediately on pageload/init, but for
1077
- // error-only replays, it should reflect the most recent checkout
1078
- // when an error occurs. Clear any state that happens before this current
1079
- // checkout. This needs to happen before `addEvent()` which updates state
1080
- // dependent on this reset.
1081
- if (_this.waitForError && event.type === 2) {
1082
- _this.setInitialState();
1083
- }
1084
- // We need to clear existing events on a checkout, otherwise they are
1085
- // incremental event updates and should be appended
1086
- _this.addEvent(event, isCheckout);
1087
- // Different behavior for full snapshots (type=2), ignore other event types
1088
- // See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16
1089
- if (event.type !== 2) {
1090
- return false;
1091
- }
1092
- // If there is a previousSessionId after a full snapshot occurs, then
1093
- // the replay session was started due to session expiration. The new session
1094
- // is started before triggering a new checkout and contains the id
1095
- // of the previous session. Do not immediately flush in this case
1096
- // to avoid capturing only the checkout and instead the replay will
1097
- // be captured if they perform any follow-up actions.
1098
- if ((_a = _this.session) === null || _a === void 0 ? void 0 : _a.previousSessionId) {
1099
- return true;
1100
- }
1101
- // See note above re: session start needs to reflect the most recent
1102
- // checkout.
1103
- if (_this.waitForError && _this.session && _this.context.earliestEvent) {
1104
- _this.session.started = _this.context.earliestEvent;
1105
- }
1106
- // If the full snapshot is due to an initial load, we will not have
1107
- // a previous session ID. In this case, we want to buffer events
1108
- // for a set amount of time before flushing. This can help avoid
1109
- // capturing replays of users that immediately close the window.
1110
- setTimeout(function () { return _this.conditionalFlush(); }, _this.options.initialFlushDelay);
1111
- // Cancel any previously debounced flushes to ensure there are no [near]
1112
- // simultaneous flushes happening. The latter request should be
1113
- // insignificant in this case, so wait for additional user interaction to
1114
- // trigger a new flush.
1115
- //
1116
- // This can happen because there's no guarantee that a recording event
1117
- // happens first. e.g. a mouse click can happen and trigger a debounced
1118
- // flush before the checkout.
1119
- (_b = _this.debouncedFlush) === null || _b === void 0 ? void 0 : _b.cancel();
1120
- return true;
1121
- });
1122
- };
1123
- /**
1124
- * Handle when visibility of the page content changes. Opening a new tab will
1125
- * cause the state to change to hidden because of content of current page will
1126
- * be hidden. Likewise, moving a different window to cover the contents of the
1127
- * page will also trigger a change to a hidden state.
1128
- */
1129
- this.handleVisibilityChange = function () {
1130
- if (document.visibilityState === 'visible') {
1131
- _this.doChangeToForegroundTasks();
1132
- }
1133
- else {
1134
- _this.doChangeToBackgroundTasks();
1135
- }
1136
- };
1137
- /**
1138
- * Handle when page is blurred
1139
- */
1140
- this.handleWindowBlur = function () {
1141
- var breadcrumb = createBreadcrumb({
1142
- category: 'ui.blur',
1143
- });
1144
- // Do not count blur as a user action -- it's part of the process of them
1145
- // leaving the page
1146
- _this.doChangeToBackgroundTasks(breadcrumb);
1147
- };
1148
- /**
1149
- * Handle when page is focused
1150
- */
1151
- this.handleWindowFocus = function () {
1152
- var breadcrumb = createBreadcrumb({
1153
- category: 'ui.focus',
1154
- });
1155
- // Do not count focus as a user action -- instead wait until they focus and
1156
- // interactive with page
1157
- _this.doChangeToForegroundTasks(breadcrumb);
1158
- };
1159
- /**
1160
- * Handler for Sentry Core SDK events.
1161
- *
1162
- * These specific events will create span-like objects in the recording.
1163
- */
1164
- this.handleCoreSpanListener = function (type) { return function (handlerData) {
1165
- if (!_this.isEnabled) {
1166
- return;
1167
- }
1168
- var handler = getSpanHandler(type);
1169
- var result = handler(handlerData);
1170
- if (result === null) {
1171
- return;
1172
- }
1173
- if (type === 'history') {
1174
- // Need to collect visited URLs
1175
- _this.context.urls.push(result.name);
1176
- _this.triggerUserActivity();
1177
- }
1178
- _this.addUpdate(function () {
1179
- _this.createPerformanceSpans([result]);
1180
- // Returning true will cause `addUpdate` to not flush
1181
- // We do not want network requests to cause a flush. This will prevent
1182
- // recurring/polling requests from keeping the replay session alive.
1183
- return ['xhr', 'fetch'].includes(type);
1184
- });
1185
- }; };
1186
- /**
1187
- * Handler for Sentry Core SDK events.
1188
- *
1189
- * These events will create breadcrumb-like objects in the recording.
1190
- */
1191
- this.handleCoreBreadcrumbListener = function (type) { return function (handlerData) {
1192
- if (!_this.isEnabled) {
1193
- return;
1194
- }
1195
- var handler = getBreadcrumbHandler(type);
1196
- var result = handler(handlerData);
1197
- if (result === null) {
1198
- return;
1199
- }
1200
- if (result.category === 'sentry.transaction') {
1201
- return;
1202
- }
1203
- if (result.category === 'ui.click') {
1204
- _this.triggerUserActivity();
1205
- }
1206
- else {
1207
- _this.checkAndHandleExpiredSession();
1208
- }
1209
- _this.addUpdate(function () {
1210
- _this.addEvent({
1211
- type: rrweb.EventType.Custom,
1212
- // TODO: We were converting from ms to seconds for breadcrumbs, spans,
1213
- // but maybe we should just keep them as milliseconds
1214
- timestamp: (result.timestamp || 0) * 1000,
1215
- data: {
1216
- tag: 'breadcrumb',
1217
- payload: result,
1218
- },
1219
- });
1220
- // Do not flush after console log messages
1221
- return result.category === 'console';
1222
- });
1223
- }; };
1224
- /**
1225
- * Keep a list of performance entries that will be sent with a replay
1226
- */
1227
- this.handlePerformanceObserver = function (list) {
1228
- // For whatever reason the observer was returning duplicate navigation
1229
- // entries (the other entry types were not duplicated).
1230
- var newPerformanceEntries = dedupePerformanceEntries(_this.performanceEvents, list.getEntries());
1231
- _this.performanceEvents = newPerformanceEntries;
1232
- };
1233
- /**
1234
- * Flush recording data to Sentry. Creates a lock so that only a single flush
1235
- * can be active at a time. Do not call this directly.
1236
- */
1237
- this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
1238
- var err_1;
1239
- var _a, _b;
1240
- return __generator(this, function (_c) {
1241
- switch (_c.label) {
1242
- case 0:
1243
- if (!this.isEnabled) {
1244
- // This is just a precaution, there should be no listeners that would
1245
- // cause a flush.
1246
- return [2 /*return*/];
1247
- }
1248
- if (!this.checkAndHandleExpiredSession()) {
1249
- logger.error(new Error('Attempting to finish replay event after session expired.'));
1250
- return [2 /*return*/];
1251
- }
1252
- if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.id)) {
1253
- console.error(new Error('[Sentry]: No transaction, no replay'));
1254
- return [2 /*return*/];
1255
- }
1256
- // A flush is about to happen, cancel any queued flushes
1257
- (_b = this.debouncedFlush) === null || _b === void 0 ? void 0 : _b.cancel();
1258
- if (!!this.flushLock) return [3 /*break*/, 2];
1259
- this.flushLock = this.runFlush();
1260
- return [4 /*yield*/, this.flushLock];
1261
- case 1:
1262
- _c.sent();
1263
- this.flushLock = null;
1264
- return [2 /*return*/];
1265
- case 2:
1266
- _c.trys.push([2, 4, 5, 6]);
1267
- return [4 /*yield*/, this.flushLock];
1268
- case 3:
1269
- _c.sent();
1270
- return [3 /*break*/, 6];
1271
- case 4:
1272
- err_1 = _c.sent();
1273
- console.error(err_1);
1274
- return [3 /*break*/, 6];
1275
- case 5:
1276
- this.debouncedFlush();
1277
- return [7 /*endfinally*/];
1278
- case 6: return [2 /*return*/];
1279
- }
1280
- });
1281
- }); };
1282
- this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass, blockSelector: blockSelector }, recordingOptions);
1283
- var usingDeprecatedReplaysSamplingRate = replaysSamplingRate !== undefined;
1284
- var usingDeprecatedCaptureOnlyOnError = captureOnlyOnError !== undefined;
1285
- this.options = {
1286
- flushMinDelay: flushMinDelay,
1287
- flushMaxDelay: flushMaxDelay,
1288
- stickySession: stickySession,
1289
- initialFlushDelay: initialFlushDelay,
1290
- sessionSampleRate: usingDeprecatedReplaysSamplingRate
1291
- ? replaysSamplingRate
1292
- : sessionSampleRate,
1293
- errorSampleRate: usingDeprecatedCaptureOnlyOnError
1294
- ? 1.0
1295
- : errorSampleRate,
1296
- useCompression: useCompression,
1297
- maskAllText: maskAllText,
1298
- blockAllMedia: blockAllMedia,
1299
- };
1300
- // TODO(deprecated): Maintain backwards compatibility for alpha users
1301
- if (usingDeprecatedCaptureOnlyOnError) {
1302
- console.warn('[@sentry/replay]: The `captureOnlyOnError` option is deprecated! Please configure `errorSampleRate` instead.');
1303
- }
1304
- if (usingDeprecatedReplaysSamplingRate) {
1305
- console.warn('[@sentry/replay]: The `replaysSamplingRate` option is deprecated! Please configure `sessionSampleRate` instead.');
1306
- }
1307
- if (this.options.maskAllText) {
1308
- // `maskAllText` is a more user friendly option to configure
1309
- // `maskTextSelector`. This means that all nodes will have their text
1310
- // content masked.
1311
- this.recordingOptions.maskTextSelector = '*';
1312
- }
1313
- if (this.options.blockAllMedia) {
1314
- // `blockAllMedia` is a more user friendly option to configure blocking
1315
- // embedded media elements
1316
- this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
1317
- ? MEDIA_SELECTORS
1318
- : "".concat(this.recordingOptions.blockSelector, ",").concat(MEDIA_SELECTORS);
1319
- }
1320
- this.debouncedFlush = debounce__default["default"](function () { return _this.flush(); }, this.options.flushMinDelay, {
1321
- maxWait: this.options.flushMaxDelay,
1322
- });
1323
- if (isBrowser && _initialized) {
1324
- var error = new Error('Multiple Sentry Session Replay instances are not supported');
1325
- captureInternalException(error);
1326
- throw error;
1327
- }
1328
- _initialized = true;
1329
- }
1330
- /**
1331
- * We previously used to create a transaction in `setupOnce` and it would
1332
- * potentially create a transaction before some native SDK integrations have run
1333
- * and applied their own global event processor. An example is:
1334
- * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
1335
- *
1336
- * So we call `this.setup` in next event loop as a workaround to wait for other
1337
- * global event processors to finish. This is no longer needed, but keeping it
1338
- * here to avoid any future issues.
1339
- */
1340
- Replay.prototype.setupOnce = function () {
1341
- var _this = this;
1342
- if (!isBrowser) {
1343
- return;
1344
- }
1345
- // XXX: See method comments above
1346
- window.setTimeout(function () { return _this.start(); });
1347
- };
1348
- /**
1349
- * Initializes the plugin.
1350
- *
1351
- * Creates or loads a session, attaches listeners to varying events (DOM,
1352
- * PerformanceObserver, Recording, Sentry SDK, etc)
1353
- */
1354
- Replay.prototype.start = function () {
1355
- if (!isBrowser) {
1356
- return;
1357
- }
1358
- this.setInitialState();
1359
- this.loadSession({ expiry: SESSION_IDLE_DURATION });
1360
- // If there is no session, then something bad has happened - can't continue
1361
- if (!this.session) {
1362
- captureInternalException(new Error('Invalid session'));
1363
- return;
1364
- }
1365
- if (!this.session.sampled) {
1366
- // If session was not sampled, then we do not initialize the integration at all.
1367
- return;
1368
- }
1369
- // Modify recording options to checkoutEveryNthSecond if
1370
- // sampling for error replay. This is because we don't know
1371
- // when an error will occur, so we need to keep a buffer of
1372
- // replay events.
1373
- if (this.session.sampled === 'error') {
1374
- // Checkout every minute, meaning we only get up-to one minute of events before the error happens
1375
- this.recordingOptions.checkoutEveryNms = 60000;
1376
- this.waitForError = true;
1377
- }
1378
- // setup() is generally called on page load or manually - in both cases we
1379
- // should treat it as an activity
1380
- this.updateSessionActivity();
1381
- this.eventBuffer = createEventBuffer({
1382
- useCompression: Boolean(this.options.useCompression),
1383
- });
1384
- this.addListeners();
1385
- this.startRecording();
1386
- this.isEnabled = true;
1387
- };
1388
- /**
1389
- * Start recording.
1390
- *
1391
- * Note that this will cause a new DOM checkout
1392
- */
1393
- Replay.prototype.startRecording = function () {
1394
- try {
1395
- this.stopRecording = rrweb.record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1396
- }
1397
- catch (err) {
1398
- logger.error(err);
1399
- captureInternalException(err);
1400
- }
1401
- };
1402
- /**
1403
- * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
1404
- * does not support a teardown
1405
- */
1406
- Replay.prototype.stop = function () {
1407
- var _a, _b;
1408
- if (!isBrowser) {
1409
- return;
1410
- }
1411
- try {
1412
- logger.log('Stopping Replays');
1413
- this.isEnabled = false;
1414
- this.removeListeners();
1415
- (_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
1416
- (_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
1417
- this.eventBuffer = null;
1418
- }
1419
- catch (err) {
1420
- logger.error(err);
1421
- captureInternalException(err);
1422
- }
1423
- };
1424
- /**
1425
- * Pause some replay functionality. See comments for `isPaused`.
1426
- * This differs from stop as this only stops DOM recording, it is
1427
- * not as thorough of a shutdown as `stop()`.
1428
- */
1429
- Replay.prototype.pause = function () {
1430
- this.isPaused = true;
1431
- try {
1432
- if (this.stopRecording) {
1433
- this.stopRecording();
1434
- this.stopRecording = undefined;
1435
- }
1436
- }
1437
- catch (err) {
1438
- logger.error(err);
1439
- captureInternalException(err);
1440
- }
1441
- };
1442
- /**
1443
- * Resumes recording, see notes for `pause().
1444
- *
1445
- * Note that calling `startRecording()` here will cause a
1446
- * new DOM checkout.`
1447
- */
1448
- Replay.prototype.resume = function () {
1449
- this.isPaused = false;
1450
- this.startRecording();
1451
- };
1452
- Replay.prototype.clearSession = function () {
1453
- try {
1454
- deleteSession();
1455
- this.session = undefined;
1456
- }
1457
- catch (err) {
1458
- logger.error(err);
1459
- captureInternalException(err);
1460
- }
1461
- };
1462
- /**
1463
- * Loads a session from storage, or creates a new one if it does not exist or
1464
- * is expired.
1465
- */
1466
- Replay.prototype.loadSession = function (_a) {
1467
- var _b, _c;
1468
- var expiry = _a.expiry;
1469
- var _d = getSession({
1470
- expiry: expiry,
1471
- stickySession: Boolean(this.options.stickySession),
1472
- currentSession: this.session,
1473
- sessionSampleRate: this.options.sessionSampleRate,
1474
- errorSampleRate: this.options.errorSampleRate,
1475
- }), type = _d.type, session = _d.session;
1476
- // If session was newly created (i.e. was not loaded from storage), then
1477
- // enable flag to create the root replay
1478
- if (type === 'new') {
1479
- this.setInitialState();
1480
- }
1481
- if (session.id !== ((_b = this.session) === null || _b === void 0 ? void 0 : _b.id)) {
1482
- session.previousSessionId = (_c = this.session) === null || _c === void 0 ? void 0 : _c.id;
1483
- }
1484
- this.session = session;
1485
- };
1486
- /**
1487
- * Capture some initial state that can change throughout the lifespan of the
1488
- * replay. This is required because otherwise they would be captured at the
1489
- * first flush.
1490
- */
1491
- Replay.prototype.setInitialState = function () {
1492
- var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
1493
- var url = "".concat(window.location.origin).concat(urlPath);
1494
- this.performanceEvents = [];
1495
- // Reset context as well
1496
- this.clearContext();
1497
- this.context.initialUrl = url;
1498
- this.context.initialTimestamp = new Date().getTime();
1499
- this.context.urls.push(url);
1500
- };
1501
- /**
1502
- * Adds listeners to record events for the replay
1503
- */
1504
- Replay.prototype.addListeners = function () {
1505
- var _this = this;
1506
- try {
1507
- document.addEventListener('visibilitychange', this.handleVisibilityChange);
1508
- window.addEventListener('blur', this.handleWindowBlur);
1509
- window.addEventListener('focus', this.handleWindowFocus);
1510
- // There is no way to remove these listeners, so ensure they are only added once
1511
- if (!this.hasInitializedCoreListeners) {
1512
- // Listeners from core SDK //
1513
- var scope = core.getCurrentHub().getScope();
1514
- scope === null || scope === void 0 ? void 0 : scope.addScopeListener(this.handleCoreBreadcrumbListener('scope'));
1515
- utils.addInstrumentationHandler('dom', this.handleCoreBreadcrumbListener('dom'));
1516
- utils.addInstrumentationHandler('fetch', this.handleCoreSpanListener('fetch'));
1517
- utils.addInstrumentationHandler('xhr', this.handleCoreSpanListener('xhr'));
1518
- utils.addInstrumentationHandler('history', this.handleCoreSpanListener('history'));
1519
- // Tag all (non replay) events that get sent to Sentry with the current
1520
- // replay ID so that we can reference them later in the UI
1521
- core.addGlobalEventProcessor(this.handleGlobalEvent);
1522
- this.hasInitializedCoreListeners = true;
1523
- }
1524
- }
1525
- catch (err) {
1526
- logger.error(err);
1527
- captureInternalException(err);
1528
- }
1529
- // PerformanceObserver //
1530
- if (!('PerformanceObserver' in window)) {
1531
- return;
1532
- }
1533
- this.performanceObserver = new PerformanceObserver(this.handlePerformanceObserver);
1534
- // Observe almost everything for now (no mark/measure)
1535
- [
1536
- 'element',
1537
- 'event',
1538
- 'first-input',
1539
- 'largest-contentful-paint',
1540
- 'layout-shift',
1541
- 'longtask',
1542
- 'navigation',
1543
- 'paint',
1544
- 'resource',
1545
- ].forEach(function (type) {
1546
- var _a;
1547
- try {
1548
- (_a = _this.performanceObserver) === null || _a === void 0 ? void 0 : _a.observe({
1549
- type: type,
1550
- buffered: true,
1551
- });
1552
- }
1553
- catch (_b) {
1554
- // This can throw if an entry type is not supported in the browser.
1555
- // Ignore these errors.
1556
- }
1557
- });
1558
- };
1559
- /**
1560
- * Cleans up listeners that were created in `addListeners`
1561
- */
1562
- Replay.prototype.removeListeners = function () {
1563
- try {
1564
- document.removeEventListener('visibilitychange', this.handleVisibilityChange);
1565
- window.removeEventListener('blur', this.handleWindowBlur);
1566
- window.removeEventListener('focus', this.handleWindowFocus);
1567
- if (this.performanceObserver) {
1568
- this.performanceObserver.disconnect();
1569
- this.performanceObserver = null;
1570
- }
1571
- }
1572
- catch (err) {
1573
- logger.error(err);
1574
- captureInternalException(err);
1575
- }
1576
- };
1577
- /**
1578
- * We want to batch uploads of replay events. Save events only if
1579
- * `<flushMinDelay>` milliseconds have elapsed since the last event
1580
- * *OR* if `<flushMaxDelay>` milliseconds have elapsed.
1581
- *
1582
- * Accepts a callback to perform side-effects and returns true to stop batch
1583
- * processing and hand back control to caller.
1584
- */
1585
- Replay.prototype.addUpdate = function (cb) {
1586
- // We need to always run `cb` (e.g. in the case of `this.waitForError == true`)
1587
- var cbResult = cb === null || cb === void 0 ? void 0 : cb();
1588
- // If this option is turned on then we will only want to call `flush`
1589
- // explicitly
1590
- if (this.waitForError) {
1591
- return;
1592
- }
1593
- // If callback is true, we do not want to continue with flushing -- the
1594
- // caller will need to handle it.
1595
- if (cbResult === true) {
1596
- return;
1597
- }
1598
- // addUpdate is called quite frequently - use debouncedFlush so that it
1599
- // respects the flush delays and does not flush immediately
1600
- this.debouncedFlush();
1601
- };
1602
- /**
1603
- * Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
1604
- */
1605
- Replay.prototype.doChangeToBackgroundTasks = function (breadcrumb) {
1606
- if (!this.session) {
1607
- return;
1608
- }
1609
- var expired = isSessionExpired(this.session, VISIBILITY_CHANGE_TIMEOUT);
1610
- if (breadcrumb && !expired) {
1611
- this.createCustomBreadcrumb(breadcrumb);
1612
- }
1613
- // Send replay when the page/tab becomes hidden. There is no reason to send
1614
- // replay if it becomes visible, since no actions we care about were done
1615
- // while it was hidden
1616
- this.conditionalFlush();
1617
- };
1618
- /**
1619
- * Tasks to run when we consider a page to be visible (via focus and/or visibility)
1620
- */
1621
- Replay.prototype.doChangeToForegroundTasks = function (breadcrumb) {
1622
- if (!this.session) {
1623
- return;
1624
- }
1625
- var isSessionActive = this.checkAndHandleExpiredSession({
1626
- expiry: VISIBILITY_CHANGE_TIMEOUT,
1627
- });
1628
- if (!isSessionActive) {
1629
- // If the user has come back to the page within VISIBILITY_CHANGE_TIMEOUT
1630
- // ms, we will re-use the existing session, otherwise create a new
1631
- // session
1632
- logger.log('Document has become active, but session has expired');
1633
- return;
1634
- }
1635
- if (breadcrumb) {
1636
- this.createCustomBreadcrumb(breadcrumb);
1637
- }
1638
- };
1639
- /**
1640
- * Trigger rrweb to take a full snapshot which will cause this plugin to
1641
- * create a new Replay event.
1642
- */
1643
- Replay.prototype.triggerFullSnapshot = function () {
1644
- logger.log('Taking full rrweb snapshot');
1645
- rrweb.record.takeFullSnapshot(true);
1646
- };
1647
- /**
1648
- * Add an event to the event buffer
1649
- */
1650
- Replay.prototype.addEvent = function (event, isCheckout) {
1651
- var _a;
1652
- if (!this.eventBuffer) {
1653
- // This implies that `isEnabled` is false
1654
- return;
1655
- }
1656
- if (this.isPaused) {
1657
- // Do not add to event buffer when recording is paused
1658
- return;
1659
- }
1660
- // TODO: sadness -- we will want to normalize timestamps to be in ms -
1661
- // requires coordination with frontend
1662
- var isMs = event.timestamp > 9999999999;
1663
- var timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
1664
- // Throw out events that happen more than 5 minutes ago. This can happen if
1665
- // page has been left open and idle for a long period of time and user
1666
- // comes back to trigger a new session. The performance entries rely on
1667
- // `performance.timeOrigin`, which is when the page first opened.
1668
- if (timestampInMs + SESSION_IDLE_DURATION < new Date().getTime()) {
1669
- return;
1670
- }
1671
- // Only record earliest event if a new session was created, otherwise it
1672
- // shouldn't be relevant
1673
- if (((_a = this.session) === null || _a === void 0 ? void 0 : _a.segmentId) === 0 &&
1674
- (!this.context.earliestEvent ||
1675
- timestampInMs < this.context.earliestEvent)) {
1676
- this.context.earliestEvent = timestampInMs;
1677
- }
1678
- this.eventBuffer.addEvent(event, isCheckout);
1679
- };
1680
- /**
1681
- * Update user activity (across session lifespans)
1682
- */
1683
- Replay.prototype.updateUserActivity = function (lastActivity) {
1684
- if (lastActivity === void 0) { lastActivity = new Date().getTime(); }
1685
- this.lastActivity = lastActivity;
1686
- };
1687
- /**
1688
- * Updates the session's last activity timestamp
1689
- */
1690
- Replay.prototype.updateSessionActivity = function (lastActivity) {
1691
- if (lastActivity === void 0) { lastActivity = new Date().getTime(); }
1692
- if (this.session) {
1693
- this.session.lastActivity = lastActivity;
1694
- }
1695
- };
1696
- /**
1697
- * Updates the user activity timestamp and resumes recording. This should be
1698
- * called in an event handler for a user action that we consider as the user
1699
- * being "active" (e.g. a mouse click).
1700
- */
1701
- Replay.prototype.triggerUserActivity = function () {
1702
- return __awaiter(this, void 0, void 0, function () {
1703
- return __generator(this, function (_a) {
1704
- this.updateUserActivity();
1705
- // This case means that recording was once stopped due to inactivity.
1706
- // Ensure that recording is resumed.
1707
- if (!this.stopRecording) {
1708
- // Create a new session, otherwise when the user action is flushed, it
1709
- // will get rejected due to an expired session.
1710
- this.loadSession({ expiry: SESSION_IDLE_DURATION });
1711
- // Note: This will cause a new DOM checkout
1712
- this.resume();
1713
- return [2 /*return*/];
1714
- }
1715
- // Otherwise... recording was never suspended, continue as normalish
1716
- this.checkAndHandleExpiredSession();
1717
- this.updateSessionActivity();
1718
- return [2 /*return*/];
1719
- });
1720
- });
1721
- };
1722
- /**
1723
- * Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
1724
- */
1725
- Replay.prototype.createCustomBreadcrumb = function (breadcrumb) {
1726
- var _this = this;
1727
- this.addUpdate(function () {
1728
- _this.addEvent({
1729
- type: rrweb.EventType.Custom,
1730
- timestamp: breadcrumb.timestamp || 0,
1731
- data: {
1732
- tag: 'breadcrumb',
1733
- payload: breadcrumb,
1734
- },
1735
- });
1736
- });
1737
- };
1738
- /**
1739
- * Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
1740
- */
1741
- Replay.prototype.createPerformanceSpans = function (entries) {
1742
- var _this = this;
1743
- return Promise.all(entries.map(function (_a) {
1744
- var type = _a.type, start = _a.start, end = _a.end, name = _a.name, data = _a.data;
1745
- return _this.addEvent({
1746
- type: rrweb.EventType.Custom,
1747
- timestamp: start,
1748
- data: {
1749
- tag: 'performanceSpan',
1750
- payload: {
1751
- op: type,
1752
- description: name,
1753
- startTimestamp: start,
1754
- endTimestamp: end,
1755
- data: data,
1756
- },
1757
- },
1758
- });
1759
- }));
1760
- };
1761
- /**
1762
- * Observed performance events are added to `this.performanceEvents`. These
1763
- * are included in the replay event before it is finished and sent to Sentry.
1764
- */
1765
- Replay.prototype.addPerformanceEntries = function () {
1766
- // Copy and reset entries before processing
1767
- var entries = __spreadArray([], this.performanceEvents, true);
1768
- this.performanceEvents = [];
1769
- return this.createPerformanceSpans(createPerformanceEntries(entries));
1770
- };
1771
- /**
1772
- * Create a "span" for the total amount of memory being used by JS objects
1773
- * (including v8 internal objects).
1774
- */
1775
- Replay.prototype.addMemoryEntry = function () {
1776
- // window.performance.memory is a non-standard API and doesn't work on all browsers
1777
- // so we check before creating the event.
1778
- if (!('memory' in window.performance)) {
1779
- return;
1780
- }
1781
- return this.createPerformanceSpans([
1782
- // @ts-expect-error memory doesn't exist on type Performance as the API is non-standard (we check that it exists above)
1783
- createMemoryEntry(window.performance.memory),
1784
- ]);
1785
- };
1786
- /**
1787
- * Checks if recording should be stopped due to user inactivity. Otherwise
1788
- * check if session is expired and create a new session if so. Triggers a new
1789
- * full snapshot on new session.
1790
- *
1791
- * Returns true if session is not expired, false otherwise.
1792
- */
1793
- Replay.prototype.checkAndHandleExpiredSession = function (_a) {
1794
- var _b, _c;
1795
- var _d = _a === void 0 ? {} : _a, _e = _d.expiry, expiry = _e === void 0 ? SESSION_IDLE_DURATION : _e;
1796
- var oldSessionId = (_b = this.session) === null || _b === void 0 ? void 0 : _b.id;
1797
- // Prevent starting a new session if the last user activity is older than
1798
- // MAX_SESSION_LIFE. Otherwise non-user activity can trigger a new
1799
- // session+recording. This creates noisy replays that do not have much
1800
- // content in them.
1801
- if (this.lastActivity && isExpired(this.lastActivity, MAX_SESSION_LIFE)) {
1802
- // Pause recording
1803
- this.pause();
1804
- return;
1805
- }
1806
- // --- There is recent user activity --- //
1807
- // This will create a new session if expired, based on expiry length
1808
- this.loadSession({ expiry: expiry });
1809
- // Session was expired if session ids do not match
1810
- var expired = oldSessionId !== ((_c = this.session) === null || _c === void 0 ? void 0 : _c.id);
1811
- if (!expired) {
1812
- return true;
1813
- }
1814
- // Session is expired, trigger a full snapshot (which will create a new session)
1815
- this.triggerFullSnapshot();
1816
- return false;
1817
- };
1818
- /**
1819
- * Only flush if `this.waitForError` is false.
1820
- */
1821
- Replay.prototype.conditionalFlush = function () {
1822
- if (this.waitForError) {
1823
- return;
1824
- }
1825
- this.flushImmediate();
1826
- };
1827
- /**
1828
- * Clear context
1829
- */
1830
- Replay.prototype.clearContext = function () {
1831
- // XXX: `initialTimestamp` and `initialUrl` do not get cleared
1832
- this.context.errorIds.clear();
1833
- this.context.traceIds.clear();
1834
- this.context.urls = [];
1835
- this.context.earliestEvent = null;
1836
- };
1837
- /**
1838
- * Return and clear context
1839
- */
1840
- Replay.prototype.popEventContext = function () {
1841
- if (this.context.earliestEvent &&
1842
- this.context.earliestEvent < this.context.initialTimestamp) {
1843
- this.context.initialTimestamp = this.context.earliestEvent;
1844
- }
1845
- var context = {
1846
- initialTimestamp: this.context.initialTimestamp,
1847
- initialUrl: this.context.initialUrl,
1848
- errorIds: Array.from(this.context.errorIds).filter(Boolean),
1849
- traceIds: Array.from(this.context.traceIds).filter(Boolean),
1850
- urls: this.context.urls,
1851
- };
1852
- this.clearContext();
1853
- return context;
1854
- };
1855
- /**
1856
- * Flushes replay event buffer to Sentry.
1857
- *
1858
- * Performance events are only added right before flushing - this is
1859
- * due to the buffered performance observer events.
1860
- *
1861
- * Should never be called directly, only by `flush`
1862
- */
1863
- Replay.prototype.runFlush = function () {
1864
- var _a;
1865
- return __awaiter(this, void 0, void 0, function () {
1866
- var recordingData, replayId, eventContext, segmentId, err_2;
1867
- return __generator(this, function (_b) {
1868
- switch (_b.label) {
1869
- case 0:
1870
- if (!this.session) {
1871
- console.error(new Error('[Sentry]: No transaction, no replay'));
1872
- return [2 /*return*/];
1873
- }
1874
- return [4 /*yield*/, this.addPerformanceEntries()];
1875
- case 1:
1876
- _b.sent();
1877
- if (!((_a = this.eventBuffer) === null || _a === void 0 ? void 0 : _a.length)) {
1878
- return [2 /*return*/];
1879
- }
1880
- // Only attach memory event if eventBuffer is not empty
1881
- return [4 /*yield*/, this.addMemoryEntry()];
1882
- case 2:
1883
- // Only attach memory event if eventBuffer is not empty
1884
- _b.sent();
1885
- _b.label = 3;
1886
- case 3:
1887
- _b.trys.push([3, 6, , 7]);
1888
- return [4 /*yield*/, this.eventBuffer.finish()];
1889
- case 4:
1890
- recordingData = _b.sent();
1891
- replayId = this.session.id;
1892
- eventContext = this.popEventContext();
1893
- segmentId = this.session.segmentId++;
1894
- return [4 /*yield*/, this.sendReplay({
1895
- replayId: replayId,
1896
- events: recordingData,
1897
- segmentId: segmentId,
1898
- includeReplayStartTimestamp: segmentId === 0,
1899
- eventContext: eventContext,
1900
- })];
1901
- case 5:
1902
- _b.sent();
1903
- return [3 /*break*/, 7];
1904
- case 6:
1905
- err_2 = _b.sent();
1906
- captureInternalException(err_2);
1907
- console.error(err_2);
1908
- return [3 /*break*/, 7];
1909
- case 7: return [2 /*return*/];
1910
- }
1911
- });
1912
- });
1913
- };
1914
- /**
1915
- *
1916
- * Always flush via `debouncedFlush` so that we do not have flushes triggered
1917
- * from calling both `flush` and `debouncedFlush`. Otherwise, there could be
1918
- * cases of mulitple flushes happening closely together.
1919
- */
1920
- Replay.prototype.flushImmediate = function () {
1921
- this.debouncedFlush();
1922
- // `.flush` is provided by lodash.debounce
1923
- return this.debouncedFlush.flush();
1924
- };
1925
- /**
1926
- * Send replay attachment using `fetch()`
1927
- */
1928
- Replay.prototype.sendReplayRequest = function (_a) {
1929
- var _b;
1930
- var events = _a.events, event_id = _a.replayId, segment_id = _a.segmentId, includeReplayStartTimestamp = _a.includeReplayStartTimestamp, eventContext = _a.eventContext;
1931
- return __awaiter(this, void 0, void 0, function () {
1932
- var payloadWithSequence, urls, errorIds, traceIds, initialTimestamp, currentTimestamp, sdkInfo, replayEvent, envelope, client;
1933
- var _this = this;
1934
- return __generator(this, function (_c) {
1935
- switch (_c.label) {
1936
- case 0:
1937
- payloadWithSequence = createPayload({
1938
- events: events,
1939
- headers: {
1940
- segment_id: segment_id,
1941
- },
1942
- });
1943
- urls = eventContext.urls, errorIds = eventContext.errorIds, traceIds = eventContext.traceIds, initialTimestamp = eventContext.initialTimestamp;
1944
- currentTimestamp = new Date().getTime();
1945
- sdkInfo = {
1946
- name: 'sentry.javascript.integration.replay',
1947
- version: "0.6.14-6",
1948
- };
1949
- return [4 /*yield*/, new Promise(function (resolve) {
1950
- var _a;
1951
- (_a = core.getCurrentHub()) === null || _a === void 0 ? void 0 : _a._withClient(function (client, scope) { return __awaiter(_this, void 0, void 0, function () {
1952
- var preparedEvent, session;
1953
- var _a;
1954
- return __generator(this, function (_b) {
1955
- switch (_b.label) {
1956
- case 0: return [4 /*yield*/, client._prepareEvent(__assign(__assign({ type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
1957
- ? { replay_start_timestamp: initialTimestamp / 1000 }
1958
- : {})), { timestamp: currentTimestamp / 1000, error_ids: errorIds, trace_ids: traceIds, urls: urls, replay_id: event_id, segment_id: segment_id }), { event_id: event_id }, scope)];
1959
- case 1:
1960
- preparedEvent = _b.sent();
1961
- session = scope && scope.getSession();
1962
- if (session) {
1963
- client._updateSessionFromEvent(session, preparedEvent);
1964
- }
1965
- preparedEvent.sdk = __assign(__assign({}, preparedEvent.sdk), sdkInfo);
1966
- preparedEvent.tags = __assign(__assign({}, preparedEvent.tags), { sessionSampleRate: this.options.sessionSampleRate, errorSampleRate: this.options.errorSampleRate, replayType: (_a = this.session) === null || _a === void 0 ? void 0 : _a.sampled });
1967
- resolve(preparedEvent);
1968
- return [2 /*return*/];
1969
- }
1970
- });
1971
- }); });
1972
- })];
1973
- case 1:
1974
- replayEvent = _c.sent();
1975
- envelope = utils.createEnvelope({
1976
- event_id: event_id,
1977
- sent_at: new Date().toISOString(),
1978
- sdk: sdkInfo,
1979
- }, [
1980
- // @ts-expect-error New types
1981
- [{ type: 'replay_event' }, replayEvent],
1982
- [
1983
- {
1984
- // @ts-expect-error setting envelope
1985
- type: 'replay_recording',
1986
- length: payloadWithSequence.length,
1987
- },
1988
- // @ts-expect-error: Type 'string' is not assignable to type 'ClientReport'.ts(2322)
1989
- payloadWithSequence,
1990
- ],
1991
- ]);
1992
- client = core.getCurrentHub().getClient();
1993
- try {
1994
- return [2 /*return*/, (_b = client === null || client === void 0 ? void 0 : client.getTransport()) === null || _b === void 0 ? void 0 : _b.send(envelope)];
1995
- }
1996
- catch (_d) {
1997
- throw new Error(UNABLE_TO_SEND_REPLAY);
1998
- }
1999
- return [2 /*return*/];
2000
- }
2001
- });
2002
- });
2003
- };
2004
- Replay.prototype.resetRetries = function () {
2005
- this.retryCount = 0;
2006
- this.retryInterval = BASE_RETRY_INTERVAL;
2007
- };
2008
- /**
2009
- * Finalize and send the current replay event to Sentry
2010
- */
2011
- Replay.prototype.sendReplay = function (_a) {
2012
- var replayId = _a.replayId, events = _a.events, segmentId = _a.segmentId, includeReplayStartTimestamp = _a.includeReplayStartTimestamp, eventContext = _a.eventContext;
2013
- return __awaiter(this, void 0, void 0, function () {
2014
- var ex_1;
2015
- var _this = this;
2016
- return __generator(this, function (_b) {
2017
- switch (_b.label) {
2018
- case 0:
2019
- // short circuit if there's no events to upload (this shouldn't happen as runFlush makes this check)
2020
- if (!events.length) {
2021
- return [2 /*return*/];
2022
- }
2023
- _b.label = 1;
2024
- case 1:
2025
- _b.trys.push([1, 3, , 5]);
2026
- return [4 /*yield*/, this.sendReplayRequest({
2027
- events: events,
2028
- replayId: replayId,
2029
- segmentId: segmentId,
2030
- includeReplayStartTimestamp: includeReplayStartTimestamp,
2031
- eventContext: eventContext,
2032
- })];
2033
- case 2:
2034
- _b.sent();
2035
- this.resetRetries();
2036
- return [2 /*return*/, true];
2037
- case 3:
2038
- ex_1 = _b.sent();
2039
- console.error(ex_1);
2040
- // Capture error for every failed replay
2041
- core.setContext('Replays', {
2042
- retryCount: this.retryCount,
2043
- });
2044
- captureInternalException(ex_1);
2045
- // If an error happened here, it's likely that uploading the attachment
2046
- // failed, we'll can retry with the same events payload
2047
- if (this.retryCount >= MAX_RETRY_COUNT) {
2048
- throw new Error("".concat(UNABLE_TO_SEND_REPLAY, " - max retries exceeded"));
2049
- }
2050
- this.retryCount = this.retryCount + 1;
2051
- // will retry in intervals of 5, 10, 30
2052
- this.retryInterval = this.retryCount * this.retryInterval;
2053
- return [4 /*yield*/, new Promise(function (resolve, reject) {
2054
- setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
2055
- var err_3;
2056
- return __generator(this, function (_a) {
2057
- switch (_a.label) {
2058
- case 0:
2059
- _a.trys.push([0, 2, , 3]);
2060
- return [4 /*yield*/, this.sendReplay({
2061
- replayId: replayId,
2062
- events: events,
2063
- segmentId: segmentId,
2064
- includeReplayStartTimestamp: includeReplayStartTimestamp,
2065
- eventContext: eventContext,
2066
- })];
2067
- case 1:
2068
- _a.sent();
2069
- resolve(true);
2070
- return [3 /*break*/, 3];
2071
- case 2:
2072
- err_3 = _a.sent();
2073
- reject(err_3);
2074
- return [3 /*break*/, 3];
2075
- case 3: return [2 /*return*/];
2076
- }
2077
- });
2078
- }); }, _this.retryInterval);
2079
- })];
2080
- case 4: return [2 /*return*/, _b.sent()];
2081
- case 5: return [2 /*return*/];
2082
- }
2083
- });
2084
- });
2085
- };
2086
- /**
2087
- * @inheritDoc
2088
- */
2089
- Replay.id = 'Replay';
2090
- return Replay;
2091
- }());
2092
-
2093
- exports.Replay = Replay;
2094
- //# sourceMappingURL=index.js.map