powerlines 0.23.9 → 0.24.0

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.
Files changed (273) hide show
  1. package/dist/{api-5H3zEedD.d.ts → api-C32Buv5_.d.ts} +1 -1
  2. package/dist/{api-B77aqxGC.d.cts → api-wzd5AREv.d.cts} +1 -1
  3. package/dist/api.cjs +2 -2
  4. package/dist/api.d.cts +4 -2
  5. package/dist/api.d.ts +4 -2
  6. package/dist/api.js +1 -1
  7. package/dist/astro.cjs +4 -4
  8. package/dist/astro.d.cts +3 -1
  9. package/dist/astro.d.ts +3 -1
  10. package/dist/astro.js +3 -3
  11. package/dist/babel-types.d.ts +292 -0
  12. package/dist/chunk-2TWFBWKA.cjs +133 -0
  13. package/dist/{chunk-UYJXRMS3.js → chunk-7V3LWCLB.js} +1 -1
  14. package/dist/chunk-EXQM3KGH.js +130 -0
  15. package/dist/{chunk-6ZKM7WOB.cjs → chunk-FGH3MZTQ.cjs} +535 -659
  16. package/dist/{chunk-ITL6JGKX.cjs → chunk-FPB2O7FD.cjs} +2 -2
  17. package/dist/{chunk-KOBCKTHY.js → chunk-H74SWU2C.js} +1 -1
  18. package/dist/{chunk-2QLM4MYP.cjs → chunk-HTGCHSLH.cjs} +2 -2
  19. package/dist/{chunk-G5K3I7JU.cjs → chunk-TIBYAWZZ.cjs} +2 -2
  20. package/dist/{chunk-S47BU5QR.js → chunk-ZEE73BCY.js} +1 -1
  21. package/dist/{chunk-FDEGM4CR.js → chunk-ZT2J55YE.js} +538 -659
  22. package/dist/config.d.cts +3 -1
  23. package/dist/config.d.ts +3 -1
  24. package/dist/esbuild.cjs +6 -6
  25. package/dist/esbuild.d.cts +3 -1
  26. package/dist/esbuild.d.ts +3 -1
  27. package/dist/esbuild.js +3 -3
  28. package/dist/farm.cjs +3 -3
  29. package/dist/farm.d.cts +3 -1
  30. package/dist/farm.d.ts +3 -1
  31. package/dist/farm.js +2 -2
  32. package/dist/index.cjs +11 -23
  33. package/dist/index.d.cts +6 -135
  34. package/dist/index.d.ts +6 -135
  35. package/dist/index.js +2 -2
  36. package/dist/lib/{api-Cm51oVbC.d.cts → api-BRMITKt-.d.cts} +1 -1
  37. package/dist/lib/{api-mja4jirh.d.ts → api-CDUN9en8.d.ts} +1 -1
  38. package/dist/lib/build/esbuild.d.cts +3 -1
  39. package/dist/lib/build/esbuild.d.ts +3 -1
  40. package/dist/lib/build/index.d.cts +5 -3
  41. package/dist/lib/build/index.d.ts +5 -3
  42. package/dist/lib/build/rolldown.d.cts +3 -1
  43. package/dist/lib/build/rolldown.d.ts +3 -1
  44. package/dist/lib/build/rollup.d.cts +3 -1
  45. package/dist/lib/build/rollup.d.ts +3 -1
  46. package/dist/lib/build/rspack.d.cts +3 -1
  47. package/dist/lib/build/rspack.d.ts +3 -1
  48. package/dist/lib/build/tsup.d.cts +3 -1
  49. package/dist/lib/build/tsup.d.ts +3 -1
  50. package/dist/lib/build/unbuild.d.cts +5 -3
  51. package/dist/lib/build/unbuild.d.ts +5 -3
  52. package/dist/lib/build/vite.d.cts +3 -1
  53. package/dist/lib/build/vite.d.ts +3 -1
  54. package/dist/lib/build/webpack.d.cts +3 -1
  55. package/dist/lib/build/webpack.d.ts +3 -1
  56. package/dist/lib/{chunk-52VDUP5J.js → chunk-6I5PL7H2.js} +5 -17
  57. package/dist/lib/{chunk-UPVFKXB7.cjs → chunk-6PPZCPME.cjs} +1 -2
  58. package/dist/lib/{chunk-OI7EHXNE.js → chunk-7CVPZOH4.js} +3 -3
  59. package/dist/lib/{chunk-7XHBIYIN.cjs → chunk-7VJ42H2I.cjs} +0 -16
  60. package/dist/lib/{chunk-SEWUUTNA.js → chunk-A2NFSQ5K.js} +1 -1
  61. package/dist/lib/{chunk-B3DJ4CXY.cjs → chunk-AA6RBP44.cjs} +10 -10
  62. package/dist/lib/{chunk-BGGENJH4.js → chunk-CGRHZJY5.js} +42 -83
  63. package/dist/lib/{chunk-AHONHQGB.js → chunk-DFW5FGEO.js} +1 -1
  64. package/dist/lib/{chunk-VL63QEPF.cjs → chunk-DUZJ7ZF2.cjs} +2 -2
  65. package/dist/lib/{chunk-EFYMNU53.cjs → chunk-EV357RFB.cjs} +5 -17
  66. package/dist/lib/{chunk-YH5GOJS3.js → chunk-FQLZZYYO.js} +1 -16
  67. package/dist/lib/{chunk-54XNJQTH.js → chunk-HAXL7QE7.js} +3 -3
  68. package/dist/lib/chunk-K3NBD5LL.cjs +75 -0
  69. package/dist/lib/{chunk-63MH3ERQ.js → chunk-KFWMKDJQ.js} +395 -591
  70. package/dist/lib/{chunk-3KR6TYGW.cjs → chunk-MS3CD2U6.cjs} +52 -94
  71. package/dist/lib/{chunk-LQEGZT5U.cjs → chunk-RNHKEPFD.cjs} +397 -594
  72. package/dist/lib/{chunk-4EIXDLFP.cjs → chunk-SAS5EPBD.cjs} +7 -5
  73. package/dist/lib/{chunk-EUDKQWSB.js → chunk-VHLINWXG.js} +1 -2
  74. package/dist/lib/{chunk-SMZ672RP.cjs → chunk-VMLQATMA.cjs} +6 -6
  75. package/dist/lib/{chunk-IBPA3VN5.cjs → chunk-WUYK74EH.cjs} +3 -3
  76. package/dist/lib/chunk-XBM7FHNK.js +68 -0
  77. package/dist/lib/{chunk-RD5AUWXN.js → chunk-YQ3ODCHV.js} +7 -5
  78. package/dist/lib/{config-BnJpgcGr.d.cts → config-D8KrE7SZ.d.cts} +109 -35
  79. package/dist/lib/{config-7Q2dBjJE.d.ts → config-DBIFdRoq.d.ts} +109 -35
  80. package/dist/lib/config-file.cjs +3 -3
  81. package/dist/lib/config-file.d.cts +3 -1
  82. package/dist/lib/config-file.d.ts +3 -1
  83. package/dist/lib/config-file.js +1 -1
  84. package/dist/lib/contexts/api-context.cjs +7 -6
  85. package/dist/lib/contexts/api-context.d.cts +5 -3
  86. package/dist/lib/contexts/api-context.d.ts +5 -3
  87. package/dist/lib/contexts/api-context.js +6 -5
  88. package/dist/lib/contexts/context.cjs +5 -4
  89. package/dist/lib/contexts/context.d.cts +47 -4
  90. package/dist/lib/contexts/context.d.ts +47 -4
  91. package/dist/lib/contexts/context.js +4 -3
  92. package/dist/lib/contexts/environment-context.cjs +6 -5
  93. package/dist/lib/contexts/environment-context.d.cts +5 -3
  94. package/dist/lib/contexts/environment-context.d.ts +5 -3
  95. package/dist/lib/contexts/environment-context.js +5 -4
  96. package/dist/lib/contexts/index.cjs +9 -8
  97. package/dist/lib/contexts/index.d.cts +5 -3
  98. package/dist/lib/contexts/index.d.ts +5 -3
  99. package/dist/lib/contexts/index.js +6 -5
  100. package/dist/lib/contexts/plugin-context.d.cts +5 -3
  101. package/dist/lib/contexts/plugin-context.d.ts +5 -3
  102. package/dist/lib/entry.d.cts +3 -1
  103. package/dist/lib/entry.d.ts +3 -1
  104. package/dist/lib/index.cjs +49 -59
  105. package/dist/lib/index.d.cts +68 -49
  106. package/dist/lib/index.d.ts +68 -49
  107. package/dist/lib/index.js +14 -16
  108. package/dist/lib/{internal-BEygquYh.d.ts → internal-1qCyw7bA.d.ts} +2 -2
  109. package/dist/lib/{internal-BeR8fOB1.d.cts → internal-CaGANOWK.d.cts} +2 -2
  110. package/dist/lib/logger.d.cts +3 -1
  111. package/dist/lib/logger.d.ts +3 -1
  112. package/dist/lib/typescript/compiler-host.cjs +7 -7
  113. package/dist/lib/typescript/compiler-host.d.cts +3 -1
  114. package/dist/lib/typescript/compiler-host.d.ts +3 -1
  115. package/dist/lib/typescript/compiler-host.js +6 -6
  116. package/dist/lib/typescript/import-transformer.cjs +1 -1
  117. package/dist/lib/typescript/import-transformer.d.cts +3 -1
  118. package/dist/lib/typescript/import-transformer.d.ts +3 -1
  119. package/dist/lib/typescript/import-transformer.js +1 -1
  120. package/dist/lib/typescript/index.cjs +8 -8
  121. package/dist/lib/typescript/index.d.cts +3 -2
  122. package/dist/lib/typescript/index.d.ts +3 -2
  123. package/dist/lib/typescript/index.js +2 -2
  124. package/dist/lib/typescript/program.cjs +6 -6
  125. package/dist/lib/typescript/program.d.cts +3 -1
  126. package/dist/lib/typescript/program.d.ts +3 -1
  127. package/dist/lib/typescript/program.js +1 -1
  128. package/dist/lib/typescript/ts-morph.cjs +2 -2
  129. package/dist/lib/typescript/ts-morph.d.cts +5 -3
  130. package/dist/lib/typescript/ts-morph.d.ts +5 -3
  131. package/dist/lib/typescript/ts-morph.js +1 -1
  132. package/dist/lib/unplugin/factory.cjs +8 -8
  133. package/dist/lib/unplugin/factory.d.cts +5 -3
  134. package/dist/lib/unplugin/factory.d.ts +5 -3
  135. package/dist/lib/unplugin/factory.js +7 -7
  136. package/dist/lib/unplugin/helpers.d.cts +3 -1
  137. package/dist/lib/unplugin/helpers.d.ts +3 -1
  138. package/dist/lib/unplugin/index.cjs +13 -13
  139. package/dist/lib/unplugin/index.d.cts +6 -4
  140. package/dist/lib/unplugin/index.d.ts +6 -4
  141. package/dist/lib/unplugin/index.js +9 -9
  142. package/dist/lib/unplugin/plugin.cjs +2 -3
  143. package/dist/lib/unplugin/plugin.d.cts +6 -4
  144. package/dist/lib/unplugin/plugin.d.ts +6 -4
  145. package/dist/lib/unplugin/plugin.js +1 -2
  146. package/dist/lib/{unplugin-CbbNDduM.d.ts → unplugin-CEeJqADD.d.ts} +2 -2
  147. package/dist/lib/{unplugin-ppAOzR__.d.cts → unplugin-bUSyjd0S.d.cts} +2 -2
  148. package/dist/lib/utilities/bundle.cjs +2 -3
  149. package/dist/lib/utilities/bundle.d.cts +3 -1
  150. package/dist/lib/utilities/bundle.d.ts +3 -1
  151. package/dist/lib/utilities/bundle.js +1 -2
  152. package/dist/lib/utilities/cache.d.cts +3 -1
  153. package/dist/lib/utilities/cache.d.ts +3 -1
  154. package/dist/lib/utilities/file-header.d.cts +3 -1
  155. package/dist/lib/utilities/file-header.d.ts +3 -1
  156. package/dist/lib/utilities/index.cjs +21 -30
  157. package/dist/lib/utilities/index.d.cts +4 -3
  158. package/dist/lib/utilities/index.d.ts +4 -3
  159. package/dist/lib/utilities/index.js +5 -6
  160. package/dist/lib/utilities/meta.cjs +7 -11
  161. package/dist/lib/utilities/meta.d.cts +4 -3
  162. package/dist/lib/utilities/meta.d.ts +4 -3
  163. package/dist/lib/utilities/meta.js +1 -1
  164. package/dist/lib/utilities/resolve.cjs +3 -4
  165. package/dist/lib/utilities/resolve.d.cts +3 -1
  166. package/dist/lib/utilities/resolve.d.ts +3 -1
  167. package/dist/lib/utilities/resolve.js +2 -3
  168. package/dist/lib/utilities/source-file.d.cts +3 -1
  169. package/dist/lib/utilities/source-file.d.ts +3 -1
  170. package/dist/lib/utilities/source-map.d.cts +3 -1
  171. package/dist/lib/utilities/source-map.d.ts +3 -1
  172. package/dist/lib/utilities/worker.d.cts +3 -1
  173. package/dist/lib/utilities/worker.d.ts +3 -1
  174. package/dist/lib/utilities/write-file.d.cts +3 -1
  175. package/dist/lib/utilities/write-file.d.ts +3 -1
  176. package/dist/next.cjs +4 -4
  177. package/dist/next.js +3 -3
  178. package/dist/nuxt.cjs +6 -6
  179. package/dist/nuxt.js +4 -4
  180. package/dist/plugin-utils/{context-Cg11S-CE.d.ts → context-BITGF5LZ.d.cts} +118 -39
  181. package/dist/plugin-utils/{context-Cg11S-CE.d.cts → context-BITGF5LZ.d.ts} +118 -39
  182. package/dist/plugin-utils/context-helpers.d.cts +4 -1
  183. package/dist/plugin-utils/context-helpers.d.ts +4 -1
  184. package/dist/plugin-utils/enforce.d.cts +4 -1
  185. package/dist/plugin-utils/enforce.d.ts +4 -1
  186. package/dist/plugin-utils/extend.d.cts +4 -1
  187. package/dist/plugin-utils/extend.d.ts +4 -1
  188. package/dist/plugin-utils/get-config-path.d.cts +4 -1
  189. package/dist/plugin-utils/get-config-path.d.ts +4 -1
  190. package/dist/plugin-utils/helpers.d.cts +4 -1
  191. package/dist/plugin-utils/helpers.d.ts +4 -1
  192. package/dist/plugin-utils/index.d.cts +4 -1
  193. package/dist/plugin-utils/index.d.ts +4 -1
  194. package/dist/plugin-utils/merge.d.cts +4 -1
  195. package/dist/plugin-utils/merge.d.ts +4 -1
  196. package/dist/plugin-utils/paths.d.cts +4 -1
  197. package/dist/plugin-utils/paths.d.ts +4 -1
  198. package/dist/{resolved-B3BSdXCt.d.ts → resolved-BABoCnXm.d.ts} +43 -1
  199. package/dist/{resolved-DGrpILrS.d.cts → resolved-CSqGKlA5.d.cts} +43 -1
  200. package/dist/rolldown.cjs +3 -3
  201. package/dist/rolldown.d.cts +3 -1
  202. package/dist/rolldown.d.ts +3 -1
  203. package/dist/rolldown.js +2 -2
  204. package/dist/rollup.cjs +3 -3
  205. package/dist/rollup.d.cts +3 -1
  206. package/dist/rollup.d.ts +3 -1
  207. package/dist/rollup.js +2 -2
  208. package/dist/rspack.cjs +3 -3
  209. package/dist/rspack.d.cts +3 -1
  210. package/dist/rspack.d.ts +3 -1
  211. package/dist/rspack.js +2 -2
  212. package/dist/tsup.cjs +4 -4
  213. package/dist/tsup.js +3 -3
  214. package/dist/types/api.d.cts +4 -2
  215. package/dist/types/api.d.ts +4 -2
  216. package/dist/types/babel.d.cts +3 -1
  217. package/dist/types/babel.d.ts +3 -1
  218. package/dist/types/commands.d.cts +3 -1
  219. package/dist/types/commands.d.ts +3 -1
  220. package/dist/types/config.d.cts +3 -1
  221. package/dist/types/config.d.ts +3 -1
  222. package/dist/types/context.d.cts +3 -1
  223. package/dist/types/context.d.ts +3 -1
  224. package/dist/types/fs.d.cts +68 -36
  225. package/dist/types/fs.d.ts +68 -36
  226. package/dist/types/hooks.d.cts +3 -1
  227. package/dist/types/hooks.d.ts +3 -1
  228. package/dist/types/index.d.cts +5 -3
  229. package/dist/types/index.d.ts +5 -3
  230. package/dist/types/internal.d.cts +4 -2
  231. package/dist/types/internal.d.ts +4 -2
  232. package/dist/types/plugin.d.cts +3 -1
  233. package/dist/types/plugin.d.ts +3 -1
  234. package/dist/types/resolved.d.cts +3 -1
  235. package/dist/types/resolved.d.ts +3 -1
  236. package/dist/types/unplugin.d.cts +4 -2
  237. package/dist/types/unplugin.d.ts +4 -2
  238. package/dist/unloader.cjs +3 -3
  239. package/dist/unloader.d.cts +3 -1
  240. package/dist/unloader.d.ts +3 -1
  241. package/dist/unloader.js +2 -2
  242. package/dist/unplugin.cjs +12 -28
  243. package/dist/unplugin.d.cts +104 -31
  244. package/dist/unplugin.d.ts +104 -31
  245. package/dist/unplugin.js +10 -23
  246. package/dist/vite.cjs +6 -6
  247. package/dist/vite.d.cts +3 -1
  248. package/dist/vite.d.ts +3 -1
  249. package/dist/vite.js +3 -3
  250. package/dist/webpack.cjs +6 -6
  251. package/dist/webpack.d.cts +3 -1
  252. package/dist/webpack.d.ts +3 -1
  253. package/dist/webpack.js +3 -3
  254. package/package.json +16 -14
  255. package/schemas/fs.capnp +35 -38
  256. package/dist/chunk-FJWXCUGQ.cjs +0 -234
  257. package/dist/chunk-RKMUBSYG.js +0 -230
  258. package/dist/lib/chunk-7JAGT5GC.cjs +0 -74
  259. package/dist/lib/chunk-G7S5PIAC.js +0 -89
  260. package/dist/lib/chunk-MZJWK36Q.cjs +0 -37
  261. package/dist/lib/chunk-NWAD7K4D.js +0 -35
  262. package/dist/lib/chunk-PVCAB6BZ.js +0 -67
  263. package/dist/lib/chunk-ZBDVQVUK.cjs +0 -91
  264. package/dist/lib/unplugin/resolve-id.cjs +0 -11
  265. package/dist/lib/unplugin/resolve-id.d.cts +0 -57
  266. package/dist/lib/unplugin/resolve-id.d.ts +0 -57
  267. package/dist/lib/unplugin/resolve-id.js +0 -2
  268. package/dist/lib/utilities/resolve-path.cjs +0 -11
  269. package/dist/lib/utilities/resolve-path.d.cts +0 -40
  270. package/dist/lib/utilities/resolve-path.d.ts +0 -40
  271. package/dist/lib/utilities/resolve-path.js +0 -2
  272. /package/dist/lib/{chunk-HMO3LAYL.js → chunk-I2DQRMX3.js} +0 -0
  273. /package/dist/lib/{chunk-EJ25PQEL.cjs → chunk-YK4PYVLM.cjs} +0 -0
