castle-web-cli 0.4.233 → 0.4.234
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 +260 -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 +50 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +140 -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 +1257 -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 +819 -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
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { register } from 'node:module';
|
|
3
|
+
|
|
4
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
5
|
+
export async function resolve(specifier, context, next) {
|
|
6
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/server/sceneBodies.js') return { url: 'data:text/javascript,export const readScene = () => globalThis.__hubTestActors;', shortCircuit: true };
|
|
7
|
+
if (context.parentURL?.includes('/kits/base/sdk/') && specifier.startsWith('.') && !specifier.endsWith('.js')) return next(specifier + '.js', context);
|
|
8
|
+
return next(specifier, context);
|
|
9
|
+
}
|
|
10
|
+
`)}`);
|
|
11
|
+
const { layer } = await import('../code/server/hub.js');
|
|
12
|
+
const flush = async () => { for (let i = 0; i < 8; i++) await Promise.resolve(); };
|
|
13
|
+
const deferred = () => { let resolve, reject; const promise = new Promise((r, e) => { resolve = r; reject = e; }); return { promise, resolve, reject }; };
|
|
14
|
+
const player = (id) => ({ playerId: id, userId: '101', username: 'Ada', isAnonymous: false });
|
|
15
|
+
const body = () => ({ at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } });
|
|
16
|
+
const localUnlock = { id: 'local-badge', class: 'badge', shape: 'badge-round', name: 'Local Badge', deed: 'choose it here', color: '#44aaff' };
|
|
17
|
+
|
|
18
|
+
function boot({ hook = true, failOnce = false, platform = false, unsaved = false, onReset = null, resumePlace = false, unlocks = null } = {}) {
|
|
19
|
+
globalThis.__hubTestActors = [{ id: 'player', components: { Player: {}, Transform: { x: 0, y: 1, z: 0 } } }];
|
|
20
|
+
const sent = [], hooks = [], opens = [], platformReads = [], arrived = [];
|
|
21
|
+
let ctx;
|
|
22
|
+
let heldHook = null;
|
|
23
|
+
const hooksForTest = {
|
|
24
|
+
ready(hub) { ctx = hub; },
|
|
25
|
+
arrive(hub, group) { arrived.push(group); },
|
|
26
|
+
...(hook ? { progressReset(hub, id, generation, options) {
|
|
27
|
+
hooks.push([id, generation, options]);
|
|
28
|
+
onReset?.(id, generation);
|
|
29
|
+
if (failOnce && id === 'p1' && generation === 2) { failOnce = false; throw Error('reset read failed'); }
|
|
30
|
+
return heldHook?.promise.then(() => hub.setHud({ title: 'Fresh' }, id));
|
|
31
|
+
} } : {}),
|
|
32
|
+
};
|
|
33
|
+
const server = layer({ ...(!unsaved ? { deckId: 'saved-test' } : {}), server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Town', ...(unlocks ? { unlocks } : {}), ...(resumePlace ? { result: { score: { unit: 's', better: 'lower' } }, resume: true } : {}) } }, hooksForTest, {}, () => true, () => null, null, {});
|
|
34
|
+
const session = {
|
|
35
|
+
sessionId: 'dev', players: [player('p1'), player('p2')],
|
|
36
|
+
storage: { playthrough() { const d = deferred(); opens.push(d); return d.promise; } },
|
|
37
|
+
...(platform ? { hub: { arrival: () => null, readResults(input) {
|
|
38
|
+
if (!input.userIds) return Promise.resolve({ boards: {} });
|
|
39
|
+
const d = deferred(); platformReads.push(d); return d.promise;
|
|
40
|
+
} } } : {}),
|
|
41
|
+
send(id, msg) { sent.push([id, structuredClone(msg)]); },
|
|
42
|
+
broadcast(msg) { sent.push(['all', structuredClone(msg)]); },
|
|
43
|
+
};
|
|
44
|
+
const world = { timeMs: 0, scenePath: 'scenes/main.scene', objects: new Map(), bodies: new Map(), players: new Map([['p1', body()], ['p2', body()]]) };
|
|
45
|
+
server.sceneFor(session); server.ready(world);
|
|
46
|
+
const hello = (id, more = {}) => server.message(session, { playerId: id }, { k: 'hub-hello', avatar: 0, party: 1, ...more });
|
|
47
|
+
const tick = () => { world.timeMs += 50; server.place(world); server.step(world, []); };
|
|
48
|
+
return { sent, hooks, opens, platformReads, arrived, hello, tick, session, world, ctx: () => ctx, snapshot: () => server.join(), hold: (d) => { heldHook = d; } };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A local unsaved serve exposes the SDK method but its broker has no storage.
|
|
52
|
+
// Its ordinary arrival must proceed without opening a marker or closing HUD.
|
|
53
|
+
const unsaved = boot({ unsaved: true });
|
|
54
|
+
unsaved.hello('p1'); unsaved.tick();
|
|
55
|
+
assert.equal(unsaved.opens.length, 0);
|
|
56
|
+
assert.equal(unsaved.ctx().progressGeneration('p1'), null);
|
|
57
|
+
assert.equal(unsaved.ctx().progressPending(), false);
|
|
58
|
+
unsaved.ctx().setHud({ title: 'Local' }, 'p1');
|
|
59
|
+
unsaved.tick();
|
|
60
|
+
assert.equal(unsaved.sent.some(([, msg]) => msg.k === 'hub-hud' && msg.hud?.title === 'Local'), true);
|
|
61
|
+
|
|
62
|
+
const r = boot();
|
|
63
|
+
r.hello('p1'); r.hello('p2');
|
|
64
|
+
r.tick();
|
|
65
|
+
assert.equal(r.opens.length, 2);
|
|
66
|
+
assert.equal(r.sent.some(([, msg]) => msg.k === 'hub-hud'), false, 'private HUD waits for the marker read');
|
|
67
|
+
r.opens[0].resolve({ generation: 1 }); r.opens[1].resolve({ generation: 1 });
|
|
68
|
+
await flush(); r.tick();
|
|
69
|
+
assert.deepEqual(r.hooks, [], 'an absent marker does not run the hook');
|
|
70
|
+
assert.equal(r.ctx().progressGeneration('p1'), 0, 'successful never-reset read observes zero');
|
|
71
|
+
assert.equal(r.ctx().progressGeneration('p2'), 0);
|
|
72
|
+
r.ctx().setHud({ title: 'Old' }, 'p1'); r.ctx().setHud({ title: 'Old' }, 'p2'); r.tick();
|
|
73
|
+
const before = r.sent.length;
|
|
74
|
+
const hookDone = deferred(); r.hold(hookDone);
|
|
75
|
+
const refresh = r.ctx().refreshProgress('p1');
|
|
76
|
+
assert.equal(r.opens.length, 3);
|
|
77
|
+
r.opens[2].resolve({ generation: 2, resetGeneration: 2 });
|
|
78
|
+
await flush();
|
|
79
|
+
assert.deepEqual(r.hooks.map(([id]) => id), ['p1']);
|
|
80
|
+
r.tick();
|
|
81
|
+
assert.equal(r.sent.slice(before).some(([, msg]) => msg.k === 'hub-hud'), false, 'the old HUD is withheld while the reread hook is pending');
|
|
82
|
+
hookDone.resolve(); await refresh; await flush(); r.tick();
|
|
83
|
+
assert.deepEqual(r.hooks.map(([id]) => id), ['p1', 'p2'], 'every connected id of the account was cleared');
|
|
84
|
+
assert.equal(r.ctx().progressGeneration('p2'), 2);
|
|
85
|
+
assert.equal(r.sent.slice(before).some(([, msg]) => msg.k === 'hub-hud' && msg.hud?.title === 'Old'), false);
|
|
86
|
+
assert.equal(r.sent.slice(before).filter(([, msg]) => msg.k === 'hub-hud' && msg.hud?.title === 'Fresh').length, 2);
|
|
87
|
+
|
|
88
|
+
// The later refresh wins even if an earlier platform open finishes last.
|
|
89
|
+
const earlier = r.ctx().refreshProgress('p1');
|
|
90
|
+
const later = r.ctx().refreshProgress('p1');
|
|
91
|
+
assert.equal(r.opens.length, 5);
|
|
92
|
+
r.opens[4].resolve({ generation: 3, resetGeneration: 3 });
|
|
93
|
+
await later;
|
|
94
|
+
r.opens[3].resolve({ generation: 2, resetGeneration: 2 });
|
|
95
|
+
await earlier;
|
|
96
|
+
assert.equal(r.ctx().progressGeneration('p1'), 3);
|
|
97
|
+
const noResetMarker = r.ctx().refreshProgress('p1');
|
|
98
|
+
r.opens.at(-1).resolve({ generation: 1 });
|
|
99
|
+
assert.equal(await noResetMarker, 3, 'marker-free stale handle cannot lower a confirmed reset');
|
|
100
|
+
assert.equal(r.ctx().progressGeneration('p1'), 3);
|
|
101
|
+
assert.equal(r.hooks.filter(([, generation]) => generation === 3).length, 2);
|
|
102
|
+
assert.equal(r.hooks.filter(([, generation]) => generation === 2).length, 2);
|
|
103
|
+
|
|
104
|
+
// An older hook may remain pending when another tab discovers a newer reset.
|
|
105
|
+
// Its completion cannot release either tab's newer private-frame gate or run
|
|
106
|
+
// its own remaining hooks against the now-current generation.
|
|
107
|
+
const overlap = boot();
|
|
108
|
+
overlap.hello('p1'); overlap.hello('p2');
|
|
109
|
+
overlap.opens[0].resolve({ generation: 1 }); overlap.opens[1].resolve({ generation: 1 });
|
|
110
|
+
await flush();
|
|
111
|
+
const oldHook = deferred(); overlap.hold(oldHook);
|
|
112
|
+
const oldRefresh = overlap.ctx().refreshProgress('p1');
|
|
113
|
+
overlap.opens[2].resolve({ generation: 2, resetGeneration: 2 });
|
|
114
|
+
await flush();
|
|
115
|
+
const newHook = deferred(); overlap.hold(newHook);
|
|
116
|
+
const newRefresh = overlap.ctx().refreshProgress('p2');
|
|
117
|
+
overlap.opens[3].resolve({ generation: 3, resetGeneration: 3 });
|
|
118
|
+
await flush();
|
|
119
|
+
oldHook.resolve(); await flush();
|
|
120
|
+
assert.equal(overlap.ctx().progressPending(), true, 'old hook must not release the newer gate');
|
|
121
|
+
assert.deepEqual(overlap.hooks.filter(([, gen]) => gen === 2).map(([id]) => id), ['p1']);
|
|
122
|
+
newHook.resolve(); await Promise.all([oldRefresh, newRefresh]);
|
|
123
|
+
assert.deepEqual(overlap.hooks.filter(([, gen]) => gen === 3).map(([id]) => id), ['p1', 'p2']);
|
|
124
|
+
assert.equal(overlap.ctx().progressPending(), false);
|
|
125
|
+
|
|
126
|
+
// Superseding an in-flight reset retires only the obsolete generation lock.
|
|
127
|
+
// The older hook may remain hung after the newer hook is fully applied.
|
|
128
|
+
const hungHook = boot();
|
|
129
|
+
hungHook.hello('p1'); hungHook.opens[0].resolve({ generation: 1 }); await flush();
|
|
130
|
+
const obsoleteHook = deferred(); hungHook.hold(obsoleteHook);
|
|
131
|
+
const obsoleteReset = hungHook.ctx().refreshProgress('p1');
|
|
132
|
+
hungHook.opens[1].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
133
|
+
const newestHook = deferred(); hungHook.hold(newestHook);
|
|
134
|
+
const newestReset = hungHook.ctx().refreshProgress('p1');
|
|
135
|
+
hungHook.opens[2].resolve({ generation: 3, resetGeneration: 3 }); await flush();
|
|
136
|
+
assert.equal(hungHook.ctx().progressPending(), true);
|
|
137
|
+
newestHook.resolve(); await newestReset;
|
|
138
|
+
assert.equal(hungHook.ctx().progressPending(), false, 'hung obsolete hook cannot pin generation 3');
|
|
139
|
+
obsoleteHook.resolve(); await obsoleteReset;
|
|
140
|
+
assert.equal(hungHook.ctx().progressPending(), false);
|
|
141
|
+
|
|
142
|
+
// A newer marker discovered by a different tab also retires the old hook's
|
|
143
|
+
// initiating read lock. Its promise may stay hung after generation 3 applies.
|
|
144
|
+
const crossTab = boot();
|
|
145
|
+
crossTab.hello('p1'); crossTab.hello('p2');
|
|
146
|
+
crossTab.opens[0].resolve({ generation: 1 }); crossTab.opens[1].resolve({ generation: 1 }); await flush();
|
|
147
|
+
const oldTabHook = deferred(); crossTab.hold(oldTabHook);
|
|
148
|
+
const oldTabReset = crossTab.ctx().refreshProgress('p1');
|
|
149
|
+
crossTab.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
150
|
+
const newTabHook = deferred(); crossTab.hold(newTabHook);
|
|
151
|
+
const newTabReset = crossTab.ctx().refreshProgress('p2');
|
|
152
|
+
crossTab.opens[3].resolve({ generation: 3, resetGeneration: 3 }); await flush();
|
|
153
|
+
newTabHook.resolve(); await newTabReset;
|
|
154
|
+
assert.equal(crossTab.ctx().progressPending('101'), false, 'obsolete initiating request cannot pin all tabs');
|
|
155
|
+
oldTabHook.resolve(); await oldTabReset;
|
|
156
|
+
|
|
157
|
+
// An older marker open may answer while newer hooks are pending. It cannot
|
|
158
|
+
// replace their reset tokens or trigger another cleanup at the next hello.
|
|
159
|
+
const reversedOpens = boot();
|
|
160
|
+
reversedOpens.hello('p1'); reversedOpens.hello('p2');
|
|
161
|
+
reversedOpens.opens[0].resolve({ generation: 1 }); reversedOpens.opens[1].resolve({ generation: 1 }); await flush();
|
|
162
|
+
const olderOpen = reversedOpens.ctx().refreshProgress('p1');
|
|
163
|
+
const newestPending = deferred(); reversedOpens.hold(newestPending);
|
|
164
|
+
const newestOpen = reversedOpens.ctx().refreshProgress('p2');
|
|
165
|
+
reversedOpens.opens[3].resolve({ generation: 3, resetGeneration: 3 }); await flush();
|
|
166
|
+
reversedOpens.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await olderOpen;
|
|
167
|
+
assert.deepEqual(reversedOpens.hooks.filter(([, gen]) => gen === 2), []);
|
|
168
|
+
newestPending.resolve(); await newestOpen;
|
|
169
|
+
const beforeSameMarker = reversedOpens.hooks.length;
|
|
170
|
+
const sameMarker = reversedOpens.ctx().refreshProgress('p1');
|
|
171
|
+
reversedOpens.opens[4].resolve({ generation: 3, resetGeneration: 3 }); await sameMarker;
|
|
172
|
+
assert.equal(reversedOpens.hooks.length, beforeSameMarker);
|
|
173
|
+
|
|
174
|
+
// Once an account's hooks complete, a brand-new tab at the equal marker
|
|
175
|
+
// inherits that applied generation. It must not discard valid queued work.
|
|
176
|
+
const currentWrites = new Set();
|
|
177
|
+
const newTab = boot({ onReset: () => currentWrites.clear() });
|
|
178
|
+
newTab.hello('p1'); newTab.hello('p2');
|
|
179
|
+
newTab.opens[0].resolve({ generation: 1 }); newTab.opens[1].resolve({ generation: 1 }); await flush();
|
|
180
|
+
const completedReset = newTab.ctx().refreshProgress('p1');
|
|
181
|
+
newTab.opens[2].resolve({ generation: 3, resetGeneration: 3 }); await completedReset;
|
|
182
|
+
currentWrites.add('generation-3-onboarding');
|
|
183
|
+
const resetCalls = newTab.hooks.length;
|
|
184
|
+
newTab.session.players.push(player('p3')); newTab.world.players.set('p3', body());
|
|
185
|
+
newTab.hello('p3'); newTab.opens[3].resolve({ generation: 3, resetGeneration: 3 }); await flush();
|
|
186
|
+
assert.equal(newTab.hooks.length, resetCalls, 'a new tab cannot re-run completed account cleanup');
|
|
187
|
+
assert.deepEqual([...currentWrites], ['generation-3-onboarding']);
|
|
188
|
+
|
|
189
|
+
// A new tab joining during a held account hook stays gated even after its
|
|
190
|
+
// own marker read answers; the pending account reset still owns the gate.
|
|
191
|
+
const joinedDuringReset = boot();
|
|
192
|
+
joinedDuringReset.hello('p1'); joinedDuringReset.opens[0].resolve({ generation: 1 }); await flush();
|
|
193
|
+
const heldAccount = deferred(); joinedDuringReset.hold(heldAccount);
|
|
194
|
+
const activeReset = joinedDuringReset.ctx().refreshProgress('p1');
|
|
195
|
+
joinedDuringReset.opens[1].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
196
|
+
joinedDuringReset.session.players.push(player('p3')); joinedDuringReset.world.players.set('p3', body());
|
|
197
|
+
joinedDuringReset.hello('p3'); joinedDuringReset.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
198
|
+
assert.equal(joinedDuringReset.ctx().progressPending('101'), true);
|
|
199
|
+
joinedDuringReset.tick();
|
|
200
|
+
assert.equal(joinedDuringReset.sent.some(([, msg]) => msg.k === 'hub-hud' && msg.hud?.title === 'Fresh'), false);
|
|
201
|
+
heldAccount.resolve(); await activeReset; await flush();
|
|
202
|
+
assert.equal(joinedDuringReset.ctx().progressPending('101'), false);
|
|
203
|
+
|
|
204
|
+
// A retained hello replaces the entry while its reset hook is pending. Its
|
|
205
|
+
// replacement must inherit the same gate until the old hook settles.
|
|
206
|
+
const replay = boot();
|
|
207
|
+
replay.hello('p1'); replay.opens[0].resolve({ generation: 1 }); await flush();
|
|
208
|
+
const replayHook = deferred(); replay.hold(replayHook);
|
|
209
|
+
const replayReset = replay.ctx().refreshProgress('p1');
|
|
210
|
+
replay.opens[1].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
211
|
+
replay.hello('p1');
|
|
212
|
+
replay.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
213
|
+
assert.equal(replay.ctx().progressPending('101'), true, 'same-marker hello cannot release an active hook');
|
|
214
|
+
replay.tick();
|
|
215
|
+
assert.equal(replay.sent.some(([, msg]) => msg.k === 'hub-hud' && msg.hud?.title === 'Fresh'), false);
|
|
216
|
+
replayHook.resolve(); await replayReset; await flush();
|
|
217
|
+
assert.equal(replay.ctx().progressPending('101'), false);
|
|
218
|
+
|
|
219
|
+
// One tab can leave while another observes a reset. The old forgotten state
|
|
220
|
+
// is removed with the account reset; returning at the equal marker need not
|
|
221
|
+
// clear the already-current account cache a second time.
|
|
222
|
+
const disconnected = boot();
|
|
223
|
+
disconnected.hello('p1'); disconnected.hello('p2');
|
|
224
|
+
disconnected.opens[0].resolve({ generation: 1 }); disconnected.opens[1].resolve({ generation: 1 }); await flush();
|
|
225
|
+
disconnected.session.players = [player('p2')]; disconnected.world.players.delete('p1'); disconnected.tick();
|
|
226
|
+
const otherReset = disconnected.ctx().refreshProgress('p2');
|
|
227
|
+
disconnected.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await otherReset;
|
|
228
|
+
disconnected.session.players = [player('p1'), player('p2')]; disconnected.world.players.set('p1', body());
|
|
229
|
+
disconnected.hello('p1'); disconnected.opens[3].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
230
|
+
assert.deepEqual(disconnected.hooks.filter(([id, gen]) => id === 'p1' && gen === 2), []);
|
|
231
|
+
assert.equal(disconnected.ctx().progressGeneration('p1'), 2);
|
|
232
|
+
|
|
233
|
+
// A town with the hook but no reset marker emits exactly the original wire
|
|
234
|
+
// sequence. The kit checks its own progress even without a place hook.
|
|
235
|
+
const legacy = boot({ hook: false }), optIn = boot();
|
|
236
|
+
legacy.hello('p1'); optIn.hello('p1');
|
|
237
|
+
assert.equal(legacy.opens.length, 1);
|
|
238
|
+
legacy.opens[0].resolve({ generation: 1 }); optIn.opens[0].resolve({ generation: 1 });
|
|
239
|
+
await flush(); legacy.tick(); optIn.tick();
|
|
240
|
+
assert.deepEqual(optIn.sent, legacy.sent);
|
|
241
|
+
assert.deepEqual(optIn.hooks, []);
|
|
242
|
+
|
|
243
|
+
legacy.ctx().setHud({ title: 'Old' }, 'p1'); legacy.tick();
|
|
244
|
+
const noHookBefore = legacy.sent.length;
|
|
245
|
+
const noHookRefresh = legacy.ctx().refreshProgress('p1');
|
|
246
|
+
legacy.opens[1].resolve({ generation: 2, resetGeneration: 2 });
|
|
247
|
+
await noHookRefresh; legacy.tick();
|
|
248
|
+
assert.equal(legacy.ctx().progressGeneration('p1'), 2);
|
|
249
|
+
assert.equal(legacy.sent.slice(noHookBefore).some(([, msg]) => msg.k === 'hub-hud' && msg.hud?.title === 'Old'), false);
|
|
250
|
+
|
|
251
|
+
// An ended resume place still repeats its exact end frame after an absent
|
|
252
|
+
// marker opens. A newer reset cancels that queued replay.
|
|
253
|
+
for (const reset of [false, true]) {
|
|
254
|
+
const ended = boot({ resumePlace: true });
|
|
255
|
+
ended.hello('p1'); ended.opens[0].resolve({ generation: 1 }); await flush(); ended.tick();
|
|
256
|
+
ended.ctx().end(['p1']);
|
|
257
|
+
const from = ended.sent.length;
|
|
258
|
+
ended.hello('p1', { resume: true });
|
|
259
|
+
assert.deepEqual(ended.sent.slice(from).filter(([, msg]) => msg.k === 'hub-end'), []);
|
|
260
|
+
ended.opens[1].resolve(reset ? { generation: 2, resetGeneration: 2 } : { generation: 1 });
|
|
261
|
+
await flush();
|
|
262
|
+
assert.deepEqual(ended.sent.slice(from).filter(([, msg]) => msg.k === 'hub-end').map(([, msg]) => msg),
|
|
263
|
+
reset ? [] : [{ k: 'hub-end', why: 'end', again: true }]);
|
|
264
|
+
}
|
|
265
|
+
const supersededEnd = boot({ resumePlace: true });
|
|
266
|
+
supersededEnd.hello('p1'); supersededEnd.opens[0].resolve({ generation: 1 }); await flush(); supersededEnd.tick();
|
|
267
|
+
supersededEnd.ctx().end(['p1']);
|
|
268
|
+
const oldEndRead = supersededEnd.ctx().refreshProgress('p1');
|
|
269
|
+
const endFrom = supersededEnd.sent.length;
|
|
270
|
+
supersededEnd.hello('p1', { resume: true });
|
|
271
|
+
assert.deepEqual(supersededEnd.sent.slice(endFrom).filter(([, msg]) => msg.k === 'hub-end'), [], 'superseding a read cannot briefly release the end replay');
|
|
272
|
+
supersededEnd.opens[2].resolve({ generation: 1 }); await flush();
|
|
273
|
+
assert.deepEqual(supersededEnd.sent.slice(endFrom).filter(([, msg]) => msg.k === 'hub-end').map(([, msg]) => msg), [{ k: 'hub-end', why: 'end', again: true }]);
|
|
274
|
+
supersededEnd.opens[1].resolve({ generation: 1 }); await oldEndRead;
|
|
275
|
+
|
|
276
|
+
const retained = boot();
|
|
277
|
+
retained.hello('p1'); retained.opens[0].resolve({ generation: 1 }); await flush();
|
|
278
|
+
retained.ctx().setHud({ title: 'Old' }, 'p1'); retained.tick();
|
|
279
|
+
const retainedBefore = retained.sent.length;
|
|
280
|
+
retained.hello('p1'); retained.tick();
|
|
281
|
+
assert.equal(retained.sent.slice(retainedBefore).some(([, msg]) => msg.k === 'hub-hud'), false,
|
|
282
|
+
'retained hello waits for marker before replaying its private HUD');
|
|
283
|
+
retained.opens[1].resolve({ generation: 2, resetGeneration: 2 });
|
|
284
|
+
await flush(); retained.tick();
|
|
285
|
+
assert.equal(retained.sent.slice(retainedBefore).some(([, msg]) => msg.k === 'hub-hud' && msg.hud?.title === 'Old'), false);
|
|
286
|
+
|
|
287
|
+
const failed = boot({ failOnce: true });
|
|
288
|
+
failed.hello('p1'); failed.hello('p2');
|
|
289
|
+
failed.opens[0].resolve({ generation: 1 }); failed.opens[1].resolve({ generation: 1 });
|
|
290
|
+
await flush();
|
|
291
|
+
const failedRefresh = failed.ctx().refreshProgress('p1');
|
|
292
|
+
failed.opens[2].resolve({ generation: 2, resetGeneration: 2 });
|
|
293
|
+
await failedRefresh;
|
|
294
|
+
assert.equal(failed.ctx().progressPending(), true, 'failed reread keeps the private frame closed');
|
|
295
|
+
const retryDone = deferred(); failed.hold(retryDone);
|
|
296
|
+
const retryRefresh = failed.ctx().refreshProgress('p2');
|
|
297
|
+
failed.opens[3].resolve({ generation: 2, resetGeneration: 2 });
|
|
298
|
+
await flush();
|
|
299
|
+
assert.equal(failed.ctx().progressPending(), true, 'equal-generation retry waits for a new reread');
|
|
300
|
+
retryDone.resolve(); await retryRefresh;
|
|
301
|
+
assert.equal(failed.ctx().progressPending(), false);
|
|
302
|
+
assert.deepEqual(failed.hooks.filter(([, gen]) => gen === 2).map(([id]) => id), ['p1', 'p2', 'p1', 'p2']);
|
|
303
|
+
|
|
304
|
+
// Retrying a failed hook at the same marker does not repeat kit cleanup. A
|
|
305
|
+
// post-reset platform read that already completed remains the current state.
|
|
306
|
+
const completedRetry = boot({ platform: true, failOnce: true, unlocks: [localUnlock] });
|
|
307
|
+
completedRetry.hello('p1'); completedRetry.opens[0].resolve({ generation: 1 }); await flush();
|
|
308
|
+
completedRetry.tick();
|
|
309
|
+
completedRetry.platformReads[0].resolve({ players: { 101: { recent: [], records: [], wearable: null } } }); await flush();
|
|
310
|
+
const firstAttempt = completedRetry.ctx().refreshProgress('p1');
|
|
311
|
+
completedRetry.opens[1].resolve({ generation: 2, resetGeneration: 2 }); await firstAttempt;
|
|
312
|
+
completedRetry.tick();
|
|
313
|
+
const freshWear = { kind: 'halo', color: '#224466', rarity: 3 };
|
|
314
|
+
const freshEarned = { deckId: 'fresh-deck', ...localUnlock };
|
|
315
|
+
completedRetry.platformReads[1].resolve({ players: { 101: { recent: [{ title: 'Fresh result' }], records: [], wearable: freshWear, earned: freshEarned } } });
|
|
316
|
+
await flush();
|
|
317
|
+
const completedAgain = completedRetry.ctx().refreshProgress('p1');
|
|
318
|
+
completedRetry.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await completedAgain;
|
|
319
|
+
assert.equal(completedRetry.ctx().results('p1')?.recent[0]?.title, 'Fresh result');
|
|
320
|
+
assert.deepEqual(completedRetry.ctx().wearing('p1'), freshWear);
|
|
321
|
+
assert.deepEqual(completedRetry.ctx().earned('p1'), freshEarned);
|
|
322
|
+
|
|
323
|
+
// The equal-marker retry also leaves a pending post-reset read on its original
|
|
324
|
+
// revision capture, so choices made after it began still win when it answers.
|
|
325
|
+
const pendingRetry = boot({ platform: true, failOnce: true, unlocks: [localUnlock] });
|
|
326
|
+
pendingRetry.hello('p1'); pendingRetry.opens[0].resolve({ generation: 1 }); await flush();
|
|
327
|
+
pendingRetry.tick();
|
|
328
|
+
pendingRetry.platformReads[0].resolve({ players: { 101: { recent: [], records: [], wearable: null } } }); await flush();
|
|
329
|
+
const pendingFirst = pendingRetry.ctx().refreshProgress('p1');
|
|
330
|
+
pendingRetry.opens[1].resolve({ generation: 2, resetGeneration: 2 }); await pendingFirst;
|
|
331
|
+
pendingRetry.tick();
|
|
332
|
+
const chosenWear = { kind: 'orbit', color: '#113355', rarity: 4 };
|
|
333
|
+
assert.equal(pendingRetry.ctx().wear('p1', chosenWear), true);
|
|
334
|
+
await pendingRetry.ctx().unlock('p1', localUnlock.id);
|
|
335
|
+
const pendingAgain = pendingRetry.ctx().refreshProgress('p1');
|
|
336
|
+
pendingRetry.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await pendingAgain;
|
|
337
|
+
pendingRetry.platformReads[1].resolve({ players: { 101: {
|
|
338
|
+
recent: [{ title: 'Pending result' }], records: [],
|
|
339
|
+
wearable: { kind: 'aura', color: '#ff0000', rarity: 1 },
|
|
340
|
+
earned: { deckId: 'old-deck', id: 'old-badge', class: 'badge', shape: 'badge-round', name: 'Old Badge', deed: 'from before', color: '#ff0000' },
|
|
341
|
+
} } });
|
|
342
|
+
await flush();
|
|
343
|
+
assert.equal(pendingRetry.ctx().results('p1')?.recent[0]?.title, 'Pending result');
|
|
344
|
+
assert.deepEqual(pendingRetry.ctx().wearing('p1'), chosenWear);
|
|
345
|
+
assert.deepEqual(pendingRetry.ctx().earned('p1'), { deckId: 'saved-test', ...localUnlock });
|
|
346
|
+
|
|
347
|
+
const readFailure = boot();
|
|
348
|
+
readFailure.hello('p1');
|
|
349
|
+
readFailure.opens[0].reject(Error('platform unavailable'));
|
|
350
|
+
await flush();
|
|
351
|
+
assert.equal(readFailure.ctx().progressPending(), true, 'a failed marker read cannot release old progress');
|
|
352
|
+
assert.equal(readFailure.ctx().progressGeneration('p1'), null, 'failed open never establishes zero');
|
|
353
|
+
const recovered = readFailure.ctx().refreshProgress('p1');
|
|
354
|
+
readFailure.opens[1].resolve({ generation: 1 });
|
|
355
|
+
await recovered;
|
|
356
|
+
assert.equal(readFailure.ctx().progressPending(), false);
|
|
357
|
+
assert.equal(readFailure.ctx().progressGeneration('p1'), 0);
|
|
358
|
+
|
|
359
|
+
for (const value of [undefined, null, {}, { generation: 0 }, { generation: 1, resetGeneration: -1 }, { generation: 1, resetGeneration: '1' }]) {
|
|
360
|
+
const absent = boot(); absent.hello('p1'); absent.opens[0].resolve(value); await flush();
|
|
361
|
+
assert.equal(absent.ctx().progressGeneration('p1'), null, 'absent or invalid handle stays unknown');
|
|
362
|
+
assert.equal(absent.ctx().progressPending(), true);
|
|
363
|
+
assert.deepEqual(absent.hooks, []);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// A failed tab's marker lock gates its account, but leaving removes that
|
|
367
|
+
// account block immediately for a healthy tab that remains connected.
|
|
368
|
+
const departingFailure = boot();
|
|
369
|
+
departingFailure.hello('p1'); departingFailure.hello('p2');
|
|
370
|
+
departingFailure.opens[0].reject(Error('platform unavailable'));
|
|
371
|
+
departingFailure.opens[1].resolve({ generation: 1 }); await flush();
|
|
372
|
+
assert.equal(departingFailure.ctx().progressPending('101'), true);
|
|
373
|
+
departingFailure.session.players = [player('p2')]; departingFailure.world.players.delete('p1'); departingFailure.tick();
|
|
374
|
+
assert.equal(departingFailure.ctx().progressPending('101'), false);
|
|
375
|
+
|
|
376
|
+
// A never-settling marker open cannot pin the gate after a newer explicit
|
|
377
|
+
// refresh succeeds. Retiring its read token leaves reset/hook locks intact.
|
|
378
|
+
const hungOpen = boot();
|
|
379
|
+
hungOpen.hello('p1');
|
|
380
|
+
const freshOpen = hungOpen.ctx().refreshProgress('p1');
|
|
381
|
+
hungOpen.opens[1].resolve({ generation: 1 }); await freshOpen;
|
|
382
|
+
assert.equal(hungOpen.ctx().progressPending(), false);
|
|
383
|
+
hungOpen.opens[0].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
384
|
+
assert.equal(hungOpen.ctx().progressGeneration('p1'), 0, 'obsolete reset cannot replace observed zero');
|
|
385
|
+
assert.deepEqual(hungOpen.hooks, []);
|
|
386
|
+
|
|
387
|
+
// Reset bumps the read epoch. A retained hello must carry that epoch forward;
|
|
388
|
+
// otherwise an older platform result can be accepted into its replacement.
|
|
389
|
+
const staleRead = boot({ platform: true });
|
|
390
|
+
staleRead.hello('p1'); staleRead.opens[0].resolve({ generation: 1 });
|
|
391
|
+
await flush(); staleRead.tick();
|
|
392
|
+
assert.equal(staleRead.platformReads.length, 1);
|
|
393
|
+
const marker = staleRead.ctx().refreshProgress('p1');
|
|
394
|
+
staleRead.opens[1].resolve({ generation: 2, resetGeneration: 2 });
|
|
395
|
+
await marker;
|
|
396
|
+
staleRead.hello('p1'); staleRead.opens[2].resolve({ generation: 2, resetGeneration: 2 });
|
|
397
|
+
await flush();
|
|
398
|
+
staleRead.platformReads[0].resolve({ players: { 101: { avatar: 9, avatarColor: 3, recent: [{ title: 'Old' }] } } });
|
|
399
|
+
await flush();
|
|
400
|
+
assert.equal(staleRead.ctx().results('p1'), null, 'the pre-reset read cannot enter the retained entry');
|
|
401
|
+
assert.equal(staleRead.snapshot().hubAv2, undefined);
|
|
402
|
+
assert.equal(staleRead.snapshot().hubAvC, undefined);
|
|
403
|
+
staleRead.tick();
|
|
404
|
+
assert.equal(staleRead.platformReads.length, 2);
|
|
405
|
+
staleRead.platformReads[1].resolve({ players: { 101: { recent: [{ title: 'Fresh' }] } } });
|
|
406
|
+
await flush();
|
|
407
|
+
assert.equal(staleRead.ctx().results('p1')?.recent[0]?.title, 'Fresh');
|
|
408
|
+
|
|
409
|
+
// The same stable read lifetime owns cosmetic revisions. Replacement hellos
|
|
410
|
+
// cannot make an older platform reply overwrite choices made after it began.
|
|
411
|
+
const choices = boot({ platform: true, unlocks: [localUnlock] });
|
|
412
|
+
choices.hello('p1'); choices.opens[0].resolve({ generation: 1 }); await flush();
|
|
413
|
+
choices.tick();
|
|
414
|
+
const localWear = { kind: 'halo', color: '#112233', rarity: 2 };
|
|
415
|
+
assert.equal(choices.ctx().wear('p1', localWear), true);
|
|
416
|
+
await choices.ctx().unlock('p1', localUnlock.id);
|
|
417
|
+
choices.hello('p1'); choices.hello('p1');
|
|
418
|
+
choices.opens.at(-1).resolve({ generation: 1 }); await flush();
|
|
419
|
+
choices.platformReads[0].resolve({ players: { 101: {
|
|
420
|
+
recent: [], records: [],
|
|
421
|
+
wearable: { kind: 'aura', color: '#ff0000', rarity: 1 },
|
|
422
|
+
earned: { deckId: 'old-deck', id: 'old-badge', class: 'badge', shape: 'badge-round', name: 'Old Badge', deed: 'from before', color: '#ff0000' },
|
|
423
|
+
} } });
|
|
424
|
+
await flush();
|
|
425
|
+
assert.deepEqual(choices.ctx().wearing('p1'), localWear);
|
|
426
|
+
assert.deepEqual(choices.ctx().earned('p1'), { deckId: 'saved-test', ...localUnlock });
|
|
427
|
+
|
|
428
|
+
// Forgetting an id gives its next entry a new identity even if both numeric
|
|
429
|
+
// read versions happen to be zero. The old read must not enter that entry.
|
|
430
|
+
const forgottenRead = boot({ platform: true });
|
|
431
|
+
forgottenRead.hello('p1'); forgottenRead.opens[0].resolve({ generation: 1 }); await flush();
|
|
432
|
+
forgottenRead.tick();
|
|
433
|
+
assert.equal(forgottenRead.platformReads.length, 1);
|
|
434
|
+
forgottenRead.session.players = [player('p2')]; forgottenRead.world.players.delete('p1'); forgottenRead.tick();
|
|
435
|
+
forgottenRead.session.players = [player('p1'), player('p2')]; forgottenRead.world.players.set('p1', body());
|
|
436
|
+
forgottenRead.hello('p1'); forgottenRead.opens[1].resolve({ generation: 1 }); await flush();
|
|
437
|
+
forgottenRead.platformReads[0].resolve({ players: { 101: { avatar: 9, avatarColor: 3, recent: [{ title: 'Forgotten' }] } } }); await flush();
|
|
438
|
+
assert.equal(forgottenRead.ctx().results('p1'), null);
|
|
439
|
+
assert.equal(forgottenRead.snapshot().hubAv2, undefined);
|
|
440
|
+
assert.equal(forgottenRead.snapshot().hubAvC, undefined);
|
|
441
|
+
forgottenRead.tick();
|
|
442
|
+
assert.equal(forgottenRead.platformReads.length, 2, 'new entry starts its own read after old finally');
|
|
443
|
+
forgottenRead.platformReads[1].resolve({ players: { 101: { recent: [{ title: 'Current' }] } } }); await flush();
|
|
444
|
+
assert.equal(forgottenRead.ctx().results('p1')?.recent[0]?.title, 'Current');
|
|
445
|
+
// Initial marker compatibility: denied and hung reads cannot hold arrival
|
|
446
|
+
// forever, while a later confirmed reset is still protected and applied once.
|
|
447
|
+
const realNow = Date.now;
|
|
448
|
+
let markerNow = realNow();
|
|
449
|
+
Date.now = () => markerNow;
|
|
450
|
+
try {
|
|
451
|
+
const denied = boot();
|
|
452
|
+
denied.hello('p1'); denied.opens[0].reject(Error('characters unavailable'));
|
|
453
|
+
await flush(); denied.tick();
|
|
454
|
+
assert.equal(denied.ctx().progressPending(), true);
|
|
455
|
+
assert.deepEqual(denied.snapshot().held, ['p1']);
|
|
456
|
+
markerNow += 4999; denied.tick();
|
|
457
|
+
assert.equal(denied.arrived.length, 0, 'the normal initial lock lasts until the deadline');
|
|
458
|
+
markerNow += 1; denied.tick();
|
|
459
|
+
assert.equal(denied.ctx().progressPending(), false);
|
|
460
|
+
assert.deepEqual(denied.snapshot().held, []);
|
|
461
|
+
assert.equal(denied.arrived.length, 1, 'denied marker reads fall back to ordinary arrival');
|
|
462
|
+
assert.equal(denied.opens.length, 2, 'the deadline also starts a background retry');
|
|
463
|
+
denied.opens[1].reject(Error('still unavailable')); await flush(); denied.tick();
|
|
464
|
+
assert.equal(denied.ctx().progressPending(), false, 'failed background retry does not relock arrival');
|
|
465
|
+
markerNow += 5000; denied.tick();
|
|
466
|
+
assert.equal(denied.opens.length, 2, 'a second failure doubles the wait');
|
|
467
|
+
markerNow += 5000; denied.tick();
|
|
468
|
+
assert.equal(denied.opens.length, 3);
|
|
469
|
+
const resetDone = deferred(); denied.hold(resetDone);
|
|
470
|
+
denied.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
471
|
+
assert.equal(denied.ctx().progressPending(), true, 'confirmed late reset locks while its hook runs');
|
|
472
|
+
assert.equal(denied.hooks.length, 1);
|
|
473
|
+
assert.equal(denied.hooks[0][2].arrived, true, 'late reset hook reloads an already arrived player');
|
|
474
|
+
markerNow += 10000; denied.tick();
|
|
475
|
+
assert.equal(denied.ctx().progressPending(), true, 'confirmed reset hook never uses initial fallback');
|
|
476
|
+
resetDone.resolve(); await flush(); denied.tick();
|
|
477
|
+
assert.equal(denied.ctx().progressPending(), false);
|
|
478
|
+
assert.equal(denied.arrived.length, 1, 'successful retry never repeats arrival side effects');
|
|
479
|
+
|
|
480
|
+
const hung = boot(); hung.hello('p1'); hung.tick();
|
|
481
|
+
markerNow += 5000; hung.tick();
|
|
482
|
+
assert.equal(hung.ctx().progressPending(), false);
|
|
483
|
+
assert.equal(hung.arrived.length, 1, 'a read that never settles also releases initial arrival');
|
|
484
|
+
hung.opens[0].resolve({ generation: 99, resetGeneration: 99 }); await flush();
|
|
485
|
+
assert.equal(hung.hooks.length, 0, 'superseded timed-out read cannot apply an old reset');
|
|
486
|
+
hung.opens[1].resolve({ generation: 1 }); await flush(); hung.tick();
|
|
487
|
+
assert.equal(hung.ctx().progressPending(), false);
|
|
488
|
+
const establishedRead = hung.ctx().refreshProgress('p1');
|
|
489
|
+
hung.opens[2].reject(Error('transient outage after established marker')); await establishedRead;
|
|
490
|
+
markerNow += 10000; hung.tick();
|
|
491
|
+
assert.equal(hung.ctx().progressPending(), true, 'an established marker retains normal failure protection');
|
|
492
|
+
hung.opens[3].resolve({ generation: 1 }); await flush(); hung.tick();
|
|
493
|
+
assert.equal(hung.ctx().progressPending(), false, 'established failed read also retries and recovers');
|
|
494
|
+
const tabs = boot(); tabs.hello('p1'); tabs.hello('p2');
|
|
495
|
+
tabs.opens[0].resolve({ generation: 2, resetGeneration: 2 }); await flush();
|
|
496
|
+
assert.equal(tabs.hooks.length, 2, 'one tab confirms the reset for both connected ids');
|
|
497
|
+
markerNow += 5000; tabs.tick();
|
|
498
|
+
assert.equal(tabs.ctx().progressPending(), true, 'sibling hung read stays protected after account reset');
|
|
499
|
+
tabs.opens[1].reject(Error('sibling read failed')); await flush();
|
|
500
|
+
assert.equal(tabs.ctx().progressPending(), true, 'sibling rejected read cannot re-enable unknown-marker bypass');
|
|
501
|
+
markerNow += 5000; tabs.tick();
|
|
502
|
+
tabs.opens[2].resolve({ generation: 2, resetGeneration: 2 }); await flush(); tabs.tick();
|
|
503
|
+
assert.equal(tabs.ctx().progressPending(), false);
|
|
504
|
+
assert.equal(tabs.hooks.length, 2, 'retrying sibling applies no duplicate reset');
|
|
505
|
+
|
|
506
|
+
const warn = console.warn, warned = [];
|
|
507
|
+
console.warn = (...args) => warned.push(args.join(' '));
|
|
508
|
+
try {
|
|
509
|
+
// Failed reads keep retrying, the gap doubling per player state to a
|
|
510
|
+
// cap, logged when the gap changes and at most every five minutes.
|
|
511
|
+
const backoff = boot(); backoff.hello('p1');
|
|
512
|
+
const gaps = [];
|
|
513
|
+
let last = markerNow;
|
|
514
|
+
for (let i = 0; i < 9; i++) {
|
|
515
|
+
backoff.opens.at(-1).reject(Error('platform unavailable')); await flush();
|
|
516
|
+
const count = backoff.opens.length;
|
|
517
|
+
while (backoff.opens.length === count) { markerNow += 1000; backoff.tick(); }
|
|
518
|
+
gaps.push(markerNow - last); last = markerNow;
|
|
519
|
+
}
|
|
520
|
+
assert.deepEqual(gaps, [5000, 10000, 20000, 40000, 80000, 160000, 300000, 300000, 300000]);
|
|
521
|
+
assert.equal(warned.filter((line) => line.startsWith('[hub] progress reset read failed')).length, 9);
|
|
522
|
+
const logged = warned.length;
|
|
523
|
+
for (let i = 0; i < 4; i++) {
|
|
524
|
+
const again = backoff.ctx().refreshProgress('p1'); backoff.opens.at(-1).reject(Error('platform unavailable')); await again;
|
|
525
|
+
}
|
|
526
|
+
assert.equal(warned.length, logged + 1, 'five minutes on, one more line; failures inside that are not logged');
|
|
527
|
+
// Success resets it: the next failure retries in five seconds.
|
|
528
|
+
const healed = backoff.ctx().refreshProgress('p1'); backoff.opens.at(-1).resolve({ generation: 1 }); await healed;
|
|
529
|
+
const lapse = backoff.ctx().refreshProgress('p1'); backoff.opens.at(-1).reject(Error('platform unavailable')); await lapse;
|
|
530
|
+
const count = backoff.opens.length;
|
|
531
|
+
markerNow += 4999; backoff.tick();
|
|
532
|
+
assert.equal(backoff.opens.length, count);
|
|
533
|
+
markerNow += 1; backoff.tick();
|
|
534
|
+
assert.equal(backoff.opens.length, count + 1);
|
|
535
|
+
assert.equal(warned.at(-1), '[hub] progress reset read failed (error); retrying in 5 s');
|
|
536
|
+
|
|
537
|
+
// Two tabs of one account, one failing transiently and one refused
|
|
538
|
+
// characters: both arrive at the ordinary five-second fallback, and both
|
|
539
|
+
// keep retrying in the background without holding arrival again.
|
|
540
|
+
const refusal = () => Object.assign(Error('characters are unavailable right now'), { code: 'CAULDRON_CHARACTER_UNAVAILABLE' });
|
|
541
|
+
const tabs = boot(); tabs.hello('p1'); tabs.hello('p2');
|
|
542
|
+
tabs.opens[0].reject(Error('platform unavailable')); tabs.opens[1].reject(refusal()); await flush(); tabs.tick();
|
|
543
|
+
assert.deepEqual(tabs.snapshot().held, ['p1', 'p2']);
|
|
544
|
+
markerNow += 5000; tabs.tick();
|
|
545
|
+
assert.equal(tabs.ctx().progressPending(), false);
|
|
546
|
+
assert.deepEqual(tabs.snapshot().held, []);
|
|
547
|
+
assert.equal(tabs.arrived.flat().length, 2);
|
|
548
|
+
assert.equal(tabs.opens.length, 4, 'both tabs retry');
|
|
549
|
+
tabs.opens[2].reject(refusal()); tabs.opens[3].reject(Error('platform unavailable')); await flush();
|
|
550
|
+
markerNow += 60_000; tabs.tick();
|
|
551
|
+
assert.equal(tabs.ctx().progressPending(), false);
|
|
552
|
+
assert.equal(tabs.arrived.length, 1, 'arrival is not repeated');
|
|
553
|
+
} finally {
|
|
554
|
+
console.warn = warn;
|
|
555
|
+
}
|
|
556
|
+
} finally {
|
|
557
|
+
Date.now = realNow;
|
|
558
|
+
}
|
|
559
|
+
console.log('hub progress reset: ok');
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { reportPushVisit } from '../code/client/pushVisit.js';
|
|
3
|
+
import * as Rehello from '../code/client/rehello.js';
|
|
4
|
+
const place = { push: { version: 1 } };
|
|
5
|
+
const sent = []; let user = '101', self = 'p1', incoming = [];
|
|
6
|
+
const net = { selfId: () => self, userId: () => user, send: (v) => sent.push(v), drain: () => incoming.splice(0) };
|
|
7
|
+
const mp = { joined: true };
|
|
8
|
+
const zone = () => 'Pacific/Honolulu';
|
|
9
|
+
assert.equal(reportPushVisit(new Proxy({}, { get() { throw Error('keyless access'); } }), {}, {}, null, 100, () => { throw Error('Intl touched'); }), null);
|
|
10
|
+
let previous = reportPushVisit(net, place, Rehello.mark(mp, net), null, 100, zone);
|
|
11
|
+
assert.deepEqual(sent, [{ k: 'hub-push-visit', userId: '101', timezone: 'Pacific/Honolulu' }]);
|
|
12
|
+
assert.equal(reportPushVisit(net, place, Rehello.mark(mp, net), previous, 200, zone), previous);
|
|
13
|
+
incoming.push({ k: 'w' }); net.drain();
|
|
14
|
+
previous = reportPushVisit(net, place, Rehello.mark(mp, net), previous, 300, zone);
|
|
15
|
+
assert.equal(sent.length, 2, 'same-socket re-admission reports a new visit');
|
|
16
|
+
user = '102';
|
|
17
|
+
previous = reportPushVisit(net, place, Rehello.mark(mp, net), previous, 400, zone);
|
|
18
|
+
assert.equal(sent.at(-1).userId, '102');
|
|
19
|
+
self = 'p2';
|
|
20
|
+
previous = reportPushVisit(net, place, Rehello.mark(mp, net), previous, 500, zone);
|
|
21
|
+
assert.equal(sent.length, 4);
|
|
22
|
+
previous = reportPushVisit(net, place, Rehello.mark(mp, net), previous, 60501, zone);
|
|
23
|
+
assert.equal(sent.length, 5, 'foreground heartbeat keeps the visit current');
|
|
24
|
+
net.send = () => { throw Error('disconnected'); };
|
|
25
|
+
assert.equal(reportPushVisit(net, place, Rehello.mark(mp, net), previous, 130000, zone), previous);
|
|
26
|
+
console.log('push visit: keyless silence, account change, retained socket and heartbeat passed');
|