@powerlines/plugin-vite 0.14.58 → 0.14.60

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 (130) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +1 -0
  2. package/dist/helpers/index.cjs +1 -1
  3. package/dist/helpers/index.d.cts +1 -3
  4. package/dist/helpers/index.d.mts +1 -3
  5. package/dist/helpers/index.mjs +1 -1
  6. package/dist/helpers/unplugin.cjs +1 -1
  7. package/dist/helpers/unplugin.d.cts +6 -2
  8. package/dist/helpers/unplugin.d.mts +6 -2
  9. package/dist/helpers/unplugin.mjs +1 -1
  10. package/dist/index.cjs +1 -14
  11. package/dist/index.d.cts +3 -4
  12. package/dist/index.d.mts +5 -5
  13. package/dist/index.mjs +1 -14
  14. package/dist/powerlines/schemas/fs.cjs +1 -0
  15. package/dist/powerlines/schemas/fs.mjs +1 -0
  16. package/dist/powerlines/src/api.cjs +11 -0
  17. package/dist/powerlines/src/api.mjs +1 -0
  18. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +1 -0
  19. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +1 -0
  20. package/dist/powerlines/src/internal/helpers/environment.cjs +1 -0
  21. package/dist/powerlines/src/internal/helpers/environment.mjs +1 -0
  22. package/dist/powerlines/src/internal/helpers/generate-types.cjs +8 -0
  23. package/dist/powerlines/src/internal/helpers/generate-types.mjs +8 -0
  24. package/dist/powerlines/src/internal/helpers/hooks.cjs +1 -0
  25. package/dist/powerlines/src/internal/helpers/hooks.mjs +1 -0
  26. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +3 -0
  27. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +3 -0
  28. package/dist/powerlines/src/internal/helpers/install.cjs +1 -0
  29. package/dist/powerlines/src/internal/helpers/install.mjs +1 -0
  30. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +8 -0
  31. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +8 -0
  32. package/dist/powerlines/src/internal/helpers/resolver.cjs +1 -0
  33. package/dist/powerlines/src/internal/helpers/resolver.mjs +1 -0
  34. package/dist/powerlines/src/lib/build/esbuild.cjs +14 -0
  35. package/dist/powerlines/src/lib/build/esbuild.mjs +14 -0
  36. package/dist/powerlines/src/lib/build/vite.cjs +1 -0
  37. package/dist/powerlines/src/lib/build/vite.mjs +1 -0
  38. package/dist/powerlines/src/lib/config-file.cjs +1 -0
  39. package/dist/powerlines/src/lib/config-file.mjs +1 -0
  40. package/dist/powerlines/src/lib/contexts/api-context.cjs +1 -0
  41. package/dist/powerlines/src/lib/contexts/api-context.mjs +1 -0
  42. package/dist/powerlines/src/lib/contexts/context.cjs +1 -0
  43. package/dist/powerlines/src/lib/contexts/context.mjs +1 -0
  44. package/dist/powerlines/src/lib/contexts/environment-context.cjs +1 -0
  45. package/dist/powerlines/src/lib/contexts/environment-context.mjs +1 -0
  46. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +1 -0
  47. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +1 -0
  48. package/dist/powerlines/src/lib/entry.cjs +1 -0
  49. package/dist/powerlines/src/lib/entry.mjs +1 -0
  50. package/dist/powerlines/src/lib/fs/helpers.cjs +1 -0
  51. package/dist/powerlines/src/lib/fs/helpers.mjs +1 -0
  52. package/dist/powerlines/src/lib/fs/storage/base.cjs +1 -0
  53. package/dist/powerlines/src/lib/fs/storage/base.mjs +1 -0
  54. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +1 -0
  55. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +1 -0
  56. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +1 -0
  57. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +1 -0
  58. package/dist/powerlines/src/lib/fs/vfs.cjs +1 -0
  59. package/dist/powerlines/src/lib/fs/vfs.mjs +1 -0
  60. package/dist/powerlines/src/lib/logger.cjs +1 -0
  61. package/dist/powerlines/src/lib/logger.mjs +1 -0
  62. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +1 -0
  63. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +1 -0
  64. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +4 -0
  65. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +4 -0
  66. package/dist/powerlines/src/lib/unplugin/factory.cjs +1 -0
  67. package/dist/powerlines/src/lib/unplugin/factory.mjs +1 -0
  68. package/dist/powerlines/src/lib/unplugin/helpers.cjs +1 -0
  69. package/dist/powerlines/src/lib/unplugin/helpers.mjs +1 -0
  70. package/dist/powerlines/src/lib/unplugin/index.cjs +1 -0
  71. package/dist/powerlines/src/lib/unplugin/index.mjs +1 -0
  72. package/dist/powerlines/src/lib/unplugin/plugin.cjs +6 -0
  73. package/dist/powerlines/src/lib/unplugin/plugin.mjs +6 -0
  74. package/dist/powerlines/src/lib/utilities/file-header.cjs +10 -0
  75. package/dist/powerlines/src/lib/utilities/file-header.mjs +10 -0
  76. package/dist/powerlines/src/lib/utilities/meta.cjs +1 -0
  77. package/dist/powerlines/src/lib/utilities/meta.mjs +1 -0
  78. package/dist/powerlines/src/lib/utilities/source-file.cjs +1 -0
  79. package/dist/powerlines/src/lib/utilities/source-file.mjs +1 -0
  80. package/dist/powerlines/src/plugin-utils/helpers.cjs +1 -0
  81. package/dist/powerlines/src/plugin-utils/helpers.mjs +1 -0
  82. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
  83. package/dist/powerlines/src/plugin-utils/paths.mjs +1 -0
  84. package/dist/powerlines/src/types/babel.d.mts +4 -0
  85. package/dist/powerlines/src/types/build.d.cts +143 -0
  86. package/dist/powerlines/src/types/build.d.mts +143 -0
  87. package/dist/powerlines/src/types/commands.cjs +1 -0
  88. package/dist/powerlines/src/types/commands.d.cts +8 -0
  89. package/dist/powerlines/src/types/commands.d.mts +9 -0
  90. package/dist/powerlines/src/types/commands.mjs +1 -0
  91. package/dist/powerlines/src/types/config.d.cts +346 -0
  92. package/dist/powerlines/src/types/config.d.mts +348 -0
  93. package/dist/powerlines/src/types/context.d.cts +347 -0
  94. package/dist/powerlines/src/types/context.d.mts +349 -0
  95. package/dist/powerlines/src/types/fs.d.cts +458 -0
  96. package/dist/powerlines/src/types/fs.d.mts +458 -0
  97. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  98. package/dist/powerlines/src/types/plugin.cjs +1 -0
  99. package/dist/powerlines/src/types/plugin.d.cts +232 -0
  100. package/dist/powerlines/src/types/plugin.d.mts +232 -0
  101. package/dist/powerlines/src/types/plugin.mjs +1 -0
  102. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  103. package/dist/powerlines/src/types/resolved.d.mts +82 -0
  104. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  105. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  106. package/dist/types/index.cjs +0 -1
  107. package/dist/types/index.d.cts +1 -2
  108. package/dist/types/index.d.mts +1 -2
  109. package/dist/types/index.mjs +1 -1
  110. package/dist/types/plugin.cjs +0 -1
  111. package/dist/types/plugin.d.cts +19 -1
  112. package/dist/types/plugin.d.mts +19 -1
  113. package/dist/types/plugin.mjs +1 -1
  114. package/package.json +10 -10
  115. package/dist/helpers-CRPRhztf.mjs +0 -1
  116. package/dist/helpers-LF26RHol.cjs +0 -0
  117. package/dist/index-9iG2qHLe.d.mts +0 -1
  118. package/dist/index-D4ELpJXS.d.cts +0 -1
  119. package/dist/index-D6CnpA_r.d.cts +0 -1
  120. package/dist/index-DL0uimUT.d.mts +0 -1
  121. package/dist/plugin-BjiGfRHE.mjs +0 -1
  122. package/dist/plugin-Bu9f0Vo1.d.mts +0 -1658
  123. package/dist/plugin-CeaU7BaT.d.cts +0 -1655
  124. package/dist/plugin-pBKbb5K9.cjs +0 -0
  125. package/dist/types-n6NgD0QK.mjs +0 -1
  126. package/dist/types-o3zWarRp.cjs +0 -0
  127. package/dist/unplugin-CQUvJGvc.d.mts +0 -7
  128. package/dist/unplugin-DD1hF9r3.mjs +0 -6
  129. package/dist/unplugin-DVT_2a_R.cjs +0 -44
  130. package/dist/unplugin-DtFSdCAn.d.cts +0 -7
