castle-web-cli 0.4.238 → 0.4.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +218 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +22 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +4 -2
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +12 -3
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +2 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +240 -8
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +8 -2
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +79 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +198 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/castle.json +4 -4
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +474 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +75 -52
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +215 -26
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +40 -15
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +854 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +437 -57
- package/kits/hub-game/docs/analytics.md +20 -3
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +80 -1
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-resync.mjs +13 -0
- package/kits/hub-game/scripts/test-role-client.mjs +10 -3
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { disguiseBody } from './disguise.js';
|
|
1
2
|
import { ensureActorModel } from './modelReady.js';
|
|
2
3
|
// Idle play (contract §6, v1.6), the client's half: the emote picker and Sit /
|
|
3
4
|
// Stand in the hub chrome, and drawing what the place says -- each player's
|
|
@@ -16,7 +17,7 @@ import { hub, simNow } from './state.js';
|
|
|
16
17
|
import { allActors } from './quality.js';
|
|
17
18
|
import { vehicleOf } from '../shared/car.js';
|
|
18
19
|
import { danceIdlePose } from '../shared/danceIdle.js';
|
|
19
|
-
import { EXPRESSION_EMOTES } from '../shared/expression.js';
|
|
20
|
+
import { EXPRESSION_EMOTES, PLACE_EMOTES } from '../shared/expression.js';
|
|
20
21
|
|
|
21
22
|
// The kit's emotes, in the picker's order, with the emoji drawn over the head.
|
|
22
23
|
// The server holds the same ids and durations (`EMOTES` in server/idle.js).
|
|
@@ -30,8 +31,12 @@ export const EMOTES = [
|
|
|
30
31
|
const EMOJI = Object.fromEntries(EMOTES);
|
|
31
32
|
export function emoteDefinition(id) {
|
|
32
33
|
if (Object.hasOwn(EMOJI, id)) { return { emoji: EMOJI[id], motion: id }; }
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const expression = hub.place?.idle?.expression
|
|
35
|
+
? (Object.hasOwn(EXPRESSION_EMOTES, id) ? { ...EXPRESSION_EMOTES[id], motion: id } : hub.place.idle.expression.roleEmotes.find((role) => role.id === id))
|
|
36
|
+
: null;
|
|
37
|
+
// v1.174: a place-only kit emote, drawn wherever it is played; a declared
|
|
38
|
+
// role of the same id keeps its own definition.
|
|
39
|
+
return expression ?? (Object.hasOwn(PLACE_EMOTES, id) ? { ...PLACE_EMOTES[id], motion: id } : null);
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
export function expressionChoices(expression, grants) {
|
|
@@ -100,6 +105,18 @@ export function emotePose(id, u, s) {
|
|
|
100
105
|
return { y: Math.abs(Math.sin(s * TAU * 2.4)) * 0.12 * e, rx: (-0.2 + Math.sin(s * TAU * 2.4) * 0.1) * e, ry: 0, rz: 0 };
|
|
101
106
|
case 'point':
|
|
102
107
|
return { y: 0, rx: 0.24 * e, ry: 0.2 * e, rz: 0 };
|
|
108
|
+
case 'yawn': {
|
|
109
|
+
// v1.174: stretch up with the head back (the yawn), then sag and droop
|
|
110
|
+
// forward and to one side with a slow nod (dozing), then settle back.
|
|
111
|
+
const stretch = Math.sin(Math.PI * Math.min(1, u / 0.45));
|
|
112
|
+
const doze = Math.sin(Math.PI * Math.min(1, Math.max(0, (u - 0.35) / 0.65)));
|
|
113
|
+
return {
|
|
114
|
+
y: (0.07 * stretch - 0.1 * doze) * e,
|
|
115
|
+
rx: (-0.3 * stretch + (0.22 + Math.sin(s * TAU * 0.5) * 0.05) * doze) * e,
|
|
116
|
+
ry: 0,
|
|
117
|
+
rz: 0.14 * doze * e,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
103
120
|
case 'spin':
|
|
104
121
|
return { y: Math.sin(Math.PI * u) * 0.2, rx: 0, ry: TAU * smooth(u), rz: 0 };
|
|
105
122
|
default:
|
|
@@ -410,6 +427,7 @@ function labels(scene, local, cam, view, project) {
|
|
|
410
427
|
const out = [];
|
|
411
428
|
const now = simNow();
|
|
412
429
|
for (const [id, actorId, e] of emoteActors(scene, local)) {
|
|
430
|
+
if (id.startsWith('emote:') && disguiseBody(scene.multiplayer?.net?.selfId?.(), id.slice(6))) {continue;}
|
|
413
431
|
const span = e.until - e.at;
|
|
414
432
|
const u = span > 0 ? (now - e.at) / span : 1;
|
|
415
433
|
const emoji = emoteDefinition(e.id)?.emoji;
|
|
@@ -24,7 +24,7 @@ export function makeInvites(api, target, route, now = () => Date.now(), notify =
|
|
|
24
24
|
let root = null, connection = null, done = null, pending = false, disposed = false;
|
|
25
25
|
let epoch = 0, attempts = 0, retryAt = 0;
|
|
26
26
|
let carriedInvite = false;
|
|
27
|
-
let identity = null;
|
|
27
|
+
let identity = null, availability = null;
|
|
28
28
|
let destination = null, landed = false, routing = false, routeDoor = null, pointerUntil = 0, pointerSince = null;
|
|
29
29
|
function close() { root?.remove(); root = null; onLayout?.(null); }
|
|
30
30
|
function askHost(read) {
|
|
@@ -158,6 +158,27 @@ export function makeInvites(api, target, route, now = () => Date.now(), notify =
|
|
|
158
158
|
const own = identity.hostUser === null ? identity.user : identity.hostUser === String(userId);
|
|
159
159
|
return own && identity.host;
|
|
160
160
|
},
|
|
161
|
+
// v1.188 Character-only read: one attempt per scene, socket and identity.
|
|
162
|
+
// Other invite entry points keep the canInvite/share behavior above.
|
|
163
|
+
inviteAvailable(scene, net, active = () => true) {
|
|
164
|
+
if (scene.data?.engine?.hubInviteRail !== true) {return false;}
|
|
165
|
+
const playerId = net?.selfId?.(), userId = net?.userId?.(playerId), data = scene.data;
|
|
166
|
+
const current = () => !disposed && active() && scene.data === data && scene.multiplayer?.net === net &&
|
|
167
|
+
!net?.closed?.() && net?.selfId?.() === playerId && net?.userId?.(playerId) === userId;
|
|
168
|
+
if (!current() || !/^[1-9]\d{0,9}$/.test(String(userId ?? ''))) {availability = null; return false;}
|
|
169
|
+
if (availability?.scene !== scene || availability.data !== data || availability.net !== net ||
|
|
170
|
+
availability.playerId !== playerId || availability.userId !== userId) {
|
|
171
|
+
const read = availability = { scene, data, net, playerId, userId, available: false };
|
|
172
|
+
Promise.resolve().then(() => {
|
|
173
|
+
if (availability !== read || !current() || scene.data.engine.hubInviteRail !== true) {return;}
|
|
174
|
+
return api.inviteAvailable?.();
|
|
175
|
+
}).then((answer) => {
|
|
176
|
+
if (availability !== read || !current() || scene.data.engine.hubInviteRail !== true) {return;}
|
|
177
|
+
read.available = answer?.status === 'ok' && answer.available === true;
|
|
178
|
+
}).catch(() => {});
|
|
179
|
+
}
|
|
180
|
+
return availability.available;
|
|
181
|
+
},
|
|
161
182
|
open() { void createShare(); },
|
|
162
183
|
frame(net, beforeHello = false) {
|
|
163
184
|
if (disposed || !net?.selfId?.()) {return;}
|
|
@@ -234,7 +255,7 @@ export function makeInvites(api, target, route, now = () => Date.now(), notify =
|
|
|
234
255
|
}
|
|
235
256
|
return null;
|
|
236
257
|
},
|
|
237
|
-
reset() { identity = null; epoch++; connection = null; done = null; pending = false; attempts = 0; retryAt = 0; destination = null; routing = false; carriedInvite = false; close(); },
|
|
238
|
-
dispose() { identity = null; epoch++; disposed = true; unwatchViewport(); close(); },
|
|
258
|
+
reset() { identity = null; availability = null; epoch++; connection = null; done = null; pending = false; attempts = 0; retryAt = 0; destination = null; routing = false; carriedInvite = false; close(); },
|
|
259
|
+
dispose() { identity = null; availability = null; epoch++; disposed = true; unwatchViewport(); close(); },
|
|
239
260
|
};
|
|
240
261
|
}
|
|
@@ -36,6 +36,21 @@ export function swallowsScroll(event) {
|
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// The keys an untouched talk field lets through to the game (`chrome.js`): the
|
|
40
|
+
// ones that walk and jump, pressed alone. Shift with a letter is a capital, and
|
|
41
|
+
// the field's.
|
|
42
|
+
const WALK_KEYS = new Set(['KeyW', 'KeyA', 'KeyS', 'KeyD', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Space']);
|
|
43
|
+
|
|
44
|
+
export function walkKey(event) {
|
|
45
|
+
return WALK_KEYS.has(event.code) && !event.isComposing && event.keyCode !== 229 &&
|
|
46
|
+
!(event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// A walk key's release always goes on: it may have been pressed before the
|
|
50
|
+
// field took focus, and a release the game never sees leaves the avatar
|
|
51
|
+
// walking. A release only ever lets go.
|
|
52
|
+
export const walkRelease = (event) => event.type === 'keyup' && WALK_KEYS.has(event.code);
|
|
53
|
+
|
|
39
54
|
// Installs the guard on `win`; returns its removal.
|
|
40
55
|
export function guardScrollKeys(win = globalThis) {
|
|
41
56
|
const onKey = (event) => {
|
|
@@ -228,7 +228,14 @@ export function chromeItem(id, text, speech, npc, box, opacity) {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
// A private goal can project a server-supplied point without moving any actor.
|
|
231
|
-
|
|
231
|
+
// v1.201: `at: "self"` projects this player's own avatar (`selfAt`, its
|
|
232
|
+
// predicted Transform), `rise` metres up; with no avatar it is not drawn.
|
|
233
|
+
export function goalAt(label, actorAt, selfAt) {
|
|
234
|
+
if (label.style === 'goal' && label.at === 'self') {
|
|
235
|
+
const rise = Number.isFinite(label.rise) ? Math.min(Math.max(label.rise, 0), 4) : 0;
|
|
236
|
+
return selfAt && ['x', 'y', 'z'].every((key) => Number.isFinite(selfAt[key]))
|
|
237
|
+
? { x: selfAt.x, y: selfAt.y + rise, z: selfAt.z } : null;
|
|
238
|
+
}
|
|
232
239
|
return label.style === 'goal' && label.at && ['x', 'y', 'z'].every((key) => Number.isFinite(label.at[key]))
|
|
233
240
|
? label.at : actorAt;
|
|
234
241
|
}
|
|
@@ -105,11 +105,21 @@ function layoutChanged(node, previous) {
|
|
|
105
105
|
// observer saw: inherited changes above a source and late font metrics.
|
|
106
106
|
const REFRESH_FRAMES = 30;
|
|
107
107
|
|
|
108
|
+
// Everything inline a node's own layout can come from, for a stand-in sample
|
|
109
|
+
// that must end the moment anything touches the node.
|
|
110
|
+
export const surfacePrint = (node) => {
|
|
111
|
+
const style = node.style ?? {};
|
|
112
|
+
return [node.textContent, node.className, 'cssText' in style ? style.cssText : JSON.stringify(style)].join('\u0001');
|
|
113
|
+
};
|
|
114
|
+
|
|
108
115
|
export function makeLayoutCache() {
|
|
109
116
|
const sources = new Map(), snapshot = new Map(), dirty = new Set(), descendants = new Set(), structural = new Set();
|
|
110
117
|
// Sources mutated since their stored layoutState; only a fresh sample clears it.
|
|
111
118
|
const unsampled = new Set();
|
|
112
|
-
|
|
119
|
+
// Stand-in samples, until the node changes or the frame ends. One with a
|
|
120
|
+
// release callback stands for a DOM state its owner must restore first.
|
|
121
|
+
const held = new Map();
|
|
122
|
+
let active = false, viewport, frame = 0, reconnect = false, fontEpoch = 0;
|
|
113
123
|
function changedChildren(node) {
|
|
114
124
|
for (const child of node.children ?? []) {
|
|
115
125
|
if (sources.has(child)) {descendants.add(child);}
|
|
@@ -145,7 +155,7 @@ export function makeLayoutCache() {
|
|
|
145
155
|
reconnect = false;
|
|
146
156
|
}
|
|
147
157
|
const fonts = globalThis.document?.fonts;
|
|
148
|
-
const fontsLoaded = () => snapshot.clear();
|
|
158
|
+
const fontsLoaded = () => {snapshot.clear(); fontEpoch += 1;};
|
|
149
159
|
fonts?.addEventListener?.('loadingdone', fontsLoaded);
|
|
150
160
|
const view = () => active ? viewport : { w: globalThis.window?.innerWidth, h: globalThis.window?.innerHeight };
|
|
151
161
|
function register(node, options = {}) {
|
|
@@ -158,7 +168,7 @@ export function makeLayoutCache() {
|
|
|
158
168
|
}
|
|
159
169
|
function forget(node) {
|
|
160
170
|
if (sources.delete(node)) {reconnect = true;}
|
|
161
|
-
snapshot.delete(node); dirty.delete(node); descendants.delete(node); structural.delete(node); unsampled.delete(node);
|
|
171
|
+
snapshot.delete(node); dirty.delete(node); descendants.delete(node); structural.delete(node); unsampled.delete(node); held.delete(node);
|
|
162
172
|
for (const child of node.children ?? []) {forget(child);}
|
|
163
173
|
}
|
|
164
174
|
// Release observer membership as soon as a surface leaves, once per call.
|
|
@@ -169,13 +179,13 @@ export function makeLayoutCache() {
|
|
|
169
179
|
}
|
|
170
180
|
// An observed source with no mutation since its last layout sample keeps
|
|
171
181
|
// that sample's copy and inline styles; only geometry is read again.
|
|
172
|
-
function measure(node, previous) {
|
|
182
|
+
function measure(node, previous, aside = false) {
|
|
173
183
|
const shown = displayed(node);
|
|
174
184
|
const box = shown ? node.getBoundingClientRect() : { left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0 };
|
|
175
185
|
const options = sources.get(node);
|
|
176
186
|
const style = node.style ?? {};
|
|
177
187
|
const reuse = shown && observer && previous?.layout && !unsampled.has(node);
|
|
178
|
-
if (shown && !reuse) {unsampled.delete(node);}
|
|
188
|
+
if (shown && !reuse && !aside) {unsampled.delete(node);}
|
|
179
189
|
const measured = {
|
|
180
190
|
rect: { left: box.left, right: box.right, top: box.top, bottom: box.bottom, width: box.width, height: box.height },
|
|
181
191
|
size: { w: shown ? node.offsetWidth : 0, h: shown ? node.offsetHeight : 0 },
|
|
@@ -192,6 +202,25 @@ export function makeLayoutCache() {
|
|
|
192
202
|
}
|
|
193
203
|
return measured;
|
|
194
204
|
}
|
|
205
|
+
function letGo(node) {
|
|
206
|
+
const entry = held.get(node);
|
|
207
|
+
held.delete(node);
|
|
208
|
+
if (entry?.release) {snapshot.delete(node); entry.release();}
|
|
209
|
+
}
|
|
210
|
+
function holding(node) {
|
|
211
|
+
const entry = held.get(node);
|
|
212
|
+
if (!entry) {return false;}
|
|
213
|
+
if (snapshot.has(node) && displayed(node) && surfacePrint(node) === entry.print) {
|
|
214
|
+
// `check` runs once, at the first read, where a restore's fresh sample
|
|
215
|
+
// would have been taken.
|
|
216
|
+
const check = entry.check;
|
|
217
|
+
entry.check = null;
|
|
218
|
+
if (!check || check()) {return true;}
|
|
219
|
+
}
|
|
220
|
+
letGo(node);
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
const letAllGo = () => {for (const node of [...held.keys()]) {letGo(node);}};
|
|
195
224
|
function used(node) {
|
|
196
225
|
if (!sources.has(node)) {register(node);}
|
|
197
226
|
sources.get(node).readFrame = frame;
|
|
@@ -199,6 +228,7 @@ export function makeLayoutCache() {
|
|
|
199
228
|
}
|
|
200
229
|
function read(node) {
|
|
201
230
|
used(node); changes();
|
|
231
|
+
if (holding(node)) {dirty.delete(node); structural.delete(node); return snapshot.get(node);}
|
|
202
232
|
const options = sources.get(node);
|
|
203
233
|
let measured = snapshot.get(node);
|
|
204
234
|
const shown = displayed(node);
|
|
@@ -213,8 +243,27 @@ export function makeLayoutCache() {
|
|
|
213
243
|
return measured;
|
|
214
244
|
}
|
|
215
245
|
return {
|
|
216
|
-
register, unregister, invalidate: (node) => snapshot.delete(node), view, active: () => active,
|
|
246
|
+
register, unregister, invalidate: (node) => {snapshot.delete(node); held.delete(node);}, view, active: () => active,
|
|
247
|
+
// Serve `measured` for an unpositioned node until the node changes or
|
|
248
|
+
// `check` fails; `release` (when given) runs before it is measured again.
|
|
249
|
+
hold(node, measured, release, check) {
|
|
250
|
+
if (!active || !measured || sources.get(used(node))?.positioned) {return false;}
|
|
251
|
+
snapshot.set(node, { ...measured, frame, layout: layoutState(node) });
|
|
252
|
+
held.set(node, { release, check, print: surfacePrint(node) });
|
|
253
|
+
return true;
|
|
254
|
+
},
|
|
255
|
+
// A sample of the node as it is now, leaving the snapshot as it was.
|
|
256
|
+
fresh: (node) => active ? measure(used(node), undefined, true) : undefined,
|
|
257
|
+
fontEpoch: () => fontEpoch,
|
|
258
|
+
held: (node) => holding(node),
|
|
259
|
+
// This frame's sample when nothing inline has changed since it was taken.
|
|
260
|
+
sample(node) {
|
|
261
|
+
const measured = snapshot.get(node), now = active && measured?.frame === frame && measured.layout ? layoutState(node) : null;
|
|
262
|
+
return now && ['text', 'className', 'css', 'left', 'right'].every((key) => now[key] === measured.layout[key])
|
|
263
|
+
&& JSON.stringify(now.styles) === JSON.stringify(measured.layout.styles) ? measured : undefined;
|
|
264
|
+
},
|
|
217
265
|
beginFrame(nodes = []) {
|
|
266
|
+
letAllGo();
|
|
218
267
|
for (const node of nodes) {register(node);}
|
|
219
268
|
changes();
|
|
220
269
|
const next = { w: globalThis.window?.innerWidth, h: globalThis.window?.innerHeight };
|
|
@@ -235,7 +284,7 @@ export function makeLayoutCache() {
|
|
|
235
284
|
}
|
|
236
285
|
dirty.clear(); descendants.clear(); structural.clear();
|
|
237
286
|
},
|
|
238
|
-
endFrame() {active = false;},
|
|
287
|
+
endFrame() {letAllGo(); active = false;},
|
|
239
288
|
rect(node) {
|
|
240
289
|
if (!active) {return used(node).getBoundingClientRect();}
|
|
241
290
|
const measured = read(node);
|
|
@@ -259,6 +308,6 @@ export function makeLayoutCache() {
|
|
|
259
308
|
const style = globalThis.getComputedStyle?.(node) ?? node.style;
|
|
260
309
|
return Object.fromEntries(['Left', 'Right', 'Top', 'Bottom'].map((edge) => [edge.toLowerCase(), Number.parseFloat(style[`padding${edge}`]) || 0]));
|
|
261
310
|
})(),
|
|
262
|
-
dispose() {active = false; observer?.disconnect(); fonts?.removeEventListener?.('loadingdone', fontsLoaded); structural.clear(); unsampled.clear(); sources.clear(); snapshot.clear(); dirty.clear(); descendants.clear(); viewport = null;},
|
|
311
|
+
dispose() {active = false; observer?.disconnect(); fonts?.removeEventListener?.('loadingdone', fontsLoaded); structural.clear(); unsampled.clear(); held.clear(); sources.clear(); snapshot.clear(); dirty.clear(); descendants.clear(); viewport = null;},
|
|
263
312
|
};
|
|
264
313
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
// v1.126: page-owned chrome, released only by a completed world draw.
|
|
2
2
|
export let loadingCover = null;
|
|
3
|
+
// A fresh player id's arrival (a progress read, then the restored pose) may
|
|
4
|
+
// follow its placement by the server's 5 s progress wait; past this the cover
|
|
5
|
+
// lifts without it, so a place that never sends one is not kept covered.
|
|
6
|
+
export const ARRIVAL_WAIT_MS = 6000;
|
|
7
|
+
// A return's cover (any cover raised after the first load lifted) shows no
|
|
8
|
+
// words and no spinner while hidden and for this long after the page shows
|
|
9
|
+
// again, then says it is reconnecting: most returns are back sooner.
|
|
10
|
+
export const QUIET_RETURN_MS = 2500;
|
|
3
11
|
export function startLoadingCover(options) {
|
|
4
12
|
loadingCover?.dispose();
|
|
5
13
|
loadingCover = makeLoadingCover(options);
|
|
@@ -20,6 +28,7 @@ export function makeLoadingCover({ enabled, title, document: doc = globalThis.do
|
|
|
20
28
|
[data-hub-loading-cover] i { width: 36px; height: 36px; box-sizing: border-box;
|
|
21
29
|
border: 3px solid #ffffff40; border-top-color: #fff; border-radius: 50%;
|
|
22
30
|
animation: hub-loading-spin .8s linear infinite; }
|
|
31
|
+
[data-hub-loading-cover] i[hidden] { display: none; }
|
|
23
32
|
@keyframes hub-loading-spin { to { transform: rotate(360deg); } }
|
|
24
33
|
`;
|
|
25
34
|
doc.head.append(css);
|
|
@@ -30,9 +39,17 @@ export function makeLoadingCover({ enabled, title, document: doc = globalThis.do
|
|
|
30
39
|
cover.setAttribute('aria-label', `Loading ${title || 'deck'}`);
|
|
31
40
|
const text = doc.createElement('span');
|
|
32
41
|
text.textContent = title || 'Loading…';
|
|
33
|
-
|
|
42
|
+
const spinner = doc.createElement('i');
|
|
43
|
+
cover.append(text, spinner);
|
|
34
44
|
let covered = false, failed = false, binding = null, sceneNow = null;
|
|
45
|
+
// Whether the first load's cover has lifted, and since when a return's
|
|
46
|
+
// cover has been quiet (`QUIET_RETURN_MS`).
|
|
47
|
+
let lifted = false, returnAt = null;
|
|
35
48
|
let hiddenAt = null;
|
|
49
|
+
// Whether the caller still waits for this session's arrival (`sync`), held
|
|
50
|
+
// one frame past it while its clamp reaches the body, and since when a
|
|
51
|
+
// settled draw has waited on it.
|
|
52
|
+
let arriving = false, wasArriving = false, arrivalSince = null;
|
|
36
53
|
const now = () => doc.defaultView?.performance?.now?.() ?? performance.now();
|
|
37
54
|
const connected = () => sceneNow?.multiplayer?.net?.status?.()?.state === 'connected';
|
|
38
55
|
// The default player catches update/sync errors before reaching the
|
|
@@ -43,7 +60,17 @@ export function makeLoadingCover({ enabled, title, document: doc = globalThis.do
|
|
|
43
60
|
if (changes.some((change) => [...change.addedNodes].some((node) => node.nodeType === 1 &&
|
|
44
61
|
(node.style?.zIndex === '2147483000' || node.querySelector?.('[style*="z-index: 2147483000"]'))))) { fail(); }
|
|
45
62
|
}) : null;
|
|
63
|
+
// A return's cover: quiet at first, then 'Reconnecting…'.
|
|
64
|
+
function label() {
|
|
65
|
+
if (returnAt === null) { return; }
|
|
66
|
+
const quiet = doc.hidden || now() - returnAt < QUIET_RETURN_MS;
|
|
67
|
+
text.textContent = quiet ? '' : 'Reconnecting…';
|
|
68
|
+
if (quiet) { spinner.setAttribute('hidden', ''); } else { spinner.removeAttribute('hidden'); }
|
|
69
|
+
cover.setAttribute('aria-label', 'Reconnecting');
|
|
70
|
+
}
|
|
46
71
|
function show() {
|
|
72
|
+
if (lifted) { returnAt ??= now(); }
|
|
73
|
+
label();
|
|
47
74
|
covered = true;
|
|
48
75
|
doc.documentElement.setAttribute('data-hub-loading', '');
|
|
49
76
|
// Outside #root: either entry can replace its children during startup.
|
|
@@ -52,6 +79,9 @@ export function makeLoadingCover({ enabled, title, document: doc = globalThis.do
|
|
|
52
79
|
}
|
|
53
80
|
function hide() {
|
|
54
81
|
covered = false;
|
|
82
|
+
lifted = true;
|
|
83
|
+
returnAt = null;
|
|
84
|
+
arrivalSince = null;
|
|
55
85
|
cover.remove();
|
|
56
86
|
doc.documentElement.removeAttribute('data-hub-loading');
|
|
57
87
|
recovery?.disconnect();
|
|
@@ -62,7 +92,12 @@ export function makeLoadingCover({ enabled, title, document: doc = globalThis.do
|
|
|
62
92
|
// A short connected app switch needs no extra black hub cover. The
|
|
63
93
|
// engine's independent room-current gate still protects stale poses.
|
|
64
94
|
if (!connected()) {show();}
|
|
95
|
+
// A return's cover already up goes quiet with the page.
|
|
96
|
+
label();
|
|
65
97
|
} else {
|
|
98
|
+
// The quiet starts again from the page showing, words and all, before
|
|
99
|
+
// the next frame.
|
|
100
|
+
if (returnAt !== null) { returnAt = now(); label(); }
|
|
66
101
|
if (hiddenAt !== null && (now() - hiddenAt >= 30_000 || !connected())) {show();}
|
|
67
102
|
hiddenAt = null;
|
|
68
103
|
}
|
|
@@ -86,11 +121,18 @@ export function makeLoadingCover({ enabled, title, document: doc = globalThis.do
|
|
|
86
121
|
doc.defaultView?.addEventListener('error', fail);
|
|
87
122
|
show();
|
|
88
123
|
return {
|
|
89
|
-
|
|
124
|
+
// `arriving`: a fresh player id the hub has not yet seen placed by its
|
|
125
|
+
// arrival. It never raises the cover; it only keeps a raised one up.
|
|
126
|
+
sync(scene, { arriving: pending = false } = {}) {
|
|
90
127
|
sceneNow = scene;
|
|
128
|
+
arriving = pending === true || wasArriving;
|
|
129
|
+
wasArriving = pending === true;
|
|
130
|
+
if (!arriving) { arrivalSince = null; }
|
|
91
131
|
if (failed) { failed = false; show(); }
|
|
92
132
|
const mp = scene.multiplayer;
|
|
93
|
-
if (
|
|
133
|
+
if (returnAt !== null) {
|
|
134
|
+
label();
|
|
135
|
+
} else if (!mp?.joined && mp?.coverText) {
|
|
94
136
|
text.textContent = mp.coverText();
|
|
95
137
|
cover.setAttribute('aria-label', text.textContent);
|
|
96
138
|
}
|
|
@@ -128,7 +170,14 @@ export function makeLoadingCover({ enabled, title, document: doc = globalThis.do
|
|
|
128
170
|
const stopped = mp?.joinError || mp?.joinFailed || mp?.net?.status?.()?.state === 'closed';
|
|
129
171
|
// Placement also keeps initial acquisition under the cover: otherwise
|
|
130
172
|
// a pre-join draw would uncover, then the next joining frame re-cover.
|
|
131
|
-
|
|
173
|
+
// A fresh rejoin's spawn is not where the player stands: its restored
|
|
174
|
+
// pose and HUD come with the arrival, which waits ARRIVAL_WAIT_MS at most.
|
|
175
|
+
let held = false;
|
|
176
|
+
if (covered && drawn && !doc.hidden && settled && !stopped && arriving) {
|
|
177
|
+
arrivalSince ??= now();
|
|
178
|
+
held = now() - arrivalSince < ARRIVAL_WAIT_MS;
|
|
179
|
+
}
|
|
180
|
+
if (covered && drawn && !doc.hidden && (settled || stopped) && !held) { hide(); }
|
|
132
181
|
return result;
|
|
133
182
|
};
|
|
134
183
|
composer.render = wrapper;
|
|
@@ -36,6 +36,21 @@ const PATHS = {
|
|
|
36
36
|
'hard-hat': 'M4 15a8 8 0 0 1 16 0zM1 15h22v3H1zM11 7h2v4h-2z',
|
|
37
37
|
'baker-cap': 'M4 10a8 5 0 0 1 16 0v4H4zM3 14h18v3H3z',
|
|
38
38
|
};
|
|
39
|
+
// The same paths for a build script and a native icon registry: each a
|
|
40
|
+
// 24x24 single path, drawn `fill-rule="evenodd"` in the tile's tint.
|
|
41
|
+
export const MENU_ICON_PATHS = Object.freeze({ ...PATHS });
|
|
42
|
+
// Kit icons a UI tree names that are not menu silhouettes: their own view
|
|
43
|
+
// box and fills (not tinted). `companion` is the dock's companion badge,
|
|
44
|
+
// the SVG `chrome.js` draws.
|
|
45
|
+
export const KIT_ICONS = Object.freeze({
|
|
46
|
+
companion: Object.freeze({
|
|
47
|
+
viewBox: '0 0 28 28',
|
|
48
|
+
paths: Object.freeze([
|
|
49
|
+
Object.freeze({ d: 'M3 6l11 5L24 3l-5 13-7 6-2-8z', fill: '#fff6e6' }),
|
|
50
|
+
Object.freeze({ d: 'M14 11l5 5-7 6 2-11zM19 16l7 1-6 3z', fill: '#e8743b' }),
|
|
51
|
+
]),
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
39
54
|
export function menuIcon(icon) {
|
|
40
55
|
const path = PATHS[icon];
|
|
41
56
|
return path ? `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="black" fill-rule="evenodd" d="${path}"/></svg>`)}")` : null;
|
|
@@ -6,7 +6,7 @@ export function drawMenuRows({ el, sheet, scroll, spec, signal, pick }) {
|
|
|
6
6
|
const readOnly = spec.readOnly === true || item.readOnly === true;
|
|
7
7
|
const row = el(readOnly ? 'div' : 'button', {
|
|
8
8
|
width: '100%', boxSizing: 'border-box', minHeight: '32px', padding: '6px 8px',
|
|
9
|
-
display: 'grid', gridTemplateColumns: item.columns ? 'minmax(0,
|
|
9
|
+
display: 'grid', gridTemplateColumns: item.columns ? 'minmax(0, 6em) minmax(4em, 1fr) minmax(0, max-content)' : '1fr',
|
|
10
10
|
alignItems: 'center', gap: '8px', textAlign: 'left',
|
|
11
11
|
color: 'inherit', font: 'inherit', lineHeight: '20px', background: 'transparent',
|
|
12
12
|
border: '0', borderBottom: '1px solid var(--castle-border-2, rgba(255,255,255,.25))',
|
|
@@ -14,8 +14,14 @@ export function drawMenuRows({ el, sheet, scroll, spec, signal, pick }) {
|
|
|
14
14
|
}, scroll);
|
|
15
15
|
row.dataset.menuRow = '';
|
|
16
16
|
row.dataset.id = item.id;
|
|
17
|
+
// The outer columns break between words where they can, so a narrow
|
|
18
|
+
// sheet (a phone held sideways) does not split a short name: the left
|
|
19
|
+
// one is a steady 6em so the middles line up, the right one takes its
|
|
20
|
+
// own width, and both shrink rather than overflow. The middle column
|
|
21
|
+
// keeps at least 4em, gets the rest and wraps anywhere.
|
|
17
22
|
for (const [index, text] of (item.columns ?? [item.label]).entries()) {
|
|
18
|
-
|
|
23
|
+
const outer = item.columns && index !== 1;
|
|
24
|
+
el('span', { minWidth: '0', whiteSpace: 'normal', ...(outer ? { overflowWrap: 'break-word' } : {}), ...(index === 2 ? { textAlign: 'right' } : {}) }, row).textContent = text;
|
|
19
25
|
}
|
|
20
26
|
if (!readOnly) {
|
|
21
27
|
row.type = 'button';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// The place menu surface: the menu sheet (`menuTree.js`) with the behaviour
|
|
2
|
+
// `chrome.js` `setMenu` gives it in the DOM -- one sheet per offer, a newer
|
|
3
|
+
// offer replacing it, an older one ignored, Close / Esc / Back telling the
|
|
4
|
+
// place `close` -- published as the `menu` UI tree root. No DOM and no
|
|
5
|
+
// window: a native host gives it the place's offers as the chrome is given
|
|
6
|
+
// them and draws the root from the UI tree sink. The web chrome does not use
|
|
7
|
+
// it yet.
|
|
8
|
+
//
|
|
9
|
+
// makeMenuSurface({ view, draw }):
|
|
10
|
+
// view() the stage: { landscape, w } in CSS px;
|
|
11
|
+
// draw(tree) called with each root built (only when it changed).
|
|
12
|
+
import { publishUiRoot } from './uiTree.js';
|
|
13
|
+
import { buildMenu, menuCovers } from './menuTree.js';
|
|
14
|
+
|
|
15
|
+
export function makeMenuSurface({ view = () => ({}), draw = null } = {}) {
|
|
16
|
+
// `n` the last offer taken; `spec` the open sheet's, or null.
|
|
17
|
+
let menu = null;
|
|
18
|
+
let key = '';
|
|
19
|
+
let disposed = false;
|
|
20
|
+
|
|
21
|
+
const on = {
|
|
22
|
+
pick: (id) => {
|
|
23
|
+
if (menu?.spec) {menu.handler(id, menu.n);}
|
|
24
|
+
},
|
|
25
|
+
close: () => cancel(),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function render() {
|
|
29
|
+
if (disposed) {return;}
|
|
30
|
+
const stage = view() ?? {};
|
|
31
|
+
const state = { view: { landscape: Boolean(stage.landscape), w: Number(stage.w) || 0 }, spec: menu?.spec ?? null };
|
|
32
|
+
const next = JSON.stringify(state);
|
|
33
|
+
if (next === key) {return;}
|
|
34
|
+
key = next;
|
|
35
|
+
const tree = buildMenu(state, on);
|
|
36
|
+
publishUiRoot('menu', tree);
|
|
37
|
+
draw?.(tree);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function close() {
|
|
41
|
+
if (!menu?.spec) {return false;}
|
|
42
|
+
const onOpen = menu.onOpen;
|
|
43
|
+
menu.spec = null;
|
|
44
|
+
menu.onOpen = null;
|
|
45
|
+
render();
|
|
46
|
+
onOpen?.(false);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
// Close / Esc / Back: the sheet shuts and the place is told `close`.
|
|
50
|
+
function cancel() {
|
|
51
|
+
if (!menu?.spec) {return false;}
|
|
52
|
+
const { handler, n } = menu;
|
|
53
|
+
close();
|
|
54
|
+
handler('close', n);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render();
|
|
59
|
+
return {
|
|
60
|
+
// chrome `setMenu`: `offer` { n, spec } (null shuts the sheet without
|
|
61
|
+
// telling the place), `handler(id, n)` for a pick or `close`, and
|
|
62
|
+
// `onOpen(open)` as the sheet opens and shuts. An offer no newer than the
|
|
63
|
+
// last one taken is ignored.
|
|
64
|
+
set(offer, handler, onOpen) {
|
|
65
|
+
if (!offer) {
|
|
66
|
+
close();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (menu && offer.n <= menu.n) {return;}
|
|
70
|
+
close();
|
|
71
|
+
menu = { n: offer.n, spec: null, handler: handler ?? (() => {}), onOpen: null };
|
|
72
|
+
if (!offer.spec) {
|
|
73
|
+
render();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
menu.spec = offer.spec;
|
|
77
|
+
menu.onOpen = onOpen ?? null;
|
|
78
|
+
render();
|
|
79
|
+
onOpen?.(true);
|
|
80
|
+
},
|
|
81
|
+
// chrome `clearMenu`: shut and forget the last offer taken.
|
|
82
|
+
clear() {
|
|
83
|
+
close();
|
|
84
|
+
menu = null;
|
|
85
|
+
render();
|
|
86
|
+
},
|
|
87
|
+
// A turned or resized stage.
|
|
88
|
+
render,
|
|
89
|
+
cancel,
|
|
90
|
+
isOpen: () => Boolean(menu?.spec),
|
|
91
|
+
// A row sheet that reaches near the top: the host hides the HUD (any row
|
|
92
|
+
// sheet) and the controls under it (`covers`) while it is open.
|
|
93
|
+
rows: () => menu?.spec?.presentation === 'rows',
|
|
94
|
+
covers: () => menuCovers(menu?.spec),
|
|
95
|
+
dispose() {
|
|
96
|
+
if (disposed) {return;}
|
|
97
|
+
close();
|
|
98
|
+
disposed = true;
|
|
99
|
+
publishUiRoot('menu', null);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|