@dcl-regenesislabs/web-editor 0.1.1-37509646646.commit-126b34d → 0.1.1-37517974772.commit-b9847a1

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/editor.js CHANGED
@@ -33889,4 +33889,4 @@ ${n}
33889
33889
  ${r}`));return"w"+Array.from(new Uint8Array(a).slice(0,16),c=>c.toString(16).padStart(2,"0")).join("")}function Lyr(t){return`${t.file===void 0?"":`${t.file}:${t.line??1}:${t.column??0}: `}${t.severity==="error"?"ERROR":"WARNING"}: ${t.message}`}function Fyr(t){return t.length<=3?t.join(", "):`${t.slice(0,3).join(", ")} and ${t.length-3} more`}function jyr(t,n){const r=Bx(t.get("package.json"));for(const a of[r==null?void 0:r.devDependencies,r==null?void 0:r.dependencies]){const c=typeof a=="object"&&a!==null?a["@dcl/sdk"]:void 0;if(typeof c=="string"&&c!==n)return`⚠ This project asks for @dcl/sdk ${c}; the editor builds it with ${n}.`}return null}function Byr(t){const{emit:n,log:r}=t;let a=null,c=!1,l=null,d=Promise.resolve();const m=A=>{const L=d.then(A,A);return d=L.catch(()=>{}),L};async function _(){if(c)throw new Error("The editor was closed");a===null&&(l=null);const A=a??whr(t.urls);a=A;try{const L=await A.ready;return{builder:A,sdkVersion:L.sdkVersion,info:L}}catch(L){throw A.dispose(),a===A&&(a=null),L}}async function S(A,L,j){const{builder:z,info:Q}=await _();let ne=!1;const ie=await Nyr(L,t.packages,Q.snapshot,he=>{t.onPackages(A,he),j&&!ne&&r("Downloading packages from npm…"),ne=!0});ie.lockFile!==void 0&&(L.set(hM,ie.lockFile),await t.saveLock(A,ie.lockFile));const Z=ie.lock===null?"":G9t(ie.lock);if(Z!==l)try{await z.setPackages(ie.lock,t.packages),l=Z}catch(he){j&&r(`⚠ ${iCt(he)}`),await z.setPackages(null),l=""}if(t.onPackages(A,ie.status),!(!j||ie.status===null)){if(ie.status.state==="error")r(`✖ ${ie.status.message??"The packages could not be installed"}`);else if(ie.downloaded>0){const he=Object.entries(ie.status.installed).map(([de,K])=>`${de} ${K}`);r(`✔ Packages frozen into the scene: ${he.join(", ")} (${ie.status.total} in all)`)}for(const he of ie.status.warnings)r(`⚠ ${he}`)}}function E(A,L,j=A){const z=Vze(t.pageDir,j),Q=new Set;let ne=null,ie=!1,Z=!1,he=null;const de=Me=>(n({type:"failed",message:Me}),r(`✖ Build failed: ${Me.split(`
33890
33890
  `)[0]}`),!1);async function K(Me){const It=performance.now();n({type:"buildStarted",changed:Me}),r(Me.length===0?"Building the scene…":`Rebuilding: ${Fyr(Me)}`);try{const{builder:Ut,sdkVersion:bt}=await _(),Dt=Me.length===0?jyr(L,bt):null;Dt!==null&&r(Dt);const _t=Me.length===0||Me.includes("package.json")||Me.includes(hM),{snapshot:Ve,result:Xt}=await m(async()=>{(_t||l!==he)&&(await S(A,L,!0),he=l);const Wt=new Map(L);return{snapshot:Wt,result:await Ut.build(Wt)}});if(Z)return!1;const He=Xt.diagnostics.filter(Wt=>Wt.severity==="error"||Wt.file===void 0||Ve.has(Wt.file));n({type:"diagnostics",diagnostics:He.map(({severity:Wt,message:mt,file:Pt,line:Tt,column:zt})=>({severity:Wt,message:mt,file:Pt,line:Tt,column:zt}))});for(const Wt of He)r(Lyr(Wt));if(!Xt.ok){const Wt=Xt.events.find(mt=>mt.type==="failed");return de((Wt==null?void 0:Wt.type)==="failed"?Wt.message:"The build produced no bundle")}const ze=Bx(Ve.get("scene.json"));return ze===null?de("scene.json is missing or is not valid JSON"):(await N_r({realmUrl:z,projectId:j,files:Ve,buildOutputs:Xt.outputs,sceneJson:ze,sdkVersion:bt,machineId:await t.machineId(j)}),Z?!1:(n({type:"bundleSaved"}),r(`✔ Built in ${Math.round(performance.now()-It)} ms`),!0))}catch(Ut){return Z?!1:de(iCt(Ut))}}async function Te(){if(!(ie||Z)){ie=!0;try{for(;Q.size>0&&!Z;){const Me=[...Q];Q.clear(),await K(Me)}}finally{ie=!1}}}return{id:A,files:L,async start(){ie=!0;try{return await K([])}finally{ie=!1,Q.size>0&&Te()}},async published(){const Me=await(await caches.open(j1e)).match(Wze(z)),It=await(Me==null?void 0:Me.json().catch(()=>{})),Ut=It==null?void 0:It.entity;return(Ut==null?void 0:Ut.id)===X9t(j,await t.machineId(j))},changed(Me){Z||(Q.add(Me),ne!==null&&clearTimeout(ne),ne=setTimeout(()=>{ne=null,Te()},Dyr))},stop(){Z=!0,ne!==null&&clearTimeout(ne)}}}return{realmUrl:A=>Vze(t.pageDir,A),open:E,async build(A,L,j){const{builder:z,sdkVersion:Q}=await _();return m(async()=>(await S(A,L,!1),{...await z.build(L,j),sdkVersion:Q}))},install:(A,L)=>m(()=>S(A,L,!1)),dispose(){c=!0,a==null||a.dispose(),a=null}}}const Uyr=200,$yr=2e3,zyr=/^\((?:no logs|\+\d+ older entries not retained)\)$/;function Vyr(t,n){for(let r=Math.min(t.length,n.length);r>0;r--){const a=t.length-r;if(n.slice(0,r).every((c,l)=>c===t[a+l]))return n.slice(r)}return[...n]}function Wyr(t,n){let r=[],a=!1,c;const l=async()=>{try{const d=await t(`scene_logs ${Uyr} --server`);if(a)return;const m=d.split(`
