@powerlines/plugin-babel 0.12.306 → 0.12.308

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 (159) hide show
  1. package/dist/ast-utils-BcmWaIan.cjs +45 -0
  2. package/dist/ast-utils-BgcE0CUh.mjs +33 -0
  3. package/dist/ast-utils-BgcE0CUh.mjs.map +1 -0
  4. package/dist/ast-utils-BrOP-SXX.d.cts +20 -0
  5. package/dist/ast-utils-BrOP-SXX.d.cts.map +1 -0
  6. package/dist/ast-utils-c95WpQzC.d.mts +20 -0
  7. package/dist/ast-utils-c95WpQzC.d.mts.map +1 -0
  8. package/dist/{_virtual/rolldown_runtime.cjs → chunk-CbDLau6x.cjs} +6 -1
  9. package/dist/config-B8fQjuSs.d.cts +86 -0
  10. package/dist/config-B8fQjuSs.d.cts.map +1 -0
  11. package/dist/config-BGnCc0aq.d.mts +86 -0
  12. package/dist/config-BGnCc0aq.d.mts.map +1 -0
  13. package/dist/config-BLkkDfsC.mjs +1 -0
  14. package/dist/config-QK0F_KAD.cjs +0 -0
  15. package/dist/create-plugin-BbG_dRTl.mjs +40 -0
  16. package/dist/create-plugin-BbG_dRTl.mjs.map +1 -0
  17. package/dist/create-plugin-D1_rga7H.d.cts +16 -0
  18. package/dist/create-plugin-D1_rga7H.d.cts.map +1 -0
  19. package/dist/create-plugin-DaXcRyMI.cjs +46 -0
  20. package/dist/create-plugin-H35OVSz7.d.mts +16 -0
  21. package/dist/create-plugin-H35OVSz7.d.mts.map +1 -0
  22. package/dist/filters-CU0L1nIa.cjs +79 -0
  23. package/dist/filters-DX-_VLWz.d.mts +43 -0
  24. package/dist/filters-DX-_VLWz.d.mts.map +1 -0
  25. package/dist/filters-DjAUc6r9.mjs +56 -0
  26. package/dist/filters-DjAUc6r9.mjs.map +1 -0
  27. package/dist/filters-xc5uoxxD.d.cts +43 -0
  28. package/dist/filters-xc5uoxxD.d.cts.map +1 -0
  29. package/dist/helpers/ast-utils.cjs +3 -34
  30. package/dist/helpers/ast-utils.d.cts +2 -20
  31. package/dist/helpers/ast-utils.d.mts +2 -20
  32. package/dist/helpers/ast-utils.mjs +2 -32
  33. package/dist/helpers/create-plugin.cjs +2 -40
  34. package/dist/helpers/create-plugin.d.cts +3 -16
  35. package/dist/helpers/create-plugin.d.mts +3 -17
  36. package/dist/helpers/create-plugin.mjs +2 -39
  37. package/dist/helpers/filters.cjs +5 -58
  38. package/dist/helpers/filters.d.cts +3 -43
  39. package/dist/helpers/filters.d.mts +3 -44
  40. package/dist/helpers/filters.mjs +2 -55
  41. package/dist/helpers/index.cjs +22 -21
  42. package/dist/helpers/index.d.cts +7 -5
  43. package/dist/helpers/index.d.mts +7 -5
  44. package/dist/helpers/index.mjs +6 -5
  45. package/dist/helpers/module-helpers.cjs +9 -102
  46. package/dist/helpers/module-helpers.d.cts +3 -50
  47. package/dist/helpers/module-helpers.d.mts +3 -50
  48. package/dist/helpers/module-helpers.mjs +3 -95
  49. package/dist/helpers/options.cjs +4 -48
  50. package/dist/helpers/options.d.cts +3 -19
  51. package/dist/helpers/options.d.mts +3 -20
  52. package/dist/helpers/options.mjs +3 -46
  53. package/dist/helpers-Bx2yBrpn.cjs +0 -0
  54. package/dist/helpers-DemUUgdw.mjs +1 -0
  55. package/dist/index-C2gUMYkE.d.cts +1 -0
  56. package/dist/index-D8dPsry7.d.mts +1 -0
  57. package/dist/index-OEBbnNdr.d.mts +1 -0
  58. package/dist/index-uTS5iDq_.d.cts +1 -0
  59. package/dist/index.cjs +30 -27
  60. package/dist/index.d.cts +10 -8
  61. package/dist/index.d.cts.map +1 -1
  62. package/dist/index.d.mts +10 -11
  63. package/dist/index.d.mts.map +1 -1
  64. package/dist/index.mjs +9 -6
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/module-helpers-B913A2FR.d.mts +50 -0
  67. package/dist/module-helpers-B913A2FR.d.mts.map +1 -0
  68. package/dist/module-helpers-BBKb6fKg.d.cts +50 -0
  69. package/dist/module-helpers-BBKb6fKg.d.cts.map +1 -0
  70. package/dist/module-helpers-DtOc93YQ.mjs +96 -0
  71. package/dist/module-helpers-DtOc93YQ.mjs.map +1 -0
  72. package/dist/module-helpers-Non-jHMu.cjs +138 -0
  73. package/dist/options-2JL6WIXT.cjs +59 -0
  74. package/dist/options-CNyetWnk.d.cts +19 -0
  75. package/dist/options-CNyetWnk.d.cts.map +1 -0
  76. package/dist/options-DT_wvMGu.mjs +47 -0
  77. package/dist/options-DT_wvMGu.mjs.map +1 -0
  78. package/dist/options-Z_v0-Y5V.d.mts +19 -0
  79. package/dist/options-Z_v0-Y5V.d.mts.map +1 -0
  80. package/dist/plugin-10Y9IjgN.d.cts +19 -0
  81. package/dist/plugin-10Y9IjgN.d.cts.map +1 -0
  82. package/dist/plugin-25m6BdNV.d.mts +19 -0
  83. package/dist/plugin-25m6BdNV.d.mts.map +1 -0
  84. package/dist/plugin-BX9Q6Mnb.mjs +1 -0
  85. package/dist/plugin-DkYJiG5m.cjs +0 -0
  86. package/dist/types/config.cjs +1 -0
  87. package/dist/types/config.d.cts +2 -87
  88. package/dist/types/config.d.mts +2 -88
  89. package/dist/types/config.mjs +2 -0
  90. package/dist/types/index.cjs +3 -0
  91. package/dist/types/index.d.cts +3 -2
  92. package/dist/types/index.d.mts +3 -2
  93. package/dist/types/index.mjs +4 -0
  94. package/dist/types/plugin.cjs +1 -0
  95. package/dist/types/plugin.d.cts +3 -20
  96. package/dist/types/plugin.d.mts +3 -21
  97. package/dist/types/plugin.mjs +2 -0
  98. package/dist/types-Bjn15Uy6.mjs +1 -0
  99. package/dist/types-D10T4PdD.cjs +0 -0
  100. package/package.json +2 -2
  101. package/dist/core/src/lib/logger.cjs +0 -41
  102. package/dist/core/src/lib/logger.mjs +0 -40
  103. package/dist/core/src/lib/logger.mjs.map +0 -1
  104. package/dist/core/src/types/api.d.cts +0 -103
  105. package/dist/core/src/types/api.d.cts.map +0 -1
  106. package/dist/core/src/types/api.d.mts +0 -103
  107. package/dist/core/src/types/api.d.mts.map +0 -1
  108. package/dist/core/src/types/commands.d.cts +0 -9
  109. package/dist/core/src/types/commands.d.cts.map +0 -1
  110. package/dist/core/src/types/commands.d.mts +0 -10
  111. package/dist/core/src/types/commands.d.mts.map +0 -1
  112. package/dist/core/src/types/config.d.cts +0 -551
  113. package/dist/core/src/types/config.d.cts.map +0 -1
  114. package/dist/core/src/types/config.d.mts +0 -551
  115. package/dist/core/src/types/config.d.mts.map +0 -1
  116. package/dist/core/src/types/context.d.cts +0 -511
  117. package/dist/core/src/types/context.d.cts.map +0 -1
  118. package/dist/core/src/types/context.d.mts +0 -511
  119. package/dist/core/src/types/context.d.mts.map +0 -1
  120. package/dist/core/src/types/fs.d.cts +0 -487
  121. package/dist/core/src/types/fs.d.cts.map +0 -1
  122. package/dist/core/src/types/fs.d.mts +0 -487
  123. package/dist/core/src/types/fs.d.mts.map +0 -1
  124. package/dist/core/src/types/hooks.d.cts +0 -99
  125. package/dist/core/src/types/hooks.d.cts.map +0 -1
  126. package/dist/core/src/types/hooks.d.mts +0 -99
  127. package/dist/core/src/types/hooks.d.mts.map +0 -1
  128. package/dist/core/src/types/index.d.mts +0 -9
  129. package/dist/core/src/types/plugin.d.cts +0 -204
  130. package/dist/core/src/types/plugin.d.cts.map +0 -1
  131. package/dist/core/src/types/plugin.d.mts +0 -204
  132. package/dist/core/src/types/plugin.d.mts.map +0 -1
  133. package/dist/core/src/types/tsconfig.d.cts +0 -70
  134. package/dist/core/src/types/tsconfig.d.cts.map +0 -1
  135. package/dist/core/src/types/tsconfig.d.mts +0 -70
  136. package/dist/core/src/types/tsconfig.d.mts.map +0 -1
  137. package/dist/core/src/types/unplugin.d.cts +0 -24
  138. package/dist/core/src/types/unplugin.d.cts.map +0 -1
  139. package/dist/core/src/types/unplugin.d.mts +0 -25
  140. package/dist/core/src/types/unplugin.d.mts.map +0 -1
  141. package/dist/helpers/ast-utils.d.cts.map +0 -1
  142. package/dist/helpers/ast-utils.d.mts.map +0 -1
  143. package/dist/helpers/ast-utils.mjs.map +0 -1
  144. package/dist/helpers/create-plugin.d.cts.map +0 -1
  145. package/dist/helpers/create-plugin.d.mts.map +0 -1
  146. package/dist/helpers/create-plugin.mjs.map +0 -1
  147. package/dist/helpers/filters.d.cts.map +0 -1
  148. package/dist/helpers/filters.d.mts.map +0 -1
  149. package/dist/helpers/filters.mjs.map +0 -1
  150. package/dist/helpers/module-helpers.d.cts.map +0 -1
  151. package/dist/helpers/module-helpers.d.mts.map +0 -1
  152. package/dist/helpers/module-helpers.mjs.map +0 -1
  153. package/dist/helpers/options.d.cts.map +0 -1
  154. package/dist/helpers/options.d.mts.map +0 -1
  155. package/dist/helpers/options.mjs.map +0 -1
  156. package/dist/types/config.d.cts.map +0 -1
  157. package/dist/types/config.d.mts.map +0 -1
  158. package/dist/types/plugin.d.cts.map +0 -1
  159. package/dist/types/plugin.d.mts.map +0 -1
