hytopia 0.10.11-prerelease-3 → 0.10.11-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 +19 -63
- package/package.json +3 -2
- package/server.mjs +1 -1
- package/bin/buildInject.js +0 -8
- package/bin/inject-dirname.js +0 -8
package/bin/scripts.js
CHANGED
@@ -68,18 +68,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
68
68
|
async function build() {
|
69
69
|
console.log('🔧 Building project...');
|
70
70
|
|
71
|
-
|
72
|
-
entryPoints: ['index.ts'],
|
73
|
-
outfile: './index.mjs',
|
74
|
-
bundle: true,
|
75
|
-
format: 'esm',
|
76
|
-
platform: 'node',
|
77
|
-
target: 'node24',
|
78
|
-
sourcemap: 'inline',
|
79
|
-
inject: [path.join(__dirname, 'buildInject.js')],
|
80
|
-
mainFields: ['module', 'main'],
|
81
|
-
conditions: ['import', 'node']
|
82
|
-
});
|
71
|
+
execSync('npx bun build --target=node --format=esm --outfile=index.mjs index.ts', { stdio: 'inherit' });
|
83
72
|
}
|
84
73
|
|
85
74
|
/**
|
@@ -87,58 +76,25 @@ async function build() {
|
|
87
76
|
* and watches for changes.
|
88
77
|
*/
|
89
78
|
function start() {
|
90
|
-
(
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
const ctx = await esbuild.context({
|
106
|
-
entryPoints: ['index.ts'],
|
107
|
-
outfile: './index.mjs',
|
108
|
-
bundle: true,
|
109
|
-
format: 'esm',
|
110
|
-
platform: 'node',
|
111
|
-
target: 'node24',
|
112
|
-
sourcemap: 'inline',
|
113
|
-
inject: [path.join(__dirname, 'buildInject.js')],
|
114
|
-
mainFields: ['module', 'main'],
|
115
|
-
conditions: ['import', 'node'],
|
116
|
-
plugins: [{
|
117
|
-
name: 'restart-after-build',
|
118
|
-
setup(build) {
|
119
|
-
build.onStart(() => {
|
120
|
-
if (restartTimer) { clearTimeout(restartTimer); restartTimer = null; }
|
121
|
-
});
|
122
|
-
build.onEnd((result) => {
|
123
|
-
if (result.errors?.length) return;
|
124
|
-
restartTimer = setTimeout(restartNode, 150);
|
125
|
-
});
|
126
|
-
}
|
127
|
-
}]
|
128
|
-
});
|
129
|
-
|
130
|
-
await ctx.watch();
|
131
|
-
|
132
|
-
const cleanup = async () => {
|
133
|
-
if (restartTimer) clearTimeout(restartTimer);
|
134
|
-
stopNode();
|
135
|
-
try { await ctx.dispose(); } catch {}
|
136
|
-
process.exit(0);
|
137
|
-
};
|
79
|
+
console.log('🚀 Starting development server with nodemon...');
|
80
|
+
|
81
|
+
const nodemon = spawn('npx', [
|
82
|
+
'nodemon',
|
83
|
+
'--watch', 'index.ts',
|
84
|
+
'--watch', 'src',
|
85
|
+
'--ext', 'ts,js',
|
86
|
+
'--exec', 'hytopia build && node --enable-source-maps index.mjs'
|
87
|
+
], { stdio: 'inherit' });
|
88
|
+
|
89
|
+
// Cleanup on exit
|
90
|
+
const cleanup = () => {
|
91
|
+
nodemon?.kill();
|
92
|
+
process.exit(0);
|
93
|
+
};
|
138
94
|
|
139
|
-
|
140
|
-
|
141
|
-
|
95
|
+
process.on('SIGINT', cleanup);
|
96
|
+
process.on('SIGTERM', cleanup);
|
97
|
+
nodemon.on('error', (err) => console.error('❌ Nodemon error:', err));
|
142
98
|
}
|
143
99
|
|
144
100
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hytopia",
|
3
|
-
"version": "0.10.11-prerelease-
|
3
|
+
"version": "0.10.11-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,8 @@
|
|
58
58
|
"dependencies": {
|
59
59
|
"@gltf-transform/cli": "^4.2.1",
|
60
60
|
"archiver": "^7.0.1",
|
61
|
-
"
|
61
|
+
"bun": "^1.2.20",
|
62
|
+
"nodemon": "^3.1.10",
|
62
63
|
"ws": "^8.18.2"
|
63
64
|
},
|
64
65
|
"optionalDependencies": {
|
package/server.mjs
CHANGED
@@ -447,7 +447,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
|
|
447
447
|
xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
|
448
448
|
6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
|
449
449
|
0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
|
450
|
-
-----END RSA PRIVATE KEY-----`;var Ef=process.env.PORT??8080,If="0.10.11-prerelease-
|
450
|
+
-----END RSA PRIVATE KEY-----`;var Ef=process.env.PORT??8080,If="0.10.11-prerelease-4",_f;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(_f||={});class F3 extends B0{static instance=new F3;_webserver=WU.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:If,runtime:"node"})}),this._webserver.use(WU.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(WU.default.static(La1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Ba1.createServer(this._webserver):ja1.createServer({key:KU.existsSync("assets/certs/localhost.key")?KU.readFileSync("assets/certs/localhost.key"):zY0,cert:KU.existsSync("assets/certs/localhost.crt")?KU.readFileSync("assets/certs/localhost.crt"):GY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(Ef,this._onStarted),console.info(`WebServer.start(): Server running on port ${Ef}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=Da1.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&M7.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await O4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
|
451
451
|
Content-Type: text/plain\r
|
452
452
|
Content-Length: ${W.length}\r
|
453
453
|
Connection: close\r
|
package/bin/buildInject.js
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import { fileURLToPath } from 'url';
|
2
|
-
import { dirname } from 'path';
|
3
|
-
import { createRequire } from 'module';
|
4
|
-
|
5
|
-
// esbuild inject requires global assignments, not exports
|
6
|
-
globalThis.__filename = fileURLToPath(import.meta.url);
|
7
|
-
globalThis.__dirname = dirname(__filename);
|
8
|
-
globalThis.require = createRequire(import.meta.url);
|
package/bin/inject-dirname.js
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import { fileURLToPath } from 'url';
|
2
|
-
import { dirname } from 'path';
|
3
|
-
import { createRequire } from 'module';
|
4
|
-
|
5
|
-
// esbuild inject requires global assignments, not exports
|
6
|
-
globalThis.__filename = fileURLToPath(import.meta.url);
|
7
|
-
globalThis.__dirname = dirname(__filename);
|
8
|
-
globalThis.require = createRequire(import.meta.url);
|