@@ -1,7 +1,8 @@
1
- import { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash } from './chunk-YH5GOJS3.js';
2
- import { loadWorkspaceConfig, loadUserConfigFile } from './chunk-PVCAB6BZ.js';
1
+ import { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash } from './chunk-FQLZZYYO.js';
2
+ import { createProgram } from './chunk-YQ3ODCHV.js';
3
+ import { loadWorkspaceConfig, loadUserConfigFile } from './chunk-XBM7FHNK.js';
3
4
  import { extendLog, createLog } from './chunk-ENRLU4UR.js';
4
- import { resolveEntriesSync, getUniqueEntries } from './chunk-XZFEHPYE.js';
5
+ import { resolveEntriesSync, getUniqueEntries, replacePathTokens } from './chunk-XZFEHPYE.js';
5
6
  import { __name } from './chunk-SHUYVCID.js';
6
7
  import { LogLevelLabel } from '@storm-software/config-tools/types';
7
8
  import { toArray } from '@stryke/convert/to-array';
@@ -9,7 +10,7 @@ import { getEnvPaths } from '@stryke/env/get-env-paths';
9
10
  import { existsSync } from '@stryke/fs/exists';
10
11
  import { relativeToWorkspaceRoot } from '@stryke/fs/get-workspace-root';
