@spooky-sync/ssp-wasm 0.0.1-canary.64 → 0.0.1-canary.66

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/AGENTS.md ADDED
@@ -0,0 +1,35 @@
1
+ # `@spooky-sync/ssp-wasm` — agent guide
2
+
3
+ ## What this package is
4
+
5
+ The browser-side stream processor: a Rust crate compiled to WebAssembly via `wasm-pack` that runs the same DBSP-style materialized-view circuit as the Rust `apps/ssp` server, but inside the user's tab. `@spooky-sync/core` instantiates it under the hood to power local reactive queries — you almost never touch this package directly.
6
+
7
+ ## When you might touch it
8
+
9
+ - You're debugging why a local query doesn't update after a mutation. `ingest()` is where new records land.
10
+ - You're testing the surrealism (embedded WASM) generation mode of `spky generate` and need to inspect the bundled circuit.
11
+ - You're saving/restoring local state across page loads outside the built-in IndexedDB persistence path (`save_state` / `load_state`).
12
+
13
+ ## Public API (`pkg/ssp_wasm.d.ts`)
14
+
15
+ - **`class Sp00kyProcessor`** (constructed once, stored on the client):
16
+ - `register_view(config: WasmViewConfig)` — register a materialized view by ID + SurQL + params.
17
+ - `unregister_view(id)` — remove a view.
18
+ - `ingest(table, op, id, record)` — push a row change; returns the affected views' deltas (`WasmViewUpdate[]`).
19
+ - `save_state()` / `load_state(json)` — serialize/restore the circuit.
20
+ - `free()` / `[Symbol.dispose]` — release WASM memory.
21
+ - **`init()`** — must be called once after the WASM module loads.
22
+ - Types: `WasmViewConfig`, `WasmViewUpdate`, `WasmIngestItem`.
23
+
24
+ ## Build
25
+
26
+ ```bash
27
+ pnpm --filter @spooky-sync/ssp-wasm build # wasm-pack build --target web --out-dir pkg
28
+ ```
29
+
30
+ Output is `pkg/`, which is the only directory shipped via `files`. The Rust source lives one level up in `packages/ssp/src/circuit/`.
31
+
32
+ ## Pointers
33
+
34
+ - Server-side counterpart (same circuit, native build): `apps/ssp/`
35
+ - Sync engine that wires this in: `node_modules/@spooky-sync/core/AGENTS.md` → `src/modules/data/`
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@spooky-sync/ssp-wasm",
3
- "version": "0.0.1-canary.64",
3
+ "version": "0.0.1-canary.66",
4
4
  "main": "pkg/ssp_wasm.js",
5
5
  "types": "pkg/ssp_wasm.d.ts",
6
6
  "files": [
7
- "pkg"
7
+ "pkg",
8
+ "AGENTS.md"
8
9
  ],
