@quake2ts/engine 0.0.739 → 0.0.740

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.
@@ -608,7 +608,7 @@ void main() {
608
608
  `;)r++;return s()}let a=r;for(;r<n&&!/\s/.test(t[r])&&t[r]!=="}"&&t[r]!=="{";)r++;return t.substring(a,r)}}}for(;r<n;){let a=s();if(a===null)break;if(a==="{"){let o={};for(;;){let u=r,l=s();if(l==="}"||l===null)break;if(l==="{"){r=u;break}let c=s();if(c===null||c==="}"||c==="{"){c==="}"&&r--,c==="{"&&r--;break}o[l]=c}e.push({classname:o.classname,properties:o})}}return e}function Wh(t){let e="";for(let r of t){e+=`{
609
609
  `;let i=Object.keys(r.properties).sort((s,a)=>s==="classname"?-1:a==="classname"?1:s==="origin"?-1:a==="origin"?1:s.localeCompare(a));for(let s of i){let a=r.properties[s];e+=`"${s}" "${a}"
610
610
  `}e+=`}
611
- `}return e}function Xh(t){let e=[],r=[];if(t.properties.classname||e.push('Missing "classname" property'),t.properties.origin){let n=t.properties.origin.split(" ");(n.length!==3||n.some(i=>isNaN(parseFloat(i))))&&e.push(`Invalid origin format: "${t.properties.origin}"`)}return t.properties.angle&&isNaN(parseFloat(t.properties.angle))&&e.push(`Invalid angle format: "${t.properties.angle}"`),{valid:e.length===0,errors:e,warnings:r}}async function Kh(t,e){if(!navigator.gpu)throw new Error("WebGPU is not supported in this environment");let r=await navigator.gpu.requestAdapter({powerPreference:e?.powerPreference||"high-performance"});if(!r)throw new Error("No appropriate GPUAdapter found");if(e?.requiredFeatures){for(let f of e.requiredFeatures)if(!r.features.has(f))throw new Error(`Required feature not available: ${f}`)}let n={requiredFeatures:e?.requiredFeatures,requiredLimits:e?.requiredLimits},i=await r.requestDevice(n),s,a="bgra8unorm",o=!0,u=0,l=0;if(t){if(s=t.getContext("webgpu"),!s)throw new Error("Failed to get WebGPU context from canvas");o=!1,a=navigator.gpu.getPreferredCanvasFormat(),u=t.width,l=t.height,s.configure({device:i,format:a,alphaMode:"opaque"})}else u=800,l=600;let c=new Set;for(let f of r.features)c.add(f);return{adapter:r,device:i,context:s,format:a,features:c,limits:i.limits,isHeadless:o,width:u,height:l}}function $h(t){let{features:e,limits:r}=t;return{hasTimestampQuery:e.has("timestamp-query"),hasDepthClipControl:e.has("depth-clip-control"),hasTextureCompressionBC:e.has("texture-compression-bc"),hasTextureCompressionETC2:e.has("texture-compression-etc2"),hasTextureCompressionASTC:e.has("texture-compression-astc"),maxTextureDimension2D:r.maxTextureDimension2D,maxBindGroups:r.maxBindGroups,maxUniformBufferBindingSize:r.maxUniformBufferBindingSize,maxStorageBufferBindingSize:r.maxStorageBufferBindingSize}}function Zh(t,e,r,n="rgba8unorm"){let i=typeof GPUTextureUsage<"u"?GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC:17,s=t.createTexture({size:{width:e,height:r,depthOrArrayLayers:1},format:n,usage:i}),a=s.createView();return{texture:s,view:a,width:e,height:r}}async function Yh(t,e){let r=e.width,n=e.height,i=4,s=r*i,a=256,o=Math.max(i*r,Math.ceil(r*i/a)*a),u=o*n,l=typeof GPUBufferUsage<"u"?GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ:9,c=t.createBuffer({size:u,usage:l}),f=t.createCommandEncoder();f.copyTextureToBuffer({texture:e},{buffer:c,bytesPerRow:o},{width:r,height:n,depthOrArrayLayers:1}),t.queue.submit([f.finish()]);let d=typeof GPUMapMode<"u"?GPUMapMode.READ:1;await c.mapAsync(d);let h=c.getMappedRange(),m=new Uint8Array(h),g=new Uint8ClampedArray(r*n*4);if(o===s)g.set(m);else for(let p=0;p<n;p++){let y=p*o,v=p*s;g.set(m.subarray(y,y+s),v)}return c.unmap(),g}var eu=(a=>(a[a.Disconnected=0]="Disconnected",a[a.Connecting=1]="Connecting",a[a.Challenge=2]="Challenge",a[a.Connected=3]="Connected",a[a.Loading=4]="Loading",a[a.Active=5]="Active",a))(eu||{}),qo=class{constructor(e){this.state=0;this.parser=null;this.listeners={};this.serverProtocol=0;this.serverCount=0;this.gameDir="";this.playerNum=0;this.levelName="";this.configStrings=new Map;this.baselines=new Map;this.entities=new Map;this.latestServerFrame=0;this.frameCRCs=new Map;this.currentPacketCRC=0;this.commandHistory=[];this.options=e,this.netchan=e.netchan??new Au}on(e,r){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(r)}off(e,r){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter(n=>n!==r))}emit(e,...r){this.listeners[e]&&this.listeners[e].forEach(n=>n(...r))}connect(){this.netchan.reset(),this.cleanup(),this.setState(1)}startProtocol(){this.state!==1&&this.connect(),this.setState(2),this.sendChallenge()}disconnect(){this.state!==0&&(this.setState(0),this.emit("disconnect"),this.cleanup())}cleanup(){this.configStrings.clear(),this.baselines.clear(),this.entities.clear(),this.commandHistory=[],this.latestServerFrame=0,this.parser=null,this.frameCRCs.clear()}getState(){return this.state}setState(e){this.state!==e&&(this.state=e,this.emit("state",e))}handleMessage(e){let r=this.netchan.process(new Uint8Array(e));if(!r||r.byteLength===0)return;this.currentPacketCRC=Su(r);let n=new Kt(r.buffer);this.parser=new Ve(n,this),this.serverProtocol&&this.parser.setProtocolVersion(this.serverProtocol),this.parser.parseMessage()}sendUserCommand(e){if(this.state!==5)return;let r={...e,serverFrame:e.serverFrame??this.latestServerFrame};this.commandHistory.push(r),this.commandHistory.length>_u&&this.commandHistory.shift();let n=new Et;n.writeByte($r.move);let i=this.frameCRCs.get(this.latestServerFrame)||0;n.writeByte(i),n.writeLong(this.latestServerFrame),wu(n,r),this.transmit(n.getData())}transmit(e){let r=this.netchan.transmit(e);this.emit("send",r)}sendChallenge(){let e=new wi;e.writeByte($r.stringcmd),e.writeString("getchallenge"),this.transmit(e.getData())}sendConnect(e){let r=new wi;r.writeByte($r.stringcmd);let n=`\\name\\${this.options.username}\\model\\${this.options.model}\\skin\\${this.options.skin}\\hand\\${this.options.hand??0}\\fov\\${this.options.fov??90}`;r.writeString(`connect ${vr} ${e} ${n}`),this.transmit(r.getData())}sendNew(){let e=new wi;e.writeByte($r.stringcmd),e.writeString("new"),this.transmit(e.getData())}sendBegin(){let e=new wi;e.writeByte($r.stringcmd),e.writeString("begin"),this.transmit(e.getData())}onServerData(e,r,n,i,s,a){this.serverProtocol=e,this.serverCount=r,this.gameDir=i,this.playerNum=s,this.levelName=a,this.setState(3),this.emit("serverdata",{protocol:e,serverCount:r,gameDir:i,levelName:a}),this.sendNew(),this.setState(4)}onConfigString(e,r){this.configStrings.set(e,r)}onSpawnBaseline(e){this.baselines.set(e.number,e)}onStuffText(e){if(this.emit("stufftext",e),e.startsWith("precache")&&(this.sendBegin(),this.setState(5)),e.startsWith("challenge ")){let r=e.split(" ");if(r.length>1){let n=parseInt(r[1],10);this.sendConnect(n)}}}onFrame(e){e.serverFrame>this.latestServerFrame&&(this.latestServerFrame=e.serverFrame),this.frameCRCs.set(e.serverFrame,this.currentPacketCRC);let r=e.packetEntities;r.delta||this.entities.clear();for(let n of r.entities)this.entities.set(n.number,n);this.emit("frame",e)}onDisconnect(){this.disconnect()}onPrint(e,r){this.emit("print",r,e)}onCenterPrint(e){this.emit("centerprint",e)}onSound(e,r,n,i,s,a,o){this.emit("sound",{flags:e,soundNum:r,volume:n,attenuation:i,offset:s,ent:a,pos:o})}onTempEntity(e,r,n,i,s,a,o,u,l){this.emit("temp_entity",{type:e,pos:r,pos2:n,dir:i,cnt:s,color:a,ent:o})}onInventory(e){this.emit("inventory",e)}onMuzzleFlash(e,r){this.emit("muzzleflash",e,r)}onMuzzleFlash2(e,r){}onMuzzleFlash3(e,r){this.emit("muzzleflash",e,r)}onDownload(e,r,n){this.emit("download",e,r,n)}onReconnect(){}onLayout(e){}onSplitClient(e){}onConfigBlast(e,r){}onSpawnBaselineBlast(e){}onLevelRestart(){}onDamage(e){}onLocPrint(e,r,n){}onFog(e){}onWaitingForPlayers(e){}onBotChat(e){}onPoi(e,r){}onHelpPath(e){}onAchievement(e){}};function yx(t){return{init(){t.trace({x:0,y:0,z:0},{x:0,y:0,z:0})},shutdown(){},createMainLoop(e,r){return new Xr(e,r)},setAreaPortalState(e,r){t.renderer&&t.renderer.setAreaPortalState&&t.renderer.setAreaPortalState(e,r)}}}return sm(bx);})();
611
+ `}return e}function Xh(t){let e=[],r=[];if(t.properties.classname||e.push('Missing "classname" property'),t.properties.origin){let n=t.properties.origin.split(" ");(n.length!==3||n.some(i=>isNaN(parseFloat(i))))&&e.push(`Invalid origin format: "${t.properties.origin}"`)}return t.properties.angle&&isNaN(parseFloat(t.properties.angle))&&e.push(`Invalid angle format: "${t.properties.angle}"`),{valid:e.length===0,errors:e,warnings:r}}async function Kh(t,e){if(!navigator.gpu)throw new Error("WebGPU is not supported in this environment");let r=await navigator.gpu.requestAdapter({powerPreference:e?.powerPreference||"high-performance"});if(!r)throw new Error("No appropriate GPUAdapter found");if(e?.requiredFeatures){for(let f of e.requiredFeatures)if(!r.features.has(f))throw new Error(`Required feature not available: ${f}`)}let n={requiredFeatures:e?.requiredFeatures,requiredLimits:e?.requiredLimits},i=await r.requestDevice(n),s,a="rgba8unorm",o=!0,u=0,l=0;if(t){if(s=t.getContext("webgpu"),!s)throw new Error("Failed to get WebGPU context from canvas");o=!1,a=navigator.gpu.getPreferredCanvasFormat(),u=t.width,l=t.height,s.configure({device:i,format:a,alphaMode:"opaque"})}else u=800,l=600;let c=new Set;for(let f of r.features)c.add(f);return{adapter:r,device:i,context:s,format:a,features:c,limits:i.limits,isHeadless:o,width:u,height:l}}function $h(t){let{features:e,limits:r}=t;return{hasTimestampQuery:e.has("timestamp-query"),hasDepthClipControl:e.has("depth-clip-control"),hasTextureCompressionBC:e.has("texture-compression-bc"),hasTextureCompressionETC2:e.has("texture-compression-etc2"),hasTextureCompressionASTC:e.has("texture-compression-astc"),maxTextureDimension2D:r.maxTextureDimension2D,maxBindGroups:r.maxBindGroups,maxUniformBufferBindingSize:r.maxUniformBufferBindingSize,maxStorageBufferBindingSize:r.maxStorageBufferBindingSize}}function Zh(t,e,r,n="rgba8unorm"){let i=typeof GPUTextureUsage<"u"?GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC:17,s=t.createTexture({size:{width:e,height:r,depthOrArrayLayers:1},format:n,usage:i}),a=s.createView();return{texture:s,view:a,width:e,height:r}}async function Yh(t,e){let r=e.width,n=e.height,i=4,s=r*i,a=256,o=Math.max(i*r,Math.ceil(r*i/a)*a),u=o*n,l=typeof GPUBufferUsage<"u"?GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ:9,c=t.createBuffer({size:u,usage:l}),f=t.createCommandEncoder();f.copyTextureToBuffer({texture:e},{buffer:c,bytesPerRow:o},{width:r,height:n,depthOrArrayLayers:1}),t.queue.submit([f.finish()]);let d=typeof GPUMapMode<"u"?GPUMapMode.READ:1;await c.mapAsync(d);let h=c.getMappedRange(),m=new Uint8Array(h),g=new Uint8ClampedArray(r*n*4);if(o===s)g.set(m);else for(let p=0;p<n;p++){let y=p*o,v=p*s;g.set(m.subarray(y,y+s),v)}return c.unmap(),g}var eu=(a=>(a[a.Disconnected=0]="Disconnected",a[a.Connecting=1]="Connecting",a[a.Challenge=2]="Challenge",a[a.Connected=3]="Connected",a[a.Loading=4]="Loading",a[a.Active=5]="Active",a))(eu||{}),qo=class{constructor(e){this.state=0;this.parser=null;this.listeners={};this.serverProtocol=0;this.serverCount=0;this.gameDir="";this.playerNum=0;this.levelName="";this.configStrings=new Map;this.baselines=new Map;this.entities=new Map;this.latestServerFrame=0;this.frameCRCs=new Map;this.currentPacketCRC=0;this.commandHistory=[];this.options=e,this.netchan=e.netchan??new Au}on(e,r){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(r)}off(e,r){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter(n=>n!==r))}emit(e,...r){this.listeners[e]&&this.listeners[e].forEach(n=>n(...r))}connect(){this.netchan.reset(),this.cleanup(),this.setState(1)}startProtocol(){this.state!==1&&this.connect(),this.setState(2),this.sendChallenge()}disconnect(){this.state!==0&&(this.setState(0),this.emit("disconnect"),this.cleanup())}cleanup(){this.configStrings.clear(),this.baselines.clear(),this.entities.clear(),this.commandHistory=[],this.latestServerFrame=0,this.parser=null,this.frameCRCs.clear()}getState(){return this.state}setState(e){this.state!==e&&(this.state=e,this.emit("state",e))}handleMessage(e){let r=this.netchan.process(new Uint8Array(e));if(!r||r.byteLength===0)return;this.currentPacketCRC=Su(r);let n=new Kt(r.buffer);this.parser=new Ve(n,this),this.serverProtocol&&this.parser.setProtocolVersion(this.serverProtocol),this.parser.parseMessage()}sendUserCommand(e){if(this.state!==5)return;let r={...e,serverFrame:e.serverFrame??this.latestServerFrame};this.commandHistory.push(r),this.commandHistory.length>_u&&this.commandHistory.shift();let n=new Et;n.writeByte($r.move);let i=this.frameCRCs.get(this.latestServerFrame)||0;n.writeByte(i),n.writeLong(this.latestServerFrame),wu(n,r),this.transmit(n.getData())}transmit(e){let r=this.netchan.transmit(e);this.emit("send",r)}sendChallenge(){let e=new wi;e.writeByte($r.stringcmd),e.writeString("getchallenge"),this.transmit(e.getData())}sendConnect(e){let r=new wi;r.writeByte($r.stringcmd);let n=`\\name\\${this.options.username}\\model\\${this.options.model}\\skin\\${this.options.skin}\\hand\\${this.options.hand??0}\\fov\\${this.options.fov??90}`;r.writeString(`connect ${vr} ${e} ${n}`),this.transmit(r.getData())}sendNew(){let e=new wi;e.writeByte($r.stringcmd),e.writeString("new"),this.transmit(e.getData())}sendBegin(){let e=new wi;e.writeByte($r.stringcmd),e.writeString("begin"),this.transmit(e.getData())}onServerData(e,r,n,i,s,a){this.serverProtocol=e,this.serverCount=r,this.gameDir=i,this.playerNum=s,this.levelName=a,this.setState(3),this.emit("serverdata",{protocol:e,serverCount:r,gameDir:i,levelName:a}),this.sendNew(),this.setState(4)}onConfigString(e,r){this.configStrings.set(e,r)}onSpawnBaseline(e){this.baselines.set(e.number,e)}onStuffText(e){if(this.emit("stufftext",e),e.startsWith("precache")&&(this.sendBegin(),this.setState(5)),e.startsWith("challenge ")){let r=e.split(" ");if(r.length>1){let n=parseInt(r[1],10);this.sendConnect(n)}}}onFrame(e){e.serverFrame>this.latestServerFrame&&(this.latestServerFrame=e.serverFrame),this.frameCRCs.set(e.serverFrame,this.currentPacketCRC);let r=e.packetEntities;r.delta||this.entities.clear();for(let n of r.entities)this.entities.set(n.number,n);this.emit("frame",e)}onDisconnect(){this.disconnect()}onPrint(e,r){this.emit("print",r,e)}onCenterPrint(e){this.emit("centerprint",e)}onSound(e,r,n,i,s,a,o){this.emit("sound",{flags:e,soundNum:r,volume:n,attenuation:i,offset:s,ent:a,pos:o})}onTempEntity(e,r,n,i,s,a,o,u,l){this.emit("temp_entity",{type:e,pos:r,pos2:n,dir:i,cnt:s,color:a,ent:o})}onInventory(e){this.emit("inventory",e)}onMuzzleFlash(e,r){this.emit("muzzleflash",e,r)}onMuzzleFlash2(e,r){}onMuzzleFlash3(e,r){this.emit("muzzleflash",e,r)}onDownload(e,r,n){this.emit("download",e,r,n)}onReconnect(){}onLayout(e){}onSplitClient(e){}onConfigBlast(e,r){}onSpawnBaselineBlast(e){}onLevelRestart(){}onDamage(e){}onLocPrint(e,r,n){}onFog(e){}onWaitingForPlayers(e){}onBotChat(e){}onPoi(e,r){}onHelpPath(e){}onAchievement(e){}};function yx(t){return{init(){t.trace({x:0,y:0,z:0},{x:0,y:0,z:0})},shutdown(){},createMainLoop(e,r){return new Xr(e,r)},setAreaPortalState(e,r){t.renderer&&t.renderer.setAreaPortalState&&t.renderer.setAreaPortalState(e,r)}}}return sm(bx);})();
612
612
  /*! Bundled license information:
613
613
 
614
614
  pako/dist/pako.esm.mjs: