@powerlines/core 0.0.8

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 (286) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1 -0
  3. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  4. package/dist/index.cjs +65 -0
  5. package/dist/index.d.cts +23 -0
  6. package/dist/index.d.mts +25 -0
  7. package/dist/index.mjs +22 -0
  8. package/dist/lib/config.cjs +90 -0
  9. package/dist/lib/config.cjs.map +1 -0
  10. package/dist/lib/config.d.cts +40 -0
  11. package/dist/lib/config.d.cts.map +1 -0
  12. package/dist/lib/config.d.mts +40 -0
  13. package/dist/lib/config.d.mts.map +1 -0
  14. package/dist/lib/config.mjs +86 -0
  15. package/dist/lib/config.mjs.map +1 -0
  16. package/dist/lib/constants/environments.cjs +17 -0
  17. package/dist/lib/constants/environments.cjs.map +1 -0
  18. package/dist/lib/constants/environments.d.cts +10 -0
  19. package/dist/lib/constants/environments.d.cts.map +1 -0
  20. package/dist/lib/constants/environments.d.mts +10 -0
  21. package/dist/lib/constants/environments.d.mts.map +1 -0
  22. package/dist/lib/constants/environments.mjs +11 -0
  23. package/dist/lib/constants/environments.mjs.map +1 -0
  24. package/dist/lib/constants/index.cjs +11 -0
  25. package/dist/lib/constants/index.d.cts +3 -0
  26. package/dist/lib/constants/index.d.mts +3 -0
  27. package/dist/lib/constants/index.mjs +4 -0
  28. package/dist/lib/constants/meta.cjs +9 -0
  29. package/dist/lib/constants/meta.cjs.map +1 -0
  30. package/dist/lib/constants/meta.d.cts +6 -0
  31. package/dist/lib/constants/meta.d.cts.map +1 -0
  32. package/dist/lib/constants/meta.d.mts +6 -0
  33. package/dist/lib/constants/meta.d.mts.map +1 -0
  34. package/dist/lib/constants/meta.mjs +7 -0
  35. package/dist/lib/constants/meta.mjs.map +1 -0
  36. package/dist/lib/entry.cjs +127 -0
  37. package/dist/lib/entry.cjs.map +1 -0
  38. package/dist/lib/entry.d.cts +47 -0
  39. package/dist/lib/entry.d.cts.map +1 -0
  40. package/dist/lib/entry.d.mts +48 -0
  41. package/dist/lib/entry.d.mts.map +1 -0
  42. package/dist/lib/entry.mjs +120 -0
  43. package/dist/lib/entry.mjs.map +1 -0
  44. package/dist/lib/index.cjs +50 -0
  45. package/dist/lib/index.d.cts +14 -0
  46. package/dist/lib/index.d.mts +16 -0
  47. package/dist/lib/index.mjs +17 -0
  48. package/dist/lib/logger.cjs +59 -0
  49. package/dist/lib/logger.cjs.map +1 -0
  50. package/dist/lib/logger.d.cts +23 -0
  51. package/dist/lib/logger.d.cts.map +1 -0
  52. package/dist/lib/logger.d.mts +24 -0
  53. package/dist/lib/logger.d.mts.map +1 -0
  54. package/dist/lib/logger.mjs +56 -0
  55. package/dist/lib/logger.mjs.map +1 -0
  56. package/dist/lib/unplugin/helpers.cjs +30 -0
  57. package/dist/lib/unplugin/helpers.cjs.map +1 -0
  58. package/dist/lib/unplugin/helpers.d.cts +24 -0
  59. package/dist/lib/unplugin/helpers.d.cts.map +1 -0
  60. package/dist/lib/unplugin/helpers.d.mts +24 -0
  61. package/dist/lib/unplugin/helpers.d.mts.map +1 -0
  62. package/dist/lib/unplugin/helpers.mjs +28 -0
  63. package/dist/lib/unplugin/helpers.mjs.map +1 -0
  64. package/dist/lib/unplugin/index.cjs +9 -0
  65. package/dist/lib/unplugin/index.d.cts +4 -0
  66. package/dist/lib/unplugin/index.d.mts +4 -0
  67. package/dist/lib/unplugin/index.mjs +5 -0
  68. package/dist/lib/unplugin/module-resolution.cjs +67 -0
  69. package/dist/lib/unplugin/module-resolution.cjs.map +1 -0
  70. package/dist/lib/unplugin/module-resolution.d.cts +21 -0
  71. package/dist/lib/unplugin/module-resolution.d.cts.map +1 -0
  72. package/dist/lib/unplugin/module-resolution.d.mts +21 -0
  73. package/dist/lib/unplugin/module-resolution.d.mts.map +1 -0
  74. package/dist/lib/unplugin/module-resolution.mjs +66 -0
  75. package/dist/lib/unplugin/module-resolution.mjs.map +1 -0
  76. package/dist/lib/unplugin/plugin.cjs +105 -0
  77. package/dist/lib/unplugin/plugin.cjs.map +1 -0
  78. package/dist/lib/unplugin/plugin.d.cts +22 -0
  79. package/dist/lib/unplugin/plugin.d.cts.map +1 -0
  80. package/dist/lib/unplugin/plugin.d.mts +22 -0
  81. package/dist/lib/unplugin/plugin.d.mts.map +1 -0
  82. package/dist/lib/unplugin/plugin.mjs +103 -0
  83. package/dist/lib/unplugin/plugin.mjs.map +1 -0
  84. package/dist/lib/utilities/file-header.cjs +24 -0
  85. package/dist/lib/utilities/file-header.cjs.map +1 -0
  86. package/dist/lib/utilities/file-header.d.cts +13 -0
  87. package/dist/lib/utilities/file-header.d.cts.map +1 -0
  88. package/dist/lib/utilities/file-header.d.mts +13 -0
  89. package/dist/lib/utilities/file-header.d.mts.map +1 -0
  90. package/dist/lib/utilities/file-header.mjs +22 -0
  91. package/dist/lib/utilities/file-header.mjs.map +1 -0
  92. package/dist/lib/utilities/format.cjs +49 -0
  93. package/dist/lib/utilities/format.cjs.map +1 -0
  94. package/dist/lib/utilities/format.d.cts +25 -0
  95. package/dist/lib/utilities/format.d.cts.map +1 -0
  96. package/dist/lib/utilities/format.d.mts +25 -0
  97. package/dist/lib/utilities/format.d.mts.map +1 -0
  98. package/dist/lib/utilities/format.mjs +47 -0
  99. package/dist/lib/utilities/format.mjs.map +1 -0
  100. package/dist/lib/utilities/index.cjs +15 -0
  101. package/dist/lib/utilities/index.d.cts +6 -0
  102. package/dist/lib/utilities/index.d.mts +6 -0
  103. package/dist/lib/utilities/index.mjs +7 -0
  104. package/dist/lib/utilities/source-file.cjs +50 -0
  105. package/dist/lib/utilities/source-file.cjs.map +1 -0
  106. package/dist/lib/utilities/source-file.d.cts +31 -0
  107. package/dist/lib/utilities/source-file.d.cts.map +1 -0
  108. package/dist/lib/utilities/source-file.d.mts +31 -0
  109. package/dist/lib/utilities/source-file.d.mts.map +1 -0
  110. package/dist/lib/utilities/source-file.mjs +46 -0
  111. package/dist/lib/utilities/source-file.mjs.map +1 -0
  112. package/dist/lib/utilities/source-map.cjs +57 -0
  113. package/dist/lib/utilities/source-map.cjs.map +1 -0
  114. package/dist/lib/utilities/source-map.d.cts +17 -0
  115. package/dist/lib/utilities/source-map.d.cts.map +1 -0
  116. package/dist/lib/utilities/source-map.d.mts +17 -0
  117. package/dist/lib/utilities/source-map.d.mts.map +1 -0
  118. package/dist/lib/utilities/source-map.mjs +55 -0
  119. package/dist/lib/utilities/source-map.mjs.map +1 -0
  120. package/dist/lib/utilities/write-file.cjs +29 -0
  121. package/dist/lib/utilities/write-file.cjs.map +1 -0
  122. package/dist/lib/utilities/write-file.d.cts +16 -0
  123. package/dist/lib/utilities/write-file.d.cts.map +1 -0
  124. package/dist/lib/utilities/write-file.d.mts +16 -0
  125. package/dist/lib/utilities/write-file.d.mts.map +1 -0
  126. package/dist/lib/utilities/write-file.mjs +28 -0
  127. package/dist/lib/utilities/write-file.mjs.map +1 -0
  128. package/dist/plugin-base.cjs +73 -0
  129. package/dist/plugin-base.cjs.map +1 -0
  130. package/dist/plugin-base.d.cts +27 -0
  131. package/dist/plugin-base.d.cts.map +1 -0
  132. package/dist/plugin-base.d.mts +27 -0
  133. package/dist/plugin-base.d.mts.map +1 -0
  134. package/dist/plugin-base.mjs +70 -0
  135. package/dist/plugin-base.mjs.map +1 -0
  136. package/dist/plugin-utils/build-helpers.cjs +36 -0
  137. package/dist/plugin-utils/build-helpers.cjs.map +1 -0
  138. package/dist/plugin-utils/build-helpers.d.cts +19 -0
  139. package/dist/plugin-utils/build-helpers.d.cts.map +1 -0
  140. package/dist/plugin-utils/build-helpers.d.mts +19 -0
  141. package/dist/plugin-utils/build-helpers.d.mts.map +1 -0
  142. package/dist/plugin-utils/build-helpers.mjs +35 -0
  143. package/dist/plugin-utils/build-helpers.mjs.map +1 -0
  144. package/dist/plugin-utils/context-helpers.cjs +50 -0
  145. package/dist/plugin-utils/context-helpers.cjs.map +1 -0
  146. package/dist/plugin-utils/context-helpers.d.cts +21 -0
  147. package/dist/plugin-utils/context-helpers.d.cts.map +1 -0
  148. package/dist/plugin-utils/context-helpers.d.mts +21 -0
  149. package/dist/plugin-utils/context-helpers.d.mts.map +1 -0
  150. package/dist/plugin-utils/context-helpers.mjs +48 -0
  151. package/dist/plugin-utils/context-helpers.mjs.map +1 -0
  152. package/dist/plugin-utils/extend.cjs +25 -0
  153. package/dist/plugin-utils/extend.cjs.map +1 -0
  154. package/dist/plugin-utils/extend.d.cts +20 -0
  155. package/dist/plugin-utils/extend.d.cts.map +1 -0
  156. package/dist/plugin-utils/extend.d.mts +20 -0
  157. package/dist/plugin-utils/extend.d.mts.map +1 -0
  158. package/dist/plugin-utils/extend.mjs +24 -0
  159. package/dist/plugin-utils/extend.mjs.map +1 -0
  160. package/dist/plugin-utils/format-package-json.cjs +20 -0
  161. package/dist/plugin-utils/format-package-json.cjs.map +1 -0
  162. package/dist/plugin-utils/format-package-json.d.cts +13 -0
  163. package/dist/plugin-utils/format-package-json.d.cts.map +1 -0
  164. package/dist/plugin-utils/format-package-json.d.mts +13 -0
  165. package/dist/plugin-utils/format-package-json.d.mts.map +1 -0
  166. package/dist/plugin-utils/format-package-json.mjs +19 -0
  167. package/dist/plugin-utils/format-package-json.mjs.map +1 -0
  168. package/dist/plugin-utils/get-config-path.cjs +50 -0
  169. package/dist/plugin-utils/get-config-path.cjs.map +1 -0
  170. package/dist/plugin-utils/get-config-path.d.cts +15 -0
  171. package/dist/plugin-utils/get-config-path.d.cts.map +1 -0
  172. package/dist/plugin-utils/get-config-path.d.mts +15 -0
  173. package/dist/plugin-utils/get-config-path.d.mts.map +1 -0
  174. package/dist/plugin-utils/get-config-path.mjs +49 -0
  175. package/dist/plugin-utils/get-config-path.mjs.map +1 -0
  176. package/dist/plugin-utils/helpers.cjs +185 -0
  177. package/dist/plugin-utils/helpers.cjs.map +1 -0
  178. package/dist/plugin-utils/helpers.d.cts +144 -0
  179. package/dist/plugin-utils/helpers.d.cts.map +1 -0
  180. package/dist/plugin-utils/helpers.d.mts +144 -0
  181. package/dist/plugin-utils/helpers.d.mts.map +1 -0
  182. package/dist/plugin-utils/helpers.mjs +170 -0
  183. package/dist/plugin-utils/helpers.mjs.map +1 -0
  184. package/dist/plugin-utils/index.cjs +35 -0
  185. package/dist/plugin-utils/index.d.cts +10 -0
  186. package/dist/plugin-utils/index.d.mts +10 -0
  187. package/dist/plugin-utils/index.mjs +11 -0
  188. package/dist/plugin-utils/merge.cjs +60 -0
  189. package/dist/plugin-utils/merge.cjs.map +1 -0
  190. package/dist/plugin-utils/merge.d.cts +35 -0
  191. package/dist/plugin-utils/merge.d.cts.map +1 -0
  192. package/dist/plugin-utils/merge.d.mts +35 -0
  193. package/dist/plugin-utils/merge.d.mts.map +1 -0
  194. package/dist/plugin-utils/merge.mjs +57 -0
  195. package/dist/plugin-utils/merge.mjs.map +1 -0
  196. package/dist/plugin-utils/modules.cjs +17 -0
  197. package/dist/plugin-utils/modules.cjs.map +1 -0
  198. package/dist/plugin-utils/modules.d.cts +15 -0
  199. package/dist/plugin-utils/modules.d.cts.map +1 -0
  200. package/dist/plugin-utils/modules.d.mts +15 -0
  201. package/dist/plugin-utils/modules.d.mts.map +1 -0
  202. package/dist/plugin-utils/modules.mjs +16 -0
  203. package/dist/plugin-utils/modules.mjs.map +1 -0
  204. package/dist/plugin-utils/paths.cjs +38 -0
  205. package/dist/plugin-utils/paths.cjs.map +1 -0
  206. package/dist/plugin-utils/paths.d.cts +34 -0
  207. package/dist/plugin-utils/paths.d.cts.map +1 -0
  208. package/dist/plugin-utils/paths.d.mts +34 -0
  209. package/dist/plugin-utils/paths.d.mts.map +1 -0
  210. package/dist/plugin-utils/paths.mjs +37 -0
  211. package/dist/plugin-utils/paths.mjs.map +1 -0
  212. package/dist/types/_internal.cjs +0 -0
  213. package/dist/types/_internal.d.cts +107 -0
  214. package/dist/types/_internal.d.cts.map +1 -0
  215. package/dist/types/_internal.d.mts +107 -0
  216. package/dist/types/_internal.d.mts.map +1 -0
  217. package/dist/types/_internal.mjs +1 -0
  218. package/dist/types/api.cjs +0 -0
  219. package/dist/types/api.d.cts +104 -0
  220. package/dist/types/api.d.cts.map +1 -0
  221. package/dist/types/api.d.mts +104 -0
  222. package/dist/types/api.d.mts.map +1 -0
  223. package/dist/types/api.mjs +1 -0
  224. package/dist/types/commands.cjs +17 -0
  225. package/dist/types/commands.cjs.map +1 -0
  226. package/dist/types/commands.d.cts +13 -0
  227. package/dist/types/commands.d.cts.map +1 -0
  228. package/dist/types/commands.d.mts +13 -0
  229. package/dist/types/commands.d.mts.map +1 -0
  230. package/dist/types/commands.mjs +16 -0
  231. package/dist/types/commands.mjs.map +1 -0
  232. package/dist/types/config.cjs +0 -0
  233. package/dist/types/config.d.cts +617 -0
  234. package/dist/types/config.d.cts.map +1 -0
  235. package/dist/types/config.d.mts +617 -0
  236. package/dist/types/config.d.mts.map +1 -0
  237. package/dist/types/config.mjs +1 -0
  238. package/dist/types/context.cjs +0 -0
  239. package/dist/types/context.d.cts +564 -0
  240. package/dist/types/context.d.cts.map +1 -0
  241. package/dist/types/context.d.mts +564 -0
  242. package/dist/types/context.d.mts.map +1 -0
  243. package/dist/types/context.mjs +1 -0
  244. package/dist/types/fs.cjs +11 -0
  245. package/dist/types/fs.cjs.map +1 -0
  246. package/dist/types/fs.d.cts +502 -0
  247. package/dist/types/fs.d.cts.map +1 -0
  248. package/dist/types/fs.d.mts +502 -0
  249. package/dist/types/fs.d.mts.map +1 -0
  250. package/dist/types/fs.mjs +8 -0
  251. package/dist/types/fs.mjs.map +1 -0
  252. package/dist/types/hooks.cjs +13 -0
  253. package/dist/types/hooks.cjs.map +1 -0
  254. package/dist/types/hooks.d.cts +117 -0
  255. package/dist/types/hooks.d.cts.map +1 -0
  256. package/dist/types/hooks.d.mts +117 -0
  257. package/dist/types/hooks.d.mts.map +1 -0
  258. package/dist/types/hooks.mjs +12 -0
  259. package/dist/types/hooks.mjs.map +1 -0
  260. package/dist/types/index.cjs +16 -0
  261. package/dist/types/index.d.cts +10 -0
  262. package/dist/types/index.d.mts +10 -0
  263. package/dist/types/index.mjs +7 -0
  264. package/dist/types/plugin.cjs +35 -0
  265. package/dist/types/plugin.cjs.map +1 -0
  266. package/dist/types/plugin.d.cts +218 -0
  267. package/dist/types/plugin.d.cts.map +1 -0
  268. package/dist/types/plugin.d.mts +218 -0
  269. package/dist/types/plugin.d.mts.map +1 -0
  270. package/dist/types/plugin.mjs +33 -0
  271. package/dist/types/plugin.mjs.map +1 -0
  272. package/dist/types/tsconfig.cjs +0 -0
  273. package/dist/types/tsconfig.d.cts +77 -0
  274. package/dist/types/tsconfig.d.cts.map +1 -0
  275. package/dist/types/tsconfig.d.mts +77 -0
  276. package/dist/types/tsconfig.d.mts.map +1 -0
  277. package/dist/types/tsconfig.mjs +1 -0
  278. package/dist/types/unplugin.cjs +24 -0
  279. package/dist/types/unplugin.cjs.map +1 -0
  280. package/dist/types/unplugin.d.cts +41 -0
  281. package/dist/types/unplugin.d.cts.map +1 -0
  282. package/dist/types/unplugin.d.mts +41 -0
  283. package/dist/types/unplugin.d.mts.map +1 -0
  284. package/dist/types/unplugin.mjs +22 -0
  285. package/dist/types/unplugin.mjs.map +1 -0
  286. package/package.json +238 -0
