@powerlines/plugin-oxc-transform 0.5.56 → 0.5.58

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