@spider-analyzer/timeline 5.0.3 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 5.0.4
2
+
3
+ - Fix: memoize the moment-typed props built by the outer TimeLine
4
+ wrapper. Previously `histo`, `quality`, `timeSpan`, `maxDomain`,
5
+ duration props, and the xAxis/margin defaults were rebuilt on every
6
+ wrapper render. The inner component's "did this reference change?"
7
+ effects (`histo !== prevHisto`, width/margin, etc.) fired on every
8
+ render, each calling `setState` and forcing another render — an
9
+ infinite loop that pegged CPU, kept the loader visible forever, and
10
+ left the x-axis ticks empty. Stabilizing the references with
11
+ `useMemo` (keyed on the raw consumer references) breaks the loop.
12
+
1
13
  ## 5.0.3
2
14
 
3
15
  - Fix: preserve `undefined` at the Date-→-Moment boundary. Optional
package/dist/index.js CHANGED
@@ -2773,19 +2773,55 @@ var TimeLine2 = react.forwardRef(function TimeLineWrapper(props, ref) {
2773
2773
  if (ret && typeof ret.then === "function") ret.then(apply);
2774
2774
  else if (ret) apply(ret);
2775
2775
  }, [props.onLoadDefaultDomain, props.onDomainChange, zone]);
2776
+ const timeSpanMoments = react.useMemo(
2777
+ () => props.timeSpan ? timeSpanToMoments(props.timeSpan, zone) : void 0,
2778
+ [props.timeSpan, zone]
2779
+ );
2780
+ const maxDomainMoments = react.useMemo(
2781
+ () => props.maxDomain ? domainToMoments(props.maxDomain, zone) : void 0,
2782
+ [props.maxDomain, zone]
2783
+ );
2784
+ const histoMoments = react.useMemo(
2785
+ () => props.histo?.items ? { ...props.histo, items: props.histo.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.histo,
2786
+ [props.histo, zone]
2787
+ );
2788
+ const qualityMoments = react.useMemo(
2789
+ () => props.quality?.items ? { ...props.quality, items: props.quality.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.quality,
2790
+ [props.quality, zone]
2791
+ );
2792
+ const biggestVisibleDomainDur = react.useMemo(
2793
+ () => props.biggestVisibleDomain != null ? toDuration(props.biggestVisibleDomain) : void 0,
2794
+ [props.biggestVisibleDomain]
2795
+ );
2796
+ const biggestTimeSpanDur = react.useMemo(
2797
+ () => props.biggestTimeSpan != null ? toDuration(props.biggestTimeSpan) : void 0,
2798
+ [props.biggestTimeSpan]
2799
+ );
2800
+ const smallestResolutionDur = react.useMemo(
2801
+ () => props.smallestResolution != null ? toDuration(props.smallestResolution) : void 0,
2802
+ [props.smallestResolution]
2803
+ );
2804
+ const xAxisMerged = react.useMemo(
2805
+ () => ({ ...xAxisDefault, ...props.xAxis ?? {} }),
2806
+ [props.xAxis]
2807
+ );
2808
+ const marginMerged = react.useMemo(
2809
+ () => ({ ...marginDefault, ...props.margin ?? {} }),
2810
+ [props.margin]
2811
+ );
2776
2812
  const innerProps = {
2777
2813
  ...props,
2778
- xAxis: { ...xAxisDefault, ...props.xAxis ?? {} },
2814
+ xAxis: xAxisMerged,
2779
2815
  yAxis: props.yAxis ?? {},
2780
- margin: { ...marginDefault, ...props.margin ?? {} },
2816
+ margin: marginMerged,
2781
2817
  domains: stack,
2782
- timeSpan: props.timeSpan ? timeSpanToMoments(props.timeSpan, zone) : void 0,
2783
- maxDomain: props.maxDomain ? domainToMoments(props.maxDomain, zone) : void 0,
2784
- histo: props.histo?.items ? { ...props.histo, items: props.histo.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.histo,
2785
- quality: props.quality?.items ? { ...props.quality, items: props.quality.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.quality,
2786
- biggestVisibleDomain: props.biggestVisibleDomain != null ? toDuration(props.biggestVisibleDomain) : void 0,
2787
- biggestTimeSpan: props.biggestTimeSpan != null ? toDuration(props.biggestTimeSpan) : void 0,
2788
- smallestResolution: props.smallestResolution != null ? toDuration(props.smallestResolution) : void 0,
2818
+ timeSpan: timeSpanMoments,
2819
+ maxDomain: maxDomainMoments,
2820
+ histo: histoMoments,
2821
+ quality: qualityMoments,
2822
+ biggestVisibleDomain: biggestVisibleDomainDur,
2823
+ biggestTimeSpan: biggestTimeSpanDur,
2824
+ smallestResolution: smallestResolutionDur,
2789
2825
  onUpdateDomains: handleUpdateDomains,
2790
2826
  onLoadDefaultDomain: handleLoadDefault,
2791
2827
  // onLoadHisto: object shape + Date instants