@vtj/renderer 0.8.164 → 0.8.165
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 +102 -88
- package/package.json +5 -5
- package/types/plugins/access.d.ts +5 -3
package/dist/index.cjs
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
"use strict";var Pe=Object.create;var Z=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Ie=(
|
1
|
+
"use strict";var Pe=Object.create;var Z=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Ie=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Re(e))!Ae.call(n,r)&&r!==t&&Z(n,r,{get:()=>e[r],enumerable:!(s=be(e,r))||s.enumerable});return n};var Oe=(n,e,t)=>(t=n!=null?Pe(Fe(n)):{},Ie(e||!n||!n.__esModule?Z(t,"default",{value:n,enumerable:!0}):t,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@vtj/core"),l=require("@vtj/utils"),h=require("vue"),te=require("vue-router"),A=require("element-plus"),Me=require("@vtj/ui");function xe(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const D=xe(h);/**!
|
2
2
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
3
3
|
* @name @vtj/renderer
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
5
|
-
* @version 0.8.
|
5
|
+
* @version 0.8.165
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
|
-
*/const b="0.8.
|
8
|
-
`)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(r){if(u.logger.error("parseExpression.error",r,s,e?.__self??e),n)throw r}}function L(s,e,t=!1,n=!1){const r=R(s,e,t,n);if(typeof r!="function"&&(u.logger.error("parseFunction.error","not a function",s,e?.__self??e),n))throw new Error(`"${s.value}" not a function`);return r}function E(s){return s&&s.type==="JSExpression"}function O(s){return typeof s=="object"&&s&&s.type==="JSFunction"}function fe(s){return E(s)||O(s)}function ke(s){return fe(s)?s.value:JSON.stringify(s)}let C=null;const Be=u.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:s=>s.data?.code===0||!!s.data?.success,failMessage:!0,showError:s=>{A.ElNotification.error({message:s||"未知错误"})},showLoading:()=>{C&&C.close(),C=A.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{C&&(C.close(),C=null)}}});let P;function pe(s,e){const{jsonp:t,request:n}=e;if(s.method==="jsonp")return(r={})=>t(s.url,{...s.jsonpOptions,query:r});{const r=s.headers?R(s.headers,{},!0):void 0,o={url:s.url,method:s.method,settings:{...s.settings,headers:r}};return(a,i)=>(delete o.data,n.send(u.merge(o,i||{},{data:a})))}}function me(s,e){const{metaQuery:t}=e;if(!t)return;const{code:n,queryCode:r}=s;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(n,r,o,a)}}function he(s=[],e=[],t){const n={};for(const r of s)n[r.id]=pe(r,t);for(const r of e)n[r.id]=me(r,t);return n}async function ge(s=[]){P=await import("mockjs").then(e=>e.default||e),P&&(P.setup({timeout:"50-500"}),V(),s.forEach(e=>ve(P,e)))}function ve(s,e){if(!e.mock)return;const{url:t,mockTemplate:n}=e;if(t&&n){const r=u.pathToRegexp(`${t}(.*)`),o=u.pathToRegexpMatch(t,{decode:decodeURIComponent}),a=R(n,{},!0);s.mock(r,i=>{const l=u.url.parse(i.url)||{},c=i.body instanceof FormData?u.formDataToJson(i.body):i.body,h=o(i.url)?.params;return Object.assign(i,{data:c,params:l,query:h}),s.mock(a(i))})}}function V(){P&&(P._mocked={})}const Ue={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ__",unauthorized:"/unauthorized",auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!"},z=Symbol("access");class Ne{options;data=null;constructor(e){this.options=Object.assign({},Ue,e),this.loadData()}connect(e){const{mode:t,router:n,request:r}=e;n&&t===j.Raw&&this.setGuard(n),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:n,session:r,authKey:o}=this.options;this.data=e,u.storage.save(t,e,{type:"local",prefix:n}),r&&u.cookie.set(o,e.token)}logout(){const{storageKey:e,storagePrefix:t}=this.options;this.data=null,u.storage.remove(e,{type:"local",prefix:t}),this.toLogin()}getData(){return this.data}can(e){const{permissions:t={}}=this.data||{};return u.toArray(e).every(r=>t[r])}some(e){const{permissions:t={}}=this.data||{};return u.toArray(e).some(r=>t[r])}install(e){e.config.globalProperties.$access=this,e.provide(z,this)}isAuthPath(e){const{auth:t,isAuth:n}=this.options;return n?n(e):e.path&&typeof t=="string"?t.includes(e.path):!1}toLogin(){const{auth:e,redirectParam:t}=this.options;e&&(typeof e=="function"?e():location.href=t?`${e}?${t}=${encodeURIComponent(location.href)}`:e)}loadData(){const{storageKey:e,storagePrefix:t}=this.options;this.data=u.storage.get(e,{type:"local",prefix:t})}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!u.cookie.get(t):!!this.data}setGuard(e){e.beforeEach((t,n,r)=>this.guard(t,r))}guard(e,t){if(this.isWhiteList(e)||this.isLogined()||this.isAuthPath(e))return t();t(!1),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(n=>e.fullPath.startsWith(n)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401}=this.options;return e.status===t||e.data.code===t}setRequest(e){const{alert:t,unauthorizedMessage:n="登录已失效"}=this.options;e.useRequest(r=>(r.headers.Authorization=this.data?.token,r)),e.useResponse(r=>(this.isUnauthorized(r)&&t&&t(n),r),r=>{const o=r.response||r||{};return this.isUnauthorized(o)&&t&&t(n),r})}}function Le(){const s=m.inject(z,null);return s||console.warn("access is null"),s}class ye{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};__transform={};constructor(e){const{mode:t,dsl:n,attrs:r}=e;this.__mode=t,n&&(this.__id=n.id||null,this.__transform=n.transform||{}),r&&Object.assign(this,r)}setup(e,t=D){const n=t.getCurrentInstance();if(!n)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=n.proxy;const r=n.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__proxy(){this.__instance&&N.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){N.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===j.Runtime){const{id:t,type:n}=e,r=t?this.__transform[t]??e.value:e.value;return L({type:n,value:r},this)}else return L(e,this)}__parseExpression(e){if(e)if(this.__mode===j.Runtime){const{id:t,type:n}=e,r=t?this.__transform[t]??e.value:e.value;return R({type:n,value:r},this)}else return R(e,this)}__ref(e=null,t){if(this.__mode!==j.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async n=>{await u.delay(0);let r=n?.$vtjEl||n?.$el||n?._?.vnode?.el||n;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}if(r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,j.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=n),typeof t=="function")t(n);else if(t){const o=this.$refs[t];if(o&&n!==o){const a=new Set([].concat(o,n));this.$refs[t]=Array.from(a)}else this.$refs[t]=n}return n}}__clone(e={}){const t={...this.context,...e},n={...t,context:t};return n.context.__proto__=this.context,n.__proto__=this,n}}function x(s){const{Vue:e=D,mode:t=j.Runtime,components:n={},libs:r={},apis:o={},loader:a}=s,i=e.computed(()=>s.dsl),l={$components:n,$libs:r,$apis:o},c=new ye({mode:t,dsl:i.value,attrs:l}),h=e.defineComponent({name:i.value.name,props:{...Je(i.value.props??[],c)},setup(f){c.$props=f,c.props=f,i.value.id&&J(s.window||window,i.value.id,i.value.css||""),c.state=Ve(e,i.value.state??{},c);const d=ze(e,i.value.computed??{},c),v=Ke(i.value.methods??{},c),p=We(e,i.value.inject,c),g=_e(i.value.dataSources||{},c),w={...p,...d,...v,...g};return c.setup(w,e),Ye(e,i.value.watch??[],c),{vtj:c}},emits:qe(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const f=i.value.nodes||[];return f.length===1?I(f[0],c,e,a):f.map(d=>I(d,c,e,a))},...Ge(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(h),context:c}}function qe(s=[]){return s.map(e=>u.isString(e)?e:e.name)}function Je(s=[],e){const t=n=>n?(Array.isArray(n)?n:[n]).map(o=>se[o]):void 0;return s.map(n=>u.isString(n)?{name:n}:{name:n.name,type:n.type,required:n.required,default:E(n.default)?e.__parseExpression(n.default):n.default}).reduce((n,r)=>(n[r.name]={type:t(r.type),required:r.required,default:r.default},n),{})}function Ve(s,e,t){return s.reactive(Object.keys(e||{}).reduce((n,r)=>{let o=e[r];return E(o)?o=t.__parseExpression(o):O(o)&&(o=t.__parseFunction(o)),n[r]=o,n},{}))}function ze(s,e,t){return Object.entries(e??{}).reduce((n,[r,o])=>(n[r]=s.computed(t.__parseFunction(o)),n),{})}function Ke(s,e){return Object.entries(s??{}).reduce((t,[n,r])=>(t[n]=e.__parseFunction(r),t),{})}function We(s,e=[],t){return e.reduce((n,r)=>{const{name:o,from:a}=r||{};r.default;const i=E(a)?t.__parseExpression(a)||o:a??o,l=E(r.default)?t.__parseExpression(r.default):r.default??null;return n[o]=s.inject(i,l),n},{})}function _e(s,e){return Object.keys(s).reduce((t,n)=>{const r=s[n],o=e.$apis[r.ref],a=O(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;return t[n]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l},t},{})}function Ye(s,e=[],t){e.forEach(n=>{s.watch(t.__parseExpression(n.source),t.__parseFunction(n.handler),{deep:n.deep,immediate:n.immediate})})}function Ge(s,e){return Object.entries(s??{}).reduce((t,[n,r])=>(t[n]=e.__parseFunction(r),t),{})}let U=[];const Se=s=>s;async function K(s,e=window){const{urls:t=[],library:n}=s,r=t.filter(i=>k(i));if(r.length===0||!n)return null;const o=t.filter(i=>H(i));return o.length&&ue(o,e),await le(r,n,e).catch(i=>(console.warn("loadScriptUrl error",r,n,i),null))}function T(s){const{getDsl:e,getDslByUrl:t,options:n}=s;return n.window&&(U.forEach(r=>{delete n.window[r]}),U=[]),(r,o,a=D)=>!o||typeof o=="string"?r:o.type==="Schema"&&o.id?a.defineAsyncComponent(async()=>{const i=await e(o.id);return i&&(i.name=r),i?x({...n,Vue:a,dsl:i,mode:j.Runtime,loader:T(s)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=r),i?x({...n,Vue:a,dsl:i,mode:j.Runtime,loader:T(s)}).renderer:null}):o.type==="Plugin"?(o.library&&U.push(o.library),a.defineAsyncComponent(async()=>{const i=await K(o,n.window);return i||(console.warn("getPlugin result is null",o),null)})):r}function I(s,e,t=D,n=Se){if(!s||!s.name||s.invisible)return null;const{id:r=null,directives:o=[]}=s,{vIf:a,vFor:i,vShow:l,vModels:c,vBind:h}=Xe(o);if(a&&!Qe(a,e))return null;const f=d=>{const v=d.$components,p=(()=>{if(s.name==="component")return Ze(d,s.props?.is);if(s.name==="slot")return s.name;const _=n(s.name,s.from,t);return u.isString(_)?v[_]??_:_})(),g=et(r,s.props??{},d),w=tt(t,s.events??{},d);if(s.name==="slot")return nt(t,s,g,d,n);h&&Object.assign(g,d.__parseExpression(h.value)),l&&(g.style=Object.assign(g.style??{},rt(l,d))),c.forEach(_=>{Object.assign(g,ot(t,_,d))});const y=it(t,s.children??[],d,n,s);return t.createVNode(p,{...g,...w},y)};return i?ut(i,f,e):f(e)}function Xe(s=[]){const e=s.find(i=>u.camelCase(i.name)==="vIf"),t=s.find(i=>u.camelCase(i.name)==="vFor"),n=s.find(i=>u.camelCase(i.name)==="vShow"),r=s.find(i=>u.camelCase(i.name)==="vBind"),o=s.filter(i=>u.camelCase(i.name)==="vModel"),a=s.filter(i=>!ne.includes(u.camelCase(i.name)));return{vIf:e,vFor:t,vShow:n,vModels:o,vBind:r,others:a}}function Qe(s,e){return!!e.__parseExpression(s.value)}function Ze(s,e){return e?E(e)?s.__parseExpression(e):e:"div"}function et(s,e,t){const n=Object.keys(e||{}).reduce((r,o)=>{let a=e[o];return E(a)?a=t.__parseExpression(a):O(a)&&(a=t.__parseFunction(a)),r[o]=a,r},{});return n.ref=t.__ref(s,n.ref),n}function tt(s,e,t){const n=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=W(i.modifiers),c=l.find(d=>n.includes(d)),h="on"+u.upperFirst(a)+(c&&r[c]||""),f=t.__parseFunction(i.handler);return f&&(o[h]=s.withModifiers(f,l)),o},{})}function W(s={},e=!1){const t=Object.keys(s);return e?t.map(n=>"."+n):t}function nt(s,e,t,n,r){const{children:o}=e,a=st(e,n),i=n.$slots?.[a.name];return i?i(t):o?u.isString(o)?s.createTextVNode(o):E(o)?s.createTextVNode(q(n.__parseExpression(o))):Array.isArray(o)?o.map(l=>I(l,n,s,r)):null:null}function st(s,e){const{props:t}=s,n=t?.name||"default";return{name:E(n)?e.__parseExpression(n):n,params:[]}}function rt(s,e){return e.__parseExpression(s.value)?{}:{display:"none"}}function ot(s,e,t){const n={type:"JSFunction",value:e.value?.value?`(v) => {
|
7
|
+
*/const b="0.8.165";var j=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(j||{});const N=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],Te=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],se=["vIf","vShow","vModel","vFor","vBind"],ne={String,Number,Boolean,Array,Object,Function,Date};function F(n,e){return n.map(t=>l.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function H(n){return/\.css$/.test(n)}function k(n){return/\.js$/.test(n)}function re(n){return/\.json$/.test(n)}function De(n){return n.map(e=>`<script src="${l.url.append(e,{v:b})}"><\/script>`).join("")}function He(n=[]){return n.map(e=>`<link rel="stylesheet" href="${l.url.append(e,{v:b})}" />`).join("")}function oe(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function ie(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],u={},c={},m=[],f={};return s.forEach(({urls:d,assetsUrl:v,library:p,assetsLibrary:g,localeLibrary:w})=>{d?.forEach(y=>{k(y)&&r.push(oe(y,t)),H(y)&&o.push(y)}),p&&(i.push(p),u[p]=F(d||[],e),w&&(c[p]=w)),v&&a.push(v),g&&m.push(g),p&&g&&(f[g]=p)}),{scripts:F(r,e),css:F(o,e),materials:F(a,e),libraryExports:i,materialExports:l.dedupArray(m),materialMapLibrary:f,libraryMap:u,libraryLocaleMap:c}}function ae(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function q(n){return l.isString(n)?n:JSON.stringify(n)}function J(n,e,t){const s=n.CSSStyleSheet;if(s.prototype.replaceSync){const r=new s;r.id=e,r.replaceSync(t);const o=n.document,a=o.adoptedStyleSheets,i=Array.from(a).filter(u=>u.id!==e);o.adoptedStyleSheets=[...i,r]}else{const r=n.document;let o=r.getElementById(e);o?o.innerHTML=t:(o=r.createElement("style"),o.id=e,o.innerHTML=t,r.head.appendChild(o))}}async function ce(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&J(window,n,t)}function le(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const a=t.createElement("link");a.rel="stylesheet",a.id=r,a.href=r,s.appendChild(a)}}async function ue(n,e,t=window){const s=t.document,r=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const u of n){const c=s.createElement("script");c.src=u,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=m=>{i(m)},r.appendChild(c)}})}function de(n){return l.isFunction(n)||l.isFunction(n?.install)}function R(n,e,t=!1,s=!1){try{const r=['"use strict";',"var __self = arguments[0];"];r.push("return ");let o=(n.value||"").trim();o=o.replace(/this(\W|$)/g,(i,u)=>`__self${u}`),o=r.join(`
|
8
|
+
`)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(r){if(l.logger.error("parseExpression.error",r,n,e?.__self??e),s)throw r}}function L(n,e,t=!1,s=!1){const r=R(n,e,t,s);if(typeof r!="function"&&(l.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return r}function $(n){return n&&n.type==="JSExpression"}function O(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function fe(n){return $(n)||O(n)}function ke(n){return fe(n)?n.value:JSON.stringify(n)}let C=null;const Ue=l.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:n=>n.data?.code===0||!!n.data?.success,failMessage:!0,showError:n=>{A.ElNotification.error({message:n||"未知错误"})},showLoading:()=>{C&&C.close(),C=A.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{C&&(C.close(),C=null)}}});let P;function pe(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?R(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(a,i)=>(delete o.data,s.send(l.merge(o,i||{},{data:a})))}}function he(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,a)}}function me(n=[],e=[],t){const s={};for(const r of n)s[r.id]=pe(r,t);for(const r of e)s[r.id]=he(r,t);return s}async function ge(n=[]){P=await import("mockjs").then(e=>e.default||e),P&&(P.setup({timeout:"50-500"}),V(),n.forEach(e=>ve(P,e)))}function ve(n,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s){const r=l.pathToRegexp(`${t}(.*)`),o=l.pathToRegexpMatch(t,{decode:decodeURIComponent}),a=R(s,{},!0);n.mock(r,i=>{const u=l.url.parse(i.url)||{},c=i.body instanceof FormData?l.formDataToJson(i.body):i.body,m=o(i.url)?.params;return Object.assign(i,{data:c,params:u,query:m}),n.mock(a(i))})}}function V(){P&&(P._mocked={})}const Be={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ__",unauthorized:"/unauthorized",auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!"},z=Symbol("access");class Ne{options;data=null;constructor(e){this.options=Object.assign({},Be,e),this.loadData()}connect(e){const{mode:t,router:s,request:r}=e;s&&t===j.Raw&&this.setGuard(s),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:s,session:r,authKey:o}=this.options;this.data=e,l.storage.save(t,e,{type:"local",prefix:s}),r&&l.cookie.set(o,e.token)}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:r}=this.options;this.data=null,l.storage.remove(e,{type:"local",prefix:t}),s&&l.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data}can(e){const{permissions:t={}}=this.data||{};return l.toArray(e).every(r=>t[r])}some(e){const{permissions:t={}}=this.data||{};return l.toArray(e).some(r=>t[r])}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 r=t.split("#")[1]||t;return e.path===r}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}loadData(){const{storageKey:e,storagePrefix:t}=this.options;this.data=l.storage.get(e,{type:"local",prefix:t})}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!l.cookie.get(t):!!this.data}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}guard(e,t){if(this.isWhiteList(e)||this.isLogined()||this.isAuthPath(e))return t();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}=this.options;return e.status===t||e.data.code===t}async showUnauthorizedAlert(e){const{alert:t,unauthorizedMessage:s="登录已失效"}=this.options;this.isUnauthorized(e)&&t&&(await t(s,{title:"提示",type:"warning"}).catch(r=>r),this.toLogin())}setRequest(e){e.useRequest(t=>(t.headers.Authorization=this.data?.token,t)),e.useResponse(async t=>(await this.showUnauthorizedAlert(t),t),async t=>{const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function Le(){const n=h.inject(z,null);return n||console.warn("access is null"),n}class ye{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=D){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__proxy(){this.__instance&&N.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){N.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===j.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return L({type:s,value:r},this)}else return L(e,this)}__parseExpression(e){if(e)if(this.__mode===j.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return R({type:s,value:r},this)}else return R(e,this)}__ref(e=null,t){if(this.__mode!==j.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await l.delay(0);let r=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}if(r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,j.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=s),typeof t=="function")t(s);else if(t){const o=this.$refs[t];if(o&&s!==o){const a=new Set([].concat(o,s));this.$refs[t]=Array.from(a)}else this.$refs[t]=s}return s}}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function x(n){const{Vue:e=D,mode:t=j.Runtime,components:s={},libs:r={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),u={$components:s,$libs:r,$apis:o},c=new ye({mode:t,dsl:i.value,attrs:u}),m=e.defineComponent({name:i.value.name,props:{...Je(i.value.props??[],c)},setup(f){c.$props=f,c.props=f,i.value.id&&J(n.window||window,i.value.id,i.value.css||""),c.state=Ve(e,i.value.state??{},c);const d=ze(e,i.value.computed??{},c),v=Ke(i.value.methods??{},c),p=We(e,i.value.inject,c),g=_e(i.value.dataSources||{},c),w={...p,...d,...v,...g};return c.setup(w,e),Ye(e,i.value.watch??[],c),{vtj:c}},emits:qe(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const f=i.value.nodes||[];return f.length===1?I(f[0],c,e,a):f.map(d=>I(d,c,e,a))},...Ge(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(m),context:c}}function qe(n=[]){return n.map(e=>l.isString(e)?e:e.name)}function Je(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>ne[o]):void 0;return n.map(s=>l.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:$(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,r)=>(s[r.name]={type:t(r.type),required:r.required,default:r.default},s),{})}function Ve(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return $(o)?o=t.__parseExpression(o):O(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function ze(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function Ke(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function We(n,e=[],t){return e.reduce((s,r)=>{const{name:o,from:a}=r||{};r.default;const i=$(a)?t.__parseExpression(a)||o:a??o,u=$(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(i,u),s},{})}function _e(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s],o=e.$apis[r.ref],a=O(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;return t[s]=async(...i)=>{const u=await o.apply(e,i);return a?a(u):u},t},{})}function Ye(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function Ge(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}let B=[];const Se=n=>n;async function K(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>k(i));if(r.length===0||!s)return null;const o=t.filter(i=>H(i));return o.length&&le(o,e),await ue(r,s,e).catch(i=>(console.warn("loadScriptUrl error",r,s,i),null))}function T(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(B.forEach(r=>{delete s.window[r]}),B=[]),(r,o,a=D)=>!o||typeof o=="string"?r:o.type==="Schema"&&o.id?a.defineAsyncComponent(async()=>{const i=await e(o.id);return i&&(i.name=r),i?x({...s,Vue:a,dsl:i,mode:j.Runtime,loader:T(n)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=r),i?x({...s,Vue:a,dsl:i,mode:j.Runtime,loader:T(n)}).renderer:null}):o.type==="Plugin"?(o.library&&B.push(o.library),a.defineAsyncComponent(async()=>{const i=await K(o,s.window);return i||(console.warn("getPlugin result is null",o),null)})):r}function I(n,e,t=D,s=Se){if(!n||!n.name||n.invisible)return null;const{id:r=null,directives:o=[]}=n,{vIf:a,vFor:i,vShow:u,vModels:c,vBind:m}=Xe(o);if(a&&!Qe(a,e))return null;const f=d=>{const v=d.$components,p=(()=>{if(n.name==="component")return Ze(d,n.props?.is);if(n.name==="slot")return n.name;const _=s(n.name,n.from,t);return l.isString(_)?v[_]??_:_})(),g=et(r,n.props??{},d),w=tt(t,n.events??{},d);if(n.name==="slot")return st(t,n,g,d,s);m&&Object.assign(g,d.__parseExpression(m.value)),u&&(g.style=Object.assign(g.style??{},rt(u,d))),c.forEach(_=>{Object.assign(g,ot(t,_,d))});const y=it(t,n.children??[],d,s,n);return t.createVNode(p,{...g,...w},y)};return i?lt(i,f,e):f(e)}function Xe(n=[]){const e=n.find(i=>l.camelCase(i.name)==="vIf"),t=n.find(i=>l.camelCase(i.name)==="vFor"),s=n.find(i=>l.camelCase(i.name)==="vShow"),r=n.find(i=>l.camelCase(i.name)==="vBind"),o=n.filter(i=>l.camelCase(i.name)==="vModel"),a=n.filter(i=>!se.includes(l.camelCase(i.name)));return{vIf:e,vFor:t,vShow:s,vModels:o,vBind:r,others:a}}function Qe(n,e){return!!e.__parseExpression(n.value)}function Ze(n,e){return e?$(e)?n.__parseExpression(e):e:"div"}function et(n,e,t){const s=Object.keys(e||{}).reduce((r,o)=>{let a=e[o];return $(a)?a=t.__parseExpression(a):O(a)&&(a=t.__parseFunction(a)),r[o]=a,r},{});return s.ref=t.__ref(n,s.ref),s}function tt(n,e,t){const s=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],u=W(i.modifiers),c=u.find(d=>s.includes(d)),m="on"+l.upperFirst(a)+(c&&r[c]||""),f=t.__parseFunction(i.handler);return f&&(o[m]=n.withModifiers(f,u)),o},{})}function W(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function st(n,e,t,s,r){const{children:o}=e,a=nt(e,s),i=s.$slots?.[a.name];return i?i(t):o?l.isString(o)?n.createTextVNode(o):$(o)?n.createTextVNode(q(s.__parseExpression(o))):Array.isArray(o)?o.map(u=>I(u,s,n,r)):null:null}function nt(n,e){const{props:t}=n,s=t?.name||"default";return{name:$(s)?e.__parseExpression(s):s,params:[]}}function rt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function ot(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
|
9
9
|
${e.value.value} = v;
|
10
|
-
}`:"(v) => {}"},r=t.__parseFunction(n),o=W(e.modifiers),a=E(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?s.withModifiers(r,o):r}}function it(s,e,t,n,r){if(!e)return null;if(u.isString(e))return{default:()=>e};if(E(e))return{default:()=>q(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=at(e),a=i=>!i||!r?{}:r?.id&&Object.keys(i).length?{[`scope_${r.id}`]:i}:{};return Object.entries(o).reduce((i,[l,{nodes:c,params:h}])=>(i[l]=f=>{const d=h.length?u.pick(f??{},h):a(f);return c.map(v=>I(v,t.__clone(d),s,n))},i),{})}return null}function at(s){const e={default:{params:[],nodes:[]}};for(const t of s){const n=ct(t.slot),r=n.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(n.params)):e[r]={nodes:[t],params:n.params}}return e}function ct(s="default"){return u.isString(s)?{name:s,params:[]}:{params:[],...s}}function ut(s,e,t){const{value:n,iterator:r}=s,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(n)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}))):(console.warn("[vForRender]:",`${n?.value} is not a Arrary`),[])}function lt(s){return m.getCurrentScope()?(m.onScopeDispose(s),!0):!1}function Y(s){return typeof s=="function"?s():m.unref(s)}const we=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const dt=s=>s!=null,ft=()=>{};function pt(s){return m.getCurrentInstance()}function mt(...s){if(s.length!==1)return m.toRef(...s);const e=s[0];return typeof e=="function"?m.readonly(m.customRef(()=>({get:e,set:ft}))):m.ref(e)}function ht(s,e){pt()&&m.onBeforeUnmount(s,e)}const gt=we?window:void 0,vt=we?window.document:void 0;function yt(s){var e;const t=Y(s);return(e=t?.$el)!=null?e:t}function _t(){const s=m.ref(!1),e=m.getCurrentInstance();return e&&m.onMounted(()=>{s.value=!0},e),s}function St(s){const e=_t();return m.computed(()=>(e.value,!!s()))}function wt(s,e,t={}){const{window:n=gt,...r}=t;let o;const a=St(()=>n&&"MutationObserver"in n),i=()=>{o&&(o.disconnect(),o=void 0)},l=m.computed(()=>{const d=Y(s),v=(Array.isArray(d)?d:[d]).map(yt).filter(dt);return new Set(v)}),c=m.watch(()=>l.value,d=>{i(),a.value&&d.size&&(o=new MutationObserver(e),d.forEach(v=>o.observe(v,r)))},{immediate:!0,flush:"post"}),h=()=>o?.takeRecords(),f=()=>{c(),i()};return lt(f),{isSupported:a,stop:f,takeRecords:h}}function jt(s=null,e={}){var t,n,r;const{document:o=vt,restoreOnUnmount:a=f=>f}=e,i=(t=o?.title)!=null?t:"",l=mt((n=s??o?.title)!=null?n:null),c=s&&typeof s=="function";function h(f){if(!("titleTemplate"in e))return f;const d=e.titleTemplate||"%s";return typeof d=="function"?d(f):Y(d).replace(/%s/g,f)}return m.watch(l,(f,d)=>{f!==d&&o&&(o.title=h(typeof f=="string"?f:""))},{immediate:!0}),e.observe&&!e.titleTemplate&&o&&!c&&wt((r=o.head)==null?void 0:r.querySelector("title"),()=>{o&&o.title!==l.value&&(l.value=h(o.title))},{childList:!0}),ht(()=>{if(a){const f=a(i,l.value||"");f!=null&&o&&(o.title=f)}}),l}const ee=m.defineComponent({name:"VtjPageContainer",async setup(){const s=X(),e=te.useRoute(),t=e.params.id,n=t?s.getPage(t):s.getHomepage(),r=n?await s.getRenderComponent(n.id):null;return n&&jt(n.title||"VTJ"),{provider:s,component:r,file:n,query:e.query}},render(){return this.component?m.h(this.component,this.query):m.h("div","页面不存在")}}),Et=m.defineComponent({name:"VtjStartupContainer",render(){return m.h(Me.XStartup)}}),G=Symbol("Provider");var je=(s=>(s.Production="production",s.Development="development",s))(je||{});class Ee extends $.Base{constructor(e){super(),this.options=e;const{service:t,mode:n=j.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:h=null,materialPath:f="./",nodeEnv:d="development"}=e;this.mode=n,this.modules=c,this.service=t,this.router=h,this.materialPath=f,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i);const{access:v,request:p}=this.adapter;v&&v.connect({mode:n,router:h,request:p}),n!==j.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Be,jsonp:u.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};async load(e){const t=this.modules[`.vtj/projects/${e.id}.json`];if(this.project=t?await t():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:n=[],meta:r=[]}=this.project,o=window;o.CKEDITOR_VERSION=void 0,this.nodeEnv!=="production"?await this.loadAssets(o):await this.loadDependencies(o),this.apis=he(n,r,this.adapter),V(),this.project.config?.mock&&ge(n),this.initRouter(),this.triggerReady()}async loadDependencies(e){const t=Object.entries(this.dependencies);for(const[n,r]of t)e[n]||(e[n]=await r())}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:n,library:r,components:o,materialPath:a,nodeEnv:i}=this,{libraryExports:l,libraryMap:c,materials:h,materialExports:f,materialMapLibrary:d}=ie(t,a,i==="development");for(const p of l){const g=n[p],w=e[p];if(w)r[p]=w;else if(g)e[p]=r[p]=await g();else{const y=c[p]||[];for(const _ of y)H(_)&&await ce(p,u.url.append(_,{v:b})),k(_)&&await u.loadScript(u.url.append(_,{v:b}));r[p]=e[p]}}for(const p of h)await u.loadScript(u.url.append(p,{v:b}));const v=this.materials||{};for(const p of f){const g=e[d[p]],w=$.BUILT_IN_COMPONENTS[p];if(w)g&&w.forEach(y=>{o[y]=g[y]});else{const y=v[p]?(await v[p]()).default:e[p];y&&g&&(y.components||[]).forEach(_=>{o[_.name]=ae(_,g)})}}}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:ee}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?ee:Et}))}install(e){const t=e.config.globalProperties.installed||{};for(const[n,r]of Object.entries(this.library))!t[n]&&de(r)&&(e.use(r),t[n]=!0);this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),e.provide(G,this),e.config.globalProperties.installed=t,this.nodeEnv==="development"&&(e.config.errorHandler=(n,r,o)=>{const a=r?.$options.name,i=typeof n=="string"?n:n?.message||n?.msg||"未知错误",l=`[ ${a} ] ${i} ${o}`;console.error("[VTJ Error]:",{err:n,instance:r,info:o},n?.stack),A.ElNotification.error({title:"运行时错误:请在控制台查看详情",message:l})})}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(n=>n.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},n=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=n(r,a.children);if(i)return i}}};return n(e,t)||null}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):null}async getDsl(e){const t=this.modules[`.vtj/files/${e}.json`];return t?await t():this.service.getFile(e).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(n=>n.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:n,components:r,mode:o,apis:a}=this,i={mode:o,Vue:n.Vue,components:r,libs:n,apis:a,window,...t},l=T({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return x({...i,dsl:e,loader:l})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return u.logger.warn(`Can not find file: ${e}`),null;const n=`.vtj/vue/${e}.vue`,r=this.modules[n];if(r)return(await r())?.default;const o=await this.getDsl(t.id);return o?this.createDslRenderer(o).renderer:(u.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return m.defineAsyncComponent(async()=>{const n=await this.getDslByUrl(e);return n?(n.name=t||n.name,this.createDslRenderer(n).renderer):null})}definePluginComponent(e){return m.defineAsyncComponent(async()=>await K(e,window))}}function $t(s){const e=new Ee(s);return{provider:e,onReady:n=>e.ready(n)}}function X(s={}){const e=m.inject(G);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:n}=s;t&&n&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==n&&A.ElNotification.warning({title:r?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const Q=new u.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:s=>s.data?.code===0,showError:s=>{A.ElNotification.error({message:s||"未知错误"})}}}),Ct=(s="/__vtj__/api/:type.json")=>(e,t)=>Q.send({url:s,method:"post",params:{type:e},data:{type:e,data:t}}),Pt=(s="/__vtj__/api/uploader.json")=>async(e,t)=>await Q.send({url:s,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(n=>n&&n[0]?n[0]:null).catch(()=>null);class B{api;pluginCaches={};uploader;constructor(){this.api=Ct(),this.uploader=Pt()}async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return console.log("BaseService.saveMaterials",e,t),!1}async saveFile(e){return console.log("BaseService.saveFile",e),!1}async getFile(e){return console.log("BaseService.getFile",e),{}}async removeFile(e){return console.log("BaseService.removeFile",e),!1}async saveHistory(e){return console.log("BaseService.saveHistory",e),!1}async removeHistory(e){return console.log("BaseService.removeHistory",e),!1}async getHistory(e){return console.log("BaseService.getHistory",e),{}}async getHistoryItem(e,t){return console.log("BaseService.getHistoryItem",e,t),{}}async saveHistoryItem(e,t){return console.log("BaseService.saveHistoryItem",e,t),!1}async removeHistoryItem(e,t){return console.log("BaseService.removeHistoryItem",e,t),!1}async publish(e){return!!await this.api("publish",e).catch(()=>!1)}async publishFile(e,t){return!!await this.api("publishFile",{project:e,file:t}).catch(()=>!1)}async genVueContent(e,t){return await this.api("genVueContent",{project:e,dsl:t}).catch(()=>"")}async createRawPage(e){return await this.api("createRawPage",e).catch(()=>"")}async removeRawPage(e){return await this.api("removeRawPage",e).catch(()=>"")}async uploadStaticFile(e,t){return await this.uploader(e,t).catch(()=>null)}async getStaticFiles(e){return await this.api("getStaticFiles",e).catch(()=>[])}async removeStaticFile(e,t){return await this.api("removeStaticFile",{name:e,projectId:t}).catch(()=>"")}async clearStaticFiles(e){return await this.api("clearStaticFiles",e).catch(()=>"")}async getPluginMaterial(e){const{urls:t=[]}=e,n=t.filter(o=>re(o))[0];if(!n)return null;const r=this.pluginCaches[n];return r||(this.pluginCaches[n]=Q.send({url:n,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const S=new u.Storage({type:"local",expired:0,prefix:"__VTJ_"});class bt extends B{init(e){const t=new $.ProjectModel(e),n=S.get(`project_${t.id}`),r=Object.assign(t.toDsl(),n||{});return S.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new $.ProjectModel(e);return S.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return S.save(`materials_${e.id}`,u.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return S.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=S.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return S.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return S.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=S.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),S.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=S.get(`history_${e}`),n=new $.HistoryModel(t||{id:e});return Promise.resolve(n.toDsl())}getHistoryItem(e,t){const n=S.get(`history_${e}_${t}`);return Promise.resolve(n)}saveHistoryItem(e,t){return S.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{S.remove(`history_${e}_${n}`)}),Promise.resolve(!0)}}class $e extends B{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new $.ProjectModel(e),n=this.projects[t.id]||{},r=Object.assign(t.toDsl(),n);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new $.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=u.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],n=new $.HistoryModel(t||{id:e});return Promise.resolve(n)}getHistoryItem(e,t){const n=`${e}_${t}`,r=this.historyItems[n]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const n=`${e}_${t.id}`;return this.historyItems[n]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{const r=`${e}_${n}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let M=null;function Rt(){return M||(M=new $e,M)}class Ft extends B{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:u.mapToObject(t)}).catch(()=>!1)}async saveFile(e){return!!await this.api("saveFile",e).catch(()=>!1)}async getFile(e){const t=this.getFileCaches[e];return t||(this.getFileCaches[e]=this.api("getFile",e).catch(()=>null)).finally(()=>{delete this.getFileCaches[e]})}async removeFile(e){return!!await this.api("removeFile",e).catch(()=>!1)}async saveHistory(e){return!!await this.api("saveHistory",e).catch(()=>!1)}async removeHistory(e){return!!await this.api("removeHistory",e).catch(()=>!1)}async getHistory(e){return await this.api("getHistory",e).catch(()=>null)||{}}async getHistoryItem(e,t){return await this.api("getHistoryItem",{fId:e,id:t}).catch(()=>null)||{}}async saveHistoryItem(e,t){return!!await this.api("saveHistoryItem",{fId:e,item:t}).catch(()=>!1)}async removeHistoryItem(e,t){return!!await this.api("removeHistoryItem",{fId:e,ids:t}).catch(()=>!1)}}function Ce(s=[]){return s.map(e=>{const{id:t,title:n,icon:r,children:o,hidden:a}=e;return{id:t,title:n,icon:r,hidden:a,url:`/page/${t}`,children:o&&o.length?Ce(o):void 0}})}function At(){const s=X(),e=te.useRoute(),t=m.ref(!1),n=s.project;m.watchEffect(()=>{const{name:a,params:i,meta:l}=e;if(a==="VtjPage"){const c=s.getPage(i.id);t.value=!c?.mask}else if(a==="VtjHomepage"){const c=s.getHomepage();t.value=!c?.mask}else t.value=!l.mask});const r=Ce(n?.pages),o=n?.config;return{disabled:t,logo:o?.logo,themeSwitchable:o?.themeSwitchable,title:o?.title||n?.description||n?.name||"VTJ App",menus:r}}exports.ACCESS_KEY=z;exports.Access=Ne;exports.BUILT_IN_DIRECTIVES=ne;exports.BaseService=B;exports.CONTEXT_HOST=N;exports.Context=ye;exports.ContextMode=j;exports.DATA_TYPES=se;exports.JSCodeToString=ke;exports.LIFE_CYCLES_LIST=Te;exports.LocalService=Ft;exports.MemoryService=$e;exports.NodeEnv=je;exports.Provider=Ee;exports.StorageService=bt;exports.VTJ_RENDERER_VERSION=b;exports.adoptedStyleSheets=J;exports.createAssetScripts=De;exports.createAssetsCss=He;exports.createDataSources=_e;exports.createLoader=T;exports.createMemoryService=Rt;exports.createMetaApi=me;exports.createProvider=$t;exports.createRenderer=x;exports.createSchemaApi=pe;exports.createSchemaApis=he;exports.defaultLoader=Se;exports.fillBasePath=F;exports.getModifiers=W;exports.getPlugin=K;exports.getRawComponent=ae;exports.isCSSUrl=H;exports.isJSCode=fe;exports.isJSExpression=E;exports.isJSFunction=O;exports.isJSON=re;exports.isJSUrl=k;exports.isVuePlugin=de;exports.loadCss=ce;exports.loadCssUrl=ue;exports.loadScriptUrl=le;exports.mockApi=ve;exports.mockApis=ge;exports.mockCleanup=V;exports.nodeRender=I;exports.parseDeps=ie;exports.parseExpression=R;exports.parseFunction=L;exports.providerKey=G;exports.removeProdFlag=oe;exports.toString=q;exports.useAccess=Le;exports.useMask=At;exports.useProvider=X;
|
10
|
+
}`:"(v) => {}"},r=t.__parseFunction(s),o=W(e.modifiers),a=$(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?n.withModifiers(r,o):r}}function it(n,e,t,s,r){if(!e)return null;if(l.isString(e))return{default:()=>e};if($(e))return{default:()=>q(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=at(e),a=i=>!i||!r?{}:r?.id&&Object.keys(i).length?{[`scope_${r.id}`]:i}:{};return Object.entries(o).reduce((i,[u,{nodes:c,params:m}])=>(i[u]=f=>{const d=m.length?l.pick(f??{},m):a(f);return c.map(v=>I(v,t.__clone(d),n,s))},i),{})}return null}function at(n){const e={default:{params:[],nodes:[]}};for(const t of n){const s=ct(t.slot),r=s.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(s.params)):e[r]={nodes:[t],params:s.params}}return e}function ct(n="default"){return l.isString(n)?{name:n,params:[]}:{params:[],...n}}function lt(n,e,t){const{value:s,iterator:r}=n,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(s)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((u,c)=>c+1)),Array.isArray(i)?i.map((u,c)=>e(t.__clone({[o]:u,[a]:c}))):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}function ut(n){return h.getCurrentScope()?(h.onScopeDispose(n),!0):!1}function Y(n){return typeof n=="function"?n():h.unref(n)}const we=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const dt=n=>n!=null,ft=()=>{};function pt(n){return h.getCurrentInstance()}function ht(...n){if(n.length!==1)return h.toRef(...n);const e=n[0];return typeof e=="function"?h.readonly(h.customRef(()=>({get:e,set:ft}))):h.ref(e)}function mt(n,e){pt()&&h.onBeforeUnmount(n,e)}const gt=we?window:void 0,vt=we?window.document:void 0;function yt(n){var e;const t=Y(n);return(e=t?.$el)!=null?e:t}function _t(){const n=h.ref(!1),e=h.getCurrentInstance();return e&&h.onMounted(()=>{n.value=!0},e),n}function St(n){const e=_t();return h.computed(()=>(e.value,!!n()))}function wt(n,e,t={}){const{window:s=gt,...r}=t;let o;const a=St(()=>s&&"MutationObserver"in s),i=()=>{o&&(o.disconnect(),o=void 0)},u=h.computed(()=>{const d=Y(n),v=(Array.isArray(d)?d:[d]).map(yt).filter(dt);return new Set(v)}),c=h.watch(()=>u.value,d=>{i(),a.value&&d.size&&(o=new MutationObserver(e),d.forEach(v=>o.observe(v,r)))},{immediate:!0,flush:"post"}),m=()=>o?.takeRecords(),f=()=>{c(),i()};return ut(f),{isSupported:a,stop:f,takeRecords:m}}function jt(n=null,e={}){var t,s,r;const{document:o=vt,restoreOnUnmount:a=f=>f}=e,i=(t=o?.title)!=null?t:"",u=ht((s=n??o?.title)!=null?s:null),c=n&&typeof n=="function";function m(f){if(!("titleTemplate"in e))return f;const d=e.titleTemplate||"%s";return typeof d=="function"?d(f):Y(d).replace(/%s/g,f)}return h.watch(u,(f,d)=>{f!==d&&o&&(o.title=m(typeof f=="string"?f:""))},{immediate:!0}),e.observe&&!e.titleTemplate&&o&&!c&&wt((r=o.head)==null?void 0:r.querySelector("title"),()=>{o&&o.title!==u.value&&(u.value=m(o.title))},{childList:!0}),mt(()=>{if(a){const f=a(i,u.value||"");f!=null&&o&&(o.title=f)}}),u}const ee=h.defineComponent({name:"VtjPageContainer",async setup(){const n=X(),e=te.useRoute(),t=e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null;return s&&jt(s.title||"VTJ"),{provider:n,component:r,file:s,query:e.query}},render(){return this.component?h.h(this.component,this.query):h.h("div","页面不存在")}}),$t=h.defineComponent({name:"VtjStartupContainer",render(){return h.h(Me.XStartup)}}),G=Symbol("Provider");var je=(n=>(n.Production="production",n.Development="development",n))(je||{});class $e extends E.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=j.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:u={},modules:c={},router:m=null,materialPath:f="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=m,this.materialPath=f,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,u),Object.assign(this.adapter,i);const{access:v,request:p}=this.adapter;v&&v.connect({mode:s,router:m,request:p}),s!==j.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Ue,jsonp:l.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};async load(e){const t=this.modules[`.vtj/projects/${e.id}.json`];if(this.project=t?await t():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:s=[],meta:r=[]}=this.project,o=window;o.CKEDITOR_VERSION=void 0,this.nodeEnv!=="production"?await this.loadAssets(o):await this.loadDependencies(o),this.apis=me(s,r,this.adapter),V(),this.project.config?.mock&&ge(s),this.initRouter(),this.triggerReady()}async loadDependencies(e){const t=Object.entries(this.dependencies);for(const[s,r]of t)e[s]||(e[s]=await r())}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:s,library:r,components:o,materialPath:a,nodeEnv:i}=this,{libraryExports:u,libraryMap:c,materials:m,materialExports:f,materialMapLibrary:d}=ie(t,a,i==="development");for(const p of u){const g=s[p],w=e[p];if(w)r[p]=w;else if(g)e[p]=r[p]=await g();else{const y=c[p]||[];for(const _ of y)H(_)&&await ce(p,l.url.append(_,{v:b})),k(_)&&await l.loadScript(l.url.append(_,{v:b}));r[p]=e[p]}}for(const p of m)await l.loadScript(l.url.append(p,{v:b}));const v=this.materials||{};for(const p of f){const g=e[d[p]],w=E.BUILT_IN_COMPONENTS[p];if(w)g&&w.forEach(y=>{o[y]=g[y]});else{const y=v[p]?(await v[p]()).default:e[p];y&&g&&(y.components||[]).forEach(_=>{o[_.name]=ae(_,g)})}}}initRouter(){const{router:e,project:t}=this;e&&(e.addRoute({path:"/page/:id",name:"VtjPage",component:ee}),e.addRoute({path:"/",name:"VtjHomepage",component:t?.homepage?ee:$t}))}install(e){const t=e.config.globalProperties.installed||{};for(const[s,r]of Object.entries(this.library))!t[s]&&de(r)&&(e.use(r),t[s]=!0);this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),e.provide(G,this),e.config.globalProperties.installed=t,this.nodeEnv==="development"&&(e.config.errorHandler=(s,r,o)=>{const a=r?.$options.name,i=typeof s=="string"?s:s?.message||s?.msg||"未知错误",u=`[ ${a} ] ${i} ${o}`;console.error("[VTJ Error]:",{err:s,instance:r,info:o},s?.stack),A.ElNotification.error({title:"运行时错误:请在控制台查看详情",message:u})})}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=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=s(r,a.children);if(i)return i}}};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`];return t?await t():this.service.getFile(e).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:s,components:r,mode:o,apis:a}=this,i={mode:o,Vue:s.Vue,components:r,libs:s,apis:a,window,...t},u=T({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return x({...i,dsl:e,loader:u})}async getRenderComponent(e){const t=this.getFile(e);if(!t)return l.logger.warn(`Can not find file: ${e}`),null;const s=`.vtj/vue/${e}.vue`,r=this.modules[s];if(r)return(await r())?.default;const o=await this.getDsl(t.id);return o?this.createDslRenderer(o).renderer:(l.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return h.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return h.defineAsyncComponent(async()=>await K(e,window))}}function Et(n){const e=new $e(n);return{provider:e,onReady:s=>e.ready(s)}}function X(n={}){const e=h.inject(G);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=n;t&&s&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==s&&A.ElNotification.warning({title:r?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const Q=new l.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0,showError:n=>{A.ElNotification.error({message:n||"未知错误"})}}}),Ct=(n="/__vtj__/api/:type.json")=>(e,t)=>Q.send({url:n,method:"post",params:{type:e},data:{type:e,data:t}}),Pt=(n="/__vtj__/api/uploader.json")=>async(e,t)=>await Q.send({url:n,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(s=>s&&s[0]?s[0]:null).catch(()=>null);class U{api;pluginCaches={};uploader;constructor(){this.api=Ct(),this.uploader=Pt()}async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return console.log("BaseService.saveMaterials",e,t),!1}async saveFile(e){return console.log("BaseService.saveFile",e),!1}async getFile(e){return console.log("BaseService.getFile",e),{}}async removeFile(e){return console.log("BaseService.removeFile",e),!1}async saveHistory(e){return console.log("BaseService.saveHistory",e),!1}async removeHistory(e){return console.log("BaseService.removeHistory",e),!1}async getHistory(e){return console.log("BaseService.getHistory",e),{}}async getHistoryItem(e,t){return console.log("BaseService.getHistoryItem",e,t),{}}async saveHistoryItem(e,t){return console.log("BaseService.saveHistoryItem",e,t),!1}async removeHistoryItem(e,t){return console.log("BaseService.removeHistoryItem",e,t),!1}async publish(e){return!!await this.api("publish",e).catch(()=>!1)}async publishFile(e,t){return!!await this.api("publishFile",{project:e,file:t}).catch(()=>!1)}async genVueContent(e,t){return await this.api("genVueContent",{project:e,dsl:t}).catch(()=>"")}async createRawPage(e){return await this.api("createRawPage",e).catch(()=>"")}async removeRawPage(e){return await this.api("removeRawPage",e).catch(()=>"")}async uploadStaticFile(e,t){return await this.uploader(e,t).catch(()=>null)}async getStaticFiles(e){return await this.api("getStaticFiles",e).catch(()=>[])}async removeStaticFile(e,t){return await this.api("removeStaticFile",{name:e,projectId:t}).catch(()=>"")}async clearStaticFiles(e){return await this.api("clearStaticFiles",e).catch(()=>"")}async getPluginMaterial(e){const{urls:t=[]}=e,s=t.filter(o=>re(o))[0];if(!s)return null;const r=this.pluginCaches[s];return r||(this.pluginCaches[s]=Q.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const S=new l.Storage({type:"local",expired:0,prefix:"__VTJ_"});class bt extends U{init(e){const t=new E.ProjectModel(e),s=S.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return S.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new E.ProjectModel(e);return S.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return S.save(`materials_${e.id}`,l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return S.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=S.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return S.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return S.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=S.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),S.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=S.get(`history_${e}`),s=new E.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=S.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return S.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{S.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class Ee extends U{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new E.ProjectModel(e),s=this.projects[t.id]||{},r=Object.assign(t.toDsl(),s);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new E.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new E.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,r=this.historyItems[s]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const r=`${e}_${s}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let M=null;function Rt(){return M||(M=new Ee,M)}class Ft extends U{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:l.mapToObject(t)}).catch(()=>!1)}async saveFile(e){return!!await this.api("saveFile",e).catch(()=>!1)}async getFile(e){const t=this.getFileCaches[e];return t||(this.getFileCaches[e]=this.api("getFile",e).catch(()=>null)).finally(()=>{delete this.getFileCaches[e]})}async removeFile(e){return!!await this.api("removeFile",e).catch(()=>!1)}async saveHistory(e){return!!await this.api("saveHistory",e).catch(()=>!1)}async removeHistory(e){return!!await this.api("removeHistory",e).catch(()=>!1)}async getHistory(e){return await this.api("getHistory",e).catch(()=>null)||{}}async getHistoryItem(e,t){return await this.api("getHistoryItem",{fId:e,id:t}).catch(()=>null)||{}}async saveHistoryItem(e,t){return!!await this.api("saveHistoryItem",{fId:e,item:t}).catch(()=>!1)}async removeHistoryItem(e,t){return!!await this.api("removeHistoryItem",{fId:e,ids:t}).catch(()=>!1)}}function Ce(n=[]){return n.map(e=>{const{id:t,title:s,icon:r,children:o,hidden:a}=e;return{id:t,title:s,icon:r,hidden:a,url:`/page/${t}`,children:o&&o.length?Ce(o):void 0}})}function At(){const n=X(),e=te.useRoute(),t=h.ref(!1),s=n.project;h.watchEffect(()=>{const{name:a,params:i,meta:u}=e;if(a==="VtjPage"){const c=n.getPage(i.id);t.value=!c?.mask}else if(a==="VtjHomepage"){const c=n.getHomepage();t.value=!c?.mask}else t.value=!u.mask});const r=Ce(s?.pages),o=s?.config;return{disabled:t,logo:o?.logo,themeSwitchable:o?.themeSwitchable,title:o?.title||s?.description||s?.name||"VTJ App",menus:r}}exports.ACCESS_KEY=z;exports.Access=Ne;exports.BUILT_IN_DIRECTIVES=se;exports.BaseService=U;exports.CONTEXT_HOST=N;exports.Context=ye;exports.ContextMode=j;exports.DATA_TYPES=ne;exports.JSCodeToString=ke;exports.LIFE_CYCLES_LIST=Te;exports.LocalService=Ft;exports.MemoryService=Ee;exports.NodeEnv=je;exports.Provider=$e;exports.StorageService=bt;exports.VTJ_RENDERER_VERSION=b;exports.adoptedStyleSheets=J;exports.createAssetScripts=De;exports.createAssetsCss=He;exports.createDataSources=_e;exports.createLoader=T;exports.createMemoryService=Rt;exports.createMetaApi=he;exports.createProvider=Et;exports.createRenderer=x;exports.createSchemaApi=pe;exports.createSchemaApis=me;exports.defaultLoader=Se;exports.fillBasePath=F;exports.getModifiers=W;exports.getPlugin=K;exports.getRawComponent=ae;exports.isCSSUrl=H;exports.isJSCode=fe;exports.isJSExpression=$;exports.isJSFunction=O;exports.isJSON=re;exports.isJSUrl=k;exports.isVuePlugin=de;exports.loadCss=ce;exports.loadCssUrl=le;exports.loadScriptUrl=ue;exports.mockApi=ve;exports.mockApis=ge;exports.mockCleanup=V;exports.nodeRender=I;exports.parseDeps=ie;exports.parseExpression=R;exports.parseFunction=L;exports.providerKey=G;exports.removeProdFlag=oe;exports.toString=q;exports.useAccess=Le;exports.useMask=At;exports.useProvider=X;
|
package/dist/index.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Base as we, BUILT_IN_COMPONENTS as Se, ProjectModel as I, HistoryModel as se } from "@vtj/core";
|
2
|
-
import { isUrl as $e, url as b, dedupArray as je, isString as $, isFunction as
|
3
|
-
import * as
|
4
|
-
import { inject as re, toRef as De, readonly as Me, customRef as ke, ref as
|
2
|
+
import { isUrl as $e, url as b, dedupArray as je, isString as $, isFunction as Y, logger as A, createRequest as Ee, merge as Pe, pathToRegexp as be, pathToRegexpMatch as Ce, formDataToJson as Re, storage as k, cookie as T, toArray as Q, delay as Fe, camelCase as j, upperFirst as xe, pick as Ie, jsonp as Ae, loadScript as X, Request as He, Storage as Oe, mapToObject as q } from "@vtj/utils";
|
3
|
+
import * as O from "vue";
|
4
|
+
import { inject as re, toRef as De, readonly as Me, customRef as ke, ref as J, onBeforeUnmount as Te, getCurrentScope as Be, onScopeDispose as Ue, unref as Ne, getCurrentInstance as oe, watch as ie, computed as ae, onMounted as Le, defineComponent as ce, h as U, defineAsyncComponent as Z, watchEffect as qe } from "vue";
|
5
5
|
import { useRoute as ue } from "vue-router";
|
6
6
|
import { ElNotification as D, ElLoading as Je } from "element-plus";
|
7
7
|
import { XStartup as Ve } from "@vtj/ui";
|
@@ -9,10 +9,10 @@ import { XStartup as Ve } from "@vtj/ui";
|
|
9
9
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
10
10
|
* @name @vtj/renderer
|
11
11
|
* @author CHC chenhuachun1549@dingtalk.com
|
12
|
-
* @version 0.8.
|
12
|
+
* @version 0.8.165
|
13
13
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
14
14
|
*/
|
15
|
-
const C = "0.8.
|
15
|
+
const C = "0.8.165";
|
16
16
|
var w = /* @__PURE__ */ ((s) => (s.Runtime = "Runtime", s.Design = "Design", s.Raw = "Raw", s.VNode = "VNode", s))(w || {});
|
17
17
|
const ee = [
|
18
18
|
"$el",
|
@@ -40,7 +40,7 @@ const ee = [
|
|
40
40
|
"renderTriggered",
|
41
41
|
"activated",
|
42
42
|
"deactivated"
|
43
|
-
], ze = ["vIf", "vShow", "vModel", "vFor", "vBind"],
|
43
|
+
], ze = ["vIf", "vShow", "vModel", "vFor", "vBind"], Ke = {
|
44
44
|
String,
|
45
45
|
Number,
|
46
46
|
Boolean,
|
@@ -52,13 +52,13 @@ const ee = [
|
|
52
52
|
function F(s, e) {
|
53
53
|
return s.map((t) => $e(t) || t.startsWith("/") ? t : `${e}${t}`);
|
54
54
|
}
|
55
|
-
function
|
55
|
+
function V(s) {
|
56
56
|
return /\.css$/.test(s);
|
57
57
|
}
|
58
|
-
function
|
58
|
+
function z(s) {
|
59
59
|
return /\.js$/.test(s);
|
60
60
|
}
|
61
|
-
function
|
61
|
+
function We(s) {
|
62
62
|
return /\.json$/.test(s);
|
63
63
|
}
|
64
64
|
function an(s) {
|
@@ -79,7 +79,7 @@ function Ye(s, e, t = !1) {
|
|
79
79
|
return n.forEach(
|
80
80
|
({ urls: l, assetsUrl: m, library: d, assetsLibrary: h, localeLibrary: _ }) => {
|
81
81
|
l?.forEach((v) => {
|
82
|
-
|
82
|
+
z(v) && r.push(Ge(v, t)), V(v) && o.push(v);
|
83
83
|
}), d && (i.push(d), u[d] = F(l || [], e), _ && (c[d] = _)), m && a.push(m), h && p.push(h), d && h && (f[h] = d);
|
84
84
|
}
|
85
85
|
), {
|
@@ -142,7 +142,7 @@ async function et(s, e, t = window) {
|
|
142
142
|
});
|
143
143
|
}
|
144
144
|
function tt(s) {
|
145
|
-
return
|
145
|
+
return Y(s) || Y(s?.install);
|
146
146
|
}
|
147
147
|
function R(s, e, t = !1, n = !1) {
|
148
148
|
try {
|
@@ -154,13 +154,13 @@ function R(s, e, t = !1, n = !1) {
|
|
154
154
|
const a = `with(${t ? "{}" : "$scope || {}"}) { ${o} }`;
|
155
155
|
return new Function("$scope", a)(e);
|
156
156
|
} catch (r) {
|
157
|
-
if (
|
157
|
+
if (A.error("parseExpression.error", r, s, e?.__self ?? e), n)
|
158
158
|
throw r;
|
159
159
|
}
|
160
160
|
}
|
161
161
|
function te(s, e, t = !1, n = !1) {
|
162
162
|
const r = R(s, e, t, n);
|
163
|
-
if (typeof r != "function" && (
|
163
|
+
if (typeof r != "function" && (A.error(
|
164
164
|
"parseFunction.error",
|
165
165
|
"not a function",
|
166
166
|
s,
|
@@ -292,14 +292,17 @@ class ln {
|
|
292
292
|
this.data = e, k.save(t, e, {
|
293
293
|
type: "local",
|
294
294
|
prefix: n
|
295
|
-
}), r &&
|
295
|
+
}), r && T.set(o, e.token);
|
296
296
|
}
|
297
|
-
|
298
|
-
const { storageKey: e, storagePrefix: t } = this.options;
|
297
|
+
clear() {
|
298
|
+
const { storageKey: e, storagePrefix: t, session: n, authKey: r } = this.options;
|
299
299
|
this.data = null, k.remove(e, {
|
300
300
|
type: "local",
|
301
301
|
prefix: t
|
302
|
-
}),
|
302
|
+
}), n && T.remove(r);
|
303
|
+
}
|
304
|
+
logout() {
|
305
|
+
this.clear(), this.toLogin();
|
303
306
|
}
|
304
307
|
getData() {
|
305
308
|
return this.data;
|
@@ -317,11 +320,19 @@ class ln {
|
|
317
320
|
}
|
318
321
|
isAuthPath(e) {
|
319
322
|
const { auth: t, isAuth: n } = this.options;
|
320
|
-
|
323
|
+
if (n)
|
324
|
+
return n(e);
|
325
|
+
if (e.path && typeof t == "string") {
|
326
|
+
const r = t.split("#")[1] || t;
|
327
|
+
return e.path === r;
|
328
|
+
}
|
329
|
+
return !1;
|
321
330
|
}
|
322
331
|
toLogin() {
|
323
332
|
const { auth: e, redirectParam: t } = this.options;
|
324
|
-
|
333
|
+
if (!e) return;
|
334
|
+
const n = t ? `?${t}=${encodeURIComponent(location.href)}` : "";
|
335
|
+
typeof e == "function" ? e(n) : location.href = t ? `${e}${n}` : e;
|
325
336
|
}
|
326
337
|
loadData() {
|
327
338
|
const { storageKey: e, storagePrefix: t } = this.options;
|
@@ -332,7 +343,7 @@ class ln {
|
|
332
343
|
}
|
333
344
|
isLogined() {
|
334
345
|
const { session: e, authKey: t } = this.options;
|
335
|
-
return e && t ? !!
|
346
|
+
return e && t ? !!T.get(t) : !!this.data;
|
336
347
|
}
|
337
348
|
setGuard(e) {
|
338
349
|
e.beforeEach((t, n, r) => this.guard(t, r));
|
@@ -350,13 +361,16 @@ class ln {
|
|
350
361
|
const { unauthorizedCode: t = 401 } = this.options;
|
351
362
|
return e.status === t || e.data.code === t;
|
352
363
|
}
|
353
|
-
|
364
|
+
async showUnauthorizedAlert(e) {
|
354
365
|
const { alert: t, unauthorizedMessage: n = "登录已失效" } = this.options;
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
366
|
+
this.isUnauthorized(e) && t && (await t(n, { title: "提示", type: "warning" }).catch((r) => r), this.toLogin());
|
367
|
+
}
|
368
|
+
setRequest(e) {
|
369
|
+
e.useRequest((t) => (t.headers.Authorization = this.data?.token, t)), e.useResponse(
|
370
|
+
async (t) => (await this.showUnauthorizedAlert(t), t),
|
371
|
+
async (t) => {
|
372
|
+
const n = t.response || t || {};
|
373
|
+
return await this.showUnauthorizedAlert(n), Promise.reject(t);
|
360
374
|
}
|
361
375
|
);
|
362
376
|
}
|
@@ -394,7 +408,7 @@ class lt {
|
|
394
408
|
const { mode: t, dsl: n, attrs: r } = e;
|
395
409
|
this.__mode = t, n && (this.__id = n.id || null, this.__transform = n.transform || {}), r && Object.assign(this, r);
|
396
410
|
}
|
397
|
-
setup(e, t =
|
411
|
+
setup(e, t = O) {
|
398
412
|
const n = t.getCurrentInstance();
|
399
413
|
if (!n) return;
|
400
414
|
this.__refs = {}, this.$refs = {}, this.context = {}, this.__contextRefs = {}, this.__instance = n.proxy;
|
@@ -463,9 +477,9 @@ class lt {
|
|
463
477
|
return n.context.__proto__ = this.context, n.__proto__ = this, n;
|
464
478
|
}
|
465
479
|
}
|
466
|
-
function
|
480
|
+
function N(s) {
|
467
481
|
const {
|
468
|
-
Vue: e =
|
482
|
+
Vue: e = O,
|
469
483
|
mode: t = w.Runtime,
|
470
484
|
components: n = {},
|
471
485
|
libs: r = {},
|
@@ -508,7 +522,7 @@ function U(s) {
|
|
508
522
|
render() {
|
509
523
|
if (!i.value.nodes) return null;
|
510
524
|
const f = i.value.nodes || [];
|
511
|
-
return f.length === 1 ?
|
525
|
+
return f.length === 1 ? H(f[0], c, e, a) : f.map((l) => H(l, c, e, a));
|
512
526
|
},
|
513
527
|
..._t(i.value.lifeCycles ?? {}, c)
|
514
528
|
});
|
@@ -521,7 +535,7 @@ function ft(s = []) {
|
|
521
535
|
return s.map((e) => $(e) ? e : e.name);
|
522
536
|
}
|
523
537
|
function dt(s = [], e) {
|
524
|
-
const t = (n) => n ? (Array.isArray(n) ? n : [n]).map((o) =>
|
538
|
+
const t = (n) => n ? (Array.isArray(n) ? n : [n]).map((o) => Ke[o]) : void 0;
|
525
539
|
return s.map((n) => $(n) ? {
|
526
540
|
name: n
|
527
541
|
} : {
|
@@ -602,44 +616,44 @@ function _t(s, e) {
|
|
602
616
|
{}
|
603
617
|
);
|
604
618
|
}
|
605
|
-
let
|
619
|
+
let B = [];
|
606
620
|
const wt = (s) => s;
|
607
621
|
async function he(s, e = window) {
|
608
|
-
const { urls: t = [], library: n } = s, r = t.filter((i) =>
|
622
|
+
const { urls: t = [], library: n } = s, r = t.filter((i) => z(i));
|
609
623
|
if (r.length === 0 || !n) return null;
|
610
|
-
const o = t.filter((i) =>
|
624
|
+
const o = t.filter((i) => V(i));
|
611
625
|
return o.length && Ze(o, e), await et(r, n, e).catch(
|
612
626
|
(i) => (console.warn("loadScriptUrl error", r, n, i), null)
|
613
627
|
);
|
614
628
|
}
|
615
|
-
function
|
629
|
+
function L(s) {
|
616
630
|
const { getDsl: e, getDslByUrl: t, options: n } = s;
|
617
|
-
return n.window && (
|
631
|
+
return n.window && (B.forEach((r) => {
|
618
632
|
delete n.window[r];
|
619
|
-
}),
|
633
|
+
}), B = []), (r, o, a = O) => !o || typeof o == "string" ? r : o.type === "Schema" && o.id ? a.defineAsyncComponent(async () => {
|
620
634
|
const i = await e(o.id);
|
621
|
-
return i && (i.name = r), i ?
|
635
|
+
return i && (i.name = r), i ? N({
|
622
636
|
...n,
|
623
637
|
Vue: a,
|
624
638
|
dsl: i,
|
625
639
|
mode: w.Runtime,
|
626
|
-
loader:
|
640
|
+
loader: L(s)
|
627
641
|
}).renderer : null;
|
628
642
|
}) : o.type === "UrlSchema" && o.url ? a.defineAsyncComponent(async () => {
|
629
643
|
const i = await t(o.url);
|
630
|
-
return i && (i.name = r), i ?
|
644
|
+
return i && (i.name = r), i ? N({
|
631
645
|
...n,
|
632
646
|
Vue: a,
|
633
647
|
dsl: i,
|
634
648
|
mode: w.Runtime,
|
635
|
-
loader:
|
649
|
+
loader: L(s)
|
636
650
|
}).renderer : null;
|
637
|
-
}) : o.type === "Plugin" ? (o.library &&
|
651
|
+
}) : o.type === "Plugin" ? (o.library && B.push(o.library), a.defineAsyncComponent(async () => {
|
638
652
|
const i = await he(o, n.window);
|
639
653
|
return i || (console.warn("getPlugin result is null", o), null);
|
640
654
|
})) : r;
|
641
655
|
}
|
642
|
-
function
|
656
|
+
function H(s, e, t = O, n = wt) {
|
643
657
|
if (!s || !s.name || s.invisible) return null;
|
644
658
|
const { id: r = null, directives: o = [] } = s, { vIf: a, vFor: i, vShow: u, vModels: c, vBind: p } = St(o);
|
645
659
|
if (a && !$t(a, e))
|
@@ -669,7 +683,7 @@ function O(s, e, t = A, n = wt) {
|
|
669
683
|
);
|
670
684
|
return t.createVNode(d, { ...h, ..._ }, v);
|
671
685
|
};
|
672
|
-
return i ?
|
686
|
+
return i ? Ht(i, f, e) : f(e);
|
673
687
|
}
|
674
688
|
function St(s = []) {
|
675
689
|
const e = s.find((i) => j(i.name) === "vIf"), t = s.find((i) => j(i.name) === "vFor"), n = s.find((i) => j(i.name) === "vShow"), r = s.find((i) => j(i.name) === "vBind"), o = s.filter((i) => j(i.name) === "vModel"), a = s.filter(
|
@@ -723,7 +737,7 @@ function bt(s, e, t, n, r) {
|
|
723
737
|
return i ? i(t) : o ? $(o) ? s.createTextVNode(o) : S(o) ? s.createTextVNode(
|
724
738
|
le(n.__parseExpression(o))
|
725
739
|
) : Array.isArray(o) ? o.map(
|
726
|
-
(u) =>
|
740
|
+
(u) => H(u, n, s, r)
|
727
741
|
) : null : null;
|
728
742
|
}
|
729
743
|
function Ct(s, e) {
|
@@ -765,7 +779,7 @@ function xt(s, e, t, n, r) {
|
|
765
779
|
return Object.entries(o).reduce((i, [u, { nodes: c, params: p }]) => (i[u] = (f) => {
|
766
780
|
const l = p.length ? Ie(f ?? {}, p) : a(f);
|
767
781
|
return c.map(
|
768
|
-
(m) =>
|
782
|
+
(m) => H(m, t.__clone(l), s, n)
|
769
783
|
);
|
770
784
|
}, i), {});
|
771
785
|
}
|
@@ -779,7 +793,7 @@ function It(s) {
|
|
779
793
|
}
|
780
794
|
};
|
781
795
|
for (const t of s) {
|
782
|
-
const n =
|
796
|
+
const n = At(t.slot), r = n.name;
|
783
797
|
e[r] ? (e[r].nodes.push(t), e[r].params = e[r].params.concat(n.params)) : e[r] = {
|
784
798
|
nodes: [t],
|
785
799
|
params: n.params
|
@@ -787,18 +801,18 @@ function It(s) {
|
|
787
801
|
}
|
788
802
|
return e;
|
789
803
|
}
|
790
|
-
function
|
804
|
+
function At(s = "default") {
|
791
805
|
return $(s) ? { name: s, params: [] } : { params: [], ...s };
|
792
806
|
}
|
793
|
-
function
|
807
|
+
function Ht(s, e, t) {
|
794
808
|
const { value: n, iterator: r } = s, { item: o = "item", index: a = "index" } = r || {};
|
795
809
|
let i = t.__parseExpression(n) || [];
|
796
810
|
return Number.isInteger(i) && (i = new Array(i).fill(!0).map((u, c) => c + 1)), Array.isArray(i) ? i.map((u, c) => e(t.__clone({ [o]: u, [a]: c }))) : (console.warn("[vForRender]:", `${n?.value} is not a Arrary`), []);
|
797
811
|
}
|
798
|
-
function
|
812
|
+
function Ot(s) {
|
799
813
|
return Be() ? (Ue(s), !0) : !1;
|
800
814
|
}
|
801
|
-
function
|
815
|
+
function K(s) {
|
802
816
|
return typeof s == "function" ? s() : Ne(s);
|
803
817
|
}
|
804
818
|
const ve = typeof window < "u" && typeof document < "u";
|
@@ -812,7 +826,7 @@ function Tt(...s) {
|
|
812
826
|
if (s.length !== 1)
|
813
827
|
return De(...s);
|
814
828
|
const e = s[0];
|
815
|
-
return typeof e == "function" ? Me(ke(() => ({ get: e, set: Mt }))) :
|
829
|
+
return typeof e == "function" ? Me(ke(() => ({ get: e, set: Mt }))) : J(e);
|
816
830
|
}
|
817
831
|
function Bt(s, e) {
|
818
832
|
kt() && Te(s, e);
|
@@ -820,11 +834,11 @@ function Bt(s, e) {
|
|
820
834
|
const Ut = ve ? window : void 0, Nt = ve ? window.document : void 0;
|
821
835
|
function Lt(s) {
|
822
836
|
var e;
|
823
|
-
const t =
|
837
|
+
const t = K(s);
|
824
838
|
return (e = t?.$el) != null ? e : t;
|
825
839
|
}
|
826
840
|
function qt() {
|
827
|
-
const s =
|
841
|
+
const s = J(!1), e = oe();
|
828
842
|
return e && Le(() => {
|
829
843
|
s.value = !0;
|
830
844
|
}, e), s;
|
@@ -839,7 +853,7 @@ function Vt(s, e, t = {}) {
|
|
839
853
|
const a = Jt(() => n && "MutationObserver" in n), i = () => {
|
840
854
|
o && (o.disconnect(), o = void 0);
|
841
855
|
}, u = ae(() => {
|
842
|
-
const l =
|
856
|
+
const l = K(s), m = (Array.isArray(l) ? l : [l]).map(Lt).filter(Dt);
|
843
857
|
return new Set(m);
|
844
858
|
}), c = ie(
|
845
859
|
() => u.value,
|
@@ -850,7 +864,7 @@ function Vt(s, e, t = {}) {
|
|
850
864
|
), p = () => o?.takeRecords(), f = () => {
|
851
865
|
c(), i();
|
852
866
|
};
|
853
|
-
return
|
867
|
+
return Ot(f), {
|
854
868
|
isSupported: a,
|
855
869
|
stop: f,
|
856
870
|
takeRecords: p
|
@@ -866,7 +880,7 @@ function zt(s = null, e = {}) {
|
|
866
880
|
if (!("titleTemplate" in e))
|
867
881
|
return f;
|
868
882
|
const l = e.titleTemplate || "%s";
|
869
|
-
return typeof l == "function" ? l(f) :
|
883
|
+
return typeof l == "function" ? l(f) : K(l).replace(/%s/g, f);
|
870
884
|
}
|
871
885
|
return ie(
|
872
886
|
u,
|
@@ -899,15 +913,15 @@ const ne = ce({
|
|
899
913
|
};
|
900
914
|
},
|
901
915
|
render() {
|
902
|
-
return this.component ?
|
916
|
+
return this.component ? U(this.component, this.query) : U("div", "页面不存在");
|
903
917
|
}
|
904
|
-
}),
|
918
|
+
}), Kt = ce({
|
905
919
|
name: "VtjStartupContainer",
|
906
920
|
render() {
|
907
|
-
return
|
921
|
+
return U(Ve);
|
908
922
|
}
|
909
923
|
}), ge = Symbol("Provider");
|
910
|
-
var
|
924
|
+
var Wt = /* @__PURE__ */ ((s) => (s.Production = "production", s.Development = "development", s))(Wt || {});
|
911
925
|
class Gt extends we {
|
912
926
|
constructor(e) {
|
913
927
|
super(), this.options = e;
|
@@ -932,7 +946,7 @@ class Gt extends we {
|
|
932
946
|
mode;
|
933
947
|
globals = {};
|
934
948
|
modules = {};
|
935
|
-
adapter = { request: st, jsonp:
|
949
|
+
adapter = { request: st, jsonp: Ae };
|
936
950
|
apis = {};
|
937
951
|
dependencies = {};
|
938
952
|
materials = {};
|
@@ -978,7 +992,7 @@ class Gt extends we {
|
|
978
992
|
else {
|
979
993
|
const v = c[d] || [];
|
980
994
|
for (const g of v)
|
981
|
-
|
995
|
+
V(g) && await Xe(d, b.append(g, { v: C })), z(g) && await X(b.append(g, { v: C }));
|
982
996
|
r[d] = e[d];
|
983
997
|
}
|
984
998
|
}
|
@@ -1008,7 +1022,7 @@ class Gt extends we {
|
|
1008
1022
|
}), e.addRoute({
|
1009
1023
|
path: "/",
|
1010
1024
|
name: "VtjHomepage",
|
1011
|
-
component: t?.homepage ? ne :
|
1025
|
+
component: t?.homepage ? ne : Kt
|
1012
1026
|
}));
|
1013
1027
|
}
|
1014
1028
|
install(e) {
|
@@ -1077,12 +1091,12 @@ class Gt extends we {
|
|
1077
1091
|
apis: a,
|
1078
1092
|
window,
|
1079
1093
|
...t
|
1080
|
-
}, u =
|
1094
|
+
}, u = L({
|
1081
1095
|
getDsl: async (c) => await this.getDsl(c) || null,
|
1082
1096
|
getDslByUrl: async (c) => await this.getDslByUrl(c) || null,
|
1083
1097
|
options: i
|
1084
1098
|
});
|
1085
|
-
return
|
1099
|
+
return N({
|
1086
1100
|
...i,
|
1087
1101
|
dsl: e,
|
1088
1102
|
loader: u
|
@@ -1091,12 +1105,12 @@ class Gt extends we {
|
|
1091
1105
|
async getRenderComponent(e) {
|
1092
1106
|
const t = this.getFile(e);
|
1093
1107
|
if (!t)
|
1094
|
-
return
|
1108
|
+
return A.warn(`Can not find file: ${e}`), null;
|
1095
1109
|
const n = `.vtj/vue/${e}.vue`, r = this.modules[n];
|
1096
1110
|
if (r)
|
1097
1111
|
return (await r())?.default;
|
1098
1112
|
const o = await this.getDsl(t.id);
|
1099
|
-
return o ? this.createDslRenderer(o).renderer : (
|
1113
|
+
return o ? this.createDslRenderer(o).renderer : (A.warn(`Can not find dsl: ${e}`), null);
|
1100
1114
|
}
|
1101
1115
|
defineUrlSchemaComponent(e, t) {
|
1102
1116
|
return Z(async () => {
|
@@ -1131,7 +1145,7 @@ function ye(s = {}) {
|
|
1131
1145
|
}
|
1132
1146
|
return e;
|
1133
1147
|
}
|
1134
|
-
const W = new
|
1148
|
+
const W = new He({
|
1135
1149
|
settings: {
|
1136
1150
|
type: "json",
|
1137
1151
|
validSuccess: !0,
|
@@ -1163,7 +1177,7 @@ const W = new Oe({
|
|
1163
1177
|
type: "data"
|
1164
1178
|
}
|
1165
1179
|
}).then((n) => n && n[0] ? n[0] : null).catch(() => null);
|
1166
|
-
class
|
1180
|
+
class G {
|
1167
1181
|
api;
|
1168
1182
|
pluginCaches = {};
|
1169
1183
|
uploader;
|
@@ -1241,7 +1255,7 @@ class K {
|
|
1241
1255
|
return await this.api("clearStaticFiles", e).catch(() => "");
|
1242
1256
|
}
|
1243
1257
|
async getPluginMaterial(e) {
|
1244
|
-
const { urls: t = [] } = e, n = t.filter((o) =>
|
1258
|
+
const { urls: t = [] } = e, n = t.filter((o) => We(o))[0];
|
1245
1259
|
if (!n) return null;
|
1246
1260
|
const r = this.pluginCaches[n];
|
1247
1261
|
return r || (this.pluginCaches[n] = W.send({
|
@@ -1254,12 +1268,12 @@ class K {
|
|
1254
1268
|
}).then((o) => o.data).catch(() => null));
|
1255
1269
|
}
|
1256
1270
|
}
|
1257
|
-
const y = new
|
1271
|
+
const y = new Oe({
|
1258
1272
|
type: "local",
|
1259
1273
|
expired: 0,
|
1260
1274
|
prefix: "__VTJ_"
|
1261
1275
|
});
|
1262
|
-
class pn extends
|
1276
|
+
class pn extends G {
|
1263
1277
|
init(e) {
|
1264
1278
|
const t = new I(e), n = y.get(`project_${t.id}`), r = Object.assign(t.toDsl(), n || {});
|
1265
1279
|
return y.save(`project_${t.id}`, r), Promise.resolve(r);
|
@@ -1269,7 +1283,7 @@ class pn extends K {
|
|
1269
1283
|
return y.save(`project_${t.id}`, t.toDsl()), Promise.resolve(!0);
|
1270
1284
|
}
|
1271
1285
|
saveMaterials(e, t) {
|
1272
|
-
return y.save(`materials_${e.id}`,
|
1286
|
+
return y.save(`materials_${e.id}`, q(t)), Promise.resolve(!0);
|
1273
1287
|
}
|
1274
1288
|
saveFile(e) {
|
1275
1289
|
return y.save(`file_${e.id}`, e), Promise.resolve(!0);
|
@@ -1309,7 +1323,7 @@ class pn extends K {
|
|
1309
1323
|
}), Promise.resolve(!0);
|
1310
1324
|
}
|
1311
1325
|
}
|
1312
|
-
class Xt extends
|
1326
|
+
class Xt extends G {
|
1313
1327
|
projects = {};
|
1314
1328
|
materials = {};
|
1315
1329
|
files = {};
|
@@ -1324,7 +1338,7 @@ class Xt extends K {
|
|
1324
1338
|
return this.projects[t.id] = t.toDsl(), Promise.resolve(!0);
|
1325
1339
|
}
|
1326
1340
|
saveMaterials(e, t) {
|
1327
|
-
return e.id && (this.materials[e.id] =
|
1341
|
+
return e.id && (this.materials[e.id] = q(t)), Promise.resolve(!0);
|
1328
1342
|
}
|
1329
1343
|
saveFile(e) {
|
1330
1344
|
return this.files[e.id] = e, Promise.resolve(!0);
|
@@ -1370,7 +1384,7 @@ let x = null;
|
|
1370
1384
|
function hn() {
|
1371
1385
|
return x || (x = new Xt(), x);
|
1372
1386
|
}
|
1373
|
-
class mn extends
|
1387
|
+
class mn extends G {
|
1374
1388
|
getFileCaches = {};
|
1375
1389
|
async getExtension() {
|
1376
1390
|
return await this.api("getExtension", {}).catch(() => {
|
@@ -1385,7 +1399,7 @@ class mn extends K {
|
|
1385
1399
|
async saveMaterials(e, t) {
|
1386
1400
|
return !!await this.api("saveMaterials", {
|
1387
1401
|
project: e,
|
1388
|
-
materials:
|
1402
|
+
materials: q(t)
|
1389
1403
|
}).catch(() => !1);
|
1390
1404
|
}
|
1391
1405
|
async saveFile(e) {
|
@@ -1439,7 +1453,7 @@ function _e(s = []) {
|
|
1439
1453
|
});
|
1440
1454
|
}
|
1441
1455
|
function vn() {
|
1442
|
-
const s = ye(), e = ue(), t =
|
1456
|
+
const s = ye(), e = ue(), t = J(!1), n = s.project;
|
1443
1457
|
qe(() => {
|
1444
1458
|
const { name: a, params: i, meta: u } = e;
|
1445
1459
|
if (a === "VtjPage") {
|
@@ -1464,16 +1478,16 @@ export {
|
|
1464
1478
|
pe as ACCESS_KEY,
|
1465
1479
|
ln as Access,
|
1466
1480
|
ze as BUILT_IN_DIRECTIVES,
|
1467
|
-
|
1481
|
+
G as BaseService,
|
1468
1482
|
ee as CONTEXT_HOST,
|
1469
1483
|
lt as Context,
|
1470
1484
|
w as ContextMode,
|
1471
|
-
|
1485
|
+
Ke as DATA_TYPES,
|
1472
1486
|
un as JSCodeToString,
|
1473
1487
|
on as LIFE_CYCLES_LIST,
|
1474
1488
|
mn as LocalService,
|
1475
1489
|
Xt as MemoryService,
|
1476
|
-
|
1490
|
+
Wt as NodeEnv,
|
1477
1491
|
Gt as Provider,
|
1478
1492
|
pn as StorageService,
|
1479
1493
|
C as VTJ_RENDERER_VERSION,
|
@@ -1481,11 +1495,11 @@ export {
|
|
1481
1495
|
an as createAssetScripts,
|
1482
1496
|
cn as createAssetsCss,
|
1483
1497
|
gt as createDataSources,
|
1484
|
-
|
1498
|
+
L as createLoader,
|
1485
1499
|
hn as createMemoryService,
|
1486
1500
|
ot as createMetaApi,
|
1487
1501
|
dn as createProvider,
|
1488
|
-
|
1502
|
+
N as createRenderer,
|
1489
1503
|
rt as createSchemaApi,
|
1490
1504
|
it as createSchemaApis,
|
1491
1505
|
wt as defaultLoader,
|
@@ -1493,12 +1507,12 @@ export {
|
|
1493
1507
|
me as getModifiers,
|
1494
1508
|
he as getPlugin,
|
1495
1509
|
Qe as getRawComponent,
|
1496
|
-
|
1510
|
+
V as isCSSUrl,
|
1497
1511
|
nt as isJSCode,
|
1498
1512
|
S as isJSExpression,
|
1499
1513
|
M as isJSFunction,
|
1500
|
-
|
1501
|
-
|
1514
|
+
We as isJSON,
|
1515
|
+
z as isJSUrl,
|
1502
1516
|
tt as isVuePlugin,
|
1503
1517
|
Xe as loadCss,
|
1504
1518
|
Ze as loadCssUrl,
|
@@ -1506,7 +1520,7 @@ export {
|
|
1506
1520
|
ct as mockApi,
|
1507
1521
|
at as mockApis,
|
1508
1522
|
de as mockCleanup,
|
1509
|
-
|
1523
|
+
H as nodeRender,
|
1510
1524
|
Ye as parseDeps,
|
1511
1525
|
R as parseExpression,
|
1512
1526
|
te as parseFunction,
|
package/package.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vtj/renderer",
|
3
3
|
"private": false,
|
4
|
-
"version": "0.8.
|
4
|
+
"version": "0.8.165",
|
5
5
|
"type": "module",
|
6
6
|
"dependencies": {
|
7
7
|
"mockjs": "~1.1.0",
|
8
|
-
"@vtj/
|
9
|
-
"@vtj/
|
10
|
-
"@vtj/
|
11
|
-
"@vtj/
|
8
|
+
"@vtj/core": "~0.8.165",
|
9
|
+
"@vtj/icons": "~0.8.165",
|
10
|
+
"@vtj/ui": "~0.8.165",
|
11
|
+
"@vtj/utils": "~0.8.165"
|
12
12
|
},
|
13
13
|
"devDependencies": {
|
14
14
|
"vue": "~3.5.5",
|
@@ -28,9 +28,9 @@ export interface AccessOptions {
|
|
28
28
|
*/
|
29
29
|
unauthorized?: string | (() => void);
|
30
30
|
/**
|
31
|
-
*
|
31
|
+
* 授权登录页面 pathname
|
32
32
|
*/
|
33
|
-
auth?: string | (() => void);
|
33
|
+
auth?: string | ((search: string) => void);
|
34
34
|
/**
|
35
35
|
* 判断是否登录页面
|
36
36
|
* @param path
|
@@ -50,7 +50,7 @@ export interface AccessOptions {
|
|
50
50
|
* @param message
|
51
51
|
* @returns
|
52
52
|
*/
|
53
|
-
alert?: (message: string) =>
|
53
|
+
alert?: (message: string, options: Record<string, any>) => Promise<any>;
|
54
54
|
unauthorizedMessage?: string;
|
55
55
|
}
|
56
56
|
export interface AccessData {
|
@@ -79,6 +79,7 @@ export declare class Access {
|
|
79
79
|
constructor(options: Partial<AccessOptions>);
|
80
80
|
connect(params: AccessConnectParams): void;
|
81
81
|
login(data: AccessData): void;
|
82
|
+
clear(): void;
|
82
83
|
logout(): void;
|
83
84
|
getData(): AccessData | null;
|
84
85
|
can(code: string | string[]): boolean;
|
@@ -92,6 +93,7 @@ export declare class Access {
|
|
92
93
|
private guard;
|
93
94
|
private isWhiteList;
|
94
95
|
private isUnauthorized;
|
96
|
+
private showUnauthorizedAlert;
|
95
97
|
private setRequest;
|
96
98
|
}
|
97
99
|
export declare function useAccess(): Access;
|