import { type CustomTransform } from '@apm-js-collab/code-transformer';
import { type AnyInstrumentationConfig } from './instrumentation-serde.js';
/**
 * The per-rule options a loader reads from `this.getOptions()`. Every field is
 * optional here because {@link createLoader} can supply it instead; the
 * loader still needs `instrumentations` from one of the two sources.
 *
 * Turbopack requires loader options to be JSON-serializable, so any `RegExp`
 * in `module.filePath` must be passed in its serialized `{ source, flags }`
 * form there — see `serializeInstrumentations` in the `/core` export.
 */
export interface LoaderOptions {
    /** Array of instrumentation configurations */
    instrumentations?: AnyInstrumentationConfig[];
    /** Optional path to a polyfill module for diagnostics_channel */
    dcModule?: string;
    /**
     * Custom transforms registered on the matcher via orchestrion's
     * `addTransform`. An `InstrumentationConfig` opts in by naming one of these
     * in its `transform` field.
     *
     * Webpack passes loader options through by reference, so functions arrive
     * intact. Turbopack does not — it serializes them as JSON — and neither do
     * loaders that run in worker processes, such as `thread-loader`. For those,
     * bind the transforms with {@link createLoader} instead.
     */
    customTransforms?: Record<string, CustomTransform>;
}
/**
 * Baked-in configuration for a loader built with {@link createLoader}. These
 * values live in the loader module's own scope, so unlike per-rule loader
 * options they never cross a serialization boundary.
 *
 * Per-rule options take precedence over `instrumentations` and `dcModule`
 * given here, and per-rule `customTransforms` are merged over these.
 */
export interface CreateLoaderOptions extends LoaderOptions {
}
/** A webpack-compatible loader function, as returned by {@link createLoader}. */
export type CodeTransformerLoader = (this: any, code: string, inputSourceMap?: any) => void;
/**
 * Builds a webpack loader that instruments JavaScript code using
 * code-transformer.
 *
 * Use this to wrap the loader in your own package when loader options are not
 * a viable channel for custom transforms — under Turbopack, which serializes
 * them as JSON, or with worker-based loaders such as `thread-loader`:
 *
 * ```js
 * // my-library/loader.cjs
 * const { createLoader } = require('@apm-js-collab/code-transformer-bundler-plugins/webpack-loader-factory');
 * module.exports = createLoader({ customTransforms: { injectIntegration } });
 * ```
 *
 * Webpack resolves that module by path, so the transform stays in the loader
 * process and only the JSON-serializable `instrumentations` cross into the
 * loader options.
 *
 * The plain `/webpack-loader` export is `createLoader()` with no baked-in
 * configuration; the webpack plugin passes `customTransforms` to it directly.
 */
export declare function createLoader(factoryOptions?: CreateLoaderOptions): CodeTransformerLoader;
export type { CustomTransform } from '@apm-js-collab/code-transformer';
export type { AnyInstrumentationConfig } from './instrumentation-serde.js';
