import { InitInput, SyncInitInput } from 'web-csv-toolbox-wasm'; import { isInitialized, resetInit } from './loaders/loadWASM.web.ts'; import { getWasmModule, isSyncInitialized, resetSyncInit } from './loaders/loadWASMSync.web.ts'; /** * Re-export all WASM functions from this module to ensure they share the same WASM instance. * * Why this is necessary: * 1. The loaders call init() which initializes the WASM module's internal global state * 2. If WASM functions are imported directly from "web-csv-toolbox-wasm" elsewhere, * they may reference a different module context in some environments (e.g., test runners) * 3. This can lead to errors like "Cannot read properties of undefined (reading '__wbindgen_malloc')" * because the WASM instance accessed by those functions hasn't been initialized * 4. By re-exporting all functions from the same module that handles initialization, * we ensure they always reference the same initialized WASM instance * * Using `export *` instead of individual named exports: * - Automatically includes all current and future WASM functions * - No maintenance needed when new functions are added to web-csv-toolbox-wasm * - Maintains type safety through TypeScript's type inference */ export * from 'web-csv-toolbox-wasm'; /** * Re-export state management functions. * This provides a unified API for all WASM-related functionality. */ export { isInitialized, resetInit, isSyncInitialized, resetSyncInit, getWasmModule, }; /** * Load and initialize the WebAssembly module (async). * * WASM will auto-initialize on first use if not preloaded. * This function is useful for: * - Warming up the WASM module before first use * - Custom initialization input (advanced use case) * * **Backward compatible:** This function works the same as the previous `loadWASM()`. * * @param input - Optional custom initialization input * * @example * ```ts * import { loadWASM } from 'web-csv-toolbox'; * * // Optional preload * await loadWASM(); * * // Now WASM functions are ready (but they auto-initialize anyway) * ``` * * @example * No preload needed - auto-initialization * ```ts * import { parseStringToArraySyncWASM } from 'web-csv-toolbox'; * * // WASM auto-initializes on first use * const result = parseStringToArraySyncWASM(csv); * ``` */ export declare function loadWASM(input?: InitInput): Promise; /** * Load and initialize the WebAssembly module synchronously. * * This function uses the inlined WASM module (base64-encoded at build time) * to enable synchronous initialization. This is useful for: * - Synchronous APIs like parseStringToArraySyncWASM * - Contexts where async initialization is not possible * * **Trade-offs:** * - ✅ Synchronous initialization - no await needed * - ✅ Works in synchronous contexts * - ❌ Larger bundle size (WASM inlined as base64) * - ❌ Slower initial load time * * **Backward compatible:** This function works the same as the previous `loadWASMSync()`. * * @param input - Optional custom initialization input. If not provided, uses inlined WASM. * * @example * ```ts * import { loadWASMSync, parseStringToArraySyncWASM } from 'web-csv-toolbox'; * * // Synchronous initialization * loadWASMSync(); * * // Now you can use sync APIs without await * const result = parseStringToArraySyncWASM(csv); * ``` */ export declare function loadWASMSync(input?: SyncInitInput): void; /** * Check if WASM module is ready. * * @returns True if WASM is initialized * * @example * ```ts * import { isWASMReady } from 'web-csv-toolbox'; * * if (isWASMReady()) { * console.log('WASM is ready'); * } * ``` */ export declare function isWASMReady(): boolean; /** * Ensure WASM module is initialized. * Auto-initializes if not already initialized. * * @internal */ export declare function ensureWASMInitialized(): Promise;