powerlines 0.23.3 → 0.23.5

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 (290) hide show
  1. package/dist/api--9pVSIbm.d.cts +168 -0
  2. package/dist/api-DxPACGY4.d.ts +168 -0
  3. package/dist/api.cjs +3 -3
  4. package/dist/api.d.cts +16 -7
  5. package/dist/api.d.ts +16 -7
  6. package/dist/api.js +2 -2
  7. package/dist/astro.cjs +8 -8
  8. package/dist/astro.d.cts +3 -5
  9. package/dist/astro.d.ts +3 -5
  10. package/dist/astro.js +5 -5
  11. package/dist/babel-types.d.ts +292 -0
  12. package/dist/{chunk-CPRXGMH2.js → chunk-33BDG6M5.js} +1 -1
  13. package/dist/{chunk-KFRKOIP3.js → chunk-3HOOIAF4.js} +1 -1
  14. package/dist/{chunk-JZAQW55G.cjs → chunk-4OAW547A.cjs} +2 -2
  15. package/dist/{chunk-Q7HBETZW.js → chunk-5CCEQUAZ.js} +1 -1
  16. package/dist/{chunk-DWV5QAGZ.cjs → chunk-62BQYRPM.cjs} +2999 -2712
  17. package/dist/{chunk-F6BDL4HD.js → chunk-AK5B45AH.js} +1 -1
  18. package/dist/{chunk-3WDMXRK6.cjs → chunk-AYKZK666.cjs} +1 -1
  19. package/dist/{chunk-TNYZH6EG.js → chunk-E4M4KEL3.js} +2983 -2701
  20. package/dist/{chunk-WSLPUUGZ.js → chunk-GHHMURR4.js} +1 -1
  21. package/dist/{chunk-5A7FM72H.cjs → chunk-GXJ5L37C.cjs} +2 -2
  22. package/dist/{chunk-IGWSCIES.js → chunk-GZNJUK7U.js} +3 -2
  23. package/dist/{chunk-J7MZRPLN.cjs → chunk-I3EUY74Q.cjs} +5 -4
  24. package/dist/chunk-IVABRCNA.js +29 -0
  25. package/dist/{chunk-M4QJ2474.cjs → chunk-JJXDDTSL.cjs} +4 -4
  26. package/dist/{chunk-WDBPA4RQ.cjs → chunk-K5TOHSUD.cjs} +2 -2
  27. package/dist/{chunk-4ODWTALP.js → chunk-M7N6RX2H.js} +2 -2
  28. package/dist/{chunk-J3LN5HOC.cjs → chunk-MAOXZVDE.cjs} +2 -2
  29. package/dist/{chunk-YQ76DZYD.cjs → chunk-NWZXH2HK.cjs} +2 -2
  30. package/dist/{chunk-ZFO3FUM4.cjs → chunk-PFECSHR6.cjs} +2 -2
  31. package/dist/{chunk-JAJ4CI2F.cjs → chunk-Q3ZFML4W.cjs} +2 -2
  32. package/dist/chunk-RM37JA3L.cjs +32 -0
  33. package/dist/{chunk-GNNF5SG6.cjs → chunk-RVO5GC2H.cjs} +2 -2
  34. package/dist/{chunk-J5LKLH5Z.js → chunk-TSKJTJ2P.js} +1 -1
  35. package/dist/{chunk-WG55ZHJL.cjs → chunk-VRFJDHDN.cjs} +2 -2
  36. package/dist/{chunk-FM4ABZQ2.js → chunk-VT7NVLLU.js} +1 -1
  37. package/dist/{chunk-LKN52AAX.js → chunk-W36NC3B7.js} +1 -1
  38. package/dist/{chunk-RWVNX2CP.js → chunk-XDNNFAQR.js} +1 -1
  39. package/dist/{chunk-DUYZ3TCT.js → chunk-XWBVMNBI.js} +1 -1
  40. package/dist/{chunk-WXU3KLBP.cjs → chunk-YBOJFFO2.cjs} +2 -2
  41. package/dist/{chunk-NH7U3PTV.js → chunk-ZOMJH52N.js} +1 -1
  42. package/dist/config.d.cts +3 -5
  43. package/dist/config.d.ts +3 -5
  44. package/dist/esbuild.cjs +7 -7
  45. package/dist/esbuild.d.cts +3 -5
  46. package/dist/esbuild.d.ts +3 -5
  47. package/dist/esbuild.js +4 -4
  48. package/dist/farm.cjs +4 -4
  49. package/dist/farm.d.cts +3 -5
  50. package/dist/farm.d.ts +3 -5
  51. package/dist/farm.js +3 -3
  52. package/dist/index.cjs +54 -33
  53. package/dist/index.d.cts +188 -36
  54. package/dist/index.d.ts +188 -36
  55. package/dist/index.js +18 -17
  56. package/dist/lib/api-B6hfFxVS.d.ts +167 -0
  57. package/dist/lib/api-CD2QlMig.d.cts +167 -0
  58. package/dist/lib/build/esbuild.d.cts +2 -4
  59. package/dist/lib/build/esbuild.d.ts +2 -4
  60. package/dist/lib/build/index.d.cts +4 -5
  61. package/dist/lib/build/index.d.ts +4 -5
  62. package/dist/lib/build/rolldown.d.cts +2 -4
  63. package/dist/lib/build/rolldown.d.ts +2 -4
  64. package/dist/lib/build/rollup.d.cts +2 -4
  65. package/dist/lib/build/rollup.d.ts +2 -4
  66. package/dist/lib/build/rspack.d.cts +2 -4
  67. package/dist/lib/build/rspack.d.ts +2 -4
  68. package/dist/lib/build/tsup.d.cts +2 -4
  69. package/dist/lib/build/tsup.d.ts +2 -4
  70. package/dist/lib/build/unbuild.d.cts +4 -23
  71. package/dist/lib/build/unbuild.d.ts +4 -23
  72. package/dist/lib/build/vite.d.cts +2 -4
  73. package/dist/lib/build/vite.d.ts +2 -4
  74. package/dist/lib/build/webpack.d.cts +2 -4
  75. package/dist/lib/build/webpack.d.ts +2 -4
  76. package/dist/lib/chunk-27RAXIPT.cjs +175 -0
  77. package/dist/lib/chunk-32Q2PG5D.js +9 -0
  78. package/dist/lib/chunk-35FGUJFD.cjs +2 -0
  79. package/dist/lib/{chunk-LIN4KAV3.js → chunk-52VDUP5J.js} +5 -7
  80. package/dist/lib/{chunk-UWHGJ4JS.js → chunk-764HUXP3.js} +484 -1777
  81. package/dist/lib/chunk-B3EE3VHZ.cjs +127 -0
  82. package/dist/lib/chunk-CCGA6ZHZ.cjs +1218 -0
  83. package/dist/lib/chunk-DX2VAXZB.cjs +11 -0
  84. package/dist/lib/{chunk-VGSV2BEL.cjs → chunk-EFYMNU53.cjs} +6 -12
  85. package/dist/lib/chunk-EJTGOYSI.cjs +146 -0
  86. package/dist/lib/chunk-EN4XP4D5.js +144 -0
  87. package/dist/lib/chunk-FFT4PWRM.js +1 -0
  88. package/dist/lib/{chunk-L4NEN725.js → chunk-G7S5PIAC.js} +1 -1
  89. package/dist/lib/chunk-KFJCWNVG.js +120 -0
  90. package/dist/lib/chunk-MVIKYHBX.cjs +2 -0
  91. package/dist/lib/chunk-NDKPSA3I.js +1190 -0
  92. package/dist/lib/{chunk-A5SB72VO.cjs → chunk-NVUXGMU5.cjs} +495 -1781
  93. package/dist/lib/chunk-NYNHNTHT.js +1 -0
  94. package/dist/lib/chunk-SZH2DJOG.js +168 -0
  95. package/dist/lib/{chunk-ULJVBW4L.cjs → chunk-ZBDVQVUK.cjs} +1 -1
  96. package/dist/lib/{config-BoGlIhnH.d.cts → config-DTSdCZsw.d.cts} +650 -633
  97. package/dist/lib/{config-CTej7RMP.d.ts → config-DeUaQYc_.d.ts} +650 -633
  98. package/dist/lib/config-file.d.cts +2 -4
  99. package/dist/lib/config-file.d.ts +2 -4
  100. package/dist/lib/contexts/api-context.cjs +18 -0
  101. package/dist/lib/contexts/api-context.d.cts +69 -0
  102. package/dist/lib/contexts/api-context.d.ts +69 -0
  103. package/dist/lib/contexts/api-context.js +9 -0
  104. package/dist/lib/contexts/context.cjs +15 -0
  105. package/dist/lib/contexts/context.d.cts +255 -0
  106. package/dist/lib/contexts/context.d.ts +255 -0
  107. package/dist/lib/contexts/context.js +6 -0
  108. package/dist/lib/contexts/environment-context.cjs +17 -0
  109. package/dist/lib/contexts/environment-context.d.cts +65 -0
  110. package/dist/lib/contexts/environment-context.d.ts +65 -0
  111. package/dist/lib/contexts/environment-context.js +8 -0
  112. package/dist/lib/contexts/index.cjs +31 -0
  113. package/dist/lib/contexts/index.d.cts +35 -0
  114. package/dist/lib/contexts/index.d.ts +35 -0
  115. package/dist/lib/contexts/index.js +10 -0
  116. package/dist/lib/contexts/plugin-context.cjs +11 -0
  117. package/dist/lib/contexts/plugin-context.d.cts +42 -0
  118. package/dist/lib/contexts/plugin-context.d.ts +42 -0
  119. package/dist/lib/contexts/plugin-context.js +2 -0
  120. package/dist/lib/entry.d.cts +2 -4
  121. package/dist/lib/entry.d.ts +2 -4
  122. package/dist/lib/index.cjs +96 -74
  123. package/dist/lib/index.d.cts +17 -14
  124. package/dist/lib/index.d.ts +17 -14
  125. package/dist/lib/index.js +18 -12
  126. package/dist/lib/internal-CpVMJCaU.d.ts +39 -0
  127. package/dist/lib/internal-ypnrUNZy.d.cts +39 -0
  128. package/dist/lib/logger.d.cts +2 -4
  129. package/dist/lib/logger.d.ts +2 -4
  130. package/dist/lib/typescript/compiler-host.cjs +1 -1
  131. package/dist/lib/typescript/compiler-host.d.cts +2 -4
  132. package/dist/lib/typescript/compiler-host.d.ts +2 -4
  133. package/dist/lib/typescript/compiler-host.js +1 -1
  134. package/dist/lib/typescript/import-transformer.d.cts +2 -4
  135. package/dist/lib/typescript/import-transformer.d.ts +2 -4
  136. package/dist/lib/typescript/index.cjs +29 -24
  137. package/dist/lib/typescript/index.d.cts +4 -4
  138. package/dist/lib/typescript/index.d.ts +4 -4
  139. package/dist/lib/typescript/index.js +3 -2
  140. package/dist/lib/typescript/program.d.cts +2 -4
  141. package/dist/lib/typescript/program.d.ts +2 -4
  142. package/dist/lib/typescript/ts-morph.cjs +11 -0
  143. package/dist/lib/{create-program.d.ts → typescript/ts-morph.d.cts} +3 -5
  144. package/dist/lib/{create-program.d.cts → typescript/ts-morph.d.ts} +3 -5
  145. package/dist/lib/typescript/ts-morph.js +2 -0
  146. package/dist/lib/unplugin/factory.cjs +8 -4
  147. package/dist/lib/unplugin/factory.d.cts +27 -10
  148. package/dist/lib/unplugin/factory.d.ts +27 -10
  149. package/dist/lib/unplugin/factory.js +7 -3
  150. package/dist/lib/unplugin/helpers.cjs +11 -0
  151. package/dist/lib/unplugin/helpers.d.cts +128 -0
  152. package/dist/lib/unplugin/helpers.d.ts +128 -0
  153. package/dist/lib/unplugin/helpers.js +2 -0
  154. package/dist/lib/unplugin/index.cjs +12 -7
  155. package/dist/lib/unplugin/index.d.cts +4 -6
  156. package/dist/lib/unplugin/index.d.ts +4 -6
  157. package/dist/lib/unplugin/index.js +9 -4
  158. package/dist/lib/unplugin/plugin.cjs +4 -3
  159. package/dist/lib/unplugin/plugin.d.cts +2 -4
  160. package/dist/lib/unplugin/plugin.d.ts +2 -4
  161. package/dist/lib/unplugin/plugin.js +3 -2
  162. package/dist/lib/unplugin/resolve-id.cjs +2 -2
  163. package/dist/lib/unplugin/resolve-id.d.cts +2 -4
  164. package/dist/lib/unplugin/resolve-id.d.ts +2 -4
  165. package/dist/lib/unplugin/resolve-id.js +1 -1
  166. package/dist/lib/utilities/bundle.d.cts +2 -4
  167. package/dist/lib/utilities/bundle.d.ts +2 -4
  168. package/dist/lib/utilities/cache.d.cts +2 -4
  169. package/dist/lib/utilities/cache.d.ts +2 -4
  170. package/dist/lib/utilities/file-header.d.cts +2 -4
  171. package/dist/lib/utilities/file-header.d.ts +2 -4
  172. package/dist/lib/utilities/index.cjs +18 -18
  173. package/dist/lib/utilities/index.d.cts +2 -4
  174. package/dist/lib/utilities/index.d.ts +2 -4
  175. package/dist/lib/utilities/index.js +4 -4
  176. package/dist/lib/utilities/meta.d.cts +2 -4
  177. package/dist/lib/utilities/meta.d.ts +2 -4
  178. package/dist/lib/utilities/resolve-path.d.cts +2 -4
  179. package/dist/lib/utilities/resolve-path.d.ts +2 -4
  180. package/dist/lib/utilities/resolve.d.cts +2 -4
  181. package/dist/lib/utilities/resolve.d.ts +2 -4
  182. package/dist/lib/utilities/source-file.d.cts +2 -4
  183. package/dist/lib/utilities/source-file.d.ts +2 -4
  184. package/dist/lib/utilities/source-map.d.cts +2 -4
  185. package/dist/lib/utilities/source-map.d.ts +2 -4
  186. package/dist/lib/utilities/worker.d.cts +2 -4
  187. package/dist/lib/utilities/worker.d.ts +2 -4
  188. package/dist/lib/utilities/write-file.d.cts +2 -4
  189. package/dist/lib/utilities/write-file.d.ts +2 -4
  190. package/dist/next.cjs +8 -8
  191. package/dist/next.js +5 -5
  192. package/dist/nuxt.cjs +9 -9
  193. package/dist/nuxt.js +6 -6
  194. package/dist/plugin-utils/{context-D1I2JQgs.d.cts → context-DRFZE3XI.d.cts} +535 -518
  195. package/dist/plugin-utils/{context-D1I2JQgs.d.ts → context-DRFZE3XI.d.ts} +535 -518
  196. package/dist/plugin-utils/context-helpers.d.cts +2 -4
  197. package/dist/plugin-utils/context-helpers.d.ts +2 -4
  198. package/dist/plugin-utils/enforce.d.cts +2 -4
  199. package/dist/plugin-utils/enforce.d.ts +2 -4
  200. package/dist/plugin-utils/extend.d.cts +2 -4
  201. package/dist/plugin-utils/extend.d.ts +2 -4
  202. package/dist/plugin-utils/get-config-path.d.cts +2 -4
  203. package/dist/plugin-utils/get-config-path.d.ts +2 -4
  204. package/dist/plugin-utils/helpers.d.cts +2 -4
  205. package/dist/plugin-utils/helpers.d.ts +2 -4
  206. package/dist/plugin-utils/index.d.cts +2 -4
  207. package/dist/plugin-utils/index.d.ts +2 -4
  208. package/dist/plugin-utils/merge.d.cts +2 -4
  209. package/dist/plugin-utils/merge.d.ts +2 -4
  210. package/dist/plugin-utils/paths.d.cts +2 -4
  211. package/dist/plugin-utils/paths.d.ts +2 -4
  212. package/dist/{resolved-Dem-rX6I.d.cts → resolved-C00CJgsk.d.cts} +9 -8
  213. package/dist/{resolved-BVakEeek.d.ts → resolved-DKFZ11S7.d.ts} +9 -8
  214. package/dist/rolldown.cjs +7 -7
  215. package/dist/rolldown.d.cts +3 -5
  216. package/dist/rolldown.d.ts +3 -5
  217. package/dist/rolldown.js +4 -4
  218. package/dist/rollup.cjs +7 -7
  219. package/dist/rollup.d.cts +3 -5
  220. package/dist/rollup.d.ts +3 -5
  221. package/dist/rollup.js +4 -4
  222. package/dist/rspack.cjs +7 -7
  223. package/dist/rspack.d.cts +3 -5
  224. package/dist/rspack.d.ts +3 -5
  225. package/dist/rspack.js +4 -4
  226. package/dist/tsup.cjs +8 -8
  227. package/dist/tsup.js +5 -5
  228. package/dist/types/api.cjs +4 -0
  229. package/dist/types/api.d.cts +36 -0
  230. package/dist/types/api.d.ts +36 -0
  231. package/dist/types/api.js +1 -0
  232. package/dist/types/babel.d.cts +3 -5
  233. package/dist/types/babel.d.ts +3 -5
  234. package/dist/types/commands.d.cts +3 -5
  235. package/dist/types/commands.d.ts +3 -5
  236. package/dist/types/config.d.cts +3 -5
  237. package/dist/types/config.d.ts +3 -5
  238. package/dist/types/context.d.cts +3 -5
  239. package/dist/types/context.d.ts +3 -5
  240. package/dist/types/{vfs.cjs → fs.cjs} +3 -3
  241. package/dist/types/{vfs.d.cts → fs.d.cts} +43 -38
  242. package/dist/types/{vfs.d.ts → fs.d.ts} +43 -38
  243. package/dist/types/fs.js +2 -0
  244. package/dist/types/hooks.d.cts +3 -5
  245. package/dist/types/hooks.d.ts +3 -5
  246. package/dist/types/index.cjs +9 -8
  247. package/dist/types/index.d.cts +5 -6
  248. package/dist/types/index.d.ts +5 -6
  249. package/dist/types/index.js +3 -2
  250. package/dist/types/internal.d.cts +44 -9
  251. package/dist/types/internal.d.ts +44 -9
  252. package/dist/types/plugin.d.cts +3 -5
  253. package/dist/types/plugin.d.ts +3 -5
  254. package/dist/types/resolved.d.cts +3 -5
  255. package/dist/types/resolved.d.ts +3 -5
  256. package/dist/types/unplugin.d.cts +20 -12
  257. package/dist/types/unplugin.d.ts +20 -12
  258. package/dist/unloader.cjs +7 -7
  259. package/dist/unloader.d.cts +12 -14
  260. package/dist/unloader.d.ts +12 -14
  261. package/dist/unloader.js +4 -4
  262. package/dist/unplugin.cjs +18 -18
  263. package/dist/unplugin.d.cts +6 -9
  264. package/dist/unplugin.d.ts +6 -9
  265. package/dist/unplugin.js +15 -15
  266. package/dist/vite.cjs +7 -7
  267. package/dist/vite.d.cts +3 -5
  268. package/dist/vite.d.ts +3 -5
  269. package/dist/vite.js +4 -4
  270. package/dist/webpack.cjs +7 -7
  271. package/dist/webpack.d.cts +3 -5
  272. package/dist/webpack.d.ts +3 -5
  273. package/dist/webpack.js +4 -4
  274. package/package.json +38 -10
  275. package/schemas/fs.capnp +73 -15
  276. package/dist/chunk-RODEAGIJ.cjs +0 -32
  277. package/dist/chunk-SKLSRHBU.js +0 -29
  278. package/dist/hooks-B3vzw6La.d.ts +0 -28
  279. package/dist/hooks-YACA4jMY.d.cts +0 -28
  280. package/dist/lib/create-program.cjs +0 -11
  281. package/dist/lib/create-program.js +0 -2
  282. package/dist/lib/hooks-CDLPWf7j.d.cts +0 -28
  283. package/dist/lib/hooks-Cn-IqwYp.d.ts +0 -28
  284. package/dist/types/vfs.js +0 -2
  285. /package/dist/{chunk-KIKTWMI3.cjs → chunk-2NCILNCH.cjs} +0 -0
  286. /package/dist/{chunk-XVLT2RQ2.js → chunk-BLNT5INX.js} +0 -0
  287. /package/dist/{lib/chunk-RJ4277VZ.cjs → chunk-GRU7B3QM.cjs} +0 -0
  288. /package/dist/{lib/chunk-ZBLDAREE.js → chunk-T2P533I5.js} +0 -0
  289. /package/dist/lib/{chunk-CGYAL3S2.cjs → chunk-4EIXDLFP.cjs} +0 -0
  290. /package/dist/lib/{chunk-CXRSMYEX.js → chunk-RD5AUWXN.js} +0 -0
