@syntropika/tembra-engine-wasm 0.2.1 → 0.3.0

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/dist/tembra.d.ts CHANGED
@@ -5,13 +5,17 @@ export class WasmKernel {
5
5
  free(): void;
6
6
  [Symbol.dispose](): void;
7
7
  /**
8
- * Create one kernel and its metadata bridge.
8
+ * Check an issued invocation through a fixed scalar entry, without an object visitor.
9
9
  */
10
- constructor();
10
+ check(root: number, call?: number | null): string | undefined;
11
+ /**
12
+ * Execute one closed kernel operation and return `{ ok }` or `{ error }`.
13
+ */
14
+ command(op: string, input: any): any;
11
15
  /**
12
- * Execute one metadata request without retaining language values.
16
+ * Create one kernel and its metadata bridge.
13
17
  */
14
- request(metadata: string): string;
18
+ constructor();
15
19
  }
16
20
 
17
21
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -19,12 +23,14 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
19
23
  export interface InitOutput {
20
24
  readonly memory: WebAssembly.Memory;
21
25
  readonly __wbg_wasmkernel_free: (a: number, b: number) => void;
26
+ readonly wasmkernel_check: (a: number, b: number, c: number, d: number, e: number) => void;
27
+ readonly wasmkernel_command: (a: number, b: number, c: number, d: number) => number;
22
28
  readonly wasmkernel_new: () => number;
23
- readonly wasmkernel_request: (a: number, b: number, c: number, d: number) => void;
24
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
25
29
  readonly __wbindgen_export: (a: number, b: number) => number;
26
30
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
27
- readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
31
+ readonly __wbindgen_export3: (a: number) => void;
32
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
33
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
28
34
  }
29
35
 
30
36
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/dist/tembra.js CHANGED
@@ -12,45 +12,274 @@ export class WasmKernel {
12
12
  wasm.__wbg_wasmkernel_free(ptr, 0);
13
13
  }
14
14
  /**
15
- * Create one kernel and its metadata bridge.
16
- */
17
- constructor() {
18
- const ret = wasm.wasmkernel_new();
19
- this.__wbg_ptr = ret;
20
- WasmKernelFinalization.register(this, this.__wbg_ptr, this);
21
- return this;
22
- }
23
- /**
24
- * Execute one metadata request without retaining language values.
25
- * @param {string} metadata
26
- * @returns {string}
15
+ * Check an issued invocation through a fixed scalar entry, without an object visitor.
16
+ * @param {number} root
17
+ * @param {number | null} [call]
18
+ * @returns {string | undefined}
27
19
  */
28
- request(metadata) {
29
- let deferred2_0;
30
- let deferred2_1;
20
+ check(root, call) {
31
21
  try {
32
22
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
33
- const ptr0 = passStringToWasm0(metadata, wasm.__wbindgen_export, wasm.__wbindgen_export2);
34
- const len0 = WASM_VECTOR_LEN;
35
- wasm.wasmkernel_request(retptr, this.__wbg_ptr, ptr0, len0);
23
+ wasm.wasmkernel_check(retptr, this.__wbg_ptr, root, !isLikeNone(call), isLikeNone(call) ? 0 : call);
36
24
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
37
25
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
38
- deferred2_0 = r0;
39
- deferred2_1 = r1;
40
- return getStringFromWasm0(r0, r1);
26
+ let v1;
27
+ if (r0 !== 0) {
28
+ v1 = getStringFromWasm0(r0, r1);
29
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
30
+ }
31
+ return v1;
41
32
  } finally {
42
33
  wasm.__wbindgen_add_to_stack_pointer(16);
43
- wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
44
34
  }
45
35
  }
36
+ /**
37
+ * Execute one closed kernel operation and return `{ ok }` or `{ error }`.
38
+ * @param {string} op
39
+ * @param {any} input
40
+ * @returns {any}
41
+ */
42
+ command(op, input) {
43
+ const ptr0 = passStringToWasm0(op, wasm.__wbindgen_export, wasm.__wbindgen_export2);
44
+ const len0 = WASM_VECTOR_LEN;
45
+ const ret = wasm.wasmkernel_command(this.__wbg_ptr, ptr0, len0, addHeapObject(input));
46
+ return takeObject(ret);
47
+ }
48
+ /**
49
+ * Create one kernel and its metadata bridge.
50
+ */
51
+ constructor() {
52
+ const ret = wasm.wasmkernel_new();
53
+ this.__wbg_ptr = ret;
54
+ WasmKernelFinalization.register(this, this.__wbg_ptr, this);
55
+ return this;
56
+ }
46
57
  }
47
58
  if (Symbol.dispose) WasmKernel.prototype[Symbol.dispose] = WasmKernel.prototype.free;
