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