castle-web-cli 0.4.235 → 0.4.237
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/dist/api.d.ts +2 -0
- package/dist/castleJson.d.ts +18 -0
- package/dist/castleJson.js +39 -0
- package/dist/save-deck.js +14 -13
- package/kits/hub-game/code/client/actionOverflow.js +10 -0
- package/kits/hub-game/code/client/chrome.js +1 -1
- package/kits/hub-game/code/client/safeLayout.js +11 -9
- package/kits/hub-game/code/systems/hub.js +28 -1
- package/kits/hub-game/docs/contract.md +5 -1
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +85 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -166,6 +166,8 @@ export interface CauldronServerConfig {
|
|
|
166
166
|
voice: {
|
|
167
167
|
enabled: boolean;
|
|
168
168
|
};
|
|
169
|
+
/** castle.json `server.placeMaxPlayers`; sent only when declared. */
|
|
170
|
+
placeMaxPlayers?: number;
|
|
169
171
|
destinations?: Array<{
|
|
170
172
|
routeId: string;
|
|
171
173
|
access: 'player' | 'party' | 'public';
|
package/dist/castleJson.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface CastleJson {
|
|
|
26
26
|
main?: string;
|
|
27
27
|
tickRate?: number;
|
|
28
28
|
maxPlayers?: number;
|
|
29
|
+
placeMaxPlayers?: number;
|
|
29
30
|
destinations?: ServerDestinationConfig[];
|
|
30
31
|
worldNotifications?: ServerWorldNotificationsConfig;
|
|
31
32
|
};
|
|
@@ -81,6 +82,7 @@ export declare const DEFAULT_SERVER_MAX_PLAYERS = 8;
|
|
|
81
82
|
export declare const SERVER_TICK_RATE_CAP = 30;
|
|
82
83
|
export declare const SERVER_MAX_PLAYERS_CAP = 24;
|
|
83
84
|
export declare const SERVER_DESTINATIONS_CAP = 16;
|
|
85
|
+
export declare const SERVER_PLACE_MAX_PLAYERS_CAP = 100;
|
|
84
86
|
export interface ServerDestinationConfig {
|
|
85
87
|
routeId: string;
|
|
86
88
|
access: 'player' | 'party' | 'public';
|
|
@@ -107,6 +109,7 @@ export interface ResolvedServerConfig {
|
|
|
107
109
|
tickRate: number;
|
|
108
110
|
maxPlayers: number;
|
|
109
111
|
voiceEnabled: boolean;
|
|
112
|
+
placeMaxPlayers?: number;
|
|
110
113
|
destinations?: ServerDestinationConfig[];
|
|
111
114
|
worldNotifications?: ServerWorldNotificationsConfig;
|
|
112
115
|
hub?: ServerHubConfig;
|
|
@@ -137,6 +140,21 @@ export interface ServerHubConfig extends ServerHubPlaceConfig {
|
|
|
137
140
|
unlocks?: unknown;
|
|
138
141
|
}
|
|
139
142
|
export declare function resolveServerConfig(dir: string): ResolvedServerConfig | null;
|
|
143
|
+
/**
|
|
144
|
+
* The config `save-deck` sends with the server bundle. Optional keys go only when
|
|
145
|
+
* declared, so a deck that declares none sends exactly what it always has.
|
|
146
|
+
*/
|
|
147
|
+
export declare function serverBundleConfig(serverConfig: ResolvedServerConfig): {
|
|
148
|
+
placeMaxPlayers?: number | undefined;
|
|
149
|
+
hub?: ServerHubConfig | undefined;
|
|
150
|
+
worldNotifications?: ServerWorldNotificationsConfig | undefined;
|
|
151
|
+
destinations?: ServerDestinationConfig[] | undefined;
|
|
152
|
+
tickRate: number;
|
|
153
|
+
maxPlayers: number;
|
|
154
|
+
voice: {
|
|
155
|
+
enabled: boolean;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
140
158
|
export declare function deckStarterScene(dir: string): string;
|
|
141
159
|
export declare const DEFAULT_MAIN = "main.jsx";
|
|
142
160
|
export declare function deckMainFile(dir: string): string;
|
package/dist/castleJson.js
CHANGED
|
@@ -157,6 +157,8 @@ export const DEFAULT_SERVER_MAX_PLAYERS = 8;
|
|
|
157
157
|
export const SERVER_TICK_RATE_CAP = 30;
|
|
158
158
|
export const SERVER_MAX_PLAYERS_CAP = 24;
|
|
159
159
|
export const SERVER_DESTINATIONS_CAP = 16;
|
|
160
|
+
// Ghost's town size class cap (ghost-server CAULDRON_SESSION_SIZE_CLASSES.town).
|
|
161
|
+
export const SERVER_PLACE_MAX_PLAYERS_CAP = 100;
|
|
160
162
|
// A deck may keep its source under `code/`, so both roots are candidates.
|
|
161
163
|
const DEFAULT_SERVER_ENTRIES = [
|
|
162
164
|
'server/index.js',
|
|
@@ -180,16 +182,53 @@ export function resolveServerConfig(dir) {
|
|
|
180
182
|
const worldNotifications = server?.worldNotifications === undefined
|
|
181
183
|
? undefined
|
|
182
184
|
: validateServerWorldNotifications(server.worldNotifications, destinations);
|
|
185
|
+
const placeMaxPlayers = server?.placeMaxPlayers === undefined
|
|
186
|
+
? undefined
|
|
187
|
+
: validatePlaceMaxPlayers(server.placeMaxPlayers);
|
|
183
188
|
return {
|
|
184
189
|
entry,
|
|
185
190
|
tickRate: clampNumber(server?.tickRate, DEFAULT_SERVER_TICK_RATE, 0, SERVER_TICK_RATE_CAP),
|
|
186
191
|
maxPlayers: Math.floor(clampNumber(server?.maxPlayers, DEFAULT_SERVER_MAX_PLAYERS, 1, SERVER_MAX_PLAYERS_CAP)),
|
|
187
192
|
voiceEnabled: castleJson?.voice?.enabled !== false,
|
|
193
|
+
...(placeMaxPlayers === undefined ? {} : { placeMaxPlayers }),
|
|
188
194
|
...(destinations === undefined ? {} : { destinations }),
|
|
189
195
|
...(worldNotifications === undefined ? {} : { worldNotifications }),
|
|
190
196
|
...(castleJson?.hub === undefined ? {} : { hub: serverHubConfig(castleJson.hub) }),
|
|
191
197
|
};
|
|
192
198
|
}
|
|
199
|
+
function validatePlaceMaxPlayers(value) {
|
|
200
|
+
if (typeof value !== 'number' ||
|
|
201
|
+
!Number.isInteger(value) ||
|
|
202
|
+
value < 1 ||
|
|
203
|
+
value > SERVER_PLACE_MAX_PLAYERS_CAP) {
|
|
204
|
+
throw new Error(`castle.json server.placeMaxPlayers must be an integer from 1 through ` +
|
|
205
|
+
`${SERVER_PLACE_MAX_PLAYERS_CAP} (got ${JSON.stringify(value)}).`);
|
|
206
|
+
}
|
|
207
|
+
return value;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The config `save-deck` sends with the server bundle. Optional keys go only when
|
|
211
|
+
* declared, so a deck that declares none sends exactly what it always has.
|
|
212
|
+
*/
|
|
213
|
+
export function serverBundleConfig(serverConfig) {
|
|
214
|
+
return {
|
|
215
|
+
tickRate: serverConfig.tickRate,
|
|
216
|
+
maxPlayers: serverConfig.maxPlayers,
|
|
217
|
+
voice: { enabled: serverConfig.voiceEnabled },
|
|
218
|
+
...(serverConfig.destinations ? { destinations: serverConfig.destinations } : {}),
|
|
219
|
+
...(serverConfig.worldNotifications
|
|
220
|
+
? { worldNotifications: serverConfig.worldNotifications }
|
|
221
|
+
: {}),
|
|
222
|
+
// Sent only for a deck whose castle.json declares a hub place, so every
|
|
223
|
+
// other deck's config is exactly what it was.
|
|
224
|
+
...(serverConfig.hub ? { hub: serverConfig.hub } : {}),
|
|
225
|
+
// A Ghost without placeMaxPlayers support drops the key (its config
|
|
226
|
+
// normalizer keeps only the keys it knows), so the save still succeeds there.
|
|
227
|
+
...(serverConfig.placeMaxPlayers === undefined
|
|
228
|
+
? {}
|
|
229
|
+
: { placeMaxPlayers: serverConfig.placeMaxPlayers }),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
193
232
|
// `serve` and `check` resolve this too, and the hub block is
|
|
194
233
|
// checked by the kit at publish and by ghost when it is saved. Invalid push capability
|
|
195
234
|
// keys are refused here; other blocks that are
|
package/dist/save-deck.js
CHANGED
|
@@ -6,7 +6,7 @@ import { nanoid } from 'nanoid';
|
|
|
6
6
|
import * as api from './api.js';
|
|
7
7
|
import * as config from './config.js';
|
|
8
8
|
import { bundleProject, bundleProjectChunked } from './bundle.js';
|
|
9
|
-
import { resolveBundleChunks, resolveServerConfig, validateExperiments, } from './castleJson.js';
|
|
9
|
+
import { resolveBundleChunks, resolveServerConfig, serverBundleConfig, validateExperiments, } from './castleJson.js';
|
|
10
10
|
import { importChecksFailedMessage, runImportChecks } from './importCheckHook.js';
|
|
11
11
|
import { selectSaveCover } from './saveCover.js';
|
|
12
12
|
import { COVER_FILE } from './localPaths.js';
|
|
@@ -276,18 +276,7 @@ async function publishServerBundle(projectDir, deckId, pack) {
|
|
|
276
276
|
const uploadConfig = await api.createCauldronServerBundleUploadConfig(deckId);
|
|
277
277
|
await uploadPresignedFile(uploadConfig, new Blob([bundle.code], { type: 'application/javascript' }), 'application/javascript', 60_000, 'Server bundle upload');
|
|
278
278
|
const packUploadId = pack ? await uploadContentPack(deckId, pack) : null;
|
|
279
|
-
const saved = await api.saveCauldronServerBundle(deckId, uploadConfig.uploadId,
|
|
280
|
-
tickRate: serverConfig.tickRate,
|
|
281
|
-
maxPlayers: serverConfig.maxPlayers,
|
|
282
|
-
voice: { enabled: serverConfig.voiceEnabled },
|
|
283
|
-
...(serverConfig.destinations ? { destinations: serverConfig.destinations } : {}),
|
|
284
|
-
...(serverConfig.worldNotifications
|
|
285
|
-
? { worldNotifications: serverConfig.worldNotifications }
|
|
286
|
-
: {}),
|
|
287
|
-
// Sent only for a deck whose castle.json declares a hub place, so every
|
|
288
|
-
// other deck's config is exactly what it was.
|
|
289
|
-
...(serverConfig.hub ? { hub: serverConfig.hub } : {}),
|
|
290
|
-
}, packUploadId ?? undefined);
|
|
279
|
+
const saved = await api.saveCauldronServerBundle(deckId, uploadConfig.uploadId, serverBundleConfig(serverConfig), packUploadId ?? undefined);
|
|
291
280
|
// The server hashes what it actually stored. A mismatch means the bytes that
|
|
292
281
|
// will run in sessions are not the bytes we bundled.
|
|
293
282
|
if (saved && saved.sha256 !== bundle.sha256) {
|
|
@@ -313,6 +302,17 @@ function checkedExperiments(castleJson) {
|
|
|
313
302
|
throw new Error(`castle.json ${e instanceof Error ? e.message : String(e)} Nothing was saved.`);
|
|
314
303
|
}
|
|
315
304
|
}
|
|
305
|
+
// The server block is read again when the bundle is published, after the deck is
|
|
306
|
+
// live; a value it refuses (server.placeMaxPlayers, server.destinations) stops
|
|
307
|
+
// the save here instead.
|
|
308
|
+
function checkedServerConfig(projectDir) {
|
|
309
|
+
try {
|
|
310
|
+
resolveServerConfig(projectDir);
|
|
311
|
+
}
|
|
312
|
+
catch (e) {
|
|
313
|
+
throw new Error(`${e instanceof Error ? e.message : String(e)} Nothing was saved.`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
316
|
// castle.json `experiments` goes to Castle on every save, with or without a
|
|
317
317
|
// server bundle. A declared block is awaited and fails the save loudly when it
|
|
318
318
|
// cannot be stored. Exported for the tests.
|
|
@@ -625,6 +625,7 @@ async function saveDeckAfterValidation(dir, opts, projectDir, visibility) {
|
|
|
625
625
|
const castleJson = readCastleJson(projectDir);
|
|
626
626
|
const existingDeckId = typeof castleJson?.deckId === 'string' && castleJson.deckId ? castleJson.deckId : null;
|
|
627
627
|
const experiments = checkedExperiments(castleJson);
|
|
628
|
+
checkedServerConfig(projectDir);
|
|
628
629
|
const chunked = checkedBundleChunks(castleJson, opts);
|
|
629
630
|
if (chunked && !existingDeckId) {
|
|
630
631
|
// Ghost grants chunk uploads for a deck that exists; a new one is created
|
|
@@ -533,6 +533,16 @@ export function makeActionOverflow({ root, edgeMax = false, readSafeInsets = nul
|
|
|
533
533
|
},
|
|
534
534
|
watch,
|
|
535
535
|
invalidate: schedule,
|
|
536
|
+
// v1.152: the safe-layout pass has just placed the controls the rail
|
|
537
|
+
// avoids (Act/Jump arriving restacks the column). Place the rail against
|
|
538
|
+
// those final boxes in the same pass, so neither the next frame nor a
|
|
539
|
+
// debug report shows it over them; layout() falls back to More/Actions or
|
|
540
|
+
// hides it when nothing clears. An unchanged layout key costs one read.
|
|
541
|
+
settle() {
|
|
542
|
+
if (disposed || !canAct || !items.length) {return;}
|
|
543
|
+
if (open) {schedule(); return;}
|
|
544
|
+
layout();
|
|
545
|
+
},
|
|
536
546
|
cancel: () => closeSheet(),
|
|
537
547
|
isOpen: () => open,
|
|
538
548
|
dispose() {
|
|
@@ -3192,7 +3192,7 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
|
|
|
3192
3192
|
}
|
|
3193
3193
|
if (safeInsets) {
|
|
3194
3194
|
safeLayout = makeSafeLayout({ root, hud: () => hud, entries: surfaces, onLayout: () => {
|
|
3195
|
-
if (actionOverflow && actionOverflowObstacles) {actionOverflow.reconcileWatch(actionOverflowObstacles()); actionOverflow.
|
|
3195
|
+
if (actionOverflow && actionOverflowObstacles) {actionOverflow.reconcileWatch(actionOverflowObstacles()); actionOverflow.settle();}
|
|
3196
3196
|
} });
|
|
3197
3197
|
debugLayout = () => { safeLayout.flush(); worldLayout?.flush(); return safeLayout.report(); };
|
|
3198
3198
|
(globalThis.castleHub ??= {}).layout = debugLayout;
|
|
@@ -256,15 +256,6 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
256
256
|
if (final && !entry.transient && kind !== 'hud' && kind !== 'label' && kind !== 'pointer') {controls.push(final);}
|
|
257
257
|
if (final && entry.transient) {transient.push(final);}
|
|
258
258
|
}
|
|
259
|
-
const boxes = [];
|
|
260
|
-
for (const entry of current) {
|
|
261
|
-
const reported = entry.reportNodes?.() ?? [{ node: entry.node, id: entry.id, kind: entry.kind }];
|
|
262
|
-
for (const item of reported) {
|
|
263
|
-
const box = visibleRect(item.node);
|
|
264
|
-
if (box) {boxes.push({ id: item.id, kind: item.kind, x: box.left, y: box.top, w: box.width, h: box.height });}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
last = { view: viewport, reserved, boxes };
|
|
268
259
|
sizes?.disconnect();
|
|
269
260
|
sizes?.observe(root);
|
|
270
261
|
sizes?.observe(probe);
|
|
@@ -278,7 +269,18 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
278
269
|
else {observer.observe(node, { subtree: true, childList: true, attributes: true, characterData: true, attributeOldValue: true, characterDataOldValue: true });}
|
|
279
270
|
}
|
|
280
271
|
|
|
272
|
+
// v1.152: the action rail settles against the final controls here, so
|
|
273
|
+
// the report is read after it.
|
|
281
274
|
onLayout();
|
|
275
|
+
const boxes = [];
|
|
276
|
+
for (const entry of current) {
|
|
277
|
+
const reported = entry.reportNodes?.() ?? [{ node: entry.node, id: entry.id, kind: entry.kind }];
|
|
278
|
+
for (const item of reported) {
|
|
279
|
+
const box = visibleRect(item.node);
|
|
280
|
+
if (box) {boxes.push({ id: item.id, kind: item.kind, x: box.left, y: box.top, w: box.width, h: box.height });}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
last = { view: viewport, reserved, boxes };
|
|
282
284
|
return last;
|
|
283
285
|
}
|
|
284
286
|
watch(root);
|
|
@@ -92,6 +92,11 @@ const OPEN_MS = 650;
|
|
|
92
92
|
const REVEAL_MS = 700;
|
|
93
93
|
const LEAVING_MS = 2800;
|
|
94
94
|
const LOADING_LIMIT_MS = 15000;
|
|
95
|
+
// Ghost's roster can lag a player's arrival in a session by up to 15 s, and
|
|
96
|
+
// the SDK asks a door again through the `forbidden` it answers meanwhile, for
|
|
97
|
+
// 16 s after the arrival (v1.154). A door asked inside that window has its
|
|
98
|
+
// LOADING_LIMIT_MS counted from the window's end: at most this much later.
|
|
99
|
+
const ROSTER_LAG_MS = 16000;
|
|
95
100
|
// How long the cover waits for the place to say where it put this player
|
|
96
101
|
// after the session has placed them, before it lifts anyway.
|
|
97
102
|
const ARRIVAL_WAIT_MS = 4000;
|
|
@@ -745,6 +750,7 @@ class HubSystem {
|
|
|
745
750
|
this.act ??= makeAct(this.chrome, this.grab, this.talk);
|
|
746
751
|
this.act.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput && !this.askInput && !this.menuInput && !this.carded);
|
|
747
752
|
}
|
|
753
|
+
this.noteArrival(mp, now);
|
|
748
754
|
if (this.trip) {
|
|
749
755
|
this.stepTrip(scene, mp, local, now);
|
|
750
756
|
} else if (!Hub.hub.faced) {
|
|
@@ -2839,6 +2845,27 @@ class HubSystem {
|
|
|
2839
2845
|
}
|
|
2840
2846
|
}
|
|
2841
2847
|
|
|
2848
|
+
// This player's latest arrival in a session (a join, a trip's, a
|
|
2849
|
+
// reconnect's), for a door's roster window (`contentDeadline`). Each frame,
|
|
2850
|
+
// before the trip steps.
|
|
2851
|
+
noteArrival(mp, now) {
|
|
2852
|
+
const placed = mp.placed?.() ?? null;
|
|
2853
|
+
if (placed === true && this.placedLast !== true) {
|
|
2854
|
+
this.arrivedAt = now;
|
|
2855
|
+
}
|
|
2856
|
+
this.placedLast = placed;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
// When a door still being asked gives up: LOADING_LIMIT_MS after it was
|
|
2860
|
+
// asked, or after the roster window of this player's latest arrival when
|
|
2861
|
+
// that ends later (v1.154). A player not placed right now is arriving now.
|
|
2862
|
+
contentDeadline(trip, now) {
|
|
2863
|
+
const from = trip.target.pendingFrom ?? trip.startedAt;
|
|
2864
|
+
const arrived = this.placedLast === false ? now : this.arrivedAt;
|
|
2865
|
+
const grace = arrived === undefined ? 0 : Math.min(ROSTER_LAG_MS, Math.max(0, arrived + ROSTER_LAG_MS - from));
|
|
2866
|
+
return from + LOADING_LIMIT_MS + grace;
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2842
2869
|
// Whether a door to another deck has its content, once the cover is down.
|
|
2843
2870
|
// Until then the cover holds; a pack that failed, or never came, keeps the
|
|
2844
2871
|
// door shut: the trip turns back without leaving this place (HUB.md, Doors:
|
|
@@ -2851,7 +2878,7 @@ class HubSystem {
|
|
|
2851
2878
|
trip.marks.covered ??= now;
|
|
2852
2879
|
this.setTripCover(1, trip);
|
|
2853
2880
|
// A retried way back has its own deadline, from when it was asked again.
|
|
2854
|
-
if (!pending.done && now
|
|
2881
|
+
if (!pending.done && now < this.contentDeadline(trip, now)) {
|
|
2855
2882
|
return false;
|
|
2856
2883
|
}
|
|
2857
2884
|
// A player barred from the hub is told so, and not asked for again. A way
|
|
@@ -1631,7 +1631,10 @@ Safe placement persists through CSS custom properties; animation frames do not
|
|
|
1631
1631
|
restore, measure or reapply it. Insets are read on initialization and viewport
|
|
1632
1632
|
resize/orientation/visual-viewport events. DOM changes coalesce into keep-out
|
|
1633
1633
|
passes at most twice per second. Loading-cover changes settle before paint;
|
|
1634
|
-
explicit debug reports still measure synchronously.
|
|
1634
|
+
explicit debug reports still measure synchronously. v1.152: the action rail is
|
|
1635
|
+
placed in the same pass, against the controls' final boxes, so a column that
|
|
1636
|
+
restacks (Act/Jump arriving) never leaves the rail over it for a frame or a
|
|
1637
|
+
report.
|
|
1635
1638
|
|
|
1636
1639
|
1. Edge-anchored chrome keeps `max(its existing margin, env(safe-area-inset-*))`
|
|
1637
1640
|
on that edge. This includes People/Doors, Character, the action column and
|
|
@@ -4278,6 +4281,7 @@ a deck written before them remains valid.
|
|
|
4278
4281
|
|
|
4279
4282
|
| date | change |
|
|
4280
4283
|
| --- | --- |
|
|
4284
|
+
| 2026-10-18 (v1.154) | §5 a door asked within 16 s of this player's arrival in a session (a join, a trip's, a reconnect; ghost's roster lags it by up to 15 s, during which the SDK asks again through `forbidden`) keeps its cover up for the 15 s loading limit counted from that window's end, not the trip's start: a door that answers ok after 14 s of `forbidden` goes through instead of "it took too long". A door that never answers still shuts, by 31 s at most; one asked later keeps 15 s. Every deck, no key. Within `hub.contract: 1`. |
|
|
4281
4285
|
| 2026-10-17 (v1.147) | §5 a joining player's body without a readable saved pose starts on the scene's spawn itself (its x and z, at the v1.48 standing height), not on the multiplayer spawn ring 1.1 m around it. The client starts its own body at the spawn; on the live Town the first WORLD snapped it to its ring slot, and the kit's arrival row back at the spawn then reached it as a correction under the client's 4 m snap distance, eased a quarter of the way a frame: a 1.1 m glide just after the cover lifted (3 of 5 captures, web and TECNO). Players waiting together share the spot until the arrival row spreads them; the row, the v1.40 settle and every later placement are unchanged. Saved and resumed poses are unchanged. A default in every hub place; no key, nothing new sent. |
|
|
4282
4286
|
| 2026-10-18 (v1.150) | §12 and §13 authored mind taps also apply in `under13Choices` places: an under-13 speaker receives the place's authored asks ahead of both bundle `childAsks` and the three legacy choices. A matching trimmed `hub-npc-say` is answered through `npcLine` `why: 'authored'`; legacy strings outside those taps are ignored, and mind turns remain refused with `HUB_NPC_CHOICE_REQUIRED`. Mind-less NPCs, minds without authored asks, adults and unknown ages are unchanged. Within `hub.contract: 1`. |
|
|
4283
4287
|
| 2026-10-17 (v1.148) | §12 and §13 authored taps: `npcOpening` may return `authored: true`, meaning the place answers its asks through `npcLine` `why: 'authored'`. A mind's open for a speaker with trusted `under13 === true` then carries those asks as `choices: string[]` with `authoredChoices: true`, ahead of bundle `childAsks`; a tap goes by `hub-npc-say` to the place's authored line, never a mind turn or ghost, and the kit refuses that speaker's mind turns on that open. Chips clear after the place answers. Over 13s and opens without `authored` are unchanged. Within `hub.contract: 1`. |
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Real CSS geometry for the safe-inset action rail in a crowded Town HUD:
|
|
2
|
+
// a five-item Today checklist wrapping to two lines, Invite/Market offers, a
|
|
3
|
+
// partner's talk prompt beside the player and the snapped avatar reserve, all
|
|
4
|
+
// under hub.act. When Act/Jump arrive (a talk or trip ends) the column
|
|
5
|
+
// restacks, and a layout report taken at once must already show the rail
|
|
6
|
+
// clear of them, labels readable (v1.152). Run with CHROME pointing to the QA
|
|
7
|
+
// browser (and BROWSER_WS when using a remote GPU browser).
|
|
8
|
+
import assert from 'node:assert/strict';
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { chromium } from 'playwright-core';
|
|
12
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
13
|
+
|
|
14
|
+
const root = new URL('../../../', import.meta.url);
|
|
15
|
+
const source = await readFile(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
16
|
+
const setup = source.slice(source.indexOf(' this.chrome.setWorldLabelFocus'), source.indexOf(' Avatar.load(scene);'));
|
|
17
|
+
const OFFERS = [
|
|
18
|
+
{ id: 'invite-friend', label: 'Invite a friend' }, { id: 'market-looks', label: 'Market looks' },
|
|
19
|
+
];
|
|
20
|
+
const PROMPT = ['Play Gem Rush', 'Stamp your card (0/4)', 'Water the garden', 'Game with a friend (extra)', 'Sit with a friend (extra)']
|
|
21
|
+
.map(item => `○\u00a0${item.replaceAll(' ', '\u00a0')}`).join(' ');
|
|
22
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
23
|
+
try {
|
|
24
|
+
const page = await browser.newPage();
|
|
25
|
+
await page.route('http://layout.test/**', async route => {
|
|
26
|
+
const path = new URL(route.request().url()).pathname;
|
|
27
|
+
if (path === '/') return route.fulfill({ contentType: 'text/html', body: '<script type="importmap">{"imports":{"three":"/node_modules/three/build/three.module.js"}}</script><body style="margin:0"></body>' });
|
|
28
|
+
const url = new URL(`.${path}`, root);
|
|
29
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
30
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
31
|
+
});
|
|
32
|
+
for (const [width, height] of [[844, 390], [390, 844], [1440, 900]]) {
|
|
33
|
+
await page.setViewportSize({ width, height });
|
|
34
|
+
await page.goto('http://layout.test/');
|
|
35
|
+
await logRenderer(page, 'action rail crowded');
|
|
36
|
+
const result = await page.evaluate(async ({ setup, OFFERS, PROMPT }) => {
|
|
37
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
38
|
+
const { overlaps } = await import('/kits/hub-game/code/client/safeLayout.js');
|
|
39
|
+
const { makeAct } = await import('/kits/hub-game/code/client/act.js');
|
|
40
|
+
const { hub } = await import('/kits/hub-game/code/client/state.js');
|
|
41
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, safeInsets: true });
|
|
42
|
+
chrome.soundControl(true, { volume: 0.7, muted: false }, { onMuted() {}, onVolume() {} });
|
|
43
|
+
chrome.showPicker(true, 0);
|
|
44
|
+
chrome.setEmotes([['wave', '👋']]); chrome.setSay({ reactions: [], phrases: [] });
|
|
45
|
+
const scene = { persistent: {}, three: { renderer: { domElement: { parentElement: document.body } } } };
|
|
46
|
+
const Hub = { deck: { safeInsets: false, act: true }, hub: {} };
|
|
47
|
+
const context = { chrome };
|
|
48
|
+
hub.place = { id: 'main', act: true };
|
|
49
|
+
hub.prompts = [{ id: 'partner', verb: 'Talk to Juniper about the shared garden plot' }];
|
|
50
|
+
const partner = { id: 'partner', components: { HubNpc: { name: 'Juniper' }, Transform: { x: 0.6, y: 1, z: 0 } } };
|
|
51
|
+
const act = makeAct(chrome, { perform() {} }, { prepare() {} });
|
|
52
|
+
Object.assign(scene, { getActors: () => [partner], getActor: () => partner, moveInput: { consumeJump() {} } });
|
|
53
|
+
scene.three.camera = { position: { clone: () => ({ set() { return this; }, project: () => ({ x: 0.08, y: -0.1, z: 0 }) }) } };
|
|
54
|
+
const local = { components: { Transform: { x: 0, y: 1, z: 0 } } };
|
|
55
|
+
// The player stands just right of centre, as with a partner beside them.
|
|
56
|
+
let avatar = { left: innerWidth * 0.5 - 30, right: innerWidth * 0.5 + 40, top: innerHeight * 0.3, bottom: innerHeight * 0.62 };
|
|
57
|
+
let can = false, canAct = true;
|
|
58
|
+
const draw = () => {
|
|
59
|
+
new Function('Hub', 'scene', 'worldLabelFocus', setup).call(context, Hub, scene, () => false);
|
|
60
|
+
chrome.setHud({ title: 'Town', text: PROMPT }, null);
|
|
61
|
+
chrome.grabPrompt(null); chrome.sitPrompt(null); chrome.talkPrompt(null);
|
|
62
|
+
chrome.setWorldAvatar(avatar);
|
|
63
|
+
act.frame(scene, { net: { selfId: () => 'p', send() {} } }, local, can);
|
|
64
|
+
chrome.layoutInteractionRail();
|
|
65
|
+
chrome.setActions(OFFERS, () => {}, canAct, 1, true);
|
|
66
|
+
chrome.frameSafeInsets?.();
|
|
67
|
+
};
|
|
68
|
+
// The engine's cached cadence: frames, observer delivery and the rail's
|
|
69
|
+
// own 500 ms throttle, with no forced debug flush before measuring.
|
|
70
|
+
const paint = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
71
|
+
const settle = async () => {
|
|
72
|
+
for (let round = 0; round < 3; round++) {
|
|
73
|
+
for (let frame = 0; frame < 4; frame++) {draw(); await paint();}
|
|
74
|
+
await new Promise(resolve => setTimeout(resolve, 550));
|
|
75
|
+
}
|
|
76
|
+
for (let frame = 0; frame < 6; frame++) {draw(); await paint();}
|
|
77
|
+
};
|
|
78
|
+
await settle();
|
|
79
|
+
// The Act pair arrives (a talk or trip ends) and the QA capture asks
|
|
80
|
+
// for the layout report at once, then reads the frame: the rail must
|
|
81
|
+
// already clear the pair's final place.
|
|
82
|
+
can = true; draw(); await paint();
|
|
83
|
+
// chrome.layout() is a single flush; castleHub.layout() flushes twice.
|
|
84
|
+
const report = chrome.layout();
|
|
85
|
+
const shown = node => node && node.getBoundingClientRect().width > 0 && getComputedStyle(node).display !== 'none' && getComputedStyle(node).visibility !== 'hidden';
|
|
86
|
+
const box = node => { const r = node.getBoundingClientRect(); return { left: r.left, right: r.right, top: r.top, bottom: r.bottom }; };
|
|
87
|
+
const rail = [...document.querySelectorAll('[data-hub="action-rail"] button')].filter(shown).map(node => ({ name: node.textContent, ...box(node) }));
|
|
88
|
+
const pair = ['act', 'jump'].map(kind => document.querySelector(`[data-hub-act="${kind}"]`)).filter(shown);
|
|
89
|
+
const controls = pair.map(node => ({ name: node.textContent, ...box(node),
|
|
90
|
+
// The label is readable when its own centre takes the tap.
|
|
91
|
+
reachable: node.contains(document.elementFromPoint((box(node).left + box(node).right) / 2, (box(node).top + box(node).bottom) / 2)) }));
|
|
92
|
+
const hits = [];
|
|
93
|
+
for (const offer of rail) for (const control of controls) if (overlaps(offer, control)) hits.push([offer.name, control.name]);
|
|
94
|
+
const prompt = document.querySelector('[data-hub="hud-prompt"]');
|
|
95
|
+
const promptHits = rail.filter(offer => overlaps(offer, box(prompt))).map(offer => offer.name);
|
|
96
|
+
// The report the capture reads agrees with the frame.
|
|
97
|
+
const reported = id => report.boxes.filter(b => b.id === id || b.id.startsWith(`${id}:`)).map(b => ({ name: b.id, left: b.x, top: b.y, right: b.x + b.w, bottom: b.y + b.h }));
|
|
98
|
+
const reportRail = reported('action-overflow');
|
|
99
|
+
const reportHits = [];
|
|
100
|
+
for (const offer of reportRail) for (const control of [...reported('act'), ...reported('jump')]) if (overlaps(offer, control)) reportHits.push([offer.name, control.name]);
|
|
101
|
+
const reportStale = reportRail.some(r => Math.abs(r.top - box(document.querySelector('[data-hub="action-rail"]')).top) > 0.5);
|
|
102
|
+
const outside = rail.filter(r => r.left < 0 || r.top < 0 || r.right > innerWidth || r.bottom > innerHeight).map(r => r.name);
|
|
103
|
+
act.dispose?.(); chrome.dispose();
|
|
104
|
+
return { rail, controls, hits, promptHits, outside, reportHits, reportStale, reportRail: reportRail.length };
|
|
105
|
+
}, { setup, OFFERS, PROMPT });
|
|
106
|
+
const label = `${width}x${height}`;
|
|
107
|
+
assert(result.rail.length > 0, `${label}: the rail shows at least one entry`);
|
|
108
|
+
assert.equal(result.controls.length, 2, `${label}: Act and Jump measured`);
|
|
109
|
+
assert.deepEqual(result.hits, [], `${label}: rail clears Act and Jump`);
|
|
110
|
+
assert(result.controls.every(control => control.reachable), `${label}: Act and Jump labels take their own taps`);
|
|
111
|
+
assert(result.reportRail > 0, `${label}: the report lists the rail`);
|
|
112
|
+
assert.deepEqual(result.reportHits, [], `${label}: reported rail clears Act and Jump`);
|
|
113
|
+
assert.equal(result.reportStale, false, `${label}: report matches the drawn rail`);
|
|
114
|
+
assert.deepEqual(result.promptHits, [], `${label}: rail clears the HUD prompt`);
|
|
115
|
+
assert.deepEqual(result.outside, [], `${label}: rail inside the viewport`);
|
|
116
|
+
console.log(`${label}: rail ${result.rail.map(r => `${r.name}@${Math.round(r.left)},${Math.round(r.top)}`).join(' ')}; act/jump clear`);
|
|
117
|
+
}
|
|
118
|
+
} finally { await browser.close(); }
|
|
@@ -514,6 +514,91 @@ await test('an acquisition that lands after the trip gave up is given back', asy
|
|
|
514
514
|
}
|
|
515
515
|
});
|
|
516
516
|
|
|
517
|
+
// v1.154: ghost's roster lags an arrival by up to 15 s, and the SDK asks a door
|
|
518
|
+
// again through its `forbidden` for 16 s after the arrival. The kit's limit
|
|
519
|
+
// counts from the end of that window, not from the trip's start.
|
|
520
|
+
async function rosterTrip({ arrivedAt, placed = true, startedAt = 1000 }) {
|
|
521
|
+
const { system, scene } = setup();
|
|
522
|
+
let release;
|
|
523
|
+
const go = globalThis.__tripHub.go;
|
|
524
|
+
globalThis.__tripHub.go = (doorId) => {
|
|
525
|
+
calls.push(['go', doorId]);
|
|
526
|
+
return new Promise((resolve) => (release = resolve));
|
|
527
|
+
};
|
|
528
|
+
try {
|
|
529
|
+
system.arrivedAt = arrivedAt;
|
|
530
|
+
system.placedLast = placed;
|
|
531
|
+
system.goHub(scene, { door: 'race', key: null, title: 'Foot Race' });
|
|
532
|
+
await flush();
|
|
533
|
+
} finally {
|
|
534
|
+
globalThis.__tripHub.go = go;
|
|
535
|
+
}
|
|
536
|
+
system.trip.startedAt = startedAt;
|
|
537
|
+
return { system, scene, trip: system.trip, release: (v) => release(v) };
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
await test('v1.154: a door used 1 s after arriving, forbidden for 14 s and then ok, goes through', async () => {
|
|
541
|
+
const { system, scene, trip, release } = await rosterTrip({ arrivedAt: 0 });
|
|
542
|
+
// 15.5 s after the trip began: the old limit's "it took too long".
|
|
543
|
+
assert.equal(system.contentReady(scene, trip, 16_500), false);
|
|
544
|
+
assert.equal(trip.shut, undefined);
|
|
545
|
+
// The SDK's retry gets its ok (14 s of `forbidden`), and the pack loads.
|
|
546
|
+
release(handoff());
|
|
547
|
+
await flush();
|
|
548
|
+
assert.equal(system.contentReady(scene, trip, 17_000), true);
|
|
549
|
+
assert.equal(trip.shut, undefined);
|
|
550
|
+
assert.deepEqual(calls, [['go', 'race'], ['loadPack', 'abc', 'https://cdn/abc.json']]);
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
await test('v1.154: a door that never answers after an arrival still shuts, by 31 s', async () => {
|
|
554
|
+
const { system, scene, trip, release } = await rosterTrip({ arrivedAt: 0 });
|
|
555
|
+
// Asked at 1 s: the window ends at 16 s, the limit 15 s after that.
|
|
556
|
+
assert.equal(system.contentReady(scene, trip, 30_999), false);
|
|
557
|
+
assert.equal(trip.shut, undefined);
|
|
558
|
+
assert.equal(system.contentReady(scene, trip, 31_001), false);
|
|
559
|
+
assert.equal(trip.shut, 'it took too long');
|
|
560
|
+
release(handoff());
|
|
561
|
+
await flush();
|
|
562
|
+
await flush();
|
|
563
|
+
assert.deepEqual(calls.at(-1), ['cancel']);
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
await test('v1.154: a player not placed (reconnecting) gets the window, capped at 16 s', async () => {
|
|
567
|
+
const { system, scene, trip } = await rosterTrip({ arrivedAt: 0, placed: false });
|
|
568
|
+
assert.equal(system.contentReady(scene, trip, 1000 + 30_999), false);
|
|
569
|
+
assert.equal(trip.shut, undefined);
|
|
570
|
+
assert.equal(system.contentReady(scene, trip, 1000 + 31_001), false);
|
|
571
|
+
assert.equal(trip.shut, 'it took too long');
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
await test('v1.154: a door used long after the arrival keeps the 15 s limit', async () => {
|
|
575
|
+
const { system, scene, trip } = await rosterTrip({ arrivedAt: -60_000 });
|
|
576
|
+
assert.equal(system.contentReady(scene, trip, 1000 + 14_999), false);
|
|
577
|
+
assert.equal(trip.shut, undefined);
|
|
578
|
+
assert.equal(system.contentReady(scene, trip, 1000 + 15_001), false);
|
|
579
|
+
assert.equal(trip.shut, 'it took too long');
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
await test('v1.154: an arrival is placed() rising; unplaced reads as arriving now', async () => {
|
|
583
|
+
const { system } = setup();
|
|
584
|
+
let placed = false;
|
|
585
|
+
const mp = { placed: () => placed };
|
|
586
|
+
system.noteArrival(mp, 0);
|
|
587
|
+
assert.equal(system.arrivedAt, undefined);
|
|
588
|
+
placed = true;
|
|
589
|
+
system.noteArrival(mp, 500);
|
|
590
|
+
system.noteArrival(mp, 900);
|
|
591
|
+
assert.equal(system.arrivedAt, 500);
|
|
592
|
+
assert.equal(system.contentDeadline({ target: {}, startedAt: 2000 }, 2000), 2000 + 15_000 + 14_500);
|
|
593
|
+
placed = false;
|
|
594
|
+
system.noteArrival(mp, 40_000);
|
|
595
|
+
assert.equal(system.contentDeadline({ target: {}, startedAt: 40_000 }, 40_000), 40_000 + 15_000 + 16_000);
|
|
596
|
+
// A runtime without placed() never extends the limit.
|
|
597
|
+
const bare = setup().system;
|
|
598
|
+
bare.noteArrival({}, 0);
|
|
599
|
+
assert.equal(bare.contentDeadline({ target: {}, startedAt: 0 }, 0), 15_000);
|
|
600
|
+
});
|
|
601
|
+
|
|
517
602
|
await test('the way back from a hub trip is Hub.back', async () => {
|
|
518
603
|
const { system, scene } = setup();
|
|
519
604
|
const ticket = { hub: true, scene: 'scenes/main.scene', content: null, join: { mode: 'public' }, door: 'race', title: 'Town' };
|