@@ -0,0 +1,564 @@
1
+ import { ResolveOptions, VirtualFile, VirtualFileSystemInterface, WriteOptions } from "./fs.mjs";
2
+ import { Plugin } from "./plugin.mjs";
3
+ import { HooksList, InferHooksListItem } from "./hooks.mjs";
4
+ import { ParsedTypeScriptConfig } from "./tsconfig.mjs";
5
+ import { EnvironmentResolvedConfig, InlineConfig, LogFn, ResolvedConfig, ResolvedEntryTypeDefinition, UserConfig, WorkspaceConfig } from "./config.mjs";
6
+ import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
7
+ import MagicString, { SourceMap } from "magic-string";
8
+ import { Jiti } from "jiti";
9
+ import { EnvPaths } from "@stryke/env/get-env-paths";
10
+ import { FetchRequestOptions } from "@stryke/http/fetch";
11
+ import { PackageJson } from "@stryke/types/package-json";
12
+ import { Worker } from "jest-worker";
13
+ import { ParseResult, ParserOptions } from "oxc-parser";
14
+ import { Range } from "semver";
15
+ import { RequestInfo, Response } from "undici";
16
+ import { Unimport } from "unimport";
17
+
18
+ //#region src/types/context.d.ts
19
+ type WorkerProcess<TExposedMethods extends ReadonlyArray<string>> = { [K in TExposedMethods[number]]: (data: any) => Promise<any> } & {
20
+ close: () => void;
21
+ end: () => ReturnType<Worker["end"]>;
22
+ };
23
+ interface MetaInfo {
24
+ /**
25
+ * The checksum generated from the resolved options
26
+ */
27
+ checksum: string;
28
+ /**
29
+ * The build id
30
+ */
31
+ buildId: string;
32
+ /**
33
+ * The release id
34
+ */
35
+ releaseId: string;
36
+ /**
37
+ * The build timestamp
38
+ */
39
+ timestamp: number;
40
+ /**
41
+ * A hash that represents the path to the project root directory
42
+ */
43
+ rootHash: string;
44
+ /**
45
+ * A hash that represents the path to the configuration root directory
46
+ */
47
+ configHash: string;
48
+ }
49
+ interface Resolver extends Jiti {
50
+ plugin: Jiti;
51
+ }
52
+ interface TransformResult {
53
+ code: string;
54
+ map: SourceMap | null;
55
+ }
56
+ /**
57
+ * The format for providing source code to the compiler
58
+ */
59
+ interface SourceFile {
60
+ /**
61
+ * The name of the file to be compiled
62
+ */
63
+ id: string;
64
+ /**
65
+ * The source code to be compiled
66
+ */
67
+ code: MagicString;
68
+ /**
69
+ * The environment variables used in the source code
70
+ */
71
+ env: string[];
72
+ /**
73
+ * The result of the transformation
74
+ */
75
+ result?: TransformResult;
76
+ }
77
+ type UnimportContext = Omit<Unimport, "injectImports"> & {
78
+ dumpImports: () => Promise<void>;
79
+ injectImports: (source: SourceFile) => Promise<SourceFile>;
80
+ refreshRuntimeImports: () => Promise<void>;
81
+ };
82
+ interface SelectHooksOptions {
83
+ order?: "pre" | "post" | "normal";
84
+ }
85
+ /**
86
+ * Options for initializing or updating the context with new configuration values
87
+ */
88
+ interface InitContextOptions {
89
+ /**
90
+ * If false, the plugin will be loaded after all other plugins.
91
+ *
92
+ * @defaultValue true
93
+ */
94
+ isHighPriority: boolean;
95
+ }
96
+ /**
97
+ * Options for fetch requests made via the context's {@link Context.fetch} method
98
+ */
99
+ interface FetchOptions extends FetchRequestOptions {
100
+ /**
101
+ * An indicator specifying that the request should bypass any caching
102
+ */
103
+ skipCache?: boolean;
104
+ }
105
+ /**
106
+ * Options for parsing code using [Oxc-Parser](https://github.com/oxc/oxc)
107
+ */
108
+ interface ParseOptions extends ParserOptions {
109
+ /**
110
+ * When true this allows return statements to be outside functions to e.g. support parsing CommonJS code.
111
+ */
112
+ allowReturnOutsideFunction?: boolean;
113
+ }
114
+ interface EmitOptions extends WriteOptions {
115
+ /**
116
+ * The file extension to use when emitting the file
117
+ */
118
+ extension?: string;
119
+ /**
120
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
121
+ */
122
+ emitWithBundler?: boolean;
123
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
124
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
125
+ }
126
+ /**
127
+ * Options for emitting entry virtual files
128
+ */
129
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
130
+ /**
131
+ * The unresolved Powerlines context.
132
+ *
133
+ * @remarks
134
+ * This context is used before the user configuration has been fully resolved after the `config`.
135
+ */
136
+ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
137
+ /**
138
+ * The Storm workspace configuration
139
+ */
140
+ workspaceConfig: WorkspaceConfig;
141
+ /**
142
+ * An object containing the options provided to Powerlines
143
+ */
144
+ config: Omit<TResolvedConfig["userConfig"], "output"> & Required<Pick<TResolvedConfig["userConfig"], "output">> & {
145
+ output: TResolvedConfig["output"];
146
+ };
147
+ /**
148
+ * A logging function for the Powerlines engine
149
+ */
150
+ log: LogFn;
151
+ /**
152
+ * A logging function for fatal messages
153
+ */
154
+ fatal: (message: string | UnpluginMessage) => void;
155
+ /**
156
+ * A logging function for error messages
157
+ */
158
+ error: (message: string | UnpluginMessage) => void;
159
+ /**
160
+ * A logging function for warning messages
161
+ */
162
+ warn: (message: string | UnpluginMessage) => void;
163
+ /**
164
+ * A logging function for informational messages
165
+ */
166
+ info: (message: string | UnpluginMessage) => void;
167
+ /**
168
+ * A logging function for debug messages
169
+ */
170
+ debug: (message: string | UnpluginMessage) => void;
171
+ /**
172
+ * A logging function for trace messages
173
+ */
174
+ trace: (message: string | UnpluginMessage) => void;
175
+ /**
176
+ * The metadata information
177
+ */
178
+ meta: MetaInfo;
179
+ /**
180
+ * The metadata information currently written to disk
181
+ */
182
+ persistedMeta?: MetaInfo;
183
+ /**
184
+ * The Powerlines artifacts directory
185
+ */
186
+ artifactsPath: string;
187
+ /**
188
+ * The path to the Powerlines builtin runtime modules directory
189
+ */
190
+ builtinsPath: string;
191
+ /**
192
+ * The path to the Powerlines entry modules directory
193
+ */
194
+ entryPath: string;
195
+ /**
196
+ * The path to the Powerlines TypeScript declaration files directory
197
+ */
198
+ dtsPath: string;
199
+ /**
200
+ * The path to a directory where the reflection data buffers (used by the build processes) are stored
201
+ */
202
+ dataPath: string;
203
+ /**
204
+ * The path to a directory where the project cache (used by the build processes) is stored
205
+ */
206
+ cachePath: string;
207
+ /**
208
+ * The Powerlines environment paths
209
+ */
210
+ envPaths: EnvPaths;
211
+ /**
212
+ * The file system path to the Powerlines package installation
213
+ */
214
+ powerlinesPath: string;
215
+ /**
216
+ * The relative path to the Powerlines workspace root directory
217
+ */
218
+ relativeToWorkspaceRoot: string;
219
+ /**
220
+ * The project's `package.json` file content
221
+ */
222
+ packageJson: PackageJson & Record<string, any>;
223
+ /**
224
+ * The project's `project.json` file content
225
+ */
226
+ projectJson?: Record<string, any>;
227
+ /**
228
+ * The dependency installations required by the project
229
+ */
230
+ dependencies: Record<string, string | Range>;
231
+ /**
232
+ * The development dependency installations required by the project
233
+ */
234
+ devDependencies: Record<string, string | Range>;
235
+ /**
236
+ * The parsed TypeScript configuration from the `tsconfig.json` file
237
+ */
238
+ tsconfig: ParsedTypeScriptConfig;
239
+ /**
240
+ * The entry points of the source code
241
+ */
242
+ entry: ResolvedEntryTypeDefinition[];
243
+ /**
244
+ * The virtual file system manager used during the build process to reference generated runtime files
245
+ */
246
+ fs: VirtualFileSystemInterface;
247
+ /**
248
+ * The Jiti module resolver
249
+ */
250
+ resolver: Resolver;
251
+ /**
252
+ * The builtin module id that exist in the Powerlines virtual file system
253
+ */
254
+ builtins: string[];
255
+ /**
256
+ * The alias mappings for the project used during module resolution
257
+ *
258
+ * @remarks
259
+ * This includes both the built-in module aliases as well as any custom aliases defined in the build configuration.
260
+ */
261
+ alias: Record<string, string>;
262
+ /**
263
+ * A function to perform HTTP fetch requests
264
+ *
265
+ * @remarks
266
+ * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * const response = await context.fetch("https://api.example.com/data");
271
+ * const data = await response.json();
272
+ * ```
273
+ *
274
+ * @see https://github.com/nodejs/undici
275
+ *
276
+ * @param input - The URL to fetch.
277
+ * @param options - The fetch request options.
278
+ * @returns A promise that resolves to a response returned by the fetch.
279
+ */
280
+ fetch: (input: RequestInfo, options?: FetchOptions) => Promise<Response>;
281
+ /**
282
+ * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
283
+ *
284
+ * @remarks
285
+ * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
286
+ *
287
+ * @example
288
+ * ```ts
289
+ * const ast = context.parse("const x: number = 42;");
290
+ * ```
291
+ *
292
+ * @see https://rollupjs.org/plugin-development/#this-parse
293
+ * @see https://github.com/oxc/oxc
294
+ *
295
+ * @param code - The source code to parse.
296
+ * @param options - The options to pass to the parser.
297
+ * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
298
+ */
299
+ parse: (code: string, options?: ParseOptions) => Promise<ParseResult>;
300
+ /**
301
+ * A helper function to resolve modules using the Jiti resolver
302
+ *
303
+ * @remarks
304
+ * This function can be used to resolve modules relative to the project root directory.
305
+ *
306
+ * @example
307
+ * ```ts
308
+ * const resolvedPath = await context.resolve("some-module", "/path/to/importer");
309
+ * ```
310
+ *
311
+ * @param id - The module to resolve.
312
+ * @param importer - An optional path to the importer module.
313
+ * @param options - Additional resolution options.
314
+ * @returns A promise that resolves to the resolved module path.
315
+ */
316
+ resolve: (id: string, importer?: string, options?: ResolveOptions) => Promise<ExternalIdResult | undefined>;
317
+ /**
318
+ * A helper function to load modules using the Jiti resolver
319
+ *
320
+ * @remarks
321
+ * This function can be used to load modules relative to the project root directory.
322
+ *
323
+ * @example
324
+ * ```ts
325
+ * const module = await context.load("some-module", "/path/to/importer");
326
+ * ```
327
+ *
328
+ * @param id - The module to load.
329
+ * @returns A promise that resolves to the loaded module.
330
+ */
331
+ load: (id: string) => Promise<TransformResult | undefined>;
332
+ /**
333
+ * The Powerlines builtin virtual files
334
+ */
335
+ getBuiltins: () => Promise<VirtualFile[]>;
336
+ /**
337
+ * Resolves a file and writes it to the VFS if it does not already exist
338
+ *
339
+ * @param code - The source code of the file
340
+ * @param path - The path to write the file to
341
+ * @param options - Additional options for writing the file
342
+ */
343
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
344
+ /**
345
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
346
+ *
347
+ * @param code - The source code of the file
348
+ * @param path - The path to write the file to
349
+ * @param options - Additional options for writing the file
350
+ */
351
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
352
+ /**
353
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
354
+ *
355
+ * @param code - The source code of the builtin file
356
+ * @param id - The unique identifier of the builtin file
357
+ * @param options - Additional options for writing the builtin file
358
+ */
359
+ emitBuiltin: (code: string, id: string, options?: EmitOptions) => Promise<void>;
360
+ /**
361
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
362
+ *
363
+ * @param code - The source code of the builtin file
364
+ * @param id - The unique identifier of the builtin file
365
+ * @param options - Additional options for writing the builtin file
366
+ */
367
+ emitBuiltinSync: (code: string, id: string, options?: EmitOptions) => void;
368
+ /**
369
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
370
+ *
371
+ * @param code - The source code of the entry file
372
+ * @param path - An optional path to write the entry file to
373
+ * @param options - Additional options for writing the entry file
374
+ */
375
+ emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
376
+ /**
377
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
378
+ *
379
+ * @param code - The source code of the entry file
380
+ * @param path - An optional path to write the entry file to
381
+ * @param options - Additional options for writing the entry file
382
+ */
383
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
384
+ /**
385
+ * A function to update the context fields using a new user configuration options
386
+ */
387
+ withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
388
+ /**
389
+ * A function to update the context fields using inline configuration options
390
+ */
391
+ withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
392
+ /**
393
+ * Create a new logger instance
394
+ *
395
+ * @param name - The name to use for the logger instance
396
+ * @returns A logger function
397
+ */
398
+ createLog: (name: string | null) => LogFn;
399
+ /**
400
+ * Extend the current logger instance with a new name
401
+ *
402
+ * @param name - The name to use for the extended logger instance
403
+ * @returns A logger function
404
+ */
405
+ extendLog: (name: string) => LogFn;
406
+ /**
407
+ * Generates a checksum representing the current context state
408
+ *
409
+ * @returns A promise that resolves to a string representing the checksum
410
+ */
411
+ generateChecksum: () => Promise<string>;
412
+ }
413
+ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
414
+ /**
415
+ * The fully resolved Powerlines configuration
416
+ */
417
+ config: TResolvedConfig;
418
+ };
419
+ interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
420
+ /**
421
+ * The expected plugins options for the Powerlines project.
422
+ *
423
+ * @remarks
424
+ * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
425
+ */
426
+ plugins: Plugin<PluginContext<TResolvedConfig>>[];
427
+ /**
428
+ * A function to add a plugin to the context and update the configuration options
429
+ */
430
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
431
+ /**
432
+ * A table for storing the current context for each configured environment
433
+ */
434
+ environments: Record<string, EnvironmentContext<TResolvedConfig>>;
435
+ /**
436
+ * Retrieves the context for a specific environment by name
437
+ *
438
+ * @throws Will throw an error if the environment does not exist
439
+ *
440
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
441
+ * @returns A promise that resolves to the environment context.
442
+ *
443
+ * @example
444
+ * ```ts
445
+ * const devEnv = await apiContext.getEnvironment("development");
446
+ * const defaultEnv = await apiContext.getEnvironment();
447
+ * ```
448
+ */
449
+ getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
450
+ /**
451
+ * Safely retrieves the context for a specific environment by name
452
+ *
453
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
454
+ * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
455
+ *
456
+ * @example
457
+ * ```ts
458
+ * const devEnv = await apiContext.getEnvironmentSafe("development");
459
+ * const defaultEnv = await apiContext.getEnvironmentSafe();
460
+ * ```
461
+ *
462
+ * @remarks
463
+ * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
464
+ * This can be useful in scenarios where the existence of an environment is optional or uncertain.
465
+ *
466
+ * ```ts
467
+ * const testEnv = await apiContext.getEnvironmentSafe("test");
468
+ * if (testEnv) {
469
+ * // Environment exists, safe to use it
470
+ * } else {
471
+ * // Environment does not exist, handle accordingly
472
+ * }
473
+ * ```
474
+ *
475
+ * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
476
+ */
477
+ getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
478
+ /**
479
+ * A function to copy the context and update the fields for a specific environment
480
+ *
481
+ * @param environment - The environment configuration to use.
482
+ * @returns A new context instance with the updated environment.
483
+ */
484
+ in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
485
+ /**
486
+ * A function to merge all configured environments into a single context
487
+ *
488
+ * @returns A promise that resolves to the merged environment context.
489
+ */
490
+ toEnvironment: () => Promise<EnvironmentContext<TResolvedConfig>>;
491
+ }
492
+ interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
493
+ plugin: Plugin<PluginContext<TResolvedConfig>>;
494
+ context: PluginContext<TResolvedConfig>;
495
+ }
496
+ type SelectHookResultItem<TContext extends PluginContext, TKey extends string> = InferHooksListItem<TContext, TKey> & {
497
+ context: TContext;
498
+ };
499
+ type SelectHookResult<TContext extends PluginContext, TKey extends string> = SelectHookResultItem<TContext, TKey>[];
500
+ interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
501
+ /**
502
+ * The expected plugins options for the Powerlines project.
503
+ *
504
+ * @remarks
505
+ * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
506
+ */
507
+ plugins: EnvironmentContextPlugin<TResolvedConfig>[];
508
+ /**
509
+ * A function to add a plugin to the context and update the configuration options
510
+ */
511
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
512
+ /**
513
+ * The environment specific resolved configuration
514
+ */
515
+ environment: EnvironmentResolvedConfig;
516
+ /**
517
+ * A table holding references to hook functions registered by plugins
518
+ */
519
+ hooks: HooksList<PluginContext<TResolvedConfig>>;
520
+ /**
521
+ * Retrieves the hook handlers for a specific hook name
522
+ */
523
+ selectHooks: <TKey extends string>(key: TKey, options?: SelectHooksOptions) => SelectHookResult<PluginContext<TResolvedConfig>, TKey>;
524
+ }
525
+ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
526
+ /**
527
+ * The environment specific resolved configuration
528
+ */
529
+ environment: EnvironmentResolvedConfig;
530
+ /**
531
+ * An alternative property name for the {@link log} property
532
+ *
533
+ * @remarks
534
+ * This is provided for compatibility with other logging libraries that expect a `logger` property.
535
+ */
536
+ logger: LogFn;
537
+ }
538
+ type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
539
+ type WithUnpluginBuildContext<TContext extends PluginContext> = UnpluginBuildContext & TContext;
540
+ declare type __ΩWorkerProcess = any[];
541
+ declare type __ΩMetaInfo = any[];
542
+ declare type __ΩResolver = any[];
543
+ declare type __ΩTransformResult = any[];
544
+ declare type __ΩSourceFile = any[];
545
+ declare type __ΩUnimportContext = any[];
546
+ declare type __ΩSelectHooksOptions = any[];
547
+ declare type __ΩInitContextOptions = any[];
548
+ declare type __ΩFetchOptions = any[];
549
+ declare type __ΩParseOptions = any[];
550
+ declare type __ΩEmitOptions = any[];
551
+ declare type __ΩEmitEntryOptions = any[];
552
+ declare type __ΩUnresolvedContext = any[];
553
+ declare type __ΩContext = any[];
554
+ declare type __ΩAPIContext = any[];
555
+ declare type __ΩEnvironmentContextPlugin = any[];
556
+ declare type __ΩSelectHookResultItem = any[];
557
+ declare type __ΩSelectHookResult = any[];
558
+ declare type __ΩEnvironmentContext = any[];
559
+ declare type __ΩPluginContext = any[];
560
+ declare type __ΩBuildPluginContext = any[];
561
+ declare type __ΩWithUnpluginBuildContext = any[];
562
+ //#endregion
563
+ export { APIContext, BuildPluginContext, Context, EmitEntryOptions, EmitOptions, EnvironmentContext, EnvironmentContextPlugin, FetchOptions, InitContextOptions, MetaInfo, ParseOptions, PluginContext, Resolver, SelectHookResult, SelectHookResultItem, SelectHooksOptions, SourceFile, TransformResult, UnimportContext, UnresolvedContext, WithUnpluginBuildContext, WorkerProcess, __ΩAPIContext, __ΩBuildPluginContext, __ΩContext, __ΩEmitEntryOptions, __ΩEmitOptions, __ΩEnvironmentContext, __ΩEnvironmentContextPlugin, __ΩFetchOptions, __ΩInitContextOptions, __ΩMetaInfo, __ΩParseOptions, __ΩPluginContext, __ΩResolver, __ΩSelectHookResult, __ΩSelectHookResultItem, __ΩSelectHooksOptions, __ΩSourceFile, __ΩTransformResult, __ΩUnimportContext, __ΩUnresolvedContext, __ΩWithUnpluginBuildContext, __ΩWorkerProcess };
564
+ //# sourceMappingURL=context.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.mts","names":[],"sources":["../../src/types/context.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;KAsDY,sCAAsC,iCAC1C,eADiB,CAAA,MAAA,CAAA,GAAA,CAAA,IAAA,EAAA,GAAA,EAAA,GACwB,OADxB,CAAA,GAAA,CAAA,EAAyB,GAAA;EAC1C,KAAA,EAAA,GAAA,GAAA,IAAA;EAAyC,GAAA,EAAA,GAAA,GAGpC,UAHoC,CAGzB,MAHyB,CAAA,KAAA,CAAA,CAAA;CAGzB;AAAX,UAGI,QAAA,CAHJ;EAAU;AAGvB;AAgCA;EAIiB,QAAA,EAAA,MAAA;EAQA;AAsBjB;;EAA8B,OAAA,EAAA,MAAA;EACT;;;EACoB,SAAA,EAAA,MAAA;EACV;;AAG/B;EAOiB,SAAA,EAAA,MAAA;EAYA;AAUjB;AAOA;EAYI,QAAA,EAAA,MAAA;EADmB;;;EAXc,UAAA,EAAA,MAAA;;AAuBzB,UAnGK,QAAA,SAAiB,IAmGN,CAAA;EAAG,MAAA,EAlGrB,IAkGqB;;AAC7B,UAhGe,eAAA,CAgGf;EAAI,IAAA,EAAA,MAAA;EAQW,GAAA,EAtGV,SAsGU,GAAA,IAAiB;;;;;AAWxB,UA3GO,UAAA,CA2GP;EACQ;;;EACJ,EAAA,EAAA,MAAA;EAMP;;;EAeoB,IAAA,EAzHn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vC,0CACa,iBAAiB,wBAErC,QAAQ,kBAAkB;;;;eAIrB;;;;;;;UAQL;;KAGE,2CACc,iBAAiB,kBACvC,uBAAuB,cAAc;KAE7B,0CAA0C,iBACpD,uBAAuB"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,11 @@
1
+
2
+ //#region src/types/fs.ts
3
+ const __VFS_PATCH__ = "__VFS_PATCH__";
4
+ const __VFS_REVERT__ = "__VFS_REVERT__";
5
+ const STORAGE_PRESETS = ["fs", "virtual"];
6
+
7
+ //#endregion
8
+ exports.STORAGE_PRESETS = STORAGE_PRESETS;
9
+ exports.__VFS_PATCH__ = __VFS_PATCH__;
10
+ exports.__VFS_REVERT__ = __VFS_REVERT__;
11
+ //# sourceMappingURL=fs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.cjs","names":["STORAGE_PRESETS: StoragePreset[]"],"sources":["../../src/types/fs.ts"],"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 { ResolveOptions as BaseResolveOptions } from \"@stryke/fs/resolve\";\nimport { MaybePromise } from \"@stryke/types/base\";\nimport { AssetGlob } from \"@stryke/types/file\";\n\nexport type VirtualFileExtension = \"js\" | \"ts\" | \"jsx\" | \"tsx\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_PATCH__ = \"__VFS_PATCH__\";\n\n// eslint-disable-next-line ts/naming-convention\nexport const __VFS_REVERT__ = \"__VFS_REVERT__\";\n\nexport type StoragePreset = \"fs\" | \"virtual\";\n\nexport const STORAGE_PRESETS: StoragePreset[] = [\"fs\", \"virtual\"];\n\n/**\n * Interface defining the methods and properties for a storage adapter.\n */\nexport interface StorageAdapter {\n /**\n * A name identifying the storage adapter type.\n */\n name: string;\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n preset?: StoragePreset | null;\n\n /**\n * Checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns A promise that resolves to `true` if the key exists, otherwise `false`.\n */\n exists: (key: string) => Promise<boolean>;\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n existsSync: (key: string) => boolean;\n\n /**\n * Read a value associated with a key from the storage.\n *\n * @param key - The key to read the value for.\n * @returns A promise that resolves to the value if found, otherwise `null`.\n */\n get: (key: string) => Promise<string | null>;\n\n /**\n * Synchronously reads the value associated with a key from the storage.\n *\n * @param key - The key to read the value for.\n * @returns The value if found, otherwise `null`.\n */\n getSync: (key: string) => string | null;\n\n /**\n * Writes a value to the storage for the given key.\n *\n * @param key - The key to associate the value with.\n * @param value - The value to store.\n */\n set: (key: string, value: string) => Promise<void>;\n\n /**\n * Synchronously writes a value to the storage for the given key.\n *\n * @param key - The key to associate the value with.\n * @param value - The value to store.\n */\n setSync: (key: string, value: string) => void;\n\n /**\n * Removes a value from the storage.\n *\n * @param key - The key whose value should be removed.\n */\n remove: (key: string) => Promise<void>;\n\n /**\n * Synchronously removes a value from the storage.\n *\n * @param key - The key whose value should be removed.\n */\n removeSync: (key: string) => void;\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n mkdir: (dirPath: string) => Promise<void>;\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n mkdirSync: (dirPath: string) => void;\n\n /**\n * Remove all entries from the storage that match the provided base path.\n *\n * @param base - The base path or prefix to clear entries from.\n */\n clear: (base?: string) => Promise<void>;\n\n /**\n * Synchronously remove all entries from the storage that match the provided base path.\n *\n * @param base - The base path or prefix to clear entries from.\n */\n clearSync: (base?: string) => void;\n\n /**\n * Lists all keys under the provided base path.\n *\n * @param base - The base path or prefix to list keys from.\n * @returns A promise resolving to the list of keys.\n */\n list: (base?: string) => Promise<string[]>;\n\n /**\n * Synchronously lists all keys under the provided base path.\n *\n * @param base - The base path or prefix to list keys from.\n * @returns The list of keys.\n */\n listSync: (base?: string) => string[];\n\n /**\n * Checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.\n */\n isDirectory: (key: string) => Promise<boolean>;\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n isDirectorySync: (key: string) => boolean;\n\n /**\n * Checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.\n */\n isFile: (key: string) => Promise<boolean>;\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n isFileSync: (key: string) => boolean;\n\n /**\n * Releases any resources held by the storage adapter.\n */\n dispose: () => MaybePromise<void>;\n}\n\n/**\n * A mapping of file paths to storage adapter names and their corresponding {@link StorageAdapter} instances.\n */\nexport type StoragePort = Record<string, StorageAdapter>;\n\nexport interface VirtualFileMetadata {\n /**\n * The identifier for the file data.\n */\n id: string;\n\n /**\n * The timestamp of the virtual file.\n */\n timestamp: number;\n\n /**\n * The type 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 type: string;\n\n /**\n * Additional metadata associated with the file.\n */\n properties: Record<string, string | undefined>;\n}\n\nexport interface VirtualFileData {\n /**\n * The identifier for the file data.\n */\n id?: string;\n\n /**\n * The contents of the virtual file.\n */\n code: string;\n\n /**\n * The type 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 type?: string;\n\n /**\n * Additional metadata associated with the file.\n */\n properties?: Record<string, string | undefined>;\n}\n\nexport interface VirtualFile\n extends Required<VirtualFileData>, VirtualFileMetadata {\n /**\n * An additional name for the file.\n */\n path: string;\n\n /**\n * The timestamp of the virtual file.\n */\n timestamp: number;\n}\n\nexport interface WriteOptions {\n /**\n * Should the file skip formatting before being written?\n *\n * @defaultValue false\n */\n skipFormat?: boolean;\n\n /**\n * The storage preset or adapter name for the output file.\n *\n * @remarks\n * If not specified, the output mode will be determined by the provided `output.mode` value.\n */\n storage?: StoragePreset | string;\n\n /**\n * Additional metadata for the file.\n */\n meta?: Partial<VirtualFileMetadata>;\n}\n\nexport type WriteData = string | NodeJS.ArrayBufferView | VirtualFileData;\n\nexport interface ResolveOptions extends BaseResolveOptions {\n /**\n * If true, the module is being resolved as an entry point.\n */\n isEntry?: boolean;\n\n /**\n * If true, the resolver will skip alias resolution when resolving modules.\n */\n skipAlias?: boolean;\n\n /**\n * If true, the resolver will skip using the cache when resolving modules.\n */\n skipCache?: boolean;\n\n /**\n * An array of external modules or patterns to exclude from resolution.\n */\n external?: (string | RegExp)[];\n\n /**\n * An array of modules or patterns to include in the resolution, even if they are marked as external.\n */\n noExternal?: (string | RegExp)[];\n\n /**\n * An array of patterns to match when resolving modules.\n */\n skipNodeModulesBundle?: boolean;\n}\n\nexport interface VirtualFileSystemInterface {\n /**\n * The underlying file metadata.\n */\n metadata: Readonly<Record<string, VirtualFileMetadata>>;\n\n /**\n * A map of file paths to their module ids.\n */\n ids: Readonly<Record<string, string>>;\n\n /**\n * A map of module ids to their file paths.\n */\n paths: Readonly<Record<string, string>>;\n\n /**\n * Checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path or id of the file.\n * @returns `true` if the file exists, otherwise `false`.\n */\n exists: (path: string) => Promise<boolean>;\n\n /**\n * Synchronously Checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path or id of the file.\n * @returns `true` if the file exists, otherwise `false`.\n */\n existsSync: (path: string) => boolean;\n\n /**\n * Checks if a file is virtual in the virtual file system (VFS).\n *\n * @param path - The path or id of the file.\n * @returns `true` if the file is virtual, otherwise `false`.\n */\n isVirtual: (path: string) => boolean;\n\n /**\n * Checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.\n */\n isDirectory: (key: string) => Promise<boolean>;\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n isDirectorySync: (key: string) => boolean;\n\n /**\n * Checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.\n */\n isFile: (key: string) => Promise<boolean>;\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n isFileSync: (key: string) => boolean;\n\n /**\n * Gets the metadata of a file in the virtual file system (VFS).\n *\n * @param path - The path or id of the file.\n * @returns The metadata of the file if it exists, otherwise undefined.\n */\n getMetadata: (path: string) => VirtualFileMetadata | undefined;\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n listSync: (path: string) => string[];\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n list: (path: string) => 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 removeSync: (path: string) => 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 remove: (path: string) => Promise<void>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param path - The path or id of the file.\n * @returns The contents of the file if it exists, otherwise undefined.\n */\n read: (path: string) => Promise<string | undefined>;\n\n /**\n * Reads a file from the virtual file system (VFS).\n *\n * @param path - The path or id of the file.\n */\n readSync: (path: 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 - Options for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n write: (path: string, data: string, options?: WriteOptions) => 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 - Options for writing the file.\n */\n writeSync: (path: string, data: string, options?: WriteOptions) => void;\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n mkdir: (dirPath: string) => Promise<void>;\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n mkdirSync: (dirPath: string) => 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: (\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) => 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: (\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) => 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: (\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ) => 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: (\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ) => string[];\n\n /**\n * A helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = await context.resolve(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n resolve: (\n id: string,\n importer?: string,\n options?: ResolveOptions\n ) => Promise<string | undefined>;\n\n /**\n * A synchronous helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = context.resolveSync(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns The resolved module path.\n */\n resolveSync: (\n id: string,\n importer?: string,\n options?: ResolveOptions\n ) => string | undefined;\n\n /**\n * Resolves a given module ID using the configured aliases.\n *\n * @remarks\n * This function can be used to map module IDs to different paths based on the alias configuration.\n *\n * @param id - The module ID to resolve.\n * @returns The resolved module ID - after applying any configured aliases (this will be the same as the input ID if no aliases match).\n */\n resolveAlias: (id: string) => string;\n\n /**\n * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.\n */\n dispose: () => Promise<void>;\n}\n"],"mappings":";;AAyBA,MAAa,gBAAgB;AAG7B,MAAa,iBAAiB;AAI9B,MAAaA,kBAAmC,CAAC,MAAM,UAAU"}