Skip to content

Commit fb3b0d8

Browse files
committed
fix: import.meta causes issues arnog#508
1 parent 2062abd commit fb3b0d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+65102
-2698
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
"print",
202202
"captureEvents",
203203
"releaseEvents",
204-
"getComputedStyle",
204+
// "getComputedStyle",
205205
"matchMedia",
206206
"moveTo",
207207
"moveBy",

CHANGELOG.md

+31-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,37 @@
22

33
### New Features
44

5-
- **#500** Next Generation MathJSON. This is a breaking change: the new
6-
MathJSON format is not backward compatible with the previour version.
7-
For more details on the format, see `src/math-json/README.md`.
8-
9-
The `astToLatex()` and `latexToAST()` functions can still be used to
10-
convert between Latex and MathJSON, but they now handle the new MathJSON
11-
format. Note that the options to these functions have changed.
12-
13-
In particular, there is greatly improved customization of the parsing
14-
possible. It is possible to define the syntax of custom notations, including
15-
requesting that no parsing be done, at which point a string of Latex
16-
tokens is returned.
5+
- **WebPack issues workaround and font loading configuation**
6+
7+
Follow up to **#508**. The fonts can now be loaded either statically or dynamically.
8+
9+
- **dynamic loading** by default, the fonts will get loaded programmatically
10+
when they are needed and the rendering will be deferred until the fonts
11+
are available to avoid unnecessary redrawing. Use this technique if you
12+
have a simple build/bundle workflow. You can still customize the relative
13+
path to the fonts folder using the `fontsDirectory` configuration option.
14+
15+
- **static loading** include the `mathlive-fonts.css` stylesheet in your
16+
page. The loading of this file will trigget the font to be loaded
17+
asynchronously by the browser. Use this technique if you are using
18+
WebPack or have a build/bundle workflow that renames the font files or
19+
in general require the bundler to know about the required assets.
20+
21+
- **New packaging options**. The distribution files have been split between
22+
minified and non-minified version. In the more common cases, the minified
23+
version (`mathlive.min.js` and `mathlive.min.mjs` should be used). The
24+
non-minified version (`mathlive.js` and
25+
`mathlive.mjs` can be used to help in debugging issues or to apply patches).
26+
27+
### Bug Fixes
28+
29+
- The fonts failed to load when loading MathLive using a `<script>` tag and
30+
a CDN. The fonts folder is now resolved correctly with the following configurations:
31+
32+
- `<script>` tag and CDN
33+
- `<script>` tag and local file
34+
- `import` and CDN
35+
- `import` and local file
1736

1837
## 0.54.0 (2020-06-24)
1938

css/fonts.less

+4
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@
6565
.font-face('Size3', normal, normal);
6666
.font-face('Size4', normal, normal);
6767
.font-face('Typewriter', normal, normal);
68+
69+
:root {
70+
--ML__static-fonts: true;
71+
}

