@chamn/render 0.3.0 → 0.3.1
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -7
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
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 s=[e.$$response,...r].filter(Boolean);return lt(a,e)(...s)})),n(...o)},Ph=(t,e)=>async(...r)=>{const o=lt(t.currentValue,e)(...r);let a;if(o!=null&&o.then?a=await o:a=o,t.valueType==="STATE"){const s=t.targetValueName,i=e.storeManager.getStore(s.nodeId);i&&i.setState({[s.keyPath]:a})}else t.valueType==="MEMORY"&&(e.actionVariableSpace[t.targetValueName]=a);return a},se=(t={},e)=>{const{$$context:r,runtimeComponentCache:n,getComponent:o,storeManager:a}=e,s=t,i=f=>{if(Array.isArray(f))return f.map(u=>i(u));if(Ze(f))return i(f.value);if(Eh(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=Lr(p,h,{...e}),m=u.params||[];return{component:(...C)=>{const j=ar(C,m),w=tr({params:j,nodeRefs:r.nodeRefs},r);return Xt(g,{$$context:w,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(ho(p.component)){const m=p.component;return N.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(ct(f))return ut(f.value,r||{});if(ca(f)){const u=f;return te({funcBody:u.value,funcName:u.name||"",nodeContext:r,storeManager:a})}else{if(jh(f))return St(f,{context:r,storeManager:a,actionVariableSpace:{}});if(Tt(f)){let u=f;Ze(f)&&(u=f.value);const d=u,l={};return Object.keys(u).forEach(h=>{l[h]=i(d[h])}),l}else return f}}},c={};return Object.keys(s).forEach(f=>{const u=s[f];c[f]=i(u)}),c},Dh=(t,e)=>{const{runtimeComponentCache:r,$$context:n={},getComponent:o,renderMode:a}=e,{$$context:s,idx:i,...c}=e;return typeof t=="string"?Xt(t):wh(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=Lr(p,u,{...c}),!r.get(d)&&a!=="design"&&r.set(d,{component:l})}const h=`${d}-${oe}`;return Xt(l,{$$context:n,$$nodeModel:t,key:h})})({currentNode:t}):void 0},Lr=(t,e,r)=>{const{storeManager:n,variableManager:o,onGetRef:a,onComponentMount:s,onComponentDestroy:i,refManager:c,processNodeConfigHook:f,requestAPI:u}=r,{...d}=r;class l extends N.Component{constructor(p){super(p);O(this,"_CONDITION",!0);O(this,"_DESIGN_BOX",!1);O(this,"_NODE_MODEL",e);O(this,"_NODE_ID",e.id);O(this,"UNIQUE_ID",`${e.id}_${Z()}`);O(this,"targetComponentRef");O(this,"listenerHandle",[]);O(this,"storeState");O(this,"storeListenDisposeList",[]);O(this,"domHeader");O(this,"mediaStyleDomMap",{});O(this,"variableSpace");O(this,"nodeName");O(this,"updateState",p=>{this.storeState.setState(p)});O(this,"getStyleDomById",p=>{const g=this.mediaStyleDomMap;let m=g[p];return m||(m=document.createElement("style"),g[p]=m),m.id=p,m});O(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 j;const S=`${this.UNIQUE_ID}_${v.state}`;let C=Ve(this._NODE_MODEL);if(v.state!=="normal"&&(C=`${C}:${v.state}`),v.text){const w=this.getStyleDomById(S);w.innerText=`.${C} { ${v.text} }`,p==null||p.appendChild(w)}(j=v.media)!=null&&j.length&&v.media.forEach(w=>{const D=`${S}_${w.type}_${w.value}`,$=this.getStyleDomById(D);$.media=`screen and (${w.type}:${w.value}px)`,$.innerHTML=`.${C} { ${w.text} }`,p==null||p.appendChild($)})})});O(this,"removeMediaCSS",()=>{const p=this.mediaStyleDomMap;Object.keys(p).forEach(g=>{var m;(m=this.domHeader)==null||m.removeChild(p[g])}),this.mediaStyleDomMap={}});O(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(p=>p()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=N.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(S=>{this.setState({...S})}),this.connectStore();const v=o.get(g);v?this.variableSpace=v:(this.variableSpace={staticVar:{},methods:{}},o.add(g,this.variableSpace))}connectStore(){const p=Mn(e.props,C=>!!ct(C)),g=Mn({css:e.value.css,class:e.value.classNames},C=>!!ct(C));let m=[];[...p,...g].map(C=>{const j=C.val,w=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],D=yo(j.value,w);m=[...m,...D]}).filter(Boolean);const v=Array.from(new Set(m)),S=[];v.length&&v.forEach(C=>{n.getStore(C)||(n.addStore(C,()=>({})),console.warn(n,C,"not exits"));const w=n.connect(C,D=>{this.setState({...D})});S.push(w)}),this.storeListenDisposeList=S}componentDidMount(){var v;this.addMediaCSS(),a==null||a(this.targetComponentRef,e,this),s==null||s(this,e);const p=()=>{n.setStore(e.value.nodeName||e.id,this.storeState),this.storeState.setState({...this.state,...e.value.state||{}}),this.rebuildNode()},g=Pr,m=(v=e.value.eventListener)==null?void 0:v.find(S=>S.name===g);m&&St(m.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})(),e.onChange(p)}componentWillUnmount(){var m;this.storeListenDisposeList.forEach(v=>v()),this.removeMediaCSS(),i==null||i(this,e);const p=Dr,g=(m=e.value.eventListener)==null?void 0:m.find(v=>v.name===p);g&&St(g.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})()}transformMethods(p){const{context:g}=p,m=se({methods:e.value.methods},{$$context:g,...d}),v=e.value.methods||[],S=m.methods,C=v.reduce((j,w,D)=>(j[w.name]=S[D],j),{});g.methods=C,this.variableSpace.methods=Object.assign(this.variableSpace.methods,C)}processRootContext(p){e.value.componentName===Lt.ROOT_CONTAINER&&(p.globalState=this.state,p.updateGlobalState=this.updateState,p.requestAPI=u,p.getGlobalState=()=>this.state)}processNodeClassName(p,g){var S;const m=((S=e.value.classNames)==null?void 0:S.map(C=>{var D;const j=C.name;return(ct(C.status)?ut(((D=C.status)==null?void 0:D.value)||"",g):!1)?j:""}))||[];let v=`${p??""} ${m.join(" ")}`.trim();return e.value.css&&(v=`${Ve(e)} ${v}`.trim()),v}processNodeStyle(p){if(!e.value.style)return{};const g=se({style:e.value.style},{$$context:p,...d});return vo(g.style||[])}processNodeChild(p,g){let m=[];if(p!==void 0)m=Array.isArray(p)?p:[p];else{const v=[];e.value.children.forEach((C,j)=>{const w=Dh(C,{$$context:g,idx:j,...d});v.push(w)}),m=v}return m}processNodeConditionAndConfigHook(p,g,m){let v=e.value.condition??!0;typeof v!="boolean"&&(v=ut(v.value,m||{}));let S={condition:v,props:p};f&&(S=f(S,e));const C=Xt(t,S.props,...g);return this._CONDITION=S.condition,S.condition?C:N.createElement("div",{style:{display:"none"}},C)}processNodeEventListener(p){const g=e.value.eventListener,m={};return g==null||g.forEach(v=>{if(fa.includes(v.name))return;const S=St(v.func,{context:p,storeManager:n,actionVariableSpace:{}});m[v.name]=S}),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:C=>n.getStateObj(C),stateManager:n.getStateSnapshot(),getMethods:()=>{const C=o.get(m).methods,j=c.get(m).current;return ke(C,j)},getMethodsById:C=>{const j=o.get(C).methods,w=c.get(C).current;return ke(j,w)},getStaticVar:()=>o.get(g).staticVar,getStaticVarById:C=>o.get(C).staticVar,nodeRefs:p.nodeRefs};return this.processRootContext(v),tr(v,p)}renderCore(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});let S=se(m,{$$context:v,...d});const C=this.processNodeClassName(S.className,v);S.className=C;const j=this.processNodeStyle(v);S.style=j;const{children:w}=S;delete S.children;const D=this.processNodeChild(w,v);if(S.ref=this.targetComponentRef,e.value.eventListener){const bt=this.processNodeEventListener(v);S={...S,...bt}}return this.processNodeConditionAndConfigHook(S,D,v)}renderLoop(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});const S=e.value.loop;let C=[];if(S&&S.open){this.targetComponentRef.current=[];let j=S.data||[];if(ct(S.data)){const w=S.data;j=ut(w.value,v||{})}return C=j.map((...w)=>{const D=w[1],$=[S.forName||"item",S.forIndex||"index"],bt=ar(w,$);let ot="loopData";S.name&&(ot=`${ot}${S.name}`);const at=tr({[ot]:bt,nodeRefs:v.nodeRefs},v),Q=se(m,{$$context:at,...d}),ya=this.processNodeClassName(Q.className,at);Q.className=ya;const ba=this.processNodeStyle(at);Q.style=ba;const{children:_a}=Q;delete Q.children;const Sa=this.processNodeChild(_a,at);if(Q.key=`${Q.key}-${D}`,ct(S.key)){const Oe=S.key,Ca=ut(Oe.value,at||{});Q.key+=`-${Ca}`}return Q.ref=Oe=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[D]=Oe},this.processNodeConditionAndConfigHook(Q,Sa,at)}),C}}render(){const p=e.value.loop;return p&&p.open?this.renderLoop():this.renderCore()}}return O(l,"__CP_TYPE__",oe),l.displayName=`${e.value.componentName}Dynamic`,l};class da{constructor(){O(this,"renderMode","normal");O(this,"components",{});O(this,"storeManager",new Vc);O(this,"variableManager",new kc);O(this,"runtimeComponentCache",new Map);O(this,"onGetRef");O(this,"onGetComponent");O(this,"onComponentMount");O(this,"refManager",new sr);O(this,"onComponentDestroy");O(this,"processNodeConfigHook");O(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=_o(r,this.components);return mo(n)||(n=go(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:s,onComponentMount:i,onComponentDestroy:c,renderMode:f,processNodeConfigHook:u,requestAPI:d}){this.renderMode=f,this.components=r,this.onGetRef=n,this.onGetComponent=s,this.onComponentMount=i,this.onComponentDestroy=c,this.processNodeConfigHook=u,this.refManager=o,this.requestAPI=d;const l=e.value.componentsTree,h=this.getComponent(l),y=Lr(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:i,onComponentDestroy:c,renderMode:f,requestAPI:d}),p={},g=l.props;return Object.keys(g).forEach(m=>{p[m]=g[m].value}),p.$$context=a,Xt(y,p)}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const Lh=kn(new da);function Fh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ae={exports:{}},kt={};/**
|
|
38
|
+
}`,nodeContext:e.context,storeManager:e.storeManager,$$response:e.$$response});let o=r;return Array.isArray(t.args)&&(o=t.args.map(a=>{const s=[e.$$response,...r].filter(Boolean);return lt(a,e)(...s)})),n(...o)},Ph=(t,e)=>async(...r)=>{const o=lt(t.currentValue,e)(...r);let a;if(o!=null&&o.then?a=await o:a=o,t.valueType==="STATE"){const s=t.targetValueName,i=e.storeManager.getStore(s.nodeId);i&&i.setState({[s.keyPath]:a})}else t.valueType==="MEMORY"&&(e.actionVariableSpace[t.targetValueName]=a);return a},se=(t={},e)=>{const{$$context:r,runtimeComponentCache:n,getComponent:o,storeManager:a}=e,s=t,i=f=>{if(Array.isArray(f))return f.map(u=>i(u));if(Ze(f))return i(f.value);if(Eh(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=Lr(p,h,{...e}),m=u.params||[];return{component:(...C)=>{const j=ar(C,m),w=tr({params:j,nodeRefs:r.nodeRefs},r);return Xt(g,{$$context:w,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(ho(p.component)){const m=p.component;return N.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(ct(f))return ut(f.value,r||{});if(ca(f)){const u=f;return te({funcBody:u.value,funcName:u.name||"",nodeContext:r,storeManager:a})}else{if(jh(f))return St(f,{context:r,storeManager:a,actionVariableSpace:{}});if(Tt(f)){let u=f;Ze(f)&&(u=f.value);const d=u,l={};return Object.keys(u).forEach(h=>{l[h]=i(d[h])}),l}else return f}}},c={};return Object.keys(s).forEach(f=>{const u=s[f];c[f]=i(u)}),c},Dh=(t,e)=>{const{runtimeComponentCache:r,$$context:n={},getComponent:o,renderMode:a}=e,{$$context:s,idx:i,...c}=e;return typeof t=="string"?Xt(t):wh(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=Lr(p,u,{...c}),!r.get(d)&&a!=="design"&&r.set(d,{component:l})}const h=`${d}-${oe}`;return Xt(l,{$$context:n,$$nodeModel:t,key:h})})({currentNode:t}):void 0},Lr=(t,e,r)=>{const{storeManager:n,variableManager:o,onGetRef:a,onComponentMount:s,onComponentDestroy:i,refManager:c,processNodeConfigHook:f,requestAPI:u}=r,{...d}=r;class l extends N.Component{constructor(p){super(p);O(this,"_CONDITION",!0);O(this,"_DESIGN_BOX",!1);O(this,"_NODE_MODEL",e);O(this,"_NODE_ID",e.id);O(this,"UNIQUE_ID",`${e.id}_${Z()}`);O(this,"targetComponentRef");O(this,"listenerHandle",[]);O(this,"storeState");O(this,"storeListenDisposeList",[]);O(this,"domHeader");O(this,"mediaStyleDomMap",{});O(this,"variableSpace");O(this,"nodeName");O(this,"updateState",p=>{this.storeState.setState(p)});O(this,"getStyleDomById",p=>{const g=this.mediaStyleDomMap;let m=g[p];return m||(m=document.createElement("style"),g[p]=m),m.id=p,m});O(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 j;const S=`${this.UNIQUE_ID}_${v.state}`;let C=Ve(this._NODE_MODEL);if(v.state!=="normal"&&(C=`${C}:${v.state}`),v.text){const w=this.getStyleDomById(S);w.innerText=`.${C} { ${v.text} }`,p==null||p.appendChild(w)}(j=v.media)!=null&&j.length&&v.media.forEach(w=>{const D=`${S}_${w.type}_${w.value}`,$=this.getStyleDomById(D);$.media=`screen and (${w.type}:${w.value}px)`,$.innerHTML=`.${C} { ${w.text} }`,p==null||p.appendChild($)})})});O(this,"removeMediaCSS",()=>{const p=this.mediaStyleDomMap;Object.keys(p).forEach(g=>{var m;(m=this.domHeader)==null||m.removeChild(p[g])}),this.mediaStyleDomMap={}});O(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(p=>p()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=N.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(S=>{this.setState({...S})}),this.connectStore();const v=o.get(g);v?this.variableSpace=v:(this.variableSpace={staticVar:{},methods:{}},o.add(g,this.variableSpace))}connectStore(){const p=Mn(e.props,C=>!!ct(C)),g=Mn({css:e.value.css,class:e.value.classNames},C=>!!ct(C));let m=[];[...p,...g].map(C=>{const j=C.val,w=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],D=yo(j.value,w);m=[...m,...D]}).filter(Boolean);const v=Array.from(new Set(m)),S=[];v.length&&v.forEach(C=>{n.getStore(C)||(n.addStore(C,()=>({})),console.warn(n,C,"not exits"));const w=n.connect(C,D=>{this.setState({...D})});S.push(w)}),this.storeListenDisposeList=S}componentDidMount(){var v;this.addMediaCSS(),a==null||a(this.targetComponentRef,e,this),s==null||s(this,e);const p=()=>{n.setStore(e.value.nodeName||e.id,this.storeState),this.storeState.setState({...this.state,...e.value.state||{}}),this.rebuildNode()},g=Pr,m=(v=e.value.eventListener)==null?void 0:v.find(S=>S.name===g);m&&St(m.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})(),e.onChange(p)}componentWillUnmount(){var m;this.storeListenDisposeList.forEach(v=>v()),this.removeMediaCSS(),i==null||i(this,e);const p=Dr,g=(m=e.value.eventListener)==null?void 0:m.find(v=>v.name===p);g&&St(g.func,{context:this.createCurrentNodeCtx(),storeManager:n,actionVariableSpace:{}})()}transformMethods(p){const{context:g}=p,m=se({methods:e.value.methods},{$$context:g,...d}),v=e.value.methods||[],S=m.methods,C=v.reduce((j,w,D)=>(j[w.name]=S[D],j),{});g.methods=C,this.variableSpace.methods=Object.assign(this.variableSpace.methods,C)}processRootContext(p){e.value.componentName===Lt.ROOT_CONTAINER&&(p.globalState=this.state,p.updateGlobalState=this.updateState,p.requestAPI=u,p.getGlobalState=()=>this.state)}processNodeClassName(p,g){var S;const m=((S=e.value.classNames)==null?void 0:S.map(C=>{var D;const j=C.name;return(ct(C.status)?ut(((D=C.status)==null?void 0:D.value)||"",g):!1)?j:""}))||[];let v=`${p??""} ${m.join(" ")}`.trim();return e.value.css&&(v=`${Ve(e)} ${v}`.trim()),v}processNodeStyle(p){if(!e.value.style)return{};const g=se({style:e.value.style},{$$context:p,...d});return vo(g.style||[])}processNodeChild(p,g){let m=[];if(p!==void 0)m=Array.isArray(p)?p:[p];else{const v=[];e.value.children.forEach((C,j)=>{const w=Dh(C,{$$context:g,idx:j,...d});v.push(w)}),m=v}return m}processNodeConditionAndConfigHook(p,g,m){let v=e.value.condition??!0;typeof v!="boolean"&&(v=ut(v.value,m||{}));let S={condition:v,props:p};f&&(S=f(S,e));const C=Xt(t,S.props,...g);return this._CONDITION=S.condition,S.condition?C:N.createElement("div",{style:{display:"none"}},C)}processNodeEventListener(p){const g=e.value.eventListener,m={};return g==null||g.forEach(v=>{if(fa.includes(v.name))return;const S=St(v.func,{context:p,storeManager:n,actionVariableSpace:{}});m[v.name]=S}),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:C=>n.getStateObj(C),stateManager:n.getStateSnapshot(),getMethods:()=>{const C=o.get(m).methods,j=c.get(m).current;return ke(C,j)},getMethodsById:C=>{const j=o.get(C).methods,w=c.get(C).current;return ke(j,w)},getStaticVar:()=>o.get(g).staticVar,getStaticVarById:C=>o.get(C).staticVar,nodeRefs:p.nodeRefs};return this.processRootContext(v),tr(v,p)}renderCore(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});let S=se(m,{$$context:v,...d});const C=this.processNodeClassName(S.className,v);S.className=C;const j=this.processNodeStyle(v);S.style=j;const{children:w}=S;delete S.children;const D=this.processNodeChild(w,v);if(S.ref=this.targetComponentRef,e.value.eventListener){const bt=this.processNodeEventListener(v);S={...S,...bt}}return this.processNodeConditionAndConfigHook(S,D,v)}renderLoop(){const{$$context:p,...g}=this.props,m={key:e.id,...e.props,...g},v=this.createCurrentNodeCtx();this.transformMethods({context:v});const S=e.value.loop;let C=[];if(S&&S.open){this.targetComponentRef.current=[];let j=S.data||[];if(ct(S.data)){const w=S.data;j=ut(w.value,v||{})}return C=j.map((...w)=>{const D=w[1],$=[S.forName||"item",S.forIndex||"index"],bt=ar(w,$);let ot="loopData";S.name&&(ot=`${ot}${S.name}`);const at=tr({[ot]:bt,nodeRefs:v.nodeRefs},v),Q=se(m,{$$context:at,...d}),ya=this.processNodeClassName(Q.className,at);Q.className=ya;const ba=this.processNodeStyle(at);Q.style=ba;const{children:_a}=Q;delete Q.children;const Sa=this.processNodeChild(_a,at);if(Q.key=`${Q.key}-${D}`,ct(S.key)){const Oe=S.key,Ca=ut(Oe.value,at||{});Q.key+=`-${Ca}`}return Q.ref=Oe=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[D]=Oe},this.processNodeConditionAndConfigHook(Q,Sa,at)}),C}}render(){const p=e.value.loop;return p&&p.open?this.renderLoop():this.renderCore()}}return O(l,"__CP_TYPE__",oe),l.displayName=`${e.value.componentName}Dynamic`,l};class da{constructor(){O(this,"renderMode","normal");O(this,"components",{});O(this,"storeManager",new Vc);O(this,"variableManager",new kc);O(this,"runtimeComponentCache",new Map);O(this,"onGetRef");O(this,"onGetComponent");O(this,"onComponentMount");O(this,"refManager",new sr);O(this,"onComponentDestroy");O(this,"processNodeConfigHook");O(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=_o(r,this.components);return mo(n)||(n=go(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:s,onComponentMount:i,onComponentDestroy:c,renderMode:f,processNodeConfigHook:u,requestAPI:d}){this.renderMode=f,this.components=r,this.onGetRef=n,this.onGetComponent=s,this.onComponentMount=i,this.onComponentDestroy=c,this.processNodeConfigHook=u,this.refManager=o,this.requestAPI=d;const l=e.value.componentsTree,h=this.getComponent(l),y=Lr(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:i,onComponentDestroy:c,renderMode:f,requestAPI:d}),p={},g=l.props;return Object.keys(g).forEach(m=>{p[m]=g[m].value}),p.$$context=a,Xt(y,p)}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const Lh=kn(new da);function Fh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ae={exports:{}},kt={};/**
|
|
39
39
|
* @license React
|
|
40
40
|
* react-jsx-runtime.production.min.js
|
|
41
41
|
*
|