@vtj/renderer 0.8.114 → 0.8.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,9 +2,9 @@
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.114
5
+ * @version 0.8.116
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const P="0.8.114";var w=(r=>(r.Runtime="Runtime",r.Design="Design",r.Raw="Raw",r.VNode="VNode",r))(w||{});const U=["$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"],te=["vIf","vShow","vModel","vFor","vBind"],ne={String,Number,Boolean,Array,Object,Function,Date};function R(r,e){return r.map(t=>u.isUrl(t)?t:`${e}${t}`)}function A(r){return/\.css$/.test(r)}function k(r){return/\.js$/.test(r)}function re(r){return/\.json$/.test(r)}function Ce(r){return r.map(e=>`<script src="${u.url.append(e,{v:P})}"><\/script>`).join("")}function Pe(r=[]){return r.map(e=>`<link rel="stylesheet" href="${u.url.append(e,{v:P})}" />`).join("")}function se(r,e){const t=r.filter(d=>!!d.enabled),n=[],s=[],o=[],a=[],i={},l={},c=[],h={};return t.forEach(({urls:d,assetsUrl:f,library:p,assetsLibrary:g,localeLibrary:v})=>{d?.forEach(y=>{k(y)&&n.push(y),A(y)&&s.push(y)}),p&&(a.push(p),i[p]=R(d||[],e),v&&(l[p]=v)),f&&o.push(f),g&&c.push(g),p&&g&&(h[g]=p)}),{scripts:R(n,e),css:R(s,e),materials:R(o,e),libraryExports:a,materialExports:u.dedupArray(c),materialMapLibrary:h,libraryMap:i,libraryLocaleMap:l}}function oe(r,e){const{name:t,parent:n,alias:s}=r;return n?e[n]?.[s||t]:e[s||t]}function J(r){return u.isString(r)?r:JSON.stringify(r)}function L(r,e,t){const n=r.CSSStyleSheet;if(n.prototype.replaceSync){const s=new n;s.id=e,s.replaceSync(t);const o=r.document,a=o.adoptedStyleSheets,i=Array.from(a).filter(l=>l.id!==e);o.adoptedStyleSheets=[...i,s]}else{const s=r.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 ie(r,e){const t=await window.fetch(e).then(n=>n.text()).catch(()=>"");t&&L(window,r,t)}function V(r,e=window){const t=e.document,n=e.document.head;for(const s of r)if(!t.getElementById(s)){const a=t.createElement("link");a.rel="stylesheet",a.id=s,a.href=s,n.appendChild(a)}}async function ae(r,e,t=window){const n=t.document,s=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const l of r){const c=n.createElement("script");c.src=l,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=h=>{i(h)},s.appendChild(c)}})}function ce(r){return u.isFunction(r)||u.isFunction(r?.install)}function b(r,e,t=!1,n=!1){try{const s=['"use strict";',"var __self = arguments[0];"];s.push("return ");let o=(r.value||"").trim();o=o.replace(/this(\W|$)/g,(i,l)=>`__self${l}`),o=s.join(`
8
- `)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(s){if(u.logger.error("parseExpression.error",s,r,e?.__self??e),n)throw s}}function q(r,e,t=!1,n=!1){const s=b(r,e,t,n);if(typeof s!="function"&&(u.logger.error("parseFunction.error","not a function",r,e?.__self??e),n))throw new Error(`"${r.value}" not a function`);return s}function S(r){return r&&r.type==="JSExpression"}function M(r){return typeof r=="object"&&r&&r.type==="JSFunction"}function le(r){return S(r)||M(r)}function be(r){return le(r)?r.value:JSON.stringify(r)}let C=null;const Re=u.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:r=>r.data?.code===0||!!r.data?.success,failMessage:!0,showError:r=>{F.ElNotification.error({message:r||"未知错误"})},showLoading:()=>{C&&C.close(),C=F.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{C&&(C.close(),C=null)}}});function ue(r,e){const{jsonp:t,request:n}=e;if(r.method==="jsonp")return(s={})=>t(r.url,{...r.jsonpOptions,query:s});{const s=r.headers?b(r.headers,{},!0):void 0,o={url:r.url,method:r.method,settings:{...r.settings,headers:s}};return(a,i)=>n.send(u.merge(o,i||{},{data:a}))}}function de(r,e){const{metaQuery:t}=e;if(!t)return;const{code:n,queryCode:s}=r;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(n,s,o,a)}}function fe(r=[],e=[],t){const n={};for(const s of r)n[s.id]=ue(s,t);for(const s of e)n[s.id]=de(s,t);return n}function pe(r=[]){T.setup({timeout:"50-500"}),W(),r.forEach(e=>me(e))}function me(r){if(!r.mock)return;const{url:e,mockTemplate:t}=r;if(e&&t){const n=u.pathToRegexp(`${e}(.*)`),s=u.pathToRegexpMatch(e,{decode:decodeURIComponent}),o=b(t,{},!0);T.mock(n,a=>{const i=u.url.parse(a.url)||{},l=a.body instanceof FormData?u.formDataToJson(a.body):a.body,c=s(a.url)?.params;return Object.assign(a,{data:l,params:i,query:c}),T.mock(o(a))})}}function W(){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:n,attrs:s}=e;this.__mode=t,n&&(this.__id=n.id||null,this.__transform=n.transform||{}),s&&Object.assign(this,s)}setup(e,t=D){const n=t.getCurrentInstance();if(!n)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=n.proxy;const s=n.appContext.config.globalProperties;Object.assign(this,s),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__proxy(){this.__instance&&U.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){U.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:n}=e,s=t?this.__transform[t]??e.value:e.value;return q({type:n,value:s},this)}else return q(e,this)}__parseExpression(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:n}=e,s=t?this.__transform[t]??e.value:e.value;return b({type:n,value:s},this)}else return b(e,this)}__ref(e=null,t){if(this.__mode!==w.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async n=>{await u.delay(0);let s=n?.$vtjEl||n?.$el||n?._?.vnode?.el||n;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]=n),typeof t=="function")t(n);else if(t){const o=this.$refs[t];if(o){const a=new Set([].concat(o,n));this.$refs[t]=Array.from(a)}else this.$refs[t]=n}return n}}__clone(e={}){const t={...this.context,...e},n={...t,context:t};return n.context.__proto__=this.context,n.__proto__=this,n}}function x(r){const{Vue:e=D,mode:t=w.Runtime,components:n={},libs:s={},apis:o={},loader:a}=r,i=e.computed(()=>r.dsl),l={$components:n,$libs:s,$apis:o},c=new he({mode:t,dsl:i.value,attrs:l}),h=e.defineComponent({name:i.value.name,props:{...Ie(i.value.props??[],c)},setup(d){c.$props=d,c.props=d,i.value.id&&L(r.window||window,i.value.id,i.value.css||""),c.state=Me(e,i.value.state??{},c);const f=Oe(e,i.value.computed??{},c),p=Te(i.value.methods??{},c),g=xe(e,i.value.inject,c),v=ve(i.value.dataSources||{},c),y={...g,...f,...p,...v};return c.setup(y,e),He(e,i.value.watch??[],c),{vtj:c}},emits:Fe(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const d=i.value.nodes||[];return d.length===1?I(d[0],c,e,a):d.map(f=>I(f,c,e,a))},...De(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(h),context:c}}function Fe(r=[]){return r.map(e=>u.isString(e)?e:e.name)}function Ie(r=[],e){const t=n=>n?(Array.isArray(n)?n:[n]).map(o=>ne[o]):void 0;return r.map(n=>u.isString(n)?{name:n}:{name:n.name,type:n.type,required:n.required,default:S(n.default)?e.__parseExpression(n.default):n.default}).reduce((n,s)=>(n[s.name]={type:t(s.type),required:s.required,default:s.default},n),{})}function Me(r,e,t){return r.reactive(Object.keys(e||{}).reduce((n,s)=>{let o=e[s];return S(o)?o=t.__parseExpression(o):M(o)&&(o=t.__parseFunction(o)),n[s]=o,n},{}))}function Oe(r,e,t){return Object.entries(e??{}).reduce((n,[s,o])=>(n[s]=r.computed(t.__parseFunction(o)),n),{})}function Te(r,e){return Object.entries(r??{}).reduce((t,[n,s])=>(t[n]=e.__parseFunction(s),t),{})}function xe(r,e=[],t){return e.reduce((n,s)=>{const{name:o,from:a}=s||{};s.default;const i=S(a)?t.__parseExpression(a)||o:a??o,l=S(s.default)?t.__parseExpression(s.default):s.default??null;return n[o]=r.inject(i,l),n},{})}function ve(r,e){return Object.keys(r).reduce((t,n)=>{const s=r[n],o=e.$apis[s.ref],a=M(s.transform)?s.transform.value?e.__parseFunction(s.transform):void 0:s.transform;return t[n]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l},t},{})}function He(r,e=[],t){e.forEach(n=>{r.watch(t.__parseExpression(n.source),t.__parseFunction(n.handler),{deep:n.deep,immediate:n.immediate})})}function De(r,e){return Object.entries(r??{}).reduce((t,[n,s])=>(t[n]=e.__parseFunction(s),t),{})}let N=[];const ge=r=>r;async function Y(r,e=window){const{urls:t=[],library:n}=r,s=t.filter(i=>k(i));if(s.length===0||!n)return null;const o=t.filter(i=>A(i)),a=await ae(s,n,e).catch(i=>(console.warn("loadScriptUrl error",s,n,i),null));return a?{component:a,css:o}:null}function H(r){const{getDsl:e,getDslByUrl:t,options:n}=r;return n.window&&(N.forEach(s=>{delete n.window[s]}),N=[]),(s,o,a=D)=>!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?x({...n,Vue:a,dsl:i,mode:w.Runtime,loader:H(r)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=s),i?x({...n,Vue:a,dsl:i,mode:w.Runtime,loader:H(r)}).renderer:null}):o.type==="Plugin"?(o.library&&N.push(o.library),a.defineAsyncComponent(async()=>{const i=await Y(o,n.window);return i?(V(i.css,n.window),i.component):(console.warn("getPlugin result is null",o),null)})):s}function I(r,e,t=D,n=ge){if(!r||!r.name||r.invisible)return null;const{id:s=null,directives:o=[]}=r,{vIf:a,vFor:i,vShow:l,vModels:c,vBind:h}=Ae(o);if(a&&!ke(a,e))return null;const d=f=>{const p=f.$components,g=(()=>{if(r.name==="component")return Be(f,r.props?.is);if(r.name==="slot")return r.name;const E=n(r.name,r.from,t);return u.isString(E)?p[E]??E:E})(),v=Ne(s,r.props??{},f),y=Ue(t,r.events??{},f);if(r.name==="slot")return qe(t,r,v,f,n);h&&Object.assign(v,f.__parseExpression(h.value)),l&&(v.style=Object.assign(v.style??{},Le(l,f))),c.forEach(E=>{Object.assign(v,Ve(t,E,f))});const j=We(t,r.children??[],f,n,r);return t.createVNode(g,{...v,...y},j)};return i?Xe(i,d,e):d(e)}function Ae(r=[]){const e=r.find(i=>u.camelCase(i.name)==="vIf"),t=r.find(i=>u.camelCase(i.name)==="vFor"),n=r.find(i=>u.camelCase(i.name)==="vShow"),s=r.find(i=>u.camelCase(i.name)==="vBind"),o=r.filter(i=>u.camelCase(i.name)==="vModel"),a=r.filter(i=>!te.includes(u.camelCase(i.name)));return{vIf:e,vFor:t,vShow:n,vModels:o,vBind:s,others:a}}function ke(r,e){return!!e.__parseExpression(r.value)}function Be(r,e){return e?S(e)?r.__parseExpression(e):e:"div"}function Ne(r,e,t){const n=Object.keys(e||{}).reduce((s,o)=>{let a=e[o];return S(a)?a=t.__parseExpression(a):M(a)&&(a=t.__parseFunction(a)),s[o]=a,s},{});return n.ref=t.__ref(r,n.ref),n}function Ue(r,e,t){const n=["passive","capture","once"],s={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=K(i.modifiers),c=l.find(f=>n.includes(f)),h="on"+u.upperFirst(a)+(c&&s[c]||""),d=t.__parseFunction(i.handler);return d&&(o[h]=r.withModifiers(d,l)),o},{})}function K(r={},e=!1){const t=Object.keys(r);return e?t.map(n=>"."+n):t}function qe(r,e,t,n,s){const{children:o}=e,a=Je(e,n),i=n.$slots?.[a.name];return i?i(t):o?u.isString(o)?r.createTextVNode(o):S(o)?r.createTextVNode(J(n.__parseExpression(o))):Array.isArray(o)?o.map(l=>I(l,n,r,s)):null:null}function Je(r,e){const{props:t}=r,n=t?.name||"default";return{name:S(n)?e.__parseExpression(n):n,params:[]}}function Le(r,e){return e.__parseExpression(r.value)?{}:{display:"none"}}function Ve(r,e,t){const n={type:"JSFunction",value:e.value?.value?`(v) => {
7
+ */const b="0.8.116";var w=(r=>(r.Runtime="Runtime",r.Design="Design",r.Raw="Raw",r.VNode="VNode",r))(w||{});const U=["$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"],te=["vIf","vShow","vModel","vFor","vBind"],ne={String,Number,Boolean,Array,Object,Function,Date};function R(r,e){return r.map(t=>u.isUrl(t)?t:`${e}${t}`)}function A(r){return/\.css$/.test(r)}function k(r){return/\.js$/.test(r)}function re(r){return/\.json$/.test(r)}function Ce(r){return r.map(e=>`<script src="${u.url.append(e,{v:b})}"><\/script>`).join("")}function be(r=[]){return r.map(e=>`<link rel="stylesheet" href="${u.url.append(e,{v:b})}" />`).join("")}function se(r,e){const t=r.filter(d=>!!d.enabled),n=[],s=[],o=[],a=[],i={},l={},c=[],h={};return t.forEach(({urls:d,assetsUrl:f,library:p,assetsLibrary:g,localeLibrary:v})=>{d?.forEach(y=>{k(y)&&n.push(y),A(y)&&s.push(y)}),p&&(a.push(p),i[p]=R(d||[],e),v&&(l[p]=v)),f&&o.push(f),g&&c.push(g),p&&g&&(h[g]=p)}),{scripts:R(n,e),css:R(s,e),materials:R(o,e),libraryExports:a,materialExports:u.dedupArray(c),materialMapLibrary:h,libraryMap:i,libraryLocaleMap:l}}function oe(r,e){const{name:t,parent:n,alias:s}=r;return n?e[n]?.[s||t]:e[s||t]}function J(r){return u.isString(r)?r:JSON.stringify(r)}function L(r,e,t){const n=r.CSSStyleSheet;if(n.prototype.replaceSync){const s=new n;s.id=e,s.replaceSync(t);const o=r.document,a=o.adoptedStyleSheets,i=Array.from(a).filter(l=>l.id!==e);o.adoptedStyleSheets=[...i,s]}else{const s=r.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 ie(r,e){const t=await window.fetch(e).then(n=>n.text()).catch(()=>"");t&&L(window,r,t)}function V(r,e=window){const t=e.document,n=e.document.head;for(const s of r)if(!t.getElementById(s)){const a=t.createElement("link");a.rel="stylesheet",a.id=s,a.href=s,n.appendChild(a)}}async function ae(r,e,t=window){const n=t.document,s=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const l of r){const c=n.createElement("script");c.src=l,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=h=>{i(h)},s.appendChild(c)}})}function ce(r){return u.isFunction(r)||u.isFunction(r?.install)}function P(r,e,t=!1,n=!1){try{const s=['"use strict";',"var __self = arguments[0];"];s.push("return ");let o=(r.value||"").trim();o=o.replace(/this(\W|$)/g,(i,l)=>`__self${l}`),o=s.join(`
8
+ `)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(s){if(u.logger.error("parseExpression.error",s,r,e?.__self??e),n)throw s}}function q(r,e,t=!1,n=!1){const s=P(r,e,t,n);if(typeof s!="function"&&(u.logger.error("parseFunction.error","not a function",r,e?.__self??e),n))throw new Error(`"${r.value}" not a function`);return s}function S(r){return r&&r.type==="JSExpression"}function M(r){return typeof r=="object"&&r&&r.type==="JSFunction"}function le(r){return S(r)||M(r)}function Pe(r){return le(r)?r.value:JSON.stringify(r)}let C=null;const Re=u.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:r=>r.data?.code===0||!!r.data?.success,failMessage:!0,showError:r=>{F.ElNotification.error({message:r||"未知错误"})},showLoading:()=>{C&&C.close(),C=F.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{C&&(C.close(),C=null)}}});function ue(r,e){const{jsonp:t,request:n}=e;if(r.method==="jsonp")return(s={})=>t(r.url,{...r.jsonpOptions,query:s});{const s=r.headers?P(r.headers,{},!0):void 0,o={url:r.url,method:r.method,settings:{...r.settings,headers:s}};return(a,i)=>n.send(u.merge(o,i||{},{data:a}))}}function de(r,e){const{metaQuery:t}=e;if(!t)return;const{code:n,queryCode:s}=r;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(n,s,o,a)}}function fe(r=[],e=[],t){const n={};for(const s of r)n[s.id]=ue(s,t);for(const s of e)n[s.id]=de(s,t);return n}function pe(r=[]){T.setup({timeout:"50-500"}),W(),r.forEach(e=>me(e))}function me(r){if(!r.mock)return;const{url:e,mockTemplate:t}=r;if(e&&t){const n=u.pathToRegexp(`${e}(.*)`),s=u.pathToRegexpMatch(e,{decode:decodeURIComponent}),o=P(t,{},!0);T.mock(n,a=>{const i=u.url.parse(a.url)||{},l=a.body instanceof FormData?u.formDataToJson(a.body):a.body,c=s(a.url)?.params;return Object.assign(a,{data:l,params:i,query:c}),T.mock(o(a))})}}function W(){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:n,attrs:s}=e;this.__mode=t,n&&(this.__id=n.id||null,this.__transform=n.transform||{}),s&&Object.assign(this,s)}setup(e,t=D){const n=t.getCurrentInstance();if(!n)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=n.proxy;const s=n.appContext.config.globalProperties;Object.assign(this,s),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__proxy(){this.__instance&&U.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){U.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:n}=e,s=t?this.__transform[t]??e.value:e.value;return q({type:n,value:s},this)}else return q(e,this)}__parseExpression(e){if(e)if(this.__mode===w.Runtime){const{id:t,type:n}=e,s=t?this.__transform[t]??e.value:e.value;return P({type:n,value:s},this)}else return P(e,this)}__ref(e=null,t){if(this.__mode!==w.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async n=>{await u.delay(0);let s=n?.$vtjEl||n?.$el||n?._?.vnode?.el||n;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]=n),typeof t=="function")t(n);else if(t){const o=this.$refs[t];if(o){const a=new Set([].concat(o,n));this.$refs[t]=Array.from(a)}else this.$refs[t]=n}return n}}__clone(e={}){const t={...this.context,...e},n={...t,context:t};return n.context.__proto__=this.context,n.__proto__=this,n}}function x(r){const{Vue:e=D,mode:t=w.Runtime,components:n={},libs:s={},apis:o={},loader:a}=r,i=e.computed(()=>r.dsl),l={$components:n,$libs:s,$apis:o},c=new he({mode:t,dsl:i.value,attrs:l}),h=e.defineComponent({name:i.value.name,props:{...Ie(i.value.props??[],c)},setup(d){c.$props=d,c.props=d,i.value.id&&L(r.window||window,i.value.id,i.value.css||""),c.state=Me(e,i.value.state??{},c);const f=Oe(e,i.value.computed??{},c),p=Te(i.value.methods??{},c),g=xe(e,i.value.inject,c),v=ve(i.value.dataSources||{},c),y={...g,...f,...p,...v};return c.setup(y,e),He(e,i.value.watch??[],c),{vtj:c}},emits:Fe(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const d=i.value.nodes||[];return d.length===1?I(d[0],c,e,a):d.map(f=>I(f,c,e,a))},...De(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(h),context:c}}function Fe(r=[]){return r.map(e=>u.isString(e)?e:e.name)}function Ie(r=[],e){const t=n=>n?(Array.isArray(n)?n:[n]).map(o=>ne[o]):void 0;return r.map(n=>u.isString(n)?{name:n}:{name:n.name,type:n.type,required:n.required,default:S(n.default)?e.__parseExpression(n.default):n.default}).reduce((n,s)=>(n[s.name]={type:t(s.type),required:s.required,default:s.default},n),{})}function Me(r,e,t){return r.reactive(Object.keys(e||{}).reduce((n,s)=>{let o=e[s];return S(o)?o=t.__parseExpression(o):M(o)&&(o=t.__parseFunction(o)),n[s]=o,n},{}))}function Oe(r,e,t){return Object.entries(e??{}).reduce((n,[s,o])=>(n[s]=r.computed(t.__parseFunction(o)),n),{})}function Te(r,e){return Object.entries(r??{}).reduce((t,[n,s])=>(t[n]=e.__parseFunction(s),t),{})}function xe(r,e=[],t){return e.reduce((n,s)=>{const{name:o,from:a}=s||{};s.default;const i=S(a)?t.__parseExpression(a)||o:a??o,l=S(s.default)?t.__parseExpression(s.default):s.default??null;return n[o]=r.inject(i,l),n},{})}function ve(r,e){return Object.keys(r).reduce((t,n)=>{const s=r[n],o=e.$apis[s.ref],a=M(s.transform)?s.transform.value?e.__parseFunction(s.transform):void 0:s.transform;return t[n]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l},t},{})}function He(r,e=[],t){e.forEach(n=>{r.watch(t.__parseExpression(n.source),t.__parseFunction(n.handler),{deep:n.deep,immediate:n.immediate})})}function De(r,e){return Object.entries(r??{}).reduce((t,[n,s])=>(t[n]=e.__parseFunction(s),t),{})}let N=[];const ge=r=>r;async function Y(r,e=window){const{urls:t=[],library:n}=r,s=t.filter(i=>k(i));if(s.length===0||!n)return null;const o=t.filter(i=>A(i)),a=await ae(s,n,e).catch(i=>(console.warn("loadScriptUrl error",s,n,i),null));return a?{component:a,css:o}:null}function H(r){const{getDsl:e,getDslByUrl:t,options:n}=r;return n.window&&(N.forEach(s=>{delete n.window[s]}),N=[]),(s,o,a=D)=>!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?x({...n,Vue:a,dsl:i,mode:w.Runtime,loader:H(r)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=s),i?x({...n,Vue:a,dsl:i,mode:w.Runtime,loader:H(r)}).renderer:null}):o.type==="Plugin"?(o.library&&N.push(o.library),a.defineAsyncComponent(async()=>{const i=await Y(o,n.window);return i?(V(i.css,n.window),i.component):(console.warn("getPlugin result is null",o),null)})):s}function I(r,e,t=D,n=ge){if(!r||!r.name||r.invisible)return null;const{id:s=null,directives:o=[]}=r,{vIf:a,vFor:i,vShow:l,vModels:c,vBind:h}=Ae(o);if(a&&!ke(a,e))return null;const d=f=>{const p=f.$components,g=(()=>{if(r.name==="component")return Be(f,r.props?.is);if(r.name==="slot")return r.name;const E=n(r.name,r.from,t);return u.isString(E)?p[E]??E:E})(),v=Ne(s,r.props??{},f),y=Ue(t,r.events??{},f);if(r.name==="slot")return qe(t,r,v,f,n);h&&Object.assign(v,f.__parseExpression(h.value)),l&&(v.style=Object.assign(v.style??{},Le(l,f))),c.forEach(E=>{Object.assign(v,Ve(t,E,f))});const j=We(t,r.children??[],f,n,r);return t.createVNode(g,{...v,...y},j)};return i?Xe(i,d,e):d(e)}function Ae(r=[]){const e=r.find(i=>u.camelCase(i.name)==="vIf"),t=r.find(i=>u.camelCase(i.name)==="vFor"),n=r.find(i=>u.camelCase(i.name)==="vShow"),s=r.find(i=>u.camelCase(i.name)==="vBind"),o=r.filter(i=>u.camelCase(i.name)==="vModel"),a=r.filter(i=>!te.includes(u.camelCase(i.name)));return{vIf:e,vFor:t,vShow:n,vModels:o,vBind:s,others:a}}function ke(r,e){return!!e.__parseExpression(r.value)}function Be(r,e){return e?S(e)?r.__parseExpression(e):e:"div"}function Ne(r,e,t){const n=Object.keys(e||{}).reduce((s,o)=>{let a=e[o];return S(a)?a=t.__parseExpression(a):M(a)&&(a=t.__parseFunction(a)),s[o]=a,s},{});return n.ref=t.__ref(r,n.ref),n}function Ue(r,e,t){const n=["passive","capture","once"],s={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=K(i.modifiers),c=l.find(f=>n.includes(f)),h="on"+u.upperFirst(a)+(c&&s[c]||""),d=t.__parseFunction(i.handler);return d&&(o[h]=r.withModifiers(d,l)),o},{})}function K(r={},e=!1){const t=Object.keys(r);return e?t.map(n=>"."+n):t}function qe(r,e,t,n,s){const{children:o}=e,a=Je(e,n),i=n.$slots?.[a.name];return i?i(t):o?u.isString(o)?r.createTextVNode(o):S(o)?r.createTextVNode(J(n.__parseExpression(o))):Array.isArray(o)?o.map(l=>I(l,n,r,s)):null:null}function Je(r,e){const{props:t}=r,n=t?.name||"default";return{name:S(n)?e.__parseExpression(n):n,params:[]}}function Le(r,e){return e.__parseExpression(r.value)?{}:{display:"none"}}function Ve(r,e,t){const n={type:"JSFunction",value:e.value?.value?`(v) => {
9
9
  ${e.value.value} = v;
10
- }`:"(v) => {}"},s=t.__parseFunction(n),o=K(e.modifiers),a=S(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&s?r.withModifiers(s,o):s}}function We(r,e,t,n,s){if(!e)return null;if(u.isString(e))return{default:()=>e};if(S(e))return{default:()=>J(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,[l,{nodes:c,params:h}])=>(i[l]=d=>{const f=h.length?u.pick(d??{},h):a(d);return c.map(p=>I(p,t.__clone(f),r,n))},i),{})}return null}function Ye(r){const e={default:{params:[],nodes:[]}};for(const t of r){const n=Ke(t.slot),s=n.name;e[s]?(e[s].nodes.push(t),e[s].params=e[s].params.concat(n.params)):e[s]={nodes:[t],params:n.params}}return e}function Ke(r="default"){return u.isString(r)?{name:r,params:[]}:{params:[],...r}}function Xe(r,e,t){const{value:n,iterator:s}=r,{item:o="item",index:a="index"}=s||{};let i=t.__parseExpression(n)||[];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}))):(console.warn("[vForRender]:",`${n?.value} is not a Arrary`),[])}function ze(r){return m.getCurrentScope()?(m.onScopeDispose(r),!0):!1}function X(r){return typeof r=="function"?r():m.unref(r)}const ye=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ge=r=>r!=null,Qe=()=>{};function Ze(r){return m.getCurrentInstance()}function et(...r){if(r.length!==1)return m.toRef(...r);const e=r[0];return typeof e=="function"?m.readonly(m.customRef(()=>({get:e,set:Qe}))):m.ref(e)}function tt(r,e){Ze()&&m.onBeforeUnmount(r,e)}function nt(r){var e;const t=X(r);return(e=t?.$el)!=null?e:t}const rt=ye?window:void 0,st=ye?window.document:void 0;function ot(){const r=m.ref(!1),e=m.getCurrentInstance();return e&&m.onMounted(()=>{r.value=!0},e),r}function it(r){const e=ot();return m.computed(()=>(e.value,!!r()))}function at(r,e,t={}){const{window:n=rt,...s}=t;let o;const a=it(()=>n&&"MutationObserver"in n),i=()=>{o&&(o.disconnect(),o=void 0)},l=m.computed(()=>{const f=X(r),p=(Array.isArray(f)?f:[f]).map(nt).filter(Ge);return new Set(p)}),c=m.watch(()=>l.value,f=>{i(),a.value&&f.size&&(o=new MutationObserver(e),f.forEach(p=>o.observe(p,s)))},{immediate:!0,flush:"post"}),h=()=>o?.takeRecords(),d=()=>{i(),c()};return ze(d),{isSupported:a,stop:d,takeRecords:h}}function ct(r=null,e={}){var t,n,s;const{document:o=st,restoreOnUnmount:a=d=>d}=e,i=(t=o?.title)!=null?t:"",l=et((n=r??o?.title)!=null?n:null),c=r&&typeof r=="function";function h(d){if(!("titleTemplate"in e))return d;const f=e.titleTemplate||"%s";return typeof f=="function"?f(d):X(f).replace(/%s/g,d)}return m.watch(l,(d,f)=>{d!==f&&o&&(o.title=h(typeof d=="string"?d:""))},{immediate:!0}),e.observe&&!e.titleTemplate&&o&&!c&&at((s=o.head)==null?void 0:s.querySelector("title"),()=>{o&&o.title!==l.value&&(l.value=h(o.title))},{childList:!0}),tt(()=>{if(a){const d=a(i,l.value||"");d!=null&&o&&(o.title=d)}}),l}const Z=m.defineComponent({name:"VtjPageContainer",async setup(){const r=G(),e=ee.useRoute(),t=e.params.id,n=t?r.getPage(t):r.getHomepage(),s=n?await r.getRenderComponent(n.id):null;return n&&ct(n.title||"VTJ"),{provider:r,component:s,file:n,query:e.query}},render(){return this.component?m.h(this.component,this.query):m.h("div","页面不存在")}}),lt=m.defineComponent({name:"VtjStartupContainer",render(){return m.h(je.XStartup)}}),z=Symbol("Provider");class _e extends $.Base{constructor(e){super(),this.options=e;const{service:t,mode:n=w.Raw,dependencies:s,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:h=null,materialPath:d="./",nodeEnv:f="development"}=e;this.mode=n,this.modules=c,this.service=t,this.router=h,this.materialPath=d,this.nodeEnv=f,s&&(this.dependencies=s),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i),n!==w.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Re,jsonp:u.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};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{apis:n=[],meta:s=[]}=this.project,o=window;o.CKEDITOR_VERSION=void 0,this.nodeEnv!=="production"&&await this.loadAssets(o),this.apis=fe(n,s,this.adapter),W(),this.project.config?.mock&&pe(n),this.initRouter(),this.triggerReady()}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:n,library:s,components:o,materialPath:a}=this,{libraryExports:i,libraryMap:l,materials:c,materialExports:h,materialMapLibrary:d}=se(t,a);for(const p of i){const g=n[p],v=e[p];if(v)s[p]=v;else if(g)e[p]=s[p]=await g();else{const y=l[p]||[];for(const j of y)A(j)&&await ie(p,u.url.append(j,{v:P})),k(j)&&await u.loadScript(u.url.append(j,{v:P}));s[p]=e[p]}}for(const p of c)await u.loadScript(u.url.append(p,{v:P}));const f=this.materials||{};for(const p of h){const g=e[d[p]],v=$.BUILT_IN_COMPONENTS[p];if(v)g&&v.forEach(y=>{o[y]=g[y]});else{const y=f[p]?(await f[p]()).default:e[p];y&&g&&(y.components||[]).forEach(j=>{o[j.name]=oe(j,g)})}}}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:Z}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?Z:lt}))}install(e){const t=e.config.globalProperties.installed||{};for(const[n,s]of Object.entries(this.library))!t[n]&&ce(s)&&(e.use(s),t[n]=!0);this.options.install&&e.use(this.options.install),e.provide(z,this),e.config.globalProperties.installed=t,this.nodeEnv==="development"&&(e.config.errorHandler=(n,s,o)=>{const a=s?.$options.name,i=n?.message||n?.msg||"未知错误",l=`[ ${a} ] ${i}`;console.error("[VTJ Error]:",{err:n,instance:s,info:o},n?.stack),F.ElNotification.error({title:"运行时错误:请在控制台查看详情",message:l})})}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(n=>n.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},n=(s,o=[])=>{for(const a of o){if(a.id===s)return a;if(a.children&&a.children.length){const i=n(s,a.children);if(i)return i}}};return n(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(n=>n.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:n,components:s,mode:o,apis:a}=this,i={mode:o,Vue:n.Vue,components:s,libs:n,apis:a,window,...t},l=H({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return x({...i,dsl:e,loader:l})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return u.logger.warn(`Can not find file: ${e}`),null;const n=`.vtj/vue/${e}.vue`,s=this.modules[n];if(s)return(await s())?.default;const o=await this.getDsl(t.id);return o?this.createDslRenderer(o).renderer:(u.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return m.defineAsyncComponent(async()=>{const n=await this.getDslByUrl(e);return n?(n.name=t||n.name,this.createDslRenderer(n).renderer):null})}definePluginComponent(e){return m.defineAsyncComponent(async()=>{const t=await Y(e,window);return t?(V(t.css),t.component):null})}}function ut(r){const e=new _e(r);return{provider:e,onReady:n=>e.ready(n)}}function G(r={}){const e=m.inject(z);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:n}=r;t&&n&&(async()=>{const s=await e.getDsl(t);s?.__VERSION__!==n&&F.ElNotification.warning({title:s?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const Q=new u.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:r=>r.data?.code===0,showError:r=>{F.ElNotification.error({message:r||"未知错误"})}}}),dt=(r="/vtj/local/repository/${type}.json")=>(e,t)=>Q.send({url:r,method:"post",query:{type:e},data:{type:e,data:t}}),ft=(r="/vtj/local/repository/uploader.json")=>async(e,t)=>await Q.send({url:r,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(n=>n&&n[0]?n[0]:null).catch(()=>null);class B{api;pluginCaches={};uploader;constructor(){this.api=dt(),this.uploader=ft()}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,n=t.filter(o=>re(o))[0];if(!n)return null;const s=this.pluginCaches[n];return s||(this.pluginCaches[n]=Q.send({url:n,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const _=new u.Storage({type:"local",expired:0,prefix:"__VTJ_"});class pt extends B{init(e){const t=new $.ProjectModel(e),n=_.get(`project_${t.id}`),s=Object.assign(t.toDsl(),n||{});return _.save(`project_${t.id}`,s),Promise.resolve(s)}saveProject(e){const t=new $.ProjectModel(e);return _.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return _.save(`materials_${e.id}`,u.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 s=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,s),_.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=_.get(`history_${e}`),n=new $.HistoryModel(t||{id:e});return Promise.resolve(n.toDsl())}getHistoryItem(e,t){const n=_.get(`history_${e}_${t}`);return Promise.resolve(n)}saveHistoryItem(e,t){return _.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{_.remove(`history_${e}_${n}`)}),Promise.resolve(!0)}}class Se extends B{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new $.ProjectModel(e),n=this.projects[t.id]||{},s=Object.assign(t.toDsl(),n);return this.projects[s.id]=s,Promise.resolve(s)}saveProject(e){const t=new $.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=u.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],n=new $.HistoryModel(t||{id:e});return Promise.resolve(n)}getHistoryItem(e,t){const n=`${e}_${t}`,s=this.historyItems[n]||{};return Promise.resolve(s)}saveHistoryItem(e,t){const n=`${e}_${t.id}`;return this.historyItems[n]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{const s=`${e}_${n}`;delete this.historyItems[s]}),Promise.resolve(!0)}}let O=null;function mt(){return O||(O=new Se,O)}class ht extends B{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:u.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 we(r=[]){return r.map(e=>{const{id:t,title:n,icon:s,children:o,hidden:a}=e;return{id:t,title:n,icon:s,hidden:a,url:`/page/${t}`,children:o&&o.length?we(o):void 0}})}function vt(){const r=G(),e=ee.useRoute(),t=m.ref(!1),n=r.project;m.watchEffect(()=>{const{name:a,params:i,meta:l}=e;if(a==="VtjPage"){const c=r.getPage(i.id);t.value=!c?.mask}else if(a==="VtjHomepage"){const c=r.getHomepage();t.value=!c?.mask}else t.value=!l.mask});const s=we(n?.pages),o=n?.config;return{disabled:t,logo:o?.logo,themeSwitchable:o?.themeSwitchable,title:o?.title||n?.description||n?.name||"VTJ App",menus:s}}exports.BUILT_IN_DIRECTIVES=te;exports.BaseService=B;exports.CONTEXT_HOST=U;exports.Context=he;exports.ContextMode=w;exports.DATA_TYPES=ne;exports.JSCodeToString=be;exports.LIFE_CYCLES_LIST=Ee;exports.LocalService=ht;exports.MemoryService=Se;exports.Provider=_e;exports.StorageService=pt;exports.VTJ_RENDERER_VERSION=P;exports.adoptedStyleSheets=L;exports.createAssetScripts=Ce;exports.createAssetsCss=Pe;exports.createDataSources=ve;exports.createLoader=H;exports.createMemoryService=mt;exports.createMetaApi=de;exports.createProvider=ut;exports.createRenderer=x;exports.createSchemaApi=ue;exports.createSchemaApis=fe;exports.defaultLoader=ge;exports.fillBasePath=R;exports.getModifiers=K;exports.getPlugin=Y;exports.getRawComponent=oe;exports.isCSSUrl=A;exports.isJSCode=le;exports.isJSExpression=S;exports.isJSFunction=M;exports.isJSON=re;exports.isJSUrl=k;exports.isVuePlugin=ce;exports.loadCss=ie;exports.loadCssUrl=V;exports.loadScriptUrl=ae;exports.mockApi=me;exports.mockApis=pe;exports.mockCleanup=W;exports.nodeRender=I;exports.parseDeps=se;exports.parseExpression=b;exports.parseFunction=q;exports.providerKey=z;exports.toString=J;exports.useMask=vt;exports.useProvider=G;
10
+ }`:"(v) => {}"},s=t.__parseFunction(n),o=K(e.modifiers),a=S(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&s?r.withModifiers(s,o):s}}function We(r,e,t,n,s){if(!e)return null;if(u.isString(e))return{default:()=>e};if(S(e))return{default:()=>J(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,[l,{nodes:c,params:h}])=>(i[l]=d=>{const f=h.length?u.pick(d??{},h):a(d);return c.map(p=>I(p,t.__clone(f),r,n))},i),{})}return null}function Ye(r){const e={default:{params:[],nodes:[]}};for(const t of r){const n=Ke(t.slot),s=n.name;e[s]?(e[s].nodes.push(t),e[s].params=e[s].params.concat(n.params)):e[s]={nodes:[t],params:n.params}}return e}function Ke(r="default"){return u.isString(r)?{name:r,params:[]}:{params:[],...r}}function Xe(r,e,t){const{value:n,iterator:s}=r,{item:o="item",index:a="index"}=s||{};let i=t.__parseExpression(n)||[];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}))):(console.warn("[vForRender]:",`${n?.value} is not a Arrary`),[])}function ze(r){return m.getCurrentScope()?(m.onScopeDispose(r),!0):!1}function X(r){return typeof r=="function"?r():m.unref(r)}const ye=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ge=r=>r!=null,Qe=()=>{};function Ze(r){return m.getCurrentInstance()}function et(...r){if(r.length!==1)return m.toRef(...r);const e=r[0];return typeof e=="function"?m.readonly(m.customRef(()=>({get:e,set:Qe}))):m.ref(e)}function tt(r,e){Ze()&&m.onBeforeUnmount(r,e)}function nt(r){var e;const t=X(r);return(e=t?.$el)!=null?e:t}const rt=ye?window:void 0,st=ye?window.document:void 0;function ot(){const r=m.ref(!1),e=m.getCurrentInstance();return e&&m.onMounted(()=>{r.value=!0},e),r}function it(r){const e=ot();return m.computed(()=>(e.value,!!r()))}function at(r,e,t={}){const{window:n=rt,...s}=t;let o;const a=it(()=>n&&"MutationObserver"in n),i=()=>{o&&(o.disconnect(),o=void 0)},l=m.computed(()=>{const f=X(r),p=(Array.isArray(f)?f:[f]).map(nt).filter(Ge);return new Set(p)}),c=m.watch(()=>l.value,f=>{i(),a.value&&f.size&&(o=new MutationObserver(e),f.forEach(p=>o.observe(p,s)))},{immediate:!0,flush:"post"}),h=()=>o?.takeRecords(),d=()=>{i(),c()};return ze(d),{isSupported:a,stop:d,takeRecords:h}}function ct(r=null,e={}){var t,n,s;const{document:o=st,restoreOnUnmount:a=d=>d}=e,i=(t=o?.title)!=null?t:"",l=et((n=r??o?.title)!=null?n:null),c=r&&typeof r=="function";function h(d){if(!("titleTemplate"in e))return d;const f=e.titleTemplate||"%s";return typeof f=="function"?f(d):X(f).replace(/%s/g,d)}return m.watch(l,(d,f)=>{d!==f&&o&&(o.title=h(typeof d=="string"?d:""))},{immediate:!0}),e.observe&&!e.titleTemplate&&o&&!c&&at((s=o.head)==null?void 0:s.querySelector("title"),()=>{o&&o.title!==l.value&&(l.value=h(o.title))},{childList:!0}),tt(()=>{if(a){const d=a(i,l.value||"");d!=null&&o&&(o.title=d)}}),l}const Z=m.defineComponent({name:"VtjPageContainer",async setup(){const r=G(),e=ee.useRoute(),t=e.params.id,n=t?r.getPage(t):r.getHomepage(),s=n?await r.getRenderComponent(n.id):null;return n&&ct(n.title||"VTJ"),{provider:r,component:s,file:n,query:e.query}},render(){return this.component?m.h(this.component,this.query):m.h("div","页面不存在")}}),lt=m.defineComponent({name:"VtjStartupContainer",render(){return m.h(je.XStartup)}}),z=Symbol("Provider");class _e extends $.Base{constructor(e){super(),this.options=e;const{service:t,mode:n=w.Raw,dependencies:s,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:h=null,materialPath:d="./",nodeEnv:f="development"}=e;this.mode=n,this.modules=c,this.service=t,this.router=h,this.materialPath=d,this.nodeEnv=f,s&&(this.dependencies=s),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i),n!==w.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Re,jsonp:u.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};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{apis:n=[],meta:s=[]}=this.project,o=window;o.CKEDITOR_VERSION=void 0,this.nodeEnv!=="production"?await this.loadAssets(o):await this.loadDependencies(o),this.apis=fe(n,s,this.adapter),W(),this.project.config?.mock&&pe(n),this.initRouter(),this.triggerReady()}async loadDependencies(e){const t=Object.entries(this.dependencies);for(const[n,s]of t)e[n]||(e[n]=await s())}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:n,library:s,components:o,materialPath:a}=this,{libraryExports:i,libraryMap:l,materials:c,materialExports:h,materialMapLibrary:d}=se(t,a);for(const p of i){const g=n[p],v=e[p];if(v)s[p]=v;else if(g)e[p]=s[p]=await g();else{const y=l[p]||[];for(const j of y)A(j)&&await ie(p,u.url.append(j,{v:b})),k(j)&&await u.loadScript(u.url.append(j,{v:b}));s[p]=e[p]}}for(const p of c)await u.loadScript(u.url.append(p,{v:b}));const f=this.materials||{};for(const p of h){const g=e[d[p]],v=$.BUILT_IN_COMPONENTS[p];if(v)g&&v.forEach(y=>{o[y]=g[y]});else{const y=f[p]?(await f[p]()).default:e[p];y&&g&&(y.components||[]).forEach(j=>{o[j.name]=oe(j,g)})}}}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:Z}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?Z:lt}))}install(e){const t=e.config.globalProperties.installed||{};for(const[n,s]of Object.entries(this.library))!t[n]&&ce(s)&&(e.use(s),t[n]=!0);this.options.install&&e.use(this.options.install),e.provide(z,this),e.config.globalProperties.installed=t,this.nodeEnv==="development"&&(e.config.errorHandler=(n,s,o)=>{const a=s?.$options.name,i=n?.message||n?.msg||"未知错误",l=`[ ${a} ] ${i}`;console.error("[VTJ Error]:",{err:n,instance:s,info:o},n?.stack),F.ElNotification.error({title:"运行时错误:请在控制台查看详情",message:l})})}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(n=>n.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},n=(s,o=[])=>{for(const a of o){if(a.id===s)return a;if(a.children&&a.children.length){const i=n(s,a.children);if(i)return i}}};return n(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(n=>n.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:n,components:s,mode:o,apis:a}=this,i={mode:o,Vue:n.Vue,components:s,libs:n,apis:a,window,...t},l=H({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return x({...i,dsl:e,loader:l})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return u.logger.warn(`Can not find file: ${e}`),null;const n=`.vtj/vue/${e}.vue`,s=this.modules[n];if(s)return(await s())?.default;const o=await this.getDsl(t.id);return o?this.createDslRenderer(o).renderer:(u.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return m.defineAsyncComponent(async()=>{const n=await this.getDslByUrl(e);return n?(n.name=t||n.name,this.createDslRenderer(n).renderer):null})}definePluginComponent(e){return m.defineAsyncComponent(async()=>{const t=await Y(e,window);return t?(V(t.css),t.component):null})}}function ut(r){const e=new _e(r);return{provider:e,onReady:n=>e.ready(n)}}function G(r={}){const e=m.inject(z);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:n}=r;t&&n&&(async()=>{const s=await e.getDsl(t);s?.__VERSION__!==n&&F.ElNotification.warning({title:s?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const Q=new u.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:r=>r.data?.code===0,showError:r=>{F.ElNotification.error({message:r||"未知错误"})}}}),dt=(r="/vtj/local/repository/${type}.json")=>(e,t)=>Q.send({url:r,method:"post",query:{type:e},data:{type:e,data:t}}),ft=(r="/vtj/local/repository/uploader.json")=>async(e,t)=>await Q.send({url:r,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(n=>n&&n[0]?n[0]:null).catch(()=>null);class B{api;pluginCaches={};uploader;constructor(){this.api=dt(),this.uploader=ft()}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,n=t.filter(o=>re(o))[0];if(!n)return null;const s=this.pluginCaches[n];return s||(this.pluginCaches[n]=Q.send({url:n,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const _=new u.Storage({type:"local",expired:0,prefix:"__VTJ_"});class pt extends B{init(e){const t=new $.ProjectModel(e),n=_.get(`project_${t.id}`),s=Object.assign(t.toDsl(),n||{});return _.save(`project_${t.id}`,s),Promise.resolve(s)}saveProject(e){const t=new $.ProjectModel(e);return _.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return _.save(`materials_${e.id}`,u.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 s=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,s),_.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=_.get(`history_${e}`),n=new $.HistoryModel(t||{id:e});return Promise.resolve(n.toDsl())}getHistoryItem(e,t){const n=_.get(`history_${e}_${t}`);return Promise.resolve(n)}saveHistoryItem(e,t){return _.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{_.remove(`history_${e}_${n}`)}),Promise.resolve(!0)}}class Se extends B{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new $.ProjectModel(e),n=this.projects[t.id]||{},s=Object.assign(t.toDsl(),n);return this.projects[s.id]=s,Promise.resolve(s)}saveProject(e){const t=new $.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=u.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],n=new $.HistoryModel(t||{id:e});return Promise.resolve(n)}getHistoryItem(e,t){const n=`${e}_${t}`,s=this.historyItems[n]||{};return Promise.resolve(s)}saveHistoryItem(e,t){const n=`${e}_${t.id}`;return this.historyItems[n]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{const s=`${e}_${n}`;delete this.historyItems[s]}),Promise.resolve(!0)}}let O=null;function mt(){return O||(O=new Se,O)}class ht extends B{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:u.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 we(r=[]){return r.map(e=>{const{id:t,title:n,icon:s,children:o,hidden:a}=e;return{id:t,title:n,icon:s,hidden:a,url:`/page/${t}`,children:o&&o.length?we(o):void 0}})}function vt(){const r=G(),e=ee.useRoute(),t=m.ref(!1),n=r.project;m.watchEffect(()=>{const{name:a,params:i,meta:l}=e;if(a==="VtjPage"){const c=r.getPage(i.id);t.value=!c?.mask}else if(a==="VtjHomepage"){const c=r.getHomepage();t.value=!c?.mask}else t.value=!l.mask});const s=we(n?.pages),o=n?.config;return{disabled:t,logo:o?.logo,themeSwitchable:o?.themeSwitchable,title:o?.title||n?.description||n?.name||"VTJ App",menus:s}}exports.BUILT_IN_DIRECTIVES=te;exports.BaseService=B;exports.CONTEXT_HOST=U;exports.Context=he;exports.ContextMode=w;exports.DATA_TYPES=ne;exports.JSCodeToString=Pe;exports.LIFE_CYCLES_LIST=Ee;exports.LocalService=ht;exports.MemoryService=Se;exports.Provider=_e;exports.StorageService=pt;exports.VTJ_RENDERER_VERSION=b;exports.adoptedStyleSheets=L;exports.createAssetScripts=Ce;exports.createAssetsCss=be;exports.createDataSources=ve;exports.createLoader=H;exports.createMemoryService=mt;exports.createMetaApi=de;exports.createProvider=ut;exports.createRenderer=x;exports.createSchemaApi=ue;exports.createSchemaApis=fe;exports.defaultLoader=ge;exports.fillBasePath=R;exports.getModifiers=K;exports.getPlugin=Y;exports.getRawComponent=oe;exports.isCSSUrl=A;exports.isJSCode=le;exports.isJSExpression=S;exports.isJSFunction=M;exports.isJSON=re;exports.isJSUrl=k;exports.isVuePlugin=ce;exports.loadCss=ie;exports.loadCssUrl=V;exports.loadScriptUrl=ae;exports.mockApi=me;exports.mockApis=pe;exports.mockCleanup=W;exports.nodeRender=I;exports.parseDeps=se;exports.parseExpression=P;exports.parseFunction=q;exports.providerKey=z;exports.toString=J;exports.useMask=vt;exports.useProvider=G;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Base as ve, BUILT_IN_COMPONENTS as ye, ProjectModel as I, HistoryModel as ee } from "@vtj/core";
2
2
  import { isUrl as ge, url as b, dedupArray as _e, isString as S, isFunction as K, logger as H, createRequest as we, merge as Se, pathToRegexp as $e, pathToRegexpMatch as je, formDataToJson as Ee, delay as be, camelCase as j, upperFirst as Pe, pick as Ce, jsonp as Re, loadScript as Q, Request as Fe, Storage as Ie, mapToObject as N } from "@vtj/utils";
3
- import * as O from "vue";
4
- import { toRef as He, readonly as xe, customRef as Me, ref as q, onBeforeUnmount as Oe, getCurrentScope as De, onScopeDispose as ke, unref as Te, getCurrentInstance as te, watch as ne, computed as re, onMounted as Ae, defineComponent as se, h as A, inject as Be, defineAsyncComponent as X, watchEffect as Ue } from "vue";
3
+ import * as M from "vue";
4
+ import { toRef as He, readonly as xe, customRef as Oe, ref as q, onBeforeUnmount as Me, getCurrentScope as De, onScopeDispose as ke, unref as Te, getCurrentInstance as te, watch as ne, computed as re, onMounted as Ae, defineComponent as se, h as A, inject as Be, defineAsyncComponent as X, watchEffect as Ue } from "vue";
5
5
  import { useRoute as oe } from "vue-router";
6
6
  import { ElNotification as D, ElLoading as Ne } from "element-plus";
7
7
  import x from "mockjs";
@@ -10,10 +10,10 @@ import { XStartup as qe } from "@vtj/ui";
10
10
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
11
11
  * @name @vtj/renderer
12
12
  * @author CHC chenhuachun1549@dingtalk.com
13
- * @version 0.8.114
13
+ * @version 0.8.116
14
14
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
15
15
  */
16
- const P = "0.8.114";
16
+ const P = "0.8.116";
17
17
  var _ = /* @__PURE__ */ ((r) => (r.Runtime = "Runtime", r.Design = "Design", r.Raw = "Raw", r.VNode = "VNode", r))(_ || {});
18
18
  const Y = [
19
19
  "$el",
@@ -292,7 +292,7 @@ class st {
292
292
  const { mode: t, dsl: n, attrs: s } = e;
293
293
  this.__mode = t, n && (this.__id = n.id || null, this.__transform = n.transform || {}), s && Object.assign(this, s);
294
294
  }
295
- setup(e, t = O) {
295
+ setup(e, t = M) {
296
296
  const n = t.getCurrentInstance();
297
297
  if (!n) return;
298
298
  this.__refs = {}, this.$refs = {}, this.context = {}, this.__contextRefs = {}, this.__instance = n.proxy;
@@ -363,7 +363,7 @@ class st {
363
363
  }
364
364
  function B(r) {
365
365
  const {
366
- Vue: e = O,
366
+ Vue: e = M,
367
367
  mode: t = _.Runtime,
368
368
  components: n = {},
369
369
  libs: s = {},
@@ -406,7 +406,7 @@ function B(r) {
406
406
  render() {
407
407
  if (!i.value.nodes) return null;
408
408
  const u = i.value.nodes || [];
409
- return u.length === 1 ? M(u[0], c, e, a) : u.map((f) => M(f, c, e, a));
409
+ return u.length === 1 ? O(u[0], c, e, a) : u.map((f) => O(f, c, e, a));
410
410
  },
411
411
  ...dt(i.value.lifeCycles ?? {}, c)
412
412
  });
@@ -517,7 +517,7 @@ function U(r) {
517
517
  const { getDsl: e, getDslByUrl: t, options: n } = r;
518
518
  return n.window && (T.forEach((s) => {
519
519
  delete n.window[s];
520
- }), T = []), (s, o, a = O) => !o || typeof o == "string" ? s : o.type === "Schema" && o.id ? a.defineAsyncComponent(async () => {
520
+ }), T = []), (s, o, a = M) => !o || typeof o == "string" ? s : o.type === "Schema" && o.id ? a.defineAsyncComponent(async () => {
521
521
  const i = await e(o.id);
522
522
  return i && (i.name = s), i ? B({
523
523
  ...n,
@@ -540,7 +540,7 @@ function U(r) {
540
540
  return i ? (ce(i.css, n.window), i.component) : (console.warn("getPlugin result is null", o), null);
541
541
  })) : s;
542
542
  }
543
- function M(r, e, t = O, n = mt) {
543
+ function O(r, e, t = M, n = mt) {
544
544
  if (!r || !r.name || r.invisible) return null;
545
545
  const { id: s = null, directives: o = [] } = r, { vIf: a, vFor: i, vShow: l, vModels: c, vBind: d } = ht(o);
546
546
  if (a && !vt(a, e))
@@ -624,7 +624,7 @@ function wt(r, e, t, n, s) {
624
624
  return i ? i(t) : o ? S(o) ? r.createTextVNode(o) : g(o) ? r.createTextVNode(
625
625
  ie(n.__parseExpression(o))
626
626
  ) : Array.isArray(o) ? o.map(
627
- (l) => M(l, n, r, s)
627
+ (l) => O(l, n, r, s)
628
628
  ) : null : null;
629
629
  }
630
630
  function St(r, e) {
@@ -666,7 +666,7 @@ function Et(r, e, t, n, s) {
666
666
  return Object.entries(o).reduce((i, [l, { nodes: c, params: d }]) => (i[l] = (u) => {
667
667
  const f = d.length ? Ce(u ?? {}, d) : a(u);
668
668
  return c.map(
669
- (p) => M(p, t.__clone(f), r, n)
669
+ (p) => O(p, t.__clone(f), r, n)
670
670
  );
671
671
  }, i), {});
672
672
  }
@@ -713,12 +713,12 @@ function xt(...r) {
713
713
  if (r.length !== 1)
714
714
  return He(...r);
715
715
  const e = r[0];
716
- return typeof e == "function" ? xe(Me(() => ({ get: e, set: It }))) : q(e);
716
+ return typeof e == "function" ? xe(Oe(() => ({ get: e, set: It }))) : q(e);
717
717
  }
718
- function Mt(r, e) {
719
- Ht() && Oe(r, e);
718
+ function Ot(r, e) {
719
+ Ht() && Me(r, e);
720
720
  }
721
- function Ot(r) {
721
+ function Mt(r) {
722
722
  var e;
723
723
  const t = V(r);
724
724
  return (e = t?.$el) != null ? e : t;
@@ -740,7 +740,7 @@ function Bt(r, e, t = {}) {
740
740
  const a = At(() => n && "MutationObserver" in n), i = () => {
741
741
  o && (o.disconnect(), o = void 0);
742
742
  }, l = re(() => {
743
- const f = V(r), p = (Array.isArray(f) ? f : [f]).map(Ot).filter(Ft);
743
+ const f = V(r), p = (Array.isArray(f) ? f : [f]).map(Mt).filter(Ft);
744
744
  return new Set(p);
745
745
  }), c = ne(
746
746
  () => l.value,
@@ -781,7 +781,7 @@ function Ut(r = null, e = {}) {
781
781
  o && o.title !== l.value && (l.value = d(o.title));
782
782
  },
783
783
  { childList: !0 }
784
- ), Mt(() => {
784
+ ), Ot(() => {
785
785
  if (a) {
786
786
  const u = a(i, l.value || "");
787
787
  u != null && o && (o.title = u);
@@ -846,7 +846,12 @@ class qt extends ve {
846
846
  if (this.project = t ? await t() : await this.service.init(e), !this.project)
847
847
  throw new Error("project is null");
848
848
  const { apis: n = [], meta: s = [] } = this.project, o = window;
849
- o.CKEDITOR_VERSION = void 0, this.nodeEnv !== "production" && await this.loadAssets(o), this.apis = tt(n, s, this.adapter), le(), this.project.config?.mock && nt(n), this.initRouter(), this.triggerReady();
849
+ o.CKEDITOR_VERSION = void 0, this.nodeEnv !== "production" ? await this.loadAssets(o) : await this.loadDependencies(o), this.apis = tt(n, s, this.adapter), le(), this.project.config?.mock && nt(n), this.initRouter(), this.triggerReady();
850
+ }
851
+ async loadDependencies(e) {
852
+ const t = Object.entries(this.dependencies);
853
+ for (const [n, s] of t)
854
+ e[n] || (e[n] = await s());
850
855
  }
851
856
  async loadAssets(e) {
852
857
  const { dependencies: t = [] } = this.project, { dependencies: n, library: s, components: o, materialPath: a } = this, {
@@ -1393,7 +1398,7 @@ export {
1393
1398
  rt as mockApi,
1394
1399
  nt as mockApis,
1395
1400
  le as mockCleanup,
1396
- M as nodeRender,
1401
+ O as nodeRender,
1397
1402
  We as parseDeps,
1398
1403
  C as parseExpression,
1399
1404
  z as parseFunction,
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@vtj/renderer",
3
3
  "private": false,
4
- "version": "0.8.114",
4
+ "version": "0.8.116",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "mockjs": "~1.1.0",
8
- "@vtj/core": "~0.8.114",
9
- "@vtj/icons": "~0.8.114",
10
- "@vtj/ui": "~0.8.114",
11
- "@vtj/utils": "~0.8.114"
8
+ "@vtj/core": "~0.8.116",
9
+ "@vtj/ui": "~0.8.116",
10
+ "@vtj/icons": "~0.8.116",
11
+ "@vtj/utils": "~0.8.116"
12
12
  },
13
13
  "devDependencies": {
14
14
  "vue": "~3.4.15",
@@ -45,6 +45,7 @@ export declare class Provider extends Base {
45
45
  private urlDslCaches;
46
46
  constructor(options: ProviderOptions);
47
47
  load(project: ProjectSchema): Promise<void>;
48
+ private loadDependencies;
48
49
  private loadAssets;
49
50
  private initRouter;
50
51
  install(app: App): void;
@@ -2,7 +2,7 @@
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.114
5
+ * @version 0.8.115
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.8.114";
8
+ export declare const version = "0.8.115";