import type { EvaluationResponse } from '../model/evaluation-response'; import type { WasmInput } from '../model/wasm-input'; import './wasm_exec.js'; import type { Logger } from '@openfeature/server-sdk'; /** * EvaluationWasm is a class that represents the evaluation of a feature flag * it calls an external WASM module to evaluate the feature flag. */ export declare class EvaluateWasm { private readonly WASM_MODULE_PATH; private wasmMemory; private wasmExports; private readonly go; private readonly logger?; private readonly wasmBinaryPath?; private readonly encoder; /** * Constructor of the EvaluationWasm. It initializes the WASM module and the host functions. * @param logger - Logger instance * @param wasmBinaryPath - Optional path to the WASM binary file */ constructor(logger?: Logger, wasmBinaryPath?: string); /** * Initializes the WASM module. * In a real implementation, this would load the WASM binary and instantiate it. */ initialize(): Promise; dispose(): Promise; /** * Loads the WASM binary file. * @returns Promise - The WASM binary data */ private loadWasmBinary; /** * Resolves the WASM file path using multiple strategies. * @param attemptedPaths - Array to collect attempted paths for error reporting * @returns The resolved path or null if not found */ private resolveWasmPath; /** * Tries to resolve WASM path from custom configured path. */ private tryCustomPath; /** * Tries to resolve WASM path relative to current file. */ private tryRelativePath; /** * Tries to resolve WASM path from node_modules. */ private tryNodeModulesPath; /** * Extracts the package name from a node_modules path. */ private extractPackageName; /** * Tries to resolve WASM path using require.resolve. */ private tryRequireResolvePath; /** * Evaluates a feature flag using the WASM module. * @param wasmInput - The input data for the evaluation * @returns A Promise - A ResolutionDetails of the feature flag * @throws WasmInvalidResultException - If for any reasons we have an issue calling the wasm module. */ evaluate(wasmInput: WasmInput): Promise; /** * Calls the WASM evaluate function. * @param inputPtr - Pointer to the input string in WASM memory * @param inputLength - Length of the input string * @returns The result from the WASM evaluate function */ private callWasmEvaluate; /** * Calls the WASM free function. * @param ptr - Pointer to free in WASM memory */ private callWasmFree; /** * Copies the input string to the WASM memory and returns the pointer to the memory location. * @param inputString - string to put in memory * @returns the address location of this string * @throws WasmInvalidResultException - If for any reasons we have an issue calling the wasm module. */ private copyToMemory; /** * Writes a string to WASM memory. * @param ptr - Pointer to write to * @param str - String to write */ private writeStringToMemory; /** * Reads the output string from the WASM memory based on the result of the evaluation. * @param evaluateRes - result of the evaluate function * @returns A string containing the output of the evaluate function * @throws WasmInvalidResultException - If for any reasons we have an issue calling the wasm module. */ private readFromMemory; }