@wildshard/engine 0.1.15 → 0.1.18
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.
- package/CHANGELOG.md +23 -0
- package/index.html +157 -11
- package/lint/engine-sides.json +23 -0
- package/lint/host-callback-syntax.mjs +2 -1
- package/lint/host-callbacks.mjs +3 -3
- package/lint/host-files.mjs +5 -4
- package/lint/host-register.json +496 -0
- package/lint/no-base64.mjs +3 -1
- package/lint/ratchet.json +2 -2
- package/lint/shard-imports.d.mts +1 -0
- package/lint/shard-imports.mjs +60 -13
- package/lint/shard-source.d.mts +9 -0
- package/lint/shard-source.mjs +91 -0
- package/lint/shardfile-boundaries.mjs +10 -8
- package/lint/sim-closure.mjs +6 -3
- package/lint/wildshard-plugin.d.ts +4 -0
- package/lint/wildshard-plugin.js +44 -27
- package/package.json +24 -6
- package/scripts/app-build/buildIdentity.d.mts +3 -1
- package/scripts/app-build/buildIdentity.mjs +25 -5
- package/scripts/app-build/builtAt.d.mts +4 -0
- package/scripts/app-build/builtAt.mjs +21 -0
- package/scripts/app-build/outputProducts.d.mts +3 -0
- package/scripts/app-build/outputProducts.mjs +31 -0
- package/scripts/app-build/serviceWorker.ts +16 -2
- package/scripts/app-build/versionFiles.ts +2 -1
- package/scripts/app-build-pipeline.mjs +7 -1
- package/scripts/audio-download-proof.mjs +843 -0
- package/scripts/build-app.mjs +4 -0
- package/scripts/build-mirror.d.mts +2 -0
- package/scripts/build-mirror.mjs +5 -4
- package/scripts/built-product.mjs +3 -3
- package/scripts/cell-mem/metrics-preload.mjs +65 -0
- package/scripts/cell-mem-bench.mjs +130 -0
- package/scripts/check-chunks.mjs +2 -1
- package/scripts/check-devserver.mjs +1 -1
- package/scripts/chromium-keychain-check.mjs +4 -2
- package/scripts/chromium-keychain.mjs +3 -1
- package/scripts/cook.mjs +7 -3
- package/scripts/devices.d.mts +4 -0
- package/scripts/devices.mjs +39 -0
- package/scripts/devserver-client.d.mts +7 -0
- package/scripts/devserver-client.mjs +85 -0
- package/scripts/doctor-proof.mjs +1 -1
- package/scripts/e2e-faults.mjs +159 -0
- package/scripts/engine-ci-budget.ts +7 -1
- package/scripts/format-lock.mjs +20 -11
- package/scripts/generate-title-launch.mjs +3 -2
- package/scripts/grid-crossing-walk-proof.mjs +30 -11
- package/scripts/heavy-lane.py +25 -1
- package/scripts/host-ruler/register-migrate.mjs +242 -0
- package/scripts/host-ruler/register.d.mts +36 -0
- package/scripts/host-ruler/register.mjs +116 -0
- package/scripts/host-ruler/roots.d.mts +29 -0
- package/scripts/host-ruler/roots.mjs +333 -0
- package/scripts/host-ruler/server-roots.d.mts +23 -0
- package/scripts/host-ruler/server-roots.mjs +272 -0
- package/scripts/main-watch.d.mts +1 -1
- package/scripts/main-watch.mjs +10 -6
- package/scripts/map-hash.mjs +3 -6
- package/scripts/memory-proof.mjs +158 -0
- package/scripts/mmo-bots.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +5 -2
- package/scripts/offline-proof-rules.mjs +43 -6
- package/scripts/offline-proof.mjs +15 -6
- package/scripts/online-rig.mjs +4 -4
- package/scripts/page-release/flow.d.mts +1 -0
- package/scripts/page-release/flow.mjs +6 -2
- package/scripts/page-release.mjs +5 -1
- package/scripts/physics-route.json +0 -71
- package/scripts/pins-catalogue.ts +103 -0
- package/scripts/pins-reuse.mjs +3 -1
- package/scripts/pins.ts +22 -14
- package/scripts/preview-grid.ts +203 -0
- package/scripts/road-preload-proof.mjs +167 -0
- package/scripts/server-release/publish.mjs +2 -2
- package/scripts/server-release/served-slug.d.mts +2 -0
- package/scripts/server-release/served-slug.mjs +10 -0
- package/scripts/server-release/sign.d.mts +1 -0
- package/scripts/server-release/sign.mjs +3 -7
- package/scripts/shard-components.mjs +0 -2
- package/scripts/shard-outputs.d.mts +8 -0
- package/scripts/shard-outputs.mjs +45 -11
- package/scripts/side-parity.d.mts +2 -1
- package/scripts/side-parity.mjs +25 -4
- package/scripts/test-amber.d.mts +1 -0
- package/scripts/test-amber.mjs +10 -0
- package/scripts/test-products.json +3 -3
- package/scripts/tier-textures-proof.mjs +101 -0
- package/scripts/tier-textures.mjs +60 -0
- package/scripts/tracked-public.d.mts +1 -0
- package/scripts/tracked-public.mjs +17 -0
- package/scripts/tsconfig.json +1 -0
- package/scripts/vps/wildshard-config +79 -23
- package/scripts/worker-client-play.mjs +1 -0
- package/scripts/worker-client-proof.mjs +1 -1
- package/scripts/worker-client-slug.mjs +44 -0
- package/src/cli/engine.mjs +8 -0
- package/src/client/app/bootRoute.ts +4 -1
- package/src/client/app/dropModal.ts +15 -2
- package/src/client/app/entry.ts +96 -13
- package/src/client/app/slugPath.ts +5 -0
- package/src/client/engine/audio/Audio.ts +20 -2
- package/src/client/engine/boot/bakedTextures.ts +3 -2
- package/src/client/engine/boot/bootTrace.ts +6 -1
- package/src/client/engine/boot/bytes.ts +4 -3
- package/src/client/engine/boot/clearDownloads.ts +1 -1
- package/src/client/engine/boot/contentRead.ts +4 -0
- package/src/client/engine/boot/dropNotice.ts +20 -6
- package/src/client/engine/boot/gpuFiles.ts +25 -2
- package/src/client/engine/boot/lastEnd.ts +8 -2
- package/src/client/engine/boot/parsedPages.ts +127 -58
- package/src/client/engine/boot/shardPrefetch.ts +7 -1
- package/src/client/engine/boot/sw.ts +19 -0
- package/src/client/engine/build.d.ts +2 -0
- package/src/client/engine/core/Game.ts +29 -3
- package/src/client/engine/core/GpuRecovery.ts +7 -0
- package/src/client/engine/core/Volumetrics.ts +5 -0
- package/src/client/engine/core/assets.ts +27 -20
- package/src/client/engine/core/bootstrap.ts +5 -3
- package/src/client/engine/core/ktx2.ts +84 -11
- package/src/client/engine/debug/probe.ts +18 -1
- package/src/client/engine/explore/Compare.ts +2 -2
- package/src/client/engine/explore/TouchFly.ts +3 -5
- package/src/client/engine/fx/LightPool.ts +41 -1
- package/src/client/engine/input/dom.ts +12 -0
- package/src/client/engine/net/predictor.ts +6 -2
- package/src/client/engine/player/Player.ts +10 -2
- package/src/client/engine/player/TouchControls.ts +12 -4
- package/src/client/engine/pwa/sw.js +59 -11
- package/src/client/engine/render/drawCheck.ts +96 -0
- package/src/client/engine/render/precompile.ts +20 -14
- package/src/client/engine/saves/staleBuildNote.ts +46 -0
- package/src/client/engine/telemetry/browserErrors.ts +161 -21
- package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
- package/src/client/engine/telemetry/screenOutbox.ts +61 -0
- package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
- package/src/client/engine/ui/DeathFade.ts +99 -11
- package/src/client/engine/ui/ErrorModal.ts +13 -6
- package/src/client/engine/ui/Feedback.ts +2 -1
- package/src/client/engine/ui/Loading.ts +10 -6
- package/src/client/engine/ui/Map.ts +2 -1
- package/src/client/engine/ui/WeaponStrip.ts +2 -1
- package/src/client/engine/ui/backGuard.ts +104 -0
- package/src/client/engine/ui/hudAdapters.ts +30 -4
- package/src/client/engine/ui/loading.css +17 -0
- package/src/client/engine/ui/namePrompt.ts +6 -5
- package/src/client/engine/ui/styles/combat.css +12 -0
- package/src/client/engine/ui/styles/namePrompt.css +4 -2
- package/src/client/game/boot/audio.generated.ts +0 -396
- package/src/client/game/boot/bytes.generated.ts +42 -71
- package/src/client/game/boot/versions.generated.ts +0 -13
- package/src/client/game/compendium/keepsakes.ts +16 -6
- package/src/client/game/grapple/tool.ts +10 -7
- package/src/client/game/grid/area.ts +38 -0
- package/src/client/game/grid/cellLoading.ts +23 -12
- package/src/client/game/grid/cellScreens.ts +39 -74
- package/src/client/game/grid/live.ts +28 -2
- package/src/client/game/grid/liveSession.ts +54 -10
- package/src/client/game/grid/menu.ts +4 -0
- package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
- package/src/client/game/grid/nearPlaceholderView.ts +9 -3
- package/src/client/game/grid/neighbourPanels.ts +10 -1
- package/src/client/game/grid/oneWayIn.ts +92 -27
- package/src/client/game/grid/pageEntry.ts +19 -0
- package/src/client/game/grid/pageShell.ts +1 -1
- package/src/client/game/grid/placedCards.ts +55 -0
- package/src/client/game/grid/placedCells.ts +131 -0
- package/src/client/game/grid/plotAudio.ts +114 -0
- package/src/client/game/grid/products.ts +55 -5
- package/src/client/game/grid/regionalRuntime.ts +6 -0
- package/src/client/game/grid/regionalWorld.ts +15 -2
- package/src/client/game/grid/roadCull.ts +44 -14
- package/src/client/game/grid/roadLookPlatform.ts +2 -2
- package/src/client/game/grid/roadTileBacking.ts +13 -3
- package/src/client/game/grid/session.ts +47 -22
- package/src/client/game/grid/shardfileFar.ts +9 -3
- package/src/client/game/grid/spawnGround.ts +68 -0
- package/src/client/game/grid/voidLook.ts +29 -23
- package/src/client/game/loot/runtime.ts +3 -1
- package/src/client/game/mainMenu.ts +14 -6
- package/src/client/game/riding/hud.ts +6 -4
- package/src/client/game/session/finish.ts +22 -4
- package/src/client/game/session/play.ts +8 -2
- package/src/client/game/session/session.ts +4 -1
- package/src/client/game/shard/titleList.ts +6 -2
- package/src/client/game/shardfile/clientWorker.ts +43 -13
- package/src/client/game/shardfile/serverRoute.ts +10 -22
- package/src/client/game/slugPage.css +11 -0
- package/src/client/game/slugPage.ts +84 -0
- package/src/client/game/systems/viewmodel/heldView.ts +6 -3
- package/src/client/game/titleDeck.ts +56 -32
- package/src/client/host/online/doctor.ts +7 -6
- package/src/client/host/online/linkScreens.ts +16 -0
- package/src/client/host/online/release.ts +51 -5
- package/src/client/host/online/shell.ts +62 -27
- package/src/client/host/standalone/shell.ts +7 -3
- package/src/cook/game/audioReport.ts +57 -0
- package/src/cook/game/entryTotals.ts +26 -6
- package/src/cook/game/installedRuntimeReads.ts +3 -0
- package/src/cook/game/shardCook.ts +38 -8
- package/src/cook/game/tierTextures.ts +276 -0
- package/src/e2e/smoke/game.ts +19 -14
- package/src/e2e/smoke/page-globals.d.ts +9 -8
- package/src/e2e/smoke/template2.spec.ts +8 -7
- package/src/server/engine/sim/respawn.ts +6 -1
- package/src/server/engine/sim.ts +3 -0
- package/src/server/game/grid/simulation.ts +35 -0
- package/src/server/game/loot/harvest.ts +2 -0
- package/src/server/game/loot/keepsakeProgression.ts +40 -0
- package/src/server/game/loot/playerOwned.ts +5 -1
- package/src/server/game/plugin/simulation.ts +4 -0
- package/src/server/game/population/nativeBake.ts +2 -1
- package/src/server/game/quest/chapterRecords.ts +2 -0
- package/src/server/game/quest/serverChapters.ts +4 -0
- package/src/server/game/quest/serverDoors.ts +11 -5
- package/src/server/game/roomRespawn.ts +4 -0
- package/src/server/game/shardfile/installedSides.ts +18 -0
- package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
- package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
- package/src/server/host/bake/headlessWorker.ts +5 -1
- package/src/server/host/dedicated/cellHost.ts +98 -29
- package/src/server/host/dedicated/cellProtocol.ts +11 -1
- package/src/server/host/dedicated/cellWorker.ts +9 -3
- package/src/server/host/dedicated/crossing.ts +6 -2
- package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
- package/src/server/host/dedicated/gridCells.ts +52 -9
- package/src/server/host/dedicated/main.ts +31 -12
- package/src/server/host/dedicated/placementFile.ts +56 -0
- package/src/server/host/dedicated/releaseFile.ts +17 -10
- package/src/server/host/dedicated/roadRoom.ts +21 -5
- package/src/server/host/dedicated/socketTransport.ts +2 -1
- package/src/server/host/dedicated/workerTable.ts +13 -1
- package/src/server/host/dedicated/world.ts +111 -10
- package/src/server/host/headlessRuntime.ts +10 -5
- package/src/server/host/installers.ts +62 -0
- package/src/server/host/openWorld.ts +59 -0
- package/src/server/host/ropeDecks.ts +2 -0
- package/src/server/host/standalone/cellWorld.ts +25 -19
- package/src/server/host/standalone/fallFloor.ts +2 -2
- package/src/server/host/standalone/gridServer.ts +7 -4
- package/src/server/host/standalone/roadWorld.ts +41 -4
- package/src/shared/engine/audio/bootAudio.ts +33 -0
- package/src/shared/engine/level/spec.ts +3 -3
- package/src/shared/engine/net/acts.ts +3 -0
- package/src/shared/engine/net/deviceWord.ts +138 -0
- package/src/shared/engine/net/socketFrames.ts +7 -4
- package/src/shared/engine/physics/query.ts +27 -0
- package/src/shared/engine/physics/terrain.ts +19 -28
- package/src/shared/engine/saves/saves.lock.json +15 -0
- package/src/shared/engine/sim/actRoutes.ts +2 -0
- package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
- package/src/shared/game/grid/catalogue.ts +12 -5
- package/src/shared/game/grid/catalogueSlot.ts +18 -0
- package/src/shared/game/grid/farProxy.ts +6 -5
- package/src/shared/game/grid/pageMode.ts +1 -1
- package/src/shared/game/grid/placementRows.ts +33 -0
- package/src/shared/game/grid/roadLayout.ts +26 -3
- package/src/shared/game/grid/singleplayer.json +0 -13
- package/src/shared/game/grid/voidFloor.ts +122 -0
- package/src/shared/game/strings.ts +15 -0
- package/src/shared/host/standalone/netInput.ts +2 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ROAD-PRELOAD (meta docs/plans/ROAD-PRELOAD-PLAN.md, J320, Jake 2026-11-13: "I just want to be able to instantaneously go onto
|
|
3
|
+
// the road"): one Shard Select entry into Driftwood on a preview build (its in-page server hosts the grid, J311), then a walk off
|
|
4
|
+
// the cell's west entryway onto the road by real input. It reports what DOWNLOAD fetched before control (all bytes, and the
|
|
5
|
+
// road's share: the grid strip book, page and mesh and the seams), what the grid had built at control (strips, road look), and
|
|
6
|
+
// the walk: the time from the feet leaving the cell (|x| > 250) to 12 m onto the deck, and the worst stop on the way.
|
|
7
|
+
// Headless WebKit (or Chromium) at Jake's phone layout, 402×874 with touch. Never production.
|
|
8
|
+
// node scripts/road-preload-proof.mjs <out dir> --base=<preview url> [--engine=webkit|chromium] [--card=Driftwood Isle]
|
|
9
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { join, resolve as absolute } from 'node:path';
|
|
11
|
+
import { chromium, webkit } from 'playwright';
|
|
12
|
+
import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
|
|
13
|
+
import { saveFixture } from './debug-settings.mjs';
|
|
14
|
+
|
|
15
|
+
/** @param {string} name @param {string} fallback */
|
|
16
|
+
const flag = (name, fallback) => process.argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback;
|
|
17
|
+
const out = absolute(process.argv.slice(2).find(arg => !arg.startsWith('--')) ?? '');
|
|
18
|
+
const base = flag('base', '').replace(/\/$/u, ''), engineName = flag('engine', 'webkit');
|
|
19
|
+
if (out === absolute('') || base === '') throw new Error('usage: road-preload-proof.mjs <out dir> --base=<preview url> [--engine=webkit|chromium]');
|
|
20
|
+
if (/play\.wildshard\.io|^https?:\/\/(?:www\.)?wildshard\.io/u.test(base)) throw new Error('Never production (J205)');
|
|
21
|
+
mkdirSync(out, { recursive: true });
|
|
22
|
+
const CARD = flag('card', 'Driftwood Isle'), HALF = 250, ONTO = 12, STUCK_MS = 1500, WALK_MS = 60_000;
|
|
23
|
+
/** @param {number} ms */
|
|
24
|
+
const sleep = ms => new Promise(resolve => { setTimeout(resolve, ms); });
|
|
25
|
+
const roadAsset = (/** @type {string} */ url) => /\/assets\/grid-(?:strip-(?:book|page|mesh)|seams|seam-plans)-/u.test(url);
|
|
26
|
+
|
|
27
|
+
const browser = await (engineName === 'webkit' ? webkit : chromium).launch({ headless: true,
|
|
28
|
+
args: engineName === 'chromium' ? [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist'] : [] });
|
|
29
|
+
/** @type {Record<string, unknown>} */
|
|
30
|
+
const result = { engine: engineName, layout: 'phone 402x874 touch', base, version: await fetch(`${base}/version.json`).then(found => found.json()).catch(() => null) };
|
|
31
|
+
let code = 1;
|
|
32
|
+
try {
|
|
33
|
+
const context = await browser.newContext({ viewport: { width: 402, height: 874 }, hasTouch: true, ...engineName === 'webkit' ? { isMobile: true } : {} });
|
|
34
|
+
await saveFixture(context, { scope: 'device', key: 'firstPlayDone', data: true });
|
|
35
|
+
const page = await context.newPage();
|
|
36
|
+
page.on('pageerror', error => { console.log(`pageerror ${String(error).slice(0, 200)}`); });
|
|
37
|
+
/** @type {{ url: string, bytes: number, at: number, phase: string }[]} */
|
|
38
|
+
const fetched = [];
|
|
39
|
+
let phase = 'title';
|
|
40
|
+
/** @type {Promise<unknown>[]} */
|
|
41
|
+
const sizing = [];
|
|
42
|
+
// The phase and time are read when the request finishes, not when its sizes arrive. Page-visible requests only: the service
|
|
43
|
+
// worker's own fetches never reach these events (and WebKit reports none), so the spawn manifests are the byte authority.
|
|
44
|
+
page.on('requestfinished', request => { const row = { url: request.url().replace(base, ''), at: Date.now(), phase };
|
|
45
|
+
sizing.push(request.sizes().then(sizes => fetched.push({ ...row, bytes: sizes.responseBodySize + sizes.responseHeadersSize })).catch(() => undefined)); });
|
|
46
|
+
await page.goto(`${base}/?mute=1&nolock=1`, { waitUntil: 'load' });
|
|
47
|
+
// DOWNLOAD starts at the card (the title reads ahead on a pick), so the entry's bytes count from SHARD SELECT.
|
|
48
|
+
await page.locator('.ws-main-select').waitFor({ state: 'visible', timeout: 120_000 });
|
|
49
|
+
phase = 'entry';
|
|
50
|
+
await page.locator('.ws-main-select').click();
|
|
51
|
+
if (await page.locator('#ws-name-box input').waitFor({ timeout: 20_000 }).then(() => true).catch(() => false)) { await page.locator('#ws-name-box input').fill('walker'); await page.locator('#ws-name-box button[type=submit]').click(); }
|
|
52
|
+
await page.locator('.ws-menu-card').first().waitFor({ state: 'visible', timeout: 30_000 });
|
|
53
|
+
const index = await page.evaluate(card => [...document.querySelectorAll('.ws-menu-card')].findIndex(row => (row.textContent ?? '').includes(card)), CARD);
|
|
54
|
+
if (index < 0) throw new Error(`No ${CARD} card`);
|
|
55
|
+
await page.locator('.ws-menu-dots i').nth(index).click();
|
|
56
|
+
await page.waitForFunction(card => [...document.querySelectorAll('.ws-menu-card')].some(row => (row.textContent ?? '').includes(card) && row.getBoundingClientRect().left >= 0 && row.getBoundingClientRect().right <= innerWidth + 1), CARD, { timeout: 10_000 });
|
|
57
|
+
const played = Date.now();
|
|
58
|
+
await page.locator('.ws-menu-play').click();
|
|
59
|
+
await page.waitForFunction(() => /** @type {any} */ (window).__wildshard?.shard?.grid?.state?.().live?.live?.gameplayReady === true, undefined, { timeout: 240_000, polling: 100 });
|
|
60
|
+
result.playToControlMs = Date.now() - played;
|
|
61
|
+
phase = 'play';
|
|
62
|
+
// What the grid had at control: its collision strips and whether the road look had landed.
|
|
63
|
+
result.atControl = await page.evaluate(() => {
|
|
64
|
+
const st = /** @type {any} */ (window).__wildshard.shard.grid.state();
|
|
65
|
+
return { inside: st.inside, strips: st.strips, road: st.road, ringsReady: st.ringsReady };
|
|
66
|
+
});
|
|
67
|
+
await Promise.all(sizing);
|
|
68
|
+
const entry = fetched.filter(row => row.phase === 'entry');
|
|
69
|
+
const road = entry.filter(row => roadAsset(row.url));
|
|
70
|
+
result.download = { entryBytes: entry.reduce((sum, row) => sum + row.bytes, 0), files: entry.length,
|
|
71
|
+
roadBytes: road.reduce((sum, row) => sum + row.bytes, 0), road: road.map(row => ({ url: row.url, bytes: row.bytes })),
|
|
72
|
+
largest: [...entry].sort((a, b) => b.bytes - a.bytes).slice(0, 12).map(row => ({ url: row.url.slice(0, 120), bytes: row.bytes })) };
|
|
73
|
+
console.log(`control after ${String(result.playToControlMs)} ms; entry ${String(entry.length)} files; road ${String(road.length)} page-visible files`);
|
|
74
|
+
await sleep(1500);
|
|
75
|
+
await page.getByText('DONE', { exact: true }).click({ timeout: 2000 }).catch(() => undefined);
|
|
76
|
+
await page.evaluate(() => {
|
|
77
|
+
const W = /** @type {any} */ (window), q = W.__roadpre = { samples: /** @type {unknown[]} */ ([]), frames: /** @type {number[][]} */ ([]) }, t0 = performance.now();
|
|
78
|
+
let lastFrame = t0;
|
|
79
|
+
const raf = (/** @type {number} */ now) => { q.frames.push([Math.round(now - t0), Math.round(now - lastFrame)]); lastFrame = now; requestAnimationFrame(raf); };
|
|
80
|
+
requestAnimationFrame(raf);
|
|
81
|
+
setInterval(() => { try {
|
|
82
|
+
const st = W.__wildshard.shard.grid.state(), p = W.__wildshard.world.player;
|
|
83
|
+
q.samples.push({ t: Math.round(performance.now() - t0), x: Number(p.position.x.toFixed(2)), y: Number(p.position.y.toFixed(2)), z: Number(p.position.z.toFixed(2)), inside: st.inside, loading: st.cellLoading, closed: st.softWalls?.closed });
|
|
84
|
+
} catch (error) { q.samples.push({ err: String(error).slice(0, 160) }); } }, 100);
|
|
85
|
+
});
|
|
86
|
+
await sleep(400);
|
|
87
|
+
/** @returns {Promise<any>} */
|
|
88
|
+
const sample = () => page.evaluate(() => { const rows = /** @type {any[]} */ (/** @type {any} */ (window).__roadpre.samples); for (let at = rows.length - 1; at >= 0; at--) if (rows[at].err === undefined) return rows[at]; return undefined; });
|
|
89
|
+
const face = (/** @type {number} */ yaw) => page.evaluate(wanted => { /** @type {any} */ (window).__wildshard.world.player.yaw = wanted; }, yaw);
|
|
90
|
+
const toward = async (/** @type {number} */ x, /** @type {number} */ z) => { const at = await sample(); await face(Math.atan2(at.x - x, at.z - z)); return Math.hypot(at.x - x, at.z - z); };
|
|
91
|
+
// Approach (boosted, not scored): Driftwood's west entryway, the 8 m gap at the middle of its west edge.
|
|
92
|
+
await page.keyboard.down('ShiftLeft');
|
|
93
|
+
for (const [x, z] of [[-235, -194], [-235, 0]]) {
|
|
94
|
+
await page.keyboard.down('KeyW');
|
|
95
|
+
let near = Infinity, stuck = 0, before = await sample();
|
|
96
|
+
for (const ends = Date.now() + 90_000; Date.now() < ends && near > 3; await sleep(250)) {
|
|
97
|
+
near = await toward(x, z);
|
|
98
|
+
const now = await sample(); if (Math.hypot(now.x - before.x, now.z - before.z) >= 0.15) stuck = 0; else if (++stuck % 6 === 0) await page.keyboard.press('Space');
|
|
99
|
+
before = now;
|
|
100
|
+
}
|
|
101
|
+
await page.keyboard.up('KeyW');
|
|
102
|
+
console.log(`approach (${String(x)}, ${String(z)}): ${String(Math.round(near))} m off`);
|
|
103
|
+
if (near > 3) throw new Error(`The approach stopped ${String(Math.round(near))} m short of (${String(x)}, ${String(z)}): not scored`);
|
|
104
|
+
}
|
|
105
|
+
await page.keyboard.up('ShiftLeft'); await sleep(500);
|
|
106
|
+
// The walk (scored): west, by real input, until 12 m past the cell edge.
|
|
107
|
+
await toward(-400, 0);
|
|
108
|
+
const t1 = Date.now(), pageFrom = (await sample()).t;
|
|
109
|
+
let last = await sample(), stuckSince = 0, worstStop = 0, leftAt = 0, ontoAt = 0;
|
|
110
|
+
const events = [];
|
|
111
|
+
await page.keyboard.down('KeyW');
|
|
112
|
+
while (Date.now() - t1 < WALK_MS) {
|
|
113
|
+
await sleep(200);
|
|
114
|
+
const s = await sample(); if (s === undefined) continue;
|
|
115
|
+
const at = Date.now() - t1, moved = Math.hypot(s.x - last.x, s.z - last.z);
|
|
116
|
+
if (s.inside !== last.inside || s.loading !== last.loading) events.push({ at, inside: s.inside, loading: s.loading, x: s.x });
|
|
117
|
+
if (leftAt === 0 && Math.abs(s.x) > HALF) leftAt = at;
|
|
118
|
+
if (moved < 0.1) stuckSince ||= at; else { if (stuckSince !== 0) { worstStop = Math.max(worstStop, at - stuckSince); if (at - stuckSince >= 400) events.push({ at, stoppedMs: at - stuckSince, x: s.x, y: s.y }); } stuckSince = 0; }
|
|
119
|
+
if (stuckSince !== 0 && at - stuckSince > STUCK_MS) { events.push({ at, stuck: true, x: s.x, z: s.z }); break; }
|
|
120
|
+
last = s;
|
|
121
|
+
if (ontoAt === 0 && Math.abs(s.x) > HALF + ONTO) ontoAt = at;
|
|
122
|
+
if (Math.abs(s.x) > HALF + 30) break;
|
|
123
|
+
}
|
|
124
|
+
await page.keyboard.up('KeyW');
|
|
125
|
+
if (stuckSince !== 0) worstStop = Math.max(worstStop, Date.now() - t1 - stuckSince);
|
|
126
|
+
// The page's own 100 ms samples and every frame of the walk (they carry their own clock): a stop is a run of samples that
|
|
127
|
+
// didn't move, a hitch a long frame. The window opens at the first movement and closes at the last sample.
|
|
128
|
+
/** @type {{ samples: { t: number, x: number, y: number, inside: string | null }[], frames: number[][] }} */
|
|
129
|
+
const window_ = await page.evaluate(from => {
|
|
130
|
+
const q = /** @type {any} */ (window).__roadpre, samples = q.samples.filter((/** @type {any} */ row) => row.t >= from && row.err === undefined), end = samples.at(-1)?.t ?? from;
|
|
131
|
+
return { samples, frames: q.frames.filter((/** @type {number[]} */ row) => (row[0] ?? 0) >= from && (row[0] ?? 0) <= end) };
|
|
132
|
+
}, pageFrom);
|
|
133
|
+
await page.screenshot({ path: join(out, `${engineName}-on-road.png`) });
|
|
134
|
+
const moving = window_.samples.findIndex((row, at) => at > 0 && Math.abs(row.x - (window_.samples[at - 1]?.x ?? row.x)) >= 0.05);
|
|
135
|
+
const page100 = window_.samples.slice(Math.max(0, moving - 1)), start = page100[0]?.t ?? pageFrom;
|
|
136
|
+
/** @type {{ from: number, ms: number, x: number, open?: true }[]} */
|
|
137
|
+
const stops = [];
|
|
138
|
+
let since = 0;
|
|
139
|
+
for (let at = 1; at < page100.length; at++) {
|
|
140
|
+
const a = page100[at - 1], b = page100[at]; if (a === undefined || b === undefined) continue;
|
|
141
|
+
if (Math.abs(b.x - a.x) < 0.05) since ||= a.t; else if (since !== 0) { if (b.t - since >= 250) stops.push({ from: since - start, ms: b.t - since, x: a.x }); since = 0; }
|
|
142
|
+
}
|
|
143
|
+
const lastRow = page100.at(-1);
|
|
144
|
+
if (since !== 0 && lastRow !== undefined && lastRow.t - since >= 250) stops.push({ from: since - start, ms: lastRow.t - since, x: lastRow.x, open: true });
|
|
145
|
+
const crossing = page100.find(row => Math.abs(row.x) > HALF)?.t ?? 0, onto = page100.find(row => Math.abs(row.x) > HALF + ONTO)?.t ?? 0;
|
|
146
|
+
// Speed (m/s) over the last 10 m inside the cell and the 12 m onto the deck: the road must be no slower than the cell.
|
|
147
|
+
const speed = (/** @type {number} */ from, /** @type {number} */ to) => { const a = page100.find(row => Math.abs(row.x) >= from), b = page100.find(row => Math.abs(row.x) >= to);
|
|
148
|
+
return a === undefined || b === undefined || b.t === a.t ? null : Number(((Math.abs(b.x) - Math.abs(a.x)) / ((b.t - a.t) / 1000)).toFixed(2)); };
|
|
149
|
+
const lowest = Math.min(...page100.filter(row => Math.abs(row.x) > HALF).map(row => row.y));
|
|
150
|
+
result.page = { edgeToRoadMs: crossing !== 0 && onto !== 0 ? onto - crossing : null, speed: { cellLast10m: speed(HALF - 10, HALF), edgeToRoad: speed(HALF, HALF + ONTO) }, stops,
|
|
151
|
+
lowestOnDeck: Number.isFinite(lowest) ? lowest : null, worstFrameMs: Math.max(0, ...window_.frames.map(row => row[1] ?? 0)), framesOver50: window_.frames.filter(row => (row[1] ?? 0) > 50).length, frames: window_.frames.length,
|
|
152
|
+
nearEdgeFrames: window_.frames.filter(row => Math.abs((row[0] ?? 0) - crossing) < 3000 && (row[1] ?? 0) > 50).map(row => [(row[0] ?? 0) - start, row[1]]),
|
|
153
|
+
leftHomeAt: page100.find(row => row.inside === null) ?? null };
|
|
154
|
+
// What the page did as it left the cell: the crossing's phases, the leave and the cell runtime's hooks (their own timings).
|
|
155
|
+
result.leave = await page.evaluate(() => { const live = /** @type {any} */ (window).__wildshard.shard.grid.state().live;
|
|
156
|
+
return live === null ? null : { crossingTiming: live.crossingTiming, leaveTiming: live.leaveTiming, crossing: live.crossing }; });
|
|
157
|
+
console.log(`page ${JSON.stringify(result.page)}`);
|
|
158
|
+
console.log(`leave ${JSON.stringify(result.leave).slice(0, 3000)}`);
|
|
159
|
+
result.walk = { leftCellAtMs: leftAt, ontoRoadAtMs: ontoAt, worstStopMs: worstStop, end: last, events };
|
|
160
|
+
console.log(`walk ${JSON.stringify(result.walk)}`);
|
|
161
|
+
// RP4's bar: onto the deck (12 m past the edge, standing on it), no page stop of 250 ms or more and no frame over 50 ms near the edge.
|
|
162
|
+
const pageRow = /** @type {{ edgeToRoadMs: number | null, stops: unknown[], lowestOnDeck: number | null, nearEdgeFrames: unknown[] }} */ (result.page);
|
|
163
|
+
code = pageRow.edgeToRoadMs !== null && (pageRow.lowestOnDeck ?? -1) > -0.5 && pageRow.stops.length === 0 && pageRow.nearEdgeFrames.length === 0 ? 0 : 1;
|
|
164
|
+
console.log(code === 0 ? 'PASS onto the road with no stop' : 'FAIL a stop, a long frame or no road (see page)');
|
|
165
|
+
} catch (error) { result.error = String(error); console.log(`FAIL ${String(error)}`); }
|
|
166
|
+
finally { await browser.close(); writeFileSync(join(out, `${engineName}.json`), JSON.stringify(result, null, 2)); }
|
|
167
|
+
process.exit(code);
|
|
@@ -7,7 +7,7 @@ import { parseArgs } from 'node:util';
|
|
|
7
7
|
import { GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client, S3ServiceException } from '@aws-sdk/client-s3';
|
|
8
8
|
import * as v from 'valibot';
|
|
9
9
|
import { readServerPackBook, serverPackBookPath } from '../../src/shared/game/shardfile/serverPack.ts';
|
|
10
|
-
import { bundleDescriptor, COMMIT, publication, readPublication, releasePublicKey, releaseShards, signRelease } from './sign.mjs';
|
|
10
|
+
import { bundleDescriptor, COMMIT, DEFAULT_SERVER_SHARDS, publication, readPublication, releasePublicKey, releaseShards, signRelease } from './sign.mjs';
|
|
11
11
|
|
|
12
12
|
/** @typedef {import('../../src/shared/host/releaseRows.ts').ReleaseFile} ReleaseFile */
|
|
13
13
|
/** @typedef {{client: S3Client, bucket: string, candidate: ReleaseFile, privateKey: string, publicKey: string, isAncestor: (older: string, newer: string) => boolean,
|
|
@@ -119,7 +119,7 @@ async function main() {
|
|
|
119
119
|
const epoch = v.parse(v.object({ saveEpoch: v.pipe(v.number(), v.integer(), v.minValue(1)) }), JSON.parse(sourceFile('save-epoch.json'))).saveEpoch;
|
|
120
120
|
const shardNames = process.env.E7_SERVER_SHARDS?.trim();
|
|
121
121
|
const candidate = publication({ channel: values.channel, serial: 1, engineBuild: values.build, saveEpoch: epoch,
|
|
122
|
-
shards: releaseShards(JSON.parse(sourceFile('test/pins/shardfiles.json')), shardNames === undefined || shardNames === '' ?
|
|
122
|
+
shards: releaseShards(JSON.parse(sourceFile('test/pins/shardfiles.json')), shardNames === undefined || shardNames === '' ? DEFAULT_SERVER_SHARDS : shardNames),
|
|
123
123
|
bundle: bundleDescriptor(values.bundle, values.tag), socket: need('E7_RELEASE_SOCKET') });
|
|
124
124
|
if (releasePublicKey(privateKey) !== publicKey.toLowerCase()) throw new Error('Signing key does not match E7_RELEASE_PUBLIC_KEY');
|
|
125
125
|
if (values.check) { console.log('Server release configuration admitted'); return; }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// The names a release and the grid use for pinned shards. No dependencies: CI's job-1 checks run it before `pnpm install`.
|
|
2
|
+
|
|
3
|
+
/** A pin whose installed folder isn't its slug: the template's shardfile is `template` on the API (J259 slugs are kebab-case), but it
|
|
4
|
+
* installs into `_template`, and the server book, the grid and the server's cells all say `_template`. The release names the folder,
|
|
5
|
+
* so a server opening the whole grid finds the template's cell (GO7: `template` in the release opened 24 of 25 cells). */
|
|
6
|
+
const PIN_FOLDERS = new Map([['template', '_template']]);
|
|
7
|
+
/** The release's shards when `E7_SERVER_SHARDS` (from `E7_STAGING_SHARDS` or `E7_PRODUCTION_SHARDS`) is unset or empty. */
|
|
8
|
+
export const DEFAULT_SERVER_SHARDS = 'driftwood-isle,nalati-grasslands';
|
|
9
|
+
/** The folder a pinned slug installs into, which is the name the server, its book and the grid use. */
|
|
10
|
+
export const servedSlug = (/** @type {string} */ slug) => PIN_FOLDERS.get(slug) ?? slug;
|
|
@@ -6,5 +6,6 @@ export function releasePublicKey(pem: string): string;
|
|
|
6
6
|
export function signRelease(value: unknown, pem: string): string;
|
|
7
7
|
export function readPublication(text: string, publicKey: string): ReleaseFile;
|
|
8
8
|
export function bundleDescriptor(archive: string, tag: string): { name: string; sha256: string };
|
|
9
|
+
export const DEFAULT_SERVER_SHARDS: string;
|
|
9
10
|
export function servedSlug(slug: string): string;
|
|
10
11
|
export function releaseShards(pins: unknown, names: string): ReleaseFile['shards'];
|
|
@@ -4,6 +4,9 @@ import { readFileSync } from 'node:fs';
|
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
5
|
import * as v from 'valibot';
|
|
6
6
|
import { ReleaseSchema, SignedSchema } from '../../src/shared/host/releaseRows.ts';
|
|
7
|
+
import { servedSlug } from './served-slug.mjs';
|
|
8
|
+
|
|
9
|
+
export { DEFAULT_SERVER_SHARDS, servedSlug } from './served-slug.mjs';
|
|
7
10
|
|
|
8
11
|
/** @typedef {import('../../src/shared/host/releaseRows.ts').ReleaseFile} ReleaseFile */
|
|
9
12
|
export const COMMIT = /^[0-9a-f]{40}$/u;
|
|
@@ -54,13 +57,6 @@ export function bundleDescriptor(archive, tag) {
|
|
|
54
57
|
return { name: `${tag}/${basename(archive)}`, sha256: createHash('sha256').update(readFileSync(archive)).digest('hex') };
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
/** A pin whose installed folder isn't its slug: the template's shardfile is `template` on the API (J259 slugs are kebab-case), but it
|
|
58
|
-
* installs into `_template`, and the server book, the grid and the server's cells all say `_template`. The release names the folder,
|
|
59
|
-
* so a server opening the whole grid finds the template's cell (GO7: `template` in the release opened 24 of 25 cells). */
|
|
60
|
-
const PIN_FOLDERS = new Map([['template', '_template']]);
|
|
61
|
-
/** The folder a pinned slug installs into, which is the name the server, its book and the grid use. */
|
|
62
|
-
export const servedSlug = (/** @type {string} */ slug) => PIN_FOLDERS.get(slug) ?? slug;
|
|
63
|
-
|
|
64
60
|
/** The release's shards, by the name the server reads them under; a variable may give a pin's slug or its folder.
|
|
65
61
|
* @param {unknown} pins @param {string} names @returns {ReleaseFile['shards']} */
|
|
66
62
|
export function releaseShards(pins, names) {
|
|
@@ -52,8 +52,6 @@ const reviewedW2Owners = new Map([
|
|
|
52
52
|
['src/format/lootEconomy.ts#ClaimedPickupSchema', 'C6'],
|
|
53
53
|
['src/shared/engine/combat/effects/EffectService.ts#playerBindings', 'C6'],
|
|
54
54
|
['src/shared/engine/combat/effects/EffectService.ts#bindPlayerEffects', 'C6'],
|
|
55
|
-
['src/shared/engine/physics/terrain.ts#EDGE_WALL_INSET', 'C1'],
|
|
56
|
-
['src/shared/engine/physics/terrain.ts#isStandaloneEdgeWall', 'C1'],
|
|
57
55
|
['src/shared/game/bag/itemCatalog.ts#isItemId', 'C6'],
|
|
58
56
|
['src/client/game/plugin/ui.ts#STARTER_EFFECTS', 'C6'],
|
|
59
57
|
['src/client/game/plugin/ui.ts#StatusMovement', 'C6'],
|
|
@@ -3,6 +3,14 @@ export interface ShardOutputRow { readonly slug: string; readonly manifest?: Rea
|
|
|
3
3
|
/** A product of the shard folders: an output of a folder, or the folder itself (`output` null). */
|
|
4
4
|
export interface ShardProduct { readonly slug: string; readonly folder: string; readonly output: ShardOutputRow | null }
|
|
5
5
|
export function mergeManifest(base: unknown, over: unknown): unknown;
|
|
6
|
+
/** SA42: a single-shard repo's folder name (its source at `src/`), or null. */
|
|
7
|
+
export function singleShardFolder(root: string): string | null;
|
|
8
|
+
/** SA42: a shard folder's source directory, `src/` or `src/shards/<folder>`. */
|
|
9
|
+
export function shardSourceDir(root: string, folder: string): string;
|
|
10
|
+
/** SA42: the tree holds shard source in either layout. */
|
|
11
|
+
export function hasShardSource(root: string): boolean;
|
|
12
|
+
/** SA42: the source folders holding one of `markers`, in either layout, sorted. */
|
|
13
|
+
export function shardSourceFolders(root: string, markers: readonly string[]): string[];
|
|
6
14
|
export function shardOutputs(root: string, folder: string): { slug: string; folder: string; row: ShardOutputRow }[] | null;
|
|
7
15
|
export function shardProducts(root: string, folders: readonly string[]): ShardProduct[];
|
|
8
16
|
export function outputManifest(root: string, folder: string, output: ShardOutputRow): Record<string, unknown>;
|
|
@@ -4,11 +4,48 @@
|
|
|
4
4
|
// the slug table, the shardfile build, the catalogue) reads them through here; the folder's manifest.json is then the
|
|
5
5
|
// shared base each output's overrides merge into (plain objects merge, everything else replaces).
|
|
6
6
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
7
|
-
import { resolve } from 'node:path';
|
|
7
|
+
import { basename, relative, resolve } from 'node:path';
|
|
8
8
|
|
|
9
9
|
const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
10
10
|
/** @param {unknown} value @returns {value is Record<string, unknown>} */
|
|
11
11
|
const plain = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
12
|
+
/** @param {string} file @returns {unknown} */
|
|
13
|
+
const readJson = (file) => { try { return JSON.parse(readFileSync(file, 'utf8')); } catch { return undefined; } };
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* SA42 (J317, sharddev SA16 `shardSource.ts`): a single-shard repo keeps its shard source at `src/` (its `src/shard.config.ts`, or a
|
|
17
|
+
* hand-written shard file folder `src/shard.json` with no config), a multi-shard repo at `src/shards/<folder>/`. The single source's
|
|
18
|
+
* folder name is a hand-written index's `identity.slug`, else its manifest's slug, else the repo folder's name, as sharddev names it.
|
|
19
|
+
* Null for a repo with no single-shard source. @param {string} root @returns {string | null}
|
|
20
|
+
*/
|
|
21
|
+
export function singleShardFolder(root) {
|
|
22
|
+
const src = resolve(root, 'src'), config = existsSync(resolve(src, 'shard.config.ts'));
|
|
23
|
+
const handwritten = !config && existsSync(resolve(src, 'shard.json'));
|
|
24
|
+
if (!config && !handwritten) return null;
|
|
25
|
+
if (handwritten) {
|
|
26
|
+
const index = readJson(resolve(src, 'shard.json'));
|
|
27
|
+
if (plain(index) && plain(index.identity) && typeof index.identity.slug === 'string') return index.identity.slug;
|
|
28
|
+
}
|
|
29
|
+
const manifest = readJson(resolve(src, 'manifest.json'));
|
|
30
|
+
return plain(manifest) && typeof manifest.slug === 'string' ? manifest.slug : basename(resolve(root));
|
|
31
|
+
}
|
|
32
|
+
/** SA42: a shard folder's source directory: `src/` for the single-shard repo's own folder, else `src/shards/<folder>`. @param {string} root @param {string} folder */
|
|
33
|
+
export function shardSourceDir(root, folder) {
|
|
34
|
+
return singleShardFolder(root) === folder ? resolve(root, 'src') : resolve(root, 'src/shards', folder);
|
|
35
|
+
}
|
|
36
|
+
/** SA42: this tree holds shard source in either layout (P3: a tree with none reads pinned products only). @param {string} root */
|
|
37
|
+
export function hasShardSource(root) {
|
|
38
|
+
return singleShardFolder(root) !== null || existsSync(resolve(root, 'src/shards'));
|
|
39
|
+
}
|
|
40
|
+
/** SA42: the source folders holding one of `markers` (a manifest, `shard.config.ts`): `src/shards/*` and a single-shard repo's own, sorted.
|
|
41
|
+
* @param {string} root @param {readonly string[]} markers */
|
|
42
|
+
export function shardSourceFolders(root, markers) {
|
|
43
|
+
const single = singleShardFolder(root), shards = resolve(root, 'src/shards');
|
|
44
|
+
const folders = existsSync(shards) ? readdirSync(shards, { withFileTypes: true })
|
|
45
|
+
.filter((entry) => entry.isDirectory() && markers.some((file) => existsSync(resolve(shards, entry.name, file)))).map((entry) => entry.name) : [];
|
|
46
|
+
if (single !== null && !folders.includes(single) && markers.some((file) => existsSync(resolve(root, 'src', file)))) folders.push(single);
|
|
47
|
+
return folders.sort();
|
|
48
|
+
}
|
|
12
49
|
/** Deep-merge plain objects (`over` wins); arrays and scalars replace. @param {unknown} base @param {unknown} over @returns {unknown} */
|
|
13
50
|
export function mergeManifest(base, over) {
|
|
14
51
|
if (!plain(base) || !plain(over)) return over === undefined ? base : over;
|
|
@@ -19,14 +56,14 @@ export function mergeManifest(base, over) {
|
|
|
19
56
|
}
|
|
20
57
|
/** A folder's declared outputs, or null for a one-product folder. @param {string} root @param {string} folder */
|
|
21
58
|
export function shardOutputs(root, folder) {
|
|
22
|
-
const file = resolve(root,
|
|
59
|
+
const file = resolve(shardSourceDir(root, folder), 'outputs.json'), named = relative(resolve(root), file);
|
|
23
60
|
if (!existsSync(file)) return null;
|
|
24
61
|
const rows = JSON.parse(readFileSync(file, 'utf8')).outputs;
|
|
25
|
-
if (!Array.isArray(rows) || rows.length === 0) throw new Error(
|
|
62
|
+
if (!Array.isArray(rows) || rows.length === 0) throw new Error(`${named}: needs a nonempty outputs list`);
|
|
26
63
|
const seen = new Set();
|
|
27
64
|
return rows.map((row) => {
|
|
28
|
-
if (!plain(row) || typeof row.slug !== 'string' || !SLUG.test(row.slug) || seen.has(row.slug) || row.slug === folder) throw new Error(
|
|
29
|
-
if (row.manifest !== undefined && !plain(row.manifest)) throw new Error(
|
|
65
|
+
if (!plain(row) || typeof row.slug !== 'string' || !SLUG.test(row.slug) || seen.has(row.slug) || row.slug === folder) throw new Error(`${named}: invalid or duplicate output slug ${String(row?.slug)}`);
|
|
66
|
+
if (row.manifest !== undefined && !plain(row.manifest)) throw new Error(`${named}: ${row.slug} manifest overrides must be an object`);
|
|
30
67
|
seen.add(row.slug);
|
|
31
68
|
return { slug: row.slug, folder, row };
|
|
32
69
|
});
|
|
@@ -42,15 +79,12 @@ export function shardProducts(root, folders) {
|
|
|
42
79
|
/** An output's authored manifest: the folder base with its overrides, its slug, canonical shardfile path and data map.
|
|
43
80
|
* @param {string} root @param {string} folder @param {{ slug: string, manifest?: object }} output */
|
|
44
81
|
export function outputManifest(root, folder, output) {
|
|
45
|
-
const base = JSON.parse(readFileSync(resolve(root,
|
|
82
|
+
const base = JSON.parse(readFileSync(resolve(shardSourceDir(root, folder), 'manifest.json'), 'utf8'));
|
|
46
83
|
return mergeManifest(base, { ...output.manifest, slug: output.slug, shardfile: `/shardfiles/${output.slug}/shard.json`, minimap: { image: `/assets/${output.slug}/map/top.webp` } });
|
|
47
84
|
}
|
|
48
|
-
/** The folders under src/shards
|
|
85
|
+
/** The shard folders with a manifest: under src/shards, or a single-shard repo's src/ (SA42). P3: a tree with no shard source has none. @param {string} root */
|
|
49
86
|
export function manifestFolders(root) {
|
|
50
|
-
|
|
51
|
-
return readdirSync(resolve(root, 'src/shards'), { withFileTypes: true })
|
|
52
|
-
.filter((entry) => entry.isDirectory() && ['manifest.ts', 'manifest.json'].some((file) => existsSync(resolve(root, 'src/shards', entry.name, file))))
|
|
53
|
-
.map((entry) => entry.name).sort();
|
|
87
|
+
return shardSourceFolders(root, ['manifest.ts', 'manifest.json']);
|
|
54
88
|
}
|
|
55
89
|
/** The source folder of a product slug (itself for a one-product folder). @param {string} root @param {string} slug */
|
|
56
90
|
export function productFolder(root, slug) {
|
|
@@ -5,4 +5,5 @@ export function ownerGroup(owner: string | null): string;
|
|
|
5
5
|
export function groupInventory(rows: readonly SideParityRow[]): Map<string, { count: number; materials: Set<string>; box: number[] }>;
|
|
6
6
|
export const PAGE_DISC: number;
|
|
7
7
|
export const MEASURED_SHAPES: readonly number[];
|
|
8
|
-
export function sideParityDiff(page: readonly SideParityRow[], server: readonly SideParityRow[], at: readonly number[] | null, allow?: Readonly<Record<string, string>>, options?: { readonly slack?: number; readonly same?: Readonly<Record<string, string
|
|
8
|
+
export function sideParityDiff(page: readonly SideParityRow[], server: readonly SideParityRow[], at: readonly number[] | null, allow?: Readonly<Record<string, string>>, options?: { readonly slack?: number; readonly same?: Readonly<Record<string, string>>; readonly sameMaterial?: Readonly<Record<string, { readonly server: string; readonly page: string }>>; readonly chunked?: readonly string[] }): string[];
|
|
9
|
+
export function chunkCopyKey(row: SideParityRow): string;
|
package/scripts/side-parity.mjs
CHANGED
|
@@ -83,7 +83,7 @@ export function ownerGroup(owner) {
|
|
|
83
83
|
const groupOf = row => row.material === 'flesh' ? 'actor' : ownerGroup(row.owner);
|
|
84
84
|
/** The key two colliders must share to match: owner group, material, sensor or solid. */
|
|
85
85
|
/** The match key `row` would have under the owner group `group`. */
|
|
86
|
-
const keyAs = (row, group) => `${row.sensor ? 'sensor:' : ''}${group}|${
|
|
86
|
+
const keyAs = (row, group, material = row.material) => `${row.sensor ? 'sensor:' : ''}${group}|${material ?? '-'}`;
|
|
87
87
|
const matchKey = row => keyAs(row, groupOf(row));
|
|
88
88
|
/** The allow key: owner group, sensors apart. */
|
|
89
89
|
const allowKey = row => `${row.sensor ? 'sensor:' : ''}${groupOf(row)}`;
|
|
@@ -119,12 +119,33 @@ export const MEASURED_SHAPES = Object.freeze([0, 1, 2, 4, 6, 7, 9, 10, 11, 12, 1
|
|
|
119
119
|
* `allow` maps an allow key (owner, `sensor:` prefixed for a sensor) to why it may differ; it is skipped both ways.
|
|
120
120
|
* `same` (SS10) maps a server owner group to the page owner group that may name the same pieces (a gate named for its door,
|
|
121
121
|
* a bake's 150-collider chunk): a collider with no match under its own name may match one under that name, still one to
|
|
122
|
-
* one and by material and shape.
|
|
122
|
+
* one and by material and shape. `sameMaterial` (HS7's owed SS1 line) maps such a server owner group to `{ server, page }`, the
|
|
123
|
+
* material each side names it by (Driftwood's boat: `wood` on the server, `planks` on the page); any other material still differs.
|
|
124
|
+
* `chunked` lists page owner groups a chunked page registers once per chunk a piece spans (Driftwood's pier deck): exact
|
|
125
|
+
* copies of one of their pieces (owner group, material, kind, box) are that one solid.
|
|
123
126
|
* A static page solid with no server match that lies inside a server edge wall (`edge`) is no finding: the wall stands there.
|
|
124
127
|
*/
|
|
125
|
-
|
|
128
|
+
/** A `chunked` page piece's identity: one solid whatever chunk registered it (boxes are whole metres, so two thin pieces in one
|
|
129
|
+
* metre cell of different chunks would read as one; none do today). */
|
|
130
|
+
export const chunkCopyKey = row => `${matchKey(row)}|${row.dynamic}|${row.shape}|${row.box.join(',')}`;
|
|
131
|
+
/** The material `row` goes by under the other side's name for it: `named` is a `sameMaterial` entry, `{ server, page }`. */
|
|
132
|
+
function materialAs(row, side, named) {
|
|
133
|
+
if (named === undefined) return row.material;
|
|
134
|
+
const [mine, theirs] = side === 'page' ? [named.page, named.server] : [named.server, named.page];
|
|
135
|
+
return row.material === mine ? theirs : row.material;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function sideParityDiff(paged, server, at, allow = {}, { slack = 1, same = {}, sameMaterial = {}, chunked = [] } = {}) {
|
|
126
139
|
// without the page's player, the server-to-page half would check nothing and pass
|
|
127
140
|
if (at === null || at.length !== 3) throw new Error('Side parity needs the page player position its half was recorded at');
|
|
141
|
+
// a copy is the same piece under another chunk's owner; two in one chunk are still two
|
|
142
|
+
const copies = new Map(), page = paged.filter(row => {
|
|
143
|
+
if (!chunked.includes(groupOf(row))) return true;
|
|
144
|
+
const key = chunkCopyKey(row), owners = copies.get(key);
|
|
145
|
+
if (owners === undefined) { copies.set(key, new Set([row.owner])); return true; }
|
|
146
|
+
if (owners.has(row.owner)) return true;
|
|
147
|
+
owners.add(row.owner); return false;
|
|
148
|
+
});
|
|
128
149
|
const index = rows => { const map = new Map(); for (const row of rows) { const key = matchKey(row); let list = map.get(key); if (list === undefined) map.set(key, list = []); list.push(row); } return map; };
|
|
129
150
|
const pages = index(page), servers = index(server), findings = new Map();
|
|
130
151
|
// the example is the smallest box, so a line does not change with the order a world lists its colliders
|
|
@@ -139,7 +160,7 @@ export function sideParityDiff(page, server, at, allow = {}, { slack = 1, same =
|
|
|
139
160
|
let best = null;
|
|
140
161
|
// its own name first; then the other side's name for it that `same` declares (a page owner may have several server names)
|
|
141
162
|
const names = side === 'page' ? Object.keys(same).filter(name => same[name] === groupOf(row)) : Object.hasOwn(same, groupOf(row)) ? [same[groupOf(row)]] : [];
|
|
142
|
-
for (const key of [matchKey(row), ...names.map(name => keyAs(row, name))]) {
|
|
163
|
+
for (const key of [matchKey(row), ...names.map(name => keyAs(row, name, materialAs(row, side, side === 'page' ? sameMaterial[name] : sameMaterial[groupOf(row)])))]) {
|
|
143
164
|
for (const other of others.get(key) ?? []) if (!used.has(other) && close(row, other) && (best === null || spread(row, other) < spread(row, best))) best = other;
|
|
144
165
|
if (best !== null) break;
|
|
145
166
|
}
|
package/scripts/test-amber.d.mts
CHANGED
|
@@ -9,3 +9,4 @@ export function amberLine(verdict:AmberVerdict,run:string|null|undefined):string
|
|
|
9
9
|
export function parseAmber(text:string):{file:string;ms:number;budget:number}[];
|
|
10
10
|
export function nextLedger(previous:AmberLedger|undefined,files:readonly {file:string;durationMs:number}[],options:{run:string;at:number;inventory:Set<string>|null;budget?:number}):AmberLedger;
|
|
11
11
|
export function judgeWall(shard:string,ms:number,budget:number,limits?:AmberLimits):AmberVerdict;
|
|
12
|
+
export function parseAudioAmber(text:string):{shard:string;tier:string;bytes:number;budget:number;red:number;level:string}[];
|
package/scripts/test-amber.mjs
CHANGED
|
@@ -88,3 +88,13 @@ export function nextLedger(previous,files,options){
|
|
|
88
88
|
* from run to run; the files that made it slow carry their own. Pure.
|
|
89
89
|
* @param {string} shard @param {number} ms @param {number} budget @param {typeof AMBER} [limits] @returns {Verdict} */
|
|
90
90
|
export const judgeWall=(shard,ms,budget,limits=AMBER)=>judgeFile(`shard-${shard}-wall`,ms,budget,undefined,0,limits);
|
|
91
|
+
|
|
92
|
+
/** AUDIO AU6 (J303): every shard-audio AMBER line in some text (`audioAmberLine` in src/cook/game/audioReport.ts, which
|
|
93
|
+
* CI's budget reporter annotates), one per shard and tier. Never red on main: `level=red` says only how far over (J295).
|
|
94
|
+
* @param {string} text @returns {{shard:string,tier:string,bytes:number,budget:number,red:number,level:string}[]} */
|
|
95
|
+
export function parseAudioAmber(text){
|
|
96
|
+
const out=new Map();
|
|
97
|
+
for(const match of text.matchAll(/\bAMBER audio shard=(\S+) tier=(\S+) bytes=(\d+) budget=(\d+) red=(\d+) level=(\S+)/gu))
|
|
98
|
+
out.set(`${match[1]} ${match[2]}`,{shard:match[1],tier:match[2],bytes:Number(match[3]),budget:Number(match[4]),red:Number(match[5]),level:match[6]});
|
|
99
|
+
return [...out.values()];
|
|
100
|
+
}
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"test/cook-hostile-pins.test.ts": ["_template"],
|
|
50
50
|
"test/net-hostile-play.test.ts": ["sunscar-dunes", "pine-hollow"],
|
|
51
51
|
"test/pinned-restore-play.test.ts": ["_template", "blender-template", "sunscar-dunes", "far-reach", "driftwood-isle", "nalati-grasslands", "pine-hollow", "nine-dragon-stack"],
|
|
52
|
-
"test/shard-stands-alone.test.ts": ["_template","blender-template","driftwood-isle","far-reach","ink-cel-valley","nalati-grasslands","nine-dragon-stack","open-plot-alien-plain","open-plot-clockwork-canyon","open-plot-coral-drift","open-plot-desert-ruin","open-plot-ember-forge","open-plot-fossil-badlands","open-plot-frostline-peaks","open-plot-jungle-ziggurat","open-plot-lantern-bayou","open-plot-mosslight-ruins","open-plot-night-market","open-plot-patchwork-fairground","open-plot-saltwind-lighthouse","open-plot-
|
|
52
|
+
"test/shard-stands-alone.test.ts": ["_template","blender-template","driftwood-isle","far-reach","ink-cel-valley","nalati-grasslands","nine-dragon-stack","open-plot-alien-plain","open-plot-clockwork-canyon","open-plot-coral-drift","open-plot-desert-ruin","open-plot-ember-forge","open-plot-fossil-badlands","open-plot-frostline-peaks","open-plot-jungle-ziggurat","open-plot-lantern-bayou","open-plot-mosslight-ruins","open-plot-night-market","open-plot-patchwork-fairground","open-plot-saltwind-lighthouse","open-plot-sky-harbor","open-plot-sky-race","open-plot-starfall-observatory","open-plot-thin-ice","pastel-plain","pine-hollow","sunscar-dunes"],
|
|
53
53
|
"test/registered-quest-catalogues.test.ts": ["pine-hollow","nalati-grasslands"],
|
|
54
54
|
"test/registered-native-population.test.ts": ["driftwood-isle","pine-hollow"],
|
|
55
|
-
"test/shipped-graph-cost.test.ts": ["_template","blender-template","driftwood-isle","far-reach","ink-cel-valley","nalati-grasslands","nine-dragon-stack","open-plot-alien-plain","open-plot-clockwork-canyon","open-plot-coral-drift","open-plot-desert-ruin","open-plot-ember-forge","open-plot-fossil-badlands","open-plot-frostline-peaks","open-plot-jungle-ziggurat","open-plot-lantern-bayou","open-plot-mosslight-ruins","open-plot-night-market","open-plot-patchwork-fairground","open-plot-saltwind-lighthouse","open-plot-
|
|
55
|
+
"test/shipped-graph-cost.test.ts": ["_template","blender-template","driftwood-isle","far-reach","ink-cel-valley","nalati-grasslands","nine-dragon-stack","open-plot-alien-plain","open-plot-clockwork-canyon","open-plot-coral-drift","open-plot-desert-ruin","open-plot-ember-forge","open-plot-fossil-badlands","open-plot-frostline-peaks","open-plot-jungle-ziggurat","open-plot-lantern-bayou","open-plot-mosslight-ruins","open-plot-night-market","open-plot-patchwork-fairground","open-plot-saltwind-lighthouse","open-plot-sky-harbor","open-plot-sky-race","open-plot-starfall-observatory","open-plot-thin-ice","pastel-plain","pine-hollow","sunscar-dunes"],
|
|
56
56
|
"test/nalati-chapter-binding.test.ts": ["nalati-grasslands"],
|
|
57
57
|
"test/nalati-headless-population.test.ts": ["nalati-grasslands"],
|
|
58
58
|
"test/nine-headless-assembly.test.ts": ["nine-dragon-stack"],
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"test/physics-nalati-headless.test.ts": ["nalati-grasslands"],
|
|
211
211
|
"test/physics-open-plots-headless.test.ts": ["open-plot-frostline-peaks", "open-plot-lantern-bayou", "open-plot-ember-forge", "open-plot-mosslight-ruins", "open-plot-coral-drift", "open-plot-fossil-badlands"],
|
|
212
212
|
"test/physics-open-plots-headless-2.test.ts": ["open-plot-patchwork-fairground", "open-plot-desert-ruin", "open-plot-sky-harbor", "open-plot-starfall-observatory", "open-plot-thin-ice", "open-plot-clockwork-canyon"],
|
|
213
|
-
"test/physics-open-plots-headless-3.test.ts": ["open-plot-saltwind-lighthouse", "open-plot-jungle-ziggurat", "open-plot-sky-race", "open-plot-alien-plain"
|
|
213
|
+
"test/physics-open-plots-headless-3.test.ts": ["open-plot-saltwind-lighthouse", "open-plot-jungle-ziggurat", "open-plot-sky-race", "open-plot-alien-plain"],
|
|
214
214
|
"test/shard-headless.test.ts": [
|
|
215
215
|
"_template",
|
|
216
216
|
"pastel-plain",
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// S12 (J330): does a shard page load and look the same with its phone textures cut to a tier size by the cook's mip trim
|
|
3
|
+
// (src/cook/game/tierTextures.ts)? Phone tier, iPhone 17 Pro viewport, headless. Every `.glb` and `.ktx2` the page reads
|
|
4
|
+
// is fetched from the served build and, with --max, answered with `tierGlb` / `trimKtx2` at that size, so the page reads
|
|
5
|
+
// exactly what a trim-only cook would ship. Reports the bytes those responses carried, the page's GPU ledger and three's
|
|
6
|
+
// texture count once the player stands in the world, and saves a screenshot to compare.
|
|
7
|
+
// scripts/browser-lane.sh node --import ./scripts/bake-loader.mjs scripts/tier-textures-proof.mjs --base=http://127.0.0.1:<port>
|
|
8
|
+
// [--engine=chromium|webkit] [--slug=pine-hollow] [--max=512] [--out=tmp/<lane>/tier-proof] [--label=<name>]
|
|
9
|
+
// Loopback only: never staging or production.
|
|
10
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { join, resolve as absolute } from 'node:path';
|
|
12
|
+
import { chromium, webkit } from 'playwright';
|
|
13
|
+
import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
|
|
14
|
+
import { saveFixture } from './debug-settings.mjs';
|
|
15
|
+
import { pageMemoryAttributionExpression } from './memory-report-snapshot.mjs';
|
|
16
|
+
|
|
17
|
+
const { tierGlb, trimKtx2 } = await import('../src/cook/game/tierTextures.ts');
|
|
18
|
+
|
|
19
|
+
/** @type {Record<string, string>} */
|
|
20
|
+
const args = Object.fromEntries(process.argv.slice(2).map(arg => /^--([^=]+)(?:=(.*))?$/u.exec(arg)).filter(match => match !== null).map(match => [match[1], match.at(2) ?? '1']));
|
|
21
|
+
const base = (args.base ?? '').replace(/\/$/u, '');
|
|
22
|
+
if (!/^http:\/\/(127\.0\.0\.1|localhost):\d+$/u.test(base)) throw new Error('--base takes a loopback build only');
|
|
23
|
+
const engineName = args.engine ?? 'chromium', slug = args.slug ?? 'pine-hollow', max = args.max === undefined ? 0 : Number(args.max);
|
|
24
|
+
if (engineName !== 'chromium' && engineName !== 'webkit') throw new Error(`No engine ${engineName}`);
|
|
25
|
+
const label = args.label ?? `${engineName}-${max === 0 ? 'master' : `max${max}`}`, out = absolute(args.out ?? 'tmp/tier-proof');
|
|
26
|
+
mkdirSync(out, { recursive: true });
|
|
27
|
+
const MB = 1e6;
|
|
28
|
+
/** @param {number} ms */
|
|
29
|
+
const sleep = ms => new Promise(resolve => { setTimeout(resolve, ms); });
|
|
30
|
+
|
|
31
|
+
const READ = `(() => {
|
|
32
|
+
const api = window.__wildshard, mem = (() => { try { return ${pageMemoryAttributionExpression}; } catch (e) { return { error: String(e) }; } })();
|
|
33
|
+
const rows = Array.isArray(mem?.allocations) ? mem.allocations : [], kinds = {};
|
|
34
|
+
for (const r of rows) { const k = r.domain + ' ' + r.kind; kinds[k] = (kinds[k] ?? 0) + r.bytes; }
|
|
35
|
+
let three = null; try { const r = api.requireWorld().game.renderer; three = { textures: r.info.memory.textures, geometries: r.info.memory.geometries }; } catch {}
|
|
36
|
+
// Decoded texture bytes, once per texture the scene draws: a compressed texture's transcoded levels as uploaded, an
|
|
37
|
+
// image's RGBA8 levels (a third more for mips). What the GPU holds for the page's textures, not counting render targets.
|
|
38
|
+
let textureBytes = null; try {
|
|
39
|
+
const world = api.requireWorld(), scene = world.game?.scene ?? world.scene, seen = new Set(); let total = 0;
|
|
40
|
+
scene.traverse(object => { for (const material of [object.material ?? []].flat()) for (const value of Object.values(material)) {
|
|
41
|
+
if (value === null || typeof value !== 'object' || value.isTexture !== true || seen.has(value)) continue;
|
|
42
|
+
seen.add(value);
|
|
43
|
+
if (value.isCompressedTexture === true) total += (value.mipmaps ?? []).reduce((sum, level) => sum + (level.data?.byteLength ?? 0), 0);
|
|
44
|
+
else { const image = value.image; if (image?.width > 0) total += image.width * image.height * 4 * (value.generateMipmaps === false ? 1 : 4 / 3); }
|
|
45
|
+
} });
|
|
46
|
+
textureBytes = { total, textures: seen.size };
|
|
47
|
+
} catch (e) { textureBytes = { error: String(e).slice(0, 160) }; }
|
|
48
|
+
let mode = null; try { mode = api.textures?.()?.mode ?? null; } catch {}
|
|
49
|
+
return { totals: mem?.totals ?? null, kinds, three, mode, textureBytes };
|
|
50
|
+
})()`;
|
|
51
|
+
|
|
52
|
+
const result = { engine: engineName, base, slug, max, label, at: new Date().toISOString(), outcome: 'none', errors: /** @type {string[]} */ ([]),
|
|
53
|
+
glb: { files: 0, served: 0, read: 0 }, ktx2: { files: 0, served: 0, read: 0 }, page: /** @type {unknown} */ (null) };
|
|
54
|
+
const browser = await (engineName === 'webkit' ? webkit : chromium).launch({ headless: true,
|
|
55
|
+
args: engineName === 'chromium' ? [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist'] : [] });
|
|
56
|
+
let code = 0;
|
|
57
|
+
try {
|
|
58
|
+
const context = await browser.newContext({ viewport: { width: 402, height: 874 }, deviceScaleFactor: 3, isMobile: engineName === 'chromium', hasTouch: true,
|
|
59
|
+
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/27.0.1 Mobile/15E148 Safari/604.1' });
|
|
60
|
+
await saveFixture(context, { scope: 'device', key: 'firstPlayDone', data: true });
|
|
61
|
+
await saveFixture(context, { scope: 'global', key: 'settings', merge: true, data: { tier: 'phone', volume: 0 } });
|
|
62
|
+
await context.route('**/api/errors', route => route.fulfill({ status: 204, body: '' }));
|
|
63
|
+
await context.route(/\.(?:glb|ktx2)(?:\?.*)?$/u, async route => {
|
|
64
|
+
const response = await route.fetch(), body = new Uint8Array(await response.body());
|
|
65
|
+
const glb = /\.glb(?:\?|$)/u.test(route.request().url()), row = glb ? result.glb : result.ktx2;
|
|
66
|
+
/** @type {Uint8Array} */
|
|
67
|
+
let read = body;
|
|
68
|
+
try { if (max !== 0 && response.status() === 200) read = glb ? tierGlb(body, max) : trimKtx2(body, max); }
|
|
69
|
+
catch (error) { result.errors.push(`trim ${route.request().url()}: ${String(error).slice(0, 160)}`); }
|
|
70
|
+
row.files++; row.served += body.length; row.read += read.length;
|
|
71
|
+
const headers = { ...response.headers() };
|
|
72
|
+
delete headers['content-length']; delete headers['content-encoding']; delete headers.etag;
|
|
73
|
+
await route.fulfill({ status: response.status(), headers, body: Buffer.from(read) });
|
|
74
|
+
});
|
|
75
|
+
const page = await context.newPage(); page.setDefaultTimeout(240_000);
|
|
76
|
+
page.on('pageerror', error => { result.errors.push(error.message.slice(0, 240)); });
|
|
77
|
+
await page.goto(`${base}/?chunk=${slug}&skipintro&mute=1&nolock=1`, { waitUntil: 'commit', timeout: 120_000 });
|
|
78
|
+
const started = Date.now();
|
|
79
|
+
for (;;) {
|
|
80
|
+
await sleep(500);
|
|
81
|
+
if (Date.now() - started > 240_000) { result.outcome = 'stalled'; break; }
|
|
82
|
+
if (await page.locator('.ws-load-play').isVisible().catch(() => false)) await page.locator('.ws-load-play').click({ timeout: 3000 }).catch(() => undefined);
|
|
83
|
+
const ready = await page.evaluate(() => {
|
|
84
|
+
const api = /** @type {any} */ (window).__wildshard; let world = null; try { world = api?.requireWorld?.() ?? null; } catch { /* not yet */ }
|
|
85
|
+
return world?.player !== undefined && world?.player !== null && document.getElementById('hud')?.classList.contains('intro') !== true;
|
|
86
|
+
}).catch(() => false);
|
|
87
|
+
if (ready) { result.outcome = 'play'; break; }
|
|
88
|
+
}
|
|
89
|
+
await sleep(12_000);
|
|
90
|
+
result.page = await page.evaluate(READ);
|
|
91
|
+
await page.screenshot({ path: join(out, `${label}.png`) }).catch(() => undefined);
|
|
92
|
+
if (result.outcome !== 'play') code = 1;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
result.errors.push(String(error).slice(0, 400)); code = 1;
|
|
95
|
+
} finally {
|
|
96
|
+
await browser.close();
|
|
97
|
+
}
|
|
98
|
+
writeFileSync(join(out, `${label}.json`), `${JSON.stringify(result, null, 2)}\n`);
|
|
99
|
+
const page = /** @type {any} */ (result.page);
|
|
100
|
+
console.log(`${label}: ${result.outcome}, mode ${page?.mode ?? '?'}, glb ${result.glb.files} files ${(result.glb.served / MB).toFixed(2)} -> ${(result.glb.read / MB).toFixed(2)} MB, ktx2 ${result.ktx2.files} files ${(result.ktx2.served / MB).toFixed(2)} -> ${(result.ktx2.read / MB).toFixed(2)} MB, decoded textures ${((page?.textureBytes?.total ?? 0) / MB).toFixed(2)} MB in ${page?.textureBytes?.textures ?? page?.textureBytes?.error ?? '?'}, three textures ${page?.three?.textures ?? '?'}, errors ${result.errors.length}`);
|
|
101
|
+
process.exit(code);
|