9
10
  "repository": {
10
11
  "type": "git",
package/pkg/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ssp-wasm",
3
3
  "type": "module",
4
4
  "description": "WASM bindings for ssp",
5
- "version": "0.0.1-canary.64",
5
+ "version": "0.0.1-canary.66",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "ssp_wasm_bg.wasm",
package/pkg/ssp_wasm.d.ts CHANGED
@@ -2,60 +2,60 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  export interface WasmViewUpdate {
5
- query_id: string;
6
- result_hash: string;
7
- result_data: [string, number][];
8
- delta: {
9
- additions: [string, number][];
10
- removals: string[];
11
- updates: [string, number][];
12
- };
5
+ query_id: string;
6
+ result_hash: string;
7
+ result_data: [string, number][];
8
+ delta: {
9
+ additions: [string, number][];
10
+ removals: string[];
11
+ updates: [string, number][];
12
+ };
13
13
  }
14
14
 
15
15
  export interface WasmViewConfig {
16
- id: string;
17
- surql: string;
18
- params?: Record<string, any>;
19
- clientId: string;
20
- ttl: string;
21
- lastActiveAt: string;
22
- safe_params?: Record<string, any>;
23
- format?: 'flat' | 'tree' | 'streaming';
16
+ id: string;
17
+ surql: string;
18
+ params?: Record<string, any>;
19
+ clientId: string;
20
+ ttl: string;
21
+ lastActiveAt: string;
22
+ safe_params?: Record<string, any>;
23
+ format?: 'flat' | 'tree' | 'streaming';
24
24
  }
25
25
 
26
26
  export interface WasmIngestItem {
27
- table: string;
28
- op: string;
29
- id: string;
30
- record: any;
27
+ table: string;
28
+ op: string;
29
+ id: string;
30
+ record: any;
31
31
  }
32
32
 
33
33
 
34
34
 
35
35
  export class Sp00kyProcessor {
36
- free(): void;
37
- [Symbol.dispose](): void;
38
- /**
39
- * Load circuit state from a JSON string
40
- */
41
- load_state(state: string): void;
42
- /**
43
- * Save the current circuit state as a JSON string
44
- */
45
- save_state(): string;
46
- /**
47
- * Register a new materialized view
48
- */
49
- register_view(config: any): any;
50
- /**
51
- * Unregister a view by ID
52
- */
53
- unregister_view(id: string): void;
54
- constructor();
55
- /**
56
- * Ingest a record into the stream processor
57
- */
58
- ingest(table: string, op: string, id: string, record: any): any;
36
+ free(): void;
37
+ [Symbol.dispose](): void;
38
+ /**
39
+ * Ingest a record into the stream processor
40
+ */
41
+ ingest(table: string, op: string, id: string, record: any): any;
42
+ /**
43
+ * Load circuit state from a JSON string
44
+ */
45
+ load_state(state: string): void;
46
+ constructor();
47
+ /**
48
+ * Register a new materialized view
49
+ */
50
+ register_view(config: any): any;
51
+ /**
52
+ * Save the current circuit state as a JSON string
53
+ */
54
+ save_state(): string;
55
+ /**
56
+ * Unregister a view by ID
57
+ */
58
+ unregister_view(id: string): void;
59
59
  }
60
60
 
61
61
  /**
@@ -66,43 +66,43 @@ export function init(): void;
66
66
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
67
67
 
68
68
  export interface InitOutput {
69
- readonly memory: WebAssembly.Memory;
70
- readonly __wbg_sp00kyprocessor_free: (a: number, b: number) => void;
71
- readonly init: () => void;
72
- readonly sp00kyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
73
- readonly sp00kyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
74
- readonly sp00kyprocessor_new: () => number;
75
- readonly sp00kyprocessor_register_view: (a: number, b: any) => [number, number, number];
76
- readonly sp00kyprocessor_save_state: (a: number) => [number, number, number, number];
77
- readonly sp00kyprocessor_unregister_view: (a: number, b: number, c: number) => void;
78
- readonly __wbindgen_malloc: (a: number, b: number) => number;
79
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
80
- readonly __wbindgen_exn_store: (a: number) => void;
81
- readonly __externref_table_alloc: () => number;
82
- readonly __wbindgen_externrefs: WebAssembly.Table;
83
- readonly __externref_table_dealloc: (a: number) => void;
84
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
85
- readonly __wbindgen_start: () => void;
69
+ readonly memory: WebAssembly.Memory;
70
+ readonly __wbg_sp00kyprocessor_free: (a: number, b: number) => void;
71
+ readonly init: () => void;
72
+ readonly sp00kyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
73
+ readonly sp00kyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
74
+ readonly sp00kyprocessor_new: () => number;
75
+ readonly sp00kyprocessor_register_view: (a: number, b: any) => [number, number, number];
76
+ readonly sp00kyprocessor_save_state: (a: number) => [number, number, number, number];
77
+ readonly sp00kyprocessor_unregister_view: (a: number, b: number, c: number) => void;
78
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
79
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
80
+ readonly __wbindgen_exn_store: (a: number) => void;
81
+ readonly __externref_table_alloc: () => number;
82
+ readonly __wbindgen_externrefs: WebAssembly.Table;
83
+ readonly __externref_table_dealloc: (a: number) => void;
84
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
85
+ readonly __wbindgen_start: () => void;
86
86
  }
87
87
 
88
88
  export type SyncInitInput = BufferSource | WebAssembly.Module;
89
89
 
90
90
  /**
91
- * Instantiates the given `module`, which can either be bytes or
92
- * a precompiled `WebAssembly.Module`.
93
- *
94
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
95
- *
96
- * @returns {InitOutput}
97
- */
91
+ * Instantiates the given `module`, which can either be bytes or
92
+ * a precompiled `WebAssembly.Module`.
93
+ *
94
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
95
+ *
96
+ * @returns {InitOutput}
97
+ */
98
98
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
99
99
 
100
100
  /**
101
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
102
- * for everything else, calls `WebAssembly.instantiate` directly.
103
- *
104
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
105
- *
106
- * @returns {Promise<InitOutput>}
107
- */
101
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
102
+ * for everything else, calls `WebAssembly.instantiate` directly.
103
+ *
104
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
105
+ *
106
+ * @returns {Promise<InitOutput>}
107
+ */
108
108
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/pkg/ssp_wasm.js CHANGED
@@ -1,4 +1,330 @@
1
- let wasm;
1
+ /* @ts-self-types="./ssp_wasm.d.ts" */
2
+
3
+ export class Sp00kyProcessor {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ Sp00kyProcessorFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_sp00kyprocessor_free(ptr, 0);
13
+ }
14
+ /**
15
+ * Ingest a record into the stream processor
16
+ * @param {string} table
17
+ * @param {string} op
18
+ * @param {string} id
19
+ * @param {any} record
20
+ * @returns {any}
21
+ */
22
+ ingest(table, op, id, record) {
23
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
24
+ const len0 = WASM_VECTOR_LEN;
25
+ const ptr1 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
26
+ const len1 = WASM_VECTOR_LEN;
27
+ const ptr2 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
28
+ const len2 = WASM_VECTOR_LEN;
29
+ const ret = wasm.sp00kyprocessor_ingest(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, record);
30
+ if (ret[2]) {
31
+ throw takeFromExternrefTable0(ret[1]);
32
+ }
33
+ return takeFromExternrefTable0(ret[0]);
34
+ }
35
+ /**
36
+ * Load circuit state from a JSON string
37
+ * @param {string} state
38
+ */
39
+ load_state(state) {
40
+ const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ const ret = wasm.sp00kyprocessor_load_state(this.__wbg_ptr, ptr0, len0);
43
+ if (ret[1]) {
44
+ throw takeFromExternrefTable0(ret[0]);
45
+ }
46
+ }
47
+ constructor() {
48
+ const ret = wasm.sp00kyprocessor_new();
49
+ this.__wbg_ptr = ret >>> 0;
50
+ Sp00kyProcessorFinalization.register(this, this.__wbg_ptr, this);
51
+ return this;
52
+ }
53
+ /**
54
+ * Register a new materialized view
55
+ * @param {any} config
56
+ * @returns {any}
57
+ */
58
+ register_view(config) {
59
+ const ret = wasm.sp00kyprocessor_register_view(this.__wbg_ptr, config);
60
+ if (ret[2]) {
61
+ throw takeFromExternrefTable0(ret[1]);
62
+ }
63
+ return takeFromExternrefTable0(ret[0]);
64
+ }
65
+ /**
66
+ * Save the current circuit state as a JSON string
67
+ * @returns {string}
68
+ */
69
+ save_state() {
70
+ let deferred2_0;
71
+ let deferred2_1;
72
+ try {
73
+ const ret = wasm.sp00kyprocessor_save_state(this.__wbg_ptr);
74
+ var ptr1 = ret[0];
75
+ var len1 = ret[1];
76
+ if (ret[3]) {
77
+ ptr1 = 0; len1 = 0;
78
+ throw takeFromExternrefTable0(ret[2]);
79
+ }
80
+ deferred2_0 = ptr1;
81
+ deferred2_1 = len1;
82
+ return getStringFromWasm0(ptr1, len1);
83
+ } finally {
84
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
85
+ }
86
+ }
87
+ /**
88
+ * Unregister a view by ID
89
+ * @param {string} id
90
+ */
91
+ unregister_view(id) {
92
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ const len0 = WASM_VECTOR_LEN;
94
+ wasm.sp00kyprocessor_unregister_view(this.__wbg_ptr, ptr0, len0);
95
+ }
96
+ }
97
+ if (Symbol.dispose) Sp00kyProcessor.prototype[Symbol.dispose] = Sp00kyProcessor.prototype.free;
98
+
99
+ /**
100
+ * Called when WASM module is loaded
101
+ */
102
+ export function init() {
103
+ wasm.init();
104
+ }
105
+ function __wbg_get_imports() {
106
+ const import0 = {
107
+ __proto__: null,
108
+ __wbg_Error_960c155d3d49e4c2: function(arg0, arg1) {
109
+ const ret = Error(getStringFromWasm0(arg0, arg1));
110
+ return ret;
111
+ },
112
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
113
+ const ret = String(arg1);
114
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
115
+ const len1 = WASM_VECTOR_LEN;
116
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
117
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
118
+ },
119
+ __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51: function(arg0, arg1) {
120
+ const v = arg1;
121
+ const ret = typeof(v) === 'bigint' ? v : undefined;
122
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
123
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
124
+ },
125
+ __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff: function(arg0) {
126
+ const v = arg0;
127
+ const ret = typeof(v) === 'boolean' ? v : undefined;
128
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
129
+ },
130
+ __wbg___wbindgen_debug_string_ab4b34d23d6778bd: function(arg0, arg1) {
131
+ const ret = debugString(arg1);
132
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ const len1 = WASM_VECTOR_LEN;
134
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
135
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
136
+ },
137
+ __wbg___wbindgen_in_a5d8b22e52b24dd1: function(arg0, arg1) {
138
+ const ret = arg0 in arg1;
139
+ return ret;
140
+ },
141
+ __wbg___wbindgen_is_bigint_ec25c7f91b4d9e93: function(arg0) {
142
+ const ret = typeof(arg0) === 'bigint';
143
+ return ret;
144
+ },
145
+ __wbg___wbindgen_is_function_3baa9db1a987f47d: function(arg0) {
146
+ const ret = typeof(arg0) === 'function';
147
+ return ret;
148
+ },
149
+ __wbg___wbindgen_is_object_63322ec0cd6ea4ef: function(arg0) {
150
+ const val = arg0;
151
+ const ret = typeof(val) === 'object' && val !== null;
152
+ return ret;
153
+ },
154
+ __wbg___wbindgen_jsval_eq_d3465d8a07697228: function(arg0, arg1) {
155
+ const ret = arg0 === arg1;
156
+ return ret;
157
+ },
158
+ __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c: function(arg0, arg1) {
159
+ const ret = arg0 == arg1;
160
+ return ret;
161
+ },
162
+ __wbg___wbindgen_number_get_c7f42aed0525c451: function(arg0, arg1) {
163
+ const obj = arg1;
164
+ const ret = typeof(obj) === 'number' ? obj : undefined;
165
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
166
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
167
+ },
168
+ __wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {
169
+ const obj = arg1;
170
+ const ret = typeof(obj) === 'string' ? obj : undefined;
171
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
172
+ var len1 = WASM_VECTOR_LEN;
173
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
174
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
175
+ },
176
+ __wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
177
+ throw new Error(getStringFromWasm0(arg0, arg1));
178
+ },
179
+ __wbg_call_14b169f759b26747: function() { return handleError(function (arg0, arg1) {
180
+ const ret = arg0.call(arg1);
181
+ return ret;
182
+ }, arguments); },
183
+ __wbg_done_9158f7cc8751ba32: function(arg0) {
184
+ const ret = arg0.done;
185
+ return ret;
186
+ },
187
+ __wbg_entries_e0b73aa8571ddb56: function(arg0) {
188
+ const ret = Object.entries(arg0);
189
+ return ret;
190
+ },
191
+ __wbg_get_1affdbdd5573b16a: function() { return handleError(function (arg0, arg1) {
192
+ const ret = Reflect.get(arg0, arg1);
193
+ return ret;
194
+ }, arguments); },
195
+ __wbg_get_8360291721e2339f: function(arg0, arg1) {
196
+ const ret = arg0[arg1 >>> 0];
197
+ return ret;
198
+ },
199
+ __wbg_get_unchecked_17f53dad852b9588: function(arg0, arg1) {
200
+ const ret = arg0[arg1 >>> 0];
201
+ return ret;
202
+ },
203
+ __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3: function(arg0) {
204
+ let result;
205
+ try {
206
+ result = arg0 instanceof ArrayBuffer;
207
+ } catch (_) {
208
+ result = false;
209
+ }
210
+ const ret = result;
211
+ return ret;
212
+ },
213
+ __wbg_instanceof_Map_1b76fd4635be43eb: function(arg0) {
214
+ let result;
215
+ try {
216
+ result = arg0 instanceof Map;
217
+ } catch (_) {
218
+ result = false;
219
+ }
220
+ const ret = result;
221
+ return ret;
222
+ },
223
+ __wbg_instanceof_Uint8Array_152ba1f289edcf3f: function(arg0) {
224
+ let result;
225
+ try {
226
+ result = arg0 instanceof Uint8Array;
227
+ } catch (_) {
228
+ result = false;
229
+ }
230
+ const ret = result;
231
+ return ret;
232
+ },
233
+ __wbg_isArray_c3109d14ffc06469: function(arg0) {
234
+ const ret = Array.isArray(arg0);
235
+ return ret;
236
+ },
237
+ __wbg_isSafeInteger_4fc213d1989d6d2a: function(arg0) {
238
+ const ret = Number.isSafeInteger(arg0);
239
+ return ret;
240
+ },
241
+ __wbg_iterator_013bc09ec998c2a7: function() {
242
+ const ret = Symbol.iterator;
243
+ return ret;
244
+ },
245
+ __wbg_length_3d4ecd04bd8d22f1: function(arg0) {
246
+ const ret = arg0.length;
247
+ return ret;
248
+ },
249
+ __wbg_length_9f1775224cf1d815: function(arg0) {
250
+ const ret = arg0.length;
251
+ return ret;
252
+ },
253
+ __wbg_log_7e1aa9064a1dbdbd: function(arg0) {
254
+ console.log(arg0);
255
+ },
256
+ __wbg_new_0c7403db6e782f19: function(arg0) {
257
+ const ret = new Uint8Array(arg0);
258
+ return ret;
259
+ },
260
+ __wbg_new_682678e2f47e32bc: function() {
261
+ const ret = new Array();
262
+ return ret;
263
+ },
264
+ __wbg_new_aa8d0fa9762c29bd: function() {
265
+ const ret = new Object();
266
+ return ret;
267
+ },
268
+ __wbg_next_0340c4ae324393c3: function() { return handleError(function (arg0) {
269
+ const ret = arg0.next();
270
+ return ret;
271
+ }, arguments); },
272
+ __wbg_next_7646edaa39458ef7: function(arg0) {
273
+ const ret = arg0.next;
274
+ return ret;
275
+ },
276
+ __wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {
277
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
278
+ },
279
+ __wbg_set_3bf1de9fab0cd644: function(arg0, arg1, arg2) {
280
+ arg0[arg1 >>> 0] = arg2;
281
+ },
282
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
283
+ arg0[arg1] = arg2;
284
+ },
285
+ __wbg_value_ee3a06f4579184fa: function(arg0) {
286
+ const ret = arg0.value;
287
+ return ret;
288
+ },
289
+ __wbindgen_cast_0000000000000001: function(arg0) {
290
+ // Cast intrinsic for `F64 -> Externref`.
291
+ const ret = arg0;
292
+ return ret;
293
+ },
294
+ __wbindgen_cast_0000000000000002: function(arg0) {
295
+ // Cast intrinsic for `I64 -> Externref`.
296
+ const ret = arg0;
297
+ return ret;
298
+ },
299
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
300
+ // Cast intrinsic for `Ref(String) -> Externref`.
301
+ const ret = getStringFromWasm0(arg0, arg1);
302
+ return ret;
303
+ },
304
+ __wbindgen_cast_0000000000000004: function(arg0) {
305
+ // Cast intrinsic for `U64 -> Externref`.
306
+ const ret = BigInt.asUintN(64, arg0);
307
+ return ret;
308
+ },
309
+ __wbindgen_init_externref_table: function() {
310
+ const table = wasm.__wbindgen_externrefs;
311
+ const offset = table.grow(4);
312
+ table.set(0, undefined);
313
+ table.set(offset + 0, undefined);
314
+ table.set(offset + 1, null);
315
+ table.set(offset + 2, true);
316
+ table.set(offset + 3, false);
317
+ },
318
+ };
319
+ return {
320
+ __proto__: null,
321
+ "./ssp_wasm_bg.js": import0,
322
+ };
323
+ }
324
+
325
+ const Sp00kyProcessorFinalization = (typeof FinalizationRegistry === 'undefined')
326
+ ? { register: () => {}, unregister: () => {} }
327
+ : new FinalizationRegistry(ptr => wasm.__wbg_sp00kyprocessor_free(ptr >>> 0, 1));
2
328
 
