@meng-xi/vite-plugin 0.1.3 → 0.1.5
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-en.md +49 -775
- package/README.md +46 -770
- package/dist/common/format/index.cjs +1 -1
- package/dist/common/format/index.d.cts +1 -130
- package/dist/common/format/index.d.mts +1 -130
- package/dist/common/format/index.d.ts +1 -130
- package/dist/common/format/index.mjs +1 -1
- package/dist/common/fs/index.cjs +1 -1
- package/dist/common/fs/index.d.cts +1 -89
- package/dist/common/fs/index.d.mts +1 -89
- package/dist/common/fs/index.d.ts +1 -89
- package/dist/common/fs/index.mjs +1 -1
- package/dist/common/html/index.cjs +2 -2
- package/dist/common/html/index.d.cts +19 -81
- package/dist/common/html/index.d.mts +19 -81
- package/dist/common/html/index.d.ts +19 -81
- package/dist/common/html/index.mjs +2 -2
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.d.cts +7 -8
- package/dist/common/index.d.mts +7 -8
- package/dist/common/index.d.ts +7 -8
- package/dist/common/index.mjs +1 -1
- package/dist/common/script/index.cjs +1 -1
- package/dist/common/script/index.d.cts +1 -44
- package/dist/common/script/index.d.mts +1 -44
- package/dist/common/script/index.d.ts +1 -44
- package/dist/common/script/index.mjs +1 -1
- package/dist/common/ui/index.cjs +1 -0
- package/dist/common/ui/index.d.cts +22 -0
- package/dist/common/ui/index.d.mts +22 -0
- package/dist/common/ui/index.d.ts +22 -0
- package/dist/common/ui/index.mjs +1 -0
- package/dist/common/validation/index.cjs +1 -1
- package/dist/common/validation/index.d.cts +2 -79
- package/dist/common/validation/index.d.mts +2 -79
- package/dist/common/validation/index.d.ts +2 -79
- package/dist/common/validation/index.mjs +1 -1
- package/dist/factory/index.cjs +1 -1
- package/dist/factory/index.d.cts +1 -1
- package/dist/factory/index.d.mts +1 -1
- package/dist/factory/index.d.ts +1 -1
- package/dist/factory/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +12 -10
- package/dist/index.d.mts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.mjs +1 -1
- package/dist/logger/index.d.cts +92 -1
- package/dist/logger/index.d.mts +92 -1
- package/dist/logger/index.d.ts +92 -1
- package/dist/plugins/autoImport/index.cjs +17 -0
- package/dist/plugins/autoImport/index.d.cts +291 -0
- package/dist/plugins/autoImport/index.d.mts +291 -0
- package/dist/plugins/autoImport/index.d.ts +291 -0
- package/dist/plugins/autoImport/index.mjs +17 -0
- package/dist/plugins/buildProgress/index.cjs +2 -2
- package/dist/plugins/buildProgress/index.d.cts +1 -1
- package/dist/plugins/buildProgress/index.d.mts +1 -1
- package/dist/plugins/buildProgress/index.d.ts +1 -1
- package/dist/plugins/buildProgress/index.mjs +2 -2
- package/dist/plugins/bundleAnalyzer/index.cjs +11 -11
- package/dist/plugins/bundleAnalyzer/index.d.cts +1 -1
- package/dist/plugins/bundleAnalyzer/index.d.mts +1 -1
- package/dist/plugins/bundleAnalyzer/index.d.ts +1 -1
- package/dist/plugins/bundleAnalyzer/index.mjs +18 -18
- package/dist/plugins/compressAssets/index.cjs +1 -1
- package/dist/plugins/compressAssets/index.d.cts +1 -1
- package/dist/plugins/compressAssets/index.d.mts +1 -1
- package/dist/plugins/compressAssets/index.d.ts +1 -1
- package/dist/plugins/compressAssets/index.mjs +1 -1
- package/dist/plugins/copyFile/index.cjs +1 -1
- package/dist/plugins/copyFile/index.d.cts +21 -3
- package/dist/plugins/copyFile/index.d.mts +21 -3
- package/dist/plugins/copyFile/index.d.ts +21 -3
- package/dist/plugins/copyFile/index.mjs +1 -1
- package/dist/plugins/envGuard/index.cjs +67 -0
- package/dist/plugins/envGuard/index.d.cts +255 -0
- package/dist/plugins/envGuard/index.d.mts +255 -0
- package/dist/plugins/envGuard/index.d.ts +255 -0
- package/dist/plugins/envGuard/index.mjs +67 -0
- package/dist/plugins/faviconManager/index.cjs +1 -1
- package/dist/plugins/faviconManager/index.d.cts +44 -6
- package/dist/plugins/faviconManager/index.d.mts +44 -6
- package/dist/plugins/faviconManager/index.d.ts +44 -6
- package/dist/plugins/faviconManager/index.mjs +1 -1
- package/dist/plugins/generateRouter/index.cjs +4 -4
- package/dist/plugins/generateRouter/index.d.cts +62 -15
- package/dist/plugins/generateRouter/index.d.mts +62 -15
- package/dist/plugins/generateRouter/index.d.ts +62 -15
- package/dist/plugins/generateRouter/index.mjs +4 -4
- package/dist/plugins/generateVersion/index.cjs +1 -1
- package/dist/plugins/generateVersion/index.d.cts +13 -1
- package/dist/plugins/generateVersion/index.d.mts +13 -1
- package/dist/plugins/generateVersion/index.d.ts +13 -1
- package/dist/plugins/generateVersion/index.mjs +1 -1
- package/dist/plugins/htmlInject/index.cjs +7 -7
- package/dist/plugins/htmlInject/index.d.cts +50 -195
- package/dist/plugins/htmlInject/index.d.mts +50 -195
- package/dist/plugins/htmlInject/index.d.ts +50 -195
- package/dist/plugins/htmlInject/index.mjs +7 -7
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +5 -2
- package/dist/plugins/index.d.mts +5 -2
- package/dist/plugins/index.d.ts +5 -2
- package/dist/plugins/index.mjs +1 -1
- package/dist/plugins/loadingManager/index.cjs +26 -26
- package/dist/plugins/loadingManager/index.d.cts +1 -1
- package/dist/plugins/loadingManager/index.d.mts +1 -1
- package/dist/plugins/loadingManager/index.d.ts +1 -1
- package/dist/plugins/loadingManager/index.mjs +11 -11
- package/dist/plugins/versionUpdateChecker/index.cjs +1 -1
- package/dist/plugins/versionUpdateChecker/index.d.cts +1 -1
- package/dist/plugins/versionUpdateChecker/index.d.mts +1 -1
- package/dist/plugins/versionUpdateChecker/index.d.ts +1 -1
- package/dist/plugins/versionUpdateChecker/index.mjs +1 -1
- package/dist/shared/vite-plugin.B8FuZce1.d.cts +45 -0
- package/dist/shared/vite-plugin.B8FuZce1.d.mts +45 -0
- package/dist/shared/vite-plugin.B8FuZce1.d.ts +45 -0
- package/dist/shared/vite-plugin.BI9taN75.d.cts +122 -0
- package/dist/shared/vite-plugin.BI9taN75.d.mts +122 -0
- package/dist/shared/vite-plugin.BI9taN75.d.ts +122 -0
- package/dist/shared/vite-plugin.BPFqtmWa.mjs +1 -0
- package/dist/shared/vite-plugin.CnOy46d3.cjs +1 -0
- package/package.json +16 -16
- package/dist/common/compress/index.cjs +0 -1
- package/dist/common/compress/index.d.cts +0 -23
- package/dist/common/compress/index.d.mts +0 -23
- package/dist/common/compress/index.d.ts +0 -23
- package/dist/common/compress/index.mjs +0 -1
- package/dist/common/object/index.cjs +0 -1
- package/dist/common/object/index.d.cts +0 -30
- package/dist/common/object/index.d.mts +0 -30
- package/dist/common/object/index.d.ts +0 -30
- package/dist/common/object/index.mjs +0 -1
- package/dist/common/path/index.cjs +0 -1
- package/dist/common/path/index.d.cts +0 -22
- package/dist/common/path/index.d.mts +0 -22
- package/dist/common/path/index.d.ts +0 -22
- package/dist/common/path/index.mjs +0 -1
- package/dist/shared/vite-plugin.CLr0ttuO.d.cts +0 -135
- package/dist/shared/vite-plugin.CLr0ttuO.d.mts +0 -135
- package/dist/shared/vite-plugin.CLr0ttuO.d.ts +0 -135
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createPluginFactory as V,BasePlugin as j}from"../../factory/index.mjs";import{
|
|
1
|
+
import{createPluginFactory as V,BasePlugin as j}from"../../factory/index.mjs";import{makeCallback as g}from"../../common/script/index.mjs";import{validateCallbackFields as G,validateNoScriptInTemplate as J,validateGlobalName as z}from"../../common/validation/index.mjs";import{injectHeadAndBody as Y}from"../../common/html/index.mjs";import"../../logger/index.mjs";import"../../shared/vite-plugin.DcExl6jd.mjs";import"../../shared/vite-plugin.BPFqtmWa.mjs";const o="__loading-overlay__",c="__loading-hidden__",f="__loading-visible__",H="__loading-top__",F="__loading-center__",A="__loading-bottom__",r="__loading-spinner__",B="__loading-text__",s="__loading-dot__",C="__loading-root__",D="data-loading-text",L="__loading-spin__",M="__loading-dots__",O="__loading-pulse__",N="__loading-bar__",K={center:F,top:H,bottom:A};function Q(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function W(e,t="spinner",n){const{overlayColor:i="rgba(255, 255, 255, 0.7)",spinnerColor:l="#4361ee",spinnerSize:d="40px",textColor:a="#333",textSize:u="14px",zIndex:p=9999,pointerEvents:$=!0,backdropBlur:_=!1,backdropBlurAmount:m=4}=e,b=$?"":"pointer-events: none;",v=_?`backdrop-filter: blur(${m}px);-webkit-backdrop-filter: blur(${m}px);`:"",w=Z(t,l,d),T=n?.enabled!==!1,h=n?.duration??200,y=n?.easing??"ease-out",E=T?`transition: opacity ${h}ms ${y}, visibility ${h}ms ${y};`:"";return`
|
|
2
2
|
.${o} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 0;
|
|
@@ -26,7 +26,7 @@ import{createPluginFactory as V,BasePlugin as j}from"../../factory/index.mjs";im
|
|
|
26
26
|
justify-content: flex-end;
|
|
27
27
|
padding-bottom: 60px;
|
|
28
28
|
}
|
|
29
|
-
${
|
|
29
|
+
${w}
|
|
30
30
|
.${B} {
|
|
31
31
|
margin-top: 12px;
|
|
32
32
|
color: ${a};
|
|
@@ -64,11 +64,11 @@ ${T}
|
|
|
64
64
|
height: calc(${n} / 4);
|
|
65
65
|
border-radius: 50%;
|
|
66
66
|
background: ${t};
|
|
67
|
-
animation: ${
|
|
67
|
+
animation: ${M} 1.2s ease-in-out infinite;
|
|
68
68
|
}
|
|
69
69
|
.${r} .${s}:nth-child(2) { animation-delay: 0.15s; }
|
|
70
70
|
.${r} .${s}:nth-child(3) { animation-delay: 0.3s; }
|
|
71
|
-
@keyframes ${
|
|
71
|
+
@keyframes ${M} {
|
|
72
72
|
0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
|
|
73
73
|
40% { transform: scale(1); opacity: 1; }
|
|
74
74
|
}`;case"pulse":return`
|
|
@@ -113,11 +113,11 @@ ${T}
|
|
|
113
113
|
border: 3px solid rgba(0, 0, 0, 0.1);
|
|
114
114
|
border-top-color: ${t};
|
|
115
115
|
border-radius: 50%;
|
|
116
|
-
animation: ${
|
|
116
|
+
animation: ${L} 0.8s linear infinite;
|
|
117
117
|
}
|
|
118
|
-
@keyframes ${
|
|
118
|
+
@keyframes ${L} {
|
|
119
119
|
to { transform: rotate(360deg); }
|
|
120
|
-
}`}}function ee(e){const t=e.position||"center",n=e.defaultText||"\u52A0\u8F7D\u4E2D...",i=e.spinnerType||"spinner",l=
|
|
120
|
+
}`}}function ee(e){const t=e.position||"center",n=e.defaultText||"\u52A0\u8F7D\u4E2D...",i=e.spinnerType||"spinner",l=K[t],d=e.style?.customClass?` ${e.style.customClass}`:"",a=e.style?.customStyle?` style="${Q(e.style.customStyle)}"`:"",u=e.defaultVisible?f:c;if(e.customTemplate)return`<div class="${o} ${l} ${u}${d}" id="${C}"${a}>${e.customTemplate}</div>`;const p=te(i);return`<div class="${o} ${l} ${u}${d}" id="${C}"${a}>
|
|
121
121
|
${p}
|
|
122
122
|
<div class="${B}" ${D}>${n}</div>
|
|
123
123
|
</div>`}function te(e){switch(e){case"dots":return`<div class="${r}"><div class="${s}"></div><div class="${s}"></div><div class="${s}"></div></div>`;default:return`<div class="${r}"></div>`}}function ne(e){return` var _loadingEl = null;
|
|
@@ -156,7 +156,7 @@ ${T}
|
|
|
156
156
|
var _originalXHROpen = null;
|
|
157
157
|
var _originalXHRSend = null;`}function ie(e){return` function _findEl() {
|
|
158
158
|
if (!_loadingEl) {
|
|
159
|
-
_loadingEl = document.getElementById('${
|
|
159
|
+
_loadingEl = document.getElementById('${C}');
|
|
160
160
|
}
|
|
161
161
|
if (!_textEl && _loadingEl) {
|
|
162
162
|
_textEl = _loadingEl.querySelector('[${D}]');
|
|
@@ -430,7 +430,7 @@ ${T}
|
|
|
430
430
|
}
|
|
431
431
|
`),i+=`
|
|
432
432
|
// \u66B4\u9732\u5230\u5168\u5C40
|
|
433
|
-
window['${n}'] = manager;`,i}function ue(e){const t=e.globalName||"__LOADING_MANAGER__",n=e.minDisplayTime||{enabled:!0,duration:300},i=e.delayShow||{enabled:!0,duration:200},l=e.debounceHide||{enabled:!1,duration:100},d=e.transition||{enabled:!0,duration:200,easing:"ease-out"},a=e.autoBind||"none",u=e.requestFilter||{},p=e.defaultVisible||!1,$=e.autoHideOn||"DOMContentLoaded",_=e.callbacks||{},m=u.excludeUrls||[],b=u.includeUrls||[],v=u.excludeMethods||[],
|
|
433
|
+
window['${n}'] = manager;`,i}function ue(e){const t=e.globalName||"__LOADING_MANAGER__",n=e.minDisplayTime||{enabled:!0,duration:300},i=e.delayShow||{enabled:!0,duration:200},l=e.debounceHide||{enabled:!1,duration:100},d=e.transition||{enabled:!0,duration:200,easing:"ease-out"},a=e.autoBind||"none",u=e.requestFilter||{},p=e.defaultVisible||!1,$=e.autoHideOn||"DOMContentLoaded",_=e.callbacks||{},m=u.excludeUrls||[],b=u.includeUrls||[],v=u.excludeMethods||[],w=u.excludeUrlPrefixes||[],T=g(_.onBeforeShow,"loadingManager"),h=g(_.onShow,"loadingManager"),y=g(_.onBeforeHide,"loadingManager"),E=g(_.onHide,"loadingManager"),R=g(_.onDestroy,"loadingManager"),I=ne({minDisplayTime:n,delayShow:i,debounceHide:l,transition:d,excludeUrls:m,includeUrls:b,excludeMethods:v,excludeUrlPrefixes:w,cbBeforeShow:T,cbShow:h,cbBeforeHide:y,cbHide:E,cbDestroy:R}),k=ie(t),U=oe(),P=re(),X=ae(a),q=le(p,$,t);return`(function() {
|
|
434
434
|
'use strict';
|
|
435
435
|
|
|
436
436
|
// SSR \u73AF\u5883\u68C0\u6D4B
|
|
@@ -449,7 +449,7 @@ ${P}
|
|
|
449
449
|
${X}
|
|
450
450
|
|
|
451
451
|
${q}
|
|
452
|
-
})();`}function de(e){if(!e)return;const{zIndex:t,pointerEvents:n,backdropBlurAmount:i}=e;if(
|
|
452
|
+
})();`}function x(e,t){if(e!==void 0&&(typeof e!="number"||e<0))throw new Error(`${t} \u5FC5\u987B\u662F\u975E\u8D1F\u6570`)}function de(e){if(!e)return;const{zIndex:t,pointerEvents:n,backdropBlurAmount:i}=e;if(x(t,"style.zIndex"),n!==void 0&&typeof n!="boolean")throw new Error("style.pointerEvents \u5FC5\u987B\u662F\u5E03\u5C14\u503C");x(i,"style.backdropBlurAmount")}function se(e){if(!e)return;const{duration:t,easing:n}=e;if(x(t,"transition.duration"),n!==void 0&&typeof n!="string")throw new Error("transition.easing \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B")}function _e(e){e&&G(e,["onBeforeShow","onShow","onBeforeHide","onHide","onDestroy"],"callbacks")}function ce(e){return e===""?"defaultText \u4E3A\u7A7A\u5B57\u7B26\u4E32\uFF0Cloading \u5C06\u4E0D\u663E\u793A\u6587\u672C\u5185\u5BB9":null}function fe(e,t){return!e&&t?"autoHideOn \u4EC5\u5728 defaultVisible \u4E3A true \u65F6\u751F\u6548\uFF0C\u5F53\u524D defaultVisible \u4E3A false\uFF0CautoHideOn \u914D\u7F6E\u5C06\u88AB\u5FFD\u7565":null}function S(e,t){if(e?.duration!==void 0&&(typeof e.duration!="number"||e.duration<0))throw new Error(t)}class pe extends j{getDefaultOptions(){return{position:"center",defaultText:"\u52A0\u8F7D\u4E2D...",spinnerType:"spinner",autoBind:"none",globalName:"__LOADING_MANAGER__",defaultVisible:!1,autoHideOn:"DOMContentLoaded",style:{overlayColor:"rgba(255, 255, 255, 0.7)",spinnerColor:"#4361ee",spinnerSize:"40px",textColor:"#333",textSize:"14px",zIndex:9999,pointerEvents:!0,backdropBlur:!1,backdropBlurAmount:4},transition:{enabled:!0,duration:200,easing:"ease-out"},minDisplayTime:{enabled:!0,duration:300},delayShow:{enabled:!0,duration:200},debounceHide:{enabled:!1,duration:100}}}validateOptions(){this.validator.field("position").enum(["center","top","bottom"]).field("defaultText").string().field("spinnerType").enum(["spinner","dots","pulse","bar"]).field("autoBind").enum(["fetch","xhr","all","none"]).field("globalName").string().field("customTemplate").string().field("defaultVisible").boolean().field("autoHideOn").enum(["DOMContentLoaded","load","manual"]).validate(),J(this.options.customTemplate,"customTemplate");const t=ce(this.options.defaultText);t&&this.logger.warn(t),z(this.options.globalName,"globalName"),de(this.options.style),S(this.options.minDisplayTime,"minDisplayTime.duration \u5FC5\u987B\u662F\u975E\u8D1F\u6570"),S(this.options.delayShow,"delayShow.duration \u5FC5\u987B\u662F\u975E\u8D1F\u6570"),S(this.options.debounceHide,"debounceHide.duration \u5FC5\u987B\u662F\u975E\u8D1F\u6570"),se(this.options.transition),_e(this.options.callbacks);const n=fe(this.options.defaultVisible,this.options.autoHideOn);n&&this.logger.warn(n)}getPluginName(){return"loading-manager"}generateLoadingManager(t){return ue(t)}generateHeadInjectCode(){const{css:t,html:n}=this.getCachedAssets();return`<!-- loading-manager: head start -->
|
|
453
453
|
<style data-loading-style data-loading-id="${this.options.globalName||"__LOADING_MANAGER__"}">${t}</style>
|
|
454
454
|
${n}
|
|
455
455
|
<!-- loading-manager: head end -->`}generateBodyInjectCode(t){const n=this.generateLoadingManager(this.options);if(t)return`<!-- loading-manager: body start -->
|
|
@@ -484,4 +484,4 @@ ${n}
|
|
|
484
484
|
})();
|
|
485
485
|
${n}
|
|
486
486
|
<\/script>
|
|
487
|
-
<!-- loading-manager: end -->`}_cachedAssets=null;getCachedAssets(){if(!this._cachedAssets){const t=this.options.style||{},n=this.options.spinnerType||"spinner",i=this.options.transition;this._cachedAssets={css:W(t,n,i),html:ee(this.options)}}return this._cachedAssets}addPluginHooks(t){const n=this.options.defaultVisible||!1,i=n?this.generateHeadInjectCode():void 0,l=this.generateBodyInjectCode(n);t.transformIndexHtml={order:"post",handler:d=>{const a=
|
|
487
|
+
<!-- loading-manager: end -->`}_cachedAssets=null;getCachedAssets(){if(!this._cachedAssets){const t=this.options.style||{},n=this.options.spinnerType||"spinner",i=this.options.transition;this._cachedAssets={css:W(t,n,i),html:ee(this.options)}}return this._cachedAssets}addPluginHooks(t){const n=this.options.defaultVisible||!1,i=n?this.generateHeadInjectCode():void 0,l=this.generateBodyInjectCode(n);t.transformIndexHtml={order:"post",handler:d=>{const a=Y(d,i,l);return i&&!a.headInjected&&this.logger.warn("\u672A\u627E\u5230 </head> \u6807\u7B7E\uFF0CdefaultVisible \u7684\u767D\u5C4F loading \u5C06\u65E0\u6CD5\u751F\u6548"),a.usedFallback&&this.logger.warn("\u672A\u627E\u5230 </body> \u6216 </html> \u6807\u7B7E\uFF0CLoading \u4EE3\u7801\u8FFD\u52A0\u5230\u6587\u4EF6\u672B\u5C3E"),a.bodyInjected&&this.logger.success("\u6210\u529F\u6CE8\u5165\u5168\u5C40 Loading \u72B6\u6001\u7BA1\u7406\u4EE3\u7801\u5230 HTML \u6587\u4EF6"),a.html}}}}const ge=V(pe);export{ge as loadingManager};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const factory_index=require("../../factory/index.cjs"),common_script_index=require("../../common/script/index.cjs"),common_validation_index=require("../../common/validation/index.cjs"),common_html_index=require("../../common/html/index.cjs");require("../../logger/index.cjs"),require("../../
|
|
1
|
+
"use strict";const factory_index=require("../../factory/index.cjs"),common_script_index=require("../../common/script/index.cjs"),common_validation_index=require("../../common/validation/index.cjs"),common_html_index=require("../../common/html/index.cjs");require("../../logger/index.cjs"),require("../../shared/vite-plugin.Bcg6RW2N.cjs"),require("../../shared/vite-plugin.CnOy46d3.cjs");function generateCSS(e,n){const u=".__vuc-overlay__{position:fixed;top:0;left:0;right:0;bottom:0;z-index:99999;pointer-events:none;}";let t="";switch(e){case"modal":t=`.__vuc-modal__{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#fff;border-radius:12px;box-shadow:0 8px 32px rgba(0,0,0,0.15);padding:32px;max-width:420px;width:90%;z-index:100000;pointer-events:auto;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;text-align:center;}
|
|
2
2
|
.__vuc-modal-title__{font-size:18px;font-weight:600;color:#1a1a2e;margin:0 0 12px 0;}
|
|
3
3
|
.__vuc-modal-body__{font-size:14px;color:#555;line-height:1.6;margin:0 0 8px 0;}
|
|
4
4
|
.__vuc-modal-version__{font-size:12px;color:#999;margin:0 0 24px 0;}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createPluginFactory as d,BasePlugin as p}from"../../factory/index.mjs";import{makeCallback as i}from"../../common/script/index.mjs";import{validateNoScriptInTemplate as v,validateGlobalName as f,validateCallbackFields as m}from"../../common/validation/index.mjs";import{injectHeadAndBody as b}from"../../common/html/index.mjs";import"../../logger/index.mjs";import"../../
|
|
1
|
+
import{createPluginFactory as d,BasePlugin as p}from"../../factory/index.mjs";import{makeCallback as i}from"../../common/script/index.mjs";import{validateNoScriptInTemplate as v,validateGlobalName as f,validateCallbackFields as m}from"../../common/validation/index.mjs";import{injectHeadAndBody as b}from"../../common/html/index.mjs";import"../../logger/index.mjs";import"../../shared/vite-plugin.DcExl6jd.mjs";import"../../shared/vite-plugin.BPFqtmWa.mjs";function F(e,n){const u=".__vuc-overlay__{position:fixed;top:0;left:0;right:0;bottom:0;z-index:99999;pointer-events:none;}";let t="";switch(e){case"modal":t=`.__vuc-modal__{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#fff;border-radius:12px;box-shadow:0 8px 32px rgba(0,0,0,0.15);padding:32px;max-width:420px;width:90%;z-index:100000;pointer-events:auto;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;text-align:center;}
|
|
2
2
|
.__vuc-modal-title__{font-size:18px;font-weight:600;color:#1a1a2e;margin:0 0 12px 0;}
|
|
3
3
|
.__vuc-modal-body__{font-size:14px;color:#555;line-height:1.6;margin:0 0 8px 0;}
|
|
4
4
|
.__vuc-modal-version__{font-size:12px;color:#999;margin:0 0 24px 0;}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 构造函数参数接口
|
|
3
|
+
*/
|
|
4
|
+
interface LoggerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* 插件名称
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* 是否启用日志
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 插件日志代理接口
|
|
16
|
+
* @description 为每个插件提供独立的日志接口
|
|
17
|
+
*/
|
|
18
|
+
interface PluginLogger {
|
|
19
|
+
/**
|
|
20
|
+
* 输出成功日志
|
|
21
|
+
* @param message 日志消息
|
|
22
|
+
* @param data 附加数据
|
|
23
|
+
*/
|
|
24
|
+
success(message: string, data?: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* 输出信息日志
|
|
27
|
+
* @param message 日志消息
|
|
28
|
+
* @param data 附加数据
|
|
29
|
+
*/
|
|
30
|
+
info(message: string, data?: any): void;
|
|
31
|
+
/**
|
|
32
|
+
* 输出警告日志
|
|
33
|
+
* @param message 日志消息
|
|
34
|
+
* @param data 附加数据
|
|
35
|
+
*/
|
|
36
|
+
warn(message: string, data?: any): void;
|
|
37
|
+
/**
|
|
38
|
+
* 输出错误日志
|
|
39
|
+
* @param message 日志消息
|
|
40
|
+
* @param data 附加数据
|
|
41
|
+
*/
|
|
42
|
+
error(message: string, data?: any): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { LoggerOptions as L, PluginLogger as P };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 构造函数参数接口
|
|
3
|
+
*/
|
|
4
|
+
interface LoggerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* 插件名称
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* 是否启用日志
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 插件日志代理接口
|
|
16
|
+
* @description 为每个插件提供独立的日志接口
|
|
17
|
+
*/
|
|
18
|
+
interface PluginLogger {
|
|
19
|
+
/**
|
|
20
|
+
* 输出成功日志
|
|
21
|
+
* @param message 日志消息
|
|
22
|
+
* @param data 附加数据
|
|
23
|
+
*/
|
|
24
|
+
success(message: string, data?: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* 输出信息日志
|
|
27
|
+
* @param message 日志消息
|
|
28
|
+
* @param data 附加数据
|
|
29
|
+
*/
|
|
30
|
+
info(message: string, data?: any): void;
|
|
31
|
+
/**
|
|
32
|
+
* 输出警告日志
|
|
33
|
+
* @param message 日志消息
|
|
34
|
+
* @param data 附加数据
|
|
35
|
+
*/
|
|
36
|
+
warn(message: string, data?: any): void;
|
|
37
|
+
/**
|
|
38
|
+
* 输出错误日志
|
|
39
|
+
* @param message 日志消息
|
|
40
|
+
* @param data 附加数据
|
|
41
|
+
*/
|
|
42
|
+
error(message: string, data?: any): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { LoggerOptions as L, PluginLogger as P };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 构造函数参数接口
|
|
3
|
+
*/
|
|
4
|
+
interface LoggerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* 插件名称
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* 是否启用日志
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 插件日志代理接口
|
|
16
|
+
* @description 为每个插件提供独立的日志接口
|
|
17
|
+
*/
|
|
18
|
+
interface PluginLogger {
|
|
19
|
+
/**
|
|
20
|
+
* 输出成功日志
|
|
21
|
+
* @param message 日志消息
|
|
22
|
+
* @param data 附加数据
|
|
23
|
+
*/
|
|
24
|
+
success(message: string, data?: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* 输出信息日志
|
|
27
|
+
* @param message 日志消息
|
|
28
|
+
* @param data 附加数据
|
|
29
|
+
*/
|
|
30
|
+
info(message: string, data?: any): void;
|
|
31
|
+
/**
|
|
32
|
+
* 输出警告日志
|
|
33
|
+
* @param message 日志消息
|
|
34
|
+
* @param data 附加数据
|
|
35
|
+
*/
|
|
36
|
+
warn(message: string, data?: any): void;
|
|
37
|
+
/**
|
|
38
|
+
* 输出错误日志
|
|
39
|
+
* @param message 日志消息
|
|
40
|
+
* @param data 附加数据
|
|
41
|
+
*/
|
|
42
|
+
error(message: string, data?: any): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { LoggerOptions as L, PluginLogger as P };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML 单点注入结果
|
|
3
|
+
*
|
|
4
|
+
* @description 表示在 HTML 中进行单点注入操作后的结果,
|
|
5
|
+
* 包含注入后的 HTML 内容和是否成功注入的标志。
|
|
6
|
+
*/
|
|
7
|
+
interface HtmlInjectResult {
|
|
8
|
+
/** 注入后的 HTML 内容 */
|
|
9
|
+
html: string;
|
|
10
|
+
/** 是否成功注入 */
|
|
11
|
+
injected: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* HTML 双区域注入结果
|
|
15
|
+
*
|
|
16
|
+
* @description 表示在 HTML 的 head 和 body 两个区域同时注入后的结果,
|
|
17
|
+
* 包含各区域的注入状态和是否使用了回退策略。
|
|
18
|
+
*/
|
|
19
|
+
interface DualInjectResult {
|
|
20
|
+
/** 注入后的 HTML 内容 */
|
|
21
|
+
html: string;
|
|
22
|
+
/** 是否成功注入到 head 区域 */
|
|
23
|
+
headInjected: boolean;
|
|
24
|
+
/** 是否成功注入到 body 区域 */
|
|
25
|
+
bodyInjected: boolean;
|
|
26
|
+
/** body 注入是否使用了回退策略(追加到末尾) */
|
|
27
|
+
usedFallback: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* HTML 注入位置类型
|
|
31
|
+
*
|
|
32
|
+
* @description 定义内容在 HTML 中可注入的所有位置:
|
|
33
|
+
* - `head-start`:`<head>` 标签开始后
|
|
34
|
+
* - `head-end`:`</head>` 标签前
|
|
35
|
+
* - `body-start`:`<body>` 标签开始后
|
|
36
|
+
* - `body-end`:`</body>` 标签前
|
|
37
|
+
* - `before-selector`:选择器匹配位置前
|
|
38
|
+
* - `after-selector`:选择器匹配位置后
|
|
39
|
+
* - `replace-selector`:替换选择器匹配的内容
|
|
40
|
+
*/
|
|
41
|
+
type InjectPosition = 'head-start' | 'head-end' | 'body-start' | 'body-end' | 'before-selector' | 'after-selector' | 'replace-selector';
|
|
42
|
+
/**
|
|
43
|
+
* 选择器匹配模式
|
|
44
|
+
*
|
|
45
|
+
* @description 定义 HTML 选择器的匹配方式:
|
|
46
|
+
* - `string`:使用字符串精确匹配(默认)
|
|
47
|
+
* - `regex`:使用正则表达式匹配
|
|
48
|
+
*/
|
|
49
|
+
type SelectorMatch = 'string' | 'regex';
|
|
50
|
+
/**
|
|
51
|
+
* 条件判断类型
|
|
52
|
+
*
|
|
53
|
+
* @description 定义注入条件的类型:
|
|
54
|
+
* - `env`:基于环境变量是否存在且为真值
|
|
55
|
+
* - `file-contains`:基于 HTML 内容是否包含指定字符串
|
|
56
|
+
* - `custom`:基于自定义函数的返回值
|
|
57
|
+
*/
|
|
58
|
+
type ConditionType = 'env' | 'file-contains' | 'custom';
|
|
59
|
+
/**
|
|
60
|
+
* 注入条件配置
|
|
61
|
+
*
|
|
62
|
+
* @description 定义 HTML 内容注入的条件判断规则,
|
|
63
|
+
* 支持环境变量检测、内容包含检测和自定义函数判断,
|
|
64
|
+
* 可通过 `negate` 字段取反结果。
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // 当环境变量 ENABLE_ANALYTICS 存在时注入
|
|
69
|
+
* { type: 'env', value: 'ENABLE_ANALYTICS' }
|
|
70
|
+
*
|
|
71
|
+
* // 当 HTML 不包含特定元素时注入(取反)
|
|
72
|
+
* { type: 'file-contains', value: '<div id="app">', negate: true }
|
|
73
|
+
*
|
|
74
|
+
* // 使用自定义函数判断
|
|
75
|
+
* { type: 'custom', value: () => process.env.NODE_ENV === 'production' }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
interface InjectCondition {
|
|
79
|
+
/** 条件类型 */
|
|
80
|
+
type: ConditionType;
|
|
81
|
+
/**
|
|
82
|
+
* 条件值:
|
|
83
|
+
* - `env` 类型:环境变量名
|
|
84
|
+
* - `file-contains` 类型:要搜索的字符串
|
|
85
|
+
* - `custom` 类型:返回布尔值的自定义函数
|
|
86
|
+
*/
|
|
87
|
+
value: string | ((...args: any[]) => boolean);
|
|
88
|
+
/** 是否取反条件结果,默认为 `false` */
|
|
89
|
+
negate?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* HTML 安全配置
|
|
93
|
+
*
|
|
94
|
+
* @description 控制 HTML 内容注入时的安全过滤策略,
|
|
95
|
+
* 可配置是否阻止危险标签和属性,以及自定义允许/阻止列表。
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // 完全禁用安全过滤(不推荐)
|
|
100
|
+
* const config: SecurityConfig = { blockDangerousTags: false, blockDangerousAttributes: false }
|
|
101
|
+
*
|
|
102
|
+
* // 允许特定标签
|
|
103
|
+
* const config: SecurityConfig = { allowedTags: ['iframe'] }
|
|
104
|
+
*
|
|
105
|
+
* // 自定义阻止属性列表
|
|
106
|
+
* const config: SecurityConfig = { blockedAttributes: ['onclick', 'onerror'] }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
interface SecurityConfig {
|
|
110
|
+
/** 是否阻止危险 HTML 标签(如 script、iframe),默认为 `true` */
|
|
111
|
+
blockDangerousTags?: boolean;
|
|
112
|
+
/** 是否阻止危险 HTML 属性(如 onclick、onerror),默认为 `true` */
|
|
113
|
+
blockDangerousAttributes?: boolean;
|
|
114
|
+
/** 允许的标签列表,设置后将从默认阻止列表中排除这些标签 */
|
|
115
|
+
allowedTags?: string[];
|
|
116
|
+
/** 自定义阻止的标签列表,覆盖默认阻止列表 */
|
|
117
|
+
blockedTags?: string[];
|
|
118
|
+
/** 自定义阻止的属性列表,覆盖默认阻止属性列表 */
|
|
119
|
+
blockedAttributes?: string[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type { ConditionType as C, DualInjectResult as D, HtmlInjectResult as H, InjectCondition as I, SecurityConfig as S, InjectPosition as a, SelectorMatch as b };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML 单点注入结果
|
|
3
|
+
*
|
|
4
|
+
* @description 表示在 HTML 中进行单点注入操作后的结果,
|
|
5
|
+
* 包含注入后的 HTML 内容和是否成功注入的标志。
|
|
6
|
+
*/
|
|
7
|
+
interface HtmlInjectResult {
|
|
8
|
+
/** 注入后的 HTML 内容 */
|
|
9
|
+
html: string;
|
|
10
|
+
/** 是否成功注入 */
|
|
11
|
+
injected: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* HTML 双区域注入结果
|
|
15
|
+
*
|
|
16
|
+
* @description 表示在 HTML 的 head 和 body 两个区域同时注入后的结果,
|
|
17
|
+
* 包含各区域的注入状态和是否使用了回退策略。
|
|
18
|
+
*/
|
|
19
|
+
interface DualInjectResult {
|
|
20
|
+
/** 注入后的 HTML 内容 */
|
|
21
|
+
html: string;
|
|
22
|
+
/** 是否成功注入到 head 区域 */
|
|
23
|
+
headInjected: boolean;
|
|
24
|
+
/** 是否成功注入到 body 区域 */
|
|
25
|
+
bodyInjected: boolean;
|
|
26
|
+
/** body 注入是否使用了回退策略(追加到末尾) */
|
|
27
|
+
usedFallback: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* HTML 注入位置类型
|
|
31
|
+
*
|
|
32
|
+
* @description 定义内容在 HTML 中可注入的所有位置:
|
|
33
|
+
* - `head-start`:`<head>` 标签开始后
|
|
34
|
+
* - `head-end`:`</head>` 标签前
|
|
35
|
+
* - `body-start`:`<body>` 标签开始后
|
|
36
|
+
* - `body-end`:`</body>` 标签前
|
|
37
|
+
* - `before-selector`:选择器匹配位置前
|
|
38
|
+
* - `after-selector`:选择器匹配位置后
|
|
39
|
+
* - `replace-selector`:替换选择器匹配的内容
|
|
40
|
+
*/
|
|
41
|
+
type InjectPosition = 'head-start' | 'head-end' | 'body-start' | 'body-end' | 'before-selector' | 'after-selector' | 'replace-selector';
|
|
42
|
+
/**
|
|
43
|
+
* 选择器匹配模式
|
|
44
|
+
*
|
|
45
|
+
* @description 定义 HTML 选择器的匹配方式:
|
|
46
|
+
* - `string`:使用字符串精确匹配(默认)
|
|
47
|
+
* - `regex`:使用正则表达式匹配
|
|
48
|
+
*/
|
|
49
|
+
type SelectorMatch = 'string' | 'regex';
|
|
50
|
+
/**
|
|
51
|
+
* 条件判断类型
|
|
52
|
+
*
|
|
53
|
+
* @description 定义注入条件的类型:
|
|
54
|
+
* - `env`:基于环境变量是否存在且为真值
|
|
55
|
+
* - `file-contains`:基于 HTML 内容是否包含指定字符串
|
|
56
|
+
* - `custom`:基于自定义函数的返回值
|
|
57
|
+
*/
|
|
58
|
+
type ConditionType = 'env' | 'file-contains' | 'custom';
|
|
59
|
+
/**
|
|
60
|
+
* 注入条件配置
|
|
61
|
+
*
|
|
62
|
+
* @description 定义 HTML 内容注入的条件判断规则,
|
|
63
|
+
* 支持环境变量检测、内容包含检测和自定义函数判断,
|
|
64
|
+
* 可通过 `negate` 字段取反结果。
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // 当环境变量 ENABLE_ANALYTICS 存在时注入
|
|
69
|
+
* { type: 'env', value: 'ENABLE_ANALYTICS' }
|
|
70
|
+
*
|
|
71
|
+
* // 当 HTML 不包含特定元素时注入(取反)
|
|
72
|
+
* { type: 'file-contains', value: '<div id="app">', negate: true }
|
|
73
|
+
*
|
|
74
|
+
* // 使用自定义函数判断
|
|
75
|
+
* { type: 'custom', value: () => process.env.NODE_ENV === 'production' }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
interface InjectCondition {
|
|
79
|
+
/** 条件类型 */
|
|
80
|
+
type: ConditionType;
|
|
81
|
+
/**
|
|
82
|
+
* 条件值:
|
|
83
|
+
* - `env` 类型:环境变量名
|
|
84
|
+
* - `file-contains` 类型:要搜索的字符串
|
|
85
|
+
* - `custom` 类型:返回布尔值的自定义函数
|
|
86
|
+
*/
|
|
87
|
+
value: string | ((...args: any[]) => boolean);
|
|
88
|
+
/** 是否取反条件结果,默认为 `false` */
|
|
89
|
+
negate?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* HTML 安全配置
|
|
93
|
+
*
|
|
94
|
+
* @description 控制 HTML 内容注入时的安全过滤策略,
|
|
95
|
+
* 可配置是否阻止危险标签和属性,以及自定义允许/阻止列表。
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // 完全禁用安全过滤(不推荐)
|
|
100
|
+
* const config: SecurityConfig = { blockDangerousTags: false, blockDangerousAttributes: false }
|
|
101
|
+
*
|
|
102
|
+
* // 允许特定标签
|
|
103
|
+
* const config: SecurityConfig = { allowedTags: ['iframe'] }
|
|
104
|
+
*
|
|
105
|
+
* // 自定义阻止属性列表
|
|
106
|
+
* const config: SecurityConfig = { blockedAttributes: ['onclick', 'onerror'] }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
interface SecurityConfig {
|
|
110
|
+
/** 是否阻止危险 HTML 标签(如 script、iframe),默认为 `true` */
|
|
111
|
+
blockDangerousTags?: boolean;
|
|
112
|
+
/** 是否阻止危险 HTML 属性(如 onclick、onerror),默认为 `true` */
|
|
113
|
+
blockDangerousAttributes?: boolean;
|
|
114
|
+
/** 允许的标签列表,设置后将从默认阻止列表中排除这些标签 */
|
|
115
|
+
allowedTags?: string[];
|
|
116
|
+
/** 自定义阻止的标签列表,覆盖默认阻止列表 */
|
|
117
|
+
blockedTags?: string[];
|
|
118
|
+
/** 自定义阻止的属性列表,覆盖默认阻止属性列表 */
|
|
119
|
+
blockedAttributes?: string[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type { ConditionType as C, DualInjectResult as D, HtmlInjectResult as H, InjectCondition as I, SecurityConfig as S, InjectPosition as a, SelectorMatch as b };
|