@amplitude/rrweb-player 2.0.0-alpha.38 → 2.0.0-alpha.40
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-player.cjs +261 -87
- package/dist/rrweb-player.cjs.map +1 -1
- package/dist/rrweb-player.js +261 -87
- package/dist/rrweb-player.js.map +1 -1
- package/dist/rrweb-player.umd.cjs +262 -87
- package/dist/rrweb-player.umd.cjs.map +2 -2
- package/dist/rrweb-player.umd.min.cjs +48 -48
- package/dist/rrweb-player.umd.min.cjs.map +3 -3
- package/package.json +4 -4
package/dist/rrweb-player.cjs
CHANGED
|
@@ -5457,7 +5457,29 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
5457
5457
|
}
|
|
5458
5458
|
return false;
|
|
5459
5459
|
}
|
|
5460
|
+
function serializeAdoptedStyleSheets(sheets, onAdoptedStyleSheet, emittedStyleIds) {
|
|
5461
|
+
return Array.from(sheets).map((sheet) => {
|
|
5462
|
+
const styleId = onAdoptedStyleSheet(sheet);
|
|
5463
|
+
let rules2 = [];
|
|
5464
|
+
if (!emittedStyleIds.has(styleId)) {
|
|
5465
|
+
emittedStyleIds.add(styleId);
|
|
5466
|
+
try {
|
|
5467
|
+
rules2 = Array.from(sheet.cssRules, (rule2, index2) => ({
|
|
5468
|
+
rule: stringifyRule(rule2, sheet.href),
|
|
5469
|
+
index: index2
|
|
5470
|
+
}));
|
|
5471
|
+
} catch (e2) {
|
|
5472
|
+
if (e2 instanceof DOMException && e2.name === "SecurityError") ;
|
|
5473
|
+
else {
|
|
5474
|
+
throw e2;
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5478
|
+
return { styleId, rules: rules2 };
|
|
5479
|
+
});
|
|
5480
|
+
}
|
|
5460
5481
|
function serializeNodeWithId(n2, options) {
|
|
5482
|
+
var _a22, _b2;
|
|
5461
5483
|
const {
|
|
5462
5484
|
doc,
|
|
5463
5485
|
mirror: mirror2,
|
|
@@ -5476,6 +5498,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5476
5498
|
inlineImages = false,
|
|
5477
5499
|
recordCanvas = false,
|
|
5478
5500
|
onSerialize,
|
|
5501
|
+
onAdoptedStyleSheet,
|
|
5479
5502
|
onIframeLoad,
|
|
5480
5503
|
iframeLoadTimeout = 5e3,
|
|
5481
5504
|
onStylesheetLoad,
|
|
@@ -5485,6 +5508,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5485
5508
|
cssCaptured = false,
|
|
5486
5509
|
applyBackgroundColorToBlockedElements = false
|
|
5487
5510
|
} = options;
|
|
5511
|
+
const emittedStyleIds = options._emittedStyleIds ?? /* @__PURE__ */ new Set();
|
|
5488
5512
|
let { needsMask } = options;
|
|
5489
5513
|
let { preserveWhiteSpace = true } = options;
|
|
5490
5514
|
if (!needsMask) {
|
|
@@ -5540,8 +5564,26 @@ function serializeNodeWithId(n2, options) {
|
|
|
5540
5564
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
5541
5565
|
delete serializedNode.needBlock;
|
|
5542
5566
|
const shadowRootEl = index$1.shadowRoot(n2);
|
|
5543
|
-
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
5567
|
+
if (shadowRootEl && isNativeShadowDom(shadowRootEl)) {
|
|
5544
5568
|
serializedNode.isShadowHost = true;
|
|
5569
|
+
if (onAdoptedStyleSheet && ((_a22 = shadowRootEl.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
5570
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5571
|
+
shadowRootEl.adoptedStyleSheets,
|
|
5572
|
+
onAdoptedStyleSheet,
|
|
5573
|
+
emittedStyleIds
|
|
5574
|
+
);
|
|
5575
|
+
}
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
if (serializedNode.type === NodeType$3.Document && onAdoptedStyleSheet) {
|
|
5579
|
+
const doc2 = n2;
|
|
5580
|
+
if ((_b2 = doc2.adoptedStyleSheets) == null ? void 0 : _b2.length) {
|
|
5581
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5582
|
+
doc2.adoptedStyleSheets,
|
|
5583
|
+
onAdoptedStyleSheet,
|
|
5584
|
+
emittedStyleIds
|
|
5585
|
+
);
|
|
5586
|
+
}
|
|
5545
5587
|
}
|
|
5546
5588
|
if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
|
|
5547
5589
|
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
|
|
@@ -5567,6 +5609,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
5567
5609
|
recordCanvas,
|
|
5568
5610
|
preserveWhiteSpace,
|
|
5569
5611
|
onSerialize,
|
|
5612
|
+
onAdoptedStyleSheet,
|
|
5613
|
+
_emittedStyleIds: emittedStyleIds,
|
|
5570
5614
|
onIframeLoad,
|
|
5571
5615
|
iframeLoadTimeout,
|
|
5572
5616
|
onStylesheetLoad,
|
|
@@ -5628,6 +5672,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5628
5672
|
recordCanvas,
|
|
5629
5673
|
preserveWhiteSpace,
|
|
5630
5674
|
onSerialize,
|
|
5675
|
+
onAdoptedStyleSheet,
|
|
5631
5676
|
onIframeLoad,
|
|
5632
5677
|
iframeLoadTimeout,
|
|
5633
5678
|
onStylesheetLoad,
|
|
@@ -5707,6 +5752,7 @@ function snapshot(n2, options) {
|
|
|
5707
5752
|
dataURLOptions,
|
|
5708
5753
|
preserveWhiteSpace,
|
|
5709
5754
|
onSerialize,
|
|
5755
|
+
onAdoptedStyleSheet,
|
|
5710
5756
|
onIframeLoad,
|
|
5711
5757
|
iframeLoadTimeout,
|
|
5712
5758
|
onStylesheetLoad,
|
|
@@ -5769,6 +5815,7 @@ function snapshot(n2, options) {
|
|
|
5769
5815
|
recordCanvas,
|
|
5770
5816
|
preserveWhiteSpace,
|
|
5771
5817
|
onSerialize,
|
|
5818
|
+
onAdoptedStyleSheet,
|
|
5772
5819
|
onIframeLoad,
|
|
5773
5820
|
iframeLoadTimeout,
|
|
5774
5821
|
onStylesheetLoad,
|
|
@@ -9834,7 +9881,8 @@ function buildNodeWithSN(n2, options) {
|
|
|
9834
9881
|
skipChild = false,
|
|
9835
9882
|
hackCss = true,
|
|
9836
9883
|
afterAppend,
|
|
9837
|
-
cache
|
|
9884
|
+
cache,
|
|
9885
|
+
scrollNodes
|
|
9838
9886
|
} = options;
|
|
9839
9887
|
if (mirror2.has(n2.id)) {
|
|
9840
9888
|
const nodeInMirror = mirror2.getNode(n2.id);
|
|
@@ -9865,6 +9913,9 @@ function buildNodeWithSN(n2, options) {
|
|
|
9865
9913
|
node2 = doc;
|
|
9866
9914
|
}
|
|
9867
9915
|
mirror2.add(node2, n2);
|
|
9916
|
+
if (scrollNodes && n2.type === NodeType$3.Element && n2.attributes && ("rr_scrollLeft" in n2.attributes || "rr_scrollTop" in n2.attributes)) {
|
|
9917
|
+
scrollNodes.push(node2);
|
|
9918
|
+
}
|
|
9868
9919
|
if ((n2.type === NodeType$3.Document || n2.type === NodeType$3.Element) && !skipChild) {
|
|
9869
9920
|
for (const childN of n2.childNodes) {
|
|
9870
9921
|
const childNode = buildNodeWithSN(childN, {
|
|
@@ -9873,7 +9924,8 @@ function buildNodeWithSN(n2, options) {
|
|
|
9873
9924
|
skipChild: false,
|
|
9874
9925
|
hackCss,
|
|
9875
9926
|
afterAppend,
|
|
9876
|
-
cache
|
|
9927
|
+
cache,
|
|
9928
|
+
scrollNodes
|
|
9877
9929
|
});
|
|
9878
9930
|
if (!childNode) {
|
|
9879
9931
|
console.warn("Failed to rebuild", childN);
|
|
@@ -9942,20 +9994,22 @@ function rebuild(n2, options) {
|
|
|
9942
9994
|
cache,
|
|
9943
9995
|
mirror: mirror2 = new Mirror()
|
|
9944
9996
|
} = options;
|
|
9997
|
+
const scrollNodes = [];
|
|
9945
9998
|
const node2 = buildNodeWithSN(n2, {
|
|
9946
9999
|
doc,
|
|
9947
10000
|
mirror: mirror2,
|
|
9948
10001
|
skipChild: false,
|
|
9949
10002
|
hackCss,
|
|
9950
10003
|
afterAppend,
|
|
9951
|
-
cache
|
|
9952
|
-
|
|
9953
|
-
visit(mirror2, (visitedNode) => {
|
|
9954
|
-
if (onVisit) {
|
|
9955
|
-
onVisit(visitedNode);
|
|
9956
|
-
}
|
|
9957
|
-
handleScroll(visitedNode, mirror2);
|
|
10004
|
+
cache,
|
|
10005
|
+
scrollNodes
|
|
9958
10006
|
});
|
|
10007
|
+
if (onVisit) {
|
|
10008
|
+
visit(mirror2, onVisit);
|
|
10009
|
+
}
|
|
10010
|
+
for (const scrollNode of scrollNodes) {
|
|
10011
|
+
handleScroll(scrollNode, mirror2);
|
|
10012
|
+
}
|
|
9959
10013
|
return node2;
|
|
9960
10014
|
}
|
|
9961
10015
|
var __defProp22 = Object.defineProperty;
|
|
@@ -15826,6 +15880,7 @@ class Timer {
|
|
|
15826
15880
|
__publicField2(this, "timeOffset", 0);
|
|
15827
15881
|
__publicField2(this, "speed");
|
|
15828
15882
|
__publicField2(this, "actions");
|
|
15883
|
+
__publicField2(this, "actionIndex", 0);
|
|
15829
15884
|
__publicField2(this, "raf", null);
|
|
15830
15885
|
__publicField2(this, "lastTimestamp");
|
|
15831
15886
|
this.actions = actions;
|
|
@@ -15836,7 +15891,7 @@ class Timer {
|
|
|
15836
15891
|
*/
|
|
15837
15892
|
addAction(action) {
|
|
15838
15893
|
const rafWasActive = this.raf === true;
|
|
15839
|
-
if (
|
|
15894
|
+
if (this.actionIndex >= this.actions.length || this.actions[this.actions.length - 1].delay <= action.delay) {
|
|
15840
15895
|
this.actions.push(action);
|
|
15841
15896
|
} else {
|
|
15842
15897
|
const index2 = this.findActionIndex(action);
|
|
@@ -15855,16 +15910,16 @@ class Timer {
|
|
|
15855
15910
|
const time = performance.now();
|
|
15856
15911
|
this.timeOffset += (time - this.lastTimestamp) * this.speed;
|
|
15857
15912
|
this.lastTimestamp = time;
|
|
15858
|
-
while (this.actions.length) {
|
|
15859
|
-
const action = this.actions[
|
|
15913
|
+
while (this.actionIndex < this.actions.length) {
|
|
15914
|
+
const action = this.actions[this.actionIndex];
|
|
15860
15915
|
if (this.timeOffset >= action.delay) {
|
|
15861
|
-
this.
|
|
15916
|
+
this.actionIndex++;
|
|
15862
15917
|
action.doAction();
|
|
15863
15918
|
} else {
|
|
15864
15919
|
break;
|
|
15865
15920
|
}
|
|
15866
15921
|
}
|
|
15867
|
-
if (this.actions.length
|
|
15922
|
+
if (this.actionIndex < this.actions.length) {
|
|
15868
15923
|
this.raf = requestAnimationFrame(this.rafCheck.bind(this));
|
|
15869
15924
|
} else {
|
|
15870
15925
|
this.raf = true;
|
|
@@ -15878,6 +15933,7 @@ class Timer {
|
|
|
15878
15933
|
this.raf = null;
|
|
15879
15934
|
}
|
|
15880
15935
|
this.actions.length = 0;
|
|
15936
|
+
this.actionIndex = 0;
|
|
15881
15937
|
}
|
|
15882
15938
|
setSpeed(speed) {
|
|
15883
15939
|
this.speed = speed;
|
|
@@ -15886,7 +15942,7 @@ class Timer {
|
|
|
15886
15942
|
return this.raf !== null;
|
|
15887
15943
|
}
|
|
15888
15944
|
findActionIndex(action) {
|
|
15889
|
-
let start =
|
|
15945
|
+
let start = this.actionIndex;
|
|
15890
15946
|
let end = this.actions.length - 1;
|
|
15891
15947
|
while (start <= end) {
|
|
15892
15948
|
const mid = Math.floor((start + end) / 2);
|
|
@@ -16055,34 +16111,44 @@ function v(t2) {
|
|
|
16055
16111
|
} };
|
|
16056
16112
|
return c2;
|
|
16057
16113
|
}
|
|
16058
|
-
function
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
-
|
|
16062
|
-
|
|
16063
|
-
|
|
16114
|
+
function buildCheckpointIndex(events) {
|
|
16115
|
+
const checkpoints = [];
|
|
16116
|
+
for (let i2 = 0; i2 < events.length; i2++) {
|
|
16117
|
+
if (events[i2].type === EventType$1.Meta) {
|
|
16118
|
+
checkpoints.push({
|
|
16119
|
+
metaEventIndex: i2,
|
|
16120
|
+
timestamp: events[i2].timestamp
|
|
16121
|
+
});
|
|
16122
|
+
}
|
|
16064
16123
|
}
|
|
16065
|
-
return
|
|
16124
|
+
return checkpoints;
|
|
16066
16125
|
}
|
|
16067
|
-
function
|
|
16126
|
+
function findNearestCheckpoint(checkpoints, baselineTime) {
|
|
16127
|
+
if (checkpoints.length === 0) {
|
|
16128
|
+
return null;
|
|
16129
|
+
}
|
|
16068
16130
|
let lo = 0;
|
|
16069
|
-
let hi =
|
|
16070
|
-
let
|
|
16131
|
+
let hi = checkpoints.length - 1;
|
|
16132
|
+
let result2 = null;
|
|
16071
16133
|
while (lo <= hi) {
|
|
16072
|
-
const mid = lo + hi
|
|
16073
|
-
if (
|
|
16074
|
-
|
|
16134
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
16135
|
+
if (checkpoints[mid].timestamp <= baselineTime) {
|
|
16136
|
+
result2 = checkpoints[mid];
|
|
16075
16137
|
lo = mid + 1;
|
|
16076
16138
|
} else {
|
|
16077
16139
|
hi = mid - 1;
|
|
16078
16140
|
}
|
|
16079
16141
|
}
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16142
|
+
return result2;
|
|
16143
|
+
}
|
|
16144
|
+
function isDuplicateEvent(existing, incoming) {
|
|
16145
|
+
if (existing === incoming) {
|
|
16146
|
+
return true;
|
|
16084
16147
|
}
|
|
16085
|
-
|
|
16148
|
+
if (existing.timestamp === incoming.timestamp && existing.type === incoming.type) {
|
|
16149
|
+
return JSON.stringify(existing) === JSON.stringify(incoming);
|
|
16150
|
+
}
|
|
16151
|
+
return false;
|
|
16086
16152
|
}
|
|
16087
16153
|
function createPlayerService(context, { getCastFn, applyEventsSynchronously, emitter }) {
|
|
16088
16154
|
const playerMachine = s(
|
|
@@ -16168,9 +16234,19 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
16168
16234
|
}),
|
|
16169
16235
|
play(ctx) {
|
|
16170
16236
|
var _a22;
|
|
16171
|
-
const {
|
|
16237
|
+
const {
|
|
16238
|
+
timer,
|
|
16239
|
+
events,
|
|
16240
|
+
baselineTime,
|
|
16241
|
+
lastPlayedEvent,
|
|
16242
|
+
checkpointIndex
|
|
16243
|
+
} = ctx;
|
|
16172
16244
|
timer.clear();
|
|
16173
|
-
const
|
|
16245
|
+
const checkpoint = findNearestCheckpoint(
|
|
16246
|
+
checkpointIndex,
|
|
16247
|
+
baselineTime
|
|
16248
|
+
);
|
|
16249
|
+
const startIndex = checkpoint ? checkpoint.metaEventIndex : 0;
|
|
16174
16250
|
let lastPlayedTimestamp = lastPlayedEvent == null ? void 0 : lastPlayedEvent.timestamp;
|
|
16175
16251
|
if ((lastPlayedEvent == null ? void 0 : lastPlayedEvent.type) === EventType$1.IncrementalSnapshot && lastPlayedEvent.data.source === IncrementalSource.MouseMove) {
|
|
16176
16252
|
lastPlayedTimestamp = lastPlayedEvent.timestamp + ((_a22 = lastPlayedEvent.data.positions[0]) == null ? void 0 : _a22.timeOffset);
|
|
@@ -16178,46 +16254,25 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
16178
16254
|
if (baselineTime < (lastPlayedTimestamp || 0)) {
|
|
16179
16255
|
emitter.emit(ReplayerEvents.PlayBack);
|
|
16180
16256
|
}
|
|
16181
|
-
|
|
16182
|
-
{
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
const mid = lo + hi >>> 1;
|
|
16187
|
-
if (neededEvents[mid].timestamp < baselineTime) lo = mid + 1;
|
|
16188
|
-
else hi = mid;
|
|
16189
|
-
}
|
|
16190
|
-
syncEnd = lo;
|
|
16191
|
-
}
|
|
16192
|
-
let syncStart = 0;
|
|
16193
|
-
if (lastPlayedTimestamp && lastPlayedTimestamp < baselineTime) {
|
|
16194
|
-
let lo = 0;
|
|
16195
|
-
let hi = syncEnd;
|
|
16196
|
-
while (lo < hi) {
|
|
16197
|
-
const mid = lo + hi >>> 1;
|
|
16198
|
-
if (neededEvents[mid].timestamp <= lastPlayedTimestamp)
|
|
16199
|
-
lo = mid + 1;
|
|
16200
|
-
else hi = mid;
|
|
16257
|
+
const syncEvents = new Array();
|
|
16258
|
+
for (let i2 = startIndex; i2 < events.length; i2++) {
|
|
16259
|
+
const event2 = events[i2];
|
|
16260
|
+
if (lastPlayedTimestamp && lastPlayedTimestamp < baselineTime && (event2.timestamp <= lastPlayedTimestamp || event2 === lastPlayedEvent)) {
|
|
16261
|
+
continue;
|
|
16201
16262
|
}
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16263
|
+
if (event2.timestamp < baselineTime) {
|
|
16264
|
+
syncEvents.push(event2);
|
|
16265
|
+
} else {
|
|
16266
|
+
addDelay(event2, baselineTime);
|
|
16267
|
+
const castFn = getCastFn(event2, false);
|
|
16268
|
+
timer.addAction({
|
|
16269
|
+
doAction: () => {
|
|
16270
|
+
castFn();
|
|
16271
|
+
},
|
|
16272
|
+
delay: event2.delay ?? 0
|
|
16273
|
+
});
|
|
16205
16274
|
}
|
|
16206
16275
|
}
|
|
16207
|
-
for (let i2 = syncEnd; i2 < neededEvents.length; i2++) {
|
|
16208
|
-
addDelay(neededEvents[i2], baselineTime);
|
|
16209
|
-
}
|
|
16210
|
-
const syncEvents = neededEvents.slice(syncStart, syncEnd);
|
|
16211
|
-
for (let i2 = syncEnd; i2 < neededEvents.length; i2++) {
|
|
16212
|
-
const event2 = neededEvents[i2];
|
|
16213
|
-
const castFn = getCastFn(event2, false);
|
|
16214
|
-
timer.addAction({
|
|
16215
|
-
doAction: () => {
|
|
16216
|
-
castFn();
|
|
16217
|
-
},
|
|
16218
|
-
delay: event2.delay ?? 0
|
|
16219
|
-
});
|
|
16220
|
-
}
|
|
16221
16276
|
applyEventsSynchronously(syncEvents);
|
|
16222
16277
|
emitter.emit(ReplayerEvents.Flush);
|
|
16223
16278
|
timer.start();
|
|
@@ -16241,19 +16296,21 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
16241
16296
|
}
|
|
16242
16297
|
}),
|
|
16243
16298
|
addEvent: o((ctx, machineEvent) => {
|
|
16244
|
-
const { baselineTime, timer, events } = ctx;
|
|
16299
|
+
const { baselineTime, timer, events, checkpointIndex } = ctx;
|
|
16245
16300
|
if (machineEvent.type === "ADD_EVENT") {
|
|
16246
16301
|
const { event: event2 } = machineEvent.payload;
|
|
16247
16302
|
addDelay(event2, baselineTime);
|
|
16248
16303
|
let end = events.length - 1;
|
|
16304
|
+
let insertionIndex;
|
|
16249
16305
|
if (!events[end] || events[end].timestamp <= event2.timestamp) {
|
|
16250
16306
|
if (events[end] && isDuplicateEvent(events[end], event2)) {
|
|
16251
16307
|
return { ...ctx, events };
|
|
16252
16308
|
}
|
|
16253
16309
|
events.push(event2);
|
|
16310
|
+
insertionIndex = events.length - 1;
|
|
16254
16311
|
} else {
|
|
16255
|
-
let insertionIndex = -1;
|
|
16256
16312
|
let start = 0;
|
|
16313
|
+
insertionIndex = 0;
|
|
16257
16314
|
while (start <= end) {
|
|
16258
16315
|
const mid = Math.floor((start + end) / 2);
|
|
16259
16316
|
if (events[mid].timestamp <= event2.timestamp) {
|
|
@@ -16262,9 +16319,7 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
16262
16319
|
end = mid - 1;
|
|
16263
16320
|
}
|
|
16264
16321
|
}
|
|
16265
|
-
|
|
16266
|
-
insertionIndex = start;
|
|
16267
|
-
}
|
|
16322
|
+
insertionIndex = start;
|
|
16268
16323
|
for (let i2 = insertionIndex - 1; i2 >= 0 && events[i2].timestamp === event2.timestamp; i2--) {
|
|
16269
16324
|
if (isDuplicateEvent(events[i2], event2)) {
|
|
16270
16325
|
return { ...ctx, events };
|
|
@@ -16277,6 +16332,39 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
16277
16332
|
}
|
|
16278
16333
|
events.splice(insertionIndex, 0, event2);
|
|
16279
16334
|
}
|
|
16335
|
+
if (event2.type === EventType$1.Meta) {
|
|
16336
|
+
const newCheckpoint = {
|
|
16337
|
+
metaEventIndex: insertionIndex,
|
|
16338
|
+
timestamp: event2.timestamp
|
|
16339
|
+
};
|
|
16340
|
+
const lastCheckpoint = checkpointIndex[checkpointIndex.length - 1];
|
|
16341
|
+
if (!lastCheckpoint || lastCheckpoint.timestamp <= event2.timestamp) {
|
|
16342
|
+
checkpointIndex.push(newCheckpoint);
|
|
16343
|
+
} else {
|
|
16344
|
+
for (const checkpoint of checkpointIndex) {
|
|
16345
|
+
if (checkpoint.metaEventIndex >= insertionIndex) {
|
|
16346
|
+
checkpoint.metaEventIndex++;
|
|
16347
|
+
}
|
|
16348
|
+
}
|
|
16349
|
+
let searchLo = 0;
|
|
16350
|
+
let searchHi = checkpointIndex.length - 1;
|
|
16351
|
+
while (searchLo <= searchHi) {
|
|
16352
|
+
const mid = Math.floor((searchLo + searchHi) / 2);
|
|
16353
|
+
if (checkpointIndex[mid].timestamp <= event2.timestamp) {
|
|
16354
|
+
searchLo = mid + 1;
|
|
16355
|
+
} else {
|
|
16356
|
+
searchHi = mid - 1;
|
|
16357
|
+
}
|
|
16358
|
+
}
|
|
16359
|
+
checkpointIndex.splice(searchLo, 0, newCheckpoint);
|
|
16360
|
+
}
|
|
16361
|
+
} else if (insertionIndex < events.length - 1) {
|
|
16362
|
+
for (const checkpoint of checkpointIndex) {
|
|
16363
|
+
if (checkpoint.metaEventIndex >= insertionIndex) {
|
|
16364
|
+
checkpoint.metaEventIndex++;
|
|
16365
|
+
}
|
|
16366
|
+
}
|
|
16367
|
+
}
|
|
16280
16368
|
const isSync = event2.timestamp < baselineTime;
|
|
16281
16369
|
const castFn = getCastFn(event2, isSync);
|
|
16282
16370
|
if (isSync) {
|
|
@@ -16290,7 +16378,7 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
16290
16378
|
});
|
|
16291
16379
|
}
|
|
16292
16380
|
}
|
|
16293
|
-
return { ...ctx, events };
|
|
16381
|
+
return { ...ctx, events, checkpointIndex };
|
|
16294
16382
|
})
|
|
16295
16383
|
}
|
|
16296
16384
|
}
|
|
@@ -16818,6 +16906,7 @@ class Replayer {
|
|
|
16818
16906
|
__publicField2(this, "lastSelectionData", null);
|
|
16819
16907
|
__publicField2(this, "constructedStyleMutations", []);
|
|
16820
16908
|
__publicField2(this, "adoptedStyleSheets", []);
|
|
16909
|
+
__publicField2(this, "snapshotAdoptedStyleSheetQueue", []);
|
|
16821
16910
|
__publicField2(this, "handleResize", (dimension) => {
|
|
16822
16911
|
this.iframe.style.display = "inherit";
|
|
16823
16912
|
for (const el of [this.mouseTail, this.iframe]) {
|
|
@@ -16830,6 +16919,13 @@ class Replayer {
|
|
|
16830
16919
|
});
|
|
16831
16920
|
__publicField2(this, "applyEventsSynchronously", (events2) => {
|
|
16832
16921
|
var _a22;
|
|
16922
|
+
let lastFullSnapshotIndex = -1;
|
|
16923
|
+
for (let i2 = events2.length - 1; i2 >= 0; i2--) {
|
|
16924
|
+
if (events2[i2].type === EventType$1.FullSnapshot) {
|
|
16925
|
+
lastFullSnapshotIndex = i2;
|
|
16926
|
+
break;
|
|
16927
|
+
}
|
|
16928
|
+
}
|
|
16833
16929
|
let startIdx = 0;
|
|
16834
16930
|
if (this.config.useSeekCache && events2.length > 0) {
|
|
16835
16931
|
const fullSnapshotEvt = events2.find(
|
|
@@ -16875,10 +16971,14 @@ class Replayer {
|
|
|
16875
16971
|
case EventType$1.Load:
|
|
16876
16972
|
case EventType$1.Custom:
|
|
16877
16973
|
continue;
|
|
16974
|
+
case EventType$1.IncrementalSnapshot:
|
|
16975
|
+
if (i2 < lastFullSnapshotIndex) {
|
|
16976
|
+
continue;
|
|
16977
|
+
}
|
|
16978
|
+
break;
|
|
16878
16979
|
case EventType$1.FullSnapshot:
|
|
16879
16980
|
case EventType$1.Meta:
|
|
16880
16981
|
case EventType$1.Plugin:
|
|
16881
|
-
case EventType$1.IncrementalSnapshot:
|
|
16882
16982
|
break;
|
|
16883
16983
|
}
|
|
16884
16984
|
const castFn = this.getCastFn(event2, true);
|
|
@@ -17086,6 +17186,14 @@ class Replayer {
|
|
|
17086
17186
|
this.applyAdoptedStyleSheet(data);
|
|
17087
17187
|
});
|
|
17088
17188
|
this.adoptedStyleSheets = [];
|
|
17189
|
+
this.snapshotAdoptedStyleSheetQueue.forEach(
|
|
17190
|
+
({ id, adoptedStyleSheets }) => {
|
|
17191
|
+
const node2 = this.mirror.getNode(id);
|
|
17192
|
+
if (node2)
|
|
17193
|
+
this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
|
|
17194
|
+
}
|
|
17195
|
+
);
|
|
17196
|
+
this.snapshotAdoptedStyleSheetQueue = [];
|
|
17089
17197
|
}
|
|
17090
17198
|
if (this.mousePos) {
|
|
17091
17199
|
this.moveAndHover(
|
|
@@ -17141,18 +17249,21 @@ class Replayer {
|
|
|
17141
17249
|
const timer = new Timer([], {
|
|
17142
17250
|
speed: this.config.speed
|
|
17143
17251
|
});
|
|
17252
|
+
const sortedEvents = events.map((e2) => {
|
|
17253
|
+
if (config && config.unpackFn) {
|
|
17254
|
+
return config.unpackFn(e2);
|
|
17255
|
+
}
|
|
17256
|
+
return e2;
|
|
17257
|
+
}).sort((a1, a2) => a1.timestamp - a2.timestamp);
|
|
17258
|
+
const checkpointIndex = buildCheckpointIndex(sortedEvents);
|
|
17144
17259
|
this.service = createPlayerService(
|
|
17145
17260
|
{
|
|
17146
|
-
events:
|
|
17147
|
-
if (config && config.unpackFn) {
|
|
17148
|
-
return config.unpackFn(e2);
|
|
17149
|
-
}
|
|
17150
|
-
return e2;
|
|
17151
|
-
}).sort((a1, a2) => a1.timestamp - a2.timestamp),
|
|
17261
|
+
events: sortedEvents,
|
|
17152
17262
|
timer,
|
|
17153
17263
|
timeOffset: 0,
|
|
17154
17264
|
baselineTime: 0,
|
|
17155
|
-
lastPlayedEvent: null
|
|
17265
|
+
lastPlayedEvent: null,
|
|
17266
|
+
checkpointIndex
|
|
17156
17267
|
},
|
|
17157
17268
|
{
|
|
17158
17269
|
getCastFn: this.getCastFn,
|
|
@@ -17456,6 +17567,7 @@ class Replayer {
|
|
|
17456
17567
|
const collectedIframes = [];
|
|
17457
17568
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17458
17569
|
const afterAppend = (builtNode, id) => {
|
|
17570
|
+
var _a22;
|
|
17459
17571
|
if (builtNode.nodeName === "DIALOG")
|
|
17460
17572
|
collectedDialogs.add(builtNode);
|
|
17461
17573
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17467,6 +17579,10 @@ class Replayer {
|
|
|
17467
17579
|
this.mirror
|
|
17468
17580
|
);
|
|
17469
17581
|
}
|
|
17582
|
+
const sn = this.mirror.getMeta(builtNode);
|
|
17583
|
+
if (sn && "adoptedStyleSheets" in sn && ((_a22 = sn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17584
|
+
this.applySnapshotAdoptedStyleSheets(builtNode, sn.adoptedStyleSheets);
|
|
17585
|
+
}
|
|
17470
17586
|
for (const plugin of this.config.plugins || []) {
|
|
17471
17587
|
if (plugin.onBuild)
|
|
17472
17588
|
plugin.onBuild(builtNode, {
|
|
@@ -17583,6 +17699,7 @@ class Replayer {
|
|
|
17583
17699
|
const collectedIframes = [];
|
|
17584
17700
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17585
17701
|
const afterAppend = (builtNode, id) => {
|
|
17702
|
+
var _a22;
|
|
17586
17703
|
if (builtNode.nodeName === "DIALOG")
|
|
17587
17704
|
collectedDialogs.add(builtNode);
|
|
17588
17705
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17595,6 +17712,25 @@ class Replayer {
|
|
|
17595
17712
|
head
|
|
17596
17713
|
);
|
|
17597
17714
|
}
|
|
17715
|
+
{
|
|
17716
|
+
const nodeSn = mirror2.getMeta(
|
|
17717
|
+
builtNode
|
|
17718
|
+
);
|
|
17719
|
+
if (nodeSn && "adoptedStyleSheets" in nodeSn && ((_a22 = nodeSn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17720
|
+
if (this.usingVirtualDom) {
|
|
17721
|
+
const id2 = mirror2.getId(builtNode);
|
|
17722
|
+
this.snapshotAdoptedStyleSheetQueue.push({
|
|
17723
|
+
id: id2,
|
|
17724
|
+
adoptedStyleSheets: nodeSn.adoptedStyleSheets
|
|
17725
|
+
});
|
|
17726
|
+
} else {
|
|
17727
|
+
this.applySnapshotAdoptedStyleSheets(
|
|
17728
|
+
builtNode,
|
|
17729
|
+
nodeSn.adoptedStyleSheets
|
|
17730
|
+
);
|
|
17731
|
+
}
|
|
17732
|
+
}
|
|
17733
|
+
}
|
|
17598
17734
|
if (this.usingVirtualDom) return;
|
|
17599
17735
|
for (const plugin of this.config.plugins || []) {
|
|
17600
17736
|
if (plugin.onBuild)
|
|
@@ -18480,6 +18616,44 @@ class Replayer {
|
|
|
18480
18616
|
rule2.style.removeProperty(data.remove.property);
|
|
18481
18617
|
}
|
|
18482
18618
|
}
|
|
18619
|
+
applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets) {
|
|
18620
|
+
var _a22;
|
|
18621
|
+
let hostWindow = null;
|
|
18622
|
+
if (hasShadowRoot(node2))
|
|
18623
|
+
hostWindow = ((_a22 = node2.ownerDocument) == null ? void 0 : _a22.defaultView) || null;
|
|
18624
|
+
else if (node2.nodeName === "#document")
|
|
18625
|
+
hostWindow = node2.defaultView;
|
|
18626
|
+
if (!hostWindow) return;
|
|
18627
|
+
const sheets = [];
|
|
18628
|
+
for (const { styleId, rules: rules2 } of adoptedStyleSheets) {
|
|
18629
|
+
const existing = this.styleMirror.getStyle(styleId);
|
|
18630
|
+
if (existing) {
|
|
18631
|
+
if (rules2.length) {
|
|
18632
|
+
this.applyStyleSheetRule(
|
|
18633
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18634
|
+
existing
|
|
18635
|
+
);
|
|
18636
|
+
}
|
|
18637
|
+
sheets.push(existing);
|
|
18638
|
+
continue;
|
|
18639
|
+
}
|
|
18640
|
+
try {
|
|
18641
|
+
const sheet = new hostWindow.CSSStyleSheet();
|
|
18642
|
+
this.styleMirror.add(sheet, styleId);
|
|
18643
|
+
if (rules2.length) {
|
|
18644
|
+
this.applyStyleSheetRule(
|
|
18645
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18646
|
+
sheet
|
|
18647
|
+
);
|
|
18648
|
+
}
|
|
18649
|
+
sheets.push(sheet);
|
|
18650
|
+
} catch (e2) {
|
|
18651
|
+
}
|
|
18652
|
+
}
|
|
18653
|
+
if (hasShadowRoot(node2)) node2.shadowRoot.adoptedStyleSheets = sheets;
|
|
18654
|
+
else if (node2.nodeName === "#document")
|
|
18655
|
+
node2.adoptedStyleSheets = sheets;
|
|
18656
|
+
}
|
|
18483
18657
|
applyAdoptedStyleSheet(data) {
|
|
18484
18658
|
var _a22;
|
|
18485
18659
|
const targetHost = this.mirror.getNode(data.id);
|