/** * The following code is modified based on * https://github.com/webpack/webpack/blob/4b4ca3b/lib/Cache.js * * MIT Licensed * Author Tobias Koppers @sokra * Copyright (c) JS Foundation and other contributors * https://github.com/webpack/webpack/blob/main/LICENSE */ import { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } from '../../compiled/@rspack/lite-tapable/dist/index.js'; import type { WebpackError } from './WebpackError.js'; export interface Etag { toString(): string; } export type CallbackCache = (err?: WebpackError | null, result?: T) => void; type GotHandler = (result: T | null, callback: (error: Error | null) => void) => void; export declare class Cache { static STAGE_DISK: number; static STAGE_MEMORY: number; static STAGE_DEFAULT: number; static STAGE_NETWORK: number; hooks: { get: AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>; store: AsyncParallelHook<[string, Etag | null, any]>; storeBuildDependencies: AsyncParallelHook<[Iterable]>; beginIdle: SyncHook<[]>; endIdle: AsyncParallelHook<[]>; shutdown: AsyncParallelHook<[]>; }; constructor(); /** * @param identifier the cache identifier * @param etag the etag * @param callback signals when the value is retrieved * @returns */ get(identifier: string, etag: Etag | null, callback: CallbackCache): void; /** * @param identifier the cache identifier * @param etag the etag * @param data the value to store * @param callback signals when the value is stored * @returns */ store(identifier: string, etag: Etag | null, data: T, callback: CallbackCache): void; /** * After this method has succeeded the cache can only be restored when build dependencies are * @param dependencies list of all build dependencies * @param callback signals when the dependencies are stored * @returns */ storeBuildDependencies(dependencies: Iterable, callback: CallbackCache): void; beginIdle(): void; /** * @param callback signals when the call finishes * @returns */ endIdle(callback: CallbackCache): void; /** * @param callback signals when the call finishes * @returns */ shutdown(callback: CallbackCache): void; } export default Cache;