@powerlines/plugin-babel 0.12.129 → 0.12.131
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/ast-utils-BcmWaIan.cjs +45 -0
- package/dist/ast-utils-Bs6DBkKg.d.mts +19 -0
- package/dist/ast-utils-DU1foCxH.mjs +32 -0
- package/dist/ast-utils-DeuXcuqs.d.cts +19 -0
- package/dist/babel-B9i2IAT_.d.cts +1805 -0
- package/dist/babel-DY_imD3U.d.mts +1805 -0
- package/dist/{_virtual/rolldown_runtime.cjs → chunk-CbDLau6x.cjs} +6 -1
- package/dist/create-plugin-BPSvsem_.mjs +73 -0
- package/dist/create-plugin-CNzMrex8.d.mts +14 -0
- package/dist/create-plugin-CQA6zFdt.d.cts +14 -0
- package/dist/create-plugin-Cs1zZrvI.cjs +80 -0
- package/dist/filters-93Z-7Nov.d.mts +44 -0
- package/dist/filters-C04cfcQR.mjs +55 -0
- package/dist/filters-D6Qe6UbO.d.cts +41 -0
- package/dist/filters-Dl2RKvrm.cjs +79 -0
- package/dist/helpers/ast-utils.cjs +3 -34
- package/dist/helpers/ast-utils.d.cts +2 -19
- package/dist/helpers/ast-utils.d.mts +2 -19
- package/dist/helpers/ast-utils.mjs +1 -30
- package/dist/helpers/create-plugin.cjs +2 -40
- package/dist/helpers/create-plugin.d.cts +2 -14
- package/dist/helpers/create-plugin.d.mts +2 -14
- package/dist/helpers/create-plugin.mjs +1 -37
- package/dist/helpers/filters.cjs +5 -58
- package/dist/helpers/filters.d.cts +2 -41
- package/dist/helpers/filters.d.mts +2 -42
- package/dist/helpers/filters.mjs +1 -53
- package/dist/helpers/index.cjs +22 -21
- package/dist/helpers/index.d.cts +7 -5
- package/dist/helpers/index.d.mts +7 -5
- package/dist/helpers/index.mjs +6 -5
- package/dist/helpers/module-helpers.cjs +9 -102
- package/dist/helpers/module-helpers.d.cts +2 -48
- package/dist/helpers/module-helpers.d.mts +2 -48
- package/dist/helpers/module-helpers.mjs +2 -93
- package/dist/helpers/options.cjs +4 -49
- package/dist/helpers/options.d.cts +2 -17
- package/dist/helpers/options.d.mts +2 -17
- package/dist/helpers/options.mjs +2 -45
- package/dist/helpers-BnW_4z5h.mjs +1 -0
- package/dist/helpers-Bx2yBrpn.cjs +0 -0
- package/dist/index-ClXLQ1fw.d.mts +1 -0
- package/dist/index-DeEmP3Jc.d.cts +1 -0
- package/dist/index-QbUkWSLh.d.mts +1 -0
- package/dist/index-zO0Ly4bS.d.cts +1 -0
- package/dist/index.cjs +29 -27
- package/dist/index.d.cts +9 -8
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +8 -6
- package/dist/module-helpers-Ckq8sc4l.mjs +95 -0
- package/dist/module-helpers-DRUocgcq.d.cts +49 -0
- package/dist/module-helpers-DiSYdstQ.d.mts +49 -0
- package/dist/module-helpers-Non-jHMu.cjs +138 -0
- package/dist/options-BQhc80ih.mjs +47 -0
- package/dist/options-CCMyIIWc.d.cts +17 -0
- package/dist/options-DgdPmsbF.d.mts +17 -0
- package/dist/options-u2MhTIFH.cjs +60 -0
- package/dist/plugin-BL8TLixo.mjs +1 -0
- package/dist/plugin-BSBH78mm.cjs +0 -0
- package/dist/plugin-Bc0EOyGF.d.mts +17 -0
- package/dist/plugin-DhjfPNQS.d.cts +17 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +3 -1
- package/dist/types/index.d.mts +3 -1
- package/dist/types/index.mjs +3 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +2 -18
- package/dist/types/plugin.d.mts +2 -18
- package/dist/types/plugin.mjs +2 -0
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CvhspRRt.mjs +1 -0
- package/package.json +5 -5
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -5
- package/dist/powerlines/src/lib/logger.cjs +0 -41
- package/dist/powerlines/src/lib/logger.mjs +0 -39
- package/dist/powerlines/src/types/api.d.mts +0 -5
- package/dist/powerlines/src/types/babel.d.cts +0 -50
- package/dist/powerlines/src/types/babel.d.mts +0 -50
- package/dist/powerlines/src/types/build.d.cts +0 -145
- package/dist/powerlines/src/types/build.d.mts +0 -145
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/commands.d.mts +0 -9
- package/dist/powerlines/src/types/config.d.cts +0 -380
- package/dist/powerlines/src/types/config.d.mts +0 -380
- package/dist/powerlines/src/types/context.d.cts +0 -403
- package/dist/powerlines/src/types/context.d.mts +0 -405
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/fs.d.mts +0 -486
- package/dist/powerlines/src/types/hooks.d.mts +0 -2
- package/dist/powerlines/src/types/index.d.mts +0 -12
- package/dist/powerlines/src/types/plugin.d.cts +0 -231
- package/dist/powerlines/src/types/plugin.d.mts +0 -231
- package/dist/powerlines/src/types/resolved.d.cts +0 -82
- package/dist/powerlines/src/types/resolved.d.mts +0 -82
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
- package/dist/powerlines/src/types/unplugin.d.mts +0 -6
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { declare } from "@babel/helper-plugin-utils";
|
|
4
|
+
import "@storm-software/config-tools/logger";
|
|
5
|
+
import "@storm-software/config-tools/utilities/colors";
|
|
6
|
+
import "@stryke/helpers/noop";
|
|
7
|
+
import "@stryke/string-format/kebab-case";
|
|
8
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
9
|
+
|
|
10
|
+
//#region ../powerlines/src/lib/logger.ts
|
|
11
|
+
const BADGE_COLORS = [
|
|
12
|
+
"#00A0DD",
|
|
13
|
+
"#6FCE4E",
|
|
14
|
+
"#FBBF24",
|
|
15
|
+
"#F43F5E",
|
|
16
|
+
"#3B82F6",
|
|
17
|
+
"#A855F7",
|
|
18
|
+
"#469592",
|
|
19
|
+
"#288EDF",
|
|
20
|
+
"#D8B4FE",
|
|
21
|
+
"#10B981",
|
|
22
|
+
"#EF4444",
|
|
23
|
+
"#F0EC56",
|
|
24
|
+
"#F472B6",
|
|
25
|
+
"#22D3EE",
|
|
26
|
+
"#EAB308",
|
|
27
|
+
"#84CC16",
|
|
28
|
+
"#F87171",
|
|
29
|
+
"#0EA5E9",
|
|
30
|
+
"#D946EF",
|
|
31
|
+
"#FACC15",
|
|
32
|
+
"#34D399",
|
|
33
|
+
"#8B5CF6"
|
|
34
|
+
];
|
|
35
|
+
const extendLog = (logFn, name) => {
|
|
36
|
+
return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/helpers/create-plugin.ts
|
|
41
|
+
/**
|
|
42
|
+
* Create a Babel plugin using the provided builder function.
|
|
43
|
+
*
|
|
44
|
+
* @param name - The name of the plugin.
|
|
45
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
46
|
+
* @returns A Babel plugin declaration.
|
|
47
|
+
*/
|
|
48
|
+
function createBabelPlugin(name, builder) {
|
|
49
|
+
const plugin = (context) => {
|
|
50
|
+
return declare((api, options, dirname) => {
|
|
51
|
+
api.cache.using(() => context.meta.checksum);
|
|
52
|
+
api.assertVersion("^7.0.0-0");
|
|
53
|
+
const log = extendLog(context.log, name);
|
|
54
|
+
log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
55
|
+
const result = builder({
|
|
56
|
+
log,
|
|
57
|
+
name,
|
|
58
|
+
api,
|
|
59
|
+
options,
|
|
60
|
+
context,
|
|
61
|
+
dirname
|
|
62
|
+
});
|
|
63
|
+
result.name = name;
|
|
64
|
+
log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
65
|
+
return result;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
plugin.$$name = name;
|
|
69
|
+
return plugin;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { createBabelPlugin as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { a as DeclareBabelTransformPluginReturn, n as BabelTransformPluginBuilder, u as Context } from "./babel-DY_imD3U.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/create-plugin.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a Babel plugin using the provided builder function.
|
|
7
|
+
*
|
|
8
|
+
* @param name - The name of the plugin.
|
|
9
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
10
|
+
* @returns A Babel plugin declaration.
|
|
11
|
+
*/
|
|
12
|
+
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createBabelPlugin as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { a as DeclareBabelTransformPluginReturn, n as BabelTransformPluginBuilder, u as Context } from "./babel-B9i2IAT_.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/create-plugin.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a Babel plugin using the provided builder function.
|
|
7
|
+
*
|
|
8
|
+
* @param name - The name of the plugin.
|
|
9
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
10
|
+
* @returns A Babel plugin declaration.
|
|
11
|
+
*/
|
|
12
|
+
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createBabelPlugin as t };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
3
|
+
let chalk = require("chalk");
|
|
4
|
+
chalk = require_chunk.__toESM(chalk);
|
|
5
|
+
let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
6
|
+
require("@storm-software/config-tools/logger");
|
|
7
|
+
require("@storm-software/config-tools/utilities/colors");
|
|
8
|
+
require("@stryke/helpers/noop");
|
|
9
|
+
require("@stryke/string-format/kebab-case");
|
|
10
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
11
|
+
|
|
12
|
+
//#region ../powerlines/src/lib/logger.ts
|
|
13
|
+
const BADGE_COLORS = [
|
|
14
|
+
"#00A0DD",
|
|
15
|
+
"#6FCE4E",
|
|
16
|
+
"#FBBF24",
|
|
17
|
+
"#F43F5E",
|
|
18
|
+
"#3B82F6",
|
|
19
|
+
"#A855F7",
|
|
20
|
+
"#469592",
|
|
21
|
+
"#288EDF",
|
|
22
|
+
"#D8B4FE",
|
|
23
|
+
"#10B981",
|
|
24
|
+
"#EF4444",
|
|
25
|
+
"#F0EC56",
|
|
26
|
+
"#F472B6",
|
|
27
|
+
"#22D3EE",
|
|
28
|
+
"#EAB308",
|
|
29
|
+
"#84CC16",
|
|
30
|
+
"#F87171",
|
|
31
|
+
"#0EA5E9",
|
|
32
|
+
"#D946EF",
|
|
33
|
+
"#FACC15",
|
|
34
|
+
"#34D399",
|
|
35
|
+
"#8B5CF6"
|
|
36
|
+
];
|
|
37
|
+
const extendLog = (logFn, name) => {
|
|
38
|
+
return (type, ...args) => logFn(type, ` ${chalk.default.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${(0, __stryke_string_format_title_case.titleCase)(name)} `)} ${args.join(" ")} `);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/helpers/create-plugin.ts
|
|
43
|
+
/**
|
|
44
|
+
* Create a Babel plugin using the provided builder function.
|
|
45
|
+
*
|
|
46
|
+
* @param name - The name of the plugin.
|
|
47
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
48
|
+
* @returns A Babel plugin declaration.
|
|
49
|
+
*/
|
|
50
|
+
function createBabelPlugin(name, builder) {
|
|
51
|
+
const plugin = (context) => {
|
|
52
|
+
return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
|
|
53
|
+
api.cache.using(() => context.meta.checksum);
|
|
54
|
+
api.assertVersion("^7.0.0-0");
|
|
55
|
+
const log = extendLog(context.log, name);
|
|
56
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
57
|
+
const result = builder({
|
|
58
|
+
log,
|
|
59
|
+
name,
|
|
60
|
+
api,
|
|
61
|
+
options,
|
|
62
|
+
context,
|
|
63
|
+
dirname
|
|
64
|
+
});
|
|
65
|
+
result.name = name;
|
|
66
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
67
|
+
return result;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
plugin.$$name = name;
|
|
71
|
+
return plugin;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
Object.defineProperty(exports, 'createBabelPlugin', {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return createBabelPlugin;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { i as BabelTransformPluginOptions, r as BabelTransformPluginFilter, s as ResolvedBabelTransformPluginOptions, t as BabelTransformPlugin, u as Context } from "./babel-DY_imD3U.mjs";
|
|
2
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
3
|
+
import { UnpluginOptions } from "unplugin";
|
|
4
|
+
import { ArrayValues } from "@stryke/types/array";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/filters.d.ts
|
|
7
|
+
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
10
|
+
*
|
|
11
|
+
* @param plugins - The list of existing Babel plugins.
|
|
12
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
13
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
14
|
+
*/
|
|
15
|
+
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Filters a Babel plugin by its runtime ID.
|
|
18
|
+
*
|
|
19
|
+
* @param context - The context in which the filter is applied.
|
|
20
|
+
* @param fileId - The file ID to filter by.
|
|
21
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
22
|
+
*/
|
|
23
|
+
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
24
|
+
/**
|
|
25
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
26
|
+
*
|
|
27
|
+
* @param context - The context in which the plugin is being added.
|
|
28
|
+
* @param plugins - The Babel plugins to add the filter to.
|
|
29
|
+
* @param filter - The filter function to apply to the plugins.
|
|
30
|
+
* @param name - The name of the plugin to add the filter to.
|
|
31
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
32
|
+
*/
|
|
33
|
+
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
34
|
+
/**
|
|
35
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
36
|
+
*
|
|
37
|
+
* @param context - The context in which the plugin is being added.
|
|
38
|
+
* @param plugin - The Babel plugin to add the filter to.
|
|
39
|
+
* @param filter - The filter function to apply to the plugin.
|
|
40
|
+
* @returns The updated Babel plugin with the filter applied.
|
|
41
|
+
*/
|
|
42
|
+
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
2
|
+
import { isObject } from "@stryke/type-checks/is-object";
|
|
3
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/filters.ts
|
|
6
|
+
function getPluginName(plugin) {
|
|
7
|
+
return isSetString(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
11
|
+
*
|
|
12
|
+
* @param plugins - The list of existing Babel plugins.
|
|
13
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
14
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
15
|
+
*/
|
|
16
|
+
function isDuplicatePlugin(plugins, plugin) {
|
|
17
|
+
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Filters a Babel plugin by its runtime ID.
|
|
21
|
+
*
|
|
22
|
+
* @param context - The context in which the filter is applied.
|
|
23
|
+
* @param fileId - The file ID to filter by.
|
|
24
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
25
|
+
*/
|
|
26
|
+
function filterPluginByFileId(context, fileId) {
|
|
27
|
+
return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The context in which the plugin is being added.
|
|
33
|
+
* @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.
|
|
34
|
+
* @param filter - The filter function to apply to the plugins.
|
|
35
|
+
* @param name - The name of the plugin to add the filter to.
|
|
36
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
37
|
+
*/
|
|
38
|
+
function addPluginFilter(context, pluginOrPlugins, filter, name) {
|
|
39
|
+
if (!Array.isArray(pluginOrPlugins) || !pluginOrPlugins.some((plugin) => Array.isArray(plugin)) && pluginOrPlugins.length < 4 && pluginOrPlugins.length > 0 && (isSetString(pluginOrPlugins[0]) || isFunction(pluginOrPlugins[0]) || pluginOrPlugins.length > 1 && isObject(pluginOrPlugins[1]) || pluginOrPlugins.length > 2 && isObject(pluginOrPlugins[2]))) return Array.isArray(pluginOrPlugins) ? [
|
|
40
|
+
pluginOrPlugins[0],
|
|
41
|
+
pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},
|
|
42
|
+
{ filter: (code, id) => filter(code, id) && (pluginOrPlugins.length < 2 || !isFunction(pluginOrPlugins[2]) || pluginOrPlugins[2]?.(code, id)) }
|
|
43
|
+
] : [
|
|
44
|
+
pluginOrPlugins,
|
|
45
|
+
{},
|
|
46
|
+
{ filter }
|
|
47
|
+
];
|
|
48
|
+
if (!name) throw new Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");
|
|
49
|
+
const foundIndex = pluginOrPlugins.findIndex((plugin) => getPluginName(plugin)?.toLowerCase() === name.toLowerCase());
|
|
50
|
+
if (foundIndex > -1) pluginOrPlugins[foundIndex] = addPluginFilter(context, pluginOrPlugins[foundIndex], filter, name);
|
|
51
|
+
return pluginOrPlugins;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { i as BabelTransformPluginOptions, r as BabelTransformPluginFilter, s as ResolvedBabelTransformPluginOptions, t as BabelTransformPlugin, u as Context } from "./babel-B9i2IAT_.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/filters.d.ts
|
|
4
|
+
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
7
|
+
*
|
|
8
|
+
* @param plugins - The list of existing Babel plugins.
|
|
9
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
10
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
11
|
+
*/
|
|
12
|
+
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Filters a Babel plugin by its runtime ID.
|
|
15
|
+
*
|
|
16
|
+
* @param context - The context in which the filter is applied.
|
|
17
|
+
* @param fileId - The file ID to filter by.
|
|
18
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
19
|
+
*/
|
|
20
|
+
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
21
|
+
/**
|
|
22
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
23
|
+
*
|
|
24
|
+
* @param context - The context in which the plugin is being added.
|
|
25
|
+
* @param plugins - The Babel plugins to add the filter to.
|
|
26
|
+
* @param filter - The filter function to apply to the plugins.
|
|
27
|
+
* @param name - The name of the plugin to add the filter to.
|
|
28
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
29
|
+
*/
|
|
30
|
+
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
31
|
+
/**
|
|
32
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
33
|
+
*
|
|
34
|
+
* @param context - The context in which the plugin is being added.
|
|
35
|
+
* @param plugin - The Babel plugin to add the filter to.
|
|
36
|
+
* @param filter - The filter function to apply to the plugin.
|
|
37
|
+
* @returns The updated Babel plugin with the filter applied.
|
|
38
|
+
*/
|
|
39
|
+
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
3
|
+
let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
4
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/filters.ts
|
|
7
|
+
function getPluginName(plugin) {
|
|
8
|
+
return (0, __stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
12
|
+
*
|
|
13
|
+
* @param plugins - The list of existing Babel plugins.
|
|
14
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
15
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
function isDuplicatePlugin(plugins, plugin) {
|
|
18
|
+
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Filters a Babel plugin by its runtime ID.
|
|
22
|
+
*
|
|
23
|
+
* @param context - The context in which the filter is applied.
|
|
24
|
+
* @param fileId - The file ID to filter by.
|
|
25
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
26
|
+
*/
|
|
27
|
+
function filterPluginByFileId(context, fileId) {
|
|
28
|
+
return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
32
|
+
*
|
|
33
|
+
* @param context - The context in which the plugin is being added.
|
|
34
|
+
* @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.
|
|
35
|
+
* @param filter - The filter function to apply to the plugins.
|
|
36
|
+
* @param name - The name of the plugin to add the filter to.
|
|
37
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
38
|
+
*/
|
|
39
|
+
function addPluginFilter(context, pluginOrPlugins, filter, name) {
|
|
40
|
+
if (!Array.isArray(pluginOrPlugins) || !pluginOrPlugins.some((plugin) => Array.isArray(plugin)) && pluginOrPlugins.length < 4 && pluginOrPlugins.length > 0 && ((0, __stryke_type_checks_is_set_string.isSetString)(pluginOrPlugins[0]) || (0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[0]) || pluginOrPlugins.length > 1 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[1]) || pluginOrPlugins.length > 2 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[2]))) return Array.isArray(pluginOrPlugins) ? [
|
|
41
|
+
pluginOrPlugins[0],
|
|
42
|
+
pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},
|
|
43
|
+
{ filter: (code, id) => filter(code, id) && (pluginOrPlugins.length < 2 || !(0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[2]) || pluginOrPlugins[2]?.(code, id)) }
|
|
44
|
+
] : [
|
|
45
|
+
pluginOrPlugins,
|
|
46
|
+
{},
|
|
47
|
+
{ filter }
|
|
48
|
+
];
|
|
49
|
+
if (!name) throw new Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");
|
|
50
|
+
const foundIndex = pluginOrPlugins.findIndex((plugin) => getPluginName(plugin)?.toLowerCase() === name.toLowerCase());
|
|
51
|
+
if (foundIndex > -1) pluginOrPlugins[foundIndex] = addPluginFilter(context, pluginOrPlugins[foundIndex], filter, name);
|
|
52
|
+
return pluginOrPlugins;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
Object.defineProperty(exports, 'addPluginFilter', {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () {
|
|
59
|
+
return addPluginFilter;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, 'filterPluginByFileId', {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () {
|
|
65
|
+
return filterPluginByFileId;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, 'getPluginName', {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () {
|
|
71
|
+
return getPluginName;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, 'isDuplicatePlugin', {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () {
|
|
77
|
+
return isDuplicatePlugin;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
let __babel_generator = require("@babel/generator");
|
|
3
|
-
__babel_generator = require_rolldown_runtime.__toESM(__babel_generator);
|
|
4
|
-
let __babel_parser = require("@babel/parser");
|
|
1
|
+
const require_ast_utils = require('../ast-utils-BcmWaIan.cjs');
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Parse the given code into an AST.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The code to parse.
|
|
11
|
-
* @param opts - The options for parsing.
|
|
12
|
-
* @returns The parsed AST.
|
|
13
|
-
*/
|
|
14
|
-
function parseAst(code, opts = {}) {
|
|
15
|
-
return (0, __babel_parser.parse)(code, {
|
|
16
|
-
plugins: ["typescript"],
|
|
17
|
-
sourceType: "module",
|
|
18
|
-
allowImportExportEverywhere: true,
|
|
19
|
-
allowAwaitOutsideFunction: true,
|
|
20
|
-
...opts
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
let generate = __babel_generator.default;
|
|
24
|
-
if ("default" in generate) generate = generate.default;
|
|
25
|
-
function generateFromAst(ast, opts) {
|
|
26
|
-
return generate(ast, opts ? {
|
|
27
|
-
importAttributesKeyword: "with",
|
|
28
|
-
sourceMaps: true,
|
|
29
|
-
...opts
|
|
30
|
-
} : void 0);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
exports.generateFromAst = generateFromAst;
|
|
35
|
-
exports.parseAst = parseAst;
|
|
3
|
+
exports.generateFromAst = require_ast_utils.generateFromAst;
|
|
4
|
+
exports.parseAst = require_ast_utils.parseAst;
|
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/ast-utils.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Parse the given code into an AST.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The code to parse.
|
|
11
|
-
* @param opts - The options for parsing.
|
|
12
|
-
* @returns The parsed AST.
|
|
13
|
-
*/
|
|
14
|
-
declare function parseAst(code: string, opts?: ParserOptions): ParseResult<t.File>;
|
|
15
|
-
type GenerateFromAstOptions = GeneratorOptions & Required<Pick<GeneratorOptions, "sourceFileName" | "filename">>;
|
|
16
|
-
declare function generateFromAst(ast: t.Node, opts?: GenerateFromAstOptions): GeneratorResult$1;
|
|
17
|
-
declare type __ΩGenerateFromAstOptions = any[];
|
|
18
|
-
//#endregion
|
|
19
|
-
export { GenerateFromAstOptions, type GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
|
|
1
|
+
import { a as parseAst, i as generateFromAst, n as GeneratorResult, r as __ΩGenerateFromAstOptions, t as GenerateFromAstOptions } from "../ast-utils-DeuXcuqs.cjs";
|
|
2
|
+
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
|
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/ast-utils.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Parse the given code into an AST.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The code to parse.
|
|
11
|
-
* @param opts - The options for parsing.
|
|
12
|
-
* @returns The parsed AST.
|
|
13
|
-
*/
|
|
14
|
-
declare function parseAst(code: string, opts?: ParserOptions): ParseResult<t.File>;
|
|
15
|
-
type GenerateFromAstOptions = GeneratorOptions & Required<Pick<GeneratorOptions, "sourceFileName" | "filename">>;
|
|
16
|
-
declare function generateFromAst(ast: t.Node, opts?: GenerateFromAstOptions): GeneratorResult$1;
|
|
17
|
-
declare type __ΩGenerateFromAstOptions = any[];
|
|
18
|
-
//#endregion
|
|
19
|
-
export { GenerateFromAstOptions, type GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
|
|
1
|
+
import { a as parseAst, i as generateFromAst, n as GeneratorResult, r as __ΩGenerateFromAstOptions, t as GenerateFromAstOptions } from "../ast-utils-Bs6DBkKg.mjs";
|
|
2
|
+
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { parse } from "@babel/parser";
|
|
1
|
+
import { n as parseAst, t as generateFromAst } from "../ast-utils-DU1foCxH.mjs";
|
|
3
2
|
|
|
4
|
-
//#region src/helpers/ast-utils.ts
|
|
5
|
-
/**
|
|
6
|
-
* Parse the given code into an AST.
|
|
7
|
-
*
|
|
8
|
-
* @param code - The code to parse.
|
|
9
|
-
* @param opts - The options for parsing.
|
|
10
|
-
* @returns The parsed AST.
|
|
11
|
-
*/
|
|
12
|
-
function parseAst(code, opts = {}) {
|
|
13
|
-
return parse(code, {
|
|
14
|
-
plugins: ["typescript"],
|
|
15
|
-
sourceType: "module",
|
|
16
|
-
allowImportExportEverywhere: true,
|
|
17
|
-
allowAwaitOutsideFunction: true,
|
|
18
|
-
...opts
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
let generate = _generate;
|
|
22
|
-
if ("default" in generate) generate = generate.default;
|
|
23
|
-
function generateFromAst(ast, opts) {
|
|
24
|
-
return generate(ast, opts ? {
|
|
25
|
-
importAttributesKeyword: "with",
|
|
26
|
-
sourceMaps: true,
|
|
27
|
-
...opts
|
|
28
|
-
} : void 0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
3
|
export { generateFromAst, parseAst };
|
|
@@ -1,41 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_logger = require('../powerlines/src/lib/logger.cjs');
|
|
3
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
-
let chalk = require("chalk");
|
|
5
|
-
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
6
|
-
let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
1
|
+
const require_create_plugin = require('../create-plugin-Cs1zZrvI.cjs');
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Create a Babel plugin using the provided builder function.
|
|
11
|
-
*
|
|
12
|
-
* @param name - The name of the plugin.
|
|
13
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
14
|
-
* @returns A Babel plugin declaration.
|
|
15
|
-
*/
|
|
16
|
-
function createBabelPlugin(name, builder) {
|
|
17
|
-
const plugin = (context) => {
|
|
18
|
-
return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
|
|
19
|
-
api.cache.using(() => context.meta.checksum);
|
|
20
|
-
api.assertVersion("^7.0.0-0");
|
|
21
|
-
const log = require_logger.extendLog(context.log, name);
|
|
22
|
-
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
23
|
-
const result = builder({
|
|
24
|
-
log,
|
|
25
|
-
name,
|
|
26
|
-
api,
|
|
27
|
-
options,
|
|
28
|
-
context,
|
|
29
|
-
dirname
|
|
30
|
-
});
|
|
31
|
-
result.name = name;
|
|
32
|
-
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
33
|
-
return result;
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
plugin.$$name = name;
|
|
37
|
-
return plugin;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
exports.createBabelPlugin = createBabelPlugin;
|
|
3
|
+
exports.createBabelPlugin = require_create_plugin.createBabelPlugin;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/create-plugin.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create a Babel plugin using the provided builder function.
|
|
8
|
-
*
|
|
9
|
-
* @param name - The name of the plugin.
|
|
10
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
11
|
-
* @returns A Babel plugin declaration.
|
|
12
|
-
*/
|
|
13
|
-
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
14
|
-
//#endregion
|
|
1
|
+
import "../babel-B9i2IAT_.cjs";
|
|
2
|
+
import { t as createBabelPlugin } from "../create-plugin-CQA6zFdt.cjs";
|
|
15
3
|
export { createBabelPlugin };
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/create-plugin.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create a Babel plugin using the provided builder function.
|
|
8
|
-
*
|
|
9
|
-
* @param name - The name of the plugin.
|
|
10
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
11
|
-
* @returns A Babel plugin declaration.
|
|
12
|
-
*/
|
|
13
|
-
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
14
|
-
//#endregion
|
|
1
|
+
import "../babel-DY_imD3U.mjs";
|
|
2
|
+
import { t as createBabelPlugin } from "../create-plugin-CNzMrex8.mjs";
|
|
15
3
|
export { createBabelPlugin };
|
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { declare } from "@babel/helper-plugin-utils";
|
|
1
|
+
import { t as createBabelPlugin } from "../create-plugin-BPSvsem_.mjs";
|
|
5
2
|
|
|
6
|
-
//#region src/helpers/create-plugin.ts
|
|
7
|
-
/**
|
|
8
|
-
* Create a Babel plugin using the provided builder function.
|
|
9
|
-
*
|
|
10
|
-
* @param name - The name of the plugin.
|
|
11
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
12
|
-
* @returns A Babel plugin declaration.
|
|
13
|
-
*/
|
|
14
|
-
function createBabelPlugin(name, builder) {
|
|
15
|
-
const plugin = (context) => {
|
|
16
|
-
return declare((api, options, dirname) => {
|
|
17
|
-
api.cache.using(() => context.meta.checksum);
|
|
18
|
-
api.assertVersion("^7.0.0-0");
|
|
19
|
-
const log = extendLog(context.log, name);
|
|
20
|
-
log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
21
|
-
const result = builder({
|
|
22
|
-
log,
|
|
23
|
-
name,
|
|
24
|
-
api,
|
|
25
|
-
options,
|
|
26
|
-
context,
|
|
27
|
-
dirname
|
|
28
|
-
});
|
|
29
|
-
result.name = name;
|
|
30
|
-
log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
31
|
-
return result;
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
plugin.$$name = name;
|
|
35
|
-
return plugin;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
3
|
export { createBabelPlugin };
|