powerlines 0.23.10 → 0.24.1

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 (262) 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/chunk-2TWFBWKA.cjs +133 -0
  12. package/dist/{chunk-3W5CN3M3.js → chunk-7V3LWCLB.js} +1 -1
  13. package/dist/chunk-EXQM3KGH.js +130 -0
  14. package/dist/{chunk-4EIGDACJ.cjs → chunk-FGH3MZTQ.cjs} +523 -649
  15. package/dist/{chunk-SNHUEYEP.cjs → chunk-FPB2O7FD.cjs} +2 -2
  16. package/dist/{chunk-ZIWN73GA.js → chunk-H74SWU2C.js} +1 -1
  17. package/dist/{chunk-WBC2XOMT.cjs → chunk-HTGCHSLH.cjs} +2 -2
  18. package/dist/{chunk-PR3JGGAL.cjs → chunk-TIBYAWZZ.cjs} +2 -2
  19. package/dist/{chunk-SS5AXCGJ.js → chunk-ZEE73BCY.js} +1 -1
  20. package/dist/{chunk-MUNYXQYT.js → chunk-ZT2J55YE.js} +526 -649
  21. package/dist/config.d.cts +3 -1
  22. package/dist/config.d.ts +3 -1
  23. package/dist/esbuild.cjs +6 -6
  24. package/dist/esbuild.d.cts +3 -1
  25. package/dist/esbuild.d.ts +3 -1
  26. package/dist/esbuild.js +3 -3
  27. package/dist/farm.cjs +3 -3
  28. package/dist/farm.d.cts +3 -1
  29. package/dist/farm.d.ts +3 -1
  30. package/dist/farm.js +2 -2
  31. package/dist/index.cjs +11 -23
  32. package/dist/index.d.cts +6 -135
  33. package/dist/index.d.ts +6 -135
  34. package/dist/index.js +2 -2
  35. package/dist/lib/{api-Cm51oVbC.d.cts → api-BRMITKt-.d.cts} +1 -1
  36. package/dist/lib/{api-mja4jirh.d.ts → api-CDUN9en8.d.ts} +1 -1
  37. package/dist/lib/build/esbuild.d.cts +3 -1
  38. package/dist/lib/build/esbuild.d.ts +3 -1
  39. package/dist/lib/build/index.d.cts +5 -3
  40. package/dist/lib/build/index.d.ts +5 -3
  41. package/dist/lib/build/rolldown.d.cts +3 -1
  42. package/dist/lib/build/rolldown.d.ts +3 -1
  43. package/dist/lib/build/rollup.d.cts +3 -1
  44. package/dist/lib/build/rollup.d.ts +3 -1
  45. package/dist/lib/build/rspack.d.cts +3 -1
  46. package/dist/lib/build/rspack.d.ts +3 -1
  47. package/dist/lib/build/tsup.d.cts +3 -1
  48. package/dist/lib/build/tsup.d.ts +3 -1
  49. package/dist/lib/build/unbuild.d.cts +5 -3
  50. package/dist/lib/build/unbuild.d.ts +5 -3
  51. package/dist/lib/build/vite.d.cts +3 -1
  52. package/dist/lib/build/vite.d.ts +3 -1
  53. package/dist/lib/build/webpack.d.cts +3 -1
  54. package/dist/lib/build/webpack.d.ts +3 -1
  55. package/dist/lib/{chunk-52VDUP5J.js → chunk-6I5PL7H2.js} +5 -17
  56. package/dist/lib/{chunk-UPVFKXB7.cjs → chunk-6PPZCPME.cjs} +1 -2
  57. package/dist/lib/{chunk-HNOAMIRO.js → chunk-7CVPZOH4.js} +2 -2
  58. package/dist/lib/{chunk-SEWUUTNA.js → chunk-A2NFSQ5K.js} +1 -1
  59. package/dist/lib/{chunk-I6TJUFA6.cjs → chunk-AA6RBP44.cjs} +10 -10
  60. package/dist/lib/{chunk-VDPCG3RR.js → chunk-CGRHZJY5.js} +41 -82
  61. package/dist/lib/{chunk-OJ5XFCZN.js → chunk-DFW5FGEO.js} +1 -1
  62. package/dist/lib/{chunk-VL63QEPF.cjs → chunk-DUZJ7ZF2.cjs} +2 -2
  63. package/dist/lib/{chunk-EFYMNU53.cjs → chunk-EV357RFB.cjs} +5 -17
  64. package/dist/lib/{chunk-54XNJQTH.js → chunk-HAXL7QE7.js} +3 -3
  65. package/dist/lib/{chunk-XG4CC73V.js → chunk-KFWMKDJQ.js} +391 -589
  66. package/dist/lib/{chunk-RBSNQFLF.cjs → chunk-MS3CD2U6.cjs} +49 -91
  67. package/dist/lib/{chunk-QABAD5RE.cjs → chunk-RNHKEPFD.cjs} +387 -586
  68. package/dist/lib/{chunk-4EIXDLFP.cjs → chunk-SAS5EPBD.cjs} +7 -5
  69. package/dist/lib/{chunk-EUDKQWSB.js → chunk-VHLINWXG.js} +1 -2
  70. package/dist/lib/{chunk-VLOUSKRX.cjs → chunk-VMLQATMA.cjs} +4 -4
  71. package/dist/lib/{chunk-IBPA3VN5.cjs → chunk-WUYK74EH.cjs} +3 -3
  72. package/dist/lib/{chunk-RD5AUWXN.js → chunk-YQ3ODCHV.js} +7 -5
  73. package/dist/lib/{config-BnJpgcGr.d.cts → config-D8KrE7SZ.d.cts} +109 -35
  74. package/dist/lib/{config-7Q2dBjJE.d.ts → config-DBIFdRoq.d.ts} +109 -35
  75. package/dist/lib/config-file.d.cts +3 -1
  76. package/dist/lib/config-file.d.ts +3 -1
  77. package/dist/lib/contexts/api-context.cjs +5 -4
  78. package/dist/lib/contexts/api-context.d.cts +5 -3
  79. package/dist/lib/contexts/api-context.d.ts +5 -3
  80. package/dist/lib/contexts/api-context.js +4 -3
  81. package/dist/lib/contexts/context.cjs +3 -2
  82. package/dist/lib/contexts/context.d.cts +47 -4
  83. package/dist/lib/contexts/context.d.ts +47 -4
  84. package/dist/lib/contexts/context.js +2 -1
  85. package/dist/lib/contexts/environment-context.cjs +4 -3
  86. package/dist/lib/contexts/environment-context.d.cts +5 -3
  87. package/dist/lib/contexts/environment-context.d.ts +5 -3
  88. package/dist/lib/contexts/environment-context.js +3 -2
  89. package/dist/lib/contexts/index.cjs +7 -6
  90. package/dist/lib/contexts/index.d.cts +5 -3
  91. package/dist/lib/contexts/index.d.ts +5 -3
  92. package/dist/lib/contexts/index.js +4 -3
  93. package/dist/lib/contexts/plugin-context.d.cts +5 -3
  94. package/dist/lib/contexts/plugin-context.d.ts +5 -3
  95. package/dist/lib/entry.d.cts +3 -1
  96. package/dist/lib/entry.d.ts +3 -1
  97. package/dist/lib/index.cjs +39 -45
  98. package/dist/lib/index.d.cts +67 -48
  99. package/dist/lib/index.d.ts +67 -48
  100. package/dist/lib/index.js +12 -14
  101. package/dist/lib/{internal-BEygquYh.d.ts → internal-1qCyw7bA.d.ts} +2 -2
  102. package/dist/lib/{internal-BeR8fOB1.d.cts → internal-CaGANOWK.d.cts} +2 -2
  103. package/dist/lib/logger.d.cts +3 -1
  104. package/dist/lib/logger.d.ts +3 -1
  105. package/dist/lib/typescript/compiler-host.cjs +7 -7
  106. package/dist/lib/typescript/compiler-host.d.cts +3 -1
  107. package/dist/lib/typescript/compiler-host.d.ts +3 -1
  108. package/dist/lib/typescript/compiler-host.js +6 -6
  109. package/dist/lib/typescript/import-transformer.cjs +1 -1
  110. package/dist/lib/typescript/import-transformer.d.cts +3 -1
  111. package/dist/lib/typescript/import-transformer.d.ts +3 -1
  112. package/dist/lib/typescript/import-transformer.js +1 -1
  113. package/dist/lib/typescript/index.cjs +8 -8
  114. package/dist/lib/typescript/index.d.cts +3 -2
  115. package/dist/lib/typescript/index.d.ts +3 -2
  116. package/dist/lib/typescript/index.js +2 -2
  117. package/dist/lib/typescript/program.cjs +6 -6
  118. package/dist/lib/typescript/program.d.cts +3 -1
  119. package/dist/lib/typescript/program.d.ts +3 -1
  120. package/dist/lib/typescript/program.js +1 -1
  121. package/dist/lib/typescript/ts-morph.cjs +2 -2
  122. package/dist/lib/typescript/ts-morph.d.cts +5 -3
  123. package/dist/lib/typescript/ts-morph.d.ts +5 -3
  124. package/dist/lib/typescript/ts-morph.js +1 -1
  125. package/dist/lib/unplugin/factory.cjs +6 -6
  126. package/dist/lib/unplugin/factory.d.cts +5 -3
  127. package/dist/lib/unplugin/factory.d.ts +5 -3
  128. package/dist/lib/unplugin/factory.js +5 -5
  129. package/dist/lib/unplugin/helpers.d.cts +3 -1
  130. package/dist/lib/unplugin/helpers.d.ts +3 -1
  131. package/dist/lib/unplugin/index.cjs +11 -11
  132. package/dist/lib/unplugin/index.d.cts +6 -4
  133. package/dist/lib/unplugin/index.d.ts +6 -4
  134. package/dist/lib/unplugin/index.js +7 -7
  135. package/dist/lib/unplugin/plugin.cjs +2 -3
  136. package/dist/lib/unplugin/plugin.d.cts +6 -4
  137. package/dist/lib/unplugin/plugin.d.ts +6 -4
  138. package/dist/lib/unplugin/plugin.js +1 -2
  139. package/dist/lib/{unplugin-CbbNDduM.d.ts → unplugin-CEeJqADD.d.ts} +2 -2
  140. package/dist/lib/{unplugin-ppAOzR__.d.cts → unplugin-bUSyjd0S.d.cts} +2 -2
  141. package/dist/lib/utilities/bundle.cjs +2 -3
  142. package/dist/lib/utilities/bundle.d.cts +3 -1
  143. package/dist/lib/utilities/bundle.d.ts +3 -1
  144. package/dist/lib/utilities/bundle.js +1 -2
  145. package/dist/lib/utilities/cache.d.cts +3 -1
  146. package/dist/lib/utilities/cache.d.ts +3 -1
  147. package/dist/lib/utilities/file-header.d.cts +3 -1
  148. package/dist/lib/utilities/file-header.d.ts +3 -1
  149. package/dist/lib/utilities/index.cjs +14 -19
  150. package/dist/lib/utilities/index.d.cts +3 -2
  151. package/dist/lib/utilities/index.d.ts +3 -2
  152. package/dist/lib/utilities/index.js +4 -5
  153. package/dist/lib/utilities/meta.d.cts +3 -1
  154. package/dist/lib/utilities/meta.d.ts +3 -1
  155. package/dist/lib/utilities/resolve.cjs +3 -4
  156. package/dist/lib/utilities/resolve.d.cts +3 -1
  157. package/dist/lib/utilities/resolve.d.ts +3 -1
  158. package/dist/lib/utilities/resolve.js +2 -3
  159. package/dist/lib/utilities/source-file.d.cts +3 -1
  160. package/dist/lib/utilities/source-file.d.ts +3 -1
  161. package/dist/lib/utilities/source-map.d.cts +3 -1
  162. package/dist/lib/utilities/source-map.d.ts +3 -1
  163. package/dist/lib/utilities/worker.d.cts +3 -1
  164. package/dist/lib/utilities/worker.d.ts +3 -1
  165. package/dist/lib/utilities/write-file.d.cts +3 -1
  166. package/dist/lib/utilities/write-file.d.ts +3 -1
  167. package/dist/next.cjs +4 -4
  168. package/dist/next.js +3 -3
  169. package/dist/nuxt.cjs +6 -6
  170. package/dist/nuxt.js +4 -4
  171. package/dist/plugin-utils/{context-Cg11S-CE.d.cts → context-BITGF5LZ.d.cts} +118 -39
  172. package/dist/plugin-utils/{context-Cg11S-CE.d.ts → context-BITGF5LZ.d.ts} +118 -39
  173. package/dist/plugin-utils/context-helpers.d.cts +4 -1
  174. package/dist/plugin-utils/context-helpers.d.ts +4 -1
  175. package/dist/plugin-utils/enforce.d.cts +4 -1
  176. package/dist/plugin-utils/enforce.d.ts +4 -1
  177. package/dist/plugin-utils/extend.d.cts +4 -1
  178. package/dist/plugin-utils/extend.d.ts +4 -1
  179. package/dist/plugin-utils/get-config-path.d.cts +4 -1
  180. package/dist/plugin-utils/get-config-path.d.ts +4 -1
  181. package/dist/plugin-utils/helpers.d.cts +4 -1
  182. package/dist/plugin-utils/helpers.d.ts +4 -1
  183. package/dist/plugin-utils/index.d.cts +4 -1
  184. package/dist/plugin-utils/index.d.ts +4 -1
  185. package/dist/plugin-utils/merge.d.cts +4 -1
  186. package/dist/plugin-utils/merge.d.ts +4 -1
  187. package/dist/plugin-utils/paths.d.cts +4 -1
  188. package/dist/plugin-utils/paths.d.ts +4 -1
  189. package/dist/{resolved-B3BSdXCt.d.ts → resolved-BABoCnXm.d.ts} +43 -1
  190. package/dist/{resolved-DGrpILrS.d.cts → resolved-CSqGKlA5.d.cts} +43 -1
  191. package/dist/rolldown.cjs +3 -3
  192. package/dist/rolldown.d.cts +3 -1
  193. package/dist/rolldown.d.ts +3 -1
  194. package/dist/rolldown.js +2 -2
  195. package/dist/rollup.cjs +3 -3
  196. package/dist/rollup.d.cts +3 -1
  197. package/dist/rollup.d.ts +3 -1
  198. package/dist/rollup.js +2 -2
  199. package/dist/rspack.cjs +3 -3
  200. package/dist/rspack.d.cts +3 -1
  201. package/dist/rspack.d.ts +3 -1
  202. package/dist/rspack.js +2 -2
  203. package/dist/tsup.cjs +4 -4
  204. package/dist/tsup.js +3 -3
  205. package/dist/types/api.d.cts +4 -2
  206. package/dist/types/api.d.ts +4 -2
  207. package/dist/types/babel.d.cts +3 -1
  208. package/dist/types/babel.d.ts +3 -1
  209. package/dist/types/commands.d.cts +3 -1
  210. package/dist/types/commands.d.ts +3 -1
  211. package/dist/types/config.d.cts +3 -1
  212. package/dist/types/config.d.ts +3 -1
  213. package/dist/types/context.d.cts +3 -1
  214. package/dist/types/context.d.ts +3 -1
  215. package/dist/types/fs.d.cts +68 -36
  216. package/dist/types/fs.d.ts +68 -36
  217. package/dist/types/hooks.d.cts +3 -1
  218. package/dist/types/hooks.d.ts +3 -1
  219. package/dist/types/index.d.cts +5 -3
  220. package/dist/types/index.d.ts +5 -3
  221. package/dist/types/internal.d.cts +4 -2
  222. package/dist/types/internal.d.ts +4 -2
  223. package/dist/types/plugin.d.cts +3 -1
  224. package/dist/types/plugin.d.ts +3 -1
  225. package/dist/types/resolved.d.cts +3 -1
  226. package/dist/types/resolved.d.ts +3 -1
  227. package/dist/types/unplugin.d.cts +4 -2
  228. package/dist/types/unplugin.d.ts +4 -2
  229. package/dist/unloader.cjs +3 -3
  230. package/dist/unloader.d.cts +3 -1
  231. package/dist/unloader.d.ts +3 -1
  232. package/dist/unloader.js +2 -2
  233. package/dist/unplugin.cjs +12 -28
  234. package/dist/unplugin.d.cts +104 -31
  235. package/dist/unplugin.d.ts +104 -31
  236. package/dist/unplugin.js +10 -23
  237. package/dist/vite.cjs +6 -6
  238. package/dist/vite.d.cts +3 -1
  239. package/dist/vite.d.ts +3 -1
  240. package/dist/vite.js +3 -3
  241. package/dist/webpack.cjs +6 -6
  242. package/dist/webpack.d.cts +3 -1
  243. package/dist/webpack.d.ts +3 -1
  244. package/dist/webpack.js +3 -3
  245. package/package.json +17 -16
  246. package/schemas/fs.capnp +35 -38
  247. package/dist/chunk-4TBQYHPZ.cjs +0 -234
  248. package/dist/chunk-7G7OFGGH.js +0 -230
  249. package/dist/lib/chunk-G7S5PIAC.js +0 -89
  250. package/dist/lib/chunk-MZJWK36Q.cjs +0 -37
  251. package/dist/lib/chunk-NWAD7K4D.js +0 -35
  252. package/dist/lib/chunk-ZBDVQVUK.cjs +0 -91
  253. package/dist/lib/unplugin/resolve-id.cjs +0 -11
  254. package/dist/lib/unplugin/resolve-id.d.cts +0 -57
  255. package/dist/lib/unplugin/resolve-id.d.ts +0 -57
  256. package/dist/lib/unplugin/resolve-id.js +0 -2
  257. package/dist/lib/utilities/resolve-path.cjs +0 -11
  258. package/dist/lib/utilities/resolve-path.d.cts +0 -40
  259. package/dist/lib/utilities/resolve-path.d.ts +0 -40
  260. package/dist/lib/utilities/resolve-path.js +0 -2
  261. /package/dist/lib/{chunk-HMO3LAYL.js → chunk-I2DQRMX3.js} +0 -0
  262. /package/dist/lib/{chunk-EJ25PQEL.cjs → chunk-YK4PYVLM.cjs} +0 -0
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk7VJ42H2I_cjs = require('./chunk-7VJ42H2I.cjs');
4
+ var chunkSAS5EPBD_cjs = require('./chunk-SAS5EPBD.cjs');
4
5
  var chunkK3NBD5LL_cjs = require('./chunk-K3NBD5LL.cjs');
