@vtj/renderer 0.16.24 → 0.16.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +239 -238
- package/package.json +5 -5
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
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.
|
|
5
|
+
* @version 0.16.25
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const D="0.16.
|
|
7
|
+
*/const D="0.16.25";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const ie=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],it=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],$e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],be={String,Number,Boolean,Array,Object,Function,Date},x="VtjPage",U="VtjHomepage",le="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot,svg".split(","),je="component,slot".split(","),at=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),ct={auth:["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o","/","a","u","t","h",".","h","t","m","l"].join(""),storageKey:["R","R","O","_","I","D","E","_","A","C","C","E","S","S","_","S","T","O","R","A","G","E","_","_"].join(""),privateKey:"MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd"};function N(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function J(n){return/\.js$/.test(n)}function Ce(n){return/\.json$/.test(n)}function lt(n){return n.map(e=>`<script src="${f.url.append(e,{v:D})}"><\/script>`).join("")}function ut(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:D})}" />`).join("")}function Re(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function Pe(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],i=[],a=[],u={},c={},l=[],p={};return s.forEach(({urls:d,assetsUrl:h,library:g,assetsLibrary:m,localeLibrary:_})=>{d?.forEach(y=>{J(y)&&r.push(Re(y,t)),B(y)&&o.push(y)}),g&&(a.push(g),u[g]=N(d||[],e),_&&(c[g]=_)),h&&i.push(h),m&&l.push(m),g&&m&&(p[m]=g)}),{scripts:N(r,e),css:N(o,e),materials:N(i,e),libraryExports:a,materialExports:f.dedupArray(l),materialMapLibrary:p,libraryMap:u,libraryLocaleMap:c}}function Ae(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Ie(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>J(s));return{css:e,js:t}}function Te(n,e){const t=c=>{const l=[];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(),C=w.includes("@keyframes");if(c[p]===";")l.push({type:"simple-at-rule",content:c.substring(y,p+1)}),p++;else if(c[p]==="{"){const v=p+1;let A=1;for(p++;p<c.length&&A>0;)c[p]==="{"?A++:c[p]==="}"&&A--,p++;const Z=c.substring(y,p),ee=c.substring(v,p-1);l.push({type:C?"keyframes":"at-rule",rule:w,content:Z,inner:ee})}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 _=c.substring(g,p-1);l.push({type:"rule",selector:h,content:_.trim()})}return l},s=c=>{const l=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(l)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(l,p,d)=>{const h=p.trim(),g=d.trim();return h?`${h}[${e}] ${g}`:g}),o=c=>{const l=c.trim();if(!l||l.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(l)||s(l))return l;const p=l.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(p){const[,d,h=""]=p,g=d.trim();return g?`${g}[${e}]${h}`:l}return`${l}[${e}]`},i=c=>r(c).split(",").map(p=>o(p)).filter(p=>p.trim()).join(", "),a=c=>c.map(l=>{switch(l.type){case"simple-at-rule":return l.content;case"keyframes":return l.content;case"at-rule":try{const d=t(l.inner),h=a(d);return`${l.rule} { ${h} }`}catch{return l.content}case"rule":if(!l.selector||!l.content)return"";const p=i(l.selector);return p.trim()?`${p} { ${l.content} }`:"";default:return""}}).filter(l=>l.trim()).join(" "),u=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
|
`),l=t(c),p=a(l);return u(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,l=>l).replace(/([^{}@]+)(?=\s*{)/g,l=>{const p=l.trim();return!p||p.startsWith("@")||p.includes(`[${e}]`)||s(p)?l:`${p}[${e}]`})}}const pt=750;function Me(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||pt;return e*s/r}function Oe(n,e){let t=!1,s=!1,r=!1,o="";for(let i=0;i<e.length;i++){const a=e[i];if(a==="'"&&!s&&!r?t=!t:a==='"'&&!t&&!r?s=!s:e.substr(i,4).toLowerCase()==="url("&&!t&&!s?r=!0:a===")"&&r&&(r=!1),!t&&!s&&!r){const u=e.substr(i).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(u){const c=u[1],l=parseFloat(c),d=`${Me(n,l).toFixed(6).replace(/\.?0+$/,"")}px`;o+=d,i+=u[0].length-1;continue}}o+=a}return o}function ue(n){return f.isString(n)?n:JSON.stringify(n)}function Q(n,e,t,s=!1){const r=n.CSSStyleSheet,o=s?`data-v-${e}`:e,i=n.__uniConfig?Oe(n,t):t,a=s?Te(i,o):i,u=!!n.__uniConfig;if(r.prototype.replaceSync&&!u){const c=new r;c.id=e,c.replaceSync(a);const l=n.document,p=l.adoptedStyleSheets,d=Array.from(p).filter(h=>h.id!==e);l.adoptedStyleSheets=[...d,c]}else{const c=n.document;let l=c.getElementById(e);l?l.innerHTML=a:(l=c.createElement("style"),l.id=e,l.innerHTML=a,c.head.appendChild(l))}}function ft(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 Fe(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&Q(window,n,t)}function pe(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const i=t.createElement("link");i.rel="stylesheet",i.id=r,i.href=r,s.appendChild(i)}}async function fe(n,e,t=window){const s=t.document,r=t.document.head;let o=t[e];return o?o.default||o:new Promise((i,a)=>{for(const u of n){const c=s.createElement("script");c.src=u,c.onload=()=>{o=t[e],o?i(o.default||o):a(null)},c.onerror=l=>{a(l)},r.appendChild(c)}})}function De(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function xe(n){return je.includes(n)}function ke(n){return le.includes(n)}function k(n=window){const e=window?.Mock;if(e)return e;const t=n?.Mock;if(t&&window)return window.Mock=t,t}function dt(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 H(n,e,t=!1,s=!1,r=!1){try{const o=['"use strict";',"var __self = arguments[0];"];o.push("return ");let i=(n.value||"").trim();r||(i=i.replace(/this(\W|$)/g,(u,c)=>`__self${c}`)),i=o.join(`
|
|
10
10
|
`)+i;const a=r?`
|
|
11
11
|
${i}
|
|
12
|
-
`:`with(${t?"{}":"$scope || {}"}) { ${i} }`;return new Function("$scope",a)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function R(n,e,t=!1,s=!1,r=!1){const o=H(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 j(n){return n&&n.type==="JSExpression"}function b(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function He(n){return j(n)||b(n)}function ht(n){return He(n)?n.value:JSON.stringify(n)}const mt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},de=Symbol("access");class Y{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},mt,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(de,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===x){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function Ne(){return $.inject(de,null)}function gt(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:i,alert:a}=n;let u=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:l=>l.data?.code===0||!!l.data?.success,failMessage:!0,showError:l=>{e&&e(l||"未知错误")},showLoading:()=>{u&&u.close(),t&&(u=t())},hideLoading:()=>{u&&(u.close(),u=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:i,alert:a,startupComponent:r,access:o?new Y({alert:a,...o}):void 0}}function _t(n={}){return new Y(n)}function Le(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?H(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(i,a)=>(delete o.data,s.send(f.merge(o,a||{},{data:i})))}}function Ue(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,i)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,i)}}function qe(n=[],e=[],t){const s={};for(const r of n){const o=Le(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=Ue(r,t);return s}async function Be(n=[],e=window){const t=k(e);t&&(he(e),n.forEach(s=>Ke(t,s)))}function Je(n,e=window){const t=b(n.mockTemplate)&&n.mockTemplate.value?R(n.mockTemplate,{},!0):void 0,s=k(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(i){f.logger.warn("模拟数据模版异常",i)}return s?.mock(o)}}function Ke(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}(.*)`),i=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),a=H(s,{},!0);n.mock(o,u=>{const c=f.url.parse(u.url)||{},l=u.body instanceof FormData?f.formDataToJson(u.body):u.body,p=f.isUrl(u.url)?new URL(u.url).pathname:u.url.split("?")[0],d=i(p)?.params;Object.assign(u,{data:l,params:d,query:c});try{return n.mock(a(u))}catch(h){return console.warn("[mockApi]",o,u,h),null}})}catch(r){console.warn("mockApi",r)}}function he(n=window){const e=k(n);e&&(e._mocked={})}class Ge{__id=null;__mode;__instance=null;__contextRefs={};__refs={};__refCaches={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=W){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.__refCaches={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&ie.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){ie.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.__refCaches={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return R({type:s,value:r},this)}else return R(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return H({type:s,value:r},this)}else return H(e,this)}__ref(e=null,t){if(this.__mode===S.VNode)return;e&&e!==this.__id&&(this.__contextRefs[e]=this);let s=e?this.__refCaches[e]:null;return s||(s=async r=>{await f.delay(0);let o=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!o){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return o.nodeType===3&&o.nextSibling&&(o=o.nextSibling),o.__vtj__=e,S.Design===this.__mode&&(o.__context__=this,o.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,r)),typeof t=="function"?t(r):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,r)),r},e&&(this.__refCaches[e]=s),s)}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function z(n){const{Vue:e=W,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:i}=n,a=e.computed(()=>n.dsl),u={$components:s,$libs:r,$apis:o},c=new Ge({mode:t,dsl:a.value,attrs:u}),l=e.defineComponent({name:a.value.name,__scopeId:a.value.id?`data-v-${a.value.id}`:void 0,props:{...yt(a.value.props??[],c)},async setup(p){c.$props=p,c.props=p,a.value.id&&Q(n.window||window,a.value.id,a.value.css||"",!0),c.state=St(e,a.value.state??{},c);const d=wt(e,a.value.computed??{},c),h=Et(a.value.methods??{},c),g=$t(e,a.value.inject,c);for(const[y,w]of Object.entries(g||{}))g[y]=e.inject(y,w);const m=ze(a.value.dataSources||{},c),_={...g,...d,...h,...m};return c.setup(_,e),bt(e,a.value.watch??[],c),{vtj:c,state:c.state,...d,...h}},emits:vt(a.value.emits),expose:["vtj",...a.value.expose||[]],render(){if(!a.value.nodes)return null;const p=a.value.nodes||[];if(p.length===1)return O(p[0],c,e,i,p);{const d=p.map(h=>O(h,c,e,i,p));return e.createVNode("div",{},d)}},...jt(a.value.lifeCycles??{},c)});return{renderer:e.markRaw(l),context:c}}function vt(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function yt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>be[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:j(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 St(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return j(o)?o=t.__parseExpression(o):b(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function wt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function Et(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:i}=r||{};r.default;const a=j(i)?t.__parseExpression(i)||o:i??o,u=j(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(a,u),s},{})}function ze(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Je(r);else if(r.ref){const o=e.$apis[r.ref],i=b(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...a)=>{const u=await o.apply(e,a);return i?i(u):u}}return t},{})}function bt(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function jt(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},{})}class Ct{__props={};__events={};__nodes={};constructor(){}setProps(e,t){this.__props[e]=t}getProps(e){return this.__props[e]}loadProps(e,t){const s=e?this.getProps(e):null;return s||(e&&this.setProps(e,t),t)}setEvents(e,t){}getEvents(e){return this.__events[e]}loadEvents(e,t){const s=e?this.getEvents(e):null;return s||(e&&this.setEvents(e,t),t)}setNode(e,t){this.__nodes[e]=t}getNode(e){return this.__nodes[e]}loadNode(e,t){const s=e?this.getNode(e):null;return s||(e&&this.setNode(e,t),t)}isEqual(e,t){return f.isEqual(e,t)}clear(){this.__props={},this.__events={},this.__nodes={}}}const F=new Ct,Ve=new f.Queue;let ne=[],M={},L={};const We=(n,e)=>e;async function me(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(a=>J(a));if(r.length===0||!s)return null;const o=t.filter(a=>B(a));return o.length&&pe(o,e),await fe(r,s,e).catch(a=>(console.warn("loadScriptUrl error",r,s,a),null))}function V(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(ne.forEach(r=>{delete s.window[r]}),ne=[]),(r,o,i,a=W)=>{if(!i||typeof i=="string")return o;let u="";if(i.type==="Schema"&&i.id)return u=i.id+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=M[i.id]||await Ve.add(i.id,()=>e(i.id));return c&&(c.name=o,M[i.id]=c),c?z({Vue:a,mode:S.Runtime,...s,dsl:f.cloneDeep(c),loader:V(n)}).renderer:null}));if(i.type==="UrlSchema"&&i.url)return u=i.url+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=M[i.url]||await t(i.url);return c&&(c.name=o,M[i.url]=c),c?z({...s,Vue:a,dsl:f.cloneDeep(c),mode:S.Runtime,loader:V(n)}).renderer:null}));if(i.type==="Plugin"){let c=i.library?M[i.library]:null;return c||(i.library&&ne.push(i.library),c=M[i.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await me(i,s.window);return l||(console.warn("getPlugin result is null",i),null)}),c)}return o}}function Rt(){M={},L={},Ve.clearAllCache(),F.clear()}function O(n,e,t=W,s=We,r=[],o=!1,i=0){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:u=null,directives:c=[]}=n,{vIf:l,vElseIf:p,vElse:d,vFor:h,vShow:g,vModels:m,vBind:_,vHtml:y,others:w}=Qe(c);if(!o&&(p||d))return null;if(l&&!At(l,e))return Ft(n,e,t,s,r);const C=(v,A=0)=>{const Z=v.$components,ee=(()=>{if(n.name==="component")return It(v,n.props?.is);if(n.name==="slot")return n.name;const P=s(`${n.id}_${A}`,n.name,n.from,t);return f.isString(P)?xe(P)||ke(P)?P:Z[P]??a?.app?.component(P)??P:P})(),I=Tt(u,n.props??{},v),tt=Ot(t,n.id,n.events??{},v);if(n.name==="slot")return Dt(t,n,I,v,s);_&&Object.assign(I,v.__parseExpression(_.value)),g&&(I.style=Object.assign(I.style??{},kt(g,v))),y&&Object.assign(I,Ht(y,v)),m.forEach(P=>{le.includes(n.name)?Object.assign(I,Nt(P,v)):Object.assign(I,Lt(t,P,v))});const st=Ut(t,n.children??[],v,s,n),Se=v?.__id?`data-v-${v.__id}`:void 0,nt=Se?{[Se]:""}:{},rt=v.__mode===S.Design?{"data-vtj":u}:{},K=`${u}_${A}`,te={key:K,...nt,...rt,...I,...tt};F.isEqual(te,F.getNode(K))||F.setNode(K,te);let se=t.createVNode(ee,F.getNode(K)||te||{},st);const we=a?Pt(a,w,v):[];return we.length&&(se=t.withDirectives(se,we)),se};return h?Jt(h,C,e):C(e,i)}function Pt(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 i=[o];return r.value&&i.push(t.__parseExpression(r.value)),r.arg&&i.push(r.arg),r.modifiers&&i.push(r.modifiers),i}).filter(r=>!!r)}function Qe(n=[]){const e=n.find(l=>f.camelCase(l.name)==="vIf"),t=n.find(l=>f.camelCase(l.name)==="vElseIf"),s=n.find(l=>f.camelCase(l.name)==="vElse"),r=n.find(l=>f.camelCase(l.name)==="vFor"),o=n.find(l=>f.camelCase(l.name)==="vShow"),i=n.find(l=>f.camelCase(l.name)==="vBind"),a=n.find(l=>f.camelCase(l.name)==="vHtml"),u=n.filter(l=>f.camelCase(l.name)==="vModel"),c=n.filter(l=>!$e.includes(f.camelCase(l.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:u,vBind:i,others:c,vHtml:a}}function At(n,e){return!!e.__parseExpression(n.value)}function It(n,e){return e?j(e)?n.__parseExpression(e):e:"div"}function Tt(n,e,t){const s=ae(e,t);return s.ref=t.__ref(n,s.ref),s}function ae(n,e){return j(n)?e.__parseExpression(n):b(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ae(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ae(r,e),t},{}):n}function Mt(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function Ot(n,e,t,s){const r=["passive","capture","once"],o={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(t||{}).reduce((a,u)=>{const c=t[u],l=ge(c.modifiers),p=l.find(g=>r.includes(g)),d="on"+f.upperFirstCamelCase(u)+(p&&o[p]||""),h=s.__parseFunction(c.handler);return h&&(a[d]=n.withModifiers(l.includes("enter")?Mt(h,"enter"):h,l)),a},{})}function Ft(n,e,t,s,r=[]){let o=r.findIndex(i=>i.id===n.id);for(let i=++o;i<r.length;i++){const{directives:a=[]}=r[i],{vElseIf:u,vElse:c}=Qe(a);if(u){if(e.__parseExpression(u.value))return O(r[i],e,t,s,r,!0);continue}if(c)return O(r[i],e,t,s,r,!0)}return null}function ge(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function Dt(n,e,t,s,r){const{children:o}=e,i=xt(e,s),a=s.$slots?.[i.name];return a?a(t):o?f.isString(o)?n.createTextVNode(o):j(o)?n.createTextVNode(ue(s.__parseExpression(o))):Array.isArray(o)?o.map((u,c)=>O(u,s,n,r,o,!1,c)):null:null}function xt(n,e){const{props:t}=n,s=t?.name||"default";return{name:j(s)?e.__parseExpression(s):s,params:[]}}function kt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ht(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Nt(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
|
|
12
|
+
`:`with(${t?"{}":"$scope || {}"}) { ${i} }`;return new Function("$scope",a)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function R(n,e,t=!1,s=!1,r=!1){const o=H(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 j(n){return n&&n.type==="JSExpression"}function b(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function He(n){return j(n)||b(n)}function ht(n){return He(n)?n.value:JSON.stringify(n)}const mt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},de=Symbol("access");class Y{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},mt,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(de,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===x){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function Ne(){return $.inject(de,null)}function gt(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:i,alert:a}=n;let u=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:l=>l.data?.code===0||!!l.data?.success,failMessage:!0,showError:l=>{e&&e(l||"未知错误")},showLoading:()=>{u&&u.close(),t&&(u=t())},hideLoading:()=>{u&&(u.close(),u=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:i,alert:a,startupComponent:r,access:o?new Y({alert:a,...o}):void 0}}function _t(n={}){return new Y(n)}function Le(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?H(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(i,a)=>(delete o.data,s.send(f.merge(o,a||{},{data:i})))}}function Ue(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,i)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,i)}}function qe(n=[],e=[],t){const s={};for(const r of n){const o=Le(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=Ue(r,t);return s}async function Be(n=[],e=window){const t=k(e);t&&(he(e),n.forEach(s=>Ke(t,s)))}function Je(n,e=window){const t=b(n.mockTemplate)&&n.mockTemplate.value?R(n.mockTemplate,{},!0):void 0,s=k(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(i){f.logger.warn("模拟数据模版异常",i)}return s?.mock(o)}}function Ke(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}(.*)`),i=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),a=H(s,{},!0);n.mock(o,u=>{const c=f.url.parse(u.url)||{},l=u.body instanceof FormData?f.formDataToJson(u.body):u.body,p=f.isUrl(u.url)?new URL(u.url).pathname:u.url.split("?")[0],d=i(p)?.params;Object.assign(u,{data:l,params:d,query:c});try{return n.mock(a(u))}catch(h){return console.warn("[mockApi]",o,u,h),null}})}catch(r){console.warn("mockApi",r)}}function he(n=window){const e=k(n);e&&(e._mocked={})}class Ge{__id=null;__mode;__instance=null;__contextRefs={};__refs={};__refCaches={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=W){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.__refCaches={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&ie.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){ie.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.__refCaches={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return R({type:s,value:r},this)}else return R(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return H({type:s,value:r},this)}else return H(e,this)}__ref(e=null,t){if(this.__mode===S.VNode)return;e&&e!==this.__id&&(this.__contextRefs[e]=this);let s=e?this.__refCaches[e]:null;return s||(s=async r=>{await f.delay(0);let o=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!o){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return o.nodeType===3&&o.nextSibling&&(o=o.nextSibling),o.__vtj__=e,S.Design===this.__mode&&(o.__context__=this,o.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,r)),typeof t=="function"?t(r):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,r)),r},e&&(this.__refCaches[e]=s),s)}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function z(n){const{Vue:e=W,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:i}=n,a=e.computed(()=>n.dsl),u={$components:s,$libs:r,$apis:o},c=new Ge({mode:t,dsl:a.value,attrs:u}),l=e.defineComponent({name:a.value.name,__scopeId:a.value.id?`data-v-${a.value.id}`:void 0,props:{...yt(a.value.props??[],c)},async setup(p={}){c.$props=p,c.props=p,a.value.id&&Q(n.window||window,a.value.id,a.value.css||"",!0),c.state=St(e,a.value.state??{},c);const d=wt(e,a.value.computed??{},c),h=Et(a.value.methods??{},c),g=$t(e,a.value.inject,c);for(const[y,w]of Object.entries(g||{}))g[y]=e.inject(y,w);const m=ze(a.value.dataSources||{},c),_={...g,...d,...h,...m};return c.setup(_,e),bt(e,a.value.watch??[],c),{vtj:c,state:c.state,...p,...d,...h}},emits:vt(a.value.emits),expose:["vtj",...a.value.expose||[]],render(){if(!a.value.nodes)return null;const p=a.value.nodes||[];if(p.length===1)return O(p[0],c,e,i,p);{const d=p.map(h=>O(h,c,e,i,p));return e.createVNode("div",{},d)}},...jt(a.value.lifeCycles??{},c)});return{renderer:e.markRaw(l),context:c}}function vt(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function yt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>be[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:j(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 St(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return j(o)?o=t.__parseExpression(o):b(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function wt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function Et(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:i}=r||{};r.default;const a=j(i)?t.__parseExpression(i)||o:i??o,u=j(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(a,u),s},{})}function ze(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Je(r);else if(r.ref){const o=e.$apis[r.ref],i=b(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...a)=>{const u=await o.apply(e,a);return i?i(u):u}}return t},{})}function bt(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function jt(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},{})}class Ct{__props={};__events={};__nodes={};constructor(){}setProps(e,t){this.__props[e]=t}getProps(e){return this.__props[e]}loadProps(e,t){const s=e?this.getProps(e):null;return s||(e&&this.setProps(e,t),t)}setEvents(e,t){}getEvents(e){return this.__events[e]}loadEvents(e,t){const s=e?this.getEvents(e):null;return s||(e&&this.setEvents(e,t),t)}setNode(e,t){this.__nodes[e]=t}getNode(e){return this.__nodes[e]}loadNode(e,t){const s=e?this.getNode(e):null;return s||(e&&this.setNode(e,t),t)}isEqual(e,t){return f.isEqual(e,t)}clear(){this.__props={},this.__events={},this.__nodes={}}}const F=new Ct,Ve=new f.Queue;let ne=[],M={},L={};const We=(n,e)=>e;async function me(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(a=>J(a));if(r.length===0||!s)return null;const o=t.filter(a=>B(a));return o.length&&pe(o,e),await fe(r,s,e).catch(a=>(console.warn("loadScriptUrl error",r,s,a),null))}function V(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(ne.forEach(r=>{delete s.window[r]}),ne=[]),(r,o,i,a=W)=>{if(!i||typeof i=="string")return o;let u="";if(i.type==="Schema"&&i.id)return u=i.id+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=M[i.id]||await Ve.add(i.id,()=>e(i.id));return c&&(c.name=o,M[i.id]=c),c?z({Vue:a,mode:S.Runtime,...s,dsl:f.cloneDeep(c),loader:V(n)}).renderer:null}));if(i.type==="UrlSchema"&&i.url)return u=i.url+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=M[i.url]||await t(i.url);return c&&(c.name=o,M[i.url]=c),c?z({...s,Vue:a,dsl:f.cloneDeep(c),mode:S.Runtime,loader:V(n)}).renderer:null}));if(i.type==="Plugin"){let c=i.library?M[i.library]:null;return c||(i.library&&ne.push(i.library),c=M[i.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await me(i,s.window);return l||(console.warn("getPlugin result is null",i),null)}),c)}return o}}function Rt(){M={},L={},Ve.clearAllCache(),F.clear()}function O(n,e,t=W,s=We,r=[],o=!1,i=0){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:u=null,directives:c=[]}=n,{vIf:l,vElseIf:p,vElse:d,vFor:h,vShow:g,vModels:m,vBind:_,vHtml:y,others:w}=Qe(c);if(!o&&(p||d))return null;if(l&&!At(l,e))return Ft(n,e,t,s,r);const C=(v,A=0)=>{const Z=v.$components,ee=(()=>{if(n.name==="component")return It(v,n.props?.is);if(n.name==="slot")return n.name;const P=s(`${n.id}_${A}`,n.name,n.from,t);return f.isString(P)?xe(P)||ke(P)?P:Z[P]??a?.app?.component(P)??P:P})(),I=Tt(u,n.props??{},v),tt=Ot(t,n.id,n.events??{},v);if(n.name==="slot")return Dt(t,n,I,v,s);_&&Object.assign(I,v.__parseExpression(_.value)),g&&(I.style=Object.assign(I.style??{},kt(g,v))),y&&Object.assign(I,Ht(y,v)),m.forEach(P=>{le.includes(n.name)?Object.assign(I,Nt(P,v)):Object.assign(I,Lt(t,P,v))});const st=Ut(t,n.children??[],v,s,n),Se=v?.__id?`data-v-${v.__id}`:void 0,nt=Se?{[Se]:""}:{},rt=v.__mode===S.Design?{"data-vtj":u}:{},K=`${u}_${A}`,te={key:K,...nt,...rt,...I,...tt};F.isEqual(te,F.getNode(K))||F.setNode(K,te);let se=t.createVNode(ee,F.getNode(K)||te||{},st);const we=a?Pt(a,w,v):[];return we.length&&(se=t.withDirectives(se,we)),se};return h?Jt(h,C,e):C(e,i)}function Pt(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 i=[o];return r.value&&i.push(t.__parseExpression(r.value)),r.arg&&i.push(r.arg),r.modifiers&&i.push(r.modifiers),i}).filter(r=>!!r)}function Qe(n=[]){const e=n.find(l=>f.camelCase(l.name)==="vIf"),t=n.find(l=>f.camelCase(l.name)==="vElseIf"),s=n.find(l=>f.camelCase(l.name)==="vElse"),r=n.find(l=>f.camelCase(l.name)==="vFor"),o=n.find(l=>f.camelCase(l.name)==="vShow"),i=n.find(l=>f.camelCase(l.name)==="vBind"),a=n.find(l=>f.camelCase(l.name)==="vHtml"),u=n.filter(l=>f.camelCase(l.name)==="vModel"),c=n.filter(l=>!$e.includes(f.camelCase(l.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:u,vBind:i,others:c,vHtml:a}}function At(n,e){return!!e.__parseExpression(n.value)}function It(n,e){return e?j(e)?n.__parseExpression(e):e:"div"}function Tt(n,e,t){const s=ae(e,t);return s.ref=t.__ref(n,s.ref),s}function ae(n,e){return j(n)?e.__parseExpression(n):b(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ae(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ae(r,e),t},{}):n}function Mt(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function Ot(n,e,t,s){const r=["passive","capture","once"],o={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(t||{}).reduce((a,u)=>{const c=t[u],l=ge(c.modifiers),p=l.find(g=>r.includes(g)),d="on"+f.upperFirstCamelCase(u)+(p&&o[p]||""),h=s.__parseFunction(c.handler);return h&&(a[d]=n.withModifiers(l.includes("enter")?Mt(h,"enter"):h,l)),a},{})}function Ft(n,e,t,s,r=[]){let o=r.findIndex(i=>i.id===n.id);for(let i=++o;i<r.length;i++){const{directives:a=[]}=r[i],{vElseIf:u,vElse:c}=Qe(a);if(u){if(e.__parseExpression(u.value))return O(r[i],e,t,s,r,!0);continue}if(c)return O(r[i],e,t,s,r,!0)}return null}function ge(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function Dt(n,e,t,s,r){const{children:o}=e,i=xt(e,s),a=s.$slots?.[i.name];return a?a(t):o?f.isString(o)?n.createTextVNode(o):j(o)?n.createTextVNode(ue(s.__parseExpression(o))):Array.isArray(o)?o.map((u,c)=>O(u,s,n,r,o,!1,c)):null:null}function xt(n,e){const{props:t}=n,s=t?.name||"default";return{name:j(s)?e.__parseExpression(s):s,params:[]}}function kt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ht(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Nt(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
|
|
13
13
|
${n.value.value} = v?.target.value;
|
|
14
14
|
}`:"(v) => {}"};return{[j(n.arg)?e.__parseExpression(n.arg):n.arg||"value"]:e.__parseExpression(n.value),onInput:e.__parseFunction(t)}}function Lt(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
|
|
15
15
|
${e.value.value} = v;
|