xxscreeps-mod-client 0.2.19 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/backend.js +16 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -35,6 +35,10 @@ SCREEPS_MOD_CLIENT_MOUNT_PATH=/play npx xxscreeps start
35
35
 
36
36
  The mod resolves the client bundle from its [`screeps-client`](../screeps-client) dependency at runtime — no separate build step is needed. The shipped bundle is built with `base=./`, but the client resolves some assets (e.g. the sprite atlas under `themes/`) against the server root `/`. Mounting anywhere other than `/` therefore breaks those asset URLs and requires a custom build of `screeps-client` with a matching base — which is why the mount path defaults to `/`.
37
37
 
38
+ ## Login UI feature detection
39
+
40
+ The mod reads `backend.allowGuestAccess`, `backend.allowEmailRegistration`, and `backend.steamApiKey` from `.screepsrc.yaml` and publishes them at `/api/version` as an `xxscreeps-mod-client` feature. `screeps-client` reads this to show or hide the Guest button, the "Create account" link, and the "Login with Steam" button to match what the server actually allows.
41
+
38
42
  ## xxscreeps mode
39
43
 
40
44
  The client bundle shipped with this mod is built with `VITE_XXSCREEPS=true`. In this mode the client auto-connects to its own origin as a guest (read-only) on first load, mirroring `@xxscreeps/client`'s default UX. A "Connect as Guest" button stays available in the login form so users can return to guest mode after signing out.
package/backend.js CHANGED
@@ -2,6 +2,7 @@ import path from 'node:path'
2
2
  import { createRequire } from 'node:module'
3
3
  import { createReadStream, existsSync, readFileSync, statSync } from 'node:fs'
4
4
  import { hooks } from 'xxscreeps/backend/index.js'
5
+ import { config } from 'xxscreeps/config/index.js'
5
6
 
6
7
  const require = createRequire(import.meta.url)
7
8
  const pkg = require('./package.json')
@@ -107,6 +108,21 @@ function sendInjectedIndex(ctx) {
107
108
  ctx.body = renderInjectedIndex(indexFile)
108
109
  }
109
110
 
111
+ // Advertise the server's guest/registration/Steam settings at `/api/version` so
112
+ // screeps-client can gate the corresponding login UI without extra requests.
113
+ // See `.screepsrc.yaml`'s `backend.allowGuestAccess`, `backend.allowEmailRegistration`,
114
+ // and `backend.steamApiKey`.
115
+ hooks.register('version', serverData => {
116
+ const backend = config.backend ?? {}
117
+ serverData.features.push({
118
+ name: 'xxscreeps-mod-client',
119
+ version: 1,
120
+ allowGuestAccess: backend.allowGuestAccess ?? true,
121
+ allowEmailRegistration: backend.allowEmailRegistration ?? false,
122
+ steamLogin: Boolean(backend.steamApiKey),
123
+ })
124
+ })
125
+
110
126
  hooks.register('middleware', koa => {
111
127
  if (!existsSync(indexFile)) {
112
128
  console.error(`[xxscreeps-mod-client] client bundle not found at ${indexFile}. Run "pnpm --filter screeps-client build:embedded:xxscreeps" first.`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xxscreeps-mod-client",
3
- "version": "0.2.19",
3
+ "version": "0.3.0",
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.13.1"
26
+ "screeps-client": "^0.14.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "xxscreeps": "*"