@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
@@ -5,7 +5,7 @@ import { sustainedFrames } from '@wildshard/engine/core/sustainedFrames';
5
5
  import { Rng } from '@wildshard/engine/core/rng';
6
6
  import { gridCells } from '../plugin/context';
7
7
  import { initialHomeMetadataRequired } from '../grid/homeMetadata';
8
- import { reenterGrid, showGridDestination } from '../grid/pageEntry';
8
+ import { reenterGrid, reenterShard, showGridDestination } from '../grid/pageEntry';
9
9
  import type { playStage } from './play';
10
10
  import type { WorkerClientGrid } from '../shardfile/clientWorker';
11
11
  import { asShell } from '@wildshard/engine/app/ownership';
@@ -14,6 +14,7 @@ import { releaseByteCounter } from '@wildshard/engine/boot/bytes';
14
14
  import { hasLateAudio, startAudioPreload, startLateAudio, type AudioBanks } from '@wildshard/engine/boot/extras';
15
15
  import { macrotask } from '@wildshard/engine/boot/plan';
16
16
  import { loadingStage, loadingUnits, waitFor } from '@wildshard/engine/boot/waits';
17
+ import { beginLoadingWait, finishLoadingWait } from '@wildshard/engine/boot/loadingWaits';
17
18
  import { currentLoadingTimeline } from '@wildshard/engine/boot/timeline';
18
19
  import { startShardPrefetch } from '@wildshard/engine/boot/shardPrefetch';
19
20
  import { afterControl, reachControl } from '@wildshard/engine/boot/prefetch';
@@ -45,7 +46,7 @@ function workerGrid({ grid, gridLive }: Pick<Awaited<ReturnType<typeof playStage
45
46
  return grid === null || gridLive === null ? null : { cells: grid.assembly.cells, bindWire: wire => { gridLive.bindWire(wire); }, frame: () => gridLive.frame(), animals: () => gridLive.enteredAnimals(), items: () => gridLive.enteredItems(), saveLocation: () => { gridLive.saveLocation(); },
46
47
  // GO5: the server's place is the save; the hint and the loading card follow it.
47
48
  serverPlace: (instance, at) => { gridLive.serverPlace(instance, at); const cell = grid.assembly.cells.find(row => row.instance === instance); if (cell !== undefined) showGridDestination(cell.slug); },
48
- reenter: instance => { reenterGrid(instance); }, booted: gridLive.booted };
49
+ reenter: instance => { reenterGrid(instance); }, reshard: instance => { reenterShard(instance); }, booted: gridLive.booted };
49
50
  }
50
51
 
51
52
  /** how often the in-play warm-up asks whether an arrival's Explorer has closed, and how long it waits for one to open */
@@ -58,6 +59,17 @@ const BOOT_SHADER_SLICE_MS = 48;
58
59
  * frame starts with narrow slices (Game FIRST_DRAW_NARROW). Measured on Driftwood at 4x CPU, 2026-11-09: SwiftShader 34 ms,
59
60
  * this Mac's Metal GPU 7 ms, WebKit 2.4 ms a program. */
60
61
  const SLOW_SHADER_MS_PER_PROGRAM = 15;
62
+ /** PINE-FLASH: the spawn ground hold, named on the loading card while it waits; its outcome and time go in a boot mark. */
63
+ async function holdSpawnGround(grid: Awaited<ReturnType<typeof playStage>>['grid']): Promise<void> {
64
+ if (grid === null) return;
65
+ const timeline = currentLoadingTimeline(), at = diagnosticNow();
66
+ const wait = beginLoadingWait('Spawn ground', { kind: 'work', step: timeline?.snapshot().current ?? null, owner: timeline?.waitOwner ?? null });
67
+ // best-effort: a hold that throws leaves the ground to the rings in play, as before it, and never fails the load
68
+ try { const outcome = await grid.prepareSpawnGround(); bootMark('app:spawn-ground', { outcome, ms: Math.round(diagnosticNow() - at) }); }
69
+ catch (error: unknown) { console.warn('[grid] spawn ground hold stopped', error); bootMark('app:spawn-ground', { outcome: 'failed', ms: Math.round(diagnosticNow() - at) }); }
70
+ finally { finishLoadingWait(wait); }
71
+ }
72
+
61
73
  /** QA8: link the world's programs the spawn view did not draw before the reveal, nearest first, at the in-play pace (a few
62
74
  * programs a frame, each link polled). Only completion or owner retirement ends this loading step. */
