manim-web 0.2.0 → 0.3.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.
@@ -0,0 +1,95 @@
1
+ import { VGroup } from '../../core/VGroup';
2
+ import { Vector3Tuple } from '../../core/Mobject';
3
+ export interface MathTexSVGOptions {
4
+ /** LaTeX string or array of strings for multi-part expressions. */
5
+ latex: string | string[];
6
+ /** Color as CSS color string. Default: WHITE ('#ffffff') */
7
+ color?: string;
8
+ /** Scale factor (1 = standard math size). Default: 1 */
9
+ fontSize?: number;
10
+ /** Use display mode (block) vs inline mode. Default: true */
11
+ displayMode?: boolean;
12
+ /** Position in 3D space. Default: [0,0,0] */
13
+ position?: Vector3Tuple;
14
+ /** Stroke width for glyph outlines. Default: 2 */
15
+ strokeWidth?: number;
16
+ /** Fill opacity for glyph interiors. Default: 1 */
17
+ fillOpacity?: number;
18
+ /** Explicit target height in world units. Overrides fontSize scaling. */
19
+ height?: number;
20
+ /** Custom LaTeX macros as { name: expansion }. */
21
+ macros?: Record<string, string>;
22
+ }
23
+ export declare class MathTexSVG extends VGroup {
24
+ protected _latex: string;
25
+ protected _fontSize: number;
26
+ protected _displayMode: boolean;
27
+ protected _color: string;
28
+ protected _svgStrokeWidth: number;
29
+ protected _svgFillOpacity: number;
30
+ protected _targetHeight: number | undefined;
31
+ protected _macros: Record<string, string> | undefined;
32
+ /** Whether this is a multi-part MathTexSVG (created from string[]) */
33
+ protected _isMultiPart: boolean;
34
+ /** Child part groups (only when _isMultiPart is true) */
35
+ protected _parts: VGroup[];
36
+ /** Promise that resolves when rendering is complete */
37
+ protected _renderPromise: Promise<void> | null;
38
+ constructor(options: MathTexSVGOptions);
39
+ /**
40
+ * Wait for the LaTeX to finish rendering.
41
+ */
42
+ waitForRender(): Promise<void>;
43
+ /**
44
+ * Get a sub-part of a multi-part expression.
45
+ * Only available when created with a string array.
46
+ * Returns a VGroup with setColor() support.
47
+ */
48
+ getPart(index: number): VGroup;
49
+ /**
50
+ * Get the number of parts.
51
+ */
52
+ getPartCount(): number;
53
+ /**
54
+ * Get the LaTeX string.
55
+ */
56
+ getLatex(): string;
57
+ /**
58
+ * Override setColor to propagate to all VMobject children (fill + stroke).
59
+ */
60
+ setColor(color: string): this;
61
+ /**
62
+ * Start the async rendering process.
63
+ */
64
+ protected _startRender(): void;
65
+ /**
66
+ * Render the LaTeX to VMobject paths.
67
+ */
68
+ protected _render(): Promise<void>;
69
+ /**
70
+ * Restyle all VMobject children for solid glyph rendering.
71
+ */
72
+ protected _restyleChildren(group: VGroup): void;
73
+ /**
74
+ * Scale and center the assembled paths by transforming actual point data.
75
+ */
76
+ protected _scaleToTarget(): void;
77
+ /**
78
+ * Render a multi-part expression by:
79
+ * 1. Rendering the FULL expression as one MathJax call (correct layout)
80
+ * 2. Rendering each part separately to count its glyphs
81
+ * 3. Splitting the full expression's VMobjects into part groups by glyph count
82
+ */
83
+ private _renderMultiPart;
84
+ /**
85
+ * Lightweight VGroup used as a part container in multi-part mode.
86
+ * Supports setColor() for per-part coloring.
87
+ */
88
+ private static _PartGroup;
89
+ /**
90
+ * Create a copy of this MathTexSVG.
91
+ */
92
+ protected _createCopy(): MathTexSVG;
93
+ }
94
+ export default MathTexSVG;
95
+ //# sourceMappingURL=MathTexSVG.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MathTexSVG.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/MathTexSVG.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIhE,MAAM,WAAW,iBAAiB;IAChC,mEAAmE;IACnE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM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,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA0BtC;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAU9B;;OAEG;cACa,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BxC;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAmB/C;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAmDhC;;;;;OAKG;YACW,gBAAgB;IAqE9B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU,CAqBvB;IAEF;;OAEG;cACgB,WAAW,IAAI,UAAU;CAgB7C;AAED,eAAe,UAAU,CAAC"}
@@ -11,6 +11,7 @@ export { Paragraph, type ParagraphOptions } from './Paragraph';
11
11
  export { MarkupText, type MarkupTextOptions, type StyledTextSegment } from './MarkupText';
12
12
  export { ensureKatexStyles, areKatexStylesLoaded } from './katex-styles';
13
13
  export { MathTex, type MathTexOptions, type TexRenderer } from './MathTex';
14
+ export { MathTexSVG, type MathTexSVGOptions } from './MathTexSVG';
14
15
  export { renderLatexToSVG, preloadMathJax, isMathJaxLoaded, katexCanRender, type MathJaxRenderOptions, type MathJaxRenderResult, } from './MathJaxRenderer';
15
16
  export { parseSVGPathData, svgToVMobjects, type SVGToVMobjectOptions, } from './svgPathParser';
16
17
  export { Tex, type TexOptions } from './Tex';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,M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ables toggling experimental features without code changes.
4
4
  */
5
5
  type FeatureFlags = Record<string, boolean>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Structured logger for manim-js.
2
+ * Structured logger for manim-web.
3
3
  * Provides consistent logging interface for both browser and Node environments.
4
4
  * Includes log sanitization to redact sensitive data (tokens, keys, emails).
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "manim-web",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Manim-like mathematical animation library for the web",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,8 +37,8 @@
37
37
  "lint": "eslint src/",
38
38
  "lint:fix": "eslint src/ --fix",
39
39
  "format": "prettier --write src/",
40
- "docs": "node scripts/generate-example-docs.mjs && cd website && npm run build",
41
- "docs:dev": "node scripts/generate-example-docs.mjs && cd website && npm start",
40
+ "docs": "node scripts/generate-example-docs.mjs && cd docs && npm run build",
41
+ "docs:dev": "node scripts/generate-example-docs.mjs && cd docs && npm start",
42
42
  "docs:examples": "node scripts/generate-example-docs.mjs",
43
43
  "cpd": "jscpd src/",
44
44
  "test:integration": "npx playwright test",
@@ -73,6 +73,7 @@
73
73
  "@vitest/coverage-v8": "^4.0.18",
74
74
  "eslint": "^9.39.2",
75
75
  "eslint-config-prettier": "^10.1.8",
76
+ "happy-dom": "^20.6.1",
76
77
  "husky": "^9.1.7",
77
78
  "jscpd": "^4.0.8",
78
79
  "knip": "^5.83.1",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=colors.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.test.d.ts","sourceRoot":"","sources":["../../src/constants/colors.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=directions.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directions.test.d.ts","sourceRoot":"","sources":["../../src/constants/directions.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SceneExtensions.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SceneExtensions.test.d.ts","sourceRoot":"","sources":["../../src/core/SceneExtensions.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=examples.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"examples.test.d.ts","sourceRoot":"","sources":["../src/examples.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=rateFunctions.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rateFunctions.test.d.ts","sourceRoot":"","sources":["../../src/rate-functions/rateFunctions.test.ts"],"names":[],"mappings":""}