@vtj/core 0.16.16 → 0.16.18

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/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  VTJ 是一款以AI驱动的Vue3前端低代码开发工具。内置低代码引擎、渲染器和代码生成器,支持Vue源码与低代码DSL双向转换,面向前端开发者,开箱即用。 无缝嵌入本地开发工程,不改变前端开发流程和编码习惯。
13
13
 
14
14
  - **官方文档**:[https://vtj.pro](https://vtj.pro)
15
- - **在线应用开发平台**:[https://lcdp.vtj.pro](https://lcdp.vtj.pro)
15
+ - **在线应用开发平台**:[https://app.vtj.pro](https://app.vtj.pro)
16
16
 
17
17
  ## 特性
18
18
 
@@ -32,7 +32,7 @@ VTJ 是一款以AI驱动的Vue3前端低代码开发工具。内置低代码引
32
32
 
33
33
  ### 在线体验
34
34
 
35
- - [https://lcdp.vtj.pro](https://lcdp.vtj.pro)
35
+ - [https://app.vtj.pro](https://app.vtj.pro)
36
36
 
37
37
  访问Vtj专属低代码开发平台,创建应用可以体验设计器和出码功能
38
38
 
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.16.16
5
+ * @version 0.16.18
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const U="0.16.16",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 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,g=Array.isArray(r)?r.map(H=>H.toDsl()):r;return{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:g,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}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];expose=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","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&&(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}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||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)}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",I="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",v="EVENT_PROJECT_PAGES_CHANGE",T="EVENT_PROJECT_BLOCKS_CHANGE",A="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",B="EVENT_PROJECT_PUBLISH",b="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(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)}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)}).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(v,s),n.emit(c,s)}return!this.currentFile&&!e.dir&&(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(v,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(v,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}).toDsl(),h=l.merge({},e,{id:s,name:a,title:o,dsl:r}),p=t?this.getPage(t)?.children||[]:this.pages,O=p.findIndex(g=>g.id===e.id);if(p.splice(O+1,0,h),!i){const g={model:this,type:"clone",data:{source:e,target:h}};n.emit(v,g),n.emit(c,g)}}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(T,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(v,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.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(T,o),n.emit(c,o)}return!this.currentFile&&a==="Schema"&&(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(T,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}).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(T,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(T,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(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)}}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(b,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 D(m){const e=l.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=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=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=T;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=v;exports.EVENT_PROJECT_PUBLISH=B;exports.EventModel=C;exports.HistoryModel=Y;exports.I18N_LOCALES=M;exports.NodeModel=_;exports.ProjectModel=x;exports.PropModel=y;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.16.18",G="BuiltIn",R="VueMaterial",D="VueRouterMaterial",J=[R,D],w={vue:"Vue","vue-router":"VueRouter"},j={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[D]:["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 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:r}=s;return t[i]={name:i,handler:a,modifiers:r},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:r}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=a,this.iterator=r}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:r,iterator:o,id:h}=t;return{id:h,name:i,arg:s,modifiers:a,value:r,iterator:o}})}}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:r,props:o={},events:h={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(a,!0),this.setSlot(r,!0),this.props=y.parse(o),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(r=>r===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:r,children:o,props:h,directives:p,events:O}=this,T=Array.isArray(o)?o.map(H=>H.toDsl()):o;return{id:e,name:t,from:i,invisible:s,locked:a,slot:r,children:T,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="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];expose=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","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&&(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((r,o)=>(r[o]=this[o],r),{}),__VTJ_BLOCK__:t,__VERSION__:e||l.timestamp().toString(),id:i,nodes:s.map(r=>r.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||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)}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=k(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",g="EVENT_PROJECT_PAGES_CHANGE",v="EVENT_PROJECT_BLOCKS_CHANGE",A="EVENT_PROJECT_APIS_CHANGE",V="EVENT_PROJECT_META_CHANGE",B="EVENT_PROJECT_PUBLISH",b="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(r=>r.package===e.package);let a;if(s>-1?(a="update",i.splice(s,1,{...i[s],...e})):(a="create",i.push(e)),!t){const r={model:this,type:a,data:e};n.emit(S,r),n.emit(c,r)}}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 r=t(i,a.children);if(r)return r}}};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)}).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)}return!this.currentFile&&!e.dir&&(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(g,s),n.emit(c,s)}return i}findParent(e){const t=(i,s=[],a)=>{for(const r of s){if(r.id===i)return a;if(r.children&&r.children.length){const o=t(i,r.children,r);if(o)return o}}};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 r=this.findParent(e);if(r?r.children=r.children?.filter(o=>o.id!==e):this.pages=this.pages.filter(o=>o.id!==e),s?(s.dir||s.layout)&&(s.children?s.children.push(a):s.children=[a]):this.pages.push(a),!i){const o={model:this,type:"update",data:a};n.emit(g,o),n.emit(c,o)}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`,r=`${e.title}_副本`,o=new u({id:s,name:a}).toDsl(),h=l.merge({},e,{id:s,name:a,title:r,dsl:o}),p=t?this.getPage(t)?.children||[]:this.pages,O=p.findIndex(T=>T.id===e.id);if(p.splice(O+1,0,h),!i){const T={model:this,type:"clone",data:{source:e,target:h}};n.emit(g,T),n.emit(c,T)}}async saveToBlock(e,t=!1){this.active(e,t),await l.delay(1e3);const i=l.uid(),s=e.name,a=e.title,r=new u({...e.dsl,id:i,name:s}).toDsl(),o=l.merge({},e,{id:i,name:s,title:a,dsl:r,type:"block",fromType:"Schema"});if(this.blocks.push(o),!t){const h={model:this,type:"create",data:o};n.emit(v,h),n.emit(c,h)}}removePage(e,t=!1){const i=this.getPage(e),s=(a,r)=>{const o=r.findIndex(h=>h.id===a);if(o>=0){r.splice(o,1);return}for(const h of r)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(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||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}).toDsl(),this.blocks.push(e);const a=e.fromType||"Schema";if(!t){const r={model:this,type:"create",data:e};n.emit(v,r),n.emit(c,r)}return!this.currentFile&&a==="Schema"&&(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(v,s),n.emit(c,s)}return i}cloneBlock(e,t=!1){const i=l.uid(),s=`${e.name}Copy`,a=`${e.title}_副本`,r=new u({id:i,name:s}).toDsl(),o=l.merge({},e,{id:i,name:s,title:a,dsl:r}),h=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(h+1,0,o),!t){const p={model:this,type:"clone",data:{source:e,target:o}};n.emit(v,p),n.emit(c,p)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,a=s.findIndex(r=>r.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 r={model:this,type:"delete",data:i};n.emit(v,r),n.emit(c,r)}}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(b,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(),r=t||"";return a.map(o=>({id:o.id,path:`${r}/${s}/${o.id}`,name:o.name,title:o.title,meta:o.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 r=this.items.filter(o=>!o.remark);if(r.length>s){const o=r.splice(s).map(h=>h.id);this.items=this.items.filter(h=>!o.includes(h.id)),i||n.emit(N,{model:this,type:"delete",data:o})}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(r=>r.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 k(m){const e=l.cloneDeep(m);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>k(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=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=v;exports.EVENT_PROJECT_CHANGE=c;exports.EVENT_PROJECT_DEPS_CHANGE=S;exports.EVENT_PROJECT_FILE_PUBLISH=b;exports.EVENT_PROJECT_GEN_SOURCE=L;exports.EVENT_PROJECT_META_CHANGE=V;exports.EVENT_PROJECT_PAGES_CHANGE=g;exports.EVENT_PROJECT_PUBLISH=B;exports.EventModel=C;exports.HistoryModel=Y;exports.I18N_LOCALES=M;exports.NodeModel=_;exports.ProjectModel=x;exports.PropModel=y;exports.Service=$;exports.VTJ_CORE_VERSION=U;exports.cloneDsl=k;exports.createNodeFrom=Q;exports.emitter=n;exports.isBlock=z;exports.isBlockSchema=q;exports.isNode=W;
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { uid as m, timestamp as G, isString as C, uuid as b, cloneDeep as T, upperFirstCamelCase as R, delay as O, merge as I, toArray as j, mitt as F } from "@vtj/base";
1
+ import { uid as m, timestamp as G, isString as N, uuid as R, cloneDeep as T, upperFirstCamelCase as b, delay as O, merge as I, toArray as j, mitt as F } from "@vtj/base";
2
2
  /**!
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.16.16
6
+ * @version 0.16.18
7
7
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
8
8
  */
9
- const z = "0.16.16", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", q = [H, L], Q = {
9
+ const z = "0.16.18", W = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", q = [H, L], Q = {
10
10
  vue: "Vue",
11
11
  "vue-router": "VueRouter"
12
12
  }, X = {
@@ -79,7 +79,7 @@ class A {
79
79
  return Object.entries(e).reduce((t, [i, s]) => (t[i] = new A(i, s), t), {});
80
80
  }
81
81
  }
82
- class N {
82
+ class C {
83
83
  constructor(e) {
84
84
  this.schema = e;
85
85
  const { name: t, handler: i } = this.schema;
@@ -101,7 +101,7 @@ class N {
101
101
  }
102
102
  static parse(e = {}) {
103
103
  return Object.entries(e).reduce(
104
- (t, [i, s]) => (t[i] = new N(s), t),
104
+ (t, [i, s]) => (t[i] = new C(s), t),
105
105
  {}
106
106
  );
107
107
  }
@@ -144,9 +144,9 @@ class v {
144
144
  }
145
145
  static toDsl(e = []) {
146
146
  return e.map((t) => {
147
- const { name: i, arg: s, modifiers: a, value: r, iterator: o, id: c } = t;
147
+ const { name: i, arg: s, modifiers: a, value: r, iterator: o, id: h } = t;
148
148
  return {
149
- id: c,
149
+ id: h,
150
150
  name: i,
151
151
  arg: s,
152
152
  modifiers: a,
@@ -156,7 +156,7 @@ class v {
156
156
  });
157
157
  }
158
158
  }
159
- const h = "EVENT_NODE_CHANGE";
159
+ const c = "EVENT_NODE_CHANGE";
160
160
  class _ {
161
161
  constructor(e, t = null) {
162
162
  this.parent = t;
@@ -227,10 +227,10 @@ class _ {
227
227
  children: a = [],
228
228
  slot: r,
229
229
  props: o = {},
230
- events: c = {},
230
+ events: h = {},
231
231
  directives: p = []
232
232
  } = e;
233
- this.invisible = i, this.locked = s, this.setChildren(a, !0), this.setSlot(r, !0), this.props = A.parse(o), this.events = N.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(r, !0), this.props = A.parse(o), this.events = C.parse(h), this.directives = v.parse(p), t || n.emit(c, this);
234
234
  }
235
235
  /**
236
236
  * 设置子节点
@@ -238,7 +238,7 @@ class _ {
238
238
  * @param silent
239
239
  */
240
240
  setChildren(e = "", t = !1) {
241
- Array.isArray(e) ? this.children = e.map((i) => new _(i, this)) : this.children = e, t || n.emit(h, this);
241
+ Array.isArray(e) ? this.children = e.map((i) => new _(i, this)) : this.children = e, t || n.emit(c, this);
242
242
  }
243
243
  /**
244
244
  * 设置节点放置的插槽
@@ -246,7 +246,7 @@ class _ {
246
246
  * @param silent
247
247
  */
248
248
  setSlot(e, t = !1) {
249
- this.slot = typeof e == "string" ? { name: e, params: [] } : e, t || n.emit(h, this);
249
+ this.slot = typeof e == "string" ? { name: e, params: [] } : e, t || n.emit(c, this);
250
250
  }
251
251
  /**
252
252
  * 新增或更新属性
@@ -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 A(e, t, i), s || n.emit(h, this);
260
+ a ? a.setValue(t) : this.props[e] = new A(e, t, i), s || n.emit(c, this);
261
261
  }
262
262
  /**
263
263
  * 删除属性
@@ -265,7 +265,7 @@ class _ {
265
265
  * @param silent
266
266
  */
267
267
  removeProp(e, t = !1) {
268
- delete this.props[e], t || n.emit(h, this);
268
+ delete this.props[e], t || n.emit(c, this);
269
269
  }
270
270
  /**
271
271
  * 获取属性值
@@ -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 N(e), t || n.emit(h, this);
287
+ i ? i.update(e) : this.events[e.name] = new C(e), t || n.emit(c, this);
288
288
  }
289
289
  /**
290
290
  * 删除事件
@@ -292,7 +292,7 @@ class _ {
292
292
  * @param silent
293
293
  */
294
294
  removeEvent(e, t = !1) {
295
- delete this.events[e], t || n.emit(h, this);
295
+ delete this.events[e], t || n.emit(c, this);
296
296
  }
297
297
  /**
298
298
  * 新增或更新指令
@@ -301,7 +301,7 @@ class _ {
301
301
  */
302
302
  setDirective(e, t = !1) {
303
303
  const i = e instanceof v ? e : new v(e), s = this.directives.findIndex((a) => a.id === e.id);
304
- s >= 0 ? this.directives.splice(s, 1, i) : this.directives.push(i), t || n.emit(h, this);
304
+ s >= 0 ? this.directives.splice(s, 1, i) : this.directives.push(i), t || n.emit(c, this);
305
305
  }
306
306
  /**
307
307
  * 删除指令
@@ -312,7 +312,7 @@ class _ {
312
312
  const i = this.directives.findIndex(
313
313
  (s) => s === e || s.id === e.id
314
314
  );
315
- i >= 0 && this.directives.splice(i, 1), t || n.emit(h, this);
315
+ i >= 0 && this.directives.splice(i, 1), t || n.emit(c, this);
316
316
  }
317
317
  /**
318
318
  * 删除子节点
@@ -324,7 +324,7 @@ class _ {
324
324
  const { children: i, disposed: s } = this;
325
325
  if (s || !Array.isArray(i)) return;
326
326
  const a = i.findIndex((r) => r === e);
327
- e.parent = null, i.splice(a, 1), t || n.emit(h, this);
327
+ e.parent = null, i.splice(a, 1), t || n.emit(c, this);
328
328
  }
329
329
  /**
330
330
  * 追加子节点
@@ -334,7 +334,7 @@ class _ {
334
334
  */
335
335
  appendChild(e, t = !1) {
336
336
  const { children: i, disposed: s } = this;
337
- s || (e.parent = this, Array.isArray(i) ? i.push(e) : this.children = [e], t || n.emit(h, this));
337
+ s || (e.parent = this, Array.isArray(i) ? i.push(e) : this.children = [e], t || n.emit(c, this));
338
338
  }
339
339
  /**
340
340
  * 在当前节点的后面插入节点
@@ -348,7 +348,7 @@ class _ {
348
348
  if (Array.isArray(i)) {
349
349
  e.parent = this.parent;
350
350
  const s = i.indexOf(this);
351
- i.splice(s + 1, 0, e), t || n.emit(h, this.parent);
351
+ i.splice(s + 1, 0, e), t || n.emit(c, this.parent);
352
352
  }
353
353
  }
354
354
  /**
@@ -363,7 +363,7 @@ class _ {
363
363
  if (Array.isArray(i)) {
364
364
  e.parent = this.parent;
365
365
  const s = i.indexOf(this);
366
- i.splice(s, 0, e), t || n.emit(h, this.parent);
366
+ i.splice(s, 0, e), t || n.emit(c, this.parent);
367
367
  }
368
368
  }
369
369
  movePrev(e = !1) {
@@ -372,7 +372,7 @@ class _ {
372
372
  const i = t.children;
373
373
  if (Array.isArray(i)) {
374
374
  const s = i.indexOf(this);
375
- s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, this), e || n.emit(h, t));
375
+ s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, this), e || n.emit(c, t));
376
376
  }
377
377
  }
378
378
  moveNext(e = !1) {
@@ -381,7 +381,7 @@ class _ {
381
381
  const i = t.children;
382
382
  if (Array.isArray(i)) {
383
383
  const s = i.indexOf(this);
384
- s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, this), e || n.emit(h, t));
384
+ s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, this), e || n.emit(c, t));
385
385
  }
386
386
  }
387
387
  /**
@@ -397,7 +397,7 @@ class _ {
397
397
  locked: a,
398
398
  slot: r,
399
399
  children: o,
400
- props: c,
400
+ props: h,
401
401
  directives: p,
402
402
  events: P
403
403
  } = this, E = Array.isArray(o) ? o.map((U) => U.toDsl()) : o;
@@ -409,9 +409,9 @@ class _ {
409
409
  locked: a,
410
410
  slot: r,
411
411
  children: E,
412
- props: A.toDsl(c),
412
+ props: A.toDsl(h),
413
413
  directives: v.toDsl(p),
414
- events: N.toDsl(P)
414
+ events: C.toDsl(P)
415
415
  };
416
416
  }
417
417
  /**
@@ -421,25 +421,25 @@ class _ {
421
421
  */
422
422
  dispose(e = !1) {
423
423
  const { children: t, disposed: i } = this;
424
- 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]);
424
+ i || (Array.isArray(t) && t.forEach((s) => s.dispose(!0)), this.parent ? this.parent.removeChild(this, e) : e || n.emit(c, this), this.parent = null, this.disposed = !0, delete _.nodes[this.id]);
425
425
  }
426
426
  lock(e = !1) {
427
427
  if (this.locked = !0, Array.isArray(this.children))
428
428
  for (const t of this.children)
429
429
  t.lock(!0);
430
- e || n.emit(h, this);
430
+ e || n.emit(c, this);
431
431
  }
432
432
  unlock(e = !1) {
433
433
  if (this.locked = !1, Array.isArray(this.children))
434
434
  for (const t of this.children)
435
435
  t.unlock(!0);
436
- e || n.emit(h, this);
436
+ e || n.emit(c, this);
437
437
  }
438
438
  setVisible(e, t = !1) {
439
439
  if (this.invisible = !e, Array.isArray(this.children))
440
440
  for (const i of this.children)
441
441
  i.setVisible(e, !0);
442
- t || n.emit(h, this);
442
+ t || n.emit(c, this);
443
443
  }
444
444
  isChild(e) {
445
445
  let t = !1;
@@ -453,6 +453,9 @@ class _ {
453
453
  }
454
454
  return t;
455
455
  }
456
+ findChildIndex(e) {
457
+ return Array.isArray(this.children) ? this.children.findIndex((t) => t === e || t.id === e.id) : -1;
458
+ }
456
459
  }
457
460
  const l = "EVENT_BLOCK_CHANGE";
458
461
  class u {
@@ -621,7 +624,7 @@ class u {
621
624
  * @param silent
622
625
  */
623
626
  setEmit(e, t = !1) {
624
- const i = C(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
627
+ const i = N(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
625
628
  (a) => a === i.name || a.name === i.name
626
629
  );
627
630
  s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(l, this);
@@ -633,7 +636,7 @@ class u {
633
636
  */
634
637
  removeEmit(e, t = !1) {
635
638
  const i = this.emits.findIndex(
636
- (s) => C(s) ? s === e : s.name === e
639
+ (s) => N(s) ? s === e : s.name === e
637
640
  );
638
641
  i > -1 && (this.emits.splice(i, 1), t || n.emit(l, this));
639
642
  }
@@ -646,7 +649,7 @@ class u {
646
649
  * @param silent
647
650
  */
648
651
  setSlot(e, t = !1) {
649
- const i = C(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
652
+ const i = N(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
650
653
  (a) => a === i.name || a.name === i.name
651
654
  );
652
655
  s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(l, this);
@@ -658,7 +661,7 @@ class u {
658
661
  */
659
662
  removeSlot(e, t = !1) {
660
663
  const i = this.slots.findIndex(
661
- (s) => C(s) ? s === e : s.name === e
664
+ (s) => N(s) ? s === e : s.name === e
662
665
  );
663
666
  i > -1 && (this.slots.splice(i, 1), t || n.emit(l, this));
664
667
  }
@@ -801,7 +804,7 @@ class u {
801
804
  }
802
805
  }
803
806
  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", $ = "EVENT_PROJECT_PUBLISH", M = "EVENT_PROJECT_FILE_PUBLISH", K = "EVENT_PROJECT_GEN_SOURCE";
804
- class S {
807
+ class k {
805
808
  id = "";
806
809
  locked = "";
807
810
  platform = "web";
@@ -824,7 +827,7 @@ class S {
824
827
  };
825
828
  env = [];
826
829
  __BASE_PATH__ = "/";
827
- __UID__ = b(!0);
830
+ __UID__ = R(!0);
828
831
  static attrs = [
829
832
  "locked",
830
833
  "platform",
@@ -846,10 +849,10 @@ class S {
846
849
  ];
847
850
  constructor(e) {
848
851
  const { id: t, __UID__: i } = e;
849
- this.id = t || m(), this.__UID__ = i || b(!0), this.update(e, !0);
852
+ this.id = t || m(), this.__UID__ = i || R(!0), this.update(e, !0);
850
853
  }
851
854
  update(e, t = !1) {
852
- for (const i of S.attrs) {
855
+ for (const i of k.attrs) {
853
856
  const s = e[i];
854
857
  s && (this[i] = s);
855
858
  }
@@ -867,7 +870,7 @@ class S {
867
870
  delete t.dsl, t.children && t.children.length && this.cleanPagesDsl(t.children);
868
871
  }
869
872
  toDsl(e) {
870
- const { id: t } = this, i = S.attrs.reduce(
873
+ const { id: t } = this, i = k.attrs.reduce(
871
874
  (s, a) => (s[a] = this[a], s),
872
875
  {}
873
876
  );
@@ -986,7 +989,7 @@ class S {
986
989
  async createPage(e, t, i = !1) {
987
990
  if (e.id = e.raw ? e.name : e.id || m(), e.type = "page", e.dir ? e.children = [] : e.dsl = e.dsl || new u({
988
991
  id: e.id,
989
- name: R(e.name)
992
+ name: b(e.name)
990
993
  }).toDsl(), t) {
991
994
  const s = this.getPage(t);
992
995
  s ? s.children ? s.children.push(e) : s.children = [e] : console.warn(`not found PageFile for id: ${t} `);
@@ -1063,14 +1066,14 @@ class S {
1063
1066
  const s = m(), a = `${e.name}Copy`, r = `${e.title}_副本`, o = new u({
1064
1067
  id: s,
1065
1068
  name: a
1066
- }).toDsl(), c = I({}, e, { id: s, name: a, title: r, dsl: o }), p = t ? this.getPage(t)?.children || [] : this.pages, P = p.findIndex((E) => E.id === e.id);
1067
- if (p.splice(P + 1, 0, c), !i) {
1069
+ }).toDsl(), h = I({}, e, { id: s, name: a, title: r, dsl: o }), p = t ? this.getPage(t)?.children || [] : this.pages, P = p.findIndex((E) => E.id === e.id);
1070
+ if (p.splice(P + 1, 0, h), !i) {
1068
1071
  const E = {
1069
1072
  model: this,
1070
1073
  type: "clone",
1071
1074
  data: {
1072
1075
  source: e,
1073
- target: c
1076
+ target: h
1074
1077
  }
1075
1078
  };
1076
1079
  n.emit(g, E), n.emit(d, E);
@@ -1091,12 +1094,12 @@ class S {
1091
1094
  fromType: "Schema"
1092
1095
  });
1093
1096
  if (this.blocks.push(o), !t) {
1094
- const c = {
1097
+ const h = {
1095
1098
  model: this,
1096
1099
  type: "create",
1097
1100
  data: o
1098
1101
  };
1099
- n.emit(y, c), n.emit(d, c);
1102
+ n.emit(y, h), n.emit(d, h);
1100
1103
  }
1101
1104
  }
1102
1105
  /**
@@ -1106,13 +1109,13 @@ class S {
1106
1109
  */
1107
1110
  removePage(e, t = !1) {
1108
1111
  const i = this.getPage(e), s = (a, r) => {
1109
- const o = r.findIndex((c) => c.id === a);
1112
+ const o = r.findIndex((h) => h.id === a);
1110
1113
  if (o >= 0) {
1111
1114
  r.splice(o, 1);
1112
1115
  return;
1113
1116
  }
1114
- for (const c of r)
1115
- c.children && c.children.length && s(a, c.children);
1117
+ for (const h of r)
1118
+ h.children && h.children.length && s(a, h.children);
1116
1119
  };
1117
1120
  if (s(e, this.pages), e === this.homepage && (this.homepage = ""), this.currentFile?.id === e && this.deactivate(t), !t) {
1118
1121
  const a = {
@@ -1140,8 +1143,8 @@ class S {
1140
1143
  * @param silent
1141
1144
  */
1142
1145
  async createBlock(e, t = !1) {
1143
- const i = e.id || m(), s = R(e.name);
1144
- e.id = i, e.type = "block", e.dsl = new u({ id: i, name: s }).toDsl(), this.blocks.push(e);
1146
+ const i = e.id || m(), s = b(e.name);
1147
+ e.id = i, e.type = "block", e.fromType = e.fromType || "Schema", e.dsl = new u({ id: i, name: s }).toDsl(), this.blocks.push(e);
1145
1148
  const a = e.fromType || "Schema";
1146
1149
  if (!t) {
1147
1150
  const r = {
@@ -1174,8 +1177,8 @@ class S {
1174
1177
  const i = m(), s = `${e.name}Copy`, a = `${e.title}_副本`, r = new u({
1175
1178
  id: i,
1176
1179
  name: s
1177
- }).toDsl(), o = I({}, e, { id: i, name: s, title: a, dsl: r }), c = this.blocks.findIndex((p) => p.id === e.id);
1178
- if (this.blocks.splice(c + 1, 0, o), !t) {
1180
+ }).toDsl(), o = I({}, e, { id: i, name: s, title: a, dsl: r }), h = this.blocks.findIndex((p) => p.id === e.id);
1181
+ if (this.blocks.splice(h + 1, 0, o), !t) {
1179
1182
  const p = {
1180
1183
  model: this,
1181
1184
  type: "clone",
@@ -1407,7 +1410,7 @@ class S {
1407
1410
  }));
1408
1411
  }
1409
1412
  }
1410
- const x = "EVENT_HISTORY_CHANGE", k = "EVENT_HISTORY_LOAD";
1413
+ const x = "EVENT_HISTORY_CHANGE", S = "EVENT_HISTORY_LOAD";
1411
1414
  class se {
1412
1415
  options = { max: 50 };
1413
1416
  index = -1;
@@ -1452,8 +1455,8 @@ class se {
1452
1455
  this.items.unshift(a);
1453
1456
  const r = this.items.filter((o) => !o.remark);
1454
1457
  if (r.length > s) {
1455
- const o = r.splice(s).map((c) => c.id);
1456
- this.items = this.items.filter((c) => !o.includes(c.id)), i || n.emit(x, {
1458
+ const o = r.splice(s).map((h) => h.id);
1459
+ this.items = this.items.filter((h) => !o.includes(h.id)), i || n.emit(x, {
1457
1460
  model: this,
1458
1461
  type: "delete",
1459
1462
  data: o
@@ -1501,7 +1504,7 @@ class se {
1501
1504
  if (t < 0) return;
1502
1505
  --this.index;
1503
1506
  const s = i[this.index];
1504
- s && !e && n.emit(k, {
1507
+ s && !e && n.emit(S, {
1505
1508
  model: this,
1506
1509
  type: "load",
1507
1510
  data: s
@@ -1512,7 +1515,7 @@ class se {
1512
1515
  if (t >= i.length - 1) return;
1513
1516
  t < 0 && (this.index = 0), ++this.index;
1514
1517
  const s = i[this.index];
1515
- s && !e && n.emit(k, {
1518
+ s && !e && n.emit(S, {
1516
1519
  model: this,
1517
1520
  type: "load",
1518
1521
  data: s
@@ -1520,7 +1523,7 @@ class se {
1520
1523
  }
1521
1524
  load(e, t = !1) {
1522
1525
  const i = this.items.findIndex((s) => s.id === e);
1523
- i >= 0 && (this.index = i, t || n.emit(k, {
1526
+ i >= 0 && (this.index = i, t || n.emit(S, {
1524
1527
  model: this,
1525
1528
  type: "load",
1526
1529
  data: this.items[i]
@@ -1577,8 +1580,8 @@ export {
1577
1580
  v as DirectiveModel,
1578
1581
  l as EVENT_BLOCK_CHANGE,
1579
1582
  x as EVENT_HISTORY_CHANGE,
1580
- k as EVENT_HISTORY_LOAD,
1581
- h as EVENT_NODE_CHANGE,
1583
+ S as EVENT_HISTORY_LOAD,
1584
+ c as EVENT_NODE_CHANGE,
1582
1585
  D as EVENT_PROJECT_ACTIVED,
1583
1586
  V as EVENT_PROJECT_APIS_CHANGE,
1584
1587
  y as EVENT_PROJECT_BLOCKS_CHANGE,
@@ -1589,11 +1592,11 @@ export {
1589
1592
  w as EVENT_PROJECT_META_CHANGE,
1590
1593
  g as EVENT_PROJECT_PAGES_CHANGE,
1591
1594
  $ as EVENT_PROJECT_PUBLISH,
1592
- N as EventModel,
1595
+ C as EventModel,
1593
1596
  se as HistoryModel,
1594
1597
  ee as I18N_LOCALES,
1595
1598
  _ as NodeModel,
1596
- S as ProjectModel,
1599
+ k as ProjectModel,
1597
1600
  A as PropModel,
1598
1601
  te as Service,
1599
1602
  z as VTJ_CORE_VERSION,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/core",
3
3
  "private": false,
4
- "version": "0.16.16",
4
+ "version": "0.16.18",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -171,4 +171,5 @@ export declare class NodeModel {
171
171
  unlock(silent?: boolean): void;
172
172
  setVisible(visible: boolean, silent?: boolean): void;
173
173
  isChild(node: NodeModel): boolean;
174
+ findChildIndex(child: NodeModel): number;
174
175
  }
@@ -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.16.15
5
+ * @version 0.16.17
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.16.15";
8
+ export declare const version = "0.16.17";