@amaster.ai/vite-plugins 1.1.0-beta.6 → 1.1.0-beta.61
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 +304 -382
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -34
- package/dist/index.d.ts +55 -34
- package/dist/index.js +304 -382
- package/dist/index.js.map +1 -1
- package/package.json +22 -6
- package/dist/bridge.bridge.js +0 -24
package/dist/index.cjs
CHANGED
|
@@ -1,30 +1,110 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var m=require('fs'),d=require('path'),C=require('process'),S=require('fs/promises');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var m__default=/*#__PURE__*/_interopDefault(m);var d__default=/*#__PURE__*/_interopDefault(d);var C__default=/*#__PURE__*/_interopDefault(C);var S__default=/*#__PURE__*/_interopDefault(S);var R="@amaster/bridge-monitor",x="\0"+R;function A(){return '<script type="module" src="/@id/@amaster/bridge-monitor"></script>'}function L(r){return `
|
|
2
|
+
// Bridge monitor module - handles all bridge logic
|
|
3
|
+
const SOURCE_KEY = Symbol.for("__jsxSource__");
|
|
4
|
+
const SESSION_KEY = "${r}";
|
|
5
|
+
|
|
6
|
+
// Expose minimal API for external bridge script
|
|
7
|
+
window.__AMASTER_BRIDGE__ = {
|
|
8
|
+
getSourceInfo: (element) => element?.[SOURCE_KEY],
|
|
9
|
+
getSourceMap: () => window.sourceElementMap,
|
|
10
|
+
postToParent: (type, data) => {
|
|
11
|
+
window.parent.postMessage({ type, data, key: SESSION_KEY }, "*");
|
|
12
|
+
},
|
|
13
|
+
isDev: true,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Listen for HMR updates
|
|
17
|
+
if (import.meta.hot) {
|
|
18
|
+
import.meta.hot.on('vite:afterUpdate', (payload) => {
|
|
19
|
+
// Dispatch custom event for bridge.js to listen
|
|
20
|
+
window.dispatchEvent(new CustomEvent('amaster:hmr-update', {
|
|
21
|
+
detail: {
|
|
22
|
+
updates: payload?.updates || []
|
|
13
23
|
}
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Import and monitor Tailwind config
|
|
29
|
+
(async () => {
|
|
30
|
+
try {
|
|
31
|
+
const tailwindConfig = await import('@amaster/tailwind-config');
|
|
32
|
+
let config = tailwindConfig.default;
|
|
33
|
+
const onUpdate = tailwindConfig.onUpdate;
|
|
34
|
+
|
|
35
|
+
if (!config) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const sendConfig = (type, newConfig) => {
|
|
40
|
+
config = newConfig || config;
|
|
41
|
+
const serializableConfig = JSON.parse(JSON.stringify(config));
|
|
42
|
+
|
|
43
|
+
// Dispatch event for bridge.js to handle
|
|
44
|
+
window.dispatchEvent(new CustomEvent('amaster:tailwind-config', {
|
|
45
|
+
detail: {
|
|
46
|
+
type: type,
|
|
47
|
+
config: serializableConfig
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Send initial config
|
|
53
|
+
sendConfig('loaded');
|
|
54
|
+
|
|
55
|
+
// Listen for bridge ready event and resend config
|
|
56
|
+
window.addEventListener('amaster:bridge-ready', () => {
|
|
57
|
+
sendConfig('loaded');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Listen for config updates
|
|
61
|
+
if (onUpdate) {
|
|
62
|
+
onUpdate((newConfig) => {
|
|
63
|
+
sendConfig('updated', newConfig);
|
|
64
|
+
});
|
|
14
65
|
}
|
|
15
|
-
}
|
|
16
|
-
|
|
66
|
+
} catch (e) {
|
|
67
|
+
// Silently fail if tailwind config is not available
|
|
68
|
+
}
|
|
69
|
+
})();
|
|
70
|
+
|
|
71
|
+
// Listen for bridge script URL from platform
|
|
72
|
+
window.addEventListener("message", (event) => {
|
|
73
|
+
const { type, data, key } = event.data;
|
|
74
|
+
|
|
75
|
+
if (key !== SESSION_KEY) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (type === "amaster.loadBridge" && data?.scriptContent) {
|
|
80
|
+
// Create blob URL from script content
|
|
81
|
+
const blob = new Blob([data.scriptContent], { type: 'application/javascript' });
|
|
82
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
83
|
+
|
|
84
|
+
const script = document.createElement("script");
|
|
85
|
+
script.src = blobUrl;
|
|
86
|
+
script.onload = () => {
|
|
87
|
+
URL.revokeObjectURL(blobUrl);
|
|
88
|
+
};
|
|
89
|
+
script.onerror = () => {
|
|
90
|
+
URL.revokeObjectURL(blobUrl);
|
|
91
|
+
};
|
|
92
|
+
document.head.appendChild(script);
|
|
17
93
|
}
|
|
18
94
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
95
|
+
|
|
96
|
+
window.addEventListener("DOMContentLoaded", () => {
|
|
97
|
+
window.__AMASTER_BRIDGE__?.postToParent("amaster.bridge.initialized", {});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export default {};
|
|
101
|
+
`}function O(){let r=false;return {name:"vite-plugin-editor-bridge",configResolved(n){r=n.command==="serve";},resolveId(n){if(n===R)return x},load(n){if(n===x){let e=process.env.VITE_AMASTER_KEY||"";return L(e)}},transformIndexHtml(n){if(!r)return n;let e=A();return n.replace("</body>",`${e}</body>`)}}}function T(r){let n=false,e=r?.routesFilePath||"src/routes.tsx";return {name:"vite-plugin-routes-expose",enforce:"post",configResolved(t){n=t.command==="serve";},transform(t,o){if(!n||!o.endsWith(e))return null;try{return t.includes("window.__APP_ROUTES__")?null:{code:`${t}
|
|
22
102
|
|
|
23
103
|
// Development mode: Expose routes to window.__APP_ROUTES__
|
|
24
104
|
if (typeof window !== 'undefined') {
|
|
25
105
|
window.__APP_ROUTES__ = typeof routes !== 'undefined' && Array.isArray(routes) ? routes : [];
|
|
26
106
|
}
|
|
27
|
-
`,map:null}}catch{return null}}}}function
|
|
107
|
+
`,map:null}}catch{return null}}}}function P(){let r="",n=`
|
|
28
108
|
<script>
|
|
29
109
|
(function() {
|
|
30
110
|
'use strict';
|
|
@@ -32,6 +112,9 @@ if (typeof window !== 'undefined') {
|
|
|
32
112
|
// Log API path (provided by Vite dev server)
|
|
33
113
|
var LOG_API_PATH = '/__browser__';
|
|
34
114
|
|
|
115
|
+
// Save original fetch before any interception, used exclusively for log writing
|
|
116
|
+
var __originalFetch__ = window.fetch.bind(window);
|
|
117
|
+
|
|
35
118
|
// Write queue to ensure sequential writes
|
|
36
119
|
var writeQueue = [];
|
|
37
120
|
var isWriting = false;
|
|
@@ -44,7 +127,7 @@ if (typeof window !== 'undefined') {
|
|
|
44
127
|
var entry = writeQueue.shift();
|
|
45
128
|
var logText = JSON.stringify(entry);
|
|
46
129
|
|
|
47
|
-
|
|
130
|
+
__originalFetch__(LOG_API_PATH, {
|
|
48
131
|
method: 'POST',
|
|
49
132
|
headers: { 'Content-Type': 'application/json' },
|
|
50
133
|
body: logText
|
|
@@ -162,12 +245,19 @@ if (typeof window !== 'undefined') {
|
|
|
162
245
|
};
|
|
163
246
|
}
|
|
164
247
|
|
|
165
|
-
//
|
|
248
|
+
// Keywords to filter from console log collection
|
|
249
|
+
var FILTERED_CONSOLE_KEYWORDS = ['[vite]', '[BrowserLogs]'];
|
|
250
|
+
|
|
251
|
+
// Check if message should be filtered
|
|
166
252
|
function shouldFilterConsoleLog(args) {
|
|
167
253
|
for (var i = 0; i < args.length; i++) {
|
|
168
254
|
var arg = args[i];
|
|
169
|
-
if (typeof arg === 'string'
|
|
170
|
-
|
|
255
|
+
if (typeof arg === 'string') {
|
|
256
|
+
for (var j = 0; j < FILTERED_CONSOLE_KEYWORDS.length; j++) {
|
|
257
|
+
if (arg.indexOf(FILTERED_CONSOLE_KEYWORDS[j]) !== -1) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
171
261
|
}
|
|
172
262
|
}
|
|
173
263
|
return false;
|
|
@@ -705,403 +795,235 @@ if (typeof window !== 'undefined') {
|
|
|
705
795
|
|
|
706
796
|
originalConsole.log('[BrowserLogs] Log collection started');
|
|
707
797
|
})();
|
|
708
|
-
</script>`;return {name:"vite-plugin-browser-logs",configResolved(
|
|
709
|
-
`,"utf-8"),o.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
'use strict';
|
|
798
|
+
</script>`;return {name:"vite-plugin-browser-logs",configResolved(e){let t=C__default.default.env.WORKSPACE_DIR;if(t)r=d__default.default.join(t,"browser.log");else {let o=e.root||C__default.default.cwd();for(;o!==d__default.default.dirname(o)&&!m__default.default.existsSync(d__default.default.join(o,"package.json"));)o=d__default.default.dirname(o);r=d__default.default.join(o,"browser.log");}},configureServer(e){e.middlewares.use((t,o,l)=>{if(t.url==="/__browser__"&&t.method==="POST"){let i=t.headers.origin||"*",u="";t.on("data",c=>{u+=c.toString();}),t.on("end",()=>{try{let c=d__default.default.dirname(r);m__default.default.existsSync(c)||m__default.default.mkdirSync(c,{recursive:!0}),m__default.default.appendFileSync(r,`${u}
|
|
799
|
+
`,"utf-8"),o.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":i,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),o.end(JSON.stringify({success:!0}));}catch(c){console.error("[BrowserLogs] Write error:",c),o.writeHead(500,{"Content-Type":"application/json","Access-Control-Allow-Origin":i,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),o.end(JSON.stringify({success:false,error:String(c)}));}});}else if(t.url==="/__browser__"&&t.method==="OPTIONS"){let i=t.headers.origin||"*";o.writeHead(204,{"Access-Control-Allow-Origin":i,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type","Access-Control-Max-Age":"86400"}),o.end();}else if(t.url==="/__browser__"){let i=t.headers.origin||"*";o.writeHead(405,{"Content-Type":"application/json","Access-Control-Allow-Origin":i}),o.end(JSON.stringify({error:"Method not allowed"}));}else l();}),console.log("[BrowserLogs] Logs will be written to:",r);},transformIndexHtml(e){return e.replace(/<head([^>]*)>/i,`<head$1>${n}`)}}}var j=`
|
|
800
|
+
import * as React from "react";
|
|
801
|
+
import * as ReactJSXDevRuntime from "react/jsx-dev-runtime";
|
|
713
802
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
var DISCONNECT_DETECT_WINDOW = 300;
|
|
717
|
-
// WebSocket \u65AD\u5F00\u540E\u7B49\u5F85\u91CD\u8FDE\u7684\u8D85\u65F6\u65F6\u95F4\uFF08ms\uFF09\uFF0C\u8D85\u65F6\u540E fallback \u5230 full-reload
|
|
718
|
-
var RECONNECT_TIMEOUT = 5000;
|
|
719
|
-
// \u91CD\u8FDE\u6210\u529F\u540E\uFF0C\u7B49\u5F85\u662F\u5426\u6709 full-reload/update \u6D88\u606F\u7684\u7A97\u53E3\u671F\uFF08ms\uFF09
|
|
720
|
-
var POST_RECONNECT_WINDOW = 2000;
|
|
721
|
-
// \u6291\u5236 location.reload \u540E\u7684\u6700\u5927\u7A97\u53E3\u671F\uFF08ms\uFF09\uFF0C\u8D85\u65F6\u540E\u6267\u884C soft-reload \u6062\u590D HMR
|
|
722
|
-
var RELOAD_SUPPRESS_WINDOW = 5000;
|
|
723
|
-
// soft-reload \u5EF6\u8FDF\uFF08ms\uFF09
|
|
724
|
-
var SOFT_RELOAD_DELAY = 300;
|
|
803
|
+
const _jsxDEV = ReactJSXDevRuntime.jsxDEV;
|
|
804
|
+
export const Fragment = ReactJSXDevRuntime.Fragment;
|
|
725
805
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
// ============================================
|
|
729
|
-
var state = {
|
|
730
|
-
// \u662F\u5426\u5DF2\u7ECF\u62E6\u622A\u4E86 Vite HMR WebSocket
|
|
731
|
-
wsIntercepted: false,
|
|
732
|
-
// \u662F\u5426\u6B63\u5728\u7B49\u5F85\u5224\u65AD full-reload \u7C7B\u578B\uFF08300ms \u7A97\u53E3\u671F\uFF09
|
|
733
|
-
detectingReloadType: false,
|
|
734
|
-
// \u5EF6\u8FDF\u6267\u884C full-reload \u7684\u5B9A\u65F6\u5668
|
|
735
|
-
reloadTimer: null,
|
|
736
|
-
// \u662F\u5426\u6B63\u5728\u7B49\u5F85\u670D\u52A1\u5668\u91CD\u8FDE
|
|
737
|
-
waitingForReconnect: false,
|
|
738
|
-
// \u662F\u5426\u662F\u670D\u52A1\u5668\u91CD\u542F\u573A\u666F
|
|
739
|
-
isServerRestart: false,
|
|
740
|
-
// \u91CD\u8FDE\u8D85\u65F6\u5B9A\u65F6\u5668
|
|
741
|
-
reconnectTimeoutTimer: null,
|
|
742
|
-
// \u91CD\u8FDE\u540E\u7B49\u5F85\u53D8\u66F4\u7684\u5B9A\u65F6\u5668
|
|
743
|
-
postReconnectTimer: null,
|
|
744
|
-
// \u662F\u5426\u6B63\u5728\u6291\u5236 location.reload
|
|
745
|
-
suppressingReload: false,
|
|
746
|
-
// \u6291\u5236 reload \u7684\u5B9A\u65F6\u5668
|
|
747
|
-
suppressReloadTimer: null,
|
|
748
|
-
// \u5DF2\u62E6\u622A\u7684 reload \u6B21\u6570\uFF08\u7528\u4E8E\u8C03\u8BD5\uFF09
|
|
749
|
-
suppressedReloadCount: 0
|
|
750
|
-
};
|
|
806
|
+
const SOURCE_KEY = Symbol.for("__jsxSource__");
|
|
807
|
+
const PROJECT_ROOT = "";
|
|
751
808
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
//
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
args.push(arguments[i]);
|
|
759
|
-
}
|
|
760
|
-
console.debug.apply(console, args);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
// ============================================
|
|
764
|
-
// \u6E05\u9664\u6240\u6709\u5B9A\u65F6\u5668
|
|
765
|
-
// ============================================
|
|
766
|
-
function clearAllTimers() {
|
|
767
|
-
if (state.reloadTimer) {
|
|
768
|
-
clearTimeout(state.reloadTimer);
|
|
769
|
-
state.reloadTimer = null;
|
|
770
|
-
}
|
|
771
|
-
if (state.reconnectTimeoutTimer) {
|
|
772
|
-
clearTimeout(state.reconnectTimeoutTimer);
|
|
773
|
-
state.reconnectTimeoutTimer = null;
|
|
774
|
-
}
|
|
775
|
-
if (state.postReconnectTimer) {
|
|
776
|
-
clearTimeout(state.postReconnectTimer);
|
|
777
|
-
state.postReconnectTimer = null;
|
|
778
|
-
}
|
|
779
|
-
if (state.suppressReloadTimer) {
|
|
780
|
-
clearTimeout(state.suppressReloadTimer);
|
|
781
|
-
state.suppressReloadTimer = null;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
// ============================================
|
|
786
|
-
// \u91CD\u7F6E\u72B6\u6001
|
|
787
|
-
// ============================================
|
|
788
|
-
function resetState() {
|
|
789
|
-
state.detectingReloadType = false;
|
|
790
|
-
state.isServerRestart = false;
|
|
791
|
-
state.waitingForReconnect = false;
|
|
792
|
-
state.suppressingReload = false;
|
|
793
|
-
state.suppressedReloadCount = 0;
|
|
794
|
-
clearAllTimers();
|
|
809
|
+
const cleanFileName = (fileName) => {
|
|
810
|
+
if (!fileName) return "";
|
|
811
|
+
// Remove project root prefix to get relative path
|
|
812
|
+
if (PROJECT_ROOT && fileName.startsWith(PROJECT_ROOT)) {
|
|
813
|
+
const relative = fileName.slice(PROJECT_ROOT.length);
|
|
814
|
+
return relative.startsWith("/") ? relative.slice(1) : relative;
|
|
795
815
|
}
|
|
816
|
+
return fileName;
|
|
817
|
+
};
|
|
796
818
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
function executeFullReload() {
|
|
801
|
-
log('Executing full-reload');
|
|
802
|
-
resetState();
|
|
803
|
-
originalLocationReload.call(window.location);
|
|
804
|
-
}
|
|
819
|
+
// Global map to track elements by source location
|
|
820
|
+
const sourceElementMap = new Map();
|
|
821
|
+
window.sourceElementMap = sourceElementMap;
|
|
805
822
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
// \u9700\u8981\u901A\u8FC7 reload \u6062\u590D HMR\u3002
|
|
810
|
-
// ============================================
|
|
811
|
-
function scheduleSoftReload() {
|
|
812
|
-
log('Scheduling soft-reload to restore HMR connection');
|
|
813
|
-
setTimeout(function() {
|
|
814
|
-
resetState();
|
|
815
|
-
originalLocationReload.call(window.location);
|
|
816
|
-
}, SOFT_RELOAD_DELAY);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// ============================================
|
|
820
|
-
// \u62E6\u622A location.reload
|
|
821
|
-
// Vite \u5BA2\u6237\u7AEF\u5728 HTTP ping \u6210\u529F\u540E\u4F1A\u76F4\u63A5\u8C03\u7528 location.reload()
|
|
822
|
-
// \u6211\u4EEC\u9700\u8981\u5728\u670D\u52A1\u5668\u91CD\u542F\u671F\u95F4\u62E6\u622A\u8FD9\u4E2A\u8C03\u7528
|
|
823
|
-
// ============================================
|
|
824
|
-
var originalLocationReload = window.location.reload.bind(window.location);
|
|
825
|
-
|
|
826
|
-
try {
|
|
827
|
-
Object.defineProperty(window.location, 'reload', {
|
|
828
|
-
value: function smartReloadInterceptedReload() {
|
|
829
|
-
if (state.suppressingReload || state.waitingForReconnect || state.isServerRestart) {
|
|
830
|
-
state.suppressedReloadCount++;
|
|
831
|
-
log('Suppressed location.reload() during server restart (count: ' + state.suppressedReloadCount + ')');
|
|
832
|
-
|
|
833
|
-
// \u9632\u6296\uFF1A\u6BCF\u6B21\u88AB\u8C03\u7528\u90FD\u91CD\u7F6E\u5B9A\u65F6\u5668
|
|
834
|
-
if (state.suppressReloadTimer) {
|
|
835
|
-
clearTimeout(state.suppressReloadTimer);
|
|
836
|
-
}
|
|
837
|
-
state.suppressReloadTimer = setTimeout(function() {
|
|
838
|
-
if (state.suppressingReload || state.isServerRestart) {
|
|
839
|
-
log('Reload suppress window expired, performing soft-reload');
|
|
840
|
-
scheduleSoftReload();
|
|
841
|
-
}
|
|
842
|
-
}, RELOAD_SUPPRESS_WINDOW);
|
|
843
|
-
|
|
844
|
-
return;
|
|
845
|
-
}
|
|
846
|
-
return originalLocationReload.call(window.location);
|
|
847
|
-
},
|
|
848
|
-
writable: true,
|
|
849
|
-
configurable: true
|
|
850
|
-
});
|
|
851
|
-
log('location.reload intercepted via defineProperty');
|
|
852
|
-
} catch (e) {
|
|
853
|
-
// \u67D0\u4E9B\u6D4F\u89C8\u5668\u73AF\u5883\u53EF\u80FD\u4E0D\u5141\u8BB8\u4FEE\u6539 location.reload
|
|
854
|
-
// \u6B64\u65F6\u63D2\u4EF6\u7684 WebSocket \u6D88\u606F\u62E6\u622A\u4ECD\u7136\u6709\u6548\uFF0C\u53EA\u662F\u65E0\u6CD5\u62E6\u622A Vite \u7684 HTTP ping \u540E\u7684 reload
|
|
855
|
-
log('Failed to intercept location.reload (plugin will have limited effectiveness):', e.message);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
// ============================================
|
|
859
|
-
// \u8FDB\u5165\u670D\u52A1\u5668\u91CD\u542F\u7B49\u5F85\u6A21\u5F0F
|
|
860
|
-
// ============================================
|
|
861
|
-
function enterServerRestartMode(reason) {
|
|
862
|
-
log('Entering server restart mode:', reason);
|
|
863
|
-
|
|
864
|
-
state.isServerRestart = true;
|
|
865
|
-
state.waitingForReconnect = true;
|
|
866
|
-
state.suppressingReload = true;
|
|
867
|
-
state.detectingReloadType = false;
|
|
823
|
+
function getSourceKey(sourceInfo) {
|
|
824
|
+
return \`\${cleanFileName(sourceInfo.fileName)}:\${sourceInfo.lineNumber}:\${sourceInfo.columnNumber}\`;
|
|
825
|
+
}
|
|
868
826
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
827
|
+
function unregisterElement(node, sourceInfo) {
|
|
828
|
+
const key = getSourceKey(sourceInfo);
|
|
829
|
+
const refs = sourceElementMap.get(key);
|
|
830
|
+
if (refs) {
|
|
831
|
+
for (const ref of refs) {
|
|
832
|
+
if (ref.deref() === node) {
|
|
833
|
+
refs.delete(ref);
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
872
836
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
if (state.reconnectTimeoutTimer) {
|
|
876
|
-
clearTimeout(state.reconnectTimeoutTimer);
|
|
837
|
+
if (refs.size === 0) {
|
|
838
|
+
sourceElementMap.delete(key);
|
|
877
839
|
}
|
|
878
|
-
state.reconnectTimeoutTimer = setTimeout(function() {
|
|
879
|
-
if (state.waitingForReconnect || state.isServerRestart) {
|
|
880
|
-
log('Reconnect timeout (' + RECONNECT_TIMEOUT + 'ms), performing full-reload as fallback');
|
|
881
|
-
executeFullReload();
|
|
882
|
-
}
|
|
883
|
-
}, RECONNECT_TIMEOUT);
|
|
884
840
|
}
|
|
841
|
+
}
|
|
885
842
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
function isViteHmrWebSocket(url) {
|
|
892
|
-
if (typeof url !== 'string') return false;
|
|
893
|
-
// \u53EA\u5339\u914D Vite HMR \u7279\u5F81\u7684 URL
|
|
894
|
-
return url.includes('/__vite_hmr') || url.includes('?token=');
|
|
843
|
+
function registerElement(node, sourceInfo) {
|
|
844
|
+
const key = getSourceKey(sourceInfo);
|
|
845
|
+
if (!sourceElementMap.has(key)) {
|
|
846
|
+
sourceElementMap.set(key, new Set());
|
|
895
847
|
}
|
|
848
|
+
sourceElementMap.get(key).add(new WeakRef(node));
|
|
849
|
+
}
|
|
896
850
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (!intercepted) {
|
|
906
|
-
listener.call(ws, event);
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
listener.__smartReloadWrapped__ = wrappedListener;
|
|
910
|
-
return originalAddEventListener(type, wrappedListener, options);
|
|
911
|
-
}
|
|
912
|
-
return originalAddEventListener(type, listener, options);
|
|
913
|
-
};
|
|
851
|
+
function getTypeName(type) {
|
|
852
|
+
if (typeof type === "string") return type;
|
|
853
|
+
if (typeof type === "function") return type.displayName || type.name || "Unknown";
|
|
854
|
+
if (typeof type === "object" && type !== null) {
|
|
855
|
+
return type.displayName || type.render?.displayName || type.render?.name || "Unknown";
|
|
856
|
+
}
|
|
857
|
+
return "Unknown";
|
|
858
|
+
}
|
|
914
859
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
860
|
+
export function jsxDEV(type, props, key, isStatic, source, self) {
|
|
861
|
+
// For custom components, tag their rendered output
|
|
862
|
+
if (source?.fileName && typeof type !== "string" && type !== Fragment) {
|
|
863
|
+
const typeName = getTypeName(type);
|
|
864
|
+
const fileName = cleanFileName(source.fileName);
|
|
865
|
+
|
|
866
|
+
const jsxSourceInfo = {
|
|
867
|
+
fileName,
|
|
868
|
+
lineNumber: source.lineNumber,
|
|
869
|
+
columnNumber: source.columnNumber,
|
|
870
|
+
displayName: typeName,
|
|
871
|
+
isComponent: true,
|
|
920
872
|
};
|
|
921
873
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
874
|
+
const originalRef = props?.ref;
|
|
875
|
+
|
|
876
|
+
// Check if component can safely receive refs
|
|
877
|
+
// - forwardRef components have $$typeof symbol
|
|
878
|
+
// - Class components have prototype.isReactComponent
|
|
879
|
+
// - If there's already a ref, the component expects it
|
|
880
|
+
const isForwardRef = type.$$typeof === Symbol.for('react.forward_ref');
|
|
881
|
+
const isClassComponent = typeof type === 'function' && type.prototype?.isReactComponent;
|
|
882
|
+
const hasExistingRef = originalRef !== undefined;
|
|
883
|
+
|
|
884
|
+
const canReceiveRef = isForwardRef || isClassComponent || hasExistingRef;
|
|
885
|
+
|
|
886
|
+
if (canReceiveRef) {
|
|
887
|
+
const enhancedProps = {
|
|
888
|
+
...props,
|
|
889
|
+
ref: (node) => {
|
|
890
|
+
if (node) {
|
|
891
|
+
const existingSource = node[SOURCE_KEY];
|
|
892
|
+
if (existingSource) {
|
|
893
|
+
// \u7EC4\u4EF6\u7EA7\u7684 source \u603B\u662F\u8986\u76D6\u5143\u7D20\u7EA7\u7684 source
|
|
894
|
+
if (!existingSource.isComponent) {
|
|
895
|
+
unregisterElement(node, existingSource);
|
|
896
|
+
node[SOURCE_KEY] = jsxSourceInfo;
|
|
897
|
+
registerElement(node, jsxSourceInfo);
|
|
898
|
+
}
|
|
899
|
+
} else {
|
|
900
|
+
node[SOURCE_KEY] = jsxSourceInfo;
|
|
901
|
+
registerElement(node, jsxSourceInfo);
|
|
937
902
|
}
|
|
938
|
-
}
|
|
939
|
-
if (
|
|
940
|
-
|
|
903
|
+
}
|
|
904
|
+
if (typeof originalRef === "function") {
|
|
905
|
+
originalRef(node);
|
|
906
|
+
} else if (originalRef && typeof originalRef === "object") {
|
|
907
|
+
originalRef.current = node;
|
|
941
908
|
}
|
|
942
909
|
},
|
|
943
|
-
|
|
944
|
-
|
|
910
|
+
};
|
|
911
|
+
return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
|
|
945
912
|
}
|
|
946
913
|
|
|
947
|
-
|
|
948
|
-
handleWsClose(event);
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
originalAddEventListener('open', function() {
|
|
952
|
-
handleWsOpen();
|
|
953
|
-
});
|
|
954
|
-
|
|
955
|
-
state.wsIntercepted = true;
|
|
956
|
-
log('Vite HMR WebSocket intercepted');
|
|
957
|
-
|
|
958
|
-
return ws;
|
|
914
|
+
return _jsxDEV(type, props, key, isStatic, source, self);
|
|
959
915
|
}
|
|
960
916
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
return ws;
|
|
974
|
-
};
|
|
975
|
-
|
|
976
|
-
window.WebSocket.prototype = OriginalWebSocket.prototype;
|
|
977
|
-
window.WebSocket.CONNECTING = OriginalWebSocket.CONNECTING;
|
|
978
|
-
window.WebSocket.OPEN = OriginalWebSocket.OPEN;
|
|
979
|
-
window.WebSocket.CLOSING = OriginalWebSocket.CLOSING;
|
|
980
|
-
window.WebSocket.CLOSED = OriginalWebSocket.CLOSED;
|
|
981
|
-
|
|
982
|
-
// ============================================
|
|
983
|
-
// WebSocket \u6D88\u606F\u5904\u7406
|
|
984
|
-
// ============================================
|
|
985
|
-
function handleWsMessage(event) {
|
|
986
|
-
var data;
|
|
987
|
-
try {
|
|
988
|
-
data = JSON.parse(event.data);
|
|
989
|
-
} catch (e) {
|
|
990
|
-
// \u975E JSON \u6D88\u606F\uFF0C\u4E0D\u62E6\u622A
|
|
991
|
-
return false;
|
|
917
|
+
// For host elements (div, span, etc.), tag with source info
|
|
918
|
+
if (source?.fileName && typeof type === "string") {
|
|
919
|
+
const fileName = cleanFileName(source.fileName);
|
|
920
|
+
|
|
921
|
+
// \u5224\u65AD\u5F53\u524D\u5143\u7D20\u662F\u5426\u5728\u7EC4\u4EF6\u5E93\u4E2D\u5B9A\u4E49
|
|
922
|
+
const isInLibrary = fileName.includes('/components/') ||
|
|
923
|
+
fileName.includes('/ui/') ||
|
|
924
|
+
fileName.includes('node_modules');
|
|
925
|
+
|
|
926
|
+
// \u7EC4\u4EF6\u5E93\u5185\u90E8\u7684\u5143\u7D20\u4E0D\u6807\u8BB0\uFF0C\u4E0D\u652F\u6301\u53EF\u89C6\u5316\u7F16\u8F91
|
|
927
|
+
if (isInLibrary) {
|
|
928
|
+
return _jsxDEV(type, props, key, isStatic, source, self);
|
|
992
929
|
}
|
|
930
|
+
|
|
931
|
+
const sourceInfo = {
|
|
932
|
+
fileName,
|
|
933
|
+
lineNumber: source.lineNumber,
|
|
934
|
+
columnNumber: source.columnNumber,
|
|
935
|
+
displayName: type,
|
|
936
|
+
isComponent: false, // \u6807\u8BB0\u8FD9\u662F\u5143\u7D20\u7EA7\u522B\u7684 source
|
|
937
|
+
};
|
|
993
938
|
|
|
994
|
-
|
|
995
|
-
if (data.type === 'full-reload') {
|
|
996
|
-
// \u5982\u679C\u5DF2\u7ECF\u5728\u670D\u52A1\u5668\u91CD\u542F\u6A21\u5F0F\uFF0C\u62E6\u622A\u6240\u6709 full-reload
|
|
997
|
-
if (state.isServerRestart) {
|
|
998
|
-
log('Suppressed full-reload during server restart');
|
|
999
|
-
return true;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
log('Intercepted full-reload, path:', data.path || '(none)');
|
|
1003
|
-
|
|
1004
|
-
// \u8FDB\u5165\u68C0\u6D4B\u6A21\u5F0F\uFF1A\u7B49\u5F85\u770B WebSocket \u662F\u5426\u65AD\u5F00
|
|
1005
|
-
state.detectingReloadType = true;
|
|
939
|
+
const originalRef = props?.ref;
|
|
1006
940
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
941
|
+
const enhancedProps = {
|
|
942
|
+
...props,
|
|
943
|
+
ref: (node) => {
|
|
944
|
+
if (node) {
|
|
945
|
+
const existingSource = node[SOURCE_KEY];
|
|
946
|
+
// \u5982\u679C\u5DF2\u6709 source\uFF0C\u68C0\u67E5\u662F\u5426\u5E94\u8BE5\u4FDD\u7559\u5916\u5C42\u7684
|
|
947
|
+
if (existingSource) {
|
|
948
|
+
// \u5982\u679C\u5DF2\u6709\u7684\u662F\u7EC4\u4EF6\u7EA7\u522B\u7684 source\uFF08isComponent: true\uFF09\uFF0C\u4FDD\u7559\u5B83
|
|
949
|
+
if (existingSource.isComponent) {
|
|
950
|
+
// \u4E0D\u66F4\u65B0\uFF0C\u4FDD\u7559\u7EC4\u4EF6\u7EA7\u522B\u7684 source
|
|
951
|
+
if (typeof originalRef === "function") {
|
|
952
|
+
originalRef(node);
|
|
953
|
+
} else if (originalRef && typeof originalRef === "object") {
|
|
954
|
+
originalRef.current = node;
|
|
955
|
+
}
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// \u5426\u5219\u6309\u6B63\u5E38\u903B\u8F91\u66F4\u65B0
|
|
960
|
+
if (getSourceKey(existingSource) !== getSourceKey(sourceInfo)) {
|
|
961
|
+
unregisterElement(node, existingSource);
|
|
962
|
+
node[SOURCE_KEY] = sourceInfo;
|
|
963
|
+
registerElement(node, sourceInfo);
|
|
964
|
+
}
|
|
965
|
+
} else {
|
|
966
|
+
node[SOURCE_KEY] = sourceInfo;
|
|
967
|
+
registerElement(node, sourceInfo);
|
|
968
|
+
}
|
|
1013
969
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
// \u5904\u7406 connected \u6D88\u606F\uFF08Vite \u670D\u52A1\u5668\u53D1\u9001\u7684\u9996\u6761\u6D88\u606F\uFF09
|
|
1021
|
-
if (data.type === 'connected') {
|
|
1022
|
-
if (state.isServerRestart) {
|
|
1023
|
-
log('Reconnected to Vite server after restart');
|
|
1024
|
-
|
|
1025
|
-
// \u6E05\u9664\u91CD\u8FDE\u8D85\u65F6
|
|
1026
|
-
if (state.reconnectTimeoutTimer) {
|
|
1027
|
-
clearTimeout(state.reconnectTimeoutTimer);
|
|
1028
|
-
state.reconnectTimeoutTimer = null;
|
|
970
|
+
if (typeof originalRef === "function") {
|
|
971
|
+
originalRef(node);
|
|
972
|
+
} else if (originalRef && typeof originalRef === "object") {
|
|
973
|
+
originalRef.current = node;
|
|
1029
974
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
// \u91CD\u8FDE\u540E\u7B49\u5F85\u4E00\u6BB5\u65F6\u95F4\uFF0C\u770B\u662F\u5426\u6709 full-reload \u6216 update \u6D88\u606F
|
|
1034
|
-
// \u5982\u679C\u6CA1\u6709\uFF0C\u8BF4\u660E\u4E0D\u9700\u8981\u5237\u65B0\uFF0C\u4F46\u4ECD\u9700 soft-reload \u6062\u590D HMR
|
|
1035
|
-
state.postReconnectTimer = setTimeout(function() {
|
|
1036
|
-
if (state.isServerRestart) {
|
|
1037
|
-
log('No changes detected after reconnect, performing soft-reload to restore HMR');
|
|
1038
|
-
scheduleSoftReload();
|
|
1039
|
-
}
|
|
1040
|
-
}, POST_RECONNECT_WINDOW);
|
|
1041
|
-
}
|
|
1042
|
-
return false; // \u8BA9 connected \u6D88\u606F\u6B63\u5E38\u4F20\u9012
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
// \u5904\u7406 update \u6D88\u606F\uFF08HMR \u70ED\u66F4\u65B0\uFF09
|
|
1046
|
-
if (data.type === 'update' && state.isServerRestart) {
|
|
1047
|
-
// \u91CD\u8FDE\u540E\u6536\u5230 HMR update\uFF0C\u8BF4\u660E\u6709\u6A21\u5757\u53D8\u66F4
|
|
1048
|
-
// \u8BA9 HMR update \u6B63\u5E38\u5904\u7406
|
|
1049
|
-
log('Received HMR update after reconnect, letting HMR handle it');
|
|
1050
|
-
if (state.postReconnectTimer) {
|
|
1051
|
-
clearTimeout(state.postReconnectTimer);
|
|
1052
|
-
state.postReconnectTimer = null;
|
|
1053
|
-
}
|
|
1054
|
-
// \u6709 HMR update \u8BF4\u660E WebSocket \u662F\u6D3B\u7684\uFF0C\u53EF\u4EE5\u76F4\u63A5\u6062\u590D
|
|
1055
|
-
resetState();
|
|
1056
|
-
return false; // \u8BA9 update \u6D88\u606F\u6B63\u5E38\u4F20\u9012\u7ED9 Vite \u5BA2\u6237\u7AEF\u5904\u7406 HMR
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
return false;
|
|
975
|
+
},
|
|
976
|
+
};
|
|
977
|
+
return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
|
|
1060
978
|
}
|
|
1061
979
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
980
|
+
return _jsxDEV(type, props, key, isStatic, source, self);
|
|
981
|
+
}
|
|
982
|
+
`;function v(){let r=false,n="";return {name:"vite-plugin-jsx-source-tagger",enforce:"pre",configResolved(e){r=e.command==="serve",n=e.root;},resolveId(e,t){return r&&e==="react/jsx-dev-runtime"&&!t?.includes("\0jsx-source")?"\0jsx-source/jsx-dev-runtime":null},load(e){return r&&e==="\0jsx-source/jsx-dev-runtime"?j.replace('const PROJECT_ROOT = "";',`const PROJECT_ROOT = ${JSON.stringify(n)};`):null}}}function _(r){let n="",e=false,t=null,o=null,l=r?.configPath||"./tailwind.config.ts",i="@amaster/tailwind-config",u="\0"+i,c=async()=>{let a=d__default.default.resolve(n,l);try{return await S__default.default.access(a),a}catch{if(l.endsWith(".ts")){let s=a.replace(/\.ts$/,".js");try{return await S__default.default.access(s),s}catch{return null}}else if(l.endsWith(".js")){let s=a.replace(/\.js$/,".ts");try{return await S__default.default.access(s),s}catch{return null}}return null}},h=async a=>{try{let s=await c();if(!s)return null;if(a){let E=await a.ssrLoadModule(s);return t=E.default||E,t}let f=await import(`file://${s}?t=${Date.now()}`);return t=f.default||f,t}catch(s){return console.error("[tailwind-config-sync] Failed to generate config:",s),null}};return {name:"vite-plugin-tailwind-config-sync",configResolved(a){n=a.root,e=a.command==="serve";},async buildStart(){e&&await h();},resolveId(a){if(a===i)return u},async load(a){if(a===u)return await h(o),t?`
|
|
983
|
+
// Use global variable to persist callbacks and current config across HMR updates
|
|
984
|
+
if (!window.__tailwindConfigCallbacks) {
|
|
985
|
+
window.__tailwindConfigCallbacks = [];
|
|
986
|
+
}
|
|
1067
987
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
enterServerRestartMode('full-reload followed by disconnect');
|
|
1071
|
-
return;
|
|
1072
|
-
}
|
|
988
|
+
// Always update current config with the latest from server
|
|
989
|
+
let tailwindConfigCurrent = ${JSON.stringify(t)};
|
|
1073
990
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
991
|
+
if (import.meta.hot) {
|
|
992
|
+
// Accept self updates
|
|
993
|
+
import.meta.hot.accept((newModule) => {
|
|
994
|
+
if (newModule && newModule.default) {
|
|
995
|
+
// Call all update callbacks with the new config from window
|
|
996
|
+
window.__tailwindConfigCallbacks.forEach((callback) => {
|
|
997
|
+
try {
|
|
998
|
+
// Pass the actual config object, not the Proxy
|
|
999
|
+
callback(newModule.default);
|
|
1000
|
+
} catch (e) {
|
|
1001
|
+
console.error('[TailwindConfig] Callback error:', e);
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1078
1004
|
}
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
function handleWsOpen() {
|
|
1082
|
-
log('WebSocket opened');
|
|
1083
|
-
}
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1084
1007
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
originalLocationReload.call(window.location);
|
|
1008
|
+
export function onUpdate(fn) {
|
|
1009
|
+
window.__tailwindConfigCallbacks.push(fn);
|
|
1010
|
+
return () => {
|
|
1011
|
+
const index = window.__tailwindConfigCallbacks.indexOf(fn);
|
|
1012
|
+
if (index > -1) {
|
|
1013
|
+
window.__tailwindConfigCallbacks.splice(index, 1);
|
|
1014
|
+
}
|
|
1093
1015
|
};
|
|
1016
|
+
};
|
|
1017
|
+
export default tailwindConfigCurrent;
|
|
1094
1018
|
|
|
1095
|
-
|
|
1096
|
-
})();
|
|
1097
|
-
</script>`;return {name:"vite-plugin-smart-reload",enforce:"pre",apply:"serve",transformIndexHtml(e){return e.replace(/<head([^>]*)>/i,`<head$1>${r}`)}}}function v(r={}){let{designWidth:e=375,maxWidth:t=750,baseFontSize:n=12,minRootSize:o=12,maxRootSize:i=24}=r;return {name:"vite-plugin-taro-style-adapter",apply:"serve",transformIndexHtml(s){let l=`
|
|
1019
|
+
`:"export default null;"},configureServer(a){e&&(o=a,(async()=>{try{let s=await c();s&&a.watcher.add(s);}catch{}})());},async handleHotUpdate({file:a,server:s}){let p=await c();if(!p||d__default.default.normalize(a)!==d__default.default.normalize(p))return;let f=s.moduleGraph.getModuleById(p);f&&s.moduleGraph.invalidateModule(f),await h(s);let g=s.moduleGraph.getModuleById(u);return g?(s.moduleGraph.invalidateModule(g),[g]):[]}}}function b(r={}){let{designWidth:n=375,maxWidth:e=750,baseFontSize:t=12,minRootSize:o=12,maxRootSize:l=24}=r;return {name:"vite-plugin-taro-style-adapter",apply:"serve",transformIndexHtml(i){let u=`
|
|
1098
1020
|
<script data-taro-flexible="true">
|
|
1099
1021
|
(function() {
|
|
1100
|
-
var designWidth = ${
|
|
1101
|
-
var maxWidth = ${
|
|
1102
|
-
var baseFontSize = ${
|
|
1022
|
+
var designWidth = ${n};
|
|
1023
|
+
var maxWidth = ${e};
|
|
1024
|
+
var baseFontSize = ${t};
|
|
1103
1025
|
var minRootSize = ${o};
|
|
1104
|
-
var maxRootSize = ${
|
|
1026
|
+
var maxRootSize = ${l};
|
|
1105
1027
|
|
|
1106
1028
|
function setRootFontSize() {
|
|
1107
1029
|
var docEl = document.documentElement;
|
|
@@ -1135,7 +1057,7 @@ if (typeof window !== 'undefined') {
|
|
|
1135
1057
|
document.addEventListener('DOMContentLoaded', setRootFontSize);
|
|
1136
1058
|
})();
|
|
1137
1059
|
</script>
|
|
1138
|
-
`;return
|
|
1060
|
+
`;return i.replace("</head>",`${u}
|
|
1139
1061
|
<style data-taro-adapter="true">
|
|
1140
1062
|
/* \u4EC5 H5 \u751F\u6548\uFF1A\u9690\u85CF Taro \u9875\u9762\u5BB9\u5668\u6EDA\u52A8\u6761\uFF0C\u4F46\u4ECD\u53EF\u6EDA\u52A8 */
|
|
1141
1063
|
.taro_page {
|
|
@@ -1181,5 +1103,5 @@ if (typeof window !== 'undefined') {
|
|
|
1181
1103
|
object-fit: contain;
|
|
1182
1104
|
}
|
|
1183
1105
|
</style>
|
|
1184
|
-
</head>`)}}}function
|
|
1106
|
+
</head>`)}}}function y(r={}){let{ratio:n=2}=r;return {postcssPlugin:"postcss-rpx2px",Declaration(e){e.value?.includes("rpx")&&(e.value=e.value.replace(/(-?\d*\.?\d+)rpx/gi,(t,o)=>{let l=parseFloat(o)/n;return l===0?"0":`${l}px`}));}}}y.postcss=true;function k(r={}){let{additional:n=[],autoInjectTaroApp:e=true,autoInjectVite:t=true}=r,o={},l=new Set(n);return e&&Object.keys(process.env).forEach(i=>{i.startsWith("TARO_APP_")&&l.add(i);}),t&&Object.keys(process.env).forEach(i=>{i.startsWith("VITE_")&&l.add(i);}),l.forEach(i=>{let u=process.env[i]||"";o[`process.env.${i}`]=JSON.stringify(u);}),o}function D(){return {"process.env.TARO_APP_API_BASE_URL":JSON.stringify(process.env.TARO_APP_API_BASE_URL||""),"process.env.VITE_API_BASE_URL":JSON.stringify(process.env.VITE_API_BASE_URL||"")}}function N(r={}){let n=r.isTaro??C__default.default.env.TARO_ENV==="h5",e=[O(),T()];return r.jsxSourceTagger!==false&&e.push(v()),r.tailwindConfigSync!==false&&e.push(_({configPath:r.tailwindConfigPath})),n&&(e.unshift(b(r.styleAdapter)),e.unshift({name:"dev-postcss-rpx2px-plugin",apply:"serve",config(t){typeof t.css?.postcss=="object"&&t.css?.postcss.plugins?.unshift(y());}})),C__default.default.env.WORKSPACE_GIT_REPO&&e.push(P()),e}exports.default=N;exports.editorBridgePlugin=O;exports.injectAmasterEnv=D;exports.injectTaroEnv=k;exports.jsxSourceTaggerPlugin=v;exports.routesExposePlugin=T;exports.rpx2pxPlugin=y;exports.tailwindConfigSyncPlugin=_;exports.taroStyleAdapterPlugin=b;//# sourceMappingURL=index.cjs.map
|
|
1185
1107
|
//# sourceMappingURL=index.cjs.map
|