UNPKG

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 11.3 kB
(()=>{"use strict";var e={d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{Package:()=>x,PackageError:()=>p});var n={};e.r(n),e.d(n,{CONFIG:()=>L,Loader:()=>v,MathJax:()=>w,PathFilters:()=>g});const s="4.1.0",o={},a="undefined"!=typeof window?window:void 0!==e.g?e.g:"undefined"!=typeof globalThis?globalThis:o;function i(e){return"object"==typeof e&&null!==e}function r(e,t,n=!1){var s;for(const o of Object.keys(t))"__esModule"!==o&&e[o]!==t[o]&&null!==t[o]&&void 0!==t[o]&&(i(e[o])&&i(t[o])?r(e[o],t[o],n||"_"===o):n&&(null===(s=Object.getOwnPropertyDescriptor(e,o))||void 0===s?void 0:s.get)||(e[o]=t[o]));return e}function d(e,t,n){e[t]||(e[t]={}),e=e[t];for(const t of Object.keys(n))i(e[t])&&i(n[t])?d(e,t,n[t]):null==e[t]&&null!=n[t]&&(e[t]=n[t]);return e}function c(e){return r(h,e)}void 0!==a.MathJax&&a.MathJax.constructor==={}.constructor||(a.MathJax={}),a.MathJax.version||(a.MathJax={version:s,_:{},config:a.MathJax});const h=a.MathJax,l="undefined"!=typeof window,u={window:l?window:null,document:l?window.document:null,os:(()=>{if(l&&window.navigator){const e=window.navigator.appVersion,t=[["Win","Windows"],["Mac","MacOS"],["X11","Unix"],["Linux","Unix"]];for(const[n,s]of t)if(e.includes(n))return s;if(window.navigator.userAgent.includes("Android"))return"Unix"}else if("undefined"!=typeof process)return{linux:"Unix",android:"Unix",aix:"Unix",freebsd:"Unix",netbsd:"Unix",openbsd:"Unix",sunos:"Unix",darwin:"MacOS",win32:"Windows",cygwin:"Windows"}[process.platform]||process.platform;return"unknown"})(),path:e=>e};"Windows"===u.os&&(u.path=e=>e.match(/^[/\\]?[a-zA-Z]:[/\\]/)?e.replace(/\\/g,"/").replace(/^\//,""):e);class p extends Error{constructor(e,t){super(e),this.package=t}}class x{get canLoad(){return 0===this.dependencyCount&&!this.noLoad&&!this.isLoading&&!this.hasFailed}static loadPromise(e){const t=L[e]||{},n=t.extraLoads?v.load(...t.extraLoads):Promise.resolve(),s=t.checkReady||(()=>Promise.resolve());return n.then((()=>s()))}static resolvePath(e,t=!0){const n={name:e,original:e,addExtension:t};return v.pathFilters.execute(n),n.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,x.packages.set(e,this),this.promise=this.makePromise(this.makeDependencies())}makeDependencies(){const e=[],t=x.packages,n=this.noLoad,s=this.name,o=[];Object.hasOwn(L.dependencies,s)?o.push(...L.dependencies[s]):"core"!==s&&o.push("core");for(const s of o){const o=t.get(s)||new x(s,n);this.dependencies.includes(o)||(o.addDependent(this,n),this.dependencies.push(o),o.isLoaded||(this.dependencyCount++,e.push(o.promise)))}return e}makePromise(e){let t=new Promise(((e,t)=>{this.resolve=e,this.reject=t}));const n=L[this.name]||{};return n.ready&&(t=t.then((e=>n.ready(this.name)))),e.length&&(e.push(t),t=Promise.all(e).then((e=>e.join(", ")))),n.failed&&t.catch((e=>n.failed(new p(e,this.name)))),t}load(){if(!this.isLoaded&&!this.isLoading&&!this.noLoad){this.isLoading=!0;const e=x.resolvePath(this.name);L.require?this.loadCustom(e):this.loadScript(e)}}loadCustom(e){try{const t=L.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=u.document.createElement("script");t.src=e,t.charset="UTF-8",t.onload=e=>this.checkLoad(),t.onerror=t=>this.failed("Can't load \""+e+'"'),u.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 p(e,this.name))}checkLoad(){x.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=x.packages.get(t);e||(L.dependencies[t]||(L.dependencies[t]=[]),L.dependencies[t].push(t),e=new x(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()}}}x.packages=new Map;class m{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=m.DEFAULTPRIORITY){let n=this.items.length;do{n--}while(n>=0&&t<this.items[n].priority);return this.items.splice(n+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}}m.DEFAULTPRIORITY=5;const f=h.config||{};var b=function(e,t,n,s){return new(n||(n=Promise))((function(o,a){function i(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,r)}d((s=s.apply(e,t||[])).next())}))};const g={source:e=>(Object.hasOwn(L.source,e.name)&&(e.name=L.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(L.paths,t[1]);)e.name=L.paths[t[1]]+e.name.substring(t[0].length);return!0},addExtension:e=>(e.addExtension&&!e.name.match(/\.[^/]+$/)&&(e.name+=".js"),!0)},y=h.version,v={versions:new Map,nestedLoads:[],ready(...e){0===e.length&&(e=Array.from(x.packages.keys()));const t=[];for(const n of e){const e=x.packages.get(n)||new x(n,!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 n=Promise.resolve().then((()=>b(this,void 0,void 0,(function*(){const n=[];for(const t of e){let e=x.packages.get(t);e||(e=new x(t),e.provides(L.provides[t])),e.checkNoLoad(),n.push(e.promise.then((()=>(L.versionWarnings&&e.isLoaded&&!v.versions.has(x.resolvePath(t))&&console.warn(`No version information available for component ${t}`),e.result))))}x.loadAll();const s=yield Promise.all(n);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),s}))));return this.nestedLoads.slice(1).forEach((e=>e.push(n))),n},preLoaded(...e){for(const t of e){let e=x.packages.get(t);e||(e=new x(t,!0),e.provides(L.provides[t])),e.loaded()}},addPackageData(e,t){let n=L[e];n||(n=L[e]={});for(const[e,s]of Object.entries(t))if(Array.isArray(s)){n[e]||(n[e]=[]);const t=new Set([...n[e],...s]);n[e]=[...t]}else n[e]=s},defaultReady(){void 0!==w.startup&&w.config.startup.ready()},getRoot(){if(u.document){const e=u.document.currentScript||u.document.getElementById("MathJax-script");if(e&&e instanceof HTMLScriptElement)return e.src.replace(/\/[^/]*$/,"")}return f?.loader?.paths?.mathjax||f?.__dirname||"/"},checkVersion(e,t,n){return this.saveVersion(e),!(!L.versionWarnings||t===y)&&(console.warn(`Component ${e} uses ${t} of MathJax; version in use is ${y}`),!0)},saveVersion(e){v.versions.set(x.resolvePath(e),y)},pathFilters:new class extends m{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 n=this.items;return new Promise(((s,o)=>{!function a(){for(;++t<n.length;){const i=n[t].item(...e);if(i instanceof Promise)return void i.then(a).catch((e=>o(e)));if(!1===i)return void s(!1)}s(!0)}()}))}}};v.pathFilters.add(g.source,0),v.pathFilters.add(g.normalize,10),v.pathFilters.add(g.prefix,20),v.pathFilters.add(g.addExtension,30);const w=h;if(void 0===w.loader){d(w.config,"loader",{paths:{mathjax:v.getRoot(),fonts:u.window?"https://cdn.jsdelivr.net/npm/@mathjax":"@mathjax"},source:{},dependencies:{},provides:{},load:[],ready:v.defaultReady.bind(v),failed:e=>console.log(`MathJax(${e.package||"?"}): ${e.message}`),require:null,pathFilters:[],versionWarnings:!0}),c({loader:v});for(const e of w.config.loader.pathFilters)Array.isArray(e)?v.pathFilters.add(e[0],e[1]):v.pathFilters.add(e)}const L=w.config.loader;MathJax.loader&&MathJax.loader.checkVersion("loader",s,"loader"),c({_:{components:{loader:n,package:t}}});d(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"]}),d(MathJax.config.loader,"paths",{tex:"[mathjax]/input/tex/extensions",mml:"[mathjax]/input/mml/extensions",sre:"[mathjax]/sre",mathmaps:"[sre]/mathmaps"}),d(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"]}),v.load(...L.load).then((()=>L.ready())).catch(((e,t)=>L.failed(e,t)))})();