@powerlines/plugin-babel 0.12.261 → 0.12.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/{chunk-CbDLau6x.cjs → _virtual/rolldown_runtime.cjs} +1 -6
  2. package/dist/helpers/ast-utils.cjs +34 -3
  3. package/dist/helpers/ast-utils.d.cts +20 -2
  4. package/dist/helpers/ast-utils.d.cts.map +1 -0
  5. package/dist/helpers/ast-utils.d.mts +20 -2
  6. package/dist/helpers/ast-utils.d.mts.map +1 -0
  7. package/dist/helpers/ast-utils.mjs +32 -2
  8. package/dist/helpers/ast-utils.mjs.map +1 -0
  9. package/dist/helpers/create-plugin.cjs +40 -2
  10. package/dist/helpers/create-plugin.d.cts +16 -2
  11. package/dist/helpers/create-plugin.d.cts.map +1 -0
  12. package/dist/helpers/create-plugin.d.mts +16 -2
  13. package/dist/helpers/create-plugin.d.mts.map +1 -0
  14. package/dist/helpers/create-plugin.mjs +39 -2
  15. package/dist/helpers/create-plugin.mjs.map +1 -0
  16. package/dist/helpers/filters.cjs +58 -5
  17. package/dist/helpers/filters.d.cts +43 -2
  18. package/dist/helpers/filters.d.cts.map +1 -0
  19. package/dist/helpers/filters.d.mts +43 -2
  20. package/dist/helpers/filters.d.mts.map +1 -0
  21. package/dist/helpers/filters.mjs +55 -2
  22. package/dist/helpers/filters.mjs.map +1 -0
  23. package/dist/helpers/index.cjs +21 -22
  24. package/dist/helpers/index.d.cts +5 -6
  25. package/dist/helpers/index.d.mts +5 -6
  26. package/dist/helpers/index.mjs +5 -6
  27. package/dist/helpers/module-helpers.cjs +102 -9
  28. package/dist/helpers/module-helpers.d.cts +50 -2
  29. package/dist/helpers/module-helpers.d.cts.map +1 -0
  30. package/dist/helpers/module-helpers.d.mts +50 -2
  31. package/dist/helpers/module-helpers.d.mts.map +1 -0
  32. package/dist/helpers/module-helpers.mjs +95 -3
  33. package/dist/helpers/module-helpers.mjs.map +1 -0
  34. package/dist/helpers/options.cjs +48 -4
  35. package/dist/helpers/options.d.cts +19 -2
  36. package/dist/helpers/options.d.cts.map +1 -0
  37. package/dist/helpers/options.d.mts +19 -2
  38. package/dist/helpers/options.d.mts.map +1 -0
  39. package/dist/helpers/options.mjs +46 -3
  40. package/dist/helpers/options.mjs.map +1 -0
  41. package/dist/index.cjs +27 -29
  42. package/dist/index.d.cts +8 -8
  43. package/dist/index.d.mts +8 -8
  44. package/dist/index.mjs +6 -8
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/types/index.cjs +0 -2
  47. package/dist/types/index.d.cts +1 -2
  48. package/dist/types/index.d.mts +1 -2
  49. package/dist/types/index.mjs +0 -3
  50. package/dist/types/plugin.cjs +0 -1
  51. package/dist/types/plugin.d.cts +20 -2
  52. package/dist/types/plugin.d.cts.map +1 -0
  53. package/dist/types/plugin.d.mts +20 -2
  54. package/dist/types/plugin.d.mts.map +1 -0
  55. package/dist/types/plugin.mjs +0 -2
  56. package/package.json +8 -8
  57. package/dist/ast-utils-BcmWaIan.cjs +0 -45
  58. package/dist/ast-utils-Bs6DBkKg.d.mts +0 -20
  59. package/dist/ast-utils-Bs6DBkKg.d.mts.map +0 -1
  60. package/dist/ast-utils-DU1foCxH.mjs +0 -33
  61. package/dist/ast-utils-DU1foCxH.mjs.map +0 -1
  62. package/dist/ast-utils-DeuXcuqs.d.cts +0 -20
  63. package/dist/ast-utils-DeuXcuqs.d.cts.map +0 -1
  64. package/dist/create-plugin-BSNFeead.mjs +0 -40
  65. package/dist/create-plugin-BSNFeead.mjs.map +0 -1
  66. package/dist/create-plugin-Bf7dRYZB.cjs +0 -46
  67. package/dist/create-plugin-DU9FBfyz.d.cts +0 -16
  68. package/dist/create-plugin-DU9FBfyz.d.cts.map +0 -1
  69. package/dist/create-plugin-DgfkdI-s.d.mts +0 -16
  70. package/dist/create-plugin-DgfkdI-s.d.mts.map +0 -1
  71. package/dist/filters-CU0L1nIa.cjs +0 -79
  72. package/dist/filters-CpjboNi8.mjs +0 -56
  73. package/dist/filters-CpjboNi8.mjs.map +0 -1
  74. package/dist/filters-D75MrPzl.d.mts +0 -43
  75. package/dist/filters-D75MrPzl.d.mts.map +0 -1
  76. package/dist/filters-DKyk7Jxg.d.cts +0 -43
  77. package/dist/filters-DKyk7Jxg.d.cts.map +0 -1
  78. package/dist/helpers-BnW_4z5h.mjs +0 -1
  79. package/dist/helpers-Bx2yBrpn.cjs +0 -0
  80. package/dist/index-BXxhKmeA.d.mts +0 -1
  81. package/dist/index-CqdNToYT.d.cts +0 -1
  82. package/dist/index-DJOHDG5e.d.mts +0 -1
  83. package/dist/index-sQecLSpR.d.cts +0 -1
  84. package/dist/module-helpers-07-NCXys.d.cts +0 -50
  85. package/dist/module-helpers-07-NCXys.d.cts.map +0 -1
  86. package/dist/module-helpers-B1gnVB7F.d.mts +0 -50
  87. package/dist/module-helpers-B1gnVB7F.d.mts.map +0 -1
  88. package/dist/module-helpers-Ckq8sc4l.mjs +0 -96
  89. package/dist/module-helpers-Ckq8sc4l.mjs.map +0 -1
  90. package/dist/module-helpers-Non-jHMu.cjs +0 -138
  91. package/dist/options-2JL6WIXT.cjs +0 -59
  92. package/dist/options-CpZXObFr.d.mts +0 -19
  93. package/dist/options-CpZXObFr.d.mts.map +0 -1
  94. package/dist/options-DZkAyLff.d.cts +0 -19
  95. package/dist/options-DZkAyLff.d.cts.map +0 -1
  96. package/dist/options-DwynxlP6.mjs +0 -47
  97. package/dist/options-DwynxlP6.mjs.map +0 -1
  98. package/dist/plugin-BL8TLixo.mjs +0 -1
  99. package/dist/plugin-BSBH78mm.cjs +0 -0
  100. package/dist/plugin-C-FvkCBm.d.cts +0 -20
  101. package/dist/plugin-C-FvkCBm.d.cts.map +0 -1
  102. package/dist/plugin-Sxw1QP5p.d.mts +0 -20
  103. package/dist/plugin-Sxw1QP5p.d.mts.map +0 -1
  104. package/dist/types-CKPddlfS.cjs +0 -0
  105. package/dist/types-CvhspRRt.mjs +0 -1
