@wildshard/engine 0.1.18 → 0.1.19
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 +8 -0
- package/budgets/shard-size-baseline.json +10 -4
- package/index.html +6 -4
- package/lint/engine-sides.json +14 -0
- package/lint/ratchet.json +0 -68
- package/lint/ratchet.mjs +1 -4
- package/package.json +17 -15
- package/scripts/agent-sync.mjs +27 -8
- package/scripts/app-build/appCook.ts +8 -2
- package/scripts/app-build/catalogue.ts +10 -7
- package/scripts/app-build/gen.ts +22 -2
- package/scripts/app-build/isolation.d.mts +10 -0
- package/scripts/app-build/isolation.mjs +47 -0
- package/scripts/app-build/outputProducts.mjs +4 -0
- package/scripts/app-build/previousDeploy.d.mts +2 -0
- package/scripts/app-build/previousDeploy.mjs +10 -1
- package/scripts/app-build/serviceWorker.ts +10 -3
- package/scripts/app-build/splitOutput.mjs +4 -2
- package/scripts/app-build/standaloneOutput.d.mts +1 -1
- package/scripts/app-build/standaloneOutput.mjs +5 -3
- package/scripts/app-build/titlePreloads.d.mts +8 -0
- package/scripts/app-build/titlePreloads.mjs +69 -0
- package/scripts/app-build/worldMapAtlas.ts +10 -6
- package/scripts/app-build-pipeline.mjs +31 -3
- package/scripts/built-product.mjs +1 -1
- package/scripts/cell-mem-bench.mjs +81 -23
- package/scripts/check-custom-sections-zero.mjs +1 -1
- package/scripts/check-devserver.mjs +2 -0
- package/scripts/check-models.mjs +2 -0
- package/scripts/check-paths.allow.json +0 -115
- package/scripts/check-paths.mjs +2 -2
- package/scripts/check-platform-ratchets.mjs +2 -3
- package/scripts/chromium-keychain.d.mts +1 -1
- package/scripts/ci-static.sh +1 -1
- package/scripts/committed-fast-checks.mjs +0 -2
- package/scripts/content-sw-proof.mjs +2 -1
- package/scripts/cook-worker.mjs +9 -3
- package/scripts/cook.mjs +18 -5
- package/scripts/docs-inputs-proof.mjs +6 -6
- package/scripts/e7-voice-staging-proof.mjs +1 -1
- package/scripts/gate-related-tests.mjs +1 -1
- package/scripts/git-source-view.mjs +1 -1
- package/scripts/goldens/capture.mjs +17 -5
- package/scripts/grid-crossing-nightly.mjs +59 -0
- package/scripts/grid-crossing-qa.mjs +44 -0
- package/scripts/grid-crossing-ratchet.d.mts +6 -0
- package/scripts/grid-crossing-ratchet.mjs +52 -0
- package/scripts/grid-crossing-report.mjs +122 -0
- package/scripts/grid-crossing-stages.mjs +47 -0
- package/scripts/grid-crossing-tour.mjs +277 -0
- package/scripts/grid-crossing-walk-proof.mjs +124 -17
- package/scripts/host-ruler/roots.mjs +2 -2
- package/scripts/host-ruler.d.mts +91 -0
- package/scripts/host-ruler.mjs +565 -0
- package/scripts/live-prepush.py +3 -5
- package/scripts/loading-flow/benchmax.mjs +3 -1
- package/scripts/look-loop/test_look_loop.py +1 -38
- package/scripts/memory-proof.mjs +61 -6
- package/scripts/mmo-bots.mjs +8 -2
- package/scripts/net-lag-proof.mjs +219 -0
- package/scripts/night-market-kit-budget.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +2 -2
- package/scripts/offline-proof-rules.mjs +15 -4
- package/scripts/offline-proof.mjs +74 -13
- package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
- package/scripts/page-release/content.d.mts +9 -1
- package/scripts/page-release/content.mjs +131 -17
- package/scripts/page-release/flow.mjs +36 -10
- package/scripts/page-release/stamp-content.mjs +24 -0
- package/scripts/page-release.mjs +28 -6
- package/scripts/page-size.mjs +2 -1
- package/scripts/pin-packs.ts +1 -1
- package/scripts/pins.ts +4 -4
- package/scripts/precommit-checks.mjs +1 -7
- package/scripts/precommit-jobs.mjs +0 -1
- package/scripts/precommit-source.py +1 -9
- package/scripts/program-discovery.mjs +1 -1
- package/scripts/ring-cook.mjs +2 -1
- package/scripts/ring-step.ts +1 -1
- package/scripts/script-scenario-metrics.mjs +1 -1
- package/scripts/shard-output-content.d.mts +1 -1
- package/scripts/shard-output-content.mjs +2 -2
- package/scripts/shard-outputs.mjs +1 -1
- package/scripts/shard-public.mjs +1 -1
- package/scripts/shard-wire-meter.mjs +24 -9
- package/scripts/side-parity.mjs +4 -2
- package/scripts/standalone-smoke.mjs +8 -3
- package/scripts/tier-textures.mjs +22 -4
- package/scripts/tile-bake-report.mjs +1 -1
- package/scripts/tile-bakes.mjs +1 -1
- package/scripts/title-assets.generated.json +2 -0
- package/scripts/tsconfig.json +0 -2
- package/scripts/vendor/basisu/LICENSE +201 -0
- package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
- package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
- package/scripts/vitest-push-guards.config.ts +1 -1
- package/scripts/vps/harden-apply.sh +4 -1
- package/scripts/vps/harden-prometheus.sh +176 -0
- package/scripts/vps/harden.sh +16 -0
- package/scripts/vps/rebuild.sh +18 -0
- package/scripts/vps/wildshard-config +6 -2
- package/scripts/worker-client-play.mjs +6 -2
- package/scripts/worktree-reap.mjs +5 -5
- package/src/.oxlintrc.json +3 -182
- package/src/client/app/entry.ts +10 -2
- package/src/client/engine/boot/bootCache.ts +2 -2
- package/src/client/engine/boot/bootTrace.ts +12 -4
- package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
- package/src/client/engine/boot/clearDownloads.ts +5 -2
- package/src/client/engine/boot/contentRead.ts +11 -0
- package/src/client/engine/boot/gpuFiles.ts +4 -2
- package/src/client/engine/boot/lastEnd.ts +99 -12
- package/src/client/engine/boot/texturePack.ts +2 -2
- package/src/client/engine/net/netPlayer.ts +19 -2
- package/src/client/engine/net/otherPlayers.ts +55 -8
- package/src/client/engine/net/predictor.ts +33 -9
- package/src/client/engine/net/redial.ts +29 -6
- package/src/client/engine/pwa/cacheNames.ts +58 -1
- package/src/client/engine/pwa/sw.js +41 -11
- package/src/client/engine/render/dataLook.ts +152 -40
- package/src/client/engine/render/families/detail.ts +89 -0
- package/src/client/engine/render/families/pbr.ts +7 -1
- package/src/client/engine/render/look.ts +6 -0
- package/src/client/engine/render/lookLight.ts +103 -11
- package/src/client/engine/render/lookRender.ts +105 -0
- package/src/client/engine/saves/indexed.ts +2 -2
- package/src/client/engine/telemetry/browserErrors.ts +24 -3
- package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
- package/src/client/engine/ui/debugOptions.ts +1 -1
- package/src/client/engine/ui/lookLightOption.ts +10 -6
- package/src/client/engine/ui/namePrompt.ts +7 -0
- package/src/client/game/boot/audio.generated.ts +114 -114
- package/src/client/game/boot/bytes.generated.ts +118 -220
- package/src/client/game/boot/placedSpawn.ts +35 -0
- package/src/client/game/boot/spawnDownload.ts +25 -6
- package/src/client/game/boot/versions.generated.ts +7 -5
- package/src/client/game/devScene/hook.ts +291 -0
- package/src/client/game/grid/cellLoading.ts +12 -2
- package/src/client/game/grid/live.ts +112 -16
- package/src/client/game/grid/liveSession.ts +33 -2
- package/src/client/game/grid/mapAtlas.ts +18 -4
- package/src/client/game/grid/minimapBlend.ts +15 -5
- package/src/client/game/grid/oneWayIn.ts +5 -1
- package/src/client/game/grid/placedCells.ts +114 -12
- package/src/client/game/grid/placedContent.ts +85 -0
- package/src/client/game/grid/prefetch.ts +9 -1
- package/src/client/game/grid/productInputs.ts +3 -1
- package/src/client/game/grid/productLeases.ts +4 -1
- package/src/client/game/grid/products.ts +8 -4
- package/src/client/game/grid/roadLook.ts +24 -15
- package/src/client/game/grid/roadLookPlatform.ts +4 -2
- package/src/client/game/grid/roadResources.ts +24 -0
- package/src/client/game/grid/roadSign.worker.ts +4 -3
- package/src/client/game/grid/roadSignPaint.ts +16 -5
- package/src/client/game/grid/roadSignPreparation.ts +4 -3
- package/src/client/game/grid/roadSignScale.ts +8 -0
- package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
- package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
- package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
- package/src/client/game/grid/roadTileWriter.ts +2 -1
- package/src/client/game/grid/screenReports.ts +39 -0
- package/src/client/game/grid/session.ts +20 -4
- package/src/client/game/grid/softWallLook.ts +25 -8
- package/src/client/game/mainMenu.ts +6 -2
- package/src/client/game/plugin/context.ts +2 -1
- package/src/client/game/plugin/followedMovers.ts +7 -1
- package/src/client/game/quest/figures.ts +2 -0
- package/src/client/game/session/finish.ts +6 -0
- package/src/client/game/shardfile/assetCache.ts +4 -4
- package/src/client/game/shardfile/client.ts +4 -1
- package/src/client/game/shardfile/clientAssets.ts +9 -5
- package/src/client/game/shardfile/clientLibrary.ts +1 -1
- package/src/client/game/shardfile/clientWater.ts +51 -9
- package/src/client/game/shardfile/clientWorker.ts +19 -7
- package/src/client/game/shardfile/look.ts +8 -3
- package/src/client/game/shardfile/product.ts +34 -7
- package/src/client/game/shardfile/productChecks.ts +2 -2
- package/src/client/game/shardfile/productCost.ts +2 -2
- package/src/client/game/shardfile/readAsset.ts +2 -2
- package/src/client/game/shardfile/reflectingWater.ts +73 -0
- package/src/client/game/shardfile/seatGrace.ts +9 -0
- package/src/client/game/shardfile/skinPlayback.ts +1 -1
- package/src/client/game/systems/npc/figureRows.ts +9 -0
- package/src/client/host/online/doctor.ts +2 -0
- package/src/client/host/online/linkScreens.ts +30 -4
- package/src/client/host/standalone/shell.ts +4 -0
- package/src/cook/game/astc6Encode.ts +55 -0
- package/src/cook/game/astc6Wasm.ts +176 -0
- package/src/cook/game/cookJob.ts +30 -6
- package/src/cook/game/cookWorker.ts +38 -11
- package/src/cook/game/entryTotals.ts +51 -24
- package/src/cook/game/shardCook.ts +35 -7
- package/src/cook/game/spawnParts.ts +33 -8
- package/src/cook/game/tierTextures.ts +87 -14
- package/src/server/engine/ai/bossContenders.ts +27 -3
- package/src/server/engine/ai/phases.ts +1 -1
- package/src/server/engine/entities/creatureRefill.ts +9 -2
- package/src/server/engine/net/ledgerBook.ts +2 -0
- package/src/server/engine/net/room.ts +15 -0
- package/src/server/engine/sim/respawn.ts +8 -0
- package/src/server/game/boss/arenaRoomEntry.ts +5 -1
- package/src/server/game/boss/arenaRoomNative.ts +2 -0
- package/src/server/game/boss/native.ts +2 -1
- package/src/server/game/boss/nativeWake.ts +9 -5
- package/src/server/game/boss/openArenaNative.ts +2 -2
- package/src/server/game/boss/openArenaRoom.ts +3 -1
- package/src/server/game/grid/room.ts +44 -3
- package/src/server/game/grid/simulation.ts +23 -0
- package/src/server/game/population/mixedRoster.ts +11 -3
- package/src/server/game/population/nativeBake.ts +8 -3
- package/src/server/game/population/nativeReturns.ts +6 -3
- package/src/server/game/population/roster.ts +5 -3
- package/src/server/game/quest/eliteDrops.ts +15 -4
- package/src/server/game/quest/nativeChapter.ts +1 -1
- package/src/server/game/quest/nativeComposition.ts +5 -1
- package/src/server/game/riding/nativeTaming.ts +10 -6
- package/src/server/game/riding/wildRefill.ts +3 -2
- package/src/server/game/shardfile/bossRow.ts +4 -2
- package/src/server/game/shardfile/homeKeeper.ts +4 -2
- package/src/server/host/bake/headlessWorker.ts +1 -1
- package/src/server/host/dedicated/cellHost.ts +98 -16
- package/src/server/host/dedicated/cellProtocol.ts +16 -1
- package/src/server/host/dedicated/cellWorker.ts +8 -5
- package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
- package/src/server/host/dedicated/gridCells.ts +15 -6
- package/src/server/host/dedicated/loopLag.ts +21 -0
- package/src/server/host/dedicated/main.ts +13 -5
- package/src/server/host/dedicated/packReader.ts +3 -3
- package/src/server/host/dedicated/placementFile.ts +3 -2
- package/src/server/host/dedicated/roadRoom.ts +34 -4
- package/src/server/host/dedicated/serverMetrics.ts +126 -0
- package/src/server/host/dedicated/socketPump.ts +21 -4
- package/src/server/host/dedicated/workerTable.ts +15 -4
- package/src/server/host/dedicated/world.ts +65 -7
- package/src/server/host/headless.ts +1 -1
- package/src/server/host/headlessRuntime.ts +1 -1
- package/src/server/host/standalone/roadWorld.ts +15 -3
- package/src/server/host/standalone/serverHost.ts +4 -1
- package/src/server/host/standalone/serverProduct.ts +41 -11
- package/src/shared/engine/ai/BossBrain.ts +8 -0
- package/src/shared/game/boss/wake.ts +6 -0
- package/src/shared/game/devColliders.ts +47 -0
- package/src/shared/game/eliteSystem.ts +8 -0
- package/src/shared/game/grid/allocator.ts +3 -0
- package/src/shared/game/grid/placementRows.ts +5 -2
- package/src/shared/game/plugin/bossRecord.ts +3 -2
- package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
- package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
- package/src/shared/game/shardfile/packReads.ts +28 -3
- package/src/shared/game/shardfile/serverPack.ts +9 -0
- package/src/shared/game/systems/looks/trampleField.ts +2 -0
- package/src/shared/host/formatJsonSchema.ts +2 -2
- package/src/tsconfig.json +1 -27
- package/lint/host-reviews.json +0 -14
- package/lint/listed-view-code.json +0 -13
- package/lint/platform-pending-users.json +0 -2520
- package/lint/platform-pending-users.md +0 -18
- package/scripts/cell-mem/metrics-preload.mjs +0 -65
- package/scripts/check-closed-components.d.mts +0 -7
- package/scripts/check-closed-components.mjs +0 -87
- package/scripts/g571-hosts.d.mts +0 -3
- package/scripts/g571-hosts.mjs +0 -54
- package/scripts/host-ruler/register-migrate.mjs +0 -242
- package/scripts/listed-view-code.d.mts +0 -7
- package/scripts/listed-view-code.mjs +0 -93
- package/scripts/look-loop/fit-lut.py +0 -142
- package/scripts/look-loop/palette-delta.py +0 -183
- package/scripts/look-loop/regions/driftwood-isle.json +0 -25
- package/scripts/look-loop/regions/far-reach.json +0 -225
- package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
- package/scripts/look-loop/regions/pine-hollow.json +0 -22
- package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
- package/scripts/platform-chargebacks.d.mts +0 -9
- package/scripts/platform-chargebacks.mjs +0 -135
- package/scripts/shard-component-spans.d.mts +0 -15
- package/scripts/shard-component-spans.mjs +0 -18
- package/scripts/shard-components.d.mts +0 -16
- package/scripts/shard-components.mjs +0 -363
- package/scripts/shard-platform-hosts.d.mts +0 -2
- package/scripts/shard-platform-hosts.mjs +0 -93
- package/scripts/shard-platform-sections.d.mts +0 -2
- package/scripts/shard-platform-sections.mjs +0 -9
- package/scripts/shard-platform.d.mts +0 -76
- package/scripts/shard-platform.mjs +0 -1072
- package/src/.oxfmtrc.json +0 -48
- package/src/scripts/ask-new.sh +0 -29
- package/src/scripts/asks.mjs +0 -142
- package/src/scripts/herdr-prompt.sh +0 -34
- package/src/scripts/herdr-question-open.sh +0 -67
- package/src/scripts/md-wrap.mjs +0 -229
- /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
- /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
- /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
|
@@ -2,7 +2,7 @@ import { pageScope } from '../../../shared/engine/app/resources';
|
|
|
2
2
|
import { saveStorage } from '../saves/slots';
|
|
3
3
|
/** A small durable breadcrumb for an enabled level boot. A terminated WebContent process cannot run a final handler. */
|
|
4
4
|
import { deliverBrowserError, flushScreenReports, screenReportsEnabled } from '../telemetry/browserErrors';
|
|
5
|
-
import { reportStaleBuild } from '../telemetry/staleBuildReport';
|
|
5
|
+
import { reportSelfReload, reportStaleBuild, selfReloadClaim } from '../telemetry/staleBuildReport';
|
|
6
6
|
import type { ProgressView } from './plan';
|
|
7
7
|
import { markDropStep } from './dropNotice';
|
|
8
8
|
|
|
@@ -49,7 +49,8 @@ export interface BootTrace {
|
|
|
49
49
|
bootTraceActive: () => boolean;
|
|
50
50
|
previousBootLevel: () => string;
|
|
51
51
|
flushBootReports: () => Promise<void>;
|
|
52
|
-
|
|
52
|
+
/** `markedReload`: the page before marked its reload (lastEnd.ts), so a self-reload claim is never index.html's (S18) */
|
|
53
|
+
inspectPreviousBoot: (markedReload?: boolean) => void;
|
|
53
54
|
previousBootLine: () => string;
|
|
54
55
|
bootDiagnostic: () => Record<string, unknown>;
|
|
55
56
|
bootDiagnosticJson: () => string;
|
|
@@ -81,6 +82,8 @@ export function createBootTrace(transports: BootTraceTransports = PAGE_TRANSPORT
|
|
|
81
82
|
interface PendingReport { record: BootRecord; reason: string; inbox: boolean; sentry: boolean }
|
|
82
83
|
let flushing = false;
|
|
83
84
|
let retryListener = false;
|
|
85
|
+
/** S18: index.html's self-reload claim as this page found it, and whether the page before marked its reload */
|
|
86
|
+
let selfReload: { claim: string | null; marked: boolean } | undefined;
|
|
84
87
|
|
|
85
88
|
function reports(): PendingReport[] {
|
|
86
89
|
try {
|
|
@@ -181,7 +184,12 @@ export function createBootTrace(transports: BootTraceTransports = PAGE_TRANSPORT
|
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
/** Called by lastEnd on every new document, before its own boot can replace the old record. */
|
|
184
|
-
function inspectPreviousBoot(): void {
|
|
187
|
+
function inspectPreviousBoot(markedReload = false): void {
|
|
188
|
+
// S18: the claim, read before an online settle clears it; lastEnd and entry.ts both call this, one report a page
|
|
189
|
+
const firstCall = selfReload === undefined;
|
|
190
|
+
selfReload ??= { claim: selfReloadClaim(), marked: false };
|
|
191
|
+
if (markedReload) selfReload.marked = true;
|
|
192
|
+
const self = selfReload;
|
|
185
193
|
if (!retryListener && typeof window !== 'undefined') {
|
|
186
194
|
retryListener = true;
|
|
187
195
|
pageScope.listen(window, 'online', () => { void flushBootReports(); });
|
|
@@ -209,7 +217,7 @@ export function createBootTrace(transports: BootTraceTransports = PAGE_TRANSPORT
|
|
|
209
217
|
// SENTRY-TRIAGE S13: an error screen an earlier page opened and could not deliver goes now, off the boot's hot path (title too).
|
|
210
218
|
// STALE-BUILD SB6: a stale-build screen an earlier page showed (index.html's note) joins the outbox first.
|
|
211
219
|
// No DSN (dev, tests): nothing can be sent, so no timer joins the page's own (the sw tests count them).
|
|
212
|
-
if (typeof window !== 'undefined' && screenReportsEnabled()) pageScope.timeout(8000, () => { reportStaleBuild(); flushScreenReports(); });
|
|
220
|
+
if (typeof window !== 'undefined' && screenReportsEnabled()) pageScope.timeout(8000, () => { reportStaleBuild(); if (firstCall) reportSelfReload(() => (self.marked ? null : self.claim)); flushScreenReports(); });
|
|
213
221
|
}
|
|
214
222
|
|
|
215
223
|
/** Shown in the loader and the Loading & memory Debug row after a restart. */
|
|
@@ -5,6 +5,7 @@ import { beginLoadingWait, finishLoadingWait } from '../../../shared/engine/boot
|
|
|
5
5
|
import { markReload, type ReloadReason } from './lastEnd';
|
|
6
6
|
import { leaveAfterPaint } from './leaveAfterPaint';
|
|
7
7
|
import { createChunkRecovery, reloadIntoNewerBuild, type ChunkRecoveryPorts } from './chunkRecovery';
|
|
8
|
+
import { captureBrowserError, engineScreenTags } from '../telemetry/browserErrors';
|
|
8
9
|
|
|
9
10
|
declare const __BUILD_ID__: string;
|
|
10
11
|
function bootSelfReloadClaimed(): boolean {
|
|
@@ -104,6 +105,9 @@ export async function reloadIfStaleBuild(): Promise<boolean> {
|
|
|
104
105
|
if (store.getItem('boot.staleBuild') === __BUILD_ID__) return false;
|
|
105
106
|
store.setItem('boot.staleBuild', __BUILD_ID__);
|
|
106
107
|
} catch { return false; }
|
|
108
|
+
// SENTRY-TRIAGE S18: the cover is a screen of a fault; the outbox keeps the report across the reload below
|
|
109
|
+
try { captureBrowserError(new Error(`stale build ${__BUILD_ID__}: its files are gone; the server runs ${live}`), engineScreenTags('stale-reload', 'chunk-recovery', 'running', { live })); }
|
|
110
|
+
catch { /* a report never holds the reload */ }
|
|
107
111
|
const cover = showReloadingSoon('This build is out of date · getting the new one');
|
|
108
112
|
void leavePastWorker('stale build: its files are gone from the server', cover);
|
|
109
113
|
return true;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { saveStorage,jsonSlot } from '../saves/slots';
|
|
2
2
|
import { contentBase } from './contentBase';
|
|
3
|
+
import { isForeign, pageCacheChannel, PRODUCTION_MARK } from '../pwa/cacheNames';
|
|
3
4
|
// oxlint-disable-next-line import/no-empty-named-blocks, unicorn/require-module-specifiers -- Its ambient Window type is the point.
|
|
4
5
|
import type {} from './shardPrefetch'; // Window.__ws_prefetch, for a program that reaches this file alone.
|
|
5
6
|
/**
|
|
@@ -75,11 +76,13 @@ export async function clearDownloads(): Promise<ClearReport> {
|
|
|
75
76
|
workers = done.filter(Boolean).length;
|
|
76
77
|
} catch { /* no worker API here: nothing registered */ }
|
|
77
78
|
}
|
|
78
|
-
// 3. every cache; a put that was already under way can re-create one, so look again until none
|
|
79
|
+
// 3. every cache of this page's channel; a put that was already under way can re-create one, so look again until none
|
|
80
|
+
// is left. OFFLINE OF12: another channel's caches on this origin (a local proof serving two channels) are left alone.
|
|
79
81
|
let deleted = 0;
|
|
80
82
|
if (typeof caches !== 'undefined') {
|
|
83
|
+
const channel = pageCacheChannel(), productionHere = await caches.has(PRODUCTION_MARK);
|
|
81
84
|
for (;;) {
|
|
82
|
-
const keys = await caches.keys();
|
|
85
|
+
const keys = (await caches.keys()).filter(key => !isForeign(key, channel, productionHere));
|
|
83
86
|
if (keys.length === 0) break;
|
|
84
87
|
let removed = false;
|
|
85
88
|
for (const k of keys) if (await caches.delete(k)) { deleted++; removed = true; }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Scope } from '../../../shared/engine/app/scope';
|
|
2
|
+
import { captureBrowserError, engineScreenTags } from '../telemetry/browserErrors';
|
|
2
3
|
import { beginLoadingWait, finishLoadingWait } from '../../../shared/engine/boot/loadingWaits';
|
|
3
4
|
import { currentLoadingTimeline } from '../../../shared/engine/boot/timeline';
|
|
4
5
|
import { bootProgress } from '../../../shared/engine/boot/timing';
|
|
@@ -97,6 +98,15 @@ function shellRetry(scope: Scope, error: ContentReadError, retry: () => void): v
|
|
|
97
98
|
button.hidden = false;
|
|
98
99
|
scope.listen(button, 'click', retry);
|
|
99
100
|
}
|
|
101
|
+
/** pages whose card has offered RETRY once already: RETRY rounds while still offline must not fill the screen outbox (8 kept) */
|
|
102
|
+
const stallReported = new WeakSet<Document>();
|
|
103
|
+
/** SENTRY-TRIAGE S18: the card's RETRY is a screen of a fault; its first offer on this page reports, once, at warning level */
|
|
104
|
+
function reportStall(target: Document, error: ContentReadError, step: string | null): void {
|
|
105
|
+
if (stallReported.has(target)) return;
|
|
106
|
+
stallReported.add(target);
|
|
107
|
+
try { captureBrowserError(error, engineScreenTags('loading-stall', 'content-read', step ?? 'loading', { url: error.url })); }
|
|
108
|
+
catch { /* a report never holds the retry */ }
|
|
109
|
+
}
|
|
100
110
|
async function retryFromCard(error: ContentReadError, signal?: AbortSignal): Promise<void> {
|
|
101
111
|
if (typeof document === 'undefined') throw error;
|
|
102
112
|
const target = document, timeline = currentLoadingTimeline(), scope = new Scope('content-read-button');
|
|
@@ -109,6 +119,7 @@ async function retryFromCard(error: ContentReadError, signal?: AbortSignal): Pro
|
|
|
109
119
|
if (signal?.aborted === true) { reject(abortReason(signal)); return; }
|
|
110
120
|
if (signal !== undefined) scope.listen(signal, 'abort', () => { reject(abortReason(signal)); }, { once: true });
|
|
111
121
|
resume = resolve; pending.add(resolve);
|
|
122
|
+
reportStall(target, error, timeline?.snapshot().current ?? null);
|
|
112
123
|
id = beginLoadingWait(error.message, { kind: 'file', resource: error.url,
|
|
113
124
|
owner: timeline?.waitOwner ?? null, step: timeline?.snapshot().current ?? null,
|
|
114
125
|
retry: () => {for (const retry of pending) retry();}, retryNavigation: false });
|
|
@@ -135,9 +135,11 @@ let resolving = false;
|
|
|
135
135
|
/** A phone-tier GPU that can't sample raw ASTC: absent, or read wrong by the probe (the iOS Simulator has the extension and
|
|
136
136
|
* zeroes sRGB mips). No verdict (no page, or a measurement pin) changes nothing. The transcoder reads this same probe. */
|
|
137
137
|
const noRawAstc = (probe: Ktx2Probe): boolean => probe.ran && probe.families.astc !== true;
|
|
138
|
-
/** S4: an overlay's raw ASTC 6×6 files have no transcode, so a phone-tier GPU that can't sample ASTC loads images.
|
|
138
|
+
/** S4: an overlay's raw ASTC 6×6 files have no transcode, so a phone-tier GPU that can't sample ASTC loads images.
|
|
139
|
+
* S12d: the cook's phone files (`<name>.t<size>-<hash8>.<ext>`) are 6×6 too, and replace the hand-made overlay. */
|
|
140
|
+
const RAW_ASTC = /\/astc6\/|\.t[0-9]+-[a-f0-9]{8}\.(?:ktx2|glb)$/u;
|
|
139
141
|
export function rawAstcVeto(probe: Ktx2Probe): string | null {
|
|
140
|
-
if (TIER !== 'phone' || !noRawAstc(probe) || ![...registered.phone].some(url =>
|
|
142
|
+
if (TIER !== 'phone' || !noRawAstc(probe) || ![...registered.phone].some(url => RAW_ASTC.test(url))) return null;
|
|
141
143
|
return 'this table names raw ASTC 6×6 and the GPU has no ASTC';
|
|
142
144
|
}
|
|
143
145
|
/** S4: which tier's splat layers this device draws. A phone's are raw ASTC 6×6, so a phone that can't sample ASTC draws the
|
|
@@ -19,6 +19,11 @@ import { saveStorage } from '../saves/slots';
|
|
|
19
19
|
* iOS tab killed in the background (its pagehide ran hidden). index.html's 12 s self-reload (`boot.selfReload`,
|
|
20
20
|
* claimed just before this document) is the engine's and resumes, unless it retried a hung player reload
|
|
21
21
|
* fresh neither: a cold launch
|
|
22
|
+
* settleLastEnd() SENTRY-TRIAGE S20: a new tab has no session copy, so it reads the device copy, which may be
|
|
23
|
+
* another tab's live beat (a duplicated tab's session copy is one too). Each page holds a Web Lock
|
|
24
|
+
* named for its page id (on the beat) while it is shown; an end that rests on a beat stays pending
|
|
25
|
+
* until a lock query says whether that page still lives (then `fresh`, and its beat is left alone).
|
|
26
|
+
* The entry awaits it before the title reads lastEnd().
|
|
22
27
|
* `document.wasDiscarded` rides along (Chrome's tab discarding; iOS never sets it).
|
|
23
28
|
*
|
|
24
29
|
* The last non-fresh end is kept in localStorage `life.lastEnd`, so pause ▸ Settings ▸ Debug ▸ Loading & memory can show it
|
|
@@ -56,7 +61,30 @@ const PLAYER_RETRY_MS = 60_000;
|
|
|
56
61
|
export interface AliveInfo<M extends string = string> { slug: string; resident: string; mode: M }
|
|
57
62
|
interface Stamp { t: number; build: string; slug: string; resident: string; mode: string }
|
|
58
63
|
interface Unload extends Stamp { reason: string; reload?: true }
|
|
59
|
-
interface Alive extends Stamp { vis: string }
|
|
64
|
+
interface Alive extends Stamp { vis: string; page?: string }
|
|
65
|
+
/** S20: a Web Lock each shown page holds, named for its page id, so another tab can ask whether the page behind a device beat
|
|
66
|
+
* still lives. `hold` returns the release. */
|
|
67
|
+
export interface PageLocks { hold: (name: string) => () => void; held: (name: string) => Promise<boolean> }
|
|
68
|
+
const PAGE_LOCK = 'ws-page:';
|
|
69
|
+
/** a lock query this slow answers "not held": the end stays what the beat said */
|
|
70
|
+
const SETTLE_MS = 500;
|
|
71
|
+
function browserLocks(): PageLocks | null {
|
|
72
|
+
// an old Safari, an insecure page or a test DOM may have none, or null
|
|
73
|
+
const locks: LockManager | null | undefined = typeof navigator === 'undefined' ? undefined : (navigator as { locks?: LockManager | null }).locks;
|
|
74
|
+
if (locks === undefined || locks === null || typeof locks.request !== 'function' || typeof locks.query !== 'function') return null;
|
|
75
|
+
return {
|
|
76
|
+
hold: (name) => {
|
|
77
|
+
let release = (): void => undefined;
|
|
78
|
+
const held = new Promise<void>((resolve) => { release = resolve; });
|
|
79
|
+
void locks.request(name, () => held).catch(() => undefined);
|
|
80
|
+
return release;
|
|
81
|
+
},
|
|
82
|
+
// a request not yet granted is a live page too (a first beat, a bfcache return, both before the grant)
|
|
83
|
+
held: async (name) => { const state = await locks.query(); return [...(state.held ?? []), ...(state.pending ?? [])].some((lock) => lock.name === name); },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** Web Locks need a secure context, which always has randomUUID; without one the beat carries no id and reads as before */
|
|
87
|
+
const newPageId = (): string => { try { return crypto.randomUUID(); } catch { return ''; } };
|
|
60
88
|
export interface LastEnd {
|
|
61
89
|
kind: 'intentional' | 'unexpected' | 'fresh';
|
|
62
90
|
/** what ended it, in words */
|
|
@@ -115,7 +143,15 @@ function navigationType(): string {
|
|
|
115
143
|
export class PageLife {
|
|
116
144
|
private source: (() => AliveInfo) | null = null;
|
|
117
145
|
private alive = true;
|
|
118
|
-
private
|
|
146
|
+
private thisEnd: LastEnd;
|
|
147
|
+
/** S20: this page's id, on its beat and its Web Lock */
|
|
148
|
+
private readonly id = newPageId();
|
|
149
|
+
private readonly locks: PageLocks | null;
|
|
150
|
+
private readonly scope: Scope;
|
|
151
|
+
private releaseLock: (() => void) | null = null;
|
|
152
|
+
/** S20: the page id of a device beat this end rests on alone, until settle() asks whether it lives */
|
|
153
|
+
private pendingPage: string | null = null;
|
|
154
|
+
private settling: Promise<LastEnd> | undefined;
|
|
119
155
|
private beforeReload: ((reason: ReloadReason) => boolean) | undefined;
|
|
120
156
|
private readonly storage: typeof store;
|
|
121
157
|
private readonly nav: () => string;
|
|
@@ -123,28 +159,67 @@ export class PageLife {
|
|
|
123
159
|
private readonly page: () => { href: string; startedAt: number };
|
|
124
160
|
|
|
125
161
|
constructor(scope: Scope, storage: typeof store = store, nav: () => string = navigationType,
|
|
126
|
-
page: () => { href: string; startedAt: number } = () => ({ href: inPage() ? location.href : '', startedAt: typeof performance === 'undefined' ? Date.now() : performance.timeOrigin })
|
|
162
|
+
page: () => { href: string; startedAt: number } = () => ({ href: inPage() ? location.href : '', startedAt: typeof performance === 'undefined' ? Date.now() : performance.timeOrigin }),
|
|
163
|
+
locks: PageLocks | null = browserLocks()) {
|
|
127
164
|
this.storage = storage;
|
|
165
|
+
this.locks = locks;
|
|
166
|
+
this.scope = scope;
|
|
128
167
|
this.nav = nav;
|
|
129
168
|
this.page = page;
|
|
130
169
|
this.thisEnd = this.classify();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (this.
|
|
170
|
+
// S18: a reload the page before marked is never index.html's self-reload
|
|
171
|
+
inspectPreviousBoot(this.thisEnd.kind === 'intentional' && this.thisEnd.player !== true && this.thisEnd.bootedAt - this.thisEnd.at < INTENT_MS);
|
|
172
|
+
if (this.pendingPage === null) this.record();
|
|
173
|
+
this.holdLock();
|
|
134
174
|
// the beat: the page's own timer (this module loads before any shard scope exists)
|
|
135
175
|
if (inPage()) {
|
|
136
176
|
this.beat();
|
|
137
177
|
scope.interval(BEAT_MS, () => { this.beat(); });
|
|
138
178
|
// back on screen after a pagehide that did not end the page (iOS can send one on an app switch): beating again
|
|
139
|
-
scope.listen(document, 'visibilitychange', () => { if (document.visibilityState === 'visible') this.alive = true; this.beat(); });
|
|
179
|
+
scope.listen(document, 'visibilitychange', () => { if (document.visibilityState === 'visible') { this.alive = true; this.holdLock(); } this.beat(); });
|
|
140
180
|
// a page that ends normally takes its marker with it; a bfcache return (pageshow persisted) puts it back
|
|
141
181
|
scope.listen(window, 'pagehide', () => {
|
|
142
|
-
this.alive = false; this.clearAlive();
|
|
182
|
+
this.alive = false; this.clearAlive(); this.dropLock();
|
|
143
183
|
// QA 11-12 row 35: how this page ended, for telling the player's reload (a visible page) from a system one (hidden)
|
|
144
184
|
writeJson(this.storage('session'), HID_KEY, { t: Date.now(), vis: document.visibilityState, href: location.href });
|
|
145
185
|
});
|
|
146
|
-
scope.listen(window, 'pageshow', (e) => { if (e.persisted) { this.alive = true; this.beat(); } });
|
|
186
|
+
scope.listen(window, 'pageshow', (e) => { if (e.persisted) { this.alive = true; this.holdLock(); this.beat(); } });
|
|
147
187
|
}
|
|
188
|
+
scope.onDispose(() => { this.dropLock(); });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** the device's last-end record and the console line, once the end is known */
|
|
192
|
+
private record(): void {
|
|
193
|
+
if (this.thisEnd.kind !== 'fresh' || this.thisEnd.discarded) writeJson(this.storage('local'), END_KEY, this.thisEnd);
|
|
194
|
+
if (this.thisEnd.kind !== 'fresh') console.info(`[lastEnd] the previous page: ${this.thisEnd.reason}${this.thisEnd.resident === '' ? '' : ` · resident ${this.thisEnd.resident}`}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** S20: held while this page is shown; a pagehide lets it go (a held lock would keep the page out of the bfcache) */
|
|
198
|
+
private holdLock(): void { if (this.locks !== null && this.id !== '' && this.releaseLock === null) this.releaseLock = this.locks.hold(PAGE_LOCK + this.id); }
|
|
199
|
+
private dropLock(): void { this.releaseLock?.(); this.releaseLock = null; }
|
|
200
|
+
|
|
201
|
+
/** S20: an end that rests on a device beat alone is `fresh` when that beat's page still holds its lock (another tab, playing);
|
|
202
|
+
* else it stands, and the beat is cleared as the classification would have. Once; at most SETTLE_MS. */
|
|
203
|
+
settle(): Promise<LastEnd> {
|
|
204
|
+
this.settling ??= (async () => {
|
|
205
|
+
const id = this.pendingPage, locks = this.locks;
|
|
206
|
+
if (id === null || locks === null) return this.thisEnd;
|
|
207
|
+
let alive = false;
|
|
208
|
+
try {
|
|
209
|
+
let timer: ReturnType<Scope['timeout']> | undefined;
|
|
210
|
+
const late = new Promise<boolean>((resolve) => { timer = this.scope.timeout(SETTLE_MS, () => { resolve(false); }); });
|
|
211
|
+
alive = await Promise.race([locks.held(PAGE_LOCK + id).catch(() => false), late]);
|
|
212
|
+
if (timer !== undefined) this.scope.cancelTimer(timer);
|
|
213
|
+
} catch { /* not settled: the beat's word stands */ }
|
|
214
|
+
this.pendingPage = null;
|
|
215
|
+
if (alive) {
|
|
216
|
+
const { bootedAt, discarded, nav } = this.thisEnd;
|
|
217
|
+
this.thisEnd = { kind: 'fresh', reason: 'fresh launch (another tab is playing)', at: 0, resident: '', slug: '', mode: '', build: '', bootedAt, discarded, nav };
|
|
218
|
+
} else this.dropBeat(id);
|
|
219
|
+
this.record();
|
|
220
|
+
return this.thisEnd;
|
|
221
|
+
})();
|
|
222
|
+
return this.settling;
|
|
148
223
|
}
|
|
149
224
|
|
|
150
225
|
/** what the alive beat and markUnload record: the running shard and the resident list (main.ts, once the host exists) */
|
|
@@ -190,13 +265,19 @@ export class PageLife {
|
|
|
190
265
|
private beat(): void {
|
|
191
266
|
if (!this.alive) return;
|
|
192
267
|
if (!inPage()) return;
|
|
193
|
-
const a: Alive = { ...this.stamp(), vis: document.visibilityState };
|
|
268
|
+
const a: Alive = { ...this.stamp(), vis: document.visibilityState, ...(this.id === '' ? {} : { page: this.id }) };
|
|
194
269
|
writeJson(this.storage('session'), ALIVE_KEY, a);
|
|
195
270
|
// A killed iOS WebContent process may lose sessionStorage too. Normal
|
|
196
271
|
// navigation clears both copies; a kill cannot run that cleanup.
|
|
197
272
|
writeJson(this.storage('local'), ALIVE_BACKUP_KEY, a);
|
|
198
273
|
}
|
|
199
274
|
|
|
275
|
+
/** the device beat of page `id`, consumed by this page's classification; once this page beats, the copy is its own and stays */
|
|
276
|
+
private dropBeat(id: string): void {
|
|
277
|
+
if (id === '') return;
|
|
278
|
+
try { const local = this.storage('local'); if (str(readJson(local, ALIVE_BACKUP_KEY), 'page') === id) local?.removeItem(ALIVE_BACKUP_KEY); } catch { /* storage blocked */ }
|
|
279
|
+
}
|
|
280
|
+
|
|
200
281
|
private clearAlive(): void {
|
|
201
282
|
try { this.storage('session')?.removeItem(ALIVE_KEY); } catch { /* storage blocked */ }
|
|
202
283
|
try { this.storage('local')?.removeItem(ALIVE_BACKUP_KEY); } catch { /* storage blocked */ }
|
|
@@ -206,15 +287,19 @@ export class PageLife {
|
|
|
206
287
|
const now = Date.now();
|
|
207
288
|
const local = this.storage('local'), session = this.storage('session');
|
|
208
289
|
const u = readJson(local, UNLOAD_KEY), a = readJson(session, ALIVE_KEY) ?? readJson(local, ALIVE_BACKUP_KEY);
|
|
209
|
-
|
|
290
|
+
// S20: a beat from a page with an id may be another tab's live one: the device copy in a new tab, or the session copy a
|
|
291
|
+
// duplicated tab (or a window.open) starts with. settle() asks before it is taken; a page of this tab can't be alive.
|
|
292
|
+
const otherPage = this.locks !== null ? str(a, 'page') : '';
|
|
293
|
+
if (otherPage === '') try { local?.removeItem(ALIVE_BACKUP_KEY); } catch { /* consumed by this page's classification */ }
|
|
210
294
|
try { local?.removeItem(UNLOAD_KEY); } catch { /* read once either way */ }
|
|
211
295
|
const discarded = inPage() && Reflect.get(document, 'wasDiscarded') === true;
|
|
212
296
|
const nav = this.nav(), hid = readJson(session, HID_KEY);
|
|
213
297
|
try { session?.removeItem(HID_KEY); } catch { /* read once either way */ }
|
|
214
298
|
const base = { bootedAt: now, discarded, nav, ...(typeof u === 'object' && u !== null && Reflect.get(u, 'reload') === true ? { reload: true as const } : {}) };
|
|
215
299
|
const ut = num(u, 't');
|
|
216
|
-
if (u !== null && now - ut < INTENT_MS) return { kind: 'intentional', reason: str(u, 'reason'), at: ut, resident: str(u, 'resident'), slug: str(u, 'slug'), mode: str(u, 'mode'), build: str(u, 'build'), ...base };
|
|
300
|
+
if (u !== null && now - ut < INTENT_MS) { this.dropBeat(otherPage); return { kind: 'intentional', reason: str(u, 'reason'), at: ut, resident: str(u, 'resident'), slug: str(u, 'slug'), mode: str(u, 'mode'), build: str(u, 'build'), ...base }; }
|
|
217
301
|
if (a !== null) {
|
|
302
|
+
if (otherPage !== '') this.pendingPage = otherPage;
|
|
218
303
|
const where = str(a, 'vis') === 'hidden' ? 'in the background' : 'on screen';
|
|
219
304
|
return { kind: 'unexpected', reason: `page ended unexpectedly ${where} (browser or system cause unknown)`, at: num(a, 't'), resident: str(a, 'resident'), slug: str(a, 'slug'), mode: str(a, 'mode'), build: str(a, 'build'), ...base };
|
|
220
305
|
}
|
|
@@ -314,5 +399,7 @@ export function leaveSaved(go: () => void): void {
|
|
|
314
399
|
}
|
|
315
400
|
|
|
316
401
|
export function lastEnd(): LastEnd { return page.lastEnd(); }
|
|
402
|
+
/** S20: lastEnd() once a device beat it rests on alone is known to be no other tab's live page; the entry awaits it before the title */
|
|
403
|
+
export function settleLastEnd(): Promise<LastEnd> { return page.settle(); }
|
|
317
404
|
export function lastRecordedEnd(): LastEnd | null { return page.lastRecordedEnd(); }
|
|
318
405
|
export function lastEndLine(now: number = Date.now()): string { return page.lastEndLine(now); }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assetCacheName } from '../pwa/cacheNames';
|
|
2
2
|
import { publishBootResponse } from './bootCache';
|
|
3
3
|
import { contentURL, isContentOrigin, pageURL } from './contentBase';
|
|
4
4
|
import type { Scope } from '../../../shared/engine/app/scope';
|
|
@@ -147,7 +147,7 @@ async function readBody(response: Response, expected: number, signal: AbortSigna
|
|
|
147
147
|
} catch (error) { void reader.cancel().catch(() => undefined); throw error; }
|
|
148
148
|
}
|
|
149
149
|
async function cachedPart(path: string): Promise<Response | undefined> {
|
|
150
|
-
try { return typeof caches === 'undefined' ? undefined : await (await caches.open(
|
|
150
|
+
try { return typeof caches === 'undefined' ? undefined : await (await caches.open(assetCacheName())).match(new URL(path, location.href).href, { ignoreVary: true }); }
|
|
151
151
|
catch { return undefined; } // Storage denial preserves the ordinary direct read.
|
|
152
152
|
}
|
|
153
153
|
const readers = new Set<TexturePackReads>();
|
|
@@ -151,6 +151,16 @@ export class NetPlayer implements PlayerLink {
|
|
|
151
151
|
get heldSlot(): number { return this.held; }
|
|
152
152
|
/** The server has put this body somewhere: a frame has been heard. */
|
|
153
153
|
get joined(): boolean { return this.seen !== null; }
|
|
154
|
+
/** OFFLINE OF10 (J298, Jake 2026-11-12: "do a very limited amount of client-side emulation"): a world page that opened without
|
|
155
|
+
* its seat (OF9) plays its input on the predictor alone until the ring is full (PREDICTION_RING, about 1 s), then holds. Nothing
|
|
156
|
+
* goes on the wire: these moves are the page's own, and the seat's first frame takes the server's place, gliding to it when it
|
|
157
|
+
* is near (under PREDICTION_SNAP). A rejoin or a crossing still holds still until its first frame. */
|
|
158
|
+
private unseated = false;
|
|
159
|
+
private unseatedSeq = 0;
|
|
160
|
+
/** OF10: play unseated until the first frame (a page that has heard one is seated, and this does nothing). */
|
|
161
|
+
playUnseated(): void { if (this.seen === null) this.unseated = true; }
|
|
162
|
+
/** OF10: unseated, and the ring is spent: movement holds until the seat. */
|
|
163
|
+
get unseatedHeld(): boolean { return this.unseated && this.predictor.full; }
|
|
154
164
|
/** A death's authoritative pose is already reset on the server. Keep this page at the death until its overlay is dark. */
|
|
155
165
|
holdRespawn(): void { this.respawnHeld = true; }
|
|
156
166
|
/** Adopt the newest server pose under the dark, dropping commands from before the death. */
|
|
@@ -158,7 +168,8 @@ export class NetPlayer implements PlayerLink {
|
|
|
158
168
|
|
|
159
169
|
/** A fixed step. False, with nothing sent, before the first frame or when a full ring says the server stopped answering. */
|
|
160
170
|
step(input: PlayerWireInput): boolean {
|
|
161
|
-
if (this.respawnHeld || this.
|
|
171
|
+
if (this.respawnHeld || this.predictor.full) return false;
|
|
172
|
+
if (this.seen === null) return this.unseated && this.deviceMode !== 'paused' && this.stepUnseated(input);
|
|
162
173
|
if (!this.claimInputTick(0)) return false;
|
|
163
174
|
const armed = this.armed(input);
|
|
164
175
|
return this.sendCommand(armed, true, this.hooked(armed));
|
|
@@ -188,6 +199,12 @@ export class NetPlayer implements PlayerLink {
|
|
|
188
199
|
for (let at = 1; at < MAX_FIXED_STEPS && !this.predictor.full && this.claimInputTick(MAX_FIXED_STEPS); at++) this.sendCommand(input, false);
|
|
189
200
|
this.client.flush();
|
|
190
201
|
}
|
|
202
|
+
/** OF10: one step of the page's own, unsent, with a seq of its own; world actions wait for the link (the hold cards). */
|
|
203
|
+
private stepUnseated(input: PlayerWireInput): boolean {
|
|
204
|
+
const seq = this.unseatedSeq = (this.unseatedSeq % 0xffff) + 1;
|
|
205
|
+
this.world.poseFor(seq, false);
|
|
206
|
+
return this.predictor.step(quantiseCommand({ ...input, seq, viewTick: 0 }));
|
|
207
|
+
}
|
|
191
208
|
private claimInputTick(reserve: number): boolean {
|
|
192
209
|
if (this.deviceMode === 'frame') return true;
|
|
193
210
|
if (this.deviceMode === 'paused') return false;
|
|
@@ -234,7 +251,7 @@ export class NetPlayer implements PlayerLink {
|
|
|
234
251
|
this.world.frame(frame.tick, frame.lastSeq);
|
|
235
252
|
for (const event of this.heard.splice(0)) if (event.kind === 'mount') seat?.enter(event.mount); else seat?.leave();
|
|
236
253
|
const ridden = seat === null ? null : frame.ride;
|
|
237
|
-
if (first) { this.predictor.adopt(frame.lastSeq, frame.owner, frame.tick, ridden); return; }
|
|
254
|
+
if (first) { const glide = this.unseated; this.unseated = false; this.predictor.adopt(frame.lastSeq, frame.owner, frame.tick, ridden, glide); return; }
|
|
238
255
|
this.predictor.reconcile(frame.lastSeq, frame.owner, frame.tick, ridden);
|
|
239
256
|
const swung = PLAYER_CLASS.owner[LAST_SWING]?.value(frame.owner[LAST_SWING] ?? 0), held = PLAYER_CLASS.owner[HELD]?.value(frame.owner[HELD] ?? 0);
|
|
240
257
|
this.attacks.frame(frame.lastSeq, typeof swung === 'number' ? swung : 0);
|
|
@@ -14,7 +14,7 @@ import { RemoteStrike } from './remoteStrike';
|
|
|
14
14
|
import { NameTag, type NameTagShown } from './nameTag';
|
|
15
15
|
import { RemoteDeath, type DeathPhase } from './remoteDeath';
|
|
16
16
|
import { RemoteHurt, type HurtShown } from './remoteHurt';
|
|
17
|
-
import { HeldInHand } from './heldOnOthers';
|
|
17
|
+
import { HeldInHand, heldOnOthers } from './heldOnOthers';
|
|
18
18
|
import type { NetClient } from './client';
|
|
19
19
|
import { othersOnMap } from './othersOnMap';
|
|
20
20
|
import { talkerKey, voiceNear, type Talker } from './voiceNear';
|
|
@@ -169,8 +169,58 @@ class OtherBody {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/** Every other player's body, kept to the client's rows. */
|
|
172
|
+
/** A body leaving: the castaway's mesh and contact disc are shared by every body (userData.shared), so only its own are freed, its
|
|
173
|
+
* skeleton's bone texture with them. A sprite's geometry is three's own, shared by every sprite. Its held item, the kit's copy,
|
|
174
|
+
* is let go of first (`undress`). */
|
|
175
|
+
function freeBody(group: THREE.Object3D): void {
|
|
176
|
+
group.traverse(node => {
|
|
177
|
+
if (node instanceof THREE.SkinnedMesh) node.skeleton.dispose();
|
|
178
|
+
if (node instanceof THREE.Mesh) { const geometry = node.geometry as THREE.BufferGeometry; if (geometry.userData['shared'] !== true) geometry.dispose(); }
|
|
179
|
+
if (node instanceof THREE.Mesh || node instanceof THREE.Sprite) { for (const material of [node.material].flat() as THREE.Material[]) { if (material.userData['shared'] === true) continue; if (material instanceof THREE.SpriteMaterial) material.map?.dispose(); material.dispose(); } }
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** NET-LAG NL4: the warm body's depth under the world, out of every view; its slots tried for the kit's held items. */
|
|
184
|
+
const WARM_DEPTH = -1000, WARM_SLOTS = 16;
|
|
185
|
+
/**
|
|
186
|
+
* NET-LAG NL4 (Jake's 60 ms frames in Driftwood): the first other player to come into view linked its body's programs inside
|
|
187
|
+
* that frame, the castaway's skinned body, its contact disc, its Name and the held item in the world's light (the item's
|
|
188
|
+
* first-person program is another): 4 programs in a 200 ms frame, 20 in a 440 ms one, on desktop Chromium's Metal. One body
|
|
189
|
+
* of the same build is drawn from the start, under the world, never culled, so the boot's in-play warm-up links those
|
|
190
|
+
* programs paced and every body after it draws with programs already built (three keys a program by its material's settings,
|
|
191
|
+
* so a body's own deck materials share the warm deck's). It holds every slot of the kit lent now, and
|
|
192
|
+
* takes the new kit's items when a crossing lends one (the old copies are freed with their kit).
|
|
193
|
+
*/
|
|
194
|
+
class WarmBody {
|
|
195
|
+
readonly group = new THREE.Group();
|
|
196
|
+
private readonly hand: THREE.Object3D | null;
|
|
197
|
+
private readonly items = new THREE.Group();
|
|
198
|
+
private kit = -1;
|
|
199
|
+
constructor() {
|
|
200
|
+
this.group.name = 'other-player-warm'; this.group.position.y = WARM_DEPTH;
|
|
201
|
+
const model = castawayBody(), board = new BoardUnder();
|
|
202
|
+
board.deck.visible = true; // a rider's deck, shown here so its programs warm too
|
|
203
|
+
this.group.add(model.root, groundContact(), nameTag('warm'), board.deck);
|
|
204
|
+
this.hand = model.mounts.rightHand;
|
|
205
|
+
this.hand.add(this.items);
|
|
206
|
+
this.unculled();
|
|
207
|
+
}
|
|
208
|
+
private slot = WARM_SLOTS;
|
|
209
|
+
/** Each frame: a newly lent kit's items replace the last's, one slot a frame (each first copy clones a first-person model). */
|
|
210
|
+
frame(): void {
|
|
211
|
+
if (this.kit !== heldOnOthers.lent) { this.kit = heldOnOthers.lent; this.items.clear(); this.slot = 0; }
|
|
212
|
+
if (this.slot >= WARM_SLOTS) return;
|
|
213
|
+
const held = heldOnOthers.prop(this.slot++);
|
|
214
|
+
if (held !== null) { const item = held.prop.clone(); item.traverse(node => { node.frustumCulled = false; }); this.items.add(item); }
|
|
215
|
+
}
|
|
216
|
+
/** Drawn wherever the camera looks, so the warm-up and every frame count its programs as used. */
|
|
217
|
+
private unculled(): void { this.group.traverse(node => { node.frustumCulled = false; }); }
|
|
218
|
+
dispose(): void { this.group.removeFromParent(); this.items.clear(); freeBody(this.group); }
|
|
219
|
+
}
|
|
220
|
+
|
|
172
221
|
export class OtherPlayers {
|
|
173
222
|
private readonly bodies = new Map<number, OtherBody>();
|
|
223
|
+
private readonly warm: WarmBody | null = null;
|
|
174
224
|
private readonly client: NetClient;
|
|
175
225
|
private readonly scene: THREE.Object3D;
|
|
176
226
|
private readonly row = new Float64Array(PLAYER_CLASS.row.length);
|
|
@@ -179,6 +229,8 @@ export class OtherPlayers {
|
|
|
179
229
|
constructor(client: NetClient, scene: THREE.Object3D, scope: Scope, me: Readonly<THREE.Vector3> | null = null) {
|
|
180
230
|
this.client = client; this.scene = scene; this.me = me;
|
|
181
231
|
scope.onDispose(() => { for (const handle of this.bodies.keys()) this.drop(handle); });
|
|
232
|
+
try { const warm = new WarmBody(); scene.add(warm.group); this.warm = warm; scope.onDispose(() => { warm.dispose(); }); }
|
|
233
|
+
catch (error) { console.error('[other players] warm body', error); }
|
|
182
234
|
if (me !== null) scope.onDispose(voiceNear.lend({ distanceTo: talker => this.distanceTo(talker) }));
|
|
183
235
|
}
|
|
184
236
|
/** Metres to a talker's body, as drawn: the body with its row's id, or, from a server that names none, the nearest with its Name. */
|
|
@@ -209,6 +261,7 @@ export class OtherPlayers {
|
|
|
209
261
|
return body !== undefined;
|
|
210
262
|
}
|
|
211
263
|
frame(renderTick: number, dt: number): void {
|
|
264
|
+
this.warm?.frame();
|
|
212
265
|
const { client, bodies, row } = this, own = client.welcome?.handle ?? 0;
|
|
213
266
|
for (const handle of bodies.keys()) if (!client.entities.has(handle)) this.drop(handle);
|
|
214
267
|
for (const [handle, info] of client.entities) {
|
|
@@ -228,12 +281,6 @@ export class OtherPlayers {
|
|
|
228
281
|
const body = this.bodies.get(handle);
|
|
229
282
|
if (body === undefined) return;
|
|
230
283
|
this.bodies.delete(handle); this.scene.remove(body.group); body.undress();
|
|
231
|
-
|
|
232
|
-
// bone texture with them. A sprite's geometry is three's own, shared by every sprite.
|
|
233
|
-
body.group.traverse(node => {
|
|
234
|
-
if (node instanceof THREE.SkinnedMesh) node.skeleton.dispose();
|
|
235
|
-
if (node instanceof THREE.Mesh) { const geometry = node.geometry as THREE.BufferGeometry; if (geometry.userData['shared'] !== true) geometry.dispose(); }
|
|
236
|
-
if (node instanceof THREE.Mesh || node instanceof THREE.Sprite) { for (const material of [node.material].flat() as THREE.Material[]) { if (material.userData['shared'] === true) continue; if (material instanceof THREE.SpriteMaterial) material.map?.dispose(); material.dispose(); } }
|
|
237
|
-
});
|
|
284
|
+
freeBody(body.group);
|
|
238
285
|
}
|
|
239
286
|
}
|
|
@@ -30,8 +30,20 @@ export const PREDICTION_SNAP = 3;
|
|
|
30
30
|
const RIDE_ROOM = 64;
|
|
31
31
|
/** One saved move. */
|
|
32
32
|
const SAVED_WORDS: number = MOTION_WORDS + RIDE_ROOM;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* NET-LAG NL12 (b): a correction glides at a steady pace over a time scaled to its size, never as a step. At 150 to 200 ms
|
|
35
|
+
* (J282) corrections are routine, and an exponential glide moved the drawn feet most in its first frame: a third of a 0.3 m
|
|
36
|
+
* correction in one 30 fps frame. Metres a second the glide adds on top of the feet's own motion, under half a walk.
|
|
37
|
+
*/
|
|
38
|
+
export const GLIDE_SPEED = 2;
|
|
39
|
+
/** The shortest glide: 4 frames at 30 fps, 8 at 60. */
|
|
40
|
+
export const GLIDE_MIN_S: number = 4 / 30;
|
|
41
|
+
/** The longest: a correction near the snap distance still settles within half a second. */
|
|
42
|
+
export const GLIDE_MAX_S = 0.5;
|
|
43
|
+
/** The pace that glides `distance` away: its own size over GLIDE_SPEED, held between the shortest and longest glide. */
|
|
44
|
+
function glidePace(distance: number): number {
|
|
45
|
+
return distance / Math.min(GLIDE_MAX_S, Math.max(GLIDE_MIN_S, distance / GLIDE_SPEED));
|
|
46
|
+
}
|
|
35
47
|
|
|
36
48
|
/** What a predictor drives. */
|
|
37
49
|
export interface PredictedBody {
|
|
@@ -105,6 +117,8 @@ export class Predictor {
|
|
|
105
117
|
private resets: number | null = null;
|
|
106
118
|
/** The newest frame has this body on a ride. */
|
|
107
119
|
private aboard = false;
|
|
120
|
+
/** Metres a second the render offset loses now (NL12 b). */
|
|
121
|
+
private glide = 0;
|
|
108
122
|
constructor(body: PredictedBody, columns: readonly NetColumn<never>[], corrected?: (row:Omit<NetCorrection,'kind'|'session'>)=>void) {
|
|
109
123
|
this.corrected=corrected;
|
|
110
124
|
this.body = body; this.columns = columns; this.table = ownerTable(columns);
|
|
@@ -154,6 +168,8 @@ export class Predictor {
|
|
|
154
168
|
const saved = offset >= 0 && offset < count, slot = (head + offset) % PREDICTION_RING, at = slot * SAVED_WORDS; // else older than the ring, or nothing saved
|
|
155
169
|
if (saved) { this.head = (slot + 1) % PREDICTION_RING; this.count = count - offset - 1; }
|
|
156
170
|
if (!forced && (!saved || this.matches(slot, owner, ridden))) return false;
|
|
171
|
+
// NL12 (c): the write below can take feet under a deck only if the server's world lacks the deck; NL5 gave the room the same
|
|
172
|
+
// rope planks (`server/host/ropeDecks.ts`), and `test/net-predict-deck.test.ts` replays a correction 0.3 to 1 m low back onto them
|
|
157
173
|
const s = body.motionState, { ride } = body, feet = ride?.feet ?? s.position, x = feet.x + body.renderOffset.x, y = feet.y + body.renderOffset.y, z = feet.z + body.renderOffset.z, { yaw } = s;
|
|
158
174
|
if (saved) restoreMotion(s, body.motor, states, at);
|
|
159
175
|
if (saved && this.rode[slot] === 1) ride?.restore(states, at + MOTION_WORDS);
|
|
@@ -169,13 +185,14 @@ export class Predictor {
|
|
|
169
185
|
if (!led && !boarded) this.corrections++;
|
|
170
186
|
const offsetX = x - feet.x, offsetY = y - feet.y, offsetZ = z - feet.z, far = offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ > PREDICTION_SNAP * PREDICTION_SNAP;
|
|
171
187
|
body.renderOffset.set(far ? 0 : offsetX, far ? 0 : offsetY, far ? 0 : offsetZ);
|
|
188
|
+
this.glide = glidePace(body.renderOffset.length());
|
|
172
189
|
if(!led&&!boarded)this.corrected?.({tick:tick??s.tick,mode:ride!==null?'ride':s.board.on?'board':s.swim.on?'swim':'foot',offset:Math.hypot(offsetX,offsetY,offsetZ),snapped:far});
|
|
173
190
|
return !led && !boarded;
|
|
174
191
|
}
|
|
175
192
|
|
|
176
193
|
/** A session's first frame: this body stands where the server says, with nothing to compare it to. */
|
|
177
|
-
adopt(lastSeq: number, owner: ArrayLike<number>, tick?: number, ridden: ArrayLike<number> | null = null): void {
|
|
178
|
-
const { body, table } = this, s = body.motionState, { yaw } = s;
|
|
194
|
+
adopt(lastSeq: number, owner: ArrayLike<number>, tick?: number, ridden: ArrayLike<number> | null = null, glide = false): void {
|
|
195
|
+
const { body, table } = this, s = body.motionState, { yaw } = s, was = { x: s.position.x, y: s.position.y, z: s.position.z };
|
|
179
196
|
if (tick !== undefined) s.tick = tick;
|
|
180
197
|
this.acked = lastSeq; this.led = this.flag(table.led, owner) === 1; this.resets = this.value(table.resets, owner); this.aboard = ridden !== null;
|
|
181
198
|
this.head = 0; this.count = 0;
|
|
@@ -185,14 +202,21 @@ export class Predictor {
|
|
|
185
202
|
this.write(s, owner); // the reset cleared the ground the owner block had just landed
|
|
186
203
|
if (ridden !== null) body.ride?.adopt(ridden);
|
|
187
204
|
body.renderOffset.set(0, 0, 0);
|
|
205
|
+
// OFFLINE OF10: a page that played unseated glides onto its seat when it is near, as a correction does; a far seat snaps
|
|
206
|
+
if (glide) {
|
|
207
|
+
const dx = was.x - s.position.x, dy = was.y - s.position.y, dz = was.z - s.position.z;
|
|
208
|
+
if (Math.hypot(dx, dy, dz) < PREDICTION_SNAP) body.renderOffset.set(dx, dy, dz);
|
|
209
|
+
}
|
|
210
|
+
this.glide = glidePace(body.renderOffset.length());
|
|
188
211
|
}
|
|
189
212
|
|
|
190
|
-
/** Each render frame: the camera glides back onto the predicted feet. */
|
|
213
|
+
/** Each render frame: the camera glides back onto the predicted feet at the correction's steady pace (NL12 b). */
|
|
191
214
|
update(dt: number): void {
|
|
192
|
-
const { renderOffset } = this.body;
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
if (
|
|
215
|
+
const { renderOffset } = this.body, left = renderOffset.length();
|
|
216
|
+
if (left === 0) return;
|
|
217
|
+
const step = (this.glide > 0 ? this.glide : glidePace(left)) * dt;
|
|
218
|
+
if (step >= left || left - step < 1e-4) renderOffset.set(0, 0, 0);
|
|
219
|
+
else renderOffset.multiplyScalar((left - step) / left);
|
|
196
220
|
}
|
|
197
221
|
|
|
198
222
|
private matches(slot: number, owner: ArrayLike<number>, ridden: ArrayLike<number> | null): boolean {
|