@powerlines/plugin-vite 0.14.122 → 0.14.124

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 (141) hide show
  1. package/dist/helpers/index.cjs +3 -2
  2. package/dist/helpers/index.d.cts +3 -1
  3. package/dist/helpers/index.d.mts +3 -1
  4. package/dist/helpers/index.mjs +2 -1
  5. package/dist/helpers/unplugin.cjs +2 -11
  6. package/dist/helpers/unplugin.d.cts +2 -6
  7. package/dist/helpers/unplugin.d.mts +2 -6
  8. package/dist/helpers/unplugin.mjs +1 -9
  9. package/dist/helpers-CmEjzAn_.mjs +1 -0
  10. package/dist/helpers-LF26RHol.cjs +0 -0
  11. package/dist/index-BR1oNnaF.d.cts +1 -0
  12. package/dist/index-DEHBdV_z.d.mts +1 -0
  13. package/dist/index-_wQ5ClJU.d.cts +1 -0
  14. package/dist/index-vkGVyY9v.d.mts +1 -0
  15. package/dist/index.cjs +170 -9
  16. package/dist/index.d.cts +4 -3
  17. package/dist/index.d.mts +5 -5
  18. package/dist/index.mjs +165 -3
  19. package/dist/plugin-Dc12T6ZF.d.mts +1960 -0
  20. package/dist/plugin-jZ9N9Mz-.mjs +1 -0
  21. package/dist/plugin-pBKbb5K9.cjs +0 -0
  22. package/dist/plugin-vkCGh5de.d.cts +1957 -0
  23. package/dist/types/index.cjs +2 -0
  24. package/dist/types/index.d.cts +2 -1
  25. package/dist/types/index.d.mts +2 -1
  26. package/dist/types/index.mjs +3 -0
  27. package/dist/types/internal.d.cts +191 -3
  28. package/dist/types/internal.d.mts +191 -3
  29. package/dist/types/plugin.cjs +1 -0
  30. package/dist/types/plugin.d.cts +1 -12
  31. package/dist/types/plugin.d.mts +1 -12
  32. package/dist/types/plugin.mjs +2 -0
  33. package/dist/types-BtDR9wb1.mjs +1 -0
  34. package/dist/types-o3zWarRp.cjs +0 -0
  35. package/dist/unplugin-B3TcDD6I.mjs +4617 -0
  36. package/dist/unplugin-Bv2agFkI.cjs +4661 -0
  37. package/dist/unplugin-D_zrAqRh.d.mts +7 -0
  38. package/dist/unplugin-F1UAxbOS.d.cts +7 -0
  39. package/package.json +5 -5
  40. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  41. package/dist/powerlines/schemas/fs.cjs +0 -226
  42. package/dist/powerlines/schemas/fs.mjs +0 -224
  43. package/dist/powerlines/src/api.cjs +0 -580
  44. package/dist/powerlines/src/api.mjs +0 -578
  45. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
  46. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
  47. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
  48. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
  49. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
  50. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
  51. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -63
  52. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -48
  53. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -50
  54. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -61
  55. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
  56. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
  57. package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
  58. package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
  59. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
  60. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
  61. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  62. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  63. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
  64. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
  65. package/dist/powerlines/src/lib/build/vite.cjs +0 -74
  66. package/dist/powerlines/src/lib/build/vite.mjs +0 -71
  67. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  68. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  69. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  70. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  71. package/dist/powerlines/src/lib/contexts/context.cjs +0 -931
  72. package/dist/powerlines/src/lib/contexts/context.mjs +0 -929
  73. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -160
  74. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -159
  75. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
  76. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
  77. package/dist/powerlines/src/lib/entry.cjs +0 -69
  78. package/dist/powerlines/src/lib/entry.mjs +0 -67
  79. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  80. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  81. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  82. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  83. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  84. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  85. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  86. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  87. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
  88. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
  89. package/dist/powerlines/src/lib/logger.cjs +0 -58
  90. package/dist/powerlines/src/lib/logger.mjs +0 -55
  91. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
  92. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
  93. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  94. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  95. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  96. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  97. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -17
  98. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -16
  99. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
  100. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
  101. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
  102. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
  103. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  104. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  105. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
  106. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
  107. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  108. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  109. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -148
  110. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -138
  111. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  112. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  113. package/dist/powerlines/src/types/api.d.cts +0 -104
  114. package/dist/powerlines/src/types/api.d.mts +0 -104
  115. package/dist/powerlines/src/types/babel.d.mts +0 -4
  116. package/dist/powerlines/src/types/build.cjs +0 -15
  117. package/dist/powerlines/src/types/build.d.cts +0 -154
  118. package/dist/powerlines/src/types/build.d.mts +0 -154
  119. package/dist/powerlines/src/types/build.mjs +0 -14
  120. package/dist/powerlines/src/types/commands.cjs +0 -16
  121. package/dist/powerlines/src/types/commands.d.cts +0 -8
  122. package/dist/powerlines/src/types/commands.d.mts +0 -9
  123. package/dist/powerlines/src/types/commands.mjs +0 -15
  124. package/dist/powerlines/src/types/config.d.cts +0 -416
  125. package/dist/powerlines/src/types/config.d.mts +0 -418
  126. package/dist/powerlines/src/types/context.d.cts +0 -514
  127. package/dist/powerlines/src/types/context.d.mts +0 -514
  128. package/dist/powerlines/src/types/fs.d.cts +0 -486
  129. package/dist/powerlines/src/types/fs.d.mts +0 -486
  130. package/dist/powerlines/src/types/hooks.d.cts +0 -30
  131. package/dist/powerlines/src/types/hooks.d.mts +0 -30
  132. package/dist/powerlines/src/types/internal.d.cts +0 -58
  133. package/dist/powerlines/src/types/internal.d.mts +0 -58
  134. package/dist/powerlines/src/types/plugin.cjs +0 -32
  135. package/dist/powerlines/src/types/plugin.d.cts +0 -234
  136. package/dist/powerlines/src/types/plugin.d.mts +0 -234
  137. package/dist/powerlines/src/types/plugin.mjs +0 -31
  138. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  139. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  140. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  141. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -0,0 +1,1960 @@