48
59
  function __wbg_get_imports() {
49
60
  const import0 = {
50
61
  __proto__: null,
62
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
63
+ const ret = Error(getStringFromWasm0(arg0, arg1));
64
+ return addHeapObject(ret);
65
+ },
66
+ __wbg_Number_14af1003b8dd5ead: function(arg0) {
67
+ const ret = Number(getObject(arg0));
68
+ return ret;
69
+ },
70
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
71
+ const ret = String(getObject(arg1));
72
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
73
+ const len1 = WASM_VECTOR_LEN;
74
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
75
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
76
+ },
77
+ __wbg___wbindgen_bigint_get_as_i64_a2383202b9353e4c: function(arg0, arg1) {
78
+ const v = getObject(arg1);
79
+ const ret = typeof(v) === 'bigint' ? v : undefined;
80
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
81
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
82
+ },
83
+ __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
84
+ const v = getObject(arg0);
85
+ const ret = typeof(v) === 'boolean' ? v : undefined;
86
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
87
+ },
88
+ __wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
89
+ const ret = debugString(getObject(arg1));
90
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
93
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
94
+ },
95
+ __wbg___wbindgen_in_92f62ee1427d9e49: function(arg0, arg1) {
96
+ const ret = getObject(arg0) in getObject(arg1);
97
+ return ret;
98
+ },
99
+ __wbg___wbindgen_is_bigint_b123553bed3bb382: function(arg0) {
100
+ const ret = typeof(getObject(arg0)) === 'bigint';
101
+ return ret;
102
+ },
103
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
104
+ const ret = typeof(getObject(arg0)) === 'function';
105
+ return ret;
106
+ },
107
+ __wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
108
+ const val = getObject(arg0);
109
+ const ret = typeof(val) === 'object' && val !== null;
110
+ return ret;
111
+ },
112
+ __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
113
+ const ret = typeof(getObject(arg0)) === 'string';
114
+ return ret;
115
+ },
116
+ __wbg___wbindgen_jsval_eq_02babf21faa37971: function(arg0, arg1) {
117
+ const ret = getObject(arg0) === getObject(arg1);
118
+ return ret;
119
+ },
120
+ __wbg___wbindgen_jsval_loose_eq_677f21e468d6b461: function(arg0, arg1) {
121
+ const ret = getObject(arg0) == getObject(arg1);
122
+ return ret;
123
+ },
124
+ __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
125
+ const obj = getObject(arg1);
126
+ const ret = typeof(obj) === 'number' ? obj : undefined;
127
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
128
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
129
+ },
130
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
131
+ const obj = getObject(arg1);
132
+ const ret = typeof(obj) === 'string' ? obj : undefined;
133
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
134
+ var len1 = WASM_VECTOR_LEN;
135
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
136
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
137
+ },
51
138
  __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
52
139
  throw new Error(getStringFromWasm0(arg0, arg1));
53
140
  },
