@wildshard/engine 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +14 -0
  5. package/lint/ratchet.json +0 -68
  6. package/lint/ratchet.mjs +1 -4
  7. package/package.json +17 -15
  8. package/scripts/agent-sync.mjs +27 -8
  9. package/scripts/app-build/appCook.ts +8 -2
  10. package/scripts/app-build/catalogue.ts +10 -7
  11. package/scripts/app-build/gen.ts +22 -2
  12. package/scripts/app-build/isolation.d.mts +10 -0
  13. package/scripts/app-build/isolation.mjs +47 -0
  14. package/scripts/app-build/outputProducts.mjs +4 -0
  15. package/scripts/app-build/previousDeploy.d.mts +2 -0
  16. package/scripts/app-build/previousDeploy.mjs +10 -1
  17. package/scripts/app-build/serviceWorker.ts +10 -3
  18. package/scripts/app-build/splitOutput.mjs +4 -2
  19. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  20. package/scripts/app-build/standaloneOutput.mjs +5 -3
  21. package/scripts/app-build/titlePreloads.d.mts +8 -0
  22. package/scripts/app-build/titlePreloads.mjs +69 -0
  23. package/scripts/app-build/worldMapAtlas.ts +10 -6
  24. package/scripts/app-build-pipeline.mjs +31 -3
  25. package/scripts/built-product.mjs +1 -1
  26. package/scripts/cell-mem-bench.mjs +81 -23
  27. package/scripts/check-custom-sections-zero.mjs +1 -1
  28. package/scripts/check-devserver.mjs +2 -0
  29. package/scripts/check-models.mjs +2 -0
  30. package/scripts/check-paths.allow.json +0 -115
  31. package/scripts/check-paths.mjs +2 -2
  32. package/scripts/check-platform-ratchets.mjs +2 -3
  33. package/scripts/chromium-keychain.d.mts +1 -1
  34. package/scripts/ci-static.sh +1 -1
  35. package/scripts/committed-fast-checks.mjs +0 -2
  36. package/scripts/content-sw-proof.mjs +2 -1
  37. package/scripts/cook-worker.mjs +9 -3
  38. package/scripts/cook.mjs +18 -5
  39. package/scripts/docs-inputs-proof.mjs +6 -6
  40. package/scripts/e7-voice-staging-proof.mjs +1 -1
  41. package/scripts/gate-related-tests.mjs +1 -1
  42. package/scripts/git-source-view.mjs +1 -1
  43. package/scripts/goldens/capture.mjs +17 -5
  44. package/scripts/grid-crossing-nightly.mjs +59 -0
  45. package/scripts/grid-crossing-qa.mjs +44 -0
  46. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  47. package/scripts/grid-crossing-ratchet.mjs +52 -0
  48. package/scripts/grid-crossing-report.mjs +122 -0
  49. package/scripts/grid-crossing-stages.mjs +47 -0
  50. package/scripts/grid-crossing-tour.mjs +277 -0
  51. package/scripts/grid-crossing-walk-proof.mjs +124 -17
  52. package/scripts/host-ruler/roots.mjs +2 -2
  53. package/scripts/host-ruler.d.mts +91 -0
  54. package/scripts/host-ruler.mjs +565 -0
  55. package/scripts/live-prepush.py +3 -5
  56. package/scripts/loading-flow/benchmax.mjs +3 -1
  57. package/scripts/look-loop/test_look_loop.py +1 -38
  58. package/scripts/memory-proof.mjs +61 -6
  59. package/scripts/mmo-bots.mjs +8 -2
  60. package/scripts/net-lag-proof.mjs +219 -0
  61. package/scripts/night-market-kit-budget.mjs +2 -2
  62. package/scripts/offline-proof-rules.d.mts +2 -2
  63. package/scripts/offline-proof-rules.mjs +15 -4
  64. package/scripts/offline-proof.mjs +74 -13
  65. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  66. package/scripts/page-release/content.d.mts +9 -1
  67. package/scripts/page-release/content.mjs +131 -17
  68. package/scripts/page-release/flow.mjs +36 -10
  69. package/scripts/page-release/stamp-content.mjs +24 -0
  70. package/scripts/page-release.mjs +28 -6
  71. package/scripts/page-size.mjs +2 -1
  72. package/scripts/pin-packs.ts +1 -1
  73. package/scripts/pins.ts +4 -4
  74. package/scripts/precommit-checks.mjs +1 -7
  75. package/scripts/precommit-jobs.mjs +0 -1
  76. package/scripts/precommit-source.py +1 -9
  77. package/scripts/program-discovery.mjs +1 -1
  78. package/scripts/ring-cook.mjs +2 -1
  79. package/scripts/ring-step.ts +1 -1
  80. package/scripts/script-scenario-metrics.mjs +1 -1
  81. package/scripts/shard-output-content.d.mts +1 -1
  82. package/scripts/shard-output-content.mjs +2 -2
  83. package/scripts/shard-outputs.mjs +1 -1
  84. package/scripts/shard-public.mjs +1 -1
  85. package/scripts/shard-wire-meter.mjs +24 -9
  86. package/scripts/side-parity.mjs +4 -2
  87. package/scripts/standalone-smoke.mjs +8 -3
  88. package/scripts/tier-textures.mjs +22 -4
  89. package/scripts/tile-bake-report.mjs +1 -1
  90. package/scripts/tile-bakes.mjs +1 -1
  91. package/scripts/title-assets.generated.json +2 -0
  92. package/scripts/tsconfig.json +0 -2
  93. package/scripts/vendor/basisu/LICENSE +201 -0
  94. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  95. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  96. package/scripts/vitest-push-guards.config.ts +1 -1
  97. package/scripts/vps/harden-apply.sh +4 -1
  98. package/scripts/vps/harden-prometheus.sh +176 -0
  99. package/scripts/vps/harden.sh +16 -0
  100. package/scripts/vps/rebuild.sh +18 -0
  101. package/scripts/vps/wildshard-config +6 -2
  102. package/scripts/worker-client-play.mjs +6 -2
  103. package/scripts/worktree-reap.mjs +5 -5
  104. package/src/.oxlintrc.json +3 -182
  105. package/src/client/app/entry.ts +10 -2
  106. package/src/client/engine/boot/bootCache.ts +2 -2
  107. package/src/client/engine/boot/bootTrace.ts +12 -4
  108. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  109. package/src/client/engine/boot/clearDownloads.ts +5 -2
  110. package/src/client/engine/boot/contentRead.ts +11 -0
  111. package/src/client/engine/boot/gpuFiles.ts +4 -2
  112. package/src/client/engine/boot/lastEnd.ts +99 -12
  113. package/src/client/engine/boot/texturePack.ts +2 -2
  114. package/src/client/engine/net/netPlayer.ts +19 -2
  115. package/src/client/engine/net/otherPlayers.ts +55 -8
  116. package/src/client/engine/net/predictor.ts +33 -9
  117. package/src/client/engine/net/redial.ts +29 -6
  118. package/src/client/engine/pwa/cacheNames.ts +58 -1
  119. package/src/client/engine/pwa/sw.js +41 -11
  120. package/src/client/engine/render/dataLook.ts +152 -40
  121. package/src/client/engine/render/families/detail.ts +89 -0
  122. package/src/client/engine/render/families/pbr.ts +7 -1
  123. package/src/client/engine/render/look.ts +6 -0
  124. package/src/client/engine/render/lookLight.ts +103 -11
  125. package/src/client/engine/render/lookRender.ts +105 -0
  126. package/src/client/engine/saves/indexed.ts +2 -2
  127. package/src/client/engine/telemetry/browserErrors.ts +24 -3
  128. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  129. package/src/client/engine/ui/debugOptions.ts +1 -1
  130. package/src/client/engine/ui/lookLightOption.ts +10 -6
  131. package/src/client/engine/ui/namePrompt.ts +7 -0
  132. package/src/client/game/boot/audio.generated.ts +114 -114
  133. package/src/client/game/boot/bytes.generated.ts +118 -220
  134. package/src/client/game/boot/placedSpawn.ts +35 -0
  135. package/src/client/game/boot/spawnDownload.ts +25 -6
  136. package/src/client/game/boot/versions.generated.ts +7 -5
  137. package/src/client/game/devScene/hook.ts +291 -0
  138. package/src/client/game/grid/cellLoading.ts +12 -2
  139. package/src/client/game/grid/live.ts +112 -16
  140. package/src/client/game/grid/liveSession.ts +33 -2
  141. package/src/client/game/grid/mapAtlas.ts +18 -4
  142. package/src/client/game/grid/minimapBlend.ts +15 -5
  143. package/src/client/game/grid/oneWayIn.ts +5 -1
  144. package/src/client/game/grid/placedCells.ts +114 -12
  145. package/src/client/game/grid/placedContent.ts +85 -0
  146. package/src/client/game/grid/prefetch.ts +9 -1
  147. package/src/client/game/grid/productInputs.ts +3 -1
  148. package/src/client/game/grid/productLeases.ts +4 -1
  149. package/src/client/game/grid/products.ts +8 -4
  150. package/src/client/game/grid/roadLook.ts +24 -15
  151. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  152. package/src/client/game/grid/roadResources.ts +24 -0
  153. package/src/client/game/grid/roadSign.worker.ts +4 -3
  154. package/src/client/game/grid/roadSignPaint.ts +16 -5
  155. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  156. package/src/client/game/grid/roadSignScale.ts +8 -0
  157. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  158. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  159. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  160. package/src/client/game/grid/roadTileWriter.ts +2 -1
  161. package/src/client/game/grid/screenReports.ts +39 -0
  162. package/src/client/game/grid/session.ts +20 -4
  163. package/src/client/game/grid/softWallLook.ts +25 -8
  164. package/src/client/game/mainMenu.ts +6 -2
  165. package/src/client/game/plugin/context.ts +2 -1
  166. package/src/client/game/plugin/followedMovers.ts +7 -1
  167. package/src/client/game/quest/figures.ts +2 -0
  168. package/src/client/game/session/finish.ts +6 -0
  169. package/src/client/game/shardfile/assetCache.ts +4 -4
  170. package/src/client/game/shardfile/client.ts +4 -1
  171. package/src/client/game/shardfile/clientAssets.ts +9 -5
  172. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  173. package/src/client/game/shardfile/clientWater.ts +51 -9
  174. package/src/client/game/shardfile/clientWorker.ts +19 -7
  175. package/src/client/game/shardfile/look.ts +8 -3
  176. package/src/client/game/shardfile/product.ts +34 -7
  177. package/src/client/game/shardfile/productChecks.ts +2 -2
  178. package/src/client/game/shardfile/productCost.ts +2 -2
  179. package/src/client/game/shardfile/readAsset.ts +2 -2
  180. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  181. package/src/client/game/shardfile/seatGrace.ts +9 -0
  182. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  183. package/src/client/game/systems/npc/figureRows.ts +9 -0
  184. package/src/client/host/online/doctor.ts +2 -0
  185. package/src/client/host/online/linkScreens.ts +30 -4
  186. package/src/client/host/standalone/shell.ts +4 -0
  187. package/src/cook/game/astc6Encode.ts +55 -0
  188. package/src/cook/game/astc6Wasm.ts +176 -0
  189. package/src/cook/game/cookJob.ts +30 -6
  190. package/src/cook/game/cookWorker.ts +38 -11
  191. package/src/cook/game/entryTotals.ts +51 -24
  192. package/src/cook/game/shardCook.ts +35 -7
  193. package/src/cook/game/spawnParts.ts +33 -8
  194. package/src/cook/game/tierTextures.ts +87 -14
  195. package/src/server/engine/ai/bossContenders.ts +27 -3
  196. package/src/server/engine/ai/phases.ts +1 -1
  197. package/src/server/engine/entities/creatureRefill.ts +9 -2
  198. package/src/server/engine/net/ledgerBook.ts +2 -0
  199. package/src/server/engine/net/room.ts +15 -0
  200. package/src/server/engine/sim/respawn.ts +8 -0
  201. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  202. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  203. package/src/server/game/boss/native.ts +2 -1
  204. package/src/server/game/boss/nativeWake.ts +9 -5
  205. package/src/server/game/boss/openArenaNative.ts +2 -2
  206. package/src/server/game/boss/openArenaRoom.ts +3 -1
  207. package/src/server/game/grid/room.ts +44 -3
  208. package/src/server/game/grid/simulation.ts +23 -0
  209. package/src/server/game/population/mixedRoster.ts +11 -3
  210. package/src/server/game/population/nativeBake.ts +8 -3
  211. package/src/server/game/population/nativeReturns.ts +6 -3
  212. package/src/server/game/population/roster.ts +5 -3
  213. package/src/server/game/quest/eliteDrops.ts +15 -4
  214. package/src/server/game/quest/nativeChapter.ts +1 -1
  215. package/src/server/game/quest/nativeComposition.ts +5 -1
  216. package/src/server/game/riding/nativeTaming.ts +10 -6
  217. package/src/server/game/riding/wildRefill.ts +3 -2
  218. package/src/server/game/shardfile/bossRow.ts +4 -2
  219. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  220. package/src/server/host/bake/headlessWorker.ts +1 -1
  221. package/src/server/host/dedicated/cellHost.ts +98 -16
  222. package/src/server/host/dedicated/cellProtocol.ts +16 -1
  223. package/src/server/host/dedicated/cellWorker.ts +8 -5
  224. package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
  225. package/src/server/host/dedicated/gridCells.ts +15 -6
  226. package/src/server/host/dedicated/loopLag.ts +21 -0
  227. package/src/server/host/dedicated/main.ts +13 -5
  228. package/src/server/host/dedicated/packReader.ts +3 -3
  229. package/src/server/host/dedicated/placementFile.ts +3 -2
  230. package/src/server/host/dedicated/roadRoom.ts +34 -4
  231. package/src/server/host/dedicated/serverMetrics.ts +126 -0
  232. package/src/server/host/dedicated/socketPump.ts +21 -4
  233. package/src/server/host/dedicated/workerTable.ts +15 -4
  234. package/src/server/host/dedicated/world.ts +65 -7
  235. package/src/server/host/headless.ts +1 -1
  236. package/src/server/host/headlessRuntime.ts +1 -1
  237. package/src/server/host/standalone/roadWorld.ts +15 -3
  238. package/src/server/host/standalone/serverHost.ts +4 -1
  239. package/src/server/host/standalone/serverProduct.ts +41 -11
  240. package/src/shared/engine/ai/BossBrain.ts +8 -0
  241. package/src/shared/game/boss/wake.ts +6 -0
  242. package/src/shared/game/devColliders.ts +47 -0
  243. package/src/shared/game/eliteSystem.ts +8 -0
  244. package/src/shared/game/grid/allocator.ts +3 -0
  245. package/src/shared/game/grid/placementRows.ts +5 -2
  246. package/src/shared/game/plugin/bossRecord.ts +3 -2
  247. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  248. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  249. package/src/shared/game/shardfile/packReads.ts +28 -3
  250. package/src/shared/game/shardfile/serverPack.ts +9 -0
  251. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  252. package/src/shared/host/formatJsonSchema.ts +2 -2
  253. package/src/tsconfig.json +1 -27
  254. package/lint/host-reviews.json +0 -14
  255. package/lint/listed-view-code.json +0 -13
  256. package/lint/platform-pending-users.json +0 -2520
  257. package/lint/platform-pending-users.md +0 -18
  258. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  259. package/scripts/check-closed-components.d.mts +0 -7
  260. package/scripts/check-closed-components.mjs +0 -87
  261. package/scripts/g571-hosts.d.mts +0 -3
  262. package/scripts/g571-hosts.mjs +0 -54
  263. package/scripts/host-ruler/register-migrate.mjs +0 -242
  264. package/scripts/listed-view-code.d.mts +0 -7
  265. package/scripts/listed-view-code.mjs +0 -93
  266. package/scripts/look-loop/fit-lut.py +0 -142
  267. package/scripts/look-loop/palette-delta.py +0 -183
  268. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  269. package/scripts/look-loop/regions/far-reach.json +0 -225
  270. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  271. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  272. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  273. package/scripts/platform-chargebacks.d.mts +0 -9
  274. package/scripts/platform-chargebacks.mjs +0 -135
  275. package/scripts/shard-component-spans.d.mts +0 -15
  276. package/scripts/shard-component-spans.mjs +0 -18
  277. package/scripts/shard-components.d.mts +0 -16
  278. package/scripts/shard-components.mjs +0 -363
  279. package/scripts/shard-platform-hosts.d.mts +0 -2
  280. package/scripts/shard-platform-hosts.mjs +0 -93
  281. package/scripts/shard-platform-sections.d.mts +0 -2
  282. package/scripts/shard-platform-sections.mjs +0 -9
  283. package/scripts/shard-platform.d.mts +0 -76
  284. package/scripts/shard-platform.mjs +0 -1072
  285. package/src/.oxfmtrc.json +0 -48
  286. package/src/scripts/ask-new.sh +0 -29
  287. package/src/scripts/asks.mjs +0 -142
  288. package/src/scripts/herdr-prompt.sh +0 -34
  289. package/src/scripts/herdr-question-open.sh +0 -67
  290. package/src/scripts/md-wrap.mjs +0 -229
  291. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  292. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  293. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -1,4 +1,4 @@
