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