react-native-livechart 4.28.2 → 4.30.0

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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/components/LiveChart.d.ts.map +1 -1
  3. package/dist/components/LiveChartSeries.d.ts.map +1 -1
  4. package/dist/components/LoadingOverlay.d.ts +6 -1
  5. package/dist/components/LoadingOverlay.d.ts.map +1 -1
  6. package/dist/components/ResetButtonOverlay.d.ts +25 -0
  7. package/dist/components/ResetButtonOverlay.d.ts.map +1 -0
  8. package/dist/constants.d.ts +6 -0
  9. package/dist/constants.d.ts.map +1 -1
  10. package/dist/core/gestureRangeOwnership.d.ts +13 -0
  11. package/dist/core/gestureRangeOwnership.d.ts.map +1 -0
  12. package/dist/core/liveChartEngineTick.d.ts +33 -1
  13. package/dist/core/liveChartEngineTick.d.ts.map +1 -1
  14. package/dist/core/resolveConfig.d.ts +39 -2
  15. package/dist/core/resolveConfig.d.ts.map +1 -1
  16. package/dist/core/useLiveChartEngine.d.ts +35 -2
  17. package/dist/core/useLiveChartEngine.d.ts.map +1 -1
  18. package/dist/draw/line.d.ts.map +1 -1
  19. package/dist/hooks/resetButtonLayout.d.ts +24 -0
  20. package/dist/hooks/resetButtonLayout.d.ts.map +1 -0
  21. package/dist/hooks/resetView.d.ts +31 -0
  22. package/dist/hooks/resetView.d.ts.map +1 -0
  23. package/dist/hooks/useBadge.d.ts.map +1 -1
  24. package/dist/hooks/useChartPaths.d.ts +3 -1
  25. package/dist/hooks/useChartPaths.d.ts.map +1 -1
  26. package/dist/hooks/useDemandFrameLoop.d.ts.map +1 -1
  27. package/dist/hooks/useLiveDot.d.ts +5 -2
  28. package/dist/hooks/useLiveDot.d.ts.map +1 -1
  29. package/dist/hooks/usePanScroll.d.ts +39 -3
  30. package/dist/hooks/usePanScroll.d.ts.map +1 -1
  31. package/dist/hooks/useReferenceLine.d.ts.map +1 -1
  32. package/dist/hooks/useResetButton.d.ts +41 -0
  33. package/dist/hooks/useResetButton.d.ts.map +1 -0
  34. package/dist/hooks/useYAxisScaleGesture.d.ts +14 -1
  35. package/dist/hooks/useYAxisScaleGesture.d.ts.map +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/math/squiggly.d.ts +12 -0
  39. package/dist/math/squiggly.d.ts.map +1 -1
  40. package/dist/types.d.ts +167 -11
  41. package/dist/types.d.ts.map +1 -1
  42. package/package.json +2 -2
  43. package/src/components/LiveChart.tsx +75 -4
  44. package/src/components/LiveChartSeries.tsx +9 -1
  45. package/src/components/LoadingOverlay.tsx +44 -6
  46. package/src/components/ResetButtonOverlay.tsx +129 -0
  47. package/src/constants.ts +7 -0
  48. package/src/core/gestureRangeOwnership.ts +46 -0
  49. package/src/core/liveChartEngineTick.ts +103 -2
  50. package/src/core/resolveConfig.ts +88 -2
  51. package/src/core/useLiveChartEngine.ts +122 -4
  52. package/src/draw/line.ts +13 -5
  53. package/src/hooks/resetButtonLayout.ts +80 -0
  54. package/src/hooks/resetView.ts +92 -0
  55. package/src/hooks/useBadge.ts +18 -5
  56. package/src/hooks/useChartPaths.ts +6 -4
  57. package/src/hooks/useDemandFrameLoop.ts +7 -2
  58. package/src/hooks/useLiveDot.ts +26 -11
  59. package/src/hooks/usePanScroll.ts +177 -5
  60. package/src/hooks/useReferenceLine.ts +4 -1
  61. package/src/hooks/useResetButton.ts +181 -0
  62. package/src/hooks/useYAxisScaleGesture.ts +70 -13
  63. package/src/index.ts +3 -0
  64. package/src/math/squiggly.ts +27 -0
  65. package/src/types.ts +170 -11
