@docmux/wasm 0.1.0
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 +165 -0
- package/bundler/docmux_wasm.d.ts +57 -0
- package/bundler/docmux_wasm.js +9 -0
- package/bundler/docmux_wasm_bg.js +445 -0
- package/bundler/docmux_wasm_bg.wasm +0 -0
- package/bundler/docmux_wasm_bg.wasm.d.ts +16 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.node.d.ts +19 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +38 -0
- package/dist/raw.d.ts +2 -0
- package/dist/raw.d.ts.map +1 -0
- package/dist/raw.js +1 -0
- package/node/docmux_wasm.d.ts +57 -0
- package/node/docmux_wasm.js +463 -0
- package/node/docmux_wasm_bg.wasm +0 -0
- package/node/docmux_wasm_bg.wasm.d.ts +16 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 docmux contributors
|
|
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
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @docmux/wasm
|
|
2
|
+
|
|
3
|
+
Universal document converter — WASM bindings for [docmux](https://github.com/aguschirico/docmux).
|
|
4
|
+
|
|
5
|
+
Convert between Markdown, LaTeX, Typst, MyST, HTML, DOCX, and plaintext in the browser or Node.js.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @docmux/wasm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { convert, convertStandalone } from "@docmux/wasm";
|
|
17
|
+
|
|
18
|
+
// Fragment conversion (no document wrapper)
|
|
19
|
+
const result = await convert("# Hello\n\nWorld!", "markdown", "html");
|
|
20
|
+
if (result.error) {
|
|
21
|
+
console.error(result.error);
|
|
22
|
+
} else {
|
|
23
|
+
console.log(result.output);
|
|
24
|
+
// <h1>Hello</h1>
|
|
25
|
+
// <p>World!</p>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Standalone conversion (full HTML document with <head>, <body>, etc.)
|
|
29
|
+
const doc = await convertStandalone("# Hello", "markdown", "html");
|
|
30
|
+
// Returns a complete HTML page with doctype, head, body
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Format conversion examples
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { convert } from "@docmux/wasm";
|
|
37
|
+
|
|
38
|
+
// Markdown → HTML
|
|
39
|
+
await convert("**bold** and *italic*", "markdown", "html");
|
|
40
|
+
|
|
41
|
+
// Markdown → LaTeX
|
|
42
|
+
await convert("# Chapter\n\nSome text.", "markdown", "latex");
|
|
43
|
+
|
|
44
|
+
// LaTeX → HTML
|
|
45
|
+
await convert("\\textbf{bold} and \\textit{italic}", "latex", "html");
|
|
46
|
+
|
|
47
|
+
// Typst → Markdown
|
|
48
|
+
await convert("= Heading\nSome *emphasized* text.", "typst", "markdown");
|
|
49
|
+
|
|
50
|
+
// HTML → Plaintext
|
|
51
|
+
await convert("<h1>Title</h1><p>Content</p>", "html", "plaintext");
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Binary formats (DOCX)
|
|
55
|
+
|
|
56
|
+
DOCX files are binary — use the `Bytes` variants with `Uint8Array` input:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { convertBytes, convertBytesStandalone, parseBytesToJson } from "@docmux/wasm";
|
|
60
|
+
|
|
61
|
+
// From a File input
|
|
62
|
+
const file = document.querySelector("input[type=file]").files[0];
|
|
63
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
64
|
+
|
|
65
|
+
// DOCX → HTML
|
|
66
|
+
const result = await convertBytes(bytes, "docx", "html");
|
|
67
|
+
|
|
68
|
+
// DOCX → Standalone HTML (full page)
|
|
69
|
+
const standalone = await convertBytesStandalone(bytes, "docx", "html");
|
|
70
|
+
|
|
71
|
+
// DOCX → AST JSON (inspect the parsed structure)
|
|
72
|
+
const ast = await parseBytesToJson(bytes, "docx");
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Parsing to AST
|
|
76
|
+
|
|
77
|
+
Inspect the parsed document structure as JSON:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { parseToJson } from "@docmux/wasm";
|
|
81
|
+
|
|
82
|
+
const ast = await parseToJson("# Hello\n\n- item 1\n- item 2", "markdown");
|
|
83
|
+
if (!ast.error) {
|
|
84
|
+
console.log(JSON.parse(ast.output));
|
|
85
|
+
// { blocks: [{ Heading: { level: 1, ... } }, { List: { ... } }], meta: { ... } }
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Supported formats
|
|
90
|
+
|
|
91
|
+
| Format | Input name | Reader | Writer |
|
|
92
|
+
|--------|-----------|--------|--------|
|
|
93
|
+
| Markdown (CommonMark + GFM) | `"markdown"` or `"md"` | ✅ | ✅ |
|
|
94
|
+
| HTML5 | `"html"` | ✅ | ✅ |
|
|
95
|
+
| LaTeX | `"latex"` or `"tex"` | ✅ | ✅ |
|
|
96
|
+
| Typst | `"typst"` | ✅ | ✅ |
|
|
97
|
+
| MyST Markdown | `"myst"` | ✅ | — |
|
|
98
|
+
| DOCX (binary) | `"docx"` | ✅ | ✅ |
|
|
99
|
+
| Plaintext | `"plaintext"` or `"txt"` | — | ✅ |
|
|
100
|
+
|
|
101
|
+
List formats programmatically:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { getInputFormats, getOutputFormats } from "@docmux/wasm";
|
|
105
|
+
|
|
106
|
+
const inputs = await getInputFormats(); // ["markdown", "md", "latex", ...]
|
|
107
|
+
const outputs = await getOutputFormats(); // ["html", "latex", "typst", ...]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Error handling
|
|
111
|
+
|
|
112
|
+
All functions return a `ConvertOutcome` discriminated union:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
type ConvertOutcome = ConversionResult | ConversionError;
|
|
116
|
+
|
|
117
|
+
interface ConversionResult {
|
|
118
|
+
output: string;
|
|
119
|
+
error: null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface ConversionError {
|
|
123
|
+
output: null;
|
|
124
|
+
error: string; // Human-readable error message
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Check `result.error` to narrow the type:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const result = await convert(input, "markdown", "html");
|
|
132
|
+
if (result.error) {
|
|
133
|
+
// result is ConversionError — result.output is null
|
|
134
|
+
showError(result.error);
|
|
135
|
+
} else {
|
|
136
|
+
// result is ConversionResult — result.output is string
|
|
137
|
+
render(result.output);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Raw bindings
|
|
142
|
+
|
|
143
|
+
For advanced use cases, import directly from `@docmux/wasm/raw` to get the raw wasm-bindgen functions without the wrapper:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { convert, inputFormats } from "@docmux/wasm/raw";
|
|
147
|
+
|
|
148
|
+
// Functions are synchronous and throw on error (no ConvertOutcome wrapper)
|
|
149
|
+
try {
|
|
150
|
+
const html = convert("# Hello", "markdown", "html");
|
|
151
|
+
} catch (e) {
|
|
152
|
+
console.error("Conversion failed:", e);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const formats = inputFormats(); // string[]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Environment support
|
|
159
|
+
|
|
160
|
+
- **Bundler** (Vite, Webpack, etc.) — import normally, the bundler handles `.wasm` loading
|
|
161
|
+
- **Node.js** — WASM loads automatically from the filesystem
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT — see [LICENSE](https://github.com/aguschirico/docmux/blob/main/LICENSE).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Convert a document from one format to another (fragment mode).
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* - `input` — the source document as a string
|
|
9
|
+
* - `from` — input format name or extension (e.g. `"markdown"`, `"md"`)
|
|
10
|
+
* - `to` — output format name or extension (e.g. `"html"`)
|
|
11
|
+
*/
|
|
12
|
+
export function convert(input: string, from: string, to: string): string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Convert binary input (e.g. DOCX bytes) to another format (fragment mode).
|
|
16
|
+
*
|
|
17
|
+
* # Arguments
|
|
18
|
+
* - `input` — the raw binary content (e.g. DOCX bytes from `FileReader`)
|
|
19
|
+
* - `from` — input format name or extension (e.g. `"docx"`)
|
|
20
|
+
* - `to` — output format name or extension (e.g. `"html"`)
|
|
21
|
+
*/
|
|
22
|
+
export function convertBytes(input: Uint8Array, from: string, to: string): string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Convert binary input producing a standalone file (full HTML, LaTeX with preamble, etc.).
|
|
26
|
+
*/
|
|
27
|
+
export function convertBytesStandalone(input: Uint8Array, from: string, to: string): string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Convert a document producing a standalone file (full HTML document, LaTeX with preamble, etc.).
|
|
31
|
+
*/
|
|
32
|
+
export function convertStandalone(input: string, from: string, to: string): string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Return a list of supported input format names.
|
|
36
|
+
*/
|
|
37
|
+
export function inputFormats(): string[];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Convert markdown to HTML (convenience wrapper).
|
|
41
|
+
*/
|
|
42
|
+
export function markdownToHtml(input: string): string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Return a list of supported output format names.
|
|
46
|
+
*/
|
|
47
|
+
export function outputFormats(): string[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Parse binary input and return the AST as pretty-printed JSON.
|
|
51
|
+
*/
|
|
52
|
+
export function parseBytesToJson(input: Uint8Array, from: string): string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Parse a document and return the AST as pretty-printed JSON.
|
|
56
|
+
*/
|
|
57
|
+
export function parseToJson(input: string, from: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./docmux_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
import * as wasm from "./docmux_wasm_bg.wasm";
|
|
4
|
+
import { __wbg_set_wasm } from "./docmux_wasm_bg.js";
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
convert, convertBytes, convertBytesStandalone, convertStandalone, inputFormats, markdownToHtml, outputFormats, parseBytesToJson, parseToJson
|
|
9
|
+
} from "./docmux_wasm_bg.js";
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a document from one format to another (fragment mode).
|
|
3
|
+
*
|
|
4
|
+
* # Arguments
|
|
5
|
+
* - `input` — the source document as a string
|
|
6
|
+
* - `from` — input format name or extension (e.g. `"markdown"`, `"md"`)
|
|
7
|
+
* - `to` — output format name or extension (e.g. `"html"`)
|
|
8
|
+
* @param {string} input
|
|
9
|
+
* @param {string} from
|
|
10
|
+
* @param {string} to
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
export function convert(input, from, to) {
|
|
14
|
+
let deferred5_0;
|
|
15
|
+
let deferred5_1;
|
|
16
|
+
try {
|
|
17
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
19
|
+
const len0 = WASM_VECTOR_LEN;
|
|
20
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
21
|
+
const len1 = WASM_VECTOR_LEN;
|
|
22
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
23
|
+
const len2 = WASM_VECTOR_LEN;
|
|
24
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
25
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
26
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
27
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
28
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
29
|
+
var ptr4 = r0;
|
|
30
|
+
var len4 = r1;
|
|
31
|
+
if (r3) {
|
|
32
|
+
ptr4 = 0; len4 = 0;
|
|
33
|
+
throw takeObject(r2);
|
|
34
|
+
}
|
|
35
|
+
deferred5_0 = ptr4;
|
|
36
|
+
deferred5_1 = len4;
|
|
37
|
+
return getStringFromWasm0(ptr4, len4);
|
|
38
|
+
} finally {
|
|
39
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
40
|
+
wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Convert binary input (e.g. DOCX bytes) to another format (fragment mode).
|
|
46
|
+
*
|
|
47
|
+
* # Arguments
|
|
48
|
+
* - `input` — the raw binary content (e.g. DOCX bytes from `FileReader`)
|
|
49
|
+
* - `from` — input format name or extension (e.g. `"docx"`)
|
|
50
|
+
* - `to` — output format name or extension (e.g. `"html"`)
|
|
51
|
+
* @param {Uint8Array} input
|
|
52
|
+
* @param {string} from
|
|
53
|
+
* @param {string} to
|
|
54
|
+
* @returns {string}
|
|
55
|
+
*/
|
|
56
|
+
export function convertBytes(input, from, to) {
|
|
57
|
+
let deferred5_0;
|
|
58
|
+
let deferred5_1;
|
|
59
|
+
try {
|
|
60
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
61
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
62
|
+
const len0 = WASM_VECTOR_LEN;
|
|
63
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
64
|
+
const len1 = WASM_VECTOR_LEN;
|
|
65
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
66
|
+
const len2 = WASM_VECTOR_LEN;
|
|
67
|
+
wasm.convertBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
68
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
69
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
70
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
71
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
72
|
+
var ptr4 = r0;
|
|
73
|
+
var len4 = r1;
|
|
74
|
+
if (r3) {
|
|
75
|
+
ptr4 = 0; len4 = 0;
|
|
76
|
+
throw takeObject(r2);
|
|
77
|
+
}
|
|
78
|
+
deferred5_0 = ptr4;
|
|
79
|
+
deferred5_1 = len4;
|
|
80
|
+
return getStringFromWasm0(ptr4, len4);
|
|
81
|
+
} finally {
|
|
82
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
83
|
+
wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Convert binary input producing a standalone file (full HTML, LaTeX with preamble, etc.).
|
|
89
|
+
* @param {Uint8Array} input
|
|
90
|
+
* @param {string} from
|
|
91
|
+
* @param {string} to
|
|
92
|
+
* @returns {string}
|
|
93
|
+
*/
|
|
94
|
+
export function convertBytesStandalone(input, from, to) {
|
|
95
|
+
let deferred5_0;
|
|
96
|
+
let deferred5_1;
|
|
97
|
+
try {
|
|
98
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
99
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
100
|
+
const len0 = WASM_VECTOR_LEN;
|
|
101
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
102
|
+
const len1 = WASM_VECTOR_LEN;
|
|
103
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
104
|
+
const len2 = WASM_VECTOR_LEN;
|
|
105
|
+
wasm.convertBytesStandalone(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
106
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
107
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
108
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
109
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
110
|
+
var ptr4 = r0;
|
|
111
|
+
var len4 = r1;
|
|
112
|
+
if (r3) {
|
|
113
|
+
ptr4 = 0; len4 = 0;
|
|
114
|
+
throw takeObject(r2);
|
|
115
|
+
}
|
|
116
|
+
deferred5_0 = ptr4;
|
|
117
|
+
deferred5_1 = len4;
|
|
118
|
+
return getStringFromWasm0(ptr4, len4);
|
|
119
|
+
} finally {
|
|
120
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
121
|
+
wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Convert a document producing a standalone file (full HTML document, LaTeX with preamble, etc.).
|
|
127
|
+
* @param {string} input
|
|
128
|
+
* @param {string} from
|
|
129
|
+
* @param {string} to
|
|
130
|
+
* @returns {string}
|
|
131
|
+
*/
|
|
132
|
+
export function convertStandalone(input, from, to) {
|
|
133
|
+
let deferred5_0;
|
|
134
|
+
let deferred5_1;
|
|
135
|
+
try {
|
|
136
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
137
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
138
|
+
const len0 = WASM_VECTOR_LEN;
|
|
139
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
140
|
+
const len1 = WASM_VECTOR_LEN;
|
|
141
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
142
|
+
const len2 = WASM_VECTOR_LEN;
|
|
143
|
+
wasm.convertStandalone(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
144
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
145
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
146
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
147
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
148
|
+
var ptr4 = r0;
|
|
149
|
+
var len4 = r1;
|
|
150
|
+
if (r3) {
|
|
151
|
+
ptr4 = 0; len4 = 0;
|
|
152
|
+
throw takeObject(r2);
|
|
153
|
+
}
|
|
154
|
+
deferred5_0 = ptr4;
|
|
155
|
+
deferred5_1 = len4;
|
|
156
|
+
return getStringFromWasm0(ptr4, len4);
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
159
|
+
wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Return a list of supported input format names.
|
|
165
|
+
* @returns {string[]}
|
|
166
|
+
*/
|
|
167
|
+
export function inputFormats() {
|
|
168
|
+
try {
|
|
169
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
170
|
+
wasm.inputFormats(retptr);
|
|
171
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
172
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
173
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
174
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
175
|
+
return v1;
|
|
176
|
+
} finally {
|
|
177
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Convert markdown to HTML (convenience wrapper).
|
|
183
|
+
* @param {string} input
|
|
184
|
+
* @returns {string}
|
|
185
|
+
*/
|
|
186
|
+
export function markdownToHtml(input) {
|
|
187
|
+
let deferred3_0;
|
|
188
|
+
let deferred3_1;
|
|
189
|
+
try {
|
|
190
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
191
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
192
|
+
const len0 = WASM_VECTOR_LEN;
|
|
193
|
+
wasm.markdownToHtml(retptr, ptr0, len0);
|
|
194
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
195
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
196
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
197
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
198
|
+
var ptr2 = r0;
|
|
199
|
+
var len2 = r1;
|
|
200
|
+
if (r3) {
|
|
201
|
+
ptr2 = 0; len2 = 0;
|
|
202
|
+
throw takeObject(r2);
|
|
203
|
+
}
|
|
204
|
+
deferred3_0 = ptr2;
|
|
205
|
+
deferred3_1 = len2;
|
|
206
|
+
return getStringFromWasm0(ptr2, len2);
|
|
207
|
+
} finally {
|
|
208
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
209
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Return a list of supported output format names.
|
|
215
|
+
* @returns {string[]}
|
|
216
|
+
*/
|
|
217
|
+
export function outputFormats() {
|
|
218
|
+
try {
|
|
219
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
220
|
+
wasm.outputFormats(retptr);
|
|
221
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
222
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
223
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
224
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
225
|
+
return v1;
|
|
226
|
+
} finally {
|
|
227
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Parse binary input and return the AST as pretty-printed JSON.
|
|
233
|
+
* @param {Uint8Array} input
|
|
234
|
+
* @param {string} from
|
|
235
|
+
* @returns {string}
|
|
236
|
+
*/
|
|
237
|
+
export function parseBytesToJson(input, from) {
|
|
238
|
+
let deferred4_0;
|
|
239
|
+
let deferred4_1;
|
|
240
|
+
try {
|
|
241
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
242
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
243
|
+
const len0 = WASM_VECTOR_LEN;
|
|
244
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
245
|
+
const len1 = WASM_VECTOR_LEN;
|
|
246
|
+
wasm.parseBytesToJson(retptr, ptr0, len0, ptr1, len1);
|
|
247
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
248
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
249
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
250
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
251
|
+
var ptr3 = r0;
|
|
252
|
+
var len3 = r1;
|
|
253
|
+
if (r3) {
|
|
254
|
+
ptr3 = 0; len3 = 0;
|
|
255
|
+
throw takeObject(r2);
|
|
256
|
+
}
|
|
257
|
+
deferred4_0 = ptr3;
|
|
258
|
+
deferred4_1 = len3;
|
|
259
|
+
return getStringFromWasm0(ptr3, len3);
|
|
260
|
+
} finally {
|
|
261
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
262
|
+
wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Parse a document and return the AST as pretty-printed JSON.
|
|
268
|
+
* @param {string} input
|
|
269
|
+
* @param {string} from
|
|
270
|
+
* @returns {string}
|
|
271
|
+
*/
|
|
272
|
+
export function parseToJson(input, from) {
|
|
273
|
+
let deferred4_0;
|
|
274
|
+
let deferred4_1;
|
|
275
|
+
try {
|
|
276
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
277
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
278
|
+
const len0 = WASM_VECTOR_LEN;
|
|
279
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
280
|
+
const len1 = WASM_VECTOR_LEN;
|
|
281
|
+
wasm.parseToJson(retptr, ptr0, len0, ptr1, len1);
|
|
282
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
283
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
284
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
285
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
286
|
+
var ptr3 = r0;
|
|
287
|
+
var len3 = r1;
|
|
288
|
+
if (r3) {
|
|
289
|
+
ptr3 = 0; len3 = 0;
|
|
290
|
+
throw takeObject(r2);
|
|
291
|
+
}
|
|
292
|
+
deferred4_0 = ptr3;
|
|
293
|
+
deferred4_1 = len3;
|
|
294
|
+
return getStringFromWasm0(ptr3, len3);
|
|
295
|
+
} finally {
|
|
296
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
297
|
+
wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
|
|
301
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
302
|
+
return addHeapObject(ret);
|
|
303
|
+
}
|
|
304
|
+
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
305
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
306
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
307
|
+
return addHeapObject(ret);
|
|
308
|
+
}
|
|
309
|
+
function addHeapObject(obj) {
|
|
310
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
311
|
+
const idx = heap_next;
|
|
312
|
+
heap_next = heap[idx];
|
|
313
|
+
|
|
314
|
+
heap[idx] = obj;
|
|
315
|
+
return idx;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function dropObject(idx) {
|
|
319
|
+
if (idx < 1028) return;
|
|
320
|
+
heap[idx] = heap_next;
|
|
321
|
+
heap_next = idx;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
325
|
+
ptr = ptr >>> 0;
|
|
326
|
+
const mem = getDataViewMemory0();
|
|
327
|
+
const result = [];
|
|
328
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
329
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
330
|
+
}
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
let cachedDataViewMemory0 = null;
|
|
335
|
+
function getDataViewMemory0() {
|
|
336
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
337
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
338
|
+
}
|
|
339
|
+
return cachedDataViewMemory0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function getStringFromWasm0(ptr, len) {
|
|
343
|
+
ptr = ptr >>> 0;
|
|
344
|
+
return decodeText(ptr, len);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
let cachedUint8ArrayMemory0 = null;
|
|
348
|
+
function getUint8ArrayMemory0() {
|
|
349
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
350
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
351
|
+
}
|
|
352
|
+
return cachedUint8ArrayMemory0;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function getObject(idx) { return heap[idx]; }
|
|
356
|
+
|
|
357
|
+
let heap = new Array(1024).fill(undefined);
|
|
358
|
+
heap.push(undefined, null, true, false);
|
|
359
|
+
|
|
360
|
+
let heap_next = heap.length;
|
|
361
|
+
|
|
362
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
363
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
364
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
365
|
+
WASM_VECTOR_LEN = arg.length;
|
|
366
|
+
return ptr;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
370
|
+
if (realloc === undefined) {
|
|
371
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
372
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
373
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
374
|
+
WASM_VECTOR_LEN = buf.length;
|
|
375
|
+
return ptr;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let len = arg.length;
|
|
379
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
380
|
+
|
|
381
|
+
const mem = getUint8ArrayMemory0();
|
|
382
|
+
|
|
383
|
+
let offset = 0;
|
|
384
|
+
|
|
385
|
+
for (; offset < len; offset++) {
|
|
386
|
+
const code = arg.charCodeAt(offset);
|
|
387
|
+
if (code > 0x7F) break;
|
|
388
|
+
mem[ptr + offset] = code;
|
|
389
|
+
}
|
|
390
|
+
if (offset !== len) {
|
|
391
|
+
if (offset !== 0) {
|
|
392
|
+
arg = arg.slice(offset);
|
|
393
|
+
}
|
|
394
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
395
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
396
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
397
|
+
|
|
398
|
+
offset += ret.written;
|
|
399
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
WASM_VECTOR_LEN = offset;
|
|
403
|
+
return ptr;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function takeObject(idx) {
|
|
407
|
+
const ret = getObject(idx);
|
|
408
|
+
dropObject(idx);
|
|
409
|
+
return ret;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
413
|
+
cachedTextDecoder.decode();
|
|
414
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
415
|
+
let numBytesDecoded = 0;
|
|
416
|
+
function decodeText(ptr, len) {
|
|
417
|
+
numBytesDecoded += len;
|
|
418
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
419
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
420
|
+
cachedTextDecoder.decode();
|
|
421
|
+
numBytesDecoded = len;
|
|
422
|
+
}
|
|
423
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const cachedTextEncoder = new TextEncoder();
|
|
427
|
+
|
|
428
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
429
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
430
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
431
|
+
view.set(buf);
|
|
432
|
+
return {
|
|
433
|
+
read: arg.length,
|
|
434
|
+
written: buf.length
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
let WASM_VECTOR_LEN = 0;
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
let wasm;
|
|
443
|
+
export function __wbg_set_wasm(val) {
|
|
444
|
+
wasm = val;
|
|
445
|
+
}
|
|
Binary file
|