@wildshard/engine 0.1.23 → 0.1.24

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 (99) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/index.html +17 -4
  3. package/lint/engine-sides.json +7 -0
  4. package/package.json +29 -3
  5. package/scripts/app-build/titlePreloads.mjs +8 -5
  6. package/scripts/bake-road-surfaces.entry.ts +18 -0
  7. package/scripts/bake-road-surfaces.mjs +44 -0
  8. package/scripts/changelog.mjs +2 -1
  9. package/scripts/goldens/capture.mjs +18 -6
  10. package/scripts/goldens/native-residency.d.mts +1 -0
  11. package/scripts/goldens/native-residency.mjs +14 -1
  12. package/scripts/grid-road-lag.mjs +209 -0
  13. package/scripts/keep-copy.mjs +64 -12
  14. package/scripts/land.d.mts +4 -1
  15. package/scripts/land.mjs +85 -3
  16. package/scripts/loading-flow/benchmax.mjs +2 -0
  17. package/scripts/map-hash.mjs +1 -1
  18. package/scripts/nightly-tag.mjs +2 -4
  19. package/scripts/page-release/content.mjs +19 -10
  20. package/scripts/page-release/flow.d.mts +3 -2
  21. package/scripts/page-release/flow.mjs +31 -21
  22. package/scripts/page-release/packs.d.mts +5 -0
  23. package/scripts/page-release/packs.mjs +13 -3
  24. package/scripts/page-release/preview.d.mts +2 -0
  25. package/scripts/page-release/preview.mjs +74 -0
  26. package/scripts/page-release.mjs +13 -5
  27. package/scripts/road-drive-proof.mjs +269 -0
  28. package/scripts/road-memory-probe.mjs +129 -0
  29. package/scripts/scratch-dir.mjs +4 -4
  30. package/scripts/server-release/github.mjs +59 -26
  31. package/scripts/server-release/publish.mjs +15 -1
  32. package/scripts/server-release/sign.mjs +8 -4
  33. package/scripts/test_prebuilt_output.py +3 -1
  34. package/scripts/turn-in-shots.mjs +83 -0
  35. package/scripts/vitest-bench-observe-proof.py +168 -0
  36. package/scripts/vitest-bench.py +122 -77
  37. package/scripts/vps/rebuild.sh +3 -1
  38. package/scripts/worktree-reap.mjs +21 -9
  39. package/scripts/worktree.mjs +1 -1
  40. package/scripts/zone-gate-proof.mjs +93 -0
  41. package/src/client/engine/boot/sw.ts +3 -1
  42. package/src/client/engine/core/ktx2.ts +30 -9
  43. package/src/client/engine/models/place.ts +7 -5
  44. package/src/client/engine/pwa/sw.js +57 -2
  45. package/src/client/engine/render/precompile.ts +6 -0
  46. package/src/client/engine/render/tiers.ts +9 -0
  47. package/src/client/engine/ui/playerReload.ts +5 -5
  48. package/src/client/game/boot/bytes.generated.ts +4 -1
  49. package/src/client/game/boot/versions.generated.ts +8 -5
  50. package/src/client/game/grid/cellClip.ts +70 -6
  51. package/src/client/game/grid/gateCard.css +9 -0
  52. package/src/client/game/grid/gateCard.ts +67 -0
  53. package/src/client/game/grid/live.ts +17 -3
  54. package/src/client/game/grid/liveSession.ts +15 -5
  55. package/src/client/game/grid/neighbourLife.ts +10 -1
  56. package/src/client/game/grid/neighbourPanels.ts +29 -2
  57. package/src/client/game/grid/pageEntry.ts +21 -0
  58. package/src/client/game/grid/regionalWorld.ts +5 -0
  59. package/src/client/game/grid/roadCompressedSurfaces.ts +69 -0
  60. package/src/client/game/grid/roadLook.ts +5 -73
  61. package/src/client/game/grid/roadLookPlatform.ts +11 -6
  62. package/src/client/game/grid/roadSurfaceMaps.ts +80 -0
  63. package/src/client/game/grid/roadTilePool.ts +4 -0
  64. package/src/client/game/grid/session.ts +52 -12
  65. package/src/client/game/grid/softWallLook.ts +6 -1
  66. package/src/client/game/plugin/ui.ts +3 -0
  67. package/src/client/game/session/play.ts +3 -0
  68. package/src/client/game/shardfile/clientSource.ts +5 -2
  69. package/src/client/game/shardfile/clientWorker.ts +3 -2
  70. package/src/client/game/shardfile/slabLibrary.ts +37 -0
  71. package/src/client/game/shardfile/slabRanges.ts +145 -0
  72. package/src/client/host/online/shell.ts +2 -2
  73. package/src/client/host/standalone/shell.ts +4 -1
  74. package/src/server/game/grid/simulation.ts +27 -4
  75. package/src/server/game/plugin/simulation.ts +2 -0
  76. package/src/server/game/shardfile/dataRespawn.ts +47 -0
  77. package/src/server/host/standalone/cellWorld.ts +1 -1
  78. package/src/server/host/standalone/gridServer.ts +18 -6
  79. package/src/server/host/standalone/roadWorld.ts +30 -0
  80. package/src/server/host/standalone/serverHost.ts +2 -2
  81. package/src/shared/engine/entities/AnimalSim.ts +10 -0
  82. package/src/shared/engine/physics/transferWalls.ts +9 -4
  83. package/src/shared/game/grid/allocator.ts +8 -1
  84. package/src/shared/game/grid/gateCount.ts +27 -0
  85. package/src/shared/game/grid/zoneWalls.ts +64 -0
  86. package/src/shared/game/strings.ts +2 -0
  87. package/src/shared/host/standalone/harnessPlace.ts +4 -0
  88. package/src/test/engine/simState.ts +134 -0
  89. package/src/test/game/builtProduct.ts +6 -0
  90. package/src/test/game/headless/admittedProductCache.ts +61 -0
  91. package/src/test/game/headless/checkedReplayPipeline.ts +21 -0
  92. package/src/test/game/headless/nativeBounds.ts +27 -0
  93. package/src/test/game/headless/processUsage.ts +22 -0
  94. package/src/test/game/headless/productSession.ts +39 -0
  95. package/src/test/game/headless/ropeBodies.ts +60 -0
  96. package/src/test/game/headless/worker.ts +34 -0
  97. package/src/test/game/headlessNative.ts +114 -0
  98. package/src/test/game/headlessWorker.ts +43 -0
  99. package/src/test/tsconfig.game.json +3 -0