1
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
2
+ import { DepOptimizationOptions, PreviewOptions, ResolvedPreviewOptions, UserConfig } from "vite";
3
+ import { ExternalIdResult, HookFilter, TransformResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage, UnpluginOptions } from "unplugin";
4
+ import { transformAsync } from "@babel/core";
5
+ import { ResolveOptions } from "@stryke/fs/resolve";
6
+ import "@babel/helper-plugin-utils";
7
+ import ts from "typescript";
8
+ import { Project } from "ts-morph";
9
+ import "c12";
10
+ import { EnvPaths } from "@stryke/env/get-env-paths";
11
+ import { FetchRequestOptions } from "@stryke/http/fetch";
12
+ import { ParseResult, ParserOptions } from "oxc-parser";
13
+ import { RequestInfo, Response } from "undici";
14
+ import { Jiti } from "jiti";
15
+ import { SourceMap } from "magic-string";
16
+ import { FunctionLike, MaybePromise, NonUndefined } from "@stryke/types/base";
17
+ import { PackageJson } from "@stryke/types/package-json";
18
+ import { Range } from "semver";
19
+ import { Format } from "@storm-software/build-tools/types";
20
+ import { StormWorkspaceConfig } from "@storm-software/config/types";
21
+ import { TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
22
+ import { AssetGlob } from "@stryke/types/file";
23
+ import { DateString } from "compatx";
24
+ import { ArrayValues } from "@stryke/types/array";
25
+ import { CompilerOptions, TsConfigJson } from "@stryke/types/tsconfig";
26
+
27
+ //#region ../powerlines/src/types/build.d.ts
28
+ type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
29
+ interface BuildConfig {
30
+ /**
31
+ * The platform to build the project for
32
+ *
33
+ * @defaultValue "neutral"
34
+ */
35
+ platform?: "node" | "browser" | "neutral";
36
+ /**
37
+ * Array of strings indicating the polyfills to include for the build.
38
+ *
39
+ * @remarks
40
+ * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * {
45
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
46
+ * }
47
+ * ```
48
+ */
49
+ polyfill?: string[];
50
+ /**
51
+ * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
52
+ *
53
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
54
+ */
55
+ mainFields?: string[];
56
+ /**
57
+ * Array of strings indicating what conditions should be used for module resolution.
58
+ */
59
+ conditions?: string[];
60
+ /**
61
+ * Array of strings indicating what file extensions should be used for module resolution.
62
+ *
63
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
64
+ */
65
+ extensions?: string[];
66
+ /**
67
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
68
+ *
69
+ * @remarks
70
+ * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
71
+ */
72
+ dedupe?: string[];
73
+ /**
74
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
75
+ */
76
+ builtins?: (string | RegExp)[];
77
+ /**
78
+ * Define global variable replacements.
79
+ *
80
+ * @remarks
81
+ * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * {
86
+ * define: {
87
+ * __VERSION__: '"1.0.0"',
88
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
89
+ * }
90
+ * }
91
+ * ```
92
+ *
93
+ * @see https://esbuild.github.io/api/#define
94
+ * @see https://vitejs.dev/config/build-options.html#define
95
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
96
+ */
97
+ define?: Record<string, any>;
98
+ /**
99
+ * Global variables that will have import statements injected where necessary
100
+ *
101
+ * @remarks
102
+ * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * {
107
+ * inject: {
108
+ * process: 'process/browser',
109
+ * Buffer: ['buffer', 'Buffer'],
110
+ * }
111
+ * }
112
+ * ```
113
+ *
114
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
115
+ */
116
+ inject?: Record<string, string | string[]>;
117
+ /**
118
+ * The alias mappings to use for module resolution during the build process.
119
+ *
120
+ * @remarks
121
+ * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * {
126
+ * alias: {
127
+ * "@utils": "./src/utils",
128
+ * "@components": "./src/components"
129
+ * }
130
+ * }
131
+ * ```
132
+ *
133
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
134
+ */
135
+ alias?: Record<string, string> | Array<{
136
+ find: string | RegExp;
137
+ replacement: string;
138
+ }>;
139
+ /**
140
+ * A list of modules that should not be bundled, even if they are external dependencies.
141
+ *
142
+ * @remarks
143
+ * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.
144
+ */
145
+ external?: (string | RegExp)[];
146
+ /**
147
+ * A list of modules that should always be bundled, even if they are external dependencies.
148
+ */
149
+ noExternal?: (string | RegExp)[];
150
+ /**
151
+ * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
152
+ */
153
+ skipNodeModulesBundle?: boolean;
154
+ /**
155
+ * If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime. Otherwise, it is statically replaced as an empty object.
156
+ *
157
+ * @defaultValue false
158
+ */
159
+ keepProcessEnv?: boolean;
160
+ /**
161
+ * An optional set of override options to apply to the selected build variant.
162
+ *
163
+ * @remarks
164
+ * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
165
+ */
166
+ override?: Record<string, any>;
167
+ }
168
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
169
+ type ViteBuildConfig = Omit<UserConfig, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
170
+ /**
171
+ * Optimize deps config
172
+ */
173
+ optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
174
+ };
175
+ type ViteResolvedBuildConfig = UserConfig & BuildResolvedConfig;
176
+ //#endregion
177
+ //#region ../powerlines/src/types/fs.d.ts
178
+ type StoragePreset = "fs" | "virtual";
179
+ /**
180
+ * Interface defining the methods and properties for a storage adapter.
181
+ */
182
+ interface StorageAdapter {
183
+ /**
184
+ * A name identifying the storage adapter type.
185
+ */
186
+ name: string;
187
+ /**
188
+ * The storage preset for the adapter.
189
+ *
190
+ * @remarks
191
+ * This can be used as an alternate way to identify the type of storage being used.
192
+ */
193
+ preset?: StoragePreset | null;
194
+ /**
195
+ * Checks if a key exists in the storage.
196
+ *
197
+ * @param key - The key to check for existence.
198
+ * @returns A promise that resolves to `true` if the key exists, otherwise `false`.
199
+ */
200
+ exists: (key: string) => Promise<boolean>;
201
+ /**
202
+ * Synchronously checks if a key exists in the storage.
203
+ *
204
+ * @param key - The key to check for existence.
205
+ * @returns Returns `true` if the key exists, otherwise `false`.
206
+ */
207
+ existsSync: (key: string) => boolean;
208
+ /**
209
+ * Read a value associated with a key from the storage.
210
+ *
211
+ * @param key - The key to read the value for.
212
+ * @returns A promise that resolves to the value if found, otherwise `null`.
213
+ */
214
+ get: (key: string) => Promise<string | null>;
215
+ /**
216
+ * Synchronously reads the value associated with a key from the storage.
217
+ *
218
+ * @param key - The key to read the value for.
219
+ * @returns The value if found, otherwise `null`.
220
+ */
221
+ getSync: (key: string) => string | null;
222
+ /**
223
+ * Writes a value to the storage for the given key.
224
+ *
225
+ * @param key - The key to associate the value with.
226
+ * @param value - The value to store.
227
+ */
228
+ set: (key: string, value: string) => Promise<void>;
229
+ /**
230
+ * Synchronously writes a value to the storage for the given key.
231
+ *
232
+ * @param key - The key to associate the value with.
233
+ * @param value - The value to store.
234
+ */
235
+ setSync: (key: string, value: string) => void;
236
+ /**
237
+ * Removes a value from the storage.
238
+ *
239
+ * @param key - The key whose value should be removed.
240
+ */
241
+ remove: (key: string) => Promise<void>;
242
+ /**
243
+ * Synchronously removes a value from the storage.
244
+ *
245
+ * @param key - The key whose value should be removed.
246
+ */
247
+ removeSync: (key: string) => void;
248
+ /**
249
+ * Creates a directory at the specified path.
250
+ *
251
+ * @param dirPath - The path of the directory to create.
252
+ */
253
+ mkdir: (dirPath: string) => Promise<void>;
254
+ /**
255
+ * Synchronously creates a directory at the specified path.
256
+ *
257
+ * @param dirPath - The path of the directory to create.
258
+ */
259
+ mkdirSync: (dirPath: string) => void;
260
+ /**
261
+ * Remove all entries from the storage that match the provided base path.
262
+ *
263
+ * @param base - The base path or prefix to clear entries from.
264
+ */
265
+ clear: (base?: string) => Promise<void>;
266
+ /**
267
+ * Synchronously remove all entries from the storage that match the provided base path.
268
+ *
269
+ * @param base - The base path or prefix to clear entries from.
270
+ */
271
+ clearSync: (base?: string) => void;
272
+ /**
273
+ * Lists all keys under the provided base path.
274
+ *
275
+ * @param base - The base path or prefix to list keys from.
276
+ * @returns A promise resolving to the list of keys.
277
+ */
278
+ list: (base?: string) => Promise<string[]>;
279
+ /**
280
+ * Synchronously lists all keys under the provided base path.
281
+ *
282
+ * @param base - The base path or prefix to list keys from.
283
+ * @returns The list of keys.
284
+ */
285
+ listSync: (base?: string) => string[];
286
+ /**
287
+ * Checks if the given key is a directory.
288
+ *
289
+ * @param key - The key to check.
290
+ * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
291
+ */
292
+ isDirectory: (key: string) => Promise<boolean>;
293
+ /**
294
+ * Synchronously checks if the given key is a directory.
295
+ *
296
+ * @param key - The key to check.
297
+ * @returns `true` if the key is a directory, otherwise `false`.
298
+ */
299
+ isDirectorySync: (key: string) => boolean;
300
+ /**
301
+ * Checks if the given key is a file.
302
+ *
303
+ * @param key - The key to check.
304
+ * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
305
+ */
306
+ isFile: (key: string) => Promise<boolean>;
307
+ /**
308
+ * Synchronously checks if the given key is a file.
309
+ *
310
+ * @param key - The key to check.
311
+ * @returns `true` if the key is a file, otherwise `false`.
312
+ */
313
+ isFileSync: (key: string) => boolean;
314
+ /**
315
+ * Releases any resources held by the storage adapter.
316
+ */
317
+ dispose: () => MaybePromise<void>;
318
+ }
319
+ /**
320
+ * A mapping of file paths to storage adapter names and their corresponding {@link StorageAdapter} instances.
321
+ */
322
+ type StoragePort = Record<string, StorageAdapter>;
323
+ interface VirtualFileMetadata {
324
+ /**
325
+ * The identifier for the file data.
326
+ */
327
+ id: string;
328
+ /**
329
+ * The timestamp of the virtual file.
330
+ */
331
+ timestamp: number;
332
+ /**
333
+ * The type of the file.
334
+ *
335
+ * @remarks
336
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
337
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
338
+ * - `entry`: Indicates that the file is an entry point for execution.
339
+ * - `normal`: Indicates that the file is a standard file without any special role.
340
+ */
341
+ type: string;
342
+ /**
343
+ * Additional metadata associated with the file.
344
+ */
345
+ properties: Record<string, string | undefined>;
346
+ }
347
+ interface VirtualFileData {
348
+ /**
349
+ * The identifier for the file data.
350
+ */
351
+ id?: string;
352
+ /**
353
+ * The contents of the virtual file.
354
+ */
355
+ code: string;
356
+ /**
357
+ * The type of the file.
358
+ *
359
+ * @remarks
360
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
361
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
362
+ * - `entry`: Indicates that the file is an entry point for execution.
363
+ * - `normal`: Indicates that the file is a standard file without any special role.
364
+ */
365
+ type?: string;
366
+ /**
367
+ * Additional metadata associated with the file.
368
+ */
369
+ properties?: Record<string, string | undefined>;
370
+ }
371
+ interface VirtualFile extends Required<VirtualFileData>, VirtualFileMetadata {
372
+ /**
373
+ * An additional name for the file.
374
+ */
375
+ path: string;
376
+ /**
377
+ * The timestamp of the virtual file.
378
+ */
379
+ timestamp: number;
380
+ }
381
+ interface WriteOptions {
382
+ /**
383
+ * Should the file skip formatting before being written?
384
+ *
385
+ * @defaultValue false
386
+ */
387
+ skipFormat?: boolean;
388
+ /**
389
+ * The storage preset or adapter name for the output file.
390
+ *
391
+ * @remarks
392
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
393
+ */
394
+ storage?: StoragePreset | string;
395
+ /**
396
+ * Additional metadata for the file.
397
+ */
398
+ meta?: Partial<VirtualFileMetadata>;
399
+ }
400
+ interface ResolveOptions$1 extends ResolveOptions {
401
+ /**
402
+ * If true, the module is being resolved as an entry point.
403
+ */
404
+ isEntry?: boolean;
405
+ /**
406
+ * If true, the resolver will skip alias resolution when resolving modules.
407
+ */
408
+ skipAlias?: boolean;
409
+ /**
410
+ * If true, the resolver will skip using the cache when resolving modules.
411
+ */
412
+ skipCache?: boolean;
413
+ /**
414
+ * An array of external modules or patterns to exclude from resolution.
415
+ */
416
+ external?: (string | RegExp)[];
417
+ /**
418
+ * An array of modules or patterns to include in the resolution, even if they are marked as external.
419
+ */
420
+ noExternal?: (string | RegExp)[];
421
+ /**
422
+ * An array of patterns to match when resolving modules.
423
+ */
424
+ skipNodeModulesBundle?: boolean;
425
+ }
426
+ interface VirtualFileSystemInterface {
427
+ /**
428
+ * The underlying file metadata.
429
+ */
430
+ metadata: Readonly<Record<string, VirtualFileMetadata>>;
431
+ /**
432
+ * A map of file paths to their module ids.
433
+ */
434
+ ids: Readonly<Record<string, string>>;
435
+ /**
436
+ * A map of module ids to their file paths.
437
+ */
438
+ paths: Readonly<Record<string, string>>;
439
+ /**
440
+ * Checks if a file exists in the virtual file system (VFS).
441
+ *
442
+ * @param path - The path or id of the file.
443
+ * @returns `true` if the file exists, otherwise `false`.
444
+ */
445
+ exists: (path: string) => Promise<boolean>;
446
+ /**
447
+ * Synchronously Checks if a file exists in the virtual file system (VFS).
448
+ *
449
+ * @param path - The path or id of the file.
450
+ * @returns `true` if the file exists, otherwise `false`.
451
+ */
452
+ existsSync: (path: string) => boolean;
453
+ /**
454
+ * Checks if a file is virtual in the virtual file system (VFS).
455
+ *
456
+ * @param path - The path or id of the file.
457
+ * @returns `true` if the file is virtual, otherwise `false`.
458
+ */
459
+ isVirtual: (path: string) => boolean;
460
+ /**
461
+ * Checks if the given key is a directory.
462
+ *
463
+ * @param key - The key to check.
464
+ * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
465
+ */
466
+ isDirectory: (key: string) => Promise<boolean>;
467
+ /**
468
+ * Synchronously checks if the given key is a directory.
469
+ *
470
+ * @param key - The key to check.
471
+ * @returns `true` if the key is a directory, otherwise `false`.
472
+ */
473
+ isDirectorySync: (key: string) => boolean;
474
+ /**
475
+ * Checks if the given key is a file.
476
+ *
477
+ * @param key - The key to check.
478
+ * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
479
+ */
480
+ isFile: (key: string) => Promise<boolean>;
481
+ /**
482
+ * Synchronously checks if the given key is a file.
483
+ *
484
+ * @param key - The key to check.
485
+ * @returns `true` if the key is a file, otherwise `false`.
486
+ */
487
+ isFileSync: (key: string) => boolean;
488
+ /**
489
+ * Gets the metadata of a file in the virtual file system (VFS).
490
+ *
491
+ * @param path - The path or id of the file.
492
+ * @returns The metadata of the file if it exists, otherwise undefined.
493
+ */
494
+ getMetadata: (path: string) => VirtualFileMetadata | undefined;
495
+ /**
496
+ * Lists files in a given path.
497
+ *
498
+ * @param path - The path to list files from.
499
+ * @returns An array of file names in the specified path.
500
+ */
501
+ listSync: (path: string) => string[];
502
+ /**
503
+ * Lists files in a given path.
504
+ *
505
+ * @param path - The path to list files from.
506
+ * @returns An array of file names in the specified path.
507
+ */
508
+ list: (path: string) => Promise<string[]>;
509
+ /**
510
+ * Removes a file or symbolic link in the virtual file system (VFS).
511
+ *
512
+ * @param path - The path to the file to remove.
513
+ * @returns A promise that resolves when the file is removed.
514
+ */
515
+ removeSync: (path: string) => void;
516
+ /**
517
+ * Asynchronously removes a file or symbolic link in the virtual file system (VFS).
518
+ *
519
+ * @param path - The path to the file to remove.
520
+ * @returns A promise that resolves when the file is removed.
521
+ */
522
+ remove: (path: string) => Promise<void>;
523
+ /**
524
+ * Reads a file from the virtual file system (VFS).
525
+ *
526
+ * @param path - The path or id of the file.
527
+ * @returns The contents of the file if it exists, otherwise undefined.
528
+ */
529
+ read: (path: string) => Promise<string | undefined>;
530
+ /**
531
+ * Reads a file from the virtual file system (VFS).
532
+ *
533
+ * @param path - The path or id of the file.
534
+ */
535
+ readSync: (path: string) => string | undefined;
536
+ /**
537
+ * Writes a file to the virtual file system (VFS).
538
+ *
539
+ * @param path - The path to the file.
540
+ * @param data - The contents of the file.
541
+ * @param options - Options for writing the file.
542
+ * @returns A promise that resolves when the file is written.
543
+ */
544
+ write: (path: string, data: string, options?: WriteOptions) => Promise<void>;
545
+ /**
546
+ * Writes a file to the virtual file system (VFS).
547
+ *
548
+ * @param path - The path to the file.
549
+ * @param data - The contents of the file.
550
+ * @param options - Options for writing the file.
551
+ */
552
+ writeSync: (path: string, data: string, options?: WriteOptions) => void;
553
+ /**
554
+ * Creates a directory at the specified path.
555
+ *
556
+ * @param dirPath - The path of the directory to create.
557
+ */
558
+ mkdir: (dirPath: string) => Promise<void>;
559
+ /**
560
+ * Synchronously creates a directory at the specified path.
561
+ *
562
+ * @param dirPath - The path of the directory to create.
563
+ */
564
+ mkdirSync: (dirPath: string) => void;
565
+ /**
566
+ * Moves a file from one path to another in the virtual file system (VFS).
567
+ *
568
+ * @param srcPath - The source path to move
569
+ * @param destPath - The destination path to move to
570
+ */
571
+ move: (srcPath: string, destPath: string) => Promise<void>;
572
+ /**
573
+ * Synchronously moves a file from one path to another in the virtual file system (VFS).
574
+ *
575
+ * @param srcPath - The source path to move
576
+ * @param destPath - The destination path to move to
577
+ */
578
+ moveSync: (srcPath: string, destPath: string) => void;
579
+ /**
580
+ * Copies a file from one path to another in the virtual file system (VFS).
581
+ *
582
+ * @param srcPath - The source path to copy
583
+ * @param destPath - The destination path to copy to
584
+ */
585
+ copy: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => Promise<void>;
586
+ /**
587
+ * Synchronously copies a file from one path to another in the virtual file system (VFS).
588
+ *
589
+ * @param srcPath - The source path to copy
590
+ * @param destPath - The destination path to copy to
591
+ */
592
+ copySync: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => void;
593
+ /**
594
+ * Glob files in the virtual file system (VFS) based on the provided pattern(s).
595
+ *
596
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
597
+ * @returns An array of file paths matching the provided pattern(s)
598
+ */
599
+ glob: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => Promise<string[]>;
600
+ /**
601
+ * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
602
+ *
603
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
604
+ * @returns An array of file paths matching the provided pattern(s)
605
+ */
606
+ globSync: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => string[];
607
+ /**
608
+ * A helper function to resolve modules using the Jiti resolver
609
+ *
610
+ * @remarks
611
+ * This function can be used to resolve modules relative to the project root directory.
612
+ *
613
+ * @example
614
+ * ```ts
615
+ * const resolvedPath = await context.resolve("some-module", "/path/to/importer");
616
+ * ```
617
+ *
618
+ * @param id - The module to resolve.
619
+ * @param importer - An optional path to the importer module.
620
+ * @param options - Additional resolution options.
621
+ * @returns A promise that resolves to the resolved module path.
622
+ */
623
+ resolve: (id: string, importer?: string, options?: ResolveOptions$1) => Promise<string | undefined>;
624
+ /**
625
+ * A synchronous helper function to resolve modules using the Jiti resolver
626
+ *
627
+ * @remarks
628
+ * This function can be used to resolve modules relative to the project root directory.
629
+ *
630
+ * @example
631
+ * ```ts
632
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
633
+ * ```
634
+ *
635
+ * @param id - The module to resolve.
636
+ * @param importer - An optional path to the importer module.
637
+ * @param options - Additional resolution options.
638
+ * @returns The resolved module path.
639
+ */
640
+ resolveSync: (id: string, importer?: string, options?: ResolveOptions$1) => string | undefined;
641
+ /**
642
+ * Resolves a given module ID using the configured aliases.
643
+ *
644
+ * @remarks
645
+ * This function can be used to map module IDs to different paths based on the alias configuration.
646
+ *
647
+ * @param id - The module ID to resolve.
648
+ * @returns The resolved module ID - after applying any configured aliases (this will be the same as the input ID if no aliases match).
649
+ */
650
+ resolveAlias: (id: string) => string;
651
+ /**
652
+ * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
653
+ */
654
+ dispose: () => Promise<void>;
655
+ }
656
+ //#endregion
657
+ //#region ../powerlines/src/types/commands.d.ts
658
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
659
+ type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
660
+ //#endregion
661
+ //#region ../powerlines/src/types/resolved.d.ts
662
+ interface ResolvedEntryTypeDefinition extends TypeDefinition {
663
+ /**
664
+ * The user provided entry point in the source code
665
+ */
666
+ input?: TypeDefinition;
667
+ /**
668
+ * An optional name to use in the package export during the build process
669
+ */
670
+ output?: string;
671
+ }
672
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "ssr">> & {
673
+ /**
674
+ * The name of the environment
675
+ */
676
+ name: string;
677
+ /**
678
+ * Configuration options for the preview server
679
+ */
680
+ preview?: ResolvedPreviewOptions;
681
+ };
682
+ type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
683
+ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets" | "storage"> & {
684
+ assets: ResolvedAssetGlob[];
685
+ }> & Pick<OutputConfig, "storage">;
686
+ /**
687
+ * The resolved options for the Powerlines project configuration.
688
+ */
689
+ type ResolvedConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = Omit<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
690
+ /**
691
+ * The configuration options that were provided inline to the Powerlines CLI.
692
+ */
693
+ inlineConfig: InlineConfig<TUserConfig>;
694
+ /**
695
+ * The original configuration options that were provided by the user to the Powerlines process.
696
+ */
697
+ userConfig: TUserConfig;
698
+ /**
699
+ * A string identifier for the Powerlines command being executed.
700
+ */
701
+ command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
702
+ /**
703
+ * The root directory of the project's source code
704
+ *
705
+ * @defaultValue "\{projectRoot\}/src"
706
+ */
707
+ sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
708
+ /**
709
+ * The root directory of the project.
710
+ */
711
+ projectRoot: NonUndefined<TUserConfig["root"]>;
712
+ /**
713
+ * The type of project being built.
714
+ */
715
+ projectType: NonUndefined<TUserConfig["type"]>;
716
+ /**
717
+ * The output configuration options to use for the build process
718
+ */
719
+ output: OutputResolvedConfig;
720
+ /**
721
+ * Configuration provided to build processes
722
+ *
723
+ * @remarks
724
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
725
+ */
726
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
727
+ /**
728
+ * The log level to use for the Powerlines processes.
729
+ *
730
+ * @defaultValue "info"
731
+ */
732
+ logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
733
+ };
734
+ type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
735
+ //#endregion
736
+ //#region ../powerlines/src/types/plugin.d.ts
737
+ interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
738
+ /**
739
+ * The order in which the plugin should be applied.
740
+ */
741
+ order?: "pre" | "post" | null | undefined;
742
+ /**
743
+ * A filter to determine when the hook should be called.
744
+ */
745
+ filter?: Pick<HookFilter, TFilter>;
746
+ /**
747
+ * The hook function to be called.
748
+ */
749
+ handler: THookFunction;
750
+ }
751
+ type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
752
+ /**
753
+ * A result returned by the plugin from the `types` hook that describes the declaration types output file.
754
+ */
755
+ interface TypesResult {
756
+ directives?: string[];
757
+ code: string;
758
+ }
759
+ type DeepPartial$1<T> = { [K in keyof T]?: DeepPartial$1<T[K]> };
760
+ type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial$1<TContext["config"]> & Record<string, any>;
761
+ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
762
+ /**
763
+ * A function that returns configuration options to be merged with the build context's options.
764
+ *
765
+ * @remarks
766
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
767
+ *
768
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect.
769
+ *
770
+ * @see https://vitejs.dev/guide/api-plugin#config
771
+ *
772
+ * @param this - The build context.
773
+ * @param config - The partial configuration object to be modified.
774
+ * @returns A promise that resolves to a partial configuration object.
775
+ */
776
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
777
+ /**
778
+ * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.
779
+ *
780
+ * @remarks
781
+ * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
782
+ *
783
+ * @see https://vitejs.dev/guide/api-plugin#configenvironment
784
+ *
785
+ * @param this - The build context.
786
+ * @param name - The name of the environment being configured.
787
+ * @param environment - The Vite-like environment object containing information about the current build environment.
788
+ * @returns A promise that resolves when the hook is complete.
789
+ */
790
+ configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
791
+ /**
792
+ * A hook that is called when the plugin is resolved.
793
+ *
794
+ * @see https://vitejs.dev/guide/api-plugin#configresolved
795
+ *
796
+ * @param this - The build context.
797
+ * @returns A promise that resolves when the hook is complete.
798
+ */
799
+ configResolved: (this: TContext) => MaybePromise<void>;
800
+ /**
801
+ * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
802
+ *
803
+ * @param this - The build context.
804
+ * @param code - The source code to generate types for.
805
+ * @returns A promise that resolves when the hook is complete.
806
+ */
807
+ types: (this: TContext, code: string) => MaybePromise<TypesResult | string | undefined | null>;
808
+ /**
809
+ * A hook that is called at the start of the build process.
810
+ *
811
+ * @param this - The build context and unplugin build context.
812
+ * @returns A promise that resolves when the hook is complete.
813
+ */
814
+ buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
815
+ /**
816
+ * A hook that is called at the end of the build process.
817
+ *
818
+ * @param this - The build context and unplugin build context.
819
+ * @returns A promise that resolves when the hook is complete.
820
+ */
821
+ buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
822
+ /**
823
+ * A hook that is called to transform the source code.
824
+ *
825
+ * @param this - The build context, unplugin build context, and unplugin context.
826
+ * @param code - The source code to transform.
827
+ * @param id - The identifier of the source code.
828
+ * @returns A promise that resolves when the hook is complete.
829
+ */
830
+ transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
831
+ /**
832
+ * A hook that is called to load the source code.
833
+ *
834
+ * @param this - The build context, unplugin build context, and unplugin context.
835
+ * @param id - The identifier of the source code.
836
+ * @returns A promise that resolves when the hook is complete.
837
+ */
838
+ load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
839
+ /**
840
+ * A hook that is called to resolve the identifier of the source code.
841
+ *
842
+ * @param this - The build context, unplugin build context, and unplugin context.
843
+ * @param id - The identifier of the source code.
844
+ * @param importer - The importer of the source code.
845
+ * @param options - The options for resolving the identifier.
846
+ * @returns A promise that resolves when the hook is complete.
847
+ */
848
+ resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
849
+ isEntry: boolean;
850
+ }) => MaybePromise<string | ExternalIdResult | null | undefined>;
851
+ /**
852
+ * A hook that is called to write the bundle to disk.
853
+ *
854
+ * @param this - The build context.
855
+ * @returns A promise that resolves when the hook is complete.
856
+ */
857
+ writeBundle: (this: TContext) => MaybePromise<void>;
858
+ }
859
+ type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant$1 extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant$1] = Required<UnpluginOptions>[TBuildVariant$1]> = { [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey] };
860
+ type ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant$1 extends UnpluginBuildVariant = UnpluginBuildVariant> = { [TKey in keyof BuildPlugin<TContext, TBuildVariant$1> & string as `${TBuildVariant$1}:${TKey}`]: BuildPlugin<TContext, TBuildVariant$1>[TKey] };
861
+ type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
862
+ type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
863
+ type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]> } & {
864
+ /**
865
+ * A function that returns configuration options to be merged with the build context's options.
866
+ *
867
+ * @remarks
868
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
869
+ *
870
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
871
+ *
872
+ * @see https://vitejs.dev/guide/api-plugin#config
873
+ *
874
+ * @param this - The build context.
875
+ * @param config - The partial configuration object to be modified.
876
+ * @returns A promise that resolves to a partial configuration object.
877
+ */
878
+ config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
879
+ /**
880
+ * A hook that is called to transform the source code.
881
+ *
882
+ * @param this - The build context, unplugin build context, and unplugin context.
883
+ * @param code - The source code to transform.
884
+ * @param id - The identifier of the source code.
885
+ * @returns A promise that resolves when the hook is complete.
886
+ */
887
+ transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
888
+ /**
889
+ * A hook that is called to load the source code.
890
+ *
891
+ * @param this - The build context, unplugin build context, and unplugin context.
892
+ * @param id - The identifier of the source code.
893
+ * @returns A promise that resolves when the hook is complete.
894
+ */
895
+ load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
896
+ /**
897
+ * A hook that is called to resolve the identifier of the source code.
898
+ *
899
+ * @param this - The build context, unplugin build context, and unplugin context.
900
+ * @param id - The identifier of the source code.
901
+ * @param importer - The importer of the source code.
902
+ * @param options - The options for resolving the identifier.
903
+ * @returns A promise that resolves when the hook is complete.
904
+ */
905
+ resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
906
+ isEntry: boolean;
907
+ }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
908
+ };
909
+ type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
910
+ interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
911
+ /**
912
+ * The name of the plugin, for use in deduplication, error messages and logs.
913
+ */
914
+ name: string;
915
+ /**
916
+ * An API object that can be used for inter-plugin communication.
917
+ *
918
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
919
+ */
920
+ api?: Record<string, any>;
921
+ /**
922
+ * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
923
+ *
924
+ * @remarks
925
+ * The Plugin invocation order is as follows:
926
+ * - `enforce: 'pre'` plugins
927
+ * - `order: 'pre'` plugin hooks
928
+ * - any other plugins (normal)
929
+ * - `order: 'post'` plugin hooks
930
+ * - `enforce: 'post'` plugins
931
+ *
932
+ * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
933
+ * @see https://rollupjs.org/plugin-development/#build-hooks
934
+ * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
935
+ * @see https://esbuild.github.io/plugins/#concepts
936
+ */
937
+ enforce?: "pre" | "post";
938
+ /**
939
+ * A function to determine if two plugins are the same and can be de-duplicated.
940
+ *
941
+ * @remarks
942
+ * If this is not provided, plugins are de-duplicated by comparing their names.
943
+ *
944
+ * @param other - The other plugin to compare against.
945
+ * @returns `true` if the two plugins are the same, `false` otherwise.
946
+ */
947
+ dedupe?: false | ((other: Plugin<any>) => boolean);
948
+ /**
949
+ * A list of pre-requisite plugins that must be loaded before this plugin can be used.
950
+ */
951
+ /**
952
+ * Define environments where this plugin should be active. By default, the plugin is active in all environments.
953
+ *
954
+ * @param environment - The environment to check.
955
+ * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
956
+ */
957
+ applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
958
+ }
959
+ //#endregion
960
+ //#region ../powerlines/src/types/tsconfig.d.ts
961
+ type ReflectionMode = "default" | "explicit" | "never";
962
+ type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
963
+ /**
964
+ * Defines the level of reflection to be used during the transpilation process.
965
+ *
966
+ * @remarks
967
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
968
+ * - `minimal` - Only the essential type information is captured.
969
+ * - `normal` - Additional type information is captured, including some contextual data.
970
+ * - `verbose` - All available type information is captured, including detailed contextual data.
971
+ */
972
+ type ReflectionLevel = "minimal" | "normal" | "verbose";
973
+ interface DeepkitOptions {
974
+ /**
975
+ * Either true to activate reflection for all files compiled using this tsconfig,
976
+ * or a list of globs/file paths relative to this tsconfig.json.
977
+ * Globs/file paths can be prefixed with a ! to exclude them.
978
+ */
979
+ reflection?: RawReflectionMode;
980
+ /**
981
+ * Defines the level of reflection to be used during the transpilation process.
982
+ *
983
+ * @remarks
984
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
985
+ * - `minimal` - Only the essential type information is captured.
986
+ * - `normal` - Additional type information is captured, including some contextual data.
987
+ * - `verbose` - All available type information is captured, including detailed contextual data.
988
+ */
989
+ reflectionLevel?: ReflectionLevel;
990
+ }
991
+ type TSCompilerOptions = CompilerOptions & DeepkitOptions;
992
+ /**
993
+ * The TypeScript compiler configuration.
994
+ *
995
+ * @see https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
996
+ */
997
+ interface TSConfig extends Omit<TsConfigJson, "reflection"> {
998
+ /**
999
+ * Either true to activate reflection for all files compiled using this tsconfig,
1000
+ * or a list of globs/file paths relative to this tsconfig.json.
1001
+ * Globs/file paths can be prefixed with a ! to exclude them.
1002
+ */
1003
+ reflection?: RawReflectionMode;
1004
+ /**
1005
+ * Defines the level of reflection to be used during the transpilation process.
1006
+ *
1007
+ * @remarks
1008
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
1009
+ * - `minimal` - Only the essential type information is captured.
1010
+ * - `normal` - Additional type information is captured, including some contextual data.
1011
+ * - `verbose` - All available type information is captured, including detailed contextual data.
1012
+ */
1013
+ reflectionLevel?: ReflectionLevel;
1014
+ /**
1015
+ * Instructs the TypeScript compiler how to compile `.ts` files.
1016
+ */
1017
+ compilerOptions?: TSCompilerOptions;
1018
+ }
1019
+ type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
1020
+ originalTsconfigJson: TsConfigJson;
1021
+ tsconfigJson: TSConfig;
1022
+ tsconfigFilePath: string;
1023
+ };
1024
+ //#endregion
1025
+ //#region ../powerlines/src/types/config.d.ts
1026
+ type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
1027
+ /**
1028
+ * The {@link StormWorkspaceConfig | configuration} object for an entire Powerlines workspace
1029
+ */
1030
+ type WorkspaceConfig = Partial<StormWorkspaceConfig> & Required<Pick<StormWorkspaceConfig, "workspaceRoot">>;
1031
+ type PluginFactory<in out TContext extends PluginContext = PluginContext, TOptions = any> = (options: TOptions) => MaybePromise<Plugin<TContext> | Plugin<TContext>[]>;
1032
+ /**
1033
+ * A configuration tuple for a Powerlines plugin.
1034
+ */
1035
+ type PluginConfigTuple<TContext extends PluginContext = PluginContext, TOptions = any> = [string | PluginFactory<TContext, TOptions>, TOptions] | [Plugin<TContext>];
1036
+ /**
1037
+ * A configuration object for a Powerlines plugin.
1038
+ */
1039
+ type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions = any> = {
1040
+ plugin: string | PluginFactory<TContext, TOptions>;
1041
+ options: TOptions;
1042
+ } | {
1043
+ plugin: Plugin<TContext>;
1044
+ options?: never;
1045
+ };
1046
+ /**
1047
+ * A configuration tuple for a Powerlines plugin.
1048
+ */
1049
+ type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | PluginConfigTuple<TContext> | PluginConfigObject<TContext> | Promise<PluginConfig<TContext>> | PluginConfig<TContext>[];
1050
+ type ProjectType = "application" | "library";
1051
+ interface DeployConfig {
1052
+ /**
1053
+ * The deployment variant being used by the Powerlines engine.
1054
+ *
1055
+ * @example
1056
+ * ```ts
1057
+ * export default defineConfig({
1058
+ * deploy: {
1059
+ * variant: "cloudflare"
1060
+ * }
1061
+ * });
1062
+ *
1063
+ * ```
1064
+ */
1065
+ variant?: string;
1066
+ }
1067
+ interface OutputConfig {
1068
+ /**
1069
+ * The path to output the final compiled files to
1070
+ *
1071
+ * @remarks
1072
+ * If a value is not provided, Powerlines will attempt to:
1073
+ * 1. Use the `outDir` value in the `tsconfig.json` file.
1074
+ * 2. Use the `dist` directory in the project root directory.
1075
+ *
1076
+ * @defaultValue "dist/\{projectRoot\}"
1077
+ */
1078
+ outputPath?: string;
1079
+ /**
1080
+ * The output directory path for the project build.
1081
+ *
1082
+ * @remarks
1083
+ * This path is used to determine where the built files will be placed after the build process completes. This will be used in scenarios where the monorepo uses TSConfig paths to link packages together.
1084
+ *
1085
+ * @defaultValue "\{projectRoot\}/dist"
1086
+ */
1087
+ buildPath?: string;
1088
+ /**
1089
+ * The folder where the generated runtime artifacts will be located
1090
+ *
1091
+ * @remarks
1092
+ * This folder will contain all runtime artifacts and builtins generated during the "prepare" phase.
1093
+ *
1094
+ * @defaultValue "\{projectRoot\}/.powerlines"
1095
+ */
1096
+ artifactsPath?: string;
1097
+ /**
1098
+ * The path of the generated runtime declaration file relative to the workspace root.
1099
+ *
1100
+ * @defaultValue "\{projectRoot\}/powerlines.d.ts"
1101
+ */
1102
+ dts?: string | false;
1103
+ /**
1104
+ * A prefix to use for identifying builtin modules
1105
+ *
1106
+ * @remarks
1107
+ * This prefix will be used to identify all builtin modules generated during the "prepare" phase. An example builtin ID for a module called `"utils"` would be `"{builtinPrefix}:utils"`.
1108
+ *
1109
+ * @defaultValue "powerlines"
1110
+ */
1111
+ builtinPrefix?: string;
1112
+ /**
1113
+ * The module format of the output files
1114
+ *
1115
+ * @remarks
1116
+ * This option can be a single format or an array of formats. If an array is provided, multiple builds will be generated for each format.
1117
+ *
1118
+ * @defaultValue "esm"
1119
+ */
1120
+ format?: Format | Format[];
1121
+ /**
1122
+ * A list of assets to copy to the output directory
1123
+ *
1124
+ * @remarks
1125
+ * The assets can be specified as a string (path to the asset) or as an object with a `glob` property (to match multiple files). The paths are relative to the project root directory.
1126
+ */
1127
+ assets?: Array<string | AssetGlob>;
1128
+ /**
1129
+ * A string preset or a custom {@link StoragePort} to provide fine-grained control over generated/output file storage.
1130
+ *
1131
+ * @remarks
1132
+ * If a string preset is provided, it must be one of the following values:
1133
+ * - `"virtual"`: Uses the local file system for storage.
1134
+ * - `"fs"`: Uses an in-memory virtual file system for storage.
1135
+ *
1136
+ * If a custom {@link StoragePort} is provided, it will be used for all file storage operations during the build process.
1137
+ *
1138
+ * @defaultValue "virtual"
1139
+ */
1140
+ storage?: StoragePort | StoragePreset;
1141
+ }
1142
+ interface BaseConfig {
1143
+ /**
1144
+ * The entry point(s) for the application
1145
+ */
1146
+ entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
1147
+ /**
1148
+ * Configuration for the output of the build process
1149
+ */
1150
+ output?: OutputConfig;
1151
+ /**
1152
+ * Configuration for cleaning the build artifacts
1153
+ *
1154
+ * @remarks
1155
+ * If set to `false`, the cleaning process will be disabled.
1156
+ */
1157
+ clean?: Record<string, any> | false;
1158
+ /**
1159
+ * Configuration for linting the source code
1160
+ *
1161
+ * @remarks
1162
+ * If set to `false`, linting will be disabled.
1163
+ */
1164
+ lint?: Record<string, any> | false;
1165
+ /**
1166
+ * Configuration for testing the source code
1167
+ *
1168
+ * @remarks
1169
+ * If set to `false`, testing will be disabled.
1170
+ */
1171
+ test?: Record<string, any> | false;
1172
+ /**
1173
+ * Configuration for the transformation of the source code
1174
+ */
1175
+ transform?: Record<string, any>;
1176
+ /**
1177
+ * Configuration provided to build processes
1178
+ *
1179
+ * @remarks
1180
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
1181
+ */
1182
+ build?: BuildConfig;
1183
+ /**
1184
+ * Configuration for documentation generation
1185
+ *
1186
+ * @remarks
1187
+ * This configuration will be used by the documentation generation plugins during the `docs` command.
1188
+ */
1189
+ docs?: Record<string, any>;
1190
+ /**
1191
+ * Configuration for deploying the source code
1192
+ *
1193
+ * @remarks
1194
+ * If set to `false`, the deployment will be disabled.
1195
+ */
1196
+ deploy?: DeployConfig | false;
1197
+ /**
1198
+ * The path to the tsconfig file to be used by the compiler
1199
+ *
1200
+ * @remarks
1201
+ * If a value is not provided, the plugin will attempt to find the `tsconfig.json` file in the project root directory. The parsed tsconfig compiler options will be merged with the {@link Options.tsconfigRaw} value (if provided).
1202
+ *
1203
+ * @defaultValue "\{projectRoot\}/tsconfig.json"
1204
+ */
1205
+ tsconfig?: string;
1206
+ /**
1207
+ * The raw {@link TSConfig} object to be used by the compiler. This object will be merged with the `tsconfig.json` file.
1208
+ *
1209
+ * @see https://www.typescriptlang.org/tsconfig
1210
+ *
1211
+ * @remarks
1212
+ * If populated, this option takes higher priority than `tsconfig`
1213
+ */
1214
+ tsconfigRaw?: TSConfig;
1215
+ }
1216
+ interface EnvironmentConfig extends BaseConfig {
1217
+ /**
1218
+ * Configuration options for the preview server
1219
+ */
1220
+ preview?: PreviewOptions;
1221
+ /**
1222
+ * A flag indicating whether the build is for a Server-Side Rendering environment.
1223
+ */
1224
+ ssr?: boolean;
1225
+ /**
1226
+ * Define if this environment is used for Server-Side Rendering
1227
+ *
1228
+ * @defaultValue "server" (if it isn't the client environment)
1229
+ */
1230
+ consumer?: "client" | "server";
1231
+ }
1232
+ interface CommonUserConfig extends BaseConfig {
1233
+ /**
1234
+ * The name of the project
1235
+ */
1236
+ name?: string;
1237
+ /**
1238
+ * The project display title
1239
+ *
1240
+ * @remarks
1241
+ * This option is used in documentation generation and other places where a human-readable title is needed.
1242
+ */
1243
+ title?: string;
1244
+ /**
1245
+ * A description of the project
1246
+ *
1247
+ * @remarks
1248
+ * If this option is not provided, the build process will try to use the \`description\` value from the `\package.json\` file.
1249
+ */
1250
+ description?: string;
1251
+ /**
1252
+ * The organization or author of the project
1253
+ *
1254
+ * @remarks
1255
+ * If this option is not provided, the build process will try to use the \`author\` value from the \`package.json\` file. If the \`author\` value cannot be determined, the {@link name | name configuration} will be used.
1256
+ */
1257
+ organization?: string;
1258
+ /**
1259
+ * The date to use for compatibility checks
1260
+ *
1261
+ * @remarks
1262
+ * This date can be used by plugins and build processes to determine compatibility with certain features or APIs. It is recommended to set this date to the date when the project was last known to be compatible with the desired features or APIs.
1263
+ *
1264
+ * @see https://developers.cloudflare.com/pages/platform/compatibility-dates/
1265
+ * @see https://docs.netlify.com/configure-builds/get-started/#set-a-compatibility-date
1266
+ * @see https://github.com/unjs/compatx
1267
+ */
1268
+ compatibilityDate?: DateString;
1269
+ /**
1270
+ * The log level to use for the Powerlines processes.
1271
+ *
1272
+ * @defaultValue "info"
1273
+ */
1274
+ logLevel?: LogLevelLabel | null;
1275
+ /**
1276
+ * A custom logger function to use for logging messages
1277
+ */
1278
+ customLogger?: LogFn;
1279
+ /**
1280
+ * Explicitly set a mode to run in. This mode will be used at various points throughout the Powerlines processes, such as when compiling the source code.
1281
+ *
1282
+ * @defaultValue "production"
1283
+ */
1284
+ mode?: "development" | "test" | "production";
1285
+ /**
1286
+ * The type of project being built
1287
+ *
1288
+ * @defaultValue "application"
1289
+ */
1290
+ type?: ProjectType;
1291
+ /**
1292
+ * The root directory of the project
1293
+ */
1294
+ root: string;
1295
+ /**
1296
+ * The root directory of the project's source code
1297
+ *
1298
+ * @defaultValue "\{root\}/src"
1299
+ */
1300
+ sourceRoot?: string;
1301
+ /**
1302
+ * A path to a custom configuration file to be used instead of the default `storm.json`, `powerlines.config.js`, or `powerlines.config.ts` files.
1303
+ *
1304
+ * @remarks
1305
+ * This option is useful for running Powerlines commands with different configuration files, such as in CI/CD environments or when testing different configurations.
1306
+ */
1307
+ configFile?: string;
1308
+ /**
1309
+ * Should the Powerlines CLI processes skip installing missing packages?
1310
+ *
1311
+ * @remarks
1312
+ * This option is useful for CI/CD environments where the installation of packages is handled by a different process.
1313
+ *
1314
+ * @defaultValue false
1315
+ */
1316
+ skipInstalls?: boolean;
1317
+ /**
1318
+ * Should the compiler processes skip any improvements that make use of cache?
1319
+ *
1320
+ * @defaultValue false
1321
+ */
1322
+ skipCache?: boolean;
1323
+ /**
1324
+ * A list of resolvable paths to plugins used during the build process
1325
+ */
1326
+ plugins?: PluginConfig<any>[];
1327
+ /**
1328
+ * Environment-specific configurations
1329
+ */
1330
+ environments?: Record<string, EnvironmentConfig>;
1331
+ /**
1332
+ * Should a single `build` process be ran for each environment?
1333
+ *
1334
+ * @remarks
1335
+ * This option determines how environments are managed during the `build` process. The available options are:
1336
+ *
1337
+ * - `false`: A separate build is ran for each environment.
1338
+ * - `true`: A single build is ran for all environments.
1339
+ *
1340
+ * @defaultValue false
1341
+ */
1342
+ singleBuild?: boolean;
1343
+ /**
1344
+ * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
1345
+ *
1346
+ * @remarks
1347
+ * If no values are provided for {@link OutputConfig.dts | output.dts}, {@link OutputConfig.builtinPrefix | output.builtinPrefix}, or {@link OutputConfig.artifactsPath | output.artifactsFolder}, this value will be used as the default.
1348
+ *
1349
+ * @defaultValue "powerlines"
1350
+ */
1351
+ framework?: string;
1352
+ }
1353
+ interface UserConfig$1<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant$1 extends string = any> extends Omit<CommonUserConfig, "build"> {
1354
+ /**
1355
+ * Configuration provided to build processes
1356
+ *
1357
+ * @remarks
1358
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
1359
+ */
1360
+ build: Omit<TBuildConfig, "override"> & {
1361
+ /**
1362
+ * The build variant being used by the Powerlines engine.
1363
+ */
1364
+ variant?: TBuildVariant$1;
1365
+ /**
1366
+ * An optional set of override options to apply to the selected build variant.
1367
+ *
1368
+ * @remarks
1369
+ * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
1370
+ */
1371
+ override?: Partial<TBuildResolvedConfig>;
1372
+ };
1373
+ }
1374
+ type ViteUserConfig = UserConfig$1<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
1375
+ type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
1376
+ /**
1377
+ * The configuration provided while executing Powerlines commands.
1378
+ */
1379
+ type InlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = Partial<TUserConfig> & {
1380
+ /**
1381
+ * A string identifier for the Powerlines command being executed
1382
+ */
1383
+ command: PowerlinesCommand;
1384
+ };
1385
+ type NewInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
1386
+ /**
1387
+ * A string identifier for the Powerlines command being executed
1388
+ */
1389
+ command: "new";
1390
+ /**
1391
+ * The package name (from the \`package.json\`) for the project that will be used in the \`new\` command to create a new project based on this configuration
1392
+ */
1393
+ packageName?: string;
1394
+ };
1395
+ type CleanInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
1396
+ /**
1397
+ * A string identifier for the Powerlines command being executed
1398
+ */
1399
+ command: "clean";
1400
+ };
1401
+ type PrepareInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
1402
+ /**
1403
+ * A string identifier for the Powerlines command being executed
1404
+ */
1405
+ command: "prepare";
1406
+ };
1407
+ type BuildInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
1408
+ /**
1409
+ * A string identifier for the Powerlines command being executed
1410
+ */
1411
+ command: "build";
1412
+ };
1413
+ type LintInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
1414
+ /**
1415
+ * A string identifier for the Powerlines command being executed
1416
+ */
1417
+ command: "lint";
1418
+ };
1419
+ type DocsInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
1420
+ /**
1421
+ * A string identifier for the Powerlines command being executed
1422
+ */
1423
+ command: "docs";
1424
+ };
1425
+ type DeployInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
1426
+ /**
1427
+ * A string identifier for the Powerlines command being executed
1428
+ */
1429
+ command: "deploy";
1430
+ };
1431
+ //#endregion
1432
+ //#region ../powerlines/src/types/hooks.d.ts
1433
+ type BaseHooks<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext>;
1434
+ type BaseHookKeys<TContext extends PluginContext = PluginContext> = keyof BaseHooks<TContext>;
1435
+ type ExternalHooks<TContext extends PluginContext = PluginContext> = ExternalPluginHookFunctions<TContext>;
1436
+ type ExternalHookKeys<TContext extends PluginContext = PluginContext> = keyof ExternalHooks<TContext>;
1437
+ type Hooks<TContext extends PluginContext = PluginContext> = PluginHookFunctions<TContext>;
1438
+ type HookKeys<TContext extends PluginContext = PluginContext> = keyof Hooks<TContext>;
1439
+ interface BaseHooksListItem<TContext extends PluginContext = PluginContext, TKey$1 extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> extends PluginHookObject<BaseHooks<TContext>[TKey$1]> {
1440
+ plugin: Plugin<TContext>;
1441
+ }
1442
+ interface BaseHooksList<TContext extends PluginContext = PluginContext, TKey$1 extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> {
1443
+ preOrdered?: BaseHooksListItem<TContext, TKey$1>[];
1444
+ preEnforced?: BaseHooksListItem<TContext, TKey$1>[];
1445
+ normal?: BaseHooksListItem<TContext, TKey$1>[];
1446
+ postEnforced?: BaseHooksListItem<TContext, TKey$1>[];
1447
+ postOrdered?: BaseHooksListItem<TContext, TKey$1>[];
1448
+ }
1449
+ interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey$1 extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
1450
+ plugin: Plugin<TContext>;
1451
+ handler: ExternalHooks<TContext>[TKey$1];
1452
+ }
1453
+ type HooksList<TContext extends PluginContext = PluginContext> = { [TKey in BaseHookKeys<TContext>]?: BaseHooksList<TContext, TKey> } & { [TKey in ExternalHookKeys<TContext>]?: ExternalHooksListItem<TContext, TKey>[] };
1454
+ type InferHookHandler<TContext extends PluginContext, TKey$1 extends HookKeys<TContext>> = Hooks<TContext>[TKey$1];
1455
+ type InferHookReturnType<TContext extends PluginContext, TKey$1 extends HookKeys<TContext>> = ReturnType<InferHookHandler<TContext, TKey$1>> extends Promise<infer U> ? U extends Promise<infer V> ? V : U : ReturnType<InferHookHandler<TContext, TKey$1>>;
1456
+ type InferHookParameters<TContext extends PluginContext, TKey$1 extends HookKeys<TContext>> = Parameters<InferHookHandler<TContext, TKey$1>>;
1457
+ //#endregion
1458
+ //#region ../powerlines/src/types/context.d.ts
1459
+ interface MetaInfo {
1460
+ /**
1461
+ * The checksum generated from the resolved options
1462
+ */
1463
+ checksum: string;
1464
+ /**
1465
+ * The build id
1466
+ */
1467
+ buildId: string;
1468
+ /**
1469
+ * The release id
1470
+ */
1471
+ releaseId: string;
1472
+ /**
1473
+ * The build timestamp
1474
+ */
1475
+ timestamp: number;
1476
+ /**
1477
+ * A hash that represents the path to the project root directory
1478
+ */
1479
+ projectRootHash: string;
1480
+ /**
1481
+ * A hash that represents the path to the project root directory
1482
+ */
1483
+ configHash: string;
1484
+ }
1485
+ interface Resolver extends Jiti {
1486
+ plugin: Jiti;
1487
+ }
1488
+ interface TransformResult$1 {
1489
+ code: string;
1490
+ map: SourceMap | null;
1491
+ }
1492
+ interface SelectHooksOptions {
1493
+ order?: "pre" | "post" | "normal";
1494
+ }
1495
+ /**
1496
+ * Options for initializing or updating the context with new configuration values
1497
+ */
1498
+ interface InitContextOptions {
1499
+ /**
1500
+ * If false, the plugin will be loaded after all other plugins.
1501
+ *
1502
+ * @defaultValue true
1503
+ */
1504
+ isHighPriority: boolean;
1505
+ }
1506
+ /**
1507
+ * Options for fetch requests made via the context's {@link Context.fetch} method
1508
+ */
1509
+ interface FetchOptions extends FetchRequestOptions {
1510
+ /**
1511
+ * An indicator specifying that the request should bypass any caching
1512
+ */
1513
+ skipCache?: boolean;
1514
+ }
1515
+ /**
1516
+ * Options for parsing code using [Oxc-Parser](https://github.com/oxc/oxc)
1517
+ */
1518
+ interface ParseOptions extends ParserOptions {
1519
+ /**
1520
+ * When true this allows return statements to be outside functions to e.g. support parsing CommonJS code.
1521
+ */
1522
+ allowReturnOutsideFunction?: boolean;
1523
+ }
1524
+ interface EmitOptions extends WriteOptions {
1525
+ /**
1526
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
1527
+ */
1528
+ emitWithBundler?: boolean;
1529
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
1530
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
1531
+ }
1532
+ /**
1533
+ * Options for emitting entry virtual files
1534
+ */
1535
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
1536
+ /**
1537
+ * The unresolved Powerlines context.
1538
+ *
1539
+ * @remarks
1540
+ * This context is used before the user configuration has been fully resolved after the `config`.
1541
+ */
1542
+ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1543
+ /**
1544
+ * The Storm workspace configuration
1545
+ */
1546
+ workspaceConfig: WorkspaceConfig;
1547
+ /**
1548
+ * An object containing the options provided to Powerlines
1549
+ */
1550
+ config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
1551
+ projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
1552
+ sourceRoot: NonUndefined<TResolvedConfig["userConfig"]["sourceRoot"]>;
1553
+ output: TResolvedConfig["output"];
1554
+ };
1555
+ /**
1556
+ * A logging function for the Powerlines engine
1557
+ */
1558
+ log: LogFn;
1559
+ /**
1560
+ * A logging function for fatal messages
1561
+ */
1562
+ fatal: (message: string | UnpluginMessage) => void;
1563
+ /**
1564
+ * A logging function for error messages
1565
+ */
1566
+ error: (message: string | UnpluginMessage) => void;
1567
+ /**
1568
+ * A logging function for warning messages
1569
+ */
1570
+ warn: (message: string | UnpluginMessage) => void;
1571
+ /**
1572
+ * A logging function for informational messages
1573
+ */
1574
+ info: (message: string | UnpluginMessage) => void;
1575
+ /**
1576
+ * A logging function for debug messages
1577
+ */
1578
+ debug: (message: string | UnpluginMessage) => void;
1579
+ /**
1580
+ * A logging function for trace messages
1581
+ */
1582
+ trace: (message: string | UnpluginMessage) => void;
1583
+ /**
1584
+ * The metadata information
1585
+ */
1586
+ meta: MetaInfo;
1587
+ /**
1588
+ * The metadata information currently written to disk
1589
+ */
1590
+ persistedMeta?: MetaInfo;
1591
+ /**
1592
+ * The Powerlines artifacts directory
1593
+ */
1594
+ artifactsPath: string;
1595
+ /**
1596
+ * The path to the Powerlines builtin runtime modules directory
1597
+ */
1598
+ builtinsPath: string;
1599
+ /**
1600
+ * The path to the Powerlines entry modules directory
1601
+ */
1602
+ entryPath: string;
1603
+ /**
1604
+ * The path to the Powerlines TypeScript declaration files directory
1605
+ */
1606
+ dtsPath: string;
1607
+ /**
1608
+ * The path to a directory where the reflection data buffers (used by the build processes) are stored
1609
+ */
1610
+ dataPath: string;
1611
+ /**
1612
+ * The path to a directory where the project cache (used by the build processes) is stored
1613
+ */
1614
+ cachePath: string;
1615
+ /**
1616
+ * The Powerlines environment paths
1617
+ */
1618
+ envPaths: EnvPaths;
1619
+ /**
1620
+ * The file system path to the Powerlines package installation
1621
+ */
1622
+ powerlinesPath: string;
1623
+ /**
1624
+ * The relative path to the Powerlines workspace root directory
1625
+ */
1626
+ relativeToWorkspaceRoot: string;
1627
+ /**
1628
+ * The project's `package.json` file content
1629
+ */
1630
+ packageJson: PackageJson & Record<string, any>;
1631
+ /**
1632
+ * The project's `project.json` file content
1633
+ */
1634
+ projectJson?: Record<string, any>;
1635
+ /**
1636
+ * The dependency installations required by the project
1637
+ */
1638
+ dependencies: Record<string, string | Range>;
1639
+ /**
1640
+ * The development dependency installations required by the project
1641
+ */
1642
+ devDependencies: Record<string, string | Range>;
1643
+ /**
1644
+ * The parsed TypeScript configuration from the `tsconfig.json` file
1645
+ */
1646
+ tsconfig: ParsedTypeScriptConfig;
1647
+ /**
1648
+ * The entry points of the source code
1649
+ */
1650
+ entry: ResolvedEntryTypeDefinition[];
1651
+ /**
1652
+ * The virtual file system manager used during the build process to reference generated runtime files
1653
+ */
1654
+ fs: VirtualFileSystemInterface;
1655
+ /**
1656
+ * The Jiti module resolver
1657
+ */
1658
+ resolver: Resolver;
1659
+ /**
1660
+ * The builtin module id that exist in the Powerlines virtual file system
1661
+ */
1662
+ builtins: string[];
1663
+ /**
1664
+ * The {@link Project} instance used for type reflection and module manipulation
1665
+ *
1666
+ * @see https://ts-morph.com/
1667
+ *
1668
+ * @remarks
1669
+ * This instance is created lazily on first access.
1670
+ */
1671
+ program: Project;
1672
+ /**
1673
+ * A function to perform HTTP fetch requests
1674
+ *
1675
+ * @remarks
1676
+ * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
1677
+ *
1678
+ * @example
1679
+ * ```ts
1680
+ * const response = await context.fetch("https://api.example.com/data");
1681
+ * const data = await response.json();
1682
+ * ```
1683
+ *
1684
+ * @see https://github.com/nodejs/undici
1685
+ *
1686
+ * @param input - The URL to fetch.
1687
+ * @param options - The fetch request options.
1688
+ * @returns A promise that resolves to a response returned by the fetch.
1689
+ */
1690
+ fetch: (input: RequestInfo, options?: FetchOptions) => Promise<Response>;
1691
+ /**
1692
+ * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
1693
+ *
1694
+ * @remarks
1695
+ * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
1696
+ *
1697
+ * @example
1698
+ * ```ts
1699
+ * const ast = context.parse("const x: number = 42;");
1700
+ * ```
1701
+ *
1702
+ * @see https://rollupjs.org/plugin-development/#this-parse
1703
+ * @see https://github.com/oxc/oxc
1704
+ *
1705
+ * @param code - The source code to parse.
1706
+ * @param options - The options to pass to the parser.
1707
+ * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
1708
+ */
1709
+ parse: (code: string, options?: ParseOptions) => Promise<ParseResult>;
1710
+ /**
1711
+ * A helper function to resolve modules using the Jiti resolver
1712
+ *
1713
+ * @remarks
1714
+ * This function can be used to resolve modules relative to the project root directory.
1715
+ *
1716
+ * @example
1717
+ * ```ts
1718
+ * const resolvedPath = await context.resolve("some-module", "/path/to/importer");
1719
+ * ```
1720
+ *
1721
+ * @param id - The module to resolve.
1722
+ * @param importer - An optional path to the importer module.
1723
+ * @param options - Additional resolution options.
1724
+ * @returns A promise that resolves to the resolved module path.
1725
+ */
1726
+ resolve: (id: string, importer?: string, options?: ResolveOptions$1) => Promise<ExternalIdResult | undefined>;
1727
+ /**
1728
+ * A helper function to load modules using the Jiti resolver
1729
+ *
1730
+ * @remarks
1731
+ * This function can be used to load modules relative to the project root directory.
1732
+ *
1733
+ * @example
1734
+ * ```ts
1735
+ * const module = await context.load("some-module", "/path/to/importer");
1736
+ * ```
1737
+ *
1738
+ * @param id - The module to load.
1739
+ * @returns A promise that resolves to the loaded module.
1740
+ */
1741
+ load: (id: string) => Promise<TransformResult$1 | undefined>;
1742
+ /**
1743
+ * The Powerlines builtin virtual files
1744
+ */
1745
+ getBuiltins: () => Promise<VirtualFile[]>;
1746
+ /**
1747
+ * Resolves a file and writes it to the VFS if it does not already exist
1748
+ *
1749
+ * @param code - The source code of the file
1750
+ * @param path - The path to write the file to
1751
+ * @param options - Additional options for writing the file
1752
+ */
1753
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
1754
+ /**
1755
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
1756
+ *
1757
+ * @param code - The source code of the file
1758
+ * @param path - The path to write the file to
1759
+ * @param options - Additional options for writing the file
1760
+ */
1761
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
1762
+ /**
1763
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1764
+ *
1765
+ * @param code - The source code of the builtin file
1766
+ * @param id - The unique identifier of the builtin file
1767
+ * @param path - An optional path to write the builtin file to
1768
+ * @param options - Additional options for writing the builtin file
1769
+ */
1770
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
1771
+ /**
1772
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
1773
+ *
1774
+ * @param code - The source code of the builtin file
1775
+ * @param id - The unique identifier of the builtin file
1776
+ * @param path - An optional path to write the builtin file to
1777
+ * @param options - Additional options for writing the builtin file
1778
+ */
1779
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
1780
+ /**
1781
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1782
+ *
1783
+ * @param code - The source code of the entry file
1784
+ * @param path - An optional path to write the entry file to
1785
+ * @param options - Additional options for writing the entry file
1786
+ */
1787
+ emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
1788
+ /**
1789
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
1790
+ *
1791
+ * @param code - The source code of the entry file
1792
+ * @param path - An optional path to write the entry file to
1793
+ * @param options - Additional options for writing the entry file
1794
+ */
1795
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
1796
+ /**
1797
+ * A function to update the context fields using a new user configuration options
1798
+ */
1799
+ withUserConfig: (userConfig: UserConfig$1, options?: InitContextOptions) => Promise<void>;
1800
+ /**
1801
+ * A function to update the context fields using inline configuration options
1802
+ */
1803
+ withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
1804
+ /**
1805
+ * Create a new logger instance
1806
+ *
1807
+ * @param name - The name to use for the logger instance
1808
+ * @returns A logger function
1809
+ */
1810
+ createLog: (name: string | null) => LogFn;
1811
+ /**
1812
+ * Extend the current logger instance with a new name
1813
+ *
1814
+ * @param name - The name to use for the extended logger instance
1815
+ * @returns A logger function
1816
+ */
1817
+ extendLog: (name: string) => LogFn;
1818
+ /**
1819
+ * Generates a checksum representing the current context state
1820
+ *
1821
+ * @returns A promise that resolves to a string representing the checksum
1822
+ */
1823
+ generateChecksum: () => Promise<string>;
1824
+ }
1825
+ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
1826
+ /**
1827
+ * The fully resolved Powerlines configuration
1828
+ */
1829
+ config: TResolvedConfig;
1830
+ };
1831
+ interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1832
+ /**
1833
+ * The expected plugins options for the Powerlines project.
1834
+ *
1835
+ * @remarks
1836
+ * 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.
1837
+ */
1838
+ plugins: Plugin<PluginContext<TResolvedConfig>>[];
1839
+ /**
1840
+ * A function to add a plugin to the context and update the configuration options
1841
+ */
1842
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1843
+ /**
1844
+ * A table for storing the current context for each configured environment
1845
+ */
1846
+ environments: Record<string, EnvironmentContext<TResolvedConfig>>;
1847
+ /**
1848
+ * Retrieves the context for a specific environment by name
1849
+ *
1850
+ * @throws Will throw an error if the environment does not exist
1851
+ *
1852
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1853
+ * @returns A promise that resolves to the environment context.
1854
+ *
1855
+ * @example
1856
+ * ```ts
1857
+ * const devEnv = await apiContext.getEnvironment("development");
1858
+ * const defaultEnv = await apiContext.getEnvironment();
1859
+ * ```
1860
+ */
1861
+ getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
1862
+ /**
1863
+ * Safely retrieves the context for a specific environment by name
1864
+ *
1865
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1866
+ * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
1867
+ *
1868
+ * @example
1869
+ * ```ts
1870
+ * const devEnv = await apiContext.getEnvironmentSafe("development");
1871
+ * const defaultEnv = await apiContext.getEnvironmentSafe();
1872
+ * ```
1873
+ *
1874
+ * @remarks
1875
+ * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
1876
+ * This can be useful in scenarios where the existence of an environment is optional or uncertain.
1877
+ *
1878
+ * ```ts
1879
+ * const testEnv = await apiContext.getEnvironmentSafe("test");
1880
+ * if (testEnv) {
1881
+ * // Environment exists, safe to use it
1882
+ * } else {
1883
+ * // Environment does not exist, handle accordingly
1884
+ * }
1885
+ * ```
1886
+ *
1887
+ * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
1888
+ */
1889
+ getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
1890
+ /**
1891
+ * A function to copy the context and update the fields for a specific environment
1892
+ *
1893
+ * @param environment - The environment configuration to use.
1894
+ * @returns A new context instance with the updated environment.
1895
+ */
1896
+ in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
1897
+ /**
1898
+ * A function to merge all configured environments into a single context
1899
+ *
1900
+ * @returns A promise that resolves to the merged environment context.
1901
+ */
1902
+ toEnvironment: () => Promise<EnvironmentContext<TResolvedConfig>>;
1903
+ }
1904
+ interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1905
+ plugin: Plugin<PluginContext<TResolvedConfig>>;
1906
+ context: PluginContext<TResolvedConfig>;
1907
+ }
1908
+ interface SelectHooksResult<TResolvedConfig extends ResolvedConfig, TKey$1 extends HookKeys<PluginContext<TResolvedConfig>>> {
1909
+ handle: Hooks[TKey$1];
1910
+ context: PluginContext<TResolvedConfig>;
1911
+ }
1912
+ interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1913
+ /**
1914
+ * The expected plugins options for the Powerlines project.
1915
+ *
1916
+ * @remarks
1917
+ * 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.
1918
+ */
1919
+ plugins: EnvironmentContextPlugin<TResolvedConfig>[];
1920
+ /**
1921
+ * A function to add a plugin to the context and update the configuration options
1922
+ */
1923
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1924
+ /**
1925
+ * The environment specific resolved configuration
1926
+ */
1927
+ environment: EnvironmentResolvedConfig;
1928
+ /**
1929
+ * A table holding references to hook functions registered by plugins
1930
+ */
1931
+ hooks: HooksList<PluginContext<TResolvedConfig>>;
1932
+ /**
1933
+ * Retrieves the hook handlers for a specific hook name
1934
+ */
1935
+ selectHooks: <TKey$1 extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey$1, options?: SelectHooksOptions) => SelectHooksResult<TResolvedConfig, TKey$1>[];
1936
+ }
1937
+ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1938
+ /**
1939
+ * The environment specific resolved configuration
1940
+ */
1941
+ environment: EnvironmentResolvedConfig;
1942
+ /**
1943
+ * An alternative property name for the {@link log} property
1944
+ *
1945
+ * @remarks
1946
+ * This is provided for compatibility with other logging libraries that expect a `logger` property.
1947
+ */
1948
+ logger: LogFn;
1949
+ }
1950
+ type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
1951
+ //#endregion
1952
+ //#region src/types/plugin.d.ts
1953
+ type VitePluginOptions = Partial<ViteBuildConfig>;
1954
+ type VitePluginResolvedConfig = ViteResolvedConfig;
1955
+ type VitePluginContext<TResolvedConfig extends VitePluginResolvedConfig = VitePluginResolvedConfig> = PluginContext<TResolvedConfig>;
1956
+ declare type __ΩVitePluginOptions = any[];
1957
+ declare type __ΩVitePluginResolvedConfig = any[];
1958
+ declare type __ΩVitePluginContext = any[];
1959
+ //#endregion
1960
+ export { ResolvedConfig as C, Plugin as S, DocsInlineConfig as _, __ΩVitePluginOptions as a, PluginConfig as b, EnvironmentContext as c, HookKeys as d, InferHookParameters as f, DeployInlineConfig as g, CleanInlineConfig as h, __ΩVitePluginContext as i, PluginContext as l, BuildInlineConfig as m, VitePluginOptions as n, __ΩVitePluginResolvedConfig as o, InferHookReturnType as p, VitePluginResolvedConfig as r, APIContext as s, VitePluginContext as t, SelectHooksOptions as u, LintInlineConfig as v, PrepareInlineConfig as x, NewInlineConfig as y };