manim-web 0.3.16 → 0.3.17

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 (45) hide show
  1. package/README.md +41 -1
  2. package/dist/animation/AnimationUtilities.d.ts +64 -0
  3. package/dist/animation/AnimationUtilities.d.ts.map +1 -0
  4. package/dist/animation/transform/TransformMatchingBase.d.ts +64 -0
  5. package/dist/animation/transform/TransformMatchingBase.d.ts.map +1 -0
  6. package/dist/animation/transform/index.d.ts +1 -0
  7. package/dist/animation/transform/index.d.ts.map +1 -1
  8. package/dist/{featureFlags-C-nwJWMy.js → featureFlags-RDWYX142.js} +7876 -6507
  9. package/dist/index.d.ts +8 -4
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +505 -488
  12. package/dist/integrations/react.js +565 -548
  13. package/dist/integrations/vue.js +524 -507
  14. package/dist/manim-web.browser.js +83624 -0
  15. package/dist/mobjects/geometry/Arc.d.ts +3 -3
  16. package/dist/mobjects/geometry/Arc.d.ts.map +1 -1
  17. package/dist/mobjects/geometry/TipableVMobject.d.ts +93 -0
  18. package/dist/mobjects/geometry/TipableVMobject.d.ts.map +1 -0
  19. package/dist/mobjects/geometry/index.d.ts +1 -0
  20. package/dist/mobjects/geometry/index.d.ts.map +1 -1
  21. package/dist/mobjects/logo/ManimBanner.d.ts +26 -0
  22. package/dist/mobjects/logo/ManimBanner.d.ts.map +1 -0
  23. package/dist/mobjects/logo/index.d.ts +2 -0
  24. package/dist/mobjects/logo/index.d.ts.map +1 -0
  25. package/dist/mobjects/matrix/Matrix.d.ts +14 -1
  26. package/dist/mobjects/matrix/Matrix.d.ts.map +1 -1
  27. package/dist/mobjects/matrix/MatrixHelpers.d.ts +48 -0
  28. package/dist/mobjects/matrix/MatrixHelpers.d.ts.map +1 -0
  29. package/dist/mobjects/matrix/index.d.ts +1 -0
  30. package/dist/mobjects/matrix/index.d.ts.map +1 -1
  31. package/dist/mobjects/text/MathTex.d.ts +6 -0
  32. package/dist/mobjects/text/MathTex.d.ts.map +1 -1
  33. package/dist/mobjects/text/MathTexParts.d.ts +80 -0
  34. package/dist/mobjects/text/MathTexParts.d.ts.map +1 -0
  35. package/dist/mobjects/text/index.d.ts +1 -0
  36. package/dist/mobjects/text/index.d.ts.map +1 -1
  37. package/dist/mobjects/three-d/ConvexHull3D.d.ts +75 -0
  38. package/dist/mobjects/three-d/ConvexHull3D.d.ts.map +1 -0
  39. package/dist/mobjects/three-d/index.d.ts +1 -0
  40. package/dist/mobjects/three-d/index.d.ts.map +1 -1
  41. package/dist/utils/tex-templates/TexTemplate.d.ts +70 -0
  42. package/dist/utils/tex-templates/TexTemplate.d.ts.map +1 -0
  43. package/dist/utils/tex-templates/index.d.ts +2 -0
  44. package/dist/utils/tex-templates/index.d.ts.map +1 -0
  45. package/package.json +9 -3
package/README.md CHANGED
@@ -38,7 +38,47 @@ async function squareToCircle(scene: Scene) {
38
38
  }
