import type { CrossOrigin as CrossOrigin_2 } from '@rsbuild/core'; import type { RsbuildPlugin } from '@rsbuild/core'; export declare const ASSETS_RETRY_DATA_ATTRIBUTE = "data-rsbuild-assets-retry"; declare type AssetsRetryHookContext_2 = { url: string; times: number; domain: string; tagName: string; isAsyncChunk: boolean; }; declare type CompileTimeRetryOptions = { /** * Whether to inline the runtime JavaScript code of Assets Retry plugin into the HTML file. * @default true */ inlineScript?: boolean; /** * Whether to minify the runtime JavaScript code of Assets Retry plugin. * @default rsbuildConfig.mode === 'production' */ minify?: boolean; }; export declare const PLUGIN_ASSETS_RETRY_NAME = "rsbuild:assets-retry"; export declare const pluginAssetsRetry: (userOptions?: PluginAssetsRetryOptions) => RsbuildPlugin; export declare type PluginAssetsRetryOptions = (RuntimeRetryOptions & CompileTimeRetryOptions) | ({ rules: RuntimeRetryOptions[]; } & CompileTimeRetryOptions); declare type RuntimeRetryOptions = RuntimeRetryOptionsWithDefaultValue & RuntimeRetryOptionsWithoutDefaultValue; declare type RuntimeRetryOptionsWithDefaultValue = { /** * The maximum number of retries for a single asset. * @default 3 */ max?: number; /** * Used to specify the HTML tag types that need to be retried. * @default ['script', 'link', 'img'] */ type?: string[]; /** * Specifies the retry domain when assets fail to load. * @default [] */ domain?: string[]; /** * Set the `crossorigin` attribute for tags. * @default rsbuildConfig.html.crossorigin */ crossOrigin?: boolean | CrossOrigin_2; /** * The delay time between retries. Unit: ms * @default 0 */ delay?: number | ((context: AssetsRetryHookContext_2) => number); /** * The function to add query parameters to the URL of the asset being retried. * @param times e.g: 1 -> 2 -> 3 * @param originalQuery initial request url's query e.g: -> "?version=1" * @default false * @description * * if set to `true`, `?retry=${times}` will be added to the url. * * ```ts * ({ times, originalQuery }) => hasQuery(originalQuery) ? `${getQuery(originalQuery)}&retry=${times}` : `?retry=${times}` * ``` */ addQuery?: boolean | ((context: { times: number; originalQuery: string; }) => string); }; declare type RuntimeRetryOptionsWithoutDefaultValue = { /** * The test function of the asset to be retried. */ test?: string | RegExp | ((url: string) => boolean); /** * The callback function when the asset is failed to be retried. */ onFail?: (context: AssetsRetryHookContext_2) => void; /** * The callback function when the asset is being retried. */ onRetry?: (context: AssetsRetryHookContext_2) => void; /** * The callback function when the asset is successfully retried. */ onSuccess?: (context: AssetsRetryHookContext_2) => void; }; export { }