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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensureActorModel } from './modelReady.js';
|
|
1
2
|
// Idle play (contract §6, v1.6), the client's half: the emote picker and Sit /
|
|
2
3
|
// Stand in the hub chrome, and drawing what the place says -- each player's
|
|
3
4
|
// emote and seated pose -- on their avatar. Only in a place whose manifest
|
|
@@ -12,6 +13,8 @@
|
|
|
12
13
|
|
|
13
14
|
import { Box3, Matrix4, Vector3 } from 'three';
|
|
14
15
|
import { hub, simNow } from './state.js';
|
|
16
|
+
import { allActors } from './quality.js';
|
|
17
|
+
import { danceIdlePose } from '../shared/danceIdle.js';
|
|
15
18
|
|
|
16
19
|
// The kit's emotes, in the picker's order, with the emoji drawn over the head.
|
|
17
20
|
// The server holds the same ids and durations (`EMOTES` in server/idle.js).
|
|
@@ -191,8 +194,7 @@ function moving(scene) {
|
|
|
191
194
|
function nearestSeat(t, scene, local, self, sceneKey) {
|
|
192
195
|
if (t.seatsFor !== sceneKey || hub.place?.decor) {
|
|
193
196
|
t.seatsFor = sceneKey;
|
|
194
|
-
t.seats = scene
|
|
195
|
-
.getActors()
|
|
197
|
+
t.seats = allActors(scene)
|
|
196
198
|
.filter((actor) => actor.components?.HubSeat)
|
|
197
199
|
.map((actor) => actor.id);
|
|
198
200
|
}
|
|
@@ -255,6 +257,7 @@ function* emoteActors(scene, local) {
|
|
|
255
257
|
// The model inside an actor's drawn node: physics-3d's model rig, the node's
|
|
256
258
|
// child the Transform does not write. Null until the node is built.
|
|
257
259
|
function rigOf(scene, actorId) {
|
|
260
|
+
ensureActorModel(scene.three, actorId);
|
|
258
261
|
const node = scene.three?.nodes?.get?.(actorId)?.node;
|
|
259
262
|
const children = node?.children ?? [];
|
|
260
263
|
const parts = node?.userData?.modelParts;
|
|
@@ -281,6 +284,15 @@ function draw(t, scene, local) {
|
|
|
281
284
|
add(actorId, pose);
|
|
282
285
|
}
|
|
283
286
|
}
|
|
287
|
+
// Draw the local player and visible remote avatars at the same song phase.
|
|
288
|
+
// A manual emote owns its whole animation; a seat/hold also takes priority.
|
|
289
|
+
const playerIds = new Set([scene.multiplayer?.net?.selfId?.(), ...(scene.multiplayer?.avatars?.actors?.keys?.() ?? [])]);
|
|
290
|
+
if (hub.danceIdle) {for (const playerId of playerIds) {
|
|
291
|
+
const actorId = actorOf(scene, local, playerId);
|
|
292
|
+
if (!actorId || poses.has(actorId) || hub.hidden.has(actorId) || hub.seated[playerId] || hub.held.has(playerId)) {continue;}
|
|
293
|
+
const pose = danceIdlePose(hub.danceIdle, hub.sounds, scene.getActor(actorId)?.components.Transform, now);
|
|
294
|
+
if (pose) {add(actorId, pose);}
|
|
295
|
+
}}
|
|
284
296
|
for (const playerId of Object.keys(hub.seated)) {
|
|
285
297
|
const actorId = actorOf(scene, local, playerId);
|
|
286
298
|
if (actorId) {
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// v1.95 opt-in; v1.103 optional share intent. Link and follow operations run
|
|
2
|
+
// in the trusted host; sharing adds only fixed authored words and its returned URL.
|
|
3
|
+
import { watchViewport } from './landscapeLayout.js';
|
|
4
|
+
|
|
5
|
+
function noSdkChannel() {
|
|
6
|
+
return typeof window === 'undefined' || (!window.ReactNativeWebView &&
|
|
7
|
+
!['web', 'dev'].includes(window.CastleEmbed?.host) &&
|
|
8
|
+
!(window.parent && window.parent !== window));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const HOST_RECHECK_MS = 15000;
|
|
12
|
+
|
|
13
|
+
// The host's answer, with the account its links belong to when it names one
|
|
14
|
+
// (v1.146: a guest's too, which User.getCurrent leaves out).
|
|
15
|
+
async function hostAllows(api) {
|
|
16
|
+
try {
|
|
17
|
+
const answer = await api.canInvite?.();
|
|
18
|
+
const allowed = answer?.status === 'ok' && answer.canInvite === true;
|
|
19
|
+
return { allowed, userId: allowed && typeof answer.userId === 'string' ? answer.userId : null };
|
|
20
|
+
} catch { return { allowed: false, userId: null }; }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function makeInvites(api, target, route, now = () => Date.now(), notify = () => {}, title = () => '', onLayout) {
|
|
24
|
+
let root = null, connection = null, done = null, pending = false, disposed = false;
|
|
25
|
+
let epoch = 0, attempts = 0, retryAt = 0;
|
|
26
|
+
let carriedInvite = false;
|
|
27
|
+
let identity = null;
|
|
28
|
+
let destination = null, landed = false, routing = false, routeDoor = null, pointerUntil = 0, pointerSince = null;
|
|
29
|
+
function close() { root?.remove(); root = null; onLayout?.(null); }
|
|
30
|
+
function askHost(read) {
|
|
31
|
+
read.asking = true;
|
|
32
|
+
void hostAllows(api).then(({ allowed, userId }) => {
|
|
33
|
+
if (disposed || identity !== read) {return;}
|
|
34
|
+
read.host = allowed; read.hostUser = userId; read.asking = false; read.hostAt = now();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// The dialog fits the viewport on any phone, either way up: its words wrap
|
|
38
|
+
// and it scrolls inside itself rather than run off the bottom.
|
|
39
|
+
function layoutPanel() {
|
|
40
|
+
if (!root) {return;}
|
|
41
|
+
Object.assign(root.style, { width: 'min(480px, calc(100vw - 24px))', bottom: 'max(12px, env(safe-area-inset-bottom))', maxHeight: 'calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))', overflowY: 'auto', overscrollBehavior: 'contain', display: 'grid', gridTemplateColumns: '1fr auto', gap: '6px', padding: '12px' });
|
|
42
|
+
for (const unit of ['vh', 'dvh']) {root.style.maxHeight = `calc(100${unit} - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))`;}
|
|
43
|
+
}
|
|
44
|
+
const unwatchViewport = watchViewport(layoutPanel);
|
|
45
|
+
function panel(title) {
|
|
46
|
+
close();
|
|
47
|
+
root = document.createElement('section');
|
|
48
|
+
root.dataset.hub = 'invite'; root.setAttribute('role', 'dialog'); root.setAttribute('aria-label', title);
|
|
49
|
+
// Above the hub chrome (2147480000), including its Sit and Talk controls.
|
|
50
|
+
Object.assign(root.style, { position: 'fixed', zIndex: '2147480001', left: '50%', bottom: 'max(24px, env(safe-area-inset-bottom))', transform: 'translateX(-50%)', width: 'min(340px, calc(100vw - 32px))', padding: '16px', boxSizing: 'border-box', borderRadius: '12px', background: '#241a2e', color: '#fff', font: '16px system-ui', pointerEvents: 'auto' });
|
|
51
|
+
document.body.append(root);
|
|
52
|
+
layoutPanel();
|
|
53
|
+
const line = document.createElement('p'); line.textContent = title; root.append(line);
|
|
54
|
+
Object.assign(line.style, { margin: '0', alignSelf: 'center', minWidth: '0', overflowWrap: 'anywhere' });
|
|
55
|
+
button('Close', close);
|
|
56
|
+
onLayout?.(root);
|
|
57
|
+
return root;
|
|
58
|
+
}
|
|
59
|
+
function button(label, action, parent = root) {
|
|
60
|
+
const b = document.createElement('button'); b.type = 'button'; b.textContent = label;
|
|
61
|
+
Object.assign(b.style, { minHeight: '44px', padding: '8px 12px', margin: '0', minWidth: '0', font: 'inherit' });
|
|
62
|
+
b.addEventListener('click', action); parent?.append(b); return b;
|
|
63
|
+
}
|
|
64
|
+
async function copyShare(url, link, origin, control, words) {
|
|
65
|
+
if (disposed || root !== origin || control.disabled) {return;}
|
|
66
|
+
control.disabled = true;
|
|
67
|
+
const text = `${words} ${url}`;
|
|
68
|
+
try {
|
|
69
|
+
await navigator.clipboard.writeText(text);
|
|
70
|
+
if (disposed || root !== origin) {return;}
|
|
71
|
+
notify('Link copied'); close();
|
|
72
|
+
} catch {
|
|
73
|
+
if (disposed || root !== origin) {return;}
|
|
74
|
+
const shown = link.value;
|
|
75
|
+
link.value = text;
|
|
76
|
+
link.focus(); link.select();
|
|
77
|
+
if (document.execCommand?.('copy') === true) {notify('Link copied'); close(); return;}
|
|
78
|
+
link.value = shown;
|
|
79
|
+
control.disabled = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function shareCopyButton(url, link, origin, words) {
|
|
83
|
+
let control;
|
|
84
|
+
control = button('Copy link', () => copyShare(url, link, origin, control, words), origin);
|
|
85
|
+
return control;
|
|
86
|
+
}
|
|
87
|
+
async function createShare() {
|
|
88
|
+
const read = identity, asked = epoch;
|
|
89
|
+
const { allowed, userId } = await hostAllows(api);
|
|
90
|
+
// A socket change, reset or new identity while asking cancels the share.
|
|
91
|
+
if (disposed || epoch !== asked || identity !== read) {return;}
|
|
92
|
+
if (!allowed || userId !== null && userId !== String(read?.userId)) {
|
|
93
|
+
if (read && identity === read) { read.host = false; read.hostAt = now(); }
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const name = String(title() ?? '').trim().replace(/\s+/g, ' ').slice(0, 120);
|
|
97
|
+
const words = name ? `Join me in ${name}.` : 'Join me here.';
|
|
98
|
+
const box = panel('Making your share link…');
|
|
99
|
+
try {
|
|
100
|
+
const answer = await api.invite({ crew: true });
|
|
101
|
+
if (disposed || root !== box) {return;}
|
|
102
|
+
if (answer?.status !== 'ok' || !answer.url) {panel('Sharing is unavailable here.'); return;}
|
|
103
|
+
const shareBox = panel('Invite up to five friends. This link lasts 24 hours.');
|
|
104
|
+
const link = document.createElement('textarea'); link.readOnly = true;
|
|
105
|
+
link.setAttribute('aria-label', 'Share link'); link.style.width = '100%'; shareBox.append(link);
|
|
106
|
+
const url = answer.url.length > 42 ? `${answer.url.slice(0, 26)}…${answer.url.slice(-15)}` : answer.url;
|
|
107
|
+
link.value = `${words}\n${url}`;
|
|
108
|
+
link.rows = 3;
|
|
109
|
+
Object.assign(link.style, { gridColumn: '1 / -1', boxSizing: 'border-box', minWidth: '0', resize: 'none', font: '14px/20px system-ui', padding: '4px', height: '70px', overflowWrap: 'anywhere', whiteSpace: 'pre-wrap' });
|
|
110
|
+
if (typeof navigator.share === 'function') {
|
|
111
|
+
const share = button('Share', async () => {
|
|
112
|
+
if (disposed || root !== shareBox || share.disabled) {return;}
|
|
113
|
+
share.disabled = true;
|
|
114
|
+
try {
|
|
115
|
+
await navigator.share({ text: words, url: answer.url });
|
|
116
|
+
if (!disposed && root === shareBox) {close();}
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
if (disposed || root !== shareBox) {return;}
|
|
120
|
+
share.disabled = false;
|
|
121
|
+
}
|
|
122
|
+
}, shareBox);
|
|
123
|
+
}
|
|
124
|
+
shareCopyButton(answer.url, link, shareBox, words);
|
|
125
|
+
} catch { if (!disposed && root === box) {panel('Sharing is unavailable here.');} }
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
...(onLayout ? { surface: () => root } : {}),
|
|
129
|
+
// The rail is offered only once the account is this socket's own player
|
|
130
|
+
// and the host says it will make a link for them (Castle's invite rule:
|
|
131
|
+
// over 13, in the invite audience). A guest counts as over 13 like any
|
|
132
|
+
// other player, so the host's answer is the authority for them too. The
|
|
133
|
+
// account is the one the host names for its links; a host that names none
|
|
134
|
+
// is checked against User.getCurrent, which has no guest account. A
|
|
135
|
+
// host without Hub.canInvite rejects it, which leaves the rail hidden. A
|
|
136
|
+
// host can replace its visit when the gate changes without replacing the
|
|
137
|
+
// socket, so the host answer is asked again every HOST_RECHECK_MS, and
|
|
138
|
+
// again before every share.
|
|
139
|
+
canInvite(net, user) {
|
|
140
|
+
const playerId = net?.selfId?.(), userId = net?.userId?.(playerId);
|
|
141
|
+
if (!/^[1-9]\d{0,9}$/.test(String(userId ?? '')) || net?.closed?.()) {identity = null; return false;}
|
|
142
|
+
if (identity?.net !== net || identity.userId !== userId) {
|
|
143
|
+
const read = identity = { net, userId, user: false, host: false, hostUser: null, hostAt: 0, asking: false };
|
|
144
|
+
Promise.resolve().then(() => user?.getCurrent?.()).then((me) => {
|
|
145
|
+
if (!disposed && identity === read) {
|
|
146
|
+
read.user = String(me?.userId) === String(userId);
|
|
147
|
+
}
|
|
148
|
+
}).catch(() => {});
|
|
149
|
+
askHost(read);
|
|
150
|
+
} else if (!identity.asking && now() - identity.hostAt >= HOST_RECHECK_MS) {askHost(identity);}
|
|
151
|
+
const own = identity.hostUser === null ? identity.user : identity.hostUser === String(userId);
|
|
152
|
+
return own && identity.host;
|
|
153
|
+
},
|
|
154
|
+
open() { void createShare(); },
|
|
155
|
+
frame(net, beforeHello = false) {
|
|
156
|
+
if (disposed || !net?.selfId?.()) {return;}
|
|
157
|
+
if (connection !== net) { carriedInvite = carriedInvite && done !== connection; connection = net; epoch++; pending = false; done = null; attempts = 0; retryAt = 0; destination = null; routing = false; }
|
|
158
|
+
if (routing && !beforeHello) { routing = false; route(routeDoor); }
|
|
159
|
+
if (pending || done === net || now() < retryAt || attempts >= 6) {return;}
|
|
160
|
+
const active = epoch;
|
|
161
|
+
let retry = false;
|
|
162
|
+
attempts++; pending = true;
|
|
163
|
+
api.inviteArrival().then((answer) => {
|
|
164
|
+
if (disposed || active !== epoch) {return;}
|
|
165
|
+
if (answer?.status === 'route' && typeof answer.doorId === 'string') { carriedInvite = true; retry = true; routing = true; routeDoor = answer.doorId; if (!beforeHello) { routing = false; route(routeDoor); } return; }
|
|
166
|
+
done = net;
|
|
167
|
+
if (answer?.status !== 'ok') {return;}
|
|
168
|
+
carriedInvite = true;
|
|
169
|
+
if (answer.destination?.hub?.target?.kind === 'player') {
|
|
170
|
+
destination = answer.destination.hub.target.id;
|
|
171
|
+
pointerUntil = now() + 120000; pointerSince = null;
|
|
172
|
+
target(net, destination);
|
|
173
|
+
}
|
|
174
|
+
if (!answer.friends?.length) {return;}
|
|
175
|
+
panel('You are now friends');
|
|
176
|
+
for (const friend of answer.friends) {
|
|
177
|
+
const row = document.createElement('div'); const line = document.createElement('span');
|
|
178
|
+
line.textContent = `You and ${friend.username} are now friends. `; row.append(line); root.append(row);
|
|
179
|
+
const undo = button('Undo', async () => {
|
|
180
|
+
undo.disabled = true;
|
|
181
|
+
try {
|
|
182
|
+
const result = await api.undoInvite(friend.userId);
|
|
183
|
+
if (result.status === 'ok') {row.remove();} else {undo.disabled = false;}
|
|
184
|
+
} catch { undo.disabled = false; }
|
|
185
|
+
}, row);
|
|
186
|
+
}
|
|
187
|
+
}).catch((error) => {
|
|
188
|
+
if (disposed || active !== epoch) {return;}
|
|
189
|
+
if (error?.code === 'UNKNOWN_COMMAND' || error?.code === 'CASTLE_HOST_UNAVAILABLE' && noSdkChannel()) {
|
|
190
|
+
done = net; return;
|
|
191
|
+
}
|
|
192
|
+
retry = true;
|
|
193
|
+
}).finally(() => {
|
|
194
|
+
if (disposed || active !== epoch) {return;}
|
|
195
|
+
pending = false;
|
|
196
|
+
if (!retry) {return;}
|
|
197
|
+
retryAt = now() + Math.min(10000, 500 * 2 ** (attempts - 1));
|
|
198
|
+
if (attempts >= 6 && carriedInvite) {
|
|
199
|
+
panel('Your friend update did not finish. Try again.');
|
|
200
|
+
button('Try again', () => { attempts = 0; retryAt = 0; done = null; close(); });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
// Socket admission precedes hello: Ghost completes against its roster,
|
|
205
|
+
// so the inviter can be named in the very first placement message.
|
|
206
|
+
hello(net) {
|
|
207
|
+
this.frame(net, true);
|
|
208
|
+
return { ready: done === net || routing || attempts >= 6 && !pending,
|
|
209
|
+
near: landed ? null : destination };
|
|
210
|
+
},
|
|
211
|
+
landed() { if (destination !== null) { landed = true; } },
|
|
212
|
+
accepted() { return destination !== null; },
|
|
213
|
+
pointer(scene) {
|
|
214
|
+
if (!destination || now() >= pointerUntil) {return null;}
|
|
215
|
+
const mp = scene.multiplayer, net = mp?.net;
|
|
216
|
+
for (const id of net?.others?.().keys() ?? []) {
|
|
217
|
+
if (String(net.userId?.(id)) !== destination) {continue;}
|
|
218
|
+
const actorId = mp.avatars?.actors?.get(id);
|
|
219
|
+
const at = actorId ? scene.getActor(actorId)?.components.Transform : null;
|
|
220
|
+
if (!at) {return null;} // Only a body in the block-filtered visible roster.
|
|
221
|
+
pointerSince ??= now();
|
|
222
|
+
const me = scene.actorWith('Player')?.components.Transform;
|
|
223
|
+
if (me && now() - pointerSince >= 10000 && Math.hypot(me.x - at.x, me.z - at.z) < 3) {return null;}
|
|
224
|
+
return { id, at };
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
},
|
|
228
|
+
reset() { identity = null; epoch++; connection = null; done = null; pending = false; attempts = 0; retryAt = 0; destination = null; routing = false; carriedInvite = false; close(); },
|
|
229
|
+
dispose() { identity = null; epoch++; disposed = true; unwatchViewport(); close(); },
|
|
230
|
+
};
|
|
231
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const BANNED_TEXT = "You can't enter the town right now.";
|
|
2
|
+
|
|
3
|
+
export function joinErrorText(code) {
|
|
4
|
+
if (code === 'CAULDRON_HUB_BANNED') { return BANNED_TEXT; }
|
|
5
|
+
if (typeof code === 'string' && code.startsWith('CAULDRON_HUB_INVITE_') && code !== 'CAULDRON_HUB_INVITE_NOT_IN_SESSION') {
|
|
6
|
+
return 'This invite is unavailable.';
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
@@ -34,6 +34,7 @@ export const HIDE_MS = 2000;
|
|
|
34
34
|
const FADE_MS = 250;
|
|
35
35
|
|
|
36
36
|
import { pushBelow } from './hudClear.js';
|
|
37
|
+
import { promptShift } from './hudCopy.js';
|
|
37
38
|
|
|
38
39
|
const RANK = { plate: 0, speech: 1, sign: 2 };
|
|
39
40
|
|
|
@@ -69,6 +70,23 @@ export function nearFor(holder, scope) {
|
|
|
69
70
|
return holder.state;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
// Keep every potentially visible sign, including ones behind the camera.
|
|
74
|
+
// A player may drift 0.5 m before refresh; the extra metre covers that drift
|
|
75
|
+
// beyond the far threshold. Plates/speech have no distance limit. This is
|
|
76
|
+
// only a projection shortlist: near() still ranks, fades and collides each frame.
|
|
77
|
+
export function nearCandidates(holder, placed, position, now, scope, defaults = false) {
|
|
78
|
+
const source = JSON.stringify([defaults, placed.map(({ id, at, label, always }) => [id, at.x, at.y, at.z, label, always])]);
|
|
79
|
+
const cached = holder.current;
|
|
80
|
+
if (!cached || cached.scope !== scope || cached.source !== source || now < cached.at || now - cached.at >= 100
|
|
81
|
+
|| Math.hypot(position.x - cached.x, (position.y ?? 0) - cached.y, position.z - cached.z) > 0.5) {
|
|
82
|
+
const ranked = placed.map((entry) => ({ ...entry, d: Math.hypot(entry.at.x - position.x, entry.at.z - position.z) }))
|
|
83
|
+
.filter((entry) => (!defaults && !entry.always) || entry.d <= SIGN_FAR_M + 1)
|
|
84
|
+
.sort((a, b) => a.d - b.d);
|
|
85
|
+
holder.current = { scope, source, at: now, x: position.x, y: position.y ?? 0, z: position.z, ids: new Set(ranked.map(({ id }) => id)) };
|
|
86
|
+
}
|
|
87
|
+
return holder.current.ids;
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
const touch = (a, b, pad) => a.left - pad < b.right && b.left - pad < a.right && a.top - pad < b.bottom && b.top - pad < a.bottom;
|
|
73
91
|
const inView = (box, view) => box.right > 0 && box.left < view.w && box.bottom > 0 && box.top < view.h;
|
|
74
92
|
|
|
@@ -186,13 +204,18 @@ function thin(item) {
|
|
|
186
204
|
// and then, in a place with a clear HUD (v1.26), moved down from under the
|
|
187
205
|
// HUD's box exactly as the chrome's flush will move it (`hudClear.js`
|
|
188
206
|
// `pushBelow`; `hud` is that box, or null where there is none to clear).
|
|
207
|
+
// v1.131 optionally reserves the bottom prompt before selection too.
|
|
189
208
|
// The rule judges these boxes, so they must be the final ones.
|
|
190
|
-
export function labelBox(x, y, size, npc, view, hud = null) {
|
|
209
|
+
export function labelBox(x, y, size, npc, view, hud = null, prompt = null) {
|
|
191
210
|
const half = size.w / 2;
|
|
192
211
|
const cx = npc ? Math.min(Math.max(x, half + 6), view.w - half - 6) : x;
|
|
193
212
|
const box = { left: cx - half, right: cx + half, top: y - size.h, bottom: y };
|
|
194
213
|
const down = pushBelow(box, hud, undefined, view.h);
|
|
195
|
-
|
|
214
|
+
const placed = down > 0 ? { left: box.left, right: box.right, top: box.top + down, bottom: box.bottom + down } : box;
|
|
215
|
+
const up = promptShift(placed, prompt);
|
|
216
|
+
const final = up < 0 ? { left: placed.left, right: placed.right, top: placed.top + up, bottom: placed.bottom + up } : placed;
|
|
217
|
+
// With both bands, a label too tall for the remaining lane is not selected.
|
|
218
|
+
return prompt && hud && touch(final, hud, 0) ? null : final;
|
|
196
219
|
}
|
|
197
220
|
|
|
198
221
|
// What the chrome is given for a world label the rule chose (`setLabels`):
|
|
@@ -203,3 +226,9 @@ export function labelBox(x, y, size, npc, view, hud = null) {
|
|
|
203
226
|
export function chromeItem(id, text, speech, npc, box, opacity) {
|
|
204
227
|
return { id: speech ? `${id}\u0000${npc ? 'npc' : 'speech'}` : id, x: (box.left + box.right) / 2, y: box.bottom, text, speech, npc, box, opacity };
|
|
205
228
|
}
|
|
229
|
+
|
|
230
|
+
// A private goal can project a server-supplied point without moving any actor.
|
|
231
|
+
export function goalAt(label, actorAt) {
|
|
232
|
+
return label.style === 'goal' && label.at && ['x', 'y', 'z'].every((key) => Number.isFinite(label.at[key]))
|
|
233
|
+
? label.at : actorAt;
|
|
234
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Viewport-only landscape detection shared by the hub's independent DOM
|
|
2
|
+
// surfaces. It deliberately does not infer from device, pointer or metadata:
|
|
3
|
+
// a live resize/turn is the whole contract.
|
|
4
|
+
export function landscapeViewport(view = globalThis.window) {
|
|
5
|
+
return Number(view?.innerWidth) > Number(view?.innerHeight);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Listen to both signals used by embedded mobile browsers. Some deliver only
|
|
9
|
+
// resize, some also deliver orientationchange; the callback is idempotent.
|
|
10
|
+
export function watchViewport(callback, view = globalThis.window) {
|
|
11
|
+
view?.addEventListener?.('resize', callback);
|
|
12
|
+
view?.addEventListener?.('orientationchange', callback);
|
|
13
|
+
return () => {
|
|
14
|
+
view?.removeEventListener?.('resize', callback);
|
|
15
|
+
view?.removeEventListener?.('orientationchange', callback);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// Placement inputs are small value records, never DOM subtrees. Keep a copy
|
|
2
|
+
// only when they change so mutating an offer in place still invalidates it.
|
|
3
|
+
function equal(a, b) {
|
|
4
|
+
if (a === b) {return true;}
|
|
5
|
+
if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {return false;}
|
|
6
|
+
const keys = Object.keys(a);
|
|
7
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && equal(a[key], b[key]));
|
|
8
|
+
}
|
|
9
|
+
const copy = (value) => !value || typeof value !== 'object' ? value
|
|
10
|
+
: Array.isArray(value) ? value.map(copy) : Object.fromEntries(Object.entries(value).map(([key, item]) => [key, copy(item)]));
|
|
11
|
+
export function placementCache() {
|
|
12
|
+
let previous, value;
|
|
13
|
+
return (inputs, place) => {
|
|
14
|
+
if (!equal(inputs, previous)) {value = place(); previous = copy(inputs);}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function displayed(node) {
|
|
20
|
+
for (let parent = node; parent; parent = parent.parentElement ?? parent.parent) {
|
|
21
|
+
if (parent.style?.display === 'none') {return false;}
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const pixels = (value, size = 0) => !value || value === 'none' ? 0
|
|
26
|
+
: /^-?(?:\d+\.?\d*|\.\d+)(px|%)?$/.test(value)
|
|
27
|
+
? Number.parseFloat(value) * (value.endsWith('%') ? size / 100 : 1) : null;
|
|
28
|
+
function anchor(value, box) {
|
|
29
|
+
const pair = /^translate\(([^,]+),\s*([^)]+)\)$/.exec(value ?? '');
|
|
30
|
+
if (pair) {return [pixels(pair[1], box.width), pixels(pair[2], box.height)];}
|
|
31
|
+
const x = /^translateX\(([^)]+)\)$/.exec(value ?? '');
|
|
32
|
+
return [x ? pixels(x[1], box.width) : 0, 0];
|
|
33
|
+
}
|
|
34
|
+
function shift(box, before, after, viewport) {
|
|
35
|
+
const [bx, by = '0'] = (before.translate || '0 0').split(' ');
|
|
36
|
+
const [ax, ay = '0'] = (after.translate || '0 0').split(' ');
|
|
37
|
+
const dx = after.left === before.left ? 0 : pixels(after.left, viewport.w) - pixels(before.left, viewport.w);
|
|
38
|
+
const dy = after.top === before.top ? 0 : pixels(after.top, viewport.h) - pixels(before.top, viewport.h);
|
|
39
|
+
const oldAnchor = before.transform === after.transform ? [0, 0] : anchor(before.transform, box);
|
|
40
|
+
const newAnchor = before.transform === after.transform ? [0, 0] : anchor(after.transform, box);
|
|
41
|
+
const x = dx + pixels(ax, box.width) - pixels(bx, box.width) + newAnchor[0] - oldAnchor[0];
|
|
42
|
+
const y = dy + pixels(ay, box.height) - pixels(by, box.height) + newAnchor[1] - oldAnchor[1];
|
|
43
|
+
return { left: box.left + x, right: box.right + x, top: box.top + y, bottom: box.bottom + y,
|
|
44
|
+
width: box.width, height: box.height };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const sizeStyles = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'boxSizing',
|
|
48
|
+
'font', 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'lineHeight', 'letterSpacing',
|
|
49
|
+
'whiteSpace', 'overflowWrap', 'wordBreak', 'padding', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom',
|
|
50
|
+
'border', 'borderWidth', 'display'];
|
|
51
|
+
const sizeProperties = new Set([...sizeStyles.map((key) => key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)),
|
|
52
|
+
'border-left-width', 'border-right-width', 'border-top-width', 'border-bottom-width']);
|
|
53
|
+
// Declarations split on semicolons outside quotes and parentheses, so a quoted
|
|
54
|
+
// font family or a data URL stays one value.
|
|
55
|
+
function parseStyles(css) {
|
|
56
|
+
const styles = Object.create(null);
|
|
57
|
+
let start = 0, quote = '', depth = 0;
|
|
58
|
+
const add = (end) => {
|
|
59
|
+
const declaration = css.slice(start, end), colon = declaration.indexOf(':');
|
|
60
|
+
if (colon >= 0) {styles[declaration.slice(0, colon).trim().toLowerCase()] = declaration.slice(colon + 1).replace(/\s*!important\s*$/i, '').trim();}
|
|
61
|
+
start = end + 1;
|
|
62
|
+
};
|
|
63
|
+
for (let i = 0; i < css.length; i += 1) {
|
|
64
|
+
const char = css[i];
|
|
65
|
+
if (quote) {if (char === '\\') {i += 1;} else if (char === quote) {quote = '';}}
|
|
66
|
+
else if (char === '"' || char === "'") {quote = char;}
|
|
67
|
+
else if (char === '(') {depth += 1;}
|
|
68
|
+
else if (char === ')') {depth = Math.max(0, depth - 1);}
|
|
69
|
+
else if (char === ';' && depth === 0) {add(i);}
|
|
70
|
+
}
|
|
71
|
+
add(css.length);
|
|
72
|
+
return styles;
|
|
73
|
+
}
|
|
74
|
+
// Auto-width wrapping text can change size when moved into a narrower lane.
|
|
75
|
+
// Fixed/max-content widths and no-wrap labels only need translation math.
|
|
76
|
+
const wrapsAtPosition = (style) => (!style.width || style.width === 'auto') && !['nowrap', 'pre'].includes(style.whiteSpace);
|
|
77
|
+
function layoutState(node) {
|
|
78
|
+
const style = node.style ?? {};
|
|
79
|
+
const css = 'cssText' in style ? style.cssText : undefined;
|
|
80
|
+
if (typeof css === 'string') {return { text: node.textContent, className: node.className, css };}
|
|
81
|
+
return { text: node.textContent, className: node.className,
|
|
82
|
+
styles: Object.fromEntries(sizeStyles.map((key) => [key, style[key]])),
|
|
83
|
+
left: wrapsAtPosition(style) ? style.left : null, right: wrapsAtPosition(style) ? style.right : null };
|
|
84
|
+
}
|
|
85
|
+
function layoutChanged(node, previous) {
|
|
86
|
+
if (node.textContent !== previous.text || node.className !== previous.className) {return true;}
|
|
87
|
+
const style = node.style ?? {};
|
|
88
|
+
const css = 'cssText' in style ? style.cssText : undefined;
|
|
89
|
+
if (typeof css === 'string') {
|
|
90
|
+
if (css === previous.css) {return false;}
|
|
91
|
+
if (previous.css === undefined) {return true;}
|
|
92
|
+
// Parse the stored sample at most once; moving/fading surfaces can keep
|
|
93
|
+
// that same measurement for many frames without native per-style reads.
|
|
94
|
+
const before = previous.parsed ??= parseStyles(previous.css), after = parseStyles(css);
|
|
95
|
+
return [...new Set([...Object.keys(before), ...Object.keys(after)])].some((key) =>
|
|
96
|
+
(sizeProperties.has(key) || key.startsWith('font-') || key.startsWith('border') || key.startsWith('padding')) && before[key] !== after[key])
|
|
97
|
+
|| (wrapsAtPosition({ width: after.width, whiteSpace: after['white-space'] })
|
|
98
|
+
&& (before.left !== after.left || before.right !== after.right));
|
|
99
|
+
}
|
|
100
|
+
return !previous.styles || sizeStyles.some((key) => style[key] !== previous.styles[key])
|
|
101
|
+
|| (wrapsAtPosition(style) && (style.left !== previous.left || style.right !== previous.right));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Positioned measurements are refreshed at least this often, whatever the
|
|
105
|
+
// observer saw: inherited changes above a source and late font metrics.
|
|
106
|
+
const REFRESH_FRAMES = 30;
|
|
107
|
+
|
|
108
|
+
export function makeLayoutCache() {
|
|
109
|
+
const sources = new Map(), snapshot = new Map(), dirty = new Set(), descendants = new Set(), structural = new Set();
|
|
110
|
+
// Sources mutated since their stored layoutState; only a fresh sample clears it.
|
|
111
|
+
const unsampled = new Set();
|
|
112
|
+
let active = false, viewport, frame = 0, reconnect = false;
|
|
113
|
+
function changedChildren(node) {
|
|
114
|
+
for (const child of node.children ?? []) {
|
|
115
|
+
if (sources.has(child)) {descendants.add(child);}
|
|
116
|
+
changedChildren(child);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function mutations(records) {
|
|
120
|
+
const parents = new Set();
|
|
121
|
+
for (const record of records) {
|
|
122
|
+
if (record.type === 'attributes' && record.target.children?.length) {parents.add(record.target);}
|
|
123
|
+
for (let node = record.target; node; node = node.parentElement ?? node.parentNode ?? node.parent) {
|
|
124
|
+
if (!sources.has(node)) {continue;}
|
|
125
|
+
dirty.add(node); unsampled.add(node);
|
|
126
|
+
if (record.type === 'childList') {structural.add(node);}
|
|
127
|
+
if (node !== record.target) {descendants.add(node);}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Inherited font/width changes can resize positioned descendants without
|
|
131
|
+
// touching their own inline inputs. Refresh those in the next read phase.
|
|
132
|
+
for (const node of parents) {changedChildren(node);}
|
|
133
|
+
}
|
|
134
|
+
const observe = (node) => observer?.observe(node, { subtree: true, childList: true, characterData: true,
|
|
135
|
+
attributes: true, attributeFilter: ['style', 'class'] });
|
|
136
|
+
const observer = globalThis.MutationObserver ? new globalThis.MutationObserver(mutations) : null;
|
|
137
|
+
function changes() {
|
|
138
|
+
if (!observer) {return;}
|
|
139
|
+
// MutationObserver callbacks run after this synchronous frame. Drain writes
|
|
140
|
+
// now too, so growing copy/wrapping is visible to the next consumer.
|
|
141
|
+
mutations(observer.takeRecords?.() ?? []);
|
|
142
|
+
if (!reconnect) {return;}
|
|
143
|
+
observer.disconnect();
|
|
144
|
+
for (const node of sources.keys()) {observe(node);}
|
|
145
|
+
reconnect = false;
|
|
146
|
+
}
|
|
147
|
+
const fonts = globalThis.document?.fonts;
|
|
148
|
+
const fontsLoaded = () => snapshot.clear();
|
|
149
|
+
fonts?.addEventListener?.('loadingdone', fontsLoaded);
|
|
150
|
+
const view = () => active ? viewport : { w: globalThis.window?.innerWidth, h: globalThis.window?.innerHeight };
|
|
151
|
+
function register(node, options = {}) {
|
|
152
|
+
if (node) {
|
|
153
|
+
const previous = sources.get(node);
|
|
154
|
+
sources.set(node, { ...previous, ...options });
|
|
155
|
+
if (!previous) {observe(node);}
|
|
156
|
+
}
|
|
157
|
+
return node;
|
|
158
|
+
}
|
|
159
|
+
function forget(node) {
|
|
160
|
+
if (sources.delete(node)) {reconnect = true;}
|
|
161
|
+
snapshot.delete(node); dirty.delete(node); descendants.delete(node); structural.delete(node); unsampled.delete(node);
|
|
162
|
+
for (const child of node.children ?? []) {forget(child);}
|
|
163
|
+
}
|
|
164
|
+
// Release observer membership as soon as a surface leaves, once per call.
|
|
165
|
+
function unregister(node) {
|
|
166
|
+
if (!node) {return;}
|
|
167
|
+
forget(node);
|
|
168
|
+
if (reconnect) {changes();}
|
|
169
|
+
}
|
|
170
|
+
// An observed source with no mutation since its last layout sample keeps
|
|
171
|
+
// that sample's copy and inline styles; only geometry is read again.
|
|
172
|
+
function measure(node, previous) {
|
|
173
|
+
const shown = displayed(node);
|
|
174
|
+
const box = shown ? node.getBoundingClientRect() : { left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0 };
|
|
175
|
+
const options = sources.get(node);
|
|
176
|
+
const style = node.style ?? {};
|
|
177
|
+
const reuse = shown && observer && previous?.layout && !unsampled.has(node);
|
|
178
|
+
if (shown && !reuse) {unsampled.delete(node);}
|
|
179
|
+
const measured = {
|
|
180
|
+
rect: { left: box.left, right: box.right, top: box.top, bottom: box.bottom, width: box.width, height: box.height },
|
|
181
|
+
size: { w: shown ? node.offsetWidth : 0, h: shown ? node.offsetHeight : 0 },
|
|
182
|
+
offsets: { left: shown ? node.offsetLeft ?? 0 : 0, top: shown ? node.offsetTop ?? 0 : 0 },
|
|
183
|
+
position: { left: style.left, top: style.top, translate: style.translate, transform: style.transform },
|
|
184
|
+
displayed: shown, frame,
|
|
185
|
+
layout: !shown ? null : reuse ? previous.layout : layoutState(node),
|
|
186
|
+
};
|
|
187
|
+
if (options?.fit) {measured.fit = { client: shown ? node.clientWidth : 0, scroll: shown ? node.scrollWidth : 0, text: node.textContent, fontSize: style.fontSize };}
|
|
188
|
+
if (options?.scroll) {measured.scroll = { height: shown ? node.scrollHeight : 0, top: shown ? node.scrollTop : 0, client: shown ? node.clientHeight : 0 };}
|
|
189
|
+
if (options?.padding) {
|
|
190
|
+
const computed = shown ? globalThis.getComputedStyle?.(node) ?? style : {};
|
|
191
|
+
measured.padding = Object.fromEntries(['Left', 'Right', 'Top', 'Bottom'].map((edge) => [edge.toLowerCase(), Number.parseFloat(computed[`padding${edge}`]) || 0]));
|
|
192
|
+
}
|
|
193
|
+
return measured;
|
|
194
|
+
}
|
|
195
|
+
function used(node) {
|
|
196
|
+
if (!sources.has(node)) {register(node);}
|
|
197
|
+
sources.get(node).readFrame = frame;
|
|
198
|
+
return node;
|
|
199
|
+
}
|
|
200
|
+
function read(node) {
|
|
201
|
+
used(node); changes();
|
|
202
|
+
const options = sources.get(node);
|
|
203
|
+
let measured = snapshot.get(node);
|
|
204
|
+
const shown = displayed(node);
|
|
205
|
+
// Descendant style changes retain the current read-phase sample, then
|
|
206
|
+
// refresh next frame. Own copy/size changes still refresh immediately.
|
|
207
|
+
if (!measured || measured.displayed !== shown || (shown && !options.positioned && measured.frame !== frame)
|
|
208
|
+
|| (shown && structural.has(node))
|
|
209
|
+
|| (shown && (!observer || dirty.has(node)) && layoutChanged(node, measured.layout))) {
|
|
210
|
+
measured = measure(node); snapshot.set(node, measured); descendants.delete(node);
|
|
211
|
+
}
|
|
212
|
+
dirty.delete(node); structural.delete(node);
|
|
213
|
+
return measured;
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
register, unregister, invalidate: (node) => snapshot.delete(node), view, active: () => active,
|
|
217
|
+
beginFrame(nodes = []) {
|
|
218
|
+
for (const node of nodes) {register(node);}
|
|
219
|
+
changes();
|
|
220
|
+
const next = { w: globalThis.window?.innerWidth, h: globalThis.window?.innerHeight };
|
|
221
|
+
if (viewport?.w !== next.w || viewport?.h !== next.h) {snapshot.clear();}
|
|
222
|
+
active = true; viewport = next; frame += 1;
|
|
223
|
+
// Keep positioned measurements through walking/camera frames. In-flow
|
|
224
|
+
// surfaces used last frame must still sample sibling/ancestor movement
|
|
225
|
+
// before writes, even when no mutation touched their own size inputs.
|
|
226
|
+
for (const [node, options] of sources) {
|
|
227
|
+
if (node.isConnected === false) {unregister(node); continue;}
|
|
228
|
+
if (!displayed(node)) {snapshot.delete(node); continue;}
|
|
229
|
+
const measured = snapshot.get(node);
|
|
230
|
+
if (!measured?.displayed || (!options.positioned && options.readFrame === frame - 1)
|
|
231
|
+
|| (options.positioned && (descendants.has(node) || structural.has(node) || frame - measured.frame >= REFRESH_FRAMES
|
|
232
|
+
|| ((!observer || dirty.has(node)) && layoutChanged(node, measured.layout))))) {
|
|
233
|
+
snapshot.set(node, measure(node, measured));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
dirty.clear(); descendants.clear(); structural.clear();
|
|
237
|
+
},
|
|
238
|
+
endFrame() {active = false;},
|
|
239
|
+
rect(node) {
|
|
240
|
+
if (!active) {return used(node).getBoundingClientRect();}
|
|
241
|
+
const measured = read(node);
|
|
242
|
+
// These owned world layers have no transformed ancestors. Use their
|
|
243
|
+
// snapshot size at the new pixel position, without another DOM read.
|
|
244
|
+
if (!measured.displayed) {return measured.rect;}
|
|
245
|
+
if (sources.get(node)?.positioned) {return shift(measured.rect, measured.position, node.style, viewport);}
|
|
246
|
+
// Caption and other surface translations can be restored after the
|
|
247
|
+
// snapshot too; derive that move without re-reading their layout.
|
|
248
|
+
return measured.position.translate !== node.style.translate
|
|
249
|
+
? shift(measured.rect, { translate: measured.position.translate }, { translate: node.style.translate }, viewport)
|
|
250
|
+
: measured.rect;
|
|
251
|
+
},
|
|
252
|
+
size: (node) => active ? read(node).size : { w: used(node).offsetWidth, h: node.offsetHeight },
|
|
253
|
+
dimensions(node) {const box = this.rect(node); return { w: box.width, h: box.height };},
|
|
254
|
+
offsets: (node) => active ? read(node).offsets : { left: used(node).offsetLeft ?? 0, top: node.offsetTop ?? 0 },
|
|
255
|
+
fit: (node) => active ? read(node).fit : { client: used(node).clientWidth, scroll: node.scrollWidth, text: node.textContent, fontSize: node.style.fontSize },
|
|
256
|
+
scroll: (node) => active ? read(node).scroll : { height: used(node).scrollHeight, top: node.scrollTop, client: node.clientHeight },
|
|
257
|
+
padding: (node) => active ? read(node).padding : (() => {
|
|
258
|
+
used(node);
|
|
259
|
+
const style = globalThis.getComputedStyle?.(node) ?? node.style;
|
|
260
|
+
return Object.fromEntries(['Left', 'Right', 'Top', 'Bottom'].map((edge) => [edge.toLowerCase(), Number.parseFloat(style[`padding${edge}`]) || 0]));
|
|
261
|
+
})(),
|
|
262
|
+
dispose() {active = false; observer?.disconnect(); fonts?.removeEventListener?.('loadingdone', fontsLoaded); structural.clear(); unsampled.clear(); sources.clear(); snapshot.clear(); dirty.clear(); descendants.clear(); viewport = null;},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// v1.138: which transports' places asked for load stages, and what each was told.
|
|
2
|
+
// Allocate nothing until an opted-in server snapshot arrives.
|
|
3
|
+
import { CLIENT_LOAD_STAGES } from '../shared/loadStages.js';
|
|
4
|
+
let sessions;
|
|
5
|
+
export function setLoadTelemetry(net, on) {
|
|
6
|
+
if (!net) {return;}
|
|
7
|
+
if (on === true) {
|
|
8
|
+
sessions ??= new WeakMap();
|
|
9
|
+
if (!sessions.has(net)) {sessions.set(net, { sent: 0 });}
|
|
10
|
+
} else {sessions?.delete(net);}
|
|
11
|
+
}
|
|
12
|
+
export function loadTelemetryFor(net) {return net ? sessions?.has(net) === true : false;}
|
|
13
|
+
// Send one client stage once per transport, only upward.
|
|
14
|
+
export function reportLoadStage(net, stage) {
|
|
15
|
+
const state = net ? sessions?.get(net) : undefined;
|
|
16
|
+
if (!state || !CLIENT_LOAD_STAGES.includes(stage) || stage <= state.sent) {return false;}
|
|
17
|
+
state.sent = stage;
|
|
18
|
+
try { net.send({ k: 'hub-load', stage }); } catch { return false; }
|
|
19
|
+
return true;
|
|
20
|
+
}
|