@vtj/renderer 0.16.17 → 0.16.18

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 CHANGED
@@ -2,15 +2,15 @@
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/renderer
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.16.17
5
+ * @version 0.16.18
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const F="0.16.17";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const se=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],st=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],_e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Se={String,Number,Boolean,Array,Object,Function,Date},k="VtjPage",N="VtjHomepage",oe="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot,svg".split(","),we="component,slot".split(","),nt=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),rt={auth:["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o","/","a","u","t","h",".","h","t","m","l"].join(""),storageKey:["R","R","O","_","I","D","E","_","A","C","C","E","S","S","_","S","T","O","R","A","G","E","_","_"].join(""),privateKey:"MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd"};function H(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function q(n){return/\.js$/.test(n)}function Ee(n){return/\.json$/.test(n)}function ot(n){return n.map(e=>`<script src="${f.url.append(e,{v:F})}"><\/script>`).join("")}function it(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:F})}" />`).join("")}function $e(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function be(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],l={},c={},u=[],p={};return s.forEach(({urls:d,assetsUrl:h,library:g,assetsLibrary:m,localeLibrary:v})=>{d?.forEach(y=>{q(y)&&r.push($e(y,t)),B(y)&&o.push(y)}),g&&(i.push(g),l[g]=H(d||[],e),v&&(c[g]=v)),h&&a.push(h),m&&u.push(m),g&&m&&(p[m]=g)}),{scripts:H(r,e),css:H(o,e),materials:H(a,e),libraryExports:i,materialExports:f.dedupArray(u),materialMapLibrary:p,libraryMap:l,libraryLocaleMap:c}}function je(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Re(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>q(s));return{css:e,js:t}}function Ce(n,e){const t=c=>{const u=[];let p=0;for(;p<c.length;){if(/\s/.test(c[p])){p++;continue}if(c.substring(p,p+2)==="/*"){const y=c.indexOf("*/",p+2);if(y!==-1){p=y+2;continue}}if(c[p]==="@"){const y=p;for(;p<c.length&&c[p]!=="{"&&c[p]!==";";)p++;const w=c.substring(y,p).trim(),_=w.includes("@keyframes");if(c[p]===";")u.push({type:"simple-at-rule",content:c.substring(y,p+1)}),p++;else if(c[p]==="{"){const E=p+1;let I=1;for(p++;p<c.length&&I>0;)c[p]==="{"?I++:c[p]==="}"&&I--,p++;const Y=c.substring(y,p),A=c.substring(E,p-1);u.push({type:_?"keyframes":"at-rule",rule:w,content:Y,inner:A})}continue}const d=p;for(;p<c.length&&c[p]!=="{";)p++;if(p>=c.length)break;const h=c.substring(d,p).trim();if(!h){p++;continue}const g=p+1;let m=1;for(p++;p<c.length&&m>0;)c[p]==="{"?m++:c[p]==="}"&&m--,p++;const v=c.substring(g,p-1);u.push({type:"rule",selector:h,content:v.trim()})}return u},s=c=>{const u=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(u)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(u,p,d)=>{const h=p.trim(),g=d.trim();return h?`${h}[${e}] ${g}`:g}),o=c=>{const u=c.trim();if(!u||u.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(u)||s(u))return u;const p=u.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(p){const[,d,h=""]=p,g=d.trim();return g?`${g}[${e}]${h}`:u}return`${u}[${e}]`},a=c=>r(c).split(",").map(p=>o(p)).filter(p=>p.trim()).join(", "),i=c=>c.map(u=>{switch(u.type){case"simple-at-rule":return u.content;case"keyframes":return u.content;case"at-rule":try{const d=t(u.inner),h=i(d);return`${u.rule} { ${h} }`}catch{return u.content}case"rule":if(!u.selector||!u.content)return"";const p=a(u.selector);return p.trim()?`${p} { ${u.content} }`:"";default:return""}}).filter(u=>u.trim()).join(" "),l=c=>c.replace(/\s*{\s*/g," { ").replace(/\s*}\s*/g," } ").replace(/\s*;\s*/g,"; ").replace(/\s*,\s*/g,", ").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").replace(/\s*}\s*}/g," } }").trim();try{const c=n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g,"").replace(/^\s+|\s+$/gm,"").replace(/\n\s*\n/g,`
8
- `),u=t(c),p=i(u);return l(p)}catch(c){return console.error("CSS scoping failed:",c),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,u=>u).replace(/([^{}@]+)(?=\s*{)/g,u=>{const p=u.trim();return!p||p.startsWith("@")||p.includes(`[${e}]`)||s(p)?u:`${p}[${e}]`})}}const at=750;function Pe(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||at;return e*s/r}function Ae(n,e){let t=!1,s=!1,r=!1,o="";for(let a=0;a<e.length;a++){const i=e[a];if(i==="'"&&!s&&!r?t=!t:i==='"'&&!t&&!r?s=!s:e.substr(a,4).toLowerCase()==="url("&&!t&&!s?r=!0:i===")"&&r&&(r=!1),!t&&!s&&!r){const l=e.substr(a).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(l){const c=l[1],u=parseFloat(c),d=`${Pe(n,u).toFixed(6).replace(/\.?0+$/,"")}px`;o+=d,a+=l[0].length-1;continue}}o+=i}return o}function ie(n){return f.isString(n)?n:JSON.stringify(n)}function V(n,e,t,s=!1){const r=n.CSSStyleSheet,o=s?`data-v-${e}`:e,a=n.__uniConfig?Ae(n,t):t,i=s?Ce(a,o):a,l=!!n.__uniConfig;if(r.prototype.replaceSync&&!l){const c=new r;c.id=e,c.replaceSync(i);const u=n.document,p=u.adoptedStyleSheets,d=Array.from(p).filter(h=>h.id!==e);u.adoptedStyleSheets=[...d,c]}else{const c=n.document;let u=c.getElementById(e);u?u.innerHTML=i:(u=c.createElement("style"),u.id=e,u.innerHTML=i,c.head.appendChild(u))}}function ct(n){const e=n.adoptedStyleSheets||[];let t="";if(e.forEach(s=>{try{for(const r of s.cssRules)t+=r.cssText+`
7
+ */const F="0.16.18";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const se=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],st=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],_e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Se={String,Number,Boolean,Array,Object,Function,Date},k="VtjPage",N="VtjHomepage",oe="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot,svg".split(","),we="component,slot".split(","),nt=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),rt={auth:["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o","/","a","u","t","h",".","h","t","m","l"].join(""),storageKey:["R","R","O","_","I","D","E","_","A","C","C","E","S","S","_","S","T","O","R","A","G","E","_","_"].join(""),privateKey:"MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd"};function H(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function q(n){return/\.js$/.test(n)}function Ee(n){return/\.json$/.test(n)}function ot(n){return n.map(e=>`<script src="${f.url.append(e,{v:F})}"><\/script>`).join("")}function it(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:F})}" />`).join("")}function $e(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function be(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],l={},c={},u=[],p={};return s.forEach(({urls:d,assetsUrl:h,library:g,assetsLibrary:m,localeLibrary:v})=>{d?.forEach(y=>{q(y)&&r.push($e(y,t)),B(y)&&o.push(y)}),g&&(i.push(g),l[g]=H(d||[],e),v&&(c[g]=v)),h&&a.push(h),m&&u.push(m),g&&m&&(p[m]=g)}),{scripts:H(r,e),css:H(o,e),materials:H(a,e),libraryExports:i,materialExports:f.dedupArray(u),materialMapLibrary:p,libraryMap:l,libraryLocaleMap:c}}function je(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Ce(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>q(s));return{css:e,js:t}}function Re(n,e){const t=c=>{const u=[];let p=0;for(;p<c.length;){if(/\s/.test(c[p])){p++;continue}if(c.substring(p,p+2)==="/*"){const y=c.indexOf("*/",p+2);if(y!==-1){p=y+2;continue}}if(c[p]==="@"){const y=p;for(;p<c.length&&c[p]!=="{"&&c[p]!==";";)p++;const w=c.substring(y,p).trim(),_=w.includes("@keyframes");if(c[p]===";")u.push({type:"simple-at-rule",content:c.substring(y,p+1)}),p++;else if(c[p]==="{"){const E=p+1;let I=1;for(p++;p<c.length&&I>0;)c[p]==="{"?I++:c[p]==="}"&&I--,p++;const Y=c.substring(y,p),A=c.substring(E,p-1);u.push({type:_?"keyframes":"at-rule",rule:w,content:Y,inner:A})}continue}const d=p;for(;p<c.length&&c[p]!=="{";)p++;if(p>=c.length)break;const h=c.substring(d,p).trim();if(!h){p++;continue}const g=p+1;let m=1;for(p++;p<c.length&&m>0;)c[p]==="{"?m++:c[p]==="}"&&m--,p++;const v=c.substring(g,p-1);u.push({type:"rule",selector:h,content:v.trim()})}return u},s=c=>{const u=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(u)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(u,p,d)=>{const h=p.trim(),g=d.trim();return h?`${h}[${e}] ${g}`:g}),o=c=>{const u=c.trim();if(!u||u.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(u)||s(u))return u;const p=u.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(p){const[,d,h=""]=p,g=d.trim();return g?`${g}[${e}]${h}`:u}return`${u}[${e}]`},a=c=>r(c).split(",").map(p=>o(p)).filter(p=>p.trim()).join(", "),i=c=>c.map(u=>{switch(u.type){case"simple-at-rule":return u.content;case"keyframes":return u.content;case"at-rule":try{const d=t(u.inner),h=i(d);return`${u.rule} { ${h} }`}catch{return u.content}case"rule":if(!u.selector||!u.content)return"";const p=a(u.selector);return p.trim()?`${p} { ${u.content} }`:"";default:return""}}).filter(u=>u.trim()).join(" "),l=c=>c.replace(/\s*{\s*/g," { ").replace(/\s*}\s*/g," } ").replace(/\s*;\s*/g,"; ").replace(/\s*,\s*/g,", ").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").replace(/\s*}\s*}/g," } }").trim();try{const c=n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g,"").replace(/^\s+|\s+$/gm,"").replace(/\n\s*\n/g,`
8
+ `),u=t(c),p=i(u);return l(p)}catch(c){return console.error("CSS scoping failed:",c),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,u=>u).replace(/([^{}@]+)(?=\s*{)/g,u=>{const p=u.trim();return!p||p.startsWith("@")||p.includes(`[${e}]`)||s(p)?u:`${p}[${e}]`})}}const at=750;function Pe(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||at;return e*s/r}function Ae(n,e){let t=!1,s=!1,r=!1,o="";for(let a=0;a<e.length;a++){const i=e[a];if(i==="'"&&!s&&!r?t=!t:i==='"'&&!t&&!r?s=!s:e.substr(a,4).toLowerCase()==="url("&&!t&&!s?r=!0:i===")"&&r&&(r=!1),!t&&!s&&!r){const l=e.substr(a).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(l){const c=l[1],u=parseFloat(c),d=`${Pe(n,u).toFixed(6).replace(/\.?0+$/,"")}px`;o+=d,a+=l[0].length-1;continue}}o+=i}return o}function ie(n){return f.isString(n)?n:JSON.stringify(n)}function V(n,e,t,s=!1){const r=n.CSSStyleSheet,o=s?`data-v-${e}`:e,a=n.__uniConfig?Ae(n,t):t,i=s?Re(a,o):a,l=!!n.__uniConfig;if(r.prototype.replaceSync&&!l){const c=new r;c.id=e,c.replaceSync(i);const u=n.document,p=u.adoptedStyleSheets,d=Array.from(p).filter(h=>h.id!==e);u.adoptedStyleSheets=[...d,c]}else{const c=n.document;let u=c.getElementById(e);u?u.innerHTML=i:(u=c.createElement("style"),u.id=e,u.innerHTML=i,c.head.appendChild(u))}}function ct(n){const e=n.adoptedStyleSheets||[];let t="";if(e.forEach(s=>{try{for(const r of s.cssRules)t+=r.cssText+`
9
9
  `}catch(r){console.error("Failed to read cssRules from adopted stylesheet:",r)}}),t){const s=n.createElement("style");s.textContent=t,n.head.appendChild(s)}}async function Ie(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&V(window,n,t)}function ae(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const a=t.createElement("link");a.rel="stylesheet",a.id=r,a.href=r,s.appendChild(a)}}async function ce(n,e,t=window){const s=t.document,r=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const l of n){const c=s.createElement("script");c.src=l,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=u=>{i(u)},r.appendChild(c)}})}function Te(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function Me(n){return we.includes(n)}function Oe(n){return oe.includes(n)}function D(n=window){const e=window?.Mock;if(e)return e;const t=n?.Mock;if(t&&window)return window.Mock=t,t}function lt(n,e,t){Object.assign(e.meta,t.meta);const s=n?._container;t?.type==="page"&&s.classList.add("is-page"),t?.pure&&s.classList.add("is-pure")}function x(n,e,t=!1,s=!1,r=!1){try{const o=['"use strict";',"var __self = arguments[0];"];o.push("return ");let a=(n.value||"").trim();r||(a=a.replace(/this(\W|$)/g,(l,c)=>`__self${c}`)),a=o.join(`
10
10
  `)+a;const i=r?`
11
11
  ${a}
12
- `:`with(${t?"{}":"$scope || {}"}) { ${a} }`;return new Function("$scope",i)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function C(n,e,t=!1,s=!1,r=!1){const o=x(n,e,t,s,r);if(typeof o!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return o}function R(n){return n&&n.type==="JSExpression"}function j(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Fe(n){return R(n)||j(n)}function ut(n){return Fe(n)?n.value:JSON.stringify(n)}const pt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},le=Symbol("access");class W{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},pt,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:r}=e;this.mode=t,s&&this.mode!==S.Design&&this.setGuard(s),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:s,session:r,authKey:o}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:t}),s&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):f.toArray(e).every(o=>s[o]||s[t+"."+o])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(o=>s[o]||s[t+"."+o])}install(e){e.config.globalProperties.$access=this,e.provide(le,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===k){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function ke(){return b.inject(le,null)}function ft(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:a,alert:i}=n;let l=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:u=>u.data?.code===0||!!u.data?.success,failMessage:!0,showError:u=>{e&&e(u||"未知错误")},showLoading:()=>{l&&l.close(),t&&(l=t())},hideLoading:()=>{l&&(l.close(),l=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:a,alert:i,startupComponent:r,access:o?new W({alert:i,...o}):void 0}}function dt(n={}){return new W(n)}function De(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?x(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(a,i)=>(delete o.data,s.send(f.merge(o,i||{},{data:a})))}}function xe(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,a)}}function He(n=[],e=[],t){const s={};for(const r of n){const o=De(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=xe(r,t);return s}async function Le(n=[],e=window){const t=D(e);t&&(ue(e),n.forEach(s=>Ue(t,s)))}function Ne(n,e=window){const t=j(n.mockTemplate)&&n.mockTemplate.value?C(n.mockTemplate,{},!0):void 0,s=D(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return s?.mock(o)}}function Ue(n,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s)try{const r=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${r}(.*)`),a=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),i=x(s,{},!0);n.mock(o,l=>{const c=f.url.parse(l.url)||{},u=l.body instanceof FormData?f.formDataToJson(l.body):l.body,p=f.isUrl(l.url)?new URL(l.url).pathname:l.url.split("?")[0],d=a(p)?.params;Object.assign(l,{data:u,params:d,query:c});try{return n.mock(i(l))}catch(h){return console.warn("[mockApi]",o,l,h),null}})}catch(r){console.warn("mockApi",r)}}function ue(n=window){const e=D(n);e&&(e._mocked={})}class Be{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=z){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&se.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){se.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return C({type:s,value:r},this)}else return C(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return x({type:s,value:r},this)}else return x(e,this)}__ref(e=null,t){if(this.__mode!==S.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await f.delay(0);let r=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,S.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,s)),typeof t=="function"?t(s):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,s)),s}}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function K(n){const{Vue:e=z,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:s,$libs:r,$apis:o},c=new Be({mode:t,dsl:i.value,attrs:l}),u=e.defineComponent({name:i.value.name,__scopeId:i.value.id?`data-v-${i.value.id}`:void 0,props:{...mt(i.value.props??[],c)},async setup(p){c.$props=p,c.props=p,i.value.id&&V(n.window||window,i.value.id,i.value.css||"",!0),c.state=gt(e,i.value.state??{},c);const d=vt(e,i.value.computed??{},c),h=yt(i.value.methods??{},c),g=_t(e,i.value.inject,c);for(const[y,w]of Object.entries(g||{}))g[y]=e.inject(y,w);const m=qe(i.value.dataSources||{},c),v={...g,...d,...h,...m};return c.setup(v,e),St(e,i.value.watch??[],c),{vtj:c,state:c.state,...d,...h}},emits:ht(i.value.emits),expose:["vtj",...i.value.expose||[]],render(){if(!i.value.nodes)return null;const p=i.value.nodes||[];if(p.length===1)return O(p[0],c,e,a,p);{const d=p.map(h=>O(h,c,e,a,p));return e.createVNode("div",{},d)}},...wt(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(u),context:c}}function ht(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function mt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>Se[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:R(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,r)=>(s[r.name]={type:t(r.type),required:r.required,default:r.default},s),{})}function gt(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return R(o)?o=t.__parseExpression(o):j(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function vt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function yt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function _t(n,e=[],t){return e.reduce((s,r)=>{const{name:o,from:a}=r||{};r.default;const i=R(a)?t.__parseExpression(a)||o:a??o,l=R(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(i,l),s},{})}function qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ne(r);else if(r.ref){const o=e.$apis[r.ref],a=j(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l}}return t},{})}function St(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function wt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const o=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(o)&&(await f.delay(0),await o())},t},{})}const Je=new f.Queue;let Z=[],M={},L={};const Ke=n=>n;async function pe(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>q(i));if(r.length===0||!s)return null;const o=t.filter(i=>B(i));return o.length&&ae(o,e),await ce(r,s,e).catch(i=>(console.warn("loadScriptUrl error",r,s,i),null))}function G(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(Z.forEach(r=>{delete s.window[r]}),Z=[]),(r,o,a=z)=>{if(!o||typeof o=="string")return r;let i="";if(o.type==="Schema"&&o.id)return i=o.id,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.id]||await Je.add(o.id,()=>e(o.id));return l&&(l.name=r,M[o.id]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return i=o.url,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.url]||await t(o.url);return l&&(l.name=r,M[o.url]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="Plugin"){let l=o.library?M[o.library]:null;return l||(o.library&&Z.push(o.library),l=M[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const c=await pe(o,s.window);return c||(console.warn("getPlugin result is null",o),null)}),l)}return r}}function Et(){M={},L={},Je.clearAllCache()}function O(n,e,t=z,s=Ke,r=[],o=!1){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:i=null,directives:l=[]}=n,{vIf:c,vElseIf:u,vElse:p,vFor:d,vShow:h,vModels:g,vBind:m,vHtml:v,others:y}=Ge(l);if(!o&&(u||p))return null;if(c&&!bt(c,e))return At(n,e,t,s,r);const w=(_,E=0)=>{const I=_.$components,Y=(()=>{if(n.name==="component")return jt(_,n.props?.is);if(n.name==="slot")return n.name;const P=s(n.name,n.from,t);return f.isString(P)?Me(P)||Oe(P)?P:I[P]??a?.app?.component(P)??P:P})(),A=Rt(i,n.props??{},_),Ye=Pt(t,n.events??{},_);if(n.name==="slot")return It(t,n,A,_,s);m&&Object.assign(A,_.__parseExpression(m.value)),h&&(A.style=Object.assign(A.style??{},Mt(h,_))),v&&Object.assign(A,Ot(v,_)),g.forEach(P=>{oe.includes(n.name)?Object.assign(A,Ft(P,_)):Object.assign(A,kt(t,P,_))});const Xe=Dt(t,n.children??[],_,s,n),ge=_?.__id?`data-v-${_.__id}`:void 0,Ze=ge?{[ge]:""}:{},et=_.__mode===S.Design?{"data-vtj":i}:{};let X=t.createVNode(Y,{key:`${i}_${E}`,...Ze,...et,...A,...Ye},Xe);const ve=a?$t(a,y,_):[];return ve.length&&(X=t.withDirectives(X,ve)),X};return d?Lt(d,w,e):w(e)}function $t(n,e,t){const s=n.app;return e.map(r=>{const o=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!o)return null;const a=[o];return r.value&&a.push(t.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function Ge(n=[]){const e=n.find(u=>f.camelCase(u.name)==="vIf"),t=n.find(u=>f.camelCase(u.name)==="vElseIf"),s=n.find(u=>f.camelCase(u.name)==="vElse"),r=n.find(u=>f.camelCase(u.name)==="vFor"),o=n.find(u=>f.camelCase(u.name)==="vShow"),a=n.find(u=>f.camelCase(u.name)==="vBind"),i=n.find(u=>f.camelCase(u.name)==="vHtml"),l=n.filter(u=>f.camelCase(u.name)==="vModel"),c=n.filter(u=>!_e.includes(f.camelCase(u.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:l,vBind:a,others:c,vHtml:i}}function bt(n,e){return!!e.__parseExpression(n.value)}function jt(n,e){return e?R(e)?n.__parseExpression(e):e:"div"}function Rt(n,e,t){const s=ne(e,t);return s.ref=t.__ref(n,s.ref),s}function ne(n,e){return R(n)?e.__parseExpression(n):j(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ne(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ne(r,e),t},{}):n}function Ct(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function Pt(n,e,t){const s=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=fe(i.modifiers),c=l.find(d=>s.includes(d)),u="on"+f.upperFirst(a)+(c&&r[c]||""),p=t.__parseFunction(i.handler);return p&&(o[u]=n.withModifiers(l.includes("enter")?Ct(p,"enter"):p,l)),o},{})}function At(n,e,t,s,r=[]){let o=r.findIndex(a=>a.id===n.id);for(let a=++o;a<r.length;a++){const{directives:i=[]}=r[a],{vElseIf:l,vElse:c}=Ge(i);if(l){if(e.__parseExpression(l.value))return O(r[a],e,t,s,r,!0);continue}if(c)return O(r[a],e,t,s,r,!0)}return null}function fe(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function It(n,e,t,s,r){const{children:o}=e,a=Tt(e,s),i=s.$slots?.[a.name];return i?i(t):o?f.isString(o)?n.createTextVNode(o):R(o)?n.createTextVNode(ie(s.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,s,n,r,o)):null:null}function Tt(n,e){const{props:t}=n,s=t?.name||"default";return{name:R(s)?e.__parseExpression(s):s,params:[]}}function Mt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ot(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Ft(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
12
+ `:`with(${t?"{}":"$scope || {}"}) { ${a} }`;return new Function("$scope",i)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function R(n,e,t=!1,s=!1,r=!1){const o=x(n,e,t,s,r);if(typeof o!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return o}function C(n){return n&&n.type==="JSExpression"}function j(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Fe(n){return C(n)||j(n)}function ut(n){return Fe(n)?n.value:JSON.stringify(n)}const pt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},le=Symbol("access");class W{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},pt,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:r}=e;this.mode=t,s&&this.mode!==S.Design&&this.setGuard(s),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:s,session:r,authKey:o}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:t}),s&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):f.toArray(e).every(o=>s[o]||s[t+"."+o])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(o=>s[o]||s[t+"."+o])}install(e){e.config.globalProperties.$access=this,e.provide(le,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===k){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function ke(){return b.inject(le,null)}function ft(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:a,alert:i}=n;let l=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:u=>u.data?.code===0||!!u.data?.success,failMessage:!0,showError:u=>{e&&e(u||"未知错误")},showLoading:()=>{l&&l.close(),t&&(l=t())},hideLoading:()=>{l&&(l.close(),l=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:a,alert:i,startupComponent:r,access:o?new W({alert:i,...o}):void 0}}function dt(n={}){return new W(n)}function De(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?x(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(a,i)=>(delete o.data,s.send(f.merge(o,i||{},{data:a})))}}function xe(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,a)}}function He(n=[],e=[],t){const s={};for(const r of n){const o=De(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=xe(r,t);return s}async function Le(n=[],e=window){const t=D(e);t&&(ue(e),n.forEach(s=>Ue(t,s)))}function Ne(n,e=window){const t=j(n.mockTemplate)&&n.mockTemplate.value?R(n.mockTemplate,{},!0):void 0,s=D(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return s?.mock(o)}}function Ue(n,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s)try{const r=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${r}(.*)`),a=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),i=x(s,{},!0);n.mock(o,l=>{const c=f.url.parse(l.url)||{},u=l.body instanceof FormData?f.formDataToJson(l.body):l.body,p=f.isUrl(l.url)?new URL(l.url).pathname:l.url.split("?")[0],d=a(p)?.params;Object.assign(l,{data:u,params:d,query:c});try{return n.mock(i(l))}catch(h){return console.warn("[mockApi]",o,l,h),null}})}catch(r){console.warn("mockApi",r)}}function ue(n=window){const e=D(n);e&&(e._mocked={})}class Be{__id=null;__mode;__instance=null;__contextRefs={};__refs={};__refCaches={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=z){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.__refCaches={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&se.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){se.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.__refCaches={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return R({type:s,value:r},this)}else return R(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return x({type:s,value:r},this)}else return x(e,this)}__ref(e=null,t){if(this.__mode===S.VNode)return;e&&e!==this.__id&&(this.__contextRefs[e]=this);let s=e?this.__refCaches[e]:null;return s||(s=async r=>{await f.delay(0);let o=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!o){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return o.nodeType===3&&o.nextSibling&&(o=o.nextSibling),o.__vtj__=e,S.Design===this.__mode&&(o.__context__=this,o.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,r)),typeof t=="function"?t(r):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,r)),r},e&&(this.__refCaches[e]=s),s)}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function K(n){const{Vue:e=z,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:s,$libs:r,$apis:o},c=new Be({mode:t,dsl:i.value,attrs:l}),u=e.defineComponent({name:i.value.name,__scopeId:i.value.id?`data-v-${i.value.id}`:void 0,props:{...mt(i.value.props??[],c)},async setup(p){c.$props=p,c.props=p,i.value.id&&V(n.window||window,i.value.id,i.value.css||"",!0),c.state=gt(e,i.value.state??{},c);const d=vt(e,i.value.computed??{},c),h=yt(i.value.methods??{},c),g=_t(e,i.value.inject,c);for(const[y,w]of Object.entries(g||{}))g[y]=e.inject(y,w);const m=qe(i.value.dataSources||{},c),v={...g,...d,...h,...m};return c.setup(v,e),St(e,i.value.watch??[],c),{vtj:c,state:c.state,...d,...h}},emits:ht(i.value.emits),expose:["vtj",...i.value.expose||[]],render(){if(!i.value.nodes)return null;const p=i.value.nodes||[];if(p.length===1)return O(p[0],c,e,a,p);{const d=p.map(h=>O(h,c,e,a,p));return e.createVNode("div",{},d)}},...wt(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(u),context:c}}function ht(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function mt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>Se[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:C(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,r)=>(s[r.name]={type:t(r.type),required:r.required,default:r.default},s),{})}function gt(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return C(o)?o=t.__parseExpression(o):j(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function vt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function yt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function _t(n,e=[],t){return e.reduce((s,r)=>{const{name:o,from:a}=r||{};r.default;const i=C(a)?t.__parseExpression(a)||o:a??o,l=C(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(i,l),s},{})}function qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ne(r);else if(r.ref){const o=e.$apis[r.ref],a=j(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l}}return t},{})}function St(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function wt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const o=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(o)&&(await f.delay(0),await o())},t},{})}const Je=new f.Queue;let Z=[],M={},L={};const Ke=n=>n;async function pe(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>q(i));if(r.length===0||!s)return null;const o=t.filter(i=>B(i));return o.length&&ae(o,e),await ce(r,s,e).catch(i=>(console.warn("loadScriptUrl error",r,s,i),null))}function G(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(Z.forEach(r=>{delete s.window[r]}),Z=[]),(r,o,a=z)=>{if(!o||typeof o=="string")return r;let i="";if(o.type==="Schema"&&o.id)return i=o.id,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.id]||await Je.add(o.id,()=>e(o.id));return l&&(l.name=r,M[o.id]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return i=o.url,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.url]||await t(o.url);return l&&(l.name=r,M[o.url]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="Plugin"){let l=o.library?M[o.library]:null;return l||(o.library&&Z.push(o.library),l=M[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const c=await pe(o,s.window);return c||(console.warn("getPlugin result is null",o),null)}),l)}return r}}function Et(){M={},L={},Je.clearAllCache()}function O(n,e,t=z,s=Ke,r=[],o=!1){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:i=null,directives:l=[]}=n,{vIf:c,vElseIf:u,vElse:p,vFor:d,vShow:h,vModels:g,vBind:m,vHtml:v,others:y}=Ge(l);if(!o&&(u||p))return null;if(c&&!bt(c,e))return At(n,e,t,s,r);const w=(_,E=0)=>{const I=_.$components,Y=(()=>{if(n.name==="component")return jt(_,n.props?.is);if(n.name==="slot")return n.name;const P=s(n.name,n.from,t);return f.isString(P)?Me(P)||Oe(P)?P:I[P]??a?.app?.component(P)??P:P})(),A=Ct(i,n.props??{},_),Ye=Pt(t,n.events??{},_);if(n.name==="slot")return It(t,n,A,_,s);m&&Object.assign(A,_.__parseExpression(m.value)),h&&(A.style=Object.assign(A.style??{},Mt(h,_))),v&&Object.assign(A,Ot(v,_)),g.forEach(P=>{oe.includes(n.name)?Object.assign(A,Ft(P,_)):Object.assign(A,kt(t,P,_))});const Xe=Dt(t,n.children??[],_,s,n),ge=_?.__id?`data-v-${_.__id}`:void 0,Ze=ge?{[ge]:""}:{},et=_.__mode===S.Design?{"data-vtj":i}:{};let X=t.createVNode(Y,{key:`${i}_${E}`,...Ze,...et,...A,...Ye},Xe);const ve=a?$t(a,y,_):[];return ve.length&&(X=t.withDirectives(X,ve)),X};return d?Lt(d,w,e):w(e)}function $t(n,e,t){const s=n.app;return e.map(r=>{const o=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!o)return null;const a=[o];return r.value&&a.push(t.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function Ge(n=[]){const e=n.find(u=>f.camelCase(u.name)==="vIf"),t=n.find(u=>f.camelCase(u.name)==="vElseIf"),s=n.find(u=>f.camelCase(u.name)==="vElse"),r=n.find(u=>f.camelCase(u.name)==="vFor"),o=n.find(u=>f.camelCase(u.name)==="vShow"),a=n.find(u=>f.camelCase(u.name)==="vBind"),i=n.find(u=>f.camelCase(u.name)==="vHtml"),l=n.filter(u=>f.camelCase(u.name)==="vModel"),c=n.filter(u=>!_e.includes(f.camelCase(u.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:l,vBind:a,others:c,vHtml:i}}function bt(n,e){return!!e.__parseExpression(n.value)}function jt(n,e){return e?C(e)?n.__parseExpression(e):e:"div"}function Ct(n,e,t){const s=ne(e,t);return s.ref=t.__ref(n,s.ref),s}function ne(n,e){return C(n)?e.__parseExpression(n):j(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ne(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ne(r,e),t},{}):n}function Rt(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function Pt(n,e,t){const s=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=fe(i.modifiers),c=l.find(d=>s.includes(d)),u="on"+f.upperFirst(a)+(c&&r[c]||""),p=t.__parseFunction(i.handler);return p&&(o[u]=n.withModifiers(l.includes("enter")?Rt(p,"enter"):p,l)),o},{})}function At(n,e,t,s,r=[]){let o=r.findIndex(a=>a.id===n.id);for(let a=++o;a<r.length;a++){const{directives:i=[]}=r[a],{vElseIf:l,vElse:c}=Ge(i);if(l){if(e.__parseExpression(l.value))return O(r[a],e,t,s,r,!0);continue}if(c)return O(r[a],e,t,s,r,!0)}return null}function fe(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function It(n,e,t,s,r){const{children:o}=e,a=Tt(e,s),i=s.$slots?.[a.name];return i?i(t):o?f.isString(o)?n.createTextVNode(o):C(o)?n.createTextVNode(ie(s.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,s,n,r,o)):null:null}function Tt(n,e){const{props:t}=n,s=t?.name||"default";return{name:C(s)?e.__parseExpression(s):s,params:[]}}function Mt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ot(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Ft(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
13
13
  ${n.value.value} = v?.target.value;
14
- }`:"(v) => {}"};return{[R(n.arg)?e.__parseExpression(n.arg):n.arg||"value"]:e.__parseExpression(n.value),onInput:e.__parseFunction(t)}}function kt(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
14
+ }`:"(v) => {}"};return{[C(n.arg)?e.__parseExpression(n.arg):n.arg||"value"]:e.__parseExpression(n.value),onInput:e.__parseFunction(t)}}function kt(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
15
15
  ${e.value.value} = v;
16
- }`:"(v) => {}"},r=t.__parseFunction(s),o=fe(R(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),a=R(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?n.withModifiers(r,o):r}}function Dt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(R(e))return{default:()=>ie(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=xt(e),a=(i,l)=>!i||!r?{}:r?.id&&Object.keys(i).length?l?{[l]:i}:{[`scope_${r.id}`]:i}:l?{[l]:Object.create(null)}:{};return Object.entries(o).reduce((i,[l,{nodes:c,params:u,scope:p}])=>(i[l]=d=>{const h=u.length?f.pick(d??{},u):a(d,p);return c.map(g=>O(g,t.__clone(h),n,s,c))},i),{})}return null}function xt(n){const e={};for(const t of n){const s=Ht(t.slot),r=s.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(s.params),e[r].scope=s.scope||""):e[r]={nodes:[t],params:s.params,scope:s.scope||""}}return e}function Ht(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Lt(n,e,t){const{value:s,iterator:r}=n,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(s)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}),c)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const ee=b.defineComponent({name:"VtjPageContainer",async setup(){const n=me(),e=ye.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,o=b.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:a}=n?.adapter;if(a){const i=e.meta.title||s.title||"VTJ.PRO";a(i)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:o,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?b.h(n,{...e,key:t}):b.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Nt=b.defineComponent({name:"VtjStartupContainer",render(){return b.h("div","page not found!")}});function U(n,e,t=[]){const s=[];for(const r of t){const{id:o,title:a,icon:i,children:l,hidden:c,layout:u}=r;if(u){const p=U(n,e,l||[]);s.push(...p)}else{const p={id:o,title:a,icon:i,hidden:c,url:`${n}/${e}/${o}`,children:l&&l.length?U(n,e,l):void 0};s.push(p)}}return s}function de(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=de(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Ut(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=me(),o=ye.useRoute(),a=ke(),i=b.ref(!1),l=b.ref(!1),c=r.project,u=(h,g)=>{i.value=!h?.mask,l.value=g?.pure??!!h?.pure};b.watchEffect(()=>{const{name:h,params:g,meta:m}=o;if(h===k){const v=r.getPage(g.id);u(v,m)}else if(h===N){const v=r.getHomepage();u(v,m)}else{const v=m.__vtj__;if(v){const y=r.getPage(v);u(y,m)}else i.value=!m.mask,l.value=!!m.pure}});const p=U(e,t,c?.pages),d=c?.config;return{disabled:i,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||c?.description||c?.name||"VTJ App",menus:s?p:de(p,a),pure:l}}function te(n,e){const{id:t,title:s,meta:r}=n,{name:o="page",prefix:a="",component:i,routeMeta:l}=e;return{name:t,path:`${a}${o}/${t}`,component:i,meta:{title:s,...l,...r,__vtj__:t}}}function re(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:o,routeMeta:a,homepage:i}=n,l=[];for(const c of s){const{id:u,title:p,dir:d,layout:h,children:g,meta:m}=c;if(d){const v=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]});l.push(...v)}else if(h){const v=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]}),y={name:`layout_${u}`,path:t,component:()=>o(u),meta:{title:p,...a,...m,__vtj__:u},children:v};l.push(y),l.push(te(c,n))}else if(l.push(te(c,n)),i===u){const v=te(c,n);v.path="",v.name=`home_${u}`,l.push(v)}}return l}function Bt(n={},e){const{css:t,store:s,enhance:r}=n,{window:o,app:a,library:i={},adapter:l,mode:c}=e,{Pinia:u}=i;a.config.globalProperties.$libs=i,V(o,"global-css",t||""),u&&s&&qt(s,a,u),Kt(a,l,n),!l.access&&n.access&&Jt(n.access,a,c,l),Gt(a,n),r&&zt(r,a,i)}function qt(n,e,t){const s=t.createPinia();if(e.use(s),j(n)&&n.value){const r=C(n,{},!1,!1,!0),o=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=o()}}function Jt(n,e,t,s){if(j(n)&&n.value){const r=C(n,{},!1,!1,!0),{alert:o,request:a}=s,i=new W({alert:o,storagePrefix:"__VTJ_APP_",...r(e)}),l=e.config.globalProperties.$router;i.connect({mode:t,router:l,request:a}),e.use(i)}}function Kt(n,e,t){if(!e.request)return;const{axios:s,request:r,response:o}=t;if(s&&j(s)&&s.value){const a=C(s,{},!1,!1,!0);e.request.setConfig(a(n))}if(r&&j(r)&&r.value){const a=C(r,{},!1,!1,!0),i=e.request;i.__unReq&&i.__unReq(),i.__unReq=e.request.useRequest(l=>a(l,n))}if(o&&j(o)&&o.value){const a=C(o,{},!1,!1,!0),i=e.request;i.__unRes&&i.__unRes(),i.__unRes=e.request.useResponse(l=>a(l,n))}}function Gt(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&j(t)&&t.value){const o=C(t,{},!1,!1,!0);r&&r.beforeEach((a,i,l)=>o(a,i,l,n))}if(s&&j(s)&&s.value){const o=C(s,{},!1,!1,!0);r&&r.afterEach((a,i,l)=>o(a,i,l,n))}}function zt(n,e,t={}){j(n)&&n.value&&C(n,{},!1,!1,!0)(e,t)}function Vt(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:o,messages:a=[]}=t,i={};for(let c of a){const u=Object.keys(c).filter(p=>p!=="key");for(const p of u)i[p]||(i[p]={}),i[p][c.key]=c[p]}const l=s.createI18n({legacy:!1,locale:r,fallbackLocale:o,messages:i});n.use(l)}}const he=Symbol("Provider");var ze=(n=>(n.Production="production",n.Development="development",n))(ze||{});class Ve extends T.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:u=null,materialPath:p="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=u,this.materialPath=p,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i);const{access:h,request:g}=this.adapter;h&&h.connect({mode:s,router:u,request:g}),a&&s!==S.Design?this.load(a):this.project=a}mode;globals={};modules={};adapter={request:f.request,jsonp:f.jsonp};apis={};dependencies={};materials={};library={};libraryLocales={};libraryLocaleMap={};service;project=null;components={};nodeEnv="development";env={};router=null;materialPath="./";urlDslCaches={};errorHandler=null;createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(o){f.logger.warn("模拟数据模版异常",o)}return D()?.mock(s)}}async load(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/projects/${e.id}.json`]||this.modules[`/src/${t}/projects/${e.id}.json`];if(this.project=s?await s():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:r=[],meta:o=[],env:a=[]}=this.project,i=window;i&&(i.CKEDITOR_VERSION=void 0),this.initEnv(a),this.mode===S.Raw?await this.loadDependencies(i):await this.loadAssets(i),this.initMock(i),this.apis=He(r,o,this.adapter),ue(i),Le(r,i),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=D(e);t&&t.setup({timeout:"50-500"})}async loadDependencies(e={}){const t=Object.entries(this.dependencies);for(const[s,r]of t)e[s]||(e[s]=this.library[s]=await r())}async loadAssets(e={}){const{dependencies:t=[]}=this.project,{dependencies:s,library:r,components:o,materialPath:a,nodeEnv:i,libraryLocales:l}=this,{libraryExports:c,libraryMap:u,materials:p,materialExports:d,materialMapLibrary:h,libraryLocaleMap:g}=be(t,a,i==="development");Object.assign(this.libraryLocaleMap,g);for(const m of c){const v=s[m],y=e[m];if(y)r[m]=y;else if(v)e[m]=r[m]=await v();else{const _=u[m]||[];for(const E of _)B(E)&&await Ie(E,f.url.append(E,{v:F})),q(E)&&await f.loadScript(f.url.append(E,{v:F}));r[m]=e[m]}const w=g[m];if(w){const _=s[w];l[w]=_?await _():e[w]}}if(i==="development"){for(const v of p)await f.loadScript(f.url.append(v,{v:F}));const m=this.materials||{};for(const v of d){const y=e[h[v]],w=y?.default||y,_=T.BUILT_IN_COMPONENTS[v];if(_)w&&_.forEach(E=>{o[E]=w[E]});else{const E=m[v]?(await m[v]()).default:e[v];E&&w&&(E.components||[]).forEach(I=>{o[I.name]=je(I,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const o=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:a,pageRouteName:i=o,routeMeta:l}=s,c=a?"":"/",u={path:`${c}${i}/:id`,name:k,component:ee},p=this.getHomepage(),d={path:c,name:N,component:p?ee:r.startupComponent||Nt,meta:l};if(e.hasRoute(k)&&e.removeRoute(k),e.hasRoute(N)&&e.removeRoute(N),s.enableStaticRoute){const h=t?.pages||[];re({name:i,prefix:c,pages:h,component:ee,loader:this.getRenderComponent.bind(this),homepage:p?.id}).forEach(m=>{a?e.addRoute(a,m):e.addRoute(m)}),p||(a?e.addRoute(a,d):e.addRoute(d))}else a?(e.addRoute(a,u),e.addRoute(a,d)):(e.addRoute(u),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const o=s?.$options.name,a=typeof t=="string"?t:t?.message||t?.msg||"未知错误",i=`[ ${o} ] ${a} ${r}`;["getComputedStyle","ResizeObserver"].some(c=>i.includes(c))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(i,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,o=e.config.globalProperties.installed||{};for(const[a,i]of Object.entries(this.library))if(!o[a]&&Te(i)){const c={locale:s[t[a]]},u=r[a]||{},p={...c,...u};e.use(i,p),o[a]=!0}e.provide(he,this),e.config.globalProperties.$provider=this,e.config.globalProperties.$request=this.adapter?.request,this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),this.project?.platform!=="uniapp"&&this.mode!==S.Design&&this.initGlobals(this.project?.globals||{},{app:e,window,adapter:this.adapter,library:this.library,mode:this.mode}),this.mode!==S.Design&&this.project?.i18n&&this.initI18n(e,this.library,this.project.i18n),this.options.enhance&&e.use(this.options.enhance,this),this.mode===S.Design&&this.setErrorHandler(e),e.config.globalProperties.installed=o}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(s=>s.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},s=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=s(r,a.children);if(i)return i}}};return s(e,t)||null}getFirstPage(){const{pages:e=[]}=this.project||{};if(!e.length)return null;const t=(s=[])=>{for(const r of s){if(r.type==="page"&&!r.dir&&!r.layout)return r;if(r.children&&r.children.length){const o=t(r.children);if(o)return o}}};return t(e)||null}getMenus(e="page",t=""){return U(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):this.getFirstPage()}async getDsl(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/files/${e}.json`]||this.modules[`/src/${t}/files/${e}.json`];return s?await s():this.service.getFile(e,this.project||void 0).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.adapter.request?this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null):null)}createDslRenderer(e,t={}){const{library:s,components:r,mode:o,apis:a}=this,i={mode:o,Vue:s.Vue,components:r,libs:s,apis:a,window,...t},l=G({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return K({...i,dsl:e,loader:l})}async getRenderComponent(e,t){const s=this.getFile(e);if(!s)return f.logger.warn(`Can not find file: ${e}`),null;if(t&&t(s),this.mode===S.Raw){const{vtjRawDir:o=".vtj/vue"}=this.options,a=`${o}/${e}.vue`,i=this.modules[a]||this.modules[`/src/pages/${e}.vue`];return i?(await i())?.default:this.nodeEnv==="development"&&this.adapter.startupComponent||null}const r=await this.getDsl(s.id);return r?this.createDslRenderer(r).renderer:(f.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return b.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return b.defineAsyncComponent(async()=>await pe(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Bt(e,s)}initI18n(e,t,s){Vt(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function Wt(n){const e=new Ve(n);return{provider:e,onReady:s=>e.ready(s)}}function me(n={}){const e=b.inject(he,null);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=n;t&&s&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==s&&e.adapter.notify&&e.adapter.notify(`[ ${r?.name} ] 组件源码版本与运行时版本不一致,请重新发布组件`,"版本不一致","warning")})()}return e}async function Qt(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(i=>e+i),{css:o,js:a}=Re(r);if(o.length&&ae(o),a.length)return await ce(a,t).catch(()=>{})}const We={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},Yt=(n,e="/__vtj__/api/:type.json")=>(t,s,r)=>n.send({url:e,method:"post",params:{type:t},query:r,data:{type:t,data:s},settings:We}),Xt=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...We,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function Zt(n){return f.createRequest({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:e=>e.data?.code===0,showError:e=>{n&&n(e||"未知错误")}}})}class Q{constructor(e=f.request){this.req=e,this.api=Yt(e),this.uploader=Xt(e)}api;pluginCaches={};uploader;async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return console.log("BaseService.saveMaterials",e,t),!1}async saveFile(e){return console.log("BaseService.saveFile",e),!1}async getFile(e){return console.log("BaseService.getFile",e),{}}async removeFile(e){return console.log("BaseService.removeFile",e),!1}async saveHistory(e){return console.log("BaseService.saveHistory",e),!1}async removeHistory(e){return console.log("BaseService.removeHistory",e),!1}async getHistory(e){return console.log("BaseService.getHistory",e),{}}async getHistoryItem(e,t){return console.log("BaseService.getHistoryItem",e,t),{}}async saveHistoryItem(e,t){return console.log("BaseService.saveHistoryItem",e,t),!1}async removeHistoryItem(e,t){return console.log("BaseService.removeHistoryItem",e,t),!1}async publish(e){return!!await this.api("publish",e).catch(()=>!1)}async publishFile(e,t){return!!await this.api("publishFile",{project:e,file:t}).catch(()=>!1)}async genVueContent(e,t){return await this.api("genVueContent",{project:e,dsl:t}).catch(()=>"")}async parseVue(e,t){return await this.api("parseVue",{project:e,...t})}async createRawPage(e){return await this.api("createRawPage",e).catch(()=>"")}async removeRawPage(e){return await this.api("removeRawPage",e).catch(()=>"")}async uploadStaticFile(e,t){return await this.uploader(e,t).catch(()=>null)}async getStaticFiles(e){return await this.api("getStaticFiles",e).catch(()=>[])}async removeStaticFile(e,t){return await this.api("removeStaticFile",{name:e,projectId:t}).catch(()=>"")}async clearStaticFiles(e){return await this.api("clearStaticFiles",e).catch(()=>"")}async getPluginMaterial(e){const{urls:t=[]}=e,s=t.filter(o=>Ee(o))[0];if(!s)return null;const r=this.pluginCaches[s];return r||(this.pluginCaches[s]=f.request.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const $=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class es extends Q{init(e){const t=new T.ProjectModel(e),s=$.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return $.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return $.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return $.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return $.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=$.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return $.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return $.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=$.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),$.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=$.get(`history_${e}`),s=new T.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=$.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return $.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{$.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class Qe extends Q{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new T.ProjectModel(e),s=this.projects[t.id]||{},r=Object.assign(t.toDsl(),s);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new T.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,r=this.historyItems[s]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const r=`${e}_${s}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let J=null;function ts(){return J||(J=new Qe,J)}class ss extends Q{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:f.mapToObject(t)}).catch(()=>!1)}async saveFile(e){return!!await this.api("saveFile",e).catch(()=>!1)}async getFile(e){const t=this.getFileCaches[e];return t||(this.getFileCaches[e]=this.api("getFile",e).catch(()=>null)).finally(()=>{delete this.getFileCaches[e]})}async removeFile(e){return!!await this.api("removeFile",e).catch(()=>!1)}async saveHistory(e){return!!await this.api("saveHistory",e).catch(()=>!1)}async removeHistory(e){return!!await this.api("removeHistory",e).catch(()=>!1)}async getHistory(e){return await this.api("getHistory",e).catch(()=>null)||{}}async getHistoryItem(e,t){return await this.api("getHistoryItem",{fId:e,id:t}).catch(()=>null)||{}}async saveHistoryItem(e,t){return!!await this.api("saveHistoryItem",{fId:e,item:t}).catch(()=>!1)}async removeHistoryItem(e,t){return!!await this.api("removeHistoryItem",{fId:e,ids:t}).catch(()=>!1)}}exports.ACCESS=rt;exports.ACCESS_KEY=le;exports.Access=W;exports.BUILD_IN_TAGS=we;exports.BUILT_IN_DIRECTIVES=_e;exports.BaseService=Q;exports.CONTEXT_HOST=se;exports.Context=Be;exports.ContextMode=S;exports.DATA_TYPES=Se;exports.HOMEPAGE_ROUTE_NAME=N;exports.HTML_TAGS=oe;exports.JSCodeToString=ut;exports.LIFE_CYCLES_LIST=st;exports.LocalService=ss;exports.MemoryService=Qe;exports.NodeEnv=ze;exports.PAGE_ROUTE_NAME=k;exports.Provider=Ve;exports.REMOTE=nt;exports.StorageService=es;exports.VTJ_RENDERER_VERSION=F;exports.adoptStylesToInline=ct;exports.adoptedStyleSheets=V;exports.clearLoaderCache=Et;exports.compileScopedCSS=Ce;exports.convertCssRpx=Ae;exports.createAccess=dt;exports.createAdapter=ft;exports.createAssetScripts=ot;exports.createAssetsCss=it;exports.createDataSources=qe;exports.createLoader=G;exports.createMemoryService=ts;exports.createMenus=U;exports.createMetaApi=xe;exports.createMock=Ne;exports.createProvider=Wt;exports.createRenderer=K;exports.createSchemaApi=De;exports.createSchemaApis=He;exports.createServiceRequest=Zt;exports.defaultLoader=Ke;exports.fillBasePath=H;exports.getMock=D;exports.getModifiers=fe;exports.getPlugin=pe;exports.getRawComponent=je;exports.isBuiltInTag=Me;exports.isCSSUrl=B;exports.isJSCode=Fe;exports.isJSExpression=R;exports.isJSFunction=j;exports.isJSON=Ee;exports.isJSUrl=q;exports.isNativeTag=Oe;exports.isVuePlugin=Te;exports.loadCss=Ie;exports.loadCssUrl=ae;exports.loadEnhance=Qt;exports.loadScriptUrl=ce;exports.menusFilter=de;exports.mockApi=Ue;exports.mockApis=Le;exports.mockCleanup=ue;exports.nodeRender=O;exports.parseDeps=be;exports.parseExpression=x;exports.parseFunction=C;exports.parseUrls=Re;exports.providerKey=he;exports.removeProdFlag=$e;exports.rpxToPx=Pe;exports.setupPageSetting=lt;exports.toString=ie;exports.useAccess=ke;exports.useMask=Ut;exports.useProvider=me;
16
+ }`:"(v) => {}"},r=t.__parseFunction(s),o=fe(C(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),a=C(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?n.withModifiers(r,o):r}}function Dt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(C(e))return{default:()=>ie(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=xt(e),a=(i,l)=>!i||!r?{}:r?.id&&Object.keys(i).length?l?{[l]:i}:{[`scope_${r.id}`]:i}:l?{[l]:Object.create(null)}:{};return Object.entries(o).reduce((i,[l,{nodes:c,params:u,scope:p}])=>(i[l]=d=>{const h=u.length?f.pick(d??{},u):a(d,p);return c.map(g=>O(g,t.__clone(h),n,s,c))},i),{})}return null}function xt(n){const e={};for(const t of n){const s=Ht(t.slot),r=s.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(s.params),e[r].scope=s.scope||""):e[r]={nodes:[t],params:s.params,scope:s.scope||""}}return e}function Ht(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Lt(n,e,t){const{value:s,iterator:r}=n,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(s)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}),c)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const ee=b.defineComponent({name:"VtjPageContainer",async setup(){const n=me(),e=ye.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,o=b.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:a}=n?.adapter;if(a){const i=e.meta.title||s.title||"VTJ.PRO";a(i)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:o,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?b.h(n,{...e,key:t}):b.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Nt=b.defineComponent({name:"VtjStartupContainer",render(){return b.h("div","page not found!")}});function U(n,e,t=[]){const s=[];for(const r of t){const{id:o,title:a,icon:i,children:l,hidden:c,layout:u}=r;if(u){const p=U(n,e,l||[]);s.push(...p)}else{const p={id:o,title:a,icon:i,hidden:c,url:`${n}/${e}/${o}`,children:l&&l.length?U(n,e,l):void 0};s.push(p)}}return s}function de(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=de(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Ut(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=me(),o=ye.useRoute(),a=ke(),i=b.ref(!1),l=b.ref(!1),c=r.project,u=(h,g)=>{i.value=!h?.mask,l.value=g?.pure??!!h?.pure};b.watchEffect(()=>{const{name:h,params:g,meta:m}=o;if(h===k){const v=r.getPage(g.id);u(v,m)}else if(h===N){const v=r.getHomepage();u(v,m)}else{const v=m.__vtj__;if(v){const y=r.getPage(v);u(y,m)}else i.value=!m.mask,l.value=!!m.pure}});const p=U(e,t,c?.pages),d=c?.config;return{disabled:i,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||c?.description||c?.name||"VTJ App",menus:s?p:de(p,a),pure:l}}function te(n,e){const{id:t,title:s,meta:r}=n,{name:o="page",prefix:a="",component:i,routeMeta:l}=e;return{name:t,path:`${a}${o}/${t}`,component:i,meta:{title:s,...l,...r,__vtj__:t}}}function re(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:o,routeMeta:a,homepage:i}=n,l=[];for(const c of s){const{id:u,title:p,dir:d,layout:h,children:g,meta:m}=c;if(d){const v=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]});l.push(...v)}else if(h){const v=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]}),y={name:`layout_${u}`,path:t,component:()=>o(u),meta:{title:p,...a,...m,__vtj__:u},children:v};l.push(y),l.push(te(c,n))}else if(l.push(te(c,n)),i===u){const v=te(c,n);v.path="",v.name=`home_${u}`,l.push(v)}}return l}function Bt(n={},e){const{css:t,store:s,enhance:r}=n,{window:o,app:a,library:i={},adapter:l,mode:c}=e,{Pinia:u}=i;a.config.globalProperties.$libs=i,V(o,"global-css",t||""),u&&s&&qt(s,a,u),Kt(a,l,n),!l.access&&n.access&&Jt(n.access,a,c,l),Gt(a,n),r&&zt(r,a,i)}function qt(n,e,t){const s=t.createPinia();if(e.use(s),j(n)&&n.value){const r=R(n,{},!1,!1,!0),o=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=o()}}function Jt(n,e,t,s){if(j(n)&&n.value){const r=R(n,{},!1,!1,!0),{alert:o,request:a}=s,i=new W({alert:o,storagePrefix:"__VTJ_APP_",...r(e)}),l=e.config.globalProperties.$router;i.connect({mode:t,router:l,request:a}),e.use(i)}}function Kt(n,e,t){if(!e.request)return;const{axios:s,request:r,response:o}=t;if(s&&j(s)&&s.value){const a=R(s,{},!1,!1,!0);e.request.setConfig(a(n))}if(r&&j(r)&&r.value){const a=R(r,{},!1,!1,!0),i=e.request;i.__unReq&&i.__unReq(),i.__unReq=e.request.useRequest(l=>a(l,n))}if(o&&j(o)&&o.value){const a=R(o,{},!1,!1,!0),i=e.request;i.__unRes&&i.__unRes(),i.__unRes=e.request.useResponse(l=>a(l,n))}}function Gt(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&j(t)&&t.value){const o=R(t,{},!1,!1,!0);r&&r.beforeEach((a,i,l)=>o(a,i,l,n))}if(s&&j(s)&&s.value){const o=R(s,{},!1,!1,!0);r&&r.afterEach((a,i,l)=>o(a,i,l,n))}}function zt(n,e,t={}){j(n)&&n.value&&R(n,{},!1,!1,!0)(e,t)}function Vt(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:o,messages:a=[]}=t,i={};for(let c of a){const u=Object.keys(c).filter(p=>p!=="key");for(const p of u)i[p]||(i[p]={}),i[p][c.key]=c[p]}const l=s.createI18n({legacy:!1,locale:r,fallbackLocale:o,messages:i});n.use(l)}}const he=Symbol("Provider");var ze=(n=>(n.Production="production",n.Development="development",n))(ze||{});class Ve extends T.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:u=null,materialPath:p="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=u,this.materialPath=p,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i);const{access:h,request:g}=this.adapter;h&&h.connect({mode:s,router:u,request:g}),a&&s!==S.Design?this.load(a):this.project=a}mode;globals={};modules={};adapter={request:f.request,jsonp:f.jsonp};apis={};dependencies={};materials={};library={};libraryLocales={};libraryLocaleMap={};service;project=null;components={};nodeEnv="development";env={};router=null;materialPath="./";urlDslCaches={};errorHandler=null;createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(o){f.logger.warn("模拟数据模版异常",o)}return D()?.mock(s)}}async load(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/projects/${e.id}.json`]||this.modules[`/src/${t}/projects/${e.id}.json`];if(this.project=s?await s():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:r=[],meta:o=[],env:a=[]}=this.project,i=window;i&&(i.CKEDITOR_VERSION=void 0),this.initEnv(a),this.mode===S.Raw?await this.loadDependencies(i):await this.loadAssets(i),this.initMock(i),this.apis=He(r,o,this.adapter),ue(i),Le(r,i),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=D(e);t&&t.setup({timeout:"50-500"})}async loadDependencies(e={}){const t=Object.entries(this.dependencies);for(const[s,r]of t)e[s]||(e[s]=this.library[s]=await r())}async loadAssets(e={}){const{dependencies:t=[]}=this.project,{dependencies:s,library:r,components:o,materialPath:a,nodeEnv:i,libraryLocales:l}=this,{libraryExports:c,libraryMap:u,materials:p,materialExports:d,materialMapLibrary:h,libraryLocaleMap:g}=be(t,a,i==="development");Object.assign(this.libraryLocaleMap,g);for(const m of c){const v=s[m],y=e[m];if(y)r[m]=y;else if(v)e[m]=r[m]=await v();else{const _=u[m]||[];for(const E of _)B(E)&&await Ie(E,f.url.append(E,{v:F})),q(E)&&await f.loadScript(f.url.append(E,{v:F}));r[m]=e[m]}const w=g[m];if(w){const _=s[w];l[w]=_?await _():e[w]}}if(i==="development"){for(const v of p)await f.loadScript(f.url.append(v,{v:F}));const m=this.materials||{};for(const v of d){const y=e[h[v]],w=y?.default||y,_=T.BUILT_IN_COMPONENTS[v];if(_)w&&_.forEach(E=>{o[E]=w[E]});else{const E=m[v]?(await m[v]()).default:e[v];E&&w&&(E.components||[]).forEach(I=>{o[I.name]=je(I,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const o=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:a,pageRouteName:i=o,routeMeta:l}=s,c=a?"":"/",u={path:`${c}${i}/:id`,name:k,component:ee},p=this.getHomepage(),d={path:c,name:N,component:p?ee:r.startupComponent||Nt,meta:l};if(e.hasRoute(k)&&e.removeRoute(k),e.hasRoute(N)&&e.removeRoute(N),s.enableStaticRoute){const h=t?.pages||[];re({name:i,prefix:c,pages:h,component:ee,loader:this.getRenderComponent.bind(this),homepage:p?.id}).forEach(m=>{a?e.addRoute(a,m):e.addRoute(m)}),p||(a?e.addRoute(a,d):e.addRoute(d))}else a?(e.addRoute(a,u),e.addRoute(a,d)):(e.addRoute(u),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const o=s?.$options.name,a=typeof t=="string"?t:t?.message||t?.msg||"未知错误",i=`[ ${o} ] ${a} ${r}`;["getComputedStyle","ResizeObserver"].some(c=>i.includes(c))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(i,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,o=e.config.globalProperties.installed||{};for(const[a,i]of Object.entries(this.library))if(!o[a]&&Te(i)){const c={locale:s[t[a]]},u=r[a]||{},p={...c,...u};e.use(i,p),o[a]=!0}e.provide(he,this),e.config.globalProperties.$provider=this,e.config.globalProperties.$request=this.adapter?.request,this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),this.project?.platform!=="uniapp"&&this.mode!==S.Design&&this.initGlobals(this.project?.globals||{},{app:e,window,adapter:this.adapter,library:this.library,mode:this.mode}),this.mode!==S.Design&&this.project?.i18n&&this.initI18n(e,this.library,this.project.i18n),this.options.enhance&&e.use(this.options.enhance,this),this.mode===S.Design&&this.setErrorHandler(e),e.config.globalProperties.installed=o}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(s=>s.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},s=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=s(r,a.children);if(i)return i}}};return s(e,t)||null}getFirstPage(){const{pages:e=[]}=this.project||{};if(!e.length)return null;const t=(s=[])=>{for(const r of s){if(r.type==="page"&&!r.dir&&!r.layout)return r;if(r.children&&r.children.length){const o=t(r.children);if(o)return o}}};return t(e)||null}getMenus(e="page",t=""){return U(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):this.getFirstPage()}async getDsl(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/files/${e}.json`]||this.modules[`/src/${t}/files/${e}.json`];return s?await s():this.service.getFile(e,this.project||void 0).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.adapter.request?this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null):null)}createDslRenderer(e,t={}){const{library:s,components:r,mode:o,apis:a}=this,i={mode:o,Vue:s.Vue,components:r,libs:s,apis:a,window,...t},l=G({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return K({...i,dsl:e,loader:l})}async getRenderComponent(e,t){const s=this.getFile(e);if(!s)return f.logger.warn(`Can not find file: ${e}`),null;if(t&&t(s),this.mode===S.Raw){const{vtjRawDir:o=".vtj/vue"}=this.options,a=`${o}/${e}.vue`,i=this.modules[a]||this.modules[`/src/pages/${e}.vue`];return i?(await i())?.default:this.nodeEnv==="development"&&this.adapter.startupComponent||null}const r=await this.getDsl(s.id);return r?this.createDslRenderer(r).renderer:(f.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return b.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return b.defineAsyncComponent(async()=>await pe(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Bt(e,s)}initI18n(e,t,s){Vt(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function Wt(n){const e=new Ve(n);return{provider:e,onReady:s=>e.ready(s)}}function me(n={}){const e=b.inject(he,null);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=n;t&&s&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==s&&e.adapter.notify&&e.adapter.notify(`[ ${r?.name} ] 组件源码版本与运行时版本不一致,请重新发布组件`,"版本不一致","warning")})()}return e}async function Qt(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(i=>e+i),{css:o,js:a}=Ce(r);if(o.length&&ae(o),a.length)return await ce(a,t).catch(()=>{})}const We={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},Yt=(n,e="/__vtj__/api/:type.json")=>(t,s,r)=>n.send({url:e,method:"post",params:{type:t},query:r,data:{type:t,data:s},settings:We}),Xt=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...We,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function Zt(n){return f.createRequest({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:e=>e.data?.code===0,showError:e=>{n&&n(e||"未知错误")}}})}class Q{constructor(e=f.request){this.req=e,this.api=Yt(e),this.uploader=Xt(e)}api;pluginCaches={};uploader;async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return console.log("BaseService.saveMaterials",e,t),!1}async saveFile(e){return console.log("BaseService.saveFile",e),!1}async getFile(e){return console.log("BaseService.getFile",e),{}}async removeFile(e){return console.log("BaseService.removeFile",e),!1}async saveHistory(e){return console.log("BaseService.saveHistory",e),!1}async removeHistory(e){return console.log("BaseService.removeHistory",e),!1}async getHistory(e){return console.log("BaseService.getHistory",e),{}}async getHistoryItem(e,t){return console.log("BaseService.getHistoryItem",e,t),{}}async saveHistoryItem(e,t){return console.log("BaseService.saveHistoryItem",e,t),!1}async removeHistoryItem(e,t){return console.log("BaseService.removeHistoryItem",e,t),!1}async publish(e){return!!await this.api("publish",e).catch(()=>!1)}async publishFile(e,t){return!!await this.api("publishFile",{project:e,file:t}).catch(()=>!1)}async genVueContent(e,t){return await this.api("genVueContent",{project:e,dsl:t}).catch(()=>"")}async parseVue(e,t){return await this.api("parseVue",{project:e,...t})}async createRawPage(e){return await this.api("createRawPage",e).catch(()=>"")}async removeRawPage(e){return await this.api("removeRawPage",e).catch(()=>"")}async uploadStaticFile(e,t){return await this.uploader(e,t).catch(()=>null)}async getStaticFiles(e){return await this.api("getStaticFiles",e).catch(()=>[])}async removeStaticFile(e,t){return await this.api("removeStaticFile",{name:e,projectId:t}).catch(()=>"")}async clearStaticFiles(e){return await this.api("clearStaticFiles",e).catch(()=>"")}async getPluginMaterial(e){const{urls:t=[]}=e,s=t.filter(o=>Ee(o))[0];if(!s)return null;const r=this.pluginCaches[s];return r||(this.pluginCaches[s]=f.request.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const $=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class es extends Q{init(e){const t=new T.ProjectModel(e),s=$.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return $.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return $.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return $.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return $.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=$.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return $.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return $.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=$.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),$.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=$.get(`history_${e}`),s=new T.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=$.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return $.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{$.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class Qe extends Q{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new T.ProjectModel(e),s=this.projects[t.id]||{},r=Object.assign(t.toDsl(),s);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new T.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,r=this.historyItems[s]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const r=`${e}_${s}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let J=null;function ts(){return J||(J=new Qe,J)}class ss extends Q{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:f.mapToObject(t)}).catch(()=>!1)}async saveFile(e){return!!await this.api("saveFile",e).catch(()=>!1)}async getFile(e){const t=this.getFileCaches[e];return t||(this.getFileCaches[e]=this.api("getFile",e).catch(()=>null)).finally(()=>{delete this.getFileCaches[e]})}async removeFile(e){return!!await this.api("removeFile",e).catch(()=>!1)}async saveHistory(e){return!!await this.api("saveHistory",e).catch(()=>!1)}async removeHistory(e){return!!await this.api("removeHistory",e).catch(()=>!1)}async getHistory(e){return await this.api("getHistory",e).catch(()=>null)||{}}async getHistoryItem(e,t){return await this.api("getHistoryItem",{fId:e,id:t}).catch(()=>null)||{}}async saveHistoryItem(e,t){return!!await this.api("saveHistoryItem",{fId:e,item:t}).catch(()=>!1)}async removeHistoryItem(e,t){return!!await this.api("removeHistoryItem",{fId:e,ids:t}).catch(()=>!1)}}exports.ACCESS=rt;exports.ACCESS_KEY=le;exports.Access=W;exports.BUILD_IN_TAGS=we;exports.BUILT_IN_DIRECTIVES=_e;exports.BaseService=Q;exports.CONTEXT_HOST=se;exports.Context=Be;exports.ContextMode=S;exports.DATA_TYPES=Se;exports.HOMEPAGE_ROUTE_NAME=N;exports.HTML_TAGS=oe;exports.JSCodeToString=ut;exports.LIFE_CYCLES_LIST=st;exports.LocalService=ss;exports.MemoryService=Qe;exports.NodeEnv=ze;exports.PAGE_ROUTE_NAME=k;exports.Provider=Ve;exports.REMOTE=nt;exports.StorageService=es;exports.VTJ_RENDERER_VERSION=F;exports.adoptStylesToInline=ct;exports.adoptedStyleSheets=V;exports.clearLoaderCache=Et;exports.compileScopedCSS=Re;exports.convertCssRpx=Ae;exports.createAccess=dt;exports.createAdapter=ft;exports.createAssetScripts=ot;exports.createAssetsCss=it;exports.createDataSources=qe;exports.createLoader=G;exports.createMemoryService=ts;exports.createMenus=U;exports.createMetaApi=xe;exports.createMock=Ne;exports.createProvider=Wt;exports.createRenderer=K;exports.createSchemaApi=De;exports.createSchemaApis=He;exports.createServiceRequest=Zt;exports.defaultLoader=Ke;exports.fillBasePath=H;exports.getMock=D;exports.getModifiers=fe;exports.getPlugin=pe;exports.getRawComponent=je;exports.isBuiltInTag=Me;exports.isCSSUrl=B;exports.isJSCode=Fe;exports.isJSExpression=C;exports.isJSFunction=j;exports.isJSON=Ee;exports.isJSUrl=q;exports.isNativeTag=Oe;exports.isVuePlugin=Te;exports.loadCss=Ie;exports.loadCssUrl=ae;exports.loadEnhance=Qt;exports.loadScriptUrl=ce;exports.menusFilter=de;exports.mockApi=Ue;exports.mockApis=Le;exports.mockCleanup=ue;exports.nodeRender=O;exports.parseDeps=be;exports.parseExpression=x;exports.parseFunction=R;exports.parseUrls=Ce;exports.providerKey=he;exports.removeProdFlag=$e;exports.rpxToPx=Pe;exports.setupPageSetting=lt;exports.toString=ie;exports.useAccess=ke;exports.useMask=Ut;exports.useProvider=me;
package/dist/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  import { Base as Ge, BUILT_IN_COMPONENTS as Ve, ProjectModel as q, HistoryModel as Ee } from "@vtj/core";
2
- import { url as k, isUrl as ne, dedupArray as We, isFunction as J, isString as I, logger as O, storage as Y, cookie as Z, toArray as ye, unRSA as ve, delay as K, createRequest as be, jsonp as je, merge as Qe, pathToRegexp as Xe, pathToRegexpMatch as Ye, formDataToJson as Ze, Queue as et, cloneDeep as _e, camelCase as C, upperFirst as tt, pick as st, request as re, loadScript as we, debounce as nt, Storage as rt, mapToObject as fe } from "@vtj/utils";
2
+ import { url as k, isUrl as ne, dedupArray as We, isFunction as J, isString as I, logger as O, storage as Y, cookie as Z, toArray as ye, unRSA as ve, delay as K, createRequest as be, jsonp as je, merge as Qe, pathToRegexp as Xe, pathToRegexpMatch as Ye, formDataToJson as Ze, Queue as et, cloneDeep as _e, camelCase as P, upperFirst as tt, pick as st, request as re, loadScript as we, debounce as nt, Storage as rt, mapToObject as fe } from "@vtj/utils";
3
3
  import * as G from "vue";
