powerlines 0.40.9 → 0.40.10

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 (117) hide show
  1. package/dist/{api-5cmWHacj.cjs → api-Ba2OWiVz.cjs} +141 -83
  2. package/dist/{api-BCnLkGu9.mjs → api-D9WIJJt3.mjs} +142 -84
  3. package/dist/api-D9WIJJt3.mjs.map +1 -0
  4. package/dist/astro.cjs +2 -2
  5. package/dist/astro.d.cts +1 -1
  6. package/dist/astro.d.mts +5 -5
  7. package/dist/astro.mjs +2 -2
  8. package/dist/{config-C60sAYU4.d.cts → config-BS54DOEG.d.mts} +2 -2
  9. package/dist/{config-C60sAYU4.d.cts.map → config-BS54DOEG.d.mts.map} +1 -1
  10. package/dist/{config-CzpJjE2i.d.mts → config-BXRlCZ9z.d.cts} +2 -2
  11. package/dist/{config-CzpJjE2i.d.mts.map → config-BXRlCZ9z.d.cts.map} +1 -1
  12. package/dist/{config-B3Xvipn4.d.cts → config-CqsFCFR8.d.cts} +5 -1
  13. package/dist/config-CqsFCFR8.d.cts.map +1 -0
  14. package/dist/{config-BLihpN3D.d.mts → config-zlkThEoC.d.mts} +5 -1
  15. package/dist/config-zlkThEoC.d.mts.map +1 -0
  16. package/dist/config.d.cts +1 -1
  17. package/dist/config.d.mts +2 -2
  18. package/dist/context/index.cjs +1 -1
  19. package/dist/context/index.d.cts +1 -1
  20. package/dist/context/index.d.mts +4 -4
  21. package/dist/context/index.mjs +1 -1
  22. package/dist/{esbuild-BsoRHGIH.mjs → esbuild-CCuAvKw8.mjs} +2 -2
  23. package/dist/{esbuild-BsoRHGIH.mjs.map → esbuild-CCuAvKw8.mjs.map} +1 -1
  24. package/dist/{esbuild-DiRy3ZaC.cjs → esbuild-CYu81t25.cjs} +1 -1
  25. package/dist/esbuild.cjs +2 -2
  26. package/dist/esbuild.d.cts +1 -1
  27. package/dist/esbuild.d.mts +4 -4
  28. package/dist/esbuild.mjs +2 -2
  29. package/dist/farm.cjs +1 -1
  30. package/dist/farm.d.cts +1 -1
  31. package/dist/farm.d.mts +4 -4
  32. package/dist/farm.mjs +1 -1
  33. package/dist/{index-DQR_ke3L.d.mts → index-BPdDWzbp.d.cts} +2 -2
  34. package/dist/{index-DQR_ke3L.d.mts.map → index-BPdDWzbp.d.cts.map} +1 -1
  35. package/dist/{index-Dv0-yJZY.d.cts → index-CRLhknww.d.mts} +2 -2
  36. package/dist/{index-Dv0-yJZY.d.cts.map → index-CRLhknww.d.mts.map} +1 -1
  37. package/dist/{index-DT3dtimM.d.mts → index-DjfS4slR.d.mts} +2 -2
  38. package/dist/{index-DT3dtimM.d.mts.map → index-DjfS4slR.d.mts.map} +1 -1
  39. package/dist/{index-Ct46ECR2.d.mts → index-PJqBw8CG.d.mts} +2 -2
  40. package/dist/{index-Ct46ECR2.d.mts.map → index-PJqBw8CG.d.mts.map} +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.d.cts +5 -5
  43. package/dist/index.d.mts +5 -5
  44. package/dist/index.mjs +1 -1
  45. package/dist/next.cjs +2 -2
  46. package/dist/next.mjs +2 -2
  47. package/dist/nuxt.cjs +3 -3
  48. package/dist/nuxt.d.cts +1 -1
  49. package/dist/nuxt.d.mts +4 -4
  50. package/dist/nuxt.mjs +3 -3
  51. package/dist/{plugin-CiMsERtX.d.mts → plugin-CUXcGRD_.d.mts} +2 -2
  52. package/dist/{plugin-CiMsERtX.d.mts.map → plugin-CUXcGRD_.d.mts.map} +1 -1
  53. package/dist/{plugin-DtbGNmRb.d.cts → plugin-jeRiyjfy.d.cts} +2 -2
  54. package/dist/{plugin-DtbGNmRb.d.cts.map → plugin-jeRiyjfy.d.cts.map} +1 -1
  55. package/dist/plugin-utils.d.cts +3 -3
  56. package/dist/plugin-utils.d.cts.map +1 -1
  57. package/dist/plugin-utils.d.mts +7 -7
  58. package/dist/plugin-utils.d.mts.map +1 -1
  59. package/dist/{plugin-D6FK1hDg.d.cts → plugin-yR7bwKa_.d.cts} +2 -2
  60. package/dist/{plugin-D6FK1hDg.d.cts.map → plugin-yR7bwKa_.d.cts.map} +1 -1
  61. package/dist/{rolldown-KnzE_4YL.mjs → rolldown-CHbI0iMF.mjs} +2 -2
  62. package/dist/{rolldown-KnzE_4YL.mjs.map → rolldown-CHbI0iMF.mjs.map} +1 -1
  63. package/dist/{rolldown-B2ExPgjq.cjs → rolldown-CWW8TO6C.cjs} +1 -1
  64. package/dist/rolldown.cjs +2 -2
  65. package/dist/rolldown.d.cts +1 -1
  66. package/dist/rolldown.d.mts +4 -4
  67. package/dist/rolldown.mjs +2 -2
  68. package/dist/rollup.cjs +1 -1
  69. package/dist/rollup.d.cts +1 -1
  70. package/dist/rollup.d.mts +4 -4
  71. package/dist/rollup.mjs +1 -1
  72. package/dist/rspack.cjs +1 -1
  73. package/dist/rspack.d.cts +1 -1
  74. package/dist/rspack.d.mts +4 -4
  75. package/dist/rspack.mjs +1 -1
  76. package/dist/storage/index.d.cts +1 -1
  77. package/dist/storage/index.d.mts +4 -4
  78. package/dist/tsdown.cjs +2 -2
  79. package/dist/tsdown.d.cts +1 -1
  80. package/dist/tsdown.d.mts +4 -4
  81. package/dist/tsdown.mjs +2 -2
  82. package/dist/tsup.cjs +2 -2
  83. package/dist/tsup.d.cts +1 -1
  84. package/dist/tsup.d.mts +4 -4
  85. package/dist/tsup.mjs +2 -2
  86. package/dist/typescript/index.d.cts +1 -1
  87. package/dist/typescript/index.d.mts +4 -4
  88. package/dist/unloader.cjs +1 -1
  89. package/dist/unloader.d.cts +1 -1
  90. package/dist/unloader.d.mts +4 -4
  91. package/dist/unloader.mjs +1 -1
  92. package/dist/unplugin.cjs +1 -1
  93. package/dist/unplugin.d.cts +2 -2
  94. package/dist/unplugin.d.mts +4 -4
  95. package/dist/unplugin.mjs +1 -1
  96. package/dist/utils.d.cts +1 -1
  97. package/dist/utils.d.mts +2 -2
  98. package/dist/{vite-DRuqHJOi.cjs → vite-BSeJ1LCi.cjs} +1 -1
  99. package/dist/{vite-BJrqgN0s.mjs → vite-aRGnKynz.mjs} +2 -2
  100. package/dist/{vite-BJrqgN0s.mjs.map → vite-aRGnKynz.mjs.map} +1 -1
  101. package/dist/vite.cjs +2 -2
  102. package/dist/vite.d.cts +2 -2
  103. package/dist/vite.d.mts +5 -5
  104. package/dist/vite.mjs +2 -2
  105. package/dist/{webpack-Ubo4zeKP.cjs → webpack-BQiVW7uT.cjs} +1 -1
  106. package/dist/{webpack-Cd5Mx3qz.mjs → webpack-DlkAraA4.mjs} +2 -2
  107. package/dist/{webpack-Cd5Mx3qz.mjs.map → webpack-DlkAraA4.mjs.map} +1 -1
  108. package/dist/webpack.cjs +2 -2
  109. package/dist/webpack.d.cts +1 -1
  110. package/dist/webpack.d.mts +4 -4
  111. package/dist/webpack.mjs +2 -2
  112. package/dist/{write-file-BXi3LP7l.d.cts → write-file-D9MsaQ36.d.cts} +2 -2
  113. package/dist/{write-file-BXi3LP7l.d.cts.map → write-file-D9MsaQ36.d.cts.map} +1 -1
  114. package/package.json +28 -28
  115. package/dist/api-BCnLkGu9.mjs.map +0 -1
  116. package/dist/config-B3Xvipn4.d.cts.map +0 -1
  117. package/dist/config-BLihpN3D.d.mts.map +0 -1