33891
33891
  `).filter(_=>_.trim()!==""&&!zyr.test(_.trim()));for(const _ of Vyr(r,m))n(_);r=m}catch{}a||(c=setTimeout(()=>void l(),$yr))};return l(),()=>{a=!0,clearTimeout(c)}}const qyr=new Set(["node_modules",".git","bin","dist"]),Gyr=300*1024,Jyr=56,Hyr=5;function Qyr(t){const n=t.origin,r=typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null;return r!==null&&(r.source==="import"||r.source==="github")?r:{...r??{},source:"user"}}function Yyr(t,n){const r=new Map;let a=new Map;function c(m,_){if(_.size>Gyr)return t.blob(m,_.hash);let S=r.get(_.hash);return S===void 0&&(S=t.blob(m,_.hash),r.set(_.hash,S),S.catch(()=>r.delete(_.hash))),S}const l={async folders(){const m=await t.list();return a=new Map(m.map(S=>[S.name,S])),(await Promise.all(m.map(async S=>{const E=S.files["data.json"];if(E===void 0)return null;const A=await c(S.name,E).then(j=>new TextDecoder().decode(j),()=>null);if(A===null)return null;const L=Object.fromEntries(Object.entries(S.files).map(([j,z])=>[j,z.size]));return{name:S.name,data:A,files:L}}))).filter(S=>S!==null)},async read(m,_){var E;const S=(E=a.get(m.name))==null?void 0:E.files[_];if(S===void 0)throw new Error(`${m.name}/${_} is not in your library`);return c(m.name,S)}};async function d(m,_){const S={},E=new Map;for(const[L,j]of _){const z=await n(j);S[L]={hash:z,size:j.length},E.set(z,j)}const A=[...E].map(([L,j])=>({hash:L,size:j.length}));for(const L of await t.uploads(m,A)){const j=E.get(L.hash);j!==void 0&&await t.putBlob(L,j)}await t.put(m,S)}return{tree:l,async copyOut(m,_){const[S,E,A]=_.split("/");if(S!=="custom"||E===void 0||A!==void 0||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(E))throw new Error(`not a prefab folder: ${_}`);const L=`${_}/`,j=new Map;for(const[K,Te]of m.files()){const Me=K.slice(L.length);K.startsWith(L)&&!Me.split("/").some(It=>qyr.has(It))&&j.set(Me,Te)}const z=j.get("data.json"),Q=z===void 0?null:fq(new TextDecoder().decode(z));if(Q===null)throw new Error(`${_} has no readable data.json`);const ne={...Q,id:typeof Q.id=="string"?Q.id:crypto.randomUUID(),origin:Qyr(Q)},ie=`${JSON.stringify(ne,null,2)}