@@ -0,0 +1,347 @@
1
+ import { ResolveOptions, VirtualFile, VirtualFileSystemInterface } from "./fs.cjs";
2
+ import { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.cjs";
3
+ import { ParsedTypeScriptConfig } from "./tsconfig.cjs";
4
+ import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.cjs";
5
+ import { EnvPaths } from "@stryke/env/get-env-paths";
6
+ import { FetchRequestOptions } from "@stryke/http/fetch";
7
+ import { NonUndefined } from "@stryke/types/base";
8
+ import { PackageJson } from "@stryke/types/package-json";
9
+ import { Jiti } from "jiti";
10
+ import { SourceMap } from "magic-string";
11
+ import { ParseResult, ParserOptions } from "oxc-parser";
12
+ import { Range } from "semver";
13
+ import { Project } from "ts-morph";
14
+ import { RequestInfo, Response } from "undici";
15
+ import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
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 { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.mjs";
3
+ import "./plugin.mjs";
4
+ import { ParsedTypeScriptConfig } from "./tsconfig.mjs";
5
+ import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.mjs";
6
+ import "./hooks.mjs";
7
+ import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
8
+ import { Project } from "ts-morph";
9
+ import { EnvPaths } from "@stryke/env/get-env-paths";
10
+ import { FetchRequestOptions } from "@stryke/http/fetch";
11
+ import { ParseResult, ParserOptions } from "oxc-parser";
12
+ import { RequestInfo, Response } from "undici";
13
+ import { Jiti } from "jiti";
14
+ import { SourceMap } from "magic-string";
15
+ import { NonUndefined } from "@stryke/types/base";
16
+ import { PackageJson } from "@stryke/types/package-json";
17
+ import { Range } from "semver";
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 };