4
- import { inject as Re, defineComponent as Pe, h as ie, ref as oe, watchEffect as it, defineAsyncComponent as Se } from "vue";
5
- import { useRoute as Ce } from "vue-router";
4
+ import { inject as Re, defineComponent as Ce, h as ie, ref as oe, watchEffect as it, defineAsyncComponent as Se } from "vue";
5
+ import { useRoute as Pe } from "vue-router";
6
6
  /**!
7
7
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
8
8
  * @name @vtj/renderer
9
9
  * @author CHC chenhuachun1549@dingtalk.com
10
- * @version 0.16.17
10
+ * @version 0.16.18
11
11
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
12
12
  */
13
- const x = "0.16.17";
13
+ const x = "0.16.18";
14
14
  var _ = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(_ || {});
15
15
  const $e = [
16
16
  "$el",
@@ -223,12 +223,12 @@ function ht(n, e) {
223
223
  let A = 1;
224
224
  for (f++; f < c.length && A > 0; )
225
225
  c[f] === "{" ? A++ : c[f] === "}" && A--, f++;
226
- const Q = c.substring(y, f), P = c.substring(S, f - 1);
226
+ const Q = c.substring(y, f), C = c.substring(S, f - 1);
227
227
  u.push({
228
228
  type: v ? "keyframes" : "at-rule",
229
229
  rule: w,
230
230
  content: Q,
231
- inner: P
231
+ inner: C
232
232
  });
233
233
  }
234
234
  continue;
@@ -347,7 +347,7 @@ function pe(n, e, t, s = !1) {
347
347
  u ? u.innerHTML = o : (u = c.createElement("style"), u.id = e, u.innerHTML = o, c.head.appendChild(u));
348
348
  }
349
349
  }
