@sentry/replay 0.6.14 → 7.24.1

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