@rsbuild/plugin-assets-retry 1.2.3 → 1.4.0

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.
package/dist/types.d.ts DELETED
@@ -1,72 +0,0 @@
1
- import type { CrossOrigin } from '@rsbuild/core';
2
- export type PluginAssetsRetryOptions = {
3
- /**
4
- * The maximum number of retries for a single asset.
5
- * @default 3
6
- */
7
- max?: number;
8
- /**
9
- * Used to specify the HTML tag types that need to be retried.
10
- * @default ['script', 'link', 'img']
11
- */
12
- type?: string[];
13
- /**
14
- * The test function of the asset to be retried.
15
- */
16
- test?: string | ((url: string) => boolean);
17
- /**
18
- * Specifies the retry domain when assets fail to load.
19
- */
20
- domain?: string[];
21
- /**
22
- * Set the `crossorigin` attribute for tags.
23
- * @default config.html.crossorigin
24
- */
25
- crossOrigin?: boolean | CrossOrigin;
26
- /**
27
- * The callback function when the asset is failed to be retried.
28
- */
29
- onFail?: (context: AssetsRetryHookContext) => void;
30
- /**
31
- * The callback function when the asset is being retried.
32
- */
33
- onRetry?: (context: AssetsRetryHookContext) => void;
34
- /**
35
- * The callback function when the asset is successfully retried.
36
- */
37
- onSuccess?: (context: AssetsRetryHookContext) => void;
38
- /**
39
- * The function to add query parameters to the URL of the asset being retried.
40
- * @param times e.g: 1 -> 2 -> 3
41
- * @param originalQuery initial request url's query e.g: <script src="https://cdn.com/a.js?version=1"></script> -> "?version=1"
42
- * @default false
43
- * @description true -> hasQuery(originalQuery) ? `${getQuery(originalQuery)}&retry=${existRetryTimes}` : `?retry=${existRetryTimes}`
44
- */
45
- addQuery?: boolean | ((context: {
46
- times: number;
47
- originalQuery: string;
48
- }) => string);
49
- /**
50
- * Whether to inline the runtime JavaScript code of Assets Retry plugin into the HTML file.
51
- * @default true
52
- */
53
- inlineScript?: boolean;
54
- /**
55
- * Whether to minify the runtime JavaScript code of Assets Retry plugin.
56
- * @default rsbuildConfig.mode === 'production'
57
- */
58
- minify?: boolean;
59
- /**
60
- * The delay time between retries. Unit: ms
61
- * @default 0
62
- */
63
- delay?: number | ((context: AssetsRetryHookContext) => number);
64
- };
65
- export type RuntimeRetryOptions = Omit<PluginAssetsRetryOptions, 'inlineScript' | 'minify'>;
66
- export type AssetsRetryHookContext = {
67
- url: string;
68
- times: number;
69
- domain: string;
70
- tagName: string;
71
- isAsyncChunk: boolean;
72
- };