manim-web 0.23.0 → 0.24.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 (32) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/integrations/react.js +17 -17
  5. package/dist/integrations/vue.js +16 -16
  6. package/dist/manim-web.browser.js +4797 -3709
  7. package/dist/mobjects/graphing/BoxPlot.d.ts +99 -0
  8. package/dist/mobjects/graphing/BoxPlot.d.ts.map +1 -0
  9. package/dist/mobjects/graphing/CandlestickChart.d.ts +191 -0
  10. package/dist/mobjects/graphing/CandlestickChart.d.ts.map +1 -0
  11. package/dist/mobjects/graphing/FourierEpicycles.d.ts +149 -0
  12. package/dist/mobjects/graphing/FourierEpicycles.d.ts.map +1 -0
  13. package/dist/mobjects/graphing/FourierSeries.d.ts +60 -0
  14. package/dist/mobjects/graphing/FourierSeries.d.ts.map +1 -0
  15. package/dist/mobjects/graphing/Histogram.d.ts +71 -0
  16. package/dist/mobjects/graphing/Histogram.d.ts.map +1 -0
  17. package/dist/mobjects/graphing/ScatterPlot.d.ts +66 -0
  18. package/dist/mobjects/graphing/ScatterPlot.d.ts.map +1 -0
  19. package/dist/mobjects/graphing/ViolinPlot.d.ts +83 -0
  20. package/dist/mobjects/graphing/ViolinPlot.d.ts.map +1 -0
  21. package/dist/mobjects/graphing/fourier.d.ts +104 -0
  22. package/dist/mobjects/graphing/fourier.d.ts.map +1 -0
  23. package/dist/mobjects/graphing/index.d.ts +9 -0
  24. package/dist/mobjects/graphing/index.d.ts.map +1 -1
  25. package/dist/mobjects/graphing/stats.d.ts +128 -0
  26. package/dist/mobjects/graphing/stats.d.ts.map +1 -0
  27. package/dist/serialization/index.d.ts +2 -0
  28. package/dist/serialization/index.d.ts.map +1 -1
  29. package/dist/serialization/urlState.d.ts +127 -0
  30. package/dist/serialization/urlState.d.ts.map +1 -0
  31. package/dist/{src-BRT6RDfk.js → src-DRH8XOAP.js} +2568 -1480
  32. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScatterPlot.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/ScatterPlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAO9B,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,2DAA2D;IAC3D,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,+DAA+D;IAC/D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,+DAA+D;IAC/D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,uDAAuD;IACvD,IAAI,EAAE,IAAI,CAAC;IACX,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IAEb,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC;gBAEX,OAAO,EAAE,kBAAkB;IAuDvC,iCAAiC;IACjC,OAAO,IAAI,IAAI;IAIf,qCAAqC;IACrC,OAAO,IAAI,MAAM;IAIjB,uEAAuE;IACvE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAItC,oCAAoC;IACpC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAEQ,IAAI,IAAI,WAAW;CAK7B"}