@@ -2,7 +2,6 @@ import { EnvPaths } from '@stryke/env/get-env-paths';
2
2
  import { NonUndefined, MaybePromise, FunctionLike, DeepPartial as DeepPartial$1 } from '@stryke/types/base';
3
3
  import { PackageJson } from '@stryke/types/package-json';
4
4
  import { Jiti } from 'jiti';
5
- import { ParserOptions, ParseResult } from 'oxc-parser';
6
5
  import { Range } from 'semver';
7
6
  import { TransformResult, ExternalIdResult, HookFilter, UnpluginOptions, UnpluginContext, UnpluginBuildContext, UnpluginMessage } from 'unplugin';
8
7
  import { Format } from '@storm-software/build-tools/types';
@@ -11,10 +10,9 @@ import { StormWorkspaceConfig } from '@storm-software/config/types';
11
10
  import { TypeDefinition, TypeDefinitionParameter } from '@stryke/types/configuration';
12
11
  import { AssetGlob } from '@stryke/types/file';
13
12
  import { ResolvedPreviewOptions, PreviewOptions } from 'vite';
13
+ import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
14
14
  import { TsConfigJson, CompilerOptions } from '@stryke/types/tsconfig';
15
15
  import ts from 'typescript';
16
- import { PrimitiveJsonValue } from '@stryke/json/types';
17
- import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
18
16
  import { ArrayValues } from '@stryke/types/array';