package/CHANGELOG.md CHANGED
@@ -9,6 +9,13 @@ run `../repo-kit/release.sh vX.Y.Z --prepare` and `--finish` as before (the help
9
9
  `scripts/changelog.mjs` checks the format; the pre-push hook and CI refuse a push whose `package.json` version has no
10
10
  valid section, and a `vX.Y.Z` tag whose commit has none.
11
11
 
12
+ ## v0.1.24 (2026-11-15)
13
+
14
+ - A phone holding an old version no longer sits on "still waiting": the new version takes over by itself, even on bad Wi-Fi.
15
+ - New versions download in the background while you play and switch in on your next visit, never as a reload in the middle of a game.
16
+ - Reloading keeps you on the page you were on, such as a shard's own link, instead of going back to the main menu.
17
+ - When the title's loading bar stalls, it says what it is waiting for, and tapping reload fetches a fresh copy past the cache.
18
+
12
19
  ## v0.1.23 (2026-11-15)
13
20
 
14
21
  - New and updated shards are cooked for the world again: since Saturday the cook refused every upload as over its space.
package/index.html CHANGED
@@ -223,7 +223,7 @@
223
223
  if (homeParams.size === 0) document.documentElement.classList.add('title-first');
224
224
  if (document.documentElement.classList.contains('title-first')) {
225
225
  const hero = document.createElement('link');
226
- hero.rel = 'preload'; hero.as = 'image'; hero.fetchPriority = 'high';
226
+ hero.rel = 'preload'; hero.as = 'image'; hero.setAttribute('fetchpriority', 'low');
227
227
  // PZ19: the shell's hero is the ~30 kB first cut, so it no longer outruns the entry's code on a slow line; the title's
228
228
  // own hero (mainMenu.ts) brings the full image in over it once the title is up
229
229
  hero.href = titleAssetURLs['/assets/title/main-crossroads-' + (matchMedia('(orientation: portrait)').matches ? 'square' : 'landscape') + '-first.jpg'];
@@ -589,6 +589,16 @@ html[data-ws-keyboard] #game, html[data-ws-keyboard] #hud { top: var(--ws-kb-top
589
589
  </head>
590
590
  <body>
591
591
  <script>
592
+ // STALESHELL (QA 11-15 row 32): the static shell's own reloads (its pill, the 12 s self-reload) go past the service worker,
593
+ // so a shell that worker can't finish booting is never served again: drop the registration (1.5 s at most), then reload this
594
+ // exact URL (Jake, 11-15: a reload keeps /slug/<x>). Offline it is a plain reload, so the cached build still answers.
595
+ globalThis.__wsShellReload = () => {
596
+ let gone = false;
597
+ const leave = () => { if (!gone) { gone = true; location.reload(); } };
598
+ if (!navigator.serviceWorker || navigator.onLine === false) return leave();
599
+ setTimeout(leave, 1500);
600
+ navigator.serviceWorker.getRegistrations().then(all => Promise.all(all.map(one => one.unregister()))).then(leave, leave);
601
+ };
592
602
  // iOS Safari: no rubber-band scroll of the fixed page, no pinch zoom — the game owns every gesture.
593
603
  document.addEventListener('touchmove', (e) => { if (!e.target.closest('[data-scroll]')) e.preventDefault(); }, { passive: false });
594
604
  document.addEventListener('gesturestart', (e) => e.preventDefault());
@@ -610,7 +620,7 @@ html[data-ws-keyboard] #game, html[data-ws-keyboard] #hud { top: var(--ws-kb-top
610
620
  <div class="ws-launch-hero" aria-hidden="true"></div>
611
621
  <div class="ws-launch-brand">WILDSHARD</div>
612
622
  <!-- plain HTML: a reload that works when every bundle failed; pointerup too, as iOS drops a jittered tap's click (Update.ts) -->
613
- <button type="button" class="ws-launch-pill" data-launch-reload onclick="this.dataset.reloading='';location.reload()" onpointerup="this.dataset.reloading='';location.reload()"><i></i><span data-launch-version>reload</span></button>
623
+ <button type="button" class="ws-launch-pill" data-launch-reload onclick="this.dataset.reloading='';(globalThis.__wsShellReload||location.reload.bind(location))()" onpointerup="this.dataset.reloading='';(globalThis.__wsShellReload||location.reload.bind(location))()"><i></i><span data-launch-version>reload</span></button>
614
624
  <div class="ws-launch-load" role="progressbar" aria-label="Loading" aria-valuemin="0" aria-valuemax="100" data-launch-load><div class="ws-launch-bar"><i data-launch-fill></i></div><span data-launch-step>Loading</span></div>
615
625
  </div><!-- /title-shell -->
616
626
  <script data-launch-progress>
@@ -642,7 +652,10 @@ html[data-ws-keyboard] #game, html[data-ws-keyboard] #hud { top: var(--ws-kb-top
642
652
  const stalled = now - changed > 8000;
643
653
  fill.style.width = pct + '%'; load.setAttribute('aria-valuenow', String(pct));
644
654
  if (shell.hasAttribute('data-stalled') !== stalled) { shell.toggleAttribute('data-stalled', stalled); version.textContent = name(stalled); }
645
- step.textContent = (stalled ? 'Still waiting · tap reload' : opening ? 'Opening the menu' : started ? 'Starting'
655
+ // STALESHELL: a stall names what it waits on, a file this document names (its hash dropped) or the code it starts
656
+ const missing = started ? undefined : [...files].find(href => !(t?.resources || []).some(row => row.url === href && row.responseStatus !== 0));
657
+ const waitingOn = opening ? 'the menu' : missing === undefined ? 'the game code' : (missing.split('/').pop() || '').replace(/-[A-Za-z0-9_-]{8}(?=\.\w+$)/u, '');
658
+ step.textContent = (stalled ? 'Still waiting on ' + waitingOn + ' · tap reload' : opening ? 'Opening the menu' : started ? 'Starting'
646
659
  : got > 0 ? 'Loading · ' + got + ' of ' + files.size + ' files' : 'Loading') + ' · ' + (now / 1000).toFixed(1) + ' s';
647
660
  };
648
661
  const timer = setInterval(tick, 100); tick();
@@ -694,7 +707,7 @@ html[data-ws-keyboard] #game, html[data-ws-keyboard] #hud { top: var(--ws-kb-top
694
707
  if (doc.keys?.['boot.selfReload']) return;
695
708
  (doc.keys ??= {})['boot.selfReload'] = { v: 1, data: String(Date.now()) }; sessionStorage.setItem('wildshard.save.v2@1.session', JSON.stringify(doc));
696
709
  } catch { return; }
697
- location.reload();
710
+ (globalThis.__wsShellReload || location.reload.bind(location))();
698
711
  }, 12000);
