@vtj/renderer 0.12.25 → 0.12.26
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 +181 -172
- package/package.json +6 -6
- package/types/utils/util.d.ts +2 -1
- 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
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("@vtj/core"),l=require("@vtj/utils"),S=require("vue"),ce=require("vue-router");function Ke(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const q=Ke(S);/**!
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
3
3
|
* @name @vtj/renderer
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
5
|
-
* @version 0.12.
|
5
|
+
* @version 0.12.26
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
|
-
*/const M="0.12.
|
8
|
-
`)+i;const a=`with(${t?"{}":"$scope || {}"}) { ${i} }`;return new Function("$scope",a)(e)}catch(n){if(c.logger.error("parseExpression.error",n,r,e?.__self??e),s)throw n}}function U(r,e,t=!1,s=!1){const n=I(r,e,t,s);if(typeof n!="function"&&(c.logger.error("parseFunction.error","not a function",r,e?.__self??e),s))throw new Error(`"${r.value}" not a function`);return n}function w(r){return r&&r.type==="JSExpression"}function F(r){return typeof r=="object"&&r&&r.type==="JSFunction"}function Ee(r){return w(r)||F(r)}function We(r){return Ee(r)?r.value:JSON.stringify(r)}const Ye={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},Z=Symbol("access");class ee{options;data=null;mode=y.Raw;interceptResponse=!0;constructor(e){this.options=Object.assign({},Ye,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:n}=e;this.mode=t,s&&this.mode===y.Raw&&this.setGuard(s),n&&this.setRequest(n)}login(e){const{storageKey:t,storagePrefix:s,session:n,authKey:i}=this.options;this.setData(e),this.data&&(c.storage.save(t,e,{type:"local",prefix:s}),n&&c.cookie.set(i,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:n}=this.options;this.data=null,c.storage.remove(e,{type:"local",prefix:t}),s&&c.cookie.remove(n)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):c.toArray(e).every(i=>s[i]||s[t+"."+i])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return c.toArray(e).some(i=>s[i]||s[t+"."+i])}install(e){e.config.globalProperties.$access=this,e.provide(Z,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const n=t.split("#")[1]||t;return e.path===n}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(n=>c.unRSA(n,t));try{this.data=JSON.parse(s.join(""))}catch(n){console.warn(n)}return}if(typeof e=="string")try{const s=t?c.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=c.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!c.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===k){const t=e.params.id;return t&&this.can(t)}return!0}setGuard(e){e.beforeEach((t,s,n)=>this.guard(t,n))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:n=!1}=this.options;return await this.showTip(s),c.isFunction(n)?(n(),t(!1)):c.isString(n)?t(n):t(!1)}}t(!1),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&(await this.showTip(t),this.toLogin())}async showTip(e){const{alert:t}=this.options;return t?(await c.delay(150),await t(e,{title:"提示",type:"warning"}).catch(()=>!1)):!1}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function je(){return S.inject(Z,null)}function Qe(r={}){const{notify:e,loading:t,settings:s={},Startup:n,access:i,useTitle:a,alert:o}=r;let l=null;return{request:c.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:p=>p.data?.code===0||!!p.data?.success,failMessage:!0,showError:p=>{e&&e(p||"未知错误")},showLoading:()=>{l&&l.close(),t&&(l=t())},hideLoading:()=>{l&&(l.close(),l=null)},...s}}),jsonp:c.jsonp,notify:e,loading:t,useTitle:a,startupComponent:n,access:i?new ee({alert:o,...i}):void 0}}function Xe(r={}){return new ee(r)}function Pe(r,e){const{jsonp:t,request:s}=e;if(r.method==="jsonp")return(n={})=>t(r.url,{...r.jsonpOptions,query:n});{const n=r.headers?I(r.headers,{},!0):void 0,i={url:r.url,method:r.method,settings:{...r.settings,headers:n}};return(a,o)=>(delete i.data,s.send(c.merge(i,o||{},{data:a})))}}function $e(r,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:n}=r;return(i,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,n,i,a)}}function Re(r=[],e=[],t){const s={};for(const n of r)s[n.id]=Pe(n,t);for(const n of e)s[n.id]=$e(n,t);return s}async function be(r=[],e=window){const t=T(e);t&&(te(e),r.forEach(s=>Ae(t,s)))}function Ce(r,e=window){const t=F(r.mockTemplate)&&r.mockTemplate.value?U(r.mockTemplate,{},!0):void 0,s=T(e);return async(...n)=>{let i={};if(t)try{i=await t.apply(t,n)}catch(a){c.logger.warn("模拟数据模版异常",a)}return s?.mock(i)}}function Ae(r,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s){const n=c.pathToRegexp(`${t}(.*)`),i=c.pathToRegexpMatch(t,{decode:decodeURIComponent}),a=I(s,{},!0);r.mock(n,o=>{const l=c.url.parse(o.url)||{},u=o.body instanceof FormData?c.formDataToJson(o.body):o.body,p=i(o.url)?.params;return Object.assign(o,{data:u,params:l,query:p}),r.mock(a(o))})}}function te(r=window){const e=T(r);e&&(e._mocked={})}class Me{__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:s,attrs:n}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),n&&Object.assign(this,n)}setup(e,t=q){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const n=s.appContext.config.globalProperties;Object.assign(this,n),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&z.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){z.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:s}=e,n=t?this.__transform[t]??e.value:e.value;return U({type:s,value:n},this)}else return U(e,this)}__parseExpression(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:s}=e,n=t?this.__transform[t]??e.value:e.value;return I({type:s,value:n},this)}else return I(e,this)}__ref(e=null,t){if(this.__mode!==y.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await c.delay(0);let n=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!n){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return n.nodeType===3&&n.nextSibling&&(n=n.nextSibling),n.__vtj__=e,y.Design===this.__mode&&(n.__context__=this,n.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,s)),typeof t=="function"?t(s):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,s)),s}}__getRefEl(e,t,s){const n=e[t];if(n&&s!==n){const i=new Set([].concat(n,s));return Array.from(i)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function B(r){const{Vue:e=q,mode:t=y.Runtime,components:s={},libs:n={},apis:i={},loader:a}=r,o=e.computed(()=>r.dsl),l={$components:s,$libs:n,$apis:i},u=new Me({mode:t,dsl:o.value,attrs:l}),p=e.defineComponent({name:o.value.name,props:{...et(o.value.props??[],u)},setup(d){u.$props=d,u.props=d,o.value.id&&Y(r.window||window,o.value.id,o.value.css||""),u.state=tt(e,o.value.state??{},u);const g=st(e,o.value.computed??{},u),h=rt(o.value.methods??{},u),f=nt(e,o.value.inject,u);for(const[v,R]of Object.entries(f||{}))f[v]=e.inject(v,R);const m=ke(o.value.dataSources||{},u),E={...f,...g,...h,...m};return u.setup(E,e),it(e,o.value.watch??[],u),{vtj:u}},emits:Ze(o.value.emits),expose:["vtj"],render(){if(!o.value.nodes)return null;const d=o.value.nodes||[];return d.length===1?A(d[0],u,e,a,d):d.map(g=>A(g,u,e,a,d))},...ot(o.value.lifeCycles??{},u)});return{renderer:e.markRaw(p),context:u}}function Ze(r=[]){return r.map(e=>c.isString(e)?e:e.name)}function et(r=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(i=>ue[i]):void 0;return r.map(s=>c.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:w(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,n)=>(s[n.name]={type:t(n.type),required:n.required,default:n.default},s),{})}function tt(r,e,t){return r.reactive(Object.keys(e||{}).reduce((s,n)=>{let i=e[n];return w(i)?i=t.__parseExpression(i):F(i)&&(i=t.__parseFunction(i)),s[n]=i,s},{}))}function st(r,e,t){return Object.entries(e??{}).reduce((s,[n,i])=>(s[n]=r.computed(t.__parseFunction(i)),s),{})}function rt(r,e){return Object.entries(r??{}).reduce((t,[s,n])=>(t[s]=e.__parseFunction(n),t),{})}function nt(r,e=[],t){return e.reduce((s,n)=>{const{name:i,from:a}=n||{};n.default;const o=w(a)?t.__parseExpression(a)||i:a??i,l=w(n.default)?t.__parseExpression(n.default):n.default??null;return s[i]=r.inject(o,l),s},{})}function ke(r,e){return Object.keys(r).reduce((t,s)=>{const n=r[s];if(n.type==="mock")t[s]=Ce(n);else if(n.ref){const i=e.$apis[n.ref],a=F(n.transform)?n.transform.value?e.__parseFunction(n.transform):void 0:n.transform;t[s]=async(...o)=>{const l=await i.apply(e,o);return a?a(l):l}}return t},{})}function it(r,e=[],t){e.forEach(s=>{r.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function ot(r,e){return Object.entries(r??{}).reduce((t,[s,n])=>(t[s]=e.__parseFunction(n),t),{})}let V=[],C={};const Te=r=>r;async function se(r,e=window){const{urls:t=[],library:s}=r,n=t.filter(o=>x(o));if(n.length===0||!s)return null;const i=t.filter(o=>H(o));return i.length&&Q(i,e),await X(n,s,e).catch(o=>(console.warn("loadScriptUrl error",n,s,o),null))}function L(r){const{getDsl:e,getDslByUrl:t,options:s}=r;return s.window&&(V.forEach(n=>{delete s.window[n]}),V=[]),(n,i,a=q)=>{if(!i||typeof i=="string")return n;if(i.type==="Schema"&&i.id)return a.defineAsyncComponent(async()=>{const o=C[i.id]||await e(i.id);return o&&(o.name=n,C[i.id]=o),o?B({...s,Vue:a,dsl:c.cloneDeep(o),mode:y.Runtime,loader:L(r)}).renderer:null});if(i.type==="UrlSchema"&&i.url)return a.defineAsyncComponent(async()=>{const o=C[i.url]||await t(i.url);return o&&(o.name=n,C[i.url]=o),o?B({...s,Vue:a,dsl:c.cloneDeep(o),mode:y.Runtime,loader:L(r)}).renderer:null});if(i.type==="Plugin"){let o=i.library?C[i.library]:null;return o||(i.library&&V.push(i.library),o=C[i.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await se(i,s.window);return l||(console.warn("getPlugin result is null",i),null)}),o)}return n}}function at(){C={}}function A(r,e,t=q,s=Te,n=[],i=!1){if(!r||!r.name||r.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:o=null,directives:l=[]}=r,{vIf:u,vElseIf:p,vElse:d,vFor:g,vShow:h,vModels:f,vBind:m,vHtml:E,others:v}=Ie(l);if(!i&&(p||d))return null;if(u&&!lt(u,e))return ft(r,e,t,s,n);const R=j=>{const Ue=j.$components,Be=(()=>{if(r.name==="component")return ut(j,r.props?.is);if(r.name==="slot")return r.name;const P=s(r.name,r.from,t);return c.isString(P)?Se(P)||we(P)?P:Ue[P]??a?.app?.component(P)??P:P})(),b=pt(o,r.props??{},j),Le=dt(t,r.events??{},j);if(r.name==="slot")return ht(t,r,b,j,s);m&&Object.assign(b,j.__parseExpression(m.value)),h&&(b.style=Object.assign(b.style??{},gt(h,j))),E&&Object.assign(b,vt(E,j)),f.forEach(P=>{Object.assign(b,yt(t,P,j))});const qe=_t(t,r.children??[],j,s,r);let K=t.createVNode(Be,{...b,...Le},qe);const oe=a?ct(a,v,j):[];return oe.length&&(K=t.withDirectives(K,oe)),K};return g?Et(g,R,e):R(e)}function ct(r,e,t){const s=r.app;return e.map(n=>{const i=typeof n.name=="string"?s.directive(n.name):t.__parseExpression(n.name);if(!i)return null;const a=[i];return n.value&&a.push(t.__parseExpression(n.value)),n.arg&&a.push(n.arg),n.modifiers&&a.push(n.modifiers),a}).filter(n=>!!n)}function Ie(r=[]){const e=r.find(p=>c.camelCase(p.name)==="vIf"),t=r.find(p=>c.camelCase(p.name)==="vElseIf"),s=r.find(p=>c.camelCase(p.name)==="vElse"),n=r.find(p=>c.camelCase(p.name)==="vFor"),i=r.find(p=>c.camelCase(p.name)==="vShow"),a=r.find(p=>c.camelCase(p.name)==="vBind"),o=r.find(p=>c.camelCase(p.name)==="vHtml"),l=r.filter(p=>c.camelCase(p.name)==="vModel"),u=r.filter(p=>!le.includes(c.camelCase(p.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:n,vShow:i,vModels:l,vBind:a,others:u,vHtml:o}}function lt(r,e){return!!e.__parseExpression(r.value)}function ut(r,e){return e?w(e)?r.__parseExpression(e):e:"div"}function pt(r,e,t){const s=G(e,t);return s.ref=t.__ref(r,s.ref),s}function G(r,e){return w(r)?e.__parseExpression(r):F(r)?e.__parseFunction(r):Array.isArray(r)?r.map(t=>G(t,e)):typeof r=="object"?Object.keys(r||{}).reduce((t,s)=>{let n=r[s];return t[s]=G(n,e),t},{}):r}function dt(r,e,t){const s=["passive","capture","once"],n={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((i,a)=>{const o=e[a],l=re(o.modifiers),u=l.find(g=>s.includes(g)),p="on"+c.upperFirst(a)+(u&&n[u]||""),d=t.__parseFunction(o.handler);return d&&(i[p]=r.withModifiers(d,l)),i},{})}function ft(r,e,t,s,n=[]){let i=n.findIndex(a=>a.id===r.id);for(let a=++i;a<n.length;a++){const{directives:o=[]}=n[a],{vElseIf:l,vElse:u}=Ie(o);if(l){if(e.__parseExpression(l.value))return A(n[a],e,t,s,n,!0);continue}if(u)return A(n[a],e,t,s,n,!0)}return null}function re(r={},e=!1){const t=Object.keys(r);return e?t.map(s=>"."+s):t}function ht(r,e,t,s,n){const{children:i}=e,a=mt(e,s),o=s.$slots?.[a.name];return o?o(t):i?c.isString(i)?r.createTextVNode(i):w(i)?r.createTextVNode(W(s.__parseExpression(i))):Array.isArray(i)?i.map(l=>A(l,s,r,n,i)):null:null}function mt(r,e){const{props:t}=r,s=t?.name||"default";return{name:w(s)?e.__parseExpression(s):s,params:[]}}function gt(r,e){return e.__parseExpression(r.value)?{}:{display:"none"}}function vt(r,e){return{innerHTML:e.__parseExpression(r.value)||""}}function yt(r,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
|
7
|
+
*/const M="0.12.26";var y=(r=>(r.Runtime="Runtime",r.Design="Design",r.Raw="Raw",r.VNode="VNode",r))(y||{});const z=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],Ve=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],le=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],ue={String,Number,Boolean,Array,Object,Function,Date},k="VtjPage",D="VtjHomepage",pe="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot".split(","),de="component,slot".split(",");function O(r,e){return r.map(t=>l.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function H(r){return/\.css$/.test(r)}function x(r){return/\.js$/.test(r)}function fe(r){return/\.json$/.test(r)}function ze(r){return r.map(e=>`<script src="${l.url.append(e,{v:M})}"><\/script>`).join("")}function Ge(r=[]){return r.map(e=>`<link rel="stylesheet" href="${l.url.append(e,{v:M})}" />`).join("")}function he(r,e=!1){return e&&r.endsWith(".prod.js")?r.replace(".prod.js",".js"):r}function me(r,e,t=!1){const s=r.filter(g=>!!g.enabled),n=[],i=[],a=[],o=[],c={},u={},p=[],d={};return s.forEach(({urls:g,assetsUrl:h,library:f,assetsLibrary:m,localeLibrary:E})=>{g?.forEach(v=>{x(v)&&n.push(he(v,t)),H(v)&&i.push(v)}),f&&(o.push(f),c[f]=O(g||[],e),E&&(u[f]=E)),h&&a.push(h),m&&p.push(m),f&&m&&(d[m]=f)}),{scripts:O(n,e),css:O(i,e),materials:O(a,e),libraryExports:o,materialExports:l.dedupArray(p),materialMapLibrary:d,libraryMap:c,libraryLocaleMap:u}}function ge(r,e){const{name:t,parent:s,alias:n}=r;return s?e[s]?.[n||t]:e[n||t]}function ve(r=[]){const e=r.filter(s=>H(s)),t=r.filter(s=>x(s));return{css:e,js:t}}function W(r){return l.isString(r)?r:JSON.stringify(r)}function ye(r,e){return r.replace(/::v-deep\(/g,":deep(").replace(/(\s*)>>>(\s*)/g,"$1:deep($2)").replace(/([\w-.:\s[\]>+~]+?):deep\(([^)]+)\)/g,(s,n,i)=>`${n.replace(/(\s*)$/,`[${e}]$1`)} ${i}`).replace(/([^{}]+)(?=\s*{)/g,s=>s.split(",").map(n=>n.includes(`[${e}]`)?n.trim():n.trim().replace(/(.*?)([^\s>+~]+)$/,`$1$2[${e}]`)).join(", "))}function Y(r,e,t,s=!1){const n=r.CSSStyleSheet,i=s?`data-v-${e}`:e,a=s?ye(t,i):t;if(n.prototype.replaceSync){const o=new n;o.id=e,o.replaceSync(a);const c=r.document,u=c.adoptedStyleSheets,p=Array.from(u).filter(d=>d.id!==e);c.adoptedStyleSheets=[...p,o]}else{const o=r.document;let c=o.getElementById(e);c?c.innerHTML=a:(c=o.createElement("style"),c.id=e,c.innerHTML=a,o.head.appendChild(c))}}async function _e(r,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&Y(window,r,t)}function Q(r,e=window){const t=e.document,s=e.document.head;for(const n of r)if(!t.getElementById(n)){const a=t.createElement("link");a.rel="stylesheet",a.id=n,a.href=n,s.appendChild(a)}}async function X(r,e,t=window){const s=t.document,n=t.document.head;let i=t[e];return i?i.default||i:new Promise((a,o)=>{for(const c of r){const u=s.createElement("script");u.src=c,u.onload=()=>{i=t[e],i?a(i.default||i):o(null)},u.onerror=p=>{o(p)},n.appendChild(u)}})}function Se(r){return l.isFunction(r)||l.isFunction(r?.install)}function we(r){return de.includes(r)}function Ee(r){return pe.includes(r)}function T(r=window){const e=window?.Mock;if(e)return e;const t=r?.Mock;if(t&&window)return window.Mock=t,t}function We(r,e,t){Object.assign(e.meta,t.meta);const s=r?._container;t?.type==="page"&&s.classList.add("is-page"),t?.pure&&s.classList.add("is-pure")}function I(r,e,t=!1,s=!1){try{const n=['"use strict";',"var __self = arguments[0];"];n.push("return ");let i=(r.value||"").trim();i=i.replace(/this(\W|$)/g,(o,c)=>`__self${c}`),i=n.join(`
|
8
|
+
`)+i;const a=`with(${t?"{}":"$scope || {}"}) { ${i} }`;return new Function("$scope",a)(e)}catch(n){if(l.logger.error("parseExpression.error",n,r,e?.__self??e),s)throw n}}function U(r,e,t=!1,s=!1){const n=I(r,e,t,s);if(typeof n!="function"&&(l.logger.error("parseFunction.error","not a function",r,e?.__self??e),s))throw new Error(`"${r.value}" not a function`);return n}function w(r){return r&&r.type==="JSExpression"}function F(r){return typeof r=="object"&&r&&r.type==="JSFunction"}function je(r){return w(r)||F(r)}function Ye(r){return je(r)?r.value:JSON.stringify(r)}const Qe={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},Z=Symbol("access");class ee{options;data=null;mode=y.Raw;interceptResponse=!0;constructor(e){this.options=Object.assign({},Qe,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:n}=e;this.mode=t,s&&this.mode===y.Raw&&this.setGuard(s),n&&this.setRequest(n)}login(e){const{storageKey:t,storagePrefix:s,session:n,authKey:i}=this.options;this.setData(e),this.data&&(l.storage.save(t,e,{type:"local",prefix:s}),n&&l.cookie.set(i,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:n}=this.options;this.data=null,l.storage.remove(e,{type:"local",prefix:t}),s&&l.cookie.remove(n)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):l.toArray(e).every(i=>s[i]||s[t+"."+i])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return l.toArray(e).some(i=>s[i]||s[t+"."+i])}install(e){e.config.globalProperties.$access=this,e.provide(Z,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const n=t.split("#")[1]||t;return e.path===n}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(n=>l.unRSA(n,t));try{this.data=JSON.parse(s.join(""))}catch(n){console.warn(n)}return}if(typeof e=="string")try{const s=t?l.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=l.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!l.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===k){const t=e.params.id;return t&&this.can(t)}return!0}setGuard(e){e.beforeEach((t,s,n)=>this.guard(t,n))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:n=!1}=this.options;return await this.showTip(s),l.isFunction(n)?(n(),t(!1)):l.isString(n)?t(n):t(!1)}}t(!1),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&(await this.showTip(t),this.toLogin())}async showTip(e){const{alert:t}=this.options;return t?(await l.delay(150),await t(e,{title:"提示",type:"warning"}).catch(()=>!1)):!1}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function $e(){return S.inject(Z,null)}function Xe(r={}){const{notify:e,loading:t,settings:s={},Startup:n,access:i,useTitle:a,alert:o}=r;let c=null;return{request:l.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:p=>p.data?.code===0||!!p.data?.success,failMessage:!0,showError:p=>{e&&e(p||"未知错误")},showLoading:()=>{c&&c.close(),t&&(c=t())},hideLoading:()=>{c&&(c.close(),c=null)},...s}}),jsonp:l.jsonp,notify:e,loading:t,useTitle:a,startupComponent:n,access:i?new ee({alert:o,...i}):void 0}}function Ze(r={}){return new ee(r)}function Pe(r,e){const{jsonp:t,request:s}=e;if(r.method==="jsonp")return(n={})=>t(r.url,{...r.jsonpOptions,query:n});{const n=r.headers?I(r.headers,{},!0):void 0,i={url:r.url,method:r.method,settings:{...r.settings,headers:n}};return(a,o)=>(delete i.data,s.send(l.merge(i,o||{},{data:a})))}}function Ce(r,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:n}=r;return(i,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,n,i,a)}}function Re(r=[],e=[],t){const s={};for(const n of r)s[n.id]=Pe(n,t);for(const n of e)s[n.id]=Ce(n,t);return s}async function be(r=[],e=window){const t=T(e);t&&(te(e),r.forEach(s=>Me(t,s)))}function Ae(r,e=window){const t=F(r.mockTemplate)&&r.mockTemplate.value?U(r.mockTemplate,{},!0):void 0,s=T(e);return async(...n)=>{let i={};if(t)try{i=await t.apply(t,n)}catch(a){l.logger.warn("模拟数据模版异常",a)}return s?.mock(i)}}function Me(r,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s){const n=l.pathToRegexp(`${t}(.*)`),i=l.pathToRegexpMatch(t,{decode:decodeURIComponent}),a=I(s,{},!0);r.mock(n,o=>{const c=l.url.parse(o.url)||{},u=o.body instanceof FormData?l.formDataToJson(o.body):o.body,p=i(o.url)?.params;return Object.assign(o,{data:u,params:c,query:p}),r.mock(a(o))})}}function te(r=window){const e=T(r);e&&(e._mocked={})}class ke{__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:s,attrs:n}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),n&&Object.assign(this,n)}setup(e,t=q){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const n=s.appContext.config.globalProperties;Object.assign(this,n),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&z.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){z.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:s}=e,n=t?this.__transform[t]??e.value:e.value;return U({type:s,value:n},this)}else return U(e,this)}__parseExpression(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:s}=e,n=t?this.__transform[t]??e.value:e.value;return I({type:s,value:n},this)}else return I(e,this)}__ref(e=null,t){if(this.__mode!==y.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await l.delay(0);let n=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!n){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return n.nodeType===3&&n.nextSibling&&(n=n.nextSibling),n.__vtj__=e,y.Design===this.__mode&&(n.__context__=this,n.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,s)),typeof t=="function"?t(s):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,s)),s}}__getRefEl(e,t,s){const n=e[t];if(n&&s!==n){const i=new Set([].concat(n,s));return Array.from(i)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function B(r){const{Vue:e=q,mode:t=y.Runtime,components:s={},libs:n={},apis:i={},loader:a}=r,o=e.computed(()=>r.dsl),c={$components:s,$libs:n,$apis:i},u=new ke({mode:t,dsl:o.value,attrs:c}),p=e.defineComponent({name:o.value.name,__scopeId:o.value.id?`data-v-${o.value.id}`:void 0,props:{...tt(o.value.props??[],u)},setup(d){u.$props=d,u.props=d,o.value.id&&Y(r.window||window,o.value.id,o.value.css||"",!0),u.state=st(e,o.value.state??{},u);const g=rt(e,o.value.computed??{},u),h=nt(o.value.methods??{},u),f=it(e,o.value.inject,u);for(const[v,C]of Object.entries(f||{}))f[v]=e.inject(v,C);const m=Te(o.value.dataSources||{},u),E={...f,...g,...h,...m};return u.setup(E,e),ot(e,o.value.watch??[],u),{vtj:u}},emits:et(o.value.emits),expose:["vtj"],render(){if(!o.value.nodes)return null;const d=o.value.nodes||[];return d.length===1?A(d[0],u,e,a,d):d.map(g=>A(g,u,e,a,d))},...at(o.value.lifeCycles??{},u)});return{renderer:e.markRaw(p),context:u}}function et(r=[]){return r.map(e=>l.isString(e)?e:e.name)}function tt(r=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(i=>ue[i]):void 0;return r.map(s=>l.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:w(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,n)=>(s[n.name]={type:t(n.type),required:n.required,default:n.default},s),{})}function st(r,e,t){return r.reactive(Object.keys(e||{}).reduce((s,n)=>{let i=e[n];return w(i)?i=t.__parseExpression(i):F(i)&&(i=t.__parseFunction(i)),s[n]=i,s},{}))}function rt(r,e,t){return Object.entries(e??{}).reduce((s,[n,i])=>(s[n]=r.computed(t.__parseFunction(i)),s),{})}function nt(r,e){return Object.entries(r??{}).reduce((t,[s,n])=>(t[s]=e.__parseFunction(n),t),{})}function it(r,e=[],t){return e.reduce((s,n)=>{const{name:i,from:a}=n||{};n.default;const o=w(a)?t.__parseExpression(a)||i:a??i,c=w(n.default)?t.__parseExpression(n.default):n.default??null;return s[i]=r.inject(o,c),s},{})}function Te(r,e){return Object.keys(r).reduce((t,s)=>{const n=r[s];if(n.type==="mock")t[s]=Ae(n);else if(n.ref){const i=e.$apis[n.ref],a=F(n.transform)?n.transform.value?e.__parseFunction(n.transform):void 0:n.transform;t[s]=async(...o)=>{const c=await i.apply(e,o);return a?a(c):c}}return t},{})}function ot(r,e=[],t){e.forEach(s=>{r.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function at(r,e){return Object.entries(r??{}).reduce((t,[s,n])=>(t[s]=e.__parseFunction(n),t),{})}let V=[],b={};const Ie=r=>r;async function se(r,e=window){const{urls:t=[],library:s}=r,n=t.filter(o=>x(o));if(n.length===0||!s)return null;const i=t.filter(o=>H(o));return i.length&&Q(i,e),await X(n,s,e).catch(o=>(console.warn("loadScriptUrl error",n,s,o),null))}function L(r){const{getDsl:e,getDslByUrl:t,options:s}=r;return s.window&&(V.forEach(n=>{delete s.window[n]}),V=[]),(n,i,a=q)=>{if(!i||typeof i=="string")return n;if(i.type==="Schema"&&i.id)return a.defineAsyncComponent(async()=>{const o=b[i.id]||await e(i.id);return o&&(o.name=n,b[i.id]=o),o?B({...s,Vue:a,dsl:l.cloneDeep(o),mode:y.Runtime,loader:L(r)}).renderer:null});if(i.type==="UrlSchema"&&i.url)return a.defineAsyncComponent(async()=>{const o=b[i.url]||await t(i.url);return o&&(o.name=n,b[i.url]=o),o?B({...s,Vue:a,dsl:l.cloneDeep(o),mode:y.Runtime,loader:L(r)}).renderer:null});if(i.type==="Plugin"){let o=i.library?b[i.library]:null;return o||(i.library&&V.push(i.library),o=b[i.library||Symbol()]=a.defineAsyncComponent(async()=>{const c=await se(i,s.window);return c||(console.warn("getPlugin result is null",i),null)}),o)}return n}}function ct(){b={}}function A(r,e,t=q,s=Ie,n=[],i=!1){if(!r||!r.name||r.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:o=null,directives:c=[]}=r,{vIf:u,vElseIf:p,vElse:d,vFor:g,vShow:h,vModels:f,vBind:m,vHtml:E,others:v}=Fe(c);if(!i&&(p||d))return null;if(u&&!ut(u,e))return ht(r,e,t,s,n);const C=j=>{const Be=j.$components,Le=(()=>{if(r.name==="component")return pt(j,r.props?.is);if(r.name==="slot")return r.name;const $=s(r.name,r.from,t);return l.isString($)?we($)||Ee($)?$:Be[$]??a?.app?.component($)??$:$})(),R=dt(o,r.props??{},j),qe=ft(t,r.events??{},j);if(r.name==="slot")return mt(t,r,R,j,s);m&&Object.assign(R,j.__parseExpression(m.value)),h&&(R.style=Object.assign(R.style??{},vt(h,j))),E&&Object.assign(R,yt(E,j)),f.forEach($=>{Object.assign(R,_t(t,$,j))});const Je=St(t,r.children??[],j,s,r);let K=t.createVNode(Le,{...R,...qe},Je);const oe=a?lt(a,v,j):[];return oe.length&&(K=t.withDirectives(K,oe)),K};return g?jt(g,C,e):C(e)}function lt(r,e,t){const s=r.app;return e.map(n=>{const i=typeof n.name=="string"?s.directive(n.name):t.__parseExpression(n.name);if(!i)return null;const a=[i];return n.value&&a.push(t.__parseExpression(n.value)),n.arg&&a.push(n.arg),n.modifiers&&a.push(n.modifiers),a}).filter(n=>!!n)}function Fe(r=[]){const e=r.find(p=>l.camelCase(p.name)==="vIf"),t=r.find(p=>l.camelCase(p.name)==="vElseIf"),s=r.find(p=>l.camelCase(p.name)==="vElse"),n=r.find(p=>l.camelCase(p.name)==="vFor"),i=r.find(p=>l.camelCase(p.name)==="vShow"),a=r.find(p=>l.camelCase(p.name)==="vBind"),o=r.find(p=>l.camelCase(p.name)==="vHtml"),c=r.filter(p=>l.camelCase(p.name)==="vModel"),u=r.filter(p=>!le.includes(l.camelCase(p.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:n,vShow:i,vModels:c,vBind:a,others:u,vHtml:o}}function ut(r,e){return!!e.__parseExpression(r.value)}function pt(r,e){return e?w(e)?r.__parseExpression(e):e:"div"}function dt(r,e,t){const s=G(e,t);return s.ref=t.__ref(r,s.ref),s}function G(r,e){return w(r)?e.__parseExpression(r):F(r)?e.__parseFunction(r):Array.isArray(r)?r.map(t=>G(t,e)):typeof r=="object"?Object.keys(r||{}).reduce((t,s)=>{let n=r[s];return t[s]=G(n,e),t},{}):r}function ft(r,e,t){const s=["passive","capture","once"],n={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((i,a)=>{const o=e[a],c=re(o.modifiers),u=c.find(g=>s.includes(g)),p="on"+l.upperFirst(a)+(u&&n[u]||""),d=t.__parseFunction(o.handler);return d&&(i[p]=r.withModifiers(d,c)),i},{})}function ht(r,e,t,s,n=[]){let i=n.findIndex(a=>a.id===r.id);for(let a=++i;a<n.length;a++){const{directives:o=[]}=n[a],{vElseIf:c,vElse:u}=Fe(o);if(c){if(e.__parseExpression(c.value))return A(n[a],e,t,s,n,!0);continue}if(u)return A(n[a],e,t,s,n,!0)}return null}function re(r={},e=!1){const t=Object.keys(r);return e?t.map(s=>"."+s):t}function mt(r,e,t,s,n){const{children:i}=e,a=gt(e,s),o=s.$slots?.[a.name];return o?o(t):i?l.isString(i)?r.createTextVNode(i):w(i)?r.createTextVNode(W(s.__parseExpression(i))):Array.isArray(i)?i.map(c=>A(c,s,r,n,i)):null:null}function gt(r,e){const{props:t}=r,s=t?.name||"default";return{name:w(s)?e.__parseExpression(s):s,params:[]}}function vt(r,e){return e.__parseExpression(r.value)?{}:{display:"none"}}function yt(r,e){return{innerHTML:e.__parseExpression(r.value)||""}}function _t(r,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
|
9
9
|
${e.value.value} = v;
|
10
|
-
}`:"(v) => {}"},n=t.__parseFunction(s),i=re(w(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),a=w(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:i.length&&n?r.withModifiers(n,i):n}}function _t(r,e,t,s,n){if(!e)return null;if(c.isString(e))return{default:()=>e};if(w(e))return{default:()=>W(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const i=St(e),a=o=>!o||!n?{}:n?.id&&Object.keys(o).length?{[`scope_${n.id}`]:o}:{};return Object.entries(i).reduce((o,[l,{nodes:u,params:p}])=>(o[l]=d=>{const g=p.length?c.pick(d??{},p):a(d);return u.map(h=>A(h,t.__clone(g),r,s,u))},o),{})}return null}function St(r){const e={default:{params:[],nodes:[]}};for(const t of r){const s=wt(t.slot),n=s.name;e[n]?(e[n].nodes.push(t),e[n].params=e[n].params.concat(s.params)):e[n]={nodes:[t],params:s.params}}return e}function wt(r="default"){return c.isString(r)?{name:r,params:[]}:{params:[],...r}}function Et(r,e,t){const{value:s,iterator:n}=r,{item:i="item",index:a="index"}=n||{};let o=t.__parseExpression(s)||[];return Number.isInteger(o)&&(o=new Array(o).fill(!0).map((l,u)=>u+1)),Array.isArray(o)?o.map((l,u)=>e(t.__clone({[i]:l,[a]:u}))):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const ae=S.defineComponent({name:"VtjPageContainer",async setup(){const r=ie(),e=ce.useRoute(),t=e.params.id,s=t?r.getPage(t):r.getHomepage(),n=s?await r.getRenderComponent(s.id):null,i=S.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:a}=r?.adapter;a&&a(s.title||"VTJ")}return{provider:r,component:n,file:s,query:e.query,meta:e.meta,sid:i,route:e}},render(){const{component:r,query:e,sid:t}=this;return r?S.h(r,{...e,key:t}):S.h("div","页面不存在")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),jt=S.defineComponent({name:"VtjStartupContainer",render(){return S.h("div","page not found!")}}),ne=Symbol("Provider");var Fe=(r=>(r.Production="production",r.Development="development",r))(Fe||{});class Oe extends $.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=y.Raw,dependencies:n,materials:i,project:a={},adapter:o={},globals:l={},modules:u={},router:p=null,materialPath:d="./",nodeEnv:g="development"}=e;this.mode=s,this.modules=u,this.service=t,this.router=p,this.materialPath=d,this.nodeEnv=g,n&&(this.dependencies=n),i&&(this.materials=i),Object.assign(this.globals,l),Object.assign(this.adapter,o);const{access:h,request:f}=this.adapter;h&&h.connect({mode:s,router:p,request:f}),a&&s!==y.Design?this.load(a):this.project=a}mode;globals={};modules={};adapter={request:c.request,jsonp:c.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(i){c.logger.warn("模拟数据模版异常",i)}return T()?.mock(s)}}async load(e){const t=this.modules[`.vtj/projects/${e.id}.json`]||this.modules[`/src/.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:s=[],meta:n=[]}=this.project,i=window;i&&(i.CKEDITOR_VERSION=void 0),this.mode===y.Raw?await this.loadDependencies(i):await this.loadAssets(i),this.initMock(i),this.apis=Re(s,n,this.adapter),te(i),be(s,i),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=T(e);t&&t.setup({timeout:"50-500"})}async loadDependencies(e){const t=Object.entries(this.dependencies);for(const[s,n]of t)e[s]||(e[s]=this.library[s]=await n())}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:s,library:n,components:i,materialPath:a,nodeEnv:o}=this,{libraryExports:l,libraryMap:u,materials:p,materialExports:d,materialMapLibrary:g}=me(t,a,o==="development");for(const h of l){const f=s[h],m=e[h];if(m)n[h]=m;else if(f)e[h]=n[h]=await f();else{const E=u[h]||[];for(const v of E)H(v)&&await ye(h,c.url.append(v,{v:M})),x(v)&&await c.loadScript(c.url.append(v,{v:M}));n[h]=e[h]}}if(o==="development"){for(const f of p)await c.loadScript(c.url.append(f,{v:M}));const h=this.materials||{};for(const f of d){const m=e[g[f]],E=$.BUILT_IN_COMPONENTS[f];if(E)m&&E.forEach(v=>{i[v]=m[v]});else{const v=h[f]?(await h[f]()).default:e[f];v&&m&&(v.components||[]).forEach(R=>{i[R.name]=ge(R,m)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:n}=this;if(!e)return;const i=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:a,pageRouteName:o=i,routeMeta:l}=s,u=a?"":"/",p={path:`${u}${o}/:id`,name:k,component:ae},d={path:u,name:D,component:t?.homepage?ae:n.startupComponent||jt,meta:l};e.hasRoute(k)&&e.removeRoute(k),e.hasRoute(D)&&e.removeRoute(D),a?(e.addRoute(a,p),e.addRoute(a,d)):(e.addRoute(p),e.addRoute(d))}install(e){const t=e.config.globalProperties.installed||{};for(const[s,n]of Object.entries(this.library))!t[s]&&_e(n)&&(e.use(n),t[s]=!0);this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),e.provide(ne,this),e.config.globalProperties.$provider=this,e.config.globalProperties.installed=t,this.mode===y.Design&&(e.config.errorHandler=(s,n,i)=>{const a=n?.$options.name,o=typeof s=="string"?s:s?.message||s?.msg||"未知错误",l=`[ ${a} ] ${o} ${i}`;console.error("[VTJ Error]:",{err:s,instance:n,info:i},s?.stack),this.adapter.notify&&this.adapter.notify(l,"组件渲染错误","error")}),this.options.enhance&&e.use(this.options.enhance,this)}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(s=>s.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},s=(n,i=[])=>{for(const a of i){if(a.id===n)return a;if(a.children&&a.children.length){const o=s(n,a.children);if(o)return o}}};return s(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`]||this.modules[`/src/.vtj/files/${e}.json`];return t?await t():this.service.getFile(e,this.project||void 0).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.adapter.request?this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null):null)}createDslRenderer(e,t={}){const{library:s,components:n,mode:i,apis:a}=this,o={mode:i,Vue:s.Vue,components:n,libs:s,apis:a,window,...t},l=L({getDsl:async u=>await this.getDsl(u)||null,getDslByUrl:async u=>await this.getDslByUrl(u)||null,options:o});return B({...o,dsl:e,loader:l})}async getRenderComponent(e,t){const s=this.getFile(e);if(!s)return c.logger.warn(`Can not find file: ${e}`),null;t&&t(s);const n=`.vtj/vue/${e}.vue`,i=this.modules[n]||this.modules[`/src/pages/${e}.vue`];if(i)return(await i())?.default;const a=await this.getDsl(s.id);return a?this.createDslRenderer(a).renderer:(c.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return S.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return S.defineAsyncComponent(async()=>await se(e,window))}}function Pt(r){const e=new Oe(r);return{provider:e,onReady:s=>e.ready(s)}}function ie(r={}){const e=S.inject(ne,null);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=r;t&&s&&(async()=>{const n=await e.getDsl(t);n?.__VERSION__!==s&&e.adapter.notify&&e.adapter.notify(`[ ${n?.name} ] 组件源码版本与运行时版本不一致,请重新发布组件`,"版本不一致","warning")})()}return e}async function $t(r,e=""){const{name:t,urls:s=[]}=r||{},n=s.map(o=>e+o),{css:i,js:a}=ve(n);if(i.length&&Q(i),a.length)return await X(a,t).catch(()=>{})}const De={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:r=>r.data?.code===0},Rt=(r,e="/__vtj__/api/:type.json")=>(t,s,n)=>r.send({url:e,method:"post",params:{type:t},query:n,data:{type:t,data:s},settings:De}),bt=(r,e="/__vtj__/api/uploader.json")=>async(t,s)=>await r.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...De,type:"data"}}).then(n=>n&&n[0]?n[0]:null).catch(()=>null);function Ct(r){return c.createRequest({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:e=>e.data?.code===0,showError:e=>{r&&r(e||"未知错误")}}})}class J{constructor(e=c.request){this.req=e,this.api=Rt(e),this.uploader=bt(e)}api;pluginCaches={};uploader;async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).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 parseVue(e,t){return await this.api("parseVue",{project:e,...t})}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,s=t.filter(i=>fe(i))[0];if(!s)return null;const n=this.pluginCaches[s];return n||(this.pluginCaches[s]=c.request.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(i=>i.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const _=new c.Storage({type:"local",expired:0,prefix:"__VTJ_"});class At extends J{init(e){const t=new $.ProjectModel(e),s=_.get(`project_${t.id}`),n=Object.assign(t.toDsl(),s||{});return _.save(`project_${t.id}`,n),Promise.resolve(n)}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}`,c.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 n=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,n),_.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=_.get(`history_${e}`),s=new $.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=_.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return _.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{_.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class He extends J{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new $.ProjectModel(e),s=this.projects[t.id]||{},n=Object.assign(t.toDsl(),s);return this.projects[n.id]=n,Promise.resolve(n)}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]=c.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 n=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,n),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new $.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,n=this.historyItems[s]||{};return Promise.resolve(n)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const n=`${e}_${s}`;delete this.historyItems[n]}),Promise.resolve(!0)}}let N=null;function Mt(){return N||(N=new He,N)}class kt extends J{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:c.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 xe(r,e,t=[]){return t.map(s=>{const{id:n,title:i,icon:a,children:o,hidden:l}=s;return{id:n,title:i,icon:a,hidden:l,url:`${r}/${e}/${n}`,children:o&&o.length?xe(r,e,o):void 0}})}function Ne(r,e){if(!e)return r;let t=[];for(const s of r)if(s.children&&s.children.length){const n=Ne(s.children,e);n.length&&(s.children=n,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Tt(r){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=r||{},n=ie(),i=ce.useRoute(),a=je(),o=S.ref(!1),l=S.ref(!1),u=n.project;S.watchEffect(()=>{const{name:g,params:h,meta:f}=i;if(g===k){const m=n.getPage(h.id);o.value=!m?.mask,l.value=!!m?.pure}else if(g===D){const m=n.getHomepage();o.value=!m?.mask,l.value=!!m?.pure}else o.value=!f.mask,l.value=!!f.pure});const p=xe(e,t,u?.pages),d=u?.config;return{disabled:o,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||u?.description||u?.name||"VTJ App",menus:s?p:Ne(p,a),pure:l}}exports.ACCESS_KEY=Z;exports.Access=ee;exports.BUILD_IN_TAGS=de;exports.BUILT_IN_DIRECTIVES=le;exports.BaseService=J;exports.CONTEXT_HOST=z;exports.Context=Me;exports.ContextMode=y;exports.DATA_TYPES=ue;exports.HOMEPAGE_ROUTE_NAME=D;exports.HTML_TAGS=pe;exports.JSCodeToString=We;exports.LIFE_CYCLES_LIST=Ke;exports.LocalService=kt;exports.MemoryService=He;exports.NodeEnv=Fe;exports.PAGE_ROUTE_NAME=k;exports.Provider=Oe;exports.StorageService=At;exports.VTJ_RENDERER_VERSION=M;exports.adoptedStyleSheets=Y;exports.clearLoaderCache=at;exports.createAccess=Xe;exports.createAdapter=Qe;exports.createAssetScripts=Ve;exports.createAssetsCss=ze;exports.createDataSources=ke;exports.createLoader=L;exports.createMemoryService=Mt;exports.createMetaApi=$e;exports.createMock=Ce;exports.createProvider=Pt;exports.createRenderer=B;exports.createSchemaApi=Pe;exports.createSchemaApis=Re;exports.createServiceRequest=Ct;exports.defaultLoader=Te;exports.fillBasePath=O;exports.getMock=T;exports.getModifiers=re;exports.getPlugin=se;exports.getRawComponent=ge;exports.isBuiltInTag=Se;exports.isCSSUrl=H;exports.isJSCode=Ee;exports.isJSExpression=w;exports.isJSFunction=F;exports.isJSON=fe;exports.isJSUrl=x;exports.isNativeTag=we;exports.isVuePlugin=_e;exports.loadCss=ye;exports.loadCssUrl=Q;exports.loadEnhance=$t;exports.loadScriptUrl=X;exports.mockApi=Ae;exports.mockApis=be;exports.mockCleanup=te;exports.nodeRender=A;exports.parseDeps=me;exports.parseExpression=I;exports.parseFunction=U;exports.parseUrls=ve;exports.providerKey=ne;exports.removeProdFlag=he;exports.setupPageSetting=Ge;exports.toString=W;exports.useAccess=je;exports.useMask=Tt;exports.useProvider=ie;
|
10
|
+
}`:"(v) => {}"},n=t.__parseFunction(s),i=re(w(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),a=w(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:i.length&&n?r.withModifiers(n,i):n}}function St(r,e,t,s,n){if(!e)return null;if(l.isString(e))return{default:()=>e};if(w(e))return{default:()=>W(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const i=wt(e),a=o=>!o||!n?{}:n?.id&&Object.keys(o).length?{[`scope_${n.id}`]:o}:{};return Object.entries(i).reduce((o,[c,{nodes:u,params:p}])=>(o[c]=d=>{const g=p.length?l.pick(d??{},p):a(d);return u.map(h=>A(h,t.__clone(g),r,s,u))},o),{})}return null}function wt(r){const e={default:{params:[],nodes:[]}};for(const t of r){const s=Et(t.slot),n=s.name;e[n]?(e[n].nodes.push(t),e[n].params=e[n].params.concat(s.params)):e[n]={nodes:[t],params:s.params}}return e}function Et(r="default"){return l.isString(r)?{name:r,params:[]}:{params:[],...r}}function jt(r,e,t){const{value:s,iterator:n}=r,{item:i="item",index:a="index"}=n||{};let o=t.__parseExpression(s)||[];return Number.isInteger(o)&&(o=new Array(o).fill(!0).map((c,u)=>u+1)),Array.isArray(o)?o.map((c,u)=>e(t.__clone({[i]:c,[a]:u}))):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const ae=S.defineComponent({name:"VtjPageContainer",async setup(){const r=ie(),e=ce.useRoute(),t=e.params.id,s=t?r.getPage(t):r.getHomepage(),n=s?await r.getRenderComponent(s.id):null,i=S.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:a}=r?.adapter;a&&a(s.title||"VTJ")}return{provider:r,component:n,file:s,query:e.query,meta:e.meta,sid:i,route:e}},render(){const{component:r,query:e,sid:t}=this;return r?S.h(r,{...e,key:t}):S.h("div","页面不存在")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),$t=S.defineComponent({name:"VtjStartupContainer",render(){return S.h("div","page not found!")}}),ne=Symbol("Provider");var Oe=(r=>(r.Production="production",r.Development="development",r))(Oe||{});class De extends P.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=y.Raw,dependencies:n,materials:i,project:a={},adapter:o={},globals:c={},modules:u={},router:p=null,materialPath:d="./",nodeEnv:g="development"}=e;this.mode=s,this.modules=u,this.service=t,this.router=p,this.materialPath=d,this.nodeEnv=g,n&&(this.dependencies=n),i&&(this.materials=i),Object.assign(this.globals,c),Object.assign(this.adapter,o);const{access:h,request:f}=this.adapter;h&&h.connect({mode:s,router:p,request:f}),a&&s!==y.Design?this.load(a):this.project=a}mode;globals={};modules={};adapter={request:l.request,jsonp:l.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(i){l.logger.warn("模拟数据模版异常",i)}return T()?.mock(s)}}async load(e){const t=this.modules[`.vtj/projects/${e.id}.json`]||this.modules[`/src/.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:s=[],meta:n=[]}=this.project,i=window;i&&(i.CKEDITOR_VERSION=void 0),this.mode===y.Raw?await this.loadDependencies(i):await this.loadAssets(i),this.initMock(i),this.apis=Re(s,n,this.adapter),te(i),be(s,i),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=T(e);t&&t.setup({timeout:"50-500"})}async loadDependencies(e){const t=Object.entries(this.dependencies);for(const[s,n]of t)e[s]||(e[s]=this.library[s]=await n())}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:s,library:n,components:i,materialPath:a,nodeEnv:o}=this,{libraryExports:c,libraryMap:u,materials:p,materialExports:d,materialMapLibrary:g}=me(t,a,o==="development");for(const h of c){const f=s[h],m=e[h];if(m)n[h]=m;else if(f)e[h]=n[h]=await f();else{const E=u[h]||[];for(const v of E)H(v)&&await _e(h,l.url.append(v,{v:M})),x(v)&&await l.loadScript(l.url.append(v,{v:M}));n[h]=e[h]}}if(o==="development"){for(const f of p)await l.loadScript(l.url.append(f,{v:M}));const h=this.materials||{};for(const f of d){const m=e[g[f]],E=P.BUILT_IN_COMPONENTS[f];if(E)m&&E.forEach(v=>{i[v]=m[v]});else{const v=h[f]?(await h[f]()).default:e[f];v&&m&&(v.components||[]).forEach(C=>{i[C.name]=ge(C,m)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:n}=this;if(!e)return;const i=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:a,pageRouteName:o=i,routeMeta:c}=s,u=a?"":"/",p={path:`${u}${o}/:id`,name:k,component:ae},d={path:u,name:D,component:t?.homepage?ae:n.startupComponent||$t,meta:c};e.hasRoute(k)&&e.removeRoute(k),e.hasRoute(D)&&e.removeRoute(D),a?(e.addRoute(a,p),e.addRoute(a,d)):(e.addRoute(p),e.addRoute(d))}install(e){const t=e.config.globalProperties.installed||{};for(const[s,n]of Object.entries(this.library))!t[s]&&Se(n)&&(e.use(n),t[s]=!0);this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),e.provide(ne,this),e.config.globalProperties.$provider=this,e.config.globalProperties.installed=t,this.mode===y.Design&&(e.config.errorHandler=(s,n,i)=>{const a=n?.$options.name,o=typeof s=="string"?s:s?.message||s?.msg||"未知错误",c=`[ ${a} ] ${o} ${i}`;console.error("[VTJ Error]:",{err:s,instance:n,info:i},s?.stack),this.adapter.notify&&this.adapter.notify(c,"组件渲染错误","error")}),this.options.enhance&&e.use(this.options.enhance,this)}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(s=>s.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},s=(n,i=[])=>{for(const a of i){if(a.id===n)return a;if(a.children&&a.children.length){const o=s(n,a.children);if(o)return o}}};return s(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`]||this.modules[`/src/.vtj/files/${e}.json`];return t?await t():this.service.getFile(e,this.project||void 0).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.adapter.request?this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null):null)}createDslRenderer(e,t={}){const{library:s,components:n,mode:i,apis:a}=this,o={mode:i,Vue:s.Vue,components:n,libs:s,apis:a,window,...t},c=L({getDsl:async u=>await this.getDsl(u)||null,getDslByUrl:async u=>await this.getDslByUrl(u)||null,options:o});return B({...o,dsl:e,loader:c})}async getRenderComponent(e,t){const s=this.getFile(e);if(!s)return l.logger.warn(`Can not find file: ${e}`),null;t&&t(s);const n=`.vtj/vue/${e}.vue`,i=this.modules[n]||this.modules[`/src/pages/${e}.vue`];if(i)return(await i())?.default;const a=await this.getDsl(s.id);return a?this.createDslRenderer(a).renderer:(l.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return S.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return S.defineAsyncComponent(async()=>await se(e,window))}}function Pt(r){const e=new De(r);return{provider:e,onReady:s=>e.ready(s)}}function ie(r={}){const e=S.inject(ne,null);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=r;t&&s&&(async()=>{const n=await e.getDsl(t);n?.__VERSION__!==s&&e.adapter.notify&&e.adapter.notify(`[ ${n?.name} ] 组件源码版本与运行时版本不一致,请重新发布组件`,"版本不一致","warning")})()}return e}async function Ct(r,e=""){const{name:t,urls:s=[]}=r||{},n=s.map(o=>e+o),{css:i,js:a}=ve(n);if(i.length&&Q(i),a.length)return await X(a,t).catch(()=>{})}const He={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:r=>r.data?.code===0},Rt=(r,e="/__vtj__/api/:type.json")=>(t,s,n)=>r.send({url:e,method:"post",params:{type:t},query:n,data:{type:t,data:s},settings:He}),bt=(r,e="/__vtj__/api/uploader.json")=>async(t,s)=>await r.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...He,type:"data"}}).then(n=>n&&n[0]?n[0]:null).catch(()=>null);function At(r){return l.createRequest({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:e=>e.data?.code===0,showError:e=>{r&&r(e||"未知错误")}}})}class J{constructor(e=l.request){this.req=e,this.api=Rt(e),this.uploader=bt(e)}api;pluginCaches={};uploader;async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).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 parseVue(e,t){return await this.api("parseVue",{project:e,...t})}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,s=t.filter(i=>fe(i))[0];if(!s)return null;const n=this.pluginCaches[s];return n||(this.pluginCaches[s]=l.request.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(i=>i.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const _=new l.Storage({type:"local",expired:0,prefix:"__VTJ_"});class Mt extends J{init(e){const t=new P.ProjectModel(e),s=_.get(`project_${t.id}`),n=Object.assign(t.toDsl(),s||{});return _.save(`project_${t.id}`,n),Promise.resolve(n)}saveProject(e){const t=new P.ProjectModel(e);return _.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return _.save(`materials_${e.id}`,l.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 n=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,n),_.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=_.get(`history_${e}`),s=new P.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=_.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return _.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{_.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class xe extends J{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new P.ProjectModel(e),s=this.projects[t.id]||{},n=Object.assign(t.toDsl(),s);return this.projects[n.id]=n,Promise.resolve(n)}saveProject(e){const t=new P.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 n=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,n),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new P.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,n=this.historyItems[s]||{};return Promise.resolve(n)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const n=`${e}_${s}`;delete this.historyItems[n]}),Promise.resolve(!0)}}let N=null;function kt(){return N||(N=new xe,N)}class Tt extends J{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).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 Ne(r,e,t=[]){return t.map(s=>{const{id:n,title:i,icon:a,children:o,hidden:c}=s;return{id:n,title:i,icon:a,hidden:c,url:`${r}/${e}/${n}`,children:o&&o.length?Ne(r,e,o):void 0}})}function Ue(r,e){if(!e)return r;let t=[];for(const s of r)if(s.children&&s.children.length){const n=Ue(s.children,e);n.length&&(s.children=n,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function It(r){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=r||{},n=ie(),i=ce.useRoute(),a=$e(),o=S.ref(!1),c=S.ref(!1),u=n.project;S.watchEffect(()=>{const{name:g,params:h,meta:f}=i;if(g===k){const m=n.getPage(h.id);o.value=!m?.mask,c.value=!!m?.pure}else if(g===D){const m=n.getHomepage();o.value=!m?.mask,c.value=!!m?.pure}else o.value=!f.mask,c.value=!!f.pure});const p=Ne(e,t,u?.pages),d=u?.config;return{disabled:o,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||u?.description||u?.name||"VTJ App",menus:s?p:Ue(p,a),pure:c}}exports.ACCESS_KEY=Z;exports.Access=ee;exports.BUILD_IN_TAGS=de;exports.BUILT_IN_DIRECTIVES=le;exports.BaseService=J;exports.CONTEXT_HOST=z;exports.Context=ke;exports.ContextMode=y;exports.DATA_TYPES=ue;exports.HOMEPAGE_ROUTE_NAME=D;exports.HTML_TAGS=pe;exports.JSCodeToString=Ye;exports.LIFE_CYCLES_LIST=Ve;exports.LocalService=Tt;exports.MemoryService=xe;exports.NodeEnv=Oe;exports.PAGE_ROUTE_NAME=k;exports.Provider=De;exports.StorageService=Mt;exports.VTJ_RENDERER_VERSION=M;exports.adoptedStyleSheets=Y;exports.clearLoaderCache=ct;exports.compileScopedCSS=ye;exports.createAccess=Ze;exports.createAdapter=Xe;exports.createAssetScripts=ze;exports.createAssetsCss=Ge;exports.createDataSources=Te;exports.createLoader=L;exports.createMemoryService=kt;exports.createMetaApi=Ce;exports.createMock=Ae;exports.createProvider=Pt;exports.createRenderer=B;exports.createSchemaApi=Pe;exports.createSchemaApis=Re;exports.createServiceRequest=At;exports.defaultLoader=Ie;exports.fillBasePath=O;exports.getMock=T;exports.getModifiers=re;exports.getPlugin=se;exports.getRawComponent=ge;exports.isBuiltInTag=we;exports.isCSSUrl=H;exports.isJSCode=je;exports.isJSExpression=w;exports.isJSFunction=F;exports.isJSON=fe;exports.isJSUrl=x;exports.isNativeTag=Ee;exports.isVuePlugin=Se;exports.loadCss=_e;exports.loadCssUrl=Q;exports.loadEnhance=Ct;exports.loadScriptUrl=X;exports.mockApi=Me;exports.mockApis=be;exports.mockCleanup=te;exports.nodeRender=A;exports.parseDeps=me;exports.parseExpression=I;exports.parseFunction=U;exports.parseUrls=ve;exports.providerKey=ne;exports.removeProdFlag=he;exports.setupPageSetting=We;exports.toString=W;exports.useAccess=$e;exports.useMask=It;exports.useProvider=ie;
|
package/dist/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Base as xe, BUILT_IN_COMPONENTS as Oe, ProjectModel as N, HistoryModel as pe } from "@vtj/core";
|
2
|
-
import { isUrl as Ne, url as C, dedupArray as Be, isString as E, isFunction as V, logger as k, storage as J, cookie as K, toArray as re, unRSA as ie, delay as
|
2
|
+
import { isUrl as Ne, url as C, dedupArray as Be, isString as E, isFunction as V, logger as k, storage as J, cookie as K, toArray as re, unRSA as ie, delay as de, createRequest as fe, jsonp as he, merge as Ue, pathToRegexp as Le, pathToRegexpMatch as qe, formDataToJson as Je, cloneDeep as oe, camelCase as j, upperFirst as Ke, pick as ze, request as W, loadScript as ae, Storage as Ve, mapToObject as te } from "@vtj/utils";
|
3
3
|
import * as B from "vue";
|
4
4
|
import { inject as me, defineComponent as ve, h as G, ref as Y, defineAsyncComponent as ce, watchEffect as We } from "vue";
|
5
5
|
import { useRoute as ge } from "vue-router";
|
@@ -7,10 +7,10 @@ import { useRoute as ge } from "vue-router";
|
|
7
7
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
8
8
|
* @name @vtj/renderer
|
9
9
|
* @author CHC chenhuachun1549@dingtalk.com
|
10
|
-
* @version 0.12.
|
10
|
+
* @version 0.12.26
|
11
11
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
12
12
|
*/
|
13
|
-
const A = "0.12.
|
13
|
+
const A = "0.12.26";
|
14
14
|
var y = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(y || {});
|
15
15
|
const le = [
|
16
16
|
"$el",
|
@@ -24,7 +24,7 @@ const le = [
|
|
24
24
|
"$props",
|
25
25
|
"$options",
|
26
26
|
"$forceUpdate"
|
27
|
-
],
|
27
|
+
], es = [
|
28
28
|
"beforeCreate",
|
29
29
|
"created",
|
30
30
|
"beforeMount",
|
@@ -70,12 +70,12 @@ function L(n) {
|
|
70
70
|
function Ze(n) {
|
71
71
|
return /\.json$/.test(n);
|
72
72
|
}
|
73
|
-
function
|
73
|
+
function ts(n) {
|
74
74
|
return n.map(
|
75
75
|
(e) => `<script src="${C.append(e, { v: A })}"><\/script>`
|
76
76
|
).join("");
|
77
77
|
}
|
78
|
-
function
|
78
|
+
function ss(n = []) {
|
79
79
|
return n.map(
|
80
80
|
(e) => `<link rel="stylesheet" href="${C.append(e, { v: A })}" />`
|
81
81
|
).join("");
|
@@ -86,10 +86,10 @@ function et(n, e = !1) {
|
|
86
86
|
function tt(n, e, t = !1) {
|
87
87
|
const s = n.filter((m) => !!m.enabled), r = [], i = [], a = [], o = [], c = {}, l = {}, u = [], p = {};
|
88
88
|
return s.forEach(
|
89
|
-
({ urls: m, assetsUrl:
|
89
|
+
({ urls: m, assetsUrl: f, library: d, assetsLibrary: h, localeLibrary: _ }) => {
|
90
90
|
m?.forEach((v) => {
|
91
91
|
L(v) && r.push(et(v, t)), U(v) && i.push(v);
|
92
|
-
}),
|
92
|
+
}), d && (o.push(d), c[d] = D(m || [], e), _ && (l[d] = _)), f && a.push(f), h && u.push(h), d && h && (p[h] = d);
|
93
93
|
}
|
94
94
|
), {
|
95
95
|
scripts: D(r, e),
|
@@ -116,22 +116,28 @@ function nt(n = []) {
|
|
116
116
|
function ye(n) {
|
117
117
|
return E(n) ? n : JSON.stringify(n);
|
118
118
|
}
|
119
|
-
function
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
119
|
+
function rt(n, e) {
|
120
|
+
return n.replace(/::v-deep\(/g, ":deep(").replace(/(\s*)>>>(\s*)/g, "$1:deep($2)").replace(
|
121
|
+
/([\w-.:\s[\]>+~]+?):deep\(([^)]+)\)/g,
|
122
|
+
(s, r, i) => `${r.replace(/(\s*)$/, `[${e}]$1`)} ${i}`
|
123
|
+
).replace(/([^{}]+)(?=\s*{)/g, (s) => s.split(",").map((r) => r.includes(`[${e}]`) ? r.trim() : r.trim().replace(/(.*?)([^\s>+~]+)$/, `$1$2[${e}]`)).join(", "));
|
124
|
+
}
|
125
|
+
function _e(n, e, t, s = !1) {
|
126
|
+
const r = n.CSSStyleSheet, i = s ? `data-v-${e}` : e, a = s ? rt(t, i) : t;
|
127
|
+
if (r.prototype.replaceSync) {
|
128
|
+
const o = new r();
|
129
|
+
o.id = e, o.replaceSync(a);
|
130
|
+
const c = n.document, l = c.adoptedStyleSheets, u = Array.from(l).filter(
|
131
|
+
(p) => p.id !== e
|
126
132
|
);
|
127
|
-
|
133
|
+
c.adoptedStyleSheets = [...u, o];
|
128
134
|
} else {
|
129
|
-
const
|
130
|
-
let
|
131
|
-
|
135
|
+
const o = n.document;
|
136
|
+
let c = o.getElementById(e);
|
137
|
+
c ? c.innerHTML = a : (c = o.createElement("style"), c.id = e, c.innerHTML = a, o.head.appendChild(c));
|
132
138
|
}
|
133
139
|
}
|
134
|
-
async function
|
140
|
+
async function it(n, e) {
|
135
141
|
const t = await window.fetch(e).then((s) => s.text()).catch(() => "");
|
136
142
|
t && _e(window, n, t);
|
137
143
|
}
|
@@ -157,13 +163,13 @@ async function Se(n, e, t = window) {
|
|
157
163
|
}
|
158
164
|
});
|
159
165
|
}
|
160
|
-
function
|
166
|
+
function ot(n) {
|
161
167
|
return V(n) || V(n?.install);
|
162
168
|
}
|
163
|
-
function
|
169
|
+
function at(n) {
|
164
170
|
return Xe.includes(n);
|
165
171
|
}
|
166
|
-
function
|
172
|
+
function ct(n) {
|
167
173
|
return Qe.includes(n);
|
168
174
|
}
|
169
175
|
function M(n = window) {
|
@@ -173,7 +179,7 @@ function M(n = window) {
|
|
173
179
|
if (t && window)
|
174
180
|
return window.Mock = t, t;
|
175
181
|
}
|
176
|
-
function
|
182
|
+
function ns(n, e, t) {
|
177
183
|
Object.assign(e.meta, t.meta);
|
178
184
|
const s = n?._container;
|
179
185
|
t?.type === "page" && s.classList.add("is-page"), t?.pure && s.classList.add("is-pure");
|
@@ -209,13 +215,13 @@ function w(n) {
|
|
209
215
|
function T(n) {
|
210
216
|
return typeof n == "object" && n && n.type === "JSFunction";
|
211
217
|
}
|
212
|
-
function
|
218
|
+
function lt(n) {
|
213
219
|
return w(n) || T(n);
|
214
220
|
}
|
215
|
-
function
|
216
|
-
return
|
221
|
+
function rs(n) {
|
222
|
+
return lt(n) ? n.value : JSON.stringify(n);
|
217
223
|
}
|
218
|
-
const
|
224
|
+
const ut = {
|
219
225
|
session: !1,
|
220
226
|
authKey: "Authorization",
|
221
227
|
storageKey: "ACCESS_STORAGE",
|
@@ -235,7 +241,7 @@ class je {
|
|
235
241
|
mode = y.Raw;
|
236
242
|
interceptResponse = !0;
|
237
243
|
constructor(e) {
|
238
|
-
this.options = Object.assign({},
|
244
|
+
this.options = Object.assign({}, ut, e), this.loadData();
|
239
245
|
}
|
240
246
|
enableIntercept() {
|
241
247
|
this.interceptResponse = !0;
|
@@ -366,7 +372,7 @@ class je {
|
|
366
372
|
}
|
367
373
|
async showTip(e) {
|
368
374
|
const { alert: t } = this.options;
|
369
|
-
return t ? (await
|
375
|
+
return t ? (await de(150), await t(e, {
|
370
376
|
title: "提示",
|
371
377
|
type: "warning"
|
372
378
|
}).catch(() => !1)) : !1;
|
@@ -382,10 +388,10 @@ class je {
|
|
382
388
|
);
|
383
389
|
}
|
384
390
|
}
|
385
|
-
function
|
391
|
+
function pt() {
|
386
392
|
return me($e, null);
|
387
393
|
}
|
388
|
-
function
|
394
|
+
function is(n = {}) {
|
389
395
|
const {
|
390
396
|
notify: e,
|
391
397
|
loading: t,
|
@@ -397,7 +403,7 @@ function rs(n = {}) {
|
|
397
403
|
} = n;
|
398
404
|
let c = null;
|
399
405
|
return {
|
400
|
-
request:
|
406
|
+
request: fe({
|
401
407
|
settings: {
|
402
408
|
type: "form",
|
403
409
|
validSuccess: !0,
|
@@ -425,10 +431,10 @@ function rs(n = {}) {
|
|
425
431
|
access: i ? new je({ alert: o, ...i }) : void 0
|
426
432
|
};
|
427
433
|
}
|
428
|
-
function
|
434
|
+
function os(n = {}) {
|
429
435
|
return new je(n);
|
430
436
|
}
|
431
|
-
function
|
437
|
+
function dt(n, e) {
|
432
438
|
const { jsonp: t, request: s } = e;
|
433
439
|
if (n.method === "jsonp")
|
434
440
|
return (r = {}) => t(n.url, {
|
@@ -459,19 +465,19 @@ function ft(n, e) {
|
|
459
465
|
return t(s, r, i, a);
|
460
466
|
};
|
461
467
|
}
|
462
|
-
function
|
468
|
+
function ht(n = [], e = [], t) {
|
463
469
|
const s = {};
|
464
470
|
for (const r of n)
|
465
|
-
s[r.id] =
|
471
|
+
s[r.id] = dt(r, t);
|
466
472
|
for (const r of e)
|
467
473
|
s[r.id] = ft(r, t);
|
468
474
|
return s;
|
469
475
|
}
|
470
|
-
async function
|
476
|
+
async function mt(n = [], e = window) {
|
471
477
|
const t = M(e);
|
472
|
-
t && (Ee(e), n.forEach((s) =>
|
478
|
+
t && (Ee(e), n.forEach((s) => gt(t, s)));
|
473
479
|
}
|
474
|
-
function
|
480
|
+
function vt(n, e = window) {
|
475
481
|
const t = T(n.mockTemplate) && n.mockTemplate.value ? Q(n.mockTemplate, {}, !0) : void 0, s = M(e);
|
476
482
|
return async (...r) => {
|
477
483
|
let i = {};
|
@@ -484,7 +490,7 @@ function mt(n, e = window) {
|
|
484
490
|
return s?.mock(i);
|
485
491
|
};
|
486
492
|
}
|
487
|
-
function
|
493
|
+
function gt(n, e) {
|
488
494
|
if (!e.mock) return;
|
489
495
|
const { url: t, mockTemplate: s } = e;
|
490
496
|
if (t && s) {
|
@@ -499,7 +505,7 @@ function Ee(n = window) {
|
|
499
505
|
const e = M(n);
|
500
506
|
e && (e._mocked = {});
|
501
507
|
}
|
502
|
-
class
|
508
|
+
class yt {
|
503
509
|
__id = null;
|
504
510
|
__mode;
|
505
511
|
__instance = null;
|
@@ -573,7 +579,7 @@ class gt {
|
|
573
579
|
__ref(e = null, t) {
|
574
580
|
if (this.__mode !== y.VNode)
|
575
581
|
return e && e !== this.__id && (this.__contextRefs[e] = this), async (s) => {
|
576
|
-
await
|
582
|
+
await de(0);
|
577
583
|
let r = s?.$vtjEl || s?.$el || s?._?.vnode?.el || s;
|
578
584
|
if (!r) {
|
579
585
|
typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]);
|
@@ -610,38 +616,40 @@ function X(n) {
|
|
610
616
|
$components: s,
|
611
617
|
$libs: r,
|
612
618
|
$apis: i
|
613
|
-
}, l = new
|
619
|
+
}, l = new yt({
|
614
620
|
mode: t,
|
615
621
|
dsl: o.value,
|
616
622
|
attrs: c
|
617
623
|
}), u = e.defineComponent({
|
618
624
|
name: o.value.name,
|
625
|
+
__scopeId: o.value.id ? `data-v-${o.value.id}` : void 0,
|
619
626
|
props: {
|
620
|
-
...
|
627
|
+
...wt(o.value.props ?? [], l)
|
621
628
|
},
|
622
629
|
setup(p) {
|
623
630
|
l.$props = p, l.props = p, o.value.id && _e(
|
624
631
|
n.window || window,
|
625
632
|
o.value.id,
|
626
|
-
o.value.css || ""
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
633
|
+
o.value.css || "",
|
634
|
+
!0
|
635
|
+
), l.state = St(e, o.value.state ?? {}, l);
|
636
|
+
const m = $t(e, o.value.computed ?? {}, l), f = jt(o.value.methods ?? {}, l), d = Et(e, o.value.inject, l);
|
637
|
+
for (const [v, P] of Object.entries(d || {}))
|
638
|
+
d[v] = e.inject(v, P);
|
639
|
+
const h = Pt(
|
632
640
|
o.value.dataSources || {},
|
633
641
|
l
|
634
642
|
), _ = {
|
635
|
-
...f,
|
636
|
-
...m,
|
637
643
|
...d,
|
644
|
+
...m,
|
645
|
+
...f,
|
638
646
|
...h
|
639
647
|
};
|
640
|
-
return l.setup(_, e),
|
648
|
+
return l.setup(_, e), Rt(e, o.value.watch ?? [], l), {
|
641
649
|
vtj: l
|
642
650
|
};
|
643
651
|
},
|
644
|
-
emits:
|
652
|
+
emits: _t(o.value.emits),
|
645
653
|
expose: ["vtj"],
|
646
654
|
render() {
|
647
655
|
if (!o.value.nodes) return null;
|
@@ -650,17 +658,17 @@ function X(n) {
|
|
650
658
|
(m) => F(m, l, e, a, p)
|
651
659
|
);
|
652
660
|
},
|
653
|
-
...
|
661
|
+
...bt(o.value.lifeCycles ?? {}, l)
|
654
662
|
});
|
655
663
|
return {
|
656
664
|
renderer: e.markRaw(u),
|
657
665
|
context: l
|
658
666
|
};
|
659
667
|
}
|
660
|
-
function
|
668
|
+
function _t(n = []) {
|
661
669
|
return n.map((e) => E(e) ? e : e.name);
|
662
670
|
}
|
663
|
-
function
|
671
|
+
function wt(n = [], e) {
|
664
672
|
const t = (s) => s ? (Array.isArray(s) ? s : [s]).map((i) => Ye[i]) : void 0;
|
665
673
|
return n.map((s) => E(s) ? {
|
666
674
|
name: s
|
@@ -678,7 +686,7 @@ function _t(n = [], e) {
|
|
678
686
|
{}
|
679
687
|
);
|
680
688
|
}
|
681
|
-
function
|
689
|
+
function St(n, e, t) {
|
682
690
|
return n.reactive(
|
683
691
|
Object.keys(e || {}).reduce(
|
684
692
|
(s, r) => {
|
@@ -689,19 +697,19 @@ function wt(n, e, t) {
|
|
689
697
|
)
|
690
698
|
);
|
691
699
|
}
|
692
|
-
function
|
700
|
+
function $t(n, e, t) {
|
693
701
|
return Object.entries(e ?? {}).reduce(
|
694
702
|
(s, [r, i]) => (s[r] = n.computed(t.__parseFunction(i)), s),
|
695
703
|
{}
|
696
704
|
);
|
697
705
|
}
|
698
|
-
function
|
706
|
+
function jt(n, e) {
|
699
707
|
return Object.entries(n ?? {}).reduce(
|
700
708
|
(t, [s, r]) => (t[s] = e.__parseFunction(r), t),
|
701
709
|
{}
|
702
710
|
);
|
703
711
|
}
|
704
|
-
function
|
712
|
+
function Et(n, e = [], t) {
|
705
713
|
return e.reduce(
|
706
714
|
(s, r) => {
|
707
715
|
const { name: i, from: a } = r || {};
|
@@ -712,12 +720,12 @@ function jt(n, e = [], t) {
|
|
712
720
|
{}
|
713
721
|
);
|
714
722
|
}
|
715
|
-
function
|
723
|
+
function Pt(n, e) {
|
716
724
|
return Object.keys(n).reduce(
|
717
725
|
(t, s) => {
|
718
726
|
const r = n[s];
|
719
727
|
if (r.type === "mock")
|
720
|
-
t[s] =
|
728
|
+
t[s] = vt(r);
|
721
729
|
else if (r.ref) {
|
722
730
|
const i = e.$apis[r.ref], a = T(r.transform) ? r.transform.value ? e.__parseFunction(r.transform) : void 0 : r.transform;
|
723
731
|
t[s] = async (...o) => {
|
@@ -730,7 +738,7 @@ function Et(n, e) {
|
|
730
738
|
{}
|
731
739
|
);
|
732
740
|
}
|
733
|
-
function
|
741
|
+
function Rt(n, e = [], t) {
|
734
742
|
e.forEach((s) => {
|
735
743
|
n.watch(
|
736
744
|
t.__parseExpression(s.source),
|
@@ -742,14 +750,14 @@ function Pt(n, e = [], t) {
|
|
742
750
|
);
|
743
751
|
});
|
744
752
|
}
|
745
|
-
function
|
753
|
+
function bt(n, e) {
|
746
754
|
return Object.entries(n ?? {}).reduce(
|
747
755
|
(t, [s, r]) => (t[s] = e.__parseFunction(r), t),
|
748
756
|
{}
|
749
757
|
);
|
750
758
|
}
|
751
759
|
let z = [], b = {};
|
752
|
-
const
|
760
|
+
const Ct = (n) => n;
|
753
761
|
async function Pe(n, e = window) {
|
754
762
|
const { urls: t = [], library: s } = n, r = t.filter((o) => L(o));
|
755
763
|
if (r.length === 0 || !s) return null;
|
@@ -798,33 +806,33 @@ function Z(n) {
|
|
798
806
|
return r;
|
799
807
|
};
|
800
808
|
}
|
801
|
-
function
|
809
|
+
function as() {
|
802
810
|
b = {};
|
803
811
|
}
|
804
|
-
function F(n, e, t = B, s =
|
812
|
+
function F(n, e, t = B, s = Ct, r = [], i = !1) {
|
805
813
|
if (!n || !n.name || n.invisible) return null;
|
806
|
-
const a = t.getCurrentInstance()?.appContext, { id: o = null, directives: c = [] } = n, { vIf: l, vElseIf: u, vElse: p, vFor: m, vShow:
|
814
|
+
const a = t.getCurrentInstance()?.appContext, { id: o = null, directives: c = [] } = n, { vIf: l, vElseIf: u, vElse: p, vFor: m, vShow: f, vModels: d, vBind: h, vHtml: _, others: v } = Re(c);
|
807
815
|
if (!i && (u || p))
|
808
816
|
return null;
|
809
|
-
if (l && !
|
810
|
-
return
|
817
|
+
if (l && !Ft(l, e))
|
818
|
+
return Ht(n, e, t, s, r);
|
811
819
|
const P = (S) => {
|
812
820
|
const Me = S.$components, He = (() => {
|
813
821
|
if (n.name === "component")
|
814
|
-
return
|
822
|
+
return At(S, n.props?.is);
|
815
823
|
if (n.name === "slot") return n.name;
|
816
824
|
const $ = s(n.name, n.from, t);
|
817
|
-
return E($) ?
|
818
|
-
})(), R =
|
825
|
+
return E($) ? at($) || ct($) ? $ : Me[$] ?? a?.app?.component($) ?? $ : $;
|
826
|
+
})(), R = It(o, n.props ?? {}, S), Te = Mt(t, n.events ?? {}, S);
|
819
827
|
if (n.name === "slot")
|
820
|
-
return
|
821
|
-
h && Object.assign(R, S.__parseExpression(h.value)),
|
828
|
+
return Tt(t, n, R, S, s);
|
829
|
+
h && Object.assign(R, S.__parseExpression(h.value)), f && (R.style = Object.assign(
|
822
830
|
R.style ?? {},
|
823
|
-
|
824
|
-
)), _ && Object.assign(R,
|
825
|
-
Object.assign(R,
|
831
|
+
xt(f, S)
|
832
|
+
)), _ && Object.assign(R, Ot(_, S)), d.forEach(($) => {
|
833
|
+
Object.assign(R, Nt(t, $, S));
|
826
834
|
});
|
827
|
-
const De =
|
835
|
+
const De = Bt(
|
828
836
|
t,
|
829
837
|
n.children ?? [],
|
830
838
|
S,
|
@@ -832,12 +840,12 @@ function F(n, e, t = B, s = bt, r = [], i = !1) {
|
|
832
840
|
n
|
833
841
|
);
|
834
842
|
let q = t.createVNode(He, { ...R, ...Te }, De);
|
835
|
-
const ne = a ?
|
843
|
+
const ne = a ? kt(a, v, S) : [];
|
836
844
|
return ne.length && (q = t.withDirectives(q, ne)), q;
|
837
845
|
};
|
838
|
-
return m ?
|
846
|
+
return m ? qt(m, P, e) : P(e);
|
839
847
|
}
|
840
|
-
function
|
848
|
+
function kt(n, e, t) {
|
841
849
|
const s = n.app;
|
842
850
|
return e.map((r) => {
|
843
851
|
const i = typeof r.name == "string" ? s.directive(r.name) : t.__parseExpression(r.name);
|
@@ -866,13 +874,13 @@ function Re(n = []) {
|
|
866
874
|
vHtml: o
|
867
875
|
};
|
868
876
|
}
|
869
|
-
function
|
877
|
+
function Ft(n, e) {
|
870
878
|
return !!e.__parseExpression(n.value);
|
871
879
|
}
|
872
|
-
function
|
880
|
+
function At(n, e) {
|
873
881
|
return e ? w(e) ? n.__parseExpression(e) : e : "div";
|
874
882
|
}
|
875
|
-
function
|
883
|
+
function It(n, e, t) {
|
876
884
|
const s = ee(e, t);
|
877
885
|
return s.ref = t.__ref(n, s.ref), s;
|
878
886
|
}
|
@@ -885,7 +893,7 @@ function ee(n, e) {
|
|
885
893
|
{}
|
886
894
|
) : n;
|
887
895
|
}
|
888
|
-
function
|
896
|
+
function Mt(n, e, t) {
|
889
897
|
const s = ["passive", "capture", "once"], r = {
|
890
898
|
capture: "Capture",
|
891
899
|
once: "Once",
|
@@ -899,7 +907,7 @@ function It(n, e, t) {
|
|
899
907
|
{}
|
900
908
|
);
|
901
909
|
}
|
902
|
-
function
|
910
|
+
function Ht(n, e, t, s, r = []) {
|
903
911
|
let i = r.findIndex((a) => a.id === n.id);
|
904
912
|
for (let a = ++i; a < r.length; a++) {
|
905
913
|
const { directives: o = [] } = r[a], { vElseIf: c, vElse: l } = Re(o);
|
@@ -917,32 +925,32 @@ function be(n = {}, e = !1) {
|
|
917
925
|
const t = Object.keys(n);
|
918
926
|
return e ? t.map((s) => "." + s) : t;
|
919
927
|
}
|
920
|
-
function
|
921
|
-
const { children: i } = e, a =
|
928
|
+
function Tt(n, e, t, s, r) {
|
929
|
+
const { children: i } = e, a = Dt(e, s), o = s.$slots?.[a.name];
|
922
930
|
return o ? o(t) : i ? E(i) ? n.createTextVNode(i) : w(i) ? n.createTextVNode(
|
923
931
|
ye(s.__parseExpression(i))
|
924
932
|
) : Array.isArray(i) ? i.map(
|
925
933
|
(c) => F(c, s, n, r, i)
|
926
934
|
) : null : null;
|
927
935
|
}
|
928
|
-
function
|
936
|
+
function Dt(n, e) {
|
929
937
|
const { props: t } = n, s = t?.name || "default";
|
930
938
|
return {
|
931
939
|
name: w(s) ? e.__parseExpression(s) : s,
|
932
940
|
params: []
|
933
941
|
};
|
934
942
|
}
|
935
|
-
function
|
943
|
+
function xt(n, e) {
|
936
944
|
return e.__parseExpression(n.value) ? {} : {
|
937
945
|
display: "none"
|
938
946
|
};
|
939
947
|
}
|
940
|
-
function
|
948
|
+
function Ot(n, e) {
|
941
949
|
return {
|
942
950
|
innerHTML: e.__parseExpression(n.value) || ""
|
943
951
|
};
|
944
952
|
}
|
945
|
-
function
|
953
|
+
function Nt(n, e, t) {
|
946
954
|
const s = {
|
947
955
|
type: "JSFunction",
|
948
956
|
value: e.value?.value ? `(v) => {
|
@@ -956,7 +964,7 @@ function Ot(n, e, t) {
|
|
956
964
|
[`onUpdate:${a}`]: i.length && r ? n.withModifiers(r, i) : r
|
957
965
|
};
|
958
966
|
}
|
959
|
-
function
|
967
|
+
function Bt(n, e, t, s, r) {
|
960
968
|
if (!e) return null;
|
961
969
|
if (E(e))
|
962
970
|
return { default: () => e };
|
@@ -965,19 +973,19 @@ function Nt(n, e, t, s, r) {
|
|
965
973
|
default: () => ye(t.__parseExpression(e))
|
966
974
|
};
|
967
975
|
if (Array.isArray(e) && e.length > 0) {
|
968
|
-
const i =
|
976
|
+
const i = Ut(e), a = (o) => !o || !r ? {} : r?.id && Object.keys(o).length ? {
|
969
977
|
[`scope_${r.id}`]: o
|
970
978
|
} : {};
|
971
979
|
return Object.entries(i).reduce((o, [c, { nodes: l, params: u }]) => (o[c] = (p) => {
|
972
980
|
const m = u.length ? ze(p ?? {}, u) : a(p);
|
973
981
|
return l.map(
|
974
|
-
(
|
982
|
+
(f) => F(f, t.__clone(m), n, s, l)
|
975
983
|
);
|
976
984
|
}, o), {});
|
977
985
|
}
|
978
986
|
return null;
|
979
987
|
}
|
980
|
-
function
|
988
|
+
function Ut(n) {
|
981
989
|
const e = {
|
982
990
|
default: {
|
983
991
|
params: [],
|
@@ -985,7 +993,7 @@ function Bt(n) {
|
|
985
993
|
}
|
986
994
|
};
|
987
995
|
for (const t of n) {
|
988
|
-
const s =
|
996
|
+
const s = Lt(t.slot), r = s.name;
|
989
997
|
e[r] ? (e[r].nodes.push(t), e[r].params = e[r].params.concat(s.params)) : e[r] = {
|
990
998
|
nodes: [t],
|
991
999
|
params: s.params
|
@@ -993,10 +1001,10 @@ function Bt(n) {
|
|
993
1001
|
}
|
994
1002
|
return e;
|
995
1003
|
}
|
996
|
-
function
|
1004
|
+
function Lt(n = "default") {
|
997
1005
|
return E(n) ? { name: n, params: [] } : { params: [], ...n };
|
998
1006
|
}
|
999
|
-
function
|
1007
|
+
function qt(n, e, t) {
|
1000
1008
|
const { value: s, iterator: r } = n, { item: i = "item", index: a = "index" } = r || {};
|
1001
1009
|
let o = t.__parseExpression(s) || [];
|
1002
1010
|
return Number.isInteger(o) && (o = new Array(o).fill(!0).map((c, l) => l + 1)), Array.isArray(o) ? o.map((c, l) => e(t.__clone({ [i]: c, [a]: l }))) : (console.warn("[vForRender]:", `${s?.value} is not a Arrary`), []);
|
@@ -1027,14 +1035,14 @@ const ue = ve({
|
|
1027
1035
|
activated() {
|
1028
1036
|
this.meta.cache === !1 && (this.sid = Symbol());
|
1029
1037
|
}
|
1030
|
-
}),
|
1038
|
+
}), Jt = ve({
|
1031
1039
|
name: "VtjStartupContainer",
|
1032
1040
|
render() {
|
1033
1041
|
return G("div", "page not found!");
|
1034
1042
|
}
|
1035
1043
|
}), Ce = Symbol("Provider");
|
1036
|
-
var
|
1037
|
-
class
|
1044
|
+
var Kt = /* @__PURE__ */ ((n) => (n.Production = "production", n.Development = "development", n))(Kt || {});
|
1045
|
+
class zt extends xe {
|
1038
1046
|
// DSL缓存
|
1039
1047
|
/**
|
1040
1048
|
* 创建Provider实例
|
@@ -1057,8 +1065,8 @@ class Kt extends xe {
|
|
1057
1065
|
/* Development */
|
1058
1066
|
} = e;
|
1059
1067
|
this.mode = s, this.modules = l, this.service = t, this.router = u, this.materialPath = p, this.nodeEnv = m, r && (this.dependencies = r), i && (this.materials = i), Object.assign(this.globals, c), Object.assign(this.adapter, o);
|
1060
|
-
const { access:
|
1061
|
-
|
1068
|
+
const { access: f, request: d } = this.adapter;
|
1069
|
+
f && f.connect({ mode: s, router: u, request: d }), a && s !== y.Design ? this.load(a) : this.project = a;
|
1062
1070
|
}
|
1063
1071
|
mode;
|
1064
1072
|
// 当前运行模式(设计/源码/预览等)
|
@@ -1115,7 +1123,7 @@ class Kt extends xe {
|
|
1115
1123
|
if (this.project = t ? await t() : await this.service.init(e), !this.project)
|
1116
1124
|
throw new Error("project is null");
|
1117
1125
|
const { apis: s = [], meta: r = [] } = this.project, i = window;
|
1118
|
-
i && (i.CKEDITOR_VERSION = void 0), this.mode === y.Raw ? await this.loadDependencies(i) : await this.loadAssets(i), this.initMock(i), this.apis =
|
1126
|
+
i && (i.CKEDITOR_VERSION = void 0), this.mode === y.Raw ? await this.loadDependencies(i) : await this.loadAssets(i), this.initMock(i), this.apis = ht(s, r, this.adapter), Ee(i), mt(s, i), e.platform !== "uniapp" && this.initRouter(), this.triggerReady();
|
1119
1127
|
}
|
1120
1128
|
initMock(e) {
|
1121
1129
|
const t = M(e);
|
@@ -1141,31 +1149,31 @@ class Kt extends xe {
|
|
1141
1149
|
o === "development"
|
1142
1150
|
/* Development */
|
1143
1151
|
);
|
1144
|
-
for (const
|
1145
|
-
const
|
1152
|
+
for (const f of c) {
|
1153
|
+
const d = s[f], h = e[f];
|
1146
1154
|
if (h)
|
1147
|
-
r[
|
1148
|
-
else if (
|
1149
|
-
e[
|
1155
|
+
r[f] = h;
|
1156
|
+
else if (d)
|
1157
|
+
e[f] = r[f] = await d();
|
1150
1158
|
else {
|
1151
|
-
const _ = l[
|
1159
|
+
const _ = l[f] || [];
|
1152
1160
|
for (const v of _)
|
1153
|
-
U(v) && await
|
1154
|
-
r[
|
1161
|
+
U(v) && await it(f, C.append(v, { v: A })), L(v) && await ae(C.append(v, { v: A }));
|
1162
|
+
r[f] = e[f];
|
1155
1163
|
}
|
1156
1164
|
}
|
1157
1165
|
if (o === "development") {
|
1158
|
-
for (const
|
1159
|
-
await ae(C.append(
|
1160
|
-
const
|
1161
|
-
for (const
|
1162
|
-
const h = e[m[
|
1166
|
+
for (const d of u)
|
1167
|
+
await ae(C.append(d, { v: A }));
|
1168
|
+
const f = this.materials || {};
|
1169
|
+
for (const d of p) {
|
1170
|
+
const h = e[m[d]], _ = Oe[d];
|
1163
1171
|
if (_)
|
1164
1172
|
h && _.forEach((v) => {
|
1165
1173
|
i[v] = h[v];
|
1166
1174
|
});
|
1167
1175
|
else {
|
1168
|
-
const v = d
|
1176
|
+
const v = f[d] ? (await f[d]()).default : e[d];
|
1169
1177
|
v && h && (v.components || []).forEach((P) => {
|
1170
1178
|
i[P.name] = st(P, h);
|
1171
1179
|
});
|
@@ -1187,7 +1195,7 @@ class Kt extends xe {
|
|
1187
1195
|
}, p = {
|
1188
1196
|
path: l,
|
1189
1197
|
name: O,
|
1190
|
-
component: t?.homepage ? ue : r.startupComponent ||
|
1198
|
+
component: t?.homepage ? ue : r.startupComponent || Jt,
|
1191
1199
|
meta: c
|
1192
1200
|
};
|
1193
1201
|
e.hasRoute(I) && e.removeRoute(I), e.hasRoute(O) && e.removeRoute(O), a ? (e.addRoute(a, u), e.addRoute(a, p)) : (e.addRoute(u), e.addRoute(p));
|
@@ -1205,7 +1213,7 @@ class Kt extends xe {
|
|
1205
1213
|
install(e) {
|
1206
1214
|
const t = e.config.globalProperties.installed || {};
|
1207
1215
|
for (const [s, r] of Object.entries(this.library))
|
1208
|
-
!t[s] &&
|
1216
|
+
!t[s] && ot(r) && (e.use(r), t[s] = !0);
|
1209
1217
|
this.options.install && e.use(this.options.install), this.adapter.access && e.use(this.adapter.access), e.provide(Ce, this), e.config.globalProperties.$provider = this, e.config.globalProperties.installed = t, this.mode === y.Design && (e.config.errorHandler = (s, r, i) => {
|
1210
1218
|
const a = r?.$options.name, o = typeof s == "string" ? s : s?.message || s?.msg || "未知错误", c = `[ ${a} ] ${o} ${i}`;
|
1211
1219
|
console.error(
|
@@ -1332,8 +1340,8 @@ class Kt extends xe {
|
|
1332
1340
|
return ce(async () => await Pe(e, window));
|
1333
1341
|
}
|
1334
1342
|
}
|
1335
|
-
function
|
1336
|
-
const e = new
|
1343
|
+
function cs(n) {
|
1344
|
+
const e = new zt(n);
|
1337
1345
|
return {
|
1338
1346
|
provider: e,
|
1339
1347
|
onReady: (s) => e.ready(s)
|
@@ -1356,7 +1364,7 @@ function ke(n = {}) {
|
|
1356
1364
|
}
|
1357
1365
|
return e;
|
1358
1366
|
}
|
1359
|
-
async function
|
1367
|
+
async function ls(n, e = "") {
|
1360
1368
|
const { name: t, urls: s = [] } = n || {}, r = s.map((o) => e + o), { css: i, js: a } = nt(r);
|
1361
1369
|
if (i.length && we(i), a.length)
|
1362
1370
|
return await Se(a, t).catch(
|
@@ -1370,7 +1378,7 @@ const Fe = {
|
|
1370
1378
|
originResponse: !1,
|
1371
1379
|
failMessage: !0,
|
1372
1380
|
validate: (n) => n.data?.code === 0
|
1373
|
-
},
|
1381
|
+
}, Vt = (n, e = "/__vtj__/api/:type.json") => (t, s, r) => n.send({
|
1374
1382
|
url: e,
|
1375
1383
|
method: "post",
|
1376
1384
|
params: { type: t },
|
@@ -1380,7 +1388,7 @@ const Fe = {
|
|
1380
1388
|
data: s
|
1381
1389
|
},
|
1382
1390
|
settings: Fe
|
1383
|
-
}),
|
1391
|
+
}), Wt = (n, e = "/__vtj__/api/uploader.json") => async (t, s) => await n.send({
|
1384
1392
|
url: e,
|
1385
1393
|
method: "post",
|
1386
1394
|
data: {
|
@@ -1392,8 +1400,8 @@ const Fe = {
|
|
1392
1400
|
type: "data"
|
1393
1401
|
}
|
1394
1402
|
}).then((r) => r && r[0] ? r[0] : null).catch(() => null);
|
1395
|
-
function
|
1396
|
-
return
|
1403
|
+
function us(n) {
|
1404
|
+
return fe({
|
1397
1405
|
settings: {
|
1398
1406
|
type: "json",
|
1399
1407
|
validSuccess: !0,
|
@@ -1408,7 +1416,7 @@ function ls(n) {
|
|
1408
1416
|
}
|
1409
1417
|
class se {
|
1410
1418
|
constructor(e = W) {
|
1411
|
-
this.req = e, this.api =
|
1419
|
+
this.req = e, this.api = Vt(e), this.uploader = Wt(e);
|
1412
1420
|
}
|
1413
1421
|
api;
|
1414
1422
|
pluginCaches = {};
|
@@ -1513,7 +1521,7 @@ const g = new Ve({
|
|
1513
1521
|
expired: 0,
|
1514
1522
|
prefix: "__VTJ_"
|
1515
1523
|
});
|
1516
|
-
class
|
1524
|
+
class ps extends se {
|
1517
1525
|
init(e) {
|
1518
1526
|
const t = new N(e), s = g.get(`project_${t.id}`), r = Object.assign(t.toDsl(), s || {});
|
1519
1527
|
return g.save(`project_${t.id}`, r), Promise.resolve(r);
|
@@ -1563,7 +1571,7 @@ class us extends se {
|
|
1563
1571
|
}), Promise.resolve(!0);
|
1564
1572
|
}
|
1565
1573
|
}
|
1566
|
-
class
|
1574
|
+
class Gt extends se {
|
1567
1575
|
projects = {};
|
1568
1576
|
materials = {};
|
1569
1577
|
files = {};
|
@@ -1621,8 +1629,8 @@ class Wt extends se {
|
|
1621
1629
|
}
|
1622
1630
|
}
|
1623
1631
|
let x = null;
|
1624
|
-
function
|
1625
|
-
return x || (x = new
|
1632
|
+
function ds() {
|
1633
|
+
return x || (x = new Gt(), x);
|
1626
1634
|
}
|
1627
1635
|
class fs extends se {
|
1628
1636
|
getFileCaches = {};
|
@@ -1705,22 +1713,22 @@ function Ie(n, e) {
|
|
1705
1713
|
e.can(s.id.toString()) && t.push(s);
|
1706
1714
|
return t;
|
1707
1715
|
}
|
1708
|
-
function
|
1716
|
+
function hs(n) {
|
1709
1717
|
const {
|
1710
1718
|
menuPathPrefix: e = "",
|
1711
1719
|
pageRouteName: t = "page",
|
1712
1720
|
disableMenusFilter: s = !1
|
1713
|
-
} = n || {}, r = ke(), i = ge(), a =
|
1721
|
+
} = n || {}, r = ke(), i = ge(), a = pt(), o = Y(!1), c = Y(!1), l = r.project;
|
1714
1722
|
We(() => {
|
1715
|
-
const { name: m, params:
|
1723
|
+
const { name: m, params: f, meta: d } = i;
|
1716
1724
|
if (m === I) {
|
1717
|
-
const h = r.getPage(
|
1725
|
+
const h = r.getPage(f.id);
|
1718
1726
|
o.value = !h?.mask, c.value = !!h?.pure;
|
1719
1727
|
} else if (m === O) {
|
1720
1728
|
const h = r.getHomepage();
|
1721
1729
|
o.value = !h?.mask, c.value = !!h?.pure;
|
1722
1730
|
} else
|
1723
|
-
o.value = !
|
1731
|
+
o.value = !d.mask, c.value = !!d.pure;
|
1724
1732
|
});
|
1725
1733
|
const u = Ae(
|
1726
1734
|
e,
|
@@ -1743,57 +1751,58 @@ export {
|
|
1743
1751
|
Ge as BUILT_IN_DIRECTIVES,
|
1744
1752
|
se as BaseService,
|
1745
1753
|
le as CONTEXT_HOST,
|
1746
|
-
|
1754
|
+
yt as Context,
|
1747
1755
|
y as ContextMode,
|
1748
1756
|
Ye as DATA_TYPES,
|
1749
1757
|
O as HOMEPAGE_ROUTE_NAME,
|
1750
1758
|
Qe as HTML_TAGS,
|
1751
|
-
|
1752
|
-
|
1759
|
+
rs as JSCodeToString,
|
1760
|
+
es as LIFE_CYCLES_LIST,
|
1753
1761
|
fs as LocalService,
|
1754
|
-
|
1755
|
-
|
1762
|
+
Gt as MemoryService,
|
1763
|
+
Kt as NodeEnv,
|
1756
1764
|
I as PAGE_ROUTE_NAME,
|
1757
|
-
|
1758
|
-
|
1765
|
+
zt as Provider,
|
1766
|
+
ps as StorageService,
|
1759
1767
|
A as VTJ_RENDERER_VERSION,
|
1760
1768
|
_e as adoptedStyleSheets,
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
ts as
|
1766
|
-
|
1769
|
+
as as clearLoaderCache,
|
1770
|
+
rt as compileScopedCSS,
|
1771
|
+
os as createAccess,
|
1772
|
+
is as createAdapter,
|
1773
|
+
ts as createAssetScripts,
|
1774
|
+
ss as createAssetsCss,
|
1775
|
+
Pt as createDataSources,
|
1767
1776
|
Z as createLoader,
|
1768
|
-
|
1777
|
+
ds as createMemoryService,
|
1769
1778
|
ft as createMetaApi,
|
1770
|
-
|
1771
|
-
|
1779
|
+
vt as createMock,
|
1780
|
+
cs as createProvider,
|
1772
1781
|
X as createRenderer,
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1782
|
+
dt as createSchemaApi,
|
1783
|
+
ht as createSchemaApis,
|
1784
|
+
us as createServiceRequest,
|
1785
|
+
Ct as defaultLoader,
|
1777
1786
|
D as fillBasePath,
|
1778
1787
|
M as getMock,
|
1779
1788
|
be as getModifiers,
|
1780
1789
|
Pe as getPlugin,
|
1781
1790
|
st as getRawComponent,
|
1782
|
-
|
1791
|
+
at as isBuiltInTag,
|
1783
1792
|
U as isCSSUrl,
|
1784
|
-
|
1793
|
+
lt as isJSCode,
|
1785
1794
|
w as isJSExpression,
|
1786
1795
|
T as isJSFunction,
|
1787
1796
|
Ze as isJSON,
|
1788
1797
|
L as isJSUrl,
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1798
|
+
ct as isNativeTag,
|
1799
|
+
ot as isVuePlugin,
|
1800
|
+
it as loadCss,
|
1792
1801
|
we as loadCssUrl,
|
1793
|
-
|
1802
|
+
ls as loadEnhance,
|
1794
1803
|
Se as loadScriptUrl,
|
1795
|
-
|
1796
|
-
|
1804
|
+
gt as mockApi,
|
1805
|
+
mt as mockApis,
|
1797
1806
|
Ee as mockCleanup,
|
1798
1807
|
F as nodeRender,
|
1799
1808
|
tt as parseDeps,
|
@@ -1802,9 +1811,9 @@ export {
|
|
1802
1811
|
nt as parseUrls,
|
1803
1812
|
Ce as providerKey,
|
1804
1813
|
et as removeProdFlag,
|
1805
|
-
|
1814
|
+
ns as setupPageSetting,
|
1806
1815
|
ye as toString,
|
1807
|
-
|
1808
|
-
|
1816
|
+
pt as useAccess,
|
1817
|
+
hs as useMask,
|
1809
1818
|
ke as useProvider
|
1810
1819
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vtj/renderer",
|
3
3
|
"private": false,
|
4
|
-
"version": "0.12.
|
4
|
+
"version": "0.12.26",
|
5
5
|
"type": "module",
|
6
6
|
"keywords": [
|
7
7
|
"低代码引擎",
|
@@ -21,15 +21,15 @@
|
|
21
21
|
"author": "chenhuachun",
|
22
22
|
"license": "MIT",
|
23
23
|
"dependencies": {
|
24
|
-
"@vtj/
|
25
|
-
"@vtj/
|
24
|
+
"@vtj/utils": "~0.12.26",
|
25
|
+
"@vtj/core": "~0.12.26"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"vue": "~3.5.5",
|
29
29
|
"vue-router": "~4.5.0",
|
30
|
-
"@vtj/
|
31
|
-
"@vtj/
|
32
|
-
"@vtj/
|
30
|
+
"@vtj/cli": "~0.12.2",
|
31
|
+
"@vtj/ui": "~0.12.26",
|
32
|
+
"@vtj/icons": "~0.12.26"
|
33
33
|
},
|
34
34
|
"exports": {
|
35
35
|
".": {
|
package/types/utils/util.d.ts
CHANGED
@@ -2,7 +2,8 @@ import { Plugin, App } from 'vue';
|
|
2
2
|
import { PageFile, BlockFile } from '@vtj/core';
|
3
3
|
import { RouteLocationNormalizedGeneric } from 'vue-router';
|
4
4
|
export declare function toString(value: any): string;
|
5
|
-
export declare function
|
5
|
+
export declare function compileScopedCSS(cssContent: string, scopeId: string): string;
|
6
|
+
export declare function adoptedStyleSheets(global: Window, id: string, css: string, scoped?: boolean): void;
|
6
7
|
export declare function loadCss(id: string, url: string): Promise<void>;
|
7
8
|
export declare function loadCssUrl(urls: string[], global?: any): void;
|
8
9
|
export declare function loadScriptUrl(urls: string[], library: string, global?: any): Promise<any>;
|
package/types/version.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
3
3
|
* @name @vtj/renderer
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
5
|
-
* @version 0.12.
|
5
|
+
* @version 0.12.25
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
7
|
*/
|
8
|
-
export declare const version = "0.12.
|
8
|
+
export declare const version = "0.12.25";
|