manim-web 0.22.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 (37) hide show
  1. package/dist/index.d.ts +4 -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/lottie-fy5zaR1g.js +7057 -0
  7. package/dist/manim-web.browser.js +5032 -3696
  8. package/dist/mobjects/graphing/BoxPlot.d.ts +99 -0
  9. package/dist/mobjects/graphing/BoxPlot.d.ts.map +1 -0
  10. package/dist/mobjects/graphing/CandlestickChart.d.ts +191 -0
  11. package/dist/mobjects/graphing/CandlestickChart.d.ts.map +1 -0
  12. package/dist/mobjects/graphing/FourierEpicycles.d.ts +149 -0
  13. package/dist/mobjects/graphing/FourierEpicycles.d.ts.map +1 -0
  14. package/dist/mobjects/graphing/FourierSeries.d.ts +60 -0
  15. package/dist/mobjects/graphing/FourierSeries.d.ts.map +1 -0
  16. package/dist/mobjects/graphing/Histogram.d.ts +71 -0
  17. package/dist/mobjects/graphing/Histogram.d.ts.map +1 -0
  18. package/dist/mobjects/graphing/ScatterPlot.d.ts +66 -0
  19. package/dist/mobjects/graphing/ScatterPlot.d.ts.map +1 -0
  20. package/dist/mobjects/graphing/ViolinPlot.d.ts +83 -0
  21. package/dist/mobjects/graphing/ViolinPlot.d.ts.map +1 -0
  22. package/dist/mobjects/graphing/fourier.d.ts +104 -0
  23. package/dist/mobjects/graphing/fourier.d.ts.map +1 -0
  24. package/dist/mobjects/graphing/index.d.ts +9 -0
  25. package/dist/mobjects/graphing/index.d.ts.map +1 -1
  26. package/dist/mobjects/graphing/stats.d.ts +128 -0
  27. package/dist/mobjects/graphing/stats.d.ts.map +1 -0
  28. package/dist/mobjects/lottie/LottieMobject.d.ts +211 -0
  29. package/dist/mobjects/lottie/LottieMobject.d.ts.map +1 -0
  30. package/dist/mobjects/lottie/index.d.ts +2 -0
  31. package/dist/mobjects/lottie/index.d.ts.map +1 -0
  32. package/dist/serialization/index.d.ts +2 -0
  33. package/dist/serialization/index.d.ts.map +1 -1
  34. package/dist/serialization/urlState.d.ts +127 -0
  35. package/dist/serialization/urlState.d.ts.map +1 -0
  36. package/dist/{src-C18aslV3.js → src-DRH8XOAP.js} +2843 -1507
  37. package/package.json +2 -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
