| 238 | } |
| 239 | |
| 240 | export class DiskBuildCache<State> implements DevBuildCache<State> { |
| 241 | #processedFiles = new Map<string, string | null>(); |
| 242 | #unprocessedFiles = new Map<string, string>(); |
| 243 | #transformer: FileTransformer; |
| 244 | #config: ResolvedBuildConfig; |
| 245 | islandModNameToChunk = new Map<string, IslandModChunk>(); |
| 246 | #fsRoutes: FsRoute<State>; |
| 247 | root: string; |
| 248 | islandRegistry: ServerIslandRegistry = new Map(); |
| 249 | clientEntry: string = ""; |
| 250 | hmrClientEntry: string | undefined = undefined; |
| 251 | features = { errorOverlay: false }; |
| 252 | |
| 253 | constructor( |
| 254 | config: ResolvedBuildConfig, |
| 255 | fsRoutes: FsRoute<State>, |
| 256 | transformer: FileTransformer, |
| 257 | ) { |
| 258 | if (config.mode === "development") { |
| 259 | this.features.errorOverlay = true; |
| 260 | } |
| 261 | this.#fsRoutes = fsRoutes; |
| 262 | this.#transformer = transformer; |
| 263 | this.#config = config; |
| 264 | this.root = config.root; |
| 265 | } |
| 266 | |
| 267 | getEntryAssets(): string[] { |
| 268 | return []; |
| 269 | } |
| 270 | |
| 271 | getFsRoutes(): Command<State>[] { |
| 272 | return []; |
| 273 | } |
| 274 | |
| 275 | addUnprocessedFile(pathname: string, dir: string): void { |
| 276 | this.#unprocessedFiles.set( |
| 277 | pathname.replaceAll(WINDOWS_SEPARATOR, "/"), |
| 278 | path.join(dir, pathname), |
| 279 | ); |
| 280 | } |
| 281 | |
| 282 | async addProcessedFile( |
| 283 | pathname: string, |
| 284 | content: Uint8Array, |
| 285 | hash: string | null, |
| 286 | ) { |
| 287 | this.#processedFiles.set(pathname, hash); |
| 288 | |
| 289 | const outDir = pathname === "/metafile.json" |
| 290 | ? this.#config.outDir |
| 291 | : path.join(this.#config.outDir, "static"); |
| 292 | const filePath = path.join(outDir, pathname); |
| 293 | assertInDir(filePath, outDir); |
| 294 | |
| 295 | await fsAdapter.mkdirp(path.dirname(filePath)); |
| 296 | await Deno.writeFile(filePath, content); |
| 297 | } |
nothing calls this directly
no outgoing calls
no test coverage detected