homegames-common 1.5.4 → 1.6.0

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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Read(//Users/josephgarcia/homegames/squishHelpers/**)",
5
+ "Read(//Users/squish-138/src/squishHelpers/**)"
6
+ ]
7
+ }
8
+ }
package/game-loader.js CHANGED
@@ -9,35 +9,10 @@ const os = require('os');
9
9
  // SINGLE SOURCE OF TRUTH — all repos should import from here.
10
10
  // ---------------------------------------------------------------------------
11
11
  const squishMap = {
12
- '061': 'squish-061',
13
- '063': 'squish-063',
14
- '0631': 'squish-0631',
15
- '0632': 'squish-0632',
16
- '0633': 'squish-0633',
17
- '0756': 'squish-0756',
18
- '0762': 'squish-0762',
19
- '0765': 'squish-0765',
20
- '0766': 'squish-0766',
21
- '0767': 'squish-0767',
22
- '1000': 'squish-1000',
23
- '1004': 'squish-1004',
24
- '1005': 'squish-1005',
25
- '1006': 'squish-1006',
26
- '1007': 'squish-1007',
27
- '1008': 'squish-1008',
28
- '1009': 'squish-1009',
29
- '1010': 'squish-1010',
30
- '110': 'squish-110',
31
- '120': 'squish-120',
32
- '130': 'squish-130',
33
- '135': 'squish-135',
34
- '136': 'squish-136',
35
- '138': 'squish-138',
36
- // 1.3.9 — adds per-tick coalescing of squish/broadcast + Squisher.flush()
37
- '139': 'squish-139',
12
+ '142': 'squish-142',
38
13
  };
39
14
 
40
- const DEFAULT_SQUISH_VERSION = '135';
15
+ const DEFAULT_SQUISH_VERSION = '142';
41
16
 
42
17
  // ---------------------------------------------------------------------------
43
18
  // Parse squish version from source file using AST (reliable, needs acorn)
@@ -92,6 +92,8 @@ class GameSessionManager {
92
92
  this.maxSessions = opts.maxSessions || 50;
93
93
  this.username = opts.username || null;
94
94
  this.certPath = opts.certPath || null;
95
+ // Port Homenames listens on, so Docker sessions can reach it on the host.
96
+ this.homenamesPort = opts.homenamesPort || null;
95
97
  this.log = opts.log || { info: console.log, error: console.error };
96
98
 
97
99
  // Memory limit for child game sessions. A single Docker-style string
@@ -251,6 +253,13 @@ class GameSessionManager {
251
253
  // which is set in docker-helper.js. HTTPS_ENABLED controls whether
252
254
  // HomenamesHelper uses https — must be false for local dev.
253
255
  extraEnv.HTTPS_ENABLED = 'false';
256
+ // The runner image bakes no config.json, so without this the container
257
+ // falls back to DEFAULT_CONFIG's HOMENAMES_PORT — which only happens to
258
+ // match the host in local dev. Pass the host's real port so player-name
259
+ // lookups (HomenamesHelper) hit the right port on hosted instances.
260
+ const homenamesPort = this.homenamesPort
261
+ || require('./index').getConfigValue('HOMENAMES_PORT', 7100);
262
+ extraEnv.HOMENAMES_PORT = String(homenamesPort);
254
263
 
255
264
  const { containerId } = await runGameContainer({
256
265
  codePath,
package/link-squish.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ // Make homegames-common the single source of squish dependencies.
3
+ //
4
+ // npm does not hoist a `file:` dependency's deps into the consumer's
5
+ // node_modules, so bare require('squish-XXX') calls in consumers (game code,
6
+ // child_game_server, the client bundle) would fail to resolve. Consumers run
7
+ // this as a postinstall step to symlink every package in the canonical
8
+ // squishMap from homegames-common's node_modules into their own.
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const { squishMap } = require('./game-loader');
12
+
13
+ const linkSquish = (consumerRoot) => {
14
+ const targetDir = path.join(consumerRoot, 'node_modules');
15
+ if (!fs.existsSync(targetDir)) {
16
+ throw new Error(`No node_modules directory at ${consumerRoot} — run npm install first`);
17
+ }
18
+
19
+ for (const packageName of Object.values(squishMap)) {
20
+ let source;
21
+ try {
22
+ source = path.dirname(require.resolve(`${packageName}/package.json`));
23
+ } catch (err) {
24
+ throw new Error(`${packageName} is not installed in homegames-common — run npm install in ${__dirname}`);
25
+ }
26
+
27
+ const dest = path.join(targetDir, packageName);
28
+ fs.rmSync(dest, { recursive: true, force: true });
29
+ fs.symlinkSync(source, dest, 'junction');
30
+ console.log(`linked ${packageName} -> ${source}`);
31
+ }
32
+ };
33
+
34
+ module.exports = linkSquish;
35
+
36
+ if (require.main === module) {
37
+ linkSquish(process.cwd());
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homegames-common",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Homegames common tools",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,6 +19,7 @@
19
19
  "dependencies": {
20
20
  "acorn": "^8.11.3",
21
21
  "decompress": "^4.2.1",
22
+ "squish-142": "npm:squishjs@1.4.2",
22
23
  "dockerode": "^4.0.10",
23
24
  "tar": "^7.0.0",
24
25
  "unzipper": "^0.10.11",