699
712
  </script>
700
713
  <script data-loading-clock>
@@ -649,6 +649,7 @@
649
649
  "src/client/game/grid/frameLook.ts": "client",
650
650
  "src/client/game/grid/frameModel.ts": "client",
651
651
  "src/client/game/grid/gridHud.ts": "client",
652
+ "src/client/game/grid/gateCard.ts": "client",
652
653
  "src/client/game/grid/hazeBand.ts": "client",
653
654
  "src/client/game/grid/homeCheckpoint.ts": "client",
654
655
  "src/client/game/grid/homeMetadata.ts": "client",
@@ -701,6 +702,7 @@
701
702
  "src/client/game/grid/roadGrain.ts": "client",
702
703
  "src/client/game/grid/roadGrain.worker.ts": "client",
703
704
  "src/client/game/grid/roadGrainPreparation.ts": "client",
705
+ "src/client/game/grid/roadCompressedSurfaces.ts": "client",
704
706
  "src/client/game/grid/roadLook.ts": "client",
705
707
  "src/client/game/grid/roadLookPlatform.ts": "client",
706
708
  "src/client/game/grid/roadResources.ts": "client",
@@ -711,6 +713,7 @@
711
713
  "src/client/game/grid/roadSignScale.ts": "client",
712
714
  "src/client/game/grid/roadSky.ts": "client",
713
715
  "src/client/game/grid/roadSolid.ts": "client",
716
+ "src/client/game/grid/roadSurfaceMaps.ts": "client",
714
717
  "src/client/game/grid/roadTileArchive.ts": "client",
715
718
  "src/client/game/grid/roadTileBacking.ts": "client",
716
719
  "src/client/game/grid/roadTileCapture.worker.ts": "client",
@@ -1016,6 +1019,7 @@
1016
1019
  "src/client/game/shardfile/skinLayerPlayback.ts": "client",
1017
1020
  "src/client/game/shardfile/skinPlayback.ts": "client",
1018
1021
  "src/client/game/shardfile/slabLibrary.ts": "client",
1022
+ "src/client/game/shardfile/slabRanges.ts": "client",
1019
1023
  "src/client/game/shardfile/stillImage.ts": "client",
1020
1024
  "src/client/game/shardfile/streamingView.ts": "client",
1021
1025
  "src/client/game/shardfile/tileBufferedDraws.ts": "client",
@@ -1286,6 +1290,7 @@
1286
1290
  "src/server/game/shardfile/borrowedDecisions.ts": "server",
1287
1291
  "src/server/game/shardfile/bossRow.ts": "server",
1288
1292
  "src/server/game/shardfile/brainRuntime.ts": "server",
1293
+ "src/server/game/shardfile/dataRespawn.ts": "server",
1289
1294
  "src/server/game/shardfile/decisions.ts": "server",
1290
1295
  "src/server/game/shardfile/declaredClimate.ts": "server",
1291
1296
  "src/server/game/shardfile/declaredKitItems.ts": "server",