@@ -0,0 +1,56 @@
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-DjAUc6r9.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters-DjAUc6r9.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 { Context } from \"@powerlines/core/types\";\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 {\n BabelTransformPlugin,\n BabelTransformPluginFilter,\n BabelTransformPluginOptions,\n ResolvedBabelTransformPluginOptions\n} from \"../types/config\";\n\nexport function getPluginName(\n plugin?:\n | BabelTransformPluginOptions\n | string\n | false\n | object\n | ((...args: any[]) => any)\n | undefined\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,QAOoB;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"}
@@ -0,0 +1,43 @@
1
+ import { c as BabelTransformPluginOptions, h as ResolvedBabelTransformPluginOptions, i as BabelTransformPlugin, s as BabelTransformPluginFilter } from "./config-B8fQjuSs.cjs";
2
+ import { Context } from "@powerlines/core/types";
3
+
4
+ //#region src/helpers/filters.d.ts
5
+ declare function getPluginName(plugin?: BabelTransformPluginOptions | string | false | object | ((...args: any[]) => any) | undefined): 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-xc5uoxxD.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters-xc5uoxxD.d.cts","names":[],"sources":["../src/helpers/filters.ts"],"sourcesContent":[],"mappings":";;;;iBA6BgB,aAAA,UAEV;;AAFN;AA2BA;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,35 +1,4 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __babel_generator = require("@babel/generator");
3
- __babel_generator = require_rolldown_runtime.__toESM(__babel_generator);
4
- let __babel_parser = require("@babel/parser");
1
+ const require_ast_utils = require('../ast-utils-BcmWaIan.cjs');
5
2
 
