Skip to content

Commit 2eb9bea

Browse files
committed
fix: suppress WASM console.log in production, export ScanOperator
- wasm-engine: js_log callback is no-op by default; pass onLog option for debug output - index.ts: export ScanOperator (required by PipelineResult.scan type)
1 parent 0d8d67c commit 2eb9bea

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export {
2323
ComputedColumnOperator, HashJoinOperator, ExternalSortOperator,
2424
InMemorySortOperator, WindowOperator, DistinctOperator, SetOperator,
2525
LimitOperator, SubqueryInOperator,
26+
ScanOperator,
2627
drainPipeline, buildPipeline, buildEdgePipeline, FsSpillBackend,
2728
buildKeptPageIndices, canSkipPageMultiCol,
2829
} from "./operators.js";

src/wasm-engine.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,20 @@ export interface WasmExports {
145145
ivfPqFree(handle: number): void;
146146
}
147147

148-
export async function instantiateWasm(wasmModule: WebAssembly.Module): Promise<WasmEngine> {
148+
export async function instantiateWasm(wasmModule: WebAssembly.Module, opts?: { onLog?: (msg: string) => void }): Promise<WasmEngine> {
149149
let mem: { buffer: ArrayBuffer } | undefined;
150+
const onLog = opts?.onLog;
150151
const instance = await WebAssembly.instantiate(wasmModule, {
151152
env: {
152153
opfs_open: () => 0, opfs_close: () => {}, opfs_read: () => 0,
153154
opfs_write: () => 0, opfs_size: () => 0, opfs_flush: () => {}, opfs_truncate: () => {},
154-
js_log: (ptr: number, len: number) => {
155-
try {
156-
if (mem) {
157-
const msg = textDecoder.decode(new Uint8Array(mem.buffer, ptr, len));
158-
console.log(`[WASM] ${msg}`);
155+
js_log: onLog
156+
? (ptr: number, len: number) => {
157+
try {
158+
if (mem) onLog(textDecoder.decode(new Uint8Array(mem.buffer, ptr, len)));
159+
} catch { /* ignore */ }
159160
}
160-
} catch { /* ignore */ }
161-
},
161+
: () => {},
162162
},
163163
});
164164
mem = (instance.exports as unknown as WasmExports).memory;

0 commit comments

Comments
 (0)