@amaster.ai/vite-plugins 1.1.0-beta.8 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,30 +1,11 @@
1
- import {createHash}from'crypto';import m,{readFileSync}from'fs';import w,{dirname,resolve}from'path';import {fileURLToPath}from'url';import R from'process';function E(r,e){let t=`${r}:${e}`;return createHash("md5").update(t).digest("hex").substring(0,12)}var x=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function v(){let r=false;return {name:"vite-plugin-component-id",enforce:"pre",configResolved(e){r=e.command==="serve";},transform(e,t){if(!r||!/\.(tsx|jsx)$/.test(t)||t.includes("node_modules")||!/<[a-z]/.test(e))return null;try{let n=e,o=/<([a-z][\da-z]*)(?=[\s/>])/g,i,s=[];for(;(i=o.exec(e))!==null;){let a=i[1];if(!a)continue;let u=i.index,d=i.index+i[0].length;if(!x.has(a))continue;let c=d,p=!1,f=!1;for(;c<e.length&&!p;)e[c]===">"&&(p=!0,e.substring(u,c).includes("data-node-component-id")&&(f=!0)),c++;f||s.push({index:u,tag:a,tagEndIndex:d});}let l=e;for(let a=s.length-1;a>=0;a--){let u=s[a];if(!u)continue;let{index:d,tagEndIndex:c}=u,p=E(t,d),f=l.substring(0,c),y=l.substring(c);n=`${f} data-node-component-id="${p}"${y}`,l=n;}return {code:n,map:null}}catch{return null}}}}var L=`<script>
2
- document.addEventListener("click", (e) => {
3
- const element = e.target;
4
- const noJumpOut = document.body.classList.contains("forbid-jump-out")
5
- if (element.hasAttribute("data-link-href") && !noJumpOut) {
6
- const href = element.getAttribute("data-link-href");
7
- const target = element.getAttribute("data-link-target");
8
- if (href) {
9
- if (target === "_blank") {
10
- window.open(href, "_blank");
11
- } else {
12
- window.location.href = href;
13
- }
14
- }
15
- } else if(noJumpOut && element.tagName === "A") {
16
- e.preventDefault();
17
- }
18
- });
19
- </script>`;function C(){try{let r=fileURLToPath(import.meta.url),e=dirname(r),t=resolve(e,"../dist/bridge.bridge.js");return `<script>
20
- ${readFileSync(t,"utf-8")}
21
- </script>`}catch(r){return console.warn("Failed to read bridge script:",r),""}}function S(){let r=false,e="";return {name:"vite-plugin-editor-bridge",configResolved(t){r=t.command==="serve",r&&(e=C());},transformIndexHtml(t){let o=`${L}${r?e:""}</body>`;return t.replace("</body>",o)}}}function b(r){let e=false,t=r?.routesFilePath||"src/routes.tsx";return {name:"vite-plugin-routes-expose",enforce:"post",configResolved(n){e=n.command==="serve";},transform(n,o){if(!e||!o.endsWith(t))return null;try{return n.includes("window.__APP_ROUTES__")?null:{code:`${n}
1
+ import y,{readFileSync}from'fs';import d,{dirname,resolve}from'path';import {fileURLToPath}from'url';import A from'process';import w from'fs/promises';import k from'@babel/generator';import {parse}from'@babel/parser';import L from'@babel/traverse';var F=fileURLToPath(import.meta.url),U=dirname(F),P="@amaster/bridge-monitor",T="\0"+P,m=null;function z(){if(m)return m;try{let e=resolve(U,"../dist/bridge-module.global.js");return m=readFileSync(e,"utf-8"),m}catch(e){return console.warn("[editor-bridge] Failed to load pre-built bridge module:",e),""}}function W(){return '<script type="module" src="/@id/@amaster/bridge-monitor"></script>'}function X(e){return z().replace(/__SESSION_KEY__/g,e)+`
2
+ export default {};`}function C(){let e=false;return {name:"vite-plugin-editor-bridge",configResolved(n){e=n.command==="serve";},resolveId(n){if(n===P)return T},load(n){if(n===T){let r=process.env.VITE_AMASTER_KEY||"";return X(r)}},transformIndexHtml(n){if(!e)return n;let r=W();return n.replace("</body>",`${r}</body>`)}}}function I(e){let n=false,r=e?.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(r))return null;try{return t.includes("window.__APP_ROUTES__")?null:{code:`${t}
22
3
 
23
4
  // Development mode: Expose routes to window.__APP_ROUTES__
24
5
  if (typeof window !== 'undefined') {
25
6
  window.__APP_ROUTES__ = typeof routes !== 'undefined' && Array.isArray(routes) ? routes : [];
26
7
  }
27
- `,map:null}}catch{return null}}}}function T(){let r="",e=`
8
+ `,map:null}}catch{return null}}}}function j(){let e="",n=`
28
9
  <script>
29
10
  (function() {
30
11
  'use strict';
@@ -32,6 +13,9 @@ if (typeof window !== 'undefined') {
32
13
  // Log API path (provided by Vite dev server)
33
14
  var LOG_API_PATH = '/__browser__';
34
15
 
16
+ // Save original fetch before any interception, used exclusively for log writing
17
+ var __originalFetch__ = window.fetch.bind(window);
18
+
35
19
  // Write queue to ensure sequential writes
36
20
  var writeQueue = [];
37
21
  var isWriting = false;
@@ -44,7 +28,7 @@ if (typeof window !== 'undefined') {
44
28
  var entry = writeQueue.shift();
45
29
  var logText = JSON.stringify(entry);
46
30
 
47
- fetch(LOG_API_PATH, {
31
+ __originalFetch__(LOG_API_PATH, {
48
32
  method: 'POST',
49
33
  headers: { 'Content-Type': 'application/json' },
50
34
  body: logText
@@ -162,12 +146,19 @@ if (typeof window !== 'undefined') {
162
146
  };
163
147
  }
164
148
 
165
- // Check if message should be filtered (contains [vite] text)
149
+ // Keywords to filter from console log collection
150
+ var FILTERED_CONSOLE_KEYWORDS = ['[vite]', '[BrowserLogs]'];
151
+
152
+ // Check if message should be filtered
166
153
  function shouldFilterConsoleLog(args) {
167
154
  for (var i = 0; i < args.length; i++) {
168
155
  var arg = args[i];
169
- if (typeof arg === 'string' && arg.indexOf('[vite]') !== -1) {
170
- return true;
156
+ if (typeof arg === 'string') {
157
+ for (var j = 0; j < FILTERED_CONSOLE_KEYWORDS.length; j++) {
158
+ if (arg.indexOf(FILTERED_CONSOLE_KEYWORDS[j]) !== -1) {
159
+ return true;
160
+ }
161
+ }
171
162
  }
172
163
  }
173
164
  return false;
@@ -705,398 +696,234 @@ if (typeof window !== 'undefined') {
705
696
 
706
697
  originalConsole.log('[BrowserLogs] Log collection started');
707
698
  })();
708
- </script>`;return {name:"vite-plugin-browser-logs",configResolved(t){let n=t.root||R.cwd();r=w.join(n,"browser.log");},configureServer(t){t.middlewares.use((n,o,i)=>{if(n.url==="/__browser__"&&n.method==="POST"){let s=n.headers.origin||"*",l="";n.on("data",a=>{l+=a.toString();}),n.on("end",()=>{try{let a=w.dirname(r);m.existsSync(a)||m.mkdirSync(a,{recursive:!0}),m.appendFileSync(r,`${l}
709
- `,"utf-8"),o.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),o.end(JSON.stringify({success:!0}));}catch(a){console.error("[BrowserLogs] Write error:",a),o.writeHead(500,{"Content-Type":"application/json","Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),o.end(JSON.stringify({success:false,error:String(a)}));}});}else if(n.url==="/__browser__"&&n.method==="OPTIONS"){let s=n.headers.origin||"*";o.writeHead(204,{"Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type","Access-Control-Max-Age":"86400"}),o.end();}else if(n.url==="/__browser__"){let s=n.headers.origin||"*";o.writeHead(405,{"Content-Type":"application/json","Access-Control-Allow-Origin":s}),o.end(JSON.stringify({error:"Method not allowed"}));}else i();}),console.log("[BrowserLogs] Logs will be written to:",r);},transformIndexHtml(t){return t.replace(/<head([^>]*)>/i,`<head$1>${e}`)}}}function _(){let e=`
710
- <script>
711
- (function() {
712
- 'use strict';
713
-
714
- var PLUGIN_TAG = '[SmartReload]';
715
- // full-reload \u540E\u7B49\u5F85 WebSocket \u65AD\u5F00\u7684\u7A97\u53E3\u671F\uFF08ms\uFF09
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
- // soft-reload \u5EF6\u8FDF\uFF08ms\uFF09
722
- var SOFT_RELOAD_DELAY = 300;
723
-
724
- // ============================================
725
- // \u72B6\u6001\u7BA1\u7406
726
- // ============================================
727
- var state = {
728
- // \u662F\u5426\u5DF2\u7ECF\u62E6\u622A\u4E86 Vite HMR WebSocket
729
- wsIntercepted: false,
730
- // \u662F\u5426\u6B63\u5728\u7B49\u5F85\u5224\u65AD full-reload \u7C7B\u578B\uFF08300ms \u7A97\u53E3\u671F\uFF09
731
- detectingReloadType: false,
732
- // \u5EF6\u8FDF\u6267\u884C full-reload \u7684\u5B9A\u65F6\u5668
733
- reloadTimer: null,
734
- // \u662F\u5426\u6B63\u5728\u7B49\u5F85\u670D\u52A1\u5668\u91CD\u8FDE
735
- waitingForReconnect: false,
736
- // \u662F\u5426\u662F\u670D\u52A1\u5668\u91CD\u542F\u573A\u666F
737
- isServerRestart: false,
738
- // \u91CD\u8FDE\u8D85\u65F6\u5B9A\u65F6\u5668
739
- reconnectTimeoutTimer: null,
740
- // \u91CD\u8FDE\u540E\u7B49\u5F85\u53D8\u66F4\u7684\u5B9A\u65F6\u5668
741
- postReconnectTimer: null,
742
- // \u662F\u5426\u6B63\u5728\u6291\u5236 fetch ping\uFF08\u963B\u6B62 Vite \u7684 HTTP ping \u89E6\u53D1 reload\uFF09
743
- suppressingReload: false,
744
- // \u5DF2\u62E6\u622A\u7684 fetch ping \u6B21\u6570\uFF08\u7528\u4E8E\u8C03\u8BD5\uFF09
745
- suppressedReloadCount: 0
746
- };
699
+ </script>`;return {name:"vite-plugin-browser-logs",configResolved(r){let t=A.env.WORKSPACE_DIR;if(t)e=d.join(t,"browser.log");else {let o=r.root||A.cwd();for(;o!==d.dirname(o)&&!y.existsSync(d.join(o,"package.json"));)o=d.dirname(o);e=d.join(o,"browser.log");}},configureServer(r){r.middlewares.use((t,o,l)=>{if(t.url==="/__browser__"&&t.method==="POST"){let i=t.headers.origin||"*",c="";t.on("data",u=>{c+=u.toString();}),t.on("end",()=>{try{let u=d.dirname(e);y.existsSync(u)||y.mkdirSync(u,{recursive:!0}),y.appendFileSync(e,`${c}
700
+ `,"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(u){console.error("[BrowserLogs] Write error:",u),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(u)}));}});}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:",e);},transformIndexHtml(r){return r.replace(/<head([^>]*)>/i,`<head$1>${n}`)}}}var J=`
701
+ import * as React from "react";
702
+ import * as ReactJSXDevRuntime from "react/jsx-dev-runtime";
747
703
 
748
- // ============================================
749
- // \u65E5\u5FD7\u5DE5\u5177
750
- // ============================================
751
- function log() {
752
- var args = [PLUGIN_TAG];
753
- for (var i = 0; i < arguments.length; i++) {
754
- args.push(arguments[i]);
755
- }
756
- console.log.apply(console, args);
757
- }
704
+ const _jsxDEV = ReactJSXDevRuntime.jsxDEV;
705
+ export const Fragment = ReactJSXDevRuntime.Fragment;
758
706
 
759
- // ============================================
760
- // \u6E05\u9664\u6240\u6709\u5B9A\u65F6\u5668
761
- // ============================================
762
- function clearAllTimers() {
763
- if (state.reloadTimer) {
764
- clearTimeout(state.reloadTimer);
765
- state.reloadTimer = null;
766
- }
767
- if (state.reconnectTimeoutTimer) {
768
- clearTimeout(state.reconnectTimeoutTimer);
769
- state.reconnectTimeoutTimer = null;
770
- }
771
- if (state.postReconnectTimer) {
772
- clearTimeout(state.postReconnectTimer);
773
- state.postReconnectTimer = null;
774
- }
775
- }
776
-
777
- // ============================================
778
- // \u91CD\u7F6E\u72B6\u6001
779
- // ============================================
780
- function resetState() {
781
- state.detectingReloadType = false;
782
- state.isServerRestart = false;
783
- state.waitingForReconnect = false;
784
- state.suppressingReload = false;
785
- state.suppressedReloadCount = 0;
786
- clearAllTimers();
787
- }
788
-
789
- // ============================================
790
- // \u6267\u884C\u771F\u6B63\u7684 full-reload
791
- // ============================================
792
- function executeFullReload() {
793
- log('Executing full-reload');
794
- resetState();
795
- originalLocationReload.call(window.location);
796
- }
707
+ const SOURCE_KEY = Symbol.for("__jsxSource__");
708
+ const PROJECT_ROOT = "";
797
709
 
798
- // ============================================
799
- // Soft-reload\uFF1A\u5EF6\u8FDF\u5237\u65B0\uFF0C\u6062\u590D HMR \u8FDE\u63A5
800
- // \u5728\u6291\u5236 reload \u540E\uFF0CVite \u5BA2\u6237\u7AEF\u7684 WebSocket \u5DF2\u6B7B\uFF0C
801
- // \u9700\u8981\u901A\u8FC7 reload \u6062\u590D HMR\u3002
802
- // ============================================
803
- function scheduleSoftReload() {
804
- log('Scheduling soft-reload to restore HMR connection');
805
- setTimeout(function() {
806
- resetState();
807
- originalLocationReload.call(window.location);
808
- }, SOFT_RELOAD_DELAY);
710
+ const cleanFileName = (fileName) => {
711
+ if (!fileName) return "";
712
+ // Remove project root prefix to get relative path
713
+ if (PROJECT_ROOT && fileName.startsWith(PROJECT_ROOT)) {
714
+ const relative = fileName.slice(PROJECT_ROOT.length);
715
+ return relative.startsWith("/") ? relative.slice(1) : relative;
809
716
  }
717
+ return fileName;
718
+ };
810
719
 
811
- // ============================================
812
- // \u62E6\u622A location.reload
813
- // \u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u76F4\u63A5\u4FEE\u6539 location.reload\uFF08Cannot redefine property\uFF09\uFF0C
814
- // \u6240\u4EE5\u6211\u4EEC\u901A\u8FC7\u62E6\u622A fetch \u6765\u963B\u6B62 Vite \u7684 HTTP ping \u6210\u529F\uFF0C
815
- // \u4ECE\u800C\u963B\u6B62 Vite \u5BA2\u6237\u7AEF\u8C03\u7528 location.reload()\u3002
816
- //
817
- // Vite \u5BA2\u6237\u7AEF\u5728 WebSocket \u65AD\u5F00\u540E\u4F1A\u901A\u8FC7 fetch ping \u670D\u52A1\u5668\uFF0C
818
- // ping \u6210\u529F\u540E\u8C03\u7528 location.reload()\u3002
819
- // \u6211\u4EEC\u5728\u670D\u52A1\u5668\u91CD\u542F\u671F\u95F4\u8BA9 ping \u8BF7\u6C42\u8FD4\u56DE\u5931\u8D25\uFF0C
820
- // \u8FD9\u6837 Vite \u5BA2\u6237\u7AEF\u4F1A\u4E00\u76F4\u8F6E\u8BE2\u800C\u4E0D\u4F1A\u89E6\u53D1 reload\u3002
821
- // \u5F53\u6211\u4EEC\u7684 WebSocket \u91CD\u8FDE\u903B\u8F91\u68C0\u6D4B\u5230\u91CD\u8FDE\u6210\u529F\u540E\uFF0C
822
- // \u6062\u590D fetch \u5E76\u7531\u6211\u4EEC\u81EA\u5DF1\u63A7\u5236\u662F\u5426\u9700\u8981 reload\u3002
823
- // ============================================
824
- var originalLocationReload = window.location.reload.bind(window.location);
825
- var originalFetch = window.fetch.bind(window);
720
+ // Global map to track elements by source location
721
+ const sourceElementMap = new Map();
722
+ window.sourceElementMap = sourceElementMap;
826
723
 
827
- window.fetch = function smartReloadInterceptedFetch(input, init) {
828
- // \u53EA\u5728\u670D\u52A1\u5668\u91CD\u542F\u671F\u95F4\u62E6\u622A Vite \u7684 ping \u8BF7\u6C42
829
- if (state.suppressingReload || state.waitingForReconnect || state.isServerRestart) {
830
- var url = '';
831
- if (typeof input === 'string') {
832
- url = input;
833
- } else if (input instanceof Request) {
834
- url = input.url;
835
- } else if (input instanceof URL) {
836
- url = input.href;
837
- }
724
+ function getSourceKey(sourceInfo) {
725
+ return \`\${cleanFileName(sourceInfo.fileName)}:\${sourceInfo.lineNumber}:\${sourceInfo.columnNumber}\`;
726
+ }
838
727
 
839
- // Vite \u7684 ping \u8BF7\u6C42\u7279\u5F81\uFF1A\u8BF7\u6C42\u5F53\u524D\u9875\u9762 URL \u6216\u6839\u8DEF\u5F84
840
- // Vite 5.x \u4F7F\u7528 fetch(location.href) \u6765 ping
841
- var currentOrigin = window.location.origin;
842
- if (url === window.location.href || url === currentOrigin + '/' || url.indexOf(currentOrigin + '/__vite_ping') !== -1) {
843
- state.suppressedReloadCount++;
844
- log('Suppressed fetch ping during server restart: ' + url + ' (count: ' + state.suppressedReloadCount + ')');
845
- // \u8FD4\u56DE\u4E00\u4E2A\u5931\u8D25\u7684 response\uFF0C\u8BA9 Vite \u8BA4\u4E3A\u670D\u52A1\u5668\u8FD8\u6CA1\u6062\u590D
846
- return Promise.reject(new TypeError('SmartReload: fetch suppressed during server restart'));
728
+ function unregisterElement(node, sourceInfo) {
729
+ const key = getSourceKey(sourceInfo);
730
+ const refs = sourceElementMap.get(key);
731
+ if (refs) {
732
+ for (const ref of refs) {
733
+ if (ref.deref() === node) {
734
+ refs.delete(ref);
735
+ break;
847
736
  }
848
737
  }
849
- return originalFetch(input, init);
850
- };
851
- log('fetch intercepted for Vite ping suppression');
852
-
853
- // ============================================
854
- // \u8FDB\u5165\u670D\u52A1\u5668\u91CD\u542F\u7B49\u5F85\u6A21\u5F0F
855
- // ============================================
856
- function enterServerRestartMode(reason) {
857
- log('Entering server restart mode:', reason);
858
-
859
- state.isServerRestart = true;
860
- state.waitingForReconnect = true;
861
- state.suppressingReload = true;
862
- state.detectingReloadType = false;
863
-
864
- if (state.reloadTimer) {
865
- clearTimeout(state.reloadTimer);
866
- state.reloadTimer = null;
738
+ if (refs.size === 0) {
739
+ sourceElementMap.delete(key);
867
740
  }
868
-
869
- // \u8D85\u65F6\u4FDD\u62A4\uFF1A\u5982\u679C\u6307\u5B9A\u65F6\u95F4\u5185\u65E0\u6CD5\u91CD\u8FDE\uFF0C\u6267\u884C full-reload
870
- if (state.reconnectTimeoutTimer) {
871
- clearTimeout(state.reconnectTimeoutTimer);
872
- }
873
- state.reconnectTimeoutTimer = setTimeout(function() {
874
- if (state.waitingForReconnect || state.isServerRestart) {
875
- log('Reconnect timeout (' + RECONNECT_TIMEOUT + 'ms), performing full-reload as fallback');
876
- executeFullReload();
877
- }
878
- }, RECONNECT_TIMEOUT);
879
741
  }
742
+ }
880
743
 
881
- // ============================================
882
- // \u62E6\u622A WebSocket \u6784\u9020\u51FD\u6570
883
- // ============================================
884
- var OriginalWebSocket = window.WebSocket;
885
-
886
- function isViteHmrWebSocket(url) {
887
- if (typeof url !== 'string') return false;
888
- // \u53EA\u5339\u914D Vite HMR \u7279\u5F81\u7684 URL
889
- return url.includes('/__vite_hmr') || url.includes('?token=');
744
+ function registerElement(node, sourceInfo) {
745
+ const key = getSourceKey(sourceInfo);
746
+ if (!sourceElementMap.has(key)) {
747
+ sourceElementMap.set(key, new Set());
890
748
  }
749
+ sourceElementMap.get(key).add(new WeakRef(node));
750
+ }
891
751
 
892
- function createWsProxy(ws) {
893
- var originalAddEventListener = ws.addEventListener.bind(ws);
894
- var originalRemoveEventListener = ws.removeEventListener.bind(ws);
895
-
896
- ws.addEventListener = function(type, listener, options) {
897
- if (type === 'message') {
898
- var wrappedListener = function(event) {
899
- var intercepted = handleWsMessage(event);
900
- if (!intercepted) {
901
- listener.call(ws, event);
902
- }
903
- };
904
- listener.__smartReloadWrapped__ = wrappedListener;
905
- return originalAddEventListener(type, wrappedListener, options);
906
- }
907
- return originalAddEventListener(type, listener, options);
908
- };
752
+ function getTypeName(type) {
753
+ if (typeof type === "string") return type;
754
+ if (typeof type === "function") return type.displayName || type.name || "Unknown";
755
+ if (typeof type === "object" && type !== null) {
756
+ return type.displayName || type.render?.displayName || type.render?.name || "Unknown";
757
+ }
758
+ return "Unknown";
759
+ }
909
760
 
910
- ws.removeEventListener = function(type, listener, options) {
911
- if (type === 'message' && listener.__smartReloadWrapped__) {
912
- return originalRemoveEventListener(type, listener.__smartReloadWrapped__, options);
913
- }
914
- return originalRemoveEventListener(type, listener, options);
761
+ export function jsxDEV(type, props, key, isStatic, source, self) {
762
+ // For custom components, tag their rendered output
763
+ if (source?.fileName && typeof type !== "string" && type !== Fragment) {
764
+ const typeName = getTypeName(type);
765
+ const fileName = cleanFileName(source.fileName);
766
+
767
+ const jsxSourceInfo = {
768
+ fileName,
769
+ lineNumber: source.lineNumber,
770
+ columnNumber: source.columnNumber,
771
+ displayName: typeName,
772
+ isComponent: true,
915
773
  };
916
774
 
917
- var originalOnMessage = null;
918
- var onMessageDescriptor = Object.getOwnPropertyDescriptor(WebSocket.prototype, 'onmessage') ||
919
- Object.getOwnPropertyDescriptor(ws, 'onmessage');
920
-
921
- if (onMessageDescriptor) {
922
- Object.defineProperty(ws, 'onmessage', {
923
- get: function() {
924
- return originalOnMessage;
925
- },
926
- set: function(handler) {
927
- originalOnMessage = handler;
928
- var wrappedHandler = function(event) {
929
- var intercepted = handleWsMessage(event);
930
- if (!intercepted && handler) {
931
- handler.call(ws, event);
775
+ const originalRef = props?.ref;
776
+
777
+ // Check if component can safely receive refs
778
+ // - forwardRef components have $$typeof symbol
779
+ // - Class components have prototype.isReactComponent
780
+ // - If there's already a ref, the component expects it
781
+ const isForwardRef = type.$$typeof === Symbol.for('react.forward_ref');
782
+ const isClassComponent = typeof type === 'function' && type.prototype?.isReactComponent;
783
+ const hasExistingRef = originalRef !== undefined;
784
+
785
+ const canReceiveRef = isForwardRef || isClassComponent || hasExistingRef;
786
+
787
+ if (canReceiveRef) {
788
+ const enhancedProps = {
789
+ ...props,
790
+ ref: (node) => {
791
+ if (node) {
792
+ const existingSource = node[SOURCE_KEY];
793
+ if (existingSource) {
794
+ // \u7EC4\u4EF6\u7EA7\u7684 source \u603B\u662F\u8986\u76D6\u5143\u7D20\u7EA7\u7684 source
795
+ if (!existingSource.isComponent) {
796
+ unregisterElement(node, existingSource);
797
+ node[SOURCE_KEY] = jsxSourceInfo;
798
+ registerElement(node, jsxSourceInfo);
799
+ }
800
+ } else {
801
+ node[SOURCE_KEY] = jsxSourceInfo;
802
+ registerElement(node, jsxSourceInfo);
932
803
  }
933
- };
934
- if (onMessageDescriptor.set) {
935
- onMessageDescriptor.set.call(ws, wrappedHandler);
804
+ }
805
+ if (typeof originalRef === "function") {
806
+ originalRef(node);
807
+ } else if (originalRef && typeof originalRef === "object") {
808
+ originalRef.current = node;
936
809
  }
937
810
  },
938
- configurable: true
939
- });
811
+ };
812
+ return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
940
813
  }
941
814
 
942
- originalAddEventListener('close', function(event) {
943
- handleWsClose(event);
944
- });
945
-
946
- originalAddEventListener('open', function() {
947
- handleWsOpen();
948
- });
949
-
950
- state.wsIntercepted = true;
951
- log('Vite HMR WebSocket intercepted');
952
-
953
- return ws;
815
+ return _jsxDEV(type, props, key, isStatic, source, self);
954
816
  }
955
817
 
956
- window.WebSocket = function SmartReloadWebSocket(url, protocols) {
957
- var ws;
958
- if (protocols !== undefined) {
959
- ws = new OriginalWebSocket(url, protocols);
960
- } else {
961
- ws = new OriginalWebSocket(url);
962
- }
963
-
964
- if (isViteHmrWebSocket(url)) {
965
- return createWsProxy(ws);
966
- }
967
-
968
- return ws;
969
- };
970
-
971
- window.WebSocket.prototype = OriginalWebSocket.prototype;
972
- window.WebSocket.CONNECTING = OriginalWebSocket.CONNECTING;
973
- window.WebSocket.OPEN = OriginalWebSocket.OPEN;
974
- window.WebSocket.CLOSING = OriginalWebSocket.CLOSING;
975
- window.WebSocket.CLOSED = OriginalWebSocket.CLOSED;
976
-
977
- // ============================================
978
- // WebSocket \u6D88\u606F\u5904\u7406
979
- // ============================================
980
- function handleWsMessage(event) {
981
- var data;
982
- try {
983
- data = JSON.parse(event.data);
984
- } catch (e) {
985
- // \u975E JSON \u6D88\u606F\uFF0C\u4E0D\u62E6\u622A
986
- return false;
818
+ // For host elements (div, span, etc.), tag with source info
819
+ if (source?.fileName && typeof type === "string") {
820
+ const fileName = cleanFileName(source.fileName);
821
+
822
+ // \u5224\u65AD\u5F53\u524D\u5143\u7D20\u662F\u5426\u5728\u7EC4\u4EF6\u5E93\u4E2D\u5B9A\u4E49
823
+ const isInLibrary = fileName.includes('src/components/ui/') ||
824
+ fileName.includes('node_modules');
825
+
826
+ // \u7EC4\u4EF6\u5E93\u5185\u90E8\u7684\u5143\u7D20\u4E0D\u6807\u8BB0\uFF0C\u4E0D\u652F\u6301\u53EF\u89C6\u5316\u7F16\u8F91
827
+ if (isInLibrary) {
828
+ return _jsxDEV(type, props, key, isStatic, source, self);
987
829
  }
830
+
831
+ const sourceInfo = {
832
+ fileName,
833
+ lineNumber: source.lineNumber,
834
+ columnNumber: source.columnNumber,
835
+ displayName: type,
836
+ isComponent: false, // \u6807\u8BB0\u8FD9\u662F\u5143\u7D20\u7EA7\u522B\u7684 source
837
+ };
988
838
 
989
- // \u5904\u7406 full-reload \u6D88\u606F
990
- if (data.type === 'full-reload') {
991
- // \u5982\u679C\u5DF2\u7ECF\u5728\u670D\u52A1\u5668\u91CD\u542F\u6A21\u5F0F\uFF0C\u62E6\u622A\u6240\u6709 full-reload
992
- if (state.isServerRestart) {
993
- log('Suppressed full-reload during server restart');
994
- return true;
995
- }
996
-
997
- log('Intercepted full-reload, path:', data.path || '(none)');
998
-
999
- // \u8FDB\u5165\u68C0\u6D4B\u6A21\u5F0F\uFF1A\u7B49\u5F85\u770B WebSocket \u662F\u5426\u65AD\u5F00
1000
- state.detectingReloadType = true;
1001
-
1002
- // \u8BBE\u7F6E\u5B9A\u65F6\u5668\uFF1A\u5982\u679C\u7A97\u53E3\u671F\u5185 WebSocket \u6CA1\u6709\u65AD\u5F00\uFF0C\u8BF4\u660E\u662F\u771F\u6B63\u7684\u6A21\u5757\u53D8\u66F4
1003
- state.reloadTimer = setTimeout(function() {
1004
- if (state.detectingReloadType && !state.isServerRestart) {
1005
- log('WebSocket still connected after ' + DISCONNECT_DETECT_WINDOW + 'ms - real module change, executing reload');
1006
- state.detectingReloadType = false;
1007
- executeFullReload();
839
+ const originalRef = props?.ref;
840
+
841
+ const enhancedProps = {
842
+ ...props,
843
+ ref: (node) => {
844
+ if (node) {
845
+ const existingSource = node[SOURCE_KEY];
846
+ // \u5982\u679C\u5DF2\u6709 source\uFF0C\u68C0\u67E5\u662F\u5426\u5E94\u8BE5\u4FDD\u7559\u5916\u5C42\u7684
847
+ if (existingSource) {
848
+ // \u5982\u679C\u5DF2\u6709\u7684\u662F\u7EC4\u4EF6\u7EA7\u522B\u7684 source\uFF08isComponent: true\uFF09\uFF0C\u4FDD\u7559\u5B83
849
+ if (existingSource.isComponent) {
850
+ // \u4E0D\u66F4\u65B0\uFF0C\u4FDD\u7559\u7EC4\u4EF6\u7EA7\u522B\u7684 source
851
+ if (typeof originalRef === "function") {
852
+ originalRef(node);
853
+ } else if (originalRef && typeof originalRef === "object") {
854
+ originalRef.current = node;
855
+ }
856
+ return;
857
+ }
858
+
859
+ // \u5426\u5219\u6309\u6B63\u5E38\u903B\u8F91\u66F4\u65B0
860
+ if (getSourceKey(existingSource) !== getSourceKey(sourceInfo)) {
861
+ unregisterElement(node, existingSource);
862
+ node[SOURCE_KEY] = sourceInfo;
863
+ registerElement(node, sourceInfo);
864
+ }
865
+ } else {
866
+ node[SOURCE_KEY] = sourceInfo;
867
+ registerElement(node, sourceInfo);
868
+ }
1008
869
  }
1009
- }, DISCONNECT_DETECT_WINDOW);
1010
-
1011
- // \u62E6\u622A\uFF0C\u4E0D\u4F20\u9012\u7ED9 Vite \u5BA2\u6237\u7AEF
1012
- return true;
1013
- }
1014
-
1015
- // \u5904\u7406 connected \u6D88\u606F\uFF08Vite \u670D\u52A1\u5668\u53D1\u9001\u7684\u9996\u6761\u6D88\u606F\uFF09
1016
- if (data.type === 'connected') {
1017
- if (state.isServerRestart) {
1018
- log('Reconnected to Vite server after restart');
1019
-
1020
- // \u6E05\u9664\u91CD\u8FDE\u8D85\u65F6
1021
- if (state.reconnectTimeoutTimer) {
1022
- clearTimeout(state.reconnectTimeoutTimer);
1023
- state.reconnectTimeoutTimer = null;
870
+ if (typeof originalRef === "function") {
871
+ originalRef(node);
872
+ } else if (originalRef && typeof originalRef === "object") {
873
+ originalRef.current = node;
1024
874
  }
1025
-
1026
- state.waitingForReconnect = false;
1027
-
1028
- // \u91CD\u8FDE\u540E\u7B49\u5F85\u4E00\u6BB5\u65F6\u95F4\uFF0C\u770B\u662F\u5426\u6709 full-reload \u6216 update \u6D88\u606F
1029
- // \u5982\u679C\u6CA1\u6709\uFF0C\u8BF4\u660E\u4E0D\u9700\u8981\u5237\u65B0\uFF0C\u4F46\u4ECD\u9700 soft-reload \u6062\u590D HMR
1030
- state.postReconnectTimer = setTimeout(function() {
1031
- if (state.isServerRestart) {
1032
- log('No changes detected after reconnect, performing soft-reload to restore HMR');
1033
- scheduleSoftReload();
1034
- }
1035
- }, POST_RECONNECT_WINDOW);
1036
- }
1037
- return false; // \u8BA9 connected \u6D88\u606F\u6B63\u5E38\u4F20\u9012
1038
- }
1039
-
1040
- // \u5904\u7406 update \u6D88\u606F\uFF08HMR \u70ED\u66F4\u65B0\uFF09
1041
- if (data.type === 'update' && state.isServerRestart) {
1042
- // \u91CD\u8FDE\u540E\u6536\u5230 HMR update\uFF0C\u8BF4\u660E\u6709\u6A21\u5757\u53D8\u66F4
1043
- // \u8BA9 HMR update \u6B63\u5E38\u5904\u7406
1044
- log('Received HMR update after reconnect, letting HMR handle it');
1045
- if (state.postReconnectTimer) {
1046
- clearTimeout(state.postReconnectTimer);
1047
- state.postReconnectTimer = null;
1048
- }
1049
- // \u6709 HMR update \u8BF4\u660E WebSocket \u662F\u6D3B\u7684\uFF0C\u53EF\u4EE5\u76F4\u63A5\u6062\u590D
1050
- resetState();
1051
- return false; // \u8BA9 update \u6D88\u606F\u6B63\u5E38\u4F20\u9012\u7ED9 Vite \u5BA2\u6237\u7AEF\u5904\u7406 HMR
1052
- }
1053
-
1054
- return false;
875
+ },
876
+ };
877
+ return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
1055
878
  }
1056
879
 
1057
- // ============================================
1058
- // WebSocket \u8FDE\u63A5\u4E8B\u4EF6\u5904\u7406
1059
- // ============================================
1060
- function handleWsClose(event) {
1061
- log('WebSocket closed, code:', event.code, 'wasClean:', event.wasClean);
880
+ return _jsxDEV(type, props, key, isStatic, source, self);
881
+ }
882
+ `;function S(){let e=false,n="";return {name:"vite-plugin-jsx-source-tagger",enforce:"pre",configResolved(r){e=r.command==="serve",n=r.root;},resolveId(r,t){return e&&r==="react/jsx-dev-runtime"&&!t?.includes("\0jsx-source")?"\0jsx-source/jsx-dev-runtime":null},load(r){return e&&r==="\0jsx-source/jsx-dev-runtime"?J.replace('const PROJECT_ROOT = "";',`const PROJECT_ROOT = ${JSON.stringify(n)};`):null}}}function b(e){let n="",r=false,t=null,o=null,l=e?.configPath||"./tailwind.config.ts",i="@amaster/tailwind-config",c="\0"+i,u=async()=>{let a=d.resolve(n,l);try{return await w.access(a),a}catch{if(l.endsWith(".ts")){let s=a.replace(/\.ts$/,".js");try{return await w.access(s),s}catch{return null}}else if(l.endsWith(".js")){let s=a.replace(/\.js$/,".ts");try{return await w.access(s),s}catch{return null}}return null}},v=async a=>{try{let s=await u();if(!s)return null;if(a){let O=await a.ssrLoadModule(s);return t=O.default||O,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,r=a.command==="serve";},async buildStart(){r&&await v();},resolveId(a){if(a===i)return c},async load(a){if(a===c)return await v(o),t?`
883
+ // Use global variable to persist callbacks and current config across HMR updates
884
+ if (!window.__tailwindConfigCallbacks) {
885
+ window.__tailwindConfigCallbacks = [];
886
+ }
1062
887
 
1063
- // \u573A\u666F1\uFF1A\u6536\u5230 full-reload \u540E WebSocket \u65AD\u5F00 \u2192 \u670D\u52A1\u5668\u91CD\u542F
1064
- if (state.detectingReloadType) {
1065
- enterServerRestartMode('full-reload followed by disconnect');
1066
- return;
1067
- }
888
+ // Always update current config with the latest from server
889
+ let tailwindConfigCurrent = ${JSON.stringify(t)};
1068
890
 
1069
- // \u573A\u666F2\uFF1A\u6CA1\u6709 full-reload \u6D88\u606F\uFF0CWebSocket \u76F4\u63A5\u65AD\u5F00
1070
- // \u53EA\u5728\u975E\u6B63\u5E38\u5173\u95ED\u65F6\u624D\u8FDB\u5165\u91CD\u542F\u6A21\u5F0F\uFF08wasClean === false \u8868\u793A\u975E\u6B63\u5E38\u65AD\u5F00\uFF09
1071
- if (!state.isServerRestart && !event.wasClean) {
1072
- enterServerRestartMode('unexpected disconnect (server process killed)');
891
+ if (import.meta.hot) {
892
+ // Accept self updates
893
+ import.meta.hot.accept((newModule) => {
894
+ if (newModule && newModule.default) {
895
+ // Call all update callbacks with the new config from window
896
+ window.__tailwindConfigCallbacks.forEach((callback) => {
897
+ try {
898
+ // Pass the actual config object, not the Proxy
899
+ callback(newModule.default);
900
+ } catch (e) {
901
+ console.error('[TailwindConfig] Callback error:', e);
902
+ }
903
+ });
1073
904
  }
1074
- }
1075
-
1076
- function handleWsOpen() {
1077
- log('WebSocket opened');
1078
- }
905
+ });
906
+ }
1079
907
 
1080
- // ============================================
1081
- // \u66B4\u9732 API \u4F9B\u8C03\u8BD5\u4F7F\u7528
1082
- // ============================================
1083
- window.__smartReloadState__ = state;
1084
- window.__smartReloadForceReload__ = function() {
1085
- log('Force reload triggered by user');
1086
- resetState();
1087
- originalLocationReload.call(window.location);
908
+ export function onUpdate(fn) {
909
+ window.__tailwindConfigCallbacks.push(fn);
910
+ return () => {
911
+ const index = window.__tailwindConfigCallbacks.indexOf(fn);
912
+ if (index > -1) {
913
+ window.__tailwindConfigCallbacks.splice(index, 1);
914
+ }
1088
915
  };
916
+ };
917
+ export default tailwindConfigCurrent;
1089
918
 
1090
- log('Smart Reload initialized');
1091
- })();
1092
- </script>`.replace(/^\s*<script>\s*/i,"").replace(/\s*<\/script>\s*$/i,"");return {name:"vite-plugin-smart-reload",apply:"serve",transformIndexHtml:{order:"pre",handler(){return [{tag:"script",injectTo:"head-prepend",children:e}]}}}}function h(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=`
919
+ `:"export default null;"},configureServer(a){r&&(o=a,(async()=>{try{let s=await u();s&&a.watcher.add(s);}catch{}})());},async handleHotUpdate({file:a,server:s}){let p=await u();if(!p||d.normalize(a)!==d.normalize(p))return;let f=s.moduleGraph.getModuleById(p);f&&s.moduleGraph.invalidateModule(f),await v(s);let g=s.moduleGraph.getModuleById(c);return g?(s.moduleGraph.invalidateModule(g),[g]):[]}}}function x(e={}){let{designWidth:n=375,maxWidth:r=750,baseFontSize:t=12,minRootSize:o=12,maxRootSize:l=24}=e;return {name:"vite-plugin-taro-style-adapter",apply:"serve",transformIndexHtml(i){let c=`
1093
920
  <script data-taro-flexible="true">
1094
921
  (function() {
1095
- var designWidth = ${e};
1096
- var maxWidth = ${t};
1097
- var baseFontSize = ${n};
922
+ var designWidth = ${n};
923
+ var maxWidth = ${r};
924
+ var baseFontSize = ${t};
1098
925
  var minRootSize = ${o};
1099
- var maxRootSize = ${i};
926
+ var maxRootSize = ${l};
1100
927
 
1101
928
  function setRootFontSize() {
1102
929
  var docEl = document.documentElement;
@@ -1130,7 +957,7 @@ if (typeof window !== 'undefined') {
1130
957
  document.addEventListener('DOMContentLoaded', setRootFontSize);
1131
958
  })();
1132
959
  </script>
1133
- `;return s.replace("</head>",`${l}
960
+ `;return i.replace("</head>",`${c}
1134
961
  <style data-taro-adapter="true">
1135
962
  /* \u4EC5 H5 \u751F\u6548\uFF1A\u9690\u85CF Taro \u9875\u9762\u5BB9\u5668\u6EDA\u52A8\u6761\uFF0C\u4F46\u4ECD\u53EF\u6EDA\u52A8 */
1136
963
  .taro_page {
@@ -1176,5 +1003,5 @@ if (typeof window !== 'undefined') {
1176
1003
  object-fit: contain;
1177
1004
  }
1178
1005
  </style>
1179
- </head>`)}}}function g(r={}){let{ratio:e=2}=r;return {postcssPlugin:"postcss-rpx2px",Declaration(t){t.value.includes("rpx")&&(t.value=t.value.replace(/(-?\d*\.?\d+)rpx/gi,(n,o)=>{let i=parseFloat(o)/e;return i===0?"0":`${i}px`}));}}}g.postcss=true;function W(r={}){let{additional:e=[],autoInjectTaroApp:t=true,autoInjectVite:n=true}=r,o={},i=new Set(e);return t&&Object.keys(process.env).forEach(s=>{s.startsWith("TARO_APP_")&&i.add(s);}),n&&Object.keys(process.env).forEach(s=>{s.startsWith("VITE_")&&i.add(s);}),i.forEach(s=>{let l=process.env[s]||"";o[`process.env.${s}`]=JSON.stringify(l);}),o}function q(){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 D(r={}){let e=[h(r.styleAdapter),{name:"dev-postcss-rpx2px-plugin",apply:"serve",config(t){R.env.TARO_ENV==="h5"&&typeof t.css?.postcss=="object"&&t.css?.postcss.plugins?.unshift(g());}},v(),S(),b(),_()];return R.env.WORKSPACE_GIT_REPO&&e.push(T()),e}export{v as componentIdPlugin,D as default,S as editorBridgePlugin,q as injectAmasterEnv,W as injectTaroEnv,b as routesExposePlugin,g as rpx2pxPlugin,_ as smartReloadPlugin,h as taroStyleAdapterPlugin};//# sourceMappingURL=index.js.map
1006
+ </head>`)}}}function h(e={}){let{ratio:n=2}=e;return {postcssPlugin:"postcss-rpx2px",Declaration(r){r.value?.includes("rpx")&&(r.value=r.value.replace(/(-?\d*\.?\d+)rpx/gi,(t,o)=>{let l=parseFloat(o)/n;return l===0?"0":`${l}px`}));}}}h.postcss=true;var $=/(-?\d*\.?\d+)rpx/gi,K=k.default??k,Y=L.default??L;function E(e,n){return e.replace($,(r,t)=>{let o=Number.parseFloat(t)/n;return o===0?"0":`${o}px`})}function G(e,n){if(!e.value.includes("rpx"))return false;let r=E(e.value,n);return r===e.value?false:(e.value=r,e.extra?.raw&&(e.extra.rawValue=r,e.extra.raw=JSON.stringify(r)),true)}function Q(e,n){let r=e.value.raw;if(!r.includes("rpx"))return false;let t=E(r,n),o=e.value.cooked==null?void 0:E(e.value.cooked,n);return t===r&&o===e.value.cooked?false:(e.value.raw=t,e.value.cooked=o,true)}function Z(e){return e.name.type==="JSXIdentifier"&&e.name.name==="style"}function ee(e,n){let r=false;return e.traverse({StringLiteral(t){G(t.node,n)&&(r=true);},TemplateElement(t){Q(t.node,n)&&(r=true);}}),r}function D(e,n=2){let r=parse(e,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:true}),t=false;return Y(r,{JSXAttribute(o){if(!Z(o.node)||o.node.value?.type!=="JSXExpressionContainer")return;let l=o.get("value");l.isJSXExpressionContainer()&&ee(l,n)&&(t=true);}}),t?{changed:true,code:K(r,{retainLines:true,decoratorsBeforeExport:true,jsescOption:{minimal:true}},e).code}:{changed:false,code:e}}function R(e={}){let{ratio:n=2}=e;return {name:"vite-plugin-jsx-inline-style-rpx",enforce:"pre",transform(r,t){if(process.env.TARO_ENV!=="h5"||!/\.[jt]sx($|\?)/.test(t))return null;let o=D(r,n);return o.changed?{code:o.code,map:null}:null}}}function re(e={}){let{additional:n=[],autoInjectTaroApp:r=true,autoInjectVite:t=true}=e,o={},l=new Set(n);return r&&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 c=process.env[i]||"";o[`process.env.${i}`]=JSON.stringify(c);}),o}function te(){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||""),"process.env.API_BASE_URL":JSON.stringify(process.env.API_BASE_URL||"")}}function ne(e={}){let n=e.isTaro??A.env.TARO_ENV==="h5",r=[C(),I()];return e.jsxSourceTagger!==false&&r.push(S()),e.tailwindConfigSync!==false&&r.push(b({configPath:e.tailwindConfigPath})),n&&(r.unshift(R()),r.unshift(x(e.styleAdapter)),r.unshift({name:"dev-postcss-rpx2px-plugin",apply:"serve",config(t){typeof t.css?.postcss=="object"&&t.css?.postcss.plugins?.unshift(h());}})),A.env.WORKSPACE_GIT_REPO&&r.push(j()),r}export{ne as default,C as editorBridgePlugin,te as injectAmasterEnv,re as injectTaroEnv,R as jsxInlineStyleRpxPlugin,S as jsxSourceTaggerPlugin,I as routesExposePlugin,h as rpx2pxPlugin,b as tailwindConfigSyncPlugin,x as taroStyleAdapterPlugin,D as transformJsxInlineStyleRpx};//# sourceMappingURL=index.js.map
1180
1007
  //# sourceMappingURL=index.js.map