19
17
 
20
18
  type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
@@ -154,746 +152,769 @@ interface BuildConfig {
154
152
  }
155
153
  type BuildResolvedConfig = Omit<BuildConfig, "override">;
156
154
 
157
- declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
158
- type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
159
-
160
- interface ResolvedEntryTypeDefinition extends TypeDefinition {
155
+ declare const __VFS_PATCH__ = "__VFS_PATCH__";
156
+ declare const __VFS_REVERT__ = "__VFS_REVERT__";
157
+ type OutputModeType = "fs" | "virtual";
158
+ interface VirtualFileMetadata {
161
159
  /**
162
- * The user provided entry point in the source code
160
+ * The identifier for the file data.
163
161
  */
164
- input: TypeDefinition;
162
+ id: string;
165
163
  /**
166
- * An optional name to use in the package export during the build process
164
+ * The timestamp of the virtual file.
167
165
  */
168
- output?: string;
169
- }
170
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
166
+ timestamp: number;
171
167
  /**
172
- * The name of the environment
168
+ * The type of the file.
169
+ *
170
+ * @remarks
171
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
172
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
173
+ * - `entry`: Indicates that the file is an entry point for execution.
174
+ * - `normal`: Indicates that the file is a standard file without any special role.
173
175
  */
174
- name: string;
176
+ type: string;
175
177
  /**
176
- * Configuration options for the preview server
178
+ * The output mode of the file.
177
179
  */
178
- preview?: ResolvedPreviewOptions;
179
- };
180
- type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
181
- type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
182
- assets: ResolvedAssetGlob[];
183
- }>;
184
- /**
185
- * The resolved options for the Powerlines project configuration.
186
- */
187
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework">> & {
180
+ mode: string;
188
181
  /**
189
- * The configuration options that were provided inline to the Powerlines CLI.
182
+ * Additional metadata associated with the file.
190
183
  */
191
- inlineConfig: InlineConfig<TUserConfig>;
184
+ properties: Record<string, string>;
185
+ }
186
+ interface VirtualFileData {
192
187
  /**
193
- * The original configuration options that were provided by the user to the Powerlines process.
188
+ * The identifier for the file data.
194
189
  */
195
- userConfig: TUserConfig;
190
+ id?: string;
196
191
  /**
197
- * A string identifier for the Powerlines command being executed.
192
+ * The contents of the virtual file.
198
193
  */
199
- command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
194
+ code: string;
200
195
  /**
201
- * The root directory of the project's source code
196
+ * The type of the file.
202
197
  *
203
- * @defaultValue "\{projectRoot\}/src"
198
+ * @remarks
199
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
200
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
201
+ * - `entry`: Indicates that the file is an entry point for execution.
202
+ * - `chunk`: Indicates that the file is a code chunk, typically used in code-splitting scenarios.
203
+ * - `prebuilt-chunk`: Indicates that the file is a prebuilt code chunk.
204
+ * - `asset`: Indicates that the file is a static asset, such as an image or stylesheet.
205
+ * - `normal`: Indicates that the file is a standard file without any special role.
204
206
  */
205
- sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
207
+ type?: string;
206
208
  /**
207
- * The root directory of the project.
209
+ * The output mode of the file.
208
210
  */
209
- projectRoot: NonUndefined<TUserConfig["root"]>;
211
+ mode?: string;
210
212
  /**
211
- * The type of project being built.
213
+ * Additional metadata associated with the file.
212
214
  */
213
- projectType: NonUndefined<TUserConfig["type"]>;
215
+ properties?: Record<string, string>;
216
+ }
217
+ interface VirtualFile extends Required<VirtualFileData>, VirtualFileMetadata {
214
218
  /**
215
- * The output configuration options to use for the build process
219
+ * An additional name for the file.
216
220
  */
217
- output: OutputResolvedConfig;
221
+ path: string;
218
222
  /**
219
- * Configuration provided to build processes
220
- *
221
- * @remarks
222
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
223
+ * The timestamp of the virtual file.
223
224
  */
224
- build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
225
+ timestamp: number;
226
+ }
227
+ interface ResolveFSOptions {
228
+ mode?: OutputModeType;
229
+ }
230
+ type MakeDirectoryOptions = (Mode | MakeDirectoryOptions$1) & ResolveFSOptions;
231
+ interface PowerlinesWriteFileOptions extends ResolveFSOptions {
225
232
  /**
226
- * The log level to use for the Powerlines processes.
233
+ * Should the file skip formatting before being written?
227
234
  *
228
- * @defaultValue "info"
235
+ * @defaultValue false
229
236
  */
230
- logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
231
- };
232
-
233
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
237
+ skipFormat?: boolean;
238
+ }
239
+ type NodeWriteFileOptions = WriteFileOptions$1;
240
+ type WriteFileOptions = NodeWriteFileOptions | PowerlinesWriteFileOptions;
241
+ type WriteFileData = string | NodeJS.ArrayBufferView | VirtualFileData;
242
+ interface ResolvePathOptions extends ResolveFSOptions {
234
243
  /**
235
- * The order in which the plugin should be applied.
244
+ * Should the resolved path include the file extension?
245
+ *
246
+ * @defaultValue true
236
247
  */
237
- order?: "pre" | "post" | null | undefined;
248
+ withExtension?: boolean;
238
249
  /**
239
- * A filter to determine when the hook should be called.
250
+ * The paths to search for the file.
240
251
  */
241
- filter?: Pick<HookFilter, TFilter>;
252
+ paths?: string[];
242
253
  /**
243
- * The hook function to be called.
254
+ * The type of the path to resolve.
244
255
  */
245
- handler: THookFunction;
246
- }
247
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
248
- /**
249
- * A result returned by the plugin from the `generateTypes` hook that describes the declaration types output file.
250
- */
251
- interface GenerateTypesResult {
252
- directives?: string[];
253
- code: string;
256
+ pathType?: "file" | "directory";
254
257
  }
