@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,117 +1,4 @@
1
-
2
- let imports = {};
3
- imports['__wbindgen_placeholder__'] = module.exports;
4
-
5
- function addHeapObject(obj) {
6
- if (heap_next === heap.length) heap.push(heap.length + 1);
7
- const idx = heap_next;
8
- heap_next = heap[idx];
9
-
10
- heap[idx] = obj;
11
- return idx;
12
- }
13
-
14
- function dropObject(idx) {
15
- if (idx < 132) return;
16
- heap[idx] = heap_next;
17
- heap_next = idx;
18
- }
19
-
20
- let cachedDataViewMemory0 = null;
21
- function getDataViewMemory0() {
22
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
23
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
24
- }
25
- return cachedDataViewMemory0;
26
- }
27
-
28
- function getStringFromWasm0(ptr, len) {
29
- ptr = ptr >>> 0;
30
- return decodeText(ptr, len);
31
- }
32
-
33
- let cachedUint8ArrayMemory0 = null;
34
- function getUint8ArrayMemory0() {
35
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
36
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
37
- }
38
- return cachedUint8ArrayMemory0;
39
- }
40
-
41
- function getObject(idx) { return heap[idx]; }
42
-
43
- let heap = new Array(128).fill(undefined);
44
- heap.push(undefined, null, true, false);
45
-
46
- let heap_next = heap.length;
47
-
48
- function passStringToWasm0(arg, malloc, realloc) {
49
- if (realloc === undefined) {
50
- const buf = cachedTextEncoder.encode(arg);
51
- const ptr = malloc(buf.length, 1) >>> 0;
52
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
53
- WASM_VECTOR_LEN = buf.length;
54
- return ptr;
55
- }
56
-
57
- let len = arg.length;
58
- let ptr = malloc(len, 1) >>> 0;
59
-
60
- const mem = getUint8ArrayMemory0();
61
-
62
- let offset = 0;
63
-
64
- for (; offset < len; offset++) {
65
- const code = arg.charCodeAt(offset);
66
- if (code > 0x7F) break;
67
- mem[ptr + offset] = code;
68
- }
69
- if (offset !== len) {
70
- if (offset !== 0) {
71
- arg = arg.slice(offset);
72
- }
73
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
74
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
75
- const ret = cachedTextEncoder.encodeInto(arg, view);
76
-
77
- offset += ret.written;
78
- ptr = realloc(ptr, len, offset, 1) >>> 0;
79
- }
80
-
81
- WASM_VECTOR_LEN = offset;
82
- return ptr;
83
- }
84
-
85
- function takeObject(idx) {
86
- const ret = getObject(idx);
87
- dropObject(idx);
88
- return ret;
89
- }
90
-
91
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
92
- cachedTextDecoder.decode();
93
- function decodeText(ptr, len) {
94
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
95
- }
96
-
97
- const cachedTextEncoder = new TextEncoder();
98
-
99
- if (!('encodeInto' in cachedTextEncoder)) {
100
- cachedTextEncoder.encodeInto = function (arg, view) {
101
- const buf = cachedTextEncoder.encode(arg);
102
- view.set(buf);
103
- return {
104
- read: arg.length,
105
- written: buf.length
106
- };
107
- }
108
- }
109
-
110
- let WASM_VECTOR_LEN = 0;
111
-
112
- const CompiledRuleFinalization = (typeof FinalizationRegistry === 'undefined')
113
- ? { register: () => {}, unregister: () => {} }
114
- : new FinalizationRegistry(ptr => wasm.__wbg_compiledrule_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./datalogic_wasm.d.ts" */
115
2
 
116
3
  /**
117
4
  * A compiled JSONLogic rule that can be evaluated multiple times.
@@ -130,34 +17,6 @@ class CompiledRule {
130
17
  const ptr = this.__destroy_into_raw();
131
18
  wasm.__wbg_compiledrule_free(ptr, 0);
132
19
  }
133
- /**
134
- * Create a new CompiledRule from a JSONLogic expression.
135
- *
136
- * # Arguments
137
- * * `logic` - JSON string containing the JSONLogic expression
138
- * * `preserve_structure` - If true, preserves object structure for JSON templates with embedded JSONLogic
139
- * @param {string} logic
140
- * @param {boolean} preserve_structure
141
- */
142
- constructor(logic, preserve_structure) {
143
- try {
144
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
145
- const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
146
- const len0 = WASM_VECTOR_LEN;
147
- wasm.compiledrule_new(retptr, ptr0, len0, preserve_structure);
148
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
149
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
150
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
151
- if (r2) {
152
- throw takeObject(r1);
153
- }
154
- this.__wbg_ptr = r0 >>> 0;
155
- CompiledRuleFinalization.register(this, this.__wbg_ptr, this);
156
- return this;
157
- } finally {
158
- wasm.__wbindgen_add_to_stack_pointer(16);
159
- }
160
- }
161
20
  /**
162
21
  * Evaluate the compiled rule against data.
163
22
  *
@@ -195,6 +54,34 @@ class CompiledRule {
195
54
  wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
196
55
  }
197
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
+ }
198
85
  }
199
86
  if (Symbol.dispose) CompiledRule.prototype[Symbol.dispose] = CompiledRule.prototype.free;
200
87
  exports.CompiledRule = CompiledRule;
@@ -313,58 +200,170 @@ function init() {
313
200
  }
314
201
  exports.init = init;
315
202
 
316
- exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
317
- throw new Error(getStringFromWasm0(arg0, arg1));
318
- };
203
+ function __wbg_get_imports() {
204
+ const import0 = {
205
+ __proto__: null,
206
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
207
+ throw new Error(getStringFromWasm0(arg0, arg1));
208
+ },
209
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
210
+ let deferred0_0;
211
+ let deferred0_1;
212
+ try {
213
+ deferred0_0 = arg0;
214
+ deferred0_1 = arg1;
215
+ console.error(getStringFromWasm0(arg0, arg1));
216
+ } finally {
217
+ wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
218
+ }
219
+ },
220
+ __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
221
+ const ret = getObject(arg0).getTime();
222
+ return ret;
223
+ },
224
+ __wbg_new_0_73afc35eb544e539: function() {
225
+ const ret = new Date();
226
+ return addHeapObject(ret);
227
+ },
228
+ __wbg_new_8a6f238a6ece86ea: function() {
229
+ const ret = new Error();
230
+ return addHeapObject(ret);
231
+ },
232
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
233
+ const ret = getObject(arg1).stack;
234
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
235
+ const len1 = WASM_VECTOR_LEN;
236
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
237
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
238
+ },
239
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
240
+ // Cast intrinsic for `Ref(String) -> Externref`.
241
+ const ret = getStringFromWasm0(arg0, arg1);
242
+ return addHeapObject(ret);
243
+ },
244
+ __wbindgen_object_drop_ref: function(arg0) {
245
+ takeObject(arg0);
246
+ },
247
+ };
248
+ return {
249
+ __proto__: null,
250
+ "./datalogic_wasm_bg.js": import0,
251
+ };
252
+ }
319
253
 
320
- exports.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
321
- let deferred0_0;
322
- let deferred0_1;
323
- try {
324
- deferred0_0 = arg0;
325
- deferred0_1 = arg1;
326
- console.error(getStringFromWasm0(arg0, arg1));
327
- } finally {
328
- wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
254
+ const CompiledRuleFinalization = (typeof FinalizationRegistry === 'undefined')
255
+ ? { register: () => {}, unregister: () => {} }
256
+ : new FinalizationRegistry(ptr => wasm.__wbg_compiledrule_free(ptr >>> 0, 1));
257
+
258
+ function addHeapObject(obj) {
259
+ if (heap_next === heap.length) heap.push(heap.length + 1);
260
+ const idx = heap_next;
261
+ heap_next = heap[idx];
262
+
263
+ heap[idx] = obj;
264
+ return idx;
265
+ }
266
+
267
+ function dropObject(idx) {
268
+ if (idx < 132) return;
269
+ heap[idx] = heap_next;
270
+ heap_next = idx;
271
+ }
272
+
273
+ let cachedDataViewMemory0 = null;
274
+ function getDataViewMemory0() {
275
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
276
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
329
277
  }
330
- };
278
+ return cachedDataViewMemory0;
279
+ }
331
280
 
332
- exports.__wbg_getTime_ad1e9878a735af08 = function(arg0) {
333
- const ret = getObject(arg0).getTime();
334
- return ret;
335
- };
281
+ function getStringFromWasm0(ptr, len) {
282
+ ptr = ptr >>> 0;
283
+ return decodeText(ptr, len);
284
+ }
285
+
286
+ let cachedUint8ArrayMemory0 = null;
287
+ function getUint8ArrayMemory0() {
288
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
289
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
290
+ }
291
+ return cachedUint8ArrayMemory0;
292
+ }
336
293
 
337
- exports.__wbg_new_0_23cedd11d9b40c9d = function() {
338
- const ret = new Date();
339
- return addHeapObject(ret);
340
- };
294
+ function getObject(idx) { return heap[idx]; }
341
295
 
342
- exports.__wbg_new_8a6f238a6ece86ea = function() {
343
- const ret = new Error();
344
- return addHeapObject(ret);
345
- };
296
+ let heap = new Array(128).fill(undefined);
297
+ heap.push(undefined, null, true, false);
346
298
 
347
- exports.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
348
- const ret = getObject(arg1).stack;
349
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
350
- const len1 = WASM_VECTOR_LEN;
351
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
352
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
353
- };
299
+ let heap_next = heap.length;
354
300
 
355
- exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
356
- // Cast intrinsic for `Ref(String) -> Externref`.
357
- const ret = getStringFromWasm0(arg0, arg1);
358
- return addHeapObject(ret);
359
- };
301
+ function passStringToWasm0(arg, malloc, realloc) {
302
+ if (realloc === undefined) {
303
+ const buf = cachedTextEncoder.encode(arg);
304
+ const ptr = malloc(buf.length, 1) >>> 0;
305
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
306
+ WASM_VECTOR_LEN = buf.length;
307
+ return ptr;
308
+ }
360
309
 
361
- exports.__wbindgen_object_drop_ref = function(arg0) {
362
- takeObject(arg0);
363
- };
310
+ let len = arg.length;
311
+ let ptr = malloc(len, 1) >>> 0;
312
+
313
+ const mem = getUint8ArrayMemory0();
314
+
315
+ let offset = 0;
316
+
317
+ for (; offset < len; offset++) {
318
+ const code = arg.charCodeAt(offset);
319
+ if (code > 0x7F) break;
320
+ mem[ptr + offset] = code;
321
+ }
322
+ if (offset !== len) {
323
+ if (offset !== 0) {
324
+ arg = arg.slice(offset);
325
+ }
326
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
327
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
328
+ const ret = cachedTextEncoder.encodeInto(arg, view);
329
+
330
+ offset += ret.written;
331
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
332
+ }
333
+
334
+ WASM_VECTOR_LEN = offset;
335
+ return ptr;
336
+ }
337
+
338
+ function takeObject(idx) {
339
+ const ret = getObject(idx);
340
+ dropObject(idx);
341
+ return ret;
342
+ }
343
+
344
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
345
+ cachedTextDecoder.decode();
346
+ function decodeText(ptr, len) {
347
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
348
+ }
349
+
350
+ const cachedTextEncoder = new TextEncoder();
351
+
352
+ if (!('encodeInto' in cachedTextEncoder)) {
353
+ cachedTextEncoder.encodeInto = function (arg, view) {
354
+ const buf = cachedTextEncoder.encode(arg);
355
+ view.set(buf);
356
+ return {
357
+ read: arg.length,
358
+ written: buf.length
359
+ };
360
+ };
361
+ }
362
+
363
+ let WASM_VECTOR_LEN = 0;
364
364
 
365
365
  const wasmPath = `${__dirname}/datalogic_wasm_bg.wasm`;
366
366
  const wasmBytes = require('fs').readFileSync(wasmPath);
367
367
  const wasmModule = new WebAssembly.Module(wasmBytes);
368
- const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
369
-
368
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
370
369
  wasm.__wbindgen_start();
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goplasmatic/datalogic",
3
- "version": "4.0.8",
3
+ "version": "4.0.12",
4
4
  "description": "High-performance JSONLogic engine for JavaScript/TypeScript - WebAssembly powered",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,27 +1,33 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * A compiled JSONLogic rule that can be evaluated multiple times.
6
+ *
7
+ * Use this when you need to evaluate the same logic against different data,
8
+ * as it avoids re-parsing the logic on each evaluation.
9
+ */
4
10
  export class CompiledRule {
5
- free(): void;
6
- [Symbol.dispose](): void;
7
- /**
8
- * Create a new CompiledRule from a JSONLogic expression.
9
- *
10
- * # Arguments
11
- * * `logic` - JSON string containing the JSONLogic expression
12
- * * `preserve_structure` - If true, preserves object structure for JSON templates with embedded JSONLogic
13
- */
14
- constructor(logic: string, preserve_structure: boolean);
15
- /**
16
- * Evaluate the compiled rule against data.
17
- *
18
- * # Arguments
19
- * * `data` - JSON string containing the data to evaluate against
20
- *
21
- * # Returns
22
- * JSON string result or error message
23
- */
24
- evaluate(data: string): string;
11
+ free(): void;
12
+ [Symbol.dispose](): void;
13
+ /**
14
+ * Evaluate the compiled rule against data.
15
+ *
16
+ * # Arguments
17
+ * * `data` - JSON string containing the data to evaluate against
18
+ *
19
+ * # Returns
20
+ * JSON string result or error message
21
+ */
22
+ evaluate(data: string): string;
23
+ /**
24
+ * Create a new CompiledRule from a JSONLogic expression.
25
+ *
26
+ * # Arguments
27
+ * * `logic` - JSON string containing the JSONLogic expression
28
+ * * `preserve_structure` - If true, preserves object structure for JSON templates with embedded JSONLogic
29
+ */
30
+ constructor(logic: string, preserve_structure: boolean);
25
31
  }
26
32
 
27
33
  /**
@@ -74,38 +80,38 @@ export function init(): void;
74
80
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
75
81
 
76
82
  export interface InitOutput {
77
- readonly memory: WebAssembly.Memory;
78
- readonly __wbg_compiledrule_free: (a: number, b: number) => void;
79
- readonly compiledrule_evaluate: (a: number, b: number, c: number, d: number) => void;
80
- readonly compiledrule_new: (a: number, b: number, c: number, d: number) => void;
81
- readonly evaluate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
82
- readonly evaluate_with_trace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
83
- readonly init: () => void;
84
- readonly __wbindgen_export: (a: number, b: number, c: number) => void;
85
- readonly __wbindgen_export2: (a: number, b: number) => number;
86
- readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
87
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
88
- readonly __wbindgen_start: () => void;
83
+ readonly memory: WebAssembly.Memory;
84
+ readonly __wbg_compiledrule_free: (a: number, b: number) => void;
85
+ readonly compiledrule_evaluate: (a: number, b: number, c: number, d: number) => void;
86
+ readonly compiledrule_new: (a: number, b: number, c: number, d: number) => void;
87
+ readonly evaluate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
88
+ readonly evaluate_with_trace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
89
+ readonly init: () => void;
90
+ readonly __wbindgen_export: (a: number, b: number, c: number) => void;
91
+ readonly __wbindgen_export2: (a: number, b: number) => number;
92
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
93
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
94
+ readonly __wbindgen_start: () => void;
89
95
  }
90
96
 
91
97
  export type SyncInitInput = BufferSource | WebAssembly.Module;
92
98
 
93
99
  /**
94
- * Instantiates the given `module`, which can either be bytes or
95
- * a precompiled `WebAssembly.Module`.
96
- *
97
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
98
- *
99
- * @returns {InitOutput}
100
- */
100
+ * Instantiates the given `module`, which can either be bytes or
101
+ * a precompiled `WebAssembly.Module`.
102
+ *
103
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
104
+ *
105
+ * @returns {InitOutput}
106
+ */
101
107
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
102
108
 
103
109
  /**
104
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
105
- * for everything else, calls `WebAssembly.instantiate` directly.
106
- *
107
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
108
- *
109
- * @returns {Promise<InitOutput>}
110
- */
110
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
111
+ * for everything else, calls `WebAssembly.instantiate` directly.
112
+ *
113
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
114
+ *
115
+ * @returns {Promise<InitOutput>}
116
+ */
111
117
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;