@vtj/core 0.19.6 → 0.19.8

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) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/core
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.19.6
5
+ * @version 0.19.8
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const U="0.19.6",G="BuiltIn",R="VueMaterial",D="VueRouterMaterial",J=[R,D],w={vue:"Vue","vue-router":"VueRouter"},M={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[D]:["RouterView","RouterLink"]},j=["slot","template","component","img","div","p","h1","h2","h3","span","a"],F=[{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 y{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 y(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||l.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value: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:r,id:h}=t;return{id:h,name:i,arg:s,modifiers:a,value:o,iterator:r}})}}const f="EVENT_NODE_CHANGE";class _{constructor(e,t=null){this.parent=t;const{id:i=l.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:r={},events:h={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(a,!0),this.setSlot(o,!0),this.props=y.parse(r),this.events=C.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 y(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 C(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:r,props:h,directives:p,events:O}=this,v=Array.isArray(r)?r.map(H=>H.toDsl()):r;return{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:v,props:y.toDsl(h),directives:E.toDsl(p),events:C.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(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}findChildIndex(e){return Array.isArray(this.children)?this.children.findIndex(t=>t===e||t.id===e.id):-1}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";apiMode="options";inject=[];state={};refs={};reactives={};lifeCycles={};methods={};computed={};watch=[];composables=[];setup=void 0;provide={};css="";props=[];emits=[];expose=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","apiMode","inject","state","refs","reactives","lifeCycles","methods","computed","watch","composables","setup","provide","css","props","emits","expose","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||l.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const a=e[s];(a!==void 0||s==="setup")&&(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,r)=>(o[r]=this[r],o),{}),__VTJ_BLOCK__:t,__VERSION__:e||l.timestamp().toString(),id:i,nodes:s.map(o=>o.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}isExistName(e){return e in this.refs||e in this.reactives||e in this.computed||e in this.methods}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)}setComputed(e,t,i=!1){t?this.computed[e]=t:delete this.computed[e],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||l.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(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=l.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=>l.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(d,this))}setExpose(e,t=!1){this.expose=e,t||n.emit(d,this)}setSlot(e,t=!1){const i=l.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=>l.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)}setApiMode(e,t=!1){this.apiMode=e,t||n.emit(d,this)}setRef(e,t,i=!1){this.refs[e]=t,i||n.emit(d,this)}removeRef(e,t=!1){delete this.refs[e],t||n.emit(d,this)}setReactive(e,t,i=!1){this.reactives[e]=t,i||n.emit(d,this)}removeReactive(e,t=!1){delete this.reactives[e],t||n.emit(d,this)}setComposable(e,t=!1){const i=this.composables.findIndex(s=>s.name===e.name);i>-1?this.composables.splice(i,1,e):this.composables.push(e),t||n.emit(d,this)}removeComposable(e,t=!1){const i=this.composables.findIndex(s=>s.name===e);i>-1&&(this.composables.splice(i,1),t||n.emit(d,this))}setProvide(e,t,i=!1){this.provide[e]=t,i||n.emit(d,this)}removeProvide(e,t=!1){delete this.provide[e],t||n.emit(d,this)}setSetup(e,t=!1){this.setup=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=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(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",I="EVENT_PROJECT_ACTIVED",S="EVENT_PROJECT_DEPS_CHANGE",T="EVENT_PROJECT_PAGES_CHANGE",g="EVENT_PROJECT_BLOCKS_CHANGE",A="EVENT_PROJECT_APIS_CHANGE",V="EVENT_PROJECT_META_CHANGE",B="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH",L="EVENT_PROJECT_GEN_SOURCE";class x{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:[]};env=[];__BASE_PATH__="/";__UID__=l.uuid(!0);static attrs=["locked","platform","name","homepage","description","dependencies","pages","blocks","apis","meta","config","uniConfig","globals","i18n","env","__BASE_PATH__","__UID__"];constructor(e){const{id:t,__UID__:i}=e;this.id=t||l.uid(),this.__UID__=i||l.uuid(!0),this.update(e,!0)}update(e,t=!1){for(const i of x.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=x.attrs.reduce((s,a)=>(s[a]=this[a],s),{});return i.pages&&(i.pages=i.pages.map(s=>l.cloneDeep({...s,dsl:void 0})),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>l.cloneDeep({...s,dsl:void 0}))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(I,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(I,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(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(S,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(S,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)}getHomepage(){return this.homepage?this.getPage(this.homepage):this.getPages()[0]}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||l.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:l.upperFirstCamelCase(e.name),apiMode:"composition"}).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(T,s),n.emit(c,s)}return!this.currentFile&&!e.dir&&(this.active(e,!0),await l.delay(1e3),this.active(e,i)),e}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(T,s),n.emit(c,s)}return i}findParent(e){const t=(i,s=[],a)=>{for(const o of s){if(o.id===i)return a;if(o.children&&o.children.length){const r=t(i,o.children,o);if(r)return r}}};return t(e,this.pages)}movePageTo(e,t,i=!1){const s=t?this.getPage(t):null,a=this.getPage(e);if(!a)return!1;const o=this.findParent(e);if(o?o.children=o.children?.filter(r=>r.id!==e):this.pages=this.pages.filter(r=>r.id!==e),s?(s.dir||s.layout)&&(s.children?s.children.push(a):s.children=[a]):this.pages.push(a),!i){const r={model:this,type:"update",data:a};n.emit(T,r),n.emit(c,r)}return!0}getPageTree(){const e=l.cloneDeep(this.pages);return this.cleanPagesDsl(e),e}clonePage(e,t,i=!1){const s=l.uid(),a=`${e.name}Copy`,o=`${e.title}_副本`,r=new u({id:s,name:a,apiMode:"composition"}).toDsl(),h=l.merge({},e,{id:s,name:a,title:o,dsl:r}),p=t?this.getPage(t)?.children||[]:this.pages,O=p.findIndex(v=>v.id===e.id);if(p.splice(O+1,0,h),!i){const v={model:this,type:"clone",data:{source:e,target:h}};n.emit(T,v),n.emit(c,v)}}async saveToBlock(e,t=!1){this.active(e,t),await l.delay(1e3);const i=l.uid(),s=e.name,a=e.title,o=new u({...e.dsl,id:i,name:s}).toDsl(),r=l.merge({},e,{id:i,name:s,title:a,dsl:o,type:"block",fromType:"Schema"});if(this.blocks.push(r),!t){const h={model:this,type:"create",data:r};n.emit(g,h),n.emit(c,h)}}removePage(e,t=!1){const i=this.getPage(e),s=(a,o)=>{const r=o.findIndex(h=>h.id===a);if(r>=0){o.splice(r,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(T,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||l.uid(),s=l.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.fromType=e.fromType||"Schema",e.dsl=new u({id:i,name:s,apiMode:"composition"}).toDsl(),this.blocks.push(e);const a=e.fromType||"Schema";if(!t){const o={model:this,type:"create",data:e};n.emit(g,o),n.emit(c,o)}return!this.currentFile&&a==="Schema"&&(this.active(e,!0),await l.delay(1e3),this.active(e,t)),e}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(g,s),n.emit(c,s)}return i}cloneBlock(e,t=!1){const i=l.uid(),s=`${e.name}Copy`,a=`${e.title}_副本`,o=new u({id:i,name:s,apiMode:"composition"}).toDsl(),r=l.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,r),!t){const p={model:this,type:"clone",data:{source:e,target:r}};n.emit(g,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(g,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=l.uid(),this.apis.push(e)),!t){const a={model:this,type:s,data:e};n.emit(A,a),n.emit(c,a)}return i||e}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=l.uid(),this.meta.push(e)),!t){const a={model:this,type:s,data:e};n.emit(V,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(V,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)}}setEnv(e,t=!1){if(this.env=[...e],!t){const i={model:this,type:"update",data:this.env};n.emit(c,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(B,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(r=>({id:r.id,path:`${o}/${s}/${r.id}`,name:r.name,title:r.title,meta:r.meta}))}}const N="EVENT_HISTORY_CHANGE",P="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:l.uid(),label:new Date().toLocaleString(),remark:t,dsl:l.cloneDeep(e)};this.items.unshift(a);const o=this.items.filter(r=>!r.remark);if(o.length>s){const r=o.splice(s).map(h=>h.id);this.items=this.items.filter(h=>!r.includes(h.id)),i||n.emit(N,{model:this,type:"delete",data:r})}this.index=-1,i||n.emit(N,{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(N,{model:this,type:"update",data:i})}remove(e,t=!1){const i=l.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(N,{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(P,{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(P,{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(P,{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(N,{model:this,type:"clear",data:t})}}const n=l.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=l.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=M;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=D;exports.Base=K;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=d;exports.EVENT_HISTORY_CHANGE=N;exports.EVENT_HISTORY_LOAD=P;exports.EVENT_NODE_CHANGE=f;exports.EVENT_PROJECT_ACTIVED=I;exports.EVENT_PROJECT_APIS_CHANGE=A;exports.EVENT_PROJECT_BLOCKS_CHANGE=g;exports.EVENT_PROJECT_CHANGE=c;exports.EVENT_PROJECT_DEPS_CHANGE=S;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_GEN_SOURCE=L;exports.EVENT_PROJECT_META_CHANGE=V;exports.EVENT_PROJECT_PAGES_CHANGE=T;exports.EVENT_PROJECT_PUBLISH=B;exports.EventModel=C;exports.HistoryModel=Y;exports.I18N_LOCALES=F;exports.NodeModel=_;exports.ProjectModel=x;exports.PropModel=y;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;
7
+ */const U="0.19.8",G="BuiltIn",R="VueMaterial",D="VueRouterMaterial",J=[R,D],w={vue:"Vue","vue-router":"VueRouter"},M={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[D]:["RouterView","RouterLink"]},j=["slot","template","component","img","div","p","h1","h2","h3","span","a"],F=[{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 y{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 y(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||l.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value: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:r,id:h}=t;return{id:h,name:i,arg:s,modifiers:a,value:o,iterator:r}})}}const f="EVENT_NODE_CHANGE";class _{constructor(e,t=null){this.parent=t;const{id:i=l.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:r={},events:h={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(a,!0),this.setSlot(o,!0),this.props=y.parse(r),this.events=C.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 y(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 C(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:r,props:h,directives:p,events:O}=this,v=Array.isArray(r)?r.map(H=>H.toDsl()):r;return{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:v,props:y.toDsl(h),directives:E.toDsl(p),events:C.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(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}findChildIndex(e){return Array.isArray(this.children)?this.children.findIndex(t=>t===e||t.id===e.id):-1}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";apiMode="options";inject=[];state={};refs={};reactives={};lifeCycles={};methods={};computed={};watch=[];composables=[];setup=void 0;provide={};css="";props=[];emits=[];expose=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","apiMode","inject","state","refs","reactives","lifeCycles","methods","computed","watch","composables","setup","provide","css","props","emits","expose","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||l.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const a=e[s];(a!==void 0||s==="setup")&&(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,r)=>(o[r]=this[r],o),{}),__VTJ_BLOCK__:t,__VERSION__:e||l.timestamp().toString(),id:i,nodes:s.map(o=>o.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}isExistName(e){return e in this.refs||e in this.reactives||e in this.computed||e in this.methods}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)}setComputed(e,t,i=!1){t?this.computed[e]=t:delete this.computed[e],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||l.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(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=l.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=>l.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(d,this))}setExpose(e,t=!1){this.expose=e,t||n.emit(d,this)}setSlot(e,t=!1){const i=l.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=>l.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)}setApiMode(e,t=!1){this.apiMode=e,t||n.emit(d,this)}setRef(e,t,i=!1){this.refs[e]=t,i||n.emit(d,this)}removeRef(e,t=!1){delete this.refs[e],t||n.emit(d,this)}setReactive(e,t,i=!1){this.reactives[e]=t,i||n.emit(d,this)}removeReactive(e,t=!1){delete this.reactives[e],t||n.emit(d,this)}setComposable(e,t=!1){const i=this.composables.findIndex(s=>s.name===e.name);i>-1?this.composables.splice(i,1,e):this.composables.push(e),t||n.emit(d,this)}removeComposable(e,t=!1){const i=this.composables.findIndex(s=>s.name===e);i>-1&&(this.composables.splice(i,1),t||n.emit(d,this))}setProvide(e,t,i=!1){this.provide[e]=t,i||n.emit(d,this)}removeProvide(e,t=!1){delete this.provide[e],t||n.emit(d,this)}setSetup(e,t=!1){this.setup=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=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(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",I="EVENT_PROJECT_ACTIVED",S="EVENT_PROJECT_DEPS_CHANGE",T="EVENT_PROJECT_PAGES_CHANGE",g="EVENT_PROJECT_BLOCKS_CHANGE",A="EVENT_PROJECT_APIS_CHANGE",V="EVENT_PROJECT_META_CHANGE",B="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH",L="EVENT_PROJECT_GEN_SOURCE";class x{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:[]};env=[];__BASE_PATH__="/";__UID__=l.uuid(!0);static attrs=["locked","platform","name","homepage","description","dependencies","pages","blocks","apis","meta","config","uniConfig","globals","i18n","env","__BASE_PATH__","__UID__"];constructor(e){const{id:t,__UID__:i}=e;this.id=t||l.uid(),this.__UID__=i||l.uuid(!0),this.update(e,!0)}update(e,t=!1){for(const i of x.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=x.attrs.reduce((s,a)=>(s[a]=this[a],s),{});return i.pages&&(i.pages=i.pages.map(s=>l.cloneDeep({...s,dsl:void 0})),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>l.cloneDeep({...s,dsl:void 0}))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(I,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(I,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(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(S,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(S,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)}getHomepage(){return this.homepage?this.getPage(this.homepage):this.getPages()[0]}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||l.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:l.upperFirstCamelCase(e.name),apiMode:"composition"}).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(T,s),n.emit(c,s)}return!this.currentFile&&!e.dir&&(this.active(e,!0),await l.delay(1e3),this.active(e,i)),e}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(T,s),n.emit(c,s)}return i}findParent(e){const t=(i,s=[],a)=>{for(const o of s){if(o.id===i)return a;if(o.children&&o.children.length){const r=t(i,o.children,o);if(r)return r}}};return t(e,this.pages)}movePageTo(e,t,i=!1){const s=t?this.getPage(t):null,a=this.getPage(e);if(!a)return!1;const o=this.findParent(e);if(o?o.children=o.children?.filter(r=>r.id!==e):this.pages=this.pages.filter(r=>r.id!==e),s?(s.dir||s.layout)&&(s.children?s.children.push(a):s.children=[a]):this.pages.push(a),!i){const r={model:this,type:"update",data:a};n.emit(T,r),n.emit(c,r)}return!0}getPageTree(){const e=l.cloneDeep(this.pages);return this.cleanPagesDsl(e),e}clonePage(e,t,i=!1){const s=l.uid(),a=`${e.name}Copy`,o=`${e.title}_副本`,r=new u({id:s,name:a,apiMode:"composition"}).toDsl(),h=l.merge({},e,{id:s,name:a,title:o,dsl:r}),p=t?this.getPage(t)?.children||[]:this.pages,O=p.findIndex(v=>v.id===e.id);if(p.splice(O+1,0,h),!i){const v={model:this,type:"clone",data:{source:e,target:h}};n.emit(T,v),n.emit(c,v)}}async saveToBlock(e,t=!1){this.active(e,t),await l.delay(1e3);const i=l.uid(),s=e.name,a=e.title,o=new u({...e.dsl,id:i,name:s}).toDsl(),r=l.merge({},e,{id:i,name:s,title:a,dsl:o,type:"block",fromType:"Schema"});if(this.blocks.push(r),!t){const h={model:this,type:"create",data:r};n.emit(g,h),n.emit(c,h)}}removePage(e,t=!1){const i=this.getPage(e),s=(a,o)=>{const r=o.findIndex(h=>h.id===a);if(r>=0){o.splice(r,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(T,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||l.uid(),s=l.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.fromType=e.fromType||"Schema",e.dsl=new u({id:i,name:s,apiMode:"composition"}).toDsl(),this.blocks.push(e);const a=e.fromType||"Schema";if(!t){const o={model:this,type:"create",data:e};n.emit(g,o),n.emit(c,o)}return!this.currentFile&&a==="Schema"&&(this.active(e,!0),await l.delay(1e3),this.active(e,t)),e}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(g,s),n.emit(c,s)}return i}cloneBlock(e,t=!1){const i=l.uid(),s=`${e.name}Copy`,a=`${e.title}_副本`,o=new u({id:i,name:s,apiMode:"composition"}).toDsl(),r=l.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,r),!t){const p={model:this,type:"clone",data:{source:e,target:r}};n.emit(g,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(g,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=l.uid(),this.apis.push(e)),!t){const a={model:this,type:s,data:e};n.emit(A,a),n.emit(c,a)}return i||e}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=l.uid(),this.meta.push(e)),!t){const a={model:this,type:s,data:e};n.emit(V,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(V,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)}}setEnv(e,t=!1){if(this.env=[...e],!t){const i={model:this,type:"update",data:this.env};n.emit(c,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(B,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(r=>({id:r.id,path:`${o}/${s}/${r.id}`,name:r.name,title:r.title,meta:r.meta}))}}const N="EVENT_HISTORY_CHANGE",P="EVENT_HISTORY_LOAD";class Y{options={max:50};index=-1;id;type;items;constructor(e,t={}){Object.assign(this.options,t);const{id:i,type:s="file",items:a=[]}=e;this.id=i,this.type=s,this.items=a}toDsl(){const{id:e,type:t,items:i}=this;return{id:e,type:t,items:i.map(s=>({id:s.id,label:s.label,remark:s.remark||""}))}}get(e){return this.items.find(t=>t.id===e)}add(e,t="",i=!1){const{max:s}=this.options,a={id:l.uid(),label:new Date().toLocaleString(),remark:t,dsl:l.cloneDeep(e)};this.items.unshift(a);const o=this.items.filter(r=>!r.remark);if(o.length>s){const r=o.splice(s).map(h=>h.id);this.items=this.items.filter(h=>!r.includes(h.id)),i||n.emit(N,{model:this,type:"delete",data:r})}this.index=-1,i||n.emit(N,{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(N,{model:this,type:"update",data:i})}remove(e,t=!1){const i=l.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(N,{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(P,{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(P,{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(P,{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(N,{model:this,type:"clear",data:t})}}const n=l.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=l.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=M;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=D;exports.Base=K;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=d;exports.EVENT_HISTORY_CHANGE=N;exports.EVENT_HISTORY_LOAD=P;exports.EVENT_NODE_CHANGE=f;exports.EVENT_PROJECT_ACTIVED=I;exports.EVENT_PROJECT_APIS_CHANGE=A;exports.EVENT_PROJECT_BLOCKS_CHANGE=g;exports.EVENT_PROJECT_CHANGE=c;exports.EVENT_PROJECT_DEPS_CHANGE=S;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_GEN_SOURCE=L;exports.EVENT_PROJECT_META_CHANGE=V;exports.EVENT_PROJECT_PAGES_CHANGE=T;exports.EVENT_PROJECT_PUBLISH=B;exports.EventModel=C;exports.HistoryModel=Y;exports.I18N_LOCALES=F;exports.NodeModel=_;exports.ProjectModel=x;exports.PropModel=y;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
@@ -3,10 +3,10 @@ import { uid as m, timestamp as G, isString as N, uuid as R, cloneDeep as T, upp
3
3
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
4
4
  * @name @vtj/core
5
5
  * @author CHC chenhuachun1549@dingtalk.com
6
- * @version 0.19.6
6
+ * @version 0.19.8
7
7
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
8
8
  */
9
- const z = "0.19.6", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", q = [H, L], Q = {
9
+ const z = "0.19.8", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", q = [H, L], Q = {
10
10
  vue: "Vue",
11
11
  "vue-router": "VueRouter"
12
12
  }, X = {
@@ -457,7 +457,7 @@ class _ {
457
457
  return Array.isArray(this.children) ? this.children.findIndex((t) => t === e || t.id === e.id) : -1;
458
458
  }
459
459
  }
460
- const d = "EVENT_BLOCK_CHANGE";
460
+ const l = "EVENT_BLOCK_CHANGE";
461
461
  class u {
462
462
  __VTJ_BLOCK__ = !0;
463
463
  id;
@@ -516,7 +516,7 @@ class u {
516
516
  (a !== void 0 || s === "setup") && (this[s] = a);
517
517
  }
518
518
  const { nodes: i = [] } = e;
519
- i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t || n.emit(d, this);
519
+ i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t || n.emit(l, this);
520
520
  }
521
521
  /**
522
522
  * 获取DSL
@@ -552,7 +552,7 @@ class u {
552
552
  * @param silent
553
553
  */
554
554
  setFunction(e, t, i, s = !1) {
555
- this[e][t] = i, s || n.emit(d, this);
555
+ this[e][t] = i, s || n.emit(l, this);
556
556
  }
557
557
  /**
558
558
  * 删除通用函数属性
@@ -561,10 +561,10 @@ class u {
561
561
  * @param silent
562
562
  */
563
563
  removeFunction(e, t, i = !1) {
564
- delete this[e][t], i || n.emit(d, this);
564
+ delete this[e][t], i || n.emit(l, this);
565
565
  }
566
566
  setComputed(e, t, i = !1) {
567
- t ? this.computed[e] = t : delete this.computed[e], i || n.emit(d, this);
567
+ t ? this.computed[e] = t : delete this.computed[e], i || n.emit(l, this);
568
568
  }
569
569
  /**
570
570
  * 设置状态
@@ -573,7 +573,7 @@ class u {
573
573
  * @param silent
574
574
  */
575
575
  setState(e, t, i = !1) {
576
- this.state[e] = t, i || n.emit(d, this);
576
+ this.state[e] = t, i || n.emit(l, this);
577
577
  }
578
578
  /**
579
579
  * 删除状态
@@ -581,7 +581,7 @@ class u {
581
581
  * @param silent
582
582
  */
583
583
  removeState(e, t = !1) {
584
- delete this.state[e], t || n.emit(d, this);
584
+ delete this.state[e], t || n.emit(l, this);
585
585
  }
586
586
  /**
587
587
  * 更新CSS
@@ -589,7 +589,7 @@ class u {
589
589
  * @param silent
590
590
  */
591
591
  setCss(e, t = !1) {
592
- this.css = e, t || n.emit(d, this);
592
+ this.css = e, t || n.emit(l, this);
593
593
  }
594
594
  /**
595
595
  * 新增或更新 watch
@@ -601,7 +601,7 @@ class u {
601
601
  const i = this.watch.findIndex(
602
602
  (s) => s.id && s.id === e.id || s === e
603
603
  );
604
- i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(d, this);
604
+ i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(l, this);
605
605
  }
606
606
  /**
607
607
  * 删除 watch
@@ -612,7 +612,7 @@ class u {
612
612
  const i = this.watch.findIndex(
613
613
  (s) => s.id && s.id === e.id || s === e
614
614
  );
615
- i > -1 && (this.watch.splice(i, 1), t || n.emit(d, this));
615
+ i > -1 && (this.watch.splice(i, 1), t || n.emit(l, this));
616
616
  }
617
617
  /**
618
618
  * 定义属性参数
@@ -623,7 +623,7 @@ class u {
623
623
  const i = this.props.findIndex(
624
624
  (s) => typeof s == "string" ? s === e.name : s.name === e.name
625
625
  );
626
- i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(d, this);
626
+ i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(l, this);
627
627
  }
628
628
  /**
629
629
  * 删除属性
@@ -634,7 +634,7 @@ class u {
634
634
  const i = this.props.findIndex(
635
635
  (s) => typeof s == "string" ? s === e.name : s.name === e.name
636
636
  );
637
- i > -1 && (this.props.splice(i, 1), t || n.emit(d, this));
637
+ i > -1 && (this.props.splice(i, 1), t || n.emit(l, this));
638
638
  }
639
639
  /**
640
640
  * 设置事件
@@ -645,7 +645,7 @@ class u {
645
645
  const i = N(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
646
646
  (a) => a === i.name || a.name === i.name
647
647
  );
648
- s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(d, this);
648
+ s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(l, this);
649
649
  }
650
650
  /**
651
651
  * 删除事件
@@ -656,10 +656,10 @@ class u {
656
656
  const i = this.emits.findIndex(
657
657
  (s) => N(s) ? s === e : s.name === e
658
658
  );
659
- i > -1 && (this.emits.splice(i, 1), t || n.emit(d, this));
659
+ i > -1 && (this.emits.splice(i, 1), t || n.emit(l, this));
660
660
  }
661
661
  setExpose(e, t = !1) {
662
- this.expose = e, t || n.emit(d, this);
662
+ this.expose = e, t || n.emit(l, this);
663
663
  }
664
664
  /**
665
665
  * 设置插槽
@@ -670,7 +670,7 @@ class u {
670
670
  const i = N(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
671
671
  (a) => a === i.name || a.name === i.name
672
672
  );
673
- s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(d, this);
673
+ s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(l, this);
674
674
  }
675
675
  /**
676
676
  * 删除插槽
@@ -681,7 +681,7 @@ class u {
681
681
  const i = this.slots.findIndex(
682
682
  (s) => N(s) ? s === e : s.name === e
683
683
  );
684
- i > -1 && (this.slots.splice(i, 1), t || n.emit(d, this));
684
+ i > -1 && (this.slots.splice(i, 1), t || n.emit(l, this));
685
685
  }
686
686
  /**
687
687
  * 设置注入
@@ -690,7 +690,7 @@ class u {
690
690
  */
691
691
  setInject(e, t = !1) {
692
692
  const i = this.inject.findIndex((s) => s.name === e.name);
693
- i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(d, this);
693
+ i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(l, this);
694
694
  }
695
695
  /**
696
696
  * 删除注入
@@ -699,7 +699,7 @@ class u {
699
699
  */
700
700
  removeInject(e, t = !1) {
701
701
  const i = this.inject.findIndex((s) => s.name === e.name);
702
- i > -1 && (this.inject.splice(i, 1), t || n.emit(d, this));
702
+ i > -1 && (this.inject.splice(i, 1), t || n.emit(l, this));
703
703
  }
704
704
  /**
705
705
  * 设置数据源
@@ -707,7 +707,7 @@ class u {
707
707
  * @param silent
708
708
  */
709
709
  setDataSource(e, t = !1) {
710
- this.dataSources[e.name] = e, t || n.emit(d, this);
710
+ this.dataSources[e.name] = e, t || n.emit(l, this);
711
711
  }
712
712
  /**
713
713
  * 删除数据源
@@ -715,7 +715,7 @@ class u {
715
715
  * @param silent
716
716
  */
717
717
  removeDataSource(e, t = !1) {
718
- delete this.dataSources[e], t || n.emit(d, this);
718
+ delete this.dataSources[e], t || n.emit(l, this);
719
719
  }
720
720
  /**
721
721
  * 设置 API 风格
@@ -723,7 +723,7 @@ class u {
723
723
  * @param silent
724
724
  */
725
725
  setApiMode(e, t = !1) {
726
- this.apiMode = e, t || n.emit(d, this);
726
+ this.apiMode = e, t || n.emit(l, this);
727
727
  }
728
728
  /**
729
729
  * 设置 ref 声明
@@ -732,7 +732,7 @@ class u {
732
732
  * @param silent
733
733
  */
734
734
  setRef(e, t, i = !1) {
735
- this.refs[e] = t, i || n.emit(d, this);
735
+ this.refs[e] = t, i || n.emit(l, this);
736
736
  }
737
737
  /**
738
738
  * 删除 ref 声明
@@ -740,7 +740,7 @@ class u {
740
740
  * @param silent
741
741
  */
742
742
  removeRef(e, t = !1) {
743
- delete this.refs[e], t || n.emit(d, this);
743
+ delete this.refs[e], t || n.emit(l, this);
744
744
  }
745
745
  /**
746
746
  * 设置 reactive 声明
@@ -749,7 +749,7 @@ class u {
749
749
  * @param silent
750
750
  */
751
751
  setReactive(e, t, i = !1) {
752
- this.reactives[e] = t, i || n.emit(d, this);
752
+ this.reactives[e] = t, i || n.emit(l, this);
753
753
  }
754
754
  /**
755
755
  * 删除 reactive 声明
@@ -757,7 +757,7 @@ class u {
757
757
  * @param silent
758
758
  */
759
759
  removeReactive(e, t = !1) {
760
- delete this.reactives[e], t || n.emit(d, this);
760
+ delete this.reactives[e], t || n.emit(l, this);
761
761
  }
762
762
  /**
763
763
  * 设置组合函数调用
@@ -766,7 +766,7 @@ class u {
766
766
  */
767
767
  setComposable(e, t = !1) {
768
768
  const i = this.composables.findIndex((s) => s.name === e.name);
769
- i > -1 ? this.composables.splice(i, 1, e) : this.composables.push(e), t || n.emit(d, this);
769
+ i > -1 ? this.composables.splice(i, 1, e) : this.composables.push(e), t || n.emit(l, this);
770
770
  }
771
771
  /**
772
772
  * 删除组合函数调用
@@ -775,7 +775,7 @@ class u {
775
775
  */
776
776
  removeComposable(e, t = !1) {
777
777
  const i = this.composables.findIndex((s) => s.name === e);
778
- i > -1 && (this.composables.splice(i, 1), t || n.emit(d, this));
778
+ i > -1 && (this.composables.splice(i, 1), t || n.emit(l, this));
779
779
  }
780
780
  /**
781
781
  * 设置 provide
@@ -784,7 +784,7 @@ class u {
784
784
  * @param silent
785
785
  */
786
786
  setProvide(e, t, i = !1) {
787
- this.provide[e] = t, i || n.emit(d, this);
787
+ this.provide[e] = t, i || n.emit(l, this);
788
788
  }
789
789
  /**
790
790
  * 删除 provide
@@ -792,7 +792,7 @@ class u {
792
792
  * @param silent
793
793
  */
794
794
  removeProvide(e, t = !1) {
795
- delete this.provide[e], t || n.emit(d, this);
795
+ delete this.provide[e], t || n.emit(l, this);
796
796
  }
797
797
  /**
798
798
  * 设置 setup 初始化代码
@@ -800,20 +800,20 @@ class u {
800
800
  * @param silent
801
801
  */
802
802
  setSetup(e, t = !1) {
803
- this.setup = e, t || n.emit(d, this);
803
+ this.setup = e, t || n.emit(l, this);
804
804
  }
805
805
  insertAfter(e, t, i = !1) {
806
806
  e.parent = null;
807
807
  const s = this.nodes.indexOf(t);
808
- this.nodes.splice(s + 1, 0, e), i || n.emit(d, this);
808
+ this.nodes.splice(s + 1, 0, e), i || n.emit(l, this);
809
809
  }
810
810
  insertBefore(e, t, i = !1) {
811
811
  e.parent = null;
812
812
  const s = this.nodes.indexOf(t);
813
- this.nodes.splice(s, 0, e), i || n.emit(d, this);
813
+ this.nodes.splice(s, 0, e), i || n.emit(l, this);
814
814
  }
815
815
  appendNode(e, t = !1) {
816
- e.parent = null, this.nodes.push(e), t || n.emit(d, this);
816
+ e.parent = null, this.nodes.push(e), t || n.emit(l, this);
817
817
  }
818
818
  /**
819
819
  * 添加节点
@@ -827,7 +827,7 @@ class u {
827
827
  }
828
828
  __removeNode(e, t = !1) {
829
829
  const i = this.nodes.findIndex((s) => s.id === e.id);
830
- i > -1 && (this.nodes.splice(i, 1), t || n.emit(d, this));
830
+ i > -1 && (this.nodes.splice(i, 1), t || n.emit(l, this));
831
831
  }
832
832
  /**
833
833
  * 删除节点
@@ -857,7 +857,7 @@ class u {
857
857
  e.movePrev(t);
858
858
  else {
859
859
  const i = this.nodes, s = i.indexOf(e);
860
- s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(d, this));
860
+ s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(l, this));
861
861
  }
862
862
  }
863
863
  /**
@@ -870,7 +870,7 @@ class u {
870
870
  e.moveNext(t);
871
871
  else {
872
872
  const i = this.nodes, s = i.indexOf(e);
873
- s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(d, this));
873
+ s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(l, this));
874
874
  }
875
875
  }
876
876
  /**
@@ -887,13 +887,13 @@ class u {
887
887
  this.locked = !0;
888
888
  for (const t of this.nodes)
889
889
  t.lock(!0);
890
- e || n.emit(d, this);
890
+ e || n.emit(l, this);
891
891
  }
892
892
  unlock(e = !1) {
893
893
  this.locked = !1;
894
894
  for (const t of this.nodes)
895
895
  t.unlock(!0);
896
- e || n.emit(d, this);
896
+ e || n.emit(l, this);
897
897
  }
898
898
  isChild(e) {
899
899
  let t = !1;
@@ -906,7 +906,7 @@ class u {
906
906
  return t;
907
907
  }
908
908
  }
909
- const l = "EVENT_PROJECT_CHANGE", D = "EVENT_PROJECT_ACTIVED", B = "EVENT_PROJECT_DEPS_CHANGE", g = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", V = "EVENT_PROJECT_APIS_CHANGE", w = "EVENT_PROJECT_META_CHANGE", M = "EVENT_PROJECT_PUBLISH", $ = "EVENT_PROJECT_FILE_PUBLISH", K = "EVENT_PROJECT_GEN_SOURCE";
909
+ const d = "EVENT_PROJECT_CHANGE", D = "EVENT_PROJECT_ACTIVED", B = "EVENT_PROJECT_DEPS_CHANGE", g = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", V = "EVENT_PROJECT_APIS_CHANGE", w = "EVENT_PROJECT_META_CHANGE", M = "EVENT_PROJECT_PUBLISH", $ = "EVENT_PROJECT_FILE_PUBLISH", K = "EVENT_PROJECT_GEN_SOURCE";
910
910
  class b {
911
911
  id = "";
912
912
  locked = "";
@@ -959,7 +959,7 @@ class b {
959
959
  const s = e[i];
960
960
  s && (this[i] = s);
961
961
  }
962
- t || n.emit(l, {
962
+ t || n.emit(d, {
963
963
  model: this,
964
964
  type: "update",
965
965
  data: e
@@ -1029,7 +1029,7 @@ class b {
1029
1029
  type: a,
1030
1030
  data: e
1031
1031
  };
1032
- n.emit(B, o), n.emit(l, o);
1032
+ n.emit(B, o), n.emit(d, o);
1033
1033
  }
1034
1034
  }
1035
1035
  /**
@@ -1045,7 +1045,7 @@ class b {
1045
1045
  type: "delete",
1046
1046
  data: e
1047
1047
  };
1048
- n.emit(B, a), n.emit(l, a);
1048
+ n.emit(B, a), n.emit(d, a);
1049
1049
  }
1050
1050
  }
1051
1051
  /**
@@ -1105,7 +1105,7 @@ class b {
1105
1105
  type: "create",
1106
1106
  data: e
1107
1107
  };
1108
- n.emit(g, s), n.emit(l, s);
1108
+ n.emit(g, s), n.emit(d, s);
1109
1109
  }
1110
1110
  return !this.currentFile && !e.dir && (this.active(e, !0), await O(1e3), this.active(e, i)), e;
1111
1111
  }
@@ -1122,7 +1122,7 @@ class b {
1122
1122
  type: "update",
1123
1123
  data: e
1124
1124
  };
1125
- n.emit(g, s), n.emit(l, s);
1125
+ n.emit(g, s), n.emit(d, s);
1126
1126
  }
1127
1127
  return i;
1128
1128
  }
@@ -1152,7 +1152,7 @@ class b {
1152
1152
  type: "update",
1153
1153
  data: a
1154
1154
  };
1155
- n.emit(g, r), n.emit(l, r);
1155
+ n.emit(g, r), n.emit(d, r);
1156
1156
  }
1157
1157
  return !0;
1158
1158
  }
@@ -1181,7 +1181,7 @@ class b {
1181
1181
  target: h
1182
1182
  }
1183
1183
  };
1184
- n.emit(g, v), n.emit(l, v);
1184
+ n.emit(g, v), n.emit(d, v);
1185
1185
  }
1186
1186
  }
1187
1187
  async saveToBlock(e, t = !1) {
@@ -1204,7 +1204,7 @@ class b {
1204
1204
  type: "create",
1205
1205
  data: r
1206
1206
  };
1207
- n.emit(y, h), n.emit(l, h);
1207
+ n.emit(y, h), n.emit(d, h);
1208
1208
  }
1209
1209
  }
1210
1210
  /**
@@ -1228,7 +1228,7 @@ class b {
1228
1228
  type: "delete",
1229
1229
  data: i
1230
1230
  };
1231
- n.emit(g, a), n.emit(l, a);
1231
+ n.emit(g, a), n.emit(d, a);
1232
1232
  }
1233
1233
  }
1234
1234
  /**
@@ -1257,7 +1257,7 @@ class b {
1257
1257
  type: "create",
1258
1258
  data: e
1259
1259
  };
1260
- n.emit(y, o), n.emit(l, o);
1260
+ n.emit(y, o), n.emit(d, o);
1261
1261
  }
1262
1262
  return !this.currentFile && a === "Schema" && (this.active(e, !0), await O(1e3), this.active(e, t)), e;
1263
1263
  }
@@ -1274,7 +1274,7 @@ class b {
1274
1274
  type: "update",
1275
1275
  data: e
1276
1276
  };
1277
- n.emit(y, s), n.emit(l, s);
1277
+ n.emit(y, s), n.emit(d, s);
1278
1278
  }
1279
1279
  return i;
1280
1280
  }
@@ -1293,7 +1293,7 @@ class b {
1293
1293
  target: r
1294
1294
  }
1295
1295
  };
1296
- n.emit(y, p), n.emit(l, p);
1296
+ n.emit(y, p), n.emit(d, p);
1297
1297
  }
1298
1298
  }
1299
1299
  /**
@@ -1309,7 +1309,7 @@ class b {
1309
1309
  type: "delete",
1310
1310
  data: i
1311
1311
  };
1312
- n.emit(y, o), n.emit(l, o);
1312
+ n.emit(y, o), n.emit(d, o);
1313
1313
  }
1314
1314
  }
1315
1315
  /**
@@ -1346,7 +1346,7 @@ class b {
1346
1346
  type: s,
1347
1347
  data: e
1348
1348
  };
1349
- n.emit(V, a), n.emit(l, a);
1349
+ n.emit(V, a), n.emit(d, a);
1350
1350
  }
1351
1351
  return i || e;
1352
1352
  }
@@ -1359,7 +1359,7 @@ class b {
1359
1359
  type: "create",
1360
1360
  data: e
1361
1361
  };
1362
- n.emit(V, i), n.emit(l, i);
1362
+ n.emit(V, i), n.emit(d, i);
1363
1363
  }
1364
1364
  }
1365
1365
  /**
@@ -1375,7 +1375,7 @@ class b {
1375
1375
  type: "delete",
1376
1376
  data: e
1377
1377
  };
1378
- n.emit(V, s), n.emit(l, s);
1378
+ n.emit(V, s), n.emit(d, s);
1379
1379
  }
1380
1380
  }
1381
1381
  existApiName(e, t = []) {
@@ -1392,7 +1392,7 @@ class b {
1392
1392
  type: s,
1393
1393
  data: e
1394
1394
  };
1395
- n.emit(w, a), n.emit(l, a);
1395
+ n.emit(w, a), n.emit(d, a);
1396
1396
  }
1397
1397
  }
1398
1398
  removeMeta(e, t = !1) {
@@ -1403,7 +1403,7 @@ class b {
1403
1403
  type: "delete",
1404
1404
  data: e
1405
1405
  };
1406
- n.emit(w, s), n.emit(l, s);
1406
+ n.emit(w, s), n.emit(d, s);
1407
1407
  }
1408
1408
  }
1409
1409
  existMetaCode(e, t = []) {
@@ -1416,7 +1416,7 @@ class b {
1416
1416
  type: "update",
1417
1417
  data: e
1418
1418
  };
1419
- n.emit(l, i);
1419
+ n.emit(d, i);
1420
1420
  }
1421
1421
  }
1422
1422
  setConfig(e, t = !1) {
@@ -1426,7 +1426,7 @@ class b {
1426
1426
  type: "update",
1427
1427
  data: e
1428
1428
  };
1429
- n.emit(l, i);
1429
+ n.emit(d, i);
1430
1430
  }
1431
1431
  }
1432
1432
  setUniConfig(e, t, i = !1) {
@@ -1436,7 +1436,7 @@ class b {
1436
1436
  type: "update",
1437
1437
  data: this.uniConfig
1438
1438
  };
1439
- n.emit(l, s);
1439
+ n.emit(d, s);
1440
1440
  }
1441
1441
  }
1442
1442
  setGloblas(e, t, i = !1) {
@@ -1446,7 +1446,7 @@ class b {
1446
1446
  type: "update",
1447
1447
  data: this.globals
1448
1448
  };
1449
- n.emit(l, s);
1449
+ n.emit(d, s);
1450
1450
  }
1451
1451
  }
1452
1452
  setI18n(e, t = !1) {
@@ -1456,7 +1456,7 @@ class b {
1456
1456
  type: "update",
1457
1457
  data: this.i18n
1458
1458
  };
1459
- n.emit(l, i);
1459
+ n.emit(d, i);
1460
1460
  }
1461
1461
  }
1462
1462
  setEnv(e, t = !1) {
@@ -1466,7 +1466,7 @@ class b {
1466
1466
  type: "update",
1467
1467
  data: this.env
1468
1468
  };
1469
- n.emit(l, i);
1469
+ n.emit(d, i);
1470
1470
  }
1471
1471
  }
1472
1472
  publish(e) {
@@ -1492,7 +1492,7 @@ class b {
1492
1492
  type: "update",
1493
1493
  data: e
1494
1494
  };
1495
- n.emit(l, t);
1495
+ n.emit(d, t);
1496
1496
  }
1497
1497
  unlock(e) {
1498
1498
  if (e !== this.locked)
@@ -1503,7 +1503,7 @@ class b {
1503
1503
  type: "update",
1504
1504
  data: null
1505
1505
  };
1506
- n.emit(l, t);
1506
+ n.emit(d, t);
1507
1507
  }
1508
1508
  getPageRoutes(e, t) {
1509
1509
  const i = this.platform === "uniapp", s = e || (i ? "pages" : "page"), a = this.getPages(), o = t || "";
@@ -1521,20 +1521,22 @@ class se {
1521
1521
  options = { max: 50 };
1522
1522
  index = -1;
1523
1523
  id;
1524
+ type;
1524
1525
  items;
1525
1526
  constructor(e, t = {}) {
1526
1527
  Object.assign(this.options, t);
1527
- const { id: i, items: s = [] } = e;
1528
- this.id = i, this.items = s;
1528
+ const { id: i, type: s = "file", items: a = [] } = e;
1529
+ this.id = i, this.type = s, this.items = a;
1529
1530
  }
1530
1531
  toDsl() {
1531
- const { id: e, items: t } = this;
1532
+ const { id: e, type: t, items: i } = this;
1532
1533
  return {
1533
1534
  id: e,
1534
- items: t.map((i) => ({
1535
- id: i.id,
1536
- label: i.label,
1537
- remark: i.remark || ""
1535
+ type: t,
1536
+ items: i.map((s) => ({
1537
+ id: s.id,
1538
+ label: s.label,
1539
+ remark: s.remark || ""
1538
1540
  }))
1539
1541
  };
1540
1542
  }
@@ -1684,14 +1686,14 @@ export {
1684
1686
  ie as Base,
1685
1687
  u as BlockModel,
1686
1688
  E as DirectiveModel,
1687
- d as EVENT_BLOCK_CHANGE,
1689
+ l as EVENT_BLOCK_CHANGE,
1688
1690
  x as EVENT_HISTORY_CHANGE,
1689
1691
  S as EVENT_HISTORY_LOAD,
1690
1692
  c as EVENT_NODE_CHANGE,
1691
1693
  D as EVENT_PROJECT_ACTIVED,
1692
1694
  V as EVENT_PROJECT_APIS_CHANGE,
1693
1695
  y as EVENT_PROJECT_BLOCKS_CHANGE,
1694
- l as EVENT_PROJECT_CHANGE,
1696
+ d as EVENT_PROJECT_CHANGE,
1695
1697
  B as EVENT_PROJECT_DEPS_CHANGE,
1696
1698
  $ as EVENT_PROJECT_FILE_PUBLISH,
1697
1699
  K as EVENT_PROJECT_GEN_SOURCE,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/core",
3
3
  "private": false,
4
- "version": "0.19.6",
4
+ "version": "0.19.8",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -1,4 +1,4 @@
1
- import { HistorySchema, HistoryItem, BlockSchema } from '../protocols';
1
+ import { HistorySchema, HistoryItem, HistoryDsl, HistoryType } from '../protocols';
2
2
  import { ModelEventType } from '../tools';
3
3
  export interface HistoryModelOptions {
4
4
  max: number;
@@ -14,6 +14,7 @@ export declare class HistoryModel {
14
14
  private options;
15
15
  index: number;
16
16
  id: string;
17
+ type: HistoryType;
17
18
  items: HistoryItem[];
18
19
  constructor(schema: HistorySchema, options?: Partial<HistoryModelOptions>);
19
20
  toDsl(): HistorySchema;
@@ -28,7 +29,7 @@ export declare class HistoryModel {
28
29
  * @param dsl
29
30
  * @param silent
30
31
  */
31
- add(dsl: BlockSchema, remark?: string, silent?: boolean): void;
32
+ add(dsl: HistoryDsl, remark?: string, silent?: boolean): void;
32
33
  /**
33
34
  * 更新历史记录
34
35
  * @param id
@@ -1,4 +1,7 @@
1
1
  import { BlockSchema } from './block';
2
+ import { ProjectSchema } from './project';
3
+ export type HistoryType = 'file' | 'project';
4
+ export type HistoryDsl = BlockSchema | ProjectSchema;
2
5
  /**
3
6
  * 历史记录描述
4
7
  */
@@ -7,6 +10,10 @@ export interface HistorySchema {
7
10
  * 页面或区块文件id
8
11
  */
9
12
  id: string;
13
+ /**
14
+ * 历史记录类型,旧数据默认为文件历史
15
+ */
16
+ type?: HistoryType;
10
17
  /**
11
18
  * 历史记录项
12
19
  */
@@ -27,7 +34,7 @@ export interface HistoryItem {
27
34
  /**
28
35
  * 记录项内容
29
36
  */
30
- dsl?: BlockSchema;
37
+ dsl?: HistoryDsl;
31
38
  /**
32
39
  * 备注
33
40
  */
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/core
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.19.5
5
+ * @version 0.19.8
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.19.5";
8
+ export declare const version = "0.19.8";