@powerlines/plugin-deepkit 0.11.102 → 0.11.103

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