@@ -0,0 +1,83 @@
1
+ import { Group } from '../../core/Group';
2
+ import { Polygon } from '../geometry/Polygon';
3
+ import { Axes } from './Axes';
4
+ import { PlotOrientation } from './BoxPlot';
5
+ /** The sampled KDE for one violin group. */
6
+ export interface ViolinDensity {
7
+ /** Value-axis positions where the density was sampled, low to high. */
8
+ values: number[];
9
+ /** Estimated density at each value. */
10
+ densities: number[];
11
+ /** Half-width of the violin at each value, in category units. */
12
+ halfWidths: number[];
13
+ }
14
+ /** Options for creating a ViolinPlot. */
15
+ export interface ViolinPlotOptions {
16
+ /** One data group (number[]) or several groups (number[][]). */
17
+ data: number[] | number[][];
18
+ /** KDE bandwidth. Default: Silverman's rule of thumb per group. */
19
+ bandwidth?: number;
20
+ /** Lay violins along the x-axis ('vertical') or y-axis ('horizontal'). Default: 'vertical' */
21
+ orientation?: PlotOrientation;
22
+ /** Violin color, or a per-group color array. Default: Manim color palette */
23
+ colors?: string | string[];
24
+ /** Fill opacity for the violins. Default: 0.5 */
25
+ fillOpacity?: number;
26
+ /** Stroke width for the violin outline. Default: 2 */
27
+ strokeWidth?: number;
28
+ /** Number of KDE samples along the value axis per group. Default: 48 */
29
+ resolution?: number;
30
+ /** Maximum half-width of a violin in category units. Default: 0.4 */
31
+ widthScale?: number;
32
+ /** An existing Axes to draw onto. When omitted, one is built from the data. */
33
+ axes?: Axes;
34
+ /** Visual length of the x-axis when auto-building axes. Default: 8 */
35
+ xLength?: number;
36
+ /** Visual length of the y-axis when auto-building axes. Default: 6 */
37
+ yLength?: number;
38
+ /** Color for the axes when auto-building. Default: '#ffffff' */
39
+ axisColor?: string;
40
+ }
41
+ /**
42
+ * ViolinPlot - a mirrored kernel-density shape per data group.
43
+ *
44
+ * Each group estimates a Gaussian KDE over its value range and draws a shape
45
+ * that is symmetric about the group's category line. The widest part of the
46
+ * violin sits at the densest value (the mode). Groups sit side by side along
47
+ * the category axis.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const violin = new ViolinPlot({
52
+ * data: [[1, 2, 2, 3, 3, 3, 4, 4, 5], [2, 3, 3, 4]],
53
+ * bandwidth: 0.5,
54
+ * });
55
+ * ```
56
+ */
57
+ export declare class ViolinPlot extends Group {
58
+ /** The coordinate system the violins are drawn on. */
59
+ axes: Axes;
60
+ protected _groupsData: number[][];
61
+ protected _orientation: PlotOrientation;
62
+ protected _densities: ViolinDensity[];
63
+ protected _violins: (Polygon | null)[];
64
+ constructor(options: ViolinPlotOptions);
65
+ /** Padded value range covering every data value across all groups. */
66
+ private _valueRange;
67
+ /** Sample the KDE of one group over its value range. */
68
+ private _sampleDensity;
69
+ /** Map a (category, value) pair to a world point, respecting orientation. */
70
+ private _toPoint;
71
+ /** Build the mirrored KDE polygon for one group. */
72
+ private _buildViolin;
73
+ /** Get the coordinate system. */
74
+ getAxes(): Axes;
75
+ /** Get the sampled KDE for one group. */
76
+ getDensity(index: number): ViolinDensity;
77
+ /** Get the violin polygon for one group, or null when the group is empty. */
78
+ getViolin(index: number): Polygon | null;
79
+ /** The number of data groups. */
80
+ get numGroups(): number;
81
+ copy(): ViolinPlot;
82
+ }
83
+ //# sourceMappingURL=ViolinPlot.d.ts.map
@@ -0,0 +1 @@
1
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,qBAAa,UAAW,SAAQ,KAAK;IACnC,sDAAsD;IACtD,IAAI,EAAE,IAAI,CAAC;IAEX,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;IAClC,SAAS,CAAC,YAAY,EAAE,eAAe,CAAC;IACxC,SAAS,CAAC,UAAU,EAAE,aAAa,EAAE,CAAM;IAC3C,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAM;gBAEhC,OAAO,EAAE,iBAAiB;IAiDtC,sEAAsE;IACtE,OAAO,CAAC,WAAW;IAKnB,wDAAwD;IACxD,OAAO,CAAC,cAAc;IAiCtB,6EAA6E;IAC7E,OAAO,CAAC,QAAQ;IAMhB,oDAAoD;IACpD,OAAO,CAAC,YAAY;IA2BpB,iCAAiC;IACjC,OAAO,IAAI,IAAI;IAIf,yCAAyC;IACzC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa;IASxC,6EAA6E;IAC7E,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAIxC,iCAAiC;IACjC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAEQ,IAAI,IAAI,UAAU;CAQ5B"}
@@ -0,0 +1,104 @@
1
+ import { Complex } from './ComplexPlane';
2
+ /**
3
+ * A single Fourier coefficient expressed in polar form.
4
+ *
5
+ * The complex coefficient is `amplitude * e^(i * phase)`. In an epicycle
6
+ * drawing each coefficient is one rotating vector: `amplitude` is the circle
7
+ * radius, `phase` is the starting angle, and `freq` is the signed number of
8
+ * turns the vector makes per unit of normalized time `t`.
9
+ */
10
+ export interface FourierCoefficient {
11
+ /** Signed integer frequency (…, -2, -1, 0, 1, 2, …), centered around 0. */
12
+ freq: number;
13
+ /** Non-negative magnitude |c_k| (the rotating-vector length / circle radius). */
14
+ amplitude: number;
15
+ /** Phase arg(c_k) in radians, in (-π, π]. */
16
+ phase: number;
17
+ }
18
+ /** Ordering strategy for the coefficient chain. */
19
+ export type FourierOrder = 'amplitude' | 'frequency';
20
+ /**
21
+ * Compute the discrete Fourier coefficients of a list of complex samples.
22
+ *
23
+ * Given `N` samples `f[0..N-1]` taken at equal spacing over one period, the
24
+ * coefficient for index `k` is:
25
+ *
26
+ * c_k = (1 / N) * Σ_n f[n] * e^(-2πi · k · n / N)
27
+ *
28
+ * The returned array has one entry per `k` (DC term first, index `k = 0`).
29
+ * Each entry carries a *centered* signed frequency: indices in the upper half
30
+ * (`k > N/2`) map to the negative frequency `k - N`. Centered frequencies make
31
+ * the vectors rotate in their natural slow-to-fast, alternating-direction
32
+ * order while still reconstructing every sample exactly (see
33
+ * {@link reconstructSample}).
34
+ *
35
+ * @param samples - Complex path samples, equally spaced over one period.
36
+ * @returns One {@link FourierCoefficient} per sample index. Empty input yields `[]`.
37
+ */
38
+ export declare function fourierCoefficients(samples: Complex[]): FourierCoefficient[];
39
+ /**
40
+ * Evaluate the complex sum of rotating vectors at normalized time `t`.
41
+ *
42
+ * Each coefficient contributes `amplitude · e^(i · (2π · freq · t + phase))`.
43
+ * At `t = sampleIndex / N` this reproduces the original sample exactly, so the
44
+ * full coefficient set round-trips the input of {@link fourierCoefficients}.
45
+ *
46
+ * @param coefficients - Coefficients to sum (any order; order does not change the sum).
47
+ * @param t - Normalized time; one full period spans `t ∈ [0, 1)`.
48
+ * @returns The summed complex value.
49
+ */
50
+ export declare function reconstructSample(coefficients: FourierCoefficient[], t: number): Complex;
51
+ /**
52
+ * Sum only the first `numTerms` coefficients at normalized time `t`.
53
+ *
54
+ * This is the partial reconstruction that an {@link FourierEpicycles} pen traces
55
+ * when it shows `numTerms` vectors: it equals the tip of the vector chain.
56
+ *
57
+ * @param coefficients - Ordered coefficients; the first `numTerms` are summed.
58
+ * @param t - Normalized time; one full period spans `t ∈ [0, 1)`.
59
+ * @param numTerms - How many leading coefficients to include. Clamped to `[0, length]`.
60
+ * @returns The summed complex value. `numTerms <= 0` yields `{ re: 0, im: 0 }`.
61
+ */
62
+ export declare function partialSum(coefficients: FourierCoefficient[], t: number, numTerms: number): Complex;
63
+ /**
64
+ * Return a reordered copy of the coefficients for the vector chain.
65
+ *
66
+ * - `'amplitude'` (best approximation per term): largest amplitude first;
67
+ * ties broken by smaller |freq|, then by larger signed freq.
68
+ * - `'frequency'` (the iconic 3Blue1Brown look): `0, +1, -1, +2, -2, …`;
69
+ * that is, smaller |freq| first, positive before negative within a |freq|.
70
+ *
71
+ * The input array is not mutated.
72
+ *
73
+ * @param coefficients - Coefficients to order.
74
+ * @param order - Ordering strategy. Default `'frequency'`.
75
+ * @returns A new, reordered array.
76
+ */
77
+ export declare function orderCoefficients(coefficients: FourierCoefficient[], order?: FourierOrder): FourierCoefficient[];
78
+ /**
79
+ * Options for {@link fourierSeriesApproximation}.
80
+ */
81
+ export interface FourierSeriesApproximationOptions {
82
+ /** Length of one period in the function's domain. Default `2π`. */
83
+ period?: number;
84
+ /** Start of the sampled period in the domain. Default `0`. */
85
+ start?: number;
86
+ /** Number of harmonics (vectors) to keep, chosen by amplitude. Default: all. */
87
+ numTerms?: number;
88
+ /** Number of samples taken over one period. Default `256`. */
89
+ numSamples?: number;
90
+ }
91
+ /**
92
+ * Build the truncated Fourier approximation of a real periodic function.
93
+ *
94
+ * The function is sampled over one period, its discrete coefficients are
95
+ * computed, the `numTerms` largest are kept, and the returned function
96
+ * evaluates the real part of the partial sum at any `x`. With `numTerms`
97
+ * equal to the sample count the approximation reproduces the samples.
98
+ *
99
+ * @param func - The real periodic function `y = f(x)`.
100
+ * @param options - Period, sampling, and term-count options.
101
+ * @returns A function `x -> y` giving the truncated approximation.
102
+ */
103
+ export declare function fourierSeriesApproximation(func: (x: number) => number, options?: FourierSeriesApproximationOptions): (x: number) => number;
104
+ //# sourceMappingURL=fourier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fourier.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/fourier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MA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, type HeatMapOptions, type ScalarField2D } from './HeatMap';
18
18
  export { ContourPlot, type ContourPlotOptions, type ContourField } from './ContourPlot';