@@ -0,0 +1,129 @@
1
+ import { useCallback, useState, type ReactElement } from "react";
2
+ import { StyleSheet, Text, View, type AccessibilityActionEvent, type LayoutChangeEvent } from "react-native";
3
+ import Animated, {
4
+ useAnimatedReaction,
5
+ useAnimatedStyle,
6
+ useDerivedValue,
7
+ withTiming,
8
+ type SharedValue,
9
+ } from "react-native-reanimated";
10
+ import { scheduleOnRN } from "react-native-worklets";
11
+
12
+ import type { ResolvedResetButtonConfig } from "../core/resolveConfig";
13
+ import type { ResetButtonRect } from "../hooks/resetButtonLayout";
14
+ import type { LiveChartPalette, ResetButtonRenderProps } from "../types";
15
+
16
+ /**
17
+ * React Native overlay (NOT Skia) for the floating reset-view button. The
18
+ * wrapper is positioned from the chart's rect on the UI thread and faded with
19
+ * `visible`; the tap itself is an RNGH gesture composed ahead of the plot graph
20
+ * (see `useResetButton`), so the content here is a plain view. Renders the
21
+ * consumer's `renderResetButton` element when given, otherwise a round glyph
22
+ * button in palette colors.
23
+ */
24
+ export function ResetButtonOverlay({
25
+ config,
26
+ visible,
27
+ rect,
28
+ measuredWidth,
29
+ measuredHeight,
30
+ reset,
31
+ render,
32
+ palette,
33
+ fontFamily,
34
+ }: {
35
+ config: ResolvedResetButtonConfig;
36
+ visible: SharedValue<boolean>;
37
+ rect: SharedValue<ResetButtonRect>;
38
+ measuredWidth: SharedValue<number>;
39
+ measuredHeight: SharedValue<number>;
40
+ reset: () => void;
41
+ render: ((props: ResetButtonRenderProps) => ReactElement) | undefined;
42
+ palette: LiveChartPalette;
43
+ fontFamily: string;
44
+ }) {
45
+ const { fadeMs } = config;
46
+ const opacity = useDerivedValue(() =>
47
+ withTiming(visible.get() ? 1 : 0, { duration: fadeMs }),
48
+ );
49
+ const wrapperStyle = useAnimatedStyle(() => {
50
+ const r = rect.get();
51
+ return {
52
+ opacity: opacity.get(),
53
+ transform: [{ translateX: r.x }, { translateY: r.y }],
54
+ };
55
+ });
56
+
57
+ // Mirrored to React so a hidden button is neither focusable by screen
58
+ // readers nor a target for native touches (the chart's RNGH gestures are
59
+ // unaffected either way: they live on the ancestor view).
60
+ const [isShown, setIsShown] = useState(false);
61
+ useAnimatedReaction(
62
+ () => visible.get(),
63
+ /* istanbul ignore next -- Reanimated reaction; state mirrored on the JS thread, not exercised under Jest */
64
+ (shown, previous) => {
65
+ if (shown !== previous) scheduleOnRN(setIsShown, shown);
66
+ },
67
+ );
68
+
69
+ const onLayout = useCallback(
70
+ (event: LayoutChangeEvent) => {
71
+ const { width, height } = event.nativeEvent.layout;
72
+ measuredWidth.set(width);
73
+ measuredHeight.set(height);
74
+ },
75
+ [measuredHeight, measuredWidth],
76
+ );
77
+ const onAccessibilityAction = useCallback(
78
+ (event: AccessibilityActionEvent) => {
79
+ if (event.nativeEvent.actionName === "activate") reset();
80
+ },
81
+ [reset],
82
+ );
83
+
84
+ return (
85
+ <Animated.View
86
+ style={[styles.wrapper, wrapperStyle]}
87
+ onLayout={onLayout}
88
+ pointerEvents={isShown ? "box-none" : "none"}
89
+ accessibilityElementsHidden={!isShown}
90
+ importantForAccessibility={isShown ? "auto" : "no-hide-descendants"}
91
+ >
92
+ {render ? (
93
+ render({ visible, reset })
94
+ ) : (
95
+ <View
96
+ accessible
97
+ accessibilityRole="button"
98
+ accessibilityLabel={config.accessibilityLabel}
99
+ onAccessibilityTap={reset}
100
+ accessibilityActions={[{ name: "activate" }]}
101
+ onAccessibilityAction={onAccessibilityAction}
102
+ style={{
103
+ width: config.size,
104
+ height: config.size,
105
+ borderRadius: config.size / 2,
106
+ backgroundColor: config.color ?? palette.badgeBg,
107
+ alignItems: "center",
108
+ justifyContent: "center",
109
+ }}
110
+ >
111
+ <Text
112
+ allowFontScaling={false}
113
+ style={{
114
+ fontFamily,
115
+ fontSize: config.size / 2,
116
+ color: config.iconColor ?? palette.badgeText,
117
+ }}
118
+ >
119
+ {config.icon}
120
+ </Text>
121
+ </View>
122
+ )}
123
+ </Animated.View>
124
+ );
125
+ }
126
+
127
+ const styles = StyleSheet.create({
128
+ wrapper: { position: "absolute", left: 0, top: 0 },
129
+ });
package/src/constants.ts CHANGED
@@ -9,6 +9,13 @@ import type {
9
9
  /** Milliseconds per frame at 60 fps — baseline for frame-rate-independent lerp. */
10
10
  export const MS_PER_FRAME_60FPS = 16.67;
11
11
 
12
+ /**
13
+ * Longest frame delta (ms) that time counted in frames takes from one frame —
14
+ * about two 60fps frames — so the first frame back from the background, or
15
+ * after a stall, counts as one frame rather than the time away.
16
+ */
17
+ export const MAX_FRAME_DELTA_MS = 34;
18
+
12
19
  /**
13
20
  * Initial size of the Y-axis label pool. The pool grows when the dynamic
14
21
  * (nice-interval) grid produces more labels (a tall plot or a small `minGap`);
@@ -0,0 +1,46 @@
1
+ import { useLayoutEffect, useState } from "react";
2
+ import { useSharedValue, type SharedValue } from "react-native-reanimated";
3
+ import { scheduleOnUI } from "react-native-worklets";
4
+
5
+ import type { ChartScale } from "../types";
6
+
7
+ type PriceRange = Pick<ChartScale, "min" | "max"> | null;
8
+
9
+ // Keep separate from Reanimated's positive mapper IDs and history listener IDs.
10
+ let nextRangeListenerId = -1_000_000;
11
+
12
+ /**
13
+ * App writes relinquish ownership synchronously, including modify() calls and
14
+ * writes followed by a reset in the same worklet. Replacing the supplied range
15
+ * also relinquishes ownership before the new viewport is painted.
16
+ */
17
+ export function useGestureRangeOwnership(range: SharedValue<PriceRange>) {
18
+ const owned = useSharedValue(false);
19
+ const [listenerId] = useState(() => nextRangeListenerId--);
20
+ useLayoutEffect(() => {
21
+ scheduleOnUI(() => {
22
+ "worklet";
23
+ owned.set(false);
24
+ range.addListener(listenerId, () => {
25
+ "worklet";
26
+ owned.set(false);
27
+ });
28
+ });
29
+ return () => scheduleOnUI(() => {
30
+ "worklet";
31
+ range.removeListener(listenerId);
32
+ });
33
+ }, [range, owned, listenerId]);
34
+ return owned;
35
+ }
36
+
37
+ /** Mark only this write as gesture-owned, after synchronous listeners run. */
38
+ export function writeGestureRange(
39
+ range: SharedValue<PriceRange>,
40
+ owned: SharedValue<boolean>,
41
+ next: Exclude<PriceRange, null>,
42
+ ): void {
43
+ "worklet";
44
+ range.value = next;
45
+ owned.value = true;
46
+ }
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  CandleGap,
3
3
  CandlePoint,
4
+ ChartScale,
4
5
  LiveChartPoint,
5
6
  RangeAnimationConfig,
6
7
  } from "../types";
