@motionscript/math 0.1.0-alpha.7 → 0.1.0-alpha.9

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 (181) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE +201 -201
  3. package/NOTICE +49 -48
  4. package/README.md +390 -391
  5. package/dist/annotate/angle-mark.d.ts +6 -6
  6. package/dist/annotate/angle-mark.js.map +1 -1
  7. package/dist/annotate/curly-brace.d.ts +9 -9
  8. package/dist/annotate/curly-brace.js.map +1 -1
  9. package/dist/annotate/emphasis-mark.d.ts +9 -9
  10. package/dist/annotate/emphasis-mark.js.map +1 -1
  11. package/dist/browser/chunks/{chunk-ABYBW64J.js → chunk-IRZCG6PM.js} +2 -2
  12. package/dist/browser/chunks/chunk-IRZCG6PM.js.map +7 -0
  13. package/dist/browser/chunks/{chunk-K77KLQX4.js → chunk-WMVW6ZIV.js} +2 -2
  14. package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +7 -0
  15. package/dist/browser/chunks/{mathjax-DNP3YRES.js → mathjax-WV55AC2P.js} +1 -1
  16. package/dist/browser/chunks/{mathjax-DNP3YRES.js.map → mathjax-WV55AC2P.js.map} +1 -1
  17. package/dist/browser/index.js +1 -1
  18. package/dist/browser/index.js.map +3 -3
  19. package/dist/browser/kit.js +1 -1
  20. package/dist/browser/manifest.json +1 -1
  21. package/dist/browser/tex.js +1 -1
  22. package/dist/browser/tex.js.map +1 -1
  23. package/dist/engine.d.ts +1 -1
  24. package/dist/engine.js +1 -1
  25. package/dist/engine.js.map +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/kit/brace.js.map +1 -1
  28. package/dist/kit/cache.js.map +1 -1
  29. package/dist/kit/component.d.ts.map +1 -1
  30. package/dist/kit/component.js.map +1 -1
  31. package/dist/kit/contour.js.map +1 -1
  32. package/dist/kit/coords.js.map +1 -1
  33. package/dist/kit/curve.js.map +1 -1
  34. package/dist/kit/equation.js.map +1 -1
  35. package/dist/kit/equation3d.js.map +1 -1
  36. package/dist/kit/expression.js.map +1 -1
  37. package/dist/kit/field-mark.d.ts.map +1 -1
  38. package/dist/kit/field-mark.js.map +1 -1
  39. package/dist/kit/field.js.map +1 -1
  40. package/dist/kit/follow.d.ts +2 -2
  41. package/dist/kit/follow.d.ts.map +1 -1
  42. package/dist/kit/follow.js.map +1 -1
  43. package/dist/kit/furniture.js.map +1 -1
  44. package/dist/kit/geometry.js.map +1 -1
  45. package/dist/kit/graph.js.map +1 -1
  46. package/dist/kit/mark.js.map +1 -1
  47. package/dist/kit/part-fills.js.map +1 -1
  48. package/dist/kit/place.js.map +1 -1
  49. package/dist/kit/sampler.js +1 -1
  50. package/dist/kit/sampler.js.map +1 -1
  51. package/dist/kit/scale.js.map +1 -1
  52. package/dist/kit/source.js.map +1 -1
  53. package/dist/kit/system.js.map +1 -1
  54. package/dist/kit/ticks.js.map +1 -1
  55. package/dist/kit/withdrawn.js.map +1 -1
  56. package/dist/marks/curve-area.js.map +1 -1
  57. package/dist/marks/drop-lines.d.ts +6 -6
  58. package/dist/marks/drop-lines.js.map +1 -1
  59. package/dist/marks/plot-point.d.ts +3 -3
  60. package/dist/marks/plot-point.js.map +1 -1
  61. package/dist/marks/riemann-sum.d.ts +3 -3
  62. package/dist/marks/riemann-sum.js.map +1 -1
  63. package/dist/marks/tangent-line.d.ts +6 -6
  64. package/dist/marks/tangent-line.js.map +1 -1
  65. package/dist/marks/vector-arrow.d.ts +6 -6
  66. package/dist/marks/vector-arrow.js.map +1 -1
  67. package/dist/nodes.js.map +1 -1
  68. package/dist/plots/function-plot.d.ts +8 -8
  69. package/dist/plots/function-plot.d.ts.map +1 -1
  70. package/dist/plots/function-plot.js.map +1 -1
  71. package/dist/plots/points-plot.js.map +1 -1
  72. package/dist/plots/stream-lines.js.map +1 -1
  73. package/dist/plots/traced-path.js.map +1 -1
  74. package/dist/plots/vector-field.js.map +1 -1
  75. package/dist/structures/graph-layout.js.map +1 -1
  76. package/dist/structures/network-graph.js.map +1 -1
  77. package/dist/structures/sample-space.js.map +1 -1
  78. package/dist/systems/axes2d.d.ts.map +1 -1
  79. package/dist/systems/axes2d.js.map +1 -1
  80. package/dist/systems/number-line.js.map +1 -1
  81. package/dist/systems/number-plane.js.map +1 -1
  82. package/dist/systems/polar-plane.js.map +1 -1
  83. package/dist/tex/geometry.js.map +1 -1
  84. package/dist/tex/index.js.map +1 -1
  85. package/dist/tex/mathjax.js.map +1 -1
  86. package/dist/tex/matrix.d.ts +2 -2
  87. package/dist/tex/matrix.js.map +1 -1
  88. package/dist/tex/node.d.ts +2 -2
  89. package/dist/tex/node.js.map +1 -1
  90. package/dist/tex/tween.js.map +1 -1
  91. package/dist/tex/typeset.d.ts +4 -4
  92. package/dist/tex/typeset.d.ts.map +1 -1
  93. package/dist/tex/typeset.js.map +1 -1
  94. package/dist/three/axes3d.js.map +1 -1
  95. package/dist/three/curve-plot3d.d.ts +27 -27
  96. package/dist/three/curve-plot3d.d.ts.map +1 -1
  97. package/dist/three/curve-plot3d.js +3 -2
  98. package/dist/three/curve-plot3d.js.map +1 -1
  99. package/dist/three/entries.js.map +1 -1
  100. package/dist/three/label3d.d.ts.map +1 -1
  101. package/dist/three/label3d.js +3 -1
  102. package/dist/three/label3d.js.map +1 -1
  103. package/dist/three/plot-point3d.d.ts +27 -27
  104. package/dist/three/plot-point3d.js.map +1 -1
  105. package/dist/three/space.js.map +1 -1
  106. package/dist/three/surface-plot3d.d.ts +36 -36
  107. package/dist/three/surface-plot3d.js +6 -1
  108. package/dist/three/surface-plot3d.js.map +1 -1
  109. package/dist/three/vector-arrow3d.d.ts +27 -27
  110. package/dist/three/vector-arrow3d.js.map +1 -1
  111. package/package.json +5 -4
  112. package/registry.json +251 -251
  113. package/src/annotate/angle-mark.ts +137 -137
  114. package/src/annotate/curly-brace.ts +148 -148
  115. package/src/annotate/emphasis-mark.ts +118 -118
  116. package/src/engine.ts +86 -86
  117. package/src/index.ts +29 -29
  118. package/src/kit/brace.ts +37 -37
  119. package/src/kit/cache.ts +61 -61
  120. package/src/kit/component.ts +57 -57
  121. package/src/kit/contour.ts +94 -94
  122. package/src/kit/coords.ts +278 -278
  123. package/src/kit/curve.ts +47 -47
  124. package/src/kit/equation.ts +181 -181
  125. package/src/kit/equation3d.ts +137 -137
  126. package/src/kit/expression.ts +159 -159
  127. package/src/kit/field-mark.ts +171 -171
  128. package/src/kit/field.ts +50 -50
  129. package/src/kit/follow.ts +229 -229
  130. package/src/kit/furniture.ts +113 -113
  131. package/src/kit/geometry.ts +49 -49
  132. package/src/kit/graph.ts +116 -116
  133. package/src/kit/mark.ts +152 -152
  134. package/src/kit/part-fills.ts +61 -61
  135. package/src/kit/place.ts +77 -77
  136. package/src/kit/sampler.ts +281 -281
  137. package/src/kit/scale.ts +39 -39
  138. package/src/kit/source.ts +57 -57
  139. package/src/kit/system.ts +105 -105
  140. package/src/kit/ticks.ts +85 -85
  141. package/src/kit/withdrawn.ts +8 -8
  142. package/src/marks/curve-area.ts +89 -89
  143. package/src/marks/drop-lines.ts +71 -71
  144. package/src/marks/plot-point.ts +102 -102
  145. package/src/marks/riemann-sum.ts +99 -99
  146. package/src/marks/tangent-line.ts +119 -119
  147. package/src/marks/vector-arrow.ts +98 -98
  148. package/src/nodes.ts +99 -99
  149. package/src/plots/function-plot.ts +220 -220
  150. package/src/plots/points-plot.ts +103 -103
  151. package/src/plots/stream-lines.ts +160 -160
  152. package/src/plots/traced-path.ts +70 -70
  153. package/src/plots/vector-field.ts +107 -107
  154. package/src/structures/graph-layout.ts +145 -145
  155. package/src/structures/network-graph.ts +291 -291
  156. package/src/structures/sample-space.ts +210 -210
  157. package/src/systems/axes2d.ts +226 -226
  158. package/src/systems/number-line.ts +130 -130
  159. package/src/systems/number-plane.ts +232 -232
  160. package/src/systems/polar-plane.ts +177 -177
  161. package/src/tex/geometry.ts +703 -703
  162. package/src/tex/index.ts +15 -15
  163. package/src/tex/mathjax.ts +82 -82
  164. package/src/tex/matrix.ts +97 -97
  165. package/src/tex/node.ts +74 -74
  166. package/src/tex/tween.ts +308 -308
  167. package/src/tex/typeset.ts +461 -461
  168. package/src/three/axes3d.ts +267 -267
  169. package/src/three/curve-plot3d.ts +146 -144
  170. package/src/three/entries.ts +42 -42
  171. package/src/three/label3d.ts +52 -50
  172. package/src/three/plot-point3d.ts +63 -63
  173. package/src/three/space.ts +92 -92
  174. package/src/three/surface-plot3d.ts +318 -312
  175. package/src/three/vector-arrow3d.ts +88 -88
  176. package/dist/browser/chunks/chunk-ABYBW64J.js.map +0 -7
  177. package/dist/browser/chunks/chunk-K77KLQX4.js.map +0 -7
  178. package/dist/kit/placement.d.ts +0 -8
  179. package/dist/kit/placement.d.ts.map +0 -1
  180. package/dist/kit/placement.js +0 -8
  181. package/dist/kit/placement.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"polar-plane.js","sourceRoot":"","sources":["../../src/systems/polar-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,KAAK,GAgBR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAsB,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAc,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAcpD,kGAAkG;AAClG,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,KAAK,GAAG;IACV,GAAG,KAAK;IACR,wDAAwD;IACxD,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAA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,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;SAC9D,CAAC,CAAC;IACP,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,UAA6B,EAAE,CAAC,CAAC,CAAC;IACxH,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,0EAA0E;AAC1E,SAAS,OAAO,CAAC,OAAe;IAC5B,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC9B,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,GAAG,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,WAAW,GAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC7D,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACV,SAAS,IAAI,CAAC,CAAC;YACf,WAAW,IAAI,CAAC,CAAC;YACjB,MAAM;QACV,CAAC;IACL,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC;IACpD,OAAO,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC7D,CAAC","sourcesContent":["import {\r\n component2d,\r\n Graphics2D,\r\n Types,\r\n type Color,\r\n type Extents,\r\n type NodeOf,\r\n type NormalizedColor,\r\n type PaintProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Values,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n} from \"@motionscript/sdk\";\r\nimport { listed, PAINT, PAINT_COMMANDS } from \"../kit/component\";\r\nimport { cartesianMap, type CoordinateMap } from \"../kit/coords\";\r\nimport { AXIS_COLOR, drawLabels, type Label } from \"../kit/furniture\";\r\nimport { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from \"../kit/system\";\r\nimport { formatTick, ticksFor } from \"../kit/ticks\";\r\n\r\nexport interface PolarPlaneProps extends PaintProps {\r\n radius?: number;\r\n ringStep?: number;\r\n spokes?: number;\r\n angleUnit?: \"degrees\" | \"radians\";\r\n gridStroke?: Stroke;\r\n labels?: boolean;\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n}\r\n\r\n/** How much room, in label sizes, the angles written round the outer ring take from the plane. */\r\nconst LABEL_ROOM = 2.2;\r\n\r\nconst state = {\r\n ...PAINT,\r\n /** The radius of the outermost ring, in graph units. */\r\n radius: Types.number(4, { min: 0.0001, step: 0.5 }),\r\n /** The spacing of the rings; zero picks a tidy one for the plane's size. */\r\n ringStep: Types.number(0, { min: 0 }),\r\n /** How many spokes divide the turn; zero draws none. */\r\n spokes: Types.number(12, { min: 0, max: 72, step: 1, animatable: false }),\r\n angleUnit: listed([\"degrees\", \"radians\"], \"degrees\", { animatable: false }),\r\n /** The inner rings and the spokes. */\r\n gridStroke: Types.stroke({ weight: 1.25, fill: \"#3b4658\", align: \"center\" }),\r\n /** A number at each ring, and an angle at each spoke. */\r\n labels: Types.boolean(true, { animatable: false }),\r\n labelSize: Types.number(16, { min: 1, unit: \"px\" }),\r\n labelColor: Types.color(AXIS_COLOR),\r\n fontFamily: Types.text(\"\", { animatable: false }),\r\n};\r\n\r\ntype PolarValues = Values<typeof state>;\r\n\r\n/**\r\n * Rings and spokes about an origin: the plane a polar curve is read on.\r\n * Children sit in its graph coordinates, x and y in the units its rings count,\r\n * so a plot of `r = 1 + cos(theta)`, a point or an arrow goes on it as on axes.\r\n */\r\nexport const PolarPlane = component2d({\r\n key: \"polarPlane\",\r\n state,\r\n /** The outer ring and the two lines through the origin. */\r\n defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: \"center\" } },\r\n load: (loader, s) => {\r\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\r\n },\r\n commands: {\r\n ...PAINT_COMMANDS,\r\n /** Animate how far out the plane reaches: a zoom about its origin. */\r\n rangeTo: { args: [\"radius\"] },\r\n },\r\n provide: (s) => systemProvides(s),\r\n measure: (_measurer, s) => systemSize(s),\r\n layout: (box, s, children) => systemLayout(box, s, children, polarMap),\r\n plane: (box, s) => systemOpenPlane(box, s, polarMap),\r\n render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, polarMap), (map) => polarFurniture(map, s)),\r\n});\r\n\r\nexport type PolarPlane = NodeOf<typeof PolarPlane>;\r\n\r\nfunction polarMap(area: Extents, s: PolarValues): CoordinateMap {\r\n const width = area.maxX - area.minX;\r\n const height = area.maxY - area.minY;\r\n // The outer ring fits the shorter side, less the room its angles are written in; units are square.\r\n const reach = Math.max(1, Math.min(width, height) / 2 - (s.labels ? s.labelSize * LABEL_ROOM : 0));\r\n const unit = reach / Math.max(s.radius, 1e-9);\r\n return cartesianMap({\r\n xRange: [-width / 2 / unit, width / 2 / unit],\r\n yRange: [-height / 2 / unit, height / 2 / unit],\r\n area,\r\n });\r\n}\r\n\r\nfunction polarFurniture(map: CoordinateMap, s: PolarValues): Graphics2D[] {\r\n const stroke = s.stroke as StrokeResolved[];\r\n const grid = s.gridStroke as StrokeResolved[];\r\n const { start, end, radius } = s;\r\n const centre = map.toPoint(0, 0);\r\n const reach = map.toPoint(radius, 0).x - centre.x;\r\n if (!(reach > 0)) return [];\r\n const at = (r: number, degrees: number) => {\r\n const angle = (degrees * Math.PI) / 180;\r\n return map.toPoint(r * Math.cos(angle), r * Math.sin(angle));\r\n };\r\n const ring = (g: Graphics2D, r: number): Graphics2D => {\r\n const size = (map.toPoint(r, 0).x - centre.x) * 2;\r\n return g.ellipse({ x: centre.x, y: centre.y, width: size, height: size, start, end });\r\n };\r\n\r\n const parts: Graphics2D[] = [];\r\n const marks = ticksFor([0, radius], s.ringStep, reach);\r\n const rings = marks.values.filter((r) => r > 0 && r < radius * (1 - 1e-9));\r\n const count = Math.round(s.spokes);\r\n const turns = Array.from({ length: count }, (_, i) => (360 * i) / count);\r\n\r\n if (grid.length > 0) {\r\n const inner = new Graphics2D();\r\n for (const r of rings) ring(inner, r);\r\n // The four along the axes are drawn with them.\r\n for (const degrees of turns) {\r\n if (degrees % 90 !== 0) inner.line({ points: [centre, at(radius, degrees)], radius: 0, start, end });\r\n }\r\n if (rings.length > 0 || turns.some((degrees) => degrees % 90 !== 0)) parts.push(inner.stroke(grid));\r\n }\r\n if (stroke.length > 0) {\r\n parts.push(\r\n ring(new Graphics2D(), radius)\r\n .line({ points: [at(radius, 180), at(radius, 0)], radius: 0, start, end })\r\n .line({ points: [at(radius, 270), at(radius, 90)], radius: 0, start, end })\r\n .stroke(stroke),\r\n );\r\n }\r\n if (!s.labels) return parts;\r\n\r\n const size = s.labelSize;\r\n const labels: Label[] = [];\r\n for (const r of [...rings, radius]) {\r\n const p = map.toPoint(r, 0);\r\n labels.push({ text: formatTick(r, marks.step), at: { x: p.x - size * 0.2, y: p.y - size * 0.95 }, align: \"right\" });\r\n }\r\n for (const degrees of turns) {\r\n const p = at(radius, degrees);\r\n const cos = Math.cos((degrees * Math.PI) / 180);\r\n const sin = Math.sin((degrees * Math.PI) / 180);\r\n labels.push({\r\n text: s.angleUnit === \"degrees\" ? `${formatTick(degrees, 1)}°` : radians(degrees),\r\n at: { x: p.x + cos * size * 0.6, y: p.y + sin * size * 1.05 },\r\n align: cos > 0.3 ? \"left\" : cos < -0.3 ? \"right\" : \"center\",\r\n });\r\n }\r\n parts.push(...drawLabels(labels, { fontSize: size, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor }));\r\n return parts;\r\n}\r\n\r\n/** An angle in degrees as a fraction of π: 90 is `π/2`, 240 is `4π/3`. */\r\nfunction radians(degrees: number): string {\r\n if (degrees === 0) return \"0\";\r\n let numerator = Math.round(degrees);\r\n let denominator = 180;\r\n for (let a = numerator, b = denominator; ; [a, b] = [b, a % b]) {\r\n if (b === 0) {\r\n numerator /= a;\r\n denominator /= a;\r\n break;\r\n }\r\n }\r\n const top = numerator === 1 ? \"π\" : `${numerator}π`;\r\n return denominator === 1 ? top : `${top}/${denominator}`;\r\n}\r\n"]}
