hytopia 0.3.20 → 0.3.22
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 +81 -2
- package/bun.lock +567 -0
- package/docs/server.baseentitycontrollerevent.md +6 -6
- package/docs/{server.baseentitycontrollereventpayloads.attach.md → server.baseentitycontrollereventpayloads._base_entity_controller.attach_.md} +2 -2
- package/docs/{server.baseentitycontrollereventpayloads.despawn.md → server.baseentitycontrollereventpayloads._base_entity_controller.despawn_.md} +2 -2
- package/docs/{server.baseentitycontrollereventpayloads.detach.md → server.baseentitycontrollereventpayloads._base_entity_controller.detach_.md} +2 -2
- package/docs/{server.baseentitycontrollereventpayloads.spawn.md → server.baseentitycontrollereventpayloads._base_entity_controller.spawn_.md} +2 -2
- package/docs/{server.baseentitycontrollereventpayloads.tick.md → server.baseentitycontrollereventpayloads._base_entity_controller.tick_.md} +2 -2
- package/docs/{server.baseentitycontrollereventpayloads.tickwithplayerinput.md → server.baseentitycontrollereventpayloads._base_entity_controller.tick_with_player_input_.md} +2 -2
- package/docs/server.baseentitycontrollereventpayloads.md +10 -10
- package/docs/server.eventrouter.md +0 -84
- package/package.json +4 -1
- package/server.api.json +167 -1038
- package/server.d.ts +6 -13
- package/server.js +1 -1
- package/docs/server.eventrouter.emit_1.md +0 -63
- package/docs/server.eventrouter.emitwithglobal_1.md +0 -63
- package/docs/server.eventrouter.emitwithworld_1.md +0 -77
- package/docs/server.eventrouter.final_1.md +0 -63
- package/docs/server.eventrouter.off_1.md +0 -63
- package/docs/server.eventrouter.on_1.md +0 -63
- package/docs/server.eventrouter.once_1.md +0 -63
package/bin/scripts.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
3
|
const { execSync } = require('child_process');
|
4
|
+
const archiver = require('archiver');
|
4
5
|
const fs = require('fs');
|
5
6
|
const path = require('path');
|
6
7
|
const readline = require('readline');
|
@@ -18,7 +19,8 @@ const flags = {};
|
|
18
19
|
// Execute the appropriate command
|
19
20
|
const commandHandlers = {
|
20
21
|
'init': init,
|
21
|
-
'init-mcp': initMcp
|
22
|
+
'init-mcp': initMcp,
|
23
|
+
'package': packageProject
|
22
24
|
};
|
23
25
|
|
24
26
|
const handler = commandHandlers[command];
|
@@ -47,7 +49,7 @@ function parseCommandLineFlags() {
|
|
47
49
|
*/
|
48
50
|
function displayAvailableCommands(command) {
|
49
51
|
console.log('Unknown command: ' + command);
|
50
|
-
console.log('Supported commands: init, init-mcp');
|
52
|
+
console.log('Supported commands: init, init-mcp, package');
|
51
53
|
}
|
52
54
|
|
53
55
|
/**
|
@@ -233,6 +235,83 @@ function initEditorMcp(editorName, editorFlag) {
|
|
233
235
|
logDivider();
|
234
236
|
}
|
235
237
|
|
238
|
+
/**
|
239
|
+
* Package command
|
240
|
+
*
|
241
|
+
* Creates a zip file of the project directory, excluding node_modules,
|
242
|
+
* package-lock.json, bun.lock, and bun.lockb files.
|
243
|
+
*
|
244
|
+
* @example
|
245
|
+
* `bunx hytopia package`
|
246
|
+
*/
|
247
|
+
function packageProject() {
|
248
|
+
const sourceDir = process.cwd();
|
249
|
+
const projectName = path.basename(sourceDir);
|
250
|
+
const outputFile = path.join(sourceDir, `${projectName}.zip`);
|
251
|
+
|
252
|
+
console.log(`📦 Packaging project "${projectName}"...`);
|
253
|
+
|
254
|
+
// Create a file to stream archive data to
|
255
|
+
const output = fs.createWriteStream(outputFile);
|
256
|
+
const archive = archiver('zip', {
|
257
|
+
zlib: { level: 9 } // Sets the compression level
|
258
|
+
});
|
259
|
+
|
260
|
+
// Listen for all archive data to be written
|
261
|
+
output.on('close', function() {
|
262
|
+
console.log(`✅ Project packaged successfully! (${archive.pointer()} total bytes)`);
|
263
|
+
console.log(`📁 Package saved to: ${outputFile}`);
|
264
|
+
});
|
265
|
+
|
266
|
+
// Good practice to catch warnings (ie stat failures and other non-blocking errors)
|
267
|
+
archive.on('warning', function(err) {
|
268
|
+
if (err.code === 'ENOENT') {
|
269
|
+
console.warn('⚠️ Warning:', err);
|
270
|
+
} else {
|
271
|
+
throw err;
|
272
|
+
}
|
273
|
+
});
|
274
|
+
|
275
|
+
// Catch errors
|
276
|
+
archive.on('error', function(err) {
|
277
|
+
console.error('❌ Error during packaging:', err);
|
278
|
+
throw err;
|
279
|
+
});
|
280
|
+
|
281
|
+
// Pipe archive data to the file
|
282
|
+
archive.pipe(output);
|
283
|
+
|
284
|
+
// Get all files and directories in the source directory
|
285
|
+
const items = fs.readdirSync(sourceDir);
|
286
|
+
|
287
|
+
// Files/directories to exclude
|
288
|
+
const excludeItems = [
|
289
|
+
'node_modules',
|
290
|
+
'package-lock.json',
|
291
|
+
'bun.lock',
|
292
|
+
'bun.lockb',
|
293
|
+
`${projectName}.zip` // Exclude the output file itself
|
294
|
+
];
|
295
|
+
|
296
|
+
// Add each item to the archive, excluding the ones in the exclude list
|
297
|
+
items.forEach(item => {
|
298
|
+
const itemPath = path.join(sourceDir, item);
|
299
|
+
|
300
|
+
if (!excludeItems.includes(item)) {
|
301
|
+
const stats = fs.statSync(itemPath);
|
302
|
+
|
303
|
+
if (stats.isDirectory()) {
|
304
|
+
archive.directory(itemPath, item);
|
305
|
+
} else {
|
306
|
+
archive.file(itemPath, { name: item });
|
307
|
+
}
|
308
|
+
}
|
309
|
+
});
|
310
|
+
|
311
|
+
// Finalize the archive
|
312
|
+
archive.finalize();
|
313
|
+
}
|
314
|
+
|
236
315
|
/**
|
237
316
|
* Prints a divider line for better console output readability
|
238
317
|
*/
|