11
12
  import { readJsonFile } from '@stryke/fs/json';
12
- import { resolvePackage } from '@stryke/fs/resolve';
13
+ import { getResolutionCombinations, resolve, resolveSync, resolvePackage } from '@stryke/fs/resolve';
13
14
  import { hashDirectory } from '@stryke/hash/hash-files';
14
15
  import { murmurhash } from '@stryke/hash/murmurhash';
15
16
  import { getUnique } from '@stryke/helpers/get-unique';
@@ -25,6 +26,7 @@ import { isSetObject } from '@stryke/type-checks/is-set-object';
25
26
  import { isSetString } from '@stryke/type-checks/is-set-string';
26
27
  import { isString } from '@stryke/type-checks/is-string';
27
28
  import { uuid } from '@stryke/unique-id/uuid';
29
+ import { tsconfigPathsToRegExp, match } from 'bundle-require';
28
30
  import defu2 from 'defu';
29
31
  import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
30
32
  import { createJiti } from 'jiti';
@@ -33,9 +35,11 @@ import { isUndefined } from '@stryke/type-checks/is-undefined';
33
35
  import * as $ from '@stryke/capnp';
34
36
  import { bufferToString } from '@stryke/convert/buffer-to-string';
35
37
  import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
36
- import { findFileDotExtensionSafe, findFilePath } from '@stryke/path/file-path-fns';
38
+ import { toAbsolutePath } from '@stryke/path/correct-path';
39
+ import { findFilePath, findFileDotExtensionSafe } from '@stryke/path/file-path-fns';
37
40
  import { prettyBytes } from '@stryke/string-format/pretty-bytes';
38
41
  import { isBuffer } from '@stryke/type-checks/is-buffer';
42
+ import { create } from 'flat-cache';
39
43
  import { Blob } from 'node:buffer';
40
44
  import _fs from 'node:fs';
41
45
  import { resolveConfig, format } from 'prettier';
@@ -45,6 +49,7 @@ import { Union } from 'unionfs';
45
49
 
