@motionscript/latex 0.1.0-alpha.0 → 0.1.0-alpha.3

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.
package/src/geometry.ts CHANGED
@@ -16,7 +16,15 @@ import '@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js';
16
16
  import '@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js';
17
17
  import '@mathjax/src/js/input/tex/bbox/BboxConfiguration.js';
18
18
  import '@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js';
19
- import { PathCommand } from '@motionscript/core';
19
+ import type { DynamicFileList } from '@mathjax/src/js/output/common/FontData.js';
20
+ import { MathJaxNewcmFont } from '@mathjax/mathjax-newcm-font/js/svg.js';
21
+ import '@mathjax/mathjax-newcm-font/js/svg/dynamic/calligraphic.js';
22
+ import '@mathjax/mathjax-newcm-font/js/svg/dynamic/double-struck.js';
23
+ import '@mathjax/mathjax-newcm-font/js/svg/dynamic/fraktur.js';
24
+ import '@mathjax/mathjax-newcm-font/js/svg/dynamic/monospace.js';
25
+ import '@mathjax/mathjax-newcm-font/js/svg/dynamic/sans-serif.js';
26
+ import '@mathjax/mathjax-newcm-font/js/svg/dynamic/script.js';
27
+ import { PathCommand } from '@motionscript/sdk';
20
28
 
21
29
  import { createBoundedCache } from './cache';
22
30
 
@@ -49,7 +57,19 @@ const texJax = new TeX({
49
57
  ],
50
58
  });
51
59
 
52
- const svgJax = new SVG({ fontCache: 'local' });
60
+ /**
61
+ * The font files behind `\mathcal`, `\mathbb`, `\mathfrak`, `\mathsf`, `\mathtt`
62
+ * and `\mathscr`, imported above. MathJax fetches these asynchronously the first
63
+ * time a formula needs one, which a synchronous typesetter cannot wait for, so
64
+ * they are bundled and set up on the font before anything is typeset. The font
65
+ * class is passed explicitly so the one they register on is the one in use.
66
+ */
67
+ const BUNDLED_FONT_FILES = ['calligraphic', 'double-struck', 'fraktur', 'monospace', 'sans-serif', 'script'];
68
+
69
+ const svgJax = new SVG({ fontCache: 'local', fontData: MathJaxNewcmFont });
70
+ const fontFiles = (MathJaxNewcmFont as unknown as { dynamicFiles: DynamicFileList }).dynamicFiles;
71
+ for (const file of BUNDLED_FONT_FILES) fontFiles[file].setup(svgJax.font);
72
+
53
73
  const mjDoc = mathjax.document('', { InputJax: texJax, OutputJax: svgJax });
54
74
 
55
75
  // --- Public API ---
package/src/node.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RenderContext2D, Graphics2D, EasingFunction, command, node, lerpNumber, NodeConfig, ShapeNode, ShapeProps, InsetsProps, Size2D, SizeConstraints, toPathString, InsetsResolved, property, insetsOps, FillResolved, ShadowResolved, driveCommand, type Command, type CommandArgs, type TweenStepper } from "@motionscript/core";
1
+ import { RenderContext2D, Graphics2D, EasingFunction, command, node, lerpNumber, NodeConfig, ShapeNode, ShapeProps, InsetsProps, Size2D, SizeConstraints, toPathString, InsetsResolved, property, insetsProperty, FillResolved, ShadowResolved, driveCommand, type Command, type CommandArgs, type TweenStepper } from "@motionscript/sdk";
2
2
  import { buildLatexPath, defaultLatexMorph, type AnimatedToken, type LatexMorphStrategy, type LatexToken } from "./engine";
3
3
 
4
4
  export interface LatexProps extends ShapeProps {
@@ -50,7 +50,7 @@ export interface LatexStrategies {
50
50
  export class Latex extends ShapeNode<LatexProps> {
51
51
  @property({ default: "" }) declare readonly latex: string;
52
52
  @property({ default: 16 }) declare readonly fontSize: number;
53
- @property({ default: 0, mapper: insetsOps.resolve, tween: insetsOps.lerp }) declare readonly padding: InsetsResolved;
53
+ @insetsProperty() declare readonly padding: InsetsResolved;
54
54
 
55
55
  /**
56
56
  * How this node morphs between two formulas. Construction-time-only (see
package/src/tween.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { lerpNumber, type PathCommand } from "@motionscript/core";
1
+ import { lerpNumber, type PathCommand } from "@motionscript/sdk";
2
2
  import type { LatexToken } from "./geometry";
3
3
 
4
4
  export interface AnimatedToken {