1
+ {"version":3,"file":"polar-plane.js","sourceRoot":"","sources":["../../src/systems/polar-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,KAAK,GAgBR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAsB,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAc,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAcpD,kGAAkG;AAClG,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,KAAK,GAAG;IACV,GAAG,KAAK;IACR,wDAAwD;IACxD,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IACnD,4EAA4E;IAC5E,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IACrC,wDAAwD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AAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,UAA6B,EAAE,CAAC,CAAC,CAAC;IACxH,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,0EAA0E;AAC1E,SAAS,OAAO,CAAC,OAAe;IAC5B,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC9B,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,GAAG,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,WAAW,GAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC7D,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACV,SAAS,IAAI,CAAC,CAAC;YACf,WAAW,IAAI,CAAC,CAAC;YACjB,MAAM;QACV,CAAC;IACL,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC;IACpD,OAAO,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC7D,CAAC","sourcesContent":["import {\n component2d,\n Graphics2D,\n Types,\n type Color,\n type Extents,\n type NodeOf,\n type NormalizedColor,\n type PaintProps,\n type Stroke,\n type StrokeResolved,\n type Values,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n} from \"@motionscript/sdk\";\nimport { listed, PAINT, PAINT_COMMANDS } from \"../kit/component\";\nimport { cartesianMap, type CoordinateMap } from \"../kit/coords\";\nimport { AXIS_COLOR, drawLabels, type Label } from \"../kit/furniture\";\nimport { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from \"../kit/system\";\nimport { formatTick, ticksFor } from \"../kit/ticks\";\n\nexport interface PolarPlaneProps extends PaintProps {\n radius?: number;\n ringStep?: number;\n spokes?: number;\n angleUnit?: \"degrees\" | \"radians\";\n gridStroke?: Stroke;\n labels?: boolean;\n labelSize?: number;\n labelColor?: Color;\n fontFamily?: string;\n}\n\n/** How much room, in label sizes, the angles written round the outer ring take from the plane. */\nconst LABEL_ROOM = 2.2;\n\nconst state = {\n ...PAINT,\n /** The radius of the outermost ring, in graph units. */\n radius: Types.number(4, { min: 0.0001, step: 0.5 }),\n /** The spacing of the rings; zero picks a tidy one for the plane's size. */\n ringStep: Types.number(0, { min: 0 }),\n /** How many spokes divide the turn; zero draws none. */\n spokes: Types.number(12, { min: 0, max: 72, step: 1, animatable: false }),\n angleUnit: listed([\"degrees\", \"radians\"], \"degrees\", { animatable: false }),\n /** The inner rings and the spokes. */\n gridStroke: Types.stroke({ weight: 1.25, fill: \"#3b4658\", align: \"center\" }),\n /** A number at each ring, and an angle at each spoke. */\n labels: Types.boolean(true, { animatable: false }),\n labelSize: Types.number(16, { min: 1, unit: \"px\" }),\n labelColor: Types.color(AXIS_COLOR),\n fontFamily: Types.text(\"\", { animatable: false }),\n};\n\ntype PolarValues = Values<typeof state>;\n\n/**\n * Rings and spokes about an origin: the plane a polar curve is read on.\n * Children sit in its graph coordinates, x and y in the units its rings count,\n * so a plot of `r = 1 + cos(theta)`, a point or an arrow goes on it as on axes.\n */\nexport const PolarPlane = component2d({\n key: \"polarPlane\",\n state,\n /** The outer ring and the two lines through the origin. */\n defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: \"center\" } },\n load: (loader, s) => {\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\n },\n commands: {\n ...PAINT_COMMANDS,\n /** Animate how far out the plane reaches: a zoom about its origin. */\n rangeTo: { args: [\"radius\"] },\n },\n provide: (s) => systemProvides(s),\n measure: (_measurer, s) => systemSize(s),\n layout: (box, s, children) => systemLayout(box, s, children, polarMap),\n plane: (box, s) => systemOpenPlane(box, s, polarMap),\n render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, polarMap), (map) => polarFurniture(map, s)),\n});\n\nexport type PolarPlane = NodeOf<typeof PolarPlane>;\n\nfunction polarMap(area: Extents, s: PolarValues): CoordinateMap {\n const width = area.maxX - area.minX;\n const height = area.maxY - area.minY;\n // The outer ring fits the shorter side, less the room its angles are written in; units are square.\n const reach = Math.max(1, Math.min(width, height) / 2 - (s.labels ? s.labelSize * LABEL_ROOM : 0));\n const unit = reach / Math.max(s.radius, 1e-9);\n return cartesianMap({\n xRange: [-width / 2 / unit, width / 2 / unit],\n yRange: [-height / 2 / unit, height / 2 / unit],\n area,\n });\n}\n\nfunction polarFurniture(map: CoordinateMap, s: PolarValues): Graphics2D[] {\n const stroke = s.stroke as StrokeResolved[];\n const grid = s.gridStroke as StrokeResolved[];\n const { start, end, radius } = s;\n const centre = map.toPoint(0, 0);\n const reach = map.toPoint(radius, 0).x - centre.x;\n if (!(reach > 0)) return [];\n const at = (r: number, degrees: number) => {\n const angle = (degrees * Math.PI) / 180;\n return map.toPoint(r * Math.cos(angle), r * Math.sin(angle));\n };\n const ring = (g: Graphics2D, r: number): Graphics2D => {\n const size = (map.toPoint(r, 0).x - centre.x) * 2;\n return g.ellipse({ x: centre.x, y: centre.y, width: size, height: size, start, end });\n };\n\n const parts: Graphics2D[] = [];\n const marks = ticksFor([0, radius], s.ringStep, reach);\n const rings = marks.values.filter((r) => r > 0 && r < radius * (1 - 1e-9));\n const count = Math.round(s.spokes);\n const turns = Array.from({ length: count }, (_, i) => (360 * i) / count);\n\n if (grid.length > 0) {\n const inner = new Graphics2D();\n for (const r of rings) ring(inner, r);\n // The four along the axes are drawn with them.\n for (const degrees of turns) {\n if (degrees % 90 !== 0) inner.line({ points: [centre, at(radius, degrees)], radius: 0, start, end });\n }\n if (rings.length > 0 || turns.some((degrees) => degrees % 90 !== 0)) parts.push(inner.stroke(grid));\n }\n if (stroke.length > 0) {\n parts.push(\n ring(new Graphics2D(), radius)\n .line({ points: [at(radius, 180), at(radius, 0)], radius: 0, start, end })\n .line({ points: [at(radius, 270), at(radius, 90)], radius: 0, start, end })\n .stroke(stroke),\n );\n }\n if (!s.labels) return parts;\n\n const size = s.labelSize;\n const labels: Label[] = [];\n for (const r of [...rings, radius]) {\n const p = map.toPoint(r, 0);\n labels.push({ text: formatTick(r, marks.step), at: { x: p.x - size * 0.2, y: p.y - size * 0.95 }, align: \"right\" });\n }\n for (const degrees of turns) {\n const p = at(radius, degrees);\n const cos = Math.cos((degrees * Math.PI) / 180);\n const sin = Math.sin((degrees * Math.PI) / 180);\n labels.push({\n text: s.angleUnit === \"degrees\" ? `${formatTick(degrees, 1)}°` : radians(degrees),\n at: { x: p.x + cos * size * 0.6, y: p.y + sin * size * 1.05 },\n align: cos > 0.3 ? \"left\" : cos < -0.3 ? \"right\" : \"center\",\n });\n }\n parts.push(...drawLabels(labels, { fontSize: size, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor }));\n return parts;\n}\n\n/** An angle in degrees as a fraction of π: 90 is `π/2`, 240 is `4π/3`. */\nfunction radians(degrees: number): string {\n if (degrees === 0) return \"0\";\n let numerator = Math.round(degrees);\n let denominator = 180;\n for (let a = numerator, b = denominator; ; [a, b] = [b, a % b]) {\n if (b === 0) {\n numerator /= a;\n denominator /= a;\n break;\n }\n }\n const top = numerator === 1 ? \"π\" : `${numerator}π`;\n return denominator === 1 ? top : `${top}/${denominator}`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/tex/geometry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMlD,IAAI,OAAO,GAA0B,IAAI,CAAC;AA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,MAAM;YAC3F,KAAK,GAAG;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,MAAM;QACtE,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC","sourcesContent":["\r\nimport { PathCommand } from '@motionscript/sdk';\r\n\r\nimport { createBoundedCache } from '../kit/cache';\r\n\r\n// --- MathJax, on demand ---\r\n\r\ntype MathJaxRuntime = typeof import('./mathjax');\r\n\r\nlet runtime: MathJaxRuntime | null = null;\r\nlet loading: Promise<void> | null = null;\r\n// MathJax's DOM, a real one or its own DOM-free tree: read only through its accessors, so its element type is opaque here.\r\nlet adaptor: any = null;\r\n\r\n/**\r\n * The asset key a node that typesets declares its loader under: the host waits\r\n * for it before laying the node out, and a scene with no formula never loads it.\r\n */\r\nexport const MATHJAX_LOADER = 'math:mathjax';\r\n\r\n/** Load MathJax, once. A host that typesets outside a scene (a tool, a test) awaits this first. */\r\nexport function loadMathJax(): Promise<void> {\r\n loading ??= import('./mathjax').then((module) => {\r\n runtime = module;\r\n adaptor = module.adaptor;\r\n });\r\n return loading;\r\n}\r\n\r\n/** Whether MathJax has loaded, so a formula can be typeset now. */\r\nexport function mathJaxLoaded(): boolean {\r\n return runtime !== null;\r\n}\r\n\r\n/** What a formula is before MathJax has loaded: nothing to draw, and nothing cached. */\r\nexport function blankLatex(): LatexPathResult {\r\n return { tokens: [], parts: [], commands: [], width: 0, height: 0, bounds: [0, 0, 0, 0] };\r\n}\r\n\r\n/** MathJax is not loaded yet: what typesetting throws before {@link loadMathJax} has resolved. */\r\nexport class LatexNotLoaded extends Error {\r\n constructor() {\r\n super('MathJax is not loaded: declare the math:mathjax loader, or await loadMathJax(), before typesetting.');\r\n this.name = 'LatexNotLoaded';\r\n }\r\n}\r\n\r\n// --- Public API ---\r\n\r\n/**\r\n * A formula MathJax could not typeset.\r\n *\r\n * MathJax does not throw on malformed TeX. It typesets an error box in place of\r\n * the formula and tags it `data-mjx-error`, so the failure arrives as a drawing:\r\n * nothing at all from the browser adaptor and a filled bar from the DOM-free\r\n * one, which left a host able to tell a bad formula from a blank one only by the\r\n * token count. {@link buildLatexPath} raises this instead, the same way under\r\n * both adaptors. `\\require` is an error too, since only the packages named above\r\n * are loaded.\r\n */\r\nexport class LatexError extends Error {\r\n /** The formula that failed, as it was given. */\r\n readonly latex: string;\r\n /** MathJax's own description of what is wrong with it. */\r\n readonly reason: string;\r\n\r\n constructor(latex: string, reason: string) {\r\n super(`Cannot typeset \"${latex}\": ${reason}`);\r\n this.name = 'LatexError';\r\n this.latex = latex;\r\n this.reason = reason;\r\n }\r\n}\r\n\r\n/** A single rendered glyph or shape with its character key and path commands. */\r\nexport interface LatexToken {\r\n /** Character this token represents, or a synthetic key for non-glyph shapes. */\r\n token: string;\r\n path: PathCommand[];\r\n /** The source of the top-level term the token belongs to, `a^2` in `a^2 + b^2`; empty for none. */\r\n term?: string;\r\n}\r\n\r\n/**\r\n * A piece of a formula as its source wrote it: `x^2`, `\\frac{d}{dx}`, a lone\r\n * `+`. Every group the typesetter makes is one, so parts nest.\r\n */\r\nexport interface LatexPart {\r\n /** The part's own source. */\r\n latex: string;\r\n /** The tokens it draws, as a span of the formula's token list: `from` up to, not including, `to`. */\r\n from: number;\r\n to: number;\r\n /** The index of the part it sits in, or -1 at the top. */\r\n parent: number;\r\n}\r\n\r\nexport interface LatexPathResult {\r\n /** All tokens in render order. */\r\n tokens: LatexToken[];\r\n /** Every part of the formula, outermost first, in source order. */\r\n parts: LatexPart[];\r\n /** Flat array of all path commands (for legacy single-path rendering). */\r\n commands: PathCommand[];\r\n width: number;\r\n height: number;\r\n /**\r\n * Bounding box over every token, in token coordinate space:\r\n * [minX, minY, maxX, maxY]. All tokens share this frame, so passing it as\r\n * each path's center frame keeps their relative layout (instead of each\r\n * glyph centering on its own bbox).\r\n */\r\n bounds: [number, number, number, number];\r\n}\r\n\r\n/**\r\n * A formula's glyph geometry, before a type size is applied to it.\r\n *\r\n * The dividing line this whole module's caching turns on. Getting here is the\r\n * expensive part — MathJax lays the formula out, then the SVG it produces is\r\n * parsed, its glyph dictionary resolved and every `<use>` walked through its\r\n * transform stack — and **none of it depends on `fontSize`**: `mjDoc.convert`\r\n * is called at a fixed em/ex, and the size arrives at the very end as one\r\n * uniform scale (see {@link scaleLatexGeometry}).\r\n *\r\n * So this is what gets remembered per formula, and the size is applied to it\r\n * afresh. A formula animating from 24pt to 120pt is one trip through MathJax\r\n * and one DOM parse, not one per frame.\r\n */\r\ninterface LatexGeometry {\r\n tokens: RawToken[];\r\n parts: LatexPart[];\r\n /** Box over every command, in the SVG's own coordinates. */\r\n box: { minX: number; minY: number; maxX: number; maxY: number };\r\n /** The formula's height in `ex`, as MathJax reported it. */\r\n heightEx: number;\r\n}\r\n\r\n/**\r\n * Formulas already worked out, and formulas already sized.\r\n *\r\n * `buildLatexPath` is a pure function of `(text, fontSize)` and used to have no\r\n * memory, which made every caller pay full price for a question it had already\r\n * asked. The callers are not occasional about it either: constructing a `Latex`\r\n * resolves its formula, and so does every `to({ latex })` the moment it starts,\r\n * so a scene re-resolves every formula in it whenever it is rebuilt *and*\r\n * whenever the playhead moves backwards, since a backward seek replays the\r\n * scene's generator from its first frame. An editor that rebuilds on a keystroke\r\n * and seeks on a click asks for the same handful of formulas hundreds of times.\r\n *\r\n * Two memos, each keyed by what its stage actually depends on, and deliberately\r\n * different sizes:\r\n *\r\n * - {@link geometryCache} is everything up to the type size, keyed by the text\r\n * alone. This is the expensive one, and it is generously sized because\r\n * nothing a scene does can churn it: a deck holds as many distinct formulas\r\n * as it holds, and it holds them for as long as it is open.\r\n * - {@link pathCache} is the finished result, keyed by text *and* size. Small\r\n * on purpose: an animated `fontSize` inserts a distinct key every frame, and\r\n * the right thing for a stream like that is to churn a little memo rather\r\n * than a big one. What a miss costs here is arithmetic over glyphs already\r\n * worked out — no MathJax, no parse.\r\n */\r\nconst geometryCache = createBoundedCache<LatexGeometry>(128);\r\nconst pathCache = createBoundedCache<LatexPathResult>(64);\r\n\r\nexport function buildLatexPath(text: string, fontSize: number): LatexPathResult {\r\n // NUL rather than a punctuation separator, so no formula can spell a key\r\n // belonging to another size.\r\n const key = `${fontSize}\\0${text}`;\r\n\r\n const hit = pathCache.get(key);\r\n if (hit) return lend(hit);\r\n\r\n let geometry = geometryCache.get(text);\r\n if (!geometry) {\r\n geometry = buildLatexGeometry(text);\r\n geometryCache.set(text, geometry);\r\n }\r\n\r\n const result = scaleLatexGeometry(geometry, fontSize);\r\n pathCache.set(key, result);\r\n return lend(result);\r\n}\r\n\r\n/** Typeset `text` and reduce the SVG MathJax returns to glyph geometry. */\r\nfunction buildLatexGeometry(text: string): LatexGeometry {\r\n if (!runtime) throw new LatexNotLoaded();\r\n const svgEl = adaptor.firstChild(runtime.convert(text));\r\n const failure = mathJaxError(svgEl);\r\n if (failure !== null) throw new LatexError(text, failure);\r\n\r\n const heightAttr = adaptor.getAttribute(svgEl, 'height') ?? '';\r\n\r\n return parseLatexSvg(svgEl, parseFloat(heightAttr) || 0);\r\n}\r\n\r\n/**\r\n * MathJax's description of the error box in a typeset formula, or `null` when\r\n * there is none. Read through the adaptor, so a real DOM and the DOM-free tree\r\n * give the same answer.\r\n */\r\nfunction mathJaxError(svgEl: unknown): string | null {\r\n for (const el of adaptor.tags(svgEl, 'g') as unknown[]) {\r\n const reason = adaptor.getAttribute(el, 'data-mjx-error');\r\n if (reason !== null && reason !== undefined) return String(reason) || 'unknown error';\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * A cached result, handed out safely.\r\n *\r\n * `tokens`, `commands` and the path arrays inside them are shared: they are read\r\n * by everything downstream and written by none of it — `Latex` maps tokens into\r\n * its own wrappers, and the morph builds new paths rather than editing the ones\r\n * it is given — so copying them would be copying the whole formula for nothing.\r\n *\r\n * `bounds` is copied, because it is the one field a caller *stores*: `Latex`\r\n * assigns `result.bounds` straight to `this._bounds` and hands it to the\r\n * renderer as a shared centring frame. That was one node holding its own array\r\n * before there was a memo, and would be two nodes drawing the same formula\r\n * holding one array between them after — four numbers is not a price worth\r\n * paying to find out whether anything downstream ever writes to it.\r\n */\r\nfunction lend(result: LatexPathResult): LatexPathResult {\r\n const [minX, minY, maxX, maxY] = result.bounds;\r\n return { ...result, bounds: [minX, minY, maxX, maxY] };\r\n}\r\n\r\n// --- High-Speed Matrix Math ---\r\n\r\ntype Matrix = [number, number, number, number, number, number]; // [a, b, c, d, tx, ty]\r\nconst identityMatrix: Matrix = [1, 0, 0, 1, 0, 0];\r\n\r\nfunction multiplyMatrix(m1: Matrix, m2: Matrix): Matrix {\r\n return [\r\n m1[0] * m2[0] + m1[2] * m2[1],\r\n m1[1] * m2[0] + m1[3] * m2[1],\r\n m1[0] * m2[2] + m1[2] * m2[3],\r\n m1[1] * m2[2] + m1[3] * m2[3],\r\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\r\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5],\r\n ];\r\n}\r\n\r\nfunction parseTransform(str: string | null): Matrix {\r\n if (!str) return identityMatrix;\r\n let m: Matrix = [...identityMatrix];\r\n const re = /([a-z]+)\\(([^)]+)\\)/g;\r\n let match;\r\n while ((match = re.exec(str)) !== null) {\r\n const type = match[1];\r\n const args = match[2].split(/[ ,]+/).map(parseFloat);\r\n if (type === 'translate') {\r\n m = multiplyMatrix(m, [1, 0, 0, 1, args[0] || 0, args[1] || 0]);\r\n } else if (type === 'scale') {\r\n const sx = args[0] || 1;\r\n const sy = args[1] !== undefined ? args[1] : sx;\r\n m = multiplyMatrix(m, [sx, 0, 0, sy, 0, 0]);\r\n } else if (type === 'matrix') {\r\n m = multiplyMatrix(m, [args[0], args[1], args[2], args[3], args[4], args[5]]);\r\n }\r\n }\r\n return m;\r\n}\r\n\r\nfunction applyMatrix(x: number, y: number, m: Matrix): [number, number] {\r\n return [\r\n x * m[0] + y * m[2] + m[4],\r\n x * m[1] + y * m[3] + m[5],\r\n ];\r\n}\r\n\r\n// --- Glyph ID → character decoding ---\r\n\r\n/**\r\n * MathJax SVG glyph IDs look like \"MJX-1-TEX-N-78\" or \"MJX-1-TEX-I-1D465\".\r\n * The last segment is the Unicode codepoint in hex.\r\n */\r\nfunction glyphIdToChar(id: string): string {\r\n const parts = id.split('-');\r\n const hex = parts[parts.length - 1];\r\n const cp = parseInt(hex, 16);\r\n if (!isNaN(cp)) {\r\n try { return String.fromCodePoint(cp); } catch { /* fall through */ }\r\n }\r\n return id;\r\n}\r\n\r\n// --- Core Fast Traversal Engine ---\r\n\r\ntype RawToken = { token: string; cmds: Array<{ cmd: string; args: number[] }>; term?: string };\r\n\r\n/** The tag name of a node's parent, or \"\" at the root. */\r\nfunction parentKind(node: unknown): string {\r\n const parent = adaptor.parent(node);\r\n return parent ? String(adaptor.kind(parent)).toLowerCase() : \"\";\r\n}\r\n\r\n/**\r\n * The size-independent half: MathJax's own SVG tree in, glyph geometry out.\r\n *\r\n * Walked through the **adaptor** rather than a `DOMParser`. MathJax already\r\n * builds this tree, and the adaptor is its own abstraction over \"a real DOM\" and\r\n * \"the DOM-free `LiteElement` tree\" — the two this module already picks between\r\n * at load. Serialising it to a string and parsing it back needed a `DOMParser`,\r\n * which Node does not have, so every LaTeX node threw `DOMParser is not defined`\r\n * and could not render headlessly at all: no export, and nothing the visual\r\n * suite could check.\r\n *\r\n * Reading the tree directly is also one representation instead of three (tree →\r\n * string → tree), so a browser and a headless host cannot disagree about how the\r\n * markup re-parsed.\r\n */\r\nfunction parseLatexSvg(svgEl: unknown, heightEx: number): LatexGeometry {\r\n // Pre-parse the glyph dictionary. `tags` reaches every <path> in the tree,\r\n // including the ones inside <defs> that the `use` elements reference.\r\n const glyphMap = new Map<string, Array<{ cmd: string; args: number[] }>>();\r\n for (const el of adaptor.tags(svgEl, 'path') as unknown[]) {\r\n const id = adaptor.getAttribute(el, 'id');\r\n const d = adaptor.getAttribute(el, 'd');\r\n if (id && d) {\r\n glyphMap.set(`#${id}`, expandToAbsolute(tokenisePath(d)));\r\n }\r\n }\r\n\r\n // Collect raw tokens — each <use> is one token, rects/paths are grouped as synthetic tokens\r\n const rawTokens: RawToken[] = [];\r\n const parts: LatexPart[] = [];\r\n let synthIdx = 0;\r\n\r\n function pushCmds(token: string, cmds: Array<{ cmd: string; args: number[] }>) {\r\n rawTokens.push({ token, cmds });\r\n }\r\n\r\n function traverse(node: unknown, currentMatrix: Matrix, within: number) {\r\n let nodeMatrix = currentMatrix;\r\n\r\n const transformStr = adaptor.getAttribute(node, \"transform\");\r\n if (transformStr) {\r\n nodeMatrix = multiplyMatrix(nodeMatrix, parseTransform(transformStr));\r\n }\r\n\r\n const nodeName = String(adaptor.kind(node)).toLowerCase();\r\n\r\n // MathJax tags each group with the source it typeset; the root's is the whole formula.\r\n let part = within;\r\n const source = nodeName === \"g\" ? adaptor.getAttribute(node, \"data-latex\") : null;\r\n if (source && adaptor.getAttribute(node, \"data-mml-node\") !== \"math\") {\r\n part = parts.length;\r\n parts.push({ latex: String(source), from: rawTokens.length, to: rawTokens.length, parent: within });\r\n }\r\n\r\n if (nodeName === \"use\") {\r\n const href = adaptor.getAttribute(node, \"href\") || adaptor.getAttribute(node, \"xlink:href\");\r\n const x = parseFloat(adaptor.getAttribute(node, \"x\") || \"0\");\r\n const y = parseFloat(adaptor.getAttribute(node, \"y\") || \"0\");\r\n\r\n if (href && glyphMap.has(href)) {\r\n const glyphCommands = glyphMap.get(href)!;\r\n const cmds: Array<{ cmd: string; args: number[] }> = [];\r\n for (const gc of glyphCommands) {\r\n const shiftedArgs = [...gc.args];\r\n for (let j = 0; j < shiftedArgs.length; j += 2) {\r\n const [nx, ny] = applyMatrix(shiftedArgs[j] + x, shiftedArgs[j + 1] + y, nodeMatrix);\r\n shiftedArgs[j] = nx;\r\n shiftedArgs[j + 1] = ny;\r\n }\r\n cmds.push({ cmd: gc.cmd, args: shiftedArgs });\r\n }\r\n // Derive character from glyph ID\r\n const rawId = href.startsWith('#') ? href.slice(1) : href;\r\n pushCmds(glyphIdToChar(rawId), cmds);\r\n }\r\n } else if (nodeName === \"rect\") {\r\n const x = parseFloat(adaptor.getAttribute(node, \"x\") || \"0\");\r\n const y = parseFloat(adaptor.getAttribute(node, \"y\") || \"0\");\r\n const w = parseFloat(adaptor.getAttribute(node, \"width\") || \"0\");\r\n const h = parseFloat(adaptor.getAttribute(node, \"height\") || \"0\");\r\n\r\n if (w > 0 && h > 0) {\r\n const pts = [[x, y], [x + w, y], [x + w, y + h], [x, y + h]];\r\n const tp = pts.map(p => applyMatrix(p[0], p[1], nodeMatrix));\r\n pushCmds(`__rect_${synthIdx++}`, [\r\n { cmd: 'M', args: [tp[0][0], tp[0][1]] },\r\n { cmd: 'L', args: [tp[1][0], tp[1][1]] },\r\n { cmd: 'L', args: [tp[2][0], tp[2][1]] },\r\n { cmd: 'L', args: [tp[3][0], tp[3][1]] },\r\n { cmd: 'Z', args: [] },\r\n ]);\r\n }\r\n } else if (nodeName === \"path\" && parentKind(node) !== \"defs\") {\r\n const d = adaptor.getAttribute(node, \"d\");\r\n if (d) {\r\n const abs = expandToAbsolute(tokenisePath(d));\r\n const cmds: Array<{ cmd: string; args: number[] }> = [];\r\n for (const gc of abs) {\r\n const shiftedArgs = [...gc.args];\r\n for (let j = 0; j < shiftedArgs.length; j += 2) {\r\n const [nx, ny] = applyMatrix(shiftedArgs[j], shiftedArgs[j + 1], nodeMatrix);\r\n shiftedArgs[j] = nx;\r\n shiftedArgs[j + 1] = ny;\r\n }\r\n cmds.push({ cmd: gc.cmd, args: shiftedArgs });\r\n }\r\n pushCmds(`__path_${synthIdx++}`, cmds);\r\n }\r\n }\r\n\r\n for (const child of adaptor.childNodes(node) as unknown[]) {\r\n // A text node's kind is \"#text\"; only elements carry geometry, and\r\n // <defs> holds the dictionary rather than anything drawn.\r\n const kind = String(adaptor.kind(child)).toLowerCase();\r\n if (kind.startsWith(\"#\") || kind === \"defs\") continue;\r\n traverse(child, nodeMatrix, part);\r\n }\r\n if (part !== within) parts[part].to = rawTokens.length;\r\n }\r\n\r\n traverse(svgEl, identityMatrix, -1);\r\n\r\n for (const part of parts) {\r\n if (part.parent !== -1) continue;\r\n for (let i = part.from; i < part.to; i++) rawTokens[i].term = part.latex;\r\n }\r\n\r\n // Bounding box across all raw commands, in the SVG's own coordinates.\r\n const box = svgBBox(rawTokens.flatMap(t => t.cmds));\r\n return { tokens: rawTokens, parts, box, heightEx };\r\n}\r\n\r\n/**\r\n * The size-dependent half: glyph geometry in, a laid-out formula out.\r\n *\r\n * Everything here is one uniform scale about the geometry's own centre, which\r\n * is exactly why {@link LatexGeometry} is worth remembering on its own.\r\n */\r\nfunction scaleLatexGeometry(geometry: LatexGeometry, fontSize: number): LatexPathResult {\r\n const { tokens: rawTokens, parts, box, heightEx } = geometry;\r\n if (rawTokens.length === 0) return { tokens: [], parts: [], commands: [], width: 0, height: 0, bounds: [0, 0, 0, 0] };\r\n\r\n const { minX, minY, maxX, maxY } = box;\r\n const svgW = maxX - minX;\r\n const svgH = maxY - minY;\r\n\r\n let scale: number;\r\n if (heightEx > 0 && svgH > 0) {\r\n const exInCoords = svgH / heightEx;\r\n scale = fontSize / (2 * exInCoords);\r\n } else {\r\n scale = svgH > 0 ? fontSize / svgH : 1;\r\n }\r\n\r\n const ocx = (minX + maxX) / 2;\r\n const ocy = (minY + maxY) / 2;\r\n\r\n const tx = (svgX: number) => (svgX - ocx) * scale;\r\n const ty = (svgY: number) => (svgY - ocy) * scale;\r\n\r\n function rawCmdsToPathCommands(cmds: Array<{ cmd: string; args: number[] }>): PathCommand[] {\r\n const out: PathCommand[] = [];\r\n for (const { cmd, args: a } of cmds) {\r\n switch (cmd) {\r\n case 'M': out.push({ type: 'M', x: tx(a[0]), y: ty(a[1]) }); break;\r\n case 'L': out.push({ type: 'L', x: tx(a[0]), y: ty(a[1]) }); break;\r\n case 'Q': out.push({ type: 'Q', x1: tx(a[0]), y1: ty(a[1]), x: tx(a[2]), y: ty(a[3]) }); break;\r\n case 'C': out.push({ type: 'C', x1: tx(a[0]), y1: ty(a[1]), x2: tx(a[2]), y2: ty(a[3]), x: tx(a[4]), y: ty(a[5]) }); break;\r\n case 'Z': out.push({ type: 'Z' }); break;\r\n }\r\n }\r\n return out;\r\n }\r\n\r\n const tokens: LatexToken[] = rawTokens.map(rt => ({\r\n token: rt.token,\r\n path: rawCmdsToPathCommands(rt.cmds),\r\n ...(rt.term !== undefined && { term: rt.term }),\r\n }));\r\n\r\n const commands = tokens.flatMap(t => t.path);\r\n\r\n // Shared center frame for all tokens, in token coordinate space. tx/ty map\r\n // the SVG bbox corners; this is the frame every token's path is laid out in.\r\n const bounds: [number, number, number, number] = [\r\n tx(minX), ty(minY), tx(maxX), ty(maxY),\r\n ];\r\n\r\n return { tokens, parts, commands, width: svgW * scale, height: svgH * scale, bounds };\r\n}\r\n\r\n// --- Parts ---\r\n\r\n// Spacing and grouping braces are how a source is written, not what it says:\r\n// `x^{2}` and `x^2` name one part.\r\nfunction partKey(latex: string): string {\r\n return latex.replace(/[\\s{}]/g, \"\");\r\n}\r\n\r\n/**\r\n * The sources of a formula's parts, each once, in the order written: what a\r\n * host offers to pick a part from. Empty for a formula that will not typeset.\r\n */\r\nexport function latexPartNames(source: string): string[] {\r\n if (source.trim() === \"\") return [];\r\n let parts: LatexPart[];\r\n try {\r\n parts = buildLatexPath(source, 16).parts;\r\n } catch {\r\n return [];\r\n }\r\n const seen = new Set<string>();\r\n const names: string[] = [];\r\n for (const part of parts) {\r\n const key = partKey(part.latex);\r\n if (part.to <= part.from || key === \"\" || seen.has(key)) continue;\r\n seen.add(key);\r\n names.push(part.latex);\r\n }\r\n return names;\r\n}\r\n\r\n/**\r\n * The token spans `selector` names in a formula, in source order: every part\r\n * whose source it is, and every run of neighbouring parts that spell it\r\n * together (`b^2 = c^2` in `a^2 + b^2 = c^2`). Empty when it names nothing.\r\n */\r\nexport function findLatexParts(parts: readonly LatexPart[], selector: string): Array<[from: number, to: number]> {\r\n const wanted = partKey(selector);\r\n if (wanted === \"\") return [];\r\n const found = new Map<string, [number, number]>();\r\n const keep = (from: number, to: number) => {\r\n if (to > from) found.set(`${from}:${to}`, [from, to]);\r\n };\r\n const children = new Map<number, number[]>();\r\n parts.forEach((part, i) => {\r\n if (partKey(part.latex) === wanted) keep(part.from, part.to);\r\n const siblings = children.get(part.parent);\r\n if (siblings) siblings.push(i);\r\n else children.set(part.parent, [i]);\r\n });\r\n for (const siblings of children.values()) {\r\n for (let a = 0; a < siblings.length; a++) {\r\n let spelled = \"\";\r\n for (let b = a; b < siblings.length && spelled.length < wanted.length; b++) {\r\n spelled += partKey(parts[siblings[b]].latex);\r\n if (b > a && spelled === wanted) keep(parts[siblings[a]].from, parts[siblings[b]].to);\r\n }\r\n }\r\n }\r\n return [...found.values()].sort((x, y) => x[0] - y[0] || x[1] - y[1]);\r\n}\r\n\r\n// --- SVG Path Utilities ---\r\n\r\ntype RawCmd = { cmd: string; args: number[] };\r\n\r\nfunction tokenisePath(d: string): RawCmd[] {\r\n const re = /([MmLlHhVvCcSsQqTtAaZz])|([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?)/g;\r\n const out: RawCmd[] = [];\r\n let cur: RawCmd | null = null;\r\n let m: RegExpExecArray | null;\r\n while ((m = re.exec(d)) !== null) {\r\n if (m[1]) { cur = { cmd: m[1], args: [] }; out.push(cur); }\r\n else if (cur) cur.args.push(parseFloat(m[2]));\r\n }\r\n return out;\r\n}\r\n\r\nfunction argCount(cmd: string): number {\r\n switch (cmd.toUpperCase()) {\r\n case 'M': return 2; case 'L': return 2; case 'H': return 1; case 'V': return 1;\r\n case 'C': return 6; case 'S': return 4; case 'Q': return 4; case 'T': return 2;\r\n case 'A': return 7; case 'Z': return 0; default: return 0;\r\n }\r\n}\r\n\r\ninterface Pt { x: number; y: number }\r\n\r\nfunction expandToAbsolute(raw: RawCmd[]): Array<{ cmd: string; args: number[] }> {\r\n const out: Array<{ cmd: string; args: number[] }> = [];\r\n let cx = 0, cy = 0;\r\n let mx = 0, my = 0;\r\n let prevCmd = '';\r\n let prevCtrl: Pt = { x: 0, y: 0 };\r\n\r\n for (const { cmd, args } of raw) {\r\n const up = cmd.toUpperCase();\r\n const rel = cmd === cmd.toLowerCase() && up !== 'Z';\r\n const n = argCount(up);\r\n const reps = n === 0 ? 1 : Math.max(1, Math.ceil(args.length / n));\r\n\r\n for (let r = 0; r < reps; r++) {\r\n const a = args.slice(r * n, r * n + n);\r\n const absX = (i: number) => rel ? a[i] + cx : a[i];\r\n const absY = (i: number) => rel ? a[i] + cy : a[i];\r\n\r\n switch (up) {\r\n case 'M': {\r\n const x = absX(0), y = absY(1);\r\n const emitCmd = r === 0 ? 'M' : 'L';\r\n out.push({ cmd: emitCmd, args: [x, y] });\r\n cx = x; cy = y;\r\n if (r === 0) { mx = x; my = y; }\r\n prevCmd = emitCmd;\r\n prevCtrl = { x: cx, y: cy };\r\n break;\r\n }\r\n case 'Z':\r\n out.push({ cmd: 'Z', args: [] });\r\n cx = mx; cy = my;\r\n prevCmd = 'Z';\r\n break;\r\n case 'L': {\r\n const x = absX(0), y = absY(1);\r\n out.push({ cmd: 'L', args: [x, y] });\r\n cx = x; cy = y;\r\n prevCmd = 'L';\r\n prevCtrl = { x: cx, y: cy };\r\n break;\r\n }\r\n case 'H': {\r\n const x = rel ? a[0] + cx : a[0];\r\n out.push({ cmd: 'L', args: [x, cy] });\r\n cx = x;\r\n prevCmd = 'L';\r\n prevCtrl = { x: cx, y: cy };\r\n break;\r\n }\r\n case 'V': {\r\n const y = rel ? a[0] + cy : a[0];\r\n out.push({ cmd: 'L', args: [cx, y] });\r\n cy = y;\r\n prevCmd = 'L';\r\n prevCtrl = { x: cx, y: cy };\r\n break;\r\n }\r\n case 'C': {\r\n const x1 = absX(0), y1 = absY(1);\r\n const x2 = absX(2), y2 = absY(3);\r\n const x = absX(4), y = absY(5);\r\n out.push({ cmd: 'C', args: [x1, y1, x2, y2, x, y] });\r\n prevCtrl = { x: x2, y: y2 };\r\n cx = x; cy = y;\r\n prevCmd = 'C';\r\n break;\r\n }\r\n case 'S': {\r\n const x1 = prevCmd === 'C' || prevCmd === 'S' ? 2 * cx - prevCtrl.x : cx;\r\n const y1 = prevCmd === 'C' || prevCmd === 'S' ? 2 * cy - prevCtrl.y : cy;\r\n const x2 = absX(0), y2 = absY(1);\r\n const x = absX(2), y = absY(3);\r\n out.push({ cmd: 'C', args: [x1, y1, x2, y2, x, y] });\r\n prevCtrl = { x: x2, y: y2 };\r\n cx = x; cy = y;\r\n prevCmd = 'S';\r\n break;\r\n }\r\n case 'Q': {\r\n const x1 = absX(0), y1 = absY(1);\r\n const x = absX(2), y = absY(3);\r\n out.push({ cmd: 'Q', args: [x1, y1, x, y] });\r\n prevCtrl = { x: x1, y: y1 };\r\n cx = x; cy = y;\r\n prevCmd = 'Q';\r\n break;\r\n }\r\n case 'T': {\r\n const x1 = prevCmd === 'Q' || prevCmd === 'T' ? 2 * cx - prevCtrl.x : cx;\r\n const y1 = prevCmd === 'Q' || prevCmd === 'T' ? 2 * cy - prevCtrl.y : cy;\r\n const x = absX(0), y = absY(1);\r\n out.push({ cmd: 'Q', args: [x1, y1, x, y] });\r\n prevCtrl = { x: x1, y: y1 };\r\n cx = x; cy = y;\r\n prevCmd = 'T';\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (out.length > 0 && out[out.length - 1].cmd !== 'Z') {\r\n out.push({ cmd: 'Z', args: [] });\r\n }\r\n\r\n return out;\r\n}\r\n\r\nfunction svgBBox(abs: Array<{ cmd: string; args: number[] }>): { minX: number; minY: number; maxX: number; maxY: number } {\r\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\r\n const touch = (x: number, y: number) => {\r\n if (x < minX) minX = x; if (x > maxX) maxX = x;\r\n if (y < minY) minY = y; if (y > maxY) maxY = y;\r\n };\r\n for (const { cmd, args } of abs) {\r\n switch (cmd) {\r\n case 'M': case 'L': touch(args[0], args[1]); break;\r\n case 'C': touch(args[0], args[1]); touch(args[2], args[3]); touch(args[4], args[5]); break;\r\n case 'Q': touch(args[0], args[1]); touch(args[2], args[3]); break;\r\n }\r\n }\r\n return { minX, minY, maxX, maxY };\r\n}\r\n"]}
1
+ {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/tex/geometry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMlD,IAAI,OAAO,GAA0B,IAAI,CAAC;AAC1C,IAAI,OAAO,GAAyB,IAAI,CAAC;AACzC,2HAA2H;AAC3H,IAAI,OAAO,GAAQ,IAAI,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C,mGAAmG;AACnG,MAAM,UAAU,WAAW;IACvB,OAAO,KAAK,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5C,OAAO,GAAG,MAAM,CAAC;QACjB,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,aAAa;IACzB,OAAO,OAAO,KAAK,IAAI,CAAC;AAC5B,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,UAAU;IACtB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC9F,CAAC;AAED,kGAAkG;AAClG,MAAM,OAAO,cAAe,SAAQ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CAAC;YACV,KAAK,GAAG,CAAC;YAAC,KAAK,GAAG;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,MAAM;YACnD,KAAK,GAAG;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,MAAM;YAC3F,KAAK,GAAG;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,MAAM;QACtE,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC","sourcesContent":["\nimport { PathCommand } from '@motionscript/sdk';\n\nimport { createBoundedCache } from '../kit/cache';\n\n// --- MathJax, on demand ---\n\ntype MathJaxRuntime = typeof import('./mathjax');\n\nlet runtime: MathJaxRuntime | null = null;\nlet loading: Promise<void> | null = null;\n// MathJax's DOM, a real one or its own DOM-free tree: read only through its accessors, so its element type is opaque here.\nlet adaptor: any = null;\n\n/**\n * The asset key a node that typesets declares its loader under: the host waits\n * for it before laying the node out, and a scene with no formula never loads it.\n */\nexport const MATHJAX_LOADER = 'math:mathjax';\n\n/** Load MathJax, once. A host that typesets outside a scene (a tool, a test) awaits this first. */\nexport function loadMathJax(): Promise<void> {\n loading ??= import('./mathjax').then((module) => {\n runtime = module;\n adaptor = module.adaptor;\n });\n return loading;\n}\n\n/** Whether MathJax has loaded, so a formula can be typeset now. */\nexport function mathJaxLoaded(): boolean {\n return runtime !== null;\n}\n\n/** What a formula is before MathJax has loaded: nothing to draw, and nothing cached. */\nexport function blankLatex(): LatexPathResult {\n return { tokens: [], parts: [], commands: [], width: 0, height: 0, bounds: [0, 0, 0, 0] };\n}\n\n/** MathJax is not loaded yet: what typesetting throws before {@link loadMathJax} has resolved. */\nexport class LatexNotLoaded extends Error {\n constructor() {\n super('MathJax is not loaded: declare the math:mathjax loader, or await loadMathJax(), before typesetting.');\n this.name = 'LatexNotLoaded';\n }\n}\n\n// --- Public API ---\n\n/**\n * A formula MathJax could not typeset.\n *\n * MathJax does not throw on malformed TeX. It typesets an error box in place of\n * the formula and tags it `data-mjx-error`, so the failure arrives as a drawing:\n * nothing at all from the browser adaptor and a filled bar from the DOM-free\n * one, which left a host able to tell a bad formula from a blank one only by the\n * token count. {@link buildLatexPath} raises this instead, the same way under\n * both adaptors. `\\require` is an error too, since only the packages named above\n * are loaded.\n */\nexport class LatexError extends Error {\n /** The formula that failed, as it was given. */\n readonly latex: string;\n /** MathJax's own description of what is wrong with it. */\n readonly reason: string;\n\n constructor(latex: string, reason: string) {\n super(`Cannot typeset \"${latex}\": ${reason}`);\n this.name = 'LatexError';\n this.latex = latex;\n this.reason = reason;\n }\n}\n\n/** A single rendered glyph or shape with its character key and path commands. */\nexport interface LatexToken {\n /** Character this token represents, or a synthetic key for non-glyph shapes. */\n token: string;\n path: PathCommand[];\n /** The source of the top-level term the token belongs to, `a^2` in `a^2 + b^2`; empty for none. */\n term?: string;\n}\n\n/**\n * A piece of a formula as its source wrote it: `x^2`, `\\frac{d}{dx}`, a lone\n * `+`. Every group the typesetter makes is one, so parts nest.\n */\nexport interface LatexPart {\n /** The part's own source. */\n latex: string;\n /** The tokens it draws, as a span of the formula's token list: `from` up to, not including, `to`. */\n from: number;\n to: number;\n /** The index of the part it sits in, or -1 at the top. */\n parent: number;\n}\n\nexport interface LatexPathResult {\n /** All tokens in render order. */\n tokens: LatexToken[];\n /** Every part of the formula, outermost first, in source order. */\n parts: LatexPart[];\n /** Flat array of all path commands (for legacy single-path rendering). */\n commands: PathCommand[];\n width: number;\n height: number;\n /**\n * Bounding box over every token, in token coordinate space:\n * [minX, minY, maxX, maxY]. All tokens share this frame, so passing it as\n * each path's center frame keeps their relative layout (instead of each\n * glyph centering on its own bbox).\n */\n bounds: [number, number, number, number];\n}\n\n/**\n * A formula's glyph geometry, before a type size is applied to it.\n *\n * The dividing line this whole module's caching turns on. Getting here is the\n * expensive part — MathJax lays the formula out, then the SVG it produces is\n * parsed, its glyph dictionary resolved and every `<use>` walked through its\n * transform stack — and **none of it depends on `fontSize`**: `mjDoc.convert`\n * is called at a fixed em/ex, and the size arrives at the very end as one\n * uniform scale (see {@link scaleLatexGeometry}).\n *\n * So this is what gets remembered per formula, and the size is applied to it\n * afresh. A formula animating from 24pt to 120pt is one trip through MathJax\n * and one DOM parse, not one per frame.\n */\ninterface LatexGeometry {\n tokens: RawToken[];\n parts: LatexPart[];\n /** Box over every command, in the SVG's own coordinates. */\n box: { minX: number; minY: number; maxX: number; maxY: number };\n /** The formula's height in `ex`, as MathJax reported it. */\n heightEx: number;\n}\n\n/**\n * Formulas already worked out, and formulas already sized.\n *\n * `buildLatexPath` is a pure function of `(text, fontSize)` and used to have no\n * memory, which made every caller pay full price for a question it had already\n * asked. The callers are not occasional about it either: constructing a `Latex`\n * resolves its formula, and so does every `to({ latex })` the moment it starts,\n * so a scene re-resolves every formula in it whenever it is rebuilt *and*\n * whenever the playhead moves backwards, since a backward seek replays the\n * scene's generator from its first frame. An editor that rebuilds on a keystroke\n * and seeks on a click asks for the same handful of formulas hundreds of times.\n *\n * Two memos, each keyed by what its stage actually depends on, and deliberately\n * different sizes:\n *\n * - {@link geometryCache} is everything up to the type size, keyed by the text\n * alone. This is the expensive one, and it is generously sized because\n * nothing a scene does can churn it: a deck holds as many distinct formulas\n * as it holds, and it holds them for as long as it is open.\n * - {@link pathCache} is the finished result, keyed by text *and* size. Small\n * on purpose: an animated `fontSize` inserts a distinct key every frame, and\n * the right thing for a stream like that is to churn a little memo rather\n * than a big one. What a miss costs here is arithmetic over glyphs already\n * worked out — no MathJax, no parse.\n */\nconst geometryCache = createBoundedCache<LatexGeometry>(128);\nconst pathCache = createBoundedCache<LatexPathResult>(64);\n\nexport function buildLatexPath(text: string, fontSize: number): LatexPathResult {\n // NUL rather than a punctuation separator, so no formula can spell a key\n // belonging to another size.\n const key = `${fontSize}\\0${text}`;\n\n const hit = pathCache.get(key);\n if (hit) return lend(hit);\n\n let geometry = geometryCache.get(text);\n if (!geometry) {\n geometry = buildLatexGeometry(text);\n geometryCache.set(text, geometry);\n }\n\n const result = scaleLatexGeometry(geometry, fontSize);\n pathCache.set(key, result);\n return lend(result);\n}\n\n/** Typeset `text` and reduce the SVG MathJax returns to glyph geometry. */\nfunction buildLatexGeometry(text: string): LatexGeometry {\n if (!runtime) throw new LatexNotLoaded();\n const svgEl = adaptor.firstChild(runtime.convert(text));\n const failure = mathJaxError(svgEl);\n if (failure !== null) throw new LatexError(text, failure);\n\n const heightAttr = adaptor.getAttribute(svgEl, 'height') ?? '';\n\n return parseLatexSvg(svgEl, parseFloat(heightAttr) || 0);\n}\n\n/**\n * MathJax's description of the error box in a typeset formula, or `null` when\n * there is none. Read through the adaptor, so a real DOM and the DOM-free tree\n * give the same answer.\n */\nfunction mathJaxError(svgEl: unknown): string | null {\n for (const el of adaptor.tags(svgEl, 'g') as unknown[]) {\n const reason = adaptor.getAttribute(el, 'data-mjx-error');\n if (reason !== null && reason !== undefined) return String(reason) || 'unknown error';\n }\n return null;\n}\n\n/**\n * A cached result, handed out safely.\n *\n * `tokens`, `commands` and the path arrays inside them are shared: they are read\n * by everything downstream and written by none of it — `Latex` maps tokens into\n * its own wrappers, and the morph builds new paths rather than editing the ones\n * it is given — so copying them would be copying the whole formula for nothing.\n *\n * `bounds` is copied, because it is the one field a caller *stores*: `Latex`\n * assigns `result.bounds` straight to `this._bounds` and hands it to the\n * renderer as a shared centring frame. That was one node holding its own array\n * before there was a memo, and would be two nodes drawing the same formula\n * holding one array between them after — four numbers is not a price worth\n * paying to find out whether anything downstream ever writes to it.\n */\nfunction lend(result: LatexPathResult): LatexPathResult {\n const [minX, minY, maxX, maxY] = result.bounds;\n return { ...result, bounds: [minX, minY, maxX, maxY] };\n}\n\n// --- High-Speed Matrix Math ---\n\ntype Matrix = [number, number, number, number, number, number]; // [a, b, c, d, tx, ty]\nconst identityMatrix: Matrix = [1, 0, 0, 1, 0, 0];\n\nfunction multiplyMatrix(m1: Matrix, m2: Matrix): Matrix {\n return [\n m1[0] * m2[0] + m1[2] * m2[1],\n m1[1] * m2[0] + m1[3] * m2[1],\n m1[0] * m2[2] + m1[2] * m2[3],\n m1[1] * m2[2] + m1[3] * m2[3],\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5],\n ];\n}\n\nfunction parseTransform(str: string | null): Matrix {\n if (!str) return identityMatrix;\n let m: Matrix = [...identityMatrix];\n const re = /([a-z]+)\\(([^)]+)\\)/g;\n let match;\n while ((match = re.exec(str)) !== null) {\n const type = match[1];\n const args = match[2].split(/[ ,]+/).map(parseFloat);\n if (type === 'translate') {\n m = multiplyMatrix(m, [1, 0, 0, 1, args[0] || 0, args[1] || 0]);\n } else if (type === 'scale') {\n const sx = args[0] || 1;\n const sy = args[1] !== undefined ? args[1] : sx;\n m = multiplyMatrix(m, [sx, 0, 0, sy, 0, 0]);\n } else if (type === 'matrix') {\n m = multiplyMatrix(m, [args[0], args[1], args[2], args[3], args[4], args[5]]);\n }\n }\n return m;\n}\n\nfunction applyMatrix(x: number, y: number, m: Matrix): [number, number] {\n return [\n x * m[0] + y * m[2] + m[4],\n x * m[1] + y * m[3] + m[5],\n ];\n}\n\n// --- Glyph ID → character decoding ---\n\n/**\n * MathJax SVG glyph IDs look like \"MJX-1-TEX-N-78\" or \"MJX-1-TEX-I-1D465\".\n * The last segment is the Unicode codepoint in hex.\n */\nfunction glyphIdToChar(id: string): string {\n const parts = id.split('-');\n const hex = parts[parts.length - 1];\n const cp = parseInt(hex, 16);\n if (!isNaN(cp)) {\n try { return String.fromCodePoint(cp); } catch { /* fall through */ }\n }\n return id;\n}\n\n// --- Core Fast Traversal Engine ---\n\ntype RawToken = { token: string; cmds: Array<{ cmd: string; args: number[] }>; term?: string };\n\n/** The tag name of a node's parent, or \"\" at the root. */\nfunction parentKind(node: unknown): string {\n const parent = adaptor.parent(node);\n return parent ? String(adaptor.kind(parent)).toLowerCase() : \"\";\n}\n\n/**\n * The size-independent half: MathJax's own SVG tree in, glyph geometry out.\n *\n * Walked through the **adaptor** rather than a `DOMParser`. MathJax already\n * builds this tree, and the adaptor is its own abstraction over \"a real DOM\" and\n * \"the DOM-free `LiteElement` tree\" — the two this module already picks between\n * at load. Serialising it to a string and parsing it back needed a `DOMParser`,\n * which Node does not have, so every LaTeX node threw `DOMParser is not defined`\n * and could not render headlessly at all: no export, and nothing the visual\n * suite could check.\n *\n * Reading the tree directly is also one representation instead of three (tree →\n * string → tree), so a browser and a headless host cannot disagree about how the\n * markup re-parsed.\n */\nfunction parseLatexSvg(svgEl: unknown, heightEx: number): LatexGeometry {\n // Pre-parse the glyph dictionary. `tags` reaches every <path> in the tree,\n // including the ones inside <defs> that the `use` elements reference.\n const glyphMap = new Map<string, Array<{ cmd: string; args: number[] }>>();\n for (const el of adaptor.tags(svgEl, 'path') as unknown[]) {\n const id = adaptor.getAttribute(el, 'id');\n const d = adaptor.getAttribute(el, 'd');\n if (id && d) {\n glyphMap.set(`#${id}`, expandToAbsolute(tokenisePath(d)));\n }\n }\n\n // Collect raw tokens — each <use> is one token, rects/paths are grouped as synthetic tokens\n const rawTokens: RawToken[] = [];\n const parts: LatexPart[] = [];\n let synthIdx = 0;\n\n function pushCmds(token: string, cmds: Array<{ cmd: string; args: number[] }>) {\n rawTokens.push({ token, cmds });\n }\n\n function traverse(node: unknown, currentMatrix: Matrix, within: number) {\n let nodeMatrix = currentMatrix;\n\n const transformStr = adaptor.getAttribute(node, \"transform\");\n if (transformStr) {\n nodeMatrix = multiplyMatrix(nodeMatrix, parseTransform(transformStr));\n }\n\n const nodeName = String(adaptor.kind(node)).toLowerCase();\n\n // MathJax tags each group with the source it typeset; the root's is the whole formula.\n let part = within;\n const source = nodeName === \"g\" ? adaptor.getAttribute(node, \"data-latex\") : null;\n if (source && adaptor.getAttribute(node, \"data-mml-node\") !== \"math\") {\n part = parts.length;\n parts.push({ latex: String(source), from: rawTokens.length, to: rawTokens.length, parent: within });\n }\n\n if (nodeName === \"use\") {\n const href = adaptor.getAttribute(node, \"href\") || adaptor.getAttribute(node, \"xlink:href\");\n const x = parseFloat(adaptor.getAttribute(node, \"x\") || \"0\");\n const y = parseFloat(adaptor.getAttribute(node, \"y\") || \"0\");\n\n if (href && glyphMap.has(href)) {\n const glyphCommands = glyphMap.get(href)!;\n const cmds: Array<{ cmd: string; args: number[] }> = [];\n for (const gc of glyphCommands) {\n const shiftedArgs = [...gc.args];\n for (let j = 0; j < shiftedArgs.length; j += 2) {\n const [nx, ny] = applyMatrix(shiftedArgs[j] + x, shiftedArgs[j + 1] + y, nodeMatrix);\n shiftedArgs[j] = nx;\n shiftedArgs[j + 1] = ny;\n }\n cmds.push({ cmd: gc.cmd, args: shiftedArgs });\n }\n // Derive character from glyph ID\n const rawId = href.startsWith('#') ? href.slice(1) : href;\n pushCmds(glyphIdToChar(rawId), cmds);\n }\n } else if (nodeName === \"rect\") {\n const x = parseFloat(adaptor.getAttribute(node, \"x\") || \"0\");\n const y = parseFloat(adaptor.getAttribute(node, \"y\") || \"0\");\n const w = parseFloat(adaptor.getAttribute(node, \"width\") || \"0\");\n const h = parseFloat(adaptor.getAttribute(node, \"height\") || \"0\");\n\n if (w > 0 && h > 0) {\n const pts = [[x, y], [x + w, y], [x + w, y + h], [x, y + h]];\n const tp = pts.map(p => applyMatrix(p[0], p[1], nodeMatrix));\n pushCmds(`__rect_${synthIdx++}`, [\n { cmd: 'M', args: [tp[0][0], tp[0][1]] },\n { cmd: 'L', args: [tp[1][0], tp[1][1]] },\n { cmd: 'L', args: [tp[2][0], tp[2][1]] },\n { cmd: 'L', args: [tp[3][0], tp[3][1]] },\n { cmd: 'Z', args: [] },\n ]);\n }\n } else if (nodeName === \"path\" && parentKind(node) !== \"defs\") {\n const d = adaptor.getAttribute(node, \"d\");\n if (d) {\n const abs = expandToAbsolute(tokenisePath(d));\n const cmds: Array<{ cmd: string; args: number[] }> = [];\n for (const gc of abs) {\n const shiftedArgs = [...gc.args];\n for (let j = 0; j < shiftedArgs.length; j += 2) {\n const [nx, ny] = applyMatrix(shiftedArgs[j], shiftedArgs[j + 1], nodeMatrix);\n shiftedArgs[j] = nx;\n shiftedArgs[j + 1] = ny;\n }\n cmds.push({ cmd: gc.cmd, args: shiftedArgs });\n }\n pushCmds(`__path_${synthIdx++}`, cmds);\n }\n }\n\n for (const child of adaptor.childNodes(node) as unknown[]) {\n // A text node's kind is \"#text\"; only elements carry geometry, and\n // <defs> holds the dictionary rather than anything drawn.\n const kind = String(adaptor.kind(child)).toLowerCase();\n if (kind.startsWith(\"#\") || kind === \"defs\") continue;\n traverse(child, nodeMatrix, part);\n }\n if (part !== within) parts[part].to = rawTokens.length;\n }\n\n traverse(svgEl, identityMatrix, -1);\n\n for (const part of parts) {\n if (part.parent !== -1) continue;\n for (let i = part.from; i < part.to; i++) rawTokens[i].term = part.latex;\n }\n\n // Bounding box across all raw commands, in the SVG's own coordinates.\n const box = svgBBox(rawTokens.flatMap(t => t.cmds));\n return { tokens: rawTokens, parts, box, heightEx };\n}\n\n/**\n * The size-dependent half: glyph geometry in, a laid-out formula out.\n *\n * Everything here is one uniform scale about the geometry's own centre, which\n * is exactly why {@link LatexGeometry} is worth remembering on its own.\n */\nfunction scaleLatexGeometry(geometry: LatexGeometry, fontSize: number): LatexPathResult {\n const { tokens: rawTokens, parts, box, heightEx } = geometry;\n if (rawTokens.length === 0) return { tokens: [], parts: [], commands: [], width: 0, height: 0, bounds: [0, 0, 0, 0] };\n\n const { minX, minY, maxX, maxY } = box;\n const svgW = maxX - minX;\n const svgH = maxY - minY;\n\n let scale: number;\n if (heightEx > 0 && svgH > 0) {\n const exInCoords = svgH / heightEx;\n scale = fontSize / (2 * exInCoords);\n } else {\n scale = svgH > 0 ? fontSize / svgH : 1;\n }\n\n const ocx = (minX + maxX) / 2;\n const ocy = (minY + maxY) / 2;\n\n const tx = (svgX: number) => (svgX - ocx) * scale;\n const ty = (svgY: number) => (svgY - ocy) * scale;\n\n function rawCmdsToPathCommands(cmds: Array<{ cmd: string; args: number[] }>): PathCommand[] {\n const out: PathCommand[] = [];\n for (const { cmd, args: a } of cmds) {\n switch (cmd) {\n case 'M': out.push({ type: 'M', x: tx(a[0]), y: ty(a[1]) }); break;\n case 'L': out.push({ type: 'L', x: tx(a[0]), y: ty(a[1]) }); break;\n case 'Q': out.push({ type: 'Q', x1: tx(a[0]), y1: ty(a[1]), x: tx(a[2]), y: ty(a[3]) }); break;\n case 'C': out.push({ type: 'C', x1: tx(a[0]), y1: ty(a[1]), x2: tx(a[2]), y2: ty(a[3]), x: tx(a[4]), y: ty(a[5]) }); break;\n case 'Z': out.push({ type: 'Z' }); break;\n }\n }\n return out;\n }\n\n const tokens: LatexToken[] = rawTokens.map(rt => ({\n token: rt.token,\n path: rawCmdsToPathCommands(rt.cmds),\n ...(rt.term !== undefined && { term: rt.term }),\n }));\n\n const commands = tokens.flatMap(t => t.path);\n\n // Shared center frame for all tokens, in token coordinate space. tx/ty map\n // the SVG bbox corners; this is the frame every token's path is laid out in.\n const bounds: [number, number, number, number] = [\n tx(minX), ty(minY), tx(maxX), ty(maxY),\n ];\n\n return { tokens, parts, commands, width: svgW * scale, height: svgH * scale, bounds };\n}\n\n// --- Parts ---\n\n// Spacing and grouping braces are how a source is written, not what it says:\n// `x^{2}` and `x^2` name one part.\nfunction partKey(latex: string): string {\n return latex.replace(/[\\s{}]/g, \"\");\n}\n\n/**\n * The sources of a formula's parts, each once, in the order written: what a\n * host offers to pick a part from. Empty for a formula that will not typeset.\n */\nexport function latexPartNames(source: string): string[] {\n if (source.trim() === \"\") return [];\n let parts: LatexPart[];\n try {\n parts = buildLatexPath(source, 16).parts;\n } catch {\n return [];\n }\n const seen = new Set<string>();\n const names: string[] = [];\n for (const part of parts) {\n const key = partKey(part.latex);\n if (part.to <= part.from || key === \"\" || seen.has(key)) continue;\n seen.add(key);\n names.push(part.latex);\n }\n return names;\n}\n\n/**\n * The token spans `selector` names in a formula, in source order: every part\n * whose source it is, and every run of neighbouring parts that spell it\n * together (`b^2 = c^2` in `a^2 + b^2 = c^2`). Empty when it names nothing.\n */\nexport function findLatexParts(parts: readonly LatexPart[], selector: string): Array<[from: number, to: number]> {\n const wanted = partKey(selector);\n if (wanted === \"\") return [];\n const found = new Map<string, [number, number]>();\n const keep = (from: number, to: number) => {\n if (to > from) found.set(`${from}:${to}`, [from, to]);\n };\n const children = new Map<number, number[]>();\n parts.forEach((part, i) => {\n if (partKey(part.latex) === wanted) keep(part.from, part.to);\n const siblings = children.get(part.parent);\n if (siblings) siblings.push(i);\n else children.set(part.parent, [i]);\n });\n for (const siblings of children.values()) {\n for (let a = 0; a < siblings.length; a++) {\n let spelled = \"\";\n for (let b = a; b < siblings.length && spelled.length < wanted.length; b++) {\n spelled += partKey(parts[siblings[b]].latex);\n if (b > a && spelled === wanted) keep(parts[siblings[a]].from, parts[siblings[b]].to);\n }\n }\n }\n return [...found.values()].sort((x, y) => x[0] - y[0] || x[1] - y[1]);\n}\n\n// --- SVG Path Utilities ---\n\ntype RawCmd = { cmd: string; args: number[] };\n\nfunction tokenisePath(d: string): RawCmd[] {\n const re = /([MmLlHhVvCcSsQqTtAaZz])|([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?)/g;\n const out: RawCmd[] = [];\n let cur: RawCmd | null = null;\n let m: RegExpExecArray | null;\n while ((m = re.exec(d)) !== null) {\n if (m[1]) { cur = { cmd: m[1], args: [] }; out.push(cur); }\n else if (cur) cur.args.push(parseFloat(m[2]));\n }\n return out;\n}\n\nfunction argCount(cmd: string): number {\n switch (cmd.toUpperCase()) {\n case 'M': return 2; case 'L': return 2; case 'H': return 1; case 'V': return 1;\n case 'C': return 6; case 'S': return 4; case 'Q': return 4; case 'T': return 2;\n case 'A': return 7; case 'Z': return 0; default: return 0;\n }\n}\n\ninterface Pt { x: number; y: number }\n\nfunction expandToAbsolute(raw: RawCmd[]): Array<{ cmd: string; args: number[] }> {\n const out: Array<{ cmd: string; args: number[] }> = [];\n let cx = 0, cy = 0;\n let mx = 0, my = 0;\n let prevCmd = '';\n let prevCtrl: Pt = { x: 0, y: 0 };\n\n for (const { cmd, args } of raw) {\n const up = cmd.toUpperCase();\n const rel = cmd === cmd.toLowerCase() && up !== 'Z';\n const n = argCount(up);\n const reps = n === 0 ? 1 : Math.max(1, Math.ceil(args.length / n));\n\n for (let r = 0; r < reps; r++) {\n const a = args.slice(r * n, r * n + n);\n const absX = (i: number) => rel ? a[i] + cx : a[i];\n const absY = (i: number) => rel ? a[i] + cy : a[i];\n\n switch (up) {\n case 'M': {\n const x = absX(0), y = absY(1);\n const emitCmd = r === 0 ? 'M' : 'L';\n out.push({ cmd: emitCmd, args: [x, y] });\n cx = x; cy = y;\n if (r === 0) { mx = x; my = y; }\n prevCmd = emitCmd;\n prevCtrl = { x: cx, y: cy };\n break;\n }\n case 'Z':\n out.push({ cmd: 'Z', args: [] });\n cx = mx; cy = my;\n prevCmd = 'Z';\n break;\n case 'L': {\n const x = absX(0), y = absY(1);\n out.push({ cmd: 'L', args: [x, y] });\n cx = x; cy = y;\n prevCmd = 'L';\n prevCtrl = { x: cx, y: cy };\n break;\n }\n case 'H': {\n const x = rel ? a[0] + cx : a[0];\n out.push({ cmd: 'L', args: [x, cy] });\n cx = x;\n prevCmd = 'L';\n prevCtrl = { x: cx, y: cy };\n break;\n }\n case 'V': {\n const y = rel ? a[0] + cy : a[0];\n out.push({ cmd: 'L', args: [cx, y] });\n cy = y;\n prevCmd = 'L';\n prevCtrl = { x: cx, y: cy };\n break;\n }\n case 'C': {\n const x1 = absX(0), y1 = absY(1);\n const x2 = absX(2), y2 = absY(3);\n const x = absX(4), y = absY(5);\n out.push({ cmd: 'C', args: [x1, y1, x2, y2, x, y] });\n prevCtrl = { x: x2, y: y2 };\n cx = x; cy = y;\n prevCmd = 'C';\n break;\n }\n case 'S': {\n const x1 = prevCmd === 'C' || prevCmd === 'S' ? 2 * cx - prevCtrl.x : cx;\n const y1 = prevCmd === 'C' || prevCmd === 'S' ? 2 * cy - prevCtrl.y : cy;\n const x2 = absX(0), y2 = absY(1);\n const x = absX(2), y = absY(3);\n out.push({ cmd: 'C', args: [x1, y1, x2, y2, x, y] });\n prevCtrl = { x: x2, y: y2 };\n cx = x; cy = y;\n prevCmd = 'S';\n break;\n }\n case 'Q': {\n const x1 = absX(0), y1 = absY(1);\n const x = absX(2), y = absY(3);\n out.push({ cmd: 'Q', args: [x1, y1, x, y] });\n prevCtrl = { x: x1, y: y1 };\n cx = x; cy = y;\n prevCmd = 'Q';\n break;\n }\n case 'T': {\n const x1 = prevCmd === 'Q' || prevCmd === 'T' ? 2 * cx - prevCtrl.x : cx;\n const y1 = prevCmd === 'Q' || prevCmd === 'T' ? 2 * cy - prevCtrl.y : cy;\n const x = absX(0), y = absY(1);\n out.push({ cmd: 'Q', args: [x1, y1, x, y] });\n prevCtrl = { x: x1, y: y1 };\n cx = x; cy = y;\n prevCmd = 'T';\n break;\n }\n }\n }\n }\n\n if (out.length > 0 && out[out.length - 1].cmd !== 'Z') {\n out.push({ cmd: 'Z', args: [] });\n }\n\n return out;\n}\n\nfunction svgBBox(abs: Array<{ cmd: string; args: number[] }>): { minX: number; minY: number; maxX: number; maxY: number } {\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n const touch = (x: number, y: number) => {\n if (x < minX) minX = x; if (x > maxX) maxX = x;\n if (y < minY) minY = y; if (y > maxY) maxY = y;\n };\n for (const { cmd, args } of abs) {\n switch (cmd) {\n case 'M': case 'L': touch(args[0], args[1]); break;\n case 'C': touch(args[0], args[1]); touch(args[2], args[3]); touch(args[4], args[5]); break;\n case 'Q': touch(args[0], args[1]); touch(args[2], args[3]); break;\n }\n }\n return { minX, minY, maxX, maxY };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,yEAAyE;AACzE,yGAAyG;AACzG,MAAM,CAAC,MAAM,SAAS,GAA0C,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { LatexMatrix } from './matrix';\r\nimport { Latex } from './node';\r\n\r\nexport * from './node';\r\nexport * from './matrix';\r\nexport {\r\n blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,\r\n} from './geometry';\r\nexport type { LatexPart, LatexToken, LatexPathResult } from './geometry';\r\nexport { defaultLatexMorph } from './tween';\r\nexport type { AnimatedToken, LatexMorphStrategy } from './tween';\r\n\r\n/** The typeset-math node types, for a host that registers only these. */\r\n// Typed by name, so the declaration names each component rather than spelling out its type through core.\r\nexport const TEX_NODES: (typeof Latex | typeof LatexMatrix)[] = [Latex, LatexMatrix];\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,yEAAyE;AACzE,yGAAyG;AACzG,MAAM,CAAC,MAAM,SAAS,GAA0C,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { LatexMatrix } from './matrix';\nimport { Latex } from './node';\n\nexport * from './node';\nexport * from './matrix';\nexport {\n blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,\n} from './geometry';\nexport type { LatexPart, LatexToken, LatexPathResult } from './geometry';\nexport { defaultLatexMorph } from './tween';\nexport type { AnimatedToken, LatexMorphStrategy } from './tween';\n\n/** The typeset-math node types, for a host that registers only these. */\n// Typed by name, so the declaration names each component rather than spelling out its type through core.\nexport const TEX_NODES: (typeof Latex | typeof LatexMatrix)[] = [Latex, LatexMatrix];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mathjax.js","sourceRoot":"","sources":["../../src/tex/mathjax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OA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AAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAC3E,MAAM,SAAS,GAAI,gBAAiE,CAAC,YAAY,CAAC;AAClG,KAAK,MAAM,IAAI,IAAI,kBAAkB;IAAE,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;AAE5E,sGAAsG;AACtG,MAAM,UAAU,OAAO,CAAC,IAAY;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QACvB,OAAO,EAAE,IAAI;QACb,EAAE,EAAE,EAAE;QACN,EAAE,EAAE,CAAC;QACL,cAAc,EAAE,EAAE,GAAG,EAAE;KAC1B,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { mathjax } from '@mathjax/src/js/mathjax.js';\r\nimport { TeX } from '@mathjax/src/js/input/tex.js';\r\nimport { SVG } from '@mathjax/src/js/output/svg.js';\r\nimport { browserAdaptor } from '@mathjax/src/js/adaptors/browserAdaptor.js';\r\nimport { liteAdaptor } from '@mathjax/src/js/adaptors/liteAdaptor.js';\r\nimport { RegisterHTMLHandler } from '@mathjax/src/js/handlers/html.js';\r\n\r\nimport '@mathjax/src/js/input/tex/base/BaseConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/ams/AmsConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/cancel/CancelConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/color/ColorConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/bbox/BboxConfiguration.js';\r\nimport '@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js';\r\nimport type { DynamicFileList } from '@mathjax/src/js/output/common/FontData.js';\r\nimport { MathJaxNewcmFont } from '@mathjax/mathjax-newcm-font/js/svg.js';\r\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/calligraphic.js';\r\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/double-struck.js';\r\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/fraktur.js';\r\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/monospace.js';\r\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/sans-serif.js';\r\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/script.js';\r\n\r\n/**\r\n * MathJax, set up: the one module that imports it, loaded on demand by\r\n * `loadMathJax` so a scene with no formula in it never downloads or parses it.\r\n */\r\n\r\n\r\n/**\r\n * MathJax needs a DOM to build its output in, and there isn't always one.\r\n *\r\n * `browserAdaptor()` reads `window` **as it is constructed**, at module scope —\r\n * so importing this file at all threw in Node, and a project with one LaTeX\r\n * scene could not be rendered headlessly no matter which scene was asked for.\r\n * `liteAdaptor` is MathJax's own DOM-free implementation and produces the same\r\n * SVG; we only ever read paths back out of it, never attach it to a page.\r\n */\r\n// The two adaptors are structurally different (a `LiteElement` tree vs. a real\r\n// one) and MathJax's generics track that, but nothing here touches an element\r\n// except through the adaptor's own accessors — so the element type is genuinely\r\n// opaque to us, and pinning it to either concrete one would be a lie.\r\nexport const adaptor: any = typeof window === 'undefined' && typeof document === 'undefined'\r\n ? liteAdaptor()\r\n : browserAdaptor();\r\nRegisterHTMLHandler(adaptor);\r\n\r\nconst texJax = new TeX({\r\n packages: [\r\n 'base', 'ams', 'boldsymbol', 'newcommand',\r\n 'cancel', 'color', 'mhchem', 'physics',\r\n 'bbox', 'mathtools',\r\n ],\r\n});\r\n\r\n/**\r\n * The font files behind `\\mathcal`, `\\mathbb`, `\\mathfrak`, `\\mathsf`, `\\mathtt`\r\n * and `\\mathscr`, imported above. MathJax fetches these asynchronously the first\r\n * time a formula needs one, which a synchronous typesetter cannot wait for, so\r\n * they are bundled and set up on the font before anything is typeset. The font\r\n * class is passed explicitly so the one they register on is the one in use.\r\n */\r\nconst BUNDLED_FONT_FILES = ['calligraphic', 'double-struck', 'fraktur', 'monospace', 'sans-serif', 'script'];\r\n\r\nconst svgJax = new SVG({ fontCache: 'local', fontData: MathJaxNewcmFont });\r\nconst fontFiles = (MathJaxNewcmFont as unknown as { dynamicFiles: DynamicFileList }).dynamicFiles;\r\nfor (const file of BUNDLED_FONT_FILES) fontFiles[file].setup(svgJax.font);\r\n\r\nconst mjDoc = mathjax.document('', { InputJax: texJax, OutputJax: svgJax });\r\n\r\n/** Typeset `text` as display math and hand back MathJax's container, read through {@link adaptor}. */\r\nexport function convert(text: string): unknown {\r\n return mjDoc.convert(text, {\r\n display: true,\r\n em: 16,\r\n ex: 8,\r\n containerWidth: 80 * 16,\r\n });\r\n}\r\n"]}
1
+ {"version":3,"file":"mathjax.js","sourceRoot":"","sources":["../../src/tex/mathjax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,qDAAqD,CAAC;AAC7D,OAAO,mDAAmD,CAAC;AAC3D,OAAO,iEAAiE,CAAC;AACzE,OAAO,iEAAiE,CAAC;AACzE,OAAO,yDAAyD,CAAC;AACjE,OAAO,uDAAuD,CAAC;AAC/D,OAAO,yDAAyD,CAAC;AACjE,OAAO,2DAA2D,CAAC;AACnE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AE,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;AAE5E,sGAAsG;AACtG,MAAM,UAAU,OAAO,CAAC,IAAY;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QACvB,OAAO,EAAE,IAAI;QACb,EAAE,EAAE,EAAE;QACN,EAAE,EAAE,CAAC;QACL,cAAc,EAAE,EAAE,GAAG,EAAE;KAC1B,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { mathjax } from '@mathjax/src/js/mathjax.js';\nimport { TeX } from '@mathjax/src/js/input/tex.js';\nimport { SVG } from '@mathjax/src/js/output/svg.js';\nimport { browserAdaptor } from '@mathjax/src/js/adaptors/browserAdaptor.js';\nimport { liteAdaptor } from '@mathjax/src/js/adaptors/liteAdaptor.js';\nimport { RegisterHTMLHandler } from '@mathjax/src/js/handlers/html.js';\n\nimport '@mathjax/src/js/input/tex/base/BaseConfiguration.js';\nimport '@mathjax/src/js/input/tex/ams/AmsConfiguration.js';\nimport '@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js';\nimport '@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js';\nimport '@mathjax/src/js/input/tex/cancel/CancelConfiguration.js';\nimport '@mathjax/src/js/input/tex/color/ColorConfiguration.js';\nimport '@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js';\nimport '@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js';\nimport '@mathjax/src/js/input/tex/bbox/BboxConfiguration.js';\nimport '@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js';\nimport type { DynamicFileList } from '@mathjax/src/js/output/common/FontData.js';\nimport { MathJaxNewcmFont } from '@mathjax/mathjax-newcm-font/js/svg.js';\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/calligraphic.js';\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/double-struck.js';\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/fraktur.js';\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/monospace.js';\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/sans-serif.js';\nimport '@mathjax/mathjax-newcm-font/js/svg/dynamic/script.js';\n\n/**\n * MathJax, set up: the one module that imports it, loaded on demand by\n * `loadMathJax` so a scene with no formula in it never downloads or parses it.\n */\n\n\n/**\n * MathJax needs a DOM to build its output in, and there isn't always one.\n *\n * `browserAdaptor()` reads `window` **as it is constructed**, at module scope —\n * so importing this file at all threw in Node, and a project with one LaTeX\n * scene could not be rendered headlessly no matter which scene was asked for.\n * `liteAdaptor` is MathJax's own DOM-free implementation and produces the same\n * SVG; we only ever read paths back out of it, never attach it to a page.\n */\n// The two adaptors are structurally different (a `LiteElement` tree vs. a real\n// one) and MathJax's generics track that, but nothing here touches an element\n// except through the adaptor's own accessors — so the element type is genuinely\n// opaque to us, and pinning it to either concrete one would be a lie.\nexport const adaptor: any = typeof window === 'undefined' && typeof document === 'undefined'\n ? liteAdaptor()\n : browserAdaptor();\nRegisterHTMLHandler(adaptor);\n\nconst texJax = new TeX({\n packages: [\n 'base', 'ams', 'boldsymbol', 'newcommand',\n 'cancel', 'color', 'mhchem', 'physics',\n 'bbox', 'mathtools',\n ],\n});\n\n/**\n * The font files behind `\\mathcal`, `\\mathbb`, `\\mathfrak`, `\\mathsf`, `\\mathtt`\n * and `\\mathscr`, imported above. MathJax fetches these asynchronously the first\n * time a formula needs one, which a synchronous typesetter cannot wait for, so\n * they are bundled and set up on the font before anything is typeset. The font\n * class is passed explicitly so the one they register on is the one in use.\n */\nconst BUNDLED_FONT_FILES = ['calligraphic', 'double-struck', 'fraktur', 'monospace', 'sans-serif', 'script'];\n\nconst svgJax = new SVG({ fontCache: 'local', fontData: MathJaxNewcmFont });\nconst fontFiles = (MathJaxNewcmFont as unknown as { dynamicFiles: DynamicFileList }).dynamicFiles;\nfor (const file of BUNDLED_FONT_FILES) fontFiles[file].setup(svgJax.font);\n\nconst mjDoc = mathjax.document('', { InputJax: texJax, OutputJax: svgJax });\n\n/** Typeset `text` as display math and hand back MathJax's container, read through {@link adaptor}. */\nexport function convert(text: string): unknown {\n return mjDoc.convert(text, {\n display: true,\n em: 16,\n ex: 8,\n containerWidth: 80 * 16,\n });\n}\n"]}
@@ -41,10 +41,10 @@ export declare const LatexMatrix: import("@motionscript/sdk").Component<"latexMa
41
41
  readonly fill: import("@motionscript/sdk").Type<_Fill, _Fill, false>;
42
42
  readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
43
43
  };
44
+ readonly overlayTo: readonly ["overlay"];
44
45
  readonly fillTo: readonly ["fill"];
45
46
  readonly strokeTo: readonly ["stroke"];
46
47
  readonly shadowTo: readonly ["shadow"];
47
- readonly overlayTo: readonly ["overlay"];
48
48
  }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
49
49
  latex: import("@motionscript/sdk").Type<string, Morphing<string>, false>;
50
50
  /** A list of rows is a whole value: mid-tween it holds both, and the morph draws the way there. */
@@ -92,10 +92,10 @@ export declare const LatexMatrix: import("@motionscript/sdk").Component<"latexMa
92
92
  readonly fill: import("@motionscript/sdk").Type<_Fill, _Fill, false>;
93
93
  readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
94
94
  };
