@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.
@@ -11041,7 +11041,7 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
11041
11041
  if (lastPlayedTimestamp && lastPlayedTimestamp < baselineTime && (event.timestamp <= lastPlayedTimestamp || event === lastPlayedEvent)) {
11042
11042
  continue;
11043
11043
  }
11044
- if (event.timestamp < baselineTime) {
11044
+ if (event.timestamp <= baselineTime) {
11045
11045
  syncEvents.push(event);
11046
11046
  } else {
11047
11047
  const castFn = getCastFn(event, false);
@@ -13897,6 +13897,154 @@ function getInactivePeriods(events, inactivePeriodThreshold) {
13897
13897
  }
13898
13898
  return inactivePeriods;
13899
13899
  }
13900
+ const NORMALIZATION_GAP = 1e-3;
13901
+ const NORMALIZATION_MIN_BLOCK_SPAN = 1;
13902
+ function createIdentityTimelineMapper() {
13903
+ return {
13904
+ normalizationApplied: false,
13905
+ toReplayerTime: (offset) => offset,
13906
+ toPlayerTime: (offset) => offset,
13907
+ toReplayerAbsolute: (value) => value,
13908
+ toPlayerAbsolute: (value) => value,
13909
+ normalizeEvent: (event) => event
13910
+ };
13911
+ }
13912
+ function normalizeEventsForReplay(events, allowNormalization = true) {
13913
+ if (!events.length) {
13914
+ const mapper2 = createIdentityTimelineMapper();
13915
+ return { events, mapper: mapper2 };
13916
+ }
13917
+ const params = allowNormalization ? getNormalizationParams(events) : null;
13918
+ const normalizedEvents = events.map(
13919
+ (event) => normalizeEventWithParams(event, params)
13920
+ );
13921
+ const originalStart = getTimelineStart(events);
13922
+ const normalizedStart = getTimelineStart(normalizedEvents);
13923
+ const mapper = createTimelineMapper(params, originalStart, normalizedStart);
13924
+ return { events: normalizedEvents, mapper };
13925
+ }
13926
+ function getTimelineStart(events) {
13927
+ return events.reduce((min, event) => Math.min(min, event.timestamp), Infinity);
13928
+ }
13929
+ function getNormalizationParams(events) {
13930
+ const firstFull = events.find((event) => event.type === EventType.FullSnapshot);
13931
+ if (!firstFull) {
13932
+ return null;
13933
+ }
13934
+ const problemEvents = events.filter(
13935
+ (event) => event.type === EventType.IncrementalSnapshot && event.timestamp < firstFull.timestamp
13936
+ );
13937
+ if (!problemEvents.length) {
13938
+ return null;
13939
+ }
13940
+ const earliestProblem = problemEvents.reduce(
13941
+ (min, event) => Math.min(min, event.timestamp),
13942
+ Infinity
13943
+ );
13944
+ const latestProblem = problemEvents.reduce(
13945
+ (max2, event) => Math.max(max2, event.timestamp),
13946
+ -Infinity
13947
+ );
13948
+ const span = Math.max(0, latestProblem - earliestProblem);
13949
+ const blockSpan = Math.max(span, NORMALIZATION_MIN_BLOCK_SPAN);
13950
+ return {
13951
+ earliestProblem,
13952
+ span,
13953
+ blockSpan,
13954
+ blockStart: firstFull.timestamp + NORMALIZATION_GAP,
13955
+ tailShift: NORMALIZATION_GAP + blockSpan,
13956
+ firstFullTimestamp: firstFull.timestamp
13957
+ };
13958
+ }
13959
+ function normalizeEventWithParams(event, params) {
13960
+ if (!params) {
13961
+ return event;
13962
+ }
13963
+ const domDependent = event.type === EventType.IncrementalSnapshot && event.timestamp < params.firstFullTimestamp;
13964
+ const normalizedTimestamp = normalizeTimestamp(
13965
+ event.timestamp,
13966
+ domDependent,
13967
+ params
13968
+ );
13969
+ if (normalizedTimestamp === event.timestamp) {
13970
+ return event;
13971
+ }
13972
+ return __spreadProps(__spreadValues({}, event), {
13973
+ timestamp: normalizedTimestamp
13974
+ });
13975
+ }
13976
+ function normalizeTimestamp(timestamp, domDependent, params) {
13977
+ if (!params) {
13978
+ return timestamp;
13979
+ }
13980
+ if (timestamp > params.firstFullTimestamp) {
13981
+ return timestamp + params.tailShift;
13982
+ }
13983
+ if (domDependent && timestamp < params.firstFullTimestamp) {
13984
+ if (params.span === 0) {
13985
+ return params.blockStart;
13986
+ }
13987
+ const scale = params.blockSpan / params.span;
13988
+ return params.blockStart + (timestamp - params.earliestProblem) * scale;
13989
+ }
13990
+ return timestamp;
13991
+ }
13992
+ function convertAbsoluteToNormalized(value, params) {
13993
+ if (!params) {
13994
+ return value;
13995
+ }
13996
+ if (value > params.firstFullTimestamp) {
13997
+ return value + params.tailShift;
13998
+ }
13999
+ if (value >= params.earliestProblem && value < params.firstFullTimestamp) {
14000
+ if (params.span === 0) {
14001
+ return params.blockStart;
14002
+ }
14003
+ const scale = params.blockSpan / params.span;
14004
+ return params.blockStart + (value - params.earliestProblem) * scale;
14005
+ }
14006
+ return value;
14007
+ }
14008
+ function convertAbsoluteToOriginal(value, params) {
14009
+ if (!params) {
14010
+ return value;
14011
+ }
14012
+ const blockEnd = params.blockStart + params.blockSpan;
14013
+ const tailStart = params.firstFullTimestamp + params.tailShift;
14014
+ if (value >= tailStart) {
14015
+ return value - params.tailShift;
14016
+ }
14017
+ if (value >= params.blockStart && value <= blockEnd) {
14018
+ if (params.span === 0) {
14019
+ return params.earliestProblem;
14020
+ }
14021
+ const scale = params.blockSpan / params.span;
14022
+ return params.earliestProblem + (value - params.blockStart) / scale;
14023
+ }
14024
+ return value;
14025
+ }
14026
+ function createTimelineMapper(params, originalStart, normalizedStart) {
14027
+ const safeOriginalStart = Number.isFinite(originalStart) ? originalStart : 0;
14028
+ const safeNormalizedStart = Number.isFinite(normalizedStart) ? normalizedStart : 0;
14029
+ const toReplayerAbsolute = (value) => convertAbsoluteToNormalized(value, params);
14030
+ const toPlayerAbsolute = (value) => convertAbsoluteToOriginal(value, params);
14031
+ return {
14032
+ normalizationApplied: Boolean(params),
14033
+ normalizeEvent: (event) => normalizeEventWithParams(event, params),
14034
+ toReplayerAbsolute,
14035
+ toPlayerAbsolute,
14036
+ toReplayerTime: (offset) => {
14037
+ const absoluteOriginal = safeOriginalStart + offset;
14038
+ const normalizedAbsolute = toReplayerAbsolute(absoluteOriginal);
14039
+ return normalizedAbsolute - safeNormalizedStart;
14040
+ },
14041
+ toPlayerTime: (offset) => {
14042
+ const normalizedAbsolute = safeNormalizedStart + offset;
14043
+ const originalAbsolute = toPlayerAbsolute(normalizedAbsolute);
14044
+ return originalAbsolute - safeOriginalStart;
14045
+ }
14046
+ };
14047
+ }
13900
14048
  function create_fragment$2(ctx) {
13901
14049
  let div;
13902
14050
  let input2;
@@ -14051,17 +14199,17 @@ class Switch extends SvelteComponent {
14051
14199
  }
14052
14200
  function get_each_context(ctx, list2, i) {
14053
14201
  const child_ctx = ctx.slice();
14054
- child_ctx[38] = list2[i];
14202
+ child_ctx[40] = list2[i];
14055
14203
  return child_ctx;
14056
14204
  }
14057
14205
  function get_each_context_1(ctx, list2, i) {
14058
14206
  const child_ctx = ctx.slice();
14059
- child_ctx[41] = list2[i];
14207
+ child_ctx[43] = list2[i];
14060
14208
  return child_ctx;
14061
14209
  }
14062
14210
  function get_each_context_2(ctx, list2, i) {
14063
14211
  const child_ctx = ctx.slice();
14064
- child_ctx[44] = list2[i];
14212
+ child_ctx[46] = list2[i];
14065
14213
  return child_ctx;
14066
14214
  }
14067
14215
  function create_if_block$1(ctx) {
@@ -14134,7 +14282,7 @@ function create_if_block$1(ctx) {
14134
14282
  each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
14135
14283
  }
14136
14284
  function switch_1_checked_binding(value) {
14137
- ctx[29](value);
14285
+ ctx[30](value);
14138
14286
  }
14139
14287
  let switch_1_props = {
14140
14288
  id: "skip",
@@ -14245,7 +14393,7 @@ function create_if_block$1(ctx) {
14245
14393
  }
14246
14394
  append(div2, t4);
14247
14395
  append(div2, div1);
14248
- ctx[27](div2);
14396
+ ctx[28](div2);
14249
14397
  append(div3, t5);
14250
14398
  append(div3, span1);
14251
14399
  append(span1, t6);
@@ -14288,7 +14436,7 @@ function create_if_block$1(ctx) {
14288
14436
  button1,
14289
14437
  "click",
14290
14438
  /*click_handler_1*/
14291
- ctx[30]
14439
+ ctx[31]
14292
14440
  )
14293
14441
  ];
14294
14442
  mounted = true;
@@ -14438,7 +14586,7 @@ function create_if_block$1(ctx) {
14438
14586
  }
14439
14587
  destroy_each(each_blocks_2, detaching);
14440
14588
  destroy_each(each_blocks_1, detaching);
14441
- ctx[27](null);
14589
+ ctx[28](null);
14442
14590
  if_block.d();
14443
14591
  destroy_each(each_blocks, detaching);
14444
14592
  destroy_component(switch_1);
@@ -14454,12 +14602,12 @@ function create_each_block_2(ctx) {
14454
14602
  c() {
14455
14603
  div = element("div");
14456
14604
  attr(div, "title", div_title_value = /*period*/
14457
- ctx[44].name);
14605
+ ctx[46].name);
14458
14606
  set_style(
14459
14607
  div,
14460
14608
  "width",
14461
14609
  /*period*/
14462
- ctx[44].width
14610
+ ctx[46].width
14463
14611
  );
14464
14612
  set_style(div, "height", "4px");
14465
14613
  set_style(div, "position", "absolute");
@@ -14467,13 +14615,13 @@ function create_each_block_2(ctx) {
14467
14615
  div,
14468
14616
  "background",
14469
14617
  /*period*/
14470
- ctx[44].background
14618
+ ctx[46].background
14471
14619
  );
14472
14620
  set_style(
14473
14621
  div,
14474
14622
  "left",
14475
14623
  /*period*/
14476
- ctx[44].position
14624
+ ctx[46].position
14477
14625
  );
14478
14626
  },
14479
14627
  m(target, anchor) {
@@ -14482,7 +14630,7 @@ function create_each_block_2(ctx) {
14482
14630
  p(ctx2, dirty) {
14483
14631
  if (dirty[0] & /*inactivePeriods*/
14484
14632
  8192 && div_title_value !== (div_title_value = /*period*/
14485
- ctx2[44].name)) {
14633
+ ctx2[46].name)) {
14486
14634
  attr(div, "title", div_title_value);
14487
14635
  }
14488
14636
  if (dirty[0] & /*inactivePeriods*/
@@ -14491,7 +14639,7 @@ function create_each_block_2(ctx) {
14491
14639
  div,
14492
14640
  "width",
14493
14641
  /*period*/
14494
- ctx2[44].width
14642
+ ctx2[46].width
14495
14643
  );
14496
14644
  }
14497
14645
  if (dirty[0] & /*inactivePeriods*/
@@ -14500,7 +14648,7 @@ function create_each_block_2(ctx) {
14500
14648
  div,
14501
14649
  "background",
14502
14650
  /*period*/
14503
- ctx2[44].background
14651
+ ctx2[46].background
14504
14652
  );
14505
14653
  }
14506
14654
  if (dirty[0] & /*inactivePeriods*/
@@ -14509,7 +14657,7 @@ function create_each_block_2(ctx) {
14509
14657
  div,
14510
14658
  "left",
14511
14659
  /*period*/
14512
- ctx2[44].position
14660
+ ctx2[46].position
14513
14661
  );
14514
14662
  }
14515
14663
  },
@@ -14527,7 +14675,7 @@ function create_each_block_1(ctx) {
14527
14675
  c() {
14528
14676
  div = element("div");
14529
14677
  attr(div, "title", div_title_value = /*event*/
14530
- ctx[41].name);
14678
+ ctx[43].name);
14531
14679
  set_style(div, "width", "10px");
14532
14680
  set_style(div, "height", "5px");
14533
14681
  set_style(div, "position", "absolute");
@@ -14537,13 +14685,13 @@ function create_each_block_1(ctx) {
14537
14685
  div,
14538
14686
  "background",
14539
14687
  /*event*/
14540
- ctx[41].background
14688
+ ctx[43].background
14541
14689
  );
14542
14690
  set_style(
14543
14691
  div,
14544
14692
  "left",
14545
14693
  /*event*/
14546
- ctx[41].position
14694
+ ctx[43].position
14547
14695
  );
14548
14696
  },
14549
14697
  m(target, anchor) {
@@ -14552,7 +14700,7 @@ function create_each_block_1(ctx) {
14552
14700
  p(ctx2, dirty) {
14553
14701
  if (dirty[0] & /*customEvents*/
14554
14702
  512 && div_title_value !== (div_title_value = /*event*/
14555
- ctx2[41].name)) {
14703
+ ctx2[43].name)) {
14556
14704
  attr(div, "title", div_title_value);
14557
14705
  }
14558
14706
  if (dirty[0] & /*customEvents*/
@@ -14561,7 +14709,7 @@ function create_each_block_1(ctx) {
14561
14709
  div,
14562
14710
  "background",
14563
14711
  /*event*/
14564
- ctx2[41].background
14712
+ ctx2[43].background
14565
14713
  );
14566
14714
  }
14567
14715
  if (dirty[0] & /*customEvents*/
@@ -14570,7 +14718,7 @@ function create_each_block_1(ctx) {
14570
14718
  div,
14571
14719
  "left",
14572
14720
  /*event*/
14573
- ctx2[41].position
14721
+ ctx2[43].position
14574
14722
  );
14575
14723
  }
14576
14724
  },
@@ -14639,7 +14787,7 @@ function create_each_block(ctx) {
14639
14787
  let button;
14640
14788
  let t0_value = (
14641
14789
  /*s*/
14642
- ctx[38] + ""
14790
+ ctx[40] + ""
14643
14791
  );
14644
14792
  let t0;
14645
14793
  let t1;
@@ -14649,9 +14797,9 @@ function create_each_block(ctx) {
14649
14797
  function click_handler() {
14650
14798
  return (
14651
14799
  /*click_handler*/
14652
- ctx[28](
14800
+ ctx[29](
14653
14801
  /*s*/
14654
- ctx[38]
14802
+ ctx[40]
14655
14803
  )
14656
14804
  );
14657
14805
  }
@@ -14667,7 +14815,7 @@ function create_each_block(ctx) {
14667
14815
  button,
14668
14816
  "active",
14669
14817
  /*s*/
14670
- ctx[38] === /*speed*/
14818
+ ctx[40] === /*speed*/
14671
14819
  ctx[1] && /*speedState*/
14672
14820
  ctx[10] !== "skipping"
14673
14821
  );
@@ -14685,7 +14833,7 @@ function create_each_block(ctx) {
14685
14833
  ctx = new_ctx;
14686
14834
  if (dirty[0] & /*speedOption*/
14687
14835
  8 && t0_value !== (t0_value = /*s*/
14688
- ctx[38] + ""))
14836
+ ctx[40] + ""))
14689
14837
  set_data(t0, t0_value);
14690
14838
  if (dirty[0] & /*speedState*/
14691
14839
  1024 && button_disabled_value !== (button_disabled_value = /*speedState*/
@@ -14698,7 +14846,7 @@ function create_each_block(ctx) {
14698
14846
  button,
14699
14847
  "active",
14700
14848
  /*s*/
14701
- ctx[38] === /*speed*/
14849
+ ctx[40] === /*speed*/
14702
14850
  ctx[1] && /*speedState*/
14703
14851
  ctx[10] !== "skipping"
14704
14852
  );
@@ -14792,6 +14940,7 @@ function instance$1($$self, $$props, $$invalidate) {
14792
14940
  let { speed = speedOption.length ? speedOption[0] : 1 } = $$props;
14793
14941
  let { tags = {} } = $$props;
14794
14942
  let { inactiveColor } = $$props;
14943
+ let { timeMapper = createIdentityTimelineMapper() } = $$props;
14795
14944
  let currentTime = 0;
14796
14945
  let timer = null;
14797
14946
  let playerState;
@@ -14801,6 +14950,14 @@ function instance$1($$self, $$props, $$invalidate) {
14801
14950
  let pauseAt = false;
14802
14951
  let onPauseHook = null;
14803
14952
  let loop = null;
14953
+ const readMeta = () => {
14954
+ const rawMeta = replayer.getMetaData();
14955
+ return {
14956
+ startTime: timeMapper.toPlayerAbsolute(rawMeta.startTime),
14957
+ endTime: timeMapper.toPlayerAbsolute(rawMeta.endTime),
14958
+ totalTime: timeMapper.toPlayerTime(rawMeta.totalTime)
14959
+ };
14960
+ };
14804
14961
  let meta;
14805
14962
  let percentage;
14806
14963
  let customEvents;
@@ -14808,7 +14965,7 @@ function instance$1($$self, $$props, $$invalidate) {
14808
14965
  const loopTimer = () => {
14809
14966
  stopTimer();
14810
14967
  function update2() {
14811
- $$invalidate(6, currentTime = replayer.getCurrentTime());
14968
+ $$invalidate(6, currentTime = timeMapper.toPlayerTime(replayer.getCurrentTime()));
14812
14969
  if (pauseAt && currentTime >= pauseAt) {
14813
14970
  if (loop) {
14814
14971
  playRange(loop.start, loop.end, true, void 0);
@@ -14850,7 +15007,7 @@ function instance$1($$self, $$props, $$invalidate) {
14850
15007
  replayer.play();
14851
15008
  finished = false;
14852
15009
  } else {
14853
- replayer.play(currentTime);
15010
+ replayer.play(timeMapper.toReplayerTime(currentTime));
14854
15011
  }
14855
15012
  };
14856
15013
  const pause = () => {
@@ -14866,9 +15023,9 @@ function instance$1($$self, $$props, $$invalidate) {
14866
15023
  finished = false;
14867
15024
  const resumePlaying = typeof play2 === "boolean" ? play2 : playerState === "playing";
14868
15025
  if (resumePlaying) {
14869
- replayer.play(timeOffset);
15026
+ replayer.play(timeMapper.toReplayerTime(timeOffset));
14870
15027
  } else {
14871
- replayer.pause(timeOffset);
15028
+ replayer.pause(timeMapper.toReplayerTime(timeOffset));
14872
15029
  }
14873
15030
  };
14874
15031
  const playRange = (timeOffset, endTimeOffset, startLooping = false, afterHook = void 0) => {
@@ -14880,7 +15037,7 @@ function instance$1($$self, $$props, $$invalidate) {
14880
15037
  $$invalidate(6, currentTime = timeOffset);
14881
15038
  pauseAt = endTimeOffset;
14882
15039
  onPauseHook = afterHook || null;
14883
- replayer.play(timeOffset);
15040
+ replayer.play(timeMapper.toReplayerTime(timeOffset));
14884
15041
  };
14885
15042
  const handleProgressClick = (event) => {
14886
15043
  if (speedState === "skipping") {
@@ -14915,7 +15072,7 @@ function instance$1($$self, $$props, $$invalidate) {
14915
15072
  }
14916
15073
  replayer.setConfig({ speed });
14917
15074
  if (needFreeze) {
14918
- replayer.play(currentTime);
15075
+ replayer.play(timeMapper.toReplayerTime(currentTime));
14919
15076
  }
14920
15077
  };
14921
15078
  const toggleSkipInactive = () => {
@@ -14923,7 +15080,7 @@ function instance$1($$self, $$props, $$invalidate) {
14923
15080
  };
14924
15081
  const triggerUpdateMeta = () => {
14925
15082
  return Promise.resolve().then(() => {
14926
- $$invalidate(8, meta = replayer.getMetaData());
15083
+ $$invalidate(8, meta = readMeta());
14927
15084
  });
14928
15085
  };
14929
15086
  onMount(() => {
@@ -14995,6 +15152,8 @@ function instance$1($$self, $$props, $$invalidate) {
14995
15152
  $$invalidate(19, tags = $$props2.tags);
14996
15153
  if ("inactiveColor" in $$props2)
14997
15154
  $$invalidate(20, inactiveColor = $$props2.inactiveColor);
15155
+ if ("timeMapper" in $$props2)
15156
+ $$invalidate(21, timeMapper = $$props2.timeMapper);
14998
15157
  };
14999
15158
  $$self.$$.update = () => {
15000
15159
  if ($$self.$$.dirty[0] & /*currentTime*/
@@ -15009,10 +15168,6 @@ function instance$1($$self, $$props, $$invalidate) {
15009
15168
  dispatch("ui-update-player-state", { payload: playerState });
15010
15169
  }
15011
15170
  }
15012
- if ($$self.$$.dirty[0] & /*replayer*/
15013
- 131072) {
15014
- $$invalidate(8, meta = replayer.getMetaData());
15015
- }
15016
15171
  if ($$self.$$.dirty[0] & /*currentTime, meta*/
15017
15172
  320) {
15018
15173
  {
@@ -15021,20 +15176,21 @@ function instance$1($$self, $$props, $$invalidate) {
15021
15176
  dispatch("ui-update-progress", { payload: percent });
15022
15177
  }
15023
15178
  }
15024
- if ($$self.$$.dirty[0] & /*replayer, tags*/
15025
- 655360) {
15179
+ if ($$self.$$.dirty[0] & /*replayer, timeMapper, tags*/
15180
+ 2752512) {
15026
15181
  $$invalidate(9, customEvents = (() => {
15027
15182
  const { context } = replayer.service.state;
15028
15183
  const totalEvents = context.events.length;
15029
- const start = context.events[0].timestamp;
15030
- const end = context.events[totalEvents - 1].timestamp;
15184
+ const start = timeMapper.toPlayerAbsolute(context.events[0].timestamp);
15185
+ const end = timeMapper.toPlayerAbsolute(context.events[totalEvents - 1].timestamp);
15031
15186
  const customEvents2 = [];
15032
15187
  context.events.forEach((event) => {
15033
15188
  if (event.type === EventType.Custom) {
15189
+ const convertedTimestamp = timeMapper.toPlayerAbsolute(event.timestamp);
15034
15190
  const customEvent = {
15035
15191
  name: event.data.tag,
15036
15192
  background: tags[event.data.tag] || "rgb(73, 80, 246)",
15037
- position: `${position(start, end, event.timestamp)}%`
15193
+ position: `${position(start, end, convertedTimestamp)}%`
15038
15194
  };
15039
15195
  customEvents2.push(customEvent);
15040
15196
  }
@@ -15042,15 +15198,18 @@ function instance$1($$self, $$props, $$invalidate) {
15042
15198
  return customEvents2;
15043
15199
  })());
15044
15200
  }
15045
- if ($$self.$$.dirty[0] & /*replayer, inactiveColor*/
15046
- 1179648) {
15201
+ if ($$self.$$.dirty[0] & /*replayer, timeMapper, inactiveColor*/
15202
+ 3276800) {
15047
15203
  $$invalidate(13, inactivePeriods = (() => {
15048
15204
  try {
15049
15205
  const { context } = replayer.service.state;
15050
- const totalEvents = context.events.length;
15051
- const start = context.events[0].timestamp;
15052
- const end = context.events[totalEvents - 1].timestamp;
15053
- const periods = getInactivePeriods(context.events, replayer.config.inactivePeriodThreshold);
15206
+ const playerEvents = context.events.map((event) => __spreadProps(__spreadValues({}, event), {
15207
+ timestamp: timeMapper.toPlayerAbsolute(event.timestamp)
15208
+ }));
15209
+ const totalEvents = playerEvents.length;
15210
+ const start = playerEvents[0].timestamp;
15211
+ const end = playerEvents[totalEvents - 1].timestamp;
15212
+ const periods = getInactivePeriods(playerEvents, replayer.config.inactivePeriodThreshold);
15054
15213
  const getWidth = (startTime, endTime, tagStart, tagEnd) => {
15055
15214
  const sessionDuration = endTime - startTime;
15056
15215
  const eventDuration = tagEnd - tagStart;
@@ -15069,6 +15228,7 @@ function instance$1($$self, $$props, $$invalidate) {
15069
15228
  })());
15070
15229
  }
15071
15230
  };
15231
+ $$invalidate(8, meta = readMeta());
15072
15232
  return [
15073
15233
  skipInactive,
15074
15234
  speed,
@@ -15091,6 +15251,7 @@ function instance$1($$self, $$props, $$invalidate) {
15091
15251
  autoPlay,
15092
15252
  tags,
15093
15253
  inactiveColor,
15254
+ timeMapper,
15094
15255
  play,
15095
15256
  pause,
15096
15257
  goto,
@@ -15121,14 +15282,15 @@ class Controller extends SvelteComponent {
15121
15282
  speed: 1,
15122
15283
  tags: 19,
15123
15284
  inactiveColor: 20,
15285
+ timeMapper: 21,
15124
15286
  toggle: 4,
15125
- play: 21,
15126
- pause: 22,
15127
- goto: 23,
15128
- playRange: 24,
15287
+ play: 22,
15288
+ pause: 23,
15289
+ goto: 24,
15290
+ playRange: 25,
15129
15291
  setSpeed: 5,
15130
- toggleSkipInactive: 25,
15131
- triggerUpdateMeta: 26
15292
+ toggleSkipInactive: 26,
15293
+ triggerUpdateMeta: 27
15132
15294
  },
15133
15295
  null,
15134
15296
  [-1, -1]
@@ -15138,25 +15300,25 @@ class Controller extends SvelteComponent {
15138
15300
  return this.$$.ctx[4];
15139
15301
  }
15140
15302
  get play() {
15141
- return this.$$.ctx[21];
15303
+ return this.$$.ctx[22];
15142
15304
  }
15143
15305
  get pause() {
15144
- return this.$$.ctx[22];
15306
+ return this.$$.ctx[23];
15145
15307
  }
15146
15308
  get goto() {
15147
- return this.$$.ctx[23];
15309
+ return this.$$.ctx[24];
15148
15310
  }
15149
15311
  get playRange() {
15150
- return this.$$.ctx[24];
15312
+ return this.$$.ctx[25];
15151
15313
  }
15152
15314
  get setSpeed() {
15153
15315
  return this.$$.ctx[5];
15154
15316
  }
15155
15317
  get toggleSkipInactive() {
15156
- return this.$$.ctx[25];
15318
+ return this.$$.ctx[26];
15157
15319
  }
15158
15320
  get triggerUpdateMeta() {
15159
- return this.$$.ctx[26];
15321
+ return this.$$.ctx[27];
15160
15322
  }
15161
15323
  }
15162
15324
  function create_if_block(ctx) {
@@ -15165,7 +15327,7 @@ function create_if_block(ctx) {
15165
15327
  let controller_1_props = {
15166
15328
  replayer: (
15167
15329
  /*replayer*/
15168
- ctx[7]
15330
+ ctx[8]
15169
15331
  ),
15170
15332
  showController: (
15171
15333
  /*showController*/
@@ -15190,14 +15352,18 @@ function create_if_block(ctx) {
15190
15352
  inactiveColor: (
15191
15353
  /*inactiveColor*/
15192
15354
  ctx[5]
15355
+ ),
15356
+ timeMapper: (
15357
+ /*timeMapper*/
15358
+ ctx[7]
15193
15359
  )
15194
15360
  };
15195
15361
  controller_1 = new Controller({ props: controller_1_props });
15196
- ctx[32](controller_1);
15362
+ ctx[34](controller_1);
15197
15363
  controller_1.$on(
15198
15364
  "fullscreen",
15199
15365
  /*fullscreen_handler*/
15200
- ctx[33]
15366
+ ctx[35]
15201
15367
  );
15202
15368
  return {
15203
15369
  c() {
@@ -15210,9 +15376,9 @@ function create_if_block(ctx) {
15210
15376
  p(ctx2, dirty) {
15211
15377
  const controller_1_changes = {};
15212
15378
  if (dirty[0] & /*replayer*/
15213
- 128)
15379
+ 256)
15214
15380
  controller_1_changes.replayer = /*replayer*/
15215
- ctx2[7];
15381
+ ctx2[8];
15216
15382
  if (dirty[0] & /*showController*/
15217
15383
  8)
15218
15384
  controller_1_changes.showController = /*showController*/
@@ -15237,6 +15403,10 @@ function create_if_block(ctx) {
15237
15403
  32)
15238
15404
  controller_1_changes.inactiveColor = /*inactiveColor*/
15239
15405
  ctx2[5];
15406
+ if (dirty[0] & /*timeMapper*/
15407
+ 128)
15408
+ controller_1_changes.timeMapper = /*timeMapper*/
15409
+ ctx2[7];
15240
15410
  controller_1.$set(controller_1_changes);
15241
15411
  },
15242
15412
  i(local) {
@@ -15250,7 +15420,7 @@ function create_if_block(ctx) {
15250
15420
  current = false;
15251
15421
  },
15252
15422
  d(detaching) {
15253
- ctx[32](null);
15423
+ ctx[34](null);
15254
15424
  destroy_component(controller_1, detaching);
15255
15425
  }
15256
15426
  };
@@ -15262,7 +15432,7 @@ function create_fragment(ctx) {
15262
15432
  let current;
15263
15433
  let if_block = (
15264
15434
  /*replayer*/
15265
- ctx[7] && create_if_block(ctx)
15435
+ ctx[8] && create_if_block(ctx)
15266
15436
  );
15267
15437
  return {
15268
15438
  c() {
@@ -15276,44 +15446,44 @@ function create_fragment(ctx) {
15276
15446
  div0,
15277
15447
  "style",
15278
15448
  /*style*/
15279
- ctx[11]
15449
+ ctx[12]
15280
15450
  );
15281
15451
  attr(div1, "class", "rr-player");
15282
15452
  attr(
15283
15453
  div1,
15284
15454
  "style",
15285
15455
  /*playerStyle*/
15286
- ctx[12]
15456
+ ctx[13]
15287
15457
  );
15288
15458
  },
15289
15459
  m(target, anchor) {
15290
15460
  insert(target, div1, anchor);
15291
15461
  append(div1, div0);
15292
- ctx[31](div0);
15462
+ ctx[33](div0);
15293
15463
  append(div1, t2);
15294
15464
  if (if_block)
15295
15465
  if_block.m(div1, null);
15296
- ctx[34](div1);
15466
+ ctx[36](div1);
15297
15467
  current = true;
15298
15468
  },
15299
15469
  p(ctx2, dirty) {
15300
15470
  if (!current || dirty[0] & /*style*/
15301
- 2048) {
15471
+ 4096) {
15302
15472
  attr(
15303
15473
  div0,
15304
15474
  "style",
15305
15475
  /*style*/
15306
- ctx2[11]
15476
+ ctx2[12]
15307
15477
  );
15308
15478
  }
15309
15479
  if (
15310
15480
  /*replayer*/
15311
- ctx2[7]
15481
+ ctx2[8]
15312
15482
  ) {
15313
15483
  if (if_block) {
15314
15484
  if_block.p(ctx2, dirty);
15315
15485
  if (dirty[0] & /*replayer*/
15316
- 128) {
15486
+ 256) {
15317
15487
  transition_in(if_block, 1);
15318
15488
  }
15319
15489
  } else {
@@ -15330,12 +15500,12 @@ function create_fragment(ctx) {
15330
15500
  check_outros();
15331
15501
  }
15332
15502
  if (!current || dirty[0] & /*playerStyle*/
15333
- 4096) {
15503
+ 8192) {
15334
15504
  attr(
15335
15505
  div1,
15336
15506
  "style",
15337
15507
  /*playerStyle*/
15338
- ctx2[12]
15508
+ ctx2[13]
15339
15509
  );
15340
15510
  }
15341
15511
  },
@@ -15353,10 +15523,10 @@ function create_fragment(ctx) {
15353
15523
  if (detaching) {
15354
15524
  detach(div1);
15355
15525
  }
15356
- ctx[31](null);
15526
+ ctx[33](null);
15357
15527
  if (if_block)
15358
15528
  if_block.d();
15359
- ctx[34](null);
15529
+ ctx[36](null);
15360
15530
  }
15361
15531
  };
15362
15532
  }
@@ -15373,6 +15543,9 @@ function instance($$self, $$props, $$invalidate) {
15373
15543
  let { showController = true } = $$props;
15374
15544
  let { tags = {} } = $$props;
15375
15545
  let { inactiveColor = "#D4D4D4" } = $$props;
15546
+ let { allowTimelineNormalization = true } = $$props;
15547
+ let normalizedEvents = events;
15548
+ let timeMapper = createIdentityTimelineMapper();
15376
15549
  let replayer;
15377
15550
  const getMirror = () => replayer.getMirror();
15378
15551
  let player;
@@ -15412,10 +15585,16 @@ function instance($$self, $$props, $$invalidate) {
15412
15585
  }
15413
15586
  };
15414
15587
  const addEvent = (event) => {
15415
- replayer.addEvent(event);
15588
+ const normalizedEvent = timeMapper.normalizeEvent(event);
15589
+ replayer.addEvent(normalizedEvent);
15416
15590
  controller.triggerUpdateMeta();
15417
15591
  };
15418
- const getMetaData = () => replayer.getMetaData();
15592
+ const mapMetaData = (meta) => ({
15593
+ startTime: timeMapper.toPlayerAbsolute(meta.startTime),
15594
+ endTime: timeMapper.toPlayerAbsolute(meta.endTime),
15595
+ totalTime: timeMapper.toPlayerTime(meta.totalTime)
15596
+ });
15597
+ const getMetaData = () => mapMetaData(replayer.getMetaData());
15419
15598
  const getReplayer = () => replayer;
15420
15599
  const toggle = () => {
15421
15600
  controller.toggle();
@@ -15458,8 +15637,8 @@ function instance($$self, $$props, $$invalidate) {
15458
15637
  }
15459
15638
  `);
15460
15639
  }
15461
- $$invalidate(7, replayer = new Replayer(
15462
- events,
15640
+ $$invalidate(8, replayer = new Replayer(
15641
+ normalizedEvents,
15463
15642
  __spreadValues({
15464
15643
  speed,
15465
15644
  root: frame,
@@ -15475,8 +15654,8 @@ function instance($$self, $$props, $$invalidate) {
15475
15654
  () => {
15476
15655
  _width = width;
15477
15656
  _height = height;
15478
- $$invalidate(13, width = player.offsetWidth);
15479
- $$invalidate(14, height = player.offsetHeight - (showController ? controllerHeight : 0));
15657
+ $$invalidate(14, width = player.offsetWidth);
15658
+ $$invalidate(15, height = player.offsetHeight - (showController ? controllerHeight : 0));
15480
15659
  updateScale(replayer.wrapper, {
15481
15660
  width: replayer.iframe.offsetWidth,
15482
15661
  height: replayer.iframe.offsetHeight
@@ -15485,8 +15664,8 @@ function instance($$self, $$props, $$invalidate) {
15485
15664
  0
15486
15665
  );
15487
15666
  } else {
15488
- $$invalidate(13, width = _width);
15489
- $$invalidate(14, height = _height);
15667
+ $$invalidate(14, width = _width);
15668
+ $$invalidate(15, height = _height);
15490
15669
  updateScale(replayer.wrapper, {
15491
15670
  width: replayer.iframe.offsetWidth,
15492
15671
  height: replayer.iframe.offsetHeight
@@ -15500,32 +15679,32 @@ function instance($$self, $$props, $$invalidate) {
15500
15679
  function div0_binding($$value) {
15501
15680
  binding_callbacks[$$value ? "unshift" : "push"](() => {
15502
15681
  frame = $$value;
15503
- $$invalidate(9, frame);
15682
+ $$invalidate(10, frame);
15504
15683
  });
15505
15684
  }
15506
15685
  function controller_1_binding($$value) {
15507
15686
  binding_callbacks[$$value ? "unshift" : "push"](() => {
15508
15687
  controller = $$value;
15509
- $$invalidate(10, controller);
15688
+ $$invalidate(11, controller);
15510
15689
  });
15511
15690
  }
15512
15691
  const fullscreen_handler = () => toggleFullscreen();
15513
15692
  function div1_binding($$value) {
15514
15693
  binding_callbacks[$$value ? "unshift" : "push"](() => {
15515
15694
  player = $$value;
15516
- $$invalidate(8, player);
15695
+ $$invalidate(9, player);
15517
15696
  });
15518
15697
  }
15519
15698
  $$self.$$set = ($$new_props) => {
15520
- $$invalidate(39, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
15699
+ $$invalidate(43, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
15521
15700
  if ("width" in $$new_props)
15522
- $$invalidate(13, width = $$new_props.width);
15701
+ $$invalidate(14, width = $$new_props.width);
15523
15702
  if ("height" in $$new_props)
15524
- $$invalidate(14, height = $$new_props.height);
15703
+ $$invalidate(15, height = $$new_props.height);
15525
15704
  if ("maxScale" in $$new_props)
15526
- $$invalidate(15, maxScale = $$new_props.maxScale);
15705
+ $$invalidate(16, maxScale = $$new_props.maxScale);
15527
15706
  if ("events" in $$new_props)
15528
- $$invalidate(16, events = $$new_props.events);
15707
+ $$invalidate(17, events = $$new_props.events);
15529
15708
  if ("skipInactive" in $$new_props)
15530
15709
  $$invalidate(0, skipInactive = $$new_props.skipInactive);
15531
15710
  if ("autoPlay" in $$new_props)
@@ -15533,25 +15712,35 @@ function instance($$self, $$props, $$invalidate) {
15533
15712
  if ("speedOption" in $$new_props)
15534
15713
  $$invalidate(2, speedOption = $$new_props.speedOption);
15535
15714
  if ("speed" in $$new_props)
15536
- $$invalidate(17, speed = $$new_props.speed);
15715
+ $$invalidate(18, speed = $$new_props.speed);
15537
15716
  if ("showController" in $$new_props)
15538
15717
  $$invalidate(3, showController = $$new_props.showController);
15539
15718
  if ("tags" in $$new_props)
15540
15719
  $$invalidate(4, tags = $$new_props.tags);
15541
15720
  if ("inactiveColor" in $$new_props)
15542
15721
  $$invalidate(5, inactiveColor = $$new_props.inactiveColor);
15722
+ if ("allowTimelineNormalization" in $$new_props)
15723
+ $$invalidate(19, allowTimelineNormalization = $$new_props.allowTimelineNormalization);
15543
15724
  };
15544
15725
  $$self.$$.update = () => {
15726
+ if ($$self.$$.dirty[0] & /*events, allowTimelineNormalization*/
15727
+ 655360) {
15728
+ {
15729
+ const result2 = normalizeEventsForReplay(events, allowTimelineNormalization);
15730
+ normalizedEvents = result2.events;
15731
+ $$invalidate(7, timeMapper = result2.mapper);
15732
+ }
15733
+ }
15545
15734
  if ($$self.$$.dirty[0] & /*width, height*/
15546
- 24576) {
15547
- $$invalidate(11, style = inlineCss({
15735
+ 49152) {
15736
+ $$invalidate(12, style = inlineCss({
15548
15737
  width: `${width}px`,
15549
15738
  height: `${height}px`
15550
15739
  }));
15551
15740
  }
15552
15741
  if ($$self.$$.dirty[0] & /*width, height, showController*/
15553
- 24584) {
15554
- $$invalidate(12, playerStyle = inlineCss({
15742
+ 49160) {
15743
+ $$invalidate(13, playerStyle = inlineCss({
15555
15744
  width: `${width}px`,
15556
15745
  height: `${height + (showController ? controllerHeight : 0)}px`
15557
15746
  }));
@@ -15566,6 +15755,7 @@ function instance($$self, $$props, $$invalidate) {
15566
15755
  tags,
15567
15756
  inactiveColor,
15568
15757
  toggleFullscreen,
15758
+ timeMapper,
15569
15759
  replayer,
15570
15760
  player,
15571
15761
  frame,
@@ -15577,6 +15767,7 @@ function instance($$self, $$props, $$invalidate) {
15577
15767
  maxScale,
15578
15768
  events,
15579
15769
  speed,
15770
+ allowTimelineNormalization,
15580
15771
  getMirror,
15581
15772
  triggerResize,
15582
15773
  addEventListener,
@@ -15606,77 +15797,78 @@ let Player$1 = class Player extends SvelteComponent {
15606
15797
  create_fragment,
15607
15798
  safe_not_equal,
15608
15799
  {
15609
- width: 13,
15610
- height: 14,
15611
- maxScale: 15,
15612
- events: 16,
15800
+ width: 14,
15801
+ height: 15,
15802
+ maxScale: 16,
15803
+ events: 17,
15613
15804
  skipInactive: 0,
15614
15805
  autoPlay: 1,
15615
15806
  speedOption: 2,
15616
- speed: 17,
15807
+ speed: 18,
15617
15808
  showController: 3,
15618
15809
  tags: 4,
15619
15810
  inactiveColor: 5,
15620
- getMirror: 18,
15621
- triggerResize: 19,
15811
+ allowTimelineNormalization: 19,
15812
+ getMirror: 20,
15813
+ triggerResize: 21,
15622
15814
  toggleFullscreen: 6,
15623
- addEventListener: 20,
15624
- addEvent: 21,
15625
- getMetaData: 22,
15626
- getReplayer: 23,
15627
- toggle: 24,
15628
- setSpeed: 25,
15629
- toggleSkipInactive: 26,
15630
- play: 27,
15631
- pause: 28,
15632
- goto: 29,
15633
- playRange: 30
15815
+ addEventListener: 22,
15816
+ addEvent: 23,
15817
+ getMetaData: 24,
15818
+ getReplayer: 25,
15819
+ toggle: 26,
15820
+ setSpeed: 27,
15821
+ toggleSkipInactive: 28,
15822
+ play: 29,
15823
+ pause: 30,
15824
+ goto: 31,
15825
+ playRange: 32
15634
15826
  },
15635
15827
  null,
15636
15828
  [-1, -1]
15637
15829
  );
15638
15830
  }
15639
15831
  get getMirror() {
15640
- return this.$$.ctx[18];
15832
+ return this.$$.ctx[20];
15641
15833
  }
15642
15834
  get triggerResize() {
15643
- return this.$$.ctx[19];
15835
+ return this.$$.ctx[21];
15644
15836
  }
15645
15837
  get toggleFullscreen() {
15646
15838
  return this.$$.ctx[6];
15647
15839
  }
15648
15840
  get addEventListener() {
15649
- return this.$$.ctx[20];
15841
+ return this.$$.ctx[22];
15650
15842
  }
15651
15843
  get addEvent() {
15652
- return this.$$.ctx[21];
15844
+ return this.$$.ctx[23];
15653
15845
  }
15654
15846
  get getMetaData() {
15655
- return this.$$.ctx[22];
15847
+ return this.$$.ctx[24];
15656
15848
  }
15657
15849
  get getReplayer() {
15658
- return this.$$.ctx[23];
15850
+ return this.$$.ctx[25];
15659
15851
  }
15660
15852
  get toggle() {
15661
- return this.$$.ctx[24];
15853
+ return this.$$.ctx[26];
15662
15854
  }
15663
15855
  get setSpeed() {
15664
- return this.$$.ctx[25];
15856
+ return this.$$.ctx[27];
15665
15857
  }
15666
15858
  get toggleSkipInactive() {
15667
- return this.$$.ctx[26];
15859
+ return this.$$.ctx[28];
15668
15860
  }
15669
15861
  get play() {
15670
- return this.$$.ctx[27];
15862
+ return this.$$.ctx[29];
15671
15863
  }
15672
15864
  get pause() {
15673
- return this.$$.ctx[28];
15865
+ return this.$$.ctx[30];
15674
15866
  }
15675
15867
  get goto() {
15676
- return this.$$.ctx[29];
15868
+ return this.$$.ctx[31];
15677
15869
  }
15678
15870
  get playRange() {
15679
- return this.$$.ctx[30];
15871
+ return this.$$.ctx[32];
15680
15872
  }
15681
15873
  };
15682
15874
  class Player2 extends Player$1 {