hytopia 0.9.5 → 0.10.0-prerelease

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
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // install is deno install --reload --global --force -A npm:hytopia@dev
4
-
5
3
  import { execSync } from 'child_process';
6
4
  import archiver from 'archiver';
7
5
  import fs from 'fs';
@@ -9,11 +7,6 @@ import path from 'path';
9
7
  import readline from 'readline';
10
8
  import { fileURLToPath } from 'url';
11
9
 
12
- if (!('Deno' in globalThis)) {
13
- console.error('❌ Error: HYTOPIA scripts must be run with Deno as of version SDK 0.9.0.');
14
- process.exit(1);
15
- }
16
-
17
10
  // Store command-line flags
18
11
  const flags = {};
19
12
 
@@ -43,6 +36,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
43
36
 
44
37
  // Execute the appropriate command
45
38
  const commandHandlers = {
39
+ 'build': build,
46
40
  'help': displayHelp,
47
41
  'init': init,
48
42
  'init-mcp': initMcp,
@@ -67,15 +61,25 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
67
61
  // ================================================================================
68
62
 
69
63
  /**
70
- * Runs a hytopia project's index file using
71
- * deno compatibility mode, allow-all permissions,
64
+ * Build command
65
+ *
66
+ * Builds the server and client code for node.js
67
+ *
68
+ * @example
69
+ */
70
+ function build() {
71
+ execSync('npx bun build --format=esm --target=node --outfile=./index.js index.ts', { stdio: 'inherit' });
72
+ }
73
+
74
+ /**
75
+ * Runs a hytopia project's index file using node.js
72
76
  * and watches for changes.
73
77
  */
74
78
  function start() {
75
- execSync('deno run -A --watch index.ts', {
76
- stdio: 'inherit',
77
- env: { ...process.env, DENO_COMPAT: '1' },
78
- });
79
+ execSync(`
80
+ nodemon -q -w index.ts
81
+ -x "npx bun build --format=esm --target=node --outfile=./index.js index.ts && node index.js"
82
+ `, { stdio: 'inherit'});
79
83
  }
80
84
 
81
85
  /**
@@ -126,6 +130,9 @@ function init() {
126
130
  initFromBoilerplate(destDir);
127
131
  }
128
132
 
133
+ // Update SDK to latest (sets package.json requirement)
134
+ upgradeProject();
135
+
129
136
  // Copy assets into project, not overwriting existing files
130
137
  copyAssets(destDir);
131
138
 
@@ -143,45 +150,23 @@ function init() {
143
150
  */
144
151
  function installProjectDependencies() {
145
152
  // init project
146
- execSync('deno init --quiet', { stdio: 'inherit' });
147
-
148
- // remove deno boilerplate
149
- Deno.removeSync('main.ts');
150
- Deno.removeSync('main_test.ts');
151
-
152
- // create deno.json with nodeModulesDir set to auto
153
- Deno.writeTextFile('deno.json', JSON.stringify({
154
- nodeModulesDir: "auto",
155
- }, null, 2));
153
+ execSync('npm init --yes', { stdio: 'inherit' });
156
154
 
157
155
  // create tsconfig.json, used by validation bundler
158
- Deno.writeTextFile('tsconfig.json', JSON.stringify({
156
+ fs.writeFileSync('tsconfig.json', JSON.stringify({
159
157
  compilerOptions: {
160
158
  lib: ["ESNext"],
161
159
  target: "ESNext",
162
160
  module: "Preserve",
163
- moduleResolution: "bundler",
164
- types: ["deno.ns"],
161
+ moduleResolution: "node",
165
162
  verbatimModuleSyntax: true,
166
163
  strict: true,
167
164
  skipLibCheck: true
168
165
  }
169
166
  }, null, 2))
170
167
 
171
- // create package.json
172
- Deno.writeTextFile('package.json', JSON.stringify({
173
- name: 'hytopia-project',
174
- version: '1.0.0',
175
- description: 'My HYTOPIA project',
176
- main: 'index.ts',
177
- scripts: {
178
- start: 'hytopia start'
179
- }
180
- }, null, 2));
181
-
182
168
  // install hytopia sdk and hytopia assets
183
- denoAddPackage('hytopia@latest', '--quiet');
184
- denoAddPackage('@hytopia.com/assets@latest', '--quiet');
169
+ execSync('npm install hytopia@latest @hytopia.com/assets@latest', { stdio: 'inherit' });
185
170
  }
186
171
 
187
172
  /**
@@ -190,7 +175,7 @@ function installProjectDependencies() {
190
175
  function initFromTemplate(destDir) {
191
176
  console.log(`🖨️ Initializing project with examples template "${flags.template}"...`);
192
177
 
193
- denoAddPackage('@hytopia.com/examples@latest');
178
+ execSync('npm install @hytopia.com/examples@latest', { stdio: 'inherit' });
194
179
 
195
180
  const templateDir = path.join(destDir, 'node_modules', '@hytopia.com', 'examples', flags.template);
196
181
 
@@ -200,7 +185,7 @@ function initFromTemplate(destDir) {
200
185
  return;
201
186
  }
202
187
 
203
- execSync('deno install', { stdio: 'inherit' });
188
+ execSync('npm install', { stdio: 'inherit' });
204
189
  }
205
190
 
206
191
  /**
@@ -353,8 +338,8 @@ function initCursorLocalMcp() {
353
338
  /**
354
339
  * Package command
355
340
  *
356
- * Creates a zip file of the project directory, excluding node_modules,
357
- * package-lock.json, deno.lock, and deno.json files.
341
+ * Creates a zip file of the project directory, excluding node_modules
342
+ * and package-lock.json files.
358
343
  *
359
344
  * @example
360
345
  * `hytopia package`
@@ -469,8 +454,6 @@ function packageProject() {
469
454
  '.git',
470
455
  'node_modules',
471
456
  'package-lock.json',
472
- 'deno.lock',
473
- 'deno.json',
474
457
  `${projectName}.zip` // Exclude the output file itself
475
458
  ];
476
459
 
@@ -573,13 +556,6 @@ function displayAvailableCommands(command) {
573
556
  displayHelp();
574
557
  }
575
558
 
576
- /**
577
- * Adds a package using deno add command
578
- */
579
- function denoAddPackage(packageName, flags = '') {
580
- execSync(`deno add --allow-scripts --npm ${flags} ${packageName}`, { stdio: 'inherit' });
581
- }
582
-
583
559
  // ================================================================================
584
560
  // VERSION CHECK AND UPGRADE
585
561
  // ================================================================================
@@ -628,7 +604,7 @@ async function fetchLatestVersion(signal) {
628
604
  function upgradeCli() {
629
605
  const versionArg = (process.argv[3] || 'latest').trim();
630
606
  console.log(`🔄 Upgrading HYTOPIA CLI to: hytopia@${versionArg} ...`);
631
- execSync(`deno install --reload --global --force -A npm:hytopia@${versionArg}`, { stdio: 'inherit' });
607
+ execSync(`npm install -g hytopia@${versionArg}`, { stdio: 'inherit' });
632
608
  console.log('✅ Upgrade complete. You may need to restart your shell for changes to take effect.');
633
609
  }
634
610
 
@@ -636,7 +612,7 @@ function upgradeProject() {
636
612
  const versionArg = (process.argv[3] || 'latest').trim();
637
613
  const spec = `hytopia@${versionArg}`;
638
614
  console.log(`🔄 Upgrading project HYTOPIA SDK to: ${spec} ...`);
639
- execSync(`deno add --allow-scripts --npm ${spec}`, { stdio: 'inherit' });
615
+ execSync(`npm install ${spec}`, { stdio: 'inherit' });
640
616
  console.log('✅ Project dependency upgraded.');
641
617
  }
642
618
 
@@ -653,7 +629,7 @@ function displayHelp() {
653
629
  console.log('Commands:');
654
630
  console.log(' help, -h, --help Show this help');
655
631
  console.log(' version, -v, --version Show CLI version');
656
- console.log(' start Start a HYTOPIA project server (Deno compat & watch)');
632
+ console.log(' start Start a HYTOPIA project server (Node.js & watch)');
657
633
  console.log(' init [--template NAME] Initialize a new project');
658
634
  console.log(' init-mcp Setup MCP integrations');
659
635
  console.log(' package Create a zip of the project for uploading to the HYTOPIA create portal.');
@@ -9,7 +9,7 @@ The payloads for all events in the game server.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export interface EventPayloads extends AudioEventPayloads, BaseEntityControllerEventPayloads, BlockTypeEventPayloads, BlockTypeRegistryEventPayloads, ChatEventPayloads, ChunkLatticeEventPayloads, ConnectionEventPayloads, EntityEventPayloads, GameServerEventPayloads, ParticleEmitterEventPayloads, PlayerCameraEventPayloads, PlayerEventPayloads, PlayerManagerEventPayloads, PlayerUIEventPayloads, SceneUIEventPayloads, SimulationEventPayloads, LightEventPayloads, WebServerEventPayloads, WorldEventPayloads, WorldLoopEventPayloads, WorldManagerEventPayloads
12
+ export interface EventPayloads extends AudioEventPayloads, BaseEntityControllerEventPayloads, BlockTypeEventPayloads, BlockTypeRegistryEventPayloads, ChatEventPayloads, ChunkLatticeEventPayloads, ConnectionEventPayloads, EntityEventPayloads, GameServerEventPayloads, ParticleEmitterEventPayloads, PlayerCameraEventPayloads, PlayerEventPayloads, PlayerManagerEventPayloads, PlayerUIEventPayloads, SceneUIEventPayloads, SimulationEventPayloads, SocketEventPayloads, LightEventPayloads, WebServerEventPayloads, WorldEventPayloads, WorldLoopEventPayloads, WorldManagerEventPayloads
13
13
  ```
14
- **Extends:** [AudioEventPayloads](./server.audioeventpayloads.md)<!-- -->, [BaseEntityControllerEventPayloads](./server.baseentitycontrollereventpayloads.md)<!-- -->, [BlockTypeEventPayloads](./server.blocktypeeventpayloads.md)<!-- -->, [BlockTypeRegistryEventPayloads](./server.blocktyperegistryeventpayloads.md)<!-- -->, [ChatEventPayloads](./server.chateventpayloads.md)<!-- -->, [ChunkLatticeEventPayloads](./server.chunklatticeeventpayloads.md)<!-- -->, ConnectionEventPayloads, [EntityEventPayloads](./server.entityeventpayloads.md)<!-- -->, [GameServerEventPayloads](./server.gameservereventpayloads.md)<!-- -->, [ParticleEmitterEventPayloads](./server.particleemittereventpayloads.md)<!-- -->, [PlayerCameraEventPayloads](./server.playercameraeventpayloads.md)<!-- -->, [PlayerEventPayloads](./server.playereventpayloads.md)<!-- -->, [PlayerManagerEventPayloads](./server.playermanagereventpayloads.md)<!-- -->, [PlayerUIEventPayloads](./server.playeruieventpayloads.md)<!-- -->, [SceneUIEventPayloads](./server.sceneuieventpayloads.md)<!-- -->, [SimulationEventPayloads](./server.simulationeventpayloads.md)<!-- -->, [LightEventPayloads](./server.lighteventpayloads.md)<!-- -->, WebServerEventPayloads, [WorldEventPayloads](./server.worldeventpayloads.md)<!-- -->, [WorldLoopEventPayloads](./server.worldloopeventpayloads.md)<!-- -->, [WorldManagerEventPayloads](./server.worldmanagereventpayloads.md)
14
+ **Extends:** [AudioEventPayloads](./server.audioeventpayloads.md)<!-- -->, [BaseEntityControllerEventPayloads](./server.baseentitycontrollereventpayloads.md)<!-- -->, [BlockTypeEventPayloads](./server.blocktypeeventpayloads.md)<!-- -->, [BlockTypeRegistryEventPayloads](./server.blocktyperegistryeventpayloads.md)<!-- -->, [ChatEventPayloads](./server.chateventpayloads.md)<!-- -->, [ChunkLatticeEventPayloads](./server.chunklatticeeventpayloads.md)<!-- -->, ConnectionEventPayloads, [EntityEventPayloads](./server.entityeventpayloads.md)<!-- -->, [GameServerEventPayloads](./server.gameservereventpayloads.md)<!-- -->, [ParticleEmitterEventPayloads](./server.particleemittereventpayloads.md)<!-- -->, [PlayerCameraEventPayloads](./server.playercameraeventpayloads.md)<!-- -->, [PlayerEventPayloads](./server.playereventpayloads.md)<!-- -->, [PlayerManagerEventPayloads](./server.playermanagereventpayloads.md)<!-- -->, [PlayerUIEventPayloads](./server.playeruieventpayloads.md)<!-- -->, [SceneUIEventPayloads](./server.sceneuieventpayloads.md)<!-- -->, [SimulationEventPayloads](./server.simulationeventpayloads.md)<!-- -->, SocketEventPayloads, [LightEventPayloads](./server.lighteventpayloads.md)<!-- -->, WebServerEventPayloads, [WorldEventPayloads](./server.worldeventpayloads.md)<!-- -->, [WorldLoopEventPayloads](./server.worldloopeventpayloads.md)<!-- -->, [WorldManagerEventPayloads](./server.worldmanagereventpayloads.md)
15
15
 
@@ -9,5 +9,5 @@ The port the server will run on. You can override this in your .env by setting P
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- PORT: number
12
+ PORT: string | 8080
13
13
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.9.5",
3
+ "version": "0.10.0-prerelease",
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.js",
@@ -70,5 +70,9 @@
70
70
  ],
71
71
  "scripts": {
72
72
  "prepublishOnly": "node ./bin/writeVersion.js"
73
+ },
74
+ "devDependencies": {
75
+ "bun": "^1.2.20",
76
+ "nodemon": "^3.1.10"
73
77
  }
74
78
  }
package/server.api.json CHANGED
@@ -17519,6 +17519,15 @@
17519
17519
  "kind": "Content",
17520
17520
  "text": ", "
17521
17521
  },
17522
+ {
17523
+ "kind": "Reference",
17524
+ "text": "SocketEventPayloads",
17525
+ "canonicalReference": "server!~SocketEventPayloads:interface"
17526
+ },
17527
+ {
17528
+ "kind": "Content",
17529
+ "text": ", "
17530
+ },
17522
17531
  {
17523
17532
  "kind": "Reference",
17524
17533
  "text": "LightEventPayloads",
@@ -17654,6 +17663,10 @@
17654
17663
  {
17655
17664
  "startIndex": 41,
17656
17665
  "endIndex": 42
17666
+ },
17667
+ {
17668
+ "startIndex": 43,
17669
+ "endIndex": 44
17657
17670
  }
17658
17671
  ]
17659
17672
  },
@@ -40002,7 +40015,7 @@
40002
40015
  },
40003
40016
  {
40004
40017
  "kind": "Content",
40005
- "text": "number"
40018
+ "text": "string | 8080"
40006
40019
  }
40007
40020
  ],
40008
40021
  "fileUrlPath": "src/networking/WebServer.ts",
package/server.d.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  import type { AnyPacket } from '@hytopia.com/server-protocol';
2
+ import type { ErrorEvent as ErrorEvent_2 } from 'ws';
2
3
  import EventEmitter from 'eventemitter3';
4
+ import http from 'http';
5
+ import type { IncomingMessage } from 'http';
3
6
  import type { InputSchema } from '@hytopia.com/server-protocol';
4
7
  import type { LobbyMembershipDto } from '@hytopia.com/creative-lib/dist/impl/getSession';
5
8
  import protocol from '@hytopia.com/server-protocol';
6
9
  import RAPIER from '@dimforge/rapier3d-simd-compat';
7
10
  import { SdpMatrix3 } from '@dimforge/rapier3d-simd-compat';
8
11
  import * as Sentry from '@sentry/node';
12
+ import type { Socket } from 'net';
9
13
  import type { types } from 'mediasoup';
14
+ import { WebSocket as WebSocket_2 } from 'ws';
10
15
 
11
16
  /**
12
17
  * Represents a audio playback in a world.
@@ -2195,7 +2200,7 @@ export declare class ErrorHandler {
2195
2200
  *
2196
2201
  * @public
2197
2202
  */
2198
- export declare interface EventPayloads extends AudioEventPayloads, BaseEntityControllerEventPayloads, BlockTypeEventPayloads, BlockTypeRegistryEventPayloads, ChatEventPayloads, ChunkLatticeEventPayloads, ConnectionEventPayloads, EntityEventPayloads, GameServerEventPayloads, ParticleEmitterEventPayloads, PlayerCameraEventPayloads, PlayerEventPayloads, PlayerManagerEventPayloads, PlayerUIEventPayloads, SceneUIEventPayloads, SimulationEventPayloads, LightEventPayloads, WebServerEventPayloads, WorldEventPayloads, WorldLoopEventPayloads, WorldManagerEventPayloads {
2203
+ export declare interface EventPayloads extends AudioEventPayloads, BaseEntityControllerEventPayloads, BlockTypeEventPayloads, BlockTypeRegistryEventPayloads, ChatEventPayloads, ChunkLatticeEventPayloads, ConnectionEventPayloads, EntityEventPayloads, GameServerEventPayloads, ParticleEmitterEventPayloads, PlayerCameraEventPayloads, PlayerEventPayloads, PlayerManagerEventPayloads, PlayerUIEventPayloads, SceneUIEventPayloads, SimulationEventPayloads, SocketEventPayloads, LightEventPayloads, WebServerEventPayloads, WorldEventPayloads, WorldLoopEventPayloads, WorldManagerEventPayloads {
2199
2204
  }
2200
2205
 
2201
2206
  /**
@@ -4962,7 +4967,7 @@ export declare interface PlayerUIEventPayloads {
4962
4967
  *
4963
4968
  * @public
4964
4969
  */
4965
- export declare const PORT: number;
4970
+ export declare const PORT: string | 8080;
4966
4971
 
4967
4972
  /**
4968
4973
  * Represents a quaternion.