@wildshard/engine 0.1.17 → 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 +16 -0
- package/budgets/shard-size-baseline.json +10 -4
- package/index.html +6 -4
- package/lint/engine-sides.json +21 -0
- package/lint/host-callback-syntax.mjs +2 -1
- package/lint/host-callbacks.mjs +3 -3
- package/lint/host-files.mjs +5 -4
- package/lint/no-base64.mjs +3 -1
- package/lint/ratchet.json +0 -68
- package/lint/ratchet.mjs +1 -4
- package/lint/shard-imports.mjs +6 -7
- package/lint/shard-source.d.mts +9 -0
- package/lint/shard-source.mjs +91 -0
- package/lint/shardfile-boundaries.mjs +10 -8
- package/lint/sim-closure.mjs +6 -3
- package/lint/wildshard-plugin.d.ts +4 -0
- package/lint/wildshard-plugin.js +22 -23
- package/package.json +25 -16
- 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.d.mts +3 -0
- package/scripts/app-build/outputProducts.mjs +35 -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 +34 -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 +3 -1
- 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-check.mjs +4 -2
- package/scripts/chromium-keychain.d.mts +1 -1
- package/scripts/chromium-keychain.mjs +3 -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 +20 -3
- package/scripts/devices.d.mts +4 -0
- package/scripts/devices.mjs +39 -0
- package/scripts/devserver-client.d.mts +4 -2
- package/scripts/devserver-client.mjs +25 -8
- package/scripts/docs-inputs-proof.mjs +6 -6
- package/scripts/doctor-proof.mjs +1 -1
- package/scripts/e2e-faults.mjs +159 -0
- 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 +136 -18
- 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 +213 -0
- 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 +5 -3
- package/scripts/offline-proof-rules.mjs +34 -7
- package/scripts/offline-proof.mjs +88 -18
- 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-proof.mjs +101 -0
- package/scripts/tier-textures.mjs +78 -0
- 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 +1 -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 +84 -24
- package/scripts/worker-client-play.mjs +7 -2
- package/scripts/worker-client-proof.mjs +1 -1
- package/scripts/worker-client-slug.mjs +44 -0
- package/scripts/worktree-reap.mjs +5 -5
- package/src/.oxlintrc.json +3 -182
- package/src/client/app/entry.ts +47 -12
- 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/parsedPages.ts +127 -58
- package/src/client/engine/boot/texturePack.ts +2 -2
- package/src/client/engine/build.d.ts +2 -0
- package/src/client/engine/core/Game.ts +18 -0
- package/src/client/engine/core/bootstrap.ts +4 -1
- package/src/client/engine/debug/probe.ts +18 -1
- package/src/client/engine/fx/LightPool.ts +41 -1
- 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 +53 -14
- 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/render/precompile.ts +20 -14
- package/src/client/engine/saves/indexed.ts +2 -2
- package/src/client/engine/telemetry/browserErrors.ts +28 -4
- package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
- 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 -216
- package/src/client/game/boot/bytes.generated.ts +118 -238
- 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 -7
- package/src/client/game/devScene/hook.ts +291 -0
- package/src/client/game/grid/area.ts +38 -0
- package/src/client/game/grid/cellLoading.ts +12 -2
- package/src/client/game/grid/live.ts +134 -12
- package/src/client/game/grid/liveSession.ts +47 -5
- package/src/client/game/grid/mapAtlas.ts +18 -4
- package/src/client/game/grid/menu.ts +4 -0
- package/src/client/game/grid/minimapBlend.ts +15 -5
- package/src/client/game/grid/neighbourPanels.ts +10 -1
- package/src/client/game/grid/oneWayIn.ts +5 -1
- package/src/client/game/grid/placedCards.ts +55 -0
- package/src/client/game/grid/placedCells.ts +233 -0
- 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/regionalRuntime.ts +6 -0
- package/src/client/game/grid/regionalWorld.ts +15 -2
- package/src/client/game/grid/roadCull.ts +44 -14
- 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/roadTileBacking.ts +13 -3
- 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 +29 -4
- package/src/client/game/grid/shardfileFar.ts +9 -3
- 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 +11 -1
- package/src/client/game/shard/titleList.ts +6 -2
- 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 +21 -8
- 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/game/titleDeck.ts +4 -3
- package/src/client/host/online/doctor.ts +2 -0
- package/src/client/host/online/linkScreens.ts +30 -4
- package/src/client/host/online/shell.ts +14 -0
- 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 +67 -9
- package/src/cook/game/spawnParts.ts +33 -8
- package/src/cook/game/tierTextures.ts +349 -0
- package/src/e2e/smoke/game.ts +19 -14
- package/src/e2e/smoke/page-globals.d.ts +9 -8
- package/src/e2e/smoke/template2.spec.ts +8 -7
- 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 +4 -19
- 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/socketTransport.ts +2 -1
- package/src/server/host/dedicated/workerTable.ts +15 -4
- package/src/server/host/dedicated/world.ts +95 -8
- 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/engine/net/deviceWord.ts +138 -0
- package/src/shared/engine/net/socketFrames.ts +7 -4
- 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/catalogueSlot.ts +7 -0
- package/src/shared/game/grid/placementRows.ts +36 -0
- 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
package/src/client/app/entry.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { inspectPreviousBoot, previousBootLine, previousBootLevel } from '@wilds
|
|
|
33
33
|
import { Scope } from '@wildshard/engine/app/scope';
|
|
34
34
|
import { bootRoute, onlineTitleFirst } from './bootRoute';
|
|
35
35
|
import { consumeTitleArrival, pendingTitleArrival } from '@wildshard/engine/boot/titleArrival';
|
|
36
|
-
import { lastEnd } from '@wildshard/engine/boot/lastEnd';
|
|
36
|
+
import { lastEnd, settleLastEnd } from '@wildshard/engine/boot/lastEnd';
|
|
37
37
|
import { installDropNotes, markDropStep, recordDrop, takeDrop } from '@wildshard/engine/boot/dropNotice';
|
|
38
38
|
import { consumeCrashResume, type CrashResume } from '@wildshard/engine/game/session/crashResume';
|
|
39
39
|
import { bootAwait, bootMark, bootTask, bootTiming, endBootOperation } from '@wildshard/engine/boot/timing';
|
|
@@ -54,6 +54,8 @@ let crashResume: CrashResume | null = null;
|
|
|
54
54
|
let selectedImages: Scope | undefined;
|
|
55
55
|
const task = (): Promise<void> => new Promise((resolve) => { entryScope.timeout(0, resolve); });
|
|
56
56
|
const UNLISTED = 'This world is not listed. Choose a world from the list.';
|
|
57
|
+
/** How long the boot waits for the placement file (`placedCells.ts`'s own deadline, GO4's 3 s), its chunk's import included. */
|
|
58
|
+
const PLACED_DEADLINE_MS = 3000;
|
|
57
59
|
/** The plain home URL paints only the title. No renderer, world, or Three.js is imported until a shard is chosen. */
|
|
58
60
|
// RL3: the static module graph has arrived and run; index.html's 12 s self-reload stands down (only a hung module
|
|
59
61
|
// fetch, which never gets here, reloads by itself; anything after this is guardBoot's)
|
|
@@ -65,6 +67,9 @@ installDropNotes();
|
|
|
65
67
|
installInlineCatalogue(document);
|
|
66
68
|
const titleRows = withCatalogueHeads(readTitleRows(document));
|
|
67
69
|
installTitleManifests(titleRows);
|
|
70
|
+
// SA33 to SA35, the page half: a released page adds the cells the API placed after its build (its channel's signed placement file) to the
|
|
71
|
+
// catalogue before anything reads the grid; `enterPage` waits for it (3 s at most), and any failure keeps the build's grid.
|
|
72
|
+
const placedCells = learnPlacedCellsOnce();
|
|
68
73
|
// G727 / I9: Settings' "Download everything"; the prefetch loads only when the player opens or presses it
|
|
69
74
|
installOfflineDownload({
|
|
70
75
|
size: async owner => (await import('@wildshard/engine/game/grid/prefetch')).remainingDownloadBytes(owner),
|
|
@@ -98,13 +103,36 @@ function serverSites(): Promise<readonly { readonly site: string | null | undefi
|
|
|
98
103
|
const late = new Promise<undefined>(resolve => { entryScope.timeout(SERVER_SITES_MS, () => { resolve(undefined); }); });
|
|
99
104
|
return Promise.race([read, late]).catch(() => undefined);
|
|
100
105
|
}
|
|
106
|
+
/** The page's placement file read, started at once; it never rejects and settles inside `PLACED_DEADLINE_MS` (3 s) of the entry's
|
|
107
|
+
* start, chunk import included. Past that the boot goes on with the build's grid and a late answer installs nothing. A page with no
|
|
108
|
+
* world (preview, solo) reads none. */
|
|
109
|
+
function learnPlacedCellsOnce(): Promise<void> {
|
|
110
|
+
const late = new AbortController();
|
|
111
|
+
const read = (async (): Promise<void> => {
|
|
112
|
+
try {
|
|
113
|
+
// a page with no world and no placement stamp (preview, solo) reads none and imports nothing (PAGE-SIZE: the title waits here)
|
|
114
|
+
const stamps = globalThis as { __WS_WORLD__?: unknown; __WS_PLACEMENTS__?: unknown };
|
|
115
|
+
if (stamps.__WS_WORLD__ === undefined && stamps.__WS_PLACEMENTS__ === undefined) return;
|
|
116
|
+
const { learnPlacedCells, placementsOf } = await import('@wildshard/engine/game/grid/placedCells');
|
|
117
|
+
const url = placementsOf(globalThis as { __WS_WORLD__?: unknown; __WS_PLACEMENTS__?: unknown });
|
|
118
|
+
if (url === null || late.signal.aborted) return;
|
|
119
|
+
const answer = await bootTask('app:placed-cells', () => learnPlacedCells(url, { signal: late.signal }));
|
|
120
|
+
if ('kept' in answer) console.info(`[grid] build's grid kept: ${answer.kept}`);
|
|
121
|
+
else console.info(`[grid] placement serial ${String(answer.serial)}: ${answer.added.map(cell => `${cell.instance} at (${cell.cell.join(',')})`).join(', ') || 'no new cell'}${answer.carded.length === 0 ? '' : `; carded from the catalogue ${answer.carded.join(', ')}`}${answer.left.length === 0 ? '' : `; left out ${answer.left.join('; ')}`}`);
|
|
122
|
+
} catch (error) { console.warn('[grid] placement file not read:', error); }
|
|
123
|
+
})();
|
|
124
|
+
const deadline = new Promise<void>(resolve => { entryScope.timeout(PLACED_DEADLINE_MS, () => { late.abort(); resolve(); }); });
|
|
125
|
+
return Promise.race([read, deadline]);
|
|
126
|
+
}
|
|
101
127
|
async function enterPage(): Promise<unknown> {
|
|
128
|
+
// S20: a crash read off another tab's live beat is no crash; asked now, answered (at most 500 ms) before the title reads it
|
|
129
|
+
const settled = settleLastEnd();
|
|
130
|
+
await placedCells;
|
|
102
131
|
const requested = search.get('chunk');
|
|
103
|
-
// SA36: a `/slug/<slug>` link opens that one shard's page; its PLAY leaves for `/?chunk=<slug>`, so a world never boots here
|
|
104
|
-
//
|
|
105
|
-
// would open it on staging and production to a returning player)
|
|
132
|
+
// SA36: a `/slug/<slug>` link opens that one shard's page; its PLAY leaves for `/?chunk=<slug>`, so a world never boots here.
|
|
133
|
+
// SA37: on every host, a world build too: PLAY's `/?chunk=` page enters the world's grid at the shard's cell (GO7 below)
|
|
106
134
|
const slugged = slugOfPath(location.pathname);
|
|
107
|
-
if (slugged !== null && requested === null
|
|
135
|
+
if (slugged !== null && requested === null) return showSlugPage(slugged);
|
|
108
136
|
// An embedded author product has its own admission. A game URL must name a
|
|
109
137
|
// listed world before any discovery, tables or renderer can be prepared.
|
|
110
138
|
if (requested !== null && document.getElementById('ws-shardfile') === null && findTitleManifest(requested) === undefined) {
|
|
@@ -112,6 +140,7 @@ async function enterPage(): Promise<unknown> {
|
|
|
112
140
|
return showPageTitle(UNLISTED);
|
|
113
141
|
}
|
|
114
142
|
await waitFor('Startup stylesheets', waitForLoadingStyles(entryScope), 'file');
|
|
143
|
+
await settled;
|
|
115
144
|
const { consumeGridRecovery, gridRecoveryRefused, pageGridRecovery, pendingGridEntry } = await bootTask('app:page-entry-import', () => import('@wildshard/engine/game/grid/pageEntry'));
|
|
116
145
|
// QA row 16 (GO1): an online level seats a body the world sees, so only a tap enters one. Crash resume is the solo build's.
|
|
117
146
|
const online = (globalThis as { __WS_WORLD__?: unknown }).__WS_WORLD__ !== undefined;
|
|
@@ -197,7 +226,10 @@ async function enterPage(): Promise<unknown> {
|
|
|
197
226
|
import('@wildshard/engine/game/grid/menu'), import('@wildshard/engine/game/boot/spawnDownload')]));
|
|
198
227
|
await tier.initializeTier();
|
|
199
228
|
const slug = search.get('chunk');
|
|
200
|
-
|
|
229
|
+
// SA43: a page that owns its inline shard (`wildshard dev`, `wildshard prepare` at `?chunk=`) has no catalogue download
|
|
230
|
+
// for it: that shard's spawn set isn't its download (as startSelected's `authored`)
|
|
231
|
+
const inlineShard = (menu.DEVSERVER || menu.PREPARATION_ONLY) && document.getElementById('ws-shardfile') !== null;
|
|
232
|
+
if (typeof slug === 'string' && !inlineShard) {
|
|
201
233
|
const mode = menu.gridMode(menu.DEVSERVER), flow = pageGridRecovery() !== null || pendingGridEntry(slug) ? 'grid' : 'client';
|
|
202
234
|
spawn.setSpawnPacks(runtimePacksOn());
|
|
203
235
|
// LD2 (J208): a Start read this download holds (selected discovery behind the warm check) is named from the tap
|
|
@@ -217,7 +249,8 @@ async function enterPage(): Promise<unknown> {
|
|
|
217
249
|
})();
|
|
218
250
|
}
|
|
219
251
|
async function showPageTitle(refusal = ''): Promise<void> {
|
|
220
|
-
|
|
252
|
+
// S20: the title's ended note reads lastEnd(), settled (the imports take longer than the lock query)
|
|
253
|
+
const [{ showStartTitle }, { buildTitleMenu, installGridTitle }, { travel }] = await Promise.all([import('@wildshard/engine/ui/StartTitle'), import('@wildshard/engine/game/mainMenu'), import('@wildshard/engine/game/travel/travel'), settleLastEnd()]);
|
|
221
254
|
// SF21a: a tap or validated recovery selects a grid; unrecorded process loss returns to title
|
|
222
255
|
const grid = installGridTitle();
|
|
223
256
|
// the composition root wires the game's main menu (over its shard deck) into the engine's title (E405)
|
|
@@ -248,6 +281,7 @@ async function showPageTitle(refusal = ''): Promise<void> {
|
|
|
248
281
|
*/
|
|
249
282
|
async function showSlugPage(slug: string): Promise<void> {
|
|
250
283
|
document.documentElement.classList.add('title-first');
|
|
284
|
+
await settleLastEnd(); // S20: its ended note reads lastEnd()
|
|
251
285
|
const manifest = findTitleManifest(slug);
|
|
252
286
|
// the page's query (`?sw=0`, `?tier=`, …) rides along to `/`, as a Shard select tap keeps it
|
|
253
287
|
const home = (): URL => new URL(`/${location.search}`, location.origin);
|
|
@@ -348,7 +382,7 @@ async function startSelected(): Promise<void> {
|
|
|
348
382
|
const moduleRows: unknown = moduleText === undefined ? undefined : JSON.parse(moduleText);
|
|
349
383
|
const gridEntryModule = import('@wildshard/engine/game/grid/pageEntry');
|
|
350
384
|
const gridMenuModule = import('@wildshard/engine/game/grid/menu');
|
|
351
|
-
const [gridSelection, { gridMode, DEVSERVER }] = await Promise.all([gridEntryModule, gridMenuModule]);
|
|
385
|
+
const [gridSelection, { gridMode, DEVSERVER, PREPARATION_ONLY }] = await Promise.all([gridEntryModule, gridMenuModule]);
|
|
352
386
|
const earlyPath = gridSelection.pageGridRecovery() !== null || gridSelection.pendingGridEntry(arrival.slug)
|
|
353
387
|
? 'grid' : 'shardfile';
|
|
354
388
|
// MF4: one spawn manifest per shard / tier / flow (grid: per menu mode) is the whole download; the bar reads only it and
|
|
@@ -358,8 +392,9 @@ async function startSelected(): Promise<void> {
|
|
|
358
392
|
setSpawnPacks(runtimePacksOn()); // DL16: Debug ▸ Loading & memory ▸ Level download
|
|
359
393
|
// DL21: a read the whole-set hold stalls is named on the card as the spawn download, in its step
|
|
360
394
|
observeSpawnHolds((held, path) => waitFor('Spawn download', held, 'file', `spawn-download:${path}`));
|
|
361
|
-
// SA15: `wildshard dev`'s page carries the author's shard inline; the catalogue shard's spawn set isn't its download
|
|
362
|
-
|
|
395
|
+
// SA15: `wildshard dev`'s page carries the author's shard inline; the catalogue shard's spawn set isn't its download.
|
|
396
|
+
// SA43: so does `wildshard prepare`'s, a preparation-only production build; only those two builds own an inline shard
|
|
397
|
+
const inlineOwner = DEVSERVER || PREPARATION_ONLY, authored = inlineOwner && document.getElementById('ws-shardfile') !== null;
|
|
363
398
|
const spawnMode = gridMode(DEVSERVER), spawnJob = authored ? null : startSpawnDownload(arrival.slug, earlyPath === 'grid' ? 'grid' : 'client', TIER,
|
|
364
399
|
`${Number(spawnMode.developer)}${Number(spawnMode.devserver)}${Number(spawnMode.nineDragon)}`);
|
|
365
400
|
if (spawnJob !== null) void loading.setDownloadSource(spawnJob);
|
|
@@ -413,7 +448,7 @@ async function startSelected(): Promise<void> {
|
|
|
413
448
|
try {
|
|
414
449
|
imports.check();
|
|
415
450
|
loading.setPrefetchSource(gridPrefetchStatus);
|
|
416
|
-
const source = pageGridRecovery() === null ? await bootTask('app:product-source-and-read', () => configuredShardfile(document, browserShardfileOptions(document.baseURI,
|
|
451
|
+
const source = pageGridRecovery() === null ? await bootTask('app:product-source-and-read', () => configuredShardfile(document, browserShardfileOptions(document.baseURI, inlineOwner))) : null;
|
|
417
452
|
page = preparePageResidency(arrival, source?.identity.slug);
|
|
418
453
|
// The script memory bank, sized by route: each reserve can cost JSC a full GC (e472f34069), so a grid page reserves
|
|
419
454
|
// the full-ALL route's demand for its cell activations in play, and a standalone page, which builds its one world under
|
|
@@ -453,7 +488,7 @@ async function startSelected(): Promise<void> {
|
|
|
453
488
|
if (spawnJob !== null) await waitFor('Spawn download', spawnJob.listed ?? spawnJob.ready, 'file');
|
|
454
489
|
const manifest = await bootAwait('app:product-admission', source === null
|
|
455
490
|
? installManifestShardfile(arrival, { ...browserShardfileOptions(document.baseURI, true), memory: page.memory, progress: (progress) => { loading.paintAdmission(progress); } }, bindings, imports.ready)
|
|
456
|
-
: installShardfileProduct(source, { ...browserShardfileOptions(document.baseURI,
|
|
491
|
+
: installShardfileProduct(source, { ...browserShardfileOptions(document.baseURI, inlineOwner), memory: page.memory, progress: (progress) => { loading.paintAdmission(progress); } }, bindings, imports.ready));
|
|
457
492
|
// Keep the seam out of code and descriptor admission; world construction
|
|
458
493
|
// can overlap this read and retains its original full-geometry barrier.
|
|
459
494
|
if (page.mode === 'grid') gridSelection.startGridEntryContent(page.instance ?? pageGridRecovery()?.instance ?? gridSelection.gridHome().instance);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assetCacheName } from '../pwa/cacheNames';
|
|
2
2
|
|
|
3
3
|
/** Publish a complete immutable native response after an uncontrolled read.
|
|
4
4
|
* No metadata owner or protocol: the next worker reads the same absolute URL.
|
|
@@ -10,7 +10,7 @@ export async function publishBootResponse(path: string, response: Response): Pro
|
|
|
10
10
|
const url = new URL(path, location.href);
|
|
11
11
|
if (url.origin !== location.origin || url.searchParams.has('sw')
|
|
12
12
|
|| !(/-[a-f0-9]{8,64}\.[a-z0-9]+$/u.test(url.pathname) || /^[a-f0-9]{8,64}$/u.test(url.searchParams.get('v') ?? ''))) return;
|
|
13
|
-
await (await caches.open(
|
|
13
|
+
await (await caches.open(assetCacheName())).put(url.href, response);
|
|
14
14
|
} catch { /* Quota, disabled storage and publication failure keep the native read usable. */ }
|
|
15
15
|
finally { void response.body?.cancel().catch(() => undefined); }
|
|
16
16
|
}
|
|
@@ -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); }
|