From bb7035515183c05783e92ce457d36f8cff36501e Mon Sep 17 00:00:00 2001 From: continuist Date: Sun, 26 Oct 2025 11:03:00 -0400 Subject: [PATCH] try to make wasm work --- frontend/src/lib/wasm.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/wasm.ts b/frontend/src/lib/wasm.ts index f154b08..976bf23 100644 --- a/frontend/src/lib/wasm.ts +++ b/frontend/src/lib/wasm.ts @@ -1,7 +1,6 @@ -import type { UserProfile, SPFPassport } from './auth/types'; +'use client'; -// Import the generated WASM module types -// import type * as WasmModule from '../wasm/pkg/sharenet_passport_wasm'; +import type { UserProfile, SPFPassport } from './auth/types'; /** * WASM module interface with proper TypeScript typing @@ -54,12 +53,17 @@ export class PassportWASMLoader { } try { - // Dynamically import the WASM bindings - they handle the WASM initialization + // Dynamically import the WASM bindings + // With bundler target, the module is automatically initialized on import + // but we need to ensure the WASM memory is ready before calling functions const wasmModule = await import('./wasm-pkg/sharenet_passport_wasm'); - // Initialize the WASM module using the default export - // With bundler target, this automatically handles the WASM loading - await wasmModule.default(); + // Test that the WASM module is properly initialized by checking if + // the wasm memory is accessible through a simple property access + // This ensures the WASM module is fully loaded before we use it + if (!wasmModule || typeof wasmModule.parse_spf_file !== 'function') { + throw new Error('WASM module exports not properly loaded'); + } // Create wrapper functions with proper typing const wasmWrapper: PassportWASM = {