@powerlines/plugin-typedoc 0.10.66 → 0.10.68
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/babel.d.mts +2 -0
- 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 +9 -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 +349 -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/hooks.d.mts +2 -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 +64 -1
- package/dist/types/plugin.d.mts +64 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +8 -8
- package/dist/index-BgAdqTbb.d.mts +0 -1
- package/dist/index-CEgs-Dz2.d.cts +0 -1
- package/dist/plugin-Bvn-he2n.mjs +0 -1
- package/dist/plugin-CyBe_fyh.d.mts +0 -1696
- package/dist/plugin-DHXHjv16.cjs +0 -0
- package/dist/plugin-DrAh3JLI.d.cts +0 -1696
- package/dist/types-B7VYa_Pp.mjs +0 -1
- package/dist/types-DHkg7xmX.cjs +0 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { ResolveOptions, VirtualFile, VirtualFileSystemInterface } from "./fs.cjs";
|
|
2
|
+
import { ParsedTypeScriptConfig } from "./tsconfig.cjs";
|
|
3
|
+
import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.cjs";
|
|
4
|
+
import { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.cjs";
|
|
5
|
+
import { NonUndefined } from "@stryke/types/base";
|
|
6
|
+
import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
|
|
7
|
+
import { EnvPaths } from "@stryke/env/get-env-paths";
|
|
8
|
+
import { FetchRequestOptions } from "@stryke/http/fetch";
|
|
9
|
+
import { PackageJson } from "@stryke/types/package-json";
|
|
10
|
+
import { Jiti } from "jiti";
|
|
11
|
+
import { SourceMap } from "magic-string";
|
|
12
|
+
import { ParseResult, ParserOptions } from "oxc-parser";
|
|
13
|
+
import { Range } from "semver";
|
|
14
|
+
import { Project } from "ts-morph";
|
|
15
|
+
import { RequestInfo, Response } from "undici";
|
|
16
|
+
|
|
17
|
+
//#region ../powerlines/src/types/context.d.ts
|
|
18
|
+
|
|
19
|
+
interface MetaInfo {
|
|
20
|
+
/**
|
|
21
|
+
* The checksum generated from the resolved options
|
|
22
|
+
*/
|
|
23
|
+
checksum: string;
|
|
24
|
+
/**
|
|
25
|
+
* The build id
|
|
26
|
+
*/
|
|
27
|
+
buildId: string;
|
|
28
|
+
/**
|
|
29
|
+
* The release id
|
|
30
|
+
*/
|
|
31
|
+
releaseId: string;
|
|
32
|
+
/**
|
|
33
|
+
* The build timestamp
|
|
34
|
+
*/
|
|
35
|
+
timestamp: number;
|
|
36
|
+
/**
|
|
37
|
+
* A hash that represents the path to the project root directory
|
|
38
|
+
*/
|
|
39
|
+
projectRootHash: string;
|
|
40
|
+
/**
|
|
41
|
+
* A hash that represents the path to the project root directory
|
|
42
|
+
*/
|
|
43
|
+
configHash: string;
|
|
44
|
+
}
|
|
45
|
+
interface Resolver extends Jiti {
|
|
46
|
+
plugin: Jiti;
|
|
47
|
+
}
|
|
48
|
+
interface TransformResult$1 {
|
|
49
|
+
code: string;
|
|
50
|
+
map: SourceMap | null;
|
|
51
|
+
}
|
|
52
|
+
interface InitContextOptions {
|
|
53
|
+
/**
|
|
54
|
+
* If false, the plugin will be loaded after all other plugins.
|
|
55
|
+
*
|
|
56
|
+
* @defaultValue true
|
|
57
|
+
*/
|
|
58
|
+
isHighPriority: boolean;
|
|
59
|
+
}
|
|
60
|
+
interface FetchOptions extends FetchRequestOptions {
|
|
61
|
+
/**
|
|
62
|
+
* An indicator specifying that the request should bypass any caching
|
|
63
|
+
*/
|
|
64
|
+
skipCache?: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface ParseOptions extends ParserOptions {
|
|
67
|
+
/**
|
|
68
|
+
* When true this allows return statements to be outside functions to e.g. support parsing CommonJS code.
|
|
69
|
+
*/
|
|
70
|
+
allowReturnOutsideFunction?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The unresolved Powerlines context.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* This context is used before the user configuration has been fully resolved after the `config`.
|
|
77
|
+
*/
|
|
78
|
+
interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
79
|
+
/**
|
|
80
|
+
* The Storm workspace configuration
|
|
81
|
+
*/
|
|
82
|
+
workspaceConfig: WorkspaceConfig;
|
|
83
|
+
/**
|
|
84
|
+
* An object containing the options provided to Powerlines
|
|
85
|
+
*/
|
|
86
|
+
config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
|
|
87
|
+
projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
|
|
88
|
+
sourceRoot: NonUndefined<TResolvedConfig["userConfig"]["sourceRoot"]>;
|
|
89
|
+
output: TResolvedConfig["output"];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* A logging function for the Powerlines engine
|
|
93
|
+
*/
|
|
94
|
+
log: LogFn;
|
|
95
|
+
/**
|
|
96
|
+
* A logging function for fatal messages
|
|
97
|
+
*/
|
|
98
|
+
fatal: (message: string | UnpluginMessage) => void;
|
|
99
|
+
/**
|
|
100
|
+
* A logging function for error messages
|
|
101
|
+
*/
|
|
102
|
+
error: (message: string | UnpluginMessage) => void;
|
|
103
|
+
/**
|
|
104
|
+
* A logging function for warning messages
|
|
105
|
+
*/
|
|
106
|
+
warn: (message: string | UnpluginMessage) => void;
|
|
107
|
+
/**
|
|
108
|
+
* A logging function for informational messages
|
|
109
|
+
*/
|
|
110
|
+
info: (message: string | UnpluginMessage) => void;
|
|
111
|
+
/**
|
|
112
|
+
* A logging function for debug messages
|
|
113
|
+
*/
|
|
114
|
+
debug: (message: string | UnpluginMessage) => void;
|
|
115
|
+
/**
|
|
116
|
+
* A logging function for trace messages
|
|
117
|
+
*/
|
|
118
|
+
trace: (message: string | UnpluginMessage) => void;
|
|
119
|
+
/**
|
|
120
|
+
* The metadata information
|
|
121
|
+
*/
|
|
122
|
+
meta: MetaInfo;
|
|
123
|
+
/**
|
|
124
|
+
* The metadata information currently written to disk
|
|
125
|
+
*/
|
|
126
|
+
persistedMeta?: MetaInfo;
|
|
127
|
+
/**
|
|
128
|
+
* The Powerlines artifacts directory
|
|
129
|
+
*/
|
|
130
|
+
artifactsPath: string;
|
|
131
|
+
/**
|
|
132
|
+
* The path to the Powerlines builtin runtime modules directory
|
|
133
|
+
*/
|
|
134
|
+
builtinsPath: string;
|
|
135
|
+
/**
|
|
136
|
+
* The path to the Powerlines entry modules directory
|
|
137
|
+
*/
|
|
138
|
+
entryPath: string;
|
|
139
|
+
/**
|
|
140
|
+
* The path to the Powerlines TypeScript declaration files directory
|
|
141
|
+
*/
|
|
142
|
+
dtsPath: string;
|
|
143
|
+
/**
|
|
144
|
+
* The path to a directory where the reflection data buffers (used by the build processes) are stored
|
|
145
|
+
*/
|
|
146
|
+
dataPath: string;
|
|
147
|
+
/**
|
|
148
|
+
* The path to a directory where the project cache (used by the build processes) is stored
|
|
149
|
+
*/
|
|
150
|
+
cachePath: string;
|
|
151
|
+
/**
|
|
152
|
+
* The Powerlines environment paths
|
|
153
|
+
*/
|
|
154
|
+
envPaths: EnvPaths;
|
|
155
|
+
/**
|
|
156
|
+
* The file system path to the Powerlines package installation
|
|
157
|
+
*/
|
|
158
|
+
powerlinesPath: string;
|
|
159
|
+
/**
|
|
160
|
+
* The relative path to the Powerlines workspace root directory
|
|
161
|
+
*/
|
|
162
|
+
relativeToWorkspaceRoot: string;
|
|
163
|
+
/**
|
|
164
|
+
* The project's `package.json` file content
|
|
165
|
+
*/
|
|
166
|
+
packageJson: PackageJson & Record<string, any>;
|
|
167
|
+
/**
|
|
168
|
+
* The project's `project.json` file content
|
|
169
|
+
*/
|
|
170
|
+
projectJson?: Record<string, any>;
|
|
171
|
+
/**
|
|
172
|
+
* The dependency installations required by the project
|
|
173
|
+
*/
|
|
174
|
+
dependencies: Record<string, string | Range>;
|
|
175
|
+
/**
|
|
176
|
+
* The development dependency installations required by the project
|
|
177
|
+
*/
|
|
178
|
+
devDependencies: Record<string, string | Range>;
|
|
179
|
+
/**
|
|
180
|
+
* The parsed TypeScript configuration from the `tsconfig.json` file
|
|
181
|
+
*/
|
|
182
|
+
tsconfig: ParsedTypeScriptConfig;
|
|
183
|
+
/**
|
|
184
|
+
* The entry points of the source code
|
|
185
|
+
*/
|
|
186
|
+
entry: ResolvedEntryTypeDefinition[];
|
|
187
|
+
/**
|
|
188
|
+
* The virtual file system manager used during the build process to reference generated runtime files
|
|
189
|
+
*/
|
|
190
|
+
fs: VirtualFileSystemInterface;
|
|
191
|
+
/**
|
|
192
|
+
* The Jiti module resolver
|
|
193
|
+
*/
|
|
194
|
+
resolver: Resolver;
|
|
195
|
+
/**
|
|
196
|
+
* The builtin module id that exist in the Powerlines virtual file system
|
|
197
|
+
*/
|
|
198
|
+
builtins: string[];
|
|
199
|
+
/**
|
|
200
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
201
|
+
*
|
|
202
|
+
* @see https://ts-morph.com/
|
|
203
|
+
*
|
|
204
|
+
* @remarks
|
|
205
|
+
* This instance is created lazily on first access.
|
|
206
|
+
*/
|
|
207
|
+
program: Project;
|
|
208
|
+
/**
|
|
209
|
+
* A function to perform HTTP fetch requests
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* This function uses a caching layer to avoid duplicate requests during the Powerlines process.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* const response = await context.fetch("https://api.example.com/data");
|
|
217
|
+
* const data = await response.json();
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @see https://github.com/nodejs/undici
|
|
221
|
+
*
|
|
222
|
+
* @param input - The URL to fetch.
|
|
223
|
+
* @param options - The fetch request options.
|
|
224
|
+
* @returns A promise that resolves to a response returned by the fetch.
|
|
225
|
+
*/
|
|
226
|
+
fetch: (input: RequestInfo, options?: FetchOptions) => Promise<Response>;
|
|
227
|
+
/**
|
|
228
|
+
* Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* This function can be used to parse TypeScript code into an AST for further analysis or transformation.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* const ast = context.parse("const x: number = 42;");
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* @see https://rollupjs.org/plugin-development/#this-parse
|
|
239
|
+
* @see https://github.com/oxc/oxc
|
|
240
|
+
*
|
|
241
|
+
* @param code - The source code to parse.
|
|
242
|
+
* @param options - The options to pass to the parser.
|
|
243
|
+
* @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
|
|
244
|
+
*/
|
|
245
|
+
parse: (code: string, options?: ParseOptions) => Promise<ParseResult>;
|
|
246
|
+
/**
|
|
247
|
+
* A helper function to resolve modules using the Jiti resolver
|
|
248
|
+
*
|
|
249
|
+
* @remarks
|
|
250
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* const resolvedPath = await context.resolve("some-module", "/path/to/importer");
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* @param id - The module to resolve.
|
|
258
|
+
* @param importer - An optional path to the importer module.
|
|
259
|
+
* @param options - Additional resolution options.
|
|
260
|
+
* @returns A promise that resolves to the resolved module path.
|
|
261
|
+
*/
|
|
262
|
+
resolve: (id: string, importer?: string, options?: ResolveOptions) => Promise<ExternalIdResult | undefined>;
|
|
263
|
+
/**
|
|
264
|
+
* A helper function to load modules using the Jiti resolver
|
|
265
|
+
*
|
|
266
|
+
* @remarks
|
|
267
|
+
* This function can be used to load modules relative to the project root directory.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @param id - The module to load.
|
|
275
|
+
* @returns A promise that resolves to the loaded module.
|
|
276
|
+
*/
|
|
277
|
+
load: (id: string) => Promise<TransformResult$1 | undefined>;
|
|
278
|
+
/**
|
|
279
|
+
* The Powerlines builtin virtual files
|
|
280
|
+
*/
|
|
281
|
+
getBuiltins: () => Promise<VirtualFile[]>;
|
|
282
|
+
/**
|
|
283
|
+
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
284
|
+
*
|
|
285
|
+
* @param code - The source code of the builtin file
|
|
286
|
+
* @param id - The unique identifier of the builtin file
|
|
287
|
+
* @param path - An optional path to write the builtin file to
|
|
288
|
+
*/
|
|
289
|
+
emitBuiltin: (code: string, id: string, path?: string) => Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
292
|
+
*
|
|
293
|
+
* @param code - The source code of the entry file
|
|
294
|
+
* @param path - An optional path to write the entry file to
|
|
295
|
+
*/
|
|
296
|
+
emitEntry: (code: string, path: string) => Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* A function to update the context fields using a new user configuration options
|
|
299
|
+
*/
|
|
300
|
+
withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* A function to update the context fields using inline configuration options
|
|
303
|
+
*/
|
|
304
|
+
withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* Create a new logger instance
|
|
307
|
+
*
|
|
308
|
+
* @param name - The name to use for the logger instance
|
|
309
|
+
* @returns A logger function
|
|
310
|
+
*/
|
|
311
|
+
createLog: (name: string | null) => LogFn;
|
|
312
|
+
/**
|
|
313
|
+
* Extend the current logger instance with a new name
|
|
314
|
+
*
|
|
315
|
+
* @param name - The name to use for the extended logger instance
|
|
316
|
+
* @returns A logger function
|
|
317
|
+
*/
|
|
318
|
+
extendLog: (name: string) => LogFn;
|
|
319
|
+
/**
|
|
320
|
+
* Generates a checksum representing the current context state
|
|
321
|
+
*
|
|
322
|
+
* @returns A promise that resolves to a string representing the checksum
|
|
323
|
+
*/
|
|
324
|
+
generateChecksum: () => Promise<string>;
|
|
325
|
+
}
|
|
326
|
+
type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
|
|
327
|
+
/**
|
|
328
|
+
* The fully resolved Powerlines configuration
|
|
329
|
+
*/
|
|
330
|
+
config: TResolvedConfig;
|
|
331
|
+
};
|
|
332
|
+
interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
|
|
333
|
+
/**
|
|
334
|
+
* The environment specific resolved configuration
|
|
335
|
+
*/
|
|
336
|
+
environment: EnvironmentResolvedConfig;
|
|
337
|
+
/**
|
|
338
|
+
* An alternative property name for the {@link log} property
|
|
339
|
+
*
|
|
340
|
+
* @remarks
|
|
341
|
+
* This is provided for compatibility with other logging libraries that expect a `logger` property.
|
|
342
|
+
*/
|
|
343
|
+
logger: LogFn;
|
|
344
|
+
}
|
|
345
|
+
type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
|
|
346
|
+
//#endregion
|
|
347
|
+
export { BuildPluginContext, PluginContext, UnresolvedContext };
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { ResolveOptions, VirtualFile, VirtualFileSystemInterface } from "./fs.mjs";
|
|
2
|
+
import { ParsedTypeScriptConfig } from "./tsconfig.mjs";
|
|
3
|
+
import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.mjs";
|
|
4
|
+
import "./hooks.mjs";
|
|
5
|
+
import { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.mjs";
|
|
6
|
+
import "./plugin.mjs";
|
|
7
|
+
import { NonUndefined } from "@stryke/types/base";
|
|
8
|
+
import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
|
|
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 { ParseResult, ParserOptions } from "oxc-parser";
|
|
15
|
+
import { Range } from "semver";
|
|
16
|
+
import { Project } from "ts-morph";
|
|
17
|
+
import { RequestInfo, Response } from "undici";
|
|
18
|
+
|
|
19
|
+
//#region ../powerlines/src/types/context.d.ts
|
|
20
|
+
|
|
21
|
+
interface MetaInfo {
|
|
22
|
+
/**
|
|
23
|
+
* The checksum generated from the resolved options
|
|
24
|
+
*/
|
|
25
|
+
checksum: string;
|
|
26
|
+
/**
|
|
27
|
+
* The build id
|
|
28
|
+
*/
|
|
29
|
+
buildId: string;
|
|
30
|
+
/**
|
|
31
|
+
* The release id
|
|
32
|
+
*/
|
|
33
|
+
releaseId: string;
|
|
34
|
+
/**
|
|
35
|
+
* The build timestamp
|
|
36
|
+
*/
|
|
37
|
+
timestamp: number;
|
|
38
|
+
/**
|
|
39
|
+
* A hash that represents the path to the project root directory
|
|
40
|
+
*/
|
|
41
|
+
projectRootHash: string;
|
|
42
|
+
/**
|
|
43
|
+
* A hash that represents the path to the project root directory
|
|
44
|
+
*/
|
|
45
|
+
configHash: string;
|
|
46
|
+
}
|
|
47
|
+
interface Resolver extends Jiti {
|
|
48
|
+
plugin: Jiti;
|
|
49
|
+
}
|
|
50
|
+
interface TransformResult$1 {
|
|
51
|
+
code: string;
|
|
52
|
+
map: SourceMap | null;
|
|
53
|
+
}
|
|
54
|
+
interface InitContextOptions {
|
|
55
|
+
/**
|
|
56
|
+
* If false, the plugin will be loaded after all other plugins.
|
|
57
|
+
*
|
|
58
|
+
* @defaultValue true
|
|
59
|
+
*/
|
|
60
|
+
isHighPriority: boolean;
|
|
61
|
+
}
|
|
62
|
+
interface FetchOptions extends FetchRequestOptions {
|
|
63
|
+
/**
|
|
64
|
+
* An indicator specifying that the request should bypass any caching
|
|
65
|
+
*/
|
|
66
|
+
skipCache?: boolean;
|
|
67
|
+
}
|
|
68
|
+
interface ParseOptions extends ParserOptions {
|
|
69
|
+
/**
|
|
70
|
+
* When true this allows return statements to be outside functions to e.g. support parsing CommonJS code.
|
|
71
|
+
*/
|
|
72
|
+
allowReturnOutsideFunction?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The unresolved Powerlines context.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* This context is used before the user configuration has been fully resolved after the `config`.
|
|
79
|
+
*/
|
|
80
|
+
interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
81
|
+
/**
|
|
82
|
+
* The Storm workspace configuration
|
|
83
|
+
*/
|
|
84
|
+
workspaceConfig: WorkspaceConfig;
|
|
85
|
+
/**
|
|
86
|
+
* An object containing the options provided to Powerlines
|
|
87
|
+
*/
|
|
88
|
+
config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
|
|
89
|
+
projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
|
|
90
|
+
sourceRoot: NonUndefined<TResolvedConfig["userConfig"]["sourceRoot"]>;
|
|
91
|
+
output: TResolvedConfig["output"];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A logging function for the Powerlines engine
|
|
95
|
+
*/
|
|
96
|
+
log: LogFn;
|
|
97
|
+
/**
|
|
98
|
+
* A logging function for fatal messages
|
|
99
|
+
*/
|
|
100
|
+
fatal: (message: string | UnpluginMessage) => void;
|
|
101
|
+
/**
|
|
102
|
+
* A logging function for error messages
|
|
103
|
+
*/
|
|
104
|
+
error: (message: string | UnpluginMessage) => void;
|
|
105
|
+
/**
|
|
106
|
+
* A logging function for warning messages
|
|
107
|
+
*/
|
|
108
|
+
warn: (message: string | UnpluginMessage) => void;
|
|
109
|
+
/**
|
|
110
|
+
* A logging function for informational messages
|
|
111
|
+
*/
|
|
112
|
+
info: (message: string | UnpluginMessage) => void;
|
|
113
|
+
/**
|
|
114
|
+
* A logging function for debug messages
|
|
115
|
+
*/
|
|
116
|
+
debug: (message: string | UnpluginMessage) => void;
|
|
117
|
+
/**
|
|
118
|
+
* A logging function for trace messages
|
|
119
|
+
*/
|
|
120
|
+
trace: (message: string | UnpluginMessage) => void;
|
|
121
|
+
/**
|
|
122
|
+
* The metadata information
|
|
123
|
+
*/
|
|
124
|
+
meta: MetaInfo;
|
|
125
|
+
/**
|
|
126
|
+
* The metadata information currently written to disk
|
|
127
|
+
*/
|
|
128
|
+
persistedMeta?: MetaInfo;
|
|
129
|
+
/**
|
|
130
|
+
* The Powerlines artifacts directory
|
|
131
|
+
*/
|
|
132
|
+
artifactsPath: string;
|
|
133
|
+
/**
|
|
134
|
+
* The path to the Powerlines builtin runtime modules directory
|
|
135
|
+
*/
|
|
136
|
+
builtinsPath: string;
|
|
137
|
+
/**
|
|
138
|
+
* The path to the Powerlines entry modules directory
|
|
139
|
+
*/
|
|
140
|
+
entryPath: string;
|
|
141
|
+
/**
|
|
142
|
+
* The path to the Powerlines TypeScript declaration files directory
|
|
143
|
+
*/
|
|
144
|
+
dtsPath: string;
|
|
145
|
+
/**
|
|
146
|
+
* The path to a directory where the reflection data buffers (used by the build processes) are stored
|
|
147
|
+
*/
|
|
148
|
+
dataPath: string;
|
|
149
|
+
/**
|
|
150
|
+
* The path to a directory where the project cache (used by the build processes) is stored
|
|
151
|
+
*/
|
|
152
|
+
cachePath: string;
|
|
153
|
+
/**
|
|
154
|
+
* The Powerlines environment paths
|
|
155
|
+
*/
|
|
156
|
+
envPaths: EnvPaths;
|
|
157
|
+
/**
|
|
158
|
+
* The file system path to the Powerlines package installation
|
|
159
|
+
*/
|
|
160
|
+
powerlinesPath: string;
|
|
161
|
+
/**
|
|
162
|
+
* The relative path to the Powerlines workspace root directory
|
|
163
|
+
*/
|
|
164
|
+
relativeToWorkspaceRoot: string;
|
|
165
|
+
/**
|
|
166
|
+
* The project's `package.json` file content
|
|
167
|
+
*/
|
|
168
|
+
packageJson: PackageJson & Record<string, any>;
|
|
169
|
+
/**
|
|
170
|
+
* The project's `project.json` file content
|
|
171
|
+
*/
|
|
172
|
+
projectJson?: Record<string, any>;
|
|
173
|
+
/**
|
|
174
|
+
* The dependency installations required by the project
|
|
175
|
+
*/
|
|
176
|
+
dependencies: Record<string, string | Range>;
|
|
177
|
+
/**
|
|
178
|
+
* The development dependency installations required by the project
|
|
179
|
+
*/
|
|
180
|
+
devDependencies: Record<string, string | Range>;
|
|
181
|
+
/**
|
|
182
|
+
* The parsed TypeScript configuration from the `tsconfig.json` file
|
|
183
|
+
*/
|
|
184
|
+
tsconfig: ParsedTypeScriptConfig;
|
|
185
|
+
/**
|
|
186
|
+
* The entry points of the source code
|
|
187
|
+
*/
|
|
188
|
+
entry: ResolvedEntryTypeDefinition[];
|
|
189
|
+
/**
|
|
190
|
+
* The virtual file system manager used during the build process to reference generated runtime files
|
|
191
|
+
*/
|
|
192
|
+
fs: VirtualFileSystemInterface;
|
|
193
|
+
/**
|
|
194
|
+
* The Jiti module resolver
|
|
195
|
+
*/
|
|
196
|
+
resolver: Resolver;
|
|
197
|
+
/**
|
|
198
|
+
* The builtin module id that exist in the Powerlines virtual file system
|
|
199
|
+
*/
|
|
200
|
+
builtins: string[];
|
|
201
|
+
/**
|
|
202
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
203
|
+
*
|
|
204
|
+
* @see https://ts-morph.com/
|
|
205
|
+
*
|
|
206
|
+
* @remarks
|
|
207
|
+
* This instance is created lazily on first access.
|
|
208
|
+
*/
|
|
209
|
+
program: Project;
|
|
210
|
+
/**
|
|
211
|
+
* A function to perform HTTP fetch requests
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
214
|
+
* This function uses a caching layer to avoid duplicate requests during the Powerlines process.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* const response = await context.fetch("https://api.example.com/data");
|
|
219
|
+
* const data = await response.json();
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @see https://github.com/nodejs/undici
|
|
223
|
+
*
|
|
224
|
+
* @param input - The URL to fetch.
|
|
225
|
+
* @param options - The fetch request options.
|
|
226
|
+
* @returns A promise that resolves to a response returned by the fetch.
|
|
227
|
+
*/
|
|
228
|
+
fetch: (input: RequestInfo, options?: FetchOptions) => Promise<Response>;
|
|
229
|
+
/**
|
|
230
|
+
* Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
|
|
231
|
+
*
|
|
232
|
+
* @remarks
|
|
233
|
+
* This function can be used to parse TypeScript code into an AST for further analysis or transformation.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const ast = context.parse("const x: number = 42;");
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @see https://rollupjs.org/plugin-development/#this-parse
|
|
241
|
+
* @see https://github.com/oxc/oxc
|
|
242
|
+
*
|
|
243
|
+
* @param code - The source code to parse.
|
|
244
|
+
* @param options - The options to pass to the parser.
|
|
245
|
+
* @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
|
|
246
|
+
*/
|
|
247
|
+
parse: (code: string, options?: ParseOptions) => Promise<ParseResult>;
|
|
248
|
+
/**
|
|
249
|
+
* A helper function to resolve modules using the Jiti resolver
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* const resolvedPath = await context.resolve("some-module", "/path/to/importer");
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @param id - The module to resolve.
|
|
260
|
+
* @param importer - An optional path to the importer module.
|
|
261
|
+
* @param options - Additional resolution options.
|
|
262
|
+
* @returns A promise that resolves to the resolved module path.
|
|
263
|
+
*/
|
|
264
|
+
resolve: (id: string, importer?: string, options?: ResolveOptions) => Promise<ExternalIdResult | undefined>;
|
|
265
|
+
/**
|
|
266
|
+
* A helper function to load modules using the Jiti resolver
|
|
267
|
+
*
|
|
268
|
+
* @remarks
|
|
269
|
+
* This function can be used to load modules relative to the project root directory.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @param id - The module to load.
|
|
277
|
+
* @returns A promise that resolves to the loaded module.
|
|
278
|
+
*/
|
|
279
|
+
load: (id: string) => Promise<TransformResult$1 | undefined>;
|
|
280
|
+
/**
|
|
281
|
+
* The Powerlines builtin virtual files
|
|
282
|
+
*/
|
|
283
|
+
getBuiltins: () => Promise<VirtualFile[]>;
|
|
284
|
+
/**
|
|
285
|
+
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
286
|
+
*
|
|
287
|
+
* @param code - The source code of the builtin file
|
|
288
|
+
* @param id - The unique identifier of the builtin file
|
|
289
|
+
* @param path - An optional path to write the builtin file to
|
|
290
|
+
*/
|
|
291
|
+
emitBuiltin: (code: string, id: string, path?: string) => Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
294
|
+
*
|
|
295
|
+
* @param code - The source code of the entry file
|
|
296
|
+
* @param path - An optional path to write the entry file to
|
|
297
|
+
*/
|
|
298
|
+
emitEntry: (code: string, path: string) => Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* A function to update the context fields using a new user configuration options
|
|
301
|
+
*/
|
|
302
|
+
withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* A function to update the context fields using inline configuration options
|
|
305
|
+
*/
|
|
306
|
+
withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Create a new logger instance
|
|
309
|
+
*
|
|
310
|
+
* @param name - The name to use for the logger instance
|
|
311
|
+
* @returns A logger function
|
|
312
|
+
*/
|
|
313
|
+
createLog: (name: string | null) => LogFn;
|
|
314
|
+
/**
|
|
315
|
+
* Extend the current logger instance with a new name
|
|
316
|
+
*
|
|
317
|
+
* @param name - The name to use for the extended logger instance
|
|
318
|
+
* @returns A logger function
|
|
319
|
+
*/
|
|
320
|
+
extendLog: (name: string) => LogFn;
|
|
321
|
+
/**
|
|
322
|
+
* Generates a checksum representing the current context state
|
|
323
|
+
*
|
|
324
|
+
* @returns A promise that resolves to a string representing the checksum
|
|
325
|
+
*/
|
|
326
|
+
generateChecksum: () => Promise<string>;
|
|
327
|
+
}
|
|
328
|
+
type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
|
|
329
|
+
/**
|
|
330
|
+
* The fully resolved Powerlines configuration
|
|
331
|
+
*/
|
|
332
|
+
config: TResolvedConfig;
|
|
333
|
+
};
|
|
334
|
+
interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
|
|
335
|
+
/**
|
|
336
|
+
* The environment specific resolved configuration
|
|
337
|
+
*/
|
|
338
|
+
environment: EnvironmentResolvedConfig;
|
|
339
|
+
/**
|
|
340
|
+
* An alternative property name for the {@link log} property
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* This is provided for compatibility with other logging libraries that expect a `logger` property.
|
|
344
|
+
*/
|
|
345
|
+
logger: LogFn;
|
|
346
|
+
}
|
|
347
|
+
type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
|
|
348
|
+
//#endregion
|
|
349
|
+
export { BuildPluginContext, PluginContext, UnresolvedContext };
|