@manuel-rhdt/formel-wasm 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +70 -2
- package/THIRD_PARTY.md +22 -0
- package/formel_wasm.d.ts +130 -0
- package/formel_wasm.js +573 -0
- package/formel_wasm_bg.wasm +0 -0
- package/formel_wasm_bg.wasm.d.ts +22 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Manuel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @manuel-rhdt/formel-wasm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Typeset MathML and LaTeX to SVG in the browser with any OpenType **MATH** font, using the layout
|
|
4
|
+
engine of [formel](https://github.com/manuel-rhdt/formel). It implements the OpenType MATH
|
|
5
|
+
specification and [MathML Core](https://www.w3.org/TR/mathml-core/): script and fraction placement,
|
|
6
|
+
stretchy operators, radicals, tables, accents, italic corrections, math kerning.
|
|
7
|
+
|
|
8
|
+
Unlike MathJax or KaTeX this is not a JavaScript typesetter: it shapes text with the MATH font you
|
|
9
|
+
load, so it matches what LuaTeX or XeTeX produce with the same font. The cost is that **you supply
|
|
10
|
+
the font**.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @manuel-rhdt/formel-wasm
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import init, { MathRenderer } from "@manuel-rhdt/formel-wasm";
|
|
22
|
+
|
|
23
|
+
await init();
|
|
24
|
+
|
|
25
|
+
const font = new Uint8Array(await (await fetch("/fonts/latinmodern-math.otf")).arrayBuffer());
|
|
26
|
+
const renderer = new MathRenderer(font);
|
|
27
|
+
|
|
28
|
+
document.querySelector("#formula").innerHTML =
|
|
29
|
+
renderer.render_svg('<math><mfrac><mi>a</mi><mi>b</mi></mfrac></math>');
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`render()` returns the SVG together with its size and the baseline inside it, both in font units
|
|
33
|
+
(`units_per_em()` per em), which is what you need to place a formula inline with text:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
const { svg, width, height, baseline } = renderer.render("<math><mi>x</mi></math>", false);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
LaTeX is converted with [math-core](https://github.com/tmke8/math-core) before it is laid out:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { latex_to_mathml, latex_error_range } from "@manuel-rhdt/formel-wasm";
|
|
43
|
+
|
|
44
|
+
const mathml = latex_to_mathml("\\int_0^1 x^2\\,\\mathrm{d}x", true); // display style
|
|
45
|
+
const range = latex_error_range("\\frac{", true); // [start, end] in UTF-16 units, or undefined
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
All free OpenType MATH fonts work (New Computer Modern, STIX Two, TeX Gyre, Asana, Fira Math, …);
|
|
49
|
+
Cambria Math works too but its license does not allow redistribution.
|
|
50
|
+
|
|
51
|
+
## Bundlers
|
|
52
|
+
|
|
53
|
+
The module is a wasm-bindgen `--target web` build. It loads its `.wasm` relative to itself
|
|
54
|
+
(`import.meta.url`), which Vite, webpack, Rollup and esbuild rewrite for you. If you serve the
|
|
55
|
+
JavaScript and the `.wasm` yourself, make sure the server sends `application/wasm`; otherwise the
|
|
56
|
+
glue falls back to a slower fetch-and-instantiate path.
|
|
57
|
+
|
|
58
|
+
## Without a bundler
|
|
59
|
+
|
|
60
|
+
Both jsDelivr and unpkg serve the ESM build and the module with the right content type:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import init, { MathRenderer } from "https://cdn.jsdelivr.net/npm/@manuel-rhdt/formel-wasm@0.1/+esm";
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Licences
|
|
67
|
+
|
|
68
|
+
MIT for the engine, see [LICENSE](https://github.com/manuel-rhdt/formel/blob/master/LICENSE). The
|
|
69
|
+
WebAssembly binary also contains the MIT and Apache-2.0 licensed crates listed in
|
|
70
|
+
[THIRD_PARTY.md](https://github.com/manuel-rhdt/formel/blob/master/formel-wasm/npm/THIRD_PARTY.md).
|
|
71
|
+
Fonts are not included and keep their own licences.
|
package/THIRD_PARTY.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Third-party licences
|
|
2
|
+
|
|
3
|
+
This package is the MIT-licensed engine of [formel](https://github.com/manuel-rhdt/formel) compiled
|
|
4
|
+
to WebAssembly. The binary therefore contains code from the libraries below; each keeps its own
|
|
5
|
+
licence, and all of them are permissive.
|
|
6
|
+
|
|
7
|
+
| Crate | Licence (SPDX) | Project |
|
|
8
|
+
| :--- | :--- | :--- |
|
|
9
|
+
| [formel](https://crates.io/crates/formel) | MIT | https://github.com/manuel-rhdt/formel |
|
|
10
|
+
| [math-core](https://crates.io/crates/math-core) | MIT | https://github.com/tmke8/math-core |
|
|
11
|
+
| [rustybuzz](https://crates.io/crates/rustybuzz) | MIT | https://github.com/harfbuzz/rustybuzz |
|
|
12
|
+
| [quick-xml](https://crates.io/crates/quick-xml) | MIT | https://github.com/tafia/quick-xml |
|
|
13
|
+
| [svg](https://crates.io/crates/svg) | MIT OR Apache-2.0 | https://github.com/bodoni/svg |
|
|
14
|
+
| [wasm-bindgen](https://crates.io/crates/wasm-bindgen) | MIT OR Apache-2.0 | https://github.com/wasm-bindgen/wasm-bindgen |
|
|
15
|
+
|
|
16
|
+
These in turn depend on the crates pinned in the repository's `Cargo.lock` — `ttf-parser`,
|
|
17
|
+
`unicode-properties`, `phf`, `bitflags` and so on — under MIT, Apache-2.0 or (for `memchr`) the
|
|
18
|
+
Unlicense. `cargo license` or `cargo deny list` prints the exact set with each crate's licence text.
|
|
19
|
+
|
|
20
|
+
The package ships **no fonts**. The OpenType MATH font you load keeps its own licence; see the
|
|
21
|
+
repositories in the [demo's licence list](https://manuel-rhdt.github.io/formel/fonts/LICENSES.html)
|
|
22
|
+
for the free ones and their terms.
|
package/formel_wasm.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Converts LaTeX math (without surrounding `$`) to a MathML string.
|
|
5
|
+
*
|
|
6
|
+
* With `display` set, the formula is typeset in display style (as in `\[ ... \]`).
|
|
7
|
+
*/
|
|
8
|
+
export function latex_to_mathml(latex: string, display: boolean): string;
|
|
9
|
+
/**
|
|
10
|
+
* Where in `latex` the conversion fails, as `[start, end]` in UTF-16 code units (the indices
|
|
11
|
+
* of a JavaScript string, e.g. for `textarea.setSelectionRange`). `undefined` if it converts.
|
|
12
|
+
*/
|
|
13
|
+
export function latex_error_range(latex: string, display: boolean): Uint32Array | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* A math font that can render MathML to SVG.
|
|
16
|
+
*
|
|
17
|
+
* The font bytes are copied once on construction and reused for every call.
|
|
18
|
+
*/
|
|
19
|
+
export class MathRenderer {
|
|
20
|
+
free(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Renders a MathML string (a `<math>` element or a fragment with one root) to an SVG
|
|
23
|
+
* string. The SVG is sized in font design units, so scale it with CSS (`height: 2em`).
|
|
24
|
+
*/
|
|
25
|
+
render_svg(mathml: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* The font's design units per em. The SVG is sized in these units.
|
|
28
|
+
*/
|
|
29
|
+
units_per_em(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Like [`render_svg`](Self::render_svg) but also outlines the box of every element.
|
|
32
|
+
*/
|
|
33
|
+
render_svg_debug(mathml: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Sets OpenType features for all following renders, as a CSS `font-feature-settings`
|
|
36
|
+
* value, for example `"ss03"` (stylistic set 3: the New Computer Modern doublestruck
|
|
37
|
+
* letters) or `"ss01" 1, "cv02" 2`. An empty string or `normal` turns them off. Elements
|
|
38
|
+
* can still override it with `style="font-feature-settings: ..."`.
|
|
39
|
+
*/
|
|
40
|
+
set_font_features(settings: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a renderer from the bytes of an OpenType font with a `MATH` table.
|
|
43
|
+
*/
|
|
44
|
+
constructor(font: Uint8Array);
|
|
45
|
+
/**
|
|
46
|
+
* Renders MathML to SVG together with its size and baseline position.
|
|
47
|
+
*
|
|
48
|
+
* With `debug` set, the box of every element is outlined. Call `free()` on the result
|
|
49
|
+
* after reading it.
|
|
50
|
+
*/
|
|
51
|
+
render(mathml: string, debug: boolean): Rendering;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The result of [`MathRenderer::render`]: the SVG and where the baseline is in it.
|
|
55
|
+
*
|
|
56
|
+
* All lengths are in font design units (see [`MathRenderer::units_per_em`]) and describe the
|
|
57
|
+
* SVG's `viewBox`, margin included. Dividing by `units_per_em` gives em of the font, which is
|
|
58
|
+
* what you need to size an inline image next to text and align it on the baseline.
|
|
59
|
+
*/
|
|
60
|
+
export class Rendering {
|
|
61
|
+
private constructor();
|
|
62
|
+
free(): void;
|
|
63
|
+
/**
|
|
64
|
+
* The formula's accessible name: the author's own text when the MathML carries one, otherwise
|
|
65
|
+
* its text content. Empty when the expression has no text at all.
|
|
66
|
+
*/
|
|
67
|
+
readonly alt: string;
|
|
68
|
+
/**
|
|
69
|
+
* The SVG document.
|
|
70
|
+
*/
|
|
71
|
+
readonly svg: string;
|
|
72
|
+
/**
|
|
73
|
+
* Width of the SVG's `viewBox`.
|
|
74
|
+
*/
|
|
75
|
+
readonly width: number;
|
|
76
|
+
/**
|
|
77
|
+
* Height of the SVG's `viewBox`.
|
|
78
|
+
*/
|
|
79
|
+
readonly height: number;
|
|
80
|
+
/**
|
|
81
|
+
* Distance from the top of the SVG's `viewBox` to the formula's alphabetic baseline.
|
|
82
|
+
*/
|
|
83
|
+
readonly baseline: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
87
|
+
|
|
88
|
+
export interface InitOutput {
|
|
89
|
+
readonly memory: WebAssembly.Memory;
|
|
90
|
+
readonly __wbg_mathrenderer_free: (a: number, b: number) => void;
|
|
91
|
+
readonly __wbg_rendering_free: (a: number, b: number) => void;
|
|
92
|
+
readonly latex_error_range: (a: number, b: number, c: number, d: number) => void;
|
|
93
|
+
readonly latex_to_mathml: (a: number, b: number, c: number, d: number) => void;
|
|
94
|
+
readonly mathrenderer_new: (a: number, b: number, c: number) => void;
|
|
95
|
+
readonly mathrenderer_render: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
96
|
+
readonly mathrenderer_render_svg: (a: number, b: number, c: number, d: number) => void;
|
|
97
|
+
readonly mathrenderer_render_svg_debug: (a: number, b: number, c: number, d: number) => void;
|
|
98
|
+
readonly mathrenderer_set_font_features: (a: number, b: number, c: number, d: number) => void;
|
|
99
|
+
readonly mathrenderer_units_per_em: (a: number) => number;
|
|
100
|
+
readonly rendering_alt: (a: number, b: number) => void;
|
|
101
|
+
readonly rendering_baseline: (a: number) => number;
|
|
102
|
+
readonly rendering_height: (a: number) => number;
|
|
103
|
+
readonly rendering_svg: (a: number, b: number) => void;
|
|
104
|
+
readonly rendering_width: (a: number) => number;
|
|
105
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
106
|
+
readonly __wbindgen_export_0: (a: number, b: number) => number;
|
|
107
|
+
readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
|
|
108
|
+
readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
112
|
+
/**
|
|
113
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
114
|
+
* a precompiled `WebAssembly.Module`.
|
|
115
|
+
*
|
|
116
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
117
|
+
*
|
|
118
|
+
* @returns {InitOutput}
|
|
119
|
+
*/
|
|
120
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
124
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
125
|
+
*
|
|
126
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
127
|
+
*
|
|
128
|
+
* @returns {Promise<InitOutput>}
|
|
129
|
+
*/
|
|
130
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/formel_wasm.js
ADDED
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
4
|
+
|
|
5
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
6
|
+
|
|
7
|
+
let cachedUint8ArrayMemory0 = null;
|
|
8
|
+
|
|
9
|
+
function getUint8ArrayMemory0() {
|
|
10
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
11
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
12
|
+
}
|
|
13
|
+
return cachedUint8ArrayMemory0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getStringFromWasm0(ptr, len) {
|
|
17
|
+
ptr = ptr >>> 0;
|
|
18
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const heap = new Array(128).fill(undefined);
|
|
22
|
+
|
|
23
|
+
heap.push(undefined, null, true, false);
|
|
24
|
+
|
|
25
|
+
let heap_next = heap.length;
|
|
26
|
+
|
|
27
|
+
function addHeapObject(obj) {
|
|
28
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
29
|
+
const idx = heap_next;
|
|
30
|
+
heap_next = heap[idx];
|
|
31
|
+
|
|
32
|
+
heap[idx] = obj;
|
|
33
|
+
return idx;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let WASM_VECTOR_LEN = 0;
|
|
37
|
+
|
|
38
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
39
|
+
|
|
40
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
41
|
+
? function (arg, view) {
|
|
42
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
43
|
+
}
|
|
44
|
+
: function (arg, view) {
|
|
45
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
46
|
+
view.set(buf);
|
|
47
|
+
return {
|
|
48
|
+
read: arg.length,
|
|
49
|
+
written: buf.length
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
54
|
+
|
|
55
|
+
if (realloc === undefined) {
|
|
56
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
57
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
58
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
59
|
+
WASM_VECTOR_LEN = buf.length;
|
|
60
|
+
return ptr;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let len = arg.length;
|
|
64
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
65
|
+
|
|
66
|
+
const mem = getUint8ArrayMemory0();
|
|
67
|
+
|
|
68
|
+
let offset = 0;
|
|
69
|
+
|
|
70
|
+
for (; offset < len; offset++) {
|
|
71
|
+
const code = arg.charCodeAt(offset);
|
|
72
|
+
if (code > 0x7F) break;
|
|
73
|
+
mem[ptr + offset] = code;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (offset !== len) {
|
|
77
|
+
if (offset !== 0) {
|
|
78
|
+
arg = arg.slice(offset);
|
|
79
|
+
}
|
|
80
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
81
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
82
|
+
const ret = encodeString(arg, view);
|
|
83
|
+
|
|
84
|
+
offset += ret.written;
|
|
85
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
WASM_VECTOR_LEN = offset;
|
|
89
|
+
return ptr;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let cachedDataViewMemory0 = null;
|
|
93
|
+
|
|
94
|
+
function getDataViewMemory0() {
|
|
95
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
96
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
97
|
+
}
|
|
98
|
+
return cachedDataViewMemory0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function getObject(idx) { return heap[idx]; }
|
|
102
|
+
|
|
103
|
+
function dropObject(idx) {
|
|
104
|
+
if (idx < 132) return;
|
|
105
|
+
heap[idx] = heap_next;
|
|
106
|
+
heap_next = idx;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function takeObject(idx) {
|
|
110
|
+
const ret = getObject(idx);
|
|
111
|
+
dropObject(idx);
|
|
112
|
+
return ret;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Converts LaTeX math (without surrounding `$`) to a MathML string.
|
|
116
|
+
*
|
|
117
|
+
* With `display` set, the formula is typeset in display style (as in `\[ ... \]`).
|
|
118
|
+
* @param {string} latex
|
|
119
|
+
* @param {boolean} display
|
|
120
|
+
* @returns {string}
|
|
121
|
+
*/
|
|
122
|
+
export function latex_to_mathml(latex, display) {
|
|
123
|
+
let deferred3_0;
|
|
124
|
+
let deferred3_1;
|
|
125
|
+
try {
|
|
126
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
127
|
+
const ptr0 = passStringToWasm0(latex, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
128
|
+
const len0 = WASM_VECTOR_LEN;
|
|
129
|
+
wasm.latex_to_mathml(retptr, ptr0, len0, display);
|
|
130
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
131
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
132
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
133
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
134
|
+
var ptr2 = r0;
|
|
135
|
+
var len2 = r1;
|
|
136
|
+
if (r3) {
|
|
137
|
+
ptr2 = 0; len2 = 0;
|
|
138
|
+
throw takeObject(r2);
|
|
139
|
+
}
|
|
140
|
+
deferred3_0 = ptr2;
|
|
141
|
+
deferred3_1 = len2;
|
|
142
|
+
return getStringFromWasm0(ptr2, len2);
|
|
143
|
+
} finally {
|
|
144
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
145
|
+
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let cachedUint32ArrayMemory0 = null;
|
|
150
|
+
|
|
151
|
+
function getUint32ArrayMemory0() {
|
|
152
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
153
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
154
|
+
}
|
|
155
|
+
return cachedUint32ArrayMemory0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
159
|
+
ptr = ptr >>> 0;
|
|
160
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Where in `latex` the conversion fails, as `[start, end]` in UTF-16 code units (the indices
|
|
164
|
+
* of a JavaScript string, e.g. for `textarea.setSelectionRange`). `undefined` if it converts.
|
|
165
|
+
* @param {string} latex
|
|
166
|
+
* @param {boolean} display
|
|
167
|
+
* @returns {Uint32Array | undefined}
|
|
168
|
+
*/
|
|
169
|
+
export function latex_error_range(latex, display) {
|
|
170
|
+
try {
|
|
171
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
172
|
+
const ptr0 = passStringToWasm0(latex, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
173
|
+
const len0 = WASM_VECTOR_LEN;
|
|
174
|
+
wasm.latex_error_range(retptr, ptr0, len0, display);
|
|
175
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
176
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
177
|
+
let v2;
|
|
178
|
+
if (r0 !== 0) {
|
|
179
|
+
v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
180
|
+
wasm.__wbindgen_export_2(r0, r1 * 4, 4);
|
|
181
|
+
}
|
|
182
|
+
return v2;
|
|
183
|
+
} finally {
|
|
184
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
189
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
190
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
191
|
+
WASM_VECTOR_LEN = arg.length;
|
|
192
|
+
return ptr;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const MathRendererFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
196
|
+
? { register: () => {}, unregister: () => {} }
|
|
197
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mathrenderer_free(ptr >>> 0, 1));
|
|
198
|
+
/**
|
|
199
|
+
* A math font that can render MathML to SVG.
|
|
200
|
+
*
|
|
201
|
+
* The font bytes are copied once on construction and reused for every call.
|
|
202
|
+
*/
|
|
203
|
+
export class MathRenderer {
|
|
204
|
+
|
|
205
|
+
__destroy_into_raw() {
|
|
206
|
+
const ptr = this.__wbg_ptr;
|
|
207
|
+
this.__wbg_ptr = 0;
|
|
208
|
+
MathRendererFinalization.unregister(this);
|
|
209
|
+
return ptr;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
free() {
|
|
213
|
+
const ptr = this.__destroy_into_raw();
|
|
214
|
+
wasm.__wbg_mathrenderer_free(ptr, 0);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Renders a MathML string (a `<math>` element or a fragment with one root) to an SVG
|
|
218
|
+
* string. The SVG is sized in font design units, so scale it with CSS (`height: 2em`).
|
|
219
|
+
* @param {string} mathml
|
|
220
|
+
* @returns {string}
|
|
221
|
+
*/
|
|
222
|
+
render_svg(mathml) {
|
|
223
|
+
let deferred3_0;
|
|
224
|
+
let deferred3_1;
|
|
225
|
+
try {
|
|
226
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
227
|
+
const ptr0 = passStringToWasm0(mathml, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
228
|
+
const len0 = WASM_VECTOR_LEN;
|
|
229
|
+
wasm.mathrenderer_render_svg(retptr, this.__wbg_ptr, ptr0, len0);
|
|
230
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
231
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
232
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
233
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
234
|
+
var ptr2 = r0;
|
|
235
|
+
var len2 = r1;
|
|
236
|
+
if (r3) {
|
|
237
|
+
ptr2 = 0; len2 = 0;
|
|
238
|
+
throw takeObject(r2);
|
|
239
|
+
}
|
|
240
|
+
deferred3_0 = ptr2;
|
|
241
|
+
deferred3_1 = len2;
|
|
242
|
+
return getStringFromWasm0(ptr2, len2);
|
|
243
|
+
} finally {
|
|
244
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
245
|
+
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* The font's design units per em. The SVG is sized in these units.
|
|
250
|
+
* @returns {number}
|
|
251
|
+
*/
|
|
252
|
+
units_per_em() {
|
|
253
|
+
const ret = wasm.mathrenderer_units_per_em(this.__wbg_ptr);
|
|
254
|
+
return ret >>> 0;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Like [`render_svg`](Self::render_svg) but also outlines the box of every element.
|
|
258
|
+
* @param {string} mathml
|
|
259
|
+
* @returns {string}
|
|
260
|
+
*/
|
|
261
|
+
render_svg_debug(mathml) {
|
|
262
|
+
let deferred3_0;
|
|
263
|
+
let deferred3_1;
|
|
264
|
+
try {
|
|
265
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
266
|
+
const ptr0 = passStringToWasm0(mathml, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
267
|
+
const len0 = WASM_VECTOR_LEN;
|
|
268
|
+
wasm.mathrenderer_render_svg_debug(retptr, this.__wbg_ptr, ptr0, len0);
|
|
269
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
270
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
271
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
272
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
273
|
+
var ptr2 = r0;
|
|
274
|
+
var len2 = r1;
|
|
275
|
+
if (r3) {
|
|
276
|
+
ptr2 = 0; len2 = 0;
|
|
277
|
+
throw takeObject(r2);
|
|
278
|
+
}
|
|
279
|
+
deferred3_0 = ptr2;
|
|
280
|
+
deferred3_1 = len2;
|
|
281
|
+
return getStringFromWasm0(ptr2, len2);
|
|
282
|
+
} finally {
|
|
283
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
284
|
+
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Sets OpenType features for all following renders, as a CSS `font-feature-settings`
|
|
289
|
+
* value, for example `"ss03"` (stylistic set 3: the New Computer Modern doublestruck
|
|
290
|
+
* letters) or `"ss01" 1, "cv02" 2`. An empty string or `normal` turns them off. Elements
|
|
291
|
+
* can still override it with `style="font-feature-settings: ..."`.
|
|
292
|
+
* @param {string} settings
|
|
293
|
+
*/
|
|
294
|
+
set_font_features(settings) {
|
|
295
|
+
try {
|
|
296
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
297
|
+
const ptr0 = passStringToWasm0(settings, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
298
|
+
const len0 = WASM_VECTOR_LEN;
|
|
299
|
+
wasm.mathrenderer_set_font_features(retptr, this.__wbg_ptr, ptr0, len0);
|
|
300
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
301
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
302
|
+
if (r1) {
|
|
303
|
+
throw takeObject(r0);
|
|
304
|
+
}
|
|
305
|
+
} finally {
|
|
306
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Creates a renderer from the bytes of an OpenType font with a `MATH` table.
|
|
311
|
+
* @param {Uint8Array} font
|
|
312
|
+
*/
|
|
313
|
+
constructor(font) {
|
|
314
|
+
try {
|
|
315
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
316
|
+
const ptr0 = passArray8ToWasm0(font, wasm.__wbindgen_export_0);
|
|
317
|
+
const len0 = WASM_VECTOR_LEN;
|
|
318
|
+
wasm.mathrenderer_new(retptr, ptr0, len0);
|
|
319
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
320
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
321
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
322
|
+
if (r2) {
|
|
323
|
+
throw takeObject(r1);
|
|
324
|
+
}
|
|
325
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
326
|
+
MathRendererFinalization.register(this, this.__wbg_ptr, this);
|
|
327
|
+
return this;
|
|
328
|
+
} finally {
|
|
329
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Renders MathML to SVG together with its size and baseline position.
|
|
334
|
+
*
|
|
335
|
+
* With `debug` set, the box of every element is outlined. Call `free()` on the result
|
|
336
|
+
* after reading it.
|
|
337
|
+
* @param {string} mathml
|
|
338
|
+
* @param {boolean} debug
|
|
339
|
+
* @returns {Rendering}
|
|
340
|
+
*/
|
|
341
|
+
render(mathml, debug) {
|
|
342
|
+
try {
|
|
343
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
344
|
+
const ptr0 = passStringToWasm0(mathml, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
345
|
+
const len0 = WASM_VECTOR_LEN;
|
|
346
|
+
wasm.mathrenderer_render(retptr, this.__wbg_ptr, ptr0, len0, debug);
|
|
347
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
348
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
349
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
350
|
+
if (r2) {
|
|
351
|
+
throw takeObject(r1);
|
|
352
|
+
}
|
|
353
|
+
return Rendering.__wrap(r0);
|
|
354
|
+
} finally {
|
|
355
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const RenderingFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
361
|
+
? { register: () => {}, unregister: () => {} }
|
|
362
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rendering_free(ptr >>> 0, 1));
|
|
363
|
+
/**
|
|
364
|
+
* The result of [`MathRenderer::render`]: the SVG and where the baseline is in it.
|
|
365
|
+
*
|
|
366
|
+
* All lengths are in font design units (see [`MathRenderer::units_per_em`]) and describe the
|
|
367
|
+
* SVG's `viewBox`, margin included. Dividing by `units_per_em` gives em of the font, which is
|
|
368
|
+
* what you need to size an inline image next to text and align it on the baseline.
|
|
369
|
+
*/
|
|
370
|
+
export class Rendering {
|
|
371
|
+
|
|
372
|
+
static __wrap(ptr) {
|
|
373
|
+
ptr = ptr >>> 0;
|
|
374
|
+
const obj = Object.create(Rendering.prototype);
|
|
375
|
+
obj.__wbg_ptr = ptr;
|
|
376
|
+
RenderingFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
377
|
+
return obj;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
__destroy_into_raw() {
|
|
381
|
+
const ptr = this.__wbg_ptr;
|
|
382
|
+
this.__wbg_ptr = 0;
|
|
383
|
+
RenderingFinalization.unregister(this);
|
|
384
|
+
return ptr;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
free() {
|
|
388
|
+
const ptr = this.__destroy_into_raw();
|
|
389
|
+
wasm.__wbg_rendering_free(ptr, 0);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The formula's accessible name: the author's own text when the MathML carries one, otherwise
|
|
393
|
+
* its text content. Empty when the expression has no text at all.
|
|
394
|
+
* @returns {string}
|
|
395
|
+
*/
|
|
396
|
+
get alt() {
|
|
397
|
+
let deferred1_0;
|
|
398
|
+
let deferred1_1;
|
|
399
|
+
try {
|
|
400
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
401
|
+
wasm.rendering_alt(retptr, this.__wbg_ptr);
|
|
402
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
403
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
404
|
+
deferred1_0 = r0;
|
|
405
|
+
deferred1_1 = r1;
|
|
406
|
+
return getStringFromWasm0(r0, r1);
|
|
407
|
+
} finally {
|
|
408
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
409
|
+
wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The SVG document.
|
|
414
|
+
* @returns {string}
|
|
415
|
+
*/
|
|
416
|
+
get svg() {
|
|
417
|
+
let deferred1_0;
|
|
418
|
+
let deferred1_1;
|
|
419
|
+
try {
|
|
420
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
421
|
+
wasm.rendering_svg(retptr, this.__wbg_ptr);
|
|
422
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
423
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
424
|
+
deferred1_0 = r0;
|
|
425
|
+
deferred1_1 = r1;
|
|
426
|
+
return getStringFromWasm0(r0, r1);
|
|
427
|
+
} finally {
|
|
428
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
429
|
+
wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Width of the SVG's `viewBox`.
|
|
434
|
+
* @returns {number}
|
|
435
|
+
*/
|
|
436
|
+
get width() {
|
|
437
|
+
const ret = wasm.rendering_width(this.__wbg_ptr);
|
|
438
|
+
return ret;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Height of the SVG's `viewBox`.
|
|
442
|
+
* @returns {number}
|
|
443
|
+
*/
|
|
444
|
+
get height() {
|
|
445
|
+
const ret = wasm.rendering_height(this.__wbg_ptr);
|
|
446
|
+
return ret;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Distance from the top of the SVG's `viewBox` to the formula's alphabetic baseline.
|
|
450
|
+
* @returns {number}
|
|
451
|
+
*/
|
|
452
|
+
get baseline() {
|
|
453
|
+
const ret = wasm.rendering_baseline(this.__wbg_ptr);
|
|
454
|
+
return ret;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async function __wbg_load(module, imports) {
|
|
459
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
460
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
461
|
+
try {
|
|
462
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
463
|
+
|
|
464
|
+
} catch (e) {
|
|
465
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
466
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
467
|
+
|
|
468
|
+
} else {
|
|
469
|
+
throw e;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const bytes = await module.arrayBuffer();
|
|
475
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
476
|
+
|
|
477
|
+
} else {
|
|
478
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
479
|
+
|
|
480
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
481
|
+
return { instance, module };
|
|
482
|
+
|
|
483
|
+
} else {
|
|
484
|
+
return instance;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function __wbg_get_imports() {
|
|
490
|
+
const imports = {};
|
|
491
|
+
imports.wbg = {};
|
|
492
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
493
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
494
|
+
return addHeapObject(ret);
|
|
495
|
+
};
|
|
496
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
497
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
return imports;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function __wbg_init_memory(imports, memory) {
|
|
504
|
+
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function __wbg_finalize_init(instance, module) {
|
|
508
|
+
wasm = instance.exports;
|
|
509
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
510
|
+
cachedDataViewMemory0 = null;
|
|
511
|
+
cachedUint32ArrayMemory0 = null;
|
|
512
|
+
cachedUint8ArrayMemory0 = null;
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
return wasm;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function initSync(module) {
|
|
520
|
+
if (wasm !== undefined) return wasm;
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
if (typeof module !== 'undefined') {
|
|
524
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
525
|
+
({module} = module)
|
|
526
|
+
} else {
|
|
527
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const imports = __wbg_get_imports();
|
|
532
|
+
|
|
533
|
+
__wbg_init_memory(imports);
|
|
534
|
+
|
|
535
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
536
|
+
module = new WebAssembly.Module(module);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
540
|
+
|
|
541
|
+
return __wbg_finalize_init(instance, module);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
async function __wbg_init(module_or_path) {
|
|
545
|
+
if (wasm !== undefined) return wasm;
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
if (typeof module_or_path !== 'undefined') {
|
|
549
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
550
|
+
({module_or_path} = module_or_path)
|
|
551
|
+
} else {
|
|
552
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if (typeof module_or_path === 'undefined') {
|
|
557
|
+
module_or_path = new URL('formel_wasm_bg.wasm', import.meta.url);
|
|
558
|
+
}
|
|
559
|
+
const imports = __wbg_get_imports();
|
|
560
|
+
|
|
561
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
562
|
+
module_or_path = fetch(module_or_path);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
__wbg_init_memory(imports);
|
|
566
|
+
|
|
567
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
568
|
+
|
|
569
|
+
return __wbg_finalize_init(instance, module);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export { initSync };
|
|
573
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_mathrenderer_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_rendering_free: (a: number, b: number) => void;
|
|
6
|
+
export const latex_error_range: (a: number, b: number, c: number, d: number) => void;
|
|
7
|
+
export const latex_to_mathml: (a: number, b: number, c: number, d: number) => void;
|
|
8
|
+
export const mathrenderer_new: (a: number, b: number, c: number) => void;
|
|
9
|
+
export const mathrenderer_render: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
|
+
export const mathrenderer_render_svg: (a: number, b: number, c: number, d: number) => void;
|
|
11
|
+
export const mathrenderer_render_svg_debug: (a: number, b: number, c: number, d: number) => void;
|
|
12
|
+
export const mathrenderer_set_font_features: (a: number, b: number, c: number, d: number) => void;
|
|
13
|
+
export const mathrenderer_units_per_em: (a: number) => number;
|
|
14
|
+
export const rendering_alt: (a: number, b: number) => void;
|
|
15
|
+
export const rendering_baseline: (a: number) => number;
|
|
16
|
+
export const rendering_height: (a: number) => number;
|
|
17
|
+
export const rendering_svg: (a: number, b: number) => void;
|
|
18
|
+
export const rendering_width: (a: number) => number;
|
|
19
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
20
|
+
export const __wbindgen_export_0: (a: number, b: number) => number;
|
|
21
|
+
export const __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
|
|
22
|
+
export const __wbindgen_export_2: (a: number, b: number, c: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuel-rhdt/formel-wasm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Typeset MathML and LaTeX to SVG in the browser with an OpenType MATH font",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Manuel Reinhardt <manuel.jr16@gmail.com>",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "formel_wasm.js",
|
|
9
|
+
"module": "formel_wasm.js",
|
|
10
|
+
"types": "formel_wasm.d.ts",
|
|
11
|
+
"jsdelivr": "formel_wasm.js",
|
|
12
|
+
"unpkg": "formel_wasm.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./formel_wasm.d.ts",
|
|
16
|
+
"default": "./formel_wasm.js"
|
|
17
|
+
},
|
|
18
|
+
"./formel_wasm_bg.wasm": "./formel_wasm_bg.wasm",
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"formel_wasm.js",
|
|
23
|
+
"formel_wasm.d.ts",
|
|
24
|
+
"formel_wasm_bg.wasm",
|
|
25
|
+
"formel_wasm_bg.wasm.d.ts",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"THIRD_PARTY.md"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"provenance": true
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/manuel-rhdt/formel.git",
|
|
41
|
+
"directory": "formel-wasm"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://manuel-rhdt.github.io/formel/",
|
|
44
|
+
"bugs": "https://github.com/manuel-rhdt/formel/issues",
|
|
45
|
+
"keywords": [
|
|
46
|
+
"mathml",
|
|
47
|
+
"latex",
|
|
48
|
+
"math",
|
|
49
|
+
"typesetting",
|
|
50
|
+
"svg",
|
|
51
|
+
"webassembly",
|
|
52
|
+
"wasm",
|
|
53
|
+
"opentype-math"
|
|
54
|
+
]
|
|
55
|
+
}
|