@powerlines/core 0.14.1 → 0.14.3
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/lib/unplugin/plugin.cjs +2 -1
- package/dist/lib/unplugin/plugin.d.cts.map +1 -1
- package/dist/lib/unplugin/plugin.d.mts.map +1 -1
- package/dist/lib/unplugin/plugin.mjs +2 -1
- package/dist/lib/unplugin/plugin.mjs.map +1 -1
- package/dist/plugin-utils/combine-plugins.mjs.map +1 -1
- package/dist/types/config.d.cts +1 -1
- package/dist/types/config.d.mts +1 -1
- package/dist/types/context.d.cts +1 -1
- package/dist/types/context.d.mts +1 -1
- package/package.json +2 -2
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_lib_logger = require('../logger.cjs');
|
|
4
4
|
const require_lib_unplugin_helpers = require('./helpers.cjs');
|
|
5
|
+
const require_virtual_modules = require('../../constants/virtual-modules.cjs');
|
|
5
6
|
const require_lib_unplugin_module_resolution = require('./module-resolution.cjs');
|
|
6
7
|
const require_lib_utilities_source_file = require('../utilities/source-file.cjs');
|
|
7
8
|
let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
@@ -59,7 +60,7 @@ function createUnplugin(context, options = {}) {
|
|
|
59
60
|
async function transform(code, id) {
|
|
60
61
|
let transformed = code;
|
|
61
62
|
for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
|
|
62
|
-
const result = await hook.handler.apply(require_lib_unplugin_helpers.combineContexts(ctx, this), [require_lib_utilities_source_file.getString(transformed), id]);
|
|
63
|
+
const result = await hook.handler.apply(require_lib_unplugin_helpers.combineContexts(ctx, this), [require_lib_utilities_source_file.getString(transformed), id.replace(require_virtual_modules.VIRTUAL_MODULE_PREFIX_REGEX, "")]);
|
|
63
64
|
if (result) transformed = result;
|
|
64
65
|
}
|
|
65
66
|
return transformed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"mappings":";;;;;UAuCiB,6BAAA,SAAsC,8CAAA;;AAAvD;;;;;AAkBA;;EATE,IAAA;AAAA;;;;;;;iBASc,sBAAA,kBACG,aAAA,GAAgB,aAAA,CAAA,CAEjC,OAAA,EAAS,QAAA,EACT,OAAA,GAAS,6BAAA,GACR,eAAA,CAAgB,QAAA;AAAA,UA+BF,qBAAA,SAA8B,6BAAA;EAnC5B;;;;;EAyCjB,kBAAA;AAAA;;;;AANF;;;iBAegB,cAAA,kBAAgC,aAAA,GAAgB,aAAA,CAAA,CAC9D,OAAA,EAAS,QAAA,EACT,OAAA,GAAS,qBAAA,GACR,eAAA,CAAgB,QAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"mappings":";;;;;UAuCiB,6BAAA,SAAsC,8CAAA;;AAAvD;;;;;AAkBA;;EATE,IAAA;AAAA;;;;;;;iBASc,sBAAA,kBACG,aAAA,GAAgB,aAAA,CAAA,CAEjC,OAAA,EAAS,QAAA,EACT,OAAA,GAAS,6BAAA,GACR,eAAA,CAAgB,QAAA;AAAA,UA+BF,qBAAA,SAA8B,6BAAA;EAnC5B;;;;;EAyCjB,kBAAA;AAAA;;;;AANF;;;iBAegB,cAAA,kBAAgC,aAAA,GAAgB,aAAA,CAAA,CAC9D,OAAA,EAAS,QAAA,EACT,OAAA,GAAS,qBAAA,GACR,eAAA,CAAgB,QAAA;AAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { extendLog } from "../logger.mjs";
|
|
2
2
|
import { combineContexts } from "./helpers.mjs";
|
|
3
|
+
import { VIRTUAL_MODULE_PREFIX_REGEX } from "../../constants/virtual-modules.mjs";
|
|
3
4
|
import { createUnpluginModuleResolutionFunctions } from "./module-resolution.mjs";
|
|
4
5
|
import { getString } from "../utilities/source-file.mjs";
|
|
5
6
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
@@ -57,7 +58,7 @@ function createUnplugin(context, options = {}) {
|
|
|
57
58
|
async function transform(code, id) {
|
|
58
59
|
let transformed = code;
|
|
59
60
|
for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
|
|
60
|
-
const result = await hook.handler.apply(combineContexts(ctx, this), [getString(transformed), id]);
|
|
61
|
+
const result = await hook.handler.apply(combineContexts(ctx, this), [getString(transformed), id.replace(VIRTUAL_MODULE_PREFIX_REGEX, "")]);
|
|
61
62
|
if (result) transformed = result;
|
|
62
63
|
}
|
|
63
64
|
return transformed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Unstable_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"powerlines\". If provided, the plugin will be named `${name} - Powerlines` (e.g., \"MyPlugin - Powerlines\").\n *\n * @defaultValue \"powerlines\"\n */\n name?: string;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {\n /**\n * Whether to silence logging for the plugin hooks. This can be useful for plugins that run frequently or have hooks that are called often, to reduce noise in the logs. When set to `true`, the plugin will not log any messages for its hooks. When set to `false` (the default), the plugin will log messages for its hooks as normal.\n *\n * @defaultValue false\n */\n silenceHookLogging?: boolean;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = options.name ? extendLog(ctx.log, name) : ctx.log;\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n }\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n }\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n }\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load,\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/lib/unplugin/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Unstable_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { VIRTUAL_MODULE_PREFIX_REGEX } from \"../../constants/virtual-modules\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"powerlines\". If provided, the plugin will be named `${name} - Powerlines` (e.g., \"MyPlugin - Powerlines\").\n *\n * @defaultValue \"powerlines\"\n */\n name?: string;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {\n /**\n * Whether to silence logging for the plugin hooks. This can be useful for plugins that run frequently or have hooks that are called often, to reduce noise in the logs. When set to `true`, the plugin will not log any messages for its hooks. When set to `false` (the default), the plugin will log messages for its hooks as normal.\n *\n * @defaultValue false\n */\n silenceHookLogging?: boolean;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = options.name ? extendLog(ctx.log, name) : ctx.log;\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n }\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\")\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n }\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n }\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load,\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyDA,SAAgB,uBAGd,SACA,UAAyC,EAAE,EAChB;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;AACpC,MAAI,cAAc,OAAO,gBAAgB,UAAU,KAAK,CAAC,SAAS;AAElE,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;AAErE,UAAO;IACL,MACE,KAAK,aAAa,KAAK,eACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACD;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM;;;;;;;;;;AAoBZ,SAAgB,eACd,SACA,UAAiC,EAAE,EACR;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,QAAQ,OAAO,UAAU,IAAI,KAAK,KAAK,GAAG,IAAI;AAC1D,MAAI,cAAc,OAAO,gBAAgB,UAAU,KAAK,CAAC,SAAS;AAElE,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;GAErE,eAAe,aAAuC;AACpD,QAAI,CAAC,QAAQ,mBACX,KAAI,cAAc,OAAO,sCAAsC;AAGjE,UAAM,IAAI,WAAW,SAAS,cAAc,EAC1C,YAAY,MACb,CAAC;;GAGJ,eAAe,UAEb,MACA,IAC6C;IAC7C,IAAI,cAAwC;AAE5C,SAAK,MAAM,QAAQ,IAAI,WAAW,YAAY,YAC5C,YACD,EAAE;KACD,MAAM,SACJ,MAAM,KAAK,QAAQ,MAAM,gBAAgB,KAAK,KAAK,EAAE,CACnD,UAAU,YAAY,EACtB,GAAG,QAAQ,6BAA6B,GAAG,CAC5C,CAAC;AACJ,SAAI,OACF,eAAc;;AAIlB,WAAO;;GAGT,eAAe,WAAoD;AACjE,QAAI,CAAC,QAAQ,mBACX,KAAI,cAAc,OAAO,uCAAuC;AAGlE,WAAO,IAAI,WAAW,SAAS,YAAY,EACzC,YAAY,MACb,CAAC;;GAGJ,eAAe,cAA6B;AAC1C,QAAI,CAAC,QAAQ,mBACX,KAAI,cAAc,OAAO,0CAA0C;AAGrE,WAAO,IAAI,WAAW,SAAS,eAAe,EAC5C,YAAY,MACb,CAAC;;AAGJ,UAAO;IACL,MACE,KAAK,aAAa,KAAK,eACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACA;IACA;IACA;IACA;IACA,MAAM,EACJ,mBAAmB,MACpB;IACF;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combine-plugins.mjs","names":[],"sources":["../../src/plugin-utils/combine-plugins.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n createCombinePlugin,\n OptionsPlugin,\n UnpluginCombineInstance\n} from \"unplugin-combine\";\nimport { Plugin } from \"../types/plugin\";\nimport { merge } from \"./merge\";\n\n/**\n * Combines multiple plugins into a single plugin instance. This is useful for creating meta-plugins that encapsulate the functionality of multiple plugins, allowing users to easily include a set of related plugins with a single import.\n *\n * @param pluginOptions - The plugin options to combine, which can be a single plugin instance or an object containing plugin instances for different build tools.\n * @returns A single plugin instance that combines the functionality of the provided plugin options.\n */\nexport function combinePluginOptions(\n pluginOptions: UnpluginCombineInstance<any>\n) {\n return {\n async rollup() {\n return (await pluginOptions.rollup()).reduce(\n (ret, plugin) => merge(ret, plugin) as Plugin<any>,\n {} as Plugin<any>\n );\n },\n async rolldown() {\n return (await pluginOptions.rolldown()).reduce(\n (ret, plugin) => merge(ret, plugin) as Plugin<any>,\n {} as Plugin<any>\n );\n },\n async vite() {\n return (await pluginOptions.vite()).reduce(\n (ret, plugin) => merge(ret, plugin) as Plugin<any>,\n {} as Plugin<any>\n );\n },\n async esbuild() {\n return pluginOptions.esbuild();\n },\n async webpack() {\n return pluginOptions.webpack();\n },\n async rspack() {\n return pluginOptions.rspack();\n },\n get raw() {\n return pluginOptions;\n }\n };\n}\n\nexport interface CombinePluginsOptions {\n name?: string;\n plugins: OptionsPlugin[];\n}\n\n/**\n * Combines multiple plugins into a single plugin. This is useful for creating meta-plugins that encapsulate the functionality of multiple plugins, allowing users to easily include a set of related plugins with a single import.\n *\n * @param options - The options for combining plugins, including the name and the plugins to combine.\n * @returns A single plugin that combines the functionality of the provided plugins.\n */\nexport function combinePlugins(options: CombinePluginsOptions) {\n const {\n plugins,\n name = `powerlines-${plugins\n .filter(p => isSetObject(p) && \"name\" in p && isSetString(p.name))\n .map(p =>\n (p as { name: string }).name\n .replace(/^powerlines[\\-_:]?/, \"\")\n .replace(/[\\-_:]?powerlines$/, \"\")\n )\n .join(\"-\")}`\n } = options;\n\n return combinePluginOptions(\n createCombinePlugin(() => {\n return {\n name,\n plugins\n };\n })\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgB,qBACd,eACA;AACA,QAAO;EACL,MAAM,SAAS;AACb,WAAQ,MAAM,cAAc,QAAQ,EAAE,QACnC,KAAK,WAAW,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"combine-plugins.mjs","names":[],"sources":["../../src/plugin-utils/combine-plugins.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n createCombinePlugin,\n OptionsPlugin,\n UnpluginCombineInstance\n} from \"unplugin-combine\";\nimport { Plugin } from \"../types/plugin\";\nimport { merge } from \"./merge\";\n\n/**\n * Combines multiple plugins into a single plugin instance. This is useful for creating meta-plugins that encapsulate the functionality of multiple plugins, allowing users to easily include a set of related plugins with a single import.\n *\n * @param pluginOptions - The plugin options to combine, which can be a single plugin instance or an object containing plugin instances for different build tools.\n * @returns A single plugin instance that combines the functionality of the provided plugin options.\n */\nexport function combinePluginOptions(\n pluginOptions: UnpluginCombineInstance<any>\n) {\n return {\n async rollup() {\n return (await pluginOptions.rollup()).reduce(\n (ret, plugin) => merge(ret, plugin as Plugin<any>) as Plugin<any>,\n {} as Plugin<any>\n );\n },\n async rolldown() {\n return (await pluginOptions.rolldown()).reduce(\n (ret, plugin) => merge(ret, plugin as Plugin<any>) as Plugin<any>,\n {} as Plugin<any>\n );\n },\n async vite() {\n return (await pluginOptions.vite()).reduce(\n (ret, plugin) => merge(ret, plugin as Plugin<any>) as Plugin<any>,\n {} as Plugin<any>\n );\n },\n async esbuild() {\n return pluginOptions.esbuild();\n },\n async webpack() {\n return pluginOptions.webpack();\n },\n async rspack() {\n return pluginOptions.rspack();\n },\n get raw() {\n return pluginOptions;\n }\n };\n}\n\nexport interface CombinePluginsOptions {\n name?: string;\n plugins: OptionsPlugin[];\n}\n\n/**\n * Combines multiple plugins into a single plugin. This is useful for creating meta-plugins that encapsulate the functionality of multiple plugins, allowing users to easily include a set of related plugins with a single import.\n *\n * @param options - The options for combining plugins, including the name and the plugins to combine.\n * @returns A single plugin that combines the functionality of the provided plugins.\n */\nexport function combinePlugins(options: CombinePluginsOptions) {\n const {\n plugins,\n name = `powerlines-${plugins\n .filter(p => isSetObject(p) && \"name\" in p && isSetString(p.name))\n .map(p =>\n (p as { name: string }).name\n .replace(/^powerlines[\\-_:]?/, \"\")\n .replace(/[\\-_:]?powerlines$/, \"\")\n )\n .join(\"-\")}`\n } = options;\n\n return combinePluginOptions(\n createCombinePlugin(() => {\n return {\n name,\n plugins\n };\n })\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgB,qBACd,eACA;AACA,QAAO;EACL,MAAM,SAAS;AACb,WAAQ,MAAM,cAAc,QAAQ,EAAE,QACnC,KAAK,WAAW,MAAM,KAAK,OAAsB,EAClD,EAAE,CACH;;EAEH,MAAM,WAAW;AACf,WAAQ,MAAM,cAAc,UAAU,EAAE,QACrC,KAAK,WAAW,MAAM,KAAK,OAAsB,EAClD,EAAE,CACH;;EAEH,MAAM,OAAO;AACX,WAAQ,MAAM,cAAc,MAAM,EAAE,QACjC,KAAK,WAAW,MAAM,KAAK,OAAsB,EAClD,EAAE,CACH;;EAEH,MAAM,UAAU;AACd,UAAO,cAAc,SAAS;;EAEhC,MAAM,UAAU;AACd,UAAO,cAAc,SAAS;;EAEhC,MAAM,SAAS;AACb,UAAO,cAAc,QAAQ;;EAE/B,IAAI,MAAM;AACR,UAAO;;EAEV;;;;;;;;AAcH,SAAgB,eAAe,SAAgC;CAC7D,MAAM,EACJ,SACA,OAAO,cAAc,QAClB,QAAO,MAAK,YAAY,EAAE,IAAI,UAAU,KAAK,YAAY,EAAE,KAAK,CAAC,CACjE,KAAI,MACF,EAAuB,KACrB,QAAQ,sBAAsB,GAAG,CACjC,QAAQ,sBAAsB,GAAG,CACrC,CACA,KAAK,IAAI,OACV;AAEJ,QAAO,qBACL,0BAA0B;AACxB,SAAO;GACL;GACA;GACD;GACD,CACH"}
|
package/dist/types/config.d.cts
CHANGED
|
@@ -481,7 +481,7 @@ type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserCo
|
|
|
481
481
|
/**
|
|
482
482
|
* Additional arguments provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed.
|
|
483
483
|
*/
|
|
484
|
-
additionalArgs?: Record<string, string>;
|
|
484
|
+
additionalArgs?: Record<string, string | string[]>;
|
|
485
485
|
};
|
|
486
486
|
type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
|
|
487
487
|
/**
|
package/dist/types/config.d.mts
CHANGED
|
@@ -481,7 +481,7 @@ type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserCo
|
|
|
481
481
|
/**
|
|
482
482
|
* Additional arguments provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed.
|
|
483
483
|
*/
|
|
484
|
-
additionalArgs?: Record<string, string>;
|
|
484
|
+
additionalArgs?: Record<string, string | string[]>;
|
|
485
485
|
};
|
|
486
486
|
type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
|
|
487
487
|
/**
|
package/dist/types/context.d.cts
CHANGED
|
@@ -338,7 +338,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
338
338
|
/**
|
|
339
339
|
* Additional arguments provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed.
|
|
340
340
|
*/
|
|
341
|
-
additionalArgs: Record<string, string>;
|
|
341
|
+
additionalArgs: Record<string, string | string[]>;
|
|
342
342
|
/**
|
|
343
343
|
* A function to perform HTTP fetch requests
|
|
344
344
|
*
|
package/dist/types/context.d.mts
CHANGED
|
@@ -338,7 +338,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
338
338
|
/**
|
|
339
339
|
* Additional arguments provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed.
|
|
340
340
|
*/
|
|
341
|
-
additionalArgs: Record<string, string>;
|
|
341
|
+
additionalArgs: Record<string, string | string[]>;
|
|
342
342
|
/**
|
|
343
343
|
* A function to perform HTTP fetch requests
|
|
344
344
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/core",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
|
|
6
6
|
"homepage": "https://stormsoftware.com",
|
|
@@ -569,5 +569,5 @@
|
|
|
569
569
|
"typescript": "^6.0.3"
|
|
570
570
|
},
|
|
571
571
|
"publishConfig": { "access": "public" },
|
|
572
|
-
"gitHead": "
|
|
572
|
+
"gitHead": "f148d4759d20c66a7f05f248680578f4329e8f3b"
|
|
573
573
|
}
|