255
- type DeepPartial<T> = {
256
- [K in keyof T]?: DeepPartial<T[K]>;
257
- };
258
- type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
259
- interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
258
+ interface VirtualFileSystemInterface {
260
259
  /**
261
- * A function that returns configuration options to be merged with the build context's options.
262
- *
263
- * @remarks
264
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
265
- *
266
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
267
- *
268
- * @see https://vitejs.dev/guide/api-plugin#config
269
- *
270
- * @param this - The build context.
271
- * @param config - The partial configuration object to be modified.
272
- * @returns A promise that resolves to a partial configuration object.
260
+ * Patches the File System to include the virtual file system (VFS) contents.
273
261
  */
274
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
262
+ [__VFS_PATCH__]: () => void;
275
263
  /**
276
- * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.
277
- *
278
- * @remarks
279
- * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
280
- *
281
- * @see https://vitejs.dev/guide/api-plugin#configenvironment
282
- *
283
- * @param this - The build context.
284
- * @param name - The name of the environment being configured.
285
- * @param environment - The Vite-like environment object containing information about the current build environment.
286
- * @returns A promise that resolves when the hook is complete.
264
+ * Reverts the virtual file system (VFS) to its previous state.
287
265
  */
288
- configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
266
+ [__VFS_REVERT__]: () => void;
289
267
  /**
290
- * A hook that is called when the plugin is resolved.
291
- *
292
- * @see https://vitejs.dev/guide/api-plugin#configresolved
293
- *
294
- * @param this - The build context.
295
- * @returns A promise that resolves when the hook is complete.
268
+ * The underlying file metadata.
296
269
  */
297
- configResolved: (this: TContext) => MaybePromise<void>;
270
+ metadata: Record<string, VirtualFileMetadata | undefined>;
298
271
  /**
299
- * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
300
- *
301
- * @param this - The build context.
302
- * @param code - The source code to generate types for.
303
- * @returns A promise that resolves when the hook is complete.
272
+ * A map of module ids to their file paths.
304
273
  */
305
- generateTypes: (this: TContext, code: string) => MaybePromise<GenerateTypesResult | string | undefined | null>;
274
+ ids: Record<string, string>;
306
275
  /**
307
- * A hook that is called at the start of the build process.
276
+ * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
308
277
  *
309
- * @param this - The build context and unplugin build context.
310
- * @returns A promise that resolves when the hook is complete.
278
+ * @param pathOrId - The path or id to check.
279
+ * @param options - Optional parameters for resolving the path.
280
+ * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
311
281
  */
312
- buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
282
+ isVirtual: (pathOrId: string, options?: ResolvePathOptions) => boolean;
313
283
  /**
314
- * A hook that is called at the end of the build process.
284
+ * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
315
285
  *
316
- * @param this - The build context and unplugin build context.
317
- * @returns A promise that resolves when the hook is complete.
286
+ * @param pathOrId - The path or id to check.
287
+ * @param options - Optional parameters for resolving the path.
288
+ * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
318
289
  */
319
- buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
290
+ isPhysical: (pathOrId: string, options?: ResolvePathOptions) => boolean;
320
291
  /**
321
- * A hook that is called to transform the source code.
292
+ * Checks if a file exists in the virtual file system (VFS).
322
293
  *
323
- * @param this - The build context, unplugin build context, and unplugin context.
324
- * @param code - The source code to transform.
325
- * @param id - The identifier of the source code.
326
- * @returns A promise that resolves when the hook is complete.
294
+ * @param path - The path of the file to check.
295
+ * @returns `true` if the file exists, otherwise `false`.
327
296
  */
328
- transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
297
+ isFile: (path: string) => boolean;
329
298
  /**
330
- * A hook that is called to load the source code.
299
+ * Checks if a directory exists in the virtual file system (VFS).
331
300
  *
332
- * @param this - The build context, unplugin build context, and unplugin context.
333
- * @param id - The identifier of the source code.
334
- * @returns A promise that resolves when the hook is complete.
301
+ * @param path - The path of the directory to check.
302
+ * @returns `true` if the directory exists, otherwise `false`.
335
303
  */
336
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
304
+ isDirectory: (path: string) => boolean;
337
305
  /**
338
- * A hook that is called to resolve the identifier of the source code.
306
+ * Checks if a file exists in the virtual file system (VFS).
339
307
  *
340
- * @param this - The build context, unplugin build context, and unplugin context.
341
- * @param id - The identifier of the source code.
342
- * @param importer - The importer of the source code.
343
- * @param options - The options for resolving the identifier.
344
- * @returns A promise that resolves when the hook is complete.
308
+ * @param pathOrId - The path or id of the file.
309
+ * @returns `true` if the file exists, otherwise `false`.
345
310
  */
346
- resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
347
- isEntry: boolean;
348
- }) => MaybePromise<string | ExternalIdResult | null | undefined>;
311
+ existsSync: (pathOrId: string) => boolean;
349
312
  /**
350
- * A hook that is called to write the bundle to disk.
313
+ * Gets the metadata of a file in the virtual file system (VFS).
351
314
  *
352
- * @param this - The build context.
353
- * @returns A promise that resolves when the hook is complete.
315
+ * @param pathOrId - The path or id of the file.
316
+ * @returns The metadata of the file if it exists, otherwise undefined.
354
317
  */