350
- function Ps(n) {
350
+ function Cs(n) {
351
351
  const e = n.adoptedStyleSheets || [];
352
352
  let t = "";
353
353
  if (e.forEach((s) => {
@@ -405,7 +405,7 @@ function H(n = window) {
405
405
  if (t && window)
406
406
  return window.Mock = t, t;
407
407
  }
408
- function Cs(n, e, t) {
408
+ function Ps(n, e, t) {
409
409
  Object.assign(e.meta, t.meta);
410
410
  const s = n?._container;
411
411
  t?.type === "page" && s.classList.add("is-page"), t?.pure && s.classList.add("is-pure");
@@ -697,7 +697,7 @@ function Rt(n, e) {
697
697
  return t(s, r, i, a);
698
698
  };
699
699
  }
700
- function Pt(n = [], e = [], t) {
700
+ function Ct(n = [], e = [], t) {
701
701
  const s = {};
702
702
  for (const r of n) {
703
703
  const i = jt(r, t);
@@ -707,7 +707,7 @@ function Pt(n = [], e = [], t) {
707
707
  s[r.id] = Rt(r, t);
708
708
  return s;
709
709
  }
710
- async function Ct(n = [], e = window) {
710
+ async function Pt(n = [], e = window) {
711
711
  const t = H(e);
712
712
  t && (Me(e), n.forEach((s) => It(t, s)));
713
713
  }
@@ -753,6 +753,7 @@ class Ft {
753
753
  __instance = null;
754
754
  __contextRefs = {};
755
755
  __refs = {};
756
+ __refCaches = {};
756
757
  context = {};
757
758
  state = {};
758
759
  props = {};
@@ -780,7 +781,7 @@ class Ft {
780
781
  setup(e, t = G) {
781
782
  const s = t.getCurrentInstance();
782
783
  if (!s) return;
783
- this.__refs = {}, this.$refs = {}, this.context = {}, this.__contextRefs = {}, this.__instance = s.proxy;
784
+ this.__refs = {}, this.__refCaches = {}, this.$refs = {}, this.context = {}, this.__contextRefs = {}, this.__instance = s.proxy;
784
785
  const r = s.appContext.config.globalProperties;
785
786
  Object.assign(this, r), Object.assign(this, e || {}), this.__proxy(), t.onMounted(() => {
786
787
  this.__proxy();
@@ -801,7 +802,7 @@ class Ft {
801
802
  }), this.__reset();
802
803
  }
803
804
  __reset() {
804
- this.__refs = {}, this.$refs = {}, this.__contextRefs = {}, this.context = {};
805
+ this.__refs = {}, this.__refCaches = {}, this.$refs = {}, this.__contextRefs = {}, this.context = {};
805
806
  }
806
807
  __parseFunction(e) {
807
808
  if (e)
@@ -820,16 +821,19 @@ class Ft {
820
821
  return B(e, this);
821
822
  }
822
823
  __ref(e = null, t) {
823
- if (this.__mode !== _.VNode)
824
- return e && e !== this.__id && (this.__contextRefs[e] = this), async (s) => {
825
- await K(0);
826
- let r = s?.$vtjEl || s?.$el || s?._?.vnode?.el || s;
827
- if (!r) {
828
- typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]);
829
- return;
830
- }
831
- return r.nodeType === 3 && r.nextSibling && (r = r.nextSibling), r.__vtj__ = e, _.Design === this.__mode && (r.__context__ = this, r.draggable = !0), e && (this.__refs[e] = this.__getRefEl(this.__refs, e, s)), typeof t == "function" ? t(s) : t && (this.$refs[t] = this.__getRefEl(this.$refs, t, s)), s;
832
- };
824
+ if (this.__mode === _.VNode)
825
+ return;
826
+ e && e !== this.__id && (this.__contextRefs[e] = this);
827
+ let s = e ? this.__refCaches[e] : null;
828
+ return s || (s = async (r) => {
829
+ await K(0);
830
+ let i = r?.$vtjEl || r?.$el || r?._?.vnode?.el || r;
831
+ if (!i) {
832
+ typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]);
833
+ return;
834
+ }
835
+ return i.nodeType === 3 && i.nextSibling && (i = i.nextSibling), i.__vtj__ = e, _.Design === this.__mode && (i.__context__ = this, i.draggable = !0), e && (this.__refs[e] = this.__getRefEl(this.__refs, e, r)), typeof t == "function" ? t(r) : t && (this.$refs[t] = this.__getRefEl(this.$refs, t, r)), r;
836
+ }, e && (this.__refCaches[e] = s), s);
833
837
  }
834
838
  __getRefEl(e, t, s) {
835
839
  const r = e[t];
@@ -1084,14 +1088,14 @@ function M(n, e, t = G, s = Nt, r = [], i = !1) {
1084
1088
  if (n.name === "slot") return n.name;
1085
1089
  const j = s(n.name, n.from, t);
1086
1090
  return I(j) ? wt(j) || St(j) ? j : A[j] ?? a?.app?.component(j) ?? j : j;
1087
- })(), P = Kt(o, n.props ?? {}, v), qe = Gt(t, n.events ?? {}, v);
1091
+ })(), C = Kt(o, n.props ?? {}, v), qe = Gt(t, n.events ?? {}, v);
1088
1092
  if (n.name === "slot")
1089
- return Wt(t, n, P, v, s);
1090
- h && Object.assign(P, v.__parseExpression(h.value)), d && (P.style = Object.assign(
1091
- P.style ?? {},
1093
+ return Wt(t, n, C, v, s);
1094
+ h && Object.assign(C, v.__parseExpression(h.value)), d && (C.style = Object.assign(
1095
+ C.style ?? {},
1092
1096
  Xt(d, v)
1093
- )), g && Object.assign(P, Yt(g, v)), m.forEach((j) => {
1094
- Ae.includes(n.name) ? Object.assign(P, Zt(j, v)) : Object.assign(P, es(t, j, v));
1097
+ )), g && Object.assign(C, Yt(g, v)), m.forEach((j) => {
1098
+ Ae.includes(n.name) ? Object.assign(C, Zt(j, v)) : Object.assign(C, es(t, j, v));
1095
1099
  });
1096
1100
  const Je = ts(
1097
1101
  t,
@@ -1102,7 +1106,7 @@ function M(n, e, t = G, s = Nt, r = [], i = !1) {
1102
1106
  ), me = v?.__id ? `data-v-${v.__id}` : void 0, Ke = me ? { [me]: "" } : {}, ze = v.__mode === _.Design ? { "data-vtj": o } : {};
1103
1107
  let X = t.createVNode(
1104
1108
  Q,
1105
- { key: `${o}_${S}`, ...Ke, ...ze, ...P, ...qe },
1109
+ { key: `${o}_${S}`, ...Ke, ...ze, ...C, ...qe },
1106
1110
  Je
1107
1111
  );
1108
1112
  const ge = a ? Ut(a, y, v) : [];
@@ -1120,12 +1124,12 @@ function Ut(n, e, t) {
1120
1124
  }).filter((r) => !!r);
1121
1125
  }
1122
1126
  function De(n = []) {
1123
- const e = n.find((u) => C(u.name) === "vIf"), t = n.find(
1124
- (u) => C(u.name) === "vElseIf"
1125
- ), s = n.find((u) => C(u.name) === "vElse"), r = n.find((u) => C(u.name) === "vFor"), i = n.find((u) => C(u.name) === "vShow"), a = n.find((u) => C(u.name) === "vBind"), o = n.find((u) => C(u.name) === "vHtml"), l = n.filter(
1126
- (u) => C(u.name) === "vModel"
1127
+ const e = n.find((u) => P(u.name) === "vIf"), t = n.find(
1128
+ (u) => P(u.name) === "vElseIf"
1129
+ ), s = n.find((u) => P(u.name) === "vElse"), r = n.find((u) => P(u.name) === "vFor"), i = n.find((u) => P(u.name) === "vShow"), a = n.find((u) => P(u.name) === "vBind"), o = n.find((u) => P(u.name) === "vHtml"), l = n.filter(
1130
+ (u) => P(u.name) === "vModel"
1127
1131
  ), c = n.filter(
1128
- (u) => !ot.includes(C(u.name))
1132
+ (u) => !ot.includes(P(u.name))
1129
1133
  );
1130
1134
  return {
1131
1135
  vIf: e,
@@ -1295,10 +1299,10 @@ function rs(n, e, t) {
1295
1299
  let o = t.__parseExpression(s) || [];
1296
1300
  return Number.isInteger(o) && (o = new Array(o).fill(!0).map((l, c) => c + 1)), Array.isArray(o) ? o.map((l, c) => e(t.__clone({ [i]: l, [a]: c }), c)) : (console.warn("[vForRender]:", `${s?.value} is not a Arrary`), []);
1297
1301
  }
1298
- const te = Pe({
1302
+ const te = Ce({
1299
1303
  name: "VtjPageContainer",
1300
1304
  async setup() {
1301
- const n = Ne(), e = Ce(), t = e.meta.__vtj__ || e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null, i = oe(Symbol());
1305
+ const n = Ne(), e = Pe(), t = e.meta.__vtj__ || e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null, i = oe(Symbol());
1302
1306
  if (s) {
1303
1307
  Object.assign(e.meta, s.meta || {}, { cache: s.cache });
1304
1308
  const { useTitle: a } = n?.adapter;
@@ -1328,7 +1332,7 @@ const te = Pe({
1328
1332
  activated() {
1329
1333
  this.meta.cache === !1 && (this.sid = Symbol());
1330
1334
  }
1331
- }), is = Pe({
1335
+ }), is = Ce({
1332
1336
  name: "VtjStartupContainer",
1333
1337
  render() {
1334
1338
  return ie("div", "page not found!");
@@ -1371,7 +1375,7 @@ function Os(n) {
1371
1375
  menuPathPrefix: e = "",
1372
1376
  pageRouteName: t = "page",
1373
1377
  disableMenusFilter: s = !1
1374
- } = n || {}, r = Ne(), i = Ce(), a = bt(), o = oe(!1), l = oe(!1), c = r.project, u = (d, m) => {
1378
+ } = n || {}, r = Ne(), i = Pe(), a = bt(), o = oe(!1), l = oe(!1), c = r.project, u = (d, m) => {
1375
1379
  o.value = !d?.mask, l.value = m?.pure ?? !!d?.pure;
1376
1380
  };
1377
1381
  it(() => {
@@ -1631,7 +1635,7 @@ class hs extends Ge {
1631
1635
  if (this.project = s ? await s() : await this.service.init(e), !this.project)
1632
1636
  throw new Error("project is null");
1633
1637
  const { apis: r = [], meta: i = [], env: a = [] } = this.project, o = window;
1634
- o && (o.CKEDITOR_VERSION = void 0), this.initEnv(a), this.mode === _.Raw ? await this.loadDependencies(o) : await this.loadAssets(o), this.initMock(o), this.apis = Pt(r, i, this.adapter), Me(o), Ct(r, o), e.platform !== "uniapp" && this.initRouter(), this.triggerReady();
1638
+ o && (o.CKEDITOR_VERSION = void 0), this.initEnv(a), this.mode === _.Raw ? await this.loadDependencies(o) : await this.loadAssets(o), this.initMock(o), this.apis = Ct(r, i, this.adapter), Me(o), Pt(r, o), e.platform !== "uniapp" && this.initRouter(), this.triggerReady();
1635
1639
  }
1636
1640
  initMock(e) {
1637
1641
  const t = H(e);
@@ -2302,7 +2306,7 @@ export {
2302
2306
  Es as REMOTE,
2303
2307
  Ds as StorageService,
2304
2308
  x as VTJ_RENDERER_VERSION,
2305
- Ps as adoptStylesToInline,
2309
+ Cs as adoptStylesToInline,
2306
2310
  pe as adoptedStyleSheets,
2307
2311
  ks as clearLoaderCache,
2308
2312
  ht as compileScopedCSS,
@@ -2320,7 +2324,7 @@ export {
2320
2324
  Ms as createProvider,
2321
2325
  ae as createRenderer,
2322
2326
  jt as createSchemaApi,
2323
- Pt as createSchemaApis,
2327
+ Ct as createSchemaApis,
2324
2328
  xs as createServiceRequest,
2325
2329
  Nt as defaultLoader,
2326
2330
  L as fillBasePath,
@@ -2343,7 +2347,7 @@ export {
2343
2347
  ke as loadScriptUrl,
2344
2348
  Be as menusFilter,
2345
2349
  It as mockApi,
2346
- Ct as mockApis,
2350
+ Pt as mockApis,
2347
2351
  Me as mockCleanup,
2348
2352
  M as nodeRender,
2349
2353
  ft as parseDeps,
@@ -2353,7 +2357,7 @@ export {
2353
2357
  Le as providerKey,
2354
2358
  ut as removeProdFlag,
2355
2359
  gt as rpxToPx,
2356
- Cs as setupPageSetting,
2360
+ Ps as setupPageSetting,
2357
2361
  Ie as toString,
2358
2362
  bt as useAccess,
2359
2363
  Os as useMask,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/renderer",
3
3
  "private": false,
4
- "version": "0.16.17",
4
+ "version": "0.16.18",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -21,15 +21,15 @@
21
21
  "author": "chenhuachun",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@vtj/core": "~0.16.17",
25
- "@vtj/utils": "~0.16.17"
24
+ "@vtj/core": "~0.16.18",
25
+ "@vtj/utils": "~0.16.18"
26
26
  },
27
27
  "devDependencies": {
28
28
  "vue": "~3.5.5",
29
29
  "vue-router": "~4.6.0",
30
- "@vtj/icons": "~0.16.17",
31
30
  "@vtj/cli": "~0.12.18",
32
- "@vtj/ui": "~0.16.17"
31
+ "@vtj/icons": "~0.16.18",
32
+ "@vtj/ui": "~0.16.18"
33
33
  },
34
34
  "exports": {
35
35
  ".": {
@@ -18,6 +18,7 @@ export declare class Context {
18
18
  __instance: any | null;
19
19
  __contextRefs: Record<string, Context>;
20
20
  __refs: Record<string, any>;
21
+ __refCaches: Record<string, any>;
21
22
  context: Record<string, any>;
22
23
  state: Record<string, any>;
23
24
  props: Record<string, any>;
@@ -45,7 +46,7 @@ export declare class Context {
45
46
  private __reset;
46
47
  __parseFunction(code?: JSFunction): Function | undefined;
47
48
  __parseExpression(code?: JSExpression | JSFunction): any;
48
- __ref(id?: string | null, ref?: string | Function): ((el: any) => Promise<any>) | undefined;
49
+ __ref(id?: string | null, ref?: string | Function): any;
49
50
  __getRefEl(refs: Record<string, any>, key: string, el: any): any;
50
51
  __clone(context?: Record<string, any>): Context;
51
52
  }
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/renderer
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.16.16
5
+ * @version 0.16.17
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.16.16";
8
+ export declare const version = "0.16.17";