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