355
- writeBundle: (this: TContext) => MaybePromise<void>;
356
- }
357
- type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant] = Required<UnpluginOptions>[TBuildVariant]> = {
358
- [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey];
359
- };
360
- type ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant> = {
361
- [TKey in keyof BuildPlugin<TContext, TBuildVariant> & string as `${TBuildVariant}:${TKey}`]: BuildPlugin<TContext, TBuildVariant>[TKey];
362
- };
363
- type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
364
- type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
365
- type PluginHooks<TContext extends PluginContext = PluginContext> = {
366
- [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]>;
367
- } & {
318
+ getMetadata: (pathOrId: PathLike) => VirtualFileMetadata | undefined;
368
319
  /**
369
- * A function that returns configuration options to be merged with the build context's options.
370
- *
371
- * @remarks
372
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
373
- *
374
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
375
- *
376
- * @see https://vitejs.dev/guide/api-plugin#config
320
+ * Gets the stats of a file in the virtual file system (VFS).
377
321
  *
378
- * @param this - The build context.
379
- * @param config - The partial configuration object to be modified.
380
- * @returns A promise that resolves to a partial configuration object.
322
+ * @param pathOrId - The path or id of the file.
323
+ * @param options - Optional parameters for getting the stats.
324
+ * @returns The stats of the file if it exists, otherwise undefined.
381
325
  */
382
- config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
326
+ lstat: (pathOrId: string, options?: StatSyncOptions & {
327
+ bigint?: false | undefined;
328
+ throwIfNoEntry: false;
329
+ }) => Promise<Stats>;
383
330
  /**
384
- * A hook that is called to transform the source code.
331
+ * Gets the stats of a file in the virtual file system (VFS).
385
332
  *
386
- * @param this - The build context, unplugin build context, and unplugin context.
387
- * @param code - The source code to transform.
388
- * @param id - The identifier of the source code.
389
- * @returns A promise that resolves when the hook is complete.
333
+ * @param pathOrId - The path or id of the file.
334
+ * @param options - Optional parameters for getting the stats.
335
+ * @returns The stats of the file if it exists, otherwise undefined.
390
336
  */
391
- transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
337
+ lstatSync: (pathOrId: string, options?: StatSyncOptions & {
338
+ bigint?: false | undefined;
339
+ throwIfNoEntry: false;
340
+ }) => Stats | undefined;
392
341
  /**
393
- * A hook that is called to load the source code.
342
+ * Gets the stats of a file in the virtual file system (VFS).
394
343
  *
395
- * @param this - The build context, unplugin build context, and unplugin context.
396
- * @param id - The identifier of the source code.
397
- * @returns A promise that resolves when the hook is complete.
344
+ * @param pathOrId - The path or id of the file.
345
+ * @returns The stats of the file if it exists, otherwise false.
398
346
  */
399
- load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
347
+ stat: (pathOrId: string, options?: StatSyncOptions & {
348
+ bigint?: false | undefined;
349
+ throwIfNoEntry: false;
350
+ }) => Promise<Stats>;
400
351
  /**
401
- * A hook that is called to resolve the identifier of the source code.
352
+ * Gets the stats of a file in the virtual file system (VFS).
402
353
  *
403
- * @param this - The build context, unplugin build context, and unplugin context.
404
- * @param id - The identifier of the source code.
405
- * @param importer - The importer of the source code.
406
- * @param options - The options for resolving the identifier.
407
- * @returns A promise that resolves when the hook is complete.
354
+ * @param pathOrId - The path or id of the file.
355
+ * @returns The stats of the file if it exists, otherwise false.
408
356
  */
409
- resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
410
- isEntry: boolean;
411
- }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
412
- };
413
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = {
414
- [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant>;
415
- };
416
- interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
357
+ statSync: (pathOrId: string, options?: StatSyncOptions & {
358
+ bigint?: false | undefined;
359
+ throwIfNoEntry: false;
360
+ }) => Stats | undefined;
417
361
  /**
418
- * The name of the plugin, for use in deduplication, error messages and logs.
362
+ * Lists files in a given path.
363
+ *
364
+ * @param path - The path to list files from.
365
+ * @param options - Options for listing files, such as encoding and recursion.
366
+ * @returns An array of file names in the specified path.
419
367
  */
420
- name: string;
368
+ readdirSync: (path: string, options?: {
369
+ encoding: BufferEncoding | null;
370
+ withFileTypes?: false | undefined;
371
+ recursive?: boolean | undefined;
372
+ } | BufferEncoding) => string[];
421
373
  /**
422
- * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
374
+ * Lists files in a given path.
423
375
  *
424
- * @remarks
425
- * The Plugin invocation order is as follows:
426
- * - `enforce: 'pre'` plugins
427
- * - `order: 'pre'` plugin hooks
428
- * - any other plugins (normal)
429
- * - `order: 'post'` plugin hooks
430
- * - `enforce: 'post'` plugins
376
+ * @param path - The path to list files from.
377
+ * @param options - Options for listing files, such as encoding and recursion.
378
+ * @returns An array of file names in the specified path.
379
+ */
380
+ readdir: (path: string, options?: {
381
+ encoding: BufferEncoding | null;
382
+ withFileTypes?: false | undefined;
383
+ recursive?: boolean | undefined;
384
+ } | BufferEncoding) => Promise<string[]>;
385
+ /**
386
+ * Removes a file or symbolic link in the virtual file system (VFS).
431
387
  *
432
- * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
433
- * @see https://rollupjs.org/plugin-development/#build-hooks
434
- * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
435
- * @see https://esbuild.github.io/plugins/#concepts
388
+ * @param path - The path to the file to remove.
389
+ * @returns A promise that resolves when the file is removed.
436
390
  */
437
- enforce?: "pre" | "post";
391
+ unlinkSync: (path: PathLike, options?: ResolveFSOptions) => void;
438
392
  /**
439
- * A function to determine if two plugins are the same and can be de-duplicated.
393
+ * Asynchronously removes a file or symbolic link in the virtual file system (VFS).
440
394
  *
441
- * @remarks
442
- * If this is not provided, plugins are de-duplicated by comparing their names.
395
+ * @param path - The path to the file to remove.
396
+ * @returns A promise that resolves when the file is removed.
397
+ */
398
+ unlink: (path: string, options?: ResolveFSOptions) => Promise<void>;
399
+ /**
400
+ * Removes a directory in the virtual file system (VFS).
443
401
  *
444
- * @param other - The other plugin to compare against.
445
- * @returns `true` if the two plugins are the same, `false` otherwise.
402
+ * @param path - The path to create the directory at.
403
+ * @param options - Options for creating the directory.
446
404
  */
447
- dedupe?: false | ((other: Plugin<any>) => boolean);
405
+ rmdirSync: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => any;
448
406
  /**
449
- * A list of pre-requisite plugins that must be loaded before this plugin can be used.
407
+ * Removes a directory in the virtual file system (VFS).
408
+ *
409
+ * @param path - The path to create the directory at.
410
+ * @param options - Options for creating the directory.
411
+ * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
450
412
  */
451
- dependsOn?: PluginConfig<any>[];
413
+ rmdir: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => Promise<void>;
452
414
  /**
453
- * Define environments where this plugin should be active. By default, the plugin is active in all environments.
415
+ * Removes a file or directory in the virtual file system (VFS).
454
416
  *
455
- * @param environment - The environment to check.
456
- * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
417
+ * @param path - The path to the file or directory to remove.
418
+ * @param options - Options for removing the file or directory.
419
+ * @returns A promise that resolves when the file or directory is removed.
457
420
  */
458
- applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | Plugin<any>>;
459
- }
460
-
461
- type ReflectionMode = "default" | "explicit" | "never";
462
- type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
463
- /**
464
- * Defines the level of reflection to be used during the transpilation process.
465
- *
466
- * @remarks
467
- * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
468
- * - `minimal` - Only the essential type information is captured.
469
- * - `normal` - Additional type information is captured, including some contextual data.
470
- * - `verbose` - All available type information is captured, including detailed contextual data.
471
- */
472
- type ReflectionLevel = "minimal" | "normal" | "verbose";
473
- interface DeepkitOptions {
421
+ rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;
474
422
  /**
475
- * Either true to activate reflection for all files compiled using this tsconfig,
476
- * or a list of globs/file paths relative to this tsconfig.json.
477
- * Globs/file paths can be prefixed with a ! to exclude them.
423
+ * Synchronously removes a file or directory in the virtual file system (VFS).
424
+ *
425
+ * @param path - The path to the file or directory to remove.
426
+ * @param options - Options for removing the file or directory.
478
427
  */
479
- reflection?: RawReflectionMode;
428
+ rmSync: (path: PathLike, options?: RmOptions & ResolveFSOptions) => void;
480
429
  /**
481
- * Defines the level of reflection to be used during the transpilation process.
430
+ * Creates a directory in the virtual file system (VFS).
482
431
  *
483
- * @remarks
484
- * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
485
- * - `minimal` - Only the essential type information is captured.
486
- * - `normal` - Additional type information is captured, including some contextual data.
487
- * - `verbose` - All available type information is captured, including detailed contextual data.
432
+ * @param path - The path to create the directory at.
433
+ * @param options - Options for creating the directory.
434
+ * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
488
435
  */
489
- reflectionLevel?: ReflectionLevel;
490
- }
491
- type TSCompilerOptions = CompilerOptions & DeepkitOptions;
492
- /**
493
- * The TypeScript compiler configuration.
494
- *
495
- * @see https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
496
- */
497
- interface TSConfig extends Omit<TsConfigJson, "reflection"> {
436
+ mkdirSync: (path: PathLike, options?: MakeDirectoryOptions) => string | undefined;
498
437
  /**
499
- * Either true to activate reflection for all files compiled using this tsconfig,
500
- * or a list of globs/file paths relative to this tsconfig.json.
501
- * Globs/file paths can be prefixed with a ! to exclude them.
438
+ * Creates a directory in the virtual file system (VFS).
439
+ *
440
+ * @param path - The path to create the directory at.
441
+ * @param options - Options for creating the directory.
442
+ * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
502
443
  */
503
- reflection?: RawReflectionMode;
444
+ mkdir: (path: PathLike, options?: MakeDirectoryOptions) => Promise<string | undefined>;
504
445
  /**
505
- * Defines the level of reflection to be used during the transpilation process.
446
+ * Reads a file from the virtual file system (VFS).
506
447
  *
507
- * @remarks
508
- * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
509
- * - `minimal` - Only the essential type information is captured.
510
- * - `normal` - Additional type information is captured, including some contextual data.
511
- * - `verbose` - All available type information is captured, including detailed contextual data.
448
+ * @param pathOrId - The path or id of the file.
449
+ * @returns The contents of the file if it exists, otherwise undefined.
512
450
  */
513
- reflectionLevel?: ReflectionLevel;
451
+ readFile: (pathOrId: string) => Promise<string | undefined>;
514
452
  /**
515
- * Instructs the TypeScript compiler how to compile `.ts` files.
453
+ * Reads a file from the virtual file system (VFS).
454
+ *
455
+ * @param pathOrId - The path or id of the file.
516
456
  */
517
- compilerOptions?: TSCompilerOptions;
518
- }
519
- type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
520
- originalTsconfigJson: TsConfigJson;
521
- tsconfigJson: TSConfig;
522
- tsconfigFilePath: string;
523
- };
524
-
525
- declare const __VFS_PATCH__ = "__VFS_PATCH__";
526
- declare const __VFS_REVERT__ = "__VFS_REVERT__";
527
- type OutputModeType = "fs" | "virtual";
528
- interface VirtualFile {
457
+ readFileSync: (pathOrId: string) => string | undefined;
529
458
  /**
530
- * The unique identifier for the virtual file.
459
+ * Writes a file to the virtual file system (VFS).
531
460
  *
532
- * @remarks
533
- * If no specific id is provided, it defaults to the file's {@link path}.
461
+ * @param path - The path to the file.
462
+ * @param data - The contents of the file.
463
+ * @param options - Optional parameters for writing the file.
464
+ * @returns A promise that resolves when the file is written.
534
465
  */
535
- id: string;
466
+ writeFile: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => Promise<void>;
536
467
  /**
537
- * Additional metadata associated with the virtual file.
468
+ * Writes a file to the virtual file system (VFS).
469
+ *
470
+ * @param path - The path to the file.
471
+ * @param data - The contents of the file.
472
+ * @param options - Optional parameters for writing the file.
538
473
  */
539
- details: Record<string, PrimitiveJsonValue>;
474
+ writeFileSync: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => void;
540
475
  /**
541
- * The variant of the file.
476
+ * Moves a file from one path to another in the virtual file system (VFS).
542
477
  *
543
- * @remarks
544
- * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
545
- * - `builtin`: Indicates that the file is a built-in module provided by the system.
546
- * - `entry`: Indicates that the file is an entry point for execution.
547
- * - `normal`: Indicates that the file is a standard file without any special role.
478
+ * @param srcPath - The source path to move
479
+ * @param destPath - The destination path to move to
548
480
  */
549
- variant: string;
481
+ move: (srcPath: string, destPath: string) => Promise<void>;
550
482
  /**
551
- * The output mode of the file.
483
+ * Synchronously moves a file from one path to another in the virtual file system (VFS).
552
484
  *
553
- * @remarks
554
- * This indicates whether the file is intended to be written to the actual file system (`fs`) or kept in the virtual file system (`virtual`).
485
+ * @param srcPath - The source path to move
486
+ * @param destPath - The destination path to move to
555
487
  */
556
- mode: OutputModeType;
488
+ moveSync: (srcPath: string, destPath: string) => void;
557
489
  /**
558
- * A virtual (or actual) path to the file in the file system.
490
+ * Copies a file from one path to another in the virtual file system (VFS).
491
+ *
492
+ * @param srcPath - The source path to copy
493
+ * @param destPath - The destination path to copy to
559
494
  */
560
- path: string;
495
+ copy: (srcPath: string, destPath: string) => Promise<void>;
561
496
  /**
562
- * The contents of the file.
497
+ * Synchronously copies a file from one path to another in the virtual file system (VFS).
498
+ *
499
+ * @param srcPath - The source path to copy
500
+ * @param destPath - The destination path to copy to
563
501
  */
564
- code: string | NodeJS.ArrayBufferView;
565
- }
566
- interface VirtualFileMetadata {
502
+ copySync: (srcPath: string, destPath: string) => void;
567
503
  /**
568
- * The identifier for the file data.
504
+ * Glob files in the virtual file system (VFS) based on the provided pattern(s).
505
+ *
506
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
507
+ * @returns An array of file paths matching the provided pattern(s)
569
508
  */
570
- id: string;
509
+ glob: (pattern: string | string[]) => Promise<string[]>;
571
510
  /**
572
- * The variant of the file.
511
+ * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
512
+ *
513
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
514
+ * @returns An array of file paths matching the provided pattern(s)
573
515
  */
574
- variant: string;
516
+ globSync: (pattern: string | string[]) => string[];
575
517
  /**
576
- * The output mode of the file.
518
+ * Resolves a path or id to a file path in the virtual file system.
519
+ *
520
+ * @param pathOrId - The path or id of the file to resolve.
521
+ * @param options - Optional parameters for resolving the path.
522
+ * @returns The resolved path of the file if it exists, otherwise false.
577
523
  */
578
- mode: string;
524
+ resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;
579
525
  /**
580
- * Additional metadata associated with the file.
526
+ * Formats a path to match the virtual file system (VFS) structure.
527
+ *
528
+ * @param path - The path to format.
529
+ * @returns The formatted path.
581
530
  */
582
- properties: Record<string, string>;
583
- }
584
- interface ResolveFSOptions {
585
- mode?: OutputModeType;
586
- }
587
- type MakeDirectoryOptions = (Mode | MakeDirectoryOptions$1) & ResolveFSOptions;
588
- interface PowerlinesWriteFileOptions extends ResolveFSOptions {
589
- skipFormat?: boolean;
590
- }
591
- type NodeWriteFileOptions = WriteFileOptions$1;
592
- type WriteFileOptions = NodeWriteFileOptions | PowerlinesWriteFileOptions;
593
- type PowerLinesWriteFileData = Partial<Omit<VirtualFile, "path" | "mode" | "code">> & Pick<VirtualFile, "code">;
594
- type WriteFileData = string | NodeJS.ArrayBufferView | PowerLinesWriteFileData;
595
- interface ResolvePathOptions extends ResolveFSOptions {
531
+ formatPath: (path: string) => string;
596
532
  /**
597
- * Should the resolved path include the file extension?
533
+ * Resolves a path or id to a file path in the virtual file system.
598
534
  *
599
- * @defaultValue true
535
+ * @param pathOrId - The path or id of the file to resolve.
536
+ * @returns The resolved path of the file if it exists, otherwise false.
600
537
  */
601
- withExtension?: boolean;
538
+ realpathSync: (pathOrId: string) => string;
602
539
  /**
603
- * The paths to search for the file.
540
+ * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
604
541
  */
605
- paths?: string[];
542
+ dispose: () => Promise<void>;
543
+ }
544
+
545
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
546
+ type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
547
+
548
+ interface ResolvedEntryTypeDefinition extends TypeDefinition {
606
549
  /**
607
- * The type of the path to resolve.
550
+ * The user provided entry point in the source code
608
551
  */
609
- type?: "file" | "directory";
552
+ input: TypeDefinition;
553
+ /**
554
+ * An optional name to use in the package export during the build process
555
+ */
556
+ output?: string;
610
557
  }
