@powerlines/plugin-babel 0.12.303 → 0.12.305

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 (49) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/core/src/lib/logger.cjs +41 -0
  3. package/dist/core/src/types/api.d.cts +103 -0
  4. package/dist/core/src/types/api.d.cts.map +1 -0
  5. package/dist/core/src/types/commands.d.cts +9 -0
  6. package/dist/core/src/types/commands.d.cts.map +1 -0
  7. package/dist/core/src/types/config.d.cts +551 -0
  8. package/dist/core/src/types/config.d.cts.map +1 -0
  9. package/dist/core/src/types/context.d.cts +511 -0
  10. package/dist/core/src/types/context.d.cts.map +1 -0
  11. package/dist/core/src/types/fs.d.cts +487 -0
  12. package/dist/core/src/types/fs.d.cts.map +1 -0
  13. package/dist/core/src/types/hooks.d.cts +99 -0
  14. package/dist/core/src/types/hooks.d.cts.map +1 -0
  15. package/dist/core/src/types/plugin.d.cts +204 -0
  16. package/dist/core/src/types/plugin.d.cts.map +1 -0
  17. package/dist/core/src/types/tsconfig.d.cts +70 -0
  18. package/dist/core/src/types/tsconfig.d.cts.map +1 -0
  19. package/dist/core/src/types/unplugin.d.cts +24 -0
  20. package/dist/core/src/types/unplugin.d.cts.map +1 -0
  21. package/dist/helpers/ast-utils.cjs +35 -0
  22. package/dist/helpers/ast-utils.d.cts +20 -0
  23. package/dist/helpers/ast-utils.d.cts.map +1 -0
  24. package/dist/helpers/create-plugin.cjs +41 -0
  25. package/dist/helpers/create-plugin.d.cts +16 -0
  26. package/dist/helpers/create-plugin.d.cts.map +1 -0
  27. package/dist/helpers/filters.cjs +59 -0
  28. package/dist/helpers/filters.d.cts +43 -0
  29. package/dist/helpers/filters.d.cts.map +1 -0
  30. package/dist/helpers/index.cjs +22 -0
  31. package/dist/helpers/index.d.cts +6 -0
  32. package/dist/helpers/module-helpers.cjs +103 -0
  33. package/dist/helpers/module-helpers.d.cts +50 -0
  34. package/dist/helpers/module-helpers.d.cts.map +1 -0
  35. package/dist/helpers/options.cjs +49 -0
  36. package/dist/helpers/options.d.cts +19 -0
  37. package/dist/helpers/options.d.cts.map +1 -0
  38. package/dist/index.cjs +104 -0
  39. package/dist/index.d.cts +20 -0
  40. package/dist/index.d.cts.map +1 -0
  41. package/dist/types/config.cjs +0 -0
  42. package/dist/types/config.d.cts +87 -0
  43. package/dist/types/config.d.cts.map +1 -0
  44. package/dist/types/index.cjs +0 -0
  45. package/dist/types/index.d.cts +3 -0
  46. package/dist/types/plugin.cjs +0 -0
  47. package/dist/types/plugin.d.cts +20 -0
  48. package/dist/types/plugin.d.cts.map +1 -0
  49. package/package.json +41 -14
