hytopia 0.10.0-prerelease-9 → 0.10.0-prerelease-10

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
@@ -69,6 +69,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
69
69
  * @example
70
70
  */
71
71
  async function build() {
72
+ logDivider();
73
+ console.log('🔧 Building project...');
72
74
  await esbuild.build({
73
75
  entryPoints: ['index.ts'],
74
76
  outfile: './index.mjs',
@@ -102,6 +104,8 @@ function start() {
102
104
 
103
105
  const scheduleRestart = () => {
104
106
  if (restartTimer) clearTimeout(restartTimer);
107
+ logDivider();
108
+ console.log('Restarting HYTOPIA server...');
105
109
  restartTimer = setTimeout(startNode, 100);
106
110
  };
107
111
 
@@ -401,7 +405,7 @@ function initCursorLocalMcp() {
401
405
  * @example
402
406
  * `hytopia package`
403
407
  */
404
- function packageProject() {
408
+ async function packageProject() {
405
409
  const sourceDir = process.cwd();
406
410
  const projectName = path.basename(sourceDir);
407
411
  const packageJsonPath = path.join(sourceDir, 'package.json');
@@ -473,6 +477,9 @@ function packageProject() {
473
477
 
474
478
  console.log(`📦 Packaging project "${projectName}"...`);
475
479
 
480
+ // Build the project
481
+ await build();
482
+
476
483
  // Create a file to stream archive data to
477
484
  const output = fs.createWriteStream(outputFile);
478
485
  const archive = archiver('zip', {
@@ -686,6 +693,7 @@ function displayHelp() {
686
693
  console.log('Commands:');
687
694
  console.log(' help, -h, --help Show this help');
688
695
  console.log(' version, -v, --version Show CLI version');
696
+ console.log(' build Build the project (Generates ESM index.js)');
689
697
  console.log(' start Start a HYTOPIA project server (Node.js & watch)');
690
698
  console.log(' init [--template NAME] Initialize a new project');
691
699
  console.log(' init-mcp Setup MCP integrations');
@@ -4,10 +4,10 @@
4
4
  import fs from 'fs';
5
5
 
6
6
  const sdkPackage = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
7
- const server = fs.readFileSync('./server.js', 'utf8');
7
+ const server = fs.readFileSync('./server.mjs', 'utf8');
8
8
 
9
9
  if (!server.includes('__DEV_SDK_VERSION__')) {
10
- throw new Error('__DEV_SDK_VERSION__ not found in server.js. Please create a fresh build before publishing! You can do this by running: cd ../server && bun run build.');
10
+ throw new Error('__DEV_SDK_VERSION__ not found in server.mjs. Please create a fresh build before publishing! You can do this by running: cd ../server && npm run build.');
11
11
  }
12
12
 
13
- fs.writeFileSync('./server.js', server.replace(/__DEV_SDK_VERSION__/g, sdkPackage.version));
13
+ fs.writeFileSync('./server.mjs', server.replace(/__DEV_SDK_VERSION__/g, sdkPackage.version));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.10.0-prerelease-9",
3
+ "version": "0.10.0-prerelease-10",
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
- "main": "./server.js",
6
+ "main": "./server.mjs",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./server.d.ts",
10
- "default": "./server.js"
10
+ "default": "./server.mjs"
11
11
  }
12
12
  },
13
13
  "bin": {
@@ -442,7 +442,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
442
442
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
443
443
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
444
444
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
445
- -----END RSA PRIVATE KEY-----`;var IE=process.env.PORT??8080,fE="0.10.0-prerelease-9",_E;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(_E||={});class D3 extends L0{static instance=new D3;_webserver=k2.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:fE,runtime:"node"})}),this._webserver.use(k2.default.static("assets"));try{this._webserver.use(k2.default.static(tn1.dirname(p.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?on1.createServer(this._webserver):rn1.createServer({key:T2.existsSync("assets/certs/localhost.key")?T2.readFileSync("assets/certs/localhost.key"):cQ0,cert:T2.existsSync("assets/certs/localhost.crt")?T2.readFileSync("assets/certs/localhost.crt"):jQ0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else y.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(IE,this._onStarted),console.info(`WebServer.start(): Server running on port ${IE}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return y.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=en1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&C7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await x7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
445
+ -----END RSA PRIVATE KEY-----`;var IE=process.env.PORT??8080,fE="0.10.0-prerelease-10",_E;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(_E||={});class D3 extends L0{static instance=new D3;_webserver=k2.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:fE,runtime:"node"})}),this._webserver.use(k2.default.static("assets"));try{this._webserver.use(k2.default.static(tn1.dirname(p.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?on1.createServer(this._webserver):rn1.createServer({key:T2.existsSync("assets/certs/localhost.key")?T2.readFileSync("assets/certs/localhost.key"):cQ0,cert:T2.existsSync("assets/certs/localhost.crt")?T2.readFileSync("assets/certs/localhost.crt"):jQ0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else y.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(IE,this._onStarted),console.info(`WebServer.start(): Server running on port ${IE}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return y.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=en1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&C7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await x7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
446
446
  Content-Type: text/plain\r
447
447
  Content-Length: ${W.length}\r
448
448
  Connection: close\r