611
- interface VirtualFileSystemInterface {
558
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
612
559
  /**
613
- * Patches the File System to include the virtual file system (VFS) contents.
560
+ * The name of the environment
614
561
  */
615
- [__VFS_PATCH__]: () => void;
562
+ name: string;
616
563
  /**
617
- * Reverts the virtual file system (VFS) to its previous state.
564
+ * Configuration options for the preview server
618
565
  */
619
- [__VFS_REVERT__]: () => void;
566
+ preview?: ResolvedPreviewOptions;
567
+ };
568
+ type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
569
+ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
570
+ assets: ResolvedAssetGlob[];
571
+ }>;
572
+ /**
573
+ * The resolved options for the Powerlines project configuration.
574
+ */
575
+ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework">> & {
620
576
  /**
621
- * The underlying file metadata.
577
+ * The configuration options that were provided inline to the Powerlines CLI.
622
578
  */
623
- metadata: Record<string, VirtualFileMetadata | undefined>;
579
+ inlineConfig: InlineConfig<TUserConfig>;
624
580
  /**
625
- * A map of module ids to their file paths.
581
+ * The original configuration options that were provided by the user to the Powerlines process.
626
582
  */
627
- ids: Record<string, string>;
583
+ userConfig: TUserConfig;
628
584
  /**
629
- * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
630
- *
631
- * @param pathOrId - The path or id to check.
632
- * @param options - Optional parameters for resolving the path.
633
- * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
585
+ * A string identifier for the Powerlines command being executed.
634
586
  */
635
- isVirtual: (pathOrId: string, options?: ResolvePathOptions) => boolean;
587
+ command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
636
588
  /**
637
- * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
589
+ * The root directory of the project's source code
638
590
  *
639
- * @param pathOrId - The path or id to check.
640
- * @param options - Optional parameters for resolving the path.
641
- * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
591
+ * @defaultValue "\{projectRoot\}/src"
642
592
  */
643
- isPhysical: (pathOrId: string, options?: ResolvePathOptions) => boolean;
593
+ sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
644
594
  /**
645
- * Checks if a file exists in the virtual file system (VFS).
646
- *
647
- * @param path - The path of the file to check.
648
- * @returns `true` if the file exists, otherwise `false`.
595
+ * The root directory of the project.
649
596
  */
650
- isFile: (path: string) => boolean;
597
+ projectRoot: NonUndefined<TUserConfig["root"]>;
651
598
  /**
652
- * Checks if a directory exists in the virtual file system (VFS).
653
- *
654
- * @param path - The path of the directory to check.
655
- * @returns `true` if the directory exists, otherwise `false`.
599
+ * The type of project being built.
656
600
  */
657
- isDirectory: (path: string) => boolean;
601
+ projectType: NonUndefined<TUserConfig["type"]>;
658
602
  /**
659
- * Checks if a file exists in the virtual file system (VFS).
660
- *
661
- * @param pathOrId - The path or id of the file.
662
- * @returns `true` if the file exists, otherwise `false`.
603
+ * The output configuration options to use for the build process
663
604
  */
664
- existsSync: (pathOrId: string) => boolean;
605
+ output: OutputResolvedConfig;
665
606
  /**
666
- * Gets the metadata of a file in the virtual file system (VFS).
607
+ * Configuration provided to build processes
667
608
  *
668
- * @param pathOrId - The path or id of the file.
669
- * @returns The metadata of the file if it exists, otherwise undefined.
609
+ * @remarks
610
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
670
611
  */
671
- getMetadata: (pathOrId: PathLike) => VirtualFileMetadata | undefined;
612
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
672
613
  /**
673
- * Gets the stats of a file in the virtual file system (VFS).
614
+ * The log level to use for the Powerlines processes.
674
615
  *
675
- * @param pathOrId - The path or id of the file.
676
- * @param options - Optional parameters for getting the stats.
677
- * @returns The stats of the file if it exists, otherwise undefined.
616
+ * @defaultValue "info"
678
617
  */
679
- lstat: (pathOrId: string, options?: StatSyncOptions & {
680
- bigint?: false | undefined;
681
- throwIfNoEntry: false;
682
- }) => Promise<Stats>;
618
+ logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
619
+ };
620
+
621
+ interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
683
622
  /**
684
- * Gets the stats of a file in the virtual file system (VFS).
685
- *
686
- * @param pathOrId - The path or id of the file.
687
- * @param options - Optional parameters for getting the stats.
688
- * @returns The stats of the file if it exists, otherwise undefined.
623
+ * The order in which the plugin should be applied.
689
624
  */
