1 import type { PassCoreProxy, PassCoreService } from './types';
3 /** The PassCoreService class provides an `exec` function that abstracts
4 * the execution of PassRustCore methods, regardless of whether the
5 * WASM module is loaded in a worker or within the same execution context.
6 * The PassCoreProxy enables duck-typing of the initial PassRustCore methods
7 * through a proxy object, thereby offering a more user-friendly API. */
8 export const createPassCoreProxy = (service: PassCoreService): PassCoreProxy =>
9 new Proxy<PassCoreProxy>({} as any, {
11 /* In case the object gets serialized during error reporting */
12 if (property === 'toJSON') return () => ({ __type: 'PassCoreProxy' });
13 if (property === Symbol.toStringTag) return 'PassCoreProxy';
15 return (...args: any[]) => service.exec(property as any, ...args);