@rsbuild/plugin-assets-retry 1.1.0 → 1.1.1
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/README.md +11 -11
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/runtime/initialChunkRetry.min.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
<a href="https://rsbuild.dev" target="blank"><img src="https://assets.rspack.dev/rsbuild/rsbuild-banner.png" alt="Rsbuild Logo" /></a>
|
|
3
|
-
</p>
|
|
1
|
+
# @rsbuild/plugin-assets-retry
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
An Rsbuild plugin to automatically resend requests when static assets fail to load.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://npmjs.com/package/@rsbuild/plugin-assets-retry">
|
|
7
|
+
<img src="https://img.shields.io/npm/v/@rsbuild/plugin-assets-retry?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
|
|
8
|
+
</a>
|
|
9
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
|
|
10
|
+
<a href="https://npmcharts.com/compare/@rsbuild/plugin-assets-retry?minimal=true"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-assets-retry.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
11
|
+
</p>
|
|
8
12
|
|
|
9
13
|
## Documentation
|
|
10
14
|
|
|
11
|
-
https://rsbuild.dev/
|
|
12
|
-
|
|
13
|
-
## Contributing
|
|
14
|
-
|
|
15
|
-
Please read the [Contributing Guide](https://github.com/web-infra-dev/rsbuild/blob/main/CONTRIBUTING.md).
|
|
15
|
+
See [Documentation](https://rsbuild.dev/plugins/list/plugin-assets-retry).
|
|
16
16
|
|
|
17
17
|
## License
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
[MIT](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
|
package/dist/index.cjs
CHANGED
|
@@ -132,7 +132,7 @@ var __webpack_exports__ = {};
|
|
|
132
132
|
let originSource = module.getGeneratedCode();
|
|
133
133
|
module.getGeneratedCode = ()=>modifier(originSource);
|
|
134
134
|
} catch (err) {
|
|
135
|
-
throw console.error('Failed to modify
|
|
135
|
+
throw console.error('Failed to modify webpack RuntimeModule'), err;
|
|
136
136
|
}
|
|
137
137
|
}(module, modifier);
|
|
138
138
|
}
|
|
@@ -196,7 +196,7 @@ var __webpack_exports__ = {};
|
|
|
196
196
|
setup (api) {
|
|
197
197
|
let { inlineScript = !0 } = userOptions, getScriptPath = (environment)=>{
|
|
198
198
|
let distDir = environment.config.output.distPath.js;
|
|
199
|
-
return external_node_path_default().posix.join(distDir, "assets-retry.1-1-
|
|
199
|
+
return external_node_path_default().posix.join(distDir, "assets-retry.1-1-1.js");
|
|
200
200
|
}, formatOptions = (config)=>{
|
|
201
201
|
let options = {
|
|
202
202
|
...userOptions
|
package/dist/index.js
CHANGED
|
@@ -116,7 +116,7 @@ function modifyRuntimeModule(module, modifier, isRspack) {
|
|
|
116
116
|
let originSource = module.getGeneratedCode();
|
|
117
117
|
module.getGeneratedCode = ()=>modifier(originSource);
|
|
118
118
|
} catch (err) {
|
|
119
|
-
throw console.error('Failed to modify
|
|
119
|
+
throw console.error('Failed to modify webpack RuntimeModule'), err;
|
|
120
120
|
}
|
|
121
121
|
}(module, modifier);
|
|
122
122
|
}
|
|
@@ -178,7 +178,7 @@ let pluginAssetsRetry = (userOptions = {})=>({
|
|
|
178
178
|
setup (api) {
|
|
179
179
|
let { inlineScript = !0 } = userOptions, getScriptPath = (environment)=>{
|
|
180
180
|
let distDir = environment.config.output.distPath.js;
|
|
181
|
-
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.posix.join(distDir, "assets-retry.1-1-
|
|
181
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.posix.join(distDir, "assets-retry.1-1-1.js");
|
|
182
182
|
}, formatOptions = (config)=>{
|
|
183
183
|
let options = {
|
|
184
184
|
...userOptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var t={link:HTMLLinkElement,script:HTMLScriptElement,img:HTMLImageElement};function n(e,t){for(var n="",r=0;r<t.length;r++)if(-1!==e.indexOf(t[r])){n=t[r];break}return n||window.origin}function r(n,r){var i=r.target,a=i.tagName.toLocaleLowerCase(),o=n.type,c=e(i,HTMLScriptElement)||e(i,HTMLImageElement)?i.src:e(i,HTMLLinkElement)?i.href:null;return!!(a&&-1!==o.indexOf(a)&&t[a]&&e(i,t[a]))&&!!c&&{target:i,tagName:a,url:c}}var i=/[?#].*$/;"undefined"==typeof window||window.__RB_ASYNC_CHUNKS__||(window.__RB_ASYNC_CHUNKS__={});try{var a,o,c=__RUNTIME_GLOBALS_OPTIONS__;a=function(t){try{!function(t,a){var o,c,s,l,u,d=r(t,a);if(!1!==
|
|
1
|
+
function e(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var t={link:HTMLLinkElement,script:HTMLScriptElement,img:HTMLImageElement};function n(e,t){for(var n="",r=0;r<t.length;r++)if(-1!==e.indexOf(t[r])){n=t[r];break}return n||window.origin}function r(n,r){var i=r.target,a=i.tagName.toLocaleLowerCase(),o=n.type,c=e(i,HTMLScriptElement)||e(i,HTMLImageElement)?i.src:e(i,HTMLLinkElement)?i.href:null;return!!(a&&-1!==o.indexOf(a)&&t[a]&&e(i,t[a]))&&!!c&&{target:i,tagName:a,url:c}}var i=/[?#].*$/;"undefined"==typeof window||window.__RB_ASYNC_CHUNKS__||(window.__RB_ASYNC_CHUNKS__={});try{var a,o,c=__RUNTIME_GLOBALS_OPTIONS__;a=function(t){try{!function(t,a){var o,c,s,l,u,d,m=r(t,a);if(!1!==m){var y=m.target,f=m.tagName,g=m.url;if(!("undefined"!=typeof window&&Object.keys(window.__RB_ASYNC_CHUNKS__||{}).some(function(e){return -1!==g.indexOf(e)}))){var p=t.test;if(p){if("string"==typeof p){var _=new RegExp(p);p=function(e){return _.test(e)}}if("function"!=typeof p||!p(g))return}var v=n(g,t.domain);if(!t.domain||!(t.domain.length>0)||-1!==t.domain.indexOf(v)){var b=Number(y.dataset.rbRetryTimes)||0;if(b===t.max){"function"==typeof t.onFail&&t.onFail({times:b,domain:v,url:g,tagName:f,isAsyncChunk:!1});return}var L=(c=n(v,o=t.domain),s=o.indexOf(c),o[(s+1)%o.length]||v),S=null!==(d=y.dataset.rbOriginalQuery)&&void 0!==d?d:(l=g.split("?")[1])?"?".concat(l.split("#")[0]):"",E=!!y.dataset.rbAsync||y.async||y.defer,w={url:g.replace(v,L).replace(i,"")+(u=b+1,!0===t.addQuery?""!==S?"".concat(S,"&retry=").concat(u):"?retry=".concat(u):"function"==typeof t.addQuery?t.addQuery({times:u,originalQuery:S}):""),times:b+1,crossOrigin:t.crossOrigin,isAsync:E,originalQuery:S},O=function(t,n){var r=!0===n.crossOrigin?"anonymous":n.crossOrigin,i=r?'crossorigin="'.concat(r,'"'):"",a=n.times?'data-rb-retry-times="'.concat(n.times,'"'):"",o=n.originalQuery?'data-rb-original-query="'.concat(n.originalQuery,'"'):"",c=n.isAsync?"data-rb-async":"";if(e(t,HTMLScriptElement)){var s=document.createElement("script");return s.src=n.url,r&&(s.crossOrigin=r),n.times&&(s.dataset.rbRetryTimes=String(n.times)),n.isAsync&&(s.dataset.rbAsync=""),void 0!==n.originalQuery&&(s.dataset.rbOriginalQuery=n.originalQuery),{element:s,str:'<script src="'.concat(n.url,'" ').concat(i," ").concat(a," ").concat(c," ").concat(o,">")+"<\/script>"}}if(e(t,HTMLLinkElement)){var l=document.createElement("link");return l.rel=t.rel||"stylesheet",t.as&&(l.as=t.as),l.href=n.url,r&&(l.crossOrigin=r),n.times&&(l.dataset.rbRetryTimes=String(n.times)),void 0!==n.originalQuery&&(l.dataset.rbOriginalQuery=n.originalQuery),{element:l,str:'<link rel="'.concat(l.rel,'" href="').concat(n.url,'" ').concat(i," ").concat(a," ").concat(l.as?'as="'.concat(l.as,'"'):""," ").concat(o,"></link>")}}}(y,w);"function"==typeof t.onRetry&&t.onRetry({times:b,domain:v,url:g,tagName:f,isAsyncChunk:!1}),e(y,HTMLScriptElement)&&(w.isAsync?document.body.appendChild(O.element):document.write(O.str)),e(y,HTMLLinkElement)&&document.getElementsByTagName("head")[0].appendChild(O.element),e(y,HTMLImageElement)&&(y.src=w.url,y.dataset.rbRetryTimes=String(w.times),y.dataset.rbOriginalQuery=String(w.originalQuery))}}}}(c,t)}catch(e){console.error("retry error captured",e)}},o=function(e){try{!function(e,t){var i=r(e,t);if(!1!==i){var a=i.target,o=i.tagName,c=i.url,s=n(c,e.domain),l=Number(a.dataset.rbRetryTimes)||0;0!==l&&"function"==typeof e.onSuccess&&e.onSuccess({times:l,domain:s,url:c,tagName:o,isAsyncChunk:!1})}}(c,e)}catch(e){console.error("load error captured",e)}},"undefined"!=typeof window&&void 0!==window.document&&(document.addEventListener("error",function(t){t&&e(t.target,Element)&&a(t)},!0),document.addEventListener("load",function(t){t&&e(t.target,Element)&&o(t)},!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.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Assets retry plugin for Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@rslib/core": "0.
|
|
27
|
-
"@swc/core": "^1.10.
|
|
26
|
+
"@rslib/core": "0.4.1",
|
|
27
|
+
"@swc/core": "^1.10.16",
|
|
28
28
|
"@types/serialize-javascript": "^5.0.4",
|
|
29
29
|
"serialize-javascript": "^6.0.2",
|
|
30
30
|
"typescript": "^5.7.3",
|
|
31
|
-
"@rsbuild/core": "1.2.
|
|
31
|
+
"@rsbuild/core": "1.2.9"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@rsbuild/core": "1.x"
|