1
- import { ASSET_CACHE_NAME } from '@wildshard/engine/pwa/cacheNames';
1
+ import { assetCacheName } from '@wildshard/engine/pwa/cacheNames';
2
2
  import { readContentResponse } from '@wildshard/engine/boot/readContentResponse';
3
3
 
4
4
  type ReadStorage = Pick<CacheStorage, 'open'> & Partial<Pick<CacheStorage, 'match'>>;
@@ -7,9 +7,9 @@ type ReadStorage = Pick<CacheStorage, 'open'> & Partial<Pick<CacheStorage, 'matc
7
7
  async function matchAsset(storage: ReadStorage, url: string): Promise<Response | undefined> {
8
8
  try {
9
9
  const match = storage.match;
10
- if (match !== undefined) return await match.call(storage, url, { cacheName: ASSET_CACHE_NAME, ignoreVary: true });
10
+ if (match !== undefined) return await match.call(storage, url, { cacheName: assetCacheName(), ignoreVary: true });
11
11
  } catch { /* The existing read port may still be available. */ }
12
- return (await storage.open(ASSET_CACHE_NAME)).match(url, { ignoreVary: true });
12
+ return (await storage.open(assetCacheName())).match(url, { ignoreVary: true });
13
13
  }
14
14
 
15
15
  /** Shared service-worker URL storage, without a page index, queue or leases. */