5
6
  var chunkJA4HSQRN_cjs = require('./chunk-JA4HSQRN.cjs');
6
7
  var chunkISBHXSDH_cjs = require('./chunk-ISBHXSDH.cjs');
@@ -27,6 +28,7 @@ var isSetObject = require('@stryke/type-checks/is-set-object');
27
28
  var isSetString = require('@stryke/type-checks/is-set-string');
28
29
  var isString = require('@stryke/type-checks/is-string');
29
30
  var uuid = require('@stryke/unique-id/uuid');
31
+ var bundleRequire = require('bundle-require');
30
32
  var defu2 = require('defu');
31
33
  var joinPaths = require('@stryke/path/join-paths');
32
34
  var jiti = require('jiti');
@@ -35,9 +37,11 @@ var isUndefined = require('@stryke/type-checks/is-undefined');
35
37
  var $ = require('@stryke/capnp');
36
38
  var bufferToString = require('@stryke/convert/buffer-to-string');
37
39
  var buffer = require('@stryke/fs/buffer');
40
+ var correctPath = require('@stryke/path/correct-path');
38
41
  var filePathFns = require('@stryke/path/file-path-fns');
39
42
  var prettyBytes = require('@stryke/string-format/pretty-bytes');
40
43
  var isBuffer = require('@stryke/type-checks/is-buffer');