63
75
  async function linkWorldUnderLoader(game: Awaited<ReturnType<typeof playStage>>['game'], unbuilt = false): Promise<void> {
@@ -137,7 +149,9 @@ export async function finishStage(ctx: Awaited<ReturnType<typeof playStage>>): P
137
149
  // so the shaders below link the fine pieces and the reveal shows them; only what lies outside it refines in play
138
150
  // The camera is posed by the shader step below. Keep the player reference
139
151
  // for this first fence; the final readyFrame fence uses the posed camera.
140
- await loadingStage('spawnDetail', () => prepareSpawnView(undefined, undefined, 'player'));
152
+ // PINE-FLASH (grid/spawnGround.ts): first the entered cell's own ground where its ring tiles are that ground (Pine), so
153
+ // control never arrives over its far proxy; bounded, and nothing for a cell that draws its own ground (Nalati)
154
+ await loadingStage('spawnDetail', async () => { await holdSpawnGround(ctx.grid); await prepareSpawnView(undefined, undefined, 'player'); });
141
155
  try {
142
156
  // LS8 (J204): the shaders step's measured cost per program decides how the first frame slices its draws
143
157
  const shadersAt = diagnosticNow(), programsBefore = game.renderer.info.programs?.length ?? 0;
@@ -106,7 +106,7 @@ import { HAPTIC, buzz } from '@wildshard/engine/ui/haptics';
106
106
  import { hudSlots } from '@wildshard/engine/ui/hudSlots';
107
107
  import { installPlayerDeath } from '@wildshard/engine/ui/playerDeath';
108
108
  import { installUnstuck } from '@wildshard/engine/ui/unstuck';
109
- import { UNSTUCK_ACT } from '@wildshard/engine/net/acts';
109
+ import { RESPAWN_NOW_ACT, UNSTUCK_ACT } from '@wildshard/engine/net/acts';
110
110
  import { PlayerHurt } from '@wildshard/engine/ui/playerHurt';
111
111
  import { onReview, queuedCount, quickNote } from '@wildshard/engine/ui/review';
112
112
  import { installBounds, playBounds } from '@wildshard/engine/world/bounds';
@@ -446,7 +446,8 @@ async function buildPlay(ctx: Awaited<ReturnType<typeof loadoutStage>>) : Promis
446
446
  // ── death (E295): a fade to dark with a "Mauled by a brown bear / respawning at Wreck Cove" card (src/client/engine/ui/DeathFade.ts),
447
447
  // the respawn under the dark at the last named place you reached (src/game/LastPlace.ts; Driftwood's places, the spawn
448
448
  // when none), input frozen and no hit taken until the view is back. A boss fight's death keeps its own checkpoint. ──
449
- const deathFade = new DeathFade();
449
+ // QA 11-13 (Jake: "It needs a button, a Respawn now button"): its words live here, in the session, not in the engine table the title carries
450
+ const deathFade = new DeathFade({ now: 'Respawn now', waiting: 'Respawning…' });
450
451
  const placePts = boot.runtime.hooks.places;
451
452
  const lastPlace = placePts !== undefined ? new LastPlace(placePts) : null;
452
453
  if (lastPlace !== null) {
@@ -481,6 +482,11 @@ async function buildPlay(ctx: Awaited<ReturnType<typeof loadoutStage>>) : Promis
481
482
  else if (stand !== null) player.spawn(stand.x, stand.z, stand.yaw, stand.y); else toSpawn();
482
483
  }, // a server owns its return; a local player uses the last place (the pier is the spawn)
483
484
  done: () => { player.carried = false; weapons.setEnabled(!player.swimming); },
485
+ // Respawn now (QA 11-13) and the timer wait for the respawn point: a server has placed the player already (its reconcile
486
+ // carries the move: SERVER-PARITY); a local last place waits for its ground in the page's physics (DeathFade's READY_WAIT caps it)
487
+ ready: () => serverRespawn !== null || stand === null || app.physics === null || floorBelow(app.physics, stand.x, stand.z, stand.y + 0.6, 1.2) !== undefined,
488
+ // a server's world holds the fallen player's commands for its own fade: Respawn now asks it to end it (roomRespawn.ts)
489
+ skipped: () => { if (player.link !== null) weapons.interact(RESPAWN_NOW_ACT); },
484
490
  });
485
491
  };
486
492
  playerHealth.bindLifecycle({ fading: () => deathFade.active, updateFade: (dt) => deathFade.update(dt) });
@@ -1,4 +1,5 @@
1
1
  import { bagMenu } from '../bag/tabs';
