@diffenderfer-games/hub 2.0.0-next.0 → 2.0.0-next.1
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/CHANGELOG.md +9 -0
- package/LICENSE +21 -21
- package/README.md +191 -139
- package/dist/doctor/cli.mjs +49 -19
- package/dist/doctor/cli.mjs.map +1 -1
- package/dist/shared/client-version.gen.js +1 -1
- package/dist/shared/daily.js +1 -1
- package/dist/shared/globals.js +8 -3
- package/dist/shared/globals.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/package.json +89 -89
- package/src/auto.ts +39 -39
- package/src/core/connection.ts +299 -299
- package/src/core/errors.ts +147 -147
- package/src/core/game-data.ts +38 -38
- package/src/core/hub-economy.ts +179 -179
- package/src/core/hub-progress.ts +205 -205
- package/src/core/hub.ts +131 -131
- package/src/core/menu-control.ts +61 -61
- package/src/core/offline/events.ts +50 -50
- package/src/core/offline/favorites.ts +21 -21
- package/src/core/offline/local-store.ts +261 -261
- package/src/core/offline/queue.ts +171 -171
- package/src/core/page.ts +74 -74
- package/src/core/rest/endpoint-types.ts +22 -22
- package/src/core/rest/rest-client.ts +152 -152
- package/src/core/storage/json-guards.ts +74 -74
- package/src/core/storage/key-value.ts +66 -66
- package/src/core/ticket.ts +43 -43
- package/src/core/types.ts +134 -134
- package/src/core/version/client-version.gen.ts +1 -1
- package/src/core/version/hub-version.ts +62 -62
- package/src/core/version/semver.ts +97 -97
- package/src/daily/daily-system.ts +161 -161
- package/src/daily/page-daily.ts +36 -36
- package/src/daily/types.ts +67 -67
- package/src/daily.ts +10 -10
- package/src/doctor/checks.ts +78 -76
- package/src/doctor/cli.ts +98 -106
- package/src/doctor/hub-version-fetch.ts +43 -0
- package/src/doctor/tsconfig.json +12 -12
- package/src/globals.ts +115 -110
- package/src/index.ts +50 -50
- package/src/input/device-state.ts +146 -146
- package/src/input/edges.ts +55 -55
- package/src/input/gamepad.ts +61 -61
- package/src/input/input-events.ts +32 -32
- package/src/input/input-registry.ts +164 -164
- package/src/input/input-system.ts +393 -393
- package/src/input/legacy-controls.ts +64 -64
- package/src/input/nav-state.ts +191 -191
- package/src/input/navigator.ts +171 -171
- package/src/input/on-screen-controls.ts +101 -101
- package/src/input/page-control.ts +43 -43
- package/src/input/page-input.ts +193 -193
- package/src/input/player-remaps.ts +77 -77
- package/src/input/source-values.ts +116 -116
- package/src/input/spatial.ts +47 -47
- package/src/input/types.ts +331 -331
- package/src/input/zero-config.ts +177 -177
- package/src/input.ts +22 -22
- package/src/mp.ts +10 -10
- package/src/overlay/controls-panel.ts +163 -163
- package/src/overlay/dom.ts +46 -46
- package/src/overlay/layout-clusters.ts +162 -162
- package/src/overlay/layout-geometry.ts +136 -136
- package/src/overlay/layout.ts +203 -203
- package/src/overlay/listener-scope.ts +23 -23
- package/src/overlay/on-screen-keyboard.ts +137 -137
- package/src/overlay/overlay.ts +208 -208
- package/src/overlay/styles.ts +9 -9
- package/src/overlay/virtual-controls.ts +262 -262
- package/src/race.ts +10 -10
- package/src/realtime/bridge.ts +121 -121
- package/src/realtime/cross-bundle.ts +29 -29
- package/src/realtime/fallback-notice.ts +48 -48
- package/src/realtime/hub-link.ts +65 -65
- package/src/realtime/latest-state.ts +33 -33
- package/src/realtime/multiplayer-forwarder.ts +28 -28
- package/src/realtime/multiplayer-types.ts +52 -52
- package/src/realtime/page-runtime.ts +60 -60
- package/src/realtime/race-forwarder.ts +59 -59
- package/src/realtime/race-types.ts +132 -132
- package/src/realtime/room-types.ts +125 -125
- package/src/realtime/rooms-forwarder.ts +79 -79
- package/src/realtime/runtime-api.ts +49 -49
- package/src/realtime/runtime-opener.ts +61 -61
- package/src/realtime/social-forwarder.ts +72 -72
- package/src/realtime/social-types.ts +78 -78
- package/src/realtime/types.ts +53 -53
- package/src/realtime/wire-types.ts +72 -72
- package/src/rooms.ts +10 -10
- package/src/social.ts +18 -18
- package/src/types.ts +13 -13
- package/src/uistack/page-stack.ts +45 -45
- package/src/uistack/play-suspension.ts +82 -82
- package/src/uistack/types.ts +76 -76
- package/src/uistack/ui-stack.ts +144 -144
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @diffenderfer-games/hub
|
|
2
|
+
|
|
3
|
+
## 2.0.0-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Follow-ups from the Bubble Pop pilot. `hub-doctor` gives up after `--timeout` ms (default 10 s) and fails with `hub unreachable at <url>` instead of hanging. A v1 vendored singleton adopted on the page is now recorded in `window.__DG__` as `{ version: 'v1' }`. The README covers exact pins for prereleases, sharing the page with the host's `/_hub/hub.js`, and testing against the hub.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @diffenderfer-games/hub-contract@2.0.0-next.1
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Philip Diffenderfer
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Philip Diffenderfer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,139 +1,191 @@
|
|
|
1
|
-
# @diffenderfer-games/hub
|
|
2
|
-
|
|
3
|
-
The client library for games on [diffenderfer.games](https://diffenderfer.games):
|
|
4
|
-
accounts, saves, stats, leaderboards, inventory and trades, daily challenges,
|
|
5
|
-
the input system (keyboard, touch and gamepad), and the social, multiplayer,
|
|
6
|
-
rooms and race namespaces. It is typed from the hub's wire contract
|
|
7
|
-
(`@diffenderfer-games/hub-contract`), ships ES modules with `.d.ts` files, and
|
|
8
|
-
carries no zod at runtime.
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
```sh
|
|
13
|
-
npm install @diffenderfer-games/hub
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
1
|
+
# @diffenderfer-games/hub
|
|
2
|
+
|
|
3
|
+
The client library for games on [diffenderfer.games](https://diffenderfer.games):
|
|
4
|
+
accounts, saves, stats, leaderboards, inventory and trades, daily challenges,
|
|
5
|
+
the input system (keyboard, touch and gamepad), and the social, multiplayer,
|
|
6
|
+
rooms and race namespaces. It is typed from the hub's wire contract
|
|
7
|
+
(`@diffenderfer-games/hub-contract`), ships ES modules with `.d.ts` files, and
|
|
8
|
+
carries no zod at runtime.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @diffenderfer-games/hub
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Prereleases: pin the exact version.** While the package is on `2.0.0-next.N`,
|
|
17
|
+
a caret range does not move between prereleases the way you might expect, so
|
|
18
|
+
install with `--save-exact` and bump on purpose:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install --save-exact @diffenderfer-games/hub@2.0.0-next.1
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The `next` dist-tag always names the newest prerelease. `latest` points at the
|
|
25
|
+
same prerelease for now. It moves to `2.0.0` with the first stable release,
|
|
26
|
+
after which ordinary `^2.0.0` ranges are fine.
|
|
27
|
+
|
|
28
|
+
ESM only, for browsers (ES2020: Safari 14+, current Chrome, Edge and Firefox).
|
|
29
|
+
Node 20+ for the `hub-doctor` command.
|
|
30
|
+
|
|
31
|
+
## Use
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { hub } from '@diffenderfer-games/hub';
|
|
35
|
+
|
|
36
|
+
const { user } = await hub.me();
|
|
37
|
+
await hub.ensureGuest(); // a guest account, so progress saves without a sign-in
|
|
38
|
+
await hub.putSave('auto', { level: 7, gold: 120 });
|
|
39
|
+
await hub.submitScore('highscore', 9001, { title: 'High Score' });
|
|
40
|
+
hub.recordPlay();
|
|
41
|
+
|
|
42
|
+
hub.input.define({ groups: { play: { inputs: { jump: { keys: [' '], gamepad: { button: 0 } } } } } });
|
|
43
|
+
hub.input.enable('play');
|
|
44
|
+
hub.daily.define({ play: (challenge) => startLevel(challenge.seed) });
|
|
45
|
+
hub.overlay.autoPause({ pause, resume });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
In a game the host serves, the slug and the API base are read from the page.
|
|
49
|
+
For anything else, create a client yourself:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { createHub } from '@diffenderfer-games/hub';
|
|
53
|
+
|
|
54
|
+
const demo = createHub({ slug: 'my-game', apiBase: '/_api', offline: 'auto' });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A game's own JSON is typed by the game: `hub.getSave<MySave>('auto')`,
|
|
58
|
+
`hub.putSave<MySave>('auto', save)`, `hub.getProfile<MyProfile>()`.
|
|
59
|
+
|
|
60
|
+
## Entry points
|
|
61
|
+
|
|
62
|
+
| Import | What it has |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `@diffenderfer-games/hub` | `hub`, `createHub`, `Hub`, the errors, every client type, and the input and daily exports |
|
|
65
|
+
| `@diffenderfer-games/hub/input` | `getInput`, `InputSystem`, the on-screen control layout, `getUiStack` |
|
|
66
|
+
| `@diffenderfer-games/hub/daily` | `getDaily`, `DailySystem` |
|
|
67
|
+
| `@diffenderfer-games/hub/race`, `/social`, `/mp`, `/rooms` | one namespace each (`race`, `social` with `presence` and `notify`, `mp`, `rooms`) |
|
|
68
|
+
| `@diffenderfer-games/hub/types` | type-only: every contract type (requests, replies, entities, error codes, socket ops and events, the `game.*` manifest) |
|
|
69
|
+
| `@diffenderfer-games/hub/auto` | everything above, and it sets `window.HubSDK` (what `/_hub/hub.js` is built from) |
|
|
70
|
+
|
|
71
|
+
The namespaces also hang off `hub` (`hub.input`, `hub.daily`, `hub.race`,
|
|
72
|
+
`hub.social`, `hub.presence`, `hub.notify`, `hub.mp`, `hub.rooms`,
|
|
73
|
+
`hub.overlay`, `hub.menu`), created on first use.
|
|
74
|
+
|
|
75
|
+
## Errors
|
|
76
|
+
|
|
77
|
+
Every call rejects with a `HubError` when it fails. `status` is the HTTP
|
|
78
|
+
status, or `undefined` when the hub could not be reached (`isOffline`).
|
|
79
|
+
`code`, `reason`, `hint` and `retryAfterMs` come from the hub's error body.
|
|
80
|
+
|
|
81
|
+
- `ContentRejectedError`: the safety filter refused some text (HTTP 422).
|
|
82
|
+
Keep the player's draft and show `hint`.
|
|
83
|
+
- `OfflineError`: an action that needs the hub was tried offline.
|
|
84
|
+
- `code: 'unsupported_by_hub'`: the hub does not have this call yet (the game
|
|
85
|
+
uses a newer client than the deployed hub). Deploy the hub first.
|
|
86
|
+
|
|
87
|
+
The analytics calls (`recordPlay`, `heartbeat`, `event`) never throw.
|
|
88
|
+
|
|
89
|
+
## Offline
|
|
90
|
+
|
|
91
|
+
With `offline: 'auto'` (the default), reads fall back to a cache in
|
|
92
|
+
`localStorage` when the hub can't be reached, and writes (saves, stats,
|
|
93
|
+
scores, profile) apply to the cache at once and are queued. The queue replays
|
|
94
|
+
in order when the connection returns; `hub.sync()` replays it on demand,
|
|
95
|
+
`hub.pending()` counts what waits, and `hub.onStatus(listener)` reports
|
|
96
|
+
changes. `hub.prefetchAll()` warms the cache for every game in one request.
|
|
97
|
+
`offline: 'always'` never touches the network (develop without a hub);
|
|
98
|
+
`offline: 'never'` always throws instead.
|
|
99
|
+
|
|
100
|
+
The cache and queue use the same `localStorage` keys as the old vendored
|
|
101
|
+
client, so a game that switches to this package keeps its players' queued
|
|
102
|
+
progress.
|
|
103
|
+
|
|
104
|
+
## Games without a build step
|
|
105
|
+
|
|
106
|
+
Keep `import('/_hub/hub.js')` or `window.HubSDK.hub`: the host serves a
|
|
107
|
+
bundle of this package's `./auto` entry, at the version the host was built
|
|
108
|
+
with. Install the package as a dev dependency only if you want editor types:
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
/** @type {import('@diffenderfer-games/hub').Hub} */
|
|
112
|
+
const hub = window.HubSDK.hub;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Sharing the page with the host's `/_hub/hub.js`
|
|
116
|
+
|
|
117
|
+
Every game page also gets the host's menu and social runtime, which use the
|
|
118
|
+
host's own copy of this client (`/_hub/hub.js`, built from the version the host
|
|
119
|
+
was deployed with). Your bundled copy and the host's cooperate. The page-wide
|
|
120
|
+
pieces (the input system, daily challenges, the realtime API) are registered
|
|
121
|
+
once on `window.__DG__`, each with the version that created it:
|
|
122
|
+
|
|
123
|
+
- **Same shape** (the usual case): the first one wins and both copies share
|
|
124
|
+
it, so an older patch version on either side is harmless.
|
|
125
|
+
- **A different shape** (a major change): your game's copy owns input and
|
|
126
|
+
daily; the host's runtime owns realtime. The mismatch is logged once in the
|
|
127
|
+
console with the fix: `npm update @diffenderfer-games/hub`.
|
|
128
|
+
- **A v1 vendored copy** already on the page is shared too, and recorded as
|
|
129
|
+
`{ version: 'v1' }`.
|
|
130
|
+
|
|
131
|
+
The v1 globals (`window.__HUB_INPUT__`, `__HUB_DAILY__`, `__HUB_RT__`) stay as
|
|
132
|
+
aliases. Don't create your own singletons; `hub.input`, `hub.daily` and the
|
|
133
|
+
forwarders always return the shared ones.
|
|
134
|
+
|
|
135
|
+
## Versions
|
|
136
|
+
|
|
137
|
+
The client sends its version as `x-hub-client`. `hub.hubVersion()` reads the
|
|
138
|
+
hub's `GET /_api/version` (`{ server, contract, supported, deprecated }`) once
|
|
139
|
+
per page, and `hub.clientSupport()` says whether this client is `supported`,
|
|
140
|
+
`deprecated` or `unsupported` (`unknown` on a hub from before versioning).
|
|
141
|
+
|
|
142
|
+
The hub supports the current major and the previous one. Update with
|
|
143
|
+
`npm update @diffenderfer-games/hub`.
|
|
144
|
+
|
|
145
|
+
## hub-doctor
|
|
146
|
+
|
|
147
|
+
Run it in a game's folder, in CI and before pushing:
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
npx hub-doctor # checks against https://diffenderfer.games
|
|
151
|
+
npx hub-doctor --offline # skip the version check
|
|
152
|
+
npx hub-doctor --timeout 5000 # wait at most 5 s for the hub (default 10 s)
|
|
153
|
+
npx hub-doctor --hub http://localhost:8080 --dir ../my-game --json
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
An unreachable or slow hub is an error (`hub unreachable at <url> (...)`) and
|
|
157
|
+
exits non-zero, so CI notices. Use `--offline` where CI has no network.
|
|
158
|
+
|
|
159
|
+
It fails when the installed client is outside the hub's `supported` range or
|
|
160
|
+
the `package.json` `game.*` block does not match the manifest schema, and it
|
|
161
|
+
warns when the client is deprecated or a vendored `src/hub/` copy (or
|
|
162
|
+
`scripts/sync-hub.mjs`) is still around.
|
|
163
|
+
|
|
164
|
+
## Testing your game against the hub
|
|
165
|
+
|
|
166
|
+
The hub's test kit lives in the host repo (`test/helpers/`). Point your
|
|
167
|
+
game's tests at a checkout of it with `DG_HOST`; the default is
|
|
168
|
+
`../diffenderfer-games`. It boots a real hub on a free port for each test
|
|
169
|
+
file:
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
DG_HOST=../diffenderfer-games HUB_IMPL=next npm run test:hub
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`HUB_IMPL=next` runs the TypeScript hub and host that production runs. Without
|
|
176
|
+
it, the kit boots the old hub (`src/index.js`), which is kept only as a
|
|
177
|
+
rollback path until it is deleted; test against `next`. The checkout needs
|
|
178
|
+
`npm ci` at its root and in `next/`.
|
|
179
|
+
|
|
180
|
+
## Moving from the vendored copy
|
|
181
|
+
|
|
182
|
+
1. `npm install @diffenderfer-games/hub`.
|
|
183
|
+
2. Change `from './hub/hub'` (or `'./hub'`) to `from '@diffenderfer-games/hub'`.
|
|
184
|
+
3. Delete `src/hub/` and `scripts/sync-hub.mjs`.
|
|
185
|
+
4. Add `npx hub-doctor` to the game's CI.
|
|
186
|
+
|
|
187
|
+
Every method name is unchanged.
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT
|
package/dist/doctor/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { parseArgs } from "node:util";
|
|
|
5
5
|
import { GamePackageJson, HubVersion } from "@diffenderfer-games/hub-contract";
|
|
6
6
|
//#region src/core/version/client-version.gen.ts
|
|
7
7
|
/** This client's package version, sent as `x-hub-client` on REST calls and `client` in `hello`. */
|
|
8
|
-
const HUB_CLIENT_VERSION = "2.0.0-next.
|
|
8
|
+
const HUB_CLIENT_VERSION = "2.0.0-next.1";
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/core/version/semver.ts
|
|
11
11
|
const VERSION_PATTERN = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
@@ -81,6 +81,39 @@ function clientSupport(hubVersion, version = HUB_CLIENT_VERSION) {
|
|
|
81
81
|
return satisfiesRange(version, hubVersion.deprecated) ? "deprecated" : "supported";
|
|
82
82
|
}
|
|
83
83
|
//#endregion
|
|
84
|
+
//#region src/doctor/hub-version-fetch.ts
|
|
85
|
+
/**
|
|
86
|
+
* Reading the hub's `GET /_api/version` for `hub-doctor`, with a timeout so a
|
|
87
|
+
* hung or unreachable hub fails a game's CI quickly instead of stalling it.
|
|
88
|
+
*/
|
|
89
|
+
/** How long the doctor waits for the hub by default, ms. */
|
|
90
|
+
const DEFAULT_HUB_TIMEOUT_MS = 1e4;
|
|
91
|
+
/** Whether a version lookup failed. */
|
|
92
|
+
function isHubUnreachable(lookup) {
|
|
93
|
+
return lookup !== null && "unreachableUrl" in lookup;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The hub's version: `null` for a hub from before versioning (404), a
|
|
97
|
+
* {@link HubUnreachable} when it can't be read within `timeoutMs`.
|
|
98
|
+
*/
|
|
99
|
+
async function fetchHubVersion(hubUrl, timeoutMs = DEFAULT_HUB_TIMEOUT_MS) {
|
|
100
|
+
const url = new URL("/_api/version", hubUrl).toString();
|
|
101
|
+
try {
|
|
102
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
|
|
103
|
+
if (response.status === 404) return null;
|
|
104
|
+
if (!response.ok) return {
|
|
105
|
+
unreachableUrl: url,
|
|
106
|
+
reason: `HTTP ${String(response.status)}`
|
|
107
|
+
};
|
|
108
|
+
return HubVersion.parse(await response.json());
|
|
109
|
+
} catch (failure) {
|
|
110
|
+
return {
|
|
111
|
+
unreachableUrl: url,
|
|
112
|
+
reason: failure instanceof Error && (failure.name === "TimeoutError" || failure.name === "AbortError") ? `timed out after ${String(timeoutMs)} ms` : failure instanceof Error ? failure.message : String(failure)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
84
117
|
//#region src/doctor/checks.ts
|
|
85
118
|
/**
|
|
86
119
|
* The checks `hub-doctor` runs on a game (plan §4.3.7). Each returns
|
|
@@ -90,14 +123,15 @@ function clientSupport(hubVersion, version = HUB_CLIENT_VERSION) {
|
|
|
90
123
|
const UPDATE_FIX = "run `npm update @diffenderfer-games/hub`";
|
|
91
124
|
/**
|
|
92
125
|
* The installed client against the hub's `/_api/version`: outside
|
|
93
|
-
* `supported` is an error, `deprecated` a warning
|
|
94
|
-
* versioning)
|
|
126
|
+
* `supported` is an error, `deprecated` a warning, `null` (a hub from before
|
|
127
|
+
* versioning) is only reported. An unreachable or slow hub is an error, so a
|
|
128
|
+
* game's CI notices (`--offline` skips the check).
|
|
95
129
|
*/
|
|
96
130
|
function checkClientVersion(installedVersion, hubVersion) {
|
|
97
|
-
if (hubVersion
|
|
98
|
-
level: "
|
|
131
|
+
if (isHubUnreachable(hubVersion)) return [{
|
|
132
|
+
level: "error",
|
|
99
133
|
check: "version",
|
|
100
|
-
message: `
|
|
134
|
+
message: `hub unreachable at ${hubVersion.unreachableUrl} (${hubVersion.reason}); check --hub, or pass --offline to skip the version check`
|
|
101
135
|
}];
|
|
102
136
|
switch (clientSupport(hubVersion, installedVersion)) {
|
|
103
137
|
case "unsupported": return [{
|
|
@@ -158,7 +192,7 @@ function checkManifest(packageJson) {
|
|
|
158
192
|
* game's folder, in CI and before pushing:
|
|
159
193
|
*
|
|
160
194
|
* ```sh
|
|
161
|
-
* npx hub-doctor [--dir <game folder>] [--hub <url>] [--offline] [--json]
|
|
195
|
+
* npx hub-doctor [--dir <game folder>] [--hub <url>] [--timeout <ms>] [--offline] [--json]
|
|
162
196
|
* ```
|
|
163
197
|
*
|
|
164
198
|
* - the installed `@diffenderfer-games/hub` against the hub's
|
|
@@ -174,6 +208,7 @@ function readOptions() {
|
|
|
174
208
|
const { values } = parseArgs({ options: {
|
|
175
209
|
dir: { type: "string" },
|
|
176
210
|
hub: { type: "string" },
|
|
211
|
+
timeout: { type: "string" },
|
|
177
212
|
offline: {
|
|
178
213
|
type: "boolean",
|
|
179
214
|
default: false
|
|
@@ -183,9 +218,15 @@ function readOptions() {
|
|
|
183
218
|
default: false
|
|
184
219
|
}
|
|
185
220
|
} });
|
|
221
|
+
const timeoutMs = values.timeout === void 0 ? DEFAULT_HUB_TIMEOUT_MS : Number(values.timeout);
|
|
222
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
223
|
+
process.stderr.write("hub-doctor: --timeout must be a positive number of milliseconds\n");
|
|
224
|
+
process.exit(2);
|
|
225
|
+
}
|
|
186
226
|
return {
|
|
187
227
|
gameDir: resolve(values.dir ?? "."),
|
|
188
228
|
hubUrl: values.hub ?? DEFAULT_HUB_URL,
|
|
229
|
+
timeoutMs,
|
|
189
230
|
isOffline: values.offline,
|
|
190
231
|
isJson: values.json
|
|
191
232
|
};
|
|
@@ -201,20 +242,9 @@ function installedClientVersion(gameDir) {
|
|
|
201
242
|
} catch {}
|
|
202
243
|
return HUB_CLIENT_VERSION;
|
|
203
244
|
}
|
|
204
|
-
/** The hub's `/_api/version`: `null` for a hub without it, an `Error` when unreachable. */
|
|
205
|
-
async function fetchHubVersion(hubUrl) {
|
|
206
|
-
try {
|
|
207
|
-
const response = await fetch(new URL("/_api/version", hubUrl));
|
|
208
|
-
if (response.status === 404) return null;
|
|
209
|
-
if (!response.ok) return /* @__PURE__ */ new Error(`HTTP ${String(response.status)}`);
|
|
210
|
-
return HubVersion.parse(await response.json());
|
|
211
|
-
} catch (failure) {
|
|
212
|
-
return failure instanceof Error ? failure : new Error(String(failure));
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
245
|
async function runDoctor(options) {
|
|
216
246
|
const findings = [];
|
|
217
|
-
if (!options.isOffline) findings.push(...checkClientVersion(installedClientVersion(options.gameDir), await fetchHubVersion(options.hubUrl)));
|
|
247
|
+
if (!options.isOffline) findings.push(...checkClientVersion(installedClientVersion(options.gameDir), await fetchHubVersion(options.hubUrl, options.timeoutMs)));
|
|
218
248
|
findings.push(...checkVendoredCopies(options.gameDir));
|
|
219
249
|
try {
|
|
220
250
|
findings.push(...checkManifest(readJsonFile(join(options.gameDir, "package.json"))));
|
package/dist/doctor/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../../src/core/version/client-version.gen.ts","../../src/core/version/semver.ts","../../src/core/version/hub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AA,GACxD,OAAO,oBAAoB,KAAA,IAAY,KAAK;EAE9C,MAAM,aAAa,mBAAmB,iBAAiB,gBAAgB;EACvE,IAAI,eAAe,GACjB,OAAO;CAEX;CACA,OAAO;AACT;AAEA,MAAM,qBAAqB;;AAG3B,SAAS,gBAAgB,SAAwB,YAA6B;CAC5E,MAAM,QAAQ,mBAAmB,KAAK,UAAU;CAChD,MAAM,QAAQ,QAAQ,OAAO,KAAA,IAAY,KAAA,IAAY,aAAa,MAAM,EAAE;CAC1E,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC9B,OAAO;CAET,MAAM,QAAQ,gBAAgB,SAAS,KAAK;CAC5C,QAAQ,MAAM,IAAd;EACE,KAAK,MAAM,OAAO,SAAS;EAC3B,KAAK,MAAM,OAAO,SAAS;EAC3B,KAAK,KAAK,OAAO,QAAQ;EACzB,KAAK,KAAK,OAAO,QAAQ;EACzB,SAAS,OAAO,UAAU;CAC5B;AACF;;AAGA,SAAgB,eAAe,aAAqB,OAAwB;CAC1E,MAAM,UAAU,aAAa,WAAW;CACxC,IAAI,YAAY,KAAA,GACd,OAAO;CAET,OAAO,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,gBAAgB;EAC7C,MAAM,cAAc,YAAY,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,QAAQ,eAAe,eAAe,EAAE;EAC5F,OAAO,YAAY,SAAS,KAAK,YAAY,OAAO,eAAe,gBAAgB,SAAS,UAAU,CAAC;CACzG,CAAC;AACH;;;;ACzEA,SAAgB,cAAc,YAA+B,UAAkB,oBAAmC;CAChH,IAAI,eAAe,MACjB,OAAO;CAET,IAAI,CAAC,eAAe,SAAS,WAAW,SAAS,GAC/C,OAAO;CAET,OAAO,eAAe,SAAS,WAAW,UAAU,IAAI,eAAe;AACzE;;;;;;;;
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../../src/core/version/client-version.gen.ts","../../src/core/version/semver.ts","../../src/core/version/hub-version.ts","../../src/doct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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/core/version/client-version.gen.ts
|
|
2
2
|
/** This client's package version, sent as `x-hub-client` on REST calls and `client` in `hello`. */
|
|
3
|
-
const HUB_CLIENT_VERSION = "2.0.0-next.
|
|
3
|
+
const HUB_CLIENT_VERSION = "2.0.0-next.1";
|
|
4
4
|
//#endregion
|
|
5
5
|
export { HUB_CLIENT_VERSION as t };
|
|
6
6
|
|
package/dist/shared/daily.js
CHANGED
|
@@ -178,7 +178,7 @@ let claimedDaily = null;
|
|
|
178
178
|
function getDaily(host) {
|
|
179
179
|
claimedDaily ?? (claimedDaily = claimSingleton({
|
|
180
180
|
name: "daily",
|
|
181
|
-
version: "2.0.0-next.
|
|
181
|
+
version: "2.0.0-next.1",
|
|
182
182
|
api: 1,
|
|
183
183
|
create: () => new DailySystem(host),
|
|
184
184
|
isInstance: isDailySystem
|
package/dist/shared/globals.js
CHANGED
|
@@ -50,8 +50,6 @@ function _defineProperty(e, r, t) {
|
|
|
50
50
|
writable: !0
|
|
51
51
|
}) : e[r] = t, e;
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/globals.ts
|
|
55
53
|
/** The v1 window names, kept as aliases. */
|
|
56
54
|
const LEGACY_GLOBAL_NAMES = {
|
|
57
55
|
input: "__HUB_INPUT__",
|
|
@@ -80,7 +78,14 @@ function claimSingleton(claim) {
|
|
|
80
78
|
if (claim.onMismatch?.(registered) !== true) return claim.create();
|
|
81
79
|
} else {
|
|
82
80
|
const legacy = page[LEGACY_GLOBAL_NAMES[claim.name]];
|
|
83
|
-
if (registered === void 0 && claim.isInstance(legacy))
|
|
81
|
+
if (registered === void 0 && claim.isInstance(legacy)) {
|
|
82
|
+
registry[claim.name] = {
|
|
83
|
+
version: "v1",
|
|
84
|
+
api: claim.api,
|
|
85
|
+
instance: legacy
|
|
86
|
+
};
|
|
87
|
+
return legacy;
|
|
88
|
+
}
|
|
84
89
|
}
|
|
85
90
|
const instance = claim.create();
|
|
86
91
|
registry[claim.name] = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.js","names":[],"sources":["../../src/realtime/cross-bundle.ts","../../src/globals.ts"],"mappings":";;AAWA,SAAgB,SAAS,WAAyC;CAChE,OAAO,OAAO,cAAc,YAAY,cAAc;AACxD;;AAIA,SAAgB,WAAgC,WAAoB,OAA8D;CAChI,IAAI,CAAC,SAAS,SAAS,GACrB,OAAO;CAET,OAAO,MAAM,OAAO,SAAS,QAAQ,aAAa,OAAO,QAAQ,IAAI,WAAW,IAAI,MAAM,UAAU;AACtG;;AAIA,SAAgB,UAAU,WAAoB,KAAsB;CAClE,OAAO,SAAS,SAAS,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,KAAA;AAC7D
|
|
1
|
+
{"version":3,"file":"globals.js","names":[],"sources":["../../src/realtime/cross-bundle.ts","../../src/globals.ts"],"mappings":";;AAWA,SAAgB,SAAS,WAAyC;CAChE,OAAO,OAAO,cAAc,YAAY,cAAc;AACxD;;AAIA,SAAgB,WAAgC,WAAoB,OAA8D;CAChI,IAAI,CAAC,SAAS,SAAS,GACrB,OAAO;CAET,OAAO,MAAM,OAAO,SAAS,QAAQ,aAAa,OAAO,QAAQ,IAAI,WAAW,IAAI,MAAM,UAAU;AACtG;;AAIA,SAAgB,UAAU,WAAoB,KAAsB;CAClE,OAAO,SAAS,SAAS,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,KAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQA,MAAa,sBAAsB;CAAE,OAAO;CAAiB,OAAO;CAAiB,IAAI;AAAa;AAkCtG,MAAM,mCAAmB,IAAI,IAAmB;;AAGhD,SAAS,WAAW,MAAiD;CACnE,IAAI,SAAS,KAAA,GACX;CAEF,KAAK,WAAL,KAAK,SAAW,CAAC;CACjB,OAAO,KAAK;AACd;;AAGA,SAAgB,eAAkB,OAA6B;CAC7D,MAAM,OAAO,OAAO,WAAW,cAAc,KAAA,IAAY;CACzD,MAAM,WAAW,WAAW,IAAI;CAChC,IAAI,SAAS,KAAA,KAAa,aAAa,KAAA,GACrC,OAAO,MAAM,OAAO;CAEtB,MAAM,aAAa,SAAS,MAAM;CAClC,IAAI,eAAe,KAAA,KAAa,MAAM,WAAW,WAAW,QAAQ,GAAG;EACrE,IAAI,WAAW,QAAQ,MAAM,KAC3B,OAAO,WAAW;EAEpB,IAAI,CAAC,iBAAiB,IAAI,MAAM,IAAI,GAAG;GACrC,iBAAiB,IAAI,MAAM,IAAI;GAE/B,QAAQ,KAAK,+CAA+C,MAAM,KAAK,MAAM,WAAW,QAAQ,OAAO,OAAO,WAAW,GAAG,EAAE,KAAK,MAAM,QAAQ,OAAO,OAAO,MAAM,GAAG,EAAE,2CAA2C;EACvN;EACA,IAAI,MAAM,aAAa,UAAU,MAAM,MACrC,OAAO,MAAM,OAAO;CAExB,OAAO;EACL,MAAM,SAAS,KAAK,oBAAoB,MAAM;EAC9C,IAAI,eAAe,KAAA,KAAa,MAAM,WAAW,MAAM,GAAG;GAGxD,SAAS,MAAM,QAAQ;IAAE,SAAA;IAA4B,KAAK,MAAM;IAAK,UAAU;GAAO;GACtF,OAAO;EACT;CACF;CACA,MAAM,WAAW,MAAM,OAAO;CAC9B,SAAS,MAAM,QAAQ;EAAE,SAAS,MAAM;EAAS,KAAK,MAAM;EAAK;CAAS;CAC1E,KAAK,oBAAoB,MAAM,SAAS;CACxC,OAAO;AACT"}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -700,7 +700,7 @@ declare class ContentRejectedError extends HubError {
|
|
|
700
700
|
//#endregion
|
|
701
701
|
//#region src/core/version/client-version.gen.d.ts
|
|
702
702
|
/** This client's package version, sent as `x-hub-client` on REST calls and `client` in `hello`. */
|
|
703
|
-
declare const HUB_CLIENT_VERSION = "2.0.0-next.
|
|
703
|
+
declare const HUB_CLIENT_VERSION = "2.0.0-next.1";
|
|
704
704
|
//#endregion
|
|
705
705
|
export { SubmitScoreResult as $, BoardWithTop as A, Json$1 as B, CLIENT_VERSION_HEADER as C, QueuedScoreOptions as D, QueueOpInput as E, GlobalAnalytics as F, Profile as G, LeaderboardResult as H, HubOptions as I, SaveMeta as J, ProfileSummary as K, HubStatus as L, GameInfo$1 as M, GameLeaderboards as N, BufferedEvent as O, GameRecords as P, SubmitScoreOptions as Q, Inventory as R, SyncResult as S, QueueOp as T, MeResponse as U, LeaderboardEntry as V, Metrics$1 as W, SortDir$1 as X, SnapshotResponse as Y, Stats$1 as Z, TradeNoteOptions as _, HubErrorDetails as a, StatResult as b, Hub as c, ClientSupport as d, User as et, HubMenuControl as f, TradeListOptions as g, TradeId as h, HubErrorCode as i, GamePayload as it, GameAnalytics as j, Board$1 as k, createHub as l, TradeBundle as m, ContentRejectedError as n, EndpointName as nt, OfflineError as o, GrantBundle as p, Save as q, HubError as r, EndpointReply as rt, UNSUPPORTED_BY_HUB as s, HUB_CLIENT_VERSION as t, EndpointFields as tt, hub as u, AuthResponse as v, ProfilePatch as w, SyncConflict as x, ProfileUpdate as y, InventorySnapshot as z };
|
|
706
706
|
//# sourceMappingURL=index.d.ts.map
|