@highlight-run/rrweb 2.0.0-lambda.7 → 2.0.0-lambda.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 +916 -76
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.d.cts +179 -1
- package/dist/rrweb.d.ts +179 -1
- package/dist/rrweb.js +916 -76
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +908 -76
- package/dist/rrweb.umd.cjs.map +4 -4
- package/dist/rrweb.umd.min.cjs +57 -47
- package/dist/rrweb.umd.min.cjs.map +4 -4
- package/package.json +5 -5
- package/umd/rrweb.js +908 -76
- package/umd/rrweb.min.js +57 -47
package/dist/rrweb.umd.cjs
CHANGED
|
@@ -1909,6 +1909,7 @@ function requireStringifier$1() {
|
|
|
1909
1909
|
hasRequiredStringifier$1 = 1;
|
|
1910
1910
|
const STYLE_TAG = /(<)(\/?style\b)/gi;
|
|
1911
1911
|
const COMMENT_OPEN = /(<)(!--)/g;
|
|
1912
|
+
const AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/;
|
|
1912
1913
|
function escapeHTMLInCSS(str) {
|
|
1913
1914
|
if (typeof str !== "string") return str;
|
|
1914
1915
|
if (!str.includes("<")) return str;
|
|
@@ -1934,12 +1935,13 @@ function requireStringifier$1() {
|
|
|
1934
1935
|
function atruleStart(str, node2) {
|
|
1935
1936
|
let name = "@" + node2.name;
|
|
1936
1937
|
let params = node2.params ? str.rawValue(node2, "params") : "";
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1938
|
+
let afterName = node2.raws.afterName;
|
|
1939
|
+
if (typeof afterName === "undefined") {
|
|
1940
|
+
afterName = params ? " " : "";
|
|
1941
|
+
} else if (afterName === "" && params && !AT_NAME_END.test(params[0])) {
|
|
1942
|
+
afterName = " ";
|
|
1941
1943
|
}
|
|
1942
|
-
return name + params;
|
|
1944
|
+
return name + afterName + params;
|
|
1943
1945
|
}
|
|
1944
1946
|
function pushBody(str, stack, node2) {
|
|
1945
1947
|
let nodes = node2.nodes;
|
|
@@ -1951,10 +1953,15 @@ function requireStringifier$1() {
|
|
|
1951
1953
|
let semicolon = str.raw(node2, "semicolon");
|
|
1952
1954
|
let isDocument = node2.type === "document";
|
|
1953
1955
|
for (let i2 = nodes.length - 1; i2 >= 0; i2--) {
|
|
1956
|
+
let child = nodes[i2];
|
|
1957
|
+
let childSemicolon = last !== i2 || semicolon;
|
|
1958
|
+
if (!childSemicolon && i2 < nodes.length - 1 && (child.type === "atrule" && !child.nodes || child.type === "decl" && child.prop.startsWith("--"))) {
|
|
1959
|
+
childSemicolon = true;
|
|
1960
|
+
}
|
|
1954
1961
|
stack.push({
|
|
1955
1962
|
document: isDocument,
|
|
1956
|
-
node:
|
|
1957
|
-
semicolon:
|
|
1963
|
+
node: child,
|
|
1964
|
+
semicolon: childSemicolon
|
|
1958
1965
|
});
|
|
1959
1966
|
}
|
|
1960
1967
|
}
|
|
@@ -2245,6 +2252,9 @@ function requireStringifier$1() {
|
|
|
2245
2252
|
return value;
|
|
2246
2253
|
}
|
|
2247
2254
|
root(node2) {
|
|
2255
|
+
if (node2.source && node2.source.input.hasBOM) {
|
|
2256
|
+
this.builder("\uFEFF", node2, "start");
|
|
2257
|
+
}
|
|
2248
2258
|
this.body(node2);
|
|
2249
2259
|
if (node2.raws.after) {
|
|
2250
2260
|
let after = node2.raws.after;
|
|
@@ -3317,15 +3327,12 @@ function requirePreviousMap$1() {
|
|
|
3317
3327
|
}
|
|
3318
3328
|
loadFile(path, cssFile, trusted) {
|
|
3319
3329
|
if (!trusted && !this.unsafeMap) {
|
|
3320
|
-
if (!/\.map$/i.test(path))
|
|
3330
|
+
if (!/\.map$/i.test(path)) return void 0;
|
|
3331
|
+
if (!cssFile) return void 0;
|
|
3332
|
+
let rel = relative(dirname(cssFile), path);
|
|
3333
|
+
if (rel === ".." || rel.startsWith(".." + sep) || isAbsolute(rel)) {
|
|
3321
3334
|
return void 0;
|
|
3322
3335
|
}
|
|
3323
|
-
if (cssFile) {
|
|
3324
|
-
let relativePath = relative(dirname(cssFile), path);
|
|
3325
|
-
if (relativePath === ".." || relativePath.startsWith(".." + sep) || isAbsolute(relativePath)) {
|
|
3326
|
-
return void 0;
|
|
3327
|
-
}
|
|
3328
|
-
}
|
|
3329
3336
|
}
|
|
3330
3337
|
this.root = dirname(path);
|
|
3331
3338
|
if (existsSync(path)) {
|
|
@@ -3697,6 +3704,7 @@ function requireList$1() {
|
|
|
3697
3704
|
return list.split(string, spaces);
|
|
3698
3705
|
},
|
|
3699
3706
|
split(string, separators, last) {
|
|
3707
|
+
if (!string) return [];
|
|
3700
3708
|
let array = [];
|
|
3701
3709
|
let current = "";
|
|
3702
3710
|
let split = false;
|
|
@@ -4982,11 +4990,16 @@ var hasRequiredWarning$1;
|
|
|
4982
4990
|
function requireWarning$1() {
|
|
4983
4991
|
if (hasRequiredWarning$1) return warning$1;
|
|
4984
4992
|
hasRequiredWarning$1 = 1;
|
|
4993
|
+
let Container = requireContainer$1();
|
|
4994
|
+
let { my } = requireSymbols$1();
|
|
4985
4995
|
class Warning {
|
|
4986
4996
|
constructor(text, opts = {}) {
|
|
4987
4997
|
this.type = "warning";
|
|
4988
4998
|
this.text = text;
|
|
4989
4999
|
if (opts.node && opts.node.source) {
|
|
5000
|
+
if (!opts.node[my]) {
|
|
5001
|
+
Container.rebuild(opts.node);
|
|
5002
|
+
}
|
|
4990
5003
|
let range = opts.node.rangeBy(opts);
|
|
4991
5004
|
this.line = range.start.line;
|
|
4992
5005
|
this.column = range.start.column;
|
|
@@ -5496,14 +5509,19 @@ function requireLazyResult$1() {
|
|
|
5496
5509
|
}
|
|
5497
5510
|
if (visit2.iterator !== 0) {
|
|
5498
5511
|
let iterator = visit2.iterator;
|
|
5512
|
+
if (visit2.descending) {
|
|
5513
|
+
visit2.descending = false;
|
|
5514
|
+
node2.indexes[iterator] += 1;
|
|
5515
|
+
}
|
|
5499
5516
|
let child;
|
|
5500
5517
|
while (child = node2.nodes[node2.indexes[iterator]]) {
|
|
5501
|
-
node2.indexes[iterator] += 1;
|
|
5502
5518
|
if (!child[isClean]) {
|
|
5503
5519
|
child[isClean] = true;
|
|
5520
|
+
visit2.descending = true;
|
|
5504
5521
|
stack.push(toStack(child));
|
|
5505
5522
|
return;
|
|
5506
5523
|
}
|
|
5524
|
+
node2.indexes[iterator] += 1;
|
|
5507
5525
|
}
|
|
5508
5526
|
visit2.iterator = 0;
|
|
5509
5527
|
delete node2.indexes[iterator];
|
|
@@ -5533,12 +5551,16 @@ function requireLazyResult$1() {
|
|
|
5533
5551
|
let visitNode = visit2.node;
|
|
5534
5552
|
if (visit2.iterator !== 0) {
|
|
5535
5553
|
let iterator = visit2.iterator;
|
|
5554
|
+
if (visit2.descending) {
|
|
5555
|
+
visit2.descending = false;
|
|
5556
|
+
visitNode.indexes[iterator] += 1;
|
|
5557
|
+
}
|
|
5536
5558
|
let child;
|
|
5537
5559
|
let descended = false;
|
|
5538
5560
|
while (child = visitNode.nodes[visitNode.indexes[iterator]]) {
|
|
5539
|
-
visitNode.indexes[iterator] += 1;
|
|
5540
5561
|
if (!child[isClean]) {
|
|
5541
5562
|
child[isClean] = true;
|
|
5563
|
+
visit2.descending = true;
|
|
5542
5564
|
stack.push({
|
|
5543
5565
|
eventIndex: 0,
|
|
5544
5566
|
events: getEvents(child),
|
|
@@ -5548,6 +5570,7 @@ function requireLazyResult$1() {
|
|
|
5548
5570
|
descended = true;
|
|
5549
5571
|
break;
|
|
5550
5572
|
}
|
|
5573
|
+
visitNode.indexes[iterator] += 1;
|
|
5551
5574
|
}
|
|
5552
5575
|
if (descended) continue;
|
|
5553
5576
|
visit2.iterator = 0;
|
|
@@ -5710,7 +5733,7 @@ function requireProcessor$1() {
|
|
|
5710
5733
|
let Root = requireRoot$1();
|
|
5711
5734
|
class Processor {
|
|
5712
5735
|
constructor(plugins = []) {
|
|
5713
|
-
this.version = "8.5.
|
|
5736
|
+
this.version = "8.5.25";
|
|
5714
5737
|
this.plugins = this.normalize(plugins);
|
|
5715
5738
|
}
|
|
5716
5739
|
normalize(plugins) {
|
|
@@ -6577,6 +6600,7 @@ function requireStringifier() {
|
|
|
6577
6600
|
hasRequiredStringifier = 1;
|
|
6578
6601
|
const STYLE_TAG = /(<)(\/?style\b)/gi;
|
|
6579
6602
|
const COMMENT_OPEN = /(<)(!--)/g;
|
|
6603
|
+
const AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/;
|
|
6580
6604
|
function escapeHTMLInCSS(str) {
|
|
6581
6605
|
if (typeof str !== "string") return str;
|
|
6582
6606
|
if (!str.includes("<")) return str;
|
|
@@ -6602,12 +6626,13 @@ function requireStringifier() {
|
|
|
6602
6626
|
function atruleStart(str, node2) {
|
|
6603
6627
|
let name = "@" + node2.name;
|
|
6604
6628
|
let params = node2.params ? str.rawValue(node2, "params") : "";
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6629
|
+
let afterName = node2.raws.afterName;
|
|
6630
|
+
if (typeof afterName === "undefined") {
|
|
6631
|
+
afterName = params ? " " : "";
|
|
6632
|
+
} else if (afterName === "" && params && !AT_NAME_END.test(params[0])) {
|
|
6633
|
+
afterName = " ";
|
|
6609
6634
|
}
|
|
6610
|
-
return name + params;
|
|
6635
|
+
return name + afterName + params;
|
|
6611
6636
|
}
|
|
6612
6637
|
function pushBody(str, stack, node2) {
|
|
6613
6638
|
let nodes = node2.nodes;
|
|
@@ -6619,10 +6644,15 @@ function requireStringifier() {
|
|
|
6619
6644
|
let semicolon = str.raw(node2, "semicolon");
|
|
6620
6645
|
let isDocument = node2.type === "document";
|
|
6621
6646
|
for (let i2 = nodes.length - 1; i2 >= 0; i2--) {
|
|
6647
|
+
let child = nodes[i2];
|
|
6648
|
+
let childSemicolon = last !== i2 || semicolon;
|
|
6649
|
+
if (!childSemicolon && i2 < nodes.length - 1 && (child.type === "atrule" && !child.nodes || child.type === "decl" && child.prop.startsWith("--"))) {
|
|
6650
|
+
childSemicolon = true;
|
|
6651
|
+
}
|
|
6622
6652
|
stack.push({
|
|
6623
6653
|
document: isDocument,
|
|
6624
|
-
node:
|
|
6625
|
-
semicolon:
|
|
6654
|
+
node: child,
|
|
6655
|
+
semicolon: childSemicolon
|
|
6626
6656
|
});
|
|
6627
6657
|
}
|
|
6628
6658
|
}
|
|
@@ -6913,6 +6943,9 @@ function requireStringifier() {
|
|
|
6913
6943
|
return value;
|
|
6914
6944
|
}
|
|
6915
6945
|
root(node2) {
|
|
6946
|
+
if (node2.source && node2.source.input.hasBOM) {
|
|
6947
|
+
this.builder("\uFEFF", node2, "start");
|
|
6948
|
+
}
|
|
6916
6949
|
this.body(node2);
|
|
6917
6950
|
if (node2.raws.after) {
|
|
6918
6951
|
let after = node2.raws.after;
|
|
@@ -7985,15 +8018,12 @@ function requirePreviousMap() {
|
|
|
7985
8018
|
}
|
|
7986
8019
|
loadFile(path, cssFile, trusted) {
|
|
7987
8020
|
if (!trusted && !this.unsafeMap) {
|
|
7988
|
-
if (!/\.map$/i.test(path))
|
|
8021
|
+
if (!/\.map$/i.test(path)) return void 0;
|
|
8022
|
+
if (!cssFile) return void 0;
|
|
8023
|
+
let rel = relative(dirname(cssFile), path);
|
|
8024
|
+
if (rel === ".." || rel.startsWith(".." + sep) || isAbsolute(rel)) {
|
|
7989
8025
|
return void 0;
|
|
7990
8026
|
}
|
|
7991
|
-
if (cssFile) {
|
|
7992
|
-
let relativePath = relative(dirname(cssFile), path);
|
|
7993
|
-
if (relativePath === ".." || relativePath.startsWith(".." + sep) || isAbsolute(relativePath)) {
|
|
7994
|
-
return void 0;
|
|
7995
|
-
}
|
|
7996
|
-
}
|
|
7997
8027
|
}
|
|
7998
8028
|
this.root = dirname(path);
|
|
7999
8029
|
if (existsSync(path)) {
|
|
@@ -8365,6 +8395,7 @@ function requireList() {
|
|
|
8365
8395
|
return list.split(string, spaces);
|
|
8366
8396
|
},
|
|
8367
8397
|
split(string, separators, last) {
|
|
8398
|
+
if (!string) return [];
|
|
8368
8399
|
let array = [];
|
|
8369
8400
|
let current = "";
|
|
8370
8401
|
let split = false;
|
|
@@ -9650,11 +9681,16 @@ var hasRequiredWarning;
|
|
|
9650
9681
|
function requireWarning() {
|
|
9651
9682
|
if (hasRequiredWarning) return warning;
|
|
9652
9683
|
hasRequiredWarning = 1;
|
|
9684
|
+
let Container = requireContainer();
|
|
9685
|
+
let { my } = requireSymbols();
|
|
9653
9686
|
class Warning {
|
|
9654
9687
|
constructor(text, opts = {}) {
|
|
9655
9688
|
this.type = "warning";
|
|
9656
9689
|
this.text = text;
|
|
9657
9690
|
if (opts.node && opts.node.source) {
|
|
9691
|
+
if (!opts.node[my]) {
|
|
9692
|
+
Container.rebuild(opts.node);
|
|
9693
|
+
}
|
|
9658
9694
|
let range = opts.node.rangeBy(opts);
|
|
9659
9695
|
this.line = range.start.line;
|
|
9660
9696
|
this.column = range.start.column;
|
|
@@ -10164,14 +10200,19 @@ function requireLazyResult() {
|
|
|
10164
10200
|
}
|
|
10165
10201
|
if (visit2.iterator !== 0) {
|
|
10166
10202
|
let iterator = visit2.iterator;
|
|
10203
|
+
if (visit2.descending) {
|
|
10204
|
+
visit2.descending = false;
|
|
10205
|
+
node2.indexes[iterator] += 1;
|
|
10206
|
+
}
|
|
10167
10207
|
let child;
|
|
10168
10208
|
while (child = node2.nodes[node2.indexes[iterator]]) {
|
|
10169
|
-
node2.indexes[iterator] += 1;
|
|
10170
10209
|
if (!child[isClean]) {
|
|
10171
10210
|
child[isClean] = true;
|
|
10211
|
+
visit2.descending = true;
|
|
10172
10212
|
stack.push(toStack(child));
|
|
10173
10213
|
return;
|
|
10174
10214
|
}
|
|
10215
|
+
node2.indexes[iterator] += 1;
|
|
10175
10216
|
}
|
|
10176
10217
|
visit2.iterator = 0;
|
|
10177
10218
|
delete node2.indexes[iterator];
|
|
@@ -10201,12 +10242,16 @@ function requireLazyResult() {
|
|
|
10201
10242
|
let visitNode = visit2.node;
|
|
10202
10243
|
if (visit2.iterator !== 0) {
|
|
10203
10244
|
let iterator = visit2.iterator;
|
|
10245
|
+
if (visit2.descending) {
|
|
10246
|
+
visit2.descending = false;
|
|
10247
|
+
visitNode.indexes[iterator] += 1;
|
|
10248
|
+
}
|
|
10204
10249
|
let child;
|
|
10205
10250
|
let descended = false;
|
|
10206
10251
|
while (child = visitNode.nodes[visitNode.indexes[iterator]]) {
|
|
10207
|
-
visitNode.indexes[iterator] += 1;
|
|
10208
10252
|
if (!child[isClean]) {
|
|
10209
10253
|
child[isClean] = true;
|
|
10254
|
+
visit2.descending = true;
|
|
10210
10255
|
stack.push({
|
|
10211
10256
|
eventIndex: 0,
|
|
10212
10257
|
events: getEvents(child),
|
|
@@ -10216,6 +10261,7 @@ function requireLazyResult() {
|
|
|
10216
10261
|
descended = true;
|
|
10217
10262
|
break;
|
|
10218
10263
|
}
|
|
10264
|
+
visitNode.indexes[iterator] += 1;
|
|
10219
10265
|
}
|
|
10220
10266
|
if (descended) continue;
|
|
10221
10267
|
visit2.iterator = 0;
|
|
@@ -10378,7 +10424,7 @@ function requireProcessor() {
|
|
|
10378
10424
|
let Root = requireRoot();
|
|
10379
10425
|
class Processor {
|
|
10380
10426
|
constructor(plugins = []) {
|
|
10381
|
-
this.version = "8.5.
|
|
10427
|
+
this.version = "8.5.25";
|
|
10382
10428
|
this.plugins = this.normalize(plugins);
|
|
10383
10429
|
}
|
|
10384
10430
|
normalize(plugins) {
|
|
@@ -13640,66 +13686,142 @@ function getIdAndStyleId(sheet, mirror2, styleMirror) {
|
|
|
13640
13686
|
id
|
|
13641
13687
|
};
|
|
13642
13688
|
}
|
|
13643
|
-
function
|
|
13689
|
+
function restorePatchedMethod(target, key, ours, restoreTo) {
|
|
13690
|
+
if (target[key] === ours) {
|
|
13691
|
+
target[key] = restoreTo;
|
|
13692
|
+
}
|
|
13693
|
+
}
|
|
13694
|
+
const MAX_CSSOM_REPATCH_ATTEMPTS = 5;
|
|
13695
|
+
function initStyleSheetObserver({
|
|
13696
|
+
styleSheetRuleCb,
|
|
13697
|
+
mirror: mirror2,
|
|
13698
|
+
stylesheetManager,
|
|
13699
|
+
doc,
|
|
13700
|
+
styleSheetResyncInterval
|
|
13701
|
+
}, { win }) {
|
|
13644
13702
|
if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
|
|
13645
13703
|
return () => {
|
|
13646
13704
|
};
|
|
13647
13705
|
}
|
|
13648
|
-
const
|
|
13649
|
-
|
|
13706
|
+
const reportedRuleCounts = /* @__PURE__ */ new WeakMap();
|
|
13707
|
+
const unreconcilableSheets = /* @__PURE__ */ new WeakSet();
|
|
13708
|
+
let probing = false;
|
|
13709
|
+
let probeInsertObserved = false;
|
|
13710
|
+
let probeDeleteObserved = false;
|
|
13711
|
+
let probeSheet;
|
|
13712
|
+
let stopped = false;
|
|
13713
|
+
let insideInsertRule = false;
|
|
13714
|
+
let insideDeleteRule = false;
|
|
13715
|
+
const noteReportedRules = (sheet, delta) => {
|
|
13716
|
+
const state = reportedRuleCounts.get(sheet);
|
|
13717
|
+
if (state) {
|
|
13718
|
+
state.reported = Math.max(0, state.reported + delta);
|
|
13719
|
+
state.everSeen = Math.max(state.everSeen, state.reported);
|
|
13720
|
+
}
|
|
13721
|
+
};
|
|
13722
|
+
const patchInsertRule = (target) => new Proxy(target, {
|
|
13650
13723
|
apply: callbackWrapper(
|
|
13651
|
-
(
|
|
13724
|
+
(nativeFn, thisArg, argumentsList) => {
|
|
13725
|
+
if (probing) {
|
|
13726
|
+
probeInsertObserved = true;
|
|
13727
|
+
return nativeFn.apply(thisArg, argumentsList);
|
|
13728
|
+
}
|
|
13729
|
+
if (stopped || insideInsertRule) {
|
|
13730
|
+
return nativeFn.apply(thisArg, argumentsList);
|
|
13731
|
+
}
|
|
13652
13732
|
const [rule2, index2] = argumentsList;
|
|
13653
13733
|
const { id, styleId } = getIdAndStyleId(
|
|
13654
13734
|
thisArg,
|
|
13655
13735
|
mirror2,
|
|
13656
13736
|
stylesheetManager.styleMirror
|
|
13657
13737
|
);
|
|
13658
|
-
|
|
13738
|
+
const reported = id && id !== -1 || styleId && styleId !== -1;
|
|
13739
|
+
if (reported) {
|
|
13659
13740
|
styleSheetRuleCb({
|
|
13660
13741
|
id,
|
|
13661
13742
|
styleId,
|
|
13662
13743
|
adds: [{ rule: rule2, index: index2 }]
|
|
13663
13744
|
});
|
|
13664
13745
|
}
|
|
13665
|
-
|
|
13746
|
+
insideInsertRule = true;
|
|
13747
|
+
let result2;
|
|
13748
|
+
try {
|
|
13749
|
+
result2 = nativeFn.apply(thisArg, argumentsList);
|
|
13750
|
+
} finally {
|
|
13751
|
+
insideInsertRule = false;
|
|
13752
|
+
}
|
|
13753
|
+
if (reported) {
|
|
13754
|
+
noteReportedRules(thisArg, 1);
|
|
13755
|
+
}
|
|
13756
|
+
return result2;
|
|
13666
13757
|
}
|
|
13667
13758
|
)
|
|
13668
13759
|
});
|
|
13669
|
-
|
|
13670
|
-
const rule2 = `${selector} { ${styleBlock} }`;
|
|
13671
|
-
return win.CSSStyleSheet.prototype.insertRule.apply(this, [rule2, index2]);
|
|
13672
|
-
};
|
|
13673
|
-
const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
|
|
13674
|
-
win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
|
|
13760
|
+
const patchDeleteRule = (target) => new Proxy(target, {
|
|
13675
13761
|
apply: callbackWrapper(
|
|
13676
|
-
(
|
|
13762
|
+
(nativeFn, thisArg, argumentsList) => {
|
|
13763
|
+
if (probing) {
|
|
13764
|
+
probeDeleteObserved = true;
|
|
13765
|
+
return nativeFn.apply(thisArg, argumentsList);
|
|
13766
|
+
}
|
|
13767
|
+
if (stopped || insideDeleteRule) {
|
|
13768
|
+
return nativeFn.apply(thisArg, argumentsList);
|
|
13769
|
+
}
|
|
13677
13770
|
const [index2] = argumentsList;
|
|
13678
13771
|
const { id, styleId } = getIdAndStyleId(
|
|
13679
13772
|
thisArg,
|
|
13680
13773
|
mirror2,
|
|
13681
13774
|
stylesheetManager.styleMirror
|
|
13682
13775
|
);
|
|
13683
|
-
|
|
13776
|
+
const reported = id && id !== -1 || styleId && styleId !== -1;
|
|
13777
|
+
if (reported) {
|
|
13684
13778
|
styleSheetRuleCb({
|
|
13685
13779
|
id,
|
|
13686
13780
|
styleId,
|
|
13687
13781
|
removes: [{ index: index2 }]
|
|
13688
13782
|
});
|
|
13689
13783
|
}
|
|
13690
|
-
|
|
13784
|
+
insideDeleteRule = true;
|
|
13785
|
+
let result2;
|
|
13786
|
+
try {
|
|
13787
|
+
result2 = nativeFn.apply(thisArg, argumentsList);
|
|
13788
|
+
} finally {
|
|
13789
|
+
insideDeleteRule = false;
|
|
13790
|
+
}
|
|
13791
|
+
if (reported) {
|
|
13792
|
+
noteReportedRules(thisArg, -1);
|
|
13793
|
+
}
|
|
13794
|
+
return result2;
|
|
13691
13795
|
}
|
|
13692
13796
|
)
|
|
13693
13797
|
});
|
|
13694
|
-
win.CSSStyleSheet.prototype.
|
|
13798
|
+
const insertRule = win.CSSStyleSheet.prototype.insertRule;
|
|
13799
|
+
let insertRuleProxy = patchInsertRule(insertRule);
|
|
13800
|
+
let restoreInsertRuleTo = insertRule;
|
|
13801
|
+
win.CSSStyleSheet.prototype.insertRule = insertRuleProxy;
|
|
13802
|
+
const addRule = win.CSSStyleSheet.prototype.addRule;
|
|
13803
|
+
const addRuleShim = function(selector, styleBlock, index2 = this.cssRules.length) {
|
|
13804
|
+
const rule2 = `${selector} { ${styleBlock} }`;
|
|
13805
|
+
return win.CSSStyleSheet.prototype.insertRule.apply(this, [rule2, index2]);
|
|
13806
|
+
};
|
|
13807
|
+
win.CSSStyleSheet.prototype.addRule = addRuleShim;
|
|
13808
|
+
const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
|
|
13809
|
+
let deleteRuleProxy = patchDeleteRule(deleteRule);
|
|
13810
|
+
let restoreDeleteRuleTo = deleteRule;
|
|
13811
|
+
win.CSSStyleSheet.prototype.deleteRule = deleteRuleProxy;
|
|
13812
|
+
const removeRule = win.CSSStyleSheet.prototype.removeRule;
|
|
13813
|
+
const removeRuleShim = function(index2) {
|
|
13695
13814
|
return win.CSSStyleSheet.prototype.deleteRule.apply(this, [index2]);
|
|
13696
13815
|
};
|
|
13816
|
+
win.CSSStyleSheet.prototype.removeRule = removeRuleShim;
|
|
13697
13817
|
let replace;
|
|
13818
|
+
let replaceProxy;
|
|
13698
13819
|
if (win.CSSStyleSheet.prototype.replace) {
|
|
13699
13820
|
replace = win.CSSStyleSheet.prototype.replace;
|
|
13700
|
-
|
|
13821
|
+
replaceProxy = new Proxy(replace, {
|
|
13701
13822
|
apply: callbackWrapper(
|
|
13702
13823
|
(target, thisArg, argumentsList) => {
|
|
13824
|
+
if (stopped) return target.apply(thisArg, argumentsList);
|
|
13703
13825
|
const [text] = argumentsList;
|
|
13704
13826
|
const { id, styleId } = getIdAndStyleId(
|
|
13705
13827
|
thisArg,
|
|
@@ -13717,13 +13839,16 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
|
|
|
13717
13839
|
}
|
|
13718
13840
|
)
|
|
13719
13841
|
});
|
|
13842
|
+
win.CSSStyleSheet.prototype.replace = replaceProxy;
|
|
13720
13843
|
}
|
|
13721
13844
|
let replaceSync;
|
|
13845
|
+
let replaceSyncProxy;
|
|
13722
13846
|
if (win.CSSStyleSheet.prototype.replaceSync) {
|
|
13723
13847
|
replaceSync = win.CSSStyleSheet.prototype.replaceSync;
|
|
13724
|
-
|
|
13848
|
+
replaceSyncProxy = new Proxy(replaceSync, {
|
|
13725
13849
|
apply: callbackWrapper(
|
|
13726
13850
|
(target, thisArg, argumentsList) => {
|
|
13851
|
+
if (stopped) return target.apply(thisArg, argumentsList);
|
|
13727
13852
|
const [text] = argumentsList;
|
|
13728
13853
|
const { id, styleId } = getIdAndStyleId(
|
|
13729
13854
|
thisArg,
|
|
@@ -13741,6 +13866,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
|
|
|
13741
13866
|
}
|
|
13742
13867
|
)
|
|
13743
13868
|
});
|
|
13869
|
+
win.CSSStyleSheet.prototype.replaceSync = replaceSyncProxy;
|
|
13744
13870
|
}
|
|
13745
13871
|
const supportedNestedCSSRuleTypes = {};
|
|
13746
13872
|
if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
|
|
@@ -13757,6 +13883,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
|
|
|
13757
13883
|
}
|
|
13758
13884
|
}
|
|
13759
13885
|
const unmodifiedFunctions = {};
|
|
13886
|
+
const nestedProxies = {};
|
|
13760
13887
|
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
13761
13888
|
unmodifiedFunctions[typeKey] = {
|
|
13762
13889
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -13764,11 +13891,13 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
|
|
|
13764
13891
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
13765
13892
|
deleteRule: type.prototype.deleteRule
|
|
13766
13893
|
};
|
|
13767
|
-
|
|
13894
|
+
nestedProxies[typeKey] = {};
|
|
13895
|
+
nestedProxies[typeKey].insertRule = new Proxy(
|
|
13768
13896
|
unmodifiedFunctions[typeKey].insertRule,
|
|
13769
13897
|
{
|
|
13770
13898
|
apply: callbackWrapper(
|
|
13771
13899
|
(target, thisArg, argumentsList) => {
|
|
13900
|
+
if (stopped) return target.apply(thisArg, argumentsList);
|
|
13772
13901
|
const [rule2, index2] = argumentsList;
|
|
13773
13902
|
const { id, styleId } = getIdAndStyleId(
|
|
13774
13903
|
thisArg.parentStyleSheet,
|
|
@@ -13796,11 +13925,12 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
|
|
|
13796
13925
|
)
|
|
13797
13926
|
}
|
|
13798
13927
|
);
|
|
13799
|
-
|
|
13928
|
+
nestedProxies[typeKey].deleteRule = new Proxy(
|
|
13800
13929
|
unmodifiedFunctions[typeKey].deleteRule,
|
|
13801
13930
|
{
|
|
13802
13931
|
apply: callbackWrapper(
|
|
13803
13932
|
(target, thisArg, argumentsList) => {
|
|
13933
|
+
if (stopped) return target.apply(thisArg, argumentsList);
|
|
13804
13934
|
const [index2] = argumentsList;
|
|
13805
13935
|
const { id, styleId } = getIdAndStyleId(
|
|
13806
13936
|
thisArg.parentStyleSheet,
|
|
@@ -13821,15 +13951,148 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM
|
|
|
13821
13951
|
)
|
|
13822
13952
|
}
|
|
13823
13953
|
);
|
|
13954
|
+
type.prototype.insertRule = nestedProxies[typeKey].insertRule;
|
|
13955
|
+
type.prototype.deleteRule = nestedProxies[typeKey].deleteRule;
|
|
13824
13956
|
});
|
|
13957
|
+
const captureIsHealthy = () => {
|
|
13958
|
+
probing = true;
|
|
13959
|
+
probeInsertObserved = false;
|
|
13960
|
+
probeDeleteObserved = false;
|
|
13961
|
+
try {
|
|
13962
|
+
const probe = probeSheet != null ? probeSheet : probeSheet = new win.CSSStyleSheet();
|
|
13963
|
+
probe.insertRule(":root {}", 0);
|
|
13964
|
+
probe.deleteRule(0);
|
|
13965
|
+
} catch (error) {
|
|
13966
|
+
return {
|
|
13967
|
+
insertRule: win.CSSStyleSheet.prototype.insertRule === insertRuleProxy,
|
|
13968
|
+
deleteRule: win.CSSStyleSheet.prototype.deleteRule === deleteRuleProxy
|
|
13969
|
+
};
|
|
13970
|
+
} finally {
|
|
13971
|
+
probing = false;
|
|
13972
|
+
}
|
|
13973
|
+
return {
|
|
13974
|
+
insertRule: probeInsertObserved,
|
|
13975
|
+
deleteRule: probeDeleteObserved
|
|
13976
|
+
};
|
|
13977
|
+
};
|
|
13978
|
+
let repatchAttempts = 0;
|
|
13979
|
+
const repatch = (health) => {
|
|
13980
|
+
if (repatchAttempts >= MAX_CSSOM_REPATCH_ATTEMPTS) return;
|
|
13981
|
+
repatchAttempts += 1;
|
|
13982
|
+
if (!health.insertRule) {
|
|
13983
|
+
restoreInsertRuleTo = win.CSSStyleSheet.prototype.insertRule;
|
|
13984
|
+
insertRuleProxy = patchInsertRule(restoreInsertRuleTo);
|
|
13985
|
+
win.CSSStyleSheet.prototype.insertRule = insertRuleProxy;
|
|
13986
|
+
}
|
|
13987
|
+
if (!health.deleteRule) {
|
|
13988
|
+
restoreDeleteRuleTo = win.CSSStyleSheet.prototype.deleteRule;
|
|
13989
|
+
deleteRuleProxy = patchDeleteRule(restoreDeleteRuleTo);
|
|
13990
|
+
win.CSSStyleSheet.prototype.deleteRule = deleteRuleProxy;
|
|
13991
|
+
}
|
|
13992
|
+
};
|
|
13993
|
+
const resyncCssomStyleSheets = (trusted) => {
|
|
13994
|
+
for (let i2 = 0; i2 < doc.styleSheets.length; i2++) {
|
|
13995
|
+
const sheet = doc.styleSheets[i2];
|
|
13996
|
+
if (unreconcilableSheets.has(sheet)) continue;
|
|
13997
|
+
const owner = sheet.ownerNode;
|
|
13998
|
+
if (!owner || toLowerCase(owner.nodeName) !== "style") continue;
|
|
13999
|
+
if ((owner.textContent || "").trim().length) continue;
|
|
14000
|
+
const id = mirror2.getId(owner);
|
|
14001
|
+
if (!id || id === -1) continue;
|
|
14002
|
+
let rules2;
|
|
14003
|
+
try {
|
|
14004
|
+
rules2 = sheet.cssRules;
|
|
14005
|
+
} catch (error) {
|
|
14006
|
+
continue;
|
|
14007
|
+
}
|
|
14008
|
+
const live = rules2.length;
|
|
14009
|
+
let state = reportedRuleCounts.get(sheet);
|
|
14010
|
+
if (!state) {
|
|
14011
|
+
if (Array.from(rules2).some((rule2) => isCSSImportRule(rule2))) {
|
|
14012
|
+
unreconcilableSheets.add(sheet);
|
|
14013
|
+
continue;
|
|
14014
|
+
}
|
|
14015
|
+
state = { reported: live, everSeen: live };
|
|
14016
|
+
reportedRuleCounts.set(sheet, state);
|
|
14017
|
+
if (trusted) continue;
|
|
14018
|
+
replaceReplayerCopy(id, state, rules2);
|
|
14019
|
+
continue;
|
|
14020
|
+
}
|
|
14021
|
+
state.everSeen = Math.max(state.everSeen, live);
|
|
14022
|
+
if (live === state.reported) continue;
|
|
14023
|
+
if (live > state.reported) {
|
|
14024
|
+
const adds = [];
|
|
14025
|
+
for (let index2 = state.reported; index2 < live; index2++) {
|
|
14026
|
+
adds.push({ rule: rules2[index2].cssText, index: index2 });
|
|
14027
|
+
}
|
|
14028
|
+
styleSheetRuleCb({ id, adds });
|
|
14029
|
+
state.reported = live;
|
|
14030
|
+
} else {
|
|
14031
|
+
replaceReplayerCopy(id, state, rules2);
|
|
14032
|
+
}
|
|
14033
|
+
}
|
|
14034
|
+
};
|
|
14035
|
+
function replaceReplayerCopy(id, state, rules2) {
|
|
14036
|
+
const removes = [];
|
|
14037
|
+
for (let index2 = state.everSeen - 1; index2 >= 0; index2--) {
|
|
14038
|
+
removes.push({ index: index2 });
|
|
14039
|
+
}
|
|
14040
|
+
if (removes.length) styleSheetRuleCb({ id, removes });
|
|
14041
|
+
styleSheetRuleCb({
|
|
14042
|
+
id,
|
|
14043
|
+
adds: Array.from(rules2, (rule2, index2) => ({
|
|
14044
|
+
rule: rule2.cssText,
|
|
14045
|
+
index: index2
|
|
14046
|
+
}))
|
|
14047
|
+
});
|
|
14048
|
+
state.reported = rules2.length;
|
|
14049
|
+
state.everSeen = rules2.length;
|
|
14050
|
+
}
|
|
14051
|
+
let resyncTimer;
|
|
14052
|
+
if (styleSheetResyncInterval > 0) {
|
|
14053
|
+
resyncTimer = win.setInterval(
|
|
14054
|
+
callbackWrapper(() => {
|
|
14055
|
+
const health = captureIsHealthy();
|
|
14056
|
+
const healthy = health.insertRule && health.deleteRule;
|
|
14057
|
+
if (!healthy) repatch(health);
|
|
14058
|
+
resyncCssomStyleSheets(healthy);
|
|
14059
|
+
}),
|
|
14060
|
+
styleSheetResyncInterval
|
|
14061
|
+
);
|
|
14062
|
+
}
|
|
13825
14063
|
return callbackWrapper(() => {
|
|
13826
|
-
win.
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
14064
|
+
if (resyncTimer !== void 0) win.clearInterval(resyncTimer);
|
|
14065
|
+
stopped = true;
|
|
14066
|
+
const proto = win.CSSStyleSheet.prototype;
|
|
14067
|
+
restorePatchedMethod(
|
|
14068
|
+
proto,
|
|
14069
|
+
"insertRule",
|
|
14070
|
+
insertRuleProxy,
|
|
14071
|
+
restoreInsertRuleTo
|
|
14072
|
+
);
|
|
14073
|
+
restorePatchedMethod(
|
|
14074
|
+
proto,
|
|
14075
|
+
"deleteRule",
|
|
14076
|
+
deleteRuleProxy,
|
|
14077
|
+
restoreDeleteRuleTo
|
|
14078
|
+
);
|
|
14079
|
+
restorePatchedMethod(proto, "addRule", addRuleShim, addRule);
|
|
14080
|
+
restorePatchedMethod(proto, "removeRule", removeRuleShim, removeRule);
|
|
14081
|
+
replaceProxy && restorePatchedMethod(proto, "replace", replaceProxy, replace);
|
|
14082
|
+
replaceSyncProxy && restorePatchedMethod(proto, "replaceSync", replaceSyncProxy, replaceSync);
|
|
13830
14083
|
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
13831
|
-
|
|
13832
|
-
|
|
14084
|
+
restorePatchedMethod(
|
|
14085
|
+
type.prototype,
|
|
14086
|
+
"insertRule",
|
|
14087
|
+
nestedProxies[typeKey].insertRule,
|
|
14088
|
+
unmodifiedFunctions[typeKey].insertRule
|
|
14089
|
+
);
|
|
14090
|
+
restorePatchedMethod(
|
|
14091
|
+
type.prototype,
|
|
14092
|
+
"deleteRule",
|
|
14093
|
+
nestedProxies[typeKey].deleteRule,
|
|
14094
|
+
unmodifiedFunctions[typeKey].deleteRule
|
|
14095
|
+
);
|
|
13833
14096
|
});
|
|
13834
14097
|
});
|
|
13835
14098
|
}
|
|
@@ -15595,6 +15858,7 @@ function record(options = {}) {
|
|
|
15595
15858
|
keepIframeSrcFn = () => false,
|
|
15596
15859
|
privacySetting = "default",
|
|
15597
15860
|
ignoreCSSAttributes = /* @__PURE__ */ new Set([]),
|
|
15861
|
+
styleSheetResyncInterval = 2e3,
|
|
15598
15862
|
errorHandler: errorHandler2,
|
|
15599
15863
|
logger
|
|
15600
15864
|
} = options;
|
|
@@ -15957,6 +16221,7 @@ function record(options = {}) {
|
|
|
15957
16221
|
processedNodeManager,
|
|
15958
16222
|
canvasManager,
|
|
15959
16223
|
ignoreCSSAttributes,
|
|
16224
|
+
styleSheetResyncInterval,
|
|
15960
16225
|
privacySetting,
|
|
15961
16226
|
plugins: ((_a3 = plugins == null ? void 0 : plugins.filter((p) => p.observer)) == null ? void 0 : _a3.map((p) => ({
|
|
15962
16227
|
observer: p.observer,
|
|
@@ -16841,12 +17106,36 @@ function variableListFor(ctx, ctor) {
|
|
|
16841
17106
|
}
|
|
16842
17107
|
return contextMap.get(ctor);
|
|
16843
17108
|
}
|
|
16844
|
-
|
|
17109
|
+
const canvasArgConstructors = /* @__PURE__ */ new Set([
|
|
17110
|
+
"Int8Array",
|
|
17111
|
+
"Int16Array",
|
|
17112
|
+
"Int32Array",
|
|
17113
|
+
"Uint8Array",
|
|
17114
|
+
"Uint8ClampedArray",
|
|
17115
|
+
"Uint16Array",
|
|
17116
|
+
"Uint32Array",
|
|
17117
|
+
"Float32Array",
|
|
17118
|
+
"Float64Array",
|
|
17119
|
+
"DataView",
|
|
17120
|
+
"ImageData",
|
|
17121
|
+
// normally serialized as base64, but reachable in `args` form through
|
|
17122
|
+
// recordings made by older clients and through nested `DataView` args.
|
|
17123
|
+
"ArrayBuffer",
|
|
17124
|
+
// wraps nested args in recordings made by older clients — see the
|
|
17125
|
+
// `preloadAllImages` tests for the shape.
|
|
17126
|
+
"Array"
|
|
17127
|
+
]);
|
|
17128
|
+
function deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist = false) {
|
|
16845
17129
|
return async (arg) => {
|
|
16846
17130
|
if (arg && typeof arg === "object" && "rr_type" in arg) {
|
|
16847
17131
|
if (preload) preload.isUnchanged = false;
|
|
16848
17132
|
if (arg.rr_type === "ImageBitmap" && "args" in arg) {
|
|
16849
|
-
const args = await deserializeArg(
|
|
17133
|
+
const args = await deserializeArg(
|
|
17134
|
+
imageMap,
|
|
17135
|
+
ctx,
|
|
17136
|
+
preload,
|
|
17137
|
+
enforceCanvasArgAllowlist
|
|
17138
|
+
)(arg.args);
|
|
16850
17139
|
return await createImageBitmap.apply(null, args);
|
|
16851
17140
|
} else if ("index" in arg) {
|
|
16852
17141
|
if (preload || ctx === null) return arg;
|
|
@@ -16854,10 +17143,18 @@ function deserializeArg(imageMap, ctx, preload) {
|
|
|
16854
17143
|
return variableListFor(ctx, name)[index2];
|
|
16855
17144
|
} else if ("args" in arg) {
|
|
16856
17145
|
const { rr_type: name, args } = arg;
|
|
17146
|
+
if (enforceCanvasArgAllowlist && !canvasArgConstructors.has(name)) {
|
|
17147
|
+
console.warn(
|
|
17148
|
+
`[replayer] refusing to construct canvas arg of unknown type: ${name}`
|
|
17149
|
+
);
|
|
17150
|
+
return null;
|
|
17151
|
+
}
|
|
16857
17152
|
const ctor = window[name];
|
|
16858
17153
|
return new ctor(
|
|
16859
17154
|
...await Promise.all(
|
|
16860
|
-
args.map(
|
|
17155
|
+
args.map(
|
|
17156
|
+
deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist)
|
|
17157
|
+
)
|
|
16861
17158
|
)
|
|
16862
17159
|
);
|
|
16863
17160
|
} else if ("base64" in arg) {
|
|
@@ -16874,7 +17171,9 @@ function deserializeArg(imageMap, ctx, preload) {
|
|
|
16874
17171
|
}
|
|
16875
17172
|
} else if ("data" in arg && arg.rr_type === "Blob") {
|
|
16876
17173
|
const blobContents = await Promise.all(
|
|
16877
|
-
arg.data.map(
|
|
17174
|
+
arg.data.map(
|
|
17175
|
+
deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist)
|
|
17176
|
+
)
|
|
16878
17177
|
);
|
|
16879
17178
|
const blob2 = new Blob(blobContents, {
|
|
16880
17179
|
type: arg.type
|
|
@@ -16883,7 +17182,9 @@ function deserializeArg(imageMap, ctx, preload) {
|
|
|
16883
17182
|
}
|
|
16884
17183
|
} else if (Array.isArray(arg)) {
|
|
16885
17184
|
const result2 = await Promise.all(
|
|
16886
|
-
arg.map(
|
|
17185
|
+
arg.map(
|
|
17186
|
+
deserializeArg(imageMap, ctx, preload, enforceCanvasArgAllowlist)
|
|
17187
|
+
)
|
|
16887
17188
|
);
|
|
16888
17189
|
return result2;
|
|
16889
17190
|
}
|
|
@@ -16924,7 +17225,8 @@ async function webglMutation({
|
|
|
16924
17225
|
target,
|
|
16925
17226
|
type,
|
|
16926
17227
|
imageMap,
|
|
16927
|
-
errorHandler: errorHandler2
|
|
17228
|
+
errorHandler: errorHandler2,
|
|
17229
|
+
enforceCanvasArgAllowlist
|
|
16928
17230
|
}) {
|
|
16929
17231
|
try {
|
|
16930
17232
|
const ctx = getContext(target, type);
|
|
@@ -16935,7 +17237,9 @@ async function webglMutation({
|
|
|
16935
17237
|
}
|
|
16936
17238
|
const original = ctx[mutation.property];
|
|
16937
17239
|
const args = await Promise.all(
|
|
16938
|
-
mutation.args.map(
|
|
17240
|
+
mutation.args.map(
|
|
17241
|
+
deserializeArg(imageMap, ctx, void 0, enforceCanvasArgAllowlist)
|
|
17242
|
+
)
|
|
16939
17243
|
);
|
|
16940
17244
|
const result2 = original.apply(ctx, args);
|
|
16941
17245
|
saveToWebGLVarMap(ctx, result2);
|
|
@@ -16950,7 +17254,8 @@ async function canvasMutation$1({
|
|
|
16950
17254
|
mutations,
|
|
16951
17255
|
target,
|
|
16952
17256
|
imageMap,
|
|
16953
|
-
errorHandler: errorHandler2
|
|
17257
|
+
errorHandler: errorHandler2,
|
|
17258
|
+
enforceCanvasArgAllowlist
|
|
16954
17259
|
}) {
|
|
16955
17260
|
const ctx = target.getContext("2d");
|
|
16956
17261
|
if (!ctx) {
|
|
@@ -16960,7 +17265,11 @@ async function canvasMutation$1({
|
|
|
16960
17265
|
wrapCanvasContextDrawImage(ctx);
|
|
16961
17266
|
const mutationArgsPromises = mutations.map(
|
|
16962
17267
|
async (mutation) => {
|
|
16963
|
-
return Promise.all(
|
|
17268
|
+
return Promise.all(
|
|
17269
|
+
mutation.args.map(
|
|
17270
|
+
deserializeArg(imageMap, ctx, void 0, enforceCanvasArgAllowlist)
|
|
17271
|
+
)
|
|
17272
|
+
);
|
|
16964
17273
|
}
|
|
16965
17274
|
);
|
|
16966
17275
|
const args = await Promise.all(mutationArgsPromises);
|
|
@@ -16990,7 +17299,8 @@ async function canvasMutation({
|
|
|
16990
17299
|
target,
|
|
16991
17300
|
imageMap,
|
|
16992
17301
|
canvasEventMap,
|
|
16993
|
-
errorHandler: errorHandler2
|
|
17302
|
+
errorHandler: errorHandler2,
|
|
17303
|
+
enforceCanvasArgAllowlist
|
|
16994
17304
|
}) {
|
|
16995
17305
|
try {
|
|
16996
17306
|
const precomputedMutation = canvasEventMap.get(event) || mutation;
|
|
@@ -17003,7 +17313,8 @@ async function canvasMutation({
|
|
|
17003
17313
|
type: mutation.type,
|
|
17004
17314
|
target,
|
|
17005
17315
|
imageMap,
|
|
17006
|
-
errorHandler: errorHandler2
|
|
17316
|
+
errorHandler: errorHandler2,
|
|
17317
|
+
enforceCanvasArgAllowlist
|
|
17007
17318
|
});
|
|
17008
17319
|
}
|
|
17009
17320
|
return;
|
|
@@ -17013,7 +17324,8 @@ async function canvasMutation({
|
|
|
17013
17324
|
mutations: commands,
|
|
17014
17325
|
target,
|
|
17015
17326
|
imageMap,
|
|
17016
|
-
errorHandler: errorHandler2
|
|
17327
|
+
errorHandler: errorHandler2,
|
|
17328
|
+
enforceCanvasArgAllowlist
|
|
17017
17329
|
});
|
|
17018
17330
|
} catch (error) {
|
|
17019
17331
|
errorHandler2(mutation, error);
|
|
@@ -17449,6 +17761,7 @@ class Replayer {
|
|
|
17449
17761
|
insertStyleRules: [],
|
|
17450
17762
|
triggerFocus: true,
|
|
17451
17763
|
UNSAFE_replayCanvas: false,
|
|
17764
|
+
enforceCanvasArgAllowlist: false,
|
|
17452
17765
|
pauseAnimation: true,
|
|
17453
17766
|
mouseTail: defaultMouseTailConfig,
|
|
17454
17767
|
useVirtualDom: true,
|
|
@@ -17477,7 +17790,8 @@ class Replayer {
|
|
|
17477
17790
|
target,
|
|
17478
17791
|
imageMap: this.imageMap,
|
|
17479
17792
|
canvasEventMap: this.canvasEventMap,
|
|
17480
|
-
errorHandler: this.warnCanvasMutationFailed.bind(this)
|
|
17793
|
+
errorHandler: this.warnCanvasMutationFailed.bind(this),
|
|
17794
|
+
enforceCanvasArgAllowlist: this.config.enforceCanvasArgAllowlist
|
|
17481
17795
|
});
|
|
17482
17796
|
},
|
|
17483
17797
|
applyInput: this.applyInput.bind(this),
|
|
@@ -18189,7 +18503,14 @@ class Replayer {
|
|
|
18189
18503
|
const commands = await Promise.all(
|
|
18190
18504
|
data.commands.map(async (c2) => {
|
|
18191
18505
|
const args = await Promise.all(
|
|
18192
|
-
c2.args.map(
|
|
18506
|
+
c2.args.map(
|
|
18507
|
+
deserializeArg(
|
|
18508
|
+
this.imageMap,
|
|
18509
|
+
null,
|
|
18510
|
+
status,
|
|
18511
|
+
this.config.enforceCanvasArgAllowlist
|
|
18512
|
+
)
|
|
18513
|
+
)
|
|
18193
18514
|
);
|
|
18194
18515
|
return __spreadProps(__spreadValues({}, c2), { args });
|
|
18195
18516
|
})
|
|
@@ -18198,7 +18519,14 @@ class Replayer {
|
|
|
18198
18519
|
this.canvasEventMap.set(event, __spreadProps(__spreadValues({}, data), { commands }));
|
|
18199
18520
|
} else {
|
|
18200
18521
|
const args = await Promise.all(
|
|
18201
|
-
data.args.map(
|
|
18522
|
+
data.args.map(
|
|
18523
|
+
deserializeArg(
|
|
18524
|
+
this.imageMap,
|
|
18525
|
+
null,
|
|
18526
|
+
status,
|
|
18527
|
+
this.config.enforceCanvasArgAllowlist
|
|
18528
|
+
)
|
|
18529
|
+
)
|
|
18202
18530
|
);
|
|
18203
18531
|
if (status.isUnchanged === false)
|
|
18204
18532
|
this.canvasEventMap.set(event, __spreadProps(__spreadValues({}, data), { args }));
|
|
@@ -18411,7 +18739,8 @@ class Replayer {
|
|
|
18411
18739
|
target,
|
|
18412
18740
|
imageMap: this.imageMap,
|
|
18413
18741
|
canvasEventMap: this.canvasEventMap,
|
|
18414
|
-
errorHandler: this.warnCanvasMutationFailed.bind(this)
|
|
18742
|
+
errorHandler: this.warnCanvasMutationFailed.bind(this),
|
|
18743
|
+
enforceCanvasArgAllowlist: this.config.enforceCanvasArgAllowlist
|
|
18415
18744
|
});
|
|
18416
18745
|
}
|
|
18417
18746
|
break;
|
|
@@ -19128,18 +19457,521 @@ class Replayer {
|
|
|
19128
19457
|
this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);
|
|
19129
19458
|
}
|
|
19130
19459
|
}
|
|
19460
|
+
const RRWEB_EMBEDDED_CHANNEL = "rrweb-embedded";
|
|
19461
|
+
const RRWEB_EMBEDDED_PROTOCOL_VERSION = 1;
|
|
19462
|
+
const SERIALIZABLE_CONFIG_KEYS = [
|
|
19463
|
+
"speed",
|
|
19464
|
+
"maxSpeed",
|
|
19465
|
+
"loadTimeout",
|
|
19466
|
+
"skipInactive",
|
|
19467
|
+
"inactivePeriodThreshold",
|
|
19468
|
+
"showWarning",
|
|
19469
|
+
"showDebug",
|
|
19470
|
+
"blockClass",
|
|
19471
|
+
"liveMode",
|
|
19472
|
+
"insertStyleRules",
|
|
19473
|
+
"triggerFocus",
|
|
19474
|
+
"UNSAFE_replayCanvas",
|
|
19475
|
+
"enforceCanvasArgAllowlist",
|
|
19476
|
+
"cspContent",
|
|
19477
|
+
"pauseAnimation",
|
|
19478
|
+
"mouseTail",
|
|
19479
|
+
"useVirtualDom",
|
|
19480
|
+
"inactiveThreshold",
|
|
19481
|
+
"inactiveSkipTime"
|
|
19482
|
+
];
|
|
19483
|
+
function pickSerializableConfig(config) {
|
|
19484
|
+
const out = {};
|
|
19485
|
+
if (config && typeof config === "object") {
|
|
19486
|
+
for (const key of SERIALIZABLE_CONFIG_KEYS) {
|
|
19487
|
+
const value = config[key];
|
|
19488
|
+
if (value !== void 0 && typeof value !== "function") {
|
|
19489
|
+
out[key] = value;
|
|
19490
|
+
}
|
|
19491
|
+
}
|
|
19492
|
+
}
|
|
19493
|
+
return out;
|
|
19494
|
+
}
|
|
19495
|
+
function wrap(message) {
|
|
19496
|
+
return {
|
|
19497
|
+
channel: RRWEB_EMBEDDED_CHANNEL,
|
|
19498
|
+
version: RRWEB_EMBEDDED_PROTOCOL_VERSION,
|
|
19499
|
+
message
|
|
19500
|
+
};
|
|
19501
|
+
}
|
|
19502
|
+
function isEnvelope(data) {
|
|
19503
|
+
if (!data || typeof data !== "object") return false;
|
|
19504
|
+
const e2 = data;
|
|
19505
|
+
return e2.channel === RRWEB_EMBEDDED_CHANNEL && e2.version === RRWEB_EMBEDDED_PROTOCOL_VERSION && !!e2.message && typeof e2.message === "object" && typeof e2.message.type === "string";
|
|
19506
|
+
}
|
|
19507
|
+
const PAYLOAD_EVENTS = /* @__PURE__ */ new Set([
|
|
19508
|
+
ReplayerEvents.Resize,
|
|
19509
|
+
ReplayerEvents.EventCast,
|
|
19510
|
+
ReplayerEvents.CustomEvent
|
|
19511
|
+
]);
|
|
19512
|
+
class EmbeddedReplayerHost {
|
|
19513
|
+
constructor(options = {}) {
|
|
19514
|
+
var _a2, _b, _c, _d, _e;
|
|
19515
|
+
__publicField(this, "root");
|
|
19516
|
+
__publicField(this, "parentWindow");
|
|
19517
|
+
__publicField(this, "timeUpdateIntervalMs");
|
|
19518
|
+
__publicField(this, "expectedParentOrigin");
|
|
19519
|
+
__publicField(this, "replayer", null);
|
|
19520
|
+
__publicField(this, "playing", false);
|
|
19521
|
+
__publicField(this, "timer", null);
|
|
19522
|
+
__publicField(this, "started", false);
|
|
19523
|
+
__publicField(this, "layout", null);
|
|
19524
|
+
__publicField(this, "onMessage", (event) => {
|
|
19525
|
+
if (event.source !== this.parentWindow) return;
|
|
19526
|
+
if (this.expectedParentOrigin === null) return;
|
|
19527
|
+
if (event.origin !== this.expectedParentOrigin) return;
|
|
19528
|
+
if (!isEnvelope(event.data)) return;
|
|
19529
|
+
try {
|
|
19530
|
+
this.handle(event.data.message);
|
|
19531
|
+
} catch (err) {
|
|
19532
|
+
this.post({
|
|
19533
|
+
type: "error",
|
|
19534
|
+
message: err instanceof Error ? err.message : String(err)
|
|
19535
|
+
});
|
|
19536
|
+
}
|
|
19537
|
+
});
|
|
19538
|
+
this.root = (_a2 = options.root) != null ? _a2 : document.body;
|
|
19539
|
+
this.parentWindow = (_b = options.parentWindow) != null ? _b : window.parent;
|
|
19540
|
+
this.timeUpdateIntervalMs = (_c = options.timeUpdateIntervalMs) != null ? _c : 50;
|
|
19541
|
+
this.expectedParentOrigin = (_e = (_d = options.expectedParentOrigin) != null ? _d : new URLSearchParams(location.search).get("parentOrigin")) != null ? _e : null;
|
|
19542
|
+
}
|
|
19543
|
+
/** Install the message listener and announce readiness to the parent. */
|
|
19544
|
+
start() {
|
|
19545
|
+
if (this.started) return;
|
|
19546
|
+
this.started = true;
|
|
19547
|
+
if (this.expectedParentOrigin === null) {
|
|
19548
|
+
console.warn(
|
|
19549
|
+
"[rrweb-embedded] no parentOrigin configured; all incoming messages will be ignored"
|
|
19550
|
+
);
|
|
19551
|
+
}
|
|
19552
|
+
window.addEventListener("message", this.onMessage);
|
|
19553
|
+
this.post({ type: "ready" });
|
|
19554
|
+
}
|
|
19555
|
+
/** Tear everything down (also invoked on a `destroy` command). */
|
|
19556
|
+
stop() {
|
|
19557
|
+
var _a2;
|
|
19558
|
+
window.removeEventListener("message", this.onMessage);
|
|
19559
|
+
this.setPlaying(false);
|
|
19560
|
+
(_a2 = this.replayer) == null ? void 0 : _a2.destroy();
|
|
19561
|
+
this.replayer = null;
|
|
19562
|
+
this.started = false;
|
|
19563
|
+
}
|
|
19564
|
+
handle(command) {
|
|
19565
|
+
var _a3, _b2, _c2;
|
|
19566
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
19567
|
+
switch (command.type) {
|
|
19568
|
+
case "ping":
|
|
19569
|
+
this.post({ type: "ready" });
|
|
19570
|
+
return;
|
|
19571
|
+
case "init":
|
|
19572
|
+
this.init(command.events, command.config, command.autoplay);
|
|
19573
|
+
return;
|
|
19574
|
+
case "play":
|
|
19575
|
+
(_a2 = this.replayer) == null ? void 0 : _a2.play((_a3 = command.timeOffset) != null ? _a3 : 0);
|
|
19576
|
+
this.setPlaying(true);
|
|
19577
|
+
return;
|
|
19578
|
+
case "pause":
|
|
19579
|
+
(_b = this.replayer) == null ? void 0 : _b.pause(command.timeOffset);
|
|
19580
|
+
this.setPlaying(false);
|
|
19581
|
+
this.postTime();
|
|
19582
|
+
return;
|
|
19583
|
+
case "resume":
|
|
19584
|
+
(_c = this.replayer) == null ? void 0 : _c.resume((_b2 = command.timeOffset) != null ? _b2 : 0);
|
|
19585
|
+
this.setPlaying(true);
|
|
19586
|
+
return;
|
|
19587
|
+
case "setLayout":
|
|
19588
|
+
this.layout = {
|
|
19589
|
+
scale: command.scale,
|
|
19590
|
+
anchor: (_c2 = command.anchor) != null ? _c2 : "center"
|
|
19591
|
+
};
|
|
19592
|
+
this.applyLayout();
|
|
19593
|
+
this.postDimensions();
|
|
19594
|
+
return;
|
|
19595
|
+
case "setConfig":
|
|
19596
|
+
(_d = this.replayer) == null ? void 0 : _d.setConfig(pickSerializableConfig(command.config));
|
|
19597
|
+
return;
|
|
19598
|
+
case "replaceEvents":
|
|
19599
|
+
if (this.replayer) {
|
|
19600
|
+
this.replayer.replaceEvents(command.events);
|
|
19601
|
+
this.postInitialized();
|
|
19602
|
+
}
|
|
19603
|
+
return;
|
|
19604
|
+
case "addEvent":
|
|
19605
|
+
(_e = this.replayer) == null ? void 0 : _e.addEvent(command.event);
|
|
19606
|
+
return;
|
|
19607
|
+
case "enableInteract":
|
|
19608
|
+
(_f = this.replayer) == null ? void 0 : _f.enableInteract();
|
|
19609
|
+
return;
|
|
19610
|
+
case "disableInteract":
|
|
19611
|
+
(_g = this.replayer) == null ? void 0 : _g.disableInteract();
|
|
19612
|
+
return;
|
|
19613
|
+
case "destroy":
|
|
19614
|
+
this.stop();
|
|
19615
|
+
return;
|
|
19616
|
+
}
|
|
19617
|
+
}
|
|
19618
|
+
init(events, config, autoplay) {
|
|
19619
|
+
if (this.replayer) {
|
|
19620
|
+
this.setPlaying(false);
|
|
19621
|
+
this.replayer.destroy();
|
|
19622
|
+
}
|
|
19623
|
+
const replayerConfig = __spreadProps(__spreadValues({}, pickSerializableConfig(config)), {
|
|
19624
|
+
root: this.root
|
|
19625
|
+
});
|
|
19626
|
+
this.replayer = new Replayer(events, replayerConfig);
|
|
19627
|
+
this.wireEvents(this.replayer);
|
|
19628
|
+
this.applyLayout();
|
|
19629
|
+
this.postInitialized();
|
|
19630
|
+
this.postDimensions();
|
|
19631
|
+
if (autoplay) {
|
|
19632
|
+
this.replayer.play(0);
|
|
19633
|
+
this.setPlaying(true);
|
|
19634
|
+
}
|
|
19635
|
+
}
|
|
19636
|
+
/**
|
|
19637
|
+
* Translate the parent's layout intent into styles on the replay wrapper.
|
|
19638
|
+
*
|
|
19639
|
+
* Mirrors what an embedder would otherwise apply from its own stylesheet:
|
|
19640
|
+
* `transform-origin: top left` with `left: 50%` to center horizontally, and
|
|
19641
|
+
* either `top: 50%` + a -50% Y translate to center vertically, or `top: 0`
|
|
19642
|
+
* with no Y translate to anchor at the top edge.
|
|
19643
|
+
*/
|
|
19644
|
+
applyLayout() {
|
|
19645
|
+
var _a2;
|
|
19646
|
+
const wrapper = (_a2 = this.replayer) == null ? void 0 : _a2.wrapper;
|
|
19647
|
+
if (!wrapper || !this.layout) return;
|
|
19648
|
+
const { scale, anchor } = this.layout;
|
|
19649
|
+
const top = anchor === "top";
|
|
19650
|
+
wrapper.style.position = "absolute";
|
|
19651
|
+
wrapper.style.transformOrigin = "top left";
|
|
19652
|
+
wrapper.style.left = "50%";
|
|
19653
|
+
wrapper.style.top = top ? "0" : "50%";
|
|
19654
|
+
wrapper.style.transform = top ? `scale(${scale}) translate(-50%, 0)` : `scale(${scale}) translate(-50%, -50%)`;
|
|
19655
|
+
}
|
|
19656
|
+
/** Report the wrapper's rendered geometry; the parent cannot measure it. */
|
|
19657
|
+
postDimensions() {
|
|
19658
|
+
var _a2;
|
|
19659
|
+
const wrapper = (_a2 = this.replayer) == null ? void 0 : _a2.wrapper;
|
|
19660
|
+
if (!wrapper) return;
|
|
19661
|
+
const rect = wrapper.getBoundingClientRect();
|
|
19662
|
+
this.post({
|
|
19663
|
+
type: "dimensions",
|
|
19664
|
+
width: rect.width,
|
|
19665
|
+
height: rect.height,
|
|
19666
|
+
top: rect.top,
|
|
19667
|
+
left: rect.left
|
|
19668
|
+
});
|
|
19669
|
+
}
|
|
19670
|
+
/** Push the stable getters (metadata, activity intervals) to the parent. */
|
|
19671
|
+
postInitialized() {
|
|
19672
|
+
if (!this.replayer) return;
|
|
19673
|
+
this.post({
|
|
19674
|
+
type: "initialized",
|
|
19675
|
+
metadata: this.replayer.getMetaData(),
|
|
19676
|
+
activityIntervals: this.replayer.getActivityIntervals()
|
|
19677
|
+
});
|
|
19678
|
+
}
|
|
19679
|
+
wireEvents(replayer) {
|
|
19680
|
+
for (const name of Object.values(ReplayerEvents)) {
|
|
19681
|
+
replayer.on(name, (payload) => {
|
|
19682
|
+
if (name === ReplayerEvents.Finish) {
|
|
19683
|
+
this.setPlaying(false);
|
|
19684
|
+
this.postTime();
|
|
19685
|
+
}
|
|
19686
|
+
if (name === ReplayerEvents.Resize) {
|
|
19687
|
+
this.postDimensions();
|
|
19688
|
+
}
|
|
19689
|
+
this.post(
|
|
19690
|
+
PAYLOAD_EVENTS.has(name) && payload !== void 0 ? { type: "replayer-event", event: name, payload } : { type: "replayer-event", event: name }
|
|
19691
|
+
);
|
|
19692
|
+
});
|
|
19693
|
+
}
|
|
19694
|
+
}
|
|
19695
|
+
/* --- current-time telemetry ------------------------------------------- */
|
|
19696
|
+
setPlaying(playing) {
|
|
19697
|
+
if (this.playing === playing) return;
|
|
19698
|
+
this.playing = playing;
|
|
19699
|
+
if (playing) this.startTimePump();
|
|
19700
|
+
else this.stopTimePump();
|
|
19701
|
+
}
|
|
19702
|
+
startTimePump() {
|
|
19703
|
+
if (this.timer !== null) return;
|
|
19704
|
+
this.timer = setInterval(() => this.postTime(), this.timeUpdateIntervalMs);
|
|
19705
|
+
}
|
|
19706
|
+
/**
|
|
19707
|
+
* Push the current playback position across the bridge.
|
|
19708
|
+
*
|
|
19709
|
+
* The parent cannot read the position synchronously — it lives in this realm
|
|
19710
|
+
* behind an origin boundary — so the client's `getCurrentTime()` is only ever
|
|
19711
|
+
* as fresh as the last push. While playing, the pump keeps it current. When
|
|
19712
|
+
* playback stops the pump stops too, so the last pumped value would be up to
|
|
19713
|
+
* one interval stale; callers that seek from it (`play(getCurrentTime())` to
|
|
19714
|
+
* resume) would drift backwards. Pausing and finishing therefore push one
|
|
19715
|
+
* final, settled value.
|
|
19716
|
+
*/
|
|
19717
|
+
postTime() {
|
|
19718
|
+
if (!this.replayer) return;
|
|
19719
|
+
this.post({ type: "time", currentTime: this.replayer.getCurrentTime() });
|
|
19720
|
+
}
|
|
19721
|
+
stopTimePump() {
|
|
19722
|
+
if (this.timer !== null) {
|
|
19723
|
+
clearInterval(this.timer);
|
|
19724
|
+
this.timer = null;
|
|
19725
|
+
}
|
|
19726
|
+
}
|
|
19727
|
+
post(message) {
|
|
19728
|
+
var _a2;
|
|
19729
|
+
this.parentWindow.postMessage(
|
|
19730
|
+
wrap(message),
|
|
19731
|
+
(_a2 = this.expectedParentOrigin) != null ? _a2 : "*"
|
|
19732
|
+
);
|
|
19733
|
+
}
|
|
19734
|
+
}
|
|
19735
|
+
function startEmbeddedReplayerHost(options) {
|
|
19736
|
+
const host2 = new EmbeddedReplayerHost(options);
|
|
19737
|
+
host2.start();
|
|
19738
|
+
return host2;
|
|
19739
|
+
}
|
|
19740
|
+
class EmbeddedReplayerClient {
|
|
19741
|
+
constructor(iframe, options = {}) {
|
|
19742
|
+
var _a2;
|
|
19743
|
+
__publicField(this, "iframe");
|
|
19744
|
+
__publicField(this, "hostOrigin");
|
|
19745
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Map());
|
|
19746
|
+
__publicField(this, "metadata", null);
|
|
19747
|
+
__publicField(this, "activityIntervals", []);
|
|
19748
|
+
__publicField(this, "dimensions", null);
|
|
19749
|
+
__publicField(this, "lastCurrentTime", 0);
|
|
19750
|
+
__publicField(this, "ready", false);
|
|
19751
|
+
__publicField(this, "readyResolvers", []);
|
|
19752
|
+
__publicField(this, "disposed", false);
|
|
19753
|
+
__publicField(this, "pending", []);
|
|
19754
|
+
__publicField(this, "onMessage", (event) => {
|
|
19755
|
+
if (event.source !== this.iframe.contentWindow) return;
|
|
19756
|
+
if (!isEnvelope(event.data)) return;
|
|
19757
|
+
this.handle(event.data.message);
|
|
19758
|
+
});
|
|
19759
|
+
this.iframe = iframe;
|
|
19760
|
+
this.hostOrigin = (_a2 = options.hostOrigin) != null ? _a2 : "*";
|
|
19761
|
+
window.addEventListener("message", this.onMessage);
|
|
19762
|
+
this.probe();
|
|
19763
|
+
}
|
|
19764
|
+
/** Resolves once the host iframe has loaded and announced readiness. */
|
|
19765
|
+
whenReady() {
|
|
19766
|
+
if (this.ready) return Promise.resolve();
|
|
19767
|
+
return new Promise((resolve) => this.readyResolvers.push(resolve));
|
|
19768
|
+
}
|
|
19769
|
+
/* --- commands --------------------------------------------------------- */
|
|
19770
|
+
init(events, config, autoplay = false) {
|
|
19771
|
+
this.send({ type: "init", events, config, autoplay });
|
|
19772
|
+
}
|
|
19773
|
+
play(timeOffset) {
|
|
19774
|
+
this.send({ type: "play", timeOffset });
|
|
19775
|
+
}
|
|
19776
|
+
pause(timeOffset) {
|
|
19777
|
+
this.send({ type: "pause", timeOffset });
|
|
19778
|
+
}
|
|
19779
|
+
resume(timeOffset) {
|
|
19780
|
+
this.send({ type: "resume", timeOffset });
|
|
19781
|
+
}
|
|
19782
|
+
setConfig(config) {
|
|
19783
|
+
this.send({ type: "setConfig", config });
|
|
19784
|
+
}
|
|
19785
|
+
/**
|
|
19786
|
+
* Scale and position the replay. Compute `scale` from your own container size
|
|
19787
|
+
* and the recorded viewport, as you would when driving a local `Replayer`;
|
|
19788
|
+
* the host applies it, since the wrapper element is not reachable from here.
|
|
19789
|
+
* The layout is retained across re-inits.
|
|
19790
|
+
*/
|
|
19791
|
+
setLayout(scale, anchor) {
|
|
19792
|
+
this.send({ type: "setLayout", scale, anchor });
|
|
19793
|
+
}
|
|
19794
|
+
replaceEvents(events) {
|
|
19795
|
+
this.send({ type: "replaceEvents", events });
|
|
19796
|
+
}
|
|
19797
|
+
addEvent(event) {
|
|
19798
|
+
this.send({ type: "addEvent", event });
|
|
19799
|
+
}
|
|
19800
|
+
enableInteract() {
|
|
19801
|
+
this.send({ type: "enableInteract" });
|
|
19802
|
+
}
|
|
19803
|
+
disableInteract() {
|
|
19804
|
+
this.send({ type: "disableInteract" });
|
|
19805
|
+
}
|
|
19806
|
+
/** Tear down: destroys the host replayer and detaches the listener. */
|
|
19807
|
+
destroy() {
|
|
19808
|
+
if (this.disposed) return;
|
|
19809
|
+
this.disposed = true;
|
|
19810
|
+
try {
|
|
19811
|
+
this.send({ type: "destroy" });
|
|
19812
|
+
} finally {
|
|
19813
|
+
window.removeEventListener("message", this.onMessage);
|
|
19814
|
+
this.listeners.clear();
|
|
19815
|
+
}
|
|
19816
|
+
}
|
|
19817
|
+
/* --- event surface ---------------------------------------------------- */
|
|
19818
|
+
on(event, listener) {
|
|
19819
|
+
let set = this.listeners.get(event);
|
|
19820
|
+
if (!set) {
|
|
19821
|
+
set = /* @__PURE__ */ new Set();
|
|
19822
|
+
this.listeners.set(event, set);
|
|
19823
|
+
}
|
|
19824
|
+
set.add(listener);
|
|
19825
|
+
}
|
|
19826
|
+
off(event, listener) {
|
|
19827
|
+
var _a2;
|
|
19828
|
+
(_a2 = this.listeners.get(event)) == null ? void 0 : _a2.delete(listener);
|
|
19829
|
+
}
|
|
19830
|
+
/* --- getters ---------------------------------------------------------- */
|
|
19831
|
+
// Cached getters mirroring the local Replayer's synchronous ones. Metadata
|
|
19832
|
+
// and activity intervals arrive on `initialized` (re-sent on replaceEvents);
|
|
19833
|
+
// current time is streamed by the host while playing.
|
|
19834
|
+
/** Last-known current time (pushed by the host while playing). */
|
|
19835
|
+
getCurrentTime() {
|
|
19836
|
+
return this.lastCurrentTime;
|
|
19837
|
+
}
|
|
19838
|
+
getMetaData() {
|
|
19839
|
+
return this.metadata;
|
|
19840
|
+
}
|
|
19841
|
+
getActivityIntervals() {
|
|
19842
|
+
return this.activityIntervals;
|
|
19843
|
+
}
|
|
19844
|
+
/**
|
|
19845
|
+
* Rendered geometry of the replay, in the host document's coordinate space —
|
|
19846
|
+
* the cross-origin stand-in for `replayer.wrapper.getBoundingClientRect()`.
|
|
19847
|
+
* Null until the host has reported it (listen for `'dimensions'`).
|
|
19848
|
+
*/
|
|
19849
|
+
getDimensions() {
|
|
19850
|
+
return this.dimensions;
|
|
19851
|
+
}
|
|
19852
|
+
/* --- internals -------------------------------------------------------- */
|
|
19853
|
+
send(command) {
|
|
19854
|
+
if (!this.ready) {
|
|
19855
|
+
this.pending.push(command);
|
|
19856
|
+
return;
|
|
19857
|
+
}
|
|
19858
|
+
this.postToHost(command);
|
|
19859
|
+
}
|
|
19860
|
+
postToHost(command) {
|
|
19861
|
+
const target = this.iframe.contentWindow;
|
|
19862
|
+
if (!target) return;
|
|
19863
|
+
target.postMessage(wrap(command), this.hostOrigin);
|
|
19864
|
+
}
|
|
19865
|
+
flushPending() {
|
|
19866
|
+
const queued = this.pending;
|
|
19867
|
+
this.pending = [];
|
|
19868
|
+
queued.forEach((command) => this.postToHost(command));
|
|
19869
|
+
}
|
|
19870
|
+
/** Data-free handshake probe; see the note in the constructor. */
|
|
19871
|
+
probe() {
|
|
19872
|
+
var _a2;
|
|
19873
|
+
(_a2 = this.iframe.contentWindow) == null ? void 0 : _a2.postMessage(wrap({ type: "ping" }), "*");
|
|
19874
|
+
}
|
|
19875
|
+
handle(message) {
|
|
19876
|
+
switch (message.type) {
|
|
19877
|
+
case "ready":
|
|
19878
|
+
this.ready = true;
|
|
19879
|
+
this.flushPending();
|
|
19880
|
+
this.readyResolvers.forEach((r2) => r2());
|
|
19881
|
+
this.readyResolvers = [];
|
|
19882
|
+
return;
|
|
19883
|
+
case "initialized":
|
|
19884
|
+
this.metadata = message.metadata;
|
|
19885
|
+
this.activityIntervals = message.activityIntervals;
|
|
19886
|
+
this.emit("initialized", message.metadata);
|
|
19887
|
+
return;
|
|
19888
|
+
case "replayer-event":
|
|
19889
|
+
this.emit(message.event, message.payload);
|
|
19890
|
+
return;
|
|
19891
|
+
case "time":
|
|
19892
|
+
this.lastCurrentTime = message.currentTime;
|
|
19893
|
+
this.emit("time", message.currentTime);
|
|
19894
|
+
return;
|
|
19895
|
+
case "dimensions":
|
|
19896
|
+
this.dimensions = {
|
|
19897
|
+
width: message.width,
|
|
19898
|
+
height: message.height,
|
|
19899
|
+
top: message.top,
|
|
19900
|
+
left: message.left
|
|
19901
|
+
};
|
|
19902
|
+
this.emit("dimensions", this.dimensions);
|
|
19903
|
+
return;
|
|
19904
|
+
case "error":
|
|
19905
|
+
this.emit("error", message.message);
|
|
19906
|
+
return;
|
|
19907
|
+
}
|
|
19908
|
+
}
|
|
19909
|
+
emit(event, payload) {
|
|
19910
|
+
var _a2;
|
|
19911
|
+
(_a2 = this.listeners.get(event)) == null ? void 0 : _a2.forEach((listener) => listener(payload));
|
|
19912
|
+
}
|
|
19913
|
+
}
|
|
19914
|
+
function originOf(url) {
|
|
19915
|
+
try {
|
|
19916
|
+
return new URL(url).origin;
|
|
19917
|
+
} catch (e2) {
|
|
19918
|
+
return "'self'";
|
|
19919
|
+
}
|
|
19920
|
+
}
|
|
19921
|
+
function buildHostDocument(options) {
|
|
19922
|
+
var _a2;
|
|
19923
|
+
const scriptOrigin = originOf(options.scriptUrl);
|
|
19924
|
+
const styleSources = [
|
|
19925
|
+
"'unsafe-inline'",
|
|
19926
|
+
scriptOrigin,
|
|
19927
|
+
...(_a2 = options.extraStyleSources) != null ? _a2 : []
|
|
19928
|
+
].join(" ");
|
|
19929
|
+
const csp = [
|
|
19930
|
+
`default-src 'none'`,
|
|
19931
|
+
`script-src ${scriptOrigin}`,
|
|
19932
|
+
`style-src ${styleSources}`,
|
|
19933
|
+
`img-src * data: blob:`,
|
|
19934
|
+
`font-src * data:`,
|
|
19935
|
+
`media-src * data: blob:`,
|
|
19936
|
+
`frame-src *`,
|
|
19937
|
+
`connect-src 'none'`,
|
|
19938
|
+
`worker-src 'none'`
|
|
19939
|
+
].join("; ");
|
|
19940
|
+
const styleTag = options.styleUrl ? `<link rel="stylesheet" href="${escapeAttr(options.styleUrl)}">` : "";
|
|
19941
|
+
return `<!DOCTYPE html>
|
|
19942
|
+
<html>
|
|
19943
|
+
<head>
|
|
19944
|
+
<meta charset="utf-8">
|
|
19945
|
+
<meta http-equiv="Content-Security-Policy" content="${escapeAttr(csp)}">
|
|
19946
|
+
<style>html,body{margin:0;padding:0;height:100%;overflow:hidden;background:transparent}</style>
|
|
19947
|
+
${styleTag}
|
|
19948
|
+
<script type="module" src="${escapeAttr(options.scriptUrl)}"><\/script>
|
|
19949
|
+
</head>
|
|
19950
|
+
<body></body>
|
|
19951
|
+
</html>`;
|
|
19952
|
+
}
|
|
19953
|
+
function escapeAttr(value) {
|
|
19954
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
19955
|
+
}
|
|
19131
19956
|
const { addCustomEvent } = record;
|
|
19132
19957
|
const { freezePage } = record;
|
|
19133
19958
|
const { takeFullSnapshot } = record;
|
|
19959
|
+
exports.EmbeddedReplayerClient = EmbeddedReplayerClient;
|
|
19960
|
+
exports.EmbeddedReplayerHost = EmbeddedReplayerHost;
|
|
19134
19961
|
exports.EventType = EventType;
|
|
19135
19962
|
exports.IncrementalSource = IncrementalSource;
|
|
19136
19963
|
exports.MouseInteractions = MouseInteractions;
|
|
19964
|
+
exports.RRWEB_EMBEDDED_CHANNEL = RRWEB_EMBEDDED_CHANNEL;
|
|
19965
|
+
exports.RRWEB_EMBEDDED_PROTOCOL_VERSION = RRWEB_EMBEDDED_PROTOCOL_VERSION;
|
|
19137
19966
|
exports.Replayer = Replayer;
|
|
19138
19967
|
exports.ReplayerEvents = ReplayerEvents;
|
|
19139
19968
|
exports.addCustomEvent = addCustomEvent;
|
|
19969
|
+
exports.buildHostDocument = buildHostDocument;
|
|
19140
19970
|
exports.canvasMutation = canvasMutation;
|
|
19141
19971
|
exports.freezePage = freezePage;
|
|
19972
|
+
exports.pickSerializableConfig = pickSerializableConfig;
|
|
19142
19973
|
exports.record = record;
|
|
19974
|
+
exports.startEmbeddedReplayerHost = startEmbeddedReplayerHost;
|
|
19143
19975
|
exports.takeFullSnapshot = takeFullSnapshot;
|
|
19144
19976
|
exports.utils = utils;
|
|
19145
19977
|
;if (typeof module.exports == "object" && typeof exports == "object") {
|