@@ -1665,6 +1670,8 @@
1665
1670
  "src/shared/game/grid/platformInputs.ts": "shared",
1666
1671
  "src/shared/game/grid/postPairs.ts": "shared",
1667
1672
  "src/shared/game/grid/readinessEdges.ts": "shared",
1673
+ "src/shared/game/grid/zoneWalls.ts": "shared",
1674
+ "src/shared/game/grid/gateCount.ts": "shared",
1668
1675
  "src/shared/game/grid/recovery.ts": "shared",
1669
1676
  "src/shared/game/grid/roadLayout.ts": "shared",
1670
1677
  "src/shared/game/grid/roadRecovery.ts": "shared",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/engine",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "The Wildshard engine: one repo with shared, client, server and cook code and three build targets (client, dedicated server, standalone listen server), shaped like Unreal or Source.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -67,7 +67,7 @@
67
67
  "@sentry/browser": "11.0.0",
68
68
  "@sentry/core": "11.0.0",
69
69
  "@valibot/to-json-schema": "1.8.0",
70
- "@wildshard/format": "npm:@wildshard/shard-format@^0.5.9",
70
+ "@wildshard/format": "npm:@wildshard/shard-format@^0.5.10",
71
71
  "@wildshard/wire": "^0.1.0",
72
72
  "ajv": "6.15.0",
73
73
  "fflate": "0.8.3",
@@ -271,6 +271,7 @@
271
271
  "./script/inputInboxV2": "./src/server/engine/script/inputInboxV2.ts",
272
272
  "./render/programRetention": "./src/client/engine/render/programRetention.ts",
273
273
  "./render/drawnEnvironment": "./src/client/engine/render/drawnEnvironment.ts",
274
+ "./render/drawNeutral": "./src/client/engine/render/drawNeutral.ts",
274
275
  "./models/modelPose": "./src/client/engine/models/modelPose.ts",
275
276
  "./models/ownedGeometry": "./src/client/engine/models/ownedGeometry.ts",
276
277
  "./entities/bodyClear": "./src/server/engine/entities/bodyClear.ts",
@@ -900,6 +901,7 @@
900
901
  "./game/grid/pageMode": "./src/shared/game/grid/pageMode.ts",
901
902
  "./game/grid/gridCollision": "./src/shared/game/grid/gridCollision.ts",
902
903
  "./game/grid/voidFloor": "./src/shared/game/grid/voidFloor.ts",
904
+ "./game/grid/zoneWalls": "./src/shared/game/grid/zoneWalls.ts",
903
905
  "./game/grid/assembly": "./src/shared/game/grid/assembly.ts",
904
906
  "./game/grid/rules": "./src/shared/game/grid/rules.ts",
905
907
  "./game/devColliders": "./src/shared/game/devColliders.ts",
@@ -1300,7 +1302,31 @@
1300
1302
  "./net/webSocketTransport": "./src/client/engine/net/webSocketTransport.ts",
1301
1303
  "./net/otherPlayers": "./src/client/engine/net/otherPlayers.ts",
1302
1304
  "./net/hurtOther": "./src/client/engine/net/hurtOther.ts",
1303
- "./game/plugin/playerSeats": "./src/server/game/plugin/playerSeats.ts"
1305
+ "./game/plugin/playerSeats": "./src/server/game/plugin/playerSeats.ts",
1306
+ "./test/headless-native": "./src/test/game/headlessNative.ts",
1307
+ "./test/headless/checkedReplayPipeline": "./src/test/game/headless/checkedReplayPipeline.ts",
1308
+ "./test/headless/nativeBounds": "./src/test/game/headless/nativeBounds.ts",
1309
+ "./test/headless/ropeBodies": "./src/test/game/headless/ropeBodies.ts",
1310
+ "./test/headless/processUsage": "./src/test/game/headless/processUsage.ts",
1311
+ "./test/builtProduct": "./src/test/game/builtProduct.ts",
1312
+ "./test/simState": "./src/test/engine/simState.ts",
1313
+ "./test/headless-worker": "./src/test/game/headlessWorker.ts",
1314
+ "./test/headless/productSession": "./src/test/game/headless/productSession.ts",
1315
+ "./game/boss/headlessCloudBody": "./src/server/game/boss/headlessCloudBody.ts",
1316
+ "./game/riding/companions": "./src/shared/game/riding/companions.ts",
1317
+ "./game/boss/patrolNative": "./src/server/game/boss/patrolNative.ts",
1318
+ "./game/quest/chapterFlow": "./src/shared/game/quest/chapterFlow.ts",
1319
+ "./practice/lineup": "./src/client/engine/practice/lineup.ts",
1320
+ "./game/quest/effectPresentation": "./src/shared/game/quest/effectPresentation.ts",
1321
+ "./game/shardfile/nativeAssemblyHosts": "./src/server/game/shardfile/nativeAssemblyHosts.ts",
1322
+ "./game/boss/slotsNative": "./src/server/game/boss/slotsNative.ts",
1323
+ "./game/population/encounterBook": "./src/server/game/population/encounterBook.ts",
1324
+ "./game/population/encounterIntake": "./src/server/game/population/encounterIntake.ts",
1325
+ "./game/quest/chapterDecision": "./src/shared/game/quest/chapterDecision.ts",
1326
+ "./game/quest/questObservation": "./src/shared/game/quest/questObservation.ts",
1327
+ "./game/quest/chapterRecords": "./src/server/game/quest/chapterRecords.ts",
1328
+ "./game/boss/arenaCollision": "./src/shared/game/boss/arenaCollision.ts",
1329
+ "./game/boss/arenaGround": "./src/shared/game/boss/arenaGround.ts"
1304
1330
  },