6
- //#region src/helpers/ast-utils.ts
7
- /**
8
- * Parse the given code into an AST.
9
- *
10
- * @param code - The code to parse.
11
- * @param opts - The options for parsing.
12
- * @returns The parsed AST.
13
- */
14
- function parseAst(code, opts = {}) {
15
- return (0, __babel_parser.parse)(code, {
16
- plugins: ["typescript"],
17
- sourceType: "module",
18
- allowImportExportEverywhere: true,
19
- allowAwaitOutsideFunction: true,
20
- ...opts
21
- });
22
- }
23
- let generate = __babel_generator.default;
24
- if ("default" in generate) generate = generate.default;
25
- function generateFromAst(ast, opts) {
26
- return generate(ast, opts ? {
27
- importAttributesKeyword: "with",
28
- sourceMaps: true,
29
- ...opts
30
- } : void 0);
31
- }
32
-
33
- //#endregion
34
- exports.generateFromAst = generateFromAst;
35
- exports.parseAst = parseAst;
3
+ exports.generateFromAst = require_ast_utils.generateFromAst;
4
+ exports.parseAst = require_ast_utils.parseAst;
@@ -1,20 +1,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 };
20
- //# sourceMappingURL=ast-utils.d.cts.map
1
+ import { a as parseAst, i as generateFromAst, n as GeneratorResult, r as __ΩGenerateFromAstOptions, t as GenerateFromAstOptions } from "../ast-utils-BrOP-SXX.cjs";
2
+ export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
@@ -1,20 +1,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 };
20
- //# sourceMappingURL=ast-utils.d.mts.map
1
+ import { a as parseAst, i as generateFromAst, n as GeneratorResult, r as __ΩGenerateFromAstOptions, t as GenerateFromAstOptions } from "../ast-utils-c95WpQzC.mjs";
2
+ export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
@@ -1,33 +1,3 @@
1
- import _generate from "@babel/generator";
2
- import { parse } from "@babel/parser";
1
+ import { n as parseAst, t as generateFromAst } from "../ast-utils-BgcE0CUh.mjs";
3
2
 