95
+ readonly overlayTo: readonly ["overlay"];
95
96
  readonly fillTo: readonly ["fill"];
96
97
  readonly strokeTo: readonly ["stroke"];
97
98
  readonly shadowTo: readonly ["shadow"];
98
- readonly overlayTo: readonly ["overlay"];
99
99
  }, _Node2D<_Node2DProps>>>>;
100
100
  export type LatexMatrix = NodeOf<typeof LatexMatrix>;
101
101
  //# sourceMappingURL=matrix.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../src/tex/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW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EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;CAC9F,CAAC,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import {\r\n component2d,\r\n Types,\r\n type EntryOptions,\r\n type NodeOf,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Alignment as _Alignment,\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type FlowMode as _FlowMode,\r\n type FlowResolved as _FlowResolved,\r\n type GapSize as _GapSize,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n type Vector2 as _Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { LatexProps } from \"./node\";\r\nimport {\r\n drawFormula, formula, formulaFrame, layoutFormula, lerpMorph, loadFormula, measureFormula, morphOf, TYPESET, TYPESET_COMMANDS,\r\n type Morphing,\r\n} from \"./typeset\";\r\n\r\nexport type MatrixBrackets = \"square\" | \"round\" | \"bar\" | \"double\" | \"curly\" | \"none\";\r\n\r\nexport interface LatexMatrixProps extends LatexProps {\r\n entries: string[][];\r\n brackets: MatrixBrackets;\r\n}\r\n\r\nconst ENVIRONMENT: Record<MatrixBrackets, string> = {\r\n square: \"bmatrix\",\r\n round: \"pmatrix\",\r\n bar: \"vmatrix\",\r\n double: \"Vmatrix\",\r\n curly: \"Bmatrix\",\r\n none: \"matrix\",\r\n};\r\n\r\nconst BRACKETS = [\"square\", \"round\", \"bar\", \"double\", \"curly\", \"none\"] as const;\r\n\r\n/** The LaTeX a matrix of `entries` is typeset from; empty for one with no entries. */\r\nexport function matrixSource(entries: readonly (readonly string[])[], brackets: MatrixBrackets = \"square\"): string {\r\n const rows = entries.filter((row) => Array.isArray(row) && row.length > 0);\r\n if (rows.length === 0) return \"\";\r\n const environment = ENVIRONMENT[brackets] ?? ENVIRONMENT.square;\r\n return `\\\\begin{${environment}} ${rows.map((row) => row.join(\" & \")).join(\" \\\\\\\\ \")} \\\\end{${environment}}`;\r\n}\r\n\r\ninterface MatrixValues {\r\n readonly entries: Morphing<string[][]>;\r\n readonly brackets: Morphing<MatrixBrackets>;\r\n}\r\n\r\n/** The matrix's source now: mid-tween of its entries or its brackets, both ends of it. */\r\nfunction sourceOf(s: MatrixValues): Morphing<string> {\r\n return morphOf([s.entries, s.brackets], ([entries, brackets]) => matrixSource(entries as string[][], brackets as MatrixBrackets));\r\n}\r\n\r\nconst state = {\r\n ...TYPESET,\r\n // Unused by the matrix's own drawing: its entries say what it writes.\r\n latex: Types.custom<string, Morphing<string>, EntryOptions & { readonly kind: \"text\"; readonly multiline: true }>(\"\", {\r\n kind: \"text\", multiline: true, lerp: lerpMorph,\r\n }),\r\n /** A list of rows is a whole value: mid-tween it holds both, and the morph draws the way there. */\r\n entries: Types.custom<string[][], Morphing<string[][]>>([[\"a\", \"b\"], [\"c\", \"d\"]], { lerp: lerpMorph }),\r\n brackets: Types.custom<MatrixBrackets, Morphing<MatrixBrackets>, EntryOptions & { readonly options: typeof BRACKETS }>(\"square\", {\r\n options: BRACKETS, animatable: false, lerp: lerpMorph,\r\n }),\r\n};\r\n\r\n/**\r\n * A matrix typeset from its entries, row by row, inside the brackets it is\r\n * given. Each entry is a piece of LaTeX and is one of the formula's parts, so\r\n * it can be painted, boxed or braced by its own source.\r\n */\r\nexport const LatexMatrix = formula(component2d({\r\n key: \"latexMatrix\",\r\n state,\r\n defaults: { width: \"hug\", height: \"hug\" },\r\n load: (loader) => loadFormula(loader),\r\n commands: {\r\n ...TYPESET_COMMANDS,\r\n morphTo: { args: [\"latex\"] },\r\n /** Change the entries: the ones both matrices write travel, the rest fade. */\r\n entriesTo: { args: [\"entries\"] },\r\n },\r\n measure: (_measurer, s) => measureFormula(formulaFrame(sourceOf(s), s.fontSize, s.partFills), s),\r\n layout: (box, s, children) => layoutFormula(box, s, children),\r\n render: (ctx, s) => drawFormula(ctx, s, formulaFrame(sourceOf(s), s.fontSize, s.partFills)),\r\n}), sourceOf);\r\n\r\nexport type LatexMatrix = NodeOf<typeof LatexMatrix>;\r\n"]}
