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
|
@@ -185,6 +185,45 @@ await test('a player out of range cannot open one', async () => {
|
|
|
185
185
|
assert.equal(w.sent.at(-1).why, 'far');
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
+
await test('a press within 1.5 s of the prompt is answered though the body has walked on', async () => {
|
|
189
|
+
// The body sets off at 2.6 m/s from beside a player 3 m away; the press
|
|
190
|
+
// lands after it has left talk range (about 4.3 m), but within the grace.
|
|
191
|
+
const w = world({ turnsAtOnce: 3 });
|
|
192
|
+
w.at('a', 0, 3);
|
|
193
|
+
w.npcs.handle('greeter').walkTo({ x: 0, z: -20 });
|
|
194
|
+
for (let i = 0; i < 5; i++) w.tick(100);
|
|
195
|
+
assert.ok(Math.hypot(w.greeter().p.x, w.greeter().p.z - 3) > 3.5, 'out of talk range at the press');
|
|
196
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
|
|
197
|
+
assert.equal(w.sent.at(-1).open, true);
|
|
198
|
+
assert.deepEqual(w.npcs.handle('greeter').talkingWith, ['a']);
|
|
199
|
+
// A turn at the distance it opened at is admitted, not refused as far.
|
|
200
|
+
w.npcs.handle('greeter').stop();
|
|
201
|
+
const t = turn({ speaker: 'a' });
|
|
202
|
+
await w.npcs.onTurn(t);
|
|
203
|
+
assert.equal(t.rejected, null);
|
|
204
|
+
assert.equal(t.sent, 1);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await test('a press after the grace, or from a player never in range, is still far', async () => {
|
|
208
|
+
const w = world({ turnsAtOnce: 3 });
|
|
209
|
+
w.at('a', 0, 3);
|
|
210
|
+
w.at('b', 0, 8);
|
|
211
|
+
w.npcs.handle('greeter').walkTo({ x: 0, z: -20 });
|
|
212
|
+
for (let i = 0; i < 5; i++) w.tick(100);
|
|
213
|
+
w.npcs.message({ playerId: 'b' }, { k: 'hub-npc-open', npc: 'greeter' });
|
|
214
|
+
assert.equal(w.sent.at(-1).open, false, 'b never had the prompt');
|
|
215
|
+
assert.equal(w.sent.at(-1).why, 'far');
|
|
216
|
+
for (let i = 0; i < 15; i++) w.tick(100);
|
|
217
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
|
|
218
|
+
assert.equal(w.sent.at(-1).open, false, 'the prompt went more than 1.5 s ago');
|
|
219
|
+
assert.equal(w.sent.at(-1).why, 'far');
|
|
220
|
+
// A body standing still answers within talk range only, as before.
|
|
221
|
+
const still = world();
|
|
222
|
+
still.at('a', 0, 3.6);
|
|
223
|
+
still.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
|
|
224
|
+
assert.equal(still.sent.at(-1).why, 'far');
|
|
225
|
+
});
|
|
226
|
+
|
|
188
227
|
await test('without a mind the place answers, and no turn is admitted', async () => {
|
|
189
228
|
const w = world({ mind: false });
|
|
190
229
|
w.at('a', 0, 2);
|
|
@@ -2447,6 +2486,62 @@ await test('v1.148: a mind with authored taps hears only those taps, and refuses
|
|
|
2447
2486
|
assert.deepEqual(w.lines.filter((l) => l.why === 'authored').map((l) => l.text), ["I'll look myself"]);
|
|
2448
2487
|
});
|
|
2449
2488
|
|
|
2489
|
+
await test('v1.175: a mind\'s authored asks are fallback taps for any other speaker; the place answers them and mind turns still go', async () => {
|
|
2490
|
+
for (const stamp of [{ under13: false }, {}]) {
|
|
2491
|
+
const w = world();
|
|
2492
|
+
w.h.hooks.npcOpening = () => WELCOME;
|
|
2493
|
+
w.h.session.players = [{ playerId: 'a', userId: '101', ...stamp }];
|
|
2494
|
+
w.at('a', 0, 2);
|
|
2495
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
|
|
2496
|
+
const opened = w.sent.find((m) => m.k === 'hub-npc' && m.open);
|
|
2497
|
+
assert.deepEqual(opened.fallbackChoices, WELCOME.asks);
|
|
2498
|
+
assert.equal(Object.hasOwn(opened, 'choices'), false, 'typing is not replaced by choices');
|
|
2499
|
+
assert.equal(Object.hasOwn(opened, 'authoredChoices'), false);
|
|
2500
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: 'tell me a secret', rid: 'r1' });
|
|
2501
|
+
assert.equal(w.lines.filter((l) => l.why === 'authored').length, 0, 'free text is dropped');
|
|
2502
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: ' Show me around ', rid: 'r2' });
|
|
2503
|
+
assert.deepEqual(w.lines.filter((l) => l.why === 'authored').map((l) => l.text), ['Show me around']);
|
|
2504
|
+
assert.ok(w.sent.some((m) => m.k === 'hub-npc-line' && m.why === 'authored' && m.rid === 'r2'));
|
|
2505
|
+
const t = turn({ speaker: 'a', input: 'hello' });
|
|
2506
|
+
await w.npcs.onTurn(t);
|
|
2507
|
+
assert.equal(t.sent, 1, 'an inspected speaker still talks to the mind');
|
|
2508
|
+
}
|
|
2509
|
+
const { authored: _authored, ...plain } = WELCOME;
|
|
2510
|
+
for (const [opening, kid, mind] of [[plain, false, true], [WELCOME, true, true], [WELCOME, false, false]]) {
|
|
2511
|
+
const w = world({ mind });
|
|
2512
|
+
w.h.hooks.npcOpening = () => opening;
|
|
2513
|
+
w.h.session.players = [{ playerId: 'a', userId: '101', under13: kid }];
|
|
2514
|
+
w.at('a', 0, 2);
|
|
2515
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
|
|
2516
|
+
const opened = w.sent.find((m) => m.k === 'hub-npc' && m.open);
|
|
2517
|
+
assert.equal(Object.hasOwn(opened, 'fallbackChoices'), false, `no fallback: authored ${opening.authored}, kid ${kid}, mind ${mind}`);
|
|
2518
|
+
}
|
|
2519
|
+
});
|
|
2520
|
+
|
|
2521
|
+
await test('v1.175: a refused inspect shows an adult the authored asks, answered by the place; typing still waits', () => withLogs(() => talkRig({ opening: WELCOME, inspectFailures: [characterRefusal()] }, async (r) => {
|
|
2522
|
+
r.frame();
|
|
2523
|
+
assert.equal(r.typing(), false);
|
|
2524
|
+
assert.deepEqual(r.offered(), WELCOME.asks);
|
|
2525
|
+
assert.equal(r.hint() ?? null, null);
|
|
2526
|
+
r.choose('Show me around'); r.frame(); await r.settle();
|
|
2527
|
+
assert.equal(r.requests.length, 0, 'no mind turn');
|
|
2528
|
+
assert.ok(r.wire.some((m) => m.k === 'hub-npc-say' && m.text === 'Show me around'));
|
|
2529
|
+
assert.ok(r.w.lines.some((l) => l.why === 'authored' && l.text === 'Show me around'), 'the place heard the tap');
|
|
2530
|
+
assert.ok(r.lines.some(([who, text]) => who === 'them' && text === 'line:authored'), 'the place answered');
|
|
2531
|
+
assert.deepEqual(r.offered(), ["I'll look myself"]);
|
|
2532
|
+
assert.equal(r.typing(), false);
|
|
2533
|
+
})));
|
|
2534
|
+
|
|
2535
|
+
await test('v1.175: once the inspect succeeds, authored asks are mind turns as before', () => withLogs(() => talkRig({ opening: WELCOME }, async (r) => {
|
|
2536
|
+
r.frame();
|
|
2537
|
+
assert.equal(r.typing(), true);
|
|
2538
|
+
assert.deepEqual(r.offered(), WELCOME.asks);
|
|
2539
|
+
r.choose('Show me around'); r.frame(); await r.settle();
|
|
2540
|
+
assert.equal(r.requests.length, 1, 'a mind turn');
|
|
2541
|
+
assert.ok(r.requests[0].input.endsWith('Show me around'));
|
|
2542
|
+
assert.ok(!r.wire.some((m) => m.k === 'hub-npc-say'));
|
|
2543
|
+
})));
|
|
2544
|
+
|
|
2450
2545
|
const LEGACY_CHILD_ASKS = ['What can I do here?', 'Tell me about yourself.', 'Where should I go next?'];
|
|
2451
2546
|
|
|
2452
2547
|
await test('v1.150: under13Choices authored taps lead bundle and legacy choices, without a mind turn', async () => {
|
|
@@ -2485,6 +2580,39 @@ await test('v1.150: under13Choices authored taps lead bundle and legacy choices,
|
|
|
2485
2580
|
}));
|
|
2486
2581
|
});
|
|
2487
2582
|
|
|
2583
|
+
await test('v1.153: a child whose inspect is refused at a mind with bundle chips taps the canned lines, answered by the place', async () => {
|
|
2584
|
+
await withLogs(() => talkRig({ kid: true, childAsks: bundleAsks.greeter, inspectFailures: [characterRefusal()] }, async (r) => {
|
|
2585
|
+
r.frame();
|
|
2586
|
+
const open = r.w.sent.find((m) => m.k === 'hub-npc' && m.open);
|
|
2587
|
+
assert.deepEqual(open.choices, bundleAsks.greeter.map(({ id, label }) => ({ id, label })));
|
|
2588
|
+
assert.deepEqual(open.fallbackChoices, LEGACY_CHILD_ASKS);
|
|
2589
|
+
assert.equal(r.typing(), false);
|
|
2590
|
+
assert.deepEqual(r.offered(), LEGACY_CHILD_ASKS, 'not an empty row');
|
|
2591
|
+
r.choose(LEGACY_CHILD_ASKS[0]); r.frame(); await r.settle();
|
|
2592
|
+
assert.equal(r.requests.length, 0, 'no mind turn');
|
|
2593
|
+
assert.ok(r.w.lines.some((l) => l.why === 'authored' && l.text === LEGACY_CHILD_ASKS[0]), 'the place heard the tap');
|
|
2594
|
+
assert.ok(r.lines.some(([who, text]) => who === 'them' && text === 'line:authored'), 'the place answered');
|
|
2595
|
+
assert.deepEqual(r.offered(), LEGACY_CHILD_ASKS, 'and may be asked again');
|
|
2596
|
+
}));
|
|
2597
|
+
// A place with no line for it: the kit's refused line, never silence.
|
|
2598
|
+
const w = world({ childAsks: bundleAsks.greeter });
|
|
2599
|
+
w.h.hooks.npcLine = () => null;
|
|
2600
|
+
w.h.session.players = [{ playerId: 'a', userId: '101', under13: true }];
|
|
2601
|
+
w.at('a', 0, 2);
|
|
2602
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-open', npc: 'greeter' });
|
|
2603
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: 'free words', rid: 'c1' });
|
|
2604
|
+
w.npcs.message({ playerId: 'a' }, { k: 'hub-npc-say', npc: 'greeter', text: LEGACY_CHILD_ASKS[1], rid: 'c2' });
|
|
2605
|
+
assert.deepEqual(w.sent.filter((m) => m.k === 'hub-npc-line').map(({ text, why, rid }) => ({ text, why, rid })), [{ text: 'Rowan smiles and nods.', why: 'authored', rid: 'c2' }]);
|
|
2606
|
+
// Bundle chip turns are still admitted; an inspected child gets the chips.
|
|
2607
|
+
const t = turn({ speaker: 'a', input: `choice:${bundleAsks.greeter[0].id}` });
|
|
2608
|
+
await w.npcs.onTurn(t);
|
|
2609
|
+
assert.equal(t.sent, 1);
|
|
2610
|
+
await withLogs(() => talkRig({ kid: true, childAsks: bundleAsks.greeter }, async (r) => {
|
|
2611
|
+
r.frame();
|
|
2612
|
+
assert.deepEqual(r.offered(), bundleAsks.greeter.map(({ id, label }) => ({ id, label })));
|
|
2613
|
+
}));
|
|
2614
|
+
});
|
|
2615
|
+
|
|
2488
2616
|
await test('v1.150: under13Choices mind-less NPC keeps only the three legacy choices', async () => {
|
|
2489
2617
|
const w = world({ mind: false });
|
|
2490
2618
|
w.h.place.under13Choices = true;
|
|
@@ -44,6 +44,8 @@ const spawn = { id: 'spawn', components: {
|
|
|
44
44
|
Player: {}, Transform: { x: 0, y: 1, z: 0 },
|
|
45
45
|
Shape: { kind: 'capsule', height: 1.4, radius: 0.35 },
|
|
46
46
|
} };
|
|
47
|
+
// v1.165: a car look, for the driving cases.
|
|
48
|
+
const kart = { id: 'kart', components: { Model: { file: 'kart.pxmodel' }, Transform: { x: -50, y: 0, z: -50 } } };
|
|
47
49
|
const door = { id: 'door', components: {
|
|
48
50
|
HubDoor: { id: 'race', to: 'race' }, Transform: { x: 30, y: 1, z: 0 },
|
|
49
51
|
} };
|
|
@@ -59,19 +61,21 @@ async function test(name, fn) {
|
|
|
59
61
|
|
|
60
62
|
// A town with one player, arrived and settled, ticked by hand. `hooks` are the
|
|
61
63
|
// place's own; `ctx` is its `hub`.
|
|
62
|
-
async function boot({ hooks = {}, use = true, hub = {} } = {}) {
|
|
63
|
-
globalThis.__observedActors = [spawn, door];
|
|
64
|
+
async function boot({ hooks = {}, use = true, hub = {}, others = [] } = {}) {
|
|
65
|
+
globalThis.__observedActors = [spawn, door, kart];
|
|
64
66
|
const sim = await World.createSimulation();
|
|
65
67
|
Players.addPlayer(sim, 'p1');
|
|
68
|
+
for (const id of others) {Players.addPlayer(sim, id);}
|
|
66
69
|
const clock = { wall: 1_000_000 };
|
|
67
70
|
const engine = { createBody: World.createBody, removeActor: World.removeActor, maxSpeed: () => 12, wallNow: () => clock.wall };
|
|
68
71
|
let ctx;
|
|
69
72
|
const h = layer({ ...config, hub: { ...config.hub, ...hub } }, { ...hooks, ready(hub) { ctx = hub; hooks.ready?.(hub); } }, {}, () => true, () => ({}), null, engine);
|
|
70
|
-
const session = { sessionId: 'dev:observed', players: [{ playerId: 'p1', userId: '101', username: 'ada', isAnonymous: false }], send() {}, broadcast() {} };
|
|
73
|
+
const session = { sessionId: 'dev:observed', players: [{ playerId: 'p1', userId: '101', username: 'ada', isAnonymous: false }, ...others.map((id, i) => ({ playerId: id, userId: `${102 + i}`, username: `u${i}`, isAnonymous: false }))], send() {}, broadcast() {} };
|
|
71
74
|
h.sceneFor(session);
|
|
72
75
|
h.ready(sim);
|
|
73
76
|
const b = { sim, h, session, ctx, clock, entry: () => sim.players.get('p1'), origin: null };
|
|
74
77
|
h.message(session, { playerId: 'p1' }, { k: 'hub-hello', avatar: 1 });
|
|
78
|
+
for (const id of others) {h.message(session, { playerId: id }, { k: 'hub-hello', avatar: 1 });}
|
|
75
79
|
tick(b);
|
|
76
80
|
if (use) {
|
|
77
81
|
// Observation starts here: a reset where the body stands, from now.
|
|
@@ -79,6 +83,7 @@ async function boot({ hooks = {}, use = true, hub = {} } = {}) {
|
|
|
79
83
|
}
|
|
80
84
|
// The client agrees with where the arrival put it, which ends the settle.
|
|
81
85
|
report(b, here(b));
|
|
86
|
+
for (const id of others) {report(b, { ...sim.players.get(id).at }, id);}
|
|
82
87
|
tick(b);
|
|
83
88
|
return b;
|
|
84
89
|
}
|
|
@@ -742,4 +747,167 @@ await test('a tuned player gets their own allowance; an absent tick adds nothing
|
|
|
742
747
|
assert.ok(b.ctx.dwell('p1', 'goal').ms > ms);
|
|
743
748
|
}));
|
|
744
749
|
|
|
750
|
+
|
|
751
|
+
// --- v1.165: drivers ------------------------------------------------------------
|
|
752
|
+
|
|
753
|
+
const car = (speed = 12, extra = {}) => ({ look: 'kart', speed, reverse: 4, ...extra });
|
|
754
|
+
|
|
755
|
+
await test('v1.165: a driver\'s allowance is their car\'s; 12 m/s driving is funded, enters and earns travel', () => withBoot({}, (b) => {
|
|
756
|
+
assert.equal(b.ctx.observed('p1').speed, 6 * 1.25, 'walking: the walker\'s');
|
|
757
|
+
assert.equal(b.ctx.drive('p1', car(12)), true);
|
|
758
|
+
tick(b);
|
|
759
|
+
assert.equal(b.ctx.observed('p1').speed, 12 * 1.25, 'driving: max(speed, reverse) x 1.25');
|
|
760
|
+
b.ctx.station('goal', station(40, 5));
|
|
761
|
+
stand(b, 500);
|
|
762
|
+
for (const every of [50, 100, 200]) {
|
|
763
|
+
const oks = [];
|
|
764
|
+
const travel0 = b.ctx.observed('p1').travel;
|
|
765
|
+
const from = here(b);
|
|
766
|
+
walk(b, { x: from.x > 20 ? 0 : 40, y: from.y, z: 0 }, { speed: 12, every, after: 300, each: () => oks.push(b.ctx.observed('p1').ok) });
|
|
767
|
+
assert.ok(oks.every(Boolean), `ok throughout at ${every} ms`);
|
|
768
|
+
const credited = b.ctx.observed('p1').travel - travel0;
|
|
769
|
+
assert.ok(credited > 39, `credited ${credited} of 40 m at ${every} ms`);
|
|
770
|
+
}
|
|
771
|
+
walk(b, { x: 30, y: here(b).y, z: 0 }, { speed: 12 });
|
|
772
|
+
walk(b, { x: 40, y: here(b).y, z: 0 }, { speed: 12, after: 300 });
|
|
773
|
+
assert.equal(b.ctx.dwell('p1', 'goal').entered, true, 'a car enters a station');
|
|
774
|
+
// A tune does not move a driver's allowance; it applies on getting out.
|
|
775
|
+
b.ctx.tune('p1', { speed: 2 });
|
|
776
|
+
tick(b);
|
|
777
|
+
assert.equal(b.ctx.observed('p1').speed, 12 * 1.25);
|
|
778
|
+
// The car's larger of speed and reverse.
|
|
779
|
+
b.ctx.drive('p1', { look: 'kart', speed: 3, reverse: 5 });
|
|
780
|
+
tick(b);
|
|
781
|
+
assert.equal(b.ctx.observed('p1').speed, 5 * 1.25);
|
|
782
|
+
}));
|
|
783
|
+
|
|
784
|
+
await test('v1.165: a driver\'s credit is capped at the car\'s: stuffing past it never enters', () => withBoot({}, (b) => {
|
|
785
|
+
b.ctx.drive('p1', car(12));
|
|
786
|
+
const start = here(b);
|
|
787
|
+
b.ctx.station('goal', station(start.x + 10, 1.5));
|
|
788
|
+
stand(b, 2000);
|
|
789
|
+
// 17 in-bound reports in one tick: 10.2 m, beyond the 6.3 m cap.
|
|
790
|
+
for (let i = 1; i <= 17; i += 1) {
|
|
791
|
+
report(b, { x: start.x + 0.6 * i, y: start.y, z: start.z });
|
|
792
|
+
}
|
|
793
|
+
assert.ok(here(b).x - start.x > 10, 'setPose took them');
|
|
794
|
+
const travel = b.ctx.observed('p1').travel;
|
|
795
|
+
tick(b);
|
|
796
|
+
assert.equal(b.ctx.dwell('p1', 'goal').entered, false);
|
|
797
|
+
assert.equal(b.ctx.observed('p1').travel, travel, 'unfunded: no travel');
|
|
798
|
+
assert.equal(b.ctx.observed('p1').ok, true, 'adopted, not rejected');
|
|
799
|
+
}));
|
|
800
|
+
|
|
801
|
+
await test('v1.165: getting in carries no more than the walker\'s credit, and the switch tick fills at the walker\'s rate', () => withBoot({}, (b) => {
|
|
802
|
+
stand(b, 2000);
|
|
803
|
+
const start = here(b);
|
|
804
|
+
const travel = b.ctx.observed('p1').travel;
|
|
805
|
+
assert.equal(b.ctx.drive('p1', car(12)), true);
|
|
806
|
+
// The walker's full credit (3.3 m) plus one 50 ms tick at the walker's
|
|
807
|
+
// 7.5 m/s (0.375 m) is 3.675 m. The car's rate would make it 3.75 m.
|
|
808
|
+
const d = 3.72;
|
|
809
|
+
for (let i = 1; i <= 7; i += 1) {
|
|
810
|
+
report(b, { x: start.x + (d * i) / 7, y: start.y, z: start.z });
|
|
811
|
+
}
|
|
812
|
+
tick(b);
|
|
813
|
+
const o = b.ctx.observed('p1');
|
|
814
|
+
assert.equal(o.speed, 15);
|
|
815
|
+
assert.equal(o.ok, true);
|
|
816
|
+
assert.equal(o.travel, travel, 'unfunded: the switch bought no credit');
|
|
817
|
+
assert.ok(Math.abs(o.at.x - (start.x + d)) < 1e-6, 'adopted');
|
|
818
|
+
}));
|
|
819
|
+
|
|
820
|
+
await test('v1.165: getting out is a reset and puts the walker\'s allowance back', () => withBoot({}, (b) => {
|
|
821
|
+
b.ctx.drive('p1', car(12));
|
|
822
|
+
stand(b, 1000);
|
|
823
|
+
walk(b, { x: 20, y: here(b).y, z: 0 }, { speed: 12 });
|
|
824
|
+
stand(b, 1000);
|
|
825
|
+
assert.ok(b.ctx.observed('p1').travel > 19);
|
|
826
|
+
assert.equal(b.ctx.drive('p1', null), true);
|
|
827
|
+
assert.equal(b.ctx.observed('p1').ok, false, 'the get-out placement invalidates at once');
|
|
828
|
+
tick(b);
|
|
829
|
+
const o = b.ctx.observed('p1');
|
|
830
|
+
assert.equal(o.ok, true);
|
|
831
|
+
assert.equal(o.travel, 0);
|
|
832
|
+
assert.equal(o.speed, 6 * 1.25);
|
|
833
|
+
// Car speed on foot now outruns the credit and never enters.
|
|
834
|
+
report(b, here(b));
|
|
835
|
+
b.ctx.station('goal', station(here(b).x - 20, 1.5));
|
|
836
|
+
stand(b, 1000);
|
|
837
|
+
let entered = false;
|
|
838
|
+
walk(b, { x: here(b).x - 20, y: here(b).y, z: here(b).z }, { speed: 12, every: 100, after: 300, each: () => { entered ||= b.ctx.dwell('p1', 'goal').entered; } });
|
|
839
|
+
assert.equal(entered, false);
|
|
840
|
+
}));
|
|
841
|
+
|
|
842
|
+
await test('v1.165: a rider is placed on their seat each tick and earns nothing from riding', async () => {
|
|
843
|
+
const reads = [];
|
|
844
|
+
await withBoot({ others: ['p2'], hooks: { step(hub) { if (hub.vehicle('p2')) {reads.push({ o: hub.observed('p2'), d: hub.dwell('p2', 'goal') });} } } }, (b) => {
|
|
845
|
+
const p2 = () => b.sim.players.get('p2');
|
|
846
|
+
assert.ok(flat(p2().at, here(b)) <= 6, 'the arrival row puts them near');
|
|
847
|
+
assert.equal(b.ctx.drive('p1', car(12, { seats: [[0, 0, 0], [0, 0, -1]] })), true);
|
|
848
|
+
assert.equal(b.ctx.ride('p2', 'p1', 1), true);
|
|
849
|
+
b.ctx.station('goal', station(30, 4));
|
|
850
|
+
stand(b, 500);
|
|
851
|
+
walk(b, { x: 30, y: here(b).y, z: 0 }, { speed: 12, every: 100, after: 1000 });
|
|
852
|
+
assert.ok(flat(p2().at, { x: 30, y: 0, z: 0 }) < 4, `carried into the station: ${JSON.stringify(p2().at)}`);
|
|
853
|
+
assert.equal(b.ctx.dwell('p1', 'goal').entered, true, 'the driver enters');
|
|
854
|
+
assert.ok(reads.length > 20);
|
|
855
|
+
for (const { o, d } of reads) {
|
|
856
|
+
assert.equal(o.travel, 0, 'no travel from riding');
|
|
857
|
+
assert.equal(o.speed, 6 * 1.25, 'a rider keeps the walker allowance');
|
|
858
|
+
assert.equal(d.entered, false, 'riding enters nothing');
|
|
859
|
+
assert.equal(d.ms, 0);
|
|
860
|
+
}
|
|
861
|
+
assert.ok(reads.slice(-5).every(({ o }) => o.ok), 'read in step, a rider is not rejected');
|
|
862
|
+
// Out, then walking in on foot enters.
|
|
863
|
+
assert.equal(b.ctx.ride('p2', null), true);
|
|
864
|
+
tick(b);
|
|
865
|
+
report(b, { ...p2().at }, 'p2');
|
|
866
|
+
tick(b);
|
|
867
|
+
assert.equal(b.ctx.observed('p2').ok, true);
|
|
868
|
+
assert.equal(b.ctx.observed('p2').travel, 0);
|
|
869
|
+
});
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
await test('v1.165: a passenger of a slow car (0.5 m/s, 50 ms ticks) earns no travel and enters nothing', async () => {
|
|
874
|
+
const reads = [];
|
|
875
|
+
await withBoot({ others: ['p2'], hooks: { step(hub) { if (hub.vehicle('p2')) {reads.push({ o: hub.observed('p2'), d: hub.dwell('p2', 'goal') });} } } }, (b) => {
|
|
876
|
+
const p2 = () => b.sim.players.get('p2');
|
|
877
|
+
assert.equal(b.ctx.drive('p1', car(12, { seats: [[0, 0, 0], [0, 0, -1]] })), true);
|
|
878
|
+
assert.equal(b.ctx.ride('p2', 'p1', 1), true);
|
|
879
|
+
stand(b, 500);
|
|
880
|
+
// A station the rider starts outside of and is carried into, slowly.
|
|
881
|
+
const seat = { ...p2().at };
|
|
882
|
+
b.ctx.station('goal', { at: { x: seat.x + 3, y: 1, z: seat.z }, radius: 1 });
|
|
883
|
+
stand(b, 200);
|
|
884
|
+
const from = here(b);
|
|
885
|
+
walk(b, { x: from.x + 4, y: from.y, z: from.z }, { speed: 0.5, every: 50, after: 1000 });
|
|
886
|
+
assert.ok(p2().at.x - seat.x > 3.5, `carried through the station: ${p2().at.x - seat.x}`);
|
|
887
|
+
const seen = reads.filter((r) => r.d);
|
|
888
|
+
assert.ok(seen.length > 100);
|
|
889
|
+
assert.ok(seen.some((r) => r.d.inside), 'the rider was inside the station');
|
|
890
|
+
for (const { o, d } of seen) {
|
|
891
|
+
assert.equal(o.travel, 0, 'no travel from riding');
|
|
892
|
+
assert.equal(d.entered, false, 'riding enters nothing');
|
|
893
|
+
assert.equal(d.ms, 0);
|
|
894
|
+
assert.equal(o.ok, true);
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
await test('v1.165: a walker’s tune change is no transition: a doubled tune with no credit funds 0.6 m in 50 ms, as before', () => withBoot({}, (b) => {
|
|
900
|
+
const at = here(b);
|
|
901
|
+
b.ctx.placeAt('p1', { x: at.x + 2, y: at.y, z: at.z });
|
|
902
|
+
tick(b);
|
|
903
|
+
report(b, here(b));
|
|
904
|
+
b.ctx.tune('p1', { speed: 2 });
|
|
905
|
+
const travel = b.ctx.observed('p1').travel;
|
|
906
|
+
report(b, { x: here(b).x + 0.6, y: at.y, z: at.z });
|
|
907
|
+
tick(b);
|
|
908
|
+
const o = b.ctx.observed('p1');
|
|
909
|
+
assert.equal(o.speed, 6 * 2 * 1.25);
|
|
910
|
+
assert.ok(Math.abs(o.travel - travel - 0.6) < 1e-6, `funded at the new allowance: ${o.travel - travel}`);
|
|
911
|
+
}));
|
|
912
|
+
|
|
745
913
|
console.log(`test-observed: ${n} passed`);
|
|
@@ -428,4 +428,170 @@ await test('the town mounts a pack with its sounds as data: URLs, and a place pl
|
|
|
428
428
|
});
|
|
429
429
|
|
|
430
430
|
fs.rmSync(soundRoot, { recursive: true, force: true });
|
|
431
|
+
|
|
432
|
+
// --- symlinked imports ----------------------------------------------------------
|
|
433
|
+
|
|
434
|
+
// A town save once packed 309 of its 326 models: its imports root was a symlink
|
|
435
|
+
// and the walk skipped it, so the player's and the hats' models were missing
|
|
436
|
+
// while every hash of what was copied matched. A link is followed, and what
|
|
437
|
+
// cannot be followed refuses the pack.
|
|
438
|
+
const linkRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-links-test-'));
|
|
439
|
+
const deck = path.join(linkRoot, 'deck');
|
|
440
|
+
const kits = path.join(linkRoot, 'kits');
|
|
441
|
+
const put = (dir, rel, value) => {
|
|
442
|
+
const file = path.join(dir, rel);
|
|
443
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
444
|
+
fs.writeFileSync(
|
|
445
|
+
file,
|
|
446
|
+
typeof value === 'string' || Buffer.isBuffer(value) ? value : JSON.stringify(value),
|
|
447
|
+
);
|
|
448
|
+
};
|
|
449
|
+
const player = { parts: [{ kind: 'model', src: 'models/player-arm.pxmodel' }] };
|
|
450
|
+
const hat = { parts: [{ art: { front: 'imports/castle.hub-game/drawings/hats/cap.png' } }] };
|
|
451
|
+
const capPng = Buffer.from([0x89, 0x50, 0x4e, 0x47, 9, 9]);
|
|
452
|
+
put(deck, 'castle.json', {
|
|
453
|
+
server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
|
|
454
|
+
imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
|
|
455
|
+
hub: { contract: 1, title: 'Linked', controller: 'walk', result: { outcomes: ['win', 'lose'] } },
|
|
456
|
+
});
|
|
457
|
+
put(deck, 'scenes/main.scene', {
|
|
458
|
+
actors: [
|
|
459
|
+
{
|
|
460
|
+
id: 'me',
|
|
461
|
+
components: { Model: { file: '@imports/castle.physics-3d/models/player.pxmodel' } },
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
id: 'cap',
|
|
465
|
+
components: { Model: { file: '@imports/castle.hub-game/models/hats/cap.pxmodel' } },
|
|
466
|
+
},
|
|
467
|
+
],
|
|
468
|
+
});
|
|
469
|
+
// The whole imports root is a link to a folder outside the deck...
|
|
470
|
+
put(kits, 'imports/castle.physics-3d/models/player.pxmodel', player);
|
|
471
|
+
put(kits, 'imports/castle.physics-3d/models/player-arm.pxmodel', { parts: [] });
|
|
472
|
+
// ...and inside it, one import is itself a link to a kit checkout elsewhere,
|
|
473
|
+
// with a node_modules of its own that is never walked.
|
|
474
|
+
put(kits, 'hub-game/models/hats/cap.pxmodel', hat);
|
|
475
|
+
put(kits, 'hub-game/drawings/hats/cap.png', capPng);
|
|
476
|
+
fs.mkdirSync(path.join(kits, 'hub-game/node_modules/x'), { recursive: true });
|
|
477
|
+
fs.symlinkSync(
|
|
478
|
+
path.join(linkRoot, 'nowhere'),
|
|
479
|
+
path.join(kits, 'hub-game/node_modules/x/dangling.pxmodel'),
|
|
480
|
+
);
|
|
481
|
+
fs.symlinkSync(path.join(kits, 'hub-game'), path.join(kits, 'imports/castle.hub-game'));
|
|
482
|
+
fs.symlinkSync(path.join(kits, 'imports'), path.join(deck, 'imports'));
|
|
483
|
+
|
|
484
|
+
const linked = await pack({ deckDir: deck, outFile: path.join(linkRoot, 'out.json') });
|
|
485
|
+
|
|
486
|
+
await test('a pack follows a symlinked imports root and a symlinked import, and carries the models behind them', () => {
|
|
487
|
+
assert.deepEqual(linked.errors, []);
|
|
488
|
+
const out = JSON.parse(fs.readFileSync(path.join(linkRoot, 'out.json'), 'utf8'));
|
|
489
|
+
assert.deepEqual(validatePack(out).errors, []);
|
|
490
|
+
// Present, by name, with the bytes behind the link: not just consistent hashes.
|
|
491
|
+
assert.deepEqual(Object.keys(out.files).sort(), [
|
|
492
|
+
'imports/castle.hub-game/models/hats/cap.pxmodel',
|
|
493
|
+
'imports/castle.physics-3d/models/player-arm.pxmodel',
|
|
494
|
+
'imports/castle.physics-3d/models/player.pxmodel',
|
|
495
|
+
'scenes/main.scene',
|
|
496
|
+
]);
|
|
497
|
+
assert.deepEqual(
|
|
498
|
+
JSON.parse(out.files['imports/castle.physics-3d/models/player.pxmodel'].text),
|
|
499
|
+
player,
|
|
500
|
+
);
|
|
501
|
+
assert.deepEqual(
|
|
502
|
+
JSON.parse(out.files['imports/castle.hub-game/models/hats/cap.pxmodel'].text),
|
|
503
|
+
hat,
|
|
504
|
+
);
|
|
505
|
+
assert.deepEqual(Object.keys(out.media), ['imports/castle.hub-game/drawings/hats/cap.png']);
|
|
506
|
+
assert.equal(
|
|
507
|
+
out.media['imports/castle.hub-game/drawings/hats/cap.png'].base64,
|
|
508
|
+
capPng.toString('base64'),
|
|
509
|
+
);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
await test('a dangling symlink in the deck refuses the pack, naming it', async () => {
|
|
513
|
+
fs.symlinkSync(
|
|
514
|
+
path.join(linkRoot, 'gone'),
|
|
515
|
+
path.join(kits, 'imports/castle.physics-3d/models/gone.pxmodel'),
|
|
516
|
+
);
|
|
517
|
+
const refused = await pack({ deckDir: deck, outFile: path.join(linkRoot, 'refused.json') });
|
|
518
|
+
assert.equal(refused.errors.length, 1);
|
|
519
|
+
assert.match(
|
|
520
|
+
refused.errors[0],
|
|
521
|
+
/imports\/castle\.physics-3d\/models\/gone\.pxmodel is a symlink that does not resolve/,
|
|
522
|
+
);
|
|
523
|
+
assert.ok(!fs.existsSync(path.join(linkRoot, 'refused.json')));
|
|
524
|
+
fs.unlinkSync(path.join(kits, 'imports/castle.physics-3d/models/gone.pxmodel'));
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
await test('a symlink loop refuses the pack, naming it', async () => {
|
|
528
|
+
fs.symlinkSync(path.join(kits, 'imports'), path.join(kits, 'hub-game/models/loop'));
|
|
529
|
+
const refused = await pack({ deckDir: deck, outFile: path.join(linkRoot, 'refused.json') });
|
|
530
|
+
assert.equal(refused.errors.length, 1);
|
|
531
|
+
assert.match(refused.errors[0], /imports\/castle\.hub-game\/models\/loop is a symlink loop/);
|
|
532
|
+
fs.unlinkSync(path.join(kits, 'hub-game/models/loop'));
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
fs.rmSync(linkRoot, { recursive: true, force: true });
|
|
536
|
+
|
|
537
|
+
await test('a deck with no links packs a referenced file under its own node_modules or .git folder', async () => {
|
|
538
|
+
const plain = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-plain-test-'));
|
|
539
|
+
put(plain, 'castle.json', {
|
|
540
|
+
server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
|
|
541
|
+
imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
|
|
542
|
+
hub: { contract: 1, title: 'Plain', controller: 'walk', result: { outcomes: ['win', 'lose'] } },
|
|
543
|
+
});
|
|
544
|
+
put(plain, 'scenes/main.scene', { actors: [{ id: 'a', components: { Model: { file: 'models/base.pxmodel' } } }] });
|
|
545
|
+
put(plain, 'models/base.pxmodel', { parts: [{ src: 'models/node_modules/hat.pxmodel' }, { src: 'models/.git/cap.pxmodel' }] });
|
|
546
|
+
put(plain, 'models/node_modules/hat.pxmodel', { parts: [] });
|
|
547
|
+
put(plain, 'models/.git/cap.pxmodel', { parts: [] });
|
|
548
|
+
const result = await pack({ deckDir: plain, outFile: path.join(plain, 'out.json') });
|
|
549
|
+
assert.deepEqual(result.errors, []);
|
|
550
|
+
const out = JSON.parse(fs.readFileSync(path.join(plain, 'out.json'), 'utf8'));
|
|
551
|
+
assert.deepEqual(Object.keys(out.files).sort(), ['models/.git/cap.pxmodel', 'models/base.pxmodel', 'models/node_modules/hat.pxmodel', 'scenes/main.scene']);
|
|
552
|
+
fs.rmSync(plain, { recursive: true, force: true });
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
await test('a reference into a linked import\'s node_modules refuses the pack, naming it', async () => {
|
|
556
|
+
const linkedDeck = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-linked-nm-test-'));
|
|
557
|
+
put(linkedDeck, 'deck/castle.json', {
|
|
558
|
+
server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
|
|
559
|
+
imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
|
|
560
|
+
hub: { contract: 1, title: 'Linked', controller: 'walk', result: { outcomes: ['win', 'lose'] } },
|
|
561
|
+
});
|
|
562
|
+
put(linkedDeck, 'deck/scenes/main.scene', {
|
|
563
|
+
actors: [{ id: 'a', components: { Model: { file: '@imports/castle.hub-game/node_modules/x/hat.pxmodel' } } }],
|
|
564
|
+
});
|
|
565
|
+
put(linkedDeck, 'kit/node_modules/x/hat.pxmodel', { parts: [] });
|
|
566
|
+
fs.mkdirSync(path.join(linkedDeck, 'deck/imports'));
|
|
567
|
+
fs.symlinkSync(path.join(linkedDeck, 'kit'), path.join(linkedDeck, 'deck/imports/castle.hub-game'));
|
|
568
|
+
const refused = await pack({ deckDir: path.join(linkedDeck, 'deck'), outFile: path.join(linkedDeck, 'out.json') });
|
|
569
|
+
assert.equal(refused.errors.length, 1);
|
|
570
|
+
assert.match(refused.errors[0], /scenes\/main\.scene names imports\/castle\.hub-game\/node_modules\/x\/hat\.pxmodel/);
|
|
571
|
+
assert.ok(!fs.existsSync(path.join(linkedDeck, 'out.json')));
|
|
572
|
+
fs.rmSync(linkedDeck, { recursive: true, force: true });
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
await test('a manifest root inside a linked folder\'s node_modules refuses the pack, naming it', async () => {
|
|
576
|
+
const signDeck = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-pack-sign-nm-test-'));
|
|
577
|
+
put(signDeck, 'deck/castle.json', {
|
|
578
|
+
server: { main: 'imports/castle.hub-game/code/server/index.js', maxPlayers: 8 },
|
|
579
|
+
imports: { 'castle.hub-game': { source: 'builtin', kit: 'hub-game', version: '9.9.9' } },
|
|
580
|
+
hub: {
|
|
581
|
+
contract: 1,
|
|
582
|
+
title: 'Sign',
|
|
583
|
+
controller: 'walk',
|
|
584
|
+
result: { outcomes: ['win', 'lose'] },
|
|
585
|
+
sign: { model: 'models/node_modules/sign.pxmodel' },
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
put(signDeck, 'deck/scenes/main.scene', { actors: [] });
|
|
589
|
+
put(signDeck, 'kit/node_modules/sign.pxmodel', { parts: [] });
|
|
590
|
+
fs.symlinkSync(path.join(signDeck, 'kit'), path.join(signDeck, 'deck/models'));
|
|
591
|
+
const refused = await pack({ deckDir: path.join(signDeck, 'deck'), outFile: path.join(signDeck, 'out.json') });
|
|
592
|
+
assert.equal(refused.errors.length, 1, refused.errors.join('; '));
|
|
593
|
+
assert.match(refused.errors[0], /castle\.json hub names models\/node_modules\/sign\.pxmodel, inside models\/node_modules/);
|
|
594
|
+
assert.ok(!fs.existsSync(path.join(signDeck, 'out.json')));
|
|
595
|
+
fs.rmSync(signDeck, { recursive: true, force: true });
|
|
596
|
+
});
|
|
431
597
|
console.log(`${passed} pack tests passed.`);
|