@@ -75,7 +75,7 @@ let unplugin = require("unplugin");
75
75
 
76
76
  //#region package.json
77
77
  var name = "powerlines";
78
- var version = "0.40.9";
78
+ var version = "0.40.10";
79
79
 
80
80
  //#endregion
81
81
  //#region src/_internal/helpers/generate-types.ts
@@ -668,6 +668,24 @@ FileSystem._Ids = __stryke_capnp.CompositeList(FileId);
668
668
  FileSystem._Storage = __stryke_capnp.CompositeList(FileStorage);
669
669
  FileSystem._Metadata = __stryke_capnp.CompositeList(FileMetadata);
670
670
 
671
+ //#endregion
672
+ //#region src/_internal/helpers/constants.ts
673
+ const DEFAULT_EXTENSIONS = [
674
+ "js",
675
+ "ts",
676
+ "cjs",
677
+ "cts",
678
+ "mjs",
679
+ "mts",
680
+ "tsx",
681
+ "jsx",
682
+ "json",
683
+ "json5",
684
+ "jsonc",
685
+ "md",
686
+ "mdx"
687
+ ];
688
+
671
689
  //#endregion
672
690
  //#region src/_internal/vfs.ts
673
691
  function toFilePath(path) {
@@ -824,6 +842,113 @@ var VirtualFileSystem = class VirtualFileSystem {
824
842
  }));
