@powerlines/plugin-image-compression 0.2.6 → 0.2.8

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