@wildshard/engine 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +21 -0
  5. package/lint/host-callback-syntax.mjs +2 -1
  6. package/lint/host-callbacks.mjs +3 -3
  7. package/lint/host-files.mjs +5 -4
  8. package/lint/no-base64.mjs +3 -1
  9. package/lint/ratchet.json +0 -68
  10. package/lint/ratchet.mjs +1 -4
  11. package/lint/shard-imports.mjs +6 -7
  12. package/lint/shard-source.d.mts +9 -0
  13. package/lint/shard-source.mjs +91 -0
  14. package/lint/shardfile-boundaries.mjs +10 -8
  15. package/lint/sim-closure.mjs +6 -3
  16. package/lint/wildshard-plugin.d.ts +4 -0
  17. package/lint/wildshard-plugin.js +22 -23
  18. package/package.json +25 -16
  19. package/scripts/agent-sync.mjs +27 -8
  20. package/scripts/app-build/appCook.ts +8 -2
  21. package/scripts/app-build/catalogue.ts +10 -7
  22. package/scripts/app-build/gen.ts +22 -2
  23. package/scripts/app-build/isolation.d.mts +10 -0
  24. package/scripts/app-build/isolation.mjs +47 -0
  25. package/scripts/app-build/outputProducts.d.mts +3 -0
  26. package/scripts/app-build/outputProducts.mjs +35 -0
  27. package/scripts/app-build/previousDeploy.d.mts +2 -0
  28. package/scripts/app-build/previousDeploy.mjs +10 -1
  29. package/scripts/app-build/serviceWorker.ts +10 -3
  30. package/scripts/app-build/splitOutput.mjs +4 -2
  31. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  32. package/scripts/app-build/standaloneOutput.mjs +5 -3
  33. package/scripts/app-build/titlePreloads.d.mts +8 -0
  34. package/scripts/app-build/titlePreloads.mjs +69 -0
  35. package/scripts/app-build/worldMapAtlas.ts +10 -6
  36. package/scripts/app-build-pipeline.mjs +34 -3
  37. package/scripts/built-product.mjs +1 -1
  38. package/scripts/cell-mem-bench.mjs +81 -23
  39. package/scripts/check-custom-sections-zero.mjs +1 -1
  40. package/scripts/check-devserver.mjs +3 -1
  41. package/scripts/check-models.mjs +2 -0
  42. package/scripts/check-paths.allow.json +0 -115
  43. package/scripts/check-paths.mjs +2 -2
  44. package/scripts/check-platform-ratchets.mjs +2 -3
  45. package/scripts/chromium-keychain-check.mjs +4 -2
  46. package/scripts/chromium-keychain.d.mts +1 -1
  47. package/scripts/chromium-keychain.mjs +3 -1
  48. package/scripts/ci-static.sh +1 -1
  49. package/scripts/committed-fast-checks.mjs +0 -2
  50. package/scripts/content-sw-proof.mjs +2 -1
  51. package/scripts/cook-worker.mjs +9 -3
  52. package/scripts/cook.mjs +20 -3
  53. package/scripts/devices.d.mts +4 -0
  54. package/scripts/devices.mjs +39 -0
  55. package/scripts/devserver-client.d.mts +4 -2
  56. package/scripts/devserver-client.mjs +25 -8
  57. package/scripts/docs-inputs-proof.mjs +6 -6
  58. package/scripts/doctor-proof.mjs +1 -1
  59. package/scripts/e2e-faults.mjs +159 -0
  60. package/scripts/e7-voice-staging-proof.mjs +1 -1
  61. package/scripts/gate-related-tests.mjs +1 -1
  62. package/scripts/git-source-view.mjs +1 -1
  63. package/scripts/goldens/capture.mjs +17 -5
  64. package/scripts/grid-crossing-nightly.mjs +59 -0
  65. package/scripts/grid-crossing-qa.mjs +44 -0
  66. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  67. package/scripts/grid-crossing-ratchet.mjs +52 -0
  68. package/scripts/grid-crossing-report.mjs +122 -0
  69. package/scripts/grid-crossing-stages.mjs +47 -0
  70. package/scripts/grid-crossing-tour.mjs +277 -0
  71. package/scripts/grid-crossing-walk-proof.mjs +136 -18
  72. package/scripts/host-ruler/roots.mjs +2 -2
  73. package/scripts/host-ruler.d.mts +91 -0
  74. package/scripts/host-ruler.mjs +565 -0
  75. package/scripts/live-prepush.py +3 -5
  76. package/scripts/loading-flow/benchmax.mjs +3 -1
  77. package/scripts/look-loop/test_look_loop.py +1 -38
  78. package/scripts/memory-proof.mjs +213 -0
  79. package/scripts/mmo-bots.mjs +8 -2
  80. package/scripts/net-lag-proof.mjs +219 -0
  81. package/scripts/night-market-kit-budget.mjs +2 -2
  82. package/scripts/offline-proof-rules.d.mts +5 -3
  83. package/scripts/offline-proof-rules.mjs +34 -7
  84. package/scripts/offline-proof.mjs +88 -18
  85. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  86. package/scripts/page-release/content.d.mts +9 -1
  87. package/scripts/page-release/content.mjs +131 -17
  88. package/scripts/page-release/flow.mjs +36 -10
  89. package/scripts/page-release/stamp-content.mjs +24 -0
  90. package/scripts/page-release.mjs +28 -6
  91. package/scripts/page-size.mjs +2 -1
  92. package/scripts/pin-packs.ts +1 -1
  93. package/scripts/pins.ts +4 -4
  94. package/scripts/precommit-checks.mjs +1 -7
  95. package/scripts/precommit-jobs.mjs +0 -1
  96. package/scripts/precommit-source.py +1 -9
  97. package/scripts/program-discovery.mjs +1 -1
  98. package/scripts/ring-cook.mjs +2 -1
  99. package/scripts/ring-step.ts +1 -1
  100. package/scripts/script-scenario-metrics.mjs +1 -1
  101. package/scripts/shard-output-content.d.mts +1 -1
  102. package/scripts/shard-output-content.mjs +2 -2
  103. package/scripts/shard-outputs.mjs +1 -1
  104. package/scripts/shard-public.mjs +1 -1
  105. package/scripts/shard-wire-meter.mjs +24 -9
  106. package/scripts/side-parity.mjs +4 -2
  107. package/scripts/standalone-smoke.mjs +8 -3
  108. package/scripts/tier-textures-proof.mjs +101 -0
  109. package/scripts/tier-textures.mjs +78 -0
  110. package/scripts/tile-bake-report.mjs +1 -1
  111. package/scripts/tile-bakes.mjs +1 -1
  112. package/scripts/title-assets.generated.json +2 -0
  113. package/scripts/tsconfig.json +1 -2
  114. package/scripts/vendor/basisu/LICENSE +201 -0
  115. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  116. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  117. package/scripts/vitest-push-guards.config.ts +1 -1
  118. package/scripts/vps/harden-apply.sh +4 -1
  119. package/scripts/vps/harden-prometheus.sh +176 -0
  120. package/scripts/vps/harden.sh +16 -0
  121. package/scripts/vps/rebuild.sh +18 -0
  122. package/scripts/vps/wildshard-config +84 -24
  123. package/scripts/worker-client-play.mjs +7 -2
  124. package/scripts/worker-client-proof.mjs +1 -1
  125. package/scripts/worker-client-slug.mjs +44 -0
  126. package/scripts/worktree-reap.mjs +5 -5
  127. package/src/.oxlintrc.json +3 -182
  128. package/src/client/app/entry.ts +47 -12
  129. package/src/client/engine/boot/bootCache.ts +2 -2
  130. package/src/client/engine/boot/bootTrace.ts +12 -4
  131. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  132. package/src/client/engine/boot/clearDownloads.ts +5 -2
  133. package/src/client/engine/boot/contentRead.ts +11 -0
  134. package/src/client/engine/boot/gpuFiles.ts +4 -2
  135. package/src/client/engine/boot/lastEnd.ts +99 -12
  136. package/src/client/engine/boot/parsedPages.ts +127 -58
  137. package/src/client/engine/boot/texturePack.ts +2 -2
  138. package/src/client/engine/build.d.ts +2 -0
  139. package/src/client/engine/core/Game.ts +18 -0
  140. package/src/client/engine/core/bootstrap.ts +4 -1
  141. package/src/client/engine/debug/probe.ts +18 -1
  142. package/src/client/engine/fx/LightPool.ts +41 -1
  143. package/src/client/engine/net/netPlayer.ts +19 -2
  144. package/src/client/engine/net/otherPlayers.ts +55 -8
  145. package/src/client/engine/net/predictor.ts +33 -9
  146. package/src/client/engine/net/redial.ts +29 -6
  147. package/src/client/engine/pwa/cacheNames.ts +58 -1
  148. package/src/client/engine/pwa/sw.js +53 -14
  149. package/src/client/engine/render/dataLook.ts +152 -40
  150. package/src/client/engine/render/families/detail.ts +89 -0
  151. package/src/client/engine/render/families/pbr.ts +7 -1
  152. package/src/client/engine/render/look.ts +6 -0
  153. package/src/client/engine/render/lookLight.ts +103 -11
  154. package/src/client/engine/render/lookRender.ts +105 -0
  155. package/src/client/engine/render/precompile.ts +20 -14
  156. package/src/client/engine/saves/indexed.ts +2 -2
  157. package/src/client/engine/telemetry/browserErrors.ts +28 -4
  158. package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
  159. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  160. package/src/client/engine/ui/debugOptions.ts +1 -1
  161. package/src/client/engine/ui/lookLightOption.ts +10 -6
  162. package/src/client/engine/ui/namePrompt.ts +7 -0
  163. package/src/client/game/boot/audio.generated.ts +114 -216
  164. package/src/client/game/boot/bytes.generated.ts +118 -238
  165. package/src/client/game/boot/placedSpawn.ts +35 -0
  166. package/src/client/game/boot/spawnDownload.ts +25 -6
  167. package/src/client/game/boot/versions.generated.ts +7 -7
  168. package/src/client/game/devScene/hook.ts +291 -0
  169. package/src/client/game/grid/area.ts +38 -0
  170. package/src/client/game/grid/cellLoading.ts +12 -2
  171. package/src/client/game/grid/live.ts +134 -12
  172. package/src/client/game/grid/liveSession.ts +47 -5
  173. package/src/client/game/grid/mapAtlas.ts +18 -4
  174. package/src/client/game/grid/menu.ts +4 -0
  175. package/src/client/game/grid/minimapBlend.ts +15 -5
  176. package/src/client/game/grid/neighbourPanels.ts +10 -1
  177. package/src/client/game/grid/oneWayIn.ts +5 -1
  178. package/src/client/game/grid/placedCards.ts +55 -0
  179. package/src/client/game/grid/placedCells.ts +233 -0
  180. package/src/client/game/grid/placedContent.ts +85 -0
  181. package/src/client/game/grid/prefetch.ts +9 -1
  182. package/src/client/game/grid/productInputs.ts +3 -1
  183. package/src/client/game/grid/productLeases.ts +4 -1
  184. package/src/client/game/grid/products.ts +8 -4
  185. package/src/client/game/grid/regionalRuntime.ts +6 -0
  186. package/src/client/game/grid/regionalWorld.ts +15 -2
  187. package/src/client/game/grid/roadCull.ts +44 -14
  188. package/src/client/game/grid/roadLook.ts +24 -15
  189. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  190. package/src/client/game/grid/roadResources.ts +24 -0
  191. package/src/client/game/grid/roadSign.worker.ts +4 -3
  192. package/src/client/game/grid/roadSignPaint.ts +16 -5
  193. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  194. package/src/client/game/grid/roadSignScale.ts +8 -0
  195. package/src/client/game/grid/roadTileBacking.ts +13 -3
  196. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  197. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  198. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  199. package/src/client/game/grid/roadTileWriter.ts +2 -1
  200. package/src/client/game/grid/screenReports.ts +39 -0
  201. package/src/client/game/grid/session.ts +29 -4
  202. package/src/client/game/grid/shardfileFar.ts +9 -3
  203. package/src/client/game/grid/softWallLook.ts +25 -8
  204. package/src/client/game/mainMenu.ts +6 -2
  205. package/src/client/game/plugin/context.ts +2 -1
  206. package/src/client/game/plugin/followedMovers.ts +7 -1
  207. package/src/client/game/quest/figures.ts +2 -0
  208. package/src/client/game/session/finish.ts +11 -1
  209. package/src/client/game/shard/titleList.ts +6 -2
  210. package/src/client/game/shardfile/assetCache.ts +4 -4
  211. package/src/client/game/shardfile/client.ts +4 -1
  212. package/src/client/game/shardfile/clientAssets.ts +9 -5
  213. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  214. package/src/client/game/shardfile/clientWater.ts +51 -9
  215. package/src/client/game/shardfile/clientWorker.ts +21 -8
  216. package/src/client/game/shardfile/look.ts +8 -3
  217. package/src/client/game/shardfile/product.ts +34 -7
  218. package/src/client/game/shardfile/productChecks.ts +2 -2
  219. package/src/client/game/shardfile/productCost.ts +2 -2
  220. package/src/client/game/shardfile/readAsset.ts +2 -2
  221. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  222. package/src/client/game/shardfile/seatGrace.ts +9 -0
  223. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  224. package/src/client/game/systems/npc/figureRows.ts +9 -0
  225. package/src/client/game/titleDeck.ts +4 -3
  226. package/src/client/host/online/doctor.ts +2 -0
  227. package/src/client/host/online/linkScreens.ts +30 -4
  228. package/src/client/host/online/shell.ts +14 -0
  229. package/src/client/host/standalone/shell.ts +4 -0
  230. package/src/cook/game/astc6Encode.ts +55 -0
  231. package/src/cook/game/astc6Wasm.ts +176 -0
  232. package/src/cook/game/cookJob.ts +30 -6
  233. package/src/cook/game/cookWorker.ts +38 -11
  234. package/src/cook/game/entryTotals.ts +51 -24
  235. package/src/cook/game/shardCook.ts +67 -9
  236. package/src/cook/game/spawnParts.ts +33 -8
  237. package/src/cook/game/tierTextures.ts +349 -0
  238. package/src/e2e/smoke/game.ts +19 -14
  239. package/src/e2e/smoke/page-globals.d.ts +9 -8
  240. package/src/e2e/smoke/template2.spec.ts +8 -7
  241. package/src/server/engine/ai/bossContenders.ts +27 -3
  242. package/src/server/engine/ai/phases.ts +1 -1
  243. package/src/server/engine/entities/creatureRefill.ts +9 -2
  244. package/src/server/engine/net/ledgerBook.ts +2 -0
  245. package/src/server/engine/net/room.ts +15 -0
  246. package/src/server/engine/sim/respawn.ts +8 -0
  247. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  248. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  249. package/src/server/game/boss/native.ts +2 -1
  250. package/src/server/game/boss/nativeWake.ts +9 -5
  251. package/src/server/game/boss/openArenaNative.ts +2 -2
  252. package/src/server/game/boss/openArenaRoom.ts +3 -1
  253. package/src/server/game/grid/room.ts +44 -3
  254. package/src/server/game/grid/simulation.ts +23 -0
  255. package/src/server/game/population/mixedRoster.ts +11 -3
  256. package/src/server/game/population/nativeBake.ts +8 -3
  257. package/src/server/game/population/nativeReturns.ts +6 -3
  258. package/src/server/game/population/roster.ts +5 -3
  259. package/src/server/game/quest/eliteDrops.ts +15 -4
  260. package/src/server/game/quest/nativeChapter.ts +1 -1
  261. package/src/server/game/quest/nativeComposition.ts +5 -1
  262. package/src/server/game/riding/nativeTaming.ts +10 -6
  263. package/src/server/game/riding/wildRefill.ts +3 -2
  264. package/src/server/game/shardfile/bossRow.ts +4 -2
  265. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  266. package/src/server/host/bake/headlessWorker.ts +1 -1
  267. package/src/server/host/dedicated/cellHost.ts +98 -16
  268. package/src/server/host/dedicated/cellProtocol.ts +16 -1
  269. package/src/server/host/dedicated/cellWorker.ts +8 -5
  270. package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
  271. package/src/server/host/dedicated/gridCells.ts +15 -6
  272. package/src/server/host/dedicated/loopLag.ts +21 -0
  273. package/src/server/host/dedicated/main.ts +13 -5
  274. package/src/server/host/dedicated/packReader.ts +3 -3
  275. package/src/server/host/dedicated/placementFile.ts +4 -19
  276. package/src/server/host/dedicated/roadRoom.ts +34 -4
  277. package/src/server/host/dedicated/serverMetrics.ts +126 -0
  278. package/src/server/host/dedicated/socketPump.ts +21 -4
  279. package/src/server/host/dedicated/socketTransport.ts +2 -1
  280. package/src/server/host/dedicated/workerTable.ts +15 -4
  281. package/src/server/host/dedicated/world.ts +95 -8
  282. package/src/server/host/headless.ts +1 -1
  283. package/src/server/host/headlessRuntime.ts +1 -1
  284. package/src/server/host/standalone/roadWorld.ts +15 -3
  285. package/src/server/host/standalone/serverHost.ts +4 -1
  286. package/src/server/host/standalone/serverProduct.ts +41 -11
  287. package/src/shared/engine/ai/BossBrain.ts +8 -0
  288. package/src/shared/engine/net/deviceWord.ts +138 -0
  289. package/src/shared/engine/net/socketFrames.ts +7 -4
  290. package/src/shared/game/boss/wake.ts +6 -0
  291. package/src/shared/game/devColliders.ts +47 -0
  292. package/src/shared/game/eliteSystem.ts +8 -0
  293. package/src/shared/game/grid/allocator.ts +3 -0
  294. package/src/shared/game/grid/catalogueSlot.ts +7 -0
  295. package/src/shared/game/grid/placementRows.ts +36 -0
  296. package/src/shared/game/plugin/bossRecord.ts +3 -2
  297. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  298. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  299. package/src/shared/game/shardfile/packReads.ts +28 -3
  300. package/src/shared/game/shardfile/serverPack.ts +9 -0
  301. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  302. package/src/shared/host/formatJsonSchema.ts +2 -2
  303. package/src/tsconfig.json +1 -27
  304. package/lint/host-reviews.json +0 -14
  305. package/lint/listed-view-code.json +0 -13
  306. package/lint/platform-pending-users.json +0 -2520
  307. package/lint/platform-pending-users.md +0 -18
  308. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  309. package/scripts/check-closed-components.d.mts +0 -7
  310. package/scripts/check-closed-components.mjs +0 -87
  311. package/scripts/g571-hosts.d.mts +0 -3
  312. package/scripts/g571-hosts.mjs +0 -54
  313. package/scripts/host-ruler/register-migrate.mjs +0 -242
  314. package/scripts/listed-view-code.d.mts +0 -7
  315. package/scripts/listed-view-code.mjs +0 -93
  316. package/scripts/look-loop/fit-lut.py +0 -142
  317. package/scripts/look-loop/palette-delta.py +0 -183
  318. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  319. package/scripts/look-loop/regions/far-reach.json +0 -225
  320. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  321. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  322. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  323. package/scripts/platform-chargebacks.d.mts +0 -9
  324. package/scripts/platform-chargebacks.mjs +0 -135
  325. package/scripts/shard-component-spans.d.mts +0 -15
  326. package/scripts/shard-component-spans.mjs +0 -18
  327. package/scripts/shard-components.d.mts +0 -16
  328. package/scripts/shard-components.mjs +0 -363
  329. package/scripts/shard-platform-hosts.d.mts +0 -2
  330. package/scripts/shard-platform-hosts.mjs +0 -93
  331. package/scripts/shard-platform-sections.d.mts +0 -2
  332. package/scripts/shard-platform-sections.mjs +0 -9
  333. package/scripts/shard-platform.d.mts +0 -76
  334. package/scripts/shard-platform.mjs +0 -1072
  335. package/src/.oxfmtrc.json +0 -48
  336. package/src/scripts/ask-new.sh +0 -29
  337. package/src/scripts/asks.mjs +0 -142
  338. package/src/scripts/herdr-prompt.sh +0 -34
  339. package/src/scripts/herdr-question-open.sh +0 -67
  340. package/src/scripts/md-wrap.mjs +0 -229
  341. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  342. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  343. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * A look's render-match draws (meta TEMPLATES-CLEANROOM M4.7/M4.8, `@wildshard/format/look-render`): what a cleanroom
