@goplasmatic/datalogic 4.0.8 → 4.0.12

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,123 +1,4 @@
1
- let wasm;
2
-
3
- function addHeapObject(obj) {
4
- if (heap_next === heap.length) heap.push(heap.length + 1);
5
- const idx = heap_next;
6
- heap_next = heap[idx];
7
-
8
- heap[idx] = obj;
9
- return idx;
10
- }
11
-
12
- function dropObject(idx) {
13
- if (idx < 132) return;
14
- heap[idx] = heap_next;
15
- heap_next = idx;
16
- }
17
-
18
- let cachedDataViewMemory0 = null;
19
- function getDataViewMemory0() {
20
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
21
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
22
- }
23
- return cachedDataViewMemory0;
24
- }
25
-
26
- function getStringFromWasm0(ptr, len) {
27
- ptr = ptr >>> 0;
28
- return decodeText(ptr, len);
29
- }
30
-
31
- let cachedUint8ArrayMemory0 = null;
32
- function getUint8ArrayMemory0() {
33
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
34
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
35
- }
36
- return cachedUint8ArrayMemory0;
37
- }
38
-
39
- function getObject(idx) { return heap[idx]; }
40
-
41
- let heap = new Array(128).fill(undefined);
42
- heap.push(undefined, null, true, false);
43
-
44
- let heap_next = heap.length;
45
-
46
- function passStringToWasm0(arg, malloc, realloc) {
47
- if (realloc === undefined) {
48
- const buf = cachedTextEncoder.encode(arg);
49
- const ptr = malloc(buf.length, 1) >>> 0;
50
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
51
- WASM_VECTOR_LEN = buf.length;
52
- return ptr;
53
- }
54
-
55
- let len = arg.length;
56
- let ptr = malloc(len, 1) >>> 0;
57
-
58
- const mem = getUint8ArrayMemory0();
59
-
60
- let offset = 0;
61
-
62
- for (; offset < len; offset++) {
63
- const code = arg.charCodeAt(offset);
64
- if (code > 0x7F) break;
65
- mem[ptr + offset] = code;
66
- }
67
- if (offset !== len) {
68
- if (offset !== 0) {
69
- arg = arg.slice(offset);
70
- }
71
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
72
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
73
- const ret = cachedTextEncoder.encodeInto(arg, view);
74
-
75
- offset += ret.written;
76
- ptr = realloc(ptr, len, offset, 1) >>> 0;
77
- }
78
-
79
- WASM_VECTOR_LEN = offset;
80
- return ptr;
81
- }
82
-
83
- function takeObject(idx) {
84
- const ret = getObject(idx);
85
- dropObject(idx);
86
- return ret;
87
- }
88
-
89
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
90
- cachedTextDecoder.decode();
91
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
92
- let numBytesDecoded = 0;
93
- function decodeText(ptr, len) {
94
- numBytesDecoded += len;
95
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
96
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
97
- cachedTextDecoder.decode();
98
- numBytesDecoded = len;
99
- }
100
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
101
- }
102
-
103
- const cachedTextEncoder = new TextEncoder();
104
-
105
- if (!('encodeInto' in cachedTextEncoder)) {
106
- cachedTextEncoder.encodeInto = function (arg, view) {
107
- const buf = cachedTextEncoder.encode(arg);
108
- view.set(buf);
109
- return {
110
- read: arg.length,
111
- written: buf.length
112
- };
113
- }
114
- }
115
-
116
- let WASM_VECTOR_LEN = 0;
117
-
118
- const CompiledRuleFinalization = (typeof FinalizationRegistry === 'undefined')
119
- ? { register: () => {}, unregister: () => {} }
120
- : new FinalizationRegistry(ptr => wasm.__wbg_compiledrule_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./datalogic_wasm.d.ts" */
121
2
 
122
3
  /**
123
4
  * A compiled JSONLogic rule that can be evaluated multiple times.
@@ -136,34 +17,6 @@ export class CompiledRule {
136
17
  const ptr = this.__destroy_into_raw();
137
18
  wasm.__wbg_compiledrule_free(ptr, 0);
138
19
  }
139
- /**
140
- * Create a new CompiledRule from a JSONLogic expression.
141
- *
142
- * # Arguments
143
- * * `logic` - JSON string containing the JSONLogic expression
144
- * * `preserve_structure` - If true, preserves object structure for JSON templates with embedded JSONLogic
145
- * @param {string} logic
146
- * @param {boolean} preserve_structure
147
- */
148
- constructor(logic, preserve_structure) {
149
- try {
150
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
151
- const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
152
- const len0 = WASM_VECTOR_LEN;
153
- wasm.compiledrule_new(retptr, ptr0, len0, preserve_structure);
154
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
155
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
156
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
157
- if (r2) {
158
- throw takeObject(r1);
159
- }
160
- this.__wbg_ptr = r0 >>> 0;
161
- CompiledRuleFinalization.register(this, this.__wbg_ptr, this);
162
- return this;
163
- } finally {
164
- wasm.__wbindgen_add_to_stack_pointer(16);
165
- }
166
- }
167
20
  /**
168
21
  * Evaluate the compiled rule against data.
169
22
  *
@@ -201,6 +54,34 @@ export class CompiledRule {
201
54
  wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
202
55
  }
203
56
  }
57
+ /**
58
+ * Create a new CompiledRule from a JSONLogic expression.
59
+ *
60
+ * # Arguments
61
+ * * `logic` - JSON string containing the JSONLogic expression
62
+ * * `preserve_structure` - If true, preserves object structure for JSON templates with embedded JSONLogic
63
+ * @param {string} logic
64
+ * @param {boolean} preserve_structure
65
+ */
66
+ constructor(logic, preserve_structure) {
67
+ try {
68
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
69
+ const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
70
+ const len0 = WASM_VECTOR_LEN;
71
+ wasm.compiledrule_new(retptr, ptr0, len0, preserve_structure);
72
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
73
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
74
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
75
+ if (r2) {
76
+ throw takeObject(r1);
77
+ }
78
+ this.__wbg_ptr = r0 >>> 0;
79
+ CompiledRuleFinalization.register(this, this.__wbg_ptr, this);
80
+ return this;
81
+ } finally {
82
+ wasm.__wbindgen_add_to_stack_pointer(16);
83
+ }
84
+ }
204
85
  }
