m-bus-parser-wasm-pack 0.5.1 → 0.5.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.
@@ -13,6 +13,10 @@ export function m_bus_decode(data: string, key_hex?: string | null, include_enri
13
13
  * Render with the shared Rust/Python/CLI output contract.
14
14
  */
15
15
  export function m_bus_render(data: string, format: string, key_hex?: string | null, width?: number | null, include_enrichment?: boolean | null): string;
16
+ /**
17
+ * Render CI-prefixed application data or bare DIF/VIF records without a link frame.
18
+ */
19
+ export function m_bus_render_application(data: string, format: string, key_hex?: string | null, width?: number | null, include_enrichment?: boolean | null): string;
16
20
  /**
17
21
  * Compatibility wrapper returning errors as text. Prefer `m_bus_render`.
18
22
  */
@@ -4,8 +4,6 @@ export function __wbg_set_wasm(val) {
4
4
  }
5
5
 
6
6
 
7
- let WASM_VECTOR_LEN = 0;
8
-
9
7
  let cachedUint8ArrayMemory0 = null;
10
8
 
11
9
  function getUint8ArrayMemory0() {
@@ -15,22 +13,41 @@ function getUint8ArrayMemory0() {
15
13
  return cachedUint8ArrayMemory0;
16
14
  }
17
15
 
18
- const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
16
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
+
18
+ cachedTextDecoder.decode();
19
19
 
20
- let cachedTextEncoder = new lTextEncoder('utf-8');
20
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
21
+ let numBytesDecoded = 0;
22
+ function decodeText(ptr, len) {
23
+ numBytesDecoded += len;
24
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
25
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+ cachedTextDecoder.decode();
27
+ numBytesDecoded = len;
28
+ }
29
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
30
+ }
21
31
 
22
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
23
- ? function (arg, view) {
24
- return cachedTextEncoder.encodeInto(arg, view);
32
+ function getStringFromWasm0(ptr, len) {
33
+ ptr = ptr >>> 0;
34
+ return decodeText(ptr, len);
35
+ }
36
+
37
+ let WASM_VECTOR_LEN = 0;
38
+
39
+ const cachedTextEncoder = new TextEncoder();
40
+
41
+ if (!('encodeInto' in cachedTextEncoder)) {
42
+ cachedTextEncoder.encodeInto = function (arg, view) {
43
+ const buf = cachedTextEncoder.encode(arg);
44
+ view.set(buf);
45
+ return {
46
+ read: arg.length,
47
+ written: buf.length
48
+ };
49
+ }
25
50
  }
26
- : function (arg, view) {
27
- const buf = cachedTextEncoder.encode(arg);
28
- view.set(buf);
29
- return {
30
- read: arg.length,
31
- written: buf.length
32
- };
33
- });
34
51
 
35
52
  function passStringToWasm0(arg, malloc, realloc) {
36
53
 
@@ -61,7 +78,7 @@ function passStringToWasm0(arg, malloc, realloc) {
61
78
  }
62
79
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
63
80
  const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
64
- const ret = encodeString(arg, view);
81
+ const ret = cachedTextEncoder.encodeInto(arg, view);
65
82
 
66
83
  offset += ret.written;
67
84
  ptr = realloc(ptr, len, offset, 1) >>> 0;
@@ -80,20 +97,13 @@ function getDataViewMemory0() {
80
97
  return cachedDataViewMemory0;
81
98
  }
82
99
 
83
- const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
84
-
85
- let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
86
-
87
- cachedTextDecoder.decode();
88
-
89
- function getStringFromWasm0(ptr, len) {
90
- ptr = ptr >>> 0;
91
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
100
+ function isLikeNone(x) {
101
+ return x === undefined || x === null;
92
102
  }
93
103
 
94
104
  function addToExternrefTable0(obj) {
95
105
  const idx = wasm.__externref_table_alloc();
96
- wasm.__wbindgen_export_4.set(idx, obj);
106
+ wasm.__wbindgen_externrefs.set(idx, obj);
97
107
  return idx;
98
108
  }
99
109
 
@@ -105,10 +115,6 @@ function handleError(f, args) {
105
115
  wasm.__wbindgen_exn_store(idx);
106
116
  }
107
117
  }
108
-
109
- function isLikeNone(x) {
110
- return x === undefined || x === null;
111
- }
112
118
  /**
113
119
  * @returns {string}
114
120
  */
@@ -126,7 +132,7 @@ export function version() {
126
132
  }
127
133
 
128
134
  function takeFromExternrefTable0(idx) {
129
- const value = wasm.__wbindgen_export_4.get(idx);
135
+ const value = wasm.__wbindgen_externrefs.get(idx);
130
136
  wasm.__externref_table_dealloc(idx);
131
137
  return value;
132
138
  }
@@ -212,6 +218,40 @@ export function m_bus_render(data, format, key_hex, width, include_enrichment) {
212
218
  }
213
219
  }
214
220
 
221
+ /**
222
+ * Render CI-prefixed application data or bare DIF/VIF records without a link frame.
223
+ * @param {string} data
224
+ * @param {string} format
225
+ * @param {string | null} [key_hex]
226
+ * @param {number | null} [width]
227
+ * @param {boolean | null} [include_enrichment]
228
+ * @returns {string}
229
+ */
230
+ export function m_bus_render_application(data, format, key_hex, width, include_enrichment) {
231
+ let deferred5_0;
232
+ let deferred5_1;
233
+ try {
234
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
237
+ const len1 = WASM_VECTOR_LEN;
238
+ var ptr2 = isLikeNone(key_hex) ? 0 : passStringToWasm0(key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
239
+ var len2 = WASM_VECTOR_LEN;
240
+ const ret = wasm.m_bus_render_application(ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(width) ? 0x100000001 : (width) >>> 0, isLikeNone(include_enrichment) ? 0xFFFFFF : include_enrichment ? 1 : 0);
241
+ var ptr4 = ret[0];
242
+ var len4 = ret[1];
243
+ if (ret[3]) {
244
+ ptr4 = 0; len4 = 0;
245
+ throw takeFromExternrefTable0(ret[2]);
246
+ }
247
+ deferred5_0 = ptr4;
248
+ deferred5_1 = len4;
249
+ return getStringFromWasm0(ptr4, len4);
250
+ } finally {
251
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
252
+ }
253
+ }
254
+
215
255
  /**
216
256
  * Compatibility wrapper returning errors as text. Prefer `m_bus_render`.
217
257
  * @param {string} data
@@ -261,6 +301,11 @@ export function m_bus_parse_with_key(data, format, key_hex) {
261
301
  }
262
302
  }
263
303
 
304
+ export function __wbg_Error_e83987f665cf5504(arg0, arg1) {
305
+ const ret = Error(getStringFromWasm0(arg0, arg1));
306
+ return ret;
307
+ };
308
+
264
309
  export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
265
310
  const ret = String(arg1);
266
311
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -269,70 +314,97 @@ export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
269
314
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
270
315
  };
271
316
 
272
- export function __wbg_new_405e22f390576ce2() {
273
- const ret = new Object();
317
+ export function __wbg___wbindgen_is_string_fbb76cb2940daafd(arg0) {
318
+ const ret = typeof(arg0) === 'string';
274
319
  return ret;
275
320
  };
276
321
 
277
- export function __wbg_new_5e0be73521bc8c17() {
278
- const ret = new Map();
322
+ export function __wbg___wbindgen_string_get_e4f06c90489ad01b(arg0, arg1) {
323
+ const obj = arg1;
324
+ const ret = typeof(obj) === 'string' ? obj : undefined;
325
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
326
+ var len1 = WASM_VECTOR_LEN;
327
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
328
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
329
+ };
330
+
331
+ export function __wbg___wbindgen_throw_b855445ff6a94295(arg0, arg1) {
332
+ throw new Error(getStringFromWasm0(arg0, arg1));
333
+ };
334
+
335
+ export function __wbg_new_1acc0b6eea89d040() {
336
+ const ret = new Object();
279
337
  return ret;
280
338
  };
281
339
 
282
- export function __wbg_new_78feb108b6472713() {
283
- const ret = new Array();
340
+ export function __wbg_new_68651c719dcda04e() {
341
+ const ret = new Map();
284
342
  return ret;
285
343
  };
286
344
 
287
- export function __wbg_new_c68d7209be747379(arg0, arg1) {
345
+ export function __wbg_new_a7442b4b19c1a356(arg0, arg1) {
288
346
  const ret = new Error(getStringFromWasm0(arg0, arg1));
289
347
  return ret;
290
348
  };
291
349
 
292
- export function __wbg_set_37837023f3d740e8(arg0, arg1, arg2) {
293
- arg0[arg1 >>> 0] = arg2;
350
+ export function __wbg_new_e17d9f43105b08be() {
351
+ const ret = new Array();
352
+ return ret;
294
353
  };
295
354
 
296
355
  export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
297
356
  arg0[arg1] = arg2;
298
357
  };
299
358
 
300
- export function __wbg_set_8fc6bf8a5b1071d1(arg0, arg1, arg2) {
359
+ export function __wbg_set_907fb406c34a251d(arg0, arg1, arg2) {
301
360
  const ret = arg0.set(arg1, arg2);
302
361
  return ret;
303
362
  };
304
363
 
305
- export function __wbg_set_bb8cecf6a62b9f46() { return handleError(function (arg0, arg1, arg2) {
364
+ export function __wbg_set_c213c871859d6500(arg0, arg1, arg2) {
365
+ arg0[arg1 >>> 0] = arg2;
366
+ };
367
+
368
+ export function __wbg_set_c2abbebe8b9ebee1() { return handleError(function (arg0, arg1, arg2) {
306
369
  const ret = Reflect.set(arg0, arg1, arg2);
307
370
  return ret;
308
371
  }, arguments) };
309
372
 
310
- export function __wbg_setname_6df54b7ebf9404a9(arg0, arg1, arg2) {
373
+ export function __wbg_set_name_d94846a29e626702(arg0, arg1, arg2) {
311
374
  arg0.name = getStringFromWasm0(arg1, arg2);
312
375
  };
313
376
 
314
- export function __wbg_stringify_f7ed6987935b4a24() { return handleError(function (arg0) {
377
+ export function __wbg_stringify_b5fb28f6465d9c3e() { return handleError(function (arg0) {
315
378
  const ret = JSON.stringify(arg0);
316
379
  return ret;
317
380
  }, arguments) };
318
381
 
319
- export function __wbindgen_bigint_from_i64(arg0) {
320
- const ret = arg0;
382
+ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
383
+ // Cast intrinsic for `Ref(String) -> Externref`.
384
+ const ret = getStringFromWasm0(arg0, arg1);
321
385
  return ret;
322
386
  };
323
387
 
324
- export function __wbindgen_bigint_from_u64(arg0) {
388
+ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
389
+ // Cast intrinsic for `U64 -> Externref`.
325
390
  const ret = BigInt.asUintN(64, arg0);
326
391
  return ret;
327
392
  };
328
393
 
329
- export function __wbindgen_error_new(arg0, arg1) {
330
- const ret = new Error(getStringFromWasm0(arg0, arg1));
394
+ export function __wbindgen_cast_9ae0607507abb057(arg0) {
395
+ // Cast intrinsic for `I64 -> Externref`.
396
+ const ret = arg0;
397
+ return ret;
398
+ };
399
+
400
+ export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
401
+ // Cast intrinsic for `F64 -> Externref`.
402
+ const ret = arg0;
331
403
  return ret;
332
404
  };
333
405
 
334
406
  export function __wbindgen_init_externref_table() {
335
- const table = wasm.__wbindgen_export_4;
407
+ const table = wasm.__wbindgen_externrefs;
336
408
  const offset = table.grow(4);
337
409
  table.set(0, undefined);
338
410
  table.set(offset + 0, undefined);
@@ -342,31 +414,3 @@ export function __wbindgen_init_externref_table() {
342
414
  ;
343
415
  };
344
416
 
345
- export function __wbindgen_is_string(arg0) {
346
- const ret = typeof(arg0) === 'string';
347
- return ret;
348
- };
349
-
350
- export function __wbindgen_number_new(arg0) {
351
- const ret = arg0;
352
- return ret;
353
- };
354
-
355
- export function __wbindgen_string_get(arg0, arg1) {
356
- const obj = arg1;
357
- const ret = typeof(obj) === 'string' ? obj : undefined;
358
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
359
- var len1 = WASM_VECTOR_LEN;
360
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
361
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
362
- };
363
-
364
- export function __wbindgen_string_new(arg0, arg1) {
365
- const ret = getStringFromWasm0(arg0, arg1);
366
- return ret;
367
- };
368
-
369
- export function __wbindgen_throw(arg0, arg1) {
370
- throw new Error(getStringFromWasm0(arg0, arg1));
371
- };
372
-
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Michael Aebli"
6
6
  ],
7
7
  "description": "A wasm-pack to use the library for parsing M-Bus frames",
8
- "version": "0.5.1",
8
+ "version": "0.5.3",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",