hytopia 0.10.27-prerelease-3 → 0.10.27-prerelease-5
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 +25 -78
- package/package.json +3 -2
- package/server.mjs +106 -106
package/bin/scripts.js
CHANGED
|
@@ -4,9 +4,9 @@ import { execSync, spawn } from 'child_process';
|
|
|
4
4
|
import archiver from 'archiver';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import nodemon from 'nodemon';
|
|
7
8
|
import readline from 'readline';
|
|
8
9
|
import { fileURLToPath } from 'url';
|
|
9
|
-
import * as esbuild from 'esbuild';
|
|
10
10
|
|
|
11
11
|
// Store command-line flags
|
|
12
12
|
const flags = {};
|
|
@@ -66,88 +66,35 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
66
66
|
* @example
|
|
67
67
|
*/
|
|
68
68
|
async function build() {
|
|
69
|
-
console.log('🔧 Building project...');
|
|
70
|
-
|
|
71
|
-
await esbuild.build({
|
|
72
|
-
entryPoints: ['index.ts'],
|
|
73
|
-
outfile: './index.mjs',
|
|
74
|
-
bundle: true,
|
|
75
|
-
format: 'esm',
|
|
76
|
-
platform: 'node',
|
|
77
|
-
target: 'node24',
|
|
78
|
-
sourcemap: 'inline',
|
|
79
|
-
mainFields: ['module', 'main'],
|
|
80
|
-
conditions: ['import', 'node'],
|
|
81
|
-
treeShaking: true,
|
|
82
|
-
minify: true,
|
|
83
|
-
banner: {
|
|
84
|
-
js: 'import { createRequire as __cr } from "module"; import { fileURLToPath } from "url"; import { dirname as __bundlerDirname } from "path"; const require = __cr(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = __bundlerDirname(__filename);'
|
|
85
|
-
}
|
|
86
|
-
});
|
|
69
|
+
console.log('🔧 Building project (bun)...');
|
|
70
|
+
execSync('npx --yes bun build --target=node --format=esm --outfile=index.mjs index.ts', { stdio: 'inherit' });
|
|
87
71
|
}
|
|
88
72
|
|
|
89
73
|
/**
|
|
90
74
|
* Runs a hytopia project's index file using node.js
|
|
91
75
|
* and watches for changes.
|
|
92
76
|
*/
|
|
93
|
-
function start() {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
platform: 'node',
|
|
115
|
-
target: 'node24',
|
|
116
|
-
sourcemap: 'inline',
|
|
117
|
-
external: [ 'mediasoup' ], // prevent pathing issues in dev env, prod sets the bin path so no issue bundling in prod build/package.
|
|
118
|
-
mainFields: ['module', 'main'],
|
|
119
|
-
conditions: ['import', 'node'],
|
|
120
|
-
treeShaking: true,
|
|
121
|
-
minify: true,
|
|
122
|
-
banner: {
|
|
123
|
-
js: 'import { createRequire as __cr } from "module"; import { fileURLToPath } from "url"; import { dirname } from "path"; const require = __cr(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);'
|
|
124
|
-
},
|
|
125
|
-
plugins: [{
|
|
126
|
-
name: 'restart-after-build',
|
|
127
|
-
setup(build) {
|
|
128
|
-
build.onStart(() => {
|
|
129
|
-
if (restartTimer) { clearTimeout(restartTimer); restartTimer = null; }
|
|
130
|
-
});
|
|
131
|
-
build.onEnd((result) => {
|
|
132
|
-
if (result.errors?.length) return;
|
|
133
|
-
restartTimer = setTimeout(restartNode, 150);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}]
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
await ctx.watch();
|
|
140
|
-
|
|
141
|
-
const cleanup = async () => {
|
|
142
|
-
if (restartTimer) clearTimeout(restartTimer);
|
|
143
|
-
stopNode();
|
|
144
|
-
try { await ctx.dispose(); } catch {}
|
|
145
|
-
process.exit(0);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
process.on('SIGINT', cleanup);
|
|
149
|
-
process.on('SIGTERM', cleanup);
|
|
150
|
-
})();
|
|
77
|
+
async function start() {
|
|
78
|
+
// Initial build via CLI to ensure consistency
|
|
79
|
+
execSync('hytopia build', { stdio: 'inherit' });
|
|
80
|
+
|
|
81
|
+
const projectRoot = process.cwd();
|
|
82
|
+
const entryFile = path.join(projectRoot, 'index.mjs');
|
|
83
|
+
const buildCmd = 'hytopia build';
|
|
84
|
+
const runCmd = `"${process.execPath}" --enable-source-maps "${entryFile}"`;
|
|
85
|
+
|
|
86
|
+
// Start nodemon to watch for changes, rebuild, then run the server
|
|
87
|
+
nodemon({
|
|
88
|
+
watch: ['.'],
|
|
89
|
+
ext: 'js,ts,html',
|
|
90
|
+
ignore: ['node_modules/**', '.git/**', '*.zip', 'index.mjs'],
|
|
91
|
+
exec: `${buildCmd} && ${runCmd}`,
|
|
92
|
+
delay: 100,
|
|
93
|
+
})
|
|
94
|
+
.on('quit', () => {
|
|
95
|
+
console.log('👋 Shutting down...');
|
|
96
|
+
process.exit();
|
|
97
|
+
});
|
|
151
98
|
}
|
|
152
99
|
|
|
153
100
|
/**
|
|
@@ -661,7 +608,7 @@ function displayHelp() {
|
|
|
661
608
|
console.log('Commands:');
|
|
662
609
|
console.log(' help, -h, --help Show this help');
|
|
663
610
|
console.log(' version, -v, --version Show CLI version');
|
|
664
|
-
console.log(' build Build the project (Generates ESM index.
|
|
611
|
+
console.log(' build Build the project (Generates ESM index.mjs)');
|
|
665
612
|
console.log(' start Start a HYTOPIA project server (Node.js & watch)');
|
|
666
613
|
console.log(' init [--template NAME] Initialize a new project');
|
|
667
614
|
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-
|
|
3
|
+
"version": "0.10.27-prerelease-5",
|
|
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",
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@gltf-transform/cli": "^4.2.1",
|
|
60
60
|
"archiver": "^7.0.1",
|
|
61
|
-
"
|
|
61
|
+
"bun": "^1.3.0",
|
|
62
|
+
"nodemon": "^3.1.10",
|
|
62
63
|
"ws": "^8.18.2"
|
|
63
64
|
},
|
|
64
65
|
"optionalDependencies": {
|