@vtj/core 0.9.0-alpha.9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,6 +2,6 @@
2
2
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/core
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.9.0-alpha.9
5
+ * @version 0.9.0
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const b="0.9.0-alpha.9",J="BuiltIn",R="VueMaterial",B="VueRouterMaterial",w=[R,B],G={vue:"Vue","vue-router":"VueRouter"},U={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[B]:["RouterView","RouterLink"]},F=["slot","template","component","img","div","p","h1","h2","h3","span","a"];class M{}class j{listeners=[];isReady=!1;triggerReady(){this.isReady=!0;for(const e of this.listeners)e();this.listeners=[]}ready(e){this.isReady?e():this.listeners.push(e)}resetReady(){this.isReady=!1}}class v{constructor(e,t,i){this.name=e,this.value=t,this.defaultValue=i,this.setValue(t)}isUnset=!1;setValue(e){this.value=e,this.isUnset=this.value===this.defaultValue}getValue(){return this.value??this.defaultValue}static toDsl(e={}){return Object.entries(e).reduce((t,[i,s])=>(s.isUnset||(t[i]=s.getValue()),t),{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(i,s),t),{})}}class A{constructor(e){this.schema=e;const{name:t,handler:i}=this.schema;this.name=t,this.handler=i,this.update(e)}name;handler;modifiers={};update(e){Object.assign(this.schema,e);const{handler:t,modifiers:i={}}=this.schema;this.handler=t,this.modifiers=i}static toDsl(e){return Object.entries(e).reduce((t,[i,s])=>{const{handler:r,modifiers:a}=s;return t[i]={name:i,handler:r,modifiers:a},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new A(s),t),{})}}class _{constructor(e){this.schema=e,this.id=e.id||o.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value:r,iterator:a}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=r,this.iterator=a}static parse(e=[]){return e.map(t=>new _(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:a,iterator:l,id:h}=t;return{id:h,name:i,arg:s,modifiers:r,value:a,iterator:l}})}}const c="EVENT_NODE_CHANGE";class E{constructor(e,t=null){this.parent=t;const{id:i=o.uid(),name:s,from:r=""}=e;this.id=i,this.name=s,this.from=r,this.update(e,!0),E.nodes[this.id]=this}__VTJ_NODE__=!0;locked=!1;static nodes={};id;name;from;invisible=!1;children="";slot;props={};events={};directives=[];disposed=!1;update(e,t=!1){const{invisible:i=!1,locked:s=!1,children:r=[],slot:a,props:l={},events:h={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(a,!0),this.props=v.parse(l),this.events=A.parse(h),this.directives=_.parse(p),t||n.emit(c,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new E(i,this)):this.children=e,t||n.emit(c,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(c,this)}setProp(e,t,i,s=!1){const r=this.props[e];r?r.setValue(t):this.props[e]=new v(e,t,i),s||n.emit(c,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(c,this)}getPropValue(e){const t=this.props[e];if(t)return t.getValue()}setEvent(e,t=!1){const i=this.events[e.name];i?i.update(e):this.events[e.name]=new A(e),t||n.emit(c,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(c,this)}setDirective(e,t=!1){const i=this.directives.findIndex(s=>s.id===e.id);i>=0?this.directives.splice(i,1,new _(e)):this.directives.push(new _(e)),t||n.emit(c,this)}removeDirective(e,t=!1){const i=this.directives.findIndex(s=>s===e||s.id===e.id);i>=0&&this.directives.splice(i,1),t||n.emit(c,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const r=i.findIndex(a=>a===e);e.parent=null,i.splice(r,1),t||n.emit(c,this)}appendChild(e,t=!1){const{children:i,disposed:s}=this;s||(e.parent=this,Array.isArray(i)?i.push(e):this.children=[e],t||n.emit(c,this))}insertAfter(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s+1,0,e),t||n.emit(c,this.parent)}}insertBefore(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s,0,e),t||n.emit(c,this.parent)}}movePrev(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>0&&(i.splice(s,1),i.splice(s-1,0,this),e||n.emit(c,t))}}moveNext(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,this),e||n.emit(c,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:l,props:h,directives:p,events:I}=this,T=Array.isArray(l)?l.map(L=>L.toDsl()):l;return{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:T,props:v.toDsl(h),directives:_.toDsl(p),events:A.toDsl(I)}}dispose(e=!1){const{children:t,disposed:i}=this;i||(Array.isArray(t)&&t.forEach(s=>s.dispose(!0)),this.parent?this.parent.removeChild(this,e):e||n.emit(c,this),this.parent=null,this.disposed=!0,delete E.nodes[this.id])}lock(e=!1){if(this.locked=!0,Array.isArray(this.children))for(const t of this.children)t.lock(!0);e||n.emit(c,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(c,this)}setVisible(e,t=!1){if(this.invisible=!e,Array.isArray(this.children))for(const i of this.children)i.setVisible(e,!0);t||n.emit(c,this)}isChild(e){let t=!1;if(Array.isArray(this.children)){for(const i of this.children)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break}return t}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||o.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const r=e[s];r&&(this[s]=r)}const{nodes:i=[]}=e;i.length&&(this.nodes=i.map(s=>new E(s))),t||n.emit(d,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((a,l)=>(a[l]=this[l],a),{}),__VTJ_BLOCK__:t,__VERSION__:e||o.timestamp().toString(),id:i,nodes:s.map(a=>a.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}setFunction(e,t,i,s=!1){this[e][t]=i,s||n.emit(d,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(d,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(d,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(d,this)}setCss(e,t=!1){this.css=e,t||n.emit(d,this)}setWatch(e,t=!1){e.id=e.id||o.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(d,this)}removeWatch(e,t=!1){const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1&&(this.watch.splice(i,1),t||n.emit(d,this))}setProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1?this.props.splice(i,1,e):this.props.push(e),t||n.emit(d,this)}removeProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1&&(this.props.splice(i,1),t||n.emit(d,this))}setEmit(e,t=!1){const i=o.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(r=>r===i.name||r===i);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(d,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>o.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(d,this))}setSlot(e,t=!1){const i=o.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(r=>r===i.name||r===i);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(d,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>o.isString(s)?s===e:s.name===e);i>-1&&(this.slots.splice(i,1),t||n.emit(d,this))}setInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1?this.inject.splice(i,1,e):this.inject.push(e),t||n.emit(d,this)}removeInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1&&(this.inject.splice(i,1),t||n.emit(d,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(d,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(d,this)}insertAfter(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s+1,0,e),i||n.emit(d,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(d,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(d,this)}addNode(e,t,i="inner",s=!1){t?["left","top"].includes(i)?t.parent?t.insertAfter(e,s):this.insertBefore(e,t,s):["right","bottom"].includes(i)?t.parent?t.insertAfter(e,s):this.insertAfter(e,t,s):t.appendChild(e,s):this.appendNode(e,s)}__removeNode(e,t=!1){const i=this.nodes.findIndex(s=>s.id===e.id);i>-1&&(this.nodes.splice(i,1),t||n.emit(d,this))}removeNode(e,t=!1){e.parent?e.dispose(t):(e.dispose(!0),this.__removeNode(e,t))}move(e,t,i="inner",s=!1){e.parent?e.parent.removeChild(e,!0):this.__removeNode(e,!0),this.addNode(e,t,i,s)}movePrev(e,t=!1){if(e.parent)e.movePrev(t);else{const i=this.nodes,s=i.indexOf(e);s>0&&(i.splice(s,1),i.splice(s-1,0,e),t||n.emit(d,this))}}moveNext(e,t=!1){if(e.parent)e.moveNext(t);else{const i=this.nodes,s=i.indexOf(e);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,e),t||n.emit(d,this))}}cloneNode(e,t=!1){const i=D(e.toDsl()),s=new E(i);return this.addNode(s,e,"bottom",t),s}lock(e=!1){this.locked=!0;for(const t of this.nodes)t.lock(!0);e||n.emit(d,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(d,this)}isChild(e){let t=!1;for(const i of this.nodes)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break;return t}}const f="EVENT_PROJECT_CHANGE",O="EVENT_PROJECT_ACTIVED",g="EVENT_PROJECT_DEPS_CHANGE",y="EVENT_PROJECT_PAGES_CHANGE",N="EVENT_PROJECT_BLOCKS_CHANGE",V="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",H="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH";class P{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};__BASE_PATH__="/";static attrs=["name","homepage","description","dependencies","pages","blocks","apis","meta","config","__BASE_PATH__"];constructor(e){const{id:t}=e;this.id=t||o.uid(),this.update(e,!0)}update(e,t=!1){for(const i of P.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(f,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}cleanPagesDsl(e){for(const t of e)delete t.dsl,t.children&&t.children.length&&this.cleanPagesDsl(t.children)}toDsl(e){const{id:t}=this,i=P.attrs.reduce((s,r)=>(s[r]=this[r],s),{});return i.pages&&(i.pages=i.pages.map(s=>(delete s.dsl,s)),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>(delete s.dsl,s))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(O,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(O,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(a=>a.package===e.package);let r;if(s>-1?(r="update",i.splice(s,1,{...i[s],...e})):(r="create",i.push(e)),!t){const a={model:this,type:r,data:e};n.emit(g,a),n.emit(f,a)}}removeDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(r=>r.package===e.package);if(s>-1&&i.splice(s,1),!t){const r={model:this,type:"delete",data:e};n.emit(g,r),n.emit(f,r)}}getPage(e){const t=(i,s=[])=>{for(const r of s){if(r.id===i)return r;if(r.children&&r.children.length){const a=t(i,r.children);if(a)return a}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir?s.children&&s.children.length&&(i=i.concat(e(s.children))):i.push(s);return i};return e(this.pages)}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||o.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:o.upperFirstCamelCase(e.name)}).toDsl(),t){const s=this.getPage(t);s?s.children?s.children.push(e):s.children=[e]:console.warn(`not found PageFile for id: ${t} `)}else this.pages.push(e);if(!i){const s={model:this,type:"create",data:e};n.emit(y,s),n.emit(f,s)}!this.currentFile&&!e.dir&&(await o.delay(1e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(i?Object.assign(i,e):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(y,s),n.emit(f,s)}}clonePage(e,t,i=!1){const s=o.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,l=new u({id:s,name:r}).toDsl(),h=o.merge({},e,{id:s,name:r,title:a,dsl:l}),p=t?this.getPage(t)?.children||[]:this.pages,I=p.findIndex(T=>T.id===e.id);if(p.splice(I+1,0,h),!i){const T={model:this,type:"clone",data:{source:e,target:h}};n.emit(y,T),n.emit(f,T)}}async saveToBlock(e,t=!1){this.active(e,t),await o.delay(1e3);const i=o.uid(),s=e.name,r=e.title,a=new u({id:i,name:s}).toDsl(),l=o.merge({},e,{id:i,name:s,title:r,dsl:a,type:"block",fromType:"Schema"});if(this.blocks.push(l),!t){const h={model:this,type:"create",data:l};n.emit(N,h),n.emit(f,h)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,a)=>{const l=a.findIndex(h=>h.id===r);if(l>=0){a.splice(l,1);return}for(const h of a)h.children&&h.children.length&&s(r,h.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const r={model:this,type:"delete",data:i};n.emit(y,r),n.emit(f,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}async createBlock(e,t=!1){const i=e.id||o.uid(),s=o.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const r=e.fromType||"Schema";if(!t){const a={model:this,type:"create",data:e};n.emit(N,a),n.emit(f,a)}!this.currentFile&&r==="Schema"&&(await o.delay(1e3),this.active(e,t))}updateBlock(e,t=!1){const i=this.getBlock(e.id);if(i?(Object.assign(i,e),i.dsl&&(i.dsl.name=e.name)):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(N,s),n.emit(f,s)}}cloneBlock(e,t=!1){const i=o.uid(),s=`${e.name}Copy`,r=`${e.title}_副本`,a=new u({id:i,name:s}).toDsl(),l=o.merge({},e,{id:i,name:s,title:r,dsl:a}),h=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(h+1,0,l),!t){const p={model:this,type:"clone",data:{source:e,target:l}};n.emit(N,p),n.emit(f,p)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,r=s.findIndex(a=>a.id===e);if(r>-1?(s.splice(r,1),this.currentFile?.id===e&&this.deactivate(t)):console.warn(`not found PageFile for id: ${e} `),!t){const a={model:this,type:"delete",data:i};n.emit(N,a),n.emit(f,a)}}existBlockName(e,t=[]){return this.blocks.some(i=>i.name===e&&!t.includes(i.id))}existPageName(e,t=[]){return this.getPages().some(s=>s.name===e&&!t.includes(s.id))}setApi(e,t=!1){const i=this.apis.find(r=>r.name===e.name||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=o.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(V,r),n.emit(f,r)}}removeApi(e,t=!1){const i=this.apis.findIndex(s=>s.name===e||s.id===e);if(i>-1?this.apis.splice(i,1):console.warn(`not found Api for name: ${e} `),!t){const s={model:this,type:"delete",data:e};n.emit(V,s),n.emit(f,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setMeta(e,t=!1){const i=this.meta.find(r=>r.code===e.code||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=o.uid(),this.meta.push(e)),!t){const r={model:this,type:s,data:e};n.emit(S,r),n.emit(f,r)}}removeMeta(e,t=!1){const i=this.meta.findIndex(s=>s.code===e||s.id===e);if(i>-1?this.meta.splice(i,1):console.warn(`not found meta for name: ${name} `),!t){const s={model:this,type:"delete",data:e};n.emit(S,s),n.emit(f,s)}}existMetaCode(e,t=[]){return this.meta.some(i=>i.code===e&&!t.includes(i.id))}setHomepage(e,t=!1){if(this.homepage=e,!t){const i={model:this,type:"update",data:e};n.emit(f,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(f,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(H,t)}}const C="EVENT_HISTORY_CHANGE",x="EVENT_HISTORY_LOAD";class ${options={max:50};index=-1;id;items;constructor(e,t={}){Object.assign(this.options,t);const{id:i,items:s=[]}=e;this.id=i,this.items=s}toDsl(){const{id:e,items:t}=this;return{id:e,items:t.map(i=>({id:i.id,label:i.label}))}}get(e){return this.items.find(t=>t.id===e)}add(e,t=!1){const{max:i}=this.options,s={id:o.uid(),label:new Date().toLocaleString(),dsl:o.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const r=this.items.splice(i);t||n.emit(C,{model:this,type:"delete",data:r.map(a=>a.id)})}this.index=-1,t||n.emit(C,{model:this,type:"create",data:s})}remove(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>-1?(this.items.splice(i,1),i===this.index?this.index=-1:this.index>=this.items.length&&(this.index=this.items.length-1)):console.warn(`not found HistoryItem for id: ${e} `),t||n.emit(C,{model:this,type:"delete",data:[e]})}forward(e=!1){const{index:t,items:i}=this;if(t<0)return;--this.index;const s=i[this.index];s&&!e&&n.emit(x,{model:this,type:"load",data:s})}backward(e=!1){const{index:t,items:i}=this;if(t>=i.length-1)return;t<0&&(this.index=0),++this.index;const s=i[this.index];s&&!e&&n.emit(x,{model:this,type:"load",data:s})}load(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>=0&&(this.index=i,t||n.emit(x,{model:this,type:"load",data:this.items[i]}))}clear(e=!1){this.index=-1;const t=this.items.map(i=>i.id);this.items=[],e||n.emit(C,{model:this,type:"clear",data:t})}}const n=o.mitt();function K(m){return m instanceof u}function Y(m){return m instanceof E}function W(m){return!!m.__VTJ_BLOCK__}function D(m){const e=o.cloneDeep(m);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>D(t))),e}function q(m){const e=m.fromType||"Schema";return e==="Schema"?{type:"Schema",id:m.id}:e==="UrlSchema"?{type:"UrlSchema",url:(m.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(m.urls||"").split(","),library:m.library}:""}exports.BUILT_IN_COMPONENTS=U;exports.BUILT_IN_LIBRARAY_MAP=G;exports.BUILT_IN_MATERIALS=w;exports.BUILT_IN_NAME=J;exports.BUILT_IN_TAGS=F;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=B;exports.Base=j;exports.BlockModel=u;exports.DirectiveModel=_;exports.EVENT_BLOCK_CHANGE=d;exports.EVENT_HISTORY_CHANGE=C;exports.EVENT_HISTORY_LOAD=x;exports.EVENT_NODE_CHANGE=c;exports.EVENT_PROJECT_ACTIVED=O;exports.EVENT_PROJECT_APIS_CHANGE=V;exports.EVENT_PROJECT_BLOCKS_CHANGE=N;exports.EVENT_PROJECT_CHANGE=f;exports.EVENT_PROJECT_DEPS_CHANGE=g;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=y;exports.EVENT_PROJECT_PUBLISH=H;exports.EventModel=A;exports.HistoryModel=$;exports.NodeModel=E;exports.ProjectModel=P;exports.PropModel=v;exports.Service=M;exports.VTJ_CORE_VERSION=b;exports.cloneDsl=D;exports.createNodeFrom=q;exports.emitter=n;exports.isBlock=K;exports.isBlockSchema=W;exports.isNode=Y;
7
+ */const J="0.9.0",G="BuiltIn",R="VueMaterial",B="VueRouterMaterial",U=[R,B],w={vue:"Vue","vue-router":"VueRouter"},F={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[B]:["RouterView","RouterLink"]},M=["slot","template","component","img","div","p","h1","h2","h3","span","a"];class j{}class ${listeners=[];isReady=!1;triggerReady(){this.isReady=!0;for(const e of this.listeners)e();this.listeners=[]}ready(e){this.isReady?e():this.listeners.push(e)}resetReady(){this.isReady=!1}}class v{constructor(e,t,i){this.name=e,this.value=t,this.defaultValue=i,this.setValue(t)}isUnset=!1;setValue(e){this.value=e,this.isUnset=this.value===this.defaultValue}getValue(){return this.value??this.defaultValue}static toDsl(e={}){return Object.entries(e).reduce((t,[i,s])=>(s.isUnset||(t[i]=s.getValue()),t),{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(i,s),t),{})}}class A{constructor(e){this.schema=e;const{name:t,handler:i}=this.schema;this.name=t,this.handler=i,this.update(e)}name;handler;modifiers={};update(e){Object.assign(this.schema,e);const{handler:t,modifiers:i={}}=this.schema;this.handler=t,this.modifiers=i}static toDsl(e){return Object.entries(e).reduce((t,[i,s])=>{const{handler:r,modifiers:a}=s;return t[i]={name:i,handler:r,modifiers:a},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new A(s),t),{})}}class _{constructor(e){this.schema=e,this.id=e.id||o.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value:r,iterator:a}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=r,this.iterator=a}static parse(e=[]){return e.map(t=>new _(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:a,iterator:l,id:h}=t;return{id:h,name:i,arg:s,modifiers:r,value:a,iterator:l}})}}const c="EVENT_NODE_CHANGE";class E{constructor(e,t=null){this.parent=t;const{id:i=o.uid(),name:s,from:r=""}=e;this.id=i,this.name=s,this.from=r,this.update(e,!0),E.nodes[this.id]=this}__VTJ_NODE__=!0;locked=!1;static nodes={};id;name;from;invisible=!1;children="";slot;props={};events={};directives=[];disposed=!1;update(e,t=!1){const{invisible:i=!1,locked:s=!1,children:r=[],slot:a,props:l={},events:h={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(a,!0),this.props=v.parse(l),this.events=A.parse(h),this.directives=_.parse(p),t||n.emit(c,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new E(i,this)):this.children=e,t||n.emit(c,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(c,this)}setProp(e,t,i,s=!1){const r=this.props[e];r?r.setValue(t):this.props[e]=new v(e,t,i),s||n.emit(c,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(c,this)}getPropValue(e){const t=this.props[e];if(t)return t.getValue()}setEvent(e,t=!1){const i=this.events[e.name];i?i.update(e):this.events[e.name]=new A(e),t||n.emit(c,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(c,this)}setDirective(e,t=!1){const i=this.directives.findIndex(s=>s.id===e.id);i>=0?this.directives.splice(i,1,new _(e)):this.directives.push(new _(e)),t||n.emit(c,this)}removeDirective(e,t=!1){const i=this.directives.findIndex(s=>s===e||s.id===e.id);i>=0&&this.directives.splice(i,1),t||n.emit(c,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const r=i.findIndex(a=>a===e);e.parent=null,i.splice(r,1),t||n.emit(c,this)}appendChild(e,t=!1){const{children:i,disposed:s}=this;s||(e.parent=this,Array.isArray(i)?i.push(e):this.children=[e],t||n.emit(c,this))}insertAfter(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s+1,0,e),t||n.emit(c,this.parent)}}insertBefore(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s,0,e),t||n.emit(c,this.parent)}}movePrev(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>0&&(i.splice(s,1),i.splice(s-1,0,this),e||n.emit(c,t))}}moveNext(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,this),e||n.emit(c,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:l,props:h,directives:p,events:P}=this,T=Array.isArray(l)?l.map(b=>b.toDsl()):l;return{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:T,props:v.toDsl(h),directives:_.toDsl(p),events:A.toDsl(P)}}dispose(e=!1){const{children:t,disposed:i}=this;i||(Array.isArray(t)&&t.forEach(s=>s.dispose(!0)),this.parent?this.parent.removeChild(this,e):e||n.emit(c,this),this.parent=null,this.disposed=!0,delete E.nodes[this.id])}lock(e=!1){if(this.locked=!0,Array.isArray(this.children))for(const t of this.children)t.lock(!0);e||n.emit(c,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(c,this)}setVisible(e,t=!1){if(this.invisible=!e,Array.isArray(this.children))for(const i of this.children)i.setVisible(e,!0);t||n.emit(c,this)}isChild(e){let t=!1;if(Array.isArray(this.children)){for(const i of this.children)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break}return t}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||o.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const r=e[s];r&&(this[s]=r)}const{nodes:i=[]}=e;i.length&&(this.nodes=i.map(s=>new E(s))),t||n.emit(d,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((a,l)=>(a[l]=this[l],a),{}),__VTJ_BLOCK__:t,__VERSION__:e||o.timestamp().toString(),id:i,nodes:s.map(a=>a.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}setFunction(e,t,i,s=!1){this[e][t]=i,s||n.emit(d,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(d,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(d,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(d,this)}setCss(e,t=!1){this.css=e,t||n.emit(d,this)}setWatch(e,t=!1){e.id=e.id||o.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(d,this)}removeWatch(e,t=!1){const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1&&(this.watch.splice(i,1),t||n.emit(d,this))}setProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1?this.props.splice(i,1,e):this.props.push(e),t||n.emit(d,this)}removeProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1&&(this.props.splice(i,1),t||n.emit(d,this))}setEmit(e,t=!1){const i=o.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(r=>r===i.name||r===i);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(d,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>o.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(d,this))}setSlot(e,t=!1){const i=o.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(r=>r===i.name||r===i);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(d,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>o.isString(s)?s===e:s.name===e);i>-1&&(this.slots.splice(i,1),t||n.emit(d,this))}setInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1?this.inject.splice(i,1,e):this.inject.push(e),t||n.emit(d,this)}removeInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1&&(this.inject.splice(i,1),t||n.emit(d,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(d,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(d,this)}insertAfter(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s+1,0,e),i||n.emit(d,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(d,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(d,this)}addNode(e,t,i="inner",s=!1){t?["left","top"].includes(i)?t.parent?t.insertAfter(e,s):this.insertBefore(e,t,s):["right","bottom"].includes(i)?t.parent?t.insertAfter(e,s):this.insertAfter(e,t,s):t.appendChild(e,s):this.appendNode(e,s)}__removeNode(e,t=!1){const i=this.nodes.findIndex(s=>s.id===e.id);i>-1&&(this.nodes.splice(i,1),t||n.emit(d,this))}removeNode(e,t=!1){e.parent?e.dispose(t):(e.dispose(!0),this.__removeNode(e,t))}move(e,t,i="inner",s=!1){e.parent?e.parent.removeChild(e,!0):this.__removeNode(e,!0),this.addNode(e,t,i,s)}movePrev(e,t=!1){if(e.parent)e.movePrev(t);else{const i=this.nodes,s=i.indexOf(e);s>0&&(i.splice(s,1),i.splice(s-1,0,e),t||n.emit(d,this))}}moveNext(e,t=!1){if(e.parent)e.moveNext(t);else{const i=this.nodes,s=i.indexOf(e);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,e),t||n.emit(d,this))}}cloneNode(e,t=!1){const i=D(e.toDsl()),s=new E(i);return this.addNode(s,e,"bottom",t),s}lock(e=!1){this.locked=!0;for(const t of this.nodes)t.lock(!0);e||n.emit(d,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(d,this)}isChild(e){let t=!1;for(const i of this.nodes)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break;return t}}const f="EVENT_PROJECT_CHANGE",I="EVENT_PROJECT_ACTIVED",g="EVENT_PROJECT_DEPS_CHANGE",y="EVENT_PROJECT_PAGES_CHANGE",N="EVENT_PROJECT_BLOCKS_CHANGE",V="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",H="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH",L="EVENT_PROJECT_GEN_SOURCE";class O{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};__BASE_PATH__="/";static attrs=["name","homepage","description","dependencies","pages","blocks","apis","meta","config","__BASE_PATH__"];constructor(e){const{id:t}=e;this.id=t||o.uid(),this.update(e,!0)}update(e,t=!1){for(const i of O.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(f,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}cleanPagesDsl(e){for(const t of e)delete t.dsl,t.children&&t.children.length&&this.cleanPagesDsl(t.children)}toDsl(e){const{id:t}=this,i=O.attrs.reduce((s,r)=>(s[r]=this[r],s),{});return i.pages&&(i.pages=i.pages.map(s=>o.cloneDeep({...s,dsl:void 0})),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>o.cloneDeep({...s,dsl:void 0}))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(I,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(I,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(a=>a.package===e.package);let r;if(s>-1?(r="update",i.splice(s,1,{...i[s],...e})):(r="create",i.push(e)),!t){const a={model:this,type:r,data:e};n.emit(g,a),n.emit(f,a)}}removeDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(r=>r.package===e.package);if(s>-1&&i.splice(s,1),!t){const r={model:this,type:"delete",data:e};n.emit(g,r),n.emit(f,r)}}getPage(e){const t=(i,s=[])=>{for(const r of s){if(r.id===i)return r;if(r.children&&r.children.length){const a=t(i,r.children);if(a)return a}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir?s.children&&s.children.length&&(i=i.concat(e(s.children))):i.push(s);return i};return e(this.pages)}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||o.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:o.upperFirstCamelCase(e.name)}).toDsl(),t){const s=this.getPage(t);s?s.children?s.children.push(e):s.children=[e]:console.warn(`not found PageFile for id: ${t} `)}else this.pages.push(e);if(!i){const s={model:this,type:"create",data:e};n.emit(y,s),n.emit(f,s)}!this.currentFile&&!e.dir&&(await o.delay(1e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(i?Object.assign(i,e):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(y,s),n.emit(f,s)}}clonePage(e,t,i=!1){const s=o.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,l=new u({id:s,name:r}).toDsl(),h=o.merge({},e,{id:s,name:r,title:a,dsl:l}),p=t?this.getPage(t)?.children||[]:this.pages,P=p.findIndex(T=>T.id===e.id);if(p.splice(P+1,0,h),!i){const T={model:this,type:"clone",data:{source:e,target:h}};n.emit(y,T),n.emit(f,T)}}async saveToBlock(e,t=!1){this.active(e,t),await o.delay(1e3);const i=o.uid(),s=e.name,r=e.title,a=new u({id:i,name:s}).toDsl(),l=o.merge({},e,{id:i,name:s,title:r,dsl:a,type:"block",fromType:"Schema"});if(this.blocks.push(l),!t){const h={model:this,type:"create",data:l};n.emit(N,h),n.emit(f,h)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,a)=>{const l=a.findIndex(h=>h.id===r);if(l>=0){a.splice(l,1);return}for(const h of a)h.children&&h.children.length&&s(r,h.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const r={model:this,type:"delete",data:i};n.emit(y,r),n.emit(f,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}async createBlock(e,t=!1){const i=e.id||o.uid(),s=o.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const r=e.fromType||"Schema";if(!t){const a={model:this,type:"create",data:e};n.emit(N,a),n.emit(f,a)}!this.currentFile&&r==="Schema"&&(await o.delay(1e3),this.active(e,t))}updateBlock(e,t=!1){const i=this.getBlock(e.id);if(i?(Object.assign(i,e),i.dsl&&(i.dsl.name=e.name)):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(N,s),n.emit(f,s)}}cloneBlock(e,t=!1){const i=o.uid(),s=`${e.name}Copy`,r=`${e.title}_副本`,a=new u({id:i,name:s}).toDsl(),l=o.merge({},e,{id:i,name:s,title:r,dsl:a}),h=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(h+1,0,l),!t){const p={model:this,type:"clone",data:{source:e,target:l}};n.emit(N,p),n.emit(f,p)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,r=s.findIndex(a=>a.id===e);if(r>-1?(s.splice(r,1),this.currentFile?.id===e&&this.deactivate(t)):console.warn(`not found PageFile for id: ${e} `),!t){const a={model:this,type:"delete",data:i};n.emit(N,a),n.emit(f,a)}}existBlockName(e,t=[]){return this.blocks.some(i=>i.name===e&&!t.includes(i.id))}existPageName(e,t=[]){return this.getPages().some(s=>s.name===e&&!t.includes(s.id))}setApi(e,t=!1){const i=this.apis.find(r=>r.name===e.name||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=o.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(V,r),n.emit(f,r)}}removeApi(e,t=!1){const i=this.apis.findIndex(s=>s.name===e||s.id===e);if(i>-1?this.apis.splice(i,1):console.warn(`not found Api for name: ${e} `),!t){const s={model:this,type:"delete",data:e};n.emit(V,s),n.emit(f,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setMeta(e,t=!1){const i=this.meta.find(r=>r.code===e.code||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=o.uid(),this.meta.push(e)),!t){const r={model:this,type:s,data:e};n.emit(S,r),n.emit(f,r)}}removeMeta(e,t=!1){const i=this.meta.findIndex(s=>s.code===e||s.id===e);if(i>-1?this.meta.splice(i,1):console.warn(`not found meta for name: ${name} `),!t){const s={model:this,type:"delete",data:e};n.emit(S,s),n.emit(f,s)}}existMetaCode(e,t=[]){return this.meta.some(i=>i.code===e&&!t.includes(i.id))}setHomepage(e,t=!1){if(this.homepage=e,!t){const i={model:this,type:"update",data:e};n.emit(f,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(f,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(H,t)}genSource(){const e={model:this,type:"gen",data:null};n.emit(L,e)}}const C="EVENT_HISTORY_CHANGE",x="EVENT_HISTORY_LOAD";class K{options={max:50};index=-1;id;items;constructor(e,t={}){Object.assign(this.options,t);const{id:i,items:s=[]}=e;this.id=i,this.items=s}toDsl(){const{id:e,items:t}=this;return{id:e,items:t.map(i=>({id:i.id,label:i.label}))}}get(e){return this.items.find(t=>t.id===e)}add(e,t=!1){const{max:i}=this.options,s={id:o.uid(),label:new Date().toLocaleString(),dsl:o.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const r=this.items.splice(i);t||n.emit(C,{model:this,type:"delete",data:r.map(a=>a.id)})}this.index=-1,t||n.emit(C,{model:this,type:"create",data:s})}remove(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>-1?(this.items.splice(i,1),i===this.index?this.index=-1:this.index>=this.items.length&&(this.index=this.items.length-1)):console.warn(`not found HistoryItem for id: ${e} `),t||n.emit(C,{model:this,type:"delete",data:[e]})}forward(e=!1){const{index:t,items:i}=this;if(t<0)return;--this.index;const s=i[this.index];s&&!e&&n.emit(x,{model:this,type:"load",data:s})}backward(e=!1){const{index:t,items:i}=this;if(t>=i.length-1)return;t<0&&(this.index=0),++this.index;const s=i[this.index];s&&!e&&n.emit(x,{model:this,type:"load",data:s})}load(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>=0&&(this.index=i,t||n.emit(x,{model:this,type:"load",data:this.items[i]}))}clear(e=!1){this.index=-1;const t=this.items.map(i=>i.id);this.items=[],e||n.emit(C,{model:this,type:"clear",data:t})}}const n=o.mitt();function Y(m){return m instanceof u}function W(m){return m instanceof E}function q(m){return!!m.__VTJ_BLOCK__}function D(m){const e=o.cloneDeep(m);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>D(t))),e}function z(m){const e=m.fromType||"Schema";return e==="Schema"?{type:"Schema",id:m.id}:e==="UrlSchema"?{type:"UrlSchema",url:(m.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(m.urls||"").split(","),library:m.library}:""}exports.BUILT_IN_COMPONENTS=F;exports.BUILT_IN_LIBRARAY_MAP=w;exports.BUILT_IN_MATERIALS=U;exports.BUILT_IN_NAME=G;exports.BUILT_IN_TAGS=M;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=B;exports.Base=$;exports.BlockModel=u;exports.DirectiveModel=_;exports.EVENT_BLOCK_CHANGE=d;exports.EVENT_HISTORY_CHANGE=C;exports.EVENT_HISTORY_LOAD=x;exports.EVENT_NODE_CHANGE=c;exports.EVENT_PROJECT_ACTIVED=I;exports.EVENT_PROJECT_APIS_CHANGE=V;exports.EVENT_PROJECT_BLOCKS_CHANGE=N;exports.EVENT_PROJECT_CHANGE=f;exports.EVENT_PROJECT_DEPS_CHANGE=g;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_GEN_SOURCE=L;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=y;exports.EVENT_PROJECT_PUBLISH=H;exports.EventModel=A;exports.HistoryModel=K;exports.NodeModel=E;exports.ProjectModel=O;exports.PropModel=v;exports.Service=j;exports.VTJ_CORE_VERSION=J;exports.cloneDsl=D;exports.createNodeFrom=z;exports.emitter=n;exports.isBlock=Y;exports.isBlockSchema=q;exports.isNode=W;
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import { uid as m, timestamp as G, isString as A, upperFirstCamelCase as S, delay as P, merge as O, cloneDeep as b, mitt as F } from "@vtj/base";
1
+ import { uid as m, timestamp as G, isString as A, cloneDeep as C, upperFirstCamelCase as R, delay as O, merge as I, mitt as U } from "@vtj/base";
2
2
  /**!
3
3
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
4
4
  * @name @vtj/core
5
5
  * @author CHC chenhuachun1549@dingtalk.com
6
- * @version 0.9.0-alpha.9
6
+ * @version 0.9.0
7
7
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
8
8
  */
9
- const M = "0.9.0-alpha.9", K = "BuiltIn", w = "VueMaterial", H = "VueRouterMaterial", Y = [w, H], W = {
9
+ const K = "0.9.0", Y = "BuiltIn", w = "VueMaterial", H = "VueRouterMaterial", W = [w, H], q = {
10
10
  vue: "Vue",
11
11
  "vue-router": "VueRouter"
12
- }, q = {
12
+ }, z = {
13
13
  [w]: [
14
14
  "Transition",
15
15
  "TransitionGroup",
@@ -18,7 +18,7 @@ const M = "0.9.0-alpha.9", K = "BuiltIn", w = "VueMaterial", H = "VueRouterMater
18
18
  "Suspense"
19
19
  ],
20
20
  [H]: ["RouterView", "RouterLink"]
21
- }, z = [
21
+ }, Q = [
22
22
  "slot",
23
23
  "template",
24
24
  "component",
@@ -31,9 +31,9 @@ const M = "0.9.0-alpha.9", K = "BuiltIn", w = "VueMaterial", H = "VueRouterMater
31
31
  "span",
32
32
  "a"
33
33
  ];
34
- class Q {
35
- }
36
34
  class X {
35
+ }
36
+ class Z {
37
37
  listeners = [];
38
38
  isReady = !1;
39
39
  triggerReady() {
@@ -390,8 +390,8 @@ class _ {
390
390
  children: d,
391
391
  props: l,
392
392
  directives: p,
393
- events: C
394
- } = this, E = Array.isArray(d) ? d.map((J) => J.toDsl()) : d;
393
+ events: P
394
+ } = this, E = Array.isArray(d) ? d.map((L) => L.toDsl()) : d;
395
395
  return {
396
396
  id: e,
397
397
  name: t,
@@ -402,7 +402,7 @@ class _ {
402
402
  children: E,
403
403
  props: x.toDsl(l),
404
404
  directives: v.toDsl(p),
405
- events: T.toDsl(C)
405
+ events: T.toDsl(P)
406
406
  };
407
407
  }
408
408
  /**
@@ -756,7 +756,7 @@ class u {
756
756
  * @returns
757
757
  */
758
758
  cloneNode(e, t = !1) {
759
- const i = L(e.toDsl()), s = new _(i);
759
+ const i = J(e.toDsl()), s = new _(i);
760
760
  return this.addNode(s, e, "bottom", t), s;
761
761
  }
762
762
  lock(e = !1) {
@@ -782,8 +782,8 @@ class u {
782
782
  return t;
783
783
  }
784
784
  }
785
- const h = "EVENT_PROJECT_CHANGE", k = "EVENT_PROJECT_ACTIVED", R = "EVENT_PROJECT_DEPS_CHANGE", N = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", D = "EVENT_PROJECT_APIS_CHANGE", B = "EVENT_PROJECT_META_CHANGE", U = "EVENT_PROJECT_PUBLISH", j = "EVENT_PROJECT_FILE_PUBLISH";
786
- class V {
785
+ const h = "EVENT_PROJECT_CHANGE", k = "EVENT_PROJECT_ACTIVED", D = "EVENT_PROJECT_DEPS_CHANGE", N = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", B = "EVENT_PROJECT_APIS_CHANGE", b = "EVENT_PROJECT_META_CHANGE", F = "EVENT_PROJECT_PUBLISH", j = "EVENT_PROJECT_FILE_PUBLISH", $ = "EVENT_PROJECT_GEN_SOURCE";
786
+ class S {
787
787
  id = "";
788
788
  name = "";
789
789
  description = "";
@@ -813,7 +813,7 @@ class V {
813
813
  this.id = t || m(), this.update(e, !0);
814
814
  }
815
815
  update(e, t = !1) {
816
- for (const i of V.attrs) {
816
+ for (const i of S.attrs) {
817
817
  const s = e[i];
818
818
  s && (this[i] = s);
819
819
  }
@@ -831,11 +831,17 @@ class V {
831
831
  delete t.dsl, t.children && t.children.length && this.cleanPagesDsl(t.children);
832
832
  }
833
833
  toDsl(e) {
834
- const { id: t } = this, i = V.attrs.reduce(
834
+ const { id: t } = this, i = S.attrs.reduce(
835
835
  (s, a) => (s[a] = this[a], s),
836
836
  {}
837
837
  );
838
- return i.pages && (i.pages = i.pages.map((s) => (delete s.dsl, s)), this.cleanPagesDsl(i.pages)), i.blocks && (i.blocks = i.blocks.map((s) => (delete s.dsl, s))), {
838
+ return i.pages && (i.pages = i.pages.map((s) => C({
839
+ ...s,
840
+ dsl: void 0
841
+ })), this.cleanPagesDsl(i.pages)), i.blocks && (i.blocks = i.blocks.map((s) => C({
842
+ ...s,
843
+ dsl: void 0
844
+ }))), {
839
845
  __VTJ_PROJECT__: !0,
840
846
  // __VERSION__: version || timestamp().toString(),
841
847
  id: t,
@@ -882,7 +888,7 @@ class V {
882
888
  type: a,
883
889
  data: e
884
890
  };
885
- n.emit(R, r), n.emit(h, r);
891
+ n.emit(D, r), n.emit(h, r);
886
892
  }
887
893
  }
888
894
  /**
@@ -898,7 +904,7 @@ class V {
898
904
  type: "delete",
899
905
  data: e
900
906
  };
901
- n.emit(R, a), n.emit(h, a);
907
+ n.emit(D, a), n.emit(h, a);
902
908
  }
903
909
  }
904
910
  /**
@@ -942,7 +948,7 @@ class V {
942
948
  async createPage(e, t, i = !1) {
943
949
  if (e.id = e.raw ? e.name : e.id || m(), e.type = "page", e.dir ? e.children = [] : e.dsl = e.dsl || new u({
944
950
  id: e.id,
945
- name: S(e.name)
951
+ name: R(e.name)
946
952
  }).toDsl(), t) {
947
953
  const s = this.getPage(t);
948
954
  s ? s.children ? s.children.push(e) : s.children = [e] : console.warn(`not found PageFile for id: ${t} `);
@@ -956,7 +962,7 @@ class V {
956
962
  };
957
963
  n.emit(N, s), n.emit(h, s);
958
964
  }
959
- !this.currentFile && !e.dir && (await P(1e3), this.active(e, i));
965
+ !this.currentFile && !e.dir && (await O(1e3), this.active(e, i));
960
966
  }
961
967
  /**
962
968
  * 更新页面
@@ -984,8 +990,8 @@ class V {
984
990
  const s = m(), a = `${e.name}Copy`, r = `${e.title}_副本`, d = new u({
985
991
  id: s,
986
992
  name: a
987
- }).toDsl(), l = O({}, e, { id: s, name: a, title: r, dsl: d }), p = t ? this.getPage(t)?.children || [] : this.pages, C = p.findIndex((E) => E.id === e.id);
988
- if (p.splice(C + 1, 0, l), !i) {
993
+ }).toDsl(), l = I({}, e, { id: s, name: a, title: r, dsl: d }), p = t ? this.getPage(t)?.children || [] : this.pages, P = p.findIndex((E) => E.id === e.id);
994
+ if (p.splice(P + 1, 0, l), !i) {
989
995
  const E = {
990
996
  model: this,
991
997
  type: "clone",
@@ -998,11 +1004,11 @@ class V {
998
1004
  }
999
1005
  }
1000
1006
  async saveToBlock(e, t = !1) {
1001
- this.active(e, t), await P(1e3);
1007
+ this.active(e, t), await O(1e3);
1002
1008
  const i = m(), s = e.name, a = e.title, r = new u({
1003
1009
  id: i,
1004
1010
  name: s
1005
- }).toDsl(), d = O({}, e, {
1011
+ }).toDsl(), d = I({}, e, {
1006
1012
  id: i,
1007
1013
  name: s,
1008
1014
  title: a,
@@ -1057,7 +1063,7 @@ class V {
1057
1063
  * @param silent
1058
1064
  */
1059
1065
  async createBlock(e, t = !1) {
1060
- const i = e.id || m(), s = S(e.name);
1066
+ const i = e.id || m(), s = R(e.name);
1061
1067
  e.id = i, e.type = "block", e.dsl = new u({ id: i, name: s }).toDsl(), this.blocks.push(e);
1062
1068
  const a = e.fromType || "Schema";
1063
1069
  if (!t) {
@@ -1068,7 +1074,7 @@ class V {
1068
1074
  };
1069
1075
  n.emit(y, r), n.emit(h, r);
1070
1076
  }
1071
- !this.currentFile && a === "Schema" && (await P(1e3), this.active(e, t));
1077
+ !this.currentFile && a === "Schema" && (await O(1e3), this.active(e, t));
1072
1078
  }
1073
1079
  /**
1074
1080
  *
@@ -1090,7 +1096,7 @@ class V {
1090
1096
  const i = m(), s = `${e.name}Copy`, a = `${e.title}_副本`, r = new u({
1091
1097
  id: i,
1092
1098
  name: s
1093
- }).toDsl(), d = O({}, e, { id: i, name: s, title: a, dsl: r }), l = this.blocks.findIndex((p) => p.id === e.id);
1099
+ }).toDsl(), d = I({}, e, { id: i, name: s, title: a, dsl: r }), l = this.blocks.findIndex((p) => p.id === e.id);
1094
1100
  if (this.blocks.splice(l + 1, 0, d), !t) {
1095
1101
  const p = {
1096
1102
  model: this,
@@ -1153,7 +1159,7 @@ class V {
1153
1159
  type: s,
1154
1160
  data: e
1155
1161
  };
1156
- n.emit(D, a), n.emit(h, a);
1162
+ n.emit(B, a), n.emit(h, a);
1157
1163
  }
1158
1164
  }
1159
1165
  /**
@@ -1169,7 +1175,7 @@ class V {
1169
1175
  type: "delete",
1170
1176
  data: e
1171
1177
  };
1172
- n.emit(D, s), n.emit(h, s);
1178
+ n.emit(B, s), n.emit(h, s);
1173
1179
  }
1174
1180
  }
1175
1181
  existApiName(e, t = []) {
@@ -1186,7 +1192,7 @@ class V {
1186
1192
  type: s,
1187
1193
  data: e
1188
1194
  };
1189
- n.emit(B, a), n.emit(h, a);
1195
+ n.emit(b, a), n.emit(h, a);
1190
1196
  }
1191
1197
  }
1192
1198
  removeMeta(e, t = !1) {
@@ -1197,7 +1203,7 @@ class V {
1197
1203
  type: "delete",
1198
1204
  data: e
1199
1205
  };
1200
- n.emit(B, s), n.emit(h, s);
1206
+ n.emit(b, s), n.emit(h, s);
1201
1207
  }
1202
1208
  }
1203
1209
  existMetaCode(e, t = []) {
@@ -1229,11 +1235,19 @@ class V {
1229
1235
  type: "publish",
1230
1236
  data: e || this
1231
1237
  };
1232
- e ? n.emit(j, t) : n.emit(U, t);
1238
+ e ? n.emit(j, t) : n.emit(F, t);
1239
+ }
1240
+ genSource() {
1241
+ const e = {
1242
+ model: this,
1243
+ type: "gen",
1244
+ data: null
1245
+ };
1246
+ n.emit($, e);
1233
1247
  }
1234
1248
  }
1235
- const g = "EVENT_HISTORY_CHANGE", I = "EVENT_HISTORY_LOAD";
1236
- class Z {
1249
+ const g = "EVENT_HISTORY_CHANGE", V = "EVENT_HISTORY_LOAD";
1250
+ class ee {
1237
1251
  options = { max: 50 };
1238
1252
  index = -1;
1239
1253
  id;
@@ -1267,7 +1281,7 @@ class Z {
1267
1281
  const { max: i } = this.options, s = {
1268
1282
  id: m(),
1269
1283
  label: (/* @__PURE__ */ new Date()).toLocaleString(),
1270
- dsl: b(e)
1284
+ dsl: C(e)
1271
1285
  };
1272
1286
  if (this.items.unshift(s), this.items.length > i) {
1273
1287
  const a = this.items.splice(i);
@@ -1301,7 +1315,7 @@ class Z {
1301
1315
  if (t < 0) return;
1302
1316
  --this.index;
1303
1317
  const s = i[this.index];
1304
- s && !e && n.emit(I, {
1318
+ s && !e && n.emit(V, {
1305
1319
  model: this,
1306
1320
  type: "load",
1307
1321
  data: s
@@ -1312,7 +1326,7 @@ class Z {
1312
1326
  if (t >= i.length - 1) return;
1313
1327
  t < 0 && (this.index = 0), ++this.index;
1314
1328
  const s = i[this.index];
1315
- s && !e && n.emit(I, {
1329
+ s && !e && n.emit(V, {
1316
1330
  model: this,
1317
1331
  type: "load",
1318
1332
  data: s
@@ -1320,7 +1334,7 @@ class Z {
1320
1334
  }
1321
1335
  load(e, t = !1) {
1322
1336
  const i = this.items.findIndex((s) => s.id === e);
1323
- i >= 0 && (this.index = i, t || n.emit(I, {
1337
+ i >= 0 && (this.index = i, t || n.emit(V, {
1324
1338
  model: this,
1325
1339
  type: "load",
1326
1340
  data: this.items[i]
@@ -1336,21 +1350,21 @@ class Z {
1336
1350
  });
1337
1351
  }
1338
1352
  }
1339
- const n = F();
1340
- function ee(f) {
1353
+ const n = U();
1354
+ function te(f) {
1341
1355
  return f instanceof u;
1342
1356
  }
1343
- function te(f) {
1357
+ function ie(f) {
1344
1358
  return f instanceof _;
1345
1359
  }
1346
- function ie(f) {
1360
+ function se(f) {
1347
1361
  return !!f.__VTJ_BLOCK__;
1348
1362
  }
1349
- function L(f) {
1350
- const e = b(f);
1351
- return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) => L(t))), e;
1363
+ function J(f) {
1364
+ const e = C(f);
1365
+ return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) => J(t))), e;
1352
1366
  }
1353
- function se(f) {
1367
+ function ne(f) {
1354
1368
  const e = f.fromType || "Schema";
1355
1369
  return e === "Schema" ? {
1356
1370
  type: "Schema",
@@ -1365,40 +1379,41 @@ function se(f) {
1365
1379
  } : "";
1366
1380
  }
1367
1381
  export {
1368
- q as BUILT_IN_COMPONENTS,
1369
- W as BUILT_IN_LIBRARAY_MAP,
1370
- Y as BUILT_IN_MATERIALS,
1371
- K as BUILT_IN_NAME,
1372
- z as BUILT_IN_TAGS,
1382
+ z as BUILT_IN_COMPONENTS,
1383
+ q as BUILT_IN_LIBRARAY_MAP,
1384
+ W as BUILT_IN_MATERIALS,
1385
+ Y as BUILT_IN_NAME,
1386
+ Q as BUILT_IN_TAGS,
1373
1387
  w as BUILT_IN_VUE,
1374
1388
  H as BUILT_IN_VUE_ROUTER,
1375
- X as Base,
1389
+ Z as Base,
1376
1390
  u as BlockModel,
1377
1391
  v as DirectiveModel,
1378
1392
  o as EVENT_BLOCK_CHANGE,
1379
1393
  g as EVENT_HISTORY_CHANGE,
1380
- I as EVENT_HISTORY_LOAD,
1394
+ V as EVENT_HISTORY_LOAD,
1381
1395
  c as EVENT_NODE_CHANGE,
1382
1396
  k as EVENT_PROJECT_ACTIVED,
1383
- D as EVENT_PROJECT_APIS_CHANGE,
1397
+ B as EVENT_PROJECT_APIS_CHANGE,
1384
1398
  y as EVENT_PROJECT_BLOCKS_CHANGE,
1385
1399
  h as EVENT_PROJECT_CHANGE,
1386
- R as EVENT_PROJECT_DEPS_CHANGE,
1400
+ D as EVENT_PROJECT_DEPS_CHANGE,
1387
1401
  j as EVENT_PROJECT_FILE_PUBLISH,
1388
- B as EVENT_PROJECT_META_CHANGE,
1402
+ $ as EVENT_PROJECT_GEN_SOURCE,
1403
+ b as EVENT_PROJECT_META_CHANGE,
1389
1404
  N as EVENT_PROJECT_PAGES_CHANGE,
1390
- U as EVENT_PROJECT_PUBLISH,
1405
+ F as EVENT_PROJECT_PUBLISH,
1391
1406
  T as EventModel,
1392
- Z as HistoryModel,
1407
+ ee as HistoryModel,
1393
1408
  _ as NodeModel,
1394
- V as ProjectModel,
1409
+ S as ProjectModel,
1395
1410
  x as PropModel,
1396
- Q as Service,
1397
- M as VTJ_CORE_VERSION,
1398
- L as cloneDsl,
1399
- se as createNodeFrom,
1411
+ X as Service,
1412
+ K as VTJ_CORE_VERSION,
1413
+ J as cloneDsl,
1414
+ ne as createNodeFrom,
1400
1415
  n as emitter,
1401
- ee as isBlock,
1402
- ie as isBlockSchema,
1403
- te as isNode
1416
+ te as isBlock,
1417
+ se as isBlockSchema,
1418
+ ie as isNode
1404
1419
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@vtj/core",
3
3
  "private": false,
4
- "version": "0.9.0-alpha.9",
4
+ "version": "0.9.0",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@vtj/base": "~0.9.0-alpha.2"
7
+ "@vtj/base": "~0.9.0"
8
8
  },
9
9
  "devDependencies": {
10
- "@vtj/cli": "~0.9.0-alpha.2"
10
+ "@vtj/cli": "~0.9.0"
11
11
  },
12
12
  "exports": {
13
13
  ".": {
@@ -1,6 +1,6 @@
1
1
  export declare class Base {
2
2
  protected listeners: Array<() => void>;
3
- protected isReady: boolean;
3
+ isReady: boolean;
4
4
  protected triggerReady(): void;
5
5
  ready(callback: () => void): void;
6
6
  resetReady(): void;
@@ -41,6 +41,10 @@ export declare const EVENT_PROJECT_PUBLISH = "EVENT_PROJECT_PUBLISH";
41
41
  * 项目文件发布
42
42
  */
43
43
  export declare const EVENT_PROJECT_FILE_PUBLISH = "EVENT_PROJECT_FILE_PUBLISH";
44
+ /**
45
+ * 出码
46
+ */
47
+ export declare const EVENT_PROJECT_GEN_SOURCE = "EVENT_PROJECT_GEN_SOURCE";
44
48
  export declare class ProjectModel {
45
49
  id: string;
46
50
  name: string;
@@ -179,4 +183,5 @@ export declare class ProjectModel {
179
183
  setHomepage(id: string, silent?: boolean): void;
180
184
  setConfig(config: ProjectConfig, silent?: boolean): void;
181
185
  publish(file?: PageFile | BlockFile): void;
186
+ genSource(): void;
182
187
  }
@@ -94,6 +94,10 @@ export interface PageFile extends BlockFile {
94
94
  * 纯净的页面
95
95
  */
96
96
  pure?: boolean;
97
+ /**
98
+ * 开启页面缓存
99
+ */
100
+ cache?: boolean;
97
101
  /**
98
102
  * 路由元信息
99
103
  */
@@ -3,26 +3,27 @@ import { MaterialDescription } from './assets';
3
3
  import { StaticFileInfo, ExtensionConfig } from './shared';
4
4
  export declare abstract class Service {
5
5
  abstract getExtension(): Promise<ExtensionConfig | undefined>;
6
- abstract init(project: ProjectSchema): Promise<ProjectSchema>;
6
+ abstract init(project: Partial<ProjectSchema>): Promise<ProjectSchema>;
7
7
  abstract saveProject(project: ProjectSchema): Promise<boolean>;
8
8
  abstract saveMaterials(project: ProjectSchema, materials: Map<string, MaterialDescription>): Promise<boolean>;
9
- abstract saveFile(file: BlockSchema): Promise<boolean>;
10
- abstract getFile(id: string): Promise<BlockSchema>;
11
- abstract removeFile(id: string): Promise<boolean>;
12
- abstract saveHistory(history: HistorySchema): Promise<boolean>;
13
- abstract removeHistory(id: string): Promise<boolean>;
14
- abstract getHistory(id: string): Promise<HistorySchema>;
15
- abstract getHistoryItem(fId: string, id: string): Promise<HistoryItem>;
16
- abstract saveHistoryItem(fId: string, item: HistoryItem): Promise<boolean>;
17
- abstract removeHistoryItem(fId: string, ids: string[]): Promise<boolean>;
9
+ abstract saveFile(file: BlockSchema, project?: ProjectSchema): Promise<boolean>;
10
+ abstract getFile(id: string, project?: ProjectSchema): Promise<BlockSchema>;
11
+ abstract removeFile(id: string, project?: ProjectSchema): Promise<boolean>;
12
+ abstract saveHistory(history: HistorySchema, project?: ProjectSchema): Promise<boolean>;
13
+ abstract removeHistory(id: string, project?: ProjectSchema): Promise<boolean>;
14
+ abstract getHistory(id: string, project?: ProjectSchema): Promise<HistorySchema>;
15
+ abstract getHistoryItem(fId: string, id: string, project?: ProjectSchema): Promise<HistoryItem>;
16
+ abstract saveHistoryItem(fId: string, item: HistoryItem, project?: ProjectSchema): Promise<boolean>;
17
+ abstract removeHistoryItem(fId: string, ids: string[], project?: ProjectSchema): Promise<boolean>;
18
18
  abstract publish(project: ProjectSchema): Promise<boolean>;
19
19
  abstract publishFile(project: ProjectSchema, file: PageFile | BlockFile): Promise<boolean>;
20
20
  abstract genVueContent(project: ProjectSchema, dsl: BlockSchema): Promise<string>;
21
- abstract createRawPage(file: PageFile): Promise<boolean>;
22
- abstract removeRawPage(id: string): Promise<boolean>;
21
+ abstract createRawPage(file: PageFile, project?: ProjectSchema): Promise<boolean>;
22
+ abstract removeRawPage(id: string, project?: ProjectSchema): Promise<boolean>;
23
23
  abstract uploadStaticFile(file: File, projectId: string): Promise<StaticFileInfo | null>;
24
24
  abstract getStaticFiles(projectId: string): Promise<StaticFileInfo[]>;
25
25
  abstract removeStaticFile(name: string, projectId: string): Promise<boolean>;
26
26
  abstract clearStaticFiles(projectId: string): Promise<boolean>;
27
27
  abstract getPluginMaterial(from: NodeFromPlugin): Promise<MaterialDescription | null>;
28
+ abstract genSource(project: ProjectSchema): Promise<string>;
28
29
  }
@@ -59,6 +59,14 @@ export interface ExtensionConfig {
59
59
  * 路由History模式
60
60
  */
61
61
  history?: 'hash' | 'web';
62
+ /**
63
+ * 页面路由 base, 默认 '/'
64
+ */
65
+ base?: string;
66
+ /**
67
+ * 页面路由目录名称,默认: page
68
+ */
69
+ pageRouteName?: string;
62
70
  /**
63
71
  * 项目部署目录
64
72
  */
@@ -1,4 +1,4 @@
1
- import { ProjectModelEvent, BlockModel, NodeModel, HistoryModelEvent, EVENT_PROJECT_CHANGE, EVENT_PROJECT_ACTIVED, EVENT_PROJECT_DEPS_CHANGE, EVENT_PROJECT_PAGES_CHANGE, EVENT_PROJECT_BLOCKS_CHANGE, EVENT_PROJECT_APIS_CHANGE, EVENT_PROJECT_META_CHANGE, EVENT_PROJECT_PUBLISH, EVENT_PROJECT_FILE_PUBLISH, EVENT_BLOCK_CHANGE, EVENT_NODE_CHANGE, EVENT_HISTORY_CHANGE, EVENT_HISTORY_LOAD } from '../models';
1
+ import { ProjectModelEvent, BlockModel, NodeModel, HistoryModelEvent, EVENT_PROJECT_CHANGE, EVENT_PROJECT_ACTIVED, EVENT_PROJECT_DEPS_CHANGE, EVENT_PROJECT_PAGES_CHANGE, EVENT_PROJECT_BLOCKS_CHANGE, EVENT_PROJECT_APIS_CHANGE, EVENT_PROJECT_META_CHANGE, EVENT_PROJECT_PUBLISH, EVENT_PROJECT_FILE_PUBLISH, EVENT_BLOCK_CHANGE, EVENT_NODE_CHANGE, EVENT_HISTORY_CHANGE, EVENT_HISTORY_LOAD, EVENT_PROJECT_GEN_SOURCE } from '../models';
2
2
  import { Emitter } from 'mitt';
3
3
  type Events = {
4
4
  [EVENT_PROJECT_CHANGE]: ProjectModelEvent;
@@ -14,6 +14,7 @@ type Events = {
14
14
  [EVENT_NODE_CHANGE]: NodeModel;
15
15
  [EVENT_HISTORY_CHANGE]: HistoryModelEvent;
16
16
  [EVENT_HISTORY_LOAD]: HistoryModelEvent;
17
+ [EVENT_PROJECT_GEN_SOURCE]: ProjectModelEvent;
17
18
  };
18
19
  export declare const emitter: Emitter<Events>;
19
20
  export type Emitter = {
@@ -24,5 +25,5 @@ export type Emitter = {
24
25
  clear(): void;
25
26
  };
26
27
  };
27
- export type ModelEventType = 'create' | 'update' | 'delete' | 'clone' | 'clear' | 'load' | 'publish';
28
+ export type ModelEventType = 'create' | 'update' | 'delete' | 'clone' | 'clear' | 'load' | 'publish' | 'gen';
28
29
  export {};
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/core
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.9.0-alpha.8
5
+ * @version 0.9.0-alpha.50
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.9.0-alpha.8";
8
+ export declare const version = "0.9.0-alpha.50";