39
39
  ```
40
40
 
41
- Or use a plain `<script>` tag — see the [examples](https://maloyan.github.io/manim-web/) for more.
41
+ ### Browser Usage
42
+
43
+ Use manim-web directly in the browser with a `<script>` tag -- no bundler needed:
44
+
45
+ ```html
46
+ <canvas id="canvas" width="800" height="450"></canvas>
47
+ <script type="module">
48
+ import { Scene, Circle, Create } from 'https://esm.sh/manim-web@0.3.17';
49
+
50
+ const scene = new Scene({ canvasId: 'canvas' });
51
+ const circle = new Circle({ radius: 1.5 });
52
+ await scene.play(new Create(circle));
53
+ </script>
54
+ ```
55
+
56
+ Alternatively, use an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) for the self-hosted bundle:
57
+
58
+ ```html
59
+ <script type="importmap">
60
+ {
61
+ "imports": {
62
+ "three": "https://esm.sh/three@0.183.2"
63
+ }
64
+ }
65
+ </script>
66
+ <script type="module">
67
+ import { Scene, Circle, Create } from './node_modules/manim-web/dist/index.js';
68
+ // ...
69
+ </script>
70
+ ```
71
+
72
+ Or use the self-contained browser bundle that includes Three.js (no import map needed):
73
+
74
+ ```html
75
+ <script type="module">
76
+ import { Scene, Circle, Create } from './node_modules/manim-web/dist/manim-web.browser.js';
77
+ // ...
78
+ </script>
79
+ ```
80
+
81
+ See the [examples](https://maloyan.github.io/manim-web/) for more.
42
82
 
43
83
  ## What You Can Build
44
84
 
@@ -0,0 +1,64 @@
1
+ import { Mobject } from '../core/Mobject';
2
+ import { Animation, AnimationOptions } from './Animation';
3
+ /**
4
+ * Type for animation override functions
5
+ */
6
+ export type AnimationOverrideFunc = (mobject: Mobject, animArgs?: AnimationOptions) => Animation;
7
+ /**
8
+ * overrideAnimation - Register a custom animation for a mobject method
9
+ *
10
+ * When using the `.animate` pattern, if a method has a registered override,
11
+ * the override animation will be used instead of the default interpolation.
12
+ *
13
+ * @param methodName The name of the method to override
14
+ * @param className The class name to scope the override to
15
+ * @param animFunc The function that creates the override animation
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Register a custom animation for clearContent
20
+ * overrideAnimation('clearContent', 'MyMobject', (mobject, args) => {
21
+ * return new Uncreate(mobject, args);
22
+ * });
23
+ * ```
24
+ */
25
+ export declare function overrideAnimation(methodName: string, className: string, animFunc: AnimationOverrideFunc): void;
26
+ /**
27
+ * getAnimationOverride - Get registered animation override for a method
28
+ *
29
+ * @param methodName The method name to check
30
+ * @param className The class name to check
31
+ * @returns The override function if registered, undefined otherwise
32
+ */
33
+ export declare function getAnimationOverride(methodName: string, className: string): AnimationOverrideFunc | undefined;
34
+ /**
35
+ * hasAnimationOverride - Check if a method has an animation override
36
+ */
37
+ export declare function hasAnimationOverride(methodName: string, className: string): boolean;
38
+ /**
39
+ * clearAnimationOverrides - Remove all overrides for a class
40
+ */
41
+ export declare function clearAnimationOverrides(className: string): void;
42
+ /**
43
+ * prepareAnimation - Normalize animation input to a consistent Animation instance
44
+ *
45
+ * Accepts an Animation object, a callable that returns an Animation, or
46
+ * other animation-like inputs and converts them to a proper Animation instance.
47
+ *
48
+ * @param animInput An Animation instance, a function returning an Animation, or a Mobject
49
+ * @returns A normalized Animation instance
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Direct animation
54
+ * const anim1 = prepareAnimation(new FadeIn(circle));
55
+ *
56
+ * // Function that returns animation
57
+ * const anim2 = prepareAnimation(() => new FadeIn(circle));
58
+ *
59
+ * // With animation args
60
+ * const anim3 = prepareAnimation(new Create(square, { duration: 2 }));
61
+ * ```
62
+ */
63
+ export declare function prepareAnimation(animInput: Animation | (() => Animation)): Animation;
64
+ //# sourceMappingURL=AnimationUtilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimationUtilities.d.ts","sourceRoot":"","sources":["../../src/animation/AnimationUtilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,gBAAgB,KAAK,SAAS,CAAC;AAOjG;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,qBAAqB,GAC9B,IAAI,CAKN;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,qBAAqB,GAAG,SAAS,CAEnC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAEnF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,GAAG,SAAS,CAgBpF"}
@@ -0,0 +1,64 @@
1
+ import { VMobject } from '../../core/VMobject';
2
+ import { Animation, AnimationOptions } from '../Animation';
3
+ export interface TransformMatchingBaseOptions extends AnimationOptions {
4
+ /** Key function to extract identifier for matching */
5
+ keyFunc?: (vmobject: VMobject) => string;
6
+ /** Fade duration as fraction of total duration (0-0.5). Default: 0.25 */
7
+ fadeRatio?: number;
8
+ }
9
+ interface MatchedPart {
10
+ source: VMobject;
11
+ target: VMobject;
12
+ startPoints: number[][];
13
+ targetPoints: number[][];
14
+ startOpacity: number;
15
+ targetOpacity: number;
16
+ }
17
+ interface FadingPart {
18
+ mobject: VMobject;
19
+ fadeIn: boolean;
20
+ startOpacity: number;
21
+ targetOpacity: number;
22
+ }
23
+ export declare abstract class TransformMatchingAbstractBase extends Animation {
24
+ /** The target mobject to transform into */
25
+ readonly target: VMobject;
26
+ /** Optional key function for matching */
27
+ readonly keyFunc?: (vmobject: VMobject) => string;
28
+ /** Fade duration ratio */
29
+ readonly fadeRatio: number;
30
+ /** Matched parts that will transform */
31
+ protected _matchedParts: MatchedPart[];
32
+ /** Source parts that will fade out (no match in target) */
33
+ protected _fadeOutParts: FadingPart[];
34
+ /** Target parts that will fade in (no match in source) */
35
+ protected _fadeInParts: FadingPart[];
36
+ constructor(source: VMobject, target: VMobject, options?: TransformMatchingBaseOptions);
37
+ /**
38
+ * Get the submobjects/parts to match from a given VMobject.
39
+ * Subclasses must implement this to define how mobjects are decomposed.
40
+ */
41
+ protected abstract _getSubmobjects(vmobject: VMobject): VMobject[];
42
+ /**
43
+ * Get a matching key for a VMobject part.
44
+ * Parts with the same key will be matched together.
45
+ * Subclasses must implement this.
46
+ */
47
+ protected abstract _getKey(vmobject: VMobject): string;
48
+ /**
49
+ * Match submobjects between source and target.
50
+ * Uses key-based exact matching by default. Subclasses can override
51
+ * to add additional matching strategies (e.g., similarity-based).
52
+ */
53
+ protected _matchParts(): void;
54
+ /**
55
+ * Add a matched pair of source and target parts.
56
+ * Aligns their points so they can be smoothly interpolated.
57
+ */
58
+ protected _addMatchedPart(source: VMobject, target: VMobject): void;
59
+ begin(): void;
60
+ interpolate(alpha: number): void;
61
+ finish(): void;
62
+ }
63
+ export {};
64
+ //# sourceMappingURL=TransformMatchingBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransformMatchingBase.d.ts","sourceRoot":"","sources":["../../../src/animation/transform/TransformMatchingBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG3D,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;IACpE,sDAAsD;IACtD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,MAAM,CAAC;IACzC,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,WAAW;IACnB,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,UAAU;IAClB,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,8BAAsB,6BAA8B,SAAQ,SAAS;IACnE,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAE1B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,MAAM,CAAC;IAElD,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,wCAAwC;IACxC,SAAS,CAAC,aAAa,EAAE,WAAW,EAAE,CAAM;IAE5C,2DAA2D;IAC3D,SAAS,CAAC,aAAa,EAAE,UAAU,EAAE,CAAM;IAE3C,0DAA0D;IAC1D,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE,CAAM;gBAE9B,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAE,4BAAiC;IAO1F;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAElE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM;IAEtD;;;;OAIG;IACH,SAAS,CAAC,WAAW,IAAI,IAAI;IAuE7B;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAkB1D,KAAK,IAAI,IAAI;IAKtB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA0BvB,MAAM,IAAI,IAAI;CAmBxB"}
@@ -3,6 +3,7 @@ export { ApplyFunction, applyFunction, type ApplyFunctionOptions, ApplyMethod, a
3
3
  export { FadeTransform, fadeTransform, type FadeTransformOptions, FadeTransformPieces, fadeTransformPieces, type FadeTransformPiecesOptions, TransformFromCopy, transformFromCopy, type TransformFromCopyOptions, } from './FadeTransforms';
4
4
  export { ClockwiseTransform, clockwiseTransform, type ClockwiseTransformOptions, CounterclockwiseTransform, counterclockwiseTransform, type CounterclockwiseTransformOptions, Swap, swap, type SwapOptions, CyclicReplace, cyclicReplace, type CyclicReplaceOptions, } from './MovementTransforms';
5
5
  export { ScaleInPlace, scaleInPlace, type ScaleInPlaceOptions, ShrinkToCenter, shrinkToCenter, type ShrinkToCenterOptions, Restore, restore, type MobjectWithSavedState, type RestoreOptions, FadeToColor, fadeToColor, type FadeToColorOptions, TransformAnimations, transformAnimations, type TransformAnimationsOptions, } from './SpecialTransforms';
6
+ export { TransformMatchingAbstractBase, type TransformMatchingBaseOptions, } from './TransformMatchingBase';
6
7
  export { TransformMatchingShapes, transformMatchingShapes, type TransformMatchingShapesOptions, TransformMatchingTex, transformMatchingTex, type TransformMatchingTexOptions, } from './TransformMatching';
7
8
  export { ApplyPointwiseFunction, applyPointwiseFunction, type ApplyPointwiseFunctionOptions, } from './ApplyPointwiseFunction';
8
9
  export { ApplyPointwiseFunctionToCenter, applyPointwiseFunctionToCenter, type ApplyPointwiseFunctionToCenterOptions, } from './ApplyPointwiseFunctionToCenter';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/animation/transform/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,aAAa,EACb,aAAa,EACb,KAAK,oBAAoB,EAGzB,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EAGvB,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EAGvB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,aAAa,EACb,aAAa,EACb,KAAK,oBAAoB,EAGzB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,0BAA0B,EAG/B,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,yBAAyB,EAG9B,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,gCAAgC,EAGrC,IAAI,EACJ,IAAI,EACJ,KAAK,WAAW,EAGhB,aAAa,EACb,aAAa,EACb,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,KAAK,mBAAmB,EAGxB,cAAc,EACd,cAAc,EACd,KAAK,qBAAqB,EAG1B,OAAO,EACP,OAAO,EACP,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EAGnB,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EAGvB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,uBAAuB,EACvB,uBAAuB,EACvB,KAAK,8BAA8B,EAGnC,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,KAAK,qCAAqC,GAC3C,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/animation/transform/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,aAAa,EACb,aAAa,EACb,KAAK,oBAAoB,EAGzB,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EAGvB,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EAGvB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,aAAa,EACb,aAAa,EACb,KAAK,oBAAoB,EAGzB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,0BAA0B,EAG/B,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,yBAAyB,EAG9B,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,gCAAgC,EAGrC,IAAI,EACJ,IAAI,EACJ,KAAK,WAAW,EAGhB,aAAa,EACb,aAAa,EACb,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,KAAK,mBAAmB,EAGxB,cAAc,EACd,cAAc,EACd,KAAK,qBAAqB,EAG1B,OAAO,EACP,OAAO,EACP,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EAGnB,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EAGvB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,6BAA6B,EAC7B,KAAK,4BAA4B,GAClC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,uBAAuB,EACvB,uBAAuB,EACvB,KAAK,8BAA8B,EAGnC,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,KAAK,qCAAqC,GAC3C,MAAM,kCAAkC,CAAC"}