@lemmabase/lemma-engine 0.9.2 → 0.9.4
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 -0
- package/lemma.bindings.d.ts +22 -3
- package/lemma.bindings.js +90 -10
- package/lemma.d.ts +41 -0
- package/lemma.iife.js +1 -1
- package/lemma_bg.wasm +0 -0
- package/lemma_bg.wasm.d.ts +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,6 +119,7 @@ A pre-wired Monaco adapter ships at `@lemmabase/lemma-engine/monaco`.
|
|
|
119
119
|
| `source(repo, spec?, effective?)` | Canonical Lemma source text. Omit `spec` for whole repository. |
|
|
120
120
|
| `run({ spec, repository?, effective?, data?, rules?, explain? })` | Evaluate. Omit `rules` for all rules; pass a non-empty array to scope. `[]` errors. Returns a `Response`. `explain: true` adds per-rule explanation trees. |
|
|
121
121
|
| `remove(repo, name, effective?)` | Remove a temporal spec slice. |
|
|
122
|
+
| `update(repo, name, effective?, code, attribute?)` | Replace a temporal spec slice (atomic remove + load). |
|
|
122
123
|
| `limits()` | Resource limits for this engine. |
|
|
123
124
|
| `format(code, attribute?)` | Canonical formatting; throws `EngineError` on parse error. |
|
|
124
125
|
|
package/lemma.bindings.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export class Engine {
|
|
|
38
38
|
*/
|
|
39
39
|
load(sources: any): void;
|
|
40
40
|
constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Structural quality recommendations across loaded specs. Advisory only.
|
|
43
|
+
*/
|
|
44
|
+
quality(): any;
|
|
41
45
|
/**
|
|
42
46
|
* Remove a temporal spec slice. `effective`: ISO datetime string or omit for now.
|
|
43
47
|
*/
|
|
@@ -56,6 +60,18 @@ export class Engine {
|
|
|
56
60
|
* Formatted canonical Lemma source. Omit `spec` for whole-repository text.
|
|
57
61
|
*/
|
|
58
62
|
source(repository?: string | null, spec?: string | null, effective?: string | null): string;
|
|
63
|
+
/**
|
|
64
|
+
* Replace a temporal spec slice with new source (atomic remove + load).
|
|
65
|
+
*
|
|
66
|
+
* `attribute` is the source label (path or `@owner/repo`). Omit for a volatile source.
|
|
67
|
+
*/
|
|
68
|
+
update(repository: string | null | undefined, spec: string, effective: string | null | undefined, code: string, attribute?: string | null): void;
|
|
69
|
+
/**
|
|
70
|
+
* Create an engine with custom [`crate::ResourceLimits`].
|
|
71
|
+
*
|
|
72
|
+
* Pass a plain object of limit keys (same names as Rust / Java). Unknown keys throw.
|
|
73
|
+
*/
|
|
74
|
+
static withLimits(limits: any): Engine;
|
|
59
75
|
}
|
|
60
76
|
|
|
61
77
|
export class IntoUnderlyingByteSource {
|
|
@@ -125,13 +141,16 @@ export interface InitOutput {
|
|
|
125
141
|
readonly engine_list: (a: number, b: number) => void;
|
|
126
142
|
readonly engine_load: (a: number, b: number, c: number) => void;
|
|
127
143
|
readonly engine_new: () => number;
|
|
144
|
+
readonly engine_quality: (a: number, b: number) => void;
|
|
128
145
|
readonly engine_remove: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
129
146
|
readonly engine_run: (a: number, b: number, c: number) => void;
|
|
130
147
|
readonly engine_show: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
131
148
|
readonly engine_source: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
132
|
-
readonly
|
|
133
|
-
readonly
|
|
134
|
-
readonly
|
|
149
|
+
readonly engine_update: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
150
|
+
readonly engine_withLimits: (a: number, b: number) => void;
|
|
151
|
+
readonly __wasm_bindgen_func_elem_12532: (a: number, b: number, c: number, d: number) => void;
|
|
152
|
+
readonly __wasm_bindgen_func_elem_2733: (a: number, b: number, c: number, d: number) => void;
|
|
153
|
+
readonly __wasm_bindgen_func_elem_12539: (a: number, b: number, c: number, d: number) => void;
|
|
135
154
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
136
155
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
137
156
|
readonly __wbindgen_export3: (a: number) => void;
|
package/lemma.bindings.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/* @ts-self-types="./lemma.d.ts" */
|
|
2
2
|
|
|
3
3
|
export class Engine {
|
|
4
|
+
static __wrap(ptr) {
|
|
5
|
+
const obj = Object.create(Engine.prototype);
|
|
6
|
+
obj.__wbg_ptr = ptr;
|
|
7
|
+
EngineFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
8
|
+
return obj;
|
|
9
|
+
}
|
|
4
10
|
__destroy_into_raw() {
|
|
5
11
|
const ptr = this.__wbg_ptr;
|
|
6
12
|
this.__wbg_ptr = 0;
|
|
@@ -114,6 +120,25 @@ export class Engine {
|
|
|
114
120
|
EngineFinalization.register(this, this.__wbg_ptr, this);
|
|
115
121
|
return this;
|
|
116
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Structural quality recommendations across loaded specs. Advisory only.
|
|
125
|
+
* @returns {any}
|
|
126
|
+
*/
|
|
127
|
+
quality() {
|
|
128
|
+
try {
|
|
129
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
130
|
+
wasm.engine_quality(retptr, this.__wbg_ptr);
|
|
131
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
132
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
133
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
134
|
+
if (r2) {
|
|
135
|
+
throw takeObject(r1);
|
|
136
|
+
}
|
|
137
|
+
return takeObject(r0);
|
|
138
|
+
} finally {
|
|
139
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
117
142
|
/**
|
|
118
143
|
* Remove a temporal spec slice. `effective`: ISO datetime string or omit for now.
|
|
119
144
|
* @param {string | null | undefined} repository
|
|
@@ -226,6 +251,61 @@ export class Engine {
|
|
|
226
251
|
wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
227
252
|
}
|
|
228
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Replace a temporal spec slice with new source (atomic remove + load).
|
|
256
|
+
*
|
|
257
|
+
* `attribute` is the source label (path or `@owner/repo`). Omit for a volatile source.
|
|
258
|
+
* @param {string | null | undefined} repository
|
|
259
|
+
* @param {string} spec
|
|
260
|
+
* @param {string | null | undefined} effective
|
|
261
|
+
* @param {string} code
|
|
262
|
+
* @param {string | null} [attribute]
|
|
263
|
+
*/
|
|
264
|
+
update(repository, spec, effective, code, attribute) {
|
|
265
|
+
try {
|
|
266
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
267
|
+
var ptr0 = isLikeNone(repository) ? 0 : passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
268
|
+
var len0 = WASM_VECTOR_LEN;
|
|
269
|
+
const ptr1 = passStringToWasm0(spec, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
270
|
+
const len1 = WASM_VECTOR_LEN;
|
|
271
|
+
var ptr2 = isLikeNone(effective) ? 0 : passStringToWasm0(effective, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
272
|
+
var len2 = WASM_VECTOR_LEN;
|
|
273
|
+
const ptr3 = passStringToWasm0(code, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
274
|
+
const len3 = WASM_VECTOR_LEN;
|
|
275
|
+
var ptr4 = isLikeNone(attribute) ? 0 : passStringToWasm0(attribute, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
276
|
+
var len4 = WASM_VECTOR_LEN;
|
|
277
|
+
wasm.engine_update(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
278
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
279
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
280
|
+
if (r1) {
|
|
281
|
+
throw takeObject(r0);
|
|
282
|
+
}
|
|
283
|
+
} finally {
|
|
284
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Create an engine with custom [`crate::ResourceLimits`].
|
|
289
|
+
*
|
|
290
|
+
* Pass a plain object of limit keys (same names as Rust / Java). Unknown keys throw.
|
|
291
|
+
* @param {any} limits
|
|
292
|
+
* @returns {Engine}
|
|
293
|
+
*/
|
|
294
|
+
static withLimits(limits) {
|
|
295
|
+
try {
|
|
296
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
297
|
+
wasm.engine_withLimits(retptr, addHeapObject(limits));
|
|
298
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
299
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
300
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
301
|
+
if (r2) {
|
|
302
|
+
throw takeObject(r1);
|
|
303
|
+
}
|
|
304
|
+
return Engine.__wrap(r0);
|
|
305
|
+
} finally {
|
|
306
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
229
309
|
}
|
|
230
310
|
if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
|
|
231
311
|
|
|
@@ -690,7 +770,7 @@ function __wbg_get_imports() {
|
|
|
690
770
|
const a = state0.a;
|
|
691
771
|
state0.a = 0;
|
|
692
772
|
try {
|
|
693
|
-
return
|
|
773
|
+
return __wasm_bindgen_func_elem_12539(a, state0.b, arg0, arg1);
|
|
694
774
|
} finally {
|
|
695
775
|
state0.a = a;
|
|
696
776
|
}
|
|
@@ -849,13 +929,13 @@ function __wbg_get_imports() {
|
|
|
849
929
|
return addHeapObject(ret);
|
|
850
930
|
},
|
|
851
931
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
852
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
853
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
932
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1404, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
933
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12532);
|
|
854
934
|
return addHeapObject(ret);
|
|
855
935
|
},
|
|
856
936
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
857
937
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("IteratorResult<any>")], shim_idx: 7, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
858
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
938
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2733);
|
|
859
939
|
return addHeapObject(ret);
|
|
860
940
|
},
|
|
861
941
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -892,10 +972,10 @@ function __wbg_get_imports() {
|
|
|
892
972
|
};
|
|
893
973
|
}
|
|
894
974
|
|
|
895
|
-
function
|
|
975
|
+
function __wasm_bindgen_func_elem_12532(arg0, arg1, arg2) {
|
|
896
976
|
try {
|
|
897
977
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
898
|
-
wasm.
|
|
978
|
+
wasm.__wasm_bindgen_func_elem_12532(retptr, arg0, arg1, addHeapObject(arg2));
|
|
899
979
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
900
980
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
901
981
|
if (r1) {
|
|
@@ -906,10 +986,10 @@ function __wasm_bindgen_func_elem_12434(arg0, arg1, arg2) {
|
|
|
906
986
|
}
|
|
907
987
|
}
|
|
908
988
|
|
|
909
|
-
function
|
|
989
|
+
function __wasm_bindgen_func_elem_2733(arg0, arg1, arg2) {
|
|
910
990
|
try {
|
|
911
991
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
912
|
-
wasm.
|
|
992
|
+
wasm.__wasm_bindgen_func_elem_2733(retptr, arg0, arg1, addHeapObject(arg2));
|
|
913
993
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
914
994
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
915
995
|
if (r1) {
|
|
@@ -920,8 +1000,8 @@ function __wasm_bindgen_func_elem_2732(arg0, arg1, arg2) {
|
|
|
920
1000
|
}
|
|
921
1001
|
}
|
|
922
1002
|
|
|
923
|
-
function
|
|
924
|
-
wasm.
|
|
1003
|
+
function __wasm_bindgen_func_elem_12539(arg0, arg1, arg2, arg3) {
|
|
1004
|
+
wasm.__wasm_bindgen_func_elem_12539(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
925
1005
|
}
|
|
926
1006
|
|
|
927
1007
|
|
package/lemma.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ export interface RegistryFetchResult {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
declare module './lemma.bindings.js' {
|
|
13
|
+
namespace Engine {
|
|
14
|
+
/** Create engine with named limit overrides. Unknown keys throw. */
|
|
15
|
+
function withLimits(limits: Record<string, number>): Engine;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
interface Engine {
|
|
14
19
|
/**
|
|
15
20
|
* Load Lemma source(s).
|
|
@@ -60,6 +65,18 @@ declare module './lemma.bindings.js' {
|
|
|
60
65
|
effective?: string | null,
|
|
61
66
|
): void;
|
|
62
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Replace a temporal spec slice with new source (atomic remove + load).
|
|
70
|
+
* `attribute` is the source label (path or `@owner/repo`); omit for volatile.
|
|
71
|
+
*/
|
|
72
|
+
update(
|
|
73
|
+
repository: string | null | undefined,
|
|
74
|
+
spec: string,
|
|
75
|
+
effective: string | null | undefined,
|
|
76
|
+
code: string,
|
|
77
|
+
attribute?: string | null,
|
|
78
|
+
): void;
|
|
79
|
+
|
|
63
80
|
/** Resource limits configured for this engine. */
|
|
64
81
|
limits(): ResourceLimits;
|
|
65
82
|
|
|
@@ -69,6 +86,11 @@ declare module './lemma.bindings.js' {
|
|
|
69
86
|
*/
|
|
70
87
|
format(code: string, attribute?: string | null): string;
|
|
71
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Structural quality recommendations across loaded specs. Advisory only.
|
|
91
|
+
*/
|
|
92
|
+
quality(): Recommendation[];
|
|
93
|
+
|
|
72
94
|
/**
|
|
73
95
|
* Evaluate a spec. Pass integers as numbers, decimals as strings in `data`.
|
|
74
96
|
*/
|
|
@@ -471,3 +493,22 @@ export interface ResourceLimits {
|
|
|
471
493
|
max_dag_specs: number;
|
|
472
494
|
max_normal_form_depth: number;
|
|
473
495
|
}
|
|
496
|
+
|
|
497
|
+
/** Source location on a quality recommendation. Same shape as {@link EngineErrorSource}. */
|
|
498
|
+
export interface RecommendationSource {
|
|
499
|
+
attribute: string;
|
|
500
|
+
line: number;
|
|
501
|
+
column: number;
|
|
502
|
+
length: number;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** One structural quality recommendation from {@link Engine.quality}. */
|
|
506
|
+
export interface Recommendation {
|
|
507
|
+
/** Advisory prose only. Temporal identity is in `spec` + `effective_from`. */
|
|
508
|
+
message: string;
|
|
509
|
+
spec: string;
|
|
510
|
+
/** Declared temporal start of the analyzed slice, or null for Origin. */
|
|
511
|
+
effective_from: string | null;
|
|
512
|
+
repository: string | null;
|
|
513
|
+
source: RecommendationSource;
|
|
514
|
+
}
|