@wildshard/engine 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/index.html +157 -11
- package/lint/engine-sides.json +16 -0
- package/lint/host-register.json +496 -0
- package/lint/ratchet.json +2 -2
- package/lint/shard-imports.d.mts +1 -0
- package/lint/shard-imports.mjs +56 -8
- package/lint/wildshard-plugin.js +22 -4
- package/package.json +16 -5
- 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/serviceWorker.ts +16 -2
- package/scripts/app-build/versionFiles.ts +2 -1
- package/scripts/app-build-pipeline.mjs +4 -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/devserver-client.d.mts +5 -0
- package/scripts/devserver-client.mjs +68 -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 +16 -8
- 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/mmo-bots.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +1 -0
- package/scripts/offline-proof-rules.mjs +22 -1
- 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/tracked-public.d.mts +1 -0
- package/scripts/tracked-public.mjs +17 -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 +67 -11
- 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/shardPrefetch.ts +7 -1
- package/src/client/engine/boot/sw.ts +19 -0
- package/src/client/engine/core/Game.ts +11 -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 +1 -2
- package/src/client/engine/core/ktx2.ts +84 -11
- package/src/client/engine/explore/Compare.ts +2 -2
- package/src/client/engine/explore/TouchFly.ts +3 -5
- 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 +47 -8
- package/src/client/engine/render/drawCheck.ts +96 -0
- package/src/client/engine/saves/staleBuildNote.ts +46 -0
- package/src/client/engine/telemetry/browserErrors.ts +157 -20
- 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 -294
- package/src/client/game/boot/bytes.generated.ts +0 -11
- package/src/client/game/boot/versions.generated.ts +0 -11
- package/src/client/game/compendium/keepsakes.ts +16 -6
- package/src/client/game/grapple/tool.ts +10 -7
- package/src/client/game/grid/cellLoading.ts +23 -12
- package/src/client/game/grid/cellScreens.ts +39 -74
- package/src/client/game/grid/liveSession.ts +40 -7
- package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
- package/src/client/game/grid/nearPlaceholderView.ts +9 -3
- 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/plotAudio.ts +114 -0
- package/src/client/game/grid/products.ts +55 -5
- package/src/client/game/grid/roadLookPlatform.ts +2 -2
- package/src/client/game/grid/session.ts +38 -22
- 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 +17 -3
- package/src/client/game/session/play.ts +8 -2
- package/src/client/game/session/session.ts +4 -1
- package/src/client/game/shardfile/clientWorker.ts +41 -12
- 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 +55 -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 +48 -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/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 +72 -0
- package/src/server/host/dedicated/releaseFile.ts +17 -10
- package/src/server/host/dedicated/roadRoom.ts +21 -5
- package/src/server/host/dedicated/workerTable.ts +13 -1
- package/src/server/host/dedicated/world.ts +81 -9
- 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/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 +11 -0
- package/src/shared/game/grid/farProxy.ts +6 -5
- package/src/shared/game/grid/pageMode.ts +1 -1
- 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,203 @@
|
|
|
1
|
+
// SHARD-AUTHORING SA35 (meta J314, grill Q11; Jake, 2026-11-12: "every deploy of preview in the github actions for deploy borrows the grid
|
|
2
|
+
// placement from staging by asking the staging mmo in the github action"). Preview has no MMO: its page bakes `test/pins/catalogue.json`.
|
|
3
|
+
// The staging MMO's grid is its build's catalogue (the same pinned J305 cells) plus every cell the API placed since, which it reads from the
|
|
4
|
+
// API-signed placement file (SA33, SA33a) at PLACEMENT_URL. Its own `/health` is tailnet-only (D7) and names instances, not cells, so the
|
|
5
|
+
// workflow asks for the one file the MMO itself believes, checked under the same placement key, and bakes those cells into preview's page.
|
|
6
|
+
//
|
|
7
|
+
// node --import ./scripts/bake-loader.mjs scripts/preview-grid.ts <out.json> [--placements=<url>] [--last=<url>] [--key=<spki hex>]
|
|
8
|
+
// writes the catalogue preview builds (page-release.mjs --catalogue=<out.json>), signature checked by engine's own reader
|
|
9
|
+
// node scripts/preview-grid.ts --news [--placements=<url>] [--last=<url>] [--key=<spki hex>]
|
|
10
|
+
// before install (node built-ins only): `news=true` when staging's placed cells differ from the live preview's
|
|
11
|
+
//
|
|
12
|
+
// Staging's file missing (404): staging placed no cell, so the pinned grid. Unreadable, refused or a bad signature (the "staging MMO down"):
|
|
13
|
+
// the live preview's own borrowed cells stay, and the run says so with a warning. Neither readable: the pinned grid, also with a warning.
|
|
14
|
+
import { createPublicKey, verify } from 'node:crypto';
|
|
15
|
+
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { dirname, resolve } from 'node:path';
|
|
17
|
+
import { pathToFileURL } from 'node:url';
|
|
18
|
+
|
|
19
|
+
/** Where the API writes staging's placement file (SA33a) and the box reads it (SA33's PLACEMENT_URL). */
|
|
20
|
+
export const STAGING_PLACEMENTS = 'https://packs.wildshard.io/releases/staging-placements.json';
|
|
21
|
+
/** The live preview's baked catalogue: the last grid, kept when staging can't be read. */
|
|
22
|
+
export const LIVE_PREVIEW_CATALOGUE = 'https://preview.wildshard.io/catalogue.json';
|
|
23
|
+
/** The API's placement key (SA33a, `~/.config/wildshard/placement-signing-key.pub.pem`), SPKI DER in hex: the box's PLACEMENT_PUBLIC_KEY. */
|
|
24
|
+
export const PLACEMENT_PUBLIC_KEY = '302a300506032b65700321004afd39342aac6a4de6066cb72e9df54cbd3d4eb522e5e6e175a17954ab98f25e';
|
|
25
|
+
const PIN = 'test/pins/catalogue.json';
|
|
26
|
+
const FETCH_MS = 20_000;
|
|
27
|
+
/** The format's 7 × 7 (shard-format `GRID_RADIUS`, SA29), as the MMO's `placeCell` bounds a spot. */
|
|
28
|
+
const GRID_RADIUS = 3;
|
|
29
|
+
|
|
30
|
+
/** One placed cell: the placement file's row and a grid catalogue's cell. */
|
|
31
|
+
export interface Cell { readonly instance: string; readonly slug: string; readonly cell: readonly [number, number] }
|
|
32
|
+
interface Catalogue {
|
|
33
|
+
readonly grid: { readonly cells: readonly Cell[] };
|
|
34
|
+
readonly shards: readonly { readonly slug: string }[];
|
|
35
|
+
readonly missing: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/** What asking staging gave: its placed cells (a verified file), none placed (404), or down (anything else). */
|
|
38
|
+
export type StagingAnswer = { readonly placed: readonly Cell[]; readonly serial: number } | { readonly none: string } | { readonly down: string };
|
|
39
|
+
/** The live preview's catalogue, or why it couldn't be read. */
|
|
40
|
+
export type LastAnswer = { readonly catalogue: unknown } | { readonly down: string };
|
|
41
|
+
export interface Borrowed {
|
|
42
|
+
/** The pinned catalogue with staging's placed cells after its own. */
|
|
43
|
+
readonly document: Catalogue;
|
|
44
|
+
readonly cells: readonly Cell[];
|
|
45
|
+
/** `staging` read and believed; `kept` the live preview's cells; `pinned` neither. */
|
|
46
|
+
readonly source: 'staging' | 'kept' | 'pinned';
|
|
47
|
+
readonly lines: readonly string[];
|
|
48
|
+
/** Set when the run kept an older grid or fell back to the pin: the workflow's warning. */
|
|
49
|
+
readonly warning?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const bare = (slug: string): string => slug.replace(/^_/u, '');
|
|
53
|
+
const at = (cell: Cell): string => `(${String(cell.cell[0])},${String(cell.cell[1])})`;
|
|
54
|
+
const named = (cells: readonly Cell[]): string => cells.map(cell => `${cell.instance} (${cell.slug}) at ${at(cell)}`).join(', ');
|
|
55
|
+
|
|
56
|
+
/** A catalogue's cells the pin's grid doesn't hold: the cells a page borrowed. */
|
|
57
|
+
export function borrowedCells(pin: Catalogue, catalogue: unknown): readonly Cell[] {
|
|
58
|
+
const cells = (catalogue as { grid?: { cells?: unknown } } | null)?.grid?.cells;
|
|
59
|
+
if (!Array.isArray(cells)) throw new Error('a catalogue with no grid cells');
|
|
60
|
+
const pinned = new Set(pin.grid.cells.map(cell => cell.instance));
|
|
61
|
+
return (cells as Cell[]).filter(cell => !pinned.has(cell.instance)).map(({ instance, slug, cell }) => ({ instance, slug, cell: [cell[0], cell[1]] }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The grid preview builds: the pin's cells, then the borrowed ones. A cell is refused, as the staging MMO's `placeCell` refuses it, when its
|
|
66
|
+
* spot is off the 7 × 7 or taken, its slug already has a cell, or its instance is taken; a cell the pin already places the same way is kept once.
|
|
67
|
+
*/
|
|
68
|
+
export function borrowGrid(pin: Catalogue, staging: StagingAnswer, last: LastAnswer): Borrowed {
|
|
69
|
+
const lines: string[] = [];
|
|
70
|
+
let source: Borrowed['source'], wanted: readonly Cell[], warning: string | undefined;
|
|
71
|
+
if ('placed' in staging) {
|
|
72
|
+
source = 'staging'; wanted = staging.placed;
|
|
73
|
+
lines.push(`staging's placement file, serial ${String(staging.serial)}, signature good: ${String(wanted.length)} placed cell(s)`);
|
|
74
|
+
} else {
|
|
75
|
+
let kept: readonly Cell[] | undefined, why = '';
|
|
76
|
+
if ('catalogue' in last) try { kept = borrowedCells(pin, last.catalogue); } catch (error) { why = error instanceof Error ? error.message : String(error); }
|
|
77
|
+
else why = last.down;
|
|
78
|
+
if ('none' in staging && (kept === undefined || kept.length === 0)) {
|
|
79
|
+
source = 'staging'; wanted = [];
|
|
80
|
+
lines.push(`staging has placed no cell (${staging.none}): the pinned grid`);
|
|
81
|
+
} else {
|
|
82
|
+
// The API rewrites its file and never deletes it, so a missing file after a placement is a fault, like an unreadable one.
|
|
83
|
+
const fault = 'none' in staging ? `${staging.none}, though the live preview borrowed cells` : 'down' in staging ? staging.down : '';
|
|
84
|
+
if (kept === undefined) {
|
|
85
|
+
source = 'pinned'; wanted = [];
|
|
86
|
+
warning = `staging's grid unreadable (${fault}), and so is the live preview's (${why}): this preview has the pinned grid only`;
|
|
87
|
+
} else {
|
|
88
|
+
source = 'kept'; wanted = kept;
|
|
89
|
+
warning = `staging's grid unreadable (${fault}): kept the live preview's grid, ${String(kept.length)} borrowed cell(s)`;
|
|
90
|
+
}
|
|
91
|
+
lines.push(warning);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const cells: Cell[] = [], left: string[] = [], spots = new Map<string, string>(), slugs = new Map<string, string>(), instances = new Map<string, string>();
|
|
95
|
+
for (const cell of pin.grid.cells) { spots.set(cell.cell.join(','), cell.instance); slugs.set(bare(cell.slug), cell.instance); instances.set(cell.instance, cell.slug); }
|
|
96
|
+
for (const cell of wanted) {
|
|
97
|
+
const [x, z] = cell.cell, spot = `${String(x)},${String(z)}`;
|
|
98
|
+
if (instances.get(cell.instance) === cell.slug && spots.get(spot) === cell.instance) continue;
|
|
99
|
+
const refused = !Number.isInteger(x) || !Number.isInteger(z) || Math.abs(x) > GRID_RADIUS || Math.abs(z) > GRID_RADIUS ? 'off the 7 × 7'
|
|
100
|
+
: spots.has(spot) ? `on ${spots.get(spot) ?? ''}'s spot`
|
|
101
|
+
: slugs.has(bare(cell.slug)) || instances.has(cell.slug) ? `${cell.slug} already has a cell (${slugs.get(bare(cell.slug)) ?? cell.slug})`
|
|
102
|
+
: instances.has(cell.instance) || slugs.has(bare(cell.instance)) ? `${cell.instance} is taken` : '';
|
|
103
|
+
if (refused !== '') { left.push(`left out ${cell.instance} (${cell.slug}) at ${at(cell)}: ${refused}`); continue; }
|
|
104
|
+
spots.set(spot, cell.instance); slugs.set(bare(cell.slug), cell.instance); instances.set(cell.instance, cell.slug);
|
|
105
|
+
cells.push({ instance: cell.instance, slug: cell.slug, cell: [x, z] });
|
|
106
|
+
}
|
|
107
|
+
// A cell staging's MMO may play but preview can't place breaks "the same cell": warn, as for a fault.
|
|
108
|
+
lines.push(...left);
|
|
109
|
+
if (left.length > 0) warning = [warning, `${String(left.length)} staging cell(s) left out of preview's grid: ${left.join('; ')}`].filter(line => line !== undefined).join('; ');
|
|
110
|
+
// A borrowed slug this build has no head for is "placed, with no head at this stage" (shard-format's `missing`).
|
|
111
|
+
const heads = new Set(pin.shards.map(head => bare(head.slug))), missing = [...pin.missing];
|
|
112
|
+
for (const cell of cells) if (!heads.has(bare(cell.slug)) && !missing.includes(cell.slug)) missing.push(cell.slug);
|
|
113
|
+
lines.push(cells.length === 0 ? `preview's grid: the pinned ${String(pin.grid.cells.length)} cells, none borrowed`
|
|
114
|
+
: `preview's grid: the pinned ${String(pin.grid.cells.length)} cells and ${String(cells.length)} from staging: ${named(cells)}`);
|
|
115
|
+
return { document: { ...pin, grid: { ...pin.grid, cells: [...pin.grid.cells, ...cells] }, missing }, cells, source, lines, ...(warning === undefined ? {} : { warning }) };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Whether two borrowed sets place the same cells. */
|
|
119
|
+
export function sameCells(a: readonly Cell[], b: readonly Cell[]): boolean {
|
|
120
|
+
const key = (cells: readonly Cell[]): string => cells.map(cell => `${cell.instance}=${cell.slug}@${cell.cell.join(',')}`).sort().join(' ');
|
|
121
|
+
return key(a) === key(b);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A signed file's body under `key`, Node built-ins only (the `--news` pass, before install). Engine's `readSigned` is the write's check. */
|
|
125
|
+
function signedBody(text: string, key: string): unknown {
|
|
126
|
+
const signed = JSON.parse(text) as { body?: unknown; signature?: unknown };
|
|
127
|
+
if (typeof signed.body !== 'string' || typeof signed.signature !== 'string') throw new Error('not a signed file');
|
|
128
|
+
if (!verify(null, Buffer.from(signed.body), createPublicKey({ key: Buffer.from(key, 'hex'), format: 'der', type: 'spki' }), Buffer.from(signed.signature, 'hex'))) throw new Error('a bad signature');
|
|
129
|
+
// The shape engine's PlacementSchema checks, roughly: a body the write's reader refuses must not make news every hour.
|
|
130
|
+
const body = JSON.parse(signed.body) as { kind?: unknown; serial?: unknown; cells?: unknown };
|
|
131
|
+
const id = (value: unknown): boolean => typeof value === 'string' && /^_?[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(value) && value.length <= 64;
|
|
132
|
+
if (body.kind !== 'placement' || !Number.isInteger(body.serial) || !Array.isArray(body.cells) || body.cells.length > 49
|
|
133
|
+
|| !body.cells.every((row: { instance?: unknown; slug?: unknown; cell?: unknown }) => id(row.instance) && id(row.slug) && Array.isArray(row.cell) && row.cell.length === 2 && row.cell.every(Number.isInteger))) throw new Error('not a placement file');
|
|
134
|
+
return body;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function fetchText(url: string): Promise<{ status: number; text: string }> {
|
|
138
|
+
if (url.startsWith('file:')) {
|
|
139
|
+
try { return { status: 200, text: readFileSync(new URL(url), 'utf8') }; }
|
|
140
|
+
catch (error) { if ((error as { code?: string }).code === 'ENOENT') return { status: 404, text: '' }; throw error; }
|
|
141
|
+
}
|
|
142
|
+
const response = await fetch(`${url}${url.includes('?') ? '&' : '?'}t=${String(Date.now())}`, { cache: 'no-store', redirect: 'error', signal: AbortSignal.timeout(FETCH_MS) });
|
|
143
|
+
return { status: response.status, text: await response.text() };
|
|
144
|
+
}
|
|
145
|
+
const message = (error: unknown): string => (error instanceof Error ? error.message : String(error));
|
|
146
|
+
|
|
147
|
+
/** Ask staging: its placement file, read by `read` (engine's reader for the write, `signedBody` for news). */
|
|
148
|
+
export async function askStaging(url: string, read: (text: string) => Promise<{ readonly channel: string; readonly serial: number; readonly cells: readonly Cell[] }>): Promise<StagingAnswer> {
|
|
149
|
+
try {
|
|
150
|
+
const { status, text } = await fetchText(url);
|
|
151
|
+
if (status === 404) return { none: `no placement file at ${url}` };
|
|
152
|
+
if (status !== 200) return { down: `${url} answered ${String(status)}` };
|
|
153
|
+
const file = await read(text);
|
|
154
|
+
if (file.channel !== 'staging') return { down: `${url} is a ${file.channel} placement file` };
|
|
155
|
+
return { placed: file.cells, serial: file.serial };
|
|
156
|
+
} catch (error) { return { down: `${url}: ${message(error)}` }; }
|
|
157
|
+
}
|
|
158
|
+
export async function askLast(url: string): Promise<LastAnswer> {
|
|
159
|
+
try {
|
|
160
|
+
const { status, text } = await fetchText(url);
|
|
161
|
+
return status === 200 ? { catalogue: JSON.parse(text) as unknown } : { down: `${url} answered ${String(status)}` };
|
|
162
|
+
} catch (error) { return { down: `${url}: ${message(error)}` }; }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function main(argv: readonly string[]): Promise<void> {
|
|
166
|
+
const flag = (name: string): string | undefined => argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
167
|
+
const placements = flag('placements') ?? STAGING_PLACEMENTS, lastUrl = flag('last') ?? LIVE_PREVIEW_CATALOGUE, key = flag('key') ?? PLACEMENT_PUBLIC_KEY;
|
|
168
|
+
const pin = JSON.parse(readFileSync(PIN, 'utf8')) as Catalogue, out = argv.find(arg => !arg.startsWith('--'));
|
|
169
|
+
const github = (file: string | undefined, text: string): void => { if (file !== undefined && file !== '') appendFileSync(file, text); };
|
|
170
|
+
const news = argv.includes('--news'), { GITHUB_OUTPUT, GITHUB_ACTIONS, GITHUB_STEP_SUMMARY } = process.env;
|
|
171
|
+
if (!news && out === undefined) throw new Error('usage: preview-grid.ts <out.json> | --news [--placements=<url>] [--last=<url>] [--key=<hex>]');
|
|
172
|
+
// The write believes only engine's own reader (`readPlacementFile`, the staging MMO's check); `--news` runs before install.
|
|
173
|
+
const read = news ? (text: string): Promise<{ channel: string; serial: number; cells: Cell[] }> => Promise.resolve(signedBody(text, key) as { channel: string; serial: number; cells: Cell[] })
|
|
174
|
+
: async (text: string): Promise<{ readonly channel: string; readonly serial: number; readonly cells: readonly Cell[] }> => {
|
|
175
|
+
const { readPlacementFile } = await import('../src/server/host/dedicated/placementFile.ts');
|
|
176
|
+
return readPlacementFile(text, key);
|
|
177
|
+
};
|
|
178
|
+
const [staging, last] = await Promise.all([askStaging(placements, read), askLast(lastUrl)]);
|
|
179
|
+
const borrowed = borrowGrid(pin, staging, last);
|
|
180
|
+
for (const line of borrowed.lines) console.log(`preview grid: ${line}`);
|
|
181
|
+
if (news) {
|
|
182
|
+
// A deploy is news when staging's cells differ from what the live preview shows; a kept grid is the live one, so no news.
|
|
183
|
+
let shown: readonly Cell[] | undefined;
|
|
184
|
+
try { if ('catalogue' in last) shown = borrowedCells(pin, last.catalogue); } catch { shown = undefined; }
|
|
185
|
+
// An unreadable live catalogue is news only when staging has a cell to show.
|
|
186
|
+
const fresh = borrowed.source === 'staging' && (shown === undefined ? borrowed.cells.length > 0 : !sameCells(shown, borrowed.cells));
|
|
187
|
+
console.log(fresh ? 'preview grid: staging\'s grid differs from the live preview\'s: deploy' : 'preview grid: the live preview already shows staging\'s grid');
|
|
188
|
+
github(GITHUB_OUTPUT, `news=${String(fresh)}\n`);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const file = resolve(out ?? '');
|
|
192
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
193
|
+
writeFileSync(file, `${JSON.stringify(borrowed.document)}\n`);
|
|
194
|
+
console.log(`preview grid: wrote ${file}`);
|
|
195
|
+
// A workflow command ends at a newline, and fetched error text can hold one: GitHub's own escapes.
|
|
196
|
+
const escaped = (text: string): string => text.replaceAll('%', '%25').replaceAll('\r', '%0D').replaceAll('\n', '%0A');
|
|
197
|
+
if (borrowed.warning !== undefined && GITHUB_ACTIONS === 'true') console.log(`::warning title=preview grid::${escaped(borrowed.warning)}`);
|
|
198
|
+
github(GITHUB_STEP_SUMMARY, `### Preview grid (SA35)\n\n${borrowed.lines.map(line => `- ${line}`).join('\n')}\n`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
202
|
+
try { await main(process.argv.slice(2)); } catch (error) { console.error(`preview grid: ${message(error)}`); process.exitCode = 1; }
|
|
203
|
+
}
|
|
@@ -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;
|