@meng-xi/vite-plugin 0.1.0 → 0.1.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.
Files changed (110) hide show
  1. package/README-en.md +264 -533
  2. package/README.md +253 -522
  3. package/dist/common/format/index.cjs +1 -0
  4. package/dist/common/format/index.d.cts +156 -0
  5. package/dist/common/format/index.d.mts +156 -0
  6. package/dist/common/format/index.d.ts +156 -0
  7. package/dist/common/format/index.mjs +1 -0
  8. package/dist/common/fs/index.cjs +1 -0
  9. package/dist/common/fs/index.d.cts +150 -0
  10. package/dist/common/fs/index.d.mts +150 -0
  11. package/dist/common/fs/index.d.ts +150 -0
  12. package/dist/common/fs/index.mjs +1 -0
  13. package/dist/common/html/index.cjs +2 -0
  14. package/dist/common/html/index.d.cts +109 -0
  15. package/dist/common/html/index.d.mts +109 -0
  16. package/dist/common/html/index.d.ts +109 -0
  17. package/dist/common/html/index.mjs +2 -0
  18. package/dist/common/index.cjs +1 -1
  19. package/dist/common/index.d.cts +7 -417
  20. package/dist/common/index.d.mts +7 -417
  21. package/dist/common/index.d.ts +7 -417
  22. package/dist/common/index.mjs +1 -1
  23. package/dist/common/object/index.cjs +1 -0
  24. package/dist/common/object/index.d.cts +30 -0
  25. package/dist/common/object/index.d.mts +30 -0
  26. package/dist/common/object/index.d.ts +30 -0
  27. package/dist/common/object/index.mjs +1 -0
  28. package/dist/common/script/index.cjs +1 -0
  29. package/dist/common/script/index.d.cts +54 -0
  30. package/dist/common/script/index.d.mts +54 -0
  31. package/dist/common/script/index.d.ts +54 -0
  32. package/dist/common/script/index.mjs +1 -0
  33. package/dist/common/validation/index.cjs +1 -0
  34. package/dist/common/validation/index.d.cts +93 -0
  35. package/dist/common/validation/index.d.mts +93 -0
  36. package/dist/common/validation/index.d.ts +93 -0
  37. package/dist/common/validation/index.mjs +1 -0
  38. package/dist/factory/index.cjs +1 -1
  39. package/dist/factory/index.d.cts +1 -1
  40. package/dist/factory/index.d.mts +1 -1
  41. package/dist/factory/index.d.ts +1 -1
  42. package/dist/factory/index.mjs +1 -1
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.d.cts +16 -3
  45. package/dist/index.d.mts +16 -3
  46. package/dist/index.d.ts +16 -3
  47. package/dist/index.mjs +1 -1
  48. package/dist/plugins/buildProgress/index.cjs +2 -0
  49. package/dist/plugins/buildProgress/index.d.cts +187 -0
  50. package/dist/plugins/buildProgress/index.d.mts +187 -0
  51. package/dist/plugins/buildProgress/index.d.ts +187 -0
  52. package/dist/plugins/buildProgress/index.mjs +2 -0
  53. package/dist/plugins/compressAssets/index.cjs +1 -0
  54. package/dist/plugins/compressAssets/index.d.cts +132 -0
  55. package/dist/plugins/compressAssets/index.d.mts +132 -0
  56. package/dist/plugins/compressAssets/index.d.ts +132 -0
  57. package/dist/plugins/compressAssets/index.mjs +1 -0
  58. package/dist/plugins/copyFile/index.cjs +1 -0
  59. package/dist/plugins/copyFile/index.d.cts +78 -0
  60. package/dist/plugins/copyFile/index.d.mts +78 -0
  61. package/dist/plugins/copyFile/index.d.ts +78 -0
  62. package/dist/plugins/copyFile/index.mjs +1 -0
  63. package/dist/plugins/faviconManager/index.cjs +1 -0
  64. package/dist/plugins/faviconManager/index.d.cts +143 -0
  65. package/dist/plugins/faviconManager/index.d.mts +143 -0
  66. package/dist/plugins/faviconManager/index.d.ts +143 -0
  67. package/dist/plugins/faviconManager/index.mjs +1 -0
  68. package/dist/plugins/generateRouter/index.cjs +35 -0
  69. package/dist/plugins/generateRouter/index.d.cts +215 -0
  70. package/dist/plugins/generateRouter/index.d.mts +215 -0
  71. package/dist/plugins/generateRouter/index.d.ts +215 -0
  72. package/dist/plugins/generateRouter/index.mjs +35 -0
  73. package/dist/plugins/generateVersion/index.cjs +1 -0
  74. package/dist/plugins/generateVersion/index.d.cts +184 -0
  75. package/dist/plugins/generateVersion/index.d.mts +184 -0
  76. package/dist/plugins/generateVersion/index.d.ts +184 -0
  77. package/dist/plugins/generateVersion/index.mjs +1 -0
  78. package/dist/plugins/htmlInject/index.cjs +7 -0
  79. package/dist/plugins/htmlInject/index.d.cts +278 -0
  80. package/dist/plugins/htmlInject/index.d.mts +278 -0
  81. package/dist/plugins/htmlInject/index.d.ts +278 -0
  82. package/dist/plugins/htmlInject/index.mjs +7 -0
  83. package/dist/plugins/index.cjs +1 -1
  84. package/dist/plugins/index.d.cts +11 -1714
  85. package/dist/plugins/index.d.mts +11 -1714
  86. package/dist/plugins/index.d.ts +11 -1714
  87. package/dist/plugins/index.mjs +1 -1
  88. package/dist/plugins/loadingManager/index.cjs +487 -0
  89. package/dist/plugins/loadingManager/index.d.cts +769 -0
  90. package/dist/plugins/loadingManager/index.d.mts +769 -0
  91. package/dist/plugins/loadingManager/index.d.ts +769 -0
  92. package/dist/plugins/loadingManager/index.mjs +487 -0
  93. package/dist/plugins/versionUpdateChecker/index.cjs +185 -0
  94. package/dist/plugins/versionUpdateChecker/index.d.cts +200 -0
  95. package/dist/plugins/versionUpdateChecker/index.d.mts +200 -0
  96. package/dist/plugins/versionUpdateChecker/index.d.ts +200 -0
  97. package/dist/plugins/versionUpdateChecker/index.mjs +185 -0
  98. package/dist/shared/vite-plugin.Bcg6RW2N.cjs +3 -0
  99. package/dist/shared/{vite-plugin.CiHfwMiN.d.ts → vite-plugin.DRRlWY8P.d.cts} +50 -0
  100. package/dist/shared/{vite-plugin.CiHfwMiN.d.cts → vite-plugin.DRRlWY8P.d.mts} +50 -0
  101. package/dist/shared/{vite-plugin.CiHfwMiN.d.mts → vite-plugin.DRRlWY8P.d.ts} +50 -0
  102. package/dist/shared/{vite-plugin.B88RyRN8.mjs → vite-plugin.DcExl6jd.mjs} +2 -2
  103. package/package.json +80 -3
  104. package/dist/shared/vite-plugin.CawoITTT.cjs +0 -1
  105. package/dist/shared/vite-plugin.D6Law9Ke.mjs +0 -706
  106. package/dist/shared/vite-plugin.D8L9KzuW.cjs +0 -706
  107. package/dist/shared/vite-plugin.DFjf9wFM.mjs +0 -2
  108. package/dist/shared/vite-plugin.DSb6XzBn.mjs +0 -1
  109. package/dist/shared/vite-plugin.IGZeStMa.cjs +0 -3
  110. package/dist/shared/vite-plugin.Tab4qcIM.cjs +0 -2