205
86
  if (Symbol.dispose) CompiledRule.prototype[Symbol.dispose] = CompiledRule.prototype.free;
206
87
 
@@ -315,7 +196,185 @@ export function init() {
315
196
  wasm.init();
316
197
  }
317
198
 
318
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
199
+ function __wbg_get_imports() {
200
+ const import0 = {
201
+ __proto__: null,
202
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
203
+ throw new Error(getStringFromWasm0(arg0, arg1));
204
+ },
205
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
206
+ let deferred0_0;
207
+ let deferred0_1;
208
+ try {
209
+ deferred0_0 = arg0;
210
+ deferred0_1 = arg1;
211
+ console.error(getStringFromWasm0(arg0, arg1));
212
+ } finally {
213
+ wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
214
+ }
215
+ },
216
+ __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
217
+ const ret = getObject(arg0).getTime();
218
+ return ret;
219
+ },
220
+ __wbg_new_0_73afc35eb544e539: function() {
221
+ const ret = new Date();
222
+ return addHeapObject(ret);
223
+ },
224
+ __wbg_new_8a6f238a6ece86ea: function() {
225
+ const ret = new Error();
226
+ return addHeapObject(ret);
227
+ },
228
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
229
+ const ret = getObject(arg1).stack;
230
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
231
+ const len1 = WASM_VECTOR_LEN;
232
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
233
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
234
+ },
235
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
236
+ // Cast intrinsic for `Ref(String) -> Externref`.
237
+ const ret = getStringFromWasm0(arg0, arg1);
238
+ return addHeapObject(ret);
239
+ },
240
+ __wbindgen_object_drop_ref: function(arg0) {
241
+ takeObject(arg0);
242
+ },
243
+ };
244
+ return {
245
+ __proto__: null,
246
+ "./datalogic_wasm_bg.js": import0,
247
+ };
248
+ }
249
+
250
+ const CompiledRuleFinalization = (typeof FinalizationRegistry === 'undefined')
251
+ ? { register: () => {}, unregister: () => {} }
252
+ : new FinalizationRegistry(ptr => wasm.__wbg_compiledrule_free(ptr >>> 0, 1));
253
+
254
+ function addHeapObject(obj) {
255
+ if (heap_next === heap.length) heap.push(heap.length + 1);
256
+ const idx = heap_next;
257
+ heap_next = heap[idx];
258
+
259
+ heap[idx] = obj;
260
+ return idx;
261
+ }
262
+
263
+ function dropObject(idx) {
264
+ if (idx < 132) return;
265
+ heap[idx] = heap_next;
266
+ heap_next = idx;
267
+ }
268
+
269
+ let cachedDataViewMemory0 = null;
270
+ function getDataViewMemory0() {
271
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
272
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
273
+ }
274
+ return cachedDataViewMemory0;
275
+ }
276
+
277
+ function getStringFromWasm0(ptr, len) {
278
+ ptr = ptr >>> 0;
279
+ return decodeText(ptr, len);
280
+ }
281
+
282
+ let cachedUint8ArrayMemory0 = null;
283
+ function getUint8ArrayMemory0() {
284
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
285
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
286
+ }
287
+ return cachedUint8ArrayMemory0;
288
+ }
289
+
290
+ function getObject(idx) { return heap[idx]; }
291
+
292
+ let heap = new Array(128).fill(undefined);
293
+ heap.push(undefined, null, true, false);
294
+
295
+ let heap_next = heap.length;
296
+
297
+ function passStringToWasm0(arg, malloc, realloc) {
298
+ if (realloc === undefined) {
299
+ const buf = cachedTextEncoder.encode(arg);
300
+ const ptr = malloc(buf.length, 1) >>> 0;
301
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
302
+ WASM_VECTOR_LEN = buf.length;
303
+ return ptr;
304
+ }
305
+
306
+ let len = arg.length;
307
+ let ptr = malloc(len, 1) >>> 0;
308
+
309
+ const mem = getUint8ArrayMemory0();
310
+
311
+ let offset = 0;
312
+
313
+ for (; offset < len; offset++) {
314
+ const code = arg.charCodeAt(offset);
315
+ if (code > 0x7F) break;
316
+ mem[ptr + offset] = code;
317
+ }
318
+ if (offset !== len) {
319
+ if (offset !== 0) {
320
+ arg = arg.slice(offset);
321
+ }
322
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
323
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
324
+ const ret = cachedTextEncoder.encodeInto(arg, view);
325
+
326
+ offset += ret.written;
327
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
328
+ }
329
+
330
+ WASM_VECTOR_LEN = offset;
331
+ return ptr;
332
+ }
333
+
334
+ function takeObject(idx) {
335
+ const ret = getObject(idx);
336
+ dropObject(idx);
337
+ return ret;
338
+ }
339
+
340
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
341
+ cachedTextDecoder.decode();
342
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
343
+ let numBytesDecoded = 0;
344
+ function decodeText(ptr, len) {
345
+ numBytesDecoded += len;
346
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
347
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
348
+ cachedTextDecoder.decode();
349
+ numBytesDecoded = len;
350
+ }
351
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
352
+ }
353
+
354
+ const cachedTextEncoder = new TextEncoder();
355
+
356
+ if (!('encodeInto' in cachedTextEncoder)) {
357
+ cachedTextEncoder.encodeInto = function (arg, view) {
358
+ const buf = cachedTextEncoder.encode(arg);
359
+ view.set(buf);
360
+ return {
361
+ read: arg.length,
362
+ written: buf.length
363
+ };
364
+ };
365
+ }
366
+
367
+ let WASM_VECTOR_LEN = 0;
368
+
369
+ let wasmModule, wasm;
370
+ function __wbg_finalize_init(instance, module) {
371
+ wasm = instance.exports;
372
+ wasmModule = module;
373
+ cachedDataViewMemory0 = null;
374
+ cachedUint8ArrayMemory0 = null;
375
+ wasm.__wbindgen_start();
376
+ return wasm;
377
+ }
319
378
 
