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

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