@rsbuild/plugin-assets-retry 1.5.1 → 1.5.2
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/index.cjs +9 -9
- package/dist/index.js +9 -38
- package/dist/rslib-runtime.js +38 -0
- package/dist/runtime/asyncChunkRetry.js +4 -4
- package/dist/runtime/asyncChunkRetry.min.js +1 -1
- package/dist/runtime/initialChunkRetry.js +6 -6
- package/dist/runtime/initialChunkRetry.min.js +1 -1
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
2
|
-
return
|
|
2
|
+
return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
}();
|
|
4
4
|
var __webpack_modules__ = {
|
|
5
|
-
"./node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js"
|
|
5
|
+
"./node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
6
6
|
module.exports = __webpack_require__("crypto").randomBytes;
|
|
7
7
|
},
|
|
8
|
-
"./node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js"
|
|
8
|
+
"./node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
9
9
|
"use strict";
|
|
10
10
|
var randomBytes = __webpack_require__("./node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js");
|
|
11
11
|
var UID_LENGTH = 16;
|
|
@@ -119,7 +119,7 @@ var __webpack_modules__ = {
|
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
121
|
},
|
|
122
|
-
crypto
|
|
122
|
+
crypto (module) {
|
|
123
123
|
"use strict";
|
|
124
124
|
module.exports = require("crypto");
|
|
125
125
|
}
|
|
@@ -156,7 +156,7 @@ function __webpack_require__(moduleId) {
|
|
|
156
156
|
})();
|
|
157
157
|
(()=>{
|
|
158
158
|
__webpack_require__.r = (exports1)=>{
|
|
159
|
-
if (
|
|
159
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
160
160
|
value: 'Module'
|
|
161
161
|
});
|
|
162
162
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -226,7 +226,7 @@ var __webpack_exports__ = {};
|
|
|
226
226
|
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
227
227
|
const isRspack = this.isRspack;
|
|
228
228
|
compilation.hooks.runtimeModule.tap(this.name, (module)=>{
|
|
229
|
-
const constructorName =
|
|
229
|
+
const constructorName = module.constructorName || module.constructor?.name;
|
|
230
230
|
const isCssLoadingRuntimeModule = 'CssLoadingRuntimeModule' === constructorName;
|
|
231
231
|
if (isCssLoadingRuntimeModule) return void modifyRuntimeModule(module, (originSource)=>originSource.replace('var fullhref = __webpack_require__.p + href;', 'var fullhref = __webpack_require__.rbLoadStyleSheet ? __webpack_require__.rbLoadStyleSheet(href, chunkId) : (__webpack_require__.p + href);'), isRspack);
|
|
232
232
|
const isPublicPathModule = 'publicPath' === module.name || 'PublicPathRuntimeModule' === constructorName || 'AutoPublicPathRuntimeModule' === constructorName;
|
|
@@ -297,7 +297,7 @@ var __webpack_exports__ = {};
|
|
|
297
297
|
const { inlineScript = true } = userOptions;
|
|
298
298
|
const getScriptPath = (environment)=>{
|
|
299
299
|
const distDir = environment.config.output.distPath.js;
|
|
300
|
-
return external_node_path_default().posix.join(distDir, "assets-retry.1-5-
|
|
300
|
+
return external_node_path_default().posix.join(distDir, "assets-retry.1-5-2.js");
|
|
301
301
|
};
|
|
302
302
|
const getDefaultValueFromRsbuildConfig = (config)=>{
|
|
303
303
|
const minify = 'boolean' == typeof config.output.minify ? config.output.minify : config.output.minify?.js;
|
|
@@ -371,11 +371,11 @@ var __webpack_exports__ = {};
|
|
|
371
371
|
exports.ASSETS_RETRY_DATA_ATTRIBUTE = __webpack_exports__.ASSETS_RETRY_DATA_ATTRIBUTE;
|
|
372
372
|
exports.PLUGIN_ASSETS_RETRY_NAME = __webpack_exports__.PLUGIN_ASSETS_RETRY_NAME;
|
|
373
373
|
exports.pluginAssetsRetry = __webpack_exports__.pluginAssetsRetry;
|
|
374
|
-
for(var
|
|
374
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
375
375
|
"ASSETS_RETRY_DATA_ATTRIBUTE",
|
|
376
376
|
"PLUGIN_ASSETS_RETRY_NAME",
|
|
377
377
|
"pluginAssetsRetry"
|
|
378
|
-
].indexOf(
|
|
378
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
379
379
|
Object.defineProperty(exports, '__esModule', {
|
|
380
380
|
value: true
|
|
381
381
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as __rspack_external_crypto from "crypto";
|
|
2
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
3
|
import node_fs from "node:fs";
|
|
3
4
|
import node_path from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
import { ensureAssetPrefix, logger, rspack } from "@rsbuild/core";
|
|
6
|
-
|
|
7
|
-
"./node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js"
|
|
7
|
+
__webpack_require__.add({
|
|
8
|
+
"./node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
8
9
|
module.exports = __webpack_require__("crypto").randomBytes;
|
|
9
10
|
},
|
|
10
|
-
"./node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js"
|
|
11
|
+
"./node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
11
12
|
var randomBytes = __webpack_require__("./node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js");
|
|
12
13
|
var UID_LENGTH = 16;
|
|
13
14
|
var UID = generateUID();
|
|
@@ -120,41 +121,11 @@ var __webpack_modules__ = {
|
|
|
120
121
|
});
|
|
121
122
|
};
|
|
122
123
|
},
|
|
123
|
-
crypto
|
|
124
|
+
crypto (module) {
|
|
124
125
|
module.exports = __rspack_external_crypto;
|
|
125
126
|
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
function __webpack_require__(moduleId) {
|
|
129
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
130
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
131
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
132
|
-
exports: {}
|
|
133
|
-
};
|
|
134
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
135
|
-
return module.exports;
|
|
136
|
-
}
|
|
137
|
-
(()=>{
|
|
138
|
-
__webpack_require__.n = (module)=>{
|
|
139
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
140
|
-
__webpack_require__.d(getter, {
|
|
141
|
-
a: getter
|
|
142
|
-
});
|
|
143
|
-
return getter;
|
|
144
|
-
};
|
|
145
|
-
})();
|
|
146
|
-
(()=>{
|
|
147
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
148
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
get: definition[key]
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
})();
|
|
154
|
-
(()=>{
|
|
155
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
156
|
-
})();
|
|
157
|
-
var serialize_javascript = __webpack_require__("./node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js");
|
|
127
|
+
});
|
|
128
|
+
const serialize_javascript = __webpack_require__("./node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js");
|
|
158
129
|
var serialize_javascript_default = /*#__PURE__*/ __webpack_require__.n(serialize_javascript);
|
|
159
130
|
function _define_property(obj, key, value) {
|
|
160
131
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -201,7 +172,7 @@ class AsyncChunkRetryPlugin {
|
|
|
201
172
|
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
202
173
|
const isRspack = this.isRspack;
|
|
203
174
|
compilation.hooks.runtimeModule.tap(this.name, (module)=>{
|
|
204
|
-
const constructorName =
|
|
175
|
+
const constructorName = module.constructorName || module.constructor?.name;
|
|
205
176
|
const isCssLoadingRuntimeModule = 'CssLoadingRuntimeModule' === constructorName;
|
|
206
177
|
if (isCssLoadingRuntimeModule) return void modifyRuntimeModule(module, (originSource)=>originSource.replace('var fullhref = __webpack_require__.p + href;', 'var fullhref = __webpack_require__.rbLoadStyleSheet ? __webpack_require__.rbLoadStyleSheet(href, chunkId) : (__webpack_require__.p + href);'), isRspack);
|
|
207
178
|
const isPublicPathModule = 'publicPath' === module.name || 'PublicPathRuntimeModule' === constructorName || 'AutoPublicPathRuntimeModule' === constructorName;
|
|
@@ -272,7 +243,7 @@ const pluginAssetsRetry = (userOptions = {})=>({
|
|
|
272
243
|
const { inlineScript = true } = userOptions;
|
|
273
244
|
const getScriptPath = (environment)=>{
|
|
274
245
|
const distDir = environment.config.output.distPath.js;
|
|
275
|
-
return node_path.posix.join(distDir, "assets-retry.1-5-
|
|
246
|
+
return node_path.posix.join(distDir, "assets-retry.1-5-2.js");
|
|
276
247
|
};
|
|
277
248
|
const getDefaultValueFromRsbuildConfig = (config)=>{
|
|
278
249
|
const minify = 'boolean' == typeof config.output.minify ? config.output.minify : config.output.minify?.js;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __webpack_modules__ = {};
|
|
2
|
+
var __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
+
return module.exports;
|
|
11
|
+
}
|
|
12
|
+
__webpack_require__.m = __webpack_modules__;
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.add = function(modules) {
|
|
15
|
+
Object.assign(__webpack_require__.m, modules);
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.n = (module)=>{
|
|
20
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
21
|
+
__webpack_require__.d(getter, {
|
|
22
|
+
a: getter
|
|
23
|
+
});
|
|
24
|
+
return getter;
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
29
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: definition[key]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
37
|
+
})();
|
|
38
|
+
export { __webpack_require__ };
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
return cleanUrl(currRetryUrl.replace(domain, nextDomain)) + getUrlRetryQuery(existRetryTimes + 1, originalQuery, config);
|
|
36
36
|
}
|
|
37
37
|
function _instanceof(left, right) {
|
|
38
|
-
if (null != right && "
|
|
38
|
+
if (null != right && "u" > typeof Symbol && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);
|
|
39
39
|
return left instanceof right;
|
|
40
40
|
}
|
|
41
41
|
function findMatchingRule(url, type, rules) {
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
try {
|
|
136
136
|
var originalScriptFilename = originalGetChunkScriptFilename(chunkId);
|
|
137
137
|
var originalCssFilename = originalGetCssFilename(chunkId);
|
|
138
|
-
if (
|
|
138
|
+
if ("u" > typeof window) {
|
|
139
139
|
if (originalScriptFilename) window.__RB_ASYNC_CHUNKS__[originalScriptFilename] = true;
|
|
140
140
|
if (originalCssFilename) window.__RB_ASYNC_CHUNKS__[originalCssFilename] = true;
|
|
141
141
|
}
|
|
@@ -211,8 +211,8 @@
|
|
|
211
211
|
return retry && retry.nextRetryUrl || __RUNTIME_GLOBALS_PUBLIC_PATH__ + href;
|
|
212
212
|
}
|
|
213
213
|
function registerAsyncChunkRetry() {
|
|
214
|
-
if (
|
|
215
|
-
if (
|
|
214
|
+
if ("u" > typeof window && !window.__RB_ASYNC_CHUNKS__) window.__RB_ASYNC_CHUNKS__ = {};
|
|
215
|
+
if ("u" > typeof __RUNTIME_GLOBALS_REQUIRE__) try {
|
|
216
216
|
__RUNTIME_GLOBALS_ENSURE_CHUNK__ = ensureChunk;
|
|
217
217
|
__RUNTIME_GLOBALS_LOAD_SCRIPT__ = loadScript;
|
|
218
218
|
__RUNTIME_GLOBALS_RSBUILD_LOAD_STYLESHEET__ = loadStyleSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var n="[@rsbuild/plugin-assets-retry] ";function
|
|
1
|
+
!function(){"use strict";var n="[@rsbuild/plugin-assets-retry] ";function r(n,r){for(var e=r.domain,t=0;t<e.length;t++){var i=e[t];if(-1!==n.indexOf(i))return i}return window.origin}var e=/[?#].*$/;function t(n,r,t,i,o,_){var a;return n.replace(r,t).replace(e,"")+(a=i+1,!0===_.addQuery?""!==o?"".concat(o,"&retry=").concat(a):"?retry=".concat(a):"function"==typeof _.addQuery?_.addQuery({times:a,originalQuery:o}):"")}var i=__RETRY_OPTIONS__,o={},_={},a={},l={},u=__RUNTIME_GLOBALS_ENSURE_CHUNK__,c=__RUNTIME_GLOBALS_GET_CHUNK_SCRIPT_FILENAME__,s=__RUNTIME_GLOBALS_GET_MINI_CSS_EXTRACT_FILENAME__||__RUNTIME_GLOBALS_GET_CSS_FILENAME__||function(){return null},f=__RUNTIME_GLOBALS_LOAD_SCRIPT__;function y(e){var f=Array.prototype.slice.call(arguments);f[10]||(f[10]={count:0,cssFailedCount:0});var S=f[10],d=u.apply(null,f);try{var p=c(e),R=s(e);"u">typeof window&&(p&&(window.__RB_ASYNC_CHUNKS__[p]=!0),R&&(window.__RB_ASYNC_CHUNKS__[R]=!0))}catch(r){console.error(n,"get original script or CSS filename error",r)}return S&&"number"==typeof S.count&&"number"==typeof S.cssFailedCount?(S.count+=1,d.catch(function(u){var d,p,R,m,E,U,g=S.count-1,v=S.cssFailedCount,L=!!(null==u||null==(d=u.message)?void 0:d.includes("CSS chunk"));L&&(S.cssFailedCount+=1);var N=L?v:g-v;try{var A=function(n,e,u){var f,y,S,d=u?null==(f=_[n])?void 0:f[e]:null==(y=o[n])?void 0:y[e],p=e+1;if(0===e||void 0===d){if(!(S=function(n,e){var o,_=e?s(n):c(n);if(!_)throw Error("only support cssExtract");var a=__RUNTIME_GLOBALS_PUBLIC_PATH__,l="/"===a[0]&&"/"!==a[1]?window.origin+a+_:a+_,u=(o=l.split("?")[1])?"?".concat(o.split("#")[0]):"",f=function(n,e,t){for(var i=0;i<t.length;i++){var o,_=t[i],a=_.test,l=!0;if((null!=(o=RegExp)&&"u">typeof Symbol&&o[Symbol.hasInstance]?!!o[Symbol.hasInstance](a):a instanceof o)?l=a.test(n):"string"==typeof a?l=new RegExp(a).test(n):"function"==typeof a&&(l=a(n)),_.domain&&_.domain.length>0){var u=r(n,_);_.domain.includes(u)||(l=!1)}if(_.type&&_.type.length>0&&!_.type.includes(e)&&(l=!1),l)return _}return null}(l,e?"link":"script",i);if(!f)return null;var y=r(l,f);return{nextDomain:y,nextRetryUrl:t(l,y,y,0,u,f),originalScriptFilename:_,originalSrcUrl:l,originalQuery:u,rule:f}}(n,u)))return null;u?_[n]=[]:o[n]=[]}else{var R,m,E,U,g=d.originalScriptFilename,v=d.originalSrcUrl,L=d.originalQuery,N=d.rule,A=(R=d.nextDomain,m=N.domain,E=r(R,N),-1===(U=m.indexOf(E))?E:m[(U+1)%m.length]);S={nextDomain:A,nextRetryUrl:t(d.nextRetryUrl,d.nextDomain,A,e,L,N),originalScriptFilename:g,originalSrcUrl:v,originalQuery:L,rule:N}}return u?(_[n][p]=S,l[n]=S):(o[n][p]=S,a[n]=S),S}(e,N,L);if(!A)throw u;p=A.originalScriptFilename,R=A.nextRetryUrl,m=A.nextDomain,E=A.rule}catch(r){throw r!==u&&console.error(n,"failed to get nextRetryUrl",r),u}var C=function(n){return{times:n,domain:m,url:R,tagName:L?"link":"script",isAsyncChunk:!0}},I=C(N);if(N>=E.max)throw u.message=(null==(U=u.message)?void 0:U.includes("retries:"))?u.message:"Loading chunk ".concat(e,' from "').concat(p,'" failed after ').concat(E.max,' retries: "').concat(u.message,'"'),"function"==typeof E.onFail&&E.onFail(I),u;"function"==typeof E.onRetry&&E.onRetry(I);var T="function"==typeof E.delay?E.delay(I):E.delay;return(T>0?new Promise(function(n){return setTimeout(n,T)}):Promise.resolve()).then(function(){return y.apply(y,f)}).then(function(n){var r=(null==S?void 0:S.count)===g+2;if("function"==typeof E.onSuccess&&r){var e=C(N+1);E.onSuccess(e)}return n})})):d}if("u">typeof window&&!window.__RB_ASYNC_CHUNKS__&&(window.__RB_ASYNC_CHUNKS__={}),"u">typeof __RUNTIME_GLOBALS_REQUIRE__)try{__RUNTIME_GLOBALS_ENSURE_CHUNK__=y,__RUNTIME_GLOBALS_LOAD_SCRIPT__=function(){var n=Array.prototype.slice.call(arguments),r=a[n[3]];return r&&(n[0]=r.nextRetryUrl),f.apply(null,n)},__RUNTIME_GLOBALS_RSBUILD_LOAD_STYLESHEET__=function(n,r){var e=l[r];return e&&e.nextRetryUrl||__RUNTIME_GLOBALS_PUBLIC_PATH__+n}}catch(r){console.error(n,"Register async chunk retry runtime failed",r)}}();
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
return cleanUrl(currRetryUrl.replace(domain, nextDomain)) + getUrlRetryQuery(existRetryTimes + 1, originalQuery, config);
|
|
36
36
|
}
|
|
37
37
|
function _instanceof(left, right) {
|
|
38
|
-
if (null != right && "
|
|
38
|
+
if (null != right && "u" > typeof Symbol && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);
|
|
39
39
|
return left instanceof right;
|
|
40
40
|
}
|
|
41
41
|
function findMatchingRule(url, type, rules) {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
62
|
function initialChunkRetry_instanceof(left, right) {
|
|
63
|
-
if (null != right && "
|
|
63
|
+
if (null != right && "u" > typeof Symbol && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);
|
|
64
64
|
return left instanceof right;
|
|
65
65
|
}
|
|
66
66
|
var TAG_TYPE = {
|
|
@@ -126,10 +126,11 @@
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
function retry(rules, e) {
|
|
129
|
+
var _target_dataset_rbOriginalQuery;
|
|
129
130
|
var targetInfo = validateTargetInfo(rules, e);
|
|
130
131
|
if (false === targetInfo) return;
|
|
131
132
|
var target = targetInfo.target, tagName = targetInfo.tagName, url = targetInfo.url, rule = targetInfo.rule, ruleIndex = targetInfo.ruleIndex;
|
|
132
|
-
if (
|
|
133
|
+
if ("u" > typeof window && Object.keys(window.__RB_ASYNC_CHUNKS__ || {}).some(function(chunkName) {
|
|
133
134
|
return -1 !== url.indexOf(chunkName);
|
|
134
135
|
})) return;
|
|
135
136
|
var domain = findCurrentDomain(url, rule);
|
|
@@ -148,7 +149,6 @@
|
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
151
|
var nextDomain = findNextDomain(domain, rule);
|
|
151
|
-
var _target_dataset_rbOriginalQuery;
|
|
152
152
|
var originalQuery = null != (_target_dataset_rbOriginalQuery = target.dataset.rbOriginalQuery) ? _target_dataset_rbOriginalQuery : getQueryFromUrl(url);
|
|
153
153
|
var isAsync = Boolean(target.dataset.rbAsync) || target.async || target.defer;
|
|
154
154
|
var attributes = {
|
|
@@ -193,10 +193,10 @@
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
function registerInitialChunkRetry() {
|
|
196
|
-
if (
|
|
196
|
+
if ("u" > typeof window && !window.__RB_ASYNC_CHUNKS__) window.__RB_ASYNC_CHUNKS__ = {};
|
|
197
197
|
try {
|
|
198
198
|
var config = __RETRY_OPTIONS__;
|
|
199
|
-
if (
|
|
199
|
+
if ("u" > typeof window && void 0 !== window.document) {
|
|
200
200
|
document.addEventListener('error', function(e) {
|
|
201
201
|
if (e && initialChunkRetry_instanceof(e.target, Element)) try {
|
|
202
202
|
retry(config, e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function e(e,r){for(var
|
|
1
|
+
!function(){"use strict";function e(e,r){for(var t=r.domain,n=0;n<t.length;n++){var i=t[n];if(-1!==e.indexOf(i))return i}return window.origin}var r=/[?#].*$/;function t(e,r){return null!=r&&"u">typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}var n={link:HTMLLinkElement,script:HTMLScriptElement,img:HTMLImageElement};function i(r,i){var a=i.target,o=a.tagName.toLocaleLowerCase(),s=t(a,HTMLScriptElement)||t(a,HTMLImageElement)?a.src:t(a,HTMLLinkElement)?a.href:null;if(!s)return!1;var u=Number(a.dataset.rbRuleI||"-1"),l=r[u]||function(r,t,n){for(var i=0;i<n.length;i++){var a,o=n[i],s=o.test,u=!0;if((null!=(a=RegExp)&&"u">typeof Symbol&&a[Symbol.hasInstance]?!!a[Symbol.hasInstance](s):s instanceof a)?u=s.test(r):"string"==typeof s?u=new RegExp(s).test(r):"function"==typeof s&&(u=s(r)),o.domain&&o.domain.length>0){var l=e(r,o);o.domain.includes(l)||(u=!1)}if(o.type&&o.type.length>0&&!o.type.includes(t)&&(u=!1),u)return o}return null}(s,o,r);if(!l)return!1;u=r.indexOf(l);var c=l.type;return!!o&&-1!==c.indexOf(o)&&!!n[o]&&!!t(a,n[o])&&{target:a,tagName:o,url:s,rule:l,ruleIndex:u}}function a(e,r,n){t(e,HTMLScriptElement)&&(n.isAsync?document.body.appendChild(r):console.warn("[@rsbuild/plugin-assets-retry] ","load sync script failed, for security only async/defer script can be retried",e)),t(e,HTMLLinkElement)&&document.getElementsByTagName("head")[0].appendChild(r),t(e,HTMLImageElement)&&(e.src=n.url,e.dataset.rbRetryTimes=n.times+"",e.dataset.rbOriginalQuery=n.originalQuery+"")}"u">typeof window&&!window.__RB_ASYNC_CHUNKS__&&(window.__RB_ASYNC_CHUNKS__={});try{var o=__RETRY_OPTIONS__;"u">typeof window&&void 0!==window.document&&(document.addEventListener("error",function(n){if(n&&t(n.target,Element))try{!function(n,o){var s,u=i(n,o);if(!1!==u){var l=u.target,c=u.tagName,d=u.url,m=u.rule,y=u.ruleIndex;if(!("u">typeof window&&Object.keys(window.__RB_ASYNC_CHUNKS__||{}).some(function(e){return -1!==d.indexOf(e)}))){var f,g,p,b,v,_=e(d,m),h=Number(l.dataset.rbRetryTimes)||0;if(h===m.max){"function"==typeof m.onFail&&m.onFail({times:h,domain:_,url:d,tagName:c,isAsyncChunk:!1});return}var E=(g=m.domain,p=e(_,m),-1===(b=g.indexOf(p))?p:g[(b+1)%g.length]),T=null!=(s=l.dataset.rbOriginalQuery)?s:(v=d.split("?")[1])?"?".concat(v.split("#")[0]):"",w=!!l.dataset.rbAsync||l.async||l.defer,L={url:d.replace(_,E).replace(r,"")+(f=h+1,!0===m.addQuery?""!==T?"".concat(T,"&retry=").concat(f):"?retry=".concat(f):"function"==typeof m.addQuery?m.addQuery({times:f,originalQuery:T}):""),times:h+1,originalQuery:T,ruleIndex:y,crossOrigin:m.crossOrigin,isAsync:w},S=function(e,r){var n=!0===r.crossOrigin?"anonymous":r.crossOrigin;if(t(e,HTMLScriptElement)){var i=document.createElement("script");return i.src=r.url,n&&(i.crossOrigin=n),r.times&&(i.dataset.rbRetryTimes=r.times+""),r.isAsync&&(i.dataset.rbAsync=""),void 0!==r.originalQuery&&(i.dataset.rbOriginalQuery=r.originalQuery),r.ruleIndex>=0&&(i.dataset.rbRuleI=r.ruleIndex+""),i}if(t(e,HTMLLinkElement)){var a=document.createElement("link");return a.rel=e.rel||"stylesheet",e.as&&(a.as=e.as),a.href=r.url,n&&(a.crossOrigin=n),r.times&&(a.dataset.rbRetryTimes=r.times+""),void 0!==r.originalQuery&&(a.dataset.rbOriginalQuery=r.originalQuery),a}}(l,L),N={times:h,domain:_,url:d,tagName:c,isAsyncChunk:!1};"function"==typeof m.onRetry&&m.onRetry(N);var O="function"==typeof m.delay?m.delay(N):m.delay;O>0?setTimeout(function(){a(l,S,L)},O):a(l,S,L)}}}(o,n)}catch(e){console.error("retry error captured",e)}},!0),document.addEventListener("load",function(r){if(r&&t(r.target,Element))try{!function(r,t){var n=i(r,t);if(!1!==n){var a=n.target,o=n.tagName,s=n.url,u=n.rule,l=e(s,u),c=Number(a.dataset.rbRetryTimes)||0;0!==c&&"function"==typeof u.onSuccess&&u.onSuccess({times:c,domain:l,url:s,tagName:o,isAsyncChunk:!1})}}(o,r)}catch(e){console.error("load error captured",e)}},!0))}catch(e){console.error("monitor error captured",e)}}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-assets-retry",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "An Rsbuild plugin to automatically resend requests when static assets fail to load.",
|
|
5
5
|
"repository": "https://github.com/rstackjs/rsbuild-plugin-assets-retry",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@biomejs/biome": "^1.9.4",
|
|
33
|
-
"@microsoft/api-extractor": "^7.
|
|
34
|
-
"@playwright/test": "^1.
|
|
35
|
-
"@rsbuild/core": "^1.
|
|
36
|
-
"@rsbuild/plugin-react": "^1.4.
|
|
37
|
-
"@rslib/core": "^0.
|
|
38
|
-
"@swc/core": "^1.15.
|
|
39
|
-
"@types/node": "^24.10.
|
|
40
|
-
"@types/react": "^19.2.
|
|
33
|
+
"@microsoft/api-extractor": "^7.56.0",
|
|
34
|
+
"@playwright/test": "^1.58.1",
|
|
35
|
+
"@rsbuild/core": "^1.7.2",
|
|
36
|
+
"@rsbuild/plugin-react": "^1.4.4",
|
|
37
|
+
"@rslib/core": "^0.19.4",
|
|
38
|
+
"@swc/core": "^1.15.11",
|
|
39
|
+
"@types/node": "^24.10.9",
|
|
40
|
+
"@types/react": "^19.2.10",
|
|
41
41
|
"@types/react-dom": "^19.2.3",
|
|
42
42
|
"@types/serialize-javascript": "^5.0.4",
|
|
43
|
-
"playwright": "^1.
|
|
44
|
-
"react": "^19.2.
|
|
45
|
-
"react-dom": "^19.2.
|
|
43
|
+
"playwright": "^1.58.1",
|
|
44
|
+
"react": "^19.2.4",
|
|
45
|
+
"react-dom": "^19.2.4",
|
|
46
46
|
"serialize-javascript": "^6.0.2",
|
|
47
47
|
"simple-git-hooks": "^2.13.1",
|
|
48
48
|
"typescript": "^5.9.3"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"optional": true
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"packageManager": "pnpm@10.
|
|
58
|
+
"packageManager": "pnpm@10.28.2",
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public",
|
|
61
61
|
"registry": "https://registry.npmjs.org/"
|