3
+ * three.js scene adds round its lamps and in its air, and the exposure its renderer applies before tone mapping.
4
+ *
5
+ * - `lampHalos`: one instanced, additive, unfogged billboard per lamp that declares a `halo` (one draw, one program).
6
+ * - `lookMotes`: fireflies, sparks or dust, one additive points draw; each mote wanders round its seed point and breathes.
7
+ * - `ExposureEffect`: `2^exposure` on the scene's linear colour, ahead of the tone curve (`look.grade.exposure`, in stops;
8
+ * 0 adds no effect).
9
+ */
10
+ import * as THREE from 'three';
11
+ import { Effect } from 'postprocessing';
12
+ import type { LookLamp } from '@wildshard/format/look-light';
13
+ import type { LookMotes } from '@wildshard/format/look-render';
14
+
15
+ const linear = (rgb: readonly [number, number, number]): THREE.Color => new THREE.Color().setRGB(rgb[0], rgb[1], rgb[2], THREE.LinearSRGBColorSpace);
16
+
17
+ /** The halos of the lamps that declare one; null when none does. Each lamp's halo is its colour × `opacity`, `size` m across. */
18
+ export function lampHalos(lamps: readonly LookLamp[]): THREE.InstancedMesh<THREE.PlaneGeometry, THREE.ShaderMaterial> | null {
19
+ const glowing = lamps.filter((lamp) => lamp.halo !== undefined);
20
+ if (glowing.length === 0) return null;
21
+ const geometry = new THREE.PlaneGeometry(1, 1), glow = new Float32Array(glowing.length * 3);
22
+ glowing.forEach((lamp, i) => { const c = linear(lamp.colour).multiplyScalar(lamp.halo?.opacity ?? 0); glow.set([c.r, c.g, c.b], i * 3); });
23
+ geometry.setAttribute('aGlow', new THREE.InstancedBufferAttribute(glow, 3));
24
+ const material = new THREE.ShaderMaterial({
25
+ name: 'engine.look.halos', transparent: true, depthWrite: false, fog: false, blending: THREE.AdditiveBlending,
26
+ vertexShader: /* glsl */`
27
+ attribute vec3 aGlow; varying vec3 vGlow; varying vec2 vDisc;
28
+ void main() {
29
+ vGlow = aGlow; vDisc = position.xy * 2.0;
30
+ vec4 centre = modelViewMatrix * instanceMatrix * vec4(0.0, 0.0, 0.0, 1.0);
31
+ float size = length(instanceMatrix[0].xyz);
32
+ centre.xy += position.xy * size;
33
+ gl_Position = projectionMatrix * centre;
34
+ }`,
35
+ fragmentShader: /* glsl */`
36
+ varying vec3 vGlow; varying vec2 vDisc;
37
+ void main() { float r = clamp(1.0 - length(vDisc), 0.0, 1.0); gl_FragColor = vec4(vGlow * r * r * r, 1.0); }`,
38
+ });
39
+ const mesh = new THREE.InstancedMesh(geometry, material, glowing.length);
40
+ const m = new THREE.Matrix4(), q = new THREE.Quaternion(), p = new THREE.Vector3(), s = new THREE.Vector3();
41
+ glowing.forEach((lamp, i) => { const size = lamp.halo?.size ?? 1; mesh.setMatrixAt(i, m.compose(p.set(lamp.at[0], lamp.at[1], lamp.at[2]), q, s.set(size, size, size))); });
42
+ mesh.instanceMatrix.needsUpdate = true;
43
+ mesh.computeBoundingSphere();
44
+ mesh.name = 'look-light-halos'; mesh.renderOrder = 2; mesh.castShadow = false; mesh.receiveShadow = false; mesh.frustumCulled = false;
45
+ return mesh;
46
+ }
47
+
48
+ /** a mote's wander (metres) round its seed point */
49
+ const MOTE_WANDER = 0.45;
50
+
51
+ /** The look's motes: `count` points seeded (fixed, so a capture repeats) through the box, one additive draw; they move on
52
+ * the look's clock (`tickGlow`). */
53
+ export function lookMotes(motes: LookMotes): THREE.Points<THREE.BufferGeometry, THREE.ShaderMaterial> {
54
+ const at = new Float32Array(motes.count * 3), seed = new Float32Array(motes.count);
55
+ let s = 0x2f6b1d;
56
+ const next = (): number => { s = (Math.imul(s ^ (s >>> 15), 0x2c1b3c6d) + 0x297a2d39) >>> 0; return s / 4294967296; };
57
+ for (let i = 0; i < motes.count; i++) {
58
+ for (let k = 0; k < 3; k++) at[i * 3 + k] = (motes.min[k] ?? 0) + ((motes.max[k] ?? 0) - (motes.min[k] ?? 0)) * next();
59
+ seed[i] = next() * 100;
60
+ }
61
+ const geometry = new THREE.BufferGeometry();
62
+ geometry.setAttribute('position', new THREE.BufferAttribute(at, 3));
63
+ geometry.setAttribute('aSeed', new THREE.BufferAttribute(seed, 1));
64
+ const material = new THREE.ShaderMaterial({
65
+ name: 'engine.look.motes', transparent: true, depthWrite: false, fog: false, blending: THREE.AdditiveBlending,
66
+ uniforms: { uTime: { value: 0 }, uColour: { value: linear(motes.colour).multiplyScalar(motes.gain) }, uSize: { value: motes.size }, uScale: { value: 500 } },
67
+ vertexShader: /* glsl */`
68
+ uniform float uTime, uSize, uScale; attribute float aSeed; varying float vBreath;
69
+ void main() {
70
+ vec3 p = position + vec3(sin(uTime * 0.31 + aSeed), sin(uTime * 0.23 + aSeed * 1.7) * 0.6, cos(uTime * 0.27 + aSeed * 0.7)) * ${MOTE_WANDER.toFixed(2)};
71
+ vec4 mv = modelViewMatrix * vec4(p, 1.0);
72
+ vBreath = 0.35 + 0.65 * pow(0.5 + 0.5 * sin(uTime * 1.7 + aSeed * 3.1), 2.0);
73
+ gl_PointSize = max(1.0, uSize * uScale / -mv.z);
74
+ gl_Position = projectionMatrix * mv;
75
+ }`,
76
+ fragmentShader: /* glsl */`
77
+ uniform vec3 uColour; varying float vBreath;
78
+ void main() { float r = clamp(1.0 - length(gl_PointCoord * 2.0 - 1.0), 0.0, 1.0); gl_FragColor = vec4(uColour * vBreath * r * r, 1.0); }`,
79
+ });
80
+ const points = new THREE.Points(geometry, material);
81
+ points.name = 'look-light-motes'; points.frustumCulled = false; points.renderOrder = 2;
82
+ const size = new THREE.Vector2();
83
+ points.onBeforeRender = (renderer, _scene, camera) => {
84
+ const scale = material.uniforms['uScale'];
85
+ // pixels per metre at 1 m: the drawing buffer's height over the view's vertical extent
86
+ if (scale !== undefined && camera instanceof THREE.PerspectiveCamera) scale.value = renderer.getDrawingBufferSize(size).y / (2 * Math.tan(THREE.MathUtils.degToRad(camera.fov) / 2));
87
+ };
88
+ return points;
89
+ }
90
+
91
+ /** Set the look's clock (seconds since the look went in) on its glow draws (the motes' wander and breath). */
92
+ export function tickGlow(draws: readonly THREE.Object3D[], time: number): void {
93
+ for (const draw of draws) {
94
+ const material = (draw as Partial<THREE.Mesh>).material;
95
+ if (material instanceof THREE.ShaderMaterial) { const uTime = material.uniforms['uTime']; if (uTime !== undefined) uTime.value = time; }
96
+ }
97
+ }
98
+
99
+ /** `look.grade.exposure` (stops) on the scene's linear colour, ahead of the tone curve. */
100
+ export class ExposureEffect extends Effect {
101
+ constructor(stops: number) {
102
+ super('ExposureEffect', 'uniform float uExposure; void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) { outputColor = vec4(inputColor.rgb * uExposure, inputColor.a); }',
103
+ { uniforms: new Map([['uExposure', new THREE.Uniform(2 ** stops)]]) });
104
+ }
105
+ }
@@ -158,9 +158,13 @@ function* exteriorJobSteps(scene: THREE.Scene, rt: THREE.WebGLRenderTarget | nul
158
158
  const target = createCompileScene(scene);
159
159
  const lights = new CompileLights();
160
160
  // the road draws with the page's own environment (a layer swaps a cell's in only while it renders, `BackdropLayer.apply`):
161
- // with none declared, the live page environment keys the exterior variant (G639: a null one keyed Driftwood's road
162
- // programs without the page PMREM, so they all linked on the first road frame)
163
- target.fog = scene.fog; target.environment = state.environment ?? scene.environment;
161
+ // the declared one keys the exterior variant, and the live one (a cell's PMREM, swapped in by its layer at half weight, so
162
+ // drawn on the road beside the cell; G639: Driftwood's road programs linked on the first road frame without it) one more
163
+ // below. RP4: keyed with the live PMREM alone, between frames inside a cell, a grid page (declared none) had no variant
164
+ // for the road past the layer's half weight, and every program of the cell linked again 2 m before its edge (Driftwood's
165
+ // west edge: about 17 links in one frame, 2.5 to 4.3 s in Chromium)
166
+ target.fog = scene.fog; target.environment = state.environment;
167
+ const live = scene.environment;
164
168
  const pending: THREE.Object3D[] = [scene];
165
169
  while (pending.length > 0) {
166
170
  const object = pending.pop();
@@ -183,17 +187,19 @@ function* exteriorJobSteps(scene: THREE.Scene, rt: THREE.WebGLRenderTarget | nul
183
187
  : exterior;
184
188
  // Passes with their own scene keep their authored state. Only the page world/depth variants transition outside.
185
189
  for (const job of jobs) if (job.target === scene) { job.target = target; job.lights = lights; }
186
- // A view root's warm-up (`roots`): also the variant for every other environment the road may draw with, one per cube
187
- // height (a cell's layer swaps its PMREM in by weight; G639: Driftwood's, Nalati's and Pine's ring and road views linked
188
- // their 256 / 512 / 1024 variants on the first road frame beside each, 150-270 ms each with a cold shader cache)
189
- if (roots !== undefined) {
190
- const own = target.environment, height = (t: THREE.Texture | null): unknown => (t === null ? null : Reflect.get(t.image ?? {}, 'height'));
191
- for (const environment of pageEnvironments()) {
192
- if (height(environment) === height(own)) continue;
193
- const lit = (yield* sceneJobSteps(scene, rt, 1, roots, state.roots)).jobs;
194
- for (const job of lit) if (job.target === scene) { job.target = target; job.lights = lights; job.environment = environment; }
195
- jobs.push(...lit);
196
- }
190
+ // Also the variant for every other environment the road may draw with, one per cube height (three keys a program by the
191
+ // PMREM's height, and by none): the live one, and for a view root's warm-up (`roots`) every one the page recorded (a
192
+ // cell's layer swaps its PMREM in by weight; G639: Driftwood's, Nalati's and Pine's ring and road views linked their
193
+ // 256 / 512 / 1024 variants on the first road frame beside each, 150-270 ms each with a cold shader cache)
194
+ const height = (t: THREE.Texture | null): unknown => (t === null ? null : Reflect.get(t.image ?? {}, 'height'));
195
+ const keyed = new Set<unknown>([height(target.environment)]);
196
+ for (const environment of [...live === null ? [] : [live], ...roots === undefined ? [] : pageEnvironments()]) {
197
+ if (keyed.has(height(environment))) continue;
198
+ keyed.add(height(environment));
199
+ const lit = [...(yield* sceneJobSteps(scene, rt, roots === undefined ? per : 1, roots ?? [scene], state.roots, undefined, from)).jobs,
200
+ ...roots === undefined ? familyCompileJobs(scene, rt, per, excludedMaterials) : []];
201
+ for (const job of lit) if (job.target === scene) { job.target = target; job.lights = lights; job.environment = environment; }
202
+ jobs.push(...lit);
197
203
  }
198
204
  return jobs;
199
205
  }
@@ -3,7 +3,7 @@
3
3
  import type { ImportReport, SaveStorage } from '../../../shared/engine/saves/store';
4
4
  import { installedIdentity, saveEpoch } from '../../../shared/engine/app/identity';
5
5
  import { deviceIdentity } from '../../../shared/engine/net/identity';
6
- import { ASSET_CACHE_NAME } from '../pwa/cacheNames';
6
+ import { assetCacheName } from '../pwa/cacheNames';
7
7
  import { bootTiming } from '../../../shared/engine/boot/timing';
8
8
 
9
9
  /** A server's saves on a page: the same documents localStorage would hold. */
@@ -89,7 +89,7 @@ export async function openIndexedSaves(name: string): Promise<IndexedSaves> {
89
89
  // Resource timings lend already-known URLs and measured sizes: no native
90
90
  // Cache.keys enumeration can be left pending across a title navigation.
91
91
  try {
92
- const cache = await caches.open(ASSET_CACHE_NAME), origin = globalThis.location?.origin;
92
+ const cache = await caches.open(assetCacheName()), origin = globalThis.location?.origin;
93
93
  const observed = new Map<string, number>();
94
94
  for (const entry of bootTiming()?.resources ?? []) {
95
95
  const url = entry['url'], bytes = entry['decodedBodySize'];
@@ -34,10 +34,24 @@ export interface BrowserErrorTags {
34
34
  * link-refused the online stop card "The world turned this connection away" (the same file)
35
35
  * stale-build the stale-build screen (index.html data-stale-build, STALE-BUILD SB6), reported by the next build that boots
36
36
  * (telemetry/staleBuildReport.ts) since that page stops before Sentry can load
37
+ * loading-stall the loading card's RETRY for a content read that failed past its own retry (boot/contentRead.ts
38
+ * retryFromCard, SENTRY-TRIAGE S18), once per page; a common screen, so it reports at warning level
39
+ * stale-reload the RELOADING cover over a build whose files are gone from the server (boot/browserChunkRecovery.ts
40
+ * reloadIfStaleBuild); the outbox carries it across the reload; warning (every deploy meets open tabs)
41
+ * self-reload index.html's 12 s self-reload of a page whose entry never arrived, reported by the page it reloads into
42
+ * (telemetry/staleBuildReport.ts reportSelfReload), since the inline script has no Sentry; warning
43
+ * save-failed the grid's SAVE FAILED, RETRY at a border (game/grid/screenReports.ts), once a session
44
+ * cell-unavailable a Shard Select UNAVAILABLE card: a neighbour cell that can't load (game/grid/session.ts refuse),
45
+ * once per cell a session; warning
46
+ * map-tile-missing a full-map cell the world map atlas has no tile for, drawn as a plain plot or its own map instead
47
+ * (game/grid/mapAtlas.ts; QA-FEEDBACK 2026-11-13 row 44), once per slug a page; warning
37
48
  * Not screens of a fault, so never reported: the player's own reload, back or exit (QA 11-12 row 35), "Playing somewhere else",
38
49
  * "The world is full", the reconnect banner (counted in `net` telemetry), title refusal lines and the Connection doctor.
39
50
  */
40
- export const ERROR_SCREENS = ['error-modal', 'stuck-step', 'glitch-chip', 'load-failure', 'title-drop', 'link-lost', 'link-refused', 'stale-build'] as const;
51
+ export const ERROR_SCREENS = ['error-modal', 'stuck-step', 'glitch-chip', 'load-failure', 'title-drop', 'link-lost', 'link-refused', 'stale-build',
52
+ 'loading-stall', 'stale-reload', 'self-reload', 'save-failed', 'cell-unavailable', 'map-tile-missing'] as const;
53
+ /** S18: screens common enough on a bad network that each is a Sentry warning, never an error */
54
+ export const WARNING_SCREENS: readonly ErrorScreen[] = ['loading-stall', 'stale-reload', 'self-reload', 'cell-unavailable', 'map-tile-missing'];
41
55
  export type ErrorScreen = typeof ERROR_SCREENS[number];
42
56
 
43
57
  // A DSN is a public browser endpoint, not an auth token. Only real production pages report.
@@ -101,7 +115,8 @@ export function browserErrorNoise(event: ErrorEvent, page: { readonly environmen
101
115
  const UNSUPPORTED_BROWSER = ['This browser is too old for the online world'] as const;
102
116
 
103
117
  /** The Sentry level an error reports at: `warning` for a designed old-browser refusal, else `fatal` or `error`. Pure, so it is tested. */
104
- export function browserErrorLevel(error: unknown, fatal: boolean): 'warning' | 'error' | 'fatal' {
118
+ export function browserErrorLevel(error: unknown, fatal: boolean, screen?: ErrorScreen): 'warning' | 'error' | 'fatal' {
119
+ if (screen !== undefined && WARNING_SCREENS.includes(screen)) return 'warning';
105
120
  const message = error instanceof Error ? error.message
106
121
  : typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string' ? error.message : String(error);
107
122
  // includes, not startsWith: a title drop reports it as `<what>: <reason>` (src/client/app/entry.ts showDrop).
@@ -117,7 +132,7 @@ function productionPage(): boolean {
117
132
 
118
133
  function loadSdk(): Promise<BrowserSdk | null> {
119
134
  if (!productionPage()) return Promise.resolve(null);
120
- sdk ??= import('@sentry/browser').then((sentry) => {
135
+ sdk ??= import('@sentry/browser').then(async (sentry) => {
121
136
  const environment = browserErrorEnvironment(location.origin, installedIdentity()?.errorReportEnvironments ?? {});
122
137
  const version = typeof __ENGINE_RELEASE__ === 'object' ? __ENGINE_RELEASE__.version : undefined;
123
138
  sentry.init({
@@ -148,6 +163,9 @@ function loadSdk(): Promise<BrowserSdk | null> {
148
163
  return event;
149
164
  },
150
165
  });
166
+ // DEVICE-TELEMETRY DT2: the device's snapshot as the `device` context and `device.*` tags, loaded with the SDK (never on the title)
167
+ try { const { applySentryDevice, deviceSnapshot } = await import('./deviceSnapshot'); applySentryDevice(sentry, await deviceSnapshot(), dsn); }
168
+ catch { /* a report goes without it */ }
151
169
  return sentry;
152
170
  // S13: a failed chunk load (a stale page, the network) must not silence every later report on this page; the next one tries again
153
171
  }).catch(() => { sdk = null; return null; });
@@ -187,6 +205,12 @@ function asError(error: unknown): Error {
187
205
  * the outbox only once Sentry acknowledges it, so a page that reloads, goes to the title or dies right after still delivers it
188
206
  * (the next page sends it with the same event id, so Sentry keeps one).
189
207
  */
208
+ /** S18: the tags for a screen engine code opens outside any level (the loading card's RETRY): this page's build, no level */
209
+ export function engineScreenTags(screen: ErrorScreen, system: string, bootStage: string, diagnostic?: Record<string, unknown>): BrowserErrorTags {
210
+ let build = ''; try { build = __BUILD_ID__; } catch { /* under Node */ }
211
+ return { system, build, shard: '', bootStage, fatal: false, screen, ...(diagnostic === undefined ? {} : { diagnostic }) };
212
+ }
213
+
190
214
  export function captureBrowserError(error: unknown, tags: BrowserErrorTags): void {
191
215
  if (!dsn || !productionPage()) return;
192
216
  if (tags.screen !== undefined) { reportScreen(error, tags); return; }
@@ -215,7 +239,7 @@ export async function deliverBrowserError(error: Error, tags: BrowserErrorTags,
215
239
  try {
216
240
  sentry.withScope((scope) => {
217
241
  scope.setTags(tagsOf(tags));
218
- scope.setLevel(browserErrorLevel(error, tags.screen !== undefined && tags.fatal));
242
+ scope.setLevel(browserErrorLevel(error, tags.screen !== undefined && tags.fatal, tags.screen));
219
243
  if (tags.diagnostic) scope.setContext('boot_diagnostic', tags.diagnostic);
220
244
  sentId = sentry.captureException(error, eventId === undefined ? undefined : { event_id: eventId });
221
245
  });
@@ -0,0 +1,155 @@
1
+ // DEVICE-TELEMETRY DT1 (meta docs/plans/DEVICE-TELEMETRY-PLAN.md): one snapshot of the device this page runs on, gathered once per page,
2
+ // for the door's `client.device` line (shell.ts sends it on each socket) and Sentry's `device` context (browserErrors.ts).
3
+ // Every field is optional and every read is failure-safe: a browser without an API gives fewer fields, never a throw.
4
+ // Privacy line: device characteristics only, the ones any page can read. No IP address, no new persistent identifier, no fingerprint
5
+ // hash, and nothing that reads files, contacts, sensors, the camera, the microphone or location.
6
+ import { Scope } from '../../../shared/engine/app/scope';
7
+ import { cleanDevice, deviceTags, type DeviceSnapshot } from '../../../shared/engine/net/deviceWord';
8
+
9
+ declare const __BUILD_ID__: string | undefined;
10
+
11
+ /** What the snapshot reads; the page's globals by default, fakes in a test. */
12
+ export interface DeviceSources {
13
+ readonly navigator?: unknown;
14
+ readonly screen?: unknown;
15
+ readonly devicePixelRatio?: unknown;
16
+ readonly matchMedia?: (query: string) => { readonly matches: boolean };
17
+ readonly timeZone?: () => string | undefined;
18
+ readonly build?: string;
19
+ }
20
+
21
+ /** What the game's own WebGL context says (never a new context). */
22
+ export type DeviceGpu = Pick<DeviceSnapshot, 'gpu' | 'gpuVendor' | 'maxTexture' | 'astc' | 'etc2' | 'bptc'>;
23
+
24
+ const HIGH_ENTROPY = ['model', 'platform', 'platformVersion', 'architecture', 'bitness', 'fullVersionList', 'formFactors', 'wow64'];
25
+ /** Client Hints can hang on a browser that never answers; the snapshot waits at most this long for them. */
26
+ const HINTS_WAIT_MS = 1500;
27
+
28
+ type Rec = Record<string, unknown>;
29
+ /** A property read that never throws (a getter may). */
30
+ const read = (from: unknown, key: string): unknown => {
31
+ if (typeof from !== 'object' && typeof from !== 'function') return undefined;
32
+ if (from === null) return undefined;
33
+ try { return (from as Rec)[key]; } catch { return undefined; }
34
+ };
35
+ const said = (value: unknown): string => typeof value === 'string' || typeof value === 'number' ? String(value) : '';
36
+ const brandList = (value: unknown): string[] | undefined => Array.isArray(value)
37
+ ? value.map(entry => `${said(read(entry, 'brand'))} ${said(read(entry, 'version'))}`.trim()).filter(Boolean) : undefined;
38
+
39
+ async function hints(nav: unknown): Promise<Rec> {
40
+ const data = read(nav, 'userAgentData');
41
+ const out: Rec = { brands: brandList(read(data, 'brands')), mobile: read(data, 'mobile'), platform: read(data, 'platform') };
42
+ const ask = read(data, 'getHighEntropyValues');
43
+ if (typeof ask !== 'function') return out;
44
+ const scope = new Scope('device.hints');
45
+ try {
46
+ const asked = Promise.resolve((ask as (hints: string[]) => unknown).call(data, HIGH_ENTROPY));
47
+ const values = await Promise.race([asked, new Promise(resolve => { scope.timeout(HINTS_WAIT_MS, () => { resolve(null); }); })]);
48
+ if (values === null || typeof values !== 'object') return out;
49
+ for (const key of ['model', 'platform', 'platformVersion', 'architecture', 'bitness', 'wow64', 'formFactors']) {
50
+ const value = read(values, key);
51
+ if (value !== undefined && value !== '') out[key] = value;
52
+ }
53
+ out['fullVersionList'] = brandList(read(values, 'fullVersionList'));
54
+ } catch { /* a refused hint leaves the low-entropy ones */ } finally { scope.dispose(); }
55
+ return out;
56
+ }
57
+
58
+ function media(sources: DeviceSources, query: string): boolean | undefined {
59
+ try { return sources.matchMedia?.(query).matches; } catch { return undefined; }
60
+ }
61
+
62
+ /** The snapshot from `sources`, without the GPU. Never throws. */
63
+ export async function collectDevice(sources: DeviceSources): Promise<DeviceSnapshot> {
64
+ const nav = sources.navigator, screen = sources.screen, out: Rec = { build: sources.build };
65
+ try { Object.assign(out, await hints(nav)); } catch { /* none */ }
66
+ out['ua'] = read(nav, 'userAgent');
67
+ out['screenW'] = read(screen, 'width'); out['screenH'] = read(screen, 'height');
68
+ out['availW'] = read(screen, 'availWidth'); out['availH'] = read(screen, 'availHeight');
69
+ out['orientation'] = read(read(screen, 'orientation'), 'type');
70
+ out['dpr'] = sources.devicePixelRatio;
71
+ out['cores'] = read(nav, 'hardwareConcurrency'); out['memory'] = read(nav, 'deviceMemory'); out['touch'] = read(nav, 'maxTouchPoints');
72
+ out['pointer'] = media(sources, '(pointer: coarse)') === true ? 'coarse' : media(sources, '(pointer: fine)') === true ? 'fine' : media(sources, '(pointer: none)') === true ? 'none' : undefined;
73
+ out['hover'] = media(sources, '(hover: hover)');
74
+ out['language'] = read(nav, 'language');
75
+ const languages = read(nav, 'languages');
76
+ out['languages'] = Array.isArray(languages) ? [...languages as unknown[]] : undefined;
77
+ try { out['timeZone'] = sources.timeZone?.(); } catch { /* none */ }
78
+ const connection = read(nav, 'connection');
79
+ out['net'] = read(connection, 'effectiveType'); out['downlink'] = read(connection, 'downlink'); out['saveData'] = read(connection, 'saveData');
80
+ out['display'] = (['standalone', 'fullscreen', 'minimal-ui', 'browser'] as const).find(mode => media(sources, `(display-mode: ${mode})`) === true);
81
+ return cleanDevice(out);
82
+ }
83
+
84
+ /** What the game's own context says about its GPU: the unmasked names, the largest texture, and the compressed forms it takes. Never throws. */
85
+ export function gpuFacts(gl: Pick<WebGLRenderingContext, 'getExtension' | 'getParameter' | 'RENDERER' | 'VENDOR' | 'MAX_TEXTURE_SIZE'>): DeviceGpu {
86
+ const out: Rec = {};
87
+ try {
88
+ const info: { UNMASKED_RENDERER_WEBGL: number; UNMASKED_VENDOR_WEBGL: number } | null = gl.getExtension('WEBGL_debug_renderer_info');
89
+ out['gpu'] = gl.getParameter(info === null ? gl.RENDERER : info.UNMASKED_RENDERER_WEBGL);
90
+ out['gpuVendor'] = gl.getParameter(info === null ? gl.VENDOR : info.UNMASKED_VENDOR_WEBGL);
91
+ } catch { /* a lost context names nothing */ }
92
+ try { out['maxTexture'] = gl.getParameter(gl.MAX_TEXTURE_SIZE); } catch { /* none */ }
93
+ const has = (name: string): boolean | undefined => { try { return gl.getExtension(name) !== null; } catch { return undefined; } };
94
+ out['astc'] = has('WEBGL_compressed_texture_astc'); out['etc2'] = has('WEBGL_compressed_texture_etc'); out['bptc'] = has('EXT_texture_compression_bptc');
95
+ return cleanDevice(out);
96
+ }
97
+
98
+ /** The noted GPU lives on the window, not in this module: the online shell and the game can be separate bundles of the engine. */
99
+ const GPU_KEY = Symbol.for('wildshard.deviceGpu');
100
+ interface GpuHolder { [GPU_KEY]?: { facts: DeviceGpu | null; waiting: ((facts: DeviceGpu) => void)[] } }
101
+ const holder = (): NonNullable<GpuHolder[typeof GPU_KEY]> => {
102
+ const host = globalThis as GpuHolder;
103
+ host[GPU_KEY] ??= { facts: null, waiting: [] };
104
+ return host[GPU_KEY];
105
+ };
106
+
107
+ /** The renderer's context is up (bootstrap.ts): note what it says, once per page. */
108
+ export function noteDeviceGpu(gl: Parameters<typeof gpuFacts>[0]): void {
109
+ try {
110
+ const held = holder();
111
+ if (held.facts !== null) return;
112
+ held.facts = gpuFacts(gl);
113
+ for (const wake of held.waiting.splice(0)) wake(held.facts);
114
+ } catch { /* telemetry never disrupts the boot */ }
115
+ }
116
+
117
+ /** The GPU noted so far, waiting at most `waitMs` for the renderer. */
118
+ function noted(waitMs: number): Promise<DeviceGpu> {
119
+ const held = holder();
120
+ if (held.facts !== null || waitMs <= 0) return Promise.resolve(held.facts ?? {});
121
+ const scope = new Scope('device.gpu');
122
+ return new Promise<DeviceGpu>(resolve => {
123
+ const wake = (facts: DeviceGpu): void => { scope.dispose(); resolve(facts); };
124
+ scope.timeout(waitMs, () => { held.waiting = held.waiting.filter(entry => entry !== wake); scope.dispose(); resolve({}); });
125
+ held.waiting.push(wake);
126
+ });
127
+ }
128
+
129
+ let page: Promise<DeviceSnapshot> | null = null;
130
+ /** This page's snapshot: gathered once, with the GPU once the renderer has said it (at most `gpuWaitMs`). Never rejects. */
131
+ export async function deviceSnapshot(gpuWaitMs = 0): Promise<DeviceSnapshot> {
132
+ page ??= collectDevice(pageSources()).catch(() => ({}));
133
+ const [device, gpu] = await Promise.all([page, noted(gpuWaitMs)]);
134
+ return { ...device, ...gpu };
135
+ }
136
+
137
+ function pageSources(): DeviceSources {
138
+ const scope = globalThis as unknown as { navigator?: unknown; screen?: unknown; devicePixelRatio?: unknown; matchMedia?: (query: string) => { matches: boolean } };
139
+ const matchMedia = scope.matchMedia;
140
+ return {
141
+ navigator: scope.navigator, screen: scope.screen, devicePixelRatio: scope.devicePixelRatio,
142
+ ...(typeof matchMedia === 'function' ? { matchMedia: (query: string) => matchMedia.call(globalThis, query) } : {}),
143
+ timeZone: () => Intl.DateTimeFormat().resolvedOptions().timeZone,
144
+ ...(typeof __BUILD_ID__ === 'string' ? { build: __BUILD_ID__ } : {}),
145
+ };
146
+ }
147
+
148
+ /** The part of the Sentry SDK the device context needs. */
149
+ export interface SentryDeviceSink { setContext: (name: string, context: Record<string, unknown> | null) => void; setTags: (tags: Record<string, string>) => void }
150
+ /** DT2: Sentry's `device` context holds the whole snapshot, and its searchable tags are set (`device.model:*`). Only with a DSN built
151
+ * in, as every Sentry call; without one nothing is called. Never throws. */
152
+ export function applySentryDevice(sentry: SentryDeviceSink, device: DeviceSnapshot, dsn: string): boolean {
153
+ if (dsn === '') return false;
154
+ try { sentry.setContext('device', { ...device }); sentry.setTags(deviceTags(device)); return true; } catch { return false; }
155
+ }
@@ -1,5 +1,6 @@
1
1
  import { takeStaleBuildNote, type StaleBuildNote } from '../saves/staleBuildNote';
2
- import { captureBrowserError, staleBuildReport } from './browserErrors';
2
+ import { saveStorage } from '../saves/slots';
3
+ import { captureBrowserError, engineScreenTags, staleBuildReport } from './browserErrors';
3
4
 
4
5
  /** STALE-BUILD SB6: report an earlier page's stale-build note (browserErrors.ts staleBuildReport), if there is one; the note is gone after this. */
5
6
  export function reportStaleBuild(take: () => StaleBuildNote | null = takeStaleBuildNote, capture: typeof captureBrowserError = captureBrowserError): void {
@@ -10,3 +11,23 @@ export function reportStaleBuild(take: () => StaleBuildNote | null = takeStaleBu
10
11
  capture(error, tags);
11
12
  } catch { /* telemetry never disrupts the boot */ }
12
13
  }
14
+
15
+ /** a claim this long before this document started is the reload that started it (lastEnd.ts SELF_RELOAD_MS) */
16
+ const SELF_RELOAD_MS = 3000;
17
+ /** S18: the session `boot.selfReload` claim as this document found it. Read it at boot: an online boot's settle clears it
18
+ * within seconds (browserChunkRecovery.ts settleRefusedBuild). */
19
+ export function selfReloadClaim(read: () => string | null = () => saveStorage('session').getItem('boot.selfReload')): string | null {
20
+ try { return read(); } catch { return null; }
21
+ }
22
+ /** SENTRY-TRIAGE S18: index.html's 12 s self-reload (RL3) stamps session `boot.selfReload` with the time, then reloads; it has
23
+ * no Sentry, so the page it reloaded into reports it. Only that page: a claim older than this document is an earlier one's.
24
+ * `read` is selfReloadClaim's reading at boot; chunk recovery's and GpuRecovery's claims are '1', never a time. stuck.ts's
25
+ * retry stamps a time too, but marks its reload (lastEnd.ts markReload), which index.html's script never does: the caller
26
+ * passes no claim for a marked reload (bootTrace.ts). */
27
+ export function reportSelfReload(read: () => string | null, startedAt: number = performance.timeOrigin, capture: typeof captureBrowserError = captureBrowserError): void {
28
+ try {
29
+ const at = Number(read());
30
+ if (!Number.isFinite(at) || at < 1e12 || at > startedAt + 50 || startedAt - at >= SELF_RELOAD_MS) return;
31
+ capture(new Error("the page's entry never arrived; index.html reloaded it after 12 s"), engineScreenTags('self-reload', 'boot', 'loading'));
32
+ } catch { /* telemetry never disrupts the boot */ }
33
+ }
@@ -147,7 +147,7 @@ const earlyProgramsRow: DebugRow = { id: 'earlyPrograms', group: 'loading', labe
147
147
  note: 'DL10: compile the spawn view\'s shader programs during loading, as soon as the world is built; default off until a Simulator / iPhone reading.',
148
148
  ask: 'E526', reviewBy: '2026-12-30' };
149
149
  /** LF1-4 (meta TEMPLATE-E2E-PLAN): a look's optional light and post settings (contact AO, a warm rim, height fog, light
150
- * pools, a declared bloom; render/lookLight.ts). Read at load, so a pick reloads; default off until Jake picks. */
150
+ * pools, a declared bloom; render/lookLight.ts). Read at load, so a pick reloads; default on for desktop since TEMPLATES-CLEANROOM B2. */
151
151
  const lookLightRow: DebugRow = { id: 'lookLight', group: 'look', label: engineString('s_debug_look_light'), reload: true, when: always,
152
152
  choices: () => [{ v: 'off', text: engineString('s_ca7981b46ecf') }, { v: 'on', text: engineString('s_130011756125') }],
153
153
  get: () => lookLightSaved() ? 'on' : 'off',
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Settings ▸ Debug ▸ Look ▸ "Look light" (meta TEMPLATE-E2E-PLAN LF1-4): whether a look's optional light and post settings
3
- * (`look.light`, `look.grade.bloom`; `render/lookLight.ts`) draw. Default off until Jake picks; read at load, so a pick
3
+ * (`look.light`, `look.grade.bloom`; `render/lookLight.ts`) draw. Default on for the desktop tier since TEMPLATES-CLEANROOM
4
+ * B2 (was off until Jake picked; Jake's 2026-11-13 cleanroom port asks for the look as authored); read at load, so a pick
4
5
  * reloads the page.
5
6
  */
6
7
  import { jsonSlot } from '../saves/slots';
@@ -9,14 +10,17 @@ import { TIER } from '../core/tier';
9
10
  /** the saved slot's key */
10
11
  export const LOOK_LIGHT_SLOT = 'debug.lookLight';
11
12
 
12
- /** The row's saved value: 'on' or 'off' (anything else, or no storage: off). */
13
+ /**
14
+ * The row's saved value: on unless saved 'off' (TEMPLATES-CLEANROOM B2: a look's declared light is how its author asked
15
+ * it to look, so it draws by default; no storage: on).
16
+ */
13
17
  export function lookLightSaved(): boolean {
14
- try { return jsonSlot(LOOK_LIGHT_SLOT, 'device').read() === 'on'; } catch { return false; }
18
+ try { return jsonSlot(LOOK_LIGHT_SLOT, 'device').read() !== 'off'; } catch { return true; }
15
19
  }
16
20
  /**
17
- * Whether the settings draw on this page: the row on, and the desktop tier. The phone tier draws none of them until
18
- * Jake picks (its 30 fps lock and program set stay as they are).
21
+ * Whether the settings draw on this page: the row on. TEMPLATES-CLEANROOM M4.9: the phone tier draws them too, gated per
22
+ * field (`lookLightManifest`: no bloom or AO, at most 4 lamps, half the motes), not all or nothing; `tier` stays for callers.
19
23
  */
20
- export function lookLightOn(tier: string = TIER): boolean { return tier !== 'phone' && lookLightSaved(); }
24
+ export function lookLightOn(_tier: string = TIER): boolean { return lookLightSaved(); }
21
25
  /** Save the row's value (the page reloads to apply it). */
22
26
  export function setLookLight(on: boolean): void { jsonSlot(LOOK_LIGHT_SLOT, 'device').write(on ? 'on' : 'off'); }
@@ -137,3 +137,10 @@ export function nameSettingRows(scope: Scope): HTMLElement[] {
137
137
  });
138
138
  return [row, note];
139
139
  }
140
+
141
+ /** OFFLINE OF11 (J298): a page joining the world asks the Name only with a link. Offline it goes on as Skip would, without
142
+ * marking the device asked, so Worker boot never waits on a prompt the world can't hear yet and the next online join asks. */
143
+ export function askNameToJoin(scope: Scope, options: Omit<NamePromptOptions, 'current'>, online: boolean = navigator.onLine): Promise<boolean> {
144
+ if (!online) return Promise.resolve(true);
145
+ return askNameOnce(scope, options);
146
+ }