@vtj/renderer 0.8.26 → 0.8.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@vtj/core"),l=require("@vtj/utils"),j=require("vue"),te=require("vue-router"),x=require("element-plus"),T=require("mockjs"),we=require("@vueuse/core"),je=require("@vtj/ui");function $e(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const A=$e(j);/**!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@vtj/core"),l=require("@vtj/utils"),j=require("vue"),re=require("vue-router"),T=require("element-plus"),D=require("mockjs"),$e=require("@vueuse/core"),Ee=require("@vtj/ui");function Ce(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const B=Ce(j);/**!
2
2
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/renderer
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.8.26
5
+ * @version 0.8.28
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const F="0.8.26";var w=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(w||{});const J=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],Ee=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],re=["vIf","vShow","vModel","vFor","vBind"],ne={String,Number,Boolean,Array,Object,Function,Date};function I(n,e){return n.map(t=>l.isUrl(t)?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function N(n){return/\.js$/.test(n)}function se(n){return/\.json$/.test(n)}function Ce(n){return n.map(e=>`<script src="${l.url.append(e,{v:F})}"><\/script>`).join("")}function Pe(n=[]){return n.map(e=>`<link rel="stylesheet" href="${l.url.append(e,{v:F})}" />`).join("")}function oe(n,e){const t=n.filter(d=>!!d.enabled),r=[],s=[],o=[],a=[],i={},u={},c=[],m={};return t.forEach(({urls:d,assetsUrl:f,library:v,assetsLibrary:h,localeLibrary:g})=>{d?.forEach(p=>{N(p)&&r.push(p),B(p)&&s.push(p)}),v&&(a.push(v),i[v]=I(d||[],e),g&&(u[v]=g)),f&&o.push(f),h&&c.push(h),v&&h&&(m[h]=v)}),{scripts:I(r,e),css:I(s,e),materials:I(o,e),libraryExports:a,materialExports:l.dedupArray(c),materialMapLibrary:m,libraryMap:i,libraryLocaleMap:u}}function ie(n,e){const{name:t,parent:r,alias:s}=n;return r?e[r]?.[s||t]:e[s||t]}function V(n){return l.isString(n)?n:JSON.stringify(n)}function Y(n,e,t){const r=n.CSSStyleSheet;if(r.prototype.replaceSync){const s=new r;s.id=e,s.replaceSync(t);const o=n.document,a=o.adoptedStyleSheets,i=Array.from(a).filter(u=>u.id!==e);o.adoptedStyleSheets=[...i,s]}else{const s=n.document;let o=s.getElementById(e);o?o.innerHTML=t:(o=s.createElement("style"),o.id=e,o.innerHTML=t,s.head.appendChild(o))}}async function ae(n,e){const t=await window.fetch(e).then(r=>r.text()).catch(()=>"");t&&Y(window,n,t)}function K(n,e=window){const t=e.document,r=e.document.head;for(const s of n)if(!t.getElementById(s)){const a=t.createElement("link");a.rel="stylesheet",a.id=s,a.href=s,r.appendChild(a)}}async function ce(n,e,t=window){const r=t.document,s=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const u of n){const c=r.createElement("script");c.src=u,c.onload=()=>{o=t[e],o&&a(o.default||o)},c.onerror=m=>{i(m)},s.appendChild(c)}})}function le(n){return l.isFunction(n)||l.isFunction(n?.install)}function R(n,e,t=!1,r=!1){try{const s=['"use strict";',"var __self = arguments[0];"];s.push("return ");let o=(n.value||"").trim();o=o.replace(/this(\W|$)/g,(i,u)=>`__self${u}`),o=s.join(`
8
- `)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(s){if(l.logger.error("parseExpression.error",s,n,e?.__self??e),r)throw s}}function L(n,e,t=!1,r=!1){const s=R(n,e,t,r);if(typeof s!="function"&&(l.logger.error("parseFunction.error","not a function",n,e?.__self??e),r))throw new Error(`"${n.value}" not a function`);return s}function S(n){return n&&n.type==="JSExpression"}function O(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function ue(n){return S(n)||O(n)}function be(n){return ue(n)?n.value:JSON.stringify(n)}let b=null;const Fe=l.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:n=>n.data?.code===0||!!n.data?.success,failMessage:!0,showError:n=>{x.ElNotification.error({message:n||"未知错误"})},showLoading:()=>{b&&b.close(),b=x.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{b&&(b.close(),b=null)}}});function pe(n,e){const{jsonp:t,request:r}=e;if(n.method==="jsonp")return(s={})=>t(n.url,{...n.jsonpOptions,query:s});{const s=n.headers?R(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:s}};return(a,i)=>r.send(l.merge(o,i||{},{data:a}))}}function de(n=[],e){return n.reduce((t,r)=>(t[r.id]=pe(r,e),t),{})}function fe(n=[]){T.setup({timeout:"50-500"}),X(),n.forEach(e=>me(e))}function me(n){if(!n.mock)return;const{url:e,mockTemplate:t}=n;if(e&&t){const r=l.pathToRegexp(`${e}(.*)`),s=l.pathToRegexpMatch(e,{decode:decodeURIComponent}),o=R(t,{},!0);T.mock(r,a=>{const i=l.url.parse(a.url)||{},u=a.body instanceof FormData?l.formDataToJson(a.body):a.body,c=s(a.url)?.params;return Object.assign(a,{data:u,params:i,query:c}),T.mock(o(a))})}}function X(){T._mocked={}}class he{__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={};__transform={};constructor(e){const{mode:t,dsl:r,attrs:s}=e;this.__mode=t,r&&(this.__id=r.id||null,this.__transform=r.transform||{}),s&&Object.assign(this,s)}setup(e,t=A){const r=t.getCurrentInstance();if(!r)return;this.__instance=r.proxy;const s=r.appContext.config.globalProperties;Object.assign(this,s),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()})}__proxy(){this.__instance&&J.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){J.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:r}=e,s=t?this.__transform[t]??e.value:e.value;return L({type:r,value:s},this)}else return L(e,this)}__parseExpression(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:r}=e,s=t?this.__transform[t]??e.value:e.value;return R({type:r,value:s},this)}else return R(e,this)}__ref(e=null,t){if(this.__mode!==w.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),r=>{let s=r?.$vtjEl||r?.$el||r;if(!s){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}if(s.nodeType===3&&s.nextSibling&&(s=s.nextSibling),s.__vtj__=e,w.Design===this.__mode&&(s.__context__=this),e&&(this.__refs[e]=r),typeof t=="function")t(r);else if(t){const o=this.$refs[t];if(o){const a=new Set([].concat(o,r));this.$refs[t]=Array.from(a)}else this.$refs[t]=r}return r}}__clone(e={}){const t={...this.context,...e},r={...t,context:t};return r.context.__proto__=this.context,r.__proto__=this,r}}function D(n){const{Vue:e=A,mode:t=w.Runtime,components:r={},libs:s={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),u={$components:r,$libs:s,$apis:o},c=new he({mode:t,dsl:i.value,attrs:u}),m=e.defineComponent({name:i.value.name,props:{...Re(i.value.props??[],c)},setup(d){c.$props=d,c.props=d,i.value.id&&Y(n.window||window,i.value.id,i.value.css||""),c.state=Ie(e,i.value.state??{},c);const f=He(e,i.value.computed??{},c),v=Oe(i.value.methods??{},c),h=Me(e,i.value.inject,c),g=ve(i.value.dataSources||{},c),p={...h,...f,...v,...g};return c.setup(p,e),xe(e,i.value.watch??[],c),{vtj:c}},emits:[...i.value.emits??[]],expose:["vtj"],render(){if(!i.value.nodes)return null;const d=i.value.nodes||[];return d.length===1?H(d[0],c,e,a):d.map(f=>H(f,c,e,a))},...Te(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(m),context:c}}function Re(n=[],e){const t=r=>r?(Array.isArray(r)?r:[r]).map(o=>ne[o]):void 0;return n.map(r=>l.isString(r)?{name:r}:{name:r.name,type:r.type,required:r.required,default:S(r.default)?e.__parseExpression(r.default):r.default}).reduce((r,s)=>(r[s.name]={type:t(s.type),required:s.required,default:s.default},r),{})}function Ie(n,e,t){return n.reactive(Object.keys(e||{}).reduce((r,s)=>{let o=e[s];return S(o)?o=t.__parseExpression(o):O(o)&&(o=t.__parseFunction(o)),r[s]=o,r},{}))}function He(n,e,t){return Object.entries(e??{}).reduce((r,[s,o])=>(r[s]=n.computed(t.__parseFunction(o)),r),{})}function Oe(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}function Me(n,e=[],t){return e.reduce((r,s)=>{const{name:o,from:a}=s||{};s.default;const i=S(a)?t.__parseExpression(a)||o:a??o,u=S(s.default)?t.__parseExpression(s.default):s.default??null;return r[o]=n.inject(i,u),r},{})}function ve(n,e){return Object.keys(n).reduce((t,r)=>{const s=n[r],o=e.$apis[s.ref],a=O(s.transform)?s.transform.value?e.__parseFunction(s.transform):void 0:s.transform;return t[r]=async(...i)=>{const u=await o.apply(e,i);return a?a(u):u},t},{})}function xe(n,e=[],t){e.forEach(r=>{n.watch(t.__parseExpression(r.source),t.__parseFunction(r.handler),{deep:r.deep,immediate:r.immediate})})}function Te(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}let q=[];const ge=n=>n;async function W(n,e=window){const{urls:t=[],library:r}=n,s=t.filter(i=>N(i));if(s.length===0||!r)return null;const o=t.filter(i=>B(i)),a=await ce(s,r,e).catch(()=>null);return a?{component:a,css:o}:null}function k(n){const{getDsl:e,getDslByUrl:t,options:r}=n;return r.window&&(q.forEach(s=>{delete r.window[s]}),q=[]),(s,o,a=A)=>!o||typeof o=="string"?s:o.type==="Schema"&&o.id?a.defineAsyncComponent(async()=>{const i=await e(o.id);return i&&(i.name=s),i?D({...r,Vue:a,dsl:i,mode:w.Runtime,loader:k(n)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=s),i?D({...r,Vue:a,dsl:i,mode:w.Runtime,loader:k(n)}).renderer:null}):o.type==="Plugin"?(o.library&&q.push(o.library),a.defineAsyncComponent(async()=>{const i=await W(o,r.window);return i?(K(i.css,r.window),i.component):null})):s}function H(n,e,t=A,r=ge){if(!n||!n.name||n.invisible)return null;const{id:s=null,directives:o=[]}=n,{vIf:a,vFor:i,vShow:u,vModels:c,vBind:m}=De(o);if(a&&!ke(a,e))return null;const d=f=>{const v=f.$components,h=(()=>{if(n.name==="component")return Ae(f,n.props?.is);if(n.name==="slot")return n.name;const _=r(n.name,n.from,t);return l.isString(_)?v[_]??_:_})(),g=Be(s,n.props??{},f),p=Ne(t,n.events??{},f);if(n.name==="slot")return Ue(t,n,g,f,r);m&&Object.assign(g,f.__parseExpression(m.value)),u&&(g.style=Object.assign(g.style??{},Je(u,f))),c.forEach(_=>{Object.assign(g,Le(t,_,f))});const $=Ve(t,n.children??[],f,r,n);return t.createVNode(h,{...g,...p},$)};return i?Xe(i,d,e):d(e)}function De(n=[]){const e=n.find(i=>l.camelCase(i.name)==="vIf"),t=n.find(i=>l.camelCase(i.name)==="vFor"),r=n.find(i=>l.camelCase(i.name)==="vShow"),s=n.find(i=>l.camelCase(i.name)==="vBind"),o=n.filter(i=>l.camelCase(i.name)==="vModel"),a=n.filter(i=>!re.includes(l.camelCase(i.name)));return{vIf:e,vFor:t,vShow:r,vModels:o,vBind:s,others:a}}function ke(n,e){return!!e.__parseExpression(n.value)}function Ae(n,e){return e?S(e)?n.__parseExpression(e):e:"div"}function Be(n,e,t){const r=Object.keys(e||{}).reduce((s,o)=>{let a=e[o];return S(a)?a=t.__parseExpression(a):O(a)&&(a=t.__parseFunction(a)),s[o]=a,s},{});return r.ref=t.__ref(n,r.ref),r}function Ne(n,e,t){const r=["passive","capture","once"],s={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],u=z(i.modifiers),c=u.find(f=>r.includes(f)),m="on"+l.upperFirst(a)+(c&&s[c]||""),d=t.__parseFunction(i.handler);return d&&(o[m]=n.withModifiers(d,u)),o},{})}function z(n={},e=!1){const t=Object.keys(n);return e?t.map(r=>"."+r):t}function Ue(n,e,t,r,s){const{children:o}=e,a=qe(e,r),i=r.$slots?.[a.name];return i?i(t):o?l.isString(o)?n.createTextVNode(o):S(o)?n.createTextVNode(V(r.__parseExpression(o))):Array.isArray(o)?o.map(u=>H(u,r,n,s)):null:null}function qe(n,e){const{props:t}=n,r=t?.name||"default";return{name:S(r)?e.__parseExpression(r):r,params:[]}}function Je(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Le(n,e,t){const r={type:"JSFunction",value:e.value?.value?`(v) => {
7
+ */const F="0.8.28";var w=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(w||{});const L=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],Pe=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],ne=["vIf","vShow","vModel","vFor","vBind"],se={String,Number,Boolean,Array,Object,Function,Date};function M(n,e){return n.map(t=>l.isUrl(t)?t:`${e}${t}`)}function N(n){return/\.css$/.test(n)}function U(n){return/\.js$/.test(n)}function oe(n){return/\.json$/.test(n)}function be(n){return n.map(e=>`<script src="${l.url.append(e,{v:F})}"><\/script>`).join("")}function Fe(n=[]){return n.map(e=>`<link rel="stylesheet" href="${l.url.append(e,{v:F})}" />`).join("")}function ie(n,e){const t=n.filter(p=>!!p.enabled),r=[],s=[],o=[],a=[],i={},u={},c=[],m={};return t.forEach(({urls:p,assetsUrl:d,library:v,assetsLibrary:$,localeLibrary:h})=>{p?.forEach(S=>{U(S)&&r.push(S),N(S)&&s.push(S)}),v&&(a.push(v),i[v]=M(p||[],e),h&&(u[v]=h)),d&&o.push(d),$&&c.push($),v&&$&&(m[$]=v)}),{scripts:M(r,e),css:M(s,e),materials:M(o,e),libraryExports:a,materialExports:l.dedupArray(c),materialMapLibrary:m,libraryMap:i,libraryLocaleMap:u}}function ae(n,e){const{name:t,parent:r,alias:s}=n;return r?e[r]?.[s||t]:e[s||t]}function Y(n){return l.isString(n)?n:JSON.stringify(n)}function K(n,e,t){const r=n.CSSStyleSheet;if(r.prototype.replaceSync){const s=new r;s.id=e,s.replaceSync(t);const o=n.document,a=o.adoptedStyleSheets,i=Array.from(a).filter(u=>u.id!==e);o.adoptedStyleSheets=[...i,s]}else{const s=n.document;let o=s.getElementById(e);o?o.innerHTML=t:(o=s.createElement("style"),o.id=e,o.innerHTML=t,s.head.appendChild(o))}}async function ce(n,e){const t=await window.fetch(e).then(r=>r.text()).catch(()=>"");t&&K(window,n,t)}function X(n,e=window){const t=e.document,r=e.document.head;for(const s of n)if(!t.getElementById(s)){const a=t.createElement("link");a.rel="stylesheet",a.id=s,a.href=s,r.appendChild(a)}}async function le(n,e,t=window){const r=t.document,s=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const u of n){const c=r.createElement("script");c.src=u,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=m=>{i(m)},s.appendChild(c)}})}function ue(n){return l.isFunction(n)||l.isFunction(n?.install)}function R(n,e,t=!1,r=!1){try{const s=['"use strict";',"var __self = arguments[0];"];s.push("return ");let o=(n.value||"").trim();o=o.replace(/this(\W|$)/g,(i,u)=>`__self${u}`),o=s.join(`
8
+ `)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(s){if(l.logger.error("parseExpression.error",s,n,e?.__self??e),r)throw s}}function V(n,e,t=!1,r=!1){const s=R(n,e,t,r);if(typeof s!="function"&&(l.logger.error("parseFunction.error","not a function",n,e?.__self??e),r))throw new Error(`"${n.value}" not a function`);return s}function _(n){return n&&n.type==="JSExpression"}function O(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function pe(n){return _(n)||O(n)}function Re(n){return pe(n)?n.value:JSON.stringify(n)}let b=null;const Ie=l.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:n=>n.data?.code===0||!!n.data?.success,failMessage:!0,showError:n=>{T.ElNotification.error({message:n||"未知错误"})},showLoading:()=>{b&&b.close(),b=T.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{b&&(b.close(),b=null)}}});function de(n,e){const{jsonp:t,request:r}=e;if(n.method==="jsonp")return(s={})=>t(n.url,{...n.jsonpOptions,query:s});{const s=n.headers?R(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:s}};return(a,i)=>r.send(l.merge(o,i||{},{data:a}))}}function fe(n,e){const{metaQuery:t}=e;if(!t)return;const{code:r,queryCode:s}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(r,s,o,a)}}function me(n=[],e=[],t){const r={};for(const s of n)r[s.id]=de(s,t);for(const s of e)r[s.id]=fe(s,t);return r}function he(n=[]){D.setup({timeout:"50-500"}),Q(),n.forEach(e=>ve(e))}function ve(n){if(!n.mock)return;const{url:e,mockTemplate:t}=n;if(e&&t){const r=l.pathToRegexp(`${e}(.*)`),s=l.pathToRegexpMatch(e,{decode:decodeURIComponent}),o=R(t,{},!0);D.mock(r,a=>{const i=l.url.parse(a.url)||{},u=a.body instanceof FormData?l.formDataToJson(a.body):a.body,c=s(a.url)?.params;return Object.assign(a,{data:u,params:i,query:c}),D.mock(o(a))})}}function Q(){D._mocked={}}class ge{__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={};__transform={};constructor(e){const{mode:t,dsl:r,attrs:s}=e;this.__mode=t,r&&(this.__id=r.id||null,this.__transform=r.transform||{}),s&&Object.assign(this,s)}setup(e,t=B){const r=t.getCurrentInstance();if(!r)return;this.__instance=r.proxy;const s=r.appContext.config.globalProperties;Object.assign(this,s),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()})}__proxy(){this.__instance&&L.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){L.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:r}=e,s=t?this.__transform[t]??e.value:e.value;return V({type:r,value:s},this)}else return V(e,this)}__parseExpression(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:r}=e,s=t?this.__transform[t]??e.value:e.value;return R({type:r,value:s},this)}else return R(e,this)}__ref(e=null,t){if(this.__mode!==w.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),r=>{let s=r?.$vtjEl||r?.$el||r;if(!s){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}if(s.nodeType===3&&s.nextSibling&&(s=s.nextSibling),s.__vtj__=e,w.Design===this.__mode&&(s.__context__=this),e&&(this.__refs[e]=r),typeof t=="function")t(r);else if(t){const o=this.$refs[t];if(o){const a=new Set([].concat(o,r));this.$refs[t]=Array.from(a)}else this.$refs[t]=r}return r}}__clone(e={}){const t={...this.context,...e},r={...t,context:t};return r.context.__proto__=this.context,r.__proto__=this,r}}function A(n){const{Vue:e=B,mode:t=w.Runtime,components:r={},libs:s={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),u={$components:r,$libs:s,$apis:o},c=new ge({mode:t,dsl:i.value,attrs:u}),m=e.defineComponent({name:i.value.name,props:{...Me(i.value.props??[],c)},setup(p){c.$props=p,c.props=p,i.value.id&&K(n.window||window,i.value.id,i.value.css||""),c.state=He(e,i.value.state??{},c);const d=Oe(e,i.value.computed??{},c),v=xe(i.value.methods??{},c),$=Te(e,i.value.inject,c),h=ye(i.value.dataSources||{},c),S={...$,...d,...v,...h};return c.setup(S,e),De(e,i.value.watch??[],c),{vtj:c}},emits:[...i.value.emits??[]],expose:["vtj"],render(){if(!i.value.nodes)return null;const p=i.value.nodes||[];return p.length===1?H(p[0],c,e,a):p.map(d=>H(d,c,e,a))},...Ae(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(m),context:c}}function Me(n=[],e){const t=r=>r?(Array.isArray(r)?r:[r]).map(o=>se[o]):void 0;return n.map(r=>l.isString(r)?{name:r}:{name:r.name,type:r.type,required:r.required,default:_(r.default)?e.__parseExpression(r.default):r.default}).reduce((r,s)=>(r[s.name]={type:t(s.type),required:s.required,default:s.default},r),{})}function He(n,e,t){return n.reactive(Object.keys(e||{}).reduce((r,s)=>{let o=e[s];return _(o)?o=t.__parseExpression(o):O(o)&&(o=t.__parseFunction(o)),r[s]=o,r},{}))}function Oe(n,e,t){return Object.entries(e??{}).reduce((r,[s,o])=>(r[s]=n.computed(t.__parseFunction(o)),r),{})}function xe(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}function Te(n,e=[],t){return e.reduce((r,s)=>{const{name:o,from:a}=s||{};s.default;const i=_(a)?t.__parseExpression(a)||o:a??o,u=_(s.default)?t.__parseExpression(s.default):s.default??null;return r[o]=n.inject(i,u),r},{})}function ye(n,e){return Object.keys(n).reduce((t,r)=>{const s=n[r],o=e.$apis[s.ref],a=O(s.transform)?s.transform.value?e.__parseFunction(s.transform):void 0:s.transform;return t[r]=async(...i)=>{const u=await o.apply(e,i);return a?a(u):u},t},{})}function De(n,e=[],t){e.forEach(r=>{n.watch(t.__parseExpression(r.source),t.__parseFunction(r.handler),{deep:r.deep,immediate:r.immediate})})}function Ae(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}let J=[];const _e=n=>n;async function W(n,e=window){const{urls:t=[],library:r}=n,s=t.filter(i=>U(i));if(s.length===0||!r)return null;const o=t.filter(i=>N(i)),a=await le(s,r,e).catch(()=>null);return a?{component:a,css:o}:null}function k(n){const{getDsl:e,getDslByUrl:t,options:r}=n;return r.window&&(J.forEach(s=>{delete r.window[s]}),J=[]),(s,o,a=B)=>!o||typeof o=="string"?s:o.type==="Schema"&&o.id?a.defineAsyncComponent(async()=>{const i=await e(o.id);return i&&(i.name=s),i?A({...r,Vue:a,dsl:i,mode:w.Runtime,loader:k(n)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=s),i?A({...r,Vue:a,dsl:i,mode:w.Runtime,loader:k(n)}).renderer:null}):o.type==="Plugin"?(o.library&&J.push(o.library),a.defineAsyncComponent(async()=>{const i=await W(o,r.window);return i?(X(i.css,r.window),i.component):null})):s}function H(n,e,t=B,r=_e){if(!n||!n.name||n.invisible)return null;const{id:s=null,directives:o=[]}=n,{vIf:a,vFor:i,vShow:u,vModels:c,vBind:m}=ke(o);if(a&&!Be(a,e))return null;const p=d=>{const v=d.$components,$=(()=>{if(n.name==="component")return Ne(d,n.props?.is);if(n.name==="slot")return n.name;const g=r(n.name,n.from,t);return l.isString(g)?v[g]??g:g})(),h=Ue(s,n.props??{},d),S=qe(t,n.events??{},d);if(n.name==="slot")return Je(t,n,h,d,r);m&&Object.assign(h,d.__parseExpression(m.value)),u&&(h.style=Object.assign(h.style??{},Ve(u,d))),c.forEach(g=>{Object.assign(h,Ye(t,g,d))});const f=Ke(t,n.children??[],d,r,n);return t.createVNode($,{...h,...S},f)};return i?We(i,p,e):p(e)}function ke(n=[]){const e=n.find(i=>l.camelCase(i.name)==="vIf"),t=n.find(i=>l.camelCase(i.name)==="vFor"),r=n.find(i=>l.camelCase(i.name)==="vShow"),s=n.find(i=>l.camelCase(i.name)==="vBind"),o=n.filter(i=>l.camelCase(i.name)==="vModel"),a=n.filter(i=>!ne.includes(l.camelCase(i.name)));return{vIf:e,vFor:t,vShow:r,vModels:o,vBind:s,others:a}}function Be(n,e){return!!e.__parseExpression(n.value)}function Ne(n,e){return e?_(e)?n.__parseExpression(e):e:"div"}function Ue(n,e,t){const r=Object.keys(e||{}).reduce((s,o)=>{let a=e[o];return _(a)?a=t.__parseExpression(a):O(a)&&(a=t.__parseFunction(a)),s[o]=a,s},{});return r.ref=t.__ref(n,r.ref),r}function qe(n,e,t){const r=["passive","capture","once"],s={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],u=z(i.modifiers),c=u.find(d=>r.includes(d)),m="on"+l.upperFirst(a)+(c&&s[c]||""),p=t.__parseFunction(i.handler);return p&&(o[m]=n.withModifiers(p,u)),o},{})}function z(n={},e=!1){const t=Object.keys(n);return e?t.map(r=>"."+r):t}function Je(n,e,t,r,s){const{children:o}=e,a=Le(e,r),i=r.$slots?.[a.name];return i?i(t):o?l.isString(o)?n.createTextVNode(o):_(o)?n.createTextVNode(Y(r.__parseExpression(o))):Array.isArray(o)?o.map(u=>H(u,r,n,s)):null:null}function Le(n,e){const{props:t}=n,r=t?.name||"default";return{name:_(r)?e.__parseExpression(r):r,params:[]}}function Ve(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ye(n,e,t){const r={type:"JSFunction",value:e.value?.value?`(v) => {
9
9
  ${e.value.value} = v;
10
- }`:"(v) => {}"},s=t.__parseFunction(r),o=z(e.modifiers),a=S(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&s?n.withModifiers(s,o):s}}function Ve(n,e,t,r,s){if(!e)return null;if(l.isString(e))return{default:()=>e};if(S(e))return{default:()=>V(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=Ye(e),a=i=>!i||!s?{}:s?.id&&Object.keys(i).length?{[`scope_${s.id}`]:i}:{};return Object.entries(o).reduce((i,[u,{nodes:c,params:m}])=>(i[u]=d=>{const f=m.length?l.pick(d??{},m):a(d);return c.map(v=>H(v,t.__clone(f),n,r))},i),{})}return null}function Ye(n){const e={default:{params:[],nodes:[]}};for(const t of n){const r=Ke(t.slot),s=r.name;e[s]?(e[s].nodes.push(t),e[s].params=e[s].params.concat(r.params)):e[s]={nodes:[t],params:r.params}}return e}function Ke(n="default"){return l.isString(n)?{name:n,params:[]}:{params:[],...n}}function Xe(n,e,t){const{value:r,iterator:s}=n,{item:o="item",index:a="index"}=s||{};let i=t.__parseExpression(r)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((u,c)=>c+1)),Array.isArray(i)?i.map((u,c)=>e(t.__clone({[o]:u,[a]:c}))):(console.warn("[vForRender]:",`${r?.value} is not a Arrary`),[])}const ee=j.defineComponent({name:"VtjPageContainer",async setup(){const n=Q(),e=te.useRoute(),t=e.params.id,r=t?n.getPage(t):n.getHomepage(),s=r?await n.getRenderComponent(r.id):null;return r&&we.useTitle(r.title||"VTJ"),{provider:n,component:s,file:r,query:e.query}},render(){return this.component?j.h(this.component,this.query):j.h("div","页面不存在")}}),We=j.defineComponent({name:"VtjStartupContainer",render(){return j.h(je.XStartup)}}),G=Symbol("Provider");class ye extends E.Base{mode;globals={};modules={};adapter={request:Fe,jsonp:l.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};constructor(e){super();const{service:t,mode:r=w.Raw,dependencies:s,materials:o,project:a={},adapter:i={},globals:u={},modules:c={},router:m=null,materialPath:d="./",nodeEnv:f="development"}=e;this.mode=r,this.modules=c,this.service=t,this.router=m,this.materialPath=d,this.nodeEnv=f,s&&(this.dependencies=s),o&&(this.materials=o),Object.assign(this.globals,u),Object.assign(this.adapter,i),r!==w.Design&&this.load(a)}async load(e){const t=this.modules[`.vtj/projects/${e.id}.json`];if(this.project=t?await t():await this.service.init(e),!this.project)throw new Error("project is null");const{dependencies:r=[],apis:s}=this.project,{dependencies:o,library:a,components:i,materialPath:u}=this,{libraryExports:c,libraryMap:m,materials:d,materialExports:f,materialMapLibrary:v}=oe(r,u),h=window;h.CKEDITOR_VERSION=void 0;for(const p of c){const $=o[p],_=h[p];if(_)a[p]=_;else if($)h[p]=a[p]=await $();else{const C=m[p]||[];for(const P of C)B(P)&&await ae(p,l.url.append(P,{v:F})),N(P)&&await l.loadScript(l.url.append(P,{v:F}));a[p]=h[p]}}for(const p of d)await l.loadScript(l.url.append(p,{v:F}));const g=this.materials||{};for(const p of f){const $=h[v[p]],_=E.BUILT_IN_COMPONENTS[p];if(_)$&&_.forEach(C=>{i[C]=$[C]});else{const C=g[p]?(await g[p]()).default:h[p];C&&$&&(C.components||[]).forEach(P=>{i[P.name]=ie(P,$)})}}s&&(this.apis=de(s,this.adapter),X(),this.project.config?.mock&&fe(s)),this.initRouter(),this.triggerReady()}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:ee}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?ee:We}))}install(e){const t=e.config.globalProperties.installed||{};for(const[r,s]of Object.entries(this.library))!t[r]&&le(s)&&(e.use(s),t[r]=!0);e.provide(G,this),e.config.globalProperties.installed=t}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(r=>r.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},r=(s,o=[])=>{for(const a of o){if(a.id===s)return a;if(a.children&&a.children.length){const i=r(s,a.children);if(i)return i}}};return r(e,t)||null}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):null}async getDsl(e){const t=this.modules[`.vtj/files/${e}.json`];return t?await t():this.service.getFile(e).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(r=>r.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:r,components:s,mode:o,apis:a}=this,i={mode:o,Vue:r.Vue,components:s,libs:r,apis:a,window,...t},u=k({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return D({...i,dsl:e,loader:u})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return l.logger.warn(`Can not find file: ${e}`),null;const r=`.vtj/vue/${e}.vue`,s=this.modules[r];if(s)return(await s())?.default;const o=await this.getDsl(t.id);return o?this.createDslRenderer(o).renderer:(l.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return j.defineAsyncComponent(async()=>{const r=await this.getDslByUrl(e);return r?(r.name=t||r.name,this.createDslRenderer(r).renderer):null})}definePluginComponent(e){return j.defineAsyncComponent(async()=>{const t=await W(e,window);return t?(K(t.css),t.component):null})}}function ze(n){const e=new ye(n);return{provider:e,onReady:r=>e.ready(r)}}function Q(n={}){const e=j.inject(G);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:r}=n;t&&r&&(async()=>{const s=await e.getDsl(t);s?.__VERSION__!==r&&x.ElNotification.warning({title:s?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const Z=new l.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0,showError:n=>{x.ElNotification.error({message:n||"未知错误"})}}}),Ge=(n="/vtj/local/repository/${type}.json")=>(e,t)=>Z.send({url:n,method:"post",query:{type:e},data:{type:e,data:t}}),Qe=(n="/vtj/local/repository/uploader.json")=>async(e,t)=>await Z.send({url:n,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);class U{api;pluginCaches={};uploader;constructor(){this.api=Ge(),this.uploader=Qe()}async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e){return!!await this.api("saveProject",e).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 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,r=t.filter(o=>se(o))[0];if(!r)return null;const s=this.pluginCaches[r];return s||(this.pluginCaches[r]=Z.send({url:r,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const y=new l.Storage({type:"local",expired:0,prefix:"__VTJ_"});class Ze extends U{init(e){const t=new E.ProjectModel(e),r=y.get(`project_${t.id}`),s=Object.assign(t.toDsl(),r||{});return y.save(`project_${t.id}`,s),Promise.resolve(s)}saveProject(e){const t=new E.ProjectModel(e);return y.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return y.save(`materials_${e.id}`,l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return y.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=y.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return y.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return y.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=y.get(`history_${e}`);if(t){const s=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,s),y.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=y.get(`history_${e}`),r=new E.HistoryModel(t||{id:e});return Promise.resolve(r.toDsl())}getHistoryItem(e,t){const r=y.get(`history_${e}_${t}`);return Promise.resolve(r)}saveHistoryItem(e,t){return y.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(r=>{y.remove(`history_${e}_${r}`)}),Promise.resolve(!0)}}class _e extends U{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new E.ProjectModel(e),r=this.projects[t.id]||{},s=Object.assign(t.toDsl(),r);return this.projects[s.id]=s,Promise.resolve(s)}saveProject(e){const t=new E.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=l.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 s=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,s),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],r=new E.HistoryModel(t||{id:e});return Promise.resolve(r)}getHistoryItem(e,t){const r=`${e}_${t}`,s=this.historyItems[r]||{};return Promise.resolve(s)}saveHistoryItem(e,t){const r=`${e}_${t.id}`;return this.historyItems[r]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(r=>{const s=`${e}_${r}`;delete this.historyItems[s]}),Promise.resolve(!0)}}let M=null;function et(){return M||(M=new _e,M)}class tt extends U{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:l.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)}}function Se(n=[]){return n.map(e=>{const{id:t,title:r,icon:s,children:o,hidden:a}=e;return{id:t,title:r,icon:s,hidden:a,url:`/page/${t}`,children:o&&o.length?Se(o):void 0}})}function rt(){const n=Q(),e=te.useRoute(),t=j.ref(!1),r=n.project;j.watchEffect(()=>{const{name:a,params:i,meta:u}=e;if(a==="VtjPage"){const c=n.getPage(i.id);t.value=!c?.mask}else if(a==="VtjHomepage"){const c=n.getHomepage();t.value=!c?.mask}else t.value=!u.mask});const s=Se(r?.pages),o=r?.config;return{disabled:t,logo:o?.logo,themeSwitchable:o?.themeSwitchable,title:o?.title||r?.description||r?.name||"VTJ App",menus:s}}exports.BUILT_IN_DIRECTIVES=re;exports.BaseService=U;exports.CONTEXT_HOST=J;exports.Context=he;exports.ContextMode=w;exports.DATA_TYPES=ne;exports.JSCodeToString=be;exports.LIFE_CYCLES_LIST=Ee;exports.LocalService=tt;exports.MemoryService=_e;exports.Provider=ye;exports.StorageService=Ze;exports.VTJ_RENDERER_VERSION=F;exports.adoptedStyleSheets=Y;exports.createAssetScripts=Ce;exports.createAssetsCss=Pe;exports.createDataSources=ve;exports.createLoader=k;exports.createMemoryService=et;exports.createProvider=ze;exports.createRenderer=D;exports.createSchemaApi=pe;exports.createSchemaApis=de;exports.defaultLoader=ge;exports.fillBasePath=I;exports.getModifiers=z;exports.getPlugin=W;exports.getRawComponent=ie;exports.isCSSUrl=B;exports.isJSCode=ue;exports.isJSExpression=S;exports.isJSFunction=O;exports.isJSON=se;exports.isJSUrl=N;exports.isVuePlugin=le;exports.loadCss=ae;exports.loadCssUrl=K;exports.loadScriptUrl=ce;exports.mockApi=me;exports.mockApis=fe;exports.mockCleanup=X;exports.nodeRender=H;exports.parseDeps=oe;exports.parseExpression=R;exports.parseFunction=L;exports.providerKey=G;exports.toString=V;exports.useMask=rt;exports.useProvider=Q;
10
+ }`:"(v) => {}"},s=t.__parseFunction(r),o=z(e.modifiers),a=_(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&s?n.withModifiers(s,o):s}}function Ke(n,e,t,r,s){if(!e)return null;if(l.isString(e))return{default:()=>e};if(_(e))return{default:()=>Y(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=Xe(e),a=i=>!i||!s?{}:s?.id&&Object.keys(i).length?{[`scope_${s.id}`]:i}:{};return Object.entries(o).reduce((i,[u,{nodes:c,params:m}])=>(i[u]=p=>{const d=m.length?l.pick(p??{},m):a(p);return c.map(v=>H(v,t.__clone(d),n,r))},i),{})}return null}function Xe(n){const e={default:{params:[],nodes:[]}};for(const t of n){const r=Qe(t.slot),s=r.name;e[s]?(e[s].nodes.push(t),e[s].params=e[s].params.concat(r.params)):e[s]={nodes:[t],params:r.params}}return e}function Qe(n="default"){return l.isString(n)?{name:n,params:[]}:{params:[],...n}}function We(n,e,t){const{value:r,iterator:s}=n,{item:o="item",index:a="index"}=s||{};let i=t.__parseExpression(r)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((u,c)=>c+1)),Array.isArray(i)?i.map((u,c)=>e(t.__clone({[o]:u,[a]:c}))):(console.warn("[vForRender]:",`${r?.value} is not a Arrary`),[])}const te=j.defineComponent({name:"VtjPageContainer",async setup(){const n=Z(),e=re.useRoute(),t=e.params.id,r=t?n.getPage(t):n.getHomepage(),s=r?await n.getRenderComponent(r.id):null;return r&&$e.useTitle(r.title||"VTJ"),{provider:n,component:s,file:r,query:e.query}},render(){return this.component?j.h(this.component,this.query):j.h("div","页面不存在")}}),ze=j.defineComponent({name:"VtjStartupContainer",render(){return j.h(Ee.XStartup)}}),G=Symbol("Provider");class Se extends E.Base{mode;globals={};modules={};adapter={request:Ie,jsonp:l.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};constructor(e){super();const{service:t,mode:r=w.Raw,dependencies:s,materials:o,project:a={},adapter:i={},globals:u={},modules:c={},router:m=null,materialPath:p="./",nodeEnv:d="development"}=e;this.mode=r,this.modules=c,this.service=t,this.router=m,this.materialPath=p,this.nodeEnv=d,s&&(this.dependencies=s),o&&(this.materials=o),Object.assign(this.globals,u),Object.assign(this.adapter,i),r!==w.Design&&this.load(a)}async load(e){const t=this.modules[`.vtj/projects/${e.id}.json`];if(this.project=t?await t():await this.service.init(e),!this.project)throw new Error("project is null");const{dependencies:r=[],apis:s=[],meta:o=[]}=this.project,{dependencies:a,library:i,components:u,materialPath:c}=this,{libraryExports:m,libraryMap:p,materials:d,materialExports:v,materialMapLibrary:$}=ie(r,c),h=window;h.CKEDITOR_VERSION=void 0;for(const f of m){const g=a[f],I=h[f];if(I)i[f]=I;else if(g)h[f]=i[f]=await g();else{const C=p[f]||[];for(const P of C)N(P)&&await ce(f,l.url.append(P,{v:F})),U(P)&&await l.loadScript(l.url.append(P,{v:F}));i[f]=h[f]}}for(const f of d)await l.loadScript(l.url.append(f,{v:F}));const S=this.materials||{};for(const f of v){const g=h[$[f]],I=E.BUILT_IN_COMPONENTS[f];if(I)g&&I.forEach(C=>{u[C]=g[C]});else{const C=S[f]?(await S[f]()).default:h[f];C&&g&&(C.components||[]).forEach(P=>{u[P.name]=ae(P,g)})}}this.apis=me(s,o,this.adapter),Q(),this.project.config?.mock&&he(s),this.initRouter(),this.triggerReady()}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:te}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?te:ze}))}install(e){const t=e.config.globalProperties.installed||{};for(const[r,s]of Object.entries(this.library))!t[r]&&ue(s)&&(e.use(s),t[r]=!0);e.provide(G,this),e.config.globalProperties.installed=t}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(r=>r.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},r=(s,o=[])=>{for(const a of o){if(a.id===s)return a;if(a.children&&a.children.length){const i=r(s,a.children);if(i)return i}}};return r(e,t)||null}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):null}async getDsl(e){const t=this.modules[`.vtj/files/${e}.json`];return t?await t():this.service.getFile(e).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(r=>r.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:r,components:s,mode:o,apis:a}=this,i={mode:o,Vue:r.Vue,components:s,libs:r,apis:a,window,...t},u=k({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return A({...i,dsl:e,loader:u})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return l.logger.warn(`Can not find file: ${e}`),null;const r=`.vtj/vue/${e}.vue`,s=this.modules[r];if(s)return(await s())?.default;const o=await this.getDsl(t.id);return o?this.createDslRenderer(o).renderer:(l.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return j.defineAsyncComponent(async()=>{const r=await this.getDslByUrl(e);return r?(r.name=t||r.name,this.createDslRenderer(r).renderer):null})}definePluginComponent(e){return j.defineAsyncComponent(async()=>{const t=await W(e,window);return t?(X(t.css),t.component):null})}}function Ge(n){const e=new Se(n);return{provider:e,onReady:r=>e.ready(r)}}function Z(n={}){const e=j.inject(G);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:r}=n;t&&r&&(async()=>{const s=await e.getDsl(t);s?.__VERSION__!==r&&T.ElNotification.warning({title:s?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const ee=new l.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0,showError:n=>{T.ElNotification.error({message:n||"未知错误"})}}}),Ze=(n="/vtj/local/repository/${type}.json")=>(e,t)=>ee.send({url:n,method:"post",query:{type:e},data:{type:e,data:t}}),et=(n="/vtj/local/repository/uploader.json")=>async(e,t)=>await ee.send({url:n,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);class q{api;pluginCaches={};uploader;constructor(){this.api=Ze(),this.uploader=et()}async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e){return!!await this.api("saveProject",e).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 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,r=t.filter(o=>oe(o))[0];if(!r)return null;const s=this.pluginCaches[r];return s||(this.pluginCaches[r]=ee.send({url:r,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const y=new l.Storage({type:"local",expired:0,prefix:"__VTJ_"});class tt extends q{init(e){const t=new E.ProjectModel(e),r=y.get(`project_${t.id}`),s=Object.assign(t.toDsl(),r||{});return y.save(`project_${t.id}`,s),Promise.resolve(s)}saveProject(e){const t=new E.ProjectModel(e);return y.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return y.save(`materials_${e.id}`,l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return y.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=y.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return y.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return y.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=y.get(`history_${e}`);if(t){const s=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,s),y.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=y.get(`history_${e}`),r=new E.HistoryModel(t||{id:e});return Promise.resolve(r.toDsl())}getHistoryItem(e,t){const r=y.get(`history_${e}_${t}`);return Promise.resolve(r)}saveHistoryItem(e,t){return y.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(r=>{y.remove(`history_${e}_${r}`)}),Promise.resolve(!0)}}class we extends q{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new E.ProjectModel(e),r=this.projects[t.id]||{},s=Object.assign(t.toDsl(),r);return this.projects[s.id]=s,Promise.resolve(s)}saveProject(e){const t=new E.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=l.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 s=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,s),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],r=new E.HistoryModel(t||{id:e});return Promise.resolve(r)}getHistoryItem(e,t){const r=`${e}_${t}`,s=this.historyItems[r]||{};return Promise.resolve(s)}saveHistoryItem(e,t){const r=`${e}_${t.id}`;return this.historyItems[r]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(r=>{const s=`${e}_${r}`;delete this.historyItems[s]}),Promise.resolve(!0)}}let x=null;function rt(){return x||(x=new we,x)}class nt 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){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:l.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)}}function je(n=[]){return n.map(e=>{const{id:t,title:r,icon:s,children:o,hidden:a}=e;return{id:t,title:r,icon:s,hidden:a,url:`/page/${t}`,children:o&&o.length?je(o):void 0}})}function st(){const n=Z(),e=re.useRoute(),t=j.ref(!1),r=n.project;j.watchEffect(()=>{const{name:a,params:i,meta:u}=e;if(a==="VtjPage"){const c=n.getPage(i.id);t.value=!c?.mask}else if(a==="VtjHomepage"){const c=n.getHomepage();t.value=!c?.mask}else t.value=!u.mask});const s=je(r?.pages),o=r?.config;return{disabled:t,logo:o?.logo,themeSwitchable:o?.themeSwitchable,title:o?.title||r?.description||r?.name||"VTJ App",menus:s}}exports.BUILT_IN_DIRECTIVES=ne;exports.BaseService=q;exports.CONTEXT_HOST=L;exports.Context=ge;exports.ContextMode=w;exports.DATA_TYPES=se;exports.JSCodeToString=Re;exports.LIFE_CYCLES_LIST=Pe;exports.LocalService=nt;exports.MemoryService=we;exports.Provider=Se;exports.StorageService=tt;exports.VTJ_RENDERER_VERSION=F;exports.adoptedStyleSheets=K;exports.createAssetScripts=be;exports.createAssetsCss=Fe;exports.createDataSources=ye;exports.createLoader=k;exports.createMemoryService=rt;exports.createMetaApi=fe;exports.createProvider=Ge;exports.createRenderer=A;exports.createSchemaApi=de;exports.createSchemaApis=me;exports.defaultLoader=_e;exports.fillBasePath=M;exports.getModifiers=z;exports.getPlugin=W;exports.getRawComponent=ae;exports.isCSSUrl=N;exports.isJSCode=pe;exports.isJSExpression=_;exports.isJSFunction=O;exports.isJSON=oe;exports.isJSUrl=U;exports.isVuePlugin=ue;exports.loadCss=ce;exports.loadCssUrl=X;exports.loadScriptUrl=le;exports.mockApi=ve;exports.mockApis=he;exports.mockCleanup=Q;exports.nodeRender=H;exports.parseDeps=ie;exports.parseExpression=R;exports.parseFunction=V;exports.providerKey=G;exports.toString=Y;exports.useMask=st;exports.useProvider=Z;