4
- //#region src/helpers/ast-utils.ts
5
- /**
6
- * Parse the given code into an AST.
7
- *
8
- * @param code - The code to parse.
9
- * @param opts - The options for parsing.
10
- * @returns The parsed AST.
11
- */
12
- function parseAst(code, opts = {}) {
13
- return parse(code, {
14
- plugins: ["typescript"],
15
- sourceType: "module",
16
- allowImportExportEverywhere: true,
17
- allowAwaitOutsideFunction: true,
18
- ...opts
19
- });
20
- }
21
- let generate = _generate;
22
- if ("default" in generate) generate = generate.default;
23
- function generateFromAst(ast, opts) {
24
- return generate(ast, opts ? {
25
- importAttributesKeyword: "with",
26
- sourceMaps: true,
27
- ...opts
28
- } : void 0);
29
- }
30
-
31
- //#endregion
32
- export { generateFromAst, parseAst };
33
- //# sourceMappingURL=ast-utils.mjs.map
3
+ export { generateFromAst, parseAst };
@@ -1,41 +1,3 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_logger = require('../core/src/lib/logger.cjs');
3
- let chalk = require("chalk");
4
- chalk = require_rolldown_runtime.__toESM(chalk);
5
- let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
6
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
1
+ const require_create_plugin = require('../create-plugin-DaXcRyMI.cjs');
7
2
 