19
19
  export { ParametricFunction, type ParametricFunctionOptions } from './ParametricFunction';
20
20
  export { VectorFieldVector, type VectorFieldVectorOptions } from './Vector';
21
+ export { fourierCoefficients, reconstructSample, partialSum, orderCoefficients, fourierSeriesApproximation, type FourierCoefficient, type FourierOrder, type FourierSeriesApproximationOptions, } from './fourier';
22
+ export { FourierEpicycles, type FourierEpicyclesOptions, type FourierPathInput, type ComplexPathFunction, } from './FourierEpicycles';
23
+ export { FourierSeries, type FourierSeriesOptions } from './FourierSeries';
21
24
  export { ComplexPlane, type ComplexPlaneOptions, type Complex } from './ComplexPlane';
22
25
  export { PolarPlane, type PolarPlaneOptions } from './ComplexPlane';
23
26
  export { BarChart, type BarChartOptions } from './BarChart';
27
+ export { CandlestickChart, type CandlestickChartOptions, type OHLC } from './CandlestickChart';
24
28
  export { PieChart, type PieChartOptions, DonutChart, type DonutChartOptions, computeSliceGeometry, type SliceGeometry, type LabelPosition, } from './PieChart';
29
+ export { mean, stdDev, quantile, iqr, histogramBins, kde, silvermanBandwidth, boxSummary, extent, niceAxisRange, type HistogramBin, type HistogramBinsOptions, type KdeOptions, type BoxSummary, } from './stats';
30
+ export { Histogram, type HistogramOptions } from './Histogram';
31
+ export { ScatterPlot, type ScatterPlotOptions } from './ScatterPlot';
32
+ export { BoxPlot, type BoxPlotOptions, type PlotOrientation } from './BoxPlot';
33
+ export { ViolinPlot, type ViolinPlotOptions, type ViolinDensity } from './ViolinPlot';
25
34
  export { VectorField, ArrowVectorField, StreamLines, stepVectorField, type Integrator, type VectorFunction, type ColorFunction, type VectorFieldBaseOptions, type ArrowVectorFieldOptions, type StreamLinesOptions, type ContinuousMotionOptions, } from './VectorField';
