@mmds/wasm 1.0.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/mmdflux_wasm.d.ts +8 -0
- package/mmdflux_wasm.js +9 -0
- package/mmdflux_wasm_bg.js +165 -0
- package/mmdflux_wasm_bg.wasm +0 -0
- package/package.json +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kevin Swiber
|
|
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/mmdflux_wasm.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./mmdflux_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
import * as wasm from "./mmdflux_wasm_bg.wasm";
|
|
4
|
+
import { __wbg_set_wasm } from "./mmdflux_wasm_bg.js";
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
detect, render, version
|
|
9
|
+
} from "./mmdflux_wasm_bg.js";
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} input
|
|
3
|
+
* @returns {string | undefined}
|
|
4
|
+
*/
|
|
5
|
+
export function detect(input) {
|
|
6
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
7
|
+
const len0 = WASM_VECTOR_LEN;
|
|
8
|
+
const ret = wasm.detect(ptr0, len0);
|
|
9
|
+
let v2;
|
|
10
|
+
if (ret[0] !== 0) {
|
|
11
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
12
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
13
|
+
}
|
|
14
|
+
return v2;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} input
|
|
19
|
+
* @param {string} format
|
|
20
|
+
* @param {string} config_json
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
export function render(input, format, config_json) {
|
|
24
|
+
let deferred5_0;
|
|
25
|
+
let deferred5_1;
|
|
26
|
+
try {
|
|
27
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
30
|
+
const len1 = WASM_VECTOR_LEN;
|
|
31
|
+
const ptr2 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
32
|
+
const len2 = WASM_VECTOR_LEN;
|
|
33
|
+
const ret = wasm.render(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
34
|
+
var ptr4 = ret[0];
|
|
35
|
+
var len4 = ret[1];
|
|
36
|
+
if (ret[3]) {
|
|
37
|
+
ptr4 = 0; len4 = 0;
|
|
38
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
39
|
+
}
|
|
40
|
+
deferred5_0 = ptr4;
|
|
41
|
+
deferred5_1 = len4;
|
|
42
|
+
return getStringFromWasm0(ptr4, len4);
|
|
43
|
+
} finally {
|
|
44
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
export function version() {
|
|
52
|
+
let deferred1_0;
|
|
53
|
+
let deferred1_1;
|
|
54
|
+
try {
|
|
55
|
+
const ret = wasm.version();
|
|
56
|
+
deferred1_0 = ret[0];
|
|
57
|
+
deferred1_1 = ret[1];
|
|
58
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
59
|
+
} finally {
|
|
60
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
|
|
64
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
65
|
+
return ret;
|
|
66
|
+
}
|
|
67
|
+
export function __wbindgen_init_externref_table() {
|
|
68
|
+
const table = wasm.__wbindgen_externrefs;
|
|
69
|
+
const offset = table.grow(4);
|
|
70
|
+
table.set(0, undefined);
|
|
71
|
+
table.set(offset + 0, undefined);
|
|
72
|
+
table.set(offset + 1, null);
|
|
73
|
+
table.set(offset + 2, true);
|
|
74
|
+
table.set(offset + 3, false);
|
|
75
|
+
}
|
|
76
|
+
function getStringFromWasm0(ptr, len) {
|
|
77
|
+
ptr = ptr >>> 0;
|
|
78
|
+
return decodeText(ptr, len);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let cachedUint8ArrayMemory0 = null;
|
|
82
|
+
function getUint8ArrayMemory0() {
|
|
83
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
84
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
85
|
+
}
|
|
86
|
+
return cachedUint8ArrayMemory0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
90
|
+
if (realloc === undefined) {
|
|
91
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
92
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
93
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
94
|
+
WASM_VECTOR_LEN = buf.length;
|
|
95
|
+
return ptr;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let len = arg.length;
|
|
99
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
100
|
+
|
|
101
|
+
const mem = getUint8ArrayMemory0();
|
|
102
|
+
|
|
103
|
+
let offset = 0;
|
|
104
|
+
|
|
105
|
+
for (; offset < len; offset++) {
|
|
106
|
+
const code = arg.charCodeAt(offset);
|
|
107
|
+
if (code > 0x7F) break;
|
|
108
|
+
mem[ptr + offset] = code;
|
|
109
|
+
}
|
|
110
|
+
if (offset !== len) {
|
|
111
|
+
if (offset !== 0) {
|
|
112
|
+
arg = arg.slice(offset);
|
|
113
|
+
}
|
|
114
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
115
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
116
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
117
|
+
|
|
118
|
+
offset += ret.written;
|
|
119
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
WASM_VECTOR_LEN = offset;
|
|
123
|
+
return ptr;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function takeFromExternrefTable0(idx) {
|
|
127
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
128
|
+
wasm.__externref_table_dealloc(idx);
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
133
|
+
cachedTextDecoder.decode();
|
|
134
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
135
|
+
let numBytesDecoded = 0;
|
|
136
|
+
function decodeText(ptr, len) {
|
|
137
|
+
numBytesDecoded += len;
|
|
138
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
139
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
140
|
+
cachedTextDecoder.decode();
|
|
141
|
+
numBytesDecoded = len;
|
|
142
|
+
}
|
|
143
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const cachedTextEncoder = new TextEncoder();
|
|
147
|
+
|
|
148
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
149
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
150
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
151
|
+
view.set(buf);
|
|
152
|
+
return {
|
|
153
|
+
read: arg.length,
|
|
154
|
+
written: buf.length
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
let WASM_VECTOR_LEN = 0;
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
let wasm;
|
|
163
|
+
export function __wbg_set_wasm(val) {
|
|
164
|
+
wasm = val;
|
|
165
|
+
}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mmds/wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "wasm-bindgen bindings for mmdflux",
|
|
5
|
+
"version": "1.0.1",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/kevinswiber/mmdflux"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"mmdflux_wasm_bg.wasm",
|
|
13
|
+
"mmdflux_wasm.js",
|
|
14
|
+
"mmdflux_wasm_bg.js",
|
|
15
|
+
"mmdflux_wasm.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"main": "mmdflux_wasm.js",
|
|
18
|
+
"types": "mmdflux_wasm.d.ts",
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"./mmdflux_wasm.js",
|
|
21
|
+
"./snippets/*"
|
|
22
|
+
]
|
|
23
|
+
}
|