@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,502 @@
1
+ import { MaybePromise } from "@stryke/types/base";
2
+ import { AssetGlob } from "@stryke/types/file";
3
+ import { ResolveOptions as ResolveOptions$1 } from "@stryke/fs/resolve";
4
+
5
+ //#region src/types/fs.d.ts
6
+ type VirtualFileExtension = "js" | "ts" | "jsx" | "tsx";
7
+ declare const __VFS_PATCH__ = "__VFS_PATCH__";
8
+ declare const __VFS_REVERT__ = "__VFS_REVERT__";
9
+ type StoragePreset = "fs" | "virtual";
10
+ declare const STORAGE_PRESETS: StoragePreset[];
11
+ /**
12
+ * Interface defining the methods and properties for a storage adapter.
13
+ */
14
+ interface StorageAdapter {
15
+ /**
16
+ * A name identifying the storage adapter type.
17
+ */
18
+ name: string;
19
+ /**
20
+ * The storage preset for the adapter.
21
+ *
22
+ * @remarks
23
+ * This can be used as an alternate way to identify the type of storage being used.
24
+ */
25
+ preset?: StoragePreset | null;
26
+ /**
27
+ * Checks if a key exists in the storage.
28
+ *
29
+ * @param key - The key to check for existence.
30
+ * @returns A promise that resolves to `true` if the key exists, otherwise `false`.
31
+ */
32
+ exists: (key: string) => Promise<boolean>;
33
+ /**
34
+ * Synchronously checks if a key exists in the storage.
35
+ *
36
+ * @param key - The key to check for existence.
37
+ * @returns Returns `true` if the key exists, otherwise `false`.
38
+ */
39
+ existsSync: (key: string) => boolean;
40
+ /**
41
+ * Read a value associated with a key from the storage.
42
+ *
43
+ * @param key - The key to read the value for.
44
+ * @returns A promise that resolves to the value if found, otherwise `null`.
45
+ */
46
+ get: (key: string) => Promise<string | null>;
47
+ /**
48
+ * Synchronously reads the value associated with a key from the storage.
49
+ *
50
+ * @param key - The key to read the value for.
51
+ * @returns The value if found, otherwise `null`.
52
+ */
53
+ getSync: (key: string) => string | null;
54
+ /**
55
+ * Writes a value to the storage for the given key.
56
+ *
57
+ * @param key - The key to associate the value with.
58
+ * @param value - The value to store.
59
+ */
60
+ set: (key: string, value: string) => Promise<void>;
61
+ /**
62
+ * Synchronously writes a value to the storage for the given key.
63
+ *
64
+ * @param key - The key to associate the value with.
65
+ * @param value - The value to store.
66
+ */
67
+ setSync: (key: string, value: string) => void;
68
+ /**
69
+ * Removes a value from the storage.
70
+ *
71
+ * @param key - The key whose value should be removed.
72
+ */
73
+ remove: (key: string) => Promise<void>;
74
+ /**
75
+ * Synchronously removes a value from the storage.
76
+ *
77
+ * @param key - The key whose value should be removed.
78
+ */
79
+ removeSync: (key: string) => void;
80
+ /**
81
+ * Creates a directory at the specified path.
82
+ *
83
+ * @param dirPath - The path of the directory to create.
84
+ */
85
+ mkdir: (dirPath: string) => Promise<void>;
86
+ /**
87
+ * Synchronously creates a directory at the specified path.
88
+ *
89
+ * @param dirPath - The path of the directory to create.
90
+ */
91
+ mkdirSync: (dirPath: string) => void;
92
+ /**
93
+ * Remove all entries from the storage that match the provided base path.
94
+ *
95
+ * @param base - The base path or prefix to clear entries from.
96
+ */
97
+ clear: (base?: string) => Promise<void>;
98
+ /**
99
+ * Synchronously remove all entries from the storage that match the provided base path.
100
+ *
101
+ * @param base - The base path or prefix to clear entries from.
102
+ */
103
+ clearSync: (base?: string) => void;
104
+ /**
105
+ * Lists all keys under the provided base path.
106
+ *
107
+ * @param base - The base path or prefix to list keys from.
108
+ * @returns A promise resolving to the list of keys.
109
+ */
110
+ list: (base?: string) => Promise<string[]>;
111
+ /**
112
+ * Synchronously lists all keys under the provided base path.
113
+ *
114
+ * @param base - The base path or prefix to list keys from.
115
+ * @returns The list of keys.
116
+ */
117
+ listSync: (base?: string) => string[];
118
+ /**
119
+ * Checks if the given key is a directory.
120
+ *
121
+ * @param key - The key to check.
122
+ * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
123
+ */
124
+ isDirectory: (key: string) => Promise<boolean>;
125
+ /**
126
+ * Synchronously checks if the given key is a directory.
127
+ *
128
+ * @param key - The key to check.
129
+ * @returns `true` if the key is a directory, otherwise `false`.
130
+ */
131
+ isDirectorySync: (key: string) => boolean;
132
+ /**
133
+ * Checks if the given key is a file.
134
+ *
135
+ * @param key - The key to check.
136
+ * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
137
+ */
138
+ isFile: (key: string) => Promise<boolean>;
139
+ /**
140
+ * Synchronously checks if the given key is a file.
141
+ *
142
+ * @param key - The key to check.
143
+ * @returns `true` if the key is a file, otherwise `false`.
144
+ */
145
+ isFileSync: (key: string) => boolean;
146
+ /**
147
+ * Releases any resources held by the storage adapter.
148
+ */
149
+ dispose: () => MaybePromise<void>;
150
+ }
151
+ /**
152
+ * A mapping of file paths to storage adapter names and their corresponding {@link StorageAdapter} instances.
153
+ */
154
+ type StoragePort = Record<string, StorageAdapter>;
155
+ interface VirtualFileMetadata {
156
+ /**
157
+ * The identifier for the file data.
158
+ */
159
+ id: string;
160
+ /**
161
+ * The timestamp of the virtual file.
162
+ */
163
+ timestamp: number;
164
+ /**
165
+ * The type of the file.
166
+ *
167
+ * @remarks
168
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
169
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
170
+ * - `entry`: Indicates that the file is an entry point for execution.
171
+ * - `normal`: Indicates that the file is a standard file without any special role.
172
+ */
173
+ type: string;
174
+ /**
175
+ * Additional metadata associated with the file.
176
+ */
177
+ properties: Record<string, string | undefined>;
178
+ }
179
+ interface VirtualFileData {
180
+ /**
181
+ * The identifier for the file data.
182
+ */
183
+ id?: string;
184
+ /**
185
+ * The contents of the virtual file.
186
+ */
187
+ code: string;
188
+ /**
189
+ * The type of the file.
190
+ *
191
+ * @remarks
192
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
193
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
194
+ * - `entry`: Indicates that the file is an entry point for execution.
195
+ * - `normal`: Indicates that the file is a standard file without any special role.
196
+ */
197
+ type?: string;
198
+ /**
199
+ * Additional metadata associated with the file.
200
+ */
201
+ properties?: Record<string, string | undefined>;
202
+ }
203
+ interface VirtualFile extends Required<VirtualFileData>, VirtualFileMetadata {
204
+ /**
205
+ * An additional name for the file.
206
+ */
207
+ path: string;
208
+ /**
209
+ * The timestamp of the virtual file.
210
+ */
211
+ timestamp: number;
212
+ }
213
+ interface WriteOptions {
214
+ /**
215
+ * Should the file skip formatting before being written?
216
+ *
217
+ * @defaultValue false
218
+ */
219
+ skipFormat?: boolean;
220
+ /**
221
+ * The storage preset or adapter name for the output file.
222
+ *
223
+ * @remarks
224
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
225
+ */
226
+ storage?: StoragePreset | string;
227
+ /**
228
+ * Additional metadata for the file.
229
+ */
230
+ meta?: Partial<VirtualFileMetadata>;
231
+ }
232
+ type WriteData = string | NodeJS.ArrayBufferView | VirtualFileData;
233
+ interface ResolveOptions extends ResolveOptions$1 {
234
+ /**
235
+ * If true, the module is being resolved as an entry point.
236
+ */
237
+ isEntry?: boolean;
238
+ /**
239
+ * If true, the resolver will skip alias resolution when resolving modules.
240
+ */
241
+ skipAlias?: boolean;
242
+ /**
243
+ * If true, the resolver will skip using the cache when resolving modules.
244
+ */
245
+ skipCache?: boolean;
246
+ /**
247
+ * An array of external modules or patterns to exclude from resolution.
248
+ */
249
+ external?: (string | RegExp)[];
250
+ /**
251
+ * An array of modules or patterns to include in the resolution, even if they are marked as external.
252
+ */
253
+ noExternal?: (string | RegExp)[];
254
+ /**
255
+ * An array of patterns to match when resolving modules.
256
+ */
257
+ skipNodeModulesBundle?: boolean;
258
+ }
259
+ interface VirtualFileSystemInterface {
260
+ /**
261
+ * The underlying file metadata.
262
+ */
263
+ metadata: Readonly<Record<string, VirtualFileMetadata>>;
264
+ /**
265
+ * A map of file paths to their module ids.
266
+ */
267
+ ids: Readonly<Record<string, string>>;
268
+ /**
269
+ * A map of module ids to their file paths.
270
+ */
271
+ paths: Readonly<Record<string, string>>;
272
+ /**
273
+ * Checks if a file exists in the virtual file system (VFS).
274
+ *
275
+ * @param path - The path or id of the file.
276
+ * @returns `true` if the file exists, otherwise `false`.
277
+ */
278
+ exists: (path: string) => Promise<boolean>;
279
+ /**
280
+ * Synchronously Checks if a file exists in the virtual file system (VFS).
281
+ *
282
+ * @param path - The path or id of the file.
283
+ * @returns `true` if the file exists, otherwise `false`.
284
+ */
285
+ existsSync: (path: string) => boolean;
286
+ /**
287
+ * Checks if a file is virtual in the virtual file system (VFS).
288
+ *
289
+ * @param path - The path or id of the file.
290
+ * @returns `true` if the file is virtual, otherwise `false`.
291
+ */
292
+ isVirtual: (path: string) => boolean;
293
+ /**
294
+ * Checks if the given key is a directory.
295
+ *
296
+ * @param key - The key to check.
297
+ * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
298
+ */
299
+ isDirectory: (key: string) => Promise<boolean>;
300
+ /**
301
+ * Synchronously checks if the given key is a directory.
302
+ *
303
+ * @param key - The key to check.
304
+ * @returns `true` if the key is a directory, otherwise `false`.
305
+ */
306
+ isDirectorySync: (key: string) => boolean;
307
+ /**
308
+ * Checks if the given key is a file.
309
+ *
310
+ * @param key - The key to check.
311
+ * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
312
+ */
313
+ isFile: (key: string) => Promise<boolean>;
314
+ /**
315
+ * Synchronously checks if the given key is a file.
316
+ *
317
+ * @param key - The key to check.
318
+ * @returns `true` if the key is a file, otherwise `false`.
319
+ */
320
+ isFileSync: (key: string) => boolean;
321
+ /**
322
+ * Gets the metadata of a file in the virtual file system (VFS).
323
+ *
324
+ * @param path - The path or id of the file.
325
+ * @returns The metadata of the file if it exists, otherwise undefined.
326
+ */
327
+ getMetadata: (path: string) => VirtualFileMetadata | undefined;
328
+ /**
329
+ * Lists files in a given path.
330
+ *
331
+ * @param path - The path to list files from.
332
+ * @returns An array of file names in the specified path.
333
+ */
334
+ listSync: (path: string) => string[];
335
+ /**
336
+ * Lists files in a given path.
337
+ *
338
+ * @param path - The path to list files from.
339
+ * @returns An array of file names in the specified path.
340
+ */
341
+ list: (path: string) => Promise<string[]>;
342
+ /**
343
+ * Removes a file or symbolic link in the virtual file system (VFS).
344
+ *
345
+ * @param path - The path to the file to remove.
346
+ * @returns A promise that resolves when the file is removed.
347
+ */
348
+ removeSync: (path: string) => void;
349
+ /**
350
+ * Asynchronously removes a file or symbolic link in the virtual file system (VFS).
351
+ *
352
+ * @param path - The path to the file to remove.
353
+ * @returns A promise that resolves when the file is removed.
354
+ */
355
+ remove: (path: string) => Promise<void>;
356
+ /**
357
+ * Reads a file from the virtual file system (VFS).
358
+ *
359
+ * @param path - The path or id of the file.
360
+ * @returns The contents of the file if it exists, otherwise undefined.
361
+ */
362
+ read: (path: string) => Promise<string | undefined>;
363
+ /**
364
+ * Reads a file from the virtual file system (VFS).
365
+ *
366
+ * @param path - The path or id of the file.
367
+ */
368
+ readSync: (path: string) => string | undefined;
369
+ /**
370
+ * Writes a file to the virtual file system (VFS).
371
+ *
372
+ * @param path - The path to the file.
373
+ * @param data - The contents of the file.
374
+ * @param options - Options for writing the file.
375
+ * @returns A promise that resolves when the file is written.
376
+ */
377
+ write: (path: string, data: string, options?: WriteOptions) => Promise<void>;
378
+ /**
379
+ * Writes a file to the virtual file system (VFS).
380
+ *
381
+ * @param path - The path to the file.
382
+ * @param data - The contents of the file.
383
+ * @param options - Options for writing the file.
384
+ */
385
+ writeSync: (path: string, data: string, options?: WriteOptions) => void;
386
+ /**
387
+ * Creates a directory at the specified path.
388
+ *
389
+ * @param dirPath - The path of the directory to create.
390
+ */
391
+ mkdir: (dirPath: string) => Promise<void>;
392
+ /**
393
+ * Synchronously creates a directory at the specified path.
394
+ *
395
+ * @param dirPath - The path of the directory to create.
396
+ */
397
+ mkdirSync: (dirPath: string) => void;
398
+ /**
399
+ * Moves a file from one path to another in the virtual file system (VFS).
400
+ *
401
+ * @param srcPath - The source path to move
402
+ * @param destPath - The destination path to move to
403
+ */
404
+ move: (srcPath: string, destPath: string) => Promise<void>;
405
+ /**
406
+ * Synchronously moves a file from one path to another in the virtual file system (VFS).
407
+ *
408
+ * @param srcPath - The source path to move
409
+ * @param destPath - The destination path to move to
410
+ */
411
+ moveSync: (srcPath: string, destPath: string) => void;
412
+ /**
413
+ * Copies a file from one path to another in the virtual file system (VFS).
414
+ *
415
+ * @param srcPath - The source path to copy
416
+ * @param destPath - The destination path to copy to
417
+ */
418
+ copy: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => Promise<void>;
419
+ /**
420
+ * Synchronously copies a file from one path to another in the virtual file system (VFS).
421
+ *
422
+ * @param srcPath - The source path to copy
423
+ * @param destPath - The destination path to copy to
424
+ */
425
+ copySync: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => void;
426
+ /**
427
+ * Glob files in the virtual file system (VFS) based on the provided pattern(s).
428
+ *
429
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
430
+ * @returns An array of file paths matching the provided pattern(s)
431
+ */
432
+ glob: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => Promise<string[]>;
433
+ /**
434
+ * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
435
+ *
436
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
437
+ * @returns An array of file paths matching the provided pattern(s)
438
+ */
439
+ globSync: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => string[];
440
+ /**
441
+ * A helper function to resolve modules using the Jiti resolver
442
+ *
443
+ * @remarks
444
+ * This function can be used to resolve modules relative to the project root directory.
445
+ *
446
+ * @example
447
+ * ```ts
448
+ * const resolvedPath = await context.resolve("some-module", "/path/to/importer");
449
+ * ```
450
+ *
451
+ * @param id - The module to resolve.
452
+ * @param importer - An optional path to the importer module.
453
+ * @param options - Additional resolution options.
454
+ * @returns A promise that resolves to the resolved module path.
455
+ */
456
+ resolve: (id: string, importer?: string, options?: ResolveOptions) => Promise<string | undefined>;
457
+ /**
458
+ * A synchronous helper function to resolve modules using the Jiti resolver
459
+ *
460
+ * @remarks
461
+ * This function can be used to resolve modules relative to the project root directory.
462
+ *
463
+ * @example
464
+ * ```ts
465
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
466
+ * ```
467
+ *
468
+ * @param id - The module to resolve.
469
+ * @param importer - An optional path to the importer module.
470
+ * @param options - Additional resolution options.
471
+ * @returns The resolved module path.
472
+ */
473
+ resolveSync: (id: string, importer?: string, options?: ResolveOptions) => string | undefined;
474
+ /**
475
+ * Resolves a given module ID using the configured aliases.
476
+ *
477
+ * @remarks
478
+ * This function can be used to map module IDs to different paths based on the alias configuration.
479
+ *
480
+ * @param id - The module ID to resolve.
481
+ * @returns The resolved module ID - after applying any configured aliases (this will be the same as the input ID if no aliases match).
482
+ */
483
+ resolveAlias: (id: string) => string;
484
+ /**
485
+ * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
486
+ */
487
+ dispose: () => Promise<void>;
488
+ }
489
+ declare type __ΩVirtualFileExtension = any[];
490
+ declare type __ΩStoragePreset = any[];
491
+ declare type __ΩStorageAdapter = any[];
492
+ declare type __ΩStoragePort = any[];
493
+ declare type __ΩVirtualFileMetadata = any[];
494
+ declare type __ΩVirtualFileData = any[];
495
+ declare type __ΩVirtualFile = any[];
496
+ declare type __ΩWriteOptions = any[];
497
+ declare type __ΩWriteData = any[];
498
+ declare type __ΩResolveOptions = any[];
499
+ declare type __ΩVirtualFileSystemInterface = any[];
500
+ //#endregion
501
+ export { ResolveOptions, STORAGE_PRESETS, StorageAdapter, StoragePort, StoragePreset, VirtualFile, VirtualFileData, VirtualFileExtension, VirtualFileMetadata, VirtualFileSystemInterface, WriteData, WriteOptions, __VFS_PATCH__, __VFS_REVERT__, __ΩResolveOptions, __ΩStorageAdapter, __ΩStoragePort, __ΩStoragePreset, __ΩVirtualFile, __ΩVirtualFileData, __ΩVirtualFileExtension, __ΩVirtualFileMetadata, __ΩVirtualFileSystemInterface, __ΩWriteData, __ΩWriteOptions };
502
+ //# sourceMappingURL=fs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.mts","names":[],"sources":["../../src/types/fs.ts"],"sourcesContent":[],"mappings":";;;;;KAsBY,oBAAA;cAGC,aAAA;AAHD,cAMC,cAAA,GANmB,gBAAA;AAGnB,KAKD,aAAA,GALc,IAAA,GAAA,SAAA;AAGb,cAIA,eAJc,EAIG,aAJH,EAAA;AAE3B;AAEA;AAKA;AAYW,UAZM,cAAA,CAYN;EAQgB;;;EA+CA,IAAA,EAAA,MAAA;EAcG;;;;;;EA0ED,MAAA,CAAA,EA/IlB,aA+IkB,GAAA,IAAA;EAMjB;AAEZ;AA4BA;AA4BA;;;EACqC,MAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAxMV,OAwMU,CAAA,OAAA,CAAA;EAAmB;AAYxD;;;;;EAsBY,UAAA,EAAS,CAAA,GAAA,EAAA,MAAA,EAAY,GAAA,OAAO;EAEvB;;;;;AAgCjB;EAIoC,GAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAhQZ,OAgQY,CAAA,MAAA,GAAA,IAAA,CAAA;EAAf;;;;;;EAkBO,OAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,MAAA,GAAA,IAAA;EAwBI;;;;;;EAyFgB,GAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,EAAA,GAnXT,OAmXS,CAAA,IAAA,CAAA;EAAiB;;;;;;EAgDrC,OAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EACL;;;;;EAWA,MAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAhaI,OAgaJ,CAAA,IAAA,CAAA;EAYV;;;;;EAaA,UAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAL;;;;;EA6CM,KAAA,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAxdgB,OAwdhB,CAAA,IAAA,CAAA;EAiBG;;;;;;;;;;;4BA3dW;;;;;;;;;;;;;2BAeD;;;;;;;;;;;;;;gCAgBK;;;;;;;;;;;;;;2BAgBL;;;;;;;;;;;iBAaV;;;;;KAML,WAAA,GAAc,eAAe;UAExB,mBAAA;;;;;;;;;;;;;;;;;;;;;;cAyBH;;UAGG,eAAA;;;;;;;;;;;;;;;;;;;;;;eAyBF;;UAGE,WAAA,SACP,SAAS,kBAAkB;;;;;;;;;;UAYpB,YAAA;;;;;;;;;;;;;YAcL;;;;SAKH,QAAQ;;KAGL,SAAA,YAAqB,MAAA,CAAO,kBAAkB;UAEzC,cAAA,SAAuB;;;;;;;;;;;;;;;;uBAmBjB;;;;yBAKE;;;;;;UAQR,0BAAA;;;;YAIL,SAAS,eAAe;;;;OAK7B,SAAS;;;;SAKP,SAAS;;;;;;;4BAQU;;;;;;;;;;;;;;;;;;;;;gCAwBI;;;;;;;;;;;;;;2BAgBL;;;;;;;;;;;;;;iCAgBM;;;;;;;;;;;;;;0BAgBP;;;;;;;;;;;;;;4BAgBE;;;;;;;0BAQF;;;;;;;;;;;;;;;gDAiBsB,iBAAiB;;;;;;;;oDASb;;;;;;8BAOtB;;;;;;;;;;;;;+CAeiB;;;;;;;;;;;;;;2BAiBzB,MAAM,KAAK,yCACV,QAChB;;;;;;;+BASe,MAAM,KAAK,yCACV;;;;;;;4BAYf,KAAK,iCACK,KAAK,4BAChB;;;;;;;gCAWC,KAAK,iCACK,KAAK;;;;;;;;;;;;;;;;;qDAsBT,mBACP;;;;;;;;;;;;;;;;;yDAqBO;;;;;;;;;;;;;;iBAiBG"}
@@ -0,0 +1,8 @@
1
+ //#region src/types/fs.ts
2
+ const __VFS_PATCH__ = "__VFS_PATCH__";
3
+ const __VFS_REVERT__ = "__VFS_REVERT__";
4
+ const STORAGE_PRESETS = ["fs", "virtual"];
5
+
6
+ //#endregion
7
+ export { STORAGE_PRESETS, __VFS_PATCH__, __VFS_REVERT__ };
8
+ //# sourceMappingURL=fs.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.mjs","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"}
@@ -0,0 +1,13 @@
1
+
2
+ //#region src/types/hooks.ts
3
+ const HOOKS_LIST_ORDERS = [
4
+ "preOrdered",
5
+ "preEnforced",
6
+ "normal",
7
+ "postEnforced",
8
+ "postOrdered"
9
+ ];
10
+
11
+ //#endregion
12
+ exports.HOOKS_LIST_ORDERS = HOOKS_LIST_ORDERS;
13
+ //# sourceMappingURL=hooks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.cjs","names":[],"sources":["../../src/types/hooks.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 { MaybePromise } from \"@stryke/types/base\";\nimport { UnpluginOptions } from \"unplugin\";\nimport type {\n PluginContext,\n SelectHooksOptions,\n WithUnpluginBuildContext\n} from \"./context\";\nimport type { Plugin, PluginHookFields, PluginHookFunctions } from \"./plugin\";\nimport { UnpluginBuilderVariant } from \"./unplugin\";\n\nexport type HookListOrders =\n | \"preOrdered\"\n | \"preEnforced\"\n | \"normal\"\n | \"postEnforced\"\n | \"postOrdered\";\n\nexport const HOOKS_LIST_ORDERS = [\n \"preOrdered\",\n \"preEnforced\",\n \"normal\",\n \"postEnforced\",\n \"postOrdered\"\n] as const;\n\nexport type UnpluginHookFunctions<\n TContext extends PluginContext = PluginContext,\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant,\n TField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] =\n keyof Required<UnpluginOptions>[TUnpluginBuilderVariant]\n> = Required<UnpluginOptions>[TUnpluginBuilderVariant][TField] extends\n | infer THandler\n | {\n handler: infer THandler;\n }\n ? THandler extends (\n this: infer THandlerOriginalContext,\n ...args: infer THandlerArgs\n ) => infer THandlerReturn\n ? (\n this: THandlerOriginalContext & WithUnpluginBuildContext<TContext>,\n ...args: THandlerArgs\n ) => THandlerReturn\n : THandler extends { handler: infer THandlerFunction }\n ? THandlerFunction extends (\n this: infer THandlerFunctionOriginalContext,\n ...args: infer THandlerFunctionArgs\n ) => infer THandlerFunctionReturn\n ? (\n this: THandlerFunctionOriginalContext &\n WithUnpluginBuildContext<TContext>,\n ...args: THandlerFunctionArgs\n ) => THandlerFunctionReturn\n : never\n : never\n : never;\n\nexport interface PluginHooksListItem<\n TContext extends PluginContext = PluginContext,\n TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>\n> {\n plugin: Plugin<TContext>;\n handler: PluginHookFunctions<TContext>[TFields];\n}\n\nexport type PluginHooksList<\n TContext extends PluginContext = PluginContext,\n TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>\n> = {\n [TKey in HookListOrders]?:\n | PluginHooksListItem<TContext, TFields>[]\n | undefined;\n};\n\nexport interface UnpluginHooksListItem<\n TContext extends PluginContext = PluginContext,\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant,\n TField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] =\n keyof Required<UnpluginOptions>[TUnpluginBuilderVariant]\n> {\n plugin: Plugin<TContext>;\n handler: UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TField>;\n}\n\nexport type UnpluginHookList<\n TContext extends PluginContext = PluginContext,\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant,\n TField extends keyof UnpluginOptions[TUnpluginBuilderVariant] =\n keyof UnpluginOptions[TUnpluginBuilderVariant]\n> = {\n [TKey in HookListOrders]?:\n | UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TField>[]\n | undefined;\n};\n\nexport type UnpluginHookVariantField<\n TContext extends PluginContext = PluginContext,\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant\n> = {\n [TKey in keyof UnpluginOptions[TUnpluginBuilderVariant]]?: UnpluginHookList<\n TContext,\n TUnpluginBuilderVariant,\n TKey\n >;\n};\n\nexport type UnpluginHookVariant<\n TContext extends PluginContext = PluginContext\n> = {\n [TKey in UnpluginBuilderVariant]?: UnpluginHookVariantField<TContext, TKey>;\n};\n\nexport type HookFields<TContext extends PluginContext = PluginContext> =\n | PluginHookFields<TContext>\n | UnpluginBuilderVariant;\n\nexport type HooksList<TContext extends PluginContext = PluginContext> = {\n [TField in HookFields<TContext>]?: TField extends PluginHookFields<TContext>\n ? PluginHooksList<TContext, TField>\n : TField extends UnpluginBuilderVariant\n ? UnpluginHookVariant<TContext>[TField]\n : never;\n};\n\nexport type InferHooksListItem<\n TContext extends PluginContext,\n TKey extends string\n> = TKey extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}`\n ? TUnpluginBuilderVariant extends UnpluginBuilderVariant\n ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant]\n ? UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TUnpluginField>\n : never\n : never\n : TKey extends keyof PluginHookFunctions<TContext>\n ? PluginHooksListItem<TContext, TKey>\n : never;\n\nexport type InferHookFunction<\n TContext extends PluginContext,\n TKey extends string\n> = TKey extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}`\n ? TUnpluginBuilderVariant extends UnpluginBuilderVariant\n ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant]\n ? UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TUnpluginField>\n : never\n : never\n : TKey extends keyof PluginHookFunctions<TContext>\n ? PluginHookFunctions<TContext>[TKey]\n : never;\n\nexport type InferHookReturnType<\n TContext extends PluginContext,\n TKey extends string\n> = ReturnType<InferHookFunction<TContext, TKey>>;\n\nexport type InferHookParameters<\n TContext extends PluginContext,\n TKey extends string\n> = Parameters<InferHookFunction<TContext, TKey>>;\n\nexport type InferHookThisType<\n TContext extends PluginContext,\n TKey extends string\n> = ThisParameterType<InferHookFunction<TContext, TKey>>;\n\nexport type CallHookOptions = SelectHooksOptions &\n (\n | ({\n /**\n * Whether to call the hooks sequentially or in parallel.\n *\n * @defaultValue true\n */\n sequential?: true;\n } & (\n | {\n /**\n * How to handle multiple return values from hooks.\n * - \"merge\": Merge all non-undefined return values (if they are objects).\n * - \"first\": Return the first non-undefined value.\n *\n * @remarks\n * Merging only works if the return values are objects.\n *\n * @defaultValue \"merge\"\n */\n result: \"first\";\n }\n | ({\n /**\n * An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter\n */\n asNextParam?: false | ((previousResult: any) => MaybePromise<any>);\n } & (\n | {\n /**\n * How to handle multiple return values from hooks.\n * - \"merge\": Merge all non-undefined return values (if they are objects).\n * - \"first\": Return the first non-undefined value.\n *\n * @remarks\n * Merging only works if the return values are objects.\n *\n * @defaultValue \"merge\"\n */\n result?: \"merge\";\n\n /**\n * A custom function to merge multiple return values from hooks.\n *\n * @remarks\n * If not provided, the {@link mergeResults} function will be used by default, which merges string results by concatenation and object results by deep merging.\n *\n * @param currentResult - The current hook result to merge with the previous results.\n * @param previousResults - The previous hook results to merge with the current result.\n * @returns The merged result.\n */\n merge?: <T>(currentResult: T, previousResults: T[]) => T[];\n }\n | {\n /**\n * How to handle multiple return values from hooks.\n * - \"merge\": Merge all non-undefined return values (if they are objects).\n * - \"first\": Return the first non-undefined value.\n *\n * @remarks\n * Merging only works if the return values are objects.\n *\n * @defaultValue \"merge\"\n */\n result?: \"last\";\n }\n ))\n ))\n | {\n /**\n * Whether to call the hooks sequentially or in parallel.\n */\n sequential: false;\n }\n );\n"],"mappings":";;AAmCA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACD"}