825
843
  }
826
844
  /**
845
+ * A helper function to resolve modules in the virtual file system (VFS).
846
+ *
847
+ * @remarks
848
+ * This function can be used to resolve modules relative to the project root directory.
849
+ *
850
+ * @example
851
+ * ```ts
852
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
853
+ * ```
854
+ *
855
+ * @param id - The module to resolve.
856
+ * @param importer - An optional path to the importer module.
857
+ * @param options - Additional resolution options.
858
+ * @returns A promise that resolves to the resolved module path.
859
+ */
860
+ #innerResolve = async (id, importer, options = {}) => {
861
+ let path = id;
862
+ if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
863
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
864
+ if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
865
+ const resolverCacheKey = (0, __stryke_hash.murmurhash)({
866
+ path: this.#normalizeId(path),
867
+ importer,
868
+ options
869
+ });
870
+ let result;
871
+ if (!this.#context.config.skipCache) {
872
+ result = this.resolverCache.get(resolverCacheKey);
873
+ if (result) return result;
874
+ }
875
+ result = this.paths[this.#normalizeId(path)];
876
+ if (!result) {
877
+ const paths = options.paths ?? [];
878
+ if (importer && !paths.includes(importer)) paths.push(importer);
879
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
880
+ paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
881
+ paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
882
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
883
+ for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
884
+ const { relativeKey, adapter } = this.#getStorage(combination);
885
+ if (await adapter.exists(relativeKey)) {
886
+ result = combination;
887
+ break;
888
+ }
889
+ }
890
+ if (!result) try {
891
+ result = await (0, __stryke_fs_resolve.resolve)(path, {
892
+ ...options,
893
+ paths
894
+ });
895
+ } catch {}
896
+ }
897
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
898
+ return result;
899
+ };
900
+ /**
901
+ * A synchronous helper function to resolve modules using the Jiti resolver
902
+ *
903
+ * @remarks
904
+ * This function can be used to resolve modules relative to the project root directory.
905
+ *
906
+ * @example
907
+ * ```ts
908
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
909
+ * ```
910
+ *
911
+ * @param id - The module to resolve.
912
+ * @param importer - An optional path to the importer module.
913
+ * @param options - Additional resolution options.
914
+ * @returns The resolved module path.
915
+ */
916
+ #innerResolveSync = (id, importer, options = {}) => {
917
+ let path = id;
918
+ if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
919
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
920
+ if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
921
+ let result;
922
+ if (!this.#context.config.skipCache) {
923
+ result = this.resolverCache.get(this.#normalizeId(path));
924
+ if (result) return result;
925
+ }
926
+ result = this.paths[this.#normalizeId(path)];
927
+ if (!result) {
928
+ const paths = options.paths ?? [];
929
+ if (importer && !paths.includes(importer)) paths.push(importer);
930
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
931
+ paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
932
+ paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
933
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
934
+ for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
935
+ const { relativeKey, adapter } = this.#getStorage(combination);
936
+ if (adapter.existsSync(relativeKey)) {
937
+ result = combination;
938
+ break;
939
+ }
940
+ }
941
+ if (!result) try {
942
+ result = (0, __stryke_fs_resolve.resolveSync)(path, {
943
+ ...options,
944
+ paths
945
+ });
946
+ } catch {}
947
+ }
948
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
949
+ return result;
950
+ };
951
+ /**
827
952
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
828
953
  *
829
954
  * @param context - The context of the virtual file system, typically containing options and logging functions.
@@ -1295,7 +1420,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1295
1420
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1296
1421
  */
