hytopia 0.6.13 → 0.6.14

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/node-server.mjs CHANGED
@@ -367,7 +367,7 @@ ${G}${I8.bold}==========[ RUNTIME ${W?"WARNING":"ERROR"} #${V} | ${K} ]=========
367
367
  `);else console.log("The server encountered a recoverable error and did not crash."),console.log(`You should fix this to prevent undefined-like return values and unexpected behavior.
368
368
  `);let F=Q?"FATAL ERROR":W?"WARNING":"ERROR";if(H(`${G}${I8.bold}⚠️ ${F}:${I8.reset} ${I8.bold}${J}${I8.reset}`),Y)H(`${I8.cyan}ℹ️ CONTEXT:${I8.reset} ${Y}`);let z=X.stack?.split(`
369
369
  `)??[];if(z.length>1)H(`${I8.cyan}\uD83D\uDD0D STACK TRACE:${I8.reset}`),z.slice(1).forEach((q)=>{let L=q.trim().replace(/at\s+([^\s]+)/,`at ${I8.green}$1${I8.reset}`).replace(/\(([^:]+):(\d+):(\d+)\)/,`(${I8.cyan}$1${I8.reset}:${I8.yellow}$2:$3${I8.reset})`);H(` ${L}`)});console.log(`${G}${I8.bold}=================================================${I8.reset}
370
- `)}}var sy=r(ay(),1);var oy=sy.default;class j0{static globalInstance=new j0;_emitter=new oy;_finalListeners={};emit(Z,J){let X=!1;try{if(X=this._emitter.emit(Z,J),Z in this._finalListeners)this._finalListeners[Z](J),X=!0}catch(Y){console.error(`EventRouter.emit(): Error emitting event "${Z}":`,Y)}return X}emitWithGlobal(Z,J){this.emit(Z,J),j0.globalInstance.emit(Z,J)}emitWithWorld(Z,J,X){this.emit(J,X),Z.emit(J,X)}final(Z,J){if(this._finalListeners[Z]&&J!==this._finalListeners[Z])return u.error(`EventRouter.final(): Listener for event type "${Z}" already exists. It must be removed explicitly with .off() before a different final listener can be set.`);this._finalListeners[Z]=J}hasListeners(Z){return this._emitter.listenerCount(Z)>0}listeners(Z){return[...this._emitter.listeners(Z),...this._finalListeners[Z]?[this._finalListeners[Z]]:[]]}listenerCount(Z){return this._emitter.listenerCount(Z)+(this._finalListeners[Z]?1:0)}off(Z,J){if(this._emitter.removeListener(Z,J),this._finalListeners[Z]===J)delete this._finalListeners[Z]}offAll(Z){if(this._emitter.removeAllListeners(Z),Z)delete this._finalListeners[Z];else this._finalListeners={}}on(Z,J){this._emitter.addListener(Z,J)}once(Z,J){this._emitter.once(Z,J)}}class p0{static serializeAudio(Z){if(Z.id===void 0)u.fatalError(`Serializer.serializeAudio(): Audio ${Z.uri} is not playing!`);if(Z.attachedToEntity&&!Z.attachedToEntity.isSpawned)u.warning(`Serializer.serializeAudio(): Audio ${Z.uri} is attached to an entity that is not spawned or was recently despawned, reverting to unattached!`);return{i:Z.id,a:Z.uri,cd:Z.cutoffDistance,d:Z.duration,de:Z.detune,di:Z.distortion,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,l:Z.loop,o:Z.offset,p:Z.position?this.serializeVector(Z.position):void 0,pa:!Z.isPlaying,pl:Z.isPlaying,pr:Z.playbackRate,rd:Z.referenceDistance,s:Z.startTick,v:Z.volume}}static serializeBlockType(Z){return{i:Z.id,l:Z.isLiquid,n:Z.name,t:Z.textureUri}}static serializeBlockTypeRegistry(Z){return Z.getAllBlockTypes().map((J)=>this.serializeBlockType(J))}static serializeChunk(Z){if(!Z.world||!Z.originCoordinate)u.fatalError("Serializer.serializeChunk(): Chunk is not in a world");return{c:this.serializeVector(Z.originCoordinate),b:Array.from(Z.blocks)}}static serializeEntity(Z){if(!Z.world||Z.id===void 0)u.fatalError("Serializer.serializeEntity(): Entity is not in a world");return{i:Z.id,al:Array.from(Z.modelLoopedAnimations),ap:Z.modelAnimationsPlaybackRate,bt:Z.blockTextureUri,bh:Z.blockHalfExtents?this.serializeVector(Z.blockHalfExtents):void 0,h:Array.from(Z.modelHiddenNodes),m:Z.modelUri,mt:Z.modelTextureUri,n:Z.name,o:Z.opacity,p:this.serializeVector(Z.position),pe:Z.parent?Z.parent.id:void 0,pn:Z.parentNodeName,r:this.serializeQuaternion(Z.rotation),s:Z.modelScale,sn:Array.from(Z.modelShownNodes),t:Z.tintColor?this.serializeRgbColor(Z.tintColor):void 0}}static serializeLight(Z){if(!Z.world||Z.id===void 0)u.fatalError("Serializer.serializeLight(): Light is not in a world");return{i:Z.id,a:Z.angle,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,c:this.serializeRgbColor(Z.color),d:Z.distance,n:Z.intensity,o:Z.offset?this.serializeVector(Z.offset):void 0,p:Z.position?this.serializeVector(Z.position):void 0,pe:Z.penumbra,t:Z.type,te:Z.trackedEntity?.isSpawned?Z.trackedEntity.id:void 0,tp:Z.trackedPosition?this.serializeVector(Z.trackedPosition):void 0}}static serializePhysicsDebugRaycast(Z){return{o:this.serializeVector(Z.origin),d:this.serializeVector(Z.direction),l:Z.length,h:Z.hit}}static serializePlayer(Z){return{i:Z.id,u:Z.username,p:Z.profilePictureUrl}}static serializePlayerCamera(Z){return{m:Z.mode,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,et:Z.trackedEntity?.isSpawned?Z.trackedEntity.id:void 0,fo:Z.filmOffset,ffo:Z.forwardOffset,fv:Z.fov,h:Array.from(Z.modelHiddenNodes),o:Z.offset?this.serializeVector(Z.offset):void 0,p:Z.attachedToPosition?this.serializeVector(Z.attachedToPosition):void 0,pt:Z.trackedPosition?this.serializeVector(Z.trackedPosition):void 0,s:Array.from(Z.modelShownNodes),sa:Z.shoulderAngle,z:Z.zoom}}static serializeQuaternion(Z){return[Z.x,Z.y,Z.z,Z.w]}static serializeRgbColor(Z){return[Z.r,Z.g,Z.b]}static serializeSceneUI(Z){if(Z.id===void 0)u.fatalError("Serializer.serializeSceneUI(): SceneUI is not loaded!");return{i:Z.id,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,o:Z.offset?this.serializeVector(Z.offset):void 0,p:Z.position?this.serializeVector(Z.position):void 0,s:Z.state,t:Z.templateId,v:Z.viewDistance}}static serializeVector(Z){return[Z.x,Z.y,Z.z]}static serializeVectorBoolean(Z){return[Z.x,Z.y,Z.z]}static serializeWorld(Z){return{i:Z.id,ac:this.serializeRgbColor(Z.ambientLightColor),ai:Z.ambientLightIntensity,dc:this.serializeRgbColor(Z.directionalLightColor),di:Z.directionalLightIntensity,dp:this.serializeVector(Z.directionalLightPosition),n:Z.name,s:Z.skyboxUri,si:Z.skyboxIntensity,t:Z.loop.timestepS}}}var ry=5,sR;((F)=>{F.PAUSE="AUDIO.PAUSE";F.PLAY="AUDIO.PLAY";F.PLAY_RESTART="AUDIO.PLAY_RESTART";F.SET_ATTACHED_TO_ENTITY="AUDIO.SET_ATTACHED_TO_ENTITY";F.SET_CUTOFF_DISTANCE="AUDIO.SET_CUTOFF_DISTANCE";F.SET_DETUNE="AUDIO.SET_DETUNE";F.SET_DISTORTION="AUDIO.SET_DISTORTION";F.SET_POSITION="AUDIO.SET_POSITION";F.SET_PLAYBACK_RATE="AUDIO.SET_PLAYBACK_RATE";F.SET_REFERENCE_DISTANCE="AUDIO.SET_REFERENCE_DISTANCE";F.SET_VOLUME="AUDIO.SET_VOLUME"})(sR||={});class mG extends j0{_id;_attachedToEntity;_cutoffDistance;_duration;_detune;_distortion;_loop;_offset;_position;_playbackRate;_playing;_referenceDistance;_startTick;_uri;_volume;_world;constructor(Z){super();this._attachedToEntity=Z.attachedToEntity,this._cutoffDistance=Z.cutoffDistance??(this.isPositional?(Z.referenceDistance??ry)+10:0),this._duration=Z.duration,this._detune=Z.detune??0,this._distortion=Z.distortion??0,this._loop=Z.loop??!1,this._offset=Z.offset??0,this._position=Z.position,this._playing=!1,this._playbackRate=Z.playbackRate??1,this._referenceDistance=Z.referenceDistance??(this.isPositional?ry:0),this._uri=Z.uri,this._volume=Z.volume??0.5}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get cutoffDistance(){return this._cutoffDistance}get duration(){return this._duration}get detune(){return this._detune}get distortion(){return this._distortion}get loop(){return this._loop}get offset(){return this._offset}get isLoaded(){return this._id!==void 0}get isPlaying(){return this._playing}get isPositional(){return this._attachedToEntity!==void 0||this._position!==void 0}get position(){return this._position}get playbackRate(){return this._playbackRate}get referenceDistance(){return this._referenceDistance}get startTick(){return this._startTick}get uri(){return this._uri}get volume(){return this._volume}get world(){return this._world}play(Z,J=!1){if(this.isPlaying&&!J)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return u.error(`Audio.play(): Attached entity ${this._attachedToEntity.id} is not spawned!`);let X=J&&this._id!==void 0?"AUDIO.PLAY_RESTART":"AUDIO.PLAY";this._id??=Z.audioManager.registerAudio(this),this._playing=!0,this._startTick=Z.loop.currentTick,this._world=this._world??Z,this.emitWithWorld(Z,X,{audio:this})}pause(){if(!this.isPlaying||!this._world)return;this._playing=!1,this.emitWithWorld(this._world,"AUDIO.PAUSE",{audio:this})}setAttachedToEntity(Z){if(!this._requirePositional())return;if(!Z.isSpawned)return u.error(`Audio.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_ATTACHED_TO_ENTITY",{audio:this,entity:Z})}setCutoffDistance(Z){if(!this._requirePositional())return;if(Z<=0||Z<this._referenceDistance)return u.error("Audio.setCutoffDistance(): Cutoff distance cannot be less than or equal to 0 or less than reference distance!");if(this._cutoffDistance===Z)return;if(this._cutoffDistance=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_CUTOFF_DISTANCE",{audio:this,cutoffDistance:Z})}setDetune(Z){if(this._detune===Z)return;if(this._detune=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_DETUNE",{audio:this,detune:Z})}setDistortion(Z){if(Z<0)return u.error("Distortion cannot be less than 0");if(this._distortion===Z)return;if(this._distortion=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_DISTORTION",{audio:this,distortion:Z})}setPosition(Z){if(!this._requirePositional())return;if(this._position===Z)return;if(this._attachedToEntity=void 0,this._position=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_POSITION",{audio:this,position:Z})}setPlaybackRate(Z){if(Z<=0)return u.error("Playback rate cannot be less than or equal to 0");if(this._playbackRate===Z)return;if(this._playbackRate=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_PLAYBACK_RATE",{audio:this,playbackRate:Z})}setReferenceDistance(Z){if(!this._requirePositional())return;if(Z<=0)return u.error("Reference distance cannot be less than or equal to 0");if(this._referenceDistance===Z)return;if(this._referenceDistance=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_REFERENCE_DISTANCE",{audio:this,referenceDistance:Z})}setVolume(Z){if(Z<0||Z>1)return u.error("Volume must be between 0 and 1");if(this._volume===Z)return;if(this._volume=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_VOLUME",{audio:this,volume:Z})}serialize(){return p0.serializeAudio(this)}_requirePositional(){if(!this.isPositional)u.error("Audio._requirePositional(): Audio is not positional. and therefor does not support the invoked method.");return this.isPositional}}class uG{_audios=new Map;_nextAudioId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}getAllAudios(){return Array.from(this._audios.values())}getAllEntityAttachedAudios(Z){return this.getAllAudios().filter((J)=>J.attachedToEntity===Z)}getAllLoopedAudios(){return this.getAllAudios().filter((Z)=>Z.loop)}getAllOneshotAudios(){return this.getAllAudios().filter((Z)=>!Z.loop)}registerAudio(Z){if(Z.id!==void 0)u.fatalError(`AudioManager.registerAudio(): Provided audio instance with uri ${Z.uri} is already assigned the id ${Z.id}!`);let J=this._nextAudioId;return this._audios.set(J,Z),this._nextAudioId++,J}unregisterAudio(Z){if(Z.id===void 0)return u.error(`AudioManager.unregisterAudio(): Provided audio instance with uri ${Z.uri} is not assigned an id!`);Z.pause(),this._audios.delete(Z.id)}unregisterEntityAttachedAudios(Z){this.getAllEntityAttachedAudios(Z).forEach((J)=>{this.unregisterAudio(J)})}}var ty;((K)=>{K.ATTACH="BASE_ENTITY_CONTROLLER.ATTACH";K.DESPAWN="BASE_ENTITY_CONTROLLER.DESPAWN";K.DETACH="BASE_ENTITY_CONTROLLER.DETACH";K.SPAWN="BASE_ENTITY_CONTROLLER.SPAWN";K.TICK="BASE_ENTITY_CONTROLLER.TICK";K.TICK_WITH_PLAYER_INPUT="BASE_ENTITY_CONTROLLER.TICK_WITH_PLAYER_INPUT"})(ty||={});class JY extends j0{attach(Z){this.emit("BASE_ENTITY_CONTROLLER.ATTACH",{entity:Z})}despawn(Z){this.emit("BASE_ENTITY_CONTROLLER.DESPAWN",{entity:Z})}detach(Z){this.emit("BASE_ENTITY_CONTROLLER.DETACH",{entity:Z})}spawn(Z){this.emit("BASE_ENTITY_CONTROLLER.SPAWN",{entity:Z})}tickWithPlayerInput(Z,J,X,Y){this.emit("BASE_ENTITY_CONTROLLER.TICK_WITH_PLAYER_INPUT",{entity:Z,input:J,cameraOrientation:X,deltaTimeMs:Y})}tick(Z,J){this.emit("BASE_ENTITY_CONTROLLER.TICK",{entity:Z,deltaTimeMs:J})}}class EQ{globalCoordinate;blockType;constructor(Z,J){this.globalCoordinate=Z,this.blockType=J}static fromGlobalCoordinate(Z,J){return new EQ(Z,J)}getNeighborGlobalCoordinateFromHitPoint(Z){let J={x:Z.x-(this.globalCoordinate.x+0.5),y:Z.y-(this.globalCoordinate.y+0.5),z:Z.z-(this.globalCoordinate.z+0.5)},X="x",Y=Math.abs(J.x);for(let[$,Q]of Object.entries(J))if(Math.abs(Q)>Y)X=$,Y=Math.abs(Q);return{x:this.globalCoordinate.x+(X==="x"?Math.sign(J.x):0),y:this.globalCoordinate.y+(X==="y"?Math.sign(J.y):0),z:this.globalCoordinate.z+(X==="z"?Math.sign(J.z):0)}}}var os=r(gQ(),1);var e8=r(gQ(),1);var OJ;((w)=>{w[w.BLOCK=1]="BLOCK";w[w.ENTITY=2]="ENTITY";w[w.ENTITY_SENSOR=4]="ENTITY_SENSOR";w[w.ENVIRONMENT_ENTITY=8]="ENVIRONMENT_ENTITY";w[w.PLAYER=16]="PLAYER";w[w.GROUP_1=32]="GROUP_1";w[w.GROUP_2=64]="GROUP_2";w[w.GROUP_3=128]="GROUP_3";w[w.GROUP_4=256]="GROUP_4";w[w.GROUP_5=512]="GROUP_5";w[w.GROUP_6=1024]="GROUP_6";w[w.GROUP_7=2048]="GROUP_7";w[w.GROUP_8=4096]="GROUP_8";w[w.GROUP_9=8192]="GROUP_9";w[w.GROUP_10=16384]="GROUP_10";w[w.GROUP_11=32768]="GROUP_11";w[w.ALL=65535]="ALL"})(OJ||={});class H4{static BELONGS_TO_SHIFT=16;static COLLIDES_WITH_MASK=65535;static buildRawCollisionGroups(Z){return this.combineGroups(Z.belongsTo)<<this.BELONGS_TO_SHIFT|this.combineGroups(Z.collidesWith)}static decodeRawCollisionGroups(Z){return{belongsTo:this.bitsToGroups(Z>>>this.BELONGS_TO_SHIFT),collidesWith:this.bitsToGroups(Z&this.COLLIDES_WITH_MASK)}}static decodeCollisionGroups(Z){return{belongsTo:Z.belongsTo.map((J)=>this.groupToName(J)),collidesWith:Z.collidesWith.map((J)=>this.groupToName(J))}}static isDefaultCollisionGroups(Z){return Z.belongsTo.includes(65535)&&Z.collidesWith.includes(65535)}static combineGroups(Z){return Z.reduce((J,X)=>J|X,0)}static bitsToGroups(Z){if(Z===65535)return[65535];return Object.values(OJ).filter((J)=>typeof J==="number"&&J!==65535&&(Z&J)!==0)}static groupToName(Z){let J=Object.entries(OJ).find(([X,Y])=>Y===Z);if(!J)u.fatalError(`CollisionGroupsBuilder.groupToName(): Unknown collision group: ${Z}`);return J[0]}}import IP1 from"crypto";import uJ from"fs";import o5 from"path";function B8(Z){if(typeof Z!=="object"||Z===null)return!1;let J=Object.getPrototypeOf(Z);return(J===null||J===Object.prototype||Object.getPrototypeOf(J)===null)&&!(Symbol.toStringTag in Z)&&!(Symbol.iterator in Z)}import{fileURLToPath as GG1}from"node:url";var mQ=(Z,J)=>{let X=EM(VG1(Z));if(typeof X!=="string")throw new TypeError(`${J} must be a string or a file URL: ${X}.`);return X},VG1=(Z)=>TM(Z)?Z.toString():Z,TM=(Z)=>typeof Z!=="string"&&Z&&Object.getPrototypeOf(Z)===String.prototype,EM=(Z)=>Z instanceof URL?GG1(Z):Z;var jU=(Z,J=[],X={})=>{let Y=mQ(Z,"First argument"),[$,Q]=B8(J)?[[],J]:[J,X];if(!Array.isArray($))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${$}`);if($.some((G)=>typeof G==="object"&&G!==null))throw new TypeError(`Second argument must be an array of strings: ${$}`);let K=$.map(String),W=K.find((G)=>G.includes("\x00"));if(W!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${W}`);if(!B8(Q))throw new TypeError(`Last argument must be an options object: ${Q}`);return[Y,K,Q]};import{ChildProcess as BG1}from"node:child_process";import{StringDecoder as HG1}from"node:string_decoder";var{toString:ub}=Object.prototype,db=(Z)=>ub.call(Z)==="[object ArrayBuffer]",b8=(Z)=>ub.call(Z)==="[object Uint8Array]",WZ=(Z)=>new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),zG1=new TextEncoder,cb=(Z)=>zG1.encode(Z),FG1=new TextDecoder,OU=(Z)=>FG1.decode(Z),lb=(Z,J)=>{return qG1(Z,J).join("")},qG1=(Z,J)=>{if(J==="utf8"&&Z.every((Q)=>typeof Q==="string"))return Z;let X=new HG1(J),Y=Z.map((Q)=>typeof Q==="string"?cb(Q):Q).map((Q)=>X.write(Q)),$=X.end();return $===""?Y:[...Y,$]},P3=(Z)=>{if(Z.length===1&&b8(Z[0]))return Z[0];return kM(UG1(Z))},UG1=(Z)=>Z.map((J)=>typeof J==="string"?cb(J):J),kM=(Z)=>{let J=new Uint8Array(LG1(Z)),X=0;for(let Y of Z)J.set(Y,X),X+=Y.length;return J},LG1=(Z)=>{let J=0;for(let X of Z)J+=X.length;return J};var ab=(Z)=>Array.isArray(Z)&&Array.isArray(Z.raw),sb=(Z,J)=>{let X=[];for(let[Q,K]of Z.entries())X=wG1({templates:Z,expressions:J,tokens:X,index:Q,template:K});if(X.length===0)throw new TypeError("Template script must not be empty");let[Y,...$]=X;return[Y,$,{}]},wG1=({templates:Z,expressions:J,tokens:X,index:Y,template:$})=>{if($===void 0)throw new TypeError(`Invalid backslash sequence: ${Z.raw[Y]}`);let{nextTokens:Q,leadingWhitespaces:K,trailingWhitespaces:W}=jG1($,Z.raw[Y]),G=ib(X,Q,K);if(Y===J.length)return G;let V=J[Y],H=Array.isArray(V)?V.map((F)=>nb(F)):[nb(V)];return ib(G,H,W)},jG1=(Z,J)=>{if(J.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let X=[],Y=0,$=pb.has(J[0]);for(let K=0,W=0;K<Z.length;K+=1,W+=1){let G=J[W];if(pb.has(G)){if(Y!==K)X.push(Z.slice(Y,K));Y=K+1}else if(G==="\\"){let V=J[W+1];if(V===`
370
+ `)}}var sy=r(ay(),1);var oy=sy.default;class j0{static globalInstance=new j0;_emitter=new oy;_finalListeners={};emit(Z,J){if(this.listenerCount(Z)===0)return!1;try{this._emitter.emit(Z,J),this._finalListeners[Z]?.(J)}catch(X){console.error(`EventRouter.emit(): Error emitting event "${Z}":`,X)}return!0}emitWithGlobal(Z,J){this.emit(Z,J),j0.globalInstance.emit(Z,J)}emitWithWorld(Z,J,X){this.emit(J,X),Z.emit(J,X)}final(Z,J){if(this._finalListeners[Z]&&J!==this._finalListeners[Z])return u.error(`EventRouter.final(): Listener for event type "${Z}" already exists. It must be removed explicitly with .off() before a different final listener can be set.`);this._finalListeners[Z]=J}hasListeners(Z){return this._emitter.listenerCount(Z)>0||Z in this._finalListeners}listeners(Z){return[...this._emitter.listeners(Z),...this._finalListeners[Z]?[this._finalListeners[Z]]:[]]}listenerCount(Z){return this._emitter.listenerCount(Z)+(this._finalListeners[Z]?1:0)}off(Z,J){if(this._emitter.removeListener(Z,J),this._finalListeners[Z]===J)delete this._finalListeners[Z]}offAll(Z){if(this._emitter.removeAllListeners(Z),Z)delete this._finalListeners[Z];else this._finalListeners={}}on(Z,J){this._emitter.addListener(Z,J)}once(Z,J){this._emitter.once(Z,J)}}class p0{static serializeAudio(Z){if(Z.id===void 0)u.fatalError(`Serializer.serializeAudio(): Audio ${Z.uri} is not playing!`);if(Z.attachedToEntity&&!Z.attachedToEntity.isSpawned)u.warning(`Serializer.serializeAudio(): Audio ${Z.uri} is attached to an entity that is not spawned or was recently despawned, reverting to unattached!`);return{i:Z.id,a:Z.uri,cd:Z.cutoffDistance,d:Z.duration,de:Z.detune,di:Z.distortion,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,l:Z.loop,o:Z.offset,p:Z.position?this.serializeVector(Z.position):void 0,pa:!Z.isPlaying,pl:Z.isPlaying,pr:Z.playbackRate,rd:Z.referenceDistance,s:Z.startTick,v:Z.volume}}static serializeBlockType(Z){return{i:Z.id,l:Z.isLiquid,n:Z.name,t:Z.textureUri}}static serializeBlockTypeRegistry(Z){return Z.getAllBlockTypes().map((J)=>this.serializeBlockType(J))}static serializeChunk(Z){if(!Z.world||!Z.originCoordinate)u.fatalError("Serializer.serializeChunk(): Chunk is not in a world");return{c:this.serializeVector(Z.originCoordinate),b:Array.from(Z.blocks)}}static serializeEntity(Z){if(!Z.world||Z.id===void 0)u.fatalError("Serializer.serializeEntity(): Entity is not in a world");return{i:Z.id,al:Array.from(Z.modelLoopedAnimations),ap:Z.modelAnimationsPlaybackRate,bt:Z.blockTextureUri,bh:Z.blockHalfExtents?this.serializeVector(Z.blockHalfExtents):void 0,h:Array.from(Z.modelHiddenNodes),m:Z.modelUri,mt:Z.modelTextureUri,n:Z.name,o:Z.opacity,p:this.serializeVector(Z.position),pe:Z.parent?Z.parent.id:void 0,pn:Z.parentNodeName,r:this.serializeQuaternion(Z.rotation),s:Z.modelScale,sn:Array.from(Z.modelShownNodes),t:Z.tintColor?this.serializeRgbColor(Z.tintColor):void 0}}static serializeLight(Z){if(!Z.world||Z.id===void 0)u.fatalError("Serializer.serializeLight(): Light is not in a world");return{i:Z.id,a:Z.angle,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,c:this.serializeRgbColor(Z.color),d:Z.distance,n:Z.intensity,o:Z.offset?this.serializeVector(Z.offset):void 0,p:Z.position?this.serializeVector(Z.position):void 0,pe:Z.penumbra,t:Z.type,te:Z.trackedEntity?.isSpawned?Z.trackedEntity.id:void 0,tp:Z.trackedPosition?this.serializeVector(Z.trackedPosition):void 0}}static serializePhysicsDebugRaycast(Z){return{o:this.serializeVector(Z.origin),d:this.serializeVector(Z.direction),l:Z.length,h:Z.hit}}static serializePlayer(Z){return{i:Z.id,u:Z.username,p:Z.profilePictureUrl}}static serializePlayerCamera(Z){return{m:Z.mode,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,et:Z.trackedEntity?.isSpawned?Z.trackedEntity.id:void 0,fo:Z.filmOffset,ffo:Z.forwardOffset,fv:Z.fov,h:Array.from(Z.modelHiddenNodes),o:Z.offset?this.serializeVector(Z.offset):void 0,p:Z.attachedToPosition?this.serializeVector(Z.attachedToPosition):void 0,pt:Z.trackedPosition?this.serializeVector(Z.trackedPosition):void 0,s:Array.from(Z.modelShownNodes),sa:Z.shoulderAngle,z:Z.zoom}}static serializeQuaternion(Z){return[Z.x,Z.y,Z.z,Z.w]}static serializeRgbColor(Z){return[Z.r,Z.g,Z.b]}static serializeSceneUI(Z){if(Z.id===void 0)u.fatalError("Serializer.serializeSceneUI(): SceneUI is not loaded!");return{i:Z.id,e:Z.attachedToEntity?.isSpawned?Z.attachedToEntity.id:void 0,o:Z.offset?this.serializeVector(Z.offset):void 0,p:Z.position?this.serializeVector(Z.position):void 0,s:Z.state,t:Z.templateId,v:Z.viewDistance}}static serializeVector(Z){return[Z.x,Z.y,Z.z]}static serializeVectorBoolean(Z){return[Z.x,Z.y,Z.z]}static serializeWorld(Z){return{i:Z.id,ac:this.serializeRgbColor(Z.ambientLightColor),ai:Z.ambientLightIntensity,dc:this.serializeRgbColor(Z.directionalLightColor),di:Z.directionalLightIntensity,dp:this.serializeVector(Z.directionalLightPosition),n:Z.name,s:Z.skyboxUri,si:Z.skyboxIntensity,t:Z.loop.timestepS}}}var ry=5,sR;((F)=>{F.PAUSE="AUDIO.PAUSE";F.PLAY="AUDIO.PLAY";F.PLAY_RESTART="AUDIO.PLAY_RESTART";F.SET_ATTACHED_TO_ENTITY="AUDIO.SET_ATTACHED_TO_ENTITY";F.SET_CUTOFF_DISTANCE="AUDIO.SET_CUTOFF_DISTANCE";F.SET_DETUNE="AUDIO.SET_DETUNE";F.SET_DISTORTION="AUDIO.SET_DISTORTION";F.SET_POSITION="AUDIO.SET_POSITION";F.SET_PLAYBACK_RATE="AUDIO.SET_PLAYBACK_RATE";F.SET_REFERENCE_DISTANCE="AUDIO.SET_REFERENCE_DISTANCE";F.SET_VOLUME="AUDIO.SET_VOLUME"})(sR||={});class mG extends j0{_id;_attachedToEntity;_cutoffDistance;_duration;_detune;_distortion;_loop;_offset;_position;_playbackRate;_playing;_referenceDistance;_startTick;_uri;_volume;_world;constructor(Z){super();this._attachedToEntity=Z.attachedToEntity,this._cutoffDistance=Z.cutoffDistance??(this.isPositional?(Z.referenceDistance??ry)+10:0),this._duration=Z.duration,this._detune=Z.detune??0,this._distortion=Z.distortion??0,this._loop=Z.loop??!1,this._offset=Z.offset??0,this._position=Z.position,this._playing=!1,this._playbackRate=Z.playbackRate??1,this._referenceDistance=Z.referenceDistance??(this.isPositional?ry:0),this._uri=Z.uri,this._volume=Z.volume??0.5}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get cutoffDistance(){return this._cutoffDistance}get duration(){return this._duration}get detune(){return this._detune}get distortion(){return this._distortion}get loop(){return this._loop}get offset(){return this._offset}get isLoaded(){return this._id!==void 0}get isPlaying(){return this._playing}get isPositional(){return this._attachedToEntity!==void 0||this._position!==void 0}get position(){return this._position}get playbackRate(){return this._playbackRate}get referenceDistance(){return this._referenceDistance}get startTick(){return this._startTick}get uri(){return this._uri}get volume(){return this._volume}get world(){return this._world}play(Z,J=!1){if(this.isPlaying&&!J)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return u.error(`Audio.play(): Attached entity ${this._attachedToEntity.id} is not spawned!`);let X=J&&this._id!==void 0?"AUDIO.PLAY_RESTART":"AUDIO.PLAY";this._id??=Z.audioManager.registerAudio(this),this._playing=!0,this._startTick=Z.loop.currentTick,this._world=this._world??Z,this.emitWithWorld(Z,X,{audio:this})}pause(){if(!this.isPlaying||!this._world)return;this._playing=!1,this.emitWithWorld(this._world,"AUDIO.PAUSE",{audio:this})}setAttachedToEntity(Z){if(!this._requirePositional())return;if(!Z.isSpawned)return u.error(`Audio.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_ATTACHED_TO_ENTITY",{audio:this,entity:Z})}setCutoffDistance(Z){if(!this._requirePositional())return;if(Z<=0||Z<this._referenceDistance)return u.error("Audio.setCutoffDistance(): Cutoff distance cannot be less than or equal to 0 or less than reference distance!");if(this._cutoffDistance===Z)return;if(this._cutoffDistance=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_CUTOFF_DISTANCE",{audio:this,cutoffDistance:Z})}setDetune(Z){if(this._detune===Z)return;if(this._detune=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_DETUNE",{audio:this,detune:Z})}setDistortion(Z){if(Z<0)return u.error("Distortion cannot be less than 0");if(this._distortion===Z)return;if(this._distortion=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_DISTORTION",{audio:this,distortion:Z})}setPosition(Z){if(!this._requirePositional())return;if(this._position===Z)return;if(this._attachedToEntity=void 0,this._position=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_POSITION",{audio:this,position:Z})}setPlaybackRate(Z){if(Z<=0)return u.error("Playback rate cannot be less than or equal to 0");if(this._playbackRate===Z)return;if(this._playbackRate=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_PLAYBACK_RATE",{audio:this,playbackRate:Z})}setReferenceDistance(Z){if(!this._requirePositional())return;if(Z<=0)return u.error("Reference distance cannot be less than or equal to 0");if(this._referenceDistance===Z)return;if(this._referenceDistance=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_REFERENCE_DISTANCE",{audio:this,referenceDistance:Z})}setVolume(Z){if(Z<0||Z>1)return u.error("Volume must be between 0 and 1");if(this._volume===Z)return;if(this._volume=Z,this.isLoaded&&this._world)this.emitWithWorld(this._world,"AUDIO.SET_VOLUME",{audio:this,volume:Z})}serialize(){return p0.serializeAudio(this)}_requirePositional(){if(!this.isPositional)u.error("Audio._requirePositional(): Audio is not positional. and therefor does not support the invoked method.");return this.isPositional}}class uG{_audios=new Map;_nextAudioId=1;_world;constructor(Z){this._world=Z}get world(){return this._world}getAllAudios(){return Array.from(this._audios.values())}getAllEntityAttachedAudios(Z){return this.getAllAudios().filter((J)=>J.attachedToEntity===Z)}getAllLoopedAudios(){return this.getAllAudios().filter((Z)=>Z.loop)}getAllOneshotAudios(){return this.getAllAudios().filter((Z)=>!Z.loop)}registerAudio(Z){if(Z.id!==void 0)u.fatalError(`AudioManager.registerAudio(): Provided audio instance with uri ${Z.uri} is already assigned the id ${Z.id}!`);let J=this._nextAudioId;return this._audios.set(J,Z),this._nextAudioId++,J}unregisterAudio(Z){if(Z.id===void 0)return u.error(`AudioManager.unregisterAudio(): Provided audio instance with uri ${Z.uri} is not assigned an id!`);Z.pause(),this._audios.delete(Z.id)}unregisterEntityAttachedAudios(Z){this.getAllEntityAttachedAudios(Z).forEach((J)=>{this.unregisterAudio(J)})}}var ty;((K)=>{K.ATTACH="BASE_ENTITY_CONTROLLER.ATTACH";K.DESPAWN="BASE_ENTITY_CONTROLLER.DESPAWN";K.DETACH="BASE_ENTITY_CONTROLLER.DETACH";K.SPAWN="BASE_ENTITY_CONTROLLER.SPAWN";K.TICK="BASE_ENTITY_CONTROLLER.TICK";K.TICK_WITH_PLAYER_INPUT="BASE_ENTITY_CONTROLLER.TICK_WITH_PLAYER_INPUT"})(ty||={});class JY extends j0{attach(Z){this.emit("BASE_ENTITY_CONTROLLER.ATTACH",{entity:Z})}despawn(Z){this.emit("BASE_ENTITY_CONTROLLER.DESPAWN",{entity:Z})}detach(Z){this.emit("BASE_ENTITY_CONTROLLER.DETACH",{entity:Z})}spawn(Z){this.emit("BASE_ENTITY_CONTROLLER.SPAWN",{entity:Z})}tickWithPlayerInput(Z,J,X,Y){this.emit("BASE_ENTITY_CONTROLLER.TICK_WITH_PLAYER_INPUT",{entity:Z,input:J,cameraOrientation:X,deltaTimeMs:Y})}tick(Z,J){this.emit("BASE_ENTITY_CONTROLLER.TICK",{entity:Z,deltaTimeMs:J})}}class EQ{globalCoordinate;blockType;constructor(Z,J){this.globalCoordinate=Z,this.blockType=J}static fromGlobalCoordinate(Z,J){return new EQ(Z,J)}getNeighborGlobalCoordinateFromHitPoint(Z){let J={x:Z.x-(this.globalCoordinate.x+0.5),y:Z.y-(this.globalCoordinate.y+0.5),z:Z.z-(this.globalCoordinate.z+0.5)},X="x",Y=Math.abs(J.x);for(let[$,Q]of Object.entries(J))if(Math.abs(Q)>Y)X=$,Y=Math.abs(Q);return{x:this.globalCoordinate.x+(X==="x"?Math.sign(J.x):0),y:this.globalCoordinate.y+(X==="y"?Math.sign(J.y):0),z:this.globalCoordinate.z+(X==="z"?Math.sign(J.z):0)}}}var os=r(gQ(),1);var e8=r(gQ(),1);var OJ;((w)=>{w[w.BLOCK=1]="BLOCK";w[w.ENTITY=2]="ENTITY";w[w.ENTITY_SENSOR=4]="ENTITY_SENSOR";w[w.ENVIRONMENT_ENTITY=8]="ENVIRONMENT_ENTITY";w[w.PLAYER=16]="PLAYER";w[w.GROUP_1=32]="GROUP_1";w[w.GROUP_2=64]="GROUP_2";w[w.GROUP_3=128]="GROUP_3";w[w.GROUP_4=256]="GROUP_4";w[w.GROUP_5=512]="GROUP_5";w[w.GROUP_6=1024]="GROUP_6";w[w.GROUP_7=2048]="GROUP_7";w[w.GROUP_8=4096]="GROUP_8";w[w.GROUP_9=8192]="GROUP_9";w[w.GROUP_10=16384]="GROUP_10";w[w.GROUP_11=32768]="GROUP_11";w[w.ALL=65535]="ALL"})(OJ||={});class H4{static BELONGS_TO_SHIFT=16;static COLLIDES_WITH_MASK=65535;static buildRawCollisionGroups(Z){return this.combineGroups(Z.belongsTo)<<this.BELONGS_TO_SHIFT|this.combineGroups(Z.collidesWith)}static decodeRawCollisionGroups(Z){return{belongsTo:this.bitsToGroups(Z>>>this.BELONGS_TO_SHIFT),collidesWith:this.bitsToGroups(Z&this.COLLIDES_WITH_MASK)}}static decodeCollisionGroups(Z){return{belongsTo:Z.belongsTo.map((J)=>this.groupToName(J)),collidesWith:Z.collidesWith.map((J)=>this.groupToName(J))}}static isDefaultCollisionGroups(Z){return Z.belongsTo.includes(65535)&&Z.collidesWith.includes(65535)}static combineGroups(Z){return Z.reduce((J,X)=>J|X,0)}static bitsToGroups(Z){if(Z===65535)return[65535];return Object.values(OJ).filter((J)=>typeof J==="number"&&J!==65535&&(Z&J)!==0)}static groupToName(Z){let J=Object.entries(OJ).find(([X,Y])=>Y===Z);if(!J)u.fatalError(`CollisionGroupsBuilder.groupToName(): Unknown collision group: ${Z}`);return J[0]}}import IP1 from"crypto";import uJ from"fs";import o5 from"path";function B8(Z){if(typeof Z!=="object"||Z===null)return!1;let J=Object.getPrototypeOf(Z);return(J===null||J===Object.prototype||Object.getPrototypeOf(J)===null)&&!(Symbol.toStringTag in Z)&&!(Symbol.iterator in Z)}import{fileURLToPath as GG1}from"node:url";var mQ=(Z,J)=>{let X=EM(VG1(Z));if(typeof X!=="string")throw new TypeError(`${J} must be a string or a file URL: ${X}.`);return X},VG1=(Z)=>TM(Z)?Z.toString():Z,TM=(Z)=>typeof Z!=="string"&&Z&&Object.getPrototypeOf(Z)===String.prototype,EM=(Z)=>Z instanceof URL?GG1(Z):Z;var jU=(Z,J=[],X={})=>{let Y=mQ(Z,"First argument"),[$,Q]=B8(J)?[[],J]:[J,X];if(!Array.isArray($))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${$}`);if($.some((G)=>typeof G==="object"&&G!==null))throw new TypeError(`Second argument must be an array of strings: ${$}`);let K=$.map(String),W=K.find((G)=>G.includes("\x00"));if(W!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${W}`);if(!B8(Q))throw new TypeError(`Last argument must be an options object: ${Q}`);return[Y,K,Q]};import{ChildProcess as BG1}from"node:child_process";import{StringDecoder as HG1}from"node:string_decoder";var{toString:ub}=Object.prototype,db=(Z)=>ub.call(Z)==="[object ArrayBuffer]",b8=(Z)=>ub.call(Z)==="[object Uint8Array]",WZ=(Z)=>new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),zG1=new TextEncoder,cb=(Z)=>zG1.encode(Z),FG1=new TextDecoder,OU=(Z)=>FG1.decode(Z),lb=(Z,J)=>{return qG1(Z,J).join("")},qG1=(Z,J)=>{if(J==="utf8"&&Z.every((Q)=>typeof Q==="string"))return Z;let X=new HG1(J),Y=Z.map((Q)=>typeof Q==="string"?cb(Q):Q).map((Q)=>X.write(Q)),$=X.end();return $===""?Y:[...Y,$]},P3=(Z)=>{if(Z.length===1&&b8(Z[0]))return Z[0];return kM(UG1(Z))},UG1=(Z)=>Z.map((J)=>typeof J==="string"?cb(J):J),kM=(Z)=>{let J=new Uint8Array(LG1(Z)),X=0;for(let Y of Z)J.set(Y,X),X+=Y.length;return J},LG1=(Z)=>{let J=0;for(let X of Z)J+=X.length;return J};var ab=(Z)=>Array.isArray(Z)&&Array.isArray(Z.raw),sb=(Z,J)=>{let X=[];for(let[Q,K]of Z.entries())X=wG1({templates:Z,expressions:J,tokens:X,index:Q,template:K});if(X.length===0)throw new TypeError("Template script must not be empty");let[Y,...$]=X;return[Y,$,{}]},wG1=({templates:Z,expressions:J,tokens:X,index:Y,template:$})=>{if($===void 0)throw new TypeError(`Invalid backslash sequence: ${Z.raw[Y]}`);let{nextTokens:Q,leadingWhitespaces:K,trailingWhitespaces:W}=jG1($,Z.raw[Y]),G=ib(X,Q,K);if(Y===J.length)return G;let V=J[Y],H=Array.isArray(V)?V.map((F)=>nb(F)):[nb(V)];return ib(G,H,W)},jG1=(Z,J)=>{if(J.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let X=[],Y=0,$=pb.has(J[0]);for(let K=0,W=0;K<Z.length;K+=1,W+=1){let G=J[W];if(pb.has(G)){if(Y!==K)X.push(Z.slice(Y,K));Y=K+1}else if(G==="\\"){let V=J[W+1];if(V===`
371
371
  `)K-=1,W+=1;else if(V==="u"&&J[W+2]==="{")W=J.indexOf("}",W+3);else W+=OG1[V]??1}}let Q=Y===Z.length;if(!Q)X.push(Z.slice(Y));return{nextTokens:X,leadingWhitespaces:$,trailingWhitespaces:Q}},pb=new Set([" ","\t","\r",`
372
372
  `]),OG1={x:3,u:5},ib=(Z,J,X)=>X||Z.length===0||J.length===0?[...Z,...J]:[...Z.slice(0,-1),`${Z.at(-1)}${J[0]}`,...J.slice(1)],nb=(Z)=>{let J=typeof Z;if(J==="string")return Z;if(J==="number")return String(Z);if(B8(Z)&&(("stdout"in Z)||("isMaxBuffer"in Z)))return NG1(Z);if(Z instanceof BG1||Object.prototype.toString.call(Z)==="[object Promise]")throw new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw new TypeError(`Unexpected "${J}" in template expression`)},NG1=({stdout:Z})=>{if(typeof Z==="string")return Z;if(b8(Z))return OU(Z);if(Z===void 0)throw new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw new TypeError(`Unexpected "${typeof Z}" stdout in template expression`)};import{spawnSync as EF1}from"node:child_process";import{debuglog as RG1}from"node:util";import IM from"node:process";var z4=(Z)=>NU.includes(Z),NU=[IM.stdin,IM.stdout,IM.stderr],O9=["stdin","stdout","stderr"],RU=(Z)=>O9[Z]??`stdio[${Z}]`;var rb=(Z)=>{let J={...Z};for(let X of SM)J[X]=_M(Z,X);return J},_M=(Z,J)=>{let X=Array.from({length:MG1(Z)+1}),Y=PG1(Z[J],X,J);return kG1(Y,J)},MG1=({stdio:Z})=>Array.isArray(Z)?Math.max(Z.length,O9.length):O9.length,PG1=(Z,J,X)=>B8(Z)?DG1(Z,J,X):J.fill(Z),DG1=(Z,J,X)=>{for(let Y of Object.keys(Z).sort(CG1))for(let $ of TG1(Y,X,J))J[$]=Z[Y];return J},CG1=(Z,J)=>ob(Z)<ob(J)?1:-1,ob=(Z)=>{if(Z==="stdout"||Z==="stderr")return 0;return Z==="all"?2:1},TG1=(Z,J,X)=>{if(Z==="ipc")return[X.length-1];let Y=vM(Z);if(Y===void 0||Y===0)throw new TypeError(`"${J}.${Z}" is invalid.
373
373
  It must be "${J}.stdout", "${J}.stderr", "${J}.all", "${J}.ipc", or "${J}.fd3", "${J}.fd4" (and so on).`);if(Y>=X.length)throw new TypeError(`"${J}.${Z}" is invalid: that file descriptor does not exist.
@@ -457,7 +457,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
457
457
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
458
458
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
459
459
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
460
- -----END RSA PRIVATE KEY-----`;var Uv=process.env.PORT??8080,Lv="0.6.13",Bv;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(Bv||={});class IW extends j0{static instance=new IW;_webserver=Cj.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:Lv,runtime:typeof Bun!=="undefined"?"bun":"node"})}),this._webserver.use(Cj.default.static("assets"));try{this._webserver.use(Cj.default.static(Cn1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Pn1.createServer(this._webserver):Dn1.createServer({key:Dj.existsSync("assets/certs/localhost.key")?Dj.readFileSync("assets/certs/localhost.key"):uY0,cert:Dj.existsSync("assets/certs/localhost.crt")?Dj.readFileSync("assets/certs/localhost.crt"):mY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else u.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(Uv,this._onStarted),console.info(`WebServer.start(): Server running on port ${Uv}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return u.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=Tn1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&S7.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await N7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
460
+ -----END RSA PRIVATE KEY-----`;var Uv=process.env.PORT??8080,Lv="0.6.14",Bv;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(Bv||={});class IW extends j0{static instance=new IW;_webserver=Cj.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:Lv,runtime:typeof Bun!=="undefined"?"bun":"node"})}),this._webserver.use(Cj.default.static("assets"));try{this._webserver.use(Cj.default.static(Cn1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Pn1.createServer(this._webserver):Dn1.createServer({key:Dj.existsSync("assets/certs/localhost.key")?Dj.readFileSync("assets/certs/localhost.key"):uY0,cert:Dj.existsSync("assets/certs/localhost.crt")?Dj.readFileSync("assets/certs/localhost.crt"):mY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else u.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(Uv,this._onStarted),console.info(`WebServer.start(): Server running on port ${Uv}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return u.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=Tn1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&S7.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await N7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
461
461
  Content-Type: text/plain\r
462
462
  Content-Length: ${W.length}\r
463
463
  Connection: close\r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.6.13",
3
+ "version": "0.6.14",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./node-server.mjs",