@vtj/core 0.8.26 → 0.8.28
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 +3 -3
- package/dist/index.mjs +107 -76
- package/package.json +1 -1
- package/types/models/project.d.ts +9 -1
- package/types/protocols/schemas/dataSource.d.ts +21 -0
- package/types/protocols/schemas/project.d.ts +5 -1
- package/types/tools/emitter.d.ts +2 -1
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@vtj/base");/**!
|
|
2
2
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/core
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.8.
|
|
5
|
+
* @version 0.8.28
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const H="0.8.26",b="BuiltIn",S="VueMaterial",R="VueRouterMaterial",J=[S,R],U={vue:"Vue","vue-router":"VueRouter"},G={[S]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[R]:["RouterView","RouterLink"]},w=["slot","template","component","img","div","p","h1","h2","h3","span","a"];class F{}class j{listeners=[];isReady=!1;triggerReady(){this.isReady=!0;for(const e of this.listeners)e();this.listeners=[]}ready(e){this.isReady?e():this.listeners.push(e)}resetReady(){this.isReady=!1}}class T{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 T(i,s),t),{})}}class v{constructor(e){this.schema=e;const{name:t,handler:i}=this.schema;this.name=t,this.handler=i,this.update(e)}name;handler;modifiers={};update(e){Object.assign(this.schema,e);const{handler:t,modifiers:i={}}=this.schema;this.handler=t,this.modifiers=i}static toDsl(e){return Object.entries(e).reduce((t,[i,s])=>{const{handler:r,modifiers:a}=s;return t[i]={name:i,handler:r,modifiers:a},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||h.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value:r,iterator:a}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=r,this.iterator=a}static parse(e=[]){return e.map(t=>new E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:a,iterator:c,id:m}=t;return{id:m,name:i,arg:s,modifiers:r,value:a,iterator:c}})}}const l="EVENT_NODE_CHANGE";class p{constructor(e,t=null){this.parent=t;const{id:i=h.uid(),name:s,from:r=""}=e;this.id=i,this.name=s,this.from=r,this.update(e,!0),p.nodes[this.id]=this}__VTJ_NODE__=!0;locked=!1;static nodes={};id;name;from;invisible=!1;children="";slot;props={};events={};directives=[];disposed=!1;update(e,t=!1){const{invisible:i=!1,locked:s=!1,children:r=[],slot:a,props:c={},events:m={},directives:_=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(a,!0),this.props=T.parse(c),this.events=v.parse(m),this.directives=E.parse(_),t||n.emit(l,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new p(i,this)):this.children=e,t||n.emit(l,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(l,this)}setProp(e,t,i,s=!1){const r=this.props[e];r?r.setValue(t):this.props[e]=new T(e,t,i),s||n.emit(l,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(l,this)}getPropValue(e){const t=this.props[e];if(t)return t.getValue()}setEvent(e,t=!1){const i=this.events[e.name];i?i.update(e):this.events[e.name]=new v(e),t||n.emit(l,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(l,this)}setDirective(e,t=!1){const i=this.directives.findIndex(s=>s.id===e.id);i>=0?this.directives.splice(i,1,new E(e)):this.directives.push(new E(e)),t||n.emit(l,this)}removeDirective(e,t=!1){const i=this.directives.findIndex(s=>s===e||s.id===e.id);i>=0&&this.directives.splice(i,1),t||n.emit(l,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const r=i.findIndex(a=>a===e);e.parent=null,i.splice(r,1),t||n.emit(l,this)}appendChild(e,t=!1){const{children:i,disposed:s}=this;s||(e.parent=this,Array.isArray(i)?i.push(e):this.children=[e],t||n.emit(l,this))}insertAfter(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s+1,0,e),t||n.emit(l,this.parent)}}insertBefore(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s,0,e),t||n.emit(l,this.parent)}}movePrev(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>0&&(i.splice(s,1),i.splice(s-1,0,this),e||n.emit(l,t))}}moveNext(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,this),e||n.emit(l,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:c,props:m,directives:_,events:O}=this,N=Array.isArray(c)?c.map(D=>D.toDsl()):c;return{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:N,props:T.toDsl(m),directives:E.toDsl(_),events:v.toDsl(O)}}dispose(e=!1){const{children:t,disposed:i}=this;i||(Array.isArray(t)&&t.forEach(s=>s.dispose(!0)),this.parent?this.parent.removeChild(this,e):e||n.emit(l,this),this.parent=null,this.disposed=!0,delete p.nodes[this.id])}lock(e=!1){if(this.locked=!0,Array.isArray(this.children))for(const t of this.children)t.lock(!0);e||n.emit(l,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(l,this)}setVisible(e,t=!1){if(this.invisible=!e,Array.isArray(this.children))for(const i of this.children)i.setVisible(e,!0);t||n.emit(l,this)}isChild(e){let t=!1;if(Array.isArray(this.children)){for(const i of this.children)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break}return t}}const o="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources"];constructor(e){const{id:t}=e;this.id=t||h.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const r=e[s];r&&(this[s]=r)}const{nodes:i=[]}=e;i.length&&(this.nodes=i.map(s=>new p(s))),t||n.emit(o,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((a,c)=>(a[c]=this[c],a),{}),__VTJ_BLOCK__:t,__VERSION__:e||h.timestamp().toString(),id:i,nodes:s.map(a=>a.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}setFunction(e,t,i,s=!1){this[e][t]=i,s||n.emit(o,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(o,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(o,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(o,this)}setCss(e,t=!1){this.css=e,t||n.emit(o,this)}setWatch(e,t=!1){e.id=e.id||h.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(o,this)}removeWatch(e,t=!1){const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1&&(this.watch.splice(i,1),t||n.emit(o,this))}setProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1?this.props.splice(i,1,e):this.props.push(e),t||n.emit(o,this)}removeProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1&&(this.props.splice(i,1),t||n.emit(o,this))}setEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1?this.emits.splice(i,1,e):this.emits.push(e),t||n.emit(o,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1&&(this.emits.splice(i,1),t||n.emit(o,this))}setSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1?this.slots.splice(i,1,e):this.slots.push(e),t||n.emit(o,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1&&(this.slots.splice(i,1),t||n.emit(o,this))}setInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1?this.inject.splice(i,1,e):this.inject.push(e),t||n.emit(o,this)}removeInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1&&(this.inject.splice(i,1),t||n.emit(o,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(o,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(o,this)}insertAfter(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s+1,0,e),i||n.emit(o,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(o,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(o,this)}addNode(e,t,i="inner",s=!1){t?["left","top"].includes(i)?t.parent?t.insertAfter(e,s):this.insertBefore(e,t,s):["right","bottom"].includes(i)?t.parent?t.insertAfter(e,s):this.insertAfter(e,t,s):t.appendChild(e,s):this.appendNode(e,s)}__removeNode(e,t=!1){const i=this.nodes.findIndex(s=>s.id===e.id);i>-1&&(this.nodes.splice(i,1),t||n.emit(o,this))}removeNode(e,t=!1){e.parent?e.dispose(t):(e.dispose(!0),this.__removeNode(e,t))}move(e,t,i="inner",s=!1){e.parent?e.parent.removeChild(e,!0):this.__removeNode(e,!0),this.addNode(e,t,i,s)}movePrev(e,t=!1){if(e.parent)e.movePrev(t);else{const i=this.nodes,s=i.indexOf(e);s>0&&(i.splice(s,1),i.splice(s-1,0,e),t||n.emit(o,this))}}moveNext(e,t=!1){if(e.parent)e.moveNext(t);else{const i=this.nodes,s=i.indexOf(e);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,e),t||n.emit(o,this))}}cloneNode(e,t=!1){const i=B(e.toDsl()),s=new p(i);return this.addNode(s,e,"bottom",t),s}lock(e=!1){this.locked=!0;for(const t of this.nodes)t.lock(!0);e||n.emit(o,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(o,this)}isChild(e){let t=!1;for(const i of this.nodes)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break;return t}}const f="EVENT_PROJECT_CHANGE",P="EVENT_PROJECT_ACTIVED",g="EVENT_PROJECT_DEPS_CHANGE",A="EVENT_PROJECT_PAGES_CHANGE",C="EVENT_PROJECT_BLOCKS_CHANGE",V="EVENT_PROJECT_APIS_CHANGE",L="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH";class I{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];currentFile=null;config={};static attrs=["name","homepage","description","dependencies","pages","blocks","apis","config"];constructor(e){const{id:t}=e;this.id=t||h.uid(),this.update(e,!0)}update(e,t=!1){for(const i of I.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(f,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}toDsl(e){const{id:t}=this,i=I.attrs.reduce((s,r)=>(s[r]=this[r],s),{});return i.pages&&(i.pages=i.pages.map(s=>(delete s.dsl,s))),i.blocks&&(i.blocks=i.blocks.map(s=>(delete s.dsl,s))),{__VTJ_PROJECT__:!0,__VERSION__:e||h.timestamp().toString(),id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(P,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(P,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(a=>a.package===e.package);let r;if(s>-1?(r="update",i.splice(s,1,{...i[s],...e})):(r="create",i.push(e)),!t){const a={model:this,type:r,data:e};n.emit(g,a),n.emit(f,a)}}removeDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(r=>r.package===e.package);if(s>-1&&i.splice(s,1),!t){const r={model:this,type:"delete",data:e};n.emit(g,r),n.emit(f,r)}}getPage(e){const t=(i,s=[])=>{for(const r of s){if(r.id===i)return r;if(r.children&&r.children.length){const a=t(i,r.children);if(a)return a}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir?s.children&&s.children.length&&(i=i.concat(e(s.children))):i.push(s);return i};return e(this.pages)}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||h.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:h.upperFirstCamelCase(e.name)}).toDsl(),t){const s=this.getPage(t);s?s.children?s.children.push(e):s.children=[e]:console.warn(`not found PageFile for id: ${t} `)}else this.pages.push(e);if(!i){const s={model:this,type:"create",data:e};n.emit(A,s),n.emit(f,s)}!this.currentFile&&!e.dir&&(await h.delay(2e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(i?Object.assign(i,e):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(A,s),n.emit(f,s)}}clonePage(e,t,i=!1){const s=h.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,c=new u({id:s,name:r}).toDsl(),m=h.merge({},e,{id:s,name:r,title:a,dsl:c}),_=t?this.getPage(t)?.children||[]:this.pages,O=_.findIndex(N=>N.id===e.id);if(_.splice(O+1,0,m),!i){const N={model:this,type:"clone",data:{page:e,newPage:m}};n.emit(A,N),n.emit(f,N)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,a)=>{const c=a.findIndex(m=>m.id===r);if(c>=0){a.splice(c,1);return}for(const m of a)if(m.children&&m.children.length)return s(r,m.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const r={model:this,type:"delete",data:i};n.emit(A,r),n.emit(f,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}async createBlock(e,t=!1){const i=e.id||h.uid(),s=h.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const r=e.fromType||"Schema";if(!t){const a={model:this,type:"create",data:e};n.emit(C,a),n.emit(f,a)}!this.currentFile&&r==="Schema"&&(await h.delay(2e3),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(C,s),n.emit(f,s)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,r=s.findIndex(a=>a.id===e);if(r>-1?(s.splice(r,1),this.currentFile?.id===e&&this.deactivate(t)):console.warn(`not found PageFile for id: ${e} `),!t){const a={model:this,type:"delete",data:i};n.emit(C,a),n.emit(f,a)}}existBlockName(e,t=[]){return this.blocks.some(i=>i.name===e&&!t.includes(i.id))}existPageName(e,t=[]){return this.getPages().some(s=>s.name===e&&!t.includes(s.id))}setApi(e,t=!1){const i=this.apis.find(r=>r.name===e.name||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=h.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(V,r),n.emit(f,r)}}removeApi(e,t=!1){const i=this.apis.findIndex(s=>s.name===e||s.id===e);if(i>-1?this.apis.splice(i,1):console.warn(`not found Api for name: ${e} `),!t){const s={model:this,type:"delete",data:e};n.emit(V,s),n.emit(f,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setHomepage(e,t=!1){if(this.homepage=e,!t){const i={model:this,type:"update",data:e};n.emit(f,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(f,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(L,t)}}const y="EVENT_HISTORY_CHANGE",x="EVENT_HISTORY_LOAD";class M{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:h.uid(),label:new Date().toLocaleString(),dsl:h.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const r=this.items.splice(i);t||n.emit(y,{model:this,type:"delete",data:r.map(a=>a.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(x,{model:this,type:"load",data:s})}backward(e=!1){const{index:t,items:i}=this;if(t>=i.length-1)return;t<0&&(this.index=0),++this.index;const s=i[this.index];s&&!e&&n.emit(x,{model:this,type:"load",data:s})}load(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>=0&&(this.index=i,t||n.emit(x,{model:this,type:"load",data:this.items[i]}))}clear(e=!1){this.index=-1;const t=this.items.map(i=>i.id);this.items=[],e||n.emit(y,{model:this,type:"clear",data:t})}}const n=h.mitt();function K(d){return d instanceof u}function Y(d){return d instanceof p}function $(d){return!!d.__VTJ_BLOCK__}function B(d){return delete d.id,Array.isArray(d.children)&&(d.children=d.children.map(e=>B(e))),d}function W(d){const e=d.fromType||"Schema";return e==="Schema"?{type:"Schema",id:d.id}:e==="UrlSchema"?{type:"UrlSchema",url:(d.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(d.urls||"").split(","),library:d.library}:""}exports.BUILT_IN_COMPONENTS=G;exports.BUILT_IN_LIBRARAY_MAP=U;exports.BUILT_IN_MATERIALS=J;exports.BUILT_IN_NAME=b;exports.BUILT_IN_TAGS=w;exports.BUILT_IN_VUE=S;exports.BUILT_IN_VUE_ROUTER=R;exports.Base=j;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=o;exports.EVENT_HISTORY_CHANGE=y;exports.EVENT_HISTORY_LOAD=x;exports.EVENT_NODE_CHANGE=l;exports.EVENT_PROJECT_ACTIVED=P;exports.EVENT_PROJECT_APIS_CHANGE=V;exports.EVENT_PROJECT_BLOCKS_CHANGE=C;exports.EVENT_PROJECT_CHANGE=f;exports.EVENT_PROJECT_DEPS_CHANGE=g;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_PAGES_CHANGE=A;exports.EVENT_PROJECT_PUBLISH=L;exports.EventModel=v;exports.HistoryModel=M;exports.NodeModel=p;exports.ProjectModel=I;exports.PropModel=T;exports.Service=F;exports.VTJ_CORE_VERSION=H;exports.cloneDsl=B;exports.createNodeFrom=W;exports.emitter=n;exports.isBlock=K;exports.isBlockSchema=$;exports.isNode=Y;
|
|
7
|
+
*/const b="0.8.28",J="BuiltIn",R="VueMaterial",B="VueRouterMaterial",G=[R,B],U={vue:"Vue","vue-router":"VueRouter"},w={[R]:["Transition","TransitionGroup","KeepAlive","Teleport","Suspense"],[B]:["RouterView","RouterLink"]},F=["slot","template","component","img","div","p","h1","h2","h3","span","a"];class M{}class j{listeners=[];isReady=!1;triggerReady(){this.isReady=!0;for(const e of this.listeners)e();this.listeners=[]}ready(e){this.isReady?e():this.listeners.push(e)}resetReady(){this.isReady=!1}}class N{constructor(e,t,i){this.name=e,this.value=t,this.defaultValue=i,this.setValue(t)}isUnset=!1;setValue(e){this.value=e,this.isUnset=this.value===this.defaultValue}getValue(){return this.value??this.defaultValue}static toDsl(e={}){return Object.entries(e).reduce((t,[i,s])=>(s.isUnset||(t[i]=s.getValue()),t),{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new N(i,s),t),{})}}class v{constructor(e){this.schema=e;const{name:t,handler:i}=this.schema;this.name=t,this.handler=i,this.update(e)}name;handler;modifiers={};update(e){Object.assign(this.schema,e);const{handler:t,modifiers:i={}}=this.schema;this.handler=t,this.modifiers=i}static toDsl(e){return Object.entries(e).reduce((t,[i,s])=>{const{handler:r,modifiers:a}=s;return t[i]={name:i,handler:r,modifiers:a},t},{})}static parse(e={}){return Object.entries(e).reduce((t,[i,s])=>(t[i]=new v(s),t),{})}}class E{constructor(e){this.schema=e,this.id=e.id||c.uid(),this.update(e)}id;name="";arg;modifiers;value;iterator;update(e){Object.assign(this.schema,e);const{name:t,arg:i,modifiers:s,value:r,iterator:a}=this.schema;this.name=t,this.arg=i,this.modifiers=s,this.value=r,this.iterator=a}static parse(e=[]){return e.map(t=>new E(t))}static toDsl(e=[]){return e.map(t=>{const{name:i,arg:s,modifiers:r,value:a,iterator:f,id:m}=t;return{id:m,name:i,arg:s,modifiers:r,value:a,iterator:f}})}}const l="EVENT_NODE_CHANGE";class p{constructor(e,t=null){this.parent=t;const{id:i=c.uid(),name:s,from:r=""}=e;this.id=i,this.name=s,this.from=r,this.update(e,!0),p.nodes[this.id]=this}__VTJ_NODE__=!0;locked=!1;static nodes={};id;name;from;invisible=!1;children="";slot;props={};events={};directives=[];disposed=!1;update(e,t=!1){const{invisible:i=!1,locked:s=!1,children:r=[],slot:a,props:f={},events:m={},directives:_=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(a,!0),this.props=N.parse(f),this.events=v.parse(m),this.directives=E.parse(_),t||n.emit(l,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new p(i,this)):this.children=e,t||n.emit(l,this)}setSlot(e,t=!1){this.slot=typeof e=="string"?{name:e,params:[]}:e,t||n.emit(l,this)}setProp(e,t,i,s=!1){const r=this.props[e];r?r.setValue(t):this.props[e]=new N(e,t,i),s||n.emit(l,this)}removeProp(e,t=!1){delete this.props[e],t||n.emit(l,this)}getPropValue(e){const t=this.props[e];if(t)return t.getValue()}setEvent(e,t=!1){const i=this.events[e.name];i?i.update(e):this.events[e.name]=new v(e),t||n.emit(l,this)}removeEvent(e,t=!1){delete this.events[e],t||n.emit(l,this)}setDirective(e,t=!1){const i=this.directives.findIndex(s=>s.id===e.id);i>=0?this.directives.splice(i,1,new E(e)):this.directives.push(new E(e)),t||n.emit(l,this)}removeDirective(e,t=!1){const i=this.directives.findIndex(s=>s===e||s.id===e.id);i>=0&&this.directives.splice(i,1),t||n.emit(l,this)}removeChild(e,t=!1){const{children:i,disposed:s}=this;if(s||!Array.isArray(i))return;const r=i.findIndex(a=>a===e);e.parent=null,i.splice(r,1),t||n.emit(l,this)}appendChild(e,t=!1){const{children:i,disposed:s}=this;s||(e.parent=this,Array.isArray(i)?i.push(e):this.children=[e],t||n.emit(l,this))}insertAfter(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s+1,0,e),t||n.emit(l,this.parent)}}insertBefore(e,t=!1){if(!this.parent)return;const i=this.parent.children;if(Array.isArray(i)){e.parent=this.parent;const s=i.indexOf(this);i.splice(s,0,e),t||n.emit(l,this.parent)}}movePrev(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>0&&(i.splice(s,1),i.splice(s-1,0,this),e||n.emit(l,t))}}moveNext(e=!1){const t=this.parent;if(!t)return;const i=t.children;if(Array.isArray(i)){const s=i.indexOf(this);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,this),e||n.emit(l,t))}}toDsl(){const{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:f,props:m,directives:_,events:O}=this,T=Array.isArray(f)?f.map(D=>D.toDsl()):f;return{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:T,props:N.toDsl(m),directives:E.toDsl(_),events:v.toDsl(O)}}dispose(e=!1){const{children:t,disposed:i}=this;i||(Array.isArray(t)&&t.forEach(s=>s.dispose(!0)),this.parent?this.parent.removeChild(this,e):e||n.emit(l,this),this.parent=null,this.disposed=!0,delete p.nodes[this.id])}lock(e=!1){if(this.locked=!0,Array.isArray(this.children))for(const t of this.children)t.lock(!0);e||n.emit(l,this)}unlock(e=!1){if(this.locked=!1,Array.isArray(this.children))for(const t of this.children)t.unlock(!0);e||n.emit(l,this)}setVisible(e,t=!1){if(this.invisible=!e,Array.isArray(this.children))for(const i of this.children)i.setVisible(e,!0);t||n.emit(l,this)}isChild(e){let t=!1;if(Array.isArray(this.children)){for(const i of this.children)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break}return t}}const o="EVENT_BLOCK_CHANGE";class u{__VTJ_BLOCK__=!0;id;name="";inject=[];state={};lifeCycles={};methods={};computed={};watch=[];css="";props=[];emits=[];slots=[];dataSources={};nodes=[];locked=!1;disposed=!1;static normalAttrs=["name","locked","inject","state","lifeCycles","methods","computed","watch","css","props","emits","slots","dataSources"];constructor(e){const{id:t}=e;this.id=t||c.uid(),this.update(e,!0)}update(e,t=!1){for(const s of u.normalAttrs){const r=e[s];r&&(this[s]=r)}const{nodes:i=[]}=e;i.length&&(this.nodes=i.map(s=>new p(s))),t||n.emit(o,this)}toDsl(e){const{__VTJ_BLOCK__:t,id:i,nodes:s}=this;return{...u.normalAttrs.reduce((a,f)=>(a[f]=this[f],a),{}),__VTJ_BLOCK__:t,__VERSION__:e||c.timestamp().toString(),id:i,nodes:s.map(a=>a.toDsl())}}dispose(){this.nodes.map(e=>e.dispose(!0)),this.nodes=[],this.disposed=!0}setFunction(e,t,i,s=!1){this[e][t]=i,s||n.emit(o,this)}removeFunction(e,t,i=!1){delete this[e][t],i||n.emit(o,this)}setState(e,t,i=!1){this.state[e]=t,i||n.emit(o,this)}removeState(e,t=!1){delete this.state[e],t||n.emit(o,this)}setCss(e,t=!1){this.css=e,t||n.emit(o,this)}setWatch(e,t=!1){e.id=e.id||c.uid();const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1?this.watch.splice(i,1,e):this.watch.push(e),t||n.emit(o,this)}removeWatch(e,t=!1){const i=this.watch.findIndex(s=>s.id&&s.id===e.id||s===e);i>-1&&(this.watch.splice(i,1),t||n.emit(o,this))}setProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1?this.props.splice(i,1,e):this.props.push(e),t||n.emit(o,this)}removeProp(e,t=!1){const i=this.props.findIndex(s=>typeof s=="string"?s===e.name:s.name===e.name);i>-1&&(this.props.splice(i,1),t||n.emit(o,this))}setEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1?this.emits.splice(i,1,e):this.emits.push(e),t||n.emit(o,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>s===e);i>-1&&(this.emits.splice(i,1),t||n.emit(o,this))}setSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1?this.slots.splice(i,1,e):this.slots.push(e),t||n.emit(o,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>s===e);i>-1&&(this.slots.splice(i,1),t||n.emit(o,this))}setInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1?this.inject.splice(i,1,e):this.inject.push(e),t||n.emit(o,this)}removeInject(e,t=!1){const i=this.inject.findIndex(s=>s.name===e.name);i>-1&&(this.inject.splice(i,1),t||n.emit(o,this))}setDataSource(e,t=!1){this.dataSources[e.name]=e,t||n.emit(o,this)}removeDataSource(e,t=!1){delete this.dataSources[e],t||n.emit(o,this)}insertAfter(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s+1,0,e),i||n.emit(o,this)}insertBefore(e,t,i=!1){e.parent=null;const s=this.nodes.indexOf(t);this.nodes.splice(s,0,e),i||n.emit(o,this)}appendNode(e,t=!1){e.parent=null,this.nodes.push(e),t||n.emit(o,this)}addNode(e,t,i="inner",s=!1){t?["left","top"].includes(i)?t.parent?t.insertAfter(e,s):this.insertBefore(e,t,s):["right","bottom"].includes(i)?t.parent?t.insertAfter(e,s):this.insertAfter(e,t,s):t.appendChild(e,s):this.appendNode(e,s)}__removeNode(e,t=!1){const i=this.nodes.findIndex(s=>s.id===e.id);i>-1&&(this.nodes.splice(i,1),t||n.emit(o,this))}removeNode(e,t=!1){e.parent?e.dispose(t):(e.dispose(!0),this.__removeNode(e,t))}move(e,t,i="inner",s=!1){e.parent?e.parent.removeChild(e,!0):this.__removeNode(e,!0),this.addNode(e,t,i,s)}movePrev(e,t=!1){if(e.parent)e.movePrev(t);else{const i=this.nodes,s=i.indexOf(e);s>0&&(i.splice(s,1),i.splice(s-1,0,e),t||n.emit(o,this))}}moveNext(e,t=!1){if(e.parent)e.moveNext(t);else{const i=this.nodes,s=i.indexOf(e);s>-1&&s<i.length-1&&(i.splice(s,1),i.splice(s+1,0,e),t||n.emit(o,this))}}cloneNode(e,t=!1){const i=H(e.toDsl()),s=new p(i);return this.addNode(s,e,"bottom",t),s}lock(e=!1){this.locked=!0;for(const t of this.nodes)t.lock(!0);e||n.emit(o,this)}unlock(e=!1){this.locked=!1;for(const t of this.nodes)t.unlock(!0);e||n.emit(o,this)}isChild(e){let t=!1;for(const i of this.nodes)if(e===i||e.id===i.id){t=!0;break}else if(t=i.isChild(e),t)break;return t}}const h="EVENT_PROJECT_CHANGE",P="EVENT_PROJECT_ACTIVED",V="EVENT_PROJECT_DEPS_CHANGE",A="EVENT_PROJECT_PAGES_CHANGE",y="EVENT_PROJECT_BLOCKS_CHANGE",g="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",L="EVENT_PROJECT_PUBLISH",k="EVENT_PROJECT_FILE_PUBLISH";class I{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};static attrs=["name","homepage","description","dependencies","pages","blocks","apis","meta","config"];constructor(e){const{id:t}=e;this.id=t||c.uid(),this.update(e,!0)}update(e,t=!1){for(const i of I.attrs){const s=e[i];s&&(this[i]=s)}t||n.emit(h,{model:this,type:"update",data:e})}isPageFile(e){return e.type==="page"}toDsl(e){const{id:t}=this,i=I.attrs.reduce((s,r)=>(s[r]=this[r],s),{});return i.pages&&(i.pages=i.pages.map(s=>(delete s.dsl,s))),i.blocks&&(i.blocks=i.blocks.map(s=>(delete s.dsl,s))),{__VTJ_PROJECT__:!0,__VERSION__:e||c.timestamp().toString(),id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(P,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(P,{model:this,type:"update",data:null})}setDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(a=>a.package===e.package);let r;if(s>-1?(r="update",i.splice(s,1,{...i[s],...e})):(r="create",i.push(e)),!t){const a={model:this,type:r,data:e};n.emit(V,a),n.emit(h,a)}}removeDeps(e,t=!1){const i=this.dependencies,s=i.findIndex(r=>r.package===e.package);if(s>-1&&i.splice(s,1),!t){const r={model:this,type:"delete",data:e};n.emit(V,r),n.emit(h,r)}}getPage(e){const t=(i,s=[])=>{for(const r of s){if(r.id===i)return r;if(r.children&&r.children.length){const a=t(i,r.children);if(a)return a}}};return t(e,this.pages)}getPages(){const e=(t=[])=>{let i=[];for(const s of t)s.dir?s.children&&s.children.length&&(i=i.concat(e(s.children))):i.push(s);return i};return e(this.pages)}async createPage(e,t,i=!1){if(e.id=e.raw?e.name:e.id||c.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:c.upperFirstCamelCase(e.name)}).toDsl(),t){const s=this.getPage(t);s?s.children?s.children.push(e):s.children=[e]:console.warn(`not found PageFile for id: ${t} `)}else this.pages.push(e);if(!i){const s={model:this,type:"create",data:e};n.emit(A,s),n.emit(h,s)}!this.currentFile&&!e.dir&&(await c.delay(1e3),this.active(e,i))}updatePage(e,t=!1){const i=this.getPage(e.id);if(i?Object.assign(i,e):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(A,s),n.emit(h,s)}}clonePage(e,t,i=!1){const s=c.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,f=new u({id:s,name:r}).toDsl(),m=c.merge({},e,{id:s,name:r,title:a,dsl:f}),_=t?this.getPage(t)?.children||[]:this.pages,O=_.findIndex(T=>T.id===e.id);if(_.splice(O+1,0,m),!i){const T={model:this,type:"clone",data:{page:e,newPage:m}};n.emit(A,T),n.emit(h,T)}}removePage(e,t=!1){const i=this.getPage(e),s=(r,a)=>{const f=a.findIndex(m=>m.id===r);if(f>=0){a.splice(f,1);return}for(const m of a)if(m.children&&m.children.length)return s(r,m.children)};if(s(e,this.pages),e===this.homepage&&(this.homepage=""),this.currentFile?.id===e&&this.deactivate(t),!t){const r={model:this,type:"delete",data:i};n.emit(A,r),n.emit(h,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}async createBlock(e,t=!1){const i=e.id||c.uid(),s=c.upperFirstCamelCase(e.name);e.id=i,e.type="block",e.dsl=new u({id:i,name:s}).toDsl(),this.blocks.push(e);const r=e.fromType||"Schema";if(!t){const a={model:this,type:"create",data:e};n.emit(y,a),n.emit(h,a)}!this.currentFile&&r==="Schema"&&(await c.delay(1e3),this.active(e,t))}updateBlock(e,t=!1){const i=this.getBlock(e.id);if(i?(Object.assign(i,e),i.dsl&&(i.dsl.name=e.name)):console.warn(`not found PageFile for id: ${e.id} `),!t){const s={model:this,type:"update",data:e};n.emit(y,s),n.emit(h,s)}}removeBlock(e,t=!1){const i=this.getBlock(e),s=this.blocks,r=s.findIndex(a=>a.id===e);if(r>-1?(s.splice(r,1),this.currentFile?.id===e&&this.deactivate(t)):console.warn(`not found PageFile for id: ${e} `),!t){const a={model:this,type:"delete",data:i};n.emit(y,a),n.emit(h,a)}}existBlockName(e,t=[]){return this.blocks.some(i=>i.name===e&&!t.includes(i.id))}existPageName(e,t=[]){return this.getPages().some(s=>s.name===e&&!t.includes(s.id))}setApi(e,t=!1){const i=this.apis.find(r=>r.name===e.name||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=c.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(g,r),n.emit(h,r)}}removeApi(e,t=!1){const i=this.apis.findIndex(s=>s.name===e||s.id===e);if(i>-1?this.apis.splice(i,1):console.warn(`not found Api for name: ${e} `),!t){const s={model:this,type:"delete",data:e};n.emit(g,s),n.emit(h,s)}}existApiName(e,t=[]){return this.apis.some(i=>i.name===e&&!t.includes(i.id))}setMeta(e,t=!1){const i=this.meta.find(r=>r.code===e.code||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=c.uid(),this.meta.push(e)),!t){const r={model:this,type:s,data:e};n.emit(S,r),n.emit(h,r)}}removeMeta(e,t=!1){const i=this.meta.findIndex(s=>s.code===e||s.id===e);if(i>-1?this.meta.splice(i,1):console.warn(`not found meta for name: ${name} `),!t){const s={model:this,type:"delete",data:e};n.emit(S,s),n.emit(h,s)}}existMetaCode(e,t=[]){return this.meta.some(i=>i.code===e&&!t.includes(i.id))}setHomepage(e,t=!1){if(this.homepage=e,!t){const i={model:this,type:"update",data:e};n.emit(h,i)}}setConfig(e,t=!1){if(this.config=Object.assign(this.config,e),!t){const i={model:this,type:"update",data:e};n.emit(h,i)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(k,t):n.emit(L,t)}}const C="EVENT_HISTORY_CHANGE",x="EVENT_HISTORY_LOAD";class K{options={max:50};index=-1;id;items;constructor(e,t={}){Object.assign(this.options,t);const{id:i,items:s=[]}=e;this.id=i,this.items=s}toDsl(){const{id:e,items:t}=this;return{id:e,items:t.map(i=>({id:i.id,label:i.label}))}}get(e){return this.items.find(t=>t.id===e)}add(e,t=!1){const{max:i}=this.options,s={id:c.uid(),label:new Date().toLocaleString(),dsl:c.cloneDeep(e)};if(this.items.unshift(s),this.items.length>i){const r=this.items.splice(i);t||n.emit(C,{model:this,type:"delete",data:r.map(a=>a.id)})}this.index=-1,t||n.emit(C,{model:this,type:"create",data:s})}remove(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>-1?(this.items.splice(i,1),i===this.index?this.index=-1:this.index>=this.items.length&&(this.index=this.items.length-1)):console.warn(`not found HistoryItem for id: ${e} `),t||n.emit(C,{model:this,type:"delete",data:[e]})}forward(e=!1){const{index:t,items:i}=this;if(t<0)return;--this.index;const s=i[this.index];s&&!e&&n.emit(x,{model:this,type:"load",data:s})}backward(e=!1){const{index:t,items:i}=this;if(t>=i.length-1)return;t<0&&(this.index=0),++this.index;const s=i[this.index];s&&!e&&n.emit(x,{model:this,type:"load",data:s})}load(e,t=!1){const i=this.items.findIndex(s=>s.id===e);i>=0&&(this.index=i,t||n.emit(x,{model:this,type:"load",data:this.items[i]}))}clear(e=!1){this.index=-1;const t=this.items.map(i=>i.id);this.items=[],e||n.emit(C,{model:this,type:"clear",data:t})}}const n=c.mitt();function $(d){return d instanceof u}function Y(d){return d instanceof p}function W(d){return!!d.__VTJ_BLOCK__}function H(d){return delete d.id,Array.isArray(d.children)&&(d.children=d.children.map(e=>H(e))),d}function q(d){const e=d.fromType||"Schema";return e==="Schema"?{type:"Schema",id:d.id}:e==="UrlSchema"?{type:"UrlSchema",url:(d.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(d.urls||"").split(","),library:d.library}:""}exports.BUILT_IN_COMPONENTS=w;exports.BUILT_IN_LIBRARAY_MAP=U;exports.BUILT_IN_MATERIALS=G;exports.BUILT_IN_NAME=J;exports.BUILT_IN_TAGS=F;exports.BUILT_IN_VUE=R;exports.BUILT_IN_VUE_ROUTER=B;exports.Base=j;exports.BlockModel=u;exports.DirectiveModel=E;exports.EVENT_BLOCK_CHANGE=o;exports.EVENT_HISTORY_CHANGE=C;exports.EVENT_HISTORY_LOAD=x;exports.EVENT_NODE_CHANGE=l;exports.EVENT_PROJECT_ACTIVED=P;exports.EVENT_PROJECT_APIS_CHANGE=g;exports.EVENT_PROJECT_BLOCKS_CHANGE=y;exports.EVENT_PROJECT_CHANGE=h;exports.EVENT_PROJECT_DEPS_CHANGE=V;exports.EVENT_PROJECT_FILE_PUBLISH=k;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=A;exports.EVENT_PROJECT_PUBLISH=L;exports.EventModel=v;exports.HistoryModel=K;exports.NodeModel=p;exports.ProjectModel=I;exports.PropModel=N;exports.Service=M;exports.VTJ_CORE_VERSION=b;exports.cloneDsl=H;exports.createNodeFrom=q;exports.emitter=n;exports.isBlock=$;exports.isBlockSchema=W;exports.isNode=Y;
|
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { uid as m, timestamp as
|
|
1
|
+
import { uid as m, timestamp as D, upperFirstCamelCase as I, delay as P, merge as L, cloneDeep as J, mitt as G } from "@vtj/base";
|
|
2
2
|
/**!
|
|
3
3
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
4
4
|
* @name @vtj/core
|
|
5
5
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
6
|
-
* @version 0.8.
|
|
6
|
+
* @version 0.8.28
|
|
7
7
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const $ = "0.8.28", K = "BuiltIn", b = "VueMaterial", B = "VueRouterMaterial", M = [b, B], Y = {
|
|
10
10
|
vue: "Vue",
|
|
11
11
|
"vue-router": "VueRouter"
|
|
12
|
-
},
|
|
13
|
-
[
|
|
12
|
+
}, W = {
|
|
13
|
+
[b]: [
|
|
14
14
|
"Transition",
|
|
15
15
|
"TransitionGroup",
|
|
16
16
|
"KeepAlive",
|
|
17
17
|
"Teleport",
|
|
18
18
|
"Suspense"
|
|
19
19
|
],
|
|
20
|
-
[
|
|
21
|
-
},
|
|
20
|
+
[B]: ["RouterView", "RouterLink"]
|
|
21
|
+
}, q = [
|
|
22
22
|
"slot",
|
|
23
23
|
"template",
|
|
24
24
|
"component",
|
|
@@ -31,9 +31,9 @@ const j = "0.8.26", K = "BuiltIn", D = "VueMaterial", b = "VueRouterMaterial", $
|
|
|
31
31
|
"span",
|
|
32
32
|
"a"
|
|
33
33
|
];
|
|
34
|
-
class q {
|
|
35
|
-
}
|
|
36
34
|
class z {
|
|
35
|
+
}
|
|
36
|
+
class Q {
|
|
37
37
|
listeners = [];
|
|
38
38
|
isReady = !1;
|
|
39
39
|
triggerReady() {
|
|
@@ -135,14 +135,14 @@ class v {
|
|
|
135
135
|
}
|
|
136
136
|
static toDsl(e = []) {
|
|
137
137
|
return e.map((t) => {
|
|
138
|
-
const { name: i, arg: s, modifiers: r, value: a, iterator:
|
|
138
|
+
const { name: i, arg: s, modifiers: r, value: a, iterator: c, id: f } = t;
|
|
139
139
|
return {
|
|
140
|
-
id:
|
|
140
|
+
id: f,
|
|
141
141
|
name: i,
|
|
142
142
|
arg: s,
|
|
143
143
|
modifiers: r,
|
|
144
144
|
value: a,
|
|
145
|
-
iterator:
|
|
145
|
+
iterator: c
|
|
146
146
|
};
|
|
147
147
|
});
|
|
148
148
|
}
|
|
@@ -217,11 +217,11 @@ class p {
|
|
|
217
217
|
locked: s = !1,
|
|
218
218
|
children: r = [],
|
|
219
219
|
slot: a,
|
|
220
|
-
props:
|
|
221
|
-
events:
|
|
220
|
+
props: c = {},
|
|
221
|
+
events: f = {},
|
|
222
222
|
directives: E = []
|
|
223
223
|
} = e;
|
|
224
|
-
this.invisible = i, this.locked = s, this.setChildren(r, !0), this.setSlot(a, !0), this.props = x.parse(
|
|
224
|
+
this.invisible = i, this.locked = s, this.setChildren(r, !0), this.setSlot(a, !0), this.props = x.parse(c), this.events = y.parse(f), this.directives = v.parse(E), t || n.emit(l, this);
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
227
|
* 设置子节点
|
|
@@ -392,11 +392,11 @@ class p {
|
|
|
392
392
|
invisible: s,
|
|
393
393
|
locked: r,
|
|
394
394
|
slot: a,
|
|
395
|
-
children:
|
|
396
|
-
props:
|
|
395
|
+
children: c,
|
|
396
|
+
props: f,
|
|
397
397
|
directives: E,
|
|
398
398
|
events: T
|
|
399
|
-
} = this, _ = Array.isArray(
|
|
399
|
+
} = this, _ = Array.isArray(c) ? c.map((H) => H.toDsl()) : c;
|
|
400
400
|
return {
|
|
401
401
|
id: e,
|
|
402
402
|
name: t,
|
|
@@ -405,7 +405,7 @@ class p {
|
|
|
405
405
|
locked: r,
|
|
406
406
|
slot: a,
|
|
407
407
|
children: _,
|
|
408
|
-
props: x.toDsl(
|
|
408
|
+
props: x.toDsl(f),
|
|
409
409
|
directives: v.toDsl(E),
|
|
410
410
|
events: y.toDsl(T)
|
|
411
411
|
};
|
|
@@ -504,11 +504,11 @@ class u {
|
|
|
504
504
|
const { __VTJ_BLOCK__: t, id: i, nodes: s } = this;
|
|
505
505
|
return {
|
|
506
506
|
...u.normalAttrs.reduce(
|
|
507
|
-
(a,
|
|
507
|
+
(a, c) => (a[c] = this[c], a),
|
|
508
508
|
{}
|
|
509
509
|
),
|
|
510
510
|
__VTJ_BLOCK__: t,
|
|
511
|
-
__VERSION__: e ||
|
|
511
|
+
__VERSION__: e || D().toString(),
|
|
512
512
|
id: i,
|
|
513
513
|
nodes: s.map((a) => a.toDsl())
|
|
514
514
|
};
|
|
@@ -756,7 +756,7 @@ class u {
|
|
|
756
756
|
* @returns
|
|
757
757
|
*/
|
|
758
758
|
cloneNode(e, t = !1) {
|
|
759
|
-
const i =
|
|
759
|
+
const i = w(e.toDsl()), s = new p(i);
|
|
760
760
|
return this.addNode(s, e, "bottom", t), s;
|
|
761
761
|
}
|
|
762
762
|
lock(e = !1) {
|
|
@@ -782,7 +782,7 @@ class u {
|
|
|
782
782
|
return t;
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
|
-
const
|
|
785
|
+
const h = "EVENT_PROJECT_CHANGE", V = "EVENT_PROJECT_ACTIVED", S = "EVENT_PROJECT_DEPS_CHANGE", A = "EVENT_PROJECT_PAGES_CHANGE", g = "EVENT_PROJECT_BLOCKS_CHANGE", R = "EVENT_PROJECT_APIS_CHANGE", k = "EVENT_PROJECT_META_CHANGE", F = "EVENT_PROJECT_PUBLISH", U = "EVENT_PROJECT_FILE_PUBLISH";
|
|
786
786
|
class O {
|
|
787
787
|
id = "";
|
|
788
788
|
name = "";
|
|
@@ -792,6 +792,7 @@ class O {
|
|
|
792
792
|
pages = [];
|
|
793
793
|
blocks = [];
|
|
794
794
|
apis = [];
|
|
795
|
+
meta = [];
|
|
795
796
|
currentFile = null;
|
|
796
797
|
config = {};
|
|
797
798
|
static attrs = [
|
|
@@ -802,6 +803,7 @@ class O {
|
|
|
802
803
|
"pages",
|
|
803
804
|
"blocks",
|
|
804
805
|
"apis",
|
|
806
|
+
"meta",
|
|
805
807
|
"config"
|
|
806
808
|
];
|
|
807
809
|
constructor(e) {
|
|
@@ -813,7 +815,7 @@ class O {
|
|
|
813
815
|
const s = e[i];
|
|
814
816
|
s && (this[i] = s);
|
|
815
817
|
}
|
|
816
|
-
t || n.emit(
|
|
818
|
+
t || n.emit(h, {
|
|
817
819
|
model: this,
|
|
818
820
|
type: "update",
|
|
819
821
|
data: e
|
|
@@ -829,7 +831,7 @@ class O {
|
|
|
829
831
|
);
|
|
830
832
|
return i.pages && (i.pages = i.pages.map((s) => (delete s.dsl, s))), i.blocks && (i.blocks = i.blocks.map((s) => (delete s.dsl, s))), {
|
|
831
833
|
__VTJ_PROJECT__: !0,
|
|
832
|
-
__VERSION__: e ||
|
|
834
|
+
__VERSION__: e || D().toString(),
|
|
833
835
|
id: t,
|
|
834
836
|
...i
|
|
835
837
|
};
|
|
@@ -874,7 +876,7 @@ class O {
|
|
|
874
876
|
type: r,
|
|
875
877
|
data: e
|
|
876
878
|
};
|
|
877
|
-
n.emit(S, a), n.emit(
|
|
879
|
+
n.emit(S, a), n.emit(h, a);
|
|
878
880
|
}
|
|
879
881
|
}
|
|
880
882
|
/**
|
|
@@ -890,7 +892,7 @@ class O {
|
|
|
890
892
|
type: "delete",
|
|
891
893
|
data: e
|
|
892
894
|
};
|
|
893
|
-
n.emit(S, r), n.emit(
|
|
895
|
+
n.emit(S, r), n.emit(h, r);
|
|
894
896
|
}
|
|
895
897
|
}
|
|
896
898
|
/**
|
|
@@ -946,9 +948,9 @@ class O {
|
|
|
946
948
|
type: "create",
|
|
947
949
|
data: e
|
|
948
950
|
};
|
|
949
|
-
n.emit(A, s), n.emit(
|
|
951
|
+
n.emit(A, s), n.emit(h, s);
|
|
950
952
|
}
|
|
951
|
-
!this.currentFile && !e.dir && (await P(
|
|
953
|
+
!this.currentFile && !e.dir && (await P(1e3), this.active(e, i));
|
|
952
954
|
}
|
|
953
955
|
/**
|
|
954
956
|
* 更新页面
|
|
@@ -963,7 +965,7 @@ class O {
|
|
|
963
965
|
type: "update",
|
|
964
966
|
data: e
|
|
965
967
|
};
|
|
966
|
-
n.emit(A, s), n.emit(
|
|
968
|
+
n.emit(A, s), n.emit(h, s);
|
|
967
969
|
}
|
|
968
970
|
}
|
|
969
971
|
/**
|
|
@@ -973,20 +975,20 @@ class O {
|
|
|
973
975
|
* @param silent
|
|
974
976
|
*/
|
|
975
977
|
clonePage(e, t, i = !1) {
|
|
976
|
-
const s = m(), r = `${e.name}Copy`, a = `${e.title}_副本`,
|
|
978
|
+
const s = m(), r = `${e.name}Copy`, a = `${e.title}_副本`, c = new u({
|
|
977
979
|
id: s,
|
|
978
980
|
name: r
|
|
979
|
-
}).toDsl(),
|
|
980
|
-
if (E.splice(T + 1, 0,
|
|
981
|
+
}).toDsl(), f = L({}, e, { id: s, name: r, title: a, dsl: c }), E = t ? this.getPage(t)?.children || [] : this.pages, T = E.findIndex((_) => _.id === e.id);
|
|
982
|
+
if (E.splice(T + 1, 0, f), !i) {
|
|
981
983
|
const _ = {
|
|
982
984
|
model: this,
|
|
983
985
|
type: "clone",
|
|
984
986
|
data: {
|
|
985
987
|
page: e,
|
|
986
|
-
newPage:
|
|
988
|
+
newPage: f
|
|
987
989
|
}
|
|
988
990
|
};
|
|
989
|
-
n.emit(A, _), n.emit(
|
|
991
|
+
n.emit(A, _), n.emit(h, _);
|
|
990
992
|
}
|
|
991
993
|
}
|
|
992
994
|
/**
|
|
@@ -996,14 +998,14 @@ class O {
|
|
|
996
998
|
*/
|
|
997
999
|
removePage(e, t = !1) {
|
|
998
1000
|
const i = this.getPage(e), s = (r, a) => {
|
|
999
|
-
const
|
|
1000
|
-
if (
|
|
1001
|
-
a.splice(
|
|
1001
|
+
const c = a.findIndex((f) => f.id === r);
|
|
1002
|
+
if (c >= 0) {
|
|
1003
|
+
a.splice(c, 1);
|
|
1002
1004
|
return;
|
|
1003
1005
|
}
|
|
1004
|
-
for (const
|
|
1005
|
-
if (
|
|
1006
|
-
return s(r,
|
|
1006
|
+
for (const f of a)
|
|
1007
|
+
if (f.children && f.children.length)
|
|
1008
|
+
return s(r, f.children);
|
|
1007
1009
|
};
|
|
1008
1010
|
if (s(e, this.pages), e === this.homepage && (this.homepage = ""), this.currentFile?.id === e && this.deactivate(t), !t) {
|
|
1009
1011
|
const r = {
|
|
@@ -1011,7 +1013,7 @@ class O {
|
|
|
1011
1013
|
type: "delete",
|
|
1012
1014
|
data: i
|
|
1013
1015
|
};
|
|
1014
|
-
n.emit(A, r), n.emit(
|
|
1016
|
+
n.emit(A, r), n.emit(h, r);
|
|
1015
1017
|
}
|
|
1016
1018
|
}
|
|
1017
1019
|
/**
|
|
@@ -1037,9 +1039,9 @@ class O {
|
|
|
1037
1039
|
type: "create",
|
|
1038
1040
|
data: e
|
|
1039
1041
|
};
|
|
1040
|
-
n.emit(g, a), n.emit(
|
|
1042
|
+
n.emit(g, a), n.emit(h, a);
|
|
1041
1043
|
}
|
|
1042
|
-
!this.currentFile && r === "Schema" && (await P(
|
|
1044
|
+
!this.currentFile && r === "Schema" && (await P(1e3), this.active(e, t));
|
|
1043
1045
|
}
|
|
1044
1046
|
/**
|
|
1045
1047
|
*
|
|
@@ -1054,7 +1056,7 @@ class O {
|
|
|
1054
1056
|
type: "update",
|
|
1055
1057
|
data: e
|
|
1056
1058
|
};
|
|
1057
|
-
n.emit(g, s), n.emit(
|
|
1059
|
+
n.emit(g, s), n.emit(h, s);
|
|
1058
1060
|
}
|
|
1059
1061
|
}
|
|
1060
1062
|
/**
|
|
@@ -1070,7 +1072,7 @@ class O {
|
|
|
1070
1072
|
type: "delete",
|
|
1071
1073
|
data: i
|
|
1072
1074
|
};
|
|
1073
|
-
n.emit(g, a), n.emit(
|
|
1075
|
+
n.emit(g, a), n.emit(h, a);
|
|
1074
1076
|
}
|
|
1075
1077
|
}
|
|
1076
1078
|
/**
|
|
@@ -1107,7 +1109,7 @@ class O {
|
|
|
1107
1109
|
type: s,
|
|
1108
1110
|
data: e
|
|
1109
1111
|
};
|
|
1110
|
-
n.emit(R, r), n.emit(
|
|
1112
|
+
n.emit(R, r), n.emit(h, r);
|
|
1111
1113
|
}
|
|
1112
1114
|
}
|
|
1113
1115
|
/**
|
|
@@ -1123,12 +1125,40 @@ class O {
|
|
|
1123
1125
|
type: "delete",
|
|
1124
1126
|
data: e
|
|
1125
1127
|
};
|
|
1126
|
-
n.emit(R, s), n.emit(
|
|
1128
|
+
n.emit(R, s), n.emit(h, s);
|
|
1127
1129
|
}
|
|
1128
1130
|
}
|
|
1129
1131
|
existApiName(e, t = []) {
|
|
1130
1132
|
return this.apis.some((i) => i.name === e && !t.includes(i.id));
|
|
1131
1133
|
}
|
|
1134
|
+
setMeta(e, t = !1) {
|
|
1135
|
+
const i = this.meta.find(
|
|
1136
|
+
(r) => r.code === e.code || r.id === e.id
|
|
1137
|
+
);
|
|
1138
|
+
let s;
|
|
1139
|
+
if (i ? (s = "update", Object.assign(i, e)) : (s = "create", e.id = m(), this.meta.push(e)), !t) {
|
|
1140
|
+
const r = {
|
|
1141
|
+
model: this,
|
|
1142
|
+
type: s,
|
|
1143
|
+
data: e
|
|
1144
|
+
};
|
|
1145
|
+
n.emit(k, r), n.emit(h, r);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
removeMeta(e, t = !1) {
|
|
1149
|
+
const i = this.meta.findIndex((s) => s.code === e || s.id === e);
|
|
1150
|
+
if (i > -1 ? this.meta.splice(i, 1) : console.warn(`not found meta for name: ${name} `), !t) {
|
|
1151
|
+
const s = {
|
|
1152
|
+
model: this,
|
|
1153
|
+
type: "delete",
|
|
1154
|
+
data: e
|
|
1155
|
+
};
|
|
1156
|
+
n.emit(k, s), n.emit(h, s);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
existMetaCode(e, t = []) {
|
|
1160
|
+
return this.meta.some((i) => i.code === e && !t.includes(i.id));
|
|
1161
|
+
}
|
|
1132
1162
|
setHomepage(e, t = !1) {
|
|
1133
1163
|
if (this.homepage = e, !t) {
|
|
1134
1164
|
const i = {
|
|
@@ -1136,7 +1166,7 @@ class O {
|
|
|
1136
1166
|
type: "update",
|
|
1137
1167
|
data: e
|
|
1138
1168
|
};
|
|
1139
|
-
n.emit(
|
|
1169
|
+
n.emit(h, i);
|
|
1140
1170
|
}
|
|
1141
1171
|
}
|
|
1142
1172
|
setConfig(e, t = !1) {
|
|
@@ -1146,7 +1176,7 @@ class O {
|
|
|
1146
1176
|
type: "update",
|
|
1147
1177
|
data: e
|
|
1148
1178
|
};
|
|
1149
|
-
n.emit(
|
|
1179
|
+
n.emit(h, i);
|
|
1150
1180
|
}
|
|
1151
1181
|
}
|
|
1152
1182
|
publish(e) {
|
|
@@ -1155,11 +1185,11 @@ class O {
|
|
|
1155
1185
|
type: "publish",
|
|
1156
1186
|
data: e || this
|
|
1157
1187
|
};
|
|
1158
|
-
e ? n.emit(
|
|
1188
|
+
e ? n.emit(U, t) : n.emit(F, t);
|
|
1159
1189
|
}
|
|
1160
1190
|
}
|
|
1161
1191
|
const N = "EVENT_HISTORY_CHANGE", C = "EVENT_HISTORY_LOAD";
|
|
1162
|
-
class
|
|
1192
|
+
class X {
|
|
1163
1193
|
options = { max: 50 };
|
|
1164
1194
|
index = -1;
|
|
1165
1195
|
id;
|
|
@@ -1193,7 +1223,7 @@ class Q {
|
|
|
1193
1223
|
const { max: i } = this.options, s = {
|
|
1194
1224
|
id: m(),
|
|
1195
1225
|
label: (/* @__PURE__ */ new Date()).toLocaleString(),
|
|
1196
|
-
dsl:
|
|
1226
|
+
dsl: J(e)
|
|
1197
1227
|
};
|
|
1198
1228
|
if (this.items.unshift(s), this.items.length > i) {
|
|
1199
1229
|
const r = this.items.splice(i);
|
|
@@ -1264,20 +1294,20 @@ class Q {
|
|
|
1264
1294
|
});
|
|
1265
1295
|
}
|
|
1266
1296
|
}
|
|
1267
|
-
const n =
|
|
1268
|
-
function
|
|
1297
|
+
const n = G();
|
|
1298
|
+
function Z(d) {
|
|
1269
1299
|
return d instanceof u;
|
|
1270
1300
|
}
|
|
1271
|
-
function
|
|
1301
|
+
function ee(d) {
|
|
1272
1302
|
return d instanceof p;
|
|
1273
1303
|
}
|
|
1274
|
-
function
|
|
1304
|
+
function te(d) {
|
|
1275
1305
|
return !!d.__VTJ_BLOCK__;
|
|
1276
1306
|
}
|
|
1277
|
-
function
|
|
1278
|
-
return delete d.id, Array.isArray(d.children) && (d.children = d.children.map((e) =>
|
|
1307
|
+
function w(d) {
|
|
1308
|
+
return delete d.id, Array.isArray(d.children) && (d.children = d.children.map((e) => w(e))), d;
|
|
1279
1309
|
}
|
|
1280
|
-
function
|
|
1310
|
+
function ie(d) {
|
|
1281
1311
|
const e = d.fromType || "Schema";
|
|
1282
1312
|
return e === "Schema" ? {
|
|
1283
1313
|
type: "Schema",
|
|
@@ -1292,14 +1322,14 @@ function te(d) {
|
|
|
1292
1322
|
} : "";
|
|
1293
1323
|
}
|
|
1294
1324
|
export {
|
|
1295
|
-
|
|
1325
|
+
W as BUILT_IN_COMPONENTS,
|
|
1296
1326
|
Y as BUILT_IN_LIBRARAY_MAP,
|
|
1297
|
-
|
|
1327
|
+
M as BUILT_IN_MATERIALS,
|
|
1298
1328
|
K as BUILT_IN_NAME,
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1329
|
+
q as BUILT_IN_TAGS,
|
|
1330
|
+
b as BUILT_IN_VUE,
|
|
1331
|
+
B as BUILT_IN_VUE_ROUTER,
|
|
1332
|
+
Q as Base,
|
|
1303
1333
|
u as BlockModel,
|
|
1304
1334
|
v as DirectiveModel,
|
|
1305
1335
|
o as EVENT_BLOCK_CHANGE,
|
|
@@ -1309,22 +1339,23 @@ export {
|
|
|
1309
1339
|
V as EVENT_PROJECT_ACTIVED,
|
|
1310
1340
|
R as EVENT_PROJECT_APIS_CHANGE,
|
|
1311
1341
|
g as EVENT_PROJECT_BLOCKS_CHANGE,
|
|
1312
|
-
|
|
1342
|
+
h as EVENT_PROJECT_CHANGE,
|
|
1313
1343
|
S as EVENT_PROJECT_DEPS_CHANGE,
|
|
1314
|
-
|
|
1344
|
+
U as EVENT_PROJECT_FILE_PUBLISH,
|
|
1345
|
+
k as EVENT_PROJECT_META_CHANGE,
|
|
1315
1346
|
A as EVENT_PROJECT_PAGES_CHANGE,
|
|
1316
1347
|
F as EVENT_PROJECT_PUBLISH,
|
|
1317
1348
|
y as EventModel,
|
|
1318
|
-
|
|
1349
|
+
X as HistoryModel,
|
|
1319
1350
|
p as NodeModel,
|
|
1320
1351
|
O as ProjectModel,
|
|
1321
1352
|
x as PropModel,
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1353
|
+
z as Service,
|
|
1354
|
+
$ as VTJ_CORE_VERSION,
|
|
1355
|
+
w as cloneDsl,
|
|
1356
|
+
ie as createNodeFrom,
|
|
1326
1357
|
n as emitter,
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1358
|
+
Z as isBlock,
|
|
1359
|
+
te as isBlockSchema,
|
|
1360
|
+
ee as isNode
|
|
1330
1361
|
};
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProjectSchema, Dependencie, PageFile, BlockFile, ApiSchema, ProjectConfig } from '../protocols';
|
|
1
|
+
import { ProjectSchema, Dependencie, PageFile, BlockFile, ApiSchema, MetaSchema, ProjectConfig } from '../protocols';
|
|
2
2
|
import { ModelEventType } from '../tools';
|
|
3
3
|
|
|
4
4
|
export interface ProjectModelEvent {
|
|
@@ -30,6 +30,10 @@ export declare const EVENT_PROJECT_BLOCKS_CHANGE = "EVENT_PROJECT_BLOCKS_CHANGE"
|
|
|
30
30
|
* API更新
|
|
31
31
|
*/
|
|
32
32
|
export declare const EVENT_PROJECT_APIS_CHANGE = "EVENT_PROJECT_APIS_CHANGE";
|
|
33
|
+
/**
|
|
34
|
+
* Meta更新
|
|
35
|
+
*/
|
|
36
|
+
export declare const EVENT_PROJECT_META_CHANGE = "EVENT_PROJECT_META_CHANGE";
|
|
33
37
|
/**
|
|
34
38
|
* 项目发布
|
|
35
39
|
*/
|
|
@@ -47,6 +51,7 @@ export declare class ProjectModel {
|
|
|
47
51
|
pages: PageFile[];
|
|
48
52
|
blocks: BlockFile[];
|
|
49
53
|
apis: ApiSchema[];
|
|
54
|
+
meta: MetaSchema[];
|
|
50
55
|
currentFile: PageFile | BlockFile | null;
|
|
51
56
|
config: ProjectConfig;
|
|
52
57
|
static attrs: string[];
|
|
@@ -165,6 +170,9 @@ export declare class ProjectModel {
|
|
|
165
170
|
*/
|
|
166
171
|
removeApi(name: string, silent?: boolean): void;
|
|
167
172
|
existApiName(name: string, excludes?: string[]): boolean;
|
|
173
|
+
setMeta(item: MetaSchema, silent?: boolean): void;
|
|
174
|
+
removeMeta(code: string, silent?: boolean): void;
|
|
175
|
+
existMetaCode(code: string, excludes?: string[]): boolean;
|
|
168
176
|
setHomepage(id: string, silent?: boolean): void;
|
|
169
177
|
setConfig(config: ProjectConfig, silent?: boolean): void;
|
|
170
178
|
publish(file?: PageFile | BlockFile): void;
|
|
@@ -53,6 +53,27 @@ export interface ApiSchema {
|
|
|
53
53
|
*/
|
|
54
54
|
mock?: boolean;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* 配置化查询数据源
|
|
58
|
+
*/
|
|
59
|
+
export interface MetaSchema {
|
|
60
|
+
/**
|
|
61
|
+
* 唯一标识
|
|
62
|
+
*/
|
|
63
|
+
id: string;
|
|
64
|
+
/**
|
|
65
|
+
* 功能号
|
|
66
|
+
*/
|
|
67
|
+
code: string;
|
|
68
|
+
/**
|
|
69
|
+
* 报表名称
|
|
70
|
+
*/
|
|
71
|
+
title: string;
|
|
72
|
+
/**
|
|
73
|
+
* 查询方案编号
|
|
74
|
+
*/
|
|
75
|
+
queryCode: string;
|
|
76
|
+
}
|
|
56
77
|
/**
|
|
57
78
|
* 页面级引用数据源
|
|
58
79
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PageFile, BlockFile } from './file';
|
|
2
2
|
import { Dependencie } from '../assets';
|
|
3
|
-
import { ApiSchema } from './dataSource';
|
|
3
|
+
import { ApiSchema, MetaSchema } from './dataSource';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 项目描述信息
|
|
@@ -38,6 +38,10 @@ export interface ProjectSchema {
|
|
|
38
38
|
* api
|
|
39
39
|
*/
|
|
40
40
|
apis?: ApiSchema[];
|
|
41
|
+
/**
|
|
42
|
+
* 配置化查询
|
|
43
|
+
*/
|
|
44
|
+
meta?: MetaSchema[];
|
|
41
45
|
/**
|
|
42
46
|
* 项目配置
|
|
43
47
|
*/
|
package/types/tools/emitter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProjectModelEvent, BlockModel, NodeModel, HistoryModelEvent, EVENT_PROJECT_CHANGE, EVENT_PROJECT_ACTIVED, EVENT_PROJECT_DEPS_CHANGE, EVENT_PROJECT_PAGES_CHANGE, EVENT_PROJECT_BLOCKS_CHANGE, EVENT_PROJECT_APIS_CHANGE, EVENT_PROJECT_PUBLISH, EVENT_PROJECT_FILE_PUBLISH, EVENT_BLOCK_CHANGE, EVENT_NODE_CHANGE, EVENT_HISTORY_CHANGE, EVENT_HISTORY_LOAD } from '../models';
|
|
1
|
+
import { ProjectModelEvent, BlockModel, NodeModel, HistoryModelEvent, EVENT_PROJECT_CHANGE, EVENT_PROJECT_ACTIVED, EVENT_PROJECT_DEPS_CHANGE, EVENT_PROJECT_PAGES_CHANGE, EVENT_PROJECT_BLOCKS_CHANGE, EVENT_PROJECT_APIS_CHANGE, EVENT_PROJECT_META_CHANGE, EVENT_PROJECT_PUBLISH, EVENT_PROJECT_FILE_PUBLISH, EVENT_BLOCK_CHANGE, EVENT_NODE_CHANGE, EVENT_HISTORY_CHANGE, EVENT_HISTORY_LOAD } from '../models';
|
|
2
2
|
import { Emitter } from 'mitt';
|
|
3
3
|
|
|
4
4
|
type Events = {
|
|
@@ -8,6 +8,7 @@ type Events = {
|
|
|
8
8
|
[EVENT_PROJECT_PAGES_CHANGE]: ProjectModelEvent;
|
|
9
9
|
[EVENT_PROJECT_BLOCKS_CHANGE]: ProjectModelEvent;
|
|
10
10
|
[EVENT_PROJECT_APIS_CHANGE]: ProjectModelEvent;
|
|
11
|
+
[EVENT_PROJECT_META_CHANGE]: ProjectModelEvent;
|
|
11
12
|
[EVENT_PROJECT_PUBLISH]: ProjectModelEvent;
|
|
12
13
|
[EVENT_PROJECT_FILE_PUBLISH]: ProjectModelEvent;
|
|
13
14
|
[EVENT_BLOCK_CHANGE]: BlockModel;
|
package/types/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/core
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.8.
|
|
5
|
+
* @version 0.8.27
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.8.
|
|
8
|
+
export declare const version = "0.8.27";
|