xxscreeps-mod-client 0.2.7 → 0.2.8

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.
Files changed (2) hide show
  1. package/backend.js +7 -2
  2. package/package.json +2 -2
package/backend.js CHANGED
@@ -73,14 +73,19 @@ function sendFile(ctx, filePath, stat) {
73
73
  }
74
74
 
75
75
  function renderInjectedIndex(filePath) {
76
+ const mountDisplay = mountPath === '/' ? '/' : mountPath + '/'
77
+ const baseTag = `<base href="${mountDisplay}">`
76
78
  const metadata = JSON.stringify({
77
79
  kind: 'xxscreeps-mod',
78
80
  packageName: pkg.name,
79
81
  version: pkg.version,
80
82
  }).replace(/</g, '\\u003c')
81
83
  const script = `<script>window.__SCREEPS_CLIENT_EMBEDDED__=${metadata}</script>`
82
- const html = readFileSync(filePath, 'utf8')
83
- return html.includes('</head>') ? html.replace('</head>', `${script}</head>`) : script + html
84
+ let html = readFileSync(filePath, 'utf8')
85
+ // Inject base tag first so relative asset URLs resolve from the mount root,
86
+ // not from the current SPA route (e.g. /room/E11N2).
87
+ html = html.includes('<head>') ? html.replace('<head>', `<head>${baseTag}`) : baseTag + html
88
+ return html.includes('</head>') ? html.replace('</head>', `${script}</head>`) : html + script
84
89
  }
85
90
 
86
91
  function sendInjectedIndex(ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xxscreeps-mod-client",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "xxscreeps mod that serves the screeps-client and connects it to the same server.",
5
5
  "type": "module",
6
6
  "xxscreeps": true,
@@ -23,7 +23,7 @@
23
23
  "node": ">=20"
24
24
  },
25
25
  "dependencies": {
26
- "screeps-client": "^0.5.0"
26
+ "screeps-client": "^0.6.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "xxscreeps": "*"