@@ -38,7 +38,7 @@ export async function cacheAsset(storage: Pick<CacheStorage, 'open'>, url: strin
38
38
  const type = path.endsWith('.wasm') ? 'application/wasm' : path.endsWith('.json') ? 'application/json'
39
39
  : path.endsWith('.glb') ? 'model/gltf-binary' : path.endsWith('.ktx2') ? 'image/ktx2' : 'application/octet-stream';
40
40
  try {
41
- await (await storage.open(ASSET_CACHE_NAME)).put(url, new Response(Uint8Array.from(bytes), {
41
+ await (await storage.open(assetCacheName())).put(url, new Response(Uint8Array.from(bytes), {
42
42
  headers: { 'content-type': type, 'content-length': String(bytes.length) },
43
43
  }));
44
44
  return true;
@@ -285,7 +285,10 @@ export class ShardfileClient {
285
285
  worldStep(ctx, 'item models');
286
286
  this.skins = await loadClientSkins(this.source, this.assets.retained, presentation.compile, ctx.scope);
287
287
  worldStep(ctx, 'skins');
288
- installClientWater(undrawnWater(this.source.water, this.plan?.features ?? []), { root: ctx.root, scope: ctx.scope, materials: presentation.materials, outline: presentation.outline });
288
+ // M4.6: a planar pool's ripples run on the game clock
289
+ const waterClocks: ((dt: number) => void)[] = [];
290
+ installClientWater(undrawnWater(this.source.water, this.plan?.features ?? []), { root: ctx.root, scope: ctx.scope, materials: presentation.materials, outline: presentation.outline, frame: (run) => { waterClocks.push(run); } });
291
+ if (waterClocks.length > 0) ctx.system({ id: 'game.shardfile.water', phase: 'update', run: (dt) => { for (const run of waterClocks) run(dt); } });
289
292
  const nativeWorld = this.nativeFeatures || this.mode === 'presentation';
290
293
  const start = nativeWorld ? ctx.manifest.spawn : this.source.spawn;
291
294
  const collider = nativeWorld && this.source.terrain !== null ? await this.assets.read(this.source.terrain.collider) : undefined;
@@ -4,9 +4,12 @@ import { memoryAttribution } from '@wildshard/engine/core/memoryAttribution';
4
4
 
5
5
  import { boundedResponse, type ProductOptions } from './product';
6
6
  import { outputBlobUrl, outputDescriptor } from '../../../shared/game/shardfile/outputDescriptor';
7
- import { readPackWhole, releasePackWholes } from '../../../shared/game/shardfile/packReads';
7
+ import { packMissing, packOrLoose, readPackWhole, releasePackWholes } from '../../../shared/game/shardfile/packReads';
8
8
  import type { Shardfile } from '@wildshard/format/shardSchema';
9
9
 
10
+ /** PZ7: the marker for "read this member loose" */
11
+ const LOOSE = new Uint8Array(0);
12
+
10
13
  /** Release admitted transport copies after decoding; revisiting a tile rechecks immutable bytes from cache or the product. */
11
14
  export class ClientAssets {
12
15
  private readonly wire: Map<string, Uint8Array>;
@@ -105,9 +108,10 @@ export class ClientAssets {
105
108
  const packs = outputDescriptor(this.source)?.index.packs;
106
109
  const pack = packs?.find(row => row.entries.some(entry => entry.hash === ref));
107
110
  const member = pack?.entries.find(entry => entry.hash === ref);
108
- if (packs === undefined || pack === undefined || member === undefined) return undefined;
111
+ if (packs === undefined || pack === undefined || member === undefined || packMissing(pack)) return undefined;
109
112
  if (member.bytes !== cap) throw new Error('Resident packed member size mismatch');
110
- const wire = await readPackWhole(packs, pack, async (path, maximum) => {
113
+ // PZ7: a pack that is not published (or fails) leaves the member to its loose blob (an abort still throws)
114
+ const wire = await packOrLoose(() => readPackWhole(packs, pack, async (path, maximum) => {
111
115
 
112
116
  const fetch = priority === 'low' ? this.options.backgroundFetch ?? this.options.fetch : this.options.fetch;
113
117
  const response = await fetch(new URL(path, this.options.base).href);
@@ -115,8 +119,8 @@ export class ClientAssets {
115
119
  const bytes = await boundedResponse(response, maximum);
116
120
 
117
121
  return this.observe(pack.hash, bytes);
118
- }, bytes => this.hashOf(bytes), this.options.hash);
119
- return wire.slice(member.offset, member.offset + member.bytes);
122
+ }, bytes => this.hashOf(bytes), this.options.hash), () => Promise.resolve(LOOSE));
123
+ return wire === LOOSE ? undefined : wire.slice(member.offset, member.offset + member.bytes);
120
124
  }
121
125
 
122
126
  /** SHA-256 of `bytes` off the page (an owned copy through `hashOwned`), else on the page. */
@@ -46,7 +46,7 @@ export async function leaseClientLibrary(source: Shardfile, assets: ReadonlyMap<
46
46
  }
47
47
  for (const hash of source.requires.commons) {
48
48
  const bytes = assets.get(`commons:${hash}`) ?? await ports.read?.(`commons:${hash}`); if (bytes === undefined) throw new Error('Missing admitted commons residency');
49
- const { assetCost, prepareAssetDecoders } = await import('@wildshard/format/product');
49
+ const { assetCost, prepareAssetDecoders } = await import('@wildshard/format/shardfileAssets');
50
50
  await prepareAssetDecoders();
51
51
  const cost = assetCost('commons', bytes);
52
52
  claims.push({ id: `commons:${hash}`, category: 'commons', bytes: cost.decoded + cost.gpu, owner: 'platform', distance: 0, needed: true });
@@ -5,12 +5,17 @@
5
5
  * a stream a ribbon through its points at their levels, the sea a cell-wide plane. The surface is `materials.get('water')`
6
6
  * when the look declares one, else the default water surface (`defaultWaterMaterial`, LF1-3: a no-code shard has no client
7
7
  * plan to draw a graph surface, so this is its pond); a graph surface that declares `stages.outline` draws its hull
8
- * through `outline` (`clientMaterials().outline`).
8
+ * through `outline` (`clientMaterials().outline`). A pool that declares its `surface` (TEMPLATES-CLEANROOM M4.6) draws
9
+ * that instead: a planar mirror on the desktop tier (`reflectingWater.ts`), the default surface in its tint and Fresnel
10
+ * otherwise.
9
11
  */
10
12
  import { BufferAttribute, BufferGeometry, CircleGeometry, Mesh, MeshStandardMaterial, PlaneGeometry, Shape, ShapeGeometry, Vector2, type Material, type Object3D } from 'three';
11
13
  import type { Scope } from '@wildshard/engine/app/scope';
12
14
  import { patchShader } from '@wildshard/engine/render/shaderPatches';
13
15
  import type { ShardWater } from '@wildshard/format/water';
16
+ import type { PoolSurface } from '@wildshard/format/pool-surface';
17
+ import { TIER } from '@wildshard/engine/core/tier';
18
+ import { mirrorPool } from './reflectingWater';
14
19
  import type { GraphOutlineHook } from './clientGraphs';
15
20
  import type { ClientFeatureRow } from '@wildshard/format/clientPlan';
16
21
 
@@ -51,9 +56,9 @@ export function undrawnWater(water: ShardWater, features: readonly ClientFeature
51
56
  * normal rippled from world position (faded with distance, so far water stays flat and does not shimmer), reflected
52
57
  * into a sky made from the shard's own light (its fog colour at the horizon, its hemisphere's sky colour above, its key
53
58
  * light's glint), Fresnel-weighted; the alpha rises with the Fresnel, so water looked into shows its bed. */
54
- const DEFAULT_WATER_GLSL = `{
59
+ const waterGlsl = (base: string, power: string, ripple: string, alpha: boolean): string => `{
55
60
  vec3 wsV = normalize(vViewPosition), wsUpV = normalize((viewMatrix * vec4(0.0, 1.0, 0.0, 0.0)).xyz);
56
- vec2 wsP = vWsWaterWorld.xz;
61
+ vec2 wsP = vWsWaterWorld.xz * ${ripple};
57
62
  float wsFade = 1.0 / (1.0 + length(vViewPosition) * 0.06);
58
63
  vec2 wsSlope = vec2(sin(wsP.x * 1.7 + sin(wsP.y * 0.9) * 1.3) + 0.6 * sin(wsP.y * 2.3 + wsP.x * 0.6),
59
64
  cos(wsP.y * 1.9 + sin(wsP.x * 1.1) * 1.2) + 0.5 * cos(wsP.x * 2.9 - wsP.y * 0.7)) * 0.045 * wsFade;
@@ -71,11 +76,13 @@ const DEFAULT_WATER_GLSL = `{
71
76
  float wsSun = max(dot(wsR, directionalLights[ 0 ].direction), 0.0);
72
77
  wsWaterSky += directionalLights[ 0 ].color * (pow(wsSun, 600.0) * 2.5 + pow(wsSun, 10.0) * 0.3);
73
78
  #endif
74
- float wsFres = 0.22 + 0.78 * pow(1.0 - clamp(dot(wsN, wsV), 0.0, 1.0), 3.0);
79
+ float wsFres = ${base} + (1.0 - ${base}) * pow(1.0 - clamp(dot(wsN, wsV), 0.0, 1.0), ${power});
75
80
  outgoingLight = mix(outgoingLight, wsWaterSky, wsFres);
76
- diffuseColor.a = mix(diffuseColor.a, 1.0, wsFres);
81
+ ${alpha ? 'diffuseColor.a = mix(diffuseColor.a, 1.0, wsFres);' : ''}
77
82
  }
78
83
  `;
84
+ const DEFAULT_WATER_GLSL = waterGlsl('0.22', '3.0', '1.0', true);
85
+ const glslFloat = (n: number): string => n.toFixed(4);
79
86
 
80
87
  /** The default water surface (LF1-3) for a declared body the look gives no `water` material: three's standard material
81
88
  * (so the engine's fog, shadow and light patches apply as to any other) with a deep tint, a sky reflection and a Fresnel
@@ -94,15 +101,50 @@ export function defaultWaterMaterial(): MeshStandardMaterial {
94
101
  return material;
95
102
  }
96
103
 
104
+ /** M4.6: a declared surface's sky water (`reflect: 'sky'`, or `planar` on the phone tier): the default surface's program
105
+ * with the surface's opaque tint, Fresnel and ripple scale (its own program, keyed by those values). */
106
+ export function skyWaterMaterial(look: PoolSurface): MeshStandardMaterial {
107
+ const material = new MeshStandardMaterial({ roughness: 0.12, metalness: 0 });
108
+ material.color.setRGB(look.tint[0], look.tint[1], look.tint[2]);
109
+ material.name = 'water-sky';
110
+ const glsl = waterGlsl(glslFloat(look.fresnel[0]), glslFloat(look.fresnel[1]), glslFloat(Math.max(0.05, look.ripple.scale / 2)), false);
111
+ const key = `m46-sky-water-${glsl.length}-${look.fresnel.join('-')}-${String(look.ripple.scale)}`;
112
+ patchShader(material, key, 100, (shader): void => {
113
+ shader.vertexShader = shader.vertexShader
114
+ .replace('#include <common>', '#include <common>\nvarying vec3 vWsWaterWorld;')
115
+ .replace('#include <project_vertex>', '#include <project_vertex>\nvWsWaterWorld = (modelMatrix * vec4(transformed, 1.0)).xyz;');
116
+ shader.fragmentShader = shader.fragmentShader
117
+ .replace('#include <common>', '#include <common>\nvarying vec3 vWsWaterWorld;')
118
+ .replace('#include <opaque_fragment>', `${glsl}#include <opaque_fragment>`);
119
+ }, { key });
120
+ return material;
121
+ }
122
+
97
123
  /** Draw every declared water body's surface under `root`; the scope takes the meshes, geometry and default material. */
98
- export function installClientWater(water: ShardWater, ports: { root: Object3D; scope: Scope; materials?: ReadonlyMap<string, Material>; outline?: GraphOutlineHook }): readonly Mesh[] {
124
+ export function installClientWater(water: ShardWater, ports: { root: Object3D; scope: Scope; materials?: ReadonlyMap<string, Material>; outline?: GraphOutlineHook; frame?: (run: (dt: number) => void) => void }, tier: string = TIER): readonly Mesh[] {
99
125
  if (water.length === 0) return [];
100
- const material = ports.materials?.get('water') ?? ports.scope.own(defaultWaterMaterial());
126
+ const declared = ports.materials?.get('water');
127
+ let fallback: Material | null = null;
128
+ const material = (): Material => declared ?? (fallback ??= ports.scope.own(defaultWaterMaterial()));
101
129
  return water.map((body) => {
102
- const mesh = new Mesh(ports.scope.own(surface(body)), material);
130
+ const look = body.kind === 'pool' ? body.surface : undefined;
131
+ if (body.kind === 'pool' && look !== undefined && declared === undefined) {
132
+ if (look.reflect === 'planar' && tier !== 'phone') {
133
+ const pool = mirrorPool(body.shape, body.level, look);
134
+ pool.mesh.name = `water:${body.id}`; pool.mesh.renderOrder = 1;
135
+ ports.root.add(pool.mesh); ports.scope.onDispose(() => { pool.mesh.removeFromParent(); pool.dispose(); });
136
+ ports.frame?.(pool.tick);
137
+ return pool.mesh;
138
+ }
139
+ const sky = ports.scope.own(skyWaterMaterial(look)), mesh = new Mesh(ports.scope.own(surface(body)), sky);
140
+ mesh.name = `water:${body.id}`; mesh.receiveShadow = true; mesh.castShadow = false; mesh.renderOrder = 1;
141
+ ports.root.add(mesh); ports.scope.onDispose(() => { mesh.removeFromParent(); });
142
+ return mesh;
143
+ }
144
+ const drawn = material(), mesh = new Mesh(ports.scope.own(surface(body)), drawn);
103
145
  mesh.name = `water:${body.id}`; mesh.receiveShadow = true; mesh.castShadow = false; mesh.renderOrder = 1;
104
146
  ports.root.add(mesh); ports.scope.onDispose(() => { mesh.removeFromParent(); });
105
- ports.outline?.(mesh, material, ports.scope);
147
+ ports.outline?.(mesh, drawn, ports.scope);
106
148
  return mesh;
107
149
  });
108
150
  }
@@ -1,6 +1,7 @@
1
1
  // P1-E5.3 I6 (J126), E6: every page runs the real Game and Player against the real server in its worker: the Player predicts and
2
2
  // reconciles, and every creature is an interpolated row drawn by the real views.
3
3
  import type { Scope } from '@wildshard/engine/app/scope';
4
+ import type { DevBox } from '@wildshard/engine/game/devColliders';
4
5
  import type { LiveGridWire } from '../grid/liveSession';
5
6
  import { chosenCell, gotoHosted, pageGoto } from '../../../shared/game/grid/pageMode';
6
7
  import type { SystemSpec } from '@wildshard/engine/app/systems';
@@ -8,6 +9,7 @@ import type { Player } from '@wildshard/engine/player/Player';
8
9
  import { Vector3, type Object3D } from 'three';
9
10
  import { appIdentity } from '@wildshard/engine/app/identity';
10
11
  import { bootMark, bootTask } from '@wildshard/engine/boot/timing';
12
+ import { SEAT_GRACE_MS, seatedInTime } from './seatGrace';
11
13
  import { importPageSaves, openIndexedSaves, serverSaveDatabase, serverStopsForImport, type IndexedSaves } from '@wildshard/engine/saves/indexed';
12
14
  import { saveEnvironment } from '@wildshard/engine/saves/environment';
13
15
  import { jsonSlot } from '@wildshard/engine/saves/slots';
@@ -21,7 +23,7 @@ import type { NetClient } from '@wildshard/engine/net/client';
21
23
  import type { NetCombatEvent } from '@wildshard/engine/net/messages';
22
24
  import type { DeathCause } from '@wildshard/engine/combat/pipeline';
23
25
  import { deviceIdentity, heldName, type NetIdentity } from '@wildshard/engine/net/identity';
24
- import { askNameOnce } from '@wildshard/engine/ui/namePrompt';
26
+ import { askNameToJoin } from '@wildshard/engine/ui/namePrompt';
25
27
  import { NetPlayer, type NetWeapons } from '@wildshard/engine/net/netPlayer';
26
28
  import type { PredictedRow } from '@wildshard/engine/net/predictionWorld';
27
29
  import { ANIMAL_CLASS } from '@wildshard/engine/net/netSchemas';
@@ -127,7 +129,7 @@ function releaseKeep(): ReleaseKeep {
127
129
  }
128
130
  /** E7.2d: the page's seat in the one world, in a shell of the same shape. */
129
131
  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> }
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 }
132
+ interface Shell { readonly redials?: true; devColliders?: (name: string, boxes: readonly DevBox[]) => void; 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 }
131
133
 
132
134
  const SAVE_EVERY_MS = 30_000;
133
135
  /** How long the card waits for the server's first rows, and how often it looks. A server that has booted says them in a tick. */
@@ -165,7 +167,7 @@ export interface WorkerClientReport {
165
167
  }
166
168
  /** A fight as a proof reads it: its row, where its body stands and the server's name for it. */
167
169
  export type WorkerClientFight = EncounterRow & { readonly at: { readonly x: number; readonly y: number; readonly z: number } | null; readonly name: string | null };
168
- declare global { interface Window { __onlinePlayers?: () => OtherPlayers['shown']; __workerClientFights?: () => readonly WorkerClientFight[]; __workerClientHits?: (by: number) => void; __workerClientTravel?: (to: ShardSlug) => void;__workerClientSky?: (name: string) => void; __workerClientTime?: (pick: OptionValue<'time'>) => void; __workerClientRow?: (name: string) => number | undefined; __workerClientFlag?: (flag: string) => void; __workerClientRows?: (kind: string) => readonly { readonly x: number; readonly y: number; readonly z: number }[]; __workerClientGate?: (flag: string) => boolean; __workerClientBot?: (id: string, x: number, y: number, z: number) => { readonly move: (x: number, y: number, z: number) => void; readonly press: (id: string) => void; readonly end: () => void }; __workerClient?: () => WorkerClientReport; __workerClientSave?: () => Promise<void> } }
170
+ declare global { interface Window { __onlinePlayers?: () => OtherPlayers['shown']; __workerClientFights?: () => readonly WorkerClientFight[]; __workerClientHits?: (by: number) => void; __workerClientTravel?: (to: ShardSlug) => void;__workerClientSky?: (name: string) => void; __workerClientTime?: (pick: OptionValue<'time'>) => void; __workerClientRow?: (name: string) => number | undefined; __workerClientFlag?: (flag: string) => void; __workerClientDevColliders?: (name: string, boxes: readonly DevBox[]) => void; __workerClientRows?: (kind: string) => readonly { readonly x: number; readonly y: number; readonly z: number }[]; __workerClientGate?: (flag: string) => boolean; __workerClientBot?: (id: string, x: number, y: number, z: number) => { readonly move: (x: number, y: number, z: number) => void; readonly press: (id: string) => void; readonly end: () => void }; __workerClient?: () => WorkerClientReport; __workerClientSave?: () => Promise<void> } }
169
171
 
170
172
  /** The page's pose inputs, as acts short enough to go. */
171
173
  function poseActs(names: ReadonlySet<string>): readonly string[] {
@@ -345,7 +347,7 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
345
347
  const online = async (world: BuildWorld, storage: SaveStorage): Promise<Shell> => {
346
348
  const { startOnline } = await onlineModule();
347
349
  // MP2.4: a page that came in without the title's PLAY (a link, a reload) asks for the Name here, once per device, before it joins
348
- const answered = await askNameOnce(scope, { parent: document.body, doctor: () => { document.dispatchEvent(new CustomEvent('ws:doctor', { detail: 'join' })); } });
350
+ const answered = await askNameToJoin(scope, { parent: document.body, doctor: () => { document.dispatchEvent(new CustomEvent('ws:doctor', { detail: 'join' })); } });
349
351
  // a page that left while it asked never joins (Codex review): a cancelled load must not take the device's seat
350
352
  if (!answered || scope.disposed) throw new Error('The page left before it joined the world');
351
353
  const { grid } = ports, booted = grid?.booted;
@@ -451,13 +453,20 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
451
453
  net.bindWeapons(ports.weapons, slotsOf(items));
452
454
  const day = ports.day(); if (day !== null) wirePage.dayPassed(day);
453
455
  });
454
- const { restored } = await bootTask('server:await-booted', () => shell.booted);
456
+ // OF9: a world build (the online shell redials) opens the world without its seat once the grace is up; the shell keeps dialling,
457
+ // the link screens say why, and the seat, when it comes, places the player (GO5). A server in this page boots with it, as before.
458
+ const unseated = shell.redials === true
459
+ && !await seatedInTime(shell.booted, SEAT_GRACE_MS, navigator.onLine, ms => new Promise<void>(resolve => { scope.timeout(ms, resolve); }));
460
+ const { restored } = unseated ? { restored: false } : await bootTask('server:await-booted', () => shell.booted);
461
+ // OF10: unseated, the page plays its own input for the predictor's ring, then holds until the seat
462
+ if (unseated) { bootMark('server:unseated'); net.playUnseated(); }
455
463
  // E7.6: only a world has anyone else in it.
456
464
  let others: OtherPlayers | null = null;
457
465
  if (shell.redials === true) others = new (await import('@wildshard/engine/net/otherPlayers')).OtherPlayers(client, ports.scene, scope, player.position);
458
466
  if (new URLSearchParams(location.search).has('bossGod')) shell.bossGod();
459
467
  bootMark('server:ready-send'); shell.ready();
460
468
  const started = diagnosticNow(), report: WorkerClientReport = { drawn: wirePage.drawn, frames: 0, framesPerSecond: 0, ticksPerSecond: 0, correctionsPerMinute: 0, corrections: 0, retired: {}, spawnMs: {}, missed: net.predictor.missed, misses: net.predictor.misses, worstOffset: 0, queue: 0, replaysPerFrame: 0, delayMs: 0, jitterMs: 0, interpHeld: 0, interpStarved: 0, mainMsP95: 0, workerTickMs: 0, rows: 0, attacks: 0, hits: 0, kills: 0, refused: 0, held: 0, dropped: 0, hp: 0, falls: 0, closed: null, x: 0, z: 0, cell: 0, serverX: 0, serverZ: 0, restored, savedTick: -1, savedOk: false, receipts: [], quests: {}, flags: [], paid: 0, fights: [], owned: {}, sky: null, day: null, clawed: false, own: null, movers: 0, posed: 0, sand: 0 };
469
+ if (unseated) void shell.booted.then(answer => { report.restored = answer.restored; bootMark('server:seated-late'); return undefined; }, () => undefined);
461
470
  scope.onDispose(client.onLedger(receipt => { report.receipts.push(`${receipt.grant}:${receipt.name}`); }));
462
471
  const contacts: NetCombatEvent[] = [];
463
472
  scope.onDispose(client.onTravel(() => { contacts.length = 0; }));
@@ -572,6 +581,8 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
572
581
  window.__onlinePlayers = () => others?.shown ?? [];
573
582
  window.__workerClientHits = by => { shell.hardHits(by); };
574
583
  window.__workerClientFlag = flag => { shell.raise(flag); };
584
+ // SHARD-SOURCE AP5: the dev hook's `swapColliders` reaches the in-page server here (DEVSERVER only: the define folds it away)
585
+ if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__) window.__workerClientDevColliders = (name, boxes) => { shell.devColliders?.(name, boxes); };
575
586
  window.__workerClientTravel = to => { travel({ to, mode: 'enter' }); };
576
587
  window.__workerClientSky = name => { wirePage.climate({ op: 'force', name, at: 0.1 }); };
577
588
  window.__workerClientTime = pick => { saveSetting('time', pick); };
@@ -613,7 +624,8 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
613
624
  const off = scope.capture('disposers', resolve);
614
625
  scope.timeout(FIRST_ROWS_POLL_MS, () => { off(); resolve(); });
615
626
  });
616
- const firstBy = diagnosticNow() + FIRST_ROWS_MS;
627
+ // OF9: an unseated page has no rows to wait for: the world opens now
628
+ const firstBy = unseated ? 0 : diagnosticNow() + FIRST_ROWS_MS;
617
629
  while (client.latest === null && diagnosticNow() < firstBy && !scope.disposed && !scope.disposing) await poll();
618
630
  if (scope.disposed || scope.disposing) return;
619
631
  net.reconcile(false);
@@ -622,7 +634,7 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
622
634
  if (ports.linkBodies === undefined) { bootMark('server:launch-complete'); return; }
623
635
  bootMark('server:first-body-preparation-start');
624
636
  let first = -1;
625
- const until = diagnosticNow() + FIRST_ROWS_MS;
637
+ const until = unseated ? 0 : diagnosticNow() + FIRST_ROWS_MS;
626
638
  while (diagnosticNow() < until) {
627
639
  renderTick = client.present();
628
640
  if (first === -1 && client.latest !== null) first = client.latest.tick;
@@ -3,6 +3,7 @@ import type { LookStrategy } from '@wildshard/engine/render/look';
3
3
  import type { Shardfile } from '@wildshard/format/shardSchema';
4
4
  import { lookLightManifest } from '@wildshard/engine/render/lookLight';
5
5
  import { lookLightOn } from '@wildshard/engine/ui/lookLightOption';
6
+ import { TIER } from '@wildshard/engine/core/tier';
6
7
 
7
8
  /**
8
9
  * A shardfile's file reference → its URL: products sit beside the page that embeds `shard.json` (the SDK build writes
@@ -17,7 +18,11 @@ export function shardfileFileUrl(ref: string): string { return `./${ref.replace(
17
18
  export function shardfileLook(look: Shardfile['look'], assets?: ReadonlyMap<string, Uint8Array>, light: boolean = lookLightOn()): LookStrategy {
18
19
  const lut = look.grade.lut === null ? null : assets?.get(look.grade.lut) ?? shardfileFileUrl(look.grade.lut);
19
20
  if (assets !== undefined && look.grade.lut !== null && !assets.has(look.grade.lut)) throw new Error('Missing admitted look LUT');
20
- const resolved = lookLightManifest(look, light);
21
- return dataLook({ day: look.day ?? DATA_LOOK_DAY, dayOverride: look.dayOverride, keys: look.keys, lut,
22
- light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity } });
21
+ const resolved = lookLightManifest(look, light, TIER);
22
+ // B2: `grade.tone` is a grade choice, not a light setting: it holds on every tier, with or without the row (so do M4.7's
23
+ // exposure and vignette); the bloom radius rides the bloom, which the row and the tier gate
24
+ return dataLook({ day: look.day ?? DATA_LOOK_DAY, dayOverride: look.dayOverride, keys: look.keys, lut, neutral: look.grade.tone === 'neutral', aces: look.grade.tone === 'aces',
25
+ exposure: look.grade.exposure, vignette: look.grade.vignette ?? null, bloomRadius: resolved.bloom.radius,
26
+ light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity, lamps: resolved.lamps, bounce: resolved.bounce, environment: resolved.environment,
27
+ shadow: resolved.shadow, motes: resolved.motes } });
23
28
  }
@@ -14,10 +14,10 @@ import { isOutputIndex } from '@wildshard/format/outputAddress';
14
14
  import { builtIndexHash } from '@wildshard/format/builtIndexes';
15
15
 
16
16
  import { acceptValidatedCost } from '@wildshard/format/deviceMemoryCost';
17
- import { ASSET_CACHE_NAME } from '@wildshard/engine/pwa/cacheNames';
17
+ import { assetCacheName } from '@wildshard/engine/pwa/cacheNames';
18
18
  import { saves } from '@wildshard/engine/saves/runtime';
19
19
  import { contentHash } from '../../../shared/game/shardfile/contentHash';
20
- import { packReads } from '../../../shared/game/shardfile/packReads';
20
+ import { packOrLoose, packReads } from '../../../shared/game/shardfile/packReads';
21
21
  import { productResourceRole } from '../../../shared/game/shardfile/resourceRole';
22
22
  import { preflightProduct } from './productPreflight';
23
23
 
@@ -107,6 +107,10 @@ export interface ProductOptions {
107
107
  memory?: MemoryAdmission;
108
108
  /** Trusted residency owner reserves parsed source and immutable transport before any asset-cache read or owned copy. */
109
109
  reserve?: (source: Shardfile) => void | Promise<void>;
110
+ /** GC9: files the trusted owner releases straight after admission (a grid neighbour's runtime-only wires, read back
111
+ * from cache or network by its inputs). A first-party read leaves them unread instead of fetching and dropping them;
112
+ * checked admission still reads every file. */
113
+ deferred?: (source: Shardfile) => Promise<readonly string[]>;
110
114
  /** Trusted presentation observer; it does not participate in admission decisions. */
111
115
  progress?: (progress: ProductProgress) => void;
112
116
  /** Trusted presentation scheduling between complete checks; validation never skips work. */
@@ -144,6 +148,8 @@ export interface AdmittedProduct {
144
148
  releasePreparedTransport?: (refs: Iterable<string>, reread?: 'cache-or-fetch') => Promise<readonly string[]>;
145
149
  /** Complete verified offline storage after control, without retaining the distant files on the page. */
146
150
  completeCache?: (scope: Scope) => Promise<void>;
151
+ /** GC9: selected files a first-party read left unread (`ProductOptions.deferred`): still this product's inputs, read back on demand. */
152
+ unread?: readonly string[];
147
153
  }
148
154
 
149
155
  // Construct outside admission's decoding context: the owner must not retain the temporary hash/transport maps.
@@ -388,7 +394,9 @@ async function readBuiltProduct(input:unknown,options:ProductOptions,read:NonNul
388
394
  if(!isBuildValidatedOutput(source))throw new Error('First-party reader did not assemble its build output');
389
395
  await options.reserve?.(source);
390
396
  const selected=options.tier===undefined?source.files:await tierProductFilesPaced(source,options.tier,options.pause,options.splatTier);
391
- const initial=options.tier==='phone'?controlFiles(await playLibrarySourcePaced(source,options.pause),selected):selected;
397
+ const control=options.tier==='phone'?controlFiles(await playLibrarySourcePaced(source,options.pause),selected):selected;
398
+ const deferred=options.deferred===undefined?undefined:new Set(await options.deferred(source));
399
+ const initial=deferred===undefined?control:control.filter(file=>!deferred.has(file.hash));
392
400
  const base=new URL('.',options.base).href,assets=new Map<string,Uint8Array>();
393
401
  const refs=[...initial.map(file=>({ref:file.hash,bytes:file.compressed})),...source.requires.commons.map(hash=>({ref:`commons:${hash}`,bytes:source.requires.commonsWire[hash]??0}))];
394
402
  const unique=new Map(refs.map(row=>[row.ref.replace(/^commons:/u,''),row]));
@@ -411,7 +419,21 @@ async function readBuiltProduct(input:unknown,options:ProductOptions,read:NonNul
411
419
  wires.set(row.ref.replace(/^commons:/u,''),result.bytes);
412
420
  }
413
421
  for(const row of refs){const bytes=wires.get(row.ref.replace(/^commons:/u,''));if(bytes===undefined)throw new Error('Missing built file bytes');assets.set(row.ref,bytes);}
414
- return {source,assets,cached:false,releaseTransport:transportRelease(source,assets,options),releasePreparedTransport:transportRelease(source,assets,options,true)};
422
+ const unread=deferred===undefined?[]:control.filter(file=>deferred.has(file.hash));
423
+ // GC9: the files left unread are fetched once more in the background, low priority and unhashed, so the entry's own
424
+ // verified reads of them find the HTTP cache warm (Pine's scene libraries read them one by one at entry); only after a read
425
+ // that succeeded
426
+ const warm=options.backgroundFetch;
427
+ if(unread.length>0&&warm!==undefined)void warmTransport(unread.map(file=>outputBlobUrl(source,file.hash,base)),warm);
428
+ return {source,assets,cached:false,...(deferred===undefined?{}:{unread:unread.map(file=>file.hash)}),releaseTransport:transportRelease(source,assets,options),releasePreparedTransport:transportRelease(source,assets,options,true)};
429
+ }
430
+ /** GC9: fetch immutable product files into the HTTP cache, eight at a time, ignoring failures (a later verified read fetches again). */
431
+ async function warmTransport(urls:readonly string[],fetchLow:NonNullable<ProductOptions['backgroundFetch']>):Promise<void>{
432
+ let next=0;
433
+ const worker=async():Promise<void>=>{
434
+ while(next<urls.length){const url=urls[next++];if(url===undefined)return;try{await (await fetchLow(url)).arrayBuffer();}catch{/* the entry's verified read fetches it */}}
435
+ };
436
+ await Promise.all(Array.from({length:Math.min(8,urls.length)},worker));
415
437
  }
416
438
  /** Drain a bounded window before refusal or publication; cache operations keep their authored error order. */
417
439
  async function cacheRows<T>(rows: readonly T[], batch: boolean, work: (row: T) => Promise<void>): Promise<void> {
@@ -565,8 +587,13 @@ async function admitProductWork(input: unknown, options: ProductOptions, trace?:
565
587
  if (bytes === null || bytes === undefined) {
566
588
  if (options.offline) throw new Error('Visited shardfile has an incomplete offline cache');
567
589
  progress('assets', `Fetching ${role}`, url);
568
- if (inPack && packed !== undefined) { bytes = await waitFor(`Pack member · ${role}`, packed.read(hash), 'file', url); bytesRead += bytes.length; }
569
- else bytes = await boundedResponse(await options.fetch(url), cap, (size) => { bytesRead += size; progress('assets', `Reading ${role}`, url); });
590
+ const loose = async (): Promise<Uint8Array> => boundedResponse(await options.fetch(url), cap, (size) => { bytesRead += size; progress('assets', `Reading ${role}`, url); });
591
+ // PZ7: a pack that is not published (or fails) falls back to the member's loose blob
592
+ if (inPack && packed !== undefined) {
593
+ let fromPack = true;
594
+ bytes = await waitFor(`Pack member · ${role}`, packOrLoose(() => packed.read(hash), () => { fromPack = false; return loose(); }), 'file', url);
595
+ if (fromPack) bytesRead += bytes.length;
596
+ } else bytes = await loose();
570
597
  } else { bytesRead += bytes.length; progress('assets', `Cached ${role}`, url); }
571
598
  if (bytes.length !== cap) throw new Error('Shardfile asset wire size differs from declaration');
572
599
  progress('hash', `Verifying ${role}`, url);
@@ -686,7 +713,7 @@ async function admitProductWork(input: unknown, options: ProductOptions, trace?:
686
713
  * browser reads use native fetch, without a page index, leases or worker. */
687
714
  export function browserProductCache(storage: Pick<CacheStorage, 'open'>,
688
715
  preparation: Pick<ProductOptions, 'pause' | 'parseJson'> = {}): ProductCache {
689
- const open = () => storage.open(ASSET_CACHE_NAME);
716
+ const open = () => storage.open(assetCacheName());
690
717
  const productUrl = (base: string) => new URL('__visited_shardfile__', base).href;
691
718
  const assetUrl = (base: string, hash: string): string => {
692
719
  if (!HASH.test(hash)) throw new Error('Invalid content hash');
@@ -17,7 +17,7 @@ export async function prepareCheckedProduct(source: Shardfile): Promise<boolean>
17
17
  if (!isBuildValidatedOutput(source)) throw new Error('Shardfile needs server validation before client admission');
18
18
  return false;
19
19
  }
20
- const checked = await import('@wildshard/format/product');
20
+ const checked = await import('@wildshard/format/shardfileAssets');
21
21
  await checked.prepareAssetDecoders();
22
22
  checked.preflightAssetGraph(source);
23
23
  return true;
@@ -33,7 +33,7 @@ export async function checkedProductCosts(source: Shardfile, memory: MemoryAdmis
33
33
  export async function validateCheckedProductAssets(source: Shardfile, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
34
34
  memory: MemoryAdmission | undefined, textures: TextureTranscodeSupport | undefined, sections: ReadonlyMap<string, unknown> | undefined, decodersReady: boolean): Promise<void> {
35
35
  if (!(import.meta.env?.SSR ?? true)) throw new Error('Shardfile needs server validation before client admission');
36
- if (!decodersReady) await (await import('@wildshard/format/product')).prepareAssetDecoders();
36
+ if (!decodersReady) await (await import('@wildshard/format/shardfileAssets')).prepareAssetDecoders();
37
37
  const { validateShardfileAssets } = await import('@wildshard/format/assetAdmission');
38
38
  const { scriptAdmissionRows } = await import('@wildshard/format/scriptContract');
39
39
  validateShardfileAssets(source, assets, hash, memory, textures, scriptAdmissionRows(sections));
@@ -14,7 +14,7 @@ import { preflightShardfile, preflightShardfileSteps } from '@wildshard/format/p
14
14
  import { jsonDataHeapBytes } from '@wildshard/format/json';
15
15
  import { outputDescriptor, isBuildValidatedOutput } from '../../../shared/game/shardfile/outputDescriptor';
16
16
  import { otherTierSplatFiles } from '../../../shared/game/shardfile/wholeInputs';
17
- import {builtProductPostCost} from '@wildshard/format/validationReceipt';
17
+ import {builtShardfilePostCost} from '@wildshard/format/validationReceipt';
18
18
  import {postStackCost,type PostStackCost} from '@wildshard/format/postStack';
19
19
  import { isPlatformDataSection } from '@wildshard/format/outputFields';
20
20
  import { parseWorldScenes } from '@wildshard/format/worldScenes';
@@ -306,7 +306,7 @@ export function jsonResidentBytes(input: unknown): number {
306
306
  export function productPostCost(source:Shardfile,bytes:(hash:string)=>Uint8Array|undefined):PostStackCost{
307
307
  const descriptor=outputDescriptor(source);
308
308
  if(descriptor?.built===true){
309
- const cost=builtProductPostCost(descriptor.index.build.sourceHash);
309
+ const cost=builtShardfilePostCost(descriptor.index.build.sourceHash);
310
310
  if(cost===undefined)throw new Error('Build must publish post cost');
311
311
  return cost;
312
312
  }
@@ -1,5 +1,5 @@
1
1
  import { readContent, type ContentReadOptions } from '@wildshard/engine/boot/contentRead';
2
- import { ASSET_CACHE_NAME } from '@wildshard/engine/pwa/cacheNames';
2
+ import { assetCacheName } from '@wildshard/engine/pwa/cacheNames';
3
3
  import { SHARDFILE_ADMISSION_LIMITS as limits } from '@wildshard/format/admissionLimits';
4
4
 
5
5
  interface AssetStorePort { open: (name: string) => Promise<Pick<Cache, 'put'>> }
@@ -36,7 +36,7 @@ export async function readAsset(url: string, bytes: number | undefined, options:
36
36
  } });
37
37
  options.signal?.throwIfAborted();
38
38
  if (copy !== undefined && publication !== undefined) {
39
- try { await (await publication.open(ASSET_CACHE_NAME)).put(url, copy); }
39
+ try { await (await publication.open(assetCacheName())).put(url, copy); }
40
40
  catch { /* Disk denial never rejects complete online bytes. */ }
41
41
  }
42
42
  return result;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * A pool's declared surface (meta TEMPLATES-CLEANROOM M4.1/M4.6, `@wildshard/format/pool-surface`): how its water draws.
3
+ *
4
+ * - `reflect: 'planar'` on the desktop tier: a mirror of the scene (three's `Reflector`, one extra scene draw per frame
5
+ * while the pool is in view, at `resolution` texels, 512 absent), its UVs rippled in world space, a Fresnel blend of the
6
+ * reflection over the deep `tint` (face-on `fresnel[0]`, rising by the power `fresnel[1]` toward grazing).
7
+ * - `reflect: 'sky'`, and `planar` on the phone tier: the engine's default water surface (`defaultWaterMaterial`), opaque
8
+ * in `tint` with the surface's Fresnel and ripple: the look's sky and sun reflected, no second scene draw.
9
+ *
10
+ * The cleanroom pond this ports (mossgate-cleanroom `src/main.js`) is a 1024² reflector, tint `#3a3458`, Fresnel 0.35 +
11
+ * 0.65·(1 − v·y)³; the milky pond it replaces was the default surface's 0.7 alpha over a fog-coloured sky.
12
+ */
13
+ import { CircleGeometry, Color, Shape, ShapeGeometry, Vector2, type BufferGeometry, type Mesh, type ShaderMaterial } from 'three';
14
+ import { Reflector } from 'three/examples/jsm/objects/Reflector.js';
15
+ import type { PoolSurface } from '@wildshard/format/pool-surface';
16
+
17
+ /** the mirror's texels on a side when the surface names none */
18
+ export const DEFAULT_MIRROR_TEXELS = 512;
19
+ /** how far the mirror's clip plane sits under the water (metres): keeps the bank's foot out of its own reflection */
20
+ const CLIP_BIAS = 0.003;
21
+
22
+ /** A pool's outline in its own x / y plane (z negated, so a −90° turn about x lays it on the ground as declared). */
23
+ export function poolPlane(shape: { readonly kind: 'circle'; readonly x: number; readonly z: number; readonly radius: number } | { readonly kind: 'polygon'; readonly points: readonly (readonly [number, number])[] }): BufferGeometry {
24
+ if (shape.kind === 'circle') return new CircleGeometry(shape.radius, 32).translate(shape.x, -shape.z, 0);
25
+ return new ShapeGeometry(new Shape(shape.points.map(([x, z]) => new Vector2(x, -z))), 12);
26
+ }
27
+
28
+ const VERTEX = /* glsl */`
29
+ uniform mat4 textureMatrix;
30
+ varying vec4 vMirror; varying vec3 vWorld;
31
+ void main() {
32
+ vMirror = textureMatrix * vec4(position, 1.0);
33
+ vWorld = (modelMatrix * vec4(position, 1.0)).xyz;
34
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
35
+ }`;
36
+ // linear out (the composer tone-maps): the rippled mirror over the tint, by Fresnel
37
+ const FRAGMENT = /* glsl */`
38
+ uniform sampler2D tDiffuse; uniform vec3 color; uniform float uTime; uniform vec3 uTint; uniform vec2 uFresnel; uniform vec3 uRipple;
39
+ varying vec4 vMirror; varying vec3 vWorld;
40
+ void main() {
41
+ vec2 w = vWorld.xz * uRipple.x, t = vec2(uTime * uRipple.z);
42
+ vec2 d = vec2(sin(w.x * 1.03 + t.x * 1.3) + sin(w.y * 0.77 - t.x * 0.9), cos(w.y * 1.23 + t.x * 1.1) + sin(w.x * 0.57 + w.y * 0.7 + t.x)) * uRipple.y;
43
+ vec4 uv = vMirror; uv.xy += d * uv.w;
44
+ vec3 mirror = texture2DProj(tDiffuse, uv).rgb * color;
45
+ vec3 v = normalize(cameraPosition - vWorld);
46
+ float fresnel = uFresnel.x + (1.0 - uFresnel.x) * pow(1.0 - max(v.y, 0.0), uFresnel.y);
47
+ gl_FragColor = vec4(mix(uTint, mirror, fresnel), 1.0);
48
+ }`;
49
+
50
+ /** A planar-reflecting pool: a `Reflector` laid on the ground at `level`; `tick(dt)` runs its ripples on the game clock. */
51
+ export function mirrorPool(shape: Parameters<typeof poolPlane>[0], level: number, surface: PoolSurface): { mesh: Mesh; tick: (dt: number) => void; dispose: () => void } {
52
+ const texels = surface.resolution ?? DEFAULT_MIRROR_TEXELS;
53
+ const mirror = new Reflector(poolPlane(shape), {
54
+ textureWidth: texels, textureHeight: texels, clipBias: CLIP_BIAS, multisample: 0,
55
+ // a faint cool cast on the mirror, as the cleanroom's (0.82, 0.76, 0.84)
56
+ color: new Color(0.82, 0.78, 0.86),
57
+ shader: {
58
+ name: 'engine.water.mirror',
59
+ uniforms: { color: { value: null }, tDiffuse: { value: null }, textureMatrix: { value: null }, uTime: { value: 0 },
60
+ uTint: { value: new Color().setRGB(surface.tint[0], surface.tint[1], surface.tint[2]) },
61
+ uFresnel: { value: new Vector2(surface.fresnel[0], surface.fresnel[1]) },
62
+ uRipple: { value: [surface.ripple.scale, surface.ripple.amplitude, surface.ripple.speed] } },
63
+ vertexShader: VERTEX, fragmentShader: FRAGMENT,
64
+ },
65
+ });
66
+ mirror.rotation.x = -Math.PI / 2;
67
+ mirror.position.y = level;
68
+ mirror.updateMatrixWorld();
69
+ const material = mirror.material as ShaderMaterial, time = material.uniforms['uTime'];
70
+ let clock = 0;
71
+ const tick = (dt: number): void => { clock += dt; if (time !== undefined) time.value = clock; };
72
+ return { mesh: mirror, tick, dispose: () => { mirror.dispose(); mirror.geometry.dispose(); } };
73
+ }
@@ -0,0 +1,9 @@
1
+ /** OFFLINE OF9 (J298, Jake 2026-11-12: "Load into the world. And then have a really hard time moving around"): how long a world
2
+ * build's load waits for its seat before it opens the world without one. A seat in time keeps QA row 29's reveal at the saved place;
3
+ * a page that knows it is offline doesn't wait at all. */
4
+ export const SEAT_GRACE_MS = 1500;
5
+ /** OF9: whether the seat comes within `graceMs` (the page's link known down: no wait). A pure race, so a test pins it. */
6
+ export function seatedInTime(booted: Promise<unknown>, graceMs: number, online: boolean, wait: (ms: number) => Promise<void>): Promise<boolean> {
7
+ if (!online) return Promise.resolve(false);
8
+ return Promise.race([booted.then(() => true, () => true), wait(graceMs).then(() => false)]);
9
+ }
@@ -14,7 +14,7 @@ import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js
14
14
  import { bindRig, prepareRigLoader, type ClipName, type RigInstance } from '@wildshard/engine/anim/rig';
15
15
  import { AnimMachine } from '@wildshard/engine/anim/machine';
16
16
  import type { Scope } from '@wildshard/engine/app/scope';
17
- import type { AssetCost } from '@wildshard/format/product';
17
+ import type { AssetCost } from '@wildshard/format/shardfileAssets';
18
18
  import { parseGlbData, prepareGlbCost } from '@wildshard/format/glbCost';
19
19
  import { skinLayerDecoded } from '@wildshard/format/skinLayers';
20
20
  import { parseSkinBindings, type SkinRow, type SkinBinding } from '@wildshard/format/skinData';
@@ -14,6 +14,7 @@ import { standingFigure, type FigureSkinState } from './standingFigure';
14
14
  import { skinEnvelope } from '../../grid/skinEnvelope';
15
15
 
16
16
  const skins = new FigureSkins();
17
+ const rootAt = new THREE.Vector3();
17
18
  const entered = new WeakMap<Scope, Map<string, Set<FigureRows>>>();
18
19
  function sourceId(ref: ScenePointRef): string {
19
20
  if (!('part' in ref)) throw new Error('Figure object requires a scene part');
@@ -139,6 +140,14 @@ export class FigureRows {
139
140
  private refreshPoint(): void {
140
141
  this.group.updateWorldMatrix(true, false);
141
142
  this.talkPoint.set(0, this.row.talkHeight, 0).applyMatrix4(this.group.matrixWorld);
143
+ // A figure on a borrowed root is placed after it is built (a kit figure's group goes to its feet once made): its body
144
+ // stands where the root is now, so a registry piece that follows the root holds it at the feet, not at the origin
145
+ // (SERVER-PARITY SS10b, Driftwood's Wendell). A standing person keeps its own collider (`update`).
146
+ if (this.person === undefined) {
147
+ const at = rootAt.setFromMatrixPosition(this.group.matrixWorld), box = this.row.collider;
148
+ this.collider.x = at.x; this.collider.z = at.z;
149
+ this.collider.yTop = at.y + (box?.kind === 'box' ? box.top : 0); this.collider.yBottom = at.y - (box?.kind === 'box' ? box.bottom : 0);
150
+ }
142
151
  }
143
152
  /** Refresh a borrowed pivot figure's world prompt without advancing its law. */
144
153
  syncAnchors(): void { if (this.live) this.refreshPoint(); }
@@ -173,6 +173,8 @@ async function checkServer(learned: Learned, ms: number): Promise<Outcome> {
173
173
  // D7: behind Cloudflare the rooms address keeps /health private (404, no CORS), so the opaque answer is all a page gets.
174
174
  return pass(`${new URL(url).host} reachable · health is private`);
175
175
  } catch {
176
+ // PZ12 (J274): an isolated page (COEP require-corp) is refused the opaque answer itself, so a failure proves nothing
177
+ if (globalThis.crossOriginIsolated) return warn(`${new URL(url).host}: health is private`, `This page is cross-origin isolated, so it cannot read ${new URL(url).host}'s private health answer. If play fails, tell Jake.`);
176
178
  return fail(`${new URL(url).host}: no answer`, `Server unreachable: ${new URL(url).host} is down, its TLS is failing, or the server is stopped. Tell Jake.`);
177
179
  }
178
180
  }