@chamn/engine 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -137,7 +137,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
137
137
|
data struct format is invalidate`);return o.message||n?console.warn(`${o.message||n}
|
|
138
138
|
originData: ${JSON.stringify(t)}`):console.warn(`${JSON.stringify(t)}
|
|
139
139
|
data struct format is invalidate`),o},Fw=e=>{const{data:t,message:n,throwError:r,dataStruct:o}=e;return Iie(({data:i})=>{try{return CL(i,o),{isValidate:!0}}catch(a){let s=a;return a instanceof SL&&(s=a.failures().map(l=>`【${l.path.join(".")}】: ${l.message}
|
|
140
|
-
`)),{isValidate:!1,message:s,error:a}}})({data:t,message:n,throwError:r})};var Cs=(e=>(e.ROOT_CONTAINER="RootContainer",e))(Cs||{});const Lie=Xe({type:Dn(_n.FUNCTION),value:ce()}),$ie=Lw(_L(Ya,["componentName"]),Xe({componentName:Dn("RootContainer")}));function Die(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(o){o(n)}),(r=e.get("*"))&&r.slice().map(function(o){o(t,n)})}}}const Sc=Die(),zie=(e,t)=>{const n={...e,value:[]},r=e.value;let o=new Qa([]);return t&&(o=t.materialsMode||new Qa([])),r&&(Tt(r)?n.value=r.map(i=>new Rt(i,{parent:t,materials:o})):On(r)&&n.value.push(new Rt(r,{parent:t,materials:o}))),n};class Ja{constructor(t,n){Ne(this,"nodeType","SLOT"),Ne(this,"rawData"),Ne(this,"parent"),Ne(this,"emitter",Sc),Ne(this,"data"),Ne(this,"id"),Ne(this,"materialsMode"),this.parent=(n==null?void 0:n.parent)||null,this.rawData=t;const r=(n==null?void 0:n.materials)||new Qa([]);this.materialsMode=r,this.id=ro(),this.data=zie(t,this)}get value(){return this.data}export(t){const n=this.data,r=o=>{if(o instanceof Rt)return o.export(t);if(On(o)){const i={};return Object.keys(o||{}).forEach(a=>{i[a]=r(o[a])}),i}return Tt(o)?o.map(i=>r(i)):(t==="design"&&delete o.id,o)};return r(n)}}const RL=e=>{let t=[];return e.forEach(n=>{const r=n;r.type?r.type===fb.SINGLE?t.push(r.content):r.type===fb.GROUP&&(t=[...t,...RL(r.content)]):t.push(n)}),t},hb=(e,t,n)=>{if(e.type)return e.type===_n.SLOT?new Ja(e,{parent:t,materials:n}):e;if(On(e)){const r={};return Object.keys(e).forEach(o=>{r[o]=pb(e[o],t,n)}),r}else return Array.isArray(e)?e.map(r=>hb(r,t,n)):e},pb=(e,t,n)=>On(e)?hb(e,t,n):Tt(e)?e.map(r=>hb(r,t,n)):e;class ti{constructor(t,n,r){Ne(this,"nodeType","PROP"),Ne(this,"rawData"),Ne(this,"parent"),Ne(this,"emitter",Sc),Ne(this,"data"),Ne(this,"name"),Ne(this,"materialsMode");const o=(r==null?void 0:r.materials)||new Qa([]);this.materialsMode=o,this.parent=r==null?void 0:r.parent,this.rawData=n,this.name=t,this.data=pb(n,this,o)}isIncludeSlot(){return!1}isIncludeExpression(){return!1}get value(){return this.data}updateValue(t){const n=this.data;this.data=pb(t??n,this,this.materialsMode),this.emitter.emit("onPropChange",{value:this.data,preValue:n,node:this}),this.parent&&!(this.parent instanceof Ja)&&this.emitter.emit("onNodeChange",{value:this.parent.value,preValue:this.parent.value,node:this.parent})}get material(){const t=this.parent;if(t instanceof Rt){const n=t.material;return RL((n==null?void 0:n.value.props)||[]).find(r=>r.name===this.name)}else return null}export(t){const n=this.data,r=o=>{if(o instanceof ti||o instanceof Ja||o instanceof Rt)return o.export(t);if(Tt(o))return o.map(i=>r(i));if(On(o)){const i={};return Object.keys(o||{}).forEach(a=>{i[a]=r(o[a])}),i}return o};return r(n)}}const Fie=e=>{if(typeof e=="string")return!0;Fw({data:e,dataStruct:Ya,throwError:!1})},ME=(e,t,n)=>{if(typeof e=="string")return e;const r={...e,id:e.id??ro(),children:[],props:{},methods:e.methods||[],configure:xL(e.configure||{},{propsSetter:{},advanceSetter:{}})},o=Object.keys(e.props||{});return o.length&&o.forEach(i=>{var a;const s=(a=e.props)==null?void 0:a[i];if(s instanceof ti){r.props[i]=s;return}r.props[i]=new ti(i,s||"",{parent:t,materials:n})}),e.children&&(Array.isArray(e.children)?r.children=e.children.map(i=>{if(i instanceof Rt)return i;if(On(i)){const a=i;return new Rt(a,{parent:t,materials:n})}else return i}):(e.children instanceof Rt&&(r.children=[e.children]),r.children=[new Rt(e.children,{parent:t,materials:n})])),r};let Rt=class gb{constructor(t,n){Ne(this,"nodeType","NODE"),Ne(this,"rawData"),Ne(this,"data"),Ne(this,"emitter",Sc),Ne(this,"parent"),Ne(this,"materialsModel"),Ne(this,"listenerHandle"),Ne(this,"onChangeCbQueue"),this.rawData=JSON.parse(JSON.stringify(t)),Fie(t);const r=(n==null?void 0:n.materials)||new Qa([]);this.parent=(n==null?void 0:n.parent)||null,this.materialsModel=r,this.data=ME(t,this,r),this.listenerHandle=[],this.onChangeCbQueue=[],this.registerListener()}registerListener(){const t=n=>{const{node:r}=n;r===this&&r.id===this.id&&this.onChangeCbQueue.forEach(o=>o(n))};this.emitter.on("onNodeChange",t),this.listenerHandle.push(()=>{this.emitter.off("onNodeChange",t)})}onChange(t){return this.onChangeCbQueue.push(t),()=>{this.onChangeCbQueue=this.onChangeCbQueue.filter(n=>n!==t)}}destroy(){this.listenerHandle.forEach(t=>t())}get id(){return this.data.id}get value(){return this.data}clone(t){const n={...this.export("design"),id:t||ro()};return new gb(n,{materials:this.materialsModel})}updateWithPlainObj(t){const n={...this.data,...t};return this.data=ME(n,this,this.materialsModel),n}updateValue(t){const n=this.data,r=this.updateWithPlainObj(t);this.emitter.emit("onNodeChange",{value:r,preValue:n,node:this})}contains(t){return Vw(this,t)}get props(){return this.data.props}get material(){const t=this.materialsModel;return t==null?void 0:t.findByComponentName(this.data.componentName)}getPlainProps(){const t=this.data,n={};return Object.keys(t.props||{}).forEach(r=>{n[r]=t.props[r].export("design")}),n}getMaterialConfig(t){var n;return this.data.configure[t]!==void 0?this.data.configure.isContainer:(n=this.material)==null?void 0:n.value.isContainer}isContainer(){return this.getMaterialConfig("isContainer")}export(t){var n;const r=this.data;if(typeof r=="string")return r;const o={};Object.keys(r.props||{}).forEach(d=>{o[d]=r.props[d].export(t)});const i=(n=r.children)==null?void 0:n.map(d=>d instanceof gb?d.export(t):d),a=r.configure||{},s=a.propsSetter||{},l={};Object.keys(s).forEach(d=>{const f=eL(s,d,!1);f&&(l[d]=f)}),a.propsSetter=l;const c=this.materialsModel.usedMaterials.find(d=>{var f;return d.componentName===((f=this.material)==null?void 0:f.componentName)});this.material&&!c&&this.materialsModel.usedMaterials.push(this.material);let u={...r,configure:a,props:o,children:i,condition:r.condition};return t==="design"&&delete u.id,u=Bw(u),u}};const PE=(e,t,n)=>{const r={...e,id:ro(),props:{},componentName:Cs.ROOT_CONTAINER,children:[],methods:e.methods||[],configure:xL(e.configure||{},{propsSetter:{},advanceSetter:{}}),injectEnvList:e.injectEnvList};let o=[];Tt(e.children)?o=e.children.map(a=>a instanceof Rt?a:On(a)?new Rt(a,{parent:t,materials:n}):a):e.children instanceof Rt?o.push(e.children):e.children&&On(e.children)&&o.push(new Rt(e.children,{parent:t,materials:n}));const i=Object.keys(e.props||{});return i.length&&i.forEach(a=>{var s;const l=(s=e.props)==null?void 0:s[a];l instanceof ti?r.props[a]=l:r.props[a]=new ti(a,l||"",{parent:t,materials:n})}),r.children=o,r};class Kl{constructor(t,{parent:n,materials:r}){Ne(this,"rawData"),Ne(this,"data"),Ne(this,"nodeType",Cs.ROOT_CONTAINER),Ne(this,"emitter",Sc),Ne(this,"materialsModel"),Ne(this,"listenerHandle"),Ne(this,"onChangeCbQueue"),Ne(this,"parent"),this.materialsModel=r,this.rawData=JSON.parse(JSON.stringify(t)),this.data=PE(t,this,r),this.listenerHandle=[],this.onChangeCbQueue=[],this.registerListener(),this.parent=n}registerListener(){const t=n=>{const{node:r}=n;r===this&&r.id===this.id&&this.onChangeCbQueue.forEach(o=>o(n))};this.emitter.on("onNodeChange",t),this.listenerHandle.push(()=>{this.emitter.off("onNodeChange",t)})}onChange(t){return this.onChangeCbQueue.push(t),()=>{this.onChangeCbQueue=this.onChangeCbQueue.filter(n=>n!==t)}}get id(){return this.data.id}get value(){return this.data}get props(){return this.data.props}get material(){const t=this.materialsModel;return t==null?void 0:t.findByComponentName(this.data.componentName)}updateWithPlainObj(t){const n={...this.data,...t};return this.data=PE(n,this,this.materialsModel),n}updateValue(t){const n=this.data;this.updateWithPlainObj(t),this.emitter.emit("onNodeChange",{value:this.data,preValue:n,node:this})}contains(t){return Vw(this,t)}getMaterialConfig(t){var n;return this.data.configure[t]!==void 0?this.data.configure.isContainer:(n=this.material)==null?void 0:n.value.isContainer}isContainer(){return this.getMaterialConfig("isContainer")}export(t=Dw.SAVE){var n;const r=this.data,o={};Object.keys(r.props||{}).forEach(l=>{o[l]=r.props[l].export(t)});const i=((n=r.children)==null?void 0:n.map(l=>{var c;return(c=l==null?void 0:l.export)==null?void 0:c.call(l,t)}))||[],a={...r,props:o,children:i.filter(l=>l),condition:r.condition};let s=wL(a,["id"]);return s=Bw(s),s}getPlainProps(){const t=this.data,n={};return Object.keys(t.props||{}).forEach(r=>{n[r]=t.props[r].export("design")}),n}destroy(){this.listenerHandle.forEach(t=>t())}clone(t){const n={...this.export("design"),id:t||ro()};return new Kl(n,{materials:this.materialsModel,parent:null})}}const pi=e=>(e==null?void 0:e.type)===_n.EXPRESSION,TL=e=>(e==null?void 0:e.type)===_n.FUNCTION,Bie=e=>(e==null?void 0:e.type)===_n.ACTION,ro=()=>Math.random().toString(32).slice(3,9),Vie=e=>(e==null?void 0:e.nodeType)==="NODE",mb=e=>(e==null?void 0:e.nodeType)==="PROP",Hie=e=>(e==null?void 0:e.nodeType)==="SLOT",Bw=e=>fie(e,t=>On(t)?!Object.keys(t).length:Tt(t)?!t.length:!t);function qie(e,t){const n=[e];for(;n.length;){const r=n.shift();if(r&&t(r))return r;const o=(r==null?void 0:r.props)||{},i=s=>{if(s instanceof Rt){n.push(s);return}if(s instanceof Ja&&i(s.value.value),s instanceof ti){i(s.value);return}if(On(s)){const l=s;Object.keys(l).forEach(c=>{i(l[c])});return}if(Tt(s)){s.forEach(l=>{i(l)});return}};i(o);const a=(r==null?void 0:r.value.children.filter(s=>s instanceof Rt))||[];n.push(...a)}}function Vw(e,t){return qie(e,n=>n.id===t)}const Uie=e=>{const t=hL(e),n=t.snippets;return delete t.snippets,t.snippets=n.map(r=>({...t,...r,id:r.id||`${e.componentName}-${ro()}`,title:r.title||e.title,category:r.category||e.category,tags:[...r.tags||[],...e.tags||[]],groupName:r.groupName||e.groupName,snapshot:r.snapshot||e.icon,snapshotText:r.snapshotText,schema:{...r.schema,componentName:r.schema.componentName||e.componentName}})),t};class Gie{constructor(t){Ne(this,"rawData"),Ne(this,"data"),this.rawData=t,this.data=Uie(t)}get value(){return this.data}get rawValue(){return this.rawData}get componentName(){return this.data.componentName}get snippets(){return this.data.snippets}getSnippetById(t){return this.data.snippets.find(n=>n.id===t)}}const _p=e=>{if(!Tt(e))throw new Error("Materials must be a array");return e.map(t=>new Gie(t))},Wie=e=>{e==null||e.forEach(t=>{Fw({data:t,dataStruct:jie,throwError:!1})})};class Qa{constructor(t){Ne(this,"rawData"),Ne(this,"data"),Ne(this,"usedMaterials",[]),this.rawData=t,Wie(t),this.data=_p(t)}addMaterials(t){const n=_p(t),r=[],o=this.data.map(a=>{const s=n.findIndex(l=>l.componentName===a.componentName);return s>=0?(r.push(s),n[s]):a}),i=n.filter((a,s)=>!r.includes(s));this.data=[...o,...i]}replaceMaterials(t){const n=_p(t);this.data=[...n]}removeMaterial(t){const n=this.data.filter(r=>!t.includes(r.componentName));this.data=n}findByComponentName(t){return this.data.find(n=>n.componentName===t)}findSnippetById(t){const n=[...this.data];let r=null;for(;!r&&n.length;){const o=n.pop();r=o==null?void 0:o.getSnippetById(t)}return r}getAllSnippets(){const t=this.data.reduce((i,a)=>(i.push(...a.snippets),i),[]),n=[],r={default:[]};t.forEach(i=>{const a=i.groupName||"default";n.includes(a)||(n.push(a),r[a]=[]),r[a].push(i)});let o=[];return n.forEach(i=>{const a=["default"],s={default:[]},l=r[i];if(l.length!==0){l.forEach(d=>{const f=d.category||"default";a.includes(f)||(a.push(f),s[f]=[]),s[f].push(d)});const c=[];a.forEach(d=>{s[d].length&&c.push({name:d,list:s[d]})});const u={name:i,list:c};o.push(u)}}),o=o.sort((i,a)=>(i.name||"")>(a.name||"")?1:-1),o}get value(){return this.data}get rawValue(){return this.rawData}}const Kie=Xe({version:se(ce()),name:se(ce()),css:se(ce()),lifecycle:se(Ye()),props:se(Ye()),methods:se(ft(Lie)),componentsMeta:ft(Lw(Xe({componentName:ce()}),$w)),thirdLibs:se(kie),componentsTree:$ie,assets:se(ft(Ye())),extra:se(Ye())}),AL=e=>(Fw({data:e,dataStruct:Kie,throwError:!1}),e),Ep=(e,t,n)=>({...e,componentsTree:new Kl(e.componentsTree,{parent:t,materials:n})});let jE=class ML{constructor(t,n){Ne(this,"nodeType","PAGE"),Ne(this,"rawData"),Ne(this,"emitter",Sc),Ne(this,"data"),Ne(this,"parent"),Ne(this,"materialsModel"),Ne(this,"assetPackagesList"),AL(t),this.rawData=JSON.parse(JSON.stringify(t)),this.materialsModel=new Qa((n==null?void 0:n.materials)||[]),this.data=Ep(t,this,this.materialsModel),this.assetPackagesList=[...(n==null?void 0:n.assetPackagesList)||[],...this.data.assets||[]]}updatePage(t){const n=this.data;this.rawData=JSON.parse(JSON.stringify(t)),this.data=Ep(t,this,this.materialsModel),this.emitter.emit("onPageChange",{value:this.data,preValue:n,node:this})}reloadPage(t){const n=this.data;t&&(this.rawData=JSON.parse(JSON.stringify(t)),this.data=Ep(t,this,this.materialsModel)),this.emitter.emit("onReloadPage",{value:this.data,preValue:n,node:this})}get value(){return this.data}getNode(t){if(!t)return;const n=this.data.componentsTree;return Vw(n,t)}addNode(t,n,r="AFTER"){var o;if(r==="AFTER"||r==="BEFORE"){const i=n.parent;if(i===null&&n instanceof Kl)return console.warn("Not found parent node"),!1;if(i instanceof ti)return console.warn("CProp can not add node"),!1;if(i instanceof Ja){const s=i.value.value,l=s.findIndex(c=>c===n)??-1;return l>=0?(r==="BEFORE"?s.splice(l,0,t):s.splice(l+1,0,t),t.parent=i,(o=i.parent)==null||o.updateValue(),!0):!1}if(i instanceof ML)return!1;const a=(i==null?void 0:i.value.children.findIndex(s=>s===n))??-1;return a>=0?(r==="BEFORE"?i==null||i.value.children.splice(a,0,t):i==null||i.value.children.splice(a+1,0,t),t.parent=i,i==null||i.updateValue(),!0):(console.warn("Not found target node"),!1)}if(r==="CHILD_START")return n.value.children.unshift(t),t.parent=n,n.updateValue(),!0;if(r==="CHILD_END")return n.value.children.push(t),t.parent=n,n.updateValue(),!0;if(On(r)){const i=r;if(i.type==="CHILD"){const a=i.pos,s=i.index||0;return a==="BEFORE"?n==null||n.value.children.splice(s,0,t):n==null||n.value.children.splice(s+1,0,t),t.parent=n,n.updateValue(),!0}else console.warn("Can not parse pos obj")}return!1}createNode(t){return delete t.id,new Rt(t,{parent:null,materials:this.materialsModel})}addNodeById(t,n,r="AFTER"){const o=this.getNode(n);return o?this.addNode(t,o,r):(console.warn(`Not find a node by ${n}, pls check it`),!1)}copyNode(t){const n=t.export("design");n.id=ro();const r=new Rt(n,{parent:t.parent,materials:this.materialsModel});return this.addNode(r,t,"AFTER"),r}copyNodeById(t){const n=this.getNode(t);return n&&n instanceof Rt?this.copyNode(n):!1}moveNode(t,n,r){this.deleteNode(t);let o=n;return["AFTER","BEFORE"].includes(r)&&(o=n.parent),t.parent=o,this.addNode(t,n,r)}moveNodeById(t,n,r){const o=this.getNode(t),i=this.getNode(n);return o&&i&&o instanceof Rt&&i instanceof Rt?this.moveNode(o,i,r):!1}deleteNode(t){var n;const r=t.parent;if(!r)throw new Error("parent node is null or undefined, pls check it");if(r instanceof Ja){const o=r.value.value,i=o.findIndex(s=>s===t),a=o[i];return o.splice(i,1),(n=r.parent)==null||n.updateValue(),a}if(r instanceof Rt||r instanceof Kl){const o=r.value.children,i=o.findIndex(s=>s===t),a=o[i];return o.splice(i,1),r.updateValue(),a}}deleteNodeById(t){const n=this.getNode(t);if(n)return this.deleteNode(n)}export(t=Dw.SAVE){var n;const r=this.data.componentsTree.export(t),o=this.assetPackagesList,i=[],a=this.materialsModel.usedMaterials.map(l=>{const c=o.find(u=>{var d;return u.package===((d=l.value.npm)==null?void 0:d.package)});return c&&i.push(c),{componentName:l.componentName,...hL(l.value.npm||{})}}).filter(l=>l.componentName&&l.package&&l.version?!0:(console.warn(`${JSON.stringify(l,null,2)} not a valid material info`),!1));this.materialsModel.usedMaterials=[];let s={...this.data,componentsTree:Bw(r),componentsMeta:a,thirdLibs:this.data.thirdLibs,assets:[]};return(n=this.data.thirdLibs)==null||n.forEach(l=>{const c=o.find(u=>l.package===u.package);c&&i.push(c)}),s.assets=vie(i,l=>l.package),s=wL(s,["id"]),JSON.parse(JSON.stringify(s))}getRootNode(){return this.data.componentsTree}};Cs.ROOT_CONTAINER;const Df="DYNAMIC",Xie=["$$context","$$nodeModel"],Hw="ON_DID_RENDER",qw="ON_WILL_DESTROY",Yie=[Hw,qw],vb=(e,t)=>{let n=e;return t&&(n={...e},n.__proto__=t||null),n},Xl=(e,t={},...n)=>typeof e=="string"||typeof e=="number"?String(e):(Xie.forEach(r=>{r in t&&e.__CP_TYPE__!==Df&&delete t[r]}),v.createElement(e,t,...n)),IE=(e={},t)=>{const n=[],r=(o,i)=>{let a=i;mb(i)&&(a=i.value),t(a)?n.push({keyPath:o,val:a}):Wa(a)?a.forEach((s,l)=>{r([...o,String(l)],s)}):vs(a)&&Object.keys(a).forEach(s=>{r([...o,s],a[s])})};return r(["$root"],e),n},Da=(e,t)=>{const n=e.handler,{context:r,storeManager:o}=t;return t.actionVariableSpace||(t.actionVariableSpace={}),async function(...i){const a={},s=async u=>{const d=u;if(d.type==="RUN_CODE"){const f=Tf({funcName:"",funcBody:`function() {
|
|
140
|
+
`)),{isValidate:!1,message:s,error:a}}})({data:t,message:n,throwError:r})};var Cs=(e=>(e.ROOT_CONTAINER="RootContainer",e))(Cs||{});const Lie=Xe({type:Dn(_n.FUNCTION),value:ce()}),$ie=Lw(_L(Ya,["componentName"]),Xe({componentName:Dn("RootContainer")}));function Die(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(o){o(n)}),(r=e.get("*"))&&r.slice().map(function(o){o(t,n)})}}}const Sc=Die(),zie=(e,t)=>{const n={...e,value:[]},r=e.value;let o=new Qa([]);return t&&(o=t.materialsMode||new Qa([])),r&&(Tt(r)?n.value=r.map(i=>new Rt(i,{parent:t,materials:o})):On(r)&&n.value.push(new Rt(r,{parent:t,materials:o}))),n};class Ja{constructor(t,n){Ne(this,"nodeType","SLOT"),Ne(this,"rawData"),Ne(this,"parent"),Ne(this,"emitter",Sc),Ne(this,"data"),Ne(this,"id"),Ne(this,"materialsMode"),this.parent=(n==null?void 0:n.parent)||null,this.rawData=t;const r=(n==null?void 0:n.materials)||new Qa([]);this.materialsMode=r,this.id=ro(),this.data=zie(t,this)}get value(){return this.data}export(t){const n=this.data,r=o=>{if(o instanceof Rt)return o.export(t);if(On(o)){const i={};return Object.keys(o||{}).forEach(a=>{i[a]=r(o[a])}),i}return Tt(o)?o.map(i=>r(i)):(t==="design"&&delete o.id,o)};return r(n)}}const RL=e=>{let t=[];return e.forEach(n=>{const r=n;r.type?r.type===fb.SINGLE?t.push(r.content):r.type===fb.GROUP&&(t=[...t,...RL(r.content)]):t.push(n)}),t},hb=(e,t,n)=>{if(e.type)return e.type===_n.SLOT?new Ja(e,{parent:t,materials:n}):e;if(On(e)){const r={};return Object.keys(e).forEach(o=>{r[o]=pb(e[o],t,n)}),r}else return Array.isArray(e)?e.map(r=>hb(r,t,n)):e},pb=(e,t,n)=>On(e)?hb(e,t,n):Tt(e)?e.map(r=>hb(r,t,n)):e;class ti{constructor(t,n,r){Ne(this,"nodeType","PROP"),Ne(this,"rawData"),Ne(this,"parent"),Ne(this,"emitter",Sc),Ne(this,"data"),Ne(this,"name"),Ne(this,"materialsMode");const o=(r==null?void 0:r.materials)||new Qa([]);this.materialsMode=o,this.parent=r==null?void 0:r.parent,this.rawData=n,this.name=t,this.data=pb(n,this,o)}isIncludeSlot(){return!1}isIncludeExpression(){return!1}get value(){return this.data}updateValue(t){const n=this.data;this.data=pb(t??n,this,this.materialsMode),this.emitter.emit("onPropChange",{value:this.data,preValue:n,node:this}),this.parent&&!(this.parent instanceof Ja)&&this.emitter.emit("onNodeChange",{value:this.parent.value,preValue:this.parent.value,node:this.parent})}get material(){const t=this.parent;if(t instanceof Rt){const n=t.material;return RL((n==null?void 0:n.value.props)||[]).find(r=>r.name===this.name)}else return null}export(t){const n=this.data,r=o=>{if(o instanceof ti||o instanceof Ja||o instanceof Rt)return o.export(t);if(Tt(o))return o.map(i=>r(i));if(On(o)){const i={};return Object.keys(o||{}).forEach(a=>{i[a]=r(o[a])}),i}return o};return r(n)}}const Fie=e=>{if(typeof e=="string")return!0;Fw({data:e,dataStruct:Ya,throwError:!1})},ME=(e,t,n)=>{if(typeof e=="string")return e;const r={...e,id:e.id??ro(),children:[],props:{},methods:e.methods||[],configure:xL(e.configure||{},{propsSetter:{},advanceSetter:{}})},o=Object.keys(e.props||{});return o.length&&o.forEach(i=>{var a;const s=(a=e.props)==null?void 0:a[i];if(s instanceof ti){r.props[i]=s;return}r.props[i]=new ti(i,s||"",{parent:t,materials:n})}),e.children&&(Array.isArray(e.children)?r.children=e.children.map(i=>{if(i instanceof Rt)return i;if(On(i)){const a=i;return new Rt(a,{parent:t,materials:n})}else return i}):(e.children instanceof Rt&&(r.children=[e.children]),r.children=[new Rt(e.children,{parent:t,materials:n})])),r};let Rt=class gb{constructor(t,n){Ne(this,"nodeType","NODE"),Ne(this,"rawData"),Ne(this,"data"),Ne(this,"emitter",Sc),Ne(this,"parent"),Ne(this,"materialsModel"),Ne(this,"listenerHandle"),Ne(this,"onChangeCbQueue"),this.rawData=JSON.parse(JSON.stringify(t)),Fie(t);const r=(n==null?void 0:n.materials)||new Qa([]);this.parent=(n==null?void 0:n.parent)||null,this.materialsModel=r,this.data=ME(t,this,r),this.listenerHandle=[],this.onChangeCbQueue=[],this.registerListener()}registerListener(){const t=n=>{const{node:r}=n;r===this&&r.id===this.id&&this.onChangeCbQueue.forEach(o=>o(n))};this.emitter.on("onNodeChange",t),this.listenerHandle.push(()=>{this.emitter.off("onNodeChange",t)})}onChange(t){return this.onChangeCbQueue.push(t),()=>{this.onChangeCbQueue=this.onChangeCbQueue.filter(n=>n!==t)}}destroy(){this.listenerHandle.forEach(t=>t())}get id(){return this.data.id}get value(){return this.data}clone(t){const n={...this.export("design"),id:t||ro()};return new gb(n,{materials:this.materialsModel})}updateWithPlainObj(t){const n={...this.data,...t};return this.data=ME(n,this,this.materialsModel),n}updateValue(t){const n=this.data,r=this.updateWithPlainObj(t);this.emitter.emit("onNodeChange",{value:r,preValue:n,node:this})}contains(t){return Vw(this,t)}get props(){return this.data.props}get material(){const t=this.materialsModel;return t==null?void 0:t.findByComponentName(this.data.componentName)}getPlainProps(){const t=this.data,n={};return Object.keys(t.props||{}).forEach(r=>{n[r]=t.props[r].export("design")}),n}getMaterialConfig(t){var n;return this.data.configure[t]!==void 0?this.data.configure.isContainer:(n=this.material)==null?void 0:n.value.isContainer}isContainer(){return this.getMaterialConfig("isContainer")}export(t){var n;const r=this.data;if(typeof r=="string")return r;const o={};Object.keys(r.props||{}).forEach(d=>{o[d]=r.props[d].export(t)});const i=(n=r.children)==null?void 0:n.map(d=>d instanceof gb?d.export(t):d),a=r.configure||{},s=a.propsSetter||{},l={};Object.keys(s).forEach(d=>{const f=eL(s,d,!1);f&&(l[d]=f)}),a.propsSetter=l;const c=this.materialsModel.usedMaterials.find(d=>{var f;return d.componentName===((f=this.material)==null?void 0:f.componentName)});this.material&&!c&&this.materialsModel.usedMaterials.push(this.material);let u={...r,configure:a,props:o,children:i,condition:r.condition,extra:this.data.extra};return t==="design"&&delete u.id,u=Bw(u),u}};const PE=(e,t,n)=>{const r={...e,id:ro(),props:{},componentName:Cs.ROOT_CONTAINER,children:[],methods:e.methods||[],configure:xL(e.configure||{},{propsSetter:{},advanceSetter:{}}),injectEnvList:e.injectEnvList};let o=[];Tt(e.children)?o=e.children.map(a=>a instanceof Rt?a:On(a)?new Rt(a,{parent:t,materials:n}):a):e.children instanceof Rt?o.push(e.children):e.children&&On(e.children)&&o.push(new Rt(e.children,{parent:t,materials:n}));const i=Object.keys(e.props||{});return i.length&&i.forEach(a=>{var s;const l=(s=e.props)==null?void 0:s[a];l instanceof ti?r.props[a]=l:r.props[a]=new ti(a,l||"",{parent:t,materials:n})}),r.children=o,r};class Kl{constructor(t,{parent:n,materials:r}){Ne(this,"rawData"),Ne(this,"data"),Ne(this,"nodeType",Cs.ROOT_CONTAINER),Ne(this,"emitter",Sc),Ne(this,"materialsModel"),Ne(this,"listenerHandle"),Ne(this,"onChangeCbQueue"),Ne(this,"parent"),this.materialsModel=r,this.rawData=JSON.parse(JSON.stringify(t)),this.data=PE(t,this,r),this.listenerHandle=[],this.onChangeCbQueue=[],this.registerListener(),this.parent=n}registerListener(){const t=n=>{const{node:r}=n;r===this&&r.id===this.id&&this.onChangeCbQueue.forEach(o=>o(n))};this.emitter.on("onNodeChange",t),this.listenerHandle.push(()=>{this.emitter.off("onNodeChange",t)})}onChange(t){return this.onChangeCbQueue.push(t),()=>{this.onChangeCbQueue=this.onChangeCbQueue.filter(n=>n!==t)}}get id(){return this.data.id}get value(){return this.data}get props(){return this.data.props}get material(){const t=this.materialsModel;return t==null?void 0:t.findByComponentName(this.data.componentName)}updateWithPlainObj(t){const n={...this.data,...t};return this.data=PE(n,this,this.materialsModel),n}updateValue(t){const n=this.data;this.updateWithPlainObj(t),this.emitter.emit("onNodeChange",{value:this.data,preValue:n,node:this})}contains(t){return Vw(this,t)}getMaterialConfig(t){var n;return this.data.configure[t]!==void 0?this.data.configure.isContainer:(n=this.material)==null?void 0:n.value.isContainer}isContainer(){return this.getMaterialConfig("isContainer")}export(t=Dw.SAVE){var n;const r=this.data,o={};Object.keys(r.props||{}).forEach(l=>{o[l]=r.props[l].export(t)});const i=((n=r.children)==null?void 0:n.map(l=>{var c;return(c=l==null?void 0:l.export)==null?void 0:c.call(l,t)}))||[],a={...r,props:o,children:i.filter(l=>l),condition:r.condition,extra:this.data.extra};let s=wL(a,["id"]);return s=Bw(s),s}getPlainProps(){const t=this.data,n={};return Object.keys(t.props||{}).forEach(r=>{n[r]=t.props[r].export("design")}),n}destroy(){this.listenerHandle.forEach(t=>t())}clone(t){const n={...this.export("design"),id:t||ro()};return new Kl(n,{materials:this.materialsModel,parent:null})}}const pi=e=>(e==null?void 0:e.type)===_n.EXPRESSION,TL=e=>(e==null?void 0:e.type)===_n.FUNCTION,Bie=e=>(e==null?void 0:e.type)===_n.ACTION,ro=()=>Math.random().toString(32).slice(3,9),Vie=e=>(e==null?void 0:e.nodeType)==="NODE",mb=e=>(e==null?void 0:e.nodeType)==="PROP",Hie=e=>(e==null?void 0:e.nodeType)==="SLOT",Bw=e=>fie(e,t=>On(t)?!Object.keys(t).length:Tt(t)?!t.length:!t);function qie(e,t){const n=[e];for(;n.length;){const r=n.shift();if(r&&t(r))return r;const o=(r==null?void 0:r.props)||{},i=s=>{if(s instanceof Rt){n.push(s);return}if(s instanceof Ja&&i(s.value.value),s instanceof ti){i(s.value);return}if(On(s)){const l=s;Object.keys(l).forEach(c=>{i(l[c])});return}if(Tt(s)){s.forEach(l=>{i(l)});return}};i(o);const a=(r==null?void 0:r.value.children.filter(s=>s instanceof Rt))||[];n.push(...a)}}function Vw(e,t){return qie(e,n=>n.id===t)}const Uie=e=>{const t=hL(e),n=t.snippets;return delete t.snippets,t.snippets=n.map(r=>({...t,...r,id:r.id||`${e.componentName}-${ro()}`,title:r.title||e.title,category:r.category||e.category,tags:[...r.tags||[],...e.tags||[]],groupName:r.groupName||e.groupName,snapshot:r.snapshot||e.icon,snapshotText:r.snapshotText,schema:{...r.schema,componentName:r.schema.componentName||e.componentName}})),t};class Gie{constructor(t){Ne(this,"rawData"),Ne(this,"data"),this.rawData=t,this.data=Uie(t)}get value(){return this.data}get rawValue(){return this.rawData}get componentName(){return this.data.componentName}get snippets(){return this.data.snippets}getSnippetById(t){return this.data.snippets.find(n=>n.id===t)}}const _p=e=>{if(!Tt(e))throw new Error("Materials must be a array");return e.map(t=>new Gie(t))},Wie=e=>{e==null||e.forEach(t=>{Fw({data:t,dataStruct:jie,throwError:!1})})};class Qa{constructor(t){Ne(this,"rawData"),Ne(this,"data"),Ne(this,"usedMaterials",[]),this.rawData=t,Wie(t),this.data=_p(t)}addMaterials(t){const n=_p(t),r=[],o=this.data.map(a=>{const s=n.findIndex(l=>l.componentName===a.componentName);return s>=0?(r.push(s),n[s]):a}),i=n.filter((a,s)=>!r.includes(s));this.data=[...o,...i]}replaceMaterials(t){const n=_p(t);this.data=[...n]}removeMaterial(t){const n=this.data.filter(r=>!t.includes(r.componentName));this.data=n}findByComponentName(t){return this.data.find(n=>n.componentName===t)}findSnippetById(t){const n=[...this.data];let r=null;for(;!r&&n.length;){const o=n.pop();r=o==null?void 0:o.getSnippetById(t)}return r}getAllSnippets(){const t=this.data.reduce((i,a)=>(i.push(...a.snippets),i),[]),n=[],r={default:[]};t.forEach(i=>{const a=i.groupName||"default";n.includes(a)||(n.push(a),r[a]=[]),r[a].push(i)});let o=[];return n.forEach(i=>{const a=["default"],s={default:[]},l=r[i];if(l.length!==0){l.forEach(d=>{const f=d.category||"default";a.includes(f)||(a.push(f),s[f]=[]),s[f].push(d)});const c=[];a.forEach(d=>{s[d].length&&c.push({name:d,list:s[d]})});const u={name:i,list:c};o.push(u)}}),o=o.sort((i,a)=>(i.name||"")>(a.name||"")?1:-1),o}get value(){return this.data}get rawValue(){return this.rawData}}const Kie=Xe({version:se(ce()),name:se(ce()),css:se(ce()),lifecycle:se(Ye()),props:se(Ye()),methods:se(ft(Lie)),componentsMeta:ft(Lw(Xe({componentName:ce()}),$w)),thirdLibs:se(kie),componentsTree:$ie,assets:se(ft(Ye())),extra:se(Ye())}),AL=e=>(Fw({data:e,dataStruct:Kie,throwError:!1}),e),Ep=(e,t,n)=>({...e,componentsTree:new Kl(e.componentsTree,{parent:t,materials:n})});let jE=class ML{constructor(t,n){Ne(this,"nodeType","PAGE"),Ne(this,"rawData"),Ne(this,"emitter",Sc),Ne(this,"data"),Ne(this,"parent"),Ne(this,"materialsModel"),Ne(this,"assetPackagesList"),AL(t),this.rawData=JSON.parse(JSON.stringify(t)),this.materialsModel=new Qa((n==null?void 0:n.materials)||[]),this.data=Ep(t,this,this.materialsModel),this.assetPackagesList=[...(n==null?void 0:n.assetPackagesList)||[],...this.data.assets||[]]}updatePage(t){const n=this.data;this.rawData=JSON.parse(JSON.stringify(t)),this.data=Ep(t,this,this.materialsModel),this.emitter.emit("onPageChange",{value:this.data,preValue:n,node:this})}reloadPage(t){const n=this.data;t&&(this.rawData=JSON.parse(JSON.stringify(t)),this.data=Ep(t,this,this.materialsModel)),this.emitter.emit("onReloadPage",{value:this.data,preValue:n,node:this})}get value(){return this.data}getNode(t){if(!t)return;const n=this.data.componentsTree;return Vw(n,t)}addNode(t,n,r="AFTER"){var o;if(r==="AFTER"||r==="BEFORE"){const i=n.parent;if(i===null&&n instanceof Kl)return console.warn("Not found parent node"),!1;if(i instanceof ti)return console.warn("CProp can not add node"),!1;if(i instanceof Ja){const s=i.value.value,l=s.findIndex(c=>c===n)??-1;return l>=0?(r==="BEFORE"?s.splice(l,0,t):s.splice(l+1,0,t),t.parent=i,(o=i.parent)==null||o.updateValue(),!0):!1}if(i instanceof ML)return!1;const a=(i==null?void 0:i.value.children.findIndex(s=>s===n))??-1;return a>=0?(r==="BEFORE"?i==null||i.value.children.splice(a,0,t):i==null||i.value.children.splice(a+1,0,t),t.parent=i,i==null||i.updateValue(),!0):(console.warn("Not found target node"),!1)}if(r==="CHILD_START")return n.value.children.unshift(t),t.parent=n,n.updateValue(),!0;if(r==="CHILD_END")return n.value.children.push(t),t.parent=n,n.updateValue(),!0;if(On(r)){const i=r;if(i.type==="CHILD"){const a=i.pos,s=i.index||0;return a==="BEFORE"?n==null||n.value.children.splice(s,0,t):n==null||n.value.children.splice(s+1,0,t),t.parent=n,n.updateValue(),!0}else console.warn("Can not parse pos obj")}return!1}createNode(t){return delete t.id,new Rt(t,{parent:null,materials:this.materialsModel})}addNodeById(t,n,r="AFTER"){const o=this.getNode(n);return o?this.addNode(t,o,r):(console.warn(`Not find a node by ${n}, pls check it`),!1)}copyNode(t){const n=t.export("design");n.id=ro();const r=new Rt(n,{parent:t.parent,materials:this.materialsModel});return this.addNode(r,t,"AFTER"),r}copyNodeById(t){const n=this.getNode(t);return n&&n instanceof Rt?this.copyNode(n):!1}moveNode(t,n,r){this.deleteNode(t);let o=n;return["AFTER","BEFORE"].includes(r)&&(o=n.parent),t.parent=o,this.addNode(t,n,r)}moveNodeById(t,n,r){const o=this.getNode(t),i=this.getNode(n);return o&&i&&o instanceof Rt&&i instanceof Rt?this.moveNode(o,i,r):!1}deleteNode(t){var n;const r=t.parent;if(!r)throw new Error("parent node is null or undefined, pls check it");if(r instanceof Ja){const o=r.value.value,i=o.findIndex(s=>s===t),a=o[i];return o.splice(i,1),(n=r.parent)==null||n.updateValue(),a}if(r instanceof Rt||r instanceof Kl){const o=r.value.children,i=o.findIndex(s=>s===t),a=o[i];return o.splice(i,1),r.updateValue(),a}}deleteNodeById(t){const n=this.getNode(t);if(n)return this.deleteNode(n)}export(t=Dw.SAVE){var n;const r=this.data.componentsTree.export(t),o=this.assetPackagesList,i=[],a=this.materialsModel.usedMaterials.map(l=>{const c=o.find(u=>{var d;return u.package===((d=l.value.npm)==null?void 0:d.package)});return c&&i.push(c),{componentName:l.componentName,...hL(l.value.npm||{})}}).filter(l=>l.componentName&&l.package&&l.version?!0:(console.warn(`${JSON.stringify(l,null,2)} not a valid material info`),!1));this.materialsModel.usedMaterials=[];let s={...this.data,componentsTree:Bw(r),componentsMeta:a,thirdLibs:this.data.thirdLibs,assets:[],extra:this.data.extra};return(n=this.data.thirdLibs)==null||n.forEach(l=>{const c=o.find(u=>l.package===u.package);c&&i.push(c)}),s.assets=vie(i,l=>l.package),s=wL(s,["id"]),JSON.parse(JSON.stringify(s))}getRootNode(){return this.data.componentsTree}};Cs.ROOT_CONTAINER;const Df="DYNAMIC",Xie=["$$context","$$nodeModel"],Hw="ON_DID_RENDER",qw="ON_WILL_DESTROY",Yie=[Hw,qw],vb=(e,t)=>{let n=e;return t&&(n={...e},n.__proto__=t||null),n},Xl=(e,t={},...n)=>typeof e=="string"||typeof e=="number"?String(e):(Xie.forEach(r=>{r in t&&e.__CP_TYPE__!==Df&&delete t[r]}),v.createElement(e,t,...n)),IE=(e={},t)=>{const n=[],r=(o,i)=>{let a=i;mb(i)&&(a=i.value),t(a)?n.push({keyPath:o,val:a}):Wa(a)?a.forEach((s,l)=>{r([...o,String(l)],s)}):vs(a)&&Object.keys(a).forEach(s=>{r([...o,s],a[s])})};return r(["$root"],e),n},Da=(e,t)=>{const n=e.handler,{context:r,storeManager:o}=t;return t.actionVariableSpace||(t.actionVariableSpace={}),async function(...i){const a={},s=async u=>{const d=u;if(d.type==="RUN_CODE"){const f=Tf({funcName:"",funcBody:`function() {
|
|
141
141
|
${d.value} }`,nodeContext:r,storeManager:o,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace});let h;t.$$response!==void 0?h=f(t.$$response,...i):h=f(...i),h!=null&&h.then?a[d.id]=await h:a[d.id]=h}if(d.type==="JUMP_LINK"){const f=Jie(d,t)(...i);f!=null&&f.then?a[d.id]=await f:a[d.id]=f}if(d.type==="REQUEST_API"){const{run:f,afterFailedResponse:h,afterSuccessResponse:p}=Qie(d,t);try{const m=f(...i);m!=null&&m.then?a[d.id]=await m:a[d.id]=m,d.responseVarName&&(t.actionVariableSpace[d.responseVarName]=a[d.id]);const g=p(a[d.id],...i);return g!=null&&g.then?await g:g}catch(m){const g=await h(m);return g!=null&&g.then?await g:g}}if(d.type==="CALL_NODE_METHOD"){const f=Zie(d,t)(...i);f!=null&&f.then?a[d.id]=await f:a[d.id]=f,d.returnVarName&&(t.actionVariableSpace[d.returnVarName]=a[d.id])}if(d.type==="ASSIGN_VALUE"){const f=eae(d,t);let h=[...i];t.$$response!==void 0&&(h=[t.$$response,h]);const p=f(...h);a[d.id]=await p}};let l=n[0];const c=new Set;for(;l;){if(c.has(l.id))return;await s(l),c.add(l.id),l=n.find(u=>(l==null?void 0:l.next)&&u.id===(l==null?void 0:l.next))}}};function Jie(e,t){return mi(e.link,t)}const mi=(e,t)=>function(...n){return pi(e)?Na(e.value,{...t.context,nodeContext:t.context,storeManager:t.storeManager,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace}):TL(e)?Tf({funcName:e.name||"",funcBody:e.value,nodeContext:t.context,storeManager:t.storeManager,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace})(...n):e},Qie=(e,t)=>({run:function(...n){var r,o;let i="";e.apiPath&&(i=mi(e.apiPath,t)(...n));const a=e.body||{};Object.keys(a).forEach(u=>{a[u]=mi(a[u],t)(...n)});const s=e.query||{};Object.keys(s).forEach(u=>{s[u]=mi(s[u],t)(...n)});const l=e.header||{};Object.keys(l).forEach(u=>{l[u]=mi(l[u],t)(...n)});const c=e.method||"GET";return(o=(r=t.context).requestAPI)==null?void 0:o.call(r,{url:i,method:c,header:l,body:a,query:s})},afterSuccessResponse:async(n,...r)=>{if(!e.afterSuccessResponse)return n;const o=[...e.afterSuccessResponse||[],...e.afterFailedResponse||[]];return Da({handler:o},{...t,$$response:n})(...r)},afterFailedResponse:async(n,...r)=>{if(!e.afterFailedResponse)return n;const o=[...e.afterFailedResponse||[],...e.afterSuccessResponse||[]];return Da({handler:o},{...t,$$response:n})(...r)}}),Zie=(e,t)=>(...n)=>{const r=Tf({funcName:"",funcBody:`
|
|
142
142
|
function () {
|
|
143
143
|
var args = arguments;
|
|
@@ -407,5 +407,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
407
407
|
ctx.font = "48px serif";
|
|
408
408
|
ctx.fillText("Hello Canvas", 10, 50);
|
|
409
409
|
}
|
|
410
|
-
`}}}}]},{title:"HTML 标签",componentName:"CNativeTag",props:[{name:"htmlTag",title:"标签名",valueType:"string",setters:[{componentName:"SelectSetter",props:{options:he.HTMl_TAGS.map(e=>({name:e,value:e}))}}]},mo],isContainer:!0,groupName:Fo,snippets:[{title:"HTML",snapshotText:"HTML",category:Bo,schema:{props:{htmlTag:"div"}}}]}];P6.forEach(e=>{e.events=$ke});const zke=P6.map(e=>({...e,npm:{name:e.componentName,package:M6,version:A6}})),Fke=[...zke,...Dke];class j6 extends v.Component{constructor(n){super(n);Y(this,"currentSelectNode");Y(this,"pluginManager");Y(this,"workbenchRef",v.createRef());Y(this,"pageSchema");Y(this,"pageModel");Y(this,"material");Y(this,"emitter");Y(this,"assetsPackageListManager");Y(this,"workbenchConfig",{});Y(this,"_oldHiddenWidgetConfig");Y(this,"updatePage",n=>{this.pageModel.updatePage(n)});Y(this,"updateMaterials",async(n,r,o)=>{const i=await this.pluginManager.get("Designer"),a=i==null?void 0:i.export;this.pluginManager.assetsPackageListManager.setList(r),this.pageModel.assetPackagesList=this.pluginManager.assetsPackageListManager.getList();const s=a==null?void 0:a.getDesignerWindow();if(!s){console.warn("subWin not exits");return}await new Mae(r,s).load();const c=zI(r,s);let u=FI(c);o!=null&&o.formatComponents&&(u=o.formatComponents(u)),a==null||a.updateRenderComponents(u),this.pageModel.materialsModel.addMaterials(n),this.emitter.emit("updateMaterials")});Y(this,"refresh",async()=>{this.pageModel.reloadPage(this.pageModel.export("design"))});Y(this,"getWorkbench",()=>this.workbenchRef.current);this.pageSchema=n.schema,this.material=n.material,this.currentSelectNode=null,window.__CHAMELEON_ENG__=this,this.assetsPackageListManager=new dI(n.assetPackagesList||[]),this.workbenchConfig=n.workbenchConfig||{};try{this.pageModel=new he.CPage(this.pageSchema,{materials:this.material||[],assetPackagesList:n.assetPackagesList||[]})}catch(r){console.error(r),this.pageModel=new he.CPage(he.EmptyPage)}this.emitter=xd()}updateCurrentSelectNode(n){this.currentSelectNode=n,this.emitter.emit("onSelectNodeChange",{node:n})}async componentDidMount(){var i,a,s,l,c,u;window.__C_ENGINE__=this;const n=this.props.plugins,r=new UL({engine:this,getWorkbench:()=>this.workbenchRef.current,emitter:this.emitter,pageModel:this.pageModel,i18n:Dd,assetsPackageListManager:this.assetsPackageListManager});this.pluginManager=r,r.customPlugin("Designer",d=>(d.ctx.config.beforeInitRender=IL,d.ctx.config.customRender=LL({components:this.props.components||{},renderProps:this.props.renderProps||{}}),d.ctx.config.components=this.props.components,d)),(a=(i=this.props).beforePluginRun)==null||a.call(i,{pluginManager:this.pluginManager});const o=n.map(d=>this.pluginManager.add(d));(l=(s=this.props).onMount)==null||l.call(s,{pluginManager:this.pluginManager,engine:this}),await Promise.all(o),this.pageModel.emitter.on("onReloadPage",()=>{var f;if(console.log("🚀 ~ Engine ~ this.pageModel.emitter.on ~ onReloadPage:"),!this.currentSelectNode)return;const d=this.pageModel.getNode((f=this.currentSelectNode)==null?void 0:f.id);d&&this.updateCurrentSelectNode(d)}),(u=(c=this.props).onReady)==null||u.call(c,{pluginManager:this.pluginManager,engine:this})}getActiveNode(){var r;if(!((r=this.currentSelectNode)!=null&&r.id))return null;const n=this.pageModel.getNode(this.currentSelectNode.id)??null;return this.currentSelectNode=n,n}getI18n(){return Dd}async preview(){var i,a;const n=(i=this.workbenchRef.current)==null?void 0:i.getHiddenWidgetConfig();this._oldHiddenWidgetConfig=n,(a=this.workbenchRef.current)==null||a.hiddenWidget({hiddenLeftPanel:!0,hiddenRightPanel:!0,hiddenTopBar:!0,canvasFull:!0});const r=await this.pluginManager.get("Designer"),o=r==null?void 0:r.export;o==null||o.setPreviewMode()}async existPreview(){var o;(o=this.workbenchRef.current)==null||o.hiddenWidget({...this._oldHiddenWidgetConfig||{},canvasFull:!1});const n=await this.pluginManager.get("Designer"),r=n==null?void 0:n.export;r==null||r.setEditMode()}hiddenWidget(n){var r;(r=this.workbenchRef.current)==null||r.hiddenWidget(n||{})}render(){return w.jsx("div",{className:De([Vae.engineContainer,this.props.className]),style:this.props.style,children:w.jsx(DL,{ref:this.workbenchRef,emitter:this.emitter,...this.workbenchConfig})})}}Y(j6,"version","0.5.
|
|
410
|
+
`}}}}]},{title:"HTML 标签",componentName:"CNativeTag",props:[{name:"htmlTag",title:"标签名",valueType:"string",setters:[{componentName:"SelectSetter",props:{options:he.HTMl_TAGS.map(e=>({name:e,value:e}))}}]},mo],isContainer:!0,groupName:Fo,snippets:[{title:"HTML",snapshotText:"HTML",category:Bo,schema:{props:{htmlTag:"div"}}}]}];P6.forEach(e=>{e.events=$ke});const zke=P6.map(e=>({...e,npm:{name:e.componentName,package:M6,version:A6}})),Fke=[...zke,...Dke];class j6 extends v.Component{constructor(n){super(n);Y(this,"currentSelectNode");Y(this,"pluginManager");Y(this,"workbenchRef",v.createRef());Y(this,"pageSchema");Y(this,"pageModel");Y(this,"material");Y(this,"emitter");Y(this,"assetsPackageListManager");Y(this,"workbenchConfig",{});Y(this,"_oldHiddenWidgetConfig");Y(this,"updatePage",n=>{this.pageModel.updatePage(n)});Y(this,"updateMaterials",async(n,r,o)=>{const i=await this.pluginManager.get("Designer"),a=i==null?void 0:i.export;this.pluginManager.assetsPackageListManager.setList(r),this.pageModel.assetPackagesList=this.pluginManager.assetsPackageListManager.getList();const s=a==null?void 0:a.getDesignerWindow();if(!s){console.warn("subWin not exits");return}await new Mae(r,s).load();const c=zI(r,s);let u=FI(c);o!=null&&o.formatComponents&&(u=o.formatComponents(u)),a==null||a.updateRenderComponents(u),this.pageModel.materialsModel.addMaterials(n),this.emitter.emit("updateMaterials")});Y(this,"refresh",async()=>{this.pageModel.reloadPage(this.pageModel.export("design"))});Y(this,"getWorkbench",()=>this.workbenchRef.current);this.pageSchema=n.schema,this.material=n.material,this.currentSelectNode=null,window.__CHAMELEON_ENG__=this,this.assetsPackageListManager=new dI(n.assetPackagesList||[]),this.workbenchConfig=n.workbenchConfig||{};try{this.pageModel=new he.CPage(this.pageSchema,{materials:this.material||[],assetPackagesList:n.assetPackagesList||[]})}catch(r){console.error(r),this.pageModel=new he.CPage(he.EmptyPage)}this.emitter=xd()}updateCurrentSelectNode(n){this.currentSelectNode=n,this.emitter.emit("onSelectNodeChange",{node:n})}async componentDidMount(){var i,a,s,l,c,u;window.__C_ENGINE__=this;const n=this.props.plugins,r=new UL({engine:this,getWorkbench:()=>this.workbenchRef.current,emitter:this.emitter,pageModel:this.pageModel,i18n:Dd,assetsPackageListManager:this.assetsPackageListManager});this.pluginManager=r,r.customPlugin("Designer",d=>(d.ctx.config.beforeInitRender=IL,d.ctx.config.customRender=LL({components:this.props.components||{},renderProps:this.props.renderProps||{}}),d.ctx.config.components=this.props.components,d)),(a=(i=this.props).beforePluginRun)==null||a.call(i,{pluginManager:this.pluginManager});const o=n.map(d=>this.pluginManager.add(d));(l=(s=this.props).onMount)==null||l.call(s,{pluginManager:this.pluginManager,engine:this}),await Promise.all(o),this.pageModel.emitter.on("onReloadPage",()=>{var f;if(console.log("🚀 ~ Engine ~ this.pageModel.emitter.on ~ onReloadPage:"),!this.currentSelectNode)return;const d=this.pageModel.getNode((f=this.currentSelectNode)==null?void 0:f.id);d&&this.updateCurrentSelectNode(d)}),(u=(c=this.props).onReady)==null||u.call(c,{pluginManager:this.pluginManager,engine:this})}getActiveNode(){var r;if(!((r=this.currentSelectNode)!=null&&r.id))return null;const n=this.pageModel.getNode(this.currentSelectNode.id)??null;return this.currentSelectNode=n,n}getI18n(){return Dd}async preview(){var i,a;const n=(i=this.workbenchRef.current)==null?void 0:i.getHiddenWidgetConfig();this._oldHiddenWidgetConfig=n,(a=this.workbenchRef.current)==null||a.hiddenWidget({hiddenLeftPanel:!0,hiddenRightPanel:!0,hiddenTopBar:!0,canvasFull:!0});const r=await this.pluginManager.get("Designer"),o=r==null?void 0:r.export;o==null||o.setPreviewMode()}async existPreview(){var o;(o=this.workbenchRef.current)==null||o.hiddenWidget({...this._oldHiddenWidgetConfig||{},canvasFull:!1});const n=await this.pluginManager.get("Designer"),r=n==null?void 0:n.export;r==null||r.setEditMode()}hiddenWidget(n){var r;(r=this.workbenchRef.current)==null||r.hiddenWidget(n||{})}render(){return w.jsx("div",{className:De([Vae.engineContainer,this.props.className]),style:this.props.style,children:w.jsx(DL,{ref:this.workbenchRef,emitter:this.emitter,...this.workbenchConfig})})}}Y(j6,"version","0.5.2");exports.AdvancePanel=iS;exports.AdvancePanelConfig=aS;exports.AssetsPackageListManager=dI;exports.BUILD_IN_SETTER_MAP=Co;exports.CSSEditor=O6;exports.CSSPropertiesEditor=wx;exports.CSSPropertiesVariableBindEditor=T3;exports.ClassNameEditor=A3;exports.ComponentLibPlugin=_c;exports.ComponentStatePanel=rS;exports.ComponentStatePanelConfig=oS;exports.CustomSchemaForm=Fc;exports.DEFAULT_PLUGIN_LIST=R6;exports.DEFAULT_PLUGIN_NAME_MAP=T6;exports.DesignerPlugin=Ec;exports.DesignerSizer=Lke;exports.DisplaySourceSchema=N6;exports.Engine=j6;exports.GlobalStatePanelPlugin=Uc;exports.HistoryPlugin=Gc;exports.HotkeysPlugin=Wc;exports.InnerComponentMeta=Fke;exports.LOGGER=ur;exports.MonacoEditor=Rs;exports.OutlineTreePlugin=kc;exports.PLUGIN_NAME=Yo;exports.PluginManager=UL;exports.PropertyPanelConfig=nS;exports.RightPanelPlugin=qc;exports.SetterSwitcher=xh;exports.VisualPanelPlus=gS;exports.VisualPanelPlusConfig=mS;exports.Workbench=DL;exports.beforeInitRender=IL;exports.defaultPropertyOptions=yd;exports.ensureKeyExist=Cc;exports.formatCSSTextProperty=lI;exports.formatCssToNodeVal=cI;exports.formatNodeValToEditor=uI;exports.formatStyleProperty=Yy;exports.getColorFromStr=Jy;exports.getDefaultRender=LL;exports.getUniqueAssetsList=uw;exports.parseBoxShadowString=rd;exports.plugins=Ike;exports.registerCustomSetter=K5;exports.sageJSONParse=$L;exports.styleArr2Obj=iI;exports.styleList2Text=sI;exports.styleObjToArr=aI;exports.waitReactUpdate=Zr;Object.keys(Xr).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Xr[e]})});
|
|
411
411
|
//# sourceMappingURL=index.cjs.map
|