mathjax
Version:
Beautiful and accessible math in all browsers. MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all browsers. This package includes the packaged components (install mathjax-full to get the source
1 lines • 10.8 kB
JavaScript
(()=>{"use strict";var e={d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Package:()=>p,PackageError:()=>u});var s={};e.r(s),e.d(s,{CONFIG:()=>w,Loader:()=>y,MathJax:()=>v,PathFilters:()=>b});const n="4.0.0",a="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:{};function o(e){return"object"==typeof e&&null!==e}function i(e,t,s=!1){var n;for(const a of Object.keys(t))"__esModule"!==a&&e[a]!==t[a]&&null!==t[a]&&void 0!==t[a]&&(o(e[a])&&o(t[a])?i(e[a],t[a],s||"_"===a):s&&(null===(n=Object.getOwnPropertyDescriptor(e,a))||void 0===n?void 0:n.get)||(e[a]=t[a]));return e}function r(e,t,s){e[t]||(e[t]={}),e=e[t];for(const t of Object.keys(s))o(e[t])&&o(s[t])?r(e,t,s[t]):null==e[t]&&null!=s[t]&&(e[t]=s[t]);return e}function d(e){return i(c,e)}void 0!==a.MathJax&&a.MathJax.constructor==={}.constructor||(a.MathJax={}),a.MathJax.version||(a.MathJax={version:n,_:{},config:a.MathJax});const c=a.MathJax,h="undefined"!=typeof window,l={window:h?window:null,document:h?window.document:null,os:(()=>{if(h&&window.navigator){const e=window.navigator.appVersion,t=[["Win","Windows"],["Mac","MacOS"],["X11","Unix"],["Linux","Unix"]];for(const[s,n]of t)if(e.includes(s))return n;if(window.navigator.userAgent.includes("Android"))return"Unix"}return"unknown"})()};class u extends Error{constructor(e,t){super(e),this.package=t}}class p{get canLoad(){return 0===this.dependencyCount&&!this.noLoad&&!this.isLoading&&!this.hasFailed}static loadPromise(e){const t=w[e]||{},s=t.extraLoads?y.load(...t.extraLoads):Promise.resolve(),n=t.checkReady||(()=>Promise.resolve());return s.then((()=>n()))}static resolvePath(e,t=!0){const s={name:e,original:e,addExtension:t};return y.pathFilters.execute(s),s.name}static loadAll(){for(const e of this.packages.values())e.canLoad&&e.load()}constructor(e,t=!1){this.isLoaded=!1,this.result={},this.isLoading=!1,this.hasFailed=!1,this.dependents=[],this.dependencies=[],this.dependencyCount=0,this.provided=[],this.name=e,this.noLoad=t,p.packages.set(e,this),this.promise=this.makePromise(this.makeDependencies())}makeDependencies(){const e=[],t=p.packages,s=this.noLoad,n=this.name,a=[];Object.hasOwn(w.dependencies,n)?a.push(...w.dependencies[n]):"core"!==n&&a.push("core");for(const n of a){const a=t.get(n)||new p(n,s);this.dependencies.includes(a)||(a.addDependent(this,s),this.dependencies.push(a),a.isLoaded||(this.dependencyCount++,e.push(a.promise)))}return e}makePromise(e){let t=new Promise(((e,t)=>{this.resolve=e,this.reject=t}));const s=w[this.name]||{};return s.ready&&(t=t.then((e=>s.ready(this.name)))),e.length&&(e.push(t),t=Promise.all(e).then((e=>e.join(", ")))),s.failed&&t.catch((e=>s.failed(new u(e,this.name)))),t}load(){if(!this.isLoaded&&!this.isLoading&&!this.noLoad){this.isLoading=!0;const e=p.resolvePath(this.name);w.require?this.loadCustom(e):this.loadScript(e)}}loadCustom(e){try{const t=w.require(e);t instanceof Promise?t.then((e=>this.result=e)).then((()=>this.checkLoad())).catch((t=>this.failed("Can't load \""+e+'"\n'+t.message.trim()))):(this.result=t,this.checkLoad())}catch(e){this.failed(e.message)}}loadScript(e){const t=l.document.createElement("script");t.src=e,t.charset="UTF-8",t.onload=e=>this.checkLoad(),t.onerror=t=>this.failed("Can't load \""+e+'"'),l.document.head.appendChild(t)}loaded(){this.isLoaded=!0,this.isLoading=!1;for(const e of this.dependents)e.requirementSatisfied();for(const e of this.provided)e.loaded();this.resolve(this.name)}failed(e){this.hasFailed=!0,this.isLoading=!1,this.reject(new u(e,this.name))}checkLoad(){p.loadPromise(this.name).then((()=>this.loaded())).catch((e=>this.failed(e)))}requirementSatisfied(){this.dependencyCount&&(this.dependencyCount--,this.canLoad&&this.load())}provides(e=[]){for(const t of e){let e=p.packages.get(t);e||(w.dependencies[t]||(w.dependencies[t]=[]),w.dependencies[t].push(t),e=new p(t,!0),e.isLoading=!0),this.provided.push(e)}}addDependent(e,t){this.dependents.push(e),t||this.checkNoLoad()}checkNoLoad(){if(this.noLoad){this.noLoad=!1;for(const e of this.dependencies)e.checkNoLoad()}}}p.packages=new Map;class x{constructor(){this.items=[],this.items=[]}[Symbol.iterator](){let e=0;const t=this.items;return{next:()=>({value:t[e++],done:e>t.length})}}add(e,t=x.DEFAULTPRIORITY){let s=this.items.length;do{s--}while(s>=0&&t<this.items[s].priority);return this.items.splice(s+1,0,{item:e,priority:t}),e}remove(e){let t=this.items.length;do{t--}while(t>=0&&this.items[t].item!==e);return t>=0&&this.items.splice(t,1),this}}x.DEFAULTPRIORITY=5;const m=c.config||{};var f=function(e,t,s,n){return new(s||(s=Promise))((function(a,o){function i(e){try{d(n.next(e))}catch(e){o(e)}}function r(e){try{d(n.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(i,r)}d((n=n.apply(e,t||[])).next())}))};const b={source:e=>(Object.hasOwn(w.source,e.name)&&(e.name=w.source[e.name]),!0),normalize:e=>{const t=e.name;return t.match(/^(?:[a-z]+:\/)?\/|[a-z]:\\|\[/i)||(e.name="[mathjax]/"+t.replace(/^\.\//,"")),!0},prefix:e=>{let t;for(;(t=e.name.match(/^\[([^\]]*)\]/))&&Object.hasOwn(w.paths,t[1]);)e.name=w.paths[t[1]]+e.name.substring(t[0].length);return!0},addExtension:e=>(e.addExtension&&!e.name.match(/\.[^/]+$/)&&(e.name+=".js"),!0)},g=c.version,y={versions:new Map,nestedLoads:[],ready(...e){0===e.length&&(e=Array.from(p.packages.keys()));const t=[];for(const s of e){const e=p.packages.get(s)||new p(s,!0);t.push(e.promise)}return Promise.all(t)},load(...e){if(0===e.length)return Promise.resolve([]);let t=[];this.nestedLoads.unshift(t);const s=Promise.resolve().then((()=>f(this,void 0,void 0,(function*(){const s=[];for(const t of e){let e=p.packages.get(t);e||(e=new p(t),e.provides(w.provides[t])),e.checkNoLoad(),s.push(e.promise.then((()=>(w.versionWarnings&&e.isLoaded&&!y.versions.has(p.resolvePath(t))&&console.warn(`No version information available for component ${t}`),e.result))))}p.loadAll();const n=yield Promise.all(s);for(;t.length;){const e=Promise.all(t);t=this.nestedLoads[this.nestedLoads.indexOf(t)]=[],yield e}return this.nestedLoads.splice(this.nestedLoads.indexOf(t),1),n}))));return this.nestedLoads.slice(1).forEach((e=>e.push(s))),s},preLoaded(...e){for(const t of e){let e=p.packages.get(t);e||(e=new p(t,!0),e.provides(w.provides[t])),e.loaded()}},addPackageData(e,t){let s=w[e];s||(s=w[e]={});for(const[e,n]of Object.entries(t))if(Array.isArray(n)){s[e]||(s[e]=[]);const t=new Set([...s[e],...n]);s[e]=[...t]}else s[e]=n},defaultReady(){void 0!==v.startup&&v.config.startup.ready()},getRoot(){if(l.document){const e=l.document.currentScript||l.document.getElementById("MathJax-script");if(e&&e instanceof HTMLScriptElement)return e.src.replace(/\/[^/]*$/,"")}return m?.loader?.paths?.mathjax||m?.__dirname||"/"},checkVersion(e,t,s){return this.saveVersion(e),!(!w.versionWarnings||t===g)&&(console.warn(`Component ${e} uses ${t} of MathJax; version in use is ${g}`),!0)},saveVersion(e){y.versions.set(p.resolvePath(e),g)},pathFilters:new class extends x{constructor(e=null){super(),e&&this.addList(e)}addList(e){for(const t of e)Array.isArray(t)?this.add(t[0],t[1]):this.add(t)}execute(...e){for(const t of this){if(!1===t.item(...e))return!1}return!0}asyncExecute(...e){let t=-1;const s=this.items;return new Promise(((n,a)=>{!function o(){for(;++t<s.length;){const i=s[t].item(...e);if(i instanceof Promise)return void i.then(o).catch((e=>a(e)));if(!1===i)return void n(!1)}n(!0)}()}))}}};y.pathFilters.add(b.source,0),y.pathFilters.add(b.normalize,10),y.pathFilters.add(b.prefix,20),y.pathFilters.add(b.addExtension,30);const v=c;if(void 0===v.loader){r(v.config,"loader",{paths:{mathjax:y.getRoot()},source:{},dependencies:{},provides:{},load:[],ready:y.defaultReady.bind(y),failed:e=>console.log(`MathJax(${e.package||"?"}): ${e.message}`),require:null,pathFilters:[],versionWarnings:!0}),d({loader:y});for(const e of v.config.loader.pathFilters)Array.isArray(e)?y.pathFilters.add(e[0],e[1]):y.pathFilters.add(e)}const w=v.config.loader;MathJax.loader&&MathJax.loader.checkVersion("loader",n,"loader"),d({_:{components:{loader:s,package:t}}});r(MathJax.config.loader,"dependencies",{"a11y/semantic-enrich":["input/mml","a11y/sre"],"a11y/speech":["a11y/semantic-enrich"],"a11y/complexity":["a11y/semantic-enrich"],"a11y/explorer":["a11y/speech"],"[mml]/mml3":["input/mml"],"[tex]/action":["input/tex-base"],"[tex]/ams":["input/tex-base","[tex]/newcommand"],"[tex]/amscd":["input/tex-base"],"[tex]/autoload":["input/tex-base","[tex]/require"],"[tex]/bbm":["input/tex-base"],"[tex]/bboldx":["input/tex-base","[tex]/textmacros"],"[tex]/bbox":["input/tex-base"],"[tex]/begingroup":["input/tex-base","[tex]/newcommand"],"[tex]/boldsymbol":["input/tex-base"],"[tex]/braket":["input/tex-base"],"[tex]/bussproofs":["input/tex-base"],"[tex]/cancel":["input/tex-base","[tex]/enclose"],"[tex]/cases":["[tex]/empheq"],"[tex]/centernot":["input/tex-base"],"[tex]/color":["input/tex-base"],"[tex]/colortbl":["input/tex-base","[tex]/color"],"[tex]/colorv2":["input/tex-base"],"[tex]/configmacros":["input/tex-base","[tex]/newcommand"],"[tex]/dsfont":["input/tex-base"],"[tex]/empheq":["input/tex-base","[tex]/ams"],"[tex]/enclose":["input/tex-base"],"[tex]/extpfeil":["input/tex-base","[tex]/newcommand","[tex]/ams"],"[tex]/gensymb":["input/tex-base"],"[tex]/html":["input/tex-base"],"[tex]/mathtools":["input/tex-base","[tex]/newcommand","[tex]/ams","[tex]/boldsymbol"],"[tex]/mhchem":["input/tex-base","[tex]/ams"],"[tex]/newcommand":["input/tex-base"],"[tex]/noerrors":["input/tex-base"],"[tex]/noundefined":["input/tex-base"],"[tex]/physics":["input/tex-base"],"[tex]/require":["input/tex-base"],"[tex]/setoptions":["input/tex-base"],"[tex]/tagformat":["input/tex-base"],"[tex]/texhtml":["input/tex-base"],"[tex]/textcomp":["input/tex-base","[tex]/textmacros"],"[tex]/textmacros":["input/tex-base"],"[tex]/unicode":["input/tex-base"],"[tex]/units":["input/tex-base"],"[tex]/upgreek":["input/tex-base"],"[tex]/verb":["input/tex-base"],"ui/menu":["a11y/sre"]}),r(MathJax.config.loader,"paths",{tex:"[mathjax]/input/tex/extensions",mml:"[mathjax]/input/mml/extensions",sre:"[mathjax]/sre",mathmaps:"[sre]/mathmaps"}),r(MathJax.config.loader,"provides",{startup:["loader"],"input/tex":["input/tex-base","[tex]/ams","[tex]/newcommand","[tex]/textmacros","[tex]/noundefined","[tex]/require","[tex]/autoload","[tex]/configmacros"]}),y.load(...w.load).then((()=>w.ready())).catch(((e,t)=>w.failed(e,t)))})();