@powerlines/core 0.48.49 → 0.48.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/vfs.cjs CHANGED
@@ -95,6 +95,12 @@ function normalizeGlobPatterns(workspaceRoot, patterns) {
95
95
  * This class provides methods to manage virtual files, check their existence, retrieve their content, and manipulate the virtual file system. It allows for efficient file management and retrieval without relying on the actual file system.
96
96
  */
97
97
  var VirtualFileSystem = class VirtualFileSystem {
98
+ /**
99
+ * An unstable storage property that can be used for testing or debugging purposes. This property is not intended for production use and may be removed or changed without warning in future releases.
100
+ *
101
+ * @internal
102
+ */
103
+ static unstable_storage = null;
98
104
  /**
99
105
  * A map of virtual file IDs to their associated metadata.
100
106
  */
@@ -319,11 +325,15 @@ var VirtualFileSystem = class VirtualFileSystem {
319
325
  * @returns A promise that resolves to a new virtual file system instance.
320
326
  */
321
327
  static async create(context) {
322
- context.debug("Starting virtual file system (VFS) initialization processes...");
328
+ context.trace("Starting virtual file system (VFS) initialization processes...");
323
329
  let result;
324
330
  if (!context.config.skipCache && (0, _stryke_fs_exists.existsSync)((0, _stryke_path_join.joinPaths)(context.dataPath, "fs.bin"))) {
325
- const buffer = await (0, _stryke_fs_buffer.readFileBuffer)((0, _stryke_path_join.joinPaths)(context.dataPath, "fs.bin"));
326
- const fs = new _stryke_capnp.Message(buffer, false).getRoot(require_fs.FileSystem);
331
+ if (!VirtualFileSystem.unstable_storage) {
332
+ context.debug("Reading virtual file system (VFS) from local storage");
333
+ const buffer = await (0, _stryke_fs_buffer.readFileBuffer)((0, _stryke_path_join.joinPaths)(context.dataPath, "fs.bin"));
334
+ VirtualFileSystem.unstable_storage = new _stryke_capnp.Message(buffer, false).getRoot(require_fs.FileSystem);
335
+ }
336
+ const fs = VirtualFileSystem.unstable_storage;
327
337
  result = new VirtualFileSystem(context, fs);
328
338
  if (fs._hasStorage() && fs.storage.length > 0) await Promise.all(fs.storage.values().map(async (file) => {
329
339
  if (file.path && file.code) {
@@ -343,7 +353,7 @@ var VirtualFileSystem = class VirtualFileSystem {
343
353
  }
344
354
  }));
345
355
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
346
- result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
356
+ result.#logger.trace("Successfully completed virtual file system (VFS) initialization.");
347
357
  return result;
348
358
  }
349
359
  /**
@@ -353,11 +363,15 @@ var VirtualFileSystem = class VirtualFileSystem {
353
363
  * @returns A new virtual file system instance.
354
364
  */
355
365
  static createSync(context) {
356
- context.debug("Starting virtual file system (VFS) initialization processes...");
366
+ context.trace("Starting virtual file system (VFS) initialization processes...");
357
367
  let result;
358
368
  if (!context.config.skipCache && (0, _stryke_fs_exists.existsSync)((0, _stryke_path_join.joinPaths)(context.dataPath, "fs.bin"))) {
359
- const buffer = (0, _stryke_fs_buffer.readFileBufferSync)((0, _stryke_path_join.joinPaths)(context.dataPath, "fs.bin"));
360
- const fs = new _stryke_capnp.Message(buffer, false).getRoot(require_fs.FileSystem);
369
+ if (!VirtualFileSystem.unstable_storage) {
370
+ context.debug("Reading virtual file system (VFS) from local storage");
371
+ const buffer = (0, _stryke_fs_buffer.readFileBufferSync)((0, _stryke_path_join.joinPaths)(context.dataPath, "fs.bin"));
372
+ VirtualFileSystem.unstable_storage = new _stryke_capnp.Message(buffer, false).getRoot(require_fs.FileSystem);
373
+ }
374
+ const fs = VirtualFileSystem.unstable_storage;
361
375
  result = new VirtualFileSystem(context, fs);
362
376
  if (fs._hasStorage() && fs.storage.length > 0) fs.storage.values().forEach((file) => {
363
377
  if (file.path && file.code) {
@@ -377,7 +391,7 @@ var VirtualFileSystem = class VirtualFileSystem {
377
391
  }
378
392
  });
379
393
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
380
- result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
394
+ result.#logger.trace("Successfully completed virtual file system (VFS) initialization.");
381
395
  return result;
382
396
  }
383
397
  /**
@@ -1,5 +1,6 @@
1
1
  import { ResolveOptions, VirtualFileMetadata, VirtualFileSystemInterface, WriteOptions } from "../types/fs.cjs";
2
2
  import { Context } from "../types/context.cjs";
3
+ import { FileSystem } from "../schemas/fs.cjs";
3
4
  import { AssetGlob } from "@stryke/types/file";
4
5
  import { FlatCache } from "flat-cache";
5
6
 
@@ -12,6 +13,12 @@ import { FlatCache } from "flat-cache";
12
13
  */
13
14
  declare class VirtualFileSystem implements VirtualFileSystemInterface {
14
15
  #private;
16
+ /**
17
+ * An unstable storage property that can be used for testing or debugging purposes. This property is not intended for production use and may be removed or changed without warning in future releases.
18
+ *
19
+ * @internal
20
+ */
21
+ static unstable_storage: FileSystem | null;
15
22
  /**
16
23
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
17
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"vfs.d.cts","names":[],"sources":["../../src/lib/vfs.ts"],"mappings":";;;;;;;;AA4LA;;;;cAAa,iBAAA,YAA6B,0BAAA;EAAA;EAsgBN;;;;;;EAAA,OA1Ed,MAAA,CAAO,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,iBAAA;EAkZnB;;;;;;EAAA,OAxUrB,UAAA,CAAW,OAAA,EAAS,OAAA,GAAU,iBAAA;EAodzC;;;EAAA,IAjZQ,QAAA,IAAY,MAAA,SAAe,mBAAA;EAujB3B;;;EAAA,IA5hBA,GAAA,IAAO,MAAA;EA8hBf;;;EAAA,IAngBQ,KAAA,IAAS,MAAA;EAojBJ;;;EAAA,cAvhBF,aAAA,IAAiB,SAAA;EAukBV;;;;;;EAAA,QAxgBd,WAAA;EA0pB0B;;;;;;EAviBpB,MAAA,CAAO,IAAA,WAAe,OAAA;EA62BhC;;;;;;EAj2BI,UAAA,CAAW,IAAA;EA11BgD;;;;;;;;EAw2B3D,SAAA,CACL,IAAA,UACA,QAAA,uBACA,OAAA,GAAU,cAAA;EArWsB;;;;;;;;EAkY3B,eAAA,C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AS,IAAA;EAsWd;;;;;;;AA+GgC;EAjcrB,KAAA,CACX,IAAA,UACA,IAAA,WACA,OAAA,GAAS,YAAA,GACR,OAAA;;;;;;;;EAuEI,SAAA,CACL,IAAA,UACA,IAAA,WACA,OAAA,GAAS,YAAA;;;;;;EAsCJ,SAAA,CAAU,OAAA;;;;;;EASJ,KAAA,CAAM,IAAA,WAAe,OAAA;;;;;;;EAU3B,WAAA,CAAY,QAAA,WAAmB,mBAAA;;;;;;;;;;EAkB/B,YAAA,CAAa,EAAA;;;;;;;;;;EAsEb,OAAA,CAAQ,EAAA;;;;;;;;;;EAqCR,cAAA,CAAe,EAAA;;;;;;;;;;;;;;;;;EAwBT,OAAA,CACX,EAAA,UACA,QAAA,WACA,OAAA,GAAS,cAAA,GACR,OAAA;;;;;;;;;;;;;;;;;EA+CI,WAAA,CACL,EAAA,UACA,QAAA,WACA,OAAA,GAAS,cAAA;;;;EAmCE,OAAA,IAAO,OAAA;;;;;;;GA4EN,MAAA,CAAO,YAAA,KAAa,OAAA;AAAA"}
@@ -1,5 +1,6 @@
1
1
  import { ResolveOptions, VirtualFileMetadata, VirtualFileSystemInterface, WriteOptions } from "../types/fs.mjs";
2
2
  import { Context } from "../types/context.mjs";
3
+ import { FileSystem } from "../schemas/fs.mjs";
3
4
  import { FlatCache } from "flat-cache";
4
5
  import { AssetGlob } from "@stryke/types/file";
5
6
 
@@ -12,6 +13,12 @@ import { AssetGlob } from "@stryke/types/file";
12
13
  */
13
14
  declare class VirtualFileSystem implements VirtualFileSystemInterface {
14
15
  #private;
16
+ /**
17
+ * An unstable storage property that can be used for testing or debugging purposes. This property is not intended for production use and may be removed or changed without warning in future releases.
18
+ *
19
+ * @internal
20
+ */
21
+ static unstable_storage: FileSystem | null;
15
22
  /**
16
23
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
17
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"vfs.d.mts","names":[],"sources":["../../src/lib/vfs.ts"],"mappings":";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;;;;GA4EN,MAAA,CAAO,YAAA,KAAa,OAAA;AAAA"}
package/dist/lib/vfs.mjs CHANGED
@@ -92,6 +92,12 @@ function normalizeGlobPatterns(workspaceRoot, patterns) {
92
92
  * This class provides methods to manage virtual files, check their existence, retrieve their content, and manipulate the virtual file system. It allows for efficient file management and retrieval without relying on the actual file system.
93
93
  */
94
94
  var VirtualFileSystem = class VirtualFileSystem {
95
+ /**
96
+ * An unstable storage property that can be used for testing or debugging purposes. This property is not intended for production use and may be removed or changed without warning in future releases.
97
+ *
98
+ * @internal
99
+ */
100
+ static unstable_storage = null;
95
101
  /**
96
102
  * A map of virtual file IDs to their associated metadata.
97
103
  */
@@ -316,11 +322,15 @@ var VirtualFileSystem = class VirtualFileSystem {
316
322
  * @returns A promise that resolves to a new virtual file system instance.
317
323
  */
318
324
  static async create(context) {
319
- context.debug("Starting virtual file system (VFS) initialization processes...");
325
+ context.trace("Starting virtual file system (VFS) initialization processes...");
320
326
  let result;
321
327
  if (!context.config.skipCache && existsSync(joinPaths(context.dataPath, "fs.bin"))) {
322
- const buffer = await readFileBuffer(joinPaths(context.dataPath, "fs.bin"));
323
- const fs = new capnp.Message(buffer, false).getRoot(FileSystem);
328
+ if (!VirtualFileSystem.unstable_storage) {
329
+ context.debug("Reading virtual file system (VFS) from local storage");
330
+ const buffer = await readFileBuffer(joinPaths(context.dataPath, "fs.bin"));
331
+ VirtualFileSystem.unstable_storage = new capnp.Message(buffer, false).getRoot(FileSystem);
332
+ }
333
+ const fs = VirtualFileSystem.unstable_storage;
324
334
  result = new VirtualFileSystem(context, fs);
325
335
  if (fs._hasStorage() && fs.storage.length > 0) await Promise.all(fs.storage.values().map(async (file) => {
326
336
  if (file.path && file.code) {
@@ -340,7 +350,7 @@ var VirtualFileSystem = class VirtualFileSystem {
340
350
  }
341
351
  }));
342
352
  } else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
343
- result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
353
+ result.#logger.trace("Successfully completed virtual file system (VFS) initialization.");
344
354
  return result;
345
355
  }
346
356
  /**
@@ -350,11 +360,15 @@ var VirtualFileSystem = class VirtualFileSystem {
350
360
  * @returns A new virtual file system instance.
351
361
  */
352
362
  static createSync(context) {
353
- context.debug("Starting virtual file system (VFS) initialization processes...");
363
+ context.trace("Starting virtual file system (VFS) initialization processes...");
354
364
  let result;
355
365
  if (!context.config.skipCache && existsSync(joinPaths(context.dataPath, "fs.bin"))) {
356
- const buffer = readFileBufferSync(joinPaths(context.dataPath, "fs.bin"));
357
- const fs = new capnp.Message(buffer, false).getRoot(FileSystem);
366
+ if (!VirtualFileSystem.unstable_storage) {
367
+ context.debug("Reading virtual file system (VFS) from local storage");
368
+ const buffer = readFileBufferSync(joinPaths(context.dataPath, "fs.bin"));
369
+ VirtualFileSystem.unstable_storage = new capnp.Message(buffer, false).getRoot(FileSystem);
370
+ }
371
+ const fs = VirtualFileSystem.unstable_storage;
358
372
  result = new VirtualFileSystem(context, fs);
359
373
  if (fs._hasStorage() && fs.storage.length > 0) fs.storage.values().forEach((file) => {
360
374
  if (file.path && file.code) {
@@ -374,7 +388,7 @@ var VirtualFileSystem = class VirtualFileSystem {
374
388
  }
375
389
  });
376
390
  } else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
377
- result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
391
+ result.#logger.trace("Successfully completed virtual file system (VFS) initialization.");
378
392
  return result;
379
393
  }
380
394
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"vfs.mjs","names":["#context","#normalizePath","#storage","#normalizeId","#getStorage","#logger","#metadata","#ids","#paths","#resolverCache","#getStorages","#innerResolve","#innerResolveSync","#isDisposed"],"sources":["../../src/lib/vfs.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport * as capnp from \"@stryke/capnp\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport {\n readFileBuffer,\n readFileBufferSync,\n writeFileBuffer\n} from \"@stryke/fs/buffer\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport {\n getResolutionCombinations,\n resolve,\n resolveSync\n} from \"@stryke/fs/resolve\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { correctPath, stripStars } from \"@stryke/path/correct-path\";\nimport {\n findFileExtensionSafe,\n findFileName,\n findFilePath,\n hasFileExtension\n} from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { slash } from \"@stryke/path/slash\";\nimport { prettyBytes } from \"@stryke/string-format/pretty-bytes\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { AssetGlob } from \"@stryke/types/file\";\nimport { match } from \"bundle-require\";\nimport { create, FlatCache } from \"flat-cache\";\nimport { Blob } from \"node:buffer\";\nimport { PathOrFileDescriptor } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { FileId, FileMetadata, FileSystem } from \"../../schemas/fs\";\nimport { DEFAULT_EXTENSIONS } from \"../constants/extensions\";\nimport { replacePathTokens } from \"../plugin-utils\";\nimport { FileSystemStorageAdapter } from \"../storage/file-system\";\nimport { VirtualStorageAdapter } from \"../storage/virtual\";\nimport { Context } from \"../types/context\";\nimport {\n ResolveOptions,\n StorageAdapter,\n StoragePort,\n StoragePreset,\n VirtualFileMetadata,\n VirtualFileSystemInterface,\n WriteOptions\n} from \"../types/fs\";\nimport { Logger } from \"../types/logging\";\nimport { format } from \"./utilities/format\";\n\ninterface StorageAdapterState {\n adapter: StorageAdapter;\n relativeKey: string;\n base: string;\n}\n\nfunction toFilePath(path: PathOrFileDescriptor): string {\n return correctPath(slash(path?.toString() || \".\").replace(/^file:\\/\\//, \"\"));\n}\n\n/**\n * Checks if a given file id is valid based on the specified prefix.\n *\n * @param id - The file ID to check.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns `true` if the file ID is valid, otherwise `false`.\n */\nfunction isValidId(id: string, prefix = \"powerlines\"): boolean {\n return id.replace(/^\\\\0/, \"\").startsWith(`${prefix.replace(/:$/, \"\")}`);\n}\n\n/**\n * Formats a file id by removing the file extension and prepended runtime prefix.\n *\n * @param id - The file ID to format.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns The formatted file ID.\n */\nfunction normalizeId(id: string, prefix = \"powerlines\"): string {\n // return `${prefix.replace(/:$/, \"\")}:${toFilePath(id)\n // .replace(new RegExp(`^${prefix.replace(/:$/, \"\")}:`), \"\")\n // .replace(/^\\\\0/, \"\")\n // .replace(findFileDotExtensionSafe(toFilePath(id)), \"\")}`;\n\n return replaceExtension(toFilePath(id))\n .replace(/^\\\\0/, \"\")\n .replace(/^powerlines:/, \"\")\n .replace(new RegExp(`^${prefix.replace(/:$/, \"\")}:`), \"\");\n}\n\n/**\n * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.\n *\n * @param path - The path to normalize.\n * @param builtinsPath - The path to built-in files.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns The normalized path.\n */\nfunction normalizePath(\n path: string,\n builtinsPath: string,\n prefix = \"powerlines\"\n): string {\n if (!isSetString(path)) {\n if (!isString(path)) {\n throw new Error(\"Path type must be a string or a file descriptor\");\n }\n throw new Error(\"Path cannot be empty\");\n }\n\n return isAbsolutePath(path)\n ? path\n : isValidId(toFilePath(path), prefix)\n ? normalizeId(toFilePath(path), prefix).replace(\n new RegExp(`^${prefix.replace(/:$/, \"\")}:`),\n builtinsPath\n )\n : toFilePath(path);\n}\n\n/**\n * Normalizes glob patterns by resolving them against the workspace root.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param patterns - The glob patterns to normalize.\n * @returns An array of normalized glob patterns.\n */\nfunction normalizeGlobPatterns(\n workspaceRoot: string,\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n): string[] {\n return getUnique(\n toArray(patterns)\n .map(pattern => {\n if (\n isSetObject(pattern) &&\n (isSetString(pattern.input) || isSetString(pattern.glob))\n ) {\n return joinPaths(\n pattern.input || workspaceRoot,\n pattern.glob || \"**/*\"\n );\n } else if (!isSetString(pattern)) {\n return undefined;\n }\n\n return pattern;\n })\n .filter(isSetString)\n );\n}\n\n/**\n * Represents a virtual file system (VFS) that stores files and their associated metadata in virtual memory.\n *\n * @remarks\n * This class provides methods to manage virtual files, check their existence, retrieve their content, and manipulate the virtual file system. It allows for efficient file management and retrieval without relying on the actual file system.\n */\nexport class VirtualFileSystem implements VirtualFileSystemInterface {\n /**\n * A map of virtual file IDs to their associated metadata.\n */\n #metadata: Record<string, VirtualFileMetadata>;\n\n /**\n * A map of underlying file paths to their virtual file IDs.\n */\n #ids: Record<string, string>;\n\n /**\n * A map of virtual file IDs to their underlying file paths.\n */\n #paths: Record<string, string>;\n\n /**\n * The unified volume that combines the virtual file system with the real file system.\n *\n * @remarks\n * This volume allows for seamless access to both virtual and real files.\n */\n #storage: StoragePort;\n\n // /**\n // * The resolver factory used during module resolution within the virtual file system.\n // *\n // * @see https://github.com/oxc-project/oxc-resolver\n // */\n // #resolver!: ResolverFactory;\n\n /**\n * A cache for module resolution results.\n */\n #resolverCache!: FlatCache;\n\n /**\n * Indicator specifying if the virtual file system (VFS) is disposed\n */\n #isDisposed = false;\n\n /**\n * The context of the virtual file system.\n */\n #context: Context;\n\n /**\n * The file system's logger client utility.\n */\n #logger: Logger;\n\n /**\n * Normalizes a given module id by resolving it against the built-ins path.\n *\n * @param id - The module id to normalize.\n * @returns The normalized module id.\n */\n #normalizeId(id: string): string {\n let normalized = id;\n if (isParentPath(normalized, this.#context.builtinsPath)) {\n normalized = replacePath(normalized, this.#context.builtinsPath);\n }\n\n return normalizeId(\n normalized,\n this.#context.config.framework?.name ?? \"powerlines\"\n );\n }\n\n /**\n * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.\n *\n * @param path - The path to normalize.\n * @returns The normalized path.\n */\n #normalizePath(path: string): string {\n if (!isSetString(path)) {\n if (!isString(path)) {\n throw new Error(\"Path type must be a string or a file descriptor\");\n }\n throw new Error(\"Path cannot be empty\");\n }\n\n return normalizePath(\n path.includes(\"{\") || path.includes(\"}\")\n ? replacePathTokens(this.#context, path)\n : path,\n this.#context.builtinsPath,\n this.#context.config.framework?.name ?? \"powerlines\"\n );\n }\n\n /**\n * Gets the storage adapter and relative key for a given key.\n *\n * @remarks\n * The `key` can be either a path or a storage adapter name.\n *\n * @param key - The key to get the storage adapter for.\n * @returns The storage adapter and relative key for the given key.\n */\n #getStorage(key: string, preset?: StoragePreset): StorageAdapterState {\n const path = this.resolveSync(this.#normalizePath(key)) || key;\n for (const base of Object.keys(this.#storage)\n .filter(Boolean)\n .sort()\n .reverse()) {\n if (\n (path === base || isParentPath(path, base)) &&\n (!preset ||\n this.#storage[base]?.preset?.toLowerCase() === preset.toLowerCase())\n ) {\n return {\n base,\n relativeKey: replacePath(path, base),\n adapter: this.#storage[base]!\n };\n }\n }\n\n if (\n !preset ||\n this.#storage[\"\"]?.preset?.toLowerCase() === preset.toLowerCase()\n ) {\n return {\n base: \"\",\n relativeKey: path,\n adapter: this.#storage[\"\"]!\n };\n }\n\n this.#storage[path] =\n preset === \"virtual\"\n ? new VirtualStorageAdapter(this.#context, {\n base: path\n })\n : new FileSystemStorageAdapter(this.#context, {\n base: path\n });\n\n return {\n base: path,\n relativeKey: \"\",\n adapter: this.#storage[path]\n };\n }\n\n /**\n * Gets all storage adapters that match a given base key.\n *\n * @param base - The base key to match storage adapters against.\n * @param includeParent - Whether to include parent storage adapters.\n * @returns An array of storage adapters that match the given base key.\n */\n #getStorages(base = \"\", includeParent = false) {\n const baseKey = this.resolveSync(base) || base;\n\n return Object.keys(this.#storage)\n .sort()\n .reverse()\n .filter(\n key =>\n isParentPath(key, baseKey) ||\n (includeParent && isParentPath(baseKey, key)) ||\n (baseKey.includes(\"*\") &&\n (isParentPath(stripStars(baseKey), key) ||\n globToRegex(replaceExtension(baseKey)).test(key)))\n )\n .map(key => ({\n relativeBase:\n baseKey.length > key.length ? baseKey.slice(key.length) : undefined,\n base: key,\n adapter: this.#storage[key]!\n }));\n }\n\n /**\n * A helper function to resolve modules in the virtual file system (VFS).\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolvePath(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n #innerResolve = async (\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<string | undefined> => {\n let path = id;\n if (path.includes(\"{\") || path.includes(\"}\")) {\n path = replacePathTokens(this.#context, path);\n }\n\n if (options.skipAlias !== true) {\n path = this.resolveAlias(path);\n }\n\n if (\n isAbsolutePath(path) &&\n (!options.isFile || !(await this.isDirectory(path)))\n ) {\n return path;\n }\n\n const resolverCacheKey = murmurhash({\n path: this.#normalizeId(path),\n importer,\n options\n });\n\n let result!: string | undefined;\n if (!this.#context.config.skipCache) {\n result = this.resolverCache.get<string | undefined>(resolverCacheKey);\n if (result) {\n return result;\n }\n }\n\n result = this.paths[this.#normalizeId(path)];\n if (!isSetString(result)) {\n const paths = options.paths ?? [];\n if (importer && !paths.includes(importer)) {\n paths.push(importer);\n }\n\n if (!importer) {\n paths.push(this.#context.config.cwd);\n paths.push(\n appendPath(this.#context.config.root, this.#context.config.cwd)\n );\n paths.push(\n appendPath(\n joinPaths(this.#context.config.root, \"src\"),\n this.#context.config.cwd\n )\n );\n }\n\n paths.push(\n ...(\n Object.keys(this.#context.tsconfig?.options?.paths ?? {})\n .filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replace(/\\*$/, \"\"))\n )\n .map(\n tsconfigPath =>\n this.#context.tsconfig?.options?.paths?.[tsconfigPath]\n )\n .flat()\n .filter(Boolean) as string[]\n ).map(tsconfigPath =>\n appendPath(tsconfigPath, this.#context.config.cwd)\n )\n );\n\n for (const combination of getResolutionCombinations(path, {\n paths: getUnique(paths)\n })) {\n const { relativeKey, adapter } = this.#getStorage(combination);\n if (await adapter.exists(relativeKey)) {\n result = combination;\n break;\n }\n }\n\n if (!isSetString(result)) {\n try {\n result = await resolve(path, { ...options, paths });\n } catch {\n // Do nothing\n }\n\n // if (!result) {\n // let index = 0;\n // do {\n // const resolveResult = await this.resolver.async(\n // (paths.length > index ? paths[index] : undefined) ||\n // this.#context.config.root,\n // path\n // );\n // if (resolveResult.path) {\n // result = resolveResult.path;\n // }\n\n // index++;\n // } while (!result && index < paths.length);\n // }\n }\n }\n\n if (isSetString(result)) {\n if (!this.#context.config.skipCache) {\n this.resolverCache.set(this.#normalizeId(path), result);\n }\n\n return result;\n }\n\n return undefined;\n };\n\n /**\n * A synchronous helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = context.resolveSync(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns The resolved module path.\n */\n #innerResolveSync = (\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): string | undefined => {\n let path = id;\n if (path.includes(\"{\") || path.includes(\"}\")) {\n path = replacePathTokens(this.#context, path);\n }\n\n if (options.skipAlias !== true) {\n path = this.resolveAlias(path);\n }\n\n if (\n isAbsolutePath(path) &&\n (!options.isFile || !this.isDirectorySync(path))\n ) {\n return path;\n }\n\n let result!: string | undefined;\n if (!this.#context.config.skipCache) {\n result = this.resolverCache.get<string | undefined>(\n this.#normalizeId(path)\n );\n if (isSetString(result)) {\n return result;\n }\n }\n\n result = this.paths[this.#normalizeId(path)];\n if (!isSetString(result)) {\n const paths = options.paths ?? [];\n if (importer && !paths.includes(importer)) {\n paths.push(importer);\n }\n\n if (!importer) {\n paths.push(this.#context.config.cwd);\n paths.push(\n appendPath(this.#context.config.root, this.#context.config.cwd)\n );\n paths.push(\n appendPath(\n joinPaths(this.#context.config.root, \"src\"),\n this.#context.config.cwd\n )\n );\n }\n\n paths.push(\n ...(\n Object.keys(this.#context.tsconfig?.options?.paths ?? {})\n .filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replace(/\\*$/, \"\"))\n )\n .map(\n tsconfigPath =>\n this.#context.tsconfig?.options?.paths?.[tsconfigPath]\n )\n .flat()\n .filter(Boolean) as string[]\n ).map(tsconfigPath =>\n appendPath(tsconfigPath, this.#context.config.cwd)\n )\n );\n\n for (const combination of getResolutionCombinations(path, { paths })) {\n const { relativeKey, adapter } = this.#getStorage(combination);\n if (adapter.existsSync(relativeKey)) {\n result = combination;\n break;\n }\n }\n\n if (!isSetString(result)) {\n try {\n result = resolveSync(path, { ...options, paths });\n } catch {\n // Do nothing\n }\n\n // if (!result) {\n // let index = 0;\n // do {\n // const resolveResult = this.resolver.sync(\n // (paths.length > index ? paths[index] : undefined) ||\n // this.#context.config.root,\n // path\n // );\n // if (resolveResult.path) {\n // result = resolveResult.path;\n // }\n\n // index++;\n // } while (!result && index < paths.length);\n // }\n }\n }\n\n if (isSetString(result)) {\n if (!this.#context.config.skipCache) {\n this.resolverCache.set(this.#normalizeId(path), result);\n }\n\n return result;\n }\n\n return undefined;\n };\n\n /**\n * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @returns A promise that resolves to a new virtual file system instance.\n */\n public static async create(context: Context): Promise<VirtualFileSystem> {\n context.debug(\n \"Starting virtual file system (VFS) initialization processes...\"\n );\n\n let result!: VirtualFileSystem;\n if (\n !context.config.skipCache &&\n existsSync(joinPaths(context.dataPath, \"fs.bin\"))\n ) {\n const buffer = await readFileBuffer(\n joinPaths(context.dataPath, \"fs.bin\")\n );\n\n const message = new capnp.Message(buffer, false);\n const fs = message.getRoot(FileSystem);\n\n result = new VirtualFileSystem(context, fs);\n\n if (fs._hasStorage() && fs.storage.length > 0) {\n await Promise.all(\n fs.storage.values().map(async file => {\n if (file.path && file.code) {\n let id: FileId | undefined;\n if (fs._hasIds()) {\n id = fs.ids.find((fileId: FileId) => fileId.path === file.path);\n }\n\n let metadata: FileMetadata | undefined;\n if (fs._hasMetadata()) {\n metadata = fs.metadata.find(\n (meta: FileMetadata) =>\n meta.id === result.#normalizeId(id?.id ?? file.path)\n );\n }\n\n await result.write(file.path, file.code, {\n meta: {\n id: result.#normalizeId(id?.id ?? metadata?.id ?? file.path),\n type: metadata?.type || \"normal\",\n properties: metadata?._hasProperties()\n ? metadata?.properties.values().reduce(\n (ret, kvp) => {\n ret[kvp.key] = kvp.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : undefined,\n timestamp: metadata?.timestamp\n }\n });\n }\n })\n );\n }\n } else {\n const message = new capnp.Message();\n result = new VirtualFileSystem(context, message.initRoot(FileSystem));\n }\n\n result.#logger.debug(\n \"Successfully completed virtual file system (VFS) initialization.\"\n );\n\n return result;\n }\n\n /**\n * Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @returns A new virtual file system instance.\n */\n public static createSync(context: Context): VirtualFileSystem {\n context.debug(\n \"Starting virtual file system (VFS) initialization processes...\"\n );\n\n let result!: VirtualFileSystem;\n if (\n !context.config.skipCache &&\n existsSync(joinPaths(context.dataPath, \"fs.bin\"))\n ) {\n const buffer = readFileBufferSync(joinPaths(context.dataPath, \"fs.bin\"));\n\n const message = new capnp.Message(buffer, false);\n const fs = message.getRoot(FileSystem);\n\n result = new VirtualFileSystem(context, fs);\n\n if (fs._hasStorage() && fs.storage.length > 0) {\n fs.storage.values().forEach(file => {\n if (file.path && file.code) {\n let id: FileId | undefined;\n if (fs._hasIds()) {\n id = fs.ids.find((fileId: FileId) => fileId.path === file.path);\n }\n\n let metadata: FileMetadata | undefined;\n if (fs._hasMetadata()) {\n metadata = fs.metadata.find(\n (meta: FileMetadata) =>\n meta.id === result.#normalizeId(id?.id ?? file.path)\n );\n }\n\n result.writeSync(file.path, file.code, {\n meta: {\n id: result.#normalizeId(id?.id ?? metadata?.id ?? file.path),\n type: metadata?.type,\n properties: metadata?._hasProperties()\n ? metadata?.properties.values().reduce(\n (ret, kvp) => {\n ret[kvp.key] = kvp.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : undefined,\n timestamp: metadata?.timestamp\n }\n });\n }\n });\n }\n } else {\n const message = new capnp.Message();\n result = new VirtualFileSystem(context, message.initRoot(FileSystem));\n }\n\n result.#logger.debug(\n \"Successfully completed virtual file system (VFS) initialization.\"\n );\n\n return result;\n }\n\n /**\n * A map of file ids to their metadata.\n */\n public get metadata(): Record<string, VirtualFileMetadata> {\n return new Proxy(this.#metadata, {\n get: (target, prop: string) => {\n return target[this.#normalizeId(prop)];\n },\n set: (target, prop: string, value) => {\n target[this.#normalizeId(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizeId(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizeId(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizeId(key as string))\n );\n }\n });\n }\n\n /**\n * A map of file paths to their module ids.\n */\n public get ids(): Record<string, string> {\n return new Proxy(this.#ids, {\n get: (target, prop: string) => {\n return target[this.#normalizePath(prop)];\n },\n set: (target, prop: string, value) => {\n target[this.#normalizePath(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizePath(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizePath(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizePath(key as string))\n );\n }\n });\n }\n\n /**\n * A map of module ids to their file paths.\n */\n public get paths(): Record<string, string> {\n return new Proxy(this.#paths, {\n get: (target, prop: string) => {\n return this.#normalizeId(prop) in target\n ? target[this.#normalizeId(prop)]\n : undefined;\n },\n set: (target, prop: string, value) => {\n target[this.#normalizeId(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizeId(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizeId(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizeId(key as string))\n );\n }\n });\n }\n\n /**\n * Gets the resolver cache.\n */\n protected get resolverCache(): FlatCache {\n if (!this.#resolverCache) {\n this.#resolverCache = create({\n cacheId: \"module-resolution\",\n cacheDir: this.#context.cachePath,\n ttl: 2.5 * 60 * 1000,\n lruSize: 8000,\n persistInterval: 100\n });\n }\n\n return this.#resolverCache;\n }\n\n // /**\n // * The resolver factory used during module resolution within the virtual file system.\n // *\n // * @remarks\n // * This resolver is configured with the workspace root, project root, TypeScript configuration, alias mappings, and other resolution options specified in the context. It is lazily initialized on first access to optimize performance.\n // *\n // * @see https://github.com/oxc-project/oxc-resolver\n // */\n // protected get resolver(): ResolverFactory {\n // if (!this.#resolver) {\n // this.#resolver = new ResolverFactory({\n // roots: [\n // this.#context.config.cwd,\n // appendPath(\n // this.#context.config.root,\n // this.#context.config.cwd\n // )\n // ],\n // tsconfig: {\n // configFile: this.#context.tsconfig.tsconfigFilePath,\n // references:\n // this.#context.tsconfig.projectReferences &&\n // this.#context.tsconfig.projectReferences.length > 0\n // ? \"auto\"\n // : undefined\n // },\n // alias: Object.fromEntries(\n // Object.entries(this.#context.alias).map(([key, value]) => [\n // key,\n // [value]\n // ])\n // ),\n // extensions: this.#context.config.resolve.extensions,\n // mainFields: this.#context.config.resolve.mainFields,\n // conditionNames: this.#context.config.resolve.conditions,\n // symlinks: this.#context.config.resolve.preserveSymlinks,\n // allowPackageExportsInDirectoryResolve: true\n // });\n // }\n\n // return this.#resolver;\n // }\n\n /**\n * Creates a new instance of the {@link VirtualFileSystem}.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @param fs - A buffer containing the serialized virtual file system data.\n */\n private constructor(context: Context, fs: FileSystem) {\n this.#context = context;\n this.#storage = { \"\": new FileSystemStorageAdapter(context) };\n\n if (isSetObject(this.#context.config.output.storage)) {\n this.#storage = {\n ...this.#storage,\n ...this.#context.config.output.storage\n };\n }\n\n this.#storage.virtual ??= new VirtualStorageAdapter(context, {\n base: \"/_virtual\"\n });\n\n this.#storage[this.#context.config.output.path] ??=\n new FileSystemStorageAdapter(context, {\n base: this.#context.config.output.path\n });\n\n if (\n this.#context.config.output.copy &&\n this.#context.config.output.copy.path\n ) {\n this.#storage[this.#context.config.output.copy.path] ??=\n new FileSystemStorageAdapter(context, {\n base: this.#context.config.output.copy.path\n });\n }\n\n if (this.#context.config.output.storage !== \"fs\") {\n this.#storage[this.#context.artifactsPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.artifactsPath\n }\n );\n this.#storage[this.#context.builtinsPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.builtinsPath\n }\n );\n this.#storage[this.#context.entryPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.entryPath\n }\n );\n }\n\n this.#metadata = {};\n if (fs._hasMetadata()) {\n this.#metadata = fs.metadata.values().reduce(\n (ret, metadata) => {\n ret[metadata.id] = {\n id: metadata.id,\n type: metadata.type,\n timestamp: metadata.timestamp ?? Date.now(),\n properties: metadata._hasProperties()\n ? metadata.properties.values().reduce(\n (ret, item) => {\n ret[item.key] = item.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : {}\n };\n\n return ret;\n },\n {} as Record<\n string,\n {\n id: string;\n type: string;\n timestamp: number;\n properties: Record<string, string>;\n }\n >\n );\n }\n\n this.#ids = {};\n this.#paths = {};\n\n if (fs._hasIds()) {\n this.#ids = fs.ids.values().reduce(\n (ret, identifier) => {\n ret[identifier.path] ??= identifier.id;\n\n return ret;\n },\n {} as Record<string, string>\n );\n\n this.#paths = fs.ids.values().reduce(\n (ret, identifier) => {\n ret[identifier.id] ??= identifier.path;\n return ret;\n },\n {} as Record<string, string>\n );\n }\n\n this.#logger = context.extendLogger({ category: \"fs\" });\n }\n\n /**\n * Asynchronously checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @returns A promise that resolves to `true` if the file exists, otherwise `false`.\n */\n public async exists(path: string): Promise<boolean> {\n const { relativeKey, adapter } = this.#getStorage(path);\n\n return adapter.exists(relativeKey);\n }\n\n /**\n * Synchronously checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @returns `true` if the file exists, otherwise `false`.\n */\n public existsSync(path: string): boolean {\n const { relativeKey, adapter } = this.#getStorage(path);\n\n return adapter.existsSync(relativeKey);\n }\n\n /**\n * Checks if a file is virtual in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the file is virtual, otherwise `false`.\n */\n public isVirtual(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return (\n this.#getStorage(resolved)?.adapter?.preset === \"virtual\" ||\n resolved.startsWith(\n `${this.#context.config.framework?.name ?? \"powerlines\"}:`\n ) ||\n path.startsWith(\n `${this.#context.config.framework?.name ?? \"powerlines\"}:`\n )\n );\n }\n\n /**\n * Checks if a path is a directory in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a directory, otherwise `false`.\n */\n public isDirectorySync(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return !!(\n this.existsSync(resolved) &&\n this.#getStorage(resolved)?.adapter?.isDirectorySync(resolved)\n );\n }\n\n /**\n * Checks if a path is a directory in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a directory, otherwise `false`.\n */\n public async isDirectory(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): Promise<boolean> {\n const resolved = await this.resolve(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return !!(\n (await this.exists(resolved)) &&\n (await this.#getStorage(resolved)?.adapter?.isDirectory(resolved))\n );\n }\n\n /**\n * Checks if a path is a file in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a file, otherwise `false`.\n */\n public isFileSync(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return this.#getStorage(resolved)?.adapter?.isFileSync(resolved) ?? false;\n }\n\n /**\n * Checks if a path is a file in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a file, otherwise `false`.\n */\n public async isFile(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): Promise<boolean> {\n const resolved = await this.resolve(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return (\n (await this.#getStorage(resolved)?.adapter?.isFile(resolved)) ?? false\n );\n }\n\n /**\n * Checks if a file Id must be resolved by the virtual file system (VFS).\n *\n * @remarks\n * Examples of file Ids that would be considered virtual include:\n * - Ids that start with the framework specific prefix (e.g. `powerlines:`)\n * - Ids that match a configured alias for virtual modules (returned true from {@link VirtualFileSystemInterface.isVirtual})\n *\n * @param path - The path or id of the file.\n * @param importer - An optional path to the importer module, used for resolving the file path.\n * @param options - Additional options for resolving the file path.\n * @returns `true` if the file is virtual, otherwise `false`.\n */\n public isResolvableId(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n return (\n path.startsWith(\n `${this.#context.config.framework?.name ?? \"powerlines\"}:`\n ) ||\n this.isVirtual(path, importer, options) ||\n this.isAlias(path) ||\n this.isTsconfigPath(path)\n );\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n public listSync(path: string): string[] {\n let resolvedPath = path;\n if (resolvedPath.includes(\"*\")) {\n this.#logger.warn(\n `Invoking \"listSync\" with a glob pattern is not supported. It is likely you meant to use \"globSync\". Path: ${path}`\n );\n resolvedPath = stripStars(resolvedPath);\n }\n\n return getUnique(\n this.#getStorages(resolvedPath, true)\n .map(storage =>\n storage.adapter.listSync(\n storage.relativeBase\n ? storage.base\n ? appendPath(storage.relativeBase, storage.base)\n : storage.relativeBase\n : storage.base\n )\n )\n .flat()\n .filter(Boolean)\n );\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n public async list(path: string): Promise<string[]> {\n let resolvedPath = path;\n if (resolvedPath.includes(\"*\")) {\n this.#logger.warn(\n `Invoking \"list\" with a glob pattern is not supported. It is likely you meant to use \"glob\". Path: ${path}`\n );\n resolvedPath = stripStars(resolvedPath);\n }\n\n return getUnique(\n (\n await Promise.all(\n this.#getStorages(resolvedPath, true).map(async storage =>\n storage.adapter.list(\n storage.relativeBase\n ? storage.base\n ? appendPath(storage.relativeBase, storage.base)\n : storage.relativeBase\n : storage.base\n )\n )\n )\n )\n .flat()\n .filter(Boolean)\n );\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public async remove(path: string): Promise<void> {\n const normalizedPath = this.#normalizePath(path);\n this.#logger.trace(`Removing file: ${normalizedPath}`);\n\n const { relativeKey, adapter } = this.#getStorage(normalizedPath);\n\n if (hasFileExtension(normalizedPath)) {\n await adapter.remove(relativeKey);\n } else {\n await adapter.clear(relativeKey);\n }\n\n const id = this.#ids[normalizedPath];\n if (id && this.#metadata[id]) {\n delete this.#metadata[id];\n delete this.#ids[normalizedPath];\n delete this.#paths[id];\n }\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public removeSync(path: string) {\n const normalizedPath = this.#normalizePath(path);\n this.#logger.trace(`Removing file: ${normalizedPath}`);\n\n const { relativeKey, adapter } = this.#getStorage(normalizedPath);\n\n if (hasFileExtension(normalizedPath)) {\n adapter.removeSync(relativeKey);\n } else {\n adapter.clearSync(relativeKey);\n }\n\n const id = this.#ids[normalizedPath];\n if (id && this.#metadata[id]) {\n delete this.#metadata[id];\n delete this.#ids[normalizedPath];\n delete this.#paths[id];\n }\n }\n\n /**\n * Glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n public async glob(\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ): Promise<string[]> {\n const results: string[] = [];\n for (const pattern of normalizeGlobPatterns(\n this.#context.config.cwd,\n patterns\n )) {\n const normalized = this.#normalizePath(pattern);\n if (!/[*?[\\]{}]/.test(normalized) && !normalized.includes(\"*\")) {\n if (this.isDirectorySync(normalized)) {\n results.push(...(await this.list(normalized)));\n } else {\n const resolved = await this.resolve(normalized);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n } else {\n const absPattern = isAbsolutePath(normalized)\n ? normalized\n : this.#normalizePath(\n appendPath(normalized, this.#context.config.cwd)\n );\n\n await Promise.all(\n (await this.list(stripStars(absPattern))).map(async file => {\n if (globToRegex(absPattern).test(file)) {\n const resolved = await this.resolve(file);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n })\n );\n }\n }\n\n return results;\n }\n\n /**\n * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n public globSync(\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ): string[] {\n const results: string[] = [];\n for (const pattern of normalizeGlobPatterns(\n this.#context.config.cwd,\n patterns\n )) {\n const normalized = this.#normalizePath(pattern);\n if (!/[*?[\\]{}]/.test(normalized) && !normalized.includes(\"*\")) {\n if (this.isDirectorySync(normalized)) {\n results.push(...this.listSync(normalized));\n } else {\n const resolved = this.resolveSync(normalized);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n } else {\n const absPattern = isAbsolutePath(normalized)\n ? normalized\n : this.#normalizePath(\n appendPath(normalized, this.#context.config.cwd)\n );\n\n const files = this.listSync(stripStars(absPattern));\n for (const file of files) {\n const regex = globToRegex(absPattern);\n if (regex.test(file)) {\n const resolved = this.resolveSync(file);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n }\n }\n }\n\n return results;\n }\n\n /**\n * Copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n public async copy(\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) {\n const src = srcPath instanceof URL ? fileURLToPath(srcPath) : srcPath;\n const dest = destPath instanceof URL ? fileURLToPath(destPath) : destPath;\n\n if (\n (!isSetString(src) && (!isSetObject(src) || !isSetString(src.input))) ||\n !isSetString(dest)\n ) {\n return;\n }\n\n const sourceStr = isString(src)\n ? src\n : src.input\n ? src.input\n : this.#context.config.cwd;\n const source = await this.resolve(sourceStr);\n if (!source) {\n return;\n }\n\n if (\n this.isDirectorySync(source) ||\n (isSetString(src) && src.includes(\"*\")) ||\n (isSetObject(src) && isSetString(src.glob))\n ) {\n await Promise.all(\n (await this.glob(src)).map(async file => {\n return this.copy(\n file,\n appendPath(replacePath(file, sourceStr), dest)\n );\n })\n );\n } else {\n const content = await this.read(source);\n if (content !== undefined) {\n await this.write(this.#normalizePath(dest), content, {\n skipFormat: true\n });\n }\n }\n }\n\n /**\n * Synchronously copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n public copySync(\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) {\n const src = srcPath instanceof URL ? fileURLToPath(srcPath) : srcPath;\n const dest = destPath instanceof URL ? fileURLToPath(destPath) : destPath;\n\n if (\n (!isSetString(src) && (!isSetObject(src) || !isSetString(src.input))) ||\n !isSetString(dest)\n ) {\n return;\n }\n\n const sourceStr = isString(src)\n ? src\n : src.input\n ? src.input\n : this.#context.config.cwd;\n const source = this.resolveSync(sourceStr);\n if (!source) {\n return;\n }\n\n if (\n this.isDirectorySync(source) ||\n (isSetString(src) && src.includes(\"*\")) ||\n (isSetObject(src) && isSetString(src.glob))\n ) {\n this.globSync(src).map(file => {\n return this.copySync(\n file,\n appendPath(findFilePath(replacePath(file, sourceStr)), dest)\n );\n });\n } else {\n const content = this.readSync(source);\n if (content !== undefined) {\n this.writeSync(\n this.#normalizePath(\n hasFileExtension(dest)\n ? dest\n : appendPath(findFileName(source), dest)\n ),\n content,\n { skipFormat: true }\n );\n }\n }\n }\n\n /**\n * Moves a file (or files) from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n public async move(srcPath: string, destPath: string) {\n if (hasFileExtension(srcPath)) {\n await this.copy(srcPath, destPath);\n await this.remove(srcPath);\n } else {\n await Promise.all(\n (await this.list(srcPath)).map(async file => {\n await this.copy(file, destPath);\n await this.remove(file);\n })\n );\n }\n }\n\n /**\n * Synchronously moves a file (or files) from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n public moveSync(srcPath: string, destPath: string) {\n if (hasFileExtension(srcPath)) {\n this.copySync(srcPath, destPath);\n this.removeSync(srcPath);\n } else {\n this.listSync(srcPath).forEach(file => {\n this.copySync(file, destPath);\n this.removeSync(file);\n });\n }\n }\n\n /**\n * Asynchronously reads a file from the virtual file system (VFS).\n *\n * @param path - The path or ID of the file to read.\n * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.\n */\n public async read(path: string): Promise<string | undefined> {\n const filePath = await this.resolve(path, undefined, { isFile: true });\n if (!filePath || !this.existsSync(filePath)) {\n return undefined;\n }\n\n const { adapter } = this.#getStorage(filePath);\n this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);\n\n return (await adapter.get(filePath)) ?? undefined;\n }\n\n /**\n * Synchronously reads a file from the virtual file system (VFS).\n *\n * @param path - The path or ID of the file to read.\n * @returns The contents of the file as a string, or undefined if the file does not exist.\n */\n public readSync(path: string): string | undefined {\n const filePath = this.resolveSync(path, undefined, { isFile: true });\n if (!filePath || !this.existsSync(filePath)) {\n return undefined;\n }\n\n const { adapter } = this.#getStorage(filePath);\n this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);\n\n return adapter.getSync(filePath) ?? undefined;\n }\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n public async write(\n path: string,\n data: string = \"\",\n options: WriteOptions = {}\n ): Promise<void> {\n const meta = options.meta ?? {};\n const resolvedPath =\n (await this.resolve(this.#normalizePath(path))) || path;\n\n const { relativeKey, adapter } = this.#getStorage(\n resolvedPath,\n options.storage as StoragePreset\n );\n\n this.#logger.trace(\n `Writing ${resolvedPath} to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n let code = data;\n try {\n if (!options.skipFormat) {\n code = await format(this.#context, resolvedPath, data);\n }\n } catch (err) {\n // Only warn about formatting errors for certain file types\n if (\n DEFAULT_EXTENSIONS.includes(\n findFileExtensionSafe(resolvedPath, {\n fullExtension: true\n })\n )\n ) {\n this.#logger.warn(\n `Failed to format file ${resolvedPath} before writing: ${(err as Error).message}`\n );\n }\n code = data;\n }\n\n this.#logger.trace(\n `Writing ${resolvedPath} to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(code)).size)})`\n );\n\n const id = this.#normalizeId(meta.id || resolvedPath);\n this.metadata[id] = {\n type: \"normal\",\n timestamp: Date.now(),\n ...(this.metadata[id] ?? {}),\n ...meta\n } as VirtualFileMetadata;\n this.paths[id] = resolvedPath;\n this.ids[resolvedPath] = id;\n\n return adapter.set(relativeKey, code);\n }\n\n /**\n * Synchronously writes a file to the virtual file system (VFS).\n *\n * @param path - The file to write.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n */\n public writeSync(\n path: string,\n data: string = \"\",\n options: WriteOptions = {}\n ): void {\n const meta = options.meta ?? {};\n const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;\n\n const { relativeKey, adapter } = this.#getStorage(\n resolvedPath,\n options.storage as StoragePreset\n );\n\n this.#logger.trace(\n `Writing ${resolvedPath} file to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n const id = this.#normalizeId(meta.id || resolvedPath);\n this.metadata[id] = {\n type: \"normal\",\n timestamp: Date.now(),\n ...(this.metadata[id] ?? {}),\n ...meta\n } as VirtualFileMetadata;\n this.paths[id] = resolvedPath;\n this.ids[resolvedPath] = id;\n\n return adapter.setSync(relativeKey, data);\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public mkdirSync(dirPath: string) {\n return this.#getStorage(dirPath)?.adapter?.mkdirSync(dirPath);\n }\n\n /**\n * Creates a directory at the specified path.\n *\n * @param path - The path of the directory to create.\n */\n public async mkdir(path: string): Promise<void> {\n return this.#getStorage(path)?.adapter?.mkdir(path);\n }\n\n /**\n * Retrieves the metadata of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to retrieve metadata for.\n * @returns The metadata of the file, or undefined if the file does not exist.\n */\n public getMetadata(pathOrId: string): VirtualFileMetadata | undefined {\n const resolved = this.resolveSync(pathOrId);\n if (resolved && this.metadata[resolved]) {\n return this.metadata[resolved];\n }\n\n return undefined;\n }\n\n /**\n * Resolves a given module ID using the configured aliases.\n *\n * @remarks\n * This function can be used to map module IDs to different paths based on the alias configuration.\n *\n * @param id - The module ID to resolve.\n * @returns The resolved module ID - after applying any configured aliases (this will be the same as the input ID if no aliases match).\n */\n public resolveAlias(id: string): string {\n let path = id;\n\n if (this.#context.config.resolve.alias) {\n if (\n Array.isArray(this.#context.config.resolve.alias) &&\n this.#context.config.resolve.alias.length > 0\n ) {\n const found = this.#context.config.resolve.alias.filter(\n alias =>\n (isSetString(alias.find) &&\n (alias.find === path || path.startsWith(`${alias.find}/`))) ||\n (isRegExp(alias.find) && alias.find.test(path))\n );\n if (found.length > 0) {\n const alias = found.reduce((ret, current) => {\n const retLength = isSetString(ret.find)\n ? ret.find.length\n : isRegExp(ret.find)\n ? ret.find.source.length\n : 0;\n const currentLength = isSetString(current.find)\n ? current.find.length\n : isRegExp(current.find)\n ? current.find.source.length\n : 0;\n\n return retLength > currentLength ? ret : current;\n });\n\n if (isSetString(alias.find)) {\n path = path.replace(\n new RegExp(`^${alias.find}`),\n alias.replacement\n );\n } else if (isRegExp(alias.find)) {\n path = path.replace(alias.find, alias.replacement);\n }\n }\n } else if (isSetObject(this.#context.config.resolve.alias)) {\n const found = Object.keys(\n this.#context.config.resolve.alias as Record<string, string>\n ).filter(key => key === path || path.startsWith(`${key}/`));\n if (found.length > 0) {\n const alias = found.reduce((ret, current) => {\n return ret.length > current.length ? ret : current;\n });\n\n path = path.replace(\n new RegExp(`^${alias}`),\n (this.#context.config.resolve.alias as Record<string, string>)[\n alias\n ]!\n );\n }\n }\n }\n\n return path;\n }\n\n /**\n * Checks if a given module ID is an alias.\n *\n * @remarks\n * This function can be used to determine if a module ID matches any configured aliases.\n *\n * @param id - The module ID to check.\n * @returns A boolean indicating whether the module ID is an alias.\n */\n public isAlias(id: string): boolean {\n const path = id;\n\n if (this.#context.config.resolve.alias) {\n if (\n Array.isArray(this.#context.config.resolve.alias) &&\n this.#context.config.resolve.alias.length > 0\n ) {\n return (\n this.#context.config.resolve.alias.filter(\n alias =>\n (isSetString(alias.find) &&\n (alias.find === path || path.startsWith(`${alias.find}/`))) ||\n (isRegExp(alias.find) && alias.find.test(path))\n ).length > 0\n );\n } else if (isSetObject(this.#context.config.resolve.alias)) {\n return (\n Object.keys(\n this.#context.config.resolve.alias as Record<string, string>\n ).filter(key => key === path || path.startsWith(`${key}/`)).length > 0\n );\n }\n }\n\n return false;\n }\n\n /**\n * Checks if a given module ID is a tsconfig path.\n *\n * @remarks\n * This function can be used to determine if a module ID matches any configured tsconfig paths.\n *\n * @param id - The module ID to check.\n * @returns A boolean indicating whether the module ID is a tsconfig path.\n */\n public isTsconfigPath(id: string): boolean {\n return !!(\n this.#context.tsconfig.options.paths &&\n Object.keys(this.#context.tsconfig.options.paths).length > 0 &&\n match(id, this.#context.resolvePatterns)\n );\n }\n\n /**\n * A helper function to resolve modules in the virtual file system (VFS).\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolvePath(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n public async resolve(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<string | undefined> {\n const origResult = await this.#innerResolve(id, importer, options);\n if (origResult && options.isFile && (await this.isDirectory(origResult))) {\n const indexResult = await this.resolve(\n joinPaths(origResult, \"index\"),\n importer,\n options\n );\n if (indexResult) {\n return indexResult;\n }\n\n if (!hasFileExtension(origResult)) {\n for (const ext of DEFAULT_EXTENSIONS) {\n const extResult = await this.resolve(\n `${origResult}.${ext}`,\n importer,\n options\n );\n if (extResult) {\n return extResult;\n }\n }\n }\n\n return undefined;\n }\n\n return origResult;\n }\n\n /**\n * A synchronous helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = context.resolveSync(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns The resolved module path.\n */\n public resolveSync(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): string | undefined {\n const origResult = this.#innerResolveSync(id, importer, options);\n if (origResult && options.isFile && this.isDirectorySync(origResult)) {\n const indexResult = this.resolveSync(\n joinPaths(origResult, \"index\"),\n importer,\n options\n );\n if (indexResult) {\n return indexResult;\n }\n\n if (!hasFileExtension(origResult)) {\n for (const ext of DEFAULT_EXTENSIONS) {\n const extResult = this.resolveSync(\n `${origResult}.${ext}`,\n importer,\n options\n );\n if (extResult) {\n return extResult;\n }\n }\n }\n\n return undefined;\n }\n\n return origResult;\n }\n\n /**\n * Disposes of the virtual file system (VFS) by saving its state to disk.\n */\n public async dispose() {\n if (!this.#isDisposed) {\n this.#isDisposed = true;\n\n this.#logger.debug(\"Disposing virtual file system...\");\n await this.remove(joinPaths(this.#context.dataPath, \"fs.bin\"));\n\n const message = new capnp.Message();\n const fs = message.initRoot(FileSystem);\n\n const storage = fs._initStorage(Object.keys(this.#paths).length);\n await Promise.all(\n Object.values(this.#paths).map(async (path, index) => {\n const code = await this.read(path);\n\n const fd = storage.get(index);\n fd.path = path;\n fd.code = code || \"\";\n })\n );\n\n const ids = fs._initIds(Object.keys(this.#ids).length);\n Object.entries(this.#ids)\n .filter(([, id]) => id)\n .forEach(([path, id], index) => {\n const fileId = ids.get(index);\n fileId.id = id;\n fileId.path = path;\n });\n\n const metadata = fs._initMetadata(Object.keys(this.#metadata).length);\n Object.entries(this.#metadata)\n .filter(([, value]) => value)\n .forEach(([id, value], index) => {\n const fileMetadata = metadata.get(index);\n fileMetadata.id = id;\n fileMetadata.type = value.type;\n fileMetadata.timestamp = value.timestamp ?? Date.now();\n\n if (value.properties) {\n const props = fileMetadata._initProperties(\n Object.keys(value.properties).length\n );\n Object.entries(value.properties)\n .filter(([, val]) => isSetString(val))\n .forEach(([key, val], index) => {\n const prop = props.get(index);\n prop.key = key;\n prop.value = val!;\n });\n }\n });\n\n await writeFileBuffer(\n joinPaths(this.#context.dataPath, \"fs.bin\"),\n message.toArrayBuffer()\n );\n\n if (!this.#context.config.skipCache) {\n this.resolverCache.save(true);\n }\n\n await Promise.all(\n this.#getStorages().map(async storage => storage.adapter.dispose())\n );\n\n this.#logger.trace(\"Virtual file system has been disposed.\");\n }\n }\n\n /**\n * Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.\n *\n * @remarks\n * This method is automatically called when the VFS instance is used within a `using` block, or can be manually invoked to ensure that the VFS state is saved and resources are cleaned up properly.\n */\n public async [Symbol.asyncDispose]() {\n return this.dispose();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,SAAS,WAAW,MAAoC;CACtD,OAAO,YAAY,MAAM,MAAM,SAAS,KAAK,GAAG,CAAC,CAAC,QAAQ,cAAc,EAAE,CAAC;AAC7E;;;;;;;;AASA,SAAS,UAAU,IAAY,SAAS,cAAuB;CAC7D,OAAO,GAAG,QAAQ,QAAQ,EAAE,CAAC,CAAC,WAAW,GAAG,OAAO,QAAQ,MAAM,EAAE,GAAG;AACxE;;;;;;;;AASA,SAAS,YAAY,IAAY,SAAS,cAAsB;CAM9D,OAAO,iBAAiB,WAAW,EAAE,CAAC,CAAC,CACpC,QAAQ,QAAQ,EAAE,CAAC,CACnB,QAAQ,gBAAgB,EAAE,CAAC,CAC3B,QAAQ,IAAI,OAAO,IAAI,OAAO,QAAQ,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE;AAC5D;;;;;;;;;AAUA,SAAS,cACP,MACA,cACA,SAAS,cACD;CACR,IAAI,CAAC,YAAY,IAAI,GAAG;EACtB,IAAI,CAAC,SAAS,IAAI,GAChB,MAAM,IAAI,MAAM,iDAAiD;EAEnE,MAAM,IAAI,MAAM,sBAAsB;CACxC;CAEA,OAAO,eAAe,IAAI,IACtB,OACA,UAAU,WAAW,IAAI,GAAG,MAAM,IAChC,YAAY,WAAW,IAAI,GAAG,MAAM,CAAC,CAAC,QACpC,IAAI,OAAO,IAAI,OAAO,QAAQ,MAAM,EAAE,EAAE,EAAE,GAC1C,YACF,IACA,WAAW,IAAI;AACvB;;;;;;;;AASA,SAAS,sBACP,eACA,UAIU;CACV,OAAO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OAAO,OAAO;GAChB,CAAC;GAEH,MAAM,WAAW,GAAG,cAAc,OAAO,KAAK,KAAKD,SAAS,CAAC,CAAC,MAAM;GACpE,OAAO,QAAQ,KAAKA,SAAS,CAAC,CAC3B,QAAQ,GAAG,WAAW,KAAK,CAAC,CAC5B,SAAS,CAAC,IAAI,QAAQ,UAAU;IAC/B,MAAM,eAAe,SAAS,IAAI,KAAK;IACvC,aAAa,KAAK;IAClB,aAAa,OAAO,MAAM;IAC1B,aAAa,YAAY,MAAM,aAAa,KAAK,IAAI;IAErD,IAAI,MAAM,YAAY;KACpB,MAAM,QAAQ,aAAa,gBACzB,OAAO,KAAK,MAAM,UAAU,CAAC,CAAC,MAChC;KACA,OAAO,QAAQ,MAAM,UAAU,CAAC,CAC7B,QAAQ,GAAG,SAAS,YAAY,GAAG,CAAC,CAAC,CACrC,SAAS,CAAC,KAAK,MAAM,UAAU;MAC9B,MAAM,OAAO,MAAM,IAAI,KAAK;MAC5B,KAAK,MAAM;MACX,KAAK,QAAQ;KACf,CAAC;IACL;GACF,CAAC;GAEH,MAAM,gBACJ,UAAU,KAAKN,SAAS,UAAU,QAAQ,GAC1C,QAAQ,cAAc,CACxB;GAEA,IAAI,CAAC,KAAKA,SAAS,OAAO,WACxB,KAAK,cAAc,KAAK,IAAI;GAG9B,MAAM,QAAQ,IACZ,KAAKU,aAAa,CAAC,CAAC,IAAI,OAAM,YAAW,QAAQ,QAAQ,QAAQ,CAAC,CACpE;GAEA,KAAKL,QAAQ,MAAM,wCAAwC;EAC7D;CACF;;;;;;;CAQA,OAAc,OAAO,gBAAgB;EACnC,OAAO,KAAK,QAAQ;CACtB;AACF"}
1
+ {"version":3,"file":"vfs.mjs","names":["#context","#normalizePath","#storage","#normalizeId","#getStorage","#logger","#metadata","#ids","#paths","#resolverCache","#getStorages","#innerResolve","#innerResolveSync","#isDisposed"],"sources":["../../src/lib/vfs.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport * as capnp from \"@stryke/capnp\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport {\n readFileBuffer,\n readFileBufferSync,\n writeFileBuffer\n} from \"@stryke/fs/buffer\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport {\n getResolutionCombinations,\n resolve,\n resolveSync\n} from \"@stryke/fs/resolve\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { correctPath, stripStars } from \"@stryke/path/correct-path\";\nimport {\n findFileExtensionSafe,\n findFileName,\n findFilePath,\n hasFileExtension\n} from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { slash } from \"@stryke/path/slash\";\nimport { prettyBytes } from \"@stryke/string-format/pretty-bytes\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { AssetGlob } from \"@stryke/types/file\";\nimport { match } from \"bundle-require\";\nimport { create, FlatCache } from \"flat-cache\";\nimport { Blob } from \"node:buffer\";\nimport { PathOrFileDescriptor } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { FileId, FileMetadata, FileSystem } from \"../../schemas/fs\";\nimport { DEFAULT_EXTENSIONS } from \"../constants/extensions\";\nimport { replacePathTokens } from \"../plugin-utils\";\nimport { FileSystemStorageAdapter } from \"../storage/file-system\";\nimport { VirtualStorageAdapter } from \"../storage/virtual\";\nimport { Context } from \"../types/context\";\nimport {\n ResolveOptions,\n StorageAdapter,\n StoragePort,\n StoragePreset,\n VirtualFileMetadata,\n VirtualFileSystemInterface,\n WriteOptions\n} from \"../types/fs\";\nimport { Logger } from \"../types/logging\";\nimport { format } from \"./utilities/format\";\n\ninterface StorageAdapterState {\n adapter: StorageAdapter;\n relativeKey: string;\n base: string;\n}\n\nfunction toFilePath(path: PathOrFileDescriptor): string {\n return correctPath(slash(path?.toString() || \".\").replace(/^file:\\/\\//, \"\"));\n}\n\n/**\n * Checks if a given file id is valid based on the specified prefix.\n *\n * @param id - The file ID to check.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns `true` if the file ID is valid, otherwise `false`.\n */\nfunction isValidId(id: string, prefix = \"powerlines\"): boolean {\n return id.replace(/^\\\\0/, \"\").startsWith(`${prefix.replace(/:$/, \"\")}`);\n}\n\n/**\n * Formats a file id by removing the file extension and prepended runtime prefix.\n *\n * @param id - The file ID to format.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns The formatted file ID.\n */\nfunction normalizeId(id: string, prefix = \"powerlines\"): string {\n // return `${prefix.replace(/:$/, \"\")}:${toFilePath(id)\n // .replace(new RegExp(`^${prefix.replace(/:$/, \"\")}:`), \"\")\n // .replace(/^\\\\0/, \"\")\n // .replace(findFileDotExtensionSafe(toFilePath(id)), \"\")}`;\n\n return replaceExtension(toFilePath(id))\n .replace(/^\\\\0/, \"\")\n .replace(/^powerlines:/, \"\")\n .replace(new RegExp(`^${prefix.replace(/:$/, \"\")}:`), \"\");\n}\n\n/**\n * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.\n *\n * @param path - The path to normalize.\n * @param builtinsPath - The path to built-in files.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns The normalized path.\n */\nfunction normalizePath(\n path: string,\n builtinsPath: string,\n prefix = \"powerlines\"\n): string {\n if (!isSetString(path)) {\n if (!isString(path)) {\n throw new Error(\"Path type must be a string or a file descriptor\");\n }\n throw new Error(\"Path cannot be empty\");\n }\n\n return isAbsolutePath(path)\n ? path\n : isValidId(toFilePath(path), prefix)\n ? normalizeId(toFilePath(path), prefix).replace(\n new RegExp(`^${prefix.replace(/:$/, \"\")}:`),\n builtinsPath\n )\n : toFilePath(path);\n}\n\n/**\n * Normalizes glob patterns by resolving them against the workspace root.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param patterns - The glob patterns to normalize.\n * @returns An array of normalized glob patterns.\n */\nfunction normalizeGlobPatterns(\n workspaceRoot: string,\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n): string[] {\n return getUnique(\n toArray(patterns)\n .map(pattern => {\n if (\n isSetObject(pattern) &&\n (isSetString(pattern.input) || isSetString(pattern.glob))\n ) {\n return joinPaths(\n pattern.input || workspaceRoot,\n pattern.glob || \"**/*\"\n );\n } else if (!isSetString(pattern)) {\n return undefined;\n }\n\n return pattern;\n })\n .filter(isSetString)\n );\n}\n\n/**\n * Represents a virtual file system (VFS) that stores files and their associated metadata in virtual memory.\n *\n * @remarks\n * This class provides methods to manage virtual files, check their existence, retrieve their content, and manipulate the virtual file system. It allows for efficient file management and retrieval without relying on the actual file system.\n */\nexport class VirtualFileSystem implements VirtualFileSystemInterface {\n /**\n * An unstable storage property that can be used for testing or debugging purposes. This property is not intended for production use and may be removed or changed without warning in future releases.\n *\n * @internal\n */\n static unstable_storage: FileSystem | null = null;\n\n /**\n * A map of virtual file IDs to their associated metadata.\n */\n #metadata: Record<string, VirtualFileMetadata>;\n\n /**\n * A map of underlying file paths to their virtual file IDs.\n */\n #ids: Record<string, string>;\n\n /**\n * A map of virtual file IDs to their underlying file paths.\n */\n #paths: Record<string, string>;\n\n /**\n * The unified volume that combines the virtual file system with the real file system.\n *\n * @remarks\n * This volume allows for seamless access to both virtual and real files.\n */\n #storage: StoragePort;\n\n // /**\n // * The resolver factory used during module resolution within the virtual file system.\n // *\n // * @see https://github.com/oxc-project/oxc-resolver\n // */\n // #resolver!: ResolverFactory;\n\n /**\n * A cache for module resolution results.\n */\n #resolverCache!: FlatCache;\n\n /**\n * Indicator specifying if the virtual file system (VFS) is disposed\n */\n #isDisposed = false;\n\n /**\n * The context of the virtual file system.\n */\n #context: Context;\n\n /**\n * The file system's logger client utility.\n */\n #logger: Logger;\n\n /**\n * Normalizes a given module id by resolving it against the built-ins path.\n *\n * @param id - The module id to normalize.\n * @returns The normalized module id.\n */\n #normalizeId(id: string): string {\n let normalized = id;\n if (isParentPath(normalized, this.#context.builtinsPath)) {\n normalized = replacePath(normalized, this.#context.builtinsPath);\n }\n\n return normalizeId(\n normalized,\n this.#context.config.framework?.name ?? \"powerlines\"\n );\n }\n\n /**\n * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.\n *\n * @param path - The path to normalize.\n * @returns The normalized path.\n */\n #normalizePath(path: string): string {\n if (!isSetString(path)) {\n if (!isString(path)) {\n throw new Error(\"Path type must be a string or a file descriptor\");\n }\n throw new Error(\"Path cannot be empty\");\n }\n\n return normalizePath(\n path.includes(\"{\") || path.includes(\"}\")\n ? replacePathTokens(this.#context, path)\n : path,\n this.#context.builtinsPath,\n this.#context.config.framework?.name ?? \"powerlines\"\n );\n }\n\n /**\n * Gets the storage adapter and relative key for a given key.\n *\n * @remarks\n * The `key` can be either a path or a storage adapter name.\n *\n * @param key - The key to get the storage adapter for.\n * @returns The storage adapter and relative key for the given key.\n */\n #getStorage(key: string, preset?: StoragePreset): StorageAdapterState {\n const path = this.resolveSync(this.#normalizePath(key)) || key;\n for (const base of Object.keys(this.#storage)\n .filter(Boolean)\n .sort()\n .reverse()) {\n if (\n (path === base || isParentPath(path, base)) &&\n (!preset ||\n this.#storage[base]?.preset?.toLowerCase() === preset.toLowerCase())\n ) {\n return {\n base,\n relativeKey: replacePath(path, base),\n adapter: this.#storage[base]!\n };\n }\n }\n\n if (\n !preset ||\n this.#storage[\"\"]?.preset?.toLowerCase() === preset.toLowerCase()\n ) {\n return {\n base: \"\",\n relativeKey: path,\n adapter: this.#storage[\"\"]!\n };\n }\n\n this.#storage[path] =\n preset === \"virtual\"\n ? new VirtualStorageAdapter(this.#context, {\n base: path\n })\n : new FileSystemStorageAdapter(this.#context, {\n base: path\n });\n\n return {\n base: path,\n relativeKey: \"\",\n adapter: this.#storage[path]\n };\n }\n\n /**\n * Gets all storage adapters that match a given base key.\n *\n * @param base - The base key to match storage adapters against.\n * @param includeParent - Whether to include parent storage adapters.\n * @returns An array of storage adapters that match the given base key.\n */\n #getStorages(base = \"\", includeParent = false) {\n const baseKey = this.resolveSync(base) || base;\n\n return Object.keys(this.#storage)\n .sort()\n .reverse()\n .filter(\n key =>\n isParentPath(key, baseKey) ||\n (includeParent && isParentPath(baseKey, key)) ||\n (baseKey.includes(\"*\") &&\n (isParentPath(stripStars(baseKey), key) ||\n globToRegex(replaceExtension(baseKey)).test(key)))\n )\n .map(key => ({\n relativeBase:\n baseKey.length > key.length ? baseKey.slice(key.length) : undefined,\n base: key,\n adapter: this.#storage[key]!\n }));\n }\n\n /**\n * A helper function to resolve modules in the virtual file system (VFS).\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolvePath(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n #innerResolve = async (\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<string | undefined> => {\n let path = id;\n if (path.includes(\"{\") || path.includes(\"}\")) {\n path = replacePathTokens(this.#context, path);\n }\n\n if (options.skipAlias !== true) {\n path = this.resolveAlias(path);\n }\n\n if (\n isAbsolutePath(path) &&\n (!options.isFile || !(await this.isDirectory(path)))\n ) {\n return path;\n }\n\n const resolverCacheKey = murmurhash({\n path: this.#normalizeId(path),\n importer,\n options\n });\n\n let result!: string | undefined;\n if (!this.#context.config.skipCache) {\n result = this.resolverCache.get<string | undefined>(resolverCacheKey);\n if (result) {\n return result;\n }\n }\n\n result = this.paths[this.#normalizeId(path)];\n if (!isSetString(result)) {\n const paths = options.paths ?? [];\n if (importer && !paths.includes(importer)) {\n paths.push(importer);\n }\n\n if (!importer) {\n paths.push(this.#context.config.cwd);\n paths.push(\n appendPath(this.#context.config.root, this.#context.config.cwd)\n );\n paths.push(\n appendPath(\n joinPaths(this.#context.config.root, \"src\"),\n this.#context.config.cwd\n )\n );\n }\n\n paths.push(\n ...(\n Object.keys(this.#context.tsconfig?.options?.paths ?? {})\n .filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replace(/\\*$/, \"\"))\n )\n .map(\n tsconfigPath =>\n this.#context.tsconfig?.options?.paths?.[tsconfigPath]\n )\n .flat()\n .filter(Boolean) as string[]\n ).map(tsconfigPath =>\n appendPath(tsconfigPath, this.#context.config.cwd)\n )\n );\n\n for (const combination of getResolutionCombinations(path, {\n paths: getUnique(paths)\n })) {\n const { relativeKey, adapter } = this.#getStorage(combination);\n if (await adapter.exists(relativeKey)) {\n result = combination;\n break;\n }\n }\n\n if (!isSetString(result)) {\n try {\n result = await resolve(path, { ...options, paths });\n } catch {\n // Do nothing\n }\n\n // if (!result) {\n // let index = 0;\n // do {\n // const resolveResult = await this.resolver.async(\n // (paths.length > index ? paths[index] : undefined) ||\n // this.#context.config.root,\n // path\n // );\n // if (resolveResult.path) {\n // result = resolveResult.path;\n // }\n\n // index++;\n // } while (!result && index < paths.length);\n // }\n }\n }\n\n if (isSetString(result)) {\n if (!this.#context.config.skipCache) {\n this.resolverCache.set(this.#normalizeId(path), result);\n }\n\n return result;\n }\n\n return undefined;\n };\n\n /**\n * A synchronous helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = context.resolveSync(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns The resolved module path.\n */\n #innerResolveSync = (\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): string | undefined => {\n let path = id;\n if (path.includes(\"{\") || path.includes(\"}\")) {\n path = replacePathTokens(this.#context, path);\n }\n\n if (options.skipAlias !== true) {\n path = this.resolveAlias(path);\n }\n\n if (\n isAbsolutePath(path) &&\n (!options.isFile || !this.isDirectorySync(path))\n ) {\n return path;\n }\n\n let result!: string | undefined;\n if (!this.#context.config.skipCache) {\n result = this.resolverCache.get<string | undefined>(\n this.#normalizeId(path)\n );\n if (isSetString(result)) {\n return result;\n }\n }\n\n result = this.paths[this.#normalizeId(path)];\n if (!isSetString(result)) {\n const paths = options.paths ?? [];\n if (importer && !paths.includes(importer)) {\n paths.push(importer);\n }\n\n if (!importer) {\n paths.push(this.#context.config.cwd);\n paths.push(\n appendPath(this.#context.config.root, this.#context.config.cwd)\n );\n paths.push(\n appendPath(\n joinPaths(this.#context.config.root, \"src\"),\n this.#context.config.cwd\n )\n );\n }\n\n paths.push(\n ...(\n Object.keys(this.#context.tsconfig?.options?.paths ?? {})\n .filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replace(/\\*$/, \"\"))\n )\n .map(\n tsconfigPath =>\n this.#context.tsconfig?.options?.paths?.[tsconfigPath]\n )\n .flat()\n .filter(Boolean) as string[]\n ).map(tsconfigPath =>\n appendPath(tsconfigPath, this.#context.config.cwd)\n )\n );\n\n for (const combination of getResolutionCombinations(path, { paths })) {\n const { relativeKey, adapter } = this.#getStorage(combination);\n if (adapter.existsSync(relativeKey)) {\n result = combination;\n break;\n }\n }\n\n if (!isSetString(result)) {\n try {\n result = resolveSync(path, { ...options, paths });\n } catch {\n // Do nothing\n }\n\n // if (!result) {\n // let index = 0;\n // do {\n // const resolveResult = this.resolver.sync(\n // (paths.length > index ? paths[index] : undefined) ||\n // this.#context.config.root,\n // path\n // );\n // if (resolveResult.path) {\n // result = resolveResult.path;\n // }\n\n // index++;\n // } while (!result && index < paths.length);\n // }\n }\n }\n\n if (isSetString(result)) {\n if (!this.#context.config.skipCache) {\n this.resolverCache.set(this.#normalizeId(path), result);\n }\n\n return result;\n }\n\n return undefined;\n };\n\n /**\n * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @returns A promise that resolves to a new virtual file system instance.\n */\n public static async create(context: Context): Promise<VirtualFileSystem> {\n context.trace(\n \"Starting virtual file system (VFS) initialization processes...\"\n );\n\n let result!: VirtualFileSystem;\n if (\n !context.config.skipCache &&\n existsSync(joinPaths(context.dataPath, \"fs.bin\"))\n ) {\n if (!VirtualFileSystem.unstable_storage) {\n context.debug(\"Reading virtual file system (VFS) from local storage\");\n\n const buffer = await readFileBuffer(\n joinPaths(context.dataPath, \"fs.bin\")\n );\n\n const message = new capnp.Message(buffer, false);\n VirtualFileSystem.unstable_storage = message.getRoot(FileSystem);\n }\n\n const fs = VirtualFileSystem.unstable_storage;\n result = new VirtualFileSystem(context, fs);\n\n if (fs._hasStorage() && fs.storage.length > 0) {\n await Promise.all(\n fs.storage.values().map(async file => {\n if (file.path && file.code) {\n let id: FileId | undefined;\n if (fs._hasIds()) {\n id = fs.ids.find((fileId: FileId) => fileId.path === file.path);\n }\n\n let metadata: FileMetadata | undefined;\n if (fs._hasMetadata()) {\n metadata = fs.metadata.find(\n (meta: FileMetadata) =>\n meta.id === result.#normalizeId(id?.id ?? file.path)\n );\n }\n\n await result.write(file.path, file.code, {\n meta: {\n id: result.#normalizeId(id?.id ?? metadata?.id ?? file.path),\n type: metadata?.type || \"normal\",\n properties: metadata?._hasProperties()\n ? metadata?.properties.values().reduce(\n (ret, kvp) => {\n ret[kvp.key] = kvp.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : undefined,\n timestamp: metadata?.timestamp\n }\n });\n }\n })\n );\n }\n } else {\n const message = new capnp.Message();\n result = new VirtualFileSystem(context, message.initRoot(FileSystem));\n }\n\n result.#logger.trace(\n \"Successfully completed virtual file system (VFS) initialization.\"\n );\n\n return result;\n }\n\n /**\n * Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @returns A new virtual file system instance.\n */\n public static createSync(context: Context): VirtualFileSystem {\n context.trace(\n \"Starting virtual file system (VFS) initialization processes...\"\n );\n\n let result!: VirtualFileSystem;\n if (\n !context.config.skipCache &&\n existsSync(joinPaths(context.dataPath, \"fs.bin\"))\n ) {\n if (!VirtualFileSystem.unstable_storage) {\n context.debug(\"Reading virtual file system (VFS) from local storage\");\n\n const buffer = readFileBufferSync(\n joinPaths(context.dataPath, \"fs.bin\")\n );\n\n const message = new capnp.Message(buffer, false);\n VirtualFileSystem.unstable_storage = message.getRoot(FileSystem);\n }\n\n const fs = VirtualFileSystem.unstable_storage;\n result = new VirtualFileSystem(context, fs);\n\n if (fs._hasStorage() && fs.storage.length > 0) {\n fs.storage.values().forEach(file => {\n if (file.path && file.code) {\n let id: FileId | undefined;\n if (fs._hasIds()) {\n id = fs.ids.find((fileId: FileId) => fileId.path === file.path);\n }\n\n let metadata: FileMetadata | undefined;\n if (fs._hasMetadata()) {\n metadata = fs.metadata.find(\n (meta: FileMetadata) =>\n meta.id === result.#normalizeId(id?.id ?? file.path)\n );\n }\n\n result.writeSync(file.path, file.code, {\n meta: {\n id: result.#normalizeId(id?.id ?? metadata?.id ?? file.path),\n type: metadata?.type,\n properties: metadata?._hasProperties()\n ? metadata?.properties.values().reduce(\n (ret, kvp) => {\n ret[kvp.key] = kvp.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : undefined,\n timestamp: metadata?.timestamp\n }\n });\n }\n });\n }\n } else {\n const message = new capnp.Message();\n result = new VirtualFileSystem(context, message.initRoot(FileSystem));\n }\n\n result.#logger.trace(\n \"Successfully completed virtual file system (VFS) initialization.\"\n );\n\n return result;\n }\n\n /**\n * A map of file ids to their metadata.\n */\n public get metadata(): Record<string, VirtualFileMetadata> {\n return new Proxy(this.#metadata, {\n get: (target, prop: string) => {\n return target[this.#normalizeId(prop)];\n },\n set: (target, prop: string, value) => {\n target[this.#normalizeId(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizeId(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizeId(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizeId(key as string))\n );\n }\n });\n }\n\n /**\n * A map of file paths to their module ids.\n */\n public get ids(): Record<string, string> {\n return new Proxy(this.#ids, {\n get: (target, prop: string) => {\n return target[this.#normalizePath(prop)];\n },\n set: (target, prop: string, value) => {\n target[this.#normalizePath(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizePath(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizePath(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizePath(key as string))\n );\n }\n });\n }\n\n /**\n * A map of module ids to their file paths.\n */\n public get paths(): Record<string, string> {\n return new Proxy(this.#paths, {\n get: (target, prop: string) => {\n return this.#normalizeId(prop) in target\n ? target[this.#normalizeId(prop)]\n : undefined;\n },\n set: (target, prop: string, value) => {\n target[this.#normalizeId(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizeId(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizeId(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizeId(key as string))\n );\n }\n });\n }\n\n /**\n * Gets the resolver cache.\n */\n protected get resolverCache(): FlatCache {\n if (!this.#resolverCache) {\n this.#resolverCache = create({\n cacheId: \"module-resolution\",\n cacheDir: this.#context.cachePath,\n ttl: 2.5 * 60 * 1000,\n lruSize: 8000,\n persistInterval: 100\n });\n }\n\n return this.#resolverCache;\n }\n\n // /**\n // * The resolver factory used during module resolution within the virtual file system.\n // *\n // * @remarks\n // * This resolver is configured with the workspace root, project root, TypeScript configuration, alias mappings, and other resolution options specified in the context. It is lazily initialized on first access to optimize performance.\n // *\n // * @see https://github.com/oxc-project/oxc-resolver\n // */\n // protected get resolver(): ResolverFactory {\n // if (!this.#resolver) {\n // this.#resolver = new ResolverFactory({\n // roots: [\n // this.#context.config.cwd,\n // appendPath(\n // this.#context.config.root,\n // this.#context.config.cwd\n // )\n // ],\n // tsconfig: {\n // configFile: this.#context.tsconfig.tsconfigFilePath,\n // references:\n // this.#context.tsconfig.projectReferences &&\n // this.#context.tsconfig.projectReferences.length > 0\n // ? \"auto\"\n // : undefined\n // },\n // alias: Object.fromEntries(\n // Object.entries(this.#context.alias).map(([key, value]) => [\n // key,\n // [value]\n // ])\n // ),\n // extensions: this.#context.config.resolve.extensions,\n // mainFields: this.#context.config.resolve.mainFields,\n // conditionNames: this.#context.config.resolve.conditions,\n // symlinks: this.#context.config.resolve.preserveSymlinks,\n // allowPackageExportsInDirectoryResolve: true\n // });\n // }\n\n // return this.#resolver;\n // }\n\n /**\n * Creates a new instance of the {@link VirtualFileSystem}.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @param fs - A buffer containing the serialized virtual file system data.\n */\n private constructor(context: Context, fs: FileSystem) {\n this.#context = context;\n this.#storage = { \"\": new FileSystemStorageAdapter(context) };\n\n if (isSetObject(this.#context.config.output.storage)) {\n this.#storage = {\n ...this.#storage,\n ...this.#context.config.output.storage\n };\n }\n\n this.#storage.virtual ??= new VirtualStorageAdapter(context, {\n base: \"/_virtual\"\n });\n\n this.#storage[this.#context.config.output.path] ??=\n new FileSystemStorageAdapter(context, {\n base: this.#context.config.output.path\n });\n\n if (\n this.#context.config.output.copy &&\n this.#context.config.output.copy.path\n ) {\n this.#storage[this.#context.config.output.copy.path] ??=\n new FileSystemStorageAdapter(context, {\n base: this.#context.config.output.copy.path\n });\n }\n\n if (this.#context.config.output.storage !== \"fs\") {\n this.#storage[this.#context.artifactsPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.artifactsPath\n }\n );\n this.#storage[this.#context.builtinsPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.builtinsPath\n }\n );\n this.#storage[this.#context.entryPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.entryPath\n }\n );\n }\n\n this.#metadata = {};\n if (fs._hasMetadata()) {\n this.#metadata = fs.metadata.values().reduce(\n (ret, metadata) => {\n ret[metadata.id] = {\n id: metadata.id,\n type: metadata.type,\n timestamp: metadata.timestamp ?? Date.now(),\n properties: metadata._hasProperties()\n ? metadata.properties.values().reduce(\n (ret, item) => {\n ret[item.key] = item.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : {}\n };\n\n return ret;\n },\n {} as Record<\n string,\n {\n id: string;\n type: string;\n timestamp: number;\n properties: Record<string, string>;\n }\n >\n );\n }\n\n this.#ids = {};\n this.#paths = {};\n\n if (fs._hasIds()) {\n this.#ids = fs.ids.values().reduce(\n (ret, identifier) => {\n ret[identifier.path] ??= identifier.id;\n\n return ret;\n },\n {} as Record<string, string>\n );\n\n this.#paths = fs.ids.values().reduce(\n (ret, identifier) => {\n ret[identifier.id] ??= identifier.path;\n return ret;\n },\n {} as Record<string, string>\n );\n }\n\n this.#logger = context.extendLogger({ category: \"fs\" });\n }\n\n /**\n * Asynchronously checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @returns A promise that resolves to `true` if the file exists, otherwise `false`.\n */\n public async exists(path: string): Promise<boolean> {\n const { relativeKey, adapter } = this.#getStorage(path);\n\n return adapter.exists(relativeKey);\n }\n\n /**\n * Synchronously checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @returns `true` if the file exists, otherwise `false`.\n */\n public existsSync(path: string): boolean {\n const { relativeKey, adapter } = this.#getStorage(path);\n\n return adapter.existsSync(relativeKey);\n }\n\n /**\n * Checks if a file is virtual in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the file is virtual, otherwise `false`.\n */\n public isVirtual(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return (\n this.#getStorage(resolved)?.adapter?.preset === \"virtual\" ||\n resolved.startsWith(\n `${this.#context.config.framework?.name ?? \"powerlines\"}:`\n ) ||\n path.startsWith(\n `${this.#context.config.framework?.name ?? \"powerlines\"}:`\n )\n );\n }\n\n /**\n * Checks if a path is a directory in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a directory, otherwise `false`.\n */\n public isDirectorySync(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return !!(\n this.existsSync(resolved) &&\n this.#getStorage(resolved)?.adapter?.isDirectorySync(resolved)\n );\n }\n\n /**\n * Checks if a path is a directory in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a directory, otherwise `false`.\n */\n public async isDirectory(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): Promise<boolean> {\n const resolved = await this.resolve(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return !!(\n (await this.exists(resolved)) &&\n (await this.#getStorage(resolved)?.adapter?.isDirectory(resolved))\n );\n }\n\n /**\n * Checks if a path is a file in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a file, otherwise `false`.\n */\n public isFileSync(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return this.#getStorage(resolved)?.adapter?.isFileSync(resolved) ?? false;\n }\n\n /**\n * Checks if a path is a file in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a file, otherwise `false`.\n */\n public async isFile(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): Promise<boolean> {\n const resolved = await this.resolve(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return (\n (await this.#getStorage(resolved)?.adapter?.isFile(resolved)) ?? false\n );\n }\n\n /**\n * Checks if a file Id must be resolved by the virtual file system (VFS).\n *\n * @remarks\n * Examples of file Ids that would be considered virtual include:\n * - Ids that start with the framework specific prefix (e.g. `powerlines:`)\n * - Ids that match a configured alias for virtual modules (returned true from {@link VirtualFileSystemInterface.isVirtual})\n *\n * @param path - The path or id of the file.\n * @param importer - An optional path to the importer module, used for resolving the file path.\n * @param options - Additional options for resolving the file path.\n * @returns `true` if the file is virtual, otherwise `false`.\n */\n public isResolvableId(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n return (\n path.startsWith(\n `${this.#context.config.framework?.name ?? \"powerlines\"}:`\n ) ||\n this.isVirtual(path, importer, options) ||\n this.isAlias(path) ||\n this.isTsconfigPath(path)\n );\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n public listSync(path: string): string[] {\n let resolvedPath = path;\n if (resolvedPath.includes(\"*\")) {\n this.#logger.warn(\n `Invoking \"listSync\" with a glob pattern is not supported. It is likely you meant to use \"globSync\". Path: ${path}`\n );\n resolvedPath = stripStars(resolvedPath);\n }\n\n return getUnique(\n this.#getStorages(resolvedPath, true)\n .map(storage =>\n storage.adapter.listSync(\n storage.relativeBase\n ? storage.base\n ? appendPath(storage.relativeBase, storage.base)\n : storage.relativeBase\n : storage.base\n )\n )\n .flat()\n .filter(Boolean)\n );\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n public async list(path: string): Promise<string[]> {\n let resolvedPath = path;\n if (resolvedPath.includes(\"*\")) {\n this.#logger.warn(\n `Invoking \"list\" with a glob pattern is not supported. It is likely you meant to use \"glob\". Path: ${path}`\n );\n resolvedPath = stripStars(resolvedPath);\n }\n\n return getUnique(\n (\n await Promise.all(\n this.#getStorages(resolvedPath, true).map(async storage =>\n storage.adapter.list(\n storage.relativeBase\n ? storage.base\n ? appendPath(storage.relativeBase, storage.base)\n : storage.relativeBase\n : storage.base\n )\n )\n )\n )\n .flat()\n .filter(Boolean)\n );\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public async remove(path: string): Promise<void> {\n const normalizedPath = this.#normalizePath(path);\n this.#logger.trace(`Removing file: ${normalizedPath}`);\n\n const { relativeKey, adapter } = this.#getStorage(normalizedPath);\n\n if (hasFileExtension(normalizedPath)) {\n await adapter.remove(relativeKey);\n } else {\n await adapter.clear(relativeKey);\n }\n\n const id = this.#ids[normalizedPath];\n if (id && this.#metadata[id]) {\n delete this.#metadata[id];\n delete this.#ids[normalizedPath];\n delete this.#paths[id];\n }\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public removeSync(path: string) {\n const normalizedPath = this.#normalizePath(path);\n this.#logger.trace(`Removing file: ${normalizedPath}`);\n\n const { relativeKey, adapter } = this.#getStorage(normalizedPath);\n\n if (hasFileExtension(normalizedPath)) {\n adapter.removeSync(relativeKey);\n } else {\n adapter.clearSync(relativeKey);\n }\n\n const id = this.#ids[normalizedPath];\n if (id && this.#metadata[id]) {\n delete this.#metadata[id];\n delete this.#ids[normalizedPath];\n delete this.#paths[id];\n }\n }\n\n /**\n * Glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n public async glob(\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ): Promise<string[]> {\n const results: string[] = [];\n for (const pattern of normalizeGlobPatterns(\n this.#context.config.cwd,\n patterns\n )) {\n const normalized = this.#normalizePath(pattern);\n if (!/[*?[\\]{}]/.test(normalized) && !normalized.includes(\"*\")) {\n if (this.isDirectorySync(normalized)) {\n results.push(...(await this.list(normalized)));\n } else {\n const resolved = await this.resolve(normalized);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n } else {\n const absPattern = isAbsolutePath(normalized)\n ? normalized\n : this.#normalizePath(\n appendPath(normalized, this.#context.config.cwd)\n );\n\n await Promise.all(\n (await this.list(stripStars(absPattern))).map(async file => {\n if (globToRegex(absPattern).test(file)) {\n const resolved = await this.resolve(file);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n })\n );\n }\n }\n\n return results;\n }\n\n /**\n * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n public globSync(\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ): string[] {\n const results: string[] = [];\n for (const pattern of normalizeGlobPatterns(\n this.#context.config.cwd,\n patterns\n )) {\n const normalized = this.#normalizePath(pattern);\n if (!/[*?[\\]{}]/.test(normalized) && !normalized.includes(\"*\")) {\n if (this.isDirectorySync(normalized)) {\n results.push(...this.listSync(normalized));\n } else {\n const resolved = this.resolveSync(normalized);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n } else {\n const absPattern = isAbsolutePath(normalized)\n ? normalized\n : this.#normalizePath(\n appendPath(normalized, this.#context.config.cwd)\n );\n\n const files = this.listSync(stripStars(absPattern));\n for (const file of files) {\n const regex = globToRegex(absPattern);\n if (regex.test(file)) {\n const resolved = this.resolveSync(file);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n }\n }\n }\n\n return results;\n }\n\n /**\n * Copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n public async copy(\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) {\n const src = srcPath instanceof URL ? fileURLToPath(srcPath) : srcPath;\n const dest = destPath instanceof URL ? fileURLToPath(destPath) : destPath;\n\n if (\n (!isSetString(src) && (!isSetObject(src) || !isSetString(src.input))) ||\n !isSetString(dest)\n ) {\n return;\n }\n\n const sourceStr = isString(src)\n ? src\n : src.input\n ? src.input\n : this.#context.config.cwd;\n const source = await this.resolve(sourceStr);\n if (!source) {\n return;\n }\n\n if (\n this.isDirectorySync(source) ||\n (isSetString(src) && src.includes(\"*\")) ||\n (isSetObject(src) && isSetString(src.glob))\n ) {\n await Promise.all(\n (await this.glob(src)).map(async file => {\n return this.copy(\n file,\n appendPath(replacePath(file, sourceStr), dest)\n );\n })\n );\n } else {\n const content = await this.read(source);\n if (content !== undefined) {\n await this.write(this.#normalizePath(dest), content, {\n skipFormat: true\n });\n }\n }\n }\n\n /**\n * Synchronously copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n public copySync(\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) {\n const src = srcPath instanceof URL ? fileURLToPath(srcPath) : srcPath;\n const dest = destPath instanceof URL ? fileURLToPath(destPath) : destPath;\n\n if (\n (!isSetString(src) && (!isSetObject(src) || !isSetString(src.input))) ||\n !isSetString(dest)\n ) {\n return;\n }\n\n const sourceStr = isString(src)\n ? src\n : src.input\n ? src.input\n : this.#context.config.cwd;\n const source = this.resolveSync(sourceStr);\n if (!source) {\n return;\n }\n\n if (\n this.isDirectorySync(source) ||\n (isSetString(src) && src.includes(\"*\")) ||\n (isSetObject(src) && isSetString(src.glob))\n ) {\n this.globSync(src).map(file => {\n return this.copySync(\n file,\n appendPath(findFilePath(replacePath(file, sourceStr)), dest)\n );\n });\n } else {\n const content = this.readSync(source);\n if (content !== undefined) {\n this.writeSync(\n this.#normalizePath(\n hasFileExtension(dest)\n ? dest\n : appendPath(findFileName(source), dest)\n ),\n content,\n { skipFormat: true }\n );\n }\n }\n }\n\n /**\n * Moves a file (or files) from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n public async move(srcPath: string, destPath: string) {\n if (hasFileExtension(srcPath)) {\n await this.copy(srcPath, destPath);\n await this.remove(srcPath);\n } else {\n await Promise.all(\n (await this.list(srcPath)).map(async file => {\n await this.copy(file, destPath);\n await this.remove(file);\n })\n );\n }\n }\n\n /**\n * Synchronously moves a file (or files) from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n public moveSync(srcPath: string, destPath: string) {\n if (hasFileExtension(srcPath)) {\n this.copySync(srcPath, destPath);\n this.removeSync(srcPath);\n } else {\n this.listSync(srcPath).forEach(file => {\n this.copySync(file, destPath);\n this.removeSync(file);\n });\n }\n }\n\n /**\n * Asynchronously reads a file from the virtual file system (VFS).\n *\n * @param path - The path or ID of the file to read.\n * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.\n */\n public async read(path: string): Promise<string | undefined> {\n const filePath = await this.resolve(path, undefined, { isFile: true });\n if (!filePath || !this.existsSync(filePath)) {\n return undefined;\n }\n\n const { adapter } = this.#getStorage(filePath);\n this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);\n\n return (await adapter.get(filePath)) ?? undefined;\n }\n\n /**\n * Synchronously reads a file from the virtual file system (VFS).\n *\n * @param path - The path or ID of the file to read.\n * @returns The contents of the file as a string, or undefined if the file does not exist.\n */\n public readSync(path: string): string | undefined {\n const filePath = this.resolveSync(path, undefined, { isFile: true });\n if (!filePath || !this.existsSync(filePath)) {\n return undefined;\n }\n\n const { adapter } = this.#getStorage(filePath);\n this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);\n\n return adapter.getSync(filePath) ?? undefined;\n }\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n public async write(\n path: string,\n data: string = \"\",\n options: WriteOptions = {}\n ): Promise<void> {\n const meta = options.meta ?? {};\n const resolvedPath =\n (await this.resolve(this.#normalizePath(path))) || path;\n\n const { relativeKey, adapter } = this.#getStorage(\n resolvedPath,\n options.storage as StoragePreset\n );\n\n this.#logger.trace(\n `Writing ${resolvedPath} to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n let code = data;\n try {\n if (!options.skipFormat) {\n code = await format(this.#context, resolvedPath, data);\n }\n } catch (err) {\n // Only warn about formatting errors for certain file types\n if (\n DEFAULT_EXTENSIONS.includes(\n findFileExtensionSafe(resolvedPath, {\n fullExtension: true\n })\n )\n ) {\n this.#logger.warn(\n `Failed to format file ${resolvedPath} before writing: ${(err as Error).message}`\n );\n }\n code = data;\n }\n\n this.#logger.trace(\n `Writing ${resolvedPath} to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(code)).size)})`\n );\n\n const id = this.#normalizeId(meta.id || resolvedPath);\n this.metadata[id] = {\n type: \"normal\",\n timestamp: Date.now(),\n ...(this.metadata[id] ?? {}),\n ...meta\n } as VirtualFileMetadata;\n this.paths[id] = resolvedPath;\n this.ids[resolvedPath] = id;\n\n return adapter.set(relativeKey, code);\n }\n\n /**\n * Synchronously writes a file to the virtual file system (VFS).\n *\n * @param path - The file to write.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n */\n public writeSync(\n path: string,\n data: string = \"\",\n options: WriteOptions = {}\n ): void {\n const meta = options.meta ?? {};\n const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;\n\n const { relativeKey, adapter } = this.#getStorage(\n resolvedPath,\n options.storage as StoragePreset\n );\n\n this.#logger.trace(\n `Writing ${resolvedPath} file to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n const id = this.#normalizeId(meta.id || resolvedPath);\n this.metadata[id] = {\n type: \"normal\",\n timestamp: Date.now(),\n ...(this.metadata[id] ?? {}),\n ...meta\n } as VirtualFileMetadata;\n this.paths[id] = resolvedPath;\n this.ids[resolvedPath] = id;\n\n return adapter.setSync(relativeKey, data);\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public mkdirSync(dirPath: string) {\n return this.#getStorage(dirPath)?.adapter?.mkdirSync(dirPath);\n }\n\n /**\n * Creates a directory at the specified path.\n *\n * @param path - The path of the directory to create.\n */\n public async mkdir(path: string): Promise<void> {\n return this.#getStorage(path)?.adapter?.mkdir(path);\n }\n\n /**\n * Retrieves the metadata of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to retrieve metadata for.\n * @returns The metadata of the file, or undefined if the file does not exist.\n */\n public getMetadata(pathOrId: string): VirtualFileMetadata | undefined {\n const resolved = this.resolveSync(pathOrId);\n if (resolved && this.metadata[resolved]) {\n return this.metadata[resolved];\n }\n\n return undefined;\n }\n\n /**\n * Resolves a given module ID using the configured aliases.\n *\n * @remarks\n * This function can be used to map module IDs to different paths based on the alias configuration.\n *\n * @param id - The module ID to resolve.\n * @returns The resolved module ID - after applying any configured aliases (this will be the same as the input ID if no aliases match).\n */\n public resolveAlias(id: string): string {\n let path = id;\n\n if (this.#context.config.resolve.alias) {\n if (\n Array.isArray(this.#context.config.resolve.alias) &&\n this.#context.config.resolve.alias.length > 0\n ) {\n const found = this.#context.config.resolve.alias.filter(\n alias =>\n (isSetString(alias.find) &&\n (alias.find === path || path.startsWith(`${alias.find}/`))) ||\n (isRegExp(alias.find) && alias.find.test(path))\n );\n if (found.length > 0) {\n const alias = found.reduce((ret, current) => {\n const retLength = isSetString(ret.find)\n ? ret.find.length\n : isRegExp(ret.find)\n ? ret.find.source.length\n : 0;\n const currentLength = isSetString(current.find)\n ? current.find.length\n : isRegExp(current.find)\n ? current.find.source.length\n : 0;\n\n return retLength > currentLength ? ret : current;\n });\n\n if (isSetString(alias.find)) {\n path = path.replace(\n new RegExp(`^${alias.find}`),\n alias.replacement\n );\n } else if (isRegExp(alias.find)) {\n path = path.replace(alias.find, alias.replacement);\n }\n }\n } else if (isSetObject(this.#context.config.resolve.alias)) {\n const found = Object.keys(\n this.#context.config.resolve.alias as Record<string, string>\n ).filter(key => key === path || path.startsWith(`${key}/`));\n if (found.length > 0) {\n const alias = found.reduce((ret, current) => {\n return ret.length > current.length ? ret : current;\n });\n\n path = path.replace(\n new RegExp(`^${alias}`),\n (this.#context.config.resolve.alias as Record<string, string>)[\n alias\n ]!\n );\n }\n }\n }\n\n return path;\n }\n\n /**\n * Checks if a given module ID is an alias.\n *\n * @remarks\n * This function can be used to determine if a module ID matches any configured aliases.\n *\n * @param id - The module ID to check.\n * @returns A boolean indicating whether the module ID is an alias.\n */\n public isAlias(id: string): boolean {\n const path = id;\n\n if (this.#context.config.resolve.alias) {\n if (\n Array.isArray(this.#context.config.resolve.alias) &&\n this.#context.config.resolve.alias.length > 0\n ) {\n return (\n this.#context.config.resolve.alias.filter(\n alias =>\n (isSetString(alias.find) &&\n (alias.find === path || path.startsWith(`${alias.find}/`))) ||\n (isRegExp(alias.find) && alias.find.test(path))\n ).length > 0\n );\n } else if (isSetObject(this.#context.config.resolve.alias)) {\n return (\n Object.keys(\n this.#context.config.resolve.alias as Record<string, string>\n ).filter(key => key === path || path.startsWith(`${key}/`)).length > 0\n );\n }\n }\n\n return false;\n }\n\n /**\n * Checks if a given module ID is a tsconfig path.\n *\n * @remarks\n * This function can be used to determine if a module ID matches any configured tsconfig paths.\n *\n * @param id - The module ID to check.\n * @returns A boolean indicating whether the module ID is a tsconfig path.\n */\n public isTsconfigPath(id: string): boolean {\n return !!(\n this.#context.tsconfig.options.paths &&\n Object.keys(this.#context.tsconfig.options.paths).length > 0 &&\n match(id, this.#context.resolvePatterns)\n );\n }\n\n /**\n * A helper function to resolve modules in the virtual file system (VFS).\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolvePath(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n public async resolve(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<string | undefined> {\n const origResult = await this.#innerResolve(id, importer, options);\n if (origResult && options.isFile && (await this.isDirectory(origResult))) {\n const indexResult = await this.resolve(\n joinPaths(origResult, \"index\"),\n importer,\n options\n );\n if (indexResult) {\n return indexResult;\n }\n\n if (!hasFileExtension(origResult)) {\n for (const ext of DEFAULT_EXTENSIONS) {\n const extResult = await this.resolve(\n `${origResult}.${ext}`,\n importer,\n options\n );\n if (extResult) {\n return extResult;\n }\n }\n }\n\n return undefined;\n }\n\n return origResult;\n }\n\n /**\n * A synchronous helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = context.resolveSync(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns The resolved module path.\n */\n public resolveSync(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): string | undefined {\n const origResult = this.#innerResolveSync(id, importer, options);\n if (origResult && options.isFile && this.isDirectorySync(origResult)) {\n const indexResult = this.resolveSync(\n joinPaths(origResult, \"index\"),\n importer,\n options\n );\n if (indexResult) {\n return indexResult;\n }\n\n if (!hasFileExtension(origResult)) {\n for (const ext of DEFAULT_EXTENSIONS) {\n const extResult = this.resolveSync(\n `${origResult}.${ext}`,\n importer,\n options\n );\n if (extResult) {\n return extResult;\n }\n }\n }\n\n return undefined;\n }\n\n return origResult;\n }\n\n /**\n * Disposes of the virtual file system (VFS) by saving its state to disk.\n */\n public async dispose() {\n if (!this.#isDisposed) {\n this.#isDisposed = true;\n\n this.#logger.debug(\"Disposing virtual file system...\");\n await this.remove(joinPaths(this.#context.dataPath, \"fs.bin\"));\n\n const message = new capnp.Message();\n const fs = message.initRoot(FileSystem);\n\n const storage = fs._initStorage(Object.keys(this.#paths).length);\n await Promise.all(\n Object.values(this.#paths).map(async (path, index) => {\n const code = await this.read(path);\n\n const fd = storage.get(index);\n fd.path = path;\n fd.code = code || \"\";\n })\n );\n\n const ids = fs._initIds(Object.keys(this.#ids).length);\n Object.entries(this.#ids)\n .filter(([, id]) => id)\n .forEach(([path, id], index) => {\n const fileId = ids.get(index);\n fileId.id = id;\n fileId.path = path;\n });\n\n const metadata = fs._initMetadata(Object.keys(this.#metadata).length);\n Object.entries(this.#metadata)\n .filter(([, value]) => value)\n .forEach(([id, value], index) => {\n const fileMetadata = metadata.get(index);\n fileMetadata.id = id;\n fileMetadata.type = value.type;\n fileMetadata.timestamp = value.timestamp ?? Date.now();\n\n if (value.properties) {\n const props = fileMetadata._initProperties(\n Object.keys(value.properties).length\n );\n Object.entries(value.properties)\n .filter(([, val]) => isSetString(val))\n .forEach(([key, val], index) => {\n const prop = props.get(index);\n prop.key = key;\n prop.value = val!;\n });\n }\n });\n\n await writeFileBuffer(\n joinPaths(this.#context.dataPath, \"fs.bin\"),\n message.toArrayBuffer()\n );\n\n if (!this.#context.config.skipCache) {\n this.resolverCache.save(true);\n }\n\n await Promise.all(\n this.#getStorages().map(async storage => storage.adapter.dispose())\n );\n\n this.#logger.trace(\"Virtual file system has been disposed.\");\n }\n }\n\n /**\n * Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.\n *\n * @remarks\n * This method is automatically called when the VFS instance is used within a `using` block, or can be manually invoked to ensure that the VFS state is saved and resources are cleaned up properly.\n */\n public async [Symbol.asyncDispose]() {\n return this.dispose();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,SAAS,WAAW,MAAoC;CACtD,OAAO,YAAY,MAAM,MAAM,SAAS,KAAK,GAAG,CAAC,CAAC,QAAQ,cAAc,EAAE,CAAC;AAC7E;;;;;;;;AASA,SAAS,UAAU,IAAY,SAAS,cAAuB;CAC7D,OAAO,GAAG,QAAQ,QAAQ,EAAE,CAAC,CAAC,WAAW,GAAG,OAAO,QAAQ,MAAM,EAAE,GAAG;AACxE;;;;;;;;AASA,SAAS,YAAY,IAAY,SAAS,cAAsB;CAM9D,OAAO,iBAAiB,WAAW,EAAE,CAAC,CAAC,CACpC,QAAQ,QAAQ,EAAE,CAAC,CACnB,QAAQ,gBAAgB,EAAE,CAAC,CAC3B,QAAQ,IAAI,OAAO,IAAI,OAAO,QAAQ,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE;AAC5D;;;;;;;;;AA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,MAAM,IAAI,KAAK;MAC5B,KAAK,MAAM;MACX,KAAK,QAAQ;KACf,CAAC;IACL;GACF,CAAC;GAEH,MAAM,gBACJ,UAAU,KAAKN,SAAS,UAAU,QAAQ,GAC1C,QAAQ,cAAc,CACxB;GAEA,IAAI,CAAC,KAAKA,SAAS,OAAO,WACxB,KAAK,cAAc,KAAK,IAAI;GAG9B,MAAM,QAAQ,IACZ,KAAKU,aAAa,CAAC,CAAC,IAAI,OAAM,YAAW,QAAQ,QAAQ,QAAQ,CAAC,CACpE;GAEA,KAAKL,QAAQ,MAAM,wCAAwC;EAC7D;CACF;;;;;;;CAQA,OAAc,OAAO,gBAAgB;EACnC,OAAO,KAAK,QAAQ;CACtB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/core",
3
- "version": "0.48.49",
3
+ "version": "0.48.51",
4
4
  "private": false,
5
5
  "description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
6
6
  "homepage": "https://stormsoftware.com",
@@ -327,8 +327,8 @@
327
327
  "@donedeal0/superdiff": "^3.2.0",
328
328
  "@jridgewell/sourcemap-codec": "^1.5.5",
329
329
  "@rolldown/pluginutils": "1.0.0-rc.18",
330
- "@storm-software/config": "^1.137.72",
331
- "@storm-software/config-tools": "^1.190.40",
330
+ "@storm-software/config": "^1.137.78",
331
+ "@storm-software/config-tools": "^1.190.46",
332
332
  "@stryke/capnp": "^0.12.111",
333
333
  "@stryke/convert": "^0.7.15",
334
334
  "@stryke/env": "^0.20.102",
@@ -357,23 +357,23 @@
357
357
  "oxc-resolver": "^11.20.0",
358
358
  "prettier": "^3.8.3",
359
359
  "ts-morph": "^27.0.2",
360
- "undici": "^7.27.1",
360
+ "undici": "^7.27.2",
361
361
  "unplugin": "^3.0.0",
362
362
  "unplugin-combine": "^2.4.0"
363
363
  },
364
364
  "devDependencies": {
365
- "@storm-software/testing-tools": "^1.119.193",
365
+ "@storm-software/testing-tools": "^1.119.199",
366
366
  "@stryke/types": "^0.12.12",
367
367
  "@types/bun": "^1.3.14",
368
368
  "@types/diff-match-patch": "^1.0.36",
369
- "@types/node": "^25.9.1",
369
+ "@types/node": "^25.9.2",
370
370
  "@types/semver": "^7.7.1",
371
371
  "bun-types-no-globals": "^1.3.11",
372
372
  "prettier-plugin-organize-imports": "^4.3.0",
373
373
  "tsdown": "^0.22.2",
374
374
  "typescript": "^6.0.3",
375
- "undici-types": "^7.27.1"
375
+ "undici-types": "^7.27.2"
376
376
  },
377
377
  "publishConfig": { "access": "public" },
378
- "gitHead": "157c1b4b9897ac88c7b753b0d5a01de30088f169"
378
+ "gitHead": "4018d378d61fc1417848f40c42af8c414b7c67e9"
379
379
  }