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,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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