3
329
  function addToExternrefTable0(obj) {
4
330
  const idx = wasm.__externref_table_alloc();
@@ -177,134 +503,33 @@ if (!('encodeInto' in cachedTextEncoder)) {
177
503
  read: arg.length,
178
504
  written: buf.length
179
505
  };
180
- }
506
+ };
181
507
  }
182
508
 
183
509
  let WASM_VECTOR_LEN = 0;
184
510
 
185
- const Sp00kyProcessorFinalization = (typeof FinalizationRegistry === 'undefined')
186
- ? { register: () => {}, unregister: () => {} }
187
- : new FinalizationRegistry(ptr => wasm.__wbg_sp00kyprocessor_free(ptr >>> 0, 1));
188
-
189
- export class Sp00kyProcessor {
190
- __destroy_into_raw() {
191
- const ptr = this.__wbg_ptr;
192
- this.__wbg_ptr = 0;
193
- Sp00kyProcessorFinalization.unregister(this);
194
- return ptr;
195
- }
196
- free() {
197
- const ptr = this.__destroy_into_raw();
198
- wasm.__wbg_sp00kyprocessor_free(ptr, 0);
199
- }
200
- /**
201
- * Load circuit state from a JSON string
202
- * @param {string} state
203
- */
204
- load_state(state) {
205
- const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
206
- const len0 = WASM_VECTOR_LEN;
207
- const ret = wasm.sp00kyprocessor_load_state(this.__wbg_ptr, ptr0, len0);
208
- if (ret[1]) {
209
- throw takeFromExternrefTable0(ret[0]);
210
- }
211
- }
212
- /**
213
- * Save the current circuit state as a JSON string
214
- * @returns {string}
215
- */
216
- save_state() {
217
- let deferred2_0;
218
- let deferred2_1;
219
- try {
220
- const ret = wasm.sp00kyprocessor_save_state(this.__wbg_ptr);
221
- var ptr1 = ret[0];
222
- var len1 = ret[1];
223
- if (ret[3]) {
224
- ptr1 = 0; len1 = 0;
225
- throw takeFromExternrefTable0(ret[2]);
226
- }
227
- deferred2_0 = ptr1;
228
- deferred2_1 = len1;
229
- return getStringFromWasm0(ptr1, len1);
230
- } finally {
231
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
232
- }
233
- }
234
- /**
235
- * Register a new materialized view
236
- * @param {any} config
237
- * @returns {any}
238
- */
239
- register_view(config) {
240
- const ret = wasm.sp00kyprocessor_register_view(this.__wbg_ptr, config);
241
- if (ret[2]) {
242
- throw takeFromExternrefTable0(ret[1]);
243
- }
244
- return takeFromExternrefTable0(ret[0]);
245
- }
246
- /**
247
- * Unregister a view by ID
248
- * @param {string} id
249
- */
250
- unregister_view(id) {
251
- const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
252
- const len0 = WASM_VECTOR_LEN;
253
- wasm.sp00kyprocessor_unregister_view(this.__wbg_ptr, ptr0, len0);
254
- }
255
- constructor() {
256
- const ret = wasm.sp00kyprocessor_new();
257
- this.__wbg_ptr = ret >>> 0;
258
- Sp00kyProcessorFinalization.register(this, this.__wbg_ptr, this);
259
- return this;
260
- }
261
- /**
262
- * Ingest a record into the stream processor
263
- * @param {string} table
264
- * @param {string} op
265
- * @param {string} id
266
- * @param {any} record
267
- * @returns {any}
268
- */
269
- ingest(table, op, id, record) {
270
- const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
271
- const len0 = WASM_VECTOR_LEN;
272
- const ptr1 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
273
- const len1 = WASM_VECTOR_LEN;
274
- const ptr2 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
275
- const len2 = WASM_VECTOR_LEN;
276
- const ret = wasm.sp00kyprocessor_ingest(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, record);
277
- if (ret[2]) {
278
- throw takeFromExternrefTable0(ret[1]);
279
- }
280
- return takeFromExternrefTable0(ret[0]);
281
- }
282
- }
283
- if (Symbol.dispose) Sp00kyProcessor.prototype[Symbol.dispose] = Sp00kyProcessor.prototype.free;
284
-
285
- /**
286
- * Called when WASM module is loaded
287
- */
288
- export function init() {
289
- wasm.init();
511
+ let wasmModule, wasm;
512
+ function __wbg_finalize_init(instance, module) {
513
+ wasm = instance.exports;
514
+ wasmModule = module;
515
+ cachedDataViewMemory0 = null;
516
+ cachedUint8ArrayMemory0 = null;
517
+ wasm.__wbindgen_start();
518
+ return wasm;
290
519
  }
291
520
 
292
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
293
-
294
521
  async function __wbg_load(module, imports) {
295
522
  if (typeof Response === 'function' && module instanceof Response) {
296
523
  if (typeof WebAssembly.instantiateStreaming === 'function') {
297
524
  try {
298
525
  return await WebAssembly.instantiateStreaming(module, imports);
299
526
  } catch (e) {
300
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
527
+ const validResponse = module.ok && expectedResponseType(module.type);
301
528
 
302
529
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
303
530
  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);
304
531
 
305
- } else {
306
- throw e;
307
- }
532
+ } else { throw e; }
308
533
  }
309
534
  }
