@sentry/replay 7.32.1 → 7.34.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +1073 -999
- package/cjs/index.js.map +1 -1
- package/esm/index.js +1075 -1001
- package/esm/index.js.map +1 -1
- package/package.json +4 -4
- package/types/constants.d.ts +0 -5
- package/types/constants.d.ts.map +1 -1
- package/types/coreHandlers/addBreadcrumbEvent.d.ts +7 -0
- package/types/coreHandlers/addBreadcrumbEvent.d.ts.map +1 -0
- package/types/coreHandlers/handleDom.d.ts +4 -6
- package/types/coreHandlers/handleDom.d.ts.map +1 -1
- package/types/coreHandlers/handleScope.d.ts +2 -0
- package/types/coreHandlers/handleScope.d.ts.map +1 -1
- package/types/integration.d.ts.map +1 -1
- package/types/replay.d.ts +11 -14
- package/types/replay.d.ts.map +1 -1
- package/types/types.d.ts +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/util/addGlobalListeners.d.ts +6 -0
- package/types/util/addGlobalListeners.d.ts.map +1 -0
- package/types/coreHandlers/breadcrumbHandler.d.ts +0 -7
- package/types/coreHandlers/breadcrumbHandler.d.ts.map +0 -1
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCurrentHub, addBreadcrumb, prepareEvent, setContext, captureException
|
|
2
|
-
import { GLOBAL_OBJ,
|
|
1
|
+
import { getCurrentHub, addBreadcrumb, addGlobalEventProcessor, prepareEvent, setContext, captureException } from '@sentry/core';
|
|
2
|
+
import { GLOBAL_OBJ, logger, uuid4, htmlTreeAsString, addInstrumentationHandler, browserPerformanceTimeOrigin, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, updateRateLimits, isRateLimited, disabledUntil, isNodeEnv } from '@sentry/utils';
|
|
3
3
|
|
|
4
4
|
// exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`
|
|
5
5
|
// prevents the browser package from being bundled in the CDN bundle, and avoids a
|
|
@@ -20,12 +20,6 @@ const VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
|
20
20
|
// The maximum length of a session
|
|
21
21
|
const MAX_SESSION_LIFE = 3600000; // 60 minutes
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Defaults for sampling rates
|
|
25
|
-
*/
|
|
26
|
-
const DEFAULT_SESSION_SAMPLE_RATE = 0.1;
|
|
27
|
-
const DEFAULT_ERROR_SAMPLE_RATE = 1.0;
|
|
28
|
-
|
|
29
23
|
/** The select to use for the `maskAllText` option */
|
|
30
24
|
const MASK_ALL_TEXT_SELECTOR = 'body *:not(style), body *:not(script)';
|
|
31
25
|
|
|
@@ -132,10 +126,14 @@ function isShadowRoot(n) {
|
|
|
132
126
|
return Boolean(host && host.shadowRoot && host.shadowRoot === n);
|
|
133
127
|
}
|
|
134
128
|
function maskInputValue(_a) {
|
|
135
|
-
var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
|
|
129
|
+
var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
|
|
136
130
|
var text = value || '';
|
|
131
|
+
if (unmaskInputSelector && input.matches(unmaskInputSelector)) {
|
|
132
|
+
return text;
|
|
133
|
+
}
|
|
137
134
|
if (maskInputOptions[tagName.toLowerCase()] ||
|
|
138
|
-
maskInputOptions[type]
|
|
135
|
+
maskInputOptions[type] ||
|
|
136
|
+
(maskInputSelector && input.matches(maskInputSelector))) {
|
|
139
137
|
if (maskInputFn) {
|
|
140
138
|
text = maskInputFn(text);
|
|
141
139
|
}
|
|
@@ -362,7 +360,10 @@ function transformAttribute(doc, tagName, name, value) {
|
|
|
362
360
|
return value;
|
|
363
361
|
}
|
|
364
362
|
}
|
|
365
|
-
function _isBlockedElement(element, blockClass, blockSelector) {
|
|
363
|
+
function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {
|
|
364
|
+
if (unblockSelector && element.matches(unblockSelector)) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
366
367
|
if (typeof blockClass === 'string') {
|
|
367
368
|
if (element.classList.contains(blockClass)) {
|
|
368
369
|
return true;
|
|
@@ -381,11 +382,16 @@ function _isBlockedElement(element, blockClass, blockSelector) {
|
|
|
381
382
|
}
|
|
382
383
|
return false;
|
|
383
384
|
}
|
|
384
|
-
function needMaskingText(node, maskTextClass, maskTextSelector) {
|
|
385
|
+
function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {
|
|
385
386
|
if (!node) {
|
|
386
387
|
return false;
|
|
387
388
|
}
|
|
388
389
|
if (node.nodeType === node.ELEMENT_NODE) {
|
|
390
|
+
if (unmaskTextSelector) {
|
|
391
|
+
if (node.matches(unmaskTextSelector) || node.closest(unmaskTextSelector)) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
389
395
|
if (typeof maskTextClass === 'string') {
|
|
390
396
|
if (node.classList.contains(maskTextClass)) {
|
|
391
397
|
return true;
|
|
@@ -404,12 +410,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector) {
|
|
|
404
410
|
return true;
|
|
405
411
|
}
|
|
406
412
|
}
|
|
407
|
-
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);
|
|
413
|
+
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
|
|
408
414
|
}
|
|
409
415
|
if (node.nodeType === node.TEXT_NODE) {
|
|
410
|
-
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);
|
|
416
|
+
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
|
|
411
417
|
}
|
|
412
|
-
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);
|
|
418
|
+
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
|
|
413
419
|
}
|
|
414
420
|
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
415
421
|
var win = iframeEl.contentWindow;
|
|
@@ -449,7 +455,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
|
449
455
|
}
|
|
450
456
|
function serializeNode(n, options) {
|
|
451
457
|
var _a;
|
|
452
|
-
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;
|
|
458
|
+
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;
|
|
453
459
|
var rootId;
|
|
454
460
|
if (doc.__sn) {
|
|
455
461
|
var docId = doc.__sn.id;
|
|
@@ -481,7 +487,7 @@ function serializeNode(n, options) {
|
|
|
481
487
|
rootId: rootId
|
|
482
488
|
};
|
|
483
489
|
case n.ELEMENT_NODE:
|
|
484
|
-
var needBlock = _isBlockedElement(n, blockClass, blockSelector);
|
|
490
|
+
var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);
|
|
485
491
|
var tagName = getValidTagName(n);
|
|
486
492
|
var attributes_1 = {};
|
|
487
493
|
for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {
|
|
@@ -522,9 +528,12 @@ function serializeNode(n, options) {
|
|
|
522
528
|
attributes_1.type !== 'button' &&
|
|
523
529
|
value) {
|
|
524
530
|
attributes_1.value = maskInputValue({
|
|
531
|
+
input: n,
|
|
525
532
|
type: attributes_1.type,
|
|
526
533
|
tagName: tagName,
|
|
527
534
|
value: value,
|
|
535
|
+
maskInputSelector: maskInputSelector,
|
|
536
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
528
537
|
maskInputOptions: maskInputOptions,
|
|
529
538
|
maskInputFn: maskInputFn
|
|
530
539
|
});
|
|
@@ -643,7 +652,7 @@ function serializeNode(n, options) {
|
|
|
643
652
|
}
|
|
644
653
|
if (!isStyle &&
|
|
645
654
|
!isScript &&
|
|
646
|
-
needMaskingText(n, maskTextClass, maskTextSelector) &&
|
|
655
|
+
needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&
|
|
647
656
|
textContent) {
|
|
648
657
|
textContent = maskTextFn
|
|
649
658
|
? maskTextFn(textContent)
|
|
@@ -751,15 +760,19 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
751
760
|
return false;
|
|
752
761
|
}
|
|
753
762
|
function serializeNodeWithId(n, options) {
|
|
754
|
-
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;
|
|
763
|
+
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;
|
|
755
764
|
var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;
|
|
756
765
|
var _serializedNode = serializeNode(n, {
|
|
757
766
|
doc: doc,
|
|
758
767
|
blockClass: blockClass,
|
|
759
768
|
blockSelector: blockSelector,
|
|
769
|
+
unblockSelector: unblockSelector,
|
|
760
770
|
maskTextClass: maskTextClass,
|
|
761
771
|
maskTextSelector: maskTextSelector,
|
|
772
|
+
unmaskTextSelector: unmaskTextSelector,
|
|
762
773
|
inlineStylesheet: inlineStylesheet,
|
|
774
|
+
maskInputSelector: maskInputSelector,
|
|
775
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
763
776
|
maskInputOptions: maskInputOptions,
|
|
764
777
|
maskTextFn: maskTextFn,
|
|
765
778
|
maskInputFn: maskInputFn,
|
|
@@ -815,10 +828,14 @@ function serializeNodeWithId(n, options) {
|
|
|
815
828
|
map: map,
|
|
816
829
|
blockClass: blockClass,
|
|
817
830
|
blockSelector: blockSelector,
|
|
831
|
+
unblockSelector: unblockSelector,
|
|
818
832
|
maskTextClass: maskTextClass,
|
|
819
833
|
maskTextSelector: maskTextSelector,
|
|
834
|
+
unmaskTextSelector: unmaskTextSelector,
|
|
820
835
|
skipChild: skipChild,
|
|
821
836
|
inlineStylesheet: inlineStylesheet,
|
|
837
|
+
maskInputSelector: maskInputSelector,
|
|
838
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
822
839
|
maskInputOptions: maskInputOptions,
|
|
823
840
|
maskTextFn: maskTextFn,
|
|
824
841
|
maskInputFn: maskInputFn,
|
|
@@ -863,10 +880,14 @@ function serializeNodeWithId(n, options) {
|
|
|
863
880
|
map: map,
|
|
864
881
|
blockClass: blockClass,
|
|
865
882
|
blockSelector: blockSelector,
|
|
883
|
+
unblockSelector: unblockSelector,
|
|
866
884
|
maskTextClass: maskTextClass,
|
|
867
885
|
maskTextSelector: maskTextSelector,
|
|
886
|
+
unmaskTextSelector: unmaskTextSelector,
|
|
868
887
|
skipChild: false,
|
|
869
888
|
inlineStylesheet: inlineStylesheet,
|
|
889
|
+
maskInputSelector: maskInputSelector,
|
|
890
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
870
891
|
maskInputOptions: maskInputOptions,
|
|
871
892
|
maskTextFn: maskTextFn,
|
|
872
893
|
maskInputFn: maskInputFn,
|
|
@@ -889,7 +910,7 @@ function serializeNodeWithId(n, options) {
|
|
|
889
910
|
return serializedNode;
|
|
890
911
|
}
|
|
891
912
|
function snapshot(n, options) {
|
|
892
|
-
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass =
|
|
913
|
+
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'rr-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;
|
|
893
914
|
var idNodeMap = {};
|
|
894
915
|
var maskInputOptions = maskAllInputs === true
|
|
895
916
|
? {
|
|
@@ -938,10 +959,14 @@ function snapshot(n, options) {
|
|
|
938
959
|
map: idNodeMap,
|
|
939
960
|
blockClass: blockClass,
|
|
940
961
|
blockSelector: blockSelector,
|
|
962
|
+
unblockSelector: unblockSelector,
|
|
941
963
|
maskTextClass: maskTextClass,
|
|
942
964
|
maskTextSelector: maskTextSelector,
|
|
965
|
+
unmaskTextSelector: unmaskTextSelector,
|
|
943
966
|
skipChild: false,
|
|
944
967
|
inlineStylesheet: inlineStylesheet,
|
|
968
|
+
maskInputSelector: maskInputSelector,
|
|
969
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
945
970
|
maskInputOptions: maskInputOptions,
|
|
946
971
|
maskTextFn: maskTextFn,
|
|
947
972
|
maskInputFn: maskInputFn,
|
|
@@ -1417,8 +1442,12 @@ var MutationBuffer = (function () {
|
|
|
1417
1442
|
map: _this.mirror.map,
|
|
1418
1443
|
blockClass: _this.blockClass,
|
|
1419
1444
|
blockSelector: _this.blockSelector,
|
|
1445
|
+
unblockSelector: _this.unblockSelector,
|
|
1420
1446
|
maskTextClass: _this.maskTextClass,
|
|
1421
1447
|
maskTextSelector: _this.maskTextSelector,
|
|
1448
|
+
unmaskTextSelector: _this.unmaskTextSelector,
|
|
1449
|
+
maskInputSelector: _this.maskInputSelector,
|
|
1450
|
+
unmaskInputSelector: _this.unmaskInputSelector,
|
|
1422
1451
|
skipChild: true,
|
|
1423
1452
|
inlineStylesheet: _this.inlineStylesheet,
|
|
1424
1453
|
maskInputOptions: _this.maskInputOptions,
|
|
@@ -1564,7 +1593,7 @@ var MutationBuffer = (function () {
|
|
|
1564
1593
|
var value = m.target.textContent;
|
|
1565
1594
|
if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) {
|
|
1566
1595
|
_this.texts.push({
|
|
1567
|
-
value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector) && value
|
|
1596
|
+
value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value
|
|
1568
1597
|
? _this.maskTextFn
|
|
1569
1598
|
? _this.maskTextFn(value)
|
|
1570
1599
|
: value.replace(/[\S]/g, '*')
|
|
@@ -1579,6 +1608,9 @@ var MutationBuffer = (function () {
|
|
|
1579
1608
|
var value = m.target.getAttribute(m.attributeName);
|
|
1580
1609
|
if (m.attributeName === 'value') {
|
|
1581
1610
|
value = maskInputValue({
|
|
1611
|
+
input: target,
|
|
1612
|
+
maskInputSelector: _this.maskInputSelector,
|
|
1613
|
+
unmaskInputSelector: _this.unmaskInputSelector,
|
|
1582
1614
|
maskInputOptions: _this.maskInputOptions,
|
|
1583
1615
|
tagName: m.target.tagName,
|
|
1584
1616
|
type: m.target.getAttribute('type'),
|
|
@@ -1715,8 +1747,12 @@ var MutationBuffer = (function () {
|
|
|
1715
1747
|
'mutationCb',
|
|
1716
1748
|
'blockClass',
|
|
1717
1749
|
'blockSelector',
|
|
1750
|
+
'unblockSelector',
|
|
1718
1751
|
'maskTextClass',
|
|
1719
1752
|
'maskTextSelector',
|
|
1753
|
+
'unmaskTextSelector',
|
|
1754
|
+
'maskInputSelector',
|
|
1755
|
+
'unmaskInputSelector',
|
|
1720
1756
|
'inlineStylesheet',
|
|
1721
1757
|
'maskInputOptions',
|
|
1722
1758
|
'maskTextFn',
|
|
@@ -1982,7 +2018,7 @@ function wrapEventWithUserTriggeredFlag(v, enable) {
|
|
|
1982
2018
|
var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
|
|
1983
2019
|
var lastInputValueMap = new WeakMap();
|
|
1984
2020
|
function initInputObserver(_a) {
|
|
1985
|
-
var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput;
|
|
2021
|
+
var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput;
|
|
1986
2022
|
function eventHandler(event) {
|
|
1987
2023
|
var target = getEventTarget(event);
|
|
1988
2024
|
var userTriggered = event.isTrusted;
|
|
@@ -1995,7 +2031,7 @@ function initInputObserver(_a) {
|
|
|
1995
2031
|
return;
|
|
1996
2032
|
}
|
|
1997
2033
|
var type = target.type;
|
|
1998
|
-
if (target.classList.contains(ignoreClass)) {
|
|
2034
|
+
if (target.classList.contains(ignoreClass) || (ignoreSelector && target.matches(ignoreSelector))) {
|
|
1999
2035
|
return;
|
|
2000
2036
|
}
|
|
2001
2037
|
var text = target.value;
|
|
@@ -2006,7 +2042,10 @@ function initInputObserver(_a) {
|
|
|
2006
2042
|
else if (maskInputOptions[target.tagName.toLowerCase()] ||
|
|
2007
2043
|
maskInputOptions[type]) {
|
|
2008
2044
|
text = maskInputValue({
|
|
2045
|
+
input: target,
|
|
2009
2046
|
maskInputOptions: maskInputOptions,
|
|
2047
|
+
maskInputSelector: maskInputSelector,
|
|
2048
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
2010
2049
|
tagName: target.tagName,
|
|
2011
2050
|
type: type,
|
|
2012
2051
|
value: text,
|
|
@@ -2090,6 +2129,9 @@ function getNestedCSSRulePositions(rule) {
|
|
|
2090
2129
|
function initStyleSheetObserver(_a, _b) {
|
|
2091
2130
|
var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror;
|
|
2092
2131
|
var win = _b.win;
|
|
2132
|
+
if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
|
|
2133
|
+
return function () { };
|
|
2134
|
+
}
|
|
2093
2135
|
var insertRule = win.CSSStyleSheet.prototype.insertRule;
|
|
2094
2136
|
win.CSSStyleSheet.prototype.insertRule = function (rule, index) {
|
|
2095
2137
|
var id = mirror.getId(this.ownerNode);
|
|
@@ -2922,7 +2964,7 @@ var takeFullSnapshot;
|
|
|
2922
2964
|
var mirror = createMirror();
|
|
2923
2965
|
function record(options) {
|
|
2924
2966
|
if (options === void 0) { options = {}; }
|
|
2925
|
-
var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass =
|
|
2967
|
+
var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s;
|
|
2926
2968
|
if (!emit) {
|
|
2927
2969
|
throw new Error('emit function is required');
|
|
2928
2970
|
}
|
|
@@ -3053,8 +3095,12 @@ function record(options) {
|
|
|
3053
3095
|
bypassOptions: {
|
|
3054
3096
|
blockClass: blockClass,
|
|
3055
3097
|
blockSelector: blockSelector,
|
|
3098
|
+
unblockSelector: unblockSelector,
|
|
3056
3099
|
maskTextClass: maskTextClass,
|
|
3057
3100
|
maskTextSelector: maskTextSelector,
|
|
3101
|
+
unmaskTextSelector: unmaskTextSelector,
|
|
3102
|
+
maskInputSelector: maskInputSelector,
|
|
3103
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
3058
3104
|
inlineStylesheet: inlineStylesheet,
|
|
3059
3105
|
maskInputOptions: maskInputOptions,
|
|
3060
3106
|
maskTextFn: maskTextFn,
|
|
@@ -3083,8 +3129,12 @@ function record(options) {
|
|
|
3083
3129
|
var _e = __read(snapshot(document, {
|
|
3084
3130
|
blockClass: blockClass,
|
|
3085
3131
|
blockSelector: blockSelector,
|
|
3132
|
+
unblockSelector: unblockSelector,
|
|
3086
3133
|
maskTextClass: maskTextClass,
|
|
3087
3134
|
maskTextSelector: maskTextSelector,
|
|
3135
|
+
unmaskTextSelector: unmaskTextSelector,
|
|
3136
|
+
maskInputSelector: maskInputSelector,
|
|
3137
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
3088
3138
|
inlineStylesheet: inlineStylesheet,
|
|
3089
3139
|
maskAllInputs: maskInputOptions,
|
|
3090
3140
|
maskTextFn: maskTextFn,
|
|
@@ -3198,8 +3248,12 @@ function record(options) {
|
|
|
3198
3248
|
},
|
|
3199
3249
|
blockClass: blockClass,
|
|
3200
3250
|
ignoreClass: ignoreClass,
|
|
3251
|
+
ignoreSelector: ignoreSelector,
|
|
3201
3252
|
maskTextClass: maskTextClass,
|
|
3202
3253
|
maskTextSelector: maskTextSelector,
|
|
3254
|
+
unmaskTextSelector: unmaskTextSelector,
|
|
3255
|
+
maskInputSelector: maskInputSelector,
|
|
3256
|
+
unmaskInputSelector: unmaskInputSelector,
|
|
3203
3257
|
maskInputOptions: maskInputOptions,
|
|
3204
3258
|
inlineStylesheet: inlineStylesheet,
|
|
3205
3259
|
sampling: sampling,
|
|
@@ -3211,6 +3265,7 @@ function record(options) {
|
|
|
3211
3265
|
maskInputFn: maskInputFn,
|
|
3212
3266
|
maskTextFn: maskTextFn,
|
|
3213
3267
|
blockSelector: blockSelector,
|
|
3268
|
+
unblockSelector: unblockSelector,
|
|
3214
3269
|
slimDOMOptions: slimDOMOptions,
|
|
3215
3270
|
mirror: mirror,
|
|
3216
3271
|
iframeManager: iframeManager,
|
|
@@ -3234,8 +3289,9 @@ function record(options) {
|
|
|
3234
3289
|
iframeManager.addLoadListener(function (iframeEl) {
|
|
3235
3290
|
try {
|
|
3236
3291
|
handlers_1.push(observe_1(iframeEl.contentDocument));
|
|
3237
|
-
}
|
|
3238
|
-
|
|
3292
|
+
}
|
|
3293
|
+
catch (error) {
|
|
3294
|
+
console.warn(error);
|
|
3239
3295
|
}
|
|
3240
3296
|
});
|
|
3241
3297
|
var init_1 = function () {
|
|
@@ -3286,1087 +3342,1158 @@ record.takeFullSnapshot = function (isCheckout) {
|
|
|
3286
3342
|
};
|
|
3287
3343
|
record.mirror = mirror;
|
|
3288
3344
|
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3345
|
+
const NAVIGATION_ENTRY_KEYS = [
|
|
3346
|
+
'name',
|
|
3347
|
+
'type',
|
|
3348
|
+
'startTime',
|
|
3349
|
+
'transferSize',
|
|
3350
|
+
'duration',
|
|
3351
|
+
];
|
|
3352
|
+
|
|
3353
|
+
function isNavigationEntryEqual(a) {
|
|
3354
|
+
return function (b) {
|
|
3355
|
+
return NAVIGATION_ENTRY_KEYS.every(key => a[key] === b[key]);
|
|
3299
3356
|
};
|
|
3300
3357
|
}
|
|
3301
3358
|
|
|
3302
3359
|
/**
|
|
3303
|
-
*
|
|
3360
|
+
* There are some difficulties diagnosing why there are duplicate navigation
|
|
3361
|
+
* entries. We've witnessed several intermittent results:
|
|
3362
|
+
* - duplicate entries have duration = 0
|
|
3363
|
+
* - duplicate entries are the same object reference
|
|
3364
|
+
* - none of the above
|
|
3365
|
+
*
|
|
3366
|
+
* Compare the values of several keys to determine if the entries are duplicates or not.
|
|
3304
3367
|
*/
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3368
|
+
// TODO (high-prio): Figure out wth is returned here
|
|
3369
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
3370
|
+
function dedupePerformanceEntries(
|
|
3371
|
+
currentList,
|
|
3372
|
+
newList,
|
|
3373
|
+
) {
|
|
3374
|
+
// Partition `currentList` into 3 different lists based on entryType
|
|
3375
|
+
const [existingNavigationEntries, existingLcpEntries, existingEntries] = currentList.reduce(
|
|
3376
|
+
(acc, entry) => {
|
|
3377
|
+
if (entry.entryType === 'navigation') {
|
|
3378
|
+
acc[0].push(entry );
|
|
3379
|
+
} else if (entry.entryType === 'largest-contentful-paint') {
|
|
3380
|
+
acc[1].push(entry );
|
|
3381
|
+
} else {
|
|
3382
|
+
acc[2].push(entry);
|
|
3383
|
+
}
|
|
3384
|
+
return acc;
|
|
3385
|
+
},
|
|
3386
|
+
[[], [], []],
|
|
3387
|
+
);
|
|
3309
3388
|
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
target = '<unknown>';
|
|
3316
|
-
}
|
|
3389
|
+
const newEntries = [];
|
|
3390
|
+
const newNavigationEntries = [];
|
|
3391
|
+
let newLcpEntry = existingLcpEntries.length
|
|
3392
|
+
? existingLcpEntries[existingLcpEntries.length - 1] // Take the last element as list is sorted
|
|
3393
|
+
: undefined;
|
|
3317
3394
|
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3395
|
+
newList.forEach(entry => {
|
|
3396
|
+
if (entry.entryType === 'largest-contentful-paint') {
|
|
3397
|
+
// We want the latest LCP event only
|
|
3398
|
+
if (!newLcpEntry || newLcpEntry.startTime < entry.startTime) {
|
|
3399
|
+
newLcpEntry = entry;
|
|
3400
|
+
}
|
|
3401
|
+
return;
|
|
3402
|
+
}
|
|
3321
3403
|
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
message: target,
|
|
3325
|
-
data: {
|
|
3326
|
-
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
3327
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3328
|
-
...(targetNode ? { nodeId: record.mirror.getId(targetNode ) } : {}),
|
|
3329
|
-
},
|
|
3330
|
-
});
|
|
3331
|
-
}
|
|
3404
|
+
if (entry.entryType === 'navigation') {
|
|
3405
|
+
const navigationEntry = entry ;
|
|
3332
3406
|
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3407
|
+
// Check if the navigation entry is contained in currentList or newList
|
|
3408
|
+
if (
|
|
3409
|
+
// Ignore any navigation entries with duration 0, as they are likely duplicates
|
|
3410
|
+
entry.duration > 0 &&
|
|
3411
|
+
// Ensure new entry does not already exist in existing entries
|
|
3412
|
+
!existingNavigationEntries.find(isNavigationEntryEqual(navigationEntry)) &&
|
|
3413
|
+
// Ensure new entry does not already exist in new list of navigation entries
|
|
3414
|
+
!newNavigationEntries.find(isNavigationEntryEqual(navigationEntry))
|
|
3415
|
+
) {
|
|
3416
|
+
newNavigationEntries.push(navigationEntry);
|
|
3417
|
+
}
|
|
3337
3418
|
|
|
3338
|
-
|
|
3339
|
-
|
|
3419
|
+
// Otherwise this navigation entry is considered a duplicate and is thrown away
|
|
3420
|
+
return;
|
|
3421
|
+
}
|
|
3340
3422
|
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
}
|
|
3423
|
+
newEntries.push(entry);
|
|
3424
|
+
});
|
|
3344
3425
|
|
|
3345
|
-
|
|
3426
|
+
// Re-combine and sort by startTime
|
|
3427
|
+
return [
|
|
3428
|
+
...(newLcpEntry ? [newLcpEntry] : []),
|
|
3429
|
+
...existingNavigationEntries,
|
|
3430
|
+
...existingEntries,
|
|
3431
|
+
...newEntries,
|
|
3432
|
+
...newNavigationEntries,
|
|
3433
|
+
].sort((a, b) => a.startTime - b.startTime);
|
|
3434
|
+
}
|
|
3346
3435
|
|
|
3347
3436
|
/**
|
|
3348
|
-
*
|
|
3437
|
+
* Sets up a PerformanceObserver to listen to all performance entry types.
|
|
3349
3438
|
*/
|
|
3350
|
-
function
|
|
3351
|
-
const
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3439
|
+
function setupPerformanceObserver(replay) {
|
|
3440
|
+
const performanceObserverHandler = (list) => {
|
|
3441
|
+
// For whatever reason the observer was returning duplicate navigation
|
|
3442
|
+
// entries (the other entry types were not duplicated).
|
|
3443
|
+
const newPerformanceEntries = dedupePerformanceEntries(
|
|
3444
|
+
replay.performanceEvents,
|
|
3445
|
+
list.getEntries() ,
|
|
3446
|
+
);
|
|
3447
|
+
replay.performanceEvents = newPerformanceEntries;
|
|
3448
|
+
};
|
|
3358
3449
|
|
|
3359
|
-
|
|
3450
|
+
const performanceObserver = new PerformanceObserver(performanceObserverHandler);
|
|
3360
3451
|
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3452
|
+
[
|
|
3453
|
+
'element',
|
|
3454
|
+
'event',
|
|
3455
|
+
'first-input',
|
|
3456
|
+
'largest-contentful-paint',
|
|
3457
|
+
'layout-shift',
|
|
3458
|
+
'longtask',
|
|
3459
|
+
'navigation',
|
|
3460
|
+
'paint',
|
|
3461
|
+
'resource',
|
|
3462
|
+
].forEach(type => {
|
|
3463
|
+
try {
|
|
3464
|
+
performanceObserver.observe({
|
|
3465
|
+
type,
|
|
3466
|
+
buffered: true,
|
|
3467
|
+
});
|
|
3468
|
+
} catch (e) {
|
|
3469
|
+
// This can throw if an entry type is not supported in the browser.
|
|
3470
|
+
// Ignore these errors.
|
|
3471
|
+
}
|
|
3472
|
+
});
|
|
3368
3473
|
|
|
3369
|
-
return
|
|
3474
|
+
return performanceObserver;
|
|
3370
3475
|
}
|
|
3371
3476
|
|
|
3477
|
+
const workerString = `/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
|
3478
|
+
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 m=t=>t<256?o[t]:o[256+(t>>>7)],b=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},g=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,b(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)},p=(t,e,a)=>{g(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++)r=r+a[n-1]<<1,i[n]=r;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.sym_next=t.matches=0},x=t=>{t.bi_valid>8?b(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.sym_next)do{s=255&t.pending_buf[t.sym_buf+f++],s+=(255&t.pending_buf[t.sym_buf+f++])<<8,r=t.pending_buf[t.sym_buf+f++],0===s?p(t,r,i):(o=l[r],p(t,o+256+1,i),_=e[o],0!==_&&(r-=h[o],g(t,r,_)),s--,o=m(s),p(t,o,n),_=a[o],0!==_&&(s-=d[o],g(t,s,_)))}while(f<t.sym_next);p(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{p(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(p(t,n,t.bl_tree),o--),p(t,16,t.bl_tree),g(t,o-3,2)):o<=10?(p(t,17,t.bl_tree),g(t,o-3,3)):(p(t,18,t.bl_tree),g(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)=>{g(t,0+(i?1:0),3),x(t),b(t,a),b(t,~a),a&&t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a};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?(g(t,2+(i?1:0),3),E(t,s,r)):(g(t,4+(i?1:0),3),((t,e,a,i)=>{let s;for(g(t,e-257,5),g(t,a-1,5),g(t,i-4,4),s=0;s<i;s++)g(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,m,b;const g=new Array(16);for(w=0,m=0;m<28;m++)for(h[m]=w,t=0;t<1<<e[m];t++)l[w++]=m;for(l[w-1]=m,b=0,m=0;m<16;m++)for(d[m]=b,t=0;t<1<<a[m];t++)o[b++]=m;for(b>>=7;m<30;m++)for(d[m]=b<<7,t=0;t<1<<a[m]-7;t++)o[256+b++]=m;for(n=0;n<=15;n++)g[n]=0;for(t=0;t<=143;)s[2*t+1]=8,t++,g[8]++;for(;t<=255;)s[2*t+1]=9,t++,g[9]++;for(;t<=279;)s[2*t+1]=7,t++,g[7]++;for(;t<=287;)s[2*t+1]=8,t++,g[8]++;for(v(s,287,g),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.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=a,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(l[a]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{g(t,2,3),p(t,256,s),(t=>{16===t.bi_valid?(b(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=>2*t-(t>4?9:0),dt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},_t=t=>{let e,a,i,n=t.w_size;e=t.hash_size,i=e;do{a=t.head[--i],t.head[i]=a>=n?a-n:0}while(--e);e=n,i=e;do{a=t.prev[--i],t.prev[i]=a>=n?a-n:0}while(--e)};let ft=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const ct=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))},ut=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ct(t.strm)},wt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(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;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),i+=e),0===t.strm.avail_in)break;if(a=bt(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=a,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=ft(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=ft(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},kt=(t,e)=>{let a,i,n,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,r=0,o=t.strm.avail_in;do{if(a=65535,n=t.bi_valid+42>>3,t.strm.avail_out<n)break;if(n=t.strm.avail_out-n,i=t.strstart-t.block_start,a>i+t.strm.avail_in&&(a=i+t.strm.avail_in),a>n&&(a=n),a<s&&(0===a&&e!==X||e===P||a!==i+t.strm.avail_in))break;r=e===X&&a===i+t.strm.avail_in?1:0,H(t,0,0,r),t.pending_buf[t.pending-4]=a,t.pending_buf[t.pending-3]=a>>8,t.pending_buf[t.pending-2]=~a,t.pending_buf[t.pending-1]=~a>>8,ct(t.strm),i&&(i>a&&(i=a),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,a-=i),a&&(bt(t.strm,t.strm.output,t.strm.next_out,a),t.strm.next_out+=a,t.strm.avail_out-=a,t.strm.total_out+=a)}while(0===r);return o-=t.strm.avail_in,o&&(o>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=o&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-o,t.strm.next_in),t.strstart),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),r?4:e!==P&&e!==X&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(n=t.window_size-t.strstart,t.strm.avail_in>n&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,n+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),n>t.strm.avail_in&&(n=t.strm.avail_in),n&&(bt(t.strm,t.window,t.strstart,n),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.high_water<t.strstart&&(t.high_water=t.strstart),n=t.bi_valid+42>>3,n=t.pending_buf_size-n>65535?65535:t.pending_buf_size-n,s=n>t.w_size?t.w_size:n,i=t.strstart-t.block_start,(i>=s||(i||e===X)&&e!==P&&0===t.strm.avail_in&&i<=n)&&(a=i>n?n:i,r=e===X&&0===t.strm.avail_in&&a===i?1:0,H(t,t.block_start,a,r),t.block_start+=a,ct(t.strm)),r?3:1)},vt=(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=ft(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=ft(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=ft(t,t.ins_h,t.window[t.strstart+1]);else i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2},yt=(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=ft(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=ft(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&&(ut(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&&ut(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?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2};function xt(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 zt=[new xt(0,0,0,0,kt),new xt(4,4,8,4,vt),new xt(4,5,16,8,vt),new xt(4,6,32,32,vt),new xt(4,4,16,16,yt),new xt(8,16,32,32,yt),new xt(8,16,128,128,yt),new xt(8,32,128,256,yt),new xt(32,128,258,1024,yt),new xt(32,258,258,4096,yt)];function At(){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.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Et=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},Rt=t=>{if(Et(t))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=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,C(e),W},Zt=t=>{const e=Rt(t);var a;return e===W&&((a=t.state).window_size=2*a.w_size,dt(a.head),a.max_lazy_match=zt[a.level].max_lazy,a.good_match=zt[a.level].good_length,a.nice_match=zt[a.level].nice_length,a.max_chain_length=zt[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},St=(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||8===i&&1!==r)return lt(t,Q);8===i&&(i=9);const o=new At;return t.state=o,o.strm=t,o.status=42,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.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=e,o.strategy=s,o.method=a,Zt(t)};var Ut={deflateInit:(t,e)=>St(t,e,ot,15,8,st),deflateInit2:St,deflateReset:Zt,deflateResetKeep:Rt,deflateSetHeader:(t,e)=>Et(t)||2!==t.state.wrap?Q:(t.state.gzhead=e,W),deflate:(t,e)=>{if(Et(t)||e>J||e<0)return t?lt(t,Q):Q;const a=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===a.status&&e!==X)return lt(t,0===t.avail_out?$:Q);const i=a.last_flush;if(a.last_flush=e,0!==a.pending){if(ct(t),0===t.avail_out)return a.last_flush=-1,W}else if(0===t.avail_in&&ht(e)<=ht(i)&&e!==X)return lt(t,$);if(666===a.status&&0!==t.avail_in)return lt(t,$);if(42===a.status&&0===a.wrap&&(a.status=113),42===a.status){let e=ot+(a.w_bits-8<<4)<<8,i=-1;if(i=a.strategy>=at||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=i<<6,0!==a.strstart&&(e|=32),e+=31-e%31,mt(a,e),0!==a.strstart&&(mt(a,t.adler>>>16),mt(a,65535&t.adler)),t.adler=1,a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(57===a.status)if(t.adler=0,wt(a,31),wt(a,139),wt(a,8),a.gzhead)wt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),wt(a,255&a.gzhead.time),wt(a,a.gzhead.time>>8&255),wt(a,a.gzhead.time>>16&255),wt(a,a.gzhead.time>>24&255),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(wt(a,255&a.gzhead.extra.length),wt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=L(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,3),a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W;if(69===a.status){if(a.gzhead.extra){let e=a.pending,i=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+i>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex+=n,ct(t),0!==a.pending)return a.last_flush=-1,W;e=0,i-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+i),a.pending),a.pending+=i,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(ct(t),0!==a.pending))return a.last_flush=-1,W;wt(a,255&t.adler),wt(a,t.adler>>8&255),t.adler=0}if(a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(0!==t.avail_in||0!==a.lookahead||e!==P&&666!==a.status){let i=0===a.level?kt(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):zt[a.level].func(a,e);if(3!==i&&4!==i||(a.status=666),1===i||3===i)return 0===t.avail_out&&(a.last_flush=-1),W;if(2===i&&(e===Y?K(a):e!==J&&(H(a,0,0,!1),e===G&&(dt(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),ct(t),0===t.avail_out))return a.last_flush=-1,W}return e!==X?W:a.wrap<=0?q:(2===a.wrap?(wt(a,255&t.adler),wt(a,t.adler>>8&255),wt(a,t.adler>>16&255),wt(a,t.adler>>24&255),wt(a,255&t.total_in),wt(a,t.total_in>>8&255),wt(a,t.total_in>>16&255),wt(a,t.total_in>>24&255)):(mt(a,t.adler>>>16),mt(a,65535&t.adler)),ct(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?W:q)},deflateEnd:t=>{if(Et(t))return Q;const e=t.state.status;return t.state=null,113===e?lt(t,V):W},deflateSetDictionary:(t,e)=>{let a=e.length;if(Et(t))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=ft(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 Dt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ot=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)Dt(a,e)&&(t[e]=a[e])}}return t},Tt=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 Nt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Nt=!1}const Ft=new Uint8Array(256);for(let t=0;t<256;t++)Ft[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ft[254]=Ft[254]=1;var Lt=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},It=(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=Ft[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&&Nt)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)},Bt=(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+Ft[t[a]]>e?a:e};var Ct=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 Ht=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:jt,Z_FULL_FLUSH:Kt,Z_FINISH:Pt,Z_OK:Yt,Z_STREAM_END:Gt,Z_DEFAULT_COMPRESSION:Xt,Z_DEFAULT_STRATEGY:Jt,Z_DEFLATED:Wt}=B;function qt(t){this.options=Ot({level:Xt,method:Wt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Jt},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 Ct,this.strm.avail_out=0;let a=Ut.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==Yt)throw new Error(I[a]);if(e.header&&Ut.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Lt(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Ut.deflateSetDictionary(this.strm,t),a!==Yt)throw new Error(I[a]);this._dict_set=!0}}function Qt(t,e){const a=new qt(e);if(a.push(t,!0),a.err)throw a.msg||I[a.err];return a.result}qt.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?Pt:Mt,"string"==typeof t?a.input=Lt(t):"[object ArrayBuffer]"===Ht.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===jt||s===Kt)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Ut.deflate(a,s),n===Gt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Ut.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Yt;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},qt.prototype.onData=function(t){this.chunks.push(t)},qt.prototype.onEnd=function(t){t===Yt&&(this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Vt={Deflate:qt,deflate:Qt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Qt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Qt(t,e)},constants:B};var $t=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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,m=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=u[f&m];e:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,0===p)A[n++]=65535&g;else{if(!(16&p)){if(0==(64&p)){g=u[(65535&g)+(f&(1<<p)-1)];continue e}if(32&p){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=16209;break t}k=65535&g,p&=15,p&&(c<p&&(f+=z[a++]<<c,c+=8),k+=f&(1<<p)-1,f>>>=p,c-=p),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=w[f&b];a:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,!(16&p)){if(0==(64&p)){g=w[(65535&g)+(f&(1<<p)-1)];continue a}t.msg="invalid distance code",E.mode=16209;break t}if(v=65535&g,p&=15,c<p&&(f+=z[a++]<<c,c+=8,c<p&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<p)-1,v>o){t.msg="invalid distance too far back",E.mode=16209;break t}if(f>>>=p,c-=p,p=n-s,v>p){if(p=v-p,p>h&&E.sane){t.msg="invalid distance too far back",E.mode=16209;break t}if(y=0,x=_,0===d){if(y+=l-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}else if(d<p){if(y+=l+d-p,p-=d,p<k){k-=p;do{A[n++]=_[y++]}while(--p);if(y=0,d<k){p=d,k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}}else if(y+=d-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);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 te=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]),ee=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]),ae=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]),ie=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 ne=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,m=0,b=0,g=0,p=0,k=0,v=0,y=0,x=0,z=0,A=null;const E=new Uint16Array(16),R=new Uint16Array(16);let Z,S,U,D=null;for(w=0;w<=15;w++)E[w]=0;for(m=0;m<i;m++)E[e[a+m]]++;for(p=l,g=15;g>=1&&0===E[g];g--);if(p>g&&(p=g),0===g)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(b=1;b<g&&0===E[b];b++);for(p<b&&(p=b),y=1,w=1;w<=15;w++)if(y<<=1,y-=E[w],y<0)return-1;if(y>0&&(0===t||1!==g))return-1;for(R[1]=0,w=1;w<15;w++)R[w+1]=R[w]+E[w];for(m=0;m<i;m++)0!==e[a+m]&&(r[R[e[a+m]]++]=m);if(0===t?(A=D=r,u=20):1===t?(A=te,D=ee,u=257):(A=ae,D=ie,u=0),z=0,m=0,w=b,c=s,k=p,v=0,_=-1,x=1<<p,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){Z=w-v,r[m]+1<u?(S=0,U=r[m]):r[m]>=u?(S=D[r[m]-u],U=A[r[m]-u]):(S=96,U=0),h=1<<w-v,d=1<<k,b=d;do{d-=h,n[c+(z>>v)+d]=Z<<24|S<<16|U|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,m++,0==--E[w]){if(w===g)break;w=e[a+r[m]]}if(w>p&&(z&f)!==_){for(0===v&&(v=p),c+=b,k=w-v,y=1<<k;k+v<g&&(y-=E[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=p<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=p,0};const{Z_FINISH:se,Z_BLOCK:re,Z_TREES:oe,Z_OK:le,Z_STREAM_END:he,Z_NEED_DICT:de,Z_STREAM_ERROR:_e,Z_DATA_ERROR:fe,Z_MEM_ERROR:ce,Z_BUF_ERROR:ue,Z_DEFLATED:we}=B,me=16209,be=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.strm=null,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 pe=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<16180||e.mode>16211?1:0},ke=t=>{if(pe(t))return _e;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=16180,e.last=0,e.havedict=0,e.flags=-1,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,le},ve=t=>{if(pe(t))return _e;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ke(t)},ye=(t,e)=>{let a;if(pe(t))return _e;const i=t.state;return e<0?(a=0,e=-e):(a=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?_e:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,ve(t))},xe=(t,e)=>{if(!t)return _e;const a=new ge;t.state=a,a.strm=t,a.window=null,a.mode=16180;const i=ye(t,e);return i!==le&&(t.state=null),i};let ze,Ae,Ee=!0;const Re=t=>{if(Ee){ze=new Int32Array(512),Ae=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(ne(1,t.lens,0,288,ze,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ne(2,t.lens,0,32,Ae,0,t.work,{bits:5}),Ee=!1}t.lencode=ze,t.lenbits=9,t.distcode=Ae,t.distbits=5},Ze=(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 Se={inflateReset:ve,inflateReset2:ye,inflateResetKeep:ke,inflateInit:t=>xe(t,15),inflateInit2:xe,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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(pe(t)||!t.output||!t.input&&0!==t.avail_in)return _e;a=t.state,16191===a.mode&&(a.mode=16192),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=le;t:for(;;)switch(a.mode){case 16180:if(0===a.wrap){a.mode=16192;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){0===a.wbits&&(a.wbits=15),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=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=me;break}if((15&h)!==we){t.msg="unknown compression method",a.mode=me;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits&&(a.wbits=y),y>15||y>a.wbits){t.msg="invalid window size",a.mode=me;break}a.dmax=1<<a.wbits,a.flags=0,t.adler=a.check=1,a.mode=512&h?16189:16191,h=0,d=0;break;case 16181:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==we){t.msg="unknown compression method",a.mode=me;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=me;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16182;case 16182:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&4&a.wrap&&(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=16183;case 16183: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&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16184;case 16184: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&&4&a.wrap&&(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=16185;case 16185: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=16186;case 16186: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&&4&a.wrap&&(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=16187;case 16187: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=me;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=16191;break;case 16189:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=be(h),h=0,d=0,a.mode=16190;case 16190: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,de;t.adler=a.check=1,a.mode=16191;case 16191:if(e===re||e===oe)break t;case 16192:if(a.last){h>>>=7&d,d-=7&d,a.mode=16206;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=16193;break;case 1:if(Re(a),a.mode=16199,e===oe){h>>>=2,d-=2;break t}break;case 2:a.mode=16196;break;case 3:t.msg="invalid block type",a.mode=me}h>>>=2,d-=2;break;case 16193: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=me;break}if(a.length=65535&h,h=0,d=0,a.mode=16194,e===oe)break t;case 16194:a.mode=16195;case 16195: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=16191;break;case 16196: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=me;break}a.have=0,a.mode=16197;case 16197: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=ne(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=me;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g<16)h>>>=m,d-=m,a.lens[a.have++]=g;else{if(16===g){for(R=m+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=m,d-=m,0===a.have){t.msg="invalid bit length repeat",a.mode=me;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===g){for(R=m+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=m+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,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=me;break}for(;c--;)a.lens[a.have++]=y}}if(a.mode===me)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=me;break}if(a.lenbits=9,E={bits:a.lenbits},x=ne(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=me;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=ne(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=me;break}if(a.mode=16199,e===oe)break t;case 16199:a.mode=16200;case 16200: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,$t(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,16191===a.mode&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(b&&0==(240&b)){for(p=m,k=b,v=g;z=a.lencode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,a.length=g,0===b){a.mode=16205;break}if(32&b){a.back=-1,a.mode=16191;break}if(64&b){t.msg="invalid literal/length code",a.mode=me;break}a.extra=15&b,a.mode=16201;case 16201: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=16202;case 16202:for(;z=a.distcode[h&(1<<a.distbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&b)){for(p=m,k=b,v=g;z=a.distcode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,64&b){t.msg="invalid distance code",a.mode=me;break}a.offset=g,a.extra=15&b,a.mode=16203;case 16203: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=me;break}a.mode=16204;case 16204: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=me;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=16200);break;case 16205:if(0===l)break t;n[r++]=a.length,l--,a.mode=16200;break;case 16206: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,4&a.wrap&&f&&(t.adler=a.check=a.flags?L(a.check,n,f,r-f):N(a.check,n,f,r-f)),f=l,4&a.wrap&&(a.flags?h:be(h))!==a.check){t.msg="incorrect data check",a.mode=me;break}h=0,d=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=me;break}h=0,d=0}a.mode=16208;case 16208:x=he;break t;case me:x=fe;break t;case 16210:return ce;default:return _e}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<me&&(a.mode<16206||e!==se))&&Ze(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,4&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)+(16191===a.mode?128:0)+(16199===a.mode||16194===a.mode?256:0),(0===_&&0===f||e===se)&&x===le&&(x=ue),x},inflateEnd:t=>{if(pe(t))return _e;let e=t.state;return e.window&&(e.window=null),t.state=null,le},inflateGetHeader:(t,e)=>{if(pe(t))return _e;const a=t.state;return 0==(2&a.wrap)?_e:(a.head=e,e.done=!1,le)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return pe(t)?_e:(i=t.state,0!==i.wrap&&16190!==i.mode?_e:16190===i.mode&&(n=1,n=N(n,e,a,0),n!==i.check)?fe:(s=Ze(t,e,a,a),s?(i.mode=16210,ce):(i.havedict=1,le)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ue=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 De=Object.prototype.toString,{Z_NO_FLUSH:Oe,Z_FINISH:Te,Z_OK:Ne,Z_STREAM_END:Fe,Z_NEED_DICT:Le,Z_STREAM_ERROR:Ie,Z_DATA_ERROR:Be,Z_MEM_ERROR:Ce}=B;function He(t){this.options=Ot({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 Ct,this.strm.avail_out=0;let a=Se.inflateInit2(this.strm,e.windowBits);if(a!==Ne)throw new Error(I[a]);if(this.header=new Ue,Se.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Lt(e.dictionary):"[object ArrayBuffer]"===De.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=Se.inflateSetDictionary(this.strm,e.dictionary),a!==Ne)))throw new Error(I[a])}He.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?Te:Oe,"[object ArrayBuffer]"===De.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=Se.inflate(a,r),s===Le&&n&&(s=Se.inflateSetDictionary(a,n),s===Ne?s=Se.inflate(a,r):s===Be&&(s=Le));a.avail_in>0&&s===Fe&&a.state.wrap>0&&0!==t[a.next_in];)Se.inflateReset(a),s=Se.inflate(a,r);switch(s){case Ie:case Be:case Le:case Ce:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===Fe))if("string"===this.options.to){let t=Bt(a.output,a.next_out),e=a.next_out-t,n=It(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!==Ne||0!==o){if(s===Fe)return s=Se.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},He.prototype.onData=function(t){this.chunks.push(t)},He.prototype.onEnd=function(t){t===Ne&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const{Deflate:Me,deflate:je,deflateRaw:Ke,gzip:Pe}=Vt;var Ye=Me,Ge=B;const Xe=new class{constructor(){this.added=0,this.init()}init(){this.added=0,this.deflate=new Ye,this.deflate.push("[",Ge.Z_NO_FLUSH)}addEvent(t){if(!t)throw new Error("Adding invalid event");const e=this.added>0?",":"";this.deflate.push(e+JSON.stringify(t),Ge.Z_SYNC_FLUSH),this.added++}finish(){if(this.deflate.push("]",Ge.Z_FINISH),this.deflate.err)throw this.deflate.err;const t=this.deflate.result;return this.init(),t}},Je={init:()=>(Xe.init(),""),addEvent:t=>Xe.addEvent(t),finish:()=>Xe.finish()};addEventListener("message",(function(t){const e=t.data.method,a=t.data.id,[i]=t.data.args?JSON.parse(t.data.args):[];if(e in Je&&"function"==typeof Je[e])try{const t=Je[e](i);postMessage({id:a,method:e,success:!0,response:t})}catch(t){postMessage({id:a,method:e,success:!1,response:t.message}),console.error(t)}})),postMessage({id:void 0,method:"init",success:!0,response:void 0});`;
|
|
3479
|
+
|
|
3372
3480
|
/**
|
|
3373
|
-
*
|
|
3481
|
+
* Create an event buffer for replays.
|
|
3374
3482
|
*/
|
|
3375
|
-
function
|
|
3376
|
-
|
|
3377
|
-
|
|
3483
|
+
function createEventBuffer({ useCompression }) {
|
|
3484
|
+
// eslint-disable-next-line no-restricted-globals
|
|
3485
|
+
if (useCompression && window.Worker) {
|
|
3486
|
+
const workerBlob = new Blob([workerString]);
|
|
3487
|
+
const workerUrl = URL.createObjectURL(workerBlob);
|
|
3488
|
+
|
|
3489
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Using compression worker');
|
|
3490
|
+
const worker = new Worker(workerUrl);
|
|
3491
|
+
return new EventBufferProxy(worker);
|
|
3378
3492
|
}
|
|
3379
3493
|
|
|
3380
|
-
|
|
3494
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Using simple buffer');
|
|
3495
|
+
return new EventBufferArray();
|
|
3381
3496
|
}
|
|
3382
3497
|
|
|
3383
3498
|
/**
|
|
3384
|
-
*
|
|
3499
|
+
* This proxy will try to use the compression worker, and fall back to use the simple buffer if an error occurs there.
|
|
3500
|
+
* This can happen e.g. if the worker cannot be loaded.
|
|
3501
|
+
* Exported only for testing.
|
|
3385
3502
|
*/
|
|
3386
|
-
|
|
3387
|
-
replay,
|
|
3388
|
-
event,
|
|
3389
|
-
isCheckout,
|
|
3390
|
-
) {
|
|
3391
|
-
if (!replay.eventBuffer) {
|
|
3392
|
-
// This implies that `_isEnabled` is false
|
|
3393
|
-
return null;
|
|
3394
|
-
}
|
|
3503
|
+
class EventBufferProxy {
|
|
3395
3504
|
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3505
|
+
constructor(worker) {
|
|
3506
|
+
this._fallback = new EventBufferArray();
|
|
3507
|
+
this._compression = new EventBufferCompressionWorker(worker);
|
|
3508
|
+
this._used = this._fallback;
|
|
3400
3509
|
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
const isMs = event.timestamp > 9999999999;
|
|
3404
|
-
const timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
|
|
3510
|
+
void this._ensureWorkerIsLoaded();
|
|
3511
|
+
}
|
|
3405
3512
|
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
// `performance.timeOrigin`, which is when the page first opened.
|
|
3410
|
-
if (timestampInMs + SESSION_IDLE_DURATION < new Date().getTime()) {
|
|
3411
|
-
return null;
|
|
3513
|
+
/** @inheritDoc */
|
|
3514
|
+
get pendingLength() {
|
|
3515
|
+
return this._used.pendingLength;
|
|
3412
3516
|
}
|
|
3413
3517
|
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
if (replay.session && replay.session.segmentId === 0 && (!earliestEvent || timestampInMs < earliestEvent)) {
|
|
3418
|
-
replay.getContext().earliestEvent = timestampInMs;
|
|
3518
|
+
/** @inheritDoc */
|
|
3519
|
+
get pendingEvents() {
|
|
3520
|
+
return this._used.pendingEvents;
|
|
3419
3521
|
}
|
|
3420
3522
|
|
|
3421
|
-
|
|
3422
|
-
|
|
3523
|
+
/** @inheritDoc */
|
|
3524
|
+
destroy() {
|
|
3525
|
+
this._fallback.destroy();
|
|
3526
|
+
this._compression.destroy();
|
|
3527
|
+
}
|
|
3423
3528
|
|
|
3424
|
-
/**
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
)
|
|
3431
|
-
return entries.map(({ type, start, end, name, data }) =>
|
|
3432
|
-
addEvent(replay, {
|
|
3433
|
-
type: EventType.Custom,
|
|
3434
|
-
timestamp: start,
|
|
3435
|
-
data: {
|
|
3436
|
-
tag: 'performanceSpan',
|
|
3437
|
-
payload: {
|
|
3438
|
-
op: type,
|
|
3439
|
-
description: name,
|
|
3440
|
-
startTimestamp: start,
|
|
3441
|
-
endTimestamp: end,
|
|
3442
|
-
data,
|
|
3443
|
-
},
|
|
3444
|
-
},
|
|
3445
|
-
}),
|
|
3446
|
-
);
|
|
3447
|
-
}
|
|
3448
|
-
|
|
3449
|
-
/**
|
|
3450
|
-
* Check whether a given request URL should be filtered out.
|
|
3451
|
-
*/
|
|
3452
|
-
function shouldFilterRequest(replay, url) {
|
|
3453
|
-
// If we enabled the `traceInternals` experiment, we want to trace everything
|
|
3454
|
-
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && replay.getOptions()._experiments.traceInternals) {
|
|
3455
|
-
return false;
|
|
3529
|
+
/**
|
|
3530
|
+
* Add an event to the event buffer.
|
|
3531
|
+
*
|
|
3532
|
+
* Returns true if event was successfully added.
|
|
3533
|
+
*/
|
|
3534
|
+
addEvent(event, isCheckout) {
|
|
3535
|
+
return this._used.addEvent(event, isCheckout);
|
|
3456
3536
|
}
|
|
3457
3537
|
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
/**
|
|
3462
|
-
* Checks wether a given URL belongs to the configured Sentry DSN.
|
|
3463
|
-
*/
|
|
3464
|
-
function _isSentryRequest(url) {
|
|
3465
|
-
const client = getCurrentHub().getClient();
|
|
3466
|
-
const dsn = client && client.getDsn();
|
|
3467
|
-
return dsn ? url.includes(dsn.host) : false;
|
|
3468
|
-
}
|
|
3469
|
-
|
|
3470
|
-
/** only exported for tests */
|
|
3471
|
-
function handleFetch(handlerData) {
|
|
3472
|
-
if (!handlerData.endTimestamp) {
|
|
3473
|
-
return null;
|
|
3538
|
+
/** @inheritDoc */
|
|
3539
|
+
finish() {
|
|
3540
|
+
return this._used.finish();
|
|
3474
3541
|
}
|
|
3475
3542
|
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
method: fetchData.method,
|
|
3485
|
-
statusCode: response.status,
|
|
3486
|
-
},
|
|
3487
|
-
};
|
|
3488
|
-
}
|
|
3489
|
-
|
|
3490
|
-
/**
|
|
3491
|
-
* Returns a listener to be added to `addInstrumentationHandler('fetch', listener)`.
|
|
3492
|
-
*/
|
|
3493
|
-
function handleFetchSpanListener(replay) {
|
|
3494
|
-
return (handlerData) => {
|
|
3495
|
-
if (!replay.isEnabled()) {
|
|
3496
|
-
return;
|
|
3497
|
-
}
|
|
3498
|
-
|
|
3499
|
-
const result = handleFetch(handlerData);
|
|
3500
|
-
|
|
3501
|
-
if (result === null) {
|
|
3543
|
+
/** Ensure the worker has loaded. */
|
|
3544
|
+
async _ensureWorkerIsLoaded() {
|
|
3545
|
+
try {
|
|
3546
|
+
await this._compression.ensureReady();
|
|
3547
|
+
} catch (error) {
|
|
3548
|
+
// If the worker fails to load, we fall back to the simple buffer.
|
|
3549
|
+
// Nothing more to do from our side here
|
|
3550
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Failed to load the compression worker, falling back to simple buffer');
|
|
3502
3551
|
return;
|
|
3503
3552
|
}
|
|
3504
3553
|
|
|
3505
|
-
|
|
3506
|
-
|
|
3554
|
+
// Compression worker is ready, we can use it
|
|
3555
|
+
// Now we need to switch over the array buffer to the compression worker
|
|
3556
|
+
const addEventPromises = [];
|
|
3557
|
+
for (const event of this._fallback.pendingEvents) {
|
|
3558
|
+
addEventPromises.push(this._compression.addEvent(event));
|
|
3507
3559
|
}
|
|
3508
3560
|
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
// We do not want network requests to cause a flush. This will prevent
|
|
3513
|
-
// recurring/polling requests from keeping the replay session alive.
|
|
3514
|
-
return true;
|
|
3515
|
-
});
|
|
3516
|
-
};
|
|
3517
|
-
}
|
|
3561
|
+
// We switch over to the compression buffer immediately - any further events will be added
|
|
3562
|
+
// after the previously buffered ones
|
|
3563
|
+
this._used = this._compression;
|
|
3518
3564
|
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
*/
|
|
3522
|
-
function isRrwebError(event) {
|
|
3523
|
-
if (event.type || !event.exception || !event.exception.values || !event.exception.values.length) {
|
|
3524
|
-
return false;
|
|
3565
|
+
// Wait for original events to be re-added before resolving
|
|
3566
|
+
await Promise.all(addEventPromises);
|
|
3525
3567
|
}
|
|
3526
|
-
|
|
3527
|
-
// Check if any exception originates from rrweb
|
|
3528
|
-
return event.exception.values.some(exception => {
|
|
3529
|
-
if (!exception.stacktrace || !exception.stacktrace.frames || !exception.stacktrace.frames.length) {
|
|
3530
|
-
return false;
|
|
3531
|
-
}
|
|
3532
|
-
|
|
3533
|
-
return exception.stacktrace.frames.some(frame => frame.filename && frame.filename.includes('/rrweb/src/'));
|
|
3534
|
-
});
|
|
3535
3568
|
}
|
|
3536
3569
|
|
|
3537
|
-
|
|
3538
|
-
* Returns a listener to be added to `addGlobalEventProcessor(listener)`.
|
|
3539
|
-
*/
|
|
3540
|
-
function handleGlobalEventListener(replay) {
|
|
3541
|
-
return (event) => {
|
|
3542
|
-
// Do not apply replayId to the root event
|
|
3543
|
-
if (event.type === REPLAY_EVENT_NAME) {
|
|
3544
|
-
// Replays have separate set of breadcrumbs, do not include breadcrumbs
|
|
3545
|
-
// from core SDK
|
|
3546
|
-
delete event.breadcrumbs;
|
|
3547
|
-
return event;
|
|
3548
|
-
}
|
|
3570
|
+
class EventBufferArray {
|
|
3549
3571
|
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Ignoring error from rrweb internals', event);
|
|
3554
|
-
return null;
|
|
3555
|
-
}
|
|
3572
|
+
constructor() {
|
|
3573
|
+
this._events = [];
|
|
3574
|
+
}
|
|
3556
3575
|
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
event.tags = { ...event.tags, replayId: replay.getSessionId() };
|
|
3561
|
-
}
|
|
3576
|
+
get pendingLength() {
|
|
3577
|
+
return this._events.length;
|
|
3578
|
+
}
|
|
3562
3579
|
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3580
|
+
/**
|
|
3581
|
+
* Returns the raw events that are buffered. In `EventBufferArray`, this is the
|
|
3582
|
+
* same as `this._events`.
|
|
3583
|
+
*/
|
|
3584
|
+
get pendingEvents() {
|
|
3585
|
+
return this._events;
|
|
3586
|
+
}
|
|
3569
3587
|
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
}
|
|
3588
|
+
destroy() {
|
|
3589
|
+
this._events = [];
|
|
3590
|
+
}
|
|
3574
3591
|
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
});
|
|
3592
|
+
async addEvent(event, isCheckout) {
|
|
3593
|
+
if (isCheckout) {
|
|
3594
|
+
this._events = [event];
|
|
3595
|
+
return;
|
|
3580
3596
|
}
|
|
3581
3597
|
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
event.exception &&
|
|
3586
|
-
event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because otherwise we could loop indefinitely with trying to capture replay and failing
|
|
3587
|
-
) {
|
|
3588
|
-
setTimeout(async () => {
|
|
3589
|
-
// Allow flush to complete before resuming as a session recording, otherwise
|
|
3590
|
-
// the checkout from `startRecording` may be included in the payload.
|
|
3591
|
-
// Prefer to keep the error replay as a separate (and smaller) segment
|
|
3592
|
-
// than the session replay.
|
|
3593
|
-
await replay.flushImmediate();
|
|
3594
|
-
|
|
3595
|
-
if (replay.stopRecording()) {
|
|
3596
|
-
// Reset all "capture on error" configuration before
|
|
3597
|
-
// starting a new recording
|
|
3598
|
-
replay.recordingMode = 'session';
|
|
3599
|
-
replay.startRecording();
|
|
3600
|
-
}
|
|
3601
|
-
});
|
|
3602
|
-
}
|
|
3598
|
+
this._events.push(event);
|
|
3599
|
+
return;
|
|
3600
|
+
}
|
|
3603
3601
|
|
|
3604
|
-
|
|
3605
|
-
|
|
3602
|
+
finish() {
|
|
3603
|
+
return new Promise(resolve => {
|
|
3604
|
+
// Make a copy of the events array reference and immediately clear the
|
|
3605
|
+
// events member so that we do not lose new events while uploading
|
|
3606
|
+
// attachment.
|
|
3607
|
+
const eventsRet = this._events;
|
|
3608
|
+
this._events = [];
|
|
3609
|
+
resolve(JSON.stringify(eventsRet));
|
|
3610
|
+
});
|
|
3611
|
+
}
|
|
3606
3612
|
}
|
|
3607
3613
|
|
|
3608
|
-
|
|
3609
|
-
|
|
3614
|
+
/**
|
|
3615
|
+
* Event buffer that uses a web worker to compress events.
|
|
3616
|
+
* Exported only for testing.
|
|
3617
|
+
*/
|
|
3618
|
+
class EventBufferCompressionWorker {
|
|
3619
|
+
/**
|
|
3620
|
+
* Keeps track of the list of events since the last flush that have not been compressed.
|
|
3621
|
+
* For example, page is reloaded and a flush attempt is made, but
|
|
3622
|
+
* `finish()` (and thus the flush), does not complete.
|
|
3623
|
+
*/
|
|
3624
|
+
__init() {this._pendingEvents = [];}
|
|
3610
3625
|
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
level: level || 'debug',
|
|
3614
|
-
message: `[debug]: ${message}`,
|
|
3615
|
-
...rest,
|
|
3616
|
-
});
|
|
3617
|
-
}
|
|
3626
|
+
__init2() {this._eventBufferItemLength = 0;}
|
|
3627
|
+
__init3() {this._id = 0;}
|
|
3618
3628
|
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
value: 'n/a',
|
|
3623
|
-
...(event.exception && event.exception.values && event.exception.values[0]),
|
|
3624
|
-
};
|
|
3625
|
-
}
|
|
3629
|
+
constructor(worker) {EventBufferCompressionWorker.prototype.__init.call(this);EventBufferCompressionWorker.prototype.__init2.call(this);EventBufferCompressionWorker.prototype.__init3.call(this);
|
|
3630
|
+
this._worker = worker;
|
|
3631
|
+
}
|
|
3626
3632
|
|
|
3627
|
-
|
|
3628
|
-
|
|
3633
|
+
/**
|
|
3634
|
+
* The number of raw events that are buffered. This may not be the same as
|
|
3635
|
+
* the number of events that have been compresed in the worker because
|
|
3636
|
+
* `addEvent` is async.
|
|
3637
|
+
*/
|
|
3638
|
+
get pendingLength() {
|
|
3639
|
+
return this._eventBufferItemLength;
|
|
3640
|
+
}
|
|
3629
3641
|
|
|
3630
|
-
|
|
3642
|
+
/**
|
|
3643
|
+
* Returns a list of the raw recording events that are being compressed.
|
|
3644
|
+
*/
|
|
3645
|
+
get pendingEvents() {
|
|
3646
|
+
return this._pendingEvents;
|
|
3647
|
+
}
|
|
3631
3648
|
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3649
|
+
/**
|
|
3650
|
+
* Ensure the worker is ready (or not).
|
|
3651
|
+
* This will either resolve when the worker is ready, or reject if an error occured.
|
|
3652
|
+
*/
|
|
3653
|
+
ensureReady() {
|
|
3654
|
+
return new Promise((resolve, reject) => {
|
|
3655
|
+
this._worker.addEventListener(
|
|
3656
|
+
'message',
|
|
3657
|
+
({ data }) => {
|
|
3658
|
+
if (data.success) {
|
|
3659
|
+
resolve();
|
|
3660
|
+
} else {
|
|
3661
|
+
reject();
|
|
3662
|
+
}
|
|
3663
|
+
},
|
|
3664
|
+
{ once: true },
|
|
3665
|
+
);
|
|
3642
3666
|
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3667
|
+
this._worker.addEventListener(
|
|
3668
|
+
'error',
|
|
3669
|
+
error => {
|
|
3670
|
+
reject(error);
|
|
3671
|
+
},
|
|
3672
|
+
{ once: true },
|
|
3673
|
+
);
|
|
3674
|
+
});
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
/**
|
|
3678
|
+
* Destroy the event buffer.
|
|
3679
|
+
*/
|
|
3680
|
+
destroy() {
|
|
3681
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Destroying compression worker');
|
|
3682
|
+
this._worker.terminate();
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
/**
|
|
3686
|
+
* Add an event to the event buffer.
|
|
3687
|
+
*
|
|
3688
|
+
* Returns true if event was successfuly received and processed by worker.
|
|
3689
|
+
*/
|
|
3690
|
+
async addEvent(event, isCheckout) {
|
|
3691
|
+
if (isCheckout) {
|
|
3692
|
+
// This event is a checkout, make sure worker buffer is cleared before
|
|
3693
|
+
// proceeding.
|
|
3694
|
+
await this._postMessage({
|
|
3695
|
+
id: this._getAndIncrementId(),
|
|
3696
|
+
method: 'init',
|
|
3697
|
+
args: [],
|
|
3698
|
+
});
|
|
3650
3699
|
}
|
|
3651
3700
|
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
return;
|
|
3701
|
+
// Don't store checkout events in `_pendingEvents` because they are too large
|
|
3702
|
+
if (!isCheckout) {
|
|
3703
|
+
this._pendingEvents.push(event);
|
|
3656
3704
|
}
|
|
3657
3705
|
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
replay.triggerUserActivity();
|
|
3706
|
+
return this._sendEventToWorker(event);
|
|
3707
|
+
}
|
|
3661
3708
|
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
}
|
|
3668
|
-
}
|
|
3709
|
+
/**
|
|
3710
|
+
* Finish the event buffer and return the compressed data.
|
|
3711
|
+
*/
|
|
3712
|
+
finish() {
|
|
3713
|
+
return this._finishRequest(this._getAndIncrementId());
|
|
3714
|
+
}
|
|
3669
3715
|
|
|
3670
|
-
|
|
3671
|
-
|
|
3716
|
+
/**
|
|
3717
|
+
* Post message to worker and wait for response before resolving promise.
|
|
3718
|
+
*/
|
|
3719
|
+
_postMessage({ id, method, args }) {
|
|
3720
|
+
return new Promise((resolve, reject) => {
|
|
3721
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
3722
|
+
const listener = ({ data }) => {
|
|
3723
|
+
if (data.method !== method) {
|
|
3724
|
+
return;
|
|
3725
|
+
}
|
|
3672
3726
|
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
}
|
|
3727
|
+
// There can be multiple listeners for a single method, the id ensures
|
|
3728
|
+
// that the response matches the caller.
|
|
3729
|
+
if (data.id !== id) {
|
|
3730
|
+
return;
|
|
3731
|
+
}
|
|
3679
3732
|
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
handlerData.xhr.__sentry_xhr__ = handlerData.xhr.__sentry_xhr__ || {};
|
|
3683
|
-
handlerData.xhr.__sentry_xhr__.startTimestamp = handlerData.startTimestamp;
|
|
3684
|
-
}
|
|
3733
|
+
// At this point, we'll always want to remove listener regardless of result status
|
|
3734
|
+
this._worker.removeEventListener('message', listener);
|
|
3685
3735
|
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3736
|
+
if (!data.success) {
|
|
3737
|
+
// TODO: Do some error handling, not sure what
|
|
3738
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('[Replay]', data.response);
|
|
3689
3739
|
|
|
3690
|
-
|
|
3740
|
+
reject(new Error('Error in compression worker'));
|
|
3741
|
+
return;
|
|
3742
|
+
}
|
|
3691
3743
|
|
|
3692
|
-
|
|
3693
|
-
|
|
3744
|
+
resolve(data.response);
|
|
3745
|
+
};
|
|
3746
|
+
|
|
3747
|
+
let stringifiedArgs;
|
|
3748
|
+
try {
|
|
3749
|
+
stringifiedArgs = JSON.stringify(args);
|
|
3750
|
+
} catch (err) {
|
|
3751
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('[Replay] Error when trying to stringify args', err);
|
|
3752
|
+
stringifiedArgs = '[]';
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
// Note: we can't use `once` option because it's possible it needs to
|
|
3756
|
+
// listen to multiple messages
|
|
3757
|
+
this._worker.addEventListener('message', listener);
|
|
3758
|
+
this._worker.postMessage({ id, method, args: stringifiedArgs });
|
|
3759
|
+
});
|
|
3694
3760
|
}
|
|
3695
3761
|
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3762
|
+
/**
|
|
3763
|
+
* Send the event to the worker.
|
|
3764
|
+
*/
|
|
3765
|
+
async _sendEventToWorker(event) {
|
|
3766
|
+
const promise = this._postMessage({
|
|
3767
|
+
id: this._getAndIncrementId(),
|
|
3768
|
+
method: 'addEvent',
|
|
3769
|
+
args: [event],
|
|
3770
|
+
});
|
|
3699
3771
|
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
name: url,
|
|
3703
|
-
start: timestamp / 1000,
|
|
3704
|
-
end: handlerData.endTimestamp / 1000,
|
|
3705
|
-
data: {
|
|
3706
|
-
method,
|
|
3707
|
-
statusCode,
|
|
3708
|
-
},
|
|
3709
|
-
};
|
|
3710
|
-
}
|
|
3772
|
+
// XXX: See note in `get length()`
|
|
3773
|
+
this._eventBufferItemLength++;
|
|
3711
3774
|
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
*/
|
|
3715
|
-
function handleXhrSpanListener(replay) {
|
|
3716
|
-
return (handlerData) => {
|
|
3717
|
-
if (!replay.isEnabled()) {
|
|
3718
|
-
return;
|
|
3719
|
-
}
|
|
3775
|
+
return promise;
|
|
3776
|
+
}
|
|
3720
3777
|
|
|
3721
|
-
|
|
3778
|
+
/**
|
|
3779
|
+
* Finish the request and return the compressed data from the worker.
|
|
3780
|
+
*/
|
|
3781
|
+
async _finishRequest(id) {
|
|
3782
|
+
const promise = this._postMessage({ id, method: 'finish', args: [] });
|
|
3722
3783
|
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
}
|
|
3784
|
+
// XXX: See note in `get length()`
|
|
3785
|
+
this._eventBufferItemLength = 0;
|
|
3726
3786
|
|
|
3727
|
-
|
|
3728
|
-
return;
|
|
3729
|
-
}
|
|
3787
|
+
await promise;
|
|
3730
3788
|
|
|
3731
|
-
|
|
3732
|
-
createPerformanceSpans(replay, [result]);
|
|
3733
|
-
// Returning true will cause `addUpdate` to not flush
|
|
3734
|
-
// We do not want network requests to cause a flush. This will prevent
|
|
3735
|
-
// recurring/polling requests from keeping the replay session alive.
|
|
3736
|
-
return true;
|
|
3737
|
-
});
|
|
3738
|
-
};
|
|
3739
|
-
}
|
|
3789
|
+
this._pendingEvents = [];
|
|
3740
3790
|
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
'type',
|
|
3744
|
-
'startTime',
|
|
3745
|
-
'transferSize',
|
|
3746
|
-
'duration',
|
|
3747
|
-
];
|
|
3791
|
+
return promise;
|
|
3792
|
+
}
|
|
3748
3793
|
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
return
|
|
3752
|
-
}
|
|
3794
|
+
/** Get the current ID and increment it for the next call. */
|
|
3795
|
+
_getAndIncrementId() {
|
|
3796
|
+
return this._id++;
|
|
3797
|
+
}
|
|
3753
3798
|
}
|
|
3754
3799
|
|
|
3755
3800
|
/**
|
|
3756
|
-
*
|
|
3757
|
-
*
|
|
3758
|
-
* - duplicate entries have duration = 0
|
|
3759
|
-
* - duplicate entries are the same object reference
|
|
3760
|
-
* - none of the above
|
|
3761
|
-
*
|
|
3762
|
-
* Compare the values of several keys to determine if the entries are duplicates or not.
|
|
3801
|
+
* Given an initial timestamp and an expiry duration, checks to see if current
|
|
3802
|
+
* time should be considered as expired.
|
|
3763
3803
|
*/
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
newList,
|
|
3804
|
+
function isExpired(
|
|
3805
|
+
initialTime,
|
|
3806
|
+
expiry,
|
|
3807
|
+
targetTime = +new Date(),
|
|
3769
3808
|
) {
|
|
3770
|
-
//
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
acc[0].push(entry );
|
|
3775
|
-
} else if (entry.entryType === 'largest-contentful-paint') {
|
|
3776
|
-
acc[1].push(entry );
|
|
3777
|
-
} else {
|
|
3778
|
-
acc[2].push(entry);
|
|
3779
|
-
}
|
|
3780
|
-
return acc;
|
|
3781
|
-
},
|
|
3782
|
-
[[], [], []],
|
|
3783
|
-
);
|
|
3809
|
+
// Always expired if < 0
|
|
3810
|
+
if (initialTime === null || expiry === undefined || expiry < 0) {
|
|
3811
|
+
return true;
|
|
3812
|
+
}
|
|
3784
3813
|
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
: undefined;
|
|
3814
|
+
// Never expires if == 0
|
|
3815
|
+
if (expiry === 0) {
|
|
3816
|
+
return false;
|
|
3817
|
+
}
|
|
3790
3818
|
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
// We want the latest LCP event only
|
|
3794
|
-
if (!newLcpEntry || newLcpEntry.startTime < entry.startTime) {
|
|
3795
|
-
newLcpEntry = entry;
|
|
3796
|
-
}
|
|
3797
|
-
return;
|
|
3798
|
-
}
|
|
3819
|
+
return initialTime + expiry <= targetTime;
|
|
3820
|
+
}
|
|
3799
3821
|
|
|
3800
|
-
|
|
3801
|
-
|
|
3822
|
+
/**
|
|
3823
|
+
* Checks to see if session is expired
|
|
3824
|
+
*/
|
|
3825
|
+
function isSessionExpired(session, idleTimeout, targetTime = +new Date()) {
|
|
3826
|
+
return (
|
|
3827
|
+
// First, check that maximum session length has not been exceeded
|
|
3828
|
+
isExpired(session.started, MAX_SESSION_LIFE, targetTime) ||
|
|
3829
|
+
// check that the idle timeout has not been exceeded (i.e. user has
|
|
3830
|
+
// performed an action within the last `idleTimeout` ms)
|
|
3831
|
+
isExpired(session.lastActivity, idleTimeout, targetTime)
|
|
3832
|
+
);
|
|
3833
|
+
}
|
|
3802
3834
|
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
) {
|
|
3812
|
-
newNavigationEntries.push(navigationEntry);
|
|
3813
|
-
}
|
|
3835
|
+
/**
|
|
3836
|
+
* Save a session to session storage.
|
|
3837
|
+
*/
|
|
3838
|
+
function saveSession(session) {
|
|
3839
|
+
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
3840
|
+
if (!hasSessionStorage) {
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3814
3843
|
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3844
|
+
try {
|
|
3845
|
+
WINDOW.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
3846
|
+
} catch (e) {
|
|
3847
|
+
// Ignore potential SecurityError exceptions
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3818
3850
|
|
|
3819
|
-
|
|
3820
|
-
|
|
3851
|
+
/**
|
|
3852
|
+
* Given a sample rate, returns true if replay should be sampled.
|
|
3853
|
+
*
|
|
3854
|
+
* 1.0 = 100% sampling
|
|
3855
|
+
* 0.0 = 0% sampling
|
|
3856
|
+
*/
|
|
3857
|
+
function isSampled(sampleRate) {
|
|
3858
|
+
if (sampleRate === undefined) {
|
|
3859
|
+
return false;
|
|
3860
|
+
}
|
|
3821
3861
|
|
|
3822
|
-
//
|
|
3823
|
-
return
|
|
3824
|
-
...(newLcpEntry ? [newLcpEntry] : []),
|
|
3825
|
-
...existingNavigationEntries,
|
|
3826
|
-
...existingEntries,
|
|
3827
|
-
...newEntries,
|
|
3828
|
-
...newNavigationEntries,
|
|
3829
|
-
].sort((a, b) => a.startTime - b.startTime);
|
|
3862
|
+
// Math.random() returns a number in range of 0 to 1 (inclusive of 0, but not 1)
|
|
3863
|
+
return Math.random() < sampleRate;
|
|
3830
3864
|
}
|
|
3831
3865
|
|
|
3832
3866
|
/**
|
|
3833
|
-
*
|
|
3867
|
+
* Get a session with defaults & applied sampling.
|
|
3834
3868
|
*/
|
|
3835
|
-
function
|
|
3836
|
-
const
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3869
|
+
function makeSession(session) {
|
|
3870
|
+
const now = new Date().getTime();
|
|
3871
|
+
const id = session.id || uuid4();
|
|
3872
|
+
// Note that this means we cannot set a started/lastActivity of `0`, but this should not be relevant outside of tests.
|
|
3873
|
+
const started = session.started || now;
|
|
3874
|
+
const lastActivity = session.lastActivity || now;
|
|
3875
|
+
const segmentId = session.segmentId || 0;
|
|
3876
|
+
const sampled = session.sampled;
|
|
3877
|
+
|
|
3878
|
+
return {
|
|
3879
|
+
id,
|
|
3880
|
+
started,
|
|
3881
|
+
lastActivity,
|
|
3882
|
+
segmentId,
|
|
3883
|
+
sampled,
|
|
3844
3884
|
};
|
|
3885
|
+
}
|
|
3845
3886
|
|
|
3846
|
-
|
|
3887
|
+
/**
|
|
3888
|
+
* Get the sampled status for a session based on sample rates & current sampled status.
|
|
3889
|
+
*/
|
|
3890
|
+
function getSessionSampleType(sessionSampleRate, errorSampleRate) {
|
|
3891
|
+
return isSampled(sessionSampleRate) ? 'session' : isSampled(errorSampleRate) ? 'error' : false;
|
|
3892
|
+
}
|
|
3847
3893
|
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
'resource',
|
|
3858
|
-
].forEach(type => {
|
|
3859
|
-
try {
|
|
3860
|
-
performanceObserver.observe({
|
|
3861
|
-
type,
|
|
3862
|
-
buffered: true,
|
|
3863
|
-
});
|
|
3864
|
-
} catch (e) {
|
|
3865
|
-
// This can throw if an entry type is not supported in the browser.
|
|
3866
|
-
// Ignore these errors.
|
|
3867
|
-
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Create a new session, which in its current implementation is a Sentry event
|
|
3896
|
+
* that all replays will be saved to as attachments. Currently, we only expect
|
|
3897
|
+
* one of these Sentry events per "replay session".
|
|
3898
|
+
*/
|
|
3899
|
+
function createSession({ sessionSampleRate, errorSampleRate, stickySession = false }) {
|
|
3900
|
+
const sampled = getSessionSampleType(sessionSampleRate, errorSampleRate);
|
|
3901
|
+
const session = makeSession({
|
|
3902
|
+
sampled,
|
|
3868
3903
|
});
|
|
3869
3904
|
|
|
3870
|
-
|
|
3871
|
-
}
|
|
3905
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log(`[Replay] Creating new session: ${session.id}`);
|
|
3872
3906
|
|
|
3873
|
-
|
|
3874
|
-
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 m=t=>t<256?o[t]:o[256+(t>>>7)],b=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},g=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,b(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)},p=(t,e,a)=>{g(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++)r=r+a[n-1]<<1,i[n]=r;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.sym_next=t.matches=0},x=t=>{t.bi_valid>8?b(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.sym_next)do{s=255&t.pending_buf[t.sym_buf+f++],s+=(255&t.pending_buf[t.sym_buf+f++])<<8,r=t.pending_buf[t.sym_buf+f++],0===s?p(t,r,i):(o=l[r],p(t,o+256+1,i),_=e[o],0!==_&&(r-=h[o],g(t,r,_)),s--,o=m(s),p(t,o,n),_=a[o],0!==_&&(s-=d[o],g(t,s,_)))}while(f<t.sym_next);p(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{p(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(p(t,n,t.bl_tree),o--),p(t,16,t.bl_tree),g(t,o-3,2)):o<=10?(p(t,17,t.bl_tree),g(t,o-3,3)):(p(t,18,t.bl_tree),g(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)=>{g(t,0+(i?1:0),3),x(t),b(t,a),b(t,~a),a&&t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a};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?(g(t,2+(i?1:0),3),E(t,s,r)):(g(t,4+(i?1:0),3),((t,e,a,i)=>{let s;for(g(t,e-257,5),g(t,a-1,5),g(t,i-4,4),s=0;s<i;s++)g(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,m,b;const g=new Array(16);for(w=0,m=0;m<28;m++)for(h[m]=w,t=0;t<1<<e[m];t++)l[w++]=m;for(l[w-1]=m,b=0,m=0;m<16;m++)for(d[m]=b,t=0;t<1<<a[m];t++)o[b++]=m;for(b>>=7;m<30;m++)for(d[m]=b<<7,t=0;t<1<<a[m]-7;t++)o[256+b++]=m;for(n=0;n<=15;n++)g[n]=0;for(t=0;t<=143;)s[2*t+1]=8,t++,g[8]++;for(;t<=255;)s[2*t+1]=9,t++,g[9]++;for(;t<=279;)s[2*t+1]=7,t++,g[7]++;for(;t<=287;)s[2*t+1]=8,t++,g[8]++;for(v(s,287,g),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.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=a,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(l[a]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{g(t,2,3),p(t,256,s),(t=>{16===t.bi_valid?(b(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=>2*t-(t>4?9:0),dt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},_t=t=>{let e,a,i,n=t.w_size;e=t.hash_size,i=e;do{a=t.head[--i],t.head[i]=a>=n?a-n:0}while(--e);e=n,i=e;do{a=t.prev[--i],t.prev[i]=a>=n?a-n:0}while(--e)};let ft=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const ct=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))},ut=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ct(t.strm)},wt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(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;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),i+=e),0===t.strm.avail_in)break;if(a=bt(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=a,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=ft(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=ft(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},kt=(t,e)=>{let a,i,n,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,r=0,o=t.strm.avail_in;do{if(a=65535,n=t.bi_valid+42>>3,t.strm.avail_out<n)break;if(n=t.strm.avail_out-n,i=t.strstart-t.block_start,a>i+t.strm.avail_in&&(a=i+t.strm.avail_in),a>n&&(a=n),a<s&&(0===a&&e!==X||e===P||a!==i+t.strm.avail_in))break;r=e===X&&a===i+t.strm.avail_in?1:0,H(t,0,0,r),t.pending_buf[t.pending-4]=a,t.pending_buf[t.pending-3]=a>>8,t.pending_buf[t.pending-2]=~a,t.pending_buf[t.pending-1]=~a>>8,ct(t.strm),i&&(i>a&&(i=a),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,a-=i),a&&(bt(t.strm,t.strm.output,t.strm.next_out,a),t.strm.next_out+=a,t.strm.avail_out-=a,t.strm.total_out+=a)}while(0===r);return o-=t.strm.avail_in,o&&(o>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=o&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-o,t.strm.next_in),t.strstart),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),r?4:e!==P&&e!==X&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(n=t.window_size-t.strstart,t.strm.avail_in>n&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,n+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),n>t.strm.avail_in&&(n=t.strm.avail_in),n&&(bt(t.strm,t.window,t.strstart,n),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.high_water<t.strstart&&(t.high_water=t.strstart),n=t.bi_valid+42>>3,n=t.pending_buf_size-n>65535?65535:t.pending_buf_size-n,s=n>t.w_size?t.w_size:n,i=t.strstart-t.block_start,(i>=s||(i||e===X)&&e!==P&&0===t.strm.avail_in&&i<=n)&&(a=i>n?n:i,r=e===X&&0===t.strm.avail_in&&a===i?1:0,H(t,t.block_start,a,r),t.block_start+=a,ct(t.strm)),r?3:1)},vt=(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=ft(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=ft(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=ft(t,t.ins_h,t.window[t.strstart+1]);else i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2},yt=(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=ft(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=ft(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&&(ut(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&&ut(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?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2};function xt(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 zt=[new xt(0,0,0,0,kt),new xt(4,4,8,4,vt),new xt(4,5,16,8,vt),new xt(4,6,32,32,vt),new xt(4,4,16,16,yt),new xt(8,16,32,32,yt),new xt(8,16,128,128,yt),new xt(8,32,128,256,yt),new xt(32,128,258,1024,yt),new xt(32,258,258,4096,yt)];function At(){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.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Et=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},Rt=t=>{if(Et(t))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=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,C(e),W},Zt=t=>{const e=Rt(t);var a;return e===W&&((a=t.state).window_size=2*a.w_size,dt(a.head),a.max_lazy_match=zt[a.level].max_lazy,a.good_match=zt[a.level].good_length,a.nice_match=zt[a.level].nice_length,a.max_chain_length=zt[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},St=(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||8===i&&1!==r)return lt(t,Q);8===i&&(i=9);const o=new At;return t.state=o,o.strm=t,o.status=42,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.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=e,o.strategy=s,o.method=a,Zt(t)};var Ut={deflateInit:(t,e)=>St(t,e,ot,15,8,st),deflateInit2:St,deflateReset:Zt,deflateResetKeep:Rt,deflateSetHeader:(t,e)=>Et(t)||2!==t.state.wrap?Q:(t.state.gzhead=e,W),deflate:(t,e)=>{if(Et(t)||e>J||e<0)return t?lt(t,Q):Q;const a=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===a.status&&e!==X)return lt(t,0===t.avail_out?$:Q);const i=a.last_flush;if(a.last_flush=e,0!==a.pending){if(ct(t),0===t.avail_out)return a.last_flush=-1,W}else if(0===t.avail_in&&ht(e)<=ht(i)&&e!==X)return lt(t,$);if(666===a.status&&0!==t.avail_in)return lt(t,$);if(42===a.status&&0===a.wrap&&(a.status=113),42===a.status){let e=ot+(a.w_bits-8<<4)<<8,i=-1;if(i=a.strategy>=at||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=i<<6,0!==a.strstart&&(e|=32),e+=31-e%31,mt(a,e),0!==a.strstart&&(mt(a,t.adler>>>16),mt(a,65535&t.adler)),t.adler=1,a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(57===a.status)if(t.adler=0,wt(a,31),wt(a,139),wt(a,8),a.gzhead)wt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),wt(a,255&a.gzhead.time),wt(a,a.gzhead.time>>8&255),wt(a,a.gzhead.time>>16&255),wt(a,a.gzhead.time>>24&255),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(wt(a,255&a.gzhead.extra.length),wt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=L(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,3),a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W;if(69===a.status){if(a.gzhead.extra){let e=a.pending,i=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+i>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex+=n,ct(t),0!==a.pending)return a.last_flush=-1,W;e=0,i-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+i),a.pending),a.pending+=i,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(ct(t),0!==a.pending))return a.last_flush=-1,W;wt(a,255&t.adler),wt(a,t.adler>>8&255),t.adler=0}if(a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(0!==t.avail_in||0!==a.lookahead||e!==P&&666!==a.status){let i=0===a.level?kt(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):zt[a.level].func(a,e);if(3!==i&&4!==i||(a.status=666),1===i||3===i)return 0===t.avail_out&&(a.last_flush=-1),W;if(2===i&&(e===Y?K(a):e!==J&&(H(a,0,0,!1),e===G&&(dt(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),ct(t),0===t.avail_out))return a.last_flush=-1,W}return e!==X?W:a.wrap<=0?q:(2===a.wrap?(wt(a,255&t.adler),wt(a,t.adler>>8&255),wt(a,t.adler>>16&255),wt(a,t.adler>>24&255),wt(a,255&t.total_in),wt(a,t.total_in>>8&255),wt(a,t.total_in>>16&255),wt(a,t.total_in>>24&255)):(mt(a,t.adler>>>16),mt(a,65535&t.adler)),ct(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?W:q)},deflateEnd:t=>{if(Et(t))return Q;const e=t.state.status;return t.state=null,113===e?lt(t,V):W},deflateSetDictionary:(t,e)=>{let a=e.length;if(Et(t))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=ft(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 Dt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ot=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)Dt(a,e)&&(t[e]=a[e])}}return t},Tt=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 Nt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Nt=!1}const Ft=new Uint8Array(256);for(let t=0;t<256;t++)Ft[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ft[254]=Ft[254]=1;var Lt=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},It=(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=Ft[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&&Nt)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)},Bt=(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+Ft[t[a]]>e?a:e};var Ct=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 Ht=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:jt,Z_FULL_FLUSH:Kt,Z_FINISH:Pt,Z_OK:Yt,Z_STREAM_END:Gt,Z_DEFAULT_COMPRESSION:Xt,Z_DEFAULT_STRATEGY:Jt,Z_DEFLATED:Wt}=B;function qt(t){this.options=Ot({level:Xt,method:Wt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Jt},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 Ct,this.strm.avail_out=0;let a=Ut.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==Yt)throw new Error(I[a]);if(e.header&&Ut.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Lt(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Ut.deflateSetDictionary(this.strm,t),a!==Yt)throw new Error(I[a]);this._dict_set=!0}}function Qt(t,e){const a=new qt(e);if(a.push(t,!0),a.err)throw a.msg||I[a.err];return a.result}qt.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?Pt:Mt,"string"==typeof t?a.input=Lt(t):"[object ArrayBuffer]"===Ht.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===jt||s===Kt)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Ut.deflate(a,s),n===Gt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Ut.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Yt;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},qt.prototype.onData=function(t){this.chunks.push(t)},qt.prototype.onEnd=function(t){t===Yt&&(this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Vt={Deflate:qt,deflate:Qt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Qt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Qt(t,e)},constants:B};var $t=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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,m=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=u[f&m];e:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,0===p)A[n++]=65535&g;else{if(!(16&p)){if(0==(64&p)){g=u[(65535&g)+(f&(1<<p)-1)];continue e}if(32&p){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=16209;break t}k=65535&g,p&=15,p&&(c<p&&(f+=z[a++]<<c,c+=8),k+=f&(1<<p)-1,f>>>=p,c-=p),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=w[f&b];a:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,!(16&p)){if(0==(64&p)){g=w[(65535&g)+(f&(1<<p)-1)];continue a}t.msg="invalid distance code",E.mode=16209;break t}if(v=65535&g,p&=15,c<p&&(f+=z[a++]<<c,c+=8,c<p&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<p)-1,v>o){t.msg="invalid distance too far back",E.mode=16209;break t}if(f>>>=p,c-=p,p=n-s,v>p){if(p=v-p,p>h&&E.sane){t.msg="invalid distance too far back",E.mode=16209;break t}if(y=0,x=_,0===d){if(y+=l-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}else if(d<p){if(y+=l+d-p,p-=d,p<k){k-=p;do{A[n++]=_[y++]}while(--p);if(y=0,d<k){p=d,k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}}else if(y+=d-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);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 te=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]),ee=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]),ae=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]),ie=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 ne=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,m=0,b=0,g=0,p=0,k=0,v=0,y=0,x=0,z=0,A=null;const E=new Uint16Array(16),R=new Uint16Array(16);let Z,S,U,D=null;for(w=0;w<=15;w++)E[w]=0;for(m=0;m<i;m++)E[e[a+m]]++;for(p=l,g=15;g>=1&&0===E[g];g--);if(p>g&&(p=g),0===g)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(b=1;b<g&&0===E[b];b++);for(p<b&&(p=b),y=1,w=1;w<=15;w++)if(y<<=1,y-=E[w],y<0)return-1;if(y>0&&(0===t||1!==g))return-1;for(R[1]=0,w=1;w<15;w++)R[w+1]=R[w]+E[w];for(m=0;m<i;m++)0!==e[a+m]&&(r[R[e[a+m]]++]=m);if(0===t?(A=D=r,u=20):1===t?(A=te,D=ee,u=257):(A=ae,D=ie,u=0),z=0,m=0,w=b,c=s,k=p,v=0,_=-1,x=1<<p,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){Z=w-v,r[m]+1<u?(S=0,U=r[m]):r[m]>=u?(S=D[r[m]-u],U=A[r[m]-u]):(S=96,U=0),h=1<<w-v,d=1<<k,b=d;do{d-=h,n[c+(z>>v)+d]=Z<<24|S<<16|U|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,m++,0==--E[w]){if(w===g)break;w=e[a+r[m]]}if(w>p&&(z&f)!==_){for(0===v&&(v=p),c+=b,k=w-v,y=1<<k;k+v<g&&(y-=E[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=p<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=p,0};const{Z_FINISH:se,Z_BLOCK:re,Z_TREES:oe,Z_OK:le,Z_STREAM_END:he,Z_NEED_DICT:de,Z_STREAM_ERROR:_e,Z_DATA_ERROR:fe,Z_MEM_ERROR:ce,Z_BUF_ERROR:ue,Z_DEFLATED:we}=B,me=16209,be=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.strm=null,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 pe=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<16180||e.mode>16211?1:0},ke=t=>{if(pe(t))return _e;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=16180,e.last=0,e.havedict=0,e.flags=-1,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,le},ve=t=>{if(pe(t))return _e;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ke(t)},ye=(t,e)=>{let a;if(pe(t))return _e;const i=t.state;return e<0?(a=0,e=-e):(a=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?_e:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,ve(t))},xe=(t,e)=>{if(!t)return _e;const a=new ge;t.state=a,a.strm=t,a.window=null,a.mode=16180;const i=ye(t,e);return i!==le&&(t.state=null),i};let ze,Ae,Ee=!0;const Re=t=>{if(Ee){ze=new Int32Array(512),Ae=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(ne(1,t.lens,0,288,ze,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ne(2,t.lens,0,32,Ae,0,t.work,{bits:5}),Ee=!1}t.lencode=ze,t.lenbits=9,t.distcode=Ae,t.distbits=5},Ze=(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 Se={inflateReset:ve,inflateReset2:ye,inflateResetKeep:ke,inflateInit:t=>xe(t,15),inflateInit2:xe,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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(pe(t)||!t.output||!t.input&&0!==t.avail_in)return _e;a=t.state,16191===a.mode&&(a.mode=16192),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=le;t:for(;;)switch(a.mode){case 16180:if(0===a.wrap){a.mode=16192;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){0===a.wbits&&(a.wbits=15),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=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=me;break}if((15&h)!==we){t.msg="unknown compression method",a.mode=me;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits&&(a.wbits=y),y>15||y>a.wbits){t.msg="invalid window size",a.mode=me;break}a.dmax=1<<a.wbits,a.flags=0,t.adler=a.check=1,a.mode=512&h?16189:16191,h=0,d=0;break;case 16181:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==we){t.msg="unknown compression method",a.mode=me;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=me;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16182;case 16182:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&4&a.wrap&&(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=16183;case 16183: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&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16184;case 16184: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&&4&a.wrap&&(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=16185;case 16185: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=16186;case 16186: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&&4&a.wrap&&(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=16187;case 16187: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=me;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=16191;break;case 16189:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=be(h),h=0,d=0,a.mode=16190;case 16190: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,de;t.adler=a.check=1,a.mode=16191;case 16191:if(e===re||e===oe)break t;case 16192:if(a.last){h>>>=7&d,d-=7&d,a.mode=16206;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=16193;break;case 1:if(Re(a),a.mode=16199,e===oe){h>>>=2,d-=2;break t}break;case 2:a.mode=16196;break;case 3:t.msg="invalid block type",a.mode=me}h>>>=2,d-=2;break;case 16193: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=me;break}if(a.length=65535&h,h=0,d=0,a.mode=16194,e===oe)break t;case 16194:a.mode=16195;case 16195: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=16191;break;case 16196: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=me;break}a.have=0,a.mode=16197;case 16197: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=ne(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=me;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g<16)h>>>=m,d-=m,a.lens[a.have++]=g;else{if(16===g){for(R=m+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=m,d-=m,0===a.have){t.msg="invalid bit length repeat",a.mode=me;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===g){for(R=m+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=m+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,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=me;break}for(;c--;)a.lens[a.have++]=y}}if(a.mode===me)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=me;break}if(a.lenbits=9,E={bits:a.lenbits},x=ne(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=me;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=ne(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=me;break}if(a.mode=16199,e===oe)break t;case 16199:a.mode=16200;case 16200: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,$t(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,16191===a.mode&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(b&&0==(240&b)){for(p=m,k=b,v=g;z=a.lencode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,a.length=g,0===b){a.mode=16205;break}if(32&b){a.back=-1,a.mode=16191;break}if(64&b){t.msg="invalid literal/length code",a.mode=me;break}a.extra=15&b,a.mode=16201;case 16201: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=16202;case 16202:for(;z=a.distcode[h&(1<<a.distbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&b)){for(p=m,k=b,v=g;z=a.distcode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,64&b){t.msg="invalid distance code",a.mode=me;break}a.offset=g,a.extra=15&b,a.mode=16203;case 16203: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=me;break}a.mode=16204;case 16204: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=me;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=16200);break;case 16205:if(0===l)break t;n[r++]=a.length,l--,a.mode=16200;break;case 16206: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,4&a.wrap&&f&&(t.adler=a.check=a.flags?L(a.check,n,f,r-f):N(a.check,n,f,r-f)),f=l,4&a.wrap&&(a.flags?h:be(h))!==a.check){t.msg="incorrect data check",a.mode=me;break}h=0,d=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=me;break}h=0,d=0}a.mode=16208;case 16208:x=he;break t;case me:x=fe;break t;case 16210:return ce;default:return _e}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<me&&(a.mode<16206||e!==se))&&Ze(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,4&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)+(16191===a.mode?128:0)+(16199===a.mode||16194===a.mode?256:0),(0===_&&0===f||e===se)&&x===le&&(x=ue),x},inflateEnd:t=>{if(pe(t))return _e;let e=t.state;return e.window&&(e.window=null),t.state=null,le},inflateGetHeader:(t,e)=>{if(pe(t))return _e;const a=t.state;return 0==(2&a.wrap)?_e:(a.head=e,e.done=!1,le)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return pe(t)?_e:(i=t.state,0!==i.wrap&&16190!==i.mode?_e:16190===i.mode&&(n=1,n=N(n,e,a,0),n!==i.check)?fe:(s=Ze(t,e,a,a),s?(i.mode=16210,ce):(i.havedict=1,le)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ue=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 De=Object.prototype.toString,{Z_NO_FLUSH:Oe,Z_FINISH:Te,Z_OK:Ne,Z_STREAM_END:Fe,Z_NEED_DICT:Le,Z_STREAM_ERROR:Ie,Z_DATA_ERROR:Be,Z_MEM_ERROR:Ce}=B;function He(t){this.options=Ot({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 Ct,this.strm.avail_out=0;let a=Se.inflateInit2(this.strm,e.windowBits);if(a!==Ne)throw new Error(I[a]);if(this.header=new Ue,Se.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Lt(e.dictionary):"[object ArrayBuffer]"===De.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=Se.inflateSetDictionary(this.strm,e.dictionary),a!==Ne)))throw new Error(I[a])}He.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?Te:Oe,"[object ArrayBuffer]"===De.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=Se.inflate(a,r),s===Le&&n&&(s=Se.inflateSetDictionary(a,n),s===Ne?s=Se.inflate(a,r):s===Be&&(s=Le));a.avail_in>0&&s===Fe&&a.state.wrap>0&&0!==t[a.next_in];)Se.inflateReset(a),s=Se.inflate(a,r);switch(s){case Ie:case Be:case Le:case Ce:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===Fe))if("string"===this.options.to){let t=Bt(a.output,a.next_out),e=a.next_out-t,n=It(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!==Ne||0!==o){if(s===Fe)return s=Se.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},He.prototype.onData=function(t){this.chunks.push(t)},He.prototype.onEnd=function(t){t===Ne&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const{Deflate:Me,deflate:je,deflateRaw:Ke,gzip:Pe}=Vt;var Ye=Me,Ge=B;const Xe=new class{constructor(){this.added=0,this.init()}init(){this.added=0,this.deflate=new Ye,this.deflate.push("[",Ge.Z_NO_FLUSH)}addEvent(t){if(!t)throw new Error("Adding invalid event");const e=this.added>0?",":"";this.deflate.push(e+JSON.stringify(t),Ge.Z_SYNC_FLUSH),this.added++}finish(){if(this.deflate.push("]",Ge.Z_FINISH),this.deflate.err)throw this.deflate.err;const t=this.deflate.result;return this.init(),t}},Je={init:()=>(Xe.init(),""),addEvent:t=>Xe.addEvent(t),finish:()=>Xe.finish()};addEventListener("message",(function(t){const e=t.data.method,a=t.data.id,[i]=t.data.args?JSON.parse(t.data.args):[];if(e in Je&&"function"==typeof Je[e])try{const t=Je[e](i);postMessage({id:a,method:e,success:!0,response:t})}catch(t){postMessage({id:a,method:e,success:!1,response:t.message}),console.error(t)}})),postMessage({id:void 0,method:"init",success:!0,response:void 0});`;
|
|
3907
|
+
if (stickySession) {
|
|
3908
|
+
saveSession(session);
|
|
3909
|
+
}
|
|
3910
|
+
|
|
3911
|
+
return session;
|
|
3912
|
+
}
|
|
3875
3913
|
|
|
3876
3914
|
/**
|
|
3877
|
-
*
|
|
3915
|
+
* Fetches a session from storage
|
|
3878
3916
|
*/
|
|
3879
|
-
function
|
|
3880
|
-
|
|
3881
|
-
if (useCompression && window.Worker) {
|
|
3882
|
-
const workerBlob = new Blob([workerString]);
|
|
3883
|
-
const workerUrl = URL.createObjectURL(workerBlob);
|
|
3917
|
+
function fetchSession() {
|
|
3918
|
+
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
3884
3919
|
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
return new EventBufferProxy(worker);
|
|
3920
|
+
if (!hasSessionStorage) {
|
|
3921
|
+
return null;
|
|
3888
3922
|
}
|
|
3889
3923
|
|
|
3890
|
-
|
|
3891
|
-
|
|
3924
|
+
try {
|
|
3925
|
+
// This can throw if cookies are disabled
|
|
3926
|
+
const sessionStringFromStorage = WINDOW.sessionStorage.getItem(REPLAY_SESSION_KEY);
|
|
3927
|
+
|
|
3928
|
+
if (!sessionStringFromStorage) {
|
|
3929
|
+
return null;
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
const sessionObj = JSON.parse(sessionStringFromStorage) ;
|
|
3933
|
+
|
|
3934
|
+
return makeSession(sessionObj);
|
|
3935
|
+
} catch (e) {
|
|
3936
|
+
return null;
|
|
3937
|
+
}
|
|
3892
3938
|
}
|
|
3893
3939
|
|
|
3894
3940
|
/**
|
|
3895
|
-
*
|
|
3896
|
-
* This can happen e.g. if the worker cannot be loaded.
|
|
3897
|
-
* Exported only for testing.
|
|
3941
|
+
* Get or create a session
|
|
3898
3942
|
*/
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3943
|
+
function getSession({
|
|
3944
|
+
expiry,
|
|
3945
|
+
currentSession,
|
|
3946
|
+
stickySession,
|
|
3947
|
+
sessionSampleRate,
|
|
3948
|
+
errorSampleRate,
|
|
3949
|
+
}) {
|
|
3950
|
+
// If session exists and is passed, use it instead of always hitting session storage
|
|
3951
|
+
const session = currentSession || (stickySession && fetchSession());
|
|
3905
3952
|
|
|
3906
|
-
|
|
3907
|
-
|
|
3953
|
+
if (session) {
|
|
3954
|
+
// If there is a session, check if it is valid (e.g. "last activity" time
|
|
3955
|
+
// should be within the "session idle time", and "session started" time is
|
|
3956
|
+
// within "max session time").
|
|
3957
|
+
const isExpired = isSessionExpired(session, expiry);
|
|
3908
3958
|
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3959
|
+
if (!isExpired) {
|
|
3960
|
+
return { type: 'saved', session };
|
|
3961
|
+
} else {
|
|
3962
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Session has expired');
|
|
3963
|
+
}
|
|
3964
|
+
// Otherwise continue to create a new session
|
|
3912
3965
|
}
|
|
3913
3966
|
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3967
|
+
const newSession = createSession({
|
|
3968
|
+
stickySession,
|
|
3969
|
+
sessionSampleRate,
|
|
3970
|
+
errorSampleRate,
|
|
3971
|
+
});
|
|
3918
3972
|
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
this._fallback.destroy();
|
|
3922
|
-
this._compression.destroy();
|
|
3923
|
-
}
|
|
3973
|
+
return { type: 'new', session: newSession };
|
|
3974
|
+
}
|
|
3924
3975
|
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3976
|
+
/**
|
|
3977
|
+
* Add an event to the event buffer
|
|
3978
|
+
*/
|
|
3979
|
+
async function addEvent(
|
|
3980
|
+
replay,
|
|
3981
|
+
event,
|
|
3982
|
+
isCheckout,
|
|
3983
|
+
) {
|
|
3984
|
+
if (!replay.eventBuffer) {
|
|
3985
|
+
// This implies that `_isEnabled` is false
|
|
3986
|
+
return null;
|
|
3932
3987
|
}
|
|
3933
3988
|
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
return
|
|
3989
|
+
if (replay.isPaused()) {
|
|
3990
|
+
// Do not add to event buffer when recording is paused
|
|
3991
|
+
return null;
|
|
3937
3992
|
}
|
|
3938
3993
|
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
} catch (error) {
|
|
3944
|
-
// If the worker fails to load, we fall back to the simple buffer.
|
|
3945
|
-
// Nothing more to do from our side here
|
|
3946
|
-
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Failed to load the compression worker, falling back to simple buffer');
|
|
3947
|
-
return;
|
|
3948
|
-
}
|
|
3949
|
-
|
|
3950
|
-
// Compression worker is ready, we can use it
|
|
3951
|
-
// Now we need to switch over the array buffer to the compression worker
|
|
3952
|
-
const addEventPromises = [];
|
|
3953
|
-
for (const event of this._fallback.pendingEvents) {
|
|
3954
|
-
addEventPromises.push(this._compression.addEvent(event));
|
|
3955
|
-
}
|
|
3994
|
+
// TODO: sadness -- we will want to normalize timestamps to be in ms -
|
|
3995
|
+
// requires coordination with frontend
|
|
3996
|
+
const isMs = event.timestamp > 9999999999;
|
|
3997
|
+
const timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
|
|
3956
3998
|
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3999
|
+
// Throw out events that happen more than 5 minutes ago. This can happen if
|
|
4000
|
+
// page has been left open and idle for a long period of time and user
|
|
4001
|
+
// comes back to trigger a new session. The performance entries rely on
|
|
4002
|
+
// `performance.timeOrigin`, which is when the page first opened.
|
|
4003
|
+
if (timestampInMs + SESSION_IDLE_DURATION < new Date().getTime()) {
|
|
4004
|
+
return null;
|
|
4005
|
+
}
|
|
3960
4006
|
|
|
3961
|
-
|
|
3962
|
-
|
|
4007
|
+
// Only record earliest event if a new session was created, otherwise it
|
|
4008
|
+
// shouldn't be relevant
|
|
4009
|
+
const earliestEvent = replay.getContext().earliestEvent;
|
|
4010
|
+
if (replay.session && replay.session.segmentId === 0 && (!earliestEvent || timestampInMs < earliestEvent)) {
|
|
4011
|
+
replay.getContext().earliestEvent = timestampInMs;
|
|
3963
4012
|
}
|
|
4013
|
+
|
|
4014
|
+
return replay.eventBuffer.addEvent(event, isCheckout);
|
|
3964
4015
|
}
|
|
3965
4016
|
|
|
3966
|
-
|
|
4017
|
+
/**
|
|
4018
|
+
* Create a breadcrumb for a replay.
|
|
4019
|
+
*/
|
|
4020
|
+
function createBreadcrumb(
|
|
4021
|
+
breadcrumb,
|
|
4022
|
+
) {
|
|
4023
|
+
return {
|
|
4024
|
+
timestamp: new Date().getTime() / 1000,
|
|
4025
|
+
type: 'default',
|
|
4026
|
+
...breadcrumb,
|
|
4027
|
+
};
|
|
4028
|
+
}
|
|
3967
4029
|
|
|
3968
|
-
|
|
3969
|
-
|
|
4030
|
+
/**
|
|
4031
|
+
* Add a breadcrumb event to replay.
|
|
4032
|
+
*/
|
|
4033
|
+
function addBreadcrumbEvent(replay, breadcrumb) {
|
|
4034
|
+
if (breadcrumb.category === 'sentry.transaction') {
|
|
4035
|
+
return;
|
|
3970
4036
|
}
|
|
3971
4037
|
|
|
3972
|
-
|
|
3973
|
-
|
|
4038
|
+
if (breadcrumb.category === 'ui.click') {
|
|
4039
|
+
replay.triggerUserActivity();
|
|
4040
|
+
} else {
|
|
4041
|
+
replay.checkAndHandleExpiredSession();
|
|
3974
4042
|
}
|
|
3975
4043
|
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4044
|
+
replay.addUpdate(() => {
|
|
4045
|
+
void addEvent(replay, {
|
|
4046
|
+
type: EventType.Custom,
|
|
4047
|
+
// TODO: We were converting from ms to seconds for breadcrumbs, spans,
|
|
4048
|
+
// but maybe we should just keep them as milliseconds
|
|
4049
|
+
timestamp: (breadcrumb.timestamp || 0) * 1000,
|
|
4050
|
+
data: {
|
|
4051
|
+
tag: 'breadcrumb',
|
|
4052
|
+
payload: breadcrumb,
|
|
4053
|
+
},
|
|
4054
|
+
});
|
|
3983
4055
|
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
}
|
|
4056
|
+
// Do not flush after console log messages
|
|
4057
|
+
return breadcrumb.category === 'console';
|
|
4058
|
+
});
|
|
4059
|
+
}
|
|
3987
4060
|
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
4061
|
+
const handleDomListener =
|
|
4062
|
+
(replay) =>
|
|
4063
|
+
(handlerData) => {
|
|
4064
|
+
if (!replay.isEnabled()) {
|
|
3991
4065
|
return;
|
|
3992
4066
|
}
|
|
3993
4067
|
|
|
3994
|
-
|
|
3995
|
-
return;
|
|
3996
|
-
}
|
|
4068
|
+
const result = handleDom(handlerData);
|
|
3997
4069
|
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
this._events = [];
|
|
4005
|
-
resolve(JSON.stringify(eventsRet));
|
|
4006
|
-
});
|
|
4007
|
-
}
|
|
4008
|
-
}
|
|
4070
|
+
if (!result) {
|
|
4071
|
+
return;
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
addBreadcrumbEvent(replay, result);
|
|
4075
|
+
};
|
|
4009
4076
|
|
|
4010
4077
|
/**
|
|
4011
|
-
*
|
|
4012
|
-
* Exported only for testing.
|
|
4078
|
+
* An event handler to react to DOM events.
|
|
4013
4079
|
*/
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
* `finish()` (and thus the flush), does not complete.
|
|
4019
|
-
*/
|
|
4020
|
-
__init() {this._pendingEvents = [];}
|
|
4021
|
-
|
|
4022
|
-
__init2() {this._eventBufferItemLength = 0;}
|
|
4023
|
-
__init3() {this._id = 0;}
|
|
4080
|
+
function handleDom(handlerData) {
|
|
4081
|
+
// Taken from https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L112
|
|
4082
|
+
let target;
|
|
4083
|
+
let targetNode;
|
|
4024
4084
|
|
|
4025
|
-
|
|
4026
|
-
|
|
4085
|
+
// Accessing event.target can throw (see getsentry/raven-js#838, #768)
|
|
4086
|
+
try {
|
|
4087
|
+
targetNode = getTargetNode(handlerData);
|
|
4088
|
+
target = htmlTreeAsString(targetNode);
|
|
4089
|
+
} catch (e) {
|
|
4090
|
+
target = '<unknown>';
|
|
4027
4091
|
}
|
|
4028
4092
|
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
* the number of events that have been compresed in the worker because
|
|
4032
|
-
* `addEvent` is async.
|
|
4033
|
-
*/
|
|
4034
|
-
get pendingLength() {
|
|
4035
|
-
return this._eventBufferItemLength;
|
|
4093
|
+
if (target.length === 0) {
|
|
4094
|
+
return null;
|
|
4036
4095
|
}
|
|
4037
4096
|
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4097
|
+
return createBreadcrumb({
|
|
4098
|
+
category: `ui.${handlerData.name}`,
|
|
4099
|
+
message: target,
|
|
4100
|
+
data: {
|
|
4101
|
+
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
4102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4103
|
+
...(targetNode ? { nodeId: record.mirror.getId(targetNode ) } : {}),
|
|
4104
|
+
},
|
|
4105
|
+
});
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
function getTargetNode(handlerData) {
|
|
4109
|
+
if (isEventWithTarget(handlerData.event)) {
|
|
4110
|
+
return handlerData.event.target;
|
|
4043
4111
|
}
|
|
4044
4112
|
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
* This will either resolve when the worker is ready, or reject if an error occured.
|
|
4048
|
-
*/
|
|
4049
|
-
ensureReady() {
|
|
4050
|
-
return new Promise((resolve, reject) => {
|
|
4051
|
-
this._worker.addEventListener(
|
|
4052
|
-
'message',
|
|
4053
|
-
({ data }) => {
|
|
4054
|
-
if (data.success) {
|
|
4055
|
-
resolve();
|
|
4056
|
-
} else {
|
|
4057
|
-
reject();
|
|
4058
|
-
}
|
|
4059
|
-
},
|
|
4060
|
-
{ once: true },
|
|
4061
|
-
);
|
|
4113
|
+
return handlerData.event;
|
|
4114
|
+
}
|
|
4062
4115
|
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4116
|
+
function isEventWithTarget(event) {
|
|
4117
|
+
return !!(event ).target;
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
/**
|
|
4121
|
+
* Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
|
|
4122
|
+
*/
|
|
4123
|
+
function createPerformanceSpans(
|
|
4124
|
+
replay,
|
|
4125
|
+
entries,
|
|
4126
|
+
) {
|
|
4127
|
+
return entries.map(({ type, start, end, name, data }) =>
|
|
4128
|
+
addEvent(replay, {
|
|
4129
|
+
type: EventType.Custom,
|
|
4130
|
+
timestamp: start,
|
|
4131
|
+
data: {
|
|
4132
|
+
tag: 'performanceSpan',
|
|
4133
|
+
payload: {
|
|
4134
|
+
op: type,
|
|
4135
|
+
description: name,
|
|
4136
|
+
startTimestamp: start,
|
|
4137
|
+
endTimestamp: end,
|
|
4138
|
+
data,
|
|
4067
4139
|
},
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4140
|
+
},
|
|
4141
|
+
}),
|
|
4142
|
+
);
|
|
4143
|
+
}
|
|
4144
|
+
|
|
4145
|
+
/**
|
|
4146
|
+
* Check whether a given request URL should be filtered out.
|
|
4147
|
+
*/
|
|
4148
|
+
function shouldFilterRequest(replay, url) {
|
|
4149
|
+
// If we enabled the `traceInternals` experiment, we want to trace everything
|
|
4150
|
+
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && replay.getOptions()._experiments.traceInternals) {
|
|
4151
|
+
return false;
|
|
4071
4152
|
}
|
|
4072
4153
|
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4154
|
+
return !_isSentryRequest(url);
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4157
|
+
/**
|
|
4158
|
+
* Checks wether a given URL belongs to the configured Sentry DSN.
|
|
4159
|
+
*/
|
|
4160
|
+
function _isSentryRequest(url) {
|
|
4161
|
+
const client = getCurrentHub().getClient();
|
|
4162
|
+
const dsn = client && client.getDsn();
|
|
4163
|
+
return dsn ? url.includes(dsn.host) : false;
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4166
|
+
/** only exported for tests */
|
|
4167
|
+
function handleFetch(handlerData) {
|
|
4168
|
+
if (!handlerData.endTimestamp) {
|
|
4169
|
+
return null;
|
|
4079
4170
|
}
|
|
4080
4171
|
|
|
4081
|
-
|
|
4082
|
-
* Add an event to the event buffer.
|
|
4083
|
-
*
|
|
4084
|
-
* Returns true if event was successfuly received and processed by worker.
|
|
4085
|
-
*/
|
|
4086
|
-
async addEvent(event, isCheckout) {
|
|
4087
|
-
if (isCheckout) {
|
|
4088
|
-
// This event is a checkout, make sure worker buffer is cleared before
|
|
4089
|
-
// proceeding.
|
|
4090
|
-
await this._postMessage({
|
|
4091
|
-
id: this._getAndIncrementId(),
|
|
4092
|
-
method: 'init',
|
|
4093
|
-
args: [],
|
|
4094
|
-
});
|
|
4095
|
-
}
|
|
4172
|
+
const { startTimestamp, endTimestamp, fetchData, response } = handlerData;
|
|
4096
4173
|
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4174
|
+
return {
|
|
4175
|
+
type: 'resource.fetch',
|
|
4176
|
+
start: startTimestamp / 1000,
|
|
4177
|
+
end: endTimestamp / 1000,
|
|
4178
|
+
name: fetchData.url,
|
|
4179
|
+
data: {
|
|
4180
|
+
method: fetchData.method,
|
|
4181
|
+
statusCode: response.status,
|
|
4182
|
+
},
|
|
4183
|
+
};
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
/**
|
|
4187
|
+
* Returns a listener to be added to `addInstrumentationHandler('fetch', listener)`.
|
|
4188
|
+
*/
|
|
4189
|
+
function handleFetchSpanListener(replay) {
|
|
4190
|
+
return (handlerData) => {
|
|
4191
|
+
if (!replay.isEnabled()) {
|
|
4192
|
+
return;
|
|
4100
4193
|
}
|
|
4101
4194
|
|
|
4102
|
-
|
|
4103
|
-
}
|
|
4195
|
+
const result = handleFetch(handlerData);
|
|
4104
4196
|
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
finish() {
|
|
4109
|
-
return this._finishRequest(this._getAndIncrementId());
|
|
4110
|
-
}
|
|
4197
|
+
if (result === null) {
|
|
4198
|
+
return;
|
|
4199
|
+
}
|
|
4111
4200
|
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
_postMessage({ id, method, args }) {
|
|
4116
|
-
return new Promise((resolve, reject) => {
|
|
4117
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
4118
|
-
const listener = ({ data }) => {
|
|
4119
|
-
if (data.method !== method) {
|
|
4120
|
-
return;
|
|
4121
|
-
}
|
|
4201
|
+
if (shouldFilterRequest(replay, result.name)) {
|
|
4202
|
+
return;
|
|
4203
|
+
}
|
|
4122
4204
|
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4205
|
+
replay.addUpdate(() => {
|
|
4206
|
+
createPerformanceSpans(replay, [result]);
|
|
4207
|
+
// Returning true will cause `addUpdate` to not flush
|
|
4208
|
+
// We do not want network requests to cause a flush. This will prevent
|
|
4209
|
+
// recurring/polling requests from keeping the replay session alive.
|
|
4210
|
+
return true;
|
|
4211
|
+
});
|
|
4212
|
+
};
|
|
4213
|
+
}
|
|
4128
4214
|
|
|
4129
|
-
|
|
4130
|
-
|
|
4215
|
+
/**
|
|
4216
|
+
* Returns true if we think the given event is an error originating inside of rrweb.
|
|
4217
|
+
*/
|
|
4218
|
+
function isRrwebError(event) {
|
|
4219
|
+
if (event.type || !event.exception || !event.exception.values || !event.exception.values.length) {
|
|
4220
|
+
return false;
|
|
4221
|
+
}
|
|
4131
4222
|
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4223
|
+
// Check if any exception originates from rrweb
|
|
4224
|
+
return event.exception.values.some(exception => {
|
|
4225
|
+
if (!exception.stacktrace || !exception.stacktrace.frames || !exception.stacktrace.frames.length) {
|
|
4226
|
+
return false;
|
|
4227
|
+
}
|
|
4135
4228
|
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4229
|
+
return exception.stacktrace.frames.some(frame => frame.filename && frame.filename.includes('/rrweb/src/'));
|
|
4230
|
+
});
|
|
4231
|
+
}
|
|
4139
4232
|
|
|
4140
|
-
|
|
4141
|
-
|
|
4233
|
+
/**
|
|
4234
|
+
* Returns a listener to be added to `addGlobalEventProcessor(listener)`.
|
|
4235
|
+
*/
|
|
4236
|
+
function handleGlobalEventListener(replay) {
|
|
4237
|
+
return (event) => {
|
|
4238
|
+
// Do not apply replayId to the root event
|
|
4239
|
+
if (event.type === REPLAY_EVENT_NAME) {
|
|
4240
|
+
// Replays have separate set of breadcrumbs, do not include breadcrumbs
|
|
4241
|
+
// from core SDK
|
|
4242
|
+
delete event.breadcrumbs;
|
|
4243
|
+
return event;
|
|
4244
|
+
}
|
|
4142
4245
|
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
}
|
|
4246
|
+
// Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
|
|
4247
|
+
// As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
|
|
4248
|
+
if (isRrwebError(event) && !replay.getOptions()._experiments.captureExceptions) {
|
|
4249
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Ignoring error from rrweb internals', event);
|
|
4250
|
+
return null;
|
|
4251
|
+
}
|
|
4150
4252
|
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
}
|
|
4156
|
-
}
|
|
4253
|
+
// Only tag transactions with replayId if not waiting for an error
|
|
4254
|
+
// @ts-ignore private
|
|
4255
|
+
if (!event.type || replay.recordingMode === 'session') {
|
|
4256
|
+
event.tags = { ...event.tags, replayId: replay.getSessionId() };
|
|
4257
|
+
}
|
|
4157
4258
|
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
method: 'addEvent',
|
|
4165
|
-
args: [event],
|
|
4166
|
-
});
|
|
4259
|
+
// Collect traceIds in _context regardless of `recordingMode` - if it's true,
|
|
4260
|
+
// _context gets cleared on every checkout
|
|
4261
|
+
if (event.type === 'transaction' && event.contexts && event.contexts.trace && event.contexts.trace.trace_id) {
|
|
4262
|
+
replay.getContext().traceIds.add(event.contexts.trace.trace_id );
|
|
4263
|
+
return event;
|
|
4264
|
+
}
|
|
4167
4265
|
|
|
4168
|
-
//
|
|
4169
|
-
|
|
4266
|
+
// no event type means error
|
|
4267
|
+
if (!event.type) {
|
|
4268
|
+
replay.getContext().errorIds.add(event.event_id );
|
|
4269
|
+
}
|
|
4170
4270
|
|
|
4171
|
-
|
|
4172
|
-
|
|
4271
|
+
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && replay.getOptions()._experiments.traceInternals) {
|
|
4272
|
+
const exc = getEventExceptionValues(event);
|
|
4273
|
+
addInternalBreadcrumb({
|
|
4274
|
+
message: `Tagging event (${event.event_id}) - ${event.message} - ${exc.type}: ${exc.value}`,
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4173
4277
|
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4278
|
+
// Need to be very careful that this does not cause an infinite loop
|
|
4279
|
+
if (
|
|
4280
|
+
replay.recordingMode === 'error' &&
|
|
4281
|
+
event.exception &&
|
|
4282
|
+
event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because otherwise we could loop indefinitely with trying to capture replay and failing
|
|
4283
|
+
) {
|
|
4284
|
+
setTimeout(async () => {
|
|
4285
|
+
// Allow flush to complete before resuming as a session recording, otherwise
|
|
4286
|
+
// the checkout from `startRecording` may be included in the payload.
|
|
4287
|
+
// Prefer to keep the error replay as a separate (and smaller) segment
|
|
4288
|
+
// than the session replay.
|
|
4289
|
+
await replay.flushImmediate();
|
|
4179
4290
|
|
|
4180
|
-
|
|
4181
|
-
|
|
4291
|
+
if (replay.stopRecording()) {
|
|
4292
|
+
// Reset all "capture on error" configuration before
|
|
4293
|
+
// starting a new recording
|
|
4294
|
+
replay.recordingMode = 'session';
|
|
4295
|
+
replay.startRecording();
|
|
4296
|
+
}
|
|
4297
|
+
});
|
|
4298
|
+
}
|
|
4182
4299
|
|
|
4183
|
-
|
|
4300
|
+
return event;
|
|
4301
|
+
};
|
|
4302
|
+
}
|
|
4184
4303
|
|
|
4185
|
-
|
|
4304
|
+
function addInternalBreadcrumb(arg) {
|
|
4305
|
+
const { category, level, message, ...rest } = arg;
|
|
4186
4306
|
|
|
4187
|
-
|
|
4188
|
-
|
|
4307
|
+
addBreadcrumb({
|
|
4308
|
+
category: category || 'console',
|
|
4309
|
+
level: level || 'debug',
|
|
4310
|
+
message: `[debug]: ${message}`,
|
|
4311
|
+
...rest,
|
|
4312
|
+
});
|
|
4313
|
+
}
|
|
4189
4314
|
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4315
|
+
function getEventExceptionValues(event) {
|
|
4316
|
+
return {
|
|
4317
|
+
type: 'Unknown',
|
|
4318
|
+
value: 'n/a',
|
|
4319
|
+
...(event.exception && event.exception.values && event.exception.values[0]),
|
|
4320
|
+
};
|
|
4194
4321
|
}
|
|
4195
4322
|
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
* time should be considered as expired.
|
|
4199
|
-
*/
|
|
4200
|
-
function isExpired(
|
|
4201
|
-
initialTime,
|
|
4202
|
-
expiry,
|
|
4203
|
-
targetTime = +new Date(),
|
|
4204
|
-
) {
|
|
4205
|
-
// Always expired if < 0
|
|
4206
|
-
if (initialTime === null || expiry === undefined || expiry < 0) {
|
|
4207
|
-
return true;
|
|
4208
|
-
}
|
|
4323
|
+
function handleHistory(handlerData) {
|
|
4324
|
+
const { from, to } = handlerData;
|
|
4209
4325
|
|
|
4210
|
-
|
|
4211
|
-
if (expiry === 0) {
|
|
4212
|
-
return false;
|
|
4213
|
-
}
|
|
4326
|
+
const now = new Date().getTime() / 1000;
|
|
4214
4327
|
|
|
4215
|
-
return
|
|
4328
|
+
return {
|
|
4329
|
+
type: 'navigation.push',
|
|
4330
|
+
start: now,
|
|
4331
|
+
end: now,
|
|
4332
|
+
name: to,
|
|
4333
|
+
data: {
|
|
4334
|
+
previous: from,
|
|
4335
|
+
},
|
|
4336
|
+
};
|
|
4216
4337
|
}
|
|
4217
4338
|
|
|
4218
4339
|
/**
|
|
4219
|
-
*
|
|
4340
|
+
* Returns a listener to be added to `addInstrumentationHandler('history', listener)`.
|
|
4220
4341
|
*/
|
|
4221
|
-
function
|
|
4222
|
-
return (
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
// performed an action within the last `idleTimeout` ms)
|
|
4227
|
-
isExpired(session.lastActivity, idleTimeout, targetTime)
|
|
4228
|
-
);
|
|
4229
|
-
}
|
|
4342
|
+
function handleHistorySpanListener(replay) {
|
|
4343
|
+
return (handlerData) => {
|
|
4344
|
+
if (!replay.isEnabled()) {
|
|
4345
|
+
return;
|
|
4346
|
+
}
|
|
4230
4347
|
|
|
4231
|
-
|
|
4232
|
-
* Save a session to session storage.
|
|
4233
|
-
*/
|
|
4234
|
-
function saveSession(session) {
|
|
4235
|
-
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
4236
|
-
if (!hasSessionStorage) {
|
|
4237
|
-
return;
|
|
4238
|
-
}
|
|
4348
|
+
const result = handleHistory(handlerData);
|
|
4239
4349
|
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
// Ignore potential SecurityError exceptions
|
|
4244
|
-
}
|
|
4245
|
-
}
|
|
4350
|
+
if (result === null) {
|
|
4351
|
+
return;
|
|
4352
|
+
}
|
|
4246
4353
|
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
* 1.0 = 100% sampling
|
|
4251
|
-
* 0.0 = 0% sampling
|
|
4252
|
-
*/
|
|
4253
|
-
function isSampled(sampleRate) {
|
|
4254
|
-
if (sampleRate === undefined) {
|
|
4255
|
-
return false;
|
|
4256
|
-
}
|
|
4354
|
+
// Need to collect visited URLs
|
|
4355
|
+
replay.getContext().urls.push(result.name);
|
|
4356
|
+
replay.triggerUserActivity();
|
|
4257
4357
|
|
|
4258
|
-
|
|
4259
|
-
|
|
4358
|
+
replay.addUpdate(() => {
|
|
4359
|
+
createPerformanceSpans(replay, [result]);
|
|
4360
|
+
// Returning false to flush
|
|
4361
|
+
return false;
|
|
4362
|
+
});
|
|
4363
|
+
};
|
|
4260
4364
|
}
|
|
4261
4365
|
|
|
4262
|
-
|
|
4263
|
-
* Get a session with defaults & applied sampling.
|
|
4264
|
-
*/
|
|
4265
|
-
function makeSession(session) {
|
|
4266
|
-
const now = new Date().getTime();
|
|
4267
|
-
const id = session.id || uuid4();
|
|
4268
|
-
// Note that this means we cannot set a started/lastActivity of `0`, but this should not be relevant outside of tests.
|
|
4269
|
-
const started = session.started || now;
|
|
4270
|
-
const lastActivity = session.lastActivity || now;
|
|
4271
|
-
const segmentId = session.segmentId || 0;
|
|
4272
|
-
const sampled = session.sampled;
|
|
4366
|
+
let _LAST_BREADCRUMB = null;
|
|
4273
4367
|
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4368
|
+
const handleScopeListener =
|
|
4369
|
+
(replay) =>
|
|
4370
|
+
(scope) => {
|
|
4371
|
+
if (!replay.isEnabled()) {
|
|
4372
|
+
return;
|
|
4373
|
+
}
|
|
4374
|
+
|
|
4375
|
+
const result = handleScope(scope);
|
|
4376
|
+
|
|
4377
|
+
if (!result) {
|
|
4378
|
+
return;
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
addBreadcrumbEvent(replay, result);
|
|
4280
4382
|
};
|
|
4281
|
-
}
|
|
4282
4383
|
|
|
4283
4384
|
/**
|
|
4284
|
-
*
|
|
4385
|
+
* An event handler to handle scope changes.
|
|
4285
4386
|
*/
|
|
4286
|
-
function
|
|
4287
|
-
|
|
4288
|
-
}
|
|
4387
|
+
function handleScope(scope) {
|
|
4388
|
+
const newBreadcrumb = scope.getLastBreadcrumb();
|
|
4289
4389
|
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
function createSession({ sessionSampleRate, errorSampleRate, stickySession = false }) {
|
|
4296
|
-
const sampled = getSessionSampleType(sessionSampleRate, errorSampleRate);
|
|
4297
|
-
const session = makeSession({
|
|
4298
|
-
sampled,
|
|
4299
|
-
});
|
|
4390
|
+
// Listener can be called when breadcrumbs have not changed, so we store the
|
|
4391
|
+
// reference to the last crumb and only return a crumb if it has changed
|
|
4392
|
+
if (_LAST_BREADCRUMB === newBreadcrumb || !newBreadcrumb) {
|
|
4393
|
+
return null;
|
|
4394
|
+
}
|
|
4300
4395
|
|
|
4301
|
-
|
|
4396
|
+
_LAST_BREADCRUMB = newBreadcrumb;
|
|
4302
4397
|
|
|
4303
|
-
if (
|
|
4304
|
-
|
|
4398
|
+
if (
|
|
4399
|
+
newBreadcrumb.category &&
|
|
4400
|
+
(['fetch', 'xhr', 'sentry.event', 'sentry.transaction'].includes(newBreadcrumb.category) ||
|
|
4401
|
+
newBreadcrumb.category.startsWith('ui.'))
|
|
4402
|
+
) {
|
|
4403
|
+
return null;
|
|
4305
4404
|
}
|
|
4306
4405
|
|
|
4307
|
-
return
|
|
4406
|
+
return createBreadcrumb(newBreadcrumb);
|
|
4308
4407
|
}
|
|
4309
4408
|
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
*/
|
|
4313
|
-
function fetchSession() {
|
|
4314
|
-
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
4409
|
+
// From sentry-javascript
|
|
4410
|
+
// e.g. https://github.com/getsentry/sentry-javascript/blob/c7fc025bf9fa8c073fdb56351808ce53909fbe45/packages/utils/src/instrument.ts#L180
|
|
4315
4411
|
|
|
4316
|
-
|
|
4412
|
+
function handleXhr(handlerData) {
|
|
4413
|
+
if (handlerData.xhr.__sentry_own_request__) {
|
|
4414
|
+
// Taken from sentry-javascript
|
|
4415
|
+
// Only capture non-sentry requests
|
|
4317
4416
|
return null;
|
|
4318
4417
|
}
|
|
4319
4418
|
|
|
4320
|
-
|
|
4321
|
-
//
|
|
4322
|
-
|
|
4419
|
+
if (handlerData.startTimestamp) {
|
|
4420
|
+
// TODO: See if this is still needed
|
|
4421
|
+
handlerData.xhr.__sentry_xhr__ = handlerData.xhr.__sentry_xhr__ || {};
|
|
4422
|
+
handlerData.xhr.__sentry_xhr__.startTimestamp = handlerData.startTimestamp;
|
|
4423
|
+
}
|
|
4323
4424
|
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4425
|
+
if (!handlerData.endTimestamp) {
|
|
4426
|
+
return null;
|
|
4427
|
+
}
|
|
4327
4428
|
|
|
4328
|
-
|
|
4429
|
+
const { method, url, status_code: statusCode } = handlerData.xhr.__sentry_xhr__ || {};
|
|
4329
4430
|
|
|
4330
|
-
|
|
4331
|
-
} catch (e) {
|
|
4431
|
+
if (url === undefined) {
|
|
4332
4432
|
return null;
|
|
4333
4433
|
}
|
|
4434
|
+
|
|
4435
|
+
const timestamp = handlerData.xhr.__sentry_xhr__
|
|
4436
|
+
? handlerData.xhr.__sentry_xhr__.startTimestamp || 0
|
|
4437
|
+
: handlerData.endTimestamp;
|
|
4438
|
+
|
|
4439
|
+
return {
|
|
4440
|
+
type: 'resource.xhr',
|
|
4441
|
+
name: url,
|
|
4442
|
+
start: timestamp / 1000,
|
|
4443
|
+
end: handlerData.endTimestamp / 1000,
|
|
4444
|
+
data: {
|
|
4445
|
+
method,
|
|
4446
|
+
statusCode,
|
|
4447
|
+
},
|
|
4448
|
+
};
|
|
4334
4449
|
}
|
|
4335
4450
|
|
|
4336
4451
|
/**
|
|
4337
|
-
*
|
|
4452
|
+
* Returns a listener to be added to `addInstrumentationHandler('xhr', listener)`.
|
|
4338
4453
|
*/
|
|
4339
|
-
function
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
errorSampleRate,
|
|
4345
|
-
}) {
|
|
4346
|
-
// If session exists and is passed, use it instead of always hitting session storage
|
|
4347
|
-
const session = currentSession || (stickySession && fetchSession());
|
|
4454
|
+
function handleXhrSpanListener(replay) {
|
|
4455
|
+
return (handlerData) => {
|
|
4456
|
+
if (!replay.isEnabled()) {
|
|
4457
|
+
return;
|
|
4458
|
+
}
|
|
4348
4459
|
|
|
4349
|
-
|
|
4350
|
-
// If there is a session, check if it is valid (e.g. "last activity" time
|
|
4351
|
-
// should be within the "session idle time", and "session started" time is
|
|
4352
|
-
// within "max session time").
|
|
4353
|
-
const isExpired = isSessionExpired(session, expiry);
|
|
4460
|
+
const result = handleXhr(handlerData);
|
|
4354
4461
|
|
|
4355
|
-
if (
|
|
4356
|
-
return
|
|
4357
|
-
} else {
|
|
4358
|
-
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Session has expired');
|
|
4462
|
+
if (result === null) {
|
|
4463
|
+
return;
|
|
4359
4464
|
}
|
|
4360
|
-
// Otherwise continue to create a new session
|
|
4361
|
-
}
|
|
4362
4465
|
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
errorSampleRate,
|
|
4367
|
-
});
|
|
4466
|
+
if (shouldFilterRequest(replay, result.name)) {
|
|
4467
|
+
return;
|
|
4468
|
+
}
|
|
4368
4469
|
|
|
4369
|
-
|
|
4470
|
+
replay.addUpdate(() => {
|
|
4471
|
+
createPerformanceSpans(replay, [result]);
|
|
4472
|
+
// Returning true will cause `addUpdate` to not flush
|
|
4473
|
+
// We do not want network requests to cause a flush. This will prevent
|
|
4474
|
+
// recurring/polling requests from keeping the replay session alive.
|
|
4475
|
+
return true;
|
|
4476
|
+
});
|
|
4477
|
+
};
|
|
4478
|
+
}
|
|
4479
|
+
|
|
4480
|
+
/**
|
|
4481
|
+
* Add global listeners that cannot be removed.
|
|
4482
|
+
*/
|
|
4483
|
+
function addGlobalListeners(replay) {
|
|
4484
|
+
// Listeners from core SDK //
|
|
4485
|
+
const scope = getCurrentHub().getScope();
|
|
4486
|
+
if (scope) {
|
|
4487
|
+
scope.addScopeListener(handleScopeListener(replay));
|
|
4488
|
+
}
|
|
4489
|
+
addInstrumentationHandler('dom', handleDomListener(replay));
|
|
4490
|
+
addInstrumentationHandler('fetch', handleFetchSpanListener(replay));
|
|
4491
|
+
addInstrumentationHandler('xhr', handleXhrSpanListener(replay));
|
|
4492
|
+
addInstrumentationHandler('history', handleHistorySpanListener(replay));
|
|
4493
|
+
|
|
4494
|
+
// Tag all (non replay) events that get sent to Sentry with the current
|
|
4495
|
+
// replay ID so that we can reference them later in the UI
|
|
4496
|
+
addGlobalEventProcessor(handleGlobalEventListener(replay));
|
|
4370
4497
|
}
|
|
4371
4498
|
|
|
4372
4499
|
/**
|
|
@@ -4993,7 +5120,7 @@ class ReplayContainer {
|
|
|
4993
5120
|
recordingOptions,
|
|
4994
5121
|
}
|
|
4995
5122
|
|
|
4996
|
-
) {ReplayContainer.prototype.__init.call(this);ReplayContainer.prototype.__init2.call(this);ReplayContainer.prototype.__init3.call(this);ReplayContainer.prototype.__init4.call(this);ReplayContainer.prototype.__init5.call(this);ReplayContainer.prototype.__init6.call(this);ReplayContainer.prototype.__init7.call(this);ReplayContainer.prototype.__init8.call(this);ReplayContainer.prototype.__init9.call(this);ReplayContainer.prototype.__init10.call(this);ReplayContainer.prototype.__init11.call(this);ReplayContainer.prototype.__init12.call(this);ReplayContainer.prototype.__init13.call(this);ReplayContainer.prototype.__init14.call(this);ReplayContainer.prototype.__init15.call(this);ReplayContainer.prototype.__init16.call(this);
|
|
5123
|
+
) {ReplayContainer.prototype.__init.call(this);ReplayContainer.prototype.__init2.call(this);ReplayContainer.prototype.__init3.call(this);ReplayContainer.prototype.__init4.call(this);ReplayContainer.prototype.__init5.call(this);ReplayContainer.prototype.__init6.call(this);ReplayContainer.prototype.__init7.call(this);ReplayContainer.prototype.__init8.call(this);ReplayContainer.prototype.__init9.call(this);ReplayContainer.prototype.__init10.call(this);ReplayContainer.prototype.__init11.call(this);ReplayContainer.prototype.__init12.call(this);ReplayContainer.prototype.__init13.call(this);ReplayContainer.prototype.__init14.call(this);ReplayContainer.prototype.__init15.call(this);ReplayContainer.prototype.__init16.call(this);
|
|
4997
5124
|
this._recordingOptions = recordingOptions;
|
|
4998
5125
|
this._options = options;
|
|
4999
5126
|
|
|
@@ -5091,12 +5218,18 @@ class ReplayContainer {
|
|
|
5091
5218
|
* Returns true if it was stopped, else false.
|
|
5092
5219
|
*/
|
|
5093
5220
|
stopRecording() {
|
|
5094
|
-
|
|
5095
|
-
this._stopRecording
|
|
5096
|
-
|
|
5097
|
-
|
|
5221
|
+
try {
|
|
5222
|
+
if (this._stopRecording) {
|
|
5223
|
+
this._stopRecording();
|
|
5224
|
+
this._stopRecording = undefined;
|
|
5225
|
+
return true;
|
|
5226
|
+
}
|
|
5098
5227
|
|
|
5099
|
-
|
|
5228
|
+
return false;
|
|
5229
|
+
} catch (err) {
|
|
5230
|
+
this._handleException(err);
|
|
5231
|
+
return false;
|
|
5232
|
+
}
|
|
5100
5233
|
}
|
|
5101
5234
|
|
|
5102
5235
|
/**
|
|
@@ -5108,7 +5241,7 @@ class ReplayContainer {
|
|
|
5108
5241
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Stopping Replays');
|
|
5109
5242
|
this._isEnabled = false;
|
|
5110
5243
|
this._removeListeners();
|
|
5111
|
-
this.
|
|
5244
|
+
this.stopRecording();
|
|
5112
5245
|
this.eventBuffer && this.eventBuffer.destroy();
|
|
5113
5246
|
this.eventBuffer = null;
|
|
5114
5247
|
this._debouncedFlush.cancel();
|
|
@@ -5124,14 +5257,7 @@ class ReplayContainer {
|
|
|
5124
5257
|
*/
|
|
5125
5258
|
pause() {
|
|
5126
5259
|
this._isPaused = true;
|
|
5127
|
-
|
|
5128
|
-
if (this._stopRecording) {
|
|
5129
|
-
this._stopRecording();
|
|
5130
|
-
this._stopRecording = undefined;
|
|
5131
|
-
}
|
|
5132
|
-
} catch (err) {
|
|
5133
|
-
this._handleException(err);
|
|
5134
|
-
}
|
|
5260
|
+
this.stopRecording();
|
|
5135
5261
|
}
|
|
5136
5262
|
|
|
5137
5263
|
/**
|
|
@@ -5195,7 +5321,7 @@ class ReplayContainer {
|
|
|
5195
5321
|
}
|
|
5196
5322
|
|
|
5197
5323
|
// Otherwise... recording was never suspended, continue as normalish
|
|
5198
|
-
this.
|
|
5324
|
+
this.checkAndHandleExpiredSession();
|
|
5199
5325
|
|
|
5200
5326
|
this._updateSessionActivity();
|
|
5201
5327
|
}
|
|
@@ -5217,6 +5343,44 @@ class ReplayContainer {
|
|
|
5217
5343
|
return this.session && this.session.id;
|
|
5218
5344
|
}
|
|
5219
5345
|
|
|
5346
|
+
/**
|
|
5347
|
+
* Checks if recording should be stopped due to user inactivity. Otherwise
|
|
5348
|
+
* check if session is expired and create a new session if so. Triggers a new
|
|
5349
|
+
* full snapshot on new session.
|
|
5350
|
+
*
|
|
5351
|
+
* Returns true if session is not expired, false otherwise.
|
|
5352
|
+
* @hidden
|
|
5353
|
+
*/
|
|
5354
|
+
checkAndHandleExpiredSession({ expiry = SESSION_IDLE_DURATION } = {}) {
|
|
5355
|
+
const oldSessionId = this.getSessionId();
|
|
5356
|
+
|
|
5357
|
+
// Prevent starting a new session if the last user activity is older than
|
|
5358
|
+
// MAX_SESSION_LIFE. Otherwise non-user activity can trigger a new
|
|
5359
|
+
// session+recording. This creates noisy replays that do not have much
|
|
5360
|
+
// content in them.
|
|
5361
|
+
if (this._lastActivity && isExpired(this._lastActivity, MAX_SESSION_LIFE)) {
|
|
5362
|
+
// Pause recording
|
|
5363
|
+
this.pause();
|
|
5364
|
+
return;
|
|
5365
|
+
}
|
|
5366
|
+
|
|
5367
|
+
// --- There is recent user activity --- //
|
|
5368
|
+
// This will create a new session if expired, based on expiry length
|
|
5369
|
+
this._loadSession({ expiry });
|
|
5370
|
+
|
|
5371
|
+
// Session was expired if session ids do not match
|
|
5372
|
+
const expired = oldSessionId !== this.getSessionId();
|
|
5373
|
+
|
|
5374
|
+
if (!expired) {
|
|
5375
|
+
return true;
|
|
5376
|
+
}
|
|
5377
|
+
|
|
5378
|
+
// Session is expired, trigger a full snapshot (which will create a new session)
|
|
5379
|
+
this._triggerFullSnapshot();
|
|
5380
|
+
|
|
5381
|
+
return false;
|
|
5382
|
+
}
|
|
5383
|
+
|
|
5220
5384
|
/** A wrapper to conditionally capture exceptions. */
|
|
5221
5385
|
_handleException(error) {
|
|
5222
5386
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('[Replay]', error);
|
|
@@ -5286,19 +5450,7 @@ class ReplayContainer {
|
|
|
5286
5450
|
|
|
5287
5451
|
// There is no way to remove these listeners, so ensure they are only added once
|
|
5288
5452
|
if (!this._hasInitializedCoreListeners) {
|
|
5289
|
-
|
|
5290
|
-
const scope = getCurrentHub().getScope();
|
|
5291
|
-
if (scope) {
|
|
5292
|
-
scope.addScopeListener(this._handleCoreBreadcrumbListener('scope'));
|
|
5293
|
-
}
|
|
5294
|
-
addInstrumentationHandler('dom', this._handleCoreBreadcrumbListener('dom'));
|
|
5295
|
-
addInstrumentationHandler('fetch', handleFetchSpanListener(this));
|
|
5296
|
-
addInstrumentationHandler('xhr', handleXhrSpanListener(this));
|
|
5297
|
-
addInstrumentationHandler('history', handleHistorySpanListener(this));
|
|
5298
|
-
|
|
5299
|
-
// Tag all (non replay) events that get sent to Sentry with the current
|
|
5300
|
-
// replay ID so that we can reference them later in the UI
|
|
5301
|
-
addGlobalEventProcessor(handleGlobalEventListener(this));
|
|
5453
|
+
addGlobalListeners(this);
|
|
5302
5454
|
|
|
5303
5455
|
this._hasInitializedCoreListeners = true;
|
|
5304
5456
|
}
|
|
@@ -5345,7 +5497,7 @@ class ReplayContainer {
|
|
|
5345
5497
|
isCheckout,
|
|
5346
5498
|
) => {
|
|
5347
5499
|
// If this is false, it means session is expired, create and a new session and wait for checkout
|
|
5348
|
-
if (!this.
|
|
5500
|
+
if (!this.checkAndHandleExpiredSession()) {
|
|
5349
5501
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('[Replay] Received replay event after session expired.');
|
|
5350
5502
|
|
|
5351
5503
|
return;
|
|
@@ -5440,51 +5592,6 @@ class ReplayContainer {
|
|
|
5440
5592
|
this._doChangeToForegroundTasks(breadcrumb);
|
|
5441
5593
|
};}
|
|
5442
5594
|
|
|
5443
|
-
/**
|
|
5444
|
-
* Handler for Sentry Core SDK events.
|
|
5445
|
-
*
|
|
5446
|
-
* These events will create breadcrumb-like objects in the recording.
|
|
5447
|
-
*/
|
|
5448
|
-
__init16() {this._handleCoreBreadcrumbListener =
|
|
5449
|
-
(type) =>
|
|
5450
|
-
(handlerData) => {
|
|
5451
|
-
if (!this._isEnabled) {
|
|
5452
|
-
return;
|
|
5453
|
-
}
|
|
5454
|
-
|
|
5455
|
-
const result = breadcrumbHandler(type, handlerData);
|
|
5456
|
-
|
|
5457
|
-
if (result === null) {
|
|
5458
|
-
return;
|
|
5459
|
-
}
|
|
5460
|
-
|
|
5461
|
-
if (result.category === 'sentry.transaction') {
|
|
5462
|
-
return;
|
|
5463
|
-
}
|
|
5464
|
-
|
|
5465
|
-
if (result.category === 'ui.click') {
|
|
5466
|
-
this.triggerUserActivity();
|
|
5467
|
-
} else {
|
|
5468
|
-
this._checkAndHandleExpiredSession();
|
|
5469
|
-
}
|
|
5470
|
-
|
|
5471
|
-
this.addUpdate(() => {
|
|
5472
|
-
void addEvent(this, {
|
|
5473
|
-
type: EventType.Custom,
|
|
5474
|
-
// TODO: We were converting from ms to seconds for breadcrumbs, spans,
|
|
5475
|
-
// but maybe we should just keep them as milliseconds
|
|
5476
|
-
timestamp: (result.timestamp || 0) * 1000,
|
|
5477
|
-
data: {
|
|
5478
|
-
tag: 'breadcrumb',
|
|
5479
|
-
payload: result,
|
|
5480
|
-
},
|
|
5481
|
-
});
|
|
5482
|
-
|
|
5483
|
-
// Do not flush after console log messages
|
|
5484
|
-
return result.category === 'console';
|
|
5485
|
-
});
|
|
5486
|
-
};}
|
|
5487
|
-
|
|
5488
5595
|
/**
|
|
5489
5596
|
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
|
|
5490
5597
|
*/
|
|
@@ -5513,7 +5620,7 @@ class ReplayContainer {
|
|
|
5513
5620
|
return;
|
|
5514
5621
|
}
|
|
5515
5622
|
|
|
5516
|
-
const isSessionActive = this.
|
|
5623
|
+
const isSessionActive = this.checkAndHandleExpiredSession({
|
|
5517
5624
|
expiry: VISIBILITY_CHANGE_TIMEOUT,
|
|
5518
5625
|
});
|
|
5519
5626
|
|
|
@@ -5535,8 +5642,12 @@ class ReplayContainer {
|
|
|
5535
5642
|
* create a new Replay event.
|
|
5536
5643
|
*/
|
|
5537
5644
|
_triggerFullSnapshot() {
|
|
5538
|
-
|
|
5539
|
-
|
|
5645
|
+
try {
|
|
5646
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Taking full rrweb snapshot');
|
|
5647
|
+
record.takeFullSnapshot(true);
|
|
5648
|
+
} catch (err) {
|
|
5649
|
+
this._handleException(err);
|
|
5650
|
+
}
|
|
5540
5651
|
}
|
|
5541
5652
|
|
|
5542
5653
|
/**
|
|
@@ -5584,43 +5695,6 @@ class ReplayContainer {
|
|
|
5584
5695
|
return Promise.all(createPerformanceSpans(this, createPerformanceEntries(entries)));
|
|
5585
5696
|
}
|
|
5586
5697
|
|
|
5587
|
-
/**
|
|
5588
|
-
* Checks if recording should be stopped due to user inactivity. Otherwise
|
|
5589
|
-
* check if session is expired and create a new session if so. Triggers a new
|
|
5590
|
-
* full snapshot on new session.
|
|
5591
|
-
*
|
|
5592
|
-
* Returns true if session is not expired, false otherwise.
|
|
5593
|
-
*/
|
|
5594
|
-
_checkAndHandleExpiredSession({ expiry = SESSION_IDLE_DURATION } = {}) {
|
|
5595
|
-
const oldSessionId = this.getSessionId();
|
|
5596
|
-
|
|
5597
|
-
// Prevent starting a new session if the last user activity is older than
|
|
5598
|
-
// MAX_SESSION_LIFE. Otherwise non-user activity can trigger a new
|
|
5599
|
-
// session+recording. This creates noisy replays that do not have much
|
|
5600
|
-
// content in them.
|
|
5601
|
-
if (this._lastActivity && isExpired(this._lastActivity, MAX_SESSION_LIFE)) {
|
|
5602
|
-
// Pause recording
|
|
5603
|
-
this.pause();
|
|
5604
|
-
return;
|
|
5605
|
-
}
|
|
5606
|
-
|
|
5607
|
-
// --- There is recent user activity --- //
|
|
5608
|
-
// This will create a new session if expired, based on expiry length
|
|
5609
|
-
this._loadSession({ expiry });
|
|
5610
|
-
|
|
5611
|
-
// Session was expired if session ids do not match
|
|
5612
|
-
const expired = oldSessionId !== this.getSessionId();
|
|
5613
|
-
|
|
5614
|
-
if (!expired) {
|
|
5615
|
-
return true;
|
|
5616
|
-
}
|
|
5617
|
-
|
|
5618
|
-
// Session is expired, trigger a full snapshot (which will create a new session)
|
|
5619
|
-
this._triggerFullSnapshot();
|
|
5620
|
-
|
|
5621
|
-
return false;
|
|
5622
|
-
}
|
|
5623
|
-
|
|
5624
5698
|
/**
|
|
5625
5699
|
* Only flush if `this.recordingMode === 'session'`
|
|
5626
5700
|
*/
|
|
@@ -5733,13 +5807,13 @@ class ReplayContainer {
|
|
|
5733
5807
|
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
5734
5808
|
* can be active at a time. Do not call this directly.
|
|
5735
5809
|
*/
|
|
5736
|
-
|
|
5810
|
+
__init16() {this._flush = async () => {
|
|
5737
5811
|
if (!this._isEnabled) {
|
|
5738
5812
|
// This can happen if e.g. the replay was stopped because of exceeding the retry limit
|
|
5739
5813
|
return;
|
|
5740
5814
|
}
|
|
5741
5815
|
|
|
5742
|
-
if (!this.
|
|
5816
|
+
if (!this.checkAndHandleExpiredSession()) {
|
|
5743
5817
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('[Replay] Attempting to finish replay event after session expired.');
|
|
5744
5818
|
return;
|
|
5745
5819
|
}
|
|
@@ -5876,8 +5950,8 @@ class Replay {
|
|
|
5876
5950
|
flushMinDelay,
|
|
5877
5951
|
flushMaxDelay,
|
|
5878
5952
|
stickySession,
|
|
5879
|
-
sessionSampleRate:
|
|
5880
|
-
errorSampleRate:
|
|
5953
|
+
sessionSampleRate: 0,
|
|
5954
|
+
errorSampleRate: 0,
|
|
5881
5955
|
useCompression,
|
|
5882
5956
|
maskAllText: typeof maskAllText === 'boolean' ? maskAllText : !maskTextSelector,
|
|
5883
5957
|
blockAllMedia,
|