141
+ __wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
142
+ const ret = getObject(arg0).call(getObject(arg1));
143
+ return addHeapObject(ret);
144
+ }, arguments); },
145
+ __wbg_done_b41a1d26cdb37fb6: function(arg0) {
146
+ const ret = getObject(arg0).done;
147
+ return ret;
148
+ },
149
+ __wbg_entries_fb6397112b1de25f: function(arg0) {
150
+ const ret = Object.entries(getObject(arg0));
151
+ return addHeapObject(ret);
152
+ },
153
+ __wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
154
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
155
+ return addHeapObject(ret);
156
+ }, arguments); },
157
+ __wbg_get_6c896e0571ddae51: function(arg0, arg1) {
158
+ const ret = getObject(arg0)[arg1 >>> 0];
159
+ return addHeapObject(ret);
160
+ },
161
+ __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
162
+ const ret = getObject(arg0)[arg1 >>> 0];
163
+ return addHeapObject(ret);
164
+ },
165
+ __wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
166
+ let result;
167
+ try {
168
+ result = getObject(arg0) instanceof ArrayBuffer;
169
+ } catch (_) {
170
+ result = false;
171
+ }
172
+ const ret = result;
173
+ return ret;
174
+ },
175
+ __wbg_instanceof_Map_b2611749102d7ba3: function(arg0) {
176
+ let result;
177
+ try {
178
+ result = getObject(arg0) instanceof Map;
179
+ } catch (_) {
180
+ result = false;
181
+ }
182
+ const ret = result;
183
+ return ret;
184
+ },
185
+ __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
186
+ let result;
187
+ try {
188
+ result = getObject(arg0) instanceof Uint8Array;
189
+ } catch (_) {
190
+ result = false;
191
+ }
192
+ const ret = result;
193
+ return ret;
194
+ },
195
+ __wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
196
+ const ret = Array.isArray(getObject(arg0));
197
+ return ret;
198
+ },
199
+ __wbg_isSafeInteger_717808ad6a54bd9e: function(arg0) {
200
+ const ret = Number.isSafeInteger(getObject(arg0));
201
+ return ret;
202
+ },
203
+ __wbg_iterator_e3c31c892080e444: function() {
204
+ const ret = Symbol.iterator;
205
+ return addHeapObject(ret);
206
+ },
207
+ __wbg_length_7f3c00c40364105e: function(arg0) {
208
+ const ret = getObject(arg0).length;
209
+ return ret;
210
+ },
211
+ __wbg_length_d4bdea10311bd9cf: function(arg0) {
212
+ const ret = getObject(arg0).length;
213
+ return ret;
214
+ },
215
+ __wbg_new_1dbf7428bba60a42: function(arg0) {
216
+ const ret = new Uint8Array(getObject(arg0));
217
+ return addHeapObject(ret);
218
+ },
219
+ __wbg_new_28744009d011f847: function() {
220
+ const ret = new Map();
221
+ return addHeapObject(ret);
222
+ },
223
+ __wbg_new_617a8cdb8bb1130e: function() {
224
+ const ret = new Object();
225
+ return addHeapObject(ret);
226
+ },
227
+ __wbg_new_ee2291f50781bf1d: function() {
228
+ const ret = new Array();
229
+ return addHeapObject(ret);
230
+ },
231
+ __wbg_next_33784799010f1bbe: function(arg0) {
232
+ const ret = getObject(arg0).next;
233
+ return addHeapObject(ret);
234
+ },
235
+ __wbg_next_f4aac29c42af995c: function() { return handleError(function (arg0) {
236
+ const ret = getObject(arg0).next();
237
+ return addHeapObject(ret);
238
+ }, arguments); },
239
+ __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
240
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
241
+ },
242
+ __wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
243
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
244
+ return addHeapObject(ret);
245
+ },
246
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
247
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
248
+ },
249
+ __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
250
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
251
+ },
252
+ __wbg_value_f3c585ee8f5ba40c: function(arg0) {
253
+ const ret = getObject(arg0).value;
254
+ return addHeapObject(ret);
255
+ },
256
+ __wbindgen_generic_0000000000000001: function(arg0) {
257
+ // Cast intrinsic for `F64 -> Externref`.
258
+ const ret = arg0;
259
+ return addHeapObject(ret);
260
+ },
261
+ __wbindgen_generic_0000000000000002: function(arg0) {
262
+ // Cast intrinsic for `I64 -> Externref`.
263
+ const ret = arg0;
264
+ return addHeapObject(ret);
265
+ },
266
+ __wbindgen_generic_0000000000000003: function(arg0, arg1) {
267
+ // Cast intrinsic for `Ref(String) -> Externref`.
268
+ const ret = getStringFromWasm0(arg0, arg1);
269
+ return addHeapObject(ret);
270
+ },
271
+ __wbindgen_generic_0000000000000004: function(arg0) {
272
+ // Cast intrinsic for `U64 -> Externref`.
273
+ const ret = BigInt.asUintN(64, arg0);
274
+ return addHeapObject(ret);
275
+ },
276
+ __wbindgen_object_clone_ref: function(arg0) {
277
+ const ret = getObject(arg0);
278
+ return addHeapObject(ret);
279
+ },
280
+ __wbindgen_object_drop_ref: function(arg0) {
281
+ takeObject(arg0);
282
+ },
54
283
  };
55
284
  return {
56
285
  __proto__: null,
@@ -62,6 +291,91 @@ const WasmKernelFinalization = (typeof FinalizationRegistry === 'undefined')
62
291
  ? { register: () => {}, unregister: () => {} }
63
292
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmkernel_free(ptr, 1));
64
293
 