310
535
 
@@ -319,237 +544,20 @@ async function __wbg_load(module, imports) {
319
544
  return instance;
320
545
  }
321
546
  }
322
- }
323
547
 
324
- function __wbg_get_imports() {
325
- const imports = {};
326
- imports.wbg = {};
327
- imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
328
- const ret = Error(getStringFromWasm0(arg0, arg1));
329
- return ret;
330
- };
331
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
332
- const ret = String(arg1);
333
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
- const len1 = WASM_VECTOR_LEN;
335
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
336
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
337
- };
338
- imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
339
- const v = arg1;
340
- const ret = typeof(v) === 'bigint' ? v : undefined;
341
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
342
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
343
- };
344
- imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
345
- const v = arg0;
346
- const ret = typeof(v) === 'boolean' ? v : undefined;
347
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
348
- };
349
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
350
- const ret = debugString(arg1);
351
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
352
- const len1 = WASM_VECTOR_LEN;
353
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
354
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
355
- };
356
- imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
357
- const ret = arg0 in arg1;
358
- return ret;
359
- };
360
- imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
361
- const ret = typeof(arg0) === 'bigint';
362
- return ret;
363
- };
364
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
365
- const ret = typeof(arg0) === 'function';
366
- return ret;
367
- };
368
- imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
369
- const val = arg0;
370
- const ret = typeof(val) === 'object' && val !== null;
371
- return ret;
372
- };
373
- imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
374
- const ret = arg0 === arg1;
375
- return ret;
376
- };
377
- imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
378
- const ret = arg0 == arg1;
379
- return ret;
380
- };
381
- imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
382
- const obj = arg1;
383
- const ret = typeof(obj) === 'number' ? obj : undefined;
384
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
385
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
386
- };
387
- imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
388
- const obj = arg1;
389
- const ret = typeof(obj) === 'string' ? obj : undefined;
390
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
391
- var len1 = WASM_VECTOR_LEN;
392
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
393
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
394
- };
395
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
396
- throw new Error(getStringFromWasm0(arg0, arg1));
397
- };
398
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
399
- const ret = arg0.call(arg1);
400
- return ret;
401
- }, arguments) };
402
- imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
403
- const ret = arg0.done;
404
- return ret;
405
- };
406
- imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
407
- const ret = Object.entries(arg0);
408
- return ret;
409
- };
410
- imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
411
- const ret = arg0[arg1 >>> 0];
412
- return ret;
413
- };
414
- imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
415
- const ret = Reflect.get(arg0, arg1);
416
- return ret;
417
- }, arguments) };
418
- imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
419
- let result;
420
- try {
421
- result = arg0 instanceof ArrayBuffer;
422
- } catch (_) {
423
- result = false;
424
- }
425
- const ret = result;
426
- return ret;
427
- };
428
- imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
429
- let result;
430
- try {
431
- result = arg0 instanceof Map;
432
- } catch (_) {
433
- result = false;
548
+ function expectedResponseType(type) {
549
+ switch (type) {
550
+ case 'basic': case 'cors': case 'default': return true;
434
551
  }
435
- const ret = result;
436
- return ret;
437
- };
438
- imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
439
- let result;
440
- try {
441
- result = arg0 instanceof Uint8Array;
442
- } catch (_) {
443
- result = false;
444
- }
445
- const ret = result;
446
- return ret;
447
- };
448
- imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
449
- const ret = Array.isArray(arg0);
450
- return ret;
451
- };
452
- imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
453
- const ret = Number.isSafeInteger(arg0);
454
- return ret;
455
- };
456
- imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
457
- const ret = Symbol.iterator;
458
- return ret;
459
- };
460
- imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
461
- const ret = arg0.length;
462
- return ret;
463
- };
464
- imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
465
- const ret = arg0.length;
466
- return ret;
467
- };
468
- imports.wbg.__wbg_log_1d990106d99dacb7 = function(arg0) {
469
- console.log(arg0);
470
- };
471
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
472
- const ret = new Object();
473
- return ret;
474
- };
475
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
476
- const ret = new Array();
477
- return ret;
478
- };
479
- imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
480
- const ret = new Uint8Array(arg0);
481
- return ret;
482
- };
483
- imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
484
- const ret = arg0.next;
485
- return ret;
486
- };
487
- imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
488
- const ret = arg0.next();
489
- return ret;
490
- }, arguments) };
491
- imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
492
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
493
- };
494
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
495
- arg0[arg1] = arg2;
496
- };
497
- imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
498
- arg0[arg1 >>> 0] = arg2;
499
- };
500
- imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
501
- const ret = arg0.value;
502
- return ret;
503
- };
504
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
505
- // Cast intrinsic for `Ref(String) -> Externref`.
506
- const ret = getStringFromWasm0(arg0, arg1);
507
- return ret;
508
- };
509
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
510
- // Cast intrinsic for `U64 -> Externref`.
511
- const ret = BigInt.asUintN(64, arg0);
512
- return ret;
513
- };
514
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
515
- // Cast intrinsic for `I64 -> Externref`.
516
- const ret = arg0;
517
- return ret;
518
- };
519
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
520
- // Cast intrinsic for `F64 -> Externref`.
521
- const ret = arg0;
522
- return ret;
523
- };
524
- imports.wbg.__wbindgen_init_externref_table = function() {
525
- const table = wasm.__wbindgen_externrefs;
526
- const offset = table.grow(4);
527
- table.set(0, undefined);
528
- table.set(offset + 0, undefined);
529
- table.set(offset + 1, null);
530
- table.set(offset + 2, true);
531
- table.set(offset + 3, false);
532
- };
533
-
534
- return imports;
535
- }
536
-
537
- function __wbg_finalize_init(instance, module) {
538
- wasm = instance.exports;
539
- __wbg_init.__wbindgen_wasm_module = module;
540
- cachedDataViewMemory0 = null;
541
- cachedUint8ArrayMemory0 = null;
542
-
543
-
544
- wasm.__wbindgen_start();
545
- return wasm;
552
+ return false;
553
+ }
546
554
  }
