md4x 0.0.18 → 0.0.19
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/build/md4x.darwin-arm64.node +0 -0
- package/build/md4x.darwin-x64.node +0 -0
- package/build/md4x.linux-arm.node +0 -0
- package/build/md4x.linux-arm64-musl.node +0 -0
- package/build/md4x.linux-arm64.node +0 -0
- package/build/md4x.linux-x64-musl.node +0 -0
- package/build/md4x.linux-x64.node +0 -0
- package/build/md4x.wasm +0 -0
- package/build/md4x.win32-arm64.node +0 -0
- package/build/md4x.win32-x64.node +0 -0
- package/lib/napi.mjs +13 -6
- package/lib/wasm/common.mjs +8 -1
- package/package.json +2 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/build/md4x.wasm
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/napi.mjs
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
let binding;
|
|
4
4
|
|
|
5
|
+
function str(input) {
|
|
6
|
+
if (input == null) return "";
|
|
7
|
+
if (typeof input !== "string")
|
|
8
|
+
throw new TypeError("md4x: input must be a string");
|
|
9
|
+
return input;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
function getBinding(opts) {
|
|
6
13
|
if (binding) return binding;
|
|
7
14
|
if (opts?.binding) {
|
|
@@ -33,12 +40,12 @@ const HEAL_FLAG = 0x0100;
|
|
|
33
40
|
export function renderToHtml(input, opts) {
|
|
34
41
|
let flags = opts?.full ? 0x0008 : 0;
|
|
35
42
|
if (opts?.heal) flags |= HEAL_FLAG;
|
|
36
|
-
return getBinding().renderToHtml(input, flags);
|
|
43
|
+
return getBinding().renderToHtml(str(input), flags);
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
export function renderToAST(input, opts) {
|
|
40
47
|
const flags = opts?.heal ? HEAL_FLAG : 0;
|
|
41
|
-
return getBinding().renderToAST(input, flags);
|
|
48
|
+
return getBinding().renderToAST(str(input), flags);
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export function parseAST(input, opts) {
|
|
@@ -47,17 +54,17 @@ export function parseAST(input, opts) {
|
|
|
47
54
|
|
|
48
55
|
export function renderToAnsi(input, opts) {
|
|
49
56
|
const flags = opts?.heal ? HEAL_FLAG : 0;
|
|
50
|
-
return getBinding().renderToAnsi(input, flags);
|
|
57
|
+
return getBinding().renderToAnsi(str(input), flags);
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
export function renderToMeta(input, opts) {
|
|
54
61
|
const flags = opts?.heal ? HEAL_FLAG : 0;
|
|
55
|
-
return getBinding().renderToMeta(input, flags);
|
|
62
|
+
return getBinding().renderToMeta(str(input), flags);
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
export function renderToText(input, opts) {
|
|
59
66
|
const flags = opts?.heal ? HEAL_FLAG : 0;
|
|
60
|
-
return getBinding().renderToText(input, flags);
|
|
67
|
+
return getBinding().renderToText(str(input), flags);
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
export function parseMeta(input, opts) {
|
|
@@ -69,5 +76,5 @@ export function parseMeta(input, opts) {
|
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
export function heal(input) {
|
|
72
|
-
return getBinding().heal(input);
|
|
79
|
+
return getBinding().heal(str(input));
|
|
73
80
|
}
|
package/lib/wasm/common.mjs
CHANGED
|
@@ -28,10 +28,17 @@ export const _imports = {
|
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
function str(input) {
|
|
32
|
+
if (input == null) return "";
|
|
33
|
+
if (typeof input !== "string")
|
|
34
|
+
throw new TypeError("md4x: input must be a string");
|
|
35
|
+
return input;
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
function render(exports, fn, input, ...extra) {
|
|
32
39
|
const { memory, md4x_alloc, md4x_free, md4x_result_ptr, md4x_result_size } =
|
|
33
40
|
exports;
|
|
34
|
-
const encoded = new TextEncoder().encode(input);
|
|
41
|
+
const encoded = new TextEncoder().encode(str(input));
|
|
35
42
|
const ptr = md4x_alloc(encoded.length);
|
|
36
43
|
new Uint8Array(memory.buffer).set(encoded, ptr);
|
|
37
44
|
const ret = fn(ptr, encoded.length, ...extra);
|