@@ -1,56 +0,0 @@
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] && context.fs.paths[fileId] !== id && fileId !== context.fs.paths[id] && context.fs.paths[fileId] !== context.fs.paths[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 };
56
- //# sourceMappingURL=filters-CpjboNi8.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filters-CpjboNi8.mjs","names":[],"sources":["../src/helpers/filters.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 { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { Context } from \"powerlines/types\";\nimport {\n BabelTransformPlugin,\n BabelTransformPluginFilter,\n BabelTransformPluginOptions,\n ResolvedBabelTransformPluginOptions\n} from \"powerlines/types/babel\";\n\nexport function getPluginName(\n plugin: BabelTransformPluginOptions\n): string | undefined {\n return isSetString(plugin)\n ? plugin\n : Array.isArray(plugin) && plugin.length > 0\n ? getPluginName(plugin[0])\n : (plugin as BabelTransformPlugin).$$name ||\n (plugin as BabelTransformPlugin).name\n ? (plugin as BabelTransformPlugin).$$name ||\n (plugin as BabelTransformPlugin).name\n : undefined;\n}\n\n/**\n * Check if a Babel plugin is a duplicate of another plugin in the list.\n *\n * @param plugins - The list of existing Babel plugins.\n * @param plugin - The Babel plugin to check for duplicates.\n * @returns True if the plugin is a duplicate, false otherwise.\n */\nexport function isDuplicatePlugin(\n plugins: (ResolvedBabelTransformPluginOptions | undefined)[],\n plugin: BabelTransformPluginOptions\n): boolean {\n return !!(\n getPluginName(plugin) &&\n plugins.some(\n existing =>\n Array.isArray(existing) &&\n getPluginName(existing[0]) === getPluginName(plugin)\n )\n );\n}\n\n/**\n * Filters a Babel plugin by its runtime ID.\n *\n * @param context - The context in which the filter is applied.\n * @param fileId - The file ID to filter by.\n * @returns A filter function that checks if a plugin's ID matches the runtime ID.\n */\nexport function filterPluginByFileId<TContext extends Context = Context>(\n context: TContext,\n fileId: string\n): BabelTransformPluginFilter {\n return (code: string, id: string): boolean =>\n fileId !== id &&\n context.fs.ids[fileId] !== id &&\n fileId !== context.fs.ids[id] &&\n context.fs.ids[fileId] !== context.fs.ids[id] &&\n context.fs.paths[fileId] !== id &&\n fileId !== context.fs.paths[id] &&\n context.fs.paths[fileId] !== context.fs.paths[id];\n}\n\n/**\n * Adds a filter to a Babel plugin or a list of Babel plugins.\n *\n * @param context - The context in which the plugin is being added.\n * @param plugins - The Babel plugins to add the filter to.\n * @param filter - The filter function to apply to the plugins.\n * @param name - The name of the plugin to add the filter to.\n * @returns The updated list of Babel plugins with the filter applied.\n */\nexport function addPluginFilter(\n context: Context,\n plugins: BabelTransformPluginOptions[],\n filter: BabelTransformPluginFilter | null | undefined,\n name: string\n): BabelTransformPluginOptions[];\n\n/**\n * Adds a filter to a Babel plugin or a list of Babel plugins.\n *\n * @param context - The context in which the plugin is being added.\n * @param plugin - The Babel plugin to add the filter to.\n * @param filter - The filter function to apply to the plugin.\n * @returns The updated Babel plugin with the filter applied.\n */\nexport function addPluginFilter(\n context: Context,\n plugin: BabelTransformPlugin | BabelTransformPluginOptions,\n filter: NonNullable<BabelTransformPluginFilter>\n): BabelTransformPluginOptions;\n\n/**\n * Adds a filter to a Babel plugin or a list of Babel plugins.\n *\n * @param context - The context in which the plugin is being added.\n * @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.\n * @param filter - The filter function to apply to the plugins.\n * @param name - The name of the plugin to add the filter to.\n * @returns The updated list of Babel plugins with the filter applied.\n */\nexport function addPluginFilter<\n T extends\n | BabelTransformPlugin\n | BabelTransformPluginOptions\n | BabelTransformPluginOptions[]\n>(\n context: Context,\n pluginOrPlugins: T,\n filter: NonNullable<BabelTransformPluginFilter>,\n name?: string\n): T extends BabelTransformPluginOptions[]\n ? BabelTransformPluginOptions[]\n : BabelTransformPluginOptions {\n if (\n !Array.isArray(pluginOrPlugins) ||\n (!pluginOrPlugins.some(plugin => Array.isArray(plugin)) &&\n pluginOrPlugins.length < 4 &&\n pluginOrPlugins.length > 0 &&\n (isSetString(pluginOrPlugins[0]) ||\n isFunction(pluginOrPlugins[0]) ||\n (pluginOrPlugins.length > 1 && isObject(pluginOrPlugins[1])) ||\n (pluginOrPlugins.length > 2 && isObject(pluginOrPlugins[2]))))\n ) {\n return Array.isArray(pluginOrPlugins)\n ? [\n pluginOrPlugins[0],\n pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},\n {\n filter: (code, id) =>\n filter(code, id) &&\n (pluginOrPlugins.length < 2 ||\n !isFunction(pluginOrPlugins[2]) ||\n pluginOrPlugins[2]?.(code, id))\n }\n ]\n : [\n pluginOrPlugins,\n {},\n {\n filter\n }\n ];\n }\n\n if (!name) {\n throw new Error(\n \"No name was provided to \\`addPluginFilter\\`, could not find babel plugin without it.\"\n );\n }\n\n const foundIndex = pluginOrPlugins.findIndex(\n plugin => getPluginName(plugin)?.toLowerCase() === name.toLowerCase()\n );\n if (foundIndex > -1) {\n pluginOrPlugins[foundIndex] = addPluginFilter(\n context,\n pluginOrPlugins[foundIndex],\n filter,\n name\n );\n }\n\n return pluginOrPlugins;\n}\n"],"mappings":";;;;;AA6BA,SAAgB,cACd,QACoB;AACpB,QAAO,YAAY,OAAO,GACtB,SACA,MAAM,QAAQ,OAAO,IAAI,OAAO,SAAS,IACvC,cAAc,OAAO,GAAG,GACvB,OAAgC,UAC9B,OAAgC,OAChC,OAAgC,UAChC,OAAgC,OACjC;;;;;;;;;AAUV,SAAgB,kBACd,SACA,QACS;AACT,QAAO,CAAC,EACN,cAAc,OAAO,IACrB,QAAQ,MACN,aACE,MAAM,QAAQ,SAAS,IACvB,cAAc,SAAS,GAAG,KAAK,cAAc,OAAO,CACvD;;;;;;;;;AAWL,SAAgB,qBACd,SACA,QAC4B;AAC5B,SAAQ,MAAc,OACpB,WAAW,MACX,QAAQ,GAAG,IAAI,YAAY,MAC3B,WAAW,QAAQ,GAAG,IAAI,OAC1B,QAAQ,GAAG,IAAI,YAAY,QAAQ,GAAG,IAAI,OAC1C,QAAQ,GAAG,MAAM,YAAY,MAC7B,WAAW,QAAQ,GAAG,MAAM,OAC5B,QAAQ,GAAG,MAAM,YAAY,QAAQ,GAAG,MAAM;;;;;;;;;;;AA0ClD,SAAgB,gBAMd,SACA,iBACA,QACA,MAG8B;AAC9B,KACE,CAAC,MAAM,QAAQ,gBAAgB,IAC9B,CAAC,gBAAgB,MAAK,WAAU,MAAM,QAAQ,OAAO,CAAC,IACrD,gBAAgB,SAAS,KACzB,gBAAgB,SAAS,MACxB,YAAY,gBAAgB,GAAG,IAC9B,WAAW,gBAAgB,GAAG,IAC7B,gBAAgB,SAAS,KAAK,SAAS,gBAAgB,GAAG,IAC1D,gBAAgB,SAAS,KAAK,SAAS,gBAAgB,GAAG,EAE/D,QAAO,MAAM,QAAQ,gBAAgB,GACjC;EACE,gBAAgB;EAChB,gBAAgB,SAAS,IAAI,gBAAgB,KAAK,EAAE;EACpD,EACE,SAAS,MAAM,OACb,OAAO,MAAM,GAAG,KACf,gBAAgB,SAAS,KACxB,CAAC,WAAW,gBAAgB,GAAG,IAC/B,gBAAgB,KAAK,MAAM,GAAG,GACnC;EACF,GACD;EACE;EACA,EAAE;EACF,EACE,QACD;EACF;AAGP,KAAI,CAAC,KACH,OAAM,IAAI,MACR,qFACD;CAGH,MAAM,aAAa,gBAAgB,WACjC,WAAU,cAAc,OAAO,EAAE,aAAa,KAAK,KAAK,aAAa,CACtE;AACD,KAAI,aAAa,GACf,iBAAgB,cAAc,gBAC5B,SACA,gBAAgB,aAChB,QACA,KACD;AAGH,QAAO"}
@@ -1,43 +0,0 @@
1
- import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "powerlines/types/babel";
2
- import { Context } from "powerlines/types";
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
42
- export { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
43
- //# sourceMappingURL=filters-D75MrPzl.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filters-D75MrPzl.d.mts","names":[],"sources":["../src/helpers/filters.ts"],"sourcesContent":[],"mappings":";;;;iBA6BgB,aAAA,SACN;;AADV;AAqBA;AAqBA;;;;AAGG,iBAxBa,iBAAA,CAwBb,OAAA,EAAA,CAvBS,mCAuBT,GAAA,SAAA,CAAA,EAAA,EAAA,MAAA,EAtBO,2BAsBP,CAAA,EAAA,OAAA;;AAoBH;;;;;;AAegB,iBAtCA,oBAsCe,CAAA,iBAtCuB,OAsCvB,GAtCiC,OAsCjC,CAAA,CAAA,OAAA,EArCpB,QAqCoB,EAAA,MAAA,EAAA,MAAA,CAAA,EAnC5B,0BAmC4B;;;;;;;;;;iBAff,eAAA,UACL,kBACA,uCACD,8DAEP;;;;;;;;;iBAUa,eAAA,UACL,iBACD,uBAAuB,qCACvB,YAAY,8BACnB"}
@@ -1,43 +0,0 @@
1
- import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "powerlines/types/babel";
2
- import { Context } from "powerlines/types";
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
42
- export { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
43
- //# sourceMappingURL=filters-DKyk7Jxg.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filters-DKyk7Jxg.d.cts","names":[],"sources":["../src/helpers/filters.ts"],"sourcesContent":[],"mappings":";;;;iBA6BgB,aAAA,SACN;;AADV;AAqBA;AAqBA;;;;AAGG,iBAxBa,iBAAA,CAwBb,OAAA,EAAA,CAvBS,mCAuBT,GAAA,SAAA,CAAA,EAAA,EAAA,MAAA,EAtBO,2BAsBP,CAAA,EAAA,OAAA;;AAoBH;;;;;;AAegB,iBAtCA,oBAsCe,CAAA,iBAtCuB,OAsCvB,GAtCiC,OAsCjC,CAAA,CAAA,OAAA,EArCpB,QAqCoB,EAAA,MAAA,EAAA,MAAA,CAAA,EAnC5B,0BAmC4B;;;;;;;;;;iBAff,eAAA,UACL,kBACA,uCACD,8DAEP;;;;;;;;;iBAUa,eAAA,UACL,iBACD,uBAAuB,qCACvB,YAAY,8BACnB"}
@@ -1 +0,0 @@
1
- export { };
File without changes
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1,50 +0,0 @@
1
- import { ParseResult } from "@babel/parser";
2
- import * as t from "@babel/types";
3
- import { ImportSpecifier } from "powerlines/types/babel";
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
49
- export { isImportCall as a, getImport as i, addImportsToProgram as n, listExports as o, findExport as r, listImports as s, addImport as t };
50
- //# sourceMappingURL=module-helpers-07-NCXys.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-helpers-07-NCXys.d.cts","names":[],"sources":["../src/helpers/module-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAgCA;AA6BA;AA4BA;;;AAAyD,iBAzDzC,UAAA,CAyDyC,GAAA,EAzDzB,WAyDyB,CAzDb,CAAA,CAAE,IAyDW,CAAA,EAAA,GAAA,EAAA,MAAA,CAAA,EAAA,GAAA;;AAsBzD;;;;;AAcgB,iBAhEA,WAAA,CAoEX,SAAA,EApEkC,WAoEjB,CApE6B,CAAA,CAAE,IAoE/B,CAAA,GAAA,MAAA,CAAA,EAAA,MAAA,EAAA;AAatB;AAuCA;;;;;iBA5FgB,WAAA,MAAiB,YAAY,CAAA,CAAE,QAAQ,CAAA,CAAE;iBAsBzC,YAAA,aACF,SAAS,CAAA,CAAE,iBAAiB,CAAA,CAAE;;;;;;;;;iBAa5B,SAAA,mDAIb,CAAA,CAAE;;;;;;;iBAaW,SAAA,OAAgB,0BAA0B;iBAuC1C,mBAAA,OACR,SAAS,CAAA,CAAE,qBACN"}
@@ -1,50 +0,0 @@
1
- import { NodePath } from "@babel/core";
2
- import { ParseResult } from "@babel/parser";
3
- import * as t from "@babel/types";
4
- import { ImportSpecifier } from "powerlines/types/babel";
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
49
- export { isImportCall as a, getImport as i, addImportsToProgram as n, listExports as o, findExport as r, listImports as s, addImport as t };
50
- //# sourceMappingURL=module-helpers-B1gnVB7F.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-helpers-B1gnVB7F.d.mts","names":[],"sources":["../src/helpers/module-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAgCA;AA6BA;AA4BA;;;AAAyD,iBAzDzC,UAAA,CAyDyC,GAAA,EAzDzB,WAyDyB,CAzDb,CAAA,CAAE,IAyDW,CAAA,EAAA,GAAA,EAAA,MAAA,CAAA,EAAA,GAAA;;AAsBzD;;;;;AAcgB,iBAhEA,WAAA,CAoEX,SAAA,EApEkC,WAoEjB,CApE6B,CAAA,CAAE,IAoE/B,CAAA,GAAA,MAAA,CAAA,EAAA,MAAA,EAAA;AAatB;AAuCA;;;;;iBA5FgB,WAAA,MAAiB,YAAY,CAAA,CAAE,QAAQ,CAAA,CAAE;iBAsBzC,YAAA,aACF,SAAS,CAAA,CAAE,iBAAiB,CAAA,CAAE;;;;;;;;;iBAa5B,SAAA,mDAIb,CAAA,CAAE;;;;;;;iBAaW,SAAA,OAAgB,0BAA0B;iBAuC1C,mBAAA,OACR,SAAS,CAAA,CAAE,qBACN"}
@@ -1,96 +0,0 @@
1
- import { n as parseAst } from "./ast-utils-DU1foCxH.mjs";
2
- import * as t from "@babel/types";
3
- import { isString } from "@stryke/type-checks/is-string";
4
-
5
- //#region src/helpers/module-helpers.ts
6
- /**
7
- * Finds an export in the given Babel AST program by its key.
8
- *
9
- * @param ast - The parsed Babel AST result containing the program body.
10
- * @param key - The name of the export to find (e.g., "default" or a named export).
11
- * @returns The declaration of the export if found, otherwise undefined.
12
- */
13
- function findExport(ast, key) {
14
- const type = key === "default" ? "ExportDefaultDeclaration" : "ExportNamedDeclaration";
15
- for (const node of ast.program.body) if (node.type === type) {
16
- if (key === "default") return node.declaration;
17
- if (node.declaration && "declarations" in node.declaration) {
18
- const declaration = node.declaration.declarations[0];
19
- if (declaration && "name" in declaration.id && declaration.id.name === key) return declaration.init;
20
- }
21
- }
22
- }
23
- /**
24
- * Lists all exports from the given Babel AST program.
25
- *
26
- * @param codeOrAst - The parsed Babel AST result containing the program body.
27
- * @returns An array of export names, including "default" for default exports.
28
- */
29
- function listExports(codeOrAst) {
30
- return (isString(codeOrAst) ? parseAst(codeOrAst) : codeOrAst).program.body.flatMap((i) => {
31
- if (i.type === "ExportDefaultDeclaration") return ["default"];
32
- if (i.type === "ExportNamedDeclaration" && i.declaration && "declarations" in i.declaration) return i.declaration.declarations.map((d) => "name" in d.id ? d.id.name : "");
33
- return [];
34
- }).filter(Boolean);
35
- }
36
- /**
37
- * Lists all imports from the given Babel AST program.
38
- *
39
- * @param ast - The parsed Babel AST result containing the program body.
40
- * @returns An array of import names, including "default" for default imports.
41
- */
42
- function listImports(ast) {
43
- return ast.program.body.flatMap((i) => {
44
- if (i.type === "ImportDeclaration") return i.specifiers.map((s) => {
45
- if (s.type === "ImportDefaultSpecifier") return "default";
46
- if (s.type === "ImportSpecifier" && "imported" in s) return s.imported.type === "Identifier" ? s.imported.name : s.imported.value;
47
- return "";
48
- });
49
- return [];
50
- }).filter(Boolean);
51
- }
52
- function isImportCall(calleePath) {
53
- return t.isImport(calleePath.node.callee);
54
- }
55
- /**
56
- * Gets the import declaration for a given name and specifier.
57
- *
58
- * @param specifier - The specifier of the import.
59
- * @param name - The name of the import.
60
- * @param named - Optional named import.
61
- * @returns The import declaration.
62
- */
63
- function getImport(specifier, name, named) {
64
- return t.importDeclaration([t.importSpecifier(t.identifier(name), t.stringLiteral(named || name))], t.stringLiteral(specifier));
65
- }
66
- /**
67
- * Adds an import to the program if it doesn't already exist.
68
- *
69
- * @param path - The current NodePath in the AST.
70
- * @param specifier - The import specifier.
71
- */
72
- function addImport(path, specifier) {
73
- addImportsToProgram(path.scope.getProgramParent().path, specifier);
74
- }
75
- function isNonNamespacedImport(importDeclPath) {
76
- return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
77
- }
78
- function getExistingImports(program) {
79
- const existingImports = /* @__PURE__ */ new Map();
80
- program.traverse({ ImportDeclaration(path) {
81
- if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
82
- } });
83
- return existingImports;
84
- }
85
- function addImportsToProgram(path, specifier) {
86
- /**
87
- * If an existing import of this module exists (ie \`import \{ ... \} from
88
- * '<moduleName>'\`), inject new imported specifiers into the list of
89
- * destructured variables.
90
- */
91
- if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(t.identifier(specifier.name || specifier.imported), t.identifier(specifier.imported))], t.stringLiteral(specifier.module)));
92
- }
93
-
94
- //#endregion
95
- export { isImportCall as a, getImport as i, addImportsToProgram as n, listExports as o, findExport as r, listImports as s, addImport as t };
96
- //# sourceMappingURL=module-helpers-Ckq8sc4l.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-helpers-Ckq8sc4l.mjs","names":[],"sources":["../src/helpers/module-helpers.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 { NodePath } from \"@babel/core\";\nimport { ParseResult } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { ImportSpecifier } from \"powerlines/types/babel\";\nimport { parseAst } from \"./ast-utils\";\n\n/**\n * Finds an export in the given Babel AST program by its key.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @param key - The name of the export to find (e.g., \"default\" or a named export).\n * @returns The declaration of the export if found, otherwise undefined.\n */\nexport function findExport(ast: ParseResult<t.File>, key: string) {\n const type =\n key === \"default\" ? \"ExportDefaultDeclaration\" : \"ExportNamedDeclaration\";\n\n for (const node of ast.program.body) {\n if (node.type === type) {\n if (key === \"default\") {\n return node.declaration;\n }\n if (node.declaration && \"declarations\" in node.declaration) {\n const declaration = node.declaration.declarations[0];\n if (\n declaration &&\n \"name\" in declaration.id &&\n declaration.id.name === key\n ) {\n return declaration.init as any;\n }\n }\n }\n }\n}\n\n/**\n * Lists all exports from the given Babel AST program.\n *\n * @param codeOrAst - The parsed Babel AST result containing the program body.\n * @returns An array of export names, including \"default\" for default exports.\n */\nexport function listExports(codeOrAst: ParseResult<t.File> | string) {\n const ast = isString(codeOrAst) ? parseAst(codeOrAst) : codeOrAst;\n\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ExportDefaultDeclaration\") {\n return [\"default\"];\n }\n if (\n i.type === \"ExportNamedDeclaration\" &&\n i.declaration &&\n \"declarations\" in i.declaration\n ) {\n return i.declaration.declarations.map(d =>\n \"name\" in d.id ? d.id.name : \"\"\n );\n }\n return [];\n })\n .filter(Boolean);\n}\n\n/**\n * Lists all imports from the given Babel AST program.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @returns An array of import names, including \"default\" for default imports.\n */\nexport function listImports(ast: ParseResult<t.File> | t.File) {\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ImportDeclaration\") {\n return i.specifiers.map(s => {\n if (s.type === \"ImportDefaultSpecifier\") {\n return \"default\";\n }\n if (s.type === \"ImportSpecifier\" && \"imported\" in s) {\n return s.imported.type === \"Identifier\"\n ? s.imported.name\n : s.imported.value;\n }\n return \"\";\n });\n }\n\n return [];\n })\n .filter(Boolean);\n}\n\nexport function isImportCall(\n calleePath: NodePath<t.CallExpression | t.NewExpression>\n) {\n return t.isImport(calleePath.node.callee);\n}\n\n/**\n * Gets the import declaration for a given name and specifier.\n *\n * @param specifier - The specifier of the import.\n * @param name - The name of the import.\n * @param named - Optional named import.\n * @returns The import declaration.\n */\nexport function getImport(\n specifier: string,\n name: string,\n named?: string\n): t.ImportDeclaration {\n return t.importDeclaration(\n [t.importSpecifier(t.identifier(name), t.stringLiteral(named || name))],\n t.stringLiteral(specifier)\n );\n}\n\n/**\n * Adds an import to the program if it doesn't already exist.\n *\n * @param path - The current NodePath in the AST.\n * @param specifier - The import specifier.\n */\nexport function addImport(path: NodePath<any>, specifier: ImportSpecifier) {\n addImportsToProgram(\n path.scope.getProgramParent().path as NodePath<t.Program>,\n specifier\n );\n}\n\n/*\n * Matches `import { ... } from <moduleName>;`\n * but not `import * as React from <moduleName>;`\n * `import type { Foo } from <moduleName>;`\n */\nfunction isNonNamespacedImport(\n importDeclPath: NodePath<t.ImportDeclaration>\n): boolean {\n return (\n importDeclPath\n .get(\"specifiers\")\n .filter(Boolean)\n .every(specifier => specifier?.isImportSpecifier()) &&\n importDeclPath.node.importKind !== \"type\" &&\n importDeclPath.node.importKind !== \"typeof\"\n );\n}\n\nfunction getExistingImports(\n program: NodePath<t.Program>\n): Map<string, NodePath<t.ImportDeclaration>> {\n const existingImports = new Map<string, NodePath<t.ImportDeclaration>>();\n program.traverse({\n ImportDeclaration(path) {\n if (isNonNamespacedImport(path)) {\n existingImports.set(path.node.source.value, path);\n }\n }\n });\n return existingImports;\n}\n\nexport function addImportsToProgram(\n path: NodePath<t.Program>,\n specifier: ImportSpecifier\n): void {\n const existingImports = getExistingImports(path);\n\n /**\n * If an existing import of this module exists (ie \\`import \\{ ... \\} from\n * '<moduleName>'\\`), inject new imported specifiers into the list of\n * destructured variables.\n */\n if (!existingImports.get(specifier.module)) {\n path.unshiftContainer(\n \"body\",\n t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(specifier.name || specifier.imported),\n t.identifier(specifier.imported)\n )\n ],\n t.stringLiteral(specifier.module)\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,WAAW,KAA0B,KAAa;CAChE,MAAM,OACJ,QAAQ,YAAY,6BAA6B;AAEnD,MAAK,MAAM,QAAQ,IAAI,QAAQ,KAC7B,KAAI,KAAK,SAAS,MAAM;AACtB,MAAI,QAAQ,UACV,QAAO,KAAK;AAEd,MAAI,KAAK,eAAe,kBAAkB,KAAK,aAAa;GAC1D,MAAM,cAAc,KAAK,YAAY,aAAa;AAClD,OACE,eACA,UAAU,YAAY,MACtB,YAAY,GAAG,SAAS,IAExB,QAAO,YAAY;;;;;;;;;;AAa7B,SAAgB,YAAY,WAAyC;AAGnE,SAFY,SAAS,UAAU,GAAG,SAAS,UAAU,GAAG,WAE7C,QAAQ,KAChB,SAAQ,MAAK;AACZ,MAAI,EAAE,SAAS,2BACb,QAAO,CAAC,UAAU;AAEpB,MACE,EAAE,SAAS,4BACX,EAAE,eACF,kBAAkB,EAAE,YAEpB,QAAO,EAAE,YAAY,aAAa,KAAI,MACpC,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,GAC9B;AAEH,SAAO,EAAE;GACT,CACD,OAAO,QAAQ;;;;;;;;AASpB,SAAgB,YAAY,KAAmC;AAC7D,QAAO,IAAI,QAAQ,KAChB,SAAQ,MAAK;AACZ,MAAI,EAAE,SAAS,oBACb,QAAO,EAAE,WAAW,KAAI,MAAK;AAC3B,OAAI,EAAE,SAAS,yBACb,QAAO;AAET,OAAI,EAAE,SAAS,qBAAqB,cAAc,EAChD,QAAO,EAAE,SAAS,SAAS,eACvB,EAAE,SAAS,OACX,EAAE,SAAS;AAEjB,UAAO;IACP;AAGJ,SAAO,EAAE;GACT,CACD,OAAO,QAAQ;;AAGpB,SAAgB,aACd,YACA;AACA,QAAO,EAAE,SAAS,WAAW,KAAK,OAAO;;;;;;;;;;AAW3C,SAAgB,UACd,WACA,MACA,OACqB;AACrB,QAAO,EAAE,kBACP,CAAC,EAAE,gBAAgB,EAAE,WAAW,KAAK,EAAE,EAAE,cAAc,SAAS,KAAK,CAAC,CAAC,EACvE,EAAE,cAAc,UAAU,CAC3B;;;;;;;;AASH,SAAgB,UAAU,MAAqB,WAA4B;AACzE,qBACE,KAAK,MAAM,kBAAkB,CAAC,MAC9B,UACD;;AAQH,SAAS,sBACP,gBACS;AACT,QACE,eACG,IAAI,aAAa,CACjB,OAAO,QAAQ,CACf,OAAM,cAAa,WAAW,mBAAmB,CAAC,IACrD,eAAe,KAAK,eAAe,UACnC,eAAe,KAAK,eAAe;;AAIvC,SAAS,mBACP,SAC4C;CAC5C,MAAM,kCAAkB,IAAI,KAA4C;AACxE,SAAQ,SAAS,EACf,kBAAkB,MAAM;AACtB,MAAI,sBAAsB,KAAK,CAC7B,iBAAgB,IAAI,KAAK,KAAK,OAAO,OAAO,KAAK;IAGtD,CAAC;AACF,QAAO;;AAGT,SAAgB,oBACd,MACA,WACM;;;;;;AAQN,KAAI,CAPoB,mBAAmB,KAAK,CAO3B,IAAI,UAAU,OAAO,CACxC,MAAK,iBACH,QACA,EAAE,kBACA,CACE,EAAE,gBACA,EAAE,WAAW,UAAU,QAAQ,UAAU,SAAS,EAClD,EAAE,WAAW,UAAU,SAAS,CACjC,CACF,EACD,EAAE,cAAc,UAAU,OAAO,CAClC,CACF"}
@@ -1,138 +0,0 @@
1
- const require_chunk = require('./chunk-CbDLau6x.cjs');
2
- const require_ast_utils = require('./ast-utils-BcmWaIan.cjs');
3
- let __babel_types = require("@babel/types");
4
- __babel_types = require_chunk.__toESM(__babel_types);
5
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
6
-
7
- //#region src/helpers/module-helpers.ts
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
- function findExport(ast, key) {
16
- const type = key === "default" ? "ExportDefaultDeclaration" : "ExportNamedDeclaration";
17
- for (const node of ast.program.body) if (node.type === type) {
18
- if (key === "default") return node.declaration;
19
- if (node.declaration && "declarations" in node.declaration) {
20
- const declaration = node.declaration.declarations[0];
21
- if (declaration && "name" in declaration.id && declaration.id.name === key) return declaration.init;
22
- }
23
- }
24
- }
25
- /**
26
- * Lists all exports from the given Babel AST program.
27
- *
28
- * @param codeOrAst - The parsed Babel AST result containing the program body.
29
- * @returns An array of export names, including "default" for default exports.
30
- */
31
- function listExports(codeOrAst) {
32
- return ((0, __stryke_type_checks_is_string.isString)(codeOrAst) ? require_ast_utils.parseAst(codeOrAst) : codeOrAst).program.body.flatMap((i) => {
33
- if (i.type === "ExportDefaultDeclaration") return ["default"];
34
- if (i.type === "ExportNamedDeclaration" && i.declaration && "declarations" in i.declaration) return i.declaration.declarations.map((d) => "name" in d.id ? d.id.name : "");
35
- return [];
36
- }).filter(Boolean);
37
- }
38
- /**
39
- * Lists all imports from the given Babel AST program.
40
- *
41
- * @param ast - The parsed Babel AST result containing the program body.
42
- * @returns An array of import names, including "default" for default imports.
43
- */
44
- function listImports(ast) {
45
- return ast.program.body.flatMap((i) => {
46
- if (i.type === "ImportDeclaration") return i.specifiers.map((s) => {
47
- if (s.type === "ImportDefaultSpecifier") return "default";
48
- if (s.type === "ImportSpecifier" && "imported" in s) return s.imported.type === "Identifier" ? s.imported.name : s.imported.value;
49
- return "";
50
- });
51
- return [];
52
- }).filter(Boolean);
53
- }
54
- function isImportCall(calleePath) {
55
- return __babel_types.isImport(calleePath.node.callee);
56
- }
57
- /**
58
- * Gets the import declaration for a given name and specifier.
59
- *
60
- * @param specifier - The specifier of the import.
61
- * @param name - The name of the import.
62
- * @param named - Optional named import.
63
- * @returns The import declaration.
64
- */
65
- function getImport(specifier, name, named) {
66
- return __babel_types.importDeclaration([__babel_types.importSpecifier(__babel_types.identifier(name), __babel_types.stringLiteral(named || name))], __babel_types.stringLiteral(specifier));
67
- }
68
- /**
69
- * Adds an import to the program if it doesn't already exist.
70
- *
71
- * @param path - The current NodePath in the AST.
72
- * @param specifier - The import specifier.
73
- */
74
- function addImport(path, specifier) {
75
- addImportsToProgram(path.scope.getProgramParent().path, specifier);
76
- }
77
- function isNonNamespacedImport(importDeclPath) {
78
- return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
79
- }
80
- function getExistingImports(program) {
81
- const existingImports = /* @__PURE__ */ new Map();
82
- program.traverse({ ImportDeclaration(path) {
83
- if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
84
- } });
85
- return existingImports;
86
- }
87
- function addImportsToProgram(path, specifier) {
88
- /**
89
- * If an existing import of this module exists (ie \`import \{ ... \} from
90
- * '<moduleName>'\`), inject new imported specifiers into the list of
91
- * destructured variables.
92
- */
93
- if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", __babel_types.importDeclaration([__babel_types.importSpecifier(__babel_types.identifier(specifier.name || specifier.imported), __babel_types.identifier(specifier.imported))], __babel_types.stringLiteral(specifier.module)));
94
- }
95
-
96
- //#endregion
97
- Object.defineProperty(exports, 'addImport', {
98
- enumerable: true,
99
- get: function () {
100
- return addImport;
101
- }
102
- });
103
- Object.defineProperty(exports, 'addImportsToProgram', {
104
- enumerable: true,
105
- get: function () {
106
- return addImportsToProgram;
107
- }
108
- });
109
- Object.defineProperty(exports, 'findExport', {
110
- enumerable: true,
111
- get: function () {
112
- return findExport;
113
- }
114
- });
115
- Object.defineProperty(exports, 'getImport', {
116
- enumerable: true,
117
- get: function () {
118
- return getImport;
119
- }
120
- });
121
- Object.defineProperty(exports, 'isImportCall', {
122
- enumerable: true,
123
- get: function () {
124
- return isImportCall;
125
- }
126
- });
127
- Object.defineProperty(exports, 'listExports', {
128
- enumerable: true,
129
- get: function () {
130
- return listExports;
131
- }
132
- });
133
- Object.defineProperty(exports, 'listImports', {
134
- enumerable: true,
135
- get: function () {
136
- return listImports;
137
- }
138
- });
@@ -1,59 +0,0 @@
1
- const require_chunk = require('./chunk-CbDLau6x.cjs');
2
- const require_filters = require('./filters-CU0L1nIa.cjs');
3
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
4
- let chalk = require("chalk");
5
- chalk = require_chunk.__toESM(chalk);
6
-
7
- //#region src/helpers/options.ts
8
- function resolvePluginFunction(context, plugin) {
9
- try {
10
- return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? (0, __stryke_type_checks_is_function.isFunction)(plugin[0]) ? plugin[0](context) : plugin[0] : (0, __stryke_type_checks_is_function.isFunction)(plugin) ? plugin(context) : plugin;
11
- } catch {
12
- return plugin[0];
13
- }
14
- }
15
- /**
16
- * Resolve the [Babel](https://babeljs.io/) plugin.
17
- *
18
- * @param context - The context for the transformation.
19
- * @param code - The code to be transformed.
20
- * @param id - The ID of the source file.
21
- * @param plugin - The Babel plugin to resolve.
22
- * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
23
- */
24
- function resolveBabelPlugin(context, code, id, plugin) {
25
- if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
26
- if (plugin.length > 2 && plugin[2] && (0, __stryke_type_checks_is_function.isFunction)(plugin[2]) && !plugin[2](code, id)) {
27
- context.trace(`Skipping filtered Babel plugin ${chalk.default.bold.cyanBright(require_filters.getPluginName(plugin) || "unnamed")} for ${id}`);
28
- return;
29
- }
30
- return plugin.length > 2 ? [
31
- resolvePluginFunction(context, plugin),
32
- plugin[1],
33
- plugin[2]
34
- ] : [
35
- resolvePluginFunction(context, plugin),
36
- plugin[1],
37
- null
38
- ];
39
- }
40
- return [
41
- resolvePluginFunction(context, plugin),
42
- {},
43
- null
44
- ];
45
- }
46
-
47
- //#endregion
48
- Object.defineProperty(exports, 'resolveBabelPlugin', {
49
- enumerable: true,
50
- get: function () {
51
- return resolveBabelPlugin;
52
- }
53
- });
54
- Object.defineProperty(exports, 'resolvePluginFunction', {
55
- enumerable: true,
56
- get: function () {
57
- return resolvePluginFunction;
58
- }
59
- });
@@ -1,19 +0,0 @@
1
- import { PluginOptions, PluginTarget } from "@babel/core";
2
- import { BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "powerlines/types/babel";
3
- import { Context } from "powerlines/types/context";
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
18
- export { resolvePluginFunction as n, resolveBabelPlugin as t };
19
- //# sourceMappingURL=options-CpZXObFr.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"options-CpZXObFr.d.mts","names":[],"sources":["../src/helpers/options.ts"],"sourcesContent":[],"mappings":";;;;;iBA4BgB,qBAAA,UACL,uBAGL,wBAEC,cAAc,kBACd,cAAc,qCAClB;;AARH;;;;;;;;AAQ8B,iBAuBd,kBAAA,CAvBc,OAAA,EAwBnB,OAxBmB,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EA2BpB,2BA3BoB,CAAA,EA4B3B,mCA5B2B,GAAA,SAAA"}