@powerlines/plugin-oxc-transform 0.5.67 → 0.5.69
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.
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +1 -1
- package/dist/powerlines/src/types/build.d.cts +139 -0
- package/dist/powerlines/src/types/build.d.mts +139 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +8 -0
- package/dist/powerlines/src/types/config.d.cts +345 -0
- package/dist/powerlines/src/types/config.d.mts +345 -0
- package/dist/powerlines/src/types/context.d.cts +347 -0
- package/dist/powerlines/src/types/context.d.mts +347 -0
- package/dist/powerlines/src/types/fs.d.cts +458 -0
- package/dist/powerlines/src/types/fs.d.mts +458 -0
- package/dist/powerlines/src/types/plugin.d.cts +232 -0
- package/dist/powerlines/src/types/plugin.d.mts +232 -0
- package/dist/powerlines/src/types/resolved.d.cts +81 -0
- package/dist/powerlines/src/types/resolved.d.mts +81 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -1
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +23 -1
- package/dist/types/plugin.d.mts +23 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +6 -6
- package/dist/index-BgAdqTbb.d.mts +0 -1
- package/dist/index-CEgs-Dz2.d.cts +0 -1
- package/dist/plugin-Biqbm7Ye.d.mts +0 -1655
- package/dist/plugin-Bvn-he2n.mjs +0 -1
- package/dist/plugin-CeRe_T8U.d.cts +0 -1655
- package/dist/plugin-DHXHjv16.cjs +0 -0
- package/dist/types-B7VYa_Pp.mjs +0 -1
- package/dist/types-DHkg7xmX.cjs +0 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
2
|
+
import { AssetGlob } from "@stryke/types/file";
|
|
3
|
+
import { ResolveOptions } from "@stryke/fs/resolve";
|
|
4
|
+
|
|
5
|
+
//#region ../powerlines/src/types/fs.d.ts
|
|
6
|
+
|
|
7
|
+
type StoragePreset = "fs" | "virtual";
|
|
8
|
+
/**
|
|
9
|
+
* Interface defining the methods and properties for a storage adapter.
|
|
10
|
+
*/
|
|
11
|
+
interface StorageAdapter {
|
|
12
|
+
/**
|
|
13
|
+
* A name identifying the storage adapter type.
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a key exists in the storage.
|
|
18
|
+
*
|
|
19
|
+
* @param key - The key to check for existence.
|
|
20
|
+
* @returns A promise that resolves to `true` if the key exists, otherwise `false`.
|
|
21
|
+
*/
|
|
22
|
+
exists: (key: string) => Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Synchronously checks if a key exists in the storage.
|
|
25
|
+
*
|
|
26
|
+
* @param key - The key to check for existence.
|
|
27
|
+
* @returns Returns `true` if the key exists, otherwise `false`.
|
|
28
|
+
*/
|
|
29
|
+
existsSync: (key: string) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Read a value associated with a key from the storage.
|
|
32
|
+
*
|
|
33
|
+
* @param key - The key to read the value for.
|
|
34
|
+
* @returns A promise that resolves to the value if found, otherwise `null`.
|
|
35
|
+
*/
|
|
36
|
+
get: (key: string) => Promise<string | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Synchronously reads the value associated with a key from the storage.
|
|
39
|
+
*
|
|
40
|
+
* @param key - The key to read the value for.
|
|
41
|
+
* @returns The value if found, otherwise `null`.
|
|
42
|
+
*/
|
|
43
|
+
getSync: (key: string) => string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Writes a value to the storage for the given key.
|
|
46
|
+
*
|
|
47
|
+
* @param key - The key to associate the value with.
|
|
48
|
+
* @param value - The value to store.
|
|
49
|
+
*/
|
|
50
|
+
set: (key: string, value: string) => Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Synchronously writes a value to the storage for the given key.
|
|
53
|
+
*
|
|
54
|
+
* @param key - The key to associate the value with.
|
|
55
|
+
* @param value - The value to store.
|
|
56
|
+
*/
|
|
57
|
+
setSync: (key: string, value: string) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Removes a value from the storage.
|
|
60
|
+
*
|
|
61
|
+
* @param key - The key whose value should be removed.
|
|
62
|
+
*/
|
|
63
|
+
remove: (key: string) => Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Synchronously removes a value from the storage.
|
|
66
|
+
*
|
|
67
|
+
* @param key - The key whose value should be removed.
|
|
68
|
+
*/
|
|
69
|
+
removeSync: (key: string) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a directory at the specified path.
|
|
72
|
+
*
|
|
73
|
+
* @param dirPath - The path of the directory to create.
|
|
74
|
+
*/
|
|
75
|
+
mkdir: (dirPath: string) => Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Synchronously creates a directory at the specified path.
|
|
78
|
+
*
|
|
79
|
+
* @param dirPath - The path of the directory to create.
|
|
80
|
+
*/
|
|
81
|
+
mkdirSync: (dirPath: string) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Remove all entries from the storage that match the provided base path.
|
|
84
|
+
*
|
|
85
|
+
* @param base - The base path or prefix to clear entries from.
|
|
86
|
+
*/
|
|
87
|
+
clear: (base?: string) => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Synchronously remove all entries from the storage that match the provided base path.
|
|
90
|
+
*
|
|
91
|
+
* @param base - The base path or prefix to clear entries from.
|
|
92
|
+
*/
|
|
93
|
+
clearSync: (base?: string) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Lists all keys under the provided base path.
|
|
96
|
+
*
|
|
97
|
+
* @param base - The base path or prefix to list keys from.
|
|
98
|
+
* @returns A promise resolving to the list of keys.
|
|
99
|
+
*/
|
|
100
|
+
list: (base?: string) => Promise<string[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Synchronously lists all keys under the provided base path.
|
|
103
|
+
*
|
|
104
|
+
* @param base - The base path or prefix to list keys from.
|
|
105
|
+
* @returns The list of keys.
|
|
106
|
+
*/
|
|
107
|
+
listSync: (base?: string) => string[];
|
|
108
|
+
/**
|
|
109
|
+
* Checks if the given key is a directory.
|
|
110
|
+
*
|
|
111
|
+
* @param key - The key to check.
|
|
112
|
+
* @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
|
|
113
|
+
*/
|
|
114
|
+
isDirectory: (key: string) => Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* Synchronously checks if the given key is a directory.
|
|
117
|
+
*
|
|
118
|
+
* @param key - The key to check.
|
|
119
|
+
* @returns `true` if the key is a directory, otherwise `false`.
|
|
120
|
+
*/
|
|
121
|
+
isDirectorySync: (key: string) => boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Checks if the given key is a file.
|
|
124
|
+
*
|
|
125
|
+
* @param key - The key to check.
|
|
126
|
+
* @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
|
|
127
|
+
*/
|
|
128
|
+
isFile: (key: string) => Promise<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Synchronously checks if the given key is a file.
|
|
131
|
+
*
|
|
132
|
+
* @param key - The key to check.
|
|
133
|
+
* @returns `true` if the key is a file, otherwise `false`.
|
|
134
|
+
*/
|
|
135
|
+
isFileSync: (key: string) => boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Releases any resources held by the storage adapter.
|
|
138
|
+
*/
|
|
139
|
+
dispose: () => MaybePromise<void>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A mapping of file paths to storage adapter names and their corresponding {@link StorageAdapter} instances.
|
|
143
|
+
*/
|
|
144
|
+
type StoragePort = Record<string, StorageAdapter>;
|
|
145
|
+
interface VirtualFileMetadata {
|
|
146
|
+
/**
|
|
147
|
+
* The identifier for the file data.
|
|
148
|
+
*/
|
|
149
|
+
id: string;
|
|
150
|
+
/**
|
|
151
|
+
* The timestamp of the virtual file.
|
|
152
|
+
*/
|
|
153
|
+
timestamp: number;
|
|
154
|
+
/**
|
|
155
|
+
* The type of the file.
|
|
156
|
+
*
|
|
157
|
+
* @remarks
|
|
158
|
+
* This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
|
|
159
|
+
* - `builtin`: Indicates that the file is a built-in module provided by the system.
|
|
160
|
+
* - `entry`: Indicates that the file is an entry point for execution.
|
|
161
|
+
* - `normal`: Indicates that the file is a standard file without any special role.
|
|
162
|
+
*/
|
|
163
|
+
type: string;
|
|
164
|
+
/**
|
|
165
|
+
* Additional metadata associated with the file.
|
|
166
|
+
*/
|
|
167
|
+
properties: Record<string, string>;
|
|
168
|
+
}
|
|
169
|
+
interface VirtualFileData {
|
|
170
|
+
/**
|
|
171
|
+
* The identifier for the file data.
|
|
172
|
+
*/
|
|
173
|
+
id?: string;
|
|
174
|
+
/**
|
|
175
|
+
* The contents of the virtual file.
|
|
176
|
+
*/
|
|
177
|
+
code: string;
|
|
178
|
+
/**
|
|
179
|
+
* The type of the file.
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
|
|
183
|
+
* - `builtin`: Indicates that the file is a built-in module provided by the system.
|
|
184
|
+
* - `entry`: Indicates that the file is an entry point for execution.
|
|
185
|
+
* - `normal`: Indicates that the file is a standard file without any special role.
|
|
186
|
+
*/
|
|
187
|
+
type?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Additional metadata associated with the file.
|
|
190
|
+
*/
|
|
191
|
+
properties?: Record<string, string>;
|
|
192
|
+
}
|
|
193
|
+
interface VirtualFile extends Required<VirtualFileData>, VirtualFileMetadata {
|
|
194
|
+
/**
|
|
195
|
+
* An additional name for the file.
|
|
196
|
+
*/
|
|
197
|
+
path: string;
|
|
198
|
+
/**
|
|
199
|
+
* The timestamp of the virtual file.
|
|
200
|
+
*/
|
|
201
|
+
timestamp: number;
|
|
202
|
+
}
|
|
203
|
+
interface WriteOptions {
|
|
204
|
+
/**
|
|
205
|
+
* Should the file skip formatting before being written?
|
|
206
|
+
*
|
|
207
|
+
* @defaultValue false
|
|
208
|
+
*/
|
|
209
|
+
skipFormat?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Additional metadata for the file.
|
|
212
|
+
*/
|
|
213
|
+
meta?: VirtualFileMetadata;
|
|
214
|
+
}
|
|
215
|
+
interface ResolveOptions$1 extends ResolveOptions {
|
|
216
|
+
/**
|
|
217
|
+
* If true, the module is being resolved as an entry point.
|
|
218
|
+
*/
|
|
219
|
+
isEntry?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* If true, the resolver will skip using the cache when resolving modules.
|
|
222
|
+
*/
|
|
223
|
+
skipCache?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* An array of external modules or patterns to exclude from resolution.
|
|
226
|
+
*/
|
|
227
|
+
external?: (string | RegExp)[];
|
|
228
|
+
/**
|
|
229
|
+
* An array of modules or patterns to include in the resolution, even if they are marked as external.
|
|
230
|
+
*/
|
|
231
|
+
noExternal?: (string | RegExp)[];
|
|
232
|
+
/**
|
|
233
|
+
* An array of patterns to match when resolving modules.
|
|
234
|
+
*/
|
|
235
|
+
skipNodeModulesBundle?: boolean;
|
|
236
|
+
}
|
|
237
|
+
interface VirtualFileSystemInterface {
|
|
238
|
+
/**
|
|
239
|
+
* The underlying file metadata.
|
|
240
|
+
*/
|
|
241
|
+
metadata: Readonly<Record<string, VirtualFileMetadata>>;
|
|
242
|
+
/**
|
|
243
|
+
* A map of file paths to their module ids.
|
|
244
|
+
*/
|
|
245
|
+
ids: Readonly<Record<string, string>>;
|
|
246
|
+
/**
|
|
247
|
+
* A map of module ids to their file paths.
|
|
248
|
+
*/
|
|
249
|
+
paths: Readonly<Record<string, string>>;
|
|
250
|
+
/**
|
|
251
|
+
* Checks if a file exists in the virtual file system (VFS).
|
|
252
|
+
*
|
|
253
|
+
* @param path - The path or id of the file.
|
|
254
|
+
* @returns `true` if the file exists, otherwise `false`.
|
|
255
|
+
*/
|
|
256
|
+
exists: (path: string) => Promise<boolean>;
|
|
257
|
+
/**
|
|
258
|
+
* Synchronously Checks if a file exists in the virtual file system (VFS).
|
|
259
|
+
*
|
|
260
|
+
* @param path - The path or id of the file.
|
|
261
|
+
* @returns `true` if the file exists, otherwise `false`.
|
|
262
|
+
*/
|
|
263
|
+
existsSync: (path: string) => boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Checks if a file is virtual in the virtual file system (VFS).
|
|
266
|
+
*
|
|
267
|
+
* @param path - The path or id of the file.
|
|
268
|
+
* @returns `true` if the file is virtual, otherwise `false`.
|
|
269
|
+
*/
|
|
270
|
+
isVirtual: (path: string) => boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Checks if the given key is a directory.
|
|
273
|
+
*
|
|
274
|
+
* @param key - The key to check.
|
|
275
|
+
* @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
|
|
276
|
+
*/
|
|
277
|
+
isDirectory: (key: string) => Promise<boolean>;
|
|
278
|
+
/**
|
|
279
|
+
* Synchronously checks if the given key is a directory.
|
|
280
|
+
*
|
|
281
|
+
* @param key - The key to check.
|
|
282
|
+
* @returns `true` if the key is a directory, otherwise `false`.
|
|
283
|
+
*/
|
|
284
|
+
isDirectorySync: (key: string) => boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Checks if the given key is a file.
|
|
287
|
+
*
|
|
288
|
+
* @param key - The key to check.
|
|
289
|
+
* @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
|
|
290
|
+
*/
|
|
291
|
+
isFile: (key: string) => Promise<boolean>;
|
|
292
|
+
/**
|
|
293
|
+
* Synchronously checks if the given key is a file.
|
|
294
|
+
*
|
|
295
|
+
* @param key - The key to check.
|
|
296
|
+
* @returns `true` if the key is a file, otherwise `false`.
|
|
297
|
+
*/
|
|
298
|
+
isFileSync: (key: string) => boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Gets the metadata of a file in the virtual file system (VFS).
|
|
301
|
+
*
|
|
302
|
+
* @param path - The path or id of the file.
|
|
303
|
+
* @returns The metadata of the file if it exists, otherwise undefined.
|
|
304
|
+
*/
|
|
305
|
+
getMetadata: (path: string) => VirtualFileMetadata | undefined;
|
|
306
|
+
/**
|
|
307
|
+
* Lists files in a given path.
|
|
308
|
+
*
|
|
309
|
+
* @param path - The path to list files from.
|
|
310
|
+
* @returns An array of file names in the specified path.
|
|
311
|
+
*/
|
|
312
|
+
listSync: (path: string) => string[];
|
|
313
|
+
/**
|
|
314
|
+
* Lists files in a given path.
|
|
315
|
+
*
|
|
316
|
+
* @param path - The path to list files from.
|
|
317
|
+
* @returns An array of file names in the specified path.
|
|
318
|
+
*/
|
|
319
|
+
list: (path: string) => Promise<string[]>;
|
|
320
|
+
/**
|
|
321
|
+
* Removes a file or symbolic link in the virtual file system (VFS).
|
|
322
|
+
*
|
|
323
|
+
* @param path - The path to the file to remove.
|
|
324
|
+
* @returns A promise that resolves when the file is removed.
|
|
325
|
+
*/
|
|
326
|
+
removeSync: (path: string) => void;
|
|
327
|
+
/**
|
|
328
|
+
* Asynchronously removes a file or symbolic link in the virtual file system (VFS).
|
|
329
|
+
*
|
|
330
|
+
* @param path - The path to the file to remove.
|
|
331
|
+
* @returns A promise that resolves when the file is removed.
|
|
332
|
+
*/
|
|
333
|
+
remove: (path: string) => Promise<void>;
|
|
334
|
+
/**
|
|
335
|
+
* Reads a file from the virtual file system (VFS).
|
|
336
|
+
*
|
|
337
|
+
* @param path - The path or id of the file.
|
|
338
|
+
* @returns The contents of the file if it exists, otherwise undefined.
|
|
339
|
+
*/
|
|
340
|
+
read: (path: string) => Promise<string | undefined>;
|
|
341
|
+
/**
|
|
342
|
+
* Reads a file from the virtual file system (VFS).
|
|
343
|
+
*
|
|
344
|
+
* @param path - The path or id of the file.
|
|
345
|
+
*/
|
|
346
|
+
readSync: (path: string) => string | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* Writes a file to the virtual file system (VFS).
|
|
349
|
+
*
|
|
350
|
+
* @param path - The path to the file.
|
|
351
|
+
* @param data - The contents of the file.
|
|
352
|
+
* @param options - Options for writing the file.
|
|
353
|
+
* @returns A promise that resolves when the file is written.
|
|
354
|
+
*/
|
|
355
|
+
write: (path: string, data: string, options?: WriteOptions) => Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Writes a file to the virtual file system (VFS).
|
|
358
|
+
*
|
|
359
|
+
* @param path - The path to the file.
|
|
360
|
+
* @param data - The contents of the file.
|
|
361
|
+
* @param options - Options for writing the file.
|
|
362
|
+
*/
|
|
363
|
+
writeSync: (path: string, data: string, options?: WriteOptions) => void;
|
|
364
|
+
/**
|
|
365
|
+
* Creates a directory at the specified path.
|
|
366
|
+
*
|
|
367
|
+
* @param dirPath - The path of the directory to create.
|
|
368
|
+
*/
|
|
369
|
+
mkdir: (dirPath: string) => Promise<void>;
|
|
370
|
+
/**
|
|
371
|
+
* Synchronously creates a directory at the specified path.
|
|
372
|
+
*
|
|
373
|
+
* @param dirPath - The path of the directory to create.
|
|
374
|
+
*/
|
|
375
|
+
mkdirSync: (dirPath: string) => void;
|
|
376
|
+
/**
|
|
377
|
+
* Moves a file from one path to another in the virtual file system (VFS).
|
|
378
|
+
*
|
|
379
|
+
* @param srcPath - The source path to move
|
|
380
|
+
* @param destPath - The destination path to move to
|
|
381
|
+
*/
|
|
382
|
+
move: (srcPath: string, destPath: string) => Promise<void>;
|
|
383
|
+
/**
|
|
384
|
+
* Synchronously moves a file from one path to another in the virtual file system (VFS).
|
|
385
|
+
*
|
|
386
|
+
* @param srcPath - The source path to move
|
|
387
|
+
* @param destPath - The destination path to move to
|
|
388
|
+
*/
|
|
389
|
+
moveSync: (srcPath: string, destPath: string) => void;
|
|
390
|
+
/**
|
|
391
|
+
* Copies a file from one path to another in the virtual file system (VFS).
|
|
392
|
+
*
|
|
393
|
+
* @param srcPath - The source path to copy
|
|
394
|
+
* @param destPath - The destination path to copy to
|
|
395
|
+
*/
|
|
396
|
+
copy: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => Promise<void>;
|
|
397
|
+
/**
|
|
398
|
+
* Synchronously copies a file from one path to another in the virtual file system (VFS).
|
|
399
|
+
*
|
|
400
|
+
* @param srcPath - The source path to copy
|
|
401
|
+
* @param destPath - The destination path to copy to
|
|
402
|
+
*/
|
|
403
|
+
copySync: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => void;
|
|
404
|
+
/**
|
|
405
|
+
* Glob files in the virtual file system (VFS) based on the provided pattern(s).
|
|
406
|
+
*
|
|
407
|
+
* @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
|
|
408
|
+
* @returns An array of file paths matching the provided pattern(s)
|
|
409
|
+
*/
|
|
410
|
+
glob: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => Promise<string[]>;
|
|
411
|
+
/**
|
|
412
|
+
* Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
|
|
413
|
+
*
|
|
414
|
+
* @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
|
|
415
|
+
* @returns An array of file paths matching the provided pattern(s)
|
|
416
|
+
*/
|
|
417
|
+
globSync: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => string[];
|
|
418
|
+
/**
|
|
419
|
+
* A helper function to resolve modules using the Jiti resolver
|
|
420
|
+
*
|
|
421
|
+
* @remarks
|
|
422
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```ts
|
|
426
|
+
* const resolvedPath = await context.resolve("some-module", "/path/to/importer");
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* @param id - The module to resolve.
|
|
430
|
+
* @param importer - An optional path to the importer module.
|
|
431
|
+
* @param options - Additional resolution options.
|
|
432
|
+
* @returns A promise that resolves to the resolved module path.
|
|
433
|
+
*/
|
|
434
|
+
resolve: (id: string, importer?: string, options?: ResolveOptions$1) => Promise<string | undefined>;
|
|
435
|
+
/**
|
|
436
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
437
|
+
*
|
|
438
|
+
* @remarks
|
|
439
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @param id - The module to resolve.
|
|
447
|
+
* @param importer - An optional path to the importer module.
|
|
448
|
+
* @param options - Additional resolution options.
|
|
449
|
+
* @returns The resolved module path.
|
|
450
|
+
*/
|
|
451
|
+
resolveSync: (id: string, importer?: string, options?: ResolveOptions$1) => string | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
|
|
454
|
+
*/
|
|
455
|
+
dispose: () => Promise<void>;
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
export { ResolveOptions$1 as ResolveOptions, StoragePort, StoragePreset, VirtualFile, VirtualFileSystemInterface };
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { UnpluginBuildVariant } from "./build.cjs";
|
|
2
|
+
import { EnvironmentConfig, PluginConfig } from "./config.cjs";
|
|
3
|
+
import { EnvironmentResolvedConfig, ResolvedConfig } from "./resolved.cjs";
|
|
4
|
+
import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.cjs";
|
|
5
|
+
import { CommandType } from "./commands.cjs";
|
|
6
|
+
import { ArrayValues } from "@stryke/types/array";
|
|
7
|
+
import { FunctionLike, MaybePromise } from "@stryke/types/base";
|
|
8
|
+
import { ExternalIdResult, HookFilter, TransformResult, UnpluginOptions } from "unplugin";
|
|
9
|
+
|
|
10
|
+
//#region ../powerlines/src/types/plugin.d.ts
|
|
11
|
+
interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
|
|
12
|
+
/**
|
|
13
|
+
* The order in which the plugin should be applied.
|
|
14
|
+
*/
|
|
15
|
+
order?: "pre" | "post" | null | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* A filter to determine when the hook should be called.
|
|
18
|
+
*/
|
|
19
|
+
filter?: Pick<HookFilter, TFilter>;
|
|
20
|
+
/**
|
|
21
|
+
* The hook function to be called.
|
|
22
|
+
*/
|
|
23
|
+
handler: THookFunction;
|
|
24
|
+
}
|
|
25
|
+
type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
|
|
26
|
+
/**
|
|
27
|
+
* A result returned by the plugin from the `types` hook that describes the declaration types output file.
|
|
28
|
+
*/
|
|
29
|
+
interface TypesResult {
|
|
30
|
+
directives?: string[];
|
|
31
|
+
code: string;
|
|
32
|
+
}
|
|
33
|
+
type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
|
|
34
|
+
type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
|
|
35
|
+
interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
|
|
36
|
+
/**
|
|
37
|
+
* A function that returns configuration options to be merged with the build context's options.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* 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.
|
|
41
|
+
*
|
|
42
|
+
* @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.
|
|
43
|
+
*
|
|
44
|
+
* @see https://vitejs.dev/guide/api-plugin#config
|
|
45
|
+
*
|
|
46
|
+
* @param this - The build context.
|
|
47
|
+
* @param config - The partial configuration object to be modified.
|
|
48
|
+
* @returns A promise that resolves to a partial configuration object.
|
|
49
|
+
*/
|
|
50
|
+
config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
|
|
51
|
+
/**
|
|
52
|
+
* 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.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* 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.
|
|
56
|
+
*
|
|
57
|
+
* @see https://vitejs.dev/guide/api-plugin#configenvironment
|
|
58
|
+
*
|
|
59
|
+
* @param this - The build context.
|
|
60
|
+
* @param name - The name of the environment being configured.
|
|
61
|
+
* @param environment - The Vite-like environment object containing information about the current build environment.
|
|
62
|
+
* @returns A promise that resolves when the hook is complete.
|
|
63
|
+
*/
|
|
64
|
+
configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
|
|
65
|
+
/**
|
|
66
|
+
* A hook that is called when the plugin is resolved.
|
|
67
|
+
*
|
|
68
|
+
* @see https://vitejs.dev/guide/api-plugin#configresolved
|
|
69
|
+
*
|
|
70
|
+
* @param this - The build context.
|
|
71
|
+
* @returns A promise that resolves when the hook is complete.
|
|
72
|
+
*/
|
|
73
|
+
configResolved: (this: TContext) => MaybePromise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* 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.
|
|
76
|
+
*
|
|
77
|
+
* @param this - The build context.
|
|
78
|
+
* @param code - The source code to generate types for.
|
|
79
|
+
* @returns A promise that resolves when the hook is complete.
|
|
80
|
+
*/
|
|
81
|
+
types: (this: TContext, code: string) => MaybePromise<TypesResult | string | undefined | null>;
|
|
82
|
+
/**
|
|
83
|
+
* A hook that is called at the start of the build process.
|
|
84
|
+
*
|
|
85
|
+
* @param this - The build context and unplugin build context.
|
|
86
|
+
* @returns A promise that resolves when the hook is complete.
|
|
87
|
+
*/
|
|
88
|
+
buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* A hook that is called at the end of the build process.
|
|
91
|
+
*
|
|
92
|
+
* @param this - The build context and unplugin build context.
|
|
93
|
+
* @returns A promise that resolves when the hook is complete.
|
|
94
|
+
*/
|
|
95
|
+
buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* A hook that is called to transform the source code.
|
|
98
|
+
*
|
|
99
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
100
|
+
* @param code - The source code to transform.
|
|
101
|
+
* @param id - The identifier of the source code.
|
|
102
|
+
* @returns A promise that resolves when the hook is complete.
|
|
103
|
+
*/
|
|
104
|
+
transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
|
|
105
|
+
/**
|
|
106
|
+
* A hook that is called to load the source code.
|
|
107
|
+
*
|
|
108
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
109
|
+
* @param id - The identifier of the source code.
|
|
110
|
+
* @returns A promise that resolves when the hook is complete.
|
|
111
|
+
*/
|
|
112
|
+
load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
|
|
113
|
+
/**
|
|
114
|
+
* A hook that is called to resolve the identifier of the source code.
|
|
115
|
+
*
|
|
116
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
117
|
+
* @param id - The identifier of the source code.
|
|
118
|
+
* @param importer - The importer of the source code.
|
|
119
|
+
* @param options - The options for resolving the identifier.
|
|
120
|
+
* @returns A promise that resolves when the hook is complete.
|
|
121
|
+
*/
|
|
122
|
+
resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
|
|
123
|
+
isEntry: boolean;
|
|
124
|
+
}) => MaybePromise<string | ExternalIdResult | null | undefined>;
|
|
125
|
+
/**
|
|
126
|
+
* A hook that is called to write the bundle to disk.
|
|
127
|
+
*
|
|
128
|
+
* @param this - The build context.
|
|
129
|
+
* @returns A promise that resolves when the hook is complete.
|
|
130
|
+
*/
|
|
131
|
+
writeBundle: (this: TContext) => MaybePromise<void>;
|
|
132
|
+
}
|
|
133
|
+
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] };
|
|
134
|
+
type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]> } & {
|
|
135
|
+
/**
|
|
136
|
+
* A function that returns configuration options to be merged with the build context's options.
|
|
137
|
+
*
|
|
138
|
+
* @remarks
|
|
139
|
+
* 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.
|
|
140
|
+
*
|
|
141
|
+
* @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.
|
|
142
|
+
*
|
|
143
|
+
* @see https://vitejs.dev/guide/api-plugin#config
|
|
144
|
+
*
|
|
145
|
+
* @param this - The build context.
|
|
146
|
+
* @param config - The partial configuration object to be modified.
|
|
147
|
+
* @returns A promise that resolves to a partial configuration object.
|
|
148
|
+
*/
|
|
149
|
+
config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
|
|
150
|
+
/**
|
|
151
|
+
* A hook that is called to transform the source code.
|
|
152
|
+
*
|
|
153
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
154
|
+
* @param code - The source code to transform.
|
|
155
|
+
* @param id - The identifier of the source code.
|
|
156
|
+
* @returns A promise that resolves when the hook is complete.
|
|
157
|
+
*/
|
|
158
|
+
transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
|
|
159
|
+
/**
|
|
160
|
+
* A hook that is called to load the source code.
|
|
161
|
+
*
|
|
162
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
163
|
+
* @param id - The identifier of the source code.
|
|
164
|
+
* @returns A promise that resolves when the hook is complete.
|
|
165
|
+
*/
|
|
166
|
+
load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
|
|
167
|
+
/**
|
|
168
|
+
* A hook that is called to resolve the identifier of the source code.
|
|
169
|
+
*
|
|
170
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
171
|
+
* @param id - The identifier of the source code.
|
|
172
|
+
* @param importer - The importer of the source code.
|
|
173
|
+
* @param options - The options for resolving the identifier.
|
|
174
|
+
* @returns A promise that resolves when the hook is complete.
|
|
175
|
+
*/
|
|
176
|
+
resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
|
|
177
|
+
isEntry: boolean;
|
|
178
|
+
}) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
|
|
179
|
+
};
|
|
180
|
+
type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
|
|
181
|
+
interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
|
|
182
|
+
/**
|
|
183
|
+
* The name of the plugin, for use in deduplication, error messages and logs.
|
|
184
|
+
*/
|
|
185
|
+
name: string;
|
|
186
|
+
/**
|
|
187
|
+
* An API object that can be used for inter-plugin communication.
|
|
188
|
+
*
|
|
189
|
+
* @see https://rollupjs.org/plugin-development/#direct-plugin-communication
|
|
190
|
+
*/
|
|
191
|
+
api?: Record<string, any>;
|
|
192
|
+
/**
|
|
193
|
+
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* The Plugin invocation order is as follows:
|
|
197
|
+
* - `enforce: 'pre'` plugins
|
|
198
|
+
* - `order: 'pre'` plugin hooks
|
|
199
|
+
* - any other plugins (normal)
|
|
200
|
+
* - `order: 'post'` plugin hooks
|
|
201
|
+
* - `enforce: 'post'` plugins
|
|
202
|
+
*
|
|
203
|
+
* @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
|
|
204
|
+
* @see https://rollupjs.org/plugin-development/#build-hooks
|
|
205
|
+
* @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
|
|
206
|
+
* @see https://esbuild.github.io/plugins/#concepts
|
|
207
|
+
*/
|
|
208
|
+
enforce?: "pre" | "post";
|
|
209
|
+
/**
|
|
210
|
+
* A function to determine if two plugins are the same and can be de-duplicated.
|
|
211
|
+
*
|
|
212
|
+
* @remarks
|
|
213
|
+
* If this is not provided, plugins are de-duplicated by comparing their names.
|
|
214
|
+
*
|
|
215
|
+
* @param other - The other plugin to compare against.
|
|
216
|
+
* @returns `true` if the two plugins are the same, `false` otherwise.
|
|
217
|
+
*/
|
|
218
|
+
dedupe?: false | ((other: Plugin<any>) => boolean);
|
|
219
|
+
/**
|
|
220
|
+
* A list of pre-requisite plugins that must be loaded before this plugin can be used.
|
|
221
|
+
*/
|
|
222
|
+
dependsOn?: PluginConfig<any>[];
|
|
223
|
+
/**
|
|
224
|
+
* Define environments where this plugin should be active. By default, the plugin is active in all environments.
|
|
225
|
+
*
|
|
226
|
+
* @param environment - The environment to check.
|
|
227
|
+
* @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
|
|
228
|
+
*/
|
|
229
|
+
applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<any>;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { Plugin };
|