690
- lstatSync: (pathOrId: string, options?: StatSyncOptions & {
691
- bigint?: false | undefined;
692
- throwIfNoEntry: false;
693
- }) => Stats | undefined;
625
+ order?: "pre" | "post" | null | undefined;
694
626
  /**
695
- * Gets the stats of a file in the virtual file system (VFS).
696
- *
697
- * @param pathOrId - The path or id of the file.
698
- * @returns The stats of the file if it exists, otherwise false.
627
+ * A filter to determine when the hook should be called.
699
628
  */
700
- stat: (pathOrId: string, options?: StatSyncOptions & {
701
- bigint?: false | undefined;
702
- throwIfNoEntry: false;
703
- }) => Promise<Stats>;
629
+ filter?: Pick<HookFilter, TFilter>;
704
630
  /**
705
- * Gets the stats of a file in the virtual file system (VFS).
706
- *
707
- * @param pathOrId - The path or id of the file.
708
- * @returns The stats of the file if it exists, otherwise false.
631
+ * The hook function to be called.
709
632
  */
710
- statSync: (pathOrId: string, options?: StatSyncOptions & {
711
- bigint?: false | undefined;
712
- throwIfNoEntry: false;
713
- }) => Stats | undefined;
633
+ handler: THookFunction;
634
+ }
635
+ type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
636
+ /**
637
+ * A result returned by the plugin from the `generateTypes` hook that describes the declaration types output file.
638
+ */
639
+ interface GenerateTypesResult {
640
+ directives?: string[];
641
+ code: string;
642
+ }
643
+ type DeepPartial<T> = {
644
+ [K in keyof T]?: DeepPartial<T[K]>;
645
+ };
646
+ type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
647
+ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
714
648
  /**
715
- * Lists files in a given path.
649
+ * A function that returns configuration options to be merged with the build context's options.
716
650
  *
717
- * @param path - The path to list files from.
718
- * @param options - Options for listing files, such as encoding and recursion.
719
- * @returns An array of file names in the specified path.
651
+ * @remarks
652
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
653
+ *
654
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
655
+ *
656
+ * @see https://vitejs.dev/guide/api-plugin#config
657
+ *
658
+ * @param this - The build context.
659
+ * @param config - The partial configuration object to be modified.
660
+ * @returns A promise that resolves to a partial configuration object.
720
661
  */
721
- readdirSync: (path: string, options?: {
722
- encoding: BufferEncoding | null;
723
- withFileTypes?: false | undefined;
724
- recursive?: boolean | undefined;
725
- } | BufferEncoding) => string[];
662
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
726
663
  /**
727
- * Lists files in a given path.
664
+ * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.
728
665
  *
729
- * @param path - The path to list files from.
730
- * @param options - Options for listing files, such as encoding and recursion.
731
- * @returns An array of file names in the specified path.
666
+ * @remarks
667
+ * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
668
+ *
669
+ * @see https://vitejs.dev/guide/api-plugin#configenvironment
670
+ *
671
+ * @param this - The build context.
672
+ * @param name - The name of the environment being configured.
673
+ * @param environment - The Vite-like environment object containing information about the current build environment.
674
+ * @returns A promise that resolves when the hook is complete.
732
675
  */
733
- readdir: (path: string, options?: {
734
- encoding: BufferEncoding | null;
735
- withFileTypes?: false | undefined;
736
- recursive?: boolean | undefined;
737
- } | BufferEncoding) => Promise<string[]>;
676
+ configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
738
677
  /**
739
- * Removes a file or symbolic link in the virtual file system (VFS).
678
+ * A hook that is called when the plugin is resolved.
740
679
  *
741
- * @param path - The path to the file to remove.
742
- * @returns A promise that resolves when the file is removed.
680
+ * @see https://vitejs.dev/guide/api-plugin#configresolved
681
+ *
682
+ * @param this - The build context.
683
+ * @returns A promise that resolves when the hook is complete.
743
684
  */
744
- unlinkSync: (path: PathLike, options?: ResolveFSOptions) => void;
685
+ configResolved: (this: TContext) => MaybePromise<void>;
745
686
  /**
746
- * Asynchronously removes a file or symbolic link in the virtual file system (VFS).
687
+ * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
747
688
  *
748
- * @param path - The path to the file to remove.
749
- * @returns A promise that resolves when the file is removed.
689
+ * @param this - The build context.
690
+ * @param code - The source code to generate types for.
691
+ * @returns A promise that resolves when the hook is complete.
750
692
  */
751
- unlink: (path: string, options?: ResolveFSOptions) => Promise<void>;
693
+ generateTypes: (this: TContext, code: string) => MaybePromise<GenerateTypesResult | string | undefined | null>;
752
694
  /**
753
- * Removes a directory in the virtual file system (VFS).
695
+ * A hook that is called at the start of the build process.
754
696
  *
755
- * @param path - The path to create the directory at.
756
- * @param options - Options for creating the directory.
697
+ * @param this - The build context and unplugin build context.
698
+ * @returns A promise that resolves when the hook is complete.
757
699
  */
758
- rmdirSync: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => any;
700
+ buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
759
701
  /**
760
- * Removes a directory in the virtual file system (VFS).
702
+ * A hook that is called at the end of the build process.
761
703
  *
762
- * @param path - The path to create the directory at.
763
- * @param options - Options for creating the directory.
764
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
704
+ * @param this - The build context and unplugin build context.
705
+ * @returns A promise that resolves when the hook is complete.
765
706
  */
766
- rmdir: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => Promise<void>;
707
+ buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
767
708
  /**
768
- * Removes a file or directory in the virtual file system (VFS).
709
+ * A hook that is called to transform the source code.
769
710
  *
770
- * @param path - The path to the file or directory to remove.
771
- * @param options - Options for removing the file or directory.
772
- * @returns A promise that resolves when the file or directory is removed.
711
+ * @param this - The build context, unplugin build context, and unplugin context.
712
+ * @param code - The source code to transform.
713
+ * @param id - The identifier of the source code.
714
+ * @returns A promise that resolves when the hook is complete.
773
715
  */
774
- rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;
716
+ transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
775
717
  /**
776
- * Synchronously removes a file or directory in the virtual file system (VFS).
718
+ * A hook that is called to load the source code.
777
719
  *
778
- * @param path - The path to the file or directory to remove.
779
- * @param options - Options for removing the file or directory.
720
+ * @param this - The build context, unplugin build context, and unplugin context.
721
+ * @param id - The identifier of the source code.
722
+ * @returns A promise that resolves when the hook is complete.
780
723
  */
781
- rmSync: (path: PathLike, options?: RmOptions & ResolveFSOptions) => void;
724
+ load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
782
725
  /**
783
- * Creates a directory in the virtual file system (VFS).
726
+ * A hook that is called to resolve the identifier of the source code.
784
727
  *
785
- * @param path - The path to create the directory at.
786
- * @param options - Options for creating the directory.
787
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
728
+ * @param this - The build context, unplugin build context, and unplugin context.
729
+ * @param id - The identifier of the source code.
730
+ * @param importer - The importer of the source code.
731
+ * @param options - The options for resolving the identifier.
732
+ * @returns A promise that resolves when the hook is complete.
788
733
  */
789
- mkdirSync: (path: PathLike, options?: MakeDirectoryOptions) => string | undefined;
734
+ resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
735
+ isEntry: boolean;
736
+ }) => MaybePromise<string | ExternalIdResult | null | undefined>;
790
737
  /**
791
- * Creates a directory in the virtual file system (VFS).
738
+ * A hook that is called to write the bundle to disk.
792
739
  *
793
- * @param path - The path to create the directory at.
794
- * @param options - Options for creating the directory.
795
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
740
+ * @param this - The build context.
741
+ * @returns A promise that resolves when the hook is complete.
796
742
  */