1305
1331
  "sideEffects": [
1306
1332
  "./src/client/**/*",
@@ -3,11 +3,11 @@ import { resolve } from 'node:path';
3
3
 
4
4
  /**
5
5
  * PZ18 (meta PAGE-SIZE, QA 11-13 row 29): the title's code comes in the first wave. The entry imports the grid's page
6
- * entry (`src/client/game/grid/pageEntry.ts`) dynamically, so its static closure (the title-0 chunks) was only requested
7
- * once the entry had run: two serial round trips after the module graph (preview, throttled: 1.07 to 1.29 s of a 1.53 s
8
- * title). The built document now names every chunk of that closure as a `modulepreload` beside the entry's own, so the
9
- * browser fetches them with the first wave. Splicing the links into preview's document moved the throttled title from
10
- * 1.54-1.56 s to 1.26-1.39 s.
6
+ * entry (`src/client/game/grid/pageEntry.ts`) dynamically, so its title chunks were only requested once the entry had
7
+ * run: two serial round trips after the module graph (preview, throttled: 1.07 to 1.29 s of a 1.53 s title). The built
8
+ * document now names the root's static closure and every `title-0-` sibling chunk as `modulepreload` beside the entry's
9
+ * own. The siblings are dynamic imports from the title slice, so the static closure alone leaves a later title request
10
+ * on the wire after the first wave.
11
11
  */
12
12
  export const TITLE_PRELOAD_ROOT = 'src/client/game/grid/pageEntry.ts';
13
13
 
@@ -38,6 +38,9 @@ export function titlePreloadFiles(report, html, root = TITLE_PRELOAD_ROOT) {
38
38
  for (const next of row.imports) visit(next);
39
39
  };
40
40
  for (const [file, row] of Object.entries(report)) if (row.moduleIds.some(id => clean(id) === root)) visit(file);
41
+ // Rolldown places title-only dynamic imports in the same `title-0-` slice but not in the root's static import graph.
42
+ // They still have to join the document's first wave: the title cannot paint until all of them are available.
43
+ for (const chunk of Object.keys(report).filter(path => path.includes('/title-0-')).sort()) visit(chunk);
41
44
  return order.filter(file => !loaded.has(file) && file.endsWith('.js'));
42
45
  }
43
46
 