44
+ var flatCache = require('flat-cache');
41
45
  var buffer$1 = require('buffer');
42
46
  var _fs = require('fs');
43
47
  var prettier = require('prettier');
@@ -258,187 +262,6 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
258
262
  return "FileMetadata_" + super.toString();
259
263
  }
260
264
  };
261
- var ChunkData = class extends $__namespace.Struct {
262
- static {
263
- chunkUSNT2KNT_cjs.__name(this, "ChunkData");
264
- }
265
- static _capnp = {
266
- displayName: "ChunkData",
267
- id: "84076f13b057f83a",
268
- size: new $__namespace.ObjectSize(8, 4)
269
- };
270
- /**
271
- * An additional name for the file.
272
- *
273
- */
274
- get id() {
275
- return $__namespace.utils.getText(0, this);
276
- }
277
- set id(value) {
278
- $__namespace.utils.setText(0, value, this);
279
- }
280
- /**
281
- * Files that are implicitly loaded after one of the specified files.
282
- *
283
- */
284
- get name() {
285
- return $__namespace.utils.getText(1, this);
286
- }
287
- set name(value) {
288
- $__namespace.utils.setText(1, value, this);
289
- }
290
- _adoptImplicitlyLoadedAfterOneOf(value) {
291
- $__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
292
- }
293
- _disownImplicitlyLoadedAfterOneOf() {
294
- return $__namespace.utils.disown(this.implicitlyLoadedAfterOneOf);
295
- }
296
- /**
297
- * The importer of the file.
298
- *
299
- */
300
- get implicitlyLoadedAfterOneOf() {
301
- return $__namespace.utils.getList(2, $__namespace.TextList, this);
302
- }
303
- _hasImplicitlyLoadedAfterOneOf() {
304
- return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
305
- }
306
- _initImplicitlyLoadedAfterOneOf(length) {
307
- return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
308
- }
309
- set implicitlyLoadedAfterOneOf(value) {
310
- $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
311
- }
312
- /**
313
- * The signature preservation mode for the file.
314
- *
315
- */
316
- get importer() {
317
- return $__namespace.utils.getText(3, this);
318
- }
319
- set importer(value) {
320
- $__namespace.utils.setText(3, value, this);
321
- }
322
- get preserveSignature() {
323
- return $__namespace.utils.getUint16(0, this);
324
- }
325
- set preserveSignature(value) {
326
- $__namespace.utils.setUint16(0, value, this);
327
- }
328
- toString() {
329
- return "ChunkData_" + super.toString();
330
- }
331
- };
332
- var PrebuiltData = class extends $__namespace.Struct {
333
- static {
334
- chunkUSNT2KNT_cjs.__name(this, "PrebuiltData");
335
- }
336
- static _capnp = {
337
- displayName: "PrebuiltData",
338
- id: "c5b1a6ca696328ee",
339
- size: new $__namespace.ObjectSize(0, 4)
340
- };
341
- /**
342
- * An additional name for the file.
343
- *
344
- */
345
- get id() {
346
- return $__namespace.utils.getText(0, this);
347
- }
348
- set id(value) {
349
- $__namespace.utils.setText(0, value, this);
350
- }
351
- /**
352
- * The file exports.
353
- *
354
- */
355
- get name() {
356
- return $__namespace.utils.getText(1, this);
357
- }
358
- set name(value) {
359
- $__namespace.utils.setText(1, value, this);
360
- }
361
- _adoptExports(value) {
362
- $__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
363
- }
364
- _disownExports() {
365
- return $__namespace.utils.disown(this.exports);
366
- }
367
- /**
368
- * The source map for the file.
369
- *
370
- */
371
- get exports() {
372
- return $__namespace.utils.getList(2, $__namespace.TextList, this);
373
- }
374
- _hasExports() {
375
- return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
376
- }
377
- _initExports(length) {
378
- return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
379
- }
380
- set exports(value) {
381
- $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
382
- }
383
- get map() {
384
- return $__namespace.utils.getText(3, this);
385
- }
386
- set map(value) {
387
- $__namespace.utils.setText(3, value, this);
388
- }
389
- toString() {
390
- return "PrebuiltData_" + super.toString();
391
- }
392
- };
393
- var AssetData = class extends $__namespace.Struct {
394
- static {
395
- chunkUSNT2KNT_cjs.__name(this, "AssetData");
396
- }
397
- static _capnp = {
398
- displayName: "AssetData",
399
- id: "da660c6c1fa4c830",
400
- size: new $__namespace.ObjectSize(8, 3)
401
- };
402
- /**
403
- * An additional name for the file.
404
- *
405
- */
406
- get id() {
407
- return $__namespace.utils.getText(0, this);
408
- }
409
- set id(value) {
410
- $__namespace.utils.setText(0, value, this);
411
- }
412
- /**
413
- * Indicates whether the file needs a code reference.
414
- *
415
- */
416
- get name() {
417
- return $__namespace.utils.getText(1, this);
418
- }
419
- set name(value) {
420
- $__namespace.utils.setText(1, value, this);
421
- }
422
- /**
423
- * The original file name before any transformations.
424
- *
425
- */
426
- get needsCodeReference() {
427
- return $__namespace.utils.getBit(0, this);
428
- }
429
- set needsCodeReference(value) {
430
- $__namespace.utils.setBit(0, value, this);
431
- }
432
- get originalFileName() {
433
- return $__namespace.utils.getText(2, this);
434
- }
435
- set originalFileName(value) {
436
- $__namespace.utils.setText(2, value, this);
437
- }
438
- toString() {
439
- return "AssetData_" + super.toString();
440
- }
441
- };
442
265
  var FileId = class extends $__namespace.Struct {
443
266
  static {
444
267
  chunkUSNT2KNT_cjs.__name(this, "FileId");
@@ -504,14 +327,11 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
504
327
  static _capnp = {
505
328
  displayName: "FileSystem",
506
329
  id: "ae0c23d43e56abcf",
507
- size: new $__namespace.ObjectSize(0, 6)
330
+ size: new $__namespace.ObjectSize(0, 3)
508
331
  };
509
332
  static _Ids;
510
333
  static _Files;
511
334
  static _Metadata;
512
- static _Assets;
513
- static _Chunks;
514
- static _Prebuilt;
515
335
  _adoptIds(value) {
516
336
  $__namespace.utils.adopt(value, $__namespace.utils.getPointer(0, this));
517
337
  }
@@ -566,60 +386,6 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
566
386
  set metadata(value) {
567
387
  $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
568
388
  }
569
- _adoptAssets(value) {
570
- $__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
571
- }
572
- _disownAssets() {
573
- return $__namespace.utils.disown(this.assets);
574
- }
575
- get assets() {
576
- return $__namespace.utils.getList(3, _FileSystem._Assets, this);
577
- }
578
- _hasAssets() {
579
- return !$__namespace.utils.isNull($__namespace.utils.getPointer(3, this));
580
- }
581
- _initAssets(length) {
582
- return $__namespace.utils.initList(3, _FileSystem._Assets, length, this);
583
- }
584
- set assets(value) {
585
- $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(3, this));
586
- }
587
- _adoptChunks(value) {
588
- $__namespace.utils.adopt(value, $__namespace.utils.getPointer(4, this));
589
- }
590
- _disownChunks() {
591
- return $__namespace.utils.disown(this.chunks);
592
- }
593
- get chunks() {
594
- return $__namespace.utils.getList(4, _FileSystem._Chunks, this);
595
- }
596
- _hasChunks() {
597
- return !$__namespace.utils.isNull($__namespace.utils.getPointer(4, this));
598
- }
599
- _initChunks(length) {
600
- return $__namespace.utils.initList(4, _FileSystem._Chunks, length, this);
601
- }
602
- set chunks(value) {
603
- $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(4, this));
604
- }
605
- _adoptPrebuilt(value) {
606
- $__namespace.utils.adopt(value, $__namespace.utils.getPointer(5, this));
607
- }
608
- _disownPrebuilt() {
609
- return $__namespace.utils.disown(this.prebuilt);
610
- }
611
- get prebuilt() {
612
- return $__namespace.utils.getList(5, _FileSystem._Prebuilt, this);
613
- }
614
- _hasPrebuilt() {
615
- return !$__namespace.utils.isNull($__namespace.utils.getPointer(5, this));
616
- }
617
- _initPrebuilt(length) {
618
- return $__namespace.utils.initList(5, _FileSystem._Prebuilt, length, this);
619
- }
620
- set prebuilt(value) {
621
- $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(5, this));
622
- }
623
389
  toString() {
624
390
  return "FileSystem_" + super.toString();
625
391
  }
