@iyulab/m3l-wasm 0.4.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/m3l_wasm.d.ts +28 -0
- package/m3l_wasm.js +9 -0
- package/m3l_wasm_bg.js +169 -0
- package/m3l_wasm_bg.wasm +0 -0
- package/package.json +31 -0
package/m3l_wasm.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parse a single M3L file and return the AST as JSON.
|
|
6
|
+
*
|
|
7
|
+
* @param content - M3L markdown text
|
|
8
|
+
* @param filename - Source filename for error reporting
|
|
9
|
+
* @returns JSON string with `{ success: boolean, data?: AST, error?: string }`
|
|
10
|
+
*/
|
|
11
|
+
export function parse(content: string, filename: string): string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Parse multiple M3L files and return the merged AST as JSON.
|
|
15
|
+
*
|
|
16
|
+
* @param files_json - JSON array of `{ content: string, filename: string }` objects
|
|
17
|
+
* @returns JSON string with `{ success: boolean, data?: AST, error?: string }`
|
|
18
|
+
*/
|
|
19
|
+
export function parseMulti(files_json: string): string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validate M3L content and return diagnostics as JSON.
|
|
23
|
+
*
|
|
24
|
+
* @param content - M3L markdown text
|
|
25
|
+
* @param options_json - JSON options `{ strict?: boolean, filename?: string }`
|
|
26
|
+
* @returns JSON string with `{ success: boolean, data?: ValidateResult, error?: string }`
|
|
27
|
+
*/
|
|
28
|
+
export function validate(content: string, options_json: string): string;
|
package/m3l_wasm.js
ADDED
package/m3l_wasm_bg.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a single M3L file and return the AST as JSON.
|
|
3
|
+
*
|
|
4
|
+
* @param content - M3L markdown text
|
|
5
|
+
* @param filename - Source filename for error reporting
|
|
6
|
+
* @returns JSON string with `{ success: boolean, data?: AST, error?: string }`
|
|
7
|
+
* @param {string} content
|
|
8
|
+
* @param {string} filename
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
export function parse(content, filename) {
|
|
12
|
+
let deferred3_0;
|
|
13
|
+
let deferred3_1;
|
|
14
|
+
try {
|
|
15
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
16
|
+
const len0 = WASM_VECTOR_LEN;
|
|
17
|
+
const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
18
|
+
const len1 = WASM_VECTOR_LEN;
|
|
19
|
+
const ret = wasm.parse(ptr0, len0, ptr1, len1);
|
|
20
|
+
deferred3_0 = ret[0];
|
|
21
|
+
deferred3_1 = ret[1];
|
|
22
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
23
|
+
} finally {
|
|
24
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Parse multiple M3L files and return the merged AST as JSON.
|
|
30
|
+
*
|
|
31
|
+
* @param files_json - JSON array of `{ content: string, filename: string }` objects
|
|
32
|
+
* @returns JSON string with `{ success: boolean, data?: AST, error?: string }`
|
|
33
|
+
* @param {string} files_json
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export function parseMulti(files_json) {
|
|
37
|
+
let deferred2_0;
|
|
38
|
+
let deferred2_1;
|
|
39
|
+
try {
|
|
40
|
+
const ptr0 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
41
|
+
const len0 = WASM_VECTOR_LEN;
|
|
42
|
+
const ret = wasm.parseMulti(ptr0, len0);
|
|
43
|
+
deferred2_0 = ret[0];
|
|
44
|
+
deferred2_1 = ret[1];
|
|
45
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
46
|
+
} finally {
|
|
47
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Validate M3L content and return diagnostics as JSON.
|
|
53
|
+
*
|
|
54
|
+
* @param content - M3L markdown text
|
|
55
|
+
* @param options_json - JSON options `{ strict?: boolean, filename?: string }`
|
|
56
|
+
* @returns JSON string with `{ success: boolean, data?: ValidateResult, error?: string }`
|
|
57
|
+
* @param {string} content
|
|
58
|
+
* @param {string} options_json
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function validate(content, options_json) {
|
|
62
|
+
let deferred3_0;
|
|
63
|
+
let deferred3_1;
|
|
64
|
+
try {
|
|
65
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
66
|
+
const len0 = WASM_VECTOR_LEN;
|
|
67
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
68
|
+
const len1 = WASM_VECTOR_LEN;
|
|
69
|
+
const ret = wasm.validate(ptr0, len0, ptr1, len1);
|
|
70
|
+
deferred3_0 = ret[0];
|
|
71
|
+
deferred3_1 = ret[1];
|
|
72
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
73
|
+
} finally {
|
|
74
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function __wbindgen_init_externref_table() {
|
|
78
|
+
const table = wasm.__wbindgen_externrefs;
|
|
79
|
+
const offset = table.grow(4);
|
|
80
|
+
table.set(0, undefined);
|
|
81
|
+
table.set(offset + 0, undefined);
|
|
82
|
+
table.set(offset + 1, null);
|
|
83
|
+
table.set(offset + 2, true);
|
|
84
|
+
table.set(offset + 3, false);
|
|
85
|
+
}
|
|
86
|
+
function getStringFromWasm0(ptr, len) {
|
|
87
|
+
ptr = ptr >>> 0;
|
|
88
|
+
return decodeText(ptr, len);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let cachedUint8ArrayMemory0 = null;
|
|
92
|
+
function getUint8ArrayMemory0() {
|
|
93
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
94
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
95
|
+
}
|
|
96
|
+
return cachedUint8ArrayMemory0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
100
|
+
if (realloc === undefined) {
|
|
101
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
102
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
103
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
104
|
+
WASM_VECTOR_LEN = buf.length;
|
|
105
|
+
return ptr;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let len = arg.length;
|
|
109
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
110
|
+
|
|
111
|
+
const mem = getUint8ArrayMemory0();
|
|
112
|
+
|
|
113
|
+
let offset = 0;
|
|
114
|
+
|
|
115
|
+
for (; offset < len; offset++) {
|
|
116
|
+
const code = arg.charCodeAt(offset);
|
|
117
|
+
if (code > 0x7F) break;
|
|
118
|
+
mem[ptr + offset] = code;
|
|
119
|
+
}
|
|
120
|
+
if (offset !== len) {
|
|
121
|
+
if (offset !== 0) {
|
|
122
|
+
arg = arg.slice(offset);
|
|
123
|
+
}
|
|
124
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
125
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
126
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
127
|
+
|
|
128
|
+
offset += ret.written;
|
|
129
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
WASM_VECTOR_LEN = offset;
|
|
133
|
+
return ptr;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
137
|
+
cachedTextDecoder.decode();
|
|
138
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
139
|
+
let numBytesDecoded = 0;
|
|
140
|
+
function decodeText(ptr, len) {
|
|
141
|
+
numBytesDecoded += len;
|
|
142
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
143
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
144
|
+
cachedTextDecoder.decode();
|
|
145
|
+
numBytesDecoded = len;
|
|
146
|
+
}
|
|
147
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const cachedTextEncoder = new TextEncoder();
|
|
151
|
+
|
|
152
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
153
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
154
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
155
|
+
view.set(buf);
|
|
156
|
+
return {
|
|
157
|
+
read: arg.length,
|
|
158
|
+
written: buf.length
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let WASM_VECTOR_LEN = 0;
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
let wasm;
|
|
167
|
+
export function __wbg_set_wasm(val) {
|
|
168
|
+
wasm = val;
|
|
169
|
+
}
|
package/m3l_wasm_bg.wasm
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iyulab/m3l-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "M3L parser WebAssembly bindings via wasm-bindgen",
|
|
5
|
+
"version": "0.4.1",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/iyulab/m3l"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"m3l_wasm_bg.wasm",
|
|
13
|
+
"m3l_wasm.js",
|
|
14
|
+
"m3l_wasm_bg.js",
|
|
15
|
+
"m3l_wasm.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"main": "m3l_wasm.js",
|
|
18
|
+
"homepage": "https://github.com/iyulab/m3l",
|
|
19
|
+
"types": "m3l_wasm.d.ts",
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"./m3l_wasm.js",
|
|
22
|
+
"./snippets/*"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"schema",
|
|
26
|
+
"markdown",
|
|
27
|
+
"parser",
|
|
28
|
+
"ast",
|
|
29
|
+
"m3l"
|
|
30
|
+
]
|
|
31
|
+
}
|