46
50
  function resolveOptions(options) {
47
51
  return defu2(options, {
52
+ debug: options.logLevel === "trace",
48
53
  interopDefault: true,
49
54
  fsCache: options.mode !== "development" ? joinPaths$1(options.cacheDir, "jiti") : false,
50
55
  moduleCache: options.mode !== "development"
@@ -231,187 +236,6 @@ var FileMetadata = class _FileMetadata extends $.Struct {
231
236
  return "FileMetadata_" + super.toString();
232
237
  }
233
238
  };
234
- var ChunkData = class extends $.Struct {
235
- static {
236
- __name(this, "ChunkData");
237
- }
238
- static _capnp = {
239
- displayName: "ChunkData",
240
- id: "84076f13b057f83a",
241
- size: new $.ObjectSize(8, 4)
242
- };
243
- /**
244
- * An additional name for the file.
245
- *
246
- */
247
- get id() {
248
- return $.utils.getText(0, this);
249
- }
250
- set id(value) {
251
- $.utils.setText(0, value, this);
252
- }
253
- /**
254
- * Files that are implicitly loaded after one of the specified files.
255
- *
256
- */
257
- get name() {
258
- return $.utils.getText(1, this);
259
- }
260
- set name(value) {
261
- $.utils.setText(1, value, this);
262
- }
263
- _adoptImplicitlyLoadedAfterOneOf(value) {
264
- $.utils.adopt(value, $.utils.getPointer(2, this));
265
- }
266
- _disownImplicitlyLoadedAfterOneOf() {
267
- return $.utils.disown(this.implicitlyLoadedAfterOneOf);
268
- }
269
- /**
270
- * The importer of the file.
271
- *
272
- */
273
- get implicitlyLoadedAfterOneOf() {
274
- return $.utils.getList(2, $.TextList, this);
275
- }
276
- _hasImplicitlyLoadedAfterOneOf() {
277
- return !$.utils.isNull($.utils.getPointer(2, this));
278
- }
279
- _initImplicitlyLoadedAfterOneOf(length) {
280
- return $.utils.initList(2, $.TextList, length, this);
281
- }
282
- set implicitlyLoadedAfterOneOf(value) {
283
- $.utils.copyFrom(value, $.utils.getPointer(2, this));
284
- }
285
- /**
286
- * The signature preservation mode for the file.
287
- *
288
- */
289
- get importer() {
290
- return $.utils.getText(3, this);
291
- }
292
- set importer(value) {
293
- $.utils.setText(3, value, this);
294
- }
295
- get preserveSignature() {
296
- return $.utils.getUint16(0, this);
297
- }
298
- set preserveSignature(value) {
299
- $.utils.setUint16(0, value, this);
300
- }
301
- toString() {
302
- return "ChunkData_" + super.toString();
303
- }
304
- };
305
- var PrebuiltData = class extends $.Struct {
306
- static {
307
- __name(this, "PrebuiltData");
308
- }
309
- static _capnp = {
310
- displayName: "PrebuiltData",
311
- id: "c5b1a6ca696328ee",
312
- size: new $.ObjectSize(0, 4)
313
- };
314
- /**
315
- * An additional name for the file.
316
- *
317
- */
318
- get id() {
319
- return $.utils.getText(0, this);
320
- }
321
- set id(value) {
322
- $.utils.setText(0, value, this);
323
- }
324
- /**
325
- * The file exports.
326
- *
327
- */
328
- get name() {
329
- return $.utils.getText(1, this);
330
- }
331
- set name(value) {
332
- $.utils.setText(1, value, this);
333
- }
334
- _adoptExports(value) {
335
- $.utils.adopt(value, $.utils.getPointer(2, this));
336
- }
337
- _disownExports() {
338
- return $.utils.disown(this.exports);
339
- }
340
- /**
341
- * The source map for the file.
342
- *
343
- */
344
- get exports() {
345
- return $.utils.getList(2, $.TextList, this);
346
- }
347
- _hasExports() {
348
- return !$.utils.isNull($.utils.getPointer(2, this));
349
- }
350
- _initExports(length) {
351
- return $.utils.initList(2, $.TextList, length, this);
352
- }
353
- set exports(value) {
354
- $.utils.copyFrom(value, $.utils.getPointer(2, this));
355
- }
356
- get map() {
357
- return $.utils.getText(3, this);
358
- }
359
- set map(value) {
360
- $.utils.setText(3, value, this);
361
- }
362
- toString() {
363
- return "PrebuiltData_" + super.toString();
364
- }
365
- };
366
- var AssetData = class extends $.Struct {
367
- static {
368
- __name(this, "AssetData");
369
- }
370
- static _capnp = {
371
- displayName: "AssetData",
372
- id: "da660c6c1fa4c830",
373
- size: new $.ObjectSize(8, 3)
374
- };
375
- /**
376
- * An additional name for the file.
377
- *
378
- */
379
- get id() {
380
- return $.utils.getText(0, this);
381
- }
382
- set id(value) {
383
- $.utils.setText(0, value, this);
384
- }
385
- /**
386
- * Indicates whether the file needs a code reference.
387
- *
388
- */
389
- get name() {
390
- return $.utils.getText(1, this);
391
- }
392
- set name(value) {
393
- $.utils.setText(1, value, this);
394
- }
395
- /**
396
- * The original file name before any transformations.
397
- *
398
- */
399
- get needsCodeReference() {
400
- return $.utils.getBit(0, this);
401
- }
402
- set needsCodeReference(value) {
403
- $.utils.setBit(0, value, this);
404
- }
405
- get originalFileName() {
406
- return $.utils.getText(2, this);
407
- }
408
- set originalFileName(value) {
409
- $.utils.setText(2, value, this);
410
- }
411
- toString() {
412
- return "AssetData_" + super.toString();
413
- }
414
- };
415
239
  var FileId = class extends $.Struct {
416
240
  static {
417
241
  __name(this, "FileId");
@@ -477,14 +301,11 @@ var FileSystem = class _FileSystem extends $.Struct {
477
301
  static _capnp = {
478
302
  displayName: "FileSystem",
479
303
  id: "ae0c23d43e56abcf",
480
- size: new $.ObjectSize(0, 6)
304
+ size: new $.ObjectSize(0, 3)
481
305
  };
482
306
  static _Ids;
483
307
  static _Files;
484
308
  static _Metadata;
485
- static _Assets;
486
- static _Chunks;
487
- static _Prebuilt;
488
309
  _adoptIds(value) {
489
310
  $.utils.adopt(value, $.utils.getPointer(0, this));
490
311
  }
@@ -539,60 +360,6 @@ var FileSystem = class _FileSystem extends $.Struct {
539
360
  set metadata(value) {
540
361
  $.utils.copyFrom(value, $.utils.getPointer(2, this));
541
362
  }
542
- _adoptAssets(value) {
543
- $.utils.adopt(value, $.utils.getPointer(3, this));
544
- }
545
- _disownAssets() {
546
- return $.utils.disown(this.assets);
547
- }
548
- get assets() {
549
- return $.utils.getList(3, _FileSystem._Assets, this);
550
- }
551
- _hasAssets() {
552
- return !$.utils.isNull($.utils.getPointer(3, this));
553
- }
554
- _initAssets(length) {
555
- return $.utils.initList(3, _FileSystem._Assets, length, this);
556
- }
557
- set assets(value) {
558
- $.utils.copyFrom(value, $.utils.getPointer(3, this));
559
- }
560
- _adoptChunks(value) {
561
- $.utils.adopt(value, $.utils.getPointer(4, this));
562
- }
563
- _disownChunks() {
564
- return $.utils.disown(this.chunks);
565
- }
566
- get chunks() {
567
- return $.utils.getList(4, _FileSystem._Chunks, this);
568
- }
569
- _hasChunks() {
570
- return !$.utils.isNull($.utils.getPointer(4, this));
571
- }
572
- _initChunks(length) {
573
- return $.utils.initList(4, _FileSystem._Chunks, length, this);
574
- }
575
- set chunks(value) {
576
- $.utils.copyFrom(value, $.utils.getPointer(4, this));
577
- }
578
- _adoptPrebuilt(value) {
579
- $.utils.adopt(value, $.utils.getPointer(5, this));
580
- }
581
- _disownPrebuilt() {
582
- return $.utils.disown(this.prebuilt);
583
- }
584
- get prebuilt() {
585
- return $.utils.getList(5, _FileSystem._Prebuilt, this);
586
- }
587
- _hasPrebuilt() {
588
- return !$.utils.isNull($.utils.getPointer(5, this));
589
- }
590
- _initPrebuilt(length) {
591
- return $.utils.initList(5, _FileSystem._Prebuilt, length, this);
592
- }
593
- set prebuilt(value) {
594
- $.utils.copyFrom(value, $.utils.getPointer(5, this));
595
- }
596
363
  toString() {
597
364
  return "FileSystem_" + super.toString();
598
365
  }
@@ -601,9 +368,6 @@ FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
601
368
  FileSystem._Ids = $.CompositeList(FileId);
602
369
  FileSystem._Files = $.CompositeList(FileData);
603
370
  FileSystem._Metadata = $.CompositeList(FileMetadata);
604
- FileSystem._Assets = $.CompositeList(AssetData);
605
- FileSystem._Chunks = $.CompositeList(ChunkData);
606
- FileSystem._Prebuilt = $.CompositeList(PrebuiltData);
607
371
 
608
372
  // src/types/fs.ts
609
373
  var __VFS_PATCH__ = "__VFS_PATCH__";
@@ -613,13 +377,9 @@ function isBufferEncoding(options) {
613
377
  }
614
378
  __name(isBufferEncoding, "isBufferEncoding");
615
379
  function isPowerlinesWriteFileOptions(options) {
616
- return !isBufferEncoding(options) && isSetObject(options) && ("skipFormat" in options || "mode" in options && (options.mode === "fs" || options.mode === "virtual"));
380
+ return !isBufferEncoding(options) && isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
617
381
  }
618
382
  __name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
619
- function isNodeWriteFileOptions(options) {
620
- return !isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
621
- }
622
- __name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
623
383
  function isVirtualFileData(obj) {
624
384
  return !!(isSetObject(obj) && "code" in obj && obj.code);
625
385
  }
@@ -756,6 +516,18 @@ function patchFS(originalFS, vfs) {
756
516
  };
757
517
  }
758
518
  __name(patchFS, "patchFS");
519
+ function isValidId(id, prefix = "powerlines") {
520
+ return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
521
+ }
522
+ __name(isValidId, "isValidId");
523
+ function normalizeId(id, prefix = "powerlines") {
524
+ return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(toFilePath(id)), "")}`;
525
+ }
526
+ __name(normalizeId, "normalizeId");
527
+ function normalizePath(path, builtinsPath, prefix = "powerlines") {
528
+ return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
529
+ }
530
+ __name(normalizePath, "normalizePath");
759
531
  var UnifiedFS = class _UnifiedFS extends Union {
760
532
  static {
761
533
  __name(this, "UnifiedFS");
@@ -932,9 +704,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
932
704
  */
933
705
  #paths;
934
706
  /**
935
- * A map of virtual file paths to their underlying file content.
707
+ * A cache for module resolution results.
936
708
  */
937
- #cachedResolver = /* @__PURE__ */ new Map();
709
+ #resolverCache;
938
710
  /**
939
711
  * The unified volume that combines the virtual file system with the real file system.
940
712
  *
@@ -969,189 +741,35 @@ var VirtualFileSystem = class _VirtualFileSystem {
969
741
  * @returns `true` if the path exists, otherwise `false`.
970
742
  */
971
743
  #existsSync(path) {
972
- const formattedPath = this.formatPath(path);
973
- return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
974
- }
975
- /**
976
- * Builds a regular expression from a string pattern for path matching.
977
- *
978
- * @param strPattern - The string pattern to convert.
979
- * @returns A regular expression for matching paths.
980
- */
981
- #buildRegex(strPattern) {
982
- const token = "::GLOBSTAR::";
983
- return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
984
- }
985
- /**
986
- * Formats a file id by removing the file extension and prepending the runtime prefix.
987
- *
988
- * @param id - The file ID to format.
989
- * @returns The formatted file ID.
990
- */
991
- #formatId(id) {
992
- const formattedId = toFilePath(id);
993
- return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(formattedId), "")}`;
994
- }
995
- /**
996
- * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
997
- *
998
- * @param id - The id to resolve.
999
- * @returns The resolved file id if it exists, otherwise undefined.
1000
- */
1001
- #resolveId(id) {
1002
- if (this.#ids[this.#formatId(id)]) {
1003
- return this.#ids[this.#formatId(id)] || false;
1004
- }
1005
- return false;
1006
- }
1007
- /**
1008
- * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1009
- *
1010
- * @param path - The path to resolve.
1011
- * @param options - Optional parameters for resolving the path.
1012
- * @returns The resolved file path if it exists, otherwise undefined.
1013
- */
1014
- #resolvePath(path, options = {}) {
1015
- if (isAbsolutePath(path)) {
1016
- if (this.#existsSync(path)) {
1017
- return path;
1018
- }
1019
- const result = this.#checkVariants(path);
1020
- if (result) {
1021
- return result;
1022
- }
1023
- }
1024
- for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
1025
- const request = joinPaths$1(parentPath, path);
1026
- if (this.#existsSync(request)) {
1027
- return request;
1028
- }
1029
- const result = this.#checkVariants(request);
1030
- if (result) {
1031
- return result;
1032
- }
1033
- }
1034
- return false;
1035
- }
1036
- /**
1037
- * Resolves parent paths for a given request.
1038
- *
1039
- * @param request - The request path to resolve parent paths for.
1040
- * @param parents - An optional array of parent paths to consider.
1041
- * @returns An array of resolved parent paths.
1042
- */
1043
- #resolveParentPaths(request, parents = []) {
1044
- let paths = [
1045
- this.#context.workspaceConfig.workspaceRoot,
1046
- joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
1047
- ];
1048
- if (this.#context.tsconfig.options.paths) {
1049
- paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
1050
- if (path && !ret.includes(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path))) {
1051
- ret.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path));
1052
- }
1053
- return ret;
1054
- }, paths) : paths;
1055
- }
1056
- return paths.reduce((ret, path) => {
1057
- if (!ret.includes(path)) {
1058
- ret.push(path);
1059
- }
1060
- return ret;
1061
- }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1062
- }
1063
- /**
1064
- * Clears the resolver cache for a given path.
1065
- *
1066
- * @param path - The path to clear the resolver cache for.
1067
- */
1068
- #clearResolverCache(path) {
1069
- this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
744
+ return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
1070
745
  }
1071
746
  /**
1072
- * Check if the file exists with different variants (index, extensions).
747
+ * Normalizes a given module id by resolving it against the built-ins path.
1073
748
  *
1074
- * @param request - The request path to check.
1075
- * @param parentPath - An optional parent path to prepend to the request.
1076
- * @returns The file path if it exists, otherwise false.
749
+ * @param id - The module id to normalize.
750
+ * @returns The normalized module id.
1077
751
  */
1078
- #checkVariants(request, parentPath) {
1079
- const path = parentPath ? joinPaths$1(parentPath, request) : request;
1080
- let file = this.#checkExtensions(path);
1081
- if (file) {
1082
- return file;
1083
- }
1084
- file = this.#checkIndex(path);
1085
- if (file) {
1086
- return file;
1087
- }
1088
- return false;
752
+ #normalizeId(id) {
753
+ return normalizeId(id, this.#context.config.output.builtinPrefix);
1089
754
  }
