@dcl-regenesislabs/web-editor 0.3.9 → 0.3.11

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.
Files changed (42) hide show
  1. package/editor.js +436 -434
  2. package/package.json +1 -1
  3. package/prefabs/catalog.json +1 -1
  4. package/prefabs/leaderboard/ai.md +3 -0
  5. package/prefabs/leaderboard/composite.json +4 -2
  6. package/prefabs/leaderboard/data.json +5 -1
  7. package/prefabs/leaderboard/scripts/leaderboard.ts +4 -3
  8. package/scene/about +1 -1
  9. package/scene/{bafkreifyskofqvjvp22m3eaxz2mpwibp7j4wtimdj5bxtqsd7onkbnjlsa → bafkreigk2a2bd5h73uubuzcqh4erz4s2p7cigdqp2qz4b47omhleeuvzfe} +1 -1
  10. package/scene/bafybeic3eddetvdagicmhn4f3le62bhbhpxzjqxooc6vooepeehsgu66q4 +90 -0
  11. package/{web-build → scene-compiler}/index.js +1 -1
  12. package/scene-compiler/sdk-snapshot.json +1 -0
  13. package/{web-build → scene-compiler}/worker.js +1 -1
  14. package/sounds/click.mp3 +0 -0
  15. package/sounds/close.mp3 +0 -0
  16. package/sounds/coin.mp3 +0 -0
  17. package/sounds/countdown-tick.mp3 +0 -0
  18. package/sounds/door-close.mp3 +0 -0
  19. package/sounds/door-open.mp3 +0 -0
  20. package/sounds/error.mp3 +0 -0
  21. package/sounds/explosion.mp3 +0 -0
  22. package/sounds/fire-loop.mp3 +0 -0
  23. package/sounds/gem.mp3 +0 -0
  24. package/sounds/hit.mp3 +0 -0
  25. package/sounds/jump.mp3 +0 -0
  26. package/sounds/land.mp3 +0 -0
  27. package/sounds/lever.mp3 +0 -0
  28. package/sounds/lose.mp3 +0 -0
  29. package/sounds/machine-loop.mp3 +0 -0
  30. package/sounds/open.mp3 +0 -0
  31. package/sounds/point.mp3 +0 -0
  32. package/sounds/power-up.mp3 +0 -0
  33. package/sounds/rumble-loop.mp3 +0 -0
  34. package/sounds/splat.mp3 +0 -0
  35. package/sounds/start.mp3 +0 -0
  36. package/sounds/teleport.mp3 +0 -0
  37. package/sounds/time-up.mp3 +0 -0
  38. package/sounds/win.mp3 +0 -0
  39. package/three/worker.js +163 -163
  40. package/scene/bafybeiblcndgruoz3ewqrheei4moyeoehankul4yd43co33djksumfd3se +0 -90
  41. package/web-build/sdk-snapshot.json +0 -1
  42. /package/{web-build → scene-compiler}/esbuild.wasm +0 -0
