import { SandboxImpl } from "./sandbox.js"; //#region src/sandbox/isolated-vm.d.ts /** * Minimal subset of the `isolated-vm` peer-dep public surface used by * the adapter. Declared inline so `@graphorin/security` does not * require type definitions for the optional peer at compile time. */ /** * Structural view of the `isolated-vm` module returned by * `IsolatedVMSandboxOptions.peerLoader`. * * @stable */ interface IsolatedVMPeerModule { readonly Isolate: { new (opts: { memoryLimit?: number; }): IsolatedVMIsolate; }; } /** * Structural view of an `isolated-vm` Isolate instance. * * @stable */ interface IsolatedVMIsolate { readonly createContext: () => Promise; readonly compileScript: (source: string) => Promise; readonly dispose: () => void; } /** * Structural view of an `isolated-vm` execution context. * * @stable */ interface IsolatedVMContext { readonly global: { readonly setSync: (name: string, value: unknown) => void; }; readonly release: () => void; } /** * Structural view of an `isolated-vm` compiled script. * * @stable */ interface IsolatedVMScript { readonly run: (context: IsolatedVMContext, opts?: { readonly timeout?: number; readonly promise?: boolean; readonly copy?: boolean; }) => Promise; readonly release: () => void; } /** * Options for `createIsolatedVMSandbox(...)`. * * @stable */ interface IsolatedVMSandboxOptions { /** Memory limit forwarded to `new Isolate({ memoryLimit })`. Defaults to 128 MB per DEC-148. */ readonly memoryLimitMb?: number; /** Default wall-clock timeout (ms). Defaults to 5000. */ readonly defaultTimeoutMs?: number; /** * Adapter to use if the `isolated-vm` peer is unavailable. Defaults * to `'fallback-to-worker-threads'`. Set to `'throw'` for production * builds that must refuse to start when the peer is missing. */ readonly fallback?: 'fallback-to-worker-threads' | 'throw'; /** Worker-threads adapter to fall back to. Required when `fallback === 'fallback-to-worker-threads'`. */ readonly fallbackAdapter?: SandboxImpl; /** Optional WARN logger called once per process when the fallback engages. */ readonly warn?: (message: string) => void; /** * Override the peer-dep loader. Tests pass a stub here so the * adapter can run without the native binary. */ readonly peerLoader?: () => Promise; } /** * Construct an `IsolatedVMSandbox`. The adapter resolves the peer * lazily on the first `run(...)` call so the package can be imported * even on hosts that cannot install `isolated-vm`. * * @stable */ declare function createIsolatedVMSandbox(opts?: IsolatedVMSandboxOptions): SandboxImpl; //#endregion export { IsolatedVMContext, IsolatedVMIsolate, IsolatedVMPeerModule, IsolatedVMSandboxOptions, IsolatedVMScript, createIsolatedVMSandbox }; //# sourceMappingURL=isolated-vm.d.ts.map