547
555
 
548
556
  function initSync(module) {
549
557
  if (wasm !== undefined) return wasm;
550
558
 
551
559
 
552
- if (typeof module !== 'undefined') {
560
+ if (module !== undefined) {
553
561
  if (Object.getPrototypeOf(module) === Object.prototype) {
554
562
  ({module} = module)
555
563
  } else {
@@ -569,7 +577,7 @@ async function __wbg_init(module_or_path) {
569
577
  if (wasm !== undefined) return wasm;
570
578
 
571
579
 
572
- if (typeof module_or_path !== 'undefined') {
580
+ if (module_or_path !== undefined) {
573
581
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
574
582
  ({module_or_path} = module_or_path)
575
583
  } else {
@@ -577,7 +585,7 @@ async function __wbg_init(module_or_path) {
577
585
  }
578
586
  }
579
587
 
580
- if (typeof module_or_path === 'undefined') {
588
+ if (module_or_path === undefined) {
581
589
  module_or_path = new URL('ssp_wasm_bg.wasm', import.meta.url);
582
590
  }
583
591
  const imports = __wbg_get_imports();
@@ -591,5 +599,4 @@ async function __wbg_init(module_or_path) {
591
599
  return __wbg_finalize_init(instance, module);
592
600
  }
593
601
 
594
- export { initSync };
595
- export default __wbg_init;
602
+ export { initSync, __wbg_init as default };
Binary file