@powerlines/plugin-satori 0.1.122 → 0.1.123

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