1090
755
  /**
1091
- * Check if the index file exists in the given request path.
756
+ * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
1092
757
  *
1093
- * @param request - The request path to check.
1094
- * @returns The index file path if it exists, otherwise false.
758
+ * @param path - The path to normalize.
759
+ * @returns The normalized path.
1095
760
  */
1096
- #checkIndex(request) {
1097
- let file = joinPaths$1(request, "index");
1098
- if (this.#existsSync(file)) {
1099
- return file;
1100
- }
1101
- file = this.#checkExtensions(file);
1102
- if (file) {
1103
- return file;
1104
- }
1105
- return false;
761
+ #normalizePath(path) {
762
+ return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
1106
763
  }
1107
764
  /**
1108
- * Check if the file exists with different extensions.
765
+ * Builds a regular expression from a string pattern for path matching.
1109
766
  *
1110
- * @param request - The request path to check.
1111
- * @returns The file path if it exists with any of the checked extensions, otherwise false.
767
+ * @param path - The string pattern to convert.
768
+ * @returns A regular expression for matching paths.
1112
769
  */
1113
- #checkExtensions(request) {
1114
- let file = `${request}.ts`;
1115
- if (this.#existsSync(file)) {
1116
- return file;
1117
- }
1118
- file = `${request}.mts`;
1119
- if (this.#existsSync(file)) {
1120
- return file;
1121
- }
1122
- file = `${request}.cts`;
1123
- if (this.#existsSync(file)) {
1124
- return file;
1125
- }
1126
- file = `${request}.tsx`;
1127
- if (this.#existsSync(file)) {
1128
- return file;
1129
- }
1130
- file = `${request}.js`;
1131
- if (this.#existsSync(file)) {
1132
- return file;
1133
- }
1134
- file = `${request}.mjs`;
1135
- if (this.#existsSync(file)) {
1136
- return file;
1137
- }
1138
- file = `${request}.cjs`;
1139
- if (this.#existsSync(file)) {
1140
- return file;
1141
- }
1142
- file = `${request}.jsx`;
1143
- if (this.#existsSync(file)) {
1144
- return file;
1145
- }
1146
- file = `${request}.json`;
1147
- if (this.#existsSync(file)) {
1148
- return file;
1149
- }
1150
- file = `${request}.d.ts`;
1151
- if (this.#existsSync(file)) {
1152
- return file;
1153
- }
1154
- return false;
770
+ #buildRegex(path) {
771
+ const token = "::GLOBSTAR::";
772
+ return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1155
773
  }
1156
774
  /**
1157
775
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
@@ -1160,8 +778,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
1160
778
  * @returns A promise that resolves to a new virtual file system instance.
1161
779
  */
1162
780
  static async create(context) {
1163
- if (!context.config.skipCache && existsSync(joinPaths$1(context.cachePath, "fs.bin"))) {
1164
- const buffer = await readFileBuffer(joinPaths$1(context.cachePath, "fs.bin"));
781
+ if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
782
+ const buffer = await readFileBuffer(joinPaths$1(context.dataPath, "fs.bin"));
1165
783
  const message2 = new $.Message(buffer, false);
1166
784
  return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
1167
785
  }
@@ -1175,8 +793,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
1175
793
  * @returns A new virtual file system instance.
1176
794
  */
1177
795
  static createSync(context) {
1178
- if (!context.config.skipCache && existsSync(joinPaths$1(context.cachePath, "fs.bin"))) {
1179
- const buffer = readFileBufferSync(joinPaths$1(context.cachePath, "fs.bin"));
796
+ if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
797
+ const buffer = readFileBufferSync(joinPaths$1(context.dataPath, "fs.bin"));
1180
798
  const message2 = new $.Message(buffer, false);
1181
799
  return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
1182
800
  }
@@ -1187,19 +805,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
1187
805
  * A map of file ids to their metadata.
1188
806
  */
1189
807
  get metadata() {
1190
- return this.#metadata;
808
+ return new Proxy(this.#metadata, {
809
+ get: /* @__PURE__ */ __name((target, prop) => {
810
+ return target[this.#normalizeId(prop)];
811
+ }, "get")
812
+ });
1191
813
  }
1192
814
  /**
1193
- * A map of module ids to their file paths.
815
+ * A map of file paths to their module ids.
1194
816
  */
1195
817
  get ids() {
1196
- return this.#ids;
818
+ return new Proxy(this.#paths, {
819
+ get: /* @__PURE__ */ __name((target, prop) => {
820
+ return target[this.#normalizePath(prop)];
821
+ }, "get")
822
+ });
1197
823
  }
1198
824
  /**
1199
- * A map of virtual file paths to their IDs.
825
+ * A map of module ids to their file paths.
1200
826
  */
1201
827
  get paths() {
1202
- return this.#paths;
828
+ return new Proxy(this.#paths, {
829
+ get: /* @__PURE__ */ __name((target, prop) => {
830
+ return target[this.#normalizeId(prop)];
831
+ }, "get")
832
+ });
833
+ }
834
+ get resolverCache() {
835
+ if (!this.#resolverCache) {
836
+ this.#resolverCache = create({
837
+ cacheId: "module-resolution",
838
+ cacheDir: this.#context.cachePath,
839
+ ttl: 60 * 60 * 1e3,
840
+ lruSize: 5e3,
841
+ persistInterval: 100
842
+ });
843
+ }
844
+ return this.#resolverCache;
1203
845
  }
1204
846
  /**
1205
847
  * Creates a new instance of the {@link VirtualFileSystem}.
@@ -1244,17 +886,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1244
886
  * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
1245
887
  *
1246
888
  * @param pathOrId - The path or id to check.
1247
- * @param options - Optional parameters for resolving the path.
1248
889
  * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
1249
890
  */
