@vtj/core 0.13.20 → 0.13.22

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) 2025, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/core
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.13.20
5
+ * @version 0.13.22
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const U="0.13.20",G="BuiltIn",R="VueMaterial",B="VueRouterMaterial",J=[R,B],w={vue:"Vue","vue-router":"VueRouter"},F={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[B]:["RouterView","RouterLink"]},j=["slot","template","component","img","div","p","h1","h2","h3","span","a"],M=[{label:"简体中文",value:"zh-CN"},{label:"English",value:"en"}];class ${}class K{listeners=[];isReady=!1;triggerReady(){this.isReady=!0;for(const e of this.listeners)e();this.listeners=[]}ready(e){this.isReady?e():this.listeners.push(e)}resetReady(){this.isReady=!1}}class v{constructor(e,t,i){this.name=e,this.value=t,this.defaultValue=i,this.setValue(t)}isUnset=!1;setValue(e){this.value=e,this.isUnset=this.value===this.defaultValue}getValue(){return this.value??this.defaultValue}static toDsl(e={}){return Object.entries(e).reduce((t,[i,s])=>(s.isUnset||(t[i]=s.getValue()),t),{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(i,s),t),{})}}class C{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:a,modifiers:o}=s;return t[i]={name:i,handler:a,modifiers:o},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new C(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||r.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:a,iterator:o}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=a,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:a,value:o,iterator:l,id:f}=t;return{id:f,name:i,arg:s,modifiers:a,value:o,iterator:l}})}}const h="EVENT_NODE_CHANGE";class _{constructor(e,t=null){this.parent=t;const{id:i=r.uid(),name:s,from:a=""}=e;this.id=i,this.name=s,this.from=a,this.update(e,!0),_.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:a=[],slot:o,props:l={},events:f={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(a,!0),this.setSlot(o,!0),this.props=v.parse(l),this.events=C.parse(f),this.directives=E.parse(p),t||n.emit(h,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new _(i,this)):this.children=e,t||n.emit(h,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(h,this)}setProp(e,t,i,s=!1){const a=this.props[e];a?a.setValue(t):this.props[e]=new v(e,t,i),s||n.emit(h,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(h,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 C(e),t||n.emit(h,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(h,this)}setDirective(e,t=!1){const i=e instanceof E?e:new E(e),s=this.directives.findIndex(a=>a.id===e.id);s>=0?this.directives.splice(s,1,i):this.directives.push(i),t||n.emit(h,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(h,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const a=i.findIndex(o=>o===e);e.parent=null,i.splice(a,1),t||n.emit(h,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(h,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(h,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(h,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(h,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(h,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:l,props:f,directives:p,events:P}=this,T=Array.isArray(l)?l.map(H=>H.toDsl()):l;return{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:T,props:v.toDsl(f),directives:E.toDsl(p),events:C.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(h,this),this.parent=null,this.disposed=!0,delete _.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(h,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(h,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(h,this)}isChild(e){let t=!1;if(Array.isArray(this.children)){for(const i of this.children)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break}return t}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||r.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const a=e[s];a!==void 0&&(this[s]=a)}const{nodes:i=[]}=e;i.length?this.nodes=i.map(s=>new _(s)):this.nodes=[],t||n.emit(d,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((o,l)=>(o[l]=this[l],o),{}),__VTJ_BLOCK__:t,__VERSION__:e||r.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(d,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(d,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(d,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(d,this)}setCss(e,t=!1){this.css=e,t||n.emit(d,this)}setWatch(e,t=!1){e.id=e.id||r.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(d,this)}removeWatch(e,t=!1){const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1&&(this.watch.splice(i,1),t||n.emit(d,this))}setProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1?this.props.splice(i,1,e):this.props.push(e),t||n.emit(d,this)}removeProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1&&(this.props.splice(i,1),t||n.emit(d,this))}setEmit(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(d,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(d,this))}setSlot(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(d,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.slots.splice(i,1),t||n.emit(d,this))}setInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1?this.inject.splice(i,1,e):this.inject.push(e),t||n.emit(d,this)}removeInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1&&(this.inject.splice(i,1),t||n.emit(d,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(d,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(d,this)}insertAfter(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s+1,0,e),i||n.emit(d,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(d,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(d,this)}addNode(e,t,i="inner",s=!1){t?["left","top"].includes(i)?t.parent?t.insertAfter(e,s):this.insertBefore(e,t,s):["right","bottom"].includes(i)?t.parent?t.insertAfter(e,s):this.insertAfter(e,t,s):t.appendChild(e,s):this.appendNode(e,s)}__removeNode(e,t=!1){const i=this.nodes.findIndex(s=>s.id===e.id);i>-1&&(this.nodes.splice(i,1),t||n.emit(d,this))}removeNode(e,t=!1){e.parent?e.dispose(t):(e.dispose(!0),this.__removeNode(e,t))}move(e,t,i="inner",s=!1){e.parent?e.parent.removeChild(e,!0):this.__removeNode(e,!0),this.addNode(e,t,i,s)}movePrev(e,t=!1){if(e.parent)e.movePrev(t);else{const i=this.nodes,s=i.indexOf(e);s>0&&(i.splice(s,1),i.splice(s-1,0,e),t||n.emit(d,this))}}moveNext(e,t=!1){if(e.parent)e.moveNext(t);else{const i=this.nodes,s=i.indexOf(e);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,e),t||n.emit(d,this))}}cloneNode(e,t=!1){const i=D(e.toDsl()),s=new _(i);return this.addNode(s,e,"bottom",t),s}lock(e=!1){this.locked=!0;for(const t of this.nodes)t.lock(!0);e||n.emit(d,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(d,this)}isChild(e){let t=!1;for(const i of this.nodes)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break;return t}}const c="EVENT_PROJECT_CHANGE",x="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",g="EVENT_PROJECT_PAGES_CHANGE",N="EVENT_PROJECT_BLOCKS_CHANGE",A="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",k="EVENT_PROJECT_PUBLISH",b="EVENT_PROJECT_FILE_PUBLISH",L="EVENT_PROJECT_GEN_SOURCE";class I{id="";locked="";platform="web";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};uniConfig={};globals={};i18n={locale:"zh-CN",fallbackLocale:"zh-CN",messages:[]};__BASE_PATH__="/";__UID__=r.uuid(!0);static attrs=["locked","platform","name","homepage","description","dependencies","pages","blocks","apis","meta","config","uniConfig","globals","i18n","__BASE_PATH__","__UID__"];constructor(e){const{id:t,__UID__:i}=e;this.id=t||r.uid(),this.__UID__=i||r.uuid(!0),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(c,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}cleanPagesDsl(e){for(const t of e)delete t.dsl,t.children&&t.children.length&&this.cleanPagesDsl(t.children)}toDsl(e){const{id:t}=this,i=I.attrs.reduce((s,a)=>(s[a]=this[a],s),{});return i.pages&&(i.pages=i.pages.map(s=>r.cloneDeep({...s,dsl:void 0})),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>r.cloneDeep({...s,dsl:void 0}))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(x,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(x,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(o=>o.package===e.package);let a;if(s>-1?(a="update",i.splice(s,1,{...i[s],...e})):(a="create",i.push(e)),!t){const o={model:this,type:a,data:e};n.emit(V,o),n.emit(c,o)}}removeDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(a=>a.package===e.package);if(s>-1&&i.splice(s,1),!t){const a={model:this,type:"delete",data:e};n.emit(V,a),n.emit(c,a)}}getPage(e){const t=(i,s=[])=>{for(const a of s){if(a.id===i)return a;if(a.children&&a.children.length){const o=t(i,a.children);if(o)return o}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir||s.layout?(s.layout&&i.push(s),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||r.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:r.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(g,s),n.emit(c,s)}!this.currentFile&&!e.dir&&(await r.delay(1e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(delete e.dsl,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(g,s),n.emit(c,s)}}clonePage(e,t,i=!1){const s=r.uid(),a=`${e.name}Copy`,o=`${e.title}_副本`,l=new u({id:s,name:a}).toDsl(),f=r.merge({},e,{id:s,name:a,title:o,dsl:l}),p=t?this.getPage(t)?.children||[]:this.pages,P=p.findIndex(T=>T.id===e.id);if(p.splice(P+1,0,f),!i){const T={model:this,type:"clone",data:{source:e,target:f}};n.emit(g,T),n.emit(c,T)}}async saveToBlock(e,t=!1){this.active(e,t),await r.delay(1e3);const i=r.uid(),s=e.name,a=e.title,o=new u({...e.dsl,id:i,name:s}).toDsl(),l=r.merge({},e,{id:i,name:s,title:a,dsl:o,type:"block",fromType:"Schema"});if(this.blocks.push(l),!t){const f={model:this,type:"create",data:l};n.emit(N,f),n.emit(c,f)}}removePage(e,t=!1){const i=this.getPage(e),s=(a,o)=>{const l=o.findIndex(f=>f.id===a);if(l>=0){o.splice(l,1);return}for(const f of o)f.children&&f.children.length&&s(a,f.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const a={model:this,type:"delete",data:i};n.emit(g,a),n.emit(c,a)}}getBlock(e){return this.blocks.find(t=>t.id===e)}getFile(e){return this.getPage(e)||this.getBlock(e)}async createBlock(e,t=!1){const i=e.id||r.uid(),s=r.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const a=e.fromType||"Schema";if(!t){const o={model:this,type:"create",data:e};n.emit(N,o),n.emit(c,o)}!this.currentFile&&a==="Schema"&&(await r.delay(1e3),this.active(e,t))}updateBlock(e,t=!1){const i=this.getBlock(e.id);if(i?(Object.assign(i,e),i.dsl&&(i.dsl.name=e.name)):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(N,s),n.emit(c,s)}}cloneBlock(e,t=!1){const i=r.uid(),s=`${e.name}Copy`,a=`${e.title}_副本`,o=new u({id:i,name:s}).toDsl(),l=r.merge({},e,{id:i,name:s,title:a,dsl:o}),f=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(f+1,0,l),!t){const p={model:this,type:"clone",data:{source:e,target:l}};n.emit(N,p),n.emit(c,p)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,a=s.findIndex(o=>o.id===e);if(a>-1?(s.splice(a,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(N,o),n.emit(c,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(a=>a.name===e.name||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.apis.push(e)),!t){const a={model:this,type:s,data:e};n.emit(A,a),n.emit(c,a)}}setApis(e,t=!1){for(const i of e)this.setApi(i,!0);if(!t){const i={model:this,type:"create",data:e};n.emit(A,i),n.emit(c,i)}}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(A,s),n.emit(c,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(a=>a.code===e.code||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.meta.push(e)),!t){const a={model:this,type:s,data:e};n.emit(S,a),n.emit(c,a)}}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(c,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(c,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(c,i)}}setUniConfig(e,t,i=!1){if(this.uniConfig=Object.assign(this.uniConfig,{[e]:t}),!i){const s={model:this,type:"update",data:this.uniConfig};n.emit(c,s)}}setGloblas(e,t,i=!1){if(this.globals=Object.assign(this.globals,{[e]:t}),!i){const s={model:this,type:"update",data:this.globals};n.emit(c,s)}}setI18n(e,t=!1){if(this.i18n=Object.assign(this.i18n,e),!t){const i={model:this,type:"update",data:this.i18n};n.emit(c,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(b,t):n.emit(k,t)}genSource(){const e={model:this,type:"gen",data:null};n.emit(L,e)}lock(e){this.locked=e;const t={model:this,type:"update",data:e};n.emit(c,t)}unlock(e){if(e!==this.locked)return;this.locked="";const t={model:this,type:"update",data:null};n.emit(c,t)}getPageRoutes(e,t){const i=this.platform==="uniapp",s=e||(i?"pages":"page"),a=this.getPages(),o=t||"";return a.map(l=>({id:l.id,path:`${o}/${s}/${l.id}`,name:l.name,title:l.title,meta:l.meta}))}}const y="EVENT_HISTORY_CHANGE",O="EVENT_HISTORY_LOAD";class Y{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:r.uid(),label:new Date().toLocaleString(),dsl:r.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const a=this.items.splice(i);t||n.emit(y,{model:this,type:"delete",data:a.map(o=>o.id)})}this.index=-1,t||n.emit(y,{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(y,{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(O,{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(O,{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(O,{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(y,{model:this,type:"clear",data:t})}}const n=r.mitt();function z(m){return m instanceof u}function W(m){return m instanceof _}function q(m){return!!m.__VTJ_BLOCK__}function D(m){const e=r.cloneDeep(m);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>D(t))),e}function Q(m){const e=m.fromType||"Schema";return e==="Schema"?{type:"Schema",id:m.id}:e==="UrlSchema"?{type:"UrlSchema",url:(m.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(m.urls||"").split(","),library:m.library}:""}exports.BUILT_IN_COMPONENTS=F;exports.BUILT_IN_LIBRARAY_MAP=w;exports.BUILT_IN_MATERIALS=J;exports.BUILT_IN_NAME=G;exports.BUILT_IN_TAGS=j;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=B;exports.Base=K;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=d;exports.EVENT_HISTORY_CHANGE=y;exports.EVENT_HISTORY_LOAD=O;exports.EVENT_NODE_CHANGE=h;exports.EVENT_PROJECT_ACTIVED=x;exports.EVENT_PROJECT_APIS_CHANGE=A;exports.EVENT_PROJECT_BLOCKS_CHANGE=N;exports.EVENT_PROJECT_CHANGE=c;exports.EVENT_PROJECT_DEPS_CHANGE=V;exports.EVENT_PROJECT_FILE_PUBLISH=b;exports.EVENT_PROJECT_GEN_SOURCE=L;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=g;exports.EVENT_PROJECT_PUBLISH=k;exports.EventModel=C;exports.HistoryModel=Y;exports.I18N_LOCALES=M;exports.NodeModel=_;exports.ProjectModel=I;exports.PropModel=v;exports.Service=$;exports.VTJ_CORE_VERSION=U;exports.cloneDsl=D;exports.createNodeFrom=Q;exports.emitter=n;exports.isBlock=z;exports.isBlockSchema=q;exports.isNode=W;
7
+ */const U="0.13.22",G="BuiltIn",R="VueMaterial",k="VueRouterMaterial",J=[R,k],w={vue:"Vue","vue-router":"VueRouter"},j={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[k]:["RouterView","RouterLink"]},F=["slot","template","component","img","div","p","h1","h2","h3","span","a"],M=[{label:"简体中文",value:"zh-CN"},{label:"English",value:"en"}];class ${}class K{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 C{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 C(i,s),t),{})}}class g{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:a,modifiers:o}=s;return t[i]={name:i,handler:a,modifiers:o},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new g(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||r.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:a,iterator:o}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=a,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:a,value:o,iterator:d,id:h}=t;return{id:h,name:i,arg:s,modifiers:a,value:o,iterator:d}})}}const f="EVENT_NODE_CHANGE";class _{constructor(e,t=null){this.parent=t;const{id:i=r.uid(),name:s,from:a=""}=e;this.id=i,this.name=s,this.from=a,this.update(e,!0),_.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:a=[],slot:o,props:d={},events:h={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(a,!0),this.setSlot(o,!0),this.props=C.parse(d),this.events=g.parse(h),this.directives=E.parse(p),t||n.emit(f,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new _(i,this)):this.children=e,t||n.emit(f,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(f,this)}setProp(e,t,i,s=!1){const a=this.props[e];a?a.setValue(t):this.props[e]=new C(e,t,i),s||n.emit(f,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(f,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 g(e),t||n.emit(f,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(f,this)}setDirective(e,t=!1){const i=e instanceof E?e:new E(e),s=this.directives.findIndex(a=>a.id===e.id);s>=0?this.directives.splice(s,1,i):this.directives.push(i),t||n.emit(f,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(f,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const a=i.findIndex(o=>o===e);e.parent=null,i.splice(a,1),t||n.emit(f,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(f,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(f,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(f,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(f,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(f,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:d,props:h,directives:p,events:P}=this,T=Array.isArray(d)?d.map(H=>H.toDsl()):d;return{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:T,props:C.toDsl(h),directives:E.toDsl(p),events:g.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(f,this),this.parent=null,this.disposed=!0,delete _.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(f,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(f,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(f,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 l="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||r.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const a=e[s];a!==void 0&&(this[s]=a)}const{nodes:i=[]}=e;i.length?this.nodes=i.map(s=>new _(s)):this.nodes=[],t||n.emit(l,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((o,d)=>(o[d]=this[d],o),{}),__VTJ_BLOCK__:t,__VERSION__:e||r.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(l,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(l,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(l,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(l,this)}setCss(e,t=!1){this.css=e,t||n.emit(l,this)}setWatch(e,t=!1){e.id=e.id||r.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(l,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(l,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(l,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(l,this))}setEmit(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(l,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(l,this))}setSlot(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(l,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.slots.splice(i,1),t||n.emit(l,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(l,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(l,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(l,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(l,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(l,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(l,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(l,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(l,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(l,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(l,this))}}cloneNode(e,t=!1){const i=B(e.toDsl()),s=new _(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(l,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(l,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 c="EVENT_PROJECT_CHANGE",x="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",y="EVENT_PROJECT_PAGES_CHANGE",N="EVENT_PROJECT_BLOCKS_CHANGE",A="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",D="EVENT_PROJECT_PUBLISH",b="EVENT_PROJECT_FILE_PUBLISH",L="EVENT_PROJECT_GEN_SOURCE";class I{id="";locked="";platform="web";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};uniConfig={};globals={};i18n={locale:"zh-CN",fallbackLocale:"zh-CN",messages:[]};__BASE_PATH__="/";__UID__=r.uuid(!0);static attrs=["locked","platform","name","homepage","description","dependencies","pages","blocks","apis","meta","config","uniConfig","globals","i18n","__BASE_PATH__","__UID__"];constructor(e){const{id:t,__UID__:i}=e;this.id=t||r.uid(),this.__UID__=i||r.uuid(!0),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(c,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}cleanPagesDsl(e){for(const t of e)delete t.dsl,t.children&&t.children.length&&this.cleanPagesDsl(t.children)}toDsl(e){const{id:t}=this,i=I.attrs.reduce((s,a)=>(s[a]=this[a],s),{});return i.pages&&(i.pages=i.pages.map(s=>r.cloneDeep({...s,dsl:void 0})),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>r.cloneDeep({...s,dsl:void 0}))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(x,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(x,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(o=>o.package===e.package);let a;if(s>-1?(a="update",i.splice(s,1,{...i[s],...e})):(a="create",i.push(e)),!t){const o={model:this,type:a,data:e};n.emit(V,o),n.emit(c,o)}}removeDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(a=>a.package===e.package);if(s>-1&&i.splice(s,1),!t){const a={model:this,type:"delete",data:e};n.emit(V,a),n.emit(c,a)}}getPage(e){const t=(i,s=[])=>{for(const a of s){if(a.id===i)return a;if(a.children&&a.children.length){const o=t(i,a.children);if(o)return o}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir||s.layout?(s.layout&&i.push(s),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||r.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:r.upperFirstCamelCase(e.name)}).toDsl(),t){const s=this.getPage(t);s?s.children?s.children.push(e):s.children=[e]:console.warn(`not found PageFile for id: ${t} `)}else this.pages.push(e);if(!i){const s={model:this,type:"create",data:e};n.emit(y,s),n.emit(c,s)}!this.currentFile&&!e.dir&&(await r.delay(1e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(delete e.dsl,i?Object.assign(i,e):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(y,s),n.emit(c,s)}}clonePage(e,t,i=!1){const s=r.uid(),a=`${e.name}Copy`,o=`${e.title}_副本`,d=new u({id:s,name:a}).toDsl(),h=r.merge({},e,{id:s,name:a,title:o,dsl:d}),p=t?this.getPage(t)?.children||[]:this.pages,P=p.findIndex(T=>T.id===e.id);if(p.splice(P+1,0,h),!i){const T={model:this,type:"clone",data:{source:e,target:h}};n.emit(y,T),n.emit(c,T)}}async saveToBlock(e,t=!1){this.active(e,t),await r.delay(1e3);const i=r.uid(),s=e.name,a=e.title,o=new u({...e.dsl,id:i,name:s}).toDsl(),d=r.merge({},e,{id:i,name:s,title:a,dsl:o,type:"block",fromType:"Schema"});if(this.blocks.push(d),!t){const h={model:this,type:"create",data:d};n.emit(N,h),n.emit(c,h)}}removePage(e,t=!1){const i=this.getPage(e),s=(a,o)=>{const d=o.findIndex(h=>h.id===a);if(d>=0){o.splice(d,1);return}for(const h of o)h.children&&h.children.length&&s(a,h.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const a={model:this,type:"delete",data:i};n.emit(y,a),n.emit(c,a)}}getBlock(e){return this.blocks.find(t=>t.id===e)}getFile(e){return this.getPage(e)||this.getBlock(e)}async createBlock(e,t=!1){const i=e.id||r.uid(),s=r.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const a=e.fromType||"Schema";if(!t){const o={model:this,type:"create",data:e};n.emit(N,o),n.emit(c,o)}!this.currentFile&&a==="Schema"&&(await r.delay(1e3),this.active(e,t))}updateBlock(e,t=!1){const i=this.getBlock(e.id);if(i?(Object.assign(i,e),i.dsl&&(i.dsl.name=e.name)):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(N,s),n.emit(c,s)}}cloneBlock(e,t=!1){const i=r.uid(),s=`${e.name}Copy`,a=`${e.title}_副本`,o=new u({id:i,name:s}).toDsl(),d=r.merge({},e,{id:i,name:s,title:a,dsl:o}),h=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(h+1,0,d),!t){const p={model:this,type:"clone",data:{source:e,target:d}};n.emit(N,p),n.emit(c,p)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,a=s.findIndex(o=>o.id===e);if(a>-1?(s.splice(a,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(N,o),n.emit(c,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(a=>a.name===e.name||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.apis.push(e)),!t){const a={model:this,type:s,data:e};n.emit(A,a),n.emit(c,a)}}setApis(e,t=!1){for(const i of e)this.setApi(i,!0);if(!t){const i={model:this,type:"create",data:e};n.emit(A,i),n.emit(c,i)}}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(A,s),n.emit(c,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(a=>a.code===e.code||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.meta.push(e)),!t){const a={model:this,type:s,data:e};n.emit(S,a),n.emit(c,a)}}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(c,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(c,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(c,i)}}setUniConfig(e,t,i=!1){if(this.uniConfig=Object.assign(this.uniConfig,{[e]:t}),!i){const s={model:this,type:"update",data:this.uniConfig};n.emit(c,s)}}setGloblas(e,t,i=!1){if(this.globals=Object.assign(this.globals,{[e]:t}),!i){const s={model:this,type:"update",data:this.globals};n.emit(c,s)}}setI18n(e,t=!1){if(this.i18n=Object.assign(this.i18n,e),!t){const i={model:this,type:"update",data:this.i18n};n.emit(c,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(b,t):n.emit(D,t)}genSource(){const e={model:this,type:"gen",data:null};n.emit(L,e)}lock(e){this.locked=e;const t={model:this,type:"update",data:e};n.emit(c,t)}unlock(e){if(e!==this.locked)return;this.locked="";const t={model:this,type:"update",data:null};n.emit(c,t)}getPageRoutes(e,t){const i=this.platform==="uniapp",s=e||(i?"pages":"page"),a=this.getPages(),o=t||"";return a.map(d=>({id:d.id,path:`${o}/${s}/${d.id}`,name:d.name,title:d.title,meta:d.meta}))}}const v="EVENT_HISTORY_CHANGE",O="EVENT_HISTORY_LOAD";class Y{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,remark:i.remark||""}))}}get(e){return this.items.find(t=>t.id===e)}add(e,t="",i=!1){const{max:s}=this.options,a={id:r.uid(),label:new Date().toLocaleString(),remark:t,dsl:r.cloneDeep(e)};this.items.unshift(a);const o=this.items.filter(d=>!d.remark);if(o.length>s){const d=o.splice(s).map(h=>h.id);this.items=this.items.filter(h=>!d.includes(h.id)),i||n.emit(v,{model:this,type:"delete",data:d})}this.index=-1,i||n.emit(v,{model:this,type:"create",data:a})}update(e,t=!1){const i=this.items.find(s=>s.id===e.id);i&&Object.assign(i,e),t||n.emit(v,{model:this,type:"update",data:i})}remove(e,t=!1){const i=r.toArray(e);for(const s of i){const a=this.items.findIndex(o=>o.id===s);a>-1?(this.items.splice(a,1),a===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(v,{model:this,type:"delete",data:i})}forward(e=!1){const{index:t,items:i}=this;if(t<0)return;--this.index;const s=i[this.index];s&&!e&&n.emit(O,{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(O,{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(O,{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(v,{model:this,type:"clear",data:t})}}const n=r.mitt();function z(m){return m instanceof u}function W(m){return m instanceof _}function q(m){return!!m.__VTJ_BLOCK__}function B(m){const e=r.cloneDeep(m);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>B(t))),e}function Q(m){const e=m.fromType||"Schema";return e==="Schema"?{type:"Schema",id:m.id}:e==="UrlSchema"?{type:"UrlSchema",url:(m.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(m.urls||"").split(","),library:m.library}:""}exports.BUILT_IN_COMPONENTS=j;exports.BUILT_IN_LIBRARAY_MAP=w;exports.BUILT_IN_MATERIALS=J;exports.BUILT_IN_NAME=G;exports.BUILT_IN_TAGS=F;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=k;exports.Base=K;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=l;exports.EVENT_HISTORY_CHANGE=v;exports.EVENT_HISTORY_LOAD=O;exports.EVENT_NODE_CHANGE=f;exports.EVENT_PROJECT_ACTIVED=x;exports.EVENT_PROJECT_APIS_CHANGE=A;exports.EVENT_PROJECT_BLOCKS_CHANGE=N;exports.EVENT_PROJECT_CHANGE=c;exports.EVENT_PROJECT_DEPS_CHANGE=V;exports.EVENT_PROJECT_FILE_PUBLISH=b;exports.EVENT_PROJECT_GEN_SOURCE=L;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=y;exports.EVENT_PROJECT_PUBLISH=D;exports.EventModel=g;exports.HistoryModel=Y;exports.I18N_LOCALES=M;exports.NodeModel=_;exports.ProjectModel=I;exports.PropModel=C;exports.Service=$;exports.VTJ_CORE_VERSION=U;exports.cloneDsl=B;exports.createNodeFrom=Q;exports.emitter=n;exports.isBlock=z;exports.isBlockSchema=q;exports.isNode=W;
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import { uid as m, timestamp as G, isString as T, uuid as b, cloneDeep as C, upperFirstCamelCase as R, delay as P, merge as I, mitt as j } from "@vtj/base";
1
+ import { uid as m, timestamp as G, isString as A, uuid as b, cloneDeep as C, upperFirstCamelCase as R, delay as P, merge as I, toArray as j, mitt as F } from "@vtj/base";
2
2
  /**!
3
3
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
4
4
  * @name @vtj/core
5
5
  * @author CHC chenhuachun1549@dingtalk.com
6
- * @version 0.13.20
6
+ * @version 0.13.22
7
7
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
8
8
  */
9
- const Y = "0.13.20", z = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", W = [H, L], q = {
9
+ const z = "0.13.22", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", q = [H, L], Q = {
10
10
  vue: "Vue",
11
11
  "vue-router": "VueRouter"
12
- }, Q = {
12
+ }, X = {
13
13
  [H]: [
14
14
  "Transition",
15
15
  "TransitionGroup",
@@ -18,7 +18,7 @@ const Y = "0.13.20", z = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial",
18
18
  "Suspense"
19
19
  ],
20
20
  [L]: ["RouterView", "RouterLink"]
21
- }, X = [
21
+ }, Z = [
22
22
  "slot",
23
23
  "template",
24
24
  "component",
@@ -30,7 +30,7 @@ const Y = "0.13.20", z = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial",
30
30
  "h3",
31
31
  "span",
32
32
  "a"
33
- ], Z = [
33
+ ], ee = [
34
34
  {
35
35
  label: "简体中文",
36
36
  value: "zh-CN"
@@ -40,9 +40,9 @@ const Y = "0.13.20", z = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial",
40
40
  value: "en"
41
41
  }
42
42
  ];
43
- class ee {
44
- }
45
43
  class te {
44
+ }
45
+ class ie {
46
46
  listeners = [];
47
47
  isReady = !1;
48
48
  triggerReady() {
@@ -58,7 +58,7 @@ class te {
58
58
  this.isReady = !1;
59
59
  }
60
60
  }
61
- class g {
61
+ class x {
62
62
  constructor(e, t, i) {
63
63
  this.name = e, this.value = t, this.defaultValue = i, this.setValue(t);
64
64
  }
@@ -76,10 +76,10 @@ class g {
76
76
  return Object.entries(e).reduce((t, [i, s]) => (s.isUnset || (t[i] = s.getValue()), t), {});
77
77
  }
78
78
  static parse(e = {}) {
79
- return Object.entries(e).reduce((t, [i, s]) => (t[i] = new g(i, s), t), {});
79
+ return Object.entries(e).reduce((t, [i, s]) => (t[i] = new x(i, s), t), {});
80
80
  }
81
81
  }
82
- class x {
82
+ class T {
83
83
  constructor(e) {
84
84
  this.schema = e;
85
85
  const { name: t, handler: i } = this.schema;
@@ -101,7 +101,7 @@ class x {
101
101
  }
102
102
  static parse(e = {}) {
103
103
  return Object.entries(e).reduce(
104
- (t, [i, s]) => (t[i] = new x(s), t),
104
+ (t, [i, s]) => (t[i] = new T(s), t),
105
105
  {}
106
106
  );
107
107
  }
@@ -230,7 +230,7 @@ class _ {
230
230
  events: c = {},
231
231
  directives: p = []
232
232
  } = e;
233
- this.invisible = i, this.locked = s, this.setChildren(a, !0), this.setSlot(o, !0), this.props = g.parse(r), this.events = x.parse(c), this.directives = v.parse(p), t || n.emit(h, this);
233
+ this.invisible = i, this.locked = s, this.setChildren(a, !0), this.setSlot(o, !0), this.props = x.parse(r), this.events = T.parse(c), this.directives = v.parse(p), t || n.emit(h, this);
234
234
  }
235
235
  /**
236
236
  * 设置子节点
@@ -257,7 +257,7 @@ class _ {
257
257
  */
258
258
  setProp(e, t, i, s = !1) {
259
259
  const a = this.props[e];
260
- a ? a.setValue(t) : this.props[e] = new g(e, t, i), s || n.emit(h, this);
260
+ a ? a.setValue(t) : this.props[e] = new x(e, t, i), s || n.emit(h, this);
261
261
  }
262
262
  /**
263
263
  * 删除属性
@@ -284,7 +284,7 @@ class _ {
284
284
  */
285
285
  setEvent(e, t = !1) {
286
286
  const i = this.events[e.name];
287
- i ? i.update(e) : this.events[e.name] = new x(e), t || n.emit(h, this);
287
+ i ? i.update(e) : this.events[e.name] = new T(e), t || n.emit(h, this);
288
288
  }
289
289
  /**
290
290
  * 删除事件
@@ -409,9 +409,9 @@ class _ {
409
409
  locked: a,
410
410
  slot: o,
411
411
  children: E,
412
- props: g.toDsl(c),
412
+ props: x.toDsl(c),
413
413
  directives: v.toDsl(p),
414
- events: x.toDsl(O)
414
+ events: T.toDsl(O)
415
415
  };
416
416
  }
417
417
  /**
@@ -619,7 +619,7 @@ class u {
619
619
  * @param silent
620
620
  */
621
621
  setEmit(e, t = !1) {
622
- const i = T(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
622
+ const i = A(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
623
623
  (a) => a === i.name || a.name === i.name
624
624
  );
625
625
  s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(l, this);
@@ -631,7 +631,7 @@ class u {
631
631
  */
632
632
  removeEmit(e, t = !1) {
633
633
  const i = this.emits.findIndex(
634
- (s) => T(s) ? s === e : s.name === e
634
+ (s) => A(s) ? s === e : s.name === e
635
635
  );
636
636
  i > -1 && (this.emits.splice(i, 1), t || n.emit(l, this));
637
637
  }
@@ -641,7 +641,7 @@ class u {
641
641
  * @param silent
642
642
  */
643
643
  setSlot(e, t = !1) {
644
- const i = T(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
644
+ const i = A(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
645
645
  (a) => a === i.name || a.name === i.name
646
646
  );
647
647
  s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(l, this);
@@ -653,7 +653,7 @@ class u {
653
653
  */
654
654
  removeSlot(e, t = !1) {
655
655
  const i = this.slots.findIndex(
656
- (s) => T(s) ? s === e : s.name === e
656
+ (s) => A(s) ? s === e : s.name === e
657
657
  );
658
658
  i > -1 && (this.slots.splice(i, 1), t || n.emit(l, this));
659
659
  }
@@ -795,8 +795,8 @@ class u {
795
795
  return t;
796
796
  }
797
797
  }
798
- const d = "EVENT_PROJECT_CHANGE", D = "EVENT_PROJECT_ACTIVED", B = "EVENT_PROJECT_DEPS_CHANGE", A = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", V = "EVENT_PROJECT_APIS_CHANGE", w = "EVENT_PROJECT_META_CHANGE", F = "EVENT_PROJECT_PUBLISH", $ = "EVENT_PROJECT_FILE_PUBLISH", M = "EVENT_PROJECT_GEN_SOURCE";
799
- class k {
798
+ const d = "EVENT_PROJECT_CHANGE", D = "EVENT_PROJECT_ACTIVED", B = "EVENT_PROJECT_DEPS_CHANGE", N = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", V = "EVENT_PROJECT_APIS_CHANGE", w = "EVENT_PROJECT_META_CHANGE", $ = "EVENT_PROJECT_PUBLISH", M = "EVENT_PROJECT_FILE_PUBLISH", K = "EVENT_PROJECT_GEN_SOURCE";
799
+ class S {
800
800
  id = "";
801
801
  locked = "";
802
802
  platform = "web";
@@ -842,7 +842,7 @@ class k {
842
842
  this.id = t || m(), this.__UID__ = i || b(!0), this.update(e, !0);
843
843
  }
844
844
  update(e, t = !1) {
845
- for (const i of k.attrs) {
845
+ for (const i of S.attrs) {
846
846
  const s = e[i];
847
847
  s && (this[i] = s);
848
848
  }
@@ -860,7 +860,7 @@ class k {
860
860
  delete t.dsl, t.children && t.children.length && this.cleanPagesDsl(t.children);
861
861
  }
862
862
  toDsl(e) {
863
- const { id: t } = this, i = k.attrs.reduce(
863
+ const { id: t } = this, i = S.attrs.reduce(
864
864
  (s, a) => (s[a] = this[a], s),
865
865
  {}
866
866
  );
@@ -988,7 +988,7 @@ class k {
988
988
  type: "create",
989
989
  data: e
990
990
  };
991
- n.emit(A, s), n.emit(d, s);
991
+ n.emit(N, s), n.emit(d, s);
992
992
  }
993
993
  !this.currentFile && !e.dir && (await P(1e3), this.active(e, i));
994
994
  }
@@ -1005,7 +1005,7 @@ class k {
1005
1005
  type: "update",
1006
1006
  data: e
1007
1007
  };
1008
- n.emit(A, s), n.emit(d, s);
1008
+ n.emit(N, s), n.emit(d, s);
1009
1009
  }
1010
1010
  }
1011
1011
  /**
@@ -1028,7 +1028,7 @@ class k {
1028
1028
  target: c
1029
1029
  }
1030
1030
  };
1031
- n.emit(A, E), n.emit(d, E);
1031
+ n.emit(N, E), n.emit(d, E);
1032
1032
  }
1033
1033
  }
1034
1034
  async saveToBlock(e, t = !1) {
@@ -1075,7 +1075,7 @@ class k {
1075
1075
  type: "delete",
1076
1076
  data: i
1077
1077
  };
1078
- n.emit(A, a), n.emit(d, a);
1078
+ n.emit(N, a), n.emit(d, a);
1079
1079
  }
1080
1080
  }
1081
1081
  /**
@@ -1309,7 +1309,7 @@ class k {
1309
1309
  type: "publish",
1310
1310
  data: e || this
1311
1311
  };
1312
- e ? n.emit($, t) : n.emit(F, t);
1312
+ e ? n.emit(M, t) : n.emit($, t);
1313
1313
  }
1314
1314
  genSource() {
1315
1315
  const e = {
@@ -1317,7 +1317,7 @@ class k {
1317
1317
  type: "gen",
1318
1318
  data: null
1319
1319
  };
1320
- n.emit(M, e);
1320
+ n.emit(K, e);
1321
1321
  }
1322
1322
  lock(e) {
1323
1323
  this.locked = e;
@@ -1350,8 +1350,8 @@ class k {
1350
1350
  }));
1351
1351
  }
1352
1352
  }
1353
- const N = "EVENT_HISTORY_CHANGE", S = "EVENT_HISTORY_LOAD";
1354
- class ie {
1353
+ const g = "EVENT_HISTORY_CHANGE", k = "EVENT_HISTORY_LOAD";
1354
+ class se {
1355
1355
  options = { max: 50 };
1356
1356
  index = -1;
1357
1357
  id;
@@ -1365,7 +1365,11 @@ class ie {
1365
1365
  const { id: e, items: t } = this;
1366
1366
  return {
1367
1367
  id: e,
1368
- items: t.map((i) => ({ id: i.id, label: i.label }))
1368
+ items: t.map((i) => ({
1369
+ id: i.id,
1370
+ label: i.label,
1371
+ remark: i.remark || ""
1372
+ }))
1369
1373
  };
1370
1374
  }
1371
1375
  /**
@@ -1381,24 +1385,41 @@ class ie {
1381
1385
  * @param dsl
1382
1386
  * @param silent
1383
1387
  */
1384
- add(e, t = !1) {
1385
- const { max: i } = this.options, s = {
1388
+ add(e, t = "", i = !1) {
1389
+ const { max: s } = this.options, a = {
1386
1390
  id: m(),
1387
1391
  label: (/* @__PURE__ */ new Date()).toLocaleString(),
1392
+ remark: t,
1388
1393
  dsl: C(e)
1389
1394
  };
1390
- if (this.items.unshift(s), this.items.length > i) {
1391
- const a = this.items.splice(i);
1392
- t || n.emit(N, {
1395
+ this.items.unshift(a);
1396
+ const o = this.items.filter((r) => !r.remark);
1397
+ if (o.length > s) {
1398
+ const r = o.splice(s).map((c) => c.id);
1399
+ this.items = this.items.filter((c) => !r.includes(c.id)), i || n.emit(g, {
1393
1400
  model: this,
1394
1401
  type: "delete",
1395
- data: a.map((o) => o.id)
1402
+ data: r
1396
1403
  });
1397
1404
  }
1398
- this.index = -1, t || n.emit(N, {
1405
+ this.index = -1, i || n.emit(g, {
1399
1406
  model: this,
1400
1407
  type: "create",
1401
- data: s
1408
+ data: a
1409
+ });
1410
+ }
1411
+ /**
1412
+ * 更新历史记录
1413
+ * @param id
1414
+ * @param remark
1415
+ * @param silent
1416
+ */
1417
+ update(e, t = !1) {
1418
+ const i = this.items.find((s) => s.id === e.id);
1419
+ i && Object.assign(i, e), t || n.emit(g, {
1420
+ model: this,
1421
+ type: "update",
1422
+ data: i
1402
1423
  });
1403
1424
  }
1404
1425
  /**
@@ -1407,11 +1428,15 @@ class ie {
1407
1428
  * @param silent
1408
1429
  */
1409
1430
  remove(e, t = !1) {
1410
- const i = this.items.findIndex((s) => s.id === e);
1411
- 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, {
1431
+ const i = j(e);
1432
+ for (const s of i) {
1433
+ const a = this.items.findIndex((o) => o.id === s);
1434
+ a > -1 ? (this.items.splice(a, 1), a === this.index ? this.index = -1 : this.index >= this.items.length && (this.index = this.items.length - 1)) : console.warn(`not found HistoryItem for id: ${e} `);
1435
+ }
1436
+ t || n.emit(g, {
1412
1437
  model: this,
1413
1438
  type: "delete",
1414
- data: [e]
1439
+ data: i
1415
1440
  });
1416
1441
  }
1417
1442
  forward(e = !1) {
@@ -1419,7 +1444,7 @@ class ie {
1419
1444
  if (t < 0) return;
1420
1445
  --this.index;
1421
1446
  const s = i[this.index];
1422
- s && !e && n.emit(S, {
1447
+ s && !e && n.emit(k, {
1423
1448
  model: this,
1424
1449
  type: "load",
1425
1450
  data: s
@@ -1430,7 +1455,7 @@ class ie {
1430
1455
  if (t >= i.length - 1) return;
1431
1456
  t < 0 && (this.index = 0), ++this.index;
1432
1457
  const s = i[this.index];
1433
- s && !e && n.emit(S, {
1458
+ s && !e && n.emit(k, {
1434
1459
  model: this,
1435
1460
  type: "load",
1436
1461
  data: s
@@ -1438,7 +1463,7 @@ class ie {
1438
1463
  }
1439
1464
  load(e, t = !1) {
1440
1465
  const i = this.items.findIndex((s) => s.id === e);
1441
- i >= 0 && (this.index = i, t || n.emit(S, {
1466
+ i >= 0 && (this.index = i, t || n.emit(k, {
1442
1467
  model: this,
1443
1468
  type: "load",
1444
1469
  data: this.items[i]
@@ -1447,28 +1472,28 @@ class ie {
1447
1472
  clear(e = !1) {
1448
1473
  this.index = -1;
1449
1474
  const t = this.items.map((i) => i.id);
1450
- this.items = [], e || n.emit(N, {
1475
+ this.items = [], e || n.emit(g, {
1451
1476
  model: this,
1452
1477
  type: "clear",
1453
1478
  data: t
1454
1479
  });
1455
1480
  }
1456
1481
  }
1457
- const n = j();
1458
- function se(f) {
1482
+ const n = F();
1483
+ function ne(f) {
1459
1484
  return f instanceof u;
1460
1485
  }
1461
- function ne(f) {
1486
+ function ae(f) {
1462
1487
  return f instanceof _;
1463
1488
  }
1464
- function ae(f) {
1489
+ function oe(f) {
1465
1490
  return !!f.__VTJ_BLOCK__;
1466
1491
  }
1467
1492
  function J(f) {
1468
1493
  const e = C(f);
1469
1494
  return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) => J(t))), e;
1470
1495
  }
1471
- function oe(f) {
1496
+ function re(f) {
1472
1497
  const e = f.fromType || "Schema";
1473
1498
  return e === "Schema" ? {
1474
1499
  type: "Schema",
@@ -1483,42 +1508,42 @@ function oe(f) {
1483
1508
  } : "";
1484
1509
  }
1485
1510
  export {
1486
- Q as BUILT_IN_COMPONENTS,
1487
- q as BUILT_IN_LIBRARAY_MAP,
1488
- W as BUILT_IN_MATERIALS,
1489
- z as BUILT_IN_NAME,
1490
- X as BUILT_IN_TAGS,
1511
+ X as BUILT_IN_COMPONENTS,
1512
+ Q as BUILT_IN_LIBRARAY_MAP,
1513
+ q as BUILT_IN_MATERIALS,
1514
+ W as BUILT_IN_NAME,
1515
+ Z as BUILT_IN_TAGS,
1491
1516
  H as BUILT_IN_VUE,
1492
1517
  L as BUILT_IN_VUE_ROUTER,
1493
- te as Base,
1518
+ ie as Base,
1494
1519
  u as BlockModel,
1495
1520
  v as DirectiveModel,
1496
1521
  l as EVENT_BLOCK_CHANGE,
1497
- N as EVENT_HISTORY_CHANGE,
1498
- S as EVENT_HISTORY_LOAD,
1522
+ g as EVENT_HISTORY_CHANGE,
1523
+ k as EVENT_HISTORY_LOAD,
1499
1524
  h as EVENT_NODE_CHANGE,
1500
1525
  D as EVENT_PROJECT_ACTIVED,
1501
1526
  V as EVENT_PROJECT_APIS_CHANGE,
1502
1527
  y as EVENT_PROJECT_BLOCKS_CHANGE,
1503
1528
  d as EVENT_PROJECT_CHANGE,
1504
1529
  B as EVENT_PROJECT_DEPS_CHANGE,
1505
- $ as EVENT_PROJECT_FILE_PUBLISH,
1506
- M as EVENT_PROJECT_GEN_SOURCE,
1530
+ M as EVENT_PROJECT_FILE_PUBLISH,
1531
+ K as EVENT_PROJECT_GEN_SOURCE,
1507
1532
  w as EVENT_PROJECT_META_CHANGE,
1508
- A as EVENT_PROJECT_PAGES_CHANGE,
1509
- F as EVENT_PROJECT_PUBLISH,
1510
- x as EventModel,
1511
- ie as HistoryModel,
1512
- Z as I18N_LOCALES,
1533
+ N as EVENT_PROJECT_PAGES_CHANGE,
1534
+ $ as EVENT_PROJECT_PUBLISH,
1535
+ T as EventModel,
1536
+ se as HistoryModel,
1537
+ ee as I18N_LOCALES,
1513
1538
  _ as NodeModel,
1514
- k as ProjectModel,
1515
- g as PropModel,
1516
- ee as Service,
1517
- Y as VTJ_CORE_VERSION,
1539
+ S as ProjectModel,
1540
+ x as PropModel,
1541
+ te as Service,
1542
+ z as VTJ_CORE_VERSION,
1518
1543
  J as cloneDsl,
1519
- oe as createNodeFrom,
1544
+ re as createNodeFrom,
1520
1545
  n as emitter,
1521
- se as isBlock,
1522
- ae as isBlockSchema,
1523
- ne as isNode
1546
+ ne as isBlock,
1547
+ oe as isBlockSchema,
1548
+ ae as isNode
1524
1549
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/core",
3
3
  "private": false,
4
- "version": "0.13.20",
4
+ "version": "0.13.22",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -24,7 +24,7 @@
24
24
  "@vtj/base": "~0.12.3"
25
25
  },
26
26
  "devDependencies": {
27
- "@vtj/cli": "~0.12.11"
27
+ "@vtj/cli": "~0.12.12"
28
28
  },
29
29
  "exports": {
30
30
  ".": {
@@ -28,13 +28,20 @@ export declare class HistoryModel {
28
28
  * @param dsl
29
29
  * @param silent
30
30
  */
31
- add(dsl: BlockSchema, silent?: boolean): void;
31
+ add(dsl: BlockSchema, remark?: string, silent?: boolean): void;
32
+ /**
33
+ * 更新历史记录
34
+ * @param id
35
+ * @param remark
36
+ * @param silent
37
+ */
38
+ update(item: HistoryItem, silent?: boolean): void;
32
39
  /**
33
40
  * 删除历史记录
34
41
  * @param id
35
42
  * @param silent
36
43
  */
37
- remove(id: string, silent?: boolean): void;
44
+ remove(id: string | string[], silent?: boolean): void;
38
45
  forward(silent?: boolean): void;
39
46
  backward(silent?: boolean): void;
40
47
  load(id: string, silent?: boolean): void;
@@ -28,4 +28,8 @@ export interface HistoryItem {
28
28
  * 记录项内容
29
29
  */
30
30
  dsl?: BlockSchema;
31
+ /**
32
+ * 备注
33
+ */
34
+ remark?: string;
31
35
  }
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/core
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.13.19
5
+ * @version 0.13.21
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.13.19";
8
+ export declare const version = "0.13.21";