@@ -51,6 +52,22 @@ export interface EngineTickMutable {
51
52
  extremaMaxValue: number;
52
53
  extremaMinTime: number;
53
54
  extremaMaxTime: number;
55
+ /**
56
+ * Fitted Y bounds this frame — the target the eased display range pursues,
57
+ * before an explicit {@link EngineTickInput.viewRange} overrides it. The
58
+ * price-pan gesture clamps its travel against these. Written every frame;
59
+ * optional so existing state literals stay valid.
60
+ */
61
+ fitMin?: number;
62
+ fitMax?: number;
63
+ /**
64
+ * A gesture-owned {@link EngineTickInput.viewRange} after
65
+ * {@link clampGestureRange}, when the clamp changed it. The engine writes it
66
+ * back to the shared value so the next gesture frame starts from the clamped
67
+ * bounds. `NaN` when nothing was adjusted; written every frame.
68
+ */
69
+ adjustedViewRangeMin?: number;
70
+ adjustedViewRangeMax?: number;
54
71
  /** Previous frame's yRangeScale — detects an in-flight scale drag. */
55
72
  lastYRangeScale?: number;
56
73
  /** Canvas width observed by the previous measured tick. */
@@ -92,6 +109,15 @@ export interface EngineTickInput {
92
109
  minRange?: number;
93
110
  /** Positive, finite Y-range multiplier around the fitted midpoint (1 = auto-fit). */
94
111
  yRangeScale?: number;
112
+ /** Explicit finite price bounds for a freely positioned external viewport. */
113
+ viewRange?: Pick<ChartScale, "min" | "max"> | null;
114
+ /**
115
+ * Apply {@link viewRange} while following live too (`viewEnd` null). Set for
116
+ * a range written by the price-pan / axis-scale gestures, so the price window
117
+ * holds as new data streams in. An app-written range keeps the
118
+ * `viewEnd`-only rule. Default `false`.
119
+ */
120
+ viewRangeFollowsLive?: boolean;
95
121
  targetValue: number;
96
122
  points: LiveChartPoint[];
97
123
  /** Internal notification revision for the selected history; omit to disable reuse. */
@@ -199,6 +225,44 @@ export function advanceTimestampByPixel(
199
225
  return elapsedSteps > 0 ? current + elapsedSteps * step : current;
200
226
  }
201
227
 
228
+ /**
229
+ * Keep a gesture-owned explicit range inside the chart's hard bounds, which
230
+ * the fit normally enforces: widen a span below `minRange` about its midpoint,
231
+ * then slide the window to respect `nonNegative` / `maxValue`. Returns the
232
+ * input object itself when nothing changes.
233
+ */
234
+ export function clampGestureRange(
235
+ range: Pick<ChartScale, "min" | "max">,
236
+ nonNegative: boolean,
237
+ maxValue: number | undefined,
238
+ minRange: number | undefined,
239
+ ): Pick<ChartScale, "min" | "max"> {
240
+ "worklet";
241
+ let min = range.min;
242
+ let max = range.max;
243
+ if (
244
+ minRange !== undefined &&
245
+ minRange > 0 &&
246
+ Number.isFinite(minRange) &&
247
+ max - min < minRange
248
+ ) {
249
+ const mid = min / 2 + max / 2;
250
+ min = mid - minRange / 2;
251
+ max = mid + minRange / 2;
252
+ }
253
+ if (nonNegative && min < 0) {
254
+ max -= min;
255
+ min = 0;
256
+ }
257
+ if (maxValue !== undefined && max > maxValue) {
258
+ min -= max - maxValue;
259
+ max = maxValue;
260
+ if (nonNegative && min < 0) min = 0;
261
+ }
262
+ if (!(Number.isFinite(min) && Number.isFinite(max) && min < max)) return range;
263
+ return min === range.min && max === range.max ? range : { min, max };
264
+ }
265
+
202
266
  /**
203
267
  * One frame of the live chart engine (mirrors `useLiveChartEngine` worklet body).
204
268
  * Mutates `state` in place for testability and reuse from the hook.
@@ -218,6 +282,17 @@ export function tickLiveChartEngineFrame(
218
282
  const timestampSecondsPerPixel =
219
283
  Math.min(state.displayWindow, targetWindow) / input.canvasWidth;
220
284
  const viewEnd = input.viewEnd;
285
+ const requestedRange = input.viewRange;
286
+ const viewRange =
287
+ ((viewEnd != null && Number.isFinite(viewEnd)) ||
288
+ input.viewRangeFollowsLive === true) &&
289
+ requestedRange &&
290
+ Number.isFinite(requestedRange.min) &&
291
+ Number.isFinite(requestedRange.max) &&
292
+ requestedRange.min < requestedRange.max &&
293
+ Number.isFinite(requestedRange.max - requestedRange.min)
294
+ ? requestedRange
295
+ : undefined;
221
296
  // First time of the visible series' data — the floor a frozen edge must stay
222
297
  // at or above. `-Infinity` when there's no data to bound against, so the freeze
223
298
  // still works (we can't strand a plot we have no time bounds for).
@@ -235,10 +310,11 @@ export function tickLiveChartEngineFrame(
235
310
  // time-scroll is disabled the hook clears `viewEnd` (and kicks off the glide
236
311
  // below), so a stale edge can't keep the window frozen. See #164. With
237
312
  // `allowFutureViewEnd` (timeScroll.overscroll) an edge parked past live is
238
- // honored too — the data-overlap strand-guard stays in both modes.
313
+ // honored too. Valid explicit price bounds let external editors position
314
+ // before the first sample as well, without an empty auto-fit to resolve.
239
315
  const scrolledBack =
240
316
  viewEnd != null &&
241
- viewEnd >= firstDataTime &&
317
+ (viewRange !== undefined || viewEnd >= firstDataTime) &&
242
318
  (viewEnd < liveEdge || input.allowFutureViewEnd === true);
243
319
  const canvasChanged =
244
320
  state.lastCanvasWidth !== input.canvasWidth ||
@@ -529,6 +605,8 @@ export function tickLiveChartEngineFrame(
529
605
  if (input.nonNegative && tMin < 0) tMin = 0;
530
606
  const maxV = input.maxValue;
531
607
  if (maxV !== undefined && tMax > maxV) tMax = maxV;
608
+ state.fitMin = tMin;
609
+ state.fitMax = tMax;
532
610
 
533
611
  const disjoint = tMin >= state.displayMax || tMax <= state.displayMin;
534
612
  // A subpixel settle must not jump across the other bound of a disjoint fit.
@@ -560,6 +638,29 @@ export function tickLiveChartEngineFrame(
560
638
  }
561
639
  }
562
640
 
641
+ // Explicit bounds keep a gesture's price coordinates stable, even in empty space.
642
+ state.adjustedViewRangeMin = NaN;
643
+ state.adjustedViewRangeMax = NaN;
644
+ if (viewRange) {
645
+ // An app-written range is applied verbatim (the app owns its bounds); a
646
+ // gesture-written one must still honor the chart's hard bounds.
647
+ const bounded =
648
+ input.viewRangeFollowsLive === true
649
+ ? clampGestureRange(
650
+ viewRange,
651
+ input.nonNegative === true,
652
+ input.maxValue,
653
+ input.minRange,
654
+ )
655
+ : viewRange;
656
+ if (bounded !== viewRange) {
657
+ state.adjustedViewRangeMin = bounded.min;
658
+ state.adjustedViewRangeMax = bounded.max;
659
+ }
660
+ state.displayMin = bounded.min;
661
+ state.displayMax = bounded.max;
662
+ }
663
+
563
664
  // Edge value: the price at the visible window's right edge. Following live →
564
665
  // track the live value (badge unchanged). Scrolled back → track the last
565
666
  // visible point/candle close, lerped so a `followViewEdge` badge glides to the
@@ -33,6 +33,8 @@ import type {
33
33
  ScrubActionConfig,
34
34
  ScrubConfig,
35
35
  PerSeriesTooltipConfig,
36
+ PriceScrollConfig,
37
+ ResetButtonConfig,
36
38
  SelectionDotConfig,
37
39
  SelectionDotProps,
38
40
  SelectionDotRingConfig,
@@ -779,6 +781,7 @@ export function resolveViewport(
779
781
  return {
780
782
  end: prop.end,
781
783
  window: prop.window,
784
+ range: prop.range,
782
785
  windowSmoothing: prop.windowSmoothing ?? VIEWPORT_DEFAULTS.windowSmoothing,
783
786
  };
784
787
  }
@@ -805,6 +808,80 @@ export function resolveZoom(
805
808
  return resolveToggle(prop, ZOOM_DEFAULTS, false);
806
809
  }
807
810
 
811
+ export interface ResolvedPriceScrollConfig {
812
+ activation: "always" | "afterScale";
813
+ /** Non-negative, finite multiple of the visible span. */
814
+ maxOvershoot: number;
815
+ }
816
+
817
+ const PRICE_SCROLL_DEFAULTS: ResolvedPriceScrollConfig = {
818
+ activation: "afterScale",
819
+ maxOvershoot: 1,
820
+ };
821
+
822
+ /**
823
+ * Resolves the `priceScroll` prop to a config or null (disabled). `true` →
824
+ * defaults, object → merged, falsy → null. A malformed `maxOvershoot` falls
825
+ * back to the default rather than unbounding the pan.
826
+ */
827
+ export function resolvePriceScroll(
828
+ prop: boolean | PriceScrollConfig | undefined,
829
+ ): ResolvedPriceScrollConfig | null {
830
+ const resolved = resolveToggle(prop, PRICE_SCROLL_DEFAULTS, false);
831
+ if (resolved === null) return null;
832
+ const validOvershoot =
833
+ Number.isFinite(resolved.maxOvershoot) && resolved.maxOvershoot >= 0;
834
+ return validOvershoot
835
+ ? resolved
836
+ : { ...resolved, maxOvershoot: PRICE_SCROLL_DEFAULTS.maxOvershoot };
837
+ }
838
+
839
+ export interface ResolvedResetButtonConfig {
840
+ placement: "bottom-center" | "bottom-right";
841
+ showFor: {
842
+ yScale: boolean;
843
+ priceScroll: boolean;
844
+ timeScroll: boolean;
845
+ zoom: boolean;
846
+ };
847
+ margin: number;
848
+ fadeMs: number;
849
+ icon: string;
850
+ size: number;
851
+ /** undefined → palette.badgeBg at render time */
852
+ color: string | undefined;
853
+ /** undefined → palette.badgeText at render time */
854
+ iconColor: string | undefined;
855
+ accessibilityLabel: string | undefined;
856
+ }
857
+
858
+ const RESET_BUTTON_DEFAULTS: ResolvedResetButtonConfig = {
859
+ placement: "bottom-center",
860
+ showFor: { yScale: true, priceScroll: true, timeScroll: true, zoom: true },
861
+ margin: 12,
862
+ fadeMs: 160,
863
+ icon: "↺",
864
+ size: 36,
865
+ color: undefined,
866
+ iconColor: undefined,
867
+ accessibilityLabel: undefined,
868
+ };
869
+
870
+ /**
871
+ * Resolves the `resetButton` prop to a config or null (disabled). `true` →
872
+ * defaults, object → merged (`showFor` merges per key), falsy → null.
873
+ */
874
+ export function resolveResetButton(
875
+ prop: boolean | ResetButtonConfig | undefined,
876
+ ): ResolvedResetButtonConfig | null {
877
+ const resolved = resolveToggle(prop, RESET_BUTTON_DEFAULTS, false);
878
+ if (resolved === null || typeof prop !== "object") return resolved;
879
+ return {
880
+ ...resolved,
881
+ showFor: { ...RESET_BUTTON_DEFAULTS.showFor, ...prop.showFor },
882
+ };
883
+ }
884
+
808
885
  /**
809
886
  * Resolves `timeScroll.returnToLive` to the "return to live" glide duration in ms,
810
887
  * where `0` means an instant snap (no animation):
@@ -1134,6 +1211,8 @@ export interface ResolvedLoadingConfig {
1134
1211
  speed: number;
1135
1212
  /** Draw the skeleton Y-axis label placeholders. */
1136
1213
  axisLabels: boolean;
1214
+ /** undefined → never frozen: the squiggle animates while the shell shows */
1215
+ freezeAfterMs: number | undefined;
1137
1216
  }
