@powerlines/plugin-webpack 0.5.134 → 0.5.136
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/powerlines/src/internal/helpers/hooks.cjs +15 -12
- package/dist/powerlines/src/internal/helpers/hooks.d.cts +47 -0
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +49 -0
- package/dist/powerlines/src/internal/helpers/hooks.mjs +15 -12
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +108 -73
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +109 -74
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +13 -1
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +12 -1
- package/dist/powerlines/src/lib/unplugin/index.cjs +1 -1
- package/dist/powerlines/src/lib/unplugin/index.mjs +1 -1
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +3 -3
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +3 -3
- package/dist/powerlines/src/plugin-utils/helpers.cjs +34 -15
- package/dist/powerlines/src/plugin-utils/helpers.mjs +33 -15
- package/dist/powerlines/src/types/api.d.cts +104 -0
- package/dist/powerlines/src/types/api.d.mts +104 -0
- package/dist/powerlines/src/types/build.cjs +11 -3
- package/dist/powerlines/src/types/build.d.cts +39 -3
- package/dist/powerlines/src/types/build.d.mts +39 -3
- package/dist/powerlines/src/types/build.mjs +10 -3
- package/dist/powerlines/src/types/config.d.cts +60 -5
- package/dist/powerlines/src/types/config.d.mts +60 -5
- package/dist/powerlines/src/types/context.d.cts +113 -1
- package/dist/powerlines/src/types/context.d.mts +113 -3
- package/dist/powerlines/src/types/hooks.d.cts +32 -0
- package/dist/powerlines/src/types/hooks.d.mts +32 -2
- package/dist/powerlines/src/types/plugin.cjs +5 -4
- package/dist/powerlines/src/types/plugin.d.cts +35 -61
- package/dist/powerlines/src/types/plugin.d.mts +35 -61
- package/dist/powerlines/src/types/plugin.mjs +6 -5
- package/dist/powerlines/src/types/resolved.d.cts +15 -4
- package/dist/powerlines/src/types/resolved.d.mts +15 -5
- package/dist/powerlines/src/types/unplugin.d.cts +22 -0
- package/dist/powerlines/src/types/unplugin.d.mts +23 -0
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildConfig, BuildResolvedConfig, WebpackBuildConfig, WebpackResolvedBuildConfig } from "./build.cjs";
|
|
1
|
+
import { BuildConfig, BuildResolvedConfig, ESBuildBuildConfig, ESBuildResolvedBuildConfig, FarmBuildConfig, FarmResolvedBuildConfig, RolldownBuildConfig, RolldownResolvedBuildConfig, RollupBuildConfig, RollupResolvedBuildConfig, RspackBuildConfig, RspackResolvedBuildConfig, TsdownBuildConfig, TsdownResolvedBuildConfig, TsupBuildConfig, TsupResolvedBuildConfig, UnbuildBuildConfig, UnbuildResolvedBuildConfig, ViteBuildConfig, ViteResolvedBuildConfig, WebpackBuildConfig, WebpackResolvedBuildConfig } from "./build.cjs";
|
|
2
2
|
import { StoragePort, StoragePreset } from "./fs.cjs";
|
|
3
3
|
import { Plugin } from "./plugin.cjs";
|
|
4
4
|
import { TSConfig } from "./tsconfig.cjs";
|
|
@@ -341,7 +341,7 @@ interface CommonUserConfig extends BaseConfig {
|
|
|
341
341
|
*/
|
|
342
342
|
framework?: string;
|
|
343
343
|
}
|
|
344
|
-
interface UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> extends Omit<CommonUserConfig, "build"> {
|
|
344
|
+
interface UserConfig$1<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> extends Omit<CommonUserConfig, "build"> {
|
|
345
345
|
/**
|
|
346
346
|
* Configuration provided to build processes
|
|
347
347
|
*
|
|
@@ -362,16 +362,71 @@ interface UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResol
|
|
|
362
362
|
override?: Partial<TBuildResolvedConfig>;
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
|
-
type WebpackUserConfig = UserConfig<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
|
|
365
|
+
type WebpackUserConfig = UserConfig$1<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
|
|
366
|
+
type RspackUserConfig = UserConfig$1<RspackBuildConfig, RspackResolvedBuildConfig, "rspack">;
|
|
367
|
+
type RollupUserConfig = UserConfig$1<RollupBuildConfig, RollupResolvedBuildConfig, "rollup">;
|
|
368
|
+
type RolldownUserConfig = UserConfig$1<RolldownBuildConfig, RolldownResolvedBuildConfig, "rolldown">;
|
|
369
|
+
type ViteUserConfig = UserConfig$1<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
|
|
370
|
+
type ESBuildUserConfig = UserConfig$1<ESBuildBuildConfig, ESBuildResolvedBuildConfig, "esbuild">;
|
|
371
|
+
type UnbuildUserConfig = UserConfig$1<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
|
|
372
|
+
type TsupUserConfig = UserConfig$1<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
|
|
373
|
+
type TsdownUserConfig = UserConfig$1<TsdownBuildConfig, TsdownResolvedBuildConfig, "tsdown">;
|
|
374
|
+
type FarmUserConfig = UserConfig$1<FarmBuildConfig, FarmResolvedBuildConfig, "farm">;
|
|
366
375
|
type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
|
|
367
376
|
/**
|
|
368
377
|
* The configuration provided while executing Powerlines commands.
|
|
369
378
|
*/
|
|
370
|
-
type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
|
|
379
|
+
type InlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = Partial<TUserConfig> & {
|
|
371
380
|
/**
|
|
372
381
|
* A string identifier for the Powerlines command being executed
|
|
373
382
|
*/
|
|
374
383
|
command: PowerlinesCommand;
|
|
375
384
|
};
|
|
385
|
+
type NewInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
|
|
386
|
+
/**
|
|
387
|
+
* A string identifier for the Powerlines command being executed
|
|
388
|
+
*/
|
|
389
|
+
command: "new";
|
|
390
|
+
/**
|
|
391
|
+
* The package name (from the \`package.json\`) for the project that will be used in the \`new\` command to create a new project based on this configuration
|
|
392
|
+
*/
|
|
393
|
+
packageName?: string;
|
|
394
|
+
};
|
|
395
|
+
type CleanInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
396
|
+
/**
|
|
397
|
+
* A string identifier for the Powerlines command being executed
|
|
398
|
+
*/
|
|
399
|
+
command: "clean";
|
|
400
|
+
};
|
|
401
|
+
type PrepareInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
402
|
+
/**
|
|
403
|
+
* A string identifier for the Powerlines command being executed
|
|
404
|
+
*/
|
|
405
|
+
command: "prepare";
|
|
406
|
+
};
|
|
407
|
+
type BuildInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
408
|
+
/**
|
|
409
|
+
* A string identifier for the Powerlines command being executed
|
|
410
|
+
*/
|
|
411
|
+
command: "build";
|
|
412
|
+
};
|
|
413
|
+
type LintInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
414
|
+
/**
|
|
415
|
+
* A string identifier for the Powerlines command being executed
|
|
416
|
+
*/
|
|
417
|
+
command: "lint";
|
|
418
|
+
};
|
|
419
|
+
type DocsInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
420
|
+
/**
|
|
421
|
+
* A string identifier for the Powerlines command being executed
|
|
422
|
+
*/
|
|
423
|
+
command: "docs";
|
|
424
|
+
};
|
|
425
|
+
type DeployInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
426
|
+
/**
|
|
427
|
+
* A string identifier for the Powerlines command being executed
|
|
428
|
+
*/
|
|
429
|
+
command: "deploy";
|
|
430
|
+
};
|
|
376
431
|
//#endregion
|
|
377
|
-
export { EnvironmentConfig, InlineConfig, LogFn, OutputConfig, PluginConfig, UserConfig, WebpackUserConfig, WorkspaceConfig };
|
|
432
|
+
export { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, ESBuildUserConfig, EnvironmentConfig, FarmUserConfig, InlineConfig, LintInlineConfig, LogFn, NewInlineConfig, OutputConfig, PluginConfig, PrepareInlineConfig, RolldownUserConfig, RollupUserConfig, RspackUserConfig, TsdownUserConfig, TsupUserConfig, UnbuildUserConfig, UserConfig$1 as UserConfig, ViteUserConfig, WebpackUserConfig, WorkspaceConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildConfig, BuildResolvedConfig, WebpackBuildConfig, WebpackResolvedBuildConfig } from "./build.mjs";
|
|
1
|
+
import { BuildConfig, BuildResolvedConfig, ESBuildBuildConfig, ESBuildResolvedBuildConfig, FarmBuildConfig, FarmResolvedBuildConfig, RolldownBuildConfig, RolldownResolvedBuildConfig, RollupBuildConfig, RollupResolvedBuildConfig, RspackBuildConfig, RspackResolvedBuildConfig, TsdownBuildConfig, TsdownResolvedBuildConfig, TsupBuildConfig, TsupResolvedBuildConfig, UnbuildBuildConfig, UnbuildResolvedBuildConfig, ViteBuildConfig, ViteResolvedBuildConfig, WebpackBuildConfig, WebpackResolvedBuildConfig } from "./build.mjs";
|
|
2
2
|
import "./babel.mjs";
|
|
3
3
|
import { StoragePort, StoragePreset } from "./fs.mjs";
|
|
4
4
|
import { Plugin } from "./plugin.mjs";
|
|
@@ -343,7 +343,7 @@ interface CommonUserConfig extends BaseConfig {
|
|
|
343
343
|
*/
|
|
344
344
|
framework?: string;
|
|
345
345
|
}
|
|
346
|
-
interface UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> extends Omit<CommonUserConfig, "build"> {
|
|
346
|
+
interface UserConfig$1<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> extends Omit<CommonUserConfig, "build"> {
|
|
347
347
|
/**
|
|
348
348
|
* Configuration provided to build processes
|
|
349
349
|
*
|
|
@@ -364,16 +364,71 @@ interface UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResol
|
|
|
364
364
|
override?: Partial<TBuildResolvedConfig>;
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
type WebpackUserConfig = UserConfig<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
|
|
367
|
+
type WebpackUserConfig = UserConfig$1<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
|
|
368
|
+
type RspackUserConfig = UserConfig$1<RspackBuildConfig, RspackResolvedBuildConfig, "rspack">;
|
|
369
|
+
type RollupUserConfig = UserConfig$1<RollupBuildConfig, RollupResolvedBuildConfig, "rollup">;
|
|
370
|
+
type RolldownUserConfig = UserConfig$1<RolldownBuildConfig, RolldownResolvedBuildConfig, "rolldown">;
|
|
371
|
+
type ViteUserConfig = UserConfig$1<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
|
|
372
|
+
type ESBuildUserConfig = UserConfig$1<ESBuildBuildConfig, ESBuildResolvedBuildConfig, "esbuild">;
|
|
373
|
+
type UnbuildUserConfig = UserConfig$1<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
|
|
374
|
+
type TsupUserConfig = UserConfig$1<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
|
|
375
|
+
type TsdownUserConfig = UserConfig$1<TsdownBuildConfig, TsdownResolvedBuildConfig, "tsdown">;
|
|
376
|
+
type FarmUserConfig = UserConfig$1<FarmBuildConfig, FarmResolvedBuildConfig, "farm">;
|
|
368
377
|
type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
|
|
369
378
|
/**
|
|
370
379
|
* The configuration provided while executing Powerlines commands.
|
|
371
380
|
*/
|
|
372
|
-
type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
|
|
381
|
+
type InlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = Partial<TUserConfig> & {
|
|
373
382
|
/**
|
|
374
383
|
* A string identifier for the Powerlines command being executed
|
|
375
384
|
*/
|
|
376
385
|
command: PowerlinesCommand;
|
|
377
386
|
};
|
|
387
|
+
type NewInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
|
|
388
|
+
/**
|
|
389
|
+
* A string identifier for the Powerlines command being executed
|
|
390
|
+
*/
|
|
391
|
+
command: "new";
|
|
392
|
+
/**
|
|
393
|
+
* The package name (from the \`package.json\`) for the project that will be used in the \`new\` command to create a new project based on this configuration
|
|
394
|
+
*/
|
|
395
|
+
packageName?: string;
|
|
396
|
+
};
|
|
397
|
+
type CleanInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
398
|
+
/**
|
|
399
|
+
* A string identifier for the Powerlines command being executed
|
|
400
|
+
*/
|
|
401
|
+
command: "clean";
|
|
402
|
+
};
|
|
403
|
+
type PrepareInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
404
|
+
/**
|
|
405
|
+
* A string identifier for the Powerlines command being executed
|
|
406
|
+
*/
|
|
407
|
+
command: "prepare";
|
|
408
|
+
};
|
|
409
|
+
type BuildInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
410
|
+
/**
|
|
411
|
+
* A string identifier for the Powerlines command being executed
|
|
412
|
+
*/
|
|
413
|
+
command: "build";
|
|
414
|
+
};
|
|
415
|
+
type LintInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
416
|
+
/**
|
|
417
|
+
* A string identifier for the Powerlines command being executed
|
|
418
|
+
*/
|
|
419
|
+
command: "lint";
|
|
420
|
+
};
|
|
421
|
+
type DocsInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
422
|
+
/**
|
|
423
|
+
* A string identifier for the Powerlines command being executed
|
|
424
|
+
*/
|
|
425
|
+
command: "docs";
|
|
426
|
+
};
|
|
427
|
+
type DeployInlineConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = InlineConfig<TUserConfig> & {
|
|
428
|
+
/**
|
|
429
|
+
* A string identifier for the Powerlines command being executed
|
|
430
|
+
*/
|
|
431
|
+
command: "deploy";
|
|
432
|
+
};
|
|
378
433
|
//#endregion
|
|
379
|
-
export { EnvironmentConfig, InlineConfig, LogFn, OutputConfig, PluginConfig, UserConfig, WebpackUserConfig, WorkspaceConfig };
|
|
434
|
+
export { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, ESBuildUserConfig, EnvironmentConfig, FarmUserConfig, InlineConfig, LintInlineConfig, LogFn, NewInlineConfig, OutputConfig, PluginConfig, PrepareInlineConfig, RolldownUserConfig, RollupUserConfig, RspackUserConfig, TsdownUserConfig, TsupUserConfig, UnbuildUserConfig, UserConfig$1 as UserConfig, ViteUserConfig, WebpackUserConfig, WorkspaceConfig };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ResolveOptions, VirtualFile, VirtualFileSystemInterface, WriteOptions } from "./fs.cjs";
|
|
2
2
|
import { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.cjs";
|
|
3
|
+
import { HooksList, InferHooksListItem } from "./hooks.cjs";
|
|
4
|
+
import { Plugin } from "./plugin.cjs";
|
|
3
5
|
import { ParsedTypeScriptConfig } from "./tsconfig.cjs";
|
|
4
6
|
import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.cjs";
|
|
5
7
|
import { EnvPaths } from "@stryke/env/get-env-paths";
|
|
@@ -49,6 +51,9 @@ interface TransformResult$1 {
|
|
|
49
51
|
code: string;
|
|
50
52
|
map: SourceMap | null;
|
|
51
53
|
}
|
|
54
|
+
interface SelectHooksOptions {
|
|
55
|
+
order?: "pre" | "post" | "normal";
|
|
56
|
+
}
|
|
52
57
|
/**
|
|
53
58
|
* Options for initializing or updating the context with new configuration values
|
|
54
59
|
*/
|
|
@@ -385,6 +390,112 @@ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<Unr
|
|
|
385
390
|
*/
|
|
386
391
|
config: TResolvedConfig;
|
|
387
392
|
};
|
|
393
|
+
interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
|
|
394
|
+
/**
|
|
395
|
+
* The expected plugins options for the Powerlines project.
|
|
396
|
+
*
|
|
397
|
+
* @remarks
|
|
398
|
+
* This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
|
|
399
|
+
*/
|
|
400
|
+
plugins: Plugin<PluginContext<TResolvedConfig>>[];
|
|
401
|
+
/**
|
|
402
|
+
* A function to add a plugin to the context and update the configuration options
|
|
403
|
+
*/
|
|
404
|
+
addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* A table for storing the current context for each configured environment
|
|
407
|
+
*/
|
|
408
|
+
environments: Record<string, EnvironmentContext<TResolvedConfig>>;
|
|
409
|
+
/**
|
|
410
|
+
* Retrieves the context for a specific environment by name
|
|
411
|
+
*
|
|
412
|
+
* @throws Will throw an error if the environment does not exist
|
|
413
|
+
*
|
|
414
|
+
* @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
|
|
415
|
+
* @returns A promise that resolves to the environment context.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* const devEnv = await apiContext.getEnvironment("development");
|
|
420
|
+
* const defaultEnv = await apiContext.getEnvironment();
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
|
|
424
|
+
/**
|
|
425
|
+
* Safely retrieves the context for a specific environment by name
|
|
426
|
+
*
|
|
427
|
+
* @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
|
|
428
|
+
* @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```ts
|
|
432
|
+
* const devEnv = await apiContext.getEnvironmentSafe("development");
|
|
433
|
+
* const defaultEnv = await apiContext.getEnvironmentSafe();
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @remarks
|
|
437
|
+
* This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
|
|
438
|
+
* This can be useful in scenarios where the existence of an environment is optional or uncertain.
|
|
439
|
+
*
|
|
440
|
+
* ```ts
|
|
441
|
+
* const testEnv = await apiContext.getEnvironmentSafe("test");
|
|
442
|
+
* if (testEnv) {
|
|
443
|
+
* // Environment exists, safe to use it
|
|
444
|
+
* } else {
|
|
445
|
+
* // Environment does not exist, handle accordingly
|
|
446
|
+
* }
|
|
447
|
+
* ```
|
|
448
|
+
*
|
|
449
|
+
* Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
|
|
450
|
+
*/
|
|
451
|
+
getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
|
|
452
|
+
/**
|
|
453
|
+
* A function to copy the context and update the fields for a specific environment
|
|
454
|
+
*
|
|
455
|
+
* @param environment - The environment configuration to use.
|
|
456
|
+
* @returns A new context instance with the updated environment.
|
|
457
|
+
*/
|
|
458
|
+
in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
|
|
459
|
+
/**
|
|
460
|
+
* A function to merge all configured environments into a single context
|
|
461
|
+
*
|
|
462
|
+
* @returns A promise that resolves to the merged environment context.
|
|
463
|
+
*/
|
|
464
|
+
toEnvironment: () => Promise<EnvironmentContext<TResolvedConfig>>;
|
|
465
|
+
}
|
|
466
|
+
interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
467
|
+
plugin: Plugin<PluginContext<TResolvedConfig>>;
|
|
468
|
+
context: PluginContext<TResolvedConfig>;
|
|
469
|
+
}
|
|
470
|
+
type SelectHookResultItem<TContext extends PluginContext, TKey extends string> = InferHooksListItem<TContext, TKey> & {
|
|
471
|
+
context: TContext;
|
|
472
|
+
};
|
|
473
|
+
type SelectHookResult<TContext extends PluginContext, TKey extends string> = SelectHookResultItem<TContext, TKey>[];
|
|
474
|
+
interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
|
|
475
|
+
/**
|
|
476
|
+
* The expected plugins options for the Powerlines project.
|
|
477
|
+
*
|
|
478
|
+
* @remarks
|
|
479
|
+
* This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
|
|
480
|
+
*/
|
|
481
|
+
plugins: EnvironmentContextPlugin<TResolvedConfig>[];
|
|
482
|
+
/**
|
|
483
|
+
* A function to add a plugin to the context and update the configuration options
|
|
484
|
+
*/
|
|
485
|
+
addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
|
|
486
|
+
/**
|
|
487
|
+
* The environment specific resolved configuration
|
|
488
|
+
*/
|
|
489
|
+
environment: EnvironmentResolvedConfig;
|
|
490
|
+
/**
|
|
491
|
+
* A table holding references to hook functions registered by plugins
|
|
492
|
+
*/
|
|
493
|
+
hooks: HooksList<PluginContext<TResolvedConfig>>;
|
|
494
|
+
/**
|
|
495
|
+
* Retrieves the hook handlers for a specific hook name
|
|
496
|
+
*/
|
|
497
|
+
selectHooks: <TKey extends string>(key: TKey, options?: SelectHooksOptions) => SelectHookResult<PluginContext<TResolvedConfig>, TKey>;
|
|
498
|
+
}
|
|
388
499
|
interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
|
|
389
500
|
/**
|
|
390
501
|
* The environment specific resolved configuration
|
|
@@ -399,5 +510,6 @@ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
399
510
|
logger: LogFn;
|
|
400
511
|
}
|
|
401
512
|
type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
|
|
513
|
+
type WithUnpluginBuildContext<TContext extends PluginContext> = UnpluginBuildContext & TContext;
|
|
402
514
|
//#endregion
|
|
403
|
-
export { BuildPluginContext, PluginContext, UnresolvedContext };
|
|
515
|
+
export { APIContext, BuildPluginContext, Context, EnvironmentContext, PluginContext, SelectHooksOptions, UnresolvedContext, WithUnpluginBuildContext };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ResolveOptions, VirtualFile, VirtualFileSystemInterface, WriteOptions } from "./fs.mjs";
|
|
2
2
|
import { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.mjs";
|
|
3
|
-
import "./
|
|
3
|
+
import { HooksList, InferHooksListItem } from "./hooks.mjs";
|
|
4
|
+
import { Plugin } from "./plugin.mjs";
|
|
4
5
|
import { ParsedTypeScriptConfig } from "./tsconfig.mjs";
|
|
5
6
|
import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.mjs";
|
|
6
|
-
import "./hooks.mjs";
|
|
7
7
|
import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
|
|
8
8
|
import { Project } from "ts-morph";
|
|
9
9
|
import { EnvPaths } from "@stryke/env/get-env-paths";
|
|
@@ -51,6 +51,9 @@ interface TransformResult$1 {
|
|
|
51
51
|
code: string;
|
|
52
52
|
map: SourceMap | null;
|
|
53
53
|
}
|
|
54
|
+
interface SelectHooksOptions {
|
|
55
|
+
order?: "pre" | "post" | "normal";
|
|
56
|
+
}
|
|
54
57
|
/**
|
|
55
58
|
* Options for initializing or updating the context with new configuration values
|
|
56
59
|
*/
|
|
@@ -387,6 +390,112 @@ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<Unr
|
|
|
387
390
|
*/
|
|
388
391
|
config: TResolvedConfig;
|
|
389
392
|
};
|
|
393
|
+
interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
|
|
394
|
+
/**
|
|
395
|
+
* The expected plugins options for the Powerlines project.
|
|
396
|
+
*
|
|
397
|
+
* @remarks
|
|
398
|
+
* This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
|
|
399
|
+
*/
|
|
400
|
+
plugins: Plugin<PluginContext<TResolvedConfig>>[];
|
|
401
|
+
/**
|
|
402
|
+
* A function to add a plugin to the context and update the configuration options
|
|
403
|
+
*/
|
|
404
|
+
addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* A table for storing the current context for each configured environment
|
|
407
|
+
*/
|
|
408
|
+
environments: Record<string, EnvironmentContext<TResolvedConfig>>;
|
|
409
|
+
/**
|
|
410
|
+
* Retrieves the context for a specific environment by name
|
|
411
|
+
*
|
|
412
|
+
* @throws Will throw an error if the environment does not exist
|
|
413
|
+
*
|
|
414
|
+
* @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
|
|
415
|
+
* @returns A promise that resolves to the environment context.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* const devEnv = await apiContext.getEnvironment("development");
|
|
420
|
+
* const defaultEnv = await apiContext.getEnvironment();
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
|
|
424
|
+
/**
|
|
425
|
+
* Safely retrieves the context for a specific environment by name
|
|
426
|
+
*
|
|
427
|
+
* @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
|
|
428
|
+
* @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```ts
|
|
432
|
+
* const devEnv = await apiContext.getEnvironmentSafe("development");
|
|
433
|
+
* const defaultEnv = await apiContext.getEnvironmentSafe();
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @remarks
|
|
437
|
+
* This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
|
|
438
|
+
* This can be useful in scenarios where the existence of an environment is optional or uncertain.
|
|
439
|
+
*
|
|
440
|
+
* ```ts
|
|
441
|
+
* const testEnv = await apiContext.getEnvironmentSafe("test");
|
|
442
|
+
* if (testEnv) {
|
|
443
|
+
* // Environment exists, safe to use it
|
|
444
|
+
* } else {
|
|
445
|
+
* // Environment does not exist, handle accordingly
|
|
446
|
+
* }
|
|
447
|
+
* ```
|
|
448
|
+
*
|
|
449
|
+
* Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
|
|
450
|
+
*/
|
|
451
|
+
getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
|
|
452
|
+
/**
|
|
453
|
+
* A function to copy the context and update the fields for a specific environment
|
|
454
|
+
*
|
|
455
|
+
* @param environment - The environment configuration to use.
|
|
456
|
+
* @returns A new context instance with the updated environment.
|
|
457
|
+
*/
|
|
458
|
+
in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
|
|
459
|
+
/**
|
|
460
|
+
* A function to merge all configured environments into a single context
|
|
461
|
+
*
|
|
462
|
+
* @returns A promise that resolves to the merged environment context.
|
|
463
|
+
*/
|
|
464
|
+
toEnvironment: () => Promise<EnvironmentContext<TResolvedConfig>>;
|
|
465
|
+
}
|
|
466
|
+
interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
467
|
+
plugin: Plugin<PluginContext<TResolvedConfig>>;
|
|
468
|
+
context: PluginContext<TResolvedConfig>;
|
|
469
|
+
}
|
|
470
|
+
type SelectHookResultItem<TContext extends PluginContext, TKey extends string> = InferHooksListItem<TContext, TKey> & {
|
|
471
|
+
context: TContext;
|
|
472
|
+
};
|
|
473
|
+
type SelectHookResult<TContext extends PluginContext, TKey extends string> = SelectHookResultItem<TContext, TKey>[];
|
|
474
|
+
interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
|
|
475
|
+
/**
|
|
476
|
+
* The expected plugins options for the Powerlines project.
|
|
477
|
+
*
|
|
478
|
+
* @remarks
|
|
479
|
+
* This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
|
|
480
|
+
*/
|
|
481
|
+
plugins: EnvironmentContextPlugin<TResolvedConfig>[];
|
|
482
|
+
/**
|
|
483
|
+
* A function to add a plugin to the context and update the configuration options
|
|
484
|
+
*/
|
|
485
|
+
addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
|
|
486
|
+
/**
|
|
487
|
+
* The environment specific resolved configuration
|
|
488
|
+
*/
|
|
489
|
+
environment: EnvironmentResolvedConfig;
|
|
490
|
+
/**
|
|
491
|
+
* A table holding references to hook functions registered by plugins
|
|
492
|
+
*/
|
|
493
|
+
hooks: HooksList<PluginContext<TResolvedConfig>>;
|
|
494
|
+
/**
|
|
495
|
+
* Retrieves the hook handlers for a specific hook name
|
|
496
|
+
*/
|
|
497
|
+
selectHooks: <TKey extends string>(key: TKey, options?: SelectHooksOptions) => SelectHookResult<PluginContext<TResolvedConfig>, TKey>;
|
|
498
|
+
}
|
|
390
499
|
interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
|
|
391
500
|
/**
|
|
392
501
|
* The environment specific resolved configuration
|
|
@@ -401,5 +510,6 @@ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
401
510
|
logger: LogFn;
|
|
402
511
|
}
|
|
403
512
|
type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
|
|
513
|
+
type WithUnpluginBuildContext<TContext extends PluginContext> = UnpluginBuildContext & TContext;
|
|
404
514
|
//#endregion
|
|
405
|
-
export { BuildPluginContext, PluginContext, UnresolvedContext };
|
|
515
|
+
export { APIContext, BuildPluginContext, Context, EnvironmentContext, PluginContext, SelectHooksOptions, UnresolvedContext, WithUnpluginBuildContext };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UnpluginBuilderVariant } from "./build.cjs";
|
|
2
|
+
import { Plugin, PluginHookFields, PluginHookFunctions } from "./plugin.cjs";
|
|
3
|
+
import { PluginContext, WithUnpluginBuildContext } from "./context.cjs";
|
|
4
|
+
import { UnpluginOptions } from "unplugin";
|
|
5
|
+
|
|
6
|
+
//#region ../powerlines/src/types/hooks.d.ts
|
|
7
|
+
type HookListOrders = "preOrdered" | "preEnforced" | "normal" | "postEnforced" | "postOrdered";
|
|
8
|
+
type UnpluginHookFunctions<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> = Required<UnpluginOptions>[TUnpluginBuilderVariant$1][TField$1] extends infer THandler | {
|
|
9
|
+
handler: infer THandler;
|
|
10
|
+
} ? THandler extends ((this: infer THandlerOriginalContext, ...args: infer THandlerArgs) => infer THandlerReturn) ? (this: THandlerOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerArgs) => THandlerReturn : THandler extends {
|
|
11
|
+
handler: infer THandlerFunction;
|
|
12
|
+
} ? THandlerFunction extends ((this: infer THandlerFunctionOriginalContext, ...args: infer THandlerFunctionArgs) => infer THandlerFunctionReturn) ? (this: THandlerFunctionOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerFunctionArgs) => THandlerFunctionReturn : never : never : never;
|
|
13
|
+
interface PluginHooksListItem<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> {
|
|
14
|
+
plugin: Plugin<TContext>;
|
|
15
|
+
handler: PluginHookFunctions<TContext>[TFields];
|
|
16
|
+
}
|
|
17
|
+
type PluginHooksList<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> = { [TKey in HookListOrders]?: PluginHooksListItem<TContext, TFields>[] | undefined };
|
|
18
|
+
interface UnpluginHooksListItem<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> {
|
|
19
|
+
plugin: Plugin<TContext>;
|
|
20
|
+
handler: UnpluginHookFunctions<TContext, TUnpluginBuilderVariant$1, TField$1>;
|
|
21
|
+
}
|
|
22
|
+
type UnpluginHookList<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof UnpluginOptions[TUnpluginBuilderVariant$1] = keyof UnpluginOptions[TUnpluginBuilderVariant$1]> = { [TKey in HookListOrders]?: UnpluginHooksListItem<TContext, TUnpluginBuilderVariant$1, TField$1>[] | undefined };
|
|
23
|
+
type UnpluginHookVariantField<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant> = { [TKey in keyof UnpluginOptions[TUnpluginBuilderVariant$1]]?: UnpluginHookList<TContext, TUnpluginBuilderVariant$1, TKey> };
|
|
24
|
+
type UnpluginHookVariant<TContext extends PluginContext = PluginContext> = { [TKey in UnpluginBuilderVariant]?: UnpluginHookVariantField<TContext, TKey> };
|
|
25
|
+
type HookFields<TContext extends PluginContext = PluginContext> = PluginHookFields<TContext> | UnpluginBuilderVariant;
|
|
26
|
+
type HooksList<TContext extends PluginContext = PluginContext> = { [TField in HookFields<TContext>]?: TField extends PluginHookFields<TContext> ? PluginHooksList<TContext, TField> : TField extends UnpluginBuilderVariant ? UnpluginHookVariant<TContext>[TField] : never };
|
|
27
|
+
type InferHooksListItem<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHooksListItem<TContext, TKey$1> : never;
|
|
28
|
+
type InferHookFunction<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHookFunctions<TContext>[TKey$1] : never;
|
|
29
|
+
type InferHookReturnType<TContext extends PluginContext, TKey$1 extends string> = ReturnType<InferHookFunction<TContext, TKey$1>>;
|
|
30
|
+
type InferHookParameters<TContext extends PluginContext, TKey$1 extends string> = Parameters<InferHookFunction<TContext, TKey$1>>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { HooksList, InferHookParameters, InferHookReturnType, InferHooksListItem };
|
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
1
|
+
import { UnpluginBuilderVariant } from "./build.mjs";
|
|
2
|
+
import { Plugin, PluginHookFields, PluginHookFunctions } from "./plugin.mjs";
|
|
3
|
+
import { PluginContext, WithUnpluginBuildContext } from "./context.mjs";
|
|
4
|
+
import { UnpluginOptions } from "unplugin";
|
|
5
|
+
|
|
6
|
+
//#region ../powerlines/src/types/hooks.d.ts
|
|
7
|
+
type HookListOrders = "preOrdered" | "preEnforced" | "normal" | "postEnforced" | "postOrdered";
|
|
8
|
+
type UnpluginHookFunctions<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> = Required<UnpluginOptions>[TUnpluginBuilderVariant$1][TField$1] extends infer THandler | {
|
|
9
|
+
handler: infer THandler;
|
|
10
|
+
} ? THandler extends ((this: infer THandlerOriginalContext, ...args: infer THandlerArgs) => infer THandlerReturn) ? (this: THandlerOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerArgs) => THandlerReturn : THandler extends {
|
|
11
|
+
handler: infer THandlerFunction;
|
|
12
|
+
} ? THandlerFunction extends ((this: infer THandlerFunctionOriginalContext, ...args: infer THandlerFunctionArgs) => infer THandlerFunctionReturn) ? (this: THandlerFunctionOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerFunctionArgs) => THandlerFunctionReturn : never : never : never;
|
|
13
|
+
interface PluginHooksListItem<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> {
|
|
14
|
+
plugin: Plugin<TContext>;
|
|
15
|
+
handler: PluginHookFunctions<TContext>[TFields];
|
|
16
|
+
}
|
|
17
|
+
type PluginHooksList<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> = { [TKey in HookListOrders]?: PluginHooksListItem<TContext, TFields>[] | undefined };
|
|
18
|
+
interface UnpluginHooksListItem<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> {
|
|
19
|
+
plugin: Plugin<TContext>;
|
|
20
|
+
handler: UnpluginHookFunctions<TContext, TUnpluginBuilderVariant$1, TField$1>;
|
|
21
|
+
}
|
|
22
|
+
type UnpluginHookList<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof UnpluginOptions[TUnpluginBuilderVariant$1] = keyof UnpluginOptions[TUnpluginBuilderVariant$1]> = { [TKey in HookListOrders]?: UnpluginHooksListItem<TContext, TUnpluginBuilderVariant$1, TField$1>[] | undefined };
|
|
23
|
+
type UnpluginHookVariantField<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant> = { [TKey in keyof UnpluginOptions[TUnpluginBuilderVariant$1]]?: UnpluginHookList<TContext, TUnpluginBuilderVariant$1, TKey> };
|
|
24
|
+
type UnpluginHookVariant<TContext extends PluginContext = PluginContext> = { [TKey in UnpluginBuilderVariant]?: UnpluginHookVariantField<TContext, TKey> };
|
|
25
|
+
type HookFields<TContext extends PluginContext = PluginContext> = PluginHookFields<TContext> | UnpluginBuilderVariant;
|
|
26
|
+
type HooksList<TContext extends PluginContext = PluginContext> = { [TField in HookFields<TContext>]?: TField extends PluginHookFields<TContext> ? PluginHooksList<TContext, TField> : TField extends UnpluginBuilderVariant ? UnpluginHookVariant<TContext>[TField] : never };
|
|
27
|
+
type InferHooksListItem<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHooksListItem<TContext, TKey$1> : never;
|
|
28
|
+
type InferHookFunction<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHookFunctions<TContext>[TKey$1] : never;
|
|
29
|
+
type InferHookReturnType<TContext extends PluginContext, TKey$1 extends string> = ReturnType<InferHookFunction<TContext, TKey$1>>;
|
|
30
|
+
type InferHookParameters<TContext extends PluginContext, TKey$1 extends string> = Parameters<InferHookFunction<TContext, TKey$1>>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { HooksList, InferHookParameters, InferHookReturnType, InferHooksListItem };
|
|
@@ -9,11 +9,12 @@ const PLUGIN_NON_HOOK_FIELDS = [
|
|
|
9
9
|
"dedupe",
|
|
10
10
|
"applyToEnvironment"
|
|
11
11
|
];
|
|
12
|
-
const
|
|
12
|
+
const PLUGIN_HOOKS_FIELDS = [
|
|
13
13
|
...require_commands.SUPPORTED_COMMANDS,
|
|
14
14
|
"config",
|
|
15
15
|
"configEnvironment",
|
|
16
16
|
"configResolved",
|
|
17
|
+
"types",
|
|
17
18
|
"buildStart",
|
|
18
19
|
"buildEnd",
|
|
19
20
|
"transform",
|
|
@@ -23,10 +24,10 @@ const KNOWN_HOOKS = [
|
|
|
23
24
|
];
|
|
24
25
|
const KNOWN_PLUGIN_FIELDS = [
|
|
25
26
|
...PLUGIN_NON_HOOK_FIELDS,
|
|
26
|
-
...
|
|
27
|
-
...require_build.
|
|
27
|
+
...PLUGIN_HOOKS_FIELDS,
|
|
28
|
+
...require_build.BUILDER_VARIANTS
|
|
28
29
|
];
|
|
29
30
|
|
|
30
31
|
//#endregion
|
|
31
|
-
exports.
|
|
32
|
+
exports.PLUGIN_HOOKS_FIELDS = PLUGIN_HOOKS_FIELDS;
|
|
32
33
|
exports.PLUGIN_NON_HOOK_FIELDS = PLUGIN_NON_HOOK_FIELDS;
|