1297
1422
  async read(path) {
1298
- const filePath = await this.resolve(path);
1423
+ const filePath = await this.resolve(path, void 0, { isFile: true });
1299
1424
  if (!filePath || !this.existsSync(filePath)) return;
1300
1425
  const { adapter } = this.#getStorage(filePath);
1301
1426
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1308,7 +1433,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1308
1433
  * @returns The contents of the file as a string, or undefined if the file does not exist.
1309
1434
  */
1310
1435
  readSync(path) {
1311
- const filePath = this.resolveSync(path);
1436
+ const filePath = this.resolveSync(path, void 0, { isFile: true });
1312
1437
  if (!filePath || !this.existsSync(filePath)) return;
1313
1438
  const { adapter } = this.#getStorage(filePath);
1314
1439
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1331,21 +1456,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1331
1456
  try {
1332
1457
  if (!options.skipFormat) code = await require_paths.format(this.#context, resolvedPath, data);
1333
1458
  } catch (err) {
1334
- if ([
1335
- "js",
1336
- "ts",
1337
- "cjs",
1338
- "cts",
1339
- "mjs",
1340
- "mts",
1341
- "tsx",
1342
- "jsx",
1343
- "json",
1344
- "json5",
1345
- "jsonc",
1346
- "md",
1347
- "mdx"
1348
- ].includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1459
+ if (DEFAULT_EXTENSIONS.includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1349
1460
  code = data;
1350
1461
  }
1351
1462
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, __stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, __stryke_convert_to_array.toArray)(code)).size)})`);
@@ -1459,43 +1570,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1459
1570
  * @returns A promise that resolves to the resolved module path.
1460
1571
  */
1461
1572
  async resolve(id, importer, options = {}) {
1462
- let path = id;
1463
- if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
1464
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1465
- if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
1466
- const resolverCacheKey = (0, __stryke_hash.murmurhash)({
1467
- path: this.#normalizeId(path),
1468
- importer,
1469
- options
1470
- });
1471
- let result;
1472
- if (!this.#context.config.skipCache) {
1473
- result = this.resolverCache.get(resolverCacheKey);
1474
- if (result) return result;
1475
- }
1476
- result = this.paths[this.#normalizeId(path)];
1477
- if (!result) {
1478
- const paths = options.paths ?? [];
1479
- if (importer && !paths.includes(importer)) paths.push(importer);
1480
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1481
- paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1482
- paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1483
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1484
- for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
1485
- const { relativeKey, adapter } = this.#getStorage(combination);
1486
- if (await adapter.exists(relativeKey)) {
1487
- result = combination;
1488
- break;
1489
- }
1573
+ let result = await this.#innerResolve(id, importer, options);
1574
+ if (result && options.isFile && await this.isDirectory(result) && !(0, __stryke_path_file_path_fns.hasFileExtension)(result)) {
1575
+ for (const ext of DEFAULT_EXTENSIONS) {
1576
+ result = await this.resolve(`${result}.${ext}`, importer, options);
1577
+ if (result) return result;
1490
1578
  }
1491
- if (!result) try {
1492
- result = await (0, __stryke_fs_resolve.resolve)(path, {
1493
- ...options,
1494
- paths
1495
- });
1496
- } catch {}
1579
+ return;
1497
1580
  }
1498
- if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
1499
1581
  return result;
1500
1582
  }
1501
1583
  /**
@@ -1515,38 +1597,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1515
1597
  * @returns The resolved module path.
1516
1598
  */
1517
1599
  resolveSync(id, importer, options = {}) {
1518
- let path = id;
1519
- if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
1520
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1521
- if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
1522
- let result;
1523
- if (!this.#context.config.skipCache) {
1524
- result = this.resolverCache.get(this.#normalizeId(path));
1525
- if (result) return result;
1526
- }
1527
- result = this.paths[this.#normalizeId(path)];
1528
- if (!result) {
1529
- const paths = options.paths ?? [];
1530
- if (importer && !paths.includes(importer)) paths.push(importer);
1531
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1532
- paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1533
- paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1534
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1535
- for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
1536
- const { relativeKey, adapter } = this.#getStorage(combination);
1537
- if (adapter.existsSync(relativeKey)) {
1538
- result = combination;
1539
- break;
1540
- }
1600
+ let result = this.#innerResolveSync(id, importer, options);
1601
+ if (result && options.isFile && this.isDirectorySync(result) && !(0, __stryke_path_file_path_fns.hasFileExtension)(result)) {
1602
+ for (const ext of DEFAULT_EXTENSIONS) {
1603
+ result = this.resolveSync(`${result}.${ext}`, importer, options);
1604
+ if (result) return result;
1541
1605
  }
1542
- if (!result) try {
1543
- result = (0, __stryke_fs_resolve.resolveSync)(path, {
1544
- ...options,
1545
- paths
1546
- });
1547
- } catch {}
1606
+ return;
1548
1607
  }
1549
- if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
1550
1608
  return result;
1551
1609
  }
1552
1610
  /**
@@ -70,7 +70,7 @@ import { setParseImpl } from "unplugin";
70
70
 
71
71
  //#region package.json
72
72
  var name = "powerlines";
73
- var version = "0.40.9";
73
+ var version = "0.40.10";
74
74
 
75
75
  //#endregion
76
76
  //#region src/_internal/helpers/generate-types.ts
@@ -663,6 +663,24 @@ FileSystem._Ids = $.CompositeList(FileId);
663
663
  FileSystem._Storage = $.CompositeList(FileStorage);
664
664
  FileSystem._Metadata = $.CompositeList(FileMetadata);
665
665
 
666
+ //#endregion
667
+ //#region src/_internal/helpers/constants.ts
668
+ const DEFAULT_EXTENSIONS = [
669
+ "js",
670
+ "ts",
671
+ "cjs",
672
+ "cts",
673
+ "mjs",
674
+ "mts",
675
+ "tsx",
676
+ "jsx",
677
+ "json",
678
+ "json5",
679
+ "jsonc",
680
+ "md",
681
+ "mdx"
682
+ ];
683
+
666
684
  //#endregion
667
685
  //#region src/_internal/vfs.ts
668
686
  function toFilePath(path) {
@@ -819,6 +837,113 @@ var VirtualFileSystem = class VirtualFileSystem {
819
837
  }));
820
838
  }
821
839
  /**
840
+ * A helper function to resolve modules in the virtual file system (VFS).
841
+ *
842
+ * @remarks
843
+ * This function can be used to resolve modules relative to the project root directory.
844
+ *
845
+ * @example
846
+ * ```ts
847
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
848
+ * ```
849
+ *
850
+ * @param id - The module to resolve.
851
+ * @param importer - An optional path to the importer module.
852
+ * @param options - Additional resolution options.
853
+ * @returns A promise that resolves to the resolved module path.
854
+ */
855
+ #innerResolve = async (id, importer, options = {}) => {
856
+ let path = id;
857
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
858
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
859
+ if (isAbsolutePath(path)) return path;
860
+ const resolverCacheKey = murmurhash({
861
+ path: this.#normalizeId(path),
862
+ importer,
863
+ options
864
+ });
865
+ let result;
866
+ if (!this.#context.config.skipCache) {
867
+ result = this.resolverCache.get(resolverCacheKey);
868
+ if (result) return result;
869
+ }
870
+ result = this.paths[this.#normalizeId(path)];
871
+ if (!result) {
872
+ const paths = options.paths ?? [];
873
+ if (importer && !paths.includes(importer)) paths.push(importer);
874
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
875
+ paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
876
+ paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
877
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
878
+ for (const combination of getResolutionCombinations(path, { paths })) {
879
+ const { relativeKey, adapter } = this.#getStorage(combination);
880
+ if (await adapter.exists(relativeKey)) {
881
+ result = combination;
882
+ break;
883
+ }
884
+ }
885
+ if (!result) try {
886
+ result = await resolve(path, {
887
+ ...options,
888
+ paths
889
+ });
890
+ } catch {}
891
+ }
892
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
893
+ return result;
894
+ };
895
+ /**
896
+ * A synchronous helper function to resolve modules using the Jiti resolver
897
+ *
898
+ * @remarks
899
+ * This function can be used to resolve modules relative to the project root directory.
900
+ *
901
+ * @example
902
+ * ```ts
903
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
904
+ * ```
905
+ *
906
+ * @param id - The module to resolve.
907
+ * @param importer - An optional path to the importer module.
908
+ * @param options - Additional resolution options.
909
+ * @returns The resolved module path.
910
+ */
911
+ #innerResolveSync = (id, importer, options = {}) => {
912
+ let path = id;
913
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
914
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
915
+ if (isAbsolutePath(path)) return path;
916
+ let result;
917
+ if (!this.#context.config.skipCache) {
918
+ result = this.resolverCache.get(this.#normalizeId(path));
919
+ if (result) return result;
920
+ }
921
+ result = this.paths[this.#normalizeId(path)];
922
+ if (!result) {
923
+ const paths = options.paths ?? [];
924
+ if (importer && !paths.includes(importer)) paths.push(importer);
925
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
926
+ paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
927
+ paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
928
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
929
+ for (const combination of getResolutionCombinations(path, { paths })) {
930
+ const { relativeKey, adapter } = this.#getStorage(combination);
931
+ if (adapter.existsSync(relativeKey)) {
932
+ result = combination;
933
+ break;
934
+ }
935
+ }
936
+ if (!result) try {
937
+ result = resolveSync(path, {
938
+ ...options,
939
+ paths
940
+ });
941
+ } catch {}
942
+ }
943
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
944
+ return result;
945
+ };
946
+ /**
822
947
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
823
948
  *
824
949
  * @param context - The context of the virtual file system, typically containing options and logging functions.
@@ -1290,7 +1415,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1290
1415
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1291
1416
  */
1292
1417
  async read(path) {
1293
- const filePath = await this.resolve(path);
1418
+ const filePath = await this.resolve(path, void 0, { isFile: true });
1294
1419
  if (!filePath || !this.existsSync(filePath)) return;
1295
1420
  const { adapter } = this.#getStorage(filePath);
1296
1421
  this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1303,7 +1428,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1303
1428
  * @returns The contents of the file as a string, or undefined if the file does not exist.
1304
1429
  */
1305
1430
  readSync(path) {
1306
- const filePath = this.resolveSync(path);
1431
+ const filePath = this.resolveSync(path, void 0, { isFile: true });
1307
1432
  if (!filePath || !this.existsSync(filePath)) return;
1308
1433
  const { adapter } = this.#getStorage(filePath);
1309
1434
  this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1326,21 +1451,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1326
1451
  try {
1327
1452
  if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
1328
1453
  } catch (err) {
1329
- if ([
1330
- "js",
1331
- "ts",
1332
- "cjs",
1333
- "cts",
1334
- "mjs",
1335
- "mts",
1336
- "tsx",
1337
- "jsx",
1338
- "json",
1339
- "json5",
1340
- "jsonc",
1341
- "md",
1342
- "mdx"
1343
- ].includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1454
+ if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1344
1455
  code = data;
1345
1456
  }
1346
1457
  this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob$1(toArray(code)).size)})`);