8
- //#region src/helpers/create-plugin.ts
9
- /**
10
- * Create a Babel plugin using the provided builder function.
11
- *
12
- * @param name - The name of the plugin.
13
- * @param builder - The builder function that defines the plugin behavior.
14
- * @returns A Babel plugin declaration.
15
- */
16
- function createBabelPlugin(name, builder) {
17
- const plugin = (context) => {
18
- return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
19
- api.cache.using(() => context.meta.checksum);
20
- api.assertVersion("^7.0.0-0");
21
- const log = require_logger.extendLog(context.log, name);
22
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
23
- const result = builder({
24
- log,
25
- name,
26
- api,
27
- options,
28
- context,
29
- dirname
30
- });
31
- result.name = name;
32
- log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
33
- return result;
34
- });
35
- };
36
- plugin.$$name = name;
37
- return plugin;
38
- }
39
-
40
- //#endregion
41
- exports.createBabelPlugin = createBabelPlugin;
3
+ exports.createBabelPlugin = require_create_plugin.createBabelPlugin;
@@ -1,16 +1,3 @@
1
- import { Context } from "../core/src/types/context.cjs";
2
- import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "../types/config.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
15
- export { createBabelPlugin };
16
- //# sourceMappingURL=create-plugin.d.cts.map
1
+ import "../config-B8fQjuSs.cjs";
2
+ import { t as createBabelPlugin } from "../create-plugin-D1_rga7H.cjs";
3
+ export { createBabelPlugin };
@@ -1,17 +1,3 @@
1
- import { Context } from "../core/src/types/context.mjs";
2
- import "../core/src/types/index.mjs";
3
- import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "../types/config.mjs";
4
-
5
- //#region src/helpers/create-plugin.d.ts
6
-
7
- /**
8
- * Create a Babel plugin using the provided builder function.
9
- *
10
- * @param name - The name of the plugin.
11
- * @param builder - The builder function that defines the plugin behavior.
12
- * @returns A Babel plugin declaration.
13
- */
14
- declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
15
- //#endregion
16
- export { createBabelPlugin };
17
- //# sourceMappingURL=create-plugin.d.mts.map
1
+ import "../config-BGnCc0aq.mjs";
2
+ import { t as createBabelPlugin } from "../create-plugin-H35OVSz7.mjs";
3
+ export { createBabelPlugin };
@@ -1,40 +1,3 @@
1
- import { extendLog } from "../core/src/lib/logger.mjs";
2
- import chalk from "chalk";
3
- import { declare } from "@babel/helper-plugin-utils";
4
- import { LogLevelLabel } from "@storm-software/config-tools/types";
1
+ import { t as createBabelPlugin } from "../create-plugin-BbG_dRTl.mjs";
5
2
 
6
- //#region src/helpers/create-plugin.ts
7
- /**
8
- * Create a Babel plugin using the provided builder function.
9
- *
10
- * @param name - The name of the plugin.
11
- * @param builder - The builder function that defines the plugin behavior.
12
- * @returns A Babel plugin declaration.
13
- */
14
- function createBabelPlugin(name, builder) {
15
- const plugin = (context) => {
16
- return declare((api, options, dirname) => {
17
- api.cache.using(() => context.meta.checksum);
18
- api.assertVersion("^7.0.0-0");
19
- const log = extendLog(context.log, name);
20
- log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
21
- const result = builder({
22
- log,
23
- name,
24
- api,
25
- options,
26
- context,
27
- dirname
28
- });
29
- result.name = name;
30
- log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
31
- return result;
32
- });
33
- };
34
- plugin.$$name = name;
35
- return plugin;
36
- }
37
-
38
- //#endregion
39
- export { createBabelPlugin };
40
- //# sourceMappingURL=create-plugin.mjs.map
3
+ export { createBabelPlugin };
@@ -1,59 +1,6 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
3
- let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
4
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
1
+ const require_filters = require('../filters-CU0L1nIa.cjs');
5
2
 
