@chamn/engine 0.3.3 → 0.3.4

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 CHANGED
@@ -136,7 +136,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
136
136
  originData: ${JSON.stringify(t)}`):console.warn(`${JSON.stringify(t)}
137
137
  data struct format is invalidate`),o},uw=e=>{const{data:t,message:n,throwError:r,dataStruct:o}=e;return Iae(({data:i})=>{try{return t$(i,o),{isValidate:!0}}catch(a){let s=a;return a instanceof e$&&(s=a.failures().map(l=>`【${l.path.join(".")}】: ${l.message}
138
138
  `)),{isValidate:!1,message:s,error:a}}})({data:t,message:n,throwError:r})};var As=(e=>(e.ROOT_CONTAINER="RootContainer",e))(As||{});const $ae=Ye({type:pn(_n.FUNCTION),value:ce()}),Lae=aw(n$(os,["componentName"]),Ye({componentName:pn("RootContainer")}));function Dae(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 Nc=Dae(),zae=(e,t)=>{const n={...e,value:[]},r=e.value;let o=new Ii([]);return t&&(o=t.materialsMode||new Ii([])),r&&(jt(r)?n.value=r.map(i=>new vt(i,{parent:t,materials:o})):Nn(r)&&n.value.push(new vt(r,{parent:t,materials:o}))),n};class is{constructor(t,n){Oe(this,"nodeType","SLOT"),Oe(this,"rawData"),Oe(this,"parent"),Oe(this,"emitter",Nc),Oe(this,"data"),Oe(this,"id"),Oe(this,"materialsMode"),this.parent=(n==null?void 0:n.parent)||null,this.rawData=t;const r=(n==null?void 0:n.materials)||new Ii([]);this.materialsMode=r,this.id=io(),this.data=zae(t,this)}get value(){return this.data}export(t){const n=this.data,r=o=>{if(o instanceof vt)return o.export(t);if(Nn(o)){const i={};return Object.keys(o||{}).forEach(a=>{i[a]=r(o[a])}),i}return jt(o)?o.map(i=>r(i)):(t==="design"&&delete o.id,o)};return r(n)}}const a$=e=>{let t=[];return e.forEach(n=>{const r=n;r.type?r.type===bb.SINGLE?t.push(r.content):r.type===bb.GROUP&&(t=[...t,...a$(r.content)]):t.push(n)}),t},xb=(e,t,n)=>{if(e.type)return e.type===_n.SLOT?new is(e,{parent:t,materials:n}):e;if(Nn(e)){const r={};return Object.keys(e).forEach(o=>{r[o]=wb(e[o],t,n)}),r}else return Array.isArray(e)?e.map(r=>xb(r,t,n)):e},wb=(e,t,n)=>Nn(e)?xb(e,t,n):jt(e)?e.map(r=>xb(r,t,n)):e;class ci{constructor(t,n,r){Oe(this,"nodeType","PROP"),Oe(this,"rawData"),Oe(this,"parent"),Oe(this,"emitter",Nc),Oe(this,"data"),Oe(this,"name"),Oe(this,"materialsMode");const o=(r==null?void 0:r.materials)||new Ii([]);this.materialsMode=o,this.parent=r==null?void 0:r.parent,this.rawData=n,this.name=t,this.data=wb(n,this,o)}isIncludeSlot(){return!1}isIncludeExpression(){return!1}get value(){return this.data}updateValue(t){const n=this.data;this.data=wb(t??n,this,this.materialsMode),this.emitter.emit("onPropChange",{value:this.data,preValue:n,node:this}),this.parent&&!(this.parent instanceof is)&&this.emitter.emit("onNodeChange",{value:this.parent.value,preValue:this.parent.value,node:this.parent})}get material(){const t=this.parent;if(t instanceof vt){const n=t.material;return a$((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 ci||o instanceof is||o instanceof vt)return o.export(t);if(jt(o))return o.map(i=>r(i));if(Nn(o)){const i={};return Object.keys(o||{}).forEach(a=>{i[a]=r(o[a])}),i}return o};return r(n)}}const Fae=e=>{if(typeof e=="string")return!0;uw({data:e,dataStruct:os,throwError:!1})},ck=(e,t,n=new Ii([]))=>{if(typeof e=="string")return e;const r={...e,id:e.id??io(),children:[],props:{},methods:e.methods||[],configure:Q5(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 ci){r.props[i]=s;return}r.props[i]=new ci(i,s||"",{parent:t,materials:n})}),e.children&&(Array.isArray(e.children)?r.children=e.children.map(i=>{if(i instanceof vt)return i;if(Nn(i)){const a=i;return new vt(a,{parent:t,materials:n})}else return i}):(e.children instanceof vt&&(r.children=[e.children]),r.children=[new vt(e.children,{parent:t,materials:n})])),r};class vt{constructor(t,n){Oe(this,"nodeType","NODE"),Oe(this,"rawData"),Oe(this,"data"),Oe(this,"emitter",Nc),Oe(this,"parent"),Oe(this,"materialsModel"),Oe(this,"listenerHandle"),Oe(this,"onChangeCbQueue"),this.rawData=JSON.parse(JSON.stringify(t)),Fae(t);const r=(n==null?void 0:n.materials)||new Ii([]);this.parent=(n==null?void 0:n.parent)||null,this.materialsModel=r,this.data=ck(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||io()};return new vt(n,{materials:this.materialsModel})}updateWithPlainObj(t){const n={...this.data,...t};return this.data=ck(n,this),n}updateValue(t){const n=this.data,r=this.updateWithPlainObj(t);this.emitter.emit("onNodeChange",{value:r,preValue:n,node:this})}contains(t){return fw(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 vt?d.export(t):d),a=r.configure||{},s=a.propsSetter||{},l={};Object.keys(s).forEach(d=>{const f=P5(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=dw(u),u}}const uk=(e,t,n)=>{const r={...e,id:io(),props:{},componentName:As.ROOT_CONTAINER,children:[],methods:e.methods||[],configure:Q5(e.configure||{},{propsSetter:{},advanceSetter:{}})};let o=[];jt(e.children)?o=e.children.map(a=>a instanceof vt?a:Nn(a)?new vt(a,{parent:t,materials:n}):a):e.children instanceof vt?o.push(e.children):e.children&&Nn(e.children)&&o.push(new vt(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 ci?r.props[a]=l:r.props[a]=new ci(a,l||"",{parent:t,materials:n})}),r.children=o,r};class ec{constructor(t,{parent:n,materials:r}){Oe(this,"rawData"),Oe(this,"data"),Oe(this,"nodeType",As.ROOT_CONTAINER),Oe(this,"emitter",Nc),Oe(this,"materialsModel"),Oe(this,"listenerHandle"),Oe(this,"onChangeCbQueue"),Oe(this,"parent"),this.materialsModel=r,this.rawData=JSON.parse(JSON.stringify(t)),this.data=uk(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=uk(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 fw(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=lw.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=Z5(a,["id"]);return s=dw(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||io()};return new ec(n,{materials:this.materialsModel,parent:null})}}const wi=e=>(e==null?void 0:e.type)===_n.EXPRESSION,s$=e=>(e==null?void 0:e.type)===_n.FUNCTION,Bae=e=>(e==null?void 0:e.type)===_n.ACTION,io=()=>Math.random().toString(32).slice(3,9),Vae=e=>(e==null?void 0:e.nodeType)==="NODE",Sb=e=>(e==null?void 0:e.nodeType)==="PROP",Hae=e=>(e==null?void 0:e.nodeType)==="SLOT",dw=e=>fae(e,t=>Nn(t)?!Object.keys(t).length:jt(t)?!t.length:!t);function qae(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 vt){n.push(s);return}if(s instanceof is&&i(s.value.value),s instanceof ci){i(s.value);return}if(Nn(s)){const l=s;Object.keys(l).forEach(c=>{i(l[c])});return}if(jt(s)){s.forEach(l=>{i(l)});return}};i(o);const a=(r==null?void 0:r.value.children.filter(s=>s instanceof vt))||[];n.push(...a)}}function fw(e,t){return qae(e,n=>n.id===t)}const Uae=e=>{const t=U5(e),n=t.snippets;return delete t.snippets,t.snippets=n.map(r=>({...t,...r,id:r.id||`${e.componentName}-${io()}`,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 Gae{constructor(t){Oe(this,"rawData"),Oe(this,"data"),this.rawData=t,this.data=Uae(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 Dp=e=>{if(!jt(e))throw new Error("Materials must be a array");return e.map(t=>new Gae(t))},Wae=e=>{e==null||e.forEach(t=>{uw({data:t,dataStruct:jae,throwError:!1})})};class Ii{constructor(t){Oe(this,"rawData"),Oe(this,"data"),Oe(this,"usedMaterials",[]),this.rawData=t,Wae(t),this.data=Dp(t)}addMaterials(t){const n=Dp(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=Dp(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 Kae=Ye({version:ce(),name:ce(),css:se(ce()),renderType:se(kn([pn("COMPONENT"),pn("PAGE")])),loadType:se(Qe()),lifecycle:se(Qe()),props:se(Qe()),methods:se(mt($ae)),componentsMeta:mt(aw(Ye({componentName:ce()}),sw)),thirdLibs:se(kae),componentsTree:Lae,assets:se(mt(Qe()))}),l$=e=>(uw({data:e,dataStruct:Kae,throwError:!1}),e),zp=(e,t,n)=>({...e,componentsTree:new ec(e.componentsTree,{parent:t,materials:n})});let dk=class c${constructor(t,n){Oe(this,"nodeType","PAGE"),Oe(this,"rawData"),Oe(this,"emitter",Nc),Oe(this,"data"),Oe(this,"parent"),Oe(this,"materialsModel"),Oe(this,"assetPackagesList"),l$(t),this.rawData=JSON.parse(JSON.stringify(t)),this.materialsModel=new Ii((n==null?void 0:n.materials)||[]),this.data=zp(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=zp(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=zp(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 fw(n,t)}addNode(t,n,r="AFTER"){var o;if(r==="AFTER"||r==="BEFORE"){const i=n.parent;if(i===null&&n instanceof ec)return console.warn("Not found parent node"),!1;if(i instanceof ci)return console.warn("CProp can not add node"),!1;if(i instanceof is){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 c$)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(Nn(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 vt(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=io();const r=new vt(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 vt?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 vt&&i instanceof vt?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 is){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 vt||r instanceof ec){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=lw.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,...U5(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:dw(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=vae(i,l=>l.package),s=Z5(s,["id"]),JSON.parse(JSON.stringify(s))}getRootNode(){return this.data.componentsTree}};As.ROOT_CONTAINER;const Kf="DYNAMIC",Yae=["$$context","$$nodeModel"],hw="ON_DID_RENDER",pw="ON_WILL_DESTROY",Xae=[hw,pw],Cb=(e,t)=>{let n=e;return t&&(n={...e},n.__proto__=t||null),n},tc=(e,t={},...n)=>typeof e=="string"||typeof e=="number"?String(e):(Yae.forEach(r=>{r in t&&e.__CP_TYPE__!==Kf&&delete t[r]}),v.createElement(e,t,...n)),fk=(e={},t)=>{const n=[],r=(o,i)=>{let a=i;Sb(i)&&(a=i.value),t(a)?n.push({keyPath:o,val:a}):ts(a)?a.forEach((s,l)=>{r([...o,String(l)],s)}):Es(a)&&Object.keys(a).forEach(s=>{r([...o,s],a[s])})};return r(["$root"],e),n},Ga=(e,t)=>{const n=e.handler,{context:r,storeManager:o}=t;return t.actionVariableSpace||(t.actionVariableSpace={}),async function(...i){const a={},s=async c=>{const u=c;if(u.type==="RUN_CODE"){const d=Ff({funcName:"",funcBody:`function() {
139
- ${u.value} }`,nodeContext:r,storeManager:o,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace});let f;t.$$response!==void 0?f=d(t.$$response,...i):f=d(...i),f!=null&&f.then?a[u.id]=await f:a[u.id]=f}if(u.type==="JUMP_LINK"){const d=Jae(u,t)(...i);d!=null&&d.then?a[u.id]=await d:a[u.id]=d}if(u.type==="REQUEST_API"){const{run:d,afterFailedResponse:f,afterSuccessResponse:h}=Qae(u,t);try{const p=d(...i);p!=null&&p.then?a[u.id]=await p:a[u.id]=p,u.responseVarName&&(t.actionVariableSpace[u.responseVarName]=a[u.id]);const g=h(a[u.id],...i);return g!=null&&g.then?await g:g}catch(p){const g=await f(p);return g!=null&&g.then?await g:g}}if(u.type==="CALL_NODE_METHOD"){const d=Zae(u,t)(...i);d!=null&&d.then?a[u.id]=await d:a[u.id]=d,u.returnVarName&&(t.actionVariableSpace[u.returnVarName]=a[u.id])}if(u.type==="ASSIGN_VALUE"){const d=ese(u,t);let f=[...i];t.$$response!==void 0&&(f=[t.$$response,f]);const h=d(...f);a[u.id]=await h}};let l=n[0];for(;l;)await s(l),l=n.find(c=>(l==null?void 0:l.next)&&c.id===(l==null?void 0:l.next))}};function Jae(e,t){return Ci(e.link,t)}const Ci=(e,t)=>function(...n){return wi(e)?$a(e.value,t.context):s$(e)?Ff({funcName:e.name||"",funcBody:e.value,nodeContext:t.context,storeManager:t.storeManager,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace})(...n):e},Qae=(e,t)=>({run:function(...n){var r,o;let i="";e.apiPath&&(i=Ci(e.apiPath,t)(...n));const a=e.body||{};Object.keys(a).forEach(u=>{a[u]=Ci(a[u],t)(...n)});const s=e.query||{};Object.keys(s).forEach(u=>{s[u]=Ci(s[u],t)(...n)});const l=e.header||{};Object.keys(l).forEach(u=>{l[u]=Ci(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 Ga({type:"ACTION",handler:o},{...t,$$response:n})(...r)},afterFailedResponse:async(n,...r)=>{if(!e.afterFailedResponse)return n;const o=[...e.afterFailedResponse||[],...e.afterSuccessResponse||[]];return Ga({type:"ACTION",handler:o},{...t,$$response:n})(...r)}}),Zae=(e,t)=>(...n)=>{const r=Ff({funcName:"",funcBody:`
139
+ ${u.value} }`,nodeContext:r,storeManager:o,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace});let f;t.$$response!==void 0?f=d(t.$$response,...i):f=d(...i),f!=null&&f.then?a[u.id]=await f:a[u.id]=f}if(u.type==="JUMP_LINK"){const d=Jae(u,t)(...i);d!=null&&d.then?a[u.id]=await d:a[u.id]=d}if(u.type==="REQUEST_API"){const{run:d,afterFailedResponse:f,afterSuccessResponse:h}=Qae(u,t);try{const p=d(...i);p!=null&&p.then?a[u.id]=await p:a[u.id]=p,u.responseVarName&&(t.actionVariableSpace[u.responseVarName]=a[u.id]);const g=h(a[u.id],...i);return g!=null&&g.then?await g:g}catch(p){const g=await f(p);return g!=null&&g.then?await g:g}}if(u.type==="CALL_NODE_METHOD"){const d=Zae(u,t)(...i);d!=null&&d.then?a[u.id]=await d:a[u.id]=d,u.returnVarName&&(t.actionVariableSpace[u.returnVarName]=a[u.id])}if(u.type==="ASSIGN_VALUE"){const d=ese(u,t);let f=[...i];t.$$response!==void 0&&(f=[t.$$response,f]);const h=d(...f);a[u.id]=await h}};let l=n[0];for(;l;)await s(l),l=n.find(c=>(l==null?void 0:l.next)&&c.id===(l==null?void 0:l.next))}};function Jae(e,t){return Ci(e.link,t)}const Ci=(e,t)=>function(...n){return wi(e)?$a(e.value,{...t.context,nodeContext:t.context,storeManager:t.storeManager,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace}):s$(e)?Ff({funcName:e.name||"",funcBody:e.value,nodeContext:t.context,storeManager:t.storeManager,$$response:t.$$response,actionVariableSpace:t.actionVariableSpace})(...n):e},Qae=(e,t)=>({run:function(...n){var r,o;let i="";e.apiPath&&(i=Ci(e.apiPath,t)(...n));const a=e.body||{};Object.keys(a).forEach(u=>{a[u]=Ci(a[u],t)(...n)});const s=e.query||{};Object.keys(s).forEach(u=>{s[u]=Ci(s[u],t)(...n)});const l=e.header||{};Object.keys(l).forEach(u=>{l[u]=Ci(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 Ga({type:"ACTION",handler:o},{...t,$$response:n})(...r)},afterFailedResponse:async(n,...r)=>{if(!e.afterFailedResponse)return n;const o=[...e.afterFailedResponse||[],...e.afterSuccessResponse||[]];return Ga({type:"ACTION",handler:o},{...t,$$response:n})(...r)}}),Zae=(e,t)=>(...n)=>{const r=Ff({funcName:"",funcBody:`
140
140
  function () {
141
141
  var args = arguments;
142
142
  var nodeRef = $$context.nodeRefs.get(${JSON.stringify(e.nodeId)});
@@ -162,7 +162,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
162
162
  *
163
163
  * This source code is licensed under the MIT license found in the
164
164
  * LICENSE file in the root directory of this source tree.
165
- */var vk;function wse(){if(vk)return Un;vk=1;function e(a){var s="https://react.dev/errors/"+a;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+a+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(a){var s=a,l=a;if(a.alternate)for(;s.return;)s=s.return;else{a=s;do s=a,s.flags&4098&&(l=s.return),a=s.return;while(a)}return s.tag===3?l:null}function n(a){if(t(a)!==a)throw Error(e(188))}function r(a){var s=a.alternate;if(!s){if(s=t(a),s===null)throw Error(e(188));return s!==a?null:a}for(var l=a,c=s;;){var u=l.return;if(u===null)break;var d=u.alternate;if(d===null){if(c=u.return,c!==null){l=c;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===l)return n(u),a;if(d===c)return n(u),s;d=d.sibling}throw Error(e(188))}if(l.return!==c.return)l=u,c=d;else{for(var f=!1,h=u.child;h;){if(h===l){f=!0,l=u,c=d;break}if(h===c){f=!0,c=u,l=d;break}h=h.sibling}if(!f){for(h=d.child;h;){if(h===l){f=!0,l=d,c=u;break}if(h===c){f=!0,c=d,l=u;break}h=h.sibling}if(!f)throw Error(e(189))}}if(l.alternate!==c)throw Error(e(190))}if(l.tag!==3)throw Error(e(188));return l.stateNode.current===l?a:s}function o(a){var s=a.tag;if(s===5||s===26||s===27||s===6)return a;for(a=a.child;a!==null;){if(s=o(a),s!==null)return s;a=a.sibling}return null}function i(a){var s=a.tag;if(s===5||s===26||s===27||s===6)return a;for(a=a.child;a!==null;){if(a.tag!==4&&(s=i(a),s!==null))return s;a=a.sibling}return null}return Un.doesFiberContain=function(a,s){for(var l=a.alternate;s!==null;){if(s===a||s===l)return!0;s=s.return}return!1},Un.findCurrentFiberUsingSlowPath=r,Un.findCurrentHostFiber=function(a){return a=r(a),a!==null?o(a):null},Un.findCurrentHostFiberWithNoPortals=function(a){return a=r(a),a!==null?i(a):null},Un.getContainerFromFiber=function(a){return a.tag===3?a.stateNode.containerInfo:null},Un.getNearestMountedFiber=t,Un.getSuspenseInstanceFromFiber=function(a){if(a.tag===13){var s=a.memoizedState;if(s===null&&(a=a.alternate,a!==null&&(s=a.memoizedState)),s!==null)return s.dehydrated}return null},Un.isFiberMounted=function(a){return t(a)===a},Un.isFiberSuspenseAndTimedOut=function(a){var s=a.memoizedState;return a.tag===13&&s!==null&&s.dehydrated===null},Un.isMounted=function(a){return(a=a._reactInternals)?t(a)===a:!1},Un}var yk;function Sse(){return yk||(yk=1,mk.exports=wse()),mk.exports}var Cse=Sse();function _se(e){return e._reactInternals}function Ese(e){const t=_se(e);if(t===void 0){if(typeof e.render=="function")throw new Error("Unable to find node on an unmounted component.");{const r=Object.keys(e).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${r}`)}}const n=Cse.findCurrentHostFiber(t);return n===null?null:n.stateNode}function kse(e){return Ese(e)}class Ose{constructor(){ge(this,"instanceMap",new Map)}get(t){return this.instanceMap.get(t)}add(t,n){const r=this.instanceMap.get(t);r?r.push(n):this.instanceMap.set(t,[n])}remove(t,n){const r=this.instanceMap.get(t);if(n!==void 0&&Array.isArray(r)){const o=r.filter(i=>i!==n);this.instanceMap.set(t,o)}else this.instanceMap.delete(t)}destroy(){this.instanceMap.clear()}}const Nse=e=>{const{node:t}=e,n=v.useMemo(()=>{const s=t.isContainer();return Es(s)?s:{placeholder:"Drag the component to place it",width:"100%",height:"100%",style:{}}},[e.node]),{placeholder:r,height:o,width:i,style:a}=n;return v.createElement("div",{style:{margin:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(200,200,200,0.1)",border:"1px solid rgba(0,0,0,0.1)",borderRadius:"2px",fontSize:"14px",color:"gray",cursor:"default",minHeight:"50px",width:i,height:o,...a}},r)};class COe extends v.Component{constructor(t){super(t),ge(this,"instanceManager",new Ose),ge(this,"renderRef"),ge(this,"dropPlaceholder",Nse),ge(this,"_components",{}),ge(this,"onGetComponent",(n,r)=>{var o,i;const a=this;let s=n;const l=(i=(o=r.material)==null?void 0:o.value.advanceCustom)==null?void 0:i.wrapComponent;l&&(s=l(n,{node:r,ctx:window.__C_ENGINE_DESIGNER_PLUGIN_CTX__}));class c extends v.Component{constructor(){super(...arguments),ge(this,"_DESIGN_BOX",!0),ge(this,"_NODE_MODEL",r),ge(this,"_NODE_ID",r.id),ge(this,"_UNIQUE_ID",`${r.id}_${io()}`),ge(this,"_STATUS"),ge(this,"_design_target_component"),ge(this,"_dom")}componentDidMount(){a.instanceManager.add(r.id,this)}getTargetComponentRef(){return this._design_target_component}componentWillUnmount(){this._STATUS="DESTROY",a.instanceManager.remove(r.id,this)}getDom(){var d,f;return((f=(d=r.material)==null?void 0:d.value.advanceCustom)==null?void 0:f.autoGetDom)??!0?kse(this):this._dom}render(){var d,f,h,p;const{children:g=[],onlyRenderChild:m,...y}=this.props;let b=g;if(ts(g)||(b=[g]),!b.filter(Boolean).length&&(r.isContainer()||r.value.componentName===As.ROOT_CONTAINER)){const S=(f=(d=r.material)==null?void 0:d.value.advanceCustom)==null?void 0:f.dropPlaceholder;b.push(v.createElement(S||a.dropPlaceholder,{node:r}))}return m?b:((p=(h=r.material)==null?void 0:h.value.advanceCustom)==null?void 0:p.autoGetDom)??!0?v.createElement(s,y,...b):v.createElement(s,{...y,$SET_DOM:S=>{this._dom=S}},...b)}}return v.forwardRef(function(u,d){return v.createElement(xse,{node:r,targetComponent:c},v.createElement(c,{ref:d,...u}))})}),this._components=Object.assign(this._components,this.props.components),this.renderRef=v.createRef(),t.dropPlaceholder&&(this.dropPlaceholder=t.dropPlaceholder)}updateComponents(t={}){this._components=Object.assign(this._components,t),this.forceUpdate()}componentDidMount(){var t,n;window.__CHAMN_RENDER_MODE="DESIGN",this.updateComponents(this.props.components),(n=(t=this.props).onMount)==null||n.call(t,this)}getPageModel(){var t;return(t=this.renderRef.current)==null?void 0:t.state.pageModel}rerender(t){var n;return(n=this.renderRef.current)==null?void 0:n.rerender(t)}getInstancesById(t,n){let r=[...this.instanceManager.get(t)||[]];return n!==void 0&&(r=r.filter(o=>n===(o==null?void 0:o._UNIQUE_ID))),r}getInstanceByDom(t){const n=u$(t);if(!n)return null;const r=d$(n);return(r==null?void 0:r.stateNode)||null}getDomsById(t,n){const r=this.getInstancesById(t),o=[];return r==null||r.forEach(i=>{var a;if((i==null?void 0:i._STATUS)==="DESTROY")return;const s=i.getDom();if(s&&!(s instanceof Text))if(n){const l=Array.from(((a=s.querySelectorAll)==null?void 0:a.call(s,n))||[]);o.push(...l)}else o.push(s)}),o}getDomRectById(t,n){return this.getDomsById(t,n).map(r=>r==null?void 0:r.getBoundingClientRect()).filter(Boolean)}render(){const{props:t,onGetComponent:n}=this,{render:r,...o}=t;return r&&(r.ref.current=this),v.createElement(bse,{onGetComponent:n,...o,components:this._components,processNodeConfigHook:(i,a)=>{var s,l;if(a.nodeType!=="NODE")return i;const{props:c,condition:u}=i;let d={...c};const f=((s=a.value.configure)==null?void 0:s.devState)||{},h=(l=a.material)==null?void 0:l.value.fixedProps;if(h!==void 0){if(Es(h))d={...d,...h};else if(typeof h=="function"){const g=h(d);d={...d,...g}}}let p=u;return f.condition===!1&&(p=f.condition),{props:Gee(d,f.props||{}),condition:p}},ref:this.renderRef})}}const u$=e=>{if(!e)return null;const t=Object.keys(e).find(n=>n.startsWith("__reactInternalInstance$")||n.startsWith("__reactFiber$"))||"";return t?e[t]:u$(e.parentElement)},d$=e=>{var t;return e?(t=e==null?void 0:e.stateNode)!=null&&t._DESIGN_BOX?e:d$(e.return):null};var _b={exports:{}},Rse=_b.exports,bk;function Tse(){return bk||(bk=1,function(e,t){(function(n,r){e.exports=r()})(Rse,function(){var n=function(){},r={},o={},i={};function a(f,h){f=f.push?f:[f];var p=[],g=f.length,m=g,y,b,S,x;for(y=function(_,k){k.length&&p.push(_),m--,m||h(p)};g--;){if(b=f[g],S=o[b],S){y(b,S);continue}x=i[b]=i[b]||[],x.push(y)}}function s(f,h){if(f){var p=i[f];if(o[f]=h,!!p)for(;p.length;)p[0](f,h),p.splice(0,1)}}function l(f,h){f.call&&(f={success:f}),h.length?(f.error||n)(h):(f.success||n)(f)}function c(f,h,p,g){var m=document,y=p.async,b=(p.numRetries||0)+1,S=p.before||n,x=f.replace(/[\?|#].*$/,""),_=f.replace(/^(css|img|module|nomodule)!/,""),k,O,C;if(g=g||0,/(^css!|\.css$)/.test(x))C=m.createElement("link"),C.rel="stylesheet",C.href=_,k="hideFocus"in C,k&&C.relList&&(k=0,C.rel="preload",C.as="style");else if(/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(x))C=m.createElement("img"),C.src=_;else if(C=m.createElement("script"),C.src=_,C.async=y===void 0?!0:y,O="noModule"in C,/^module!/.test(x)){if(!O)return h(f,"l");C.type="module"}else if(/^nomodule!/.test(x)&&O)return h(f,"l");C.onload=C.onerror=C.onbeforeload=function(E){var N=E.type[0];if(k)try{C.sheet.cssText.length||(N="e")}catch(R){R.code!=18&&(N="e")}if(N=="e"){if(g+=1,g<b)return c(f,h,p,g)}else if(C.rel=="preload"&&C.as=="style")return C.rel="stylesheet";h(f,N,E.defaultPrevented)},S(f,C)!==!1&&m.head.appendChild(C)}function u(f,h,p){f=f.push?f:[f];var g=f.length,m=g,y=[],b,S;for(b=function(x,_,k){if(_=="e"&&y.push(x),_=="b")if(k)y.push(x);else return;g--,g||h(y)},S=0;S<m;S++)c(f[S],b,p)}function d(f,h,p){var g,m;if(h&&h.trim&&(g=h),m=(g?p:h)||{},g){if(g in r)throw"LoadJS";r[g]=!0}function y(b,S){u(f,function(x){l(m,x),b&&l({success:b,error:S},x),s(g,x)},m)}if(m.returnPromise)return new Promise(y);y()}return d.ready=function(f,h){return a(f,function(p){l(h,p)}),d},d.done=function(f){s(f,[])},d.reset=function(){r={},o={},i={}},d.isDefined=function(f){return f in r},d})}(_b)),_b.exports}var Ase=Tse();const xk=rse(Ase);class Pse{constructor(t,n){ge(this,"assets"),ge(this,"loadStatus"),ge(this,"win",window),ge(this,"_onSuccessList",[]),ge(this,"_onErrorList",[]),this.assets=JSON.parse(JSON.stringify(t||[])),this.loadStatus="INIT",n!=null&&n.window&&(this.win=n.window)}load(t){const n=this.assets||[],r=[];for(let o=0;o<n.length;o++){const i=n[o];i.id||(i.id=io()),r.push(i.id);const a=i.resources.map(s=>s.src);a.length&&xk(a,i.id,{async:(t==null?void 0:t.async)??!1,before:(s,l)=>(this.win.document.body.appendChild(l),!1)})}return new Promise((o,i)=>{if(n.length===0){this._onSuccessList.forEach(a=>a()),o("");return}xk.ready(r,{success:()=>{this._onSuccessList.forEach(a=>a()),o("")},error:a=>{this._onErrorList.forEach(s=>s(a)),i(a)}})})}onSuccess(t){return this._onSuccessList.push(t),this}onError(t){return this._onErrorList.push(t),this}}const f$=async({iframe:e})=>{const t=e.getWindow();t&&(t.React=window.React,t.ReactDOM=window.ReactDOM,t.ReactDOMClient=window.ReactDOMClient)},h$=e=>async({iframe:n,assets:r,page:o,pageModel:i,ready:a,renderJSUrl:s})=>{await n.injectJS(s||"");const l=n.getWindow(),c=n.getDocument(),u=l.React,d=l.ReactDOMClient,f=l.CRender,h=o||(i==null?void 0:i.export());if(!h){console.log("page schema is empty");return}const p=j1([...r,...h.assets||[]]);new f.AssetLoader(p,{window:n.getWindow()}).onSuccess(()=>{const m=v5(p,l),y=y5(m),b=Zee(m,h.thirdLibs||[]),S=u==null?void 0:u.createElement(f.DesignRender,{adapter:f==null?void 0:f.ReactAdapter,page:o,pageModel:i,components:{...y,...e},$$context:{thirdLibs:b},onMount:x=>{a(x)}});d.createRoot(c.getElementById("app")).render(S)}).onError(()=>{console.log("资源加载出错")}).load()},Mn={silent:Number.NEGATIVE_INFINITY,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:Number.POSITIVE_INFINITY},wk={silent:{level:-1},fatal:{level:Mn.fatal},error:{level:Mn.error},warn:{level:Mn.warn},log:{level:Mn.log},info:{level:Mn.info},success:{level:Mn.success},fail:{level:Mn.fail},ready:{level:Mn.info},start:{level:Mn.info},box:{level:Mn.info},debug:{level:Mn.debug},trace:{level:Mn.trace},verbose:{level:Mn.verbose}};function Fp(e){return e!==null&&typeof e=="object"}function Eb(e,t,n=".",r){if(!Fp(t))return Eb(e,{},n);const o=Object.assign({},t);for(const i in e){if(i==="__proto__"||i==="constructor")continue;const a=e[i];a!=null&&(Array.isArray(a)&&Array.isArray(o[i])?o[i]=[...a,...o[i]]:Fp(a)&&Fp(o[i])?o[i]=Eb(a,o[i],(n?`${n}.`:"")+i.toString()):o[i]=a)}return o}function Mse(e){return(...t)=>t.reduce((n,r)=>Eb(n,r,""),{})}const jse=Mse();function Ise(e){return Object.prototype.toString.call(e)==="[object Object]"}function $se(e){return!(!Ise(e)||!e.message&&!e.args||e.stack)}let Bp=!1;const Sk=[];class nn{constructor(t={}){const n=t.types||wk;this.options=jse({...t,defaults:{...t.defaults},level:Vp(t.level,n),reporters:[...t.reporters||[]]},{types:wk,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(const r in n){const o={type:r,...this.options.defaults,...n[r]};this[r]=this._wrapLogFn(o),this[r].raw=this._wrapLogFn(o,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(t){this.options.level=Vp(t,this.options.types,this.options.level)}prompt(t,n){if(!this.options.prompt)throw new Error("prompt is not supported!");return this.options.prompt(t,n)}create(t){const n=new nn({...this.options,...t});return this._mockFn&&n.mockTypes(this._mockFn),n}withDefaults(t){return this.create({...this.options,defaults:{...this.options.defaults,...t}})}withTag(t){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+t:t})}addReporter(t){return this.options.reporters.push(t),this}removeReporter(t){if(t){const n=this.options.reporters.indexOf(t);if(n>=0)return this.options.reporters.splice(n,1)}else this.options.reporters.splice(0);return this}setReporters(t){return this.options.reporters=Array.isArray(t)?t:[t],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(const t in this.options.types)console["__"+t]||(console["__"+t]=console[t]),console[t]=this[t].raw}restoreConsole(){for(const t in this.options.types)console["__"+t]&&(console[t]=console["__"+t],delete console["__"+t])}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(t,n){t&&(t.__write||(t.__write=t.write),t.write=r=>{this[n].raw(String(r).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}pauseLogs(){Bp=!0}resumeLogs(){Bp=!1;const t=Sk.splice(0);for(const n of t)n[0]._logFn(n[1],n[2])}mockTypes(t){const n=t||this.options.mockFn;if(this._mockFn=n,typeof n=="function")for(const r in this.options.types)this[r]=n(r,this.options.types[r])||this[r],this[r].raw=this[r]}_wrapLogFn(t,n){return(...r)=>{if(Bp){Sk.push([this,t,r,n]);return}return this._logFn(t,r,n)}}_logFn(t,n,r){if((t.level||0)>this.level)return!1;const o={date:new Date,args:[],...t,level:Vp(t.level,this.options.types)};!r&&n.length===1&&$se(n[0])?Object.assign(o,n[0]):o.args=[...n],o.message&&(o.args.unshift(o.message),delete o.message),o.additional&&(Array.isArray(o.additional)||(o.additional=o.additional.split(`
165
+ */var vk;function wse(){if(vk)return Un;vk=1;function e(a){var s="https://react.dev/errors/"+a;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+a+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(a){var s=a,l=a;if(a.alternate)for(;s.return;)s=s.return;else{a=s;do s=a,s.flags&4098&&(l=s.return),a=s.return;while(a)}return s.tag===3?l:null}function n(a){if(t(a)!==a)throw Error(e(188))}function r(a){var s=a.alternate;if(!s){if(s=t(a),s===null)throw Error(e(188));return s!==a?null:a}for(var l=a,c=s;;){var u=l.return;if(u===null)break;var d=u.alternate;if(d===null){if(c=u.return,c!==null){l=c;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===l)return n(u),a;if(d===c)return n(u),s;d=d.sibling}throw Error(e(188))}if(l.return!==c.return)l=u,c=d;else{for(var f=!1,h=u.child;h;){if(h===l){f=!0,l=u,c=d;break}if(h===c){f=!0,c=u,l=d;break}h=h.sibling}if(!f){for(h=d.child;h;){if(h===l){f=!0,l=d,c=u;break}if(h===c){f=!0,c=d,l=u;break}h=h.sibling}if(!f)throw Error(e(189))}}if(l.alternate!==c)throw Error(e(190))}if(l.tag!==3)throw Error(e(188));return l.stateNode.current===l?a:s}function o(a){var s=a.tag;if(s===5||s===26||s===27||s===6)return a;for(a=a.child;a!==null;){if(s=o(a),s!==null)return s;a=a.sibling}return null}function i(a){var s=a.tag;if(s===5||s===26||s===27||s===6)return a;for(a=a.child;a!==null;){if(a.tag!==4&&(s=i(a),s!==null))return s;a=a.sibling}return null}return Un.doesFiberContain=function(a,s){for(var l=a.alternate;s!==null;){if(s===a||s===l)return!0;s=s.return}return!1},Un.findCurrentFiberUsingSlowPath=r,Un.findCurrentHostFiber=function(a){return a=r(a),a!==null?o(a):null},Un.findCurrentHostFiberWithNoPortals=function(a){return a=r(a),a!==null?i(a):null},Un.getContainerFromFiber=function(a){return a.tag===3?a.stateNode.containerInfo:null},Un.getNearestMountedFiber=t,Un.getSuspenseInstanceFromFiber=function(a){if(a.tag===13){var s=a.memoizedState;if(s===null&&(a=a.alternate,a!==null&&(s=a.memoizedState)),s!==null)return s.dehydrated}return null},Un.isFiberMounted=function(a){return t(a)===a},Un.isFiberSuspenseAndTimedOut=function(a){var s=a.memoizedState;return a.tag===13&&s!==null&&s.dehydrated===null},Un.isMounted=function(a){return(a=a._reactInternals)?t(a)===a:!1},Un}var yk;function Sse(){return yk||(yk=1,mk.exports=wse()),mk.exports}var Cse=Sse();function _se(e){return e._reactInternals}function Ese(e){const t=_se(e);if(t===void 0){if(typeof e.render=="function")throw new Error("Unable to find node on an unmounted component.");{const r=Object.keys(e).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${r}`)}}const n=Cse.findCurrentHostFiber(t);return n===null?null:n.stateNode}function kse(e){return Ese(e)}class Ose{constructor(){ge(this,"instanceMap",new Map)}get(t){return this.instanceMap.get(t)}add(t,n){const r=this.instanceMap.get(t);r?r.push(n):this.instanceMap.set(t,[n])}remove(t,n){const r=this.instanceMap.get(t);if(n!==void 0&&Array.isArray(r)){const o=r.filter(i=>i!==n);this.instanceMap.set(t,o)}else this.instanceMap.delete(t)}destroy(){this.instanceMap.clear()}}const Nse=e=>{const{node:t}=e,n=v.useMemo(()=>{const s=t.isContainer();return Es(s)?s:{placeholder:"Drag the component to place it",width:"100%",height:"100%",style:{}}},[e.node]),{placeholder:r,height:o,width:i,style:a}=n;return v.createElement("div",{style:{margin:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(200,200,200,0.1)",border:"1px solid rgba(0,0,0,0.1)",borderRadius:"2px",fontSize:"14px",color:"gray",cursor:"default",minHeight:"50px",width:i,height:o,...a}},r)};class COe extends v.Component{constructor(t){super(t),ge(this,"instanceManager",new Ose),ge(this,"renderRef"),ge(this,"dropPlaceholder",Nse),ge(this,"_components",{}),ge(this,"onGetComponent",(n,r)=>{var o,i;const a=this;let s=n;const l=(i=(o=r.material)==null?void 0:o.value.advanceCustom)==null?void 0:i.wrapComponent;l&&(s=l(n,{node:r,ctx:window.__C_ENGINE_DESIGNER_PLUGIN_CTX__}));class c extends v.Component{constructor(){super(...arguments),ge(this,"_DESIGN_BOX",!0),ge(this,"_NODE_MODEL",r),ge(this,"_NODE_ID",r.id),ge(this,"_UNIQUE_ID",`${r.id}_${io()}`),ge(this,"_STATUS"),ge(this,"_design_target_component"),ge(this,"_dom")}componentDidMount(){a.instanceManager.add(r.id,this)}getTargetComponentRef(){return this._design_target_component}componentWillUnmount(){this._STATUS="DESTROY",a.instanceManager.remove(r.id,this)}getDom(){var d,f;return((f=(d=r.material)==null?void 0:d.value.advanceCustom)==null?void 0:f.autoGetDom)??!0?kse(this):this._dom}render(){var d,f,h,p;const{children:g=[],onlyRenderChild:m,...y}=this.props;let b=g;if(ts(g)||(b=[g]),!b.filter(Boolean).length&&(r.isContainer()||r.value.componentName===As.ROOT_CONTAINER)){const S=(f=(d=r.material)==null?void 0:d.value.advanceCustom)==null?void 0:f.dropPlaceholder;b.push(v.createElement(S||a.dropPlaceholder,{node:r}))}return m?b:((p=(h=r.material)==null?void 0:h.value.advanceCustom)==null?void 0:p.autoGetDom)??!0?v.createElement(s,y,...b):v.createElement(s,{...y,$SET_DOM:S=>{this._dom=S}},...b)}}return v.forwardRef(function(u,d){return v.createElement(xse,{node:r,targetComponent:c},v.createElement(c,{ref:d,...u}))})}),this._components=Object.assign(this._components,this.props.components),this.renderRef=v.createRef(),t.dropPlaceholder&&(this.dropPlaceholder=t.dropPlaceholder)}updateComponents(t={}){this._components=Object.assign(this._components,t),this.forceUpdate()}componentDidMount(){var t,n;window.__CHAMN_RENDER_MODE="DESIGN",this.updateComponents(this.props.components),(n=(t=this.props).onMount)==null||n.call(t,this)}getPageModel(){var t;return(t=this.renderRef.current)==null?void 0:t.state.pageModel}rerender(t){var n;return(n=this.renderRef.current)==null?void 0:n.rerender(t)}getInstancesById(t,n){let r=[...this.instanceManager.get(t)||[]];return n!==void 0&&(r=r.filter(o=>n===(o==null?void 0:o._UNIQUE_ID))),r}getInstanceByDom(t){const n=u$(t);if(!n)return null;const r=d$(n);return(r==null?void 0:r.stateNode)||null}getDomsById(t,n){const r=this.getInstancesById(t),o=[];return r==null||r.forEach(i=>{var a;if((i==null?void 0:i._STATUS)==="DESTROY")return;const s=i.getDom();if(s&&!(s instanceof Text))if(n){const l=Array.from(((a=s.querySelectorAll)==null?void 0:a.call(s,n))||[]);o.push(...l)}else o.push(s)}),o}getDomRectById(t,n){return this.getDomsById(t,n).map(r=>r==null?void 0:r.getBoundingClientRect()).filter(Boolean)}render(){const{props:t,onGetComponent:n}=this,{render:r,...o}=t;return r&&(r.ref.current=this),v.createElement(bse,{onGetComponent:n,...o,components:this._components,processNodeConfigHook:(i,a)=>{var s,l;if(a.nodeType!=="NODE")return i;const{props:c,condition:u}=i;let d={...c};const f=((s=a.value.configure)==null?void 0:s.devState)||{},h=(l=a.material)==null?void 0:l.value.fixedProps;if(h!==void 0){if(Es(h))d={...d,...h};else if(typeof h=="function"){const g=h(d);d={...d,...g}}}let p=u;return f.condition===!1&&(p=f.condition),{props:Gee(d,f.props||{}),condition:p}},ref:this.renderRef})}}const u$=e=>{if(!e)return null;const t=Object.keys(e).find(n=>n.startsWith("__reactInternalInstance$")||n.startsWith("__reactFiber$"))||"";return t?e[t]:u$(e.parentElement)},d$=e=>{var t;return e?(t=e==null?void 0:e.stateNode)!=null&&t._DESIGN_BOX?e:d$(e.return):null};var _b={exports:{}},Rse=_b.exports,bk;function Tse(){return bk||(bk=1,function(e,t){(function(n,r){e.exports=r()})(Rse,function(){var n=function(){},r={},o={},i={};function a(f,h){f=f.push?f:[f];var p=[],g=f.length,m=g,y,b,S,x;for(y=function(_,k){k.length&&p.push(_),m--,m||h(p)};g--;){if(b=f[g],S=o[b],S){y(b,S);continue}x=i[b]=i[b]||[],x.push(y)}}function s(f,h){if(f){var p=i[f];if(o[f]=h,!!p)for(;p.length;)p[0](f,h),p.splice(0,1)}}function l(f,h){f.call&&(f={success:f}),h.length?(f.error||n)(h):(f.success||n)(f)}function c(f,h,p,g){var m=document,y=p.async,b=(p.numRetries||0)+1,S=p.before||n,x=f.replace(/[\?|#].*$/,""),_=f.replace(/^(css|img|module|nomodule)!/,""),k,O,C;if(g=g||0,/(^css!|\.css$)/.test(x))C=m.createElement("link"),C.rel="stylesheet",C.href=_,k="hideFocus"in C,k&&C.relList&&(k=0,C.rel="preload",C.as="style");else if(/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(x))C=m.createElement("img"),C.src=_;else if(C=m.createElement("script"),C.src=_,C.async=y===void 0?!0:y,O="noModule"in C,/^module!/.test(x)){if(!O)return h(f,"l");C.type="module"}else if(/^nomodule!/.test(x)&&O)return h(f,"l");C.onload=C.onerror=C.onbeforeload=function(E){var N=E.type[0];if(k)try{C.sheet.cssText.length||(N="e")}catch(R){R.code!=18&&(N="e")}if(N=="e"){if(g+=1,g<b)return c(f,h,p,g)}else if(C.rel=="preload"&&C.as=="style")return C.rel="stylesheet";h(f,N,E.defaultPrevented)},S(f,C)!==!1&&m.head.appendChild(C)}function u(f,h,p){f=f.push?f:[f];var g=f.length,m=g,y=[],b,S;for(b=function(x,_,k){if(_=="e"&&y.push(x),_=="b")if(k)y.push(x);else return;g--,g||h(y)},S=0;S<m;S++)c(f[S],b,p)}function d(f,h,p){var g,m;if(h&&h.trim&&(g=h),m=(g?p:h)||{},g){if(g in r)throw"LoadJS";r[g]=!0}function y(b,S){u(f,function(x){l(m,x),b&&l({success:b,error:S},x),s(g,x)},m)}if(m.returnPromise)return new Promise(y);y()}return d.ready=function(f,h){return a(f,function(p){l(h,p)}),d},d.done=function(f){s(f,[])},d.reset=function(){r={},o={},i={}},d.isDefined=function(f){return f in r},d})}(_b)),_b.exports}var Ase=Tse();const xk=rse(Ase);class Pse{constructor(t,n){ge(this,"assets"),ge(this,"loadStatus"),ge(this,"win",window),ge(this,"_onSuccessList",[]),ge(this,"_onErrorList",[]),this.assets=JSON.parse(JSON.stringify(t||[])),this.loadStatus="INIT",n!=null&&n.window&&(this.win=n.window)}load(t){const n=this.assets||[],r=[];for(let o=0;o<n.length;o++){const i=n[o];i.id||(i.id=io()),r.push(i.id);const a=i.resources.map(s=>s.src);a.length&&xk(a,i.id,{async:(t==null?void 0:t.async)??!1,before:(s,l)=>(this.win.document.body.appendChild(l),!1)})}return new Promise((o,i)=>{if(n.length===0){this._onSuccessList.forEach(a=>a()),o("");return}xk.ready(r,{success:()=>{this._onSuccessList.forEach(a=>a()),o("")},error:a=>{this._onErrorList.forEach(s=>s(a)),i(a)}})})}onSuccess(t){return this._onSuccessList.push(t),this}onError(t){return this._onErrorList.push(t),this}}const f$=async({iframe:e})=>{const t=e.getWindow();t&&(t.React=window.React,t.ReactDOM=window.ReactDOM,t.ReactDOMClient=window.ReactDOMClient)},h$=e=>async({iframe:n,assets:r,page:o,pageModel:i,ready:a,renderJSUrl:s})=>{await n.injectJS(s||"");const l=n.getWindow(),c=n.getDocument(),u=l.React,d=l.ReactDOMClient,f=l.CRender,h=o||(i==null?void 0:i.export());if(!h){console.log("page schema is empty");return}const p=j1([...r,...h.assets||[]]);new f.AssetLoader(p,{window:n.getWindow()}).onSuccess(()=>{const m=v5(p,l),y=y5(m),b=Zee(m,h.thirdLibs||[]),S=u==null?void 0:u.createElement(f.DesignRender,{adapter:f==null?void 0:f.ReactAdapter,page:o,pageModel:i,components:{...y,...e.components||{}},$$context:{thirdLibs:b},onMount:x=>{a(x)},...(e==null?void 0:e.renderProps)||{}});d.createRoot(c.getElementById("app")).render(S)}).onError(()=>{console.log("资源加载出错")}).load()},Mn={silent:Number.NEGATIVE_INFINITY,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:Number.POSITIVE_INFINITY},wk={silent:{level:-1},fatal:{level:Mn.fatal},error:{level:Mn.error},warn:{level:Mn.warn},log:{level:Mn.log},info:{level:Mn.info},success:{level:Mn.success},fail:{level:Mn.fail},ready:{level:Mn.info},start:{level:Mn.info},box:{level:Mn.info},debug:{level:Mn.debug},trace:{level:Mn.trace},verbose:{level:Mn.verbose}};function Fp(e){return e!==null&&typeof e=="object"}function Eb(e,t,n=".",r){if(!Fp(t))return Eb(e,{},n);const o=Object.assign({},t);for(const i in e){if(i==="__proto__"||i==="constructor")continue;const a=e[i];a!=null&&(Array.isArray(a)&&Array.isArray(o[i])?o[i]=[...a,...o[i]]:Fp(a)&&Fp(o[i])?o[i]=Eb(a,o[i],(n?`${n}.`:"")+i.toString()):o[i]=a)}return o}function Mse(e){return(...t)=>t.reduce((n,r)=>Eb(n,r,""),{})}const jse=Mse();function Ise(e){return Object.prototype.toString.call(e)==="[object Object]"}function $se(e){return!(!Ise(e)||!e.message&&!e.args||e.stack)}let Bp=!1;const Sk=[];class nn{constructor(t={}){const n=t.types||wk;this.options=jse({...t,defaults:{...t.defaults},level:Vp(t.level,n),reporters:[...t.reporters||[]]},{types:wk,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(const r in n){const o={type:r,...this.options.defaults,...n[r]};this[r]=this._wrapLogFn(o),this[r].raw=this._wrapLogFn(o,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(t){this.options.level=Vp(t,this.options.types,this.options.level)}prompt(t,n){if(!this.options.prompt)throw new Error("prompt is not supported!");return this.options.prompt(t,n)}create(t){const n=new nn({...this.options,...t});return this._mockFn&&n.mockTypes(this._mockFn),n}withDefaults(t){return this.create({...this.options,defaults:{...this.options.defaults,...t}})}withTag(t){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+t:t})}addReporter(t){return this.options.reporters.push(t),this}removeReporter(t){if(t){const n=this.options.reporters.indexOf(t);if(n>=0)return this.options.reporters.splice(n,1)}else this.options.reporters.splice(0);return this}setReporters(t){return this.options.reporters=Array.isArray(t)?t:[t],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(const t in this.options.types)console["__"+t]||(console["__"+t]=console[t]),console[t]=this[t].raw}restoreConsole(){for(const t in this.options.types)console["__"+t]&&(console[t]=console["__"+t],delete console["__"+t])}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(t,n){t&&(t.__write||(t.__write=t.write),t.write=r=>{this[n].raw(String(r).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}pauseLogs(){Bp=!0}resumeLogs(){Bp=!1;const t=Sk.splice(0);for(const n of t)n[0]._logFn(n[1],n[2])}mockTypes(t){const n=t||this.options.mockFn;if(this._mockFn=n,typeof n=="function")for(const r in this.options.types)this[r]=n(r,this.options.types[r])||this[r],this[r].raw=this[r]}_wrapLogFn(t,n){return(...r)=>{if(Bp){Sk.push([this,t,r,n]);return}return this._logFn(t,r,n)}}_logFn(t,n,r){if((t.level||0)>this.level)return!1;const o={date:new Date,args:[],...t,level:Vp(t.level,this.options.types)};!r&&n.length===1&&$se(n[0])?Object.assign(o,n[0]):o.args=[...n],o.message&&(o.args.unshift(o.message),delete o.message),o.additional&&(Array.isArray(o.additional)||(o.additional=o.additional.split(`
166
166
  `)),o.args.push(`
167
167
  `+o.additional.join(`
168
168
  `)),delete o.additional),o.type=typeof o.type=="string"?o.type.toLowerCase():"log",o.tag=typeof o.tag=="string"?o.tag:"";const i=(s=!1)=>{const l=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&l>0){const c=[...this._lastLog.object.args];l>1&&c.push(`(repeated ${l} times)`),this._log({...this._lastLog.object,args:c}),this._lastLog.count=1}s&&(this._lastLog.object=o,this._log(o))};clearTimeout(this._lastLog.timeout);const a=this._lastLog.time&&o.date?o.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=o.date,a<this.options.throttle)try{const s=JSON.stringify([o.type,o.tag,o.args]),l=this._lastLog.serialized===s;if(this._lastLog.serialized=s,l&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(t){for(const n of this.options.reporters)n.log(t,{options:this.options})}}function Vp(e,t={},n=3){return e===void 0?n:typeof e=="number"?e:t[e]&&t[e].level!==void 0?t[e].level:n}nn.prototype.add=nn.prototype.addReporter;nn.prototype.remove=nn.prototype.removeReporter;nn.prototype.clear=nn.prototype.removeReporter;nn.prototype.withScope=nn.prototype.withTag;nn.prototype.mock=nn.prototype.mockTypes;nn.prototype.pause=nn.prototype.pauseLogs;nn.prototype.resume=nn.prototype.resumeLogs;function Lse(e={}){return new nn(e)}class Dse{constructor(t){this.options={...t},this.defaultColor="#7f8c8d",this.levelColorMap={0:"#c0392b",1:"#f39c12",3:"#00BCD4"},this.typeColorMap={success:"#2ecc71"}}_getLogFn(t){return t<1?console.__error||console.error:t===1?console.__warn||console.warn:console.__log||console.log}log(t){const n=this._getLogFn(t.level),r=t.type==="log"?"":t.type,o=t.tag||"",a=`
@@ -406,5 +406,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
406
406
  ctx.font = "48px serif";
407
407
  ctx.fillText("Hello Canvas", 10, 50);
408
408
  }
409
- `}}}}]},{title:"HTML 标签",componentName:"CNativeTag",props:[{name:"htmlTag",title:"标签名",valueType:"string",setters:[{componentName:"SelectSetter",props:{options:fe.HTMl_TAGS.map(e=>({name:e,value:e}))}}]},bo],isContainer:!0,groupName:"原子组件",snippets:[{title:"HTML",snapshotText:"HTML",category:"基础组件",schema:{props:{htmlTag:"div"}}}]}];_8.forEach(e=>{e.events=cOe});const dOe=_8.map(e=>({...e,npm:{name:e.componentName,package:C8,version:S8}})),fOe=[...dOe,...uOe];class E8 extends v.Component{constructor(n){super(n);Z(this,"currentSelectNode");Z(this,"pluginManager");Z(this,"workbenchRef",v.createRef());Z(this,"pageSchema");Z(this,"pageModel");Z(this,"material");Z(this,"emitter");Z(this,"assetsPackageListManager");Z(this,"updatePage",n=>{this.pageModel.updatePage(n)});Z(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 Pse(r,s).load();const c=v5(r,s);let u=y5(c);o!=null&&o.formatComponents&&(u=o.formatComponents(u)),a==null||a.updateRenderComponents(u),this.pageModel.materialsModel.addMaterials(n),this.emitter.emit("updateMaterials")});Z(this,"refresh",async()=>{this.pageModel.reloadPage(this.pageModel.export("design"))});Z(this,"getWorkbench",()=>this.workbenchRef.current);this.pageSchema=n.schema,this.material=n.material,this.currentSelectNode=null,window.__CHAMELEON_ENG__=this,this.assetsPackageListManager=new HI(n.assetPackagesList||[]);try{this.pageModel=new fe.CPage(this.pageSchema,{materials:this.material||[],assetPackagesList:n.assetPackagesList||[]})}catch(r){console.error(r),this.pageModel=new fe.CPage(fe.EmptyPage)}this.emitter=kd()}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 x$({engine:this,getWorkbench:()=>this.workbenchRef.current,emitter:this.emitter,pageModel:this.pageModel,i18n:qd,assetsPackageListManager:this.assetsPackageListManager});this.pluginManager=r,r.customPlugin("Designer",d=>(d.ctx.config.beforeInitRender=f$,d.ctx.config.customRender=h$(this.props.components||{}),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 qd}render(){return w.jsx("div",{className:Ve([Vse.engineContainer,this.props.className]),style:this.props.style,children:w.jsx(g$,{ref:this.workbenchRef,emitter:this.emitter})})}}Z(E8,"version","0.3.3");exports.AdvancePanel=TS;exports.AdvancePanelConfig=AS;exports.AssetsPackageListManager=HI;exports.BUILD_IN_SETTER_MAP=ko;exports.CSSEditor=y8;exports.CSSPropertiesEditor=Ux;exports.CSSPropertiesVariableBindEditor=a6;exports.ClassNameEditor=s6;exports.ComponentLibPlugin=Ac;exports.ComponentStatePanel=NS;exports.ComponentStatePanelConfig=RS;exports.CustomSchemaForm=Wc;exports.DEFAULT_PLUGIN_LIST=x8;exports.DEFAULT_PLUGIN_NAME_MAP=w8;exports.DesignerPlugin=Pc;exports.DesignerSizer=lOe;exports.DisplaySourceSchema=b8;exports.Engine=E8;exports.GlobalStatePanelPlugin=Jc;exports.HistoryPlugin=Qc;exports.HotkeysPlugin=Zc;exports.InnerComponentMeta=fOe;exports.LOGGER=ur;exports.MonacoEditor=$s;exports.OutlineTreePlugin=Mc;exports.PLUGIN_NAME=oi;exports.PluginManager=x$;exports.PropertyPanelConfig=OS;exports.RightPanelPlugin=Xc;exports.SetterSwitcher=Th;exports.VisualPanelPlus=qS;exports.VisualPanelPlusConfig=US;exports.Workbench=g$;exports.beforeInitRender=f$;exports.defaultPropertyOptions=Ed;exports.ensureKeyExist=Rc;exports.formatCSSTextProperty=FI;exports.formatCssToNodeVal=BI;exports.formatNodeValToEditor=VI;exports.formatStyleProperty=rb;exports.getColorFromStr=ob;exports.getDefaultRender=h$;exports.getUniqueAssetsList=j1;exports.parseBoxShadowString=dd;exports.plugins=sOe;exports.registerCustomSetter=_D;exports.sageJSONParse=p$;exports.styleArr2Obj=LI;exports.styleList2Text=zI;exports.styleObjToArr=DI;exports.waitReactUpdate=to;Object.keys(ni).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>ni[e]})});
409
+ `}}}}]},{title:"HTML 标签",componentName:"CNativeTag",props:[{name:"htmlTag",title:"标签名",valueType:"string",setters:[{componentName:"SelectSetter",props:{options:fe.HTMl_TAGS.map(e=>({name:e,value:e}))}}]},bo],isContainer:!0,groupName:"原子组件",snippets:[{title:"HTML",snapshotText:"HTML",category:"基础组件",schema:{props:{htmlTag:"div"}}}]}];_8.forEach(e=>{e.events=cOe});const dOe=_8.map(e=>({...e,npm:{name:e.componentName,package:C8,version:S8}})),fOe=[...dOe,...uOe];class E8 extends v.Component{constructor(n){super(n);Z(this,"currentSelectNode");Z(this,"pluginManager");Z(this,"workbenchRef",v.createRef());Z(this,"pageSchema");Z(this,"pageModel");Z(this,"material");Z(this,"emitter");Z(this,"assetsPackageListManager");Z(this,"updatePage",n=>{this.pageModel.updatePage(n)});Z(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 Pse(r,s).load();const c=v5(r,s);let u=y5(c);o!=null&&o.formatComponents&&(u=o.formatComponents(u)),a==null||a.updateRenderComponents(u),this.pageModel.materialsModel.addMaterials(n),this.emitter.emit("updateMaterials")});Z(this,"refresh",async()=>{this.pageModel.reloadPage(this.pageModel.export("design"))});Z(this,"getWorkbench",()=>this.workbenchRef.current);this.pageSchema=n.schema,this.material=n.material,this.currentSelectNode=null,window.__CHAMELEON_ENG__=this,this.assetsPackageListManager=new HI(n.assetPackagesList||[]);try{this.pageModel=new fe.CPage(this.pageSchema,{materials:this.material||[],assetPackagesList:n.assetPackagesList||[]})}catch(r){console.error(r),this.pageModel=new fe.CPage(fe.EmptyPage)}this.emitter=kd()}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 x$({engine:this,getWorkbench:()=>this.workbenchRef.current,emitter:this.emitter,pageModel:this.pageModel,i18n:qd,assetsPackageListManager:this.assetsPackageListManager});this.pluginManager=r,r.customPlugin("Designer",d=>(d.ctx.config.beforeInitRender=f$,d.ctx.config.customRender=h$({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 qd}render(){return w.jsx("div",{className:Ve([Vse.engineContainer,this.props.className]),style:this.props.style,children:w.jsx(g$,{ref:this.workbenchRef,emitter:this.emitter})})}}Z(E8,"version","0.3.4");exports.AdvancePanel=TS;exports.AdvancePanelConfig=AS;exports.AssetsPackageListManager=HI;exports.BUILD_IN_SETTER_MAP=ko;exports.CSSEditor=y8;exports.CSSPropertiesEditor=Ux;exports.CSSPropertiesVariableBindEditor=a6;exports.ClassNameEditor=s6;exports.ComponentLibPlugin=Ac;exports.ComponentStatePanel=NS;exports.ComponentStatePanelConfig=RS;exports.CustomSchemaForm=Wc;exports.DEFAULT_PLUGIN_LIST=x8;exports.DEFAULT_PLUGIN_NAME_MAP=w8;exports.DesignerPlugin=Pc;exports.DesignerSizer=lOe;exports.DisplaySourceSchema=b8;exports.Engine=E8;exports.GlobalStatePanelPlugin=Jc;exports.HistoryPlugin=Qc;exports.HotkeysPlugin=Zc;exports.InnerComponentMeta=fOe;exports.LOGGER=ur;exports.MonacoEditor=$s;exports.OutlineTreePlugin=Mc;exports.PLUGIN_NAME=oi;exports.PluginManager=x$;exports.PropertyPanelConfig=OS;exports.RightPanelPlugin=Xc;exports.SetterSwitcher=Th;exports.VisualPanelPlus=qS;exports.VisualPanelPlusConfig=US;exports.Workbench=g$;exports.beforeInitRender=f$;exports.defaultPropertyOptions=Ed;exports.ensureKeyExist=Rc;exports.formatCSSTextProperty=FI;exports.formatCssToNodeVal=BI;exports.formatNodeValToEditor=VI;exports.formatStyleProperty=rb;exports.getColorFromStr=ob;exports.getDefaultRender=h$;exports.getUniqueAssetsList=j1;exports.parseBoxShadowString=dd;exports.plugins=sOe;exports.registerCustomSetter=_D;exports.sageJSONParse=p$;exports.styleArr2Obj=LI;exports.styleList2Text=zI;exports.styleObjToArr=DI;exports.waitReactUpdate=to;Object.keys(ni).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>ni[e]})});
410
410
  //# sourceMappingURL=index.cjs.map