figureone 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -12280,7 +12280,7 @@ var FigureElement = /*#__PURE__*/function () {
12280
12280
  this.stop();
12281
12281
  this.notifications.cleanup();
12282
12282
  this.animations.notifications.cleanup();
12283
- this.figure = {};
12283
+ this.figure = null;
12284
12284
  this.parent = null;
12285
12285
  // this.textureAtlases = {};
12286
12286
  }
@@ -14960,7 +14960,14 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
14960
14960
  return _createClass(FigureElementCollection, [{
14961
14961
  key: "cleanup",
14962
14962
  value: function cleanup() {
14963
+ var _this0 = this;
14963
14964
  _superPropGet(FigureElementCollection, "cleanup", this, 3)([]);
14965
+ Object.keys(this.textureAtlases).forEach(function (id) {
14966
+ var ta = _this0.textureAtlases[id];
14967
+ if (ta.notif != null && ta.atlas && ta.atlas.notifications) {
14968
+ ta.atlas.notifications.remove('updated2', ta.notif);
14969
+ }
14970
+ });
14964
14971
  this.textureAtlases = {};
14965
14972
  this.cleanupChildren();
14966
14973
  }
@@ -14968,11 +14975,12 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
14968
14975
  key: "cleanupChildren",
14969
14976
  value: function cleanupChildren() {
14970
14977
  for (var i = 0; i < this.drawOrder.length; i += 1) {
14971
- this.elements[this.drawOrder[i]].cleanup();
14972
- delete this.elements[this.drawOrder[i]];
14973
- this.elements = {};
14974
- this.drawOrder = [];
14978
+ var _name = this.drawOrder[i];
14979
+ this.elements[_name].cleanup();
14980
+ delete this["_".concat(_name)];
14975
14981
  }
14982
+ this.elements = {};
14983
+ this.drawOrder = [];
14976
14984
  }
14977
14985
  }, {
14978
14986
  key: "init",
@@ -15028,8 +15036,8 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15028
15036
  });
15029
15037
  (0,_tools_tools__WEBPACK_IMPORTED_MODULE_9__.duplicateFromTo)(this, collection, ['elements', 'drawOrder', 'parent', 'recorder', 'figure', 'collections', 'pulseDefault.centerOn'].concat(_toConsumableArray(doNotDuplicate), _toConsumableArray(exceptions)));
15030
15038
  for (var i = 0; i < this.drawOrder.length; i += 1) {
15031
- var _name = this.drawOrder[i];
15032
- collection.add(_name, this.elements[_name]._dup());
15039
+ var _name2 = this.drawOrder[i];
15040
+ collection.add(_name2, this.elements[_name2]._dup());
15033
15041
  }
15034
15042
  collection.recorder = this.recorder;
15035
15043
  if (typeof this.pulseDefault !== 'string' && typeof this.pulseDefault !== 'function') {
@@ -15192,7 +15200,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15192
15200
  }, {
15193
15201
  key: "add",
15194
15202
  value: function add(nameOrElementOrElementDefinition) {
15195
- var _this0 = this;
15203
+ var _this1 = this;
15196
15204
  var elementToAdd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
15197
15205
  if (typeof nameOrElementOrElementDefinition === 'string') {
15198
15206
  if (elementToAdd == null) {
@@ -15210,7 +15218,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15210
15218
  var addedElements = [];
15211
15219
  elements.forEach(function (elementDefinition, index) {
15212
15220
  if (elementDefinition instanceof FigureElement) {
15213
- addedElements.push(_this0.add(elementDefinition.name, elementDefinition));
15221
+ addedElements.push(_this1.add(elementDefinition.name, elementDefinition));
15214
15222
  return;
15215
15223
  }
15216
15224
  // Extract the parameters from the layout object
@@ -15248,7 +15256,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15248
15256
  throw new Error("Figure addElement ERROR at index ".concat(index, " in collection ").concat(rootCollection.name, ": missing or incorrect path property in ").concat(elementDefinition));
15249
15257
  }
15250
15258
  var methodPath = methodPathToUse.split('/');
15251
- var method = _this0.getMethod(methodPathToUse);
15259
+ var method = _this1.getMethod(methodPathToUse);
15252
15260
  if (typeof method !== 'function') {
15253
15261
  return;
15254
15262
  }
@@ -15604,7 +15612,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15604
15612
  }, {
15605
15613
  key: "exec",
15606
15614
  value: function exec(execFunctionAndArgs) {
15607
- var _this1 = this;
15615
+ var _this10 = this;
15608
15616
  var elementsToExec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
15609
15617
  if (elementsToExec == null) {
15610
15618
  _superPropGet(FigureElementCollection, "exec", this, 3)([execFunctionAndArgs]);
@@ -15616,7 +15624,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15616
15624
  elementsToExec.forEach(function (elementToExec) {
15617
15625
  var element;
15618
15626
  if (typeof elementToExec === 'string') {
15619
- element = _this1.getElement(elementToExec);
15627
+ element = _this10.getElement(elementToExec);
15620
15628
  } else {
15621
15629
  element = elementToExec;
15622
15630
  }
@@ -15628,7 +15636,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15628
15636
  }, {
15629
15637
  key: "pulse",
15630
15638
  value: function pulse() {
15631
- var _this10 = this;
15639
+ var _this11 = this;
15632
15640
  var optionsOrElementsOrDone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
15633
15641
  var done = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
15634
15642
  if (optionsOrElementsOrDone == null || typeof optionsOrElementsOrDone === 'function' || typeof optionsOrElementsOrDone === 'string') {
@@ -15684,7 +15692,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15684
15692
  elements.forEach(function (elementToPulse) {
15685
15693
  var element;
15686
15694
  if (typeof elementToPulse === 'string') {
15687
- element = _this10.getElement(elementToPulse);
15695
+ element = _this11.getElement(elementToPulse);
15688
15696
  } else {
15689
15697
  element = elementToPulse;
15690
15698
  }
@@ -15802,7 +15810,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15802
15810
  }, {
15803
15811
  key: "getElements",
15804
15812
  value: function getElements(children) {
15805
- var _this11 = this;
15813
+ var _this12 = this;
15806
15814
  // const paths = [];
15807
15815
  if (children == null) {
15808
15816
  return [];
@@ -15831,7 +15839,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15831
15839
  var paths = _processPath(children);
15832
15840
  var elements = [];
15833
15841
  paths.forEach(function (child) {
15834
- var element = _this11.getElement(child);
15842
+ var element = _this12.getElement(child);
15835
15843
  if (element != null) {
15836
15844
  elements.push(element);
15837
15845
  }
@@ -15841,13 +15849,13 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
15841
15849
  }, {
15842
15850
  key: "getShown",
15843
15851
  value: function getShown() {
15844
- var _this12 = this;
15852
+ var _this13 = this;
15845
15853
  if (this.isShown === false) {
15846
15854
  return [];
15847
15855
  }
15848
15856
  var shown = [[this.getPath(), this.uid, this]];
15849
15857
  this.drawOrder.forEach(function (elementName) {
15850
- var element = _this12.elements[elementName];
15858
+ var element = _this13.elements[elementName];
15851
15859
  shown.push.apply(shown, _toConsumableArray(element.getShown()));
15852
15860
  });
15853
15861
  return shown;
@@ -16002,7 +16010,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16002
16010
  }, {
16003
16011
  key: "getBorderPoints",
16004
16012
  value: function getBorderPoints() {
16005
- var _this13 = this;
16013
+ var _this14 = this;
16006
16014
  var border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'border';
16007
16015
  var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
16008
16016
  var shownOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
@@ -16010,13 +16018,13 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16010
16018
  var childrenBorder = [];
16011
16019
  var childrenToUse = children;
16012
16020
  if (childrenToUse == null) {
16013
- childrenToUse = Object.keys(_this13.elements);
16021
+ childrenToUse = Object.keys(_this14.elements);
16014
16022
  }
16015
16023
  if (childrenToUse.length === 0) {
16016
16024
  return [[]];
16017
16025
  }
16018
16026
  childrenToUse.forEach(function (child) {
16019
- var e = _this13.getElement(child);
16027
+ var e = _this14.getElement(child);
16020
16028
  if (e == null || shownOnly && e.isShown === false) {
16021
16029
  return;
16022
16030
  }
@@ -16290,7 +16298,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16290
16298
  }, {
16291
16299
  key: "undim",
16292
16300
  value: function undim() {
16293
- var _this14 = this;
16301
+ var _this15 = this;
16294
16302
  var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
16295
16303
  var elements;
16296
16304
  if (children != null) {
@@ -16298,7 +16306,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16298
16306
  } else {
16299
16307
  this.color = this.defaultColor.slice();
16300
16308
  elements = this.drawOrder.map(function (name) {
16301
- return _this14.elements[name];
16309
+ return _this15.elements[name];
16302
16310
  });
16303
16311
  }
16304
16312
  elements.forEach(function (element) {
@@ -16308,7 +16316,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16308
16316
  }, {
16309
16317
  key: "dim",
16310
16318
  value: function dim() {
16311
- var _this15 = this;
16319
+ var _this16 = this;
16312
16320
  var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
16313
16321
  var elements;
16314
16322
  if (children != null) {
@@ -16316,7 +16324,7 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16316
16324
  } else {
16317
16325
  this.color = this.dimColor.slice();
16318
16326
  elements = this.drawOrder.map(function (name) {
16319
- return _this15.elements[name];
16327
+ return _this16.elements[name];
16320
16328
  });
16321
16329
  }
16322
16330
  elements.forEach(function (element) {
@@ -16384,10 +16392,10 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16384
16392
  }, {
16385
16393
  key: "reorder",
16386
16394
  value: function reorder() {
16387
- var _this16 = this;
16395
+ var _this17 = this;
16388
16396
  this.drawOrder.sort(function (a, b) {
16389
- var elemA = _this16.elements[a];
16390
- var elemB = _this16.elements[b];
16397
+ var elemA = _this17.elements[a];
16398
+ var elemB = _this17.elements[b];
16391
16399
  return elemB.drawPriority - elemA.drawPriority;
16392
16400
  });
16393
16401
  for (var i = 0; i < this.drawOrder.length; i += 1) {
@@ -16530,11 +16538,11 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16530
16538
  }, {
16531
16539
  key: "getAtlases",
16532
16540
  value: function getAtlases() {
16533
- var _this17 = this;
16541
+ var _this18 = this;
16534
16542
  var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
16535
16543
  Object.keys(this.textureAtlases).forEach(function (id) {
16536
- if (_this17.textureAtlases[id].notif != null) {
16537
- _this17.textureAtlases[id].atlas.notifications.remove('updated2', _this17.textureAtlases[id].notif);
16544
+ if (_this18.textureAtlases[id].notif != null) {
16545
+ _this18.textureAtlases[id].atlas.notifications.remove('updated2', _this18.textureAtlases[id].notif);
16538
16546
  }
16539
16547
  });
16540
16548
  this.textureAtlases = {};
@@ -16542,8 +16550,8 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16542
16550
  primitives.forEach(function (e) {
16543
16551
  if (e.atlas != null) {
16544
16552
  var id = e.atlas.font.getTextureID();
16545
- if (_this17.textureAtlases[id] == null) {
16546
- _this17.textureAtlases[id] = {
16553
+ if (_this18.textureAtlases[id] == null) {
16554
+ _this18.textureAtlases[id] = {
16547
16555
  atlas: e.atlas,
16548
16556
  notif: callback ? e.atlas.notifications.add('updated2', callback) : null
16549
16557
  };
@@ -16558,10 +16566,10 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16558
16566
  }, {
16559
16567
  key: "recreateAtlases",
16560
16568
  value: function recreateAtlases() {
16561
- var _this18 = this;
16569
+ var _this19 = this;
16562
16570
  this.getAtlases();
16563
16571
  Object.keys(this.textureAtlases).forEach(function (id) {
16564
- return _this18.textureAtlases[id].atlas.recreate();
16572
+ return _this19.textureAtlases[id].atlas.recreate();
16565
16573
  });
16566
16574
  }
16567
16575
 
@@ -16903,13 +16911,15 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16903
16911
  return;
16904
16912
  }
16905
16913
  var element = this.elements[elementName];
16914
+ // Freeze animations at current values before cleanup
16906
16915
  element.animations.cancelAll('freeze', true);
16907
- element.stop();
16908
- element.parent = null;
16916
+ // cleanup() handles: stop, notifications, drawing objects, children, textureAtlases, figure, parent
16917
+ element.cleanup();
16918
+ // Null out remaining references that cleanup() doesn't handle
16909
16919
  element.animations = null;
16910
16920
  element.move.element = null;
16911
16921
  element.recorder = null;
16912
- element.figure = null;
16922
+ // Remove from parent's data structures
16913
16923
  delete this["_".concat(elementName)];
16914
16924
  delete this.elements[elementName];
16915
16925
  var index = this.drawOrder.indexOf(elementName);
@@ -33025,6 +33035,1125 @@ var Vinculum = /*#__PURE__*/function (_Symbol2) {
33025
33035
  }(_SymbolNew__WEBPACK_IMPORTED_MODULE_1__["default"]);
33026
33036
 
33027
33037
 
33038
+ /***/ },
33039
+
33040
+ /***/ "./src/js/figure/Equation/latexToFigureOne.ts"
33041
+ /*!****************************************************!*\
33042
+ !*** ./src/js/figure/Equation/latexToFigureOne.ts ***!
33043
+ \****************************************************/
33044
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
33045
+
33046
+ __webpack_require__.r(__webpack_exports__);
33047
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33048
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
33049
+ /* harmony export */ latexToFigureOne: () => (/* binding */ latexToFigureOne)
33050
+ /* harmony export */ });
33051
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
33052
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33053
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
33054
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
33055
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
33056
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
33057
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
33058
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
33059
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
33060
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
33061
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
33062
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
33063
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
33064
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
33065
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
33066
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33067
+ /**
33068
+ * LaTeX to FigureOne equation form converter.
33069
+ *
33070
+ * Converts a LaTeX math expression string into FigureOne `elements` and `form`
33071
+ * objects that can be passed directly to `figure.add({ make: 'equation', ... })`.
33072
+ *
33073
+ * Supported LaTeX constructs:
33074
+ * - Fractions: \frac{a}{b}
33075
+ * - Superscripts / subscripts: x^2, x_{ij}, x_i^2
33076
+ * - Square roots: \sqrt{x}, \sqrt[n]{x}
33077
+ * - Integrals: \int, \int_{a}^{b} f(x)\,dx
33078
+ * - Sums / products: \sum_{i=1}^{n}, \prod_{k=0}^{n}
33079
+ * - Brackets: \left( ... \right), \left[ ... \right], \left\{ ... \right\}
33080
+ * - Overline / underline: \overline{x}, \underline{x}
33081
+ * - Accents: \hat{x}, \tilde{x}, \dot{x}, \vec{x}
33082
+ * - Greek letters: \alpha, \Beta, etc.
33083
+ * - Operators: \sin, \cos, \lim, \log, etc.
33084
+ * - Symbols: \cdot, \times, \pm, \infty, \to, \partial, etc.
33085
+ * - Spacing: \, \; \quad \qquad
33086
+ * - Text mode: \text{...}, \mathrm{...}
33087
+ *
33088
+ * @module latexToFigureOne
33089
+ */
33090
+
33091
+ // ---------------------------------------------------------------------------
33092
+ // Greek letter → Unicode mappings
33093
+ // ---------------------------------------------------------------------------
33094
+ var GREEK_LETTERS = {
33095
+ // lowercase
33096
+ alpha: "\u03B1",
33097
+ beta: "\u03B2",
33098
+ gamma: "\u03B3",
33099
+ delta: "\u03B4",
33100
+ epsilon: "\u03B5",
33101
+ varepsilon: "\u03B5",
33102
+ zeta: "\u03B6",
33103
+ eta: "\u03B7",
33104
+ theta: "\u03B8",
33105
+ vartheta: "\u03D1",
33106
+ iota: "\u03B9",
33107
+ kappa: "\u03BA",
33108
+ lambda: "\u03BB",
33109
+ mu: "\u03BC",
33110
+ nu: "\u03BD",
33111
+ xi: "\u03BE",
33112
+ pi: "\u03C0",
33113
+ rho: "\u03C1",
33114
+ sigma: "\u03C3",
33115
+ varsigma: "\u03C2",
33116
+ tau: "\u03C4",
33117
+ upsilon: "\u03C5",
33118
+ phi: "\u03C6",
33119
+ varphi: "\u03D5",
33120
+ chi: "\u03C7",
33121
+ psi: "\u03C8",
33122
+ omega: "\u03C9",
33123
+ // uppercase
33124
+ Gamma: "\u0393",
33125
+ Delta: "\u0394",
33126
+ Theta: "\u0398",
33127
+ Lambda: "\u039B",
33128
+ Xi: "\u039E",
33129
+ Pi: "\u03A0",
33130
+ Sigma: "\u03A3",
33131
+ Upsilon: "\u03A5",
33132
+ Phi: "\u03A6",
33133
+ Psi: "\u03A8",
33134
+ Omega: "\u03A9"
33135
+ };
33136
+
33137
+ // ---------------------------------------------------------------------------
33138
+ // Symbol command → Unicode mappings
33139
+ // ---------------------------------------------------------------------------
33140
+ var SYMBOLS = {
33141
+ // binary operators
33142
+ cdot: "\xB7",
33143
+ times: "\xD7",
33144
+ pm: "\xB1",
33145
+ mp: "\u2213",
33146
+ div: "\xF7",
33147
+ ast: '*',
33148
+ star: "\u2605",
33149
+ circ: "\u2218",
33150
+ // relations
33151
+ leq: "\u2264",
33152
+ le: "\u2264",
33153
+ geq: "\u2265",
33154
+ ge: "\u2265",
33155
+ neq: "\u2260",
33156
+ ne: "\u2260",
33157
+ approx: "\u2248",
33158
+ equiv: "\u2261",
33159
+ sim: "\u223C",
33160
+ simeq: "\u2243",
33161
+ propto: "\u221D",
33162
+ prec: "\u227A",
33163
+ succ: "\u227B",
33164
+ ll: "\u226A",
33165
+ gg: "\u226B",
33166
+ // arrows
33167
+ to: "\u2192",
33168
+ rightarrow: "\u2192",
33169
+ leftarrow: "\u2190",
33170
+ Rightarrow: "\u21D2",
33171
+ Leftarrow: "\u21D0",
33172
+ leftrightarrow: "\u2194",
33173
+ Leftrightarrow: "\u21D4",
33174
+ mapsto: "\u21A6",
33175
+ uparrow: "\u2191",
33176
+ downarrow: "\u2193",
33177
+ // misc math
33178
+ partial: "\u2202",
33179
+ nabla: "\u2207",
33180
+ infty: "\u221E",
33181
+ forall: "\u2200",
33182
+ exists: "\u2203",
33183
+ neg: "\xAC",
33184
+ // set theory
33185
+ "in": "\u2208",
33186
+ notin: "\u2209",
33187
+ subset: "\u2282",
33188
+ supset: "\u2283",
33189
+ subseteq: "\u2286",
33190
+ supseteq: "\u2287",
33191
+ cup: "\u222A",
33192
+ cap: "\u2229",
33193
+ emptyset: "\u2205",
33194
+ varnothing: "\u2205",
33195
+ // dots
33196
+ ldots: "\u2026",
33197
+ cdots: "\u22EF",
33198
+ vdots: "\u22EE",
33199
+ ddots: "\u22F1",
33200
+ dots: "\u2026",
33201
+ // misc
33202
+ ell: "\u2113",
33203
+ hbar: "\u210F",
33204
+ Re: "\u211C",
33205
+ Im: "\u2111",
33206
+ aleph: "\u2135",
33207
+ prime: "\u2032"
33208
+ };
33209
+
33210
+ // ---------------------------------------------------------------------------
33211
+ // Text-mode operators (rendered upright / roman style)
33212
+ // ---------------------------------------------------------------------------
33213
+ var TEXT_OPERATORS = new Set(['sin', 'cos', 'tan', 'cot', 'sec', 'csc', 'arcsin', 'arccos', 'arctan', 'sinh', 'cosh', 'tanh', 'coth', 'log', 'ln', 'exp', 'lim', 'limsup', 'liminf', 'max', 'min', 'sup', 'inf', 'det', 'dim', 'ker', 'deg', 'gcd', 'hom', 'arg', 'Pr']);
33214
+
33215
+ // ---------------------------------------------------------------------------
33216
+ // Binary operator characters (get spaces around them in output)
33217
+ // ---------------------------------------------------------------------------
33218
+ var BINARY_OPS = new Set(['+', '-', '=', '<', '>']);
33219
+ var OPERATOR_NAMES = {
33220
+ '+': 'plus',
33221
+ '-': 'minus',
33222
+ '=': 'equals',
33223
+ '<': 'lt',
33224
+ '>': 'gt'
33225
+ };
33226
+
33227
+ // ---------------------------------------------------------------------------
33228
+ // Tokeniser
33229
+ // ---------------------------------------------------------------------------
33230
+
33231
+ function tokenize(latex) {
33232
+ var tokens = [];
33233
+ var i = 0;
33234
+ while (i < latex.length) {
33235
+ var ch = latex[i];
33236
+
33237
+ // ----- backslash commands -------------------------------------------------
33238
+ if (ch === '\\') {
33239
+ i++;
33240
+ if (i >= latex.length) break;
33241
+ var next = latex[i];
33242
+
33243
+ // Single-character commands \, \; \: \! \ \{ \}
33244
+ if (',;:! '.includes(next)) {
33245
+ tokens.push({
33246
+ type: 'command',
33247
+ value: next
33248
+ });
33249
+ i++;
33250
+ continue;
33251
+ }
33252
+ if (next === '{') {
33253
+ // \{ is an escaped brace — treat as text
33254
+ tokens.push({
33255
+ type: 'command',
33256
+ value: '\\{'
33257
+ });
33258
+ i++;
33259
+ continue;
33260
+ }
33261
+ if (next === '}') {
33262
+ tokens.push({
33263
+ type: 'command',
33264
+ value: '\\}'
33265
+ });
33266
+ i++;
33267
+ continue;
33268
+ }
33269
+ if (next === '\\') {
33270
+ // \\ line break — ignore for equation parsing
33271
+ i++;
33272
+ continue;
33273
+ }
33274
+
33275
+ // Multi-character command: \frac, \alpha, etc.
33276
+ var cmd = '';
33277
+ while (i < latex.length && /[a-zA-Z]/.test(latex[i])) {
33278
+ cmd += latex[i];
33279
+ i++;
33280
+ }
33281
+ if (cmd.length > 0) {
33282
+ tokens.push({
33283
+ type: 'command',
33284
+ value: cmd
33285
+ });
33286
+ }
33287
+ continue;
33288
+ }
33289
+
33290
+ // ----- braces & brackets --------------------------------------------------
33291
+ if (ch === '{') {
33292
+ tokens.push({
33293
+ type: 'lbrace',
33294
+ value: ch
33295
+ });
33296
+ i++;
33297
+ continue;
33298
+ }
33299
+ if (ch === '}') {
33300
+ tokens.push({
33301
+ type: 'rbrace',
33302
+ value: ch
33303
+ });
33304
+ i++;
33305
+ continue;
33306
+ }
33307
+ if (ch === '[') {
33308
+ tokens.push({
33309
+ type: 'lbracket',
33310
+ value: ch
33311
+ });
33312
+ i++;
33313
+ continue;
33314
+ }
33315
+ if (ch === ']') {
33316
+ tokens.push({
33317
+ type: 'rbracket',
33318
+ value: ch
33319
+ });
33320
+ i++;
33321
+ continue;
33322
+ }
33323
+
33324
+ // ----- super / subscript --------------------------------------------------
33325
+ if (ch === '^') {
33326
+ tokens.push({
33327
+ type: 'caret',
33328
+ value: ch
33329
+ });
33330
+ i++;
33331
+ continue;
33332
+ }
33333
+ if (ch === '_') {
33334
+ tokens.push({
33335
+ type: 'underscore',
33336
+ value: ch
33337
+ });
33338
+ i++;
33339
+ continue;
33340
+ }
33341
+
33342
+ // ----- whitespace (ignored in math mode) ----------------------------------
33343
+ if (/\s/.test(ch)) {
33344
+ i++;
33345
+ continue;
33346
+ }
33347
+
33348
+ // ----- everything else is literal text ------------------------------------
33349
+ tokens.push({
33350
+ type: 'text',
33351
+ value: ch
33352
+ });
33353
+ i++;
33354
+ }
33355
+ return tokens;
33356
+ }
33357
+
33358
+ // ---------------------------------------------------------------------------
33359
+ // AST node types
33360
+ // ---------------------------------------------------------------------------
33361
+ // ---------------------------------------------------------------------------
33362
+ // Parser (recursive descent)
33363
+ // ---------------------------------------------------------------------------
33364
+ var Parser = /*#__PURE__*/function () {
33365
+ function Parser(tokens) {
33366
+ _classCallCheck(this, Parser);
33367
+ this.tokens = tokens;
33368
+ this.pos = 0;
33369
+ }
33370
+ return _createClass(Parser, [{
33371
+ key: "peek",
33372
+ value: function peek() {
33373
+ return this.pos < this.tokens.length ? this.tokens[this.pos] : null;
33374
+ }
33375
+ }, {
33376
+ key: "advance",
33377
+ value: function advance() {
33378
+ return this.tokens[this.pos++];
33379
+ }
33380
+ }, {
33381
+ key: "expect",
33382
+ value: function expect(type) {
33383
+ var tok = this.peek();
33384
+ if (!tok || tok.type !== type) {
33385
+ throw new Error("LaTeX parse error: expected ".concat(type, " but got ").concat(tok ? "".concat(tok.type, "(").concat(tok.value, ")") : 'EOF', " at token ").concat(this.pos));
33386
+ }
33387
+ return this.advance();
33388
+ }
33389
+
33390
+ /** Entry point. */
33391
+ }, {
33392
+ key: "parse",
33393
+ value: function parse() {
33394
+ return this.parseSequence();
33395
+ }
33396
+
33397
+ // ---- sequence of items (stops at }, ], \right, or EOF) -------------------
33398
+ }, {
33399
+ key: "parseSequence",
33400
+ value: function parseSequence() {
33401
+ var items = [];
33402
+ while (this.pos < this.tokens.length) {
33403
+ var tok = this.peek();
33404
+ if (!tok) break;
33405
+ // Stop tokens
33406
+ if (tok.type === 'rbrace' || tok.type === 'rbracket') break;
33407
+ if (tok.type === 'command' && tok.value === 'right') break;
33408
+
33409
+ // Large operators consume the rest of the current scope as content
33410
+ if (tok.type === 'command' && (tok.value === 'int' || tok.value === 'sum' || tok.value === 'prod')) {
33411
+ items.push(this.parseLargeOperator());
33412
+ continue;
33413
+ }
33414
+ var item = this.parseItem();
33415
+ if (item) items.push(item);
33416
+ }
33417
+ if (items.length === 0) return {
33418
+ type: 'text',
33419
+ value: ''
33420
+ };
33421
+ if (items.length === 1) return items[0];
33422
+ return {
33423
+ type: 'sequence',
33424
+ children: items
33425
+ };
33426
+ }
33427
+
33428
+ // ---- single item (atom + optional ^/_ ) -----------------------------------
33429
+ }, {
33430
+ key: "parseItem",
33431
+ value: function parseItem() {
33432
+ var atom = this.parseAtom();
33433
+ if (!atom) return null;
33434
+ return this.attachSupSub(atom);
33435
+ }
33436
+ }, {
33437
+ key: "attachSupSub",
33438
+ value: function attachSupSub(base) {
33439
+ var superscript;
33440
+ var subscript;
33441
+
33442
+ // ^ and _ can appear in either order, at most once each
33443
+ for (var i = 0; i < 2; i++) {
33444
+ var tok = this.peek();
33445
+ if (!tok) break;
33446
+ if (tok.type === 'caret' && !superscript) {
33447
+ this.advance();
33448
+ superscript = this.parseAtom();
33449
+ } else if (tok.type === 'underscore' && !subscript) {
33450
+ this.advance();
33451
+ subscript = this.parseAtom();
33452
+ } else {
33453
+ break;
33454
+ }
33455
+ }
33456
+ if (superscript && subscript) return {
33457
+ type: 'supsub',
33458
+ base: base,
33459
+ superscript: superscript,
33460
+ subscript: subscript
33461
+ };
33462
+ if (superscript) return {
33463
+ type: 'sup',
33464
+ base: base,
33465
+ superscript: superscript
33466
+ };
33467
+ if (subscript) return {
33468
+ type: 'sub',
33469
+ base: base,
33470
+ subscript: subscript
33471
+ };
33472
+ return base;
33473
+ }
33474
+
33475
+ // ---- atom (single indivisible piece) --------------------------------------
33476
+ }, {
33477
+ key: "parseAtom",
33478
+ value: function parseAtom() {
33479
+ var tok = this.peek();
33480
+ if (!tok) return null;
33481
+ if (tok.type === 'lbrace') return this.parseGroup();
33482
+ if (tok.type === 'text') {
33483
+ this.advance();
33484
+ return {
33485
+ type: 'text',
33486
+ value: tok.value
33487
+ };
33488
+ }
33489
+ if (tok.type === 'command') return this.parseCommand();
33490
+ return null;
33491
+ }
33492
+ }, {
33493
+ key: "parseGroup",
33494
+ value: function parseGroup() {
33495
+ this.expect('lbrace');
33496
+ var content = this.parseSequence();
33497
+ this.expect('rbrace');
33498
+ return content;
33499
+ }
33500
+
33501
+ // ---- command dispatch -----------------------------------------------------
33502
+ }, {
33503
+ key: "parseCommand",
33504
+ value: function parseCommand() {
33505
+ var tok = this.advance(); // consume command token
33506
+ var cmd = tok.value;
33507
+
33508
+ // ---- structural commands ----
33509
+ if (cmd === 'frac') return this.parseFrac();
33510
+ if (cmd === 'sqrt') return this.parseSqrt();
33511
+ if (cmd === 'left') return this.parseBrackets();
33512
+
33513
+ // ---- accents / decorations ----
33514
+ if (cmd === 'overline' || cmd === 'bar') return {
33515
+ type: 'overline',
33516
+ content: this.parseAtom()
33517
+ };
33518
+ if (cmd === 'underline') return {
33519
+ type: 'underline',
33520
+ content: this.parseAtom()
33521
+ };
33522
+ if (cmd === 'hat' || cmd === 'tilde' || cmd === 'dot' || cmd === 'vec' || cmd === 'ddot' || cmd === 'breve' || cmd === 'check' || cmd === 'acute' || cmd === 'grave') {
33523
+ return {
33524
+ type: 'accent',
33525
+ accent: cmd,
33526
+ content: this.parseAtom()
33527
+ };
33528
+ }
33529
+
33530
+ // ---- text mode ----
33531
+ if (cmd === 'text' || cmd === 'mathrm' || cmd === 'textrm' || cmd === 'textit' || cmd === 'mathit') {
33532
+ return this.parseTextBlock();
33533
+ }
33534
+
33535
+ // ---- spacing ----
33536
+ if (cmd === ',') return {
33537
+ type: 'space',
33538
+ size: 'thin'
33539
+ };
33540
+ if (cmd === ';' || cmd === ':') return {
33541
+ type: 'space',
33542
+ size: 'medium'
33543
+ };
33544
+ if (cmd === '!') return {
33545
+ type: 'space',
33546
+ size: 'neg'
33547
+ };
33548
+ if (cmd === ' ') return {
33549
+ type: 'space',
33550
+ size: 'normal'
33551
+ };
33552
+ if (cmd === 'quad') return {
33553
+ type: 'space',
33554
+ size: 'quad'
33555
+ };
33556
+ if (cmd === 'qquad') return {
33557
+ type: 'space',
33558
+ size: 'qquad'
33559
+ };
33560
+
33561
+ // ---- escaped braces as text ----
33562
+ if (cmd === '\\{') return {
33563
+ type: 'text',
33564
+ value: '{'
33565
+ };
33566
+ if (cmd === '\\}') return {
33567
+ type: 'text',
33568
+ value: '}'
33569
+ };
33570
+
33571
+ // ---- Greek letters ----
33572
+ if (GREEK_LETTERS[cmd]) return {
33573
+ type: 'text',
33574
+ value: GREEK_LETTERS[cmd]
33575
+ };
33576
+
33577
+ // ---- math symbols ----
33578
+ if (SYMBOLS[cmd]) return {
33579
+ type: 'text',
33580
+ value: SYMBOLS[cmd]
33581
+ };
33582
+
33583
+ // ---- text operators ----
33584
+ if (TEXT_OPERATORS.has(cmd)) return {
33585
+ type: 'textOp',
33586
+ name: cmd
33587
+ };
33588
+
33589
+ // ---- unknown command → pass through as text ----
33590
+ return {
33591
+ type: 'text',
33592
+ value: "\\".concat(cmd)
33593
+ };
33594
+ }
33595
+ }, {
33596
+ key: "parseFrac",
33597
+ value: function parseFrac() {
33598
+ var numerator = this.parseAtom();
33599
+ var denominator = this.parseAtom();
33600
+ return {
33601
+ type: 'frac',
33602
+ numerator: numerator,
33603
+ denominator: denominator
33604
+ };
33605
+ }
33606
+ }, {
33607
+ key: "parseSqrt",
33608
+ value: function parseSqrt() {
33609
+ var _this$peek;
33610
+ var index;
33611
+ // optional index: \sqrt[n]{...}
33612
+ if (((_this$peek = this.peek()) === null || _this$peek === void 0 ? void 0 : _this$peek.type) === 'lbracket') {
33613
+ this.advance(); // consume [
33614
+ var items = [];
33615
+ while (this.peek() && this.peek().type !== 'rbracket') {
33616
+ var item = this.parseItem();
33617
+ if (item) items.push(item);
33618
+ }
33619
+ this.expect('rbracket');
33620
+ index = items.length === 1 ? items[0] : {
33621
+ type: 'sequence',
33622
+ children: items
33623
+ };
33624
+ }
33625
+ var content = this.parseAtom();
33626
+ return {
33627
+ type: 'sqrt',
33628
+ content: content,
33629
+ index: index
33630
+ };
33631
+ }
33632
+ }, {
33633
+ key: "parseLargeOperator",
33634
+ value: function parseLargeOperator() {
33635
+ var tok = this.advance(); // \int, \sum, \prod
33636
+ var op = tok.value;
33637
+
33638
+ // Parse optional limits (^ and _ in any order)
33639
+ var from;
33640
+ var to;
33641
+ for (var i = 0; i < 2; i++) {
33642
+ var p = this.peek();
33643
+ if (!p) break;
33644
+ if (p.type === 'underscore' && !from) {
33645
+ this.advance();
33646
+ from = this.parseAtom();
33647
+ } else if (p.type === 'caret' && !to) {
33648
+ this.advance();
33649
+ to = this.parseAtom();
33650
+ } else {
33651
+ break;
33652
+ }
33653
+ }
33654
+
33655
+ // Content is the rest of the current scope
33656
+ var content = this.parseSequence();
33657
+ return {
33658
+ type: 'largeOp',
33659
+ op: op,
33660
+ from: from,
33661
+ to: to,
33662
+ content: content
33663
+ };
33664
+ }
33665
+ }, {
33666
+ key: "parseBrackets",
33667
+ value: function parseBrackets() {
33668
+ var _this$peek2, _this$peek3;
33669
+ // \left has already been consumed. Next token is the delimiter.
33670
+ var leftDelim = this.readDelimiter();
33671
+ var content = this.parseSequence(); // stops at \right
33672
+ // consume \right
33673
+ if (((_this$peek2 = this.peek()) === null || _this$peek2 === void 0 ? void 0 : _this$peek2.type) === 'command' && ((_this$peek3 = this.peek()) === null || _this$peek3 === void 0 ? void 0 : _this$peek3.value) === 'right') {
33674
+ this.advance();
33675
+ }
33676
+ var rightDelim = this.readDelimiter();
33677
+ return {
33678
+ type: 'brac',
33679
+ left: leftDelim,
33680
+ right: rightDelim,
33681
+ content: content
33682
+ };
33683
+ }
33684
+ }, {
33685
+ key: "readDelimiter",
33686
+ value: function readDelimiter() {
33687
+ var tok = this.peek();
33688
+ if (!tok) return '(';
33689
+ if (tok.type === 'text') {
33690
+ this.advance();
33691
+ return tok.value;
33692
+ }
33693
+ if (tok.type === 'command') {
33694
+ this.advance();
33695
+ if (tok.value === '\\{' || tok.value === 'lbrace') return '{';
33696
+ if (tok.value === '\\}' || tok.value === 'rbrace') return '}';
33697
+ if (tok.value === 'langle') return '<';
33698
+ if (tok.value === 'rangle') return '>';
33699
+ if (tok.value === 'vert' || tok.value === '|') return '|';
33700
+ return tok.value;
33701
+ }
33702
+ // [ and ] can be delimiters too
33703
+ if (tok.type === 'lbracket' || tok.type === 'rbracket') {
33704
+ this.advance();
33705
+ return tok.value;
33706
+ }
33707
+ return '(';
33708
+ }
33709
+ }, {
33710
+ key: "parseTextBlock",
33711
+ value: function parseTextBlock() {
33712
+ this.expect('lbrace');
33713
+ var text = '';
33714
+ while (this.peek() && this.peek().type !== 'rbrace') {
33715
+ var t = this.advance();
33716
+ if (t.type === 'command') {
33717
+ text += "\\".concat(t.value);
33718
+ } else {
33719
+ text += t.value;
33720
+ }
33721
+ }
33722
+ this.expect('rbrace');
33723
+ return {
33724
+ type: 'text',
33725
+ value: text
33726
+ };
33727
+ }
33728
+ }]);
33729
+ }(); // ---------------------------------------------------------------------------
33730
+ // Code generator — converts AST to FigureOne elements + form
33731
+ // ---------------------------------------------------------------------------
33732
+ var CodeGenerator = /*#__PURE__*/function () {
33733
+ function CodeGenerator() {
33734
+ _classCallCheck(this, CodeGenerator);
33735
+ /** Accumulated element definitions (symbols, styled text, operators). */
33736
+ _defineProperty(this, "elements", {});
33737
+ /**
33738
+ * Track how many times a given *display text* has been emitted so we can
33739
+ * generate unique element names via the `name_N` convention.
33740
+ */
33741
+ _defineProperty(this, "textUsage", {});
33742
+ /** Counter per symbol type so each gets a unique name. */
33743
+ _defineProperty(this, "symbolCounters", {});
33744
+ }
33745
+ return _createClass(CodeGenerator, [{
33746
+ key: "nextTextName",
33747
+ value:
33748
+ // ---- element name helpers -------------------------------------------------
33749
+
33750
+ /**
33751
+ * Return a unique FigureOne element name for the given display text.
33752
+ * First occurrence of "x" → "x"; second → "x_1"; third → "x_2"; etc.
33753
+ */
33754
+ function nextTextName(text) {
33755
+ var _this$textUsage$text;
33756
+ var count = (_this$textUsage$text = this.textUsage[text]) !== null && _this$textUsage$text !== void 0 ? _this$textUsage$text : 0;
33757
+ this.textUsage[text] = count + 1;
33758
+ if (count === 0) return text;
33759
+ return "".concat(text, "_").concat(count);
33760
+ }
33761
+
33762
+ /** Add a symbol element and return its unique name. */
33763
+ }, {
33764
+ key: "addSymbol",
33765
+ value: function addSymbol(symbolType, extra) {
33766
+ var _this$symbolCounters$, _baseNames$symbolType;
33767
+ var counter = (_this$symbolCounters$ = this.symbolCounters[symbolType]) !== null && _this$symbolCounters$ !== void 0 ? _this$symbolCounters$ : 0;
33768
+ this.symbolCounters[symbolType] = counter + 1;
33769
+
33770
+ // Derive a readable base name from symbol type
33771
+ var baseNames = {
33772
+ vinculum: 'v',
33773
+ "int": 'int_sym',
33774
+ sum: 'sum_sym',
33775
+ prod: 'prod_sym',
33776
+ radical: 'rad',
33777
+ bracket: 'bk',
33778
+ squareBracket: 'sqbk',
33779
+ brace: 'br',
33780
+ angleBracket: 'abk',
33781
+ bar: 'bar_sym'
33782
+ };
33783
+ var base = (_baseNames$symbolType = baseNames[symbolType]) !== null && _baseNames$symbolType !== void 0 ? _baseNames$symbolType : symbolType;
33784
+ var name = counter === 0 ? base : "".concat(base, "_").concat(counter);
33785
+ var def = {
33786
+ symbol: symbolType
33787
+ };
33788
+ if (extra) Object.assign(def, extra);
33789
+ this.elements[name] = def;
33790
+ return name;
33791
+ }
33792
+
33793
+ /**
33794
+ * Register a text element that needs an explicit definition (e.g. styled
33795
+ * operators, multi-char text with special properties).
33796
+ */
33797
+ }, {
33798
+ key: "addTextElement",
33799
+ value: function addTextElement(displayText, props) {
33800
+ var name = this.nextTextName(displayText);
33801
+ this.elements[name] = _objectSpread({
33802
+ text: displayText
33803
+ }, props);
33804
+ return name;
33805
+ }
33806
+
33807
+ /** Register an operator element (e.g. ' + ') and return its name. */
33808
+ }, {
33809
+ key: "addOperator",
33810
+ value: function addOperator(_char) {
33811
+ var _OPERATOR_NAMES$_char, _this$textUsage$baseN;
33812
+ var paddedText = " ".concat(_char, " ");
33813
+ var baseName = (_OPERATOR_NAMES$_char = OPERATOR_NAMES[_char]) !== null && _OPERATOR_NAMES$_char !== void 0 ? _OPERATOR_NAMES$_char : "op_".concat(_char);
33814
+ var count = (_this$textUsage$baseN = this.textUsage[baseName]) !== null && _this$textUsage$baseN !== void 0 ? _this$textUsage$baseN : 0;
33815
+ this.textUsage[baseName] = count + 1;
33816
+ var name = count === 0 ? baseName : "".concat(baseName, "_").concat(count);
33817
+ this.elements[name] = paddedText;
33818
+ return name;
33819
+ }
33820
+
33821
+ // ---- main generation ------------------------------------------------------
33822
+ }, {
33823
+ key: "generate",
33824
+ value: function generate(node) {
33825
+ switch (node.type) {
33826
+ case 'text':
33827
+ return this.genText(node.value);
33828
+ case 'sequence':
33829
+ return this.genSequence(node.children);
33830
+ case 'frac':
33831
+ return this.genFrac(node);
33832
+ case 'sup':
33833
+ return this.genSup(node);
33834
+ case 'sub':
33835
+ return this.genSub(node);
33836
+ case 'supsub':
33837
+ return this.genSupSub(node);
33838
+ case 'sqrt':
33839
+ return this.genSqrt(node);
33840
+ case 'largeOp':
33841
+ return this.genLargeOp(node);
33842
+ case 'brac':
33843
+ return this.genBrac(node);
33844
+ case 'overline':
33845
+ return this.genOverline(node);
33846
+ case 'underline':
33847
+ return this.genUnderline(node);
33848
+ case 'accent':
33849
+ return this.genAccent(node);
33850
+ case 'textOp':
33851
+ return this.genTextOp(node.name);
33852
+ case 'space':
33853
+ return this.genSpace(node.size);
33854
+ default:
33855
+ return '';
33856
+ }
33857
+ }
33858
+ }, {
33859
+ key: "genText",
33860
+ value: function genText(text) {
33861
+ if (text === '') return '';
33862
+ if (BINARY_OPS.has(text)) return this.addOperator(text);
33863
+ return this.nextTextName(text);
33864
+ }
33865
+ }, {
33866
+ key: "genSequence",
33867
+ value: function genSequence(children) {
33868
+ var _this = this;
33869
+ var items = children.map(function (c) {
33870
+ return _this.generate(c);
33871
+ }).filter(function (x) {
33872
+ return x !== '';
33873
+ });
33874
+ if (items.length === 0) return '';
33875
+ if (items.length === 1) return items[0];
33876
+ // Flatten nested arrays one level for cleaner FigureOne forms
33877
+ var flat = [];
33878
+ var _iterator = _createForOfIteratorHelper(items),
33879
+ _step;
33880
+ try {
33881
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
33882
+ var item = _step.value;
33883
+ if (Array.isArray(item)) {
33884
+ flat.push.apply(flat, _toConsumableArray(item));
33885
+ } else {
33886
+ flat.push(item);
33887
+ }
33888
+ }
33889
+ } catch (err) {
33890
+ _iterator.e(err);
33891
+ } finally {
33892
+ _iterator.f();
33893
+ }
33894
+ return flat;
33895
+ }
33896
+ }, {
33897
+ key: "genFrac",
33898
+ value: function genFrac(node) {
33899
+ var vName = this.addSymbol('vinculum');
33900
+ var num = this.generate(node.numerator);
33901
+ var den = this.generate(node.denominator);
33902
+ return {
33903
+ frac: [num, vName, den]
33904
+ };
33905
+ }
33906
+ }, {
33907
+ key: "genSup",
33908
+ value: function genSup(node) {
33909
+ return {
33910
+ sup: [this.generate(node.base), this.generate(node.superscript)]
33911
+ };
33912
+ }
33913
+ }, {
33914
+ key: "genSub",
33915
+ value: function genSub(node) {
33916
+ return {
33917
+ sub: [this.generate(node.base), this.generate(node.subscript)]
33918
+ };
33919
+ }
33920
+ }, {
33921
+ key: "genSupSub",
33922
+ value: function genSupSub(node) {
33923
+ return {
33924
+ supSub: [this.generate(node.base), this.generate(node.superscript), this.generate(node.subscript)]
33925
+ };
33926
+ }
33927
+ }, {
33928
+ key: "genSqrt",
33929
+ value: function genSqrt(node) {
33930
+ var radName = this.addSymbol('radical');
33931
+ var content = this.generate(node.content);
33932
+ if (node.index) {
33933
+ var idx = this.generate(node.index);
33934
+ return {
33935
+ root: {
33936
+ symbol: radName,
33937
+ content: content,
33938
+ root: idx
33939
+ }
33940
+ };
33941
+ }
33942
+ return {
33943
+ root: [radName, content]
33944
+ };
33945
+ }
33946
+ }, {
33947
+ key: "genLargeOp",
33948
+ value: function genLargeOp(node) {
33949
+ var content = this.generate(node.content);
33950
+ var from = node.from ? this.generate(node.from) : undefined;
33951
+ var to = node.to ? this.generate(node.to) : undefined;
33952
+ if (node.op === 'int') {
33953
+ var _symName = this.addSymbol('int');
33954
+ var _def = {
33955
+ symbol: _symName,
33956
+ content: content
33957
+ };
33958
+ if (from !== undefined) _def.from = from;
33959
+ if (to !== undefined) _def.to = to;
33960
+ return {
33961
+ "int": _def
33962
+ };
33963
+ }
33964
+
33965
+ // sum and prod
33966
+ var symType = node.op === 'sum' ? 'sum' : 'prod';
33967
+ var fnName = node.op === 'sum' ? 'sumOf' : 'prodOf';
33968
+ var symName = this.addSymbol(symType);
33969
+ var def = {
33970
+ symbol: symName,
33971
+ content: content
33972
+ };
33973
+ if (from !== undefined) def.from = from;
33974
+ if (to !== undefined) def.to = to;
33975
+ return _defineProperty({}, fnName, def);
33976
+ }
33977
+ }, {
33978
+ key: "delimiterToSymbol",
33979
+ value: function delimiterToSymbol(delim) {
33980
+ var isLeft = '(<[{'.includes(delim) || delim === '|';
33981
+ var side = isLeft ? 'left' : 'right';
33982
+ switch (delim) {
33983
+ case '(':
33984
+ case ')':
33985
+ return {
33986
+ type: 'bracket',
33987
+ side: side
33988
+ };
33989
+ case '[':
33990
+ case ']':
33991
+ return {
33992
+ type: 'squareBracket',
33993
+ side: side
33994
+ };
33995
+ case '{':
33996
+ case '}':
33997
+ return {
33998
+ type: 'brace',
33999
+ side: side
34000
+ };
34001
+ case '<':
34002
+ return {
34003
+ type: 'angleBracket',
34004
+ side: 'left'
34005
+ };
34006
+ case '>':
34007
+ return {
34008
+ type: 'angleBracket',
34009
+ side: 'right'
34010
+ };
34011
+ case '|':
34012
+ return {
34013
+ type: 'bar',
34014
+ side: side
34015
+ };
34016
+ case '.':
34017
+ return {
34018
+ type: 'bracket',
34019
+ side: side
34020
+ };
34021
+ // invisible delimiter
34022
+ default:
34023
+ return {
34024
+ type: 'bracket',
34025
+ side: side
34026
+ };
34027
+ }
34028
+ }
34029
+ }, {
34030
+ key: "genBrac",
34031
+ value: function genBrac(node) {
34032
+ var leftInfo = this.delimiterToSymbol(node.left);
34033
+ var rightInfo = this.delimiterToSymbol(node.right);
34034
+ var lbName = this.addSymbol(leftInfo.type, {
34035
+ side: 'left'
34036
+ });
34037
+ var rbName = this.addSymbol(rightInfo.type, {
34038
+ side: 'right'
34039
+ });
34040
+ var content = this.generate(node.content);
34041
+ return {
34042
+ brac: [lbName, content, rbName]
34043
+ };
34044
+ }
34045
+ }, {
34046
+ key: "genOverline",
34047
+ value: function genOverline(node) {
34048
+ var barName = this.addSymbol('bar', {
34049
+ side: 'top'
34050
+ });
34051
+ var content = this.generate(node.content);
34052
+ return {
34053
+ bar: {
34054
+ content: content,
34055
+ symbol: barName,
34056
+ side: 'top'
34057
+ }
34058
+ };
34059
+ }
34060
+ }, {
34061
+ key: "genUnderline",
34062
+ value: function genUnderline(node) {
34063
+ var barName = this.addSymbol('bar', {
34064
+ side: 'bottom'
34065
+ });
34066
+ var content = this.generate(node.content);
34067
+ return {
34068
+ bar: {
34069
+ content: content,
34070
+ symbol: barName,
34071
+ side: 'bottom'
34072
+ }
34073
+ };
34074
+ }
34075
+ }, {
34076
+ key: "genAccent",
34077
+ value: function genAccent(node) {
34078
+ var _accentChars$node$acc;
34079
+ var content = this.generate(node.content);
34080
+ var accentChars = {
34081
+ hat: "\u0302",
34082
+ tilde: "\u0303",
34083
+ dot: "\u0307",
34084
+ ddot: "\u0308",
34085
+ vec: "\u2192",
34086
+ breve: "\u0306",
34087
+ check: "\u030C",
34088
+ acute: "\u0301",
34089
+ grave: "\u0300"
34090
+ };
34091
+ var accentChar = (_accentChars$node$acc = accentChars[node.accent]) !== null && _accentChars$node$acc !== void 0 ? _accentChars$node$acc : '^';
34092
+ var commentName = this.nextTextName(accentChar);
34093
+ return {
34094
+ topComment: {
34095
+ content: content,
34096
+ comment: commentName,
34097
+ scale: 0.6
34098
+ }
34099
+ };
34100
+ }
34101
+ }, {
34102
+ key: "genTextOp",
34103
+ value: function genTextOp(name) {
34104
+ return this.addTextElement(name, {
34105
+ style: 'normal'
34106
+ });
34107
+ }
34108
+ }, {
34109
+ key: "genSpace",
34110
+ value: function genSpace(size) {
34111
+ switch (size) {
34112
+ case 'thin':
34113
+ return ' ';
34114
+ case 'medium':
34115
+ return ' ';
34116
+ case 'normal':
34117
+ return ' ';
34118
+ case 'quad':
34119
+ return ' ';
34120
+ case 'qquad':
34121
+ return ' ';
34122
+ case 'neg':
34123
+ return '';
34124
+ default:
34125
+ return ' ';
34126
+ }
34127
+ }
34128
+ }]);
34129
+ }(); // ---------------------------------------------------------------------------
34130
+ // Public API
34131
+ // ---------------------------------------------------------------------------
34132
+ /** Result of converting a LaTeX expression to FigureOne form. */
34133
+ /**
34134
+ * Convert a LaTeX math expression into a FigureOne equation form.
34135
+ *
34136
+ * @example
34137
+ * const { elements, form } = Fig.latexToFigureOne('\\frac{a}{b} = c');
34138
+ * figure.add({
34139
+ * make: 'equation',
34140
+ * elements,
34141
+ * forms: { base: form },
34142
+ * });
34143
+ */
34144
+ function latexToFigureOne(latex) {
34145
+ var tokens = tokenize(latex);
34146
+ var parser = new Parser(tokens);
34147
+ var ast = parser.parse();
34148
+ var generator = new CodeGenerator();
34149
+ var form = generator.generate(ast);
34150
+ return {
34151
+ elements: generator.elements,
34152
+ form: form
34153
+ };
34154
+ }
34155
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (latexToFigureOne);
34156
+
33028
34157
  /***/ },
33029
34158
 
33030
34159
  /***/ "./src/js/figure/Figure.ts"
@@ -33410,8 +34539,10 @@ var Figure = /*#__PURE__*/function () {
33410
34539
  this.backgroundColor = optionsToUse.backgroundColor;
33411
34540
  var webglLow = new _webgl_webgl__WEBPACK_IMPORTED_MODULE_0__["default"](this.canvasLow, this.backgroundColor, optionsToUse.antialias, optionsToUse.atlasScale);
33412
34541
  this.webglLow = webglLow;
33413
- this.canvasLow.addEventListener('webglcontextlost', this.contextLost.bind(this), false);
33414
- this.canvasLow.addEventListener('webglcontextrestored', this.contextRestored.bind(this), false);
34542
+ this._boundContextLost = this.contextLost.bind(this);
34543
+ this._boundContextRestored = this.contextRestored.bind(this);
34544
+ this.canvasLow.addEventListener('webglcontextlost', this._boundContextLost, false);
34545
+ this.canvasLow.addEventListener('webglcontextrestored', this._boundContextRestored, false);
33415
34546
  // TODO in future, if still using canvasOffScreen then need to have it
33416
34547
  // handle context lost and restored events
33417
34548
  if (this.canvasOffscreen) {
@@ -33614,9 +34745,12 @@ var Figure = /*#__PURE__*/function () {
33614
34745
  // this.updateFontSize = optionsToUse.updateFontSize;
33615
34746
 
33616
34747
  this.focused = true;
33617
- window.addEventListener('resize', this.resize.bind(this));
33618
- window.addEventListener('focus', this.focusGained.bind(this));
33619
- window.addEventListener('blur', this.focusLost.bind(this));
34748
+ this._boundResize = this.resize.bind(this);
34749
+ this._boundFocusGained = this.focusGained.bind(this);
34750
+ this._boundFocusLost = this.focusLost.bind(this);
34751
+ window.addEventListener('resize', this._boundResize);
34752
+ window.addEventListener('focus', this._boundFocusGained);
34753
+ window.addEventListener('blur', this._boundFocusLost);
33620
34754
  // window.addEventListener('resize', this.resize.bind(this));
33621
34755
  this.sizeHtmlText();
33622
34756
  this.isTouchDevice = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_7__.isTouchDevice)();
@@ -34317,7 +35451,33 @@ var Figure = /*#__PURE__*/function () {
34317
35451
  }, {
34318
35452
  key: "destroy",
34319
35453
  value: function destroy() {
35454
+ // Remove gesture listeners (canvas + window)
34320
35455
  this.gesture.destroy();
35456
+
35457
+ // Remove window listeners
35458
+ window.removeEventListener('resize', this._boundResize);
35459
+ window.removeEventListener('focus', this._boundFocusGained);
35460
+ window.removeEventListener('blur', this._boundFocusLost);
35461
+
35462
+ // Remove canvas listeners (only set when webgl !== 'manual')
35463
+ if (this.canvasLow && this._boundContextLost) {
35464
+ this.canvasLow.removeEventListener('webglcontextlost', this._boundContextLost, false);
35465
+ this.canvasLow.removeEventListener('webglcontextrestored', this._boundContextRestored, false);
35466
+ }
35467
+
35468
+ // Clean up all elements recursively (notifications, drawing objects, children)
35469
+ this.elements.cleanup();
35470
+ this.elements = null;
35471
+
35472
+ // Clean up WebGL resources (programs, textures, atlases, framebuffers)
35473
+ if (this.webglLow) {
35474
+ this.webglLow.cleanup();
35475
+ }
35476
+ if (this.webglOffscreen) {
35477
+ this.webglOffscreen.cleanup();
35478
+ }
35479
+
35480
+ // Release the WebGL context
34321
35481
  this.loseContext();
34322
35482
  }
34323
35483
 
@@ -51635,11 +52795,26 @@ var FigureElementPrimitiveGesture = /*#__PURE__*/function (_FigureElementPrimiti
51635
52795
  this.setMovable();
51636
52796
  }
51637
52797
  this.cleanupIDs();
51638
- this.notificationIDs.push(this.figure.notifications.add('gestureWheel', this.wheelHandler.bind(this)));
51639
- this.notificationIDs.push(this.figure.notifications.add('mousePosition', this.mousePosition.bind(this)));
51640
- this.notificationIDs.push(this.figure.notifications.add('gestureStartPinch', this.startPinchZoom.bind(this)));
51641
- this.notificationIDs.push(this.figure.notifications.add('gesturePinching', this.pinchZoom.bind(this)));
51642
- this.notificationIDs.push(this.figure.notifications.add('gesturePinchEnd', this.endPinchZoom.bind(this)));
52798
+ this.notificationIDs.push({
52799
+ event: 'gestureWheel',
52800
+ id: this.figure.notifications.add('gestureWheel', this.wheelHandler.bind(this))
52801
+ });
52802
+ this.notificationIDs.push({
52803
+ event: 'mousePosition',
52804
+ id: this.figure.notifications.add('mousePosition', this.mousePosition.bind(this))
52805
+ });
52806
+ this.notificationIDs.push({
52807
+ event: 'gestureStartPinch',
52808
+ id: this.figure.notifications.add('gestureStartPinch', this.startPinchZoom.bind(this))
52809
+ });
52810
+ this.notificationIDs.push({
52811
+ event: 'gesturePinching',
52812
+ id: this.figure.notifications.add('gesturePinching', this.pinchZoom.bind(this))
52813
+ });
52814
+ this.notificationIDs.push({
52815
+ event: 'gesturePinchEnd',
52816
+ id: this.figure.notifications.add('gesturePinchEnd', this.endPinchZoom.bind(this))
52817
+ });
51643
52818
  this.reset();
51644
52819
  this.notifications.publish('setFigure');
51645
52820
  }
@@ -51647,11 +52822,21 @@ var FigureElementPrimitiveGesture = /*#__PURE__*/function (_FigureElementPrimiti
51647
52822
  key: "cleanupIDs",
51648
52823
  value: function cleanupIDs() {
51649
52824
  var _this2 = this;
51650
- this.notificationIDs.forEach(function (id) {
51651
- return _this2.figure.notifications.remove(id);
51652
- });
52825
+ if (this.figure && this.figure.notifications) {
52826
+ this.notificationIDs.forEach(function (_ref) {
52827
+ var event = _ref.event,
52828
+ id = _ref.id;
52829
+ _this2.figure.notifications.remove(event, id);
52830
+ });
52831
+ }
51653
52832
  this.notificationIDs = [];
51654
52833
  }
52834
+ }, {
52835
+ key: "cleanup",
52836
+ value: function cleanup() {
52837
+ this.cleanupIDs();
52838
+ _superPropGet(FigureElementPrimitiveGesture, "cleanup", this, 3)([]);
52839
+ }
51655
52840
  }]);
51656
52841
  }(_Element__WEBPACK_IMPORTED_MODULE_0__.FigureElementPrimitive); // Let's say we have a rectangular scene of width 4 and height 2 from [-2, -1]
51657
52842
  // to [2, 1].
@@ -55190,17 +56375,22 @@ var Gesture = /*#__PURE__*/function () {
55190
56375
  return _createClass(Gesture, [{
55191
56376
  key: "addEvent",
55192
56377
  value: function addEvent(event, method, flag) {
55193
- this.figure.gestureCanvas.addEventListener(event, method.bind(this), flag);
56378
+ this.figure.gestureCanvas.addEventListener(event, method, flag);
55194
56379
  }
55195
56380
  }, {
55196
56381
  key: "addWindowEvent",
55197
56382
  value: function addWindowEvent(event, method, flag) {
55198
- window.addEventListener(event, method.bind(this), flag);
56383
+ window.addEventListener(event, method, flag);
55199
56384
  }
55200
56385
  }, {
55201
56386
  key: "removeEvent",
55202
56387
  value: function removeEvent(event, method, flag) {
55203
- this.figure.gestureCanvas.removeEventListener(event, method.bind(this), flag);
56388
+ this.figure.gestureCanvas.removeEventListener(event, method, flag);
56389
+ }
56390
+ }, {
56391
+ key: "removeWindowEvent",
56392
+ value: function removeWindowEvent(event, method, flag) {
56393
+ window.removeEventListener(event, method, flag);
55204
56394
  }
55205
56395
  }, {
55206
56396
  key: "startHandler",
@@ -55293,10 +56483,10 @@ var Gesture = /*#__PURE__*/function () {
55293
56483
  key: "destroy",
55294
56484
  value: function destroy() {
55295
56485
  this.removeEvent('mousedown', this.binds.mouseDownHandler, false);
55296
- this.removeEvent('mouseup', this.binds.mouseUpHandler, false);
56486
+ this.removeWindowEvent('mouseup', this.binds.mouseUpHandler, false);
55297
56487
  this.removeEvent('mousemove', this.binds.mouseMoveHandler, false);
55298
56488
  this.removeEvent('touchstart', this.binds.touchStartHandler, false);
55299
- this.removeEvent('touchend', this.binds.touchEndHandler, false);
56489
+ this.removeWindowEvent('touchend', this.binds.touchEndHandler, false);
55300
56490
  this.removeEvent('touchmove', this.binds.touchMoveHandler, false);
55301
56491
  this.removeEvent('wheel', this.binds.wheelHandler, false);
55302
56492
  }
@@ -63993,8 +65183,8 @@ var TargetTexture = /*#__PURE__*/function () {
63993
65183
  gl.bindRenderbuffer(gl.RENDERBUFFER, this.depthBuffer);
63994
65184
 
63995
65185
  // Create and bind the framebuffer
63996
- var fb = gl.createFramebuffer();
63997
- gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
65186
+ this.fb = gl.createFramebuffer();
65187
+ gl.bindFramebuffer(gl.FRAMEBUFFER, this.fb);
63998
65188
 
63999
65189
  // attach the texture as the first color attachment
64000
65190
  var attachmentPoint = gl.COLOR_ATTACHMENT0;
@@ -64022,6 +65212,23 @@ var TargetTexture = /*#__PURE__*/function () {
64022
65212
  gl.bindRenderbuffer(gl.RENDERBUFFER, this.depthBuffer);
64023
65213
  gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
64024
65214
  }
65215
+ }, {
65216
+ key: "cleanup",
65217
+ value: function cleanup() {
65218
+ var gl = this.webgl.gl;
65219
+ if (this.target) {
65220
+ gl.deleteTexture(this.target);
65221
+ this.target = null;
65222
+ }
65223
+ if (this.depthBuffer) {
65224
+ gl.deleteRenderbuffer(this.depthBuffer);
65225
+ this.depthBuffer = null;
65226
+ }
65227
+ if (this.fb) {
65228
+ gl.deleteFramebuffer(this.fb);
65229
+ this.fb = null;
65230
+ }
65231
+ }
64025
65232
  }]);
64026
65233
  }();
64027
65234
 
@@ -64172,7 +65379,12 @@ function createProgramFromScripts(gl, vertexShaderSource, fragmentShaderSource)
64172
65379
 
64173
65380
  // Link the two shaders into a program
64174
65381
  if (vertexShader && fragmentShader) {
64175
- return createProgram(gl, vertexShader, fragmentShader);
65382
+ var program = createProgram(gl, vertexShader, fragmentShader);
65383
+ // Shaders can be safely deleted after linking — they're flagged for
65384
+ // deletion and freed when the program is deleted
65385
+ gl.deleteShader(vertexShader);
65386
+ gl.deleteShader(fragmentShader);
65387
+ return program;
64176
65388
  }
64177
65389
  return null;
64178
65390
  }
@@ -64388,6 +65600,32 @@ var WebGLInstance = /*#__PURE__*/function () {
64388
65600
  _this3.textures[id].glTexture = null;
64389
65601
  });
64390
65602
  }
65603
+ }, {
65604
+ key: "cleanup",
65605
+ value: function cleanup() {
65606
+ var _this4 = this;
65607
+ var gl = this.gl;
65608
+ // Delete all programs
65609
+ this.programs.forEach(function (p) {
65610
+ if (p.program) {
65611
+ gl.deleteProgram(p.program);
65612
+ }
65613
+ });
65614
+ this.programs = [];
65615
+ // Delete all textures
65616
+ Object.keys(this.textures).forEach(function (id) {
65617
+ _this4.deleteTexture(id);
65618
+ });
65619
+ this.textures = {};
65620
+ // Clean up atlases
65621
+ this.atlases = {};
65622
+ // Clean up target texture
65623
+ if (this.targetTexture) {
65624
+ this.targetTexture.cleanup();
65625
+ this.targetTexture = null;
65626
+ }
65627
+ this.lastUsedProgram = null;
65628
+ }
64391
65629
  }, {
64392
65630
  key: "setTextureData",
64393
65631
  value: function setTextureData(id, image) {
@@ -64472,18 +65710,18 @@ var WebGLInstance = /*#__PURE__*/function () {
64472
65710
  }, {
64473
65711
  key: "onLoad",
64474
65712
  value: function onLoad(id) {
64475
- var _this4 = this;
65713
+ var _this5 = this;
64476
65714
  this.textures[id].onLoad.forEach(function (f) {
64477
- return _this4.fnMap.exec(f, true, _this4.textures[id].index);
65715
+ return _this5.fnMap.exec(f, true, _this5.textures[id].index);
64478
65716
  });
64479
65717
  this.textures[id].onLoad = [];
64480
65718
  }
64481
65719
  }, {
64482
65720
  key: "cancel",
64483
65721
  value: function cancel(id) {
64484
- var _this5 = this;
65722
+ var _this6 = this;
64485
65723
  this.textures[id].onLoad.forEach(function (f) {
64486
- return _this5.fnMap.exec(f, false, _this5.textures[id].index);
65724
+ return _this6.fnMap.exec(f, false, _this6.textures[id].index);
64487
65725
  });
64488
65726
  this.textures[id].onLoad = [];
64489
65727
  }
@@ -64559,6 +65797,7 @@ var WebGLInstance = /*#__PURE__*/function () {
64559
65797
  this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
64560
65798
  this.gl.enable(this.gl.BLEND);
64561
65799
  this.targetTexture = new _target__WEBPACK_IMPORTED_MODULE_1__["default"](this);
65800
+ this.targetTexture.setFramebufferAttachmentSizes(this.gl.canvas.width, this.gl.canvas.height);
64562
65801
  }
64563
65802
  }, {
64564
65803
  key: "resize",
@@ -79091,8 +80330,9 @@ __webpack_require__.r(__webpack_exports__);
79091
80330
  /* harmony import */ var _js_figure_FigureCollections_EquationLabel__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./js/figure/FigureCollections/EquationLabel */ "./src/js/figure/FigureCollections/EquationLabel.ts");
79092
80331
  /* harmony import */ var _js_figure_Equation_Equation__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./js/figure/Equation/Equation */ "./src/js/figure/Equation/Equation.ts");
79093
80332
  /* harmony import */ var _js_figure_Equation_EquationForm__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./js/figure/Equation/EquationForm */ "./src/js/figure/Equation/EquationForm.ts");
79094
- /* harmony import */ var _js_figure_SlideNavigator__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./js/figure/SlideNavigator */ "./src/js/figure/SlideNavigator.ts");
79095
- /* harmony import */ var _js_figure_Animation_Animation__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./js/figure/Animation/Animation */ "./src/js/figure/Animation/Animation.ts");
80333
+ /* harmony import */ var _js_figure_Equation_latexToFigureOne__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./js/figure/Equation/latexToFigureOne */ "./src/js/figure/Equation/latexToFigureOne.ts");
80334
+ /* harmony import */ var _js_figure_SlideNavigator__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./js/figure/SlideNavigator */ "./src/js/figure/SlideNavigator.ts");
80335
+ /* harmony import */ var _js_figure_Animation_Animation__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./js/figure/Animation/Animation */ "./src/js/figure/Animation/Animation.ts");
79096
80336
 
79097
80337
 
79098
80338
 
@@ -79126,6 +80366,7 @@ __webpack_require__.r(__webpack_exports__);
79126
80366
 
79127
80367
 
79128
80368
 
80369
+
79129
80370
  // This helps the docgen find the types file
79130
80371
  // eslint-disable-next-line
79131
80372
 
@@ -79158,14 +80399,14 @@ var tools = {
79158
80399
  */
79159
80400
 
79160
80401
  var Fig = {
79161
- version: "1.0.7",
79162
- gitHash: "9c0a1c7fa",
80402
+ version: "1.0.8",
80403
+ gitHash: "48b41c1bd",
79163
80404
  tools: tools,
79164
80405
  Figure: _js_figure_Figure__WEBPACK_IMPORTED_MODULE_5__["default"],
79165
80406
  Recorder: _js_figure_Recorder_Recorder__WEBPACK_IMPORTED_MODULE_7__.Recorder,
79166
80407
  FunctionMap: _js_tools_FunctionMap__WEBPACK_IMPORTED_MODULE_8__.FunctionMap,
79167
80408
  GlobalFunctionMap: _js_tools_FunctionMap__WEBPACK_IMPORTED_MODULE_8__.GlobalFunctionMap,
79168
- SlideNavigator: _js_figure_SlideNavigator__WEBPACK_IMPORTED_MODULE_29__["default"],
80409
+ SlideNavigator: _js_figure_SlideNavigator__WEBPACK_IMPORTED_MODULE_30__["default"],
79169
80410
  //
79170
80411
  FigureElement: _js_figure_Element__WEBPACK_IMPORTED_MODULE_14__.FigureElement,
79171
80412
  FigureElementCollection: _js_figure_Element__WEBPACK_IMPORTED_MODULE_14__.FigureElementCollection,
@@ -79188,8 +80429,9 @@ var Fig = {
79188
80429
  Equation: _js_figure_Equation_Equation__WEBPACK_IMPORTED_MODULE_27__.Equation,
79189
80430
  //
79190
80431
  HTMLEquation: _js_figure_Equation_HTMLEquation__WEBPACK_IMPORTED_MODULE_22__["default"],
80432
+ latexToFigureOne: _js_figure_Equation_latexToFigureOne__WEBPACK_IMPORTED_MODULE_29__.latexToFigureOne,
79191
80433
  //
79192
- Animation: _js_figure_Animation_Animation__WEBPACK_IMPORTED_MODULE_30__,
80434
+ Animation: _js_figure_Animation_Animation__WEBPACK_IMPORTED_MODULE_31__,
79193
80435
  //
79194
80436
  Scene: _js_tools_geometry_scene__WEBPACK_IMPORTED_MODULE_15__["default"],
79195
80437
  Point: _js_tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point,