@powerlines/plugin-content-collections 0.1.47 → 0.1.49

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