26
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/index.ts"],"names":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EACpB,UAAU,EACV,KAAK,iBAAiB,EACtB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,GAAG,EACH,aAAa,EACb,GAAG,EACH,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAGtF,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAC"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Pure statistics helpers for the statistical plot suite.
3
+ *
4
+ * These functions are side-effect free and operate on plain number arrays.
5
+ * They are reused by Histogram, ScatterPlot, BoxPlot and ViolinPlot.
6
+ *
7
+ * Degenerate inputs never throw:
8
+ * - Empty data returns NaN for scalar reducers and empty results for binning.
9
+ * - All-equal data returns a zero inter-quartile range and a zero-width spread.
10
+ */
11
+ /** One bin of a histogram. */
12
+ export interface HistogramBin {
13
+ /** Left edge of the bin (inclusive). */
14
+ x0: number;
15
+ /** Right edge of the bin (exclusive, except the last bin which is inclusive). */
16
+ x1: number;
17
+ /** Number of data values that fall in the bin. */
18
+ count: number;
19
+ /** Probability density: count / (total * binWidth). Area over all bins is 1. */
20
+ density: number;
21
+ }
22
+ /** Options for {@link histogramBins}. */
23
+ export interface HistogramBinsOptions {
24
+ /** Number of equal-width bins. Ignored when binEdges is given. Default: 10 */
25
+ bins?: number;
26
+ /** Explicit bin edges (length n+1 for n bins). Overrides bins. */
27
+ binEdges?: number[];
28
+ }
29
+ /** Options for {@link kde}. */
30
+ export interface KdeOptions {
31
+ /** Kernel bandwidth. Default: Silverman's rule of thumb. */
32
+ bandwidth?: number;
33
+ }
34
+ /**
35
+ * Arithmetic mean of the data.
36
+ * @returns NaN when data is empty.
37
+ */
38
+ export declare function mean(data: number[]): number;
39
+ /**
40
+ * Standard deviation of the data.
41
+ * @param sample - When true, divide by n-1 (sample). Default: false (population).
42
+ * @returns NaN when data is empty. 0 for a single population value.
43
+ */
44
+ export declare function stdDev(data: number[], sample?: boolean): number;
45
+ /**
46
+ * Linear-interpolated quantile (the numpy / R type-7 definition).
47
+ * @param data - The sample values (not required to be sorted).
48
+ * @param q - Quantile in [0, 1]. Values outside are clamped.
49
+ * @returns NaN when data is empty.
50
+ */
51
+ export declare function quantile(data: number[], q: number): number;
52
+ /**
53
+ * Inter-quartile range: quantile(0.75) - quantile(0.25).
54
+ * @returns NaN when data is empty. 0 when all values are equal.
55
+ */
56
+ export declare function iqr(data: number[]): number;
57
+ /**
58
+ * Bin raw data into a histogram.
59
+ *
60
+ * With computed edges, every value lands in a bin and the counts sum to the
61
+ * data length. The last bin includes its right edge. With explicit binEdges,
62
+ * values outside the edge range are dropped.
63
+ *
64
+ * @returns An array of bins, left to right. Empty when data is empty and no
65
+ * explicit edges are given.
66
+ */
67
+ export declare function histogramBins(data: number[], options?: HistogramBinsOptions): HistogramBin[];
68
+ /**
69
+ * Smallest and largest values in an array.
70
+ * @returns [0, 0] when the array is empty.
71
+ */
72
+ export declare function extent(values: number[]): [number, number];
73
+ /**
74
+ * Build a padded [min, max, step] axis range that covers [dataMin, dataMax].
75
+ *
76
+ * The range is padded by 5% on each side. Equal or reversed bounds expand to a
77
+ * unit-wide window so a plot axis is never zero-width. The step divides the
78
+ * padded span into about `divisions` ticks.
79
+ *
80
+ * @param dataMin - Smallest data value.
81
+ * @param dataMax - Largest data value.
82
+ * @param divisions - Target tick count. Default: 5
83
+ */
84
+ export declare function niceAxisRange(dataMin: number, dataMax: number, divisions?: number): [number, number, number];
85
+ /**
86
+ * Silverman's rule-of-thumb bandwidth: 1.06 * sigma * n^(-1/5).
87
+ * @returns 0 when data has fewer than 2 points or zero spread.
88
+ */
89
+ export declare function silvermanBandwidth(data: number[]): number;
90
+ /**
91
+ * Build a Gaussian kernel-density estimator for the data.
92
+ *
93
+ * @returns A function that evaluates the estimated density at a point. The
94
+ * estimator returns 0 everywhere when data is empty. Zero-spread data uses a
95
+ * tiny positive bandwidth so the estimator stays finite and never divides by
96
+ * zero.
97
+ */
98
+ export declare function kde(data: number[], options?: KdeOptions): (x: number) => number;
99
+ /**
100
+ * Compute box-plot summary statistics for one group of data.
101
+ *
102
+ * The whiskers extend to the most extreme data values still inside
103
+ * [Q1 - factor*IQR, Q3 + factor*IQR]. Values beyond the whiskers are outliers.
104
+ */
105
+ export interface BoxSummary {
106
+ /** First quartile (25th percentile). */
107
+ q1: number;
108
+ /** Median (50th percentile). */
109
+ median: number;
110
+ /** Third quartile (75th percentile). */
111
+ q3: number;
112
+ /** Inter-quartile range (Q3 - Q1). */
113
+ iqr: number;
114
+ /** Lower whisker end (smallest datum >= Q1 - factor*IQR). */
115
+ whiskerLow: number;
116
+ /** Upper whisker end (largest datum <= Q3 + factor*IQR). */
117
+ whiskerHigh: number;
118
+ /** Data values outside the whiskers. */
119
+ outliers: number[];
120
+ }
121
+ /**
122
+ * Summarise a data group for a box plot.
123
+ * @param factor - Whisker length as a multiple of the IQR. Default: 1.5
124
+ * @returns A summary whose fields are NaN and whose outliers are empty when
125
+ * data is empty.
126
+ */
127
+ export declare function boxSummary(data: number[], factor?: number): BoxSummary;
128
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8BAA8B;AAC9B,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,iFAAiF;IACjF,EAAE,EAAE,MAAM,CAAC;IACX,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,+BAA+B;AAC/B,MAAM,WAAW,UAAU;IACzB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAK3C;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,UAAQ,GAAG,MAAM,CAW7D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS1D;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,YAAY,EAAE,CAwBhG;AAmCD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CASzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,SAAI,GACZ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAY1B;AAOD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAKzD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAAe,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAWnF;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,SAAM,GAAG,UAAU,CAoCnE"}
@@ -12,4 +12,6 @@
12
12
  export { serializeScene, deserializeScene, serializeMobject, deserializeMobject, } from './serialize';