1250
- isVirtual(pathOrId, options = {}) {
891
+ isVirtual(pathOrId, importer, options = {}) {
1251
892
  if (!pathOrId) {
1252
893
  return false;
1253
894
  }
1254
- const resolvedPath = this.resolve(pathOrId, {
1255
- ...options,
1256
- pathType: "file"
1257
- });
895
+ const resolvedPath = this.resolveSync(pathOrId, importer, options);
1258
896
  if (!resolvedPath) {
1259
897
  return false;
1260
898
  }
@@ -1264,17 +902,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1264
902
  * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
1265
903
  *
1266
904
  * @param pathOrId - The path or id to check.
1267
- * @param options - Optional parameters for resolving the path.
1268
905
  * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
1269
906
  */
1270
- isPhysical(pathOrId, options = {}) {
907
+ isPhysical(pathOrId, importer, options = {}) {
1271
908
  if (!pathOrId) {
1272
909
  return false;
1273
910
  }
1274
- const resolvedPath = this.resolve(pathOrId, {
1275
- ...options,
1276
- pathType: "file"
1277
- });
911
+ const resolvedPath = this.resolveSync(pathOrId, importer, options);
1278
912
  if (!resolvedPath) {
1279
913
  return false;
1280
914
  }
@@ -1296,16 +930,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
1296
930
  * @param path - The path to create the directory at.
1297
931
  */
1298
932
  unlinkSync(path, options) {
1299
- const formattedPath = toFilePath(path);
1300
- if (!this.isFile(formattedPath)) {
933
+ if (!this.isFile(this.#normalizePath(path))) {
1301
934
  return;
1302
935
  }
1303
- this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
1304
- this.#unifiedFS.resolveFS(path, options).unlinkSync(formattedPath);
1305
- if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1306
- delete this.metadata[this.paths[formattedPath]];
936
+ this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
937
+ this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
938
+ if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
939
+ delete this.#metadata[this.#ids[this.#normalizePath(path)]];
940
+ delete this.#ids[this.#normalizePath(path)];
941
+ delete this.#paths[this.#normalizeId(path)];
942
+ this.#resolverCache.delete(this.#normalizePath(path));
1307
943
  }
1308
- this.#clearResolverCache(formattedPath);
1309
944
  }
1310
945
  /**
1311
946
  * Removes a file in the virtual file system (VFS).
@@ -1313,19 +948,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
1313
948
  * @param path - The path to create the directory at.
1314
949
  */
1315
950
  async unlink(path, options) {
1316
- const formattedPath = toFilePath(path);
1317
- if (!this.isFile(formattedPath)) {
951
+ if (!this.isFile(this.#normalizePath(path))) {
1318
952
  return;
1319
953
  }
1320
- this.#log(LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
954
+ this.#log(LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
1321
955
  if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
1322
- await this.#unifiedFS.resolveFS(path, options).promises.unlink(formattedPath);
1323
- if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1324
- delete this.metadata[this.paths[formattedPath]];
956
+ await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
957
+ if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
958
+ delete this.#metadata[this.#ids[this.#normalizePath(path)]];
1325
959
  }
1326
- this.#clearResolverCache(formattedPath);
1327
960
  } else {
1328
- this.unlinkSync(formattedPath, options);
961
+ this.unlinkSync(this.#normalizePath(path), options);
1329
962
  }
1330
963
  }
1331
964
  /**
@@ -1335,15 +968,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1335
968
  * @param options - Options for creating the directory.
1336
969
  */
1337
970
  rmdirSync(path, options = {}) {
1338
- const formattedPath = toFilePath(path);
1339
- if (!this.isDirectory(formattedPath)) {
971
+ if (!this.isDirectory(this.#normalizePath(path))) {
1340
972
  return;
1341
973
  }
1342
- this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
1343
- this.#unifiedFS.resolveFS(path, options).rmdirSync(formattedPath, defu2(options, {
974
+ this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
975
+ this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu2(options, {
1344
976
  recursive: true
1345
977
  }));
1346
- this.#clearResolverCache(formattedPath);
1347
978
  }
1348
979
  /**
1349
980
  * Removes a directory in the virtual file system (VFS).
@@ -1353,19 +984,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
1353
984
  * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1354
985
  */
1355
986
  async rmdir(path, options = {}) {
1356
- const formattedPath = toFilePath(path);
1357
- if (!this.isDirectory(formattedPath)) {
987
+ if (!this.isDirectory(this.#normalizePath(path))) {
1358
988
  return;
1359
989
  }
1360
- this.#log(LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
990
+ this.#log(LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
1361
991
  if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
1362
- await this.#unifiedFS.resolveFS(path, options).promises.rm(formattedPath, defu2(options, {
992
+ await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu2(options, {
1363
993
  force: true,
1364
994
  recursive: true
1365
995
  }));
1366
- this.#clearResolverCache(formattedPath);
1367
996
  } else {
1368
- this.rmdirSync(formattedPath, defu2(options ?? {}, {
997
+ this.rmdirSync(this.#normalizePath(path), defu2(options ?? {}, {
1369
998
  force: true,
1370
999
  recursive: true
1371
1000
  }));
@@ -1379,11 +1008,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
1379
1008
  * @returns A promise that resolves when the file is removed.
1380
1009
  */
1381
1010
  async rm(path, options = {}) {
1382
- this.#log(LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
1383
- if (this.isDirectory(path)) {
1384
- return this.rmdir(path, options);
1011
+ this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1012
+ if (this.isDirectory(this.#normalizePath(path))) {
1013
+ return this.rmdir(this.#normalizePath(path), options);
1385
1014
  }
1386
- return this.unlink(path, options);
1015
+ return this.unlink(this.#normalizePath(path), options);
1387
1016
  }
1388
1017
  /**
1389
1018
  * Synchronously removes a file or directory in the virtual file system (VFS).
@@ -1392,11 +1021,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
1392
1021
  * @param options - Options for removing the file or directory.
1393
1022
  */
1394
1023
  rmSync(path, options = {}) {
1395
- this.#log(LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
1396
- if (this.isDirectory(path)) {
1397
- return this.rmdirSync(path, options);
1024
+ this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1025
+ if (this.isDirectory(this.#normalizePath(path))) {
1026
+ return this.rmdirSync(this.#normalizePath(path), options);
1398
1027
  }
1399
- return this.unlinkSync(path, options);
1028
+ return this.unlinkSync(this.#normalizePath(path), options);
1400
1029
  }
1401
1030
  /**
1402
1031
  * Creates a directory in the virtual file system (VFS).
@@ -1406,9 +1035,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
1406
1035
  * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1407
1036
  */
1408
1037
  mkdirSync(path, options = {}) {
1409
- const filePath = toFilePath(path);
1410
- this.#clearResolverCache(filePath);
1411
- return this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2(options ?? {}, {
1038
+ return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2(omit(options, [
1039
+ "mode"
1040
+ ]), {
1412
1041
  recursive: true
1413
1042
  }));
1414
1043
  }
@@ -1421,17 +1050,19 @@ var VirtualFileSystem = class _VirtualFileSystem {
1421
1050
  */
1422
1051
  async mkdir(path, options = {}) {
1423
1052
  let result;
1424
- const filePath = toFilePath(path);
1425
- if (isFunction(this.#unifiedFS.resolveFS(filePath, options).promises.mkdir)) {
1426
- result = await this.#unifiedFS.resolveFS(filePath, options).promises.mkdir(filePath, defu2(options ?? {}, {
1053
+ if (isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
1054
+ result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu2(omit(options, [
1055
+ "mode"
1056
+ ]), {
1427
1057
  recursive: true
1428
1058
  }));
1429
1059
  } else {
1430
- result = this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2(options ?? {}, {
1060
+ result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2(omit(options, [
1061
+ "mode"
1062
+ ]), {
1431
1063
  recursive: true
1432
1064
  }));
1433
1065
  }
1434
- this.#clearResolverCache(filePath);
1435
1066
  return result;
1436
1067
  }
1437
1068
  /**
@@ -1443,17 +1074,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
1443
1074
  async glob(patterns) {
1444
1075
  const results = [];
1445
1076
  for (const pattern of toArray(patterns)) {
1446
- const normalized = this.formatPath(pattern);
1077
+ const normalized = this.#normalizePath(pattern);
1447
1078
  if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1448
- const resolved = this.resolve(normalized, {
1449
- pathType: "file"
1450
- });
1079
+ const resolved = this.resolveSync(normalized);
1451
1080
  if (resolved && !results.includes(resolved)) {
1452
1081
  results.push(resolved);
1453
1082
  }
1454
1083
  continue;
1455
1084
  }
1456
- const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1085
+ const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1457
1086
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1458
1087
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1459
1088
  const stack = [
@@ -1468,7 +1097,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1468
1097
  continue;
1469
1098
  }
1470
1099
  for (const entry of entries) {
1471
- const full = this.formatPath(joinPaths$1(dir, entry));
1100
+ const full = this.#normalizePath(joinPaths$1(dir, entry));
1472
1101
  let stats;
1473
1102
  try {
1474
1103
  stats = this.#unifiedFS.lstatSync(full);
@@ -1480,9 +1109,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1480
1109
  stack.push(full);
1481
1110
  } else if (stats.isFile()) {
1482
1111
  if (this.#buildRegex(absPattern).test(full)) {
1483
- const resolved = this.resolve(full, {
1484
- pathType: "file"
1485
- });
1112
+ const resolved = this.resolveSync(full);
1486
1113
  if (resolved && !results.includes(resolved)) {
1487
1114
  results.push(resolved);
1488
1115
  }
@@ -1502,17 +1129,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
1502
1129
  globSync(patterns) {
1503
1130
  const results = [];
1504
1131
  for (const pattern of toArray(patterns)) {
1505
- const normalized = this.formatPath(pattern);
1132
+ const normalized = this.#normalizePath(pattern);
1506
1133
  if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1507
- const resolved = this.resolve(normalized, {
1508
- pathType: "file"
1509
- });
1134
+ const resolved = this.resolveSync(normalized);
1510
1135
  if (resolved && !results.includes(resolved)) {
1511
1136
  results.push(resolved);
1512
1137
  }
1513
1138
  continue;
1514
1139
  }
1515
- const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1140
+ const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1516
1141
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1517
1142
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1518
1143
  const stack = [
@@ -1527,7 +1152,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1527
1152
  continue;
1528
1153
  }
1529
1154
  for (const entry of entries) {
1530
- const full = this.formatPath(joinPaths$1(dir, entry));
1155
+ const full = this.#normalizePath(joinPaths$1(dir, entry));
1531
1156
  let stats;
1532
1157
  try {
1533
1158
  stats = this.#unifiedFS.lstatSync(full);
@@ -1539,9 +1164,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1539
1164
  stack.push(full);
1540
1165
  } else if (stats.isFile()) {
1541
1166
  if (this.#buildRegex(absPattern).test(full)) {
1542
- const resolved = this.resolve(full, {
1543
- pathType: "file"
1544
- });
1167
+ const resolved = this.resolveSync(full);
1545
1168
  if (resolved && !results.includes(resolved)) {
1546
1169
  results.push(resolved);
1547
1170
  }
@@ -1611,21 +1234,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
1611
1234
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1612
1235
  */
1613
1236
  async readFile(pathOrId, options = "utf8") {
1614
- if (!pathOrId) {
1615
- return void 0;
1616
- }
1617
- const filePath = this.resolve(toFilePath(pathOrId), {
1618
- pathType: "file"
1619
- });
1620
- if (filePath) {
1237
+ const filePath = await this.resolve(pathOrId);
1238
+ if (filePath && this.isFile(filePath)) {
1621
1239
  let result;
1622
1240
  if (isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
1623
1241
  result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1624
1242
  } else {
1625
1243
  result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1626
1244
  }
1627
- const content = isBuffer(result) ? bufferToString(result) : result;
1628
- return content;
1245
+ return isBuffer(result) ? bufferToString(result) : result;
1629
1246
  }
1630
1247
  return void 0;
1631
1248
  }
@@ -1636,16 +1253,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
1636
1253
  * @returns The contents of the file as a string, or undefined if the file does not exist.
1637
1254
  */
1638
1255
  readFileSync(pathOrId, options = "utf8") {
1639
- if (!pathOrId) {
1640
- return void 0;
1641
- }
1642
- const filePath = this.resolve(toFilePath(pathOrId), {
1643
- pathType: "file"
1644
- });
1645
- if (filePath) {
1256
+ const filePath = this.resolveSync(pathOrId);
1257
+ if (filePath && this.isFile(filePath)) {
1646
1258
  const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1647
- const content = isBuffer(result) ? bufferToString(result) : result;
1648
- return content;
1259
+ return isBuffer(result) ? bufferToString(result) : result;
1649
1260
  }
1650
1261
  return void 0;
1651
1262
  }
@@ -1658,34 +1269,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
1658
1269
  * @returns A promise that resolves when the file is written.
1659
1270
  */
1660
1271
  async writeFile(path, data = "", options = "utf8") {
1661
- const formattedPath = this.formatPath(path);
1662
- if (!this.isDirectory(findFilePath(formattedPath))) {
1663
- await this.mkdir(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1272
+ if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
1273
+ await this.mkdir(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
1664
1274
  }
1665
- let code = isVirtualFileData(data) ? data.code : data;
1275
+ const metadata = isVirtualFileData(data) ? data : {};
1276
+ metadata.id = this.#normalizeId(path);
1277
+ let code = isVirtualFileData(data) ? metadata.code : data;
1666
1278
  if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString(code)) {
1667
- const resolvedConfig = await resolveConfig(formattedPath);
1279
+ const resolvedConfig = await resolveConfig(this.#normalizePath(path));
1668
1280
  if (resolvedConfig) {
1669
1281
  code = await format(code, {
1670
- absolutePath: formattedPath,
1282
+ absolutePath: this.#normalizePath(path),
1671
1283
  ...resolvedConfig
1672
1284
  });
1673
1285
  }
1674
1286
  }
1675
- const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1676
- this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1677
- this.metadata[formattedPath] = {
1287
+ const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1288
+ this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1289
+ this.#metadata[metadata.id] = {
1678
1290
  mode: outputMode,
1679
1291
  variant: "normal",
1680
1292
  timestamp: Date.now(),
1681
- ...isVirtualFileData(data) ? data : {}
1293
+ ...metadata
1682
1294
  };
1683
- this.#clearResolverCache(formattedPath);
1684
- const ifs = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1295
+ this.#paths[metadata.id] = this.#normalizePath(path);
1296
+ this.#ids[this.#normalizePath(path)] = metadata.id;
1297
+ const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1685
1298
  if (isFunction(ifs.promises.writeFile)) {
1686
- return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1299
+ return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
1300
+ "mode"
1301
+ ]) : "utf8");
1687
1302
  }
1688
- return ifs.writeFileSync(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1303
+ return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
1304
+ "mode"
1305
+ ]) : "utf8");
1689
1306
  }
1690
1307
  /**
1691
1308
  * Synchronously writes a file to the virtual file system (VFS).
@@ -1695,21 +1312,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
1695
1312
  * @param options - Optional parameters for writing the file.
1696
1313
  */
1697
1314
  writeFileSync(path, data = "", options = "utf8") {
1698
- const formattedPath = this.formatPath(path);
1699
- if (!this.isDirectory(findFilePath(formattedPath))) {
1700
- this.mkdirSync(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1701
- }
1702
- const code = isVirtualFileData(data) ? data.code : data;
1703
- const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1704
- this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1705
- this.metadata[formattedPath] = {
1315
+ if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
1316
+ this.mkdirSync(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
1317
+ }
1318
+ const metadata = isVirtualFileData(data) ? data : {};
1319
+ metadata.id = this.#normalizeId(path);
1320
+ const code = isVirtualFileData(data) ? metadata.code : data;
1321
+ const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1322
+ this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1323
+ this.#metadata[metadata.id] = {
1706
1324
  mode: outputMode,
1707
1325
  variant: "normal",
1708
1326
  timestamp: Date.now(),
1709
- ...isVirtualFileData(data) ? data : {}
1327
+ ...metadata
1710
1328
  };
1711
- this.#clearResolverCache(formattedPath);
1712
- const writeStream = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1329
+ this.#paths[metadata.id] = this.#normalizePath(path);
1330
+ this.#ids[this.#normalizePath(path)] = metadata.id;
1331
+ const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
1713
1332
  try {
1714
1333
  writeStream.write(code);
1715
1334
  } finally {
@@ -1723,7 +1342,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1723
1342
  * @returns `true` if the file exists, otherwise `false`.
1724
1343
  */
1725
1344
  existsSync(pathOrId) {
1726
- return this.resolve(pathOrId) !== false;
1345
+ return !!this.resolveSync(pathOrId);
1727
1346
  }
1728
1347
  /**
1729
1348
  * Retrieves the metadata of a file in the virtual file system (VFS).
@@ -1732,7 +1351,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1732
1351
  * @returns The metadata of the file, or undefined if the file does not exist.
1733
1352
  */
1734
1353
  getMetadata(pathOrId) {
1735
- const resolved = this.resolve(pathOrId);
1354
+ const resolved = this.resolveSync(pathOrId);
1736
1355
  if (resolved && this.metadata[resolved]) {
1737
1356
  return this.metadata[resolved];
1738
1357
  }
@@ -1748,7 +1367,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1748
1367
  * @returns `true` if the file exists, otherwise `false`.
1749
1368
  */
1750
1369
  isFile(pathOrId) {
1751
- const resolved = this.resolve(pathOrId);
1370
+ const resolved = this.resolveSync(pathOrId);
1752
1371
  return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isFile() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isFile() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isFile()));
1753
1372
  }
1754
1373
  /**
@@ -1758,7 +1377,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1758
1377
  * @returns `true` if the directory exists, otherwise `false`.
1759
1378
  */
1760
1379
  isDirectory(pathOrId) {
1761
- const resolved = this.resolve(pathOrId);
1380
+ const resolved = this.resolveSync(pathOrId);
1762
1381
  return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isDirectory() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isDirectory() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isDirectory()));
1763
1382
  }
1764
1383
  /**
@@ -1768,7 +1387,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1768
1387
  * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1769
1388
  */
1770
1389
  async stat(pathOrId, options) {
1771
- return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1390
+ return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
1772
1391
  }
1773
1392
  /**
1774
1393
  * Synchronously retrieves the status of a file in the virtual file system (VFS).
@@ -1777,7 +1396,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1777
1396
  * @returns The file's status information, or false if the file does not exist.
1778
1397
  */
1779
1398
  statSync(pathOrId) {
1780
- return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1399
+ return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
1781
1400
  }
1782
1401
  /**
1783
1402
  * Retrieves the status of a symbolic link in the virtual file system (VFS).
@@ -1786,7 +1405,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1786
1405
  * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1787
1406
  */
1788
1407
  async lstat(pathOrId, options) {
1789
- return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1408
+ return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
1790
1409
  }
1791
1410
  /**
1792
1411
  * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
@@ -1795,7 +1414,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1795
1414
  * @returns The symbolic link's status information, or false if the link does not exist.
1796
1415
  */
1797
1416
  lstatSync(pathOrId, options) {
1798
- return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1417
+ return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
1799
1418
  }
1800
1419
  /**
1801
1420
  * Resolves a path or ID to its real path in the virtual file system (VFS).
@@ -1804,52 +1423,113 @@ var VirtualFileSystem = class _VirtualFileSystem {
1804
1423
  * @returns The resolved real path if it exists, otherwise undefined.
1805
1424
  */
1806
1425
  realpathSync(pathOrId) {
1807
- const filePath = this.resolve(toFilePath(pathOrId));
1426
+ const filePath = this.resolveSync(pathOrId);
1808
1427
  if (!filePath) {
1809
- throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1428
+ throw new Error(`File not found: ${pathOrId}`);
1810
1429
  }
1811
1430
  return filePath;
1812
1431
  }
1813
1432
  /**
1814
- * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1433
+ * A helper function to resolve modules in the virtual file system (VFS).
1815
1434
  *
1816
- * @param pathOrId - The path or ID to resolve.
1817
- * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1818
- * @returns The resolved file path if it exists, otherwise undefined.
1435
+ * @remarks
1436
+ * This function can be used to resolve modules relative to the project root directory.
1437
+ *
1438
+ * @example
1439
+ * ```ts
1440
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
1441
+ * ```
1442
+ *
1443
+ * @param id - The module to resolve.
1444
+ * @param importer - An optional path to the importer module.
1445
+ * @param options - Additional resolution options.
1446
+ * @returns A promise that resolves to the resolved module path.
1819
1447
  */
1820
- resolve(pathOrId, options = {}) {
1821
- const formattedPathOrId = toFilePath(pathOrId);
1822
- const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash(options.paths)}` : ""}${options.pathType ? `-${options.pathType}` : ""}`;
1823
- if (this.#cachedResolver.has(resolverKey)) {
1824
- return this.#cachedResolver.get(resolverKey);
1825
- }
1826
- let result = this.#resolveId(formattedPathOrId);
1827
- if (!result) {
1828
- result = this.#resolvePath(formattedPathOrId, options);
1448
+ async resolve(id, importer, options = {}) {
1449
+ let result = this.resolverCache.get(this.#normalizeId(id));
1450
+ if (result) {
1451
+ return result;
1829
1452
  }
1453
+ result = this.paths[this.#normalizeId(id)];
1830
1454
  if (!result) {
1831
- result = false;
1455
+ const paths = options.paths ?? [];
1456
+ if (importer && !paths.includes(importer)) {
1457
+ paths.push(importer);
1458
+ }
1459
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
1460
+ paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
1461
+ paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
1462
+ paths.push(...Object.keys(this.#context.tsconfig.options.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1463
+ for (const combination of getResolutionCombinations(id, {
1464
+ paths
1465
+ })) {
1466
+ if (this.#existsSync(combination)) {
1467
+ result = combination;
1468
+ }
1469
+ }
1470
+ try {
1471
+ result = await resolve(id, {
1472
+ paths
1473
+ });
1474
+ } catch {
1475
+ }
1832
1476
  }
1833
- if (result && options.withExtension === false) {
1834
- return result.replace(/\.[m|c]?[t|j]sx?$/, "");
1477
+ if (result) {
1478
+ result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
1479
+ this.resolverCache.set(this.#normalizeId(id), result);
1835
1480
  }
1836
- this.#cachedResolver.set(resolverKey, result);
1837
1481
  return result;
1838
1482
  }
1839
1483
  /**
1840
- * Converts a relative path to an absolute path based on the workspace and project root.
1484
+ * A synchronous helper function to resolve modules using the Jiti resolver
1841
1485
  *
1842
- * @param path - The relative path to convert.
1843
- * @returns The absolute path.
1486
+ * @remarks
1487
+ * This function can be used to resolve modules relative to the project root directory.
1488
+ *
1489
+ * @example
1490
+ * ```ts
1491
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
1492
+ * ```
1493
+ *
1494
+ * @param id - The module to resolve.
1495
+ * @param importer - An optional path to the importer module.
1496
+ * @param options - Additional resolution options.
1497
+ * @returns The resolved module path.
1844
1498
  */
1845
- formatPath(path) {
1846
- const formattedPath = toFilePath(path);
1847
- if (isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1848
- return formattedPath;
1849
- } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1850
- return joinPaths$1(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1499
+ resolveSync(id, importer, options = {}) {
1500
+ let result = this.resolverCache.get(this.#normalizeId(id));
1501
+ if (result) {
1502
+ return result;
1851
1503
  }
1852
- return formattedPath;
1504
+ result = this.paths[this.#normalizeId(id)];
1505
+ if (!result) {
1506
+ const paths = options.paths ?? [];
1507
+ if (importer && !paths.includes(importer)) {
1508
+ paths.push(importer);
1509
+ }
1510
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
1511
+ paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
1512
+ paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
1513
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1514
+ for (const combination of getResolutionCombinations(id, {
1515
+ paths
1516
+ })) {
1517
+ if (this.#existsSync(combination)) {
1518
+ result = combination;
1519
+ }
1520
+ }
1521
+ try {
1522
+ result = resolveSync(id, {
1523
+ paths
1524
+ });
1525
+ } catch {
1526
+ }
1527
+ }
1528
+ if (result) {
1529
+ result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
1530
+ this.resolverCache.set(this.#normalizeId(id), result);
1531
+ }
1532
+ return result;
1853
1533
  }
1854
1534
  /**
1855
1535
  * Disposes of the virtual file system (VFS) by saving its state to disk.
@@ -1858,7 +1538,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1858
1538
  if (!this.#isDisposed) {
1859
1539
  this.#isDisposed = true;
1860
1540
  this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
1861
- await this.unlink(joinPaths$1(this.#context.cachePath, "fs.bin"));
1541
+ await this.unlink(joinPaths$1(this.#context.dataPath, "fs.bin"));
1862
1542
  const message = new $.Message();
1863
1543
  const fs2 = message.initRoot(FileSystem);
1864
1544
  const virtualFS = this.#unifiedFS.toJSON();
@@ -1867,7 +1547,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1867
1547
  virtualFiles.forEach(([path, code], index) => {
1868
1548
  const fd = files.get(index);
1869
1549
  fd.path = path;
1870
- fd.code = code;
1550
+ fd.code = code || "";
1871
1551
  });
1872
1552
  const ids = fs2._initIds(Object.keys(this.ids).length);
1873
1553
  Object.entries(this.ids).forEach(([id, path], index) => {
@@ -1891,7 +1571,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
1891
1571
  });
1892
1572
  }
1893
1573
  });
1894
- await writeFileBuffer(joinPaths$1(this.#context.cachePath, "fs.bin"), message.toArrayBuffer());
1574
+ await writeFileBuffer(joinPaths$1(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1575
+ this.#resolverCache.save(true);
1576
+ this.#log(LogLevelLabel.DEBUG, "Virtual file system disposed.");
1895
1577
  }
1896
1578
  }
1897
1579
  /**
@@ -1940,6 +1622,8 @@ var PowerlinesContext = class _PowerlinesContext {
1940
1622
  #envPaths;
1941
1623
  #fs;
1942
1624
  #tsconfig;
1625
+ #program;
1626
+ #resolvePatterns = [];
1943
1627
  #getConfigProps(config = {}) {
1944
1628
  return {
1945
1629
  variant: config.build?.variant,
@@ -2031,7 +1715,7 @@ var PowerlinesContext = class _PowerlinesContext {
2031
1715
  */
2032
1716
  get tsconfig() {
2033
1717
  if (!this.#tsconfig) {
2034
- this.#tsconfig = {
1718
+ this.tsconfig = {
2035
1719
  tsconfigFilePath: this.config.tsconfig
2036
1720
  };
2037
1721
  }
@@ -2042,6 +1726,7 @@ var PowerlinesContext = class _PowerlinesContext {
2042
1726
  */
2043
1727
  set tsconfig(value) {
2044
1728
  this.#tsconfig = value;
1729
+ this.#resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});
2045
1730
  }
2046
1731
  /**
2047
1732
  * The virtual file system interface for the project
@@ -2166,6 +1851,106 @@ var PowerlinesContext = class _PowerlinesContext {
2166
1851
  return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
2167
1852
  }
2168
1853
  /**
1854
+ * The {@link Project} instance used for type reflection and module manipulation
1855
+ *
1856
+ * @see https://ts-morph.com/
1857
+ *
1858
+ * @remarks
1859
+ * This instance is created lazily on first access.
1860
+ */
1861
+ get program() {
1862
+ if (!this.#program) {
1863
+ this.#program = createProgram(this, {
1864
+ skipAddingFilesFromTsConfig: true
1865
+ });
1866
+ }
1867
+ return this.#program;
1868
+ }
1869
+ /**
1870
+ * A helper function to resolve modules in the Virtual File System
1871
+ *
1872
+ * @remarks
1873
+ * This function can be used to resolve modules relative to the project root directory.
1874
+ *
1875
+ * @example
1876
+ * ```ts
1877
+ * const resolved = await context.resolve("some-module", "/path/to/importer");
1878
+ * ```
1879
+ *
1880
+ * @param id - The module to resolve.
1881
+ * @param importer - An optional path to the importer module.
1882
+ * @param options - Additional resolution options.
1883
+ * @returns A promise that resolves to the resolved module path.
1884
+ */
1885
+ async resolveId(id, importer, options = {}) {
1886
+ if (this.fs.isVirtual(id)) {
1887
+ const result = await this.fs.resolve(id, importer, options);
1888
+ if (!result) {
1889
+ return void 0;
1890
+ }
1891
+ return {
1892
+ id: `\0${result}`,
1893
+ external: this.config.projectType !== "application"
1894
+ };
1895
+ }
1896
+ if (this.config.build.skipNodeModulesBundle) {
1897
+ if (match(id, this.#resolvePatterns) || match(id, this.config.build.noExternal)) {
1898
+ return void 0;
1899
+ }
1900
+ if (match(id, this.config.build.external) || id.startsWith("node:")) {
1901
+ return {
1902
+ id,
1903
+ external: true
1904
+ };
1905
+ }
1906
+ if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(id)) {
1907
+ return {
1908
+ id,
1909
+ external: true
1910
+ };
1911
+ }
1912
+ } else {
1913
+ if (match(id, this.config.build.noExternal)) {
1914
+ return void 0;
1915
+ }
1916
+ if (match(id, this.config.build.external) || id.startsWith("node:")) {
1917
+ return {
1918
+ id,
1919
+ external: true
1920
+ };
1921
+ }
1922
+ }
1923
+ return void 0;
1924
+ }
1925
+ /**
1926
+ * A helper function to load modules from the Virtual File System
1927
+ *
1928
+ * @remarks
1929
+ * This function can be used to load modules relative to the project root directory.
1930
+ *
1931
+ * @example
1932
+ * ```ts
1933
+ * const module = await context.load("some-module", "/path/to/importer");
1934
+ * ```
1935
+ *
1936
+ * @param id - The module to load.
1937
+ * @returns A promise that resolves to the loaded module.
1938
+ */
1939
+ async load(id) {
1940
+ const resolvedId = await this.fs.resolve(id);
1941
+ if (!resolvedId) {
1942
+ return void 0;
1943
+ }
1944
+ const code = await this.fs.readFile(resolvedId);
1945
+ if (!code) {
1946
+ return void 0;
1947
+ }
1948
+ return {
1949
+ code,
1950
+ map: null
1951
+ };
1952
+ }
1953
+ /**
2169
1954
  * Get the builtin virtual files that exist in the Powerlines virtual file system
2170
1955
  */
2171
1956
  async getBuiltins() {
@@ -2388,6 +2173,7 @@ var PowerlinesContext = class _PowerlinesContext {
2388
2173
  projectRoot: cacheKey.projectRoot,
2389
2174
  cacheDir: this.cachePath,
2390
2175
  mode: cacheKey.mode,
2176
+ logLevel: config.logLevel || this.config?.logLevel || this.workspaceConfig.logLevel || "info",
2391
2177
  skipCache: cacheKey.skipCache
2392
2178
  });
2393
2179
  const userConfig = await loadUserConfigFile(cacheKey.projectRoot, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
@@ -2501,6 +2287,24 @@ var PowerlinesContext = class _PowerlinesContext {
2501
2287
  ret.push(plugin);
2502
2288
  return ret;
2503
2289
  }, []);
2290
+ if (this.config.tsconfig) {
2291
+ this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);
2292
+ }
2293
+ if (this.config.output.dts) {
2294
+ this.config.output.dts = replacePathTokens(this, this.config.output.dts);
2295
+ }
2296
+ if (this.config.build.polyfill) {
2297
+ this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => replacePathTokens(this, polyfill));
2298
+ }
2299
+ if (this.config.output.assets) {
2300
+ this.config.output.assets = this.config.output.assets.map((asset) => ({
2301
+ ...asset,
2302
+ glob: replacePathTokens(this, asset.glob),
2303
+ ignore: asset.ignore ? asset.ignore.map((ignore) => replacePathTokens(this, ignore)) : void 0,
2304
+ input: replacePathTokens(this, asset.input),
2305
+ output: replacePathTokens(this, asset.output)
2306
+ }));
2307
+ }
2504
2308
  this.#fs ??= await VirtualFileSystem.create(this);
2505
2309
  }
2506
2310
  mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
@@ -2524,4 +2328,4 @@ var PowerlinesContext = class _PowerlinesContext {
2524
2328
  }
2525
2329
  };
2526
2330
 
2527
- export { PowerlinesContext, VirtualFileSystem, __VFS_PATCH__, __VFS_REVERT__, addPluginHook, checkDedupe, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook };
2331
+ export { PowerlinesContext, VirtualFileSystem, __VFS_REVERT__, addPluginHook, checkDedupe, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook };