@wildshard/engine 0.1.20 → 0.1.22
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 +16 -0
- package/lint/engine-sides.json +4 -0
- package/lint/shardfile-boundaries.mjs +4 -2
- package/lint/wildshard-plugin.js +1 -1
- package/package.json +3 -1
- package/scripts/audio-download-proof.mjs +1 -1
- package/scripts/chaos-proxy-core.mjs +14 -1
- package/scripts/chaos-proxy-proof.mjs +22 -0
- package/scripts/check-spelled-paths.mjs +6 -3
- package/scripts/committed-fast-checks.mjs +2 -2
- package/scripts/failmode-cases.d.mts +8 -0
- package/scripts/failmode-cases.mjs +97 -0
- package/scripts/failmode-proof.mjs +556 -0
- package/scripts/grid-crossing-nightly.mjs +5 -4
- package/scripts/grid-crossing-report.mjs +5 -2
- package/scripts/grid-crossing-tour.mjs +25 -8
- package/scripts/grid-crossing-walk-proof.mjs +3 -3
- package/scripts/hover-speed-probe.mjs +136 -0
- package/scripts/mmo-bots.mjs +7 -3
- package/scripts/net-lag-proof.mjs +4 -3
- package/scripts/online-rig.mjs +11 -9
- package/scripts/parity/boot-smoke.mjs +1 -1
- package/scripts/release-cook.mjs +113 -0
- package/scripts/test-products.json +0 -21
- package/scripts/vps/cook-follow.d.mts +6 -0
- package/scripts/vps/cook-follow.mjs +45 -0
- package/scripts/vps/harden-apply.sh +10 -1
- package/scripts/vps/rebuild.sh +120 -26
- package/scripts/vps/wildshard-apply.mjs +5 -1
- package/scripts/vps/wildshard-config +117 -3
- package/src/client/app/entry.ts +2 -3
- package/src/client/engine/boot/contentRead.ts +78 -9
- package/src/client/engine/boot/downloadGiveUp.ts +34 -0
- package/src/client/engine/boot/gpuFiles.ts +3 -3
- package/src/client/engine/boot/leaveAfterPaint.ts +4 -1
- package/src/client/engine/combat/EquipmentService.ts +2 -0
- package/src/client/engine/core/Game.ts +6 -2
- package/src/client/engine/core/shadowLayer.ts +18 -0
- package/src/client/engine/explore/pick.ts +13 -1
- package/src/client/engine/net/predictor.ts +12 -4
- package/src/client/engine/player/TouchControls.ts +3 -2
- package/src/client/engine/render/families/sceneSurface.ts +3 -1
- package/src/client/engine/telemetry/browserErrors.ts +3 -1
- package/src/client/engine/ui/ErrorModal.ts +1 -1
- package/src/client/engine/ui/Loading.ts +14 -2
- package/src/client/engine/ui/downloadFailed.ts +54 -0
- package/src/client/engine/ui/errorScreen.ts +51 -9
- package/src/client/engine/ui/hoverBoost.ts +31 -4
- package/src/client/engine/ui/styles/touch.css +6 -0
- package/src/client/game/boot/spawnDownload.ts +56 -7
- package/src/client/game/grid/copyPrompts.ts +3 -4
- package/src/client/game/grid/dataCellKit.ts +91 -0
- package/src/client/game/grid/enteredEquipment.ts +11 -2
- package/src/client/game/grid/live.ts +11 -301
- package/src/client/game/grid/liveSession.ts +33 -10
- package/src/client/game/grid/neighbourLife.ts +50 -32
- package/src/client/game/grid/reveal.ts +7 -2
- package/src/client/game/grid/session.ts +6 -70
- package/src/client/game/grid/shardfileFar.ts +13 -2
- package/src/client/game/plugin/weaponFamily.ts +6 -0
- package/src/client/game/shardfile/clientSource.ts +7 -3
- package/src/client/game/shardfile/clientWorker.ts +17 -7
- package/src/client/game/shardfile/groundMerge.ts +5 -3
- package/src/client/host/online/linkScreens.ts +12 -6
- package/src/client/host/online/reconnectStrip.ts +3 -2
- package/src/client/host/online/release.ts +87 -16
- package/src/client/host/online/releaseScreens.ts +108 -0
- package/src/client/host/online/shell.ts +46 -12
- package/src/client/host/online/voice.ts +45 -1
- package/src/client/host/online/voiceUi.ts +24 -6
- package/src/server/engine/sim/playerSim.ts +1 -1
- package/src/server/game/grid/room.ts +2 -38
- package/src/server/game/grid/simulation.ts +12 -6
- package/src/server/game/shardfile/declaredKitItems.ts +8 -2
- package/src/server/host/dedicated/cellHost.ts +9 -2
- package/src/server/host/dedicated/cellProtocol.ts +1 -1
- package/src/server/host/dedicated/cellWorker.ts +2 -2
- package/src/server/host/dedicated/dedicatedRoom.ts +22 -4
- package/src/server/host/dedicated/gridCells.ts +5 -3
- package/src/server/host/dedicated/main.ts +6 -4
- package/src/server/host/dedicated/roadRoom.ts +3 -0
- package/src/server/host/dedicated/workerTable.ts +0 -10
- package/src/server/host/dedicated/world.ts +39 -5
- package/src/server/host/standalone/cellWorld.ts +1 -1
- package/src/server/host/standalone/gridServer.ts +1 -1
- package/src/shared/engine/boot/loadingWaits.ts +10 -2
- package/src/shared/engine/core/config.ts +3 -0
- package/src/shared/engine/player/hoverSpeed.ts +3 -3
- package/src/shared/engine/saves/shape.ts +17 -2
- package/src/shared/engine/strings.ts +22 -1
- package/src/shared/game/grid/placementRows.ts +4 -3
- package/src/shared/game/grid/rules.ts +12 -0
- package/src/client/game/grid/cellLoading.ts +0 -110
- package/src/client/game/grid/cellScreens.ts +0 -48
|
@@ -7,7 +7,7 @@ import { app } from '../app/runtime';
|
|
|
7
7
|
import { uiScope, mountUi } from './ownership';
|
|
8
8
|
import { listenTap } from '../input/dom';
|
|
9
9
|
import { copyText, diagnosticsSource, DOCTOR_EARLIER_KEY } from './diagnosticsCopy';
|
|
10
|
-
import
|
|
10
|
+
import { Scope } from '../../../shared/engine/app/scope';
|
|
11
11
|
|
|
12
12
|
const scope = uiScope('loadFailure', app.engineScope);
|
|
13
13
|
|
|
@@ -28,19 +28,61 @@ export function doctorUrl(from: string, at: Location = location): string {
|
|
|
28
28
|
return url.href;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
/** FM8 mode 14: how long the doctor's preflight may take before it counts as failed. */
|
|
32
|
+
const DOCTOR_PREFLIGHT_MS = 8000;
|
|
33
|
+
/** FM8 mode 14 (meta MMO-FAILURE-MODES-PLAN): a same-origin preflight of the doctor's own page. It says only that this one
|
|
34
|
+
* request answered now; it can't promise the document's later reads will, so a pass never claims more. Null when it answered. */
|
|
35
|
+
export async function doctorPreflight(url: string, read: typeof fetch = fetch, deadlineMs: number = DOCTOR_PREFLIGHT_MS): Promise<string | null> {
|
|
36
|
+
const abort = new AbortController(), timer = setTimeout(() => { abort.abort(); }, deadlineMs);
|
|
37
|
+
try {
|
|
38
|
+
const response = await read(url, { method: 'HEAD', cache: 'no-store', signal: abort.signal });
|
|
39
|
+
return response.ok ? null : engineString('s_doctor_http_status', [response.status]);
|
|
40
|
+
} catch { return abort.signal.aborted ? engineString('s_doctor_http_slow', [Math.round(deadlineMs / 1000)]) : engineString('s_doctor_http_none'); }
|
|
41
|
+
finally { clearTimeout(timer); }
|
|
42
|
+
}
|
|
43
|
+
/** The doctor-http card on screen, if any: a new one (or a repeated `ws:doctor`) closes it, scope and all. */
|
|
44
|
+
let doctorCardClose: (() => void) | null = null;
|
|
45
|
+
/** FM8 mode 14's card: the doctor didn't open, and this page stays as it was. Try again re-checks with the card up (a failure
|
|
46
|
+
* replaces it, a pass leaves the page); Back closes the card. */
|
|
47
|
+
function doctorHttpCard(measured: string, again: () => Promise<boolean>): void {
|
|
48
|
+
doctorCardClose?.();
|
|
49
|
+
const card = document.createElement('div'), box = document.createElement('div'), title = document.createElement('h1'), body = document.createElement('p');
|
|
50
|
+
const retry = document.createElement('button'), back = document.createElement('button'), details = document.createElement('details'), summary = document.createElement('summary'), fact = document.createElement('p');
|
|
51
|
+
card.dataset['failmode'] = 'doctor-http'; card.dataset['tone'] = 'warn'; card.setAttribute('role', 'alertdialog'); card.setAttribute('aria-modal', 'true'); card.setAttribute('aria-label', engineString('s_doctor_http_title'));
|
|
52
|
+
card.style.cssText = 'position:fixed;inset:0;z-index:2147482600;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(4,9,14,.62);color:#e6f2f8;font:12px/1.5 "JetBrains Mono",Menlo,monospace';
|
|
53
|
+
box.style.cssText = 'width:min(440px,100%);padding:22px 18px 16px;background:rgba(13,27,38,.92);border:1px solid rgba(143,227,255,.35);display:flex;flex-direction:column;gap:10px';
|
|
54
|
+
title.textContent = engineString('s_doctor_http_title'); title.style.cssText = 'margin:0;font:700 24px/1.1 Rajdhani,Bahnschrift,sans-serif;letter-spacing:.1em;text-transform:uppercase;color:#fff';
|
|
55
|
+
body.textContent = engineString('s_doctor_http_body'); body.style.margin = '0';
|
|
56
|
+
const button = 'min-height:48px;padding:13px 16px;cursor:pointer;font:700 12px/1 "JetBrains Mono",Menlo,monospace;letter-spacing:.22em;text-transform:uppercase;border:1px solid rgba(143,227,255,.35);background:rgba(13,27,38,.6);color:#e6f2f8';
|
|
57
|
+
retry.type = 'button'; retry.className = 'go'; retry.textContent = engineString('s_doctor_http_retry'); retry.style.cssText = `${button};border-color:#8fe3ff;background:rgba(143,227,255,.18)`;
|
|
58
|
+
back.type = 'button'; back.textContent = engineString('s_doctor_http_back'); back.style.cssText = button;
|
|
59
|
+
summary.textContent = engineString('s_doctor_http_details'); fact.textContent = engineString('s_doctor_http_fact', [measured]); fact.style.cssText = 'margin:8px 0 0;opacity:.6';
|
|
60
|
+
details.append(summary, fact);
|
|
61
|
+
const owner = new Scope('doctor-http', scope), close = (): void => { if (doctorCardClose === close) doctorCardClose = null; owner.dispose(); card.remove(); };
|
|
62
|
+
doctorCardClose = close;
|
|
63
|
+
owner.listen(retry, 'click', () => { retry.disabled = true; retry.textContent = engineString('s_doctor_http_checking'); void again(); });
|
|
64
|
+
owner.listen(back, 'click', close);
|
|
65
|
+
box.append(title, body, retry, back, details); card.append(box);
|
|
66
|
+
mountUi(card, owner, document.body);
|
|
67
|
+
retry.focus();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Leave for the doctor: a held session saves first, and the page's report and the way back go with it. FM8 mode 14: a doctor page
|
|
71
|
+
* that doesn't answer its preflight leaves this page as it was, with a card saying so. Resolves true when the page leaves. */
|
|
72
|
+
export async function openDoctorPage(from: string, read: typeof fetch = fetch): Promise<boolean> {
|
|
73
|
+
const url = doctorUrl(from), failed = await doctorPreflight(url, read);
|
|
74
|
+
if (failed !== null) { doctorHttpCard(failed, () => openDoctorPage(from, read)); return false; }
|
|
75
|
+
const report = diagnosticsSource();
|
|
34
76
|
try {
|
|
35
77
|
// oxlint-disable-next-line wildshard/no-raw-save -- one tab-scoped handoff key the doctor's page reads; that page loads no save service
|
|
36
|
-
sessionStorage.setItem(DOCTOR_EARLIER_KEY, JSON.stringify({ earlier:
|
|
78
|
+
sessionStorage.setItem(DOCTOR_EARLIER_KEY, JSON.stringify({ earlier: report === null ? null : report(), back: `${location.pathname}${location.search}` }));
|
|
37
79
|
} catch { /* storage refused: the doctor still runs, its report is just shorter */ }
|
|
38
|
-
const url = doctorUrl(from);
|
|
39
80
|
leaveSaved(() => { markUnload('doctor'); location.assign(url); });
|
|
81
|
+
return true;
|
|
40
82
|
}
|
|
41
83
|
|
|
42
84
|
// The online page's own module graph (src/client/host/online/shell.ts) asks by event: it can't share this bundle's save hold.
|
|
43
|
-
scope.listen(document, 'ws:doctor', event => { openDoctorPage(event instanceof CustomEvent && typeof event.detail === 'string' ? event.detail : 'online'); });
|
|
85
|
+
scope.listen(document, 'ws:doctor', event => { void openDoctorPage(event instanceof CustomEvent && typeof event.detail === 'string' ? event.detail : 'online'); });
|
|
44
86
|
|
|
45
87
|
/** Settings ▸ Connection: the doctor for everyone, beside Offline play (the title's Settings and the pause menu's saves). */
|
|
46
88
|
export function buildConnectionRow(owner: Scope): HTMLElement {
|
|
@@ -48,7 +90,7 @@ export function buildConnectionRow(owner: Scope): HTMLElement {
|
|
|
48
90
|
const label = document.createElement('div'); label.className = 'ws-gmenu-label'; label.textContent = engineString('s_doctor_title');
|
|
49
91
|
const note = document.createElement('div'); note.className = 'ws-gmenu-note'; note.textContent = engineString('s_doctor_note');
|
|
50
92
|
const go = document.createElement('button'); go.type = 'button'; go.className = 'ws-gmenu-btn ws-gmenu-doctor'; go.textContent = engineString('s_doctor_open');
|
|
51
|
-
listenTap(owner, go, () => { go.disabled = true; openDoctorPage('settings'); });
|
|
93
|
+
listenTap(owner, go, () => { go.disabled = true; void openDoctorPage('settings').then(left => { go.disabled = left; return left; }); });
|
|
52
94
|
box.append(label, note, go);
|
|
53
95
|
return box;
|
|
54
96
|
}
|
|
@@ -98,7 +140,7 @@ export function showLoadFailure(failure: LoadFailure): HTMLElement {
|
|
|
98
140
|
const doctor = document.createElement('button');
|
|
99
141
|
doctor.type = 'button'; doctor.className = 'ws-load-doctor'; doctor.textContent = engineString('s_doctor_failed');
|
|
100
142
|
doctor.style.cssText = button;
|
|
101
|
-
listenTap(scope, doctor, () => { doctor.disabled = true; openDoctorPage('ls4'); });
|
|
143
|
+
listenTap(scope, doctor, () => { doctor.disabled = true; void openDoctorPage('ls4').then(left => { doctor.disabled = left; return left; }); });
|
|
102
144
|
actions.append(doctor);
|
|
103
145
|
root.append(heading, context, message, stack, actions);
|
|
104
146
|
mountUi(root, scope, document.body);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Scope } from '../../../shared/engine/app/scope';
|
|
2
2
|
import type { Events } from '../../../shared/engine/events/events';
|
|
3
|
+
import { engineString } from '../../../shared/engine/strings';
|
|
3
4
|
import { isDev, onDev } from '../core/devMode';
|
|
4
5
|
|
|
5
6
|
// QA row 42 (Jake, 2026-11-10): "Let's get rid of the boost button. Let's make boost be like an undocumented double tap on the
|
|
@@ -50,12 +51,38 @@ export function pressHover(player: HoverPort, taps: HoverTaps, now: number): voi
|
|
|
50
51
|
/** Boost shows while it moves the board: Developer mode, riding, latched. */
|
|
51
52
|
export const boostShown = (player: Pick<HoverPort, 'hover' | 'hoverBoost'>): boolean => isDev() && player.hover && player.hoverBoost;
|
|
52
53
|
|
|
53
|
-
/** The
|
|
54
|
-
|
|
55
|
-
const
|
|
54
|
+
/** The word BOOST, hidden until `follow` shows it. */
|
|
55
|
+
function boostWord(scope: Scope): HTMLElement {
|
|
56
|
+
const word = document.createElement('b');
|
|
57
|
+
word.className = 'ws-touch-boost-word'; word.textContent = engineString('s_hover_boost'); word.hidden = true;
|
|
58
|
+
scope.onDispose(() => { word.remove(); });
|
|
59
|
+
return word;
|
|
60
|
+
}
|
|
61
|
+
/** Run `show` with whether boost is shown now and on every change that can move it, until `scope` ends. */
|
|
62
|
+
function follow(player: Pick<HoverPort, 'hover' | 'hoverBoost'>, events: Events, scope: Scope, show: (on: boolean) => void): void {
|
|
63
|
+
const sync = (): void => { show(boostShown(player)); };
|
|
56
64
|
events.on('player.hover', sync, scope);
|
|
57
65
|
events.on('player.boost', sync, scope);
|
|
58
66
|
scope.onDispose(onDev(sync));
|
|
59
|
-
scope.onDispose(() => { button.classList.remove('boost'); });
|
|
60
67
|
sync();
|
|
61
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The HOVER tab turns amber (`.boost`) while boost is shown, and says BOOST under its HOVER. QA 11-15 row 9 (Jake: "I want that little
|
|
72
|
+
* icon on the left edge of the screen to say hover boost. I just want the word boost there, boost is on. I want the word boost gone [when]
|
|
73
|
+
* boost is off."): the word is there only while boost is on.
|
|
74
|
+
*/
|
|
75
|
+
export function mountBoostLook(button: HTMLElement, player: Pick<HoverPort, 'hover' | 'hoverBoost'>, events: Events, scope: Scope): void {
|
|
76
|
+
const word = boostWord(scope);
|
|
77
|
+
button.append(word);
|
|
78
|
+
scope.onDispose(() => { button.classList.remove('boost'); });
|
|
79
|
+
follow(player, events, scope, on => { button.classList.toggle('boost', on); word.hidden = !on; });
|
|
80
|
+
}
|
|
81
|
+
/** QA 11-15 row 9 on a keyboard page, which has no HOVER tab: the same word on the left edge, where the phone's tab stands, only while
|
|
82
|
+
* boost is on. */
|
|
83
|
+
export function mountBoostTag(hud: HTMLElement, player: Pick<HoverPort, 'hover' | 'hoverBoost'>, events: Events, scope: Scope): void {
|
|
84
|
+
const tag = boostWord(scope);
|
|
85
|
+
tag.classList.add('ws-touch-boost-tag');
|
|
86
|
+
hud.append(tag);
|
|
87
|
+
follow(player, events, scope, on => { tag.hidden = !on; });
|
|
88
|
+
}
|
|
@@ -300,4 +300,10 @@ html[data-ws-keyboard] .ws-touch { visibility: hidden; pointer-events: none; }
|
|
|
300
300
|
|
|
301
301
|
/* QA row 42: no BOOST button. A double tap of HOVER latches Developer boost; the tab burns amber while it moves the board
|
|
302
302
|
(ui/hoverBoost.ts `.boost`), as do the board's repulsors. */
|
|
303
|
+
/* QA 11-15 row 9: the word BOOST under HOVER while boost is on, gone while it is off (ui/hoverBoost.ts `.ws-touch-boost-word`). A keyboard
|
|
304
|
+
page has no tab: the word stands alone on the left edge, at the tab's height, in the tab's amber. */
|
|
305
|
+
.ws-touch-boost-word { display: block; font: inherit; font-weight: 700; letter-spacing: inherit; line-height: 1; }
|
|
306
|
+
.ws-touch-boost-word[hidden] { display: none; }
|
|
307
|
+
#hud .ws-touch-boost-tag { position: absolute; z-index: calc(var(--ws-layer-hud) + 2); left: env(safe-area-inset-left, 0px); top: 46%; transform: translateY(-50%); padding: 8px 10px 8px 8px; border: 1px solid var(--ws-amber); border-left: 0; border-radius: 0 10px 10px 0; background: var(--ws-amber); color: #2a1600; box-shadow: 0 0 0 2px rgba(255, 181, 71, 0.35), 0 0 18px rgba(255, 181, 71, 0.75); font-family: var(--ws-mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; pointer-events: none; }
|
|
308
|
+
#hud .ws-touch-boost-tag[hidden] { display: none; }
|
|
303
309
|
#hud .ws-touch .ws-touch-hover.on.boost { color: #2a1600; border-color: var(--ws-amber); background: var(--ws-amber); box-shadow: 0 0 0 2px rgba(255, 181, 71, 0.35), 0 0 18px rgba(255, 181, 71, 0.75); text-shadow: none; font-weight: 700; }
|
|
@@ -2,7 +2,11 @@ import {joinSpawnManifest, packsBookPath, readSpawnCodeList, readSpawnManifest,
|
|
|
2
2
|
import {assetCacheName} from '@wildshard/engine/pwa/cacheNames';
|
|
3
3
|
import {jsonSlot} from '@wildshard/engine/saves/slots';
|
|
4
4
|
import { bootMark,bootProgress,bootTiming,downloadShown } from '@wildshard/engine/boot/timing';
|
|
5
|
+
import { beginLoadingWait, finishLoadingWait } from '@wildshard/engine/boot/loadingWaits';
|
|
6
|
+
import { diagnosticNow } from '@wildshard/engine/core/clock';
|
|
7
|
+
import { Scope } from '@wildshard/engine/app/scope';
|
|
5
8
|
import {contentBase, contentURL, isContentOrigin, pageURL} from '@wildshard/engine/boot/contentBase';
|
|
9
|
+
import { clearDownloadGiveUp, noteDownloadGiveUp } from '@wildshard/engine/boot/downloadGiveUp';
|
|
6
10
|
import {bareSlug} from '../../../shared/game/grid/catalogueSlot';
|
|
7
11
|
import {placedLoose, placedSpawn} from './placedSpawn';
|
|
8
12
|
|
|
@@ -315,7 +319,8 @@ function isQuota(failure: unknown): boolean { return typeof failure === 'object'
|
|
|
315
319
|
* worker-cache response credits immediately without reading/checksumming it. */
|
|
316
320
|
export function downloadSpawnManifest(address: SpawnManifestAddress, ports: SpawnDownloadPorts, base: string, packs: string = base): SpawnDownload {
|
|
317
321
|
const controller = new AbortController(), listeners = new Set<(snapshot: SpawnDownloadSnapshot) => void>(), aliases = new Map<string, string>();
|
|
318
|
-
let cacheWriteDenied = false;
|
|
322
|
+
let cacheWriteDenied = false, storageFull: number | null = null;
|
|
323
|
+
const endStorageFull = (): void => { if (storageFull !== null) finishLoadingWait(storageFull); storageFull = null; };
|
|
319
324
|
// Verified bytes remain usable when optional disk publication exhausts quota.
|
|
320
325
|
// Do not retry the part, claim cached credit, or publish an index for unkept bytes.
|
|
321
326
|
const keepCopy = async (write: SpawnDownloadPorts['store'], url: string, response: Response): Promise<boolean> => {
|
|
@@ -326,7 +331,10 @@ export function downloadSpawnManifest(address: SpawnManifestAddress, ports: Spaw
|
|
|
326
331
|
await write(url, response); retained = true; return true;
|
|
327
332
|
} catch (failure) {
|
|
328
333
|
if (!isQuota(failure)) throw failure;
|
|
329
|
-
cacheWriteDenied = true; bootMark('download:cache-write-quota');
|
|
334
|
+
cacheWriteDenied = true; bootMark('download:cache-write-quota');
|
|
335
|
+
// FM6 mode 43: the card says so while this download runs; the world plays on from the bytes in memory
|
|
336
|
+
storageFull ??= beginLoadingWait('Storage is full', { kind: 'work', failmode: 'storage-full', line: 'Storage is full · the world will load more slowly' });
|
|
337
|
+
return false;
|
|
330
338
|
} finally { if (!retained) void response.body?.cancel().catch(() => undefined); }
|
|
331
339
|
};
|
|
332
340
|
let completedBytes = 0, cachedBytes = 0, filesDone = 0, complete = false, progressKnown = false, error: string | null = null;
|
|
@@ -382,6 +390,9 @@ export function downloadSpawnManifest(address: SpawnManifestAddress, ports: Spaw
|
|
|
382
390
|
let markListed = (): void => undefined, markStopped = (_reason: unknown): void => undefined;
|
|
383
391
|
const listedOnly = new Promise<void>(resolve => { markListed = resolve; });
|
|
384
392
|
const stopped = new Promise<never>((_resolve, reject) => { markStopped = reject; });
|
|
393
|
+
// FM6 mode 36: a part that ran out of reads, and the last status a part answered (no HTTP response: null)
|
|
394
|
+
const exhausted: { fact: { readonly status: number | null; readonly detail: string } | null } = { fact: null };
|
|
395
|
+
clearDownloadGiveUp();
|
|
385
396
|
const work = (async () => {
|
|
386
397
|
try {
|
|
387
398
|
// OVERNIGHT 6e: the manifest and its code list, read together. The list is the build's own, read from the content base
|
|
@@ -599,9 +610,13 @@ export function downloadSpawnManifest(address: SpawnManifestAddress, ports: Spaw
|
|
|
599
610
|
const file = files[index]; if (file === undefined) continue;
|
|
600
611
|
members.set(file.url, new Promise(resolve => {settle.set(index, resolve); memberSettles.add(resolve);}));
|
|
601
612
|
}
|
|
613
|
+
// FM6 mode 36: this part's last failed HTTP status (null: no response, or a body that broke)
|
|
614
|
+
let status: number | null = null;
|
|
602
615
|
// One read of the part. A read after a failure starts over and skips what landed, so no member counts twice.
|
|
603
616
|
const read = async (init: RequestInit | undefined): Promise<void> => {
|
|
617
|
+
status = null;
|
|
604
618
|
const response = await ports.fetch(onPacks(part.url, packs), controller.signal, init);
|
|
619
|
+
if (!response.ok) status = response.status;
|
|
605
620
|
if (!response.ok || response.body === null) throw new Error(`Spawn part unavailable: ${part.url}`);
|
|
606
621
|
const body = new Uint8Array(part.bytes), reader = response.body.getReader();
|
|
607
622
|
let at = 0, next = 0;
|
|
@@ -643,7 +658,7 @@ export function downloadSpawnManifest(address: SpawnManifestAddress, ports: Spaw
|
|
|
643
658
|
const last = attempt >= PART_READS || controller.signal.aborted;
|
|
644
659
|
if (last) for (const [index] of order) { const file = files[index]; if (file !== undefined) landed(file.url); }
|
|
645
660
|
controller.signal.throwIfAborted();
|
|
646
|
-
if (attempt >= PART_READS) throw failure; // the job's failure answers every read still waiting
|
|
661
|
+
if (attempt >= PART_READS) { exhausted.fact ??= { status, detail: failure instanceof Error ? failure.message : String(failure) }; throw failure; } // the job's failure answers every read still waiting
|
|
647
662
|
if (attempt > 1) { await partPause(); controller.signal.throwIfAborted(); }
|
|
648
663
|
}
|
|
649
664
|
}
|
|
@@ -682,6 +697,9 @@ export function downloadSpawnManifest(address: SpawnManifestAddress, ports: Spaw
|
|
|
682
697
|
} catch (failure) {
|
|
683
698
|
// A read waiting on a file this download will not store falls through to the network.
|
|
684
699
|
releaseWaits();
|
|
700
|
+
// FM6 mode 36: a part out of reads refused the job (a cancel is no refusal); a read that falls through and fails too shows
|
|
701
|
+
// the download-failed page, not RETRY's line alone (contentRead.ts)
|
|
702
|
+
if (!controller.signal.aborted && exhausted.fact !== null) noteDownloadGiveUp({ attempts: PART_READS, ...exhausted.fact });
|
|
685
703
|
error = failure instanceof Error ? failure.message : String(failure); publish(); controller.abort(); nudge(); throw failure;
|
|
686
704
|
}
|
|
687
705
|
})();
|
|
@@ -690,11 +708,12 @@ export function downloadSpawnManifest(address: SpawnManifestAddress, ports: Spaw
|
|
|
690
708
|
// The tap starts work before its composition root reaches the await. Keep
|
|
691
709
|
// its original rejection for that await without a premature global report.
|
|
692
710
|
void work.catch(() => undefined); void ready.catch(() => undefined);
|
|
711
|
+
void ready.finally(endStorageFull).catch(() => undefined);
|
|
693
712
|
const listed = Promise.race([listedOnly, ready]);
|
|
694
713
|
void listed.catch(() => undefined);
|
|
695
714
|
return {ready, listed, snapshot, subscribe: listener => {listeners.add(listener); listener(snapshot()); return () => {listeners.delete(listener);};},
|
|
696
715
|
resolve: input => {const url = new URL(input, base); return url.origin === new URL(base).origin ? aliases.get(url.pathname) ?? url.href : url.href;},
|
|
697
|
-
cancel: () => {controller.abort(); releaseWaits(); nudge(); markStopped(controller.signal.reason); listeners.clear();}};
|
|
716
|
+
cancel: () => {controller.abort(); endStorageFull(); releaseWaits(); nudge(); markStopped(controller.signal.reason); listeners.clear();}};
|
|
698
717
|
}
|
|
699
718
|
|
|
700
719
|
let current: {key: string; download: SpawnDownload; foreground: boolean} | undefined;
|
|
@@ -847,6 +866,36 @@ function spawnSelection(slug: string, flow: 'client' | 'grid', tier: 'phone' | '
|
|
|
847
866
|
declare const __BUILD_ID__: string;
|
|
848
867
|
let packsBook: {readonly url: string; readonly book: Promise<unknown>} | undefined;
|
|
849
868
|
const PACKS_BOOK_MS = 20_000;
|
|
869
|
+
/** FM6 mode 35 (meta MMO-FAILURE-MODES-PLAN): a server error or busy answer on the book is read again on content's ladder (a
|
|
870
|
+
* 429's Retry-After as told, at least 2 s) for up to BOOK_TRIES reads, the loading card saying `book-5xx` meanwhile, before the
|
|
871
|
+
* named refusal. FM3's proof found a single 503 refusing the whole start ("Something broke"). A 404 still refuses at once. */
|
|
872
|
+
const BOOK_LINE = 'The world\'s book didn\'t arrive';
|
|
873
|
+
const BOOK_TRIES = 6, BOOK_LADDER_MS: readonly number[] = [2000, 4000, 8000, 16_000, 30_000];
|
|
874
|
+
async function bookResponse(url: string, fresh: () => AbortSignal, stalled: (error: unknown) => never): Promise<Response> {
|
|
875
|
+
let wait: number | undefined, shellFoot: HTMLElement | null = null;
|
|
876
|
+
try {
|
|
877
|
+
for (let attempt = 0; ; attempt++) {
|
|
878
|
+
// each read has its own 20 s limit (DL21), body included; the waits between reads are the ladder's, not a stall
|
|
879
|
+
const response = await fetch(url, {signal: fresh()}).catch(stalled);
|
|
880
|
+
if (response.ok) return response;
|
|
881
|
+
const busy = response.status === 429 || response.status >= 500;
|
|
882
|
+
if (!busy || attempt + 1 >= BOOK_TRIES) throw new Error(`Packs book unavailable (${response.status})`);
|
|
883
|
+
void response.body?.cancel().catch(() => undefined);
|
|
884
|
+
const told = Number(response.headers.get('retry-after'));
|
|
885
|
+
const ms = Math.max(2000, response.status === 429 && Number.isFinite(told) && told > 0 ? Math.min(told, 60) * 1000 : BOOK_LADDER_MS[attempt] ?? 30_000);
|
|
886
|
+
// at START, before Loading owns the card, only the shell's foot is on screen: it says so too (Loading repaints it later)
|
|
887
|
+
const foot = document.querySelector?.<HTMLElement>('.ws-load [data-el="foot"]') ?? null;
|
|
888
|
+
if (foot !== null) { foot.textContent = BOOK_LINE; foot.dataset['failmode'] = 'book-5xx'; shellFoot = foot; }
|
|
889
|
+
if (wait === undefined) wait = beginLoadingWait('Packs book', {kind: 'file', resource: url, failmode: 'book-5xx', line: BOOK_LINE, dueAt: diagnosticNow() + ms});
|
|
890
|
+
else { finishLoadingWait(wait); wait = beginLoadingWait('Packs book', {kind: 'file', resource: url, failmode: 'book-5xx', line: BOOK_LINE, dueAt: diagnosticNow() + ms}); }
|
|
891
|
+
const pause = new Scope('packs-book-retry');
|
|
892
|
+
try { await new Promise<void>(resolve => { pause.timeout(ms, resolve); }); } finally { pause.dispose(); }
|
|
893
|
+
}
|
|
894
|
+
} finally {
|
|
895
|
+
if (wait !== undefined) finishLoadingWait(wait);
|
|
896
|
+
if (shellFoot?.dataset['failmode'] === 'book-5xx') { delete shellFoot.dataset['failmode']; shellFoot.textContent = ''; }
|
|
897
|
+
}
|
|
898
|
+
}
|
|
850
899
|
function readPacksBook(): Promise<unknown> {
|
|
851
900
|
const url = contentURL(new URL(`/${packsBookPath(__BUILD_ID__)}`, document.baseURI).href);
|
|
852
901
|
if (packsBook?.url === url) return packsBook.book;
|
|
@@ -854,11 +903,11 @@ function readPacksBook(): Promise<unknown> {
|
|
|
854
903
|
try {
|
|
855
904
|
// DL21 (E526): a stalled book is a named refusal with the loading card's retry, never an endless wait.
|
|
856
905
|
// The limit covers the body too (sp-x9): a stalled body is the same named refusal.
|
|
857
|
-
|
|
906
|
+
let signal = AbortSignal.timeout(PACKS_BOOK_MS);
|
|
907
|
+
const stalled = (error: unknown): never => {
|
|
858
908
|
throw signal.aborted ? new Error(`Packs book did not arrive in ${PACKS_BOOK_MS / 1000} s`) : error;
|
|
859
909
|
};
|
|
860
|
-
const response = await
|
|
861
|
-
if (!response.ok) throw new Error(`Packs book unavailable (${response.status})`);
|
|
910
|
+
const response = await bookResponse(url, () => (signal = AbortSignal.timeout(PACKS_BOOK_MS)), stalled);
|
|
862
911
|
const value: unknown = await response.json().catch(stalled);
|
|
863
912
|
// Bound to its purpose and this build: a valid default book or another build's book is refused (sp-x9).
|
|
864
913
|
if (get(value, 'book') !== 'packs' || get(value, 'build') !== __BUILD_ID__) throw new Error('Packs book is not this build\'s whole-level book');
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* which runs the scene. The page offers them only while the feet stand in the entered copy (`enteredCopy`), and they go
|
|
7
7
|
* with the region (built at admission, dropped at its disposal).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* An item scene's prompt (`targets.itemActions`: Brasscap's rack) is offered too (TEMPLATE-E2E TC-E1b): an entered copy holds
|
|
10
|
+
* its declared kit (`dataCellKit.ts`), and the server runs the scene on the held item, as it does a standalone page's.
|
|
11
11
|
*/
|
|
12
12
|
import { Vector3 } from 'three';
|
|
13
13
|
import type { ShardRuntime } from '../../../shared/game/shard/runtime';
|
|
@@ -17,8 +17,7 @@ type Interactable = ShardRuntime['interactables'][number];
|
|
|
17
17
|
|
|
18
18
|
/** The copy's declared interactions as frame-local prompts the server answers. */
|
|
19
19
|
export function copyPrompts(source: Pick<Shardfile, 'targets'>): Interactable[] {
|
|
20
|
-
|
|
21
|
-
return source.targets.interactions.filter((row) => !items.has(row.scene)).map((row) => ({
|
|
20
|
+
return source.targets.interactions.map((row) => ({
|
|
22
21
|
position: new Vector3(...row.at), radius: row.radius, label: row.label, wireId: row.id, onInteract: () => undefined,
|
|
23
22
|
}));
|
|
24
23
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A grid data cell's declared items, in hand while the feet stand in it (TEMPLATE-E2E TC-E1b). Standalone, a shardfile shard's
|
|
3
|
+
* client builds its `items` rows into the page's equipment (`client.ts` `buildEquipment`); in the grid a data cell (no runtime,
|
|
4
|
+
* no declared client page: the templates) has no client of its own, so it held bare hands (G68) and Brasscap's lever never came
|
|
5
|
+
* to hand. Entering the cell now builds its rows (kit families, item models) into one equipment service bound under the page's
|
|
6
|
+
* controls (`EnteredEquipment.bind`); leaving disposes it and the road's bare hands come back.
|
|
7
|
+
*
|
|
8
|
+
* On the wire the server owns every round: the kit takes the road's weapon wire, so a press, a reload and the held row go to the
|
|
9
|
+
* server's seat for this cell (its slots are the cell's `enteredItems`), and a declared lever follows the server's owned lines
|
|
10
|
+
* (rounds, reserve, taken) as the standalone client's does. An item request (a rack's take) is the scene the server runs it by.
|
|
11
|
+
*/
|
|
12
|
+
import { Object3D, Vector3 } from 'three';
|
|
13
|
+
import type { Scope } from '@wildshard/engine/app/scope';
|
|
14
|
+
import type { Actor, CombatTarget } from '@wildshard/engine/combat/pipeline';
|
|
15
|
+
import type { ItemTarget } from '@wildshard/engine/combat/items';
|
|
16
|
+
import { EquipmentService } from '@wildshard/engine/combat/EquipmentService';
|
|
17
|
+
import type { Weapon } from '@wildshard/engine/combat/Weapon';
|
|
18
|
+
import { playerModes } from '@wildshard/engine/player/modes';
|
|
19
|
+
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
20
|
+
import { installDeclaredItems, leverLines } from '../../../shared/game/shardfile/items';
|
|
21
|
+
import { declaredItemIcon, declaredKitItemFamilies, declaredLever } from '../plugin/weaponFamily';
|
|
22
|
+
import { itemScene } from '../shardfile/clientItems';
|
|
23
|
+
import { loadItemModels } from '../shardfile/itemModels';
|
|
24
|
+
import { wirePage } from '../shardfile/wirePage';
|
|
25
|
+
import type { RegionalRuntimePage } from './regionalRuntime';
|
|
26
|
+
|
|
27
|
+
function isItemModel(value: unknown): value is Object3D { return value instanceof Object3D; }
|
|
28
|
+
|
|
29
|
+
/** Whether a data cell has anything to hold: a declared weapon (a kit is built around one). */
|
|
30
|
+
export function holdsItems(source: Pick<Shardfile, 'items'>): boolean {
|
|
31
|
+
return source.items.rows.some(row => row.kind === 'weapon');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Build the cell's declared kit under `entry` and bind it as the page's held equipment until `entry` is disposed. */
|
|
35
|
+
/** `here`: whether the wire's frames are this cell's (a crossing's frames are another's, and their lines are not this kit's). */
|
|
36
|
+
export async function enterDataCellKit(source: Shardfile, assets: ReadonlyMap<string, Uint8Array>, page: RegionalRuntimePage, entry: Scope, here: () => boolean = () => true): Promise<EquipmentService | null> {
|
|
37
|
+
const controls = page.equipment;
|
|
38
|
+
if (controls === undefined || !holdsItems(source)) return null;
|
|
39
|
+
const models = await loadItemModels(source.items, assets, entry);
|
|
40
|
+
if (entry.disposed || entry.disposing) return null;
|
|
41
|
+
const { app } = page.context, camera = page.world.game.camera, player = page.world.player;
|
|
42
|
+
const health = (): NonNullable<typeof app.player> => { const actor = app.player; if (actor === null) throw new Error('Player health has not entered play'); return actor; };
|
|
43
|
+
const actor: Actor = { id: 'actor.player', get tags() { return health().tags; }, get state() { return health().state; }, get attributes() { return health().attributes; }, get alive() { return health().alive; }, applyDamage: (request) => health().applyDamage(request) };
|
|
44
|
+
const aimTarget = (target: CombatTarget): ItemTarget => {
|
|
45
|
+
const { dims, scale = 1 } = target.target;
|
|
46
|
+
return { ...target, aimPoint: target.position.clone().add(new Vector3(0, dims === undefined ? 0.9 : dims.bodyY * scale, 0)) };
|
|
47
|
+
};
|
|
48
|
+
const items = installDeclaredItems(source.items, { scope: entry, actorId: actor.id, input: app.input, bindings: app.input.bindings,
|
|
49
|
+
observation: { get mode() { return playerModes(player).current(); }, get item() { return app.equipment?.current.row.id ?? null; }, get flags() { return wirePage.client === null ? [] : [...wirePage.client.flags()]; } },
|
|
50
|
+
families: declaredKitItemFamilies(), models, icon: declaredItemIcon,
|
|
51
|
+
aim: () => ({ origin: camera.getWorldPosition(new Vector3()), direction: camera.getWorldDirection(new Vector3()) }),
|
|
52
|
+
// SR11 (C9): on the wire an item request is the scene the server takes it by
|
|
53
|
+
relay: (item, action) => { const scene = itemScene(source, item, action); if (scene === undefined || wirePage.client === null) return false; wirePage.send(scene); return true; },
|
|
54
|
+
runtime: row => ({ actor, combat: app.combat, active: () => app.state === 'play',
|
|
55
|
+
targets: () => app.combat.targets().map(aimTarget),
|
|
56
|
+
effect: (target, effect, from) => { const service = app.effects; if (service === null) throw new Error('Missing normal effect host'); service.apply(target, effect, from); },
|
|
57
|
+
hook: row.hook === null ? null : (command) => command.action, // the server runs an item's script on the wire
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
const weapons: readonly Weapon[] = [items.primary, items.secondary, ...items.extras].filter((weapon): weapon is Weapon => weapon !== null);
|
|
61
|
+
const first = weapons[0];
|
|
62
|
+
if (first === undefined) return null;
|
|
63
|
+
const kit = new EquipmentService(first, { scope: entry, events: app.events, input: { bind: (action, run, _scope, allowed) => { app.input.bind(action, run, entry, allowed ?? (() => kit.enabled)); } }, order: [...items.order] });
|
|
64
|
+
for (const weapon of weapons) if (weapon !== first) kit.add(weapon, { locked: true });
|
|
65
|
+
items.install(kit);
|
|
66
|
+
// the held models hang off the page's viewmodel, as a standalone page's do (client.ts)
|
|
67
|
+
const host = app.equipmentHost;
|
|
68
|
+
if (host !== null) for (const item of [...weapons, ...items.tools]) {
|
|
69
|
+
const model: unknown = Reflect.get(item, 'model');
|
|
70
|
+
if (isItemModel(model)) { host.viewmodel.add(model); entry.onDispose(() => { model.removeFromParent(); }); }
|
|
71
|
+
}
|
|
72
|
+
// the road's switches, read before the kit takes the controls: the page's reveal, menu and safe zone set them on the controls,
|
|
73
|
+
// which set both while a kit is bound, so the kit starts where the road stands; it takes the road's wire with it
|
|
74
|
+
const road = controls.service, enabled = road.enabled, visible = road.visible;
|
|
75
|
+
controls.bind(kit, entry, { wire: true });
|
|
76
|
+
kit.enabled = enabled; kit.visible = visible; kit.stowed = false;
|
|
77
|
+
// TE-ENG2: a lever follows the server's owned lines; taken, it unlocks and comes to hand
|
|
78
|
+
const levers = weapons.flatMap(weapon => { const lever = declaredLever(weapon); return lever === null ? [] : [lever]; });
|
|
79
|
+
app.addContentSystem({ id: 'grid.data-cell-kit', phase: 'update', run: (dt, t) => {
|
|
80
|
+
for (const lever of levers) {
|
|
81
|
+
if (wirePage.client !== null && here()) {
|
|
82
|
+
const lines = leverLines(lever.row.id);
|
|
83
|
+
lever.mirror(wirePage.line(lines.rounds), wirePage.line(lines.reserve), wirePage.line(lines.reloading) > 0, wirePage.line(lines.taken) > 0);
|
|
84
|
+
}
|
|
85
|
+
if (lever.taken && !kit.has(lever.id)) { kit.unlock(lever.id); kit.select(lever.id); }
|
|
86
|
+
}
|
|
87
|
+
kit.update(dt, t);
|
|
88
|
+
} }, entry);
|
|
89
|
+
entry.onDispose(() => { kit.enabled = false; kit.visible = false; kit.adsHeld = false; kit.altHeld = false; });
|
|
90
|
+
return kit;
|
|
91
|
+
}
|
|
@@ -7,6 +7,7 @@ const callbacks = new Set<PropertyKey>(['onFire', 'onHit', 'onImpact', 'onReload
|
|
|
7
7
|
export class EnteredEquipment {
|
|
8
8
|
readonly service: EquipmentService;
|
|
9
9
|
private active: EquipmentService;
|
|
10
|
+
private wired = false;
|
|
10
11
|
constructor(private readonly road: EquipmentService) {
|
|
11
12
|
this.active = road;
|
|
12
13
|
this.service = new Proxy(road, {
|
|
@@ -26,6 +27,8 @@ export class EnteredEquipment {
|
|
|
26
27
|
owner.unlock(id); return undefined;
|
|
27
28
|
};
|
|
28
29
|
if (key === 'setEnabled') return (on: boolean) => { this.service.enabled = on; };
|
|
30
|
+
// TC-E1b: a wired kit (a data cell's) takes the road's wire with it; the road keeps it for when the kit goes
|
|
31
|
+
if (key === 'bindWire') return (wire: Parameters<EquipmentService['bindWire']>[0]) => { road.bindWire(wire); if (this.wired && this.active !== road) this.active.bindWire(wire); };
|
|
29
32
|
const value: unknown = Reflect.get(active, key, active);
|
|
30
33
|
const bound: unknown = typeof value === 'function' ? value.bind(active) : value;
|
|
31
34
|
return bound;
|
|
@@ -39,7 +42,9 @@ export class EnteredEquipment {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/** Install only after trusted play and continuation succeed; leaving restores every prior callback descriptor. */
|
|
42
|
-
|
|
45
|
+
/** `wire`: the kit plays on the server's wire as the road does (a data cell's declared kit, TC-E1b); leaving gives the server
|
|
46
|
+
* the road's held row again. A regional runtime's kit keeps its own contacts. */
|
|
47
|
+
bind(equipment: EquipmentService, entry: Scope, options: { readonly wire?: boolean } = {}): void {
|
|
43
48
|
if (entry.disposed || this.active !== this.road || equipment === this.road) throw new Error('Equipment entry is not available');
|
|
44
49
|
const prior = [...callbacks].map(key => [key, Object.getOwnPropertyDescriptor(equipment, key)] as const);
|
|
45
50
|
if (prior.some(([, descriptor]) => descriptor?.configurable === false)) throw new Error('Equipment callbacks are not configurable');
|
|
@@ -54,8 +59,12 @@ export class EnteredEquipment {
|
|
|
54
59
|
} });
|
|
55
60
|
}
|
|
56
61
|
this.active = equipment;
|
|
62
|
+
const wire = options.wire === true ? this.road.boundWire : null;
|
|
63
|
+
this.wired = options.wire === true;
|
|
64
|
+
if (wire !== null) equipment.bindWire(wire);
|
|
57
65
|
entry.onDispose(() => {
|
|
58
|
-
this.active = this.road;
|
|
66
|
+
this.active = this.road; this.wired = false;
|
|
67
|
+
if (options.wire === true) { equipment.bindWire(null); const now = this.road.boundWire; if (now !== null) this.road.bindWire(now); }
|
|
59
68
|
for (const [key, descriptor] of prior) {
|
|
60
69
|
if (descriptor === undefined) Reflect.deleteProperty(equipment, key); else Object.defineProperty(equipment, key, descriptor);
|
|
61
70
|
}
|