2
+ import { guardPlayBack } from '@wildshard/engine/ui/backGuard';
2
3
  import { wirePage } from '../shardfile/wirePage';
3
4
  import * as THREE from 'three';
4
5
  import { type LevelSequence, bootLevel } from '@wildshard/engine/boot';
@@ -103,7 +104,8 @@ export async function startSession(manifest: ShardManifest, kit: KitPorts, optio
103
104
  build: __BUILD_ID__, dispose: () => {
104
105
  if (app.render !== null) app.render.hold = true;
105
106
  scope.dispose();
106
- }, report: reportError,
107
+ // SENTRY-TRIAGE S13: a failure whose page the player sees says so (`screen:load-failure`); a recovery's stays a plain report
108
+ }, report: (failure) => reportError(options.recovery === undefined ? { ...failure, tags: { ...failure.tags, screen: 'load-failure' } } : failure),
107
109
  show: (failure) => { if (options.recovery !== undefined) return; session.fatalShown = true; showLoadFailure(failure); },
108
110
  });
109
111
  let memoryAt = -Infinity, memoryMB = 0;
@@ -114,6 +116,7 @@ export async function startSession(manifest: ShardManifest, kit: KitPorts, optio
114
116
  };
115
117
  app.levelAdapters.residentMemory = memory;
116
118
  markDropStep({ step: PLAYING });
119
+ guardPlayBack(); // QA 11-13 row 20: iOS's edge swipe (any back) stays in play
117
120
  setAliveSource((): AliveInfo<PageMode> => ({ slug: selected, resident: `${selected} (playing) ~${Math.round(memory(60_000).levels[0]?.textureMB ?? 0)} MB`, mode }));
