@chamn/render 0.0.39 → 0.0.41
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/commonComponent/index.d.ts +1 -12
- package/dist/core/adapterReact.d.ts +2 -2
- package/dist/core/designReactRender.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -17
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/util/assetsLoader.d.ts +4 -1
- package/dist/util/index.d.ts +3 -3
- package/package.json +6 -6
package/dist/index.umd.js
CHANGED
|
@@ -17,7 +17,7 @@ function $$_run_$$() {
|
|
|
17
17
|
return $$_f_$$.apply($$_f_$$, $$$__args__$$$);
|
|
18
18
|
}
|
|
19
19
|
return $$_run_$$();
|
|
20
|
-
`,new Function(a)(...o,e,r)}catch(s){console.log(a),console.warn(s)}},xr=(t,e)=>{const r={};return e.forEach((n,o)=>{r[n]=t[o]}),r},Dr=(t=[])=>{const e={};return t.forEach(({property:r,value:n})=>{let o=r.replace("-webkit","Webkit");o=o.replace("-ms","ms"),o=o.replace("-moz","Moz"),o=o.replace("-o","O");let a=o.split("-");a.length>=2&&(a=a.map((s,i)=>i!==0?Wh(s):s)),e[a.join("")]=n}),e},mm=t=>{let e="";return Object.keys(t||{}).forEach(r=>{e+=`${r}:${t[r]};`}),e},vm=(t,e)=>{const r={};return t.forEach(n=>{if(n.globalName){const o=e[n.globalName];o&&(r[n.globalName]=o,o.__esModule&&(r[n.globalName]=o.default))}}),r},gm=(t,e=1)=>{let r=0,n=t,o={},a={};for(;r<e;)Object.keys(n).forEach(s=>{o={...o,...n[s]}}),a=o,n=o,o={},r+=1;return a},ta=(t,e)=>{const r=[];return e.forEach(n=>{const a=n.exec(t);a!=null&&a.length&&r.push(a[1])}),r},ea=(t,e)=>{const r={};return e.forEach(n=>{t[n.name]&&(r[n.name]=t[n.name])}),r},ym=(t,e)=>ea(t,e),bm=(t,e)=>ea(t,e),Oe=t=>{var r;return((r=t.value.css)==null?void 0:r.class)||`c_${t.id}`},ra=(t,e)=>{const r=t.split(".");let n,o=e;return r.forEach(a=>{n=o==null?void 0:o[a],o=n}),n||(()=>`Component [${t}] not found`)},Ce="DYNAMIC",_m=["$$context","$$nodeModel"],na=t=>{let e;const r=new Set,n=(c,u)=>{const l=typeof c=="function"?c(e):c;if(!Object.is(l,e)){const d=e;e=u??typeof l!="object"?l:Object.assign({},e,l),r.forEach(f=>f(e,d))}},o=()=>e,i={setState:n,getState:o,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,i),i},Sm=t=>t?na(t):na;class jm{constructor(){b(this,"storeMap",new Map)}addStore(e,r){const n=Sm(r);return this.storeMap.set(e,n),n.name=e,n}setStore(e,r){this.storeMap.set(e,r)}removeStore(e){this.storeMap.delete(e)}getStore(e){return this.storeMap.get(e)}getState(e){var r;return(r=this.storeMap.get(e))==null?void 0:r.getState()}getStateObj(e){return{state:this.getState(e),updateState:r=>{this.setState(e,r)}}}setState(e,r){var n;return(n=this.storeMap.get(e))==null?void 0:n.setState(r)}connect(e,r){const n=this.storeMap.get(e);return n?n.subscribe(r):(console.warn("store not exits"),()=>{})}getStateSnapshot(){const e={};return this.storeMap.forEach((r,n)=>{e[n]=this.getStateObj(n)}),e}destroy(){this.storeMap=new Map}}class Om{constructor(){b(this,"varSpace",new Map)}get(e){return this.varSpace.get(e)}add(e,r){this.varSpace.set(e,r)}remove(e){this.varSpace.delete(e)}destroy(){this.varSpace.clear()}getStateSnapshot(){const e={};return this.varSpace.forEach((r,n)=>{e[n]=r}),e}}class oa{constructor(){b(this,"renderMode","normal");b(this,"components",{});b(this,"storeManager",new jm);b(this,"variableManager",new Om);b(this,"runtimeComponentCache",new Map);b(this,"onGetRef");b(this,"onGetComponent");b(this,"onComponentMount");b(this,"onComponentDestroy");b(this,"processNodeConfigHook")}getComponent(e){var o;const r=e.value.componentName;let n=ra(r,this.components);return Ko(n)||(n=Xo(n),this.components[r]=n),this.onGetComponent&&(n=(o=this.onGetComponent)==null?void 0:o.call(this,n,e)),n}getContext(e={},r){let n=e;return r&&(n={...e},n.__proto__=r||null),n}pageRender(e,{components:r,onGetRef:n,$$context:o={},onGetComponent:a,onComponentMount:s,onComponentDestroy:i,renderMode:c,processNodeConfigHook:u}){this.renderMode=c,this.components=r,this.onGetRef=n,this.onGetComponent=a,this.onComponentMount=s,this.onComponentDestroy=i,this.processNodeConfigHook=u;const l=e.value.componentsTree,d=this.getComponent(l),f=this.convertModelToComponent(d,e.value.componentsTree),p={},h=l.props;return Object.keys(h).forEach(y=>{p[y]=h[y].value}),p.$$context=o,this.render(f,p)}transformProps(e={},{$$context:r}){const n=e,o=s=>{if(Array.isArray(s))return s.map(i=>o(i));if(yr(s))return o(s.value);if(Lf(s)){const i=s.value,c=i.value;if(!c)return console.warn("slot value is null, this maybe cause some error, pls check it",e),()=>{};const u=l=>{const d=`${l.id}-${Ce}`;if(this.runtimeComponentCache.get(l.id))return{key:d,component:this.runtimeComponentCache.get(l.id)};const f=this.getComponent(l),p=this.convertModelToComponent(f,l),h=i.params||[];return{component:(...O)=>{const C=xr(O,h),P=this.getContext({params:C},r);return this.render(p,{$$context:P,key:d})},key:d}};if(Array.isArray(c)){const l=c==null?void 0:c.map(d=>u(d));return(...d)=>l.map(f=>{if(Yo(f.component)){const h=f.component;return S.createElement(h,{$$context:r,key:f.key})}else{const h=f.component;return h==null?void 0:h(...d)}})}else return u(c).component}else{if(mt(s))return bt(s.value,r||{});if(If(s))return Zo(s.value,r,this.storeManager);if(Rt(s)){let i=s;yr(s)&&(i=s.value);const c=i,u={};return Object.keys(i).forEach(l=>{u[l]=o(c[l])}),u}else return s}},a={};return Object.keys(n).forEach(s=>{const i=n[s];a[s]=o(i)}),a}collectSpecialProps(e={},r){const n=[],o=(a,s)=>{let i=s;yr(s)&&(i=s.value),r(i)?n.push({keyPath:a,val:i}):Dt(i)?i.forEach((c,u)=>{o([...a,String(u)],c)}):Rt(i)&&Object.keys(i).forEach(c=>{o([...a,c],i[c])})};return o(["$root"],e),n}convertModelToComponent(e,r){const n=this;class o extends S.Component{constructor(i){super(i);b(this,"_CONDITION",!0);b(this,"_DESIGN_BOX",!1);b(this,"_NODE_MODEL",r);b(this,"_NODE_ID",r.id);b(this,"UNIQUE_ID",`${r.id}_${Z()}`);b(this,"targetComponentRef");b(this,"listenerHandle",[]);b(this,"storeState");b(this,"storeListenDisposeList",[]);b(this,"domHeader");b(this,"mediaStyleDomMap",{});b(this,"variableSpace");b(this,"nodeName");b(this,"updateState",i=>{this.storeState.setState(i),this.forceUpdate()});b(this,"getStyleDomById",i=>{const c=this.mediaStyleDomMap;let u=c[i];return u||(u=document.createElement("style"),c[i]=u),u.id=i,u});b(this,"addMediaCSS",()=>{var u;let i=this.domHeader;if(i||(i=(u=document.getElementsByTagName("head"))==null?void 0:u[0],this.domHeader=i),!this.domHeader)return;const c=this._NODE_MODEL.value.css;c&&c.value.forEach(l=>{var p;const d=`${this.UNIQUE_ID}_${l.state}`;let f=Oe(this._NODE_MODEL);if(l.state!=="normal"&&(f=`${f}:${l.state}`),l.text){const h=this.getStyleDomById(d);h.innerText=`.${f} { ${l.text} }`,i==null||i.appendChild(h)}(p=l.media)!=null&&p.length&&l.media.forEach(h=>{const y=`${d}_${h.type}_${h.value}`,_=this.getStyleDomById(y);_.media=`screen and (${h.type}:${h.value}px)`,_.innerHTML=`.${f} { ${h.text} }`,i==null||i.appendChild(_)})})});b(this,"removeMediaCSS",()=>{const i=this.mediaStyleDomMap;Object.keys(i).forEach(c=>{var u;(u=this.domHeader)==null||u.removeChild(i[c])}),this.mediaStyleDomMap={}});b(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(i=>i()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=S.createRef(),this.state=r.value.state||{};const c=r.value.nodeName||r.id;this.nodeName=c;const u=n.storeManager.getStore(c);u?(this.storeState=u,u.setState({...r.value.state||{}})):this.storeState=n.storeManager.addStore(c,()=>({...r.value.state||{}})),this.storeState.subscribe(d=>{this.setState({...d})}),this.connectStore();const l=n.variableManager.get(c);l?this.variableSpace=l:(this.variableSpace={staticVar:{},methods:{}},n.variableManager.add(c,this.variableSpace))}connectStore(){const i=n.collectSpecialProps(r.props,f=>!!mt(f)),c=n.collectSpecialProps({css:r.value.css,class:r.value.classNames},f=>!!mt(f));let u=[];[...i,...c].map(f=>{const p=f.val,h=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],y=ta(p.value,h);u=[...u,...y]}).filter(Boolean);const l=Array.from(new Set(u)),d=[];l.length&&l.forEach(f=>{n.storeManager.getStore(f)||(n.storeManager.addStore(f,()=>({})),console.warn(n.storeManager,f,"not exits"));const h=n.storeManager.connect(f,()=>{this.forceUpdate()});d.push(h)}),this.storeListenDisposeList=d}componentDidMount(){var c;this.addMediaCSS(),n.onGetRef&&n.onGetRef(this.targetComponentRef,r,this),(c=n.onComponentMount)==null||c.call(n,this,r);const i=()=>{n.storeManager.setStore(r.value.nodeName||r.id,this.storeState),this.storeState.setState({...this.state,...r.value.state||{}}),this.rebuildNode()};r.onChange(i)}componentWillUnmount(){var i;this.storeListenDisposeList.forEach(c=>c()),this.removeMediaCSS(),(i=n.onComponentDestroy)==null||i.call(n,this,r)}render(){var Ee;const{$$context:i,...c}=this.props,u=r.value.nodeName||r.id,l={key:r.id,...r.props,...c},d={state:this.state||{},staticVar:this.variableSpace.staticVar,updateState:this.updateState,storeManager:n.storeManager,getState:()=>n.storeManager.getStateObj(u),getStateObj:()=>n.storeManager.getStateObj(u),getStateObjById:R=>n.storeManager.getStateObj(R),stateManager:n.storeManager.getStateSnapshot(),getMethods:()=>n.variableManager.get(u).methods,getMethodsById:R=>n.variableManager.get(R).methods,getStaticVar:()=>n.variableManager.get(u).staticVar,getStaticVarById:R=>n.variableManager.get(R).staticVar};r.value.componentName===Tt.ROOT_CONTAINER&&(d.globalState=this.state,d.updateGlobalState=this.updateState);const f=n.getContext(d,i),y=n.transformProps({methods:r.value.methods},{$$context:f}).methods.reduce((R,Q)=>(R[Q.name]=Q.define,R),{});f.methods=y,this.variableSpace.methods=Object.assign(this.variableSpace.methods,y);const _=r.value.loop;let O=[];if(_&&_.open){this.targetComponentRef.current=[];let R=_.data||[];if(mt(_.data)){const Q=_.data;R=bt(Q.value,f||{})}return O=R.map((...Q)=>{var ha;const oe=Q[1],Bt=[_.forName||"item",_.forIndex||"index"],Ir=xr(Q,Bt);let Rr="loopData";_.name&&(Rr=`${Rr}${_.name}`);const ae=n.getContext({[Rr]:Ir},f),tt=n.transformProps(l,{$$context:ae}),Hm=((ha=r.value.classNames)==null?void 0:ha.map(q=>{var Ne;const ie=q.name;return(mt(q.status)?bt(String(((Ne=q.status)==null?void 0:Ne.value)||""),ae):!1)?ie:""}))||[];let Lr=`${tt.className??""} ${Hm.join(" ")}`.trim();r.value.css&&(Lr=`${Oe(r)} ${Lr}`.trim()),tt.className=Lr;const Jm=n.transformProps({style:r.value.style},{$$context:ae});r.value.style&&(tt.style=Dr(Jm.style||[]));const{children:$e}=tt;let Br=[];if($e!==void 0)delete tt.children,Br=Array.isArray($e)?$e:[$e];else{const q=[];r.value.children.forEach((ma,Ne)=>{const Wm=n.buildComponent(ma,{$$context:ae,idx:Ne});q.push(Wm)}),Br=q}if(tt.key=`${tt.key}-${oe}`,mt(_.key)){const q=_.key,ie=bt(q.value,ae||{});tt.key+=`-${ie}`}return tt.ref=q=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[oe]=q},n.render(e,tt,...Br)}),O}const C=n.transformProps(l,{$$context:f}),{children:P}=C;let x=[];if(P!==void 0)delete C.children,x=Array.isArray(P)?P:[P];else{const R=[];r.value.children.forEach((oe,Bt)=>{const Ir=n.buildComponent(oe,{$$context:f,idx:Bt});R.push(Ir)}),x=R}C.ref=this.targetComponentRef;const L=((Ee=r.value.classNames)==null?void 0:Ee.map(R=>{var Bt;const Q=R.name;return(mt(R.status)?bt(((Bt=R.status)==null?void 0:Bt.value)||"",f):!1)?Q:""}))||[];let z=`${C.className??""} ${L.join(" ")}`.trim();r.value.css&&(z=`${Oe(r)} ${z}`.trim()),C.className=z;const ne=n.transformProps({style:r.value.style},{$$context:f});r.value.style&&(C.style=Dr(ne.style||[]));let E=r.value.condition??!0;typeof E!="boolean"&&(E=bt(E.value,f||{}));let st={condition:E,props:C};n.processNodeConfigHook&&(st=n.processNodeConfigHook(st,r));const _t=n.render(e,st.props,...x);return this._CONDITION=st.condition,st.condition?_t:S.createElement("div",{style:{display:"none"}},_t)}}return b(o,"__CP_TYPE__",Ce),o.displayName=`${r.value.componentName}Dynamic`,o}buildComponent(e,{$$context:r={}}){const n=this.runtimeComponentCache;return typeof e=="string"?this.render(e):Rf(e)?(({currentNode:a})=>{const s=a.value.id;let i=null;if(n.get(s)){const l=n.get(s);i=l==null?void 0:l.component}else{const l=this.getComponent(a);i=this.convertModelToComponent(l,a),!n.get(s)&&this.renderMode!=="design"&&n.set(s,{component:i})}const c=`${s}-${Ce}`,u={$$context:r,$$nodeModel:e,key:c};return this.render(i,u)})({currentNode:e}):void 0}render(e,r={},...n){return typeof e=="string"||typeof e=="number"?String(e):(_m.forEach(a=>{a in r&&e.__CP_TYPE__!==Ce&&delete r[a]}),S.createElement(e,r,...n))}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const Cm=Ur(new oa),wm=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","element","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","math","menu","menuitem","meta","meter","multicol","nav","nextid","nobr","noembed","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rbc","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"];var Em=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $m(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var aa={exports:{}},we={};/**
|
|
20
|
+
`,new Function(a)(...o,e,r)}catch(s){console.log(a),console.warn(s)}},xr=(t,e)=>{const r={};return e.forEach((n,o)=>{r[n]=t[o]}),r},Dr=(t=[])=>{const e={};return t.forEach(({property:r,value:n})=>{let o=r.replace("-webkit","Webkit");o=o.replace("-ms","ms"),o=o.replace("-moz","Moz"),o=o.replace("-o","O");let a=o.split("-");a.length>=2&&(a=a.map((s,i)=>i!==0?Wh(s):s)),e[a.join("")]=n}),e},mm=t=>{let e="";return Object.keys(t||{}).forEach(r=>{e+=`${r}:${t[r]};`}),e},vm=(t,e)=>{const r={};return t.forEach(n=>{if(n.globalName){const o=e[n.globalName];o&&(r[n.globalName]=o,o.__esModule&&o.default&&(r[n.globalName]=o.default))}}),r},gm=(t,e=1)=>{let r=0,n=t,o={},a={};for(;r<e;)Object.keys(n).forEach(s=>{o={...o,...n[s]}}),a=o,n=o,o={},r+=1;return a},ta=(t,e)=>{const r=[];return e.forEach(n=>{const a=n.exec(t);a!=null&&a.length&&r.push(a[1])}),r},ea=(t,e)=>{const r={};return e.forEach(n=>{t[n.name]&&(r[n.name]=t[n.name])}),r},ym=(t,e)=>ea(t,e),bm=(t,e)=>ea(t,e),Oe=t=>{var r;return((r=t.value.css)==null?void 0:r.class)||`c_${t.id}`},ra=(t,e)=>{const r=t.split(".");let n,o=e;return r.forEach(a=>{n=o==null?void 0:o[a],o=n}),n||(()=>`Component [${t}] not found`)},Ce="DYNAMIC",_m=["$$context","$$nodeModel"],na=t=>{let e;const r=new Set,n=(c,u)=>{const l=typeof c=="function"?c(e):c;if(!Object.is(l,e)){const d=e;e=u??typeof l!="object"?l:Object.assign({},e,l),r.forEach(f=>f(e,d))}},o=()=>e,i={setState:n,getState:o,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,i),i},Sm=t=>t?na(t):na;class jm{constructor(){b(this,"storeMap",new Map)}addStore(e,r){const n=Sm(r);return this.storeMap.set(e,n),n.name=e,n}setStore(e,r){this.storeMap.set(e,r)}removeStore(e){this.storeMap.delete(e)}getStore(e){return this.storeMap.get(e)}getState(e){var r;return(r=this.storeMap.get(e))==null?void 0:r.getState()}getStateObj(e){return{state:this.getState(e),updateState:r=>{this.setState(e,r)}}}setState(e,r){var n;return(n=this.storeMap.get(e))==null?void 0:n.setState(r)}connect(e,r){const n=this.storeMap.get(e);return n?n.subscribe(r):(console.warn("store not exits"),()=>{})}getStateSnapshot(){const e={};return this.storeMap.forEach((r,n)=>{e[n]=this.getStateObj(n)}),e}destroy(){this.storeMap=new Map}}class Om{constructor(){b(this,"varSpace",new Map)}get(e){return this.varSpace.get(e)}add(e,r){this.varSpace.set(e,r)}remove(e){this.varSpace.delete(e)}destroy(){this.varSpace.clear()}getStateSnapshot(){const e={};return this.varSpace.forEach((r,n)=>{e[n]=r}),e}}class oa{constructor(){b(this,"renderMode","normal");b(this,"components",{});b(this,"storeManager",new jm);b(this,"variableManager",new Om);b(this,"runtimeComponentCache",new Map);b(this,"onGetRef");b(this,"onGetComponent");b(this,"onComponentMount");b(this,"onComponentDestroy");b(this,"processNodeConfigHook")}getComponent(e){var o;const r=e.value.componentName;let n=ra(r,this.components);return Ko(n)||(n=Xo(n),this.components[r]=n),this.onGetComponent&&(n=(o=this.onGetComponent)==null?void 0:o.call(this,n,e)),n}getContext(e={},r){let n=e;return r&&(n={...e},n.__proto__=r||null),n}pageRender(e,{components:r,onGetRef:n,$$context:o={},onGetComponent:a,onComponentMount:s,onComponentDestroy:i,renderMode:c,processNodeConfigHook:u}){this.renderMode=c,this.components=r,this.onGetRef=n,this.onGetComponent=a,this.onComponentMount=s,this.onComponentDestroy=i,this.processNodeConfigHook=u;const l=e.value.componentsTree,d=this.getComponent(l),f=this.convertModelToComponent(d,e.value.componentsTree),p={},h=l.props;return Object.keys(h).forEach(y=>{p[y]=h[y].value}),p.$$context=o,this.render(f,p)}transformProps(e={},{$$context:r}){const n=e,o=s=>{if(Array.isArray(s))return s.map(i=>o(i));if(yr(s))return o(s.value);if(Lf(s)){const i=s.value,c=i.value;if(!c)return console.warn("slot value is null, this maybe cause some error, pls check it",e),()=>{};const u=l=>{const d=`${l.id}-${Ce}`;if(this.runtimeComponentCache.get(l.id))return{key:d,component:this.runtimeComponentCache.get(l.id)};const f=this.getComponent(l),p=this.convertModelToComponent(f,l),h=i.params||[];return{component:(...O)=>{const C=xr(O,h),P=this.getContext({params:C},r);return this.render(p,{$$context:P,key:d})},key:d}};if(Array.isArray(c)){const l=c==null?void 0:c.map(d=>u(d));return(...d)=>l.map(f=>{if(Yo(f.component)){const h=f.component;return S.createElement(h,{$$context:r,key:f.key})}else{const h=f.component;return h==null?void 0:h(...d)}})}else return u(c).component}else{if(mt(s))return bt(s.value,r||{});if(If(s))return Zo(s.value,r,this.storeManager);if(Rt(s)){let i=s;yr(s)&&(i=s.value);const c=i,u={};return Object.keys(i).forEach(l=>{u[l]=o(c[l])}),u}else return s}},a={};return Object.keys(n).forEach(s=>{const i=n[s];a[s]=o(i)}),a}collectSpecialProps(e={},r){const n=[],o=(a,s)=>{let i=s;yr(s)&&(i=s.value),r(i)?n.push({keyPath:a,val:i}):Dt(i)?i.forEach((c,u)=>{o([...a,String(u)],c)}):Rt(i)&&Object.keys(i).forEach(c=>{o([...a,c],i[c])})};return o(["$root"],e),n}convertModelToComponent(e,r){const n=this;class o extends S.Component{constructor(i){super(i);b(this,"_CONDITION",!0);b(this,"_DESIGN_BOX",!1);b(this,"_NODE_MODEL",r);b(this,"_NODE_ID",r.id);b(this,"UNIQUE_ID",`${r.id}_${Z()}`);b(this,"targetComponentRef");b(this,"listenerHandle",[]);b(this,"storeState");b(this,"storeListenDisposeList",[]);b(this,"domHeader");b(this,"mediaStyleDomMap",{});b(this,"variableSpace");b(this,"nodeName");b(this,"updateState",i=>{this.storeState.setState(i),this.forceUpdate()});b(this,"getStyleDomById",i=>{const c=this.mediaStyleDomMap;let u=c[i];return u||(u=document.createElement("style"),c[i]=u),u.id=i,u});b(this,"addMediaCSS",()=>{var u;let i=this.domHeader;if(i||(i=(u=document.getElementsByTagName("head"))==null?void 0:u[0],this.domHeader=i),!this.domHeader)return;const c=this._NODE_MODEL.value.css;c&&c.value.forEach(l=>{var p;const d=`${this.UNIQUE_ID}_${l.state}`;let f=Oe(this._NODE_MODEL);if(l.state!=="normal"&&(f=`${f}:${l.state}`),l.text){const h=this.getStyleDomById(d);h.innerText=`.${f} { ${l.text} }`,i==null||i.appendChild(h)}(p=l.media)!=null&&p.length&&l.media.forEach(h=>{const y=`${d}_${h.type}_${h.value}`,_=this.getStyleDomById(y);_.media=`screen and (${h.type}:${h.value}px)`,_.innerHTML=`.${f} { ${h.text} }`,i==null||i.appendChild(_)})})});b(this,"removeMediaCSS",()=>{const i=this.mediaStyleDomMap;Object.keys(i).forEach(c=>{var u;(u=this.domHeader)==null||u.removeChild(i[c])}),this.mediaStyleDomMap={}});b(this,"rebuildNode",()=>{this.storeListenDisposeList.forEach(i=>i()),this.removeMediaCSS(),this.connectStore(),this.addMediaCSS(),this.forceUpdate()});this.targetComponentRef=S.createRef(),this.state=r.value.state||{};const c=r.value.nodeName||r.id;this.nodeName=c;const u=n.storeManager.getStore(c);u?(this.storeState=u,u.setState({...r.value.state||{}})):this.storeState=n.storeManager.addStore(c,()=>({...r.value.state||{}})),this.storeState.subscribe(d=>{this.setState({...d})}),this.connectStore();const l=n.variableManager.get(c);l?this.variableSpace=l:(this.variableSpace={staticVar:{},methods:{}},n.variableManager.add(c,this.variableSpace))}connectStore(){const i=n.collectSpecialProps(r.props,f=>!!mt(f)),c=n.collectSpecialProps({css:r.value.css,class:r.value.classNames},f=>!!mt(f));let u=[];[...i,...c].map(f=>{const p=f.val,h=[/\$\$context.stateManager\.(.+?)\./gim,/\$\$context.stateManager\["(.+?)"\]/gim,/\$\$context.stateManager\['(.+?)'\]/gim,/getStateObj\('(.+?)'\)/gim,/getStateObj\("(.+?)"\)/gim,/getStateById\('(.+?)'\)/gim,/getStateById\("(.+?)"\)/gim],y=ta(p.value,h);u=[...u,...y]}).filter(Boolean);const l=Array.from(new Set(u)),d=[];l.length&&l.forEach(f=>{n.storeManager.getStore(f)||(n.storeManager.addStore(f,()=>({})),console.warn(n.storeManager,f,"not exits"));const h=n.storeManager.connect(f,()=>{this.forceUpdate()});d.push(h)}),this.storeListenDisposeList=d}componentDidMount(){var c;this.addMediaCSS(),n.onGetRef&&n.onGetRef(this.targetComponentRef,r,this),(c=n.onComponentMount)==null||c.call(n,this,r);const i=()=>{n.storeManager.setStore(r.value.nodeName||r.id,this.storeState),this.storeState.setState({...this.state,...r.value.state||{}}),this.rebuildNode()};r.onChange(i)}componentWillUnmount(){var i;this.storeListenDisposeList.forEach(c=>c()),this.removeMediaCSS(),(i=n.onComponentDestroy)==null||i.call(n,this,r)}render(){var Ee;const{$$context:i,...c}=this.props,u=r.value.nodeName||r.id,l={key:r.id,...r.props,...c},d={state:this.state||{},staticVar:this.variableSpace.staticVar,updateState:this.updateState,storeManager:n.storeManager,getState:()=>n.storeManager.getStateObj(u),getStateObj:()=>n.storeManager.getStateObj(u),getStateObjById:R=>n.storeManager.getStateObj(R),stateManager:n.storeManager.getStateSnapshot(),getMethods:()=>n.variableManager.get(u).methods,getMethodsById:R=>n.variableManager.get(R).methods,getStaticVar:()=>n.variableManager.get(u).staticVar,getStaticVarById:R=>n.variableManager.get(R).staticVar};r.value.componentName===Tt.ROOT_CONTAINER&&(d.globalState=this.state,d.updateGlobalState=this.updateState);const f=n.getContext(d,i),y=n.transformProps({methods:r.value.methods},{$$context:f}).methods.reduce((R,Q)=>(R[Q.name]=Q.define,R),{});f.methods=y,this.variableSpace.methods=Object.assign(this.variableSpace.methods,y);const _=r.value.loop;let O=[];if(_&&_.open){this.targetComponentRef.current=[];let R=_.data||[];if(mt(_.data)){const Q=_.data;R=bt(Q.value,f||{})}return O=R.map((...Q)=>{var ha;const oe=Q[1],Bt=[_.forName||"item",_.forIndex||"index"],Ir=xr(Q,Bt);let Rr="loopData";_.name&&(Rr=`${Rr}${_.name}`);const ae=n.getContext({[Rr]:Ir},f),tt=n.transformProps(l,{$$context:ae}),Hm=((ha=r.value.classNames)==null?void 0:ha.map(q=>{var Ne;const ie=q.name;return(mt(q.status)?bt(String(((Ne=q.status)==null?void 0:Ne.value)||""),ae):!1)?ie:""}))||[];let Lr=`${tt.className??""} ${Hm.join(" ")}`.trim();r.value.css&&(Lr=`${Oe(r)} ${Lr}`.trim()),tt.className=Lr;const Jm=n.transformProps({style:r.value.style},{$$context:ae});r.value.style&&(tt.style=Dr(Jm.style||[]));const{children:$e}=tt;let Br=[];if($e!==void 0)delete tt.children,Br=Array.isArray($e)?$e:[$e];else{const q=[];r.value.children.forEach((ma,Ne)=>{const Wm=n.buildComponent(ma,{$$context:ae,idx:Ne});q.push(Wm)}),Br=q}if(tt.key=`${tt.key}-${oe}`,mt(_.key)){const q=_.key,ie=bt(q.value,ae||{});tt.key+=`-${ie}`}return tt.ref=q=>{this.targetComponentRef.current=this.targetComponentRef.current||[],this.targetComponentRef.current[oe]=q},n.render(e,tt,...Br)}),O}const C=n.transformProps(l,{$$context:f}),{children:P}=C;let x=[];if(P!==void 0)delete C.children,x=Array.isArray(P)?P:[P];else{const R=[];r.value.children.forEach((oe,Bt)=>{const Ir=n.buildComponent(oe,{$$context:f,idx:Bt});R.push(Ir)}),x=R}C.ref=this.targetComponentRef;const L=((Ee=r.value.classNames)==null?void 0:Ee.map(R=>{var Bt;const Q=R.name;return(mt(R.status)?bt(((Bt=R.status)==null?void 0:Bt.value)||"",f):!1)?Q:""}))||[];let z=`${C.className??""} ${L.join(" ")}`.trim();r.value.css&&(z=`${Oe(r)} ${z}`.trim()),C.className=z;const ne=n.transformProps({style:r.value.style},{$$context:f});r.value.style&&(C.style=Dr(ne.style||[]));let E=r.value.condition??!0;typeof E!="boolean"&&(E=bt(E.value,f||{}));let st={condition:E,props:C};n.processNodeConfigHook&&(st=n.processNodeConfigHook(st,r));const _t=n.render(e,st.props,...x);return this._CONDITION=st.condition,st.condition?_t:S.createElement("div",{style:{display:"none"}},_t)}}return b(o,"__CP_TYPE__",Ce),o.displayName=`${r.value.componentName}Dynamic`,o}buildComponent(e,{$$context:r={}}){const n=this.runtimeComponentCache;return typeof e=="string"?this.render(e):Rf(e)?(({currentNode:a})=>{const s=a.value.id;let i=null;if(n.get(s)){const l=n.get(s);i=l==null?void 0:l.component}else{const l=this.getComponent(a);i=this.convertModelToComponent(l,a),!n.get(s)&&this.renderMode!=="design"&&n.set(s,{component:i})}const c=`${s}-${Ce}`,u={$$context:r,$$nodeModel:e,key:c};return this.render(i,u)})({currentNode:e}):void 0}render(e,r={},...n){return typeof e=="string"||typeof e=="number"?String(e):(_m.forEach(a=>{a in r&&e.__CP_TYPE__!==Ce&&delete r[a]}),S.createElement(e,r,...n))}clear(){this.runtimeComponentCache.clear(),this.storeManager.destroy()}}const Cm=Ur(new oa),wm=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","element","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","math","menu","menuitem","meta","meter","multicol","nav","nextid","nobr","noembed","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rbc","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"];var Em=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $m(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var aa={exports:{}},we={};/**
|
|
21
21
|
* @license React
|
|
22
22
|
* react-jsx-runtime.production.min.js
|
|
23
23
|
*
|
|
@@ -25,5 +25,5 @@ return $$_run_$$();
|
|
|
25
25
|
*
|
|
26
26
|
* This source code is licensed under the MIT license found in the
|
|
27
27
|
* LICENSE file in the root directory of this source tree.
|
|
28
|
-
*/var Nm=S,Tm=Symbol.for("react.element"),Am=Symbol.for("react.fragment"),Mm=Object.prototype.hasOwnProperty,Pm=Nm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xm={key:!0,ref:!0,__self:!0,__source:!0};function ia(t,e,r){var n,o={},a=null,s=null;r!==void 0&&(a=""+r),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Mm.call(e,n)&&!xm.hasOwnProperty(n)&&(o[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)o[n]===void 0&&(o[n]=e[n]);return{$$typeof:Tm,type:t,key:a,ref:s,props:o,_owner:Pm.current}}we.Fragment=Am,we.jsx=ia,we.jsxs=ia,aa.exports=we;var Dm=aa.exports;const Im=Dm.jsx,ot=t=>{const e={};return t.forEach(r=>{e[r.key]=r.value}),e},Rm=[...wm,...Sf].reduce((t,e)=>(t[e]=({children:r,$$attributes:n=[],...o})=>{let a=r;return Array.isArray(r)||(a=[r]),S.createElement(e,{...o,...ot(n)},...a)},t),{}),Lm={RootContainer:({children:t})=>t,...Rm,CContainer:({children:t,$$attributes:e=[],afterMount:r,beforeDestroy:n,...o})=>{let a=t;return Array.isArray(t)||(a=[t]),S.useEffect(()=>(r==null||r(o),()=>{n==null||n(o)}),[]),Im("div",{...o,...ot(e),children:a})},CVideo:({children:t,$$attributes:e=[],...r})=>{let n=t;return Array.isArray(t)||(n=[t]),S.createElement("video",{...r,...ot(e)},...n)},CAudio:({children:t,$$attributes:e=[],...r})=>{let n=t;return Array.isArray(t)||(n=[t]),S.createElement("audio",{...r,...ot(e)},...n)},CBlock:({children:t,width:e,height:r,$$attributes:n=[],...o})=>{let a=t;Array.isArray(t)||(a=[t]),a=a.filter(u=>u!==void 0);const{style:s={},...i}=ot(n),c={height:r,width:e,...s,...o.style||{}};return S.createElement("div",{...o,...i,style:c},...a)},CImage:({children:t,$$attributes:e=[],...r})=>{let n=t;return Array.isArray(t)||(n=[t]),S.createElement("img",{...r,...ot(e)},...n)},CText:({$$attributes:t=[],content:e,...r})=>S.createElement("span",{...r,...ot(t)},e),CCanvas:({afterMount:t,beforeDestroy:e,$$attributes:r=[],...n})=>(S.useEffect(()=>(t==null||t(n),()=>{e==null||e(n)}),[]),S.createElement("canvas",{...n,...ot(r)})),CNativeTag:({children:t,$$attributes:e=[],htmlTag:r="div",...n})=>{let o=t;Array.isArray(t)||(o=[t]);const{style:a={},...s}=ot(e),i={...a,...n.style||{}};return S.createElement(r,{...n,...s,style:i},...o)}};class Bm{constructor(){b(this,"refMap",new Map)}get(e){return this.refMap.get(e)}add(e,r){this.refMap.set(e,r)}remove(e){this.refMap.delete(e)}destroy(){this.refMap.clear()}}class sa extends S.Component{constructor(r){super(r);b(this,"refManager");b(this,"dynamicComponentInstanceMap",new Map);b(this,"onGetRef",(r,n,o)=>{var a,s;(s=(a=this.props).onGetRef)==null||s.call(a,r,n,o),this.dynamicComponentInstanceMap.set(n.id,o),this.refManager.add(n.value.refId||n.id,r)});b(this,"rerender",r=>{if(this.props.adapter.clear(),(r==null?void 0:r.nodeType)==="PAGE"&&r)this.setState({pageModel:r});else if(Rt(r)&&so(r)){const n=r;this.setState({pageModel:new ye(n,{materials:this.state.pageModel.materialsModel.rawValue})})}});this.state={pageModel:r.pageModel||new ye(r.page)},this.refManager=new Bm}getPageModel(){return this.state.pageModel}componentDidMount(){const{render:r}=this.props;r&&(r.ref.current=this)}componentWillUnmount(){this.refManager.destroy()}render(){const{props:r}=this,{adapter:n,onGetComponent:o,onComponentDestroy:a,onComponentMount:s}=r,{pageModel:i}=this.state;if(!i)return console.warn("pageModel is null"),null;const c={...Lm,...r.components},u=this.props.$$context??{};return u.refs=this.refManager,n.pageRender(i,{libs:{},components:c,onGetRef:this.onGetRef,onGetComponent:o,onComponentMount:s,onComponentDestroy:a,$$context:u,renderMode:r.renderMode,processNodeConfigHook:r.processNodeConfigHook})}}const Fm=()=>{const t=S.useRef(null);return{ref:t,rerender:function(...e){t.current&&t.current.rerender(...e)}}};class Um extends S.Component{constructor(r){super(r);b(this,"onDoubleClick",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:""}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){var o,a;(a=(o=this.props).onError)==null||a.call(o,n)}render(){if(this.state.hasError){const{onDoubleClick:r}=this,n=this.props.node.value;console.error(this.props.node,this.props.children);const o=S.createElement("div",{style:{backgroundColor:"rgb(255 206 215 / 13%)",padding:"5px",color:"#ff0000b0",textAlign:"center",fontSize:"12px"}},"Render error, node id: ",n.id,", node name:",n.title," component name:",n.title||n.componentName,S.createElement("p",null,"msg: ",String(this.state.error)),S.createElement("button",{onDoubleClick:r,style:{border:"1px solid rgba(100,100,100,0.1)",backgroundColor:"#fff",padding:"5px 10px",borderRadius:"2px",color:"gray",cursor:"pointer",marginTop:"5px"}},"double click to refresh"),S.createElement("div",{style:{display:"none"}}));return S.createElement(this.props.targetComponent,{onlyRenderChild:!0},o)}return this.props.children}}class ca{constructor(){b(this,"instanceMap",new Map)}get(e){return this.instanceMap.get(e)}add(e,r){const n=this.instanceMap.get(e);n?n.push(r):this.instanceMap.set(e,[r])}remove(e,r){const n=this.instanceMap.get(e);if(r!==void 0&&Array.isArray(n)){const o=n.filter(a=>a!==r);this.instanceMap.set(e,o)}else this.instanceMap.delete(e)}destroy(){this.instanceMap.clear()}}const ua=t=>{const{node:e}=t,r=S.useMemo(()=>{const i=e.isContainer();return Rt(i)?i:{placeholder:"Drag the component to place it",width:"100%",height:"100%",style:{}}},[t.node]),{placeholder:n,height:o,width:a,style:s}=r;return S.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",width:a,height:o,...s}},n)};class km extends S.Component{constructor(r){super(r);b(this,"instanceManager",new ca);b(this,"renderRef");b(this,"dropPlaceholder",ua);b(this,"_components",{});b(this,"onGetComponent",(r,n)=>{var c,u;const o=this;let a=r;const s=(u=(c=n.material)==null?void 0:c.value.advanceCustom)==null?void 0:u.wrapComponent;s&&(a=s(r,{node:n,ctx:window.__C_ENGINE_DESIGNER_PLUGIN_CTX__}));class i extends S.Component{constructor(){super(...arguments);b(this,"_DESIGN_BOX",!0);b(this,"_NODE_MODEL",n);b(this,"_NODE_ID",n.id);b(this,"_UNIQUE_ID",`${n.id}_${Z()}`);b(this,"_STATUS")}componentDidMount(){o.instanceManager.add(n.id,this)}componentWillUnmount(){this._STATUS="DESTROY",o.instanceManager.remove(n.id,this)}render(){var O,C;const{children:f=[],onlyRenderChild:p,...h}=this.props;let y=f;if(Dt(f)||(y=[f]),!!!y.filter(Boolean).length&&(n.isContainer()||n.value.componentName===Tt.ROOT_CONTAINER)){const P=(C=(O=n.material)==null?void 0:O.value.advanceCustom)==null?void 0:C.dropPlaceholder;y.push(S.createElement(P||o.dropPlaceholder,{node:n}))}return p?y:S.createElement(a,h,...y)}}return S.forwardRef(function(d,f){return S.createElement(Um,{node:n,targetComponent:i},S.createElement(i,{ref:f,...d}))})});this.updateComponents(this.props.components),this.renderRef=S.createRef(),r.dropPlaceholder&&(this.dropPlaceholder=r.dropPlaceholder)}updateComponents(r={}){this._components=Object.assign(this._components,r),this.forceUpdate()}componentDidMount(){var r,n;this.updateComponents(this.props.components),(n=(r=this.props).onMount)==null||n.call(r,this)}getPageModel(){var r;return(r=this.renderRef.current)==null?void 0:r.state.pageModel}rerender(r){var n;return(n=this.renderRef.current)==null?void 0:n.rerender(r)}getInstancesById(r,n){let o=[...this.instanceManager.get(r)||[]];return n!==void 0&&(o=o.filter(a=>n===(a==null?void 0:a._UNIQUE_ID))),o}getInstanceByDom(r){const n=la(r);if(!n)return null;const o=fa(n);return(o==null?void 0:o.stateNode)||null}getDomsById(r,n){const o=this.getInstancesById(r),a=[];return o==null||o.forEach(s=>{var c;if((s==null?void 0:s._STATUS)==="DESTROY")return;const i=ga.findDOMNode(s);if(i&&!(i instanceof Text))if(n){const u=Array.from(((c=i.querySelectorAll)==null?void 0:c.call(i,n))||[]);a.push(...u)}else a.push(i)}),a}getDomRectById(r,n){return this.getDomsById(r,n).map(s=>s==null?void 0:s.getBoundingClientRect()).filter(Boolean)}render(){const{props:r,onGetComponent:n}=this,{render:o,...a}=r;return o&&(o.ref.current=this),S.createElement(sa,{onGetComponent:n,...a,components:this._components,processNodeConfigHook:(s,i)=>{var h,y;if(i.nodeType!=="NODE")return s;const{props:c,condition:u}=s;let l={...c};const d=((h=i.value.configure)==null?void 0:h.devState)||{},f=(y=i.material)==null?void 0:y.value.fixedProps;if(f!==void 0){if(Rt(f))l={...l,...f};else if(typeof f=="function"){const _=f(l);l={...l,..._}}}let p=u;return d.condition===!1&&(p=d.condition),{props:pm(l,d.props||{}),condition:p}},ref:this.renderRef})}}const la=t=>{if(!t)return null;const e=Object.keys(t).find(r=>r.startsWith("__reactInternalInstance$")||r.startsWith("__reactFiber$"))||"";return e?t[e]:la(t.parentElement)},fa=t=>{var e;return t?(e=t==null?void 0:t.stateNode)!=null&&e._DESIGN_BOX?t:fa(t.return):null},Vm=()=>{const t=S.useRef(null);return{ref:t,rerender:function(...e){t.current&&t.current.rerender(...e)},getInstancesById(e,r){var n;return((n=t.current)==null?void 0:n.getInstancesById(e,r))||[]},getInstanceByDom(e){var r;return((r=t.current)==null?void 0:r.getInstanceByDom(e))||null},getDomsById(e,r){var n;return((n=t.current)==null?void 0:n.getDomsById(e,r))||[]},getDomRectById(e,r){var n;return((n=t.current)==null?void 0:n.getDomRectById(e,r))||[]}}};var da={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(Em,function(){var r=function(){},n={},o={},a={};function s(f,p){f=f.push?f:[f];var h=[],y=f.length,_=y,O,C,P,x;for(O=function(L,z){z.length&&h.push(L),_--,_||p(h)};y--;){if(C=f[y],P=o[C],P){O(C,P);continue}x=a[C]=a[C]||[],x.push(O)}}function i(f,p){if(f){var h=a[f];if(o[f]=p,!!h)for(;h.length;)h[0](f,p),h.splice(0,1)}}function c(f,p){f.call&&(f={success:f}),p.length?(f.error||r)(p):(f.success||r)(f)}function u(f,p,h,y){var _=document,O=h.async,C=(h.numRetries||0)+1,P=h.before||r,x=f.replace(/[\?|#].*$/,""),L=f.replace(/^(css|img|module|nomodule)!/,""),z,ne,E;if(y=y||0,/(^css!|\.css$)/.test(x))E=_.createElement("link"),E.rel="stylesheet",E.href=L,z="hideFocus"in E,z&&E.relList&&(z=0,E.rel="preload",E.as="style");else if(/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(x))E=_.createElement("img"),E.src=L;else if(E=_.createElement("script"),E.src=L,E.async=O===void 0?!0:O,ne="noModule"in E,/^module!/.test(x)){if(!ne)return p(f,"l");E.type="module"}else if(/^nomodule!/.test(x)&&ne)return p(f,"l");E.onload=E.onerror=E.onbeforeload=function(st){var _t=st.type[0];if(z)try{E.sheet.cssText.length||(_t="e")}catch(Ee){Ee.code!=18&&(_t="e")}if(_t=="e"){if(y+=1,y<C)return u(f,p,h,y)}else if(E.rel=="preload"&&E.as=="style")return E.rel="stylesheet";p(f,_t,st.defaultPrevented)},P(f,E)!==!1&&_.head.appendChild(E)}function l(f,p,h){f=f.push?f:[f];var y=f.length,_=y,O=[],C,P;for(C=function(x,L,z){if(L=="e"&&O.push(x),L=="b")if(z)O.push(x);else return;y--,y||p(O)},P=0;P<_;P++)u(f[P],C,h)}function d(f,p,h){var y,_;if(p&&p.trim&&(y=p),_=(y?h:p)||{},y){if(y in n)throw"LoadJS";n[y]=!0}function O(C,P){l(f,function(x){c(_,x),C&&c({success:C,error:P},x),i(y,x)},_)}if(_.returnPromise)return new Promise(O);O()}return d.ready=function(p,h){return s(p,function(y){c(h,y)}),d},d.done=function(p){i(p,[])},d.reset=function(){n={},o={},a={}},d.isDefined=function(p){return p in n},d})})(da);var Gm=da.exports;const pa=$m(Gm);class zm{constructor(e,r){b(this,"assets");b(this,"loadStatus");b(this,"win",window);b(this,"_onSuccessList",[]);b(this,"_onErrorList",[]);this.assets=JSON.parse(JSON.stringify(e||[])),this.loadStatus="INIT",r!=null&&r.window&&(this.win=r.window)}load(){const e=this.assets||[],r=[];for(let n=0;n<e.length;n++){const o=e[n];o.id||(o.id=Z()),r.push(o.id);const a=o.resources.map(s=>s.src);a.length&&pa(a,o.id,{async:!1,before:(s,i)=>(this.win.document.body.appendChild(i),!1)})}return new Promise((n,o)=>{if(e.length===0){this._onSuccessList.forEach(a=>a()),n("");return}pa.ready(r,{success:()=>{this._onSuccessList.forEach(a=>a()),n("")},error:a=>{this._onErrorList.forEach(s=>s(a)),o(a)}})})}onSuccess(e){return this._onSuccessList.push(e),this}onError(e){return this._onErrorList.push(e),this}}g.AssetLoader=zm,g.ComponentInstanceManager=ca,g.DefaultDropPlaceholder=ua,g.DefineReactAdapter=oa,g.DesignRender=km,g.ReactAdapter=Cm,g.Render=sa,g.canAcceptsRef=Ko,g.collectVariable=vm,g.compWrapper=Xo,g.convertCodeStringToFunction=Zo,g.findComponentByChainRefer=ra,g.flatObject=gm,g.formatSourceStylePropertyName=Dr,g.getAdapter=Ur,g.getCSSTextValue=mm,g.getComponentsLibs=ym,g.getMatchVal=ta,g.getNodeCssClassName=Oe,g.getObjFromArrayMap=xr,g.getThirdLibs=bm,g.isClass=hm,g.runExpression=bt,g.shouldConstruct=Yo,g.useDesignRender=Vm,g.useRender=Fm,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
28
|
+
*/var Nm=S,Tm=Symbol.for("react.element"),Am=Symbol.for("react.fragment"),Mm=Object.prototype.hasOwnProperty,Pm=Nm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xm={key:!0,ref:!0,__self:!0,__source:!0};function ia(t,e,r){var n,o={},a=null,s=null;r!==void 0&&(a=""+r),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Mm.call(e,n)&&!xm.hasOwnProperty(n)&&(o[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)o[n]===void 0&&(o[n]=e[n]);return{$$typeof:Tm,type:t,key:a,ref:s,props:o,_owner:Pm.current}}we.Fragment=Am,we.jsx=ia,we.jsxs=ia,aa.exports=we;var Dm=aa.exports;const Im=Dm.jsx,ot=t=>{const e={};return t.forEach(r=>{e[r.key]=r.value}),e},Rm=[...wm,...Sf].reduce((t,e)=>(t[e]=({children:r,$$attributes:n=[],...o})=>{let a=r;return Array.isArray(r)||(a=[r]),S.createElement(e,{...o,...ot(n)},...a)},t),{}),Lm={RootContainer:({children:t})=>t,...Rm,CContainer:({children:t,$$attributes:e=[],afterMount:r,beforeDestroy:n,...o})=>{let a=t;return Array.isArray(t)||(a=[t]),S.useEffect(()=>(r==null||r(o),()=>{n==null||n(o)}),[]),Im("div",{...o,...ot(e),children:a})},CVideo:({children:t,$$attributes:e=[],...r})=>{let n=t;return Array.isArray(t)||(n=[t]),S.createElement("video",{...r,...ot(e)},...n)},CAudio:({children:t,$$attributes:e=[],...r})=>{let n=t;return Array.isArray(t)||(n=[t]),S.createElement("audio",{...r,...ot(e)},...n)},CBlock:({children:t,width:e,height:r,$$attributes:n=[],...o})=>{let a=t;Array.isArray(t)||(a=[t]),a=a.filter(u=>u!==void 0);const{style:s={},...i}=ot(n),c={height:r,width:e,...s,...o.style||{}};return S.createElement("div",{...o,...i,style:c},...a)},CImage:({children:t,$$attributes:e=[],...r})=>{let n=t;return Array.isArray(t)||(n=[t]),S.createElement("img",{...r,...ot(e)},...n)},CText:({$$attributes:t=[],content:e,...r})=>S.createElement("span",{...r,...ot(t)},e),CCanvas:({afterMount:t,beforeDestroy:e,$$attributes:r=[],...n})=>(S.useEffect(()=>(t==null||t(n),()=>{e==null||e(n)}),[]),S.createElement("canvas",{...n,...ot(r)})),CNativeTag:({children:t,$$attributes:e=[],htmlTag:r="div",...n})=>{let o=t;Array.isArray(t)||(o=[t]);const{style:a={},...s}=ot(e),i={...a,...n.style||{}};return S.createElement(r,{...n,...s,style:i},...o)}};class Bm{constructor(){b(this,"refMap",new Map)}get(e){return this.refMap.get(e)}add(e,r){this.refMap.set(e,r)}remove(e){this.refMap.delete(e)}destroy(){this.refMap.clear()}}class sa extends S.Component{constructor(r){super(r);b(this,"refManager");b(this,"dynamicComponentInstanceMap",new Map);b(this,"onGetRef",(r,n,o)=>{var a,s;(s=(a=this.props).onGetRef)==null||s.call(a,r,n,o),this.dynamicComponentInstanceMap.set(n.id,o),this.refManager.add(n.value.refId||n.id,r)});b(this,"rerender",r=>{if(this.props.adapter.clear(),(r==null?void 0:r.nodeType)==="PAGE"&&r)this.setState({pageModel:r});else if(Rt(r)&&so(r)){const n=r;this.setState({pageModel:new ye(n,{materials:this.state.pageModel.materialsModel.rawValue})})}});this.state={pageModel:r.pageModel||new ye(r.page)},this.refManager=new Bm}getPageModel(){return this.state.pageModel}componentDidMount(){const{render:r}=this.props;r&&(r.ref.current=this)}componentWillUnmount(){this.refManager.destroy()}render(){const{props:r}=this,{adapter:n,onGetComponent:o,onComponentDestroy:a,onComponentMount:s}=r,{pageModel:i}=this.state;if(!i)return console.warn("pageModel is null"),null;const c={...Lm,...r.components},u=this.props.$$context??{};return u.refs=this.refManager,n.pageRender(i,{libs:{},components:c,onGetRef:this.onGetRef,onGetComponent:o,onComponentMount:s,onComponentDestroy:a,$$context:u,renderMode:r.renderMode,processNodeConfigHook:r.processNodeConfigHook})}}const Fm=()=>{const t=S.useRef(null);return{ref:t,rerender:function(...e){t.current&&t.current.rerender(...e)}}};class Um extends S.Component{constructor(r){super(r);b(this,"onDoubleClick",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:""}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){var o,a;(a=(o=this.props).onError)==null||a.call(o,n)}render(){if(this.state.hasError){const{onDoubleClick:r}=this,n=this.props.node.value;console.error(this.props.node,this.props.children);const o=S.createElement("div",{style:{backgroundColor:"rgb(255 206 215 / 13%)",padding:"5px",color:"#ff0000b0",textAlign:"center",fontSize:"12px"}},"Render error, node id: ",n.id,", node name:",n.title," component name:",n.title||n.componentName,S.createElement("p",null,"msg: ",String(this.state.error)),S.createElement("button",{onDoubleClick:r,style:{border:"1px solid rgba(100,100,100,0.1)",backgroundColor:"#fff",padding:"5px 10px",borderRadius:"2px",color:"gray",cursor:"pointer",marginTop:"5px"}},"double click to refresh"),S.createElement("div",{style:{display:"none"}}));return S.createElement(this.props.targetComponent,{onlyRenderChild:!0},o)}return this.props.children}}class ca{constructor(){b(this,"instanceMap",new Map)}get(e){return this.instanceMap.get(e)}add(e,r){const n=this.instanceMap.get(e);n?n.push(r):this.instanceMap.set(e,[r])}remove(e,r){const n=this.instanceMap.get(e);if(r!==void 0&&Array.isArray(n)){const o=n.filter(a=>a!==r);this.instanceMap.set(e,o)}else this.instanceMap.delete(e)}destroy(){this.instanceMap.clear()}}const ua=t=>{const{node:e}=t,r=S.useMemo(()=>{const i=e.isContainer();return Rt(i)?i:{placeholder:"Drag the component to place it",width:"100%",height:"100%",style:{}}},[t.node]),{placeholder:n,height:o,width:a,style:s}=r;return S.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",width:a,height:o,...s}},n)};class km extends S.Component{constructor(r){super(r);b(this,"instanceManager",new ca);b(this,"renderRef");b(this,"dropPlaceholder",ua);b(this,"_components",{});b(this,"onGetComponent",(r,n)=>{var c,u;const o=this;let a=r;const s=(u=(c=n.material)==null?void 0:c.value.advanceCustom)==null?void 0:u.wrapComponent;s&&(a=s(r,{node:n,ctx:window.__C_ENGINE_DESIGNER_PLUGIN_CTX__}));class i extends S.Component{constructor(){super(...arguments);b(this,"_DESIGN_BOX",!0);b(this,"_NODE_MODEL",n);b(this,"_NODE_ID",n.id);b(this,"_UNIQUE_ID",`${n.id}_${Z()}`);b(this,"_STATUS")}componentDidMount(){o.instanceManager.add(n.id,this)}componentWillUnmount(){this._STATUS="DESTROY",o.instanceManager.remove(n.id,this)}render(){var O,C;const{children:f=[],onlyRenderChild:p,...h}=this.props;let y=f;if(Dt(f)||(y=[f]),!!!y.filter(Boolean).length&&(n.isContainer()||n.value.componentName===Tt.ROOT_CONTAINER)){const P=(C=(O=n.material)==null?void 0:O.value.advanceCustom)==null?void 0:C.dropPlaceholder;y.push(S.createElement(P||o.dropPlaceholder,{node:n}))}return p?y:S.createElement(a,h,...y)}}return S.forwardRef(function(d,f){return S.createElement(Um,{node:n,targetComponent:i},S.createElement(i,{ref:f,...d}))})});this.updateComponents(this.props.components),this.renderRef=S.createRef(),r.dropPlaceholder&&(this.dropPlaceholder=r.dropPlaceholder)}updateComponents(r={}){this._components=Object.assign(this._components,r),this.forceUpdate()}componentDidMount(){var r,n;this.updateComponents(this.props.components),(n=(r=this.props).onMount)==null||n.call(r,this)}getPageModel(){var r;return(r=this.renderRef.current)==null?void 0:r.state.pageModel}rerender(r){var n;return(n=this.renderRef.current)==null?void 0:n.rerender(r)}getInstancesById(r,n){let o=[...this.instanceManager.get(r)||[]];return n!==void 0&&(o=o.filter(a=>n===(a==null?void 0:a._UNIQUE_ID))),o}getInstanceByDom(r){const n=la(r);if(!n)return null;const o=fa(n);return(o==null?void 0:o.stateNode)||null}getDomsById(r,n){const o=this.getInstancesById(r),a=[];return o==null||o.forEach(s=>{var c;if((s==null?void 0:s._STATUS)==="DESTROY")return;const i=ga.findDOMNode(s);if(i&&!(i instanceof Text))if(n){const u=Array.from(((c=i.querySelectorAll)==null?void 0:c.call(i,n))||[]);a.push(...u)}else a.push(i)}),a}getDomRectById(r,n){return this.getDomsById(r,n).map(s=>s==null?void 0:s.getBoundingClientRect()).filter(Boolean)}render(){const{props:r,onGetComponent:n}=this,{render:o,...a}=r;return o&&(o.ref.current=this),S.createElement(sa,{onGetComponent:n,...a,components:this._components,processNodeConfigHook:(s,i)=>{var h,y;if(i.nodeType!=="NODE")return s;const{props:c,condition:u}=s;let l={...c};const d=((h=i.value.configure)==null?void 0:h.devState)||{},f=(y=i.material)==null?void 0:y.value.fixedProps;if(f!==void 0){if(Rt(f))l={...l,...f};else if(typeof f=="function"){const _=f(l);l={...l,..._}}}let p=u;return d.condition===!1&&(p=d.condition),{props:pm(l,d.props||{}),condition:p}},ref:this.renderRef})}}const la=t=>{if(!t)return null;const e=Object.keys(t).find(r=>r.startsWith("__reactInternalInstance$")||r.startsWith("__reactFiber$"))||"";return e?t[e]:la(t.parentElement)},fa=t=>{var e;return t?(e=t==null?void 0:t.stateNode)!=null&&e._DESIGN_BOX?t:fa(t.return):null},Vm=()=>{const t=S.useRef(null);return{ref:t,rerender:function(...e){t.current&&t.current.rerender(...e)},getInstancesById(e,r){var n;return((n=t.current)==null?void 0:n.getInstancesById(e,r))||[]},getInstanceByDom(e){var r;return((r=t.current)==null?void 0:r.getInstanceByDom(e))||null},getDomsById(e,r){var n;return((n=t.current)==null?void 0:n.getDomsById(e,r))||[]},getDomRectById(e,r){var n;return((n=t.current)==null?void 0:n.getDomRectById(e,r))||[]}}};var da={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(Em,function(){var r=function(){},n={},o={},a={};function s(f,p){f=f.push?f:[f];var h=[],y=f.length,_=y,O,C,P,x;for(O=function(L,z){z.length&&h.push(L),_--,_||p(h)};y--;){if(C=f[y],P=o[C],P){O(C,P);continue}x=a[C]=a[C]||[],x.push(O)}}function i(f,p){if(f){var h=a[f];if(o[f]=p,!!h)for(;h.length;)h[0](f,p),h.splice(0,1)}}function c(f,p){f.call&&(f={success:f}),p.length?(f.error||r)(p):(f.success||r)(f)}function u(f,p,h,y){var _=document,O=h.async,C=(h.numRetries||0)+1,P=h.before||r,x=f.replace(/[\?|#].*$/,""),L=f.replace(/^(css|img|module|nomodule)!/,""),z,ne,E;if(y=y||0,/(^css!|\.css$)/.test(x))E=_.createElement("link"),E.rel="stylesheet",E.href=L,z="hideFocus"in E,z&&E.relList&&(z=0,E.rel="preload",E.as="style");else if(/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(x))E=_.createElement("img"),E.src=L;else if(E=_.createElement("script"),E.src=L,E.async=O===void 0?!0:O,ne="noModule"in E,/^module!/.test(x)){if(!ne)return p(f,"l");E.type="module"}else if(/^nomodule!/.test(x)&&ne)return p(f,"l");E.onload=E.onerror=E.onbeforeload=function(st){var _t=st.type[0];if(z)try{E.sheet.cssText.length||(_t="e")}catch(Ee){Ee.code!=18&&(_t="e")}if(_t=="e"){if(y+=1,y<C)return u(f,p,h,y)}else if(E.rel=="preload"&&E.as=="style")return E.rel="stylesheet";p(f,_t,st.defaultPrevented)},P(f,E)!==!1&&_.head.appendChild(E)}function l(f,p,h){f=f.push?f:[f];var y=f.length,_=y,O=[],C,P;for(C=function(x,L,z){if(L=="e"&&O.push(x),L=="b")if(z)O.push(x);else return;y--,y||p(O)},P=0;P<_;P++)u(f[P],C,h)}function d(f,p,h){var y,_;if(p&&p.trim&&(y=p),_=(y?h:p)||{},y){if(y in n)throw"LoadJS";n[y]=!0}function O(C,P){l(f,function(x){c(_,x),C&&c({success:C,error:P},x),i(y,x)},_)}if(_.returnPromise)return new Promise(O);O()}return d.ready=function(p,h){return s(p,function(y){c(h,y)}),d},d.done=function(p){i(p,[])},d.reset=function(){n={},o={},a={}},d.isDefined=function(p){return p in n},d})})(da);var Gm=da.exports;const pa=$m(Gm);class zm{constructor(e,r){b(this,"assets");b(this,"loadStatus");b(this,"win",window);b(this,"_onSuccessList",[]);b(this,"_onErrorList",[]);this.assets=JSON.parse(JSON.stringify(e||[])),this.loadStatus="INIT",r!=null&&r.window&&(this.win=r.window)}load(e){const r=this.assets||[],n=[];for(let o=0;o<r.length;o++){const a=r[o];a.id||(a.id=Z()),n.push(a.id);const s=a.resources.map(i=>i.src);s.length&&pa(s,a.id,{async:(e==null?void 0:e.async)??!1,before:(i,c)=>(this.win.document.body.appendChild(c),!1)})}return new Promise((o,a)=>{if(r.length===0){this._onSuccessList.forEach(s=>s()),o("");return}pa.ready(n,{success:()=>{this._onSuccessList.forEach(s=>s()),o("")},error:s=>{this._onErrorList.forEach(i=>i(s)),a(s)}})})}onSuccess(e){return this._onSuccessList.push(e),this}onError(e){return this._onErrorList.push(e),this}}g.AssetLoader=zm,g.ComponentInstanceManager=ca,g.DefaultDropPlaceholder=ua,g.DefineReactAdapter=oa,g.DesignRender=km,g.ReactAdapter=Cm,g.Render=sa,g.canAcceptsRef=Ko,g.collectVariable=vm,g.compWrapper=Xo,g.convertCodeStringToFunction=Zo,g.findComponentByChainRefer=ra,g.flatObject=gm,g.formatSourceStylePropertyName=Dr,g.getAdapter=Ur,g.getCSSTextValue=mm,g.getComponentsLibs=ym,g.getMatchVal=ta,g.getNodeCssClassName=Oe,g.getObjFromArrayMap=xr,g.getThirdLibs=bm,g.isClass=hm,g.runExpression=bt,g.shouldConstruct=Yo,g.useDesignRender=Vm,g.useRender=Fm,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
29
29
|
//# sourceMappingURL=index.umd.js.map
|