@chamn/render 0.3.0 → 0.3.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.umd.js CHANGED
@@ -35,7 +35,7 @@
35
35
  func.apply(null, args);
36
36
  }
37
37
  }
38
- }`,nodeContext:e.context,storeManager:e.storeManager,$$response:e.$$response});let o=r;return Array.isArray(t.args)&&(o=t.args.map(a=>{const i=[e.$$response,...r].filter(Boolean);return bt(a,e)(...i)})),n(...o)},Th=(t,e)=>async(...r)=>{const o=bt(t.currentValue,e)(...r);let a;if(o!=null&&o.then?a=await o:a=o,t.valueType==="STATE"){const i=t.targetValueName,s=e.storeManager.getStore(i.nodeId);s&&s.setState({[i.keyPath]:a})}else t.valueType==="MEMORY"&&(e.actionVariableSpace[t.targetValueName]=a);return a},Oe=(t={},e)=>{const{$$context:r,runtimeComponentCache:n,getComponent:o,storeManager:a}=e,i=t,s=f=>{if(Array.isArray(f))return f.map(u=>s(u));if($r(f))return s(f.value);if(_h(f)){const u=f.value,d=u.value;if(!d)return console.warn("slot value is null, this maybe cause some error, pls check it",t),()=>{};const l=h=>{const y=`${h.id}-${oe}`;if(n.get(h.id))return{key:y,component:n.get(h.id)};const p=o(h),g=Dr(p,h,{...e}),m=u.params||[];return{component:(...O)=>{const N=De(O,m),$=Pr({params:N,nodeRefs:r.nodeRefs},r);return ae(g,{$$context:$,key:y})},key:y}};if(Array.isArray(d)){const h=d==null?void 0:d.map(y=>l(y));return(...y)=>h.map(p=>{if(Tn(p.component)){const m=p.component;return w.createElement(m,{$$context:r,key:p.key})}else{const m=p.component;return m==null?void 0:m(...y)}})}else return l(d).component}else{if(vt(f))return ft(f.value,r||{});if(na(f)){const u=f;return Gt({funcBody:u.value,funcName:u.name||"",nodeContext:r,storeManager:a})}else{if(yh(f))return Ft(f,{context:r,storeManager:a,actionVariableSpace:{}});if(Et(f)){let u=f;$r(f)&&(u=f.value);const d=u,l={};return Object.keys(u).forEach(h=>{l[h]=s(d[h])}),l}else return f}}},c={};return Object.keys(i).forEach(f=>{const u=i[f];c[f]=s(u)}),c},Ah=(t,e)=>{const{runtimeComponentCache:r,$$context:n={},getComponent:o,renderMode:a}=e,{$$context:i,idx:s,...c}=e;return typeof t=="string"?ae(t):bh(t)?(({currentNode:u})=>{const d=u.value.id;let l=null;if(r.get(d)){const p=r.get(d);l=p==null?void 0:p.component}else{const p=o(u);l=Dr(p,u,{...c}),!r.get(d)&&a!=="design"&&r.set(d,{component:l})}const h=`${d}-${oe}`;return ae(l,{$$context:n,$$nodeModel:t,key:h})})({currentNode:t}):void 0},Dr=(t,e,r)=>{const{storeManager:n,variableManager:o,onGetRef:a,onComponentMount:i,onComponentDestroy:s,refManager:c,processNodeConfigHook:f,requestAPI:u}=r,{...d}=r;class l extends w.Component{constructor(p){super(p);j(this,"_CONDITION",!0);j(this,"_DESIGN_BOX",!1);j(this,"_NODE_MODEL",e);j(this,"_NODE_ID",e.id);j(this,"UNIQUE_ID",`${e.id}_${Z()}`);j(this,"targetComponentRef");j(this,"listenerHandle",[]);j(this,"storeState");j(this,"storeListenDisposeList",[]);j(this,"domHeader");j(this,"mediaStyleDomMap",{});j(this,"variableSpace");j(this,"nodeName");j(this,"updateState",p=>{this.storeState.setState(p)});j(this,"getStyleDomById",p=>{const g=this.mediaStyleDomMap;let m=g[p];return m||(m=document.createElement("style"),g[p]=m),m.id=p,m});j(this,"addMediaCSS",()=>{var m;let p=this.domHeader;if(p||(p=(m=document.getElementsByTagName("head"))==null?void 0:m[0],this.domHeader=p),!this.domHeader)return;const g=this._NODE_MODEL.value.css;g&&g.value.forEach(v=>{var N;const C=`${this.UNIQUE_ID}_${v.state}`;let O=Le(this._NODE_MODEL);if(v.state!=="normal"&&(O=`${O}:${v.state}`),v.text){const $=this.getStyleDomById(C);$.innerText=`.${O} { ${v.text} }`,p==null||p.appendChild($)}(N=v.media)!=null&&N.length&&v.media.forEach($=>{const L=`${C}_${$.type}_${$.value}`,A=this.getStyleDomById(L);A.media=`screen and (${$.type}:${$.value}px)`,A.innerHTML=`.${O} { ${$.text} }`,p==null||p.appendChild(A)})})});j(this,"removeMediaCSS",()=>{const p=this.mediaStyleDomMap;Object.keys(p).forEach(g=>{var m;(m=this.domHeader)==null||m.removeChild(p[g])}),this.mediaStyleDomMap={}});j(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(p=>p()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=w.createRef(),this.state=e.value.state||{};const g=e.value.nodeName||e.id;this.nodeName=g;const m=n.getStore(g);m?(this.storeState=m,m.setState({...e.value.state||{}})):this.storeState=n.addStore(g,()=>({...e.value.state||{}})),this.storeState.subscribe(C=>{this.setState({...C})}),this.connectStore();const v=o.get(g);v?this.variableSpace=v:(this.variableSpace={staticVar:{},methods:{}},o.add(g,this.variableSpace))}connectStore(){const p=sa(e.props,O=>!!vt(O)),g=sa({css:e.value.css,class:e.value.classNames},O=>!!vt(O));let m=[];[...p,...g].map(O=>{const N=O.val,$=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],L=xn(N.value,$);m=[...m,...L]}).filter(Boolean);const v=Array.from(new Set(m)),C=[];v.length&&v.forEach(O=>{n.getStore(O)||(n.addStore(O,()=>({})),console.warn(n,O,"not exits"));const $=n.connect(O,L=>{this.setState({...L})});C.push($)}),this.storeListenDisposeList=C}componentDidMount(){var v;this.addMediaCSS(),a==null||a(this.targetComponentRef,e,this),i==null||i(this,e);const p=()=>{n.setStore(e.value.nodeName||e.id,this.storeState),this.storeState.setState({...this.state,...e.value.state||{}}),this.rebuildNode()},g=xr,m=(v=e.value.eventListener)==null?void 0:v.find(C=>C.name===g);m&&Ft(m.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})(),e.onChange(p)}componentWillUnmount(){var m;this.storeListenDisposeList.forEach(v=>v()),this.removeMediaCSS(),s==null||s(this,e);const p=Rr,g=(m=e.value.eventListener)==null?void 0:m.find(v=>v.name===p);g&&Ft(g.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})()}transformMethods(p){const{context:g}=p,m=Oe({methods:e.value.methods},{$$context:g,...d}),v=e.value.methods||[],C=m.methods,O=v.reduce((N,$,L)=>(N[$.name]=C[L],N),{});g.methods=O,this.variableSpace.methods=Object.assign(this.variableSpace.methods,O)}processRootContext(p){e.value.componentName===Dt.ROOT_CONTAINER&&(p.globalState=this.state,p.updateGlobalState=this.updateState,p.requestAPI=u,p.getGlobalState=()=>this.state)}processNodeClassName(p,g){var C;const m=((C=e.value.classNames)==null?void 0:C.map(O=>{var L;const N=O.name;return(vt(O.status)?ft(((L=O.status)==null?void 0:L.value)||"",g):!1)?N:""}))||[];let v=`${p??""} ${m.join(" ")}`.trim();return e.value.css&&(v=`${Le(e)} ${v}`.trim()),v}processNodeStyle(p){if(!e.value.style)return{};const g=Oe({style:e.value.style},{$$context:p,...d});return In(g.style||[])}processNodeChild(p,g){let m=[];if(p!==void 0)m=Array.isArray(p)?p:[p];else{const v=[];e.value.children.forEach((O,N)=>{const $=Ah(O,{$$context:g,idx:N,...d});v.push($)}),m=v}return m}processNodeConditionAndConfigHook(p,g,m){let v=e.value.condition??!0;typeof v!="boolean"&&(v=ft(v.value,m||{}));let C={condition:v,props:p};f&&(C=f(C,e));const O=ae(t,C.props,...g);return this._CONDITION=C.condition,C.condition?O:w.createElement("div",{style:{display:"none"}},O)}processNodeEventListener(p){const g=e.value.eventListener,m={};return g==null||g.forEach(v=>{if(ia.includes(v.name))return;const C=Ft(v.func,{context:p,storeManager:n,actionVariableSpace:{}});m[v.name]=C}),m}createCurrentNodeCtx(){const{$$context:p}=this.props,g=e.value.nodeName||e.id,m=e.id,v={state:this.state||{},staticVar:this.variableSpace.staticVar,updateState:this.updateState,storeManager:n,getState:()=>n.getStateObj(g),getStateObj:()=>n.getStateObj(g),getStateObjById:O=>n.getStateObj(O),stateManager:n.getStateSnapshot(),getMethods:()=>{const O=o.get(m).methods,N=c.get(m).current;return Fe(O,N)},getMethodsById:O=>{const N=o.get(O).methods,$=c.get(O).current;return Fe(N,$)},getStaticVar:()=>o.get(g).staticVar,getStaticVarById:O=>o.get(O).staticVar,nodeRefs:p.nodeRefs};return this.processRootContext(v),Pr(v,p)}renderCore(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});let C=Oe(m,{$$context:v,...d});const O=this.processNodeClassName(C.className,v);C.className=O;const N=this.processNodeStyle(v);C.style=N;const{children:$}=C;delete C.children;const L=this.processNodeChild($,v);if(C.ref=this.targetComponentRef,e.value.eventListener){const Vt=this.processNodeEventListener(v);C={...C,...Vt}}return this.processNodeConditionAndConfigHook(C,L,v)}renderLoop(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});const C=e.value.loop;let O=[];if(C&&C.open){this.targetComponentRef.current=[];let N=C.data||[];if(vt(C.data)){const $=C.data;N=ft($.value,v||{})}return O=N.map((...$)=>{const L=$[1],A=[C.forName||"item",C.forIndex||"index"],Vt=De($,A);let st="loopData";C.name&&(st=`${st}${C.name}`);const ct=Pr({[st]:Vt,nodeRefs:v.nodeRefs},v),tt=Oe(m,{$$context:ct,...d}),Zh=this.processNodeClassName(tt.className,ct);tt.className=Zh;const tm=this.processNodeStyle(ct);tt.style=tm;const{children:em}=tt;delete tt.children;const rm=this.processNodeChild(em,ct);if(tt.key=`${tt.key}-${L}`,vt(C.key)){const Vr=C.key,nm=ft(Vr.value,ct||{});tt.key+=`-${nm}`}return tt.ref=Vr=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[L]=Vr},this.processNodeConditionAndConfigHook(tt,rm,ct)}),O}}render(){const p=e.value.loop;return p&&p.open?this.renderLoop():this.renderCore()}}return j(l,"__CP_TYPE__",oe),l.displayName=`${e.value.componentName}Dynamic`,l};class ca{constructor(){j(this,"renderMode","normal");j(this,"components",{});j(this,"storeManager",new xc);j(this,"variableManager",new Rc);j(this,"runtimeComponentCache",new Map);j(this,"onGetRef");j(this,"onGetComponent");j(this,"onComponentMount");j(this,"refManager",new Ve);j(this,"onComponentDestroy");j(this,"processNodeConfigHook");j(this,"requestAPI",async e=>(console.log("🚀 ~ DefineReactAdapter ~ requestAPI ~ params:",e),new Promise(r=>{setTimeout(()=>{r({a:5555})},100)})))}getComponent(e){var o;const r=e.value.componentName;let n=Pn(r,this.components);return An(n)||(n=Mn(n),this.components[r]=n),this.onGetComponent&&(n=(o=this.onGetComponent)==null?void 0:o.call(this,n,e)),n}pageRender(e,{components:r,onGetRef:n,refManager:o,$$context:a={nodeRefs:o},onGetComponent:i,onComponentMount:s,onComponentDestroy:c,renderMode:f,processNodeConfigHook:u,requestAPI:d}){this.renderMode=f,this.components=r,this.onGetRef=n,this.onGetComponent=i,this.onComponentMount=s,this.onComponentDestroy=c,this.processNodeConfigHook=u,this.refManager=o,this.requestAPI=d;const l=e.value.componentsTree,h=this.getComponent(l),y=Dr(h,e.value.componentsTree,{storeManager:this.storeManager,variableManager:this.variableManager,runtimeComponentCache:this.runtimeComponentCache,getComponent:this.getComponent.bind(this),refManager:this.refManager,onGetRef:this.onGetRef,processNodeConfigHook:u,onComponentMount:s,onComponentDestroy:c,renderMode:f,requestAPI:d}),p={},g=l.props;return Object.keys(g).forEach(m=>{p[m]=g[m].value}),p.$$context=a,ae(y,p)}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const Mh=Ur(new ca);function Ih(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Lr={exports:{}},ie={};/**
38
+ }`,nodeContext:e.context,storeManager:e.storeManager,$$response:e.$$response});let o=r;return Array.isArray(t.args)&&(o=t.args.map(a=>{const i=[e.$$response,...r].filter(Boolean);return bt(a,e)(...i)})),n(...o)},Th=(t,e)=>async(...r)=>{const o=bt(t.currentValue,e)(...r);let a;if(o!=null&&o.then?a=await o:a=o,t.valueType==="STATE"){const i=t.targetValueName,s=e.storeManager.getStore(i.nodeId);s&&s.setState({[i.keyPath]:a})}else t.valueType==="MEMORY"&&(e.actionVariableSpace[t.targetValueName]=a);return a},Oe=(t={},e)=>{const{$$context:r,runtimeComponentCache:n,getComponent:o,storeManager:a}=e,i=t,s=f=>{if(Array.isArray(f))return f.map(u=>s(u));if($r(f))return s(f.value);if(_h(f)){const u=f.value,d=u.value;if(!d)return console.warn("slot value is null, this maybe cause some error, pls check it",t),()=>{};const l=h=>{const y=`${h.id}-${oe}`;if(n.get(h.id))return{key:y,component:n.get(h.id)};const p=o(h),g=Dr(p,h,{...e}),m=u.params||[];return{component:(...O)=>{const N=De(O,m),$=Pr({params:N,nodeRefs:r.nodeRefs},r);return ae(g,{$$context:$,key:y})},key:y}};if(Array.isArray(d)){const h=d==null?void 0:d.map(y=>l(y));return(...y)=>h.map(p=>{if(Tn(p.component)){const m=p.component;return w.createElement(m,{$$context:r,key:p.key})}else{const m=p.component;return m==null?void 0:m(...y)}})}else return l(d).component}else{if(vt(f))return ft(f.value,r||{});if(na(f)){const u=f;return Gt({funcBody:u.value,funcName:u.name||"",nodeContext:r,storeManager:a})}else{if(yh(f))return Ft(f,{context:r,storeManager:a,actionVariableSpace:{}});if(Et(f)){let u=f;$r(f)&&(u=f.value);const d=u,l={};return Object.keys(u).forEach(h=>{l[h]=s(d[h])}),l}else return f}}},c={};return Object.keys(i).forEach(f=>{const u=i[f];c[f]=s(u)}),c},Ah=(t,e)=>{const{runtimeComponentCache:r,$$context:n={},getComponent:o,renderMode:a}=e,{$$context:i,idx:s,...c}=e;return typeof t=="string"?ae(t):bh(t)?(({currentNode:u})=>{const d=u.value.id;let l=null;if(r.get(d)){const p=r.get(d);l=p==null?void 0:p.component}else{const p=o(u);l=Dr(p,u,{...c}),!r.get(d)&&a!=="design"&&r.set(d,{component:l})}const h=`${d}-${oe}`;return ae(l,{$$context:n,$$nodeModel:t,key:h})})({currentNode:t}):void 0},Dr=(t,e,r)=>{const{storeManager:n,variableManager:o,onGetRef:a,onComponentMount:i,onComponentDestroy:s,refManager:c,processNodeConfigHook:f,requestAPI:u}=r,{...d}=r;class l extends w.Component{constructor(p){super(p);j(this,"_CONDITION",!0);j(this,"_DESIGN_BOX",!1);j(this,"_NODE_MODEL",e);j(this,"_NODE_ID",e.id);j(this,"UNIQUE_ID",`${e.id}_${Z()}`);j(this,"targetComponentRef");j(this,"listenerHandle",[]);j(this,"storeState");j(this,"storeListenDisposeList",[]);j(this,"domHeader");j(this,"mediaStyleDomMap",{});j(this,"variableSpace");j(this,"nodeName");j(this,"updateState",p=>{this.storeState.setState(p)});j(this,"getStyleDomById",p=>{const g=this.mediaStyleDomMap;let m=g[p];return m||(m=document.createElement("style"),g[p]=m),m.id=p,m});j(this,"addMediaCSS",()=>{var m;let p=this.domHeader;if(p||(p=(m=document.getElementsByTagName("head"))==null?void 0:m[0],this.domHeader=p),!this.domHeader)return;const g=this._NODE_MODEL.value.css;g&&g.value.forEach(v=>{var N;const C=`${this.UNIQUE_ID}_${v.state}`;let O=Le(this._NODE_MODEL);if(v.state!=="normal"&&(O=`${O}:${v.state}`),v.text){const $=this.getStyleDomById(C);$.innerText=`.${O} { ${v.text} }`,p==null||p.appendChild($)}(N=v.media)!=null&&N.length&&v.media.forEach($=>{const L=`${C}_${$.type}_${$.value}`,A=this.getStyleDomById(L);A.media=`screen and (${$.type}:${$.value}px)`,A.innerHTML=`.${O} { ${$.text} }`,p==null||p.appendChild(A)})})});j(this,"removeMediaCSS",()=>{const p=this.mediaStyleDomMap;Object.keys(p).forEach(g=>{var m;(m=this.domHeader)==null||m.removeChild(p[g])}),this.mediaStyleDomMap={}});j(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(p=>p()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=w.createRef(),this.state=e.value.state||{};const g=e.value.nodeName||e.id;this.nodeName=g;const m=n.getStore(g);m?(this.storeState=m,m.setState({...e.value.state||{}})):this.storeState=n.addStore(g,()=>({...e.value.state||{}})),this.storeState.subscribe(C=>{this.setState({...C})}),this.connectStore();const v=o.get(g);v?this.variableSpace=v:(this.variableSpace={staticVar:{},methods:{}},o.add(g,this.variableSpace))}connectStore(){const p=sa(e.props,O=>!!vt(O)),g=sa({css:e.value.css,class:e.value.classNames},O=>!!vt(O));let m=[];[...p,...g].map(O=>{const N=O.val,$=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],L=xn(N.value,$);m=[...m,...L]}).filter(Boolean);const v=Array.from(new Set(m)),C=[];v.length&&v.forEach(O=>{n.getStore(O)||(n.addStore(O,()=>({})),console.warn(n,O,"not exits"));const $=n.connect(O,L=>{this.setState({...L})});C.push($)}),this.storeListenDisposeList=C}componentDidMount(){var v;this.addMediaCSS(),a==null||a(this.targetComponentRef,e,this),i==null||i(this,e);const p=()=>{n.setStore(e.value.nodeName||e.id,this.storeState),this.storeState.setState({...this.state,...e.value.state||{}}),this.rebuildNode()},g=xr,m=(v=e.value.eventListener)==null?void 0:v.find(C=>C.name===g);m&&Ft(m.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})(),e.onChange(p)}componentWillUnmount(){var m;this.storeListenDisposeList.forEach(v=>v()),this.removeMediaCSS(),s==null||s(this,e);const p=Rr,g=(m=e.value.eventListener)==null?void 0:m.find(v=>v.name===p);g&&Ft(g.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})()}transformMethods(p){const{context:g}=p,m=Oe({methods:e.value.methods},{$$context:g,...d}),v=e.value.methods||[],C=m.methods,O=v.reduce((N,$,L)=>(N[$.name]=C[L],N),{});g.methods=O,this.variableSpace.methods=Object.assign(this.variableSpace.methods,O)}processRootContext(p){e.value.componentName===Dt.ROOT_CONTAINER&&(p.globalState=this.state,p.updateGlobalState=this.updateState,p.requestAPI=u,p.getGlobalState=()=>this.state)}processNodeClassName(p,g){var C;const m=((C=e.value.classNames)==null?void 0:C.map(O=>{var L;const N=O.name;return(vt(O.status)?ft(((L=O.status)==null?void 0:L.value)||"",g):!1)?N:""}))||[];let v=`${p??""} ${m.join(" ")}`.trim();return e.value.css&&(v=`${Le(e)} ${v}`.trim()),v}processNodeStyle(p){if(!e.value.style)return{};const g=Oe({style:e.value.style},{$$context:p,...d});return In(g.style||[])}processNodeChild(p,g){let m=[];if(p!==void 0)m=Array.isArray(p)?p:[p];else{const v=[];e.value.children.forEach((O,N)=>{const $=Ah(O,{$$context:g,idx:N,...d});v.push($)}),m=v}return m}processNodeConditionAndConfigHook(p,g,m){let v=e.value.condition??!0;typeof v!="boolean"&&(v=ft(v.value,m||{}));let C={condition:v,props:p};f&&(C=f(C,e));const O=ae(t,C.props,...g);return this._CONDITION=C.condition,C.condition?O:w.createElement("div",{style:{display:"none"}},O)}processNodeEventListener(p){const g=e.value.eventListener,m={};return g==null||g.forEach(v=>{if(ia.includes(v.name))return;const C=Ft(v.func,{context:p,storeManager:n,actionVariableSpace:{}});m[v.name]=C}),m}createCurrentNodeCtx(){const{$$context:p}=this.props,g=e.value.nodeName||e.id,m=e.id,v={state:this.state||{},staticVar:this.variableSpace.staticVar,updateState:this.updateState,storeManager:n,getState:()=>n.getStateObj(g),getStateObj:()=>n.getStateObj(g),getStateObjById:O=>n.getStateObj(O),stateManager:n.getStateSnapshot(),getMethods:()=>{const O=o.get(m).methods,N=c.get(m).current;return Fe(O,N)},getMethodsById:O=>{const N=o.get(O).methods,$=c.get(O).current;return Fe(N,$)},getStaticVar:()=>o.get(g).staticVar,getStaticVarById:O=>o.get(O).staticVar,nodeRefs:p.nodeRefs};return this.processRootContext(v),Pr(v,p)}renderCore(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});let C=Oe(m,{$$context:v,...d});const O=this.processNodeClassName(C.className,v);C.className=O;const N=this.processNodeStyle(v);C.style=N;const{children:$}=C;delete C.children;const L=this.processNodeChild($,v);if(C.ref=this.targetComponentRef,e.value.eventListener){const Vt=this.processNodeEventListener(v);C={...C,...Vt}}return this.processNodeConditionAndConfigHook(C,L,v)}renderLoop(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});const C=e.value.loop;let O=[];if(C&&C.open){this.targetComponentRef.current=[];let N=C.data||[];if(vt(C.data)){const $=C.data;N=ft($.value,v||{})}return O=N.map((...$)=>{const L=$[1],A=[C.forName||"item",C.forIndex||"index"],Vt=De($,A);let st="loopData";C.name&&(st=`${st}${C.name}`);const ct=Pr({[st]:Vt,nodeRefs:v.nodeRefs},v),tt=Oe(m,{$$context:ct,...d}),Zh=this.processNodeClassName(tt.className,ct);tt.className=Zh;const tm=this.processNodeStyle(ct);tt.style=tm;const{children:em}=tt;delete tt.children;const rm=this.processNodeChild(em,ct);if(tt.key=`${tt.key}-${L}`,vt(C.key)){const Vr=C.key,nm=ft(Vr.value,ct||{});tt.key+=`-${nm}`}return tt.ref=Vr=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[L]=Vr},this.processNodeConditionAndConfigHook(tt,rm,ct)}),O}}render(){const p=e.value.loop;return p&&p.open?this.renderLoop():this.renderCore()}}return j(l,"__CP_TYPE__",oe),l.displayName=`${e.value.componentName}Dynamic`,l};class ca{constructor(){j(this,"renderMode","normal");j(this,"components",{});j(this,"storeManager",new xc);j(this,"variableManager",new Rc);j(this,"runtimeComponentCache",new Map);j(this,"onGetRef");j(this,"onGetComponent");j(this,"onComponentMount");j(this,"refManager",new Ve);j(this,"onComponentDestroy");j(this,"processNodeConfigHook");j(this,"requestAPI",async e=>{throw console.log(e),new Error("Need to implement requestAPI for Render")})}getComponent(e){var o;const r=e.value.componentName;let n=Pn(r,this.components);return An(n)||(n=Mn(n),this.components[r]=n),this.onGetComponent&&(n=(o=this.onGetComponent)==null?void 0:o.call(this,n,e)),n}pageRender(e,{components:r,onGetRef:n,refManager:o,$$context:a={nodeRefs:o},onGetComponent:i,onComponentMount:s,onComponentDestroy:c,renderMode:f,processNodeConfigHook:u,requestAPI:d}){this.renderMode=f,this.components=r,this.onGetRef=n,this.onGetComponent=i,this.onComponentMount=s,this.onComponentDestroy=c,this.processNodeConfigHook=u,this.refManager=o,this.requestAPI=d;const l=e.value.componentsTree,h=this.getComponent(l),y=Dr(h,e.value.componentsTree,{storeManager:this.storeManager,variableManager:this.variableManager,runtimeComponentCache:this.runtimeComponentCache,getComponent:this.getComponent.bind(this),refManager:this.refManager,onGetRef:this.onGetRef,processNodeConfigHook:u,onComponentMount:s,onComponentDestroy:c,renderMode:f,requestAPI:d}),p={},g=l.props;return Object.keys(g).forEach(m=>{p[m]=g[m].value}),p.$$context=a,ae(y,p)}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const Mh=Ur(new ca);function Ih(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Lr={exports:{}},ie={};/**
39
39
  * @license React
40
40
  * react-jsx-runtime.production.min.js
41
41
  *