From fe405838a461b4890dd8c26891d8800c283585ad Mon Sep 17 00:00:00 2001 From: Rizky Date: Tue, 27 Aug 2024 06:10:12 +0700 Subject: [PATCH] fix --- app/srv/core/main.js | 2 +- app/web/src/nova/ed/logic/ed-global.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/srv/core/main.js b/app/srv/core/main.js index 0e5d1d93..8762eadc 100644 --- a/app/srv/core/main.js +++ b/app/srv/core/main.js @@ -93,7 +93,7 @@ Error generating stack: `+o.message+` ${Ly(e,t.mode)} ${wy(e,t.mode)} ${jy(e,t.mode)} - `,(t?.hover||t?.active)&&My({item:e,hover:t?.hover,active:t?.active}),_y(e,t.mode)])}catch(n){console.log(n)}return cx([])};var Uy=Z(me()),ms=(e,t,n,r,i)=>{let o=t.item,s;o.component?.style&&(s={style:o.component.style,className:Sd(o.component.style,{mode:e.mode})});let l={className:Sd(o,{mode:e.mode}),inherit:s},u={},c=t.item.childs,a;return t.item.type==="text"?(a=null,l.dangerouslySetInnerHTML={__html:t.item.html||""}):a=Array.isArray(c)&&c?.map(p=>{if(!p)return null;let{id:f}=p,d=n?e.layout?.meta[f]:e.meta[f];return d?(0,Uy.jsx)(Dn,{meta:d,is_layout:n,passprop:{...r},depth:i+1},f):(p.type==="item"&&p.component?.id&&console.error(`Warning component ${p.name} - ${p.component.id} failed to load.`),null)}),l.children=a,t.item.adv?.html?(delete l.children,l.dangerouslySetInnerHTML={__html:t.item.adv?.html}):t.item.adv?.js&&!t.item.adv.js.includes("children")&&(delete l.children,delete l.dangerouslySetInnerHTML),{props:l,text_props:u}};y();w();_();var Z_=Z(Ze());y();w();_();var V_=Z(Pa());y();w();_();y();w();_();var Ki={NORMAL:0,WILDCARD:1,PLACEHOLDER:2};function La(e={}){let t={options:e,rootNode:D_(),staticRoutesMap:{}},n=r=>e.strictTrailingSlash?r:r.replace(/\/$/,"")||"/";if(e.routes)for(let r in e.routes)L_(t,n(r),e.routes[r]);return{ctx:t,lookup:r=>Pb(t,n(r)),insert:(r,i)=>L_(t,n(r),i),remove:r=>Lb(t,n(r))}}function Pb(e,t){let n=e.staticRoutesMap[t];if(n)return n.data;let r=t.split("/"),i={},o=!1,s=null,l=e.rootNode,u=null;for(let c=0;c1){let f=r.length-c;l=l.placeholderChildren.find(d=>d.maxDepth===f)||null}else l=l.placeholderChildren[0]||null;if(!l)break;l.paramName&&(i[l.paramName]=a),o=!0}else l=p}return(l===null||l.data===null)&&s!==null&&(l=s,i[l.paramName||"_"]=u,o=!0),l?o?{...l.data,params:o?i:void 0}:l.data:null}function L_(e,t,n){let r=!0,i=t.split("/"),o=e.rootNode,s=0,l=[o];for(let u of i){let c;if(c=o.children.get(u))o=c;else{let a=Db(u);c=D_({type:a,parent:o}),o.children.set(u,c),a===Ki.PLACEHOLDER?(c.paramName=u==="*"?`_${s++}`:u.slice(1),o.placeholderChildren.push(c),r=!1):a===Ki.WILDCARD&&(o.wildcardChildNode=c,c.paramName=u.slice(3)||"_",r=!1),l.push(c),o=c}}for(let[u,c]of l.entries())c.maxDepth=Math.max(l.length-u,c.maxDepth||0);return o.data=n,r===!0&&(e.staticRoutesMap[t]=o),o}function Lb(e,t){let n=!1,r=t.split("/"),i=e.rootNode;for(let o of r)if(i=i.children.get(o),!i)return n;if(i.data){let o=r.at(-1)||"";i.data=null,Object.keys(i.children).length===0&&i.parent&&(i.parent.children.delete(o),i.parent.wildcardChildNode=null,i.parent.placeholderChildren=[]),n=!0}return n}function D_(e={}){return{type:e.type||Ki.NORMAL,maxDepth:0,parent:e.parent||null,children:new Map,data:e.data||null,paramName:e.paramName||null,wildcardChildNode:null,placeholderChildren:[]}}function Db(e){return e.startsWith("**")?Ki.WILDCARD:e[0]===":"||e==="*"?Ki.PLACEHOLDER:Ki.NORMAL}var Mb={id:"",name:"",domain:"",config:{api_url:""},deploy_name:"",js:"",js_compiled:"",responsive:"",layout:{id:"--",meta:void 0,entry:[]}},jb={id:"",name:"",url:"",snapshot:null,comps:{}};var st={active_id:!1,comp_id:!1,instance_comp_id:!1,instance_item_id:!1},qi={should_render_main:!0,hover:{id:"",tree:!1},scope:{},script_nav:{list:[],idx:-1},text:{id:"",content:"",timeout:null,el:null},get item_id(){return st.active_id===!1&&(st.active_id=localStorage.getItem("prasi-active-id")||""),st.active_id||""},set item_id(e){localStorage.setItem("prasi-active-id",e||""),st.active_id=e||""},get comp_id(){return st.comp_id===!1&&(st.comp_id=localStorage.getItem("prasi-comp-id")||""),st.comp_id||""},set comp_id(e){localStorage.setItem("prasi-comp-id",e||""),st.comp_id=e||""},instance:{get comp_id(){return st.instance_comp_id===!1&&(st.instance_comp_id=localStorage.getItem("prasi-instance-comp-id")||""),st.instance_comp_id||""},set comp_id(e){localStorage.setItem("prasi-instance-comp-id",e||""),st.instance_comp_id=e||""},get item_id(){return st.instance_item_id===!1&&(st.instance_item_id=localStorage.getItem("prasi-instance-item-id")||""),st.instance_item_id||""},set item_id(e){localStorage.setItem("prasi-instance-item-id",e||""),st.instance_item_id=e||""}}},W4={mode:"",user:{id:"",username:"",client_id:""},clients:{},status:"init",preview:{url_cache:new Set,route_cache:La(),page_cache:{},meta_cache:{}},sync:void 0,site:gr(Mb),site_tstamp:Date.now(),site_exports:{},site_dts:"",site_dts_entry:{},prisma_ext:"",script:{site_types:{},loaded:!1,do_edit:async(e,t)=>{},db:null,api:null,init_local_effect:{}},page:{history:{id:"",show:!1},root_id:"root",cur:jb,doc:null,list:{},building:!1,meta:{},entry:[],tree:[],render:()=>{}},comp:{doc:null,item:null,loaded:{},list:{},group:{}},code:{},global_prop:[],ui:{build:{status:"ready"},monaco:null,comp_editable:localStorage.getItem("prasi-comp-editable")==="yes",zoom:localStorage.zoom||"100%",side:{prop:!0},layout:{left:parseInt(localStorage.getItem("prasi-layout-left")||"250"),right:parseInt(localStorage.getItem("prasi-layout-right")||"250")},prevent_indent_hook:!1,syncing:!1,tree:{item_loading:[],search:"",search_ref:null,search_mode:{Name:!0,JS:!1,HTML:!1,CSS:!1},rename_id:"",open_all:!1,open:{}},popup:{file:{enabled:!1,open:!1,picker:{value:"",on_pick:!1,multi:!1},path:"/",expanded:JSON.parse(localStorage.getItem("panel-file-expanded")||"{}"),entry:{},selected:new Set,action:null,file_renaming:"",file_ctx_menu_event:null,tree:[],tree_renaming:"",tree_ctx_path:"",tree_ctx_menu_event:null,preview:!0,upload:{started:!1,progress:{}}},code:{init:!1,open:!1,name:"site",log:"",loading:!1,rebuilding:!1,startup_status:"init",error:!1,show_log:!1,list:{}},page:{open:null,form:null},script:{open:!1,mode:"js",lastMode:"js",type:"item",prop_kind:"",prop_name:"",on_close:()=>{},typings:{status:"ok",err_msg:""},wb_render:()=>{}},site:null,site_form:null,comp:{preview_id:"",open:null,import:!1},comp_group:null,api:{open:!0}}}};y();w();_();var Da=e=>({isMobile:e.mode==="mobile",isDesktop:e.mode==="desktop",isEditor:location.pathname.startsWith("/ed/")});y();w();_();var Ad={transform:null},Ma=async(e,t)=>{Ad.transform||(Ad.transform=(await import("./esm-XKHB6BMI.js")).transform);let n={};for(let[r,i]of Object.entries(e)){n[r]=Ad.transform(i,{transforms:["typescript","imports","jsx"],preserveDynamicImport:!0,disableESTransforms:!0,filePath:t}).code;let o=['"use strict";'];for(let s of o)n[r].startsWith(s)&&(n[r]=n[r].substring(s.length).trim())}return n};y();w();_();var Xr=Z(Ze());y();w();_();var zn=window;y();w();_();var zb=fd("prasi-cache","prasi-cache-store"),M_={timeout:null,store:zb},ja=(e,t)=>{let n=[...j_(t,"navigate(",")"),...j_(t,"href = ",";")],r=e.page.cur.id;e.page.navs[r]||(e.page.navs[r]=new Set);for(let i of n)e.page.navs[r].add(i);clearTimeout(M_.timeout),M_.timeout=setTimeout(()=>{e.on_nav_loaded&&e.on_nav_loaded({urls:Array.from(e.page.navs[r])})},100)},j_=(e,t,n)=>{let r=0,i=0,o=[];for(;;){let s=e.indexOf(t,r);if(i=r,s>=0){let l=e[s+t.length];if(l==='"'||l==="'"||l==="`"){let u=e.indexOf(`${l}${n}`,s+t.length+1),c=e.substring(s+t.length+1,u);r=u+2+n.length,o.push(c)}}if(i===r)break}return o};y();w();_();var qr=Z(Ze());y();w();_();var z_=Z(xd()),Kr=Z(Ze());var Pd=Z(me()),F_=(e,t,n,r,i)=>o=>{let[s,l]=(0,Kr.useState)({}),u=o.idx||o.internal_key;n.item.script||(n.item.script={});let c=n.item.script;typeof u<"u"&&(n.item.script_keyed||(n.item.script_keyed={}),n.item.script_keyed[u]||(n.item.script_keyed[u]={}),c=n.item.script_keyed[u]),c.passprop||(c.passprop={});let a={},p=!1;for(let[h,S]of Object.entries(o))["children","key"].includes(h)||(p=!0,a[h]=S);let f={...r,...a};if(typeof u<"u"&&((typeof c.passprop.internal_key>"u"||u===c.passprop.internal_key)&&(c.passprop=f),f=c.passprop),n.editor_props=f,!Array.isArray(o.children)&&(0,Kr.isValidElement)(o.children)&&typeof o.children=="object"){let h=(0,z_.default)(o.children,"props.meta.item.component.props.child.content.childs");if(Array.isArray(h)){let S=!0;for(let k of h)!(0,Kr.isValidElement)(k)&&typeof k=="object"||(S=!1);if(S)return h.map(k=>{let m=e.meta[k.id];if(m||(e.meta[k.id]={item:k},m=e.meta[k.id]),m){if(Object.keys(m.item).length<=3&&m.mitem){let g={...m.item},v=m.mitem.toJSON();m.item={...v,...g}}return(0,Pd.jsx)(Dn,{is_layout:t,meta:m,passprop:f,parent_key:o.internal_key,depth:i},k.id)}return null})}}if(!Array.isArray(o.children)&&!(0,Kr.isValidElement)(o.children)&&typeof o.children=="object"){let h=o.children.id;if(h){let S=e.meta[h];if(!S){e.meta[h]={item:o.children},S=e.meta[h];let k=S.item.component?.id;k&&e.comp.load(k).then(m=>{if(m){for(let[v,x]of Object.entries(m)){let N=S.item;N[v]||(N[v]=x)}let g=S.item.component?.props;for(let[v,x]of Object.entries(m.component?.props||{}))g[v]||(g[v]=x);l({})}})}return(0,Pd.jsx)(Dn,{is_layout:t,meta:S,passprop:f,parent_key:o.internal_key,depth:i})}}return za(o,f,u?{parent_key:u}:void 0)},za=(e,t,n)=>{let r={};if(Array.isArray(e)?r.children=e:r=e,Array.isArray(r.children)){if(r.children.length===1)return Nd(r.children[0],r,t,n);let i=[];for(let o of r.children)i.push(Nd(o,r,t,n));return i}return Nd(r.children,r,t,n)},Nd=(e,t,n,r)=>{if((0,Kr.isValidElement)(e)){let i={...t};return delete i.children,{...e,props:{...e.props,...r,passprop:{...n,...i}}}}else if(Array.isArray(e))return za(e,n,r);return e};var Bt={},U_=(e,t,n)=>r=>{let i=(["prasi.avolut.com"].includes(location.hostname)||location.host==="localhost:4550")&&location.pathname.startsWith("/ed/"),o=n.item.id,{children:s,parent_key:l}=r,u=e.script?.init_local_effect,c=t?e.layout?.meta:e.meta,a=e.page.cur.id+"~"+o;if(!Bt[a])Bt[a]={mounted:!0,value:r.value};else if(!Bt[a].mounted){if(!B_.isEditor){for(let[k,m]of Object.entries(Bt[a].value))delete Bt[a].value[k];for(let[k,m]of Object.entries(gr(r.value)))Bt[a].value[k]=m}Bt[a].mounted=!0}let p=(0,qr.useRef)(Bt[a].value),[f,d]=(0,qr.useState)({}),h=p.current;return h.render=()=>{let k=window;!k.isEditor&&k.prasiContext.render?k.prasiContext.render():d({})},r.hook&&r.hook(h),(0,qr.useEffect)(()=>{if(n.parent?.instance_id&&c){let m=c[n.parent?.instance_id];if(m&&m.instances){for(let[g,v]of Object.entries(m.instances[n.parent.instance_id]))if(v===n.item.id){o=g;break}}}return!u[o]&&(typeof u=="object"&&(u[o]=!0),(async()=>r.effect&&await r.effect(h))()),()=>{Bt[a].mounted=!1}},[...r.deps||[],location.pathname]),(0,qr.useEffect)(()=>{i&&Bt[o]===null&&(async()=>r.effect&&(await r.effect(h),i&&(Bt[o]=h)))()},[Bt[o]]),za(s,{...n.script?.scope,[r.name]:h})};y();w();_();var Ld=Z(Pa());var vs=window,Xi=(e,t,n,r)=>{let i=r||{},o=t.get("id")||"";vs.prasiEditDevItem||(vs.prasiEditDevItem={});let s=vs.prasiEditDevItem[n];s||(vs.prasiEditDevItem[n]={},s=vs.prasiEditDevItem[n]);let l=()=>{let a=t.get("id")||"",p=s[a];return p||(s[a]=[],p=s[a]),p},u=t.toJSON(),c={...u,edit:{get props(){if(u.component?.props){let a={};for(let[p,f]of Object.entries(u.component.props))if(f.content){let d=t.get("component")?.get("props")?.get(p)?.get("content");if(d){let h=d.get("id")||"";i[h]?a[p]={mode:"jsx",value:i[h]}:a[p]={mode:"jsx",value:Xi(e,d,n,i)}}else a[p]={mode:"jsx",value:null}}else{let d=typeof f.valueBuilt=="string"?f.valueBuilt.trim():"";if(d.endsWith(`; + `,(t?.hover||t?.active)&&My({item:e,hover:t?.hover,active:t?.active}),_y(e,t.mode)])}catch(n){console.log(n)}return cx([])};var Uy=Z(me()),ms=(e,t,n,r,i)=>{let o=t.item,s;o.component?.style&&(s={style:o.component.style,className:Sd(o.component.style,{mode:e.mode})});let l={className:Sd(o,{mode:e.mode}),inherit:s},u={},c=t.item.childs,a;return t.item.type==="text"?(a=null,l.dangerouslySetInnerHTML={__html:t.item.html||""}):a=Array.isArray(c)&&c?.map(p=>{if(!p)return null;let{id:f}=p,d=n?e.layout?.meta[f]:e.meta[f];return d?(0,Uy.jsx)(Dn,{meta:d,is_layout:n,passprop:{...r},depth:i+1},f):(p.type==="item"&&p.component?.id&&console.error(`Warning component ${p.name} - ${p.component.id} failed to load.`),null)}),l.children=a,t.item.adv?.html?(delete l.children,l.dangerouslySetInnerHTML={__html:t.item.adv?.html}):t.item.adv?.js&&!t.item.adv.js.includes("children")&&(delete l.children,delete l.dangerouslySetInnerHTML),{props:l,text_props:u}};y();w();_();var Z_=Z(Ze());y();w();_();var V_=Z(Pa());y();w();_();y();w();_();var Ki={NORMAL:0,WILDCARD:1,PLACEHOLDER:2};function La(e={}){let t={options:e,rootNode:D_(),staticRoutesMap:{}},n=r=>e.strictTrailingSlash?r:r.replace(/\/$/,"")||"/";if(e.routes)for(let r in e.routes)L_(t,n(r),e.routes[r]);return{ctx:t,lookup:r=>Pb(t,n(r)),insert:(r,i)=>L_(t,n(r),i),remove:r=>Lb(t,n(r))}}function Pb(e,t){let n=e.staticRoutesMap[t];if(n)return n.data;let r=t.split("/"),i={},o=!1,s=null,l=e.rootNode,u=null;for(let c=0;c1){let f=r.length-c;l=l.placeholderChildren.find(d=>d.maxDepth===f)||null}else l=l.placeholderChildren[0]||null;if(!l)break;l.paramName&&(i[l.paramName]=a),o=!0}else l=p}return(l===null||l.data===null)&&s!==null&&(l=s,i[l.paramName||"_"]=u,o=!0),l?o?{...l.data,params:o?i:void 0}:l.data:null}function L_(e,t,n){let r=!0,i=t.split("/"),o=e.rootNode,s=0,l=[o];for(let u of i){let c;if(c=o.children.get(u))o=c;else{let a=Db(u);c=D_({type:a,parent:o}),o.children.set(u,c),a===Ki.PLACEHOLDER?(c.paramName=u==="*"?`_${s++}`:u.slice(1),o.placeholderChildren.push(c),r=!1):a===Ki.WILDCARD&&(o.wildcardChildNode=c,c.paramName=u.slice(3)||"_",r=!1),l.push(c),o=c}}for(let[u,c]of l.entries())c.maxDepth=Math.max(l.length-u,c.maxDepth||0);return o.data=n,r===!0&&(e.staticRoutesMap[t]=o),o}function Lb(e,t){let n=!1,r=t.split("/"),i=e.rootNode;for(let o of r)if(i=i.children.get(o),!i)return n;if(i.data){let o=r.at(-1)||"";i.data=null,Object.keys(i.children).length===0&&i.parent&&(i.parent.children.delete(o),i.parent.wildcardChildNode=null,i.parent.placeholderChildren=[]),n=!0}return n}function D_(e={}){return{type:e.type||Ki.NORMAL,maxDepth:0,parent:e.parent||null,children:new Map,data:e.data||null,paramName:e.paramName||null,wildcardChildNode:null,placeholderChildren:[]}}function Db(e){return e.startsWith("**")?Ki.WILDCARD:e[0]===":"||e==="*"?Ki.PLACEHOLDER:Ki.NORMAL}var Mb={id:"",name:"",domain:"",config:{api_url:""},deploy_name:"",js:"",js_compiled:"",responsive:"",layout:{id:"--",meta:void 0,entry:[]}},jb={id:"",name:"",url:"",snapshot:null,comps:{}};var st={active_id:!1,comp_id:!1,instance_comp_id:!1,instance_item_id:!1},qi={should_render_main:!0,hover:{id:"",tree:!1},scope:{},script_nav:{list:[],idx:-1},text:{id:"",content:"",timeout:null,el:null},get item_id(){return st.active_id===!1&&(st.active_id=localStorage.getItem("prasi-active-id")||""),st.active_id||""},set item_id(e){localStorage.setItem("prasi-active-id",e||""),st.active_id=e||""},get comp_id(){return st.comp_id===!1&&(st.comp_id=localStorage.getItem("prasi-comp-id")||""),st.comp_id||""},set comp_id(e){localStorage.setItem("prasi-comp-id",e||""),st.comp_id=e||""},instance:{get comp_id(){return st.instance_comp_id===!1&&(st.instance_comp_id=localStorage.getItem("prasi-instance-comp-id")||""),st.instance_comp_id||""},set comp_id(e){localStorage.setItem("prasi-instance-comp-id",e||""),st.instance_comp_id=e||""},get item_id(){return st.instance_item_id===!1&&(st.instance_item_id=localStorage.getItem("prasi-instance-item-id")||""),st.instance_item_id||""},set item_id(e){localStorage.setItem("prasi-instance-item-id",e||""),st.instance_item_id=e||""}}},W4={mode:"",user:{id:"",username:"",client_id:""},clients:{},status:"init",preview:{url_cache:new Set,route_cache:La(),page_cache:{},meta_cache:{}},sync:void 0,site:gr(Mb),site_tstamp:Date.now(),site_exports:{},site_dts:"",site_dts_entry:{},prisma_ext:"",script:{site_types:{},loaded:!1,do_edit:async(e,t)=>{},db:null,api:null,init_local_effect:{}},page:{history:{id:"",show:!1},root_id:"root",cur:jb,doc:null,list:{},building:!1,meta:{},entry:[],tree:[],render:()=>{}},comp:{doc:null,item:null,loaded:{},list:{},group:{}},code:{},global_prop:[],ui:{build:{status:"ready"},monaco:null,comp_editable:localStorage.getItem("prasi-comp-editable")==="yes",zoom:localStorage.zoom||"100%",side:{prop:!0},layout:{left:parseInt(localStorage.getItem("prasi-layout-left")||"250"),right:parseInt(localStorage.getItem("prasi-layout-right")||"250")},prevent_indent_hook:!1,syncing:!1,tree:{item_loading:[],search:"",search_ref:null,search_mode:{Name:!0,JS:!1,HTML:!1,CSS:!1},rename_id:"",open_all:!1,open:{}},popup:{file:{enabled:!1,open:!1,picker:{value:"",on_pick:!1,multi:!1},path:"/",expanded:JSON.parse(localStorage.getItem("panel-file-expanded")||"{}"),entry:{},selected:new Set,action:null,file_renaming:"",file_ctx_menu_event:null,tree:[],tree_renaming:"",tree_ctx_path:"",tree_ctx_menu_event:null,preview:!0,upload:{started:!1,progress:{}}},code:{init:!1,open:!1,name:"site",log:"",loading:!1,rebuilding:!1,startup_status:"init",error:!1,show_log:!1,list:{}},page:{open:null,form:null},script:{open:!1,mode:"js",lastMode:"js",type:"item",prop_kind:"",prop_name:"",on_close:()=>{},typings:{status:"ok",err_msg:""},wb_render:()=>{}},site:null,site_form:null,comp:{preview_id:"",open:null,import:!1},comp_group:null,api:{open:!1}}}};y();w();_();var Da=e=>({isMobile:e.mode==="mobile",isDesktop:e.mode==="desktop",isEditor:location.pathname.startsWith("/ed/")});y();w();_();var Ad={transform:null},Ma=async(e,t)=>{Ad.transform||(Ad.transform=(await import("./esm-XKHB6BMI.js")).transform);let n={};for(let[r,i]of Object.entries(e)){n[r]=Ad.transform(i,{transforms:["typescript","imports","jsx"],preserveDynamicImport:!0,disableESTransforms:!0,filePath:t}).code;let o=['"use strict";'];for(let s of o)n[r].startsWith(s)&&(n[r]=n[r].substring(s.length).trim())}return n};y();w();_();var Xr=Z(Ze());y();w();_();var zn=window;y();w();_();var zb=fd("prasi-cache","prasi-cache-store"),M_={timeout:null,store:zb},ja=(e,t)=>{let n=[...j_(t,"navigate(",")"),...j_(t,"href = ",";")],r=e.page.cur.id;e.page.navs[r]||(e.page.navs[r]=new Set);for(let i of n)e.page.navs[r].add(i);clearTimeout(M_.timeout),M_.timeout=setTimeout(()=>{e.on_nav_loaded&&e.on_nav_loaded({urls:Array.from(e.page.navs[r])})},100)},j_=(e,t,n)=>{let r=0,i=0,o=[];for(;;){let s=e.indexOf(t,r);if(i=r,s>=0){let l=e[s+t.length];if(l==='"'||l==="'"||l==="`"){let u=e.indexOf(`${l}${n}`,s+t.length+1),c=e.substring(s+t.length+1,u);r=u+2+n.length,o.push(c)}}if(i===r)break}return o};y();w();_();var qr=Z(Ze());y();w();_();var z_=Z(xd()),Kr=Z(Ze());var Pd=Z(me()),F_=(e,t,n,r,i)=>o=>{let[s,l]=(0,Kr.useState)({}),u=o.idx||o.internal_key;n.item.script||(n.item.script={});let c=n.item.script;typeof u<"u"&&(n.item.script_keyed||(n.item.script_keyed={}),n.item.script_keyed[u]||(n.item.script_keyed[u]={}),c=n.item.script_keyed[u]),c.passprop||(c.passprop={});let a={},p=!1;for(let[h,S]of Object.entries(o))["children","key"].includes(h)||(p=!0,a[h]=S);let f={...r,...a};if(typeof u<"u"&&((typeof c.passprop.internal_key>"u"||u===c.passprop.internal_key)&&(c.passprop=f),f=c.passprop),n.editor_props=f,!Array.isArray(o.children)&&(0,Kr.isValidElement)(o.children)&&typeof o.children=="object"){let h=(0,z_.default)(o.children,"props.meta.item.component.props.child.content.childs");if(Array.isArray(h)){let S=!0;for(let k of h)!(0,Kr.isValidElement)(k)&&typeof k=="object"||(S=!1);if(S)return h.map(k=>{let m=e.meta[k.id];if(m||(e.meta[k.id]={item:k},m=e.meta[k.id]),m){if(Object.keys(m.item).length<=3&&m.mitem){let g={...m.item},v=m.mitem.toJSON();m.item={...v,...g}}return(0,Pd.jsx)(Dn,{is_layout:t,meta:m,passprop:f,parent_key:o.internal_key,depth:i},k.id)}return null})}}if(!Array.isArray(o.children)&&!(0,Kr.isValidElement)(o.children)&&typeof o.children=="object"){let h=o.children.id;if(h){let S=e.meta[h];if(!S){e.meta[h]={item:o.children},S=e.meta[h];let k=S.item.component?.id;k&&e.comp.load(k).then(m=>{if(m){for(let[v,x]of Object.entries(m)){let N=S.item;N[v]||(N[v]=x)}let g=S.item.component?.props;for(let[v,x]of Object.entries(m.component?.props||{}))g[v]||(g[v]=x);l({})}})}return(0,Pd.jsx)(Dn,{is_layout:t,meta:S,passprop:f,parent_key:o.internal_key,depth:i})}}return za(o,f,u?{parent_key:u}:void 0)},za=(e,t,n)=>{let r={};if(Array.isArray(e)?r.children=e:r=e,Array.isArray(r.children)){if(r.children.length===1)return Nd(r.children[0],r,t,n);let i=[];for(let o of r.children)i.push(Nd(o,r,t,n));return i}return Nd(r.children,r,t,n)},Nd=(e,t,n,r)=>{if((0,Kr.isValidElement)(e)){let i={...t};return delete i.children,{...e,props:{...e.props,...r,passprop:{...n,...i}}}}else if(Array.isArray(e))return za(e,n,r);return e};var Bt={},U_=(e,t,n)=>r=>{let i=(["prasi.avolut.com"].includes(location.hostname)||location.host==="localhost:4550")&&location.pathname.startsWith("/ed/"),o=n.item.id,{children:s,parent_key:l}=r,u=e.script?.init_local_effect,c=t?e.layout?.meta:e.meta,a=e.page.cur.id+"~"+o;if(!Bt[a])Bt[a]={mounted:!0,value:r.value};else if(!Bt[a].mounted){if(!B_.isEditor){for(let[k,m]of Object.entries(Bt[a].value))delete Bt[a].value[k];for(let[k,m]of Object.entries(gr(r.value)))Bt[a].value[k]=m}Bt[a].mounted=!0}let p=(0,qr.useRef)(Bt[a].value),[f,d]=(0,qr.useState)({}),h=p.current;return h.render=()=>{let k=window;!k.isEditor&&k.prasiContext.render?k.prasiContext.render():d({})},r.hook&&r.hook(h),(0,qr.useEffect)(()=>{if(n.parent?.instance_id&&c){let m=c[n.parent?.instance_id];if(m&&m.instances){for(let[g,v]of Object.entries(m.instances[n.parent.instance_id]))if(v===n.item.id){o=g;break}}}return!u[o]&&(typeof u=="object"&&(u[o]=!0),(async()=>r.effect&&await r.effect(h))()),()=>{Bt[a].mounted=!1}},[...r.deps||[],location.pathname]),(0,qr.useEffect)(()=>{i&&Bt[o]===null&&(async()=>r.effect&&(await r.effect(h),i&&(Bt[o]=h)))()},[Bt[o]]),za(s,{...n.script?.scope,[r.name]:h})};y();w();_();var Ld=Z(Pa());var vs=window,Xi=(e,t,n,r)=>{let i=r||{},o=t.get("id")||"";vs.prasiEditDevItem||(vs.prasiEditDevItem={});let s=vs.prasiEditDevItem[n];s||(vs.prasiEditDevItem[n]={},s=vs.prasiEditDevItem[n]);let l=()=>{let a=t.get("id")||"",p=s[a];return p||(s[a]=[],p=s[a]),p},u=t.toJSON(),c={...u,edit:{get props(){if(u.component?.props){let a={};for(let[p,f]of Object.entries(u.component.props))if(f.content){let d=t.get("component")?.get("props")?.get(p)?.get("content");if(d){let h=d.get("id")||"";i[h]?a[p]={mode:"jsx",value:i[h]}:a[p]={mode:"jsx",value:Xi(e,d,n,i)}}else a[p]={mode:"jsx",value:null}}else{let d=typeof f.valueBuilt=="string"?f.valueBuilt.trim():"";if(d.endsWith(`; `)&&(d=d.substring(0,d.length-2)),d&&d===f.value.trim()){let h=new Function(`return ${f.value}`);a[p]={mode:"string",value:h()}}else a[p]={mode:"raw",value:f.value,valueBuilt:f.valueBuilt}}return a}},get pending(){return[]},async commit(){let a={},p={};if(t){for(let[f,d]of Object.entries(s)){let h=e[f];if(!h||!h.mitem)continue;let k=h.mitem.toJSON();if(k&&k.component){let m=k?.component?.props;if(!m){console.log(k,m);return}let g={};for(let x of d)if(x.type==="prop"&&m)m[x.name]&&(x.mode==="string"?(m[x.name].value=JSON.stringify(x.value),m[x.name].valueBuilt=JSON.stringify(x.value)):x.mode==="raw"?(m[x.name].value=x.value,x.valueBuilt?m[x.name].valueBuilt=x.valueBuilt:g[x.name]=x.value):x.mode==="jsx"&&(m[x.name]||(m[x.name]={meta:{type:"content-element"}}),x.value&&(m[x.name].content=Qi([x.value],p)[0])));else if(x.type==="set"&&typeof x.value=="object")for(let[N,L]of Object.entries(x.value))k[N]=L;else if(x.type==="child"&&Array.isArray(x.childs))if(k.component?.id)k.component.props||(k.component.props={}),k.component.props.child={meta:{type:"content-element"},content:{type:"item",id:(0,Ld.createId)(),name:"child",childs:Qi(x.childs.filter(N=>N),p)}};else{let N=Qi(x.childs.filter(L=>L),p);k.childs=N}for(let[x,N]of Object.entries(p))g[x]=N.value;let v=await Ma(g);if(await new Promise(x=>{setTimeout(x)}),m)for(let[x,N]of Object.entries(v))m[x]?m[x].valueBuilt=N:p[x]&&(p[x].valueBuilt=N);a[f]=k}}t.doc?.transact(()=>{for(let[f,d]of Object.entries(a)){let h=e[f];h.mitem&&syncronize(h.mitem,d)}})}},setValue(a,p){let f=l(),d=p;if(a==="childs")throw new Error("Please modify childs via .child");f.push({type:"set",name:a,value:d})},setProp(a,p){let f=l();typeof p=="string"?f.push({type:"prop",mode:"string",name:a,value:p}):p.mode==="string"?f.push({type:"prop",mode:"string",name:a,value:p.value}):p.mode==="raw"?f.push({type:"prop",mode:"raw",name:a,value:p.value,valueBuilt:p.valueBuilt}):p.mode==="jsx"&&f.push({type:"prop",mode:"jsx",name:a,value:p.value})},setChilds(a){l().push({type:"child",childs:a})},get childs(){if(u.component?.id){let a=u.component?.props.child;if(a&&a.content){let p=t.get("component")?.get("props")?.get("child")?.get("content");if(p){let f=p.get("id")||"";return i[f]?[i[f]]:[Xi(e,p,n,i)]}}return[]}return u.childs?u.childs.map(a=>{if(a){let p=e[a.id];if(i[a.id])return i[a.id];if(p&&p.mitem)return Xi(e,p.mitem,n,i)}}).filter(a=>a):[]},get parent(){if(t){let a=t.parent.toJSON(),p=null;if(Array.isArray(a))p=(t.parent?.parent).get("id");else{let d=t.parent?.parent?.parent?.parent;typeof d=="object"&&typeof d.get=="function"&&(p=d.get("id"))}let f=e[p]?.mitem;if(f){let d=i[p]?i[p]:Xi(e,f,n,i);return Array.isArray(a)?{item:d,child_type:"child",child_idx:a.findIndex(h=>h.id===d.id)}:{item:d,child_type:"prop"}}}return null}}};return i[o]=c,c},Fb=(e,t)=>{let n={};for(let[r,i]of Object.entries(e))i.mode?i.mode==="string"?n[r]={value:JSON.stringify(i.value),valueBuilt:JSON.stringify(i.value),meta:{type:"text"}}:i.mode==="jsx"&&i.value?n[r]={value:"",valueBuilt:"",content:Qi([i.value],t)[0],meta:{type:"content-element"}}:i.mode==="raw"&&(n[r]={value:i.value,valueBuilt:i.valueBuilt,meta:{type:"text"}}):n[r]=i;return n},Qi=(e,t)=>{let n=t||{};return e.map(i=>{let o={...i};if(delete o.edit,o.id||(o.id=(0,Ld.createId)()),o.component&&(o.component.instances||(o.component.instances={}),o.component.ref_ids||(o.component.ref_ids={}),o.component?.props)){o.component.props=Fb(o.component.props,n);for(let[s,l]of Object.entries(o.component.props))!l.valueBuilt&&l.value&&(n[o.id+"|||"+s]=l),l.content&&(l.content=Qi([l.content],n)[0])}return o.childs?o.childs=Qi(o.childs,n):o.childs=[],o})};y();w();_();var Ji=(e,t,n)=>({...t,edit:{setChilds(r){},get childs(){if(t.component?.id){let r=t.component?.props.child;return r.content?[Ji(e,r.content,n)]:[]}return t.childs?t.childs.map(r=>{if(r){let i=e[r.id];if(i&&i.item)return Ji(e,i.item,n)}}).filter(r=>r):[]},get props(){if(t.component?.props){let r={};for(let[i,o]of Object.entries(t.component.props))if(o.content){let s=t.component?.props?.[i]?.content;s?r[i]={mode:"jsx",value:Ji(e,s,n)}:r[i]={mode:"jsx",value:null}}else{let s=typeof o.valueBuilt=="string"?o.valueBuilt.trim():"";if(s.endsWith(`; `)&&(s=s.substring(0,s.length-2)),s&&s===o.value.trim()){let l=new Function(`return ${o.value}`);r[i]={mode:"string",value:l()}}else r[i]={mode:"raw",value:o.value,valueBuilt:o.valueBuilt}}return r}},async commit(){},get parent(){let r=e[t.id];if(r&&r.parent?.id){let i=e[r.parent.id];return Ji(e,i.item,n)}return null},pending:[],setProp(r,i){},setValue(r,i){}}});var Dd=Z(me()),$_=(e,t,n,r,i,o)=>{let s=ms(e,t,n,r,i);e.visit&&e.visit(t,s),t.script?t.script.scope=r:t.script={scope:r,result:null,Local:U_(e,n,t),PassProp:F_(e,n,t,r,i)};let l=t.script,u=window.exports,c={useEffect:Xr.useEffect,children:s.props.children,props:s.props,Local:l?.Local,db:e.site.db,api:e.site.api,PassProp:l?.PassProp,ErrorBox:pn,newElement:()=>{},__props:r,_item:t.mitem?Xi(e.meta,t.mitem,e.page.cur.id):Ji(e.meta,t.item,e.page.cur.id),_meta:e.meta,render:d=>{let h=d;if((0,Xr.isValidElement)(d)&&d.props.children){let S=m=>{let g=!1,v=[];if((0,Xr.isValidElement)(m)){if(m.type===t.script?.PassProp)return{should_replace:!0,el:{...m,props:{...m.props,internal_key:m.key}}};if(m.props?.children&&(Array.isArray(m.props.children)||(m.props.children=[m.props.children]),Array.isArray(m.props.children)))for(let x of m.props.children)if(Array.isArray(x)){let N=[],L=!1;for(let P of x){let D=S(P);D.should_replace?(N.push(D.el),L=!0):N.push(P)}L?(g=!0,v.push(N)):v.push(x)}else typeof x=="object"&&x?x.type===t.script?.PassProp&&(g=!0,v.push({...x,props:{...x.props,internal_key:x.props.key}})):v.push(x)}return{should_replace:g,el:{...m,props:{...m.props,children:v}}}},k=S(d);k.should_replace&&(h=k.el)}l&&(l.result=(0,Dd.jsx)(Xr.Suspense,{children:h}))},params,...Da(e),...u,...r};if(typeof r=="object"){for(let[d,h]of Object.entries(r))if(typeof h=="object"&&h&&h._jsx){let S=h;c[d]=(0,Dd.jsx)(Ub,{fn:S.fn,passprop:{...r},meta:t})}}!zn.isEditor&&t.item.adv?.js&&ja(e,t.item.adv.js);let a=t.item.adv?.jsBuilt||"",p=jd(a,Md)||"";a.includes("parent_props")&&console.log(t.item.name,c);let f=`// ${t.item.name}: ${t.item.id} try { diff --git a/app/web/src/nova/ed/logic/ed-global.ts b/app/web/src/nova/ed/logic/ed-global.ts index 6d88cdf3..b4670e14 100644 --- a/app/web/src/nova/ed/logic/ed-global.ts +++ b/app/web/src/nova/ed/logic/ed-global.ts @@ -325,7 +325,7 @@ export const EDGlobal = { on_pick?: (group_id: string) => void | Promise; on_close?: () => void | Promise; }, - api: { open: true }, + api: { open: false }, }, }, };