@wildshard/engine 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/budgets/shard-size-baseline.json +10 -4
- package/index.html +6 -4
- package/lint/engine-sides.json +14 -0
- package/lint/ratchet.json +0 -68
- package/lint/ratchet.mjs +1 -4
- package/package.json +17 -15
- package/scripts/agent-sync.mjs +27 -8
- package/scripts/app-build/appCook.ts +8 -2
- package/scripts/app-build/catalogue.ts +10 -7
- package/scripts/app-build/gen.ts +22 -2
- package/scripts/app-build/isolation.d.mts +10 -0
- package/scripts/app-build/isolation.mjs +47 -0
- package/scripts/app-build/outputProducts.mjs +4 -0
- package/scripts/app-build/previousDeploy.d.mts +2 -0
- package/scripts/app-build/previousDeploy.mjs +10 -1
- package/scripts/app-build/serviceWorker.ts +10 -3
- package/scripts/app-build/splitOutput.mjs +4 -2
- package/scripts/app-build/standaloneOutput.d.mts +1 -1
- package/scripts/app-build/standaloneOutput.mjs +5 -3
- package/scripts/app-build/titlePreloads.d.mts +8 -0
- package/scripts/app-build/titlePreloads.mjs +69 -0
- package/scripts/app-build/worldMapAtlas.ts +10 -6
- package/scripts/app-build-pipeline.mjs +31 -3
- package/scripts/built-product.mjs +1 -1
- package/scripts/cell-mem-bench.mjs +81 -23
- package/scripts/check-custom-sections-zero.mjs +1 -1
- package/scripts/check-devserver.mjs +2 -0
- package/scripts/check-models.mjs +2 -0
- package/scripts/check-paths.allow.json +0 -115
- package/scripts/check-paths.mjs +2 -2
- package/scripts/check-platform-ratchets.mjs +2 -3
- package/scripts/chromium-keychain.d.mts +1 -1
- package/scripts/ci-static.sh +1 -1
- package/scripts/committed-fast-checks.mjs +0 -2
- package/scripts/content-sw-proof.mjs +2 -1
- package/scripts/cook-worker.mjs +9 -3
- package/scripts/cook.mjs +18 -5
- package/scripts/docs-inputs-proof.mjs +6 -6
- package/scripts/e7-voice-staging-proof.mjs +1 -1
- package/scripts/gate-related-tests.mjs +1 -1
- package/scripts/git-source-view.mjs +1 -1
- package/scripts/goldens/capture.mjs +17 -5
- package/scripts/grid-crossing-nightly.mjs +59 -0
- package/scripts/grid-crossing-qa.mjs +44 -0
- package/scripts/grid-crossing-ratchet.d.mts +6 -0
- package/scripts/grid-crossing-ratchet.mjs +52 -0
- package/scripts/grid-crossing-report.mjs +122 -0
- package/scripts/grid-crossing-stages.mjs +47 -0
- package/scripts/grid-crossing-tour.mjs +277 -0
- package/scripts/grid-crossing-walk-proof.mjs +124 -17
- package/scripts/host-ruler/roots.mjs +2 -2
- package/scripts/host-ruler.d.mts +91 -0
- package/scripts/host-ruler.mjs +565 -0
- package/scripts/live-prepush.py +3 -5
- package/scripts/loading-flow/benchmax.mjs +3 -1
- package/scripts/look-loop/test_look_loop.py +1 -38
- package/scripts/memory-proof.mjs +61 -6
- package/scripts/mmo-bots.mjs +8 -2
- package/scripts/net-lag-proof.mjs +219 -0
- package/scripts/night-market-kit-budget.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +2 -2
- package/scripts/offline-proof-rules.mjs +15 -4
- package/scripts/offline-proof.mjs +74 -13
- package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
- package/scripts/page-release/content.d.mts +9 -1
- package/scripts/page-release/content.mjs +131 -17
- package/scripts/page-release/flow.mjs +36 -10
- package/scripts/page-release/stamp-content.mjs +24 -0
- package/scripts/page-release.mjs +28 -6
- package/scripts/page-size.mjs +2 -1
- package/scripts/pin-packs.ts +1 -1
- package/scripts/pins.ts +4 -4
- package/scripts/precommit-checks.mjs +1 -7
- package/scripts/precommit-jobs.mjs +0 -1
- package/scripts/precommit-source.py +1 -9
- package/scripts/program-discovery.mjs +1 -1
- package/scripts/ring-cook.mjs +2 -1
- package/scripts/ring-step.ts +1 -1
- package/scripts/script-scenario-metrics.mjs +1 -1
- package/scripts/shard-output-content.d.mts +1 -1
- package/scripts/shard-output-content.mjs +2 -2
- package/scripts/shard-outputs.mjs +1 -1
- package/scripts/shard-public.mjs +1 -1
- package/scripts/shard-wire-meter.mjs +24 -9
- package/scripts/side-parity.mjs +4 -2
- package/scripts/standalone-smoke.mjs +8 -3
- package/scripts/tier-textures.mjs +22 -4
- package/scripts/tile-bake-report.mjs +1 -1
- package/scripts/tile-bakes.mjs +1 -1
- package/scripts/title-assets.generated.json +2 -0
- package/scripts/tsconfig.json +0 -2
- package/scripts/vendor/basisu/LICENSE +201 -0
- package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
- package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
- package/scripts/vitest-push-guards.config.ts +1 -1
- package/scripts/vps/harden-apply.sh +4 -1
- package/scripts/vps/harden-prometheus.sh +176 -0
- package/scripts/vps/harden.sh +16 -0
- package/scripts/vps/rebuild.sh +18 -0
- package/scripts/vps/wildshard-config +6 -2
- package/scripts/worker-client-play.mjs +6 -2
- package/scripts/worktree-reap.mjs +5 -5
- package/src/.oxlintrc.json +3 -182
- package/src/client/app/entry.ts +10 -2
- package/src/client/engine/boot/bootCache.ts +2 -2
- package/src/client/engine/boot/bootTrace.ts +12 -4
- package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
- package/src/client/engine/boot/clearDownloads.ts +5 -2
- package/src/client/engine/boot/contentRead.ts +11 -0
- package/src/client/engine/boot/gpuFiles.ts +4 -2
- package/src/client/engine/boot/lastEnd.ts +99 -12
- package/src/client/engine/boot/texturePack.ts +2 -2
- package/src/client/engine/net/netPlayer.ts +19 -2
- package/src/client/engine/net/otherPlayers.ts +55 -8
- package/src/client/engine/net/predictor.ts +33 -9
- package/src/client/engine/net/redial.ts +29 -6
- package/src/client/engine/pwa/cacheNames.ts +58 -1
- package/src/client/engine/pwa/sw.js +41 -11
- package/src/client/engine/render/dataLook.ts +152 -40
- package/src/client/engine/render/families/detail.ts +89 -0
- package/src/client/engine/render/families/pbr.ts +7 -1
- package/src/client/engine/render/look.ts +6 -0
- package/src/client/engine/render/lookLight.ts +103 -11
- package/src/client/engine/render/lookRender.ts +105 -0
- package/src/client/engine/saves/indexed.ts +2 -2
- package/src/client/engine/telemetry/browserErrors.ts +24 -3
- package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
- package/src/client/engine/ui/debugOptions.ts +1 -1
- package/src/client/engine/ui/lookLightOption.ts +10 -6
- package/src/client/engine/ui/namePrompt.ts +7 -0
- package/src/client/game/boot/audio.generated.ts +114 -114
- package/src/client/game/boot/bytes.generated.ts +118 -220
- package/src/client/game/boot/placedSpawn.ts +35 -0
- package/src/client/game/boot/spawnDownload.ts +25 -6
- package/src/client/game/boot/versions.generated.ts +7 -5
- package/src/client/game/devScene/hook.ts +291 -0
- package/src/client/game/grid/cellLoading.ts +12 -2
- package/src/client/game/grid/live.ts +112 -16
- package/src/client/game/grid/liveSession.ts +33 -2
- package/src/client/game/grid/mapAtlas.ts +18 -4
- package/src/client/game/grid/minimapBlend.ts +15 -5
- package/src/client/game/grid/oneWayIn.ts +5 -1
- package/src/client/game/grid/placedCells.ts +114 -12
- package/src/client/game/grid/placedContent.ts +85 -0
- package/src/client/game/grid/prefetch.ts +9 -1
- package/src/client/game/grid/productInputs.ts +3 -1
- package/src/client/game/grid/productLeases.ts +4 -1
- package/src/client/game/grid/products.ts +8 -4
- package/src/client/game/grid/roadLook.ts +24 -15
- package/src/client/game/grid/roadLookPlatform.ts +4 -2
- package/src/client/game/grid/roadResources.ts +24 -0
- package/src/client/game/grid/roadSign.worker.ts +4 -3
- package/src/client/game/grid/roadSignPaint.ts +16 -5
- package/src/client/game/grid/roadSignPreparation.ts +4 -3
- package/src/client/game/grid/roadSignScale.ts +8 -0
- package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
- package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
- package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
- package/src/client/game/grid/roadTileWriter.ts +2 -1
- package/src/client/game/grid/screenReports.ts +39 -0
- package/src/client/game/grid/session.ts +20 -4
- package/src/client/game/grid/softWallLook.ts +25 -8
- package/src/client/game/mainMenu.ts +6 -2
- package/src/client/game/plugin/context.ts +2 -1
- package/src/client/game/plugin/followedMovers.ts +7 -1
- package/src/client/game/quest/figures.ts +2 -0
- package/src/client/game/session/finish.ts +6 -0
- package/src/client/game/shardfile/assetCache.ts +4 -4
- package/src/client/game/shardfile/client.ts +4 -1
- package/src/client/game/shardfile/clientAssets.ts +9 -5
- package/src/client/game/shardfile/clientLibrary.ts +1 -1
- package/src/client/game/shardfile/clientWater.ts +51 -9
- package/src/client/game/shardfile/clientWorker.ts +19 -7
- package/src/client/game/shardfile/look.ts +8 -3
- package/src/client/game/shardfile/product.ts +34 -7
- package/src/client/game/shardfile/productChecks.ts +2 -2
- package/src/client/game/shardfile/productCost.ts +2 -2
- package/src/client/game/shardfile/readAsset.ts +2 -2
- package/src/client/game/shardfile/reflectingWater.ts +73 -0
- package/src/client/game/shardfile/seatGrace.ts +9 -0
- package/src/client/game/shardfile/skinPlayback.ts +1 -1
- package/src/client/game/systems/npc/figureRows.ts +9 -0
- package/src/client/host/online/doctor.ts +2 -0
- package/src/client/host/online/linkScreens.ts +30 -4
- package/src/client/host/standalone/shell.ts +4 -0
- package/src/cook/game/astc6Encode.ts +55 -0
- package/src/cook/game/astc6Wasm.ts +176 -0
- package/src/cook/game/cookJob.ts +30 -6
- package/src/cook/game/cookWorker.ts +38 -11
- package/src/cook/game/entryTotals.ts +51 -24
- package/src/cook/game/shardCook.ts +35 -7
- package/src/cook/game/spawnParts.ts +33 -8
- package/src/cook/game/tierTextures.ts +87 -14
- package/src/server/engine/ai/bossContenders.ts +27 -3
- package/src/server/engine/ai/phases.ts +1 -1
- package/src/server/engine/entities/creatureRefill.ts +9 -2
- package/src/server/engine/net/ledgerBook.ts +2 -0
- package/src/server/engine/net/room.ts +15 -0
- package/src/server/engine/sim/respawn.ts +8 -0
- package/src/server/game/boss/arenaRoomEntry.ts +5 -1
- package/src/server/game/boss/arenaRoomNative.ts +2 -0
- package/src/server/game/boss/native.ts +2 -1
- package/src/server/game/boss/nativeWake.ts +9 -5
- package/src/server/game/boss/openArenaNative.ts +2 -2
- package/src/server/game/boss/openArenaRoom.ts +3 -1
- package/src/server/game/grid/room.ts +44 -3
- package/src/server/game/grid/simulation.ts +23 -0
- package/src/server/game/population/mixedRoster.ts +11 -3
- package/src/server/game/population/nativeBake.ts +8 -3
- package/src/server/game/population/nativeReturns.ts +6 -3
- package/src/server/game/population/roster.ts +5 -3
- package/src/server/game/quest/eliteDrops.ts +15 -4
- package/src/server/game/quest/nativeChapter.ts +1 -1
- package/src/server/game/quest/nativeComposition.ts +5 -1
- package/src/server/game/riding/nativeTaming.ts +10 -6
- package/src/server/game/riding/wildRefill.ts +3 -2
- package/src/server/game/shardfile/bossRow.ts +4 -2
- package/src/server/game/shardfile/homeKeeper.ts +4 -2
- package/src/server/host/bake/headlessWorker.ts +1 -1
- package/src/server/host/dedicated/cellHost.ts +98 -16
- package/src/server/host/dedicated/cellProtocol.ts +16 -1
- package/src/server/host/dedicated/cellWorker.ts +8 -5
- package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
- package/src/server/host/dedicated/gridCells.ts +15 -6
- package/src/server/host/dedicated/loopLag.ts +21 -0
- package/src/server/host/dedicated/main.ts +13 -5
- package/src/server/host/dedicated/packReader.ts +3 -3
- package/src/server/host/dedicated/placementFile.ts +3 -2
- package/src/server/host/dedicated/roadRoom.ts +34 -4
- package/src/server/host/dedicated/serverMetrics.ts +126 -0
- package/src/server/host/dedicated/socketPump.ts +21 -4
- package/src/server/host/dedicated/workerTable.ts +15 -4
- package/src/server/host/dedicated/world.ts +65 -7
- package/src/server/host/headless.ts +1 -1
- package/src/server/host/headlessRuntime.ts +1 -1
- package/src/server/host/standalone/roadWorld.ts +15 -3
- package/src/server/host/standalone/serverHost.ts +4 -1
- package/src/server/host/standalone/serverProduct.ts +41 -11
- package/src/shared/engine/ai/BossBrain.ts +8 -0
- package/src/shared/game/boss/wake.ts +6 -0
- package/src/shared/game/devColliders.ts +47 -0
- package/src/shared/game/eliteSystem.ts +8 -0
- package/src/shared/game/grid/allocator.ts +3 -0
- package/src/shared/game/grid/placementRows.ts +5 -2
- package/src/shared/game/plugin/bossRecord.ts +3 -2
- package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
- package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
- package/src/shared/game/shardfile/packReads.ts +28 -3
- package/src/shared/game/shardfile/serverPack.ts +9 -0
- package/src/shared/game/systems/looks/trampleField.ts +2 -0
- package/src/shared/host/formatJsonSchema.ts +2 -2
- package/src/tsconfig.json +1 -27
- package/lint/host-reviews.json +0 -14
- package/lint/listed-view-code.json +0 -13
- package/lint/platform-pending-users.json +0 -2520
- package/lint/platform-pending-users.md +0 -18
- package/scripts/cell-mem/metrics-preload.mjs +0 -65
- package/scripts/check-closed-components.d.mts +0 -7
- package/scripts/check-closed-components.mjs +0 -87
- package/scripts/g571-hosts.d.mts +0 -3
- package/scripts/g571-hosts.mjs +0 -54
- package/scripts/host-ruler/register-migrate.mjs +0 -242
- package/scripts/listed-view-code.d.mts +0 -7
- package/scripts/listed-view-code.mjs +0 -93
- package/scripts/look-loop/fit-lut.py +0 -142
- package/scripts/look-loop/palette-delta.py +0 -183
- package/scripts/look-loop/regions/driftwood-isle.json +0 -25
- package/scripts/look-loop/regions/far-reach.json +0 -225
- package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
- package/scripts/look-loop/regions/pine-hollow.json +0 -22
- package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
- package/scripts/platform-chargebacks.d.mts +0 -9
- package/scripts/platform-chargebacks.mjs +0 -135
- package/scripts/shard-component-spans.d.mts +0 -15
- package/scripts/shard-component-spans.mjs +0 -18
- package/scripts/shard-components.d.mts +0 -16
- package/scripts/shard-components.mjs +0 -363
- package/scripts/shard-platform-hosts.d.mts +0 -2
- package/scripts/shard-platform-hosts.mjs +0 -93
- package/scripts/shard-platform-sections.d.mts +0 -2
- package/scripts/shard-platform-sections.mjs +0 -9
- package/scripts/shard-platform.d.mts +0 -76
- package/scripts/shard-platform.mjs +0 -1072
- package/src/.oxfmtrc.json +0 -48
- package/src/scripts/ask-new.sh +0 -29
- package/src/scripts/asks.mjs +0 -142
- package/src/scripts/herdr-prompt.sh +0 -34
- package/src/scripts/herdr-question-open.sh +0 -67
- package/src/scripts/md-wrap.mjs +0 -229
- /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
- /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
- /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// HOST-RULER (meta docs/plans/HOST-RULER-PLAN.md): the closure each built product reaches, and the modules it alone
|
|
3
|
+
// reaches. A product's roots are its HR1 page/section roots (scripts/host-ruler/roots.mjs) and its HR2 server roots
|
|
4
|
+
// (scripts/host-ruler/server-roots.mjs).
|
|
5
|
+
// HR3: from them the ruler follows static imports and ordinary import()s, but never through a dispatch table (TABLES):
|
|
6
|
+
// a table's entries are already rooted per declared kind or host id, so following the whole table would make every
|
|
7
|
+
// product a user of every entry (HA0 a, b). Engine self-imports (`@wildshard/engine/*`) resolve through engine's
|
|
8
|
+
// package.json exports map. Lines are code lines: nonblank once comments are blanked (the old census's codeLines unit).
|
|
9
|
+
// HR4: the shell (the app entry with no product loaded) is a user only of the modules SHELL_CONTROL names, not of
|
|
10
|
+
// whole folders (HA0 d); `@wildshard/format/*` modules resolve through the pinned format package's exports map and are
|
|
11
|
+
// charged like any host, reported under `format`, published files only (HA0 e).
|
|
12
|
+
// Report-only: nothing here fails a commit.
|
|
13
|
+
// Usage: node scripts/host-ruler.mjs --products <product-dir>... [--json]
|
|
14
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
15
|
+
import { dirname, extname, join, relative, resolve } from 'node:path';
|
|
16
|
+
import { parseSync } from 'vite';
|
|
17
|
+
import { CLIENT_PLAN, CLIENT_PLAN_ROOT, ENGINE_ROOT, SECTION_HOSTS, clientPlanRoots, modulePath, productRoots, resolveModule } from './host-ruler/roots.mjs';
|
|
18
|
+
import { NATIVE_ASSEMBLY, NATIVE_ASSEMBLY_ROOT, NATIVE_HOSTS, nativeAssemblyRoots, productServerRoots } from './host-ruler/server-roots.mjs';
|
|
19
|
+
import { REGISTER, namesBinding, readHostRegister } from './host-ruler/register.mjs';
|
|
20
|
+
|
|
21
|
+
/** Dispatch tables: a module whose entries a product reaches one by one through its declarations. The module itself
|
|
22
|
+
* runs (its lines count for every product that reaches it); `static` and `dynamic` say which of its own imports are
|
|
23
|
+
* still followed. Explorer dispatch and the chapter facets the plan names are no longer tables in this tree:
|
|
24
|
+
* explorerCatalogue.ts statically builds one catalogue for every product, and the facet owners were retired (G621). */
|
|
25
|
+
export const TABLES = Object.freeze({
|
|
26
|
+
// CLIENT_FEATURES: its import()s are the per-kind roots; its static imports are the shared `@client-plan` root.
|
|
27
|
+
[CLIENT_PLAN]: { static: true, dynamic: false },
|
|
28
|
+
// `switch (row.host)`: every case's imports are rooted per declared host id, the shared part as `@native-assembly`.
|
|
29
|
+
[NATIVE_HOSTS]: { static: false, dynamic: false },
|
|
30
|
+
// Its value imports are `@native-assembly`, minus the ones gated on one host id (NATIVE_GATED).
|
|
31
|
+
[NATIVE_ASSEMBLY]: { static: false, dynamic: false },
|
|
32
|
+
// CALLS: the `{$call}` rows a discovery document may name; each look loads only when a product names it.
|
|
33
|
+
'src/client/game/shard/discovery.ts': { static: true, dynamic: false },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/** The shell: the app entry with no product loaded. */
|
|
37
|
+
export const SHELL = '@shell';
|
|
38
|
+
export const SHELL_ROOTS = Object.freeze(['src/client/app/entry.ts']);
|
|
39
|
+
/** The modules the shell is a user of: orchestration it runs for every shard (grid, session, shard loading, travel).
|
|
40
|
+
* Named one by one, replacing the old census's SHELL_CONTROL_PREFIXES, seven folders (retired by HR9): a new module in those
|
|
41
|
+
* folders is charged to its shard until someone adds it here. Seeded 2026-11-13 from the folder rule's reach: the
|
|
42
|
+
* modules in those folders (and plugin/ui.ts, whose bridge declarations the old rule named) that the shell reaches and a
|
|
43
|
+
* built product reaches. Never add species, models, looks or gameplay. The test checks the shell reaches each one. */
|
|
44
|
+
export const SHELL_CONTROL = Object.freeze([
|
|
45
|
+
'src/client/game/grid/assetResidency.ts', 'src/client/game/grid/entryDownloads.ts', 'src/client/game/grid/farImpostorView.ts',
|
|
46
|
+
'src/client/game/grid/farView.ts', 'src/client/game/grid/frameLook.ts', 'src/client/game/grid/intent.ts', 'src/client/game/grid/menu.ts',
|
|
47
|
+
'src/client/game/grid/nearGrain.ts', 'src/client/game/grid/nearPlaceholderPlan.ts', 'src/client/game/grid/nearPlaceholderView.ts',
|
|
48
|
+
'src/client/game/grid/pageEntry.ts', 'src/client/game/grid/pageResidency.ts', 'src/client/game/grid/productInputs.ts',
|
|
49
|
+
'src/client/game/grid/skinEnvelope.ts', 'src/client/game/grid/tileDecoder.ts', 'src/client/game/grid/titlePrefetchChoice.ts',
|
|
50
|
+
'src/client/game/plugin/ui.ts',
|
|
51
|
+
'src/client/game/session/clockSettings.ts', 'src/client/game/session/hudAccent.ts',
|
|
52
|
+
'src/client/game/shard/declaredPlumbing.ts', 'src/client/game/shard/declaredTargets.ts', 'src/client/game/shard/declaredUi.ts',
|
|
53
|
+
'src/client/game/shard/list.ts', 'src/client/game/shard/manifest.ts', 'src/client/game/shard/registry.ts',
|
|
54
|
+
'src/client/game/shard/retainedHooks.ts', 'src/client/game/shard/scopedRuntime.ts', 'src/client/game/shard/spec.ts',
|
|
55
|
+
'src/client/game/shard/titleList.ts',
|
|
56
|
+
'src/client/game/travel/travel.ts',
|
|
57
|
+
'src/shared/game/grid/allocator.ts', 'src/shared/game/grid/assembly.ts', 'src/shared/game/grid/catalogue.ts',
|
|
58
|
+
'src/shared/game/grid/catalogueDocument.ts', 'src/shared/game/grid/catalogueSlot.ts', 'src/shared/game/grid/cellEvents.ts',
|
|
59
|
+
'src/shared/game/grid/farProxy.ts', 'src/shared/game/grid/instances.ts', 'src/shared/game/grid/pageMode.ts',
|
|
60
|
+
'src/shared/game/grid/recovery.ts', 'src/shared/game/grid/roadLayout.ts', 'src/shared/game/grid/roadRecovery.ts',
|
|
61
|
+
'src/shared/game/grid/rules.ts',
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
/** Per line of `source`, whether it holds code once comment spans are blanked.
|
|
65
|
+
* @param {string} source @param {readonly { start: number, end: number }[]} comments */
|
|
66
|
+
function codeLineMask(source, comments) {
|
|
67
|
+
const chunks = [];
|
|
68
|
+
let cursor = 0;
|
|
69
|
+
for (const { start, end } of comments) {
|
|
70
|
+
chunks.push(source.slice(cursor, start), source.slice(start, end).replaceAll(/[^\n]/gu, ' '));
|
|
71
|
+
cursor = end;
|
|
72
|
+
}
|
|
73
|
+
chunks.push(source.slice(cursor));
|
|
74
|
+
return chunks.join('').split('\n').map(line => line.trim() !== '');
|
|
75
|
+
}
|
|
76
|
+
/** Code lines of a TypeScript source: nonblank lines once parser comment spans are blanked.
|
|
77
|
+
* @param {string} source @param {string} [path] */
|
|
78
|
+
export function codeLines(source, path = 'measure.ts') {
|
|
79
|
+
return codeLineMask(source, parseSync(path, source).comments).filter(Boolean).length;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @param {any} pattern @param {string[]} out */
|
|
83
|
+
function patternIds(pattern, out) {
|
|
84
|
+
if (pattern === null || pattern === undefined) return out;
|
|
85
|
+
if (pattern.type === 'Identifier') out.push(pattern.name);
|
|
86
|
+
else if (pattern.type === 'ObjectPattern') for (const p of pattern.properties) patternIds(p.type === 'RestElement' ? p.argument : p.value, out);
|
|
87
|
+
else if (pattern.type === 'ArrayPattern') for (const e of pattern.elements) patternIds(e, out);
|
|
88
|
+
else if (pattern.type === 'RestElement') patternIds(pattern.argument, out);
|
|
89
|
+
else if (pattern.type === 'AssignmentPattern') patternIds(pattern.left, out);
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
/** Each top-level declaration's names and span, for crediting a register row on one binding.
|
|
93
|
+
* @param {any} program @returns {{ names: string[], start: number, end: number }[]} */
|
|
94
|
+
function declarations(program) {
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const statement of program.body) {
|
|
97
|
+
const node = statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;
|
|
98
|
+
if (statement.type === 'ExportDefaultDeclaration') {
|
|
99
|
+
// `export default function Foo` answers to both `#default` and `#Foo`.
|
|
100
|
+
const named = statement.declaration?.id?.type === 'Identifier' ? [statement.declaration.id.name] : [];
|
|
101
|
+
out.push({ names: ['default', ...named], start: statement.start, end: statement.end }); continue;
|
|
102
|
+
}
|
|
103
|
+
if (node === null || node === undefined) continue;
|
|
104
|
+
if (node.type === 'VariableDeclaration') {
|
|
105
|
+
const one = node.declarations.length === 1;
|
|
106
|
+
for (const d of node.declarations) out.push({ names: patternIds(d.id, []), start: one ? statement.start : d.start, end: one ? statement.end : d.end });
|
|
107
|
+
} else if (node.id?.type === 'Identifier') out.push({ names: [node.id.name], start: statement.start, end: statement.end });
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const FORMAT = '@wildshard/format';
|
|
113
|
+
/** A glob of package.json `files` as a regex over package paths: `**` any depth, `*` one segment. @param {string} glob */
|
|
114
|
+
const globRegex = glob => new RegExp(`^${glob.replace(/\/$/u, '/**').replaceAll(/[.+^${}()|[\]\\]/gu, String.raw`\$&`).replaceAll('**', '\0').replaceAll('*', '[^/]*').replaceAll('\0', '.*')}$`, 'u');
|
|
115
|
+
/** The pinned format package: its dir, its exports map and its published `files` (HR4: only published files count).
|
|
116
|
+
* @param {string} dir */
|
|
117
|
+
export function formatPackage(dir) {
|
|
118
|
+
const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
119
|
+
const files = /** @type {string[]} */ (manifest.files ?? []);
|
|
120
|
+
const include = files.filter(glob => !glob.startsWith('!')).map(globRegex), exclude = files.filter(glob => glob.startsWith('!')).map(glob => globRegex(glob.slice(1)));
|
|
121
|
+
return {
|
|
122
|
+
dir,
|
|
123
|
+
version: /** @type {string} */ (manifest.version),
|
|
124
|
+
exports: /** @type {Record<string, unknown>} */ (manifest.exports ?? {}),
|
|
125
|
+
/** Whether a package path (`src/format/stealth.ts`) is a published file. */
|
|
126
|
+
published: (/** @type {string} */ path) => include.some(re => re.test(path)) && !exclude.some(re => re.test(path)),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** A module id: an engine path `src/...`, a format id `@wildshard/format/<package path>`, `npm:<name>`, or a non-code
|
|
131
|
+
* file (`.json`, `.css`, `?raw`), which is data and counts no lines. Engine self-imports and format imports resolve
|
|
132
|
+
* through their package's exports map; a format file the package does not publish refuses.
|
|
133
|
+
* @param {string} specifier @param {string} from @param {string} root @param {ReturnType<typeof formatPackage>} format */
|
|
134
|
+
function resolveFrom(specifier, from, root, format) {
|
|
135
|
+
const bare = specifier.replace(/\?.*$/u, '');
|
|
136
|
+
/** @param {string} file */
|
|
137
|
+
const id = file => {
|
|
138
|
+
const inFormat = relative(format.dir, file);
|
|
139
|
+
if (inFormat.startsWith('..')) return relative(root, file);
|
|
140
|
+
if (!format.published(inFormat)) throw new Error(`${from} imports ${specifier}: ${inFormat} is not a published file of ${FORMAT}`);
|
|
141
|
+
return `${FORMAT}/${inFormat}`;
|
|
142
|
+
};
|
|
143
|
+
if (bare.startsWith('.')) {
|
|
144
|
+
const fromFile = from.startsWith(`${FORMAT}/`) ? join(format.dir, from.slice(FORMAT.length + 1)) : join(root, from);
|
|
145
|
+
const base = resolve(dirname(fromFile), bare);
|
|
146
|
+
const candidates = [base, `${base}.ts`, `${base}.tsx`, `${base}.mts`, join(base, 'index.ts')];
|
|
147
|
+
if (/\.[cm]?js$/u.test(base)) candidates.push(base.replace(/\.[cm]?js$/u, '.ts'));
|
|
148
|
+
const file = candidates.find(candidate => existsSync(candidate) && extname(candidate) !== '');
|
|
149
|
+
if (file === undefined) throw new Error(`Unresolved import ${specifier} from ${from}`);
|
|
150
|
+
return id(file);
|
|
151
|
+
}
|
|
152
|
+
if (bare.startsWith(`${FORMAT}/`)) {
|
|
153
|
+
const target = format.exports[`./${bare.slice(FORMAT.length + 1)}`];
|
|
154
|
+
if (typeof target !== 'string') throw new Error(`Unresolved import ${specifier} from ${from}: not in ${FORMAT} exports`);
|
|
155
|
+
return id(join(format.dir, target));
|
|
156
|
+
}
|
|
157
|
+
return resolveModule(bare, from, root);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** @typedef {{ lines: number, imports: string[], dynamic: string[], opaque: string[], declarations: { names: string[], lines: number }[] }} ModuleFacts */
|
|
161
|
+
const CODE = /\.[cm]?[jt]sx?$/u;
|
|
162
|
+
/** Read engine's tree and the pinned format package one module at a time, cached.
|
|
163
|
+
* @param {{ root?: string, format?: boolean, formatDir?: string }} [options] `format: false` stops at format modules
|
|
164
|
+
* (HR3's reading); by default they are followed and charged like any host (HR4). */
|
|
165
|
+
export function createTreeReader(options = {}) {
|
|
166
|
+
const root = options.root ?? ENGINE_ROOT, followFormat = options.format ?? true;
|
|
167
|
+
const format = formatPackage(options.formatDir ?? join(root, 'node_modules', FORMAT));
|
|
168
|
+
/** @type {Map<string, ModuleFacts>} */
|
|
169
|
+
const cache = new Map();
|
|
170
|
+
/** @param {string} module */
|
|
171
|
+
const followed = module => module.startsWith('src/') || (followFormat && module.startsWith(`${FORMAT}/`));
|
|
172
|
+
return {
|
|
173
|
+
root,
|
|
174
|
+
format,
|
|
175
|
+
followed,
|
|
176
|
+
/** @param {string} module @returns {ModuleFacts} */
|
|
177
|
+
read(module) {
|
|
178
|
+
const known = cache.get(module);
|
|
179
|
+
if (known !== undefined) return known;
|
|
180
|
+
if (!CODE.test(module)) { const row = { lines: 0, imports: [], dynamic: [], opaque: [], declarations: [] }; cache.set(module, row); return row; }
|
|
181
|
+
const file = module.startsWith(`${FORMAT}/`) ? join(format.dir, module.slice(FORMAT.length + 1)) : join(root, module);
|
|
182
|
+
const source = readFileSync(file, 'utf8');
|
|
183
|
+
const parsed = parseSync(module, source);
|
|
184
|
+
if (parsed.errors.length > 0) throw new Error(`${module}: parse errors`);
|
|
185
|
+
const mask = codeLineMask(source, parsed.comments);
|
|
186
|
+
const lineStarts = [0];
|
|
187
|
+
for (let i = 0; i < source.length; i++) if (source[i] === '\n') lineStarts.push(i + 1);
|
|
188
|
+
const lineOf = (/** @type {number} */ offset) => { let lo = 0, hi = lineStarts.length - 1; while (lo < hi) { const mid = (lo + hi + 1) >> 1; if (lineStarts[mid] <= offset) lo = mid; else hi = mid - 1; } return lo; };
|
|
189
|
+
const spanLines = (/** @type {number} */ start, /** @type {number} */ end) => { let n = 0; for (let line = lineOf(start); line <= lineOf(Math.max(start, end - 1)); line++) if (mask[line]) n++; return n; };
|
|
190
|
+
const to = (/** @type {string} */ specifier) => resolveFrom(specifier, module, root, format);
|
|
191
|
+
/** @type {Set<string>} */
|
|
192
|
+
const imports = new Set();
|
|
193
|
+
// A type-only import or re-export never runs; a side-effect import does.
|
|
194
|
+
for (const row of parsed.module.staticImports) if (row.entries.length === 0 || row.entries.some((/** @type {any} */ e) => !e.isType)) imports.add(to(row.moduleRequest.value));
|
|
195
|
+
for (const row of parsed.module.staticExports) for (const entry of row.entries) if (entry.moduleRequest !== null && !entry.isType) imports.add(to(entry.moduleRequest.value));
|
|
196
|
+
/** @type {Set<string>} */
|
|
197
|
+
const dynamic = new Set();
|
|
198
|
+
/** @type {string[]} */
|
|
199
|
+
const opaque = [];
|
|
200
|
+
for (const row of parsed.module.dynamicImports) {
|
|
201
|
+
const text = source.slice(row.moduleRequest.start, row.moduleRequest.end);
|
|
202
|
+
const literal = /^(['"`])([^'"`$]*)\1$/u.exec(text);
|
|
203
|
+
// A computed import() (a built bundle's URL, a page's own script) loads no source module: listed, not followed.
|
|
204
|
+
if (literal === null) opaque.push(text);
|
|
205
|
+
else dynamic.add(to(literal[2]));
|
|
206
|
+
}
|
|
207
|
+
const row = { lines: mask.filter(Boolean).length, imports: [...imports].sort(), dynamic: [...dynamic].sort(), opaque,
|
|
208
|
+
declarations: declarations(parsed.program).map(d => ({ names: d.names, lines: spanLines(d.start, d.end) })) };
|
|
209
|
+
cache.set(module, row);
|
|
210
|
+
return row;
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** The report layer of a module: `format` for the format package, else its side-first layer (`client/game`, ...).
|
|
216
|
+
* @param {string} module */
|
|
217
|
+
export const layerOf = module => module.startsWith(`${FORMAT}/`) ? 'format' : /^src\/(\w+\/\w+)\//u.exec(module)?.[1] ?? 'other';
|
|
218
|
+
|
|
219
|
+
/** Every module reached from `roots`: static imports and import()s, except the ones a dispatch table holds back.
|
|
220
|
+
* Modules the reader does not follow (npm packages) end the walk and are not listed.
|
|
221
|
+
* `held` names edges (`from\0to`) a product's options hold back (HR7).
|
|
222
|
+
* @param {Iterable<string>} roots @param {ReturnType<typeof createTreeReader>} reader @param {Readonly<Record<string, { static: boolean, dynamic: boolean }>>} [tables]
|
|
223
|
+
* @param {ReadonlySet<string>} [held] */
|
|
224
|
+
export function reach(roots, reader, tables = TABLES, held = new Set()) {
|
|
225
|
+
/** @type {Set<string>} */
|
|
226
|
+
const seen = new Set();
|
|
227
|
+
const stack = [...roots].filter(module => reader.followed(module));
|
|
228
|
+
while (stack.length > 0) {
|
|
229
|
+
const module = /** @type {string} */ (stack.pop());
|
|
230
|
+
if (seen.has(module)) continue;
|
|
231
|
+
seen.add(module);
|
|
232
|
+
const row = reader.read(module), table = Object.hasOwn(tables, module) ? tables[module] : undefined;
|
|
233
|
+
const next = [...(table?.static === false ? [] : row.imports), ...(table?.dynamic === false ? [] : row.dynamic)];
|
|
234
|
+
for (const target of next) if (!seen.has(target) && reader.followed(target) && !held.has(`${module}\0${target}`)) stack.push(target);
|
|
235
|
+
}
|
|
236
|
+
return seen;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** HR7 (HA0 c): the options that change what a client-plan kind installs. A row without `from` names a binding of the
|
|
240
|
+
* kind's own CLIENT_FEATURES entry that runs only when the option is set: a product that declares the kind without
|
|
241
|
+
* the option is not rooted at it, and when exactly one product sets the option, the binding's lines are charged to it
|
|
242
|
+
* even when the kind (and the module) has two users. A row with `from` names imports of `from` that only the option's
|
|
243
|
+
* branch uses: a product without the option does not follow those edges. Every other option a product sets prints as
|
|
244
|
+
* unmeasured, never as free. `when` narrows an option to some values. Each binding here is used only by its option
|
|
245
|
+
* (the test checks it). */
|
|
246
|
+
export const OPTIONS = Object.freeze([
|
|
247
|
+
// clientPlan.ts: species.program's `world` hook runs only `when: row.catalogue !== undefined`.
|
|
248
|
+
{ kind: 'species.program', option: 'catalogue', bindings: ['src/client/game/shardfile/clientSpeciesProgram.ts#prepareClientSpeciesCatalogue'] },
|
|
249
|
+
// clientPlan.ts: debug.expose imports sceneDressing only for `source.kind === 'dressing'` (HR1's open note).
|
|
250
|
+
{ kind: 'debug.expose', option: 'source', when: (/** @type {any} */ value) => value?.kind === 'dressing', bindings: ['src/client/game/shardfile/sceneDressing.ts#SceneDressing'] },
|
|
251
|
+
// clientQuestComposition.ts: a composition's figures (Pine's and Driftwood's people) load only when `figures` is set.
|
|
252
|
+
{ kind: 'quest.composition', option: 'figures', from: 'src/client/game/shardfile/clientQuestComposition.ts', bindings: [
|
|
253
|
+
'src/client/game/quest/figures.ts#installQuestFigures', 'src/client/game/models/figureCatalogue.ts#ProductFigureCatalogue',
|
|
254
|
+
'src/client/game/models/worldSceneCatalogue.ts#defineWorldSceneCatalogue', '@wildshard/format/src/format/questFigures.ts#parseQuestFiguresDocument',
|
|
255
|
+
'src/client/game/shardfile/worldScenes.ts#installWorldScenes'] },
|
|
256
|
+
]);
|
|
257
|
+
/** Read a product's client-plan feature rows (kind plus options), or none.
|
|
258
|
+
* @param {string} dir */
|
|
259
|
+
function featureRows(dir) {
|
|
260
|
+
const shard = JSON.parse(readFileSync(join(dir, 'shard.json'), 'utf8'));
|
|
261
|
+
const row = (Array.isArray(shard.sections) ? shard.sections : []).find((/** @type {any} */ section) => section.name === 'client/plan');
|
|
262
|
+
return row === undefined ? [] : /** @type {Record<string, unknown>[]} */ (JSON.parse(readFileSync(join(dir, row.path), 'utf8')).features);
|
|
263
|
+
}
|
|
264
|
+
/** @param {{ kind: string, option: string, when?: (value: unknown) => boolean }} entry @param {Record<string, unknown>} feature */
|
|
265
|
+
const sets = (entry, feature) => feature.kind === entry.kind && feature[entry.option] !== undefined && (entry.when === undefined || entry.when(feature[entry.option]));
|
|
266
|
+
|
|
267
|
+
/** The roots of one built product: its page and section roots, its server roots, the tables it enters, and the edges
|
|
268
|
+
* its unset options hold back.
|
|
269
|
+
* @param {string} dir @param {{ plan?: ReturnType<typeof clientPlanRoots>, native?: ReturnType<typeof nativeAssemblyRoots> }} [tables]
|
|
270
|
+
* @param {typeof OPTIONS} [options] */
|
|
271
|
+
export function productRootModules(dir, tables = {}, options = OPTIONS) {
|
|
272
|
+
const page = productRoots(dir, tables.plan), server = productServerRoots(dir, tables.native), features = featureRows(dir);
|
|
273
|
+
const setOptions = options.filter(entry => features.some(feature => sets(entry, feature)));
|
|
274
|
+
// A kind root binding gated on an unset option roots nothing; a module root keeps any binding left.
|
|
275
|
+
const gated = new Set(options.filter(entry => entry.from === undefined && !setOptions.includes(entry)).flatMap(entry => entry.bindings));
|
|
276
|
+
/** @type {Set<string>} */
|
|
277
|
+
const modules = new Set(server.modules.map(row => row.module));
|
|
278
|
+
for (const root of page.roots) if (!root.from.startsWith('kind:') || root.bindings.some(binding => !gated.has(`${root.module}#${binding}`))) modules.add(root.module);
|
|
279
|
+
if (page.sections.includes('client/plan')) modules.add(CLIENT_PLAN);
|
|
280
|
+
if (server.roots.length > 0 || server.unmeasured.length > 0) { modules.add(NATIVE_ASSEMBLY); modules.add(NATIVE_HOSTS); }
|
|
281
|
+
const held = new Set(options.filter(entry => entry.from !== undefined && !setOptions.includes(entry)).flatMap(entry => entry.bindings.map(binding => `${entry.from}\0${binding.split('#')[0]}`)));
|
|
282
|
+
/** @type {string[]} */
|
|
283
|
+
const unmeasuredOptions = [];
|
|
284
|
+
for (const feature of features) for (const key of Object.keys(feature)) {
|
|
285
|
+
if (key === 'kind' || options.some(entry => entry.kind === feature.kind && entry.option === key)) continue;
|
|
286
|
+
const name = `${String(feature.kind)}.${key}`;
|
|
287
|
+
if (!unmeasuredOptions.includes(name)) unmeasuredOptions.push(name);
|
|
288
|
+
}
|
|
289
|
+
// Every binding rooted other than through an option row's own kind: an option binding found here is not the option's alone.
|
|
290
|
+
const own = new Set(options.filter(entry => entry.from === undefined).flatMap(entry => entry.bindings.map(key => `kind:${entry.kind}\0${key}`)));
|
|
291
|
+
const rootKeys = [...new Set([...page.roots, ...server.roots].flatMap(root => root.bindings.map(binding => `${root.module}#${binding}`).filter(key => !own.has(`${root.from}\0${key}`))))].sort();
|
|
292
|
+
return { slug: page.slug, roots: [...modules].sort(), rootKeys, unmeasured: server.unmeasured, held, options: setOptions.map(entry => `${entry.kind}.${entry.option}`), unmeasuredOptions: unmeasuredOptions.sort() };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** HR7: a binding only one product's option reaches is charged to that product, even in a shared module. Only rows
|
|
296
|
+
* without `from` charge bindings, and only when nothing else uses the binding: no product roots it through another
|
|
297
|
+
* kind or section, and no module the products reach imports its module and names it. A module only that product reaches
|
|
298
|
+
* is already charged whole, so it adds nothing here.
|
|
299
|
+
* @param {ReturnType<typeof measure>} modules @param {readonly { slug: string, options?: readonly string[], rootKeys?: readonly string[] }[]} products
|
|
300
|
+
* @param {ReturnType<typeof createTreeReader>} reader @param {typeof OPTIONS} [options] */
|
|
301
|
+
export function optionCharges(modules, products, reader, options = OPTIONS) {
|
|
302
|
+
const out = [];
|
|
303
|
+
for (const entry of options) {
|
|
304
|
+
if (entry.from !== undefined) continue;
|
|
305
|
+
const setters = products.filter(product => product.options?.includes(`${entry.kind}.${entry.option}`)).map(product => product.slug);
|
|
306
|
+
if (setters.length !== 1) continue;
|
|
307
|
+
for (const key of entry.bindings) {
|
|
308
|
+
const [module = '', binding = ''] = key.split('#'), use = modules.get(module);
|
|
309
|
+
if (use === undefined || use.users.length < 2 || products.some(product => product.rootKeys?.includes(key))) continue;
|
|
310
|
+
const importers = [...modules.keys()].filter(other => other !== module && other !== CLIENT_PLAN
|
|
311
|
+
&& (reader.read(other).imports.includes(module) || reader.read(other).dynamic.includes(module)));
|
|
312
|
+
if (importers.some(other => namesBinding(readFileSync(/** @type {string} */ (modulePath(other, reader.root)), 'utf8'), binding))) continue;
|
|
313
|
+
const lines = reader.read(module).declarations.filter(d => d.names.includes(binding)).reduce((sum, d) => sum + d.lines, 0);
|
|
314
|
+
out.push({ key, user: setters[0], option: `${entry.kind}.${entry.option}`, lines });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return out;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Per module, its code lines, layer and the users that reach it. The shell, when given, is a user only of the
|
|
321
|
+
* `control` modules it reaches (HR4).
|
|
322
|
+
* @param {readonly { slug: string, roots: Iterable<string>, held?: ReadonlySet<string> }[]} users @param {ReturnType<typeof createTreeReader>} reader
|
|
323
|
+
* @param {{ tables?: Readonly<Record<string, { static: boolean, dynamic: boolean }>>, shell?: { roots: Iterable<string>, control: readonly string[] } }} [options] */
|
|
324
|
+
export function measure(users, reader, options = {}) {
|
|
325
|
+
const tables = options.tables ?? TABLES;
|
|
326
|
+
/** @type {Map<string, { lines: number, layer: string, users: string[] }>} */
|
|
327
|
+
const modules = new Map();
|
|
328
|
+
for (const user of users) for (const module of reach(user.roots, reader, tables, user.held)) {
|
|
329
|
+
const row = modules.get(module) ?? { lines: reader.read(module).lines, layer: layerOf(module), users: [] };
|
|
330
|
+
if (!row.users.includes(user.slug)) row.users.push(user.slug);
|
|
331
|
+
modules.set(module, row);
|
|
332
|
+
}
|
|
333
|
+
if (options.shell !== undefined) {
|
|
334
|
+
const shell = reach(options.shell.roots, reader, tables);
|
|
335
|
+
for (const module of options.shell.control) if (shell.has(module)) modules.get(module)?.users.push(SHELL);
|
|
336
|
+
}
|
|
337
|
+
for (const row of modules.values()) row.users.sort();
|
|
338
|
+
return new Map([...modules].sort(([a], [b]) => a.localeCompare(b)));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Per product: the modules only it reaches, their lines, and how many of those lines are format modules.
|
|
342
|
+
* @param {ReturnType<typeof measure>} modules @param {readonly string[]} slugs */
|
|
343
|
+
export function oneUserLines(modules, slugs) {
|
|
344
|
+
const out = new Map(slugs.map(slug => [slug, { modules: 0, lines: 0, format: 0 }]));
|
|
345
|
+
for (const row of modules.values()) if (row.users.length === 1) {
|
|
346
|
+
const total = out.get(row.users[0]);
|
|
347
|
+
if (total === undefined) continue;
|
|
348
|
+
total.modules++;
|
|
349
|
+
total.lines += row.lines;
|
|
350
|
+
if (row.layer === 'format') total.format += row.lines;
|
|
351
|
+
}
|
|
352
|
+
return out;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** HR6's verdict on a span of one-user lines. `platform` and `pending` are credited (pending only until its recheck);
|
|
356
|
+
* the rest are charged to the user: `no-row` ("one-user host, no register row"), `charged-back` (pending or
|
|
357
|
+
* borderline past recheck) and `silly`. */
|
|
358
|
+
export const STATUSES = /** @type {const} */ (['platform', 'pending', 'no-row', 'charged-back', 'silly']);
|
|
359
|
+
const CREDITED = new Set(['platform', 'pending']);
|
|
360
|
+
const PLATFORM_VERDICTS = new Set(['engine', 'game']);
|
|
361
|
+
/** @param {{ verdict: string, recheck?: string } | undefined} row @param {string} today */
|
|
362
|
+
const statusOf = (row, today) => {
|
|
363
|
+
if (row === undefined) return 'no-row';
|
|
364
|
+
if (PLATFORM_VERDICTS.has(row.verdict)) return 'platform';
|
|
365
|
+
if (row.verdict === 'silly') return 'silly';
|
|
366
|
+
return row.recheck !== undefined && row.recheck >= today ? 'pending' : 'charged-back';
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
/** The platform rule (HA0 f) and the register's gates. A module with two or more real users (products, or the shell
|
|
370
|
+
* on a named control module) is platform. A one-user module is charged to its user unless a register row credits it: an
|
|
371
|
+
* `engine`/`game` row with a decision is platform; a `pending`/`borderline` row is credited until its `recheck` date and
|
|
372
|
+
* charged back after it; a `silly` row is charged. A `module#binding` row decides that binding's declaration lines,
|
|
373
|
+
* the module's own row (or none) the rest. A `silly` row on a shared module charges its lines to the row's users that
|
|
374
|
+
* reach it. A platform verdict without a decision id refuses. Report-only until Jake says otherwise.
|
|
375
|
+
* @param {ReturnType<typeof measure>} modules @param {ReturnType<typeof createTreeReader>} reader
|
|
376
|
+
* @param {readonly { key: string, verdict: string, decision?: string, users: readonly string[], recheck?: string }[]} rows
|
|
377
|
+
* @param {{ today: string }} options `today` as YYYY-MM-DD */
|
|
378
|
+
export function applyRegister(modules, reader, rows, options) {
|
|
379
|
+
/** @type {Map<string, typeof rows[number]>} */
|
|
380
|
+
const byModule = new Map();
|
|
381
|
+
/** @type {Map<string, Map<string, typeof rows[number]>>} */
|
|
382
|
+
const byBinding = new Map();
|
|
383
|
+
for (const row of rows) {
|
|
384
|
+
if (PLATFORM_VERDICTS.has(row.verdict) && !/^[GJ]\d+$/u.test(row.decision ?? '')) throw new Error(`host register: ${row.key} is ${row.verdict} (platform) without a decision id`);
|
|
385
|
+
const [module = '', binding] = row.key.split('#');
|
|
386
|
+
if (binding === undefined) byModule.set(module, row);
|
|
387
|
+
else byBinding.set(module, (byBinding.get(module) ?? new Map()).set(binding, row));
|
|
388
|
+
}
|
|
389
|
+
/** @type {Map<string, { module: string, user: string, lines: number, layer: string, spans: Record<string, number>, rows: string[] }>} */
|
|
390
|
+
const charged = new Map();
|
|
391
|
+
/** @type {{ module: string, users: string[], lines: number, key: string }[]} */
|
|
392
|
+
const sillyShared = [];
|
|
393
|
+
for (const [module, use] of modules) {
|
|
394
|
+
const bindings = byBinding.get(module) ?? new Map(), own = byModule.get(module);
|
|
395
|
+
if (use.users.length !== 1) {
|
|
396
|
+
for (const row of [own, ...bindings.values()]) if (row?.verdict === 'silly') {
|
|
397
|
+
const binding = row.key.split('#')[1];
|
|
398
|
+
const lines = binding === undefined ? use.lines : reader.read(module).declarations.filter(d => d.names.includes(binding)).reduce((sum, d) => sum + d.lines, 0);
|
|
399
|
+
sillyShared.push({ module, users: row.users.filter(user => use.users.includes(user)), lines, key: row.key });
|
|
400
|
+
}
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
/** @type {Record<string, number>} */
|
|
404
|
+
const spans = Object.fromEntries(STATUSES.map(status => [status, 0]));
|
|
405
|
+
let rest = use.lines;
|
|
406
|
+
if (bindings.size > 0) for (const declaration of reader.read(module).declarations) {
|
|
407
|
+
const row = declaration.names.map(name => bindings.get(name)).find(found => found !== undefined);
|
|
408
|
+
if (row === undefined) continue;
|
|
409
|
+
spans[statusOf(row, options.today)] += declaration.lines;
|
|
410
|
+
rest -= declaration.lines;
|
|
411
|
+
}
|
|
412
|
+
spans[statusOf(own, options.today)] += rest;
|
|
413
|
+
charged.set(module, { module, user: use.users[0], lines: use.lines, layer: use.layer, spans,
|
|
414
|
+
rows: [own, ...bindings.values()].filter(row => row !== undefined).map(row => row.key) });
|
|
415
|
+
}
|
|
416
|
+
return { modules: charged, sillyShared };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** Per product: one-user lines without register credit, and what the register credits or charges of them.
|
|
420
|
+
* @param {ReturnType<typeof applyRegister>} ruled @param {readonly string[]} slugs @param {readonly { user: string, lines: number }[]} [options] HR7 option charges */
|
|
421
|
+
export function shardTotals(ruled, slugs, options = []) {
|
|
422
|
+
const out = new Map(slugs.map(slug => [slug, { modules: 0, lines: 0, format: 0, ...Object.fromEntries(STATUSES.map(status => [status, 0])), option: 0, charged: 0 }]));
|
|
423
|
+
for (const row of options) {
|
|
424
|
+
const total = /** @type {Record<string, number> | undefined} */ (out.get(row.user));
|
|
425
|
+
if (total !== undefined) { total.option += row.lines; total.charged += row.lines; }
|
|
426
|
+
}
|
|
427
|
+
for (const row of ruled.modules.values()) {
|
|
428
|
+
const total = /** @type {Record<string, number> | undefined} */ (out.get(row.user));
|
|
429
|
+
if (total === undefined) continue;
|
|
430
|
+
total.modules++;
|
|
431
|
+
total.lines += row.lines;
|
|
432
|
+
if (row.layer === 'format') total.format += row.lines;
|
|
433
|
+
for (const status of STATUSES) {
|
|
434
|
+
total[status] += row.spans[status];
|
|
435
|
+
if (!CREDITED.has(status)) total.charged += row.spans[status];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
for (const row of ruled.sillyShared) for (const user of row.users) {
|
|
439
|
+
const total = /** @type {Record<string, number> | undefined} */ (out.get(user));
|
|
440
|
+
if (total !== undefined) { total.silly += row.lines; total.charged += row.lines; }
|
|
441
|
+
}
|
|
442
|
+
return out;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** Today in Cancún time (the register's recheck dates are Cancún days). */
|
|
446
|
+
const cancunToday = () => new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Cancun' }).format(new Date());
|
|
447
|
+
|
|
448
|
+
/** Measure built product dirs end to end, with the shell, the pinned format package and the host register.
|
|
449
|
+
* @param {readonly string[]} dirs @param {{ root?: string, today?: string, register?: readonly any[] }} [options] */
|
|
450
|
+
export function rule(dirs, options = {}) {
|
|
451
|
+
const root = options.root ?? ENGINE_ROOT, today = options.today ?? cancunToday();
|
|
452
|
+
const tables = { plan: clientPlanRoots(root), native: nativeAssemblyRoots({ root }) };
|
|
453
|
+
const products = dirs.map(dir => productRootModules(dir, tables));
|
|
454
|
+
const slugs = products.map(product => product.slug);
|
|
455
|
+
if (new Set(slugs).size !== slugs.length) throw new Error(`two products share a slug: ${slugs.join(', ')}`);
|
|
456
|
+
const reader = createTreeReader({ root });
|
|
457
|
+
const modules = measure(products, reader, { shell: { roots: SHELL_ROOTS, control: SHELL_CONTROL } });
|
|
458
|
+
const register = options.register ?? readHostRegister(root).rows;
|
|
459
|
+
const ruled = applyRegister(modules, reader, register, { today });
|
|
460
|
+
const charges = optionCharges(modules, products, reader);
|
|
461
|
+
return { products, format: reader.format.version, today, modules, ruled, options: charges, oneUser: oneUserLines(modules, slugs), totals: shardTotals(ruled, slugs, charges),
|
|
462
|
+
root, reader, tables, register };
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** Every `.ts` file under `dir` (relative to `base`), tests and declaration files left out.
|
|
466
|
+
* @param {string} base @param {string} dir @returns {string[]} */
|
|
467
|
+
function sourceFiles(base, dir) {
|
|
468
|
+
const full = join(base, dir);
|
|
469
|
+
if (!existsSync(full)) return [];
|
|
470
|
+
return readdirSync(full, { recursive: true, encoding: 'utf8' }).filter(path => /\.tsx?$/u.test(path) && !/\.(?:test|spec)\.tsx?$/u.test(path) && !path.endsWith('.d.ts'))
|
|
471
|
+
.map(path => join(dir, path)).sort();
|
|
472
|
+
}
|
|
473
|
+
/** HR8 (HA1): every module in engine `src/{client,shared,server,cook}/{engine,game,host,app}`, the pinned format
|
|
474
|
+
* package's published `src/format/`, and sharddev's `src/sharddev/` (the sdk: build-time, never a runtime host): its
|
|
475
|
+
* layer, lines, runtime users, register row and the entry table that names it.
|
|
476
|
+
* @param {ReturnType<typeof rule>} report @param {{ sharddev?: string }} [options] */
|
|
477
|
+
export function inventory(report, options = {}) {
|
|
478
|
+
const { root, reader, tables, register } = report;
|
|
479
|
+
/** @type {Map<string, Set<string>>} */
|
|
480
|
+
const entries = new Map();
|
|
481
|
+
const name = (/** @type {string} */ module, /** @type {string} */ entry) => entries.set(module, (entries.get(module) ?? new Set()).add(entry));
|
|
482
|
+
for (const [kind, rows] of tables.plan.kinds) for (const row of rows) name(row.module, `kind ${kind}`);
|
|
483
|
+
for (const row of tables.plan.shared) if (!row.typeOnly) name(row.module, CLIENT_PLAN_ROOT);
|
|
484
|
+
for (const [section, selectors] of Object.entries(SECTION_HOSTS)) for (const selector of selectors) {
|
|
485
|
+
if (selector === CLIENT_PLAN_ROOT) continue;
|
|
486
|
+
const module = selector.split('#')[0] ?? '';
|
|
487
|
+
name(module.startsWith(`${FORMAT}/`) ? resolveModule(module, CLIENT_PLAN, root) : module, `section ${section}`);
|
|
488
|
+
}
|
|
489
|
+
for (const [id, host] of tables.native.hosts) for (const row of host.roots) name(row.module, `native ${id}`);
|
|
490
|
+
for (const row of tables.native.shared) name(row.module, NATIVE_ASSEMBLY_ROOT);
|
|
491
|
+
/** @type {Map<string, string[]>} */
|
|
492
|
+
const rows = new Map();
|
|
493
|
+
for (const row of register) {
|
|
494
|
+
const [module = '', binding] = row.key.split('#');
|
|
495
|
+
rows.set(module, [...rows.get(module) ?? [], binding === undefined ? `${row.verdict} ${row.decision ?? ''}`.trim() : `#${binding} ${row.verdict}`]);
|
|
496
|
+
}
|
|
497
|
+
const registerOf = (/** @type {string} */ module) => {
|
|
498
|
+
const found = rows.get(module) ?? [];
|
|
499
|
+
const own = found.filter(row => !row.startsWith('#')), bindings = found.length - own.length;
|
|
500
|
+
return [...own, ...bindings > 0 ? [`${bindings} binding row${bindings === 1 ? '' : 's'}`] : []].join('; ') || '-';
|
|
501
|
+
};
|
|
502
|
+
const entryOf = (/** @type {string} */ module) => {
|
|
503
|
+
const found = [...entries.get(module) ?? []].sort();
|
|
504
|
+
return found.length === 0 ? 'none' : found.length > 3 ? `${found.slice(0, 3).join(', ')} +${found.length - 3}` : found.join(', ');
|
|
505
|
+
};
|
|
506
|
+
const out = [];
|
|
507
|
+
for (const side of ['client', 'shared', 'server', 'cook']) for (const layer of ['engine', 'game', 'host', 'app']) for (const module of sourceFiles(root, `src/${side}/${layer}`)) {
|
|
508
|
+
const use = report.modules.get(module);
|
|
509
|
+
out.push({ module, layer: `${side}/${layer}`, lines: use?.lines ?? codeLines(readFileSync(join(root, module), 'utf8'), module), users: use?.users ?? [], register: registerOf(module), entry: entryOf(module) });
|
|
510
|
+
}
|
|
511
|
+
for (const path of sourceFiles(reader.format.dir, 'src/format')) {
|
|
512
|
+
if (!reader.format.published(path)) continue;
|
|
513
|
+
const module = `${FORMAT}/${path}`, use = report.modules.get(module);
|
|
514
|
+
out.push({ module, layer: 'format', lines: use?.lines ?? codeLines(readFileSync(join(reader.format.dir, path), 'utf8'), path), users: use?.users ?? [], register: registerOf(module), entry: entryOf(module) });
|
|
515
|
+
}
|
|
516
|
+
if (options.sharddev !== undefined) for (const path of sourceFiles(options.sharddev, 'src/sharddev')) {
|
|
517
|
+
out.push({ module: `sharddev/${path}`, layer: 'sdk', lines: codeLines(readFileSync(join(options.sharddev, path), 'utf8'), path), users: ['build-time'], register: '-', entry: 'none' });
|
|
518
|
+
}
|
|
519
|
+
return out;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/** @param {ReturnType<typeof inventory>} rows */
|
|
523
|
+
export function formatInventory(rows) {
|
|
524
|
+
const users = (/** @type {readonly string[]} */ list) => list.length === 0 ? '-' : list.length > 4 ? `${list.length} users` : list.join(', ');
|
|
525
|
+
return ['| Module | Layer | Lines | Users | Register | Entry |', '|---|---|---:|---|---|---|',
|
|
526
|
+
...rows.map(row => `| \`${row.module}\` | ${row.layer} | ${row.lines} | ${users(row.users)} | ${row.register} | ${row.entry} |`)].join('\n');
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** @param {Pick<ReturnType<typeof rule>, 'format' | 'options' | 'products' | 'ruled' | 'today' | 'totals'>} report */
|
|
530
|
+
export function formatTable(report) {
|
|
531
|
+
const columns = /** @type {const} */ ([['modules', 'one-user modules'], ['lines', 'one-user lines'], ['format', 'of which format'], ['platform', 'credited'],
|
|
532
|
+
['pending', 'pending'], ['no-row', 'no row'], ['charged-back', 'charged back'], ['silly', 'silly'], ['option', 'option'], ['charged', 'charged']]);
|
|
533
|
+
const rows = [...report.totals].map(([slug, total]) => [slug].concat(columns.map(([key]) => String(/** @type {Record<string, number>} */ (total)[key]))));
|
|
534
|
+
const head = ['shard', ...columns.map(([, name]) => name)];
|
|
535
|
+
const width = head.map((h, i) => Math.max(h.length, ...rows.map(row => row[i].length)));
|
|
536
|
+
const line = (/** @type {string[]} */ cells) => `| ${cells.map((cell, i) => i === 0 ? cell.padEnd(width[i]) : cell.padStart(width[i])).join(' | ')} |`;
|
|
537
|
+
const noRow = [...report.ruled.modules.values()].filter(row => row.spans['no-row'] > 0)
|
|
538
|
+
.sort((a, b) => a.user.localeCompare(b.user) || a.module.localeCompare(b.module))
|
|
539
|
+
.map(row => `one-user host, no register row: ${row.user} ${row.module} (${row.spans['no-row']} lines)`);
|
|
540
|
+
const option = report.options.map(row => `option-charged: ${row.user} ${row.key} (${row.lines} lines, only it sets ${row.option})`);
|
|
541
|
+
const unmeasured = report.products.flatMap(p => p.unmeasured.map(u => `unmeasured: ${p.slug} host ${u.host}: ${u.reason}`));
|
|
542
|
+
/** @type {Map<string, string[]>} */
|
|
543
|
+
const byOption = new Map();
|
|
544
|
+
for (const product of report.products) for (const name of product.unmeasuredOptions) byOption.set(name, [...byOption.get(name) ?? [], product.slug]);
|
|
545
|
+
const options = [...byOption].sort(([a], [b]) => a.localeCompare(b)).map(([name, slugs]) => `unmeasured option: ${name} (${slugs.join(', ')})`);
|
|
546
|
+
// A silly row whose users no longer reach its module charges nobody: say so rather than drop the lines.
|
|
547
|
+
const orphans = report.ruled.sillyShared.filter(row => row.users.length === 0).map(row => `silly row, no current user: ${row.key} (${row.lines} lines)`);
|
|
548
|
+
return [`format package ${FORMAT} ${report.format}; register ${REGISTER}; today ${report.today}`,
|
|
549
|
+
'one-user lines without register credit: "one-user lines"; with it: "charged" (no row + charged back + silly + option)',
|
|
550
|
+
line(head), `|${width.map((w, i) => i === 0 ? '-'.repeat(w + 2) : `${'-'.repeat(w + 1)}:`).join('|')}|`, ...rows.map(line), ...noRow, ...option, ...orphans, ...unmeasured, ...options].join('\n');
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (process.argv[1] !== undefined && resolve(process.argv[1]) === import.meta.filename) {
|
|
554
|
+
const args = process.argv.slice(2), json = args.includes('--json'), sharddevAt = args.indexOf('--sharddev');
|
|
555
|
+
const at = args.indexOf('--products'), todayAt = args.indexOf('--today');
|
|
556
|
+
const dirs = at === -1 ? [] : args.slice(at + 1).filter((arg, i, all) => !arg.startsWith('--') && all.slice(0, i).every(prev => !prev.startsWith('--')));
|
|
557
|
+
if (todayAt !== -1 && !/^\d{4}-\d{2}-\d{2}$/u.test(args[todayAt + 1] ?? '')) { console.error('--today takes YYYY-MM-DD'); process.exit(2); }
|
|
558
|
+
if (dirs.length === 0) { console.error('usage: node scripts/host-ruler.mjs --products <product-dir>... [--today YYYY-MM-DD] [--json] [--inventory [--sharddev <dir>]]'); process.exit(2); }
|
|
559
|
+
const report = rule(dirs, todayAt === -1 ? {} : { today: args[todayAt + 1] });
|
|
560
|
+
if (json) console.log(JSON.stringify({ format: report.format, today: report.today, products: report.products, modules: Object.fromEntries(report.modules),
|
|
561
|
+
oneUser: Object.fromEntries(report.ruled.modules), sillyShared: report.ruled.sillyShared, options: report.options, totals: Object.fromEntries(report.totals) },
|
|
562
|
+
(key, value) => value instanceof Set ? [...value] : value, 2));
|
|
563
|
+
else console.log(formatTable(report));
|
|
564
|
+
if (args.includes('--inventory')) console.log(`\n${formatInventory(inventory(report, sharddevAt === -1 ? {} : { sharddev: args[sharddevAt + 1] }))}`);
|
|
565
|
+
}
|
package/scripts/live-prepush.py
CHANGED
|
@@ -53,7 +53,7 @@ class GateSteps:
|
|
|
53
53
|
row['reason'] = reason
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
CHECK_STEPS = ('
|
|
56
|
+
CHECK_STEPS = ('ratchet', 'deleted-paths', 'fast-lint', 'guards', 'recent-selection', 'recent-tests',
|
|
57
57
|
'related-selection', 'related-tests', 'importer-selection', 'typed-lint')
|
|
58
58
|
|
|
59
59
|
|
|
@@ -165,7 +165,6 @@ def check(root, base, tip, deadline, runner=run, files=None, tools=None, types_a
|
|
|
165
165
|
# explicit gate/CI handoff instead of losing the empty typed-file case.
|
|
166
166
|
if policy_checks:
|
|
167
167
|
for phase, command in [
|
|
168
|
-
('closed-components', ['node', str(tools / 'check-closed-components.mjs'), '--source-only']),
|
|
169
168
|
('ratchet', ['node', str(root / 'lint/ratchet.mjs'), '--defer-reductions']),
|
|
170
169
|
]:
|
|
171
170
|
rc, output = steps.run(phase, runner, command, root, deadline, env)
|
|
@@ -176,7 +175,7 @@ def check(root, base, tip, deadline, runner=run, files=None, tools=None, types_a
|
|
|
176
175
|
return result
|
|
177
176
|
result['output'] += '\nDeferred policy passed: ' + phase
|
|
178
177
|
else:
|
|
179
|
-
steps.skip(('
|
|
178
|
+
steps.skip(('ratchet',), 'not-requested')
|
|
180
179
|
# Mandatory cheap guards precede optional related tests, including when
|
|
181
180
|
# current generated declarations are unavailable. No app setup runs.
|
|
182
181
|
removed = Path(temporary) / 'deleted.json'
|
|
@@ -199,8 +198,7 @@ def check(root, base, tip, deadline, runner=run, files=None, tools=None, types_a
|
|
|
199
198
|
result.update(phase='fast-lint', output=output, files=failure_paths(output))
|
|
200
199
|
return result
|
|
201
200
|
result['output'] += '\nWhole-repo fast lint passed'
|
|
202
|
-
guards = ['test/host-callbacks.test.ts', 'test/shardfile-boundaries.test.ts',
|
|
203
|
-
'test/platform-chargebacks.test.ts', 'test/manifest-declarations.test.ts']
|
|
201
|
+
guards = ['test/host-callbacks.test.ts', 'test/shardfile-boundaries.test.ts', 'test/manifest-declarations.test.ts']
|
|
204
202
|
if any(name.startswith(('src/sdk/', 'src/sharddev/')) or name == 'pnpm-lock.yaml' for name in files):
|
|
205
203
|
guards.insert(0, 'test/schema-reference.test.ts')
|
|
206
204
|
rc, output = steps.run('guards', runner, ['pnpm', 'exec', 'vitest', 'run', '--config',
|
|
@@ -16,7 +16,7 @@ import { writeFileSync } from 'node:fs';
|
|
|
16
16
|
import { parseArgs } from 'node:util';
|
|
17
17
|
import { chromium, devices } from 'playwright';
|
|
18
18
|
import { KEYCHAIN_ARGS } from '../chromium-keychain.mjs';
|
|
19
|
-
import { developerSettings, saveFixture, levelDownloadFixtures, hideDeveloperOverlays } from '../debug-settings.mjs';
|
|
19
|
+
import { NAME_ASKED, developerSettings, saveFixture, levelDownloadFixtures, hideDeveloperOverlays } from '../debug-settings.mjs';
|
|
20
20
|
import { bootTimelineEntries, CLOCK_MARK_EXPRESSION, profileAnchor, profileIdle, stageStalls, STALL_IDLE_SHARE, STALL_WINDOW_MS } from './stalls.mjs';
|
|
21
21
|
|
|
22
22
|
const { values } = parseArgs({ options: { base: { type: 'string' }, shard: { type: 'string', default: 'Nine' }, throttle: { type: 'string', default: '4' },
|
|
@@ -35,6 +35,8 @@ try {
|
|
|
35
35
|
for (const fixture of levelDownloadFixtures('packs')) await saveFixture(context, fixture);
|
|
36
36
|
// a phone's first PLAY goes straight to Driftwood's first-play card (MOBILE-GRAPHICS MG5): this device has done it
|
|
37
37
|
await saveFixture(context, { scope: 'device', key: 'firstPlayDone', data: true });
|
|
38
|
+
// MP2.4: a page with a world asks for the Name before it joins; a bench never answers it, so it never reached control
|
|
39
|
+
await saveFixture(context, NAME_ASKED);
|
|
38
40
|
await context.addInitScript(hideDeveloperOverlays);
|
|
39
41
|
const page = await context.newPage();
|
|
40
42
|
page.setDefaultTimeout(240_000);
|