+ {"version":3,"file":"ViolinPlot.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/ViolinPlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAMlE,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,uCAAuC;IACvC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iEAAiE;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,yCAAyC;AACzC,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;IAC5B,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,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,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,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;AAIrD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CA+B5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,kBAAkB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAExF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,kBAAkB,EAAE,EAClC,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,MAAM,GACf,OAAO,CAaT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,kBAAkB,EAAE,EAClC,KAAK,GAAE,YAA0B,GAChC,kBAAkB,EAAE,CAiBtB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAC3B,OAAO,GAAE,iCAAsC,GAC9C,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAgBvB"}
@@ -18,9 +18,18 @@ export { HeatMap, 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":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtF,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGjG,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG/F,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAG7E,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAGxF,OAAO,EAAE,kBAAkB,EAAE,KA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AAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/F,OAAO,EACL,QAAQ,EACR,KAAK,eAAe,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"}
@@ -0,0 +1,211 @@
1
+ import { Vector3Tuple } from '../../core/Mobject';
2
+ import { TexturedMobject } from '../../core/TexturedMobject';
3
+ import * as THREE from 'three';
4
+ /**
5
+ * LottieMobject - display a Lottie (Bodymovin JSON) animation as a mobject.
6
+ *
7
+ * ManimCE cannot import After Effects / Lottie vector animations. The browser
8
+ * can: `lottie-web` renders the JSON into an offscreen `<canvas>`, which this
9
+ * mobject presents through a `THREE.CanvasTexture` on a plane - exactly how
10
+ * {@link VideoMobject} and {@link ImageMobject} draw their frames. The plane
11
+ * then participates in the standard mobject transforms (shift, scale, rotate),
12
+ * z-index/depth, opacity, and `scene.add`.
13
+ *
14
+ * The animation is time-driven: call {@link syncToTime} on scrub/seek so the
15
+ * displayed frame follows the Player clock, or {@link play} for live playback
16
+ * via the updater. `lottie-web` is pulled in through a lazy dynamic `import()`
17
+ * so the base bundle and SSR never load it. Tests inject a player (via the
18
+ * `player` option or {@link setLottiePlayerFactory}) to avoid the real library
19
+ * and any DOM/canvas - mirroring ModelMobject's loader-injection seam.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const anim = await LottieMobject.fromUrl('spinner.json', { width: 4, loop: true });
24
+ * scene.add(anim);
25
+ * anim.play();
26
+ * ```
27
+ */
28
+ /**
29
+ * Parsed Bodymovin JSON. Only `w`, `h` and `fr` are read here (for the natural
30
+ * size and frame rate); the whole object is handed to the player unchanged.
31
+ */
32
+ export interface LottieAnimationData {
33
+ /** Composition width in pixels. */
34
+ w?: number;
35
+ /** Composition height in pixels. */
36
+ h?: number;
37
+ /** Frame rate in frames per second. */
38
+ fr?: number;
39
+ [key: string]: unknown;
40
+ }
41
+ /**
42
+ * The subset of a `lottie-web` AnimationItem this mobject drives. The real
43
+ * AnimationItem satisfies it structurally; tests implement it with a stub.
44
+ */
45
+ export interface LottieAnimation {
46
+ /** Total number of frames in the composition. */
47
+ totalFrames: number;
48
+ /** Frame rate in frames per second. */
49
+ frameRate: number;
50
+ /** Seek to a frame (`isFrame` true) or a time, and stop there. */
51
+ goToAndStop(value: number, isFrame?: boolean): void;
52
+ /** Set the live-playback speed multiplier. */
53
+ setSpeed?(speed: number): void;
54
+ /** Release the player's resources. */
55
+ destroy(): void;
56
+ }
57
+ /** Parameters passed to the player's `loadAnimation`. */
58
+ export interface LottieLoadParams {
59
+ /** The canvas element that backs the texture. */
60
+ container: unknown;
61
+ /** Always `'canvas'`: this mobject renders into an offscreen canvas. */
62
+ renderer: 'canvas';
63
+ /** Loop the composition during live playback. */
64
+ loop: boolean;
65
+ /** Never autoplay: playback is driven by the updater or by seeks. */
66
+ autoplay: boolean;
67
+ /** The parsed Bodymovin JSON. */
68
+ animationData: LottieAnimationData;
69
+ /** Canvas renderer settings (the 2D context to draw into). */
70
+ rendererSettings: {
71
+ context?: unknown;
72
+ canvas?: unknown;
73
+ clearCanvas?: boolean;
74
+ };
75
+ }
76
+ /**
77
+ * The minimal player contract. `lottie-web`'s default export satisfies it.
78
+ */
79
+ export interface LottiePlayer {
80
+ loadAnimation(params: LottieLoadParams): LottieAnimation;
81
+ }
82
+ /** Builds a player. The DI seam set by {@link setLottiePlayerFactory}. */
83
+ export type LottiePlayerFactory = () => LottiePlayer | Promise<LottiePlayer>;
84
+ /**
85
+ * Inject a player factory, replacing the lazy-loaded `lottie-web`. Pass `null`
86
+ * to restore the default. Tests use this to avoid the real library.
87
+ */
88
+ export declare function setLottiePlayerFactory(factory: LottiePlayerFactory | null): void;
89
+ /** Options for creating a {@link LottieMobject}. */
90
+ export interface LottieMobjectOptions {
91
+ /** Parsed Bodymovin JSON. Required unless using {@link LottieMobject.fromUrl}. */
92
+ animationData?: LottieAnimationData;
93
+ /** Loop the composition during live playback and time wrapping. Default: false. */
94
+ loop?: boolean;
95
+ /** Playback speed multiplier (1 = normal). Default: 1. */
96
+ speed?: number;
97
+ /** Width in scene units. Default: auto from the composition aspect ratio. */
98
+ width?: number;
99
+ /** Height in scene units. Default: auto from the composition aspect ratio. */
100
+ height?: number;
101
+ /** If both width and height given, fit inside the box preserving aspect. Default: true. */
102
+ scaleToFit?: boolean;
103
+ /** Center position [x, y, z]. Default: [0, 0, 0]. */
104
+ center?: Vector3Tuple;
105
+ /** Opacity from 0 to 1. Default: 1. */
106
+ opacity?: number;
107
+ /** Render both sides of the plane. Default: false. */
108
+ doubleSided?: boolean;
109
+ /** Inject a player directly (bypasses the factory and the network). */
110
+ player?: LottiePlayer;
111
+ }
112
+ /** Options for {@link LottieMobject.fromUrl}. */
113
+ export interface LottieFromUrlOptions extends Omit<LottieMobjectOptions, 'animationData'> {
114
+ /** Inject a `fetch` implementation (bypasses the global; used by tests). */
115
+ fetchImpl?: typeof fetch;
116
+ }
117
+ export declare class LottieMobject extends TexturedMobject {
118
+ protected _animationData: LottieAnimationData | undefined;
119
+ protected _loop: boolean;
120
+ protected _speed: number;
121
+ protected _width: number | undefined;
122
+ protected _height: number | undefined;
123
+ protected _scaleToFit: boolean;
124
+ protected _centerPoint: Vector3Tuple;
125
+ protected _doubleSided: boolean;
126
+ protected _injectedPlayer: LottiePlayer | undefined;
127
+ protected _canvas: HTMLCanvasElement | null;
128
+ protected _texture: THREE.CanvasTexture | null;
129
+ protected _animation: LottieAnimation | null;
130
+ protected _totalFrames: number;
131
+ protected _frameRate: number;
132
+ protected _naturalWidth: number;
133
+ protected _naturalHeight: number;
134
+ protected _loaded: boolean;
135
+ protected _loadError: Error | null;
136
+ protected _playing: boolean;
137
+ protected _playhead: number;
138
+ private _mesh;
139
+ private _loadPromise;
140
+ private _loadResolve;
141
+ private _loadReject;
142
+ constructor(options: LottieMobjectOptions);
143
+ /**
144
+ * Load a Lottie JSON from a URL and return a ready LottieMobject.
145
+ *
146
+ * The JSON is fetched and parsed, then handed to the player. Inject a player
147
+ * (via the `player` option or {@link setLottiePlayerFactory}) and a `fetchImpl`
148
+ * to avoid the network, e.g. in tests.
149
+ */
150
+ static fromUrl(url: string, options?: LottieFromUrlOptions): Promise<LottieMobject>;
151
+ /**
152
+ * Create the offscreen canvas and its CanvasTexture. Node/SSR-safe: when
153
+ * `document` is missing, the load fails gracefully instead of throwing.
154
+ */
155
+ private _createCanvasTexture;
156
+ /** Resolve the player, load the animation, and show the first frame. */
157
+ private _load;
158
+ /** Record a load error and reject the ready promise once. */
159
+ private _failLoad;
160
+ /** Promise that resolves when the animation is ready and rejects on error. */
161
+ waitForLoad(): Promise<void>;
162
+ /** The captured load error, or null when no error occurred. */
163
+ getLoadError(): Error | null;
164
+ /** Whether the animation is loaded and seekable. */
165
+ isLoaded(): boolean;
166
+ /** Total number of frames in the composition (0 until loaded). */
167
+ getTotalFrames(): number;
168
+ /** Frame rate in frames per second. */
169
+ getFrameRate(): number;
170
+ /** Natural duration of one loop in seconds (0 until loaded). */
171
+ get duration(): number;
172
+ /** The frame index for a scene time, honoring speed and loop. */
173
+ private _frameForTime;
174
+ /** Seek the player to a frame and flag the texture for upload. */
175
+ private _seekFrame;
176
+ /** Show the frame for a scene time without moving the live playhead. */
177
+ private _applyTime;
178
+ /**
179
+ * Follow the Player clock: show the frame at `sceneTime` seconds. Use this on
180
+ * scrub and seek so the displayed frame tracks the timeline position.
181
+ */
182
+ syncToTime(sceneTime: number): this;
183
+ /** Seek to a progress fraction in [0, 1] of the composition. */
184
+ seekToProgress(progress: number): this;
185
+ /** Start live playback from the current playhead (advanced by the updater). */
186
+ play(): this;
187
+ /** Pause live playback. */
188
+ pause(): this;
189
+ /** Set the playback speed multiplier. */
190
+ setSpeed(speed: number): this;
191
+ /** Enable or disable looping. */
192
+ setLoop(loop: boolean): this;
193
+ /** Display dimensions from width/height options and the natural size. */
194
+ private _calculateDimensions;
195
+ protected _createThreeObject(): THREE.Object3D;
196
+ getDisplayMeshLength(): number;
197
+ getDisplayMeshes(): THREE.Mesh[];
198
+ applyTextureFrom(other: TexturedMobject): void;
199
+ applyVisualSize(width: number, height: number): void;
200
+ applyContentFrom(other: TexturedMobject): void;
201
+ protected _updateGeometry(): void;
202
+ protected _syncMaterialToThree(): void;
203
+ getBoundingBox(): {
204
+ width: number;
205
+ height: number;
206
+ depth: number;
207
+ };
208
+ copy(): LottieMobject;
209
+ dispose(): void;
210
+ }
211
+ //# sourceMappingURL=LottieMobject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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E;IASlE,IAAI,IAAI,aAAa;IAsBrB,OAAO,IAAI,IAAI;CAazB"}
@@ -0,0 +1,2 @@
1
+ export { LottieMobject, setLottiePlayerFactory, type LottieMobjectOptions, type LottieFromUrlOptions, type LottieAnimationData, type LottieAnimation, type LottiePlayer, type LottiePlayerFactory, type LottieLoadParams, } from './LottieMobject';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mobjects/lottie/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC"}
@@ -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"}