dist/math-json/public.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export declare type FunctionDefinition = {
2929
* - **'rest'**: The first argument is evaluated, the others aren't
3030
*/
3131
hold?: 'none' | 'all' | 'first' | 'rest';
32+
/**
33+
* If true, `Sequence` arguments are not automatically spliced in
34+
*/
35+
sequenceHold?: boolean;
3236
/**
3337
* Number of arguments, or minimum or minimum and maximum number of arguments.
3438
*
@@ -213,7 +217,7 @@ export declare type Expression = MathJsonRealNumber | number | MathJsonSymbol |
213217
* - 'full',
214218
*/
215219
export declare type Form = 'canonical' | 'canonical-add' | 'canonical-divide' | 'canonical-exp' | 'canonical-list' | 'canonical-multiply' | 'canonical-power' | 'canonical-negate' | 'canonical-number' | 'canonical-root' | 'canonical-subtract' | 'flatten' | 'full' | 'sorted' | 'stripped-metadata' | 'sum-product';
216-
export declare type DictionaryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'complex' | 'combinatorics' | 'dimensions' | 'intervals' | 'linear-algebra' | 'lists' | 'logic' | 'numeric' | 'quantifiers' | 'physics' | 'polynomials' | 'relations' | 'sets' | 'statistics' | 'core' | 'transcendentals' | 'trigonometry' | 'rounding' | 'units';
220+
export declare type DictionaryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'complex' | 'combinatorics' | 'dimensions' | 'inequalities' | 'intervals' | 'linear-algebra' | 'lists' | 'logic' | 'numeric' | 'other' | 'quantifiers' | 'physics' | 'polynomials' | 'relations' | 'sets' | 'statistics' | 'symbols' | 'core' | 'transcendentals' | 'trigonometry' | 'rounding' | 'units';
217221
/**
218222
* Return a dictionary suitable for the specified category, or `"all"`
219223
* for all categories (`"arithmetic"`, `"algebra"`, etc...).

dist/mathlive-fonts.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mathlive-static.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mathlive.js

+30,135-2
Large diffs are not rendered by default.

dist/mathlive.min.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mathlive.min.mjs

+2
Large diffs are not rendered by default.

dist/mathlive.mjs

+30,127-2
Large diffs are not rendered by default.

dist/public/config.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ export declare type MathfieldConfig = LayoutOptions & EditingOptions & Localizat
705705
* | `'linux.french'` | Linux | French (AZERTY) |
706706
* | `'linux.german'` | Linux | German (QWERTZ) |
707707
*/
708-
export declare type KeyboardLayoutName = 'apple.en-intl' | 'apple.french' | 'apple.german' | 'windows.en-intl' | 'windows.french' | 'windows.german' | 'linux.en' | 'linux.french' | 'linux.german';
708+
export declare type KeyboardLayoutName = 'apple.en-intl' | 'apple.french' | 'apple.german' | 'apple.spanish' | 'windows.en-intl' | 'windows.french' | 'windows.german' | 'windows.spanish' | 'linux.en' | 'linux.french' | 'linux.german' | 'linux.spanish';
709709
/**
710710
* Change the current physical keyboard layout.
711711
*

dist/public/mathlive.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @example
99
* <script type="module">
1010
* // Load the `Mathlive` module from a CDN
11-
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
11+
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.min.mjs';
1212
*
1313
* console.log(MathLive.latexToAST('e^{i\\pi}+1=0'));
1414
* </script>
@@ -79,7 +79,7 @@ export declare function latexToMarkup(text: string, options: {
7979
* ```
8080
* The following code will turn the span into an editable mathfield.
8181
* ```javascript
82-
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
82+
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.min.mjs';
8383
* MathLive.makeMathField('equation');
8484
* ```
8585
* @keywords create, make, mathfield
@@ -317,7 +317,7 @@ export declare type AutoRenderOptions = {
317317
* Read {@tutorial mathfield-getting-started | Getting Started}.
318318
*
319319
* @example
320-
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
320+
* import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.min.mjs';
321321
* document.addEventListener("load", () => {
322322
* MathLive.renderMathInDocument();
323323
* });

examples/basic/index.esm.html

+68-77
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,76 @@
11
<!DOCTYPE html>
22
<html lang="en-US">
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>MathLive Basic Example</title>
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<link rel="stylesheet" href="../style.css" />
8-
</head>
9-
<body>
10-
<header>
11-
<h1>MathLive Basic Example</h1>
12-
</header>
13-
<main>
14-
<div class="mathfield" id="mf">
15-
$$\nexists \exists f(x)+\frac{3i}{y\cdot h}$$
16-
<!-- $$\frac{\text{a\textit{b\textbf{\textsf{c}d}}}}{\mathbf{e\mathit{f}\mathbb{G}}}$$ -->
17-
</div>
18-
<div class="output" id="latex"></div>
19-
<div class="output" id="mathjson"></div>
20-
</main>
213

22-
<footer>
23-
<a
24-
href="https://github.com/arnog/mathlive/tree/master/examples/basic"
25-
><svg
26-
class="fa-w-24"
27-
height="24px"
28-
style="vertical-align: -3px; margin-right: 6px;"
29-
>
30-
<use xlink:href="../icons.svg#github" /></svg
31-
>View source&nbsp;<svg class="fa-w-24" height="24px">
32-
<use xlink:href="../icons.svg#angle-right" /></svg
33-
></a>
34-
<a href="../"
35-
>More examples&nbsp;<svg class="fa-w-24" height="24px">
36-
<use xlink:href="../icons.svg#angle-right" /></svg
37-
></a>
38-
<a href="/"
39-
>Return to the homepage&nbsp;<svg class="fa-w-24" height="24px">
40-
<use xlink:href="../icons.svg#angle-right" /></svg
41-
></a>
42-
</footer>
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>MathLive Basic Example</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<link rel="stylesheet" href="../style.css" />
9+
<!-- <link rel="stylesheet" href="/dist/mathlive-fonts.css" /> -->
10+
</head>
4311

44-
<script type="module">
45-
import MathLive from '/dist/mathlive.mjs';
46-
// import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
12+
<body>
13+
<header>
14+
<h1>MathLive Basic Example</h1>
15+
</header>
16+
<main>
17+
<div class="mathfield" id="mf">f(x)=\frac{\sin(x)}{\cos(x)}
18+
</div>
19+
<div class="output" id="latex"></div>
20+
<div class="output" id="mathjson"></div>
21+
</main>
4722

48-
const mf = MathLive.makeMathField('mf', {
49-
smartMode: true,
50-
virtualKeyboardMode: 'manual',
51-
onContentDidChange: (mf) => {
52-
const latex = mf.$text();
53-
document.getElementById('latex').innerHTML = escapeHtml(
54-
latex
55-
);
23+
<footer>
24+
<a href="https://github.com/arnog/mathlive/tree/master/examples/basic"><svg class="fa-w-24" height="24px"
25+
style="vertical-align: -3px; margin-right: 6px;">
26+
<use xlink:href="../icons.svg#github" /></svg>View source&nbsp;<svg class="fa-w-24" height="24px">
27+
<use xlink:href="../icons.svg#angle-right" /></svg></a>
28+
<a href="../">More examples&nbsp;<svg class="fa-w-24" height="24px">
29+
<use xlink:href="../icons.svg#angle-right" /></svg></a>
30+
<a href="/">Return to the homepage&nbsp;<svg class="fa-w-24" height="24px">
31+
<use xlink:href="../icons.svg#angle-right" /></svg></a>
32+
</footer>
5633

57-
const mathJSON = MathLive.latexToAST(latex);
58-
document.getElementById('mathjson').innerHTML = escapeHtml(
59-
JSON.stringify(mathJSON)
60-
);
61-
},
34+
<script type="module">
35+
import MathLive from '/dist/mathlive.mjs';
36+
// import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.min.mjs';
37+
38+
const mf = MathLive.makeMathField('mf', {
39+
smartMode: true,
40+
virtualKeyboardMode: 'manual',
41+
onContentDidChange: (mf) => {
42+
const latex = mf.$text();
43+
document.getElementById('latex').innerHTML = escapeHtml(
44+
latex
45+
);
46+
47+
const mathJSON = MathLive.latexToAST(latex);
48+
document.getElementById('mathjson').innerHTML = escapeHtml(
49+
JSON.stringify(mathJSON)
50+
);
51+
},
52+
});
53+
54+
function escapeHtml(string) {
55+
return String(string).replace(/[&<>"'`=/\u200b]/g, function (
56+
s
57+
) {
58+
return (
59+
{
60+
'&': '&amp;',
61+
'<': '&lt;',
62+
'>': '&gt;',
63+
'"': '&quot;',
64+
"'": '&#39;',
65+
'/': '&#x2F;',
66+
'`': '&#x60;',
67+
'=': '&#x3D;',
68+
'\u200b': '&amp;#zws;',
69+
}[s] || s
70+
);
6271
});
72+
}
73+
</script>
74+
</body>
6375

64-
function escapeHtml(string) {
65-
return String(string).replace(/[&<>"'`=/\u200b]/g, function (
66-
s
67-
) {
68-
return (
69-
{
70-
'&': '&amp;',
71-
'<': '&lt;',
72-
'>': '&gt;',
73-
'"': '&quot;',
74-
"'": '&#39;',
75-
'/': '&#x2F;',
76-
'`': '&#x60;',
77-
'=': '&#x3D;',
78-
'\u200b': '&amp;#zws;',
79-
}[s] || s
80-
);
81-
});
82-
}
83-
</script>
84-
</body>
85-
</html>
76+
</html>

0 commit comments

Comments
 (0)