@vtj/renderer 0.8.43 → 0.8.45

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"),u=require("@vtj/utils"),p=require("vue"),re=require("vue-router"),H=require("element-plus"),D=require("mockjs"),Ce=require("@vtj/ui");function be(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=be(p);/**!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@vtj/core"),u=require("@vtj/utils"),p=require("vue"),re=require("vue-router"),H=require("element-plus"),D=require("mockjs"),Ce=require("@vtj/ui");function Pe(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=Pe(p);/**!
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.43
5
+ * @version 0.8.45
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const R="0.8.43";var j=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(j||{});const J=["$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"],se=["vIf","vShow","vModel","vFor","vBind"],oe={String,Number,Boolean,Array,Object,Function,Date};function M(n,e){return n.map(t=>u.isUrl(t)?t:`${e}${t}`)}function N(n){return/\.css$/.test(n)}function U(n){return/\.js$/.test(n)}function ie(n){return/\.json$/.test(n)}function Re(n){return n.map(e=>`<script src="${u.url.append(e,{v:R})}"><\/script>`).join("")}function Fe(n=[]){return n.map(e=>`<link rel="stylesheet" href="${u.url.append(e,{v:R})}" />`).join("")}function ae(n,e){const t=n.filter(f=>!!f.enabled),r=[],s=[],o=[],a=[],i={},l={},c=[],m={};return t.forEach(({urls:f,assetsUrl:d,library:v,assetsLibrary:$,localeLibrary:g})=>{f?.forEach(w=>{U(w)&&r.push(w),N(w)&&s.push(w)}),v&&(a.push(v),i[v]=M(f||[],e),g&&(l[v]=g)),d&&o.push(d),$&&c.push($),v&&$&&(m[$]=v)}),{scripts:M(r,e),css:M(s,e),materials:M(o,e),libraryExports:a,materialExports:u.dedupArray(c),materialMapLibrary:m,libraryMap:i,libraryLocaleMap:l}}function ce(n,e){const{name:t,parent:r,alias:s}=n;return r?e[r]?.[s||t]:e[s||t]}function W(n){return u.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(l=>l.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 le(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 ue(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 l of n){const c=r.createElement("script");c.src=l,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=m=>{i(m)},s.appendChild(c)}})}function fe(n){return u.isFunction(n)||u.isFunction(n?.install)}function F(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,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,n,e?.__self??e),r)throw s}}function V(n,e,t=!1,r=!1){const s=F(n,e,t,r);if(typeof s!="function"&&(u.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 x(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function de(n){return S(n)||x(n)}function Ie(n){return de(n)?n.value:JSON.stringify(n)}let P=null;const Me=u.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:n=>n.data?.code===0||!!n.data?.success,failMessage:!0,showError:n=>{H.ElNotification.error({message:n||"未知错误"})},showLoading:()=>{P&&P.close(),P=H.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{P&&(P.close(),P=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?F(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:s}};return(a,i)=>r.send(u.merge(o,i||{},{data:a}))}}function me(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 he(n=[],e=[],t){const r={};for(const s of n)r[s.id]=pe(s,t);for(const s of e)r[s.id]=me(s,t);return r}function ve(n=[]){D.setup({timeout:"50-500"}),X(),n.forEach(e=>ge(e))}function ge(n){if(!n.mock)return;const{url:e,mockTemplate:t}=n;if(e&&t){const r=u.pathToRegexp(`${e}(.*)`),s=u.pathToRegexpMatch(e,{decode:decodeURIComponent}),o=F(t,{},!0);D.mock(r,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}),D.mock(o(a))})}}function X(){D._mocked={}}class ye{__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.__refs={},this.$refs={},this.context={},this.__contextRefs={},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()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__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===j.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===j.Runtime){const{id:t,type:r}=e,s=t?this.__transform[t]??e.value:e.value;return F({type:r,value:s},this)}else return F(e,this)}__ref(e=null,t){if(this.__mode!==j.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,j.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 k(n){const{Vue:e=B,mode:t=j.Runtime,components:r={},libs:s={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:r,$libs:s,$apis:o},c=new ye({mode:t,dsl:i.value,attrs:l}),m=e.defineComponent({name:i.value.name,props:{...xe(i.value.props??[],c)},setup(f){c.$props=f,c.props=f,i.value.id&&Y(n.window||window,i.value.id,i.value.css||""),c.state=Te(e,i.value.state??{},c);const d=He(e,i.value.computed??{},c),v=De(i.value.methods??{},c),$=ke(e,i.value.inject,c),g=_e(i.value.dataSources||{},c),w={...$,...d,...v,...g};return c.setup(w,e),Ae(e,i.value.watch??[],c),{vtj:c}},emits:Oe(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const f=i.value.nodes||[];return f.length===1?O(f[0],c,e,a):f.map(d=>O(d,c,e,a))},...Be(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(m),context:c}}function Oe(n=[]){return n.map(e=>u.isString(e)?e:e.name)}function xe(n=[],e){const t=r=>r?(Array.isArray(r)?r:[r]).map(o=>oe[o]):void 0;return n.map(r=>u.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 Te(n,e,t){return n.reactive(Object.keys(e||{}).reduce((r,s)=>{let o=e[s];return S(o)?o=t.__parseExpression(o):x(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 De(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}function ke(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,l=S(s.default)?t.__parseExpression(s.default):s.default??null;return r[o]=n.inject(i,l),r},{})}function _e(n,e){return Object.keys(n).reduce((t,r)=>{const s=n[r],o=e.$apis[s.ref],a=x(s.transform)?s.transform.value?e.__parseFunction(s.transform):void 0:s.transform;return t[r]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l},t},{})}function Ae(n,e=[],t){e.forEach(r=>{n.watch(t.__parseExpression(r.source),t.__parseFunction(r.handler),{deep:r.deep,immediate:r.immediate})})}function Be(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}let L=[];const Se=n=>n;async function z(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 ue(s,r,e).catch(()=>null);return a?{component:a,css:o}:null}function A(n){const{getDsl:e,getDslByUrl:t,options:r}=n;return r.window&&(L.forEach(s=>{delete r.window[s]}),L=[]),(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?k({...r,Vue:a,dsl:i,mode:j.Runtime,loader:A(n)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=s),i?k({...r,Vue:a,dsl:i,mode:j.Runtime,loader:A(n)}).renderer:null}):o.type==="Plugin"?(o.library&&L.push(o.library),a.defineAsyncComponent(async()=>{const i=await z(o,r.window);return i?(K(i.css,r.window),i.component):null})):s}function O(n,e,t=B,r=Se){if(!n||!n.name||n.invisible)return null;const{id:s=null,directives:o=[]}=n,{vIf:a,vFor:i,vShow:l,vModels:c,vBind:m}=Ne(o);if(a&&!Ue(a,e))return null;const f=d=>{const v=d.$components,$=(()=>{if(n.name==="component")return qe(d,n.props?.is);if(n.name==="slot")return n.name;const y=r(n.name,n.from,t);return u.isString(y)?v[y]??y:y})(),g=Le(s,n.props??{},d),w=Je(t,n.events??{},d);if(n.name==="slot")return Ve(t,n,g,d,r);m&&Object.assign(g,d.__parseExpression(m.value)),l&&(g.style=Object.assign(g.style??{},Ye(l,d))),c.forEach(y=>{Object.assign(g,Ke(t,y,d))});const h=Xe(t,n.children??[],d,r,n);return t.createVNode($,{...g,...w},h)};return i?Qe(i,f,e):f(e)}function Ne(n=[]){const e=n.find(i=>u.camelCase(i.name)==="vIf"),t=n.find(i=>u.camelCase(i.name)==="vFor"),r=n.find(i=>u.camelCase(i.name)==="vShow"),s=n.find(i=>u.camelCase(i.name)==="vBind"),o=n.filter(i=>u.camelCase(i.name)==="vModel"),a=n.filter(i=>!se.includes(u.camelCase(i.name)));return{vIf:e,vFor:t,vShow:r,vModels:o,vBind:s,others:a}}function Ue(n,e){return!!e.__parseExpression(n.value)}function qe(n,e){return e?S(e)?n.__parseExpression(e):e:"div"}function Le(n,e,t){const r=Object.keys(e||{}).reduce((s,o)=>{let a=e[o];return S(a)?a=t.__parseExpression(a):x(a)&&(a=t.__parseFunction(a)),s[o]=a,s},{});return r.ref=t.__ref(n,r.ref),r}function Je(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],l=G(i.modifiers),c=l.find(d=>r.includes(d)),m="on"+u.upperFirst(a)+(c&&s[c]||""),f=t.__parseFunction(i.handler);return f&&(o[m]=n.withModifiers(f,l)),o},{})}function G(n={},e=!1){const t=Object.keys(n);return e?t.map(r=>"."+r):t}function Ve(n,e,t,r,s){const{children:o}=e,a=We(e,r),i=r.$slots?.[a.name];return i?i(t):o?u.isString(o)?n.createTextVNode(o):S(o)?n.createTextVNode(W(r.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,r,n,s)):null:null}function We(n,e){const{props:t}=n,r=t?.name||"default";return{name:S(r)?e.__parseExpression(r):r,params:[]}}function Ye(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ke(n,e,t){const r={type:"JSFunction",value:e.value?.value?`(v) => {
7
+ */const R="0.8.45";var j=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(j||{});const J=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],be=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],se=["vIf","vShow","vModel","vFor","vBind"],oe={String,Number,Boolean,Array,Object,Function,Date};function M(n,e){return n.map(t=>u.isUrl(t)?t:`${e}${t}`)}function N(n){return/\.css$/.test(n)}function U(n){return/\.js$/.test(n)}function ie(n){return/\.json$/.test(n)}function Re(n){return n.map(e=>`<script src="${u.url.append(e,{v:R})}"><\/script>`).join("")}function Fe(n=[]){return n.map(e=>`<link rel="stylesheet" href="${u.url.append(e,{v:R})}" />`).join("")}function ae(n,e){const t=n.filter(d=>!!d.enabled),r=[],s=[],o=[],a=[],i={},l={},c=[],m={};return t.forEach(({urls:d,assetsUrl:f,library:v,assetsLibrary:$,localeLibrary:g})=>{d?.forEach(w=>{U(w)&&r.push(w),N(w)&&s.push(w)}),v&&(a.push(v),i[v]=M(d||[],e),g&&(l[v]=g)),f&&o.push(f),$&&c.push($),v&&$&&(m[$]=v)}),{scripts:M(r,e),css:M(s,e),materials:M(o,e),libraryExports:a,materialExports:u.dedupArray(c),materialMapLibrary:m,libraryMap:i,libraryLocaleMap:l}}function ce(n,e){const{name:t,parent:r,alias:s}=n;return r?e[r]?.[s||t]:e[s||t]}function W(n){return u.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(l=>l.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 le(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 ue(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 l of n){const c=r.createElement("script");c.src=l,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=m=>{i(m)},s.appendChild(c)}})}function de(n){return u.isFunction(n)||u.isFunction(n?.install)}function F(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,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,n,e?.__self??e),r)throw s}}function V(n,e,t=!1,r=!1){const s=F(n,e,t,r);if(typeof s!="function"&&(u.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 x(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function fe(n){return S(n)||x(n)}function Ie(n){return fe(n)?n.value:JSON.stringify(n)}let b=null;const Me=u.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:n=>n.data?.code===0||!!n.data?.success,failMessage:!0,showError:n=>{H.ElNotification.error({message:n||"未知错误"})},showLoading:()=>{b&&b.close(),b=H.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?F(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:s}};return(a,i)=>r.send(u.merge(o,i||{},{data:a}))}}function me(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 he(n=[],e=[],t){const r={};for(const s of n)r[s.id]=pe(s,t);for(const s of e)r[s.id]=me(s,t);return r}function ve(n=[]){D.setup({timeout:"50-500"}),X(),n.forEach(e=>ge(e))}function ge(n){if(!n.mock)return;const{url:e,mockTemplate:t}=n;if(e&&t){const r=u.pathToRegexp(`${e}(.*)`),s=u.pathToRegexpMatch(e,{decode:decodeURIComponent}),o=F(t,{},!0);D.mock(r,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}),D.mock(o(a))})}}function X(){D._mocked={}}class ye{__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.__refs={},this.$refs={},this.context={},this.__contextRefs={},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()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__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===j.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===j.Runtime){const{id:t,type:r}=e,s=t?this.__transform[t]??e.value:e.value;return F({type:r,value:s},this)}else return F(e,this)}__ref(e=null,t){if(this.__mode!==j.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,j.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 k(n){const{Vue:e=B,mode:t=j.Runtime,components:r={},libs:s={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:r,$libs:s,$apis:o},c=new ye({mode:t,dsl:i.value,attrs:l}),m=e.defineComponent({name:i.value.name,props:{...xe(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=Te(e,i.value.state??{},c);const f=He(e,i.value.computed??{},c),v=De(i.value.methods??{},c),$=ke(e,i.value.inject,c),g=_e(i.value.dataSources||{},c),w={...$,...f,...v,...g};return c.setup(w,e),Ae(e,i.value.watch??[],c),{vtj:c}},emits:Oe(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const d=i.value.nodes||[];return d.length===1?O(d[0],c,e,a):d.map(f=>O(f,c,e,a))},...Be(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(m),context:c}}function Oe(n=[]){return n.map(e=>u.isString(e)?e:e.name)}function xe(n=[],e){const t=r=>r?(Array.isArray(r)?r:[r]).map(o=>oe[o]):void 0;return n.map(r=>u.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 Te(n,e,t){return n.reactive(Object.keys(e||{}).reduce((r,s)=>{let o=e[s];return S(o)?o=t.__parseExpression(o):x(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 De(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}function ke(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,l=S(s.default)?t.__parseExpression(s.default):s.default??null;return r[o]=n.inject(i,l),r},{})}function _e(n,e){return Object.keys(n).reduce((t,r)=>{const s=n[r],o=e.$apis[s.ref],a=x(s.transform)?s.transform.value?e.__parseFunction(s.transform):void 0:s.transform;return t[r]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l},t},{})}function Ae(n,e=[],t){e.forEach(r=>{n.watch(t.__parseExpression(r.source),t.__parseFunction(r.handler),{deep:r.deep,immediate:r.immediate})})}function Be(n,e){return Object.entries(n??{}).reduce((t,[r,s])=>(t[r]=e.__parseFunction(s),t),{})}let L=[];const Se=n=>n;async function z(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 ue(s,r,e).catch(i=>(console.warn("loadScriptUrl error",s,r,i),null));return a?{component:a,css:o}:null}function A(n){const{getDsl:e,getDslByUrl:t,options:r}=n;return r.window&&(L.forEach(s=>{delete r.window[s]}),L=[]),(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?k({...r,Vue:a,dsl:i,mode:j.Runtime,loader:A(n)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=s),i?k({...r,Vue:a,dsl:i,mode:j.Runtime,loader:A(n)}).renderer:null}):o.type==="Plugin"?(o.library&&L.push(o.library),a.defineAsyncComponent(async()=>{const i=await z(o,r.window);return i?(K(i.css,r.window),i.component):(console.warn("getPlugin result is null",o),null)})):s}function O(n,e,t=B,r=Se){if(!n||!n.name||n.invisible)return null;const{id:s=null,directives:o=[]}=n,{vIf:a,vFor:i,vShow:l,vModels:c,vBind:m}=Ne(o);if(a&&!Ue(a,e))return null;const d=f=>{const v=f.$components,$=(()=>{if(n.name==="component")return qe(f,n.props?.is);if(n.name==="slot")return n.name;const y=r(n.name,n.from,t);return u.isString(y)?v[y]??y:y})(),g=Le(s,n.props??{},f),w=Je(t,n.events??{},f);if(n.name==="slot")return Ve(t,n,g,f,r);m&&Object.assign(g,f.__parseExpression(m.value)),l&&(g.style=Object.assign(g.style??{},Ye(l,f))),c.forEach(y=>{Object.assign(g,Ke(t,y,f))});const h=Xe(t,n.children??[],f,r,n);return t.createVNode($,{...g,...w},h)};return i?Qe(i,d,e):d(e)}function Ne(n=[]){const e=n.find(i=>u.camelCase(i.name)==="vIf"),t=n.find(i=>u.camelCase(i.name)==="vFor"),r=n.find(i=>u.camelCase(i.name)==="vShow"),s=n.find(i=>u.camelCase(i.name)==="vBind"),o=n.filter(i=>u.camelCase(i.name)==="vModel"),a=n.filter(i=>!se.includes(u.camelCase(i.name)));return{vIf:e,vFor:t,vShow:r,vModels:o,vBind:s,others:a}}function Ue(n,e){return!!e.__parseExpression(n.value)}function qe(n,e){return e?S(e)?n.__parseExpression(e):e:"div"}function Le(n,e,t){const r=Object.keys(e||{}).reduce((s,o)=>{let a=e[o];return S(a)?a=t.__parseExpression(a):x(a)&&(a=t.__parseFunction(a)),s[o]=a,s},{});return r.ref=t.__ref(n,r.ref),r}function Je(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],l=G(i.modifiers),c=l.find(f=>r.includes(f)),m="on"+u.upperFirst(a)+(c&&s[c]||""),d=t.__parseFunction(i.handler);return d&&(o[m]=n.withModifiers(d,l)),o},{})}function G(n={},e=!1){const t=Object.keys(n);return e?t.map(r=>"."+r):t}function Ve(n,e,t,r,s){const{children:o}=e,a=We(e,r),i=r.$slots?.[a.name];return i?i(t):o?u.isString(o)?n.createTextVNode(o):S(o)?n.createTextVNode(W(r.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,r,n,s)):null:null}function We(n,e){const{props:t}=n,r=t?.name||"default";return{name:S(r)?e.__parseExpression(r):r,params:[]}}function Ye(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Ke(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=G(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 Xe(n,e,t,r,s){if(!e)return null;if(u.isString(e))return{default:()=>e};if(S(e))return{default:()=>W(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=ze(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:m}])=>(i[l]=f=>{const d=m.length?u.pick(f??{},m):a(f);return c.map(v=>O(v,t.__clone(d),n,r))},i),{})}return null}function ze(n){const e={default:{params:[],nodes:[]}};for(const t of n){const r=Ge(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 Ge(n="default"){return u.isString(n)?{name:n,params:[]}:{params:[],...n}}function Qe(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((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}))):(console.warn("[vForRender]:",`${r?.value} is not a Arrary`),[])}function Ze(n){return p.getCurrentScope()?(p.onScopeDispose(n),!0):!1}function Q(n){return typeof n=="function"?n():p.unref(n)}const we=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const et=n=>n!=null,tt=()=>{};function nt(n){return p.getCurrentInstance()}function rt(...n){if(n.length!==1)return p.toRef(...n);const e=n[0];return typeof e=="function"?p.readonly(p.customRef(()=>({get:e,set:tt}))):p.ref(e)}function st(n,e){nt()&&p.onBeforeUnmount(n,e)}function ot(n){var e;const t=Q(n);return(e=t?.$el)!=null?e:t}const it=we?window:void 0,at=we?window.document:void 0;function ct(){const n=p.ref(!1),e=p.getCurrentInstance();return e&&p.onMounted(()=>{n.value=!0},e),n}function lt(n){const e=ct();return p.computed(()=>(e.value,!!n()))}function ut(n,e,t={}){const{window:r=it,...s}=t;let o;const a=lt(()=>r&&"MutationObserver"in r),i=()=>{o&&(o.disconnect(),o=void 0)},l=p.computed(()=>{const d=Q(n),v=(Array.isArray(d)?d:[d]).map(ot).filter(et);return new Set(v)}),c=p.watch(()=>l.value,d=>{i(),a.value&&d.size&&(o=new MutationObserver(e),d.forEach(v=>o.observe(v,s)))},{immediate:!0,flush:"post"}),m=()=>o?.takeRecords(),f=()=>{i(),c()};return Ze(f),{isSupported:a,stop:f,takeRecords:m}}function ft(n=null,e={}){var t,r,s;const{document:o=at,restoreOnUnmount:a=f=>f}=e,i=(t=o?.title)!=null?t:"",l=rt((r=n??o?.title)!=null?r:null),c=n&&typeof n=="function";function m(f){if(!("titleTemplate"in e))return f;const d=e.titleTemplate||"%s";return typeof d=="function"?d(f):Q(d).replace(/%s/g,f)}return p.watch(l,(f,d)=>{f!==d&&o&&(o.title=m(typeof f=="string"?f:""))},{immediate:!0}),e.observe&&!e.titleTemplate&&o&&!c&&ut((s=o.head)==null?void 0:s.querySelector("title"),()=>{o&&o.title!==l.value&&(l.value=m(o.title))},{childList:!0}),st(()=>{if(a){const f=a(i,l.value||"");f!=null&&o&&(o.title=f)}}),l}const ne=p.defineComponent({name:"VtjPageContainer",async setup(){const n=ee(),e=re.useRoute(),t=e.params.id,r=t?n.getPage(t):n.getHomepage(),s=r?await n.getRenderComponent(r.id):null;return r&&ft(r.title||"VTJ"),{provider:n,component:s,file:r,query:e.query}},render(){return this.component?p.h(this.component,this.query):p.h("div","页面不存在")}}),dt=p.defineComponent({name:"VtjStartupContainer",render(){return p.h(Ce.XStartup)}}),Z=Symbol("Provider");class je extends E.Base{constructor(e){super(),this.options=e;const{service:t,mode:r=j.Raw,dependencies:s,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:m=null,materialPath:f="./",nodeEnv:d="development"}=e;this.mode=r,this.modules=c,this.service=t,this.router=m,this.materialPath=f,this.nodeEnv=d,s&&(this.dependencies=s),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i),r!==j.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Me,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{dependencies:r=[],apis:s=[],meta:o=[]}=this.project,{dependencies:a,library:i,components:l,materialPath:c}=this,{libraryExports:m,libraryMap:f,materials:d,materialExports:v,materialMapLibrary:$}=ae(r,c),g=window;g.CKEDITOR_VERSION=void 0;for(const h of m){const y=a[h],I=g[h];if(I)i[h]=I;else if(y)g[h]=i[h]=await y();else{const C=f[h]||[];for(const b of C)N(b)&&await le(h,u.url.append(b,{v:R})),U(b)&&await u.loadScript(u.url.append(b,{v:R}));i[h]=g[h]}}for(const h of d)await u.loadScript(u.url.append(h,{v:R}));const w=this.materials||{};for(const h of v){const y=g[$[h]],I=E.BUILT_IN_COMPONENTS[h];if(I)y&&I.forEach(C=>{l[C]=y[C]});else{const C=w[h]?(await w[h]()).default:g[h];C&&y&&(C.components||[]).forEach(b=>{l[b.name]=ce(b,y)})}}this.apis=he(s,o,this.adapter),X(),this.project.config?.mock&&ve(s),this.initRouter(),this.triggerReady()}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:ne}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?ne:dt}))}install(e){const t=e.config.globalProperties.installed||{};for(const[r,s]of Object.entries(this.library))!t[r]&&fe(s)&&(e.use(s),t[r]=!0);this.options.install&&e.use(this.options.install),e.provide(Z,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},l=A({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return k({...i,dsl:e,loader:l})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return u.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:(u.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return p.defineAsyncComponent(async()=>{const r=await this.getDslByUrl(e);return r?(r.name=t||r.name,this.createDslRenderer(r).renderer):null})}definePluginComponent(e){return p.defineAsyncComponent(async()=>{const t=await z(e,window);return t?(K(t.css),t.component):null})}}function pt(n){const e=new je(n);return{provider:e,onReady:r=>e.ready(r)}}function ee(n={}){const e=p.inject(Z);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&&H.ElNotification.warning({title:s?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const te=new u.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0,showError:n=>{H.ElNotification.error({message:n||"未知错误"})}}}),mt=(n="/vtj/local/repository/${type}.json")=>(e,t)=>te.send({url:n,method:"post",query:{type:e},data:{type:e,data:t}}),ht=(n="/vtj/local/repository/uploader.json")=>async(e,t)=>await te.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=mt(),this.uploader=ht()}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=>ie(o))[0];if(!r)return null;const s=this.pluginCaches[r];return s||(this.pluginCaches[r]=te.send({url:r,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const _=new u.Storage({type:"local",expired:0,prefix:"__VTJ_"});class vt extends q{init(e){const t=new E.ProjectModel(e),r=_.get(`project_${t.id}`),s=Object.assign(t.toDsl(),r||{});return _.save(`project_${t.id}`,s),Promise.resolve(s)}saveProject(e){const t=new E.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}`),r=new E.HistoryModel(t||{id:e});return Promise.resolve(r.toDsl())}getHistoryItem(e,t){const r=_.get(`history_${e}_${t}`);return Promise.resolve(r)}saveHistoryItem(e,t){return _.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(r=>{_.remove(`history_${e}_${r}`)}),Promise.resolve(!0)}}class $e 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]=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],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 T=null;function gt(){return T||(T=new $e,T)}class yt 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: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 Ee(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?Ee(o):void 0}})}function _t(){const n=ee(),e=re.useRoute(),t=p.ref(!1),r=n.project;p.watchEffect(()=>{const{name:a,params:i,meta:l}=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=!l.mask});const s=Ee(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=se;exports.BaseService=q;exports.CONTEXT_HOST=J;exports.Context=ye;exports.ContextMode=j;exports.DATA_TYPES=oe;exports.JSCodeToString=Ie;exports.LIFE_CYCLES_LIST=Pe;exports.LocalService=yt;exports.MemoryService=$e;exports.Provider=je;exports.StorageService=vt;exports.VTJ_RENDERER_VERSION=R;exports.adoptedStyleSheets=Y;exports.createAssetScripts=Re;exports.createAssetsCss=Fe;exports.createDataSources=_e;exports.createLoader=A;exports.createMemoryService=gt;exports.createMetaApi=me;exports.createProvider=pt;exports.createRenderer=k;exports.createSchemaApi=pe;exports.createSchemaApis=he;exports.defaultLoader=Se;exports.fillBasePath=M;exports.getModifiers=G;exports.getPlugin=z;exports.getRawComponent=ce;exports.isCSSUrl=N;exports.isJSCode=de;exports.isJSExpression=S;exports.isJSFunction=x;exports.isJSON=ie;exports.isJSUrl=U;exports.isVuePlugin=fe;exports.loadCss=le;exports.loadCssUrl=K;exports.loadScriptUrl=ue;exports.mockApi=ge;exports.mockApis=ve;exports.mockCleanup=X;exports.nodeRender=O;exports.parseDeps=ae;exports.parseExpression=F;exports.parseFunction=V;exports.providerKey=Z;exports.toString=W;exports.useMask=_t;exports.useProvider=ee;
10
+ }`:"(v) => {}"},s=t.__parseFunction(r),o=G(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 Xe(n,e,t,r,s){if(!e)return null;if(u.isString(e))return{default:()=>e};if(S(e))return{default:()=>W(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=ze(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:m}])=>(i[l]=d=>{const f=m.length?u.pick(d??{},m):a(d);return c.map(v=>O(v,t.__clone(f),n,r))},i),{})}return null}function ze(n){const e={default:{params:[],nodes:[]}};for(const t of n){const r=Ge(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 Ge(n="default"){return u.isString(n)?{name:n,params:[]}:{params:[],...n}}function Qe(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((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}))):(console.warn("[vForRender]:",`${r?.value} is not a Arrary`),[])}function Ze(n){return p.getCurrentScope()?(p.onScopeDispose(n),!0):!1}function Q(n){return typeof n=="function"?n():p.unref(n)}const we=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const et=n=>n!=null,tt=()=>{};function nt(n){return p.getCurrentInstance()}function rt(...n){if(n.length!==1)return p.toRef(...n);const e=n[0];return typeof e=="function"?p.readonly(p.customRef(()=>({get:e,set:tt}))):p.ref(e)}function st(n,e){nt()&&p.onBeforeUnmount(n,e)}function ot(n){var e;const t=Q(n);return(e=t?.$el)!=null?e:t}const it=we?window:void 0,at=we?window.document:void 0;function ct(){const n=p.ref(!1),e=p.getCurrentInstance();return e&&p.onMounted(()=>{n.value=!0},e),n}function lt(n){const e=ct();return p.computed(()=>(e.value,!!n()))}function ut(n,e,t={}){const{window:r=it,...s}=t;let o;const a=lt(()=>r&&"MutationObserver"in r),i=()=>{o&&(o.disconnect(),o=void 0)},l=p.computed(()=>{const f=Q(n),v=(Array.isArray(f)?f:[f]).map(ot).filter(et);return new Set(v)}),c=p.watch(()=>l.value,f=>{i(),a.value&&f.size&&(o=new MutationObserver(e),f.forEach(v=>o.observe(v,s)))},{immediate:!0,flush:"post"}),m=()=>o?.takeRecords(),d=()=>{i(),c()};return Ze(d),{isSupported:a,stop:d,takeRecords:m}}function dt(n=null,e={}){var t,r,s;const{document:o=at,restoreOnUnmount:a=d=>d}=e,i=(t=o?.title)!=null?t:"",l=rt((r=n??o?.title)!=null?r:null),c=n&&typeof n=="function";function m(d){if(!("titleTemplate"in e))return d;const f=e.titleTemplate||"%s";return typeof f=="function"?f(d):Q(f).replace(/%s/g,d)}return p.watch(l,(d,f)=>{d!==f&&o&&(o.title=m(typeof d=="string"?d:""))},{immediate:!0}),e.observe&&!e.titleTemplate&&o&&!c&&ut((s=o.head)==null?void 0:s.querySelector("title"),()=>{o&&o.title!==l.value&&(l.value=m(o.title))},{childList:!0}),st(()=>{if(a){const d=a(i,l.value||"");d!=null&&o&&(o.title=d)}}),l}const ne=p.defineComponent({name:"VtjPageContainer",async setup(){const n=ee(),e=re.useRoute(),t=e.params.id,r=t?n.getPage(t):n.getHomepage(),s=r?await n.getRenderComponent(r.id):null;return r&&dt(r.title||"VTJ"),{provider:n,component:s,file:r,query:e.query}},render(){return this.component?p.h(this.component,this.query):p.h("div","页面不存在")}}),ft=p.defineComponent({name:"VtjStartupContainer",render(){return p.h(Ce.XStartup)}}),Z=Symbol("Provider");class je extends E.Base{constructor(e){super(),this.options=e;const{service:t,mode:r=j.Raw,dependencies:s,materials:o,project:a={},adapter:i={},globals:l={},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,l),Object.assign(this.adapter,i),r!==j.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Me,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{dependencies:r=[],apis:s=[],meta:o=[]}=this.project,{dependencies:a,library:i,components:l,materialPath:c}=this,{libraryExports:m,libraryMap:d,materials:f,materialExports:v,materialMapLibrary:$}=ae(r,c),g=window;g.CKEDITOR_VERSION=void 0;for(const h of m){const y=a[h],I=g[h];if(I)i[h]=I;else if(y)g[h]=i[h]=await y();else{const C=d[h]||[];for(const P of C)N(P)&&await le(h,u.url.append(P,{v:R})),U(P)&&await u.loadScript(u.url.append(P,{v:R}));i[h]=g[h]}}for(const h of f)await u.loadScript(u.url.append(h,{v:R}));const w=this.materials||{};for(const h of v){const y=g[$[h]],I=E.BUILT_IN_COMPONENTS[h];if(I)y&&I.forEach(C=>{l[C]=y[C]});else{const C=w[h]?(await w[h]()).default:g[h];C&&y&&(C.components||[]).forEach(P=>{l[P.name]=ce(P,y)})}}this.apis=he(s,o,this.adapter),X(),this.project.config?.mock&&ve(s),this.initRouter(),this.triggerReady()}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:ne}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?ne:ft}))}install(e){const t=e.config.globalProperties.installed||{};for(const[r,s]of Object.entries(this.library))!t[r]&&de(s)&&(e.use(s),t[r]=!0);this.options.install&&e.use(this.options.install),e.provide(Z,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},l=A({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return k({...i,dsl:e,loader:l})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return u.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:(u.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return p.defineAsyncComponent(async()=>{const r=await this.getDslByUrl(e);return r?(r.name=t||r.name,this.createDslRenderer(r).renderer):null})}definePluginComponent(e){return p.defineAsyncComponent(async()=>{const t=await z(e,window);return t?(K(t.css),t.component):null})}}function pt(n){const e=new je(n);return{provider:e,onReady:r=>e.ready(r)}}function ee(n={}){const e=p.inject(Z);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&&H.ElNotification.warning({title:s?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const te=new u.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0,showError:n=>{H.ElNotification.error({message:n||"未知错误"})}}}),mt=(n="/vtj/local/repository/${type}.json")=>(e,t)=>te.send({url:n,method:"post",query:{type:e},data:{type:e,data:t}}),ht=(n="/vtj/local/repository/uploader.json")=>async(e,t)=>await te.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=mt(),this.uploader=ht()}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=>ie(o))[0];if(!r)return null;const s=this.pluginCaches[r];return s||(this.pluginCaches[r]=te.send({url:r,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const _=new u.Storage({type:"local",expired:0,prefix:"__VTJ_"});class vt extends q{init(e){const t=new E.ProjectModel(e),r=_.get(`project_${t.id}`),s=Object.assign(t.toDsl(),r||{});return _.save(`project_${t.id}`,s),Promise.resolve(s)}saveProject(e){const t=new E.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}`),r=new E.HistoryModel(t||{id:e});return Promise.resolve(r.toDsl())}getHistoryItem(e,t){const r=_.get(`history_${e}_${t}`);return Promise.resolve(r)}saveHistoryItem(e,t){return _.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(r=>{_.remove(`history_${e}_${r}`)}),Promise.resolve(!0)}}class $e 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]=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],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 T=null;function gt(){return T||(T=new $e,T)}class yt 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: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 Ee(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?Ee(o):void 0}})}function _t(){const n=ee(),e=re.useRoute(),t=p.ref(!1),r=n.project;p.watchEffect(()=>{const{name:a,params:i,meta:l}=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=!l.mask});const s=Ee(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=se;exports.BaseService=q;exports.CONTEXT_HOST=J;exports.Context=ye;exports.ContextMode=j;exports.DATA_TYPES=oe;exports.JSCodeToString=Ie;exports.LIFE_CYCLES_LIST=be;exports.LocalService=yt;exports.MemoryService=$e;exports.Provider=je;exports.StorageService=vt;exports.VTJ_RENDERER_VERSION=R;exports.adoptedStyleSheets=Y;exports.createAssetScripts=Re;exports.createAssetsCss=Fe;exports.createDataSources=_e;exports.createLoader=A;exports.createMemoryService=gt;exports.createMetaApi=me;exports.createProvider=pt;exports.createRenderer=k;exports.createSchemaApi=pe;exports.createSchemaApis=he;exports.defaultLoader=Se;exports.fillBasePath=M;exports.getModifiers=G;exports.getPlugin=z;exports.getRawComponent=ce;exports.isCSSUrl=N;exports.isJSCode=fe;exports.isJSExpression=S;exports.isJSFunction=x;exports.isJSON=ie;exports.isJSUrl=U;exports.isVuePlugin=de;exports.loadCss=le;exports.loadCssUrl=K;exports.loadScriptUrl=ue;exports.mockApi=ge;exports.mockApis=ve;exports.mockCleanup=X;exports.nodeRender=O;exports.parseDeps=ae;exports.parseExpression=F;exports.parseFunction=V;exports.providerKey=Z;exports.toString=W;exports.useMask=_t;exports.useProvider=ee;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Base as _e, BUILT_IN_COMPONENTS as we, ProjectModel as M, HistoryModel as re } from "@vtj/core";
2
2
  import { isUrl as Se, url as C, dedupArray as $e, isString as E, isFunction as Y, logger as O, createRequest as je, merge as Ee, pathToRegexp as be, pathToRegexpMatch as Pe, formDataToJson as Ce, camelCase as b, upperFirst as Re, pick as Fe, jsonp as Ie, loadScript as z, Request as xe, Storage as He, mapToObject as J } from "@vtj/utils";
3
3
  import * as T from "vue";
4
- import { toRef as Me, readonly as Oe, customRef as De, ref as L, onBeforeUnmount as ke, getCurrentScope as Te, onScopeDispose as Be, unref as Ae, getCurrentInstance as se, watch as oe, computed as ie, onMounted as Ne, defineComponent as ae, h as N, inject as Ue, defineAsyncComponent as Z, watchEffect as qe } from "vue";
4
+ import { toRef as Me, readonly as Oe, customRef as De, ref as L, onBeforeUnmount as ke, getCurrentScope as Te, onScopeDispose as Be, unref as Ae, getCurrentInstance as se, watch as oe, computed as ie, onMounted as Ue, defineComponent as ae, h as U, inject as Ne, defineAsyncComponent as Z, watchEffect as qe } from "vue";
5
5
  import { useRoute as ce } from "vue-router";
6
6
  import { ElNotification as V, ElLoading as Je } from "element-plus";
7
7
  import D from "mockjs";
@@ -10,10 +10,10 @@ import { XStartup as Le } 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.43
13
+ * @version 0.8.45
14
14
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
15
15
  */
16
- const F = "0.8.43";
16
+ const F = "0.8.45";
17
17
  var S = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(S || {});
18
18
  const ee = [
19
19
  "$el",
@@ -363,7 +363,7 @@ class it {
363
363
  return r.context.__proto__ = this.context, r.__proto__ = this, r;
364
364
  }
365
365
  }
366
- function U(n) {
366
+ function N(n) {
367
367
  const {
368
368
  Vue: e = T,
369
369
  mode: t = S.Runtime,
@@ -510,7 +510,7 @@ async function de(n, e = window) {
510
510
  if (s.length === 0 || !r)
511
511
  return null;
512
512
  const o = t.filter((i) => W(i)), a = await Ye(s, r, e).catch(
513
- () => null
513
+ (i) => (console.warn("loadScriptUrl error", s, r, i), null)
514
514
  );
515
515
  return a ? {
516
516
  component: a,
@@ -523,7 +523,7 @@ function q(n) {
523
523
  delete r.window[s];
524
524
  }), A = []), (s, o, a = T) => !o || typeof o == "string" ? s : o.type === "Schema" && o.id ? a.defineAsyncComponent(async () => {
525
525
  const i = await e(o.id);
526
- return i && (i.name = s), i ? U({
526
+ return i && (i.name = s), i ? N({
527
527
  ...r,
528
528
  Vue: a,
529
529
  dsl: i,
@@ -532,7 +532,7 @@ function q(n) {
532
532
  }).renderer : null;
533
533
  }) : o.type === "UrlSchema" && o.url ? a.defineAsyncComponent(async () => {
534
534
  const i = await t(o.url);
535
- return i && (i.name = s), i ? U({
535
+ return i && (i.name = s), i ? N({
536
536
  ...r,
537
537
  Vue: a,
538
538
  dsl: i,
@@ -541,7 +541,7 @@ function q(n) {
541
541
  }).renderer : null;
542
542
  }) : o.type === "Plugin" ? (o.library && A.push(o.library), a.defineAsyncComponent(async () => {
543
543
  const i = await de(o, r.window);
544
- return i ? (fe(i.css, r.window), i.component) : null;
544
+ return i ? (fe(i.css, r.window), i.component) : (console.warn("getPlugin result is null", o), null);
545
545
  })) : s;
546
546
  }
547
547
  function k(n, e, t = T, r = vt) {
@@ -733,18 +733,18 @@ function kt(n) {
733
733
  const Tt = he ? window : void 0, Bt = he ? window.document : void 0;
734
734
  function At() {
735
735
  const n = L(!1), e = se();
736
- return e && Ne(() => {
736
+ return e && Ue(() => {
737
737
  n.value = !0;
738
738
  }, e), n;
739
739
  }
740
- function Nt(n) {
740
+ function Ut(n) {
741
741
  const e = At();
742
742
  return ie(() => (e.value, !!n()));
743
743
  }
744
- function Ut(n, e, t = {}) {
744
+ function Nt(n, e, t = {}) {
745
745
  const { window: r = Tt, ...s } = t;
746
746
  let o;
747
- const a = Nt(() => r && "MutationObserver" in r), i = () => {
747
+ const a = Ut(() => r && "MutationObserver" in r), i = () => {
748
748
  o && (o.disconnect(), o = void 0);
749
749
  }, l = ie(() => {
750
750
  const f = K(n), m = (Array.isArray(f) ? f : [f]).map(kt).filter(xt);
@@ -782,7 +782,7 @@ function qt(n = null, e = {}) {
782
782
  u !== f && o && (o.title = p(typeof u == "string" ? u : ""));
783
783
  },
784
784
  { immediate: !0 }
785
- ), e.observe && !e.titleTemplate && o && !c && Ut(
785
+ ), e.observe && !e.titleTemplate && o && !c && Nt(
786
786
  (s = o.head) == null ? void 0 : s.querySelector("title"),
787
787
  () => {
788
788
  o && o.title !== l.value && (l.value = p(o.title));
@@ -807,12 +807,12 @@ const ne = ae({
807
807
  };
808
808
  },
809
809
  render() {
810
- return this.component ? N(this.component, this.query) : N("div", "页面不存在");
810
+ return this.component ? U(this.component, this.query) : U("div", "页面不存在");
811
811
  }
812
812
  }), Jt = ae({
813
813
  name: "VtjStartupContainer",
814
814
  render() {
815
- return N(Le);
815
+ return U(Le);
816
816
  }
817
817
  }), ve = Symbol("Provider");
818
818
  class Lt extends _e {
@@ -964,7 +964,7 @@ class Lt extends _e {
964
964
  getDslByUrl: async (c) => await this.getDslByUrl(c) || null,
965
965
  options: i
966
966
  });
967
- return U({
967
+ return N({
968
968
  ...i,
969
969
  dsl: e,
970
970
  loader: l
@@ -1001,7 +1001,7 @@ function on(n) {
1001
1001
  };
1002
1002
  }
1003
1003
  function ye(n = {}) {
1004
- const e = Ue(ve);
1004
+ const e = Ne(ve);
1005
1005
  if (!e)
1006
1006
  throw new Error("Can not find provider");
1007
1007
  if (e.nodeEnv === "development") {
@@ -1368,7 +1368,7 @@ export {
1368
1368
  cn as createMemoryService,
1369
1369
  nt as createMetaApi,
1370
1370
  on as createProvider,
1371
- U as createRenderer,
1371
+ N as createRenderer,
1372
1372
  tt as createSchemaApi,
1373
1373
  rt as createSchemaApis,
1374
1374
  vt as defaultLoader,
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@vtj/renderer",
3
3
  "private": false,
4
- "version": "0.8.43",
4
+ "version": "0.8.45",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "mockjs": "~1.1.0",
8
- "@vtj/icons": "~0.8.43",
9
- "@vtj/ui": "~0.8.43",
10
- "@vtj/core": "~0.8.43",
11
- "@vtj/utils": "~0.8.43"
8
+ "@vtj/core": "~0.8.45",
9
+ "@vtj/icons": "~0.8.45",
10
+ "@vtj/ui": "~0.8.45",
11
+ "@vtj/utils": "~0.8.45"
12
12
  },
13
13
  "devDependencies": {
14
14
  "vue": "~3.4.15",
@@ -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.42
5
+ * @version 0.8.44
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.8.42";
8
+ export declare const version = "0.8.44";