castle-web-cli 0.4.239 → 0.4.241
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/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +163 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +6 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +2 -0
- package/dist/platformDoc.js +3 -2
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +1 -0
- package/dist/roomLogs.js +30 -6
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +481 -57
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/padCues.js +11 -7
- package/kits/hub-game/code/client/padReadability.js +3 -3
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +72 -51
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +205 -25
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +35 -3
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +991 -72
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +14 -2
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/standing.js +7 -3
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +429 -55
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +956 -101
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +79 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +421 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +242 -3
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-role-client.mjs +2 -1
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-standing.mjs +135 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +36 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +59 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -7,10 +7,20 @@
|
|
|
7
7
|
// A device is 'high' (the picture as authored) or 'low'. The low picture was
|
|
8
8
|
// chosen on real phones (a Galaxy Tab A7 Lite and a Redmi 9A, CPU-bound at 12
|
|
9
9
|
// fps in the town): no sun shadow, decorative actors not drawn, other scenery
|
|
10
|
-
// not drawn past 30 m and NPC bodies past 20 m.
|
|
11
|
-
//
|
|
12
|
-
// made Low visibly jagged, while shadows off alone took a TECNO
|
|
13
|
-
// 48.5 fps.
|
|
10
|
+
// not drawn past 30 m and NPC bodies past 20 m. Low does not simply lower the
|
|
11
|
+
// render resolution: a render scale of 1 on a 2x screen bought 2-9% on those
|
|
12
|
+
// phones and made Low visibly jagged, while shadows off alone took a TECNO
|
|
13
|
+
// from 32-35 to 48.5 fps. A fill-bound device is the other way round: an iPad
|
|
14
|
+
// 7th gen (A10) ran the town at 14 fps at pixel ratio 2 and 23 at 1, and
|
|
15
|
+
// shadows made no difference. So auto Low measures it (`scaleStep` in
|
|
16
|
+
// `makeTiers`): when a Low window is still slow, the renderer and composer
|
|
17
|
+
// drop to half their pixel ratio (never under 1) for one window, and the
|
|
18
|
+
// lower ratio stays only if that window's median is at least 20% faster;
|
|
19
|
+
// otherwise both are put back and the visit never tries again. The outcome is
|
|
20
|
+
// remembered beside the low mark, so the next visit within the week starts
|
|
21
|
+
// at the lower ratio, or never tries. A Low or High picked by hand, and a
|
|
22
|
+
// deck with the weakest tier (which has its own resolution rule), never get
|
|
23
|
+
// this step.
|
|
14
24
|
// "Not drawn" takes the actor's three.js node out of the scene graph, which
|
|
15
25
|
// saves the traversal and matrix work as well as the draw. Nothing here
|
|
16
26
|
// touches colliders, physics, the network, labels or anything another player
|
|
@@ -32,19 +42,21 @@
|
|
|
32
42
|
// existing underground visibility path alone.
|
|
33
43
|
//
|
|
34
44
|
// Where a device starts: low if it was found slow here in the last week
|
|
35
|
-
// (remembered
|
|
36
|
-
// otherwise high, and the frame times decide
|
|
37
|
-
// Low or High by hand (the Graphics row in
|
|
38
|
-
// over all of it.
|
|
45
|
+
// (remembered on the device: `deviceStorage.js`), or its GPU or memory says
|
|
46
|
+
// it is a weak phone; otherwise high, and the frame times decide
|
|
47
|
+
// (`makeJudge`). A player may pick Low or High by hand (the Graphics row in
|
|
48
|
+
// the Character card), which wins over all of it.
|
|
39
49
|
|
|
40
50
|
import { Box3, Sphere } from 'three';
|
|
41
51
|
import { classify } from '../shared/quality.js';
|
|
42
52
|
import { hub, deck } from './state.js';
|
|
53
|
+
import { deviceStorage, primeDeviceStorage } from './deviceStorage.js';
|
|
43
54
|
|
|
44
55
|
export const TIERS = ['low', 'high'];
|
|
45
56
|
export const MODES = ['auto', 'low', 'high'];
|
|
46
|
-
//
|
|
47
|
-
//
|
|
57
|
+
// Kept on the device (`deviceStorage.js`): the tier found here (`{ tier:
|
|
58
|
+
// 'low', at }`, with `scale: 'kept' | 'refused'` once Low's resolution step
|
|
59
|
+
// has been measured), and the mode the player picked.
|
|
48
60
|
export const TIER_KEY = 'castle.hub.tier';
|
|
49
61
|
export const MODE_KEY = 'castle.hub.graphics';
|
|
50
62
|
// A device found slow stays low this long, then is tried from high again.
|
|
@@ -64,6 +76,11 @@ export const GAP_MS = 1000;
|
|
|
64
76
|
export const SCENERY_NEAR_M = 30;
|
|
65
77
|
export const NPC_NEAR_M = 20;
|
|
66
78
|
export const CHECK_EVERY_MS = 500;
|
|
79
|
+
// Low's resolution step: the pixel ratio is multiplied by this (never under
|
|
80
|
+
// 1), and kept only when the trial window's median is at most KEEP_SCALE of
|
|
81
|
+
// the slow window before it.
|
|
82
|
+
export const SCALE_STEP = 0.5;
|
|
83
|
+
export const KEEP_SCALE = 0.8;
|
|
67
84
|
|
|
68
85
|
// GPUs of the phones the low picture is for, by the WebGL renderer string
|
|
69
86
|
// (`WEBGL_debug_renderer_info`): PowerVR Rogue GE8xxx, Mali-G52 MC1/MC2,
|
|
@@ -158,16 +175,14 @@ export function median(values) {
|
|
|
158
175
|
// is judged, so the odd long frame (a mesh built, a collection) does not
|
|
159
176
|
// decide. Returns 'low' once, when a window is slow; the judge then stops: a
|
|
160
177
|
// visit never moves back up.
|
|
161
|
-
export function makeJudge() {
|
|
162
|
-
const judge = { done: false, first
|
|
178
|
+
export function makeJudge({ first = true } = {}) {
|
|
179
|
+
const judge = { done: false, first, start: null, frames: [] };
|
|
163
180
|
judge.reset = () => {
|
|
164
181
|
judge.start = null;
|
|
165
182
|
judge.frames = [];
|
|
166
183
|
};
|
|
167
|
-
judge
|
|
168
|
-
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
184
|
+
// The window under the judge's rules: its median when one closes, else null.
|
|
185
|
+
judge.window = (dt, now, counts) => {
|
|
171
186
|
if (!counts || !(dt >= 0) || dt > GAP_MS) {
|
|
172
187
|
judge.reset();
|
|
173
188
|
return null;
|
|
@@ -181,10 +196,17 @@ export function makeJudge() {
|
|
|
181
196
|
if (now - judge.start < (judge.first ? FIRST_WINDOW_MS : WINDOW_MS)) {
|
|
182
197
|
return null;
|
|
183
198
|
}
|
|
184
|
-
const
|
|
199
|
+
const m = median(judge.frames);
|
|
185
200
|
judge.first = false;
|
|
186
201
|
judge.reset();
|
|
187
|
-
|
|
202
|
+
return m;
|
|
203
|
+
};
|
|
204
|
+
judge.feed = (dt, now, counts) => {
|
|
205
|
+
if (judge.done) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
const m = judge.window(dt, now, counts);
|
|
209
|
+
if (m !== null && m > SLOW_FRAME_MS) {
|
|
188
210
|
judge.done = true;
|
|
189
211
|
return 'low';
|
|
190
212
|
}
|
|
@@ -885,17 +907,182 @@ export function gpuOf(renderer) {
|
|
|
885
907
|
}
|
|
886
908
|
}
|
|
887
909
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
910
|
+
// The keys tiers keep, fetched before the first scene load where the device's
|
|
911
|
+
// storage has to fetch them (`qualityEntry.js`), and adopted by `makeTiers`
|
|
912
|
+
// whenever they arrive otherwise.
|
|
913
|
+
export const TIER_KEYS = [TIER_KEY, MODE_KEY];
|
|
914
|
+
export function primeTiers(options) {
|
|
915
|
+
return primeDeviceStorage(TIER_KEYS, options);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// The low mark stored here, if it is still within the week.
|
|
919
|
+
function rememberedLow(storage, now) {
|
|
920
|
+
const seen = readJson(storage, TIER_KEY);
|
|
921
|
+
return seen?.tier === 'low' && typeof seen.at === 'number' && now - seen.at >= 0 && now - seen.at < REMEMBER_MS ? seen : null;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// Auto Low's resolution step (see the top of this file). `frame(world, dt,
|
|
925
|
+
// now, counts, on)` each frame: `on` is whether the step may run (auto, Low,
|
|
926
|
+
// not a weakest-tier deck). States: 'none' (not run yet), 'baseline' (Low
|
|
927
|
+
// windows measured until one is slow), 'trial' (one window at the lower
|
|
928
|
+
// ratio), 'kept', 'refused' (put back; never tried again this visit), and
|
|
929
|
+
// 'settled' (nothing to step: already at 1, or a renderer or composer it
|
|
930
|
+
// cannot read). Off, or on another renderer, it puts back exactly what it
|
|
931
|
+
// set, and only where the renderer and composer still hold its value.
|
|
932
|
+
function makeScaleStep({ storage, clock }) {
|
|
933
|
+
const step = { state: 'none', baseline: null, trial: null, held: null, place: null, judge: makeJudge({ first: false }) };
|
|
934
|
+
|
|
935
|
+
const usable = (world) => {
|
|
936
|
+
const renderer = world?.renderer;
|
|
937
|
+
const composer = world?.composer;
|
|
938
|
+
try {
|
|
939
|
+
if (
|
|
940
|
+
typeof renderer?.getPixelRatio !== 'function' ||
|
|
941
|
+
typeof renderer.setPixelRatio !== 'function' ||
|
|
942
|
+
typeof composer?.setPixelRatio !== 'function' ||
|
|
943
|
+
!Number.isFinite(composer._pixelRatio)
|
|
944
|
+
) {
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
const ratio = renderer.getPixelRatio();
|
|
948
|
+
return Number.isFinite(ratio) && ratio > 0 ? { renderer, composer, ratio } : null;
|
|
949
|
+
} catch {
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// Halves the world's ratio; false when there is nothing to step.
|
|
955
|
+
const lower = (world) => {
|
|
956
|
+
const found = usable(world);
|
|
957
|
+
if (!found || found.ratio <= 1) {
|
|
958
|
+
return false;
|
|
959
|
+
}
|
|
960
|
+
const { renderer, composer, ratio } = found;
|
|
961
|
+
const cheap = Math.max(1, ratio * SCALE_STEP);
|
|
962
|
+
step.held = { renderer, composer, ratio, composerRatio: composer._pixelRatio, cheap };
|
|
963
|
+
try {
|
|
964
|
+
renderer.setPixelRatio(cheap);
|
|
965
|
+
composer.setPixelRatio(cheap);
|
|
966
|
+
} catch {
|
|
967
|
+
// A half-applied change is still put back by `restore`.
|
|
968
|
+
}
|
|
969
|
+
return true;
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
step.restore = () => {
|
|
973
|
+
const held = step.held;
|
|
974
|
+
step.held = null;
|
|
975
|
+
if (!held) {
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
try {
|
|
979
|
+
if (held.renderer.getPixelRatio() === held.cheap) {
|
|
980
|
+
held.renderer.setPixelRatio(held.ratio);
|
|
981
|
+
}
|
|
982
|
+
if (held.composer._pixelRatio === held.cheap) {
|
|
983
|
+
held.composer.setPixelRatio(held.composerRatio);
|
|
984
|
+
}
|
|
985
|
+
} catch {
|
|
986
|
+
// Nothing more can be done for a renderer that throws.
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
const remember = (scale) => {
|
|
991
|
+
const seen = rememberedLow(storage, clock());
|
|
992
|
+
writeJson(storage, TIER_KEY, { tier: 'low', at: seen ? seen.at : clock(), scale });
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
// A trial compares two windows of the same place on the same world; when
|
|
996
|
+
// either changes, or a frame stops counting (a trip, a scene swap, the page
|
|
997
|
+
// hidden), the trial is dropped and the step measures a baseline again.
|
|
998
|
+
const dropTrial = () => {
|
|
999
|
+
if (step.state === 'trial') {
|
|
1000
|
+
step.restore();
|
|
1001
|
+
step.state = 'baseline';
|
|
1002
|
+
step.baseline = null;
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
step.frame = (world, dt, now, counts, on, place = null) => {
|
|
1007
|
+
if (step.held && (step.held.renderer !== world.renderer || step.held.composer !== world.composer)) {
|
|
1008
|
+
// Another world: what was set belongs to the old one, and frames
|
|
1009
|
+
// measured there say nothing about this one.
|
|
1010
|
+
step.restore();
|
|
1011
|
+
step.judge.reset();
|
|
1012
|
+
dropTrial();
|
|
1013
|
+
}
|
|
1014
|
+
if (place !== step.place) {
|
|
1015
|
+
step.place = place;
|
|
1016
|
+
step.judge.reset();
|
|
1017
|
+
dropTrial();
|
|
1018
|
+
}
|
|
1019
|
+
if (!on) {
|
|
1020
|
+
step.restore();
|
|
1021
|
+
step.judge.reset();
|
|
1022
|
+
dropTrial();
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
if (!counts) {
|
|
1026
|
+
dropTrial();
|
|
1027
|
+
}
|
|
1028
|
+
if (step.state === 'none') {
|
|
1029
|
+
const scale = rememberedLow(storage, clock())?.scale;
|
|
1030
|
+
step.state = scale === 'kept' ? 'kept' : scale === 'refused' ? 'refused' : 'baseline';
|
|
1031
|
+
}
|
|
1032
|
+
if (step.state === 'kept') {
|
|
1033
|
+
if (!step.held && !lower(world)) {
|
|
1034
|
+
step.state = 'settled';
|
|
1035
|
+
}
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
if (step.state !== 'baseline' && step.state !== 'trial') {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
const m = step.judge.window(dt, now, counts);
|
|
1042
|
+
if (m === null) {
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
if (step.state === 'baseline') {
|
|
1046
|
+
if (m <= SLOW_FRAME_MS) {
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
if (!lower(world)) {
|
|
1050
|
+
step.state = 'settled';
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
step.baseline = m;
|
|
1054
|
+
step.state = 'trial';
|
|
1055
|
+
// The frame after a resize is a stall; the trial window starts after it.
|
|
1056
|
+
step.judge.reset();
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
step.trial = m;
|
|
1060
|
+
if (m <= KEEP_SCALE * step.baseline) {
|
|
1061
|
+
step.state = 'kept';
|
|
1062
|
+
remember('kept');
|
|
1063
|
+
} else {
|
|
1064
|
+
step.restore();
|
|
1065
|
+
step.state = 'refused';
|
|
1066
|
+
remember('refused');
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
// The low mark came from the device's storage after the step was started
|
|
1071
|
+
// without it: a step still only measuring its baseline reads it again on
|
|
1072
|
+
// its next frame. A trial under way is left to finish and write its own.
|
|
1073
|
+
step.adopt = () => {
|
|
1074
|
+
if (step.state === 'baseline') {
|
|
1075
|
+
step.state = 'none';
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
step.view = () => ({ state: step.state, ratio: step.held?.cheap ?? null, baseline: step.baseline, trial: step.trial });
|
|
1080
|
+
return step;
|
|
894
1081
|
}
|
|
895
1082
|
|
|
896
1083
|
// The hub system's tiers: `frame(scene, counts, now)` each frame. `counts` is
|
|
897
1084
|
// whether this frame says how the device draws the place (see `makeJudge`).
|
|
898
|
-
export function makeTiers({ storage =
|
|
1085
|
+
export function makeTiers({ storage = deviceStorage(), clock = () => Date.now(), deviceMemory = globalThis.navigator?.deviceMemory ?? null, lowMemory = false, onLayout, levers = makeLevers({ onLayout }), weakest = false } = {}) {
|
|
899
1086
|
const t = {
|
|
900
1087
|
mode: readMode(storage, weakest),
|
|
901
1088
|
auto: null,
|
|
@@ -904,6 +1091,7 @@ export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), d
|
|
|
904
1091
|
last: null,
|
|
905
1092
|
weakestDevice: false,
|
|
906
1093
|
middleDevice: false,
|
|
1094
|
+
scale: makeScaleStep({ storage, clock }),
|
|
907
1095
|
};
|
|
908
1096
|
|
|
909
1097
|
t.current = () => (t.mode === 'weakest' ? 'low' : t.mode === 'auto' ? (t.auto?.tier ?? 'high') : t.mode);
|
|
@@ -922,6 +1110,37 @@ export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), d
|
|
|
922
1110
|
return true;
|
|
923
1111
|
};
|
|
924
1112
|
|
|
1113
|
+
// A storage that fetches its values (`deviceStorage.js` in a frame without
|
|
1114
|
+
// localStorage) may hand them over after this was made and picked: the
|
|
1115
|
+
// player's mode is taken as stored, and a low mark from the last week moves
|
|
1116
|
+
// a device still on High by its hints to Low, as `initialTier` would have.
|
|
1117
|
+
// A pick or a slow window here since then wrote its own value, which the
|
|
1118
|
+
// storage keeps over the fetched one, so neither is undone. The chrome's
|
|
1119
|
+
// Graphics row follows `mode` (hub.js `deviceTier`).
|
|
1120
|
+
t.adopt = (adopted) => {
|
|
1121
|
+
const before = t.current();
|
|
1122
|
+
if (adopted.has(MODE_KEY)) {
|
|
1123
|
+
const mode = readMode(storage, weakest);
|
|
1124
|
+
if (mode !== t.mode) {
|
|
1125
|
+
t.mode = mode;
|
|
1126
|
+
t.judge.reset();
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
if (adopted.has(TIER_KEY)) {
|
|
1130
|
+
if (t.auto?.tier === 'high' && rememberedLow(storage, clock())) {
|
|
1131
|
+
t.auto = { tier: 'low', reason: 'remembered' };
|
|
1132
|
+
t.judge.reset();
|
|
1133
|
+
}
|
|
1134
|
+
t.scale.adopt();
|
|
1135
|
+
}
|
|
1136
|
+
// Low only now, after a scene may have loaded as High: the quality visit
|
|
1137
|
+
// takes out what that load would have skipped (quality.js `lowerLate`).
|
|
1138
|
+
if (before !== 'low' && t.current() === 'low') {
|
|
1139
|
+
t.lateLow = true;
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
storage?.prime?.(TIER_KEYS).then(t.adopt, () => {});
|
|
1143
|
+
|
|
925
1144
|
// Also used before load by the quality entry; frame timing still starts on frame one.
|
|
926
1145
|
t.pick = (renderer) => {
|
|
927
1146
|
// Hints are read once, from the renderer the place is drawn with.
|
|
@@ -943,8 +1162,8 @@ export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), d
|
|
|
943
1162
|
t.pick(world.renderer);
|
|
944
1163
|
const dt = t.last === null ? 0 : now - t.last;
|
|
945
1164
|
t.last = now;
|
|
1165
|
+
const hidden = globalThis.document?.hidden === true;
|
|
946
1166
|
if (t.mode === 'auto' && t.auto.tier === 'high') {
|
|
947
|
-
const hidden = globalThis.document?.hidden === true;
|
|
948
1167
|
if (t.judge.feed(dt, now, counts && !hidden) === 'low') {
|
|
949
1168
|
t.auto = { tier: 'low', reason: 'slow' };
|
|
950
1169
|
writeJson(storage, TIER_KEY, { tier: 'low', at: clock() });
|
|
@@ -954,6 +1173,7 @@ export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), d
|
|
|
954
1173
|
// for a later window.
|
|
955
1174
|
t.judge.reset();
|
|
956
1175
|
}
|
|
1176
|
+
t.scale.frame(world, dt, now, counts && !hidden, !weakest && t.mode === 'auto' && t.current() === 'low', scene.data ?? null);
|
|
957
1177
|
if (t.current() === 'low') {
|
|
958
1178
|
levers.apply(world, scene, now, { actors: !scene.content });
|
|
959
1179
|
} else {
|
|
@@ -989,10 +1209,15 @@ export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), d
|
|
|
989
1209
|
get cellHidden() {
|
|
990
1210
|
return levers.cellHidden ?? 0;
|
|
991
1211
|
},
|
|
1212
|
+
// Auto Low's resolution step: where it is, the ratio it set (null when
|
|
1213
|
+
// none), and the baseline and trial window medians in ms.
|
|
1214
|
+
get scale() {
|
|
1215
|
+
return t.scale.view();
|
|
1216
|
+
},
|
|
992
1217
|
cells: (on) => levers.setCells?.(on),
|
|
993
1218
|
set: (mode) => t.set(mode),
|
|
994
1219
|
};
|
|
995
|
-
//
|
|
1220
|
+
// Configured mode for local diagnostics; FPS telemetry includes it only on Low.
|
|
996
1221
|
if (deck.quality) {Object.defineProperty(t.handle, 'quality', { enumerable: true, get: () => deck.quality?.low.decor });}
|
|
997
1222
|
if (weakest) { Object.defineProperty(t.handle, 'profile', { enumerable: true, get: () => t.weakest() ? 'weakest' : t.middle() ? 'middle' : t.current() }); }
|
|
998
1223
|
return t;
|
|
@@ -309,8 +309,11 @@ export function makeTogether() {
|
|
|
309
309
|
}
|
|
310
310
|
// Anyone standing on or by a door can be gone to the way Doors > Go
|
|
311
311
|
// goes: to that door's pad, which is no more than the Doors list offers.
|
|
312
|
+
// Not a door that takes one player (`solo`): its pad sends each who
|
|
313
|
+
// stands there into a game of their own (the Town's House, their own
|
|
314
|
+
// House), never to the one they went to; Find still points the way.
|
|
312
315
|
const spot = town ? hub.whereAt[playerId] : null;
|
|
313
|
-
if (!t?.party && !t?.friend && spot?.door && hub.doors.some((d) => d.id === spot.door)) {
|
|
316
|
+
if (!t?.party && !t?.friend && spot?.door && hub.doors.some((d) => d.id === spot.door && d.solo !== true)) {
|
|
314
317
|
actions.push({ id: 'door', text: 'Go there' });
|
|
315
318
|
}
|
|
316
319
|
if (town && !t?.party) {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// that child to someone else). Children of the root are appended when made
|
|
19
19
|
// and never moved after, so the host may place them in its own stacking
|
|
20
20
|
// order.
|
|
21
|
-
import { BARE_TEXT_SHADOW, FONTS, SHADOWS, TEXT_SHADOWS, color, keyOf, readClock, segment } from './uiTree.js';
|
|
21
|
+
import { BARE_TEXT_SHADOW, FONTS, SHADOWS, TEXT_SHADOWS, color, keyOf, readClock, segment, sliderValue } from './uiTree.js';
|
|
22
22
|
|
|
23
23
|
const MAX_SCROLL = Number.MAX_SAFE_INTEGER;
|
|
24
24
|
const EDGE_KEYS = new Set(['top', 'right', 'bottom', 'left', 'transform']);
|
|
@@ -74,6 +74,17 @@ export function lenCss(value) {
|
|
|
74
74
|
return termCss(value);
|
|
75
75
|
}
|
|
76
76
|
const boxCss = (value) => (Array.isArray(value) ? value.map((n) => (typeof n === 'number' ? px(n) : n)).join(' ') : typeof value === 'number' ? px(value) : value);
|
|
77
|
+
// s.pad: the box sides, CSS order. v1.167: a side may be an edge value
|
|
78
|
+
// [min, add] = max(min, safe-area inset + add) on that side; a pad with one is
|
|
79
|
+
// written as four sides.
|
|
80
|
+
const PAD_SIDES = ['t', 'r', 'b', 'l'];
|
|
81
|
+
const fourSides = (list) => [list[0], list[1] ?? list[0], list[2] ?? list[0], list[3] ?? list[1] ?? list[0]];
|
|
82
|
+
function padCss(value) {
|
|
83
|
+
if (!Array.isArray(value) || !value.some(Array.isArray)) {return boxCss(value);}
|
|
84
|
+
return fourSides(value).map((side, i) => edgeCss(side, PAD_SIDES[i])).join(' ');
|
|
85
|
+
}
|
|
86
|
+
// A pad side's least length in px (an edge value's min).
|
|
87
|
+
const sideMin = (side) => (Array.isArray(side) ? Number(side[0]) || 0 : Number(side) || 0);
|
|
77
88
|
const ALIGN = { start: 'flex-start', end: 'flex-end', center: 'center', stretch: 'stretch', baseline: 'baseline' };
|
|
78
89
|
const JUSTIFY = { start: 'flex-start', end: 'flex-end', center: 'center', between: 'space-between' };
|
|
79
90
|
const TALIGN = { start: 'left', center: 'center', end: 'right' };
|
|
@@ -85,7 +96,7 @@ function colsCss(cols) {
|
|
|
85
96
|
return '';
|
|
86
97
|
}
|
|
87
98
|
const isSpanParent = (type) => type === 'row' || type === 'grid';
|
|
88
|
-
const tagFor = (node, parentType) => (node.t === 'button' ? 'button' : node.t === 'field' ? 'input' : node.t === 'image' ? 'img'
|
|
99
|
+
const tagFor = (node, parentType) => (node.t === 'button' ? 'button' : node.t === 'field' || node.t === 'slider' ? 'input' : node.t === 'image' ? 'img'
|
|
89
100
|
: node.t === 'text' && isSpanParent(parentType) && !node.at ? 'span' : 'div');
|
|
90
101
|
// A first child that is only words is drawn as its parent's own text, the way
|
|
91
102
|
// the chrome wrote `node.textContent` (a button's label, a talk line).
|
|
@@ -100,6 +111,8 @@ export function cssFor(node, parentType, inherited = {}) {
|
|
|
100
111
|
const css = {};
|
|
101
112
|
if (t === 'button' || t === 'field') {css.font = 'inherit';}
|
|
102
113
|
if (t === 'button') {Object.assign(css, { color: 'inherit', cursor: 'pointer', border: 'none', background: 'transparent', padding: '0' });}
|
|
114
|
+
// The sound card's range input, as chrome.js wrote it.
|
|
115
|
+
if (t === 'slider') {Object.assign(css, { margin: '0', accentColor: color(node.tint ?? 'gold'), cursor: node.disabled ? 'default' : 'pointer' });}
|
|
103
116
|
if (node.at) {
|
|
104
117
|
const at = node.at;
|
|
105
118
|
css.position = 'absolute';
|
|
@@ -137,7 +150,7 @@ export function cssFor(node, parentType, inherited = {}) {
|
|
|
137
150
|
else {css.alignSelf = ALIGN[s.self];}
|
|
138
151
|
}
|
|
139
152
|
if (s.mt && !css.margin) {css.marginTop = px(s.mt);}
|
|
140
|
-
if (s.pad !== undefined) {css.padding =
|
|
153
|
+
if (s.pad !== undefined) {css.padding = padCss(s.pad);}
|
|
141
154
|
if (s.gap !== undefined) {css.gap = px(s.gap);}
|
|
142
155
|
if (s.flex !== undefined) {css.flex = String(s.flex);}
|
|
143
156
|
if (s.basis === '100%') {Object.assign(css, { flexBasis: '100%', gridColumn: '1 / -1' });}
|
|
@@ -149,11 +162,12 @@ export function cssFor(node, parentType, inherited = {}) {
|
|
|
149
162
|
if (s.radius !== undefined) {css.borderRadius = boxCss(s.radius);}
|
|
150
163
|
if (s.border !== undefined) {css.border = s.border === 'none' || !s.border ? 'none' : `${s.border.w}px ${s.border.dash ? 'dashed' : 'solid'} ${color(s.border.c)}`;}
|
|
151
164
|
if (s.shadow) {css.boxShadow = SHADOWS[s.shadow] ?? s.shadow;}
|
|
165
|
+
if (Number.isFinite(s.aspect) && s.aspect > 0) {css.aspectRatio = String(s.aspect);}
|
|
152
166
|
if (s.opacity !== undefined) {css.opacity = String(s.opacity);}
|
|
153
167
|
if (s.gray) {css.filter = 'grayscale(1)';}
|
|
154
168
|
if (s.clip !== undefined) {css.overflow = s.clip ? 'hidden' : 'visible';}
|
|
155
169
|
if (s.hidden) {css.visibility = 'hidden';}
|
|
156
|
-
const hit = s.hit ?? (t === 'button' || t === 'field' ? 'auto' : undefined);
|
|
170
|
+
const hit = s.hit ?? (t === 'button' || t === 'field' || t === 'slider' ? 'auto' : undefined);
|
|
157
171
|
if (hit) {css.pointerEvents = hit;}
|
|
158
172
|
if (t === 'button' && (node.on?.press || node.on?.release)) {Object.assign(css, { touchAction: 'none', userSelect: 'none' });}
|
|
159
173
|
// Text.
|
|
@@ -178,7 +192,7 @@ export function cssFor(node, parentType, inherited = {}) {
|
|
|
178
192
|
// n lines of this size and line height, plus the padding: hard clipped.
|
|
179
193
|
const size = s.size ?? inherited.size ?? 15;
|
|
180
194
|
const lh = Number(s.lh ?? inherited.lh ?? 1.3) || 1.3;
|
|
181
|
-
const pad = Array.isArray(s.pad) ? (s.pad.length === 4 ? s.pad[0] + s.pad[2] : 2 * s.pad[0]) : 2 * (s.pad ?? 0);
|
|
195
|
+
const pad = Array.isArray(s.pad) ? (s.pad.length === 4 ? sideMin(s.pad[0]) + sideMin(s.pad[2]) : 2 * sideMin(s.pad[0])) : 2 * (s.pad ?? 0);
|
|
182
196
|
Object.assign(css, { maxHeight: px(Number((s.lines * size * lh + pad).toFixed(2))), overflow: 'hidden' });
|
|
183
197
|
} else if (s.lines > 1) {
|
|
184
198
|
Object.assign(css, { display: '-webkit-box', webkitLineClamp: String(s.lines), webkitBoxOrient: 'vertical', overflow: 'hidden' });
|
|
@@ -200,7 +214,9 @@ const defaultMeasure = {
|
|
|
200
214
|
// layout cache, so a rule reads the frame's snapshot like the rest of it).
|
|
201
215
|
// clockNow: the simulation time, in seconds, every `clock` is read at (its
|
|
202
216
|
// `t0` is in the same time); a clock's words move on each `tick()`.
|
|
203
|
-
|
|
217
|
+
// passKey(element, event): true lets a key event on a field go on to the page
|
|
218
|
+
// (the game) instead of stopping at the field; the host decides which.
|
|
219
|
+
export function mountUiTree(container, { slots = {}, created = () => {}, removed = () => {}, measure = defaultMeasure, clockNow = () => 0, passKey = () => false } = {}) {
|
|
204
220
|
const byPath = new Map();
|
|
205
221
|
// The records drawing a clock, ticked by `tick()`.
|
|
206
222
|
const clocks = new Set();
|
|
@@ -220,6 +236,8 @@ export function mountUiTree(container, { slots = {}, created = () => {}, removed
|
|
|
220
236
|
function drop(rec, path) {
|
|
221
237
|
for (const [key, kid] of rec.kids) {drop(kid, `${path}/${segment(key)}`);}
|
|
222
238
|
rec.kids.clear();
|
|
239
|
+
// A slider dropped mid-hold is never let go: its page listeners go too.
|
|
240
|
+
rec.unhold?.();
|
|
223
241
|
rec.el.remove();
|
|
224
242
|
clocks.delete(rec);
|
|
225
243
|
byPath.delete(path);
|
|
@@ -274,7 +292,9 @@ export function mountUiTree(container, { slots = {}, created = () => {}, removed
|
|
|
274
292
|
}
|
|
275
293
|
if (t === 'field') {
|
|
276
294
|
for (const type of ['keydown', 'keyup', 'keypress']) {
|
|
277
|
-
listen(rec, type, (event) =>
|
|
295
|
+
listen(rec, type, (event) => {
|
|
296
|
+
if (!passKey(rec.el, event)) {event.stopPropagation?.();}
|
|
297
|
+
});
|
|
278
298
|
}
|
|
279
299
|
if (rec.listening.has('input')) {return;}
|
|
280
300
|
rec.el.addEventListener('keydown', (event) => {
|
|
@@ -295,6 +315,49 @@ export function mountUiTree(container, { slots = {}, created = () => {}, removed
|
|
|
295
315
|
listen(rec, 'blur', () => fire(rec, 'blur', {}));
|
|
296
316
|
return;
|
|
297
317
|
}
|
|
318
|
+
if (t === 'slider') {
|
|
319
|
+
// Let go: once per hold, whether or not the value moved (a press that
|
|
320
|
+
// does not move it fires no `change`). The arrow keys are the
|
|
321
|
+
// avatar's again after.
|
|
322
|
+
const letGo = (byPointer) => {
|
|
323
|
+
rec.holding = false;
|
|
324
|
+
rec.pointerLetGo = byPointer;
|
|
325
|
+
fire(rec, 'release', { value: Number(rec.el.value) });
|
|
326
|
+
rec.el.blur?.();
|
|
327
|
+
};
|
|
328
|
+
// The scene under it never sees the drag. The hold ends wherever the
|
|
329
|
+
// pointer is let go, on the slider or off it.
|
|
330
|
+
listen(rec, 'pointerdown', (event) => {
|
|
331
|
+
event.stopPropagation?.();
|
|
332
|
+
if (rec.holding) {return;}
|
|
333
|
+
rec.holding = true;
|
|
334
|
+
rec.pointerLetGo = false;
|
|
335
|
+
const unhold = () => {
|
|
336
|
+
globalThis.removeEventListener?.('pointerup', end, true);
|
|
337
|
+
globalThis.removeEventListener?.('pointercancel', end, true);
|
|
338
|
+
rec.unhold = null;
|
|
339
|
+
rec.holding = false;
|
|
340
|
+
};
|
|
341
|
+
const end = () => {
|
|
342
|
+
const held = rec.holding;
|
|
343
|
+
unhold();
|
|
344
|
+
if (held) {letGo(true);}
|
|
345
|
+
};
|
|
346
|
+
rec.unhold = unhold;
|
|
347
|
+
globalThis.addEventListener?.('pointerup', end, true);
|
|
348
|
+
globalThis.addEventListener?.('pointercancel', end, true);
|
|
349
|
+
});
|
|
350
|
+
listen(rec, 'input', () => fire(rec, 'input', { value: Number(rec.el.value) }));
|
|
351
|
+
// A keyboard change is let go at once; a pointer's change (fired
|
|
352
|
+
// before or after its pointerup) is that pointerup's release.
|
|
353
|
+
listen(rec, 'keydown', () => {rec.pointerLetGo = false;});
|
|
354
|
+
listen(rec, 'change', () => {
|
|
355
|
+
if (rec.holding) {return;}
|
|
356
|
+
if (rec.pointerLetGo) {rec.pointerLetGo = false; return;}
|
|
357
|
+
letGo(false);
|
|
358
|
+
});
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
298
361
|
if (node.s?.hit === 'auto') {
|
|
299
362
|
listen(rec, 'pointerdown', (event) => event.stopPropagation?.());
|
|
300
363
|
}
|
|
@@ -392,6 +455,18 @@ export function mountUiTree(container, { slots = {}, created = () => {}, removed
|
|
|
392
455
|
rec.focus = focus;
|
|
393
456
|
}
|
|
394
457
|
|
|
458
|
+
function patchSlider(rec, node, fresh) {
|
|
459
|
+
const el = rec.el;
|
|
460
|
+
if (fresh) {el.type = 'range';}
|
|
461
|
+
const { min, max, step, value } = sliderValue(node);
|
|
462
|
+
const props = { min: String(min), max: String(max), step: step > 0 ? String(step) : 'any', disabled: Boolean(node.disabled) };
|
|
463
|
+
for (const [name, prop] of Object.entries(props)) {
|
|
464
|
+
if (rec.props[name] !== prop) {el[name] = prop; rec.props[name] = prop;}
|
|
465
|
+
}
|
|
466
|
+
// Not while the player drags it: the value is theirs then.
|
|
467
|
+
if (!rec.holding && document.activeElement !== el && Number(el.value) !== value) {el.value = String(value);}
|
|
468
|
+
}
|
|
469
|
+
|
|
395
470
|
function patchActivity(rec, node, fresh) {
|
|
396
471
|
if (!fresh) {return;}
|
|
397
472
|
ensureActivityStyle();
|
|
@@ -495,6 +570,8 @@ export function mountUiTree(container, { slots = {}, created = () => {}, removed
|
|
|
495
570
|
if (rec.el.disabled !== disabled) {rec.el.disabled = disabled;}
|
|
496
571
|
} else if (node.t === 'field') {
|
|
497
572
|
patchField(rec, node, fresh);
|
|
573
|
+
} else if (node.t === 'slider') {
|
|
574
|
+
patchSlider(rec, node, fresh);
|
|
498
575
|
} else if (node.t === 'activity') {
|
|
499
576
|
patchActivity(rec, node, fresh);
|
|
500
577
|
} else if (node.t === 'image') {
|
|
@@ -532,7 +609,8 @@ export function mountUiTree(container, { slots = {}, created = () => {}, removed
|
|
|
532
609
|
});
|
|
533
610
|
for (const [key, kid] of rec.kids) {
|
|
534
611
|
const child = wanted.get(key);
|
|
535
|
-
|
|
612
|
+
// A field and a slider are both inputs, of different types.
|
|
613
|
+
if (!child || kid.tag !== tagFor(child, node.t) || (kid.node.t === 'slider') !== (child.t === 'slider')) {
|
|
536
614
|
drop(kid, `${path}/${segment(key)}`);
|
|
537
615
|
rec.kids.delete(key);
|
|
538
616
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
// A node is { t, k?, s?, at?, on?, c?, ...type fields }:
|
|
9
9
|
// t the type: column row stack scroll grid text button field image icon
|
|
10
|
-
// activity spacer;
|
|
10
|
+
// activity spacer slider;
|
|
11
11
|
// k its key, unique among its siblings (default `#<index>`); the keys from
|
|
12
12
|
// the root down, joined with '/', are its path ('%' and '/' in a key are
|
|
13
13
|
// written %25 and %2F there, so a key 'a/b' is never the path of 'b'
|
|
@@ -40,14 +40,32 @@
|
|
|
40
40
|
// key appears and the viewer was at the end)
|
|
41
41
|
// and scroll.refollow (a counter: re-apply the
|
|
42
42
|
// last alignment if the viewer has not moved).
|
|
43
|
+
//
|
|
44
|
+
// v1.167, opt-in shapes (a tree without them is the same bytes):
|
|
45
|
+
// s.pad side [min, add] an edge value: max(min, the safe-area
|
|
46
|
+
// inset on that side + add); plain numbers
|
|
47
|
+
// stay the default (a bottom sheet's paint
|
|
48
|
+
// reaching under the home bar);
|
|
49
|
+
// s.aspect n width / height (a square menu tile is 1);
|
|
50
|
+
// s.shadow 'glow' 0 0 0 3px rgba(255,216,74,0.5) (a chosen
|
|
51
|
+
// ballot face).
|
|
52
|
+
//
|
|
53
|
+
// v1.198, the slider (a type no earlier tree has, so trees without one are
|
|
54
|
+
// the same bytes; an older native renderer drops it with its subtree):
|
|
55
|
+
// slider a leaf: value, min (0), max (1), step (0: continuous), disabled
|
|
56
|
+
// (false), tint (the track and thumb's colour, a token or a CSS
|
|
57
|
+
// colour; 'gold'). Its value is clamped to [min, max] (`sliderValue`).
|
|
58
|
+
// Events: 'input' { value } on each move while it is dragged,
|
|
59
|
+
// 'release' { value } when it is let go. While the player holds it,
|
|
60
|
+
// a renderer keeps the player's value, not a resent one.
|
|
43
61
|
|
|
44
|
-
export const TYPES = new Set(['column', 'row', 'stack', 'scroll', 'grid', 'text', 'button', 'field', 'image', 'icon', 'activity', 'spacer']);
|
|
62
|
+
export const TYPES = new Set(['column', 'row', 'stack', 'scroll', 'grid', 'text', 'button', 'field', 'image', 'icon', 'activity', 'spacer', 'slider']);
|
|
45
63
|
const CONTAINERS = new Set(['column', 'row', 'stack', 'scroll', 'grid', 'button']);
|
|
46
64
|
export const EVENTS = new Set(['tap', 'press', 'release', 'cancel', 'input', 'submit', 'focus', 'blur']);
|
|
47
65
|
|
|
48
66
|
// The closed style subset. Text keys inherit down the tree, as in CSS.
|
|
49
67
|
export const STYLE_KEYS = new Set([
|
|
50
|
-
'w', 'h', 'minW', 'minH', 'maxW', 'maxH', 'pad', 'mt', 'gap', 'flex', 'basis', 'align', 'justify', 'wrap', 'self', 'box',
|
|
68
|
+
'w', 'h', 'minW', 'minH', 'maxW', 'maxH', 'aspect', 'pad', 'mt', 'gap', 'flex', 'basis', 'align', 'justify', 'wrap', 'self', 'box',
|
|
51
69
|
'bg', 'radius', 'border', 'shadow', 'opacity', 'gray', 'clip', 'gone', 'hidden', 'hit',
|
|
52
70
|
'color', 'font', 'size', 'weight', 'lh', 'ls', 'italic', 'upper', 'tabular', 'talign', 'lines', 'ellipsis', 'tshadow', 'fit',
|
|
53
71
|
]);
|
|
@@ -62,8 +80,19 @@ const TYPE_FIELDS = {
|
|
|
62
80
|
image: ['src', 'fit'],
|
|
63
81
|
icon: ['name', 'tint'],
|
|
64
82
|
activity: ['kind'],
|
|
83
|
+
slider: ['value', 'min', 'max', 'step', 'disabled', 'tint'],
|
|
65
84
|
};
|
|
66
85
|
|
|
86
|
+
// A slider's range and value, defaults filled in: the value clamped to
|
|
87
|
+
// [min, max] (a missing or non-number value is min; max below min is min).
|
|
88
|
+
export function sliderValue(node) {
|
|
89
|
+
const num = (value, fallback) => (typeof value === 'number' && Number.isFinite(value) ? value : fallback);
|
|
90
|
+
const min = num(node?.min, 0);
|
|
91
|
+
const max = Math.max(min, num(node?.max, 1));
|
|
92
|
+
const step = Math.max(0, num(node?.step, 0));
|
|
93
|
+
return { min, max, step, value: Math.min(max, Math.max(min, num(node?.value, min))) };
|
|
94
|
+
}
|
|
95
|
+
|
|
67
96
|
// Theme tokens: today's literals, byte for byte (schema §4).
|
|
68
97
|
export const TOKENS = {
|
|
69
98
|
chip: 'rgba(20,16,12,0.72)',
|
|
@@ -93,7 +122,7 @@ export const TOKENS = {
|
|
|
93
122
|
// close around each letter as well as the soft drop shadow, so it reads over a
|
|
94
123
|
// pale sky as it does over a dark street.
|
|
95
124
|
export const BARE_TEXT_SHADOW = '0 0 2px rgba(0,0,0,0.95), 0 0 2px rgba(0,0,0,0.95), 0 1px 4px rgba(0,0,0,0.75), 0 0 10px rgba(0,0,0,0.45)';
|
|
96
|
-
export const SHADOWS = { card: '0 4px 14px rgba(0,0,0,0.45)', sheet: '0 -4px 18px rgba(0,0,0,0.45)', lift: '0 2px 6px rgba(0,0,0,0.4)', none: 'none' };
|
|
125
|
+
export const SHADOWS = { card: '0 4px 14px rgba(0,0,0,0.45)', sheet: '0 -4px 18px rgba(0,0,0,0.45)', lift: '0 2px 6px rgba(0,0,0,0.4)', glow: '0 0 0 3px rgba(255,216,74,0.5)', none: 'none' };
|
|
97
126
|
export const TEXT_SHADOWS = { outline: BARE_TEXT_SHADOW, soft: '0 2px 4px rgba(0,0,0,0.5)', none: 'none' };
|
|
98
127
|
export const FONTS = { ui: 'system-ui, sans-serif', mono: 'ui-monospace, monospace' };
|
|
99
128
|
|