@tevm/bundler-cache
Version:
Cache for tevm bundler
56 lines (51 loc) • 2.41 kB
text/typescript
import { statSync, mkdirSync } from 'node:fs';
import { writeFile, stat, mkdir } from 'node:fs/promises';
import { ResolvedArtifacts } from '@tevm/compiler';
/**
* Generalized interface for accessing file system
* Allows this package to be used in browser environments or otherwise pluggable
*/
type FileAccessObject$1 = {
writeFileSync: (path: string, data: string) => void;
writeFile: typeof writeFile;
readFile: (path: string, encoding: BufferEncoding) => Promise<string>;
readFileSync: (path: string, encoding: BufferEncoding) => string;
exists: (path: string) => Promise<boolean>;
existsSync: (path: string) => boolean;
statSync: typeof statSync;
stat: typeof stat;
mkdirSync: typeof mkdirSync;
mkdir: typeof mkdir;
};
type CachedItem$1 = 'artifactsJson' | 'dts' | 'mjs';
type ReadArtifactsSync = (entryModuleId: string) => ResolvedArtifacts | undefined;
type ReadArtifacts = (entryModuleId: string) => Promise<ResolvedArtifacts | undefined>;
type ReadDtsSync = (entryModuleId: string) => string | undefined;
type ReadDts = (entryModuleId: string) => Promise<string | undefined>;
type ReadMjsSync = (entryModuleId: string) => string | undefined;
type ReadMjs = (entryModuleId: string) => Promise<string | undefined>;
type WriteArtifactsSync = (entryModuleId: string, artifacts: ResolvedArtifacts) => string;
type WriteArtifacts = (entryModuleId: string, artifacts: ResolvedArtifacts) => Promise<string>;
type WriteDtsSync = (entryModuleId: string, dtsFile: string) => string;
type WriteDts = (entryModuleId: string, dtsFile: string) => Promise<string>;
type WriteMjsSync = (entryModuleId: string, mjsFile: string) => string;
type WriteMjs = (entryModuleId: string, mjsFile: string) => Promise<string>;
type Cache$1 = {
readArtifactsSync: ReadArtifactsSync;
readArtifacts: ReadArtifacts;
readDtsSync: ReadDtsSync;
readDts: ReadDts;
readMjsSync: ReadMjsSync;
readMjs: ReadMjs;
writeArtifactsSync: WriteArtifactsSync;
writeArtifacts: WriteArtifacts;
writeDtsSync: WriteDtsSync;
writeDts: WriteDts;
writeMjsSync: WriteMjsSync;
writeMjs: WriteMjs;
};
declare function createCache(cacheDir: string, fs: FileAccessObject$1, cwd: string): Cache$1;
type Cache = Cache$1;
type CachedItem = CachedItem$1;
type FileAccessObject = FileAccessObject$1;
export { type Cache, type CachedItem, type FileAccessObject, createCache };