@@ -0,0 +1,185 @@
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"../../common/object/index.mjs";import"../../shared/vite-plugin.DcExl6jd.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
+ .__vuc-modal-title__{font-size:18px;font-weight:600;color:#1a1a2e;margin:0 0 12px 0;}
3
+ .__vuc-modal-body__{font-size:14px;color:#555;line-height:1.6;margin:0 0 8px 0;}
4
+ .__vuc-modal-version__{font-size:12px;color:#999;margin:0 0 24px 0;}
5
+ .__vuc-modal-version__ span{font-family:Consolas,'Courier New',monospace;background:#f0f0f0;padding:2px 6px;border-radius:4px;font-size:11px;}
6
+ .__vuc-modal-actions__{display:flex;gap:12px;justify-content:center;}
7
+ .__vuc-btn__{padding:10px 24px;border-radius:8px;font-size:14px;cursor:pointer;border:none;transition:all 0.2s ease;}
8
+ .__vuc-btn-refresh__{background:#4361ee;color:#fff;}
9
+ .__vuc-btn-refresh__:hover{background:#3451d1;}
10
+ .__vuc-btn-dismiss__{background:#f0f0f0;color:#666;}
11
+ .__vuc-btn-dismiss__:hover{background:#e0e0e0;}`;break;case"banner":t=`.__vuc-banner__{position:fixed;top:0;left:0;right:0;background:linear-gradient(135deg,#4361ee,#7c3aed);color:#fff;padding:12px 20px;z-index:100000;pointer-events:auto;display:flex;align-items:center;justify-content:space-between;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;box-shadow:0 2px 12px rgba(67,97,238,0.3);}
12
+ .__vuc-banner-text__{font-size:14px;flex:1;}
13
+ .__vuc-banner-actions__{display:flex;gap:8px;flex-shrink:0;}
14
+ .__vuc-btn-banner-refresh__{background:rgba(255,255,255,0.2);color:#fff;border:1px solid rgba(255,255,255,0.3);padding:6px 16px;border-radius:6px;font-size:13px;cursor:pointer;transition:all 0.2s ease;}
15
+ .__vuc-btn-banner-refresh__:hover{background:rgba(255,255,255,0.3);}
16
+ .__vuc-btn-banner-dismiss__{background:transparent;color:rgba(255,255,255,0.8);border:none;padding:6px 12px;font-size:13px;cursor:pointer;}
17
+ .__vuc-btn-banner-dismiss__:hover{color:#fff;}`;break;case"toast":t=`.__vuc-toast__{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:#1a1a2e;color:#fff;padding:14px 24px;border-radius:10px;z-index:100000;pointer-events:auto;display:flex;align-items:center;gap:12px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;box-shadow:0 4px 20px rgba(0,0,0,0.2);max-width:90%;}
18
+ .__vuc-toast-text__{font-size:14px;white-space:nowrap;}
19
+ .__vuc-btn-toast-refresh__{background:#4361ee;color:#fff;border:none;padding:6px 16px;border-radius:6px;font-size:13px;cursor:pointer;white-space:nowrap;transition:all 0.2s ease;}
20
+ .__vuc-btn-toast-refresh__:hover{background:#3451d1;}
21
+ .__vuc-btn-toast-dismiss__{background:transparent;color:rgba(255,255,255,0.6);border:none;padding:6px 12px;font-size:13px;cursor:pointer;white-space:nowrap;transition:all 0.2s ease;}
22
+ .__vuc-btn-toast-dismiss__:hover{color:#fff;}`;break}return`<style data-vuc-style>${u}${t}${n||""}</style>`}function g(e){const n=e.promptStyle||"modal",u=e.promptMessage||"\u53D1\u73B0\u65B0\u7248\u672C\uFF0C\u662F\u5426\u7ACB\u5373\u5237\u65B0\u83B7\u53D6\u6700\u65B0\u5185\u5BB9\uFF1F",t=e.refreshButtonText||"\u7ACB\u5373\u5237\u65B0",r=e.dismissButtonText||"\u7A0D\u540E\u518D\u8BF4";if(e.customPromptTemplate)return e.customPromptTemplate.replace(/\{\{message\}\}/g,u).replace(/\{\{currentVersion\}\}/g,'<span id="__vuc-current__"></span>').replace(/\{\{newVersion\}\}/g,'<span id="__vuc-new__"></span>').replace(/\{\{refreshButton\}\}/g,`<button class="__vuc-btn-refresh__" onclick="window.__VUC_REFRESH__()">${t}</button>`).replace(/\{\{dismissButton\}\}/g,`<button class="__vuc-btn-dismiss__" onclick="window.__VUC_DISMISS__()">${r}</button>`);switch(n){case"modal":return`<div class="__vuc-overlay__"><div class="__vuc-modal__">
23
+ <p class="__vuc-modal-title__">\u7248\u672C\u66F4\u65B0</p>
24
+ <p class="__vuc-modal-body__">${u}</p>
25
+ <p class="__vuc-modal-version__"><span id="__vuc-current__"></span> \u2192 <span id="__vuc-new__"></span></p>
26
+ <div class="__vuc-modal-actions__">
27
+ <button class="__vuc-btn__ __vuc-btn-dismiss__" onclick="window.__VUC_DISMISS__()">${r}</button>
28
+ <button class="__vuc-btn__ __vuc-btn-refresh__" onclick="window.__VUC_REFRESH__()">${t}</button>
29
+ </div></div></div>`;case"banner":return`<div class="__vuc-overlay__"><div class="__vuc-banner__">
30
+ <span class="__vuc-banner-text__">${u}</span>
31
+ <div class="__vuc-banner-actions__">
32
+ <button class="__vuc-btn-banner-dismiss__" onclick="window.__VUC_DISMISS__()">${r}</button>
33
+ <button class="__vuc-btn-banner-refresh__" onclick="window.__VUC_REFRESH__()">${t}</button>
34
+ </div></div></div>`;case"toast":return`<div class="__vuc-overlay__"><div class="__vuc-toast__">
35
+ <span class="__vuc-toast-text__">${u}</span>
36
+ <button class="__vuc-btn-toast-dismiss__" onclick="window.__VUC_DISMISS__()">${r}</button>
37
+ <button class="__vuc-btn-toast-refresh__" onclick="window.__VUC_REFRESH__()">${t}</button>
38
+ </div></div>`;default:return`<div class="__vuc-overlay__"><div class="__vuc-modal__">
39
+ <p class="__vuc-modal-title__">\u7248\u672C\u66F4\u65B0</p>
40
+ <p class="__vuc-modal-body__">${u}</p>
41
+ <p class="__vuc-modal-version__"><span id="__vuc-current__"></span> \u2192 <span id="__vuc-new__"></span></p>
42
+ <div class="__vuc-modal-actions__">
43
+ <button class="__vuc-btn__ __vuc-btn-dismiss__" onclick="window.__VUC_DISMISS__()">${r}</button>
44
+ <button class="__vuc-btn__ __vuc-btn-refresh__" onclick="window.__VUC_REFRESH__()">${t}</button>
45
+ </div></div></div>`}}function h(e){const n=e.versionSource||"auto",u=e.defineName||"__APP_VERSION__",t=e.checkUrl||"/version.json",r=e.checkInterval||3e5,o=e.checkOnVisibilityChange!==!1,a=e.enableInDev||!1,_=i(e.onUpdateAvailable,"versionUpdateChecker","currentVersion, newVersion"),c=i(e.onRefresh,"versionUpdateChecker","currentVersion, newVersion"),l=i(e.onDismiss,"versionUpdateChecker","currentVersion, newVersion");let s="";return(n==="define"||n==="auto")&&(s=`
46
+ // \u4F18\u5148\u4ECE define \u5168\u5C40\u53D8\u91CF\u8BFB\u53D6
47
+ if (typeof ${u} !== 'undefined') return ${u};`),(n==="file"||n==="auto")&&(s+=`
48
+ // \u4ECE\u9875\u9762 meta \u6807\u7B7E\u8BFB\u53D6
49
+ var metaEl = document.querySelector('meta[name="app-version"]');
50
+ if (metaEl && metaEl.getAttribute('content')) return metaEl.getAttribute('content');`),s+=`
51
+ return null;`,`;(function() {
52
+ 'use strict';
53
+
54
+ // SSR \u73AF\u5883\u68C0\u6D4B
55
+ if (typeof window === 'undefined' || typeof document === 'undefined') return;
56
+
57
+ // \u5F00\u53D1\u6A21\u5F0F\u68C0\u6D4B
58
+ var _isDev = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'development';
59
+ if (_isDev && !${JSON.stringify(a)}) return;
60
+
61
+ // \u72B6\u6001
62
+ var _currentVersion = null;
63
+ var _latestVersion = null;
64
+ var _promptVisible = false;
65
+ var _dismissed = false;
66
+ var _delayTimer = null;
67
+ var _intervalTimer = null;
68
+ var _destroyed = false;
69
+
70
+ // \u83B7\u53D6\u5F53\u524D\u7248\u672C\u53F7
71
+ function _getCurrentVersion() {${s}
72
+ }
73
+
74
+ // \u68C0\u67E5\u7248\u672C\u66F4\u65B0
75
+ function _checkForUpdate() {
76
+ if (_destroyed || _dismissed || _promptVisible) return;
77
+
78
+ var xhr = new XMLHttpRequest();
79
+ xhr.open('GET', ${JSON.stringify(t)} + '?_t=' + Date.now(), true);
80
+ xhr.timeout = 10000;
81
+ xhr.onreadystatechange = function() {
82
+ if (xhr.readyState !== 4) return;
83
+ if (xhr.status !== 200) return;
84
+ try {
85
+ var data = JSON.parse(xhr.responseText);
86
+ _latestVersion = data.version || data;
87
+ if (!_currentVersion) _currentVersion = _getCurrentVersion();
88
+ if (!_currentVersion || !_latestVersion) return;
89
+ if (_currentVersion === _latestVersion) return;
90
+
91
+ // \u7248\u672C\u4E0D\u4E00\u81F4\uFF0C\u53D1\u73B0\u66F4\u65B0
92
+ var shouldShow = ${_}(_currentVersion, _latestVersion);
93
+ if (shouldShow !== false) {
94
+ _showPrompt();
95
+ }
96
+ } catch(e) {
97
+ // \u89E3\u6790\u5931\u8D25\uFF0C\u9759\u9ED8\u5FFD\u7565
98
+ }
99
+ };
100
+ xhr.send();
101
+ }
102
+
103
+ // \u663E\u793A\u66F4\u65B0\u63D0\u793A
104
+ function _showPrompt() {
105
+ if (_promptVisible || _destroyed) return;
106
+ _promptVisible = true;
107
+
108
+ var container = document.getElementById('__vuc-root__');
109
+ if (!container) return;
110
+
111
+ container.style.display = '';
112
+
113
+ // \u586B\u5145\u7248\u672C\u53F7
114
+ var currentEl = document.getElementById('__vuc-current__');
115
+ var newEl = document.getElementById('__vuc-new__');
116
+ if (currentEl) currentEl.textContent = _currentVersion;
117
+ if (newEl) newEl.textContent = _latestVersion;
118
+ }
119
+
120
+ // \u9690\u85CF\u66F4\u65B0\u63D0\u793A
121
+ function _hidePrompt() {
122
+ _promptVisible = false;
123
+ var container = document.getElementById('__vuc-root__');
124
+ if (container) container.style.display = 'none';
125
+ }
126
+
127
+ // \u5237\u65B0\u9875\u9762
128
+ window.__VUC_REFRESH__ = function() {
129
+ ${c}(_currentVersion, _latestVersion);
130
+ window.location.reload();
131
+ };
132
+
133
+ // \u5FFD\u7565\u66F4\u65B0
134
+ window.__VUC_DISMISS__ = function() {
135
+ ${l}(_currentVersion, _latestVersion);
136
+ _dismissed = true;
137
+ _hidePrompt();
138
+ };
139
+
140
+ // \u542F\u52A8\u5B9A\u65F6\u68C0\u67E5
141
+ function _startChecking() {
142
+ _currentVersion = _getCurrentVersion();
143
+ if (!_currentVersion) {
144
+ console.warn('[versionUpdateChecker] \u65E0\u6CD5\u83B7\u53D6\u5F53\u524D\u7248\u672C\u53F7\uFF0C\u7248\u672C\u68C0\u67E5\u5DF2\u8DF3\u8FC7\u3002\u8BF7\u786E\u8BA4 generateVersion \u63D2\u4EF6\u5DF2\u6B63\u786E\u914D\u7F6E\u3002');
145
+ return;
146
+ }
147
+
148
+ // \u9996\u6B21\u5EF6\u8FDF 10 \u79D2\u68C0\u67E5\uFF0C\u907F\u514D\u9875\u9762\u521A\u52A0\u8F7D\u5C31\u5F39\u51FA
149
+ _delayTimer = setTimeout(function() {
150
+ _checkForUpdate();
151
+ // \u4E4B\u540E\u6309\u95F4\u9694\u5B9A\u671F\u68C0\u67E5
152
+ _intervalTimer = setInterval(_checkForUpdate, ${r});
153
+ }, 10000);
154
+ }
155
+
156
+ // \u9500\u6BC1\u68C0\u67E5\u5668\uFF0C\u6E05\u7406\u5B9A\u65F6\u5668\u548C DOM
157
+ function _destroy() {
158
+ _destroyed = true;
159
+ if (_delayTimer) { clearTimeout(_delayTimer); _delayTimer = null; }
160
+ if (_intervalTimer) { clearInterval(_intervalTimer); _intervalTimer = null; }
161
+ var container = document.getElementById('__vuc-root__');
162
+ if (container) container.parentNode.removeChild(container);
163
+ var styleEl = document.querySelector('style[data-vuc-style]');
164
+ if (styleEl) styleEl.parentNode.removeChild(styleEl);
165
+ delete window.__VUC_REFRESH__;
166
+ delete window.__VUC_DISMISS__;
167
+ }
168
+
169
+ // \u9875\u9762\u53EF\u89C1\u6027\u53D8\u5316\u65F6\u68C0\u67E5
170
+ ${o?`
171
+ document.addEventListener('visibilitychange', function() {
172
+ if (!document.hidden && !_destroyed && !_dismissed && !_promptVisible) {
173
+ _checkForUpdate();
174
+ }
175
+ });`:""}
176
+
177
+ // DOM \u5C31\u7EEA\u540E\u542F\u52A8
178
+ if (document.readyState === 'loading') {
179
+ document.addEventListener('DOMContentLoaded', _startChecking);
180
+ } else {
181
+ _startChecking();
182
+ }
183
+ })();`}function x(e){const n=e.versionSource||"auto";return n!=="file"&&n!=="auto"?"":`<meta name="app-version" content="${e.defineName||"__APP_VERSION__"}">`}function C(e){const n=F(e.promptStyle||"modal",e.customStyle),u=g(e),t=h(e);return`${n}
184
+ <div id="__vuc-root__" style="display:none">${u}</div>
185
+ <script>${t}<\/script>`}function E(e){m(e,["onUpdateAvailable","onRefresh","onDismiss"],"callbacks")}function y(e){v(e.customPromptTemplate,"customPromptTemplate"),E(e),f(e.defineName,"defineName")}class B extends p{getDefaultOptions(){return{versionSource:"auto",defineName:"__APP_VERSION__",checkUrl:"/version.json",checkInterval:3e5,checkOnVisibilityChange:!0,enableInDev:!1,promptStyle:"modal",promptMessage:"\u53D1\u73B0\u65B0\u7248\u672C\uFF0C\u662F\u5426\u7ACB\u5373\u5237\u65B0\u83B7\u53D6\u6700\u65B0\u5185\u5BB9\uFF1F",refreshButtonText:"\u7ACB\u5373\u5237\u65B0",dismissButtonText:"\u7A0D\u540E\u518D\u8BF4"}}validateOptions(){this.validator.field("versionSource").enum(["define","file","auto"]).field("promptStyle").enum(["modal","banner","toast"]).field("checkInterval").number().minValue(5e3).validate(),y(this.options)}getPluginName(){return"version-update-checker"}addPluginHooks(n){const u=C(this.options),t=x(this.options);n.transformIndexHtml={order:"post",handler:r=>{const o=b(r,t,u);return o.usedFallback&&this.logger.warn("\u672A\u627E\u5230 </body> \u6216 </html> \u6807\u7B7E\uFF0C\u7248\u672C\u66F4\u65B0\u68C0\u67E5\u4EE3\u7801\u8FFD\u52A0\u5230\u6587\u4EF6\u672B\u5C3E"),o.bodyInjected&&this.logger.success("\u6210\u529F\u6CE8\u5165\u7248\u672C\u66F4\u65B0\u68C0\u67E5\u4EE3\u7801\u5230 HTML \u6587\u4EF6"),o.html}}}}const w=d(B);export{w as versionUpdateChecker};
@@ -0,0 +1,3 @@
1
+ "use strict";class Validator{options;currentField=null;errors=[];constructor(u){this.options=u}field(u){const r=this;return r.currentField=u,r}required(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");return this.options[this.currentField]==null&&this.errors.push(`${String(this.currentField)} \u662F\u5FC5\u586B\u5B57\u6BB5`),this}string(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="string"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`),this}boolean(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="boolean"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5E03\u5C14\u7C7B\u578B`),this}number(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="number"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u6570\u5B57\u7C7B\u578B`),this}array(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&!Array.isArray(u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u6570\u7EC4\u7C7B\u578B`),this}object(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="object"&&!Array.isArray(u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5BF9\u8C61\u7C7B\u578B`),this}default(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");return this.options[this.currentField]==null&&(this.options[this.currentField]=u),this}enum(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const r=this.options[this.currentField];return r!=null&&r!==""&&!u.includes(r)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F ${u.join(", ")}`),this}minValue(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const r=this.options[this.currentField];return r!=null&&(typeof r!="number"||r<u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u4E0D\u5C0F\u4E8E ${u} \u7684\u6570\u5B57`),this}maxValue(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const r=this.options[this.currentField];return r!=null&&(typeof r!="number"||r>u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u4E0D\u5927\u4E8E ${u} \u7684\u6570\u5B57`),this}custom(u,r){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const t=this.options[this.currentField];return t!=null&&!u(t)&&this.errors.push(r),this}validate(){if(this.errors.length>0)throw new Error(`\u914D\u7F6E\u9A8C\u8BC1\u5931\u8D25\uFF1A
2
+ ${this.errors.map(u=>`- ${u}`).join(`
3
+ `)}`);return this.options}}exports.Validator=Validator;
@@ -73,6 +73,56 @@ declare class Validator<T extends Record<string, any>, K extends keyof T = any>
73
73
  * @returns Validator 实例,用于链式调用
74
74
  */
75
75
  default(defaultValue: T[K]): this;
76
+ /**
77
+ * 验证字段值是否在允许的枚举列表中
78
+ *
79
+ * @param allowedValues 允许的值列表
80
+ * @returns Validator 实例,用于链式调用
81
+ *
82
+ * @description 当字段值存在(非 undefined 且非 null 且非空字符串)时,
83
+ * 检查其是否在允许的枚举列表中。空值跳过验证。
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * validator
88
+ * .field('position').enum(['center', 'top', 'bottom'])
89
+ * .field('format').enum(['bar', 'spinner', 'minimal'])
90
+ * ```
91
+ */
92
+ enum(allowedValues: string[]): this;
93
+ /**
94
+ * 验证数字字段值是否不小于指定最小值
95
+ *
96
+ * @param min 最小值(包含)
97
+ * @returns Validator 实例,用于链式调用
98
+ *
99
+ * @description 当字段值存在(非 undefined 且非 null)时,
100
+ * 检查其是否为数字类型且不小于最小值。通常与 `.number()` 链式调用配合使用。
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * validator
105
+ * .field('checkInterval').number().minValue(5000)
106
+ * .field('width').number().minValue(1)
107
+ * ```
108
+ */
109
+ minValue(min: number): this;
110
+ /**
111
+ * 验证数字字段值是否不大于指定最大值
112
+ *
113
+ * @param max 最大值(包含)
114
+ * @returns Validator 实例,用于链式调用
115
+ *
116
+ * @description 当字段值存在(非 undefined 且非 null)时,
117
+ * 检查其是否为数字类型且不大于最大值。通常与 `.number()` 链式调用配合使用。
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * validator
122
+ * .field('hashLength').number().minValue(1).maxValue(32)
123
+ * ```
124
+ */
125
+ maxValue(max: number): this;
76
126
  /**
77
127
  * 使用自定义函数验证字段值
78
128
  * @param validator 自定义验证函数,返回 true 表示验证通过,返回 false 表示验证失败
@@ -73,6 +73,56 @@ declare class Validator<T extends Record<string, any>, K extends keyof T = any>
73
73
  * @returns Validator 实例,用于链式调用
74
74
  */
75
75
  default(defaultValue: T[K]): this;
76
+ /**
77
+ * 验证字段值是否在允许的枚举列表中
78
+ *
79
+ * @param allowedValues 允许的值列表
80
+ * @returns Validator 实例,用于链式调用
81
+ *
82
+ * @description 当字段值存在(非 undefined 且非 null 且非空字符串)时,
83
+ * 检查其是否在允许的枚举列表中。空值跳过验证。
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * validator
88
+ * .field('position').enum(['center', 'top', 'bottom'])
89
+ * .field('format').enum(['bar', 'spinner', 'minimal'])
90
+ * ```
91
+ */
92
+ enum(allowedValues: string[]): this;
93
+ /**
94
+ * 验证数字字段值是否不小于指定最小值
95
+ *
96
+ * @param min 最小值(包含)
97
+ * @returns Validator 实例,用于链式调用
98
+ *
99
+ * @description 当字段值存在(非 undefined 且非 null)时,
100
+ * 检查其是否为数字类型且不小于最小值。通常与 `.number()` 链式调用配合使用。
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * validator
105
+ * .field('checkInterval').number().minValue(5000)
106
+ * .field('width').number().minValue(1)
107
+ * ```
108
+ */
109
+ minValue(min: number): this;
110
+ /**
111
+ * 验证数字字段值是否不大于指定最大值
112
+ *
113
+ * @param max 最大值(包含)
114
+ * @returns Validator 实例,用于链式调用
115
+ *
116
+ * @description 当字段值存在(非 undefined 且非 null)时,
117
+ * 检查其是否为数字类型且不大于最大值。通常与 `.number()` 链式调用配合使用。
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * validator
122
+ * .field('hashLength').number().minValue(1).maxValue(32)
123
+ * ```
124
+ */
125
+ maxValue(max: number): this;
76
126
  /**
77
127
  * 使用自定义函数验证字段值
78
128
  * @param validator 自定义验证函数,返回 true 表示验证通过,返回 false 表示验证失败
@@ -73,6 +73,56 @@ declare class Validator<T extends Record<string, any>, K extends keyof T = any>
73
73
  * @returns Validator 实例,用于链式调用
74
74
  */
75
75
  default(defaultValue: T[K]): this;
76
+ /**
77
+ * 验证字段值是否在允许的枚举列表中
78
+ *
79
+ * @param allowedValues 允许的值列表
80
+ * @returns Validator 实例,用于链式调用
81
+ *
82
+ * @description 当字段值存在(非 undefined 且非 null 且非空字符串)时,
83
+ * 检查其是否在允许的枚举列表中。空值跳过验证。
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * validator
88
+ * .field('position').enum(['center', 'top', 'bottom'])
89
+ * .field('format').enum(['bar', 'spinner', 'minimal'])
90
+ * ```
91
+ */
92
+ enum(allowedValues: string[]): this;
93
+ /**
94
+ * 验证数字字段值是否不小于指定最小值
95
+ *
96
+ * @param min 最小值(包含)
97
+ * @returns Validator 实例,用于链式调用
98
+ *
99
+ * @description 当字段值存在(非 undefined 且非 null)时,
100
+ * 检查其是否为数字类型且不小于最小值。通常与 `.number()` 链式调用配合使用。
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * validator
105
+ * .field('checkInterval').number().minValue(5000)
106
+ * .field('width').number().minValue(1)
107
+ * ```
108
+ */
109
+ minValue(min: number): this;
110
+ /**
111
+ * 验证数字字段值是否不大于指定最大值
112
+ *
113
+ * @param max 最大值(包含)
114
+ * @returns Validator 实例,用于链式调用
115
+ *
116
+ * @description 当字段值存在(非 undefined 且非 null)时,
117
+ * 检查其是否为数字类型且不大于最大值。通常与 `.number()` 链式调用配合使用。
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * validator
122
+ * .field('hashLength').number().minValue(1).maxValue(32)
123
+ * ```
124
+ */
125
+ maxValue(max: number): this;
76
126
  /**
77
127
  * 使用自定义函数验证字段值
78
128
  * @param validator 自定义验证函数,返回 true 表示验证通过,返回 false 表示验证失败
@@ -1,3 +1,3 @@
1
- function s(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)&&Object.prototype.toString.call(i)==="[object Object]"}function o(...i){const u={};for(const r of i)if(r)for(const t in r){if(!Object.prototype.hasOwnProperty.call(r,t))continue;const e=r[t],n=u[t];e!==void 0&&(s(e)&&s(n)?u[t]=o(n,e):u[t]=e)}return u}class l{options;currentField=null;errors=[];constructor(u){this.options=u}field(u){const r=this;return r.currentField=u,r}required(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");return this.options[this.currentField]==null&&this.errors.push(`${String(this.currentField)} \u662F\u5FC5\u586B\u5B57\u6BB5`),this}string(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="string"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`),this}boolean(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="boolean"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5E03\u5C14\u7C7B\u578B`),this}number(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="number"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u6570\u5B57\u7C7B\u578B`),this}array(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&!Array.isArray(u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u6570\u7EC4\u7C7B\u578B`),this}object(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="object"&&!Array.isArray(u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5BF9\u8C61\u7C7B\u578B`),this}default(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");return this.options[this.currentField]==null&&(this.options[this.currentField]=u),this}custom(u,r){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const t=this.options[this.currentField];return t!=null&&!u(t)&&this.errors.push(r),this}validate(){if(this.errors.length>0)throw new Error(`\u914D\u7F6E\u9A8C\u8BC1\u5931\u8D25\uFF1A
1
+ class i{options;currentField=null;errors=[];constructor(u){this.options=u}field(u){const r=this;return r.currentField=u,r}required(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");return this.options[this.currentField]==null&&this.errors.push(`${String(this.currentField)} \u662F\u5FC5\u586B\u5B57\u6BB5`),this}string(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="string"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`),this}boolean(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="boolean"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5E03\u5C14\u7C7B\u578B`),this}number(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="number"&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u6570\u5B57\u7C7B\u578B`),this}array(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&!Array.isArray(u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u6570\u7EC4\u7C7B\u578B`),this}object(){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const u=this.options[this.currentField];return u!=null&&typeof u!="object"&&!Array.isArray(u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u5BF9\u8C61\u7C7B\u578B`),this}default(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");return this.options[this.currentField]==null&&(this.options[this.currentField]=u),this}enum(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const r=this.options[this.currentField];return r!=null&&r!==""&&!u.includes(r)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F ${u.join(", ")}`),this}minValue(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const r=this.options[this.currentField];return r!=null&&(typeof r!="number"||r<u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u4E0D\u5C0F\u4E8E ${u} \u7684\u6570\u5B57`),this}maxValue(u){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const r=this.options[this.currentField];return r!=null&&(typeof r!="number"||r>u)&&this.errors.push(`${String(this.currentField)} \u5FC5\u987B\u662F\u4E0D\u5927\u4E8E ${u} \u7684\u6570\u5B57`),this}custom(u,r){if(this.currentField===null)throw new Error("\u5FC5\u987B\u5148\u8C03\u7528 field() \u65B9\u6CD5\u6307\u5B9A\u8981\u9A8C\u8BC1\u7684\u5B57\u6BB5");const t=this.options[this.currentField];return t!=null&&!u(t)&&this.errors.push(r),this}validate(){if(this.errors.length>0)throw new Error(`\u914D\u7F6E\u9A8C\u8BC1\u5931\u8D25\uFF1A
2
2
  ${this.errors.map(u=>`- ${u}`).join(`
3
- `)}`);return this.options}}export{l as V,o as d};
3
+ `)}`);return this.options}}export{i as V};
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@meng-xi/vite-plugin",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "private": false,
6
- "description": "一个为 Vite 提供的插件库",
6
+ "description": "一个为 Vite 提供实用插件的工具包,同时也是一个完整的插件开发框架",
7
7
  "keywords": [
8
8
  "@meng-xi/vite-plugin",
9
9
  "meng-xi",
@@ -25,6 +25,36 @@
25
25
  "import": "./dist/common/index.mjs",
26
26
  "types": "./dist/common/index.d.ts"
27
27
  },
28
+ "./common/format": {
29
+ "require": "./dist/common/format/index.cjs",
30
+ "import": "./dist/common/format/index.mjs",
31
+ "types": "./dist/common/format/index.d.ts"
32
+ },
33
+ "./common/fs": {
34
+ "require": "./dist/common/fs/index.cjs",
35
+ "import": "./dist/common/fs/index.mjs",
36
+ "types": "./dist/common/fs/index.d.ts"
37
+ },
38
+ "./common/html": {
39
+ "require": "./dist/common/html/index.cjs",
40
+ "import": "./dist/common/html/index.mjs",
41
+ "types": "./dist/common/html/index.d.ts"
42
+ },
43
+ "./common/object": {
44
+ "require": "./dist/common/object/index.cjs",
45
+ "import": "./dist/common/object/index.mjs",
46
+ "types": "./dist/common/object/index.d.ts"
47
+ },
48
+ "./common/script": {
49
+ "require": "./dist/common/script/index.cjs",
50
+ "import": "./dist/common/script/index.mjs",
51
+ "types": "./dist/common/script/index.d.ts"
52
+ },
53
+ "./common/validation": {
54
+ "require": "./dist/common/validation/index.cjs",
55
+ "import": "./dist/common/validation/index.mjs",
56
+ "types": "./dist/common/validation/index.d.ts"
57
+ },
28
58
  "./factory": {
29
59
  "require": "./dist/factory/index.cjs",
30
60
  "import": "./dist/factory/index.mjs",
@@ -39,6 +69,51 @@
39
69
  "require": "./dist/plugins/index.cjs",
40
70
  "import": "./dist/plugins/index.mjs",
41
71
  "types": "./dist/plugins/index.d.ts"
72
+ },
73
+ "./plugins/build-progress": {
74
+ "require": "./dist/plugins/buildProgress/index.cjs",
75
+ "import": "./dist/plugins/buildProgress/index.mjs",
76
+ "types": "./dist/plugins/buildProgress/index.d.ts"
77
+ },
78
+ "./plugins/compress-assets": {
79
+ "require": "./dist/plugins/compressAssets/index.cjs",
80
+ "import": "./dist/plugins/compressAssets/index.mjs",
81
+ "types": "./dist/plugins/compressAssets/index.d.ts"
82
+ },
83
+ "./plugins/copy-file": {
84
+ "require": "./dist/plugins/copyFile/index.cjs",
85
+ "import": "./dist/plugins/copyFile/index.mjs",
86
+ "types": "./dist/plugins/copyFile/index.d.ts"
87
+ },
88
+ "./plugins/favicon-manager": {
89
+ "require": "./dist/plugins/faviconManager/index.cjs",
90
+ "import": "./dist/plugins/faviconManager/index.mjs",
91
+ "types": "./dist/plugins/faviconManager/index.d.ts"
92
+ },
93
+ "./plugins/generate-router": {
94
+ "require": "./dist/plugins/generateRouter/index.cjs",
95
+ "import": "./dist/plugins/generateRouter/index.mjs",
96
+ "types": "./dist/plugins/generateRouter/index.d.ts"
97
+ },
98
+ "./plugins/generate-version": {
99
+ "require": "./dist/plugins/generateVersion/index.cjs",
100
+ "import": "./dist/plugins/generateVersion/index.mjs",
101
+ "types": "./dist/plugins/generateVersion/index.d.ts"
102
+ },
103
+ "./plugins/html-inject": {
104
+ "require": "./dist/plugins/htmlInject/index.cjs",
105
+ "import": "./dist/plugins/htmlInject/index.mjs",
106
+ "types": "./dist/plugins/htmlInject/index.d.ts"
107
+ },
108
+ "./plugins/loading-manager": {
109
+ "require": "./dist/plugins/loadingManager/index.cjs",
110
+ "import": "./dist/plugins/loadingManager/index.mjs",
111
+ "types": "./dist/plugins/loadingManager/index.d.ts"
112
+ },
113
+ "./plugins/version-update-checker": {
114
+ "require": "./dist/plugins/versionUpdateChecker/index.cjs",
115
+ "import": "./dist/plugins/versionUpdateChecker/index.mjs",
116
+ "types": "./dist/plugins/versionUpdateChecker/index.d.ts"
42
117
  }
43
118
  },
44
119
  "files": [
@@ -48,13 +123,15 @@
48
123
  ],
49
124
  "scripts": {
50
125
  "dev": "unbuild --watch",
51
- "build": "unbuild"
126
+ "build": "tsx scripts/generate-exports.ts && unbuild",
127
+ "generate-exports": "tsx scripts/generate-exports.ts"
52
128
  },
53
129
  "peerDependencies": {
54
130
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
55
131
  },
56
132
  "devDependencies": {
57
133
  "@types/node": "^22.0.0",
134
+ "tsx": "^4.22.3",
58
135
  "unbuild": "^3.6.0",
59
136
  "typescript": "^5.9.3"
60
137
  },
@@ -1 +0,0 @@
1
- "use strict";const logger_index=require("../logger/index.cjs");require("fs"),require("path"),require("crypto");const validation=require("./vite-plugin.IGZeStMa.cjs");class BasePlugin{options;logger;validator;viteConfig=null;constructor(e,r){this.options=this.mergeOptions(e),this.logger=this.initLogger(r),this.validator=new validation.Validator(this.options),this.safeExecuteSync(()=>this.validateOptions(),"\u63D2\u4EF6\u914D\u7F6E\u9A8C\u8BC1")}getDefaultOptions(){return{}}mergeOptions(e){const r={enabled:!0,verbose:!0,errorStrategy:"throw"},t=this.getDefaultOptions();return validation.deepMerge(r,t,e)}initLogger(e){return logger_index.Logger.create({name:this.getPluginName(),enabled:this.options.verbose,...e}).createPluginLogger(this.getPluginName())}validateOptions(){}getEnforce(){}onConfigResolved(e){this.viteConfig=e,this.logger.info("\u914D\u7F6E\u89E3\u6790\u5B8C\u6210\uFF0C\u63D2\u4EF6\u5DF2\u521D\u59CB\u5316")}destroy(){logger_index.Logger.unregister(this.getPluginName())}safeExecuteSync(e,r){try{return e()}catch(t){return this.handleError(t,r)}}async safeExecute(e,r){try{return await e()}catch(t){return this.handleError(t,r)}}handleError(e,r){let t=`${r}: `;switch(e instanceof Error?t+=e.message:typeof e=="string"?t+=e:t+=String(e),this.options.errorStrategy){case"throw":throw this.logger.error(t),e;case"log":case"ignore":this.logger.error(t);return;default:throw this.logger.error(t),e}}toPlugin(){const e={name:this.getPluginName(),enforce:this.getEnforce()};this.addPluginHooks(e);const r=e.configResolved;e.configResolved=o=>{this.options.enabled&&(this.onConfigResolved(o),typeof r=="function"&&r(o))};const t=this,n=e.closeBundle;return e.closeBundle=function(){typeof n=="function"&&n.call(this),t.destroy()},e}}function createPluginFactory(i,e){return r=>{const t=e?e(r):r,n=new i(t),o=n.toPlugin();return o.pluginInstance=n,o}}exports.BasePlugin=BasePlugin,exports.createPluginFactory=createPluginFactory;