@benrogmans/lemma-engine 0.6.9 → 0.7.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.
- package/README.md +1 -3
- package/lemma.d.ts +46 -33
- package/lemma.js +253 -206
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -222,7 +222,7 @@ interface EvaluationResponse {
|
|
|
222
222
|
document: string;
|
|
223
223
|
rules: {
|
|
224
224
|
[ruleName: string]: {
|
|
225
|
-
value: any; // The computed value (e.g., {Number: "100"}
|
|
225
|
+
value: any; // The computed value (e.g., {Number: "100"})
|
|
226
226
|
veto?: string; // Present if rule was vetoed
|
|
227
227
|
missing_facts?: string[]; // Present if rule couldn't be evaluated
|
|
228
228
|
operations?: Array<{ // Operation records (always present if rule was evaluated)
|
|
@@ -254,8 +254,6 @@ async function typedExample() {
|
|
|
254
254
|
|
|
255
255
|
if (result.success && result.data) {
|
|
256
256
|
const price = result.data.rules.final_price?.value;
|
|
257
|
-
// price might be {Unit: "100 USD"} or {Number: "100"}
|
|
258
|
-
// depending on the rule's result type
|
|
259
257
|
}
|
|
260
258
|
}
|
|
261
259
|
```
|
package/lemma.d.ts
CHANGED
|
@@ -1,49 +1,62 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
|
|
3
4
|
export class WasmEngine {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
addLemmaCode(code: string, source: string): string;
|
|
8
|
+
evaluate(doc_name: string, fact_values_json: string): string;
|
|
9
|
+
evaluateRules(doc_name: string, rule_names_json: string, fact_values_json: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Return a UI-friendly schema for a document: facts + resolved types (from execution plan).
|
|
12
|
+
*
|
|
13
|
+
* This is intended for frontends to build fact input forms without having to parse Lemma code.
|
|
14
|
+
*/
|
|
15
|
+
getDocumentSchema(doc_name: string): string;
|
|
16
|
+
getRequiredFacts(doc_name: string, rule_names_json: string): string;
|
|
17
|
+
invert(_doc_name: string, _rule_name: string, _target_json: string, _provided_values_json: string): string;
|
|
18
|
+
listDocuments(): string;
|
|
19
|
+
constructor();
|
|
11
20
|
}
|
|
12
21
|
|
|
13
22
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
14
23
|
|
|
15
24
|
export interface InitOutput {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
readonly memory: WebAssembly.Memory;
|
|
26
|
+
readonly __wbg_wasmengine_free: (a: number, b: number) => void;
|
|
27
|
+
readonly wasmengine_addLemmaCode: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
28
|
+
readonly wasmengine_evaluate: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
29
|
+
readonly wasmengine_evaluateRules: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
30
|
+
readonly wasmengine_getDocumentSchema: (a: number, b: number, c: number) => [number, number];
|
|
31
|
+
readonly wasmengine_getRequiredFacts: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
32
|
+
readonly wasmengine_invert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
33
|
+
readonly wasmengine_listDocuments: (a: number) => [number, number];
|
|
34
|
+
readonly wasmengine_new: () => number;
|
|
35
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
36
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
37
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
38
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
39
|
+
readonly __wbindgen_start: () => void;
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
43
|
+
|
|
31
44
|
/**
|
|
32
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
33
|
-
* a precompiled `WebAssembly.Module`.
|
|
34
|
-
*
|
|
35
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
36
|
-
*
|
|
37
|
-
* @returns {InitOutput}
|
|
38
|
-
*/
|
|
45
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
46
|
+
* a precompiled `WebAssembly.Module`.
|
|
47
|
+
*
|
|
48
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
49
|
+
*
|
|
50
|
+
* @returns {InitOutput}
|
|
51
|
+
*/
|
|
39
52
|
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
43
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
44
|
-
*
|
|
45
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
46
|
-
*
|
|
47
|
-
* @returns {Promise<InitOutput>}
|
|
48
|
-
*/
|
|
55
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
56
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
57
|
+
*
|
|
58
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
59
|
+
*
|
|
60
|
+
* @returns {Promise<InitOutput>}
|
|
61
|
+
*/
|
|
49
62
|
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/lemma.js
CHANGED
|
@@ -1,111 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let cachedUint8ArrayMemory0 = null;
|
|
4
|
-
|
|
5
|
-
function getUint8ArrayMemory0() {
|
|
6
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
-
}
|
|
9
|
-
return cachedUint8ArrayMemory0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
-
|
|
14
|
-
cachedTextDecoder.decode();
|
|
15
|
-
|
|
16
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
-
let numBytesDecoded = 0;
|
|
18
|
-
function decodeText(ptr, len) {
|
|
19
|
-
numBytesDecoded += len;
|
|
20
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
-
cachedTextDecoder.decode();
|
|
23
|
-
numBytesDecoded = len;
|
|
24
|
-
}
|
|
25
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getStringFromWasm0(ptr, len) {
|
|
29
|
-
ptr = ptr >>> 0;
|
|
30
|
-
return decodeText(ptr, len);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let WASM_VECTOR_LEN = 0;
|
|
34
|
-
|
|
35
|
-
const cachedTextEncoder = new TextEncoder();
|
|
36
|
-
|
|
37
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
38
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
39
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
40
|
-
view.set(buf);
|
|
41
|
-
return {
|
|
42
|
-
read: arg.length,
|
|
43
|
-
written: buf.length
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
49
|
-
|
|
50
|
-
if (realloc === undefined) {
|
|
51
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
52
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
53
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
54
|
-
WASM_VECTOR_LEN = buf.length;
|
|
55
|
-
return ptr;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let len = arg.length;
|
|
59
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
60
|
-
|
|
61
|
-
const mem = getUint8ArrayMemory0();
|
|
62
|
-
|
|
63
|
-
let offset = 0;
|
|
64
|
-
|
|
65
|
-
for (; offset < len; offset++) {
|
|
66
|
-
const code = arg.charCodeAt(offset);
|
|
67
|
-
if (code > 0x7F) break;
|
|
68
|
-
mem[ptr + offset] = code;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (offset !== len) {
|
|
72
|
-
if (offset !== 0) {
|
|
73
|
-
arg = arg.slice(offset);
|
|
74
|
-
}
|
|
75
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
76
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
77
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
78
|
-
|
|
79
|
-
offset += ret.written;
|
|
80
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
WASM_VECTOR_LEN = offset;
|
|
84
|
-
return ptr;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let cachedDataViewMemory0 = null;
|
|
88
|
-
|
|
89
|
-
function getDataViewMemory0() {
|
|
90
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
91
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
92
|
-
}
|
|
93
|
-
return cachedDataViewMemory0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
97
|
-
? { register: () => {}, unregister: () => {} }
|
|
98
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
|
|
1
|
+
/* @ts-self-types="./lemma.d.ts" */
|
|
99
2
|
|
|
100
3
|
export class WasmEngine {
|
|
101
|
-
|
|
102
4
|
__destroy_into_raw() {
|
|
103
5
|
const ptr = this.__wbg_ptr;
|
|
104
6
|
this.__wbg_ptr = 0;
|
|
105
7
|
WasmEngineFinalization.unregister(this);
|
|
106
8
|
return ptr;
|
|
107
9
|
}
|
|
108
|
-
|
|
109
10
|
free() {
|
|
110
11
|
const ptr = this.__destroy_into_raw();
|
|
111
12
|
wasm.__wbg_wasmengine_free(ptr, 0);
|
|
@@ -132,67 +33,85 @@ export class WasmEngine {
|
|
|
132
33
|
}
|
|
133
34
|
}
|
|
134
35
|
/**
|
|
36
|
+
* @param {string} doc_name
|
|
37
|
+
* @param {string} fact_values_json
|
|
135
38
|
* @returns {string}
|
|
136
39
|
*/
|
|
137
|
-
|
|
138
|
-
let
|
|
139
|
-
let
|
|
40
|
+
evaluate(doc_name, fact_values_json) {
|
|
41
|
+
let deferred3_0;
|
|
42
|
+
let deferred3_1;
|
|
140
43
|
try {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
44
|
+
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
45
|
+
const len0 = WASM_VECTOR_LEN;
|
|
46
|
+
const ptr1 = passStringToWasm0(fact_values_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
47
|
+
const len1 = WASM_VECTOR_LEN;
|
|
48
|
+
const ret = wasm.wasmengine_evaluate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
49
|
+
deferred3_0 = ret[0];
|
|
50
|
+
deferred3_1 = ret[1];
|
|
144
51
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
145
52
|
} finally {
|
|
146
|
-
wasm.__wbindgen_free(
|
|
53
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
147
54
|
}
|
|
148
55
|
}
|
|
149
|
-
constructor() {
|
|
150
|
-
const ret = wasm.wasmengine_new();
|
|
151
|
-
this.__wbg_ptr = ret >>> 0;
|
|
152
|
-
WasmEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
153
|
-
return this;
|
|
154
|
-
}
|
|
155
56
|
/**
|
|
156
57
|
* @param {string} doc_name
|
|
157
|
-
* @param {string}
|
|
158
|
-
* @param {string}
|
|
159
|
-
* @param {string} given_facts_json
|
|
58
|
+
* @param {string} rule_names_json
|
|
59
|
+
* @param {string} fact_values_json
|
|
160
60
|
* @returns {string}
|
|
161
61
|
*/
|
|
162
|
-
|
|
163
|
-
let
|
|
164
|
-
let
|
|
62
|
+
evaluateRules(doc_name, rule_names_json, fact_values_json) {
|
|
63
|
+
let deferred4_0;
|
|
64
|
+
let deferred4_1;
|
|
165
65
|
try {
|
|
166
66
|
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
167
67
|
const len0 = WASM_VECTOR_LEN;
|
|
168
|
-
const ptr1 = passStringToWasm0(
|
|
68
|
+
const ptr1 = passStringToWasm0(rule_names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
169
69
|
const len1 = WASM_VECTOR_LEN;
|
|
170
|
-
const ptr2 = passStringToWasm0(
|
|
70
|
+
const ptr2 = passStringToWasm0(fact_values_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
171
71
|
const len2 = WASM_VECTOR_LEN;
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
deferred5_0 = ret[0];
|
|
176
|
-
deferred5_1 = ret[1];
|
|
72
|
+
const ret = wasm.wasmengine_evaluateRules(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
73
|
+
deferred4_0 = ret[0];
|
|
74
|
+
deferred4_1 = ret[1];
|
|
177
75
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
178
76
|
} finally {
|
|
179
|
-
wasm.__wbindgen_free(
|
|
77
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
180
78
|
}
|
|
181
79
|
}
|
|
182
80
|
/**
|
|
81
|
+
* Return a UI-friendly schema for a document: facts + resolved types (from execution plan).
|
|
82
|
+
*
|
|
83
|
+
* This is intended for frontends to build fact input forms without having to parse Lemma code.
|
|
183
84
|
* @param {string} doc_name
|
|
184
|
-
* @param {string} fact_values_json
|
|
185
85
|
* @returns {string}
|
|
186
86
|
*/
|
|
187
|
-
|
|
87
|
+
getDocumentSchema(doc_name) {
|
|
88
|
+
let deferred2_0;
|
|
89
|
+
let deferred2_1;
|
|
90
|
+
try {
|
|
91
|
+
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
92
|
+
const len0 = WASM_VECTOR_LEN;
|
|
93
|
+
const ret = wasm.wasmengine_getDocumentSchema(this.__wbg_ptr, ptr0, len0);
|
|
94
|
+
deferred2_0 = ret[0];
|
|
95
|
+
deferred2_1 = ret[1];
|
|
96
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
97
|
+
} finally {
|
|
98
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @param {string} doc_name
|
|
103
|
+
* @param {string} rule_names_json
|
|
104
|
+
* @returns {string}
|
|
105
|
+
*/
|
|
106
|
+
getRequiredFacts(doc_name, rule_names_json) {
|
|
188
107
|
let deferred3_0;
|
|
189
108
|
let deferred3_1;
|
|
190
109
|
try {
|
|
191
110
|
const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
111
|
const len0 = WASM_VECTOR_LEN;
|
|
193
|
-
const ptr1 = passStringToWasm0(
|
|
112
|
+
const ptr1 = passStringToWasm0(rule_names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
194
113
|
const len1 = WASM_VECTOR_LEN;
|
|
195
|
-
const ret = wasm.
|
|
114
|
+
const ret = wasm.wasmengine_getRequiredFacts(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
196
115
|
deferred3_0 = ret[0];
|
|
197
116
|
deferred3_1 = ret[1];
|
|
198
117
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -200,106 +119,242 @@ export class WasmEngine {
|
|
|
200
119
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
201
120
|
}
|
|
202
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* @param {string} _doc_name
|
|
124
|
+
* @param {string} _rule_name
|
|
125
|
+
* @param {string} _target_json
|
|
126
|
+
* @param {string} _provided_values_json
|
|
127
|
+
* @returns {string}
|
|
128
|
+
*/
|
|
129
|
+
invert(_doc_name, _rule_name, _target_json, _provided_values_json) {
|
|
130
|
+
let deferred5_0;
|
|
131
|
+
let deferred5_1;
|
|
132
|
+
try {
|
|
133
|
+
const ptr0 = passStringToWasm0(_doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
134
|
+
const len0 = WASM_VECTOR_LEN;
|
|
135
|
+
const ptr1 = passStringToWasm0(_rule_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
136
|
+
const len1 = WASM_VECTOR_LEN;
|
|
137
|
+
const ptr2 = passStringToWasm0(_target_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
+
const len2 = WASM_VECTOR_LEN;
|
|
139
|
+
const ptr3 = passStringToWasm0(_provided_values_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
const len3 = WASM_VECTOR_LEN;
|
|
141
|
+
const ret = wasm.wasmengine_invert(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
142
|
+
deferred5_0 = ret[0];
|
|
143
|
+
deferred5_1 = ret[1];
|
|
144
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
145
|
+
} finally {
|
|
146
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @returns {string}
|
|
151
|
+
*/
|
|
152
|
+
listDocuments() {
|
|
153
|
+
let deferred1_0;
|
|
154
|
+
let deferred1_1;
|
|
155
|
+
try {
|
|
156
|
+
const ret = wasm.wasmengine_listDocuments(this.__wbg_ptr);
|
|
157
|
+
deferred1_0 = ret[0];
|
|
158
|
+
deferred1_1 = ret[1];
|
|
159
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
160
|
+
} finally {
|
|
161
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
constructor() {
|
|
165
|
+
const ret = wasm.wasmengine_new();
|
|
166
|
+
this.__wbg_ptr = ret >>> 0;
|
|
167
|
+
WasmEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
203
170
|
}
|
|
204
171
|
if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
|
|
205
172
|
|
|
206
|
-
|
|
173
|
+
function __wbg_get_imports() {
|
|
174
|
+
const import0 = {
|
|
175
|
+
__proto__: null,
|
|
176
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
177
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
178
|
+
},
|
|
179
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
180
|
+
let deferred0_0;
|
|
181
|
+
let deferred0_1;
|
|
182
|
+
try {
|
|
183
|
+
deferred0_0 = arg0;
|
|
184
|
+
deferred0_1 = arg1;
|
|
185
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
186
|
+
} finally {
|
|
187
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
191
|
+
const ret = new Error();
|
|
192
|
+
return ret;
|
|
193
|
+
},
|
|
194
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
195
|
+
const ret = arg1.stack;
|
|
196
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
197
|
+
const len1 = WASM_VECTOR_LEN;
|
|
198
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
199
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
200
|
+
},
|
|
201
|
+
__wbindgen_init_externref_table: function() {
|
|
202
|
+
const table = wasm.__wbindgen_externrefs;
|
|
203
|
+
const offset = table.grow(4);
|
|
204
|
+
table.set(0, undefined);
|
|
205
|
+
table.set(offset + 0, undefined);
|
|
206
|
+
table.set(offset + 1, null);
|
|
207
|
+
table.set(offset + 2, true);
|
|
208
|
+
table.set(offset + 3, false);
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
return {
|
|
212
|
+
__proto__: null,
|
|
213
|
+
"./lemma_bg.js": import0,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
218
|
+
? { register: () => {}, unregister: () => {} }
|
|
219
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
|
|
220
|
+
|
|
221
|
+
let cachedDataViewMemory0 = null;
|
|
222
|
+
function getDataViewMemory0() {
|
|
223
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
224
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
225
|
+
}
|
|
226
|
+
return cachedDataViewMemory0;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function getStringFromWasm0(ptr, len) {
|
|
230
|
+
ptr = ptr >>> 0;
|
|
231
|
+
return decodeText(ptr, len);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let cachedUint8ArrayMemory0 = null;
|
|
235
|
+
function getUint8ArrayMemory0() {
|
|
236
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
237
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
238
|
+
}
|
|
239
|
+
return cachedUint8ArrayMemory0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
243
|
+
if (realloc === undefined) {
|
|
244
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
245
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
246
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
247
|
+
WASM_VECTOR_LEN = buf.length;
|
|
248
|
+
return ptr;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let len = arg.length;
|
|
252
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
253
|
+
|
|
254
|
+
const mem = getUint8ArrayMemory0();
|
|
255
|
+
|
|
256
|
+
let offset = 0;
|
|
257
|
+
|
|
258
|
+
for (; offset < len; offset++) {
|
|
259
|
+
const code = arg.charCodeAt(offset);
|
|
260
|
+
if (code > 0x7F) break;
|
|
261
|
+
mem[ptr + offset] = code;
|
|
262
|
+
}
|
|
263
|
+
if (offset !== len) {
|
|
264
|
+
if (offset !== 0) {
|
|
265
|
+
arg = arg.slice(offset);
|
|
266
|
+
}
|
|
267
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
268
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
269
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
270
|
+
|
|
271
|
+
offset += ret.written;
|
|
272
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
WASM_VECTOR_LEN = offset;
|
|
276
|
+
return ptr;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
280
|
+
cachedTextDecoder.decode();
|
|
281
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
282
|
+
let numBytesDecoded = 0;
|
|
283
|
+
function decodeText(ptr, len) {
|
|
284
|
+
numBytesDecoded += len;
|
|
285
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
286
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
287
|
+
cachedTextDecoder.decode();
|
|
288
|
+
numBytesDecoded = len;
|
|
289
|
+
}
|
|
290
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const cachedTextEncoder = new TextEncoder();
|
|
294
|
+
|
|
295
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
296
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
297
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
298
|
+
view.set(buf);
|
|
299
|
+
return {
|
|
300
|
+
read: arg.length,
|
|
301
|
+
written: buf.length
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
let WASM_VECTOR_LEN = 0;
|
|
307
|
+
|
|
308
|
+
let wasmModule, wasm;
|
|
309
|
+
function __wbg_finalize_init(instance, module) {
|
|
310
|
+
wasm = instance.exports;
|
|
311
|
+
wasmModule = module;
|
|
312
|
+
cachedDataViewMemory0 = null;
|
|
313
|
+
cachedUint8ArrayMemory0 = null;
|
|
314
|
+
wasm.__wbindgen_start();
|
|
315
|
+
return wasm;
|
|
316
|
+
}
|
|
207
317
|
|
|
208
318
|
async function __wbg_load(module, imports) {
|
|
209
319
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
210
320
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
211
321
|
try {
|
|
212
322
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
213
|
-
|
|
214
323
|
} catch (e) {
|
|
215
|
-
const validResponse = module.ok &&
|
|
324
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
216
325
|
|
|
217
326
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
218
327
|
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);
|
|
219
328
|
|
|
220
|
-
} else {
|
|
221
|
-
throw e;
|
|
222
|
-
}
|
|
329
|
+
} else { throw e; }
|
|
223
330
|
}
|
|
224
331
|
}
|
|
225
332
|
|
|
226
333
|
const bytes = await module.arrayBuffer();
|
|
227
334
|
return await WebAssembly.instantiate(bytes, imports);
|
|
228
|
-
|
|
229
335
|
} else {
|
|
230
336
|
const instance = await WebAssembly.instantiate(module, imports);
|
|
231
337
|
|
|
232
338
|
if (instance instanceof WebAssembly.Instance) {
|
|
233
339
|
return { instance, module };
|
|
234
|
-
|
|
235
340
|
} else {
|
|
236
341
|
return instance;
|
|
237
342
|
}
|
|
238
343
|
}
|
|
239
|
-
}
|
|
240
344
|
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
245
|
-
let deferred0_0;
|
|
246
|
-
let deferred0_1;
|
|
247
|
-
try {
|
|
248
|
-
deferred0_0 = arg0;
|
|
249
|
-
deferred0_1 = arg1;
|
|
250
|
-
console.error(getStringFromWasm0(arg0, arg1));
|
|
251
|
-
} finally {
|
|
252
|
-
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
345
|
+
function expectedResponseType(type) {
|
|
346
|
+
switch (type) {
|
|
347
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
253
348
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const ret = new Error();
|
|
257
|
-
return ret;
|
|
258
|
-
};
|
|
259
|
-
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
260
|
-
const ret = arg1.stack;
|
|
261
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
262
|
-
const len1 = WASM_VECTOR_LEN;
|
|
263
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
264
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
265
|
-
};
|
|
266
|
-
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
267
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
268
|
-
};
|
|
269
|
-
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
270
|
-
const table = wasm.__wbindgen_export_3;
|
|
271
|
-
const offset = table.grow(4);
|
|
272
|
-
table.set(0, undefined);
|
|
273
|
-
table.set(offset + 0, undefined);
|
|
274
|
-
table.set(offset + 1, null);
|
|
275
|
-
table.set(offset + 2, true);
|
|
276
|
-
table.set(offset + 3, false);
|
|
277
|
-
;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
return imports;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function __wbg_init_memory(imports, memory) {
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function __wbg_finalize_init(instance, module) {
|
|
288
|
-
wasm = instance.exports;
|
|
289
|
-
__wbg_init.__wbindgen_wasm_module = module;
|
|
290
|
-
cachedDataViewMemory0 = null;
|
|
291
|
-
cachedUint8ArrayMemory0 = null;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
wasm.__wbindgen_start();
|
|
295
|
-
return wasm;
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
296
351
|
}
|
|
297
352
|
|
|
298
353
|
function initSync(module) {
|
|
299
354
|
if (wasm !== undefined) return wasm;
|
|
300
355
|
|
|
301
356
|
|
|
302
|
-
if (
|
|
357
|
+
if (module !== undefined) {
|
|
303
358
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
304
359
|
({module} = module)
|
|
305
360
|
} else {
|
|
@@ -308,15 +363,10 @@ function initSync(module) {
|
|
|
308
363
|
}
|
|
309
364
|
|
|
310
365
|
const imports = __wbg_get_imports();
|
|
311
|
-
|
|
312
|
-
__wbg_init_memory(imports);
|
|
313
|
-
|
|
314
366
|
if (!(module instanceof WebAssembly.Module)) {
|
|
315
367
|
module = new WebAssembly.Module(module);
|
|
316
368
|
}
|
|
317
|
-
|
|
318
369
|
const instance = new WebAssembly.Instance(module, imports);
|
|
319
|
-
|
|
320
370
|
return __wbg_finalize_init(instance, module);
|
|
321
371
|
}
|
|
322
372
|
|
|
@@ -324,7 +374,7 @@ async function __wbg_init(module_or_path) {
|
|
|
324
374
|
if (wasm !== undefined) return wasm;
|
|
325
375
|
|
|
326
376
|
|
|
327
|
-
if (
|
|
377
|
+
if (module_or_path !== undefined) {
|
|
328
378
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
329
379
|
({module_or_path} = module_or_path)
|
|
330
380
|
} else {
|
|
@@ -332,7 +382,7 @@ async function __wbg_init(module_or_path) {
|
|
|
332
382
|
}
|
|
333
383
|
}
|
|
334
384
|
|
|
335
|
-
if (
|
|
385
|
+
if (module_or_path === undefined) {
|
|
336
386
|
module_or_path = new URL('lemma_bg.wasm', import.meta.url);
|
|
337
387
|
}
|
|
338
388
|
const imports = __wbg_get_imports();
|
|
@@ -341,12 +391,9 @@ async function __wbg_init(module_or_path) {
|
|
|
341
391
|
module_or_path = fetch(module_or_path);
|
|
342
392
|
}
|
|
343
393
|
|
|
344
|
-
__wbg_init_memory(imports);
|
|
345
|
-
|
|
346
394
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
347
395
|
|
|
348
396
|
return __wbg_finalize_init(instance, module);
|
|
349
397
|
}
|
|
350
398
|
|
|
351
|
-
export { initSync };
|
|
352
|
-
export default __wbg_init;
|
|
399
|
+
export { initSync, __wbg_init as default };
|
package/lemma_bg.wasm
CHANGED
|
Binary file
|
package/lemma_bg.wasm.d.ts
CHANGED
|
@@ -4,11 +4,14 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const __wbg_wasmengine_free: (a: number, b: number) => void;
|
|
5
5
|
export const wasmengine_addLemmaCode: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
6
6
|
export const wasmengine_evaluate: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
7
|
+
export const wasmengine_evaluateRules: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
8
|
+
export const wasmengine_getDocumentSchema: (a: number, b: number, c: number) => [number, number];
|
|
9
|
+
export const wasmengine_getRequiredFacts: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
7
10
|
export const wasmengine_invert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
8
11
|
export const wasmengine_listDocuments: (a: number) => [number, number];
|
|
9
12
|
export const wasmengine_new: () => number;
|
|
10
13
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
11
14
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
12
15
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
13
|
-
export const
|
|
16
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
14
17
|
export const __wbindgen_start: () => void;
|