@spooky-sync/ssp-wasm 0.0.1-canary.100

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 ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@spooky-sync/ssp-wasm",
3
+ "version": "0.0.1-canary.100",
4
+ "main": "pkg/ssp_wasm.js",
5
+ "types": "pkg/ssp_wasm.d.ts",
6
+ "files": [
7
+ "pkg",
8
+ "AGENTS.md"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/mono424/sp00ky.git",
13
+ "directory": "packages/ssp-wasm"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "build": "wasm-pack build --target web --out-dir pkg",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.0.0",
25
+ "vitest": "^3.0.0",
26
+ "wasm-pack": "^0.13.1"
27
+ }
28
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "ssp-wasm",
3
+ "type": "module",
4
+ "description": "WASM bindings for ssp",
5
+ "version": "0.0.1-canary.100",
6
+ "license": "MIT",
7
+ "files": [
8
+ "ssp_wasm_bg.wasm",
9
+ "ssp_wasm.js",
10
+ "ssp_wasm.d.ts"
11
+ ],
12
+ "main": "ssp_wasm.js",
13
+ "types": "ssp_wasm.d.ts",
14
+ "sideEffects": [
15
+ "./snippets/*"
16
+ ]
17
+ }
@@ -0,0 +1,127 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
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
+ };
13
+ // Per-phase SSP processing time (ms). Ingest path: store_apply/circuit_step/
14
+ // transform. Register path: parse/plan/snapshot. Unused side is 0.
15
+ timing_store_apply_ms: number;
16
+ timing_circuit_step_ms: number;
17
+ timing_transform_ms: number;
18
+ timing_parse_ms: number;
19
+ timing_plan_ms: number;
20
+ timing_snapshot_ms: number;
21
+ }
22
+
23
+ export interface WasmViewConfig {
24
+ id: string;
25
+ surql: string;
26
+ params?: Record<string, any>;
27
+ clientId: string;
28
+ ttl: string;
29
+ lastActiveAt: string;
30
+ safe_params?: Record<string, any>;
31
+ format?: 'flat' | 'tree' | 'streaming';
32
+ }
33
+
34
+ export interface WasmIngestItem {
35
+ table: string;
36
+ op: string;
37
+ id: string;
38
+ record: any;
39
+ }
40
+
41
+
42
+
43
+ export class Sp00kyProcessor {
44
+ free(): void;
45
+ [Symbol.dispose](): void;
46
+ /**
47
+ * Ingest a record into the stream processor
48
+ */
49
+ ingest(table: string, op: string, id: string, record: any): any;
50
+ /**
51
+ * Load circuit state from a JSON string
52
+ */
53
+ load_state(state: string): void;
54
+ constructor();
55
+ /**
56
+ * Register a new materialized view
57
+ */
58
+ register_view(config: any): any;
59
+ /**
60
+ * Save the current circuit state as a JSON string
61
+ */
62
+ save_state(): string;
63
+ /**
64
+ * Seed per-table `select` permission predicates so `register_view` can
65
+ * inject them (and so non-`_00_` tables aren't default-denied).
66
+ *
67
+ * Expects a `{ [table]: whereText }` object, where `whereText` is the raw
68
+ * `WHERE` expression from the table's `PERMISSIONS FOR select` clause
69
+ * (e.g. `"true"`, or `"owner = $auth.id"`). Called once at boot after the
70
+ * schema is parsed — mirrors the native boot path that reads `INFO FOR DB`.
71
+ */
72
+ set_permissions(permissions: any): void;
73
+ /**
74
+ * Unregister a view by ID
75
+ */
76
+ unregister_view(id: string): void;
77
+ }
78
+
79
+ /**
80
+ * Called when WASM module is loaded
81
+ */
82
+ export function init(): void;
83
+
84
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
85
+
86
+ export interface InitOutput {
87
+ readonly memory: WebAssembly.Memory;
88
+ readonly __wbg_sp00kyprocessor_free: (a: number, b: number) => void;
89
+ readonly init: () => void;
90
+ readonly sp00kyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
91
+ readonly sp00kyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
92
+ readonly sp00kyprocessor_new: () => number;
93
+ readonly sp00kyprocessor_register_view: (a: number, b: any) => [number, number, number];
94
+ readonly sp00kyprocessor_save_state: (a: number) => [number, number, number, number];
95
+ readonly sp00kyprocessor_set_permissions: (a: number, b: any) => [number, number];
96
+ readonly sp00kyprocessor_unregister_view: (a: number, b: number, c: number) => void;
97
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
98
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
99
+ readonly __wbindgen_exn_store: (a: number) => void;
100
+ readonly __externref_table_alloc: () => number;
101
+ readonly __wbindgen_externrefs: WebAssembly.Table;
102
+ readonly __externref_table_dealloc: (a: number) => void;
103
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
104
+ readonly __wbindgen_start: () => void;
105
+ }
106
+
107
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
108
+
109
+ /**
110
+ * Instantiates the given `module`, which can either be bytes or
111
+ * a precompiled `WebAssembly.Module`.
112
+ *
113
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
114
+ *
115
+ * @returns {InitOutput}
116
+ */
117
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
118
+
119
+ /**
120
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
121
+ * for everything else, calls `WebAssembly.instantiate` directly.
122
+ *
123
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
124
+ *
125
+ * @returns {Promise<InitOutput>}
126
+ */
127
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,647 @@
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
+ * Seed per-table `select` permission predicates so `register_view` can
89
+ * inject them (and so non-`_00_` tables aren't default-denied).
90
+ *
91
+ * Expects a `{ [table]: whereText }` object, where `whereText` is the raw
92
+ * `WHERE` expression from the table's `PERMISSIONS FOR select` clause
93
+ * (e.g. `"true"`, or `"owner = $auth.id"`). Called once at boot after the
94
+ * schema is parsed — mirrors the native boot path that reads `INFO FOR DB`.
95
+ * @param {any} permissions
96
+ */
97
+ set_permissions(permissions) {
98
+ const ret = wasm.sp00kyprocessor_set_permissions(this.__wbg_ptr, permissions);
99
+ if (ret[1]) {
100
+ throw takeFromExternrefTable0(ret[0]);
101
+ }
102
+ }
103
+ /**
104
+ * Unregister a view by ID
105
+ * @param {string} id
106
+ */
107
+ unregister_view(id) {
108
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
+ const len0 = WASM_VECTOR_LEN;
110
+ wasm.sp00kyprocessor_unregister_view(this.__wbg_ptr, ptr0, len0);
111
+ }
112
+ }
113
+ if (Symbol.dispose) Sp00kyProcessor.prototype[Symbol.dispose] = Sp00kyProcessor.prototype.free;
114
+
115
+ /**
116
+ * Called when WASM module is loaded
117
+ */
118
+ export function init() {
119
+ wasm.init();
120
+ }
121
+
122
+ function __wbg_get_imports() {
123
+ const import0 = {
124
+ __proto__: null,
125
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
126
+ const ret = Error(getStringFromWasm0(arg0, arg1));
127
+ return ret;
128
+ },
129
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
130
+ const ret = String(arg1);
131
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
+ const len1 = WASM_VECTOR_LEN;
133
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
134
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
135
+ },
136
+ __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
137
+ const v = arg1;
138
+ const ret = typeof(v) === 'bigint' ? v : undefined;
139
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
140
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
141
+ },
142
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
143
+ const v = arg0;
144
+ const ret = typeof(v) === 'boolean' ? v : undefined;
145
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
146
+ },
147
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
148
+ const ret = debugString(arg1);
149
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
150
+ const len1 = WASM_VECTOR_LEN;
151
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
152
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
153
+ },
154
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
155
+ const ret = arg0 in arg1;
156
+ return ret;
157
+ },
158
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
159
+ const ret = typeof(arg0) === 'bigint';
160
+ return ret;
161
+ },
162
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
163
+ const ret = typeof(arg0) === 'function';
164
+ return ret;
165
+ },
166
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
167
+ const val = arg0;
168
+ const ret = typeof(val) === 'object' && val !== null;
169
+ return ret;
170
+ },
171
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
172
+ const ret = arg0 === undefined;
173
+ return ret;
174
+ },
175
+ __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
176
+ const ret = arg0 === arg1;
177
+ return ret;
178
+ },
179
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
180
+ const ret = arg0 == arg1;
181
+ return ret;
182
+ },
183
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
184
+ const obj = arg1;
185
+ const ret = typeof(obj) === 'number' ? obj : undefined;
186
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
187
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
188
+ },
189
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
190
+ const obj = arg1;
191
+ const ret = typeof(obj) === 'string' ? obj : undefined;
192
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
193
+ var len1 = WASM_VECTOR_LEN;
194
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
195
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
196
+ },
197
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
198
+ throw new Error(getStringFromWasm0(arg0, arg1));
199
+ },
200
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
201
+ const ret = arg0.call(arg1);
202
+ return ret;
203
+ }, arguments); },
204
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
205
+ const ret = arg0.done;
206
+ return ret;
207
+ },
208
+ __wbg_entries_58c7934c745daac7: function(arg0) {
209
+ const ret = Object.entries(arg0);
210
+ return ret;
211
+ },
212
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
213
+ const ret = arg0[arg1 >>> 0];
214
+ return ret;
215
+ },
216
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
217
+ const ret = Reflect.get(arg0, arg1);
218
+ return ret;
219
+ }, arguments); },
220
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
221
+ let result;
222
+ try {
223
+ result = arg0 instanceof ArrayBuffer;
224
+ } catch (_) {
225
+ result = false;
226
+ }
227
+ const ret = result;
228
+ return ret;
229
+ },
230
+ __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
231
+ let result;
232
+ try {
233
+ result = arg0 instanceof Map;
234
+ } catch (_) {
235
+ result = false;
236
+ }
237
+ const ret = result;
238
+ return ret;
239
+ },
240
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
241
+ let result;
242
+ try {
243
+ result = arg0 instanceof Uint8Array;
244
+ } catch (_) {
245
+ result = false;
246
+ }
247
+ const ret = result;
248
+ return ret;
249
+ },
250
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
251
+ const ret = Array.isArray(arg0);
252
+ return ret;
253
+ },
254
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
255
+ const ret = Number.isSafeInteger(arg0);
256
+ return ret;
257
+ },
258
+ __wbg_iterator_6ff6560ca1568e55: function() {
259
+ const ret = Symbol.iterator;
260
+ return ret;
261
+ },
262
+ __wbg_length_32ed9a279acd054c: function(arg0) {
263
+ const ret = arg0.length;
264
+ return ret;
265
+ },
266
+ __wbg_length_35a7bace40f36eac: function(arg0) {
267
+ const ret = arg0.length;
268
+ return ret;
269
+ },
270
+ __wbg_log_6b5ca2e6124b2808: function(arg0) {
271
+ console.log(arg0);
272
+ },
273
+ __wbg_new_361308b2356cecd0: function() {
274
+ const ret = new Object();
275
+ return ret;
276
+ },
277
+ __wbg_new_3eb36ae241fe6f44: function() {
278
+ const ret = new Array();
279
+ return ret;
280
+ },
281
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
282
+ const ret = new Uint8Array(arg0);
283
+ return ret;
284
+ },
285
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
286
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
287
+ return ret;
288
+ },
289
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
290
+ const ret = arg0.next();
291
+ return ret;
292
+ }, arguments); },
293
+ __wbg_next_418f80d8f5303233: function(arg0) {
294
+ const ret = arg0.next;
295
+ return ret;
296
+ },
297
+ __wbg_now_2c95c9de01293173: function(arg0) {
298
+ const ret = arg0.now();
299
+ return ret;
300
+ },
301
+ __wbg_performance_7a3ffd0b17f663ad: function(arg0) {
302
+ const ret = arg0.performance;
303
+ return ret;
304
+ },
305
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
306
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
307
+ },
308
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
309
+ arg0[arg1] = arg2;
310
+ },
311
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
312
+ arg0[arg1 >>> 0] = arg2;
313
+ },
314
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
315
+ const ret = typeof global === 'undefined' ? null : global;
316
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
317
+ },
318
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
319
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
320
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
321
+ },
322
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
323
+ const ret = typeof self === 'undefined' ? null : self;
324
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
325
+ },
326
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
327
+ const ret = typeof window === 'undefined' ? null : window;
328
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
329
+ },
330
+ __wbg_value_0546255b415e96c1: function(arg0) {
331
+ const ret = arg0.value;
332
+ return ret;
333
+ },
334
+ __wbindgen_cast_0000000000000001: function(arg0) {
335
+ // Cast intrinsic for `F64 -> Externref`.
336
+ const ret = arg0;
337
+ return ret;
338
+ },
339
+ __wbindgen_cast_0000000000000002: function(arg0) {
340
+ // Cast intrinsic for `I64 -> Externref`.
341
+ const ret = arg0;
342
+ return ret;
343
+ },
344
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
345
+ // Cast intrinsic for `Ref(String) -> Externref`.
346
+ const ret = getStringFromWasm0(arg0, arg1);
347
+ return ret;
348
+ },
349
+ __wbindgen_cast_0000000000000004: function(arg0) {
350
+ // Cast intrinsic for `U64 -> Externref`.
351
+ const ret = BigInt.asUintN(64, arg0);
352
+ return ret;
353
+ },
354
+ __wbindgen_init_externref_table: function() {
355
+ const table = wasm.__wbindgen_externrefs;
356
+ const offset = table.grow(4);
357
+ table.set(0, undefined);
358
+ table.set(offset + 0, undefined);
359
+ table.set(offset + 1, null);
360
+ table.set(offset + 2, true);
361
+ table.set(offset + 3, false);
362
+ },
363
+ };
364
+ return {
365
+ __proto__: null,
366
+ "./ssp_wasm_bg.js": import0,
367
+ };
368
+ }
369
+
370
+ const Sp00kyProcessorFinalization = (typeof FinalizationRegistry === 'undefined')
371
+ ? { register: () => {}, unregister: () => {} }
372
+ : new FinalizationRegistry(ptr => wasm.__wbg_sp00kyprocessor_free(ptr >>> 0, 1));
373
+
374
+ function addToExternrefTable0(obj) {
375
+ const idx = wasm.__externref_table_alloc();
376
+ wasm.__wbindgen_externrefs.set(idx, obj);
377
+ return idx;
378
+ }
379
+
380
+ function debugString(val) {
381
+ // primitive types
382
+ const type = typeof val;
383
+ if (type == 'number' || type == 'boolean' || val == null) {
384
+ return `${val}`;
385
+ }
386
+ if (type == 'string') {
387
+ return `"${val}"`;
388
+ }
389
+ if (type == 'symbol') {
390
+ const description = val.description;
391
+ if (description == null) {
392
+ return 'Symbol';
393
+ } else {
394
+ return `Symbol(${description})`;
395
+ }
396
+ }
397
+ if (type == 'function') {
398
+ const name = val.name;
399
+ if (typeof name == 'string' && name.length > 0) {
400
+ return `Function(${name})`;
401
+ } else {
402
+ return 'Function';
403
+ }
404
+ }
405
+ // objects
406
+ if (Array.isArray(val)) {
407
+ const length = val.length;
408
+ let debug = '[';
409
+ if (length > 0) {
410
+ debug += debugString(val[0]);
411
+ }
412
+ for(let i = 1; i < length; i++) {
413
+ debug += ', ' + debugString(val[i]);
414
+ }
415
+ debug += ']';
416
+ return debug;
417
+ }
418
+ // Test for built-in
419
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
420
+ let className;
421
+ if (builtInMatches && builtInMatches.length > 1) {
422
+ className = builtInMatches[1];
423
+ } else {
424
+ // Failed to match the standard '[object ClassName]'
425
+ return toString.call(val);
426
+ }
427
+ if (className == 'Object') {
428
+ // we're a user defined class or Object
429
+ // JSON.stringify avoids problems with cycles, and is generally much
430
+ // easier than looping through ownProperties of `val`.
431
+ try {
432
+ return 'Object(' + JSON.stringify(val) + ')';
433
+ } catch (_) {
434
+ return 'Object';
435
+ }
436
+ }
437
+ // errors
438
+ if (val instanceof Error) {
439
+ return `${val.name}: ${val.message}\n${val.stack}`;
440
+ }
441
+ // TODO we could test for more things here, like `Set`s and `Map`s.
442
+ return className;
443
+ }
444
+
445
+ function getArrayU8FromWasm0(ptr, len) {
446
+ ptr = ptr >>> 0;
447
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
448
+ }
449
+
450
+ let cachedDataViewMemory0 = null;
451
+ function getDataViewMemory0() {
452
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
453
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
454
+ }
455
+ return cachedDataViewMemory0;
456
+ }
457
+
458
+ function getStringFromWasm0(ptr, len) {
459
+ ptr = ptr >>> 0;
460
+ return decodeText(ptr, len);
461
+ }
462
+
463
+ let cachedUint8ArrayMemory0 = null;
464
+ function getUint8ArrayMemory0() {
465
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
466
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
467
+ }
468
+ return cachedUint8ArrayMemory0;
469
+ }
470
+
471
+ function handleError(f, args) {
472
+ try {
473
+ return f.apply(this, args);
474
+ } catch (e) {
475
+ const idx = addToExternrefTable0(e);
476
+ wasm.__wbindgen_exn_store(idx);
477
+ }
478
+ }
479
+
480
+ function isLikeNone(x) {
481
+ return x === undefined || x === null;
482
+ }
483
+
484
+ function passStringToWasm0(arg, malloc, realloc) {
485
+ if (realloc === undefined) {
486
+ const buf = cachedTextEncoder.encode(arg);
487
+ const ptr = malloc(buf.length, 1) >>> 0;
488
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
489
+ WASM_VECTOR_LEN = buf.length;
490
+ return ptr;
491
+ }
492
+
493
+ let len = arg.length;
494
+ let ptr = malloc(len, 1) >>> 0;
495
+
496
+ const mem = getUint8ArrayMemory0();
497
+
498
+ let offset = 0;
499
+
500
+ for (; offset < len; offset++) {
501
+ const code = arg.charCodeAt(offset);
502
+ if (code > 0x7F) break;
503
+ mem[ptr + offset] = code;
504
+ }
505
+ if (offset !== len) {
506
+ if (offset !== 0) {
507
+ arg = arg.slice(offset);
508
+ }
509
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
510
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
511
+ const ret = cachedTextEncoder.encodeInto(arg, view);
512
+
513
+ offset += ret.written;
514
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
515
+ }
516
+
517
+ WASM_VECTOR_LEN = offset;
518
+ return ptr;
519
+ }
520
+
521
+ function takeFromExternrefTable0(idx) {
522
+ const value = wasm.__wbindgen_externrefs.get(idx);
523
+ wasm.__externref_table_dealloc(idx);
524
+ return value;
525
+ }
526
+
527
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
528
+ cachedTextDecoder.decode();
529
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
530
+ let numBytesDecoded = 0;
531
+ function decodeText(ptr, len) {
532
+ numBytesDecoded += len;
533
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
534
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
535
+ cachedTextDecoder.decode();
536
+ numBytesDecoded = len;
537
+ }
538
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
539
+ }
540
+
541
+ const cachedTextEncoder = new TextEncoder();
542
+
543
+ if (!('encodeInto' in cachedTextEncoder)) {
544
+ cachedTextEncoder.encodeInto = function (arg, view) {
545
+ const buf = cachedTextEncoder.encode(arg);
546
+ view.set(buf);
547
+ return {
548
+ read: arg.length,
549
+ written: buf.length
550
+ };
551
+ };
552
+ }
553
+
554
+ let WASM_VECTOR_LEN = 0;
555
+
556
+ let wasmModule, wasm;
557
+ function __wbg_finalize_init(instance, module) {
558
+ wasm = instance.exports;
559
+ wasmModule = module;
560
+ cachedDataViewMemory0 = null;
561
+ cachedUint8ArrayMemory0 = null;
562
+ wasm.__wbindgen_start();
563
+ return wasm;
564
+ }
565
+
566
+ async function __wbg_load(module, imports) {
567
+ if (typeof Response === 'function' && module instanceof Response) {
568
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
569
+ try {
570
+ return await WebAssembly.instantiateStreaming(module, imports);
571
+ } catch (e) {
572
+ const validResponse = module.ok && expectedResponseType(module.type);
573
+
574
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
575
+ 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);
576
+
577
+ } else { throw e; }
578
+ }
579
+ }
580
+
581
+ const bytes = await module.arrayBuffer();
582
+ return await WebAssembly.instantiate(bytes, imports);
583
+ } else {
584
+ const instance = await WebAssembly.instantiate(module, imports);
585
+
586
+ if (instance instanceof WebAssembly.Instance) {
587
+ return { instance, module };
588
+ } else {
589
+ return instance;
590
+ }
591
+ }
592
+
593
+ function expectedResponseType(type) {
594
+ switch (type) {
595
+ case 'basic': case 'cors': case 'default': return true;
596
+ }
597
+ return false;
598
+ }
599
+ }
600
+
601
+ function initSync(module) {
602
+ if (wasm !== undefined) return wasm;
603
+
604
+
605
+ if (module !== undefined) {
606
+ if (Object.getPrototypeOf(module) === Object.prototype) {
607
+ ({module} = module)
608
+ } else {
609
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
610
+ }
611
+ }
612
+
613
+ const imports = __wbg_get_imports();
614
+ if (!(module instanceof WebAssembly.Module)) {
615
+ module = new WebAssembly.Module(module);
616
+ }
617
+ const instance = new WebAssembly.Instance(module, imports);
618
+ return __wbg_finalize_init(instance, module);
619
+ }
620
+
621
+ async function __wbg_init(module_or_path) {
622
+ if (wasm !== undefined) return wasm;
623
+
624
+
625
+ if (module_or_path !== undefined) {
626
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
627
+ ({module_or_path} = module_or_path)
628
+ } else {
629
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
630
+ }
631
+ }
632
+
633
+ if (module_or_path === undefined) {
634
+ module_or_path = new URL('ssp_wasm_bg.wasm', import.meta.url);
635
+ }
636
+ const imports = __wbg_get_imports();
637
+
638
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
639
+ module_or_path = fetch(module_or_path);
640
+ }
641
+
642
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
643
+
644
+ return __wbg_finalize_init(instance, module);
645
+ }
646
+
647
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,20 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_sp00kyprocessor_free: (a: number, b: number) => void;
5
+ export const init: () => void;
6
+ export const sp00kyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
7
+ export const sp00kyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
8
+ export const sp00kyprocessor_new: () => number;
9
+ export const sp00kyprocessor_register_view: (a: number, b: any) => [number, number, number];
10
+ export const sp00kyprocessor_save_state: (a: number) => [number, number, number, number];
11
+ export const sp00kyprocessor_set_permissions: (a: number, b: any) => [number, number];
12
+ export const sp00kyprocessor_unregister_view: (a: number, b: number, c: number) => void;
13
+ export const __wbindgen_malloc: (a: number, b: number) => number;
14
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
15
+ export const __wbindgen_exn_store: (a: number) => void;
16
+ export const __externref_table_alloc: () => number;
17
+ export const __wbindgen_externrefs: WebAssembly.Table;
18
+ export const __externref_table_dealloc: (a: number) => void;
19
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
20
+ export const __wbindgen_start: () => void;