@wildshard/engine 0.1.15 → 0.1.17

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.
Files changed (207) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/index.html +157 -11
  3. package/lint/engine-sides.json +16 -0
  4. package/lint/host-register.json +496 -0
  5. package/lint/ratchet.json +2 -2
  6. package/lint/shard-imports.d.mts +1 -0
  7. package/lint/shard-imports.mjs +56 -8
  8. package/lint/wildshard-plugin.js +22 -4
  9. package/package.json +16 -5
  10. package/scripts/app-build/buildIdentity.d.mts +3 -1
  11. package/scripts/app-build/buildIdentity.mjs +25 -5
  12. package/scripts/app-build/builtAt.d.mts +4 -0
  13. package/scripts/app-build/builtAt.mjs +21 -0
  14. package/scripts/app-build/serviceWorker.ts +16 -2
  15. package/scripts/app-build/versionFiles.ts +2 -1
  16. package/scripts/app-build-pipeline.mjs +4 -1
  17. package/scripts/audio-download-proof.mjs +843 -0
  18. package/scripts/build-app.mjs +4 -0
  19. package/scripts/build-mirror.d.mts +2 -0
  20. package/scripts/build-mirror.mjs +5 -4
  21. package/scripts/built-product.mjs +3 -3
  22. package/scripts/cell-mem/metrics-preload.mjs +65 -0
  23. package/scripts/cell-mem-bench.mjs +130 -0
  24. package/scripts/check-chunks.mjs +2 -1
  25. package/scripts/devserver-client.d.mts +5 -0
  26. package/scripts/devserver-client.mjs +68 -0
  27. package/scripts/engine-ci-budget.ts +7 -1
  28. package/scripts/format-lock.mjs +20 -11
  29. package/scripts/generate-title-launch.mjs +3 -2
  30. package/scripts/grid-crossing-walk-proof.mjs +16 -8
  31. package/scripts/heavy-lane.py +25 -1
  32. package/scripts/host-ruler/register-migrate.mjs +242 -0
  33. package/scripts/host-ruler/register.d.mts +36 -0
  34. package/scripts/host-ruler/register.mjs +116 -0
  35. package/scripts/host-ruler/roots.d.mts +29 -0
  36. package/scripts/host-ruler/roots.mjs +333 -0
  37. package/scripts/host-ruler/server-roots.d.mts +23 -0
  38. package/scripts/host-ruler/server-roots.mjs +272 -0
  39. package/scripts/main-watch.d.mts +1 -1
  40. package/scripts/main-watch.mjs +10 -6
  41. package/scripts/map-hash.mjs +3 -6
  42. package/scripts/mmo-bots.mjs +2 -2
  43. package/scripts/offline-proof-rules.d.mts +1 -0
  44. package/scripts/offline-proof-rules.mjs +22 -1
  45. package/scripts/online-rig.mjs +4 -4
  46. package/scripts/page-release/flow.d.mts +1 -0
  47. package/scripts/page-release/flow.mjs +6 -2
  48. package/scripts/page-release.mjs +5 -1
  49. package/scripts/physics-route.json +0 -71
  50. package/scripts/pins-catalogue.ts +103 -0
  51. package/scripts/pins-reuse.mjs +3 -1
  52. package/scripts/pins.ts +22 -14
  53. package/scripts/preview-grid.ts +203 -0
  54. package/scripts/road-preload-proof.mjs +167 -0
  55. package/scripts/server-release/publish.mjs +2 -2
  56. package/scripts/server-release/served-slug.d.mts +2 -0
  57. package/scripts/server-release/served-slug.mjs +10 -0
  58. package/scripts/server-release/sign.d.mts +1 -0
  59. package/scripts/server-release/sign.mjs +3 -7
  60. package/scripts/shard-components.mjs +0 -2
  61. package/scripts/shard-outputs.d.mts +8 -0
  62. package/scripts/shard-outputs.mjs +45 -11
  63. package/scripts/side-parity.d.mts +2 -1
  64. package/scripts/side-parity.mjs +25 -4
  65. package/scripts/test-amber.d.mts +1 -0
  66. package/scripts/test-amber.mjs +10 -0
  67. package/scripts/test-products.json +3 -3
  68. package/scripts/tracked-public.d.mts +1 -0
  69. package/scripts/tracked-public.mjs +17 -0
  70. package/src/cli/engine.mjs +8 -0
  71. package/src/client/app/bootRoute.ts +4 -1
  72. package/src/client/app/dropModal.ts +15 -2
  73. package/src/client/app/entry.ts +67 -11
  74. package/src/client/app/slugPath.ts +5 -0
  75. package/src/client/engine/audio/Audio.ts +20 -2
  76. package/src/client/engine/boot/bakedTextures.ts +3 -2
  77. package/src/client/engine/boot/bootTrace.ts +6 -1
  78. package/src/client/engine/boot/bytes.ts +4 -3
  79. package/src/client/engine/boot/clearDownloads.ts +1 -1
  80. package/src/client/engine/boot/contentRead.ts +4 -0
  81. package/src/client/engine/boot/dropNotice.ts +20 -6
  82. package/src/client/engine/boot/gpuFiles.ts +25 -2
  83. package/src/client/engine/boot/lastEnd.ts +8 -2
  84. package/src/client/engine/boot/shardPrefetch.ts +7 -1
  85. package/src/client/engine/boot/sw.ts +19 -0
  86. package/src/client/engine/core/Game.ts +11 -3
  87. package/src/client/engine/core/GpuRecovery.ts +7 -0
  88. package/src/client/engine/core/Volumetrics.ts +5 -0
  89. package/src/client/engine/core/assets.ts +27 -20
  90. package/src/client/engine/core/bootstrap.ts +1 -2
  91. package/src/client/engine/core/ktx2.ts +84 -11
  92. package/src/client/engine/explore/Compare.ts +2 -2
  93. package/src/client/engine/explore/TouchFly.ts +3 -5
  94. package/src/client/engine/input/dom.ts +12 -0
  95. package/src/client/engine/net/predictor.ts +6 -2
  96. package/src/client/engine/player/Player.ts +10 -2
  97. package/src/client/engine/player/TouchControls.ts +12 -4
  98. package/src/client/engine/pwa/sw.js +47 -8
  99. package/src/client/engine/render/drawCheck.ts +96 -0
  100. package/src/client/engine/saves/staleBuildNote.ts +46 -0
  101. package/src/client/engine/telemetry/browserErrors.ts +157 -20
  102. package/src/client/engine/telemetry/screenOutbox.ts +61 -0
  103. package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
  104. package/src/client/engine/ui/DeathFade.ts +99 -11
  105. package/src/client/engine/ui/ErrorModal.ts +13 -6
  106. package/src/client/engine/ui/Feedback.ts +2 -1
  107. package/src/client/engine/ui/Loading.ts +10 -6
  108. package/src/client/engine/ui/Map.ts +2 -1
  109. package/src/client/engine/ui/WeaponStrip.ts +2 -1
  110. package/src/client/engine/ui/backGuard.ts +104 -0
  111. package/src/client/engine/ui/hudAdapters.ts +30 -4
  112. package/src/client/engine/ui/loading.css +17 -0
  113. package/src/client/engine/ui/namePrompt.ts +6 -5
  114. package/src/client/engine/ui/styles/combat.css +12 -0
  115. package/src/client/engine/ui/styles/namePrompt.css +4 -2
  116. package/src/client/game/boot/audio.generated.ts +0 -294
  117. package/src/client/game/boot/bytes.generated.ts +0 -11
  118. package/src/client/game/boot/versions.generated.ts +0 -11
  119. package/src/client/game/compendium/keepsakes.ts +16 -6
  120. package/src/client/game/grapple/tool.ts +10 -7
  121. package/src/client/game/grid/cellLoading.ts +23 -12
  122. package/src/client/game/grid/cellScreens.ts +39 -74
  123. package/src/client/game/grid/liveSession.ts +40 -7
  124. package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
  125. package/src/client/game/grid/nearPlaceholderView.ts +9 -3
  126. package/src/client/game/grid/oneWayIn.ts +92 -27
  127. package/src/client/game/grid/pageEntry.ts +19 -0
  128. package/src/client/game/grid/pageShell.ts +1 -1
  129. package/src/client/game/grid/plotAudio.ts +114 -0
  130. package/src/client/game/grid/products.ts +55 -5
  131. package/src/client/game/grid/roadLookPlatform.ts +2 -2
  132. package/src/client/game/grid/session.ts +38 -22
  133. package/src/client/game/grid/spawnGround.ts +68 -0
  134. package/src/client/game/grid/voidLook.ts +29 -23
  135. package/src/client/game/loot/runtime.ts +3 -1
  136. package/src/client/game/mainMenu.ts +14 -6
  137. package/src/client/game/riding/hud.ts +6 -4
  138. package/src/client/game/session/finish.ts +17 -3
  139. package/src/client/game/session/play.ts +8 -2
  140. package/src/client/game/session/session.ts +4 -1
  141. package/src/client/game/shardfile/clientWorker.ts +41 -12
  142. package/src/client/game/shardfile/serverRoute.ts +10 -22
  143. package/src/client/game/slugPage.css +11 -0
  144. package/src/client/game/slugPage.ts +84 -0
  145. package/src/client/game/systems/viewmodel/heldView.ts +6 -3
  146. package/src/client/game/titleDeck.ts +55 -32
  147. package/src/client/host/online/doctor.ts +7 -6
  148. package/src/client/host/online/linkScreens.ts +16 -0
  149. package/src/client/host/online/release.ts +51 -5
  150. package/src/client/host/online/shell.ts +48 -27
  151. package/src/client/host/standalone/shell.ts +7 -3
  152. package/src/cook/game/audioReport.ts +57 -0
  153. package/src/cook/game/entryTotals.ts +26 -6
  154. package/src/cook/game/installedRuntimeReads.ts +3 -0
  155. package/src/server/engine/sim/respawn.ts +6 -1
  156. package/src/server/engine/sim.ts +3 -0
  157. package/src/server/game/grid/simulation.ts +35 -0
  158. package/src/server/game/loot/harvest.ts +2 -0
  159. package/src/server/game/loot/keepsakeProgression.ts +40 -0
  160. package/src/server/game/loot/playerOwned.ts +5 -1
  161. package/src/server/game/plugin/simulation.ts +4 -0
  162. package/src/server/game/population/nativeBake.ts +2 -1
  163. package/src/server/game/quest/chapterRecords.ts +2 -0
  164. package/src/server/game/quest/serverChapters.ts +4 -0
  165. package/src/server/game/quest/serverDoors.ts +11 -5
  166. package/src/server/game/roomRespawn.ts +4 -0
  167. package/src/server/game/shardfile/installedSides.ts +18 -0
  168. package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
  169. package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
  170. package/src/server/host/bake/headlessWorker.ts +5 -1
  171. package/src/server/host/dedicated/cellHost.ts +98 -29
  172. package/src/server/host/dedicated/cellProtocol.ts +11 -1
  173. package/src/server/host/dedicated/cellWorker.ts +9 -3
  174. package/src/server/host/dedicated/crossing.ts +6 -2
  175. package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
  176. package/src/server/host/dedicated/gridCells.ts +52 -9
  177. package/src/server/host/dedicated/main.ts +31 -12
  178. package/src/server/host/dedicated/placementFile.ts +72 -0
  179. package/src/server/host/dedicated/releaseFile.ts +17 -10
  180. package/src/server/host/dedicated/roadRoom.ts +21 -5
  181. package/src/server/host/dedicated/workerTable.ts +13 -1
  182. package/src/server/host/dedicated/world.ts +81 -9
  183. package/src/server/host/headlessRuntime.ts +10 -5
  184. package/src/server/host/installers.ts +62 -0
  185. package/src/server/host/openWorld.ts +59 -0
  186. package/src/server/host/ropeDecks.ts +2 -0
  187. package/src/server/host/standalone/cellWorld.ts +25 -19
  188. package/src/server/host/standalone/fallFloor.ts +2 -2
  189. package/src/server/host/standalone/gridServer.ts +7 -4
  190. package/src/server/host/standalone/roadWorld.ts +41 -4
  191. package/src/shared/engine/audio/bootAudio.ts +33 -0
  192. package/src/shared/engine/level/spec.ts +3 -3
  193. package/src/shared/engine/net/acts.ts +3 -0
  194. package/src/shared/engine/physics/query.ts +27 -0
  195. package/src/shared/engine/physics/terrain.ts +19 -28
  196. package/src/shared/engine/saves/saves.lock.json +15 -0
  197. package/src/shared/engine/sim/actRoutes.ts +2 -0
  198. package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
  199. package/src/shared/game/grid/catalogue.ts +12 -5
  200. package/src/shared/game/grid/catalogueSlot.ts +11 -0
  201. package/src/shared/game/grid/farProxy.ts +6 -5
  202. package/src/shared/game/grid/pageMode.ts +1 -1
  203. package/src/shared/game/grid/roadLayout.ts +26 -3
  204. package/src/shared/game/grid/singleplayer.json +0 -13
  205. package/src/shared/game/grid/voidFloor.ts +122 -0
  206. package/src/shared/game/strings.ts +15 -0
  207. package/src/shared/host/standalone/netInput.ts +2 -1
