Leon4gr45/builder
0
1import { AsyncLocalStorage } from 'node:async_hooks';2import { registerContextVFSProvider } from '@/lib/vfs';3import type { VirtualFileSystem } from '@/lib/vfs';4 5const vfsStorage = new AsyncLocalStorage<VirtualFileSystem>();6 7export function runWithVFS<T>(vfs: VirtualFileSystem, fn: () => Promise<T>): Promise<T> {8 return vfsStorage.run(vfs, fn);9}10 11export function getContextVFS(): VirtualFileSystem | undefined {12 return vfsStorage.getStore();13}14 15registerContextVFSProvider(getContextVFS);16 