@screeb/rrweb 1.0.8 → 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 +184 -71
- 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 +184 -71
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +180 -71
- 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.cjs
CHANGED
|
@@ -144,6 +144,32 @@ function querySelectorAll$1(n2, selectors) {
|
|
|
144
144
|
function mutationObserverCtor$1() {
|
|
145
145
|
return getUntaintedPrototype$1("MutationObserver").constructor;
|
|
146
146
|
}
|
|
147
|
+
function patch$1(source, name, replacement) {
|
|
148
|
+
try {
|
|
149
|
+
if (!(name in source)) {
|
|
150
|
+
return () => {
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const original = source[name];
|
|
154
|
+
const wrapped = replacement(original);
|
|
155
|
+
if (typeof wrapped === "function") {
|
|
156
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
157
|
+
Object.defineProperties(wrapped, {
|
|
158
|
+
__rrweb_original__: {
|
|
159
|
+
enumerable: false,
|
|
160
|
+
value: original
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
source[name] = wrapped;
|
|
165
|
+
return () => {
|
|
166
|
+
source[name] = original;
|
|
167
|
+
};
|
|
168
|
+
} catch {
|
|
169
|
+
return () => {
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
147
173
|
const index$1 = {
|
|
148
174
|
childNodes: childNodes$1,
|
|
149
175
|
parentNode: parentNode$1,
|
|
@@ -156,7 +182,8 @@ const index$1 = {
|
|
|
156
182
|
shadowRoot: shadowRoot$1,
|
|
157
183
|
querySelector: querySelector$1,
|
|
158
184
|
querySelectorAll: querySelectorAll$1,
|
|
159
|
-
mutationObserver: mutationObserverCtor$1
|
|
185
|
+
mutationObserver: mutationObserverCtor$1,
|
|
186
|
+
patch: patch$1
|
|
160
187
|
};
|
|
161
188
|
function isElement(n2) {
|
|
162
189
|
return n2.nodeType === n2.ELEMENT_NODE;
|
|
@@ -437,19 +464,27 @@ function absolutifyURLs(cssText, href) {
|
|
|
437
464
|
}
|
|
438
465
|
);
|
|
439
466
|
}
|
|
440
|
-
function normalizeCssString(cssText) {
|
|
441
|
-
|
|
467
|
+
function normalizeCssString(cssText, _testNoPxNorm = false) {
|
|
468
|
+
if (_testNoPxNorm) {
|
|
469
|
+
return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
|
|
470
|
+
} else {
|
|
471
|
+
return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
|
|
472
|
+
}
|
|
442
473
|
}
|
|
443
|
-
function splitCssText(cssText, style) {
|
|
474
|
+
function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
444
475
|
const childNodes2 = Array.from(style.childNodes);
|
|
445
476
|
const splits = [];
|
|
446
|
-
let
|
|
477
|
+
let iterCount = 0;
|
|
447
478
|
if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
|
|
448
|
-
let cssTextNorm = normalizeCssString(cssText);
|
|
479
|
+
let cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
|
|
449
480
|
const normFactor = cssTextNorm.length / cssText.length;
|
|
450
481
|
for (let i2 = 1; i2 < childNodes2.length; i2++) {
|
|
451
482
|
if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
|
|
452
|
-
const textContentNorm = normalizeCssString(
|
|
483
|
+
const textContentNorm = normalizeCssString(
|
|
484
|
+
childNodes2[i2].textContent,
|
|
485
|
+
_testNoPxNorm
|
|
486
|
+
);
|
|
487
|
+
const jLimit = 100;
|
|
453
488
|
let j = 3;
|
|
454
489
|
for (; j < textContentNorm.length; j++) {
|
|
455
490
|
if (
|
|
@@ -462,23 +497,49 @@ function splitCssText(cssText, style) {
|
|
|
462
497
|
break;
|
|
463
498
|
}
|
|
464
499
|
for (; j < textContentNorm.length; j++) {
|
|
465
|
-
|
|
466
|
-
|
|
500
|
+
let startSubstring = textContentNorm.substring(0, j);
|
|
501
|
+
let cssNormSplits = cssTextNorm.split(startSubstring);
|
|
467
502
|
let splitNorm = -1;
|
|
468
|
-
if (
|
|
469
|
-
splitNorm =
|
|
470
|
-
} else if (
|
|
471
|
-
splitNorm = cssTextNorm.indexOf(
|
|
503
|
+
if (cssNormSplits.length === 2) {
|
|
504
|
+
splitNorm = cssNormSplits[0].length;
|
|
505
|
+
} else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
|
|
506
|
+
splitNorm = cssTextNorm.indexOf(startSubstring, 1);
|
|
507
|
+
} else if (cssNormSplits.length === 1) {
|
|
508
|
+
startSubstring = startSubstring.substring(
|
|
509
|
+
0,
|
|
510
|
+
startSubstring.length - 1
|
|
511
|
+
);
|
|
512
|
+
cssNormSplits = cssTextNorm.split(startSubstring);
|
|
513
|
+
if (cssNormSplits.length <= 1) {
|
|
514
|
+
splits.push(cssText);
|
|
515
|
+
return splits;
|
|
516
|
+
}
|
|
517
|
+
j = jLimit + 1;
|
|
518
|
+
} else if (j === textContentNorm.length - 1) {
|
|
519
|
+
splitNorm = cssTextNorm.indexOf(startSubstring);
|
|
520
|
+
}
|
|
521
|
+
if (cssNormSplits.length >= 2 && j > jLimit) {
|
|
522
|
+
const prevTextContent = childNodes2[i2 - 1].textContent;
|
|
523
|
+
if (prevTextContent && typeof prevTextContent === "string") {
|
|
524
|
+
const prevMinLength = normalizeCssString(prevTextContent).length;
|
|
525
|
+
splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
|
|
526
|
+
}
|
|
527
|
+
if (splitNorm === -1) {
|
|
528
|
+
splitNorm = cssNormSplits[0].length;
|
|
529
|
+
}
|
|
472
530
|
}
|
|
473
531
|
if (splitNorm !== -1) {
|
|
474
532
|
let k = Math.floor(splitNorm / normFactor);
|
|
475
533
|
for (; k > 0 && k < cssText.length; ) {
|
|
476
|
-
|
|
477
|
-
if (
|
|
534
|
+
iterCount += 1;
|
|
535
|
+
if (iterCount > 50 * childNodes2.length) {
|
|
478
536
|
splits.push(cssText);
|
|
479
537
|
return splits;
|
|
480
538
|
}
|
|
481
|
-
const normPart = normalizeCssString(
|
|
539
|
+
const normPart = normalizeCssString(
|
|
540
|
+
cssText.substring(0, k),
|
|
541
|
+
_testNoPxNorm
|
|
542
|
+
);
|
|
482
543
|
if (normPart.length === splitNorm) {
|
|
483
544
|
splits.push(cssText.substring(0, k));
|
|
484
545
|
cssText = cssText.substring(k);
|
|
@@ -5048,11 +5109,16 @@ function getTagName(n2) {
|
|
|
5048
5109
|
function adaptCssForReplay(cssText, cache) {
|
|
5049
5110
|
const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
5050
5111
|
if (cachedStyle) return cachedStyle;
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5112
|
+
let result2 = cssText;
|
|
5113
|
+
try {
|
|
5114
|
+
const ast = postcss$1$1([
|
|
5115
|
+
mediaSelectorPlugin,
|
|
5116
|
+
pseudoClassPlugin
|
|
5117
|
+
]).process(cssText);
|
|
5118
|
+
result2 = ast.css;
|
|
5119
|
+
} catch (error) {
|
|
5120
|
+
console.warn("Failed to adapt css for replay", error);
|
|
5121
|
+
}
|
|
5056
5122
|
cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
|
|
5057
5123
|
return result2;
|
|
5058
5124
|
}
|
|
@@ -5073,11 +5139,39 @@ function applyCssSplits(n2, cssText, hackCss, cache) {
|
|
|
5073
5139
|
while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
|
|
5074
5140
|
cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
|
|
5075
5141
|
}
|
|
5142
|
+
let adaptedCss = "";
|
|
5143
|
+
if (hackCss) {
|
|
5144
|
+
adaptedCss = adaptCssForReplay(cssTextSplits.join(""), cache);
|
|
5145
|
+
}
|
|
5146
|
+
let startIndex = 0;
|
|
5076
5147
|
for (let i2 = 0; i2 < childTextNodes.length; i2++) {
|
|
5148
|
+
if (i2 === cssTextSplits.length) {
|
|
5149
|
+
break;
|
|
5150
|
+
}
|
|
5077
5151
|
const childTextNode = childTextNodes[i2];
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5152
|
+
if (!hackCss) {
|
|
5153
|
+
childTextNode.textContent = cssTextSplits[i2];
|
|
5154
|
+
} else if (i2 < cssTextSplits.length - 1) {
|
|
5155
|
+
let endIndex = startIndex;
|
|
5156
|
+
let endSearch = cssTextSplits[i2 + 1].length;
|
|
5157
|
+
endSearch = Math.min(endSearch, 30);
|
|
5158
|
+
let found = false;
|
|
5159
|
+
for (; endSearch > 2; endSearch--) {
|
|
5160
|
+
const searchBit = cssTextSplits[i2 + 1].substring(0, endSearch);
|
|
5161
|
+
const searchIndex = adaptedCss.substring(startIndex).indexOf(searchBit);
|
|
5162
|
+
found = searchIndex !== -1;
|
|
5163
|
+
if (found) {
|
|
5164
|
+
endIndex += searchIndex;
|
|
5165
|
+
break;
|
|
5166
|
+
}
|
|
5167
|
+
}
|
|
5168
|
+
if (!found) {
|
|
5169
|
+
endIndex += cssTextSplits[i2].length;
|
|
5170
|
+
}
|
|
5171
|
+
childTextNode.textContent = adaptedCss.substring(startIndex, endIndex);
|
|
5172
|
+
startIndex = endIndex;
|
|
5173
|
+
} else {
|
|
5174
|
+
childTextNode.textContent = adaptedCss.substring(startIndex);
|
|
5081
5175
|
}
|
|
5082
5176
|
}
|
|
5083
5177
|
}
|
|
@@ -10396,6 +10490,32 @@ function querySelectorAll(n2, selectors) {
|
|
|
10396
10490
|
function mutationObserverCtor() {
|
|
10397
10491
|
return getUntaintedPrototype("MutationObserver").constructor;
|
|
10398
10492
|
}
|
|
10493
|
+
function patch(source, name, replacement) {
|
|
10494
|
+
try {
|
|
10495
|
+
if (!(name in source)) {
|
|
10496
|
+
return () => {
|
|
10497
|
+
};
|
|
10498
|
+
}
|
|
10499
|
+
const original = source[name];
|
|
10500
|
+
const wrapped = replacement(original);
|
|
10501
|
+
if (typeof wrapped === "function") {
|
|
10502
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
10503
|
+
Object.defineProperties(wrapped, {
|
|
10504
|
+
__rrweb_original__: {
|
|
10505
|
+
enumerable: false,
|
|
10506
|
+
value: original
|
|
10507
|
+
}
|
|
10508
|
+
});
|
|
10509
|
+
}
|
|
10510
|
+
source[name] = wrapped;
|
|
10511
|
+
return () => {
|
|
10512
|
+
source[name] = original;
|
|
10513
|
+
};
|
|
10514
|
+
} catch {
|
|
10515
|
+
return () => {
|
|
10516
|
+
};
|
|
10517
|
+
}
|
|
10518
|
+
}
|
|
10399
10519
|
const index = {
|
|
10400
10520
|
childNodes,
|
|
10401
10521
|
parentNode,
|
|
@@ -10408,7 +10528,8 @@ const index = {
|
|
|
10408
10528
|
shadowRoot,
|
|
10409
10529
|
querySelector,
|
|
10410
10530
|
querySelectorAll,
|
|
10411
|
-
mutationObserver: mutationObserverCtor
|
|
10531
|
+
mutationObserver: mutationObserverCtor,
|
|
10532
|
+
patch
|
|
10412
10533
|
};
|
|
10413
10534
|
function on(type, fn, target = document) {
|
|
10414
10535
|
const options = { capture: true, passive: true };
|
|
@@ -10491,32 +10612,6 @@ function hookSetter(target, key, d, isRevoked, win = window) {
|
|
|
10491
10612
|
);
|
|
10492
10613
|
return () => hookSetter(target, key, original || {}, true);
|
|
10493
10614
|
}
|
|
10494
|
-
function patch(source, name, replacement) {
|
|
10495
|
-
try {
|
|
10496
|
-
if (!(name in source)) {
|
|
10497
|
-
return () => {
|
|
10498
|
-
};
|
|
10499
|
-
}
|
|
10500
|
-
const original = source[name];
|
|
10501
|
-
const wrapped = replacement(original);
|
|
10502
|
-
if (typeof wrapped === "function") {
|
|
10503
|
-
wrapped.prototype = wrapped.prototype || {};
|
|
10504
|
-
Object.defineProperties(wrapped, {
|
|
10505
|
-
__rrweb_original__: {
|
|
10506
|
-
enumerable: false,
|
|
10507
|
-
value: original
|
|
10508
|
-
}
|
|
10509
|
-
});
|
|
10510
|
-
}
|
|
10511
|
-
source[name] = wrapped;
|
|
10512
|
-
return () => {
|
|
10513
|
-
source[name] = original;
|
|
10514
|
-
};
|
|
10515
|
-
} catch {
|
|
10516
|
-
return () => {
|
|
10517
|
-
};
|
|
10518
|
-
}
|
|
10519
|
-
}
|
|
10520
10615
|
let nowTimestamp = Date.now;
|
|
10521
10616
|
if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
|
|
10522
10617
|
nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -10530,10 +10625,12 @@ function getWindowScroll(win) {
|
|
|
10530
10625
|
};
|
|
10531
10626
|
}
|
|
10532
10627
|
function getWindowHeight(win) {
|
|
10533
|
-
|
|
10628
|
+
var _a2, _b;
|
|
10629
|
+
return win.innerHeight || ((_a2 = win.document.documentElement) == null ? void 0 : _a2.clientHeight) || ((_b = win.document.body) == null ? void 0 : _b.clientHeight);
|
|
10534
10630
|
}
|
|
10535
10631
|
function getWindowWidth(win) {
|
|
10536
|
-
|
|
10632
|
+
var _a2, _b;
|
|
10633
|
+
return win.innerWidth || ((_a2 = win.document.documentElement) == null ? void 0 : _a2.clientWidth) || ((_b = win.document.body) == null ? void 0 : _b.clientWidth);
|
|
10537
10634
|
}
|
|
10538
10635
|
function closestElementOfNode(node2) {
|
|
10539
10636
|
if (!node2) {
|
|
@@ -10802,7 +10899,6 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
10802
10899
|
return nowTimestamp;
|
|
10803
10900
|
},
|
|
10804
10901
|
on,
|
|
10805
|
-
patch,
|
|
10806
10902
|
polyfill: polyfill$1,
|
|
10807
10903
|
queueToResolveTrees,
|
|
10808
10904
|
shadowHostInDom,
|
|
@@ -11245,10 +11341,18 @@ class MutationBuffer {
|
|
|
11245
11341
|
this.attributes.push(item);
|
|
11246
11342
|
this.attributeMap.set(textarea, item);
|
|
11247
11343
|
}
|
|
11248
|
-
|
|
11344
|
+
const value = Array.from(
|
|
11249
11345
|
index.childNodes(textarea),
|
|
11250
11346
|
(cn) => index.textContent(cn) || ""
|
|
11251
11347
|
).join("");
|
|
11348
|
+
item.attributes.value = maskInputValue({
|
|
11349
|
+
element: textarea,
|
|
11350
|
+
maskInputOptions: this.maskInputOptions,
|
|
11351
|
+
tagName: textarea.tagName,
|
|
11352
|
+
type: getInputType(textarea),
|
|
11353
|
+
value,
|
|
11354
|
+
maskInputFn: this.maskInputFn
|
|
11355
|
+
});
|
|
11252
11356
|
});
|
|
11253
11357
|
__publicField(this, "processMutation", (m) => {
|
|
11254
11358
|
if (isIgnored(m.target, this.mirror, this.slimDOMOptions)) {
|
|
@@ -12862,7 +12966,7 @@ class ShadowDomManager {
|
|
|
12862
12966
|
}
|
|
12863
12967
|
init() {
|
|
12864
12968
|
this.reset();
|
|
12865
|
-
this.patchAttachShadow(Element, document);
|
|
12969
|
+
this.patchAttachShadow(Element, this.bypassOptions.win.document);
|
|
12866
12970
|
}
|
|
12867
12971
|
addShadowRoot(shadowRoot2, doc) {
|
|
12868
12972
|
if (!isNativeShadowDom(shadowRoot2)) return;
|
|
@@ -14053,7 +14157,7 @@ function record(options = {}) {
|
|
|
14053
14157
|
data: {}
|
|
14054
14158
|
});
|
|
14055
14159
|
if (recordAfter === "DOMContentLoaded") init();
|
|
14056
|
-
})
|
|
14160
|
+
}, win.document)
|
|
14057
14161
|
);
|
|
14058
14162
|
handlers.push(
|
|
14059
14163
|
on(
|
|
@@ -15402,21 +15506,21 @@ class Replayer {
|
|
|
15402
15506
|
if (plugin3.handler) plugin3.handler(event, isSync, { replayer: this });
|
|
15403
15507
|
}
|
|
15404
15508
|
this.service.send({ type: "CAST_EVENT", payload: { event } });
|
|
15405
|
-
const
|
|
15406
|
-
if (!this.config.liveMode && event === this.service.state.context.events[
|
|
15509
|
+
const lastIndex = this.service.state.context.events.length - 1;
|
|
15510
|
+
if (!this.config.liveMode && event === this.service.state.context.events[lastIndex]) {
|
|
15407
15511
|
const finish = () => {
|
|
15408
|
-
if (
|
|
15512
|
+
if (lastIndex < this.service.state.context.events.length - 1) {
|
|
15409
15513
|
return;
|
|
15410
15514
|
}
|
|
15411
15515
|
this.backToNormal();
|
|
15412
15516
|
this.service.send("END");
|
|
15413
15517
|
this.emitter.emit(ReplayerEvents.Finish);
|
|
15414
15518
|
};
|
|
15415
|
-
let
|
|
15519
|
+
let finishBuffer = 50;
|
|
15416
15520
|
if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.MouseMove && event.data.positions.length) {
|
|
15417
|
-
|
|
15521
|
+
finishBuffer += Math.max(0, -event.data.positions[0].timeOffset);
|
|
15418
15522
|
}
|
|
15419
|
-
setTimeout(finish,
|
|
15523
|
+
setTimeout(finish, finishBuffer);
|
|
15420
15524
|
}
|
|
15421
15525
|
this.emitter.emit(ReplayerEvents.EventCast, event);
|
|
15422
15526
|
};
|
|
@@ -16599,18 +16703,27 @@ class Replayer {
|
|
|
16599
16703
|
const newSn = mirror2.getMeta(
|
|
16600
16704
|
target
|
|
16601
16705
|
);
|
|
16706
|
+
const newNode = buildNodeWithSN(
|
|
16707
|
+
{
|
|
16708
|
+
...newSn,
|
|
16709
|
+
attributes: {
|
|
16710
|
+
...newSn.attributes,
|
|
16711
|
+
...mutation.attributes
|
|
16712
|
+
}
|
|
16713
|
+
},
|
|
16714
|
+
{
|
|
16715
|
+
doc: target.ownerDocument,
|
|
16716
|
+
// can be Document or RRDocument
|
|
16717
|
+
mirror: mirror2,
|
|
16718
|
+
skipChild: true,
|
|
16719
|
+
hackCss: true,
|
|
16720
|
+
cache: this.cache
|
|
16721
|
+
}
|
|
16722
|
+
);
|
|
16602
16723
|
Object.assign(
|
|
16603
16724
|
newSn.attributes,
|
|
16604
16725
|
mutation.attributes
|
|
16605
16726
|
);
|
|
16606
|
-
const newNode = buildNodeWithSN(newSn, {
|
|
16607
|
-
doc: target.ownerDocument,
|
|
16608
|
-
// can be Document or RRDocument
|
|
16609
|
-
mirror: mirror2,
|
|
16610
|
-
skipChild: true,
|
|
16611
|
-
hackCss: true,
|
|
16612
|
-
cache: this.cache
|
|
16613
|
-
});
|
|
16614
16727
|
const siblingNode = target.nextSibling;
|
|
16615
16728
|
const parentNode2 = target.parentNode;
|
|
16616
16729
|
if (newNode && parentNode2) {
|