@@ -1,83 +1,48 @@
1
1
  /**
2
- * G578 (Jake, 2026-10-21: on the grid a cell load never leaves the 3D world): the waiting cell's loading steps on an
3
- * in-world screen at its edge, the same rows as the loading screen (`loadingPath('cell')`): each step done, the one now with
4
- * its detail, the rest to come, or why it refused. It stands over the road where the traveller meets the closed wall (the
5
- * soft wall's edge midpoint), 12 m beyond the wall and facing out, so a traveller held at the wall reads all of it (closer,
6
- * the 9 m panel overflows a portrait view; on the traveller's side it stood behind the camera). It draws over the cell's
7
- * ground (no depth test): the road and the other cells stay live around it while the cell's boundary holds. Presentation
8
- * only: it reads the session's step, and owns one canvas.
2
+ * QA 2026-11-13 (Jake: "This loading screen here, I have no idea why this loading screen in the 3D world is completely
3
+ * different from the new one ... make it look the same as the one for Shard Select"): a waiting cell's steps on SHARD
4
+ * SELECT's own loading card (`Loading`, scoped, in its `inset` mode), a crisp screen-space card over the live world. It
5
+ * replaced G578's blurry canvas panel standing in 3D beyond the cell's wall (`CellScreen`, removed). The card opens when
6
+ * a cell's preparation shows, steps with it, completes and fades when the cell is entered, and goes at once when the
7
+ * traveller leaves or the session ends. Presentation only: `CellLoading` decides what it shows.
9
8
  */