13
13
  export { registerSerializableMobject, unregisterSerializableMobject, getSerializer, getSerializableTypes, } from './registry';
14
14
  export type { SerializedScene, SerializedMobject, SerializedTransform, SerializedStyle, MobjectSerializer, SceneLike, ContainerLike, Vec3, } from './types';
15
+ export { encodeStateToHash, decodeStateFromHash, writeStateToUrl, readStateFromUrl, onUrlStateChange, bindStateToUrl, } from './urlState';
16
+ export type { WriteStateOptions, BindUrlStateOptions, UrlStateBinding, UrlStateController, } from './urlState';
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,IAAI,GACL,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,IAAI,GACL,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * URL-state permalinks for explorables.
3
+ *
4
+ * Turn the live state of an explorable (MovablePoint positions, Slider values,
5
+ * PanZoom camera) into a compact, shareable URL and restore it on load. This is
6
+ * the Desmos/Observable "share this view" behavior: one link reproduces the
7
+ * reader's interactive state.
8
+ *
9
+ * The state is any JSON-serializable value. It is `JSON.stringify`-ed, encoded
10
+ * as UTF-8 bytes, then written as an unpadded base64url string, so the result
11
+ * is URL-safe (only `A-Z a-z 0-9 - _`) and needs no percent-escaping in a hash.
12
+ *
13
+ * Every `window` / `location` / `history` access is guarded, so each function
14
+ * degrades to a no-op (or `null`) without throwing in a headless environment.
15
+ */
16
+ /** Options for {@link bindStateToUrl}. */
17
+ export interface BindUrlStateOptions {
18
+ /** Use `history.replaceState` (no new history entry) when saving. Default: true. */
19
+ replace?: boolean;
20
+ /** Apply the URL state to the controls immediately on bind. Default: true. */
21
+ restoreOnBind?: boolean;
22
+ /** Re-apply the URL state to the controls on every `hashchange`. Default: true. */
23
+ listen?: boolean;
24
+ }
25
+ /**
26
+ * One control's serializable state, keyed by a stable user-provided id.
27
+ *
28
+ * The controls (MovablePoint, Slider, PanZoomControls) have no registered scene
29
+ * serializer for their interactive state, so a permalink captures a small
30
+ * explicit `{ id: value }` map: `get` reads the live value, `set` restores it.
31
+ */
32
+ export interface UrlStateBinding {
33
+ /** Stable id used as the key in the encoded `{ id: value }` map. */
34
+ id: string;
35
+ /** Read the current JSON-serializable value of this control. */
36
+ get: () => unknown;
37
+ /** Apply a decoded value back to this control. */
38
+ set: (value: unknown) => void;
39
+ }
40
+ /** Handle returned by {@link bindStateToUrl}. */
41
+ export interface UrlStateController {
42
+ /** Read the current value of every binding into an `{ id: value }` map. */
43
+ capture: () => Record<string, unknown>;
44
+ /** Capture the current state and write it to the URL hash. */
45
+ save: () => void;
46
+ /**
47
+ * Read the URL hash and apply it to the bindings. Returns `true` when a valid
48
+ * state was found and applied, `false` otherwise.
49
+ */
50
+ restore: () => boolean;
51
+ /** Stop listening for `hashchange` (when `listen` was enabled). */
52
+ dispose: () => void;
53
+ }
54
+ /**
55
+ * Encode a JSON-serializable state to a compact, URL-safe string.
56
+ *
57
+ * The result contains only `A-Z a-z 0-9 - _`, so it is safe to drop into a URL
58
+ * hash without percent-escaping.
59
+ *
60
+ * @param state - Any JSON-serializable value.
61
+ * @returns The base64url-encoded JSON.
62
+ */
63
+ export declare function encodeStateToHash(state: unknown): string;
64
+ /**
65
+ * Decode a hash string produced by {@link encodeStateToHash} back to its state.
66
+ *
67
+ * A leading `#` is tolerated. A malformed or empty hash yields `null` and never
68
+ * throws.
69
+ *
70
+ * @param hash - The encoded string, with or without a leading `#`.
71
+ * @returns The decoded state, or `null` when the hash is empty or invalid.
72
+ */
73
+ export declare function decodeStateFromHash(hash: string): unknown;
74
+ /** Options for {@link writeStateToUrl}. */
75
+ export interface WriteStateOptions {
76
+ /**
77
+ * Replace the current history entry instead of pushing a new one. A replace
78
+ * does not create a back-button step and does not fire `hashchange`.
79
+ * Default: false.
80
+ */
81
+ replace?: boolean;
82
+ }
83
+ /**
84
+ * Write a state to `location.hash`. No-op when there is no DOM.
85
+ *
86
+ * @param state - Any JSON-serializable value.
87
+ * @param options - `replace` to overwrite the current history entry.
88
+ */
89
+ export declare function writeStateToUrl(state: unknown, options?: WriteStateOptions): void;
90
+ /**
91
+ * Read and decode the state from the current `location.hash`.
92
+ *
93
+ * @returns The decoded state, or `null` when there is no DOM, no hash, or the
94
+ * hash is invalid.
95
+ */
96
+ export declare function readStateFromUrl(): unknown;
97
+ /**
98
+ * Listen for `hashchange` and call `cb` with the newly decoded state.
99
+ *
100
+ * @param cb - Called with the decoded state (or `null`) on every hash change.
101
+ * @returns An unsubscribe function. A no-op when there is no DOM.
102
+ */
103
+ export declare function onUrlStateChange(cb: (state: unknown) => void): () => void;
104
+ /**
105
+ * Bind a set of explorable controls to the URL hash.
106
+ *
107
+ * Each binding exposes a stable id, a getter and a setter. On bind the current
108
+ * URL state is applied to the controls (so a shared link restores the view),
109
+ * and `save()` captures the controls back into the URL. When `listen` is on,
110
+ * the controls also follow back/forward navigation through `hashchange`.
111
+ *
112
+ * @param bindings - One {@link UrlStateBinding} per control.
113
+ * @param options - Bind-time behavior (replace, restoreOnBind, listen).
114
+ * @returns A {@link UrlStateController} to capture, save, restore and dispose.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * const controller = bindStateToUrl([
119
+ * { id: 'p', get: () => point.getPoint(), set: (v) => point.setPoint(v as Vector3Tuple) },
120
+ * { id: 's', get: () => slider.getValue(), set: (v) => slider.setValue(v as number) },
121
+ * ]);
122
+ * // after a drag:
123
+ * controller.save();
124
+ * ```
125
+ */
126
+ export declare function bindStateToUrl(bindings: readonly UrlStateBinding[], options?: BindUrlStateOptions): UrlStateController;
127
+ //# sourceMappingURL=urlState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlState.d.ts","sourceRoot":"","sources":["../../src/serialization/urlState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,mBAAmB;IAClC,oFAAoF;IACpF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mFAAmF;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,GAAG,EAAE,MAAM,OAAO,CAAC;IACnB,kDAAkD;IAClD,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/B;AAED,iDAAiD;AACjD,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,8DAA8D;IAC9D,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,mEAAmE;IACnE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAoDD;;;;;;;;GAQG;AACH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