320
379
  async function __wbg_load(module, imports) {
321
380
  if (typeof Response === 'function' && module instanceof Response) {
@@ -323,14 +382,12 @@ async function __wbg_load(module, imports) {
323
382
  try {
324
383
  return await WebAssembly.instantiateStreaming(module, imports);
325
384
  } catch (e) {
326
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
385
+ const validResponse = module.ok && expectedResponseType(module.type);
327
386
 
328
387
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
329
388
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
330
389
 
331
- } else {
332
- throw e;
333
- }
390
+ } else { throw e; }
334
391
  }
335
392
  }
336
393
 
@@ -345,72 +402,20 @@ async function __wbg_load(module, imports) {
345
402
  return instance;
346
403
  }
347
404
  }
348
- }
349
405
 
350
- function __wbg_get_imports() {
351
- const imports = {};
352
- imports.wbg = {};
353
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
354
- throw new Error(getStringFromWasm0(arg0, arg1));
355
- };
356
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
357
- let deferred0_0;
358
- let deferred0_1;
359
- try {
360
- deferred0_0 = arg0;
361
- deferred0_1 = arg1;
362
- console.error(getStringFromWasm0(arg0, arg1));
363
- } finally {
364
- wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
406
+ function expectedResponseType(type) {
407
+ switch (type) {
408
+ case 'basic': case 'cors': case 'default': return true;
365
409
  }
366
- };
367
- imports.wbg.__wbg_getTime_ad1e9878a735af08 = function(arg0) {
368
- const ret = getObject(arg0).getTime();
369
- return ret;
370
- };
371
- imports.wbg.__wbg_new_0_23cedd11d9b40c9d = function() {
372
- const ret = new Date();
373
- return addHeapObject(ret);
374
- };
375
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
376
- const ret = new Error();
377
- return addHeapObject(ret);
378
- };
379
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
380
- const ret = getObject(arg1).stack;
381
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
382
- const len1 = WASM_VECTOR_LEN;
383
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
384
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
385
- };
386
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
387
- // Cast intrinsic for `Ref(String) -> Externref`.
388
- const ret = getStringFromWasm0(arg0, arg1);
389
- return addHeapObject(ret);
390
- };
391
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
392
- takeObject(arg0);
393
- };
394
-
395
- return imports;
396
- }
397
-
398
- function __wbg_finalize_init(instance, module) {
399
- wasm = instance.exports;
400
- __wbg_init.__wbindgen_wasm_module = module;
401
- cachedDataViewMemory0 = null;
402
- cachedUint8ArrayMemory0 = null;
403
-
404
-
405
- wasm.__wbindgen_start();
406
- return wasm;
410
+ return false;
411
+ }
407
412
  }