10
- import { CanvasTexture, Mesh, MeshBasicMaterial, type Object3D, PlaneGeometry, SRGBColorSpace } from 'three';
11
- import type { Scope } from '@wildshard/engine/app/scope';
12
- import type { SoftWallEdge } from './softWallLook';
9
+ import { Loading } from '@wildshard/engine/ui/Loading';
10
+ import { loadingPath } from '../boot/loadingPaths';
11
+ import type { CellLoadingScreen, CellLoadingView } from './cellLoading';
13
12
 
14
- /** One row of the screen: its label and whether it is done, running now (with the detail) or still to come. */
15
- export interface CellScreenRow { readonly label: string; readonly state: 'done' | 'now' | 'next' }
16
- /** What the screen shows: whose cell, its rows, the running step's detail, or the refusal instead of the rows. */
17
- export interface CellScreenView { readonly name: string; readonly rows: readonly CellScreenRow[]; readonly detail: string; readonly failed: string | null }
13
+ export class CellLoadingCard implements CellLoadingScreen {
14
+ private card: { readonly instance: string; readonly loading: Loading; failed: string | null } | null = null;
15
+ /** an entered cell's card while it completes and fades: a new card or a leave ends it at once */
16
+ private fading: Loading | null = null;
18
17
 
19
- /** The side of a cell (`sides`, its four edges around `centre`) the traveller faces from `dx`, `dz` (their offset from the
20
- * cell's centre): the axis they are further along, on their side; one standing at the very centre gets the +x side. */
21
- export function facingEdge<E extends { readonly x: number; readonly z: number; readonly axis: 'x' | 'z' }>(sides: readonly E[],
22
- centre: { readonly x: number; readonly z: number }, dx: number, dz: number): E | undefined {
23
- const sx = dx < 0 ? -1 : 1, sz = dz < 0 ? -1 : 1;
24
- return Math.abs(dx) >= Math.abs(dz) ? sides.find(row => row.axis === 'x' && Math.sign(row.x - centre.x) === sx)
25
- : sides.find(row => row.axis === 'z' && Math.sign(row.z - centre.z) === sz);
26
- }
27
-
28
- const W = 1024, H = 576, WIDTH = 9, HEIGHT = WIDTH * H / W, LIFT = 1, IN = 12;
29
- const CYAN = '#38e6ff', DIM = 'rgba(205, 240, 255, 0.55)', FONT = 'system-ui, -apple-system, sans-serif';
30
-
31
- /** The one in-world loading screen, moved to whichever cell the traveller waits at. */
32
- export class CellScreen {
33
- private readonly canvas: HTMLCanvasElement | OffscreenCanvas;
34
- private readonly texture: CanvasTexture<HTMLCanvasElement | OffscreenCanvas>;
35
- private readonly mesh: Mesh<PlaneGeometry, MeshBasicMaterial>;
36
- private drawn = '';
37
- constructor(parent: Object3D, scope: Scope) {
38
- this.canvas = typeof document === 'undefined' ? new OffscreenCanvas(W, H) : Object.assign(document.createElement('canvas'), { width: W, height: H });
39
- this.texture = scope.own(new CanvasTexture(this.canvas)); this.texture.colorSpace = SRGBColorSpace;
40
- const material = scope.own(new MeshBasicMaterial({ map: this.texture, transparent: true, depthTest: false, depthWrite: false, toneMapped: false, fog: false }));
41
- this.mesh = new Mesh(scope.own(new PlaneGeometry(WIDTH, HEIGHT)), material);
42
- this.mesh.name = 'cell-loading-screen'; this.mesh.visible = false; this.mesh.renderOrder = 20; this.mesh.frustumCulled = false;
43
- parent.add(this.mesh); scope.onDispose(() => { this.mesh.removeFromParent(); });
18
+ show(view: CellLoadingView): void {
19
+ // a cleared refusal starts a fresh card: a failed card keeps its reason until it is disposed
20
+ if (this.card !== null && (this.card.instance !== view.instance || this.card.failed !== null && view.failed === null)) this.hide(false);
21
+ let card = this.card;
22
+ if (card === null) {
23
+ this.fading?.scope.dispose(); this.fading = null;
24
+ const loading = new Loading({ id: view.instance, name: view.name }, { scoped: true, inset: true });
25
+ loading.setPath(loadingPath('cell'));
26
+ card = this.card = { instance: view.instance, loading, failed: null };
27
+ }
28
+ if (view.failed !== null) {
29
+ if (card.failed !== view.failed) { card.failed = view.failed; card.loading.scopedFail(view.failed); }
30
+ return;
31
+ }
32
+ card.loading.scopedStep(view.step, view.detail);
44
33
  }
45
34
 
46
- /** Stand beyond `edge` (the waiting cell's closed wall in the home frame), facing the traveller outside it, and draw `view`. */
47
- show(edge: SoftWallEdge, cell: { readonly x: number; readonly z: number }, ground: number, view: CellScreenView): void {
48
- const outward = edge.axis === 'x' ? Math.sign(edge.x - cell.x) : Math.sign(edge.z - cell.z);
49
- const x = edge.axis === 'x' ? edge.x - outward * IN : edge.x, z = edge.axis === 'z' ? edge.z - outward * IN : edge.z;
50
- this.mesh.position.set(x, ground + LIFT + HEIGHT / 2, z);
51
- // the (front) face looks out of the cell, toward the traveller on the road
52
- this.mesh.rotation.set(0, edge.axis === 'x' ? (outward > 0 ? Math.PI / 2 : -Math.PI / 2) : (outward > 0 ? 0 : Math.PI), 0);
53
- this.mesh.updateMatrixWorld();
54
- this.mesh.visible = true;
55
- const key = JSON.stringify(view);
56
- if (key !== this.drawn) { this.drawn = key; this.draw(view); }
35
+ hide(entered: boolean): void {
36
+ const card = this.card;
37
+ if (!entered) { this.fading?.scope.dispose(); this.fading = null; }
38
+ if (card === null) return;
39
+ this.card = null;
40
+ if (entered && card.failed === null) {
41
+ const fading = this.fading = card.loading;
42
+ void fading.done().then(() => { if (this.fading === fading) this.fading = null; return undefined; }, () => undefined);
43
+ } else card.loading.scope.dispose();
57
44
  }
58
- /** Hide it (the cell is ready, or no cell is waiting). */
59
- hide(): void { this.mesh.visible = false; }
60
- get visible(): boolean { return this.mesh.visible; }
61
45
 
62
- private draw(view: CellScreenView): void {
63
- const g = this.canvas.getContext('2d');
64
- if (g === null) throw new Error('Cell screen has no 2D context');
65
- g.clearRect(0, 0, W, H);
66
- g.fillStyle = 'rgba(4, 18, 28, 0.82)'; g.fillRect(0, 0, W, H);
67
- g.strokeStyle = CYAN; g.lineWidth = 6; g.strokeRect(3, 3, W - 6, H - 6);
68
- g.fillStyle = CYAN; g.font = `700 54px ${FONT}`; g.textBaseline = 'top';
69
- g.fillText(view.name.toUpperCase(), 44, 34);
70
- if (view.failed !== null) {
71
- g.fillStyle = '#ff9a7a'; g.font = `600 36px ${FONT}`; g.fillText(view.failed.slice(0, 48), 44, 130);
72
- } else {
73
- g.font = `500 32px ${FONT}`;
74
- view.rows.forEach((row, i) => {
75
- const y = 118 + i * 52;
76
- g.fillStyle = row.state === 'next' ? DIM : row.state === 'now' ? CYAN : '#ffffff';
77
- g.fillText(`${row.state === 'done' ? '✓' : row.state === 'now' ? '▶' : '·'} ${row.label}`, 44, y);
78
- });
79
- g.fillStyle = DIM; g.font = `400 28px ${FONT}`; g.fillText(view.detail.slice(0, 60), 44, H - 64);
80
- }
81
- this.texture.needsUpdate = true;
82
- }
46
+ /** The card's root while one is up (tests and proofs read it). */
47
+ get root(): HTMLElement | null { return this.card?.loading.root ?? null; }
83
48
  }
@@ -78,6 +78,8 @@ import { copyPrompts, enteredCopy } from './copyPrompts';
78
78
  import { yieldGridAdmission, yieldGridConstruction } from './admissionYield';
79
79
  import { HybridRuntimeSession, type HybridResident } from '../shardfile/hybrid';
80
80
 
81
+ import { enterPlotAudio, pagePlotAudioPorts, plotAudioScene, type PlotAudioPorts, type PlotAudioScene } from './plotAudio';
82
+ import { shardProductFromAdmission } from '../shardfile/runtimeProduct';
81
83
  import { createRegionalRuntimeFactory, regionalRuntimeAccountedBytes, type PreparedRegionalRuntime, type RegionalRuntimePage, type RegionalRuntimeTextures } from './regionalRuntime';
82
84
  import { bindHomeBuildCache } from '../shardfile/homeBuildCache';
83
85
  import type { ClientTileRegistration } from '../shardfile/tileContent';
@@ -87,6 +89,7 @@ import { resolveLevelBounds } from '../../../shared/game/shard/runtime';
87
89
  import { declaredPlayArea, type PlayArea } from '@wildshard/engine/game/shardfile/playArea';
88
90
  import type { ShardProduct } from '@wildshard/engine/game/shardfile/shardProduct';
89
91
  import type { Bounds } from '@wildshard/engine/level/spec';
92
+ import { pinFrameOffset } from '@wildshard/engine/ui/hudAdapters';
90
93
 
91
94
  /** The cached metadata claim and its later constructor enter the same immutable
92
95
  * texture policy. Fresh inputs remain borrowed only by actual construction. */
@@ -230,7 +233,10 @@ export class LiveGridSession {
230
233
  private readonly applied = new Vector3();
231
234
  private readonly roadWallet: GridWallet;
232
235
  /** each admitted region's authored spawn (its level's player start) and its ground / water queries, local */
233
- private readonly regions = new Map<string, { readonly spawn: LiveGridSpawn; readonly items: Shardfile['items']['rows']; readonly queries: PlayerFrameQueries; readonly colliders: PanelRegion['colliders']; readonly prompts: ReturnType<typeof copyPrompts> }>();
236
+ private readonly regions = new Map<string, { readonly spawn: LiveGridSpawn; readonly items: Shardfile['items']['rows']; readonly queries: PlayerFrameQueries; readonly colliders: PanelRegion['colliders']; readonly prompts: ReturnType<typeof copyPrompts>; readonly audio: PlotAudioScene | null }>();
237
+ /** AU20: the entered data cell's own audio scene (an Open Plot's score, bed and loops), live while the feet are in it. */
238
+ private plotAudio: { readonly instance: string; readonly scope: Scope } | null = null;
239
+ private readonly plotBanks = new Map<string, ReturnType<PlotAudioPorts['bank']>>();
234
240
  private readonly runtimeScope: Scope;
235
241
  private readonly runtimeRegions = new Map<string, PreparedRegionalRuntime>();
236
242
  private readonly leaveTiming: { instance: string; leaveMs: number }[] = [];
@@ -261,8 +267,9 @@ export class LiveGridSession {
261
267
  this.runtimeScope = scope.child('grid.runtime.residents');
262
268
  this.hybrid = new HybridRuntimeSession(this.runtimeResidents, scope, { pause: yieldGridConstruction });
263
269
  scope.onDispose(gridCells.onLeave(() => { this.hybrid.leave(); }));
270
+ scope.onDispose(gridCells.onLeave(() => { this.leavePlotAudio(); }));
264
271
  scope.onDispose(gridCells.onEnter(cell => {
265
- if (!this.runtimeResidents.has(cell.instance)) { ports.lightingSettled?.(); return; }
272
+ if (!this.runtimeResidents.has(cell.instance)) { this.enterPlotAudio(cell.instance); ports.lightingSettled?.(); return; }
266
273
  this.startedRuntimes.add(cell.instance);
267
274
  const activation = this.hybrid.enter(cell);
268
275
  this.activation = activation;
@@ -367,15 +374,16 @@ export class LiveGridSession {
367
374
  // done in one go it froze a template cell 1.0–1.6 s every ~6.2 s on the phone.
368
375
  if (++saveTicks >= 300) { saveTicks = 0; this.captureAutosave(); }
369
376
  });
370
- page.onInput(() => { traveller.camera.position.sub(this.applied); this.applied.set(0, 0, 0); });
377
+ page.onInput(() => { traveller.camera.position.sub(this.applied); this.applied.set(0, 0, 0); pinFrameOffset.set(0, 0, 0); });
371
378
  scope.onDispose(() => { this.autosave?.return(false); this.autosave = null; });
372
379
  page.onUpdate(() => { // the page has one update slot (game.grid.origin): the camera offset, then one autosave stage
373
- if (this.offset.lengthSq() !== 0) { traveller.camera.position.add(this.offset); this.applied.copy(this.offset); }
380
+ // the HUD's world pins stand in the same frame: their points move with the camera (hudAdapters.ts pinFrameOffset)
381
+ if (this.offset.lengthSq() !== 0) { traveller.camera.position.add(this.offset); this.applied.copy(this.offset); pinFrameOffset.copy(this.offset); }
374
382
  // The capture's own frame encodes nothing more: the next stage waits for the next frame's update.
375
383
  if (scope.disposed) return;
376
384
  if (this.autosaveCaptured) this.autosaveCaptured = false; else this.stepAutosave();
377
385
  });
378
- scope.onDispose(() => { traveller.camera.position.sub(this.applied); this.applied.set(0, 0, 0); });
386
+ scope.onDispose(() => { traveller.camera.position.sub(this.applied); this.applied.set(0, 0, 0); pinFrameOffset.set(0, 0, 0); });
379
387
  scope.listen(window, 'pagehide', () => { this.checkpoint(); });
380
388
  scope.listen(document, 'visibilitychange', () => { if (document.visibilityState === 'hidden') this.checkpoint(); });
381
389
  scope.onDispose(() => { this.checkpoint(); });
@@ -696,7 +704,9 @@ export class LiveGridSession {
696
704
  transfer.sync(); this.transferWalls.set(cell.instance, transfer);
697
705
  this.regions.set(cell.instance, { spawn: { x: start.at.x, y: undefined, z: start.at.z, yaw: start.yaw },
698
706
  // the admitted terrain inside the cell (one source of truth); its strips are road level (the terrain tile ends at the cell edge)
699
- queries: { heightAt: (x, z) => (Math.max(Math.abs(x), Math.abs(z)) <= CHUNK_HALF ? heightAt(x, z) : 0), waterSurfaceAt: (x, z) => water.restAt(x, z), platforms: [] }, colliders, items: copySource.items.rows, prompts: copyPrompts(copySource) });
707
+ queries: { heightAt: (x, z) => (Math.max(Math.abs(x), Math.abs(z)) <= CHUNK_HALF ? heightAt(x, z) : 0), waterSurfaceAt: (x, z) => water.restAt(x, z), platforms: [] }, colliders, items: copySource.items.rows, prompts: copyPrompts(copySource),
708
+ // AU20: the cell's declared audio scene, bound only while the feet stand in it (no entered hooks run here)
709
+ audio: source.runtime === null && source.audio.scene !== undefined ? plotAudioScene(source, ((plot) => plot.has('client/plan') ? plot.section('client/plan') : undefined)(shardProductFromAdmission(retained.admitted, shell.scope))) : null });
700
710
  this.respawnCells.set(cell.instance, { instance: cell.instance, origin: cell.origin, entryways: source.entryways });
701
711
  // G321: its own sky inside its cell (its data look's dome and light), laid while it is resident
702
712
  {
@@ -705,7 +715,7 @@ export class LiveGridSession {
705
715
  try { await hangCellDataSky(request); } catch (error) { console.warn(`[region sky] ${cell.instance}`, error); }
706
716
  })();
707
717
  }
708
- const unlist = (): void => { this.regions.delete(cell.instance); this.transferWalls.delete(cell.instance); };
718
+ const unlist = (): void => { if (this.plotAudio?.instance === cell.instance) this.leavePlotAudio(); this.plotBanks.delete(cell.instance); this.regions.delete(cell.instance); this.transferWalls.delete(cell.instance); };
709
719
  return { host: shell, shell, dispose: () => {
710
720
  unlist();
711
721
  try { shell.dispose(); } finally { retained.release(); }
@@ -813,6 +823,29 @@ export class LiveGridSession {
813
823
  } };
814
824
  }
815
825
 
826
+ /** AU20: the feet entered a data cell; bind its declared audio scene to the page's mixer until they leave. */
827
+ private enterPlotAudio(instance: string): void {
828
+ this.leavePlotAudio();
829
+ const scene = this.regions.get(instance)?.audio ?? null, page = this.page.runtimePage?.() ?? null;
830
+ if (scene === null || page === null) return;
831
+ const own = pagePlotAudioPorts(page.context.app, page.world.player, instance);
832
+ if (own === null) return;
833
+ // one bank read per resident cell: dropped with the region (unlist), so a re-entry lends the bank it already decoded
834
+ const ports: PlotAudioPorts = { ...own, bank: (data) => {
835
+ let read = this.plotBanks.get(instance);
836
+ if (read === undefined) { read = own.bank(data); this.plotBanks.set(instance, read); void read.catch(() => { if (this.plotBanks.get(instance) === read) this.plotBanks.delete(instance); }); }
837
+ return read;
838
+ } };
839
+ const owner = this.ports.scope.child(`grid.plot-audio.${instance}`);
840
+ this.plotAudio = { instance, scope: owner };
841
+ try { enterPlotAudio(scene, owner, ports); }
842
+ catch (error) { this.leavePlotAudio(); ports.fault(error); }
843
+ }
844
+ private leavePlotAudio(): void {
845
+ const entered = this.plotAudio; this.plotAudio = null;
846
+ entered?.scope.dispose();
847
+ }
848
+
816
849
  /** Live scalar warm-up progress for this destination, never the last trace of a different region. */
817
850
  warmPreparation(instance: string): NonNullable<PreparedRegionalRuntime['warmPreparation']> | null {
818
851
  return this.runtimeRegions.get(instance)?.warmPreparation ?? null;
@@ -58,3 +58,11 @@ export function planNearPlaceholders(cells: readonly GridCell[], pitch: number,
58
58
  export function placeholderBlocksTiles(instance:string,entered:string|null,registered:boolean,ownsNear:boolean,absentNear:boolean):boolean {
59
59
  return instance!==entered&&!registered&&(ownsNear||absentNear);
60
60
  }
61
+
62
+ /** DL17 (G872) with D189: the cell the player is in, drawn by its regional runtime, skips its tile-view admission only when
63
+ * that runtime draws its own ground, through the tile registration (`registered`) or its manifest's `cellGround: 'world'`.
64
+ * A runtime whose ground is the cell's ring tiles (Pine) admits them like any neighbour: skipped, its far proxy stayed over
65
+ * the spawn and its ground never drew. */
66
+ export function admitsCellTiles(instance:string,drawn:string|null,registered:boolean,ownGround:boolean):boolean {
67
+ return instance!==drawn||(!registered&&!ownGround);
68
+ }
@@ -73,6 +73,11 @@ export class NearPlaceholders {
73
73
  ...(this.host.limit === undefined ? {} : { limit: this.host.limit }) });
74
74
  this.eye = { x: Math.round(eye.x * 10) / 10, z: Math.round(eye.z * 10) / 10 };
75
75
  const wanted = new Map(plan.cells.map(c => [c.instance, c.distance]));
76
+ // QA 2026-11-13 (Jake, Driftwood from the road): a cell turns live a few metres before its runtime draws it (the entry
77
+ // waits at its wall). An owning near view already drawn stays until the runtime covers the cell (its root hides);
78
+ // dropped at once, its far proxy and props-only tiles drew the props over holes. Never started for the entered cell.
79
+ const held = entered === null ? undefined : this.slots.get(entered);
80
+ if (entered !== null && held?.ready === true && held.owns && this.host.root(entered)?.visible === true) wanted.set(entered, plan.cells.find(c => c.instance === entered)?.distance ?? 0);
76
81
  this.distances.clear();
77
82
  for (const [instance, distance] of wanted) this.distances.set(instance, Math.round(distance));
78
83
  for (const [instance, slot] of this.slots) if (!wanted.has(instance)) this.drop(slot);
@@ -86,9 +91,10 @@ export class NearPlaceholders {
86
91
 
87
92
  /** Mirror the rings' refinement onto a cell's near view (the regions its L1 / L0 tiles now draw). */
88
93
  remask(instance: string): void {
89
- const view = this.slots.get(instance)?.view;
94
+ const slot = this.slots.get(instance), view = slot?.view;
90
95
  if (view !== null && view !== undefined) {
91
- view.mask(this.host.mask(instance));
96
+ // an owning near view draws the whole cell: tiles refined beside it (the entry's arrival ring) never cut holes in it
97
+ view.mask(slot?.owns === true ? new Set<number>() : this.host.mask(instance));
92
98
  if (this.slots.get(instance)?.ready !== true) view.mesh.visible = false;
93
99
  }
94
100
  }
@@ -165,7 +171,7 @@ export class NearPlaceholders {
165
171
  }
166
172
  if (!current()) return;
167
173
  slot.ready = true;
168
- view.mask(this.host.mask(instance));
174
+ view.mask(owns ? new Set<number>() : this.host.mask(instance));
169
175
  this.host.cover(instance, true);
170
176
  };
171
177
  void run();
@@ -1,16 +1,17 @@
1
1
  // GO7 (meta MMO-PLAN MP1G, DG4; MMO-ZONE-SELECT ZS4's goto and ZS5's retirement): one way in. On a build with a world (GO4's gate),
2
2
  // Shard select → a grid shard enters the grid at that shard's cell, so Shard select only changes the spawn cell of the one online
3
3
  // world, and no online page boots a bordered `'shard'` page for a grid shard. J300 (GRID-CROSSING GC20): that holds when the world's
4
- // word is missing, late or never kept; only a world known to host one cell (production before GC16) keeps GO4's one-shard page. A
5
- // shard the grid doesn't place (OFFLINE OF3's) keeps today's one-shard page. J311: a build with no world (preview) does the same with
4
+ // word is missing, late or never kept; only a world known to host one cell (production before GC16) keeps GO4's one-shard page. On a
5
+ // world build, a shard the world doesn't open (the grid doesn't place it, or its kept word leaves it out) is never entered (OFFLINE OF3). J311: a build with no world (preview) does the same with
6
6
  // its in-page server, which hosts the whole grid: a Shard select tap enters the solo grid at the shard's cell (`entry.ts` asks only
7
7
  // for a tap, so a bare `?chunk=` link, a harness or an author's embedded product still opens the shard alone).
8
8
  import { pageScope } from '@wildshard/engine/app/resources';
9
- import { jsonSlot } from '@wildshard/engine/saves/slots';
9
+ import { jsonSlot, type Json } from '@wildshard/engine/saves/slots';
10
10
  import { GridAssembly, type GridCell } from '../../../shared/game/grid/assembly';
11
11
  import { hostsGrid } from '../shardfile/serverRoute';
12
12
  import { pageGridIntents } from './intent';
13
13
  import { DEVSERVER, gridMode } from './menu';
14
+ import { GAME_STRINGS } from '../../../shared/game/strings';
14
15
 
15
16
  /** The grid cell a shard's page enters: the first in catalogue order that runs this shard, or undefined for a shard the grid doesn't place. */
16
17
  export function shardCell(slug: string, assembly: GridAssembly = new GridAssembly(gridMode(DEVSERVER))): GridCell | undefined {
@@ -29,6 +30,22 @@ export interface OneWayIn {
29
30
  readonly kept: boolean;
30
31
  }
31
32
 
33
+ /** OFFLINE OF3: the shards a world's word names (`shards`, opus-route2), or null when it names none (an older door, nonsense). */
34
+ export function wordShards(word: unknown): readonly string[] | null {
35
+ const shards = typeof word === 'object' && word !== null && 'shards' in word ? word.shards : null;
36
+ return Array.isArray(shards) && shards.every(shard => typeof shard === 'string') ? shards : null;
37
+ }
38
+
39
+ /** OFFLINE OF3 (J298): whether a world build may enter `slug`. The catalogue must place it (the world opens only grid cells, so a shard
40
+ * with no cell would be seated in another one), and a word that names shards (`shards`, heard now or kept) must name it. No word
41
+ * and nothing kept leaves the catalogue's answer (J300). This replaces ba88ac9a's "unplaced plays solo". */
42
+ export function inThisWorld(slug: string, shards: readonly string[] | null, assembly?: GridAssembly): boolean {
43
+ return shardCell(slug, assembly) !== undefined && (shards === null || shards.includes(slug));
44
+ }
45
+
46
+ /** OF3: the title's line after a `?chunk=` link to a shard this world doesn't open (here, so the entry's static graph stays small). */
47
+ export function notInWorldLine(name: string): string { return GAME_STRINGS.notInWorld.line(name); }
48
+
32
49
  /** The cell a one-shard page enters instead, or null when it stays a one-shard page. */
33
50
  export function oneWayIn(page: OneWayIn, assembly?: GridAssembly): GridCell | null {
34
51
  if ((page.online && !page.hosted) || page.kept) return null;
@@ -36,7 +53,26 @@ export function oneWayIn(page: OneWayIn, assembly?: GridAssembly): GridCell | nu
36
53
  }
37
54
 
38
55
  /** The online module's gate, as `clientWorker.ts` reads it; a page with no world never asks. */
39
- interface OnlineGate { readonly worldWord: (world: { readonly release: string; readonly key: string }, waitMs?: number) => Promise<unknown> }
56
+ export interface OnlineGate { readonly worldWord: (world: { readonly release: string; readonly key: string }, waitMs?: number, keep?: WordKeep) => Promise<unknown> }
57
+ /** opus-wordkeep: the word the door said, which release and when (`online.js`'s `KeptWord`). */
58
+ interface KeptWord { readonly of: string; readonly at: number; readonly word: unknown }
59
+ interface WordKeep { readonly read: () => KeptWord | null; readonly write: (kept: KeptWord) => void }
60
+ /** opus-wordkeep: the tab's kept word, in the page's own session saves. `online.js` keeps the word a minute (so the title, a `?chunk=`
61
+ * page and the grid page share one socket), but its own store has no storage (OF4's finding for `release.kept`), so the page lends
62
+ * this one. The release is under `of`, not `release`: an older build in the same tab kept only a yes there. */
63
+ export function tabWordKeep(): WordKeep {
64
+ const slot = (): ReturnType<typeof jsonSlot> => jsonSlot('gridGate', 'session');
65
+ return {
66
+ read: () => {
67
+ const kept = slot().read();
68
+ if (typeof kept !== 'object' || kept === null || Array.isArray(kept)) return null;
69
+ const { of, at, word } = kept;
70
+ return typeof of === 'string' && typeof at === 'number' && word !== undefined ? { of, at, word } : null;
71
+ },
72
+ // a word is parsed JSON, so it keeps as it came
73
+ write: kept => { slot().write({ of: kept.of, at: kept.at, word: kept.word as Json }); },
74
+ };
75
+ }
40
76
 
41
77
  /** QA 11-12 row 36 (Jake on bad LTE: Driftwood sat 34 s on "Read audio 7 / 91"): the last answer this device got from its world, grid
42
78
  * or one-shard, kept across sessions. A check that misses its deadline uses it, so a cached player stays on the route they downloaded
@@ -44,25 +80,46 @@ interface OnlineGate { readonly worldWord: (world: { readonly release: string; r
44
80
  export interface RouteMemory {
45
81
  /** the kept answer for this world's release (true: it hosts the grid), or null when this device never heard one */
46
82
  readonly read: (release: string) => boolean | null;
47
- readonly write: (release: string, grid: boolean) => void;
83
+ /** OF3: the shards the kept word named, or null when it named none or nothing is kept */
84
+ readonly shards: (release: string) => readonly string[] | null;
85
+ readonly write: (release: string, grid: boolean, shards?: readonly string[] | null) => void;
48
86
  }
49
87
  /** The device's slot (`localStorage`), keyed by the world's release; the build that heard the answer rides along for diagnostics. */
50
88
  export function deviceRouteMemory(): RouteMemory {
51
89
  const slot = (): ReturnType<typeof jsonSlot> => jsonSlot('gridRoute', 'device');
90
+ const kept = (release: string): Readonly<Record<string, unknown>> | null => {
91
+ try {
92
+ const row = slot().read();
93
+ return typeof row === 'object' && row !== null && !Array.isArray(row) && row['of'] === release ? row : null;
94
+ } catch { return null; }
95
+ };
52
96
  return {
53
- read: release => {
54
- try {
55
- const kept = slot().read();
56
- return typeof kept === 'object' && kept !== null && !Array.isArray(kept) && kept['of'] === release && typeof kept['grid'] === 'boolean' ? kept['grid'] : null;
57
- } catch { return null; }
58
- },
59
- write: (release, grid) => {
97
+ read: release => { const grid = kept(release)?.['grid']; return typeof grid === 'boolean' ? grid : null; },
98
+ shards: release => wordShards(kept(release)),
99
+ write: (release, grid, shards = null) => {
60
100
  const build = (globalThis as { __WS_BUILD_ID__?: string }).__WS_BUILD_ID__ ?? '';
61
- try { slot().write({ of: release, grid, build, at: Date.now() }); } catch { /* a device that keeps nothing falls back to today's page */ }
101
+ try { slot().write({ of: release, grid, ...(shards === null ? {} : { shards: [...shards] }), build, at: Date.now() }); } catch { /* a device that keeps nothing falls back to today's page */ }
62
102
  },
63
103
  };
64
104
  }
65
105
 
106
+ const releaseOf = (world: unknown): string | null =>
107
+ typeof world === 'object' && world !== null && 'release' in world && typeof world.release === 'string' ? world.release : null;
108
+ /** OF3: which shards a build may enter, by the world's kept word (`memory`) and the catalogue. A build with no world (preview,
109
+ * sharddev) opens every card: its in-page server hosts any shard. A word that arrives after the page's deadline is kept for the next
110
+ * launch only: until then the page enters as J300 says (no word takes the grid). */
111
+ export function worldOpens(world: unknown, memory: RouteMemory = deviceRouteMemory()): (slug: string) => boolean {
112
+ if (world === undefined) return () => true;
113
+ const release = releaseOf(world), shards = release === null ? null : memory.shards(release);
114
+ let assembly: GridAssembly | undefined; // one catalogue read for a whole deck of cards
115
+ return slug => { assembly ??= new GridAssembly(gridMode(DEVSERVER)); return inThisWorld(slug, shards, assembly); };
116
+ }
117
+ /** OF3: a page leaving for the title because its shard isn't in this world drops any grid entry it held (a tap's, or the one way in's). */
118
+ export function dropGridEntry(slug: string): void { pageGridIntents().consume(slug); }
119
+
120
+ /** What a world's word says, as this page reads it: whether it hosts the grid, and the shards it opens (OF3). */
121
+ export interface WorldHeard { readonly grid: boolean; readonly shards: readonly string[] | null }
122
+
66
123
  /** One deadline over the whole read, the online module's import included (GO4's 3 s). */
67
124
  const HOSTED_MS = 3000;
68
125
  /** How long the read may go on after the deadline, so a late answer is still kept for the next launch. */
@@ -72,29 +129,34 @@ const KEEP_LATE_MS = 10_000;
72
129
  * a grid shard to a one-shard page for want of a word, so only a world known to open one cell does. A build with no world answers
73
130
  * false. Whether the page then reaches the world is the online shell's business: it never waits here. */
74
131
  export async function worldHosted(world: unknown, waitMs: number = HOSTED_MS, memory: RouteMemory = deviceRouteMemory(),
75
- read: (world: unknown, waitMs: number) => Promise<boolean | null> = readHosted): Promise<boolean> {
76
- const release = typeof world === 'object' && world !== null && 'release' in world && typeof world.release === 'string' ? world.release : null;
132
+ read: (world: unknown, waitMs: number) => Promise<WorldHeard | boolean | null> = readHosted): Promise<boolean> {
133
+ const release = releaseOf(world);
77
134
  if (release === null) return false;
78
135
  const scope = pageScope.child('grid.hosted'), late = new Promise<null>(resolve => { scope.timeout(waitMs, () => { resolve(null); }); });
79
136
  // The read itself may run past the page's deadline (`KEEP_LATE_MS`): a link that always answers late still fills the memory
80
137
  // for the next launch, though this page has already gone on without it.
81
- const reading = read(world, Math.max(waitMs, KEEP_LATE_MS)).catch(() => null);
82
- void reading.then(word => { if (word !== null) memory.write(release, word); return undefined; });
83
- let heard: boolean | null;
138
+ // A bare yes or no (a test's reader) names no shards.
139
+ const reading = read(world, Math.max(waitMs, KEEP_LATE_MS))
140
+ .then((word): WorldHeard | null => word === null ? null : typeof word === 'boolean' ? { grid: word, shards: null } : word, () => null);
141
+ void reading.then(word => { if (word !== null) memory.write(release, word.grid, word.shards); return undefined; });
142
+ let heard: WorldHeard | null;
84
143
  try { heard = await Promise.race([reading, late]); } finally { scope.dispose(); }
85
- if (heard !== null) return heard;
144
+ if (heard !== null) return heard.grid;
86
145
  return memory.read(release) ?? true;
87
146
  }
88
- /** The door's word read as grid or not, or null when no word came (unreachable, stalled, closed before its word). */
89
- async function readHosted(world: unknown, waitMs: number): Promise<boolean | null> {
147
+ /** This build's `online.js`, a bundle of its own. */
148
+ async function onlineGate(): Promise<OnlineGate> {
149
+ const build = (globalThis as { __WS_BUILD_ID__?: string }).__WS_BUILD_ID__ ?? '';
150
+ return await import(/* @vite-ignore */ `/b/${build}/standalone/online.js`) as OnlineGate;
151
+ }
152
+ /** The door's word read as grid or not and the shards it opens, or null when no word came (unreachable, stalled, closed before its word). */
153
+ export async function readHosted(world: unknown, waitMs: number, gate: () => Promise<OnlineGate> = onlineGate): Promise<WorldHeard | null> {
90
154
  if (typeof world !== 'object' || world === null || !('release' in world) || !('key' in world)) return null;
91
155
  const { release, key } = world;
92
156
  if (typeof release !== 'string' || typeof key !== 'string') return null;
93
157
  try {
94
- const build = (globalThis as { __WS_BUILD_ID__?: string }).__WS_BUILD_ID__ ?? '';
95
- const gate = await import(/* @vite-ignore */ `/b/${build}/standalone/online.js`) as OnlineGate;
96
- const word = await gate.worldWord({ release, key }, waitMs);
97
- return word === null ? null : hostsGrid(word);
158
+ const word = await (await gate()).worldWord({ release, key }, waitMs, tabWordKeep());
159
+ return word === null ? null : { grid: hostsGrid(word), shards: wordShards(word) };
98
160
  } catch { return null; }
99
161
  }
100
162
 
@@ -103,12 +165,15 @@ async function readHosted(world: unknown, waitMs: number): Promise<boolean | nul
103
165
  * goto intent turns this same page into a grid page (`bootPageMode` consumes it), so Shard select loads once. Returns the cell's
104
166
  * instance, or null when the page stays a one-shard page.
105
167
  */
106
- export async function enterByShard(page: Omit<OneWayIn, 'hosted'>, world: unknown, hosted: (world: unknown) => Promise<boolean> = worldHosted): Promise<string | null> {
168
+ export async function enterByShard(page: Omit<OneWayIn, 'hosted'>, world: unknown, hosted: (world: unknown) => Promise<boolean> = worldHosted,
169
+ opens: (slug: string) => boolean = slug => worldOpens(world)(slug)): Promise<string | null> {
107
170
  // Only a page that could turn asks the world: a kept page and a shard off the grid never wait on a read, and a solo build has no
108
171
  // world to ask (its in-page server hosts the grid, J311).
109
172
  if (oneWayIn({ ...page, hosted: true }) === null) return null;
110
173
  const cell = oneWayIn({ ...page, hosted: !page.online || await hosted(world) });
111
- if (cell === null) return null;
174
+ // OF3: a world whose word (heard just now, or kept) leaves this shard out never seats it there: no grid entry, and the page's entry
175
+ // (`entry.ts`) lands on the title with "Not in this world yet"
176
+ if (cell === null || (page.online && !opens(page.slug))) return null;
112
177
  pageGridIntents().admit({ instance: cell.instance, slug: cell.slug, goto: true });
113
178
  return cell.instance;
114
179
  }
@@ -94,6 +94,18 @@ export function reenterGrid(instance: string): void {
94
94
  travel({ to: target.slug, mode: 'enter', shown: gridDestination({ slug: target.slug }, target) });
95
95
  }
96
96
 
97
+ /** OFFLINE OF2 (J298): a grid page on a build whose world is known to host one cell (production before GC16) re-enters as that cell's
98
+ * one-shard page, online, never the solo grid. The page that boots is a `?chunk=` page with no grid intent; Shard select's one way in
99
+ * keeps it a one-shard page, since the same word (kept a minute, and in the device's route memory) says the world opens one cell. */
100
+ export function reenterShard(instance: string): void {
101
+ const cell = new GridAssembly(gridMode(DEVSERVER)).cells.find(row => row.instance === instance), target = cell === undefined ? undefined : findTitleManifest(cell.slug);
102
+ if (cell === undefined || target === undefined) {
103
+ recordDrop({ reason: `The world hosts one place, and this build can't open ${cell?.slug ?? instance} on its own, so the game went back to the title.`, code: instance });
104
+ location.replace(new URL(location.pathname, location.origin)); return;
105
+ }
106
+ travel({ to: target.slug, mode: 'enter', shown: gridDestination({ slug: target.slug }, target) });
107
+ }
108
+
97
109
  /** GO5: set once the world's door has placed this device in the grid, so its hint is the server's; a solo grid's hint boots home, as before. */
98
110
  export const SERVER_PLACED: SaveKeyDef<boolean> = { key: 'grid.server-placed', scope: 'device', version: 1, schema: v.boolean(), initial: () => false };
99
111
 
@@ -137,6 +149,13 @@ export function bootPageMode(slug: string): PageMode {
137
149
  if (recovery !== null && [slug].includes(recovery.slug)) intent = { instance: recovery.instance, slug: recovery.slug, at: recovery.at };
138
150
  const mode: PageMode = intent === null ? 'shard' : 'grid';
139
151
  setPageMode(mode);
152
+ // OFFLINE OF5: the title's read-ahead (S2) takes the route this pick booted. A deck tap remembers the one-shard flow before the
153
+ // page knows its route; a world that hosts the grid turns it into a grid entry, and a read-ahead of the one-shard manifest is a
154
+ // file this device never keeps (offline, it fails). Only the last pick's own page corrects it.
155
+ try {
156
+ const choice = titlePrefetchChoice(saves);
157
+ if ([slug].includes(choice.read() ?? '')) choice.remember(slug, mode === 'grid' ? 'grid' : 'client');
158
+ } catch { /* the read-ahead hint is optional: blocked storage keeps the page's flow */ }
140
159
  // GO7: a goto, or a recovery reload (the cell this page stood in, the goto's cell if it reloaded before the door placed it), asks the
141
160
  // world for that cell; a title tap's PLAY takes the seat the world keeps (GO5).
142
161
  const chosen = intent !== null && recovery === null && 'goto' in intent && intent.goto;
@@ -46,7 +46,7 @@ export function gridPageShell(source: ShardManifest): ShardManifest {
46
46
 
47
47
  /** The neutral page cannot read a home terrain/navmesh bake merely because it keeps the picker's identity. */
48
48
  export function gridPageShellLevel(shell: ShardManifest): LevelSpec {
49
- return { ...toLevelSpec(shell), id: 'platform.grid', boundary: { visible: false, walls: false } };
49
+ return { ...toLevelSpec(shell), id: 'platform.grid', boundary: { visible: false } };
50
50
  }
51
51
 
52
52
  /** Select the neutral engine level before its staged boot; catalogue identity and each resident's frame stay separate. */