@@ -0,0 +1,204 @@
1
+ import { CommandType } from "./commands.cjs";
2
+ import { BuilderVariant, InferUnpluginOptions } from "./unplugin.cjs";
3
+ import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.cjs";
4
+ import { EnvironmentConfig, EnvironmentResolvedConfig, PluginConfig, ResolvedConfig } from "./config.cjs";
5
+ import { AnyFunction, MaybePromise } from "@stryke/types/base";
6
+ import { ExternalIdResult, HookFilter, TransformResult } from "unplugin";
7
+ import { ArrayValues } from "@stryke/types/array";
8
+ import { LoadResult } from "rollup";
9
+
10
+ //#region ../core/src/types/plugin.d.ts
11
+ interface PluginHookObject<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> {
12
+ /**
13
+ * The order in which the plugin should be applied.
14
+ */
15
+ order?: "pre" | "post" | null | undefined;
16
+ /**
17
+ * A filter to determine when the hook should be called.
18
+ */
19
+ filter?: Pick<HookFilter, TFilter>;
20
+ /**
21
+ * The hook function to be called.
22
+ */
23
+ handler: THookFunction;
24
+ }
25
+ type PluginHook<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
26
+ /**
27
+ * A result returned by the plugin from the `types` hook that describes the declaration types output file.
28
+ */
29
+ interface TypesResult {
30
+ directives?: string[];
31
+ code: string;
32
+ }
33
+ type PluginHookFunctions<TContext extends PluginContext> = { [TCommandType in CommandType]: (this: TContext) => MaybePromise<void> } & {
34
+ /**
35
+ * A function that returns configuration options to be merged with the build context's options.
36
+ *
37
+ * @remarks
38
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
39
+ *
40
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect.
41
+ *
42
+ * @see https://vitejs.dev/guide/api-plugin#config
43
+ *
44
+ * @param this - The build context.
45
+ * @param config - The partial configuration object to be modified.
46
+ * @returns A promise that resolves to a partial configuration object.
47
+ */
48
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>;
49
+ /**
50
+ * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.
51
+ *
52
+ * @remarks
53
+ * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
54
+ *
55
+ * @see https://vitejs.dev/guide/api-plugin#configenvironment
56
+ *
57
+ * @param this - The build context.
58
+ * @param name - The name of the environment being configured.
59
+ * @param environment - The Vite-like environment object containing information about the current build environment.
60
+ * @returns A promise that resolves when the hook is complete.
61
+ */
62
+ configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
63
+ /**
64
+ * A hook that is called when the plugin is resolved.
65
+ *
66
+ * @see https://vitejs.dev/guide/api-plugin#configresolved
67
+ *
68
+ * @param this - The build context.
69
+ * @returns A promise that resolves when the hook is complete.
70
+ */
71
+ configResolved: (this: TContext) => MaybePromise<void>;
72
+ /**
73
+ * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
74
+ *
75
+ * @param this - The build context.
76
+ * @param code - The source code to generate types for.
77
+ * @returns A promise that resolves when the hook is complete.
78
+ */
79
+ types: (this: TContext, code: string) => MaybePromise<TypesResult | string | undefined | null>;
80
+ /**
81
+ * A hook that is called at the start of the build process.
82
+ *
83
+ * @param this - The build context and unplugin build context.
84
+ * @returns A promise that resolves when the hook is complete.
85
+ */
86
+ buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
87
+ /**
88
+ * A hook that is called at the end of the build process.
89
+ *
90
+ * @param this - The build context and unplugin build context.
91
+ * @returns A promise that resolves when the hook is complete.
92
+ */
93
+ buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
94
+ /**
95
+ * A hook that is called to transform the source code.
96
+ *
97
+ * @param this - The build context, unplugin build context, and unplugin context.
98
+ * @param code - The source code to transform.
99
+ * @param id - The identifier of the source code.
100
+ * @returns A promise that resolves when the hook is complete.
101
+ */
102
+ transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
103
+ /**
104
+ * A hook that is called to load the source code.
105
+ *
106
+ * @param this - The build context, unplugin build context, and unplugin context.
107
+ * @param id - The identifier of the source code.
108
+ * @returns A promise that resolves when the hook is complete.
109
+ */
110
+ load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<LoadResult>;
111
+ /**
112
+ * A hook that is called to resolve the identifier of the source code.
113
+ *
114
+ * @param this - The build context, unplugin build context, and unplugin context.
115
+ * @param id - The identifier of the source code.
116
+ * @param importer - The importer of the source code.
117
+ * @param options - The options for resolving the identifier.
118
+ * @returns A promise that resolves when the hook is complete.
119
+ */
120
+ resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
121
+ isEntry: boolean;
122
+ }) => MaybePromise<string | ExternalIdResult | null | undefined>;
123
+ /**
124
+ * A hook that is called to write the bundle to disk.
125
+ *
126
+ * @param this - The build context.
127
+ * @returns A promise that resolves when the hook is complete.
128
+ */
129
+ writeBundle: (this: TContext) => MaybePromise<void>;
130
+ };
131
+ type PluginHooks<TContext extends PluginContext> = { [TPluginHook in keyof PluginHookFunctions<TContext>]?: PluginHook<PluginHookFunctions<TContext>[TPluginHook]> } & {
132
+ transform: PluginHook<PluginHookFunctions<TContext>["transform"], "code" | "id">;
133
+ load: PluginHook<PluginHookFunctions<TContext>["load"], "id">;
134
+ resolveId: PluginHook<PluginHookFunctions<TContext>["resolveId"], "id">;
135
+ };
136
+ type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
137
+ type Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> = Partial<PluginHooks<TContext>> & {
138
+ /**
139
+ * The name of the plugin, for use in deduplication, error messages and logs.
140
+ */
141
+ name: string;
142
+ /**
143
+ * An API object that can be used for inter-plugin communication.
144
+ *
145
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
146
+ */
147
+ api?: Record<string, any>;
148
+ /**
149
+ * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
150
+ *
151
+ * @remarks
152
+ * The Plugin invocation order is as follows:
153
+ * - `enforce: 'pre'` plugins
154
+ * - `order: 'pre'` plugin hooks
155
+ * - any other plugins (normal)
156
+ * - `order: 'post'` plugin hooks
157
+ * - `enforce: 'post'` plugins
158
+ *
159
+ * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
160
+ * @see https://rollupjs.org/plugin-development/#build-hooks
161
+ * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
162
+ * @see https://esbuild.github.io/plugins/#concepts
163
+ */
164
+ enforce?: "pre" | "post";
165
+ /**
166
+ * A function to determine if two plugins are the same and can be de-duplicated.
167
+ *
168
+ * @remarks
169
+ * If this is not provided, plugins are de-duplicated by comparing their names.
170
+ *
171
+ * @param other - The other plugin to compare against.
172
+ * @returns `true` if the two plugins are the same, `false` otherwise.
173
+ */
174
+ dedupe?: false | ((other: Plugin<any>) => boolean);
175
+ /**
176
+ * A list of pre-requisite plugins that must be loaded before this plugin can be used.
177
+ */
178
+ /**
179
+ * Define environments where this plugin should be active. By default, the plugin is active in all environments.
180
+ *
181
+ * @param environment - The environment to check.
182
+ * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
183
+ */
184
+ applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
185
+ /**
186
+ * A function that returns configuration options to be merged with the build context's options.
187
+ *
188
+ * @remarks
189
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
190
+ *
191
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
192
+ *
193
+ * @see https://vitejs.dev/guide/api-plugin#config
194
+ *
195
+ * @param this - The build context.
196
+ * @param config - The partial configuration object to be modified.
197
+ * @returns A promise that resolves to a partial configuration object.
198
+ */
199
+ config?: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>> | (DeepPartial<TContext["config"]> & Record<string, any>);
200
+ } & { [TBuilderVariant in BuilderVariant]?: InferUnpluginOptions<TContext, TBuilderVariant> };
201
+ type PluginHookFields<TContext extends PluginContext = PluginContext> = keyof PluginHookFunctions<TContext>;
202
+ //#endregion
203
+ export { Plugin, PluginHook, PluginHookFields, PluginHookFunctions };
204
+ //# sourceMappingURL=plugin.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../../../core/src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAsCiB,uCACO,mCACA;EAFP;;;EAYD,KAAA,CAAA,EAAA,KAAA,GAAA,MAAA,GAAA,IAAA,GAAA,SAAA;EAAY;;;EAKJ,MAAA,CAAA,EALb,IAKa,CALR,UAKQ,EALI,OAKJ,CAAA;EAGZ;;;EAGR,OAAA,EANO,aAMP;;AAAgD,K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AC7D,QAAQ,YAAY;;;;;;;;;;QAWhB;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA6BoB;;;;;;;;;;qCAcX,wCACA,aAAa;;;;;;;;;;;;;;;WAiBxB,kBAEU,kBAAkB,wBACrB,aAAa,YAAY,sBAAsB,yBAErD,YAAY,sBAAsB;0BAEnB,kBAAkB,qBACpC,UACA;KA8BQ,kCAAkC,gBAAgB,uBACtD,oBAAoB"}
@@ -0,0 +1,70 @@
1
+ import { CompilerOptions, TsConfigJson } from "@stryke/types/tsconfig";
2
+ import ts from "typescript";
3
+
4
+ //#region ../core/src/types/tsconfig.d.ts
5
+ type ReflectionMode = "default" | "explicit" | "never";
6
+ type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
7
+ /**
8
+ * Defines the level of reflection to be used during the transpilation process.
9
+ *
10
+ * @remarks
11
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
12
+ * - `minimal` - Only the essential type information is captured.
13
+ * - `normal` - Additional type information is captured, including some contextual data.
14
+ * - `verbose` - All available type information is captured, including detailed contextual data.
15
+ */
16
+ type ReflectionLevel = "minimal" | "normal" | "verbose";
17
+ interface DeepkitOptions {
18
+ /**
19
+ * Either true to activate reflection for all files compiled using this tsconfig,
20
+ * or a list of globs/file paths relative to this tsconfig.json.
21
+ * Globs/file paths can be prefixed with a ! to exclude them.
22
+ */
23
+ reflection?: RawReflectionMode;
24
+ /**
25
+ * Defines the level of reflection to be used during the transpilation process.
26
+ *
27
+ * @remarks
28
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
29
+ * - `minimal` - Only the essential type information is captured.
30
+ * - `normal` - Additional type information is captured, including some contextual data.
31
+ * - `verbose` - All available type information is captured, including detailed contextual data.
32
+ */
33
+ reflectionLevel?: ReflectionLevel;
34
+ }
35
+ type TSCompilerOptions = CompilerOptions & DeepkitOptions;
36
+ /**
37
+ * The TypeScript compiler configuration.
38
+ *
39
+ * @see https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
40
+ */
41
+ interface TSConfig extends Omit<TsConfigJson, "reflection"> {
42
+ /**
43
+ * Either true to activate reflection for all files compiled using this tsconfig,
44
+ * or a list of globs/file paths relative to this tsconfig.json.
45
+ * Globs/file paths can be prefixed with a ! to exclude them.
46
+ */
47
+ reflection?: RawReflectionMode;
48
+ /**
49
+ * Defines the level of reflection to be used during the transpilation process.
50
+ *
51
+ * @remarks
52
+ * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
53
+ * - `minimal` - Only the essential type information is captured.
54
+ * - `normal` - Additional type information is captured, including some contextual data.
55
+ * - `verbose` - All available type information is captured, including detailed contextual data.
56
+ */
57
+ reflectionLevel?: ReflectionLevel;
58
+ /**
59
+ * Instructs the TypeScript compiler how to compile `.ts` files.
60
+ */
61
+ compilerOptions?: TSCompilerOptions;
62
+ }
63
+ type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
64
+ originalTsconfigJson: TsConfigJson;
65
+ tsconfigJson: TSConfig;
66
+ tsconfigFilePath: string;
67
+ };
68
+ //#endregion
69
+ export { ParsedTypeScriptConfig, TSConfig };
70
+ //# sourceMappingURL=tsconfig.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig.d.cts","names":[],"sources":["../../../../../core/src/types/tsconfig.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,cAAA;KACA,iBAAA,GACR;AAFJ;AACA;AAiBA;AAEA;AAoBA;AAOA;;;;AAsBoB,KAnDR,eAAA,GAmDQ,SAAA,GAAA,QAAA,GAAA,SAAA;AAtBc,UA3BjB,cAAA,CA2BiB;EAAI;AAyBtC;;;;EAEwB,UAAA,CAAA,EAhDT,iBAgDS;;;;;;;;;;oBArCJ;;KAGR,iBAAA,GAAoB,kBAAkB;;;;;;UAOjC,QAAA,SAAiB,KAAK;;;;;;eAMxB;;;;;;;;;;oBAWK;;;;oBAKA;;KAGR,sBAAA,GAAyB,EAAA,CAAG;wBAChB;gBACR"}
@@ -0,0 +1,24 @@
1
+ import { PluginHook } from "./plugin.cjs";
2
+ import { Context } from "./context.cjs";
3
+ import { API } from "./api.cjs";
4
+ import { MaybePromise } from "@stryke/types/base";
5
+ import { HookFilter, UnpluginOptions } from "unplugin";
6
+
7
+ //#region ../core/src/types/unplugin.d.ts
8
+ type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
9
+ type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
10
+ type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
11
+ interface UnpluginOptions$1<TContext extends Context = Context> extends UnpluginOptions {
12
+ /**
13
+ * An API object that can be used for inter-plugin communication.
14
+ *
15
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
16
+ */
17
+ api: API<TContext["config"]>;
18
+ }
19
+ type InferUnpluginOptions<TContext extends Context = Context, TBuilderVariant extends BuilderVariant = BuilderVariant, TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> = InferUnpluginVariant<TBuilderVariant>> = { [TKey in keyof Required<UnpluginOptions$1<TContext>>[TUnpluginVariant]]?: Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] extends infer THandler | {
20
+ handler: infer THandler;
21
+ } ? THandler extends ((this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn) ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] };
22
+ //#endregion
23
+ export { BuilderVariant, InferUnpluginOptions, UnpluginBuilderVariant };
24
+ //# sourceMappingURL=unplugin.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unplugin.d.cts","names":[],"sources":["../../../../../core/src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AA,GAoCvB,QApCuB,CAoCd,iBApCc,CAoCE,QApCF,CAAA,CAAA,CAoCa,gBApCb,CAAA,CAoC+B,IApC/B,CAAA,EAS7B"}
@@ -0,0 +1,35 @@
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");
5
+
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;
@@ -0,0 +1,20 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-utils.d.cts","names":[],"sources":["../../src/helpers/ast-utils.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA;;;;;AAkBY,iBAlBI,QAAA,CAkBkB,IAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAhB1B,aAgB0B,CAAA,EAf/B,WAe+B,CAfnB,CAAA,CAAE,IAeiB,CAAA;AAAG,KAAzB,sBAAA,GAAyB,gBAAA,GACnC,QADmC,CAC1B,IAD0B,CACrB,gBADqB,EAAA,gBAAA,GAAA,UAAA,CAAA,CAAA;AACrB,iBAEA,eAAA,CAFA,GAAA,EAGT,CAAA,CAAE,IAHO,EAAA,IAAA,CAAA,EAIP,sBAJO,CAAA,EAKb,iBALa;AAAd,yCAAA,GAAA,EAAA"}
@@ -0,0 +1,41 @@
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");
7
+
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;
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-plugin.d.cts","names":[],"sources":["../../src/helpers/create-plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;AAmCA;;;;;AAKuC,iBALvB,iBAKuB,CAAA,iBAJpB,OAIoB,GAJV,OAIU,EAAA,iBAHpB,MAGoB,CAAA,MAAA,EAAA,GAAA,CAAA,GAHE,MAGF,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAA5B,2BAA4B,CAAA,QAAA,EAAU,QAAV,CAAA,CAAA,EACpC,iCADoC,CACF,QADE,EACQ,QADR,CAAA"}
@@ -0,0 +1,59 @@
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");
5
+
6
+ //#region src/helpers/filters.ts
7
+ function getPluginName(plugin) {
8
+ return (0, __stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
9
+ }
10
+ /**
11
+ * Check if a Babel plugin is a duplicate of another plugin in the list.
12
+ *
13
+ * @param plugins - The list of existing Babel plugins.
14
+ * @param plugin - The Babel plugin to check for duplicates.
15
+ * @returns True if the plugin is a duplicate, false otherwise.
16
+ */
17
+ function isDuplicatePlugin(plugins, plugin) {
18
+ return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
19
+ }
20
+ /**
21
+ * Filters a Babel plugin by its runtime ID.
22
+ *
23
+ * @param context - The context in which the filter is applied.
24
+ * @param fileId - The file ID to filter by.
25
+ * @returns A filter function that checks if a plugin's ID matches the runtime ID.
26
+ */
27
+ function filterPluginByFileId(context, fileId) {
28
+ return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id] && 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;
@@ -0,0 +1,43 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.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"}
@@ -0,0 +1,22 @@
1
+ const require_helpers_filters = require('./filters.cjs');
2
+ const require_helpers_options = require('./options.cjs');
3
+ const require_helpers_ast_utils = require('./ast-utils.cjs');
4
+ const require_helpers_create_plugin = require('./create-plugin.cjs');
5
+ const require_helpers_module_helpers = require('./module-helpers.cjs');
6
+
7
+ exports.addImport = require_helpers_module_helpers.addImport;
8
+ exports.addImportsToProgram = require_helpers_module_helpers.addImportsToProgram;
9
+ exports.addPluginFilter = require_helpers_filters.addPluginFilter;
10
+ exports.createBabelPlugin = require_helpers_create_plugin.createBabelPlugin;
11
+ exports.filterPluginByFileId = require_helpers_filters.filterPluginByFileId;
12
+ exports.findExport = require_helpers_module_helpers.findExport;
13
+ exports.generateFromAst = require_helpers_ast_utils.generateFromAst;
14
+ exports.getImport = require_helpers_module_helpers.getImport;
15
+ exports.getPluginName = require_helpers_filters.getPluginName;
16
+ exports.isDuplicatePlugin = require_helpers_filters.isDuplicatePlugin;
17
+ exports.isImportCall = require_helpers_module_helpers.isImportCall;
18
+ exports.listExports = require_helpers_module_helpers.listExports;
19
+ exports.listImports = require_helpers_module_helpers.listImports;
20
+ exports.parseAst = require_helpers_ast_utils.parseAst;
21
+ exports.resolveBabelPlugin = require_helpers_options.resolveBabelPlugin;
22
+ exports.resolvePluginFunction = require_helpers_options.resolvePluginFunction;
@@ -0,0 +1,6 @@
1
+ import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./ast-utils.cjs";
2
+ import { createBabelPlugin } from "./create-plugin.cjs";
3
+ import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./filters.cjs";
4
+ import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./module-helpers.cjs";
5
+ import { resolveBabelPlugin, resolvePluginFunction } from "./options.cjs";
6
+ export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };