@powerlines/plugin-tsdown 0.1.243 → 0.1.244

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