castle-web-cli 0.4.233 → 0.4.235
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/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +17 -2
- package/dist/castle-host/host.js +793 -36
- package/dist/castleJson.d.ts +20 -1
- package/dist/castleJson.js +44 -2
- package/dist/check.js +9 -2
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +3 -1
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- package/dist/index.js +8 -2
- package/dist/init.js +1 -1
- package/dist/save-deck.d.ts +20 -1
- package/dist/save-deck.js +141 -5
- package/dist/serve.js +29 -11
- package/dist/shell/assets/{index-BjOxR-lW.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/index.html +1 -1
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +266 -3
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +162 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +33 -6
- package/kits/base/sdk/hub.js +68 -5
- package/kits/base/sdk/hubRejoin.d.ts +4 -0
- package/kits/base/sdk/hubRejoin.js +15 -0
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +147 -40
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +79 -6
- package/kits/base/sdk/server/hub.d.ts +31 -1
- package/kits/base/sdk/server/hub.js +50 -3
- package/kits/base/sdk/server/platformHandle.d.ts +13 -1
- package/kits/base/sdk/server/storage.d.ts +4 -0
- package/kits/base/sdk/server/storage.js +19 -3
- package/kits/base/sdk/server/wrapper.d.ts +7 -1
- package/kits/base/sdk/server/wrapper.js +10 -1
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +123 -3
- package/kits/hub-game/README.md +63 -0
- package/kits/hub-game/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/avatar.js +4 -2
- package/kits/hub-game/code/client/avatarShare.js +2 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +15 -10
- package/kits/hub-game/code/client/build.js +16 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +1148 -258
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +10 -4
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -0
- package/kits/hub-game/code/client/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +31 -11
- package/kits/hub-game/code/client/hookLayer.js +87 -8
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +14 -2
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/labelsNear.js +31 -2
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- package/kits/hub-game/code/client/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +64 -10
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -0
- package/kits/hub-game/code/client/state.js +53 -0
- package/kits/hub-game/code/client/talk.js +209 -45
- package/kits/hub-game/code/client/tiers.js +68 -66
- package/kits/hub-game/code/client/together.js +7 -2
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +10 -9
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +6 -1
- package/kits/hub-game/code/server/actors.js +2 -1
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- package/kits/hub-game/code/server/companion.js +28 -3
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +22 -5
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendsAmong.js +49 -9
- package/kits/hub-game/code/server/history.js +2 -0
- package/kits/hub-game/code/server/hub.js +1306 -95
- package/kits/hub-game/code/server/idle.js +30 -1
- package/kits/hub-game/code/server/index.js +26 -4
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +9 -1
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +211 -3
- package/kits/hub-game/code/server/menu.js +31 -3
- package/kits/hub-game/code/server/npcs.js +226 -64
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/players.js +9 -1
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/standing.js +4 -5
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +67 -5
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +35 -1
- package/kits/hub-game/code/systems/hub.js +970 -169
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/contract.md +1259 -42
- package/kits/hub-game/docs/home-pieces.md +9 -2
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/package-lock.json +10 -3
- package/kits/hub-game/package.json +6 -3
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +39 -5
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -1
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +11 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +5 -5
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +3 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +19 -3
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +3 -3
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -1
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +367 -2
- package/kits/hub-game/scripts/test-actors.mjs +20 -7
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +49 -10
- package/kits/hub-game/scripts/test-avatar.mjs +44 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +11 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +20 -2
- package/kits/hub-game/scripts/test-chat.mjs +206 -5
- package/kits/hub-game/scripts/test-companion-chat.mjs +20 -2
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +45 -4
- package/kits/hub-game/scripts/test-decor.mjs +7 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned.mjs +33 -3
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +47 -4
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +321 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +879 -11
- package/kits/hub-game/scripts/test-hud-clear.mjs +162 -59
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +66 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +20 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-labels.mjs +71 -3
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +265 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +105 -0
- package/kits/hub-game/scripts/test-menu.mjs +23 -0
- package/kits/hub-game/scripts/test-npcs.mjs +917 -10
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +234 -7
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +699 -5
- package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +145 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +22 -17
- package/kits/hub-game/scripts/test-standing.mjs +35 -2
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +5 -4
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +86 -13
- package/kits/hub-game/scripts/test-tiers.mjs +7 -8
- package/kits/hub-game/scripts/test-vis.mjs +433 -6
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +50 -6
- package/kits/hub-game/scripts/test-yours.mjs +39 -8
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +369 -30
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +10 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +87 -5
- package/kits/physics-2d/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-3d/CLAUDE.md +25 -1651
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +35 -18
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +1 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -333
- package/kits/physics-3d/engine3d/actornode.js +1 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
- package/kits/physics-3d/engine3d/framecap.js +4 -1
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +8 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/look.js +7 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +3 -3
- package/kits/physics-3d/engine3d/nearshadows.js +77 -10
- package/kits/physics-3d/engine3d/orbitinput.js +59 -25
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +3 -3
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +23 -15
- package/kits/physics-3d/engine3d/sky.js +1 -1
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- package/kits/physics-3d/engine3d/world3d.js +468 -18
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +6 -3
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +52 -4
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +6 -3
- package/kits/physics-3d/scripts/test-frame-cap.mjs +1 -1
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1 -1
- package/kits/physics-3d/scripts/test-near-shadows.mjs +2 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +88 -7
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +40 -3
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +75 -1
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-sky.mjs +1 -1
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +3 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +5 -2
- package/kits/physics-3d/scripts/test-steady-hover.mjs +5 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/systems/physics3d.js +37 -4
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/session.js +6 -4
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// or told no after a place that asked. `npm run check` runs it.
|
|
7
7
|
|
|
8
8
|
import assert from 'node:assert/strict';
|
|
9
|
+
import { firstPromptSentence, promptShift, warnHudCopy } from '../code/client/hudCopy.js';
|
|
9
10
|
import {
|
|
10
11
|
BIG_MIN_PX,
|
|
11
12
|
BIG_PX,
|
|
@@ -257,11 +258,13 @@ function rig(view = PHONE) {
|
|
|
257
258
|
const dom = fakeDom(view);
|
|
258
259
|
const chrome = makeChrome({ onBack() {}, onAvatar() {}, avatarCount: 4 });
|
|
259
260
|
const root = dom.body.children[0];
|
|
260
|
-
const hud = root.children.find((c) => c.styles.
|
|
261
|
-
const [hudTitle, hudBig
|
|
261
|
+
const hud = root.children.find((c) => c.styles.textShadow?.includes('rgba(0,0,0,0.95)'));
|
|
262
|
+
const [hudTitle, hudBig] = hud.children;
|
|
263
|
+
const hudText = dom.made.find(node => node.dataset.hub === 'hud-prompt');
|
|
264
|
+
hudText.rect = { left: view.viewW * 0.2, right: view.viewW * 0.8, top: view.viewH - 80, bottom: view.viewH - 54, width: view.viewW * 0.6, height: 26 };
|
|
262
265
|
// v1.38: the pointers' layer is under the labels' (a speech bubble is read over a chip).
|
|
263
|
-
const pointers = root.children[root.children.indexOf(hud) +
|
|
264
|
-
const labels = root.children[root.children.indexOf(hud) +
|
|
266
|
+
const pointers = root.children[root.children.indexOf(hud) + 2];
|
|
267
|
+
const labels = root.children[root.children.indexOf(hud) + 3];
|
|
265
268
|
const cabinet = dom.made.find((c) => c.dataset.hub === 'cabinet');
|
|
266
269
|
return { ...dom, chrome, root, hud, hudTitle, hudBig, hudText, labels, pointers, cabinet };
|
|
267
270
|
}
|
|
@@ -297,7 +300,7 @@ test('v1.52: leaving toasts wrap a 120-character unbroken line and restore the o
|
|
|
297
300
|
r.chrome.setToast('Ordinary feedback');
|
|
298
301
|
const original = { ...toast.styles, display: 'none' };
|
|
299
302
|
assert.equal(toast.styles.width, 'max-content');
|
|
300
|
-
assert.equal(toast.styles.maxWidth, 'calc(100vw - 24px)');
|
|
303
|
+
assert.equal(toast.styles.maxWidth, view.viewW > view.viewH ? 'min(42vw, 420px)' : 'calc(100vw - 24px)');
|
|
301
304
|
assert.equal(toast.styles.textAlign, 'center');
|
|
302
305
|
r.log.length = 0;
|
|
303
306
|
r.chrome.setToast('Ordinary feedback');
|
|
@@ -363,11 +366,12 @@ const styleOf = (node) => Object.fromEntries(Object.entries(node.styles).filter(
|
|
|
363
366
|
const tree = (node) => ({ id: node.id, text: node.children.length ? undefined : node.textContent, style: styleOf(node), kids: node.children.map(tree) });
|
|
364
367
|
|
|
365
368
|
// The HUD as it is today, written here so a change to the default shows.
|
|
369
|
+
const COPY = { background: 'rgba(20,16,12,0.78)', borderRadius: '14px', padding: '4px 8px', boxSizing: 'border-box', width: 'max-content', maxWidth: '100%', margin: '0 auto', lineHeight: '1.3', whiteSpace: 'normal', overflowWrap: 'anywhere', overflow: 'hidden', display: 'block' };
|
|
366
370
|
const TODAY = {
|
|
367
371
|
hud: { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '50%', transform: 'translateX(-50%)', textAlign: 'center', textShadow: '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)', display: 'block', maxWidth: '70vw' },
|
|
368
|
-
title: { fontSize: '13px',
|
|
369
|
-
big: { fontSize: '56px', fontWeight: '800', lineHeight: '1.05', display: 'block' },
|
|
370
|
-
text: { fontSize: '14px', fontWeight: '500' },
|
|
372
|
+
title: { ...COPY, fontSize: '13px', maxHeight: '41.8px', letterSpacing: '0.06em', textTransform: 'uppercase' },
|
|
373
|
+
big: { background: 'rgba(20,16,12,0.78)', borderRadius: '14px', padding: '0 8px', boxSizing: 'border-box', width: 'max-content', maxWidth: '100%', margin: '4px auto 0', overflowWrap: 'anywhere', fontSize: '56px', fontWeight: '800', lineHeight: '1.05', display: 'block' },
|
|
374
|
+
text: { ...COPY, position: 'absolute', left: 'max(16px, env(safe-area-inset-left))', right: 'max(16px, env(safe-area-inset-right))', bottom: 'max(54px, calc(env(safe-area-inset-bottom) + 48px))', fontSize: '14px', overflow: 'visible', maxWidth: 'min(60vw, 560px, calc(100vw - max(16px, env(safe-area-inset-left)) - max(16px, env(safe-area-inset-right))))', fontWeight: '500', textAlign: 'center', zIndex: '2' },
|
|
371
375
|
};
|
|
372
376
|
|
|
373
377
|
test('never told: the HUD, labels and pointers are styled and placed as today', () => {
|
|
@@ -385,8 +389,8 @@ test('never told: the HUD, labels and pointers are styled and placed as today',
|
|
|
385
389
|
assert.deepEqual(top, { 'Start here': '90px', 'Take the lantern to the well.': '60px', IT: '80px', Well: '400px', '👋': '138px' });
|
|
386
390
|
assert.deepEqual(r.pointers.children.map((c) => c.styles.top), ['84px', '95px', '500px']);
|
|
387
391
|
// Nothing of a clear HUD was written anywhere.
|
|
388
|
-
for (const node of [r.hud, r.hudBig
|
|
389
|
-
assert.ok(!r.log.some((line) => line.startsWith(`${node.id} `) && /overflow
|
|
392
|
+
for (const node of [r.hud, r.hudBig]) {
|
|
393
|
+
assert.ok(!r.log.some((line) => line.startsWith(`${node.id} `) && /overflow=|maxHeight|webkit|textOverflow|whiteSpace/.test(line)), node.id);
|
|
390
394
|
}
|
|
391
395
|
});
|
|
392
396
|
|
|
@@ -424,7 +428,7 @@ test('asked: a big line over text is 32 px on one line; alone it is 56 px again'
|
|
|
424
428
|
assert.equal(r.hudBig.styles.fontSize, '56px');
|
|
425
429
|
assert.equal(r.hudBig.styles.whiteSpace, '');
|
|
426
430
|
assert.equal(r.hudBig.styles.overflow, '');
|
|
427
|
-
assert.equal(r.hudBig.styles.maxWidth, '');
|
|
431
|
+
assert.equal(r.hudBig.styles.maxWidth, '100%');
|
|
428
432
|
// The drawn line is wider than its box: shrunk again by what was measured.
|
|
429
433
|
r.hudBig.client = 252;
|
|
430
434
|
r.hudBig.scroll = 336;
|
|
@@ -450,24 +454,25 @@ test('asked, a phone on its side: two lines of text and a box no taller than its
|
|
|
450
454
|
r.chrome.setHudClear(true);
|
|
451
455
|
r.chrome.setHud(SPEC, null);
|
|
452
456
|
assert.equal(r.hudBig.styles.fontSize, '28px');
|
|
453
|
-
assert.equal(r.hudText.styles.display, '
|
|
454
|
-
assert.equal(r.hudText.styles.webkitLineClamp, '
|
|
455
|
-
assert.equal(r.hudText.styles.webkitBoxOrient, '
|
|
456
|
-
assert.equal(r.hudText.styles.overflow, '
|
|
457
|
+
assert.equal(r.hudText.styles.display, 'block');
|
|
458
|
+
assert.equal(r.hudText.styles.webkitLineClamp ?? '', '');
|
|
459
|
+
assert.equal(r.hudText.styles.webkitBoxOrient ?? '', '');
|
|
460
|
+
assert.equal(r.hudText.styles.overflow, 'visible');
|
|
457
461
|
assert.equal(r.hud.styles.maxHeight, '144px');
|
|
458
462
|
assert.equal(r.hud.styles.overflow, 'hidden');
|
|
459
463
|
});
|
|
460
464
|
|
|
461
|
-
test('emote bubbles: sizes are read
|
|
465
|
+
test('emote bubbles: sizes are read each frame before its writes', () => {
|
|
462
466
|
const r = rig();
|
|
463
467
|
const heads = Array.from({ length: 30 }, (_, i) => ({ id: `e${i}`, x: 0, y: 0, text: i % 2 ? '👋' : '💃', emote: true, head: { left: 20 + i * 10, right: 50 + i * 10, top: 400, bottom: 430 }, lift: 0 }));
|
|
464
468
|
r.chrome.setLabels(heads);
|
|
465
469
|
const reads = (from) => r.log.slice(from).filter((line) => line.endsWith(' read'));
|
|
466
|
-
assert.equal(reads(0).length, 4, 'two emoji, each read once (width and height)');
|
|
467
470
|
for (let frame = 0; frame < 3; frame += 1) {
|
|
471
|
+
r.chrome.beginLayoutFrame();
|
|
468
472
|
const from = r.log.length;
|
|
469
473
|
r.chrome.setLabels(heads.map((h) => ({ ...h, head: { ...h.head, top: h.head.top + frame } })));
|
|
470
|
-
assert.deepEqual(reads(from), [], 'no read
|
|
474
|
+
assert.deepEqual(reads(from), [], 'no geometry read after the read phase');
|
|
475
|
+
r.chrome.endLayoutFrame();
|
|
471
476
|
}
|
|
472
477
|
});
|
|
473
478
|
|
|
@@ -561,59 +566,43 @@ test('after a place that asked, a place that does not is drawn as never told', (
|
|
|
561
566
|
assert.equal(strip(tree(after.pointers)), strip(tree(never.pointers)));
|
|
562
567
|
assert.deepEqual(styleOf(after.hudBig), TODAY.big);
|
|
563
568
|
assert.deepEqual(styleOf(after.hudText), TODAY.text);
|
|
564
|
-
assert.deepEqual(styleOf(after.hud), TODAY.hud);
|
|
569
|
+
assert.deepEqual(styleOf(after.hud), view.viewW > view.viewH ? { ...TODAY.hud, maxWidth: 'min(42vw, 420px)' } : TODAY.hud);
|
|
565
570
|
// And after the one frame that put it back, nothing of it is written.
|
|
566
571
|
const putBack = after.log.slice(mark).filter((line) => /maxHeight|webkit|textOverflow/.test(line));
|
|
567
|
-
assert.equal(putBack.length,
|
|
572
|
+
assert.equal(putBack.length, 2, 'put back once, in the first frame');
|
|
568
573
|
}
|
|
569
574
|
});
|
|
570
575
|
|
|
571
|
-
test('asked: a
|
|
576
|
+
test('asked: a wrapping change refreshes the affected bubble once in the same frame', () => {
|
|
572
577
|
const r = rig();
|
|
573
578
|
r.hud.rect = { left: 90, right: 270, top: 12, bottom: 106 };
|
|
574
|
-
r.chrome.setHudClear(true);
|
|
575
|
-
r.chrome.setHud(SPEC, null);
|
|
576
|
-
// A player's chat bubble: its width is what is left of the view to its
|
|
577
|
-
// right, so nearer the right edge it is narrower and taller.
|
|
579
|
+
r.chrome.setHudClear(true); r.chrome.setHud(SPEC, null);
|
|
578
580
|
const bubble = (x) => [{ id: 'say:p2', x, y: 136, text: 'meet me by the well when the bell rings', speech: true, npc: false, opacity: 1 }];
|
|
579
|
-
|
|
580
|
-
r.chrome.setLabels(bubble(100));
|
|
581
|
-
r.chrome.flushHudClear?.();
|
|
581
|
+
r.chrome.setLabels(bubble(100)); r.chrome.flushHudClear();
|
|
582
582
|
const node = r.labels.children[0];
|
|
583
|
-
node.size = (self) =>
|
|
584
|
-
r.chrome.
|
|
585
|
-
r.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
r.
|
|
589
|
-
r.chrome.
|
|
590
|
-
assert.equal(node.styles.top, '170px', 'its top is 112 again');
|
|
591
|
-
// Standing still it is not measured every frame.
|
|
592
|
-
const before = reads;
|
|
583
|
+
node.size = (self) => parseFloat(self.styles.left) > 200 ? { w: 150, h: 58 } : { w: 220, h: 24 };
|
|
584
|
+
r.chrome.beginLayoutFrame();
|
|
585
|
+
const mark = r.log.length;
|
|
586
|
+
r.chrome.setLabels(bubble(210)); r.chrome.flushHudClear();
|
|
587
|
+
assert.equal(node.styles.top, '170px', 'this frame clears the current wrapped height');
|
|
588
|
+
assert.equal(r.log.slice(mark).filter((line) => line === `${node.id} read`).length, 2, 'only one fresh width/height measurement');
|
|
589
|
+
r.chrome.endLayoutFrame();
|
|
593
590
|
for (let i = 0; i < 10; i += 1) {
|
|
594
|
-
r.chrome.
|
|
595
|
-
r.
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
r.chrome.setLabels(sign(100));
|
|
601
|
-
r.chrome.flushHudClear?.();
|
|
602
|
-
let signReads = 0;
|
|
603
|
-
r.labels.children[0].size = () => ((signReads += 1), { w: 90, h: 24 });
|
|
604
|
-
for (let x = 100; x < 260; x += 10) {
|
|
605
|
-
r.chrome.setLabels(sign(x));
|
|
606
|
-
r.chrome.flushHudClear?.();
|
|
591
|
+
r.chrome.beginLayoutFrame();
|
|
592
|
+
const from = r.log.length;
|
|
593
|
+
r.chrome.setLabels(bubble(210)); r.chrome.flushHudClear();
|
|
594
|
+
assert.equal(node.styles.top, '170px', 'unchanged later frames retain the wrapped clearance');
|
|
595
|
+
assert(!r.log.slice(from).some((line) => line.endsWith(' read')));
|
|
596
|
+
r.chrome.endLayoutFrame();
|
|
607
597
|
}
|
|
608
|
-
assert.ok(signReads <= 2, `${signReads} reads`);
|
|
609
598
|
});
|
|
610
599
|
|
|
611
600
|
test('asked: a frame is all measured, then all moved -- no layout read after its first push, across pointers, labels, the card and the ribbon', () => {
|
|
612
601
|
const r = rig();
|
|
613
602
|
r.hud.rect = { left: 60, right: 300, top: 12, bottom: 106 };
|
|
614
603
|
// Four chat bubbles and two pointers drifting sideways under the HUD: each
|
|
615
|
-
// bubble
|
|
616
|
-
//
|
|
604
|
+
// bubble keeps its max-content size through movement, while each pointer's
|
|
605
|
+
// words change with its distance and need a new measurement.
|
|
617
606
|
const bubbles = (dx) => [0, 1, 2, 3].map((i) => ({ id: `say:p${i}`, x: 100 + i * 40 + dx, y: 60 + i * 10, text: `bubble ${i} has a few words in it`, speech: true, npc: false, opacity: 1 }));
|
|
618
607
|
const chips = (dx) => [0, 1].map((i) => ({ id: `to:p${i}`, x: 150 + i * 60 + dx, y: 90, text: `friend ${i} · ${20 + dx} m`, angle: null }));
|
|
619
608
|
const card = { id: 'cab', rev: 1, card: { title: 'Arcade', top: [{ username: 'bo', score: 12 }] }, x: 180, y: 90, opacity: 1 };
|
|
@@ -630,7 +619,16 @@ test('asked: a frame is all measured, then all moved -- no layout read after its
|
|
|
630
619
|
};
|
|
631
620
|
for (let dx = 0; dx < 8; dx += 1) {
|
|
632
621
|
const mark = r.log.length;
|
|
622
|
+
r.chrome.beginLayoutFrame();
|
|
633
623
|
frame(dx);
|
|
624
|
+
r.chrome.endLayoutFrame();
|
|
625
|
+
// Browser textContent includes descendant copy; this fixture normally
|
|
626
|
+
// keeps it on the child. Let pointer invalidation see its changing words.
|
|
627
|
+
if (dx === 0) {
|
|
628
|
+
for (const node of r.pointers.children) {
|
|
629
|
+
Object.defineProperty(node, 'textContent', { get: () => node.children.map((child) => child.textContent).join('') });
|
|
630
|
+
}
|
|
631
|
+
}
|
|
634
632
|
const lines = r.log.slice(mark);
|
|
635
633
|
// A push is the second write of `top` to a node in the frame.
|
|
636
634
|
const tops = new Set();
|
|
@@ -648,9 +646,10 @@ test('asked: a frame is all measured, then all moved -- no layout read after its
|
|
|
648
646
|
assert.ok(firstPush > 0, 'something was pushed');
|
|
649
647
|
const before = lines.slice(0, firstPush);
|
|
650
648
|
const after = lines.slice(firstPush);
|
|
651
|
-
//
|
|
649
|
+
// Changed pointers are sampled before pushes; unchanged max-content
|
|
650
|
+
// bubbles can reuse their persistent first-use measurements.
|
|
652
651
|
const measured = new Set(before.filter((line) => line.endsWith(' read')).map((line) => line.split(' ')[0]));
|
|
653
|
-
for (const node of [...r.labels.children, ...r.pointers.children]) {
|
|
652
|
+
for (const node of [...(dx === 0 ? r.labels.children : []), ...r.pointers.children]) {
|
|
654
653
|
assert.ok(measured.has(node.id), `${node.id} was measured`);
|
|
655
654
|
}
|
|
656
655
|
assert.ok(!after.some((line) => line.endsWith(' read')), `frame ${dx}: no read after the first push`);
|
|
@@ -675,11 +674,13 @@ test('never asked: the end of a frame reads and writes nothing', () => {
|
|
|
675
674
|
assert.equal(r.log.length, mark);
|
|
676
675
|
// Nor after a place that asked has been left.
|
|
677
676
|
frames(r, () => true, [SPEC]);
|
|
677
|
+
r.chrome.beginLayoutFrame();
|
|
678
678
|
r.chrome.setHudClear(false);
|
|
679
679
|
r.chrome.setLabels(LABELS);
|
|
680
680
|
const quiet = r.log.length;
|
|
681
681
|
r.chrome.flushHudClear();
|
|
682
682
|
assert.equal(r.log.length, quiet);
|
|
683
|
+
r.chrome.endLayoutFrame();
|
|
683
684
|
});
|
|
684
685
|
|
|
685
686
|
test('pushBelow: nothing is pushed off the bottom of the view', () => {
|
|
@@ -728,14 +729,15 @@ test('asked, then not, with no HUD drawn: put back at once, and written to as ne
|
|
|
728
729
|
assert.notDeepEqual(styleOf(after.hudBig), TODAY.big);
|
|
729
730
|
// The place is left for one with no HUD: the option goes, then no HUD.
|
|
730
731
|
after.chrome.setHudClear(false);
|
|
731
|
-
|
|
732
|
+
const hudToday = view.viewW > view.viewH ? { ...TODAY.hud, maxWidth: 'min(42vw, 420px)' } : TODAY.hud;
|
|
733
|
+
for (const [node, today] of [[after.hud, hudToday], [after.hudTitle, TODAY.title], [after.hudBig, TODAY.big], [after.hudText, TODAY.text]]) {
|
|
732
734
|
assert.deepEqual(styleOf(node), today, 'put back before any HUD is drawn');
|
|
733
735
|
}
|
|
734
736
|
const mark = after.log.length;
|
|
735
737
|
after.chrome.setHud(null, null);
|
|
736
|
-
assert.deepEqual(styleOf(after.hud), { ...
|
|
738
|
+
assert.deepEqual(styleOf(after.hud), { ...hudToday, display: 'none' });
|
|
737
739
|
assert.deepEqual(styleOf(after.hudBig), TODAY.big);
|
|
738
|
-
assert.deepEqual(styleOf(after.hudText), TODAY.text);
|
|
740
|
+
assert.deepEqual(styleOf(after.hudText), { ...TODAY.text, display: 'none' });
|
|
739
741
|
after.log.length = mark;
|
|
740
742
|
// From then on: the same writes, in the same order, as a client never told.
|
|
741
743
|
frames(after, () => undefined, later);
|
|
@@ -885,6 +887,35 @@ test('asked, then not, with no HUD drawn: put back at once, and written to as ne
|
|
|
885
887
|
// ...and their own next line does.
|
|
886
888
|
add('me', 30);
|
|
887
889
|
assert.equal(logNode.scrollTop, logNode.scrollHeight);
|
|
890
|
+
// During a hub frame even the scroll metrics come from the read phase.
|
|
891
|
+
// Model the browser's clamping setter while appending another own line.
|
|
892
|
+
let height = logNode.scrollHeight, top = height - 100, reads = 0;
|
|
893
|
+
Object.defineProperties(logNode, {
|
|
894
|
+
scrollHeight: { get() {reads += 1; return height;} },
|
|
895
|
+
clientHeight: { get() {reads += 1; return 100;} },
|
|
896
|
+
scrollTop: { get() {reads += 1; return top;}, set(value) {top = Math.min(height - 100, value);} },
|
|
897
|
+
});
|
|
898
|
+
r.chrome.beginLayoutFrame();
|
|
899
|
+
const before = reads, append = logNode.appendChild;
|
|
900
|
+
logNode.appendChild = (child) => {height += 30; return append.call(logNode, child);};
|
|
901
|
+
r.chrome.talkLine('me', 'another line');
|
|
902
|
+
assert.equal(reads, before, 'appending does not reread scroll layout after writes');
|
|
903
|
+
assert.equal(top, height - 100, 'an own line still scrolls to the live end');
|
|
904
|
+
r.chrome.talkAsks(['Next'], () => {});
|
|
905
|
+
assert.equal(reads, before, 'following the line when chips arrive reuses the scroll snapshot');
|
|
906
|
+
const followed = top;
|
|
907
|
+
r.chrome.endLayoutFrame();
|
|
908
|
+
r.chrome.beginLayoutFrame();
|
|
909
|
+
const beforeFollow = reads;
|
|
910
|
+
r.chrome.talkAsks(['Next again'], () => {});
|
|
911
|
+
assert.equal(reads, beforeFollow, 'a later frame follows without live scroll reads');
|
|
912
|
+
assert.equal(top, followed, 'browser-clamped scroll retains the followed line');
|
|
913
|
+
r.chrome.endLayoutFrame();
|
|
914
|
+
top = 10;
|
|
915
|
+
r.chrome.beginLayoutFrame();
|
|
916
|
+
r.chrome.talkAsks(['After scrolling back'], () => {});
|
|
917
|
+
assert.equal(top, 10, 'chips preserve a player scroll after an in-frame append');
|
|
918
|
+
r.chrome.endLayoutFrame();
|
|
888
919
|
n += 1;
|
|
889
920
|
}
|
|
890
921
|
|
|
@@ -997,4 +1028,76 @@ test('a new distance alone rewrites the chip\'s words: the same node, nothing el
|
|
|
997
1028
|
assert.equal(r.log.some((line) => / text=/.test(line)), false);
|
|
998
1029
|
});
|
|
999
1030
|
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
// Dev overflow diagnostics use browser-measured wrapping, not character counts.
|
|
1034
|
+
test('two lines fit at 844x390; a third warns once and is rechecked on resize', () => {
|
|
1035
|
+
const previous = { window: globalThis.window, getComputedStyle: globalThis.getComputedStyle, warn: console.warn };
|
|
1036
|
+
const warnings = [];
|
|
1037
|
+
let reads = 0;
|
|
1038
|
+
globalThis.window = { innerWidth: 844, innerHeight: 390 };
|
|
1039
|
+
globalThis.getComputedStyle = () => { reads += 1; return { lineHeight: '18.2px', paddingTop: '4px', paddingBottom: '4px' }; };
|
|
1040
|
+
console.warn = (...args) => warnings.push(args);
|
|
1041
|
+
try {
|
|
1042
|
+
const node = { textContent: 'Two lines of instructions', scrollHeight: 44, clientWidth: 354 };
|
|
1043
|
+
warnHudCopy(node, 'instruction');
|
|
1044
|
+
assert.equal(warnings.length, 0);
|
|
1045
|
+
node.textContent = 'Three lines of instructions';
|
|
1046
|
+
node.scrollHeight = 63;
|
|
1047
|
+
warnHudCopy(node, 'instruction');
|
|
1048
|
+
warnHudCopy(node, 'instruction');
|
|
1049
|
+
assert.equal(warnings.length, 1);
|
|
1050
|
+
assert.match(warnings[0][0], /instruction exceeds two lines at 844x390/);
|
|
1051
|
+
assert.equal(warnings[0][1], node.textContent);
|
|
1052
|
+
assert.equal(reads, 2, 'unchanged timer frames do not measure again');
|
|
1053
|
+
window.innerWidth = 1440; window.innerHeight = 900; node.scrollHeight = 26;
|
|
1054
|
+
warnHudCopy(node, 'instruction');
|
|
1055
|
+
assert.equal(warnings.length, 1, 'desktop copy fits');
|
|
1056
|
+
window.innerWidth = 844; window.innerHeight = 390; node.scrollHeight = 63;
|
|
1057
|
+
warnHudCopy(node, 'instruction');
|
|
1058
|
+
assert.equal(warnings.length, 2, 'returning to landscape checks again');
|
|
1059
|
+
node.clientWidth = 250;
|
|
1060
|
+
warnHudCopy(node, 'instruction');
|
|
1061
|
+
assert.equal(warnings.length, 3, 'safe layout narrowing at the same viewport checks again');
|
|
1062
|
+
warnHudCopy({ textContent: '', scrollHeight: 100 }, 'subtitle');
|
|
1063
|
+
assert.equal(warnings.length, 3, 'empty scrims are absent');
|
|
1064
|
+
} finally {
|
|
1065
|
+
globalThis.window = previous.window; globalThis.getComputedStyle = previous.getComputedStyle; console.warn = previous.warn;
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1069
|
+
test('prompt is separate from top HUD and uses only first sentence', () => {
|
|
1070
|
+
const r = rig({ viewW: 844, viewH: 390 });
|
|
1071
|
+
r.chrome.setHud({ title: 'Color Call', big: '4', text: 'Stand on plum. Stay until the floor returns.' }, null);
|
|
1072
|
+
assert.equal(r.hud.children.length, 2);
|
|
1073
|
+
assert.equal(r.hudText.parent, r.root);
|
|
1074
|
+
assert.equal(r.hudText.textContent, 'Stand on plum.');
|
|
1075
|
+
assert.equal(r.hudText.style.maxHeight, '');
|
|
1076
|
+
assert.equal(r.hudText.style.overflow, 'visible', 'legacy long first sentences remain readable until authors cut them');
|
|
1077
|
+
r.chrome.setDecorating(true);
|
|
1078
|
+
assert.equal(r.hudText.style.visibility, 'hidden');
|
|
1079
|
+
r.chrome.setDecorating(false);
|
|
1080
|
+
assert.equal(r.hudText.style.visibility, '');
|
|
1081
|
+
assert.ok(r.hudText.style.bottom.includes('safe-area-inset-bottom'));
|
|
1082
|
+
r.chrome.setHud(null, null);
|
|
1083
|
+
assert.equal(r.hudText.style.display, 'none');
|
|
1084
|
+
assert.equal(firstPromptSentence('Wait 1.5 seconds. Then jump!'), 'Wait 1.5 seconds.');
|
|
1085
|
+
assert.equal(firstPromptSentence('Move now! A story follows.'), 'Move now!');
|
|
1086
|
+
assert.equal(firstPromptSentence(' Walk to the gold gate '), 'Walk to the gold gate');
|
|
1087
|
+
assert.equal(firstPromptSentence(null), '');
|
|
1088
|
+
assert.equal(firstPromptSentence('Talk to Dr. Bloom. Then plant a seed.'), 'Talk to Dr. Bloom.');
|
|
1089
|
+
assert.equal(firstPromptSentence('The helper says "Go now!" Then wait.'), 'The helper says "Go now!"');
|
|
1090
|
+
});
|
|
1091
|
+
test('projected labels and pointers avoid the bottom pill without hud.clear', () => {
|
|
1092
|
+
const r = rig({ viewW: 844, viewH: 390 });
|
|
1093
|
+
r.chrome.setHud({ text: 'Stand on plum.' }, null);
|
|
1094
|
+
r.chrome.setLabels([{ id: 'near-prompt', x: 422, y: 330, text: 'Plum', speech: false, npc: false }]);
|
|
1095
|
+
r.chrome.setPointers([{ id: 'goal:plum', x: 422, y: 330, text: 'Plum', angle: null }]);
|
|
1096
|
+
r.chrome.flushHudClear();
|
|
1097
|
+
assert.equal(r.labels.children[0].style.top, '304px');
|
|
1098
|
+
assert.equal(r.pointers.children[0].style.top, '304px');
|
|
1099
|
+
assert.ok(r.chrome.padOccupancyControls().some(box => box.top === 310 && box.bottom === 336));
|
|
1100
|
+
assert.equal(promptShift({ left: 400, right: 450, top: 306, bottom: 330 }, r.hudText.rect), -26);
|
|
1101
|
+
assert.equal(promptShift({ left: 0, right: 50, top: 306, bottom: 330 }, r.hudText.rect), 0);
|
|
1102
|
+
});
|
|
1000
1103
|
console.log(`hub-game hud-clear: ${n} tests passed`);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Actual browser geometry at the two phone sizes used for the HUD defects.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { chromium } from 'playwright-core';
|
|
6
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
7
|
+
const root = new URL('../../../', import.meta.url);
|
|
8
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
9
|
+
try {
|
|
10
|
+
const page = await browser.newPage({ hasTouch: true });
|
|
11
|
+
await page.route('http://hud.test/**', async route => {
|
|
12
|
+
const pathname = new URL(route.request().url()).pathname;
|
|
13
|
+
if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: '<body style="margin:0"></body>' });
|
|
14
|
+
const url = new URL(`.${pathname}`, root);
|
|
15
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
16
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
17
|
+
});
|
|
18
|
+
for (const [width, height] of [[412, 870], [844, 390]]) {
|
|
19
|
+
await page.setViewportSize({ width, height });
|
|
20
|
+
await page.goto('http://hud.test/');
|
|
21
|
+
await logRenderer(page, 'HUD defects');
|
|
22
|
+
const result = await page.evaluate(async () => {
|
|
23
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
24
|
+
const { overlaps } = await import('/kits/hub-game/code/client/safeLayout.js');
|
|
25
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {} });
|
|
26
|
+
chrome.setWorldLabelFocus(false);
|
|
27
|
+
chrome.showPicker(true, 0, undefined, { onPick() {} });
|
|
28
|
+
chrome.setCompanionBadge(true, 'Chirp', () => {});
|
|
29
|
+
chrome.setDoors([{ id: 'color', title: 'Color Call' }]);
|
|
30
|
+
chrome.talkPrompt('Chirp', true);
|
|
31
|
+
const caption = document.createElement('div');
|
|
32
|
+
caption.textContent = 'Castle Town · 1 here · Explore the town and meet your neighbours';
|
|
33
|
+
Object.assign(caption.style, { position: 'absolute', left: '0', right: '0', bottom: '22px', textAlign: 'center', font: 'italic 15px/1.4 Georgia, serif' });
|
|
34
|
+
document.body.append(caption);
|
|
35
|
+
chrome.safeSurface('engine-look', caption, 'text');
|
|
36
|
+
const rect = n => n.getBoundingClientRect();
|
|
37
|
+
const visible = n => rect(n).width > 0 && getComputedStyle(n).visibility !== 'hidden';
|
|
38
|
+
const navigation = [...document.querySelectorAll('button')].filter(n => ['Doors', 'Character', 'Invite a friend', 'Chat with Chirp'].includes(n.textContent));
|
|
39
|
+
chrome.flushWorldLabels();
|
|
40
|
+
const captionHits = navigation.filter(visible).filter(n => overlaps(rect(n), rect(caption))).map(n => n.textContent);
|
|
41
|
+
const firstCaption = caption.style.translate;
|
|
42
|
+
chrome.flushWorldLabels();
|
|
43
|
+
const stableCaption = firstCaption === caption.style.translate;
|
|
44
|
+
// The rail itself is a world-layout obstacle without safeInsets enabled.
|
|
45
|
+
chrome.setActions([{ id: 'short', label: 'Short trip' }, { id: 'bay', label: 'Bay trip' }, { id: 'next', label: 'Next' }], () => {}, true, 1, true);
|
|
46
|
+
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
47
|
+
const rail = document.querySelector('[data-hub="action-rail"]');
|
|
48
|
+
const railBox = rect(rail);
|
|
49
|
+
chrome.beginWorldLabels();
|
|
50
|
+
chrome.setPointers([{ id: 'goal:house', x: railBox.left + railBox.width / 2, y: railBox.top + railBox.height / 2, text: 'your house · 80 m', angle: 0 }]);
|
|
51
|
+
chrome.flushWorldLabels();
|
|
52
|
+
const pointer = [...document.querySelectorAll('span')].find(n => n.textContent === 'your house · 80 m').parentElement;
|
|
53
|
+
const pointerVisible = visible(pointer);
|
|
54
|
+
const pointerHits = overlaps(rect(pointer), rect(rail));
|
|
55
|
+
const railHits = navigation.filter(visible).filter(n => overlaps(rect(n), rect(rail))).map(n => n.textContent);
|
|
56
|
+
chrome.setToast('Back from Color Call: win · 2 pts');
|
|
57
|
+
const toast = document.querySelector('[data-hub="toast"]');
|
|
58
|
+
chrome.setRibbon({ x: innerWidth / 2, y: rect(toast).bottom }, 'Color Call: win · 2 pts');
|
|
59
|
+
const ribbon = [...document.querySelectorAll('div')].find(n => n.textContent === 'Color Call: win · 2 pts');
|
|
60
|
+
const toastHits = overlaps(rect(toast), rect(ribbon));
|
|
61
|
+
chrome.clearActions();
|
|
62
|
+
chrome.beginWorldLabels(); chrome.flushWorldLabels();
|
|
63
|
+
const restored = visible(pointer);
|
|
64
|
+
// No full-width gap fits the caption: a bounded narrow slot must.
|
|
65
|
+
const blockers = [[0, 0, innerWidth, innerHeight * .5], [0, innerHeight * .52, innerWidth * .4, innerHeight * .42], [0, innerHeight - 24, innerWidth, 24]].map(([left, top, width, height], i) => {
|
|
66
|
+
const n = document.createElement('div');
|
|
67
|
+
Object.assign(n.style, { position: 'fixed', left: `${left}px`, top: `${top}px`, width: `${width}px`, height: `${height}px` });
|
|
68
|
+
document.body.append(n); chrome.safeSurface(`dense-${i}`, n, 'control'); return n;
|
|
69
|
+
});
|
|
70
|
+
chrome.beginWorldLabels(); chrome.flushWorldLabels();
|
|
71
|
+
const reflowBox = rect(caption);
|
|
72
|
+
const boundedReflow = reflowBox.top >= 8 && reflowBox.bottom <= innerHeight - 8 &&
|
|
73
|
+
reflowBox.left >= 8 && reflowBox.right <= innerWidth - 8 && !blockers.some(n => overlaps(rect(n), reflowBox));
|
|
74
|
+
blockers.forEach((n, i) => { chrome.safeSurface(`dense-${i}`, null); n.remove(); });
|
|
75
|
+
chrome.beginWorldLabels(); chrome.flushWorldLabels();
|
|
76
|
+
const reflowRestored = caption.style.width === '' && caption.style.right === '0px';
|
|
77
|
+
const sideWidth = (innerWidth - 196) / 2;
|
|
78
|
+
const sides = [0, sideWidth + 196].map((left, i) => {
|
|
79
|
+
const n = document.createElement('div');
|
|
80
|
+
Object.assign(n.style, { position: 'fixed', left: `${left}px`, top: '0', width: `${sideWidth}px`, height: '100vh' });
|
|
81
|
+
document.body.append(n); chrome.safeSurface(`side-${i}`, n, 'control'); return n;
|
|
82
|
+
});
|
|
83
|
+
chrome.beginWorldLabels(); chrome.flushWorldLabels();
|
|
84
|
+
const narrowBox = rect(caption);
|
|
85
|
+
const narrowLane = visible(caption) && narrowBox.width <= 180 && narrowBox.top >= 8 && narrowBox.bottom <= innerHeight - 8 && !sides.some(n => overlaps(rect(n), narrowBox));
|
|
86
|
+
sides.forEach((n, i) => { chrome.safeSurface(`side-${i}`, null); n.remove(); });
|
|
87
|
+
chrome.dispose(); caption.remove();
|
|
88
|
+
return { captionHits, stableCaption, pointerVisible, pointerHits, railHits, toastHits, restored, boundedReflow, reflowRestored, narrowLane };
|
|
89
|
+
});
|
|
90
|
+
assert.deepEqual(result.captionHits, [], 'caption clears navigation and Chirp');
|
|
91
|
+
assert(result.stableCaption, 'caption translation does not accumulate');
|
|
92
|
+
assert(result.pointerVisible && result.restored, 'guidance is visible and restores in the same frame');
|
|
93
|
+
assert.equal(result.pointerHits, false, 'guidance clears compact action rail');
|
|
94
|
+
assert.deepEqual(result.railHits, [], 'rail clears navigation and Chirp');
|
|
95
|
+
assert(result.narrowLane, 'caption fits a measured 180px lane');
|
|
96
|
+
assert(result.boundedReflow && result.reflowRestored, 'dense caption reflows in bounds and restores original width');
|
|
97
|
+
assert.equal(result.toastHits, false, 'return banner clears result ribbon');
|
|
98
|
+
console.log(`${width}x${height}: caption, guidance, rail and return banner passed`);
|
|
99
|
+
}
|
|
100
|
+
} finally { await browser.close(); }
|