1
+ {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../src/tex/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAEhI,MAAM,WAAW,CAAC;AASnB,MAAM,WAAW,GAAmC;IAChD,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAEhF,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,OAAuC,EAAE,WAA2B,QAAQ;IACrG,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3E,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,WAAW,GAAG,WAAW,CAAC,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,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;IACrC,QAAQ,EAAE;QACN,GAAG,gBAAgB;QACnB,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;QAC5B,8EAA8E;QAC9E,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;KACnC;IACD,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAChG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;CAC9F,CAAC,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import {\n component2d,\n Types,\n type EntryOptions,\n type NodeOf,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Alignment as _Alignment,\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type FlowMode as _FlowMode,\n type FlowResolved as _FlowResolved,\n type GapSize as _GapSize,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Vector2 as _Vector2,\n} from \"@motionscript/sdk\";\nimport type { LatexProps } from \"./node\";\nimport {\n drawFormula, formula, formulaFrame, layoutFormula, lerpMorph, loadFormula, measureFormula, morphOf, TYPESET, TYPESET_COMMANDS,\n type Morphing,\n} from \"./typeset\";\n\nexport type MatrixBrackets = \"square\" | \"round\" | \"bar\" | \"double\" | \"curly\" | \"none\";\n\nexport interface LatexMatrixProps extends LatexProps {\n entries: string[][];\n brackets: MatrixBrackets;\n}\n\nconst ENVIRONMENT: Record<MatrixBrackets, string> = {\n square: \"bmatrix\",\n round: \"pmatrix\",\n bar: \"vmatrix\",\n double: \"Vmatrix\",\n curly: \"Bmatrix\",\n none: \"matrix\",\n};\n\nconst BRACKETS = [\"square\", \"round\", \"bar\", \"double\", \"curly\", \"none\"] as const;\n\n/** The LaTeX a matrix of `entries` is typeset from; empty for one with no entries. */\nexport function matrixSource(entries: readonly (readonly string[])[], brackets: MatrixBrackets = \"square\"): string {\n const rows = entries.filter((row) => Array.isArray(row) && row.length > 0);\n if (rows.length === 0) return \"\";\n const environment = ENVIRONMENT[brackets] ?? ENVIRONMENT.square;\n return `\\\\begin{${environment}} ${rows.map((row) => row.join(\" & \")).join(\" \\\\\\\\ \")} \\\\end{${environment}}`;\n}\n\ninterface MatrixValues {\n readonly entries: Morphing<string[][]>;\n readonly brackets: Morphing<MatrixBrackets>;\n}\n\n/** The matrix's source now: mid-tween of its entries or its brackets, both ends of it. */\nfunction sourceOf(s: MatrixValues): Morphing<string> {\n return morphOf([s.entries, s.brackets], ([entries, brackets]) => matrixSource(entries as string[][], brackets as MatrixBrackets));\n}\n\nconst state = {\n ...TYPESET,\n // Unused by the matrix's own drawing: its entries say what it writes.\n latex: Types.custom<string, Morphing<string>, EntryOptions & { readonly kind: \"text\"; readonly multiline: true }>(\"\", {\n kind: \"text\", multiline: true, lerp: lerpMorph,\n }),\n /** A list of rows is a whole value: mid-tween it holds both, and the morph draws the way there. */\n entries: Types.custom<string[][], Morphing<string[][]>>([[\"a\", \"b\"], [\"c\", \"d\"]], { lerp: lerpMorph }),\n brackets: Types.custom<MatrixBrackets, Morphing<MatrixBrackets>, EntryOptions & { readonly options: typeof BRACKETS }>(\"square\", {\n options: BRACKETS, animatable: false, lerp: lerpMorph,\n }),\n};\n\n/**\n * A matrix typeset from its entries, row by row, inside the brackets it is\n * given. Each entry is a piece of LaTeX and is one of the formula's parts, so\n * it can be painted, boxed or braced by its own source.\n */\nexport const LatexMatrix = formula(component2d({\n key: \"latexMatrix\",\n state,\n defaults: { width: \"hug\", height: \"hug\" },\n load: (loader) => loadFormula(loader),\n commands: {\n ...TYPESET_COMMANDS,\n morphTo: { args: [\"latex\"] },\n /** Change the entries: the ones both matrices write travel, the rest fade. */\n entriesTo: { args: [\"entries\"] },\n },\n measure: (_measurer, s) => measureFormula(formulaFrame(sourceOf(s), s.fontSize, s.partFills), s),\n layout: (box, s, children) => layoutFormula(box, s, children),\n render: (ctx, s) => drawFormula(ctx, s, formulaFrame(sourceOf(s), s.fontSize, s.partFills)),\n}), sourceOf);\n\nexport type LatexMatrix = NodeOf<typeof LatexMatrix>;\n"]}
@@ -43,10 +43,10 @@ export declare const Latex: import("@motionscript/sdk").Component<"latex", impor
43
43
  readonly fill: import("@motionscript/sdk").Type<_Fill, _Fill, false>;
