powerlines 0.10.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/astro.cjs +8 -8
  2. package/dist/astro.d.cts +1 -1
  3. package/dist/astro.d.ts +1 -1
  4. package/dist/astro.js +5 -5
  5. package/dist/{chunk-5XYGZ3DC.cjs → chunk-22K72CJ5.cjs} +2 -2
  6. package/dist/{chunk-GPPJ2CRE.js → chunk-4HGQJ4KR.js} +2 -2
  7. package/dist/chunk-7MTW3KR2.cjs +12 -0
  8. package/dist/{chunk-VIRKTIPK.js → chunk-7UIYU6SC.js} +3 -3
  9. package/dist/chunk-7WMWRX2S.cjs +12 -0
  10. package/dist/{chunk-HVT7PBFF.js → chunk-A3BBPLTY.js} +3 -3
  11. package/dist/{chunk-S746E63M.js → chunk-BHP6KBGK.js} +3 -3
  12. package/dist/{chunk-ZU4IRZSQ.js → chunk-BOIEJ5I6.js} +3 -3
  13. package/dist/chunk-DELRP3WY.js +31 -0
  14. package/dist/{chunk-ZBDP43LG.cjs → chunk-ELHJY5WG.cjs} +4 -4
  15. package/dist/{chunk-UHCRNFFC.cjs → chunk-FANQC345.cjs} +4 -4
  16. package/dist/chunk-GV3S7ZR3.cjs +34 -0
  17. package/dist/{chunk-WCPY7HPU.js → chunk-L3DAMAEC.js} +4 -4
  18. package/dist/chunk-LC6FLEJS.cjs +12 -0
  19. package/dist/{chunk-N7NE3VOU.js → chunk-MAEKW52U.js} +3 -3
  20. package/dist/chunk-MXJWCZDP.cjs +12 -0
  21. package/dist/{chunk-EGSEJQCE.js → chunk-NGKWITCO.js} +3 -3
  22. package/dist/{chunk-L2SAK2JC.cjs → chunk-OC7CCD5M.cjs} +4 -4
  23. package/dist/{chunk-OYIM2M74.js → chunk-P4BOYWXT.js} +195 -6
  24. package/dist/{chunk-UTVZVGM3.cjs → chunk-PJRHRDLS.cjs} +204 -15
  25. package/dist/{chunk-5Y4JYQ66.js → chunk-RBRFT2R6.js} +3 -3
  26. package/dist/{chunk-66GXB2UY.cjs → chunk-RU6BHTIP.cjs} +4 -4
  27. package/dist/{chunk-WPVIF35O.js → chunk-SIZKRND7.js} +2 -2
  28. package/dist/chunk-SNARILEC.cjs +24 -0
  29. package/dist/{chunk-6UDHGAAI.js → chunk-SY7N6FC3.js} +3 -3
  30. package/dist/{chunk-QHGPZK2H.cjs → chunk-V5D5NVV7.cjs} +4 -4
  31. package/dist/{chunk-SDEBJQDT.js → chunk-V7LXFIGK.js} +3 -3
  32. package/dist/{chunk-2RHPFVYT.cjs → chunk-WCTOTE3T.cjs} +8 -8
  33. package/dist/chunk-WD4363UW.cjs +12 -0
  34. package/dist/{chunk-7IWH37DY.cjs → chunk-YIWHO6SW.cjs} +2 -2
  35. package/dist/{chunk-3Y5CCIJR.js → chunk-ZP5QLZQ2.js} +3 -3
  36. package/dist/{chunk-KYGEWAEG.js → chunk-ZQ7U35QZ.js} +3 -3
  37. package/dist/define-config.d.cts +1 -1
  38. package/dist/define-config.d.ts +1 -1
  39. package/dist/esbuild.cjs +7 -7
  40. package/dist/esbuild.d.cts +1 -1
  41. package/dist/esbuild.d.ts +1 -1
  42. package/dist/esbuild.js +4 -4
  43. package/dist/extend-plugin.d.cts +1 -1
  44. package/dist/extend-plugin.d.ts +1 -1
  45. package/dist/farm.cjs +4 -4
  46. package/dist/farm.d.cts +1 -1
  47. package/dist/farm.d.ts +1 -1
  48. package/dist/farm.js +3 -3
  49. package/dist/{hooks-BGYnc61f.d.ts → hooks-BmvalJZ4.d.ts} +1 -1
  50. package/dist/{hooks-gk8S8LFP.d.cts → hooks-BzFKq34L.d.cts} +1 -1
  51. package/dist/index.cjs +26 -26
  52. package/dist/index.d.cts +2 -2
  53. package/dist/index.d.ts +2 -2
  54. package/dist/index.js +17 -17
  55. package/dist/internal/api.cjs +3 -3
  56. package/dist/internal/api.d.cts +2 -2
  57. package/dist/internal/api.d.ts +2 -2
  58. package/dist/internal/api.js +2 -2
  59. package/dist/lib/build/esbuild.d.cts +12 -12
  60. package/dist/lib/build/esbuild.d.ts +12 -12
  61. package/dist/lib/build/index.cjs +18 -18
  62. package/dist/lib/build/index.d.cts +13 -13
  63. package/dist/lib/build/index.d.ts +13 -13
  64. package/dist/lib/build/index.js +3 -3
  65. package/dist/lib/build/rolldown.d.cts +12 -12
  66. package/dist/lib/build/rolldown.d.ts +12 -12
  67. package/dist/lib/build/rollup.d.cts +12 -12
  68. package/dist/lib/build/rollup.d.ts +12 -12
  69. package/dist/lib/build/rspack.d.cts +12 -12
  70. package/dist/lib/build/rspack.d.ts +12 -12
  71. package/dist/lib/build/tsup.d.cts +11 -11
  72. package/dist/lib/build/tsup.d.ts +11 -11
  73. package/dist/lib/build/unbuild.cjs +5 -5
  74. package/dist/lib/build/unbuild.d.cts +13 -13
  75. package/dist/lib/build/unbuild.d.ts +13 -13
  76. package/dist/lib/build/unbuild.js +2 -2
  77. package/dist/lib/build/vite.d.cts +12 -12
  78. package/dist/lib/build/vite.d.ts +12 -12
  79. package/dist/lib/build/webpack.d.cts +12 -12
  80. package/dist/lib/build/webpack.d.ts +12 -12
  81. package/dist/lib/bundle.cjs +16 -0
  82. package/dist/lib/bundle.cjs.map +1 -0
  83. package/dist/lib/bundle.d.cts +44 -0
  84. package/dist/lib/bundle.d.ts +44 -0
  85. package/dist/lib/bundle.js +7 -0
  86. package/dist/lib/bundle.js.map +1 -0
  87. package/dist/lib/chunk-2625RJNJ.cjs +41 -0
  88. package/dist/lib/chunk-2625RJNJ.cjs.map +1 -0
  89. package/dist/lib/{chunk-PIFE7MUZ.js → chunk-6BRTJXZ2.js} +195 -6
  90. package/dist/lib/chunk-6BRTJXZ2.js.map +1 -0
  91. package/dist/lib/chunk-6IJTWIVJ.cjs +107 -0
  92. package/dist/lib/chunk-6IJTWIVJ.cjs.map +1 -0
  93. package/dist/lib/{chunk-YVDJCVE5.cjs → chunk-BAC4AJEP.cjs} +3 -3
  94. package/dist/lib/{chunk-YVDJCVE5.cjs.map → chunk-BAC4AJEP.cjs.map} +1 -1
  95. package/dist/lib/{chunk-Q2RUDKWY.cjs → chunk-BW3VFCTS.cjs} +2 -2
  96. package/dist/lib/chunk-BW3VFCTS.cjs.map +1 -0
  97. package/dist/lib/chunk-ESYYL5UH.js +105 -0
  98. package/dist/lib/chunk-ESYYL5UH.js.map +1 -0
  99. package/dist/lib/chunk-GTQZYDA7.js +39 -0
  100. package/dist/lib/chunk-GTQZYDA7.js.map +1 -0
  101. package/dist/lib/{chunk-M7U5RMK7.js → chunk-KOCDKJDJ.js} +2 -2
  102. package/dist/lib/chunk-KOCDKJDJ.js.map +1 -0
  103. package/dist/lib/{chunk-M7WHFUKR.cjs → chunk-LYD5OTBI.cjs} +210 -21
  104. package/dist/lib/chunk-LYD5OTBI.cjs.map +1 -0
  105. package/dist/lib/{chunk-6U2UX2PX.cjs → chunk-RLMEYZ5I.cjs} +11 -15
  106. package/dist/lib/chunk-RLMEYZ5I.cjs.map +1 -0
  107. package/dist/lib/{chunk-CAPN4FSS.js → chunk-S4TGQD45.js} +3 -3
  108. package/dist/lib/{chunk-CAPN4FSS.js.map → chunk-S4TGQD45.js.map} +1 -1
  109. package/dist/lib/{chunk-KFE2IR3Y.js → chunk-V2T4H24I.js} +11 -15
  110. package/dist/lib/chunk-V2T4H24I.js.map +1 -0
  111. package/dist/lib/config-file.d.cts +11 -11
  112. package/dist/lib/config-file.d.ts +11 -11
  113. package/dist/lib/{config-AuIGsUck.d.cts → context-BI46yeFZ.d.cts} +617 -557
  114. package/dist/lib/{config-B_WTwd49.d.ts → context-tEqvC3yI.d.ts} +617 -557
  115. package/dist/lib/create-program.cjs +13 -0
  116. package/dist/lib/create-program.cjs.map +1 -0
  117. package/dist/lib/create-program.d.cts +42 -0
  118. package/dist/lib/create-program.d.ts +42 -0
  119. package/dist/lib/create-program.js +4 -0
  120. package/dist/lib/create-program.js.map +1 -0
  121. package/dist/lib/entry.d.cts +12 -12
  122. package/dist/lib/entry.d.ts +12 -12
  123. package/dist/lib/{hooks-DErK4Fv4.d.ts → hooks-C9_XPS6c.d.cts} +1 -1
  124. package/dist/lib/{hooks-4KkL9GD2.d.cts → hooks-DESiFNA6.d.ts} +1 -1
  125. package/dist/lib/index.cjs +47 -36
  126. package/dist/lib/index.d.cts +16 -13
  127. package/dist/lib/index.d.ts +16 -13
  128. package/dist/lib/index.js +10 -7
  129. package/dist/lib/logger.d.cts +12 -12
  130. package/dist/lib/logger.d.ts +12 -12
  131. package/dist/lib/typescript/compiler-host.cjs +46 -2
  132. package/dist/lib/typescript/compiler-host.cjs.map +1 -1
  133. package/dist/lib/typescript/compiler-host.d.cts +18 -13
  134. package/dist/lib/typescript/compiler-host.d.ts +18 -13
  135. package/dist/lib/typescript/compiler-host.js +45 -2
  136. package/dist/lib/typescript/compiler-host.js.map +1 -1
  137. package/dist/lib/typescript/import-transformer.d.cts +12 -12
  138. package/dist/lib/typescript/import-transformer.d.ts +12 -12
  139. package/dist/lib/typescript/index.cjs +6 -6
  140. package/dist/lib/typescript/index.d.cts +12 -12
  141. package/dist/lib/typescript/index.d.ts +12 -12
  142. package/dist/lib/typescript/index.js +1 -1
  143. package/dist/lib/typescript/program.cjs +6 -6
  144. package/dist/lib/typescript/program.d.cts +13 -13
  145. package/dist/lib/typescript/program.d.ts +13 -13
  146. package/dist/lib/typescript/program.js +1 -1
  147. package/dist/lib/unplugin/factory.cjs +3 -3
  148. package/dist/lib/unplugin/factory.d.cts +12 -12
  149. package/dist/lib/unplugin/factory.d.ts +12 -12
  150. package/dist/lib/unplugin/factory.js +2 -2
  151. package/dist/lib/unplugin/index.cjs +3 -3
  152. package/dist/lib/unplugin/index.d.cts +12 -12
  153. package/dist/lib/unplugin/index.d.ts +12 -12
  154. package/dist/lib/unplugin/index.js +2 -2
  155. package/dist/lib/unplugin/plugin.d.cts +11 -11
  156. package/dist/lib/unplugin/plugin.d.ts +11 -11
  157. package/dist/lib/unplugin/resolve-id.d.cts +11 -11
  158. package/dist/lib/unplugin/resolve-id.d.ts +11 -11
  159. package/dist/lib/utilities/file-header.d.cts +12 -12
  160. package/dist/lib/utilities/file-header.d.ts +12 -12
  161. package/dist/lib/utilities/index.cjs +20 -20
  162. package/dist/lib/utilities/index.d.cts +12 -12
  163. package/dist/lib/utilities/index.d.ts +12 -12
  164. package/dist/lib/utilities/index.js +3 -3
  165. package/dist/lib/utilities/meta.cjs +8 -8
  166. package/dist/lib/utilities/meta.d.cts +12 -12
  167. package/dist/lib/utilities/meta.d.ts +12 -12
  168. package/dist/lib/utilities/meta.js +1 -1
  169. package/dist/lib/utilities/plugin-helpers.d.cts +11 -11
  170. package/dist/lib/utilities/plugin-helpers.d.ts +11 -11
  171. package/dist/lib/utilities/resolve-path.d.cts +12 -12
  172. package/dist/lib/utilities/resolve-path.d.ts +12 -12
  173. package/dist/lib/utilities/worker.d.cts +11 -11
  174. package/dist/lib/utilities/worker.d.ts +11 -11
  175. package/dist/lib/utilities/write-file.d.cts +12 -12
  176. package/dist/lib/utilities/write-file.d.ts +12 -12
  177. package/dist/next.cjs +8 -8
  178. package/dist/next.js +5 -5
  179. package/dist/nuxt.cjs +9 -9
  180. package/dist/nuxt.js +6 -6
  181. package/dist/{resolved-Dhscmo3z.d.ts → resolved-BS8bJ6b1.d.ts} +21 -17
  182. package/dist/{resolved-CcuVqMqc.d.cts → resolved-CjkYiKA1.d.cts} +21 -17
  183. package/dist/rolldown.cjs +7 -7
  184. package/dist/rolldown.d.cts +1 -1
  185. package/dist/rolldown.d.ts +1 -1
  186. package/dist/rolldown.js +4 -4
  187. package/dist/rollup.cjs +7 -7
  188. package/dist/rollup.d.cts +1 -1
  189. package/dist/rollup.d.ts +1 -1
  190. package/dist/rollup.js +4 -4
  191. package/dist/rspack.cjs +7 -7
  192. package/dist/rspack.d.cts +1 -1
  193. package/dist/rspack.d.ts +1 -1
  194. package/dist/rspack.js +4 -4
  195. package/dist/tsup.cjs +8 -8
  196. package/dist/tsup.js +5 -5
  197. package/dist/types/babel.d.cts +1 -1
  198. package/dist/types/babel.d.ts +1 -1
  199. package/dist/types/commands.d.cts +1 -1
  200. package/dist/types/commands.d.ts +1 -1
  201. package/dist/types/compiler.d.cts +1 -1
  202. package/dist/types/compiler.d.ts +1 -1
  203. package/dist/types/config.d.cts +1 -1
  204. package/dist/types/config.d.ts +1 -1
  205. package/dist/types/context.cjs +2 -2
  206. package/dist/types/context.d.cts +1 -1
  207. package/dist/types/context.d.ts +1 -1
  208. package/dist/types/context.js +1 -1
  209. package/dist/types/hooks.d.cts +1 -1
  210. package/dist/types/hooks.d.ts +1 -1
  211. package/dist/types/index.cjs +9 -9
  212. package/dist/types/index.d.cts +1 -1
  213. package/dist/types/index.d.ts +1 -1
  214. package/dist/types/index.js +2 -2
  215. package/dist/types/internal.d.cts +2 -2
  216. package/dist/types/internal.d.ts +2 -2
  217. package/dist/types/plugin.d.cts +1 -1
  218. package/dist/types/plugin.d.ts +1 -1
  219. package/dist/types/resolved.d.cts +1 -1
  220. package/dist/types/resolved.d.ts +1 -1
  221. package/dist/types/unplugin.d.cts +1 -1
  222. package/dist/types/unplugin.d.ts +1 -1
  223. package/dist/types/vfs.cjs +7 -7
  224. package/dist/types/vfs.d.cts +61 -5
  225. package/dist/types/vfs.d.ts +61 -5
  226. package/dist/types/vfs.js +1 -1
  227. package/dist/unloader.cjs +7 -7
  228. package/dist/unloader.d.cts +1 -1
  229. package/dist/unloader.d.ts +1 -1
  230. package/dist/unloader.js +4 -4
  231. package/dist/unplugin.cjs +18 -18
  232. package/dist/unplugin.d.cts +2 -2
  233. package/dist/unplugin.d.ts +2 -2
  234. package/dist/unplugin.js +15 -15
  235. package/dist/vite.cjs +7 -7
  236. package/dist/vite.d.cts +1 -1
  237. package/dist/vite.d.ts +1 -1
  238. package/dist/vite.js +4 -4
  239. package/dist/webpack.cjs +7 -7
  240. package/dist/webpack.d.cts +1 -1
  241. package/dist/webpack.d.ts +1 -1
  242. package/dist/webpack.js +4 -4
  243. package/package.json +11 -9
  244. package/dist/chunk-IJBH5OUN.cjs +0 -12
  245. package/dist/chunk-JBTSAOIQ.js +0 -31
  246. package/dist/chunk-LXMNDUPG.cjs +0 -12
  247. package/dist/chunk-RQ4CHMPO.cjs +0 -12
  248. package/dist/chunk-S5QFX2GM.cjs +0 -12
  249. package/dist/chunk-SL3CXJWD.cjs +0 -34
  250. package/dist/chunk-YG7U2GIR.cjs +0 -24
  251. package/dist/chunk-ZFATNDSY.cjs +0 -12
  252. package/dist/lib/chunk-6U2UX2PX.cjs.map +0 -1
  253. package/dist/lib/chunk-KFE2IR3Y.js.map +0 -1
  254. package/dist/lib/chunk-M7U5RMK7.js.map +0 -1
  255. package/dist/lib/chunk-M7WHFUKR.cjs.map +0 -1
  256. package/dist/lib/chunk-PIFE7MUZ.js.map +0 -1
  257. package/dist/lib/chunk-Q2RUDKWY.cjs.map +0 -1
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ var chunkPK6SKIKE_cjs = require('./chunk-PK6SKIKE.cjs');
4
+ var join = require('@stryke/path/join');
5
+ var tsMorph = require('ts-morph');
6
+
7
+ var VirtualFileSystemHost = class VirtualFileSystemHost2 extends tsMorph.InMemoryFileSystemHost {
8
+ static {
9
+ chunkPK6SKIKE_cjs.__name(this, "VirtualFileSystemHost");
10
+ }
11
+ #fs;
12
+ constructor(fs) {
13
+ super();
14
+ this.#fs = fs;
15
+ }
16
+ deleteSync(path) {
17
+ this.#fs.rmSync(path);
18
+ }
19
+ readDirSync(dirPath) {
20
+ return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {
21
+ const fullPath = this.#fs.resolve(join.joinPaths(dirPath, entry));
22
+ if (fullPath) {
23
+ ret.push({
24
+ name: entry,
25
+ isDirectory: this.#fs.isDirectory(fullPath),
26
+ isFile: this.#fs.isFile(fullPath),
27
+ isSymlink: false
28
+ });
29
+ }
30
+ return ret;
31
+ }, []);
32
+ }
33
+ async readFile(filePath) {
34
+ if (!this.#fs.existsSync(filePath)) {
35
+ throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
36
+ }
37
+ return await this.#fs.readFile(filePath);
38
+ }
39
+ readFileSync(filePath) {
40
+ if (!this.#fs.existsSync(filePath)) {
41
+ throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
42
+ }
43
+ return this.#fs.readFileSync(filePath);
44
+ }
45
+ async writeFile(filePath, fileText) {
46
+ return this.#fs.writeFile(filePath, fileText);
47
+ }
48
+ writeFileSync(filePath, fileText) {
49
+ this.#fs.writeFileSync(filePath, fileText);
50
+ }
51
+ async mkdir(dirPath) {
52
+ await this.#fs.mkdir(dirPath);
53
+ }
54
+ mkdirSync(dirPath) {
55
+ this.#fs.mkdirSync(dirPath);
56
+ }
57
+ async move(srcPath, destPath) {
58
+ await this.#fs.move(srcPath, destPath);
59
+ }
60
+ moveSync(srcPath, destPath) {
61
+ this.#fs.moveSync(srcPath, destPath);
62
+ }
63
+ async copy(srcPath, destPath) {
64
+ await this.#fs.copy(srcPath, destPath);
65
+ }
66
+ copySync(srcPath, destPath) {
67
+ this.#fs.copySync(srcPath, destPath);
68
+ }
69
+ async fileExists(filePath) {
70
+ return this.#fs.isFile(filePath);
71
+ }
72
+ fileExistsSync(filePath) {
73
+ return this.#fs.isFile(filePath);
74
+ }
75
+ async directoryExists(dirPath) {
76
+ return this.#fs.isDirectory(dirPath);
77
+ }
78
+ directoryExistsSync(dirPath) {
79
+ return this.#fs.isDirectory(dirPath);
80
+ }
81
+ realpathSync(path) {
82
+ return this.#fs.resolve(path) || path;
83
+ }
84
+ getCurrentDirectory() {
85
+ return "/";
86
+ }
87
+ async glob(patterns) {
88
+ return this.#fs.glob(patterns);
89
+ }
90
+ globSync(patterns) {
91
+ return this.#fs.globSync(patterns);
92
+ }
93
+ };
94
+ function createProgram(context) {
95
+ return new tsMorph.Project({
96
+ compilerOptions: {
97
+ ...context.tsconfig.options
98
+ },
99
+ tsConfigFilePath: context.tsconfig.tsconfigFilePath,
100
+ fileSystem: new VirtualFileSystemHost(context.fs)
101
+ });
102
+ }
103
+ chunkPK6SKIKE_cjs.__name(createProgram, "createProgram");
104
+
105
+ exports.createProgram = createProgram;
106
+ //# sourceMappingURL=chunk-6IJTWIVJ.cjs.map
107
+ //# sourceMappingURL=chunk-6IJTWIVJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/create-program.ts"],"names":["VirtualFileSystemHost","InMemoryFileSystemHost","fs","deleteSync","path","rmSync","readDirSync","dirPath","readdirSync","reduce","ret","entry","fullPath","resolve","joinPaths","push","name","isDirectory","isFile","isSymlink","readFile","filePath","existsSync","Error","readFileSync","writeFile","fileText","writeFileSync","mkdir","mkdirSync","move","srcPath","destPath","moveSync","copy","copySync","fileExists","fileExistsSync","directoryExists","directoryExistsSync","realpathSync","getCurrentDirectory","glob","patterns","globSync","createProgram","context","Project","compilerOptions","tsconfig","options","tsConfigFilePath","tsconfigFilePath","fileSystem"],"mappings":";;;;;;AA4BA,IAAMA,qBAAAA,GAAN,MAAMA,sBAAAA,SACIC,8BAAAA,CAAAA;EA7BV;;;AAgCE,EAAA,GAAA;AAEA,EAAA,WAAA,CAAmBC,EAAAA,EAAgC;AACjD,IAAA,KAAA,EAAK;AACL,IAAA,IAAA,CAAK,GAAA,GAAMA,EAAAA;AACb,EAAA;AAEgBC,EAAAA,UAAAA,CAAWC,IAAAA,EAAc;AACvC,IAAA,IAAA,CAAK,GAAA,CAAIC,OAAOD,IAAAA,CAAAA;AAClB,EAAA;AAEgBE,EAAAA,WAAAA,CAAYC,OAAAA,EAAoC;AAC9D,IAAA,OAAO,IAAA,CAAK,IAAIC,WAAAA,CAAYD,OAAAA,EAASE,MAAAA,CAAO,CAACC,KAAKC,KAAAA,KAAAA;AAChD,MAAA,MAAMC,WAAW,IAAA,CAAK,GAAA,CAAIC,QAAQC,cAAAA,CAAUP,OAAAA,EAASI,KAAAA,CAAAA,CAAAA;AACrD,MAAA,IAAIC,QAAAA,EAAU;AACZF,QAAAA,GAAAA,CAAIK,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AAAA;AAC9B,EAAA;AAEgBgC,EAAAA,mBAAAA,CAAoBhC,OAAAA,EAA0B;AAC5D,IAAA,OAAO,IAAA,CAAK,GAAA,CAAIU,WAAAA,CAAYV,OAAAA,CAAAA;AAC9B,EAAA;AAEgBiC,EAAAA,YAAAA,CAAapC,IAAAA,EAAc;AACzC,IAAA,OAAO,IAAA,CAAK,GAAA,CAAIS,OAAAA,CAAQT,IAAAA,CAAAA,IAASA,IAAAA;AACnC,EAAA;EAEgBqC,mBAAAA,GAAsB;AACpC,IAAA,OAAO,GAAA;AACT,EAAA;AAEA,EAAA,MAAsBC,KACpBC,QAAAA,EACmB;AACnB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAID,IAAAA,CAAKC,QAAAA,CAAAA;AACvB,EAAA;AAEgBC,EAAAA,QAAAA,CAASD,QAAAA,EAA2C;AAClE,IAAA,OAAO,IAAA,CAAK,GAAA,CAAIC,QAAAA,CAASD,QAAAA,CAAAA;AAC3B,EAAA;AACF,CAAA;AAOO,SAASE,cAAcC,OAAAA,EAAgB;AAC5C,EAAA,OAAO,IAAIC,eAAAA,CAAQ;IACjBC,eAAAA,EAAiB;AACf,MAAA,GAAGF,QAAQG,QAAAA,CAASC;AACtB,KAAA;AACAC,IAAAA,gBAAAA,EAAkBL,QAAQG,QAAAA,CAASG,gBAAAA;IACnCC,UAAAA,EAAY,IAAIrD,qBAAAA,CAAsB8C,OAAAA,CAAQ5C,EAAE;GAClD,CAAA;AACF;AARgB2C,wBAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"chunk-6IJTWIVJ.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport {\n FileSystemHost,\n InMemoryFileSystemHost,\n Project,\n RuntimeDirEntry\n} from \"ts-morph\";\nimport { Context } from \"../types/context\";\nimport { VirtualFileSystemInterface } from \"../types/vfs\";\n\nclass VirtualFileSystemHost\n extends InMemoryFileSystemHost\n implements FileSystemHost\n{\n #fs: VirtualFileSystemInterface;\n\n public constructor(fs: VirtualFileSystemInterface) {\n super();\n this.#fs = fs;\n }\n\n public override deleteSync(path: string) {\n this.#fs.rmSync(path);\n }\n\n public override readDirSync(dirPath: string): RuntimeDirEntry[] {\n return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {\n const fullPath = this.#fs.resolve(joinPaths(dirPath, entry));\n if (fullPath) {\n ret.push({\n name: entry,\n isDirectory: this.#fs.isDirectory(fullPath),\n isFile: this.#fs.isFile(fullPath),\n isSymlink: false\n });\n }\n\n return ret;\n }, [] as RuntimeDirEntry[]);\n }\n\n public override async readFile(filePath: string) {\n if (!this.#fs.existsSync(filePath)) {\n throw new Error(\n `File not found: '${filePath}'. Please check the path and try again.`\n );\n }\n\n return (await this.#fs.readFile(filePath))!;\n }\n\n public override readFileSync(filePath: string) {\n if (!this.#fs.existsSync(filePath)) {\n throw new Error(\n `File not found: '${filePath}'. Please check the path and try again.`\n );\n }\n\n return this.#fs.readFileSync(filePath)!;\n }\n\n public override async writeFile(filePath: string, fileText: string) {\n return this.#fs.writeFile(filePath, fileText);\n }\n\n public override writeFileSync(filePath: string, fileText: string) {\n this.#fs.writeFileSync(filePath, fileText);\n }\n\n public override async mkdir(dirPath: string) {\n await this.#fs.mkdir(dirPath);\n }\n\n public override mkdirSync(dirPath: string) {\n this.#fs.mkdirSync(dirPath);\n }\n\n public override async move(srcPath: string, destPath: string) {\n await this.#fs.move(srcPath, destPath);\n }\n\n public override moveSync(srcPath: string, destPath: string) {\n this.#fs.moveSync(srcPath, destPath);\n }\n\n public override async copy(srcPath: string, destPath: string) {\n await this.#fs.copy(srcPath, destPath);\n }\n\n public override copySync(srcPath: string, destPath: string) {\n this.#fs.copySync(srcPath, destPath);\n }\n\n public override async fileExists(filePath: string) {\n return this.#fs.isFile(filePath);\n }\n\n public override fileExistsSync(filePath: string) {\n return this.#fs.isFile(filePath);\n }\n\n public override async directoryExists(dirPath: string) {\n return this.#fs.isDirectory(dirPath);\n }\n\n public override directoryExistsSync(dirPath: string): boolean {\n return this.#fs.isDirectory(dirPath);\n }\n\n public override realpathSync(path: string) {\n return this.#fs.resolve(path) || path;\n }\n\n public override getCurrentDirectory() {\n return \"/\";\n }\n\n public override async glob(\n patterns: ReadonlyArray<string>\n ): Promise<string[]> {\n return this.#fs.glob(patterns as string[]);\n }\n\n public override globSync(patterns: ReadonlyArray<string>): string[] {\n return this.#fs.globSync(patterns as string[]);\n }\n}\n\n/**\n * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing\n *\n * @returns A ts-morph {@link Project} instance\n */\nexport function createProgram(context: Context): Project {\n return new Project({\n compilerOptions: {\n ...context.tsconfig.options\n },\n tsConfigFilePath: context.tsconfig.tsconfigFilePath,\n fileSystem: new VirtualFileSystemHost(context.fs)\n });\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkUQJWVRRE_cjs = require('./chunk-UQJWVRRE.cjs');
4
3
  var chunkJTUL3477_cjs = require('./chunk-JTUL3477.cjs');