408
413
 
409
414
  function initSync(module) {
410
415
  if (wasm !== undefined) return wasm;
411
416
 
412
417
 
413
- if (typeof module !== 'undefined') {
418
+ if (module !== undefined) {
414
419
  if (Object.getPrototypeOf(module) === Object.prototype) {
415
420
  ({module} = module)
416
421
  } else {
@@ -430,7 +435,7 @@ async function __wbg_init(module_or_path) {
430
435
  if (wasm !== undefined) return wasm;
431
436
 
432
437
 
433
- if (typeof module_or_path !== 'undefined') {
438
+ if (module_or_path !== undefined) {
434
439
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
435
440
  ({module_or_path} = module_or_path)
436
441
  } else {
@@ -438,7 +443,7 @@ async function __wbg_init(module_or_path) {
438
443
  }
439
444
  }
440
445
 
441
- if (typeof module_or_path === 'undefined') {
446
+ if (module_or_path === undefined) {
442
447
  module_or_path = new URL('datalogic_wasm_bg.wasm', import.meta.url);
443
448
  }
444
449
  const imports = __wbg_get_imports();
@@ -452,5 +457,4 @@ async function __wbg_init(module_or_path) {
452
457
  return __wbg_finalize_init(instance, module);
453
458
  }
454
459
 
455
- export { initSync };
456
- export default __wbg_init;
460
+ export { initSync, __wbg_init as default };
Binary file