@screeb/rrweb 1.0.7 → 1.0.9
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/dist/rrweb.cjs +217 -67
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.d.cts +0 -7
- package/dist/rrweb.d.ts +0 -7
- package/dist/rrweb.js +217 -67
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +213 -67
- package/dist/rrweb.umd.cjs.map +3 -3
- package/dist/rrweb.umd.min.cjs +24 -24
- package/dist/rrweb.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/rrweb.umd.cjs
CHANGED
|
@@ -188,6 +188,32 @@ function querySelectorAll$1(n2, selectors) {
|
|
|
188
188
|
function mutationObserverCtor$1() {
|
|
189
189
|
return getUntaintedPrototype$1("MutationObserver").constructor;
|
|
190
190
|
}
|
|
191
|
+
function patch$1(source, name, replacement) {
|
|
192
|
+
try {
|
|
193
|
+
if (!(name in source)) {
|
|
194
|
+
return () => {
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const original = source[name];
|
|
198
|
+
const wrapped = replacement(original);
|
|
199
|
+
if (typeof wrapped === "function") {
|
|
200
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
201
|
+
Object.defineProperties(wrapped, {
|
|
202
|
+
__rrweb_original__: {
|
|
203
|
+
enumerable: false,
|
|
204
|
+
value: original
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
source[name] = wrapped;
|
|
209
|
+
return () => {
|
|
210
|
+
source[name] = original;
|
|
211
|
+
};
|
|
212
|
+
} catch (e2) {
|
|
213
|
+
return () => {
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
191
217
|
const index$1 = {
|
|
192
218
|
childNodes: childNodes$1,
|
|
193
219
|
parentNode: parentNode$1,
|
|
@@ -200,7 +226,8 @@ const index$1 = {
|
|
|
200
226
|
shadowRoot: shadowRoot$1,
|
|
201
227
|
querySelector: querySelector$1,
|
|
202
228
|
querySelectorAll: querySelectorAll$1,
|
|
203
|
-
mutationObserver: mutationObserverCtor$1
|
|
229
|
+
mutationObserver: mutationObserverCtor$1,
|
|
230
|
+
patch: patch$1
|
|
204
231
|
};
|
|
205
232
|
function isElement(n2) {
|
|
206
233
|
return n2.nodeType === n2.ELEMENT_NODE;
|
|
@@ -482,26 +509,97 @@ function absolutifyURLs(cssText, href) {
|
|
|
482
509
|
}
|
|
483
510
|
);
|
|
484
511
|
}
|
|
485
|
-
function normalizeCssString(cssText) {
|
|
486
|
-
|
|
512
|
+
function normalizeCssString(cssText, _testNoPxNorm = false) {
|
|
513
|
+
if (_testNoPxNorm) {
|
|
514
|
+
return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
|
|
515
|
+
} else {
|
|
516
|
+
return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
|
|
517
|
+
}
|
|
487
518
|
}
|
|
488
|
-
function splitCssText(cssText, style) {
|
|
519
|
+
function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
489
520
|
const childNodes2 = Array.from(style.childNodes);
|
|
490
521
|
const splits = [];
|
|
522
|
+
let iterCount = 0;
|
|
491
523
|
if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
|
|
492
|
-
|
|
524
|
+
let cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
|
|
525
|
+
const normFactor = cssTextNorm.length / cssText.length;
|
|
493
526
|
for (let i2 = 1; i2 < childNodes2.length; i2++) {
|
|
494
527
|
if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
|
|
495
|
-
const textContentNorm = normalizeCssString(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
528
|
+
const textContentNorm = normalizeCssString(
|
|
529
|
+
childNodes2[i2].textContent,
|
|
530
|
+
_testNoPxNorm
|
|
531
|
+
);
|
|
532
|
+
const jLimit = 100;
|
|
533
|
+
let j = 3;
|
|
534
|
+
for (; j < textContentNorm.length; j++) {
|
|
535
|
+
if (
|
|
536
|
+
// keep consuming css identifiers (to get a decent chunk more quickly)
|
|
537
|
+
textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
|
|
538
|
+
textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
|
|
539
|
+
) {
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
for (; j < textContentNorm.length; j++) {
|
|
545
|
+
let startSubstring = textContentNorm.substring(0, j);
|
|
546
|
+
let cssNormSplits = cssTextNorm.split(startSubstring);
|
|
547
|
+
let splitNorm = -1;
|
|
548
|
+
if (cssNormSplits.length === 2) {
|
|
549
|
+
splitNorm = cssNormSplits[0].length;
|
|
550
|
+
} else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
|
|
551
|
+
splitNorm = cssTextNorm.indexOf(startSubstring, 1);
|
|
552
|
+
} else if (cssNormSplits.length === 1) {
|
|
553
|
+
startSubstring = startSubstring.substring(
|
|
554
|
+
0,
|
|
555
|
+
startSubstring.length - 1
|
|
556
|
+
);
|
|
557
|
+
cssNormSplits = cssTextNorm.split(startSubstring);
|
|
558
|
+
if (cssNormSplits.length <= 1) {
|
|
559
|
+
splits.push(cssText);
|
|
560
|
+
return splits;
|
|
561
|
+
}
|
|
562
|
+
j = jLimit + 1;
|
|
563
|
+
} else if (j === textContentNorm.length - 1) {
|
|
564
|
+
splitNorm = cssTextNorm.indexOf(startSubstring);
|
|
565
|
+
}
|
|
566
|
+
if (cssNormSplits.length >= 2 && j > jLimit) {
|
|
567
|
+
const prevTextContent = childNodes2[i2 - 1].textContent;
|
|
568
|
+
if (prevTextContent && typeof prevTextContent === "string") {
|
|
569
|
+
const prevMinLength = normalizeCssString(prevTextContent).length;
|
|
570
|
+
splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
|
|
571
|
+
}
|
|
572
|
+
if (splitNorm === -1) {
|
|
573
|
+
splitNorm = cssNormSplits[0].length;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (splitNorm !== -1) {
|
|
577
|
+
let k = Math.floor(splitNorm / normFactor);
|
|
578
|
+
for (; k > 0 && k < cssText.length; ) {
|
|
579
|
+
iterCount += 1;
|
|
580
|
+
if (iterCount > 50 * childNodes2.length) {
|
|
581
|
+
splits.push(cssText);
|
|
582
|
+
return splits;
|
|
583
|
+
}
|
|
584
|
+
const normPart = normalizeCssString(
|
|
585
|
+
cssText.substring(0, k),
|
|
586
|
+
_testNoPxNorm
|
|
587
|
+
);
|
|
588
|
+
if (normPart.length === splitNorm) {
|
|
502
589
|
splits.push(cssText.substring(0, k));
|
|
503
590
|
cssText = cssText.substring(k);
|
|
591
|
+
cssTextNorm = cssTextNorm.substring(splitNorm);
|
|
504
592
|
break;
|
|
593
|
+
} else if (normPart.length < splitNorm) {
|
|
594
|
+
k += Math.max(
|
|
595
|
+
1,
|
|
596
|
+
Math.floor((splitNorm - normPart.length) / normFactor)
|
|
597
|
+
);
|
|
598
|
+
} else {
|
|
599
|
+
k -= Math.max(
|
|
600
|
+
1,
|
|
601
|
+
Math.floor((normPart.length - splitNorm) * normFactor)
|
|
602
|
+
);
|
|
505
603
|
}
|
|
506
604
|
}
|
|
507
605
|
break;
|
|
@@ -5060,11 +5158,16 @@ function getTagName(n2) {
|
|
|
5060
5158
|
function adaptCssForReplay(cssText, cache) {
|
|
5061
5159
|
const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
5062
5160
|
if (cachedStyle) return cachedStyle;
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5161
|
+
let result2 = cssText;
|
|
5162
|
+
try {
|
|
5163
|
+
const ast = postcss$1$1([
|
|
5164
|
+
mediaSelectorPlugin,
|
|
5165
|
+
pseudoClassPlugin
|
|
5166
|
+
]).process(cssText);
|
|
5167
|
+
result2 = ast.css;
|
|
5168
|
+
} catch (error) {
|
|
5169
|
+
console.warn("Failed to adapt css for replay", error);
|
|
5170
|
+
}
|
|
5068
5171
|
cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
|
|
5069
5172
|
return result2;
|
|
5070
5173
|
}
|
|
@@ -5085,11 +5188,39 @@ function applyCssSplits(n2, cssText, hackCss, cache) {
|
|
|
5085
5188
|
while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
|
|
5086
5189
|
cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
|
|
5087
5190
|
}
|
|
5191
|
+
let adaptedCss = "";
|
|
5192
|
+
if (hackCss) {
|
|
5193
|
+
adaptedCss = adaptCssForReplay(cssTextSplits.join(""), cache);
|
|
5194
|
+
}
|
|
5195
|
+
let startIndex = 0;
|
|
5088
5196
|
for (let i2 = 0; i2 < childTextNodes.length; i2++) {
|
|
5197
|
+
if (i2 === cssTextSplits.length) {
|
|
5198
|
+
break;
|
|
5199
|
+
}
|
|
5089
5200
|
const childTextNode = childTextNodes[i2];
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5201
|
+
if (!hackCss) {
|
|
5202
|
+
childTextNode.textContent = cssTextSplits[i2];
|
|
5203
|
+
} else if (i2 < cssTextSplits.length - 1) {
|
|
5204
|
+
let endIndex = startIndex;
|
|
5205
|
+
let endSearch = cssTextSplits[i2 + 1].length;
|
|
5206
|
+
endSearch = Math.min(endSearch, 30);
|
|
5207
|
+
let found = false;
|
|
5208
|
+
for (; endSearch > 2; endSearch--) {
|
|
5209
|
+
const searchBit = cssTextSplits[i2 + 1].substring(0, endSearch);
|
|
5210
|
+
const searchIndex = adaptedCss.substring(startIndex).indexOf(searchBit);
|
|
5211
|
+
found = searchIndex !== -1;
|
|
5212
|
+
if (found) {
|
|
5213
|
+
endIndex += searchIndex;
|
|
5214
|
+
break;
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
if (!found) {
|
|
5218
|
+
endIndex += cssTextSplits[i2].length;
|
|
5219
|
+
}
|
|
5220
|
+
childTextNode.textContent = adaptedCss.substring(startIndex, endIndex);
|
|
5221
|
+
startIndex = endIndex;
|
|
5222
|
+
} else {
|
|
5223
|
+
childTextNode.textContent = adaptedCss.substring(startIndex);
|
|
5093
5224
|
}
|
|
5094
5225
|
}
|
|
5095
5226
|
}
|
|
@@ -10412,6 +10543,32 @@ function querySelectorAll(n2, selectors) {
|
|
|
10412
10543
|
function mutationObserverCtor() {
|
|
10413
10544
|
return getUntaintedPrototype("MutationObserver").constructor;
|
|
10414
10545
|
}
|
|
10546
|
+
function patch(source, name, replacement) {
|
|
10547
|
+
try {
|
|
10548
|
+
if (!(name in source)) {
|
|
10549
|
+
return () => {
|
|
10550
|
+
};
|
|
10551
|
+
}
|
|
10552
|
+
const original = source[name];
|
|
10553
|
+
const wrapped = replacement(original);
|
|
10554
|
+
if (typeof wrapped === "function") {
|
|
10555
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
10556
|
+
Object.defineProperties(wrapped, {
|
|
10557
|
+
__rrweb_original__: {
|
|
10558
|
+
enumerable: false,
|
|
10559
|
+
value: original
|
|
10560
|
+
}
|
|
10561
|
+
});
|
|
10562
|
+
}
|
|
10563
|
+
source[name] = wrapped;
|
|
10564
|
+
return () => {
|
|
10565
|
+
source[name] = original;
|
|
10566
|
+
};
|
|
10567
|
+
} catch (e2) {
|
|
10568
|
+
return () => {
|
|
10569
|
+
};
|
|
10570
|
+
}
|
|
10571
|
+
}
|
|
10415
10572
|
const index = {
|
|
10416
10573
|
childNodes,
|
|
10417
10574
|
parentNode,
|
|
@@ -10424,7 +10581,8 @@ const index = {
|
|
|
10424
10581
|
shadowRoot,
|
|
10425
10582
|
querySelector,
|
|
10426
10583
|
querySelectorAll,
|
|
10427
|
-
mutationObserver: mutationObserverCtor
|
|
10584
|
+
mutationObserver: mutationObserverCtor,
|
|
10585
|
+
patch
|
|
10428
10586
|
};
|
|
10429
10587
|
function on(type, fn, target = document) {
|
|
10430
10588
|
const options = { capture: true, passive: true };
|
|
@@ -10507,32 +10665,6 @@ function hookSetter(target, key, d, isRevoked, win = window) {
|
|
|
10507
10665
|
);
|
|
10508
10666
|
return () => hookSetter(target, key, original || {}, true);
|
|
10509
10667
|
}
|
|
10510
|
-
function patch(source, name, replacement) {
|
|
10511
|
-
try {
|
|
10512
|
-
if (!(name in source)) {
|
|
10513
|
-
return () => {
|
|
10514
|
-
};
|
|
10515
|
-
}
|
|
10516
|
-
const original = source[name];
|
|
10517
|
-
const wrapped = replacement(original);
|
|
10518
|
-
if (typeof wrapped === "function") {
|
|
10519
|
-
wrapped.prototype = wrapped.prototype || {};
|
|
10520
|
-
Object.defineProperties(wrapped, {
|
|
10521
|
-
__rrweb_original__: {
|
|
10522
|
-
enumerable: false,
|
|
10523
|
-
value: original
|
|
10524
|
-
}
|
|
10525
|
-
});
|
|
10526
|
-
}
|
|
10527
|
-
source[name] = wrapped;
|
|
10528
|
-
return () => {
|
|
10529
|
-
source[name] = original;
|
|
10530
|
-
};
|
|
10531
|
-
} catch (e2) {
|
|
10532
|
-
return () => {
|
|
10533
|
-
};
|
|
10534
|
-
}
|
|
10535
|
-
}
|
|
10536
10668
|
let nowTimestamp = Date.now;
|
|
10537
10669
|
if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
|
|
10538
10670
|
nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -10546,10 +10678,12 @@ function getWindowScroll(win) {
|
|
|
10546
10678
|
};
|
|
10547
10679
|
}
|
|
10548
10680
|
function getWindowHeight(win) {
|
|
10549
|
-
|
|
10681
|
+
var _a2, _b;
|
|
10682
|
+
return win.innerHeight || ((_a2 = win.document.documentElement) == null ? void 0 : _a2.clientHeight) || ((_b = win.document.body) == null ? void 0 : _b.clientHeight);
|
|
10550
10683
|
}
|
|
10551
10684
|
function getWindowWidth(win) {
|
|
10552
|
-
|
|
10685
|
+
var _a2, _b;
|
|
10686
|
+
return win.innerWidth || ((_a2 = win.document.documentElement) == null ? void 0 : _a2.clientWidth) || ((_b = win.document.body) == null ? void 0 : _b.clientWidth);
|
|
10553
10687
|
}
|
|
10554
10688
|
function closestElementOfNode(node2) {
|
|
10555
10689
|
if (!node2) {
|
|
@@ -10819,7 +10953,6 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
10819
10953
|
return nowTimestamp;
|
|
10820
10954
|
},
|
|
10821
10955
|
on,
|
|
10822
|
-
patch,
|
|
10823
10956
|
polyfill: polyfill$1,
|
|
10824
10957
|
queueToResolveTrees,
|
|
10825
10958
|
shadowHostInDom,
|
|
@@ -11245,10 +11378,18 @@ class MutationBuffer {
|
|
|
11245
11378
|
this.attributes.push(item);
|
|
11246
11379
|
this.attributeMap.set(textarea, item);
|
|
11247
11380
|
}
|
|
11248
|
-
|
|
11381
|
+
const value = Array.from(
|
|
11249
11382
|
index.childNodes(textarea),
|
|
11250
11383
|
(cn) => index.textContent(cn) || ""
|
|
11251
11384
|
).join("");
|
|
11385
|
+
item.attributes.value = maskInputValue({
|
|
11386
|
+
element: textarea,
|
|
11387
|
+
maskInputOptions: this.maskInputOptions,
|
|
11388
|
+
tagName: textarea.tagName,
|
|
11389
|
+
type: getInputType(textarea),
|
|
11390
|
+
value,
|
|
11391
|
+
maskInputFn: this.maskInputFn
|
|
11392
|
+
});
|
|
11252
11393
|
});
|
|
11253
11394
|
__publicField(this, "processMutation", (m) => {
|
|
11254
11395
|
if (isIgnored(m.target, this.mirror, this.slimDOMOptions)) {
|
|
@@ -12857,7 +12998,7 @@ class ShadowDomManager {
|
|
|
12857
12998
|
}
|
|
12858
12999
|
init() {
|
|
12859
13000
|
this.reset();
|
|
12860
|
-
this.patchAttachShadow(Element, document);
|
|
13001
|
+
this.patchAttachShadow(Element, this.bypassOptions.win.document);
|
|
12861
13002
|
}
|
|
12862
13003
|
addShadowRoot(shadowRoot2, doc) {
|
|
12863
13004
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
@@ -14033,7 +14174,7 @@ function record(options = {}) {
|
|
|
14033
14174
|
data: {}
|
|
14034
14175
|
});
|
|
14035
14176
|
if (recordAfter === "DOMContentLoaded") init();
|
|
14036
|
-
})
|
|
14177
|
+
}, win.document)
|
|
14037
14178
|
);
|
|
14038
14179
|
handlers.push(
|
|
14039
14180
|
on(
|
|
@@ -15373,21 +15514,21 @@ class Replayer {
|
|
|
15373
15514
|
if (plugin3.handler) plugin3.handler(event, isSync, { replayer: this });
|
|
15374
15515
|
}
|
|
15375
15516
|
this.service.send({ type: "CAST_EVENT", payload: { event } });
|
|
15376
|
-
const
|
|
15377
|
-
if (!this.config.liveMode && event === this.service.state.context.events[
|
|
15517
|
+
const lastIndex = this.service.state.context.events.length - 1;
|
|
15518
|
+
if (!this.config.liveMode && event === this.service.state.context.events[lastIndex]) {
|
|
15378
15519
|
const finish = () => {
|
|
15379
|
-
if (
|
|
15520
|
+
if (lastIndex < this.service.state.context.events.length - 1) {
|
|
15380
15521
|
return;
|
|
15381
15522
|
}
|
|
15382
15523
|
this.backToNormal();
|
|
15383
15524
|
this.service.send("END");
|
|
15384
15525
|
this.emitter.emit(ReplayerEvents.Finish);
|
|
15385
15526
|
};
|
|
15386
|
-
let
|
|
15527
|
+
let finishBuffer = 50;
|
|
15387
15528
|
if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.MouseMove && event.data.positions.length) {
|
|
15388
|
-
|
|
15529
|
+
finishBuffer += Math.max(0, -event.data.positions[0].timeOffset);
|
|
15389
15530
|
}
|
|
15390
|
-
setTimeout(finish,
|
|
15531
|
+
setTimeout(finish, finishBuffer);
|
|
15391
15532
|
}
|
|
15392
15533
|
this.emitter.emit(ReplayerEvents.EventCast, event);
|
|
15393
15534
|
};
|
|
@@ -16568,18 +16709,23 @@ class Replayer {
|
|
|
16568
16709
|
const newSn = mirror2.getMeta(
|
|
16569
16710
|
target
|
|
16570
16711
|
);
|
|
16712
|
+
const newNode = buildNodeWithSN(
|
|
16713
|
+
__spreadProps(__spreadValues({}, newSn), {
|
|
16714
|
+
attributes: __spreadValues(__spreadValues({}, newSn.attributes), mutation.attributes)
|
|
16715
|
+
}),
|
|
16716
|
+
{
|
|
16717
|
+
doc: target.ownerDocument,
|
|
16718
|
+
// can be Document or RRDocument
|
|
16719
|
+
mirror: mirror2,
|
|
16720
|
+
skipChild: true,
|
|
16721
|
+
hackCss: true,
|
|
16722
|
+
cache: this.cache
|
|
16723
|
+
}
|
|
16724
|
+
);
|
|
16571
16725
|
Object.assign(
|
|
16572
16726
|
newSn.attributes,
|
|
16573
16727
|
mutation.attributes
|
|
16574
16728
|
);
|
|
16575
|
-
const newNode = buildNodeWithSN(newSn, {
|
|
16576
|
-
doc: target.ownerDocument,
|
|
16577
|
-
// can be Document or RRDocument
|
|
16578
|
-
mirror: mirror2,
|
|
16579
|
-
skipChild: true,
|
|
16580
|
-
hackCss: true,
|
|
16581
|
-
cache: this.cache
|
|
16582
|
-
});
|
|
16583
16729
|
const siblingNode = target.nextSibling;
|
|
16584
16730
|
const parentNode2 = target.parentNode;
|
|
16585
16731
|
if (newNode && parentNode2) {
|