44
44
  readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
45
45
  };
46
+ readonly overlayTo: readonly ["overlay"];
46
47
  readonly fillTo: readonly ["fill"];
47
48
  readonly strokeTo: readonly ["stroke"];
48
49
  readonly shadowTo: readonly ["shadow"];
49
- readonly overlayTo: readonly ["overlay"];
50
50
  }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
51
51
  /** The formula. Mid-tween it holds both ends, and the glyphs morph from the one into the other. */
52
52
  latex: import("@motionscript/sdk").Type<string, Morphing<string>, false>;
@@ -89,10 +89,10 @@ export declare const Latex: import("@motionscript/sdk").Component<"latex", impor
89
89
  readonly fill: import("@motionscript/sdk").Type<_Fill, _Fill, false>;
90
90
  readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
91
91
  };
92
+ readonly overlayTo: readonly ["overlay"];
92
93
  readonly fillTo: readonly ["fill"];
93
94
  readonly strokeTo: readonly ["stroke"];
94
95
  readonly shadowTo: readonly ["shadow"];
95
- readonly overlayTo: readonly ["overlay"];
96
96
  }, _Node2D<_Node2DProps>>>>;
97
97
  export type Latex = NodeOf<typeof Latex>;
98
98
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/tex/node.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAmBR,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EACH,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAEvH,MAAM,WAAW,CAAC;AAoBnB,MAAM,KAAK,GAAG;IACV,GAAG,OAAO;IACV,mGAAmG;IACnG,KAAK,EAAE,KAAK,CAAC,MAAM,CAA+F,EAAE,EAAE;QAClH,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS;KACjD,CAAC;CACL,CAAC;AAEF,sFAAsF;AACtF,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC;IACrC,GAAG,EAAE,OAAO;IACZ,KAAK;IACL,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;IACzC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;IACrC,QAAQ,EAAE;QACN,GAAG,gBAAgB;QACnB,oFAAoF;QACpF,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;KAC/B;IACD,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5F,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;CAC1F,CAAC,EAAE,CAAC,CAAuC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import {\r\n component2d,\r\n Types,\r\n type EntryOptions,\r\n type InsetsProps,\r\n type NodeOf,\r\n type ShapeProps,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Alignment as _Alignment,\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type FlowMode as _FlowMode,\r\n type FlowResolved as _FlowResolved,\r\n type GapSize as _GapSize,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n type Vector2 as _Vector2,\r\n} from \"@motionscript/sdk\";\r\n// From each module, never the `../engine` barrel: it re-exports this file, so a\r\n// load that enters through the barrel would build this component before the\r\n// modules it spreads exist.\r\nimport type { PartFill } from \"../kit/part-fills\";\r\nimport {\r\n drawFormula, formula, formulaFrame, layoutFormula, lerpMorph, loadFormula, measureFormula, TYPESET, TYPESET_COMMANDS,\r\n type Morphing,\r\n} from \"./typeset\";\r\nimport type { LatexMorphStrategy } from \"./tween\";\r\n\r\nexport interface LatexProps extends ShapeProps {\r\n latex: string;\r\n fontSize: number;\r\n padding: InsetsProps;\r\n partFills: PartFill[];\r\n written: number;\r\n}\r\n\r\n/**\r\n * How a formula morphs, for a node built on the `Typeset` helpers: they take it\r\n * as an argument (`formulaFrame(source, fontSize, partFills, morph)`).\r\n */\r\nexport interface LatexStrategies {\r\n /** How the node morphs between two formulas. Defaults to `defaultLatexMorph`. */\r\n morph?: LatexMorphStrategy;\r\n}\r\n\r\nconst state = {\r\n ...TYPESET,\r\n /** The formula. Mid-tween it holds both ends, and the glyphs morph from the one into the other. */\r\n latex: Types.custom<string, Morphing<string>, EntryOptions & { readonly kind: \"text\"; readonly multiline: true }>(\"\", {\r\n kind: \"text\", multiline: true, lerp: lerpMorph,\r\n }),\r\n};\r\n\r\n/** A LaTeX formula drawn as glyph paths, morphing token by token between formulas. */\r\nexport const Latex = formula(component2d({\r\n key: \"latex\",\r\n state,\r\n defaults: { width: \"hug\", height: \"hug\" },\r\n load: (loader) => loadFormula(loader),\r\n commands: {\r\n ...TYPESET_COMMANDS,\r\n /** Morph this formula into another, its glyphs travelling to their places in it. */\r\n morphTo: { args: [\"latex\"] },\r\n },\r\n measure: (_measurer, s) => measureFormula(formulaFrame(s.latex, s.fontSize, s.partFills), s),\r\n layout: (box, s, children) => layoutFormula(box, s, children),\r\n render: (ctx, s) => drawFormula(ctx, s, formulaFrame(s.latex, s.fontSize, s.partFills)),\r\n}), (s: { readonly latex: Morphing<string> }) => s.latex);\r\n\r\nexport type Latex = NodeOf<typeof Latex>;\r\n"]}
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/tex/node.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAmBR,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EACH,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAEvH,MAAM,WAAW,CAAC;AAoBnB,MAAM,KAAK,GAAG;IACV,GAAG,OAAO;IACV,mGAAmG;IACnG,KAAK,EAAE,KAAK,CAAC,MAAM,CAA+F,EAAE,EAAE;QAClH,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS;KACjD,CAAC;CACL,CAAC;AAEF,sFAAsF;AACtF,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC;IACrC,GAAG,EAAE,OAAO;IACZ,KAAK;IACL,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;IACzC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;IACrC,QAAQ,EAAE;QACN,GAAG,gBAAgB;QACnB,oFAAoF;QACpF,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;KAC/B;IACD,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5F,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;CAC1F,CAAC,EAAE,CAAC,CAAuC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import {\n component2d,\n Types,\n type EntryOptions,\n type InsetsProps,\n type NodeOf,\n type ShapeProps,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Alignment as _Alignment,\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type FlowMode as _FlowMode,\n type FlowResolved as _FlowResolved,\n type GapSize as _GapSize,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Vector2 as _Vector2,\n} from \"@motionscript/sdk\";\n// From each module, never the `../engine` barrel: it re-exports this file, so a\n// load that enters through the barrel would build this component before the\n// modules it spreads exist.\nimport type { PartFill } from \"../kit/part-fills\";\nimport {\n drawFormula, formula, formulaFrame, layoutFormula, lerpMorph, loadFormula, measureFormula, TYPESET, TYPESET_COMMANDS,\n type Morphing,\n} from \"./typeset\";\nimport type { LatexMorphStrategy } from \"./tween\";\n\nexport interface LatexProps extends ShapeProps {\n latex: string;\n fontSize: number;\n padding: InsetsProps;\n partFills: PartFill[];\n written: number;\n}\n\n/**\n * How a formula morphs, for a node built on the `Typeset` helpers: they take it\n * as an argument (`formulaFrame(source, fontSize, partFills, morph)`).\n */\nexport interface LatexStrategies {\n /** How the node morphs between two formulas. Defaults to `defaultLatexMorph`. */\n morph?: LatexMorphStrategy;\n}\n\nconst state = {\n ...TYPESET,\n /** The formula. Mid-tween it holds both ends, and the glyphs morph from the one into the other. */\n latex: Types.custom<string, Morphing<string>, EntryOptions & { readonly kind: \"text\"; readonly multiline: true }>(\"\", {\n kind: \"text\", multiline: true, lerp: lerpMorph,\n }),\n};\n\n/** A LaTeX formula drawn as glyph paths, morphing token by token between formulas. */\nexport const Latex = formula(component2d({\n key: \"latex\",\n state,\n defaults: { width: \"hug\", height: \"hug\" },\n load: (loader) => loadFormula(loader),\n commands: {\n ...TYPESET_COMMANDS,\n /** Morph this formula into another, its glyphs travelling to their places in it. */\n morphTo: { args: [\"latex\"] },\n },\n measure: (_measurer, s) => measureFormula(formulaFrame(s.latex, s.fontSize, s.partFills), s),\n layout: (box, s, children) => layoutFormula(box, s, children),\n render: (ctx, s) => drawFormula(ctx, s, formulaFrame(s.latex, s.fontSize, s.partFills)),\n}), (s: { readonly latex: Morphing<string> }) => s.latex);\n\nexport type Latex = NodeOf<typeof Latex>;\n"]}