better-react-mathjax 2.2.0 → 2.4.0-beta-1
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/MathJax/MathJax.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},__createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&("get"in i?t.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){e[r=void 0===r?n:r]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n
|
|
1
|
+
"use strict";"use client";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},__createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&("get"in i?t.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){e[r=void 0===r?n:r]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||(()=>{var i=function(e){return(i=Object.getOwnPropertyNames||function(e){var t,n=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[n.length]=t);return n})(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),r=0;r<n.length;r++)"default"!==n[r]&&__createBinding(t,e,n[r]);return __setModuleDefault(t,e),t}})(),__rest=this&&this.__rest||function(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n},react_1=(Object.defineProperty(exports,"__esModule",{value:!0}),__importStar(require("react"))),MathJaxContext_1=require("../MathJaxContext"),typesettingFailed=function(e){return"Typesetting failed: ".concat(void 0!==e.message?e.message:JSON.stringify(e))},MathJax=function(e){function r(){var e;"every"===h&&g&&"post"===_&&null!==f.current&&(f.current.style.visibility=null!=(e=null==(e=p.style)?void 0:e.visibility)?e:"visible"),b.current||("first"===h&&null!==f.current&&(f.current.style.visibility="visible"),n&&n(),b.current=!0),o&&o(),m.current=!1}var t=e.inline,i=void 0!==t&&t,t=e.hideUntilTypeset,n=e.onInitTypeset,o=e.onTypeset,s=e.text,u=e.dynamic,a=e.typesettingOptions,l=e.renderMode,c=e.children,p=__rest(e,["inline","hideUntilTypeset","onInitTypeset","onTypeset","text","dynamic","typesettingOptions","renderMode","children"]),d=(0,react_1.useRef)(""),f=(0,react_1.useRef)(null),y=(0,react_1.useContext)(MathJaxContext_1.MathJaxBaseContext),h=null!=t?t:null==y?void 0:y.hideUntilTypeset,_=null!=l?l:null==y?void 0:y.renderMode,v=null!=a?a:null==y?void 0:y.typesettingOptions,g=!1!==u&&(u||"production"!==process.env.NODE_ENV),b=(0,react_1.useRef)(!1),m=(0,react_1.useRef)(!1);return!m.current&&null!==f.current&&g&&"every"===h&&"post"===_&&(f.current.style.visibility="hidden"),("undefined"!=typeof window?react_1.useLayoutEffect:react_1.useEffect)(function(){if((g||!b.current)&&null!==f.current){if(!y)throw Error("MathJax was not loaded, did you use the MathJax component outside of a MathJaxContext?");if("pre"===_){if(!("string"==typeof(e=s)&&0<e.length))throw Error("Render mode 'pre' requires text prop to be set and non-empty, which was currently \"".concat(s,'"'));if(!a||!a.fn)throw Error("Render mode 'pre' requires 'typesettingOptions' prop with 'fn' property to be set on MathJax element or in the MathJaxContext");if(2===y.version)throw Error("Render mode 'pre' only available with MathJax 3 and 4, and version 2 is currently in use")}"post"!==_&&s===d.current||m.current||(m.current=!0,3===y.version||4===y.version?y.promise.then(function(t){var n;"pre"===_?(n=function(e){d.current=s,t.startup.document.clear(),t.startup.document.updateDocument(),null!==f.current&&(f.current.innerHTML=e.outerHTML),r()},a.fn.endsWith("Promise")?t.startup.promise.then(function(){return t[v.fn](s,__assign(__assign({},(null==v?void 0:v.options)||{}),{display:!i}))}).then(n).catch(function(e){throw r(),Error(typesettingFailed(e))}):t.startup.promise.then(function(){var e=t[v.fn](s,__assign(__assign({},(null==v?void 0:v.options)||{}),{display:!i}));n(e)}).catch(function(e){throw r(),Error(typesettingFailed(e))})):t.startup.promise.then(function(){return t.typesetClear([f.current]),t.typesetPromise([f.current])}).then(r).catch(function(e){throw r(),Error(typesettingFailed(e))})}).catch(function(e){throw r(),Error(typesettingFailed(e))}):y.promise.then(function(e){e.Hub.Queue(["Typeset",e.Hub,f.current]),e.Hub.Queue(r)}).catch(function(e){throw r(),Error(typesettingFailed(e))}))}var e}),react_1.default.createElement("span",__assign({},p,{style:__assign(__assign({display:i?"inline":"block"},p.style),{visibility:h?"hidden":null==(e=p.style)?void 0:e.visibility}),ref:f}),c)};exports.default=MathJax;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { FC, ReactNode } from "react";
|
|
2
2
|
import type { MathJax2Config, MathJax2Object } from "../MathJax2";
|
|
3
|
-
import type { MathJax3Config, MathJax3Object, OptionList } from "../MathJax3";
|
|
3
|
+
import type { MathJax3Config, MathJax3Object, OptionList as MathJax3OptionList } from "../MathJax3";
|
|
4
|
+
import type { MathJax4Config, MathJax4Object, OptionList as MathJax4OptionList } from "../MathJax4";
|
|
4
5
|
export type TypesettingFunction = "tex2chtml" | "tex2chtmlPromise" | "tex2svg" | "tex2svgPromise" | "tex2mml" | "tex2mmlPromise" | "mathml2chtml" | "mathml2chtmlPromise" | "mathml2svg" | "mathml2svgPromise" | "mathml2mml" | "mathml2mmlPromise" | "asciimath2chtml" | "asciimath2chtmlPromise" | "asciimath2svg" | "asciimath2svgPromise" | "asciimath2mml" | "asciimath2mmlPromise";
|
|
5
6
|
export interface MathJaxOverrideableProps {
|
|
6
7
|
hideUntilTypeset?: "first" | "every";
|
|
7
8
|
typesettingOptions?: {
|
|
8
9
|
fn: TypesettingFunction;
|
|
9
|
-
options?: Omit<
|
|
10
|
+
options?: Omit<MathJax3OptionList | MathJax4OptionList, "display">;
|
|
10
11
|
};
|
|
11
12
|
renderMode?: "pre" | "post";
|
|
12
13
|
}
|
|
@@ -16,6 +17,9 @@ export type MathJaxSubscriberProps = ({
|
|
|
16
17
|
} | {
|
|
17
18
|
version: 3;
|
|
18
19
|
promise: Promise<MathJax3Object>;
|
|
20
|
+
} | {
|
|
21
|
+
version: 4;
|
|
22
|
+
promise: Promise<MathJax4Object>;
|
|
19
23
|
}) & MathJaxOverrideableProps;
|
|
20
24
|
export declare const MathJaxBaseContext: React.Context<MathJaxSubscriberProps | undefined>;
|
|
21
25
|
interface MathJaxContextStaticProps extends MathJaxOverrideableProps {
|
|
@@ -33,6 +37,10 @@ export type MathJaxContextProps = ({
|
|
|
33
37
|
config?: MathJax3Config;
|
|
34
38
|
version?: 3;
|
|
35
39
|
onStartup?: (mathJax: MathJax3Object) => void;
|
|
40
|
+
} | {
|
|
41
|
+
config?: MathJax4Config;
|
|
42
|
+
version?: 4;
|
|
43
|
+
onStartup?: (mathJax: MathJax4Object) => void;
|
|
36
44
|
}) & MathJaxContextStaticProps;
|
|
37
45
|
declare const MathJaxContext: FC<MathJaxContextProps>;
|
|
38
46
|
export default MathJaxContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v2Promise,v3Promise,__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,o=1,
|
|
1
|
+
"use strict";"use client";var v2Promise,v3Promise,v4Promise,__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},__createBinding=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var n=Object.getOwnPropertyDescriptor(t,o);n&&("get"in n?t.__esModule:!n.writable&&!n.configurable)||(n={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,n)}:function(e,t,o,r){e[r=void 0===r?o:r]=t[o]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||(()=>{var n=function(e){return(n=Object.getOwnPropertyNames||function(e){var t,o=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[o.length]=t);return o})(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o=n(e),r=0;r<o.length;r++)"default"!==o[r]&&__createBinding(t,e,o[r]);return __setModuleDefault(t,e),t}})(),react_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.MathJaxBaseContext=void 0,__importStar(require("react"))),DEFAULT_V2_SRC=(exports.MathJaxBaseContext=(0,react_1.createContext)(void 0),"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_CHTML"),DEFAULT_V3_SRC="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js",DEFAULT_V4_SRC="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js",MathJaxContext=function(e){var r=e.config,t=e.version,t=void 0===t?4:t,o=e.src,o=void 0===o?2===t?DEFAULT_V2_SRC:3===t?DEFAULT_V3_SRC:DEFAULT_V4_SRC:o,n=e.onStartup,i=e.onLoad,a=e.asyncLoad,s=void 0!==a&&a,c=e.onError,a=e.typesettingOptions,d=e.renderMode,d=void 0===d?"post":d,u=e.hideUntilTypeset,e=e.children,h=(0,react_1.useContext)(exports.MathJaxBaseContext);if(void 0!==(null==h?void 0:h.version)&&(null==h?void 0:h.version)!==t)throw Error("Cannot nest MathJaxContexts with different versions. MathJaxContexts should not be nested at all but if they are, they cannot have different versions. Stick with one version of MathJax in your app and avoid using more than one MathJaxContext.");if(2===t&&(void 0!==v3Promise||void 0!==v4Promise)||3===t&&(void 0!==v2Promise||void 0!==v4Promise)||4===t&&(void 0!==v2Promise||void 0!==v3Promise))throw Error("Cannot use two MathJax versions simultaneously in the same app due to how MathJax is set up in the browser; either you have multiple MathJaxContexts with different versions or you have mounted and unmounted MathJaxContexts with different versions. Please stick with one version of MathJax in your app. File an issue in the project Github page if you need this feature.");var v=(0,react_1.useRef)(h),h=(0,react_1.useRef)((null==h?void 0:h.version)||null);if(null===h.current)h.current=t;else if(h.current!==t)throw Error("Cannot change version of MathJax in a MathJaxContext after it has mounted. Reload the page with a new version when this must happen.");var l=o||(2===t?DEFAULT_V2_SRC:3===t?DEFAULT_V3_SRC:DEFAULT_V4_SRC);function f(t,o){r&&(window.MathJax=r);var e=document.createElement("script");e.type="text/javascript",e.src=l,e.async=s,e.addEventListener("load",function(){var e=window.MathJax;n&&n(e),t(e),i&&i()}),e.addEventListener("error",function(e){return o(e)}),document.getElementsByTagName("head")[0].appendChild(e)}return void 0===v.current&&(h={typesettingOptions:a,renderMode:d,hideUntilTypeset:u},2===t?void 0===v2Promise&&("undefined"!=typeof window?(v2Promise=new Promise(f)).catch(function(e){if(!c)throw Error("Failed to download MathJax version 2 from '".concat(l,"' due to: ").concat(JSON.stringify(e)));c(e)}):(v2Promise=Promise.reject()).catch(function(e){})):3===t?void 0===v3Promise&&("undefined"!=typeof window?(v3Promise=new Promise(f)).catch(function(e){if(!c)throw Error("Failed to download MathJax version 3 from '".concat(l,"' due to: ").concat(e));c(e)}):(v3Promise=Promise.reject()).catch(function(e){})):void 0===v4Promise&&("undefined"!=typeof window?(v4Promise=new Promise(f)).catch(function(e){if(!c)throw Error("Failed to download MathJax version 4 from '".concat(l,"' due to: ").concat(e));c(e)}):(v4Promise=Promise.reject()).catch(function(e){})),v.current=__assign(__assign({},h),2===t?{version:2,promise:v2Promise}:3===t?{version:3,promise:v3Promise}:{version:4,promise:v4Promise})),react_1.default.createElement(exports.MathJaxBaseContext.Provider,{value:v.current},e)};exports.default=MathJaxContext;
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ well as dynamic updates. Simple to use but with many configuration options.
|
|
|
34
34
|
Add this library manually as a dependency to `package.json`...
|
|
35
35
|
```
|
|
36
36
|
dependencies: {
|
|
37
|
-
"better-react-mathjax": "^2.
|
|
37
|
+
"better-react-mathjax": "^2.3.0"
|
|
38
38
|
}
|
|
39
39
|
```
|
|
40
40
|
... and then run `npm install` **or** let `npm` or `yarn` do it for you, depending on which package manager you have
|
|
@@ -91,8 +91,8 @@ text in a long paragraph. If you have a lot of math, try to wrap as much as poss
|
|
|
91
91
|
The `MathJaxContext` is responsible for downloading MathJax and providing it to all wrapped `MathJax` components that
|
|
92
92
|
typeset math. By default, `MathJaxContext` imports MathJax from a CDN which allows for use of Latex, AsciiMath and MathML
|
|
93
93
|
with [MathJax version 2](https://docs.mathjax.org/en/v2.7-latest/config-files.html#the-tex-mml-am-chtml-configuration-file) and
|
|
94
|
-
Latex and MathML with the default [MathJax version
|
|
95
|
-
HTML output for
|
|
94
|
+
Latex and MathML with [MathJax version 3](https://docs.mathjax.org/en/v3.2/web/components/combined.html#tex-mml-chtml) and the default [MathJax version 4](https://docs.mathjax.org/en/latest/web/components/combined.html#tex-mml-chtml) with
|
|
95
|
+
HTML output for all three. If you need something else or want to host your own copy of MathJax, read more about the `src`
|
|
96
96
|
attribute of the `MathJaxContext` below.
|
|
97
97
|
|
|
98
98
|
Note that both `MathJax` and `MathJaxContext` components ship with `"use client"` directives and are thus client
|
package/esm/MathJax/MathJax.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(
|
|
1
|
+
"use client";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},__rest=this&&this.__rest||function(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};import React,{useContext,useEffect,useLayoutEffect,useRef}from"react";import{MathJaxBaseContext}from"../MathJaxContext";var typesettingFailed=function(e){return"Typesetting failed: ".concat(void 0!==e.message?e.message:JSON.stringify(e))},MathJax=function(e){function r(){var e;"every"===h&&m&&"post"===v&&null!==f.current&&(f.current.style.visibility=null!=(e=null==(e=p.style)?void 0:e.visibility)?e:"visible"),_.current||("first"===h&&null!==f.current&&(f.current.style.visibility="visible"),n&&n(),_.current=!0),o&&o(),b.current=!1}var t=e.inline,i=void 0!==t&&t,t=e.hideUntilTypeset,n=e.onInitTypeset,o=e.onTypeset,s=e.text,u=e.dynamic,a=e.typesettingOptions,l=e.renderMode,c=e.children,p=__rest(e,["inline","hideUntilTypeset","onInitTypeset","onTypeset","text","dynamic","typesettingOptions","renderMode","children"]),y=useRef(""),f=useRef(null),d=useContext(MathJaxBaseContext),h=null!=t?t:null==d?void 0:d.hideUntilTypeset,v=null!=l?l:null==d?void 0:d.renderMode,g=null!=a?a:null==d?void 0:d.typesettingOptions,m=!1!==u&&(u||"production"!==process.env.NODE_ENV),_=useRef(!1),b=useRef(!1);return!b.current&&null!==f.current&&m&&"every"===h&&"post"===v&&(f.current.style.visibility="hidden"),("undefined"!=typeof window?useLayoutEffect:useEffect)(function(){if((m||!_.current)&&null!==f.current){if(!d)throw Error("MathJax was not loaded, did you use the MathJax component outside of a MathJaxContext?");if("pre"===v){if(!("string"==typeof(e=s)&&0<e.length))throw Error("Render mode 'pre' requires text prop to be set and non-empty, which was currently \"".concat(s,'"'));if(!a||!a.fn)throw Error("Render mode 'pre' requires 'typesettingOptions' prop with 'fn' property to be set on MathJax element or in the MathJaxContext");if(2===d.version)throw Error("Render mode 'pre' only available with MathJax 3 and 4, and version 2 is currently in use")}"post"!==v&&s===y.current||b.current||(b.current=!0,3===d.version||4===d.version?d.promise.then(function(t){var n;"pre"===v?(n=function(e){y.current=s,t.startup.document.clear(),t.startup.document.updateDocument(),null!==f.current&&(f.current.innerHTML=e.outerHTML),r()},a.fn.endsWith("Promise")?t.startup.promise.then(function(){return t[g.fn](s,__assign(__assign({},(null==g?void 0:g.options)||{}),{display:!i}))}).then(n).catch(function(e){throw r(),Error(typesettingFailed(e))}):t.startup.promise.then(function(){var e=t[g.fn](s,__assign(__assign({},(null==g?void 0:g.options)||{}),{display:!i}));n(e)}).catch(function(e){throw r(),Error(typesettingFailed(e))})):t.startup.promise.then(function(){return t.typesetClear([f.current]),t.typesetPromise([f.current])}).then(r).catch(function(e){throw r(),Error(typesettingFailed(e))})}).catch(function(e){throw r(),Error(typesettingFailed(e))}):d.promise.then(function(e){e.Hub.Queue(["Typeset",e.Hub,f.current]),e.Hub.Queue(r)}).catch(function(e){throw r(),Error(typesettingFailed(e))}))}var e}),React.createElement("span",__assign({},p,{style:__assign(__assign({display:i?"inline":"block"},p.style),{visibility:h?"hidden":null==(e=p.style)?void 0:e.visibility}),ref:f}),c)};export default MathJax;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var
|
|
1
|
+
"use client";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};import React,{createContext,useContext,useRef}from"react";var v2Promise,v3Promise,v4Promise,MathJaxBaseContext=createContext(void 0),DEFAULT_V2_SRC="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_CHTML",DEFAULT_V3_SRC="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js",DEFAULT_V4_SRC="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js",MathJaxContext=function(e){var n=e.config,t=e.version,t=void 0===t?4:t,o=e.src,o=void 0===o?2===t?DEFAULT_V2_SRC:3===t?DEFAULT_V3_SRC:DEFAULT_V4_SRC:o,i=e.onStartup,r=e.onLoad,a=e.asyncLoad,s=void 0!==a&&a,d=e.onError,a=e.typesettingOptions,c=e.renderMode,c=void 0===c?"post":c,h=e.hideUntilTypeset,e=e.children,v=useContext(MathJaxBaseContext);if(void 0!==(null==v?void 0:v.version)&&(null==v?void 0:v.version)!==t)throw Error("Cannot nest MathJaxContexts with different versions. MathJaxContexts should not be nested at all but if they are, they cannot have different versions. Stick with one version of MathJax in your app and avoid using more than one MathJaxContext.");if(2===t&&(void 0!==v3Promise||void 0!==v4Promise)||3===t&&(void 0!==v2Promise||void 0!==v4Promise)||4===t&&(void 0!==v2Promise||void 0!==v3Promise))throw Error("Cannot use two MathJax versions simultaneously in the same app due to how MathJax is set up in the browser; either you have multiple MathJaxContexts with different versions or you have mounted and unmounted MathJaxContexts with different versions. Please stick with one version of MathJax in your app. File an issue in the project Github page if you need this feature.");var u=useRef(v),v=useRef((null==v?void 0:v.version)||null);if(null===v.current)v.current=t;else if(v.current!==t)throw Error("Cannot change version of MathJax in a MathJaxContext after it has mounted. Reload the page with a new version when this must happen.");var m=o||(2===t?DEFAULT_V2_SRC:3===t?DEFAULT_V3_SRC:DEFAULT_V4_SRC);function f(t,o){n&&(window.MathJax=n);var e=document.createElement("script");e.type="text/javascript",e.src=m,e.async=s,e.addEventListener("load",function(){var e=window.MathJax;i&&i(e),t(e),r&&r()}),e.addEventListener("error",function(e){return o(e)}),document.getElementsByTagName("head")[0].appendChild(e)}return void 0===u.current&&(v={typesettingOptions:a,renderMode:c,hideUntilTypeset:h},2===t?void 0===v2Promise&&("undefined"!=typeof window?(v2Promise=new Promise(f)).catch(function(e){if(!d)throw Error("Failed to download MathJax version 2 from '".concat(m,"' due to: ").concat(JSON.stringify(e)));d(e)}):(v2Promise=Promise.reject()).catch(function(e){})):3===t?void 0===v3Promise&&("undefined"!=typeof window?(v3Promise=new Promise(f)).catch(function(e){if(!d)throw Error("Failed to download MathJax version 3 from '".concat(m,"' due to: ").concat(e));d(e)}):(v3Promise=Promise.reject()).catch(function(e){})):void 0===v4Promise&&("undefined"!=typeof window?(v4Promise=new Promise(f)).catch(function(e){if(!d)throw Error("Failed to download MathJax version 4 from '".concat(m,"' due to: ").concat(e));d(e)}):(v4Promise=Promise.reject()).catch(function(e){})),u.current=__assign(__assign({},v),2===t?{version:2,promise:v2Promise}:3===t?{version:3,promise:v3Promise}:{version:4,promise:v4Promise})),React.createElement(MathJaxBaseContext.Provider,{value:u.current},e)};export default MathJaxContext;export{MathJaxBaseContext};
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as MathJax, MathJaxProps } from "./MathJax";
|
|
2
2
|
export { default as MathJaxContext, MathJaxContextProps, MathJaxBaseContext, MathJaxSubscriberProps } from "./MathJaxContext";
|
|
3
3
|
export { MathJax2Config, MathJax2Object } from "./MathJax2";
|
|
4
|
-
export { MathJax3Object, MathJax3Config, OptionList } from "./MathJax3";
|
|
4
|
+
export { MathJax3Object, MathJax3Config, OptionList as MathJax3OptionList } from "./MathJax3";
|
|
5
|
+
export { MathJax4Object, MathJax4Config, OptionList as MathJax4OptionList } from "./MathJax4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-react-mathjax",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-beta-1",
|
|
4
4
|
"description": "Up-to-date component for using MathJax in latest React (using functional components and hooks API). Focuses on being versatile and making the use of MathJax in React a pleasant experience without flashes of non-typeset content, both with respect to initial rendering as well as dynamic updates. Simple to use but with many configuration options.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"react": ">=16.8"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"mathjax-full": "^3.2.2"
|
|
30
|
+
"mathjax-full": "^3.2.2",
|
|
31
|
+
"@mathjax/src": "^4.0.0"
|
|
31
32
|
}
|
|
32
33
|
}
|