castle-web-cli 0.4.239 → 0.4.241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +163 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +6 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +2 -0
- package/dist/platformDoc.js +3 -2
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +1 -0
- package/dist/roomLogs.js +30 -6
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +481 -57
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/padCues.js +11 -7
- package/kits/hub-game/code/client/padReadability.js +3 -3
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +72 -51
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +205 -25
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +35 -3
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +991 -72
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +14 -2
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/standing.js +7 -3
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +429 -55
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +956 -101
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +79 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +421 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +242 -3
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-role-client.mjs +2 -1
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-standing.mjs +135 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +36 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +59 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -604,6 +604,17 @@ test('private goal position projects independently of a hidden actor Transform',
|
|
|
604
604
|
assert.strictEqual(goalAt({style:'goal'}, hidden), hidden);
|
|
605
605
|
});
|
|
606
606
|
|
|
607
|
+
test('v1.201 self goal projects the viewer\'s own avatar, never the actor or a stale point', () => {
|
|
608
|
+
const actor = { x: 5, y: 0, z: 5 };
|
|
609
|
+
const me = { x: 1.5, y: 0.2, z: -3 };
|
|
610
|
+
assert.deepEqual(goalAt({style:'goal',at:'self',rise:0.4}, actor, me), { x: 1.5, y: 0.6000000000000001, z: -3 });
|
|
611
|
+
assert.deepEqual(goalAt({style:'goal',at:'self'}, actor, me), { x: 1.5, y: 0.2, z: -3 });
|
|
612
|
+
assert.deepEqual(goalAt({style:'goal',at:'self',rise:9}, actor, me), { x: 1.5, y: 4.2, z: -3 }, 'rise is capped at 4 m');
|
|
613
|
+
assert.strictEqual(goalAt({style:'goal',at:'self'}, actor, null), null, 'no avatar: not drawn');
|
|
614
|
+
assert.strictEqual(goalAt({style:'goal',at:'self'}, actor, {x:NaN,y:0,z:0}), null);
|
|
615
|
+
assert.strictEqual(goalAt({style:'tag',at:'self'}, actor, me), actor, 'only a goal');
|
|
616
|
+
});
|
|
617
|
+
|
|
607
618
|
|
|
608
619
|
|
|
609
620
|
test('v1.131 prompt clearance happens before near-label selection', () => {
|
|
@@ -166,6 +166,26 @@ for (const [w, h, expected] of [[740, 360, true], [851, 393, true], [1180, 820,
|
|
|
166
166
|
ballot.dispose();
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
// v1.204: a ballot tap refused while catching up says why and sends nothing;
|
|
170
|
+
// the same tap goes once it ends.
|
|
171
|
+
{
|
|
172
|
+
const dom = fakeDom({ viewW: 740, viewH: 360 });
|
|
173
|
+
eventWindow(740, 360);
|
|
174
|
+
let catching = true; const refusals = [], sent = [];
|
|
175
|
+
const ballot = makeBallot({ send: (ids) => sent.push(ids), refuse: () => { if (!catching) {return false;} refusals.push(1); return true; } });
|
|
176
|
+
ballot.frame({
|
|
177
|
+
v: 1, mode: 'talk', title: 'Chat', text: '', faces: [], options: [{ id: 'river', text: 'River' }],
|
|
178
|
+
lines: [], feed: [], who: {},
|
|
179
|
+
}, [], 'p1', 0, 0);
|
|
180
|
+
const river = dom.made.findLast((node) => node.type === 'button' && node.textContent.includes('River'));
|
|
181
|
+
const click = () => river.handlers.click({ stopPropagation() {}, preventDefault() {} });
|
|
182
|
+
click();
|
|
183
|
+
assert.deepEqual(sent, []); assert.equal(refusals.length, 1, 'one line per press');
|
|
184
|
+
catching = false; click();
|
|
185
|
+
assert.equal(sent.length, 1, 'the same tap goes once catching ends'); assert.equal(refusals.length, 1);
|
|
186
|
+
ballot.dispose();
|
|
187
|
+
}
|
|
188
|
+
|
|
169
189
|
console.log('landscape layout tests passed');
|
|
170
190
|
|
|
171
191
|
// Doors owns the bottom navigation area while open, including after a HUD
|
|
@@ -120,6 +120,32 @@ doc.visibility(true);
|
|
|
120
120
|
doc.advance(30_000);
|
|
121
121
|
doc.visibility(false);
|
|
122
122
|
assert(covered());
|
|
123
|
+
// A return's cover says nothing, with no spinner, for its first 2.5 s after
|
|
124
|
+
// the page shows, then that it is reconnecting.
|
|
125
|
+
const words = () => doc.body.children[0].children[0].textContent;
|
|
126
|
+
const spinning = () => !doc.body.children[0].children[1].attributes.has('hidden');
|
|
127
|
+
assert.equal(words(), '');
|
|
128
|
+
assert(!spinning());
|
|
129
|
+
doc.advance(2_400);
|
|
130
|
+
cover.sync(scene);
|
|
131
|
+
assert.equal(words(), '');
|
|
132
|
+
doc.advance(100);
|
|
133
|
+
cover.sync(scene);
|
|
134
|
+
assert.equal(words(), 'Reconnecting…');
|
|
135
|
+
assert(spinning());
|
|
136
|
+
// Hidden again and back, even briefly: quiet at each event, before a frame.
|
|
137
|
+
doc.visibility(true);
|
|
138
|
+
assert.equal(words(), '', 'hidden says nothing');
|
|
139
|
+
assert(!spinning());
|
|
140
|
+
doc.advance(500);
|
|
141
|
+
doc.visibility(false);
|
|
142
|
+
assert.equal(words(), '', 'a short hide restarts the quiet');
|
|
143
|
+
doc.advance(2_000);
|
|
144
|
+
cover.sync(scene);
|
|
145
|
+
assert.equal(words(), '');
|
|
146
|
+
doc.advance(500);
|
|
147
|
+
cover.sync(scene);
|
|
148
|
+
assert.equal(words(), 'Reconnecting…');
|
|
123
149
|
connected = false;
|
|
124
150
|
composer.render(0.2);
|
|
125
151
|
assert(covered());
|
|
@@ -136,6 +162,46 @@ assert(covered());
|
|
|
136
162
|
connected = true;
|
|
137
163
|
composer.render(0.2);
|
|
138
164
|
assert(!covered());
|
|
165
|
+
// A 180 s drop rejoins as a fresh player id: the new session places the body
|
|
166
|
+
// at the spawn, and only the place's arrival restores the retained pose (and
|
|
167
|
+
// sends its HUD). The cover waits for that arrival, one frame more while its
|
|
168
|
+
// clamp reaches the body, and lifts at the bound if it never comes.
|
|
169
|
+
doc.visibility(true);
|
|
170
|
+
doc.advance(180_000);
|
|
171
|
+
connected = false;
|
|
172
|
+
doc.visibility(false);
|
|
173
|
+
assert(covered());
|
|
174
|
+
connected = true;
|
|
175
|
+
cover.sync(scene, { arriving: true });
|
|
176
|
+
composer.render(0.2);
|
|
177
|
+
assert(covered()); // placed at the spawn; the restored pose is still to come
|
|
178
|
+
doc.advance(300);
|
|
179
|
+
cover.sync(scene, { arriving: true });
|
|
180
|
+
composer.render(0.2);
|
|
181
|
+
assert(covered());
|
|
182
|
+
cover.sync(scene, { arriving: false }); // the arrival's clamp latched this frame
|
|
183
|
+
composer.render(0.2);
|
|
184
|
+
assert(covered());
|
|
185
|
+
cover.sync(scene, { arriving: false });
|
|
186
|
+
composer.render(0.2);
|
|
187
|
+
assert(!covered());
|
|
188
|
+
cover.sync(scene, { arriving: true });
|
|
189
|
+
assert(!covered()); // a pending arrival never raises the cover itself
|
|
190
|
+
connected = false;
|
|
191
|
+
cover.sync(scene);
|
|
192
|
+
assert(covered());
|
|
193
|
+
connected = true;
|
|
194
|
+
cover.sync(scene, { arriving: true });
|
|
195
|
+
composer.render(0.2);
|
|
196
|
+
assert(covered());
|
|
197
|
+
doc.advance(5_999);
|
|
198
|
+
cover.sync(scene, { arriving: true });
|
|
199
|
+
composer.render(0.2);
|
|
200
|
+
assert(covered());
|
|
201
|
+
doc.advance(1);
|
|
202
|
+
composer.render(0.2);
|
|
203
|
+
assert(!covered()); // no restore and no HUD: the bound lifts it
|
|
204
|
+
cover.sync(scene);
|
|
139
205
|
// Scene disposal gives back the composer; a replacement binds independently.
|
|
140
206
|
cover.detach();
|
|
141
207
|
assert.equal(composer.render, original);
|
|
@@ -159,4 +225,4 @@ assert.equal(doc.head.children.length, 0);
|
|
|
159
225
|
assert.equal(doc.listeners.size, 0);
|
|
160
226
|
assert(!doc.observing());
|
|
161
227
|
assert(draws > 0);
|
|
162
|
-
console.log('loading cover: disabled parity, completed/failed render, hidden resume, reconnect and cleanup passed');
|
|
228
|
+
console.log('loading cover: disabled parity, completed/failed render, hidden resume, reconnect, fresh-id arrival hold and cleanup passed');
|
|
@@ -16,6 +16,15 @@ function base(hub = {}, rest = {}) {
|
|
|
16
16
|
return { server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Game', ...hub }, ...rest };
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const leased = readManifest(base({ writerLease: true }), has);
|
|
20
|
+
assert.deepEqual(leased.errors, []);
|
|
21
|
+
assert.equal(leased.manifest.places.main.writerLease, true);
|
|
22
|
+
assert.equal(publicPlace('main', leased.manifest.places.main).writerLease, undefined);
|
|
23
|
+
assert.equal(readManifest(base(), has).manifest.places.main.writerLease, undefined);
|
|
24
|
+
for (const writerLease of [false, null, 'true', 1]) {
|
|
25
|
+
assert.match(readManifest(base({ writerLease }), has).errors.join(), /writerLease must be true/);
|
|
26
|
+
}
|
|
27
|
+
|
|
19
28
|
let n = 0;
|
|
20
29
|
function test(name, fn) {
|
|
21
30
|
fn();
|
|
@@ -117,6 +126,24 @@ test('house resume is strict, server-only and absent manifests stay unchanged',
|
|
|
117
126
|
assert(readManifest(base({ houseResume: true, result: {} }), has).errors.length);
|
|
118
127
|
});
|
|
119
128
|
|
|
129
|
+
test('resume window is a bounded door opt-in and absent manifests stay unchanged', () => {
|
|
130
|
+
const absent = readManifest(base(), has).manifest;
|
|
131
|
+
assert.equal(Object.hasOwn(absent.places.main, 'resumeWindowSec'), false);
|
|
132
|
+
for (const resumeWindowSec of [1, 30, 180]) {
|
|
133
|
+
const enabled = readManifest(base({ resumeWindowSec }), has);
|
|
134
|
+
assert.deepEqual(enabled.errors, []);
|
|
135
|
+
assert.equal(enabled.manifest.places.main.resumeWindowSec, resumeWindowSec);
|
|
136
|
+
assert.deepEqual(publicPlace('main', enabled.manifest.places.main), publicPlace('main', absent.places.main));
|
|
137
|
+
}
|
|
138
|
+
for (const resumeWindowSec of [0, 181, 30.5, -1, '30', true, null, {}]) {
|
|
139
|
+
assert(readManifest(base({ resumeWindowSec }), has).errors.length, String(resumeWindowSec));
|
|
140
|
+
}
|
|
141
|
+
for (const keys of [{ result: {} }, { resumePose: true }, { houseResume: true }, { resumeArrivalPose: true }]) {
|
|
142
|
+
const read = readManifest(base({ ...keys, resumeWindowSec: 60 }), has);
|
|
143
|
+
assert(read.errors.some((e) => e.includes('resumeWindowSec')), JSON.stringify(keys));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
120
147
|
test("the kit's own manifest is valid", () => {
|
|
121
148
|
const { errors, manifest } = readManifest(kit, has);
|
|
122
149
|
assert.deepEqual(errors, []);
|
|
@@ -206,7 +206,7 @@ test('buffer before WORLD, opt-in only, stale versions ignored, place change cle
|
|
|
206
206
|
test('lazy sheet, sections including empty sections, square phone touch tiles, scroll, note and selection', () => {
|
|
207
207
|
const r = rig(), count = r.dom.made.length; r.draw(null); assert.equal(r.dom.made.length, count); assert.deepEqual(r.locks, []);
|
|
208
208
|
r.draw(); const card = sheet(r.dom), blue = tile(r.dom, 'blue'), red = tile(r.dom, 'red');
|
|
209
|
-
assert.equal(card.attrs.role, 'dialog'); assert.equal(card.attrs['aria-label'], 'Wardrobe'); assert.equal(card.style.maxHeight, '55vh');
|
|
209
|
+
assert.equal(card.attrs.role, 'dialog'); assert.equal(card.attrs['aria-label'], 'Wardrobe'); assert.equal(card.style.maxHeight, 'min(max(55vh, 220px), calc(100vh - 24px))');
|
|
210
210
|
assert.equal(card.style.bottom, '0'); assert.equal(card.style.pointerEvents, 'auto');
|
|
211
211
|
assert(card.style.background.startsWith('var(--castle-surface-'));
|
|
212
212
|
for (const text of ['Wardrobe', 'Pick a colour', 'Colours', 'Hats', 'Empty', 'Blue', 'Red', 'Cap', '✓']) assert(find(r.dom, text));
|
|
@@ -214,6 +214,9 @@ test('lazy sheet, sections including empty sections, square phone touch tiles, s
|
|
|
214
214
|
assert.equal(blue.parent.style.gridTemplateColumns, 'repeat(auto-fill, minmax(64px, 1fr))');
|
|
215
215
|
assert.equal(blue.parent.parent.style.overflowY, 'auto'); assert.equal(blue.parent.parent.style.overscrollBehavior, 'contain');
|
|
216
216
|
assert.equal(blue.attrs['aria-pressed'], 'true'); assert.equal(red.attrs['aria-pressed'], 'false'); assert(blue.style.outline.includes('2px'));
|
|
217
|
+
assert.equal(blue.style.containerType, 'inline-size');
|
|
218
|
+
assert.match(blue.children.find((node) => node.textContent === 'Blue').style.fontSize, /^clamp\(8px, calc\(100cqi \* 0\.\d{4}\), 12px\)$/, 'a label fits its longest word to the tile');
|
|
219
|
+
assert(!card.children.some((node) => node.style.visibility === 'hidden'), 'the measuring probe is gone');
|
|
217
220
|
assert(red.children.some((node) => node.style.maskImage.includes('data:image/svg+xml')));
|
|
218
221
|
assert(tile(r.dom, 'cap').children.some((node) => node.style.maskImage.includes('data:image/svg+xml')));
|
|
219
222
|
const css = card.children.find((node) => node.tag === 'style').textContent;
|
|
@@ -232,14 +235,15 @@ test('face caps the sheet at 40 percent, absent face preserves CSS and replaceme
|
|
|
232
235
|
@media (prefers-reduced-motion: reduce) { .hub-menu-tile:not(:disabled):active, .hub-menu-tile.is-pressed { transform: none; } }
|
|
233
236
|
@media (max-width: 600px) { .hub-menu-grid { grid-template-columns: repeat(4, minmax(64px, 1fr)) !important; } }
|
|
234
237
|
@media (max-width: 340px) { .hub-menu-grid { grid-template-columns: repeat(3, minmax(64px, 1fr)) !important; } }
|
|
235
|
-
@supports (height: 1dvh) { .hub-menu-sheet { max-height: 55dvh !important; } }
|
|
238
|
+
@supports (height: 1dvh) { .hub-menu-sheet { max-height: min(max(55dvh, 220px), calc(100dvh - 24px)) !important; } }
|
|
236
239
|
`;
|
|
237
240
|
r.draw(); const stylesBefore = { ...sheet(r.dom).styles };
|
|
238
241
|
for (const [i, value] of [spec, { ...spec, face: 0 }, spec, { ...spec, face: 90 }].entries()) {
|
|
239
242
|
r.draw({ n: i + 2, spec: value });
|
|
240
243
|
const card = sheet(r.dom), hasFace = Object.hasOwn(value, 'face');
|
|
241
|
-
|
|
242
|
-
assert.
|
|
244
|
+
// A short view keeps a row of choices: 220 px (150 px with face) at least, short of the view.
|
|
245
|
+
assert.deepEqual(card.styles, { ...stylesBefore, maxHeight: hasFace ? 'min(max(40vh, 150px), calc(100vh - 24px))' : 'min(max(55vh, 220px), calc(100vh - 24px))' });
|
|
246
|
+
assert.equal(card.children.find((node) => node.tag === 'style').textContent, hasFace ? cssBefore.replace('max(55dvh, 220px)', 'max(40dvh, 150px)') : cssBefore);
|
|
243
247
|
const scroll = tile(r.dom, 'blue').parent.parent;
|
|
244
248
|
assert.equal(scroll.style.overflowY, 'auto'); assert.equal(scroll.style.minHeight, '0');
|
|
245
249
|
assert.equal(scroll.style.overscrollBehavior, 'contain'); assert.equal(scroll.style.touchAction, 'pan-y');
|
|
@@ -492,7 +496,7 @@ test('row menu has complete text columns, no icon slots and a pinned footer; clo
|
|
|
492
496
|
assert.equal(leave.parent.parent, card); assert.equal(leave.parent.style.flexShrink, '0');
|
|
493
497
|
assert.equal(leave.textContent, 'Back to town'); assert.equal(leave.style.minHeight, '44px'); assert.equal(leave.style.aspectRatio, '');
|
|
494
498
|
tap(tile(r.dom, 'next')); assert.deepEqual(r.sent, [{ k: 'hub-menu-pick', id: 'next', n: 1 }]);
|
|
495
|
-
r.draw({ n: 2, spec: { ...rows, face: 0 } }); assert.equal(sheet(r.dom).style.maxHeight, '40vh');
|
|
499
|
+
r.draw({ n: 2, spec: { ...rows, face: 0 } }); assert.equal(sheet(r.dom).style.maxHeight, 'min(max(40vh, 150px), calc(100vh - 24px))');
|
|
496
500
|
r.draw(null); assert.equal(hud.style.visibility, ''); assert.equal(prompt.style.visibility, '');
|
|
497
501
|
r.draw({ n: 3, spec }); assert.equal(tile(r.dom, 'blue').style.aspectRatio, '1');
|
|
498
502
|
r.chrome.dispose();
|
|
@@ -582,4 +586,49 @@ test('row menu without face covers a shown pad-context chip and restores it; no
|
|
|
582
586
|
assert.equal(chip.style.visibility, '', 'shown again');
|
|
583
587
|
r.chrome.dispose();
|
|
584
588
|
});
|
|
589
|
+
test('a host covering sheet masks the same controls through coverControls, apart from the DOM menu', () => {
|
|
590
|
+
const r = rig();
|
|
591
|
+
r.chrome.soundControl(true, { volume: 0.5, muted: false }, {});
|
|
592
|
+
r.chrome.setPointers([{ id: 'goal', x: 300, y: 400, text: 'Post', angle: 0 }]);
|
|
593
|
+
const doors = find(r.dom, 'Doors'), dock = doors.parent, picker = find(r.dom, 'Your character').parent.parent;
|
|
594
|
+
const say = find(r.dom, '💬'), emote = find(r.dom, '☺'), pointers = find(r.dom, 'Post').parent.parent;
|
|
595
|
+
const sound = r.dom.made.findLast((node) => node.dataset.hub === 'sound');
|
|
596
|
+
const controls = { dock, picker, say, emote, sound, pointers };
|
|
597
|
+
const masks = () => Object.fromEntries(Object.entries(controls).map(([name, node]) => [name, covered(node)]));
|
|
598
|
+
const none = Object.fromEntries(Object.keys(controls).map((name) => [name, false]));
|
|
599
|
+
const all = Object.fromEntries(Object.keys(controls).map((name) => [name, true]));
|
|
600
|
+
const hostRule = () => r.dom.made.some((node) => node.tag === 'style' && node.parent?.children.includes(node) && node.textContent === RULE);
|
|
601
|
+
const before = Object.fromEntries(Object.entries(controls).map(([name, node]) => [name, node.style.visibility]));
|
|
602
|
+
r.chrome.coverControls(true);
|
|
603
|
+
assert.deepEqual(masks(), all);
|
|
604
|
+
assert.equal(hostRule(), true, 'the rule has a style element of its own');
|
|
605
|
+
assert.equal(find(r.dom, 'Hello'), undefined, 'no DOM sheet is drawn');
|
|
606
|
+
const late = document.createElement('button'); r.dom.body.appendChild(late);
|
|
607
|
+
r.chrome.safeSurface('act-prompt:late', late, 'control', { transient: true });
|
|
608
|
+
r.chrome.endLayoutFrame();
|
|
609
|
+
assert.equal(covered(late), true, 'a control made while covered is covered at the frame end');
|
|
610
|
+
r.chrome.coverControls(true);
|
|
611
|
+
assert.equal(r.dom.made.filter((node) => node.tag === 'style' && node.parent?.children.includes(node) && node.textContent === RULE).length, 1, 'asking twice adds nothing');
|
|
612
|
+
// A DOM covering sheet closing while the host still covers leaves the mask.
|
|
613
|
+
const rows = { title: 'Rowan post', presentation: 'rows', sections: [{ title: 'Notes', items: [{ id: 'a', label: 'Hello', columns: ['1', 'Hello', 'Rowan'] }] }] };
|
|
614
|
+
r.draw({ n: 1, spec: rows });
|
|
615
|
+
r.draw(null);
|
|
616
|
+
assert.deepEqual(masks(), all, 'the host still covers');
|
|
617
|
+
r.chrome.coverControls(false);
|
|
618
|
+
assert.deepEqual(masks(), none);
|
|
619
|
+
assert.equal(covered(late), false);
|
|
620
|
+
assert.equal(hostRule(), false);
|
|
621
|
+
// The host letting go while a DOM covering sheet is open leaves that sheet's mask.
|
|
622
|
+
r.draw({ n: 2, spec: rows });
|
|
623
|
+
r.chrome.coverControls(true);
|
|
624
|
+
r.chrome.coverControls(false);
|
|
625
|
+
assert.deepEqual(masks(), all, 'the DOM sheet still covers');
|
|
626
|
+
r.draw(null);
|
|
627
|
+
assert.deepEqual(masks(), none);
|
|
628
|
+
r.chrome.coverControls(true);
|
|
629
|
+
r.chrome.dispose();
|
|
630
|
+
assert.deepEqual(masks(), none, 'dispose: unmasked');
|
|
631
|
+
assert.equal(hostRule(), false);
|
|
632
|
+
assert.deepEqual(Object.fromEntries(Object.entries(controls).map(([name, node]) => [name, node.style.visibility])), before);
|
|
633
|
+
});
|
|
585
634
|
console.log(`${passed} menu client tests passed`);
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// The place menu surface (`code/client/menuSurface.js`) and its tree
|
|
2
|
+
// (`menuTree.js`): the menu sheet as the `menu` UI tree root, with no DOM,
|
|
3
|
+
// for a native host. Checks that the trees validate for tiles and rows,
|
|
4
|
+
// portrait and landscape; that bytes and binding ids do not move across
|
|
5
|
+
// rebuilds with fresh closures; that every event reaches the right action
|
|
6
|
+
// (a tile, a row, a footer button, Close and Back telling the place
|
|
7
|
+
// `close`, read-only sheets taking nothing); offers replacing and ignored as
|
|
8
|
+
// the DOM's; and that the icon ids name the same paths `menuIcon()` draws.
|
|
9
|
+
import assert from 'node:assert/strict';
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { dispatchUiEvent, resetUiTrees, serialize, setUiTreeSink, validate } from '../code/client/uiTree.js';
|
|
13
|
+
import { buildMenu, menuCovers, tileCols } from '../code/client/menuTree.js';
|
|
14
|
+
import { makeMenuSurface } from '../code/client/menuSurface.js';
|
|
15
|
+
import { KIT_ICONS, MENU_ICON_PATHS, menuIcon } from '../code/client/menuIcons.js';
|
|
16
|
+
|
|
17
|
+
let passed = 0;
|
|
18
|
+
const test = async (name, fn) => {
|
|
19
|
+
try {await fn();} catch (error) {error.message = `${name}: ${error.message}`; throw error;}
|
|
20
|
+
passed += 1;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const VIEWS = { portrait: { landscape: false, w: 390 }, landscape: { landscape: true, w: 844 } };
|
|
24
|
+
const TILES = {
|
|
25
|
+
title: 'Wardrobe', note: 'Pick what to wear',
|
|
26
|
+
sections: [
|
|
27
|
+
{ title: 'Hats', items: [{ id: 'cap', label: 'Cap', icon: 'cap', on: true }, { id: 'witch', label: 'Witch', icon: 'witch', color: '#8a5cff' }] },
|
|
28
|
+
{ title: 'Colours', items: [{ id: 'red', label: 'Firefighter red', color: '#e04040' }] },
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
const ROWS = {
|
|
32
|
+
title: 'Scores', presentation: 'rows',
|
|
33
|
+
sections: [{ title: 'Today', items: [{ id: 'r1', label: 'amy', columns: ['1st', 'amy', '42'] }, { id: 'r2', label: 'Just words' }, { id: 'r3', label: 'Locked', readOnly: true }] }],
|
|
34
|
+
footer: [{ id: 'again', label: 'Play again' }, { id: 'leave', label: 'Leave' }],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function at(tree, path) {
|
|
38
|
+
let node = tree;
|
|
39
|
+
for (const key of path.split('/').slice(1)) {
|
|
40
|
+
node = node?.c?.find((child) => child.k === key);
|
|
41
|
+
}
|
|
42
|
+
return node ?? null;
|
|
43
|
+
}
|
|
44
|
+
function find(tree, k) {
|
|
45
|
+
if (!tree) {return null;}
|
|
46
|
+
if (tree.k === k) {return tree;}
|
|
47
|
+
for (const child of tree.c ?? []) {
|
|
48
|
+
const hit = find(child, k);
|
|
49
|
+
if (hit) {return hit;}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const words = (node) => node?.text ?? node?.c?.find((child) => child.t === 'text' && !child.k)?.text;
|
|
54
|
+
|
|
55
|
+
function makeHost(view = VIEWS.portrait) {
|
|
56
|
+
resetUiTrees();
|
|
57
|
+
const host = { roots: [], calls: [], view };
|
|
58
|
+
setUiTreeSink((name, wire, handlers) => {host.roots.push({ name, wire, handlers });}, { dom: false });
|
|
59
|
+
host.surface = makeMenuSurface({ view: () => host.view });
|
|
60
|
+
host.wire = () => host.roots.filter((r) => r.name === 'menu').at(-1)?.wire ?? null;
|
|
61
|
+
host.ids = () => [...(host.roots.filter((r) => r.name === 'menu').at(-1)?.handlers.keys() ?? [])];
|
|
62
|
+
host.event = (id) => dispatchUiEvent('menu', id, {});
|
|
63
|
+
host.offer = (n, spec) => host.surface.set({ n, spec }, (id, at) => host.calls.push(['pick', id, at]), (open) => host.calls.push(['open', open]));
|
|
64
|
+
return host;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
await test('trees validate for tiles and rows, portrait and landscape', () => {
|
|
68
|
+
for (const view of [...Object.values(VIEWS), { landscape: false, w: 320 }, { landscape: false, w: 700 }]) {
|
|
69
|
+
for (const spec of [null, TILES, { ...TILES, readOnly: true }, ROWS, { ...ROWS, face: 'p1' }, { ...ROWS, readOnly: true }, { ...ROWS, footer: [] }]) {
|
|
70
|
+
assert.deepEqual(validate(buildMenu({ view, spec }, { pick() {}, close() {} })), [], JSON.stringify(spec));
|
|
71
|
+
assert.deepEqual(validate(buildMenu({ view, spec })), []);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await test('bytes and binding ids do not move across rebuilds with fresh closures', () => {
|
|
77
|
+
for (const view of Object.values(VIEWS)) {
|
|
78
|
+
for (const spec of [TILES, ROWS]) {
|
|
79
|
+
const one = serialize(buildMenu({ view, spec }, { pick: () => 1, close: () => 1 }), 'menu');
|
|
80
|
+
const two = serialize(buildMenu({ view, spec }, { pick: () => 2, close: () => 2 }), 'menu');
|
|
81
|
+
assert.equal(one.json, two.json);
|
|
82
|
+
assert.deepEqual([...one.handlers.keys()], [...two.handlers.keys()]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const ids = [...serialize(buildMenu({ view: VIEWS.portrait, spec: TILES }, { pick() {}, close() {} }), 'menu').handlers.keys()];
|
|
86
|
+
assert.deepEqual(ids, ['menu#cancel', 'menu/sheet/head/close#tap', 'menu/sheet/list/g0/t:cap#tap', 'menu/sheet/list/g0/t:witch#tap', 'menu/sheet/list/g1/t:red#tap']);
|
|
87
|
+
const rowIds = [...serialize(buildMenu({ view: VIEWS.portrait, spec: ROWS }, { pick() {}, close() {} }), 'menu').handlers.keys()];
|
|
88
|
+
assert.deepEqual(rowIds, ['menu#cancel', 'menu/sheet/head/close#tap', 'menu/sheet/list/r:r1#tap', 'menu/sheet/list/r:r2#tap', 'menu/sheet/footer/b:again#tap', 'menu/sheet/footer/b:leave#tap']);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await test('tiles: icons by menuIcons id with the DOM\'s tint and size, swatches, ticks, columns by width', () => {
|
|
92
|
+
const tree = buildMenu({ view: VIEWS.portrait, spec: TILES });
|
|
93
|
+
const sheet = at(tree, 'menu/sheet');
|
|
94
|
+
assert.equal(sheet.role, 'dialog');
|
|
95
|
+
assert.equal(sheet.label, 'Wardrobe');
|
|
96
|
+
assert.equal(sheet.at.z, 9);
|
|
97
|
+
assert.deepEqual(sheet.s.maxH, [{ max: [{ dvh: 55 }, 220] }, { dvh: 100, px: -24 }], 'a short view still shows a row of tiles');
|
|
98
|
+
assert.deepEqual(sheet.s.w, [{ vw: 100 }, { px: 720 }]);
|
|
99
|
+
// v1.167: the sheet stands on the view's bottom edge, its paint reaching
|
|
100
|
+
// under the safe inset; a tile is square.
|
|
101
|
+
assert.deepEqual(sheet.at.bottom, 0);
|
|
102
|
+
assert.deepEqual(sheet.s.pad, [12, 12, [12, 0], 12]);
|
|
103
|
+
assert.equal(find(tree, 't:cap').s.aspect, 1);
|
|
104
|
+
assert.equal(at(tree, 'menu/sheet/note').text, 'Pick what to wear');
|
|
105
|
+
assert.deepEqual([at(tree, 'menu/sheet/list/s0').text, at(tree, 'menu/sheet/list/s1').text], ['Hats', 'Colours']);
|
|
106
|
+
const cap = find(tree, 't:cap');
|
|
107
|
+
assert.deepEqual([cap.label, cap.pressed, cap.disabled], ['Cap', true, false]);
|
|
108
|
+
assert.deepEqual(find(cap, 'swatch'), { t: 'icon', k: 'swatch', name: 'cap', tint: '#fff', s: { w: 28, h: 28, flex: '0 0 auto' } });
|
|
109
|
+
assert.equal(find(cap, 'tick').text, '✓');
|
|
110
|
+
assert.equal(find(find(tree, 't:witch'), 'swatch').tint, '#8a5cff');
|
|
111
|
+
assert.equal(find(find(tree, 't:witch'), 'tick'), null);
|
|
112
|
+
const red = find(find(tree, 't:red'), 'swatch');
|
|
113
|
+
assert.deepEqual([red.t, red.s.bg, red.s.radius], ['spacer', '#e04040', 6]);
|
|
114
|
+
assert.equal(find(find(tree, 't:red'), 'label').text, 'Firefighter red');
|
|
115
|
+
// Four columns on a phone, three on a very narrow one, auto-fill wider.
|
|
116
|
+
assert.equal(at(tree, 'menu/sheet/list/g0').cols, 4);
|
|
117
|
+
assert.deepEqual([tileCols(320), tileCols(600), tileCols(844)], [3, 4, { min: 64 }]);
|
|
118
|
+
// Landscape: the narrower side panel width.
|
|
119
|
+
assert.deepEqual(at(buildMenu({ view: VIEWS.landscape, spec: TILES }), 'menu/sheet').s.w, [{ vw: 56 }, { max: [220, { vw: 100, px: -344 }] }, { px: 560 }]);
|
|
120
|
+
// Every flex value is a number or a 'grow shrink basis' string.
|
|
121
|
+
(function walk(node) {
|
|
122
|
+
if (node.s?.flex !== undefined) {assert(typeof node.s.flex === 'number' || /^\d+ \d+ \S+$/.test(node.s.flex), node.s.flex);}
|
|
123
|
+
for (const child of node.c ?? []) {walk(child);}
|
|
124
|
+
})(buildMenu({ view: VIEWS.portrait, spec: ROWS }));
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
await test('rows: one label or three columns, read-only rows, the footer, how far the sheet reaches', () => {
|
|
128
|
+
for (const view of Object.values(VIEWS)) {
|
|
129
|
+
const tree = buildMenu({ view, spec: ROWS });
|
|
130
|
+
const sheet = at(tree, 'menu/sheet');
|
|
131
|
+
assert.deepEqual(sheet.s.maxH, [{ dvh: 100, px: -24 }]);
|
|
132
|
+
assert.deepEqual(sheet.s.w, [{ vw: 100, px: -24 }, { px: 720 }]);
|
|
133
|
+
const r1 = find(tree, 'r:r1');
|
|
134
|
+
assert.equal(r1.t, 'button');
|
|
135
|
+
assert.equal(r1.label, '1st · amy · 42');
|
|
136
|
+
assert.deepEqual(find(r1, 'cols').c.map((c) => [c.text, c.s.flex]), [['1st', '0 1 90px'], ['amy', '1 1 0'], ['42', '0 1 auto']]);
|
|
137
|
+
assert.equal(find(r1, 'cols').c[2].s.talign, 'end');
|
|
138
|
+
assert.equal(find(tree, 'r:r2').label, 'Just words');
|
|
139
|
+
assert.equal(find(tree, 'r:r3').t, 'column', 'a read-only row is not a button');
|
|
140
|
+
assert.deepEqual(find(tree, 'footer').c.map((b) => [b.k, words(b), b.s.flex]), [['b:again', 'Play again', '1 1 0'], ['b:leave', 'Leave', '1 1 0']]);
|
|
141
|
+
}
|
|
142
|
+
assert.deepEqual(at(buildMenu({ view: VIEWS.portrait, spec: { ...ROWS, face: 'p1' } }), 'menu/sheet').s.maxH, [{ max: [{ dvh: 40 }, 150] }, { dvh: 100, px: -24 }]);
|
|
143
|
+
assert.equal(menuCovers(ROWS), true);
|
|
144
|
+
assert.equal(menuCovers({ ...ROWS, face: 'p1' }), false);
|
|
145
|
+
assert.equal(menuCovers(TILES), false);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
await test('events: a tile, Close and Back tell the place; a newer offer replaces, an older one is ignored', () => {
|
|
149
|
+
for (const view of Object.values(VIEWS)) {
|
|
150
|
+
const host = makeHost(view);
|
|
151
|
+
host.offer(3, TILES);
|
|
152
|
+
assert.equal(host.surface.isOpen(), true);
|
|
153
|
+
assert.equal(host.event('menu/sheet/list/g0/t:witch#tap'), true);
|
|
154
|
+
assert.equal(host.surface.isOpen(), true, 'a pick leaves the sheet up until the place answers');
|
|
155
|
+
// Close.
|
|
156
|
+
host.event('menu/sheet/head/close#tap');
|
|
157
|
+
assert.equal(host.surface.isOpen(), false);
|
|
158
|
+
assert.equal(host.wire().on, undefined, 'a shut menu binds no cancel');
|
|
159
|
+
assert.equal(host.event('menu#cancel'), false);
|
|
160
|
+
// A newer offer; Back.
|
|
161
|
+
host.offer(4, TILES);
|
|
162
|
+
assert.equal(host.event('menu#cancel'), true);
|
|
163
|
+
assert.equal(host.surface.isOpen(), false);
|
|
164
|
+
// An offer no newer is ignored.
|
|
165
|
+
host.offer(4, TILES);
|
|
166
|
+
assert.equal(host.surface.isOpen(), false);
|
|
167
|
+
// A newer one replaces an open one (the old is shut, not told close).
|
|
168
|
+
host.offer(5, TILES);
|
|
169
|
+
host.offer(6, ROWS);
|
|
170
|
+
assert.equal(host.surface.rows(), true);
|
|
171
|
+
assert.equal(host.surface.covers(), true);
|
|
172
|
+
host.event('menu/sheet/list/r:r1#tap');
|
|
173
|
+
host.event('menu/sheet/footer/b:leave#tap');
|
|
174
|
+
// A null offer shuts it without telling the place.
|
|
175
|
+
host.surface.set(null);
|
|
176
|
+
assert.equal(host.surface.isOpen(), false);
|
|
177
|
+
assert.deepEqual(host.calls, [
|
|
178
|
+
['open', true], ['pick', 'witch', 3], ['open', false], ['pick', 'close', 3],
|
|
179
|
+
['open', true], ['open', false], ['pick', 'close', 4],
|
|
180
|
+
['open', true], ['open', false], ['open', true], ['pick', 'r1', 6], ['pick', 'leave', 6], ['open', false],
|
|
181
|
+
]);
|
|
182
|
+
host.surface.dispose();
|
|
183
|
+
assert.equal(host.wire(), null);
|
|
184
|
+
resetUiTrees();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
await test('events: a read-only sheet takes no picks; an offer without a spec opens nothing', () => {
|
|
189
|
+
const host = makeHost();
|
|
190
|
+
host.offer(1, { ...TILES, readOnly: true });
|
|
191
|
+
assert.equal(find(host.wire(), 't:cap').disabled, true);
|
|
192
|
+
host.event('menu/sheet/list/g0/t:cap#tap');
|
|
193
|
+
host.offer(2, { ...ROWS, readOnly: true });
|
|
194
|
+
assert.equal(find(host.wire(), 'b:again').disabled, true);
|
|
195
|
+
assert.equal(host.ids().some((id) => id.includes('r:r1')), false, 'read-only rows are not buttons');
|
|
196
|
+
host.event('menu/sheet/footer/b:again#tap');
|
|
197
|
+
host.offer(3, null);
|
|
198
|
+
assert.equal(host.surface.isOpen(), false);
|
|
199
|
+
assert.equal(host.wire().c, undefined);
|
|
200
|
+
host.surface.clear();
|
|
201
|
+
host.offer(1, TILES);
|
|
202
|
+
assert.equal(host.surface.isOpen(), true, 'clear forgets the last offer taken');
|
|
203
|
+
assert.deepEqual(host.calls.filter(([kind]) => kind === 'pick'), []);
|
|
204
|
+
host.surface.dispose();
|
|
205
|
+
resetUiTrees();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
await test('icons: MENU_ICON_PATHS names the paths menuIcon() draws; the companion icon is chrome.js\'s SVG', () => {
|
|
209
|
+
for (const [id, path] of Object.entries(MENU_ICON_PATHS)) {
|
|
210
|
+
assert.equal(menuIcon(id), `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>`)}")`);
|
|
211
|
+
}
|
|
212
|
+
assert.equal(menuIcon('companion'), null, 'the web menu is unchanged');
|
|
213
|
+
assert(Object.isFrozen(MENU_ICON_PATHS));
|
|
214
|
+
const chrome = readFileSync(new URL('../code/client/chrome.js', import.meta.url), 'utf8');
|
|
215
|
+
const { viewBox, paths } = KIT_ICONS.companion;
|
|
216
|
+
assert(chrome.includes(`<svg viewBox="${viewBox}" width="26" height="26" aria-hidden="true">${paths.map((p) => `<path fill="${p.fill}" d="${p.d}"/>`).join('')}</svg>`));
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
await test('the surface loads and runs in a process that never had a DOM', () => {
|
|
220
|
+
const probe = `
|
|
221
|
+
if (globalThis.document || globalThis.window) throw new Error('a DOM');
|
|
222
|
+
const { setUiTreeSink, dispatchUiEvent } = await import(${JSON.stringify(new URL('../code/client/uiTree.js', import.meta.url).href)});
|
|
223
|
+
const { makeMenuSurface } = await import(${JSON.stringify(new URL('../code/client/menuSurface.js', import.meta.url).href)});
|
|
224
|
+
const seen = [];
|
|
225
|
+
setUiTreeSink((name, wire) => seen.push(name + ':' + (wire ? (wire.c ?? []).length : null)), { dom: false });
|
|
226
|
+
const surface = makeMenuSurface({ view: () => ({ landscape: false, w: 390 }) });
|
|
227
|
+
surface.set({ n: 1, spec: ${JSON.stringify(TILES)} }, (id, n) => seen.push(id + '@' + n));
|
|
228
|
+
dispatchUiEvent('menu', 'menu/sheet/list/g1/t:red#tap', {});
|
|
229
|
+
dispatchUiEvent('menu', 'menu#cancel', {});
|
|
230
|
+
surface.dispose();
|
|
231
|
+
console.log(seen.join(' '));
|
|
232
|
+
`;
|
|
233
|
+
assert.equal(execFileSync(process.execPath, ['--input-type=module', '-e', probe], { encoding: 'utf8' }).trim(), 'menu:0 menu:1 red@1 menu:0 close@1 menu:null');
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
console.log(`menu surface: ${passed} checks passed`);
|