@vtj/renderer 0.16.16 → 0.16.17

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/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  VTJ 是一款以AI驱动的Vue3前端低代码开发工具。内置低代码引擎、渲染器和代码生成器,支持Vue源码与低代码DSL双向转换,面向前端开发者,开箱即用。 无缝嵌入本地开发工程,不改变前端开发流程和编码习惯。
13
13
 
14
14
  - **官方文档**:[https://vtj.pro](https://vtj.pro)
15
- - **在线应用开发平台**:[https://lcdp.vtj.pro](https://lcdp.vtj.pro)
15
+ - **在线应用开发平台**:[https://app.vtj.pro](https://app.vtj.pro)
16
16
 
17
17
  ## 特性
18
18
 
@@ -32,7 +32,7 @@ VTJ 是一款以AI驱动的Vue3前端低代码开发工具。内置低代码引
32
32
 
33
33
  ### 在线体验
34
34
 
35
- - [https://lcdp.vtj.pro](https://lcdp.vtj.pro)
35
+ - [https://app.vtj.pro](https://app.vtj.pro)
36
36
 
37
37
  访问Vtj专属低代码开发平台,创建应用可以体验设计器和出码功能
38
38
 
package/dist/index.cjs CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@vtj/core"),f=require("@vtj/utils"),b=require("vue"),ve=require("vue-router");function tt(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const z=tt(b);/**!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@vtj/core"),f=require("@vtj/utils"),b=require("vue"),ye=require("vue-router");function tt(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const z=tt(b);/**!
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/renderer
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.16.16
5
+ * @version 0.16.17
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const F="0.16.16";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const se=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],st=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],_e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Se={String,Number,Boolean,Array,Object,Function,Date},k="VtjPage",N="VtjHomepage",oe="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot,svg".split(","),we="component,slot".split(","),nt=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),rt={auth:["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o","/","a","u","t","h",".","h","t","m","l"].join(""),storageKey:["R","R","O","_","I","D","E","_","A","C","C","E","S","S","_","S","T","O","R","A","G","E","_","_"].join(""),privateKey:"MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd"};function H(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function q(n){return/\.js$/.test(n)}function Ee(n){return/\.json$/.test(n)}function ot(n){return n.map(e=>`<script src="${f.url.append(e,{v:F})}"><\/script>`).join("")}function it(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:F})}" />`).join("")}function $e(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function be(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],l={},c={},u=[],p={};return s.forEach(({urls:d,assetsUrl:h,library:g,assetsLibrary:m,localeLibrary:y})=>{d?.forEach(v=>{q(v)&&r.push($e(v,t)),B(v)&&o.push(v)}),g&&(i.push(g),l[g]=H(d||[],e),y&&(c[g]=y)),h&&a.push(h),m&&u.push(m),g&&m&&(p[m]=g)}),{scripts:H(r,e),css:H(o,e),materials:H(a,e),libraryExports:i,materialExports:f.dedupArray(u),materialMapLibrary:p,libraryMap:l,libraryLocaleMap:c}}function je(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Re(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>q(s));return{css:e,js:t}}function Ce(n,e){const t=c=>{const u=[];let p=0;for(;p<c.length;){if(/\s/.test(c[p])){p++;continue}if(c.substring(p,p+2)==="/*"){const v=c.indexOf("*/",p+2);if(v!==-1){p=v+2;continue}}if(c[p]==="@"){const v=p;for(;p<c.length&&c[p]!=="{"&&c[p]!==";";)p++;const w=c.substring(v,p).trim(),_=w.includes("@keyframes");if(c[p]===";")u.push({type:"simple-at-rule",content:c.substring(v,p+1)}),p++;else if(c[p]==="{"){const E=p+1;let I=1;for(p++;p<c.length&&I>0;)c[p]==="{"?I++:c[p]==="}"&&I--,p++;const Y=c.substring(v,p),A=c.substring(E,p-1);u.push({type:_?"keyframes":"at-rule",rule:w,content:Y,inner:A})}continue}const d=p;for(;p<c.length&&c[p]!=="{";)p++;if(p>=c.length)break;const h=c.substring(d,p).trim();if(!h){p++;continue}const g=p+1;let m=1;for(p++;p<c.length&&m>0;)c[p]==="{"?m++:c[p]==="}"&&m--,p++;const y=c.substring(g,p-1);u.push({type:"rule",selector:h,content:y.trim()})}return u},s=c=>{const u=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(u)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(u,p,d)=>{const h=p.trim(),g=d.trim();return h?`${h}[${e}] ${g}`:g}),o=c=>{const u=c.trim();if(!u||u.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(u)||s(u))return u;const p=u.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(p){const[,d,h=""]=p,g=d.trim();return g?`${g}[${e}]${h}`:u}return`${u}[${e}]`},a=c=>r(c).split(",").map(p=>o(p)).filter(p=>p.trim()).join(", "),i=c=>c.map(u=>{switch(u.type){case"simple-at-rule":return u.content;case"keyframes":return u.content;case"at-rule":try{const d=t(u.inner),h=i(d);return`${u.rule} { ${h} }`}catch{return u.content}case"rule":if(!u.selector||!u.content)return"";const p=a(u.selector);return p.trim()?`${p} { ${u.content} }`:"";default:return""}}).filter(u=>u.trim()).join(" "),l=c=>c.replace(/\s*{\s*/g," { ").replace(/\s*}\s*/g," } ").replace(/\s*;\s*/g,"; ").replace(/\s*,\s*/g,", ").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").replace(/\s*}\s*}/g," } }").trim();try{const c=n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g,"").replace(/^\s+|\s+$/gm,"").replace(/\n\s*\n/g,`
7
+ */const F="0.16.17";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const se=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],st=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],_e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Se={String,Number,Boolean,Array,Object,Function,Date},k="VtjPage",N="VtjHomepage",oe="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot,svg".split(","),we="component,slot".split(","),nt=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),rt={auth:["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o","/","a","u","t","h",".","h","t","m","l"].join(""),storageKey:["R","R","O","_","I","D","E","_","A","C","C","E","S","S","_","S","T","O","R","A","G","E","_","_"].join(""),privateKey:"MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd"};function H(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function q(n){return/\.js$/.test(n)}function Ee(n){return/\.json$/.test(n)}function ot(n){return n.map(e=>`<script src="${f.url.append(e,{v:F})}"><\/script>`).join("")}function it(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:F})}" />`).join("")}function $e(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function be(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],l={},c={},u=[],p={};return s.forEach(({urls:d,assetsUrl:h,library:g,assetsLibrary:m,localeLibrary:v})=>{d?.forEach(y=>{q(y)&&r.push($e(y,t)),B(y)&&o.push(y)}),g&&(i.push(g),l[g]=H(d||[],e),v&&(c[g]=v)),h&&a.push(h),m&&u.push(m),g&&m&&(p[m]=g)}),{scripts:H(r,e),css:H(o,e),materials:H(a,e),libraryExports:i,materialExports:f.dedupArray(u),materialMapLibrary:p,libraryMap:l,libraryLocaleMap:c}}function je(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Re(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>q(s));return{css:e,js:t}}function Ce(n,e){const t=c=>{const u=[];let p=0;for(;p<c.length;){if(/\s/.test(c[p])){p++;continue}if(c.substring(p,p+2)==="/*"){const y=c.indexOf("*/",p+2);if(y!==-1){p=y+2;continue}}if(c[p]==="@"){const y=p;for(;p<c.length&&c[p]!=="{"&&c[p]!==";";)p++;const w=c.substring(y,p).trim(),_=w.includes("@keyframes");if(c[p]===";")u.push({type:"simple-at-rule",content:c.substring(y,p+1)}),p++;else if(c[p]==="{"){const E=p+1;let I=1;for(p++;p<c.length&&I>0;)c[p]==="{"?I++:c[p]==="}"&&I--,p++;const Y=c.substring(y,p),A=c.substring(E,p-1);u.push({type:_?"keyframes":"at-rule",rule:w,content:Y,inner:A})}continue}const d=p;for(;p<c.length&&c[p]!=="{";)p++;if(p>=c.length)break;const h=c.substring(d,p).trim();if(!h){p++;continue}const g=p+1;let m=1;for(p++;p<c.length&&m>0;)c[p]==="{"?m++:c[p]==="}"&&m--,p++;const v=c.substring(g,p-1);u.push({type:"rule",selector:h,content:v.trim()})}return u},s=c=>{const u=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(u)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(u,p,d)=>{const h=p.trim(),g=d.trim();return h?`${h}[${e}] ${g}`:g}),o=c=>{const u=c.trim();if(!u||u.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(u)||s(u))return u;const p=u.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(p){const[,d,h=""]=p,g=d.trim();return g?`${g}[${e}]${h}`:u}return`${u}[${e}]`},a=c=>r(c).split(",").map(p=>o(p)).filter(p=>p.trim()).join(", "),i=c=>c.map(u=>{switch(u.type){case"simple-at-rule":return u.content;case"keyframes":return u.content;case"at-rule":try{const d=t(u.inner),h=i(d);return`${u.rule} { ${h} }`}catch{return u.content}case"rule":if(!u.selector||!u.content)return"";const p=a(u.selector);return p.trim()?`${p} { ${u.content} }`:"";default:return""}}).filter(u=>u.trim()).join(" "),l=c=>c.replace(/\s*{\s*/g," { ").replace(/\s*}\s*/g," } ").replace(/\s*;\s*/g,"; ").replace(/\s*,\s*/g,", ").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").replace(/\s*}\s*}/g," } }").trim();try{const c=n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g,"").replace(/^\s+|\s+$/gm,"").replace(/\n\s*\n/g,`
8
8
  `),u=t(c),p=i(u);return l(p)}catch(c){return console.error("CSS scoping failed:",c),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,u=>u).replace(/([^{}@]+)(?=\s*{)/g,u=>{const p=u.trim();return!p||p.startsWith("@")||p.includes(`[${e}]`)||s(p)?u:`${p}[${e}]`})}}const at=750;function Pe(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||at;return e*s/r}function Ae(n,e){let t=!1,s=!1,r=!1,o="";for(let a=0;a<e.length;a++){const i=e[a];if(i==="'"&&!s&&!r?t=!t:i==='"'&&!t&&!r?s=!s:e.substr(a,4).toLowerCase()==="url("&&!t&&!s?r=!0:i===")"&&r&&(r=!1),!t&&!s&&!r){const l=e.substr(a).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(l){const c=l[1],u=parseFloat(c),d=`${Pe(n,u).toFixed(6).replace(/\.?0+$/,"")}px`;o+=d,a+=l[0].length-1;continue}}o+=i}return o}function ie(n){return f.isString(n)?n:JSON.stringify(n)}function V(n,e,t,s=!1){const r=n.CSSStyleSheet,o=s?`data-v-${e}`:e,a=n.__uniConfig?Ae(n,t):t,i=s?Ce(a,o):a,l=!!n.__uniConfig;if(r.prototype.replaceSync&&!l){const c=new r;c.id=e,c.replaceSync(i);const u=n.document,p=u.adoptedStyleSheets,d=Array.from(p).filter(h=>h.id!==e);u.adoptedStyleSheets=[...d,c]}else{const c=n.document;let u=c.getElementById(e);u?u.innerHTML=i:(u=c.createElement("style"),u.id=e,u.innerHTML=i,c.head.appendChild(u))}}function ct(n){const e=n.adoptedStyleSheets||[];let t="";if(e.forEach(s=>{try{for(const r of s.cssRules)t+=r.cssText+`
9
9
  `}catch(r){console.error("Failed to read cssRules from adopted stylesheet:",r)}}),t){const s=n.createElement("style");s.textContent=t,n.head.appendChild(s)}}async function Ie(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&V(window,n,t)}function ae(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const a=t.createElement("link");a.rel="stylesheet",a.id=r,a.href=r,s.appendChild(a)}}async function ce(n,e,t=window){const s=t.document,r=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const l of n){const c=s.createElement("script");c.src=l,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=u=>{i(u)},r.appendChild(c)}})}function Te(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function Me(n){return we.includes(n)}function Oe(n){return oe.includes(n)}function D(n=window){const e=window?.Mock;if(e)return e;const t=n?.Mock;if(t&&window)return window.Mock=t,t}function lt(n,e,t){Object.assign(e.meta,t.meta);const s=n?._container;t?.type==="page"&&s.classList.add("is-page"),t?.pure&&s.classList.add("is-pure")}function x(n,e,t=!1,s=!1,r=!1){try{const o=['"use strict";',"var __self = arguments[0];"];o.push("return ");let a=(n.value||"").trim();r||(a=a.replace(/this(\W|$)/g,(l,c)=>`__self${c}`)),a=o.join(`
10
10
  `)+a;const i=r?`
11
11
  ${a}
12
- `:`with(${t?"{}":"$scope || {}"}) { ${a} }`;return new Function("$scope",i)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function C(n,e,t=!1,s=!1,r=!1){const o=x(n,e,t,s,r);if(typeof o!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return o}function R(n){return n&&n.type==="JSExpression"}function j(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Fe(n){return R(n)||j(n)}function ut(n){return Fe(n)?n.value:JSON.stringify(n)}const pt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},le=Symbol("access");class W{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},pt,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:r}=e;this.mode=t,s&&this.mode!==S.Design&&this.setGuard(s),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:s,session:r,authKey:o}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:t}),s&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):f.toArray(e).every(o=>s[o]||s[t+"."+o])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(o=>s[o]||s[t+"."+o])}install(e){e.config.globalProperties.$access=this,e.provide(le,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===k){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function ke(){return b.inject(le,null)}function ft(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:a,alert:i}=n;let l=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:u=>u.data?.code===0||!!u.data?.success,failMessage:!0,showError:u=>{e&&e(u||"未知错误")},showLoading:()=>{l&&l.close(),t&&(l=t())},hideLoading:()=>{l&&(l.close(),l=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:a,alert:i,startupComponent:r,access:o?new W({alert:i,...o}):void 0}}function dt(n={}){return new W(n)}function De(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?x(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(a,i)=>(delete o.data,s.send(f.merge(o,i||{},{data:a})))}}function xe(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,a)}}function He(n=[],e=[],t){const s={};for(const r of n){const o=De(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=xe(r,t);return s}async function Le(n=[],e=window){const t=D(e);t&&(ue(e),n.forEach(s=>Ue(t,s)))}function Ne(n,e=window){const t=j(n.mockTemplate)&&n.mockTemplate.value?C(n.mockTemplate,{},!0):void 0,s=D(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return s?.mock(o)}}function Ue(n,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s)try{const r=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${r}(.*)`),a=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),i=x(s,{},!0);n.mock(o,l=>{const c=f.url.parse(l.url)||{},u=l.body instanceof FormData?f.formDataToJson(l.body):l.body,p=f.isUrl(l.url)?new URL(l.url).pathname:l.url.split("?")[0],d=a(p)?.params;Object.assign(l,{data:u,params:d,query:c});try{return n.mock(i(l))}catch(h){return console.warn("[mockApi]",o,l,h),null}})}catch(r){console.warn("mockApi",r)}}function ue(n=window){const e=D(n);e&&(e._mocked={})}class Be{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=z){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&se.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){se.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return C({type:s,value:r},this)}else return C(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return x({type:s,value:r},this)}else return x(e,this)}__ref(e=null,t){if(this.__mode!==S.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await f.delay(0);let r=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,S.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,s)),typeof t=="function"?t(s):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,s)),s}}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function K(n){const{Vue:e=z,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:s,$libs:r,$apis:o},c=new Be({mode:t,dsl:i.value,attrs:l}),u=e.defineComponent({name:i.value.name,__scopeId:i.value.id?`data-v-${i.value.id}`:void 0,props:{...mt(i.value.props??[],c)},async setup(p){c.$props=p,c.props=p,i.value.id&&V(n.window||window,i.value.id,i.value.css||"",!0),c.state=gt(e,i.value.state??{},c);const d=yt(e,i.value.computed??{},c),h=vt(i.value.methods??{},c),g=_t(e,i.value.inject,c);for(const[v,w]of Object.entries(g||{}))g[v]=e.inject(v,w);const m=qe(i.value.dataSources||{},c),y={...g,...d,...h,...m};return c.setup(y,e),St(e,i.value.watch??[],c),{vtj:c,state:c.state,...d,...h}},emits:ht(i.value.emits),expose:["vtj",...i.value.expose||[]],render(){if(!i.value.nodes)return null;const p=i.value.nodes||[];if(p.length===1)return O(p[0],c,e,a,p);{const d=p.map(h=>O(h,c,e,a,p));return e.createVNode("div",{},d)}},...wt(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(u),context:c}}function ht(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function mt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>Se[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:R(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,r)=>(s[r.name]={type:t(r.type),required:r.required,default:r.default},s),{})}function gt(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return R(o)?o=t.__parseExpression(o):j(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function yt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function vt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function _t(n,e=[],t){return e.reduce((s,r)=>{const{name:o,from:a}=r||{};r.default;const i=R(a)?t.__parseExpression(a)||o:a??o,l=R(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(i,l),s},{})}function qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ne(r);else if(r.ref){const o=e.$apis[r.ref],a=j(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l}}return t},{})}function St(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function wt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const o=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(o)&&(await f.delay(0),await o())},t},{})}const Je=new f.Queue;let Z=[],M={},L={};const Ke=n=>n;async function pe(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>q(i));if(r.length===0||!s)return null;const o=t.filter(i=>B(i));return o.length&&ae(o,e),await ce(r,s,e).catch(i=>(console.warn("loadScriptUrl error",r,s,i),null))}function G(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(Z.forEach(r=>{delete s.window[r]}),Z=[]),(r,o,a=z)=>{if(!o||typeof o=="string")return r;let i="";if(o.type==="Schema"&&o.id)return i=o.id,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.id]||await Je.add(o.id,()=>e(o.id));return l&&(l.name=r,M[o.id]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return i=o.url,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.url]||await t(o.url);return l&&(l.name=r,M[o.url]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="Plugin"){let l=o.library?M[o.library]:null;return l||(o.library&&Z.push(o.library),l=M[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const c=await pe(o,s.window);return c||(console.warn("getPlugin result is null",o),null)}),l)}return r}}function Et(){M={},L={},Je.clearAllCache()}function O(n,e,t=z,s=Ke,r=[],o=!1){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:i=null,directives:l=[]}=n,{vIf:c,vElseIf:u,vElse:p,vFor:d,vShow:h,vModels:g,vBind:m,vHtml:y,others:v}=Ge(l);if(!o&&(u||p))return null;if(c&&!bt(c,e))return At(n,e,t,s,r);const w=(_,E=0)=>{const I=_.$components,Y=(()=>{if(n.name==="component")return jt(_,n.props?.is);if(n.name==="slot")return n.name;const P=s(n.name,n.from,t);return f.isString(P)?Me(P)||Oe(P)?P:I[P]??a?.app?.component(P)??P:P})(),A=Rt(i,n.props??{},_),Ye=Pt(t,n.events??{},_);if(n.name==="slot")return It(t,n,A,_,s);m&&Object.assign(A,_.__parseExpression(m.value)),h&&(A.style=Object.assign(A.style??{},Mt(h,_))),y&&Object.assign(A,Ot(y,_)),g.forEach(P=>{oe.includes(n.name)?Object.assign(A,Ft(P,_)):Object.assign(A,kt(t,P,_))});const Xe=Dt(t,n.children??[],_,s,n),ge=_?.__id?`data-v-${_.__id}`:void 0,Ze=ge?{[ge]:""}:{},et=_.__mode===S.Design?{"data-vtj":i}:{};let X=t.createVNode(Y,{key:`${i}_${E}`,...Ze,...et,...A,...Ye},Xe);const ye=a?$t(a,v,_):[];return ye.length&&(X=t.withDirectives(X,ye)),X};return d?Lt(d,w,e):w(e)}function $t(n,e,t){const s=n.app;return e.map(r=>{const o=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!o)return null;const a=[o];return r.value&&a.push(t.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function Ge(n=[]){const e=n.find(u=>f.camelCase(u.name)==="vIf"),t=n.find(u=>f.camelCase(u.name)==="vElseIf"),s=n.find(u=>f.camelCase(u.name)==="vElse"),r=n.find(u=>f.camelCase(u.name)==="vFor"),o=n.find(u=>f.camelCase(u.name)==="vShow"),a=n.find(u=>f.camelCase(u.name)==="vBind"),i=n.find(u=>f.camelCase(u.name)==="vHtml"),l=n.filter(u=>f.camelCase(u.name)==="vModel"),c=n.filter(u=>!_e.includes(f.camelCase(u.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:l,vBind:a,others:c,vHtml:i}}function bt(n,e){return!!e.__parseExpression(n.value)}function jt(n,e){return e?R(e)?n.__parseExpression(e):e:"div"}function Rt(n,e,t){const s=ne(e,t);return s.ref=t.__ref(n,s.ref),s}function ne(n,e){return R(n)?e.__parseExpression(n):j(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ne(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ne(r,e),t},{}):n}function Ct(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function Pt(n,e,t){const s=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=fe(i.modifiers),c=l.find(d=>s.includes(d)),u="on"+f.upperFirst(a)+(c&&r[c]||""),p=t.__parseFunction(i.handler);return p&&(o[u]=n.withModifiers(l.includes("enter")?Ct(p,"enter"):p,l)),o},{})}function At(n,e,t,s,r=[]){let o=r.findIndex(a=>a.id===n.id);for(let a=++o;a<r.length;a++){const{directives:i=[]}=r[a],{vElseIf:l,vElse:c}=Ge(i);if(l){if(e.__parseExpression(l.value))return O(r[a],e,t,s,r,!0);continue}if(c)return O(r[a],e,t,s,r,!0)}return null}function fe(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function It(n,e,t,s,r){const{children:o}=e,a=Tt(e,s),i=s.$slots?.[a.name];return i?i(t):o?f.isString(o)?n.createTextVNode(o):R(o)?n.createTextVNode(ie(s.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,s,n,r,o)):null:null}function Tt(n,e){const{props:t}=n,s=t?.name||"default";return{name:R(s)?e.__parseExpression(s):s,params:[]}}function Mt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ot(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Ft(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
12
+ `:`with(${t?"{}":"$scope || {}"}) { ${a} }`;return new Function("$scope",i)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function C(n,e,t=!1,s=!1,r=!1){const o=x(n,e,t,s,r);if(typeof o!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return o}function R(n){return n&&n.type==="JSExpression"}function j(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Fe(n){return R(n)||j(n)}function ut(n){return Fe(n)?n.value:JSON.stringify(n)}const pt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},le=Symbol("access");class W{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},pt,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:r}=e;this.mode=t,s&&this.mode!==S.Design&&this.setGuard(s),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:s,session:r,authKey:o}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:t}),s&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):f.toArray(e).every(o=>s[o]||s[t+"."+o])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(o=>s[o]||s[t+"."+o])}install(e){e.config.globalProperties.$access=this,e.provide(le,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===k){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function ke(){return b.inject(le,null)}function ft(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:a,alert:i}=n;let l=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:u=>u.data?.code===0||!!u.data?.success,failMessage:!0,showError:u=>{e&&e(u||"未知错误")},showLoading:()=>{l&&l.close(),t&&(l=t())},hideLoading:()=>{l&&(l.close(),l=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:a,alert:i,startupComponent:r,access:o?new W({alert:i,...o}):void 0}}function dt(n={}){return new W(n)}function De(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?x(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(a,i)=>(delete o.data,s.send(f.merge(o,i||{},{data:a})))}}function xe(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,a)}}function He(n=[],e=[],t){const s={};for(const r of n){const o=De(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=xe(r,t);return s}async function Le(n=[],e=window){const t=D(e);t&&(ue(e),n.forEach(s=>Ue(t,s)))}function Ne(n,e=window){const t=j(n.mockTemplate)&&n.mockTemplate.value?C(n.mockTemplate,{},!0):void 0,s=D(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return s?.mock(o)}}function Ue(n,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s)try{const r=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${r}(.*)`),a=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),i=x(s,{},!0);n.mock(o,l=>{const c=f.url.parse(l.url)||{},u=l.body instanceof FormData?f.formDataToJson(l.body):l.body,p=f.isUrl(l.url)?new URL(l.url).pathname:l.url.split("?")[0],d=a(p)?.params;Object.assign(l,{data:u,params:d,query:c});try{return n.mock(i(l))}catch(h){return console.warn("[mockApi]",o,l,h),null}})}catch(r){console.warn("mockApi",r)}}function ue(n=window){const e=D(n);e&&(e._mocked={})}class Be{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=z){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&se.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){se.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return C({type:s,value:r},this)}else return C(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return x({type:s,value:r},this)}else return x(e,this)}__ref(e=null,t){if(this.__mode!==S.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await f.delay(0);let r=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,S.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,s)),typeof t=="function"?t(s):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,s)),s}}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function K(n){const{Vue:e=z,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:s,$libs:r,$apis:o},c=new Be({mode:t,dsl:i.value,attrs:l}),u=e.defineComponent({name:i.value.name,__scopeId:i.value.id?`data-v-${i.value.id}`:void 0,props:{...mt(i.value.props??[],c)},async setup(p){c.$props=p,c.props=p,i.value.id&&V(n.window||window,i.value.id,i.value.css||"",!0),c.state=gt(e,i.value.state??{},c);const d=vt(e,i.value.computed??{},c),h=yt(i.value.methods??{},c),g=_t(e,i.value.inject,c);for(const[y,w]of Object.entries(g||{}))g[y]=e.inject(y,w);const m=qe(i.value.dataSources||{},c),v={...g,...d,...h,...m};return c.setup(v,e),St(e,i.value.watch??[],c),{vtj:c,state:c.state,...d,...h}},emits:ht(i.value.emits),expose:["vtj",...i.value.expose||[]],render(){if(!i.value.nodes)return null;const p=i.value.nodes||[];if(p.length===1)return O(p[0],c,e,a,p);{const d=p.map(h=>O(h,c,e,a,p));return e.createVNode("div",{},d)}},...wt(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(u),context:c}}function ht(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function mt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>Se[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:R(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,r)=>(s[r.name]={type:t(r.type),required:r.required,default:r.default},s),{})}function gt(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return R(o)?o=t.__parseExpression(o):j(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function vt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function yt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function _t(n,e=[],t){return e.reduce((s,r)=>{const{name:o,from:a}=r||{};r.default;const i=R(a)?t.__parseExpression(a)||o:a??o,l=R(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(i,l),s},{})}function qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ne(r);else if(r.ref){const o=e.$apis[r.ref],a=j(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l}}return t},{})}function St(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function wt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const o=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(o)&&(await f.delay(0),await o())},t},{})}const Je=new f.Queue;let Z=[],M={},L={};const Ke=n=>n;async function pe(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>q(i));if(r.length===0||!s)return null;const o=t.filter(i=>B(i));return o.length&&ae(o,e),await ce(r,s,e).catch(i=>(console.warn("loadScriptUrl error",r,s,i),null))}function G(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(Z.forEach(r=>{delete s.window[r]}),Z=[]),(r,o,a=z)=>{if(!o||typeof o=="string")return r;let i="";if(o.type==="Schema"&&o.id)return i=o.id,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.id]||await Je.add(o.id,()=>e(o.id));return l&&(l.name=r,M[o.id]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return i=o.url,L[i]||(L[i]=a.defineAsyncComponent(async()=>{const l=M[o.url]||await t(o.url);return l&&(l.name=r,M[o.url]=l),l?K({...s,Vue:a,dsl:f.cloneDeep(l),mode:S.Runtime,loader:G(n)}).renderer:null}));if(o.type==="Plugin"){let l=o.library?M[o.library]:null;return l||(o.library&&Z.push(o.library),l=M[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const c=await pe(o,s.window);return c||(console.warn("getPlugin result is null",o),null)}),l)}return r}}function Et(){M={},L={},Je.clearAllCache()}function O(n,e,t=z,s=Ke,r=[],o=!1){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:i=null,directives:l=[]}=n,{vIf:c,vElseIf:u,vElse:p,vFor:d,vShow:h,vModels:g,vBind:m,vHtml:v,others:y}=Ge(l);if(!o&&(u||p))return null;if(c&&!bt(c,e))return At(n,e,t,s,r);const w=(_,E=0)=>{const I=_.$components,Y=(()=>{if(n.name==="component")return jt(_,n.props?.is);if(n.name==="slot")return n.name;const P=s(n.name,n.from,t);return f.isString(P)?Me(P)||Oe(P)?P:I[P]??a?.app?.component(P)??P:P})(),A=Rt(i,n.props??{},_),Ye=Pt(t,n.events??{},_);if(n.name==="slot")return It(t,n,A,_,s);m&&Object.assign(A,_.__parseExpression(m.value)),h&&(A.style=Object.assign(A.style??{},Mt(h,_))),v&&Object.assign(A,Ot(v,_)),g.forEach(P=>{oe.includes(n.name)?Object.assign(A,Ft(P,_)):Object.assign(A,kt(t,P,_))});const Xe=Dt(t,n.children??[],_,s,n),ge=_?.__id?`data-v-${_.__id}`:void 0,Ze=ge?{[ge]:""}:{},et=_.__mode===S.Design?{"data-vtj":i}:{};let X=t.createVNode(Y,{key:`${i}_${E}`,...Ze,...et,...A,...Ye},Xe);const ve=a?$t(a,y,_):[];return ve.length&&(X=t.withDirectives(X,ve)),X};return d?Lt(d,w,e):w(e)}function $t(n,e,t){const s=n.app;return e.map(r=>{const o=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!o)return null;const a=[o];return r.value&&a.push(t.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function Ge(n=[]){const e=n.find(u=>f.camelCase(u.name)==="vIf"),t=n.find(u=>f.camelCase(u.name)==="vElseIf"),s=n.find(u=>f.camelCase(u.name)==="vElse"),r=n.find(u=>f.camelCase(u.name)==="vFor"),o=n.find(u=>f.camelCase(u.name)==="vShow"),a=n.find(u=>f.camelCase(u.name)==="vBind"),i=n.find(u=>f.camelCase(u.name)==="vHtml"),l=n.filter(u=>f.camelCase(u.name)==="vModel"),c=n.filter(u=>!_e.includes(f.camelCase(u.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:l,vBind:a,others:c,vHtml:i}}function bt(n,e){return!!e.__parseExpression(n.value)}function jt(n,e){return e?R(e)?n.__parseExpression(e):e:"div"}function Rt(n,e,t){const s=ne(e,t);return s.ref=t.__ref(n,s.ref),s}function ne(n,e){return R(n)?e.__parseExpression(n):j(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ne(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ne(r,e),t},{}):n}function Ct(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function Pt(n,e,t){const s=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=fe(i.modifiers),c=l.find(d=>s.includes(d)),u="on"+f.upperFirst(a)+(c&&r[c]||""),p=t.__parseFunction(i.handler);return p&&(o[u]=n.withModifiers(l.includes("enter")?Ct(p,"enter"):p,l)),o},{})}function At(n,e,t,s,r=[]){let o=r.findIndex(a=>a.id===n.id);for(let a=++o;a<r.length;a++){const{directives:i=[]}=r[a],{vElseIf:l,vElse:c}=Ge(i);if(l){if(e.__parseExpression(l.value))return O(r[a],e,t,s,r,!0);continue}if(c)return O(r[a],e,t,s,r,!0)}return null}function fe(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function It(n,e,t,s,r){const{children:o}=e,a=Tt(e,s),i=s.$slots?.[a.name];return i?i(t):o?f.isString(o)?n.createTextVNode(o):R(o)?n.createTextVNode(ie(s.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,s,n,r,o)):null:null}function Tt(n,e){const{props:t}=n,s=t?.name||"default";return{name:R(s)?e.__parseExpression(s):s,params:[]}}function Mt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ot(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Ft(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
13
13
  ${n.value.value} = v?.target.value;
14
14
  }`:"(v) => {}"};return{[R(n.arg)?e.__parseExpression(n.arg):n.arg||"value"]:e.__parseExpression(n.value),onInput:e.__parseFunction(t)}}function kt(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
15
15
  ${e.value.value} = v;
16
- }`:"(v) => {}"},r=t.__parseFunction(s),o=fe(R(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),a=R(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?n.withModifiers(r,o):r}}function Dt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(R(e))return{default:()=>ie(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=xt(e),a=(i,l)=>!i||!r?{}:r?.id&&Object.keys(i).length?l?{[l]:i}:{[`scope_${r.id}`]:i}:l?{[l]:Object.create(null)}:{};return Object.entries(o).reduce((i,[l,{nodes:c,params:u,scope:p}])=>(i[l]=d=>{const h=u.length?f.pick(d??{},u):a(d,p);return c.map(g=>O(g,t.__clone(h),n,s,c))},i),{})}return null}function xt(n){const e={};for(const t of n){const s=Ht(t.slot),r=s.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(s.params),e[r].scope=s.scope||""):e[r]={nodes:[t],params:s.params,scope:s.scope||""}}return e}function Ht(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Lt(n,e,t){const{value:s,iterator:r}=n,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(s)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}),c)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const ee=b.defineComponent({name:"VtjPageContainer",async setup(){const n=me(),e=ve.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,o=b.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:a}=n?.adapter;if(a){const i=e.meta.title||s.title||"VTJ.PRO";a(i)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:o,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?b.h(n,{...e,key:t}):b.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Nt=b.defineComponent({name:"VtjStartupContainer",render(){return b.h("div","page not found!")}});function U(n,e,t=[]){const s=[];for(const r of t){const{id:o,title:a,icon:i,children:l,hidden:c,layout:u}=r;if(u){const p=U(n,e,l||[]);s.push(...p)}else{const p={id:o,title:a,icon:i,hidden:c,url:`${n}/${e}/${o}`,children:l&&l.length?U(n,e,l):void 0};s.push(p)}}return s}function de(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=de(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Ut(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=me(),o=ve.useRoute(),a=ke(),i=b.ref(!1),l=b.ref(!1),c=r.project,u=(h,g)=>{i.value=!h?.mask,l.value=g?.pure??!!h?.pure};b.watchEffect(()=>{const{name:h,params:g,meta:m}=o;if(h===k){const y=r.getPage(g.id);u(y,m)}else if(h===N){const y=r.getHomepage();u(y,m)}else{const y=m.__vtj__;if(y){const v=r.getPage(y);u(v,m)}else i.value=!m.mask,l.value=!!m.pure}});const p=U(e,t,c?.pages),d=c?.config;return{disabled:i,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||c?.description||c?.name||"VTJ App",menus:s?p:de(p,a),pure:l}}function te(n,e){const{id:t,title:s,meta:r}=n,{name:o="page",prefix:a="",component:i,routeMeta:l}=e;return{name:t,path:`${a}${o}/${t}`,component:i,meta:{title:s,...l,...r,__vtj__:t}}}function re(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:o,routeMeta:a,homepage:i}=n,l=[];for(const c of s){const{id:u,title:p,dir:d,layout:h,children:g,meta:m}=c;if(d){const y=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]});l.push(...y)}else if(h){const y=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]}),v={name:`layout_${u}`,path:t,component:()=>o(u),meta:{title:p,...a,...m,__vtj__:u},children:y};l.push(v),l.push(te(c,n))}else if(l.push(te(c,n)),i===u){const y=te(c,n);y.path="",y.name=`home_${u}`,l.push(y)}}return l}function Bt(n={},e){const{css:t,store:s,enhance:r}=n,{window:o,app:a,library:i={},adapter:l,mode:c}=e,{Pinia:u}=i;a.config.globalProperties.$libs=i,V(o,"global-css",t||""),u&&s&&qt(s,a,u),Kt(a,l,n),!l.access&&n.access&&Jt(n.access,a,c,l),Gt(a,n),r&&zt(r,a,i)}function qt(n,e,t){const s=t.createPinia();if(e.use(s),j(n)&&n.value){const r=C(n,{},!1,!1,!0),o=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=o()}}function Jt(n,e,t,s){if(j(n)&&n.value){const r=C(n,{},!1,!1,!0),{alert:o,request:a}=s,i=new W({alert:o,storagePrefix:"__VTJ_APP_",...r(e)}),l=e.config.globalProperties.$router;i.connect({mode:t,router:l,request:a}),e.use(i)}}function Kt(n,e,t){if(!e.request)return;const{axios:s,request:r,response:o}=t;if(s&&j(s)&&s.value){const a=C(s,{},!1,!1,!0);e.request.setConfig(a(n))}if(r&&j(r)&&r.value){const a=C(r,{},!1,!1,!0),i=e.request;i.__unReq&&i.__unReq(),i.__unReq=e.request.useRequest(l=>a(l,n))}if(o&&j(o)&&o.value){const a=C(o,{},!1,!1,!0),i=e.request;i.__unRes&&i.__unRes(),i.__unRes=e.request.useResponse(l=>a(l,n))}}function Gt(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&j(t)&&t.value){const o=C(t,{},!1,!1,!0);r&&r.beforeEach((a,i,l)=>o(a,i,l,n))}if(s&&j(s)&&s.value){const o=C(s,{},!1,!1,!0);r&&r.afterEach((a,i,l)=>o(a,i,l,n))}}function zt(n,e,t={}){j(n)&&n.value&&C(n,{},!1,!1,!0)(e,t)}function Vt(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:o,messages:a=[]}=t,i={};for(let c of a){const u=Object.keys(c).filter(p=>p!=="key");for(const p of u)i[p]||(i[p]={}),i[p][c.key]=c[p]}const l=s.createI18n({legacy:!1,locale:r,fallbackLocale:o,messages:i});n.use(l)}}const he=Symbol("Provider");var ze=(n=>(n.Production="production",n.Development="development",n))(ze||{});class Ve extends T.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:u=null,materialPath:p="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=u,this.materialPath=p,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i);const{access:h,request:g}=this.adapter;h&&h.connect({mode:s,router:u,request:g}),a&&s!==S.Design?this.load(a):this.project=a}mode;globals={};modules={};adapter={request:f.request,jsonp:f.jsonp};apis={};dependencies={};materials={};library={};libraryLocales={};libraryLocaleMap={};service;project=null;components={};nodeEnv="development";env={};router=null;materialPath="./";urlDslCaches={};errorHandler=null;createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(o){f.logger.warn("模拟数据模版异常",o)}return D()?.mock(s)}}async load(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/projects/${e.id}.json`]||this.modules[`/src/${t}/projects/${e.id}.json`];if(this.project=s?await s():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:r=[],meta:o=[],env:a=[]}=this.project,i=window;i&&(i.CKEDITOR_VERSION=void 0),this.initEnv(a),this.mode===S.Raw?await this.loadDependencies(i):await this.loadAssets(i),this.initMock(i),this.apis=He(r,o,this.adapter),ue(i),Le(r,i),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=D(e);t&&t.setup({timeout:"50-500"})}async loadDependencies(e={}){const t=Object.entries(this.dependencies);for(const[s,r]of t)e[s]||(e[s]=this.library[s]=await r())}async loadAssets(e={}){const{dependencies:t=[]}=this.project,{dependencies:s,library:r,components:o,materialPath:a,nodeEnv:i,libraryLocales:l}=this,{libraryExports:c,libraryMap:u,materials:p,materialExports:d,materialMapLibrary:h,libraryLocaleMap:g}=be(t,a,i==="development");Object.assign(this.libraryLocaleMap,g);for(const m of c){const y=s[m],v=e[m];if(v)r[m]=v;else if(y)e[m]=r[m]=await y();else{const _=u[m]||[];for(const E of _)B(E)&&await Ie(E,f.url.append(E,{v:F})),q(E)&&await f.loadScript(f.url.append(E,{v:F}));r[m]=e[m]}const w=g[m];if(w){const _=s[w];l[w]=_?await _():e[w]}}if(i==="development"){for(const y of p)await f.loadScript(f.url.append(y,{v:F}));const m=this.materials||{};for(const y of d){const v=e[h[y]],w=v?.default||v,_=T.BUILT_IN_COMPONENTS[y];if(_)w&&_.forEach(E=>{o[E]=w[E]});else{const E=m[y]?(await m[y]()).default:e[y];E&&w&&(E.components||[]).forEach(I=>{o[I.name]=je(I,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const o=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:a,pageRouteName:i=o,routeMeta:l}=s,c=a?"":"/",u={path:`${c}${i}/:id`,name:k,component:ee},p=this.getHomepage(),d={path:c,name:N,component:p?ee:r.startupComponent||Nt,meta:l};if(e.hasRoute(k)&&e.removeRoute(k),e.hasRoute(N)&&e.removeRoute(N),s.enableStaticRoute){const h=t?.pages||[];re({name:i,prefix:c,pages:h,component:ee,loader:this.getRenderComponent.bind(this),homepage:p?.id}).forEach(m=>{a?e.addRoute(a,m):e.addRoute(m)}),p||(a?e.addRoute(a,d):e.addRoute(d))}else a?(e.addRoute(a,u),e.addRoute(a,d)):(e.addRoute(u),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const o=s?.$options.name,a=typeof t=="string"?t:t?.message||t?.msg||"未知错误",i=`[ ${o} ] ${a} ${r}`;["getComputedStyle","ResizeObserver"].some(c=>i.includes(c))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(i,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,o=e.config.globalProperties.installed||{};for(const[a,i]of Object.entries(this.library))if(!o[a]&&Te(i)){const c={locale:s[t[a]]},u=r[a]||{},p={...c,...u};e.use(i,p),o[a]=!0}e.provide(he,this),e.config.globalProperties.$provider=this,e.config.globalProperties.$request=this.adapter?.request,this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),this.project?.platform!=="uniapp"&&this.mode!==S.Design&&this.initGlobals(this.project?.globals||{},{app:e,window,adapter:this.adapter,library:this.library,mode:this.mode}),this.mode!==S.Design&&this.project?.i18n&&this.initI18n(e,this.library,this.project.i18n),this.options.enhance&&e.use(this.options.enhance,this),this.mode===S.Design&&this.setErrorHandler(e),e.config.globalProperties.installed=o}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(s=>s.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},s=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=s(r,a.children);if(i)return i}}};return s(e,t)||null}getFirstPage(){const{pages:e=[]}=this.project||{};if(!e.length)return null;const t=(s=[])=>{for(const r of s){if(r.type==="page"&&!r.dir&&!r.layout)return r;if(r.children&&r.children.length){const o=t(r.children);if(o)return o}}};return t(e)||null}getMenus(e="page",t=""){return U(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):this.getFirstPage()}async getDsl(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/files/${e}.json`]||this.modules[`/src/${t}/files/${e}.json`];return s?await s():this.service.getFile(e,this.project||void 0).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.adapter.request?this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null):null)}createDslRenderer(e,t={}){const{library:s,components:r,mode:o,apis:a}=this,i={mode:o,Vue:s.Vue,components:r,libs:s,apis:a,window,...t},l=G({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return K({...i,dsl:e,loader:l})}async getRenderComponent(e,t){const s=this.getFile(e);if(!s)return f.logger.warn(`Can not find file: ${e}`),null;if(t&&t(s),this.mode===S.Raw){const{vtjRawDir:o=".vtj/vue"}=this.options,a=`${o}/${e}.vue`,i=this.modules[a]||this.modules[`/src/pages/${e}.vue`];return i?(await i())?.default:null}const r=await this.getDsl(s.id);return r?this.createDslRenderer(r).renderer:(f.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return b.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return b.defineAsyncComponent(async()=>await pe(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Bt(e,s)}initI18n(e,t,s){Vt(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function Wt(n){const e=new Ve(n);return{provider:e,onReady:s=>e.ready(s)}}function me(n={}){const e=b.inject(he,null);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=n;t&&s&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==s&&e.adapter.notify&&e.adapter.notify(`[ ${r?.name} ] 组件源码版本与运行时版本不一致,请重新发布组件`,"版本不一致","warning")})()}return e}async function Qt(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(i=>e+i),{css:o,js:a}=Re(r);if(o.length&&ae(o),a.length)return await ce(a,t).catch(()=>{})}const We={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},Yt=(n,e="/__vtj__/api/:type.json")=>(t,s,r)=>n.send({url:e,method:"post",params:{type:t},query:r,data:{type:t,data:s},settings:We}),Xt=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...We,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function Zt(n){return f.createRequest({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:e=>e.data?.code===0,showError:e=>{n&&n(e||"未知错误")}}})}class Q{constructor(e=f.request){this.req=e,this.api=Yt(e),this.uploader=Xt(e)}api;pluginCaches={};uploader;async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return console.log("BaseService.saveMaterials",e,t),!1}async saveFile(e){return console.log("BaseService.saveFile",e),!1}async getFile(e){return console.log("BaseService.getFile",e),{}}async removeFile(e){return console.log("BaseService.removeFile",e),!1}async saveHistory(e){return console.log("BaseService.saveHistory",e),!1}async removeHistory(e){return console.log("BaseService.removeHistory",e),!1}async getHistory(e){return console.log("BaseService.getHistory",e),{}}async getHistoryItem(e,t){return console.log("BaseService.getHistoryItem",e,t),{}}async saveHistoryItem(e,t){return console.log("BaseService.saveHistoryItem",e,t),!1}async removeHistoryItem(e,t){return console.log("BaseService.removeHistoryItem",e,t),!1}async publish(e){return!!await this.api("publish",e).catch(()=>!1)}async publishFile(e,t){return!!await this.api("publishFile",{project:e,file:t}).catch(()=>!1)}async genVueContent(e,t){return await this.api("genVueContent",{project:e,dsl:t}).catch(()=>"")}async parseVue(e,t){return await this.api("parseVue",{project:e,...t})}async createRawPage(e){return await this.api("createRawPage",e).catch(()=>"")}async removeRawPage(e){return await this.api("removeRawPage",e).catch(()=>"")}async uploadStaticFile(e,t){return await this.uploader(e,t).catch(()=>null)}async getStaticFiles(e){return await this.api("getStaticFiles",e).catch(()=>[])}async removeStaticFile(e,t){return await this.api("removeStaticFile",{name:e,projectId:t}).catch(()=>"")}async clearStaticFiles(e){return await this.api("clearStaticFiles",e).catch(()=>"")}async getPluginMaterial(e){const{urls:t=[]}=e,s=t.filter(o=>Ee(o))[0];if(!s)return null;const r=this.pluginCaches[s];return r||(this.pluginCaches[s]=f.request.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const $=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class es extends Q{init(e){const t=new T.ProjectModel(e),s=$.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return $.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return $.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return $.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return $.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=$.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return $.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return $.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=$.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),$.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=$.get(`history_${e}`),s=new T.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=$.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return $.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{$.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class Qe extends Q{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new T.ProjectModel(e),s=this.projects[t.id]||{},r=Object.assign(t.toDsl(),s);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new T.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,r=this.historyItems[s]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const r=`${e}_${s}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let J=null;function ts(){return J||(J=new Qe,J)}class ss extends Q{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:f.mapToObject(t)}).catch(()=>!1)}async saveFile(e){return!!await this.api("saveFile",e).catch(()=>!1)}async getFile(e){const t=this.getFileCaches[e];return t||(this.getFileCaches[e]=this.api("getFile",e).catch(()=>null)).finally(()=>{delete this.getFileCaches[e]})}async removeFile(e){return!!await this.api("removeFile",e).catch(()=>!1)}async saveHistory(e){return!!await this.api("saveHistory",e).catch(()=>!1)}async removeHistory(e){return!!await this.api("removeHistory",e).catch(()=>!1)}async getHistory(e){return await this.api("getHistory",e).catch(()=>null)||{}}async getHistoryItem(e,t){return await this.api("getHistoryItem",{fId:e,id:t}).catch(()=>null)||{}}async saveHistoryItem(e,t){return!!await this.api("saveHistoryItem",{fId:e,item:t}).catch(()=>!1)}async removeHistoryItem(e,t){return!!await this.api("removeHistoryItem",{fId:e,ids:t}).catch(()=>!1)}}exports.ACCESS=rt;exports.ACCESS_KEY=le;exports.Access=W;exports.BUILD_IN_TAGS=we;exports.BUILT_IN_DIRECTIVES=_e;exports.BaseService=Q;exports.CONTEXT_HOST=se;exports.Context=Be;exports.ContextMode=S;exports.DATA_TYPES=Se;exports.HOMEPAGE_ROUTE_NAME=N;exports.HTML_TAGS=oe;exports.JSCodeToString=ut;exports.LIFE_CYCLES_LIST=st;exports.LocalService=ss;exports.MemoryService=Qe;exports.NodeEnv=ze;exports.PAGE_ROUTE_NAME=k;exports.Provider=Ve;exports.REMOTE=nt;exports.StorageService=es;exports.VTJ_RENDERER_VERSION=F;exports.adoptStylesToInline=ct;exports.adoptedStyleSheets=V;exports.clearLoaderCache=Et;exports.compileScopedCSS=Ce;exports.convertCssRpx=Ae;exports.createAccess=dt;exports.createAdapter=ft;exports.createAssetScripts=ot;exports.createAssetsCss=it;exports.createDataSources=qe;exports.createLoader=G;exports.createMemoryService=ts;exports.createMenus=U;exports.createMetaApi=xe;exports.createMock=Ne;exports.createProvider=Wt;exports.createRenderer=K;exports.createSchemaApi=De;exports.createSchemaApis=He;exports.createServiceRequest=Zt;exports.defaultLoader=Ke;exports.fillBasePath=H;exports.getMock=D;exports.getModifiers=fe;exports.getPlugin=pe;exports.getRawComponent=je;exports.isBuiltInTag=Me;exports.isCSSUrl=B;exports.isJSCode=Fe;exports.isJSExpression=R;exports.isJSFunction=j;exports.isJSON=Ee;exports.isJSUrl=q;exports.isNativeTag=Oe;exports.isVuePlugin=Te;exports.loadCss=Ie;exports.loadCssUrl=ae;exports.loadEnhance=Qt;exports.loadScriptUrl=ce;exports.menusFilter=de;exports.mockApi=Ue;exports.mockApis=Le;exports.mockCleanup=ue;exports.nodeRender=O;exports.parseDeps=be;exports.parseExpression=x;exports.parseFunction=C;exports.parseUrls=Re;exports.providerKey=he;exports.removeProdFlag=$e;exports.rpxToPx=Pe;exports.setupPageSetting=lt;exports.toString=ie;exports.useAccess=ke;exports.useMask=Ut;exports.useProvider=me;
16
+ }`:"(v) => {}"},r=t.__parseFunction(s),o=fe(R(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),a=R(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?n.withModifiers(r,o):r}}function Dt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(R(e))return{default:()=>ie(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=xt(e),a=(i,l)=>!i||!r?{}:r?.id&&Object.keys(i).length?l?{[l]:i}:{[`scope_${r.id}`]:i}:l?{[l]:Object.create(null)}:{};return Object.entries(o).reduce((i,[l,{nodes:c,params:u,scope:p}])=>(i[l]=d=>{const h=u.length?f.pick(d??{},u):a(d,p);return c.map(g=>O(g,t.__clone(h),n,s,c))},i),{})}return null}function xt(n){const e={};for(const t of n){const s=Ht(t.slot),r=s.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(s.params),e[r].scope=s.scope||""):e[r]={nodes:[t],params:s.params,scope:s.scope||""}}return e}function Ht(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Lt(n,e,t){const{value:s,iterator:r}=n,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(s)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}),c)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const ee=b.defineComponent({name:"VtjPageContainer",async setup(){const n=me(),e=ye.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,o=b.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:a}=n?.adapter;if(a){const i=e.meta.title||s.title||"VTJ.PRO";a(i)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:o,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?b.h(n,{...e,key:t}):b.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Nt=b.defineComponent({name:"VtjStartupContainer",render(){return b.h("div","page not found!")}});function U(n,e,t=[]){const s=[];for(const r of t){const{id:o,title:a,icon:i,children:l,hidden:c,layout:u}=r;if(u){const p=U(n,e,l||[]);s.push(...p)}else{const p={id:o,title:a,icon:i,hidden:c,url:`${n}/${e}/${o}`,children:l&&l.length?U(n,e,l):void 0};s.push(p)}}return s}function de(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=de(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Ut(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=me(),o=ye.useRoute(),a=ke(),i=b.ref(!1),l=b.ref(!1),c=r.project,u=(h,g)=>{i.value=!h?.mask,l.value=g?.pure??!!h?.pure};b.watchEffect(()=>{const{name:h,params:g,meta:m}=o;if(h===k){const v=r.getPage(g.id);u(v,m)}else if(h===N){const v=r.getHomepage();u(v,m)}else{const v=m.__vtj__;if(v){const y=r.getPage(v);u(y,m)}else i.value=!m.mask,l.value=!!m.pure}});const p=U(e,t,c?.pages),d=c?.config;return{disabled:i,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||c?.description||c?.name||"VTJ App",menus:s?p:de(p,a),pure:l}}function te(n,e){const{id:t,title:s,meta:r}=n,{name:o="page",prefix:a="",component:i,routeMeta:l}=e;return{name:t,path:`${a}${o}/${t}`,component:i,meta:{title:s,...l,...r,__vtj__:t}}}function re(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:o,routeMeta:a,homepage:i}=n,l=[];for(const c of s){const{id:u,title:p,dir:d,layout:h,children:g,meta:m}=c;if(d){const v=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]});l.push(...v)}else if(h){const v=re({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:g||[]}),y={name:`layout_${u}`,path:t,component:()=>o(u),meta:{title:p,...a,...m,__vtj__:u},children:v};l.push(y),l.push(te(c,n))}else if(l.push(te(c,n)),i===u){const v=te(c,n);v.path="",v.name=`home_${u}`,l.push(v)}}return l}function Bt(n={},e){const{css:t,store:s,enhance:r}=n,{window:o,app:a,library:i={},adapter:l,mode:c}=e,{Pinia:u}=i;a.config.globalProperties.$libs=i,V(o,"global-css",t||""),u&&s&&qt(s,a,u),Kt(a,l,n),!l.access&&n.access&&Jt(n.access,a,c,l),Gt(a,n),r&&zt(r,a,i)}function qt(n,e,t){const s=t.createPinia();if(e.use(s),j(n)&&n.value){const r=C(n,{},!1,!1,!0),o=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=o()}}function Jt(n,e,t,s){if(j(n)&&n.value){const r=C(n,{},!1,!1,!0),{alert:o,request:a}=s,i=new W({alert:o,storagePrefix:"__VTJ_APP_",...r(e)}),l=e.config.globalProperties.$router;i.connect({mode:t,router:l,request:a}),e.use(i)}}function Kt(n,e,t){if(!e.request)return;const{axios:s,request:r,response:o}=t;if(s&&j(s)&&s.value){const a=C(s,{},!1,!1,!0);e.request.setConfig(a(n))}if(r&&j(r)&&r.value){const a=C(r,{},!1,!1,!0),i=e.request;i.__unReq&&i.__unReq(),i.__unReq=e.request.useRequest(l=>a(l,n))}if(o&&j(o)&&o.value){const a=C(o,{},!1,!1,!0),i=e.request;i.__unRes&&i.__unRes(),i.__unRes=e.request.useResponse(l=>a(l,n))}}function Gt(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&j(t)&&t.value){const o=C(t,{},!1,!1,!0);r&&r.beforeEach((a,i,l)=>o(a,i,l,n))}if(s&&j(s)&&s.value){const o=C(s,{},!1,!1,!0);r&&r.afterEach((a,i,l)=>o(a,i,l,n))}}function zt(n,e,t={}){j(n)&&n.value&&C(n,{},!1,!1,!0)(e,t)}function Vt(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:o,messages:a=[]}=t,i={};for(let c of a){const u=Object.keys(c).filter(p=>p!=="key");for(const p of u)i[p]||(i[p]={}),i[p][c.key]=c[p]}const l=s.createI18n({legacy:!1,locale:r,fallbackLocale:o,messages:i});n.use(l)}}const he=Symbol("Provider");var ze=(n=>(n.Production="production",n.Development="development",n))(ze||{});class Ve extends T.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:u=null,materialPath:p="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=u,this.materialPath=p,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i);const{access:h,request:g}=this.adapter;h&&h.connect({mode:s,router:u,request:g}),a&&s!==S.Design?this.load(a):this.project=a}mode;globals={};modules={};adapter={request:f.request,jsonp:f.jsonp};apis={};dependencies={};materials={};library={};libraryLocales={};libraryLocaleMap={};service;project=null;components={};nodeEnv="development";env={};router=null;materialPath="./";urlDslCaches={};errorHandler=null;createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(o){f.logger.warn("模拟数据模版异常",o)}return D()?.mock(s)}}async load(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/projects/${e.id}.json`]||this.modules[`/src/${t}/projects/${e.id}.json`];if(this.project=s?await s():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:r=[],meta:o=[],env:a=[]}=this.project,i=window;i&&(i.CKEDITOR_VERSION=void 0),this.initEnv(a),this.mode===S.Raw?await this.loadDependencies(i):await this.loadAssets(i),this.initMock(i),this.apis=He(r,o,this.adapter),ue(i),Le(r,i),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=D(e);t&&t.setup({timeout:"50-500"})}async loadDependencies(e={}){const t=Object.entries(this.dependencies);for(const[s,r]of t)e[s]||(e[s]=this.library[s]=await r())}async loadAssets(e={}){const{dependencies:t=[]}=this.project,{dependencies:s,library:r,components:o,materialPath:a,nodeEnv:i,libraryLocales:l}=this,{libraryExports:c,libraryMap:u,materials:p,materialExports:d,materialMapLibrary:h,libraryLocaleMap:g}=be(t,a,i==="development");Object.assign(this.libraryLocaleMap,g);for(const m of c){const v=s[m],y=e[m];if(y)r[m]=y;else if(v)e[m]=r[m]=await v();else{const _=u[m]||[];for(const E of _)B(E)&&await Ie(E,f.url.append(E,{v:F})),q(E)&&await f.loadScript(f.url.append(E,{v:F}));r[m]=e[m]}const w=g[m];if(w){const _=s[w];l[w]=_?await _():e[w]}}if(i==="development"){for(const v of p)await f.loadScript(f.url.append(v,{v:F}));const m=this.materials||{};for(const v of d){const y=e[h[v]],w=y?.default||y,_=T.BUILT_IN_COMPONENTS[v];if(_)w&&_.forEach(E=>{o[E]=w[E]});else{const E=m[v]?(await m[v]()).default:e[v];E&&w&&(E.components||[]).forEach(I=>{o[I.name]=je(I,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const o=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:a,pageRouteName:i=o,routeMeta:l}=s,c=a?"":"/",u={path:`${c}${i}/:id`,name:k,component:ee},p=this.getHomepage(),d={path:c,name:N,component:p?ee:r.startupComponent||Nt,meta:l};if(e.hasRoute(k)&&e.removeRoute(k),e.hasRoute(N)&&e.removeRoute(N),s.enableStaticRoute){const h=t?.pages||[];re({name:i,prefix:c,pages:h,component:ee,loader:this.getRenderComponent.bind(this),homepage:p?.id}).forEach(m=>{a?e.addRoute(a,m):e.addRoute(m)}),p||(a?e.addRoute(a,d):e.addRoute(d))}else a?(e.addRoute(a,u),e.addRoute(a,d)):(e.addRoute(u),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const o=s?.$options.name,a=typeof t=="string"?t:t?.message||t?.msg||"未知错误",i=`[ ${o} ] ${a} ${r}`;["getComputedStyle","ResizeObserver"].some(c=>i.includes(c))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(i,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,o=e.config.globalProperties.installed||{};for(const[a,i]of Object.entries(this.library))if(!o[a]&&Te(i)){const c={locale:s[t[a]]},u=r[a]||{},p={...c,...u};e.use(i,p),o[a]=!0}e.provide(he,this),e.config.globalProperties.$provider=this,e.config.globalProperties.$request=this.adapter?.request,this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),this.project?.platform!=="uniapp"&&this.mode!==S.Design&&this.initGlobals(this.project?.globals||{},{app:e,window,adapter:this.adapter,library:this.library,mode:this.mode}),this.mode!==S.Design&&this.project?.i18n&&this.initI18n(e,this.library,this.project.i18n),this.options.enhance&&e.use(this.options.enhance,this),this.mode===S.Design&&this.setErrorHandler(e),e.config.globalProperties.installed=o}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(s=>s.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},s=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=s(r,a.children);if(i)return i}}};return s(e,t)||null}getFirstPage(){const{pages:e=[]}=this.project||{};if(!e.length)return null;const t=(s=[])=>{for(const r of s){if(r.type==="page"&&!r.dir&&!r.layout)return r;if(r.children&&r.children.length){const o=t(r.children);if(o)return o}}};return t(e)||null}getMenus(e="page",t=""){return U(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):this.getFirstPage()}async getDsl(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/files/${e}.json`]||this.modules[`/src/${t}/files/${e}.json`];return s?await s():this.service.getFile(e,this.project||void 0).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.adapter.request?this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null):null)}createDslRenderer(e,t={}){const{library:s,components:r,mode:o,apis:a}=this,i={mode:o,Vue:s.Vue,components:r,libs:s,apis:a,window,...t},l=G({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return K({...i,dsl:e,loader:l})}async getRenderComponent(e,t){const s=this.getFile(e);if(!s)return f.logger.warn(`Can not find file: ${e}`),null;if(t&&t(s),this.mode===S.Raw){const{vtjRawDir:o=".vtj/vue"}=this.options,a=`${o}/${e}.vue`,i=this.modules[a]||this.modules[`/src/pages/${e}.vue`];return i?(await i())?.default:this.nodeEnv==="development"&&this.adapter.startupComponent||null}const r=await this.getDsl(s.id);return r?this.createDslRenderer(r).renderer:(f.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return b.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return b.defineAsyncComponent(async()=>await pe(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Bt(e,s)}initI18n(e,t,s){Vt(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function Wt(n){const e=new Ve(n);return{provider:e,onReady:s=>e.ready(s)}}function me(n={}){const e=b.inject(he,null);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=n;t&&s&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==s&&e.adapter.notify&&e.adapter.notify(`[ ${r?.name} ] 组件源码版本与运行时版本不一致,请重新发布组件`,"版本不一致","warning")})()}return e}async function Qt(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(i=>e+i),{css:o,js:a}=Re(r);if(o.length&&ae(o),a.length)return await ce(a,t).catch(()=>{})}const We={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},Yt=(n,e="/__vtj__/api/:type.json")=>(t,s,r)=>n.send({url:e,method:"post",params:{type:t},query:r,data:{type:t,data:s},settings:We}),Xt=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...We,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function Zt(n){return f.createRequest({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:e=>e.data?.code===0,showError:e=>{n&&n(e||"未知错误")}}})}class Q{constructor(e=f.request){this.req=e,this.api=Yt(e),this.uploader=Xt(e)}api;pluginCaches={};uploader;async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return console.log("BaseService.saveMaterials",e,t),!1}async saveFile(e){return console.log("BaseService.saveFile",e),!1}async getFile(e){return console.log("BaseService.getFile",e),{}}async removeFile(e){return console.log("BaseService.removeFile",e),!1}async saveHistory(e){return console.log("BaseService.saveHistory",e),!1}async removeHistory(e){return console.log("BaseService.removeHistory",e),!1}async getHistory(e){return console.log("BaseService.getHistory",e),{}}async getHistoryItem(e,t){return console.log("BaseService.getHistoryItem",e,t),{}}async saveHistoryItem(e,t){return console.log("BaseService.saveHistoryItem",e,t),!1}async removeHistoryItem(e,t){return console.log("BaseService.removeHistoryItem",e,t),!1}async publish(e){return!!await this.api("publish",e).catch(()=>!1)}async publishFile(e,t){return!!await this.api("publishFile",{project:e,file:t}).catch(()=>!1)}async genVueContent(e,t){return await this.api("genVueContent",{project:e,dsl:t}).catch(()=>"")}async parseVue(e,t){return await this.api("parseVue",{project:e,...t})}async createRawPage(e){return await this.api("createRawPage",e).catch(()=>"")}async removeRawPage(e){return await this.api("removeRawPage",e).catch(()=>"")}async uploadStaticFile(e,t){return await this.uploader(e,t).catch(()=>null)}async getStaticFiles(e){return await this.api("getStaticFiles",e).catch(()=>[])}async removeStaticFile(e,t){return await this.api("removeStaticFile",{name:e,projectId:t}).catch(()=>"")}async clearStaticFiles(e){return await this.api("clearStaticFiles",e).catch(()=>"")}async getPluginMaterial(e){const{urls:t=[]}=e,s=t.filter(o=>Ee(o))[0];if(!s)return null;const r=this.pluginCaches[s];return r||(this.pluginCaches[s]=f.request.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const $=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class es extends Q{init(e){const t=new T.ProjectModel(e),s=$.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return $.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return $.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return $.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return $.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=$.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return $.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return $.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=$.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),$.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=$.get(`history_${e}`),s=new T.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=$.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return $.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{$.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class Qe extends Q{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new T.ProjectModel(e),s=this.projects[t.id]||{},r=Object.assign(t.toDsl(),s);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new T.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,r=this.historyItems[s]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const r=`${e}_${s}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let J=null;function ts(){return J||(J=new Qe,J)}class ss extends Q{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:f.mapToObject(t)}).catch(()=>!1)}async saveFile(e){return!!await this.api("saveFile",e).catch(()=>!1)}async getFile(e){const t=this.getFileCaches[e];return t||(this.getFileCaches[e]=this.api("getFile",e).catch(()=>null)).finally(()=>{delete this.getFileCaches[e]})}async removeFile(e){return!!await this.api("removeFile",e).catch(()=>!1)}async saveHistory(e){return!!await this.api("saveHistory",e).catch(()=>!1)}async removeHistory(e){return!!await this.api("removeHistory",e).catch(()=>!1)}async getHistory(e){return await this.api("getHistory",e).catch(()=>null)||{}}async getHistoryItem(e,t){return await this.api("getHistoryItem",{fId:e,id:t}).catch(()=>null)||{}}async saveHistoryItem(e,t){return!!await this.api("saveHistoryItem",{fId:e,item:t}).catch(()=>!1)}async removeHistoryItem(e,t){return!!await this.api("removeHistoryItem",{fId:e,ids:t}).catch(()=>!1)}}exports.ACCESS=rt;exports.ACCESS_KEY=le;exports.Access=W;exports.BUILD_IN_TAGS=we;exports.BUILT_IN_DIRECTIVES=_e;exports.BaseService=Q;exports.CONTEXT_HOST=se;exports.Context=Be;exports.ContextMode=S;exports.DATA_TYPES=Se;exports.HOMEPAGE_ROUTE_NAME=N;exports.HTML_TAGS=oe;exports.JSCodeToString=ut;exports.LIFE_CYCLES_LIST=st;exports.LocalService=ss;exports.MemoryService=Qe;exports.NodeEnv=ze;exports.PAGE_ROUTE_NAME=k;exports.Provider=Ve;exports.REMOTE=nt;exports.StorageService=es;exports.VTJ_RENDERER_VERSION=F;exports.adoptStylesToInline=ct;exports.adoptedStyleSheets=V;exports.clearLoaderCache=Et;exports.compileScopedCSS=Ce;exports.convertCssRpx=Ae;exports.createAccess=dt;exports.createAdapter=ft;exports.createAssetScripts=ot;exports.createAssetsCss=it;exports.createDataSources=qe;exports.createLoader=G;exports.createMemoryService=ts;exports.createMenus=U;exports.createMetaApi=xe;exports.createMock=Ne;exports.createProvider=Wt;exports.createRenderer=K;exports.createSchemaApi=De;exports.createSchemaApis=He;exports.createServiceRequest=Zt;exports.defaultLoader=Ke;exports.fillBasePath=H;exports.getMock=D;exports.getModifiers=fe;exports.getPlugin=pe;exports.getRawComponent=je;exports.isBuiltInTag=Me;exports.isCSSUrl=B;exports.isJSCode=Fe;exports.isJSExpression=R;exports.isJSFunction=j;exports.isJSON=Ee;exports.isJSUrl=q;exports.isNativeTag=Oe;exports.isVuePlugin=Te;exports.loadCss=Ie;exports.loadCssUrl=ae;exports.loadEnhance=Qt;exports.loadScriptUrl=ce;exports.menusFilter=de;exports.mockApi=Ue;exports.mockApis=Le;exports.mockCleanup=ue;exports.nodeRender=O;exports.parseDeps=be;exports.parseExpression=x;exports.parseFunction=C;exports.parseUrls=Re;exports.providerKey=he;exports.removeProdFlag=$e;exports.rpxToPx=Pe;exports.setupPageSetting=lt;exports.toString=ie;exports.useAccess=ke;exports.useMask=Ut;exports.useProvider=me;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { Base as Ge, BUILT_IN_COMPONENTS as Ve, ProjectModel as q, HistoryModel as be } from "@vtj/core";
2
- import { url as k, isUrl as ne, dedupArray as We, isFunction as J, isString as I, logger as O, storage as Y, cookie as Z, toArray as ye, unRSA as ve, delay as K, createRequest as Ee, jsonp as je, merge as Qe, pathToRegexp as Xe, pathToRegexpMatch as Ye, formDataToJson as Ze, Queue as et, cloneDeep as _e, camelCase as C, upperFirst as tt, pick as st, request as re, loadScript as we, debounce as nt, Storage as rt, mapToObject as fe } from "@vtj/utils";
1
+ import { Base as Ge, BUILT_IN_COMPONENTS as Ve, ProjectModel as q, HistoryModel as Ee } from "@vtj/core";
2
+ import { url as k, isUrl as ne, dedupArray as We, isFunction as J, isString as I, logger as O, storage as Y, cookie as Z, toArray as ye, unRSA as ve, delay as K, createRequest as be, jsonp as je, merge as Qe, pathToRegexp as Xe, pathToRegexpMatch as Ye, formDataToJson as Ze, Queue as et, cloneDeep as _e, camelCase as C, upperFirst as tt, pick as st, request as re, loadScript as we, debounce as nt, Storage as rt, mapToObject as fe } from "@vtj/utils";
3
3
  import * as G from "vue";