797
- mkdir: (path: PathLike, options?: MakeDirectoryOptions) => Promise<string | undefined>;
743
+ writeBundle: (this: TContext) => MaybePromise<void>;
744
+ }
745
+ type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant] = Required<UnpluginOptions>[TBuildVariant]> = {
746
+ [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey];
747
+ };
748
+ type ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant> = {
749
+ [TKey in keyof BuildPlugin<TContext, TBuildVariant> & string as `${TBuildVariant}:${TKey}`]: BuildPlugin<TContext, TBuildVariant>[TKey];
750
+ };
751
+ type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
752
+ type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
753
+ type PluginHooks<TContext extends PluginContext = PluginContext> = {
754
+ [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]>;
755
+ } & {
798
756
  /**
799
- * Reads a file from the virtual file system (VFS).
757
+ * A function that returns configuration options to be merged with the build context's options.
800
758
  *
801
- * @param pathOrId - The path or id of the file.
802
- * @returns The contents of the file if it exists, otherwise undefined.
759
+ * @remarks
760
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
761
+ *
762
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
763
+ *
764
+ * @see https://vitejs.dev/guide/api-plugin#config
765
+ *
766
+ * @param this - The build context.
767
+ * @param config - The partial configuration object to be modified.
768
+ * @returns A promise that resolves to a partial configuration object.
803
769
  */
804
- readFile: (pathOrId: string) => Promise<string | undefined>;
770
+ config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
805
771
  /**
806
- * Reads a file from the virtual file system (VFS).
772
+ * A hook that is called to transform the source code.
807
773
  *
808
- * @param pathOrId - The path or id of the file.
774
+ * @param this - The build context, unplugin build context, and unplugin context.
775
+ * @param code - The source code to transform.
776
+ * @param id - The identifier of the source code.
777
+ * @returns A promise that resolves when the hook is complete.
809
778
  */
810
- readFileSync: (pathOrId: string) => string | undefined;
779
+ transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
811
780
  /**
812
- * Writes a file to the virtual file system (VFS).
781
+ * A hook that is called to load the source code.
813
782
  *
814
- * @param path - The path to the file.
815
- * @param data - The contents of the file.
816
- * @param options - Optional parameters for writing the file.
817
- * @returns A promise that resolves when the file is written.
783
+ * @param this - The build context, unplugin build context, and unplugin context.
784
+ * @param id - The identifier of the source code.
785
+ * @returns A promise that resolves when the hook is complete.
818
786
  */
819
- writeFile: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => Promise<void>;
787
+ load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
820
788
  /**
821
- * Writes a file to the virtual file system (VFS).
789
+ * A hook that is called to resolve the identifier of the source code.
822
790
  *
823
- * @param path - The path to the file.
824
- * @param data - The contents of the file.
825
- * @param options - Optional parameters for writing the file.
791
+ * @param this - The build context, unplugin build context, and unplugin context.
792
+ * @param id - The identifier of the source code.
793
+ * @param importer - The importer of the source code.
794
+ * @param options - The options for resolving the identifier.
795
+ * @returns A promise that resolves when the hook is complete.
826
796
  */
827
- writeFileSync: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => void;
797
+ resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
798
+ isEntry: boolean;
799
+ }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
828
800
  /**
829
- * Moves a file from one path to another in the virtual file system (VFS).
801
+ * An API object that can be used for inter-plugin communication.
830
802
  *
831
- * @param srcPath - The source path to move
832
- * @param destPath - The destination path to move to
803
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
833
804
  */
834
- move: (srcPath: string, destPath: string) => Promise<void>;
805
+ api?: Record<string, any>;
806
+ };
807
+ type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = {
808
+ [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant>;
809
+ };
810
+ interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
835
811
  /**
836
- * Synchronously moves a file from one path to another in the virtual file system (VFS).
837
- *
838
- * @param srcPath - The source path to move
839
- * @param destPath - The destination path to move to
812
+ * The name of the plugin, for use in deduplication, error messages and logs.
840
813
  */
841
- moveSync: (srcPath: string, destPath: string) => void;
814
+ name: string;
842
815
  /**
843
- * Copies a file from one path to another in the virtual file system (VFS).
816
+ * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
844
817
  *
845
- * @param srcPath - The source path to copy
846
- * @param destPath - The destination path to copy to
818
+ * @remarks
819
+ * The Plugin invocation order is as follows:
820
+ * - `enforce: 'pre'` plugins
821
+ * - `order: 'pre'` plugin hooks
822
+ * - any other plugins (normal)
823
+ * - `order: 'post'` plugin hooks
824
+ * - `enforce: 'post'` plugins
825
+ *
826
+ * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
827
+ * @see https://rollupjs.org/plugin-development/#build-hooks
828
+ * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
829
+ * @see https://esbuild.github.io/plugins/#concepts
847
830
  */
848
- copy: (srcPath: string, destPath: string) => Promise<void>;
831
+ enforce?: "pre" | "post";
849
832
  /**
850
- * Synchronously copies a file from one path to another in the virtual file system (VFS).
833
+ * A function to determine if two plugins are the same and can be de-duplicated.
851
834
  *
852
- * @param srcPath - The source path to copy
853
- * @param destPath - The destination path to copy to
835
+ * @remarks
836
+ * If this is not provided, plugins are de-duplicated by comparing their names.
837
+ *
838
+ * @param other - The other plugin to compare against.
839
+ * @returns `true` if the two plugins are the same, `false` otherwise.
854
840
  */
855
- copySync: (srcPath: string, destPath: string) => void;
841
+ dedupe?: false | ((other: Plugin<any>) => boolean);
856
842
  /**
857
- * Glob files in the virtual file system (VFS) based on the provided pattern(s).
858
- *
859
- * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
860
- * @returns An array of file paths matching the provided pattern(s)
843
+ * A list of pre-requisite plugins that must be loaded before this plugin can be used.
861
844
  */
862
- glob: (pattern: string | string[]) => Promise<string[]>;
845
+ dependsOn?: PluginConfig<any>[];
863
846
  /**
864
- * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
847
+ * Define environments where this plugin should be active. By default, the plugin is active in all environments.
865
848
  *
866
- * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
867
- * @returns An array of file paths matching the provided pattern(s)
849
+ * @param environment - The environment to check.
850
+ * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
868
851
  */
869
- globSync: (pattern: string | string[]) => string[];
852
+ applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | Plugin<any>>;
853
+ }
854
+
855
+ type ReflectionMode = "default" | "explicit" | "never";
856
+ type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
857
+ /**
858
+ * Defines the level of reflection to be used during the transpilation process.
859
+ *
860
+ * @remarks
861
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
862
+ * - `minimal` - Only the essential type information is captured.
863
+ * - `normal` - Additional type information is captured, including some contextual data.
864
+ * - `verbose` - All available type information is captured, including detailed contextual data.
865
+ */
866
+ type ReflectionLevel = "minimal" | "normal" | "verbose";
867
+ interface DeepkitOptions {
870
868
  /**
871
- * Resolves a path or id to a file path in the virtual file system.
872
- *
873
- * @param pathOrId - The path or id of the file to resolve.
874
- * @param options - Optional parameters for resolving the path.
875
- * @returns The resolved path of the file if it exists, otherwise false.
869
+ * Either true to activate reflection for all files compiled using this tsconfig,
870
+ * or a list of globs/file paths relative to this tsconfig.json.
871
+ * Globs/file paths can be prefixed with a ! to exclude them.
876
872
  */
877
- resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;
873
+ reflection?: RawReflectionMode;
878
874
  /**
879
- * Formats a path to match the virtual file system (VFS) structure.
875
+ * Defines the level of reflection to be used during the transpilation process.
880
876
  *
881
- * @param path - The path to format.
882
- * @returns The formatted path.
877
+ * @remarks
878
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
879
+ * - `minimal` - Only the essential type information is captured.
880
+ * - `normal` - Additional type information is captured, including some contextual data.
881
+ * - `verbose` - All available type information is captured, including detailed contextual data.
883
882
  */
884
- formatPath: (path: string) => string;
883
+ reflectionLevel?: ReflectionLevel;
884
+ }
885
+ type TSCompilerOptions = CompilerOptions & DeepkitOptions;
886
+ /**
887
+ * The TypeScript compiler configuration.
888
+ *
889
+ * @see https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
890
+ */
891
+ interface TSConfig extends Omit<TsConfigJson, "reflection"> {
885
892
  /**
886
- * Resolves a path or id to a file path in the virtual file system.
893
+ * Either true to activate reflection for all files compiled using this tsconfig,
894
+ * or a list of globs/file paths relative to this tsconfig.json.
895
+ * Globs/file paths can be prefixed with a ! to exclude them.
896
+ */
897
+ reflection?: RawReflectionMode;
898
+ /**
899
+ * Defines the level of reflection to be used during the transpilation process.
887
900
  *
888
- * @param pathOrId - The path or id of the file to resolve.
889
- * @returns The resolved path of the file if it exists, otherwise false.
901
+ * @remarks
902
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
903
+ * - `minimal` - Only the essential type information is captured.
904
+ * - `normal` - Additional type information is captured, including some contextual data.
905
+ * - `verbose` - All available type information is captured, including detailed contextual data.
890
906
  */
891
- realpathSync: (pathOrId: string) => string;
907
+ reflectionLevel?: ReflectionLevel;
892
908
  /**
893
- * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
909
+ * Instructs the TypeScript compiler how to compile `.ts` files.
894
910
  */
895
- dispose: () => Promise<void>;
911
+ compilerOptions?: TSCompilerOptions;
896
912
  }
913
+ type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
914
+ originalTsconfigJson: TsConfigJson;
915
+ tsconfigJson: TSConfig;
916
+ tsconfigFilePath: string;
917
+ };
897
918
 
898
919
  type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
899
920
  /**
@@ -1371,7 +1392,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
1371
1392
  * @param path - An optional path to write the builtin file to
1372
1393
  * @param options - Options for writing the file
1373
1394
  */
1374
- writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1395
+ emitBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1375
1396
  /**
1376
1397
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1377
1398
  *
@@ -1379,11 +1400,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
1379
1400
  * @param path - An optional path to write the entry file to
1380
1401
  * @param options - Options for writing the file
1381
1402
  */
1382
- writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1383
- /**
1384
- * Parses the source code and returns a {@link ParseResult} object.
1385
- */
1386
- parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
1403
+ emitEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1387
1404
  /**
1388
1405
  * A function to update the context fields using a new user configuration options
1389
1406
  */