1138
1217
 
1139
1218
  const LOADING_DEFAULTS: ResolvedLoadingConfig = {
@@ -1142,18 +1221,25 @@ const LOADING_DEFAULTS: ResolvedLoadingConfig = {
1142
1221
  amplitude: LOADING_WAVE_AMPLITUDE,
1143
1222
  speed: LOADING_WAVE_SPEED,
1144
1223
  axisLabels: true,
1224
+ freezeAfterMs: undefined,
1145
1225
  };
1146
1226
 
1147
1227
  /**
1148
1228
  * Resolves the `loading` prop to a fully-typed config or null (not loading).
1149
1229
  * `true` → defaults (loading on, built-in look), object → merged with defaults
1150
1230
  * (loading on, restyled), `false` / omitted → null. So a non-null result is the
1151
- * "is loading" flag and carries the resolved styling.
1231
+ * "is loading" flag and carries the resolved styling. A `freezeAfterMs` of
1232
+ * `NaN` or `Infinity` resolves to `undefined`: no limit, and no frame counting.
1152
1233
  */
1153
1234
  export function resolveLoading(
1154
1235
  prop: boolean | LoadingConfig | undefined,
1155
1236
  ): ResolvedLoadingConfig | null {
1156
- return resolveToggle(prop, LOADING_DEFAULTS, false);
1237
+ const resolved = resolveToggle(prop, LOADING_DEFAULTS, false);
1238
+ if (resolved === null) return null;
1239
+ const { freezeAfterMs } = resolved;
1240
+ return Number.isNaN(freezeAfterMs) || freezeAfterMs === Infinity
1241
+ ? { ...resolved, freezeAfterMs: undefined }
1242
+ : resolved;
1157
1243
  }
1158
1244
 
1159
1245
  const SCRUB_ACTION_DEFAULTS: ResolvedScrubActionConfig = {