4
+ var chunkUQJWVRRE_cjs = require('./chunk-UQJWVRRE.cjs');
5
5
  var chunkPK6SKIKE_cjs = require('./chunk-PK6SKIKE.cjs');
6
6
  var joinPaths = require('@stryke/path/join-paths');
7
7
  var isObject = require('@stryke/type-checks/is-object');
@@ -156,5 +156,5 @@ chunkPK6SKIKE_cjs.__name(extractUnbuildConfig, "extractUnbuildConfig");
156
156
  exports.DEFAULT_UNBUILD_CONFIG = DEFAULT_UNBUILD_CONFIG;
157
157
  exports.extractUnbuildConfig = extractUnbuildConfig;
158
158
  exports.unbuildLoader = unbuildLoader;
159
- //# sourceMappingURL=chunk-YVDJCVE5.cjs.map
160
- //# sourceMappingURL=chunk-YVDJCVE5.cjs.map
159
+ //# sourceMappingURL=chunk-BAC4AJEP.cjs.map
160
+ //# sourceMappingURL=chunk-BAC4AJEP.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/build/unbuild.ts"],"names":["DEFAULT_UNBUILD_CONFIG","dts","clean","includeSrc","treeShaking","splitting","stub","watchOptions","outputPath","generatePackageJson","banner","rollup","emitCJS","replace","resolve","json","esbuild","target","commonjs","alias","unbuildLoader","context","input","options","test","path","output","contents","getContents","declaration","srcPath","match","cm","extension","push","transformed","result","$$internal","callHook","sequential","order","getString","includes","transform","Object","fromEntries","entries","filter","key","loader","then","r","code","isCjs","format","resolver","source","retainLines","ext","startsWith","extractUnbuildConfig","defu","builtins","reduce","ret","id","fs","ids","config","build","variant","override","projectName","name","orgName","isObject","workspaceConfig","organization","sourceRoot","projectRoot","platform","external","loaders","jiti","interopDefault","fsCache","joinPaths","envPaths","cache","moduleCache","extractRollupConfig","debug","mode","minify","sourcemap"],"mappings":";;;;;;;;;;;;;;AAiCO,IAAMA,sBAAAA,GAAyB;EACpCC,GAAAA,EAAK,IAAA;EACLC,KAAAA,EAAO,KAAA;EACPC,UAAAA,EAAY,KAAA;EACZC,WAAAA,EAAa,IAAA;EACbC,SAAAA,EAAW,IAAA;EACXC,IAAAA,EAAM,KAAA;AACNC,EAAAA,YAAAA,EAAc,EAAC;EACfC,UAAAA,EAAY,MAAA;EACZC,mBAAAA,EAAqB,IAAA;EACrBC,MAAAA,EAAQ,GAAA;EACRC,MAAAA,EAAQ;AACNV,IAAAA,GAAAA,EAAK,EAAC;IACNW,OAAAA,EAAS,IAAA;AACTC,IAAAA,OAAAA,EAAS,EAAC;AACVC,IAAAA,OAAAA,EAAS,EAAC;AACVC,IAAAA,IAAAA,EAAM,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U3D,OAAAA,CAAQ+C,OAAOC,KAAAA,CAAMW,QAAAA;AAC/BC,IAAAA,QAAAA,EAAU5D,OAAAA,CAAQyC,QAAAA,CAASC,MAAAA,CAAO,CAACC,KAAKC,EAAAA,KAAAA;AACtC,MAAA,IAAI,CAACD,GAAAA,CAAItB,QAAAA,CAASuB,EAAAA,CAAAA,EAAK;AACrBD,QAAAA,GAAAA,CAAI9B,KAAK+B,EAAAA,CAAAA;AACX,MAAA;AAEA,MAAA,OAAOD,GAAAA;AACT,IAAA,CAAA,EAAG3C,OAAAA,CAAQ+C,MAAAA,CAAOC,KAAAA,CAAMY,QAAAA,IAAY,EAAE,CAAA;IAEtCC,OAAAA,EAAS;AAAC9D,MAAAA,aAAAA,CAAcC,OAAAA;;IACxB8D,IAAAA,EAAM;MACJC,cAAAA,EAAgB,IAAA;AAChBC,MAAAA,OAAAA,EAASC,mBAAAA,CAAUjE,OAAAA,CAAQkE,QAAAA,CAASC,KAAAA,EAAO,MAAA,CAAA;MAC3CC,WAAAA,EAAa;AACf,KAAA;AACA9E,IAAAA,MAAAA,EAAQ+E,sCAAoBrE,OAAAA;GAC9B,EACAA,OAAAA,CAAQ+C,OAAOC,KAAAA,CAAMC,OAAAA,KAAY,YAAYjD,OAAAA,CAAQ+C,MAAAA,CAAOC,KAAAA,GAAQ,EAAC,EACrE;IACEsB,KAAAA,EAAOtE,OAAAA,CAAQ+C,OAAOwB,IAAAA,KAAS,aAAA;IAC/BC,MAAAA,EAAQxE,OAAAA,CAAQ+C,OAAOwB,IAAAA,KAAS,aAAA;IAChCE,SAAAA,EAAWzE,OAAAA,CAAQ+C,OAAOwB,IAAAA,KAAS;AACrC,GAAA,EACA5F,sBAAAA,CAAAA;AAEJ;AApDgB4D,wBAAAA,CAAAA,oBAAAA,EAAAA,sBAAAA,CAAAA","file":"chunk-YVDJCVE5.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Loader, LoaderResult } from \"@storm-software/unbuild/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport defu from \"defu\";\nimport { transform } from \"esbuild\";\nimport { TransformResult } from \"unplugin\";\nimport {\n UnbuildBuildConfig,\n UnbuildResolvedBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\nimport { UNSAFE_PluginContext } from \"../../types/internal\";\nimport { getString } from \"../utilities/source-file\";\nimport { extractRollupConfig } from \"./rollup\";\n\nexport const DEFAULT_UNBUILD_CONFIG = {\n dts: true,\n clean: false,\n includeSrc: false,\n treeShaking: true,\n splitting: true,\n stub: false,\n watchOptions: {},\n outputPath: \"dist\",\n generatePackageJson: true,\n banner: \" \",\n rollup: {\n dts: {},\n emitCJS: true,\n replace: {},\n resolve: {},\n json: {},\n esbuild: { target: \"es2020\" },\n commonjs: {},\n alias: {}\n }\n} as Partial<UnbuildBuildConfig>;\n\nexport const unbuildLoader = (context: UNSAFE_PluginContext): Loader => {\n return async (input, { options }) => {\n if (\n !/\\.(?:c|m)?[jt]sx?$/.test(input.path) ||\n /\\.d\\.[cm]?ts$/.test(input.path)\n ) {\n return;\n }\n\n const output: LoaderResult = [];\n\n let contents = await input.getContents();\n\n // declaration\n if (options.declaration && !input.srcPath?.match(/\\.d\\.[cm]?ts$/)) {\n const cm = input.srcPath?.match(/(?<=\\.)(?:c|m)(?=[jt]s$)/)?.[0] || \"\";\n const extension = `.d.${cm}ts`;\n output.push({\n contents,\n srcPath: input.srcPath,\n path: input.path,\n extension,\n declaration: true\n });\n }\n\n let transformed: TransformResult | string = contents;\n\n let result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"pre\"\n },\n transformed,\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"normal\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"post\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n // typescript => js\n if ([\".ts\", \".mts\", \".cts\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n ),\n loader: \"ts\"\n }).then(r => r.code);\n } else if ([\".tsx\", \".jsx\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n loader: input.extension === \".tsx\" ? \"tsx\" : \"jsx\",\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n )\n }).then(r => r.code);\n }\n\n // esm => cjs\n const isCjs = options.format === \"cjs\";\n if (isCjs) {\n contents = context.resolver\n .transform({\n source: contents,\n retainLines: false\n })\n .replace(/^exports.default = /gm, \"module.exports = \")\n .replace(/^var _default = exports.default = /gm, \"module.exports = \")\n .replace(\"module.exports = void 0;\", \"\");\n }\n\n let extension = isCjs ? \".js\" : \".mjs\"; // TODO: Default to .cjs in next major version\n if (options.ext) {\n extension = options.ext.startsWith(\".\") ? options.ext : `.${options.ext}`;\n }\n\n output.push({\n contents,\n path: input.path,\n extension\n });\n\n return output;\n };\n};\n\n/**\n * Extracts the unbuild configuration from the context.\n *\n * @param context - The build context.\n * @returns The resolved unbuild configuration.\n */\nexport function extractUnbuildConfig(\n context: Context\n): UnbuildResolvedBuildConfig {\n return defu(\n {\n alias: context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.ids[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n )\n },\n context.config.build.variant === \"unbuild\" ? context.config.override : {},\n {\n projectName: context.config.name,\n name: context.config.name,\n orgName: isObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization,\n sourceRoot: context.config.sourceRoot,\n projectRoot: context.config.projectRoot,\n outputPath: context.config.output.outputPath || \"dist\",\n platform: context.config.build.platform,\n external: context.builtins.reduce((ret, id) => {\n if (!ret.includes(id)) {\n ret.push(id);\n }\n\n return ret;\n }, context.config.build.external ?? []) as string[],\n\n loaders: [unbuildLoader(context as UNSAFE_PluginContext)],\n jiti: {\n interopDefault: true,\n fsCache: joinPaths(context.envPaths.cache, \"jiti\"),\n moduleCache: true\n },\n rollup: extractRollupConfig(context) as any\n },\n context.config.build.variant === \"unbuild\" ? context.config.build : {},\n {\n debug: context.config.mode === \"development\",\n minify: context.config.mode !== \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_UNBUILD_CONFIG\n );\n}\n"]}
1
+ {"version":3,"sources":["../../src/lib/build/unbuild.ts"],"names":["DEFAULT_UNBUILD_CONFIG","dts","clean","includeSrc","treeShaking","splitting","stub","watchOptions","outputPath","generatePackageJson","banner","rollup","emitCJS","replace","resolve","json","esbuild","target","commonjs","alias","unbuildLoader","context","input","options","test","path","output","contents","getContents","declaration","srcPath","match","cm","extension","push","transformed","result","$$internal","callHook","sequential","order","getString","includes","transform","Object","fromEntries","entries","filter","key","loader","then","r","code","isCjs","format","resolver","source","retainLines","ext","startsWith","extractUnbuildConfig","defu","builtins","reduce","ret","id","fs","ids","config","build","variant","override","projectName","name","orgName","isObject","workspaceConfig","organization","sourceRoot","projectRoot","platform","external","loaders","jiti","interopDefault","fsCache","joinPaths","envPaths","cache","moduleCache","extractRollupConfig","debug","mode","minify","sourcemap"],"mappings":";;;;;;;;;;;;;;AAiCO,IAAMA,sBAAAA,GAAyB;EACpCC,GAAAA,EAA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AQ,EAAC,EACrE;IACEsB,KAAAA,EAAOtE,OAAAA,CAAQ+C,OAAOwB,IAAAA,KAAS,aAAA;IAC/BC,MAAAA,EAAQxE,OAAAA,CAAQ+C,OAAOwB,IAAAA,KAAS,aAAA;IAChCE,SAAAA,EAAWzE,OAAAA,CAAQ+C,OAAOwB,IAAAA,KAAS;AACrC,GAAA,EACA5F,sBAAAA,CAAAA;AAEJ;AApDgB4D,wBAAAA,CAAAA,oBAAAA,EAAAA,sBAAAA,CAAAA","file":"chunk-BAC4AJEP.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Loader, LoaderResult } from \"@storm-software/unbuild/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport defu from \"defu\";\nimport { transform } from \"esbuild\";\nimport { TransformResult } from \"unplugin\";\nimport {\n UnbuildBuildConfig,\n UnbuildResolvedBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\nimport { UNSAFE_PluginContext } from \"../../types/internal\";\nimport { getString } from \"../utilities/source-file\";\nimport { extractRollupConfig } from \"./rollup\";\n\nexport const DEFAULT_UNBUILD_CONFIG = {\n dts: true,\n clean: false,\n includeSrc: false,\n treeShaking: true,\n splitting: true,\n stub: false,\n watchOptions: {},\n outputPath: \"dist\",\n generatePackageJson: true,\n banner: \" \",\n rollup: {\n dts: {},\n emitCJS: true,\n replace: {},\n resolve: {},\n json: {},\n esbuild: { target: \"es2020\" },\n commonjs: {},\n alias: {}\n }\n} as Partial<UnbuildBuildConfig>;\n\nexport const unbuildLoader = (context: UNSAFE_PluginContext): Loader => {\n return async (input, { options }) => {\n if (\n !/\\.(?:c|m)?[jt]sx?$/.test(input.path) ||\n /\\.d\\.[cm]?ts$/.test(input.path)\n ) {\n return;\n }\n\n const output: LoaderResult = [];\n\n let contents = await input.getContents();\n\n // declaration\n if (options.declaration && !input.srcPath?.match(/\\.d\\.[cm]?ts$/)) {\n const cm = input.srcPath?.match(/(?<=\\.)(?:c|m)(?=[jt]s$)/)?.[0] || \"\";\n const extension = `.d.${cm}ts`;\n output.push({\n contents,\n srcPath: input.srcPath,\n path: input.path,\n extension,\n declaration: true\n });\n }\n\n let transformed: TransformResult | string = contents;\n\n let result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"pre\"\n },\n transformed,\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"normal\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"post\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n // typescript => js\n if ([\".ts\", \".mts\", \".cts\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n ),\n loader: \"ts\"\n }).then(r => r.code);\n } else if ([\".tsx\", \".jsx\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n loader: input.extension === \".tsx\" ? \"tsx\" : \"jsx\",\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n )\n }).then(r => r.code);\n }\n\n // esm => cjs\n const isCjs = options.format === \"cjs\";\n if (isCjs) {\n contents = context.resolver\n .transform({\n source: contents,\n retainLines: false\n })\n .replace(/^exports.default = /gm, \"module.exports = \")\n .replace(/^var _default = exports.default = /gm, \"module.exports = \")\n .replace(\"module.exports = void 0;\", \"\");\n }\n\n let extension = isCjs ? \".js\" : \".mjs\"; // TODO: Default to .cjs in next major version\n if (options.ext) {\n extension = options.ext.startsWith(\".\") ? options.ext : `.${options.ext}`;\n }\n\n output.push({\n contents,\n path: input.path,\n extension\n });\n\n return output;\n };\n};\n\n/**\n * Extracts the unbuild configuration from the context.\n *\n * @param context - The build context.\n * @returns The resolved unbuild configuration.\n */\nexport function extractUnbuildConfig(\n context: Context\n): UnbuildResolvedBuildConfig {\n return defu(\n {\n alias: context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.ids[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n )\n },\n context.config.build.variant === \"unbuild\" ? context.config.override : {},\n {\n projectName: context.config.name,\n name: context.config.name,\n orgName: isObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization,\n sourceRoot: context.config.sourceRoot,\n projectRoot: context.config.projectRoot,\n outputPath: context.config.output.outputPath || \"dist\",\n platform: context.config.build.platform,\n external: context.builtins.reduce((ret, id) => {\n if (!ret.includes(id)) {\n ret.push(id);\n }\n\n return ret;\n }, context.config.build.external ?? []) as string[],\n\n loaders: [unbuildLoader(context as UNSAFE_PluginContext)],\n jiti: {\n interopDefault: true,\n fsCache: joinPaths(context.envPaths.cache, \"jiti\"),\n moduleCache: true\n },\n rollup: extractRollupConfig(context) as any\n },\n context.config.build.variant === \"unbuild\" ? context.config.build : {},\n {\n debug: context.config.mode === \"development\",\n minify: context.config.mode !== \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_UNBUILD_CONFIG\n );\n}\n"]}
@@ -106,5 +106,5 @@ exports.getChecksum = getChecksum;
106
106
  exports.getPersistedMeta = getPersistedMeta;