118
121
  } catch (error) {
119
122
  options.residency?.dispose(); // Pre-bootstrap failures have no consumers; runShardLoad disposes allocated ones first.
@@ -10,6 +10,7 @@ import { appIdentity } from '@wildshard/engine/app/identity';
10
10
  import { bootMark, bootTask } from '@wildshard/engine/boot/timing';
11
11
  import { importPageSaves, openIndexedSaves, serverSaveDatabase, serverStopsForImport, type IndexedSaves } from '@wildshard/engine/saves/indexed';
12
12
  import { saveEnvironment } from '@wildshard/engine/saves/environment';
13
+ import { jsonSlot } from '@wildshard/engine/saves/slots';
13
14
  import { syncPageRewards } from '../../../shared/game/saves';
14
15
  import type { SaveStorage } from '@wildshard/engine/saves/store';
15
16
  import { atMostLeaveWait, holdLeaving } from '@wildshard/engine/boot/lastEnd';
@@ -52,8 +53,8 @@ import type { EncounterRow } from '../boss/barFeed';
52
53
  import { wirePage, type DayFollower } from './wirePage';
53
54
  import { OWNED_ROW } from '../../../shared/game/loot/ownedRows';
54
55
  import { declaredKitSlots } from '../../../shared/game/shardfile/items';
55
- import { earlyStandalone, hostsGrid, opensShard, serverRoute } from './serverRoute';
56
- import { shardCell } from '../grid/oneWayIn';
56
+ import { earlyStandalone, serverRoute } from './serverRoute';
57
+ import { worldHosted } from '../grid/oneWayIn';
57
58
 
58
59
  type Creatures = Pick<RowBodiesView, 'animals' | 'spawn' | 'retire' | 'onWindup' | 'presentHit' | 'presentDeath' | 'presentReward'>;
59
60
  /** What a grid page lends: its crossing follows the server, and its creatures are the entered cell's. */
@@ -70,6 +71,8 @@ export interface WorkerClientGrid {
70
71
  readonly serverPlace?: (instance: string, at: { readonly x: number; readonly y: number; readonly z: number; readonly yaw: number }) => void;
71
72
  /** GO4: the seat is in another cell than this page booted: enter the grid again there (a grid entry, never a `?chunk=` page). */
72
73
  readonly reenter?: (instance: string) => void;
74
+ /** OF2: the world hosts one cell: enter this cell again as its one-shard online page, never the solo grid. */
75
+ readonly reshard?: (instance: string) => void;
73
76
  /** The cell (instance) this page booted in. */
74
77
  readonly booted?: string;
75
78
  }
@@ -108,8 +111,22 @@ export interface WorkerClientPorts {
108
111
  interface ShellModule { readonly startStandalone: (config: { slug: string; base: string; build: string; savePrefix: string; name?: string; lone?: true; held?: (url: string) => Promise<ArrayBuffer | null> } & IndexedSaves) => Shell }
109
112
  /** What `stampBuildDocuments` writes into a build that has a world: its signed release file and the key that signed it. */
110
113
  interface BuildWorld { readonly release: string; readonly key: string; readonly recordTag?: string }
114
+ /** OF4: the page's keep for the last verified release file, in its own device saves (online.js's store has no storage). */
115
+ interface ReleaseKeep { readonly read: () => { of: string; at: number; text: string } | null; readonly write: (kept: { of: string; at: number; text: string }) => void }
116
+ function releaseKeep(): ReleaseKeep {
117
+ const slot = jsonSlot('release.kept', 'device');
118
+ return {
119
+ read: () => {
120
+ const kept = slot.read();
121
+ if (typeof kept !== 'object' || kept === null || Array.isArray(kept)) return null;
122
+ const { of, at, text } = kept;
123
+ return typeof of === 'string' && typeof at === 'number' && typeof text === 'string' ? { of, at, text } : null;
124
+ },
125
+ write: kept => { slot.write({ of: kept.of, at: kept.at, text: kept.text }); },
126
+ };
127
+ }
111
128
  /** E7.2d: the page's seat in the one world, in a shell of the same shape. */
112
- interface OnlineModule { readonly worldHostsGrid: (world: BuildWorld, hosts: (world: unknown) => boolean) => Promise<boolean>; readonly worldWord: (world: BuildWorld) => Promise<unknown>; readonly startOnline: (config: BuildWorld & { loaded: string; build: string; identity: (name?: string) => NetIdentity; grid?: { readonly cell: string; readonly cells: readonly string[]; readonly placed: (cell: string, at: { readonly x: number; readonly y: number; readonly z: number; readonly yaw: number }) => void; readonly reenter: (cell: string) => void; readonly goto?: boolean } }) => Promise<Shell> }
129
+ interface OnlineModule { readonly startOnline: (config: BuildWorld & { keep: ReleaseKeep; loaded: string; build: string; identity: (name?: string) => NetIdentity; grid?: { readonly cell: string; readonly cells: readonly string[]; readonly placed: (cell: string, at: { readonly x: number; readonly y: number; readonly z: number; readonly yaw: number }) => void; readonly reenter: (cell: string) => void; readonly goto?: boolean } }) => Promise<Shell> }
113
130
  interface Shell { readonly redials?: true; pause: () => void; hold: (on: boolean) => void; bossGod: () => void; raise: (flag: string) => void; join: (id: string, x: number, y: number, z: number) => { readonly client: NetClient; readonly move: (x: number, y: number, z: number) => void }; readonly client: NetClient; readonly booted: Promise<{ readonly restored: boolean }>; place: (x: number, y: number, z: number, yaw: number) => void; hardHits: (by: number) => void; ready: () => void; leave?: () => Promise<void>; save: () => Promise<{ readonly tick: number; readonly ok: boolean }>; probe: () => Promise<{ readonly tickMs: number }>; dispose: () => void }
114
131
 
115
132
  const SAVE_EVERY_MS = 30_000;
@@ -283,7 +300,7 @@ async function leaveEarly(shell: Promise<Shell>): Promise<void> {
283
300
  * that step instead, as before. A level left before adoption saves and stops this server as an adopted one would. */
284
301
  export function startWorkerServerEarly(options: { readonly slug: string; readonly lone: boolean; readonly scope: Scope }): void {
285
302
  // GO4: a build with a world puts every page in it, a grid page too: no in-page server to start early.
286
- if (!earlyStandalone((globalThis as { __WS_WORLD__?: BuildWorld }).__WS_WORLD__, !options.lone || shardCell(options.slug) !== undefined)) return;
303
+ if (!earlyStandalone((globalThis as { __WS_WORLD__?: BuildWorld }).__WS_WORLD__)) return;
287
304
  if (early !== null && !early.adopted) return;
288
305
  const reads: EarlyServer['reads'] = { count: 0, card: null };
289
306
  const shell = bootStandalone(options.slug, options.lone, () => { if (reads.card === null) reads.count++; else reads.card.add(); });
@@ -305,6 +322,12 @@ export function startWorkerServerEarly(options: { readonly slug: string; readonl
305
322
  closing = leaveEarly(shell);
306
323
  });
307
324
  }
325
+ /** A device id's storage for a page whose browser keeps nothing (OF2: such a page still joins the world, as a new device each time). */
326
+ function pageOnlyStorage(): SaveStorage {
327
+ const items = new Map<string, string>();
328
+ return { get length() { return items.size; }, key: index => [...items.keys()][index] ?? null, getItem: key => items.get(key) ?? null,
329
+ setItem: (key, value) => { items.set(key, value); }, removeItem: key => { items.delete(key); } };
330
+ }
308
331
  async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<typeof countedWait>): Promise<void> {
309
332
  const { slug, player, physics, scope, system } = ports, { savePrefix } = appIdentity(), page = saveEnvironment().storage('shard');
310
333
  const { root, build } = buildRoot();
@@ -326,18 +349,24 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
326
349
  // a page that left while it asked never joins (Codex review): a cancelled load must not take the device's seat
327
350
  if (!answered || scope.disposed) throw new Error('The page left before it joined the world');
328
351
  const { grid } = ports, booted = grid?.booted;
329
- return startOnline({ ...world, loaded: slug, build, identity: name => deviceIdentity(storage, savePrefix, name),
352
+ return startOnline({ ...world, keep: releaseKeep(), loaded: slug, build, identity: name => deviceIdentity(storage, savePrefix, name),
330
353
  ...(grid === null || booted === undefined ? {} : { grid: { cell: booted, cells: grid.cells.map(cell => cell.instance), placed: (cell, at) => { grid.serverPlace?.(cell, at); }, reenter: cell => { grid.reenter?.(cell); },
331
354
  ...(pageGoto() === booted ? { goto: true } : {}) } }) });
332
355
  };
333
356
  const world = (globalThis as { __WS_WORLD__?: BuildWorld }).__WS_WORLD__;
334
- // GO4 gate: a grid page joins the world only once the world hosts the grid; until then, today's solo grid.
335
- const hosted = world !== undefined && page !== null && ports.grid !== null && (gotoHosted() || await bootTask('server:grid-hosted', async () => (await onlineModule()).worldHostsGrid(world, hostsGrid)));
336
- // A one-shard page joins only a world whose door names its shard (opus-route2): a shard the grid doesn't place, or one this world leaves
337
- // closed (prod opens Driftwood alone), plays solo. Shard select's one-way-in read keeps the word a minute, so this rarely dials again.
338
- const catalogued = ports.grid === null && shardCell(slug) !== undefined, asks = catalogued && world !== undefined && page !== null;
339
- const placed = ports.grid !== null || opensShard(await (asks ? bootTask('server:opens-shard', async () => (await onlineModule()).worldWord(world)).catch(() => null) : null), slug, catalogued);
340
- const shell = await (world !== undefined && page !== null && serverRoute(world, page, { page: ports.grid !== null, hosted }, placed) === 'online' ? online(world, page) : standalone()), { client } = shell;
357
+ // OFFLINE OF2 (J298): a build with a world sends every page online; the world's word never picks the server. A grid page whose world
358
+ // is known to host one cell (a word in time, or the device's kept answer; no word takes the grid, J300) re-enters as that cell's
359
+ // one-shard online page, never the solo grid. Shard select's goto already asked, so its grid page doesn't ask again.
360
+ const bootedCell = ports.grid?.booted, reshard = ports.grid?.reshard;
361
+ if (world !== undefined && bootedCell !== undefined && reshard !== undefined && !gotoHosted() && !await bootTask('server:grid-hosted', () => worldHosted(world))) {
362
+ // a page the player left while it asked (back to the title) goes nowhere: the title keeps the document (review MUST)
363
+ if (scope.disposed) throw new Error('The page left before it joined the world');
364
+ reshard(bootedCell);
365
+ // the page is leaving for the one-shard page (or the title): this boot never goes on, as a GO4 regrid's never arrives
366
+ await new Promise<never>(() => { /* settles never: the page unloads */ });
367
+ }
368
+ // A page that can keep nothing still joins, with a device id for this page only.
369
+ const shell = await (world !== undefined && serverRoute(world) === 'online' ? online(world, page ?? pageOnlyStorage()) : standalone()), { client } = shell;
341
370
  void shell.booted.catch(() => undefined);
342
371
  // QA row 16: a navigation the game chose leaves the world's seat from the moment there is a shell, even mid-load (a returning held
343
372
  // body may already be back). Once the page can save, the hold below replaces this one.
@@ -5,13 +5,13 @@
5
5
  /** Where a page's server is. */
6
6
  export type ServerRoute = 'online' | 'standalone';
7
7
 
8
- /** The route for a page. `world` is the build's stamp (`__WS_WORLD__`); `storage` is null where the page can keep nothing, and an
9
- * online seat needs a device id it can keep. A grid page goes online only once the world hosts the grid (`gridHosted`: the door's
10
- * `world` word counts more than the home cell, which `WORLD_CELLS` decides); until then it keeps today's solo grid. A one-shard page of a
11
- * shard the grid doesn't place (`placed` false: Brasscap's Developer-only card) plays solo: the world opens only grid cells, so its door
12
- * would seat the device in another cell and the page would leave for the title (opus-brass3, Jake 2026-11-12: "kicked me out"). */
13
- export function serverRoute(world: unknown, storage: unknown, grid?: { readonly page: boolean; readonly hosted: boolean }, placed = true): ServerRoute {
14
- return world !== undefined && storage !== null && (grid === undefined || !grid.page || grid.hosted) && (grid?.page === true || placed) ? 'online' : 'standalone';
8
+ /** The route for a page. `world` is the build's stamp (`__WS_WORLD__`). OFFLINE OF2 (J298, Jake 2026-11-12: "staging and prod should
9
+ * never try to play offline versions"): a build with a world sends every page online, whatever its world says or doesn't say. No
10
+ * answer (unreachable, offline), a world that hosts one cell, a shard the grid doesn't place: the page still joins, and a failing link
11
+ * shows the connection screens in the world, never the in-page server. The world's word picks only which page boots (Shard select's
12
+ * one way in, `oneWayIn.ts`), never the server. */
13
+ export function serverRoute(world: unknown): ServerRoute {
14
+ return world === undefined ? 'standalone' : 'online';
15
15
  }
16
16
 
17
17
  /** Whether the door's `world` word (`socketFrames.ts` `WorldWord`, sent on every socket before hello) says it hosts the grid: more
@@ -21,18 +21,6 @@ export function hostsGrid(world: unknown): boolean {
21
21
  return typeof cells === 'number' && cells > 1;
22
22
  }
23
23
 
24
- /** Whether a one-shard page of `slug` joins the world (`serverRoute`'s `placed`). The page's catalogue must place the shard (`catalogued`):
25
- * an off-grid page's early in-page server is already running. Then the door's world word decides: a world that names its open shards
26
- * and leaves this one out would seat the device in another cell, and the page would leave for the title (opus-route2, QA row 28: prod
27
- * opens Driftwood alone). No word (unreachable, stalled, a door older than the list) keeps the catalogue's answer. It does not seat
28
- * the page in its own cell: a one-shard page dials the bare address, so a world of several cells still seats it where the device last
29
- * stood (GO5); a one-cell world, prod's, has nowhere else to put it. */
30
- export function opensShard(word: unknown, slug: string, catalogued: boolean): boolean {
31
- if (!catalogued) return false;
32
- const shards = typeof word === 'object' && word !== null && 'shards' in word ? word.shards : null;
33
- return !Array.isArray(shards) || !shards.every(shard => typeof shard === 'string') || shards.includes(slug);
34
- }
35
-
36
- /** Whether a page may start the in-page server before its Worker boot step. A build with a world never does: its pages join the world,
37
- * except a one-shard page of a shard the grid doesn't place (`placed` false), which plays solo. */
38
- export function earlyStandalone(world: unknown, placed = true): boolean { return world === undefined || !placed; }
24
+ /** Whether a page may start the in-page server before its Worker boot step: only on a build with no world (OF2: a world build's pages
25
+ * all join the world). */
26
+ export function earlyStandalone(world: unknown): boolean { return serverRoute(world) === 'standalone'; }
@@ -0,0 +1,11 @@
1
+ /* ─── SA36: the `/slug/<slug>` page (src/client/game/slugPage.ts) ─── prefix ws-slug ───
2
+ Shard Select's restyled deck (mainMenu.css `.ws-menu-carousel`) with exactly one card: no thumbnail strip to pick from, and a
3
+ disabled PLAY (a slug with no grid cell, Jake's grill Q16) is dimmed with its "Not on the grid yet" line kept readable. */
4
+ .ws-menu.ws-slug .ws-menu-dots { display: none; }
5
+ .ws-menu.ws-slug .ws-menu-play:disabled { cursor: default; opacity: 1; border-color: rgba(143, 227, 255, 0.25); background: rgba(9, 22, 36, 0.78); box-shadow: none; }
6
+ .ws-menu.ws-slug .ws-menu-play:disabled b, .ws-menu.ws-slug .ws-menu-play:disabled .ws-menu-mode-glyph { opacity: 0.4; }
7
+ .ws-menu.ws-slug .ws-menu-play:disabled small { color: var(--ws-amber); opacity: 1; }
8
+ /* a phone keeps MAIN MENU and the build pill on the top row; the WILDSHARD word ran under the pill at 402 px */
9
+ @media (max-width: 480px) {
10
+ .ws-menu.ws-slug .ws-menu-title { display: none; }
11
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * SA36 (meta SHARD-AUTHORING-PLAN; Jake, grill 2026-11-12 Q14 to Q18): the `/slug/<slug>` page, the link a sharddev author shares
3
+ * with friends. "it's kind of like SHARD SELECT. But instead of being shard select it has exactly one shard, the slugName, and it
4
+ * has the hero image of it, and it will dynamically load that hero / slug / shard etc, and spawn you into the infinite grid there."
5
+ *
6
+ * const view = buildSlugPage({ manifest, placed, onEnter, onExplore, onSettings }) // a TitleDeckView for showStartTitle
7
+ *
8
+ * It is Shard Select's own deck (src/client/game/titleDeck.ts) holding that one card, dressed the same (mainMenu.css
9
+ * `.ws-menu-carousel`): the card, its hero behind, PLAY, SETTINGS. PLAY is ENTER WORLD: the same shardfile download, loading
10
+ * shell and `onEnter`, which src/client/app/entry.ts points at `travel`, so the next page enters the grid at the shard's cell
11
+ * exactly as a Shard select tap does (grid/oneWayIn.ts). A slug with no grid cell (not placed yet, `--no-place`, an off-grid
12
+ * shard such as Thin Ice) keeps its card and hero with PLAY disabled: "Not on the grid yet" (Q16). MAIN MENU leaves for `/`.
13
+ */
14
+ import { pageScope } from '@wildshard/engine/app/resources';
15
+ import { mobileDevice } from '@wildshard/engine/boot/titleArrival';
16
+ import { dropFirstPlay, firstPlayDone, startFirstPlay } from '@wildshard/engine/boot/firstPlayMark';
17
+ import { askNameOnce, nameAskDue } from '@wildshard/engine/ui/namePrompt';
18
+ import type { TitleDeckView } from '@wildshard/engine/ui/HUD';
19
+ import { buildTitleDeck, titleCard, type TitleCard, type TitleDeckOptions } from './titleDeck';
20
+ import type { TitleManifest } from './shard/titleList';
21
+ import { GAME_STRINGS } from '../../shared/game/strings';
22
+ import './mainMenu.css';
23
+ import './slugPage.css';
24
+
25
+ export interface SlugPageOptions extends Pick<TitleDeckOptions, 'onExplore' | 'onSettings' | 'notice' | 'mode'> {
26
+ /** the shard the link names (its title row) */
27
+ readonly manifest: TitleManifest;
28
+ /** the grid places this shard: PLAY enters it at its cell. False: PLAY is disabled, "Not on the grid yet" */
29
+ readonly placed: boolean;
30
+ /** PLAY, once the name is asked and the loading shell is up (the deck's ENTER WORLD) */
31
+ readonly onEnter: (card: TitleCard) => void;
32
+ }
33
+
34
+ /** One shard's page over Shard Select's deck. */
35
+ export function buildSlugPage(opts: SlugPageOptions): TitleDeckView {
36
+ const owner = pageScope.child('slug-page');
37
+ const s = GAME_STRINGS.slugPage;
38
+ const card = titleCard(opts.manifest);
39
+ // MG5 (as the main menu arms it): a phone's first play arms its first-play card for this shard; any other entry drops one
40
+ const phone = mobileDevice(navigator.userAgent, navigator.platform, navigator.maxTouchPoints);
41
+ // MMO-PLAN MP2.4 (as the main menu asks it): a device's first PLAY asks for the Name once, then enters
42
+ let naming = false;
43
+ const gate = (go: () => void): void => {
44
+ if (naming || !opts.placed) return; // a slug with no cell enters nothing, so it asks nothing
45
+ if (!nameAskDue()) { go(); return; }
46
+ naming = true;
47
+ void askNameOnce(owner, { parent: document.body }).then(answered => { naming = false; if (answered && !owner.disposed) go(); return undefined; },
48
+ () => { naming = false; });
49
+ };
50
+ const deck = buildTitleDeck({
51
+ cards: [card], active: null, onSettings: opts.onSettings, gate,
52
+ ...(opts.notice === undefined ? {} : { notice: opts.notice }), ...(opts.mode === undefined ? {} : { mode: opts.mode }),
53
+ single: { play: s.play, hint: s.placed, ...(opts.placed ? {} : { closed: s.unplaced }) },
54
+ onEnter: (entered) => { if (!(phone && !firstPlayDone() && startFirstPlay(entered.slug))) dropFirstPlay(); opts.onEnter(entered); },
55
+ onExplore: (entered) => { dropFirstPlay(); opts.onExplore(entered); },
56
+ });
57
+ deck.root.classList.add('ws-menu-carousel', 'ws-slug');
58
+ deck.root.dataset['slug'] = card.slug;
59
+ deck.root.dataset['placed'] = String(opts.placed);
60
+ const bar = document.createElement('div');
61
+ bar.className = 'ws-menu-bar';
62
+ const back = document.createElement('button');
63
+ back.type = 'button';
64
+ back.className = 'ws-menu-back';
65
+ back.textContent = s.menu;
66
+ const title = document.createElement('div');
67
+ title.className = 'ws-menu-title';
68
+ title.textContent = GAME_STRINGS.mainMenu.logo;
69
+ bar.append(back, title);
70
+ deck.root.querySelector('.ws-menu-head')?.prepend(bar);
71
+ deck.onTap(back, () => { location.assign('/'); });
72
+ const root = document.createElement('div');
73
+ root.className = 'ws-title-stack';
74
+ root.dataset['screen'] = 'slug';
75
+ root.append(deck.root);
76
+ return {
77
+ root, cards: deck.cards,
78
+ get index() { return deck.index; },
79
+ select: (i, smooth) => { deck.select(i, smooth); },
80
+ activate: () => { gate(() => { deck.activate(); }); },
81
+ start: () => { deck.start(); },
82
+ dispose: () => { owner.dispose(); deck.dispose(); },
83
+ };
84
+ }
@@ -5,7 +5,7 @@
5
5
  * its own look and the frame rows that write time, buffer size, pixel ratio and projection into the looks. Rows are
6
6
  * admitted before any rig, look or texture is borrowed; Model Explorer cards settle the same rigs. Client-only.
7
7
  */
8
- import { BackSide, type BufferGeometry, ClampToEdgeWrapping, DataTexture, DoubleSide, LinearMipmapLinearFilter, type Material, Mesh, NoColorSpace,
8
+ import { BackSide, type BufferGeometry, ClampToEdgeWrapping, CompressedTexture, DataTexture, DoubleSide, LinearMipmapLinearFilter, type Material, Mesh, NoColorSpace,
9
9
  type Object3D, type PerspectiveCamera, Quaternion, RedFormat, RepeatWrapping, SkinnedMesh, Texture, UnsignedByteType, Vector2, Vector3 } from 'three';
10
10
  import type { RigBake, RigContract } from '@wildshard/engine/anim/rig';
11
11
  import { retainCachedResources } from '@wildshard/engine/app/cachedAssets';
@@ -14,7 +14,7 @@ import { resourceScope } from '@wildshard/engine/app/resources';
14
14
  import { app } from '@wildshard/engine/app/runtime';
15
15
  import type { Scope } from '@wildshard/engine/app/scope';
16
16
  import { fetchImage, phoneUrl } from '@wildshard/engine/boot/bytes';
17
- import { ktx2Texture } from '@wildshard/engine/core/ktx2';
17
+ import { ktx2Texture, readHeldForm } from '@wildshard/engine/core/ktx2';
18
18
  import { loadTextureRow } from '@wildshard/engine/core/assets';
19
19
  import { SlashTrail } from '@wildshard/engine/combat/view/slashTrail';
20
20
  import type { ModelContext } from '@wildshard/engine/models/model';
@@ -82,7 +82,10 @@ function loadMap(path: string, anisotropy: number): Promise<Texture> {
82
82
  let loading = images.get(path);
83
83
  if (loading === undefined) {
84
84
  loading = (async () => {
85
- const value = await ktx2Texture(phoneUrl(path)) ?? new Texture(await fetchImage(path, Infinity, false));
85
+ // OF17: a form that fails to read gives way to the other when the cache holds it
86
+ const served = phoneUrl(path);
87
+ const read = await readHeldForm(served, tex => ktx2Texture(served, Infinity, tex), instead => fetchImage(path, Infinity, false, false, instead));
88
+ const value = read instanceof CompressedTexture ? read : new Texture(read);
86
89
  value.colorSpace = NoColorSpace; value.flipY = false; value.minFilter = LinearMipmapLinearFilter; value.anisotropy = anisotropy; value.needsUpdate = true;
87
90
  resolved.set(path, value);
88
91
  return retainCachedResources(value);