33892
- `;j.set("data.json",new TextEncoder().encode(ie));const Z=eVe(SUt(Q,E)).slice(0,Jyr).replace(/_+$/,"")||"prefab",he=new Set((await t.list()).map(K=>K.name));let de=1;for(let K=0;K<Hyr;K++){let Te=Z;for(;he.has(Te);)Te=`${Z}_${++de}`;try{return await d(Te,j),{ref:`user:${Te}`,scope:"user",data:ie}}catch(Me){if(!(Me instanceof uUt))throw Me;he.add(Te)}}throw new Error("could not find a free name in your library — try again")},remove:m=>t.remove(m)}}function ure(t){const n={"web-build/worker.js":"sha384-ifej6zgLpr5r83XEO56nt4ZXOzQlxTmShy+nL+opSlQHaMKSawtrTn/Ty7zDTJbF","web-build/esbuild.wasm":"sha384-V8Ml7eHSlgGTb/TR1IYB6LtWwAW1NXLDPRjL2FjxwIfqDkSZ/hp+zmfvXDHqu8NV","web-build/sdk-snapshot.json":"sha384-W6PmOgO8Kk3JU+1ah/OJqTTxScfb4+BnVuC25NhYFKIjb5WnUUCE3O4BuPC7NLvg","prefabs/catalog.json":"sha384-rxpF/AYN1NtzvtLqUzjnnLFSv4aNP7+QCxWsLLr5hksKAsRLuI849rQNzDwJAT5t","editor.css":"sha384-UtVv2Sy+fO5029No4SyC1iW7hUXbIfy4nqF1QP2S8A7M1rUOv5qoJPnxdiNzAF60"}[t];if(n===void 0)throw new Error(`${t} is not one of the editor's published files`);return n}function Xyr(t){const n=r=>new URL(`web-build/${r}`,t).href;return{workerUrl:n("worker.js"),wasmUrl:n("esbuild.wasm"),snapshotUrl:n("sdk-snapshot.json"),integrity:{worker:ure("web-build/worker.js"),wasm:ure("web-build/esbuild.wasm"),snapshot:ure("web-build/sdk-snapshot.json")}}}const aCt=4e3,Zyr=4e6,Kyr=yNt*24*60*60*1e3,evr="assets/images",tvr=3e3,nvr=100,rvr="Sign in to keep prefabs in your own library. The built-in prefabs work without it.",ivr=t=>t instanceof Error?t.message:String(t),avr=({host:t,webBuild:n})=>{const r=new Tgr(ygr()),a=q3(t),c=a===null||a.services.projects===null?null:lUt(a.services.projects,(Xn,Fr)=>a.signedFetch(Xn,Fr)),l=()=>{const{address:Xn,isGuest:Fr}=t.identity();return Fr||Xn===null?null:Xn.toLowerCase()},d=[],m=[],_=[],S=[],E=[],A=Xn=>{d.push(Xn),d.length>aCt&&d.splice(0,d.length-aCt);for(const Fr of m)Fr(Xn)},L=Xn=>{for(const Fr of _)Fr(Xn)},j=new Map,z=new Set,Q=aNt.then(Ryr),ne=Byr({pageDir:t.pageDir,urls:n,machineId:async Xn=>Myr(await Q,l()??"guest",Xn),emit:L,log:A,packages:r.packages,saveLock:async(Xn,Fr)=>{await r.write(Xn,hM,Fr),mt.touched(Xn,hM),(Z==null?void 0:Z.id)===Xn&&Z.files.set(hM,Fr)},onPackages:(Xn,Fr)=>{if(Fr===null){j.delete(Xn);return}j.set(Xn,Fr);for(const ea of z)ea(Xn,Fr)}});let ie=null,Z=null,he=null,de=null;async function K(Xn){var ra;const Fr=(ra=(await r.list()).find(gs=>gs.id===Xn))==null?void 0:ra.previewId;if(Fr!==void 0)return Fr;const ea="p"+Array.from(crypto.getRandomValues(new Uint8Array(16)),gs=>gs.toString(16).padStart(2,"0")).join("");return await r.patch(Xn,{previewId:ea}),ea}async function Te(Xn){const Fr=new URL("preview/",t.pageDir).href,ea=await caches.open(j1e);for(const ra of await ea.keys())ra.url.startsWith(Fr)&&(Xn===null||!ra.url.startsWith(Xn))&&await ea.delete(ra)}let Me=0,It=Promise.resolve(),Ut=Promise.resolve();const bt=B_r({service:(a==null?void 0:a.services.projects)??null,fetch:(Xn,Fr)=>a===null?Promise.reject(new Error("The assistant service is not configured.")):a.signedFetch(Xn,Fr),wallet:l,project:()=>{const Xn=ui();return{id:Xn.id,tools:{files:()=>Xn.files,write:(Fr,ea,ra,gs)=>Ve(Xn.id,Fr,ea,{expected:ra,signal:gs}),scene:(Fr,ea)=>nUt(Fr,ea,async ra=>{await st(Xn.id,Bo=>Q_r(Bo,ra));const gs=Bx(await _t(Xn.id,"scene.json"));return{requiredPermissions:(gs==null?void 0:gs.requiredPermissions)??[],spawnPoints:(gs==null?void 0:gs.spawnPoints)??[]}}),written:U_r(),build:async Fr=>{Fr.throwIfAborted(),await Ut;const ea=await ne.build(Xn.id,new Map(Xn.files));return Fr.throwIfAborted(),{ok:ea.ok,diagnostics:ea.diagnostics}}}}}});function Dt(){bt.reset(),de==null||de(),de=null,Z!==null&&(Z.stop(),r.close(Z.id),mt.flush(Z.id),Z=null,he=null)}async function _t(Xn,Fr){return(Z==null?void 0:Z.id)===Xn?Z.files.get(Fr):r.read(Xn,Fr).catch(ea=>{if(!XP(ea))throw ea})}function Ve(Xn,Fr,ea,ra){const gs=Ut.then(async()=>{if(ra==null||ra.signal.throwIfAborted(),ra!==void 0&&((Z==null?void 0:Z.id)!==Xn||!L_r(Z.files.get(Fr),ra.expected)))throw new Error("This file changed. Read it again before writing.");await r.write(Xn,Fr,ea),mt.touched(Xn,Fr),(Z==null?void 0:Z.id)===Xn&&(Z.files.set(Fr,ea),Z.changed(Fr))});return Ut=gs.catch(Bo=>console.error("[editor] file write failed",Bo)),gs}function Xt(Xn,Fr){const ea=Ut.then(async()=>{const ra=await r.remove(Xn,Fr);return ra&&mt.touched(Xn,Fr),ra&&(Z==null?void 0:Z.id)===Xn&&Z.files.delete(Fr)&&Z.changed(Fr),ra});return Ut=ea.catch(ra=>console.error("[editor] file removal failed",ra)),ea}function He(Xn){const Fr=ui();if(Fr.id!==Xn)throw new Error("that scene is not the one open");return{files:()=>Fr.files,write:(ea,ra)=>Ve(Xn,ea,ra),remove:async ea=>{await Xt(Xn,ea)}}}async function ze(Xn){var ra;const Fr=Bx(await _t(Xn,"scene.json").catch(()=>{})),ea=(((ra=Fr==null?void 0:Fr.display)==null?void 0:ra.title)??"").replace(/[\x00-\x1f\x7f]/g,"").replace(new RegExp(cUt.source,"g"),"").trim().slice(0,nvr);return ea===""?Xn:ea}async function Wt(Xn,Fr){const ea=(await r.list()).find(gs=>gs.id===Xn);if(ea===void 0)return null;const ra=await r.duplicate(Xn,`${ea.name} ${Fr}`,mt.remoteIds());return await st(ra.id,gs=>{var Bo;return{...gs,display:{...gs.display??{},title:`${((Bo=gs.display)==null?void 0:Bo.title)||ea.name} ${Fr}`}}}),ra.id}const mt=Igr({store:r,session:()=>{const Xn=l();return c===null||Xn===null?null:{api:c,wallet:Xn}},account:()=>c===null?"unavailable":l()===null?"guest":"on",hash:M1e,title:ze,duplicate:async Xn=>{const Fr=await Wt(Xn,gNt(new Date));if(Fr===null)throw new Error("The scene is no longer on this device");return Fr}});let Pt=!1,Tt=0;async function zt(){const Xn=++Tt,Fr=l()!==null&&(await bt.shell.aiProviders()).some(ea=>ea.available);Xn!==Tt||Fr===Pt||(Pt=Fr,z0())}zt();let Qt=l();const Gt=setInterval(()=>{const Xn=l();Xn!==Qt&&(Qt=Xn,bt.reset(),z0(),zt(),mt.refresh(!0),Te(he).catch(Fr=>console.warn("[editor] could not clear the previews",Fr)))},tvr),Le=()=>{document.visibilityState==="hidden"&&mt.flush()};document.addEventListener("visibilitychange",Le);const Ze=new Set;async function st(Xn,Fr){const ea=Bx(await _t(Xn,"scene.json"));if(ea===null)throw new Error("scene.json is missing or is not valid JSON");await Ve(Xn,"scene.json",IEt(Fr(ea)))}async function sn(Xn,Fr){if(Fr==null||Fr==="")return null;const ea=await _t(Xn,Fr).catch(()=>{});return ea===void 0||ea.length>Zyr?null:NEt(Fr,ea)}async function Mn(Xn,Fr=mt.status().projects){var ra,gs,Bo,ef;const ea=Bx(await _t(Xn.id,"scene.json").catch(()=>{}));return{sync:Fr[Xn.id],path:Xn.id,name:Xn.name,title:((ra=ea==null?void 0:ea.display)==null?void 0:ra.title)||Xn.name,world:((gs=ea==null?void 0:ea.worldConfiguration)==null?void 0:gs.name)||null,parcels:Array.isArray((Bo=ea==null?void 0:ea.scene)==null?void 0:Bo.parcels)?ea.scene.parcels.length:0,thumbnail:await sn(Xn.id,(ef=ea==null?void 0:ea.display)==null?void 0:ef.navmapThumbnail),favourite:Xn.favourite,lastOpened:Xn.lastOpened,published:Xn.published,deletedAt:Xn.deletedAt??void 0}}async function dn(Xn,Fr){var ra,gs,Bo,ef,Qm;Dt(),d.length=0,L({type:"sessionStarted"});const ea=xr=>{if(Dt(),Fr===Me){A(`✖ ${xr}`);for(const Pc of E)Pc(xr)}};try{if(await mt.prepareOpen(Xn,(wu,Vv)=>A(`Downloading from your account… ${wu}/${Vv}`)),Fr!==Me)return;if(!await r.open(Xn)){ea("This scene is open in another tab. Close it there to edit it here.");return}const xr=await r.readAll(Xn).catch(wu=>{throw r.close(Xn),wu});if(Fr!==Me){r.close(Xn);return}const Pc=await K(Xn);if(Fr!==Me){r.close(Xn);return}const sd=ne.open(Xn,xr,Pc);Z=sd;const xi=ne.realmUrl(Pc);if(he=xi,A(`▶ Opening ${((gs=(ra=Bx(sd.files.get("scene.json")))==null?void 0:ra.display)==null?void 0:gs.title)||Xn}`),!await sd.start()&&!await sd.published()){if(Fr!==Me)return;A("✖ The scene did not build.");for(const wu of E)wu("The scene did not build.");return}if(await r.patch(Xn,{lastOpened:Date.now()}),Fr!==Me){Dt();return}const dl=Bx(sd.files.get("scene.json"))??{};ie={realm:xi.replace(/\/$/,""),systemScene:"",position:((Bo=dl.scene)==null?void 0:Bo.base)??((Qm=(ef=dl.scene)==null?void 0:ef.parcels)==null?void 0:Qm[0])??"0,0",spawn:G_r(dl),spawnPoints:JSON.stringify(Array.isArray(dl.spawnPoints)?dl.spawnPoints:[])},de=Wyr(wu=>t.engineConsole(wu),A);for(const wu of S)wu(ie)}catch(xr){ea(ivr(xr))}}function kn(Xn){ie=null;const Fr=++Me,ea=bt.reset(),ra=It.then(async()=>{await ea,await Ut,Fr===Me&&await Xn(Fr)});return It=ra.catch(gs=>console.error("[editor] project transition failed",gs)),ra}function ui(){if(Z===null)throw new Error("no project is open");return Z}const vt={saveFile:async({path:Xn,content:Fr})=>Ve(ui().id,Xn,Fr),getFile:async({path:Xn})=>{const Fr=ui().files.get(Xn)??byr(Xn);if(Fr===void 0)throw new Error(`no such file: ${Xn}`);return{content:Fr}},removeFiles:async({filePaths:Xn})=>{const Fr=ui(),ea=[],ra=[];for(const gs of Xn)(await Xt(Fr.id,gs).catch(()=>!1)?ea:ra).push(gs);return{success:ea,failed:ra}},getFilesSizes:async({path:Xn,ignore:Fr})=>{const ea=Xn===""?"":`${Xn.replace(/\/+$/,"")}/`;return{files:[...ui().files.keys()].filter(gs=>gs.startsWith(ea)&&!gs.split("/").some(Bo=>Fr.includes(Bo))).sort().map(gs=>({path:gs}))}}},zi={async find(Xn){return(await r.list()).some(Fr=>Fr.id===Xn)?!0:(await mt.refresh(!0),mt.remoteOnly().some(Fr=>Fr.id===Xn))},files:async Xn=>(Z==null?void 0:Z.id)===Xn?new Map(Z.files):r.readAll(Xn),manifest:Xn=>mt.manifest(Xn),build:async(Xn,Fr)=>ne.build(Xn,await zi.files(Xn),Fr),dependencies:async Xn=>iUt(await _t(Xn,"package.json")),onImported:Xn=>(Ze.add(Xn),()=>Ze.delete(Xn))},Br=a===null?null:ggr({host:a,setWorld:async(Xn,Fr)=>{var ra,gs;((gs=(ra=Bx(await _t(Xn,"scene.json")))==null?void 0:ra.worldConfiguration)==null?void 0:gs.name)!==Fr&&await st(Xn,Bo=>({...Bo,worldConfiguration:{...Bo.worldConfiguration??{},name:Fr}}))},files:Xn=>zi.files(Xn),build:(Xn,Fr)=>ne.build(Xn,Fr,{production:!0}),published:(Xn,Fr)=>r.patch(Xn,{published:Fr})}),_o=(a==null?void 0:a.services.projects)==null?null:Yyr(Cgr(a.services.projects,(Xn,Fr)=>a.signedFetch(Xn,Fr)),M1e),Bs=Oyr({builtin:Ggr(t.editorBase,ure("prefabs/catalog.json"),U9t),user:()=>_o!==null&&l()!==null?_o.tree:null}),xs={...(a==null?void 0:a.services.projects)==null?{}:{...bt.shell,aiOffered:()=>Pt,aiTranscript:()=>{const Xn=Qt;if(Xn===null||Z===null)return null;const Fr=Z.id;return{owner:`${Fr}@${Xn.toLowerCase()}`,load:()=>r.transcript(Fr,Xn),save:ea=>r.setTranscript(Fr,Xn,ea)}}},pickProject:async()=>{},openProject:Xn=>kn(Fr=>dn(Xn,Fr)),closeProject:()=>kn(async()=>{Dt(),L({type:"sessionStarted"}),A("■ Scene closed"),await Te(null).catch(Xn=>console.warn("[editor] could not clear the previews",Xn))}),getState:async()=>{const Xn=await r.list(),Fr=mt.status().projects,ea=mt.remoteOnly().map(ra=>({path:ra.id,name:ra.name,title:ra.name,world:null,parcels:0,thumbnail:null,remoteOnly:!0}));return{recentProjects:[...Xn].sort((ra,gs)=>gs.lastOpened-ra.lastOpened).map(ra=>ra.id),projects:[...await Promise.all(Xn.map(ra=>Mn(ra,Fr))),...ea],logs:[...d],bevyWebDir:"",editorSceneDir:"",webPort:0,scenePort:0,editorScenePort:0,favourites:Xn.filter(ra=>ra.favourite).map(ra=>ra.id)}},onStackLog:Xn=>{m.push(Xn)},onBuildEvent:Xn=>{_.push(Xn)},onServersReady:Xn=>{S.push(Xn)},requestReady:async()=>ie,onServersError:Xn=>{E.push(Xn)},toggleFavourite:async Xn=>{const Fr=(await r.list()).find(ea=>ea.id===Xn);Fr!==void 0&&await r.patch(Xn,{favourite:!Fr.favourite})},deleteProject:async Xn=>{const Fr=await r.trash(Xn);return Fr&&mt.trashed(Xn),Fr},trashedProjects:async()=>Promise.all((await r.trashed()).map(Xn=>Mn(Xn))),restoreProject:async Xn=>{const Fr=await r.restore(Xn);return Fr&&mt.restored(Xn),Fr},syncStatus:async()=>(mt.refresh(),mt.status()),onSyncStatus:Xn=>mt.subscribe(Xn),resolveSyncConflict:(Xn,Fr)=>mt.resolve(Xn,Fr),exportProject:async Xn=>Vgr(await ze(Xn),await zi.files(Xn)),importProject:async Xn=>{const Fr=await qgr(Xn,async(ea,ra)=>{const gs=await r.create(ea,ra,{taken:mt.remoteIds()});return mt.touched(gs.id,"scene.json"),gs.id});if((Fr==null?void 0:Fr.ok)===!0){const{id:ea,needsPackages:ra}=Fr.report;Object.keys(ra).length>0&&r.readAll(ea).then(gs=>ne.install(ea,gs)).catch(gs=>console.warn("[editor] could not install the packages of",ea,gs));for(const gs of Ze)gs(Fr.report)}return Fr},projectPackages:async Xn=>j.get(Xn)??null,onProjectPackages:Xn=>(z.add(Xn),()=>z.delete(Xn)),...Br===null||a===null?{}:{publishScene:(Xn,Fr,ea)=>Br.publish(Xn,Fr,ea),publishStop:async()=>Br.stop(),publishWorlds:async()=>{const Xn=l();return Xn===null?[]:hgr(Xn,a.services.worldsContent.replace(/\/+$/,""))}},canImportFolder:zgr(),renameProject:(Xn,Fr)=>st(Xn,ea=>({...ea,display:{...ea.display??{},title:Fr.trim()}})),duplicateProject:Xn=>Wt(Xn,"copy"),sceneTemplates:async()=>gyr(),createScene:async(Xn,Fr,ea)=>{const ra=bUt(ea),gs=Bx(ra.get("scene.json"));if(gs===null)throw new Error(`template not found: ${ea}`);ra.set("scene.json",IEt({...gs,display:{...gs.display??{},title:Fr.trim()}}));const Bo=await r.create(Fr,ra,{taken:mt.remoteIds()});return mt.touched(Bo.id,"scene.json"),Bo.id},openExternal:async Xn=>{/^https?:$/.test(new URL(Xn).protocol)&&window.open(Xn,"_blank","noopener,noreferrer")},compositeEntityIds:async Xn=>{for(const Fr of J_r){const ea=await _t(Xn,Fr);if(ea!==void 0)return H_r(new TextDecoder().decode(ea))}return[]},sceneSettings:async Xn=>{const Fr=Bx(await _t(Xn,"scene.json"));if(Fr===null)throw new Error("scene.json is missing or is not valid JSON");const ea=z_r(Fr);return{...ea,thumbnail:await sn(Xn,ea.thumbnailPath)}},saveSceneSettings:async(Xn,Fr)=>{const ea=W_r(Fr);return ea!==null?ea:(await st(Xn,ra=>q_r(ra,Fr)),null)},pickSceneThumbnail:async Xn=>{const Fr=await vUt(Object.values(qze).join(","));if(Fr===null)return null;const ea=rUt(Fr.name);if(qze[ea]===void 0)throw new Error("not a supported image (png, jpg, gif, webp)");const ra=`${evr}/scene-thumbnail${ea}`,gs=new Uint8Array(await Fr.arrayBuffer());return await Ve(Xn,ra,gs),{path:ra,dataUrl:NEt(ra,gs)}},appVersion:async()=>D_r,prefabLibraryList:()=>Bs.list(),prefabLibraryCopyIn:async(Xn,Fr)=>Bs.copyIn(Xn,He(Fr)),prefabLibraryUpdateCopy:async(Xn,Fr)=>Bs.updateCopy(Xn,He(Fr)),prefabUserLibrary:()=>_o===null?"unavailable":l()===null?"guest":"on",..._o===null?{}:{prefabLibraryCopyOut:async(Xn,Fr)=>{if(l()===null)throw new Error(rvr);return _o.copyOut(He(Xn),Fr)},prefabLibraryDelete:async Xn=>{const Fr=xUt(Xn);return(Fr==null?void 0:Fr.scope)==="user"&&l()!==null?_o.remove(Fr.name):!1}}};async function vc(){const Xn=new Set;for(const Fr of[...await r.list(),...await r.trashed()]){const ea=q9t(await _t(Fr.id,hM).catch(()=>{}));for(const ra of Object.keys((ea==null?void 0:ea.packages)??{}))Xn.add(ra);for(const[ra,gs]of Object.entries((ea==null?void 0:ea.dependencies)??{}))Xn.add(E7(ra,gs))}for(const Fr of await r.packages.keys())Xn.has(Fr)||await r.packages.remove(Fr)}return r.purge(Date.now()-Kyr).then(async Xn=>{const Fr=await caches.open(j1e),ea=Xn.map(({id:gs,previewId:Bo})=>ne.realmUrl(Bo??gs));for(const gs of await Fr.keys())ea.some(Bo=>gs.url.startsWith(Bo))&&await Fr.delete(gs);const ra=await caches.open(I_r);for(const gs of ea)await ra.delete(`${gs}__storage`);Xn.length>0&&await vc()}).catch(Xn=>console.warn("[editor] could not empty the trash",Xn)),{shell:xs,projects:zi,dataLayer:vt,dispose:()=>{bt.dispose(),Me++,Dt(),ne.dispose(),clearInterval(Gt),document.removeEventListener("visibilitychange",Le),mt.flush().finally(()=>mt.dispose())}}};let C7=null,Hq=null,xne=null,sCt=!1;function svr(){if(C7!==null)return C7;const t=window.__dclEditorHost;if(t===void 0||t.version!==0&&t.version!==1)return console.error("[editor] window.__dclEditorHost (contract v0 or v1) is missing: nothing to mount into"),null;console.log("[editor] web build 2026-10-06T18:14:34.709Z"),cOt(t),rOt(a=>t.engineConsole(a)),pNt(()=>t.identity()),lzn.needed=!1;const n=avr({host:t,webBuild:Xyr(t.editorBase)});window.editorShell=ovr(n.shell,t),DPt(n.dataLayer??null),QWe();const r=document.createElement("link");return r.rel="stylesheet",r.href=new URL("editor.css",t.editorBase).href,r.integrity=ure("editor.css"),r.crossOrigin="anonymous",r.onerror=()=>console.error("[editor] editor.css did not load or does not match the hash this editor was published with: its fonts are not applied"),document.head.appendChild(r),CA.project=null,CA.notice=null,C7={host:t,web:n,fonts:r},C7}function z1e(){const t=Hq;Hq=null,t==null||t.unmount()}function ovr(t,n){return{...t,openProject:async r=>{const a=Hq;z1e(),a==null||a.api.close(),xne??(xne=KLt(n.container,P.jsx(fhr,{}))),n.setMode("edit"),CA.project=r,CA.opens++,await t.openProject(r)}}}function cvr(t,n){var m;const r=svr();if(r===null)return()=>{};z1e();const a=document.createElement("div");a.style.cssText="position:relative;width:100%;height:100%",V$n(a),t.appendChild(a);const c=KLt(a,P.jsx(G$n,{}),"eui-create-root"),l={api:n,unmount:()=>{c(),a.remove()}};Hq=l;const d=sCt?null:((m=q3(r.host))==null?void 0:m.openProject)??null;return sCt=!0,d!==null&&r.web.projects.find(d).catch(()=>!1).then(_=>{var S;Hq===l&&(_?(S=window.editorShell)==null||S.openProject(d):CA.notice=`“${d}” is not on this device or on your account. Here are your scenes.`)}),()=>{Hq===l&&z1e()}}function lvr(){z1e();const t=C7;if(t===null)return;C7=null;const n=J3();xne==null||xne(),xne=null,t.fonts.remove(),CA.project=null,delete window.editorShell,pNt(null),rOt(null),cOt(null),t.host.setMode("off"),n.finally(()=>{var r,a;(a=(r=t.web).dispose)==null||a.call(r),C7===null&&DPt(null)})}window.__dclEditor={mountHome:cvr,unmount:lvr};
33892
+ `;j.set("data.json",new TextEncoder().encode(ie));const Z=eVe(SUt(Q,E)).slice(0,Jyr).replace(/_+$/,"")||"prefab",he=new Set((await t.list()).map(K=>K.name));let de=1;for(let K=0;K<Hyr;K++){let Te=Z;for(;he.has(Te);)Te=`${Z}_${++de}`;try{return await d(Te,j),{ref:`user:${Te}`,scope:"user",data:ie}}catch(Me){if(!(Me instanceof uUt))throw Me;he.add(Te)}}throw new Error("could not find a free name in your library — try again")},remove:m=>t.remove(m)}}function ure(t){const n={"web-build/worker.js":"sha384-ifej6zgLpr5r83XEO56nt4ZXOzQlxTmShy+nL+opSlQHaMKSawtrTn/Ty7zDTJbF","web-build/esbuild.wasm":"sha384-V8Ml7eHSlgGTb/TR1IYB6LtWwAW1NXLDPRjL2FjxwIfqDkSZ/hp+zmfvXDHqu8NV","web-build/sdk-snapshot.json":"sha384-W6PmOgO8Kk3JU+1ah/OJqTTxScfb4+BnVuC25NhYFKIjb5WnUUCE3O4BuPC7NLvg","prefabs/catalog.json":"sha384-rxpF/AYN1NtzvtLqUzjnnLFSv4aNP7+QCxWsLLr5hksKAsRLuI849rQNzDwJAT5t","editor.css":"sha384-UtVv2Sy+fO5029No4SyC1iW7hUXbIfy4nqF1QP2S8A7M1rUOv5qoJPnxdiNzAF60"}[t];if(n===void 0)throw new Error(`${t} is not one of the editor's published files`);return n}function Xyr(t){const n=r=>new URL(`web-build/${r}`,t).href;return{workerUrl:n("worker.js"),wasmUrl:n("esbuild.wasm"),snapshotUrl:n("sdk-snapshot.json"),integrity:{worker:ure("web-build/worker.js"),wasm:ure("web-build/esbuild.wasm"),snapshot:ure("web-build/sdk-snapshot.json")}}}const aCt=4e3,Zyr=4e6,Kyr=yNt*24*60*60*1e3,evr="assets/images",tvr=3e3,nvr=100,rvr="Sign in to keep prefabs in your own library. The built-in prefabs work without it.",ivr=t=>t instanceof Error?t.message:String(t),avr=({host:t,webBuild:n})=>{const r=new Tgr(ygr()),a=q3(t),c=a===null||a.services.projects===null?null:lUt(a.services.projects,(Xn,Fr)=>a.signedFetch(Xn,Fr)),l=()=>{const{address:Xn,isGuest:Fr}=t.identity();return Fr||Xn===null?null:Xn.toLowerCase()},d=[],m=[],_=[],S=[],E=[],A=Xn=>{d.push(Xn),d.length>aCt&&d.splice(0,d.length-aCt);for(const Fr of m)Fr(Xn)},L=Xn=>{for(const Fr of _)Fr(Xn)},j=new Map,z=new Set,Q=aNt.then(Ryr),ne=Byr({pageDir:t.pageDir,urls:n,machineId:async Xn=>Myr(await Q,l()??"guest",Xn),emit:L,log:A,packages:r.packages,saveLock:async(Xn,Fr)=>{await r.write(Xn,hM,Fr),mt.touched(Xn,hM),(Z==null?void 0:Z.id)===Xn&&Z.files.set(hM,Fr)},onPackages:(Xn,Fr)=>{if(Fr===null){j.delete(Xn);return}j.set(Xn,Fr);for(const ea of z)ea(Xn,Fr)}});let ie=null,Z=null,he=null,de=null;async function K(Xn){var ra;const Fr=(ra=(await r.list()).find(gs=>gs.id===Xn))==null?void 0:ra.previewId;if(Fr!==void 0)return Fr;const ea="p"+Array.from(crypto.getRandomValues(new Uint8Array(16)),gs=>gs.toString(16).padStart(2,"0")).join("");return await r.patch(Xn,{previewId:ea}),ea}async function Te(Xn){const Fr=new URL("preview/",t.pageDir).href,ea=await caches.open(j1e);for(const ra of await ea.keys())ra.url.startsWith(Fr)&&(Xn===null||!ra.url.startsWith(Xn))&&await ea.delete(ra)}let Me=0,It=Promise.resolve(),Ut=Promise.resolve();const bt=B_r({service:(a==null?void 0:a.services.projects)??null,fetch:(Xn,Fr)=>a===null?Promise.reject(new Error("The assistant service is not configured.")):a.signedFetch(Xn,Fr),wallet:l,project:()=>{const Xn=ui();return{id:Xn.id,tools:{files:()=>Xn.files,write:(Fr,ea,ra,gs)=>Ve(Xn.id,Fr,ea,{expected:ra,signal:gs}),scene:(Fr,ea)=>nUt(Fr,ea,async ra=>{await st(Xn.id,Bo=>Q_r(Bo,ra));const gs=Bx(await _t(Xn.id,"scene.json"));return{requiredPermissions:(gs==null?void 0:gs.requiredPermissions)??[],spawnPoints:(gs==null?void 0:gs.spawnPoints)??[]}}),written:U_r(),build:async Fr=>{Fr.throwIfAborted(),await Ut;const ea=await ne.build(Xn.id,new Map(Xn.files));return Fr.throwIfAborted(),{ok:ea.ok,diagnostics:ea.diagnostics}}}}}});function Dt(){bt.reset(),de==null||de(),de=null,Z!==null&&(Z.stop(),r.close(Z.id),mt.flush(Z.id),Z=null,he=null)}async function _t(Xn,Fr){return(Z==null?void 0:Z.id)===Xn?Z.files.get(Fr):r.read(Xn,Fr).catch(ea=>{if(!XP(ea))throw ea})}function Ve(Xn,Fr,ea,ra){const gs=Ut.then(async()=>{if(ra==null||ra.signal.throwIfAborted(),ra!==void 0&&((Z==null?void 0:Z.id)!==Xn||!L_r(Z.files.get(Fr),ra.expected)))throw new Error("This file changed. Read it again before writing.");await r.write(Xn,Fr,ea),mt.touched(Xn,Fr),(Z==null?void 0:Z.id)===Xn&&(Z.files.set(Fr,ea),Z.changed(Fr))});return Ut=gs.catch(Bo=>console.error("[editor] file write failed",Bo)),gs}function Xt(Xn,Fr){const ea=Ut.then(async()=>{const ra=await r.remove(Xn,Fr);return ra&&mt.touched(Xn,Fr),ra&&(Z==null?void 0:Z.id)===Xn&&Z.files.delete(Fr)&&Z.changed(Fr),ra});return Ut=ea.catch(ra=>console.error("[editor] file removal failed",ra)),ea}function He(Xn){const Fr=ui();if(Fr.id!==Xn)throw new Error("that scene is not the one open");return{files:()=>Fr.files,write:(ea,ra)=>Ve(Xn,ea,ra),remove:async ea=>{await Xt(Xn,ea)}}}async function ze(Xn){var ra;const Fr=Bx(await _t(Xn,"scene.json").catch(()=>{})),ea=(((ra=Fr==null?void 0:Fr.display)==null?void 0:ra.title)??"").replace(/[\x00-\x1f\x7f]/g,"").replace(new RegExp(cUt.source,"g"),"").trim().slice(0,nvr);return ea===""?Xn:ea}async function Wt(Xn,Fr){const ea=(await r.list()).find(gs=>gs.id===Xn);if(ea===void 0)return null;const ra=await r.duplicate(Xn,`${ea.name} ${Fr}`,mt.remoteIds());return await st(ra.id,gs=>{var Bo;return{...gs,display:{...gs.display??{},title:`${((Bo=gs.display)==null?void 0:Bo.title)||ea.name} ${Fr}`}}}),ra.id}const mt=Igr({store:r,session:()=>{const Xn=l();return c===null||Xn===null?null:{api:c,wallet:Xn}},account:()=>c===null?"unavailable":l()===null?"guest":"on",hash:M1e,title:ze,duplicate:async Xn=>{const Fr=await Wt(Xn,gNt(new Date));if(Fr===null)throw new Error("The scene is no longer on this device");return Fr}});let Pt=!1,Tt=0;async function zt(){const Xn=++Tt,Fr=l()!==null&&(await bt.shell.aiProviders()).some(ea=>ea.available);Xn!==Tt||Fr===Pt||(Pt=Fr,z0())}zt();let Qt=l();const Gt=setInterval(()=>{const Xn=l();Xn!==Qt&&(Qt=Xn,bt.reset(),z0(),zt(),mt.refresh(!0),Te(he).catch(Fr=>console.warn("[editor] could not clear the previews",Fr)))},tvr),Le=()=>{document.visibilityState==="hidden"&&mt.flush()};document.addEventListener("visibilitychange",Le);const Ze=new Set;async function st(Xn,Fr){const ea=Bx(await _t(Xn,"scene.json"));if(ea===null)throw new Error("scene.json is missing or is not valid JSON");await Ve(Xn,"scene.json",IEt(Fr(ea)))}async function sn(Xn,Fr){if(Fr==null||Fr==="")return null;const ea=await _t(Xn,Fr).catch(()=>{});return ea===void 0||ea.length>Zyr?null:NEt(Fr,ea)}async function Mn(Xn,Fr=mt.status().projects){var ra,gs,Bo,ef;const ea=Bx(await _t(Xn.id,"scene.json").catch(()=>{}));return{sync:Fr[Xn.id],path:Xn.id,name:Xn.name,title:((ra=ea==null?void 0:ea.display)==null?void 0:ra.title)||Xn.name,world:((gs=ea==null?void 0:ea.worldConfiguration)==null?void 0:gs.name)||null,parcels:Array.isArray((Bo=ea==null?void 0:ea.scene)==null?void 0:Bo.parcels)?ea.scene.parcels.length:0,thumbnail:await sn(Xn.id,(ef=ea==null?void 0:ea.display)==null?void 0:ef.navmapThumbnail),favourite:Xn.favourite,lastOpened:Xn.lastOpened,published:Xn.published,deletedAt:Xn.deletedAt??void 0}}async function dn(Xn,Fr){var ra,gs,Bo,ef,Qm;Dt(),d.length=0,L({type:"sessionStarted"});const ea=xr=>{if(Dt(),Fr===Me){A(`✖ ${xr}`);for(const Pc of E)Pc(xr)}};try{if(await mt.prepareOpen(Xn,(wu,Vv)=>A(`Downloading from your account… ${wu}/${Vv}`)),Fr!==Me)return;if(!await r.open(Xn)){ea("This scene is open in another tab. Close it there to edit it here.");return}const xr=await r.readAll(Xn).catch(wu=>{throw r.close(Xn),wu});if(Fr!==Me){r.close(Xn);return}const Pc=await K(Xn);if(Fr!==Me){r.close(Xn);return}const sd=ne.open(Xn,xr,Pc);Z=sd;const xi=ne.realmUrl(Pc);if(he=xi,A(`▶ Opening ${((gs=(ra=Bx(sd.files.get("scene.json")))==null?void 0:ra.display)==null?void 0:gs.title)||Xn}`),!await sd.start()&&!await sd.published()){if(Fr!==Me)return;A("✖ The scene did not build.");for(const wu of E)wu("The scene did not build.");return}if(await r.patch(Xn,{lastOpened:Date.now()}),Fr!==Me){Dt();return}const dl=Bx(sd.files.get("scene.json"))??{};ie={realm:xi.replace(/\/$/,""),systemScene:"",position:((Bo=dl.scene)==null?void 0:Bo.base)??((Qm=(ef=dl.scene)==null?void 0:ef.parcels)==null?void 0:Qm[0])??"0,0",spawn:G_r(dl),spawnPoints:JSON.stringify(Array.isArray(dl.spawnPoints)?dl.spawnPoints:[])},de=Wyr(wu=>t.engineConsole(wu),A);for(const wu of S)wu(ie)}catch(xr){ea(ivr(xr))}}function kn(Xn){ie=null;const Fr=++Me,ea=bt.reset(),ra=It.then(async()=>{await ea,await Ut,Fr===Me&&await Xn(Fr)});return It=ra.catch(gs=>console.error("[editor] project transition failed",gs)),ra}function ui(){if(Z===null)throw new Error("no project is open");return Z}const vt={saveFile:async({path:Xn,content:Fr})=>Ve(ui().id,Xn,Fr),getFile:async({path:Xn})=>{const Fr=ui().files.get(Xn)??byr(Xn);if(Fr===void 0)throw new Error(`no such file: ${Xn}`);return{content:Fr}},removeFiles:async({filePaths:Xn})=>{const Fr=ui(),ea=[],ra=[];for(const gs of Xn)(await Xt(Fr.id,gs).catch(()=>!1)?ea:ra).push(gs);return{success:ea,failed:ra}},getFilesSizes:async({path:Xn,ignore:Fr})=>{const ea=Xn===""?"":`${Xn.replace(/\/+$/,"")}/`;return{files:[...ui().files.keys()].filter(gs=>gs.startsWith(ea)&&!gs.split("/").some(Bo=>Fr.includes(Bo))).sort().map(gs=>({path:gs}))}}},zi={async find(Xn){return(await r.list()).some(Fr=>Fr.id===Xn)?!0:(await mt.refresh(!0),mt.remoteOnly().some(Fr=>Fr.id===Xn))},files:async Xn=>(Z==null?void 0:Z.id)===Xn?new Map(Z.files):r.readAll(Xn),manifest:Xn=>mt.manifest(Xn),build:async(Xn,Fr)=>ne.build(Xn,await zi.files(Xn),Fr),dependencies:async Xn=>iUt(await _t(Xn,"package.json")),onImported:Xn=>(Ze.add(Xn),()=>Ze.delete(Xn))},Br=a===null?null:ggr({host:a,setWorld:async(Xn,Fr)=>{var ra,gs;((gs=(ra=Bx(await _t(Xn,"scene.json")))==null?void 0:ra.worldConfiguration)==null?void 0:gs.name)!==Fr&&await st(Xn,Bo=>({...Bo,worldConfiguration:{...Bo.worldConfiguration??{},name:Fr}}))},files:Xn=>zi.files(Xn),build:(Xn,Fr)=>ne.build(Xn,Fr,{production:!0}),published:(Xn,Fr)=>r.patch(Xn,{published:Fr})}),_o=(a==null?void 0:a.services.projects)==null?null:Yyr(Cgr(a.services.projects,(Xn,Fr)=>a.signedFetch(Xn,Fr)),M1e),Bs=Oyr({builtin:Ggr(t.editorBase,ure("prefabs/catalog.json"),U9t),user:()=>_o!==null&&l()!==null?_o.tree:null}),xs={...(a==null?void 0:a.services.projects)==null?{}:{...bt.shell,aiOffered:()=>Pt,aiTranscript:()=>{const Xn=Qt;if(Xn===null||Z===null)return null;const Fr=Z.id;return{owner:`${Fr}@${Xn.toLowerCase()}`,load:()=>r.transcript(Fr,Xn),save:ea=>r.setTranscript(Fr,Xn,ea)}}},pickProject:async()=>{},openProject:Xn=>kn(Fr=>dn(Xn,Fr)),closeProject:()=>kn(async()=>{Dt(),L({type:"sessionStarted"}),A("■ Scene closed"),await Te(null).catch(Xn=>console.warn("[editor] could not clear the previews",Xn))}),getState:async()=>{const Xn=await r.list(),Fr=mt.status().projects,ea=mt.remoteOnly().map(ra=>({path:ra.id,name:ra.name,title:ra.name,world:null,parcels:0,thumbnail:null,remoteOnly:!0}));return{recentProjects:[...Xn].sort((ra,gs)=>gs.lastOpened-ra.lastOpened).map(ra=>ra.id),projects:[...await Promise.all(Xn.map(ra=>Mn(ra,Fr))),...ea],logs:[...d],bevyWebDir:"",editorSceneDir:"",webPort:0,scenePort:0,editorScenePort:0,favourites:Xn.filter(ra=>ra.favourite).map(ra=>ra.id)}},onStackLog:Xn=>{m.push(Xn)},onBuildEvent:Xn=>{_.push(Xn)},onServersReady:Xn=>{S.push(Xn)},requestReady:async()=>ie,onServersError:Xn=>{E.push(Xn)},toggleFavourite:async Xn=>{const Fr=(await r.list()).find(ea=>ea.id===Xn);Fr!==void 0&&await r.patch(Xn,{favourite:!Fr.favourite})},deleteProject:async Xn=>{const Fr=await r.trash(Xn);return Fr&&mt.trashed(Xn),Fr},trashedProjects:async()=>Promise.all((await r.trashed()).map(Xn=>Mn(Xn))),restoreProject:async Xn=>{const Fr=await r.restore(Xn);return Fr&&mt.restored(Xn),Fr},syncStatus:async()=>(mt.refresh(),mt.status()),onSyncStatus:Xn=>mt.subscribe(Xn),resolveSyncConflict:(Xn,Fr)=>mt.resolve(Xn,Fr),exportProject:async Xn=>Vgr(await ze(Xn),await zi.files(Xn)),importProject:async Xn=>{const Fr=await qgr(Xn,async(ea,ra)=>{const gs=await r.create(ea,ra,{taken:mt.remoteIds()});return mt.touched(gs.id,"scene.json"),gs.id});if((Fr==null?void 0:Fr.ok)===!0){const{id:ea,needsPackages:ra}=Fr.report;Object.keys(ra).length>0&&r.readAll(ea).then(gs=>ne.install(ea,gs)).catch(gs=>console.warn("[editor] could not install the packages of",ea,gs));for(const gs of Ze)gs(Fr.report)}return Fr},projectPackages:async Xn=>j.get(Xn)??null,onProjectPackages:Xn=>(z.add(Xn),()=>z.delete(Xn)),...Br===null||a===null?{}:{publishScene:(Xn,Fr,ea)=>Br.publish(Xn,Fr,ea),publishStop:async()=>Br.stop(),publishWorlds:async()=>{const Xn=l();return Xn===null?[]:hgr(Xn,a.services.worldsContent.replace(/\/+$/,""))}},canImportFolder:zgr(),renameProject:(Xn,Fr)=>st(Xn,ea=>({...ea,display:{...ea.display??{},title:Fr.trim()}})),duplicateProject:Xn=>Wt(Xn,"copy"),sceneTemplates:async()=>gyr(),createScene:async(Xn,Fr,ea)=>{const ra=bUt(ea),gs=Bx(ra.get("scene.json"));if(gs===null)throw new Error(`template not found: ${ea}`);ra.set("scene.json",IEt({...gs,display:{...gs.display??{},title:Fr.trim()}}));const Bo=await r.create(Fr,ra,{taken:mt.remoteIds()});return mt.touched(Bo.id,"scene.json"),Bo.id},openExternal:async Xn=>{/^https?:$/.test(new URL(Xn).protocol)&&window.open(Xn,"_blank","noopener,noreferrer")},compositeEntityIds:async Xn=>{for(const Fr of J_r){const ea=await _t(Xn,Fr);if(ea!==void 0)return H_r(new TextDecoder().decode(ea))}return[]},sceneSettings:async Xn=>{const Fr=Bx(await _t(Xn,"scene.json"));if(Fr===null)throw new Error("scene.json is missing or is not valid JSON");const ea=z_r(Fr);return{...ea,thumbnail:await sn(Xn,ea.thumbnailPath)}},saveSceneSettings:async(Xn,Fr)=>{const ea=W_r(Fr);return ea!==null?ea:(await st(Xn,ra=>q_r(ra,Fr)),null)},pickSceneThumbnail:async Xn=>{const Fr=await vUt(Object.values(qze).join(","));if(Fr===null)return null;const ea=rUt(Fr.name);if(qze[ea]===void 0)throw new Error("not a supported image (png, jpg, gif, webp)");const ra=`${evr}/scene-thumbnail${ea}`,gs=new Uint8Array(await Fr.arrayBuffer());return await Ve(Xn,ra,gs),{path:ra,dataUrl:NEt(ra,gs)}},appVersion:async()=>D_r,prefabLibraryList:()=>Bs.list(),prefabLibraryCopyIn:async(Xn,Fr)=>Bs.copyIn(Xn,He(Fr)),prefabLibraryUpdateCopy:async(Xn,Fr)=>Bs.updateCopy(Xn,He(Fr)),prefabUserLibrary:()=>_o===null?"unavailable":l()===null?"guest":"on",..._o===null?{}:{prefabLibraryCopyOut:async(Xn,Fr)=>{if(l()===null)throw new Error(rvr);return _o.copyOut(He(Xn),Fr)},prefabLibraryDelete:async Xn=>{const Fr=xUt(Xn);return(Fr==null?void 0:Fr.scope)==="user"&&l()!==null?_o.remove(Fr.name):!1}}};async function vc(){const Xn=new Set;for(const Fr of[...await r.list(),...await r.trashed()]){const ea=q9t(await _t(Fr.id,hM).catch(()=>{}));for(const ra of Object.keys((ea==null?void 0:ea.packages)??{}))Xn.add(ra);for(const[ra,gs]of Object.entries((ea==null?void 0:ea.dependencies)??{}))Xn.add(E7(ra,gs))}for(const Fr of await r.packages.keys())Xn.has(Fr)||await r.packages.remove(Fr)}return r.purge(Date.now()-Kyr).then(async Xn=>{const Fr=await caches.open(j1e),ea=Xn.map(({id:gs,previewId:Bo})=>ne.realmUrl(Bo??gs));for(const gs of await Fr.keys())ea.some(Bo=>gs.url.startsWith(Bo))&&await Fr.delete(gs);const ra=await caches.open(I_r);for(const gs of ea)await ra.delete(`${gs}__storage`);Xn.length>0&&await vc()}).catch(Xn=>console.warn("[editor] could not empty the trash",Xn)),{shell:xs,projects:zi,dataLayer:vt,dispose:()=>{bt.dispose(),Me++,Dt(),ne.dispose(),clearInterval(Gt),document.removeEventListener("visibilitychange",Le),mt.flush().finally(()=>mt.dispose())}}};let C7=null,Hq=null,xne=null,sCt=!1;function svr(){if(C7!==null)return C7;const t=window.__dclEditorHost;if(t===void 0||t.version!==0&&t.version!==1)return console.error("[editor] window.__dclEditorHost (contract v0 or v1) is missing: nothing to mount into"),null;console.log("[editor] web build 2026-10-06T19:19:12.550Z"),cOt(t),rOt(a=>t.engineConsole(a)),pNt(()=>t.identity()),lzn.needed=!1;const n=avr({host:t,webBuild:Xyr(t.editorBase)});window.editorShell=ovr(n.shell,t),DPt(n.dataLayer??null),QWe();const r=document.createElement("link");return r.rel="stylesheet",r.href=new URL("editor.css",t.editorBase).href,r.integrity=ure("editor.css"),r.crossOrigin="anonymous",r.onerror=()=>console.error("[editor] editor.css did not load or does not match the hash this editor was published with: its fonts are not applied"),document.head.appendChild(r),CA.project=null,CA.notice=null,C7={host:t,web:n,fonts:r},C7}function z1e(){const t=Hq;Hq=null,t==null||t.unmount()}function ovr(t,n){return{...t,openProject:async r=>{const a=Hq;z1e(),a==null||a.api.close(),xne??(xne=KLt(n.container,P.jsx(fhr,{}))),n.setMode("edit"),CA.project=r,CA.opens++,await t.openProject(r)}}}function cvr(t,n){var m;const r=svr();if(r===null)return()=>{};z1e();const a=document.createElement("div");a.style.cssText="position:relative;width:100%;height:100%",V$n(a),t.appendChild(a);const c=KLt(a,P.jsx(G$n,{}),"eui-create-root"),l={api:n,unmount:()=>{c(),a.remove()}};Hq=l;const d=sCt?null:((m=q3(r.host))==null?void 0:m.openProject)??null;return sCt=!0,d!==null&&r.web.projects.find(d).catch(()=>!1).then(_=>{var S;Hq===l&&(_?(S=window.editorShell)==null||S.openProject(d):CA.notice=`“${d}” is not on this device or on your account. Here are your scenes.`)}),()=>{Hq===l&&z1e()}}function lvr(){z1e();const t=C7;if(t===null)return;C7=null;const n=J3();xne==null||xne(),xne=null,t.fonts.remove(),CA.project=null,delete window.editorShell,pNt(null),rOt(null),cOt(null),t.host.setMode("off"),n.finally(()=>{var r,a;(a=(r=t.web).dispose)==null||a.call(r),C7===null&&DPt(null)})}window.__dclEditor={mountHome:cvr,unmount:lvr};
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dcl-regenesislabs/web-editor",
3
- "version": "0.1.1-37509646646.commit-126b34d",
3
+ "version": "0.1.1-37517974772.commit-b9847a1",
4
4
  "description": "The Decentraland scene editor for the web explorer: editor.js plus the files it loads beside it. Served by version, not installed.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/dcl-regenesislabs/bevy-editor.git",
8
8
  "directory": "packages/web"
9
9
  },
10
- "commit": "126b34d94422ac7dbf6702ef8f5409be79849b01"
10
+ "commit": "b9847a1334ed688a86f5f66fe9a6e75eaf43fd32"
11
11
  }