@@ -0,0 +1,18 @@
1
+ import {junctionTextureSteps, roadTextureSteps} from '../src/client/game/grid/roadSurfaceMaps';
2
+
3
+ async function paint(kind: 'asphalt' | 'junction'): Promise<{kind: string; width: number; height: number; png: number[]}> {
4
+ const steps = kind === 'asphalt' ? roadTextureSteps() : junctionTextureSteps();
5
+ let next = steps.next();
6
+ while (next.done !== true) next = steps.next();
7
+ const texture = next.value, image: unknown = texture.image;
8
+ if (!(image instanceof HTMLCanvasElement)) throw new Error('Road painter must produce a canvas');
9
+ // Compressed textures upload without WebGL flipY; preserve the canvas texture sampler orientation.
10
+ const output = document.createElement('canvas'); output.width = image.width; output.height = image.height;
11
+ const context = output.getContext('2d'); if (context === null) throw new Error('No road bake context');
12
+ context.translate(0, image.height); context.scale(1, -1); context.drawImage(image, 0, 0);
13
+ const blob = await new Promise<Blob>((resolve, reject) => { output.toBlob(value => { if (value === null) reject(new Error('Road PNG encode failed')); else resolve(value); }, 'image/png'); });
14
+ const result = {kind, width: image.width, height: image.height, png: Array.from(new Uint8Array(await blob.arrayBuffer()))};
15
+ texture.dispose();
16
+ return result;
17
+ }
18
+ Object.defineProperty(globalThis, '__bakeRoadSurfaces', {value: () => Promise.all([paint('asphalt'), paint('junction')])});
@@ -0,0 +1,44 @@
1
+ // PZ24d1: reproduce the existing procedural surface maps, then encode phone ASTC 6x6.
2
+ // Run through scripts/browser-lane.sh; scratch and output paths are explicit.
3
+ import {execFileSync} from 'node:child_process';
4
+ import {createHash} from 'node:crypto';
5
+ import {mkdirSync, readFileSync, writeFileSync} from 'node:fs';
6
+ import {join, resolve} from 'node:path';
7
+ import {parseArgs} from 'node:util';
8
+ import {chromium, devices} from 'playwright';
9
+ import {KEYCHAIN_ARGS} from './chromium-keychain.mjs';
10
+
11
+ const {values} = parseArgs({options: {scratch: {type: 'string'}, out: {type: 'string'}}});
12
+ if (values.scratch === undefined || values.out === undefined) throw new Error('Use --scratch=<owned lane folder> --out=<asset folder>');
13
+ const scratch = resolve(values.scratch), out = resolve(values.out);
14
+ mkdirSync(scratch, {recursive: true}); mkdirSync(out, {recursive: true});
15
+ const bundle = join(scratch, 'road-painters.js');
16
+ execFileSync('node_modules/.bin/rolldown', ['scripts/bake-road-surfaces.entry.ts', '--file', bundle, '--format', 'iife'], {stdio: 'ignore'});
17
+ const browser = await chromium.launch({headless: true, args: [...KEYCHAIN_ARGS]});
18
+ /** @type {{kind: string, width: number, height: number, png: number[]}[]} */
19
+ let images;
20
+ try {
21
+ const context = await browser.newContext({...devices['iPhone 16 Pro']});
22
+ const page = await context.newPage();
23
+ await page.addScriptTag({content: readFileSync(bundle, 'utf8')});
24
+ images = await page.evaluate('globalThis.__bakeRoadSurfaces()');
25
+ } finally { await browser.close(); }
26
+ const hash = (/** @type {Uint8Array} */ bytes) => createHash('sha256').update(bytes).digest('hex');
27
+ const encoderVersion = execFileSync('basisu', ['-version'], {encoding: 'utf8'}).split('\n')[0].trim();
28
+ const encoderOptions = ['-ktx2', '-ldr_6x6', '-effort', '4', '-srgb', '-mipmap'];
29
+ const sourcePaths = ['src/client/game/grid/roadSurfaceMaps.ts', 'src/client/game/grid/roadGrain.ts',
30
+ 'src/shared/game/grid/roadLayout.ts', 'scripts/bake-road-surfaces.entry.ts', 'scripts/bake-road-surfaces.mjs'];
31
+ const assets = [];
32
+ for (const image of images) {
33
+ const source = join(scratch, `${image.kind}.png`), target = join(out, `road-${image.kind}-phone.ktx2`);
34
+ writeFileSync(source, Buffer.from(image.png));
35
+ execFileSync('basisu', [...encoderOptions, source, '-output_file', target], {stdio: 'ignore'});
36
+ const bytes = readFileSync(target), levels = bytes.readUInt32LE(40);
37
+ let gpuBytes = 0;
38
+ for (let level = 0; level < levels; level++) gpuBytes += Number(bytes.readBigUInt64LE(80 + level * 24 + 16));
39
+ assets.push({kind: image.kind, file: `road-${image.kind}-phone.ktx2`, width: image.width, height: image.height, levels, bytes: bytes.length, gpuBytes, sha256: hash(bytes)});
40
+ console.log(`${image.kind}: ${image.width}x${image.height}, ${bytes.length} bytes, ${gpuBytes} GPU bytes`);
41
+ }
42
+ writeFileSync(join(out, 'road-surfaces.json'), `${JSON.stringify({format: 2, vkFormat: 166,
43
+ sourcesSHA256: Object.fromEntries(sourcePaths.map(path => [path, hash(readFileSync(path))])),
44
+ encoder: {version: encoderVersion, options: encoderOptions}, assets}, null, 2)}\n`);
@@ -113,7 +113,8 @@ export function pushProblems(lines, cwd = process.cwd()) {
113
113
  if (/^0+$/u.test(local)) return [];
114
114
  const tag = /^refs\/tags\/(v\d+\.\d+\.\d+)$/u.exec(remote)?.[1];
115
115
  if (tag !== undefined) return problemsAt(`${local}^{commit}`, tag, cwd).map(p => `${tag}: ${p}`);
116
- return remote === 'refs/heads/main' ? problemsAt(local, undefined, cwd).map(p => `main: ${p}`) : [];
116
+ return remote === 'refs/heads/main' || remote.startsWith('refs/heads/release/')
117
+ ? problemsAt(local, undefined, cwd).map(p => `${remote.slice('refs/heads/'.length)}: ${p}`) : [];
117
118
  });
118
119
  }
119
120
 
@@ -39,7 +39,7 @@ const exp=arg('exp','')?readFileSync(arg('exp',''),'utf8'):'';// --exp=<file.js>
39
39
  const only=selectGoldenCameraNumbers(arg('cams',''));
40
40
  const slugs=selectGoldenShards(canonical,arg('shards',undefined));
41
41
  const nativeBinding=mode==='shardfile'&&slugs.includes('nine-dragon-stack')?await goldenRefinementBinding(base,source):null;
42
- const FRAMES=120,SETTLE_MS=30000,LIVE=60,FREE=4,EYE=1.7,ON_FOOT=new Set(['far-reach']);
42
+ const FRAMES=120,SETTLE_MS=30000,LIVE=60,FREE=4,EYE=1.7,AWAY=20,ON_FOOT=new Set(['far-reach']);
43
43
  // --textures=ktx2|img pins the page's texture mode (the harness pin, src/engine/boot/gpuFiles.ts) to judge a texture-policy
44
44
  // change on a clean build; omitted, the shipped Auto policy picks
45
45
  const TEXTURES=arg('textures','');if(!['','ktx2','img'].includes(TEXTURES))throw Error(`--textures=${TEXTURES}`);
