@vtj/core 0.8.38 → 0.8.39

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
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@vtj/base");/**!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@vtj/base");/**!
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.8.38
5
+ * @version 0.8.39
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const b="0.8.38",J="BuiltIn",R="VueMaterial",B="VueRouterMaterial",G=[R,B],U={vue:"Vue","vue-router":"VueRouter"},w={[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 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 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: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 v(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||c.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 E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:a,iterator:f,id:m}=t;return{id:m,name:i,arg:s,modifiers:r,value:a,iterator:f}})}}const l="EVENT_NODE_CHANGE";class p{constructor(e,t=null){this.parent=t;const{id:i=c.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:a,props:f={},events:m={},directives:_=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(a,!0),this.props=N.parse(f),this.events=v.parse(m),this.directives=E.parse(_),t||n.emit(l,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new p(i,this)):this.children=e,t||n.emit(l,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(l,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(l,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(l,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(l,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(l,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(l,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(l,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(l,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(l,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(l,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(l,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(l,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(l,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:f,props:m,directives:_,events:O}=this,T=Array.isArray(f)?f.map(D=>D.toDsl()):f;return{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:T,props:N.toDsl(m),directives:E.toDsl(_),events:v.toDsl(O)}}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(l,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(l,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(l,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(l,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 o="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||c.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(o,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((a,f)=>(a[f]=this[f],a),{}),__VTJ_BLOCK__:t,__VERSION__:e||c.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(o,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(o,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(o,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(o,this)}setCss(e,t=!1){this.css=e,t||n.emit(o,this)}setWatch(e,t=!1){e.id=e.id||c.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(o,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(o,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(o,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(o,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(o,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1&&(this.emits.splice(i,1),t||n.emit(o,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(o,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1&&(this.slots.splice(i,1),t||n.emit(o,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(o,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(o,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(o,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(o,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(o,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(o,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(o,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(o,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(o,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(o,this))}}cloneNode(e,t=!1){const i=H(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(o,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(o,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 h="EVENT_PROJECT_CHANGE",P="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",A="EVENT_PROJECT_PAGES_CHANGE",y="EVENT_PROJECT_BLOCKS_CHANGE",g="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",L="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH";class I{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};static attrs=["name","homepage","description","dependencies","pages","blocks","apis","meta","config"];constructor(e){const{id:t}=e;this.id=t||c.uid(),this.update(e,!0)}update(e,t=!1){for(const i of I.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(h,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}toDsl(e){const{id:t}=this,i=I.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||c.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(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(V,a),n.emit(h,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(V,r),n.emit(h,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||c.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:c.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(A,s),n.emit(h,s)}!this.currentFile&&!e.dir&&(await c.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(A,s),n.emit(h,s)}}clonePage(e,t,i=!1){const s=c.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,f=new u({id:s,name:r}).toDsl(),m=c.merge({},e,{id:s,name:r,title:a,dsl:f}),_=t?this.getPage(t)?.children||[]:this.pages,O=_.findIndex(T=>T.id===e.id);if(_.splice(O+1,0,m),!i){const T={model:this,type:"clone",data:{page:e,newPage:m}};n.emit(A,T),n.emit(h,T)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,a)=>{const f=a.findIndex(m=>m.id===r);if(f>=0){a.splice(f,1);return}for(const m of a)if(m.children&&m.children.length)return s(r,m.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(h,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}async createBlock(e,t=!1){const i=e.id||c.uid(),s=c.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(y,a),n.emit(h,a)}!this.currentFile&&r==="Schema"&&(await c.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(y,s),n.emit(h,s)}}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(y,a),n.emit(h,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=c.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(g,r),n.emit(h,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(h,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=c.uid(),this.meta.push(e)),!t){const r={model:this,type:s,data:e};n.emit(S,r),n.emit(h,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(h,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(h,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(h,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(L,t)}}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:c.uid(),label:new Date().toLocaleString(),dsl:c.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=c.mitt();function $(d){return d instanceof u}function Y(d){return d instanceof p}function W(d){return!!d.__VTJ_BLOCK__}function H(d){return delete d.id,Array.isArray(d.children)&&(d.children=d.children.map(e=>H(e))),d}function q(d){const e=d.fromType||"Schema";return e==="Schema"?{type:"Schema",id:d.id}:e==="UrlSchema"?{type:"UrlSchema",url:(d.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(d.urls||"").split(","),library:d.library}:""}exports.BUILT_IN_COMPONENTS=w;exports.BUILT_IN_LIBRARAY_MAP=U;exports.BUILT_IN_MATERIALS=G;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=E;exports.EVENT_BLOCK_CHANGE=o;exports.EVENT_HISTORY_CHANGE=C;exports.EVENT_HISTORY_LOAD=x;exports.EVENT_NODE_CHANGE=l;exports.EVENT_PROJECT_ACTIVED=P;exports.EVENT_PROJECT_APIS_CHANGE=g;exports.EVENT_PROJECT_BLOCKS_CHANGE=y;exports.EVENT_PROJECT_CHANGE=h;exports.EVENT_PROJECT_DEPS_CHANGE=V;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=A;exports.EVENT_PROJECT_PUBLISH=L;exports.EventModel=v;exports.HistoryModel=K;exports.NodeModel=p;exports.ProjectModel=I;exports.PropModel=N;exports.Service=M;exports.VTJ_CORE_VERSION=b;exports.cloneDsl=H;exports.createNodeFrom=q;exports.emitter=n;exports.isBlock=$;exports.isBlockSchema=W;exports.isNode=Y;
7
+ */const b="0.8.39",J="BuiltIn",R="VueMaterial",B="VueRouterMaterial",G=[R,B],U={vue:"Vue","vue-router":"VueRouter"},w={[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 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 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: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 v(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||d.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 E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:a,iterator:f,id:m}=t;return{id:m,name:i,arg:s,modifiers:r,value:a,iterator:f}})}}const c="EVENT_NODE_CHANGE";class p{constructor(e,t=null){this.parent=t;const{id:i=d.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:a,props:f={},events:m={},directives:_=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(a,!0),this.props=N.parse(f),this.events=v.parse(m),this.directives=E.parse(_),t||n.emit(c,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new p(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 N(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 v(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(e)):this.directives.push(new E(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:f,props:m,directives:_,events:O}=this,T=Array.isArray(f)?f.map(D=>D.toDsl()):f;return{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:T,props:N.toDsl(m),directives:E.toDsl(_),events:v.toDsl(O)}}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 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(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 o="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||d.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(o,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((a,f)=>(a[f]=this[f],a),{}),__VTJ_BLOCK__:t,__VERSION__:e||d.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(o,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(o,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(o,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(o,this)}setCss(e,t=!1){this.css=e,t||n.emit(o,this)}setWatch(e,t=!1){e.id=e.id||d.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(o,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(o,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(o,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(o,this))}setEmit(e,t=!1){const i=d.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(o,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>d.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(o,this))}setSlot(e,t=!1){const i=d.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(o,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>d.isString(s)?s===e:s.name===e);i>-1&&(this.slots.splice(i,1),t||n.emit(o,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(o,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(o,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(o,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(o,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(o,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(o,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(o,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(o,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(o,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(o,this))}}cloneNode(e,t=!1){const i=H(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(o,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(o,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 h="EVENT_PROJECT_CHANGE",P="EVENT_PROJECT_ACTIVED",g="EVENT_PROJECT_DEPS_CHANGE",A="EVENT_PROJECT_PAGES_CHANGE",y="EVENT_PROJECT_BLOCKS_CHANGE",V="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",L="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH";class I{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};static attrs=["name","homepage","description","dependencies","pages","blocks","apis","meta","config"];constructor(e){const{id:t}=e;this.id=t||d.uid(),this.update(e,!0)}update(e,t=!1){for(const i of I.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(h,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}toDsl(e){const{id:t}=this,i=I.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||d.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(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(h,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(h,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||d.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:d.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(A,s),n.emit(h,s)}!this.currentFile&&!e.dir&&(await d.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(A,s),n.emit(h,s)}}clonePage(e,t,i=!1){const s=d.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,f=new u({id:s,name:r}).toDsl(),m=d.merge({},e,{id:s,name:r,title:a,dsl:f}),_=t?this.getPage(t)?.children||[]:this.pages,O=_.findIndex(T=>T.id===e.id);if(_.splice(O+1,0,m),!i){const T={model:this,type:"clone",data:{page:e,newPage:m}};n.emit(A,T),n.emit(h,T)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,a)=>{const f=a.findIndex(m=>m.id===r);if(f>=0){a.splice(f,1);return}for(const m of a)if(m.children&&m.children.length)return s(r,m.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(h,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}async createBlock(e,t=!1){const i=e.id||d.uid(),s=d.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(y,a),n.emit(h,a)}!this.currentFile&&r==="Schema"&&(await d.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(y,s),n.emit(h,s)}}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(y,a),n.emit(h,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=d.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(V,r),n.emit(h,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(h,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=d.uid(),this.meta.push(e)),!t){const r={model:this,type:s,data:e};n.emit(S,r),n.emit(h,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(h,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(h,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(h,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(L,t)}}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:d.uid(),label:new Date().toLocaleString(),dsl:d.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=d.mitt();function $(l){return l instanceof u}function Y(l){return l instanceof p}function W(l){return!!l.__VTJ_BLOCK__}function H(l){return delete l.id,Array.isArray(l.children)&&(l.children=l.children.map(e=>H(e))),l}function q(l){const e=l.fromType||"Schema";return e==="Schema"?{type:"Schema",id:l.id}:e==="UrlSchema"?{type:"UrlSchema",url:(l.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(l.urls||"").split(","),library:l.library}:""}exports.BUILT_IN_COMPONENTS=w;exports.BUILT_IN_LIBRARAY_MAP=U;exports.BUILT_IN_MATERIALS=G;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=E;exports.EVENT_BLOCK_CHANGE=o;exports.EVENT_HISTORY_CHANGE=C;exports.EVENT_HISTORY_LOAD=x;exports.EVENT_NODE_CHANGE=c;exports.EVENT_PROJECT_ACTIVED=P;exports.EVENT_PROJECT_APIS_CHANGE=V;exports.EVENT_PROJECT_BLOCKS_CHANGE=y;exports.EVENT_PROJECT_CHANGE=h;exports.EVENT_PROJECT_DEPS_CHANGE=g;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=A;exports.EVENT_PROJECT_PUBLISH=L;exports.EventModel=v;exports.HistoryModel=K;exports.NodeModel=p;exports.ProjectModel=I;exports.PropModel=N;exports.Service=M;exports.VTJ_CORE_VERSION=b;exports.cloneDsl=H;exports.createNodeFrom=q;exports.emitter=n;exports.isBlock=$;exports.isBlockSchema=W;exports.isNode=Y;
package/dist/index.mjs CHANGED
@@ -1,24 +1,24 @@
1
- import { uid as m, timestamp as D, upperFirstCamelCase as I, delay as P, merge as L, cloneDeep as J, mitt as G } from "@vtj/base";
1
+ import { uid as m, timestamp as b, isString as A, upperFirstCamelCase as P, delay as V, merge as J, cloneDeep as G, mitt as F } 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.8.38
6
+ * @version 0.8.39
7
7
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
8
8
  */
9
- const $ = "0.8.38", K = "BuiltIn", b = "VueMaterial", B = "VueRouterMaterial", M = [b, B], Y = {
9
+ const K = "0.8.39", M = "BuiltIn", B = "VueMaterial", w = "VueRouterMaterial", Y = [B, w], W = {
10
10
  vue: "Vue",
11
11
  "vue-router": "VueRouter"
12
- }, W = {
13
- [b]: [
12
+ }, q = {
13
+ [B]: [
14
14
  "Transition",
15
15
  "TransitionGroup",
16
16
  "KeepAlive",
17
17
  "Teleport",
18
18
  "Suspense"
19
19
  ],
20
- [B]: ["RouterView", "RouterLink"]
21
- }, q = [
20
+ [w]: ["RouterView", "RouterLink"]
21
+ }, z = [
22
22
  "slot",
23
23
  "template",
24
24
  "component",
@@ -31,9 +31,9 @@ const $ = "0.8.38", K = "BuiltIn", b = "VueMaterial", B = "VueRouterMaterial", M
31
31
  "span",
32
32
  "a"
33
33
  ];
34
- class z {
35
- }
36
34
  class Q {
35
+ }
36
+ class X {
37
37
  listeners = [];
38
38
  isReady = !1;
39
39
  triggerReady() {
@@ -395,8 +395,8 @@ class p {
395
395
  children: c,
396
396
  props: f,
397
397
  directives: E,
398
- events: T
399
- } = this, _ = Array.isArray(c) ? c.map((H) => H.toDsl()) : c;
398
+ events: g
399
+ } = this, _ = Array.isArray(c) ? c.map((L) => L.toDsl()) : c;
400
400
  return {
401
401
  id: e,
402
402
  name: t,
@@ -407,7 +407,7 @@ class p {
407
407
  children: _,
408
408
  props: x.toDsl(f),
409
409
  directives: v.toDsl(E),
410
- events: y.toDsl(T)
410
+ events: y.toDsl(g)
411
411
  };
412
412
  }
413
413
  /**
@@ -508,7 +508,7 @@ class u {
508
508
  {}
509
509
  ),
510
510
  __VTJ_BLOCK__: t,
511
- __VERSION__: e || D().toString(),
511
+ __VERSION__: e || b().toString(),
512
512
  id: i,
513
513
  nodes: s.map((a) => a.toDsl())
514
514
  };
@@ -614,8 +614,8 @@ class u {
614
614
  * @param silent
615
615
  */
616
616
  setEmit(e, t = !1) {
617
- const i = this.emits.findIndex((s) => s === e);
618
- i > -1 ? this.emits.splice(i, 1, e) : this.emits.push(e), t || n.emit(o, this);
617
+ const i = A(e) ? { name: e, params: [] } : e, s = this.emits.findIndex((r) => r === i.name || r === i);
618
+ s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(o, this);
619
619
  }
620
620
  /**
621
621
  * 删除事件
@@ -623,7 +623,9 @@ class u {
623
623
  * @param silent
624
624
  */
625
625
  removeEmit(e, t = !1) {
626
- const i = this.emits.findIndex((s) => s === e);
626
+ const i = this.emits.findIndex(
627
+ (s) => A(s) ? s === e : s.name === e
628
+ );
627
629
  i > -1 && (this.emits.splice(i, 1), t || n.emit(o, this));
628
630
  }
629
631
  /**
@@ -632,8 +634,8 @@ class u {
632
634
  * @param silent
633
635
  */
634
636
  setSlot(e, t = !1) {
635
- const i = this.slots.findIndex((s) => s === e);
636
- i > -1 ? this.slots.splice(i, 1, e) : this.slots.push(e), t || n.emit(o, this);
637
+ const i = A(e) ? { name: e, params: [] } : e, s = this.slots.findIndex((r) => r === i.name || r === i);
638
+ s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(o, this);
637
639
  }
638
640
  /**
639
641
  * 删除插槽
@@ -641,7 +643,9 @@ class u {
641
643
  * @param silent
642
644
  */
643
645
  removeSlot(e, t = !1) {
644
- const i = this.slots.findIndex((s) => s === e);
646
+ const i = this.slots.findIndex(
647
+ (s) => A(s) ? s === e : s.name === e
648
+ );
645
649
  i > -1 && (this.slots.splice(i, 1), t || n.emit(o, this));
646
650
  }
647
651
  /**
@@ -756,7 +760,7 @@ class u {
756
760
  * @returns
757
761
  */
758
762
  cloneNode(e, t = !1) {
759
- const i = w(e.toDsl()), s = new p(i);
763
+ const i = H(e.toDsl()), s = new p(i);
760
764
  return this.addNode(s, e, "bottom", t), s;
761
765
  }
762
766
  lock(e = !1) {
@@ -782,8 +786,8 @@ class u {
782
786
  return t;
783
787
  }
784
788
  }
785
- const h = "EVENT_PROJECT_CHANGE", V = "EVENT_PROJECT_ACTIVED", S = "EVENT_PROJECT_DEPS_CHANGE", A = "EVENT_PROJECT_PAGES_CHANGE", g = "EVENT_PROJECT_BLOCKS_CHANGE", R = "EVENT_PROJECT_APIS_CHANGE", k = "EVENT_PROJECT_META_CHANGE", F = "EVENT_PROJECT_PUBLISH", U = "EVENT_PROJECT_FILE_PUBLISH";
786
- class O {
789
+ const h = "EVENT_PROJECT_CHANGE", S = "EVENT_PROJECT_ACTIVED", R = "EVENT_PROJECT_DEPS_CHANGE", N = "EVENT_PROJECT_PAGES_CHANGE", C = "EVENT_PROJECT_BLOCKS_CHANGE", k = "EVENT_PROJECT_APIS_CHANGE", D = "EVENT_PROJECT_META_CHANGE", U = "EVENT_PROJECT_PUBLISH", j = "EVENT_PROJECT_FILE_PUBLISH";
790
+ class I {
787
791
  id = "";
788
792
  name = "";
789
793
  description = "";
@@ -811,7 +815,7 @@ class O {
811
815
  this.id = t || m(), this.update(e, !0);
812
816
  }
813
817
  update(e, t = !1) {
814
- for (const i of O.attrs) {
818
+ for (const i of I.attrs) {
815
819
  const s = e[i];
816
820
  s && (this[i] = s);
817
821
  }
@@ -825,13 +829,13 @@ class O {
825
829
  return e.type === "page";
826
830
  }
827
831
  toDsl(e) {
828
- const { id: t } = this, i = O.attrs.reduce(
832
+ const { id: t } = this, i = I.attrs.reduce(
829
833
  (s, r) => (s[r] = this[r], s),
830
834
  {}
831
835
  );
832
836
  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))), {
833
837
  __VTJ_PROJECT__: !0,
834
- __VERSION__: e || D().toString(),
838
+ __VERSION__: e || b().toString(),
835
839
  id: t,
836
840
  ...i
837
841
  };
@@ -842,7 +846,7 @@ class O {
842
846
  * @param silent
843
847
  */
844
848
  active(e, t = !1) {
845
- this.currentFile = e, t || n.emit(V, {
849
+ this.currentFile = e, t || n.emit(S, {
846
850
  model: this,
847
851
  type: "update",
848
852
  data: e
@@ -853,7 +857,7 @@ class O {
853
857
  * @param silent
854
858
  */
855
859
  deactivate(e = !1) {
856
- this.currentFile = null, e || n.emit(V, {
860
+ this.currentFile = null, e || n.emit(S, {
857
861
  model: this,
858
862
  type: "update",
859
863
  data: null
@@ -876,7 +880,7 @@ class O {
876
880
  type: r,
877
881
  data: e
878
882
  };
879
- n.emit(S, a), n.emit(h, a);
883
+ n.emit(R, a), n.emit(h, a);
880
884
  }
881
885
  }
882
886
  /**
@@ -892,7 +896,7 @@ class O {
892
896
  type: "delete",
893
897
  data: e
894
898
  };
895
- n.emit(S, r), n.emit(h, r);
899
+ n.emit(R, r), n.emit(h, r);
896
900
  }
897
901
  }
898
902
  /**
@@ -936,7 +940,7 @@ class O {
936
940
  async createPage(e, t, i = !1) {
937
941
  if (e.id = e.raw ? e.name : e.id || m(), e.type = "page", e.dir ? e.children = [] : e.dsl = e.dsl || new u({
938
942
  id: e.id,
939
- name: I(e.name)
943
+ name: P(e.name)
940
944
  }).toDsl(), t) {
941
945
  const s = this.getPage(t);
942
946
  s ? s.children ? s.children.push(e) : s.children = [e] : console.warn(`not found PageFile for id: ${t} `);
@@ -948,9 +952,9 @@ class O {
948
952
  type: "create",
949
953
  data: e
950
954
  };
951
- n.emit(A, s), n.emit(h, s);
955
+ n.emit(N, s), n.emit(h, s);
952
956
  }
953
- !this.currentFile && !e.dir && (await P(1e3), this.active(e, i));
957
+ !this.currentFile && !e.dir && (await V(1e3), this.active(e, i));
954
958
  }
955
959
  /**
956
960
  * 更新页面
@@ -965,7 +969,7 @@ class O {
965
969
  type: "update",
966
970
  data: e
967
971
  };
968
- n.emit(A, s), n.emit(h, s);
972
+ n.emit(N, s), n.emit(h, s);
969
973
  }
970
974
  }
971
975
  /**
@@ -978,8 +982,8 @@ class O {
978
982
  const s = m(), r = `${e.name}Copy`, a = `${e.title}_副本`, c = new u({
979
983
  id: s,
980
984
  name: r
981
- }).toDsl(), f = L({}, e, { id: s, name: r, title: a, dsl: c }), E = t ? this.getPage(t)?.children || [] : this.pages, T = E.findIndex((_) => _.id === e.id);
982
- if (E.splice(T + 1, 0, f), !i) {
985
+ }).toDsl(), f = J({}, e, { id: s, name: r, title: a, dsl: c }), E = t ? this.getPage(t)?.children || [] : this.pages, g = E.findIndex((_) => _.id === e.id);
986
+ if (E.splice(g + 1, 0, f), !i) {
983
987
  const _ = {
984
988
  model: this,
985
989
  type: "clone",
@@ -988,7 +992,7 @@ class O {
988
992
  newPage: f
989
993
  }
990
994
  };
991
- n.emit(A, _), n.emit(h, _);
995
+ n.emit(N, _), n.emit(h, _);
992
996
  }
993
997
  }
994
998
  /**
@@ -1013,7 +1017,7 @@ class O {
1013
1017
  type: "delete",
1014
1018
  data: i
1015
1019
  };
1016
- n.emit(A, r), n.emit(h, r);
1020
+ n.emit(N, r), n.emit(h, r);
1017
1021
  }
1018
1022
  }
1019
1023
  /**
@@ -1030,7 +1034,7 @@ class O {
1030
1034
  * @param silent
1031
1035
  */
1032
1036
  async createBlock(e, t = !1) {
1033
- const i = e.id || m(), s = I(e.name);
1037
+ const i = e.id || m(), s = P(e.name);
1034
1038
  e.id = i, e.type = "block", e.dsl = new u({ id: i, name: s }).toDsl(), this.blocks.push(e);
1035
1039
  const r = e.fromType || "Schema";
1036
1040
  if (!t) {
@@ -1039,9 +1043,9 @@ class O {
1039
1043
  type: "create",
1040
1044
  data: e
1041
1045
  };
1042
- n.emit(g, a), n.emit(h, a);
1046
+ n.emit(C, a), n.emit(h, a);
1043
1047
  }
1044
- !this.currentFile && r === "Schema" && (await P(1e3), this.active(e, t));
1048
+ !this.currentFile && r === "Schema" && (await V(1e3), this.active(e, t));
1045
1049
  }
1046
1050
  /**
1047
1051
  *
@@ -1056,7 +1060,7 @@ class O {
1056
1060
  type: "update",
1057
1061
  data: e
1058
1062
  };
1059
- n.emit(g, s), n.emit(h, s);
1063
+ n.emit(C, s), n.emit(h, s);
1060
1064
  }
1061
1065
  }
1062
1066
  /**
@@ -1072,7 +1076,7 @@ class O {
1072
1076
  type: "delete",
1073
1077
  data: i
1074
1078
  };
1075
- n.emit(g, a), n.emit(h, a);
1079
+ n.emit(C, a), n.emit(h, a);
1076
1080
  }
1077
1081
  }
1078
1082
  /**
@@ -1109,7 +1113,7 @@ class O {
1109
1113
  type: s,
1110
1114
  data: e
1111
1115
  };
1112
- n.emit(R, r), n.emit(h, r);
1116
+ n.emit(k, r), n.emit(h, r);
1113
1117
  }
1114
1118
  }
1115
1119
  /**
@@ -1125,7 +1129,7 @@ class O {
1125
1129
  type: "delete",
1126
1130
  data: e
1127
1131
  };
1128
- n.emit(R, s), n.emit(h, s);
1132
+ n.emit(k, s), n.emit(h, s);
1129
1133
  }
1130
1134
  }
1131
1135
  existApiName(e, t = []) {
@@ -1142,7 +1146,7 @@ class O {
1142
1146
  type: s,
1143
1147
  data: e
1144
1148
  };
1145
- n.emit(k, r), n.emit(h, r);
1149
+ n.emit(D, r), n.emit(h, r);
1146
1150
  }
1147
1151
  }
1148
1152
  removeMeta(e, t = !1) {
@@ -1153,7 +1157,7 @@ class O {
1153
1157
  type: "delete",
1154
1158
  data: e
1155
1159
  };
1156
- n.emit(k, s), n.emit(h, s);
1160
+ n.emit(D, s), n.emit(h, s);
1157
1161
  }
1158
1162
  }
1159
1163
  existMetaCode(e, t = []) {
@@ -1185,11 +1189,11 @@ class O {
1185
1189
  type: "publish",
1186
1190
  data: e || this
1187
1191
  };
1188
- e ? n.emit(U, t) : n.emit(F, t);
1192
+ e ? n.emit(j, t) : n.emit(U, t);
1189
1193
  }
1190
1194
  }
1191
- const N = "EVENT_HISTORY_CHANGE", C = "EVENT_HISTORY_LOAD";
1192
- class X {
1195
+ const T = "EVENT_HISTORY_CHANGE", O = "EVENT_HISTORY_LOAD";
1196
+ class Z {
1193
1197
  options = { max: 50 };
1194
1198
  index = -1;
1195
1199
  id;
@@ -1223,17 +1227,17 @@ class X {
1223
1227
  const { max: i } = this.options, s = {
1224
1228
  id: m(),
1225
1229
  label: (/* @__PURE__ */ new Date()).toLocaleString(),
1226
- dsl: J(e)
1230
+ dsl: G(e)
1227
1231
  };
1228
1232
  if (this.items.unshift(s), this.items.length > i) {
1229
1233
  const r = this.items.splice(i);
1230
- t || n.emit(N, {
1234
+ t || n.emit(T, {
1231
1235
  model: this,
1232
1236
  type: "delete",
1233
1237
  data: r.map((a) => a.id)
1234
1238
  });
1235
1239
  }
1236
- this.index = -1, t || n.emit(N, {
1240
+ this.index = -1, t || n.emit(T, {
1237
1241
  model: this,
1238
1242
  type: "create",
1239
1243
  data: s
@@ -1246,7 +1250,7 @@ class X {
1246
1250
  */
1247
1251
  remove(e, t = !1) {
1248
1252
  const i = this.items.findIndex((s) => s.id === e);
1249
- 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(N, {
1253
+ 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, {
1250
1254
  model: this,
1251
1255
  type: "delete",
1252
1256
  data: [e]
@@ -1258,7 +1262,7 @@ class X {
1258
1262
  return;
1259
1263
  --this.index;
1260
1264
  const s = i[this.index];
1261
- s && !e && n.emit(C, {
1265
+ s && !e && n.emit(O, {
1262
1266
  model: this,
1263
1267
  type: "load",
1264
1268
  data: s
@@ -1270,7 +1274,7 @@ class X {
1270
1274
  return;
1271
1275
  t < 0 && (this.index = 0), ++this.index;
1272
1276
  const s = i[this.index];
1273
- s && !e && n.emit(C, {
1277
+ s && !e && n.emit(O, {
1274
1278
  model: this,
1275
1279
  type: "load",
1276
1280
  data: s
@@ -1278,7 +1282,7 @@ class X {
1278
1282
  }
1279
1283
  load(e, t = !1) {
1280
1284
  const i = this.items.findIndex((s) => s.id === e);
1281
- i >= 0 && (this.index = i, t || n.emit(C, {
1285
+ i >= 0 && (this.index = i, t || n.emit(O, {
1282
1286
  model: this,
1283
1287
  type: "load",
1284
1288
  data: this.items[i]
@@ -1287,27 +1291,27 @@ class X {
1287
1291
  clear(e = !1) {
1288
1292
  this.index = -1;
1289
1293
  const t = this.items.map((i) => i.id);
1290
- this.items = [], e || n.emit(N, {
1294
+ this.items = [], e || n.emit(T, {
1291
1295
  model: this,
1292
1296
  type: "clear",
1293
1297
  data: t
1294
1298
  });
1295
1299
  }
1296
1300
  }
1297
- const n = G();
1298
- function Z(d) {
1301
+ const n = F();
1302
+ function ee(d) {
1299
1303
  return d instanceof u;
1300
1304
  }
1301
- function ee(d) {
1305
+ function te(d) {
1302
1306
  return d instanceof p;
1303
1307
  }
1304
- function te(d) {
1308
+ function ie(d) {
1305
1309
  return !!d.__VTJ_BLOCK__;
1306
1310
  }
1307
- function w(d) {
1308
- return delete d.id, Array.isArray(d.children) && (d.children = d.children.map((e) => w(e))), d;
1311
+ function H(d) {
1312
+ return delete d.id, Array.isArray(d.children) && (d.children = d.children.map((e) => H(e))), d;
1309
1313
  }
1310
- function ie(d) {
1314
+ function se(d) {
1311
1315
  const e = d.fromType || "Schema";
1312
1316
  return e === "Schema" ? {
1313
1317
  type: "Schema",
@@ -1322,40 +1326,40 @@ function ie(d) {
1322
1326
  } : "";
1323
1327
  }
1324
1328
  export {
1325
- W as BUILT_IN_COMPONENTS,
1326
- Y as BUILT_IN_LIBRARAY_MAP,
1327
- M as BUILT_IN_MATERIALS,
1328
- K as BUILT_IN_NAME,
1329
- q as BUILT_IN_TAGS,
1330
- b as BUILT_IN_VUE,
1331
- B as BUILT_IN_VUE_ROUTER,
1332
- Q as Base,
1329
+ q as BUILT_IN_COMPONENTS,
1330
+ W as BUILT_IN_LIBRARAY_MAP,
1331
+ Y as BUILT_IN_MATERIALS,
1332
+ M as BUILT_IN_NAME,
1333
+ z as BUILT_IN_TAGS,
1334
+ B as BUILT_IN_VUE,
1335
+ w as BUILT_IN_VUE_ROUTER,
1336
+ X as Base,
1333
1337
  u as BlockModel,
1334
1338
  v as DirectiveModel,
1335
1339
  o as EVENT_BLOCK_CHANGE,
1336
- N as EVENT_HISTORY_CHANGE,
1337
- C as EVENT_HISTORY_LOAD,
1340
+ T as EVENT_HISTORY_CHANGE,
1341
+ O as EVENT_HISTORY_LOAD,
1338
1342
  l as EVENT_NODE_CHANGE,
1339
- V as EVENT_PROJECT_ACTIVED,
1340
- R as EVENT_PROJECT_APIS_CHANGE,
1341
- g as EVENT_PROJECT_BLOCKS_CHANGE,
1343
+ S as EVENT_PROJECT_ACTIVED,
1344
+ k as EVENT_PROJECT_APIS_CHANGE,
1345
+ C as EVENT_PROJECT_BLOCKS_CHANGE,
1342
1346
  h as EVENT_PROJECT_CHANGE,
1343
- S as EVENT_PROJECT_DEPS_CHANGE,
1344
- U as EVENT_PROJECT_FILE_PUBLISH,
1345
- k as EVENT_PROJECT_META_CHANGE,
1346
- A as EVENT_PROJECT_PAGES_CHANGE,
1347
- F as EVENT_PROJECT_PUBLISH,
1347
+ R as EVENT_PROJECT_DEPS_CHANGE,
1348
+ j as EVENT_PROJECT_FILE_PUBLISH,
1349
+ D as EVENT_PROJECT_META_CHANGE,
1350
+ N as EVENT_PROJECT_PAGES_CHANGE,
1351
+ U as EVENT_PROJECT_PUBLISH,
1348
1352
  y as EventModel,
1349
- X as HistoryModel,
1353
+ Z as HistoryModel,
1350
1354
  p as NodeModel,
1351
- O as ProjectModel,
1355
+ I as ProjectModel,
1352
1356
  x as PropModel,
1353
- z as Service,
1354
- $ as VTJ_CORE_VERSION,
1355
- w as cloneDsl,
1356
- ie as createNodeFrom,
1357
+ Q as Service,
1358
+ K as VTJ_CORE_VERSION,
1359
+ H as cloneDsl,
1360
+ se as createNodeFrom,
1357
1361
  n as emitter,
1358
- Z as isBlock,
1359
- te as isBlockSchema,
1360
- ee as isNode
1362
+ ee as isBlock,
1363
+ ie as isBlockSchema,
1364
+ te as isNode
1361
1365
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/core",
3
3
  "private": false,
4
- "version": "0.8.38",
4
+ "version": "0.8.39",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "@vtj/base": "~0.8.4"
@@ -1,4 +1,4 @@
1
- import { BlockSchema, BlockInject, BlockState, JSFunction, JSONValue, JSExpression, BlockWatch, BlockProp, DataSourceSchema } from '../protocols';
1
+ import { BlockSchema, BlockInject, BlockState, JSFunction, JSONValue, JSExpression, BlockWatch, BlockProp, DataSourceSchema, BlockEmit, BlockSlot } from '../protocols';
2
2
  import { NodeModel } from './node';
3
3
 
4
4
  /**
@@ -21,8 +21,8 @@ export declare class BlockModel {
21
21
  watch: BlockWatch[];
22
22
  css: string;
23
23
  props: Array<string | BlockProp>;
24
- emits: string[];
25
- slots: string[];
24
+ emits: Array<string | BlockEmit>;
25
+ slots: Array<string | BlockSlot>;
26
26
  dataSources: Record<string, DataSourceSchema>;
27
27
  nodes: NodeModel[];
28
28
  locked: boolean;
@@ -102,7 +102,7 @@ export declare class BlockModel {
102
102
  * @param emit
103
103
  * @param silent
104
104
  */
105
- setEmit(emit: string, silent?: boolean): void;
105
+ setEmit(emit: string | BlockEmit, silent?: boolean): void;
106
106
  /**
107
107
  * 删除事件
108
108
  * @param emit
@@ -114,7 +114,7 @@ export declare class BlockModel {
114
114
  * @param slot
115
115
  * @param silent
116
116
  */
117
- setSlot(slot: string, silent?: boolean): void;
117
+ setSlot(slot: string | BlockSlot, silent?: boolean): void;
118
118
  /**
119
119
  * 删除插槽
120
120
  * @param slot
@@ -50,11 +50,11 @@ export interface BlockSchema {
50
50
  /**
51
51
  * 定义事件
52
52
  */
53
- emits?: string[];
53
+ emits?: Array<string | BlockEmit>;
54
54
  /**
55
55
  * 定义插槽
56
56
  */
57
- slots?: string[];
57
+ slots?: Array<string | BlockSlot>;
58
58
  /**
59
59
  * 节点树
60
60
  */
@@ -105,3 +105,11 @@ export interface BlockProp {
105
105
  default?: JSONValue | JSExpression;
106
106
  }
107
107
  export type BlockPropDataType = 'String' | 'Number' | 'Boolean' | 'Array' | 'Object' | 'Function' | 'Date';
108
+ export interface BlockEmit {
109
+ name: string;
110
+ params: string[];
111
+ }
112
+ export interface BlockSlot {
113
+ name: string;
114
+ params: string[];
115
+ }