@@ -628,9 +394,6 @@ FileMetadata._Properties = $__namespace.CompositeList(FileMetadata_KeyValuePair)
628
394
  FileSystem._Ids = $__namespace.CompositeList(FileId);
629
395
  FileSystem._Files = $__namespace.CompositeList(FileData);
630
396
  FileSystem._Metadata = $__namespace.CompositeList(FileMetadata);
631
- FileSystem._Assets = $__namespace.CompositeList(AssetData);
632
- FileSystem._Chunks = $__namespace.CompositeList(ChunkData);
633
- FileSystem._Prebuilt = $__namespace.CompositeList(PrebuiltData);
634
397
 
635
398
  // src/types/fs.ts
636
399
  var __VFS_PATCH__ = "__VFS_PATCH__";
@@ -640,13 +403,9 @@ function isBufferEncoding(options) {
640
403
  }
641
404
  chunkUSNT2KNT_cjs.__name(isBufferEncoding, "isBufferEncoding");
642
405
  function isPowerlinesWriteFileOptions(options) {
643
- return !isBufferEncoding(options) && isSetObject.isSetObject(options) && ("skipFormat" in options || "mode" in options && (options.mode === "fs" || options.mode === "virtual"));
406
+ return !isBufferEncoding(options) && isSetObject.isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
644
407
  }
645
408
  chunkUSNT2KNT_cjs.__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
646
- function isNodeWriteFileOptions(options) {
647
- return !isUndefined.isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
648
- }
649
- chunkUSNT2KNT_cjs.__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
650
409
  function isVirtualFileData(obj) {
651
410
  return !!(isSetObject.isSetObject(obj) && "code" in obj && obj.code);
652
411
  }
@@ -783,6 +542,18 @@ function patchFS(originalFS, vfs) {
783
542
  };
784
543
  }
785
544
  chunkUSNT2KNT_cjs.__name(patchFS, "patchFS");
