m-bus-parser-wasm-pack 0.0.11 → 0.1.3
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.
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./m_bus_parser_wasm_pack.d.ts" */
|
|
1
2
|
import * as wasm from "./m_bus_parser_wasm_pack_bg.wasm";
|
|
2
|
-
export * from "./m_bus_parser_wasm_pack_bg.js";
|
|
3
3
|
import { __wbg_set_wasm } from "./m_bus_parser_wasm_pack_bg.js";
|
|
4
|
+
|
|
4
5
|
__wbg_set_wasm(wasm);
|
|
5
6
|
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
m_bus_parse, m_bus_parse_with_key, version
|
|
9
|
+
} from "./m_bus_parser_wasm_pack_bg.js";
|
|
@@ -1,13 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} data
|
|
3
|
+
* @param {string} format
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function m_bus_parse(data, format) {
|
|
7
|
+
let deferred3_0;
|
|
8
|
+
let deferred3_1;
|
|
9
|
+
try {
|
|
10
|
+
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
11
|
+
const len0 = WASM_VECTOR_LEN;
|
|
12
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
13
|
+
const len1 = WASM_VECTOR_LEN;
|
|
14
|
+
const ret = wasm.m_bus_parse(ptr0, len0, ptr1, len1);
|
|
15
|
+
deferred3_0 = ret[0];
|
|
16
|
+
deferred3_1 = ret[1];
|
|
17
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
18
|
+
} finally {
|
|
19
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
20
|
+
}
|
|
4
21
|
}
|
|
5
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} data
|
|
25
|
+
* @param {string} format
|
|
26
|
+
* @param {string} key_hex
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
export function m_bus_parse_with_key(data, format, key_hex) {
|
|
30
|
+
let deferred4_0;
|
|
31
|
+
let deferred4_1;
|
|
32
|
+
try {
|
|
33
|
+
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
34
|
+
const len0 = WASM_VECTOR_LEN;
|
|
35
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
36
|
+
const len1 = WASM_VECTOR_LEN;
|
|
37
|
+
const ptr2 = passStringToWasm0(key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
+
const len2 = WASM_VECTOR_LEN;
|
|
39
|
+
const ret = wasm.m_bus_parse_with_key(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
40
|
+
deferred4_0 = ret[0];
|
|
41
|
+
deferred4_1 = ret[1];
|
|
42
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
43
|
+
} finally {
|
|
44
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
6
47
|
|
|
7
|
-
|
|
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 __wbindgen_init_externref_table() {
|
|
64
|
+
const table = wasm.__wbindgen_externrefs;
|
|
65
|
+
const offset = table.grow(4);
|
|
66
|
+
table.set(0, undefined);
|
|
67
|
+
table.set(offset + 0, undefined);
|
|
68
|
+
table.set(offset + 1, null);
|
|
69
|
+
table.set(offset + 2, true);
|
|
70
|
+
table.set(offset + 3, false);
|
|
71
|
+
}
|
|
72
|
+
function getStringFromWasm0(ptr, len) {
|
|
73
|
+
return decodeText(ptr >>> 0, len);
|
|
74
|
+
}
|
|
8
75
|
|
|
9
76
|
let cachedUint8ArrayMemory0 = null;
|
|
10
|
-
|
|
11
77
|
function getUint8ArrayMemory0() {
|
|
12
78
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13
79
|
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
@@ -15,21 +81,7 @@ function getUint8ArrayMemory0() {
|
|
|
15
81
|
return cachedUint8ArrayMemory0;
|
|
16
82
|
}
|
|
17
83
|
|
|
18
|
-
const cachedTextEncoder = new TextEncoder();
|
|
19
|
-
|
|
20
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
21
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
22
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
23
|
-
view.set(buf);
|
|
24
|
-
return {
|
|
25
|
-
read: arg.length,
|
|
26
|
-
written: buf.length
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
84
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
32
|
-
|
|
33
85
|
if (realloc === undefined) {
|
|
34
86
|
const buf = cachedTextEncoder.encode(arg);
|
|
35
87
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
@@ -50,7 +102,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
50
102
|
if (code > 0x7F) break;
|
|
51
103
|
mem[ptr + offset] = code;
|
|
52
104
|
}
|
|
53
|
-
|
|
54
105
|
if (offset !== len) {
|
|
55
106
|
if (offset !== 0) {
|
|
56
107
|
arg = arg.slice(offset);
|
|
@@ -68,9 +119,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
68
119
|
}
|
|
69
120
|
|
|
70
121
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
71
|
-
|
|
72
122
|
cachedTextDecoder.decode();
|
|
73
|
-
|
|
74
123
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
75
124
|
let numBytesDecoded = 0;
|
|
76
125
|
function decodeText(ptr, len) {
|
|
@@ -83,40 +132,23 @@ function decodeText(ptr, len) {
|
|
|
83
132
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
84
133
|
}
|
|
85
134
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
let deferred3_1;
|
|
98
|
-
try {
|
|
99
|
-
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
100
|
-
const len0 = WASM_VECTOR_LEN;
|
|
101
|
-
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
102
|
-
const len1 = WASM_VECTOR_LEN;
|
|
103
|
-
const ret = wasm.m_bus_parse(ptr0, len0, ptr1, len1);
|
|
104
|
-
deferred3_0 = ret[0];
|
|
105
|
-
deferred3_1 = ret[1];
|
|
106
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
107
|
-
} finally {
|
|
108
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
109
|
-
}
|
|
135
|
+
const cachedTextEncoder = new TextEncoder();
|
|
136
|
+
|
|
137
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
138
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
139
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
140
|
+
view.set(buf);
|
|
141
|
+
return {
|
|
142
|
+
read: arg.length,
|
|
143
|
+
written: buf.length
|
|
144
|
+
};
|
|
145
|
+
};
|
|
110
146
|
}
|
|
111
147
|
|
|
112
|
-
|
|
113
|
-
const table = wasm.__wbindgen_externrefs;
|
|
114
|
-
const offset = table.grow(4);
|
|
115
|
-
table.set(0, undefined);
|
|
116
|
-
table.set(offset + 0, undefined);
|
|
117
|
-
table.set(offset + 1, null);
|
|
118
|
-
table.set(offset + 2, true);
|
|
119
|
-
table.set(offset + 3, false);
|
|
120
|
-
;
|
|
121
|
-
};
|
|
148
|
+
let WASM_VECTOR_LEN = 0;
|
|
122
149
|
|
|
150
|
+
|
|
151
|
+
let wasm;
|
|
152
|
+
export function __wbg_set_wasm(val) {
|
|
153
|
+
wasm = val;
|
|
154
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"Michael Aebli"
|
|
6
6
|
],
|
|
7
7
|
"description": "A wasm-pack to use the library for parsing M-Bus frames",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.1.3",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/maebli/m-bus-parser"
|
|
12
|
+
"url": "git+https://github.com/maebli/m-bus-parser.git"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"m_bus_parser_wasm_pack_bg.wasm",
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
"parse",
|
|
31
31
|
"wasm-pack"
|
|
32
32
|
]
|
|
33
|
-
}
|
|
33
|
+
}
|