6
- //#region src/helpers/filters.ts
7
- function getPluginName(plugin) {
8
- return (0, __stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
9
- }
10
- /**
11
- * Check if a Babel plugin is a duplicate of another plugin in the list.
12
- *
13
- * @param plugins - The list of existing Babel plugins.
14
- * @param plugin - The Babel plugin to check for duplicates.
15
- * @returns True if the plugin is a duplicate, false otherwise.
16
- */
17
- function isDuplicatePlugin(plugins, plugin) {
18
- return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
19
- }
20
- /**
21
- * Filters a Babel plugin by its runtime ID.
22
- *
23
- * @param context - The context in which the filter is applied.
24
- * @param fileId - The file ID to filter by.
25
- * @returns A filter function that checks if a plugin's ID matches the runtime ID.
26
- */
27
- function filterPluginByFileId(context, fileId) {
28
- return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id] && context.fs.paths[fileId] !== id && fileId !== context.fs.paths[id] && context.fs.paths[fileId] !== context.fs.paths[id];
29
- }
30
- /**
31
- * Adds a filter to a Babel plugin or a list of Babel plugins.
32
- *
33
- * @param context - The context in which the plugin is being added.
34
- * @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.
35
- * @param filter - The filter function to apply to the plugins.
36
- * @param name - The name of the plugin to add the filter to.
37
- * @returns The updated list of Babel plugins with the filter applied.
38
- */
39
- function addPluginFilter(context, pluginOrPlugins, filter, name) {
40
- if (!Array.isArray(pluginOrPlugins) || !pluginOrPlugins.some((plugin) => Array.isArray(plugin)) && pluginOrPlugins.length < 4 && pluginOrPlugins.length > 0 && ((0, __stryke_type_checks_is_set_string.isSetString)(pluginOrPlugins[0]) || (0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[0]) || pluginOrPlugins.length > 1 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[1]) || pluginOrPlugins.length > 2 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[2]))) return Array.isArray(pluginOrPlugins) ? [
41
- pluginOrPlugins[0],
42
- pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},
43
- { filter: (code, id) => filter(code, id) && (pluginOrPlugins.length < 2 || !(0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[2]) || pluginOrPlugins[2]?.(code, id)) }
44
- ] : [
45
- pluginOrPlugins,
46
- {},
47
- { filter }
48
- ];
49
- if (!name) throw new Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");
50
- const foundIndex = pluginOrPlugins.findIndex((plugin) => getPluginName(plugin)?.toLowerCase() === name.toLowerCase());
51
- if (foundIndex > -1) pluginOrPlugins[foundIndex] = addPluginFilter(context, pluginOrPlugins[foundIndex], filter, name);
52
- return pluginOrPlugins;
53
- }
54
-
55
- //#endregion
56
- exports.addPluginFilter = addPluginFilter;
57
- exports.filterPluginByFileId = filterPluginByFileId;
58
- exports.getPluginName = getPluginName;
59
- exports.isDuplicatePlugin = isDuplicatePlugin;
3
+ exports.addPluginFilter = require_filters.addPluginFilter;
4
+ exports.filterPluginByFileId = require_filters.filterPluginByFileId;
5
+ exports.getPluginName = require_filters.getPluginName;
6
+ exports.isDuplicatePlugin = require_filters.isDuplicatePlugin;
@@ -1,43 +1,3 @@
1
- import { Context } from "../core/src/types/context.cjs";
2
- import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../types/config.cjs";
3
-
4
- //#region src/helpers/filters.d.ts
5
- declare function getPluginName(plugin?: BabelTransformPluginOptions | string | false | object | ((...args: any[]) => any) | undefined): 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 { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
43
- //# sourceMappingURL=filters.d.cts.map
1
+ import "../config-B8fQjuSs.cjs";
2
+ import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-xc5uoxxD.cjs";
3
+ export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
@@ -1,44 +1,3 @@
1
- import { Context } from "../core/src/types/context.mjs";
2
- import "../core/src/types/index.mjs";
3
- import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../types/config.mjs";
4
-
5
- //#region src/helpers/filters.d.ts
6
- declare function getPluginName(plugin?: BabelTransformPluginOptions | string | false | object | ((...args: any[]) => any) | undefined): 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
43
- export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
44
- //# sourceMappingURL=filters.d.mts.map
1
+ import "../config-BGnCc0aq.mjs";
2
+ import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-DX-_VLWz.mjs";
3
+ export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
@@ -1,56 +1,3 @@
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";
1
+ import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-DjAUc6r9.mjs";
4
2
 
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 { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
56
- //# sourceMappingURL=filters.mjs.map
3
+ export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };