@vtj/core 0.13.13 → 0.13.15
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 +2 -2
- package/dist/index.mjs +160 -112
- package/package.json +1 -1
- package/types/constants.d.ts +4 -0
- package/types/models/project.d.ts +11 -1
- package/types/protocols/schemas/project.d.ts +34 -0
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/core
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.13.
|
|
5
|
+
* @version 0.13.15
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const U="0.13.13",G="BuiltIn",R="VueMaterial",B="VueRouterMaterial",J=[R,B],w={vue:"Vue","vue-router":"VueRouter"},F={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[B]:["RouterView","RouterLink"]},j=["slot","template","component","img","div","p","h1","h2","h3","span","a"];class M{}class ${listeners=[];isReady=!1;triggerReady(){this.isReady=!0;for(const e of this.listeners)e();this.listeners=[]}ready(e){this.isReady?e():this.listeners.push(e)}resetReady(){this.isReady=!1}}class v{constructor(e,t,i){this.name=e,this.value=t,this.defaultValue=i,this.setValue(t)}isUnset=!1;setValue(e){this.value=e,this.isUnset=this.value===this.defaultValue}getValue(){return this.value??this.defaultValue}static toDsl(e={}){return Object.entries(e).reduce((t,[i,s])=>(s.isUnset||(t[i]=s.getValue()),t),{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(i,s),t),{})}}class y{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 y(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||r.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value:a,iterator:o}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=a,this.iterator=o}static parse(e=[]){return e.map(t=>new E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:a,value:o,iterator:c,id:f}=t;return{id:f,name:i,arg:s,modifiers:a,value:o,iterator:c}})}}const h="EVENT_NODE_CHANGE";class _{constructor(e,t=null){this.parent=t;const{id:i=r.uid(),name:s,from:a=""}=e;this.id=i,this.name=s,this.from=a,this.update(e,!0),_.nodes[this.id]=this}__VTJ_NODE__=!0;locked=!1;static nodes={};id;name;from;invisible=!1;children="";slot;props={};events={};directives=[];disposed=!1;update(e,t=!1){const{invisible:i=!1,locked:s=!1,children:a=[],slot:o,props:c={},events:f={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(a,!0),this.setSlot(o,!0),this.props=v.parse(c),this.events=y.parse(f),this.directives=E.parse(p),t||n.emit(h,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new _(i,this)):this.children=e,t||n.emit(h,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(h,this)}setProp(e,t,i,s=!1){const a=this.props[e];a?a.setValue(t):this.props[e]=new v(e,t,i),s||n.emit(h,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(h,this)}getPropValue(e){const t=this.props[e];if(t)return t.getValue()}setEvent(e,t=!1){const i=this.events[e.name];i?i.update(e):this.events[e.name]=new y(e),t||n.emit(h,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(h,this)}setDirective(e,t=!1){const i=e instanceof E?e:new E(e),s=this.directives.findIndex(a=>a.id===e.id);s>=0?this.directives.splice(s,1,i):this.directives.push(i),t||n.emit(h,this)}removeDirective(e,t=!1){const i=this.directives.findIndex(s=>s===e||s.id===e.id);i>=0&&this.directives.splice(i,1),t||n.emit(h,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const a=i.findIndex(o=>o===e);e.parent=null,i.splice(a,1),t||n.emit(h,this)}appendChild(e,t=!1){const{children:i,disposed:s}=this;s||(e.parent=this,Array.isArray(i)?i.push(e):this.children=[e],t||n.emit(h,this))}insertAfter(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s+1,0,e),t||n.emit(h,this.parent)}}insertBefore(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s,0,e),t||n.emit(h,this.parent)}}movePrev(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>0&&(i.splice(s,1),i.splice(s-1,0,this),e||n.emit(h,t))}}moveNext(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,this),e||n.emit(h,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:c,props:f,directives:p,events:O}=this,T=Array.isArray(c)?c.map(L=>L.toDsl()):c;return{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:T,props:v.toDsl(f),directives:E.toDsl(p),events:y.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(h,this),this.parent=null,this.disposed=!0,delete _.nodes[this.id])}lock(e=!1){if(this.locked=!0,Array.isArray(this.children))for(const t of this.children)t.lock(!0);e||n.emit(h,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(h,this)}setVisible(e,t=!1){if(this.invisible=!e,Array.isArray(this.children))for(const i of this.children)i.setVisible(e,!0);t||n.emit(h,this)}isChild(e){let t=!1;if(Array.isArray(this.children)){for(const i of this.children)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break}return t}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||r.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const a=e[s];a!==void 0&&(this[s]=a)}const{nodes:i=[]}=e;i.length?this.nodes=i.map(s=>new _(s)):this.nodes=[],t||n.emit(d,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((o,c)=>(o[c]=this[c],o),{}),__VTJ_BLOCK__:t,__VERSION__:e||r.timestamp().toString(),id:i,nodes:s.map(o=>o.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}setFunction(e,t,i,s=!1){this[e][t]=i,s||n.emit(d,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(d,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(d,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(d,this)}setCss(e,t=!1){this.css=e,t||n.emit(d,this)}setWatch(e,t=!1){e.id=e.id||r.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(d,this)}removeWatch(e,t=!1){const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1&&(this.watch.splice(i,1),t||n.emit(d,this))}setProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1?this.props.splice(i,1,e):this.props.push(e),t||n.emit(d,this)}removeProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1&&(this.props.splice(i,1),t||n.emit(d,this))}setEmit(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(d,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(d,this))}setSlot(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(d,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.slots.splice(i,1),t||n.emit(d,this))}setInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1?this.inject.splice(i,1,e):this.inject.push(e),t||n.emit(d,this)}removeInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1&&(this.inject.splice(i,1),t||n.emit(d,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(d,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(d,this)}insertAfter(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s+1,0,e),i||n.emit(d,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(d,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(d,this)}addNode(e,t,i="inner",s=!1){t?["left","top"].includes(i)?t.parent?t.insertAfter(e,s):this.insertBefore(e,t,s):["right","bottom"].includes(i)?t.parent?t.insertAfter(e,s):this.insertAfter(e,t,s):t.appendChild(e,s):this.appendNode(e,s)}__removeNode(e,t=!1){const i=this.nodes.findIndex(s=>s.id===e.id);i>-1&&(this.nodes.splice(i,1),t||n.emit(d,this))}removeNode(e,t=!1){e.parent?e.dispose(t):(e.dispose(!0),this.__removeNode(e,t))}move(e,t,i="inner",s=!1){e.parent?e.parent.removeChild(e,!0):this.__removeNode(e,!0),this.addNode(e,t,i,s)}movePrev(e,t=!1){if(e.parent)e.movePrev(t);else{const i=this.nodes,s=i.indexOf(e);s>0&&(i.splice(s,1),i.splice(s-1,0,e),t||n.emit(d,this))}}moveNext(e,t=!1){if(e.parent)e.moveNext(t);else{const i=this.nodes,s=i.indexOf(e);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,e),t||n.emit(d,this))}}cloneNode(e,t=!1){const i=D(e.toDsl()),s=new _(i);return this.addNode(s,e,"bottom",t),s}lock(e=!1){this.locked=!0;for(const t of this.nodes)t.lock(!0);e||n.emit(d,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(d,this)}isChild(e){let t=!1;for(const i of this.nodes)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break;return t}}const l="EVENT_PROJECT_CHANGE",P="EVENT_PROJECT_ACTIVED",I="EVENT_PROJECT_DEPS_CHANGE",C="EVENT_PROJECT_PAGES_CHANGE",N="EVENT_PROJECT_BLOCKS_CHANGE",V="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",k="EVENT_PROJECT_PUBLISH",b="EVENT_PROJECT_FILE_PUBLISH",H="EVENT_PROJECT_GEN_SOURCE";class x{id="";locked="";platform="web";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};uniConfig={};globals={};__BASE_PATH__="/";__UID__=r.uuid(!0);static attrs=["locked","platform","name","homepage","description","dependencies","pages","blocks","apis","meta","config","uniConfig","globals","__BASE_PATH__","__UID__"];constructor(e){const{id:t,__UID__:i}=e;this.id=t||r.uid(),this.__UID__=i||r.uuid(!0),this.update(e,!0)}update(e,t=!1){for(const i of x.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(l,{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=>r.cloneDeep({...s,dsl:void 0})),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>r.cloneDeep({...s,dsl:void 0}))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(P,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(P,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(o=>o.package===e.package);let 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(I,o),n.emit(l,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(I,a),n.emit(l,a)}}getPage(e){const t=(i,s=[])=>{for(const a of s){if(a.id===i)return a;if(a.children&&a.children.length){const o=t(i,a.children);if(o)return o}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir||s.layout?(s.layout&&i.push(s),s.children&&s.children.length&&(i=i.concat(e(s.children)))):i.push(s);return i};return e(this.pages)}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||r.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:r.upperFirstCamelCase(e.name)}).toDsl(),t){const s=this.getPage(t);s?s.children?s.children.push(e):s.children=[e]:console.warn(`not found PageFile for id: ${t} `)}else this.pages.push(e);if(!i){const s={model:this,type:"create",data:e};n.emit(C,s),n.emit(l,s)}!this.currentFile&&!e.dir&&(await r.delay(1e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(delete e.dsl,i?Object.assign(i,e):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(C,s),n.emit(l,s)}}clonePage(e,t,i=!1){const s=r.uid(),a=`${e.name}Copy`,o=`${e.title}_副本`,c=new u({id:s,name:a}).toDsl(),f=r.merge({},e,{id:s,name:a,title:o,dsl:c}),p=t?this.getPage(t)?.children||[]:this.pages,O=p.findIndex(T=>T.id===e.id);if(p.splice(O+1,0,f),!i){const T={model:this,type:"clone",data:{source:e,target:f}};n.emit(C,T),n.emit(l,T)}}async saveToBlock(e,t=!1){this.active(e,t),await r.delay(1e3);const i=r.uid(),s=e.name,a=e.title,o=new u({...e.dsl,id:i,name:s}).toDsl(),c=r.merge({},e,{id:i,name:s,title:a,dsl:o,type:"block",fromType:"Schema"});if(this.blocks.push(c),!t){const f={model:this,type:"create",data:c};n.emit(N,f),n.emit(l,f)}}removePage(e,t=!1){const i=this.getPage(e),s=(a,o)=>{const c=o.findIndex(f=>f.id===a);if(c>=0){o.splice(c,1);return}for(const f of o)f.children&&f.children.length&&s(a,f.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const a={model:this,type:"delete",data:i};n.emit(C,a),n.emit(l,a)}}getBlock(e){return this.blocks.find(t=>t.id===e)}getFile(e){return this.getPage(e)||this.getBlock(e)}async createBlock(e,t=!1){const i=e.id||r.uid(),s=r.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const a=e.fromType||"Schema";if(!t){const o={model:this,type:"create",data:e};n.emit(N,o),n.emit(l,o)}!this.currentFile&&a==="Schema"&&(await r.delay(1e3),this.active(e,t))}updateBlock(e,t=!1){const i=this.getBlock(e.id);if(i?(Object.assign(i,e),i.dsl&&(i.dsl.name=e.name)):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(N,s),n.emit(l,s)}}cloneBlock(e,t=!1){const i=r.uid(),s=`${e.name}Copy`,a=`${e.title}_副本`,o=new u({id:i,name:s}).toDsl(),c=r.merge({},e,{id:i,name:s,title:a,dsl:o}),f=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(f+1,0,c),!t){const p={model:this,type:"clone",data:{source:e,target:c}};n.emit(N,p),n.emit(l,p)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,a=s.findIndex(o=>o.id===e);if(a>-1?(s.splice(a,1),this.currentFile?.id===e&&this.deactivate(t)):console.warn(`not found PageFile for id: ${e} `),!t){const o={model:this,type:"delete",data:i};n.emit(N,o),n.emit(l,o)}}existBlockName(e,t=[]){return this.blocks.some(i=>i.name===e&&!t.includes(i.id))}existPageName(e,t=[]){return this.getPages().some(s=>s.name===e&&!t.includes(s.id))}setApi(e,t=!1){const i=this.apis.find(a=>a.name===e.name||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.apis.push(e)),!t){const a={model:this,type:s,data:e};n.emit(V,a),n.emit(l,a)}}removeApi(e,t=!1){const i=this.apis.findIndex(s=>s.name===e||s.id===e);if(i>-1?this.apis.splice(i,1):console.warn(`not found Api for name: ${e} `),!t){const s={model:this,type:"delete",data:e};n.emit(V,s),n.emit(l,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setMeta(e,t=!1){const i=this.meta.find(a=>a.code===e.code||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.meta.push(e)),!t){const a={model:this,type:s,data:e};n.emit(S,a),n.emit(l,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(l,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(l,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(l,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(l,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(l,s)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(b,t):n.emit(k,t)}genSource(){const e={model:this,type:"gen",data:null};n.emit(H,e)}lock(e){this.locked=e;const t={model:this,type:"update",data:e};n.emit(l,t)}unlock(e){if(e!==this.locked)return;this.locked="";const t={model:this,type:"update",data:null};n.emit(l,t)}}const A="EVENT_HISTORY_CHANGE",g="EVENT_HISTORY_LOAD";class K{options={max:50};index=-1;id;items;constructor(e,t={}){Object.assign(this.options,t);const{id:i,items:s=[]}=e;this.id=i,this.items=s}toDsl(){const{id:e,items:t}=this;return{id:e,items:t.map(i=>({id:i.id,label:i.label}))}}get(e){return this.items.find(t=>t.id===e)}add(e,t=!1){const{max:i}=this.options,s={id:r.uid(),label:new Date().toLocaleString(),dsl:r.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const a=this.items.splice(i);t||n.emit(A,{model:this,type:"delete",data:a.map(o=>o.id)})}this.index=-1,t||n.emit(A,{model:this,type:"create",data:s})}remove(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>-1?(this.items.splice(i,1),i===this.index?this.index=-1:this.index>=this.items.length&&(this.index=this.items.length-1)):console.warn(`not found HistoryItem for id: ${e} `),t||n.emit(A,{model:this,type:"delete",data:[e]})}forward(e=!1){const{index:t,items:i}=this;if(t<0)return;--this.index;const s=i[this.index];s&&!e&&n.emit(g,{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(g,{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(g,{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(A,{model:this,type:"clear",data:t})}}const n=r.mitt();function Y(m){return m instanceof u}function W(m){return m instanceof _}function q(m){return!!m.__VTJ_BLOCK__}function D(m){const e=r.cloneDeep(m);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>D(t))),e}function z(m){const e=m.fromType||"Schema";return e==="Schema"?{type:"Schema",id:m.id}:e==="UrlSchema"?{type:"UrlSchema",url:(m.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(m.urls||"").split(","),library:m.library}:""}exports.BUILT_IN_COMPONENTS=F;exports.BUILT_IN_LIBRARAY_MAP=w;exports.BUILT_IN_MATERIALS=J;exports.BUILT_IN_NAME=G;exports.BUILT_IN_TAGS=j;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=B;exports.Base=$;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=d;exports.EVENT_HISTORY_CHANGE=A;exports.EVENT_HISTORY_LOAD=g;exports.EVENT_NODE_CHANGE=h;exports.EVENT_PROJECT_ACTIVED=P;exports.EVENT_PROJECT_APIS_CHANGE=V;exports.EVENT_PROJECT_BLOCKS_CHANGE=N;exports.EVENT_PROJECT_CHANGE=l;exports.EVENT_PROJECT_DEPS_CHANGE=I;exports.EVENT_PROJECT_FILE_PUBLISH=b;exports.EVENT_PROJECT_GEN_SOURCE=H;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=C;exports.EVENT_PROJECT_PUBLISH=k;exports.EventModel=y;exports.HistoryModel=K;exports.NodeModel=_;exports.ProjectModel=x;exports.PropModel=v;exports.Service=M;exports.VTJ_CORE_VERSION=U;exports.cloneDsl=D;exports.createNodeFrom=z;exports.emitter=n;exports.isBlock=Y;exports.isBlockSchema=q;exports.isNode=W;
|
|
7
|
+
*/const U="0.13.15",G="BuiltIn",R="VueMaterial",B="VueRouterMaterial",J=[R,B],w={vue:"Vue","vue-router":"VueRouter"},F={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[B]:["RouterView","RouterLink"]},j=["slot","template","component","img","div","p","h1","h2","h3","span","a"],M=[{label:"简体中文",value:"zh-CN"},{label:"English",value:"en"}];class ${}class K{listeners=[];isReady=!1;triggerReady(){this.isReady=!0;for(const e of this.listeners)e();this.listeners=[]}ready(e){this.isReady?e():this.listeners.push(e)}resetReady(){this.isReady=!1}}class v{constructor(e,t,i){this.name=e,this.value=t,this.defaultValue=i,this.setValue(t)}isUnset=!1;setValue(e){this.value=e,this.isUnset=this.value===this.defaultValue}getValue(){return this.value??this.defaultValue}static toDsl(e={}){return Object.entries(e).reduce((t,[i,s])=>(s.isUnset||(t[i]=s.getValue()),t),{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(i,s),t),{})}}class C{constructor(e){this.schema=e;const{name:t,handler:i}=this.schema;this.name=t,this.handler=i,this.update(e)}name;handler;modifiers={};update(e){Object.assign(this.schema,e);const{handler:t,modifiers:i={}}=this.schema;this.handler=t,this.modifiers=i}static toDsl(e){return Object.entries(e).reduce((t,[i,s])=>{const{handler:a,modifiers:o}=s;return t[i]={name:i,handler:a,modifiers:o},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new C(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||r.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value:a,iterator:o}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=a,this.iterator=o}static parse(e=[]){return e.map(t=>new E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:a,value:o,iterator:l,id:f}=t;return{id:f,name:i,arg:s,modifiers:a,value:o,iterator:l}})}}const h="EVENT_NODE_CHANGE";class _{constructor(e,t=null){this.parent=t;const{id:i=r.uid(),name:s,from:a=""}=e;this.id=i,this.name=s,this.from=a,this.update(e,!0),_.nodes[this.id]=this}__VTJ_NODE__=!0;locked=!1;static nodes={};id;name;from;invisible=!1;children="";slot;props={};events={};directives=[];disposed=!1;update(e,t=!1){const{invisible:i=!1,locked:s=!1,children:a=[],slot:o,props:l={},events:f={},directives:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(a,!0),this.setSlot(o,!0),this.props=v.parse(l),this.events=C.parse(f),this.directives=E.parse(p),t||n.emit(h,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new _(i,this)):this.children=e,t||n.emit(h,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(h,this)}setProp(e,t,i,s=!1){const a=this.props[e];a?a.setValue(t):this.props[e]=new v(e,t,i),s||n.emit(h,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(h,this)}getPropValue(e){const t=this.props[e];if(t)return t.getValue()}setEvent(e,t=!1){const i=this.events[e.name];i?i.update(e):this.events[e.name]=new C(e),t||n.emit(h,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(h,this)}setDirective(e,t=!1){const i=e instanceof E?e:new E(e),s=this.directives.findIndex(a=>a.id===e.id);s>=0?this.directives.splice(s,1,i):this.directives.push(i),t||n.emit(h,this)}removeDirective(e,t=!1){const i=this.directives.findIndex(s=>s===e||s.id===e.id);i>=0&&this.directives.splice(i,1),t||n.emit(h,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const a=i.findIndex(o=>o===e);e.parent=null,i.splice(a,1),t||n.emit(h,this)}appendChild(e,t=!1){const{children:i,disposed:s}=this;s||(e.parent=this,Array.isArray(i)?i.push(e):this.children=[e],t||n.emit(h,this))}insertAfter(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s+1,0,e),t||n.emit(h,this.parent)}}insertBefore(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s,0,e),t||n.emit(h,this.parent)}}movePrev(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>0&&(i.splice(s,1),i.splice(s-1,0,this),e||n.emit(h,t))}}moveNext(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,this),e||n.emit(h,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:l,props:f,directives:p,events:P}=this,T=Array.isArray(l)?l.map(H=>H.toDsl()):l;return{id:e,name:t,from:i,invisible:s,locked:a,slot:o,children:T,props:v.toDsl(f),directives:E.toDsl(p),events:C.toDsl(P)}}dispose(e=!1){const{children:t,disposed:i}=this;i||(Array.isArray(t)&&t.forEach(s=>s.dispose(!0)),this.parent?this.parent.removeChild(this,e):e||n.emit(h,this),this.parent=null,this.disposed=!0,delete _.nodes[this.id])}lock(e=!1){if(this.locked=!0,Array.isArray(this.children))for(const t of this.children)t.lock(!0);e||n.emit(h,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(h,this)}setVisible(e,t=!1){if(this.invisible=!e,Array.isArray(this.children))for(const i of this.children)i.setVisible(e,!0);t||n.emit(h,this)}isChild(e){let t=!1;if(Array.isArray(this.children)){for(const i of this.children)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break}return t}}const d="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||r.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const a=e[s];a!==void 0&&(this[s]=a)}const{nodes:i=[]}=e;i.length?this.nodes=i.map(s=>new _(s)):this.nodes=[],t||n.emit(d,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((o,l)=>(o[l]=this[l],o),{}),__VTJ_BLOCK__:t,__VERSION__:e||r.timestamp().toString(),id:i,nodes:s.map(o=>o.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}setFunction(e,t,i,s=!1){this[e][t]=i,s||n.emit(d,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(d,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(d,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(d,this)}setCss(e,t=!1){this.css=e,t||n.emit(d,this)}setWatch(e,t=!1){e.id=e.id||r.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(d,this)}removeWatch(e,t=!1){const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1&&(this.watch.splice(i,1),t||n.emit(d,this))}setProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1?this.props.splice(i,1,e):this.props.push(e),t||n.emit(d,this)}removeProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1&&(this.props.splice(i,1),t||n.emit(d,this))}setEmit(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(d,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(d,this))}setSlot(e,t=!1){const i=r.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(a=>a===i.name||a.name===i.name);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(d,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>r.isString(s)?s===e:s.name===e);i>-1&&(this.slots.splice(i,1),t||n.emit(d,this))}setInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1?this.inject.splice(i,1,e):this.inject.push(e),t||n.emit(d,this)}removeInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1&&(this.inject.splice(i,1),t||n.emit(d,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(d,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(d,this)}insertAfter(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s+1,0,e),i||n.emit(d,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(d,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(d,this)}addNode(e,t,i="inner",s=!1){t?["left","top"].includes(i)?t.parent?t.insertAfter(e,s):this.insertBefore(e,t,s):["right","bottom"].includes(i)?t.parent?t.insertAfter(e,s):this.insertAfter(e,t,s):t.appendChild(e,s):this.appendNode(e,s)}__removeNode(e,t=!1){const i=this.nodes.findIndex(s=>s.id===e.id);i>-1&&(this.nodes.splice(i,1),t||n.emit(d,this))}removeNode(e,t=!1){e.parent?e.dispose(t):(e.dispose(!0),this.__removeNode(e,t))}move(e,t,i="inner",s=!1){e.parent?e.parent.removeChild(e,!0):this.__removeNode(e,!0),this.addNode(e,t,i,s)}movePrev(e,t=!1){if(e.parent)e.movePrev(t);else{const i=this.nodes,s=i.indexOf(e);s>0&&(i.splice(s,1),i.splice(s-1,0,e),t||n.emit(d,this))}}moveNext(e,t=!1){if(e.parent)e.moveNext(t);else{const i=this.nodes,s=i.indexOf(e);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,e),t||n.emit(d,this))}}cloneNode(e,t=!1){const i=D(e.toDsl()),s=new _(i);return this.addNode(s,e,"bottom",t),s}lock(e=!1){this.locked=!0;for(const t of this.nodes)t.lock(!0);e||n.emit(d,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(d,this)}isChild(e){let t=!1;for(const i of this.nodes)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break;return t}}const c="EVENT_PROJECT_CHANGE",x="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",g="EVENT_PROJECT_PAGES_CHANGE",N="EVENT_PROJECT_BLOCKS_CHANGE",A="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",k="EVENT_PROJECT_PUBLISH",b="EVENT_PROJECT_FILE_PUBLISH",L="EVENT_PROJECT_GEN_SOURCE";class I{id="";locked="";platform="web";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};uniConfig={};globals={};i18n={locale:"zh-CN",fallbackLocale:"zh-CN",messages:[]};__BASE_PATH__="/";__UID__=r.uuid(!0);static attrs=["locked","platform","name","homepage","description","dependencies","pages","blocks","apis","meta","config","uniConfig","globals","i18n","__BASE_PATH__","__UID__"];constructor(e){const{id:t,__UID__:i}=e;this.id=t||r.uid(),this.__UID__=i||r.uuid(!0),this.update(e,!0)}update(e,t=!1){for(const i of I.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(c,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}cleanPagesDsl(e){for(const t of e)delete t.dsl,t.children&&t.children.length&&this.cleanPagesDsl(t.children)}toDsl(e){const{id:t}=this,i=I.attrs.reduce((s,a)=>(s[a]=this[a],s),{});return i.pages&&(i.pages=i.pages.map(s=>r.cloneDeep({...s,dsl:void 0})),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>r.cloneDeep({...s,dsl:void 0}))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(x,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(x,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(o=>o.package===e.package);let a;if(s>-1?(a="update",i.splice(s,1,{...i[s],...e})):(a="create",i.push(e)),!t){const o={model:this,type:a,data:e};n.emit(V,o),n.emit(c,o)}}removeDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(a=>a.package===e.package);if(s>-1&&i.splice(s,1),!t){const a={model:this,type:"delete",data:e};n.emit(V,a),n.emit(c,a)}}getPage(e){const t=(i,s=[])=>{for(const a of s){if(a.id===i)return a;if(a.children&&a.children.length){const o=t(i,a.children);if(o)return o}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir||s.layout?(s.layout&&i.push(s),s.children&&s.children.length&&(i=i.concat(e(s.children)))):i.push(s);return i};return e(this.pages)}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||r.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:r.upperFirstCamelCase(e.name)}).toDsl(),t){const s=this.getPage(t);s?s.children?s.children.push(e):s.children=[e]:console.warn(`not found PageFile for id: ${t} `)}else this.pages.push(e);if(!i){const s={model:this,type:"create",data:e};n.emit(g,s),n.emit(c,s)}!this.currentFile&&!e.dir&&(await r.delay(1e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(delete e.dsl,i?Object.assign(i,e):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(g,s),n.emit(c,s)}}clonePage(e,t,i=!1){const s=r.uid(),a=`${e.name}Copy`,o=`${e.title}_副本`,l=new u({id:s,name:a}).toDsl(),f=r.merge({},e,{id:s,name:a,title:o,dsl:l}),p=t?this.getPage(t)?.children||[]:this.pages,P=p.findIndex(T=>T.id===e.id);if(p.splice(P+1,0,f),!i){const T={model:this,type:"clone",data:{source:e,target:f}};n.emit(g,T),n.emit(c,T)}}async saveToBlock(e,t=!1){this.active(e,t),await r.delay(1e3);const i=r.uid(),s=e.name,a=e.title,o=new u({...e.dsl,id:i,name:s}).toDsl(),l=r.merge({},e,{id:i,name:s,title:a,dsl:o,type:"block",fromType:"Schema"});if(this.blocks.push(l),!t){const f={model:this,type:"create",data:l};n.emit(N,f),n.emit(c,f)}}removePage(e,t=!1){const i=this.getPage(e),s=(a,o)=>{const l=o.findIndex(f=>f.id===a);if(l>=0){o.splice(l,1);return}for(const f of o)f.children&&f.children.length&&s(a,f.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const a={model:this,type:"delete",data:i};n.emit(g,a),n.emit(c,a)}}getBlock(e){return this.blocks.find(t=>t.id===e)}getFile(e){return this.getPage(e)||this.getBlock(e)}async createBlock(e,t=!1){const i=e.id||r.uid(),s=r.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const a=e.fromType||"Schema";if(!t){const o={model:this,type:"create",data:e};n.emit(N,o),n.emit(c,o)}!this.currentFile&&a==="Schema"&&(await r.delay(1e3),this.active(e,t))}updateBlock(e,t=!1){const i=this.getBlock(e.id);if(i?(Object.assign(i,e),i.dsl&&(i.dsl.name=e.name)):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(N,s),n.emit(c,s)}}cloneBlock(e,t=!1){const i=r.uid(),s=`${e.name}Copy`,a=`${e.title}_副本`,o=new u({id:i,name:s}).toDsl(),l=r.merge({},e,{id:i,name:s,title:a,dsl:o}),f=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(f+1,0,l),!t){const p={model:this,type:"clone",data:{source:e,target:l}};n.emit(N,p),n.emit(c,p)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,a=s.findIndex(o=>o.id===e);if(a>-1?(s.splice(a,1),this.currentFile?.id===e&&this.deactivate(t)):console.warn(`not found PageFile for id: ${e} `),!t){const o={model:this,type:"delete",data:i};n.emit(N,o),n.emit(c,o)}}existBlockName(e,t=[]){return this.blocks.some(i=>i.name===e&&!t.includes(i.id))}existPageName(e,t=[]){return this.getPages().some(s=>s.name===e&&!t.includes(s.id))}setApi(e,t=!1){const i=this.apis.find(a=>a.name===e.name||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.apis.push(e)),!t){const a={model:this,type:s,data:e};n.emit(A,a),n.emit(c,a)}}setApis(e,t=!1){for(const i of e)this.setApi(i,!0);if(!t){const i={model:this,type:"create",data:e};n.emit(A,i),n.emit(c,i)}}removeApi(e,t=!1){const i=this.apis.findIndex(s=>s.name===e||s.id===e);if(i>-1?this.apis.splice(i,1):console.warn(`not found Api for name: ${e} `),!t){const s={model:this,type:"delete",data:e};n.emit(A,s),n.emit(c,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setMeta(e,t=!1){const i=this.meta.find(a=>a.code===e.code||a.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=r.uid(),this.meta.push(e)),!t){const a={model:this,type:s,data:e};n.emit(S,a),n.emit(c,a)}}removeMeta(e,t=!1){const i=this.meta.findIndex(s=>s.code===e||s.id===e);if(i>-1?this.meta.splice(i,1):console.warn(`not found meta for name: ${name} `),!t){const s={model:this,type:"delete",data:e};n.emit(S,s),n.emit(c,s)}}existMetaCode(e,t=[]){return this.meta.some(i=>i.code===e&&!t.includes(i.id))}setHomepage(e,t=!1){if(this.homepage=e,!t){const i={model:this,type:"update",data:e};n.emit(c,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(c,i)}}setUniConfig(e,t,i=!1){if(this.uniConfig=Object.assign(this.uniConfig,{[e]:t}),!i){const s={model:this,type:"update",data:this.uniConfig};n.emit(c,s)}}setGloblas(e,t,i=!1){if(this.globals=Object.assign(this.globals,{[e]:t}),!i){const s={model:this,type:"update",data:this.globals};n.emit(c,s)}}setI18n(e,t=!1){if(this.i18n=Object.assign(this.i18n,e),!t){const i={model:this,type:"update",data:this.i18n};n.emit(c,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(b,t):n.emit(k,t)}genSource(){const e={model:this,type:"gen",data:null};n.emit(L,e)}lock(e){this.locked=e;const t={model:this,type:"update",data:e};n.emit(c,t)}unlock(e){if(e!==this.locked)return;this.locked="";const t={model:this,type:"update",data:null};n.emit(c,t)}getPageRoutes(e,t){const i=this.platform==="uniapp",s=e||(i?"pages":"page"),a=this.getPages(),o=t||"";return a.map(l=>({id:l.id,path:`${o}/${s}/${l.id}`,name:l.name,title:l.title,meta:l.meta}))}}const y="EVENT_HISTORY_CHANGE",O="EVENT_HISTORY_LOAD";class Y{options={max:50};index=-1;id;items;constructor(e,t={}){Object.assign(this.options,t);const{id:i,items:s=[]}=e;this.id=i,this.items=s}toDsl(){const{id:e,items:t}=this;return{id:e,items:t.map(i=>({id:i.id,label:i.label}))}}get(e){return this.items.find(t=>t.id===e)}add(e,t=!1){const{max:i}=this.options,s={id:r.uid(),label:new Date().toLocaleString(),dsl:r.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const a=this.items.splice(i);t||n.emit(y,{model:this,type:"delete",data:a.map(o=>o.id)})}this.index=-1,t||n.emit(y,{model:this,type:"create",data:s})}remove(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>-1?(this.items.splice(i,1),i===this.index?this.index=-1:this.index>=this.items.length&&(this.index=this.items.length-1)):console.warn(`not found HistoryItem for id: ${e} `),t||n.emit(y,{model:this,type:"delete",data:[e]})}forward(e=!1){const{index:t,items:i}=this;if(t<0)return;--this.index;const s=i[this.index];s&&!e&&n.emit(O,{model:this,type:"load",data:s})}backward(e=!1){const{index:t,items:i}=this;if(t>=i.length-1)return;t<0&&(this.index=0),++this.index;const s=i[this.index];s&&!e&&n.emit(O,{model:this,type:"load",data:s})}load(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>=0&&(this.index=i,t||n.emit(O,{model:this,type:"load",data:this.items[i]}))}clear(e=!1){this.index=-1;const t=this.items.map(i=>i.id);this.items=[],e||n.emit(y,{model:this,type:"clear",data:t})}}const n=r.mitt();function z(m){return m instanceof u}function W(m){return m instanceof _}function q(m){return!!m.__VTJ_BLOCK__}function D(m){const e=r.cloneDeep(m);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>D(t))),e}function Q(m){const e=m.fromType||"Schema";return e==="Schema"?{type:"Schema",id:m.id}:e==="UrlSchema"?{type:"UrlSchema",url:(m.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(m.urls||"").split(","),library:m.library}:""}exports.BUILT_IN_COMPONENTS=F;exports.BUILT_IN_LIBRARAY_MAP=w;exports.BUILT_IN_MATERIALS=J;exports.BUILT_IN_NAME=G;exports.BUILT_IN_TAGS=j;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=B;exports.Base=K;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=d;exports.EVENT_HISTORY_CHANGE=y;exports.EVENT_HISTORY_LOAD=O;exports.EVENT_NODE_CHANGE=h;exports.EVENT_PROJECT_ACTIVED=x;exports.EVENT_PROJECT_APIS_CHANGE=A;exports.EVENT_PROJECT_BLOCKS_CHANGE=N;exports.EVENT_PROJECT_CHANGE=c;exports.EVENT_PROJECT_DEPS_CHANGE=V;exports.EVENT_PROJECT_FILE_PUBLISH=b;exports.EVENT_PROJECT_GEN_SOURCE=L;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=g;exports.EVENT_PROJECT_PUBLISH=k;exports.EventModel=C;exports.HistoryModel=Y;exports.I18N_LOCALES=M;exports.NodeModel=_;exports.ProjectModel=I;exports.PropModel=v;exports.Service=$;exports.VTJ_CORE_VERSION=U;exports.cloneDsl=D;exports.createNodeFrom=Q;exports.emitter=n;exports.isBlock=z;exports.isBlockSchema=q;exports.isNode=W;
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { uid as m, timestamp as G, isString as T, uuid as
|
|
1
|
+
import { uid as m, timestamp as G, isString as T, uuid as b, cloneDeep as C, upperFirstCamelCase as R, delay as P, merge as I, mitt as j } from "@vtj/base";
|
|
2
2
|
/**!
|
|
3
3
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
4
4
|
* @name @vtj/core
|
|
5
5
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
6
|
-
* @version 0.13.
|
|
6
|
+
* @version 0.13.15
|
|
7
7
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
8
8
|
*/
|
|
9
|
-
const Y = "0.13.
|
|
9
|
+
const Y = "0.13.15", z = "BuiltIn", H = "VueMaterial", L = "VueRouterMaterial", W = [H, L], q = {
|
|
10
10
|
vue: "Vue",
|
|
11
11
|
"vue-router": "VueRouter"
|
|
12
12
|
}, Q = {
|
|
@@ -17,7 +17,7 @@ const Y = "0.13.13", W = "BuiltIn", H = "VueMaterial", J = "VueRouterMaterial",
|
|
|
17
17
|
"Teleport",
|
|
18
18
|
"Suspense"
|
|
19
19
|
],
|
|
20
|
-
[
|
|
20
|
+
[L]: ["RouterView", "RouterLink"]
|
|
21
21
|
}, X = [
|
|
22
22
|
"slot",
|
|
23
23
|
"template",
|
|
@@ -30,10 +30,19 @@ const Y = "0.13.13", W = "BuiltIn", H = "VueMaterial", J = "VueRouterMaterial",
|
|
|
30
30
|
"h3",
|
|
31
31
|
"span",
|
|
32
32
|
"a"
|
|
33
|
+
], Z = [
|
|
34
|
+
{
|
|
35
|
+
label: "简体中文",
|
|
36
|
+
value: "zh-CN"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "English",
|
|
40
|
+
value: "en"
|
|
41
|
+
}
|
|
33
42
|
];
|
|
34
|
-
class Z {
|
|
35
|
-
}
|
|
36
43
|
class ee {
|
|
44
|
+
}
|
|
45
|
+
class te {
|
|
37
46
|
listeners = [];
|
|
38
47
|
isReady = !1;
|
|
39
48
|
triggerReady() {
|
|
@@ -135,14 +144,14 @@ class v {
|
|
|
135
144
|
}
|
|
136
145
|
static toDsl(e = []) {
|
|
137
146
|
return e.map((t) => {
|
|
138
|
-
const { name: i, arg: s, modifiers: a, value: o, iterator:
|
|
147
|
+
const { name: i, arg: s, modifiers: a, value: o, iterator: r, id: c } = t;
|
|
139
148
|
return {
|
|
140
149
|
id: c,
|
|
141
150
|
name: i,
|
|
142
151
|
arg: s,
|
|
143
152
|
modifiers: a,
|
|
144
153
|
value: o,
|
|
145
|
-
iterator:
|
|
154
|
+
iterator: r
|
|
146
155
|
};
|
|
147
156
|
});
|
|
148
157
|
}
|
|
@@ -217,11 +226,11 @@ class _ {
|
|
|
217
226
|
locked: s = !1,
|
|
218
227
|
children: a = [],
|
|
219
228
|
slot: o,
|
|
220
|
-
props:
|
|
229
|
+
props: r = {},
|
|
221
230
|
events: c = {},
|
|
222
231
|
directives: p = []
|
|
223
232
|
} = e;
|
|
224
|
-
this.invisible = i, this.locked = s, this.setChildren(a, !0), this.setSlot(o, !0), this.props = g.parse(
|
|
233
|
+
this.invisible = i, this.locked = s, this.setChildren(a, !0), this.setSlot(o, !0), this.props = g.parse(r), this.events = x.parse(c), this.directives = v.parse(p), t || n.emit(h, this);
|
|
225
234
|
}
|
|
226
235
|
/**
|
|
227
236
|
* 设置子节点
|
|
@@ -387,11 +396,11 @@ class _ {
|
|
|
387
396
|
invisible: s,
|
|
388
397
|
locked: a,
|
|
389
398
|
slot: o,
|
|
390
|
-
children:
|
|
399
|
+
children: r,
|
|
391
400
|
props: c,
|
|
392
401
|
directives: p,
|
|
393
402
|
events: O
|
|
394
|
-
} = this, E = Array.isArray(
|
|
403
|
+
} = this, E = Array.isArray(r) ? r.map((U) => U.toDsl()) : r;
|
|
395
404
|
return {
|
|
396
405
|
id: e,
|
|
397
406
|
name: t,
|
|
@@ -445,7 +454,7 @@ class _ {
|
|
|
445
454
|
return t;
|
|
446
455
|
}
|
|
447
456
|
}
|
|
448
|
-
const
|
|
457
|
+
const l = "EVENT_BLOCK_CHANGE";
|
|
449
458
|
class u {
|
|
450
459
|
__VTJ_BLOCK__ = !0;
|
|
451
460
|
id;
|
|
@@ -490,7 +499,7 @@ class u {
|
|
|
490
499
|
a !== void 0 && (this[s] = a);
|
|
491
500
|
}
|
|
492
501
|
const { nodes: i = [] } = e;
|
|
493
|
-
i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t || n.emit(
|
|
502
|
+
i.length ? this.nodes = i.map((s) => new _(s)) : this.nodes = [], t || n.emit(l, this);
|
|
494
503
|
}
|
|
495
504
|
/**
|
|
496
505
|
* 获取DSL
|
|
@@ -500,7 +509,7 @@ class u {
|
|
|
500
509
|
const { __VTJ_BLOCK__: t, id: i, nodes: s } = this;
|
|
501
510
|
return {
|
|
502
511
|
...u.normalAttrs.reduce(
|
|
503
|
-
(o,
|
|
512
|
+
(o, r) => (o[r] = this[r], o),
|
|
504
513
|
{}
|
|
505
514
|
),
|
|
506
515
|
__VTJ_BLOCK__: t,
|
|
@@ -523,7 +532,7 @@ class u {
|
|
|
523
532
|
* @param silent
|
|
524
533
|
*/
|
|
525
534
|
setFunction(e, t, i, s = !1) {
|
|
526
|
-
this[e][t] = i, s || n.emit(
|
|
535
|
+
this[e][t] = i, s || n.emit(l, this);
|
|
527
536
|
}
|
|
528
537
|
/**
|
|
529
538
|
* 删除通用函数属性
|
|
@@ -532,7 +541,7 @@ class u {
|
|
|
532
541
|
* @param silent
|
|
533
542
|
*/
|
|
534
543
|
removeFunction(e, t, i = !1) {
|
|
535
|
-
delete this[e][t], i || n.emit(
|
|
544
|
+
delete this[e][t], i || n.emit(l, this);
|
|
536
545
|
}
|
|
537
546
|
/**
|
|
538
547
|
* 设置状态
|
|
@@ -541,7 +550,7 @@ class u {
|
|
|
541
550
|
* @param silent
|
|
542
551
|
*/
|
|
543
552
|
setState(e, t, i = !1) {
|
|
544
|
-
this.state[e] = t, i || n.emit(
|
|
553
|
+
this.state[e] = t, i || n.emit(l, this);
|
|
545
554
|
}
|
|
546
555
|
/**
|
|
547
556
|
* 删除状态
|
|
@@ -549,7 +558,7 @@ class u {
|
|
|
549
558
|
* @param silent
|
|
550
559
|
*/
|
|
551
560
|
removeState(e, t = !1) {
|
|
552
|
-
delete this.state[e], t || n.emit(
|
|
561
|
+
delete this.state[e], t || n.emit(l, this);
|
|
553
562
|
}
|
|
554
563
|
/**
|
|
555
564
|
* 更新CSS
|
|
@@ -557,7 +566,7 @@ class u {
|
|
|
557
566
|
* @param silent
|
|
558
567
|
*/
|
|
559
568
|
setCss(e, t = !1) {
|
|
560
|
-
this.css = e, t || n.emit(
|
|
569
|
+
this.css = e, t || n.emit(l, this);
|
|
561
570
|
}
|
|
562
571
|
/**
|
|
563
572
|
* 新增或更新 watch
|
|
@@ -569,7 +578,7 @@ class u {
|
|
|
569
578
|
const i = this.watch.findIndex(
|
|
570
579
|
(s) => s.id && s.id === e.id || s === e
|
|
571
580
|
);
|
|
572
|
-
i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(
|
|
581
|
+
i > -1 ? this.watch.splice(i, 1, e) : this.watch.push(e), t || n.emit(l, this);
|
|
573
582
|
}
|
|
574
583
|
/**
|
|
575
584
|
* 删除 watch
|
|
@@ -580,7 +589,7 @@ class u {
|
|
|
580
589
|
const i = this.watch.findIndex(
|
|
581
590
|
(s) => s.id && s.id === e.id || s === e
|
|
582
591
|
);
|
|
583
|
-
i > -1 && (this.watch.splice(i, 1), t || n.emit(
|
|
592
|
+
i > -1 && (this.watch.splice(i, 1), t || n.emit(l, this));
|
|
584
593
|
}
|
|
585
594
|
/**
|
|
586
595
|
* 定义属性参数
|
|
@@ -591,7 +600,7 @@ class u {
|
|
|
591
600
|
const i = this.props.findIndex(
|
|
592
601
|
(s) => typeof s == "string" ? s === e.name : s.name === e.name
|
|
593
602
|
);
|
|
594
|
-
i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(
|
|
603
|
+
i > -1 ? this.props.splice(i, 1, e) : this.props.push(e), t || n.emit(l, this);
|
|
595
604
|
}
|
|
596
605
|
/**
|
|
597
606
|
* 删除属性
|
|
@@ -602,7 +611,7 @@ class u {
|
|
|
602
611
|
const i = this.props.findIndex(
|
|
603
612
|
(s) => typeof s == "string" ? s === e.name : s.name === e.name
|
|
604
613
|
);
|
|
605
|
-
i > -1 && (this.props.splice(i, 1), t || n.emit(
|
|
614
|
+
i > -1 && (this.props.splice(i, 1), t || n.emit(l, this));
|
|
606
615
|
}
|
|
607
616
|
/**
|
|
608
617
|
* 设置事件
|
|
@@ -613,7 +622,7 @@ class u {
|
|
|
613
622
|
const i = T(e) ? { name: e, params: [] } : e, s = this.emits.findIndex(
|
|
614
623
|
(a) => a === i.name || a.name === i.name
|
|
615
624
|
);
|
|
616
|
-
s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(
|
|
625
|
+
s > -1 ? this.emits.splice(s, 1, i) : this.emits.push(i), t || n.emit(l, this);
|
|
617
626
|
}
|
|
618
627
|
/**
|
|
619
628
|
* 删除事件
|
|
@@ -624,7 +633,7 @@ class u {
|
|
|
624
633
|
const i = this.emits.findIndex(
|
|
625
634
|
(s) => T(s) ? s === e : s.name === e
|
|
626
635
|
);
|
|
627
|
-
i > -1 && (this.emits.splice(i, 1), t || n.emit(
|
|
636
|
+
i > -1 && (this.emits.splice(i, 1), t || n.emit(l, this));
|
|
628
637
|
}
|
|
629
638
|
/**
|
|
630
639
|
* 设置插槽
|
|
@@ -635,7 +644,7 @@ class u {
|
|
|
635
644
|
const i = T(e) ? { name: e, params: [] } : e, s = this.slots.findIndex(
|
|
636
645
|
(a) => a === i.name || a.name === i.name
|
|
637
646
|
);
|
|
638
|
-
s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(
|
|
647
|
+
s > -1 ? this.slots.splice(s, 1, i) : this.slots.push(i), t || n.emit(l, this);
|
|
639
648
|
}
|
|
640
649
|
/**
|
|
641
650
|
* 删除插槽
|
|
@@ -646,7 +655,7 @@ class u {
|
|
|
646
655
|
const i = this.slots.findIndex(
|
|
647
656
|
(s) => T(s) ? s === e : s.name === e
|
|
648
657
|
);
|
|
649
|
-
i > -1 && (this.slots.splice(i, 1), t || n.emit(
|
|
658
|
+
i > -1 && (this.slots.splice(i, 1), t || n.emit(l, this));
|
|
650
659
|
}
|
|
651
660
|
/**
|
|
652
661
|
* 设置注入
|
|
@@ -655,7 +664,7 @@ class u {
|
|
|
655
664
|
*/
|
|
656
665
|
setInject(e, t = !1) {
|
|
657
666
|
const i = this.inject.findIndex((s) => s.name === e.name);
|
|
658
|
-
i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(
|
|
667
|
+
i > -1 ? this.inject.splice(i, 1, e) : this.inject.push(e), t || n.emit(l, this);
|
|
659
668
|
}
|
|
660
669
|
/**
|
|
661
670
|
* 删除注入
|
|
@@ -664,7 +673,7 @@ class u {
|
|
|
664
673
|
*/
|
|
665
674
|
removeInject(e, t = !1) {
|
|
666
675
|
const i = this.inject.findIndex((s) => s.name === e.name);
|
|
667
|
-
i > -1 && (this.inject.splice(i, 1), t || n.emit(
|
|
676
|
+
i > -1 && (this.inject.splice(i, 1), t || n.emit(l, this));
|
|
668
677
|
}
|
|
669
678
|
/**
|
|
670
679
|
* 设置数据源
|
|
@@ -672,7 +681,7 @@ class u {
|
|
|
672
681
|
* @param silent
|
|
673
682
|
*/
|
|
674
683
|
setDataSource(e, t = !1) {
|
|
675
|
-
this.dataSources[e.name] = e, t || n.emit(
|
|
684
|
+
this.dataSources[e.name] = e, t || n.emit(l, this);
|
|
676
685
|
}
|
|
677
686
|
/**
|
|
678
687
|
* 删除数据源
|
|
@@ -680,20 +689,20 @@ class u {
|
|
|
680
689
|
* @param silent
|
|
681
690
|
*/
|
|
682
691
|
removeDataSource(e, t = !1) {
|
|
683
|
-
delete this.dataSources[e], t || n.emit(
|
|
692
|
+
delete this.dataSources[e], t || n.emit(l, this);
|
|
684
693
|
}
|
|
685
694
|
insertAfter(e, t, i = !1) {
|
|
686
695
|
e.parent = null;
|
|
687
696
|
const s = this.nodes.indexOf(t);
|
|
688
|
-
this.nodes.splice(s + 1, 0, e), i || n.emit(
|
|
697
|
+
this.nodes.splice(s + 1, 0, e), i || n.emit(l, this);
|
|
689
698
|
}
|
|
690
699
|
insertBefore(e, t, i = !1) {
|
|
691
700
|
e.parent = null;
|
|
692
701
|
const s = this.nodes.indexOf(t);
|
|
693
|
-
this.nodes.splice(s, 0, e), i || n.emit(
|
|
702
|
+
this.nodes.splice(s, 0, e), i || n.emit(l, this);
|
|
694
703
|
}
|
|
695
704
|
appendNode(e, t = !1) {
|
|
696
|
-
e.parent = null, this.nodes.push(e), t || n.emit(
|
|
705
|
+
e.parent = null, this.nodes.push(e), t || n.emit(l, this);
|
|
697
706
|
}
|
|
698
707
|
/**
|
|
699
708
|
* 添加节点
|
|
@@ -707,7 +716,7 @@ class u {
|
|
|
707
716
|
}
|
|
708
717
|
__removeNode(e, t = !1) {
|
|
709
718
|
const i = this.nodes.findIndex((s) => s.id === e.id);
|
|
710
|
-
i > -1 && (this.nodes.splice(i, 1), t || n.emit(
|
|
719
|
+
i > -1 && (this.nodes.splice(i, 1), t || n.emit(l, this));
|
|
711
720
|
}
|
|
712
721
|
/**
|
|
713
722
|
* 删除节点
|
|
@@ -737,7 +746,7 @@ class u {
|
|
|
737
746
|
e.movePrev(t);
|
|
738
747
|
else {
|
|
739
748
|
const i = this.nodes, s = i.indexOf(e);
|
|
740
|
-
s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(
|
|
749
|
+
s > 0 && (i.splice(s, 1), i.splice(s - 1, 0, e), t || n.emit(l, this));
|
|
741
750
|
}
|
|
742
751
|
}
|
|
743
752
|
/**
|
|
@@ -750,7 +759,7 @@ class u {
|
|
|
750
759
|
e.moveNext(t);
|
|
751
760
|
else {
|
|
752
761
|
const i = this.nodes, s = i.indexOf(e);
|
|
753
|
-
s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(
|
|
762
|
+
s > -1 && s < i.length - 1 && (i.splice(s, 1), i.splice(s + 1, 0, e), t || n.emit(l, this));
|
|
754
763
|
}
|
|
755
764
|
}
|
|
756
765
|
/**
|
|
@@ -760,20 +769,20 @@ class u {
|
|
|
760
769
|
* @returns
|
|
761
770
|
*/
|
|
762
771
|
cloneNode(e, t = !1) {
|
|
763
|
-
const i =
|
|
772
|
+
const i = J(e.toDsl()), s = new _(i);
|
|
764
773
|
return this.addNode(s, e, "bottom", t), s;
|
|
765
774
|
}
|
|
766
775
|
lock(e = !1) {
|
|
767
776
|
this.locked = !0;
|
|
768
777
|
for (const t of this.nodes)
|
|
769
778
|
t.lock(!0);
|
|
770
|
-
e || n.emit(
|
|
779
|
+
e || n.emit(l, this);
|
|
771
780
|
}
|
|
772
781
|
unlock(e = !1) {
|
|
773
782
|
this.locked = !1;
|
|
774
783
|
for (const t of this.nodes)
|
|
775
784
|
t.unlock(!0);
|
|
776
|
-
e || n.emit(
|
|
785
|
+
e || n.emit(l, this);
|
|
777
786
|
}
|
|
778
787
|
isChild(e) {
|
|
779
788
|
let t = !1;
|
|
@@ -786,8 +795,8 @@ class u {
|
|
|
786
795
|
return t;
|
|
787
796
|
}
|
|
788
797
|
}
|
|
789
|
-
const
|
|
790
|
-
class
|
|
798
|
+
const d = "EVENT_PROJECT_CHANGE", D = "EVENT_PROJECT_ACTIVED", B = "EVENT_PROJECT_DEPS_CHANGE", A = "EVENT_PROJECT_PAGES_CHANGE", y = "EVENT_PROJECT_BLOCKS_CHANGE", V = "EVENT_PROJECT_APIS_CHANGE", w = "EVENT_PROJECT_META_CHANGE", F = "EVENT_PROJECT_PUBLISH", $ = "EVENT_PROJECT_FILE_PUBLISH", M = "EVENT_PROJECT_GEN_SOURCE";
|
|
799
|
+
class k {
|
|
791
800
|
id = "";
|
|
792
801
|
locked = "";
|
|
793
802
|
platform = "web";
|
|
@@ -803,8 +812,13 @@ class S {
|
|
|
803
812
|
config = {};
|
|
804
813
|
uniConfig = {};
|
|
805
814
|
globals = {};
|
|
815
|
+
i18n = {
|
|
816
|
+
locale: "zh-CN",
|
|
817
|
+
fallbackLocale: "zh-CN",
|
|
818
|
+
messages: []
|
|
819
|
+
};
|
|
806
820
|
__BASE_PATH__ = "/";
|
|
807
|
-
__UID__ =
|
|
821
|
+
__UID__ = b(!0);
|
|
808
822
|
static attrs = [
|
|
809
823
|
"locked",
|
|
810
824
|
"platform",
|
|
@@ -819,19 +833,20 @@ class S {
|
|
|
819
833
|
"config",
|
|
820
834
|
"uniConfig",
|
|
821
835
|
"globals",
|
|
836
|
+
"i18n",
|
|
822
837
|
"__BASE_PATH__",
|
|
823
838
|
"__UID__"
|
|
824
839
|
];
|
|
825
840
|
constructor(e) {
|
|
826
841
|
const { id: t, __UID__: i } = e;
|
|
827
|
-
this.id = t || m(), this.__UID__ = i ||
|
|
842
|
+
this.id = t || m(), this.__UID__ = i || b(!0), this.update(e, !0);
|
|
828
843
|
}
|
|
829
844
|
update(e, t = !1) {
|
|
830
|
-
for (const i of
|
|
845
|
+
for (const i of k.attrs) {
|
|
831
846
|
const s = e[i];
|
|
832
847
|
s && (this[i] = s);
|
|
833
848
|
}
|
|
834
|
-
t || n.emit(
|
|
849
|
+
t || n.emit(d, {
|
|
835
850
|
model: this,
|
|
836
851
|
type: "update",
|
|
837
852
|
data: e
|
|
@@ -845,7 +860,7 @@ class S {
|
|
|
845
860
|
delete t.dsl, t.children && t.children.length && this.cleanPagesDsl(t.children);
|
|
846
861
|
}
|
|
847
862
|
toDsl(e) {
|
|
848
|
-
const { id: t } = this, i =
|
|
863
|
+
const { id: t } = this, i = k.attrs.reduce(
|
|
849
864
|
(s, a) => (s[a] = this[a], s),
|
|
850
865
|
{}
|
|
851
866
|
);
|
|
@@ -901,7 +916,7 @@ class S {
|
|
|
901
916
|
type: a,
|
|
902
917
|
data: e
|
|
903
918
|
};
|
|
904
|
-
n.emit(
|
|
919
|
+
n.emit(B, o), n.emit(d, o);
|
|
905
920
|
}
|
|
906
921
|
}
|
|
907
922
|
/**
|
|
@@ -917,7 +932,7 @@ class S {
|
|
|
917
932
|
type: "delete",
|
|
918
933
|
data: e
|
|
919
934
|
};
|
|
920
|
-
n.emit(
|
|
935
|
+
n.emit(B, a), n.emit(d, a);
|
|
921
936
|
}
|
|
922
937
|
}
|
|
923
938
|
/**
|
|
@@ -973,7 +988,7 @@ class S {
|
|
|
973
988
|
type: "create",
|
|
974
989
|
data: e
|
|
975
990
|
};
|
|
976
|
-
n.emit(A, s), n.emit(
|
|
991
|
+
n.emit(A, s), n.emit(d, s);
|
|
977
992
|
}
|
|
978
993
|
!this.currentFile && !e.dir && (await P(1e3), this.active(e, i));
|
|
979
994
|
}
|
|
@@ -990,7 +1005,7 @@ class S {
|
|
|
990
1005
|
type: "update",
|
|
991
1006
|
data: e
|
|
992
1007
|
};
|
|
993
|
-
n.emit(A, s), n.emit(
|
|
1008
|
+
n.emit(A, s), n.emit(d, s);
|
|
994
1009
|
}
|
|
995
1010
|
}
|
|
996
1011
|
/**
|
|
@@ -1000,10 +1015,10 @@ class S {
|
|
|
1000
1015
|
* @param silent
|
|
1001
1016
|
*/
|
|
1002
1017
|
clonePage(e, t, i = !1) {
|
|
1003
|
-
const s = m(), a = `${e.name}Copy`, o = `${e.title}_副本`,
|
|
1018
|
+
const s = m(), a = `${e.name}Copy`, o = `${e.title}_副本`, r = new u({
|
|
1004
1019
|
id: s,
|
|
1005
1020
|
name: a
|
|
1006
|
-
}).toDsl(), c = I({}, e, { id: s, name: a, title: o, dsl:
|
|
1021
|
+
}).toDsl(), c = I({}, e, { id: s, name: a, title: o, dsl: r }), p = t ? this.getPage(t)?.children || [] : this.pages, O = p.findIndex((E) => E.id === e.id);
|
|
1007
1022
|
if (p.splice(O + 1, 0, c), !i) {
|
|
1008
1023
|
const E = {
|
|
1009
1024
|
model: this,
|
|
@@ -1013,7 +1028,7 @@ class S {
|
|
|
1013
1028
|
target: c
|
|
1014
1029
|
}
|
|
1015
1030
|
};
|
|
1016
|
-
n.emit(A, E), n.emit(
|
|
1031
|
+
n.emit(A, E), n.emit(d, E);
|
|
1017
1032
|
}
|
|
1018
1033
|
}
|
|
1019
1034
|
async saveToBlock(e, t = !1) {
|
|
@@ -1022,7 +1037,7 @@ class S {
|
|
|
1022
1037
|
...e.dsl,
|
|
1023
1038
|
id: i,
|
|
1024
1039
|
name: s
|
|
1025
|
-
}).toDsl(),
|
|
1040
|
+
}).toDsl(), r = I({}, e, {
|
|
1026
1041
|
id: i,
|
|
1027
1042
|
name: s,
|
|
1028
1043
|
title: a,
|
|
@@ -1030,13 +1045,13 @@ class S {
|
|
|
1030
1045
|
type: "block",
|
|
1031
1046
|
fromType: "Schema"
|
|
1032
1047
|
});
|
|
1033
|
-
if (this.blocks.push(
|
|
1048
|
+
if (this.blocks.push(r), !t) {
|
|
1034
1049
|
const c = {
|
|
1035
1050
|
model: this,
|
|
1036
1051
|
type: "create",
|
|
1037
|
-
data:
|
|
1052
|
+
data: r
|
|
1038
1053
|
};
|
|
1039
|
-
n.emit(y, c), n.emit(
|
|
1054
|
+
n.emit(y, c), n.emit(d, c);
|
|
1040
1055
|
}
|
|
1041
1056
|
}
|
|
1042
1057
|
/**
|
|
@@ -1046,9 +1061,9 @@ class S {
|
|
|
1046
1061
|
*/
|
|
1047
1062
|
removePage(e, t = !1) {
|
|
1048
1063
|
const i = this.getPage(e), s = (a, o) => {
|
|
1049
|
-
const
|
|
1050
|
-
if (
|
|
1051
|
-
o.splice(
|
|
1064
|
+
const r = o.findIndex((c) => c.id === a);
|
|
1065
|
+
if (r >= 0) {
|
|
1066
|
+
o.splice(r, 1);
|
|
1052
1067
|
return;
|
|
1053
1068
|
}
|
|
1054
1069
|
for (const c of o)
|
|
@@ -1060,7 +1075,7 @@ class S {
|
|
|
1060
1075
|
type: "delete",
|
|
1061
1076
|
data: i
|
|
1062
1077
|
};
|
|
1063
|
-
n.emit(A, a), n.emit(
|
|
1078
|
+
n.emit(A, a), n.emit(d, a);
|
|
1064
1079
|
}
|
|
1065
1080
|
}
|
|
1066
1081
|
/**
|
|
@@ -1089,7 +1104,7 @@ class S {
|
|
|
1089
1104
|
type: "create",
|
|
1090
1105
|
data: e
|
|
1091
1106
|
};
|
|
1092
|
-
n.emit(y, o), n.emit(
|
|
1107
|
+
n.emit(y, o), n.emit(d, o);
|
|
1093
1108
|
}
|
|
1094
1109
|
!this.currentFile && a === "Schema" && (await P(1e3), this.active(e, t));
|
|
1095
1110
|
}
|
|
@@ -1106,24 +1121,24 @@ class S {
|
|
|
1106
1121
|
type: "update",
|
|
1107
1122
|
data: e
|
|
1108
1123
|
};
|
|
1109
|
-
n.emit(y, s), n.emit(
|
|
1124
|
+
n.emit(y, s), n.emit(d, s);
|
|
1110
1125
|
}
|
|
1111
1126
|
}
|
|
1112
1127
|
cloneBlock(e, t = !1) {
|
|
1113
1128
|
const i = m(), s = `${e.name}Copy`, a = `${e.title}_副本`, o = new u({
|
|
1114
1129
|
id: i,
|
|
1115
1130
|
name: s
|
|
1116
|
-
}).toDsl(),
|
|
1117
|
-
if (this.blocks.splice(c + 1, 0,
|
|
1131
|
+
}).toDsl(), r = I({}, e, { id: i, name: s, title: a, dsl: o }), c = this.blocks.findIndex((p) => p.id === e.id);
|
|
1132
|
+
if (this.blocks.splice(c + 1, 0, r), !t) {
|
|
1118
1133
|
const p = {
|
|
1119
1134
|
model: this,
|
|
1120
1135
|
type: "clone",
|
|
1121
1136
|
data: {
|
|
1122
1137
|
source: e,
|
|
1123
|
-
target:
|
|
1138
|
+
target: r
|
|
1124
1139
|
}
|
|
1125
1140
|
};
|
|
1126
|
-
n.emit(y, p), n.emit(
|
|
1141
|
+
n.emit(y, p), n.emit(d, p);
|
|
1127
1142
|
}
|
|
1128
1143
|
}
|
|
1129
1144
|
/**
|
|
@@ -1139,7 +1154,7 @@ class S {
|
|
|
1139
1154
|
type: "delete",
|
|
1140
1155
|
data: i
|
|
1141
1156
|
};
|
|
1142
|
-
n.emit(y, o), n.emit(
|
|
1157
|
+
n.emit(y, o), n.emit(d, o);
|
|
1143
1158
|
}
|
|
1144
1159
|
}
|
|
1145
1160
|
/**
|
|
@@ -1176,7 +1191,19 @@ class S {
|
|
|
1176
1191
|
type: s,
|
|
1177
1192
|
data: e
|
|
1178
1193
|
};
|
|
1179
|
-
n.emit(
|
|
1194
|
+
n.emit(V, a), n.emit(d, a);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
setApis(e, t = !1) {
|
|
1198
|
+
for (const i of e)
|
|
1199
|
+
this.setApi(i, !0);
|
|
1200
|
+
if (!t) {
|
|
1201
|
+
const i = {
|
|
1202
|
+
model: this,
|
|
1203
|
+
type: "create",
|
|
1204
|
+
data: e
|
|
1205
|
+
};
|
|
1206
|
+
n.emit(V, i), n.emit(d, i);
|
|
1180
1207
|
}
|
|
1181
1208
|
}
|
|
1182
1209
|
/**
|
|
@@ -1192,7 +1219,7 @@ class S {
|
|
|
1192
1219
|
type: "delete",
|
|
1193
1220
|
data: e
|
|
1194
1221
|
};
|
|
1195
|
-
n.emit(
|
|
1222
|
+
n.emit(V, s), n.emit(d, s);
|
|
1196
1223
|
}
|
|
1197
1224
|
}
|
|
1198
1225
|
existApiName(e, t = []) {
|
|
@@ -1209,7 +1236,7 @@ class S {
|
|
|
1209
1236
|
type: s,
|
|
1210
1237
|
data: e
|
|
1211
1238
|
};
|
|
1212
|
-
n.emit(w, a), n.emit(
|
|
1239
|
+
n.emit(w, a), n.emit(d, a);
|
|
1213
1240
|
}
|
|
1214
1241
|
}
|
|
1215
1242
|
removeMeta(e, t = !1) {
|
|
@@ -1220,7 +1247,7 @@ class S {
|
|
|
1220
1247
|
type: "delete",
|
|
1221
1248
|
data: e
|
|
1222
1249
|
};
|
|
1223
|
-
n.emit(w, s), n.emit(
|
|
1250
|
+
n.emit(w, s), n.emit(d, s);
|
|
1224
1251
|
}
|
|
1225
1252
|
}
|
|
1226
1253
|
existMetaCode(e, t = []) {
|
|
@@ -1233,7 +1260,7 @@ class S {
|
|
|
1233
1260
|
type: "update",
|
|
1234
1261
|
data: e
|
|
1235
1262
|
};
|
|
1236
|
-
n.emit(
|
|
1263
|
+
n.emit(d, i);
|
|
1237
1264
|
}
|
|
1238
1265
|
}
|
|
1239
1266
|
setConfig(e, t = !1) {
|
|
@@ -1243,7 +1270,7 @@ class S {
|
|
|
1243
1270
|
type: "update",
|
|
1244
1271
|
data: e
|
|
1245
1272
|
};
|
|
1246
|
-
n.emit(
|
|
1273
|
+
n.emit(d, i);
|
|
1247
1274
|
}
|
|
1248
1275
|
}
|
|
1249
1276
|
setUniConfig(e, t, i = !1) {
|
|
@@ -1253,7 +1280,7 @@ class S {
|
|
|
1253
1280
|
type: "update",
|
|
1254
1281
|
data: this.uniConfig
|
|
1255
1282
|
};
|
|
1256
|
-
n.emit(
|
|
1283
|
+
n.emit(d, s);
|
|
1257
1284
|
}
|
|
1258
1285
|
}
|
|
1259
1286
|
setGloblas(e, t, i = !1) {
|
|
@@ -1263,7 +1290,17 @@ class S {
|
|
|
1263
1290
|
type: "update",
|
|
1264
1291
|
data: this.globals
|
|
1265
1292
|
};
|
|
1266
|
-
n.emit(
|
|
1293
|
+
n.emit(d, s);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
setI18n(e, t = !1) {
|
|
1297
|
+
if (this.i18n = Object.assign(this.i18n, e), !t) {
|
|
1298
|
+
const i = {
|
|
1299
|
+
model: this,
|
|
1300
|
+
type: "update",
|
|
1301
|
+
data: this.i18n
|
|
1302
|
+
};
|
|
1303
|
+
n.emit(d, i);
|
|
1267
1304
|
}
|
|
1268
1305
|
}
|
|
1269
1306
|
publish(e) {
|
|
@@ -1272,7 +1309,7 @@ class S {
|
|
|
1272
1309
|
type: "publish",
|
|
1273
1310
|
data: e || this
|
|
1274
1311
|
};
|
|
1275
|
-
e ? n.emit($, t) : n.emit(
|
|
1312
|
+
e ? n.emit($, t) : n.emit(F, t);
|
|
1276
1313
|
}
|
|
1277
1314
|
genSource() {
|
|
1278
1315
|
const e = {
|
|
@@ -1289,7 +1326,7 @@ class S {
|
|
|
1289
1326
|
type: "update",
|
|
1290
1327
|
data: e
|
|
1291
1328
|
};
|
|
1292
|
-
n.emit(
|
|
1329
|
+
n.emit(d, t);
|
|
1293
1330
|
}
|
|
1294
1331
|
unlock(e) {
|
|
1295
1332
|
if (e !== this.locked)
|
|
@@ -1300,11 +1337,21 @@ class S {
|
|
|
1300
1337
|
type: "update",
|
|
1301
1338
|
data: null
|
|
1302
1339
|
};
|
|
1303
|
-
n.emit(
|
|
1340
|
+
n.emit(d, t);
|
|
1341
|
+
}
|
|
1342
|
+
getPageRoutes(e, t) {
|
|
1343
|
+
const i = this.platform === "uniapp", s = e || (i ? "pages" : "page"), a = this.getPages(), o = t || "";
|
|
1344
|
+
return a.map((r) => ({
|
|
1345
|
+
id: r.id,
|
|
1346
|
+
path: `${o}/${s}/${r.id}`,
|
|
1347
|
+
name: r.name,
|
|
1348
|
+
title: r.title,
|
|
1349
|
+
meta: r.meta
|
|
1350
|
+
}));
|
|
1304
1351
|
}
|
|
1305
1352
|
}
|
|
1306
|
-
const N = "EVENT_HISTORY_CHANGE",
|
|
1307
|
-
class
|
|
1353
|
+
const N = "EVENT_HISTORY_CHANGE", S = "EVENT_HISTORY_LOAD";
|
|
1354
|
+
class ie {
|
|
1308
1355
|
options = { max: 50 };
|
|
1309
1356
|
index = -1;
|
|
1310
1357
|
id;
|
|
@@ -1372,7 +1419,7 @@ class te {
|
|
|
1372
1419
|
if (t < 0) return;
|
|
1373
1420
|
--this.index;
|
|
1374
1421
|
const s = i[this.index];
|
|
1375
|
-
s && !e && n.emit(
|
|
1422
|
+
s && !e && n.emit(S, {
|
|
1376
1423
|
model: this,
|
|
1377
1424
|
type: "load",
|
|
1378
1425
|
data: s
|
|
@@ -1383,7 +1430,7 @@ class te {
|
|
|
1383
1430
|
if (t >= i.length - 1) return;
|
|
1384
1431
|
t < 0 && (this.index = 0), ++this.index;
|
|
1385
1432
|
const s = i[this.index];
|
|
1386
|
-
s && !e && n.emit(
|
|
1433
|
+
s && !e && n.emit(S, {
|
|
1387
1434
|
model: this,
|
|
1388
1435
|
type: "load",
|
|
1389
1436
|
data: s
|
|
@@ -1391,7 +1438,7 @@ class te {
|
|
|
1391
1438
|
}
|
|
1392
1439
|
load(e, t = !1) {
|
|
1393
1440
|
const i = this.items.findIndex((s) => s.id === e);
|
|
1394
|
-
i >= 0 && (this.index = i, t || n.emit(
|
|
1441
|
+
i >= 0 && (this.index = i, t || n.emit(S, {
|
|
1395
1442
|
model: this,
|
|
1396
1443
|
type: "load",
|
|
1397
1444
|
data: this.items[i]
|
|
@@ -1407,21 +1454,21 @@ class te {
|
|
|
1407
1454
|
});
|
|
1408
1455
|
}
|
|
1409
1456
|
}
|
|
1410
|
-
const n =
|
|
1411
|
-
function
|
|
1457
|
+
const n = j();
|
|
1458
|
+
function se(f) {
|
|
1412
1459
|
return f instanceof u;
|
|
1413
1460
|
}
|
|
1414
|
-
function
|
|
1461
|
+
function ne(f) {
|
|
1415
1462
|
return f instanceof _;
|
|
1416
1463
|
}
|
|
1417
|
-
function
|
|
1464
|
+
function ae(f) {
|
|
1418
1465
|
return !!f.__VTJ_BLOCK__;
|
|
1419
1466
|
}
|
|
1420
|
-
function
|
|
1467
|
+
function J(f) {
|
|
1421
1468
|
const e = C(f);
|
|
1422
|
-
return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) =>
|
|
1469
|
+
return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) => J(t))), e;
|
|
1423
1470
|
}
|
|
1424
|
-
function
|
|
1471
|
+
function oe(f) {
|
|
1425
1472
|
const e = f.fromType || "Schema";
|
|
1426
1473
|
return e === "Schema" ? {
|
|
1427
1474
|
type: "Schema",
|
|
@@ -1437,40 +1484,41 @@ function ae(f) {
|
|
|
1437
1484
|
}
|
|
1438
1485
|
export {
|
|
1439
1486
|
Q as BUILT_IN_COMPONENTS,
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1487
|
+
q as BUILT_IN_LIBRARAY_MAP,
|
|
1488
|
+
W as BUILT_IN_MATERIALS,
|
|
1489
|
+
z as BUILT_IN_NAME,
|
|
1443
1490
|
X as BUILT_IN_TAGS,
|
|
1444
1491
|
H as BUILT_IN_VUE,
|
|
1445
|
-
|
|
1446
|
-
|
|
1492
|
+
L as BUILT_IN_VUE_ROUTER,
|
|
1493
|
+
te as Base,
|
|
1447
1494
|
u as BlockModel,
|
|
1448
1495
|
v as DirectiveModel,
|
|
1449
|
-
|
|
1496
|
+
l as EVENT_BLOCK_CHANGE,
|
|
1450
1497
|
N as EVENT_HISTORY_CHANGE,
|
|
1451
|
-
|
|
1498
|
+
S as EVENT_HISTORY_LOAD,
|
|
1452
1499
|
h as EVENT_NODE_CHANGE,
|
|
1453
1500
|
D as EVENT_PROJECT_ACTIVED,
|
|
1454
|
-
|
|
1501
|
+
V as EVENT_PROJECT_APIS_CHANGE,
|
|
1455
1502
|
y as EVENT_PROJECT_BLOCKS_CHANGE,
|
|
1456
|
-
|
|
1457
|
-
|
|
1503
|
+
d as EVENT_PROJECT_CHANGE,
|
|
1504
|
+
B as EVENT_PROJECT_DEPS_CHANGE,
|
|
1458
1505
|
$ as EVENT_PROJECT_FILE_PUBLISH,
|
|
1459
1506
|
M as EVENT_PROJECT_GEN_SOURCE,
|
|
1460
1507
|
w as EVENT_PROJECT_META_CHANGE,
|
|
1461
1508
|
A as EVENT_PROJECT_PAGES_CHANGE,
|
|
1462
|
-
|
|
1509
|
+
F as EVENT_PROJECT_PUBLISH,
|
|
1463
1510
|
x as EventModel,
|
|
1464
|
-
|
|
1511
|
+
ie as HistoryModel,
|
|
1512
|
+
Z as I18N_LOCALES,
|
|
1465
1513
|
_ as NodeModel,
|
|
1466
|
-
|
|
1514
|
+
k as ProjectModel,
|
|
1467
1515
|
g as PropModel,
|
|
1468
|
-
|
|
1516
|
+
ee as Service,
|
|
1469
1517
|
Y as VTJ_CORE_VERSION,
|
|
1470
|
-
|
|
1471
|
-
|
|
1518
|
+
J as cloneDsl,
|
|
1519
|
+
oe as createNodeFrom,
|
|
1472
1520
|
n as emitter,
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1521
|
+
se as isBlock,
|
|
1522
|
+
ae as isBlockSchema,
|
|
1523
|
+
ne as isNode
|
|
1476
1524
|
};
|
package/package.json
CHANGED
package/types/constants.d.ts
CHANGED
|
@@ -23,3 +23,7 @@ export declare const BUILT_IN_LIBRARAY_MAP: Record<string, string>;
|
|
|
23
23
|
*/
|
|
24
24
|
export declare const BUILT_IN_COMPONENTS: Record<string, string[]>;
|
|
25
25
|
export declare const BUILT_IN_TAGS: string[];
|
|
26
|
+
export declare const I18N_LOCALES: {
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProjectSchema, Dependencie, PageFile, BlockFile, ApiSchema, MetaSchema, ProjectConfig, UniConfig, PlatformType, GlobalConfig, JSFunction } from '../protocols';
|
|
1
|
+
import { ProjectSchema, Dependencie, PageFile, BlockFile, ApiSchema, MetaSchema, ProjectConfig, UniConfig, PlatformType, GlobalConfig, JSFunction, I18nConfig } from '../protocols';
|
|
2
2
|
import { ModelEventType } from '../tools';
|
|
3
3
|
export interface ProjectModelEvent {
|
|
4
4
|
model: ProjectModel;
|
|
@@ -61,6 +61,7 @@ export declare class ProjectModel {
|
|
|
61
61
|
config: ProjectConfig;
|
|
62
62
|
uniConfig: UniConfig;
|
|
63
63
|
globals: GlobalConfig;
|
|
64
|
+
i18n: I18nConfig;
|
|
64
65
|
__BASE_PATH__: string;
|
|
65
66
|
__UID__: string;
|
|
66
67
|
static attrs: string[];
|
|
@@ -176,6 +177,7 @@ export declare class ProjectModel {
|
|
|
176
177
|
* @param silent
|
|
177
178
|
*/
|
|
178
179
|
setApi(item: ApiSchema, silent?: boolean): void;
|
|
180
|
+
setApis(items: ApiSchema[], silent?: boolean): void;
|
|
179
181
|
/**
|
|
180
182
|
* 删除api
|
|
181
183
|
* @param name
|
|
@@ -190,8 +192,16 @@ export declare class ProjectModel {
|
|
|
190
192
|
setConfig(config: ProjectConfig, silent?: boolean): void;
|
|
191
193
|
setUniConfig(key: keyof UniConfig, value: Record<string, any>, silent?: boolean): void;
|
|
192
194
|
setGloblas(key: keyof GlobalConfig, value: string | JSFunction, silent?: boolean): void;
|
|
195
|
+
setI18n(i18n: I18nConfig, silent?: boolean): void;
|
|
193
196
|
publish(file?: PageFile | BlockFile): void;
|
|
194
197
|
genSource(): void;
|
|
195
198
|
lock(id: string): void;
|
|
196
199
|
unlock(id: string): void;
|
|
200
|
+
getPageRoutes(pageRouteName?: string, pageBasePath?: string): {
|
|
201
|
+
id: string;
|
|
202
|
+
path: string;
|
|
203
|
+
name: string;
|
|
204
|
+
title: string;
|
|
205
|
+
meta: Record<string, any> | undefined;
|
|
206
|
+
}[];
|
|
197
207
|
}
|
|
@@ -62,6 +62,10 @@ export interface ProjectSchema {
|
|
|
62
62
|
* (Web、H5)应用全局配置
|
|
63
63
|
*/
|
|
64
64
|
globals?: GlobalConfig;
|
|
65
|
+
/**
|
|
66
|
+
* 国际化
|
|
67
|
+
*/
|
|
68
|
+
i18n?: I18nConfig;
|
|
65
69
|
/**
|
|
66
70
|
* 标记
|
|
67
71
|
*/
|
|
@@ -194,3 +198,33 @@ export interface GlobalConfig {
|
|
|
194
198
|
*/
|
|
195
199
|
afterEach?: JSFunction;
|
|
196
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* 国际化配置
|
|
203
|
+
*/
|
|
204
|
+
export interface I18nConfig {
|
|
205
|
+
/**
|
|
206
|
+
* 默认本地化语言
|
|
207
|
+
*/
|
|
208
|
+
locale?: I18nLocale;
|
|
209
|
+
/**
|
|
210
|
+
* 兜底语言
|
|
211
|
+
*/
|
|
212
|
+
fallbackLocale?: I18nLocale;
|
|
213
|
+
/**
|
|
214
|
+
* 语言包
|
|
215
|
+
*/
|
|
216
|
+
messages?: I18nMessage[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 本地语言名
|
|
220
|
+
*/
|
|
221
|
+
export type I18nLocale = 'zh-CN' | 'en';
|
|
222
|
+
/**
|
|
223
|
+
* 语言信息项
|
|
224
|
+
*/
|
|
225
|
+
export interface I18nMessage {
|
|
226
|
+
key: string;
|
|
227
|
+
['zh-CN']: string;
|
|
228
|
+
en: string;
|
|
229
|
+
[index: string]: string;
|
|
230
|
+
}
|
package/types/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/core
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.13.
|
|
5
|
+
* @version 0.13.14
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.13.
|
|
8
|
+
export declare const version = "0.13.14";
|