UNPKG

react-native-mathjax-html-to-svg

Version:

React Native component to display mathematics in html using MathJax. Uses [MathJax](https://github.com/mathjax/)

100 lines 3.68 kB
"use strict"; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractFactory = void 0; var AbstractFactory = (function () { function AbstractFactory(nodes) { var e_1, _a; if (nodes === void 0) { nodes = null; } this.defaultKind = 'unknown'; this.nodeMap = new Map(); this.node = {}; if (nodes === null) { nodes = this.constructor.defaultNodes; } try { for (var _b = __values(Object.keys(nodes)), _c = _b.next(); !_c.done; _c = _b.next()) { var kind = _c.value; this.setNodeClass(kind, nodes[kind]); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } } AbstractFactory.prototype.create = function (kind) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } return (this.node[kind] || this.node[this.defaultKind]).apply(void 0, __spreadArray([], __read(args), false)); }; AbstractFactory.prototype.setNodeClass = function (kind, nodeClass) { this.nodeMap.set(kind, nodeClass); var THIS = this; var KIND = this.nodeMap.get(kind); this.node[kind] = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return new (KIND.bind.apply(KIND, __spreadArray([void 0, THIS], __read(args), false)))(); }; }; AbstractFactory.prototype.getNodeClass = function (kind) { return this.nodeMap.get(kind); }; AbstractFactory.prototype.deleteNodeClass = function (kind) { this.nodeMap.delete(kind); delete this.node[kind]; }; AbstractFactory.prototype.nodeIsKind = function (node, kind) { return (node instanceof this.getNodeClass(kind)); }; AbstractFactory.prototype.getKinds = function () { return Array.from(this.nodeMap.keys()); }; AbstractFactory.defaultNodes = {}; return AbstractFactory; }()); exports.AbstractFactory = AbstractFactory; //# sourceMappingURL=Factory.js.map