107
107
  exports.getPrefixedProjectRootHash = getPrefixedProjectRootHash;
108
108
  exports.writeMetaFile = writeMetaFile;
109
- //# sourceMappingURL=chunk-Q2RUDKWY.cjs.map
110
- //# sourceMappingURL=chunk-Q2RUDKWY.cjs.map
109
+ //# sourceMappingURL=chunk-BW3VFCTS.cjs.map
110
+ //# sourceMappingURL=chunk-BW3VFCTS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/vfs.ts","../../src/lib/utilities/meta.ts"],"names":["__VFS_INIT__","__VFS_REVERT__","__VFS_CACHE__","__VFS_RESOLVER__","__VFS_VIRTUAL__","__VFS_UNIFIED__","PROJECT_ROOT_HASH_LENGTH","CACHE_HASH_LENGTH","getPrefixedProjectRootHash","name","projectRootHash","combined","kebabCase","length","slice","discoverTemplatePath","path","Promise","all","resolve","test","includes","hasFileExtension","joinPaths","listFiles","flat","filter","Boolean","discoverTemplates","context","paths","getUnique","map","config","sourceRoot","envPaths","projectRoot","reduce","ret","existsSync","push","getChecksum","hashDirectory","ignore","getPersistedMeta","metaFilePath","dataPath","readJsonFile","log","LogLevelLabel","WARN","removeFile","persistedMeta","undefined","writeMetaFile","DEBUG","fs","writeFile","JSON","stringify","meta","virtualFiles","toJSON","artifactsPath","virtualFilesMeta","getPartialMeta","mode"],"mappings":";;;;;;;;;;;;;;;AAoCO,IAAMA,YAAAA,GAAe;AAGrB,IAAMC,cAAAA,GAAiB;AAGvB,IAAMC,aAAAA,GAAgB;AAGtB,IAAMC,gBAAAA,GAAmB;AAGzB,IAAMC,eAAAA,GAAkB;AAGxB,IAAMC,eAAAA,GAAkB;;;AChBxB,IAAMC,wBAAAA,GAA2B;AACjC,IAAMC,iBAAAA,GAAoB;AAY1B,SAASC,0BAAAA,CACdC,MACAC,eAAAA,EAAuB;AAEvB,EAAA,MAAMC,WAAW,CAAA,EAAGC,mBAAAA,CAAUH,IAAAA,CAAAA,IAASC,eAAAA,CAAAA,CAAAA;AAEvC,EAAA,OAAOC,SAASE,MAAAA,GAASP,wBAAAA,GACrBK,SAASG,KAAAA,CAAM,CAAA,EAAGR,wBAAAA,CAAAA,GA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ACd,CAAA,4BAAA,EAA+BL,YAAAA,CAAAA,sBAAAA,CAAoC,CAAA;AAErE,MAAA,MAAMM,sBAAWN,YAAAA,CAAAA;AAEjBhB,MAAAA,OAAAA,CAAQuB,aAAAA,GAAgBC,MAAAA;AAC1B,IAAA;AACF,EAAA;AAEA,EAAA,OAAOA,MAAAA;AACT;AAnBsBT,wBAAAA,CAAAA,gBAAAA,EAAAA,kBAAAA,CAAAA;AA2BtB,eAAsBU,cAAczB,OAAAA,EAAgB;AAClD,EAAA,MAAMgB,YAAAA,GAAetB,mBAAAA,CAAUM,OAAAA,CAAQiB,QAAAA,EAAU,WAAA,CAAA;AAEjDjB,EAAAA,OAAAA,CAAQmB,GAAAA,CACNC,mBAAAA,CAAcM,KAAAA,EACd,CAAA,4BAAA,EAA+BV,YAAAA,CAAAA,CAAc,CAAA;AAG/C,EAAA,MAAMhB,OAAAA,CAAQ2B,EAAAA,CAAGC,SAAAA,CACfZ,YAAAA,EACAa,KAAKC,SAAAA,CACH;AACE,IAAA,GAAG9B,OAAAA,CAAQ+B,IAAAA;AACXC,IAAAA,YAAAA,EAAchC,QAAQ2B,EAAAA,CAAGpD,eAAAA,CAAAA,CAAiB0D,MAAAA,CAAOjC,QAAQkC,aAAa,CAAA;IACtEC,gBAAAA,EAAkBnC,OAAAA,CAAQ2B,GAAGS,cAAAA;GAC/B,EACA,IAAA,EACA,CAAA,CAAA,EAEF;IACEC,IAAAA,EAAM;GACR,CAAA;AAEJ;AAvBsBZ,wBAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"chunk-BW3VFCTS.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { PrimitiveJsonValue } from \"@stryke/json/types\";\nimport type { Volume } from \"memfs\";\nimport type {\n MakeDirectoryOptions as FsMakeDirectoryOptions,\n WriteFileOptions as FsWriteFileOptions,\n Mode,\n PathLike,\n PathOrFileDescriptor,\n RmDirOptions,\n RmOptions,\n Stats,\n StatSyncOptions\n} from \"node:fs\";\nimport type { IUnionFs } from \"unionfs\";\n\nexport type VirtualFileExtension = \"js\" | \"ts\" | \"jsx\" | \"tsx\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_INIT__ = \"__VFS_INIT__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_REVERT__ = \"__VFS_REVERT__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_CACHE__ = \"__VFS_CACHE__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_RESOLVER__ = \"__VFS_RESOLVER__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_VIRTUAL__ = \"__VFS_VIRTUAL__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_UNIFIED__ = \"__VFS_UNIFIED__\";\n\nexport type OutputModeType = \"fs\" | \"virtual\";\n\nexport interface VirtualFile {\n /**\n * The unique identifier for the virtual file.\n *\n * @remarks\n * If no specific id is provided, it defaults to the file's {@link path}.\n */\n id: string;\n\n /**\n * Additional metadata associated with the virtual file.\n */\n details: Record<string, PrimitiveJsonValue>;\n\n /**\n * The variant of the file.\n *\n * @remarks\n * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:\n * - `builtin`: Indicates that the file is a built-in module provided by the system.\n * - `entry`: Indicates that the file is an entry point for execution.\n * - `normal`: Indicates that the file is a standard file without any special role.\n */\n variant: string;\n\n /**\n * The output mode of the file.\n *\n * @remarks\n * This indicates whether the file is intended to be written to the actual file system (`fs`) or kept in the virtual file system (`virtual`).\n */\n mode: OutputModeType;\n\n /**\n * A virtual (or actual) path to the file in the file system.\n */\n path: string;\n\n /**\n * The contents of the file.\n */\n code: string | NodeJS.ArrayBufferView;\n}\n\nexport type VirtualFileSystemMetadata = Pick<\n VirtualFile,\n \"id\" | \"details\" | \"variant\" | \"mode\"\n>;\n\nexport interface ResolveFSOptions {\n mode?: OutputModeType;\n}\n\nexport type MakeDirectoryOptions = (Mode | FsMakeDirectoryOptions) &\n ResolveFSOptions;\n\nexport interface PowerlinesWriteFileOptions extends ResolveFSOptions {\n skipFormat?: boolean;\n}\n\nexport type NodeWriteFileOptions = FsWriteFileOptions;\n\nexport type WriteFileOptions =\n | NodeWriteFileOptions\n | PowerlinesWriteFileOptions;\n\nexport type PowerLinesWriteFileData = Partial<\n Omit<VirtualFile, \"path\" | \"mode\" | \"code\">\n> &\n Pick<VirtualFile, \"code\">;\n\nexport type WriteFileData =\n | string\n | NodeJS.ArrayBufferView\n | PowerLinesWriteFileData;\n\nexport interface ResolvePathOptions extends ResolveFSOptions {\n /**\n * Should the resolved path include the file extension?\n *\n * @defaultValue true\n */\n withExtension?: boolean;\n\n /**\n * The paths to search for the file.\n */\n paths?: string[];\n\n /**\n * The type of the path to resolve.\n */\n type?: \"file\" | \"directory\";\n}\n\nexport interface VirtualFileSystemInterface {\n [__VFS_INIT__]: () => void;\n [__VFS_REVERT__]: () => void;\n\n /**\n * The underlying file metadata.\n */\n meta: Record<string, VirtualFileSystemMetadata | undefined>;\n\n /**\n * A map of module ids to their file paths.\n */\n ids: Record<string, string>;\n\n /**\n * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.\n *\n * @param pathOrId - The path or id to check.\n * @param options - Optional parameters for resolving the path.\n * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.\n */\n isVirtual: (pathOrId: string, options?: ResolvePathOptions) => boolean;\n\n /**\n * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.\n *\n * @param pathOrId - The path or id to check.\n * @param options - Optional parameters for resolving the path.\n * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.\n */\n isFs: (pathOrId: string, options?: ResolvePathOptions) => boolean;\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path of the file to check.\n * @returns `true` if the file exists, otherwise `false`.\n */\n isFile: (path: string) => boolean;\n\n /**\n * Checks if a directory exists in the virtual file system (VFS).\n *\n * @param path - The path of the directory to check.\n * @returns `true` if the directory exists, otherwise `false`.\n */\n isDirectory: (path: string) => boolean;\n\n /**\n * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param pathOrId - The path or id to check.\n * @returns Whether the path or id corresponds to a virtual file.\n */\n isTsconfigPath: (pathOrId: string) => boolean;\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns `true` if the file exists, otherwise `false`.\n */\n existsSync: (pathOrId: string) => boolean;\n\n /**\n * Gets the metadata of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The metadata of the file if it exists, otherwise undefined.\n */\n getMetadata: (pathOrId: PathLike) => VirtualFileSystemMetadata | undefined;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @param options - Optional parameters for getting the stats.\n * @returns The stats of the file if it exists, otherwise undefined.\n */\n lstat: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Promise<Stats>;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @param options - Optional parameters for getting the stats.\n * @returns The stats of the file if it exists, otherwise undefined.\n */\n lstatSync: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Stats | undefined;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The stats of the file if it exists, otherwise false.\n */\n stat: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Promise<Stats>;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The stats of the file if it exists, otherwise false.\n */\n statSync: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Stats | undefined;\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n readdirSync: (\n path: string,\n options?:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding\n ) => string[];\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n readdir: (\n path: string,\n options?:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding\n ) => Promise<string[]>;\n\n /**\n * Removes a file or symbolic link in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @returns A promise that resolves when the file is removed.\n */\n unlinkSync: (path: PathLike, options?: ResolveFSOptions) => void;\n\n /**\n * Asynchronously removes a file or symbolic link in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @returns A promise that resolves when the file is removed.\n */\n unlink: (path: string, options?: ResolveFSOptions) => Promise<void>;\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n */\n rmdirSync: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => any;\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n rmdir: (\n path: PathLike,\n options?: RmDirOptions & ResolveFSOptions\n ) => Promise<void>;\n\n /**\n * Removes a file or directory in the virtual file system (VFS).\n *\n * @param path - The path to the file or directory to remove.\n * @param options - Options for removing the file or directory.\n * @returns A promise that resolves when the file or directory is removed.\n */\n rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;\n\n /**\n * Synchronously removes a file or directory in the virtual file system (VFS).\n *\n * @param path - The path to the file or directory to remove.\n * @param options - Options for removing the file or directory.\n */\n rmSync: (path: PathLike, options?: RmOptions & ResolveFSOptions) => void;\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n mkdirSync: (\n path: PathLike,\n options?: MakeDirectoryOptions\n ) => string | undefined;\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n mkdir: (\n path: PathLike,\n options?: MakeDirectoryOptions\n ) => Promise<string | undefined>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The contents of the file if it exists, otherwise undefined.\n */\n readFile: (pathOrId: string) => Promise<string | undefined>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n */\n readFileSync: (pathOrId: string) => string | undefined;\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n writeFile: (\n path: PathOrFileDescriptor,\n data?: WriteFileData,\n options?: WriteFileOptions\n ) => Promise<void>;\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n */\n writeFileSync: (\n path: PathOrFileDescriptor,\n data?: WriteFileData,\n options?: WriteFileOptions\n ) => void;\n\n /**\n * Moves a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n move: (srcPath: string, destPath: string) => Promise<void>;\n\n /**\n * Synchronously moves a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n moveSync: (srcPath: string, destPath: string) => void;\n\n /**\n * Copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n copy: (srcPath: string, destPath: string) => Promise<void>;\n\n /**\n * Synchronously copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n copySync: (srcPath: string, destPath: string) => void;\n\n /**\n * Glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n glob: (pattern: string | string[]) => Promise<string[]>;\n\n /**\n * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n globSync: (pattern: string | string[]) => string[];\n\n /**\n * Resolves a path or id to a file path in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @param options - Optional parameters for resolving the path.\n * @returns The resolved path of the file if it exists, otherwise false.\n */\n resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;\n\n /**\n * Resolves a path based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved file path if it exists, otherwise undefined.\n */\n resolveTsconfigPath: (path: string) => string | false;\n\n /**\n * Resolves a package name based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved package name if it exists, otherwise undefined.\n */\n resolveTsconfigPathPackage: (path: string) => string | false;\n\n /**\n * Resolves a path or id to a file path in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @returns The resolved path of the file if it exists, otherwise false.\n */\n realpathSync: (pathOrId: string) => string;\n\n /**\n * Retrieves a partial metadata mapping of all files in the virtual file system (VFS).\n *\n * @returns A record mapping file paths to their partial metadata.\n */\n getPartialMeta: () => Record<string, Partial<VirtualFileSystemMetadata>>;\n\n /**\n * A map of cached file paths to their underlying file content.\n */\n [__VFS_CACHE__]: Map<string, string>;\n\n /**\n * A reference to the underlying virtual file system.\n */\n [__VFS_VIRTUAL__]: Volume;\n\n /**\n * A reference to the underlying unified file system.\n */\n [__VFS_UNIFIED__]: IUnionFs;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { removeFile } from \"@stryke/fs/remove-file\";\nimport { hashDirectory } from \"@stryke/hash/hash-files\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { Context, MetaInfo } from \"../../types/context\";\nimport { __VFS_VIRTUAL__ } from \"../../types/vfs\";\n\nexport interface CreateContextOptions {\n name?: string;\n}\n\nexport const PROJECT_ROOT_HASH_LENGTH = 45;\nexport const CACHE_HASH_LENGTH = 62;\n\n/**\n * Generates a prefixed project root hash object.\n *\n * @remarks\n * This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.\n *\n * @param name - The name of the project.\n * @param projectRootHash - The hash of the project root.\n * @returns An object containing the name and project root hash.\n */\nexport function getPrefixedProjectRootHash(\n name: string,\n projectRootHash: string\n): string {\n const combined = `${kebabCase(name)}_${projectRootHash}`;\n\n return combined.length > PROJECT_ROOT_HASH_LENGTH\n ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH)\n : combined;\n}\n\nasync function discoverTemplatePath(path: string): Promise<string[]> {\n return (\n await Promise.all([\n Promise.resolve(/.tsx?$/.test(path) && !path.includes(\"*\") && path),\n Promise.resolve(!hasFileExtension(path) && joinPaths(path, \".ts\")),\n Promise.resolve(!hasFileExtension(path) && joinPaths(path, \".tsx\")),\n Promise.resolve(\n !hasFileExtension(path) && listFiles(joinPaths(path, \"**/*.ts\"))\n ),\n Promise.resolve(\n !hasFileExtension(path) && listFiles(joinPaths(path, \"**/*.tsx\"))\n )\n ])\n )\n .flat()\n .filter(Boolean) as string[];\n}\n\nexport async function discoverTemplates(\n context: Context,\n paths: string[] = []\n): Promise<string[]> {\n return getUnique(\n (\n await Promise.all([\n ...paths.map(discoverTemplatePath),\n discoverTemplatePath(joinPaths(context.config.sourceRoot, \"plugin\")),\n discoverTemplatePath(joinPaths(context.envPaths.config, \"templates\")),\n discoverTemplatePath(joinPaths(context.config.projectRoot, \"templates\"))\n ])\n )\n .flat()\n .reduce((ret, path) => {\n if (existsSync(path)) {\n ret.push(path);\n }\n\n return ret;\n }, [] as string[])\n );\n}\n\nexport async function getChecksum(path: string): Promise<string> {\n return hashDirectory(path, {\n ignore: [\"node_modules\", \".git\", \".nx\", \".cache\", \".storm\", \"tmp\", \"dist\"]\n });\n}\n\n/**\n * Retrieves the persisted meta information from the context's data path.\n *\n * @param context - The build context.\n * @returns A promise that resolves to the persisted meta information, or undefined if not found.\n */\nexport async function getPersistedMeta(\n context: Context\n): Promise<MetaInfo | undefined> {\n const metaFilePath = joinPaths(context.dataPath, \"meta.json\");\n if (existsSync(metaFilePath)) {\n try {\n return await readJsonFile<MetaInfo>(metaFilePath);\n } catch {\n context.log(\n LogLevelLabel.WARN,\n `Failed to read meta file at ${metaFilePath}. It may be corrupted.`\n );\n await removeFile(metaFilePath);\n\n context.persistedMeta = undefined;\n }\n }\n\n return undefined;\n}\n\n/**\n * Writes the meta file for the context.\n *\n * @param context - The context to write the meta file for.\n * @returns A promise that resolves when the meta file has been written.\n */\nexport async function writeMetaFile(context: Context): Promise<void> {\n const metaFilePath = joinPaths(context.dataPath, \"meta.json\");\n\n context.log(\n LogLevelLabel.DEBUG,\n `Writing runtime metadata to ${metaFilePath}`\n );\n\n await context.fs.writeFile(\n metaFilePath,\n JSON.stringify(\n {\n ...context.meta,\n virtualFiles: context.fs[__VFS_VIRTUAL__].toJSON(context.artifactsPath),\n virtualFilesMeta: context.fs.getPartialMeta()\n },\n null,\n 2\n ),\n {\n mode: \"fs\"\n }\n );\n}\n"]}
@@ -0,0 +1,105 @@
1
+ import { __name } from './chunk-7QVYU63E.js';
2
+ import { joinPaths } from '@stryke/path/join';
3
+ import { InMemoryFileSystemHost, Project } from 'ts-morph';
4
+
5
+ var VirtualFileSystemHost = class VirtualFileSystemHost2 extends InMemoryFileSystemHost {
6
+ static {
7
+ __name(this, "VirtualFileSystemHost");
8
+ }
9
+ #fs;
10
+ constructor(fs) {
11
+ super();
12
+ this.#fs = fs;
13
+ }
14
+ deleteSync(path) {
15
+ this.#fs.rmSync(path);
16
+ }
17
+ readDirSync(dirPath) {
18
+ return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {
19
+ const fullPath = this.#fs.resolve(joinPaths(dirPath, entry));
20
+ if (fullPath) {
21
+ ret.push({
22
+ name: entry,
23
+ isDirectory: this.#fs.isDirectory(fullPath),
24
+ isFile: this.#fs.isFile(fullPath),
25
+ isSymlink: false
26
+ });
27
+ }
28
+ return ret;
29
+ }, []);
30
+ }
31
+ async readFile(filePath) {
32
+ if (!this.#fs.existsSync(filePath)) {
33
+ throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
34
+ }
35
+ return await this.#fs.readFile(filePath);
36
+ }
37
+ readFileSync(filePath) {
38
+ if (!this.#fs.existsSync(filePath)) {
39
+ throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
40
+ }
41
+ return this.#fs.readFileSync(filePath);
42
+ }
43
+ async writeFile(filePath, fileText) {
44
+ return this.#fs.writeFile(filePath, fileText);
45
+ }
46
+ writeFileSync(filePath, fileText) {
47
+ this.#fs.writeFileSync(filePath, fileText);
48
+ }
49
+ async mkdir(dirPath) {
50
+ await this.#fs.mkdir(dirPath);
51
+ }
52
+ mkdirSync(dirPath) {
53
+ this.#fs.mkdirSync(dirPath);
54
+ }
55
+ async move(srcPath, destPath) {
56
+ await this.#fs.move(srcPath, destPath);
57
+ }
58
+ moveSync(srcPath, destPath) {
59
+ this.#fs.moveSync(srcPath, destPath);
60
+ }
61
+ async copy(srcPath, destPath) {
62
+ await this.#fs.copy(srcPath, destPath);
63
+ }
64
+ copySync(srcPath, destPath) {
65
+ this.#fs.copySync(srcPath, destPath);
66
+ }
67
+ async fileExists(filePath) {
68
+ return this.#fs.isFile(filePath);
69
+ }
70
+ fileExistsSync(filePath) {
71
+ return this.#fs.isFile(filePath);
72
+ }
73
+ async directoryExists(dirPath) {
74
+ return this.#fs.isDirectory(dirPath);
75
+ }
76
+ directoryExistsSync(dirPath) {
77
+ return this.#fs.isDirectory(dirPath);
78
+ }
79
+ realpathSync(path) {
80
+ return this.#fs.resolve(path) || path;
81
+ }
82
+ getCurrentDirectory() {
83
+ return "/";
84
+ }
85
+ async glob(patterns) {
86
+ return this.#fs.glob(patterns);
87
+ }
88
+ globSync(patterns) {
89
+ return this.#fs.globSync(patterns);
90
+ }
91
+ };
92
+ function createProgram(context) {
93
+ return new Project({
94
+ compilerOptions: {
95
+ ...context.tsconfig.options
96
+ },
97
+ tsConfigFilePath: context.tsconfig.tsconfigFilePath,
98
+ fileSystem: new VirtualFileSystemHost(context.fs)
99
+ });
100
+ }
101
+ __name(createProgram, "createProgram");
102
+
103
+ export { createProgram };
104
+ //# sourceMappingURL=chunk-ESYYL5UH.js.map
105
+ //# sourceMappingURL=chunk-ESYYL5UH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/create-program.ts"],"names":["VirtualFileSystemHost","InMemoryFileSystemHost","fs","deleteSync","path","rmSync","readDirSync","dirPath","readdirSync","reduce","ret","entry","fullPath","resolve","joinPaths","push","name","isDirectory","isFile","isSymlink","readFile","filePath","existsSync","Error","readFileSync","writeFile","fileText","writeFileSync","mkdir","mkdirSync","move","srcPath","destPath","moveSync","copy","copySync","fileExists","fileExistsSync","directoryExists","directoryExistsSync","realpathSync","getCurrentDirectory","glob","patterns","globSync","createProgram","context","Project","compilerOptions","tsconfig","options","tsConfigFilePath","tsconfigFilePath","fileSystem"],"mappings":";;;;AA4BA,IAAMA,qBAAAA,GAAN,MAAMA,sBAAAA,SACIC,sBAAAA,CAAAA;EA7BV;;;AAgCE,EAAA,GAAA;AAEA,EAAA,WAAA,CAAmBC,EAAAA,EAAgC;AACjD,IAAA,KAAA,EAAK;AACL,IAAA,IAAA,CAAK,GAAA,GAAMA,EAAAA;AACb,EAAA;AAEgBC,EAAAA,UAAAA,CAAWC,IAAAA,EAAc;AACvC,IAAA,IAAA,CAAK,GAAA,CAAIC,OAAOD,IAAAA,CAAAA;AAClB,EAAA;AAEgBE,EAAAA,WAAAA,CAAYC,OAAAA,EAAoC;AAC9D,IAAA,OAAO,IAAA,CAAK,IAAIC,WAAAA,CAAYD,OAAAA,EAASE,MAAAA,CAAO,CAACC,KAAKC,KAAAA,KAAAA;AAChD,MAAA,MAAMC,WAAW,IAAA,CAAK,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AAA;AACzB,EAAA;AAEA,EAAA,MAAsBiB,gBAAgB/B,OAAAA,EAAiB;AACrD,IAAA,OAAO,IAAA,CAAK,GAAA,CAAIU,WAAAA,CAAYV,OAAAA,CAAAA;AAC9B,EAAA;AAEgBgC,EAAAA,mBAAAA,CAAoBhC,OAAAA,EAA0B;AAC5D,IAAA,OAAO,IAAA,CAAK,GAAA,CAAIU,WAAAA,CAAYV,OAAAA,CAAAA;AAC9B,EAAA;AAEgBiC,EAAAA,YAAAA,CAAapC,IAAAA,EAAc;AACzC,IAAA,OAAO,IAAA,CAAK,GAAA,CAAIS,OAAAA,CAAQT,IAAAA,CAAAA,IAASA,IAAAA;AACnC,EAAA;EAEgBqC,mBAAAA,GAAsB;AACpC,IAAA,OAAO,GAAA;AACT,EAAA;AAEA,EAAA,MAAsBC,KACpBC,QAAAA,EACmB;AACnB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAID,IAAAA,CAAKC,QAAAA,CAAAA;AACvB,EAAA;AAEgBC,EAAAA,QAAAA,CAASD,QAAAA,EAA2C;AAClE,IAAA,OAAO,IAAA,CAAK,GAAA,CAAIC,QAAAA,CAASD,QAAAA,CAAAA;AAC3B,EAAA;AACF,CAAA;AAOO,SAASE,cAAcC,OAAAA,EAAgB;AAC5C,EAAA,OAAO,IAAIC,OAAAA,CAAQ;IACjBC,eAAAA,EAAiB;AACf,MAAA,GAAGF,QAAQG,QAAAA,CAASC;AACtB,KAAA;AACAC,IAAAA,gBAAAA,EAAkBL,QAAQG,QAAAA,CAASG,gBAAAA;IACnCC,UAAAA,EAAY,IAAIrD,qBAAAA,CAAsB8C,OAAAA,CAAQ5C,EAAE;GAClD,CAAA;AACF;AARgB2C,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"chunk-ESYYL5UH.js","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport {\n FileSystemHost,\n InMemoryFileSystemHost,\n Project,\n RuntimeDirEntry\n} from \"ts-morph\";\nimport { Context } from \"../types/context\";\nimport { VirtualFileSystemInterface } from \"../types/vfs\";\n\nclass VirtualFileSystemHost\n extends InMemoryFileSystemHost\n implements FileSystemHost\n{\n #fs: VirtualFileSystemInterface;\n\n public constructor(fs: VirtualFileSystemInterface) {\n super();\n this.#fs = fs;\n }\n\n public override deleteSync(path: string) {\n this.#fs.rmSync(path);\n }\n\n public override readDirSync(dirPath: string): RuntimeDirEntry[] {\n return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {\n const fullPath = this.#fs.resolve(joinPaths(dirPath, entry));\n if (fullPath) {\n ret.push({\n name: entry,\n isDirectory: this.#fs.isDirectory(fullPath),\n isFile: this.#fs.isFile(fullPath),\n isSymlink: false\n });\n }\n\n return ret;\n }, [] as RuntimeDirEntry[]);\n }\n\n public override async readFile(filePath: string) {\n if (!this.#fs.existsSync(filePath)) {\n throw new Error(\n `File not found: '${filePath}'. Please check the path and try again.`\n );\n }\n\n return (await this.#fs.readFile(filePath))!;\n }\n\n public override readFileSync(filePath: string) {\n if (!this.#fs.existsSync(filePath)) {\n throw new Error(\n `File not found: '${filePath}'. Please check the path and try again.`\n );\n }\n\n return this.#fs.readFileSync(filePath)!;\n }\n\n public override async writeFile(filePath: string, fileText: string) {\n return this.#fs.writeFile(filePath, fileText);\n }\n\n public override writeFileSync(filePath: string, fileText: string) {\n this.#fs.writeFileSync(filePath, fileText);\n }\n\n public override async mkdir(dirPath: string) {\n await this.#fs.mkdir(dirPath);\n }\n\n public override mkdirSync(dirPath: string) {\n this.#fs.mkdirSync(dirPath);\n }\n\n public override async move(srcPath: string, destPath: string) {\n await this.#fs.move(srcPath, destPath);\n }\n\n public override moveSync(srcPath: string, destPath: string) {\n this.#fs.moveSync(srcPath, destPath);\n }\n\n public override async copy(srcPath: string, destPath: string) {\n await this.#fs.copy(srcPath, destPath);\n }\n\n public override copySync(srcPath: string, destPath: string) {\n this.#fs.copySync(srcPath, destPath);\n }\n\n public override async fileExists(filePath: string) {\n return this.#fs.isFile(filePath);\n }\n\n public override fileExistsSync(filePath: string) {\n return this.#fs.isFile(filePath);\n }\n\n public override async directoryExists(dirPath: string) {\n return this.#fs.isDirectory(dirPath);\n }\n\n public override directoryExistsSync(dirPath: string): boolean {\n return this.#fs.isDirectory(dirPath);\n }\n\n public override realpathSync(path: string) {\n return this.#fs.resolve(path) || path;\n }\n\n public override getCurrentDirectory() {\n return \"/\";\n }\n\n public override async glob(\n patterns: ReadonlyArray<string>\n ): Promise<string[]> {\n return this.#fs.glob(patterns as string[]);\n }\n\n public override globSync(patterns: ReadonlyArray<string>): string[] {\n return this.#fs.globSync(patterns as string[]);\n }\n}\n\n/**\n * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing\n *\n * @returns A ts-morph {@link Project} instance\n */\nexport function createProgram(context: Context): Project {\n return new Project({\n compilerOptions: {\n ...context.tsconfig.options\n },\n tsConfigFilePath: context.tsconfig.tsconfigFilePath,\n fileSystem: new VirtualFileSystemHost(context.fs)\n });\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import { resolvePath } from './chunk-RXQWNSZX.js';
2
+ import { extractESBuildConfig } from './chunk-3I2YOM2E.js';
3
+ import { __name } from './chunk-7QVYU63E.js';
4
+ import { LogLevelLabel } from '@storm-software/config-tools/types';
5
+ import { build } from 'esbuild';
6
+
7
+ async function bundle(context, file, overrides = {}) {
8
+ const path = await resolvePath(context, file);
9
+ if (!path || !context.fs.existsSync(path)) {
10
+ throw new Error(`Module not found: "${file}". Please check the path and try again.`);
11
+ }
12
+ const result = await build({
13
+ ...extractESBuildConfig(context),
14
+ entry: [
15
+ path
16
+ ],
17
+ write: false,
18
+ sourcemap: false,
19
+ splitting: false,
20
+ treeShaking: false,
21
+ bundle: true,
22
+ ...overrides
23
+ });
24
+ if (result.errors.length > 0) {
25
+ throw new Error(`Failed to transpile ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
26
+ }
27
+ if (result.warnings.length > 0) {
28
+ context.log(LogLevelLabel.WARN, `Warnings while transpiling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
29
+ }
30
+ if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {
31
+ throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
32
+ }
33
+ return result.outputFiles.filter(Boolean)[0];
34
+ }
35
+ __name(bundle, "bundle");
36
+
37
+ export { bundle };
38
+ //# sourceMappingURL=chunk-GTQZYDA7.js.map
39
+ //# sourceMappingURL=chunk-GTQZYDA7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/bundle.ts"],"names":["bundle","context","file","overrides","path","resolvePath","fs","existsSync","Error","result","build","extractESBuildConfig","entry","write","sourcemap","splitting","treeShaking","errors","length","map","error","text","join","warnings","log","LogLevelLabel","WARN","warning","outputFiles","filter","Boolean"],"mappings":";;;;;;AAiCA,eAAsBA,MAAAA,CACpBC,OAAAA,EACAC,IAAAA,EACAC,SAAAA,GAAiD,EAAC,EAAC;AAEnD,EAAA,MAAMC,IAAAA,GAAO,MAAMC,WAAAA,CAAYJ,OAAAA,EAASC,IAAAA,CAAAA;AACxC,EAAA,IAAI,CAACE,IAAAA,IAAQ,CAACH,QAAQK,EAAAA,CAAGC,UAAAA,CAAWH,IAAAA,CAAAA,EAAO;AACzC,IAAA,MAAM,IAAII,KAAAA,CACR,CAAA,mBAAA,EAAsBN,IAAAA,CAAAA,uCAAAA,CAA6C,CAAA;AAEvE,EAAA;AAEA,EAAA,MAAMO,MAAAA,GAAS,MAAMC,K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A,QAAAA,CAAAA","file":"chunk-GTQZYDA7.js","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { build, BuildOptions, OutputFile } from \"esbuild\";\nimport { ESBuildResolvedBuildConfig } from \"powerlines/types/build\";\nimport { Context } from \"../types/context\";\nimport { extractESBuildConfig } from \"./build/esbuild\";\nimport { resolvePath } from \"./utilities/resolve-path\";\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle(\n context: Context,\n file: string,\n overrides: Partial<ESBuildResolvedBuildConfig> = {}\n): Promise<OutputFile> {\n const path = await resolvePath(context, file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n const result = await build({\n ...extractESBuildConfig(context),\n entry: [path],\n write: false,\n sourcemap: false,\n splitting: false,\n treeShaking: false,\n bundle: true,\n ...overrides\n } as BuildOptions);\n if (result.errors.length > 0) {\n throw new Error(\n `Failed to transpile ${file}: ${result.errors\n .map(error => error.text)\n .join(\", \")}`\n );\n }\n if (result.warnings.length > 0) {\n context.log(\n LogLevelLabel.WARN,\n `Warnings while transpiling ${file}: ${result.warnings\n .map(warning => warning.text)\n .join(\", \")}`\n );\n }\n if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n\n return result.outputFiles.filter(Boolean)[0]!;\n}\n"]}
@@ -92,5 +92,5 @@ async function writeMetaFile(context) {
92
92
  __name(writeMetaFile, "writeMetaFile");
93
93
 
94
94
  export { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, __VFS_CACHE__, __VFS_INIT__, __VFS_RESOLVER__, __VFS_REVERT__, __VFS_UNIFIED__, __VFS_VIRTUAL__, discoverTemplates, getChecksum, getPersistedMeta, getPrefixedProjectRootHash, writeMetaFile };
95
- //# sourceMappingURL=chunk-M7U5RMK7.js.map
96
- //# sourceMappingURL=chunk-M7U5RMK7.js.map
95
+ //# sourceMappingURL=chunk-KOCDKJDJ.js.map
96
+ //# sourceMappingURL=chunk-KOCDKJDJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/vfs.ts","../../src/lib/utilities/meta.ts"],"names":["__VFS_INIT__","__VFS_REVERT__","__VFS_CACHE__","__VFS_RESOLVER__","__VFS_VIRTUAL__","__VFS_UNIFIED__","PROJECT_ROOT_HASH_LENGTH","CACHE_HASH_LENGTH","getPrefixedProjectRootHash","name","projectRootHash","combined","kebabCase","length","slice","discoverTemplatePath","path","Promise","all","resolve","test","includes","hasFileExtension","joinPaths","listFiles","flat","filter","Boolean","discoverTemplates","context","paths","getUnique","map","config","sourceRoot","envPaths","projectRoot","reduce","ret","existsSync","push","getChecksum","hashDirectory","ignore","getPersistedMeta","metaFilePath","dataPath","readJsonFile","log","LogLevelLabel","WARN","removeFile","persistedMeta","undefined","writeMetaFile","DEBUG","fs","writeFile","JSON","stringify","meta","virtualFiles","toJSON","artifactsPath","virtualFilesMeta","getPartialMeta","mode"],"mappings":";;;;;;;;;;;;;AAoCO,IAAMA,YAAAA,GAAe;AAGrB,IAAMC,cAAAA,GAAiB;AAGvB,IAAMC,aAAAA,GAAgB;AAGtB,IAAMC,gBAAAA,GAAmB;AAGzB,IAAMC,eAAAA,GAAkB;AAGx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AAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"chunk-KOCDKJDJ.js","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { PrimitiveJsonValue } from \"@stryke/json/types\";\nimport type { Volume } from \"memfs\";\nimport type {\n MakeDirectoryOptions as FsMakeDirectoryOptions,\n WriteFileOptions as FsWriteFileOptions,\n Mode,\n PathLike,\n PathOrFileDescriptor,\n RmDirOptions,\n RmOptions,\n Stats,\n StatSyncOptions\n} from \"node:fs\";\nimport type { IUnionFs } from \"unionfs\";\n\nexport type VirtualFileExtension = \"js\" | \"ts\" | \"jsx\" | \"tsx\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_INIT__ = \"__VFS_INIT__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_REVERT__ = \"__VFS_REVERT__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_CACHE__ = \"__VFS_CACHE__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_RESOLVER__ = \"__VFS_RESOLVER__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_VIRTUAL__ = \"__VFS_VIRTUAL__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_UNIFIED__ = \"__VFS_UNIFIED__\";\n\nexport type OutputModeType = \"fs\" | \"virtual\";\n\nexport interface VirtualFile {\n /**\n * The unique identifier for the virtual file.\n *\n * @remarks\n * If no specific id is provided, it defaults to the file's {@link path}.\n */\n id: string;\n\n /**\n * Additional metadata associated with the virtual file.\n */\n details: Record<string, PrimitiveJsonValue>;\n\n /**\n * The variant of the file.\n *\n * @remarks\n * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:\n * - `builtin`: Indicates that the file is a built-in module provided by the system.\n * - `entry`: Indicates that the file is an entry point for execution.\n * - `normal`: Indicates that the file is a standard file without any special role.\n */\n variant: string;\n\n /**\n * The output mode of the file.\n *\n * @remarks\n * This indicates whether the file is intended to be written to the actual file system (`fs`) or kept in the virtual file system (`virtual`).\n */\n mode: OutputModeType;\n\n /**\n * A virtual (or actual) path to the file in the file system.\n */\n path: string;\n\n /**\n * The contents of the file.\n */\n code: string | NodeJS.ArrayBufferView;\n}\n\nexport type VirtualFileSystemMetadata = Pick<\n VirtualFile,\n \"id\" | \"details\" | \"variant\" | \"mode\"\n>;\n\nexport interface ResolveFSOptions {\n mode?: OutputModeType;\n}\n\nexport type MakeDirectoryOptions = (Mode | FsMakeDirectoryOptions) &\n ResolveFSOptions;\n\nexport interface PowerlinesWriteFileOptions extends ResolveFSOptions {\n skipFormat?: boolean;\n}\n\nexport type NodeWriteFileOptions = FsWriteFileOptions;\n\nexport type WriteFileOptions =\n | NodeWriteFileOptions\n | PowerlinesWriteFileOptions;\n\nexport type PowerLinesWriteFileData = Partial<\n Omit<VirtualFile, \"path\" | \"mode\" | \"code\">\n> &\n Pick<VirtualFile, \"code\">;\n\nexport type WriteFileData =\n | string\n | NodeJS.ArrayBufferView\n | PowerLinesWriteFileData;\n\nexport interface ResolvePathOptions extends ResolveFSOptions {\n /**\n * Should the resolved path include the file extension?\n *\n * @defaultValue true\n */\n withExtension?: boolean;\n\n /**\n * The paths to search for the file.\n */\n paths?: string[];\n\n /**\n * The type of the path to resolve.\n */\n type?: \"file\" | \"directory\";\n}\n\nexport interface VirtualFileSystemInterface {\n [__VFS_INIT__]: () => void;\n [__VFS_REVERT__]: () => void;\n\n /**\n * The underlying file metadata.\n */\n meta: Record<string, VirtualFileSystemMetadata | undefined>;\n\n /**\n * A map of module ids to their file paths.\n */\n ids: Record<string, string>;\n\n /**\n * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.\n *\n * @param pathOrId - The path or id to check.\n * @param options - Optional parameters for resolving the path.\n * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.\n */\n isVirtual: (pathOrId: string, options?: ResolvePathOptions) => boolean;\n\n /**\n * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.\n *\n * @param pathOrId - The path or id to check.\n * @param options - Optional parameters for resolving the path.\n * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.\n */\n isFs: (pathOrId: string, options?: ResolvePathOptions) => boolean;\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path of the file to check.\n * @returns `true` if the file exists, otherwise `false`.\n */\n isFile: (path: string) => boolean;\n\n /**\n * Checks if a directory exists in the virtual file system (VFS).\n *\n * @param path - The path of the directory to check.\n * @returns `true` if the directory exists, otherwise `false`.\n */\n isDirectory: (path: string) => boolean;\n\n /**\n * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param pathOrId - The path or id to check.\n * @returns Whether the path or id corresponds to a virtual file.\n */\n isTsconfigPath: (pathOrId: string) => boolean;\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns `true` if the file exists, otherwise `false`.\n */\n existsSync: (pathOrId: string) => boolean;\n\n /**\n * Gets the metadata of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The metadata of the file if it exists, otherwise undefined.\n */\n getMetadata: (pathOrId: PathLike) => VirtualFileSystemMetadata | undefined;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @param options - Optional parameters for getting the stats.\n * @returns The stats of the file if it exists, otherwise undefined.\n */\n lstat: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Promise<Stats>;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @param options - Optional parameters for getting the stats.\n * @returns The stats of the file if it exists, otherwise undefined.\n */\n lstatSync: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Stats | undefined;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The stats of the file if it exists, otherwise false.\n */\n stat: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Promise<Stats>;\n\n /**\n * Gets the stats of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The stats of the file if it exists, otherwise false.\n */\n statSync: (\n pathOrId: string,\n options?: StatSyncOptions & {\n bigint?: false | undefined;\n throwIfNoEntry: false;\n }\n ) => Stats | undefined;\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n readdirSync: (\n path: string,\n options?:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding\n ) => string[];\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @param options - Options for listing files, such as encoding and recursion.\n * @returns An array of file names in the specified path.\n */\n readdir: (\n path: string,\n options?:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding\n ) => Promise<string[]>;\n\n /**\n * Removes a file or symbolic link in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @returns A promise that resolves when the file is removed.\n */\n unlinkSync: (path: PathLike, options?: ResolveFSOptions) => void;\n\n /**\n * Asynchronously removes a file or symbolic link in the virtual file system (VFS).\n *\n * @param path - The path to the file to remove.\n * @returns A promise that resolves when the file is removed.\n */\n unlink: (path: string, options?: ResolveFSOptions) => Promise<void>;\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n */\n rmdirSync: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => any;\n\n /**\n * Removes a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n rmdir: (\n path: PathLike,\n options?: RmDirOptions & ResolveFSOptions\n ) => Promise<void>;\n\n /**\n * Removes a file or directory in the virtual file system (VFS).\n *\n * @param path - The path to the file or directory to remove.\n * @param options - Options for removing the file or directory.\n * @returns A promise that resolves when the file or directory is removed.\n */\n rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;\n\n /**\n * Synchronously removes a file or directory in the virtual file system (VFS).\n *\n * @param path - The path to the file or directory to remove.\n * @param options - Options for removing the file or directory.\n */\n rmSync: (path: PathLike, options?: RmOptions & ResolveFSOptions) => void;\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n mkdirSync: (\n path: PathLike,\n options?: MakeDirectoryOptions\n ) => string | undefined;\n\n /**\n * Creates a directory in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n * @param options - Options for creating the directory.\n * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.\n */\n mkdir: (\n path: PathLike,\n options?: MakeDirectoryOptions\n ) => Promise<string | undefined>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n * @returns The contents of the file if it exists, otherwise undefined.\n */\n readFile: (pathOrId: string) => Promise<string | undefined>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param pathOrId - The path or id of the file.\n */\n readFileSync: (pathOrId: string) => string | undefined;\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n writeFile: (\n path: PathOrFileDescriptor,\n data?: WriteFileData,\n options?: WriteFileOptions\n ) => Promise<void>;\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n */\n writeFileSync: (\n path: PathOrFileDescriptor,\n data?: WriteFileData,\n options?: WriteFileOptions\n ) => void;\n\n /**\n * Moves a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n move: (srcPath: string, destPath: string) => Promise<void>;\n\n /**\n * Synchronously moves a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n moveSync: (srcPath: string, destPath: string) => void;\n\n /**\n * Copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n copy: (srcPath: string, destPath: string) => Promise<void>;\n\n /**\n * Synchronously copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n copySync: (srcPath: string, destPath: string) => void;\n\n /**\n * Glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n glob: (pattern: string | string[]) => Promise<string[]>;\n\n /**\n * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n globSync: (pattern: string | string[]) => string[];\n\n /**\n * Resolves a path or id to a file path in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @param options - Optional parameters for resolving the path.\n * @returns The resolved path of the file if it exists, otherwise false.\n */\n resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;\n\n /**\n * Resolves a path based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved file path if it exists, otherwise undefined.\n */\n resolveTsconfigPath: (path: string) => string | false;\n\n /**\n * Resolves a package name based on TypeScript's `tsconfig.json` paths.\n *\n * @see https://www.typescriptlang.org/tsconfig#paths\n *\n * @param path - The path to check.\n * @returns The resolved package name if it exists, otherwise undefined.\n */\n resolveTsconfigPathPackage: (path: string) => string | false;\n\n /**\n * Resolves a path or id to a file path in the virtual file system.\n *\n * @param pathOrId - The path or id of the file to resolve.\n * @returns The resolved path of the file if it exists, otherwise false.\n */\n realpathSync: (pathOrId: string) => string;\n\n /**\n * Retrieves a partial metadata mapping of all files in the virtual file system (VFS).\n *\n * @returns A record mapping file paths to their partial metadata.\n */\n getPartialMeta: () => Record<string, Partial<VirtualFileSystemMetadata>>;\n\n /**\n * A map of cached file paths to their underlying file content.\n */\n [__VFS_CACHE__]: Map<string, string>;\n\n /**\n * A reference to the underlying virtual file system.\n */\n [__VFS_VIRTUAL__]: Volume;\n\n /**\n * A reference to the underlying unified file system.\n */\n [__VFS_UNIFIED__]: IUnionFs;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { removeFile } from \"@stryke/fs/remove-file\";\nimport { hashDirectory } from \"@stryke/hash/hash-files\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { Context, MetaInfo } from \"../../types/context\";\nimport { __VFS_VIRTUAL__ } from \"../../types/vfs\";\n\nexport interface CreateContextOptions {\n name?: string;\n}\n\nexport const PROJECT_ROOT_HASH_LENGTH = 45;\nexport const CACHE_HASH_LENGTH = 62;\n\n/**\n * Generates a prefixed project root hash object.\n *\n * @remarks\n * This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.\n *\n * @param name - The name of the project.\n * @param projectRootHash - The hash of the project root.\n * @returns An object containing the name and project root hash.\n */\nexport function getPrefixedProjectRootHash(\n name: string,\n projectRootHash: string\n): string {\n const combined = `${kebabCase(name)}_${projectRootHash}`;\n\n return combined.length > PROJECT_ROOT_HASH_LENGTH\n ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH)\n : combined;\n}\n\nasync function discoverTemplatePath(path: string): Promise<string[]> {\n return (\n await Promise.all([\n Promise.resolve(/.tsx?$/.test(path) && !path.includes(\"*\") && path),\n Promise.resolve(!hasFileExtension(path) && joinPaths(path, \".ts\")),\n Promise.resolve(!hasFileExtension(path) && joinPaths(path, \".tsx\")),\n Promise.resolve(\n !hasFileExtension(path) && listFiles(joinPaths(path, \"**/*.ts\"))\n ),\n Promise.resolve(\n !hasFileExtension(path) && listFiles(joinPaths(path, \"**/*.tsx\"))\n )\n ])\n )\n .flat()\n .filter(Boolean) as string[];\n}\n\nexport async function discoverTemplates(\n context: Context,\n paths: string[] = []\n): Promise<string[]> {\n return getUnique(\n (\n await Promise.all([\n ...paths.map(discoverTemplatePath),\n discoverTemplatePath(joinPaths(context.config.sourceRoot, \"plugin\")),\n discoverTemplatePath(joinPaths(context.envPaths.config, \"templates\")),\n discoverTemplatePath(joinPaths(context.config.projectRoot, \"templates\"))\n ])\n )\n .flat()\n .reduce((ret, path) => {\n if (existsSync(path)) {\n ret.push(path);\n }\n\n return ret;\n }, [] as string[])\n );\n}\n\nexport async function getChecksum(path: string): Promise<string> {\n return hashDirectory(path, {\n ignore: [\"node_modules\", \".git\", \".nx\", \".cache\", \".storm\", \"tmp\", \"dist\"]\n });\n}\n\n/**\n * Retrieves the persisted meta information from the context's data path.\n *\n * @param context - The build context.\n * @returns A promise that resolves to the persisted meta information, or undefined if not found.\n */\nexport async function getPersistedMeta(\n context: Context\n): Promise<MetaInfo | undefined> {\n const metaFilePath = joinPaths(context.dataPath, \"meta.json\");\n if (existsSync(metaFilePath)) {\n try {\n return await readJsonFile<MetaInfo>(metaFilePath);\n } catch {\n context.log(\n LogLevelLabel.WARN,\n `Failed to read meta file at ${metaFilePath}. It may be corrupted.`\n );\n await removeFile(metaFilePath);\n\n context.persistedMeta = undefined;\n }\n }\n\n return undefined;\n}\n\n/**\n * Writes the meta file for the context.\n *\n * @param context - The context to write the meta file for.\n * @returns A promise that resolves when the meta file has been written.\n */\nexport async function writeMetaFile(context: Context): Promise<void> {\n const metaFilePath = joinPaths(context.dataPath, \"meta.json\");\n\n context.log(\n LogLevelLabel.DEBUG,\n `Writing runtime metadata to ${metaFilePath}`\n );\n\n await context.fs.writeFile(\n metaFilePath,\n JSON.stringify(\n {\n ...context.meta,\n virtualFiles: context.fs[__VFS_VIRTUAL__].toJSON(context.artifactsPath),\n virtualFilesMeta: context.fs.getPartialMeta()\n },\n null,\n 2\n ),\n {\n mode: \"fs\"\n }\n );\n}\n"]}