UNPKG

hakojs

Version:

A secure, embeddable JavaScript engine that runs untrusted code inside WebAssembly sandboxes with fine-grained permissions and resource limits

70 lines 2.9 kB
import type { HakoExports } from "../etc/ffi"; import type { HakoBuildInfo } from "../etc/types"; import type { MemoryManager } from "../mem/memory"; /** * Provides utility functions for the PrimJS wrapper. * * This class encapsulates various helper methods for working with the PrimJS * engine, including build information retrieval, JavaScript object property * access, value comparison, and runtime configuration checks. */ export declare class Utils { private memory; private exports; private buildInfo; /** * Creates a new Utils instance. * * @param exports - The WebAssembly exports interface for accessing PrimJS functions * @param memory - The memory manager for handling WebAssembly memory operations */ constructor(exports: HakoExports, memory: MemoryManager); /** * Retrieves detailed build information about the PrimJS engine. * * This method reads the build information structure from the WebAssembly module, * including version strings, compiler details, and feature flags. Results are * cached after the first call for better performance. * * @returns A HakoBuildInfo object containing build configuration details */ getBuildInfo(): HakoBuildInfo; /** * Gets the length property of a JavaScript object or array. * * This utility method safely retrieves the 'length' property from a JavaScript * object in the PrimJS engine, useful for arrays, strings, and other objects * with a length property. * * @param ctx - PrimJS context pointer * @param ptr - JSValue pointer to the object * @returns The length value as a number, or -1 if the length is not available */ getLength(ctx: number, ptr: number): number; /** * Checks if two JavaScript values are equal according to the specified equality operation. * * This method allows comparing JavaScript values in the PrimJS engine using * different equality semantics. * * @param ctx - PrimJS context pointer * @param aPtr - First JSValue pointer * @param bPtr - Second JSValue pointer * @param op - Equality operation mode: * 0: Strict equality (===) * 1: Same value (Object.is) * 2: Same value zero (treats +0 and -0 as equal) * @returns True if the values are equal according to the specified operation */ isEqual(ctx: number, aPtr: number, bPtr: number, op?: number): boolean; /** * Checks if the PrimJS engine was built with debug mode enabled. * * Debug builds contain additional runtime checks, assertions, and debugging * facilities, but typically run slower than release builds. * * @returns True if PrimJS is running in a debug build, false otherwise */ isDebugBuild(): boolean; } //# sourceMappingURL=utils.d.ts.map