@@ -53,6 +53,9 @@ const LEVEL_DOWNLOAD=arg('level-download','');if(!['','packs','shardfile'].inclu
53
53
  // out at the URLs they stand in for) are judged on a served build. Pair it with --level-download=shardfile: a pack part is not a request.
54
54
  const SERVE_OVER=arg('serve-over',''),overHits=new Set();
55
55
  const DIRECT=process.argv.includes('--direct');
56
+ // A repeated stationary view can pause the solo room before posing: creatures remain where boot put them while the
57
+ // real local motor and the renderer stream the camera. This never removes a creature or changes authored geometry.
58
+ const STILL_ROOM=process.argv.includes('--still-room');if(STILL_ROOM&&!DIRECT)throw Error('--still-room requires --direct solo entry');
56
59
  mkdirSync(root,{recursive:true});
57
60
 
58
61
  // --engine=webkit: Playwright's WebKit (muted by the game's volume 0; its Escape is a plain key press)
@@ -88,7 +91,7 @@ async function settle(page,inflight){
88
91
 
89
92
  try{for(const slug of slugs){
90
93
  const dir=`${root}/${slug}`;mkdirSync(dir,{recursive:true});
91
- const row={slug,head,engine,device:'iPhone 16 Pro',tier:'phone',dpr:2,seed:357,levelDownload:LEVEL_DOWNLOAD===''?'default':LEVEL_DOWNLOAD,errors:[],warnings:{},poses:[]};
94
+ const row={slug,head,engine,device:'iPhone 16 Pro',tier:'phone',dpr:2,seed:357,stillRoom:STILL_ROOM,levelDownload:LEVEL_DOWNLOAD===''?'default':LEVEL_DOWNLOAD,errors:[],warnings:{},poses:[]};
92
95
  const context=await browser.newContext({...devices['iPhone 16 Pro']});let page;
93
96
  try{
94
97
  await developerSettings(context,{tier:'phone',volume:0,time:'midday',weather:'clear'});
@@ -156,8 +159,11 @@ try{for(const slug of slugs){
156
159
  row.entry=await page.evaluate(()=>({url:location.href,id:window.__wildshard.world.game.level.id}));
157
160
  const want=slug;if(row.entry.id!==want)throw Error(`Not ${mode}: ${row.entry.id}`);row.mode=mode;
158
161
  // the golden camera is a spectator: its player takes no damage (Pine's bear-den elite killed it, and the death fade put it
159
- // back at spawn with the ring and the grass field)
160
- await page.evaluate(()=>{const hp=window.__wildshard.world.game.app.player;if(hp)hp.attributes.incomingCap=0;});
162
+ // back at spawn with the ring and the grass field). The cap holds on a main-thread page. On a worker page only the server lands
163
+ // a blow: Pine's den bears woke, charged, knocked the eye-height player of camera 11 down the slope and killed it, and the shot
164
+ // streamed its ground cover round spawn, 250 m away (meta SH-ALL-11). There the server holds every creature where it stands.
165
+ row.still=await page.evaluate(()=>{const hp=window.__wildshard.world.game.app.player;if(hp)hp.attributes.incomingCap=0;
166
+ if(!window.__workerClientStill)return false;window.__workerClientStill();return true;});
161
167
  for(let i=0;i<canonical[slug].length;i++){
162
168
  const c=canonical[slug][i];if(only&&!only.has(c.n??i+1))continue;
163
169
  const probe=c.probe??{x:c.feet?.[0]??c.eye[0],z:c.feet?.[2]??c.eye[2],yaw:-c.yaw*Math.PI/180,pitch:c.pitch*Math.PI/180,...c.feet?{y:c.feet[1]}:{}};
@@ -166,9 +172,11 @@ try{for(const slug of slugs){
166
172
  const free=c.eye!==undefined&&Math.hypot(c.eye[0]-probe.x,c.eye[2]-probe.z,probe.y===undefined?0:c.eye[1]-EYE-probe.y)>FREE;
167
173
  const at=free?{...probe,x:c.eye[0],y:c.eye[1]-EYE,z:c.eye[2]}:probe;
168
174
  await page.evaluate(()=>{const w=window.__wildshard.world;w.game.hold=false;window.__wsEye=null;
175
+ if(window.__wsGoldenPractice){document.dispatchEvent(new CustomEvent('ws:practice-active',{detail:false}));window.__wsGoldenPractice=false;}
169
176
  // what hangs off the camera before any hover (the held weapon, the hands): the shot keeps only these visible. Taken
170
177
  // once per entry: a board stepped off a moment ago still shows while it fades
171
178
  window.__wsCamOff??=new Set(w.game.camera.children.filter(o=>o.visible));});
179
+ if(STILL_ROOM)await page.evaluate(()=>{document.dispatchEvent(new CustomEvent('ws:practice-active',{detail:true}));window.__wsGoldenPractice=true;});
172
180
  await board(page,false);await page.evaluate(p=>window.__wildshard.pose(p),at);if(free)await board(page,true);
173
181
  await frames(page,FRAMES);const idle=await settle(page,inflight);await frames(page,30);
174
182
  // a player on a slope slides off its pose while streaming settles (Pine's bear den slid into the lake and respawned at
@@ -207,6 +215,7 @@ try{for(const slug of slugs){
207
215
  g.shardFrame();g.composer.render(0);g.shardFrame();g.composer.render(0);
208
216
  return{eye:cam.position.toArray(),rotation:cam.rotation.toArray(),fov:cam.fov,frame:g.frameCount,player,hover:w.player.hover===true,settledEye:e.settled};
209
217
  });
218
+ if(!Number.isFinite(observed.player[0])||!Number.isFinite(observed.player[2])||Math.hypot(observed.player[0]-at.x,observed.player[2]-at.z)>FREE)row.errors.push(`camera ${c.n}: residency player left the probe; repeat solo with --still-room`);
210
219
  const shot=set?`${dir}/${String(c.n).padStart(2,'0')}-${c.name}-${mode}.png`:`${dir}/${i+1}-${c.name}-shardfile.png`;
211
220
  // the 24-camera set hides the HUD (every element but the canvases; a canvas read-back misses Nine's layered composite)
212
221
  // and the minimap: a canvas smaller than half the viewport stays hidden
@@ -215,12 +224,15 @@ try{for(const slug of slugs){
215
224
  await page.screenshot({path:shot,type:'png',scale:'device'});await hide.evaluate(e=>e.remove());}
216
225
  else await page.screenshot({path:shot,type:'png',scale:'css'});
217
226
  await page.evaluate(()=>{for(const o of window.__wsBoards??[])o.visible=true;window.__wsBoards=[];});
218
- row.poses.push({n:c.n??i+1,name:c.name,free,drifted,sunk,idle,live,residency,...observed,...(exp?{exp:expResult}:{}),shot});
227
+ // the ring, the grass and the culling stream round the player: one that ended up far from its pose (killed and respawned,
228
+ // knocked away) shot the camera's view with somewhere else's ground cover, so the frame is an error, not a golden
229
+ const away=Math.hypot(observed.player[0]-at.x,observed.player[2]-at.z);if(away>AWAY)row.errors.push(`camera ${c.n??i+1}: the player stood ${away.toFixed(0)} m from its pose at the shot`);
230
+ row.poses.push({n:c.n??i+1,name:c.name,free,drifted,sunk,away,idle,live,residency,...observed,...(exp?{exp:expResult}:{}),shot});
219
231
  writeFileSync(`${root}/receipts-${slug}.json`,JSON.stringify(row,null,1));
220
232
  }
221
233
  row.status=row.errors.length===0?'complete':'errors';
222
234
  }catch(error){row.status='failed';row.failure=String(error);if(page)await page.screenshot({path:`${dir}/failure.jpg`,type:'jpeg',quality:80,scale:'css'}).catch(()=>{});}
223
235
  finally{if(SERVE_OVER)row.servedOver=[...overHits].sort();rows.push(row);writeFileSync(`${root}/receipts-${slug}.json`,JSON.stringify(row,null,1));writeFileSync(`${root}/receipts.json`,JSON.stringify(rows,null,2));await context.close();
224
236
  console.log(JSON.stringify({slug,status:row.status,poses:row.poses.length,idle:row.poses.map(p=>p.idle.settled),failure:row.failure,errors:row.errors.slice(0,3),warnings:Object.values(row.warnings).reduce((n,c)=>n+c,0),...(SERVE_OVER?{servedOver:overHits.size}:{})}));}
225
- if(row.status==='failed')process.exitCode=1;
237
+ if(row.status!=='complete')process.exitCode=1;
226
238
  }}finally{try{await browser.close();}finally{await owner?.close();}}
@@ -9,3 +9,4 @@ export function observeRefinement<T extends readonly unknown[]>(proto:{add:(...a
9
9
  jobs:{id:T[0];at:T[1];state:string;error?:string}[];
10
10
  };
11
11
  export function heldGoldenResidency():Promise<unknown>;
12
+ export function goldenScriptPaths(graph: unknown, build: string): string[];
@@ -48,12 +48,14 @@ export async function goldenRefinementBinding(base,source) {
48
48
  nineIndexSHA256:createHash('sha256').update(index).digest('hex'),chunk,chunkSHA256:createHash('sha256').update(served).digest('hex')};
49
49
  }
50
50
 
51
- /** This build's code chunks, as served paths: its own folder `b/<build>`, plus the
51
+ /** Prefer the current build's chunk ownership graph (PZ5). Legacy builds use their own folder `b/<build>`, plus the
52
52
  * content-named chunks in the shared `b/c` that its `importmap.json` names (J217
53
53
  * LD6). The shared folder can also hold other builds' chunks, so it is never
54
54
  * listed. A build without `b/<build>` keeps everything in `assets/`.
55
55
  * @param {string} root the preview's dist @param {string} build */
56
56
  export function buildCodeChunks(root,build) {
57
+ const graph=join(root,'deploy-chunks.json');
58
+ if (existsSync(graph)) return goldenScriptPaths(JSON.parse(readFileSync(graph,'utf8')),build).map(file=>`/${file}`);
57
59
  const own=`b/${build}`;
58
60
  if (!existsSync(join(root,own))) return readdirSync(join(root,'assets')).filter(file=>file.endsWith('.js')).map(file=>`/assets/${file}`);
59
61
  const chunks=readdirSync(join(root,own)).filter(file=>file.endsWith('.js')).map(file=>`/${own}/${file}`);
@@ -63,6 +65,17 @@ export function buildCodeChunks(root,build) {
63
65
  return chunks;
64
66
  }
65
67
 
68
+ /** The current build's owned JavaScript, including shared chunks, excluding carry-only files.
69
+ * @param {unknown} graph @param {string} build @returns {string[]} */
70
+ export function goldenScriptPaths(graph,build) {
71
+ const rows=typeof graph==='object'&&graph!==null?Reflect.get(graph,'builds'):undefined;
72
+ if (!Array.isArray(rows)) throw new Error('Golden chunk graph is missing');
73
+ const owners=rows.filter(row=>row?.build===build);
74
+ if (owners.length!==1||!Array.isArray(owners[0].files)) throw new Error('Golden build chunk ownership is ambiguous');
75
+ return owners[0].files.map(row=>row.path).filter(path=>typeof path==='string'&&path.endsWith('.js')
76
+ &&path.startsWith('b/')&&!path.split('/').some(part=>part==='..'||part===''||part.includes('\\')));
77
+ }
78
+
66
79
  /** Fail closed when the compiler shape changes; no guessed export or copied release binding.
67
80
  * @param {string} source */
68
81
  export function refinementExports(source) {