hytopia 0.10.0-prerelease-11 → 0.10.0-prerelease-12
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 +16 -6
- package/package.json +1 -1
- package/server.mjs +2 -2
package/bin/scripts.js
CHANGED
@@ -89,6 +89,7 @@ async function build() {
|
|
89
89
|
function start() {
|
90
90
|
(async () => {
|
91
91
|
let child = null;
|
92
|
+
let restartTimer = null;
|
92
93
|
|
93
94
|
const stopNode = () => {
|
94
95
|
if (child && !child.killed) {
|
@@ -96,9 +97,9 @@ function start() {
|
|
96
97
|
}
|
97
98
|
};
|
98
99
|
|
99
|
-
const
|
100
|
+
const restartNode = () => {
|
100
101
|
stopNode();
|
101
|
-
child = spawn(process.execPath, ['
|
102
|
+
child = spawn(process.execPath, ['index.mjs'], { stdio: 'inherit', shell: false });
|
102
103
|
};
|
103
104
|
|
104
105
|
const ctx = await esbuild.context({
|
@@ -109,15 +110,24 @@ function start() {
|
|
109
110
|
platform: 'node',
|
110
111
|
target: 'node24',
|
111
112
|
sourcemap: 'inline',
|
113
|
+
plugins: [{
|
114
|
+
name: 'restart-after-build',
|
115
|
+
setup(build) {
|
116
|
+
build.onStart(() => {
|
117
|
+
if (restartTimer) { clearTimeout(restartTimer); restartTimer = null; }
|
118
|
+
});
|
119
|
+
build.onEnd((result) => {
|
120
|
+
if (result.errors?.length) return;
|
121
|
+
restartTimer = setTimeout(restartNode, 150);
|
122
|
+
});
|
123
|
+
}
|
124
|
+
}]
|
112
125
|
});
|
113
126
|
|
114
|
-
// Start watching (per esbuild, this performs an initial build before resolving)
|
115
127
|
await ctx.watch();
|
116
128
|
|
117
|
-
// Run node with native --watch to auto-restart on output changes
|
118
|
-
spawnNode();
|
119
|
-
|
120
129
|
const cleanup = async () => {
|
130
|
+
if (restartTimer) clearTimeout(restartTimer);
|
121
131
|
stopNode();
|
122
132
|
try { await ctx.dispose(); } catch {}
|
123
133
|
process.exit(0);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hytopia",
|
3
|
-
"version": "0.10.0-prerelease-
|
3
|
+
"version": "0.10.0-prerelease-12",
|
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",
|