CoolFace
Apppublic

Leon4gr45/builder

sourceHugging Facemitupdated 2d agoView on Hugging Face
0likes
vfs-context.ts16 linesDownload Raw Back to server-generate
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