@vtj/core 0.7.13 → 0.7.14

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.7.13
5
+ * @version 0.7.14
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const H="0.7.13";class b{}class B{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 N{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 N(i,s),t),{})}}class x{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:d}=s;return t[i]={name:i,handler:r,modifiers:d},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new x(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||l.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:d}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=r,this.iterator=d}static parse(e=[]){return e.map(t=>new E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:d,iterator:h,id:f}=t;return{id:f,name:i,arg:s,modifiers:r,value:d,iterator:h}})}}const o="EVENT_NODE_CHANGE";class p{constructor(e,t=null){this.parent=t;const{id:i=l.uid(),name:s,from:r=""}=e;this.id=i,this.name=s,this.from=r,this.update(e,!0),p.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:d,props:h={},events:f={},directives:_=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(d,!0),this.props=N.parse(h),this.events=x.parse(f),this.directives=E.parse(_),t||n.emit(o,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new p(i,this)):this.children=e,t||n.emit(o,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(o,this)}setProp(e,t,i,s=!1){const r=this.props[e];r?r.setValue(t):this.props[e]=new N(e,t,i),s||n.emit(o,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(o,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 x(e),t||n.emit(o,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(o,this)}setDirective(e,t=!1){const i=this.directives.findIndex(s=>s.id===e.id);i>=0?this.directives.splice(i,1,new E(e)):this.directives.push(new E(e)),t||n.emit(o,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(o,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const r=i.findIndex(d=>d===e);e.parent=null,i.splice(r,1),t||n.emit(o,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(o,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(o,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(o,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(o,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(o,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:r,slot:d,children:h,props:f,directives:_,events:P}=this,v=Array.isArray(h)?h.map(D=>D.toDsl()):h;return{id:e,name:t,from:i,invisible:s,locked:r,slot:d,children:v,props:N.toDsl(f),directives:E.toDsl(_),events:x.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(o,this),this.parent=null,this.disposed=!0,delete p.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(o,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(o,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(o,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 a="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"];constructor(e){const{id:t}=e;this.id=t||l.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 p(s))),t||n.emit(a,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((d,h)=>(d[h]=this[h],d),{}),__VTJ_BLOCK__:t,__VERSION__:e||l.timestamp().toString(),id:i,nodes:s.map(d=>d.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(a,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(a,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(a,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(a,this)}setCss(e,t=!1){this.css=e,t||n.emit(a,this)}setWatch(e,t=!1){e.id=e.id||l.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(a,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(a,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(a,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(a,this))}setEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1?this.emits.splice(i,1,e):this.emits.push(e),t||n.emit(a,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1&&(this.emits.splice(i,1),t||n.emit(a,this))}setSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1?this.slots.splice(i,1,e):this.slots.push(e),t||n.emit(a,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1&&(this.slots.splice(i,1),t||n.emit(a,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(a,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(a,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(a,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(a,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(a,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(a,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(a,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(a,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(a,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(a,this))}}cloneNode(e,t=!1){const i=I(e.toDsl()),s=new p(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(a,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(a,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 m="EVENT_PROJECT_CHANGE",g="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",C="EVENT_PROJECT_PAGES_CHANGE",A="EVENT_PROJECT_BLOCKS_CHANGE",S="EVENT_PROJECT_APIS_CHANGE",R="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH";class O{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];currentFile=null;static attrs=["name","homepage","description","dependencies","pages","blocks","apis"];constructor(e){const{id:t}=e;this.id=t||l.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(m,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}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=>(delete s.dsl,s))),i.blocks&&(i.blocks=i.blocks.map(s=>(delete s.dsl,s))),{__VTJ_PROJECT__:!0,__VERSION__:e||l.timestamp().toString(),id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(g,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(g,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(d=>d.package===e.package);let r;if(s>-1?(r="update",i.splice(s,1,{...i[s],...e})):(r="create",i.push(e)),!t){const d={model:this,type:r,data:e};n.emit(V,d),n.emit(m,d)}}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(V,r),n.emit(m,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 d=t(i,r.children);if(d)return d}}};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)}createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||l.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:l.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(!this.currentFile&&!e.dir&&this.active(e,i),!i){const s={model:this,type:"create",data:e};n.emit(C,s),n.emit(m,s)}}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(C,s),n.emit(m,s)}}clonePage(e,t,i=!1){const s=l.uid(),r=`${e.name}Copy`,d=`${e.title}_副本`,h=new u({id:s,name:r}).toDsl(),f=l.merge({},e,{id:s,name:r,title:d,dsl:h}),_=t?this.getPage(t)?.children||[]:this.pages,P=_.findIndex(v=>v.id===e.id);if(_.splice(P+1,0,f),!i){const v={model:this,type:"clone",data:{page:e,newPage:f}};n.emit(C,v),n.emit(m,v)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,d)=>{const h=d.findIndex(f=>f.id===r);if(h>=0){d.splice(h,1);return}for(const f of d)if(f.children&&f.children.length)return s(r,f.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(C,r),n.emit(m,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}createBlock(e,t=!1){const i=e.id||l.uid(),s=l.upperFirstCamelCase(e.name);if(e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e),this.currentFile||this.active(e,t),!t){const r={model:this,type:"create",data:e};n.emit(A,r),n.emit(m,r)}}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(A,s),n.emit(m,s)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,r=s.findIndex(d=>d.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 d={model:this,type:"delete",data:i};n.emit(A,d),n.emit(m,d)}}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=l.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(S,r),n.emit(m,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(S,s),n.emit(m,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setHomepage(e,t=!1){if(this.homepage=e,!t){const i={model:this,type:"update",data:e};n.emit(m,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(R,t)}}const T="EVENT_HISTORY_CHANGE",y="EVENT_HISTORY_LOAD";class J{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:l.uid(),label:new Date().toLocaleString(),dsl:l.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const r=this.items.splice(i);t||n.emit(T,{model:this,type:"delete",data:r.map(d=>d.id)})}this.index=-1,t||n.emit(T,{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(T,{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(y,{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(y,{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(y,{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(T,{model:this,type:"clear",data:t})}}const n=l.mitt();function G(c){return c instanceof u}function w(c){return c instanceof p}function L(c){return!!c.__VTJ_BLOCK__}function I(c){return delete c.id,Array.isArray(c.children)&&(c.children=c.children.map(e=>I(e))),c}exports.Base=B;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=a;exports.EVENT_HISTORY_CHANGE=T;exports.EVENT_HISTORY_LOAD=y;exports.EVENT_NODE_CHANGE=o;exports.EVENT_PROJECT_ACTIVED=g;exports.EVENT_PROJECT_APIS_CHANGE=S;exports.EVENT_PROJECT_BLOCKS_CHANGE=A;exports.EVENT_PROJECT_CHANGE=m;exports.EVENT_PROJECT_DEPS_CHANGE=V;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_PAGES_CHANGE=C;exports.EVENT_PROJECT_PUBLISH=R;exports.EventModel=x;exports.HistoryModel=J;exports.NodeModel=p;exports.ProjectModel=O;exports.PropModel=N;exports.Service=b;exports.VTJ_CORE_VERSION=H;exports.cloneDsl=I;exports.emitter=n;exports.isBlock=G;exports.isBlockSchema=L;exports.isNode=w;
7
+ */const H="0.7.14",b="BuiltIn",R="VueMaterial",S="VueRouterMaterial",J=[R,S],G={vue:"Vue","vue-router":"VueRouter"},U={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[S]:["RouterView","RouterLink"]},w=["slot","template","component","img","div","p","h1","h2","h3","span","a"];class F{}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 T{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 T(i,s),t),{})}}class v{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:o}=s;return t[i]={name:i,handler:r,modifiers:o},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||l.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:o}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=r,this.iterator=o}static parse(e=[]){return e.map(t=>new E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:o,iterator:h,id:f}=t;return{id:f,name:i,arg:s,modifiers:r,value:o,iterator:h}})}}const d="EVENT_NODE_CHANGE";class p{constructor(e,t=null){this.parent=t;const{id:i=l.uid(),name:s,from:r=""}=e;this.id=i,this.name=s,this.from=r,this.update(e,!0),p.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:o,props:h={},events:f={},directives:_=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(o,!0),this.props=T.parse(h),this.events=v.parse(f),this.directives=E.parse(_),t||n.emit(d,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new p(i,this)):this.children=e,t||n.emit(d,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(d,this)}setProp(e,t,i,s=!1){const r=this.props[e];r?r.setValue(t):this.props[e]=new T(e,t,i),s||n.emit(d,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(d,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 v(e),t||n.emit(d,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(d,this)}setDirective(e,t=!1){const i=this.directives.findIndex(s=>s.id===e.id);i>=0?this.directives.splice(i,1,new E(e)):this.directives.push(new E(e)),t||n.emit(d,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(d,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const r=i.findIndex(o=>o===e);e.parent=null,i.splice(r,1),t||n.emit(d,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(d,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(d,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(d,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(d,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(d,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:r,slot:o,children:h,props:f,directives:_,events:y}=this,N=Array.isArray(h)?h.map(D=>D.toDsl()):h;return{id:e,name:t,from:i,invisible:s,locked:r,slot:o,children:N,props:T.toDsl(f),directives:E.toDsl(_),events:v.toDsl(y)}}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(d,this),this.parent=null,this.disposed=!0,delete p.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(d,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(d,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(d,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 a="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"];constructor(e){const{id:t}=e;this.id=t||l.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 p(s))),t||n.emit(a,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((o,h)=>(o[h]=this[h],o),{}),__VTJ_BLOCK__:t,__VERSION__:e||l.timestamp().toString(),id:i,nodes:s.map(o=>o.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(a,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(a,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(a,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(a,this)}setCss(e,t=!1){this.css=e,t||n.emit(a,this)}setWatch(e,t=!1){e.id=e.id||l.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(a,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(a,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(a,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(a,this))}setEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1?this.emits.splice(i,1,e):this.emits.push(e),t||n.emit(a,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1&&(this.emits.splice(i,1),t||n.emit(a,this))}setSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1?this.slots.splice(i,1,e):this.slots.push(e),t||n.emit(a,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1&&(this.slots.splice(i,1),t||n.emit(a,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(a,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(a,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(a,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(a,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(a,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(a,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(a,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(a,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(a,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(a,this))}}cloneNode(e,t=!1){const i=B(e.toDsl()),s=new p(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(a,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(a,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 m="EVENT_PROJECT_CHANGE",P="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",A="EVENT_PROJECT_PAGES_CHANGE",C="EVENT_PROJECT_BLOCKS_CHANGE",g="EVENT_PROJECT_APIS_CHANGE",k="EVENT_PROJECT_PUBLISH",L="EVENT_PROJECT_FILE_PUBLISH";class O{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];currentFile=null;static attrs=["name","homepage","description","dependencies","pages","blocks","apis"];constructor(e){const{id:t}=e;this.id=t||l.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(m,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}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=>(delete s.dsl,s))),i.blocks&&(i.blocks=i.blocks.map(s=>(delete s.dsl,s))),{__VTJ_PROJECT__:!0,__VERSION__:e||l.timestamp().toString(),id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(P,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(P,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(o=>o.package===e.package);let r;if(s>-1?(r="update",i.splice(s,1,{...i[s],...e})):(r="create",i.push(e)),!t){const o={model:this,type:r,data:e};n.emit(V,o),n.emit(m,o)}}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(V,r),n.emit(m,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 o=t(i,r.children);if(o)return o}}};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)}createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||l.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:l.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(!this.currentFile&&!e.dir&&this.active(e,i),!i){const s={model:this,type:"create",data:e};n.emit(A,s),n.emit(m,s)}}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(A,s),n.emit(m,s)}}clonePage(e,t,i=!1){const s=l.uid(),r=`${e.name}Copy`,o=`${e.title}_副本`,h=new u({id:s,name:r}).toDsl(),f=l.merge({},e,{id:s,name:r,title:o,dsl:h}),_=t?this.getPage(t)?.children||[]:this.pages,y=_.findIndex(N=>N.id===e.id);if(_.splice(y+1,0,f),!i){const N={model:this,type:"clone",data:{page:e,newPage:f}};n.emit(A,N),n.emit(m,N)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,o)=>{const h=o.findIndex(f=>f.id===r);if(h>=0){o.splice(h,1);return}for(const f of o)if(f.children&&f.children.length)return s(r,f.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(A,r),n.emit(m,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}createBlock(e,t=!1){const i=e.id||l.uid(),s=l.upperFirstCamelCase(e.name);if(e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e),this.currentFile||this.active(e,t),!t){const r={model:this,type:"create",data:e};n.emit(C,r),n.emit(m,r)}}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(C,s),n.emit(m,s)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,r=s.findIndex(o=>o.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 o={model:this,type:"delete",data:i};n.emit(C,o),n.emit(m,o)}}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=l.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(g,r),n.emit(m,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(g,s),n.emit(m,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setHomepage(e,t=!1){if(this.homepage=e,!t){const i={model:this,type:"update",data:e};n.emit(m,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(L,t):n.emit(k,t)}}const x="EVENT_HISTORY_CHANGE",I="EVENT_HISTORY_LOAD";class M{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:l.uid(),label:new Date().toLocaleString(),dsl:l.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const r=this.items.splice(i);t||n.emit(x,{model:this,type:"delete",data:r.map(o=>o.id)})}this.index=-1,t||n.emit(x,{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(x,{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(I,{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(I,{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(I,{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(x,{model:this,type:"clear",data:t})}}const n=l.mitt();function K(c){return c instanceof u}function Y(c){return c instanceof p}function $(c){return!!c.__VTJ_BLOCK__}function B(c){return delete c.id,Array.isArray(c.children)&&(c.children=c.children.map(e=>B(e))),c}exports.BUILT_IN_COMPONENTS=U;exports.BUILT_IN_LIBRARAY_MAP=G;exports.BUILT_IN_MATERIALS=J;exports.BUILT_IN_NAME=b;exports.BUILT_IN_TAGS=w;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=S;exports.Base=j;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=a;exports.EVENT_HISTORY_CHANGE=x;exports.EVENT_HISTORY_LOAD=I;exports.EVENT_NODE_CHANGE=d;exports.EVENT_PROJECT_ACTIVED=P;exports.EVENT_PROJECT_APIS_CHANGE=g;exports.EVENT_PROJECT_BLOCKS_CHANGE=C;exports.EVENT_PROJECT_CHANGE=m;exports.EVENT_PROJECT_DEPS_CHANGE=V;exports.EVENT_PROJECT_FILE_PUBLISH=L;exports.EVENT_PROJECT_PAGES_CHANGE=A;exports.EVENT_PROJECT_PUBLISH=k;exports.EventModel=v;exports.HistoryModel=M;exports.NodeModel=p;exports.ProjectModel=O;exports.PropModel=T;exports.Service=F;exports.VTJ_CORE_VERSION=H;exports.cloneDsl=B;exports.emitter=n;exports.isBlock=K;exports.isBlockSchema=$;exports.isNode=Y;
package/dist/index.mjs CHANGED
@@ -1,15 +1,39 @@
1
- import { uid as m, timestamp as S, upperFirstCamelCase as P, merge as b, cloneDeep as H, mitt as w } from "@vtj/base";
1
+ import { uid as m, timestamp as S, upperFirstCamelCase as I, merge as H, cloneDeep as w, mitt as L } 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.7.13
6
+ * @version 0.7.14
7
7
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
8
8
  */
9
- const G = "0.7.13";
10
- class j {
9
+ const U = "0.7.14", j = "BuiltIn", k = "VueMaterial", D = "VueRouterMaterial", K = [k, D], $ = {
10
+ vue: "Vue",
11
+ "vue-router": "VueRouter"
12
+ }, Y = {
13
+ [k]: [
14
+ "Transition",
15
+ "TransitionGroup",
16
+ "KeepAlive",
17
+ "Teleport",
18
+ "Suspense"
19
+ ],
20
+ [D]: ["RouterView", "RouterLink"]
21
+ }, M = [
22
+ "slot",
23
+ "template",
24
+ "component",
25
+ "img",
26
+ "div",
27
+ "p",
28
+ "h1",
29
+ "h2",
30
+ "h3",
31
+ "span",
32
+ "a"
33
+ ];
34
+ class W {
11
35
  }
12
- class L {
36
+ class q {
13
37
  listeners = [];
14
38
  isReady = !1;
15
39
  triggerReady() {
@@ -46,7 +70,7 @@ class x {
46
70
  return Object.entries(e).reduce((t, [i, s]) => (t[i] = new x(i, s), t), {});
47
71
  }
48
72
  }
49
- class y {
73
+ class A {
50
74
  constructor(e) {
51
75
  this.schema = e;
52
76
  const { name: t, handler: i } = this.schema;
@@ -68,12 +92,12 @@ class y {
68
92
  }
69
93
  static parse(e = {}) {
70
94
  return Object.entries(e).reduce(
71
- (t, [i, s]) => (t[i] = new y(s), t),
95
+ (t, [i, s]) => (t[i] = new A(s), t),
72
96
  {}
73
97
  );
74
98
  }
75
99
  }
76
- class _ {
100
+ class v {
77
101
  constructor(e) {
78
102
  this.schema = e, this.id = e.id || m(), this.update(e);
79
103
  }
@@ -107,7 +131,7 @@ class _ {
107
131
  this.name = t, this.arg = i, this.modifiers = s, this.value = r, this.iterator = a;
108
132
  }
109
133
  static parse(e = []) {
110
- return e.map((t) => new _(t));
134
+ return e.map((t) => new v(t));
111
135
  }
112
136
  static toDsl(e = []) {
113
137
  return e.map((t) => {
@@ -123,7 +147,7 @@ class _ {
123
147
  });
124
148
  }
125
149
  }
126
- const o = "EVENT_NODE_CHANGE";
150
+ const d = "EVENT_NODE_CHANGE";
127
151
  class p {
128
152
  constructor(e, t = null) {
129
153
  this.parent = t;
@@ -197,7 +221,7 @@ class p {
197
221
  events: c = {},
198
222
  directives: E = []
199
223
  } = e;
200
- this.invisible = i, this.locked = s, this.setChildren(r, !0), this.setSlot(a, !0), this.props = x.parse(l), this.events = y.parse(c), this.directives = _.parse(E), t || n.emit(o, this);
224
+ this.invisible = i, this.locked = s, this.setChildren(r, !0), this.setSlot(a, !0), this.props = x.parse(l), this.events = A.parse(c), this.directives = v.parse(E), t || n.emit(d, this);
201
225
  }
202
226
  /**
203
227
  * 设置子节点
@@ -205,7 +229,7 @@ class p {
205
229
  * @param silent
206
230
  */
207
231
  setChildren(e = "", t = !1) {
208
- Array.isArray(e) ? this.children = e.map((i) => new p(i, this)) : this.children = e, t || n.emit(o, this);
232
+ Array.isArray(e) ? this.children = e.map((i) => new p(i, this)) : this.children = e, t || n.emit(d, this);
209
233
  }
210
234
  /**
211
235
  * 设置节点放置的插槽
@@ -213,7 +237,7 @@ class p {
213
237
  * @param silent
214
238
  */
215
239
  setSlot(e, t = !1) {
216
- this.slot = typeof e == "string" ? { name: e, params: [] } : e, t || n.emit(o, this);
240
+ this.slot = typeof e == "string" ? { name: e, params: [] } : e, t || n.emit(d, this);
217
241
  }
218
242
  /**
219
243
  * 新增或更新属性
@@ -224,7 +248,7 @@ class p {
224
248
  */
225
249
  setProp(e, t, i, s = !1) {
226
250
  const r = this.props[e];
227
- r ? r.setValue(t) : this.props[e] = new x(e, t, i), s || n.emit(o, this);
251
+ r ? r.setValue(t) : this.props[e] = new x(e, t, i), s || n.emit(d, this);
228
252
  }
229
253
  /**
230
254
  * 删除属性
@@ -232,7 +256,7 @@ class p {
232
256
  * @param silent
233
257
  */
234
258
  removeProp(e, t = !1) {
235
- delete this.props[e], t || n.emit(o, this);
259
+ delete this.props[e], t || n.emit(d, this);
236
260
  }
237
261
  /**
238
262
  * 获取属性值
@@ -251,7 +275,7 @@ class p {
251
275
  */
252
276
  setEvent(e, t = !1) {
253
277
  const i = this.events[e.name];
254
- i ? i.update(e) : this.events[e.name] = new y(e), t || n.emit(o, this);
278
+ i ? i.update(e) : this.events[e.name] = new A(e), t || n.emit(d, this);
255
279
  }
256
280
  /**
257
281
  * 删除事件
@@ -259,7 +283,7 @@ class p {
259
283
  * @param silent
260
284
  */
261
285
  removeEvent(e, t = !1) {
262
- delete this.events[e], t || n.emit(o, this);
286
+ delete this.events[e], t || n.emit(d, this);
263
287
  }
264
288
  /**
265
289
  * 新增或更新指令
@@ -268,7 +292,7 @@ class p {
268
292
  */
269
293
  setDirective(e, t = !1) {
270
294
  const i = this.directives.findIndex((s) => s.id === e.id);
271
- i >= 0 ? this.directives.splice(i, 1, new _(e)) : this.directives.push(new _(e)), t || n.emit(o, this);
295
+ i >= 0 ? this.directives.splice(i, 1, new v(e)) : this.directives.push(new v(e)), t || n.emit(d, this);
272
296
  }
273
297
  /**
274
298
  * 删除指令
@@ -279,7 +303,7 @@ class p {
279
303
  const i = this.directives.findIndex(
280
304
  (s) => s === e || s.id === e.id
281
305
  );
282
- i >= 0 && this.directives.splice(i, 1), t || n.emit(o, this);
306
+ i >= 0 && this.directives.splice(i, 1), t || n.emit(d, this);
283
307
  }
284
308
  /**
285
309
  * 删除子节点
@@ -292,7 +316,7 @@ class p {
292
316
  if (s || !Array.isArray(i))
293
317
  return;
294
318
  const r = i.findIndex((a) => a === e);
295
- e.parent = null, i.splice(r, 1), t || n.emit(o, this);
319
+ e.parent = null, i.splice(r, 1), t || n.emit(d, this);
296
320
  }
297
321
  /**
298
322
  * 追加子节点
@@ -302,7 +326,7 @@ class p {
302
326
  */
303
327
  appendChild(e, t = !1) {
304
328
  const { children: i, disposed: s } = this;
305
- s || (e.parent = this, Array.isArray(i) ? i.push(e) : this.children = [e], t || n.emit(o, this));
329
+ s || (e.parent = this, Array.isArray(i) ? i.push(e) : this.children = [e], t || n.emit(d, this));
306
330
  }
307
331
  /**
308
332
  * 在当前节点的后面插入节点
@@ -317,7 +341,7 @@ class p {
317
341
  if (Array.isArray(i)) {
318
342
  e.parent = this.parent;
319
343
  const s = i.indexOf(this);
320
- i.splice(s + 1, 0, e), t || n.emit(o, this.parent);
344
+ i.splice(s + 1, 0, e), t || n.emit(d, this.parent);
321
345
  }
322
346
  }
323
347
  /**
@@ -333,7 +357,7 @@ class p {
333
357
  if (Array.isArray(i)) {
334
358
  e.parent = this.parent;
335
359
  const s = i.indexOf(this);
336
- i.splice(s, 0, e), t || n.emit(o, this.parent);
360
+ i.splice(s, 0, e), t || n.emit(d, this.parent);
337
361
  }
338
362
  }
339
363
  movePrev(e = !1) {
@@ -343,7 +367,7 @@ class p {
343
367
  const i = t.children;
344
368
  if (Array.isArray(i)) {
345
369
  const s = i.indexOf(this);
346
- s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, this), e || n.emit(o, t));
370
+ s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, this), e || n.emit(d, t));
347
371
  }
348
372
  }
349
373
  moveNext(e = !1) {
@@ -353,7 +377,7 @@ class p {
353
377
  const i = t.children;
354
378
  if (Array.isArray(i)) {
355
379
  const s = i.indexOf(this);
356
- s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, this), e || n.emit(o, t));
380
+ s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, this), e || n.emit(d, t));
357
381
  }
358
382
  }
359
383
  /**
@@ -371,8 +395,8 @@ class p {
371
395
  children: l,
372
396
  props: c,
373
397
  directives: E,
374
- events: C
375
- } = this, v = Array.isArray(l) ? l.map((R) => R.toDsl()) : l;
398
+ events: T
399
+ } = this, _ = Array.isArray(l) ? l.map((b) => b.toDsl()) : l;
376
400
  return {
377
401
  id: e,
378
402
  name: t,
@@ -380,10 +404,10 @@ class p {
380
404
  invisible: s,
381
405
  locked: r,
382
406
  slot: a,
383
- children: v,
407
+ children: _,
384
408
  props: x.toDsl(c),
385
- directives: _.toDsl(E),
386
- events: y.toDsl(C)
409
+ directives: v.toDsl(E),
410
+ events: A.toDsl(T)
387
411
  };
388
412
  }
389
413
  /**
@@ -393,25 +417,25 @@ class p {
393
417
  */
394
418
  dispose(e = !1) {
395
419
  const { children: t, disposed: i } = this;
396
- i || (Array.isArray(t) && t.forEach((s) => s.dispose(!0)), this.parent ? this.parent.removeChild(this, e) : e || n.emit(o, this), this.parent = null, this.disposed = !0, delete p.nodes[this.id]);
420
+ i || (Array.isArray(t) && t.forEach((s) => s.dispose(!0)), this.parent ? this.parent.removeChild(this, e) : e || n.emit(d, this), this.parent = null, this.disposed = !0, delete p.nodes[this.id]);
397
421
  }
398
422
  lock(e = !1) {
399
423
  if (this.locked = !0, Array.isArray(this.children))
400
424
  for (const t of this.children)
401
425
  t.lock(!0);
402
- e || n.emit(o, this);
426
+ e || n.emit(d, this);
403
427
  }
404
428
  unlock(e = !1) {
405
429
  if (this.locked = !1, Array.isArray(this.children))
406
430
  for (const t of this.children)
407
431
  t.unlock(!0);
408
- e || n.emit(o, this);
432
+ e || n.emit(d, this);
409
433
  }
410
434
  setVisible(e, t = !1) {
411
435
  if (this.invisible = !e, Array.isArray(this.children))
412
436
  for (const i of this.children)
413
437
  i.setVisible(e, !0);
414
- t || n.emit(o, this);
438
+ t || n.emit(d, this);
415
439
  }
416
440
  isChild(e) {
417
441
  let t = !1;
@@ -426,7 +450,7 @@ class p {
426
450
  return t;
427
451
  }
428
452
  }
429
- const d = "EVENT_BLOCK_CHANGE";
453
+ const o = "EVENT_BLOCK_CHANGE";
430
454
  class u {
431
455
  __VTJ_BLOCK__ = !0;
432
456
  id;
@@ -470,7 +494,7 @@ class u {
470
494
  r && (this[s] = r);
471
495
  }
472
496
  const { nodes: i = [] } = e;
473
- i.length && (this.nodes = i.map((s) => new p(s))), t || n.emit(d, this);
497
+ i.length && (this.nodes = i.map((s) => new p(s))), t || n.emit(o, this);
474
498
  }
475
499
  /**
476
500
  * 获取DSL
@@ -503,7 +527,7 @@ class u {
503
527
  * @param silent
504
528
  */
505
529
  setFunction(e, t, i, s = !1) {
506
- this[e][t] = i, s || n.emit(d, this);
530
+ this[e][t] = i, s || n.emit(o, this);
507
531
  }
508
532
  /**
509
533
  * 删除通用函数属性
@@ -512,7 +536,7 @@ class u {
512
536
  * @param silent
513
537
  */
514
538
  removeFunction(e, t, i = !1) {
515
- delete this[e][t], i || n.emit(d, this);
539
+ delete this[e][t], i || n.emit(o, this);
516
540
  }
517
541
  /**
518
542
  * 设置状态
@@ -521,7 +545,7 @@ class u {
521
545
  * @param silent
522
546
  */
523
547
  setState(e, t, i = !1) {
524
- this.state[e] = t, i || n.emit(d, this);
548
+ this.state[e] = t, i || n.emit(o, this);
525
549
  }
526
550
  /**
527
551
  * 删除状态
@@ -529,7 +553,7 @@ class u {
529
553
  * @param silent
530
554
  */
531
555
  removeState(e, t = !1) {
532
- delete this.state[e], t || n.emit(d, this);
556
+ delete this.state[e], t || n.emit(o, this);
533
557
  }
534
558
  /**
535
559
  * 更新CSS
@@ -537,7 +561,7 @@ class u {
537
561
  * @param silent
538
562
  */
539
563
  setCss(e, t = !1) {
540
- this.css = e, t || n.emit(d, this);
564
+ this.css = e, t || n.emit(o, this);
541
565
  }
542
566
  /**
543
567
  * 新增或更新 watch
@@ -549,7 +573,7 @@ class u {
549
573
  const i = this.watch.findIndex(
550
574
  (s) => s.id && s.id === e.id || s === e
551
575
  );
552
- i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(d, this);
576
+ i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(o, this);
553
577
  }
554
578
  /**
555
579
  * 删除 watch
@@ -560,7 +584,7 @@ class u {
560
584
  const i = this.watch.findIndex(
561
585
  (s) => s.id && s.id === e.id || s === e
562
586
  );
563
- i > -1 && (this.watch.splice(i, 1), t || n.emit(d, this));
587
+ i > -1 && (this.watch.splice(i, 1), t || n.emit(o, this));
564
588
  }
565
589
  /**
566
590
  * 定义属性参数
@@ -571,7 +595,7 @@ class u {
571
595
  const i = this.props.findIndex(
572
596
  (s) => typeof s == "string" ? s === e.name : s.name === e.name
573
597
  );
574
- i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(d, this);
598
+ i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(o, this);
575
599
  }
576
600
  /**
577
601
  * 删除属性
@@ -582,7 +606,7 @@ class u {
582
606
  const i = this.props.findIndex(
583
607
  (s) => typeof s == "string" ? s === e.name : s.name === e.name
584
608
  );
585
- i > -1 && (this.props.splice(i, 1), t || n.emit(d, this));
609
+ i > -1 && (this.props.splice(i, 1), t || n.emit(o, this));
586
610
  }
587
611
  /**
588
612
  * 设置事件
@@ -591,7 +615,7 @@ class u {
591
615
  */
592
616
  setEmit(e, t = !1) {
593
617
  const i = this.emits.findIndex((s) => s === e);
594
- i > -1 ? this.emits.splice(i, 1, e) : this.emits.push(e), t || n.emit(d, this);
618
+ i > -1 ? this.emits.splice(i, 1, e) : this.emits.push(e), t || n.emit(o, this);
595
619
  }
596
620
  /**
597
621
  * 删除事件
@@ -600,7 +624,7 @@ class u {
600
624
  */
601
625
  removeEmit(e, t = !1) {
602
626
  const i = this.emits.findIndex((s) => s === e);
603
- i > -1 && (this.emits.splice(i, 1), t || n.emit(d, this));
627
+ i > -1 && (this.emits.splice(i, 1), t || n.emit(o, this));
604
628
  }
605
629
  /**
606
630
  * 设置插槽
@@ -609,7 +633,7 @@ class u {
609
633
  */
610
634
  setSlot(e, t = !1) {
611
635
  const i = this.slots.findIndex((s) => s === e);
612
- i > -1 ? this.slots.splice(i, 1, e) : this.slots.push(e), t || n.emit(d, this);
636
+ i > -1 ? this.slots.splice(i, 1, e) : this.slots.push(e), t || n.emit(o, this);
613
637
  }
614
638
  /**
615
639
  * 删除插槽
@@ -618,7 +642,7 @@ class u {
618
642
  */
619
643
  removeSlot(e, t = !1) {
620
644
  const i = this.slots.findIndex((s) => s === e);
621
- i > -1 && (this.slots.splice(i, 1), t || n.emit(d, this));
645
+ i > -1 && (this.slots.splice(i, 1), t || n.emit(o, this));
622
646
  }
623
647
  /**
624
648
  * 设置注入
@@ -627,7 +651,7 @@ class u {
627
651
  */
628
652
  setInject(e, t = !1) {
629
653
  const i = this.inject.findIndex((s) => s.name === e.name);
630
- i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(d, this);
654
+ i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(o, this);
631
655
  }
632
656
  /**
633
657
  * 删除注入
@@ -636,7 +660,7 @@ class u {
636
660
  */
637
661
  removeInject(e, t = !1) {
638
662
  const i = this.inject.findIndex((s) => s.name === e.name);
639
- i > -1 && (this.inject.splice(i, 1), t || n.emit(d, this));
663
+ i > -1 && (this.inject.splice(i, 1), t || n.emit(o, this));
640
664
  }
641
665
  /**
642
666
  * 设置数据源
@@ -644,7 +668,7 @@ class u {
644
668
  * @param silent
645
669
  */
646
670
  setDataSource(e, t = !1) {
647
- this.dataSources[e.name] = e, t || n.emit(d, this);
671
+ this.dataSources[e.name] = e, t || n.emit(o, this);
648
672
  }
649
673
  /**
650
674
  * 删除数据源
@@ -652,20 +676,20 @@ class u {
652
676
  * @param silent
653
677
  */
654
678
  removeDataSource(e, t = !1) {
655
- delete this.dataSources[e], t || n.emit(d, this);
679
+ delete this.dataSources[e], t || n.emit(o, this);
656
680
  }
657
681
  insertAfter(e, t, i = !1) {
658
682
  e.parent = null;
659
683
  const s = this.nodes.indexOf(t);
660
- this.nodes.splice(s + 1, 0, e), i || n.emit(d, this);
684
+ this.nodes.splice(s + 1, 0, e), i || n.emit(o, this);
661
685
  }
662
686
  insertBefore(e, t, i = !1) {
663
687
  e.parent = null;
664
688
  const s = this.nodes.indexOf(t);
665
- this.nodes.splice(s, 0, e), i || n.emit(d, this);
689
+ this.nodes.splice(s, 0, e), i || n.emit(o, this);
666
690
  }
667
691
  appendNode(e, t = !1) {
668
- e.parent = null, this.nodes.push(e), t || n.emit(d, this);
692
+ e.parent = null, this.nodes.push(e), t || n.emit(o, this);
669
693
  }
670
694
  /**
671
695
  * 添加节点
@@ -679,7 +703,7 @@ class u {
679
703
  }
680
704
  __removeNode(e, t = !1) {
681
705
  const i = this.nodes.findIndex((s) => s.id === e.id);
682
- i > -1 && (this.nodes.splice(i, 1), t || n.emit(d, this));
706
+ i > -1 && (this.nodes.splice(i, 1), t || n.emit(o, this));
683
707
  }
684
708
  /**
685
709
  * 删除节点
@@ -709,7 +733,7 @@ class u {
709
733
  e.movePrev(t);
710
734
  else {
711
735
  const i = this.nodes, s = i.indexOf(e);
712
- s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(d, this));
736
+ s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(o, this));
713
737
  }
714
738
  }
715
739
  /**
@@ -722,7 +746,7 @@ class u {
722
746
  e.moveNext(t);
723
747
  else {
724
748
  const i = this.nodes, s = i.indexOf(e);
725
- s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(d, this));
749
+ s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(o, this));
726
750
  }
727
751
  }
728
752
  /**
@@ -732,20 +756,20 @@ class u {
732
756
  * @returns
733
757
  */
734
758
  cloneNode(e, t = !1) {
735
- const i = D(e.toDsl()), s = new p(i);
759
+ const i = B(e.toDsl()), s = new p(i);
736
760
  return this.addNode(s, e, "bottom", t), s;
737
761
  }
738
762
  lock(e = !1) {
739
763
  this.locked = !0;
740
764
  for (const t of this.nodes)
741
765
  t.lock(!0);
742
- e || n.emit(d, this);
766
+ e || n.emit(o, this);
743
767
  }
744
768
  unlock(e = !1) {
745
769
  this.locked = !1;
746
770
  for (const t of this.nodes)
747
771
  t.unlock(!0);
748
- e || n.emit(d, this);
772
+ e || n.emit(o, this);
749
773
  }
750
774
  isChild(e) {
751
775
  let t = !1;
@@ -758,8 +782,8 @@ class u {
758
782
  return t;
759
783
  }
760
784
  }
761
- const f = "EVENT_PROJECT_CHANGE", V = "EVENT_PROJECT_ACTIVED", I = "EVENT_PROJECT_DEPS_CHANGE", A = "EVENT_PROJECT_PAGES_CHANGE", g = "EVENT_PROJECT_BLOCKS_CHANGE", k = "EVENT_PROJECT_APIS_CHANGE", B = "EVENT_PROJECT_PUBLISH", J = "EVENT_PROJECT_FILE_PUBLISH";
762
- class T {
785
+ const f = "EVENT_PROJECT_CHANGE", P = "EVENT_PROJECT_ACTIVED", V = "EVENT_PROJECT_DEPS_CHANGE", y = "EVENT_PROJECT_PAGES_CHANGE", C = "EVENT_PROJECT_BLOCKS_CHANGE", R = "EVENT_PROJECT_APIS_CHANGE", J = "EVENT_PROJECT_PUBLISH", G = "EVENT_PROJECT_FILE_PUBLISH";
786
+ class O {
763
787
  id = "";
764
788
  name = "";
765
789
  description = "";
@@ -783,7 +807,7 @@ class T {
783
807
  this.id = t || m(), this.update(e, !0);
784
808
  }
785
809
  update(e, t = !1) {
786
- for (const i of T.attrs) {
810
+ for (const i of O.attrs) {
787
811
  const s = e[i];
788
812
  s && (this[i] = s);
789
813
  }
@@ -797,7 +821,7 @@ class T {
797
821
  return e.type === "page";
798
822
  }
799
823
  toDsl(e) {
800
- const { id: t } = this, i = T.attrs.reduce(
824
+ const { id: t } = this, i = O.attrs.reduce(
801
825
  (s, r) => (s[r] = this[r], s),
802
826
  {}
803
827
  );
@@ -814,7 +838,7 @@ class T {
814
838
  * @param silent
815
839
  */
816
840
  active(e, t = !1) {
817
- this.currentFile = e, t || n.emit(V, {
841
+ this.currentFile = e, t || n.emit(P, {
818
842
  model: this,
819
843
  type: "update",
820
844
  data: e
@@ -825,7 +849,7 @@ class T {
825
849
  * @param silent
826
850
  */
827
851
  deactivate(e = !1) {
828
- this.currentFile = null, e || n.emit(V, {
852
+ this.currentFile = null, e || n.emit(P, {
829
853
  model: this,
830
854
  type: "update",
831
855
  data: null
@@ -848,7 +872,7 @@ class T {
848
872
  type: r,
849
873
  data: e
850
874
  };
851
- n.emit(I, a), n.emit(f, a);
875
+ n.emit(V, a), n.emit(f, a);
852
876
  }
853
877
  }
854
878
  /**
@@ -864,7 +888,7 @@ class T {
864
888
  type: "delete",
865
889
  data: e
866
890
  };
867
- n.emit(I, r), n.emit(f, r);
891
+ n.emit(V, r), n.emit(f, r);
868
892
  }
869
893
  }
870
894
  /**
@@ -908,7 +932,7 @@ class T {
908
932
  createPage(e, t, i = !1) {
909
933
  if (e.id = e.raw ? e.name : e.id || m(), e.type = "page", e.dir ? e.children = [] : e.dsl = e.dsl || new u({
910
934
  id: e.id,
911
- name: P(e.name)
935
+ name: I(e.name)
912
936
  }).toDsl(), t) {
913
937
  const s = this.getPage(t);
914
938
  s ? s.children ? s.children.push(e) : s.children = [e] : console.warn(`not found PageFile for id: ${t} `);
@@ -920,7 +944,7 @@ class T {
920
944
  type: "create",
921
945
  data: e
922
946
  };
923
- n.emit(A, s), n.emit(f, s);
947
+ n.emit(y, s), n.emit(f, s);
924
948
  }
925
949
  }
926
950
  /**
@@ -936,7 +960,7 @@ class T {
936
960
  type: "update",
937
961
  data: e
938
962
  };
939
- n.emit(A, s), n.emit(f, s);
963
+ n.emit(y, s), n.emit(f, s);
940
964
  }
941
965
  }
942
966
  /**
@@ -949,9 +973,9 @@ class T {
949
973
  const s = m(), r = `${e.name}Copy`, a = `${e.title}_副本`, l = new u({
950
974
  id: s,
951
975
  name: r
952
- }).toDsl(), c = b({}, e, { id: s, name: r, title: a, dsl: l }), E = t ? this.getPage(t)?.children || [] : this.pages, C = E.findIndex((v) => v.id === e.id);
953
- if (E.splice(C + 1, 0, c), !i) {
954
- const v = {
976
+ }).toDsl(), c = H({}, e, { id: s, name: r, title: a, dsl: l }), E = t ? this.getPage(t)?.children || [] : this.pages, T = E.findIndex((_) => _.id === e.id);
977
+ if (E.splice(T + 1, 0, c), !i) {
978
+ const _ = {
955
979
  model: this,
956
980
  type: "clone",
957
981
  data: {
@@ -959,7 +983,7 @@ class T {
959
983
  newPage: c
960
984
  }
961
985
  };
962
- n.emit(A, v), n.emit(f, v);
986
+ n.emit(y, _), n.emit(f, _);
963
987
  }
964
988
  }
965
989
  /**
@@ -984,7 +1008,7 @@ class T {
984
1008
  type: "delete",
985
1009
  data: i
986
1010
  };
987
- n.emit(A, r), n.emit(f, r);
1011
+ n.emit(y, r), n.emit(f, r);
988
1012
  }
989
1013
  }
990
1014
  /**
@@ -1001,14 +1025,14 @@ class T {
1001
1025
  * @param silent
1002
1026
  */
1003
1027
  createBlock(e, t = !1) {
1004
- const i = e.id || m(), s = P(e.name);
1028
+ const i = e.id || m(), s = I(e.name);
1005
1029
  if (e.id = i, e.type = "block", e.dsl = new u({ id: i, name: s }).toDsl(), this.blocks.push(e), this.currentFile || this.active(e, t), !t) {
1006
1030
  const r = {
1007
1031
  model: this,
1008
1032
  type: "create",
1009
1033
  data: e
1010
1034
  };
1011
- n.emit(g, r), n.emit(f, r);
1035
+ n.emit(C, r), n.emit(f, r);
1012
1036
  }
1013
1037
  }
1014
1038
  /**
@@ -1024,7 +1048,7 @@ class T {
1024
1048
  type: "update",
1025
1049
  data: e
1026
1050
  };
1027
- n.emit(g, s), n.emit(f, s);
1051
+ n.emit(C, s), n.emit(f, s);
1028
1052
  }
1029
1053
  }
1030
1054
  /**
@@ -1040,7 +1064,7 @@ class T {
1040
1064
  type: "delete",
1041
1065
  data: i
1042
1066
  };
1043
- n.emit(g, a), n.emit(f, a);
1067
+ n.emit(C, a), n.emit(f, a);
1044
1068
  }
1045
1069
  }
1046
1070
  /**
@@ -1077,7 +1101,7 @@ class T {
1077
1101
  type: s,
1078
1102
  data: e
1079
1103
  };
1080
- n.emit(k, r), n.emit(f, r);
1104
+ n.emit(R, r), n.emit(f, r);
1081
1105
  }
1082
1106
  }
1083
1107
  /**
@@ -1093,7 +1117,7 @@ class T {
1093
1117
  type: "delete",
1094
1118
  data: e
1095
1119
  };
1096
- n.emit(k, s), n.emit(f, s);
1120
+ n.emit(R, s), n.emit(f, s);
1097
1121
  }
1098
1122
  }
1099
1123
  existApiName(e, t = []) {
@@ -1115,11 +1139,11 @@ class T {
1115
1139
  type: "publish",
1116
1140
  data: e || this
1117
1141
  };
1118
- e ? n.emit(J, t) : n.emit(B, t);
1142
+ e ? n.emit(G, t) : n.emit(J, t);
1119
1143
  }
1120
1144
  }
1121
- const N = "EVENT_HISTORY_CHANGE", O = "EVENT_HISTORY_LOAD";
1122
- class $ {
1145
+ const N = "EVENT_HISTORY_CHANGE", g = "EVENT_HISTORY_LOAD";
1146
+ class z {
1123
1147
  options = { max: 50 };
1124
1148
  index = -1;
1125
1149
  id;
@@ -1153,7 +1177,7 @@ class $ {
1153
1177
  const { max: i } = this.options, s = {
1154
1178
  id: m(),
1155
1179
  label: (/* @__PURE__ */ new Date()).toLocaleString(),
1156
- dsl: H(e)
1180
+ dsl: w(e)
1157
1181
  };
1158
1182
  if (this.items.unshift(s), this.items.length > i) {
1159
1183
  const r = this.items.splice(i);
@@ -1188,7 +1212,7 @@ class $ {
1188
1212
  return;
1189
1213
  --this.index;
1190
1214
  const s = i[this.index];
1191
- s && !e && n.emit(O, {
1215
+ s && !e && n.emit(g, {
1192
1216
  model: this,
1193
1217
  type: "load",
1194
1218
  data: s
@@ -1200,7 +1224,7 @@ class $ {
1200
1224
  return;
1201
1225
  t < 0 && (this.index = 0), ++this.index;
1202
1226
  const s = i[this.index];
1203
- s && !e && n.emit(O, {
1227
+ s && !e && n.emit(g, {
1204
1228
  model: this,
1205
1229
  type: "load",
1206
1230
  data: s
@@ -1208,7 +1232,7 @@ class $ {
1208
1232
  }
1209
1233
  load(e, t = !1) {
1210
1234
  const i = this.items.findIndex((s) => s.id === e);
1211
- i >= 0 && (this.index = i, t || n.emit(O, {
1235
+ i >= 0 && (this.index = i, t || n.emit(g, {
1212
1236
  model: this,
1213
1237
  type: "load",
1214
1238
  data: this.items[i]
@@ -1224,45 +1248,52 @@ class $ {
1224
1248
  });
1225
1249
  }
1226
1250
  }
1227
- const n = w();
1228
- function K(h) {
1251
+ const n = L();
1252
+ function Q(h) {
1229
1253
  return h instanceof u;
1230
1254
  }
1231
- function U(h) {
1255
+ function X(h) {
1232
1256
  return h instanceof p;
1233
1257
  }
1234
- function Y(h) {
1258
+ function Z(h) {
1235
1259
  return !!h.__VTJ_BLOCK__;
1236
1260
  }
1237
- function D(h) {
1238
- return delete h.id, Array.isArray(h.children) && (h.children = h.children.map((e) => D(e))), h;
1261
+ function B(h) {
1262
+ return delete h.id, Array.isArray(h.children) && (h.children = h.children.map((e) => B(e))), h;
1239
1263
  }
1240
1264
  export {
1241
- L as Base,
1265
+ Y as BUILT_IN_COMPONENTS,
1266
+ $ as BUILT_IN_LIBRARAY_MAP,
1267
+ K as BUILT_IN_MATERIALS,
1268
+ j as BUILT_IN_NAME,
1269
+ M as BUILT_IN_TAGS,
1270
+ k as BUILT_IN_VUE,
1271
+ D as BUILT_IN_VUE_ROUTER,
1272
+ q as Base,
1242
1273
  u as BlockModel,
1243
- _ as DirectiveModel,
1244
- d as EVENT_BLOCK_CHANGE,
1274
+ v as DirectiveModel,
1275
+ o as EVENT_BLOCK_CHANGE,
1245
1276
  N as EVENT_HISTORY_CHANGE,
1246
- O as EVENT_HISTORY_LOAD,
1247
- o as EVENT_NODE_CHANGE,
1248
- V as EVENT_PROJECT_ACTIVED,
1249
- k as EVENT_PROJECT_APIS_CHANGE,
1250
- g as EVENT_PROJECT_BLOCKS_CHANGE,
1277
+ g as EVENT_HISTORY_LOAD,
1278
+ d as EVENT_NODE_CHANGE,
1279
+ P as EVENT_PROJECT_ACTIVED,
1280
+ R as EVENT_PROJECT_APIS_CHANGE,
1281
+ C as EVENT_PROJECT_BLOCKS_CHANGE,
1251
1282
  f as EVENT_PROJECT_CHANGE,
1252
- I as EVENT_PROJECT_DEPS_CHANGE,
1253
- J as EVENT_PROJECT_FILE_PUBLISH,
1254
- A as EVENT_PROJECT_PAGES_CHANGE,
1255
- B as EVENT_PROJECT_PUBLISH,
1256
- y as EventModel,
1257
- $ as HistoryModel,
1283
+ V as EVENT_PROJECT_DEPS_CHANGE,
1284
+ G as EVENT_PROJECT_FILE_PUBLISH,
1285
+ y as EVENT_PROJECT_PAGES_CHANGE,
1286
+ J as EVENT_PROJECT_PUBLISH,
1287
+ A as EventModel,
1288
+ z as HistoryModel,
1258
1289
  p as NodeModel,
1259
- T as ProjectModel,
1290
+ O as ProjectModel,
1260
1291
  x as PropModel,
1261
- j as Service,
1262
- G as VTJ_CORE_VERSION,
1263
- D as cloneDsl,
1292
+ W as Service,
1293
+ U as VTJ_CORE_VERSION,
1294
+ B as cloneDsl,
1264
1295
  n as emitter,
1265
- K as isBlock,
1266
- Y as isBlockSchema,
1267
- U as isNode
1296
+ Q as isBlock,
1297
+ Z as isBlockSchema,
1298
+ X as isNode
1268
1299
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/core",
3
3
  "private": false,
4
- "version": "0.7.13",
4
+ "version": "0.7.14",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "vue-tsc && vite build",
@@ -29,7 +29,7 @@
29
29
  "dist",
30
30
  "types"
31
31
  ],
32
- "gitHead": "010201b133340a84d345745a0ea351c98098fa14",
32
+ "gitHead": "8e69e3eea31f488f318f28013b7ef3df02ee8174",
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 内置物料名
3
+ */
4
+ export declare const BUILT_IN_NAME = "BuiltIn";
5
+ /**
6
+ * 内置 vue 组件物料名
7
+ */
8
+ export declare const BUILT_IN_VUE = "VueMaterial";
9
+ /**
10
+ * 内置 vue-router 组件物料名
11
+ */
12
+ export declare const BUILT_IN_VUE_ROUTER = "VueRouterMaterial";
13
+ /**
14
+ * 内置物料
15
+ */
16
+ export declare const BUILT_IN_MATERIALS: string[];
17
+ /**
18
+ * 内置类库包名和导出名映射
19
+ */
20
+ export declare const BUILT_IN_LIBRARAY_MAP: Record<string, string>;
21
+ /**
22
+ * 内置组件
23
+ */
24
+ export declare const BUILT_IN_COMPONENTS: Record<string, string[]>;
25
+ export declare const BUILT_IN_TAGS: string[];
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { version as VTJ_CORE_VERSION } from './version';
2
+ export * from './constants';
2
3
  export * from './protocols';
3
4
  export * from './tools';
4
5
  export * from './models';