4
4
  import { inject as Re, defineComponent as Pe, h as ie, ref as oe, watchEffect as it, defineAsyncComponent as Se } from "vue";
5
5
  import { useRoute as Ce } from "vue-router";
@@ -7,10 +7,10 @@ import { useRoute as Ce } 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.16.16
10
+ * @version 0.16.17
11
11
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
12
12
  */
13
- const x = "0.16.16";
13
+ const x = "0.16.17";
14
14
  var _ = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(_ || {});
15
15
  const $e = [
16
16
  "$el",
@@ -57,7 +57,7 @@ const $e = [
57
57
  Date
58
58
  }, D = "VtjPage", U = "VtjHomepage", Ae = "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
- ), ct = "component,slot".split(","), bs = [
60
+ ), ct = "component,slot".split(","), Es = [
61
61
  "h",
62
62
  "t",
63
63
  "t",
@@ -77,7 +77,7 @@ const $e = [
77
77
  "p",
78
78
  "r",
79
79
  "o"
80
- ].join(""), Es = {
80
+ ].join(""), bs = {
81
81
  auth: [
82
82
  "h",
83
83
  "t",
@@ -437,19 +437,19 @@ function R(n, e, t = !1, s = !1, r = !1) {
437
437
  throw new Error(`"${n.value}" not a function`);
438
438
  return i;
439
439
  }
440
- function E(n) {
440
+ function b(n) {
441
441
  return n && n.type === "JSExpression";
442
442
  }
443
- function b(n) {
443
+ function E(n) {
444
444
  return typeof n == "object" && n && n.type === "JSFunction";
445
445
  }
446
446
  function $t(n) {
447
- return E(n) || b(n);
447
+ return b(n) || E(n);
448
448
  }
449
449
  function As(n) {
450
450
  return $t(n) ? n.value : JSON.stringify(n);
451
451
  }
452
- const bt = {
452
+ const Et = {
453
453
  session: !1,
454
454
  authKey: "Authorization",
455
455
  storageKey: "ACCESS_STORAGE",
@@ -470,7 +470,7 @@ class de {
470
470
  interceptResponse = !0;
471
471
  isTipShowing = !1;
472
472
  constructor(e) {
473
- this.options = Object.assign({}, bt, e), this.loadData();
473
+ this.options = Object.assign({}, Et, e), this.loadData();
474
474
  }
475
475
  enableIntercept() {
476
476
  this.interceptResponse = !0;
@@ -619,7 +619,7 @@ class de {
619
619
  );
620
620
  }
621
621
  }
622
- function Et() {
622
+ function bt() {
623
623
  return Re(Oe, null);
624
624
  }
625
625
  function Is(n = {}) {
@@ -634,7 +634,7 @@ function Is(n = {}) {
634
634
  } = n;
635
635
  let l = null;
636
636
  return {
637
- request: Ee({
637
+ request: be({
638
638
  settings: {
639
639
  type: "form",
640
640
  validSuccess: !0,
@@ -712,7 +712,7 @@ async function Ct(n = [], e = window) {
712
712
  t && (Me(e), n.forEach((s) => It(t, s)));
713
713
  }
714
714
  function At(n, e = window) {
715
- const t = b(n.mockTemplate) && n.mockTemplate.value ? R(n.mockTemplate, {}, !0) : void 0, s = H(e);
715
+ const t = E(n.mockTemplate) && n.mockTemplate.value ? R(n.mockTemplate, {}, !0) : void 0, s = H(e);
716
716
  return async (...r) => {
717
717
  let i = {};
718
718
  if (t)
@@ -927,7 +927,7 @@ function Ot(n = [], e) {
927
927
  name: s.name,
928
928
  type: s.type,
929
929
  required: s.required,
930
- default: E(s.default) ? e.__parseExpression(s.default) : s.default
930
+ default: b(s.default) ? e.__parseExpression(s.default) : s.default
931
931
  }).reduce(
932
932
  (s, r) => (s[r.name] = {
933
933
  type: t(r.type),
@@ -942,7 +942,7 @@ function Mt(n, e, t) {
942
942
  Object.keys(e || {}).reduce(
943
943
  (s, r) => {
944
944
  let i = e[r];
945
- return E(i) ? i = t.__parseExpression(i) : b(i) && (i = t.__parseFunction(i)), s[r] = i, s;
945
+ return b(i) ? i = t.__parseExpression(i) : E(i) && (i = t.__parseFunction(i)), s[r] = i, s;
946
946
  },
947
947
  {}
948
948
  )
@@ -965,7 +965,7 @@ function Dt(n, e = [], t) {
965
965
  (s, r) => {
966
966
  const { name: i, from: a } = r || {};
967
967
  r.default;
968
- const o = E(a) ? t.__parseExpression(a) || i : a ?? i, l = E(r.default) ? t.__parseExpression(r.default) : r.default ?? null;
968
+ const o = b(a) ? t.__parseExpression(a) || i : a ?? i, l = b(r.default) ? t.__parseExpression(r.default) : r.default ?? null;
969
969
  return s[i] = n.inject(o, l), s;
970
970
  },
971
971
  {}
@@ -978,7 +978,7 @@ function Ht(n, e) {
978
978
  if (r.type === "mock")
979
979
  t[s] = At(r);
980
980
  else if (r.ref) {
981
- const i = e.$apis[r.ref], a = b(r.transform) ? r.transform.value ? e.__parseFunction(r.transform) : void 0 : r.transform;
981
+ const i = e.$apis[r.ref], a = E(r.transform) ? r.transform.value ? e.__parseFunction(r.transform) : void 0 : r.transform;
982
982
  t[s] = async (...o) => {
983
983
  const l = await i.apply(e, o);
984
984
  return a ? a(l) : l;
@@ -1143,14 +1143,14 @@ function qt(n, e) {
1143
1143
  return !!e.__parseExpression(n.value);
1144
1144
  }
1145
1145
  function Jt(n, e) {
1146
- return e ? E(e) ? n.__parseExpression(e) : e : "div";
1146
+ return e ? b(e) ? n.__parseExpression(e) : e : "div";
1147
1147
  }
1148
1148
  function Kt(n, e, t) {
1149
1149
  const s = le(e, t);
1150
1150
  return s.ref = t.__ref(n, s.ref), s;
1151
1151
  }
1152
1152
  function le(n, e) {
1153
- return E(n) ? e.__parseExpression(n) : b(n) ? e.__parseFunction(n) : Array.isArray(n) ? n.map((t) => le(t, e)) : typeof n == "object" ? Object.keys(n || {}).reduce(
1153
+ return b(n) ? e.__parseExpression(n) : E(n) ? e.__parseFunction(n) : Array.isArray(n) ? n.map((t) => le(t, e)) : typeof n == "object" ? Object.keys(n || {}).reduce(
1154
1154
  (t, s) => {
1155
1155
  let r = n[s];
1156
1156
  return t[s] = le(r, e), t;
@@ -1200,7 +1200,7 @@ function He(n = {}, e = !1) {
1200
1200
  }
1201
1201
  function Wt(n, e, t, s, r) {
1202
1202
  const { children: i } = e, a = Qt(e, s), o = s.$slots?.[a.name];
1203
- return o ? o(t) : i ? I(i) ? n.createTextVNode(i) : E(i) ? n.createTextVNode(
1203
+ return o ? o(t) : i ? I(i) ? n.createTextVNode(i) : b(i) ? n.createTextVNode(
1204
1204
  Ie(s.__parseExpression(i))
1205
1205
  ) : Array.isArray(i) ? i.map(
1206
1206
  (l) => M(l, s, n, r, i)
@@ -1209,7 +1209,7 @@ function Wt(n, e, t, s, r) {
1209
1209
  function Qt(n, e) {
1210
1210
  const { props: t } = n, s = t?.name || "default";
1211
1211
  return {
1212
- name: E(s) ? e.__parseExpression(s) : s,
1212
+ name: b(s) ? e.__parseExpression(s) : s,
1213
1213
  params: []
1214
1214
  };
1215
1215
  }
@@ -1231,7 +1231,7 @@ function Zt(n, e) {
1231
1231
  }` : "(v) => {}"
1232
1232
  };
1233
1233
  return {
1234
- [E(n.arg) ? e.__parseExpression(n.arg) : n.arg || "value"]: e.__parseExpression(n.value),
1234
+ [b(n.arg) ? e.__parseExpression(n.arg) : n.arg || "value"]: e.__parseExpression(n.value),
1235
1235
  onInput: e.__parseFunction(t)
1236
1236
  };
1237
1237
  }
@@ -1242,8 +1242,8 @@ function es(n, e, t) {
1242
1242
  ${e.value.value} = v;
1243
1243
  }` : "(v) => {}"
1244
1244
  }, r = t.__parseFunction(s), i = He(
1245
- E(e.modifiers) ? t.__parseExpression(e.modifiers) : e.modifiers
1246
- ), a = E(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue";
1245
+ b(e.modifiers) ? t.__parseExpression(e.modifiers) : e.modifiers
1246
+ ), a = b(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue";
1247
1247
  return {
1248
1248
  [a]: t.__parseExpression(e.value),
1249
1249
  [`onUpdate:${a}`]: i.length && r ? n.withModifiers(r, i) : r
@@ -1253,7 +1253,7 @@ function ts(n, e, t, s, r) {
1253
1253
  if (!e) return null;
1254
1254
  if (I(e))
1255
1255
  return { default: () => e };
1256
- if (E(e))
1256
+ if (b(e))
1257
1257
  return {
1258
1258
  default: () => Ie(t.__parseExpression(e))
1259
1259
  };
@@ -1371,7 +1371,7 @@ function Os(n) {
1371
1371
  menuPathPrefix: e = "",
1372
1372
  pageRouteName: t = "page",
1373
1373
  disableMenusFilter: s = !1
1374
- } = n || {}, r = Ne(), i = Ce(), a = Et(), o = oe(!1), l = oe(!1), c = r.project, u = (d, m) => {
1374
+ } = n || {}, r = Ne(), i = Ce(), a = bt(), o = oe(!1), l = oe(!1), c = r.project, u = (d, m) => {
1375
1375
  o.value = !d?.mask, l.value = m?.pure ?? !!d?.pure;
1376
1376
  };
1377
1377
  it(() => {
@@ -1477,13 +1477,13 @@ function os(n = {}, e) {
1477
1477
  }
1478
1478
  function as(n, e, t) {
1479
1479
  const s = t.createPinia();
1480
- if (e.use(s), b(n) && n.value) {
1480
+ if (e.use(s), E(n) && n.value) {
1481
1481
  const r = R(n, {}, !1, !1, !0), i = t.defineStore("$store", r(e) || {});
1482
1482
  e.config.globalProperties.$store = i();
1483
1483
  }
1484
1484
  }
1485
1485
  function cs(n, e, t, s) {
1486
- if (b(n) && n.value) {
1486
+ if (E(n) && n.value) {
1487
1487
  const r = R(n, {}, !1, !1, !0), { alert: i, request: a } = s, o = new de({
1488
1488
  alert: i,
1489
1489
  storagePrefix: "__VTJ_APP_",
@@ -1495,32 +1495,32 @@ function cs(n, e, t, s) {
1495
1495
  function ls(n, e, t) {
1496
1496
  if (!e.request) return;
1497
1497
  const { axios: s, request: r, response: i } = t;
1498
- if (s && b(s) && s.value) {
1498
+ if (s && E(s) && s.value) {
1499
1499
  const a = R(s, {}, !1, !1, !0);
1500
1500
  e.request.setConfig(a(n));
1501
1501
  }
1502
- if (r && b(r) && r.value) {
1502
+ if (r && E(r) && r.value) {
1503
1503
  const a = R(r, {}, !1, !1, !0), o = e.request;
1504
1504
  o.__unReq && o.__unReq(), o.__unReq = e.request.useRequest((l) => a(l, n));
1505
1505
  }
1506
- if (i && b(i) && i.value) {
1506
+ if (i && E(i) && i.value) {
1507
1507
  const a = R(i, {}, !1, !1, !0), o = e.request;
1508
1508
  o.__unRes && o.__unRes(), o.__unRes = e.request.useResponse((l) => a(l, n));
1509
1509
  }
1510
1510
  }
1511
1511
  function us(n, e) {
1512
1512
  const { beforeEach: t, afterEach: s } = e, r = n.config.globalProperties.$router;
1513
- if (t && b(t) && t.value) {
1513
+ if (t && E(t) && t.value) {
1514
1514
  const i = R(t, {}, !1, !1, !0);
1515
1515
  r && r.beforeEach((a, o, l) => i(a, o, l, n));
1516
1516
  }
1517
- if (s && b(s) && s.value) {
1517
+ if (s && E(s) && s.value) {
1518
1518
  const i = R(s, {}, !1, !1, !0);
1519
1519
  r && r.afterEach((a, o, l) => i(a, o, l, n));
1520
1520
  }
1521
1521
  }
1522
1522
  function fs(n, e, t = {}) {
1523
- b(n) && n.value && R(n, {}, !1, !1, !0)(e, t);
1523
+ E(n) && n.value && R(n, {}, !1, !1, !0)(e, t);
1524
1524
  }
1525
1525
  function ps(n, e, t) {
1526
1526
  if (!n || !e || !t) return;
@@ -1875,7 +1875,7 @@ class hs extends Ge {
1875
1875
  return O.warn(`Can not find file: ${e}`), null;
1876
1876
  if (t && t(s), this.mode === _.Raw) {
1877
1877
  const { vtjRawDir: i = ".vtj/vue" } = this.options, a = `${i}/${e}.vue`, o = this.modules[a] || this.modules[`/src/pages/${e}.vue`];
1878
- return o ? (await o())?.default : null;
1878
+ return o ? (await o())?.default : this.nodeEnv === "development" && this.adapter.startupComponent || null;
1879
1879
  }
1880
1880
  const r = await this.getDsl(s.id);
1881
1881
  return r ? this.createDslRenderer(r).renderer : (O.warn(`Can not find dsl: ${e}`), null);
@@ -1991,7 +1991,7 @@ const Ue = {
1991
1991
  }
1992
1992
  }).then((r) => r && r[0] ? r[0] : null).catch(() => null);
1993
1993
  function xs(n) {
1994
- return Ee({
1994
+ return be({
1995
1995
  settings: {
1996
1996
  type: "json",
1997
1997
  validSuccess: !0,
@@ -2145,7 +2145,7 @@ class Ds extends he {
2145
2145
  return Promise.resolve(!0);
2146
2146
  }
2147
2147
  getHistory(e) {
2148
- const t = $.get(`history_${e}`), s = new be(t || { id: e });
2148
+ const t = $.get(`history_${e}`), s = new Ee(t || { id: e });
2149
2149
  return Promise.resolve(s.toDsl());
2150
2150
  }
2151
2151
  getHistoryItem(e, t) {
@@ -2200,7 +2200,7 @@ class ys extends he {
2200
2200
  return Promise.resolve(!0);
2201
2201
  }
2202
2202
  getHistory(e) {
2203
- const t = this.histories[e], s = new be(t || { id: e });
2203
+ const t = this.histories[e], s = new Ee(t || { id: e });
2204
2204
  return Promise.resolve(s);
2205
2205
  }
2206
2206
  getHistoryItem(e, t) {
@@ -2280,7 +2280,7 @@ class Bs extends he {
2280
2280
  }
2281
2281
  }
2282
2282
  export {
2283
- Es as ACCESS,
2283
+ bs as ACCESS,
2284
2284
  Oe as ACCESS_KEY,
2285
2285
  de as Access,
2286
2286
  ct as BUILD_IN_TAGS,
@@ -2299,7 +2299,7 @@ export {
2299
2299
  ds as NodeEnv,
2300
2300
  D as PAGE_ROUTE_NAME,
2301
2301
  hs as Provider,
2302
- bs as REMOTE,
2302
+ Es as REMOTE,
2303
2303
  Ds as StorageService,
2304
2304
  x as VTJ_RENDERER_VERSION,
2305
2305
  Ps as adoptStylesToInline,
@@ -2331,8 +2331,8 @@ export {
2331
2331
  wt as isBuiltInTag,
2332
2332
  V as isCSSUrl,
2333
2333
  $t as isJSCode,
2334
- E as isJSExpression,
2335
- b as isJSFunction,
2334
+ b as isJSExpression,
2335
+ E as isJSFunction,
2336
2336
  lt as isJSON,
2337
2337
  W as isJSUrl,
2338
2338
  St as isNativeTag,
@@ -2355,7 +2355,7 @@ export {
2355
2355
  gt as rpxToPx,
2356
2356
  Cs as setupPageSetting,
2357
2357
  Ie as toString,
2358
- Et as useAccess,
2358
+ bt as useAccess,
2359
2359
  Os as useMask,
2360
2360
  Ne as useProvider
2361
2361
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/renderer",
3
3
  "private": false,
4
- "version": "0.16.16",
4
+ "version": "0.16.17",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -21,15 +21,15 @@
21
21
  "author": "chenhuachun",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@vtj/core": "~0.16.16",
25
- "@vtj/utils": "~0.16.16"
24
+ "@vtj/core": "~0.16.17",
25
+ "@vtj/utils": "~0.16.17"
26
26
  },
27
27
  "devDependencies": {
28
28
  "vue": "~3.5.5",
29
29
  "vue-router": "~4.6.0",
30
+ "@vtj/icons": "~0.16.17",
30
31
  "@vtj/cli": "~0.12.18",
31
- "@vtj/ui": "~0.16.16",
32
- "@vtj/icons": "~0.16.16"
32
+ "@vtj/ui": "~0.16.17"
33
33
  },
34
34
  "exports": {
35
35
  ".": {
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/renderer
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.16.15
5
+ * @version 0.16.16
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.16.15";
8
+ export declare const version = "0.16.16";