UNPKG

@vtj/renderer

Version:

VTJ 是一款基于 Vue3 + Typescript 的低代码页面可视化设计器。内置低代码引擎、渲染器和代码生成器,面向前端开发者,开箱即用。 无缝嵌入本地开发工程,不改变前端开发流程和编码习惯。

15 lines (14 loc) 46.1 kB
"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 K=tt(b);/**! * Copyright (c) 2026, VTJ.PRO All rights reserved. * @name @vtj/renderer * @author CHC chenhuachun1549@dingtalk.com * @version 0.14.0 * @license <a href="https://vtj.pro/license.html">MIT License</a> */const k="0.14.0";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const te=["$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},F="VtjPage",L="VtjHomepage",we="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(","),Ee="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 U(n){return/\.css$/.test(n)}function B(n){return/\.js$/.test(n)}function $e(n){return/\.json$/.test(n)}function ot(n){return n.map(e=>`<script src="${f.url.append(e,{v:k})}"><\/script>`).join("")}function it(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:k})}" />`).join("")}function be(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function je(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],l={},c={},p=[],u={};return s.forEach(({urls:d,assetsUrl:m,library:h,assetsLibrary:g,localeLibrary:v})=>{d?.forEach(y=>{B(y)&&r.push(be(y,t)),U(y)&&o.push(y)}),h&&(i.push(h),l[h]=H(d||[],e),v&&(c[h]=v)),m&&a.push(m),g&&p.push(g),h&&g&&(u[g]=h)}),{scripts:H(r,e),css:H(o,e),materials:H(a,e),libraryExports:i,materialExports:f.dedupArray(p),materialMapLibrary:u,libraryMap:l,libraryLocaleMap:c}}function Re(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Ce(n=[]){const e=n.filter(s=>U(s)),t=n.filter(s=>B(s));return{css:e,js:t}}function Pe(n,e){const t=c=>{const p=[];let u=0;for(;u<c.length;){if(/\s/.test(c[u])){u++;continue}if(c.substring(u,u+2)==="/*"){const y=c.indexOf("*/",u+2);if(y!==-1){u=y+2;continue}}if(c[u]==="@"){const y=u;for(;u<c.length&&c[u]!=="{"&&c[u]!==";";)u++;const w=c.substring(y,u).trim(),_=w.includes("@keyframes");if(c[u]===";")p.push({type:"simple-at-rule",content:c.substring(y,u+1)}),u++;else if(c[u]==="{"){const E=u+1;let A=1;for(u++;u<c.length&&A>0;)c[u]==="{"?A++:c[u]==="}"&&A--,u++;const Q=c.substring(y,u),I=c.substring(E,u-1);p.push({type:_?"keyframes":"at-rule",rule:w,content:Q,inner:I})}continue}const d=u;for(;u<c.length&&c[u]!=="{";)u++;if(u>=c.length)break;const m=c.substring(d,u).trim();if(!m){u++;continue}const h=u+1;let g=1;for(u++;u<c.length&&g>0;)c[u]==="{"?g++:c[u]==="}"&&g--,u++;const v=c.substring(h,u-1);p.push({type:"rule",selector:m,content:v.trim()})}return p},s=c=>{const p=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(p)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(p,u,d)=>{const m=u.trim(),h=d.trim();return m?`${m}[${e}] ${h}`:h}),o=c=>{const p=c.trim();if(!p||p.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(p)||s(p))return p;const u=p.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(u){const[,d,m=""]=u,h=d.trim();return h?`${h}[${e}]${m}`:p}return`${p}[${e}]`},a=c=>r(c).split(",").map(u=>o(u)).filter(u=>u.trim()).join(", "),i=c=>c.map(p=>{switch(p.type){case"simple-at-rule":return p.content;case"keyframes":return p.content;case"at-rule":try{const d=t(p.inner),m=i(d);return`${p.rule} { ${m} }`}catch{return p.content}case"rule":if(!p.selector||!p.content)return"";const u=a(p.selector);return u.trim()?`${u} { ${p.content} }`:"";default:return""}}).filter(p=>p.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,` `),p=t(c),u=i(p);return l(u)}catch(c){return console.error("CSS scoping failed:",c),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,p=>p).replace(/([^{}@]+)(?=\s*{)/g,p=>{const u=p.trim();return!u||u.startsWith("@")||u.includes(`[${e}]`)||s(u)?p:`${u}[${e}]`})}}const at=750;function Ae(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 Ie(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],p=parseFloat(c),d=`${Ae(n,p).toFixed(6).replace(/\.?0+$/,"")}px`;o+=d,a+=l[0].length-1;continue}}o+=i}return o}function re(n){return f.isString(n)?n:JSON.stringify(n)}function z(n,e,t,s=!1){const r=n.CSSStyleSheet,o=s?`data-v-${e}`:e,a=n.__uniConfig?Ie(n,t):t,i=s?Pe(a,o):a;if(r.prototype.replaceSync){const l=new r;l.id=e,l.replaceSync(i);const c=n.document,p=c.adoptedStyleSheets,u=Array.from(p).filter(d=>d.id!==e);c.adoptedStyleSheets=[...u,l]}else{const l=n.document;let c=l.getElementById(e);c?c.innerHTML=i:(c=l.createElement("style"),c.id=e,c.innerHTML=i,l.head.appendChild(c))}}function ct(n){const e=n.adoptedStyleSheets||[];let t="";if(e.forEach(s=>{try{for(const r of s.cssRules)t+=r.cssText+` `}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 Te(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&z(window,n,t)}function oe(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 ie(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=p=>{i(p)},r.appendChild(c)}})}function Me(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function Oe(n){return Ee.includes(n)}function ke(n){return we.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(` `)+a;const i=r?` ${a} `:`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 P(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"},ae=Symbol("access");class V{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(ae,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===F){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 De(){return b.inject(ae,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:p=>p.data?.code===0||!!p.data?.success,failMessage:!0,showError:p=>{e&&e(p||"未知错误")},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 V({alert:i,...o}):void 0}}function dt(n={}){return new V(n)}function xe(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 He(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 Le(n=[],e=[],t){const s={};for(const r of n){const o=xe(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=He(r,t);return s}async function Ne(n=[],e=window){const t=D(e);t&&(ce(e),n.forEach(s=>Be(t,s)))}function Ue(n,e=window){const t=j(n.mockTemplate)&&n.mockTemplate.value?P(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 Be(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)||{},p=l.body instanceof FormData?f.formDataToJson(l.body):l.body,u=f.isUrl(l.url)?new URL(l.url).pathname:l.url.split("?")[0],d=a(u)?.params;Object.assign(l,{data:p,params:d,query:c});try{return n.mock(i(l))}catch(m){return console.warn("[mockApi]",o,l,m),null}})}catch(r){console.warn("mockApi",r)}}function ce(n=window){const e=D(n);e&&(e._mocked={})}class qe{__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=K){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&&te.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){te.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 P({type:s,value:r},this)}else return P(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 J(n){const{Vue:e=K,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 qe({mode:t,dsl:i.value,attrs:l}),p=e.defineComponent({name:i.value.name,__scopeId:i.value.id?`data-v-${i.value.id}`:void 0,props:{...mt(i.value.props??[],c)},setup(u){c.$props=u,c.props=u,i.value.id&&z(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),m=yt(i.value.methods??{},c),h=_t(e,i.value.inject,c);for(const[y,w]of Object.entries(h||{}))h[y]=e.inject(y,w);const g=Je(i.value.dataSources||{},c),v={...h,...d,...m,...g};return c.setup(v,e),St(e,i.value.watch??[],c),{vtj:c,state:c.state,...d,...m}},emits:ht(i.value.emits),expose:["vtj",...i.value.expose||[]],render(){if(!i.value.nodes)return null;const u=i.value.nodes||[];return u.length===1?O(u[0],c,e,a,u):u.map(d=>O(d,c,e,a,u))},...wt(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(p),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 Je(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ue(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()=>{await f.delay(0),f.isFunction(o)&&o()},t},{})}const Ge=new f.Queue;let X=[],M={};const Ke=n=>n;async function le(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>B(i));if(r.length===0||!s)return null;const o=t.filter(i=>U(i));return o.length&&oe(o,e),await ie(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&&(X.forEach(r=>{delete s.window[r]}),X=[]),(r,o,a=K)=>{if(!o||typeof o=="string")return r;if(o.type==="Schema"&&o.id)return a.defineAsyncComponent(async()=>{const i=M[o.id]||await Ge.add(o.id,()=>e(o.id));return i&&(i.name=r,M[o.id]=i),i?J({...s,Vue:a,dsl:f.cloneDeep(i),mode:S.Runtime,loader:G(n)}).renderer:null});if(o.type==="UrlSchema"&&o.url)return a.defineAsyncComponent(async()=>{const i=M[o.url]||await t(o.url);return i&&(i.name=r,M[o.url]=i),i?J({...s,Vue:a,dsl:f.cloneDeep(i),mode:S.Runtime,loader:G(n)}).renderer:null});if(o.type==="Plugin"){let i=o.library?M[o.library]:null;return i||(o.library&&X.push(o.library),i=M[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await le(o,s.window);return l||(console.warn("getPlugin result is null",o),null)}),i)}return r}}function Et(){M={},Ge.clearAllCache()}function O(n,e,t=K,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:p,vElse:u,vFor:d,vShow:m,vModels:h,vBind:g,vHtml:v,others:y}=ze(l);if(!o&&(p||u))return null;if(c&&!bt(c,e))return Pt(n,e,t,s,r);const w=(_,E=0)=>{const A=_.$components,Q=(()=>{if(n.name==="component")return jt(_,n.props?.is);if(n.name==="slot")return n.name;const C=s(n.name,n.from,t);if(f.isString(C))return Oe(C)||ke(C)?C:A[C]??a?.app?.component(C)??C;if(f.isObject(C)&&n.id){const ge=`Loader${n.id}_${E}`,ve=A[ge];return ve||(A[ge]=C)}return C})(),I=Rt(i,n.props??{},_),Xe=Ct(t,n.events??{},_);if(n.name==="slot")return At(t,n,I,_,s);g&&Object.assign(I,_.__parseExpression(g.value)),m&&(I.style=Object.assign(I.style??{},Tt(m,_))),v&&Object.assign(I,Mt(v,_)),h.forEach(C=>{Object.assign(I,Ot(t,C,_))});const Ze=kt(t,n.children??[],_,s,n),he=_?.__id?`data-v-${_.__id}`:void 0,et=he?{[he]:""}:{};let Y=t.createVNode(Q,{key:`${i}_${E}`,...et,...I,...Xe},Ze);const me=a?$t(a,y,_):[];return me.length&&(Y=t.withDirectives(Y,me)),Y};return d?xt(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 ze(n=[]){const e=n.find(p=>f.camelCase(p.name)==="vIf"),t=n.find(p=>f.camelCase(p.name)==="vElseIf"),s=n.find(p=>f.camelCase(p.name)==="vElse"),r=n.find(p=>f.camelCase(p.name)==="vFor"),o=n.find(p=>f.camelCase(p.name)==="vShow"),a=n.find(p=>f.camelCase(p.name)==="vBind"),i=n.find(p=>f.camelCase(p.name)==="vHtml"),l=n.filter(p=>f.camelCase(p.name)==="vModel"),c=n.filter(p=>!_e.includes(f.camelCase(p.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=se(e,t);return s.ref=t.__ref(n,s.ref),s}function se(n,e){return R(n)?e.__parseExpression(n):j(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>se(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=se(r,e),t},{}):n}function Ct(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=ue(i.modifiers),c=l.find(d=>s.includes(d)),p="on"+f.upperFirst(a)+(c&&r[c]||""),u=t.__parseFunction(i.handler);return u&&(o[p]=n.withModifiers(u,l)),o},{})}function Pt(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}=ze(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 ue(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function At(n,e,t,s,r){const{children:o}=e,a=It(e,s),i=s.$slots?.[a.name];return i?i(t):o?f.isString(o)?n.createTextVNode(o):R(o)?n.createTextVNode(re(s.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,s,n,r,o)):null:null}function It(n,e){const{props:t}=n,s=t?.name||"default";return{name:R(s)?e.__parseExpression(s):s,params:[]}}function Tt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Mt(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Ot(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => { ${e.value.value} = v; }`:"(v) => {}"},r=t.__parseFunction(s),o=ue(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 kt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(R(e))return{default:()=>re(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=Ft(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:p,scope:u}])=>(i[l]=d=>{const m=p.length?f.pick(d??{},p):a(d,u);return c.map(h=>O(h,t.__clone(m),n,s,c))},i),{})}return null}function Ft(n){const e={};for(const t of n){const s=Dt(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 Dt(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function xt(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 Z=b.defineComponent({name:"VtjPageContainer",async setup(){const n=de(),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","页面不存在")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Ht=b.defineComponent({name:"VtjStartupContainer",render(){return b.h("div","page not found!")}});function N(n,e,t=[]){const s=[];for(const r of t){const{id:o,title:a,icon:i,children:l,hidden:c,layout:p}=r;if(p){const u=N(n,e,l||[]);s.push(...u)}else{const u={id:o,title:a,icon:i,hidden:c,url:`${n}/${e}/${o}`,children:l&&l.length?N(n,e,l):void 0};s.push(u)}}return s}function pe(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=pe(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Lt(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=de(),o=ye.useRoute(),a=De(),i=b.ref(!1),l=b.ref(!1),c=r.project,p=(m,h)=>{i.value=!m?.mask,l.value=h?.pure??!!m?.pure};b.watchEffect(()=>{const{name:m,params:h,meta:g}=o;if(m===F){const v=r.getPage(h.id);p(v,g)}else if(m===L){const v=r.getHomepage();p(v,g)}else{const v=g.__vtj__;if(v){const y=r.getPage(v);p(y,g)}else i.value=!g.mask,l.value=!!g.pure}});const u=N(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?u:pe(u,a),pure:l}}function ee(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 ne(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:p,title:u,dir:d,layout:m,children:h,meta:g}=c;if(d){const v=ne({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:h||[]});l.push(...v)}else if(m){const v=ne({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:h||[]}),y={name:`layout_${p}`,path:t,component:()=>o(p),meta:{title:u,...a,...g,__vtj__:p},children:v};l.push(y),l.push(ee(c,n))}else if(l.push(ee(c,n)),i===p){const v=ee(c,n);v.path="",v.name=`home_${p}`,l.push(v)}}return l}function Nt(n={},e){const{css:t,store:s,enhance:r}=n,{window:o,app:a,library:i={},adapter:l,mode:c}=e,{Pinia:p}=i;a.config.globalProperties.$libs=i,z(o,"global-css",t||""),p&&s&&Ut(s,a,p),qt(a,l,n),!l.access&&n.access&&Bt(n.access,a,c,l),Jt(a,n),r&&Gt(r,a,i)}function Ut(n,e,t){const s=t.createPinia();if(e.use(s),j(n)&&n.value){const r=P(n,{},!1,!1,!0),o=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=o()}}function Bt(n,e,t,s){if(j(n)&&n.value){const r=P(n,{},!1,!1,!0),{alert:o,request:a}=s,i=new V({alert:o,storagePrefix:"__VTJ_APP_",...r(e)}),l=e.config.globalProperties.$router;i.connect({mode:t,router:l,request:a}),e.use(i)}}function qt(n,e,t){if(!e.request)return;const{axios:s,request:r,response:o}=t;if(s&&j(s)&&s.value){const a=P(s,{},!1,!1,!0);e.request.setConfig(a(n))}if(r&&j(r)&&r.value){const a=P(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=P(o,{},!1,!1,!0),i=e.request;i.__unRes&&i.__unRes(),i.__unRes=e.request.useResponse(l=>a(l,n))}}function Jt(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&j(t)&&t.value){const o=P(t,{},!1,!1,!0);r&&r.beforeEach((a,i,l)=>o(a,i,l,n))}if(s&&j(s)&&s.value){const o=P(s,{},!1,!1,!0);r&&r.afterEach((a,i,l)=>o(a,i,l,n))}}function Gt(n,e,t={}){j(n)&&n.value&&P(n,{},!1,!1,!0)(e,t)}function Kt(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 p=Object.keys(c).filter(u=>u!=="key");for(const u of p)i[u]||(i[u]={}),i[u][c.key]=c[u]}const l=s.createI18n({legacy:!1,locale:r,fallbackLocale:o,messages:i});n.use(l)}}const fe=Symbol("Provider");var Ve=(n=>(n.Production="production",n.Development="development",n))(Ve||{});class We 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:p=null,materialPath:u="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=p,this.materialPath=u,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i);const{access:m,request:h}=this.adapter;m&&m.connect({mode:s,router:p,request:h}),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={};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=Le(r,o,this.adapter),ce(i),Ne(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:p,materials:u,materialExports:d,materialMapLibrary:m,libraryLocaleMap:h}=je(t,a,i==="development");Object.assign(this.libraryLocaleMap,h);for(const g of c){const v=s[g],y=e[g];if(y)r[g]=y;else if(v)e[g]=r[g]=await v();else{const _=p[g]||[];for(const E of _)U(E)&&await Te(E,f.url.append(E,{v:k})),B(E)&&await f.loadScript(f.url.append(E,{v:k}));r[g]=e[g]}const w=h[g];if(w){const _=s[w];l[w]=_?await _():e[w]}}if(i==="development"){for(const v of u)await f.loadScript(f.url.append(v,{v:k}));const g=this.materials||{};for(const v of d){const y=e[m[v]],w=y?.default||y,_=T.BUILT_IN_COMPONENTS[v];if(_)w&&_.forEach(E=>{o[E]=w[E]});else{const E=g[v]?(await g[v]()).default:e[v];E&&w&&(E.components||[]).forEach(A=>{o[A.name]=Re(A,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?"":"/",p={path:`${c}${i}/:id`,name:F,component:Z},u={path:c,name:L,component:t?.homepage?Z:r.startupComponent||Ht,meta:l};if(e.hasRoute(F)&&e.removeRoute(F),e.hasRoute(L)&&e.removeRoute(L),s.enableStaticRoute){const d=t?.pages||[];ne({name:i,prefix:c,pages:d,component:Z,loader:this.getRenderComponent.bind(this),homepage:t?.homepage}).forEach(h=>{a?e.addRoute(a,h):e.addRoute(h)}),t?.homepage||(a?e.addRoute(a,u):e.addRoute(u))}else a?(e.addRoute(a,p),e.addRoute(a,u)):(e.addRoute(p),e.addRoute(u))}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]&&Me(i)){const c={locale:s[t[a]]},p=r[a]||{},u={...c,...p};e.use(i,u),o[a]=!0}e.provide(fe,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&&(e.config.errorHandler=(a,i,l)=>{const c=i?.$options.name,p=typeof a=="string"?a:a?.message||a?.msg||"未知错误",u=`[ ${c} ] ${p} ${l}`;console.error("[VTJ Error]:",{err:a,instance:i,info:l},a?.stack),this.adapter.notify&&this.adapter.notify(u,"组件渲染错误","error")}),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}getMenus(e="page",t=""){return N(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):null}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 J({...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 le(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Nt(e,s)}initI18n(e,t,s){Kt(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function zt(n){const e=new We(n);return{provider:e,onReady:s=>e.ready(s)}}function de(n={}){const e=b.inject(fe,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 Vt(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(i=>e+i),{css:o,js:a}=Ce(r);if(o.length&&oe(o),a.length)return await ie(a,t).catch(()=>{})}const Qe={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},Wt=(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:Qe}),Qt=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...Qe,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function Yt(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 W{constructor(e=f.request){this.req=e,this.api=Wt(e),this.uploader=Qt(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=>$e(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 Xt extends W{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 Ye extends W{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 q=null;function Zt(){return q||(q=new Ye,q)}class es extends W{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=ae;exports.Access=V;exports.BUILD_IN_TAGS=Ee;exports.BUILT_IN_DIRECTIVES=_e;exports.BaseService=W;exports.CONTEXT_HOST=te;exports.Context=qe;exports.ContextMode=S;exports.DATA_TYPES=Se;exports.HOMEPAGE_ROUTE_NAME=L;exports.HTML_TAGS=we;exports.JSCodeToString=ut;exports.LIFE_CYCLES_LIST=st;exports.LocalService=es;exports.MemoryService=Ye;exports.NodeEnv=Ve;exports.PAGE_ROUTE_NAME=F;exports.Provider=We;exports.REMOTE=nt;exports.StorageService=Xt;exports.VTJ_RENDERER_VERSION=k;exports.adoptStylesToInline=ct;exports.adoptedStyleSheets=z;exports.clearLoaderCache=Et;exports.compileScopedCSS=Pe;exports.convertCssRpx=Ie;exports.createAccess=dt;exports.createAdapter=ft;exports.createAssetScripts=ot;exports.createAssetsCss=it;exports.createDataSources=Je;exports.createLoader=G;exports.createMemoryService=Zt;exports.createMenus=N;exports.createMetaApi=He;exports.createMock=Ue;exports.createProvider=zt;exports.createRenderer=J;exports.createSchemaApi=xe;exports.createSchemaApis=Le;exports.createServiceRequest=Yt;exports.defaultLoader=Ke;exports.fillBasePath=H;exports.getMock=D;exports.getModifiers=ue;exports.getPlugin=le;exports.getRawComponent=Re;exports.isBuiltInTag=Oe;exports.isCSSUrl=U;exports.isJSCode=Fe;exports.isJSExpression=R;exports.isJSFunction=j;exports.isJSON=$e;exports.isJSUrl=B;exports.isNativeTag=ke;exports.isVuePlugin=Me;exports.loadCss=Te;exports.loadCssUrl=oe;exports.loadEnhance=Vt;exports.loadScriptUrl=ie;exports.menusFilter=pe;exports.mockApi=Be;exports.mockApis=Ne;exports.mockCleanup=ce;exports.nodeRender=O;exports.parseDeps=je;exports.parseExpression=x;exports.parseFunction=P;exports.parseUrls=Ce;exports.providerKey=fe;exports.removeProdFlag=be;exports.rpxToPx=Ae;exports.setupPageSetting=lt;exports.toString=re;exports.useAccess=De;exports.useMask=Lt;exports.useProvider=de;