hytopia 0.10.27-prerelease-5 → 0.10.27-prerelease-6

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/bin/scripts.js CHANGED
@@ -34,7 +34,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
34
34
 
35
35
  // Execute the appropriate command
36
36
  const commandHandlers = {
37
- 'build': build,
37
+ 'build': () => build(false),
38
+ 'build-dev': () => build(true),
38
39
  'help': displayHelp,
39
40
  'init': init,
40
41
  'init-mcp': initMcp,
@@ -65,22 +66,15 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
65
66
  *
66
67
  * @example
67
68
  */
68
- async function build() {
69
- console.log('🔧 Building project (bun)...');
70
- execSync('npx --yes bun build --target=node --format=esm --outfile=index.mjs index.ts', { stdio: 'inherit' });
71
- }
72
69
 
73
70
  /**
74
71
  * Runs a hytopia project's index file using node.js
75
72
  * and watches for changes.
76
73
  */
77
74
  async function start() {
78
- // Initial build via CLI to ensure consistency
79
- execSync('hytopia build', { stdio: 'inherit' });
80
-
81
75
  const projectRoot = process.cwd();
82
76
  const entryFile = path.join(projectRoot, 'index.mjs');
83
- const buildCmd = 'hytopia build';
77
+ const buildCmd = 'hytopia build-dev';
84
78
  const runCmd = `"${process.execPath}" --enable-source-maps "${entryFile}"`;
85
79
 
86
80
  // Start nodemon to watch for changes, rebuild, then run the server
@@ -478,6 +472,12 @@ async function packageProject() {
478
472
 
479
473
  // set priority level for takahiro tickets
480
474
 
475
+ async function build(devMode = false) {
476
+ let devFlags = devMode ? '--external=mediasoup' : '';
477
+
478
+ execSync(`npx --yes bun build --target=node --format=esm ${devFlags} --outfile=index.mjs index.ts`, { stdio: 'inherit' });
479
+ }
480
+
481
481
  /**
482
482
  * Parses command-line flags in the format --flag value
483
483
  */
@@ -609,6 +609,7 @@ function displayHelp() {
609
609
  console.log(' help, -h, --help Show this help');
610
610
  console.log(' version, -v, --version Show CLI version');
611
611
  console.log(' build Build the project (Generates ESM index.mjs)');
612
+ console.log(' build-dev Build the project in development mode (Generates ESM index.mjs with local dependencies externalized)');
612
613
  console.log(' start Start a HYTOPIA project server (Node.js & watch)');
613
614
  console.log(' init [--template NAME] Initialize a new project');
614
615
  console.log(' init-mcp Setup MCP integrations');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.10.27-prerelease-5",
3
+ "version": "0.10.27-prerelease-6",
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": "./server.mjs",
package/server.mjs CHANGED
@@ -447,7 +447,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
447
447
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
448
448
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
449
449
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
450
- -----END RSA PRIVATE KEY-----`;var hf=process.env.PORT??8080,Sf="0.10.27-prerelease-5",bf;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(bf||={});class cK extends j0{static instance=new cK;_webserver=QU.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:Sf,runtime:"node"})}),this._webserver.use(QU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(QU.default.static(Pn1.dirname(i.resolve("@hytopia.com/assets")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Mn1.createServer(this._webserver):Rn1.createServer({key:YU.existsSync("assets/certs/localhost.key")?YU.readFileSync("assets/certs/localhost.key"):iY0,cert:YU.existsSync("assets/certs/localhost.crt")?YU.readFileSync("assets/certs/localhost.crt"):pY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(hf,this._onStarted),console.info(`WebServer.start(): Server running on port ${hf}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=Nn1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&R7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await F7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
450
+ -----END RSA PRIVATE KEY-----`;var hf=process.env.PORT??8080,Sf="0.10.27-prerelease-6",bf;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(bf||={});class cK extends j0{static instance=new cK;_webserver=QU.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:Sf,runtime:"node"})}),this._webserver.use(QU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(QU.default.static(Pn1.dirname(i.resolve("@hytopia.com/assets")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Mn1.createServer(this._webserver):Rn1.createServer({key:YU.existsSync("assets/certs/localhost.key")?YU.readFileSync("assets/certs/localhost.key"):iY0,cert:YU.existsSync("assets/certs/localhost.crt")?YU.readFileSync("assets/certs/localhost.crt"):pY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(hf,this._onStarted),console.info(`WebServer.start(): Server running on port ${hf}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=Nn1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&R7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await F7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
451
451
  Content-Type: text/plain\r
452
452
  Content-Length: ${W.length}\r
453
453
  Connection: close\r