@vtj/core 0.8.171 → 0.9.0-alpha.0
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/LICENSE +21 -21
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +95 -77
- package/package.json +3 -3
- package/types/models/project.d.ts +1 -0
- package/types/protocols/schemas/block.d.ts +4 -0
- package/types/protocols/schemas/file.d.ts +9 -5
- package/types/version.d.ts +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 陈华春
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 陈华春
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
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.
|
|
5
|
+
* @version 0.9.0-alpha.0
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const b="0.8.171",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||d.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=d.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:I}=this,T=Array.isArray(f)?f.map(k=>k.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(I)}}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||d.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||d.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||d.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=d.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(r=>r===i.name||r===i);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(o,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>d.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(o,this))}setSlot(e,t=!1){const i=d.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(r=>r===i.name||r===i);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(o,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>d.isString(s)?s===e:s.name===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 c="EVENT_PROJECT_CHANGE",O="EVENT_PROJECT_ACTIVED",g="EVENT_PROJECT_DEPS_CHANGE",A="EVENT_PROJECT_PAGES_CHANGE",y="EVENT_PROJECT_BLOCKS_CHANGE",V="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",D="EVENT_PROJECT_PUBLISH",L="EVENT_PROJECT_FILE_PUBLISH";class P{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};__BASE_PATH__="/";static attrs=["name","homepage","description","dependencies","pages","blocks","apis","meta","config","__BASE_PATH__"];constructor(e){const{id:t}=e;this.id=t||d.uid(),this.update(e,!0)}update(e,t=!1){for(const i of P.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=P.attrs.reduce((s,r)=>(s[r]=this[r],s),{});return i.pages&&(i.pages=i.pages.map(s=>(delete s.dsl,s)),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>(delete s.dsl,s))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(O,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(O,{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(c,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(c,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||d.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:d.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(c,s)}!this.currentFile&&!e.dir&&(await d.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(c,s)}}clonePage(e,t,i=!1){const s=d.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,f=new u({id:s,name:r}).toDsl(),m=d.merge({},e,{id:s,name:r,title:a,dsl:f}),_=t?this.getPage(t)?.children||[]:this.pages,I=_.findIndex(T=>T.id===e.id);if(_.splice(I+1,0,m),!i){const T={model:this,type:"clone",data:{page:e,newPage:m}};n.emit(A,T),n.emit(c,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)m.children&&m.children.length&&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(c,r)}}getBlock(e){return this.blocks.find(t=>t.id===e)}async createBlock(e,t=!1){const i=e.id||d.uid(),s=d.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(c,a)}!this.currentFile&&r==="Schema"&&(await d.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(c,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(c,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=d.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(V,r),n.emit(c,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(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(r=>r.code===e.code||r.id===e.id);let s;if(i?(s="update",Object.assign(i,e)):(s="create",e.id=d.uid(),this.meta.push(e)),!t){const r={model:this,type:s,data:e};n.emit(S,r),n.emit(c,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(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)}}publish(e){const t={model:this,type:"publish",data:e||this};e?n.emit(L,t):n.emit(D,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:d.uid(),label:new Date().toLocaleString(),dsl:d.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=d.mitt();function $(h){return h instanceof u}function Y(h){return h instanceof p}function W(h){return!!h.__VTJ_BLOCK__}function H(h){const e=d.cloneDeep(h);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>H(t))),e}function q(h){const e=h.fromType||"Schema";return e==="Schema"?{type:"Schema",id:h.id}:e==="UrlSchema"?{type:"UrlSchema",url:(h.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(h.urls||"").split(","),library:h.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=O;exports.EVENT_PROJECT_APIS_CHANGE=V;exports.EVENT_PROJECT_BLOCKS_CHANGE=y;exports.EVENT_PROJECT_CHANGE=c;exports.EVENT_PROJECT_DEPS_CHANGE=g;exports.EVENT_PROJECT_FILE_PUBLISH=L;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=A;exports.EVENT_PROJECT_PUBLISH=D;exports.EventModel=v;exports.HistoryModel=K;exports.NodeModel=p;exports.ProjectModel=P;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;
|
|
7
|
+
*/const b="0.9.0-alpha.0",J="BuiltIn",R="VueMaterial",B="VueRouterMaterial",G=[R,B],w={vue:"Vue","vue-router":"VueRouter"},U={[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 _{constructor(e){this.schema=e,this.id=e.id||d.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 _(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 E{constructor(e,t=null){this.parent=t;const{id:i=d.uid(),name:s,from:r=""}=e;this.id=i,this.name=s,this.from=r,this.update(e,!0),E.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:p=[]}=e;this.invisible=i,this.locked=s,this.setChildren(r,!0),this.setSlot(a,!0),this.props=N.parse(c),this.events=v.parse(m),this.directives=_.parse(p),t||n.emit(l,this)}setChildren(e="",t=!1){Array.isArray(e)?this.children=e.map(i=>new E(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)):this.directives.push(new _(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:p,events:I}=this,T=Array.isArray(c)?c.map(k=>k.toDsl()):c;return{id:e,name:t,from:i,invisible:s,locked:r,slot:a,children:T,props:N.toDsl(m),directives:_.toDsl(p),events:v.toDsl(I)}}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 E.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","__TEMPLATE_ID__"];constructor(e){const{id:t}=e;this.id=t||d.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 E(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||d.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||d.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=d.isString(e)?{name:e,params:[]}:e,s=this.emits.findIndex(r=>r===i.name||r===i);s>-1?this.emits.splice(s,1,i):this.emits.push(i),t||n.emit(o,this)}removeEmit(e,t=!1){const i=this.emits.findIndex(s=>d.isString(s)?s===e:s.name===e);i>-1&&(this.emits.splice(i,1),t||n.emit(o,this))}setSlot(e,t=!1){const i=d.isString(e)?{name:e,params:[]}:e,s=this.slots.findIndex(r=>r===i.name||r===i);s>-1?this.slots.splice(s,1,i):this.slots.push(i),t||n.emit(o,this)}removeSlot(e,t=!1){const i=this.slots.findIndex(s=>d.isString(s)?s===e:s.name===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=D(e.toDsl()),s=new E(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",g="EVENT_PROJECT_ACTIVED",O="EVENT_PROJECT_DEPS_CHANGE",A="EVENT_PROJECT_PAGES_CHANGE",y="EVENT_PROJECT_BLOCKS_CHANGE",V="EVENT_PROJECT_APIS_CHANGE",S="EVENT_PROJECT_META_CHANGE",H="EVENT_PROJECT_PUBLISH",L="EVENT_PROJECT_FILE_PUBLISH";class P{id="";name="";description="";homepage="";dependencies=[];pages=[];blocks=[];apis=[];meta=[];currentFile=null;config={};__BASE_PATH__="/";static attrs=["name","homepage","description","dependencies","pages","blocks","apis","meta","config","__BASE_PATH__"];constructor(e){const{id:t}=e;this.id=t||d.uid(),this.update(e,!0)}update(e,t=!1){for(const i of P.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"}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=P.attrs.reduce((s,r)=>(s[r]=this[r],s),{});return i.pages&&(i.pages=i.pages.map(s=>(delete s.dsl,s)),this.cleanPagesDsl(i.pages)),i.blocks&&(i.blocks=i.blocks.map(s=>(delete s.dsl,s))),{__VTJ_PROJECT__:!0,id:t,...i}}active(e,t=!1){this.currentFile=e,t||n.emit(g,{model:this,type:"update",data:e})}deactivate(e=!1){this.currentFile=null,e||n.emit(g,{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(O,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(O,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||d.uid(),e.type="page",e.dir?e.children=[]:e.dsl=e.dsl||new u({id:e.id,name:d.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 d.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=d.uid(),r=`${e.name}Copy`,a=`${e.title}_副本`,c=new u({id:s,name:r}).toDsl(),m=d.merge({},e,{id:s,name:r,title:a,dsl:c}),p=t?this.getPage(t)?.children||[]:this.pages,I=p.findIndex(T=>T.id===e.id);if(p.splice(I+1,0,m),!i){const T={model:this,type:"clone",data:{source:e,target:m}};n.emit(A,T),n.emit(h,T)}}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)m.children&&m.children.length&&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||d.uid(),s=d.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 d.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)}}cloneBlock(e,t=!1){const i=d.uid(),s=`${e.name}Copy`,r=`${e.title}_副本`,a=new u({id:i,name:s}).toDsl(),c=d.merge({},e,{id:i,name:s,title:r,dsl:a}),m=this.blocks.findIndex(p=>p.id===e.id);if(this.blocks.splice(m+1,0,c),!t){const p={model:this,type:"clone",data:{source:e,target:c}};n.emit(y,p),n.emit(h,p)}}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=d.uid(),this.apis.push(e)),!t){const r={model:this,type:s,data:e};n.emit(V,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(V,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=d.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(L,t):n.emit(H,t)}}const C="EVENT_HISTORY_CHANGE",x="EVENT_HISTORY_LOAD";class ${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:d.uid(),label:new Date().toLocaleString(),dsl:d.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=d.mitt();function K(f){return f instanceof u}function Y(f){return f instanceof E}function W(f){return!!f.__VTJ_BLOCK__}function D(f){const e=d.cloneDeep(f);return delete e.id,Array.isArray(e.children)&&(e.children=e.children.map(t=>D(t))),e}function q(f){const e=f.fromType||"Schema";return e==="Schema"?{type:"Schema",id:f.id}:e==="UrlSchema"?{type:"UrlSchema",url:(f.urls||"").split(",")[0]||""}:e==="Plugin"?{type:"Plugin",urls:(f.urls||"").split(","),library:f.library}:""}exports.BUILT_IN_COMPONENTS=U;exports.BUILT_IN_LIBRARAY_MAP=w;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=_;exports.EVENT_BLOCK_CHANGE=o;exports.EVENT_HISTORY_CHANGE=C;exports.EVENT_HISTORY_LOAD=x;exports.EVENT_NODE_CHANGE=l;exports.EVENT_PROJECT_ACTIVED=g;exports.EVENT_PROJECT_APIS_CHANGE=V;exports.EVENT_PROJECT_BLOCKS_CHANGE=y;exports.EVENT_PROJECT_CHANGE=h;exports.EVENT_PROJECT_DEPS_CHANGE=O;exports.EVENT_PROJECT_FILE_PUBLISH=L;exports.EVENT_PROJECT_META_CHANGE=S;exports.EVENT_PROJECT_PAGES_CHANGE=A;exports.EVENT_PROJECT_PUBLISH=H;exports.EventModel=v;exports.HistoryModel=$;exports.NodeModel=E;exports.ProjectModel=P;exports.PropModel=N;exports.Service=M;exports.VTJ_CORE_VERSION=b;exports.cloneDsl=D;exports.createNodeFrom=q;exports.emitter=n;exports.isBlock=K;exports.isBlockSchema=W;exports.isNode=Y;
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { uid as m, timestamp as
|
|
1
|
+
import { uid as m, timestamp as G, isString as A, upperFirstCamelCase as I, delay as V, merge as S, cloneDeep as b, mitt as F } 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.
|
|
6
|
+
* @version 0.9.0-alpha.0
|
|
7
7
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const M = "0.9.0-alpha.0", K = "BuiltIn", w = "VueMaterial", H = "VueRouterMaterial", Y = [w, H], W = {
|
|
10
10
|
vue: "Vue",
|
|
11
11
|
"vue-router": "VueRouter"
|
|
12
12
|
}, q = {
|
|
13
|
-
[
|
|
13
|
+
[w]: [
|
|
14
14
|
"Transition",
|
|
15
15
|
"TransitionGroup",
|
|
16
16
|
"KeepAlive",
|
|
@@ -135,24 +135,24 @@ 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: l, id: f } = t;
|
|
139
139
|
return {
|
|
140
140
|
id: f,
|
|
141
141
|
name: i,
|
|
142
142
|
arg: s,
|
|
143
143
|
modifiers: r,
|
|
144
144
|
value: a,
|
|
145
|
-
iterator:
|
|
145
|
+
iterator: l
|
|
146
146
|
};
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
const d = "EVENT_NODE_CHANGE";
|
|
151
|
-
class
|
|
151
|
+
class _ {
|
|
152
152
|
constructor(e, t = null) {
|
|
153
153
|
this.parent = t;
|
|
154
154
|
const { id: i = m(), name: s, from: r = "" } = e;
|
|
155
|
-
this.id = i, this.name = s, this.from = r, this.update(e, !0),
|
|
155
|
+
this.id = i, this.name = s, this.from = r, this.update(e, !0), _.nodes[this.id] = this;
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* 标记
|
|
@@ -217,11 +217,11 @@ class p {
|
|
|
217
217
|
locked: s = !1,
|
|
218
218
|
children: r = [],
|
|
219
219
|
slot: a,
|
|
220
|
-
props:
|
|
220
|
+
props: l = {},
|
|
221
221
|
events: f = {},
|
|
222
|
-
directives:
|
|
222
|
+
directives: p = []
|
|
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(l), this.events = y.parse(f), this.directives = v.parse(p), t || n.emit(d, this);
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
227
|
* 设置子节点
|
|
@@ -229,7 +229,7 @@ class p {
|
|
|
229
229
|
* @param silent
|
|
230
230
|
*/
|
|
231
231
|
setChildren(e = "", t = !1) {
|
|
232
|
-
Array.isArray(e) ? this.children = e.map((i) => new
|
|
232
|
+
Array.isArray(e) ? this.children = e.map((i) => new _(i, this)) : this.children = e, t || n.emit(d, this);
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* 设置节点放置的插槽
|
|
@@ -387,11 +387,11 @@ class p {
|
|
|
387
387
|
invisible: s,
|
|
388
388
|
locked: r,
|
|
389
389
|
slot: a,
|
|
390
|
-
children:
|
|
390
|
+
children: l,
|
|
391
391
|
props: f,
|
|
392
|
-
directives:
|
|
393
|
-
events:
|
|
394
|
-
} = this, E = Array.isArray(
|
|
392
|
+
directives: p,
|
|
393
|
+
events: C
|
|
394
|
+
} = this, E = Array.isArray(l) ? l.map((J) => J.toDsl()) : l;
|
|
395
395
|
return {
|
|
396
396
|
id: e,
|
|
397
397
|
name: t,
|
|
@@ -401,8 +401,8 @@ class p {
|
|
|
401
401
|
slot: a,
|
|
402
402
|
children: E,
|
|
403
403
|
props: x.toDsl(f),
|
|
404
|
-
directives: v.toDsl(
|
|
405
|
-
events: y.toDsl(
|
|
404
|
+
directives: v.toDsl(p),
|
|
405
|
+
events: y.toDsl(C)
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
@@ -412,7 +412,7 @@ class p {
|
|
|
412
412
|
*/
|
|
413
413
|
dispose(e = !1) {
|
|
414
414
|
const { children: t, disposed: i } = this;
|
|
415
|
-
i || (Array.isArray(t) && t.forEach((s) => s.dispose(!0)), this.parent ? this.parent.removeChild(this, e) : e || n.emit(d, this), this.parent = null, this.disposed = !0, delete
|
|
415
|
+
i || (Array.isArray(t) && t.forEach((s) => s.dispose(!0)), this.parent ? this.parent.removeChild(this, e) : e || n.emit(d, this), this.parent = null, this.disposed = !0, delete _.nodes[this.id]);
|
|
416
416
|
}
|
|
417
417
|
lock(e = !1) {
|
|
418
418
|
if (this.locked = !0, Array.isArray(this.children))
|
|
@@ -477,7 +477,8 @@ class u {
|
|
|
477
477
|
"props",
|
|
478
478
|
"emits",
|
|
479
479
|
"slots",
|
|
480
|
-
"dataSources"
|
|
480
|
+
"dataSources",
|
|
481
|
+
"__TEMPLATE_ID__"
|
|
481
482
|
];
|
|
482
483
|
constructor(e) {
|
|
483
484
|
const { id: t } = e;
|
|
@@ -489,7 +490,7 @@ class u {
|
|
|
489
490
|
r && (this[s] = r);
|
|
490
491
|
}
|
|
491
492
|
const { nodes: i = [] } = e;
|
|
492
|
-
i.length && (this.nodes = i.map((s) => new
|
|
493
|
+
i.length && (this.nodes = i.map((s) => new _(s))), t || n.emit(o, this);
|
|
493
494
|
}
|
|
494
495
|
/**
|
|
495
496
|
* 获取DSL
|
|
@@ -499,11 +500,11 @@ class u {
|
|
|
499
500
|
const { __VTJ_BLOCK__: t, id: i, nodes: s } = this;
|
|
500
501
|
return {
|
|
501
502
|
...u.normalAttrs.reduce(
|
|
502
|
-
(a,
|
|
503
|
+
(a, l) => (a[l] = this[l], a),
|
|
503
504
|
{}
|
|
504
505
|
),
|
|
505
506
|
__VTJ_BLOCK__: t,
|
|
506
|
-
__VERSION__: e ||
|
|
507
|
+
__VERSION__: e || G().toString(),
|
|
507
508
|
id: i,
|
|
508
509
|
nodes: s.map((a) => a.toDsl())
|
|
509
510
|
};
|
|
@@ -755,7 +756,7 @@ class u {
|
|
|
755
756
|
* @returns
|
|
756
757
|
*/
|
|
757
758
|
cloneNode(e, t = !1) {
|
|
758
|
-
const i =
|
|
759
|
+
const i = L(e.toDsl()), s = new _(i);
|
|
759
760
|
return this.addNode(s, e, "bottom", t), s;
|
|
760
761
|
}
|
|
761
762
|
lock(e = !1) {
|
|
@@ -781,7 +782,7 @@ class u {
|
|
|
781
782
|
return t;
|
|
782
783
|
}
|
|
783
784
|
}
|
|
784
|
-
const
|
|
785
|
+
const c = "EVENT_PROJECT_CHANGE", R = "EVENT_PROJECT_ACTIVED", D = "EVENT_PROJECT_DEPS_CHANGE", T = "EVENT_PROJECT_PAGES_CHANGE", g = "EVENT_PROJECT_BLOCKS_CHANGE", k = "EVENT_PROJECT_APIS_CHANGE", B = "EVENT_PROJECT_META_CHANGE", U = "EVENT_PROJECT_PUBLISH", j = "EVENT_PROJECT_FILE_PUBLISH";
|
|
785
786
|
class O {
|
|
786
787
|
id = "";
|
|
787
788
|
name = "";
|
|
@@ -816,7 +817,7 @@ class O {
|
|
|
816
817
|
const s = e[i];
|
|
817
818
|
s && (this[i] = s);
|
|
818
819
|
}
|
|
819
|
-
t || n.emit(
|
|
820
|
+
t || n.emit(c, {
|
|
820
821
|
model: this,
|
|
821
822
|
type: "update",
|
|
822
823
|
data: e
|
|
@@ -847,7 +848,7 @@ class O {
|
|
|
847
848
|
* @param silent
|
|
848
849
|
*/
|
|
849
850
|
active(e, t = !1) {
|
|
850
|
-
this.currentFile = e, t || n.emit(
|
|
851
|
+
this.currentFile = e, t || n.emit(R, {
|
|
851
852
|
model: this,
|
|
852
853
|
type: "update",
|
|
853
854
|
data: e
|
|
@@ -858,7 +859,7 @@ class O {
|
|
|
858
859
|
* @param silent
|
|
859
860
|
*/
|
|
860
861
|
deactivate(e = !1) {
|
|
861
|
-
this.currentFile = null, e || n.emit(
|
|
862
|
+
this.currentFile = null, e || n.emit(R, {
|
|
862
863
|
model: this,
|
|
863
864
|
type: "update",
|
|
864
865
|
data: null
|
|
@@ -881,7 +882,7 @@ class O {
|
|
|
881
882
|
type: r,
|
|
882
883
|
data: e
|
|
883
884
|
};
|
|
884
|
-
n.emit(
|
|
885
|
+
n.emit(D, a), n.emit(c, a);
|
|
885
886
|
}
|
|
886
887
|
}
|
|
887
888
|
/**
|
|
@@ -897,7 +898,7 @@ class O {
|
|
|
897
898
|
type: "delete",
|
|
898
899
|
data: e
|
|
899
900
|
};
|
|
900
|
-
n.emit(
|
|
901
|
+
n.emit(D, r), n.emit(c, r);
|
|
901
902
|
}
|
|
902
903
|
}
|
|
903
904
|
/**
|
|
@@ -953,7 +954,7 @@ class O {
|
|
|
953
954
|
type: "create",
|
|
954
955
|
data: e
|
|
955
956
|
};
|
|
956
|
-
n.emit(T, s), n.emit(
|
|
957
|
+
n.emit(T, s), n.emit(c, s);
|
|
957
958
|
}
|
|
958
959
|
!this.currentFile && !e.dir && (await V(1e3), this.active(e, i));
|
|
959
960
|
}
|
|
@@ -970,7 +971,7 @@ class O {
|
|
|
970
971
|
type: "update",
|
|
971
972
|
data: e
|
|
972
973
|
};
|
|
973
|
-
n.emit(T, s), n.emit(
|
|
974
|
+
n.emit(T, s), n.emit(c, s);
|
|
974
975
|
}
|
|
975
976
|
}
|
|
976
977
|
/**
|
|
@@ -980,20 +981,20 @@ class O {
|
|
|
980
981
|
* @param silent
|
|
981
982
|
*/
|
|
982
983
|
clonePage(e, t, i = !1) {
|
|
983
|
-
const s = m(), r = `${e.name}Copy`, a = `${e.title}_副本`,
|
|
984
|
+
const s = m(), r = `${e.name}Copy`, a = `${e.title}_副本`, l = new u({
|
|
984
985
|
id: s,
|
|
985
986
|
name: r
|
|
986
|
-
}).toDsl(), f =
|
|
987
|
-
if (
|
|
987
|
+
}).toDsl(), f = S({}, e, { id: s, name: r, title: a, dsl: l }), p = t ? this.getPage(t)?.children || [] : this.pages, C = p.findIndex((E) => E.id === e.id);
|
|
988
|
+
if (p.splice(C + 1, 0, f), !i) {
|
|
988
989
|
const E = {
|
|
989
990
|
model: this,
|
|
990
991
|
type: "clone",
|
|
991
992
|
data: {
|
|
992
|
-
|
|
993
|
-
|
|
993
|
+
source: e,
|
|
994
|
+
target: f
|
|
994
995
|
}
|
|
995
996
|
};
|
|
996
|
-
n.emit(T, E), n.emit(
|
|
997
|
+
n.emit(T, E), n.emit(c, E);
|
|
997
998
|
}
|
|
998
999
|
}
|
|
999
1000
|
/**
|
|
@@ -1003,9 +1004,9 @@ class O {
|
|
|
1003
1004
|
*/
|
|
1004
1005
|
removePage(e, t = !1) {
|
|
1005
1006
|
const i = this.getPage(e), s = (r, a) => {
|
|
1006
|
-
const
|
|
1007
|
-
if (
|
|
1008
|
-
a.splice(
|
|
1007
|
+
const l = a.findIndex((f) => f.id === r);
|
|
1008
|
+
if (l >= 0) {
|
|
1009
|
+
a.splice(l, 1);
|
|
1009
1010
|
return;
|
|
1010
1011
|
}
|
|
1011
1012
|
for (const f of a)
|
|
@@ -1017,7 +1018,7 @@ class O {
|
|
|
1017
1018
|
type: "delete",
|
|
1018
1019
|
data: i
|
|
1019
1020
|
};
|
|
1020
|
-
n.emit(T, r), n.emit(
|
|
1021
|
+
n.emit(T, r), n.emit(c, r);
|
|
1021
1022
|
}
|
|
1022
1023
|
}
|
|
1023
1024
|
/**
|
|
@@ -1043,7 +1044,7 @@ class O {
|
|
|
1043
1044
|
type: "create",
|
|
1044
1045
|
data: e
|
|
1045
1046
|
};
|
|
1046
|
-
n.emit(
|
|
1047
|
+
n.emit(g, a), n.emit(c, a);
|
|
1047
1048
|
}
|
|
1048
1049
|
!this.currentFile && r === "Schema" && (await V(1e3), this.active(e, t));
|
|
1049
1050
|
}
|
|
@@ -1060,7 +1061,24 @@ class O {
|
|
|
1060
1061
|
type: "update",
|
|
1061
1062
|
data: e
|
|
1062
1063
|
};
|
|
1063
|
-
n.emit(
|
|
1064
|
+
n.emit(g, s), n.emit(c, s);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
cloneBlock(e, t = !1) {
|
|
1068
|
+
const i = m(), s = `${e.name}Copy`, r = `${e.title}_副本`, a = new u({
|
|
1069
|
+
id: i,
|
|
1070
|
+
name: s
|
|
1071
|
+
}).toDsl(), l = S({}, e, { id: i, name: s, title: r, dsl: a }), f = this.blocks.findIndex((p) => p.id === e.id);
|
|
1072
|
+
if (this.blocks.splice(f + 1, 0, l), !t) {
|
|
1073
|
+
const p = {
|
|
1074
|
+
model: this,
|
|
1075
|
+
type: "clone",
|
|
1076
|
+
data: {
|
|
1077
|
+
source: e,
|
|
1078
|
+
target: l
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
n.emit(g, p), n.emit(c, p);
|
|
1064
1082
|
}
|
|
1065
1083
|
}
|
|
1066
1084
|
/**
|
|
@@ -1076,7 +1094,7 @@ class O {
|
|
|
1076
1094
|
type: "delete",
|
|
1077
1095
|
data: i
|
|
1078
1096
|
};
|
|
1079
|
-
n.emit(
|
|
1097
|
+
n.emit(g, a), n.emit(c, a);
|
|
1080
1098
|
}
|
|
1081
1099
|
}
|
|
1082
1100
|
/**
|
|
@@ -1113,7 +1131,7 @@ class O {
|
|
|
1113
1131
|
type: s,
|
|
1114
1132
|
data: e
|
|
1115
1133
|
};
|
|
1116
|
-
n.emit(k, r), n.emit(
|
|
1134
|
+
n.emit(k, r), n.emit(c, r);
|
|
1117
1135
|
}
|
|
1118
1136
|
}
|
|
1119
1137
|
/**
|
|
@@ -1129,7 +1147,7 @@ class O {
|
|
|
1129
1147
|
type: "delete",
|
|
1130
1148
|
data: e
|
|
1131
1149
|
};
|
|
1132
|
-
n.emit(k, s), n.emit(
|
|
1150
|
+
n.emit(k, s), n.emit(c, s);
|
|
1133
1151
|
}
|
|
1134
1152
|
}
|
|
1135
1153
|
existApiName(e, t = []) {
|
|
@@ -1146,7 +1164,7 @@ class O {
|
|
|
1146
1164
|
type: s,
|
|
1147
1165
|
data: e
|
|
1148
1166
|
};
|
|
1149
|
-
n.emit(
|
|
1167
|
+
n.emit(B, r), n.emit(c, r);
|
|
1150
1168
|
}
|
|
1151
1169
|
}
|
|
1152
1170
|
removeMeta(e, t = !1) {
|
|
@@ -1157,7 +1175,7 @@ class O {
|
|
|
1157
1175
|
type: "delete",
|
|
1158
1176
|
data: e
|
|
1159
1177
|
};
|
|
1160
|
-
n.emit(
|
|
1178
|
+
n.emit(B, s), n.emit(c, s);
|
|
1161
1179
|
}
|
|
1162
1180
|
}
|
|
1163
1181
|
existMetaCode(e, t = []) {
|
|
@@ -1170,7 +1188,7 @@ class O {
|
|
|
1170
1188
|
type: "update",
|
|
1171
1189
|
data: e
|
|
1172
1190
|
};
|
|
1173
|
-
n.emit(
|
|
1191
|
+
n.emit(c, i);
|
|
1174
1192
|
}
|
|
1175
1193
|
}
|
|
1176
1194
|
setConfig(e, t = !1) {
|
|
@@ -1180,7 +1198,7 @@ class O {
|
|
|
1180
1198
|
type: "update",
|
|
1181
1199
|
data: e
|
|
1182
1200
|
};
|
|
1183
|
-
n.emit(
|
|
1201
|
+
n.emit(c, i);
|
|
1184
1202
|
}
|
|
1185
1203
|
}
|
|
1186
1204
|
publish(e) {
|
|
@@ -1227,7 +1245,7 @@ class Z {
|
|
|
1227
1245
|
const { max: i } = this.options, s = {
|
|
1228
1246
|
id: m(),
|
|
1229
1247
|
label: (/* @__PURE__ */ new Date()).toLocaleString(),
|
|
1230
|
-
dsl:
|
|
1248
|
+
dsl: b(e)
|
|
1231
1249
|
};
|
|
1232
1250
|
if (this.items.unshift(s), this.items.length > i) {
|
|
1233
1251
|
const r = this.items.splice(i);
|
|
@@ -1297,40 +1315,40 @@ class Z {
|
|
|
1297
1315
|
}
|
|
1298
1316
|
}
|
|
1299
1317
|
const n = F();
|
|
1300
|
-
function ee(
|
|
1301
|
-
return
|
|
1318
|
+
function ee(h) {
|
|
1319
|
+
return h instanceof u;
|
|
1302
1320
|
}
|
|
1303
|
-
function te(
|
|
1304
|
-
return
|
|
1321
|
+
function te(h) {
|
|
1322
|
+
return h instanceof _;
|
|
1305
1323
|
}
|
|
1306
|
-
function ie(
|
|
1307
|
-
return !!
|
|
1324
|
+
function ie(h) {
|
|
1325
|
+
return !!h.__VTJ_BLOCK__;
|
|
1308
1326
|
}
|
|
1309
|
-
function
|
|
1310
|
-
const e =
|
|
1311
|
-
return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) =>
|
|
1327
|
+
function L(h) {
|
|
1328
|
+
const e = b(h);
|
|
1329
|
+
return delete e.id, Array.isArray(e.children) && (e.children = e.children.map((t) => L(t))), e;
|
|
1312
1330
|
}
|
|
1313
|
-
function se(
|
|
1314
|
-
const e =
|
|
1331
|
+
function se(h) {
|
|
1332
|
+
const e = h.fromType || "Schema";
|
|
1315
1333
|
return e === "Schema" ? {
|
|
1316
1334
|
type: "Schema",
|
|
1317
|
-
id:
|
|
1335
|
+
id: h.id
|
|
1318
1336
|
} : e === "UrlSchema" ? {
|
|
1319
1337
|
type: "UrlSchema",
|
|
1320
|
-
url: (
|
|
1338
|
+
url: (h.urls || "").split(",")[0] || ""
|
|
1321
1339
|
} : e === "Plugin" ? {
|
|
1322
1340
|
type: "Plugin",
|
|
1323
|
-
urls: (
|
|
1324
|
-
library:
|
|
1341
|
+
urls: (h.urls || "").split(","),
|
|
1342
|
+
library: h.library
|
|
1325
1343
|
} : "";
|
|
1326
1344
|
}
|
|
1327
1345
|
export {
|
|
1328
1346
|
q as BUILT_IN_COMPONENTS,
|
|
1329
1347
|
W as BUILT_IN_LIBRARAY_MAP,
|
|
1330
1348
|
Y as BUILT_IN_MATERIALS,
|
|
1331
|
-
|
|
1349
|
+
K as BUILT_IN_NAME,
|
|
1332
1350
|
z as BUILT_IN_TAGS,
|
|
1333
|
-
|
|
1351
|
+
w as BUILT_IN_VUE,
|
|
1334
1352
|
H as BUILT_IN_VUE_ROUTER,
|
|
1335
1353
|
X as Base,
|
|
1336
1354
|
u as BlockModel,
|
|
@@ -1339,23 +1357,23 @@ export {
|
|
|
1339
1357
|
N as EVENT_HISTORY_CHANGE,
|
|
1340
1358
|
P as EVENT_HISTORY_LOAD,
|
|
1341
1359
|
d as EVENT_NODE_CHANGE,
|
|
1342
|
-
|
|
1360
|
+
R as EVENT_PROJECT_ACTIVED,
|
|
1343
1361
|
k as EVENT_PROJECT_APIS_CHANGE,
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1362
|
+
g as EVENT_PROJECT_BLOCKS_CHANGE,
|
|
1363
|
+
c as EVENT_PROJECT_CHANGE,
|
|
1364
|
+
D as EVENT_PROJECT_DEPS_CHANGE,
|
|
1347
1365
|
j as EVENT_PROJECT_FILE_PUBLISH,
|
|
1348
|
-
|
|
1366
|
+
B as EVENT_PROJECT_META_CHANGE,
|
|
1349
1367
|
T as EVENT_PROJECT_PAGES_CHANGE,
|
|
1350
1368
|
U as EVENT_PROJECT_PUBLISH,
|
|
1351
1369
|
y as EventModel,
|
|
1352
1370
|
Z as HistoryModel,
|
|
1353
|
-
|
|
1371
|
+
_ as NodeModel,
|
|
1354
1372
|
O as ProjectModel,
|
|
1355
1373
|
x as PropModel,
|
|
1356
1374
|
Q as Service,
|
|
1357
|
-
|
|
1358
|
-
|
|
1375
|
+
M as VTJ_CORE_VERSION,
|
|
1376
|
+
L as cloneDsl,
|
|
1359
1377
|
se as createNodeFrom,
|
|
1360
1378
|
n as emitter,
|
|
1361
1379
|
ee as isBlock,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0-alpha.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@vtj/base": "~0.
|
|
7
|
+
"@vtj/base": "~0.9.0-alpha.0"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@vtj/cli": "~0.
|
|
10
|
+
"@vtj/cli": "~0.9.0-alpha.0"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
@@ -11,11 +11,7 @@ export interface MarketInstallInfo {
|
|
|
11
11
|
/**
|
|
12
12
|
* 安装版本号
|
|
13
13
|
*/
|
|
14
|
-
version
|
|
15
|
-
/**
|
|
16
|
-
* 物料主页 url
|
|
17
|
-
*/
|
|
18
|
-
url: string;
|
|
14
|
+
version?: string;
|
|
19
15
|
}
|
|
20
16
|
export interface BlockFile {
|
|
21
17
|
/**
|
|
@@ -94,4 +90,12 @@ export interface PageFile extends BlockFile {
|
|
|
94
90
|
* 源码文件,非低代码页面
|
|
95
91
|
*/
|
|
96
92
|
raw?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* 纯净的页面
|
|
95
|
+
*/
|
|
96
|
+
pure?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 路由元信息
|
|
99
|
+
*/
|
|
100
|
+
meta?: Record<string, any>;
|
|
97
101
|
}
|
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.172
|
|
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.172";
|