545
+ function isValidId(id, prefix = "powerlines") {
546
+ return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
547
+ }
548
+ chunkUSNT2KNT_cjs.__name(isValidId, "isValidId");
549
+ function normalizeId(id, prefix = "powerlines") {
550
+ return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(toFilePath(id)), "")}`;
551
+ }
552
+ chunkUSNT2KNT_cjs.__name(normalizeId, "normalizeId");
553
+ function normalizePath(path, builtinsPath, prefix = "powerlines") {
554
+ return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
555
+ }
556
+ chunkUSNT2KNT_cjs.__name(normalizePath, "normalizePath");
786
557
  var UnifiedFS = class _UnifiedFS extends unionfs.Union {
787
558
  static {
788
559
  chunkUSNT2KNT_cjs.__name(this, "UnifiedFS");
@@ -959,9 +730,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
959
730
  */
960
731
  #paths;
961
732
  /**
962
- * A map of virtual file paths to their underlying file content.
733
+ * A cache for module resolution results.
963
734
  */
964
- #cachedResolver = /* @__PURE__ */ new Map();
735
+ #resolverCache;
965
736
  /**
966
737
  * The unified volume that combines the virtual file system with the real file system.
967
738
  *
@@ -996,189 +767,35 @@ var VirtualFileSystem = class _VirtualFileSystem {
996
767
  * @returns `true` if the path exists, otherwise `false`.
997
768
  */
998
769
  #existsSync(path) {
999
- const formattedPath = this.formatPath(path);
1000
- return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
1001
- }
1002
- /**
1003
- * Builds a regular expression from a string pattern for path matching.
1004
- *
1005
- * @param strPattern - The string pattern to convert.
1006
- * @returns A regular expression for matching paths.
1007
- */
1008
- #buildRegex(strPattern) {
1009
- const token = "::GLOBSTAR::";
1010
- return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1011
- }
1012
- /**
1013
- * Formats a file id by removing the file extension and prepending the runtime prefix.
1014
- *
1015
- * @param id - The file ID to format.
1016
- * @returns The formatted file ID.
1017
- */
1018
- #formatId(id) {
1019
- const formattedId = toFilePath(id);
1020
- return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
1021
- }
1022
- /**
1023
- * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
1024
- *
1025
- * @param id - The id to resolve.
1026
- * @returns The resolved file id if it exists, otherwise undefined.
1027
- */
1028
- #resolveId(id) {
1029
- if (this.#ids[this.#formatId(id)]) {
1030
- return this.#ids[this.#formatId(id)] || false;
1031
- }
1032
- return false;
1033
- }
1034
- /**
1035
- * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1036
- *
1037
- * @param path - The path to resolve.
1038
- * @param options - Optional parameters for resolving the path.
1039
- * @returns The resolved file path if it exists, otherwise undefined.
1040
- */
1041
- #resolvePath(path, options = {}) {
1042
- if (isType.isAbsolutePath(path)) {
1043
- if (this.#existsSync(path)) {
1044
- return path;
1045
- }
1046
- const result = this.#checkVariants(path);
1047
- if (result) {
1048
- return result;
1049
- }
1050
- }
1051
- for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
1052
- const request = joinPaths.joinPaths(parentPath, path);
1053
- if (this.#existsSync(request)) {
1054
- return request;
1055
- }
1056
- const result = this.#checkVariants(request);
1057
- if (result) {
1058
- return result;
1059
- }
1060
- }
1061
- return false;
1062
- }
1063
- /**
1064
- * Resolves parent paths for a given request.
1065
- *
1066
- * @param request - The request path to resolve parent paths for.
1067
- * @param parents - An optional array of parent paths to consider.
1068
- * @returns An array of resolved parent paths.
1069
- */
1070
- #resolveParentPaths(request, parents = []) {
1071
- let paths = [
1072
- this.#context.workspaceConfig.workspaceRoot,
1073
- joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
1074
- ];
1075
- if (this.#context.tsconfig.options.paths) {
1076
- 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) => {
1077
- if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
1078
- ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
1079
- }
1080
- return ret;
1081
- }, paths) : paths;
1082
- }
1083
- return paths.reduce((ret, path) => {
1084
- if (!ret.includes(path)) {
1085
- ret.push(path);
1086
- }
1087
- return ret;
1088
- }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1089
- }
1090
- /**
1091
- * Clears the resolver cache for a given path.
1092
- *
1093
- * @param path - The path to clear the resolver cache for.
1094
- */
1095
- #clearResolverCache(path) {
1096
- this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
770
+ return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
1097
771
  }
1098
772
  /**
1099
- * Check if the file exists with different variants (index, extensions).
773
+ * Normalizes a given module id by resolving it against the built-ins path.
1100
774
  *
1101
- * @param request - The request path to check.
1102
- * @param parentPath - An optional parent path to prepend to the request.
1103
- * @returns The file path if it exists, otherwise false.
775
+ * @param id - The module id to normalize.
776
+ * @returns The normalized module id.
1104
777
  */
1105
- #checkVariants(request, parentPath) {
1106
- const path = parentPath ? joinPaths.joinPaths(parentPath, request) : request;
1107
- let file = this.#checkExtensions(path);
1108
- if (file) {
1109
- return file;
1110
- }
1111
- file = this.#checkIndex(path);
1112
- if (file) {
1113
- return file;
1114
- }
1115
- return false;
778
+ #normalizeId(id) {
779
+ return normalizeId(id, this.#context.config.output.builtinPrefix);
1116
780
  }
1117
781
  /**
1118
- * Check if the index file exists in the given request path.
782
+ * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
1119
783
  *
1120
- * @param request - The request path to check.
1121
- * @returns The index file path if it exists, otherwise false.
784
+ * @param path - The path to normalize.
785
+ * @returns The normalized path.
1122
786
  */
1123
- #checkIndex(request) {
1124
- let file = joinPaths.joinPaths(request, "index");
1125
- if (this.#existsSync(file)) {
1126
- return file;
1127
- }
1128
- file = this.#checkExtensions(file);
1129
- if (file) {
1130
- return file;
1131
- }
1132
- return false;
787
+ #normalizePath(path) {
788
+ return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
1133
789
  }
1134
790
  /**
1135
- * Check if the file exists with different extensions.
791
+ * Builds a regular expression from a string pattern for path matching.
1136
792
  *
1137
- * @param request - The request path to check.
1138
- * @returns The file path if it exists with any of the checked extensions, otherwise false.
793
+ * @param path - The string pattern to convert.
794
+ * @returns A regular expression for matching paths.
1139
795
  */
1140
- #checkExtensions(request) {
1141
- let file = `${request}.ts`;
1142
- if (this.#existsSync(file)) {
1143
- return file;
1144
- }
1145
- file = `${request}.mts`;
1146
- if (this.#existsSync(file)) {
1147
- return file;
1148
- }
1149
- file = `${request}.cts`;
1150
- if (this.#existsSync(file)) {
1151
- return file;
1152
- }
1153
- file = `${request}.tsx`;
1154
- if (this.#existsSync(file)) {
1155
- return file;
1156
- }
1157
- file = `${request}.js`;
1158
- if (this.#existsSync(file)) {
1159
- return file;
1160
- }
1161
- file = `${request}.mjs`;
1162
- if (this.#existsSync(file)) {
1163
- return file;
1164
- }
1165
- file = `${request}.cjs`;
1166
- if (this.#existsSync(file)) {
1167
- return file;
1168
- }
1169
- file = `${request}.jsx`;
1170
- if (this.#existsSync(file)) {
1171
- return file;
1172
- }
1173
- file = `${request}.json`;
1174
- if (this.#existsSync(file)) {
1175
- return file;
1176
- }
1177
- file = `${request}.d.ts`;
1178
- if (this.#existsSync(file)) {
1179
- return file;
1180
- }
1181
- return false;
796
+ #buildRegex(path) {
797
+ const token = "::GLOBSTAR::";
798
+ return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1182
799
  }
1183
800
  /**
1184
801
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
@@ -1187,8 +804,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
1187
804
  * @returns A promise that resolves to a new virtual file system instance.
1188
805
  */
1189
806
  static async create(context) {
1190
- if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.cachePath, "fs.bin"))) {
1191
- const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.cachePath, "fs.bin"));
807
+ if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
808
+ const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.dataPath, "fs.bin"));
1192
809
  const message2 = new $__namespace.Message(buffer$1, false);
1193
810
  return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
1194
811
  }
@@ -1202,8 +819,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
1202
819
  * @returns A new virtual file system instance.
1203
820
  */
1204
821
  static createSync(context) {
1205
- if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.cachePath, "fs.bin"))) {
1206
- const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.cachePath, "fs.bin"));
822
+ if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
823
+ const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.dataPath, "fs.bin"));
1207
824
  const message2 = new $__namespace.Message(buffer$1, false);
1208
825
  return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
1209
826
  }
@@ -1214,19 +831,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
1214
831
  * A map of file ids to their metadata.
1215
832
  */
1216
833
  get metadata() {
1217
- return this.#metadata;
834
+ return new Proxy(this.#metadata, {
835
+ get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
836
+ return target[this.#normalizeId(prop)];
837
+ }, "get")
838
+ });
1218
839
  }
1219
840
  /**
1220
- * A map of module ids to their file paths.
841
+ * A map of file paths to their module ids.
1221
842
  */
1222
843
  get ids() {
1223
- return this.#ids;
844
+ return new Proxy(this.#paths, {
845
+ get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
846
+ return target[this.#normalizePath(prop)];
847
+ }, "get")
848
+ });
1224
849
  }
1225
850
  /**
1226
- * A map of virtual file paths to their IDs.
851
+ * A map of module ids to their file paths.
1227
852
  */
1228
853
  get paths() {
1229
- return this.#paths;
854
+ return new Proxy(this.#paths, {
855
+ get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
856
+ return target[this.#normalizeId(prop)];
857
+ }, "get")
858
+ });
859
+ }
860
+ get resolverCache() {
861
+ if (!this.#resolverCache) {
862
+ this.#resolverCache = flatCache.create({
863
+ cacheId: "module-resolution",
864
+ cacheDir: this.#context.cachePath,
865
+ ttl: 60 * 60 * 1e3,
866
+ lruSize: 5e3,
867
+ persistInterval: 100
868
+ });
869
+ }
870
+ return this.#resolverCache;
1230
871
  }
1231
872
  /**
1232
873
  * Creates a new instance of the {@link VirtualFileSystem}.
@@ -1271,17 +912,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1271
912
  * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
1272
913
  *
1273
914
  * @param pathOrId - The path or id to check.
1274
- * @param options - Optional parameters for resolving the path.
1275
915
  * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
1276
916
  */
1277
- isVirtual(pathOrId, options = {}) {
917
+ isVirtual(pathOrId, importer, options = {}) {
1278
918
  if (!pathOrId) {
1279
919
  return false;
1280
920
  }
1281
- const resolvedPath = this.resolve(pathOrId, {
1282
- ...options,
1283
- pathType: "file"
1284
- });
921
+ const resolvedPath = this.resolveSync(pathOrId, importer, options);
1285
922
  if (!resolvedPath) {
1286
923
  return false;
1287
924
  }
@@ -1291,17 +928,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1291
928
  * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
1292
929
  *
1293
930
  * @param pathOrId - The path or id to check.
1294
- * @param options - Optional parameters for resolving the path.
1295
931
  * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
1296
932
  */
1297
- isPhysical(pathOrId, options = {}) {
933
+ isPhysical(pathOrId, importer, options = {}) {
1298
934
  if (!pathOrId) {
1299
935
  return false;
1300
936
  }
1301
- const resolvedPath = this.resolve(pathOrId, {
1302
- ...options,
1303
- pathType: "file"
1304
- });
937
+ const resolvedPath = this.resolveSync(pathOrId, importer, options);
1305
938
  if (!resolvedPath) {
1306
939
  return false;
1307
940
  }
@@ -1323,16 +956,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
1323
956
  * @param path - The path to create the directory at.
1324
957
  */
1325
958
  unlinkSync(path, options) {
1326
- const formattedPath = toFilePath(path);
1327
- if (!this.isFile(formattedPath)) {
959
+ if (!this.isFile(this.#normalizePath(path))) {
1328
960
  return;
1329
961
  }
1330
- this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
1331
- this.#unifiedFS.resolveFS(path, options).unlinkSync(formattedPath);
1332
- if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1333
- delete this.metadata[this.paths[formattedPath]];
962
+ this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
963
+ this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
964
+ if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
965
+ delete this.#metadata[this.#ids[this.#normalizePath(path)]];
966
+ delete this.#ids[this.#normalizePath(path)];
967
+ delete this.#paths[this.#normalizeId(path)];
968
+ this.#resolverCache.delete(this.#normalizePath(path));
1334
969
  }
1335
- this.#clearResolverCache(formattedPath);
1336
970
  }
1337
971
  /**
1338
972
  * Removes a file in the virtual file system (VFS).
@@ -1340,19 +974,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
1340
974
  * @param path - The path to create the directory at.
1341
975
  */
1342
976
  async unlink(path, options) {
1343
- const formattedPath = toFilePath(path);
1344
- if (!this.isFile(formattedPath)) {
977
+ if (!this.isFile(this.#normalizePath(path))) {
1345
978
  return;
1346
979
  }
1347
- this.#log(types.LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
980
+ this.#log(types.LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
1348
981
  if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
1349
- await this.#unifiedFS.resolveFS(path, options).promises.unlink(formattedPath);
1350
- if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1351
- delete this.metadata[this.paths[formattedPath]];
982
+ await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
983
+ if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
984
+ delete this.#metadata[this.#ids[this.#normalizePath(path)]];
1352
985
  }
1353
- this.#clearResolverCache(formattedPath);
1354
986
  } else {
1355
- this.unlinkSync(formattedPath, options);
987
+ this.unlinkSync(this.#normalizePath(path), options);
1356
988
  }
1357
989
  }
1358
990
  /**
@@ -1362,15 +994,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1362
994
  * @param options - Options for creating the directory.
1363
995
  */
1364
996
  rmdirSync(path, options = {}) {
1365
- const formattedPath = toFilePath(path);
1366
- if (!this.isDirectory(formattedPath)) {
997
+ if (!this.isDirectory(this.#normalizePath(path))) {
1367
998
  return;
1368
999
  }
1369
- this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
1370
- this.#unifiedFS.resolveFS(path, options).rmdirSync(formattedPath, defu2__default.default(options, {
1000
+ this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
1001
+ this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu2__default.default(options, {
1371
1002
  recursive: true
1372
1003
  }));
1373
- this.#clearResolverCache(formattedPath);
1374
1004
  }
1375
1005
  /**
1376
1006
  * Removes a directory in the virtual file system (VFS).
@@ -1380,19 +1010,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
1380
1010
  * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1381
1011
  */
1382
1012
  async rmdir(path, options = {}) {
1383
- const formattedPath = toFilePath(path);
1384
- if (!this.isDirectory(formattedPath)) {
1013
+ if (!this.isDirectory(this.#normalizePath(path))) {
1385
1014
  return;
1386
1015
  }
1387
- this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
1016
+ this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
1388
1017
  if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
1389
- await this.#unifiedFS.resolveFS(path, options).promises.rm(formattedPath, defu2__default.default(options, {
1018
+ await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu2__default.default(options, {
1390
1019
  force: true,
1391
1020
  recursive: true
1392
1021
  }));
1393
- this.#clearResolverCache(formattedPath);
1394
1022
  } else {
1395
- this.rmdirSync(formattedPath, defu2__default.default(options ?? {}, {
1023
+ this.rmdirSync(this.#normalizePath(path), defu2__default.default(options ?? {}, {
1396
1024
  force: true,
1397
1025
  recursive: true
1398
1026
  }));
@@ -1406,11 +1034,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
1406
1034
  * @returns A promise that resolves when the file is removed.
1407
1035
  */
1408
1036
  async rm(path, options = {}) {
1409
- this.#log(types.LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
1410
- if (this.isDirectory(path)) {
1411
- return this.rmdir(path, options);
1037
+ this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1038
+ if (this.isDirectory(this.#normalizePath(path))) {
1039
+ return this.rmdir(this.#normalizePath(path), options);
1412
1040
  }
1413
- return this.unlink(path, options);
1041
+ return this.unlink(this.#normalizePath(path), options);
1414
1042
  }
1415
1043
  /**
1416
1044
  * Synchronously removes a file or directory in the virtual file system (VFS).
@@ -1419,11 +1047,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
1419
1047
  * @param options - Options for removing the file or directory.
1420
1048
  */
1421
1049
  rmSync(path, options = {}) {
1422
- this.#log(types.LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
1423
- if (this.isDirectory(path)) {
1424
- return this.rmdirSync(path, options);
1050
+ this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1051
+ if (this.isDirectory(this.#normalizePath(path))) {
1052
+ return this.rmdirSync(this.#normalizePath(path), options);
1425
1053
  }
1426
- return this.unlinkSync(path, options);
1054
+ return this.unlinkSync(this.#normalizePath(path), options);
1427
1055
  }
1428
1056
  /**
1429
1057
  * Creates a directory in the virtual file system (VFS).
@@ -1433,9 +1061,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
1433
1061
  * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1434
1062
  */
1435
1063
  mkdirSync(path, options = {}) {
1436
- const filePath = toFilePath(path);
1437
- this.#clearResolverCache(filePath);
1438
- return this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2__default.default(options ?? {}, {
1064
+ return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2__default.default(omit.omit(options, [
1065
+ "mode"
1066
+ ]), {
1439
1067
  recursive: true
1440
1068
  }));
1441
1069
  }
@@ -1448,17 +1076,19 @@ var VirtualFileSystem = class _VirtualFileSystem {
1448
1076
  */
1449
1077
  async mkdir(path, options = {}) {
1450
1078
  let result;
1451
- const filePath = toFilePath(path);
1452
- if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath, options).promises.mkdir)) {
1453
- result = await this.#unifiedFS.resolveFS(filePath, options).promises.mkdir(filePath, defu2__default.default(options ?? {}, {
1079
+ if (isFunction.isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
1080
+ result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu2__default.default(omit.omit(options, [
1081
+ "mode"
1082
+ ]), {
1454
1083
  recursive: true
1455
1084
  }));
1456
1085
  } else {
1457
- result = this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2__default.default(options ?? {}, {
1086
+ result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2__default.default(omit.omit(options, [
1087
+ "mode"
1088
+ ]), {
1458
1089
  recursive: true
1459
1090
  }));
1460
1091
  }
1461
- this.#clearResolverCache(filePath);
1462
1092
  return result;
1463
1093
  }
1464
1094
  /**
@@ -1470,17 +1100,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
1470
1100
  async glob(patterns) {
1471
1101
  const results = [];
1472
1102
  for (const pattern of toArray.toArray(patterns)) {
1473
- const normalized = this.formatPath(pattern);
1103
+ const normalized = this.#normalizePath(pattern);
1474
1104
  if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1475
- const resolved = this.resolve(normalized, {
1476
- pathType: "file"
1477
- });
1105
+ const resolved = this.resolveSync(normalized);
1478
1106
  if (resolved && !results.includes(resolved)) {
1479
1107
  results.push(resolved);
1480
1108
  }
1481
1109
  continue;
1482
1110
  }
1483
- const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1111
+ const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1484
1112
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1485
1113
  const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1486
1114
  const stack = [
@@ -1495,7 +1123,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1495
1123
  continue;
1496
1124
  }
1497
1125
  for (const entry of entries) {
1498
- const full = this.formatPath(joinPaths.joinPaths(dir, entry));
1126
+ const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
1499
1127
  let stats;
1500
1128
  try {
1501
1129
  stats = this.#unifiedFS.lstatSync(full);
@@ -1507,9 +1135,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1507
1135
  stack.push(full);
1508
1136
  } else if (stats.isFile()) {
1509
1137
  if (this.#buildRegex(absPattern).test(full)) {
1510
- const resolved = this.resolve(full, {
1511
- pathType: "file"
1512
- });
1138
+ const resolved = this.resolveSync(full);
1513
1139
  if (resolved && !results.includes(resolved)) {
1514
1140
  results.push(resolved);
1515
1141
  }
@@ -1529,17 +1155,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
1529
1155
  globSync(patterns) {
1530
1156
  const results = [];
1531
1157
  for (const pattern of toArray.toArray(patterns)) {
1532
- const normalized = this.formatPath(pattern);
1158
+ const normalized = this.#normalizePath(pattern);
1533
1159
  if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1534
- const resolved = this.resolve(normalized, {
1535
- pathType: "file"
1536
- });
1160
+ const resolved = this.resolveSync(normalized);
1537
1161
  if (resolved && !results.includes(resolved)) {
1538
1162
  results.push(resolved);
1539
1163
  }
1540
1164
  continue;
1541
1165
  }
1542
- const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1166
+ const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1543
1167
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1544
1168
  const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1545
1169
  const stack = [
@@ -1554,7 +1178,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1554
1178
  continue;
1555
1179
  }
1556
1180
  for (const entry of entries) {
1557
- const full = this.formatPath(joinPaths.joinPaths(dir, entry));
1181
+ const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
1558
1182
  let stats;
1559
1183
  try {
1560
1184
  stats = this.#unifiedFS.lstatSync(full);
@@ -1566,9 +1190,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1566
1190
  stack.push(full);
1567
1191
  } else if (stats.isFile()) {
1568
1192
  if (this.#buildRegex(absPattern).test(full)) {
1569
- const resolved = this.resolve(full, {
1570
- pathType: "file"
1571
- });
1193
+ const resolved = this.resolveSync(full);
1572
1194
  if (resolved && !results.includes(resolved)) {
1573
1195
  results.push(resolved);
1574
1196
  }
@@ -1638,21 +1260,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
1638
1260
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1639
1261
  */
1640
1262
  async readFile(pathOrId, options = "utf8") {
1641
- if (!pathOrId) {
1642
- return void 0;
1643
- }
1644
- const filePath = this.resolve(toFilePath(pathOrId), {
1645
- pathType: "file"
1646
- });
1647
- if (filePath) {
1263
+ const filePath = await this.resolve(pathOrId);
1264
+ if (filePath && this.isFile(filePath)) {
1648
1265
  let result;
1649
1266
  if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
1650
1267
  result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1651
1268
  } else {
1652
1269
  result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1653
1270
  }
1654
- const content = isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1655
- return content;
1271
+ return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1656
1272
  }
1657
1273
  return void 0;
1658
1274
  }
@@ -1663,16 +1279,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
1663
1279
  * @returns The contents of the file as a string, or undefined if the file does not exist.
1664
1280
  */
1665
1281
  readFileSync(pathOrId, options = "utf8") {
1666
- if (!pathOrId) {
1667
- return void 0;
1668
- }
1669
- const filePath = this.resolve(toFilePath(pathOrId), {
1670
- pathType: "file"
1671
- });
1672
- if (filePath) {
1282
+ const filePath = this.resolveSync(pathOrId);
1283
+ if (filePath && this.isFile(filePath)) {
1673
1284
  const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1674
- const content = isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1675
- return content;
1285
+ return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1676
1286
  }
1677
1287
  return void 0;
1678
1288
  }
@@ -1685,34 +1295,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
1685
1295
  * @returns A promise that resolves when the file is written.
1686
1296
  */
1687
1297
  async writeFile(path, data = "", options = "utf8") {
1688
- const formattedPath = this.formatPath(path);
1689
- if (!this.isDirectory(filePathFns.findFilePath(formattedPath))) {
1690
- await this.mkdir(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1298
+ if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
1299
+ await this.mkdir(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
1691
1300
  }
1692
- let code = isVirtualFileData(data) ? data.code : data;
1301
+ const metadata = isVirtualFileData(data) ? data : {};
1302
+ metadata.id = this.#normalizeId(path);
1303
+ let code = isVirtualFileData(data) ? metadata.code : data;
1693
1304
  if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString.isSetString(code)) {
1694
- const resolvedConfig = await prettier.resolveConfig(formattedPath);
1305
+ const resolvedConfig = await prettier.resolveConfig(this.#normalizePath(path));
1695
1306
  if (resolvedConfig) {
1696
1307
  code = await prettier.format(code, {
1697
- absolutePath: formattedPath,
1308
+ absolutePath: this.#normalizePath(path),
1698
1309
  ...resolvedConfig
1699
1310
  });
1700
1311
  }
1701
1312
  }
1702
- const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1703
- this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
1704
- this.metadata[formattedPath] = {
1313
+ const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1314
+ this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
1315
+ this.#metadata[metadata.id] = {
1705
1316
  mode: outputMode,
1706
1317
  variant: "normal",
1707
1318
  timestamp: Date.now(),
1708
- ...isVirtualFileData(data) ? data : {}
1319
+ ...metadata
1709
1320
  };
1710
- this.#clearResolverCache(formattedPath);
1711
- const ifs = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1321
+ this.#paths[metadata.id] = this.#normalizePath(path);
1322
+ this.#ids[this.#normalizePath(path)] = metadata.id;
1323
+ const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1712
1324
  if (isFunction.isFunction(ifs.promises.writeFile)) {
1713
- return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1325
+ return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
1326
+ "mode"
1327
+ ]) : "utf8");
1714
1328
  }
1715
- return ifs.writeFileSync(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1329
+ return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
1330
+ "mode"
1331
+ ]) : "utf8");
1716
1332
  }
1717
1333
  /**
1718
1334
  * Synchronously writes a file to the virtual file system (VFS).
@@ -1722,21 +1338,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
1722
1338
  * @param options - Optional parameters for writing the file.
1723
1339
  */
1724
1340
  writeFileSync(path, data = "", options = "utf8") {
1725
- const formattedPath = this.formatPath(path);
1726
- if (!this.isDirectory(filePathFns.findFilePath(formattedPath))) {
1727
- this.mkdirSync(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1728
- }
1729
- const code = isVirtualFileData(data) ? data.code : data;
1730
- const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1731
- this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
1732
- this.metadata[formattedPath] = {
1341
+ if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
1342
+ this.mkdirSync(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
1343
+ }
1344
+ const metadata = isVirtualFileData(data) ? data : {};
1345
+ metadata.id = this.#normalizeId(path);
1346
+ const code = isVirtualFileData(data) ? metadata.code : data;
1347
+ const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1348
+ this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
1349
+ this.#metadata[metadata.id] = {
1733
1350
  mode: outputMode,
1734
1351
  variant: "normal",
1735
1352
  timestamp: Date.now(),
1736
- ...isVirtualFileData(data) ? data : {}
1353
+ ...metadata
1737
1354
  };
1738
- this.#clearResolverCache(formattedPath);
1739
- const writeStream = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1355
+ this.#paths[metadata.id] = this.#normalizePath(path);
1356
+ this.#ids[this.#normalizePath(path)] = metadata.id;
1357
+ const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
1740
1358
  try {
1741
1359
  writeStream.write(code);
1742
1360
  } finally {
@@ -1750,7 +1368,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1750
1368
  * @returns `true` if the file exists, otherwise `false`.
1751
1369
  */
1752
1370
  existsSync(pathOrId) {
1753
- return this.resolve(pathOrId) !== false;
1371
+ return !!this.resolveSync(pathOrId);
1754
1372
  }
1755
1373
  /**
1756
1374
  * Retrieves the metadata of a file in the virtual file system (VFS).
@@ -1759,7 +1377,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1759
1377
  * @returns The metadata of the file, or undefined if the file does not exist.
1760
1378
  */
1761
1379
  getMetadata(pathOrId) {
1762
- const resolved = this.resolve(pathOrId);
1380
+ const resolved = this.resolveSync(pathOrId);
1763
1381
  if (resolved && this.metadata[resolved]) {
1764
1382
  return this.metadata[resolved];
1765
1383
  }
@@ -1775,7 +1393,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1775
1393
  * @returns `true` if the file exists, otherwise `false`.
1776
1394
  */
1777
1395
  isFile(pathOrId) {
1778
- const resolved = this.resolve(pathOrId);
1396
+ const resolved = this.resolveSync(pathOrId);
1779
1397
  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()));
1780
1398
  }
1781
1399
  /**
@@ -1785,7 +1403,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1785
1403
  * @returns `true` if the directory exists, otherwise `false`.
1786
1404
  */
1787
1405
  isDirectory(pathOrId) {
1788
- const resolved = this.resolve(pathOrId);
1406
+ const resolved = this.resolveSync(pathOrId);
1789
1407
  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()));
1790
1408
  }
1791
1409
  /**
@@ -1795,7 +1413,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1795
1413
  * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1796
1414
  */
1797
1415
  async stat(pathOrId, options) {
1798
- return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1416
+ return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
1799
1417
  }
1800
1418
  /**
1801
1419
  * Synchronously retrieves the status of a file in the virtual file system (VFS).
@@ -1804,7 +1422,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1804
1422
  * @returns The file's status information, or false if the file does not exist.
1805
1423
  */
1806
1424
  statSync(pathOrId) {
1807
- return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1425
+ return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
1808
1426
  }
1809
1427
  /**
1810
1428
  * Retrieves the status of a symbolic link in the virtual file system (VFS).
@@ -1813,7 +1431,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1813
1431
  * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1814
1432
  */
1815
1433
  async lstat(pathOrId, options) {
1816
- return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1434
+ return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
1817
1435
  }
1818
1436
  /**
1819
1437
  * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
@@ -1822,7 +1440,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1822
1440
  * @returns The symbolic link's status information, or false if the link does not exist.
1823
1441
  */
1824
1442
  lstatSync(pathOrId, options) {
1825
- return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1443
+ return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
1826
1444
  }
1827
1445
  /**
1828
1446
  * Resolves a path or ID to its real path in the virtual file system (VFS).
@@ -1831,52 +1449,113 @@ var VirtualFileSystem = class _VirtualFileSystem {
1831
1449
  * @returns The resolved real path if it exists, otherwise undefined.
1832
1450
  */
1833
1451
  realpathSync(pathOrId) {
1834
- const filePath = this.resolve(toFilePath(pathOrId));
1452
+ const filePath = this.resolveSync(pathOrId);
1835
1453
  if (!filePath) {
1836
- throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1454
+ throw new Error(`File not found: ${pathOrId}`);
1837
1455
  }
1838
1456
  return filePath;
1839
1457
  }
1840
1458
  /**
1841
- * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1459
+ * A helper function to resolve modules in the virtual file system (VFS).
1842
1460
  *
1843
- * @param pathOrId - The path or ID to resolve.
1844
- * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1845
- * @returns The resolved file path if it exists, otherwise undefined.
1461
+ * @remarks
1462
+ * This function can be used to resolve modules relative to the project root directory.
1463
+ *
1464
+ * @example
1465
+ * ```ts
1466
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
1467
+ * ```
1468
+ *
1469
+ * @param id - The module to resolve.
1470
+ * @param importer - An optional path to the importer module.
1471
+ * @param options - Additional resolution options.
1472
+ * @returns A promise that resolves to the resolved module path.
1846
1473
  */
1847
- resolve(pathOrId, options = {}) {
1848
- const formattedPathOrId = toFilePath(pathOrId);
1849
- const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash.murmurhash(options.paths)}` : ""}${options.pathType ? `-${options.pathType}` : ""}`;
1850
- if (this.#cachedResolver.has(resolverKey)) {
1851
- return this.#cachedResolver.get(resolverKey);
1852
- }
1853
- let result = this.#resolveId(formattedPathOrId);
1854
- if (!result) {
1855
- result = this.#resolvePath(formattedPathOrId, options);
1474
+ async resolve(id, importer, options = {}) {
1475
+ let result = this.resolverCache.get(this.#normalizeId(id));
1476
+ if (result) {
1477
+ return result;
1856
1478
  }
1479
+ result = this.paths[this.#normalizeId(id)];
1857
1480
  if (!result) {
1858
- result = false;
1481
+ const paths = options.paths ?? [];
1482
+ if (importer && !paths.includes(importer)) {
1483
+ paths.push(importer);
1484
+ }
1485
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
1486
+ paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
1487
+ paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
1488
+ 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) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1489
+ for (const combination of resolve.getResolutionCombinations(id, {
1490
+ paths
1491
+ })) {
1492
+ if (this.#existsSync(combination)) {
1493
+ result = combination;
1494
+ }
1495
+ }
1496
+ try {
1497
+ result = await resolve.resolve(id, {
1498
+ paths
1499
+ });
1500
+ } catch {
1501
+ }
1859
1502
  }
1860
- if (result && options.withExtension === false) {
1861
- return result.replace(/\.[m|c]?[t|j]sx?$/, "");
1503
+ if (result) {
1504
+ result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
1505
+ this.resolverCache.set(this.#normalizeId(id), result);
1862
1506
  }
1863
- this.#cachedResolver.set(resolverKey, result);
1864
1507
  return result;
1865
1508
  }
1866
1509
  /**
1867
- * Converts a relative path to an absolute path based on the workspace and project root.
1510
+ * A synchronous helper function to resolve modules using the Jiti resolver
1868
1511
  *
1869
- * @param path - The relative path to convert.
1870
- * @returns The absolute path.
1512
+ * @remarks
1513
+ * This function can be used to resolve modules relative to the project root directory.
1514
+ *
1515
+ * @example
1516
+ * ```ts
1517
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
1518
+ * ```
1519
+ *
1520
+ * @param id - The module to resolve.
1521
+ * @param importer - An optional path to the importer module.
1522
+ * @param options - Additional resolution options.
1523
+ * @returns The resolved module path.
1871
1524
  */
1872
- formatPath(path) {
1873
- const formattedPath = toFilePath(path);
1874
- if (isType.isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1875
- return formattedPath;
1876
- } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1877
- return joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1525
+ resolveSync(id, importer, options = {}) {
1526
+ let result = this.resolverCache.get(this.#normalizeId(id));
1527
+ if (result) {
1528
+ return result;
1878
1529
  }
1879
- return formattedPath;
1530
+ result = this.paths[this.#normalizeId(id)];
1531
+ if (!result) {
1532
+ const paths = options.paths ?? [];
1533
+ if (importer && !paths.includes(importer)) {
1534
+ paths.push(importer);
1535
+ }
1536
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
1537
+ paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
1538
+ paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
1539
+ 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) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1540
+ for (const combination of resolve.getResolutionCombinations(id, {
1541
+ paths
1542
+ })) {
1543
+ if (this.#existsSync(combination)) {
1544
+ result = combination;
1545
+ }
1546
+ }
1547
+ try {
1548
+ result = resolve.resolveSync(id, {
1549
+ paths
1550
+ });
1551
+ } catch {
1552
+ }
1553
+ }
1554
+ if (result) {
1555
+ result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
1556
+ this.resolverCache.set(this.#normalizeId(id), result);
1557
+ }
1558
+ return result;
1880
1559
  }
1881
1560
  /**
1882
1561
  * Disposes of the virtual file system (VFS) by saving its state to disk.
@@ -1885,7 +1564,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1885
1564
  if (!this.#isDisposed) {
1886
1565
  this.#isDisposed = true;
1887
1566
  this.#log(types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
1888
- await this.unlink(joinPaths.joinPaths(this.#context.cachePath, "fs.bin"));
1567
+ await this.unlink(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"));
1889
1568
  const message = new $__namespace.Message();
1890
1569
  const fs2 = message.initRoot(FileSystem);
1891
1570
  const virtualFS = this.#unifiedFS.toJSON();
@@ -1894,7 +1573,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1894
1573
  virtualFiles.forEach(([path, code], index) => {
1895
1574
  const fd = files.get(index);
1896
1575
  fd.path = path;
1897
- fd.code = code;
1576
+ fd.code = code || "";
1898
1577
  });
1899
1578
  const ids = fs2._initIds(Object.keys(this.ids).length);
1900
1579
  Object.entries(this.ids).forEach(([id, path], index) => {
@@ -1918,7 +1597,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
1918
1597
  });
1919
1598
  }
1920
1599
  });
1921
- await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.cachePath, "fs.bin"), message.toArrayBuffer());
1600
+ await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1601
+ this.#resolverCache.save(true);
1602
+ this.#log(types.LogLevelLabel.DEBUG, "Virtual file system disposed.");
1922
1603
  }
1923
1604
  }
1924
1605
  /**
@@ -1967,6 +1648,8 @@ var PowerlinesContext = class _PowerlinesContext {
1967
1648
  #envPaths;
1968
1649
  #fs;
1969
1650
  #tsconfig;
1651
+ #program;
1652
+ #resolvePatterns = [];
1970
1653
  #getConfigProps(config = {}) {
1971
1654
  return {
1972
1655
  variant: config.build?.variant,
@@ -2058,7 +1741,7 @@ var PowerlinesContext = class _PowerlinesContext {
2058
1741
  */
2059
1742
  get tsconfig() {
2060
1743
  if (!this.#tsconfig) {
2061
- this.#tsconfig = {
1744
+ this.tsconfig = {
2062
1745
  tsconfigFilePath: this.config.tsconfig
2063
1746
  };
2064
1747
  }
@@ -2069,6 +1752,7 @@ var PowerlinesContext = class _PowerlinesContext {
2069
1752
  */
2070
1753
  set tsconfig(value) {
2071
1754
  this.#tsconfig = value;
1755
+ this.#resolvePatterns = bundleRequire.tsconfigPathsToRegExp(value?.options?.paths ?? {});
2072
1756
  }
2073
1757
  /**
2074
1758
  * The virtual file system interface for the project
@@ -2193,6 +1877,106 @@ var PowerlinesContext = class _PowerlinesContext {
2193
1877
  return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
2194
1878
  }
2195
1879
  /**
1880
+ * The {@link Project} instance used for type reflection and module manipulation
1881
+ *
1882
+ * @see https://ts-morph.com/
1883
+ *
1884
+ * @remarks
1885
+ * This instance is created lazily on first access.
1886
+ */
1887
+ get program() {
1888
+ if (!this.#program) {
1889
+ this.#program = chunkSAS5EPBD_cjs.createProgram(this, {
1890
+ skipAddingFilesFromTsConfig: true
1891
+ });
1892
+ }
1893
+ return this.#program;
1894
+ }
1895
+ /**
1896
+ * A helper function to resolve modules in the Virtual File System
1897
+ *
1898
+ * @remarks
1899
+ * This function can be used to resolve modules relative to the project root directory.
1900
+ *
1901
+ * @example
1902
+ * ```ts
1903
+ * const resolved = await context.resolve("some-module", "/path/to/importer");
1904
+ * ```
1905
+ *
1906
+ * @param id - The module to resolve.
1907
+ * @param importer - An optional path to the importer module.
1908
+ * @param options - Additional resolution options.
1909
+ * @returns A promise that resolves to the resolved module path.
1910
+ */
1911
+ async resolveId(id, importer, options = {}) {
1912
+ if (this.fs.isVirtual(id)) {
1913
+ const result = await this.fs.resolve(id, importer, options);
1914
+ if (!result) {
1915
+ return void 0;
1916
+ }
1917
+ return {
1918
+ id: `\0${result}`,
1919
+ external: this.config.projectType !== "application"
1920
+ };
1921
+ }
1922
+ if (this.config.build.skipNodeModulesBundle) {
1923
+ if (bundleRequire.match(id, this.#resolvePatterns) || bundleRequire.match(id, this.config.build.noExternal)) {
1924
+ return void 0;
1925
+ }
1926
+ if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
1927
+ return {
1928
+ id,
1929
+ external: true
1930
+ };
1931
+ }
1932
+ if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(id)) {
1933
+ return {
1934
+ id,
1935
+ external: true
1936
+ };
1937
+ }
1938
+ } else {
1939
+ if (bundleRequire.match(id, this.config.build.noExternal)) {
1940
+ return void 0;
1941
+ }
1942
+ if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
1943
+ return {
1944
+ id,
1945
+ external: true
1946
+ };
1947
+ }
1948
+ }
1949
+ return void 0;
1950
+ }
1951
+ /**
1952
+ * A helper function to load modules from the Virtual File System
1953
+ *
1954
+ * @remarks
1955
+ * This function can be used to load modules relative to the project root directory.
1956
+ *
1957
+ * @example
1958
+ * ```ts
1959
+ * const module = await context.load("some-module", "/path/to/importer");
1960
+ * ```
1961
+ *
1962
+ * @param id - The module to load.
1963
+ * @returns A promise that resolves to the loaded module.
1964
+ */
1965
+ async load(id) {
1966
+ const resolvedId = await this.fs.resolve(id);
1967
+ if (!resolvedId) {
1968
+ return void 0;
1969
+ }
1970
+ const code = await this.fs.readFile(resolvedId);
1971
+ if (!code) {
1972
+ return void 0;
1973
+ }
1974
+ return {
1975
+ code,
1976
+ map: null
1977
+ };
1978
+ }
1979
+ /**
2196
1980
  * Get the builtin virtual files that exist in the Powerlines virtual file system
2197
1981
  */
2198
1982
  async getBuiltins() {
@@ -2529,6 +2313,24 @@ var PowerlinesContext = class _PowerlinesContext {
2529
2313
  ret.push(plugin);
2530
2314
  return ret;
2531
2315
  }, []);
2316
+ if (this.config.tsconfig) {
2317
+ this.config.tsconfig = chunkISBHXSDH_cjs.replacePathTokens(this, this.config.tsconfig);
2318
+ }
2319
+ if (this.config.output.dts) {
2320
+ this.config.output.dts = chunkISBHXSDH_cjs.replacePathTokens(this, this.config.output.dts);
2321
+ }
2322
+ if (this.config.build.polyfill) {
2323
+ this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => chunkISBHXSDH_cjs.replacePathTokens(this, polyfill));
2324
+ }
2325
+ if (this.config.output.assets) {
2326
+ this.config.output.assets = this.config.output.assets.map((asset) => ({
2327
+ ...asset,
2328
+ glob: chunkISBHXSDH_cjs.replacePathTokens(this, asset.glob),
2329
+ ignore: asset.ignore ? asset.ignore.map((ignore) => chunkISBHXSDH_cjs.replacePathTokens(this, ignore)) : void 0,
2330
+ input: chunkISBHXSDH_cjs.replacePathTokens(this, asset.input),
2331
+ output: chunkISBHXSDH_cjs.replacePathTokens(this, asset.output)
2332
+ }));
2333
+ }
2532
2334
  this.#fs ??= await VirtualFileSystem.create(this);
2533
2335
  }
2534
2336
  mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
@@ -2554,7 +2356,6 @@ var PowerlinesContext = class _PowerlinesContext {
2554
2356
 
2555
2357
  exports.PowerlinesContext = PowerlinesContext;
2556
2358
  exports.VirtualFileSystem = VirtualFileSystem;
2557
- exports.__VFS_PATCH__ = __VFS_PATCH__;
2558
2359
  exports.__VFS_REVERT__ = __VFS_REVERT__;
2559
2360
  exports.addPluginHook = addPluginHook;
2560
2361
  exports.checkDedupe = checkDedupe;