@@ -701,4 +701,4 @@ module.exports = require('./index')
701
701
  `)).replace(i.scriptsArray,()=>n.size===0?"[]":`[
702
702
  ${t.join(`,
703
703
  `)}
704
- ]`)}function w3(e,n){return e.map(o=>({severity:n,message:o.text,file:o.location?.file,line:o.location?.line,column:o.location?.column,lineText:o.location?.lineText,...$t(o.detail)&&typeof o.detail.missingPackage=="string"?{missingPackage:o.detail.missingPackage}:{}}))}var Bte=e=>e instanceof Error&&"errors"in e&&Array.isArray(e.errors);function Ute(e,n,o){let t=`Could not resolve "${e}"`;if(!Um(e)||e.startsWith("#"))return{text:t};let i=n.lastIndexOf("/node_modules/"),r=i===-1?"":` (imported by ${Dm(n.slice(i+14))})`;if(uI(e))return{text:`${t}: it is a Node built-in, which a scene does not have${r}`};let c=Dm(e);return o.isDir(ot(kt,"node_modules/"+c))?{text:`${t}: the package "${c}" has no module there${r}`}:{text:`${t}: the package "${c}" is not installed${r}`,detail:{missingPackage:c}}}var $m=class{constructor(n,o){this.esbuild=n;this.snapshot=o;this.contextKey=""}setPackages(n){this.packages=n}async build(n,o){let t=o.production===!0,i=Wl(n,"scene.json");if(i===void 0)return Gl("scene.json is missing or is not valid JSON");let r=i.main;if(typeof r!="string"||r==="")return Gl('scene.json needs a "main" entry, the path of the built bundle');if(i.runtimeVersion!=="7")return Gl('scene.json needs "runtimeVersion": "7"');if(!n.has("tsconfig.json"))return Gl("tsconfig.json is missing");if(!n.has(Lm))return Gl(`${Lm} is missing`);let c=[],{meta:s}=this.snapshot,a=pI(this.snapshot,n,this.packages),u=a.dependencies["@dcl/sdk"];typeof u=="string"&&/^\d/.test(u)&&u!==s.sdkVersion&&c.push({severity:"warning",file:"package.json",message:`This project pins @dcl/sdk ${u}; it is built here with ${s.sdkVersion}.`});let d=sI(n);c.push(...d.diagnostics);let p=cI(n);p&&!a.ownAssetPacks&&c.push({severity:"warning",message:"This scene uses smart items but ships no @dcl/asset-packs; they are built as no-ops."}),this.inputs={vfs:a.vfs,resolver:a.resolver,virtualModules:{"sdk-composite":`export const compositeFromLoader = {${d.compositeLines.join(",")}}`,"sdk-scripts":Ite(this.snapshot,d.scripts)}};let f={bundle:!0,platform:"browser",format:"cjs",write:!1,outfile:ot(kt,r),sourcemap:t?!1:"inline",minify:t,minifyIdentifiers:t,minifySyntax:t,minifyWhitespace:t,treeShaking:!0,absWorkingDir:kt,target:"es2020",sourceRoot:"dcl://"+(t?"/":Fn("/"+r)),define:{document:"undefined",window:"undefined",DEBUG:t?"false":"true","globalThis.DEBUG":t?"false":"true","process.env.NODE_ENV":JSON.stringify(t?"production":"development"),DCL_MAX_COMPOSITE_ENTITY:String(d.maxCompositeEntity)},tsconfigRaw:JSON.stringify({compilerOptions:fI(a.tsconfig.compilerOptions)}),supported:{"import-assertions":!1,"import-meta":!1,"dynamic-import":!1,hashbang:!1},logOverride:{"import-is-undefined":"silent"},logLevel:"silent",stdin:{contents:(p?s.entrypoint.editorScene:s.entrypoint.scene).split(JSON.stringify(s.placeholders.entrypoint)).join(JSON.stringify(ot(kt,Lm))),resolveDir:ot(kt,Fn(Lm)),sourcefile:"index.ts.entry-point.ts",loader:"ts"}};try{let g=await(await this.contextFor(f)).rebuild();c.push(...w3(g.warnings,"warning"));let m=g.outputFiles?.[0];if(m===void 0)return{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:"The bundler produced no output"};let y=new Map([[r,m.contents]]);return d.crdt!==void 0&&y.set("main.crdt",d.crdt),{outputs:y,bundleFile:r,diagnostics:c,failure:void 0}}catch(h){if(!Bte(h))throw h;return c.push(...w3(h.errors,"error"),...w3(h.warnings,"warning")),{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:h.message}}}async contextFor(n){let o=JSON.stringify(n);return this.context!==void 0&&o===this.contextKey?this.context:(await this.context?.dispose(),this.context=await this.esbuild.context({...n,plugins:[this.plugin()]}),this.contextKey=o,this.context)}plugin(){let n=()=>{if(this.inputs===void 0)throw new Error("no build in progress");return this.inputs};return{name:"in-memory-scene",setup:o=>{o.onResolve({filter:/~sdk\/all-composites/},()=>({namespace:"sdk-composite",path:"all-composites"})),o.onResolve({filter:/~sdk\/script-utils/},()=>({namespace:"sdk-scripts",path:"script-utils"})),o.onLoad({filter:/.*/,namespace:"sdk-composite"},()=>({loader:"js",contents:n().virtualModules["sdk-composite"]})),o.onLoad({filter:/.*/,namespace:"sdk-scripts"},()=>({loader:"ts",contents:n().virtualModules["sdk-scripts"],resolveDir:kt})),o.onResolve({filter:/.*/},t=>{if(Mte.test(t.path))return{path:t.path,external:!0};let i=t.kind==="require-call"||t.kind==="require-resolve"?"require":"import",r=n().resolver.resolve(t.path,t.resolveDir||kt,i);return r.kind==="file"?{path:r.path,sideEffects:r.sideEffects}:r.kind==="disabled"?{path:r.path,namespace:"disabled"}:{errors:[Ute(t.path,t.importer,n().vfs)]}}),o.onLoad({filter:/.*/,namespace:"disabled"},()=>({loader:"js",contents:""})),o.onLoad({filter:/.*/,namespace:"file"},t=>{let i=n().vfs.read(t.path),r=Rte[Bc(t.path)];return i===void 0?{errors:[{text:`File not found: ${t.path}`}]}:r===void 0?{errors:[{text:`No loader is configured for "${Bc(t.path)}" files: ${t.path}`}]}:{contents:i,loader:r}})}}}};async function A3(e,n,o){let t;try{t=await fetch(e,n===void 0?{}:{integrity:n,mode:"cors"})}catch(i){if(n===void 0)throw i;let r=await fetch(e).then(c=>c.ok,()=>!1);throw new Error(r?`${o} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${o} could not be loaded (${e}). Check the connection and reload the page.`)}if(!t.ok)throw new Error(`${o} could not be loaded: ${t.status} ${e}`);return t}var Cc=(e,n=[])=>self.postMessage(e,n),Hl=e=>Cc({type:"event",event:e}),k3=e=>e instanceof Error?e.message:String(e);async function xte(e){let n=new Uint8Array(await crypto.subtle.digest("SHA-256",Jm(e)));return Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}function Dte(){let e=self.setTimeout.bind(self),n=[],o=new MessageChannel;o.port1.onmessage=()=>n.shift()?.();let t=(i,r,...c)=>typeof i!="function"||r!==void 0&&r>0?e(i,r,...c):(n.push(()=>i(...c)),o.port2.postMessage(null),0);self.setTimeout=t}async function Lte(e){Dte();let[n,o]=await Promise.all([A3(e.wasmUrl,e.integrity?.wasm,"web-build/esbuild.wasm"),A3(e.snapshotUrl,e.integrity?.snapshot,"web-build/sdk-snapshot.json")]),t=await WebAssembly.compile(await n.arrayBuffer()),[,i]=await Promise.all([as.initialize({wasmModule:t,worker:!1}),o.json()]);if(as.version!==i.meta.esbuildVersion)throw new Error(`bundler ${as.version} does not match the SDK's ${i.meta.esbuildVersion}`);let r={};for(let[c,{version:s}]of Object.entries(i.meta.provided))r[c]=s;return Cc({type:"ready",sdkVersion:i.meta.sdkVersion,esbuildVersion:as.version,provided:r}),{session:new $m(as,i),snapshotNames:new Set(Object.keys(r))}}var Rc,jm=Promise.resolve();async function $te(e){let{buildId:n}=e,o=performance.now(),t=()=>Math.round(performance.now()-o);Hl({type:"buildStarted",buildId:n});let i=new Map;try{if(Rc===void 0)throw new Error("build requested before init");let c=await(await Rc).session.build(new Map(e.files),e.options);Hl({type:"diagnostics",buildId:n,diagnostics:c.diagnostics});let s=c.bundleFile===void 0?void 0:c.outputs.get(c.bundleFile);c.failure!==void 0||c.bundleFile===void 0||s===void 0?Hl({type:"failed",buildId:n,message:c.failure??"The build produced no bundle"}):(i=c.outputs,Hl({type:"bundleSaved",buildId:n,file:c.bundleFile,hash:await xte(s),bytes:s.length,ms:t()}))}catch(c){Hl({type:"failed",buildId:n,message:k3(c)})}let r=[...i];Cc({type:"result",buildId:n,outputs:r,ms:t()},r.map(([,c])=>c.buffer))}async function jte(e){let{requestId:n}=e;try{if(Rc===void 0)throw new Error("packages sent before init");let{session:o,snapshotNames:t}=await Rc,i=e.lock===null?void 0:x3(e.lock,e.files,t);o.setPackages(i),Cc({type:"packagesSet",requestId:n,packages:i?.count??0,shadowed:i?.shadowed??[]})}catch(o){Cc({type:"packagesSet",requestId:n,error:k3(o),packages:0,shadowed:[]})}}self.onmessage=e=>{let n=e.data;n.type==="init"?(Rc=Lte(n),Rc.catch(o=>Cc({type:"initFailed",message:k3(o)}))):n.type==="packages"?jm=jm.then(()=>jte(n)):jm=jm.then(()=>$te(n))};})();
704
+ ]`)}function w3(e,n){return e.map(o=>({severity:n,message:o.text,file:o.location?.file,line:o.location?.line,column:o.location?.column,lineText:o.location?.lineText,...$t(o.detail)&&typeof o.detail.missingPackage=="string"?{missingPackage:o.detail.missingPackage}:{}}))}var Bte=e=>e instanceof Error&&"errors"in e&&Array.isArray(e.errors);function Ute(e,n,o){let t=`Could not resolve "${e}"`;if(!Um(e)||e.startsWith("#"))return{text:t};let i=n.lastIndexOf("/node_modules/"),r=i===-1?"":` (imported by ${Dm(n.slice(i+14))})`;if(uI(e))return{text:`${t}: it is a Node built-in, which a scene does not have${r}`};let c=Dm(e);return o.isDir(ot(kt,"node_modules/"+c))?{text:`${t}: the package "${c}" has no module there${r}`}:{text:`${t}: the package "${c}" is not installed${r}`,detail:{missingPackage:c}}}var $m=class{constructor(n,o){this.esbuild=n;this.snapshot=o;this.contextKey=""}setPackages(n){this.packages=n}async build(n,o){let t=o.production===!0,i=Wl(n,"scene.json");if(i===void 0)return Gl("scene.json is missing or is not valid JSON");let r=i.main;if(typeof r!="string"||r==="")return Gl('scene.json needs a "main" entry, the path of the built bundle');if(i.runtimeVersion!=="7")return Gl('scene.json needs "runtimeVersion": "7"');if(!n.has("tsconfig.json"))return Gl("tsconfig.json is missing");if(!n.has(Lm))return Gl(`${Lm} is missing`);let c=[],{meta:s}=this.snapshot,a=pI(this.snapshot,n,this.packages),u=a.dependencies["@dcl/sdk"];typeof u=="string"&&/^\d/.test(u)&&u!==s.sdkVersion&&c.push({severity:"warning",file:"package.json",message:`This project pins @dcl/sdk ${u}; it is built here with ${s.sdkVersion}.`});let d=sI(n);c.push(...d.diagnostics);let p=cI(n);p&&!a.ownAssetPacks&&c.push({severity:"warning",message:"This scene uses smart items but ships no @dcl/asset-packs; they are built as no-ops."}),this.inputs={vfs:a.vfs,resolver:a.resolver,virtualModules:{"sdk-composite":`export const compositeFromLoader = {${d.compositeLines.join(",")}}`,"sdk-scripts":Ite(this.snapshot,d.scripts)}};let f={bundle:!0,platform:"browser",format:"cjs",write:!1,outfile:ot(kt,r),sourcemap:t?!1:"inline",minify:t,minifyIdentifiers:t,minifySyntax:t,minifyWhitespace:t,treeShaking:!0,absWorkingDir:kt,target:"es2020",sourceRoot:"dcl://"+(t?"/":Fn("/"+r)),define:{document:"undefined",window:"undefined",DEBUG:t?"false":"true","globalThis.DEBUG":t?"false":"true","process.env.NODE_ENV":JSON.stringify(t?"production":"development"),DCL_MAX_COMPOSITE_ENTITY:String(d.maxCompositeEntity)},tsconfigRaw:JSON.stringify({compilerOptions:fI(a.tsconfig.compilerOptions)}),supported:{"import-assertions":!1,"import-meta":!1,"dynamic-import":!1,hashbang:!1},logOverride:{"import-is-undefined":"silent"},logLevel:"silent",stdin:{contents:(p?s.entrypoint.editorScene:s.entrypoint.scene).split(JSON.stringify(s.placeholders.entrypoint)).join(JSON.stringify(ot(kt,Lm))),resolveDir:ot(kt,Fn(Lm)),sourcefile:"index.ts.entry-point.ts",loader:"ts"}};try{let g=await(await this.contextFor(f)).rebuild();c.push(...w3(g.warnings,"warning"));let m=g.outputFiles?.[0];if(m===void 0)return{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:"The bundler produced no output"};let y=new Map([[r,m.contents]]);return d.crdt!==void 0&&y.set("main.crdt",d.crdt),{outputs:y,bundleFile:r,diagnostics:c,failure:void 0}}catch(h){if(!Bte(h))throw h;return c.push(...w3(h.errors,"error"),...w3(h.warnings,"warning")),{outputs:new Map,bundleFile:void 0,diagnostics:c,failure:h.message}}}async contextFor(n){let o=JSON.stringify(n);return this.context!==void 0&&o===this.contextKey?this.context:(await this.context?.dispose(),this.context=await this.esbuild.context({...n,plugins:[this.plugin()]}),this.contextKey=o,this.context)}plugin(){let n=()=>{if(this.inputs===void 0)throw new Error("no build in progress");return this.inputs};return{name:"in-memory-scene",setup:o=>{o.onResolve({filter:/~sdk\/all-composites/},()=>({namespace:"sdk-composite",path:"all-composites"})),o.onResolve({filter:/~sdk\/script-utils/},()=>({namespace:"sdk-scripts",path:"script-utils"})),o.onLoad({filter:/.*/,namespace:"sdk-composite"},()=>({loader:"js",contents:n().virtualModules["sdk-composite"]})),o.onLoad({filter:/.*/,namespace:"sdk-scripts"},()=>({loader:"ts",contents:n().virtualModules["sdk-scripts"],resolveDir:kt})),o.onResolve({filter:/.*/},t=>{if(Mte.test(t.path))return{path:t.path,external:!0};let i=t.kind==="require-call"||t.kind==="require-resolve"?"require":"import",r=n().resolver.resolve(t.path,t.resolveDir||kt,i);return r.kind==="file"?{path:r.path,sideEffects:r.sideEffects}:r.kind==="disabled"?{path:r.path,namespace:"disabled"}:{errors:[Ute(t.path,t.importer,n().vfs)]}}),o.onLoad({filter:/.*/,namespace:"disabled"},()=>({loader:"js",contents:""})),o.onLoad({filter:/.*/,namespace:"file"},t=>{let i=n().vfs.read(t.path),r=Rte[Bc(t.path)];return i===void 0?{errors:[{text:`File not found: ${t.path}`}]}:r===void 0?{errors:[{text:`No loader is configured for "${Bc(t.path)}" files: ${t.path}`}]}:{contents:i,loader:r}})}}}};async function A3(e,n,o){let t;try{t=await fetch(e,n===void 0?{}:{integrity:n,mode:"cors"})}catch(i){if(n===void 0)throw i;let r=await fetch(e).then(c=>c.ok,()=>!1);throw new Error(r?`${o} does not match the hash this editor was published with. The editor will not run it: reload the page, and if this persists the files you were served were altered.`:`${o} could not be loaded (${e}). Check the connection and reload the page.`)}if(!t.ok)throw new Error(`${o} could not be loaded: ${t.status} ${e}`);return t}var Cc=(e,n=[])=>self.postMessage(e,n),Hl=e=>Cc({type:"event",event:e}),k3=e=>e instanceof Error?e.message:String(e);async function xte(e){let n=new Uint8Array(await crypto.subtle.digest("SHA-256",Jm(e)));return Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}function Dte(){let e=self.setTimeout.bind(self),n=[],o=new MessageChannel;o.port1.onmessage=()=>n.shift()?.();let t=(i,r,...c)=>typeof i!="function"||r!==void 0&&r>0?e(i,r,...c):(n.push(()=>i(...c)),o.port2.postMessage(null),0);self.setTimeout=t}async function Lte(e){Dte();let[n,o]=await Promise.all([A3(e.wasmUrl,e.integrity?.wasm,"scene-compiler/esbuild.wasm"),A3(e.snapshotUrl,e.integrity?.snapshot,"scene-compiler/sdk-snapshot.json")]),t=await WebAssembly.compile(await n.arrayBuffer()),[,i]=await Promise.all([as.initialize({wasmModule:t,worker:!1}),o.json()]);if(as.version!==i.meta.esbuildVersion)throw new Error(`bundler ${as.version} does not match the SDK's ${i.meta.esbuildVersion}`);let r={};for(let[c,{version:s}]of Object.entries(i.meta.provided))r[c]=s;return Cc({type:"ready",sdkVersion:i.meta.sdkVersion,esbuildVersion:as.version,provided:r}),{session:new $m(as,i),snapshotNames:new Set(Object.keys(r))}}var Rc,jm=Promise.resolve();async function $te(e){let{buildId:n}=e,o=performance.now(),t=()=>Math.round(performance.now()-o);Hl({type:"buildStarted",buildId:n});let i=new Map;try{if(Rc===void 0)throw new Error("build requested before init");let c=await(await Rc).session.build(new Map(e.files),e.options);Hl({type:"diagnostics",buildId:n,diagnostics:c.diagnostics});let s=c.bundleFile===void 0?void 0:c.outputs.get(c.bundleFile);c.failure!==void 0||c.bundleFile===void 0||s===void 0?Hl({type:"failed",buildId:n,message:c.failure??"The build produced no bundle"}):(i=c.outputs,Hl({type:"bundleSaved",buildId:n,file:c.bundleFile,hash:await xte(s),bytes:s.length,ms:t()}))}catch(c){Hl({type:"failed",buildId:n,message:k3(c)})}let r=[...i];Cc({type:"result",buildId:n,outputs:r,ms:t()},r.map(([,c])=>c.buffer))}async function jte(e){let{requestId:n}=e;try{if(Rc===void 0)throw new Error("packages sent before init");let{session:o,snapshotNames:t}=await Rc,i=e.lock===null?void 0:x3(e.lock,e.files,t);o.setPackages(i),Cc({type:"packagesSet",requestId:n,packages:i?.count??0,shadowed:i?.shadowed??[]})}catch(o){Cc({type:"packagesSet",requestId:n,error:k3(o),packages:0,shadowed:[]})}}self.onmessage=e=>{let n=e.data;n.type==="init"?(Rc=Lte(n),Rc.catch(o=>Cc({type:"initFailed",message:k3(o)}))):n.type==="packages"?jm=jm.then(()=>jte(n)):jm=jm.then(()=>$te(n))};})();
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/sounds/gem.mp3 ADDED
Binary file
package/sounds/hit.mp3 ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/sounds/win.mp3 ADDED
Binary file