@@ -1454,43 +1565,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1454
1565
  * @returns A promise that resolves to the resolved module path.
1455
1566
  */
1456
1567
  async resolve(id, importer, options = {}) {
1457
- let path = id;
1458
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
1459
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1460
- if (isAbsolutePath(path)) return path;
1461
- const resolverCacheKey = murmurhash({
1462
- path: this.#normalizeId(path),
1463
- importer,
1464
- options
1465
- });
1466
- let result;
1467
- if (!this.#context.config.skipCache) {
1468
- result = this.resolverCache.get(resolverCacheKey);
1469
- if (result) return result;
1470
- }
1471
- result = this.paths[this.#normalizeId(path)];
1472
- if (!result) {
1473
- const paths = options.paths ?? [];
1474
- if (importer && !paths.includes(importer)) paths.push(importer);
1475
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1476
- paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1477
- paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1478
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1479
- for (const combination of getResolutionCombinations(path, { paths })) {
1480
- const { relativeKey, adapter } = this.#getStorage(combination);
1481
- if (await adapter.exists(relativeKey)) {
1482
- result = combination;
1483
- break;
1484
- }
1568
+ let result = await this.#innerResolve(id, importer, options);
1569
+ if (result && options.isFile && await this.isDirectory(result) && !hasFileExtension(result)) {
1570
+ for (const ext of DEFAULT_EXTENSIONS) {
1571
+ result = await this.resolve(`${result}.${ext}`, importer, options);
1572
+ if (result) return result;
1485
1573
  }
1486
- if (!result) try {
1487
- result = await resolve(path, {
1488
- ...options,
1489
- paths
1490
- });
1491
- } catch {}
1574
+ return;
1492
1575
  }
1493
- if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
1494
1576
  return result;
1495
1577
  }
1496
1578
  /**
@@ -1510,38 +1592,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1510
1592
  * @returns The resolved module path.
1511
1593
  */
1512
1594
  resolveSync(id, importer, options = {}) {
1513
- let path = id;
1514
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
1515
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1516
- if (isAbsolutePath(path)) return path;
1517
- let result;
1518
- if (!this.#context.config.skipCache) {
1519
- result = this.resolverCache.get(this.#normalizeId(path));
1520
- if (result) return result;
1521
- }
1522
- result = this.paths[this.#normalizeId(path)];
1523
- if (!result) {
1524
- const paths = options.paths ?? [];
1525
- if (importer && !paths.includes(importer)) paths.push(importer);
1526
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1527
- paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1528
- paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1529
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1530
- for (const combination of getResolutionCombinations(path, { paths })) {
1531
- const { relativeKey, adapter } = this.#getStorage(combination);
1532
- if (adapter.existsSync(relativeKey)) {
1533
- result = combination;
1534
- break;
1535
- }
1595
+ let result = this.#innerResolveSync(id, importer, options);
1596
+ if (result && options.isFile && this.isDirectorySync(result) && !hasFileExtension(result)) {
1597
+ for (const ext of DEFAULT_EXTENSIONS) {
1598
+ result = this.resolveSync(`${result}.${ext}`, importer, options);
1599
+ if (result) return result;
1536
1600
  }
1537
- if (!result) try {
1538
- result = resolveSync(path, {
1539
- ...options,
1540
- paths
1541
- });
1542
- } catch {}
1601
+ return;
1543
1602
  }
1544
- if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
1545
1603
  return result;
1546
1604
  }
1547
1605
  /**
@@ -3785,4 +3843,4 @@ Note: Please ensure the plugin package's default export is a class that extends
3785
3843
 
3786
3844
  //#endregion
3787
3845
  export { _capnpFileId as _, createUnpluginFactory as a, createUnpluginModuleResolutionFunctions as c, PowerlinesContext as d, FileId as f, FileSystem as g, FileStorage as h, createPluginContext as i, combineContexts as l, FileMetadata_KeyValuePair as m, PowerlinesAPIContext as n, createUnplugin as o, FileMetadata as p, PowerlinesEnvironmentContext as r, createUnpluginResolver as s, PowerlinesAPI as t, isUnpluginBuilderVariant as u, name as v, version as y };
3788
- //# sourceMappingURL=api-BCnLkGu9.mjs.map
3846
+ //# sourceMappingURL=api-D9WIJJt3.mjs.map