294
+ function addHeapObject(obj) {
295
+ if (heap_next === heap.length) heap.push(heap.length + 1);
296
+ const idx = heap_next;
297
+ heap_next = heap[idx];
298
+
299
+ heap[idx] = obj;
300
+ return idx;
301
+ }
302
+
303
+ function debugString(val) {
304
+ // primitive types
305
+ const type = typeof val;
306
+ if (type == 'number' || type == 'boolean' || val == null) {
307
+ return `${val}`;
308
+ }
309
+ if (type == 'string') {
310
+ return `"${val}"`;
311
+ }
312
+ if (type == 'symbol') {
313
+ const description = val.description;
314
+ if (description == null) {
315
+ return 'Symbol';
316
+ } else {
317
+ return `Symbol(${description})`;
318
+ }
319
+ }
320
+ if (type == 'function') {
321
+ const name = val.name;
322
+ if (typeof name == 'string' && name.length > 0) {
323
+ return `Function(${name})`;
324
+ } else {
325
+ return 'Function';
326
+ }
327
+ }
328
+ // objects
329
+ if (Array.isArray(val)) {
330
+ const length = val.length;
331
+ let debug = '[';
332
+ if (length > 0) {
333
+ debug += debugString(val[0]);
334
+ }
335
+ for(let i = 1; i < length; i++) {
336
+ debug += ', ' + debugString(val[i]);
337
+ }
338
+ debug += ']';
339
+ return debug;
340
+ }
341
+ // Test for built-in
342
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
343
+ let className;
344
+ if (builtInMatches && builtInMatches.length > 1) {
345
+ className = builtInMatches[1];
346
+ } else {
347
+ // Failed to match the standard '[object ClassName]'
348
+ return toString.call(val);
349
+ }
350
+ if (className == 'Object') {
351
+ // we're a user defined class or Object
352
+ // JSON.stringify avoids problems with cycles, and is generally much
353
+ // easier than looping through ownProperties of `val`.
354
+ try {
355
+ return 'Object(' + JSON.stringify(val) + ')';
356
+ } catch (_) {
357
+ return 'Object';
358
+ }
359
+ }
360
+ // errors
361
+ if (val instanceof Error) {
362
+ return `${val.name}: ${val.message}\n${val.stack}`;
363
+ }
364
+ // TODO we could test for more things here, like `Set`s and `Map`s.
365
+ return className;
366
+ }
367
+
368
+ function dropObject(idx) {
369
+ if (idx < 1028) return;
370
+ heap[idx] = heap_next;
371
+ heap_next = idx;
372
+ }
373
+
374
+ function getArrayU8FromWasm0(ptr, len) {
375
+ ptr = ptr >>> 0;
376
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
377
+ }
378
+
65
379
  let cachedDataViewMemory0 = null;
66
380
  function getDataViewMemory0() {
67
381
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -82,6 +396,25 @@ function getUint8ArrayMemory0() {
82
396
  return cachedUint8ArrayMemory0;
83
397
  }
84
398
 
399
+ function getObject(idx) { return heap[idx]; }
400
+
401
+ function handleError(f, args) {
402
+ try {
403
+ return f.apply(this, args);
404
+ } catch (e) {
405
+ wasm.__wbindgen_export3(addHeapObject(e));
406
+ }
407
+ }
408
+
409
+ let heap = new Array(1024).fill(undefined);
410
+ heap.push(undefined, null, true, false);
411
+
412
+ let heap_next = heap.length;
413
+
414
+ function isLikeNone(x) {
415
+ return x === undefined || x === null;
416
+ }
417
+
85
418
  function passStringToWasm0(arg, malloc, realloc) {
86
419
  if (realloc === undefined) {
87
420
  const buf = cachedTextEncoder.encode(arg);
@@ -119,6 +452,12 @@ function passStringToWasm0(arg, malloc, realloc) {
119
452
  return ptr;
120
453
  }
121
454
 
455
+ function takeObject(idx) {
456
+ const ret = getObject(idx);
457
+ dropObject(idx);
458
+ return ret;
459
+ }
460
+
122
461
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
123
462
  cachedTextDecoder.decode();
124
463
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
Binary file
@@ -2,9 +2,11 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_wasmkernel_free: (a: number, b: number) => void;
5
+ export const wasmkernel_check: (a: number, b: number, c: number, d: number, e: number) => void;
6
+ export const wasmkernel_command: (a: number, b: number, c: number, d: number) => number;
5
7
  export const wasmkernel_new: () => number;
6
- export const wasmkernel_request: (a: number, b: number, c: number, d: number) => void;
7
- export const __wbindgen_add_to_stack_pointer: (a: number) => number;
8
8
  export const __wbindgen_export: (a: number, b: number) => number;
9
9
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
10
- export const __wbindgen_export3: (a: number, b: number, c: number) => void;
10
+ export const __wbindgen_export3: (a: number) => void;
11
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
12
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syntropika/tembra-engine-wasm",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,7 +16,17 @@
16
16
  "types": "./dist/tembra.d.ts",
17
17
  "default": "./dist/tembra.js"
18
18
  },
19
- "./tembra_bg.wasm": "./dist/tembra_bg.wasm"
19
+ "./tembra_bg.wasm": "./dist/tembra_bg.wasm",
20
+ "./contracts": {
21
+ "types": "./dist/contracts.d.ts",
22
+ "default": "./dist/contracts.js"
23
+ },
24
+ "./contracts_bg.wasm": "./dist/contracts_bg.wasm",
25
+ "./assets": {
26
+ "types": "./dist/assets.d.ts",
27
+ "default": "./dist/assets.js"
28
+ },
29
+ "./interpreter": "./dist/interpreter/interpreter.wasm"
20
30
  },
21
31
  "publishConfig": {
22
32
  "access": "public"