@powerlines/plugin-babel 0.12.67 → 0.12.69
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/{chunk-Bmb41Sf3.cjs → _virtual/rolldown_runtime.cjs} +1 -1
- package/dist/helpers/ast-utils.cjs +1 -1
- package/dist/helpers/ast-utils.d.cts +19 -2
- package/dist/helpers/ast-utils.d.mts +19 -2
- package/dist/helpers/ast-utils.mjs +1 -1
- package/dist/helpers/create-plugin.cjs +1 -1
- package/dist/helpers/create-plugin.d.cts +14 -2
- package/dist/helpers/create-plugin.d.mts +14 -2
- package/dist/helpers/create-plugin.mjs +1 -1
- package/dist/helpers/filters.cjs +1 -1
- package/dist/helpers/filters.d.cts +41 -2
- package/dist/helpers/filters.d.mts +42 -2
- package/dist/helpers/filters.mjs +1 -1
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.d.cts +5 -7
- package/dist/helpers/index.d.mts +5 -7
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/module-helpers.cjs +1 -1
- package/dist/helpers/module-helpers.d.cts +48 -2
- package/dist/helpers/module-helpers.d.mts +48 -2
- package/dist/helpers/module-helpers.mjs +1 -1
- package/dist/helpers/options.cjs +1 -1
- package/dist/helpers/options.d.cts +17 -2
- package/dist/helpers/options.d.mts +17 -2
- package/dist/helpers/options.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -9
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +1 -1
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +5 -0
- package/dist/powerlines/src/lib/logger.cjs +1 -0
- package/dist/powerlines/src/lib/logger.mjs +1 -0
- package/dist/powerlines/src/types/api.d.mts +5 -0
- package/dist/powerlines/src/types/babel.d.cts +50 -0
- package/dist/powerlines/src/types/babel.d.mts +50 -0
- package/dist/powerlines/src/types/build.d.cts +139 -0
- package/dist/powerlines/src/types/build.d.mts +139 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/config.d.cts +356 -0
- package/dist/powerlines/src/types/config.d.mts +356 -0
- package/dist/powerlines/src/types/context.d.cts +347 -0
- package/dist/powerlines/src/types/context.d.mts +349 -0
- package/dist/powerlines/src/types/fs.d.cts +458 -0
- package/dist/powerlines/src/types/fs.d.mts +458 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/index.d.mts +12 -0
- package/dist/powerlines/src/types/plugin.d.cts +232 -0
- package/dist/powerlines/src/types/plugin.d.mts +232 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +82 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/powerlines/src/types/unplugin.d.mts +6 -0
- package/dist/types/index.cjs +0 -1
- package/dist/types/index.d.cts +1 -3
- package/dist/types/index.d.mts +1 -3
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +18 -2
- package/dist/types/plugin.d.mts +18 -2
- package/dist/types/plugin.mjs +1 -1
- package/package.json +10 -10
- package/dist/ast-utils-BXgehtOj.cjs +0 -1
- package/dist/ast-utils-Bs6DBkKg.d.mts +0 -19
- package/dist/ast-utils-DeuXcuqs.d.cts +0 -19
- package/dist/ast-utils-QwV5Hp9M.mjs +0 -1
- package/dist/babel-ChnxDnEW.d.cts +0 -1692
- package/dist/babel-DTaio8BX.d.mts +0 -1692
- package/dist/create-plugin-BX_bUhNU.cjs +0 -1
- package/dist/create-plugin-CT3AmMST.d.cts +0 -14
- package/dist/create-plugin-CcyQJscB.d.mts +0 -14
- package/dist/create-plugin-pWE4rRW3.mjs +0 -1
- package/dist/filters-DJgM_YqO.cjs +0 -1
- package/dist/filters-DWUVYxNP.d.cts +0 -41
- package/dist/filters-Dy71Hudo.d.mts +0 -44
- package/dist/filters-H7GHqM8L.mjs +0 -1
- package/dist/helpers-Bx2yBrpn.cjs +0 -0
- package/dist/helpers-C23KLU23.mjs +0 -1
- package/dist/index-ClXLQ1fw.d.mts +0 -1
- package/dist/index-DeEmP3Jc.d.cts +0 -1
- package/dist/index-QbUkWSLh.d.mts +0 -1
- package/dist/index-zO0Ly4bS.d.cts +0 -1
- package/dist/module-helpers-BXxcpiSf.d.cts +0 -49
- package/dist/module-helpers-CBJeXQA-.cjs +0 -1
- package/dist/module-helpers-CFI-GsFM.mjs +0 -1
- package/dist/module-helpers-ptD32AP3.d.mts +0 -49
- package/dist/options-Bxa6CVME.d.cts +0 -17
- package/dist/options-WrgZrzO5.mjs +0 -1
- package/dist/options-d1d8EwPZ.cjs +0 -1
- package/dist/options-kquKKsDE.d.mts +0 -17
- package/dist/plugin-BSBH78mm.cjs +0 -0
- package/dist/plugin-Ckany8iM.d.cts +0 -17
- package/dist/plugin-CpXo1Y2H.d.mts +0 -17
- package/dist/plugin-CpyJWCZI.mjs +0 -1
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-cM7ObqRe.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`);let t=require(`@babel/generator`);t=e.__toESM(t);let n=require(`@babel/parser`);function r(e,t={}){return(0,n.parse)(e,{plugins:[`typescript`],sourceType:`module`,allowImportExportEverywhere:!0,allowAwaitOutsideFunction:!0,...t})}let i=t.default;`default`in i&&(i=i.default);function a(e,t){return i(e,t?{importAttributesKeyword:`with`,sourceMaps:!0,...t}:void 0)}exports.generateFromAst=a,exports.parseAst=r;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { GeneratorOptions, GeneratorResult, GeneratorResult as GeneratorResult$1 } from "@babel/generator";
|
|
2
|
+
import { ParseResult, ParserOptions } from "@babel/parser";
|
|
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,2 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { GeneratorOptions, GeneratorResult, GeneratorResult as GeneratorResult$1 } from "@babel/generator";
|
|
2
|
+
import { ParseResult, ParserOptions } from "@babel/parser";
|
|
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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import e from"@babel/generator";import{parse as t}from"@babel/parser";function n(e,n={}){return t(e,{plugins:[`typescript`],sourceType:`module`,allowImportExportEverywhere:!0,allowAwaitOutsideFunction:!0,...n})}let r=e;`default`in r&&(r=r.default);function i(e,t){return r(e,t?{importAttributesKeyword:`with`,sourceMaps:!0,...t}:void 0)}export{i as generateFromAst,n as parseAst};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../powerlines/src/lib/logger.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`chalk`);r=e.__toESM(r);let i=require(`@babel/helper-plugin-utils`);function a(e,a){let o=o=>(0,i.declare)((i,s,c)=>{i.cache.using(()=>o.meta.checksum),i.assertVersion(`^7.0.0-0`);let l=t.extendLog(o.log,e);l(n.LogLevelLabel.TRACE,`Initializing the ${r.default.bold.cyanBright(e)} Babel plugin`);let u=a({log:l,name:e,api:i,options:s,context:o,dirname:c});return u.name=e,l(n.LogLevelLabel.TRACE,`Completed initialization of the ${r.default.bold.cyanBright(e)} Babel plugin`),u});return o.$$name=e,o}exports.createBabelPlugin=a;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from "../powerlines/src/types/context.cjs";
|
|
2
|
+
import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "../powerlines/src/types/babel.cjs";
|
|
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
|
|
3
15
|
export { createBabelPlugin };
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from "../powerlines/src/types/context.mjs";
|
|
2
|
+
import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "../powerlines/src/types/babel.mjs";
|
|
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
|
|
3
15
|
export { createBabelPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{extendLog as e}from"../powerlines/src/lib/logger.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import n from"chalk";import{declare as r}from"@babel/helper-plugin-utils";function i(i,a){let o=o=>r((r,s,c)=>{r.cache.using(()=>o.meta.checksum),r.assertVersion(`^7.0.0-0`);let l=e(o.log,i);l(t.TRACE,`Initializing the ${n.bold.cyanBright(i)} Babel plugin`);let u=a({log:l,name:i,api:r,options:s,context:o,dirname:c});return u.name=i,l(t.TRACE,`Completed initialization of the ${n.bold.cyanBright(i)} Babel plugin`),u});return o.$$name=i,o}export{i as createBabelPlugin};
|
package/dist/helpers/filters.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/type-checks/is-function`),n=require(`@stryke/type-checks/is-object`),r=require(`@stryke/type-checks/is-set-string`);function i(e){return(0,r.isSetString)(e)?e:Array.isArray(e)&&e.length>0?i(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function a(e,t){return!!(i(t)&&e.some(e=>Array.isArray(e)&&i(e[0])===i(t)))}function o(e,t){return(n,r)=>t!==r&&e.fs.ids[t]!==r&&t!==e.fs.ids[r]&&e.fs.ids[t]!==e.fs.ids[r]}function s(e,a,o,c){if(!Array.isArray(a)||!a.some(e=>Array.isArray(e))&&a.length<4&&a.length>0&&((0,r.isSetString)(a[0])||(0,t.isFunction)(a[0])||a.length>1&&(0,n.isObject)(a[1])||a.length>2&&(0,n.isObject)(a[2])))return Array.isArray(a)?[a[0],a.length>1?a[1]:{},{filter:(e,n)=>o(e,n)&&(a.length<2||!(0,t.isFunction)(a[2])||a[2]?.(e,n))}]:[a,{},{filter:o}];if(!c)throw Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");let l=a.findIndex(e=>i(e)?.toLowerCase()===c.toLowerCase());return l>-1&&(a[l]=s(e,a[l],o,c)),a}exports.addPluginFilter=s,exports.filterPluginByFileId=o,exports.getPluginName=i,exports.isDuplicatePlugin=a;
|
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from "../powerlines/src/types/context.cjs";
|
|
2
|
+
import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../powerlines/src/types/babel.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/filters.d.ts
|
|
5
|
+
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
8
|
+
*
|
|
9
|
+
* @param plugins - The list of existing Babel plugins.
|
|
10
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
11
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Filters a Babel plugin by its runtime ID.
|
|
16
|
+
*
|
|
17
|
+
* @param context - The context in which the filter is applied.
|
|
18
|
+
* @param fileId - The file ID to filter by.
|
|
19
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
20
|
+
*/
|
|
21
|
+
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
22
|
+
/**
|
|
23
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
24
|
+
*
|
|
25
|
+
* @param context - The context in which the plugin is being added.
|
|
26
|
+
* @param plugins - The Babel plugins to add the filter to.
|
|
27
|
+
* @param filter - The filter function to apply to the plugins.
|
|
28
|
+
* @param name - The name of the plugin to add the filter to.
|
|
29
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
30
|
+
*/
|
|
31
|
+
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
32
|
+
/**
|
|
33
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
34
|
+
*
|
|
35
|
+
* @param context - The context in which the plugin is being added.
|
|
36
|
+
* @param plugin - The Babel plugin to add the filter to.
|
|
37
|
+
* @param filter - The filter function to apply to the plugin.
|
|
38
|
+
* @returns The updated Babel plugin with the filter applied.
|
|
39
|
+
*/
|
|
40
|
+
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
41
|
+
//#endregion
|
|
3
42
|
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from "../powerlines/src/types/context.mjs";
|
|
2
|
+
import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../powerlines/src/types/babel.mjs";
|
|
3
|
+
import "../powerlines/src/types/index.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/filters.d.ts
|
|
6
|
+
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
9
|
+
*
|
|
10
|
+
* @param plugins - The list of existing Babel plugins.
|
|
11
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
12
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Filters a Babel plugin by its runtime ID.
|
|
17
|
+
*
|
|
18
|
+
* @param context - The context in which the filter is applied.
|
|
19
|
+
* @param fileId - The file ID to filter by.
|
|
20
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
21
|
+
*/
|
|
22
|
+
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
23
|
+
/**
|
|
24
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
25
|
+
*
|
|
26
|
+
* @param context - The context in which the plugin is being added.
|
|
27
|
+
* @param plugins - The Babel plugins to add the filter to.
|
|
28
|
+
* @param filter - The filter function to apply to the plugins.
|
|
29
|
+
* @param name - The name of the plugin to add the filter to.
|
|
30
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
31
|
+
*/
|
|
32
|
+
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
33
|
+
/**
|
|
34
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
35
|
+
*
|
|
36
|
+
* @param context - The context in which the plugin is being added.
|
|
37
|
+
* @param plugin - The Babel plugin to add the filter to.
|
|
38
|
+
* @param filter - The filter function to apply to the plugin.
|
|
39
|
+
* @returns The updated Babel plugin with the filter applied.
|
|
40
|
+
*/
|
|
41
|
+
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
42
|
+
//#endregion
|
|
3
43
|
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
package/dist/helpers/filters.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isFunction as e}from"@stryke/type-checks/is-function";import{isObject as t}from"@stryke/type-checks/is-object";import{isSetString as n}from"@stryke/type-checks/is-set-string";function r(e){return n(e)?e:Array.isArray(e)&&e.length>0?r(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function i(e,t){return!!(r(t)&&e.some(e=>Array.isArray(e)&&r(e[0])===r(t)))}function a(e,t){return(n,r)=>t!==r&&e.fs.ids[t]!==r&&t!==e.fs.ids[r]&&e.fs.ids[t]!==e.fs.ids[r]}function o(i,a,s,c){if(!Array.isArray(a)||!a.some(e=>Array.isArray(e))&&a.length<4&&a.length>0&&(n(a[0])||e(a[0])||a.length>1&&t(a[1])||a.length>2&&t(a[2])))return Array.isArray(a)?[a[0],a.length>1?a[1]:{},{filter:(t,n)=>s(t,n)&&(a.length<2||!e(a[2])||a[2]?.(t,n))}]:[a,{},{filter:s}];if(!c)throw Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");let l=a.findIndex(e=>r(e)?.toLowerCase()===c.toLowerCase());return l>-1&&(a[l]=o(i,a[l],s,c)),a}export{o as addPluginFilter,a as filterPluginByFileId,r as getPluginName,i as isDuplicatePlugin};
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(
|
|
1
|
+
const e=require(`./filters.cjs`),t=require(`./options.cjs`),n=require(`./ast-utils.cjs`),r=require(`./create-plugin.cjs`),i=require(`./module-helpers.cjs`);exports.addImport=i.addImport,exports.addImportsToProgram=i.addImportsToProgram,exports.addPluginFilter=e.addPluginFilter,exports.createBabelPlugin=r.createBabelPlugin,exports.filterPluginByFileId=e.filterPluginByFileId,exports.findExport=i.findExport,exports.generateFromAst=n.generateFromAst,exports.getImport=i.getImport,exports.getPluginName=e.getPluginName,exports.isDuplicatePlugin=e.isDuplicatePlugin,exports.isImportCall=i.isImportCall,exports.listExports=i.listExports,exports.listImports=i.listImports,exports.parseAst=n.parseAst,exports.resolveBabelPlugin=t.resolveBabelPlugin,exports.resolvePluginFunction=t.resolvePluginFunction;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-Bxa6CVME.cjs";
|
|
7
|
-
import "../index-DeEmP3Jc.cjs";
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./ast-utils.cjs";
|
|
2
|
+
import { createBabelPlugin } from "./create-plugin.cjs";
|
|
3
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./filters.cjs";
|
|
4
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./module-helpers.cjs";
|
|
5
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./options.cjs";
|
|
8
6
|
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-kquKKsDE.mjs";
|
|
7
|
-
import "../index-ClXLQ1fw.mjs";
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./ast-utils.mjs";
|
|
2
|
+
import { createBabelPlugin } from "./create-plugin.mjs";
|
|
3
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./filters.mjs";
|
|
4
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./module-helpers.mjs";
|
|
5
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./options.mjs";
|
|
8
6
|
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{addPluginFilter as e,filterPluginByFileId as t,getPluginName as n,isDuplicatePlugin as r}from"./filters.mjs";import{resolveBabelPlugin as i,resolvePluginFunction as a}from"./options.mjs";import{generateFromAst as o,parseAst as s}from"./ast-utils.mjs";import{createBabelPlugin as c}from"./create-plugin.mjs";import{addImport as l,addImportsToProgram as u,findExport as d,getImport as f,isImportCall as p,listExports as m,listImports as h}from"./module-helpers.mjs";export{l as addImport,u as addImportsToProgram,e as addPluginFilter,c as createBabelPlugin,t as filterPluginByFileId,d as findExport,o as generateFromAst,f as getImport,n as getPluginName,r as isDuplicatePlugin,p as isImportCall,m as listExports,h as listImports,s as parseAst,i as resolveBabelPlugin,a as resolvePluginFunction};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../ast-utils
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`./ast-utils.cjs`);let n=require(`@babel/types`);n=e.__toESM(n);let r=require(`@stryke/type-checks/is-string`);function i(e,t){let n=t===`default`?`ExportDefaultDeclaration`:`ExportNamedDeclaration`;for(let r of e.program.body)if(r.type===n){if(t===`default`)return r.declaration;if(r.declaration&&`declarations`in r.declaration){let e=r.declaration.declarations[0];if(e&&`name`in e.id&&e.id.name===t)return e.init}}}function a(e){return((0,r.isString)(e)?t.parseAst(e):e).program.body.flatMap(e=>e.type===`ExportDefaultDeclaration`?[`default`]:e.type===`ExportNamedDeclaration`&&e.declaration&&`declarations`in e.declaration?e.declaration.declarations.map(e=>`name`in e.id?e.id.name:``):[]).filter(Boolean)}function o(e){return e.program.body.flatMap(e=>e.type===`ImportDeclaration`?e.specifiers.map(e=>e.type===`ImportDefaultSpecifier`?`default`:e.type===`ImportSpecifier`&&`imported`in e?e.imported.type===`Identifier`?e.imported.name:e.imported.value:``):[]).filter(Boolean)}function s(e){return n.isImport(e.node.callee)}function c(e,t,r){return n.importDeclaration([n.importSpecifier(n.identifier(t),n.stringLiteral(r||t))],n.stringLiteral(e))}function l(e,t){f(e.scope.getProgramParent().path,t)}function u(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function d(e){let t=new Map;return e.traverse({ImportDeclaration(e){u(e)&&t.set(e.node.source.value,e)}}),t}function f(e,t){d(e).get(t.module)||e.unshiftContainer(`body`,n.importDeclaration([n.importSpecifier(n.identifier(t.name||t.imported),n.identifier(t.imported))],n.stringLiteral(t.module)))}exports.addImport=l,exports.addImportsToProgram=f,exports.findExport=i,exports.getImport=c,exports.isImportCall=s,exports.listExports=a,exports.listImports=o;
|
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
import "../babel
|
|
2
|
-
import {
|
|
1
|
+
import { ImportSpecifier } from "../powerlines/src/types/babel.cjs";
|
|
2
|
+
import { ParseResult } from "@babel/parser";
|
|
3
|
+
import * as t from "@babel/types";
|
|
4
|
+
import { NodePath } from "@babel/core";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/module-helpers.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Finds an export in the given Babel AST program by its key.
|
|
10
|
+
*
|
|
11
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
12
|
+
* @param key - The name of the export to find (e.g., "default" or a named export).
|
|
13
|
+
* @returns The declaration of the export if found, otherwise undefined.
|
|
14
|
+
*/
|
|
15
|
+
declare function findExport(ast: ParseResult<t.File>, key: string): any;
|
|
16
|
+
/**
|
|
17
|
+
* Lists all exports from the given Babel AST program.
|
|
18
|
+
*
|
|
19
|
+
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
20
|
+
* @returns An array of export names, including "default" for default exports.
|
|
21
|
+
*/
|
|
22
|
+
declare function listExports(codeOrAst: ParseResult<t.File> | string): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Lists all imports from the given Babel AST program.
|
|
25
|
+
*
|
|
26
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
27
|
+
* @returns An array of import names, including "default" for default imports.
|
|
28
|
+
*/
|
|
29
|
+
declare function listImports(ast: ParseResult<t.File> | t.File): string[];
|
|
30
|
+
declare function isImportCall(calleePath: NodePath<t.CallExpression | t.NewExpression>): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the import declaration for a given name and specifier.
|
|
33
|
+
*
|
|
34
|
+
* @param specifier - The specifier of the import.
|
|
35
|
+
* @param name - The name of the import.
|
|
36
|
+
* @param named - Optional named import.
|
|
37
|
+
* @returns The import declaration.
|
|
38
|
+
*/
|
|
39
|
+
declare function getImport(specifier: string, name: string, named?: string): t.ImportDeclaration;
|
|
40
|
+
/**
|
|
41
|
+
* Adds an import to the program if it doesn't already exist.
|
|
42
|
+
*
|
|
43
|
+
* @param path - The current NodePath in the AST.
|
|
44
|
+
* @param specifier - The import specifier.
|
|
45
|
+
*/
|
|
46
|
+
declare function addImport(path: NodePath<any>, specifier: ImportSpecifier): void;
|
|
47
|
+
declare function addImportsToProgram(path: NodePath<t.Program>, specifier: ImportSpecifier): void;
|
|
48
|
+
//#endregion
|
|
3
49
|
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
import "../babel
|
|
2
|
-
import {
|
|
1
|
+
import { ImportSpecifier } from "../powerlines/src/types/babel.mjs";
|
|
2
|
+
import { NodePath } from "@babel/core";
|
|
3
|
+
import { ParseResult } from "@babel/parser";
|
|
4
|
+
import * as t from "@babel/types";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/module-helpers.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Finds an export in the given Babel AST program by its key.
|
|
10
|
+
*
|
|
11
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
12
|
+
* @param key - The name of the export to find (e.g., "default" or a named export).
|
|
13
|
+
* @returns The declaration of the export if found, otherwise undefined.
|
|
14
|
+
*/
|
|
15
|
+
declare function findExport(ast: ParseResult<t.File>, key: string): any;
|
|
16
|
+
/**
|
|
17
|
+
* Lists all exports from the given Babel AST program.
|
|
18
|
+
*
|
|
19
|
+
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
20
|
+
* @returns An array of export names, including "default" for default exports.
|
|
21
|
+
*/
|
|
22
|
+
declare function listExports(codeOrAst: ParseResult<t.File> | string): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Lists all imports from the given Babel AST program.
|
|
25
|
+
*
|
|
26
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
27
|
+
* @returns An array of import names, including "default" for default imports.
|
|
28
|
+
*/
|
|
29
|
+
declare function listImports(ast: ParseResult<t.File> | t.File): string[];
|
|
30
|
+
declare function isImportCall(calleePath: NodePath<t.CallExpression | t.NewExpression>): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the import declaration for a given name and specifier.
|
|
33
|
+
*
|
|
34
|
+
* @param specifier - The specifier of the import.
|
|
35
|
+
* @param name - The name of the import.
|
|
36
|
+
* @param named - Optional named import.
|
|
37
|
+
* @returns The import declaration.
|
|
38
|
+
*/
|
|
39
|
+
declare function getImport(specifier: string, name: string, named?: string): t.ImportDeclaration;
|
|
40
|
+
/**
|
|
41
|
+
* Adds an import to the program if it doesn't already exist.
|
|
42
|
+
*
|
|
43
|
+
* @param path - The current NodePath in the AST.
|
|
44
|
+
* @param specifier - The import specifier.
|
|
45
|
+
*/
|
|
46
|
+
declare function addImport(path: NodePath<any>, specifier: ImportSpecifier): void;
|
|
47
|
+
declare function addImportsToProgram(path: NodePath<t.Program>, specifier: ImportSpecifier): void;
|
|
48
|
+
//#endregion
|
|
3
49
|
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"
|
|
1
|
+
import{parseAst as e}from"./ast-utils.mjs";import*as t from"@babel/types";import{isString as n}from"@stryke/type-checks/is-string";function r(e,t){let n=t===`default`?`ExportDefaultDeclaration`:`ExportNamedDeclaration`;for(let r of e.program.body)if(r.type===n){if(t===`default`)return r.declaration;if(r.declaration&&`declarations`in r.declaration){let e=r.declaration.declarations[0];if(e&&`name`in e.id&&e.id.name===t)return e.init}}}function i(t){return(n(t)?e(t):t).program.body.flatMap(e=>e.type===`ExportDefaultDeclaration`?[`default`]:e.type===`ExportNamedDeclaration`&&e.declaration&&`declarations`in e.declaration?e.declaration.declarations.map(e=>`name`in e.id?e.id.name:``):[]).filter(Boolean)}function a(e){return e.program.body.flatMap(e=>e.type===`ImportDeclaration`?e.specifiers.map(e=>e.type===`ImportDefaultSpecifier`?`default`:e.type===`ImportSpecifier`&&`imported`in e?e.imported.type===`Identifier`?e.imported.name:e.imported.value:``):[]).filter(Boolean)}function o(e){return t.isImport(e.node.callee)}function s(e,n,r){return t.importDeclaration([t.importSpecifier(t.identifier(n),t.stringLiteral(r||n))],t.stringLiteral(e))}function c(e,t){d(e.scope.getProgramParent().path,t)}function l(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function u(e){let t=new Map;return e.traverse({ImportDeclaration(e){l(e)&&t.set(e.node.source.value,e)}}),t}function d(e,n){u(e).get(n.module)||e.unshiftContainer(`body`,t.importDeclaration([t.importSpecifier(t.identifier(n.name||n.imported),t.identifier(n.imported))],t.stringLiteral(n.module)))}export{c as addImport,d as addImportsToProgram,r as findExport,s as getImport,o as isImportCall,i as listExports,a as listImports};
|
package/dist/helpers/options.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../filters
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`./filters.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`@stryke/type-checks/is-function`),i=require(`chalk`);i=e.__toESM(i);function a(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?(0,r.isFunction)(t[0])?t[0](e):t[0]:(0,r.isFunction)(t)?t(e):t}catch{return t[0]}}function o(e,o,s,c){if(Array.isArray(c)&&c.length>0&&c[0]){if(c.length>2&&c[2]&&(0,r.isFunction)(c[2])&&!c[2](o,s)){e.log(n.LogLevelLabel.TRACE,`Skipping filtered Babel plugin ${i.default.bold.cyanBright(t.getPluginName(c)||`unnamed`)} for ${s}`);return}return c.length>2?[a(e,c),c[1],c[2]]:[a(e,c),c[1],null]}return[a(e,c),{},null]}exports.resolveBabelPlugin=o,exports.resolvePluginFunction=a;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from "../powerlines/src/types/context.cjs";
|
|
2
|
+
import { BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../powerlines/src/types/babel.cjs";
|
|
3
|
+
import { PluginOptions, PluginTarget } from "@babel/core";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/options.d.ts
|
|
6
|
+
declare function resolvePluginFunction(context: Context, plugin: any | PluginTarget | any[] | [PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined]): BabelTransformPluginOptions;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The context for the transformation.
|
|
11
|
+
* @param code - The code to be transformed.
|
|
12
|
+
* @param id - The ID of the source file.
|
|
13
|
+
* @param plugin - The Babel plugin to resolve.
|
|
14
|
+
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
15
|
+
*/
|
|
16
|
+
declare function resolveBabelPlugin(context: Context, code: string, id: string, plugin: BabelTransformPluginOptions): ResolvedBabelTransformPluginOptions | undefined;
|
|
17
|
+
//#endregion
|
|
3
18
|
export { resolveBabelPlugin, resolvePluginFunction };
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
1
|
+
import { Context } from "../powerlines/src/types/context.mjs";
|
|
2
|
+
import { BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../powerlines/src/types/babel.mjs";
|
|
3
|
+
import { PluginOptions, PluginTarget } from "@babel/core";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/options.d.ts
|
|
6
|
+
declare function resolvePluginFunction(context: Context, plugin: any | PluginTarget | any[] | [PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined]): BabelTransformPluginOptions;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The context for the transformation.
|
|
11
|
+
* @param code - The code to be transformed.
|
|
12
|
+
* @param id - The ID of the source file.
|
|
13
|
+
* @param plugin - The Babel plugin to resolve.
|
|
14
|
+
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
15
|
+
*/
|
|
16
|
+
declare function resolveBabelPlugin(context: Context, code: string, id: string, plugin: BabelTransformPluginOptions): ResolvedBabelTransformPluginOptions | undefined;
|
|
17
|
+
//#endregion
|
|
3
18
|
export { resolveBabelPlugin, resolvePluginFunction };
|
package/dist/helpers/options.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"
|
|
1
|
+
import{getPluginName as e}from"./filters.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import{isFunction as n}from"@stryke/type-checks/is-function";import r from"chalk";function i(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?n(t[0])?t[0](e):t[0]:n(t)?t(e):t}catch{return t[0]}}function a(a,o,s,c){if(Array.isArray(c)&&c.length>0&&c[0]){if(c.length>2&&c[2]&&n(c[2])&&!c[2](o,s)){a.log(t.TRACE,`Skipping filtered Babel plugin ${r.bold.cyanBright(e(c)||`unnamed`)} for ${s}`);return}return c.length>2?[i(a,c),c[1],c[2]]:[i(a,c),c[1],null]}return[i(a,c),{},null]}export{a as resolveBabelPlugin,i as resolvePluginFunction};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./helpers/filters.cjs`),n=require(`./helpers/options.cjs`),r=require(`./helpers/ast-utils.cjs`),i=require(`./helpers/create-plugin.cjs`),a=require(`./helpers/module-helpers.cjs`);require(`./helpers/index.cjs`);let o=require(`@babel/core`),s=require(`@storm-software/config-tools/types`),c=require(`@stryke/path/file-path-fns`),l=require(`@stryke/path/is-parent-path`),u=require(`@stryke/type-checks/is-set-object`),d=require(`defu`);d=e.__toESM(d);const f=(e={})=>({name:`babel`,config(){if((0,u.isSetObject)(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=(0,d.default)(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(r,i){if((0,l.isParentPath)(i,this.powerlinesPath)||r.includes(`/* @storm-ignore */`)||r.includes(`/* @storm-disable */`))return this.log(s.LogLevelLabel.TRACE,`Skipping Babel transformation for: ${i}`),{code:r,id:i};this.log(s.LogLevelLabel.TRACE,`Babel transforming file: ${i}`);let a=this.config.transform.babel.plugins.map(e=>n.resolveBabelPlugin(this,r,i,e)).filter((e,n,r)=>e&&!t.isDuplicatePlugin(r,e)),u=this.config.transform.babel.presets.map(e=>n.resolveBabelPlugin(this,r,i,e)).filter((e,n,r)=>e&&!t.isDuplicatePlugin(r,e));if(Array.isArray(a)&&a.length===0&&Array.isArray(u)&&u.length===0)return{code:r,id:i};[`ts`,`cts`,`mts`,`tsx`].includes((0,c.findFileExtensionSafe)(i))&&!t.isDuplicatePlugin(a,`@babel/plugin-syntax-typescript`)&&!t.isDuplicatePlugin(u,`@babel/preset-typescript`)&&a.unshift([`@babel/plugin-syntax-typescript`,{isTSX:(0,c.findFileExtension)(i)===`.tsx`}]);let f=await(0,o.transformAsync)(r,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:i,plugins:a.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,d.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:u.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,d.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!f?.code)throw Error(`Powerlines - Babel plugin failed to compile ${i}`);return{code:f.code,id:i}}});var p=f;exports.addImport=a.addImport,exports.addImportsToProgram=a.addImportsToProgram,exports.addPluginFilter=t.addPluginFilter,exports.createBabelPlugin=i.createBabelPlugin,exports.default=p,exports.filterPluginByFileId=t.filterPluginByFileId,exports.findExport=a.findExport,exports.generateFromAst=r.generateFromAst,exports.getImport=a.getImport,exports.getPluginName=t.getPluginName,exports.isDuplicatePlugin=t.isDuplicatePlugin,exports.isImportCall=a.isImportCall,exports.listExports=a.listExports,exports.listImports=a.listImports,exports.parseAst=r.parseAst,exports.plugin=f,exports.resolveBabelPlugin=n.resolveBabelPlugin,exports.resolvePluginFunction=n.resolvePluginFunction;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "./
|
|
8
|
-
import { a as __ΩBabelPluginContext, c as __ΩBabelPluginUserConfig, i as BabelPluginUserConfig, n as BabelPluginOptions, o as __ΩBabelPluginOptions, r as BabelPluginResolvedConfig, s as __ΩBabelPluginResolvedConfig, t as BabelPluginContext } from "./plugin-Ckany8iM.cjs";
|
|
9
|
-
import "./index-zO0Ly4bS.cjs";
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./helpers/ast-utils.cjs";
|
|
2
|
+
import { Plugin } from "./powerlines/src/types/plugin.cjs";
|
|
3
|
+
import { createBabelPlugin } from "./helpers/create-plugin.cjs";
|
|
4
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.cjs";
|
|
5
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.cjs";
|
|
6
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.cjs";
|
|
7
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./types/plugin.cjs";
|
|
10
8
|
|
|
11
9
|
//#region src/index.d.ts
|
|
10
|
+
|
|
12
11
|
/**
|
|
13
12
|
* Babel plugin for Powerlines.
|
|
14
13
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "./index
|
|
8
|
-
import {
|
|
9
|
-
import "./index
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./helpers/ast-utils.mjs";
|
|
2
|
+
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
3
|
+
import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
4
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.mjs";
|
|
5
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.mjs";
|
|
6
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.mjs";
|
|
7
|
+
import "./helpers/index.mjs";
|
|
8
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./types/plugin.mjs";
|
|
9
|
+
import "./types/index.mjs";
|
|
10
10
|
|
|
11
11
|
//#region src/index.d.ts
|
|
12
12
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{addPluginFilter as e,filterPluginByFileId as t,getPluginName as n,isDuplicatePlugin as r}from"./helpers/filters.mjs";import{resolveBabelPlugin as i,resolvePluginFunction as a}from"./helpers/options.mjs";import{generateFromAst as o,parseAst as s}from"./helpers/ast-utils.mjs";import{createBabelPlugin as c}from"./helpers/create-plugin.mjs";import{addImport as l,addImportsToProgram as u,findExport as d,getImport as f,isImportCall as p,listExports as m,listImports as h}from"./helpers/module-helpers.mjs";import"./helpers/index.mjs";import{transformAsync as g}from"@babel/core";import{LogLevelLabel as _}from"@storm-software/config-tools/types";import{findFileExtension as v,findFileExtensionSafe as y}from"@stryke/path/file-path-fns";import{isParentPath as b}from"@stryke/path/is-parent-path";import{isSetObject as x}from"@stryke/type-checks/is-set-object";import S from"defu";const C=(e={})=>({name:`babel`,config(){if(x(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=S(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if(b(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(_.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(_.TRACE,`Babel transforming file: ${n}`);let a=this.config.transform.babel.plugins.map(e=>i(this,t,n,e)).filter((e,t,n)=>e&&!r(n,e)),o=this.config.transform.babel.presets.map(e=>i(this,t,n,e)).filter((e,t,n)=>e&&!r(n,e));if(Array.isArray(a)&&a.length===0&&Array.isArray(o)&&o.length===0)return{code:t,id:n};[`ts`,`cts`,`mts`,`tsx`].includes(y(n))&&!r(a,`@babel/plugin-syntax-typescript`)&&!r(o,`@babel/preset-typescript`)&&a.unshift([`@babel/plugin-syntax-typescript`,{isTSX:v(n)===`.tsx`}]);let s=await g(t,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:n,plugins:a.map(t=>Array.isArray(t)&&t.length>=2?[t[0],S(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:o.map(t=>Array.isArray(t)&&t.length>=2?[t[0],S(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!s?.code)throw Error(`Powerlines - Babel plugin failed to compile ${n}`);return{code:s.code,id:n}}});var w=C;export{l as addImport,u as addImportsToProgram,e as addPluginFilter,c as createBabelPlugin,w as default,t as filterPluginByFileId,d as findExport,o as generateFromAst,f as getImport,n as getPluginName,r as isDuplicatePlugin,p as isImportCall,m as listExports,h as listImports,s as parseAst,C as plugin,i as resolveBabelPlugin,a as resolvePluginFunction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`chalk`);n=e.__toESM(n),require(`@storm-software/config-tools/logger`),require(`@storm-software/config-tools/utilities/colors`),require(`@stryke/helpers/noop`);let r=require(`@stryke/string-format/title-case`);const i=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],a=(e,t)=>(a,...o)=>e(a,` ${n.default.inverse.hex(i[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%i.length]||i[0])(` ${(0,r.titleCase)(t)} `)} ${o.join(` `)} `);exports.extendLog=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LogLevelLabel as e}from"@storm-software/config-tools/types";import t from"chalk";import"@storm-software/config-tools/logger";import"@storm-software/config-tools/utilities/colors";import"@stryke/helpers/noop";import{titleCase as n}from"@stryke/string-format/title-case";const r=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],i=(e,i)=>(a,...o)=>e(a,` ${t.inverse.hex(r[i.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%r.length]||r[0])(` ${n(i)} `)} ${o.join(` `)} `);export{i as extendLog};
|