@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
@@ -1,514 +0,0 @@
1
- import { ResolveOptions, VirtualFile, VirtualFileSystemInterface, WriteOptions } from "./fs.mjs";
2
- import { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.mjs";
3
- import { Plugin } from "./plugin.mjs";
4
- import { ParsedTypeScriptConfig } from "./tsconfig.mjs";
5
- import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.mjs";
6
- import { HookKeys, Hooks, HooksList } from "./hooks.mjs";
7
- import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
8
- import { Project } from "ts-morph";
9
- import { EnvPaths } from "@stryke/env/get-env-paths";
10
- import { FetchRequestOptions } from "@stryke/http/fetch";
11
- import { ParseResult, ParserOptions } from "oxc-parser";
12
- import { RequestInfo, Response } from "undici";
13
- import { Jiti } from "jiti";
14
- import { SourceMap } from "magic-string";
15
- import { NonUndefined } from "@stryke/types/base";
16
- import { PackageJson } from "@stryke/types/package-json";
17
- import { Range } from "semver";
18
-
19
- //#region ../powerlines/src/types/context.d.ts
20
-
21
- interface MetaInfo {
22
- /**
23
- * The checksum generated from the resolved options
24
- */
25
- checksum: string;
26
- /**
27
- * The build id
28
- */
29
- buildId: string;
30
- /**
31
- * The release id
32
- */
33
- releaseId: string;
34
- /**
35
- * The build timestamp
36
- */
37
- timestamp: number;
38
- /**
39
- * A hash that represents the path to the project root directory
40
- */
41
- projectRootHash: string;
42
- /**
43
- * A hash that represents the path to the project root directory
44
- */
45
- configHash: string;
46
- }
47
- interface Resolver extends Jiti {
48
- plugin: Jiti;
49
- }
50
- interface TransformResult$1 {
51
- code: string;
52
- map: SourceMap | null;
53
- }
54
- interface SelectHooksOptions {
55
- order?: "pre" | "post" | "normal";
56
- }
57
- /**
58
- * Options for initializing or updating the context with new configuration values
59
- */
60
- interface InitContextOptions {
61
- /**
62
- * If false, the plugin will be loaded after all other plugins.
63
- *
64
- * @defaultValue true
65
- */
66
- isHighPriority: boolean;
67
- }
68
- /**
69
- * Options for fetch requests made via the context's {@link Context.fetch} method
70
- */
71
- interface FetchOptions extends FetchRequestOptions {
72
- /**
73
- * An indicator specifying that the request should bypass any caching
74
- */
75
- skipCache?: boolean;
76
- }
77
- /**
78
- * Options for parsing code using [Oxc-Parser](https://github.com/oxc/oxc)
79
- */
80
- interface ParseOptions extends ParserOptions {
81
- /**
82
- * When true this allows return statements to be outside functions to e.g. support parsing CommonJS code.
83
- */
84
- allowReturnOutsideFunction?: boolean;
85
- }
86
- interface EmitOptions extends WriteOptions {
87
- /**
88
- * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
89
- */
90
- emitWithBundler?: boolean;
91
- needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
92
- originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
93
- }
94
- /**
95
- * Options for emitting entry virtual files
96
- */
97
- type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
98
- /**
99
- * The unresolved Powerlines context.
100
- *
101
- * @remarks
102
- * This context is used before the user configuration has been fully resolved after the `config`.
103
- */
104
- interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
105
- /**
106
- * The Storm workspace configuration
107
- */
108
- workspaceConfig: WorkspaceConfig;
109
- /**
110
- * An object containing the options provided to Powerlines
111
- */
112
- config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
113
- projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
114
- sourceRoot: NonUndefined<TResolvedConfig["userConfig"]["sourceRoot"]>;
115
- output: TResolvedConfig["output"];
116
- };
117
- /**
118
- * A logging function for the Powerlines engine
119
- */
120
- log: LogFn;
121
- /**
122
- * A logging function for fatal messages
123
- */
124
- fatal: (message: string | UnpluginMessage) => void;
125
- /**
126
- * A logging function for error messages
127
- */
128
- error: (message: string | UnpluginMessage) => void;
129
- /**
130
- * A logging function for warning messages
131
- */
132
- warn: (message: string | UnpluginMessage) => void;
133
- /**
134
- * A logging function for informational messages
135
- */
136
- info: (message: string | UnpluginMessage) => void;
137
- /**
138
- * A logging function for debug messages
139
- */
140
- debug: (message: string | UnpluginMessage) => void;
141
- /**
142
- * A logging function for trace messages
143
- */
144
- trace: (message: string | UnpluginMessage) => void;
145
- /**
146
- * The metadata information
147
- */
148
- meta: MetaInfo;
149
- /**
150
- * The metadata information currently written to disk
151
- */
152
- persistedMeta?: MetaInfo;
153
- /**
154
- * The Powerlines artifacts directory
155
- */
156
- artifactsPath: string;
157
- /**
158
- * The path to the Powerlines builtin runtime modules directory
159
- */
160
- builtinsPath: string;
161
- /**
162
- * The path to the Powerlines entry modules directory
163
- */
164
- entryPath: string;
165
- /**
166
- * The path to the Powerlines TypeScript declaration files directory
167
- */
168
- dtsPath: string;
169
- /**
170
- * The path to a directory where the reflection data buffers (used by the build processes) are stored
171
- */
172
- dataPath: string;
173
- /**
174
- * The path to a directory where the project cache (used by the build processes) is stored
175
- */
176
- cachePath: string;
177
- /**
178
- * The Powerlines environment paths
179
- */
180
- envPaths: EnvPaths;
181
- /**
182
- * The file system path to the Powerlines package installation
183
- */
184
- powerlinesPath: string;
185
- /**
186
- * The relative path to the Powerlines workspace root directory
187
- */
188
- relativeToWorkspaceRoot: string;
189
- /**
190
- * The project's `package.json` file content
191
- */
192
- packageJson: PackageJson & Record<string, any>;
193
- /**
194
- * The project's `project.json` file content
195
- */
196
- projectJson?: Record<string, any>;
197
- /**
198
- * The dependency installations required by the project
199
- */
200
- dependencies: Record<string, string | Range>;
201
- /**
202
- * The development dependency installations required by the project
203
- */
204
- devDependencies: Record<string, string | Range>;
205
- /**
206
- * The parsed TypeScript configuration from the `tsconfig.json` file
207
- */
208
- tsconfig: ParsedTypeScriptConfig;
209
- /**
210
- * The entry points of the source code
211
- */
212
- entry: ResolvedEntryTypeDefinition[];
213
- /**
214
- * The virtual file system manager used during the build process to reference generated runtime files
215
- */
216
- fs: VirtualFileSystemInterface;
217
- /**
218
- * The Jiti module resolver
219
- */
220
- resolver: Resolver;
221
- /**
222
- * The builtin module id that exist in the Powerlines virtual file system
223
- */
224
- builtins: string[];
225
- /**
226
- * The {@link Project} instance used for type reflection and module manipulation
227
- *
228
- * @see https://ts-morph.com/
229
- *
230
- * @remarks
231
- * This instance is created lazily on first access.
232
- */
233
- program: Project;
234
- /**
235
- * A function to perform HTTP fetch requests
236
- *
237
- * @remarks
238
- * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
239
- *
240
- * @example
241
- * ```ts
242
- * const response = await context.fetch("https://api.example.com/data");
243
- * const data = await response.json();
244
- * ```
245
- *
246
- * @see https://github.com/nodejs/undici
247
- *
248
- * @param input - The URL to fetch.
249
- * @param options - The fetch request options.
250
- * @returns A promise that resolves to a response returned by the fetch.
251
- */
252
- fetch: (input: RequestInfo, options?: FetchOptions) => Promise<Response>;
253
- /**
254
- * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
255
- *
256
- * @remarks
257
- * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
258
- *
259
- * @example
260
- * ```ts
261
- * const ast = context.parse("const x: number = 42;");
262
- * ```
263
- *
264
- * @see https://rollupjs.org/plugin-development/#this-parse
265
- * @see https://github.com/oxc/oxc
266
- *
267
- * @param code - The source code to parse.
268
- * @param options - The options to pass to the parser.
269
- * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
270
- */
271
- parse: (code: string, options?: ParseOptions) => Promise<ParseResult>;
272
- /**
273
- * A helper function to resolve modules using the Jiti resolver
274
- *
275
- * @remarks
276
- * This function can be used to resolve modules relative to the project root directory.
277
- *
278
- * @example
279
- * ```ts
280
- * const resolvedPath = await context.resolve("some-module", "/path/to/importer");
281
- * ```
282
- *
283
- * @param id - The module to resolve.
284
- * @param importer - An optional path to the importer module.
285
- * @param options - Additional resolution options.
286
- * @returns A promise that resolves to the resolved module path.
287
- */
288
- resolve: (id: string, importer?: string, options?: ResolveOptions) => Promise<ExternalIdResult | undefined>;
289
- /**
290
- * A helper function to load modules using the Jiti resolver
291
- *
292
- * @remarks
293
- * This function can be used to load modules relative to the project root directory.
294
- *
295
- * @example
296
- * ```ts
297
- * const module = await context.load("some-module", "/path/to/importer");
298
- * ```
299
- *
300
- * @param id - The module to load.
301
- * @returns A promise that resolves to the loaded module.
302
- */
303
- load: (id: string) => Promise<TransformResult$1 | undefined>;
304
- /**
305
- * The Powerlines builtin virtual files
306
- */
307
- getBuiltins: () => Promise<VirtualFile[]>;
308
- /**
309
- * Resolves a file and writes it to the VFS if it does not already exist
310
- *
311
- * @param code - The source code of the file
312
- * @param path - The path to write the file to
313
- * @param options - Additional options for writing the file
314
- */
315
- emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
316
- /**
317
- * Synchronously resolves a file and writes it to the VFS if it does not already exist
318
- *
319
- * @param code - The source code of the file
320
- * @param path - The path to write the file to
321
- * @param options - Additional options for writing the file
322
- */
323
- emitSync: (code: string, path: string, options?: EmitOptions) => void;
324
- /**
325
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
326
- *
327
- * @param code - The source code of the builtin file
328
- * @param id - The unique identifier of the builtin file
329
- * @param path - An optional path to write the builtin file to
330
- * @param options - Additional options for writing the builtin file
331
- */
332
- emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
333
- /**
334
- * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
335
- *
336
- * @param code - The source code of the builtin file
337
- * @param id - The unique identifier of the builtin file
338
- * @param path - An optional path to write the builtin file to
339
- * @param options - Additional options for writing the builtin file
340
- */
341
- emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
342
- /**
343
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
344
- *
345
- * @param code - The source code of the entry file
346
- * @param path - An optional path to write the entry file to
347
- * @param options - Additional options for writing the entry file
348
- */
349
- emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
350
- /**
351
- * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
352
- *
353
- * @param code - The source code of the entry file
354
- * @param path - An optional path to write the entry file to
355
- * @param options - Additional options for writing the entry file
356
- */
357
- emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
358
- /**
359
- * A function to update the context fields using a new user configuration options
360
- */
361
- withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
362
- /**
363
- * A function to update the context fields using inline configuration options
364
- */
365
- withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
366
- /**
367
- * Create a new logger instance
368
- *
369
- * @param name - The name to use for the logger instance
370
- * @returns A logger function
371
- */
372
- createLog: (name: string | null) => LogFn;
373
- /**
374
- * Extend the current logger instance with a new name
375
- *
376
- * @param name - The name to use for the extended logger instance
377
- * @returns A logger function
378
- */
379
- extendLog: (name: string) => LogFn;
380
- /**
381
- * Generates a checksum representing the current context state
382
- *
383
- * @returns A promise that resolves to a string representing the checksum
384
- */
385
- generateChecksum: () => Promise<string>;
386
- }
387
- type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
388
- /**
389
- * The fully resolved Powerlines configuration
390
- */
391
- config: TResolvedConfig;
392
- };
393
- interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
394
- /**
395
- * The expected plugins options for the Powerlines project.
396
- *
397
- * @remarks
398
- * 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.
399
- */
400
- plugins: Plugin<PluginContext<TResolvedConfig>>[];
401
- /**
402
- * A function to add a plugin to the context and update the configuration options
403
- */
404
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
405
- /**
406
- * A table for storing the current context for each configured environment
407
- */
408
- environments: Record<string, EnvironmentContext<TResolvedConfig>>;
409
- /**
410
- * Retrieves the context for a specific environment by name
411
- *
412
- * @throws Will throw an error if the environment does not exist
413
- *
414
- * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
415
- * @returns A promise that resolves to the environment context.
416
- *
417
- * @example
418
- * ```ts
419
- * const devEnv = await apiContext.getEnvironment("development");
420
- * const defaultEnv = await apiContext.getEnvironment();
421
- * ```
422
- */
423
- getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
424
- /**
425
- * Safely retrieves the context for a specific environment by name
426
- *
427
- * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
428
- * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
429
- *
430
- * @example
431
- * ```ts
432
- * const devEnv = await apiContext.getEnvironmentSafe("development");
433
- * const defaultEnv = await apiContext.getEnvironmentSafe();
434
- * ```
435
- *
436
- * @remarks
437
- * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
438
- * This can be useful in scenarios where the existence of an environment is optional or uncertain.
439
- *
440
- * ```ts
441
- * const testEnv = await apiContext.getEnvironmentSafe("test");
442
- * if (testEnv) {
443
- * // Environment exists, safe to use it
444
- * } else {
445
- * // Environment does not exist, handle accordingly
446
- * }
447
- * ```
448
- *
449
- * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
450
- */
451
- getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
452
- /**
453
- * A function to copy the context and update the fields for a specific environment
454
- *
455
- * @param environment - The environment configuration to use.
456
- * @returns A new context instance with the updated environment.
457
- */
458
- in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
459
- /**
460
- * A function to merge all configured environments into a single context
461
- *
462
- * @returns A promise that resolves to the merged environment context.
463
- */
464
- toEnvironment: () => Promise<EnvironmentContext<TResolvedConfig>>;
465
- }
466
- interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
467
- plugin: Plugin<PluginContext<TResolvedConfig>>;
468
- context: PluginContext<TResolvedConfig>;
469
- }
470
- interface SelectHooksResult<TResolvedConfig extends ResolvedConfig, TKey extends HookKeys<PluginContext<TResolvedConfig>>> {
471
- handle: Hooks[TKey];
472
- context: PluginContext<TResolvedConfig>;
473
- }
474
- interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
475
- /**
476
- * The expected plugins options for the Powerlines project.
477
- *
478
- * @remarks
479
- * 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.
480
- */
481
- plugins: EnvironmentContextPlugin<TResolvedConfig>[];
482
- /**
483
- * A function to add a plugin to the context and update the configuration options
484
- */
485
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
486
- /**
487
- * The environment specific resolved configuration
488
- */
489
- environment: EnvironmentResolvedConfig;
490
- /**
491
- * A table holding references to hook functions registered by plugins
492
- */
493
- hooks: HooksList<PluginContext<TResolvedConfig>>;
494
- /**
495
- * Retrieves the hook handlers for a specific hook name
496
- */
497
- selectHooks: <TKey extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey, options?: SelectHooksOptions) => SelectHooksResult<TResolvedConfig, TKey>[];
498
- }
499
- interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
500
- /**
501
- * The environment specific resolved configuration
502
- */
503
- environment: EnvironmentResolvedConfig;
504
- /**
505
- * An alternative property name for the {@link log} property
506
- *
507
- * @remarks
508
- * This is provided for compatibility with other logging libraries that expect a `logger` property.
509
- */
510
- logger: LogFn;
511
- }
512
- type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
513
- //#endregion
514
- export { APIContext, BuildPluginContext, EnvironmentContext, PluginContext, SelectHooksOptions, UnresolvedContext };