@vtj/renderer 0.17.5 → 0.17.6

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,19 +2,19 @@
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.17.5
5
+ * @version 0.17.6
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const D="0.17.5";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const oe=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],lt=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],$e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Ce={String,Number,Boolean,Array,Object,Function,Date},x="VtjPage",U="VtjHomepage",le="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(","),be="component,slot".split(","),ut=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),pt={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 N(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function J(n){return/\.js$/.test(n)}function je(n){return/\.json$/.test(n)}function ft(n){return n.map(e=>`<script src="${f.url.append(e,{v:D})}"><\/script>`).join("")}function dt(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:D})}" />`).join("")}function Re(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function Pe(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],i=[],o=[],c=[],p={},a={},l=[],u={};return s.forEach(({urls:d,assetsUrl:h,library:m,assetsLibrary:g,localeLibrary:_})=>{d?.forEach(y=>{J(y)&&r.push(Re(y,t)),B(y)&&i.push(y)}),m&&(c.push(m),p[m]=N(d||[],e),_&&(a[m]=_)),h&&o.push(h),g&&l.push(g),m&&g&&(u[g]=m)}),{scripts:N(r,e),css:N(i,e),materials:N(o,e),libraryExports:c,materialExports:f.dedupArray(l),materialMapLibrary:u,libraryMap:p,libraryLocaleMap:a}}function Ae(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Ie(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>J(s));return{css:e,js:t}}function Fe(n,e){const t=a=>{const l=[];let u=0;for(;u<a.length;){if(/\s/.test(a[u])){u++;continue}if(a.substring(u,u+2)==="/*"){const y=a.indexOf("*/",u+2);if(y!==-1){u=y+2;continue}}if(a[u]==="@"){const y=u;for(;u<a.length&&a[u]!=="{"&&a[u]!==";";)u++;const w=a.substring(y,u).trim(),j=w.includes("@keyframes");if(a[u]===";")l.push({type:"simple-at-rule",content:a.substring(y,u+1)}),u++;else if(a[u]==="{"){const v=u+1;let A=1;for(u++;u<a.length&&A>0;)a[u]==="{"?A++:a[u]==="}"&&A--,u++;const Z=a.substring(y,u),ee=a.substring(v,u-1);l.push({type:j?"keyframes":"at-rule",rule:w,content:Z,inner:ee})}continue}const d=u;for(;u<a.length&&a[u]!=="{";)u++;if(u>=a.length)break;const h=a.substring(d,u).trim();if(!h){u++;continue}const m=u+1;let g=1;for(u++;u<a.length&&g>0;)a[u]==="{"?g++:a[u]==="}"&&g--,u++;const _=a.substring(m,u-1);l.push({type:"rule",selector:h,content:_.trim()})}return l},s=a=>{const l=a.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(l)},r=a=>a.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(l,u,d)=>{const h=u.trim(),m=d.trim();return h?`${h}[${e}] ${m}`:m}),i=a=>{const l=a.trim();if(!l||l.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(l)||s(l))return l;const u=l.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(u){const[,d,h=""]=u,m=d.trim();return m?`${m}[${e}]${h}`:l}return`${l}[${e}]`},o=a=>r(a).split(",").map(u=>i(u)).filter(u=>u.trim()).join(", "),c=a=>a.map(l=>{switch(l.type){case"simple-at-rule":return l.content;case"keyframes":return l.content;case"at-rule":try{const d=t(l.inner),h=c(d);return`${l.rule} { ${h} }`}catch{return l.content}case"rule":if(!l.selector||!l.content)return"";const u=o(l.selector);return u.trim()?`${u} { ${l.content} }`:"";default:return""}}).filter(l=>l.trim()).join(" "),p=a=>a.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 a=n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g,"").replace(/^\s+|\s+$/gm,"").replace(/\n\s*\n/g,`
7
+ */const x="0.17.6";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const oe=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],lt=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],$e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Ce={String,Number,Boolean,Array,Object,Function,Date},D="VtjPage",U="VtjHomepage",le="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(","),be="component,slot".split(","),ut=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),pt={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 N(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function J(n){return/\.js$/.test(n)}function je(n){return/\.json$/.test(n)}function ft(n){return n.map(e=>`<script src="${f.url.append(e,{v:x})}"><\/script>`).join("")}function dt(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:x})}" />`).join("")}function Re(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function Pe(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],i=[],o=[],c=[],p={},a={},l=[],u={};return s.forEach(({urls:d,assetsUrl:h,library:m,assetsLibrary:g,localeLibrary:_})=>{d?.forEach(y=>{J(y)&&r.push(Re(y,t)),B(y)&&i.push(y)}),m&&(c.push(m),p[m]=N(d||[],e),_&&(a[m]=_)),h&&o.push(h),g&&l.push(g),m&&g&&(u[g]=m)}),{scripts:N(r,e),css:N(i,e),materials:N(o,e),libraryExports:c,materialExports:f.dedupArray(l),materialMapLibrary:u,libraryMap:p,libraryLocaleMap:a}}function Ae(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Ie(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>J(s));return{css:e,js:t}}function Fe(n,e){const t=a=>{const l=[];let u=0;for(;u<a.length;){if(/\s/.test(a[u])){u++;continue}if(a.substring(u,u+2)==="/*"){const y=a.indexOf("*/",u+2);if(y!==-1){u=y+2;continue}}if(a[u]==="@"){const y=u;for(;u<a.length&&a[u]!=="{"&&a[u]!==";";)u++;const w=a.substring(y,u).trim(),j=w.includes("@keyframes");if(a[u]===";")l.push({type:"simple-at-rule",content:a.substring(y,u+1)}),u++;else if(a[u]==="{"){const v=u+1;let A=1;for(u++;u<a.length&&A>0;)a[u]==="{"?A++:a[u]==="}"&&A--,u++;const Z=a.substring(y,u),ee=a.substring(v,u-1);l.push({type:j?"keyframes":"at-rule",rule:w,content:Z,inner:ee})}continue}const d=u;for(;u<a.length&&a[u]!=="{";)u++;if(u>=a.length)break;const h=a.substring(d,u).trim();if(!h){u++;continue}const m=u+1;let g=1;for(u++;u<a.length&&g>0;)a[u]==="{"?g++:a[u]==="}"&&g--,u++;const _=a.substring(m,u-1);l.push({type:"rule",selector:h,content:_.trim()})}return l},s=a=>{const l=a.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(l)},r=a=>a.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(l,u,d)=>{const h=u.trim(),m=d.trim();return h?`${h}[${e}] ${m}`:m}),i=a=>{const l=a.trim();if(!l||l.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(l)||s(l))return l;const u=l.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(u){const[,d,h=""]=u,m=d.trim();return m?`${m}[${e}]${h}`:l}return`${l}[${e}]`},o=a=>r(a).split(",").map(u=>i(u)).filter(u=>u.trim()).join(", "),c=a=>a.map(l=>{switch(l.type){case"simple-at-rule":return l.content;case"keyframes":return l.content;case"at-rule":try{const d=t(l.inner),h=c(d);return`${l.rule} { ${h} }`}catch{return l.content}case"rule":if(!l.selector||!l.content)return"";const u=o(l.selector);return u.trim()?`${u} { ${l.content} }`:"";default:return""}}).filter(l=>l.trim()).join(" "),p=a=>a.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 a=n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g,"").replace(/^\s+|\s+$/gm,"").replace(/\n\s*\n/g,`
8
8
  `),l=t(a),u=c(l);return p(u)}catch(a){return console.error("CSS scoping failed:",a),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,l=>l).replace(/([^{}@]+)(?=\s*{)/g,l=>{const u=l.trim();return!u||u.startsWith("@")||u.includes(`[${e}]`)||s(u)?l:`${u}[${e}]`})}}const ht=750;function Te(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||ht;return e*s/r}function Me(n,e){let t=!1,s=!1,r=!1,i="";for(let o=0;o<e.length;o++){const c=e[o];if(c==="'"&&!s&&!r?t=!t:c==='"'&&!t&&!r?s=!s:e.substr(o,4).toLowerCase()==="url("&&!t&&!s?r=!0:c===")"&&r&&(r=!1),!t&&!s&&!r){const p=e.substr(o).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(p){const a=p[1],l=parseFloat(a),d=`${Te(n,l).toFixed(6).replace(/\.?0+$/,"")}px`;i+=d,o+=p[0].length-1;continue}}i+=c}return i}function ue(n){return f.isString(n)?n:JSON.stringify(n)}function Q(n,e,t,s=!1){const r=n.CSSStyleSheet,i=s?`data-v-${e}`:e,o=n.__uniConfig?Me(n,t):t,c=s?Fe(o,i):o,p=!!n.__uniConfig;if(r.prototype.replaceSync&&!p){const a=new r;a.id=e,a.replaceSync(c);const l=n.document,u=l.adoptedStyleSheets,d=Array.from(u).filter(h=>h.id!==e);l.adoptedStyleSheets=[...d,a]}else{const a=n.document;let l=a.getElementById(e);l?l.innerHTML=c:(l=a.createElement("style"),l.id=e,l.innerHTML=c,a.head.appendChild(l))}}function mt(n){const e=n.adoptedStyleSheets||[];let t="";if(e.forEach(s=>{try{for(const r of s.cssRules)t+=r.cssText+`
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 Oe(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&Q(window,n,t)}function pe(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const o=t.createElement("link");o.rel="stylesheet",o.id=r,o.href=r,s.appendChild(o)}}async function fe(n,e,t=window){const s=t.document,r=t.document.head;let i=t[e];return i?i.default||i:new Promise((o,c)=>{for(const p of n){const a=s.createElement("script");a.src=p,a.onload=()=>{i=t[e],i?o(i.default||i):c(null)},a.onerror=l=>{c(l)},r.appendChild(a)}})}function De(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function xe(n){return be.includes(n)}function ke(n){return le.includes(n)}function k(n=window){const e=window?.Mock;if(e)return e;const t=n?.Mock;if(t&&window)return window.Mock=t,t}function gt(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 He(n){return/^\([\s\S]*\)/.test(n.trim())}function Ne(n){return/\w+\([\s\S]*\)$/.test(n.trim())}function Le(n){return n.includes("=")}function _t(n){if(typeof window>"u")return;const e=window[0]||window;if(e.__simulator__)try{const t=e.__simulator__.engine.provider.errorHandler;t&&t(n)}catch{}}function H(n,e,t=!1,s=!1,r=!1){try{const i=['"use strict";',"var __self = arguments[0];"];i.push("return ");let o=(n.value||"").trim();r||(o=o.replace(/this(\W|$)/g,(p,a)=>`__self${a}`)),o=i.join(`
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 Oe(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&Q(window,n,t)}function pe(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const o=t.createElement("link");o.rel="stylesheet",o.id=r,o.href=r,s.appendChild(o)}}async function fe(n,e,t=window){const s=t.document,r=t.document.head;let i=t[e];return i?i.default||i:new Promise((o,c)=>{for(const p of n){const a=s.createElement("script");a.src=p,a.onload=()=>{i=t[e],i?o(i.default||i):c(null)},a.onerror=l=>{c(l)},r.appendChild(a)}})}function xe(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function De(n){return be.includes(n)}function ke(n){return le.includes(n)}function k(n=window){const e=window?.Mock;if(e)return e;const t=n?.Mock;if(t&&window)return window.Mock=t,t}function gt(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 He(n){return/^\([\s\S]*\)/.test(n.trim())}function Ne(n){return/\w+\([\s\S]*\)$/.test(n.trim())}function Le(n){return n.includes("=")}function _t(n){if(typeof window>"u")return;const e=window[0]||window;if(e.__simulator__)try{const t=e.__simulator__.engine.provider.errorHandler;t&&t(n)}catch{}}function H(n,e,t=!1,s=!1,r=!1){try{const i=['"use strict";',"var __self = arguments[0];"];i.push("return ");let o=(n.value||"").trim();r||(o=o.replace(/this(\W|$)/g,(p,a)=>`__self${a}`)),o=i.join(`
10
10
  `)+o;const c=r?`
11
11
  ${o}
12
- `:`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",c)(e)}catch(i){if(f.logger.error("parseExpression.error",i,n,e?.__self??e),_t(i),s)throw i}}function R(n,e,t=!1,s=!1,r=!1){const i=H(n,e,t,s,r);if(typeof i!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return i}function b(n){return n&&n.type==="JSExpression"}function C(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Ue(n){return b(n)||C(n)}function vt(n){return Ue(n)?n.value:JSON.stringify(n)}const yt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},de=Symbol("access");class Y{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},yt,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:i}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(i,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(i=>s[i]||s[t+"."+i])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(i=>s[i]||s[t+"."+i])}install(e){e.config.globalProperties.$access=this,e.provide(de,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===x){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 qe(){return $.inject(de,null)}function St(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:i,useTitle:o,alert:c}=n;let p=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:l=>l.data?.code===0||!!l.data?.success,failMessage:!0,showError:l=>{e&&e(l||"未知错误")},showLoading:()=>{p&&p.close(),t&&(p=t())},hideLoading:()=>{p&&(p.close(),p=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:o,alert:c,startupComponent:r,access:i?new Y({alert:c,...i}):void 0}}function wt(n={}){return new Y(n)}function Be(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?H(n.headers,{},!0):void 0,i={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(o,c)=>(delete i.data,s.send(f.merge(i,c||{},{data:o})))}}function Je(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(i,o)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,i,o)}}function Ke(n=[],e=[],t){const s={};for(const r of n){const i=Be(r,t);s[r.id]=i,s[r.name]=i}for(const r of e)s[r.id]=Je(r,t);return s}async function Ge(n=[],e=window){const t=k(e);t&&(he(e),n.forEach(s=>Ve(t,s)))}function ze(n,e=window){const t=C(n.mockTemplate)&&n.mockTemplate.value?R(n.mockTemplate,{},!0):void 0,s=k(e);return async(...r)=>{let i={};if(t)try{i=await t.apply(t,r)}catch(o){f.logger.warn("模拟数据模版异常",o)}return s?.mock(i)}}function Ve(n,e){if(!e.mock)return;const{url:t,mockTemplate:s,method:r="get"}=e;if(t&&s)try{const i=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${i}(.*)`),c=f.pathToRegexpMatch(i,{decode:decodeURIComponent}),p=H(s,{},!0);n.mock(o,r.toLowerCase(),a=>{const l=f.url.parse(a.url)||{},u=a.body instanceof FormData?f.formDataToJson(a.body):a.body,d=f.isUrl(a.url)?new URL(a.url).pathname:a.url.split("?")[0],h=c(d)?.params;Object.assign(a,{data:u,params:h,query:l});try{return n.mock(p(a))}catch(m){return console.warn("[mockApi]",o,a,m),null}})}catch(i){console.warn("mockApi",i)}}function he(n=window){const e=k(n);e&&(e._mocked={})}class We{__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=W){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(){if(!this.__instance)return;const e=this.__instance;oe.forEach(t=>{this[t]=e[t]||e._?.[t.replace("$","")]||null})}__cleanup(){oe.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 H({type:s,value:r},this)}else return H(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 i=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!i){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return i.nodeType===3&&i.nextSibling&&(i=i.nextSibling),i.__vtj__=e,S.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},e&&(this.__refCaches[e]=s),s)}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const i=new Set([].concat(r,s));return Array.from(i)}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 z(n){const{Vue:e=W,mode:t=S.Runtime,components:s={},libs:r={},apis:i={},loader:o}=n,c=e.computed(()=>n.dsl),p={$components:s,$libs:r,$apis:i},a=new We({mode:t,dsl:c.value,attrs:p}),l=e.defineComponent({name:c.value.name,__scopeId:c.value.id?`data-v-${c.value.id}`:void 0,props:{...$t(c.value.props??[],a)},async setup(u={}){a.$props=u,a.props=u,c.value.id&&Q(n.window||window,c.value.id,c.value.css||"",!0),a.state=Ct(e,c.value.state??{},a);const d=bt(e,c.value.computed??{},a),h=jt(c.value.methods??{},a),m=Rt(e,c.value.inject,a);for(const[y,w]of Object.entries(m||{}))m[y]=e.inject(y,w);const g=Qe(c.value.dataSources||{},a),_={...m,...d,...h,...g};return a.setup(_,e),Pt(e,c.value.watch??[],a),{vtj:a,state:a.state,...u,...d,...h}},emits:Et(c.value.emits),expose:["vtj",...c.value.expose||[]],render(){if(!c.value.nodes)return null;const u=c.value.nodes||[];if(u.length===1)return M(u[0],a,e,o,u);{const d=u.map(h=>M(h,a,e,o,u));return e.createVNode("div",{},d)}},...At(c.value.lifeCycles??{},a)});return{renderer:e.markRaw(l),context:a}}function Et(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function $t(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(i=>Ce[i]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:b(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 Ct(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let i=e[r];return b(i)?i=t.__parseExpression(i):C(i)&&(i=t.__parseFunction(i)),s[r]=i,s},{}))}function bt(n,e,t){return Object.entries(e??{}).reduce((s,[r,i])=>(s[r]=n.computed(t.__parseFunction(i)),s),{})}function jt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function Rt(n,e=[],t){return e.reduce((s,r)=>{const{name:i,from:o}=r||{};r.default;const c=b(o)?t.__parseExpression(o)||i:o??i,p=b(r.default)?t.__parseExpression(r.default):r.default??null;return s[i]=n.inject(c,p),s},{})}function Qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=ze(r);else if(r.ref){const i=e.$apis[r.ref],o=C(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...c)=>{const p=await i.apply(e,c);return o?o(p):p}}return t},{})}function Pt(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function At(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const i=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(i)&&(await f.delay(0),await i())},t},{})}class It{__props={};__events={};__nodes={};constructor(){}setProps(e,t){this.__props[e]=t}getProps(e){return this.__props[e]}loadProps(e,t){const s=e?this.getProps(e):null;return s||(e&&this.setProps(e,t),t)}setEvents(e,t){}getEvents(e){return this.__events[e]}loadEvents(e,t){const s=e?this.getEvents(e):null;return s||(e&&this.setEvents(e,t),t)}setNode(e,t){this.__nodes[e]=t}getNode(e){return this.__nodes[e]}loadNode(e,t){const s=e?this.getNode(e):null;return s||(e&&this.setNode(e,t),t)}isEqual(e,t){return f.isEqual(e,t)}clear(){this.__props={},this.__events={},this.__nodes={}}}const O=new It,Ye=new f.Queue;let ne=[],T={},L={};const Xe=(n,e)=>e;async function me(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(c=>J(c));if(r.length===0||!s)return null;const i=t.filter(c=>B(c));return i.length&&pe(i,e),await fe(r,s,e).catch(c=>(console.warn("loadScriptUrl error",r,s,c),null))}function V(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(ne.forEach(r=>{delete s.window[r]}),ne=[]),(r,i,o,c=W)=>{if(!o||typeof o=="string")return i;let p="";if(o.type==="Schema"&&o.id)return p=o.id+"_"+r,L[p]||(L[p]=c.defineAsyncComponent(async()=>{const a=T[o.id]||await Ye.add(o.id,()=>e(o.id));return a&&(a.name=i,T[o.id]=a),a?z({Vue:c,mode:S.Runtime,...s,dsl:f.cloneDeep(a),loader:V(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return p=o.url+"_"+r,L[p]||(L[p]=c.defineAsyncComponent(async()=>{const a=T[o.url]||await t(o.url);return a&&(a.name=i,T[o.url]=a),a?z({...s,Vue:c,dsl:f.cloneDeep(a),mode:S.Runtime,loader:V(n)}).renderer:null}));if(o.type==="Plugin"){let a=o.library?T[o.library]:null;return a||(o.library&&ne.push(o.library),a=T[o.library||Symbol()]=c.defineAsyncComponent(async()=>{const l=await me(o,s.window);return l||(console.warn("getPlugin result is null",o),null)}),a)}return i}}function Ft(){T={},L={},Ye.clearAllCache(),O.clear()}function M(n,e,t=W,s=Xe,r=[],i=!1,o=0){if(!n||!n.name||n.invisible)return null;const c=t.getCurrentInstance()?.appContext,{id:p=null,directives:a=[]}=n,{vIf:l,vElseIf:u,vElse:d,vFor:h,vShow:m,vModels:g,vBind:_,vHtml:y,others:w}=Ze(a);if(!i&&(u||d))return null;if(l&&!Mt(l,e))return Nt(n,e,t,s,r);const j=(v,A=0)=>{const Z=v.$components,ee=(()=>{if(n.name==="component")return Ot(v,n.props?.is);if(n.name==="slot")return n.name;const P=s(`${n.id}_${A}`,n.name,n.from,t);return f.isString(P)?xe(P)||ke(P)?P:Z[P]??c?.app?.component(P)??P:P})(),I=Dt(p,n.props??{},v),rt=Ht(t,n.id,n.events??{},v);if(n.name==="slot")return Lt(t,n,I,v,s);_&&Object.assign(I,v.__parseExpression(_.value)),m&&(I.style=Object.assign(I.style??{},qt(m,v))),y&&Object.assign(I,Bt(y,v)),g.forEach(P=>{le.includes(n.name)?Object.assign(I,Jt(P,v)):Object.assign(I,Kt(t,P,v))});const it=Gt(t,n.children??[],v,s,n),Se=v?.__id?`data-v-${v.__id}`:void 0,ot=Se?{[Se]:""}:{},at=v.__mode===S.Design?{"data-vtj":p}:{},K=`${p}_${A}`,te={key:K,...ot,...at,...I,...rt};O.isEqual(te,O.getNode(K))||O.setNode(K,te);let se=t.createVNode(ee,O.getNode(K)||te||{},it);const we=c?Tt(c,w,v):[];return we.length&&(se=t.withDirectives(se,we)),se};return h?Wt(h,j,e):j(e,o)}function Tt(n,e,t){const s=n.app;return e.map(r=>{const i=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!i)return null;const o=[i];return r.value&&o.push(t.__parseExpression(r.value)),r.arg&&o.push(r.arg),r.modifiers&&o.push(r.modifiers),o}).filter(r=>!!r)}function Ze(n=[]){const e=n.find(l=>f.camelCase(l.name)==="vIf"),t=n.find(l=>f.camelCase(l.name)==="vElseIf"),s=n.find(l=>f.camelCase(l.name)==="vElse"),r=n.find(l=>f.camelCase(l.name)==="vFor"),i=n.find(l=>f.camelCase(l.name)==="vShow"),o=n.find(l=>f.camelCase(l.name)==="vBind"),c=n.find(l=>f.camelCase(l.name)==="vHtml"),p=n.filter(l=>f.camelCase(l.name)==="vModel"),a=n.filter(l=>!$e.includes(f.camelCase(l.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:i,vModels:p,vBind:o,others:a,vHtml:c}}function Mt(n,e){return!!e.__parseExpression(n.value)}function Ot(n,e){return e?b(e)?n.__parseExpression(e):e:"div"}function Dt(n,e,t){const s=ae(e,t);return s.ref=t.__ref(n,s.ref),s}function ae(n,e){return b(n)?e.__parseExpression(n):C(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ae(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ae(r,e),t},{}):n}function xt(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function kt(n){return He(n.value)?n:Ne(n.value)?{type:"JSFunction",value:`(...args) => (() => {
12
+ `:`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",c)(e)}catch(i){if(f.logger.error("parseExpression.error",i,n,e?.__self??e),_t(i),s)throw i}}function R(n,e,t=!1,s=!1,r=!1){const i=H(n,e,t,s,r);if(typeof i!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return i}function b(n){return n&&n.type==="JSExpression"}function C(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Ue(n){return b(n)||C(n)}function vt(n){return Ue(n)?n.value:JSON.stringify(n)}const yt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},de=Symbol("access");class Y{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},yt,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:i}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(i,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(i=>s[i]||s[t+"."+i])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(i=>s[i]||s[t+"."+i])}install(e){e.config.globalProperties.$access=this,e.provide(de,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===D){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 qe(){return $.inject(de,null)}function St(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:i,useTitle:o,alert:c}=n;let p=null;return{request:f.createRequest({adapter:n.axiosAdapter,settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:l=>l.data?.code===0||!!l.data?.success,failMessage:!0,showError:l=>{e&&e(l||"未知错误")},showLoading:()=>{p&&p.close(),t&&(p=t())},hideLoading:()=>{p&&(p.close(),p=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:o,alert:c,startupComponent:r,access:i?new Y({alert:c,...i}):void 0}}function wt(n={}){return new Y(n)}function Be(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?H(n.headers,{},!0):void 0,i={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(o,c)=>(delete i.data,s.send(f.merge(i,c||{},{data:o})))}}function Je(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(i,o)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,i,o)}}function Ke(n=[],e=[],t){const s={};for(const r of n){const i=Be(r,t);s[r.id]=i,s[r.name]=i}for(const r of e)s[r.id]=Je(r,t);return s}async function Ge(n=[],e=window){const t=k(e);t&&(he(e),n.forEach(s=>Ve(t,s)))}function ze(n,e=window){const t=C(n.mockTemplate)&&n.mockTemplate.value?R(n.mockTemplate,{},!0):void 0,s=k(e);return async(...r)=>{let i={};if(t)try{i=await t.apply(t,r)}catch(o){f.logger.warn("模拟数据模版异常",o)}return s?.mock(i)}}function Ve(n,e){if(!e.mock)return;const{url:t,mockTemplate:s,method:r="get"}=e;if(t&&s)try{const i=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${i}(.*)`),c=f.pathToRegexpMatch(i,{decode:decodeURIComponent}),p=H(s,{},!0);n.mock(o,r.toLowerCase(),a=>{const l=f.url.parse(a.url)||{},u=a.body instanceof FormData?f.formDataToJson(a.body):a.body,d=f.isUrl(a.url)?new URL(a.url).pathname:a.url.split("?")[0],h=c(d)?.params;Object.assign(a,{data:u,params:h,query:l});try{return n.mock(p(a))}catch(m){return console.warn("[mockApi]",o,a,m),null}})}catch(i){console.warn("mockApi",i)}}function he(n=window){const e=k(n);e&&(e._mocked={})}class We{__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=W){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(){if(!this.__instance)return;const e=this.__instance;oe.forEach(t=>{this[t]=e[t]||e._?.[t.replace("$","")]||null})}__cleanup(){oe.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 H({type:s,value:r},this)}else return H(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 i=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!i){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return i.nodeType===3&&i.nextSibling&&(i=i.nextSibling),i.__vtj__=e,S.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},e&&(this.__refCaches[e]=s),s)}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const i=new Set([].concat(r,s));return Array.from(i)}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 z(n){const{Vue:e=W,mode:t=S.Runtime,components:s={},libs:r={},apis:i={},loader:o}=n,c=e.computed(()=>n.dsl),p={$components:s,$libs:r,$apis:i},a=new We({mode:t,dsl:c.value,attrs:p}),l=e.defineComponent({name:c.value.name,__scopeId:c.value.id?`data-v-${c.value.id}`:void 0,props:{...$t(c.value.props??[],a)},async setup(u={}){a.$props=u,a.props=u,c.value.id&&Q(n.window||window,c.value.id,c.value.css||"",!0),a.state=Ct(e,c.value.state??{},a);const d=bt(e,c.value.computed??{},a),h=jt(c.value.methods??{},a),m=Rt(e,c.value.inject,a);for(const[y,w]of Object.entries(m||{}))m[y]=e.inject(y,w);const g=Qe(c.value.dataSources||{},a),_={...m,...d,...h,...g};return a.setup(_,e),Pt(e,c.value.watch??[],a),{vtj:a,state:a.state,...u,...d,...h}},emits:Et(c.value.emits),expose:["vtj",...c.value.expose||[]],render(){if(!c.value.nodes)return null;const u=c.value.nodes||[];if(u.length===1)return M(u[0],a,e,o,u);{const d=u.map(h=>M(h,a,e,o,u));return e.createVNode("div",{},d)}},...At(c.value.lifeCycles??{},a)});return{renderer:e.markRaw(l),context:a}}function Et(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function $t(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(i=>Ce[i]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:b(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 Ct(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let i=e[r];return b(i)?i=t.__parseExpression(i):C(i)&&(i=t.__parseFunction(i)),s[r]=i,s},{}))}function bt(n,e,t){return Object.entries(e??{}).reduce((s,[r,i])=>(s[r]=n.computed(t.__parseFunction(i)),s),{})}function jt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function Rt(n,e=[],t){return e.reduce((s,r)=>{const{name:i,from:o}=r||{};r.default;const c=b(o)?t.__parseExpression(o)||i:o??i,p=b(r.default)?t.__parseExpression(r.default):r.default??null;return s[i]=n.inject(c,p),s},{})}function Qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=ze(r);else if(r.ref){const i=e.$apis[r.ref],o=C(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...c)=>{const p=await i.apply(e,c);return o?o(p):p}}return t},{})}function Pt(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function At(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const i=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(i)&&(await f.delay(0),await i())},t},{})}class It{__props={};__events={};__nodes={};constructor(){}setProps(e,t){this.__props[e]=t}getProps(e){return this.__props[e]}loadProps(e,t){const s=e?this.getProps(e):null;return s||(e&&this.setProps(e,t),t)}setEvents(e,t){}getEvents(e){return this.__events[e]}loadEvents(e,t){const s=e?this.getEvents(e):null;return s||(e&&this.setEvents(e,t),t)}setNode(e,t){this.__nodes[e]=t}getNode(e){return this.__nodes[e]}loadNode(e,t){const s=e?this.getNode(e):null;return s||(e&&this.setNode(e,t),t)}isEqual(e,t){return f.isEqual(e,t)}clear(){this.__props={},this.__events={},this.__nodes={}}}const O=new It,Ye=new f.Queue;let ne=[],T={},L={};const Xe=(n,e)=>e;async function me(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(c=>J(c));if(r.length===0||!s)return null;const i=t.filter(c=>B(c));return i.length&&pe(i,e),await fe(r,s,e).catch(c=>(console.warn("loadScriptUrl error",r,s,c),null))}function V(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(ne.forEach(r=>{delete s.window[r]}),ne=[]),(r,i,o,c=W)=>{if(!o||typeof o=="string")return i;let p="";if(o.type==="Schema"&&o.id)return p=o.id+"_"+r,L[p]||(L[p]=c.defineAsyncComponent(async()=>{const a=T[o.id]||await Ye.add(o.id,()=>e(o.id));return a&&(a.name=i,T[o.id]=a),a?z({Vue:c,mode:S.Runtime,...s,dsl:f.cloneDeep(a),loader:V(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return p=o.url+"_"+r,L[p]||(L[p]=c.defineAsyncComponent(async()=>{const a=T[o.url]||await t(o.url);return a&&(a.name=i,T[o.url]=a),a?z({...s,Vue:c,dsl:f.cloneDeep(a),mode:S.Runtime,loader:V(n)}).renderer:null}));if(o.type==="Plugin"){let a=o.library?T[o.library]:null;return a||(o.library&&ne.push(o.library),a=T[o.library||Symbol()]=c.defineAsyncComponent(async()=>{const l=await me(o,s.window);return l||(console.warn("getPlugin result is null",o),null)}),a)}return i}}function Ft(){T={},L={},Ye.clearAllCache(),O.clear()}function M(n,e,t=W,s=Xe,r=[],i=!1,o=0){if(!n||!n.name||n.invisible)return null;const c=t.getCurrentInstance()?.appContext,{id:p=null,directives:a=[]}=n,{vIf:l,vElseIf:u,vElse:d,vFor:h,vShow:m,vModels:g,vBind:_,vHtml:y,others:w}=Ze(a);if(!i&&(u||d))return null;if(l&&!Mt(l,e))return Nt(n,e,t,s,r);const j=(v,A=0)=>{const Z=v.$components,ee=(()=>{if(n.name==="component")return Ot(v,n.props?.is);if(n.name==="slot")return n.name;const P=s(`${n.id}_${A}`,n.name,n.from,t);return f.isString(P)?De(P)||ke(P)?P:Z[P]??c?.app?.component(P)??P:P})(),I=xt(p,n.props??{},v),rt=Ht(t,n.id,n.events??{},v);if(n.name==="slot")return Lt(t,n,I,v,s);_&&Object.assign(I,v.__parseExpression(_.value)),m&&(I.style=Object.assign(I.style??{},qt(m,v))),y&&Object.assign(I,Bt(y,v)),g.forEach(P=>{le.includes(n.name)?Object.assign(I,Jt(P,v)):Object.assign(I,Kt(t,P,v))});const it=Gt(t,n.children??[],v,s,n),Se=v?.__id?`data-v-${v.__id}`:void 0,ot=Se?{[Se]:""}:{},at=v.__mode===S.Design?{"data-vtj":p}:{},K=`${p}_${A}`,te={key:K,...ot,...at,...I,...rt};O.isEqual(te,O.getNode(K))||O.setNode(K,te);let se=t.createVNode(ee,O.getNode(K)||te||{},it);const we=c?Tt(c,w,v):[];return we.length&&(se=t.withDirectives(se,we)),se};return h?Wt(h,j,e):j(e,o)}function Tt(n,e,t){const s=n.app;return e.map(r=>{const i=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!i)return null;const o=[i];return r.value&&o.push(t.__parseExpression(r.value)),r.arg&&o.push(r.arg),r.modifiers&&o.push(r.modifiers),o}).filter(r=>!!r)}function Ze(n=[]){const e=n.find(l=>f.camelCase(l.name)==="vIf"),t=n.find(l=>f.camelCase(l.name)==="vElseIf"),s=n.find(l=>f.camelCase(l.name)==="vElse"),r=n.find(l=>f.camelCase(l.name)==="vFor"),i=n.find(l=>f.camelCase(l.name)==="vShow"),o=n.find(l=>f.camelCase(l.name)==="vBind"),c=n.find(l=>f.camelCase(l.name)==="vHtml"),p=n.filter(l=>f.camelCase(l.name)==="vModel"),a=n.filter(l=>!$e.includes(f.camelCase(l.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:i,vModels:p,vBind:o,others:a,vHtml:c}}function Mt(n,e){return!!e.__parseExpression(n.value)}function Ot(n,e){return e?b(e)?n.__parseExpression(e):e:"div"}function xt(n,e,t){const s=ae(e,t);return s.ref=t.__ref(n,s.ref),s}function ae(n,e){return b(n)?e.__parseExpression(n):C(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ae(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ae(r,e),t},{}):n}function Dt(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function kt(n){return He(n.value)?n:Ne(n.value)?{type:"JSFunction",value:`(...args) => (() => {
13
13
  return (($event) => {
14
14
  ${n.value}
15
15
  }).apply(this, args);
16
- })()`}:Le(n.value)?{type:"JSFunction",value:`() => { ${n.value}}`}:n}function Ht(n,e,t,s){const r=["passive","capture","once"],i={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(t||{}).reduce((c,p)=>{const a=t[p],l=ge(a.modifiers),u=l.find(m=>r.includes(m)),d="on"+f.upperFirstCamelCase(p)+(u&&i[u]||""),h=a.handler?s.__parseFunction(kt(a.handler)):null;return h&&(c[d]=n.withModifiers(l.includes("enter")?xt(h,"enter"):h,l)),c},{})}function Nt(n,e,t,s,r=[]){let i=r.findIndex(o=>o.id===n.id);for(let o=++i;o<r.length;o++){const{directives:c=[]}=r[o],{vElseIf:p,vElse:a}=Ze(c);if(p){if(e.__parseExpression(p.value))return M(r[o],e,t,s,r,!0);continue}if(a)return M(r[o],e,t,s,r,!0)}return null}function ge(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function Lt(n,e,t,s,r){const{children:i}=e,o=Ut(e,s),c=s.$slots?.[o.name];return c?c(t):i?f.isString(i)?n.createTextVNode(i):b(i)?n.createTextVNode(ue(s.__parseExpression(i))):Array.isArray(i)?i.map((p,a)=>M(p,s,n,r,i,!1,a)):null:null}function Ut(n,e){const{props:t}=n,s=t?.name||"default";return{name:b(s)?e.__parseExpression(s):s,params:[]}}function qt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Bt(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Jt(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
16
+ })()`}:Le(n.value)?{type:"JSFunction",value:`() => { ${n.value}}`}:n}function Ht(n,e,t,s){const r=["passive","capture","once"],i={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(t||{}).reduce((c,p)=>{const a=t[p],l=ge(a.modifiers),u=l.find(m=>r.includes(m)),d="on"+f.upperFirstCamelCase(p)+(u&&i[u]||""),h=a.handler?s.__parseFunction(kt(a.handler)):null;return h&&(c[d]=n.withModifiers(l.includes("enter")?Dt(h,"enter"):h,l)),c},{})}function Nt(n,e,t,s,r=[]){let i=r.findIndex(o=>o.id===n.id);for(let o=++i;o<r.length;o++){const{directives:c=[]}=r[o],{vElseIf:p,vElse:a}=Ze(c);if(p){if(e.__parseExpression(p.value))return M(r[o],e,t,s,r,!0);continue}if(a)return M(r[o],e,t,s,r,!0)}return null}function ge(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function Lt(n,e,t,s,r){const{children:i}=e,o=Ut(e,s),c=s.$slots?.[o.name];return c?c(t):i?f.isString(i)?n.createTextVNode(i):b(i)?n.createTextVNode(ue(s.__parseExpression(i))):Array.isArray(i)?i.map((p,a)=>M(p,s,n,r,i,!1,a)):null:null}function Ut(n,e){const{props:t}=n,s=t?.name||"default";return{name:b(s)?e.__parseExpression(s):s,params:[]}}function qt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Bt(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Jt(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
17
17
  ${n.value.value} = v?.target.value;
18
18
  }`:"(v) => {}"};return{[b(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) => {
19
19
  ${e.value.value} = v;
20
- }`:"(v) => {}"},r=t.__parseFunction(s),i=ge(b(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),o=b(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[o]:t.__parseExpression(e.value),[`onUpdate:${o}`]:i.length&&r?n.withModifiers(r,i):r}}function Gt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(b(e))return{default:()=>ue(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const i=zt(e),o=(c,p)=>!c||!r?{}:r?.id&&Object.keys(c).length?p?{[p]:c}:{[`scope_${r.id}`]:c}:p?{[p]:Object.create(null)}:{};return Object.entries(i).reduce((c,[p,{nodes:a,params:l,scope:u}])=>(c[p]=d=>{const h=l.length?f.pick(d??{},l):o(d,u);return a.map((m,g)=>M(m,t.__clone(h),n,s,a,!1,g))},c),{})}return null}function zt(n){const e={};for(const t of n){const s=Vt(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 Vt(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Wt(n,e,t){const{value:s,iterator:r}=n,{item:i="item",index:o="index"}=r||{};let c=t.__parseExpression(s)||[];return Number.isInteger(c)&&(c=new Array(c).fill(!0).map((p,a)=>a+1)),Array.isArray(c)?c.map((p,a)=>e(t.__clone({[i]:p,[o]:a}),a)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const re=$.defineComponent({name:"VtjPageContainer",async setup(){const n=ye(),e=Ee.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,i=$.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:o}=n?.adapter;if(o){const c=e.meta.title||s.title||"VTJ.PRO";o(c)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:i,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?$.h(n,{...e,key:t}):$.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Qt=$.defineComponent({name:"VtjStartupContainer",render(){return $.h("div","page not found!")}});function q(n,e,t=[]){const s=[];for(const r of t){const{id:i,title:o,icon:c,children:p,hidden:a,layout:l}=r;if(l){const u=q(n,e,p||[]);s.push(...u)}else{const u={id:i,title:o,icon:c,hidden:a,url:`${n}/${e}/${i}`,children:p&&p.length?q(n,e,p):void 0};s.push(u)}}return s}function _e(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=_e(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Yt(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=ye(),i=Ee.useRoute(),o=qe(),c=$.ref(!1),p=$.ref(!1),a=r.project,l=(h,m)=>{c.value=!h?.mask,p.value=m?.pure??!!h?.pure};$.watchEffect(()=>{const{name:h,params:m,meta:g}=i;if(h===x){const _=r.getPage(m.id);l(_,g)}else if(h===U){const _=r.getHomepage();l(_,g)}else{const _=g.__vtj__;if(_){const y=r.getPage(_);l(y,g)}else c.value=!g.mask,p.value=!!g.pure}});const u=q(e,t,a?.pages),d=a?.config;return{disabled:c,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||a?.description||a?.name||"VTJ App",menus:s?u:_e(u,o),pure:p}}function ie(n,e){const{id:t,title:s,meta:r}=n,{name:i="page",prefix:o="",component:c,routeMeta:p}=e;return{name:t,path:`${o}${i}/${t}`,component:c,meta:{title:s,...p,...r,__vtj__:t}}}function ce(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:i,routeMeta:o,homepage:c}=n,p=[];for(const a of s){const{id:l,title:u,dir:d,layout:h,children:m,meta:g}=a;if(d){const _=ce({name:e,prefix:t,component:r,routeMeta:o,homepage:c,loader:i,pages:m||[]});p.push(..._)}else if(h){const _=ce({name:e,prefix:t,component:r,routeMeta:o,homepage:c,loader:i,pages:m||[]}),y={name:`layout_${l}`,path:t,component:()=>i(l),meta:{title:u,...o,...g,__vtj__:l},children:_};p.push(y),p.push(ie(a,n))}else if(p.push(ie(a,n)),c===l){const _=ie(a,n);_.path="",_.name=`home_${l}`,p.push(_)}}return p}function Xt(n={},e){const{css:t,store:s,enhance:r}=n,{window:i,app:o,library:c={},adapter:p,mode:a}=e,{Pinia:l}=c;o.config.globalProperties.$libs=c,Q(i,"global-css",t||""),l&&s&&Zt(s,o,l),ts(o,p,n),!p.access&&n.access&&es(n.access,o,a,p),ss(o,n),r&&ns(r,o,c)}function Zt(n,e,t){const s=t.createPinia();if(e.use(s),C(n)&&n.value){const r=R(n,{},!1,!1,!0),i=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=i()}}function es(n,e,t,s){if(C(n)&&n.value){const r=R(n,{},!1,!1,!0),{alert:i,request:o}=s,c=new Y({alert:i,storagePrefix:"__VTJ_APP_",...r(e)}),p=e.config.globalProperties.$router;c.connect({mode:t,router:p,request:o}),e.use(c)}}function ts(n,e,t){if(!e.request)return;const{axios:s,request:r,response:i}=t;if(s&&C(s)&&s.value){const o=R(s,{},!1,!1,!0);e.request.setConfig(o(n))}if(r&&C(r)&&r.value){const o=R(r,{},!1,!1,!0),c=e.request;c.__unReq&&c.__unReq(),c.__unReq=e.request.useRequest(p=>o(p,n))}if(i&&C(i)&&i.value){const o=R(i,{},!1,!1,!0),c=e.request;c.__unRes&&c.__unRes(),c.__unRes=e.request.useResponse(p=>o(p,n))}}function ss(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&C(t)&&t.value){const i=R(t,{},!1,!1,!0);r&&r.beforeEach((o,c,p)=>i(o,c,p,n))}if(s&&C(s)&&s.value){const i=R(s,{},!1,!1,!0);r&&r.afterEach((o,c,p)=>i(o,c,p,n))}}function ns(n,e,t={}){C(n)&&n.value&&R(n,{},!1,!1,!0)(e,t)}function rs(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:i,messages:o=[]}=t,c={};for(let a of o){const l=Object.keys(a).filter(u=>u!=="key");for(const u of l)c[u]||(c[u]={}),c[u][a.key]=a[u]}const p=s.createI18n({legacy:!1,locale:r,fallbackLocale:i,messages:c});n.use(p)}}const ve=Symbol("Provider");var et=(n=>(n.Production="production",n.Development="development",n))(et||{});class tt extends F.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:i,project:o={},adapter:c={},globals:p={},modules:a={},router:l=null,materialPath:u="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=a,this.service=t,this.router=l,this.materialPath=u,this.nodeEnv=d,r&&(this.dependencies=r),i&&(this.materials=i),Object.assign(this.globals,p),Object.assign(this.adapter,c);const{access:h,request:m}=this.adapter;h&&h.connect({mode:s,router:l,request:m}),o&&s!==S.Design?this.load(o):this.project=o}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(i){f.logger.warn("模拟数据模版异常",i)}return k()?.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:i=[],env:o=[]}=this.project,c=window;c&&(c.CKEDITOR_VERSION=void 0),this.initEnv(o),this.mode===S.Raw?await this.loadDependencies(c):await this.loadAssets(c),this.initMock(c),this.apis=Ke(r,i,this.adapter),he(c),Ge(r,c),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=k(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:i,materialPath:o,nodeEnv:c,libraryLocales:p}=this,{libraryExports:a,libraryMap:l,materials:u,materialExports:d,materialMapLibrary:h,libraryLocaleMap:m}=Pe(t,o,c==="development");Object.assign(this.libraryLocaleMap,m);for(const g of a){const _=s[g],y=e[g];if(y)r[g]=y;else if(_)e[g]=r[g]=await _();else{const j=l[g]||[];for(const v of j)B(v)&&await Oe(v,f.url.append(v,{v:D})),J(v)&&await f.loadScript(f.url.append(v,{v:D}));r[g]=e[g]}const w=m[g];if(w){const j=s[w];p[w]=j?await j():e[w]}}if(c==="development"){for(const _ of u)await f.loadScript(f.url.append(_,{v:D}));const g=this.materials||{};for(const _ of d){const y=e[h[_]],w=y?.default||y,j=F.BUILT_IN_COMPONENTS[_];if(j)w&&j.forEach(v=>{i[v]=w[v]});else{const v=g[_]?(await g[_]()).default:e[_];v&&w&&(v.components||[]).forEach(A=>{i[A.name]=Ae(A,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const i=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:o,pageRouteName:c=i,routeMeta:p}=s,a=o?"":"/",l={path:`${a}${c}/:id`,name:x,component:re},u=this.getHomepage(),d={path:a,name:U,component:u?re:r.startupComponent||Qt,meta:p};if(e.hasRoute(x)&&e.removeRoute(x),e.hasRoute(U)&&e.removeRoute(U),s.enableStaticRoute){const h=t?.pages||[];ce({name:c,prefix:a,pages:h,component:re,loader:this.getRenderComponent.bind(this),homepage:u?.id}).forEach(g=>{o?e.addRoute(o,g):e.addRoute(g)}),u||(o?e.addRoute(o,d):e.addRoute(d))}else o?(e.addRoute(o,l),e.addRoute(o,d)):(e.addRoute(l),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const i=s?.$options.name,o=typeof t=="string"?t:t?.message||t?.msg||"未知错误",c=`[ ${i} ] ${o} ${r}`;["getComputedStyle","ResizeObserver"].some(a=>c.includes(a))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(c,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,i=e.config.globalProperties.installed||{};for(const[o,c]of Object.entries(this.library))if(!i[o]&&De(c)){const a={locale:s[t[o]]},l=r[o]||{},u={...a,...l};e.use(c,u),i[o]=!0}e.provide(ve,this),e.config.globalProperties.$provider=this,e.config.globalProperties.$apis=this.apis,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=i}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,i=[])=>{for(const o of i){if(o.id===r)return o;if(o.children&&o.children.length){const c=s(r,o.children);if(c)return c}}};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 i=t(r.children);if(i)return i}}};return t(e)||null}getMenus(e="page",t=""){return q(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:i,apis:o}=this,c={mode:i,Vue:s.Vue,components:r,libs:s,apis:o,window,...t},p=V({getDsl:async a=>await this.getDsl(a)||null,getDslByUrl:async a=>await this.getDslByUrl(a)||null,options:c});return z({...c,dsl:e,loader:p})}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:i=".vtj/vue"}=this.options,o=`${i}/${e}.vue`,c=this.modules[o]||this.modules[`/src/pages/${e}.vue`];return c?(await c())?.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 $.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return $.defineAsyncComponent(async()=>await me(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Xt(e,s)}initI18n(e,t,s){rs(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function is(n){const e=new tt(n);return{provider:e,onReady:s=>e.ready(s)}}function ye(n={}){const e=$.inject(ve,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 os(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(c=>e+c),{css:i,js:o}=Ie(r);if(i.length&&pe(i),o.length)return await fe(o,t).catch(()=>{})}const st={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},as=(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:st}),cs=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...st,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function ls(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 X{constructor(e=f.request){this.req=e,this.api=as(e),this.uploader=cs(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(i=>je(i))[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(i=>i.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const E=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class us extends X{init(e){const t=new F.ProjectModel(e),s=E.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return E.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new F.ProjectModel(e);return E.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return E.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return E.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=E.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return E.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return E.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=E.get(`history_${e}`);if(t){const r=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,r),E.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=E.get(`history_${e}`),s=new F.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=E.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return E.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{E.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class nt extends X{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new F.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 F.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(i=>i.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new F.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 G=null;function ps(){return G||(G=new nt,G)}class fs extends X{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=pt;exports.ACCESS_KEY=de;exports.Access=Y;exports.BUILD_IN_TAGS=be;exports.BUILT_IN_DIRECTIVES=$e;exports.BaseService=X;exports.CONTEXT_HOST=oe;exports.Context=We;exports.ContextMode=S;exports.DATA_TYPES=Ce;exports.HOMEPAGE_ROUTE_NAME=U;exports.HTML_TAGS=le;exports.JSCodeToString=vt;exports.LIFE_CYCLES_LIST=lt;exports.LocalService=fs;exports.MemoryService=nt;exports.NodeEnv=et;exports.PAGE_ROUTE_NAME=x;exports.Provider=tt;exports.REMOTE=ut;exports.StorageService=us;exports.VTJ_RENDERER_VERSION=D;exports.adoptStylesToInline=mt;exports.adoptedStyleSheets=Q;exports.clearLoaderCache=Ft;exports.compileScopedCSS=Fe;exports.convertCssRpx=Me;exports.createAccess=wt;exports.createAdapter=St;exports.createAssetScripts=ft;exports.createAssetsCss=dt;exports.createDataSources=Qe;exports.createLoader=V;exports.createMemoryService=ps;exports.createMenus=q;exports.createMetaApi=Je;exports.createMock=ze;exports.createProvider=is;exports.createRenderer=z;exports.createSchemaApi=Be;exports.createSchemaApis=Ke;exports.createServiceRequest=ls;exports.defaultLoader=Xe;exports.fillBasePath=N;exports.getMock=k;exports.getModifiers=ge;exports.getPlugin=me;exports.getRawComponent=Ae;exports.isArrowFunction=He;exports.isAssignment‌=Le;exports.isBuiltInTag=xe;exports.isCSSUrl=B;exports.isCallFunction=Ne;exports.isJSCode=Ue;exports.isJSExpression=b;exports.isJSFunction=C;exports.isJSON=je;exports.isJSUrl=J;exports.isNativeTag=ke;exports.isVuePlugin=De;exports.loadCss=Oe;exports.loadCssUrl=pe;exports.loadEnhance=os;exports.loadScriptUrl=fe;exports.menusFilter=_e;exports.mockApi=Ve;exports.mockApis=Ge;exports.mockCleanup=he;exports.nodeCache=O;exports.nodeRender=M;exports.parseDeps=Pe;exports.parseExpression=H;exports.parseFunction=R;exports.parseUrls=Ie;exports.providerKey=ve;exports.removeProdFlag=Re;exports.rpxToPx=Te;exports.setupPageSetting=gt;exports.toString=ue;exports.useAccess=qe;exports.useMask=Yt;exports.useProvider=ye;
20
+ }`:"(v) => {}"},r=t.__parseFunction(s),i=ge(b(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),o=b(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[o]:t.__parseExpression(e.value),[`onUpdate:${o}`]:i.length&&r?n.withModifiers(r,i):r}}function Gt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(b(e))return{default:()=>ue(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const i=zt(e),o=(c,p)=>!c||!r?{}:r?.id&&Object.keys(c).length?p?{[p]:c}:{[`scope_${r.id}`]:c}:p?{[p]:Object.create(null)}:{};return Object.entries(i).reduce((c,[p,{nodes:a,params:l,scope:u}])=>(c[p]=d=>{const h=l.length?f.pick(d??{},l):o(d,u);return a.map((m,g)=>M(m,t.__clone(h),n,s,a,!1,g))},c),{})}return null}function zt(n){const e={};for(const t of n){const s=Vt(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 Vt(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Wt(n,e,t){const{value:s,iterator:r}=n,{item:i="item",index:o="index"}=r||{};let c=t.__parseExpression(s)||[];return Number.isInteger(c)&&(c=new Array(c).fill(!0).map((p,a)=>a+1)),Array.isArray(c)?c.map((p,a)=>e(t.__clone({[i]:p,[o]:a}),a)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const re=$.defineComponent({name:"VtjPageContainer",async setup(){const n=ye(),e=Ee.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,i=$.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:o}=n?.adapter;if(o){const c=e.meta.title||s.title||"VTJ.PRO";o(c)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:i,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?$.h(n,{...e,key:t}):$.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Qt=$.defineComponent({name:"VtjStartupContainer",render(){return $.h("div","page not found!")}});function q(n,e,t=[]){const s=[];for(const r of t){const{id:i,title:o,icon:c,children:p,hidden:a,layout:l}=r;if(l){const u=q(n,e,p||[]);s.push(...u)}else{const u={id:i,title:o,icon:c,hidden:a,url:`${n}/${e}/${i}`,children:p&&p.length?q(n,e,p):void 0};s.push(u)}}return s}function _e(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=_e(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Yt(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=ye(),i=Ee.useRoute(),o=qe(),c=$.ref(!1),p=$.ref(!1),a=r.project,l=(h,m)=>{c.value=!h?.mask,p.value=m?.pure??!!h?.pure};$.watchEffect(()=>{const{name:h,params:m,meta:g}=i;if(h===D){const _=r.getPage(m.id);l(_,g)}else if(h===U){const _=r.getHomepage();l(_,g)}else{const _=g.__vtj__;if(_){const y=r.getPage(_);l(y,g)}else c.value=!g.mask,p.value=!!g.pure}});const u=q(e,t,a?.pages),d=a?.config;return{disabled:c,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||a?.description||a?.name||"VTJ App",menus:s?u:_e(u,o),pure:p}}function ie(n,e){const{id:t,title:s,meta:r}=n,{name:i="page",prefix:o="",component:c,routeMeta:p}=e;return{name:t,path:`${o}${i}/${t}`,component:c,meta:{title:s,...p,...r,__vtj__:t}}}function ce(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:i,routeMeta:o,homepage:c}=n,p=[];for(const a of s){const{id:l,title:u,dir:d,layout:h,children:m,meta:g}=a;if(d){const _=ce({name:e,prefix:t,component:r,routeMeta:o,homepage:c,loader:i,pages:m||[]});p.push(..._)}else if(h){const _=ce({name:e,prefix:t,component:r,routeMeta:o,homepage:c,loader:i,pages:m||[]}),y={name:`layout_${l}`,path:t,component:()=>i(l),meta:{title:u,...o,...g,__vtj__:l},children:_};p.push(y),p.push(ie(a,n))}else if(p.push(ie(a,n)),c===l){const _=ie(a,n);_.path="",_.name=`home_${l}`,p.push(_)}}return p}function Xt(n={},e){const{css:t,store:s,enhance:r}=n,{window:i,app:o,library:c={},adapter:p,mode:a}=e,{Pinia:l}=c;o.config.globalProperties.$libs=c,Q(i,"global-css",t||""),l&&s&&Zt(s,o,l),ts(o,p,n),!p.access&&n.access&&es(n.access,o,a,p),ss(o,n),r&&ns(r,o,c)}function Zt(n,e,t){const s=t.createPinia();if(e.use(s),C(n)&&n.value){const r=R(n,{},!1,!1,!0),i=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=i()}}function es(n,e,t,s){if(C(n)&&n.value){const r=R(n,{},!1,!1,!0),{alert:i,request:o}=s,c=new Y({alert:i,storagePrefix:"__VTJ_APP_",...r(e)}),p=e.config.globalProperties.$router;c.connect({mode:t,router:p,request:o}),e.use(c)}}function ts(n,e,t){if(!e.request)return;const{axios:s,request:r,response:i}=t;if(s&&C(s)&&s.value){const o=R(s,{},!1,!1,!0);e.request.setConfig(o(n))}if(r&&C(r)&&r.value){const o=R(r,{},!1,!1,!0),c=e.request;c.__unReq&&c.__unReq(),c.__unReq=e.request.useRequest(p=>o(p,n))}if(i&&C(i)&&i.value){const o=R(i,{},!1,!1,!0),c=e.request;c.__unRes&&c.__unRes(),c.__unRes=e.request.useResponse(p=>o(p,n))}}function ss(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&C(t)&&t.value){const i=R(t,{},!1,!1,!0);r&&r.beforeEach((o,c,p)=>i(o,c,p,n))}if(s&&C(s)&&s.value){const i=R(s,{},!1,!1,!0);r&&r.afterEach((o,c,p)=>i(o,c,p,n))}}function ns(n,e,t={}){C(n)&&n.value&&R(n,{},!1,!1,!0)(e,t)}function rs(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:i,messages:o=[]}=t,c={};for(let a of o){const l=Object.keys(a).filter(u=>u!=="key");for(const u of l)c[u]||(c[u]={}),c[u][a.key]=a[u]}const p=s.createI18n({legacy:!1,locale:r,fallbackLocale:i,messages:c});n.use(p)}}const ve=Symbol("Provider");var et=(n=>(n.Production="production",n.Development="development",n))(et||{});class tt extends F.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:i,project:o={},adapter:c={},globals:p={},modules:a={},router:l=null,materialPath:u="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=a,this.service=t,this.router=l,this.materialPath=u,this.nodeEnv=d,r&&(this.dependencies=r),i&&(this.materials=i),Object.assign(this.globals,p),Object.assign(this.adapter,c);const{access:h,request:m}=this.adapter;h&&h.connect({mode:s,router:l,request:m}),o&&s!==S.Design?this.load(o):this.project=o}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(i){f.logger.warn("模拟数据模版异常",i)}return k()?.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:i=[],env:o=[]}=this.project,c=window;c&&(c.CKEDITOR_VERSION=void 0),this.initEnv(o),this.mode===S.Raw?await this.loadDependencies(c):await this.loadAssets(c),this.initMock(c),this.apis=Ke(r,i,this.adapter),he(c),Ge(r,c),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=k(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:i,materialPath:o,nodeEnv:c,libraryLocales:p}=this,{libraryExports:a,libraryMap:l,materials:u,materialExports:d,materialMapLibrary:h,libraryLocaleMap:m}=Pe(t,o,c==="development");Object.assign(this.libraryLocaleMap,m);for(const g of a){const _=s[g],y=e[g];if(y)r[g]=y;else if(_)e[g]=r[g]=await _();else{const j=l[g]||[];for(const v of j)B(v)&&await Oe(v,f.url.append(v,{v:x})),J(v)&&await f.loadScript(f.url.append(v,{v:x}));r[g]=e[g]}const w=m[g];if(w){const j=s[w];p[w]=j?await j():e[w]}}if(c==="development"){for(const _ of u)await f.loadScript(f.url.append(_,{v:x}));const g=this.materials||{};for(const _ of d){const y=e[h[_]],w=y?.default||y,j=F.BUILT_IN_COMPONENTS[_];if(j)w&&j.forEach(v=>{i[v]=w[v]});else{const v=g[_]?(await g[_]()).default:e[_];v&&w&&(v.components||[]).forEach(A=>{i[A.name]=Ae(A,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const i=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:o,pageRouteName:c=i,routeMeta:p}=s,a=o?"":"/",l={path:`${a}${c}/:id`,name:D,component:re},u=this.getHomepage(),d={path:a,name:U,component:u?re:r.startupComponent||Qt,meta:p};if(e.hasRoute(D)&&e.removeRoute(D),e.hasRoute(U)&&e.removeRoute(U),s.enableStaticRoute){const h=t?.pages||[];ce({name:c,prefix:a,pages:h,component:re,loader:this.getRenderComponent.bind(this),homepage:u?.id}).forEach(g=>{o?e.addRoute(o,g):e.addRoute(g)}),u||(o?e.addRoute(o,d):e.addRoute(d))}else o?(e.addRoute(o,l),e.addRoute(o,d)):(e.addRoute(l),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const i=s?.$options.name,o=typeof t=="string"?t:t?.message||t?.msg||"未知错误",c=`[ ${i} ] ${o} ${r}`;["getComputedStyle","ResizeObserver"].some(a=>c.includes(a))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(c,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,i=e.config.globalProperties.installed||{};for(const[o,c]of Object.entries(this.library))if(!i[o]&&xe(c)){const a={locale:s[t[o]]},l=r[o]||{},u={...a,...l};e.use(c,u),i[o]=!0}e.provide(ve,this),e.config.globalProperties.$provider=this,e.config.globalProperties.$apis=this.apis,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=i}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,i=[])=>{for(const o of i){if(o.id===r)return o;if(o.children&&o.children.length){const c=s(r,o.children);if(c)return c}}};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 i=t(r.children);if(i)return i}}};return t(e)||null}getMenus(e="page",t=""){return q(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:i,apis:o}=this,c={mode:i,Vue:s.Vue,components:r,libs:s,apis:o,window,...t},p=V({getDsl:async a=>await this.getDsl(a)||null,getDslByUrl:async a=>await this.getDslByUrl(a)||null,options:c});return z({...c,dsl:e,loader:p})}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:i=".vtj/vue"}=this.options,o=`${i}/${e}.vue`,c=this.modules[o]||this.modules[`/src/pages/${e}.vue`];return c?(await c())?.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 $.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return $.defineAsyncComponent(async()=>await me(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Xt(e,s)}initI18n(e,t,s){rs(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function is(n){const e=new tt(n);return{provider:e,onReady:s=>e.ready(s)}}function ye(n={}){const e=$.inject(ve,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 os(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(c=>e+c),{css:i,js:o}=Ie(r);if(i.length&&pe(i),o.length)return await fe(o,t).catch(()=>{})}const st={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},as=(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:st}),cs=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...st,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function ls(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 X{constructor(e=f.request){this.req=e,this.api=as(e),this.uploader=cs(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(i=>je(i))[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(i=>i.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const E=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class us extends X{init(e){const t=new F.ProjectModel(e),s=E.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return E.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new F.ProjectModel(e);return E.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return E.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return E.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=E.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return E.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return E.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=E.get(`history_${e}`);if(t){const r=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,r),E.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=E.get(`history_${e}`),s=new F.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=E.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return E.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{E.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class nt extends X{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new F.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 F.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(i=>i.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new F.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 G=null;function ps(){return G||(G=new nt,G)}class fs extends X{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=pt;exports.ACCESS_KEY=de;exports.Access=Y;exports.BUILD_IN_TAGS=be;exports.BUILT_IN_DIRECTIVES=$e;exports.BaseService=X;exports.CONTEXT_HOST=oe;exports.Context=We;exports.ContextMode=S;exports.DATA_TYPES=Ce;exports.HOMEPAGE_ROUTE_NAME=U;exports.HTML_TAGS=le;exports.JSCodeToString=vt;exports.LIFE_CYCLES_LIST=lt;exports.LocalService=fs;exports.MemoryService=nt;exports.NodeEnv=et;exports.PAGE_ROUTE_NAME=D;exports.Provider=tt;exports.REMOTE=ut;exports.StorageService=us;exports.VTJ_RENDERER_VERSION=x;exports.adoptStylesToInline=mt;exports.adoptedStyleSheets=Q;exports.clearLoaderCache=Ft;exports.compileScopedCSS=Fe;exports.convertCssRpx=Me;exports.createAccess=wt;exports.createAdapter=St;exports.createAssetScripts=ft;exports.createAssetsCss=dt;exports.createDataSources=Qe;exports.createLoader=V;exports.createMemoryService=ps;exports.createMenus=q;exports.createMetaApi=Je;exports.createMock=ze;exports.createProvider=is;exports.createRenderer=z;exports.createSchemaApi=Be;exports.createSchemaApis=Ke;exports.createServiceRequest=ls;exports.defaultLoader=Xe;exports.fillBasePath=N;exports.getMock=k;exports.getModifiers=ge;exports.getPlugin=me;exports.getRawComponent=Ae;exports.isArrowFunction=He;exports.isAssignment‌=Le;exports.isBuiltInTag=De;exports.isCSSUrl=B;exports.isCallFunction=Ne;exports.isJSCode=Ue;exports.isJSExpression=b;exports.isJSFunction=C;exports.isJSON=je;exports.isJSUrl=J;exports.isNativeTag=ke;exports.isVuePlugin=xe;exports.loadCss=Oe;exports.loadCssUrl=pe;exports.loadEnhance=os;exports.loadScriptUrl=fe;exports.menusFilter=_e;exports.mockApi=Ve;exports.mockApis=Ge;exports.mockCleanup=he;exports.nodeCache=O;exports.nodeRender=M;exports.parseDeps=Pe;exports.parseExpression=H;exports.parseFunction=R;exports.parseUrls=Ie;exports.providerKey=ve;exports.removeProdFlag=Re;exports.rpxToPx=Te;exports.setupPageSetting=gt;exports.toString=ue;exports.useAccess=qe;exports.useMask=Yt;exports.useProvider=ye;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Base as Xe, BUILT_IN_COMPONENTS as Ye, ProjectModel as K, HistoryModel as Ce } from "@vtj/core";
2
- import { url as O, isUrl as ae, dedupArray as Ze, isFunction as z, isString as I, logger as M, storage as se, cookie as ne, toArray as Se, unRSA as $e, delay as G, createRequest as Pe, jsonp as Ae, merge as et, pathToRegexp as tt, pathToRegexpMatch as st, formDataToJson as nt, isEqual as rt, Queue as it, cloneDeep as Ee, camelCase as P, upperFirstCamelCase as ot, pick as at, request as ce, loadScript as be, debounce as ct, Storage as lt, mapToObject as me } from "@vtj/utils";
2
+ import { url as O, isUrl as ae, dedupArray as Ze, isFunction as z, isString as I, logger as x, storage as se, cookie as ne, toArray as Se, unRSA as $e, delay as G, createRequest as Pe, jsonp as Ae, merge as et, pathToRegexp as tt, pathToRegexpMatch as st, formDataToJson as nt, isEqual as rt, Queue as it, cloneDeep as Ee, camelCase as P, upperFirstCamelCase as ot, pick as at, request as ce, loadScript as be, debounce as ct, Storage as lt, mapToObject as me } from "@vtj/utils";
3
3
  import * as W from "vue";
4
4
  import { inject as Ie, defineComponent as Fe, h as le, ref as ue, watchEffect as ut, defineAsyncComponent as je } from "vue";
5
5
  import { useRoute as Oe } from "vue-router";
@@ -7,10 +7,10 @@ import { useRoute as Oe } from "vue-router";
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.17.5
10
+ * @version 0.17.6
11
11
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
12
12
  */
13
- const H = "0.17.5";
13
+ const H = "0.17.6";
14
14
  var y = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(y || {});
15
15
  const Re = [
16
16
  "$el",
@@ -24,7 +24,7 @@ const Re = [
24
24
  "$props",
25
25
  "$options",
26
26
  "$forceUpdate"
27
- ], Ms = [
27
+ ], xs = [
28
28
  "beforeCreate",
29
29
  "created",
30
30
  "beforeMount",
@@ -55,9 +55,9 @@ const Re = [
55
55
  Object,
56
56
  Function,
57
57
  Date
58
- }, k = "VtjPage", J = "VtjHomepage", Me = "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(
58
+ }, k = "VtjPage", J = "VtjHomepage", xe = "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(
59
59
  ","
60
- ), dt = "component,slot".split(","), Ts = [
60
+ ), dt = "component,slot".split(","), Ms = [
61
61
  "h",
62
62
  "t",
63
63
  "t",
@@ -77,7 +77,7 @@ const Re = [
77
77
  "p",
78
78
  "r",
79
79
  "o"
80
- ].join(""), xs = {
80
+ ].join(""), Ts = {
81
81
  auth: [
82
82
  "h",
83
83
  "t",
@@ -329,7 +329,7 @@ function $t(n, e) {
329
329
  }
330
330
  return i;
331
331
  }
332
- function Te(n) {
332
+ function Me(n) {
333
333
  return I(n) ? n : JSON.stringify(n);
334
334
  }
335
335
  function ge(n, e, t, s = !1) {
@@ -367,7 +367,7 @@ async function Et(n, e) {
367
367
  const t = await window.fetch(e).then((s) => s.text()).catch(() => "");
368
368
  t && ge(window, n, t);
369
369
  }
370
- function xe(n, e = window) {
370
+ function Te(n, e = window) {
371
371
  const t = e.document, s = e.document.head;
372
372
  for (const r of n)
373
373
  if (!t.getElementById(r)) {
@@ -396,7 +396,7 @@ function jt(n) {
396
396
  return dt.includes(n);
397
397
  }
398
398
  function Rt(n) {
399
- return Me.includes(n);
399
+ return xe.includes(n);
400
400
  }
401
401
  function N(n = window) {
402
402
  const e = window?.Mock;
@@ -441,13 +441,13 @@ ${o}
441
441
  ` : `with(${t ? "{}" : "$scope || {}"}) { ${o} }`;
442
442
  return new Function("$scope", c)(e);
443
443
  } catch (i) {
444
- if (M.error("parseExpression.error", i, n, e?.__self ?? e), It(i), s)
444
+ if (x.error("parseExpression.error", i, n, e?.__self ?? e), It(i), s)
445
445
  throw i;
446
446
  }
447
447
  }
448
448
  function R(n, e, t = !1, s = !1, r = !1) {
449
449
  const i = L(n, e, t, s, r);
450
- if (typeof i != "function" && (M.error(
450
+ if (typeof i != "function" && (x.error(
451
451
  "parseFunction.error",
452
452
  "not a function",
453
453
  n,
@@ -638,7 +638,7 @@ class _e {
638
638
  );
639
639
  }
640
640
  }
641
- function Mt() {
641
+ function xt() {
642
642
  return Ie(He, null);
643
643
  }
644
644
  function Bs(n = {}) {
@@ -654,6 +654,7 @@ function Bs(n = {}) {
654
654
  let f = null;
655
655
  return {
656
656
  request: Pe({
657
+ adapter: n.axiosAdapter,
657
658
  settings: {
658
659
  type: "form",
659
660
  validSuccess: !0,
@@ -685,7 +686,7 @@ function Bs(n = {}) {
685
686
  function qs(n = {}) {
686
687
  return new _e(n);
687
688
  }
688
- function Tt(n, e) {
689
+ function Mt(n, e) {
689
690
  const { jsonp: t, request: s } = e;
690
691
  if (n.method === "jsonp")
691
692
  return (r = {}) => t(n.url, {
@@ -704,7 +705,7 @@ function Tt(n, e) {
704
705
  return (o, c) => (delete i.data, s.send(et(i, c || {}, { data: o })));
705
706
  }
706
707
  }
707
- function xt(n, e) {
708
+ function Tt(n, e) {
708
709
  const { metaQuery: t } = e;
709
710
  if (!t) return;
710
711
  const { code: s, queryCode: r } = n;
@@ -719,11 +720,11 @@ function xt(n, e) {
719
720
  function Dt(n = [], e = [], t) {
720
721
  const s = {};
721
722
  for (const r of n) {
722
- const i = Tt(r, t);
723
+ const i = Mt(r, t);
723
724
  s[r.id] = i, s[r.name] = i;
724
725
  }
725
726
  for (const r of e)
726
- s[r.id] = xt(r, t);
727
+ s[r.id] = Tt(r, t);
727
728
  return s;
728
729
  }
729
730
  async function Ht(n = [], e = window) {
@@ -738,7 +739,7 @@ function kt(n, e = window) {
738
739
  try {
739
740
  i = await t.apply(t, r);
740
741
  } catch (o) {
741
- M.warn("模拟数据模版异常", o);
742
+ x.warn("模拟数据模版异常", o);
742
743
  }
743
744
  return s?.mock(i);
744
745
  };
@@ -931,10 +932,10 @@ function fe(n) {
931
932
  if (!c.value.nodes) return null;
932
933
  const u = c.value.nodes || [];
933
934
  if (u.length === 1)
934
- return T(u[0], a, e, o, u);
935
+ return M(u[0], a, e, o, u);
935
936
  {
936
937
  const p = u.map(
937
- (d) => T(d, a, e, o, u)
938
+ (d) => M(d, a, e, o, u)
938
939
  );
939
940
  return e.createVNode("div", {}, p);
940
941
  }
@@ -1084,14 +1085,14 @@ class Qt {
1084
1085
  this.__props = {}, this.__events = {}, this.__nodes = {};
1085
1086
  }
1086
1087
  }
1087
- const x = new Qt(), Ne = new it();
1088
+ const T = new Qt(), Ne = new it();
1088
1089
  let re = [], F = {}, D = {};
1089
1090
  const Xt = (n, e) => e;
1090
1091
  async function Le(n, e = window) {
1091
1092
  const { urls: t = [], library: s } = n, r = t.filter((c) => X(c));
1092
1093
  if (r.length === 0 || !s) return null;
1093
1094
  const i = t.filter((c) => Q(c));
1094
- return i.length && xe(i, e), await De(r, s, e).catch(
1095
+ return i.length && Te(i, e), await De(r, s, e).catch(
1095
1096
  (c) => (console.warn("loadScriptUrl error", r, s, c), null)
1096
1097
  );
1097
1098
  }
@@ -1140,9 +1141,9 @@ function pe(n) {
1140
1141
  };
1141
1142
  }
1142
1143
  function Us() {
1143
- F = {}, D = {}, Ne.clearAllCache(), x.clear();
1144
+ F = {}, D = {}, Ne.clearAllCache(), T.clear();
1144
1145
  }
1145
- function T(n, e, t = W, s = Xt, r = [], i = !1, o = 0) {
1146
+ function M(n, e, t = W, s = Xt, r = [], i = !1, o = 0) {
1146
1147
  if (!n || !n.name || n.invisible) return null;
1147
1148
  const c = t.getCurrentInstance()?.appContext, { id: f = null, directives: a = [] } = n, { vIf: l, vElseIf: u, vElse: p, vFor: d, vShow: h, vModels: m, vBind: g, vHtml: v, others: w } = Be(a);
1148
1149
  if (!i && (u || p))
@@ -1168,7 +1169,7 @@ function T(n, e, t = W, s = Xt, r = [], i = !1, o = 0) {
1168
1169
  A.style ?? {},
1169
1170
  cs(h, _)
1170
1171
  )), v && Object.assign(A, ls(v, _)), m.forEach((j) => {
1171
- Me.includes(n.name) ? Object.assign(A, us(j, _)) : Object.assign(A, fs(t, j, _));
1172
+ xe.includes(n.name) ? Object.assign(A, us(j, _)) : Object.assign(A, fs(t, j, _));
1172
1173
  });
1173
1174
  const Ve = ps(
1174
1175
  t,
@@ -1183,10 +1184,10 @@ function T(n, e, t = W, s = Xt, r = [], i = !1, o = 0) {
1183
1184
  ...A,
1184
1185
  ...Ge
1185
1186
  };
1186
- x.isEqual(ee, x.getNode(B)) || x.setNode(B, ee);
1187
+ T.isEqual(ee, T.getNode(B)) || T.setNode(B, ee);
1187
1188
  let te = t.createVNode(
1188
1189
  Z,
1189
- x.getNode(B) || ee || {},
1190
+ T.getNode(B) || ee || {},
1190
1191
  Ve
1191
1192
  );
1192
1193
  const we = c ? Yt(c, w, _) : [];
@@ -1283,11 +1284,11 @@ function is(n, e, t, s, r = []) {
1283
1284
  const { directives: c = [] } = r[o], { vElseIf: f, vElse: a } = Be(c);
1284
1285
  if (f) {
1285
1286
  if (e.__parseExpression(f.value))
1286
- return T(r[o], e, t, s, r, !0);
1287
+ return M(r[o], e, t, s, r, !0);
1287
1288
  continue;
1288
1289
  }
1289
1290
  if (a)
1290
- return T(r[o], e, t, s, r, !0);
1291
+ return M(r[o], e, t, s, r, !0);
1291
1292
  }
1292
1293
  return null;
1293
1294
  }
@@ -1298,9 +1299,9 @@ function qe(n = {}, e = !1) {
1298
1299
  function os(n, e, t, s, r) {
1299
1300
  const { children: i } = e, o = as(e, s), c = s.$slots?.[o.name];
1300
1301
  return c ? c(t) : i ? I(i) ? n.createTextVNode(i) : E(i) ? n.createTextVNode(
1301
- Te(s.__parseExpression(i))
1302
+ Me(s.__parseExpression(i))
1302
1303
  ) : Array.isArray(i) ? i.map(
1303
- (f, a) => T(f, s, n, r, i, !1, a)
1304
+ (f, a) => M(f, s, n, r, i, !1, a)
1304
1305
  ) : null : null;
1305
1306
  }
1306
1307
  function as(n, e) {
@@ -1352,7 +1353,7 @@ function ps(n, e, t, s, r) {
1352
1353
  return { default: () => e };
1353
1354
  if (E(e))
1354
1355
  return {
1355
- default: () => Te(t.__parseExpression(e))
1356
+ default: () => Me(t.__parseExpression(e))
1356
1357
  };
1357
1358
  if (Array.isArray(e) && e.length > 0) {
1358
1359
  const i = ds(e), o = (c, f) => !c || !r ? {} : r?.id && Object.keys(c).length ? f ? {
@@ -1364,7 +1365,7 @@ function ps(n, e, t, s, r) {
1364
1365
  (c, [f, { nodes: a, params: l, scope: u }]) => (c[f] = (p) => {
1365
1366
  const d = l.length ? at(p ?? {}, l) : o(p, u);
1366
1367
  return a.map(
1367
- (h, m) => T(
1368
+ (h, m) => M(
1368
1369
  h,
1369
1370
  t.__clone(d),
1370
1371
  n,
@@ -1476,7 +1477,7 @@ function Js(n) {
1476
1477
  menuPathPrefix: e = "",
1477
1478
  pageRouteName: t = "page",
1478
1479
  disableMenusFilter: s = !1
1479
- } = n || {}, r = Ke(), i = Oe(), o = Mt(), c = ue(!1), f = ue(!1), a = r.project, l = (d, h) => {
1480
+ } = n || {}, r = Ke(), i = Oe(), o = xt(), c = ue(!1), f = ue(!1), a = r.project, l = (d, h) => {
1480
1481
  c.value = !d?.mask, f.value = h?.pure ?? !!d?.pure;
1481
1482
  };
1482
1483
  ut(() => {
@@ -1717,7 +1718,7 @@ class js extends Xe {
1717
1718
  try {
1718
1719
  s = await e.apply(e, t);
1719
1720
  } catch (i) {
1720
- M.warn("模拟数据模版异常", i);
1721
+ x.warn("模拟数据模版异常", i);
1721
1722
  }
1722
1723
  return N()?.mock(s);
1723
1724
  };
@@ -1977,13 +1978,13 @@ class js extends Xe {
1977
1978
  async getRenderComponent(e, t) {
1978
1979
  const s = this.getFile(e);
1979
1980
  if (!s)
1980
- return M.warn(`Can not find file: ${e}`), null;
1981
+ return x.warn(`Can not find file: ${e}`), null;
1981
1982
  if (t && t(s), this.mode === y.Raw) {
1982
1983
  const { vtjRawDir: i = ".vtj/vue" } = this.options, o = `${i}/${e}.vue`, c = this.modules[o] || this.modules[`/src/pages/${e}.vue`];
1983
1984
  return c ? (await c())?.default : this.nodeEnv === "development" && this.adapter.startupComponent || null;
1984
1985
  }
1985
1986
  const r = await this.getDsl(s.id);
1986
- return r ? this.createDslRenderer(r).renderer : (M.warn(`Can not find dsl: ${e}`), null);
1987
+ return r ? this.createDslRenderer(r).renderer : (x.warn(`Can not find dsl: ${e}`), null);
1987
1988
  }
1988
1989
  /**
1989
1990
  * 定义基于URL的异步组件
@@ -2061,7 +2062,7 @@ function Ke(n = {}) {
2061
2062
  }
2062
2063
  async function zs(n, e = "") {
2063
2064
  const { name: t, urls: s = [] } = n || {}, r = s.map((c) => e + c), { css: i, js: o } = vt(r);
2064
- if (i.length && xe(i), o.length)
2065
+ if (i.length && Te(i), o.length)
2065
2066
  return await De(o, t).catch(
2066
2067
  () => {
2067
2068
  }
@@ -2385,7 +2386,7 @@ class Qs extends ve {
2385
2386
  }
2386
2387
  }
2387
2388
  export {
2388
- xs as ACCESS,
2389
+ Ts as ACCESS,
2389
2390
  He as ACCESS_KEY,
2390
2391
  _e as Access,
2391
2392
  dt as BUILD_IN_TAGS,
@@ -2396,15 +2397,15 @@ export {
2396
2397
  y as ContextMode,
2397
2398
  pt as DATA_TYPES,
2398
2399
  J as HOMEPAGE_ROUTE_NAME,
2399
- Me as HTML_TAGS,
2400
+ xe as HTML_TAGS,
2400
2401
  Ls as JSCodeToString,
2401
- Ms as LIFE_CYCLES_LIST,
2402
+ xs as LIFE_CYCLES_LIST,
2402
2403
  Qs as LocalService,
2403
2404
  Ps as MemoryService,
2404
2405
  bs as NodeEnv,
2405
2406
  k as PAGE_ROUTE_NAME,
2406
2407
  js as Provider,
2407
- Ts as REMOTE,
2408
+ Ms as REMOTE,
2408
2409
  Vs as StorageService,
2409
2410
  H as VTJ_RENDERER_VERSION,
2410
2411
  ks as adoptStylesToInline,
@@ -2420,11 +2421,11 @@ export {
2420
2421
  pe as createLoader,
2421
2422
  Ws as createMemoryService,
2422
2423
  V as createMenus,
2423
- xt as createMetaApi,
2424
+ Tt as createMetaApi,
2424
2425
  kt as createMock,
2425
2426
  Ks as createProvider,
2426
2427
  fe as createRenderer,
2427
- Tt as createSchemaApi,
2428
+ Mt as createSchemaApi,
2428
2429
  Dt as createSchemaApis,
2429
2430
  Gs as createServiceRequest,
2430
2431
  Xt as defaultLoader,
@@ -2446,15 +2447,15 @@ export {
2446
2447
  Rt as isNativeTag,
2447
2448
  bt as isVuePlugin,
2448
2449
  Et as loadCss,
2449
- xe as loadCssUrl,
2450
+ Te as loadCssUrl,
2450
2451
  zs as loadEnhance,
2451
2452
  De as loadScriptUrl,
2452
2453
  Ue as menusFilter,
2453
2454
  Nt as mockApi,
2454
2455
  Ht as mockApis,
2455
2456
  ke as mockCleanup,
2456
- x as nodeCache,
2457
- T as nodeRender,
2457
+ T as nodeCache,
2458
+ M as nodeRender,
2458
2459
  gt as parseDeps,
2459
2460
  L as parseExpression,
2460
2461
  R as parseFunction,
@@ -2463,8 +2464,8 @@ export {
2463
2464
  mt as removeProdFlag,
2464
2465
  St as rpxToPx,
2465
2466
  Ns as setupPageSetting,
2466
- Te as toString,
2467
- Mt as useAccess,
2467
+ Me as toString,
2468
+ xt as useAccess,
2468
2469
  Js as useMask,
2469
2470
  Ke as useProvider
2470
2471
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/renderer",
3
3
  "private": false,
4
- "version": "0.17.5",
4
+ "version": "0.17.6",
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.17.5",
25
- "@vtj/utils": "~0.17.5"
24
+ "@vtj/utils": "~0.17.6",
25
+ "@vtj/core": "~0.17.6"
26
26
  },
27
27
  "devDependencies": {
28
28
  "vue": "~3.5.5",
29
29
  "vue-router": "~4.6.0",
30
- "@vtj/cli": "~0.12.19",
31
- "@vtj/ui": "~0.17.5",
32
- "@vtj/icons": "~0.17.5"
30
+ "@vtj/cli": "~0.12.20",
31
+ "@vtj/ui": "~0.17.6",
32
+ "@vtj/icons": "~0.17.6"
33
33
  },
34
34
  "exports": {
35
35
  ".": {
@@ -1,5 +1,5 @@
1
1
  import { MaybeRef, Ref } from 'vue';
2
- import { IRequestSettings, IStaticRequest, Jsonp } from '@vtj/utils';
2
+ import { IRequestSettings, IStaticRequest, Jsonp, AxiosAdapter } from '@vtj/utils';
3
3
  import { Access, AccessOptions } from '../plugins';
4
4
  export type UseTitle = (newTitle?: MaybeRef<string | null | undefined>, options?: Record<string, any>) => Ref<string | null | undefined>;
5
5
  export interface CreateAdapterOptions {
@@ -10,6 +10,7 @@ export interface CreateAdapterOptions {
10
10
  access?: Partial<AccessOptions>;
11
11
  useTitle?: UseTitle;
12
12
  alert?: (msg: string, opt?: any) => any;
13
+ axiosAdapter?: AxiosAdapter;
13
14
  }
14
15
  export interface ProvideAdapter {
15
16
  request: IStaticRequest;
@@ -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.17.4
5
+ * @version 0.17.5
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.17.4";
8
+ export declare const version = "0.17.5";