@spooky-sync/ssp-wasm 0.0.1-canary.21 → 0.0.1-canary.210

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,38 @@
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 snapshot path (`save_store_state` / `load_store_state`, with `reconcile` for the delta since).
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)` / `ingest_many(items)` — push row changes (`CREATE`/`UPDATE`/`MERGE`/`DELETE`); returns the affected views' deltas (`WasmViewUpdate[]`). Membership is presence-driven: the verb never double-counts or ghosts a row, and an unchanged write is a no-op.
19
+ - `save_store_state()` / `load_store_state(bytes)` — snapshot/restore the base rows as bytes, under the registered views; `reconcile(table, [id, rv][])` steps in the delta against the durable store.
20
+ - `set_projection(bool)` — keep only the fields registered plans evaluate per row; `register_view` reports `missing_fields` to widen with `MERGE`.
21
+ - `compact()` / `dead_bytes()` / `live_bytes()` / `size_report()` — row-arena hygiene and memory attribution.
22
+ - `save_state()` / `load_state(json)` — full circuit snapshot including views (server-shaped; the client uses the store-only pair).
23
+ - `free()` / `[Symbol.dispose]` — release WASM memory.
24
+ - **`init()`** — must be called once after the WASM module loads.
25
+ - Types: `WasmViewConfig`, `WasmViewUpdate`, `WasmIngestItem`.
26
+
27
+ ## Build
28
+
29
+ ```bash
30
+ pnpm --filter @spooky-sync/ssp-wasm build # wasm-pack build --target web --out-dir pkg
31
+ ```
32
+
33
+ Output is `pkg/`, which is the only directory shipped via `files`. The Rust source lives one level up in `packages/ssp/src/circuit/`.
34
+
35
+ ## Pointers
36
+
37
+ - Server-side counterpart (same circuit, native build): `apps/ssp/`
38
+ - Sync engine that wires this in: `node_modules/@spooky-sync/core/AGENTS.md` → `src/modules/data/`
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@spooky-sync/ssp-wasm",
3
- "version": "0.0.1-canary.21",
3
+ "version": "0.0.1-canary.210",
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",
11
- "url": "https://github.com/mono424/spooky.git",
12
+ "url": "https://github.com/mono424/sp00ky.git",
12
13
  "directory": "packages/ssp-wasm"
13
14
  },
14
15
  "publishConfig": {
@@ -17,7 +18,9 @@
17
18
  "scripts": {
18
19
  "build": "wasm-pack build --target web --out-dir pkg",
19
20
  "test": "vitest run",
20
- "test:watch": "vitest"
21
+ "test:watch": "vitest",
22
+ "bench:save": "node bench/circuit-save.mjs",
23
+ "bench:ingest": "node bench/ingest-memory.mjs"
21
24
  },
22
25
  "devDependencies": {
23
26
  "typescript": "^5.0.0",
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.1.0",
5
+ "version": "0.0.1-canary.210",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "ssp_wasm_bg.wasm",
package/pkg/ssp_wasm.d.ts CHANGED
@@ -2,60 +2,156 @@
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
+ // 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;
13
21
  }
14
22
 
15
23
  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';
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';
24
32
  }
25
33
 
26
34
  export interface WasmIngestItem {
27
- table: string;
28
- op: string;
29
- id: string;
30
- record: any;
35
+ table: string;
36
+ op: string;
37
+ id: string;
38
+ record: any;
31
39
  }
32
40
 
41
+ export interface WasmRegistration extends WasmViewUpdate {
42
+ /** Under projection: fields this plan evaluates that stored rows lack. */
43
+ missing_fields?: Record<string, string[]>;
44
+ }
45
+
46
+ export interface WasmReconciled {
47
+ fetch: string[];
48
+ deleted: number;
49
+ updates: WasmViewUpdate[];
50
+ }
33
51
 
34
52
 
35
- export class SpookyProcessor {
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;
53
+
54
+ export class Sp00kyProcessor {
55
+ free(): void;
56
+ [Symbol.dispose](): void;
57
+ /**
58
+ * Rebuild row storage without the bytes orphaned by updates and deletes.
59
+ * Returns how many bytes were dead. Costs a decode of every row, so call
60
+ * it from a checkpoint, never per ingest.
61
+ */
62
+ compact(): number;
63
+ /**
64
+ * Bytes of row storage orphaned by updates and deletes.
65
+ */
66
+ dead_bytes(): number;
67
+ /**
68
+ * Ingest a record into the stream processor
69
+ */
70
+ ingest(table: string, op: string, id: string, record: any): any;
71
+ /**
72
+ * Ingest MANY record changes as ONE circuit step.
73
+ *
74
+ * `ingest` costs one full circuit step per record, and a step walks every
75
+ * registered view, so a cold sync that lands thousands of rows paid that
76
+ * fixed cost thousands of times (a ~3.9k-row registry took ~3.4s of circuit
77
+ * time on a laptop, ~0.85ms a row, nearly all of it per-step overhead).
78
+ * `ChangeSet` already carries many changes and `step_timed` applies them
79
+ * all to the store before stepping once, so a batch is a single step with
80
+ * one set of deltas.
81
+ *
82
+ * Same input shape as `ingest`, as an array: `WasmIngestItem[]`. Returns
83
+ * the coalesced `WasmViewUpdate[]` for the whole batch. Changes are applied
84
+ * in array order, so repeated ids inside one batch settle last-write-wins,
85
+ * exactly as sequential `ingest` calls would.
86
+ */
87
+ ingest_many(items: any): any;
88
+ /**
89
+ * Bytes of row storage referenced by live rows.
90
+ */
91
+ live_bytes(): number;
92
+ /**
93
+ * Load circuit state from a JSON string
94
+ */
95
+ load_state(state: string): void;
96
+ /**
97
+ * Install a snapshot written by `save_store_state` UNDER the views that
98
+ * are already registered, keeping permissions and projection. Every
99
+ * registered view is re-primed against the restored rows; the returned
100
+ * `WasmViewUpdate[]` carries their new full results, so a query that
101
+ * registered against the empty pre-snapshot store catches up.
102
+ */
103
+ load_store_state(bytes: Uint8Array): any;
104
+ /**
105
+ * Highest `_00_rv` folded into each table, `{ [table]: rv }`.
106
+ */
107
+ max_row_versions(): any;
108
+ constructor();
109
+ /**
110
+ * Compare one table against the caller's authoritative `[id, rv][]`.
111
+ * Rows the store holds but the list lacks are deleted (with view
112
+ * updates); ids the store lacks or holds at a lower `_00_rv` come back in
113
+ * `fetch` for the caller to ingest. See `Circuit::reconcile`.
114
+ */
115
+ reconcile(table: string, entries: any): any;
116
+ /**
117
+ * Register a new materialized view
118
+ */
119
+ register_view(config: any): any;
120
+ /**
121
+ * Save the current circuit state as a JSON string
122
+ */
123
+ save_state(): string;
124
+ /**
125
+ * Snapshot the base collections only, as bytes (a `Uint8Array` in JS).
126
+ * Views are deliberately left out: the client re-registers every query
127
+ * under a fresh session id on boot, so persisted views would only be
128
+ * stepped and never read. Pair with `load_store_state`.
129
+ */
130
+ save_store_state(): Uint8Array;
131
+ /**
132
+ * Seed per-table `select` permission predicates so `register_view` can
133
+ * inject them (and so non-`_00_` tables aren't default-denied).
134
+ *
135
+ * Expects a `{ [table]: whereText }` object, where `whereText` is the raw
136
+ * `WHERE` expression from the table's `PERMISSIONS FOR select` clause
137
+ * (e.g. `"true"`, or `"owner = $auth.id"`). Called once at boot after the
138
+ * schema is parsed — mirrors the native boot path that reads `INFO FOR DB`.
139
+ */
140
+ set_permissions(permissions: any): void;
141
+ /**
142
+ * Keep only the fields registered plans evaluate (plus `id`/`_00_rv`)
143
+ * per stored row. Off by default. Must be set before the first ingest
144
+ * to take effect on those rows; `compact` re-projects existing ones.
145
+ */
146
+ set_projection(enabled: boolean): void;
147
+ /**
148
+ * Per-table and per-view heap attribution, sorted heaviest first.
149
+ */
150
+ size_report(): any;
151
+ /**
152
+ * Unregister a view by ID
153
+ */
154
+ unregister_view(id: string): void;
59
155
  }
60
156
 
61
157
  /**
@@ -66,43 +162,54 @@ export function init(): void;
66
162
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
67
163
 
68
164
  export interface InitOutput {
69
- readonly memory: WebAssembly.Memory;
70
- readonly __wbg_spookyprocessor_free: (a: number, b: number) => void;
71
- readonly init: () => void;
72
- readonly spookyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
73
- readonly spookyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
74
- readonly spookyprocessor_new: () => number;
75
- readonly spookyprocessor_register_view: (a: number, b: any) => [number, number, number];
76
- readonly spookyprocessor_save_state: (a: number) => [number, number, number, number];
77
- readonly spookyprocessor_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;
165
+ readonly memory: WebAssembly.Memory;
166
+ readonly __wbg_sp00kyprocessor_free: (a: number, b: number) => void;
167
+ readonly init: () => void;
168
+ readonly sp00kyprocessor_compact: (a: number) => number;
169
+ readonly sp00kyprocessor_dead_bytes: (a: number) => number;
170
+ readonly sp00kyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
171
+ readonly sp00kyprocessor_ingest_many: (a: number, b: any) => [number, number, number];
172
+ readonly sp00kyprocessor_live_bytes: (a: number) => number;
173
+ readonly sp00kyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
174
+ readonly sp00kyprocessor_load_store_state: (a: number, b: number, c: number) => [number, number, number];
175
+ readonly sp00kyprocessor_max_row_versions: (a: number) => [number, number, number];
176
+ readonly sp00kyprocessor_new: () => number;
177
+ readonly sp00kyprocessor_reconcile: (a: number, b: number, c: number, d: any) => [number, number, number];
178
+ readonly sp00kyprocessor_register_view: (a: number, b: any) => [number, number, number];
179
+ readonly sp00kyprocessor_save_state: (a: number) => [number, number, number, number];
180
+ readonly sp00kyprocessor_save_store_state: (a: number) => [number, number, number, number];
181
+ readonly sp00kyprocessor_set_permissions: (a: number, b: any) => [number, number];
182
+ readonly sp00kyprocessor_set_projection: (a: number, b: number) => void;
183
+ readonly sp00kyprocessor_size_report: (a: number) => [number, number, number];
184
+ readonly sp00kyprocessor_unregister_view: (a: number, b: number, c: number) => void;
185
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
186
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
187
+ readonly __wbindgen_exn_store: (a: number) => void;
188
+ readonly __externref_table_alloc: () => number;
189
+ readonly __wbindgen_externrefs: WebAssembly.Table;
190
+ readonly __externref_table_dealloc: (a: number) => void;
191
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
192
+ readonly __wbindgen_start: () => void;
86
193
  }
87
194
 
88
195
  export type SyncInitInput = BufferSource | WebAssembly.Module;
89
196
 
90
197
  /**
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
- */
198
+ * Instantiates the given `module`, which can either be bytes or
199
+ * a precompiled `WebAssembly.Module`.
200
+ *
201
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
202
+ *
203
+ * @returns {InitOutput}
204
+ */
98
205
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
99
206
 
100
207
  /**
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
- */
208
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
209
+ * for everything else, calls `WebAssembly.instantiate` directly.
210
+ *
211
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
212
+ *
213
+ * @returns {Promise<InitOutput>}
214
+ */
108
215
  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,529 @@
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
+ * Rebuild row storage without the bytes orphaned by updates and deletes.
16
+ * Returns how many bytes were dead. Costs a decode of every row, so call
17
+ * it from a checkpoint, never per ingest.
18
+ * @returns {number}
19
+ */
20
+ compact() {
21
+ const ret = wasm.sp00kyprocessor_compact(this.__wbg_ptr);
22
+ return ret;
23
+ }
24
+ /**
25
+ * Bytes of row storage orphaned by updates and deletes.
26
+ * @returns {number}
27
+ */
28
+ dead_bytes() {
29
+ const ret = wasm.sp00kyprocessor_dead_bytes(this.__wbg_ptr);
30
+ return ret;
31
+ }
32
+ /**
33
+ * Ingest a record into the stream processor
34
+ * @param {string} table
35
+ * @param {string} op
36
+ * @param {string} id
37
+ * @param {any} record
38
+ * @returns {any}
39
+ */
40
+ ingest(table, op, id, record) {
41
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
42
+ const len0 = WASM_VECTOR_LEN;
43
+ const ptr1 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
44
+ const len1 = WASM_VECTOR_LEN;
45
+ const ptr2 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
46
+ const len2 = WASM_VECTOR_LEN;
47
+ const ret = wasm.sp00kyprocessor_ingest(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, record);
48
+ if (ret[2]) {
49
+ throw takeFromExternrefTable0(ret[1]);
50
+ }
51
+ return takeFromExternrefTable0(ret[0]);
52
+ }
53
+ /**
54
+ * Ingest MANY record changes as ONE circuit step.
55
+ *
56
+ * `ingest` costs one full circuit step per record, and a step walks every
57
+ * registered view, so a cold sync that lands thousands of rows paid that
58
+ * fixed cost thousands of times (a ~3.9k-row registry took ~3.4s of circuit
59
+ * time on a laptop, ~0.85ms a row, nearly all of it per-step overhead).
60
+ * `ChangeSet` already carries many changes and `step_timed` applies them
61
+ * all to the store before stepping once, so a batch is a single step with
62
+ * one set of deltas.
63
+ *
64
+ * Same input shape as `ingest`, as an array: `WasmIngestItem[]`. Returns
65
+ * the coalesced `WasmViewUpdate[]` for the whole batch. Changes are applied
66
+ * in array order, so repeated ids inside one batch settle last-write-wins,
67
+ * exactly as sequential `ingest` calls would.
68
+ * @param {any} items
69
+ * @returns {any}
70
+ */
71
+ ingest_many(items) {
72
+ const ret = wasm.sp00kyprocessor_ingest_many(this.__wbg_ptr, items);
73
+ if (ret[2]) {
74
+ throw takeFromExternrefTable0(ret[1]);
75
+ }
76
+ return takeFromExternrefTable0(ret[0]);
77
+ }
78
+ /**
79
+ * Bytes of row storage referenced by live rows.
80
+ * @returns {number}
81
+ */
82
+ live_bytes() {
83
+ const ret = wasm.sp00kyprocessor_live_bytes(this.__wbg_ptr);
84
+ return ret;
85
+ }
86
+ /**
87
+ * Load circuit state from a JSON string
88
+ * @param {string} state
89
+ */
90
+ load_state(state) {
91
+ const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
92
+ const len0 = WASM_VECTOR_LEN;
93
+ const ret = wasm.sp00kyprocessor_load_state(this.__wbg_ptr, ptr0, len0);
94
+ if (ret[1]) {
95
+ throw takeFromExternrefTable0(ret[0]);
96
+ }
97
+ }
98
+ /**
99
+ * Install a snapshot written by `save_store_state` UNDER the views that
100
+ * are already registered, keeping permissions and projection. Every
101
+ * registered view is re-primed against the restored rows; the returned
102
+ * `WasmViewUpdate[]` carries their new full results, so a query that
103
+ * registered against the empty pre-snapshot store catches up.
104
+ * @param {Uint8Array} bytes
105
+ * @returns {any}
106
+ */
107
+ load_store_state(bytes) {
108
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
109
+ const len0 = WASM_VECTOR_LEN;
110
+ const ret = wasm.sp00kyprocessor_load_store_state(this.__wbg_ptr, ptr0, len0);
111
+ if (ret[2]) {
112
+ throw takeFromExternrefTable0(ret[1]);
113
+ }
114
+ return takeFromExternrefTable0(ret[0]);
115
+ }
116
+ /**
117
+ * Highest `_00_rv` folded into each table, `{ [table]: rv }`.
118
+ * @returns {any}
119
+ */
120
+ max_row_versions() {
121
+ const ret = wasm.sp00kyprocessor_max_row_versions(this.__wbg_ptr);
122
+ if (ret[2]) {
123
+ throw takeFromExternrefTable0(ret[1]);
124
+ }
125
+ return takeFromExternrefTable0(ret[0]);
126
+ }
127
+ constructor() {
128
+ const ret = wasm.sp00kyprocessor_new();
129
+ this.__wbg_ptr = ret >>> 0;
130
+ Sp00kyProcessorFinalization.register(this, this.__wbg_ptr, this);
131
+ return this;
132
+ }
133
+ /**
134
+ * Compare one table against the caller's authoritative `[id, rv][]`.
135
+ * Rows the store holds but the list lacks are deleted (with view
136
+ * updates); ids the store lacks or holds at a lower `_00_rv` come back in
137
+ * `fetch` for the caller to ingest. See `Circuit::reconcile`.
138
+ * @param {string} table
139
+ * @param {any} entries
140
+ * @returns {any}
141
+ */
142
+ reconcile(table, entries) {
143
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
144
+ const len0 = WASM_VECTOR_LEN;
145
+ const ret = wasm.sp00kyprocessor_reconcile(this.__wbg_ptr, ptr0, len0, entries);
146
+ if (ret[2]) {
147
+ throw takeFromExternrefTable0(ret[1]);
148
+ }
149
+ return takeFromExternrefTable0(ret[0]);
150
+ }
151
+ /**
152
+ * Register a new materialized view
153
+ * @param {any} config
154
+ * @returns {any}
155
+ */
156
+ register_view(config) {
157
+ const ret = wasm.sp00kyprocessor_register_view(this.__wbg_ptr, config);
158
+ if (ret[2]) {
159
+ throw takeFromExternrefTable0(ret[1]);
160
+ }
161
+ return takeFromExternrefTable0(ret[0]);
162
+ }
163
+ /**
164
+ * Save the current circuit state as a JSON string
165
+ * @returns {string}
166
+ */
167
+ save_state() {
168
+ let deferred2_0;
169
+ let deferred2_1;
170
+ try {
171
+ const ret = wasm.sp00kyprocessor_save_state(this.__wbg_ptr);
172
+ var ptr1 = ret[0];
173
+ var len1 = ret[1];
174
+ if (ret[3]) {
175
+ ptr1 = 0; len1 = 0;
176
+ throw takeFromExternrefTable0(ret[2]);
177
+ }
178
+ deferred2_0 = ptr1;
179
+ deferred2_1 = len1;
180
+ return getStringFromWasm0(ptr1, len1);
181
+ } finally {
182
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
183
+ }
184
+ }
185
+ /**
186
+ * Snapshot the base collections only, as bytes (a `Uint8Array` in JS).
187
+ * Views are deliberately left out: the client re-registers every query
188
+ * under a fresh session id on boot, so persisted views would only be
189
+ * stepped and never read. Pair with `load_store_state`.
190
+ * @returns {Uint8Array}
191
+ */
192
+ save_store_state() {
193
+ const ret = wasm.sp00kyprocessor_save_store_state(this.__wbg_ptr);
194
+ if (ret[3]) {
195
+ throw takeFromExternrefTable0(ret[2]);
196
+ }
197
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
198
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
199
+ return v1;
200
+ }
201
+ /**
202
+ * Seed per-table `select` permission predicates so `register_view` can
203
+ * inject them (and so non-`_00_` tables aren't default-denied).
204
+ *
205
+ * Expects a `{ [table]: whereText }` object, where `whereText` is the raw
206
+ * `WHERE` expression from the table's `PERMISSIONS FOR select` clause
207
+ * (e.g. `"true"`, or `"owner = $auth.id"`). Called once at boot after the
208
+ * schema is parsed — mirrors the native boot path that reads `INFO FOR DB`.
209
+ * @param {any} permissions
210
+ */
211
+ set_permissions(permissions) {
212
+ const ret = wasm.sp00kyprocessor_set_permissions(this.__wbg_ptr, permissions);
213
+ if (ret[1]) {
214
+ throw takeFromExternrefTable0(ret[0]);
215
+ }
216
+ }
217
+ /**
218
+ * Keep only the fields registered plans evaluate (plus `id`/`_00_rv`)
219
+ * per stored row. Off by default. Must be set before the first ingest
220
+ * to take effect on those rows; `compact` re-projects existing ones.
221
+ * @param {boolean} enabled
222
+ */
223
+ set_projection(enabled) {
224
+ wasm.sp00kyprocessor_set_projection(this.__wbg_ptr, enabled);
225
+ }
226
+ /**
227
+ * Per-table and per-view heap attribution, sorted heaviest first.
228
+ * @returns {any}
229
+ */
230
+ size_report() {
231
+ const ret = wasm.sp00kyprocessor_size_report(this.__wbg_ptr);
232
+ if (ret[2]) {
233
+ throw takeFromExternrefTable0(ret[1]);
234
+ }
235
+ return takeFromExternrefTable0(ret[0]);
236
+ }
237
+ /**
238
+ * Unregister a view by ID
239
+ * @param {string} id
240
+ */
241
+ unregister_view(id) {
242
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
243
+ const len0 = WASM_VECTOR_LEN;
244
+ wasm.sp00kyprocessor_unregister_view(this.__wbg_ptr, ptr0, len0);
245
+ }
246
+ }
247
+ if (Symbol.dispose) Sp00kyProcessor.prototype[Symbol.dispose] = Sp00kyProcessor.prototype.free;
248
+
249
+ /**
250
+ * Called when WASM module is loaded
251
+ */
252
+ export function init() {
253
+ wasm.init();
254
+ }
255
+
256
+ function __wbg_get_imports() {
257
+ const import0 = {
258
+ __proto__: null,
259
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
260
+ const ret = Error(getStringFromWasm0(arg0, arg1));
261
+ return ret;
262
+ },
263
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
264
+ const ret = Number(arg0);
265
+ return ret;
266
+ },
267
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
268
+ const ret = String(arg1);
269
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
270
+ const len1 = WASM_VECTOR_LEN;
271
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
272
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
273
+ },
274
+ __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
275
+ const v = arg1;
276
+ const ret = typeof(v) === 'bigint' ? v : undefined;
277
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
278
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
279
+ },
280
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
281
+ const v = arg0;
282
+ const ret = typeof(v) === 'boolean' ? v : undefined;
283
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
284
+ },
285
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
286
+ const ret = debugString(arg1);
287
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
288
+ const len1 = WASM_VECTOR_LEN;
289
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
290
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
291
+ },
292
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
293
+ const ret = arg0 in arg1;
294
+ return ret;
295
+ },
296
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
297
+ const ret = typeof(arg0) === 'bigint';
298
+ return ret;
299
+ },
300
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
301
+ const ret = typeof(arg0) === 'function';
302
+ return ret;
303
+ },
304
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
305
+ const val = arg0;
306
+ const ret = typeof(val) === 'object' && val !== null;
307
+ return ret;
308
+ },
309
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
310
+ const ret = typeof(arg0) === 'string';
311
+ return ret;
312
+ },
313
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
314
+ const ret = arg0 === undefined;
315
+ return ret;
316
+ },
317
+ __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
318
+ const ret = arg0 === arg1;
319
+ return ret;
320
+ },
321
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
322
+ const ret = arg0 == arg1;
323
+ return ret;
324
+ },
325
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
326
+ const obj = arg1;
327
+ const ret = typeof(obj) === 'number' ? obj : undefined;
328
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
329
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
330
+ },
331
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
332
+ const obj = arg1;
333
+ const ret = typeof(obj) === 'string' ? obj : undefined;
334
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
335
+ var len1 = WASM_VECTOR_LEN;
336
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
337
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
338
+ },
339
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
340
+ throw new Error(getStringFromWasm0(arg0, arg1));
341
+ },
342
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
343
+ const ret = arg0.call(arg1);
344
+ return ret;
345
+ }, arguments); },
346
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
347
+ const ret = arg0.done;
348
+ return ret;
349
+ },
350
+ __wbg_entries_58c7934c745daac7: function(arg0) {
351
+ const ret = Object.entries(arg0);
352
+ return ret;
353
+ },
354
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
355
+ const ret = arg0[arg1 >>> 0];
356
+ return ret;
357
+ },
358
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
359
+ const ret = Reflect.get(arg0, arg1);
360
+ return ret;
361
+ }, arguments); },
362
+ __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
363
+ const ret = arg0[arg1];
364
+ return ret;
365
+ },
366
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
367
+ let result;
368
+ try {
369
+ result = arg0 instanceof ArrayBuffer;
370
+ } catch (_) {
371
+ result = false;
372
+ }
373
+ const ret = result;
374
+ return ret;
375
+ },
376
+ __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
377
+ let result;
378
+ try {
379
+ result = arg0 instanceof Map;
380
+ } catch (_) {
381
+ result = false;
382
+ }
383
+ const ret = result;
384
+ return ret;
385
+ },
386
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
387
+ let result;
388
+ try {
389
+ result = arg0 instanceof Uint8Array;
390
+ } catch (_) {
391
+ result = false;
392
+ }
393
+ const ret = result;
394
+ return ret;
395
+ },
396
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
397
+ const ret = Array.isArray(arg0);
398
+ return ret;
399
+ },
400
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
401
+ const ret = Number.isSafeInteger(arg0);
402
+ return ret;
403
+ },
404
+ __wbg_iterator_6ff6560ca1568e55: function() {
405
+ const ret = Symbol.iterator;
406
+ return ret;
407
+ },
408
+ __wbg_length_32ed9a279acd054c: function(arg0) {
409
+ const ret = arg0.length;
410
+ return ret;
411
+ },
412
+ __wbg_length_35a7bace40f36eac: function(arg0) {
413
+ const ret = arg0.length;
414
+ return ret;
415
+ },
416
+ __wbg_log_6b5ca2e6124b2808: function(arg0) {
417
+ console.log(arg0);
418
+ },
419
+ __wbg_new_361308b2356cecd0: function() {
420
+ const ret = new Object();
421
+ return ret;
422
+ },
423
+ __wbg_new_3eb36ae241fe6f44: function() {
424
+ const ret = new Array();
425
+ return ret;
426
+ },
427
+ __wbg_new_dca287b076112a51: function() {
428
+ const ret = new Map();
429
+ return ret;
430
+ },
431
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
432
+ const ret = new Uint8Array(arg0);
433
+ return ret;
434
+ },
435
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
436
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
437
+ return ret;
438
+ },
439
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
440
+ const ret = arg0.next();
441
+ return ret;
442
+ }, arguments); },
443
+ __wbg_next_418f80d8f5303233: function(arg0) {
444
+ const ret = arg0.next;
445
+ return ret;
446
+ },
447
+ __wbg_now_2c95c9de01293173: function(arg0) {
448
+ const ret = arg0.now();
449
+ return ret;
450
+ },
451
+ __wbg_performance_7a3ffd0b17f663ad: function(arg0) {
452
+ const ret = arg0.performance;
453
+ return ret;
454
+ },
455
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
456
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
457
+ },
458
+ __wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
459
+ const ret = arg0.set(arg1, arg2);
460
+ return ret;
461
+ },
462
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
463
+ arg0[arg1] = arg2;
464
+ },
465
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
466
+ arg0[arg1 >>> 0] = arg2;
467
+ },
468
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
469
+ const ret = typeof global === 'undefined' ? null : global;
470
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
471
+ },
472
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
473
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
474
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
475
+ },
476
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
477
+ const ret = typeof self === 'undefined' ? null : self;
478
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
479
+ },
480
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
481
+ const ret = typeof window === 'undefined' ? null : window;
482
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
483
+ },
484
+ __wbg_value_0546255b415e96c1: function(arg0) {
485
+ const ret = arg0.value;
486
+ return ret;
487
+ },
488
+ __wbindgen_cast_0000000000000001: function(arg0) {
489
+ // Cast intrinsic for `F64 -> Externref`.
490
+ const ret = arg0;
491
+ return ret;
492
+ },
493
+ __wbindgen_cast_0000000000000002: function(arg0) {
494
+ // Cast intrinsic for `I64 -> Externref`.
495
+ const ret = arg0;
496
+ return ret;
497
+ },
498
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
499
+ // Cast intrinsic for `Ref(String) -> Externref`.
500
+ const ret = getStringFromWasm0(arg0, arg1);
501
+ return ret;
502
+ },
503
+ __wbindgen_cast_0000000000000004: function(arg0) {
504
+ // Cast intrinsic for `U64 -> Externref`.
505
+ const ret = BigInt.asUintN(64, arg0);
506
+ return ret;
507
+ },
508
+ __wbindgen_init_externref_table: function() {
509
+ const table = wasm.__wbindgen_externrefs;
510
+ const offset = table.grow(4);
511
+ table.set(0, undefined);
512
+ table.set(offset + 0, undefined);
513
+ table.set(offset + 1, null);
514
+ table.set(offset + 2, true);
515
+ table.set(offset + 3, false);
516
+ },
517
+ };
518
+ return {
519
+ __proto__: null,
520
+ "./ssp_wasm_bg.js": import0,
521
+ };
522
+ }
523
+
524
+ const Sp00kyProcessorFinalization = (typeof FinalizationRegistry === 'undefined')
525
+ ? { register: () => {}, unregister: () => {} }
526
+ : new FinalizationRegistry(ptr => wasm.__wbg_sp00kyprocessor_free(ptr >>> 0, 1));
2
527
 
3
528
  function addToExternrefTable0(obj) {
4
529
  const idx = wasm.__externref_table_alloc();
@@ -110,6 +635,13 @@ function isLikeNone(x) {
110
635
  return x === undefined || x === null;
111
636
  }
112
637
 
638
+ function passArray8ToWasm0(arg, malloc) {
639
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
640
+ getUint8ArrayMemory0().set(arg, ptr / 1);
641
+ WASM_VECTOR_LEN = arg.length;
642
+ return ptr;
643
+ }
644
+
113
645
  function passStringToWasm0(arg, malloc, realloc) {
114
646
  if (realloc === undefined) {
115
647
  const buf = cachedTextEncoder.encode(arg);
@@ -177,134 +709,33 @@ if (!('encodeInto' in cachedTextEncoder)) {
177
709
  read: arg.length,
178
710
  written: buf.length
179
711
  };
180
- }
712
+ };
181
713
  }
182
714
 
183
715
  let WASM_VECTOR_LEN = 0;
184
716
 
185
- const SpookyProcessorFinalization = (typeof FinalizationRegistry === 'undefined')
186
- ? { register: () => {}, unregister: () => {} }
187
- : new FinalizationRegistry(ptr => wasm.__wbg_spookyprocessor_free(ptr >>> 0, 1));
188
-
189
- export class SpookyProcessor {
190
- __destroy_into_raw() {
191
- const ptr = this.__wbg_ptr;
192
- this.__wbg_ptr = 0;
193
- SpookyProcessorFinalization.unregister(this);
194
- return ptr;
195
- }
196
- free() {
197
- const ptr = this.__destroy_into_raw();
198
- wasm.__wbg_spookyprocessor_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.spookyprocessor_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.spookyprocessor_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.spookyprocessor_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.spookyprocessor_unregister_view(this.__wbg_ptr, ptr0, len0);
254
- }
255
- constructor() {
256
- const ret = wasm.spookyprocessor_new();
257
- this.__wbg_ptr = ret >>> 0;
258
- SpookyProcessorFinalization.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.spookyprocessor_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) SpookyProcessor.prototype[Symbol.dispose] = SpookyProcessor.prototype.free;
284
-
285
- /**
286
- * Called when WASM module is loaded
287
- */
288
- export function init() {
289
- wasm.init();
717
+ let wasmModule, wasm;
718
+ function __wbg_finalize_init(instance, module) {
719
+ wasm = instance.exports;
720
+ wasmModule = module;
721
+ cachedDataViewMemory0 = null;
722
+ cachedUint8ArrayMemory0 = null;
723
+ wasm.__wbindgen_start();
724
+ return wasm;
290
725
  }
291
726
 
292
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
293
-
294
727
  async function __wbg_load(module, imports) {
295
728
  if (typeof Response === 'function' && module instanceof Response) {
296
729
  if (typeof WebAssembly.instantiateStreaming === 'function') {
297
730
  try {
298
731
  return await WebAssembly.instantiateStreaming(module, imports);
299
732
  } catch (e) {
300
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
733
+ const validResponse = module.ok && expectedResponseType(module.type);
301
734
 
302
735
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
303
736
  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
737
 
305
- } else {
306
- throw e;
307
- }
738
+ } else { throw e; }
308
739
  }
309
740
  }
310
741
 
@@ -319,237 +750,20 @@ async function __wbg_load(module, imports) {
319
750
  return instance;
320
751
  }
321
752
  }
322
- }
323
753
 
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;
754
+ function expectedResponseType(type) {
755
+ switch (type) {
756
+ case 'basic': case 'cors': case 'default': return true;
424
757
  }
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;
434
- }
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;
758
+ return false;
759
+ }
546
760
  }
547
761
 
548
762
  function initSync(module) {
549
763
  if (wasm !== undefined) return wasm;
550
764
 
551
765
 
552
- if (typeof module !== 'undefined') {
766
+ if (module !== undefined) {
553
767
  if (Object.getPrototypeOf(module) === Object.prototype) {
554
768
  ({module} = module)
555
769
  } else {
@@ -569,7 +783,7 @@ async function __wbg_init(module_or_path) {
569
783
  if (wasm !== undefined) return wasm;
570
784
 
571
785
 
572
- if (typeof module_or_path !== 'undefined') {
786
+ if (module_or_path !== undefined) {
573
787
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
574
788
  ({module_or_path} = module_or_path)
575
789
  } else {
@@ -577,7 +791,7 @@ async function __wbg_init(module_or_path) {
577
791
  }
578
792
  }
579
793
 
580
- if (typeof module_or_path === 'undefined') {
794
+ if (module_or_path === undefined) {
581
795
  module_or_path = new URL('ssp_wasm_bg.wasm', import.meta.url);
582
796
  }
583
797
  const imports = __wbg_get_imports();
@@ -591,5 +805,4 @@ async function __wbg_init(module_or_path) {
591
805
  return __wbg_finalize_init(instance, module);
592
806
  }
593
807
 
594
- export { initSync };
595
- export default __wbg_init;
808
+ export { initSync, __wbg_init as default };
Binary file
@@ -1,14 +1,25 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const __wbg_spookyprocessor_free: (a: number, b: number) => void;
4
+ export const __wbg_sp00kyprocessor_free: (a: number, b: number) => void;
5
5
  export const init: () => void;
6
- export const spookyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
7
- export const spookyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
8
- export const spookyprocessor_new: () => number;
9
- export const spookyprocessor_register_view: (a: number, b: any) => [number, number, number];
10
- export const spookyprocessor_save_state: (a: number) => [number, number, number, number];
11
- export const spookyprocessor_unregister_view: (a: number, b: number, c: number) => void;
6
+ export const sp00kyprocessor_compact: (a: number) => number;
7
+ export const sp00kyprocessor_dead_bytes: (a: number) => number;
8
+ export const sp00kyprocessor_ingest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
9
+ export const sp00kyprocessor_ingest_many: (a: number, b: any) => [number, number, number];
10
+ export const sp00kyprocessor_live_bytes: (a: number) => number;
11
+ export const sp00kyprocessor_load_state: (a: number, b: number, c: number) => [number, number];
12
+ export const sp00kyprocessor_load_store_state: (a: number, b: number, c: number) => [number, number, number];
13
+ export const sp00kyprocessor_max_row_versions: (a: number) => [number, number, number];
14
+ export const sp00kyprocessor_new: () => number;
15
+ export const sp00kyprocessor_reconcile: (a: number, b: number, c: number, d: any) => [number, number, number];
16
+ export const sp00kyprocessor_register_view: (a: number, b: any) => [number, number, number];
17
+ export const sp00kyprocessor_save_state: (a: number) => [number, number, number, number];
18
+ export const sp00kyprocessor_save_store_state: (a: number) => [number, number, number, number];
19
+ export const sp00kyprocessor_set_permissions: (a: number, b: any) => [number, number];
20
+ export const sp00kyprocessor_set_projection: (a: number, b: number) => void;
21
+ export const sp00kyprocessor_size_report: (a: number) => [number, number, number];
22
+ export const sp00kyprocessor_unregister_view: (a: number, b: number, c: number) => void;
12
23
  export const __wbindgen_malloc: (a: number, b: number) => number;
13
24
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
14
25
  export const __wbindgen_exn_store: (a: number) => void;