From b0c609e4090b570f6a1ca34f8fb7b55a560bd67a Mon Sep 17 00:00:00 2001 From: Rizky Date: Fri, 19 Jul 2024 21:05:06 +0700 Subject: [PATCH] fix --- app/srv/core/main.js | 4 ++-- app/srv/ws/sync/code/utlis/ensure-lib.ts | 10 ++++++---- app/web/src/nova/vi/render/script/eval-prop.tsx | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/srv/core/main.js b/app/srv/core/main.js index c892f52d..8cd8a98f 100644 --- a/app/srv/core/main.js +++ b/app/srv/core/main.js @@ -118,8 +118,8 @@ ${d.message} `)}Kl(e,t,r,o)},aE=({fn:e,meta:t,passprop:n})=>e({passprop:n,meta:t}),Uf={"stroke-width":"strokeWidth","fill-rule":"fillRule","clip-rule":"clipRule","stroke-linejoin":"strokeLinejoin","stroke-linecap":"strokeLinecap","clip-path":"clipPath"},Bf=(e,t)=>{let n=e;for(let[r,i]of Object.entries(t))n=n.replaceAll(r,i);return n};var jy=P(G());var zy=(e,t,n,r,i,o)=>{if(t.item.component?.id){let s=t.item.script;if(o?(t.item.script_keyed||(t.item.script_keyed={}),t.item.script_keyed[o]||(t.item.script_keyed[o]={}),s=t.item.script_keyed[o]):(t.item.script||(t.item.script={}),s=t.item.script),!s)return;let c={...window.exports,db:e.site.db,api:e.site.api,...Gl(e),...r,params};s.props={};let u=new Set;if(t.item.component.props){let a={};for(let[p,f]of Object.entries(t.item.component.props))try{if(f.meta?.type==="content-element"){let m={_jsx:!0,fn:g=>{let y=f.content?.id;if(y){let _=n?e.layout?.meta[y]:e.meta[y];if(!_)return null;let S=t.instances;if(!g.meta.item.originalId||!S||!S[t.item.id])return null;let k=g.meta.item.originalId;if(_.mitem&&(f.jsxCalledBy&&(!f.jsxCalledBy.includes(k)||f.jsxCalledBy.length!==2)||!f.jsxCalledBy)){let b=t.mitem?.get("component")?.get("props")?.get(p);if(b){let O=b.get("jsxCalledBy");!O||typeof O!="object"?b.set("jsxCalledBy",[t.item.id,k]):Array.isArray(O)&&(!O.includes(k)||O.length!==2||O[0]!==t.item.id||O[1]!==k)&&b.set("jsxCalledBy",[t.item.id,k])}}return(0,jy.jsx)(en,{meta:_,passprop:g.passprop,is_layout:n,depth:i+1})}return null}};c[p]=m,r&&(r[p]=m);continue}if(f.value&&Zl(e,f.value),!f.valueBuilt&&f.value&&t.mitem){let m=t.mitem?.get("component")?.get("props")?.get(p);if(m){uE(m,f.value);return}}let d=f.valueBuilt||"",h=Bf(d,Uf)||"",v=new Function(...Object.keys(c),`// [${t.item.name}] ${p}: ${t.item.id} return ${h} `);s.props[p]={value:h,valueBuilt:h};let w=v(...Object.values(c));typeof w=="function"&&(w=(...m)=>new Function(...Object.keys(c),`// [${t.item.name}] ${p}: ${t.item.id} - return ${h} - `)(...Object.values(c))(...m)),c[p]=w,a[p]=w,r&&(r[p]=w)}catch{u.add(p)}if(location.pathname.startsWith("/ed/")&&ri.item_id&&t.item.id===ri.item_id){ri.scope={};for(let[p,f]of Object.entries(r))ri.scope[p]=f;ri.scope.self_props=a}}}},ut={timeout:null,set:new WeakSet,map:{},src:{}},uE=(e,t)=>{if(!ut.set.has(e)){ut.set.add(e);let n=(0,My.createId)();ut.map[n]={mprop:e},ut.src[n]=t}clearTimeout(ut.timeout),ut.timeout=setTimeout(async()=>{let n=await _api.code_build(ut.src),r=null;for(let[i,o]of Object.entries(n)){let s=ut.map[i].mprop;if(!r&&s.doc){r=s.doc;break}}r&&(r.transact(()=>{for(let[i,o]of Object.entries(n))ut.map[i].mprop.set("valueBuilt",o)}),ut.set=new WeakSet,ut.map={},ut.src={})},300)},Kl=(e,t,n,r)=>{let i=r?t.item.script_keyed?.[r]:t.item.script;if(i&&i.props){let o={...n,api:e.site.api,db:e.site.db};for(let[s,l]of Object.entries(i.props))if(l.fn){let c=new Function(...Object.keys(o),`// [${t.item.name}] ${s}: ${t.item.id} +return ${h.trim()} +`)(...Object.values(c))(...m)),c[p]=w,a[p]=w,r&&(r[p]=w)}catch{u.add(p)}if(location.pathname.startsWith("/ed/")&&ri.item_id&&t.item.id===ri.item_id){ri.scope={};for(let[p,f]of Object.entries(r))ri.scope[p]=f;ri.scope.self_props=a}}}},ut={timeout:null,set:new WeakSet,map:{},src:{}},uE=(e,t)=>{if(!ut.set.has(e)){ut.set.add(e);let n=(0,My.createId)();ut.map[n]={mprop:e},ut.src[n]=t}clearTimeout(ut.timeout),ut.timeout=setTimeout(async()=>{let n=await _api.code_build(ut.src),r=null;for(let[i,o]of Object.entries(n)){let s=ut.map[i].mprop;if(!r&&s.doc){r=s.doc;break}}r&&(r.transact(()=>{for(let[i,o]of Object.entries(n))ut.map[i].mprop.set("valueBuilt",o)}),ut.set=new WeakSet,ut.map={},ut.src={})},300)},Kl=(e,t,n,r)=>{let i=r?t.item.script_keyed?.[r]:t.item.script;if(i&&i.props){let o={...n,api:e.site.api,db:e.site.db};for(let[s,l]of Object.entries(i.props))if(l.fn){let c=new Function(...Object.keys(o),`// [${t.item.name}] ${s}: ${t.item.id} return ${l.value||""} `);l.fn=c(...Object.values(o))}}};var $f=P(G()),Hf=({meta:e,passprop:t,is_layout:n,parent_key:r,depth:i})=>{let o=Pn(An,"VI"),[s,l]=(0,Fy.useState)({});e.render=()=>{l({})};let c=t;return e.item.component?.id&&(c||(c={}),zy(o,e,n,c,i,r)),e.item.adv?.html?(0,$f.jsx)(Ql,{meta:e,passprop:c,is_layout:n,depth:i}):e.item.adv?.js&&(Dy(o,e,n,c,i,r),e.script)?e.script.result:(0,$f.jsx)(Ql,{meta:e,passprop:c,is_layout:n,depth:i})};var Se=P(G()),cE=70,fE={debug:!!localStorage.getItem("prasi-js-debug")},ql={enabled:!1,meta:{}},en=({meta:e,passprop:t,is_layout:n,parent_key:r,depth:i})=>{if(ql.enabled){let o=ql.meta;if(o[e.item.id]?o[e.item.id].last_render===Math.floor(Date.now()/1e3)?o[e.item.id].count++:o[e.item.id]={last_render:Math.floor(Date.now()/1e3),count:1}:o[e.item.id]={last_render:Math.floor(Date.now()/1e3),count:1},o[e.item.id]?.count>cE)return(0,Se.jsxs)("div",{className:"bg-orange-100 border border-orange-300 rounded-sm text-xs flex flex-col items-center",children:[(0,Se.jsxs)("div",{className:"text-[10px] font-bold text-red-900 self-stretch px-1",children:["WARNING: Render loop detected in [",e.item.name,"]"]}),(0,Se.jsxs)("p",{className:"border-b border-orange-300 px-1 pb-1 min-w-[100px]",children:["Rendered ",o[e.item.id]?.count," times in less than 1 second."]})]})}if(!e||e.item.hidden)return null;if(fE.debug){let o="";for(let s=0;s{let o=Pn(An,"VI");if(n&&e.item.name==="children"){let l=[];for(let c of o.entry){let u=o.meta[c];if(u.item.adv?.js||u.item.component?.id)l.push((0,Se.jsx)(Nt,{meta:u,children:(0,Se.jsx)(Hf,{meta:u,is_layout:!1,passprop:{...t},parent_key:r,depth:i+1})}));else{let a=bo(o,u,!1,t,i);o.visit&&o.visit(u,a),l.push((0,Se.jsx)("div",{...a.props}))}}return(0,Se.jsx)(Se.Fragment,{children:l.map((c,u)=>(0,Se.jsx)(Uy.Fragment,{children:c},u))})}let s=bo(o,e,n,t,i);return o.visit&&o.visit(e,s),(0,Se.jsx)("div",{...s.props})};var Je=window,By=async(e,t)=>{window.parent&&(window.addEventListener("message",async({data:n})=>{if(typeof n=="object"&&n.mobile){let r=n,i=async o=>{if(!Je.notif?.onTap){let s=null,l=0;await new Promise(()=>{s=setInterval(()=>{l++,l>20&&clearInterval(s),o()&&clearInterval(s)},500)});return}};switch(r.type){case"notification-token":t.notif={token:r.token},Je.notif={async send(o){if(e&&e.site.api)return await e.site.api._notif("send",{type:"send",id:typeof o.user_id=="string"?o.user_id:o.user_id.toString(),body:o.body,title:o.title,data:o.data})},async register(o){if(e&&e.site.api&&t.notif?.token)return await e.site.api._notif("register",{type:"register",id:typeof o=="string"?o:o.toString(),token:t.notif.token})},onReceive(o){},onTap(o){}};break;case"notification-tap":if(!Je.notif?.onTap){i(()=>Je.notif?.onTap?(Je.notif?.onTap(r.notif),!0):!1);return}Je.notif?.onTap&&Je.notif?.onTap(r.notif);break;case"notification-receive":Je.notif?.onReceive||i(()=>Je.notif?.onReceive?(Je.notif?.onReceive(r.notif),!0):!1),Je.notif?.onReceive&&Je.notif?.onReceive(r.notif);break}}}),window.parent.postMessage({mobile:!0,type:"ready"},"*")),Je.notif={async send(n){if(e&&e.site.api)return await e.site.api._notif("send",{type:"send",id:typeof n.user_id=="string"?n.user_id:n.user_id.toString(),body:n.body,title:n.title,data:n.data})}}};var Vf=window;Vf.prasi_ext||(Vf.prasi_ext={});var Xl=Vf.prasi_ext;var $y=async e=>{let t=Xl[e.site.id];if(t||(Xl[e.site.id]={status:"init"},t=Xl[e.site.id]),t.status==="init"){if(t.status="loading",window.parent!==window){let n=r=>{window.parent.postMessage({mobile:!0,...r},"*")};window.addEventListener("message",async({data:r})=>{console.log(r),typeof r=="object"&&r.mobile}),n({type:"ready"})}await By(e,t),t.status="ready"}};var ai=P(G()),Hy=({})=>{let e=Pn(An,"VI"),t=Nn({tick:Date.now()});if(e.tick=t.tick,$y(e),e.status!=="ready")return(0,ai.jsx)("div",{className:"flex flex-1 flex-col relative",children:(0,ai.jsx)(So,{backdrop:!1})});let n=!!e.layout?.entry&&e.layout.entry.length>0,r=e.entry;return n&&e.layout?.entry&&(r=e.layout?.entry),(0,ai.jsx)("div",{className:"flex flex-1 flex-col relative",children:Array.isArray(r)&&r.map(i=>{let o=n?e.layout?.meta[i]:e.meta[i];return o&&Element?(0,ai.jsx)(Nt,{children:(0,ai.jsx)(en,{meta:o,is_layout:n,depth:0})},o.item.id):null})})};var Jl=P(G()),At=window;At.prasi_internal||(At.prasi_internal={page:{id:""}});var Vy=({meta:e,entry:t,api_url:n,site_id:r,api:i,mode:o,db:s,visit:l,script:c,preloaded:u,page_id:a,render_stat:p,on_status_changed:f,on_preload:d,layout:h,comp_load:v})=>{let w=Pn(An,"VI");return w.mode=o,w.entry=t,w.on_preload=d,w.comp.load=v,a&&(At.prasi_internal.page.id=a),At.siteurl=(m,g)=>{if(m.startsWith("http://")||m.startsWith("https://"))return m;try{["prasi.avolut.com"].includes(location.hostname)||location.host==="localhost:4550"?w.site.api_url&&(w.site_url||(w.site_url=new URL(w.site.api_url))):w.site_url||(g&&w.site.api_url?w.site_url=new URL(w.site.api_url):w.site_url=new URL(location.href),w.site_url.pathname="")}catch{}if(w.site_url){let y=w.site_url,_=m;return _.startsWith("/")||(_="/"+_),At.prasiContext.siteUrl&&(_=At.prasiContext.siteUrl(_)),`${y.protocol}//${y.host}${_}`}return m},At.isMobile=o==="mobile",At.isDesktop=o==="desktop",At.preloaded=u||(m=>{}),At.preload=(m,g)=>{if(w.on_preload)return new Promise(y=>{w.page.navs[a]||(w.page.navs[a]=new Set);let _=w.page.navs[a],S=typeof m=="string"?[m]:m,E=!0;for(let k of S)_.has(k)||(_.add(k),E=!1);E?y():(w.page.preload.push(y),w.on_preload?.({urls:Array.from(w.page.navs[a]),opt:{on_load:(...k)=>{g?.on_load?.(...k);for(let b of w.page.preload)b();w.page.preload=[],w.render()}}}))})},w.layout=h,w.page.cur.id=a,w.on_status_changes=f,p==="disabled"&&(ql.enabled=!1),w.meta!==e&&(w.meta=e),c&&(w.script.init_local_effect=c.init_local_effect),w.visit=l,w.status==="init"&&(w.site.db=s,w.site.api=i,lg(w,{api_url:n,site_id:r})),d&&(0,Yl.useEffect)(()=>{setTimeout(()=>{let m=w.page.navs[w.page.cur.id];m&&d({urls:Array.from(m),opt:{on_load(g){}}})},500)},[w.page.cur.id]),(0,Jl.jsx)(Nt,{children:(0,Jl.jsx)(Yl.Suspense,{children:(0,Jl.jsx)(Hy,{})})})};var ui=async(e,t)=>{let n=C.comp;for(let i of e)i&&i.type!=="text"&&ea(i,t);let r=Object.keys(n.pending);if(r.length>0)try{let i=await(await fetch(C.url`_prasi/comp`,{method:"POST",body:JSON.stringify({ids:[...r]})})).json();for(let[o,s]of Object.entries(i))delete n.pending[o],n.list[o]=s,await zl(`comp-${o}`,s);if(Object.keys(n.pending).length>0){console.error(`Warning: component not found: ${Object.keys(n.pending)}`);return}await ui(Object.values(i))}catch(i){console.error(i)}},ea=(e,t)=>{let n=C.comp;if(e.type==="item"){let r=e.component?.id;if(r){if(!n.list[r]&&!n.pending[r]&&(n.pending[r]=[]),n.pending[r]&&(n.pending[r].find(i=>i.id===e.id)||n.pending[r].push(e)),n.pending[r]&&n.list[r]){for(let i of n.pending[r])for(let o of Object.values(i.component?.props||{}))o.content&&ea(o.content,t);delete n.pending[r]}if(e.component?.props)for(let i of Object.values(e.component?.props||{}))i.content&&ea(i.content,t)}}if(e.childs)for(let r of e.childs){let i=r;i&&i.type!=="text"&&ea(i,t)}};var Wy=e=>new Promise(async t=>{let n=!1,r=await gf(`page-${e}`);r&&(t(r),n=!0);let i=await(await fetch(C.url`_prasi/page/${e}`)).json();n||t(i)}),dE=e=>new Promise(async t=>{let n={},r=[...new Set(e)],i=!0;for(let s of r){let l=await gf(`page-${s}`);if(l)n[s]=l;else{i=!1;break}}i&&t(n);let o=await(await fetch(C.url`_prasi/pages`,{method:"POST",body:JSON.stringify({ids:r})})).json();i||t(o)}),Gy=async e=>{let t=e.map(r=>C.route.router?.lookup(r)).filter(r=>r&&r.id);return await dE(t.map(r=>r?.id))};var Ky=P(Zy()),Qy=()=>{let e=C;if(e.site.id){if(!e.mode&&e.site.responsive)if(e.site.responsive!=="mobile-only"&&e.site.responsive!=="desktop-only"){let t=(0,Ky.default)();e.mode=t.device.type==="mobile"?"mobile":"desktop"}else e.site.responsive==="mobile-only"?e.mode="mobile":e.site.responsive==="desktop-only"&&(e.mode="desktop");localStorage.getItem("prasi-editor-mode")&&(e.mode=localStorage.getItem("prasi-editor-mode"))}};function Ao(e,t){return function(){return e.apply(t,arguments)}}var{toString:pE}=Object.prototype,{getPrototypeOf:Zf}=Object,ra=(e=>t=>{let n=pE.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),xt=e=>(e=e.toLowerCase(),t=>ra(t)===e),ia=e=>t=>typeof t===e,{isArray:ci}=Array,Lo=ia("undefined");function mE(e){return e!==null&&!Lo(e)&&e.constructor!==null&&!Lo(e.constructor)&&ct(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Jy=xt("ArrayBuffer");function hE(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Jy(e.buffer),t}var gE=ia("string"),ct=ia("function"),Yy=ia("number"),oa=e=>e!==null&&typeof e=="object",yE=e=>e===!0||e===!1,na=e=>{if(ra(e)!=="object")return!1;let t=Zf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},_E=xt("Date"),vE=xt("File"),wE=xt("Blob"),xE=xt("FileList"),kE=e=>oa(e)&&ct(e.pipe),SE=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||ct(e.append)&&((t=ra(e))==="formdata"||t==="object"&&ct(e.toString)&&e.toString()==="[object FormData]"))},EE=xt("URLSearchParams"),[bE,RE,CE,IE]=["ReadableStream","Request","Response","Headers"].map(xt),TE=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Do(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,i;if(typeof e!="object"&&(e=[e]),ci(e))for(r=0,i=e.length;r0;)if(i=n[r],t===i.toLowerCase())return i;return null}var t_=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,n_=e=>!Lo(e)&&e!==t_;function Gf(){let{caseless:e}=n_(this)&&this||{},t={},n=(r,i)=>{let o=e&&e_(t,i)||i;na(t[o])&&na(r)?t[o]=Gf(t[o],r):na(r)?t[o]=Gf({},r):ci(r)?t[o]=r.slice():t[o]=r};for(let r=0,i=arguments.length;r(Do(t,(i,o)=>{n&&ct(i)?e[o]=Ao(i,n):e[o]=i},{allOwnKeys:r}),e),NE=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),PE=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},AE=(e,t,n,r)=>{let i,o,s,l={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!r||r(s,e,t))&&!l[s]&&(t[s]=e[s],l[s]=!0);e=n!==!1&&Zf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},LE=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},DE=e=>{if(!e)return null;if(ci(e))return e;let t=e.length;if(!Yy(t))return null;let n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},ME=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Zf(Uint8Array)),zE=(e,t)=>{let r=(e&&e[Symbol.iterator]).call(e),i;for(;(i=r.next())&&!i.done;){let o=i.value;t.call(e,o[0],o[1])}},jE=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},FE=xt("HTMLFormElement"),UE=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),qy=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),BE=xt("RegExp"),r_=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};Do(n,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(r[o]=s||i)}),Object.defineProperties(e,r)},$E=e=>{r_(e,(t,n)=>{if(ct(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;let r=e[n];if(ct(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},HE=(e,t)=>{let n={},r=i=>{i.forEach(o=>{n[o]=!0})};return ci(e)?r(e):r(String(e).split(t)),n},VE=()=>{},WE=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,Wf="abcdefghijklmnopqrstuvwxyz",Xy="0123456789",i_={DIGIT:Xy,ALPHA:Wf,ALPHA_DIGIT:Wf+Wf.toUpperCase()+Xy},GE=(e=16,t=i_.ALPHA_DIGIT)=>{let n="",{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function ZE(e){return!!(e&&ct(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var KE=e=>{let t=new Array(10),n=(r,i)=>{if(oa(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[i]=r;let o=ci(r)?[]:{};return Do(r,(s,l)=>{let c=n(s,i+1);!Lo(c)&&(o[l]=c)}),t[i]=void 0,o}}return r};return n(e,0)},QE=xt("AsyncFunction"),qE=e=>e&&(oa(e)||ct(e))&&ct(e.then)&&ct(e.catch),x={isArray:ci,isArrayBuffer:Jy,isBuffer:mE,isFormData:SE,isArrayBufferView:hE,isString:gE,isNumber:Yy,isBoolean:yE,isObject:oa,isPlainObject:na,isReadableStream:bE,isRequest:RE,isResponse:CE,isHeaders:IE,isUndefined:Lo,isDate:_E,isFile:vE,isBlob:wE,isRegExp:BE,isFunction:ct,isStream:kE,isURLSearchParams:EE,isTypedArray:ME,isFileList:xE,forEach:Do,merge:Gf,extend:OE,trim:TE,stripBOM:NE,inherits:PE,toFlatObject:AE,kindOf:ra,kindOfTest:xt,endsWith:LE,toArray:DE,forEachEntry:zE,matchAll:jE,isHTMLForm:FE,hasOwnProperty:qy,hasOwnProp:qy,reduceDescriptors:r_,freezeMethods:$E,toObjectSet:HE,toCamelCase:UE,noop:VE,toFiniteNumber:WE,findKey:e_,global:t_,isContextDefined:n_,ALPHABET:i_,generateString:GE,isSpecCompliantForm:ZE,toJSONObject:KE,isAsyncFn:QE,isThenable:qE};function fi(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i)}x.inherits(fi,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:x.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var o_=fi.prototype,s_={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{s_[e]={value:e}});Object.defineProperties(fi,s_);Object.defineProperty(o_,"isAxiosError",{value:!0});fi.from=(e,t,n,r,i,o)=>{let s=Object.create(o_);return x.toFlatObject(e,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),fi.call(s,e.message,t,n,r,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};var D=fi;var sa=null;function Kf(e){return x.isPlainObject(e)||x.isArray(e)}function a_(e){return x.endsWith(e,"[]")?e.slice(0,-2):e}function l_(e,t,n){return e?e.concat(t).map(function(i,o){return i=a_(i),!n&&o?"["+i+"]":i}).join(n?".":""):t}function XE(e){return x.isArray(e)&&!e.some(Kf)}var JE=x.toFlatObject(x,{},null,function(t){return/^is[A-Z]/.test(t)});function YE(e,t,n){if(!x.isObject(e))throw new TypeError("target must be an object");t=t||new(sa||FormData),n=x.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,w){return!x.isUndefined(w[v])});let r=n.metaTokens,i=n.visitor||a,o=n.dots,s=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&x.isSpecCompliantForm(t);if(!x.isFunction(i))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(x.isDate(h))return h.toISOString();if(!c&&x.isBlob(h))throw new D("Blob is not supported. Use a Buffer instead.");return x.isArrayBuffer(h)||x.isTypedArray(h)?c&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function a(h,v,w){let m=h;if(h&&!w&&typeof h=="object"){if(x.endsWith(v,"{}"))v=r?v:v.slice(0,-2),h=JSON.stringify(h);else if(x.isArray(h)&&XE(h)||(x.isFileList(h)||x.endsWith(v,"[]"))&&(m=x.toArray(h)))return v=a_(v),m.forEach(function(y,_){!(x.isUndefined(y)||y===null)&&t.append(s===!0?l_([v],_,o):s===null?v:v+"[]",u(y))}),!1}return Kf(h)?!0:(t.append(l_(w,v,o),u(h)),!1)}let p=[],f=Object.assign(JE,{defaultVisitor:a,convertValue:u,isVisitable:Kf});function d(h,v){if(!x.isUndefined(h)){if(p.indexOf(h)!==-1)throw Error("Circular reference detected in "+v.join("."));p.push(h),x.forEach(h,function(m,g){(!(x.isUndefined(m)||m===null)&&i.call(t,m,x.isString(g)?g.trim():g,v,f))===!0&&d(m,v?v.concat(g):[g])}),p.pop()}}if(!x.isObject(e))throw new TypeError("data must be an object");return d(e),t}var zn=YE;function u_(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function c_(e,t){this._pairs=[],e&&zn(e,this,t)}var f_=c_.prototype;f_.append=function(t,n){this._pairs.push([t,n])};f_.toString=function(t){let n=t?function(r){return t.call(this,r,u_)}:u_;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};var la=c_;function e2(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Mo(e,t,n){if(!t)return e;let r=n&&n.encode||e2,i=n&&n.serialize,o;if(i?o=i(t,n):o=x.isURLSearchParams(t)?t.toString():new la(t,n).toString(r),o){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}var Qf=class{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){x.forEach(this.handlers,function(r){r!==null&&t(r)})}},qf=Qf;var aa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var d_=typeof URLSearchParams<"u"?URLSearchParams:la;var p_=typeof FormData<"u"?FormData:null;var m_=typeof Blob<"u"?Blob:null;var h_={isBrowser:!0,classes:{URLSearchParams:d_,FormData:p_,Blob:m_},protocols:["http","https","file","blob","url","data"]};var Jf={};$1(Jf,{hasBrowserEnv:()=>Xf,hasStandardBrowserEnv:()=>t2,hasStandardBrowserWebWorkerEnv:()=>n2,origin:()=>r2});var Xf=typeof window<"u"&&typeof document<"u",t2=(e=>Xf&&["ReactNative","NativeScript","NS"].indexOf(e)<0)(typeof navigator<"u"&&navigator.product),n2=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",r2=Xf&&window.location.href||"http://localhost";var ge={...Jf,...h_};function Yf(e,t){return zn(e,new ge.classes.URLSearchParams,Object.assign({visitor:function(n,r,i,o){return ge.isNode&&x.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function i2(e){return x.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function o2(e){let t={},n=Object.keys(e),r,i=n.length,o;for(r=0;r=n.length;return s=!s&&x.isArray(i)?i.length:s,c?(x.hasOwnProp(i,s)?i[s]=[i[s],r]:i[s]=r,!l):((!i[s]||!x.isObject(i[s]))&&(i[s]=[]),t(n,r,i[s],o)&&x.isArray(i[s])&&(i[s]=o2(i[s])),!l)}if(x.isFormData(e)&&x.isFunction(e.entries)){let n={};return x.forEachEntry(e,(r,i)=>{t(i2(r),i,n,0)}),n}return null}var ua=s2;function l2(e,t,n){if(x.isString(e))try{return(t||JSON.parse)(e),x.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}var ed={transitional:aa,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){let r=n.getContentType()||"",i=r.indexOf("application/json")>-1,o=x.isObject(t);if(o&&x.isHTMLForm(t)&&(t=new FormData(t)),x.isFormData(t))return i?JSON.stringify(ua(t)):t;if(x.isArrayBuffer(t)||x.isBuffer(t)||x.isStream(t)||x.isFile(t)||x.isBlob(t)||x.isReadableStream(t))return t;if(x.isArrayBufferView(t))return t.buffer;if(x.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Yf(t,this.formSerializer).toString();if((l=x.isFileList(t))||r.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return zn(l?{"files[]":t}:t,c&&new c,this.formSerializer)}}return o||i?(n.setContentType("application/json",!1),l2(t)):t}],transformResponse:[function(t){let n=this.transitional||ed.transitional,r=n&&n.forcedJSONParsing,i=this.responseType==="json";if(x.isResponse(t)||x.isReadableStream(t))return t;if(t&&x.isString(t)&&(r&&!this.responseType||i)){let s=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(l){if(s)throw l.name==="SyntaxError"?D.from(l,D.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ge.classes.FormData,Blob:ge.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};x.forEach(["delete","get","head","post","put","patch"],e=>{ed.headers[e]={}});var di=ed;var a2=x.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),g_=e=>{let t={},n,r,i;return e&&e.split(` `).forEach(function(s){i=s.indexOf(":"),n=s.substring(0,i).trim().toLowerCase(),r=s.substring(i+1).trim(),!(!n||t[n]&&a2[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t};var y_=Symbol("internals");function zo(e){return e&&String(e).trim().toLowerCase()}function ca(e){return e===!1||e==null?e:x.isArray(e)?e.map(ca):String(e)}function u2(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var c2=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function td(e,t,n,r,i){if(x.isFunction(r))return r.call(this,t,n);if(i&&(t=n),!!x.isString(t)){if(x.isString(r))return t.indexOf(r)!==-1;if(x.isRegExp(r))return r.test(t)}}function f2(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function d2(e,t){let n=x.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(i,o,s){return this[r].call(this,t,i,o,s)},configurable:!0})})}var pi=class{constructor(t){t&&this.set(t)}set(t,n,r){let i=this;function o(l,c,u){let a=zo(c);if(!a)throw new Error("header name must be a non-empty string");let p=x.findKey(i,a);(!p||i[p]===void 0||u===!0||u===void 0&&i[p]!==!1)&&(i[p||c]=ca(l))}let s=(l,c)=>x.forEach(l,(u,a)=>o(u,a,c));if(x.isPlainObject(t)||t instanceof this.constructor)s(t,n);else if(x.isString(t)&&(t=t.trim())&&!c2(t))s(g_(t),n);else if(x.isHeaders(t))for(let[l,c]of t.entries())o(c,l,r);else t!=null&&o(n,t,r);return this}get(t,n){if(t=zo(t),t){let r=x.findKey(this,t);if(r){let i=this[r];if(!n)return i;if(n===!0)return u2(i);if(x.isFunction(n))return n.call(this,i,r);if(x.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=zo(t),t){let r=x.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||td(this,this[r],r,n)))}return!1}delete(t,n){let r=this,i=!1;function o(s){if(s=zo(s),s){let l=x.findKey(r,s);l&&(!n||td(r,r[l],l,n))&&(delete r[l],i=!0)}}return x.isArray(t)?t.forEach(o):o(t),i}clear(t){let n=Object.keys(this),r=n.length,i=!1;for(;r--;){let o=n[r];(!t||td(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){let n=this,r={};return x.forEach(this,(i,o)=>{let s=x.findKey(r,o);if(s){n[s]=ca(i),delete n[o];return}let l=t?f2(o):String(o).trim();l!==o&&delete n[o],n[l]=ca(i),r[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let n=Object.create(null);return x.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=t&&x.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` diff --git a/app/srv/ws/sync/code/utlis/ensure-lib.ts b/app/srv/ws/sync/code/utlis/ensure-lib.ts index 1fbf04c7..dd9fc901 100644 --- a/app/srv/ws/sync/code/utlis/ensure-lib.ts +++ b/app/srv/ws/sync/code/utlis/ensure-lib.ts @@ -1,8 +1,6 @@ import { $ } from "bun"; import { dir } from "dir"; -import { exists, dirAsync } from "fs-jetpack"; -import { removeAsync } from "fs-jetpack"; -import { g } from "utils/global"; +import { dirAsync, exists } from "fs-jetpack"; export const ensureLib = async (src_dir: string, id_site: string) => { if (!exists(dir.data(src_dir))) { @@ -13,7 +11,7 @@ export const ensureLib = async (src_dir: string, id_site: string) => { const _ = $.cwd(dir.data(src_dir)); await _`git clone https://github.com/avolut/prasi-lib lib`; } - if (true || !exists(dir.data(`${src_dir}/typings`))) { + if (!exists(dir.data(`${src_dir}/typings`))) { try { const site = await _db.site.findFirst({ where: { id: id_site }, @@ -38,6 +36,10 @@ export const ensureLib = async (src_dir: string, id_site: string) => { for (const [k, v] of Object.entries(prismaTypes)) { await Bun.write(dir.data(`${src_dir}/typings/${k}`), v as any); } + await Bun.write( + `${src_dir}/typings/api.d.ts`, + w.prasiApi["http://127.0.0.1/"]["apiTypes"] + ); } } } catch (e) { diff --git a/app/web/src/nova/vi/render/script/eval-prop.tsx b/app/web/src/nova/vi/render/script/eval-prop.tsx index c3929259..6ded2e03 100644 --- a/app/web/src/nova/vi/render/script/eval-prop.tsx +++ b/app/web/src/nova/vi/render/script/eval-prop.tsx @@ -156,8 +156,8 @@ export const viEvalProps = ( const definer = new Function( ...Object.keys(arg), `// [${meta.item.name}] ${name}: ${meta.item.id} - return ${src} - ` +return ${src.trim()} +` ); const fn = definer(...Object.values(arg));