@vtj/renderer 0.8.116 → 0.8.118
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 +5 -5
- package/dist/index.mjs +76 -82
- package/package.json +5 -5
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@vtj/core"),u=require("@vtj/utils"),m=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@vtj/core"),u=require("@vtj/utils"),m=require("vue"),Z=require("vue-router"),F=require("element-plus"),T=require("mockjs"),je=require("@vtj/ui");function $e(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const D=$e(m);/**!
|
|
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.
|
|
5
|
+
* @version 0.8.118
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const b="0.8.
|
|
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"}),
|
|
7
|
+
*/const b="0.8.118";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"],ee=["vIf","vShow","vModel","vFor","vBind"],te={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 ne(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 re(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 se(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 oe(r,e){const t=await window.fetch(e).then(n=>n.text()).catch(()=>"");t&&L(window,r,t)}function ie(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"}),V(),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 V(){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=>te[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 W(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));return o.length&&ie(o),await ae(s,n,e).catch(i=>(console.warn("loadScriptUrl error",s,n,i),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 W(o,n.window);return i||(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=>!ee.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=Y(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 Y(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):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;
|
|
10
|
+
}`:"(v) => {}"},s=t.__parseFunction(n),o=Y(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 K(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=K(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=K(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):K(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 Q=m.defineComponent({name:"VtjPageContainer",async setup(){const r=z(),e=Z.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)}}),X=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),V(),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}=re(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 oe(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]=se(j,g)})}}}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:Q}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?Q: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(X,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()=>await W(e,window))}}function ut(r){const e=new _e(r);return{provider:e,onReady:n=>e.ready(n)}}function z(r={}){const e=m.inject(X);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 G=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)=>G.send({url:r,method:"post",query:{type:e},data:{type:e,data:t}}),ft=(r="/vtj/local/repository/uploader.json")=>async(e,t)=>await G.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=>ne(o))[0];if(!n)return null;const s=this.pluginCaches[n];return s||(this.pluginCaches[n]=G.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=z(),e=Z.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=ee;exports.BaseService=B;exports.CONTEXT_HOST=U;exports.Context=he;exports.ContextMode=w;exports.DATA_TYPES=te;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=Y;exports.getPlugin=W;exports.getRawComponent=se;exports.isCSSUrl=A;exports.isJSCode=le;exports.isJSExpression=S;exports.isJSFunction=M;exports.isJSON=ne;exports.isJSUrl=k;exports.isVuePlugin=ce;exports.loadCss=oe;exports.loadCssUrl=ie;exports.loadScriptUrl=ae;exports.mockApi=me;exports.mockApis=pe;exports.mockCleanup=V;exports.nodeRender=I;exports.parseDeps=re;exports.parseExpression=P;exports.parseFunction=q;exports.providerKey=X;exports.toString=J;exports.useMask=vt;exports.useProvider=z;
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Base as
|
|
2
|
-
import { isUrl as
|
|
1
|
+
import { Base as he, BUILT_IN_COMPONENTS as ve, ProjectModel as I, HistoryModel as ee } from "@vtj/core";
|
|
2
|
+
import { isUrl as ye, url as b, dedupArray as ge, isString as S, isFunction as K, logger as H, createRequest as _e, merge as we, pathToRegexp as Se, pathToRegexpMatch as $e, formDataToJson as je, delay as Ee, camelCase as j, upperFirst as be, pick as Pe, jsonp as Ce, loadScript as Q, Request as Re, Storage as Fe, mapToObject as N } from "@vtj/utils";
|
|
3
3
|
import * as M from "vue";
|
|
4
|
-
import { toRef as
|
|
4
|
+
import { toRef as Ie, readonly as He, customRef as xe, ref as q, onBeforeUnmount as Oe, getCurrentScope as Me, onScopeDispose as De, unref as ke, getCurrentInstance as te, watch as ne, computed as re, onMounted as Te, defineComponent as se, h as A, inject as Ae, defineAsyncComponent as X, watchEffect as Be } from "vue";
|
|
5
5
|
import { useRoute as oe } from "vue-router";
|
|
6
|
-
import { ElNotification as D, ElLoading as
|
|
6
|
+
import { ElNotification as D, ElLoading as Ue } from "element-plus";
|
|
7
7
|
import x from "mockjs";
|
|
8
|
-
import { XStartup as
|
|
8
|
+
import { XStartup as Ne } from "@vtj/ui";
|
|
9
9
|
/**!
|
|
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.
|
|
13
|
+
* @version 0.8.118
|
|
14
14
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
15
15
|
*/
|
|
16
|
-
const P = "0.8.
|
|
16
|
+
const P = "0.8.118";
|
|
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",
|
|
@@ -41,7 +41,7 @@ const Y = [
|
|
|
41
41
|
"renderTriggered",
|
|
42
42
|
"activated",
|
|
43
43
|
"deactivated"
|
|
44
|
-
],
|
|
44
|
+
], qe = ["vIf", "vShow", "vModel", "vFor", "vBind"], Je = {
|
|
45
45
|
String,
|
|
46
46
|
Number,
|
|
47
47
|
Boolean,
|
|
@@ -51,7 +51,7 @@ const Y = [
|
|
|
51
51
|
Date
|
|
52
52
|
};
|
|
53
53
|
function R(r, e) {
|
|
54
|
-
return r.map((t) =>
|
|
54
|
+
return r.map((t) => ye(t) ? t : `${e}${t}`);
|
|
55
55
|
}
|
|
56
56
|
function J(r) {
|
|
57
57
|
return /\.css$/.test(r);
|
|
@@ -59,7 +59,7 @@ function J(r) {
|
|
|
59
59
|
function L(r) {
|
|
60
60
|
return /\.js$/.test(r);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function Le(r) {
|
|
63
63
|
return /\.json$/.test(r);
|
|
64
64
|
}
|
|
65
65
|
function en(r) {
|
|
@@ -72,7 +72,7 @@ function tn(r = []) {
|
|
|
72
72
|
(e) => `<link rel="stylesheet" href="${b.append(e, { v: P })}" />`
|
|
73
73
|
).join("");
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function Ve(r, e) {
|
|
76
76
|
const t = r.filter((u) => !!u.enabled), n = [], s = [], o = [], a = [], i = {}, l = {}, c = [], d = {};
|
|
77
77
|
return t.forEach(
|
|
78
78
|
({ urls: u, assetsUrl: f, library: p, assetsLibrary: h, localeLibrary: m }) => {
|
|
@@ -85,13 +85,13 @@ function We(r, e) {
|
|
|
85
85
|
css: R(s, e),
|
|
86
86
|
materials: R(o, e),
|
|
87
87
|
libraryExports: a,
|
|
88
|
-
materialExports:
|
|
88
|
+
materialExports: ge(c),
|
|
89
89
|
materialMapLibrary: d,
|
|
90
90
|
libraryMap: i,
|
|
91
91
|
libraryLocaleMap: l
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function We(r, e) {
|
|
95
95
|
const { name: t, parent: n, alias: s } = r;
|
|
96
96
|
return n ? e[n]?.[s || t] : e[s || t];
|
|
97
97
|
}
|
|
@@ -113,11 +113,11 @@ function ae(r, e, t) {
|
|
|
113
113
|
o ? o.innerHTML = t : (o = s.createElement("style"), o.id = e, o.innerHTML = t, s.head.appendChild(o));
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
async function
|
|
116
|
+
async function Ge(r, e) {
|
|
117
117
|
const t = await window.fetch(e).then((n) => n.text()).catch(() => "");
|
|
118
118
|
t && ae(window, r, t);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Ke(r, e = window) {
|
|
121
121
|
const t = e.document, n = e.document.head;
|
|
122
122
|
for (const s of r)
|
|
123
123
|
if (!t.getElementById(s)) {
|
|
@@ -180,7 +180,7 @@ function nn(r) {
|
|
|
180
180
|
return Ye(r) ? r.value : JSON.stringify(r);
|
|
181
181
|
}
|
|
182
182
|
let E = null;
|
|
183
|
-
const ze =
|
|
183
|
+
const ze = _e({
|
|
184
184
|
settings: {
|
|
185
185
|
type: "form",
|
|
186
186
|
validSuccess: !0,
|
|
@@ -194,7 +194,7 @@ const ze = we({
|
|
|
194
194
|
});
|
|
195
195
|
},
|
|
196
196
|
showLoading: () => {
|
|
197
|
-
E && E.close(), E =
|
|
197
|
+
E && E.close(), E = Ue.service({
|
|
198
198
|
lock: !0,
|
|
199
199
|
text: "Loading",
|
|
200
200
|
background: "rgba(0, 0, 0, 0.05)"
|
|
@@ -221,7 +221,7 @@ function Ze(r, e) {
|
|
|
221
221
|
headers: s
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
return (a, i) => n.send(
|
|
224
|
+
return (a, i) => n.send(we(o, i || {}, { data: a }));
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
function et(r, e) {
|
|
@@ -247,20 +247,20 @@ function tt(r = [], e = [], t) {
|
|
|
247
247
|
function nt(r = []) {
|
|
248
248
|
x.setup({
|
|
249
249
|
timeout: "50-500"
|
|
250
|
-
}),
|
|
250
|
+
}), ce(), r.forEach((e) => rt(e));
|
|
251
251
|
}
|
|
252
252
|
function rt(r) {
|
|
253
253
|
if (!r.mock) return;
|
|
254
254
|
const { url: e, mockTemplate: t } = r;
|
|
255
255
|
if (e && t) {
|
|
256
|
-
const n =
|
|
256
|
+
const n = Se(`${e}(.*)`), s = $e(e, { decode: decodeURIComponent }), o = C(t, {}, !0);
|
|
257
257
|
x.mock(n, (a) => {
|
|
258
|
-
const i = b.parse(a.url) || {}, l = a.body instanceof FormData ?
|
|
258
|
+
const i = b.parse(a.url) || {}, l = a.body instanceof FormData ? je(a.body) : a.body, c = s(a.url)?.params;
|
|
259
259
|
return Object.assign(a, { data: l, params: i, query: c }), x.mock(o(a));
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function ce() {
|
|
264
264
|
x._mocked = {};
|
|
265
265
|
}
|
|
266
266
|
class st {
|
|
@@ -334,7 +334,7 @@ class st {
|
|
|
334
334
|
__ref(e = null, t) {
|
|
335
335
|
if (this.__mode !== _.VNode)
|
|
336
336
|
return e && e !== this.__id && (this.__contextRefs[e] = this), async (n) => {
|
|
337
|
-
await
|
|
337
|
+
await Ee(0);
|
|
338
338
|
let s = n?.$vtjEl || n?.$el || n?._?.vnode?.el || n;
|
|
339
339
|
if (!s) {
|
|
340
340
|
typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]);
|
|
@@ -419,7 +419,7 @@ function ot(r = []) {
|
|
|
419
419
|
return r.map((e) => S(e) ? e : e.name);
|
|
420
420
|
}
|
|
421
421
|
function it(r = [], e) {
|
|
422
|
-
const t = (n) => n ? (Array.isArray(n) ? n : [n]).map((o) =>
|
|
422
|
+
const t = (n) => n ? (Array.isArray(n) ? n : [n]).map((o) => Je[o]) : void 0;
|
|
423
423
|
return r.map((n) => S(n) ? {
|
|
424
424
|
name: n
|
|
425
425
|
} : {
|
|
@@ -502,16 +502,13 @@ function dt(r, e) {
|
|
|
502
502
|
}
|
|
503
503
|
let T = [];
|
|
504
504
|
const mt = (r) => r;
|
|
505
|
-
async function
|
|
505
|
+
async function le(r, e = window) {
|
|
506
506
|
const { urls: t = [], library: n } = r, s = t.filter((i) => L(i));
|
|
507
507
|
if (s.length === 0 || !n) return null;
|
|
508
|
-
const o = t.filter((i) => J(i))
|
|
508
|
+
const o = t.filter((i) => J(i));
|
|
509
|
+
return o.length && Ke(o), await Qe(s, n, e).catch(
|
|
509
510
|
(i) => (console.warn("loadScriptUrl error", s, n, i), null)
|
|
510
511
|
);
|
|
511
|
-
return a ? {
|
|
512
|
-
component: a,
|
|
513
|
-
css: o
|
|
514
|
-
} : null;
|
|
515
512
|
}
|
|
516
513
|
function U(r) {
|
|
517
514
|
const { getDsl: e, getDslByUrl: t, options: n } = r;
|
|
@@ -536,8 +533,8 @@ function U(r) {
|
|
|
536
533
|
loader: U(r)
|
|
537
534
|
}).renderer : null;
|
|
538
535
|
}) : o.type === "Plugin" ? (o.library && T.push(o.library), a.defineAsyncComponent(async () => {
|
|
539
|
-
const i = await
|
|
540
|
-
return i
|
|
536
|
+
const i = await le(o, n.window);
|
|
537
|
+
return i || (console.warn("getPlugin result is null", o), null);
|
|
541
538
|
})) : s;
|
|
542
539
|
}
|
|
543
540
|
function O(r, e, t = M, n = mt) {
|
|
@@ -574,7 +571,7 @@ function O(r, e, t = M, n = mt) {
|
|
|
574
571
|
}
|
|
575
572
|
function ht(r = []) {
|
|
576
573
|
const e = r.find((i) => j(i.name) === "vIf"), t = r.find((i) => j(i.name) === "vFor"), n = r.find((i) => j(i.name) === "vShow"), s = r.find((i) => j(i.name) === "vBind"), o = r.filter((i) => j(i.name) === "vModel"), a = r.filter(
|
|
577
|
-
(i) => !
|
|
574
|
+
(i) => !qe.includes(j(i.name))
|
|
578
575
|
);
|
|
579
576
|
return {
|
|
580
577
|
vIf: e,
|
|
@@ -609,13 +606,13 @@ function _t(r, e, t) {
|
|
|
609
606
|
};
|
|
610
607
|
return Object.keys(e || {}).reduce(
|
|
611
608
|
(o, a) => {
|
|
612
|
-
const i = e[a], l =
|
|
609
|
+
const i = e[a], l = ue(i.modifiers), c = l.find((f) => n.includes(f)), d = "on" + be(a) + (c && s[c] || ""), u = t.__parseFunction(i.handler);
|
|
613
610
|
return u && (o[d] = r.withModifiers(u, l)), o;
|
|
614
611
|
},
|
|
615
612
|
{}
|
|
616
613
|
);
|
|
617
614
|
}
|
|
618
|
-
function
|
|
615
|
+
function ue(r = {}, e = !1) {
|
|
619
616
|
const t = Object.keys(r);
|
|
620
617
|
return e ? t.map((n) => "." + n) : t;
|
|
621
618
|
}
|
|
@@ -645,7 +642,7 @@ function jt(r, e, t) {
|
|
|
645
642
|
value: e.value?.value ? `(v) => {
|
|
646
643
|
${e.value.value} = v;
|
|
647
644
|
}` : "(v) => {}"
|
|
648
|
-
}, s = t.__parseFunction(n), o =
|
|
645
|
+
}, s = t.__parseFunction(n), o = ue(e.modifiers), a = g(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue";
|
|
649
646
|
return {
|
|
650
647
|
[a]: t.__parseExpression(e.value),
|
|
651
648
|
[`onUpdate:${a}`]: o.length && s ? r.withModifiers(s, o) : s
|
|
@@ -664,7 +661,7 @@ function Et(r, e, t, n, s) {
|
|
|
664
661
|
[`scope_${s.id}`]: i
|
|
665
662
|
} : {};
|
|
666
663
|
return Object.entries(o).reduce((i, [l, { nodes: c, params: d }]) => (i[l] = (u) => {
|
|
667
|
-
const f = d.length ?
|
|
664
|
+
const f = d.length ? Pe(u ?? {}, d) : a(u);
|
|
668
665
|
return c.map(
|
|
669
666
|
(p) => O(p, t.__clone(f), r, n)
|
|
670
667
|
);
|
|
@@ -697,12 +694,12 @@ function Ct(r, e, t) {
|
|
|
697
694
|
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`), []);
|
|
698
695
|
}
|
|
699
696
|
function Rt(r) {
|
|
700
|
-
return
|
|
697
|
+
return Me() ? (De(r), !0) : !1;
|
|
701
698
|
}
|
|
702
699
|
function V(r) {
|
|
703
|
-
return typeof r == "function" ? r() :
|
|
700
|
+
return typeof r == "function" ? r() : ke(r);
|
|
704
701
|
}
|
|
705
|
-
const
|
|
702
|
+
const fe = typeof window < "u" && typeof document < "u";
|
|
706
703
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
707
704
|
const Ft = (r) => r != null, It = () => {
|
|
708
705
|
};
|
|
@@ -711,22 +708,22 @@ function Ht(r) {
|
|
|
711
708
|
}
|
|
712
709
|
function xt(...r) {
|
|
713
710
|
if (r.length !== 1)
|
|
714
|
-
return
|
|
711
|
+
return Ie(...r);
|
|
715
712
|
const e = r[0];
|
|
716
|
-
return typeof e == "function" ? xe(
|
|
713
|
+
return typeof e == "function" ? He(xe(() => ({ get: e, set: It }))) : q(e);
|
|
717
714
|
}
|
|
718
715
|
function Ot(r, e) {
|
|
719
|
-
Ht() &&
|
|
716
|
+
Ht() && Oe(r, e);
|
|
720
717
|
}
|
|
721
718
|
function Mt(r) {
|
|
722
719
|
var e;
|
|
723
720
|
const t = V(r);
|
|
724
721
|
return (e = t?.$el) != null ? e : t;
|
|
725
722
|
}
|
|
726
|
-
const Dt =
|
|
723
|
+
const Dt = fe ? window : void 0, kt = fe ? window.document : void 0;
|
|
727
724
|
function Tt() {
|
|
728
725
|
const r = q(!1), e = te();
|
|
729
|
-
return e &&
|
|
726
|
+
return e && Te(() => {
|
|
730
727
|
r.value = !0;
|
|
731
728
|
}, e), r;
|
|
732
729
|
}
|
|
@@ -791,7 +788,7 @@ function Ut(r = null, e = {}) {
|
|
|
791
788
|
const Z = se({
|
|
792
789
|
name: "VtjPageContainer",
|
|
793
790
|
async setup() {
|
|
794
|
-
const r =
|
|
791
|
+
const r = de(), e = oe(), t = e.params.id, n = t ? r.getPage(t) : r.getHomepage(), s = n ? await r.getRenderComponent(n.id) : null;
|
|
795
792
|
return n && Ut(n.title || "VTJ"), {
|
|
796
793
|
provider: r,
|
|
797
794
|
component: s,
|
|
@@ -805,10 +802,10 @@ const Z = se({
|
|
|
805
802
|
}), Nt = se({
|
|
806
803
|
name: "VtjStartupContainer",
|
|
807
804
|
render() {
|
|
808
|
-
return A(
|
|
805
|
+
return A(Ne);
|
|
809
806
|
}
|
|
810
|
-
}),
|
|
811
|
-
class qt extends
|
|
807
|
+
}), pe = Symbol("Provider");
|
|
808
|
+
class qt extends he {
|
|
812
809
|
constructor(e) {
|
|
813
810
|
super(), this.options = e;
|
|
814
811
|
const {
|
|
@@ -829,7 +826,7 @@ class qt extends ve {
|
|
|
829
826
|
mode;
|
|
830
827
|
globals = {};
|
|
831
828
|
modules = {};
|
|
832
|
-
adapter = { request: ze, jsonp:
|
|
829
|
+
adapter = { request: ze, jsonp: Ce };
|
|
833
830
|
apis = {};
|
|
834
831
|
dependencies = {};
|
|
835
832
|
materials = {};
|
|
@@ -846,7 +843,7 @@ class qt extends ve {
|
|
|
846
843
|
if (this.project = t ? await t() : await this.service.init(e), !this.project)
|
|
847
844
|
throw new Error("project is null");
|
|
848
845
|
const { apis: n = [], meta: s = [] } = this.project, o = window;
|
|
849
|
-
o.CKEDITOR_VERSION = void 0, this.nodeEnv !== "production" ? await this.loadAssets(o) : await this.loadDependencies(o), this.apis = tt(n, s, this.adapter),
|
|
846
|
+
o.CKEDITOR_VERSION = void 0, this.nodeEnv !== "production" ? await this.loadAssets(o) : await this.loadDependencies(o), this.apis = tt(n, s, this.adapter), ce(), this.project.config?.mock && nt(n), this.initRouter(), this.triggerReady();
|
|
850
847
|
}
|
|
851
848
|
async loadDependencies(e) {
|
|
852
849
|
const t = Object.entries(this.dependencies);
|
|
@@ -860,7 +857,7 @@ class qt extends ve {
|
|
|
860
857
|
materials: c,
|
|
861
858
|
materialExports: d,
|
|
862
859
|
materialMapLibrary: u
|
|
863
|
-
} =
|
|
860
|
+
} = Ve(t, a);
|
|
864
861
|
for (const p of i) {
|
|
865
862
|
const h = n[p], m = e[p];
|
|
866
863
|
if (m)
|
|
@@ -870,7 +867,7 @@ class qt extends ve {
|
|
|
870
867
|
else {
|
|
871
868
|
const v = l[p] || [];
|
|
872
869
|
for (const w of v)
|
|
873
|
-
J(w) && await
|
|
870
|
+
J(w) && await Ge(p, b.append(w, { v: P })), L(w) && await Q(b.append(w, { v: P }));
|
|
874
871
|
s[p] = e[p];
|
|
875
872
|
}
|
|
876
873
|
}
|
|
@@ -878,7 +875,7 @@ class qt extends ve {
|
|
|
878
875
|
await Q(b.append(p, { v: P }));
|
|
879
876
|
const f = this.materials || {};
|
|
880
877
|
for (const p of d) {
|
|
881
|
-
const h = e[u[p]], m =
|
|
878
|
+
const h = e[u[p]], m = ve[p];
|
|
882
879
|
if (m)
|
|
883
880
|
h && m.forEach((v) => {
|
|
884
881
|
o[v] = h[v];
|
|
@@ -886,7 +883,7 @@ class qt extends ve {
|
|
|
886
883
|
else {
|
|
887
884
|
const v = f[p] ? (await f[p]()).default : e[p];
|
|
888
885
|
v && h && (v.components || []).forEach((w) => {
|
|
889
|
-
o[w.name] =
|
|
886
|
+
o[w.name] = We(w, h);
|
|
890
887
|
});
|
|
891
888
|
}
|
|
892
889
|
}
|
|
@@ -907,7 +904,7 @@ class qt extends ve {
|
|
|
907
904
|
const t = e.config.globalProperties.installed || {};
|
|
908
905
|
for (const [n, s] of Object.entries(this.library))
|
|
909
906
|
!t[n] && Xe(s) && (e.use(s), t[n] = !0);
|
|
910
|
-
this.options.install && e.use(this.options.install), e.provide(
|
|
907
|
+
this.options.install && e.use(this.options.install), e.provide(pe, this), e.config.globalProperties.installed = t, this.nodeEnv === "development" && (e.config.errorHandler = (n, s, o) => {
|
|
911
908
|
const a = s?.$options.name, i = n?.message || n?.msg || "未知错误", l = `[ ${a} ] ${i}`;
|
|
912
909
|
console.error(
|
|
913
910
|
"[VTJ Error]:",
|
|
@@ -997,10 +994,7 @@ class qt extends ve {
|
|
|
997
994
|
});
|
|
998
995
|
}
|
|
999
996
|
definePluginComponent(e) {
|
|
1000
|
-
return X(async () =>
|
|
1001
|
-
const t = await ue(e, window);
|
|
1002
|
-
return t ? (ce(t.css), t.component) : null;
|
|
1003
|
-
});
|
|
997
|
+
return X(async () => await le(e, window));
|
|
1004
998
|
}
|
|
1005
999
|
}
|
|
1006
1000
|
function rn(r) {
|
|
@@ -1010,8 +1004,8 @@ function rn(r) {
|
|
|
1010
1004
|
onReady: (n) => e.ready(n)
|
|
1011
1005
|
};
|
|
1012
1006
|
}
|
|
1013
|
-
function
|
|
1014
|
-
const e =
|
|
1007
|
+
function de(r = {}) {
|
|
1008
|
+
const e = Ae(pe);
|
|
1015
1009
|
if (!e)
|
|
1016
1010
|
throw new Error("Can not find provider");
|
|
1017
1011
|
if (e.nodeEnv === "development") {
|
|
@@ -1026,7 +1020,7 @@ function me(r = {}) {
|
|
|
1026
1020
|
}
|
|
1027
1021
|
return e;
|
|
1028
1022
|
}
|
|
1029
|
-
const W = new
|
|
1023
|
+
const W = new Re({
|
|
1030
1024
|
settings: {
|
|
1031
1025
|
type: "json",
|
|
1032
1026
|
validSuccess: !0,
|
|
@@ -1136,7 +1130,7 @@ class G {
|
|
|
1136
1130
|
return await this.api("clearStaticFiles", e).catch(() => "");
|
|
1137
1131
|
}
|
|
1138
1132
|
async getPluginMaterial(e) {
|
|
1139
|
-
const { urls: t = [] } = e, n = t.filter((o) =>
|
|
1133
|
+
const { urls: t = [] } = e, n = t.filter((o) => Le(o))[0];
|
|
1140
1134
|
if (!n) return null;
|
|
1141
1135
|
const s = this.pluginCaches[n];
|
|
1142
1136
|
return s || (this.pluginCaches[n] = W.send({
|
|
@@ -1149,7 +1143,7 @@ class G {
|
|
|
1149
1143
|
}).then((o) => o.data).catch(() => null));
|
|
1150
1144
|
}
|
|
1151
1145
|
}
|
|
1152
|
-
const y = new
|
|
1146
|
+
const y = new Fe({
|
|
1153
1147
|
type: "local",
|
|
1154
1148
|
expired: 0,
|
|
1155
1149
|
prefix: "__VTJ_"
|
|
@@ -1320,7 +1314,7 @@ class an extends G {
|
|
|
1320
1314
|
);
|
|
1321
1315
|
}
|
|
1322
1316
|
}
|
|
1323
|
-
function
|
|
1317
|
+
function me(r = []) {
|
|
1324
1318
|
return r.map((e) => {
|
|
1325
1319
|
const { id: t, title: n, icon: s, children: o, hidden: a } = e;
|
|
1326
1320
|
return {
|
|
@@ -1329,13 +1323,13 @@ function he(r = []) {
|
|
|
1329
1323
|
icon: s,
|
|
1330
1324
|
hidden: a,
|
|
1331
1325
|
url: `/page/${t}`,
|
|
1332
|
-
children: o && o.length ?
|
|
1326
|
+
children: o && o.length ? me(o) : void 0
|
|
1333
1327
|
};
|
|
1334
1328
|
});
|
|
1335
1329
|
}
|
|
1336
1330
|
function cn() {
|
|
1337
|
-
const r =
|
|
1338
|
-
|
|
1331
|
+
const r = de(), e = oe(), t = q(!1), n = r.project;
|
|
1332
|
+
Be(() => {
|
|
1339
1333
|
const { name: a, params: i, meta: l } = e;
|
|
1340
1334
|
if (a === "VtjPage") {
|
|
1341
1335
|
const c = r.getPage(i.id);
|
|
@@ -1346,7 +1340,7 @@ function cn() {
|
|
|
1346
1340
|
} else
|
|
1347
1341
|
t.value = !l.mask;
|
|
1348
1342
|
});
|
|
1349
|
-
const s =
|
|
1343
|
+
const s = me(n?.pages), o = n?.config;
|
|
1350
1344
|
return {
|
|
1351
1345
|
disabled: t,
|
|
1352
1346
|
logo: o?.logo,
|
|
@@ -1356,12 +1350,12 @@ function cn() {
|
|
|
1356
1350
|
};
|
|
1357
1351
|
}
|
|
1358
1352
|
export {
|
|
1359
|
-
|
|
1353
|
+
qe as BUILT_IN_DIRECTIVES,
|
|
1360
1354
|
G as BaseService,
|
|
1361
1355
|
Y as CONTEXT_HOST,
|
|
1362
1356
|
st as Context,
|
|
1363
1357
|
_ as ContextMode,
|
|
1364
|
-
|
|
1358
|
+
Je as DATA_TYPES,
|
|
1365
1359
|
nn as JSCodeToString,
|
|
1366
1360
|
Zt as LIFE_CYCLES_LIST,
|
|
1367
1361
|
an as LocalService,
|
|
@@ -1382,28 +1376,28 @@ export {
|
|
|
1382
1376
|
tt as createSchemaApis,
|
|
1383
1377
|
mt as defaultLoader,
|
|
1384
1378
|
R as fillBasePath,
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1379
|
+
ue as getModifiers,
|
|
1380
|
+
le as getPlugin,
|
|
1381
|
+
We as getRawComponent,
|
|
1388
1382
|
J as isCSSUrl,
|
|
1389
1383
|
Ye as isJSCode,
|
|
1390
1384
|
g as isJSExpression,
|
|
1391
1385
|
k as isJSFunction,
|
|
1392
|
-
|
|
1386
|
+
Le as isJSON,
|
|
1393
1387
|
L as isJSUrl,
|
|
1394
1388
|
Xe as isVuePlugin,
|
|
1395
|
-
|
|
1396
|
-
|
|
1389
|
+
Ge as loadCss,
|
|
1390
|
+
Ke as loadCssUrl,
|
|
1397
1391
|
Qe as loadScriptUrl,
|
|
1398
1392
|
rt as mockApi,
|
|
1399
1393
|
nt as mockApis,
|
|
1400
|
-
|
|
1394
|
+
ce as mockCleanup,
|
|
1401
1395
|
O as nodeRender,
|
|
1402
|
-
|
|
1396
|
+
Ve as parseDeps,
|
|
1403
1397
|
C as parseExpression,
|
|
1404
1398
|
z as parseFunction,
|
|
1405
|
-
|
|
1399
|
+
pe as providerKey,
|
|
1406
1400
|
ie as toString,
|
|
1407
1401
|
cn as useMask,
|
|
1408
|
-
|
|
1402
|
+
de as useProvider
|
|
1409
1403
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/renderer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.118",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"mockjs": "~1.1.0",
|
|
8
|
-
"@vtj/core": "~0.8.
|
|
9
|
-
"@vtj/
|
|
10
|
-
"@vtj/icons": "~0.8.
|
|
11
|
-
"@vtj/
|
|
8
|
+
"@vtj/core": "~0.8.118",
|
|
9
|
+
"@vtj/utils": "~0.8.118",
|
|
10
|
+
"@vtj/icons": "~0.8.118",
|
|
11
|
+
"@vtj/ui": "~0.8.118"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"vue": "~3.4.15",
|
package/types/version.d.ts
CHANGED
|
@@ -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.
|
|
5
|
+
* @version 0.8.117
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.8.
|
|
8
|
+
export declare const version = "0.8.117";
|