@appsurify-testmap/rrweb-player 2.1.3-alpha.2 → 2.1.3-alpha.3

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.
@@ -10649,7 +10649,7 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
10649
10649
  if (lastPlayedTimestamp && lastPlayedTimestamp < baselineTime && (event.timestamp <= lastPlayedTimestamp || event === lastPlayedEvent)) {
10650
10650
  continue;
10651
10651
  }
10652
- if (event.timestamp < baselineTime) {
10652
+ if (event.timestamp <= baselineTime) {
10653
10653
  syncEvents.push(event);
10654
10654
  } else {
10655
10655
  const castFn = getCastFn(event, false);
@@ -13466,6 +13466,155 @@ function getInactivePeriods(events, inactivePeriodThreshold) {
13466
13466
  }
13467
13467
  return inactivePeriods;
13468
13468
  }
13469
+ const NORMALIZATION_GAP = 1e-3;
13470
+ const NORMALIZATION_MIN_BLOCK_SPAN = 1;
13471
+ function createIdentityTimelineMapper() {
13472
+ return {
13473
+ normalizationApplied: false,
13474
+ toReplayerTime: (offset) => offset,
13475
+ toPlayerTime: (offset) => offset,
13476
+ toReplayerAbsolute: (value) => value,
13477
+ toPlayerAbsolute: (value) => value,
13478
+ normalizeEvent: (event) => event
13479
+ };
13480
+ }
13481
+ function normalizeEventsForReplay(events, allowNormalization = true) {
13482
+ if (!events.length) {
13483
+ const mapper2 = createIdentityTimelineMapper();
13484
+ return { events, mapper: mapper2 };
13485
+ }
13486
+ const params = allowNormalization ? getNormalizationParams(events) : null;
13487
+ const normalizedEvents = events.map(
13488
+ (event) => normalizeEventWithParams(event, params)
13489
+ );
13490
+ const originalStart = getTimelineStart(events);
13491
+ const normalizedStart = getTimelineStart(normalizedEvents);
13492
+ const mapper = createTimelineMapper(params, originalStart, normalizedStart);
13493
+ return { events: normalizedEvents, mapper };
13494
+ }
13495
+ function getTimelineStart(events) {
13496
+ return events.reduce((min, event) => Math.min(min, event.timestamp), Infinity);
13497
+ }
13498
+ function getNormalizationParams(events) {
13499
+ const firstFull = events.find((event) => event.type === EventType.FullSnapshot);
13500
+ if (!firstFull) {
13501
+ return null;
13502
+ }
13503
+ const problemEvents = events.filter(
13504
+ (event) => event.type === EventType.IncrementalSnapshot && event.timestamp < firstFull.timestamp
13505
+ );
13506
+ if (!problemEvents.length) {
13507
+ return null;
13508
+ }
13509
+ const earliestProblem = problemEvents.reduce(
13510
+ (min, event) => Math.min(min, event.timestamp),
13511
+ Infinity
13512
+ );
13513
+ const latestProblem = problemEvents.reduce(
13514
+ (max2, event) => Math.max(max2, event.timestamp),
13515
+ -Infinity
13516
+ );
13517
+ const span = Math.max(0, latestProblem - earliestProblem);
13518
+ const blockSpan = Math.max(span, NORMALIZATION_MIN_BLOCK_SPAN);
13519
+ return {
13520
+ earliestProblem,
13521
+ span,
13522
+ blockSpan,
13523
+ blockStart: firstFull.timestamp + NORMALIZATION_GAP,
13524
+ tailShift: NORMALIZATION_GAP + blockSpan,
13525
+ firstFullTimestamp: firstFull.timestamp
13526
+ };
13527
+ }
13528
+ function normalizeEventWithParams(event, params) {
13529
+ if (!params) {
13530
+ return event;
13531
+ }
13532
+ const domDependent = event.type === EventType.IncrementalSnapshot && event.timestamp < params.firstFullTimestamp;
13533
+ const normalizedTimestamp = normalizeTimestamp(
13534
+ event.timestamp,
13535
+ domDependent,
13536
+ params
13537
+ );
13538
+ if (normalizedTimestamp === event.timestamp) {
13539
+ return event;
13540
+ }
13541
+ return {
13542
+ ...event,
13543
+ timestamp: normalizedTimestamp
13544
+ };
13545
+ }
13546
+ function normalizeTimestamp(timestamp, domDependent, params) {
13547
+ if (!params) {
13548
+ return timestamp;
13549
+ }
13550
+ if (timestamp > params.firstFullTimestamp) {
13551
+ return timestamp + params.tailShift;
13552
+ }
13553
+ if (domDependent && timestamp < params.firstFullTimestamp) {
13554
+ if (params.span === 0) {
13555
+ return params.blockStart;
13556
+ }
13557
+ const scale = params.blockSpan / params.span;
13558
+ return params.blockStart + (timestamp - params.earliestProblem) * scale;
13559
+ }
13560
+ return timestamp;
13561
+ }
13562
+ function convertAbsoluteToNormalized(value, params) {
13563
+ if (!params) {
13564
+ return value;
13565
+ }
13566
+ if (value > params.firstFullTimestamp) {
13567
+ return value + params.tailShift;
13568
+ }
13569
+ if (value >= params.earliestProblem && value < params.firstFullTimestamp) {
13570
+ if (params.span === 0) {
13571
+ return params.blockStart;
13572
+ }
13573
+ const scale = params.blockSpan / params.span;
13574
+ return params.blockStart + (value - params.earliestProblem) * scale;
13575
+ }
13576
+ return value;
13577
+ }
13578
+ function convertAbsoluteToOriginal(value, params) {
13579
+ if (!params) {
13580
+ return value;
13581
+ }
13582
+ const blockEnd = params.blockStart + params.blockSpan;
13583
+ const tailStart = params.firstFullTimestamp + params.tailShift;
13584
+ if (value >= tailStart) {
13585
+ return value - params.tailShift;
13586
+ }
13587
+ if (value >= params.blockStart && value <= blockEnd) {
13588
+ if (params.span === 0) {
13589
+ return params.earliestProblem;
13590
+ }
13591
+ const scale = params.blockSpan / params.span;
13592
+ return params.earliestProblem + (value - params.blockStart) / scale;
13593
+ }
13594
+ return value;
13595
+ }
13596
+ function createTimelineMapper(params, originalStart, normalizedStart) {
13597
+ const safeOriginalStart = Number.isFinite(originalStart) ? originalStart : 0;
13598
+ const safeNormalizedStart = Number.isFinite(normalizedStart) ? normalizedStart : 0;
13599
+ const toReplayerAbsolute = (value) => convertAbsoluteToNormalized(value, params);
13600
+ const toPlayerAbsolute = (value) => convertAbsoluteToOriginal(value, params);
13601
+ return {
13602
+ normalizationApplied: Boolean(params),
13603
+ normalizeEvent: (event) => normalizeEventWithParams(event, params),
13604
+ toReplayerAbsolute,
13605
+ toPlayerAbsolute,
13606
+ toReplayerTime: (offset) => {
13607
+ const absoluteOriginal = safeOriginalStart + offset;
13608
+ const normalizedAbsolute = toReplayerAbsolute(absoluteOriginal);
13609
+ return normalizedAbsolute - safeNormalizedStart;
13610
+ },
13611
+ toPlayerTime: (offset) => {
13612
+ const normalizedAbsolute = safeNormalizedStart + offset;
13613
+ const originalAbsolute = toPlayerAbsolute(normalizedAbsolute);
13614
+ return originalAbsolute - safeOriginalStart;
13615
+ }
13616
+ };
13617
+ }
13469
13618
  function create_fragment$2(ctx) {
13470
13619
  let div;
13471
13620
  let input2;
@@ -13615,17 +13764,17 @@ class Switch extends SvelteComponent {
13615
13764
  }
13616
13765
  function get_each_context(ctx, list2, i) {
13617
13766
  const child_ctx = ctx.slice();
13618
- child_ctx[38] = list2[i];
13767
+ child_ctx[40] = list2[i];
13619
13768
  return child_ctx;
13620
13769
  }
13621
13770
  function get_each_context_1(ctx, list2, i) {
13622
13771
  const child_ctx = ctx.slice();
13623
- child_ctx[41] = list2[i];
13772
+ child_ctx[43] = list2[i];
13624
13773
  return child_ctx;
13625
13774
  }
13626
13775
  function get_each_context_2(ctx, list2, i) {
13627
13776
  const child_ctx = ctx.slice();
13628
- child_ctx[44] = list2[i];
13777
+ child_ctx[46] = list2[i];
13629
13778
  return child_ctx;
13630
13779
  }
13631
13780
  function create_if_block$1(ctx) {
@@ -13697,7 +13846,7 @@ function create_if_block$1(ctx) {
13697
13846
  each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
13698
13847
  }
13699
13848
  function switch_1_checked_binding(value) {
13700
- ctx[29](value);
13849
+ ctx[30](value);
13701
13850
  }
13702
13851
  let switch_1_props = {
13703
13852
  id: "skip",
@@ -13808,7 +13957,7 @@ function create_if_block$1(ctx) {
13808
13957
  }
13809
13958
  append(div2, t4);
13810
13959
  append(div2, div1);
13811
- ctx[27](div2);
13960
+ ctx[28](div2);
13812
13961
  append(div3, t5);
13813
13962
  append(div3, span1);
13814
13963
  append(span1, t6);
@@ -13851,7 +14000,7 @@ function create_if_block$1(ctx) {
13851
14000
  button1,
13852
14001
  "click",
13853
14002
  /*click_handler_1*/
13854
- ctx[30]
14003
+ ctx[31]
13855
14004
  )
13856
14005
  ];
13857
14006
  mounted = true;
@@ -13997,7 +14146,7 @@ function create_if_block$1(ctx) {
13997
14146
  }
13998
14147
  destroy_each(each_blocks_2, detaching);
13999
14148
  destroy_each(each_blocks_1, detaching);
14000
- ctx[27](null);
14149
+ ctx[28](null);
14001
14150
  if_block.d();
14002
14151
  destroy_each(each_blocks, detaching);
14003
14152
  destroy_component(switch_1);
@@ -14013,12 +14162,12 @@ function create_each_block_2(ctx) {
14013
14162
  c() {
14014
14163
  div = element("div");
14015
14164
  attr(div, "title", div_title_value = /*period*/
14016
- ctx[44].name);
14165
+ ctx[46].name);
14017
14166
  set_style(
14018
14167
  div,
14019
14168
  "width",
14020
14169
  /*period*/
14021
- ctx[44].width
14170
+ ctx[46].width
14022
14171
  );
14023
14172
  set_style(div, "height", "4px");
14024
14173
  set_style(div, "position", "absolute");
@@ -14026,13 +14175,13 @@ function create_each_block_2(ctx) {
14026
14175
  div,
14027
14176
  "background",
14028
14177
  /*period*/
14029
- ctx[44].background
14178
+ ctx[46].background
14030
14179
  );
14031
14180
  set_style(
14032
14181
  div,
14033
14182
  "left",
14034
14183
  /*period*/
14035
- ctx[44].position
14184
+ ctx[46].position
14036
14185
  );
14037
14186
  },
14038
14187
  m(target, anchor) {
@@ -14041,7 +14190,7 @@ function create_each_block_2(ctx) {
14041
14190
  p(ctx2, dirty) {
14042
14191
  if (dirty[0] & /*inactivePeriods*/
14043
14192
  8192 && div_title_value !== (div_title_value = /*period*/
14044
- ctx2[44].name)) {
14193
+ ctx2[46].name)) {
14045
14194
  attr(div, "title", div_title_value);
14046
14195
  }
14047
14196
  if (dirty[0] & /*inactivePeriods*/
@@ -14050,7 +14199,7 @@ function create_each_block_2(ctx) {
14050
14199
  div,
14051
14200
  "width",
14052
14201
  /*period*/
14053
- ctx2[44].width
14202
+ ctx2[46].width
14054
14203
  );
14055
14204
  }
14056
14205
  if (dirty[0] & /*inactivePeriods*/
@@ -14059,7 +14208,7 @@ function create_each_block_2(ctx) {
14059
14208
  div,
14060
14209
  "background",
14061
14210
  /*period*/
14062
- ctx2[44].background
14211
+ ctx2[46].background
14063
14212
  );
14064
14213
  }
14065
14214
  if (dirty[0] & /*inactivePeriods*/
@@ -14068,7 +14217,7 @@ function create_each_block_2(ctx) {
14068
14217
  div,
14069
14218
  "left",
14070
14219
  /*period*/
14071
- ctx2[44].position
14220
+ ctx2[46].position
14072
14221
  );
14073
14222
  }
14074
14223
  },
@@ -14086,7 +14235,7 @@ function create_each_block_1(ctx) {
14086
14235
  c() {
14087
14236
  div = element("div");
14088
14237
  attr(div, "title", div_title_value = /*event*/
14089
- ctx[41].name);
14238
+ ctx[43].name);
14090
14239
  set_style(div, "width", "10px");
14091
14240
  set_style(div, "height", "5px");
14092
14241
  set_style(div, "position", "absolute");
@@ -14096,13 +14245,13 @@ function create_each_block_1(ctx) {
14096
14245
  div,
14097
14246
  "background",
14098
14247
  /*event*/
14099
- ctx[41].background
14248
+ ctx[43].background
14100
14249
  );
14101
14250
  set_style(
14102
14251
  div,
14103
14252
  "left",
14104
14253
  /*event*/
14105
- ctx[41].position
14254
+ ctx[43].position
14106
14255
  );
14107
14256
  },
14108
14257
  m(target, anchor) {
@@ -14111,7 +14260,7 @@ function create_each_block_1(ctx) {
14111
14260
  p(ctx2, dirty) {
14112
14261
  if (dirty[0] & /*customEvents*/
14113
14262
  512 && div_title_value !== (div_title_value = /*event*/
14114
- ctx2[41].name)) {
14263
+ ctx2[43].name)) {
14115
14264
  attr(div, "title", div_title_value);
14116
14265
  }
14117
14266
  if (dirty[0] & /*customEvents*/
@@ -14120,7 +14269,7 @@ function create_each_block_1(ctx) {
14120
14269
  div,
14121
14270
  "background",
14122
14271
  /*event*/
14123
- ctx2[41].background
14272
+ ctx2[43].background
14124
14273
  );
14125
14274
  }
14126
14275
  if (dirty[0] & /*customEvents*/
@@ -14129,7 +14278,7 @@ function create_each_block_1(ctx) {
14129
14278
  div,
14130
14279
  "left",
14131
14280
  /*event*/
14132
- ctx2[41].position
14281
+ ctx2[43].position
14133
14282
  );
14134
14283
  }
14135
14284
  },
@@ -14198,7 +14347,7 @@ function create_each_block(ctx) {
14198
14347
  let button;
14199
14348
  let t0_value = (
14200
14349
  /*s*/
14201
- ctx[38] + ""
14350
+ ctx[40] + ""
14202
14351
  );
14203
14352
  let t0;
14204
14353
  let t1;
@@ -14208,9 +14357,9 @@ function create_each_block(ctx) {
14208
14357
  function click_handler() {
14209
14358
  return (
14210
14359
  /*click_handler*/
14211
- ctx[28](
14360
+ ctx[29](
14212
14361
  /*s*/
14213
- ctx[38]
14362
+ ctx[40]
14214
14363
  )
14215
14364
  );
14216
14365
  }
@@ -14226,7 +14375,7 @@ function create_each_block(ctx) {
14226
14375
  button,
14227
14376
  "active",
14228
14377
  /*s*/
14229
- ctx[38] === /*speed*/
14378
+ ctx[40] === /*speed*/
14230
14379
  ctx[1] && /*speedState*/
14231
14380
  ctx[10] !== "skipping"
14232
14381
  );
@@ -14244,7 +14393,7 @@ function create_each_block(ctx) {
14244
14393
  ctx = new_ctx;
14245
14394
  if (dirty[0] & /*speedOption*/
14246
14395
  8 && t0_value !== (t0_value = /*s*/
14247
- ctx[38] + "")) set_data(t0, t0_value);
14396
+ ctx[40] + "")) set_data(t0, t0_value);
14248
14397
  if (dirty[0] & /*speedState*/
14249
14398
  1024 && button_disabled_value !== (button_disabled_value = /*speedState*/
14250
14399
  ctx[10] === "skipping")) {
@@ -14256,7 +14405,7 @@ function create_each_block(ctx) {
14256
14405
  button,
14257
14406
  "active",
14258
14407
  /*s*/
14259
- ctx[38] === /*speed*/
14408
+ ctx[40] === /*speed*/
14260
14409
  ctx[1] && /*speedState*/
14261
14410
  ctx[10] !== "skipping"
14262
14411
  );
@@ -14346,6 +14495,7 @@ function instance$1($$self, $$props, $$invalidate) {
14346
14495
  let { speed = speedOption.length ? speedOption[0] : 1 } = $$props;
14347
14496
  let { tags = {} } = $$props;
14348
14497
  let { inactiveColor } = $$props;
14498
+ let { timeMapper = createIdentityTimelineMapper() } = $$props;
14349
14499
  let currentTime = 0;
14350
14500
  let timer = null;
14351
14501
  let playerState;
@@ -14355,6 +14505,14 @@ function instance$1($$self, $$props, $$invalidate) {
14355
14505
  let pauseAt = false;
14356
14506
  let onPauseHook = null;
14357
14507
  let loop = null;
14508
+ const readMeta = () => {
14509
+ const rawMeta = replayer.getMetaData();
14510
+ return {
14511
+ startTime: timeMapper.toPlayerAbsolute(rawMeta.startTime),
14512
+ endTime: timeMapper.toPlayerAbsolute(rawMeta.endTime),
14513
+ totalTime: timeMapper.toPlayerTime(rawMeta.totalTime)
14514
+ };
14515
+ };
14358
14516
  let meta;
14359
14517
  let percentage;
14360
14518
  let customEvents;
@@ -14362,7 +14520,7 @@ function instance$1($$self, $$props, $$invalidate) {
14362
14520
  const loopTimer = () => {
14363
14521
  stopTimer();
14364
14522
  function update2() {
14365
- $$invalidate(6, currentTime = replayer.getCurrentTime());
14523
+ $$invalidate(6, currentTime = timeMapper.toPlayerTime(replayer.getCurrentTime()));
14366
14524
  if (pauseAt && currentTime >= pauseAt) {
14367
14525
  if (loop) {
14368
14526
  playRange(loop.start, loop.end, true, void 0);
@@ -14404,7 +14562,7 @@ function instance$1($$self, $$props, $$invalidate) {
14404
14562
  replayer.play();
14405
14563
  finished = false;
14406
14564
  } else {
14407
- replayer.play(currentTime);
14565
+ replayer.play(timeMapper.toReplayerTime(currentTime));
14408
14566
  }
14409
14567
  };
14410
14568
  const pause = () => {
@@ -14420,9 +14578,9 @@ function instance$1($$self, $$props, $$invalidate) {
14420
14578
  finished = false;
14421
14579
  const resumePlaying = typeof play2 === "boolean" ? play2 : playerState === "playing";
14422
14580
  if (resumePlaying) {
14423
- replayer.play(timeOffset);
14581
+ replayer.play(timeMapper.toReplayerTime(timeOffset));
14424
14582
  } else {
14425
- replayer.pause(timeOffset);
14583
+ replayer.pause(timeMapper.toReplayerTime(timeOffset));
14426
14584
  }
14427
14585
  };
14428
14586
  const playRange = (timeOffset, endTimeOffset, startLooping = false, afterHook = void 0) => {
@@ -14434,7 +14592,7 @@ function instance$1($$self, $$props, $$invalidate) {
14434
14592
  $$invalidate(6, currentTime = timeOffset);
14435
14593
  pauseAt = endTimeOffset;
14436
14594
  onPauseHook = afterHook || null;
14437
- replayer.play(timeOffset);
14595
+ replayer.play(timeMapper.toReplayerTime(timeOffset));
14438
14596
  };
14439
14597
  const handleProgressClick = (event) => {
14440
14598
  if (speedState === "skipping") {
@@ -14469,7 +14627,7 @@ function instance$1($$self, $$props, $$invalidate) {
14469
14627
  }
14470
14628
  replayer.setConfig({ speed });
14471
14629
  if (needFreeze) {
14472
- replayer.play(currentTime);
14630
+ replayer.play(timeMapper.toReplayerTime(currentTime));
14473
14631
  }
14474
14632
  };
14475
14633
  const toggleSkipInactive = () => {
@@ -14477,7 +14635,7 @@ function instance$1($$self, $$props, $$invalidate) {
14477
14635
  };
14478
14636
  const triggerUpdateMeta = () => {
14479
14637
  return Promise.resolve().then(() => {
14480
- $$invalidate(8, meta = replayer.getMetaData());
14638
+ $$invalidate(8, meta = readMeta());
14481
14639
  });
14482
14640
  };
14483
14641
  onMount(() => {
@@ -14541,6 +14699,7 @@ function instance$1($$self, $$props, $$invalidate) {
14541
14699
  if ("speed" in $$props2) $$invalidate(1, speed = $$props2.speed);
14542
14700
  if ("tags" in $$props2) $$invalidate(19, tags = $$props2.tags);
14543
14701
  if ("inactiveColor" in $$props2) $$invalidate(20, inactiveColor = $$props2.inactiveColor);
14702
+ if ("timeMapper" in $$props2) $$invalidate(21, timeMapper = $$props2.timeMapper);
14544
14703
  };
14545
14704
  $$self.$$.update = () => {
14546
14705
  if ($$self.$$.dirty[0] & /*currentTime*/
@@ -14555,10 +14714,6 @@ function instance$1($$self, $$props, $$invalidate) {
14555
14714
  dispatch("ui-update-player-state", { payload: playerState });
14556
14715
  }
14557
14716
  }
14558
- if ($$self.$$.dirty[0] & /*replayer*/
14559
- 131072) {
14560
- $$invalidate(8, meta = replayer.getMetaData());
14561
- }
14562
14717
  if ($$self.$$.dirty[0] & /*currentTime, meta*/
14563
14718
  320) {
14564
14719
  {
@@ -14567,20 +14722,21 @@ function instance$1($$self, $$props, $$invalidate) {
14567
14722
  dispatch("ui-update-progress", { payload: percent });
14568
14723
  }
14569
14724
  }
14570
- if ($$self.$$.dirty[0] & /*replayer, tags*/
14571
- 655360) {
14725
+ if ($$self.$$.dirty[0] & /*replayer, timeMapper, tags*/
14726
+ 2752512) {
14572
14727
  $$invalidate(9, customEvents = (() => {
14573
14728
  const { context } = replayer.service.state;
14574
14729
  const totalEvents = context.events.length;
14575
- const start = context.events[0].timestamp;
14576
- const end = context.events[totalEvents - 1].timestamp;
14730
+ const start = timeMapper.toPlayerAbsolute(context.events[0].timestamp);
14731
+ const end = timeMapper.toPlayerAbsolute(context.events[totalEvents - 1].timestamp);
14577
14732
  const customEvents2 = [];
14578
14733
  context.events.forEach((event) => {
14579
14734
  if (event.type === EventType.Custom) {
14735
+ const convertedTimestamp = timeMapper.toPlayerAbsolute(event.timestamp);
14580
14736
  const customEvent = {
14581
14737
  name: event.data.tag,
14582
14738
  background: tags[event.data.tag] || "rgb(73, 80, 246)",
14583
- position: `${position(start, end, event.timestamp)}%`
14739
+ position: `${position(start, end, convertedTimestamp)}%`
14584
14740
  };
14585
14741
  customEvents2.push(customEvent);
14586
14742
  }
@@ -14588,15 +14744,19 @@ function instance$1($$self, $$props, $$invalidate) {
14588
14744
  return customEvents2;
14589
14745
  })());
14590
14746
  }
14591
- if ($$self.$$.dirty[0] & /*replayer, inactiveColor*/
14592
- 1179648) {
14747
+ if ($$self.$$.dirty[0] & /*replayer, timeMapper, inactiveColor*/
14748
+ 3276800) {
14593
14749
  $$invalidate(13, inactivePeriods = (() => {
14594
14750
  try {
14595
14751
  const { context } = replayer.service.state;
14596
- const totalEvents = context.events.length;
14597
- const start = context.events[0].timestamp;
14598
- const end = context.events[totalEvents - 1].timestamp;
14599
- const periods = getInactivePeriods(context.events, replayer.config.inactivePeriodThreshold);
14752
+ const playerEvents = context.events.map((event) => ({
14753
+ ...event,
14754
+ timestamp: timeMapper.toPlayerAbsolute(event.timestamp)
14755
+ }));
14756
+ const totalEvents = playerEvents.length;
14757
+ const start = playerEvents[0].timestamp;
14758
+ const end = playerEvents[totalEvents - 1].timestamp;
14759
+ const periods = getInactivePeriods(playerEvents, replayer.config.inactivePeriodThreshold);
14600
14760
  const getWidth = (startTime, endTime, tagStart, tagEnd) => {
14601
14761
  const sessionDuration = endTime - startTime;
14602
14762
  const eventDuration = tagEnd - tagStart;
@@ -14615,6 +14775,7 @@ function instance$1($$self, $$props, $$invalidate) {
14615
14775
  })());
14616
14776
  }
14617
14777
  };
14778
+ $$invalidate(8, meta = readMeta());
14618
14779
  return [
14619
14780
  skipInactive,
14620
14781
  speed,
@@ -14637,6 +14798,7 @@ function instance$1($$self, $$props, $$invalidate) {
14637
14798
  autoPlay,
14638
14799
  tags,
14639
14800
  inactiveColor,
14801
+ timeMapper,
14640
14802
  play,
14641
14803
  pause,
14642
14804
  goto,
@@ -14667,14 +14829,15 @@ class Controller extends SvelteComponent {
14667
14829
  speed: 1,
14668
14830
  tags: 19,
14669
14831
  inactiveColor: 20,
14832
+ timeMapper: 21,
14670
14833
  toggle: 4,
14671
- play: 21,
14672
- pause: 22,
14673
- goto: 23,
14674
- playRange: 24,
14834
+ play: 22,
14835
+ pause: 23,
14836
+ goto: 24,
14837
+ playRange: 25,
14675
14838
  setSpeed: 5,
14676
- toggleSkipInactive: 25,
14677
- triggerUpdateMeta: 26
14839
+ toggleSkipInactive: 26,
14840
+ triggerUpdateMeta: 27
14678
14841
  },
14679
14842
  null,
14680
14843
  [-1, -1]
@@ -14684,25 +14847,25 @@ class Controller extends SvelteComponent {
14684
14847
  return this.$$.ctx[4];
14685
14848
  }
14686
14849
  get play() {
14687
- return this.$$.ctx[21];
14850
+ return this.$$.ctx[22];
14688
14851
  }
14689
14852
  get pause() {
14690
- return this.$$.ctx[22];
14853
+ return this.$$.ctx[23];
14691
14854
  }
14692
14855
  get goto() {
14693
- return this.$$.ctx[23];
14856
+ return this.$$.ctx[24];
14694
14857
  }
14695
14858
  get playRange() {
14696
- return this.$$.ctx[24];
14859
+ return this.$$.ctx[25];
14697
14860
  }
14698
14861
  get setSpeed() {
14699
14862
  return this.$$.ctx[5];
14700
14863
  }
14701
14864
  get toggleSkipInactive() {
14702
- return this.$$.ctx[25];
14865
+ return this.$$.ctx[26];
14703
14866
  }
14704
14867
  get triggerUpdateMeta() {
14705
- return this.$$.ctx[26];
14868
+ return this.$$.ctx[27];
14706
14869
  }
14707
14870
  }
14708
14871
  function create_if_block(ctx) {
@@ -14711,7 +14874,7 @@ function create_if_block(ctx) {
14711
14874
  let controller_1_props = {
14712
14875
  replayer: (
14713
14876
  /*replayer*/
14714
- ctx[7]
14877
+ ctx[8]
14715
14878
  ),
14716
14879
  showController: (
14717
14880
  /*showController*/
@@ -14736,14 +14899,18 @@ function create_if_block(ctx) {
14736
14899
  inactiveColor: (
14737
14900
  /*inactiveColor*/
14738
14901
  ctx[5]
14902
+ ),
14903
+ timeMapper: (
14904
+ /*timeMapper*/
14905
+ ctx[7]
14739
14906
  )
14740
14907
  };
14741
14908
  controller_1 = new Controller({ props: controller_1_props });
14742
- ctx[32](controller_1);
14909
+ ctx[34](controller_1);
14743
14910
  controller_1.$on(
14744
14911
  "fullscreen",
14745
14912
  /*fullscreen_handler*/
14746
- ctx[33]
14913
+ ctx[35]
14747
14914
  );
14748
14915
  return {
14749
14916
  c() {
@@ -14756,8 +14923,8 @@ function create_if_block(ctx) {
14756
14923
  p(ctx2, dirty) {
14757
14924
  const controller_1_changes = {};
14758
14925
  if (dirty[0] & /*replayer*/
14759
- 128) controller_1_changes.replayer = /*replayer*/
14760
- ctx2[7];
14926
+ 256) controller_1_changes.replayer = /*replayer*/
14927
+ ctx2[8];
14761
14928
  if (dirty[0] & /*showController*/
14762
14929
  8) controller_1_changes.showController = /*showController*/
14763
14930
  ctx2[3];
@@ -14776,6 +14943,9 @@ function create_if_block(ctx) {
14776
14943
  if (dirty[0] & /*inactiveColor*/
14777
14944
  32) controller_1_changes.inactiveColor = /*inactiveColor*/
14778
14945
  ctx2[5];
14946
+ if (dirty[0] & /*timeMapper*/
14947
+ 128) controller_1_changes.timeMapper = /*timeMapper*/
14948
+ ctx2[7];
14779
14949
  controller_1.$set(controller_1_changes);
14780
14950
  },
14781
14951
  i(local) {
@@ -14788,7 +14958,7 @@ function create_if_block(ctx) {
14788
14958
  current = false;
14789
14959
  },
14790
14960
  d(detaching) {
14791
- ctx[32](null);
14961
+ ctx[34](null);
14792
14962
  destroy_component(controller_1, detaching);
14793
14963
  }
14794
14964
  };
@@ -14800,7 +14970,7 @@ function create_fragment(ctx) {
14800
14970
  let current;
14801
14971
  let if_block = (
14802
14972
  /*replayer*/
14803
- ctx[7] && create_if_block(ctx)
14973
+ ctx[8] && create_if_block(ctx)
14804
14974
  );
14805
14975
  return {
14806
14976
  c() {
@@ -14813,43 +14983,43 @@ function create_fragment(ctx) {
14813
14983
  div0,
14814
14984
  "style",
14815
14985
  /*style*/
14816
- ctx[11]
14986
+ ctx[12]
14817
14987
  );
14818
14988
  attr(div1, "class", "rr-player");
14819
14989
  attr(
14820
14990
  div1,
14821
14991
  "style",
14822
14992
  /*playerStyle*/
14823
- ctx[12]
14993
+ ctx[13]
14824
14994
  );
14825
14995
  },
14826
14996
  m(target, anchor) {
14827
14997
  insert(target, div1, anchor);
14828
14998
  append(div1, div0);
14829
- ctx[31](div0);
14999
+ ctx[33](div0);
14830
15000
  append(div1, t2);
14831
15001
  if (if_block) if_block.m(div1, null);
14832
- ctx[34](div1);
15002
+ ctx[36](div1);
14833
15003
  current = true;
14834
15004
  },
14835
15005
  p(ctx2, dirty) {
14836
15006
  if (!current || dirty[0] & /*style*/
14837
- 2048) {
15007
+ 4096) {
14838
15008
  attr(
14839
15009
  div0,
14840
15010
  "style",
14841
15011
  /*style*/
14842
- ctx2[11]
15012
+ ctx2[12]
14843
15013
  );
14844
15014
  }
14845
15015
  if (
14846
15016
  /*replayer*/
14847
- ctx2[7]
15017
+ ctx2[8]
14848
15018
  ) {
14849
15019
  if (if_block) {
14850
15020
  if_block.p(ctx2, dirty);
14851
15021
  if (dirty[0] & /*replayer*/
14852
- 128) {
15022
+ 256) {
14853
15023
  transition_in(if_block, 1);
14854
15024
  }
14855
15025
  } else {
@@ -14866,12 +15036,12 @@ function create_fragment(ctx) {
14866
15036
  check_outros();
14867
15037
  }
14868
15038
  if (!current || dirty[0] & /*playerStyle*/
14869
- 4096) {
15039
+ 8192) {
14870
15040
  attr(
14871
15041
  div1,
14872
15042
  "style",
14873
15043
  /*playerStyle*/
14874
- ctx2[12]
15044
+ ctx2[13]
14875
15045
  );
14876
15046
  }
14877
15047
  },
@@ -14888,9 +15058,9 @@ function create_fragment(ctx) {
14888
15058
  if (detaching) {
14889
15059
  detach(div1);
14890
15060
  }
14891
- ctx[31](null);
15061
+ ctx[33](null);
14892
15062
  if (if_block) if_block.d();
14893
- ctx[34](null);
15063
+ ctx[36](null);
14894
15064
  }
14895
15065
  };
14896
15066
  }
@@ -14907,6 +15077,9 @@ function instance($$self, $$props, $$invalidate) {
14907
15077
  let { showController = true } = $$props;
14908
15078
  let { tags = {} } = $$props;
14909
15079
  let { inactiveColor = "#D4D4D4" } = $$props;
15080
+ let { allowTimelineNormalization = true } = $$props;
15081
+ let normalizedEvents = events;
15082
+ let timeMapper = createIdentityTimelineMapper();
14910
15083
  let replayer;
14911
15084
  const getMirror = () => replayer.getMirror();
14912
15085
  let player;
@@ -14945,10 +15118,16 @@ function instance($$self, $$props, $$invalidate) {
14945
15118
  }
14946
15119
  };
14947
15120
  const addEvent = (event) => {
14948
- replayer.addEvent(event);
15121
+ const normalizedEvent = timeMapper.normalizeEvent(event);
15122
+ replayer.addEvent(normalizedEvent);
14949
15123
  controller.triggerUpdateMeta();
14950
15124
  };
14951
- const getMetaData = () => replayer.getMetaData();
15125
+ const mapMetaData = (meta) => ({
15126
+ startTime: timeMapper.toPlayerAbsolute(meta.startTime),
15127
+ endTime: timeMapper.toPlayerAbsolute(meta.endTime),
15128
+ totalTime: timeMapper.toPlayerTime(meta.totalTime)
15129
+ });
15130
+ const getMetaData = () => mapMetaData(replayer.getMetaData());
14952
15131
  const getReplayer = () => replayer;
14953
15132
  const toggle = () => {
14954
15133
  controller.toggle();
@@ -14991,8 +15170,8 @@ function instance($$self, $$props, $$invalidate) {
14991
15170
  }
14992
15171
  `);
14993
15172
  }
14994
- $$invalidate(7, replayer = new Replayer(
14995
- events,
15173
+ $$invalidate(8, replayer = new Replayer(
15174
+ normalizedEvents,
14996
15175
  {
14997
15176
  speed,
14998
15177
  root: frame,
@@ -15009,8 +15188,8 @@ function instance($$self, $$props, $$invalidate) {
15009
15188
  () => {
15010
15189
  _width = width;
15011
15190
  _height = height;
15012
- $$invalidate(13, width = player.offsetWidth);
15013
- $$invalidate(14, height = player.offsetHeight - (showController ? controllerHeight : 0));
15191
+ $$invalidate(14, width = player.offsetWidth);
15192
+ $$invalidate(15, height = player.offsetHeight - (showController ? controllerHeight : 0));
15014
15193
  updateScale(replayer.wrapper, {
15015
15194
  width: replayer.iframe.offsetWidth,
15016
15195
  height: replayer.iframe.offsetHeight
@@ -15019,8 +15198,8 @@ function instance($$self, $$props, $$invalidate) {
15019
15198
  0
15020
15199
  );
15021
15200
  } else {
15022
- $$invalidate(13, width = _width);
15023
- $$invalidate(14, height = _height);
15201
+ $$invalidate(14, width = _width);
15202
+ $$invalidate(15, height = _height);
15024
15203
  updateScale(replayer.wrapper, {
15025
15204
  width: replayer.iframe.offsetWidth,
15026
15205
  height: replayer.iframe.offsetHeight
@@ -15034,47 +15213,56 @@ function instance($$self, $$props, $$invalidate) {
15034
15213
  function div0_binding($$value) {
15035
15214
  binding_callbacks[$$value ? "unshift" : "push"](() => {
15036
15215
  frame = $$value;
15037
- $$invalidate(9, frame);
15216
+ $$invalidate(10, frame);
15038
15217
  });
15039
15218
  }
15040
15219
  function controller_1_binding($$value) {
15041
15220
  binding_callbacks[$$value ? "unshift" : "push"](() => {
15042
15221
  controller = $$value;
15043
- $$invalidate(10, controller);
15222
+ $$invalidate(11, controller);
15044
15223
  });
15045
15224
  }
15046
15225
  const fullscreen_handler = () => toggleFullscreen();
15047
15226
  function div1_binding($$value) {
15048
15227
  binding_callbacks[$$value ? "unshift" : "push"](() => {
15049
15228
  player = $$value;
15050
- $$invalidate(8, player);
15229
+ $$invalidate(9, player);
15051
15230
  });
15052
15231
  }
15053
15232
  $$self.$$set = ($$new_props) => {
15054
- $$invalidate(39, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
15055
- if ("width" in $$new_props) $$invalidate(13, width = $$new_props.width);
15056
- if ("height" in $$new_props) $$invalidate(14, height = $$new_props.height);
15057
- if ("maxScale" in $$new_props) $$invalidate(15, maxScale = $$new_props.maxScale);
15058
- if ("events" in $$new_props) $$invalidate(16, events = $$new_props.events);
15233
+ $$invalidate(43, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
15234
+ if ("width" in $$new_props) $$invalidate(14, width = $$new_props.width);
15235
+ if ("height" in $$new_props) $$invalidate(15, height = $$new_props.height);
15236
+ if ("maxScale" in $$new_props) $$invalidate(16, maxScale = $$new_props.maxScale);
15237
+ if ("events" in $$new_props) $$invalidate(17, events = $$new_props.events);
15059
15238
  if ("skipInactive" in $$new_props) $$invalidate(0, skipInactive = $$new_props.skipInactive);
15060
15239
  if ("autoPlay" in $$new_props) $$invalidate(1, autoPlay = $$new_props.autoPlay);
15061
15240
  if ("speedOption" in $$new_props) $$invalidate(2, speedOption = $$new_props.speedOption);
15062
- if ("speed" in $$new_props) $$invalidate(17, speed = $$new_props.speed);
15241
+ if ("speed" in $$new_props) $$invalidate(18, speed = $$new_props.speed);
15063
15242
  if ("showController" in $$new_props) $$invalidate(3, showController = $$new_props.showController);
15064
15243
  if ("tags" in $$new_props) $$invalidate(4, tags = $$new_props.tags);
15065
15244
  if ("inactiveColor" in $$new_props) $$invalidate(5, inactiveColor = $$new_props.inactiveColor);
15245
+ if ("allowTimelineNormalization" in $$new_props) $$invalidate(19, allowTimelineNormalization = $$new_props.allowTimelineNormalization);
15066
15246
  };
15067
15247
  $$self.$$.update = () => {
15248
+ if ($$self.$$.dirty[0] & /*events, allowTimelineNormalization*/
15249
+ 655360) {
15250
+ {
15251
+ const result2 = normalizeEventsForReplay(events, allowTimelineNormalization);
15252
+ normalizedEvents = result2.events;
15253
+ $$invalidate(7, timeMapper = result2.mapper);
15254
+ }
15255
+ }
15068
15256
  if ($$self.$$.dirty[0] & /*width, height*/
15069
- 24576) {
15070
- $$invalidate(11, style = inlineCss({
15257
+ 49152) {
15258
+ $$invalidate(12, style = inlineCss({
15071
15259
  width: `${width}px`,
15072
15260
  height: `${height}px`
15073
15261
  }));
15074
15262
  }
15075
15263
  if ($$self.$$.dirty[0] & /*width, height, showController*/
15076
- 24584) {
15077
- $$invalidate(12, playerStyle = inlineCss({
15264
+ 49160) {
15265
+ $$invalidate(13, playerStyle = inlineCss({
15078
15266
  width: `${width}px`,
15079
15267
  height: `${height + (showController ? controllerHeight : 0)}px`
15080
15268
  }));
@@ -15089,6 +15277,7 @@ function instance($$self, $$props, $$invalidate) {
15089
15277
  tags,
15090
15278
  inactiveColor,
15091
15279
  toggleFullscreen,
15280
+ timeMapper,
15092
15281
  replayer,
15093
15282
  player,
15094
15283
  frame,
@@ -15100,6 +15289,7 @@ function instance($$self, $$props, $$invalidate) {
15100
15289
  maxScale,
15101
15290
  events,
15102
15291
  speed,
15292
+ allowTimelineNormalization,
15103
15293
  getMirror,
15104
15294
  triggerResize,
15105
15295
  addEventListener,
@@ -15129,77 +15319,78 @@ let Player$1 = class Player extends SvelteComponent {
15129
15319
  create_fragment,
15130
15320
  safe_not_equal,
15131
15321
  {
15132
- width: 13,
15133
- height: 14,
15134
- maxScale: 15,
15135
- events: 16,
15322
+ width: 14,
15323
+ height: 15,
15324
+ maxScale: 16,
15325
+ events: 17,
15136
15326
  skipInactive: 0,
15137
15327
  autoPlay: 1,
15138
15328
  speedOption: 2,
15139
- speed: 17,
15329
+ speed: 18,
15140
15330
  showController: 3,
15141
15331
  tags: 4,
15142
15332
  inactiveColor: 5,
15143
- getMirror: 18,
15144
- triggerResize: 19,
15333
+ allowTimelineNormalization: 19,
15334
+ getMirror: 20,
15335
+ triggerResize: 21,
15145
15336
  toggleFullscreen: 6,
15146
- addEventListener: 20,
15147
- addEvent: 21,
15148
- getMetaData: 22,
15149
- getReplayer: 23,
15150
- toggle: 24,
15151
- setSpeed: 25,
15152
- toggleSkipInactive: 26,
15153
- play: 27,
15154
- pause: 28,
15155
- goto: 29,
15156
- playRange: 30
15337
+ addEventListener: 22,
15338
+ addEvent: 23,
15339
+ getMetaData: 24,
15340
+ getReplayer: 25,
15341
+ toggle: 26,
15342
+ setSpeed: 27,
15343
+ toggleSkipInactive: 28,
15344
+ play: 29,
15345
+ pause: 30,
15346
+ goto: 31,
15347
+ playRange: 32
15157
15348
  },
15158
15349
  null,
15159
15350
  [-1, -1]
15160
15351
  );
15161
15352
  }
15162
15353
  get getMirror() {
15163
- return this.$$.ctx[18];
15354
+ return this.$$.ctx[20];
15164
15355
  }
15165
15356
  get triggerResize() {
15166
- return this.$$.ctx[19];
15357
+ return this.$$.ctx[21];
15167
15358
  }
15168
15359
  get toggleFullscreen() {
15169
15360
  return this.$$.ctx[6];
15170
15361
  }
15171
15362
  get addEventListener() {
15172
- return this.$$.ctx[20];
15363
+ return this.$$.ctx[22];
15173
15364
  }
15174
15365
  get addEvent() {
15175
- return this.$$.ctx[21];
15366
+ return this.$$.ctx[23];
15176
15367
  }
15177
15368
  get getMetaData() {
15178
- return this.$$.ctx[22];
15369
+ return this.$$.ctx[24];
15179
15370
  }
15180
15371
  get getReplayer() {
15181
- return this.$$.ctx[23];
15372
+ return this.$$.ctx[25];
15182
15373
  }
15183
15374
  get toggle() {
15184
- return this.$$.ctx[24];
15375
+ return this.$$.ctx[26];
15185
15376
  }
15186
15377
  get setSpeed() {
15187
- return this.$$.ctx[25];
15378
+ return this.$$.ctx[27];
15188
15379
  }
15189
15380
  get toggleSkipInactive() {
15190
- return this.$$.ctx[26];
15381
+ return this.$$.ctx[28];
15191
15382
  }
15192
15383
  get play() {
15193
- return this.$$.ctx[27];
15384
+ return this.$$.ctx[29];
15194
15385
  }
15195
15386
  get pause() {
15196
- return this.$$.ctx[28];
15387
+ return this.$$.ctx[30];
15197
15388
  }
15198
15389
  get goto() {
15199
- return this.$$.ctx[29];
15390
+ return this.$$.ctx[31];
15200
15391
  }
15201
15392
  get playRange() {
15202
- return this.$$.ctx[30];
15393
+ return this.$$.ctx[32];
15203
15394
  }
15204
15395
  };
15205
15396
  class Player2 extends Player$1 {