hytopia 0.10.27-prerelease-3 → 0.10.27-prerelease-4
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 +39 -51
- package/package.json +2 -2
- package/server.mjs +106 -106
package/bin/scripts.js
CHANGED
|
@@ -6,7 +6,6 @@ import fs from 'fs';
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import readline from 'readline';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
|
-
import * as esbuild from 'esbuild';
|
|
10
9
|
|
|
11
10
|
// Store command-line flags
|
|
12
11
|
const flags = {};
|
|
@@ -66,24 +65,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
66
65
|
* @example
|
|
67
66
|
*/
|
|
68
67
|
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
|
-
});
|
|
68
|
+
console.log('🔧 Building project (bun)...');
|
|
69
|
+
execSync('npx --yes bun build --target=node --format=esm --outfile=index.mjs index.ts', { stdio: 'inherit' });
|
|
87
70
|
}
|
|
88
71
|
|
|
89
72
|
/**
|
|
@@ -94,6 +77,8 @@ function start() {
|
|
|
94
77
|
(async () => {
|
|
95
78
|
let child = null;
|
|
96
79
|
let restartTimer = null;
|
|
80
|
+
let bunProc = null;
|
|
81
|
+
let watcher = null;
|
|
97
82
|
|
|
98
83
|
const stopNode = () => {
|
|
99
84
|
if (child && !child.killed) {
|
|
@@ -106,42 +91,45 @@ function start() {
|
|
|
106
91
|
child = spawn(process.execPath, ['--enable-source-maps', 'index.mjs'], { stdio: 'inherit', shell: false });
|
|
107
92
|
};
|
|
108
93
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
format
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
});
|
|
94
|
+
// Start bun build in watch mode. Externalize mediasoup similar to previous dev behavior.
|
|
95
|
+
const bunArgs = [
|
|
96
|
+
'--yes', 'bun', 'build',
|
|
97
|
+
'--target=node',
|
|
98
|
+
'--format=esm',
|
|
99
|
+
'--outfile=index.mjs',
|
|
100
|
+
'--external=mediasoup',
|
|
101
|
+
'--watch',
|
|
102
|
+
'index.ts'
|
|
103
|
+
];
|
|
104
|
+
bunProc = spawn('npx', bunArgs, { stdio: 'inherit', shell: false });
|
|
105
|
+
|
|
106
|
+
const outputFile = path.join(process.cwd(), 'index.mjs');
|
|
107
|
+
// If output exists, start the node process; otherwise wait for first build
|
|
108
|
+
if (fs.existsSync(outputFile)) {
|
|
109
|
+
restartNode();
|
|
110
|
+
}
|
|
138
111
|
|
|
139
|
-
|
|
112
|
+
// Watch for changes to the output file and restart the node process
|
|
113
|
+
try {
|
|
114
|
+
watcher = fs.watch(outputFile, { persistent: true }, () => {
|
|
115
|
+
if (restartTimer) { clearTimeout(restartTimer); restartTimer = null; }
|
|
116
|
+
restartTimer = setTimeout(restartNode, 150);
|
|
117
|
+
});
|
|
118
|
+
} catch {
|
|
119
|
+
// Fallback: watch the current directory for changes to index.mjs
|
|
120
|
+
watcher = fs.watch(process.cwd(), { persistent: true }, (eventType, filename) => {
|
|
121
|
+
if (filename === 'index.mjs') {
|
|
122
|
+
if (restartTimer) { clearTimeout(restartTimer); restartTimer = null; }
|
|
123
|
+
restartTimer = setTimeout(restartNode, 150);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
140
127
|
|
|
141
128
|
const cleanup = async () => {
|
|
142
129
|
if (restartTimer) clearTimeout(restartTimer);
|
|
143
130
|
stopNode();
|
|
144
|
-
try {
|
|
131
|
+
try { if (watcher) watcher.close(); } catch {}
|
|
132
|
+
try { if (bunProc && !bunProc.killed) bunProc.kill(); } catch {}
|
|
145
133
|
process.exit(0);
|
|
146
134
|
};
|
|
147
135
|
|
|
@@ -661,7 +649,7 @@ function displayHelp() {
|
|
|
661
649
|
console.log('Commands:');
|
|
662
650
|
console.log(' help, -h, --help Show this help');
|
|
663
651
|
console.log(' version, -v, --version Show CLI version');
|
|
664
|
-
console.log(' build Build the project (Generates ESM index.
|
|
652
|
+
console.log(' build Build the project (Generates ESM index.mjs)');
|
|
665
653
|
console.log(' start Start a HYTOPIA project server (Node.js & watch)');
|
|
666
654
|
console.log(' init [--template NAME] Initialize a new project');
|
|
667
655
|
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-4",
|
|
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,7 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@gltf-transform/cli": "^4.2.1",
|
|
60
60
|
"archiver": "^7.0.1",
|
|
61
|
-
"
|
|
61
|
+
"bun": "^1.3.0",
|
|
62
62
|
"ws": "^8.18.2"
|
|
63
63
|
},
|
|
64
64
|
"optionalDependencies": {
|