castle-web-cli 0.4.232 → 0.4.234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +18 -2
- package/dist/castle-host/host.js +844 -39
- package/dist/castleJson.d.ts +23 -2
- package/dist/castleJson.js +46 -2
- package/dist/check.d.ts +3 -1
- package/dist/check.js +20 -3
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +50 -2
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +11 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +25 -1
- package/dist/save-deck.js +178 -9
- package/dist/serve.js +32 -11
- package/dist/shell/assets/{index-D2tWM896.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +339 -5
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +176 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +37 -6
- package/kits/base/sdk/hub.js +63 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +148 -32
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +81 -7
- package/kits/base/sdk/server/hub.d.ts +117 -0
- package/kits/base/sdk/server/hub.js +119 -2
- package/kits/base/sdk/server/platformHandle.d.ts +43 -1
- package/kits/base/sdk/server/storage.d.ts +17 -0
- package/kits/base/sdk/server/storage.js +65 -3
- package/kits/base/sdk/server/wrapper.d.ts +43 -6
- package/kits/base/sdk/server/wrapper.js +93 -9
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +451 -13
- package/kits/hub-game/README.md +63 -0
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +311 -35
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +253 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +472 -0
- package/kits/hub-game/code/client/build.js +38 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +2144 -160
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +515 -0
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +368 -29
- package/kits/hub-game/code/client/hookLayer.js +385 -20
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +177 -24
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +234 -0
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +146 -0
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +162 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +714 -59
- package/kits/hub-game/code/client/tiers.js +543 -52
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +39 -2
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +200 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +138 -0
- package/kits/hub-game/code/server/actors.js +11 -2
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +107 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +478 -0
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +272 -0
- package/kits/hub-game/code/server/history.js +7 -0
- package/kits/hub-game/code/server/hub.js +2510 -95
- package/kits/hub-game/code/server/idle.js +60 -12
- package/kits/hub-game/code/server/index.js +28 -6
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +36 -2
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +586 -7
- package/kits/hub-game/code/server/menu.js +161 -0
- package/kits/hub-game/code/server/npcs.js +1025 -113
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +30 -0
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +123 -0
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +175 -0
- package/kits/hub-game/code/server/wear.js +12 -0
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +53 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1753 -202
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +3475 -77
- package/kits/hub-game/docs/home-pieces.md +71 -0
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +10 -1
- package/kits/hub-game/package.json +6 -2
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +117 -16
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +132 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +26 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +123 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +853 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +38 -23
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +792 -0
- package/kits/hub-game/scripts/test-avatar.mjs +584 -7
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +1008 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +49 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +863 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +216 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +344 -0
- package/kits/hub-game/scripts/test-decor.mjs +464 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1224 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +961 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +758 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1594 -12
- package/kits/hub-game/scripts/test-hud-clear.mjs +484 -57
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +427 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +513 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +664 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +472 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +585 -0
- package/kits/hub-game/scripts/test-menu.mjs +319 -0
- package/kits/hub-game/scripts/test-npcs.mjs +2528 -13
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +541 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1733 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +901 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5437 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +449 -0
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1904 -0
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +412 -0
- package/kits/hub-game/scripts/test-tiers.mjs +476 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- package/kits/hub-game/scripts/test-vis.mjs +770 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +210 -0
- package/kits/hub-game/scripts/test-yours.mjs +403 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +443 -34
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +3 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +19 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +337 -3
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +42 -529
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +661 -87
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +9 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -277
- package/kits/physics-3d/engine3d/actornode.js +87 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +99 -0
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +126 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +514 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +106 -21
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +522 -10
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +890 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +1253 -76
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +10 -2
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2613 -82
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +2 -2
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +438 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +5 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +2001 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +582 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +657 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +10 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2174 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +7 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +419 -9
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +102 -22
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// The default world view: goals already become pointers, other actor labels
|
|
2
|
+
// use the existing three-slot distance/hysteresis rule in games as well.
|
|
3
|
+
import { makeLayoutCache } from './layoutCache.js';
|
|
4
|
+
import { near } from './labelsNear.js';
|
|
5
|
+
import { clearBox } from './padOccupancy.js';
|
|
6
|
+
import { overlaps, reservedCorners } from './safeLayout.js';
|
|
7
|
+
|
|
8
|
+
export const worldLabelFocus = (nearPolicy, game, throughDoor) => !nearPolicy || game || throughDoor;
|
|
9
|
+
|
|
10
|
+
export function mapWorldPoint(point, view) {
|
|
11
|
+
const area = view.world;
|
|
12
|
+
if (!area || (area.left === 0 && area.top === 0 && area.width === view.w && area.height === view.h)) {return point;}
|
|
13
|
+
const sx = area.width / view.w, sy = area.height / view.h;
|
|
14
|
+
return { ...point, x: area.left + point.x * sx, y: area.top + point.y * sy };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function offsetWorldPoint(point, view) {
|
|
18
|
+
return view.world ? { ...point, x: point.x + view.world.left, y: point.y + view.world.top } : point;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function relevantLabels(state, items, view, now) {
|
|
22
|
+
const area = view.world;
|
|
23
|
+
return near(state, items.map((item) => ({ ...item, kind: 'sign', box: area && item.box &&
|
|
24
|
+
(item.box.left < area.left || item.box.right > area.right || item.box.top < area.top || item.box.bottom > area.bottom) ? null : item.box })), view, now);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Pointers keep their words before ordinary labels. Labels retain their world
|
|
28
|
+
// anchor: when there is no clear air there, they collapse instead of becoming
|
|
29
|
+
// a second row of HUD. Speech/emotes/marks participate in clearance too.
|
|
30
|
+
export function worldPlacement(pointers, labels, controls, view) {
|
|
31
|
+
const insets = view.insets ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
32
|
+
const world = view.world;
|
|
33
|
+
const bounds = {
|
|
34
|
+
left: Math.max(6, insets.left, world?.left ?? 0),
|
|
35
|
+
right: Math.min(view.w - Math.max(6, insets.right), world?.right ?? view.w),
|
|
36
|
+
top: Math.max(6, insets.top, world?.top ?? 0),
|
|
37
|
+
bottom: Math.min(view.h - Math.max(6, insets.bottom), world?.bottom ?? view.h),
|
|
38
|
+
};
|
|
39
|
+
const corners = reservedCorners({ ...view, insets })
|
|
40
|
+
.map(({ x, y, w, h }) => ({ left: x, right: x + w, top: y, bottom: y + h }));
|
|
41
|
+
const safeEdges = [
|
|
42
|
+
{ left: 0, right: bounds.left, top: 0, bottom: view.h },
|
|
43
|
+
{ left: bounds.right, right: view.w, top: 0, bottom: view.h },
|
|
44
|
+
{ left: 0, right: view.w, top: 0, bottom: bounds.top },
|
|
45
|
+
{ left: 0, right: view.w, top: bounds.bottom, bottom: view.h },
|
|
46
|
+
].filter((box) => box.right > box.left && box.bottom > box.top);
|
|
47
|
+
const taken = [...controls, ...corners, ...safeEdges];
|
|
48
|
+
const pointerBoxes = pointers.map((box) => {
|
|
49
|
+
const placed = clearBox(box, taken, view);
|
|
50
|
+
if (placed) {taken.push(placed);}
|
|
51
|
+
return placed;
|
|
52
|
+
});
|
|
53
|
+
const labelBoxes = labels.map((box) => {
|
|
54
|
+
const fits = box.left >= bounds.left && box.right <= bounds.right && box.top >= bounds.top && box.bottom <= bounds.bottom;
|
|
55
|
+
if (!fits || taken.some((other) => overlaps(box, other))) {return null;}
|
|
56
|
+
taken.push(box);
|
|
57
|
+
return box;
|
|
58
|
+
});
|
|
59
|
+
return { pointers: pointerBoxes, labels: labelBoxes };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Try whole-width vertical bands first; the DOM pass can reflow on failure.
|
|
63
|
+
export function captionBand(box, controls, view) {
|
|
64
|
+
const height = box.bottom - box.top;
|
|
65
|
+
const topEdge = Math.max(8, view.insets?.top ?? 0);
|
|
66
|
+
const bottomEdge = view.h - Math.max(8, view.insets?.bottom ?? 0);
|
|
67
|
+
const tops = [...new Set([box.top, topEdge, bottomEdge - height,
|
|
68
|
+
...controls.flatMap((other) => [other.top - height - 8, other.bottom + 8])])]
|
|
69
|
+
.filter((top) => top >= topEdge && top + height <= bottomEdge)
|
|
70
|
+
.sort((a, b) => Math.abs(a - box.top) - Math.abs(b - box.top));
|
|
71
|
+
for (const top of tops) {
|
|
72
|
+
const candidate = { left: box.left, right: box.right, top, bottom: top + height };
|
|
73
|
+
if (!controls.some((other) => overlaps(candidate, other))) {return candidate;}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Widths come from actual horizontal gaps, including lanes narrower than a
|
|
79
|
+
// conventional text card. Sample each vertical band between obstacle edges.
|
|
80
|
+
export function captionWidths(controls, view) {
|
|
81
|
+
const left = Math.max(8, view.insets?.left ?? 0), right = view.w - Math.max(8, view.insets?.right ?? 0);
|
|
82
|
+
const ys = [...new Set([8, view.h - 8, ...controls.flatMap((box) => [box.top - 8, box.bottom + 8])])]
|
|
83
|
+
.filter((y) => y >= 8 && y <= view.h - 8).sort((a, b) => a - b);
|
|
84
|
+
const widths = new Set([Math.min(320, right - left)]);
|
|
85
|
+
for (let i = 1; i < ys.length; i++) {
|
|
86
|
+
const y = (ys[i - 1] + ys[i]) / 2;
|
|
87
|
+
const intervals = controls.filter((box) => box.top - 8 < y && box.bottom + 8 > y)
|
|
88
|
+
.map((box) => [Math.max(left, box.left - 8), Math.min(right, box.right + 8)])
|
|
89
|
+
.filter(([a, b]) => b > a).sort((a, b) => a[0] - b[0]);
|
|
90
|
+
let start = left;
|
|
91
|
+
for (const [a, b] of intervals) {
|
|
92
|
+
if (a > start) {widths.add(a - start);}
|
|
93
|
+
start = Math.max(start, b);
|
|
94
|
+
}
|
|
95
|
+
if (right > start) {widths.add(right - start);}
|
|
96
|
+
}
|
|
97
|
+
return [...widths].filter((width) => width >= 44).sort((a, b) => b - a);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function captionSlot(box, controls, view) {
|
|
101
|
+
const width = box.right - box.left, height = box.bottom - box.top;
|
|
102
|
+
const edge = (side) => Math.max(8, view.insets?.[side] ?? 0);
|
|
103
|
+
const lefts = [...new Set([box.left, edge('left'), view.w - edge('right') - width,
|
|
104
|
+
...controls.flatMap((other) => [other.left - width - 8, other.right + 8])])]
|
|
105
|
+
.filter((left) => left >= edge('left') && left + width <= view.w - edge('right'))
|
|
106
|
+
.sort((a, b) => Math.abs(a - box.left) - Math.abs(b - box.left));
|
|
107
|
+
const tops = [...new Set([box.top, edge('top'), view.h - edge('bottom') - height,
|
|
108
|
+
...controls.flatMap((other) => [other.top - height - 8, other.bottom + 8])])]
|
|
109
|
+
.filter((top) => top >= edge('top') && top + height <= view.h - edge('bottom'))
|
|
110
|
+
.sort((a, b) => Math.abs(a - box.top) - Math.abs(b - box.top));
|
|
111
|
+
for (const top of tops) {
|
|
112
|
+
for (const left of lefts) {
|
|
113
|
+
const candidate = { left, right: left + width, top, bottom: top + height };
|
|
114
|
+
if (!controls.some((other) => overlaps(candidate, other))) {return candidate;}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function makeWorldLayout(entries, view, obstacles = () => [], geometry = makeLayoutCache()) {
|
|
121
|
+
const hidden = new Set();
|
|
122
|
+
const shifted = new Map();
|
|
123
|
+
const reflowed = new Map();
|
|
124
|
+
function restoreReflowed() {
|
|
125
|
+
for (const [node, styles] of reflowed) {
|
|
126
|
+
Object.assign(node.style, styles);
|
|
127
|
+
// The snapshot may contain the narrower caption from the last flush.
|
|
128
|
+
geometry.invalidate(node);
|
|
129
|
+
}
|
|
130
|
+
reflowed.clear();
|
|
131
|
+
}
|
|
132
|
+
function begin() {
|
|
133
|
+
for (const node of hidden) {node.style.visibility = '';}
|
|
134
|
+
for (const [node, value] of shifted) {node.style.translate = value;}
|
|
135
|
+
restoreReflowed();
|
|
136
|
+
hidden.clear(); shifted.clear();
|
|
137
|
+
}
|
|
138
|
+
function flush() {
|
|
139
|
+
// Width restoration changes wrapping, so only those captions need a fresh
|
|
140
|
+
// DOM read. Ordinary surfaces keep using the frame-start snapshot.
|
|
141
|
+
restoreReflowed();
|
|
142
|
+
const surfaces = entries();
|
|
143
|
+
const styleHides = (style) => style?.display === 'none' || style?.visibility === 'hidden' || style?.opacity === '0';
|
|
144
|
+
// Surfaces share their layers, so each ancestor's style is read once per
|
|
145
|
+
// flush. Nothing is written between these reads.
|
|
146
|
+
const ancestorHidden = new Map();
|
|
147
|
+
const chainHidden = (start) => {
|
|
148
|
+
const walked = [];
|
|
149
|
+
let result = false;
|
|
150
|
+
for (let parent = start; parent; parent = parent.parentElement ?? parent.parent) {
|
|
151
|
+
if (ancestorHidden.has(parent)) {result = ancestorHidden.get(parent); break;}
|
|
152
|
+
walked.push(parent);
|
|
153
|
+
if (styleHides(globalThis.getComputedStyle?.(parent) ?? parent.style)) {result = true; break;}
|
|
154
|
+
}
|
|
155
|
+
for (const parent of walked) {ancestorHidden.set(parent, result);}
|
|
156
|
+
return result;
|
|
157
|
+
};
|
|
158
|
+
const visible = ({ node }) => {
|
|
159
|
+
if (!node || node.isConnected === false) {return null;}
|
|
160
|
+
// The node's own last-pass hide is ignored; an ancestor's is not.
|
|
161
|
+
const own = globalThis.getComputedStyle?.(node) ?? node.style;
|
|
162
|
+
if (own?.display === 'none' || (own?.visibility === 'hidden' && !hidden.has(node)) || own?.opacity === '0') {return null;}
|
|
163
|
+
if (chainHidden(node.parentElement ?? node.parent)) {return null;}
|
|
164
|
+
let box = geometry.rect(node);
|
|
165
|
+
if (shifted.has(node)) {
|
|
166
|
+
const [dx, dy] = node.style.translate.split(' ').map(Number.parseFloat);
|
|
167
|
+
const original = shifted.get(node) || '0 0';
|
|
168
|
+
const [ox, oy = '0'] = original.split(' ');
|
|
169
|
+
const pixels = (value, size) => (Number.parseFloat(value) || 0) * (value.endsWith('%') ? size / 100 : 1);
|
|
170
|
+
const x = pixels(ox, box.width) - dx, y = pixels(oy, box.height) - dy;
|
|
171
|
+
box = { left: box.left + x, right: box.right + x, top: box.top + y, bottom: box.bottom + y, width: box.width, height: box.height };
|
|
172
|
+
}
|
|
173
|
+
return box.width > 0 && box.height > 0 ? box : null;
|
|
174
|
+
};
|
|
175
|
+
const measured = surfaces.map((entry) => ({ ...entry, box: visible(entry) })).filter((entry) => entry.box);
|
|
176
|
+
// Restore the previous pass after reading its unshifted boxes, before the
|
|
177
|
+
// caption pass records this flush's shifts, hides and reflowed styles.
|
|
178
|
+
begin();
|
|
179
|
+
// Text bands yield to navigation, but never escape the viewport while
|
|
180
|
+
// doing so. Dense lanes reflow into a narrower gap before world labels.
|
|
181
|
+
const viewport = view();
|
|
182
|
+
const captions = ['hud-prompt', 'engine-look'].flatMap((id) => measured.filter((entry) => entry.id === id));
|
|
183
|
+
for (const caption of captions) {
|
|
184
|
+
const controls = measured.filter((entry) => entry !== caption &&
|
|
185
|
+
entry.kind !== 'label' && entry.kind !== 'pointer').map((entry) => entry.box)
|
|
186
|
+
.concat(reservedCorners({ ...viewport, insets: viewport.insets ?? { top: 0, right: 0, bottom: 0, left: 0 } })
|
|
187
|
+
.map(({ x, y, w, h }) => ({ left: x, right: x + w, top: y, bottom: y + h })));
|
|
188
|
+
let box = caption.box;
|
|
189
|
+
let placed = captionBand(box, controls, viewport);
|
|
190
|
+
if (!placed) {
|
|
191
|
+
const style = caption.node.style;
|
|
192
|
+
reflowed.set(caption.node, Object.fromEntries(['width', 'maxWidth', 'left', 'right', 'boxSizing', 'whiteSpace', 'maxHeight', 'overflowY', 'pointerEvents'].map((key) => [key, style[key]])));
|
|
193
|
+
for (const width of captionWidths(controls, viewport)) {
|
|
194
|
+
Object.assign(style, { width: `${width}px`, maxWidth: `${width}px`, left: `${(viewport.w - width) / 2}px`, right: 'auto', boxSizing: 'border-box', whiteSpace: 'normal' });
|
|
195
|
+
box = geometry.rect(caption.node);
|
|
196
|
+
placed = captionSlot(box, controls, viewport);
|
|
197
|
+
if (placed) {break;}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (!placed) {
|
|
201
|
+
// A menu owns its reading surface until it closes. Outside a menu,
|
|
202
|
+
// make a one-line scrollable caption in a measured gap, preserving
|
|
203
|
+
// access to the full words even when the complete paragraph won't fit.
|
|
204
|
+
const menu = measured.some((entry) => entry.id === 'menu' || entry.node.dataset?.hub === 'action-sheet');
|
|
205
|
+
if (!menu) {
|
|
206
|
+
for (const width of captionWidths(controls, viewport)) {
|
|
207
|
+
Object.assign(caption.node.style, { width: `${width}px`, maxWidth: `${width}px`, left: `${(viewport.w - width) / 2}px`, right: 'auto', maxHeight: '21px', overflowY: 'auto', pointerEvents: 'auto' });
|
|
208
|
+
box = geometry.rect(caption.node);
|
|
209
|
+
placed = captionSlot(box, controls, viewport);
|
|
210
|
+
if (placed) {break;}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!placed) {
|
|
214
|
+
caption.node.style.visibility = 'hidden'; hidden.add(caption.node);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (placed.left !== box.left || placed.top !== box.top) {
|
|
219
|
+
shifted.set(caption.node, caption.node.style.translate);
|
|
220
|
+
caption.node.style.translate = `${placed.left - box.left}px ${placed.top - box.top}px`;
|
|
221
|
+
}
|
|
222
|
+
caption.box = { left: placed.left, right: placed.right, top: placed.top, bottom: placed.top + box.bottom - box.top };
|
|
223
|
+
}
|
|
224
|
+
const pointers = measured.filter((entry) => entry.kind === 'pointer' && entry.id !== 'stuck')
|
|
225
|
+
.sort((a, b) => Number(b.id?.startsWith('pointer:goal:') === true) - Number(a.id?.startsWith('pointer:goal:') === true));
|
|
226
|
+
const labels = measured.filter((entry) => entry.kind === 'label');
|
|
227
|
+
const controls = measured.filter((entry) => (entry.kind !== 'pointer' || entry.id === 'stuck') && entry.kind !== 'label').map((entry) => entry.box);
|
|
228
|
+
const placements = worldPlacement(pointers.map((entry) => entry.box), labels.map((entry) => entry.box), [...controls, ...obstacles()], view());
|
|
229
|
+
for (const [items, boxes] of [[pointers, placements.pointers], [labels, placements.labels]]) {
|
|
230
|
+
items.forEach(({ node, box }, index) => {
|
|
231
|
+
const placed = boxes[index];
|
|
232
|
+
if (!placed) {node.style.visibility = 'hidden'; hidden.add(node);}
|
|
233
|
+
else if (placed.left !== box.left || placed.top !== box.top) {
|
|
234
|
+
shifted.set(node, node.style.translate);
|
|
235
|
+
node.style.translate = `${placed.left - box.left}px ${placed.top - box.top}px`;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return { begin, flush };
|
|
241
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// One town visit's account hearts and arrival offer. No browser storage.
|
|
2
|
+
const ARRIVAL_WAIT_MS = 60000;
|
|
3
|
+
// hub.results refreshes about once a minute; allow several reads to catch up.
|
|
4
|
+
const HEARTS_CATCH_UP_MS = 3 * 60000;
|
|
5
|
+
|
|
6
|
+
export function relativeDay(at, now = Date.now()) {
|
|
7
|
+
if (!Number.isFinite(at)) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
const day = (time) => {
|
|
11
|
+
const date = new Date(time);
|
|
12
|
+
return Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) / 86400000;
|
|
13
|
+
};
|
|
14
|
+
const days = Math.max(0, day(now) - day(at));
|
|
15
|
+
return days === 0 ? 'today' : days === 1 ? 'yesterday' : `${days} days ago`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function toggleHeart(hearts, door) {
|
|
19
|
+
return hearts.includes(door) ? hearts.filter((id) => id !== door) : [...hearts, door].slice(-8);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function makeYours(api, user, toast, clock = () => performance.now()) {
|
|
23
|
+
let visit = 0;
|
|
24
|
+
let occurrence = 0;
|
|
25
|
+
let offerKey = null;
|
|
26
|
+
let started = false;
|
|
27
|
+
let signed = false;
|
|
28
|
+
let available = false;
|
|
29
|
+
let confirmed = [];
|
|
30
|
+
let pending = [];
|
|
31
|
+
let saving = false;
|
|
32
|
+
let latestHearts = null;
|
|
33
|
+
let authoritativeUntil = 0;
|
|
34
|
+
let waitUntil = 0;
|
|
35
|
+
let arrived = false;
|
|
36
|
+
let offered = false;
|
|
37
|
+
let returning = null;
|
|
38
|
+
let returnLine = '';
|
|
39
|
+
let dismissed = false;
|
|
40
|
+
const hearts = () => pending.reduce((ids, door) => toggleHeart(ids, door), confirmed);
|
|
41
|
+
|
|
42
|
+
// Each toggle reads the account's hearts from ghost and writes the list with the
|
|
43
|
+
// toggle applied, one write at a time in this tab. The accepted limit: two tabs or
|
|
44
|
+
// devices of one account that toggle within the same read-to-write moment can each
|
|
45
|
+
// write over the other's read, so one of those two hearts is lost (tapped again, it
|
|
46
|
+
// stays). Ghost replaces the whole list; there is no atomic toggle. Hearts are a
|
|
47
|
+
// convenience list, as tokens.js accepts its own two-tab race for play money.
|
|
48
|
+
async function save() {
|
|
49
|
+
if (saving || !pending.length) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
saving = true;
|
|
53
|
+
const token = visit;
|
|
54
|
+
const door = pending[0];
|
|
55
|
+
try {
|
|
56
|
+
const fresh = await api.hearts();
|
|
57
|
+
if (token !== visit) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (fresh?.status !== 'ok') {
|
|
61
|
+
throw new Error('unavailable');
|
|
62
|
+
}
|
|
63
|
+
const answer = await api.setHearts(toggleHeart(fresh.hearts, door));
|
|
64
|
+
if (token !== visit) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (answer?.status !== 'ok') {
|
|
68
|
+
throw new Error('unavailable');
|
|
69
|
+
}
|
|
70
|
+
confirmed = [...answer.hearts];
|
|
71
|
+
authoritativeUntil = clock() + HEARTS_CATCH_UP_MS;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if (token !== visit) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (error?.code === 'UNKNOWN_COMMAND') {
|
|
77
|
+
available = false;
|
|
78
|
+
}
|
|
79
|
+
toast("Couldn't save that heart.");
|
|
80
|
+
} finally {
|
|
81
|
+
if (token === visit) {
|
|
82
|
+
pending.shift();
|
|
83
|
+
saving = false;
|
|
84
|
+
void save();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
clear() {
|
|
91
|
+
visit += 1;
|
|
92
|
+
occurrence = 0;
|
|
93
|
+
offerKey = null;
|
|
94
|
+
started = signed = available = saving = offered = dismissed = arrived = false;
|
|
95
|
+
confirmed = [];
|
|
96
|
+
pending = [];
|
|
97
|
+
latestHearts = returning = null;
|
|
98
|
+
authoritativeUntil = 0;
|
|
99
|
+
returnLine = '';
|
|
100
|
+
waitUntil = 0;
|
|
101
|
+
},
|
|
102
|
+
returned(door, result = null) {
|
|
103
|
+
offerKey = `yours:${visit}:return:${++occurrence}`;
|
|
104
|
+
returning = door;
|
|
105
|
+
const last = Number.isFinite(result?.score) ? `Last ${result.score}${['ms', 's', 'points'].includes(result.unit) ? ` ${result.unit}` : ''}` : result?.outcome ?? '';
|
|
106
|
+
returnLine = [last, 'today'].filter(Boolean).join(' · ');
|
|
107
|
+
offered = false;
|
|
108
|
+
dismissed = false;
|
|
109
|
+
arrived = false;
|
|
110
|
+
waitUntil = 0;
|
|
111
|
+
},
|
|
112
|
+
frame(town, state, now) {
|
|
113
|
+
if (!town) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!started) {
|
|
117
|
+
started = true;
|
|
118
|
+
const token = visit;
|
|
119
|
+
Promise.resolve(user?.getCurrent?.()).then(async (me) => {
|
|
120
|
+
if (token !== visit || !me?.userId || me.isAnonymous) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
signed = true;
|
|
124
|
+
if (typeof api?.hearts !== 'function') {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const answer = await api.hearts();
|
|
128
|
+
if (token === visit && answer?.status === 'ok') {
|
|
129
|
+
available = true;
|
|
130
|
+
if (!pending.length) {
|
|
131
|
+
// The private snapshot may already have arrived and been latched.
|
|
132
|
+
confirmed = [...(latestHearts ?? answer.hearts)];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}).catch(() => {});
|
|
136
|
+
}
|
|
137
|
+
if (!waitUntil) {
|
|
138
|
+
waitUntil = now + ARRIVAL_WAIT_MS;
|
|
139
|
+
}
|
|
140
|
+
if (state) {
|
|
141
|
+
latestHearts = [...state.hearts];
|
|
142
|
+
}
|
|
143
|
+
// Reconsider even a buffered snapshot each frame once the write's
|
|
144
|
+
// freshness window expires; a matching snapshot never shortens it.
|
|
145
|
+
if (!pending.length && latestHearts && clock() >= authoritativeUntil && JSON.stringify(latestHearts) !== JSON.stringify(confirmed)) {
|
|
146
|
+
confirmed = [...latestHearts];
|
|
147
|
+
}
|
|
148
|
+
if (now < waitUntil && signed && (state?.rows?.length || confirmed.length || returning)) {
|
|
149
|
+
arrived = true;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
rows(state, doors) {
|
|
153
|
+
if (!signed) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
const ids = hearts();
|
|
157
|
+
const recent = (state?.rows ?? []).map((r) => ({ ...r, line: [r.line, relativeDay(r.lastAt)].filter(Boolean).join(' · ') })).filter((r) => doors.some((d) => d.id === r.door) && (ids.includes(r.door) || r.line));
|
|
158
|
+
const hearted = ids.flatMap((id) => {
|
|
159
|
+
const door = doors.find((d) => d.id === id);
|
|
160
|
+
return door ? [{ ...(recent.find((r) => r.door === id) ?? { door: id, title: door.title, line: '' }), hearted: true }] : [];
|
|
161
|
+
});
|
|
162
|
+
return [...hearted, ...recent.filter((r) => !ids.includes(r.door)).map((r) => ({ ...r, hearted: false }))].slice(0, 5);
|
|
163
|
+
},
|
|
164
|
+
controls() {
|
|
165
|
+
return signed && available ? { hearts: hearts() } : null;
|
|
166
|
+
},
|
|
167
|
+
toggle(door) {
|
|
168
|
+
if (!signed || !available) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
pending.push(door);
|
|
172
|
+
void save();
|
|
173
|
+
},
|
|
174
|
+
ask(state, doors, party, now) {
|
|
175
|
+
if (!signed || dismissed || (!arrived && !offered && waitUntil && now >= waitUntil)) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const rows = this.rows(state, doors);
|
|
179
|
+
const row = returning ? rows.find((r) => r.door === returning) ?? (() => {
|
|
180
|
+
const door = doors.find((d) => d.id === returning);
|
|
181
|
+
return door ? { door: door.id, title: door.title, line: '' } : null;
|
|
182
|
+
})() : rows[0];
|
|
183
|
+
if (!row) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
if (!offered) {
|
|
187
|
+
offered = true;
|
|
188
|
+
offerKey ??= `yours:${visit}:arrival`;
|
|
189
|
+
}
|
|
190
|
+
const door = doors.find((d) => d.id === row.door);
|
|
191
|
+
const controls = this.controls();
|
|
192
|
+
const line = row.line || (returning ? returnLine : '');
|
|
193
|
+
const together = party?.length && !door?.solo;
|
|
194
|
+
return { key: `yours:${offerKey}:${row.door}:${hearts().join(',')}:${line}:${Boolean(together)}:${Boolean(returning && controls)}`, slotKey: offerKey, kind: 'yours', door: row.door, text: `♥ ${row.title}`, line, yes: together ? 'Go together' : 'Go', no: 'Not now', ...(returning ? { requiresArrivalPlacement: true } : {}), ...(returning && controls ? { heart: hearts().includes(row.door) } : {}) };
|
|
195
|
+
},
|
|
196
|
+
dismiss() {
|
|
197
|
+
dismissed = true;
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// v1.78: the same private spec rules at the API and at the client boundary.
|
|
2
|
+
const DIRECTIONS = /[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028-\u202e\u2060-\u2069\ufeff]/;
|
|
3
|
+
const object = (value) => value !== null && typeof value === 'object' && [Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
4
|
+
function need(condition, message) {
|
|
5
|
+
if (!condition) {
|
|
6
|
+
throw new TypeError(`hub.companion: ${message}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export const DRESS = Object.freeze({
|
|
10
|
+
species: Object.freeze(['songbird', 'owl', 'parrot', 'hummingbird']),
|
|
11
|
+
wear: Object.freeze(['tophat', 'sunhat', 'bow', 'scarf', 'stampcap', 'flowercrown']),
|
|
12
|
+
tint: Object.freeze(['rose', 'mint', 'midnight', 'gold']),
|
|
13
|
+
});
|
|
14
|
+
export function checkDress(value) {
|
|
15
|
+
need(object(value), 'dress must be a plain object');
|
|
16
|
+
need(Reflect.ownKeys(value).every((key) => Object.hasOwn(DRESS, key)), 'dress has an unknown key');
|
|
17
|
+
const out = {};
|
|
18
|
+
for (const key of Object.keys(DRESS)) {
|
|
19
|
+
if (!Object.hasOwn(value, key)) { continue; }
|
|
20
|
+
const choice = value[key];
|
|
21
|
+
need(DRESS[key].includes(choice), `dress.${key} is unknown`);
|
|
22
|
+
if (choice !== 'songbird') { out[key] = choice; }
|
|
23
|
+
}
|
|
24
|
+
return Object.keys(out).length ? out : undefined;
|
|
25
|
+
}
|
|
26
|
+
export function check(spec) {
|
|
27
|
+
if (spec === null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
need(object(spec), 'spec must be a plain object or null');
|
|
31
|
+
need(Reflect.ownKeys(spec).every((key) => ['look', 'say', 'at', 'dress', 'pose'].includes(key)), 'spec has an unknown key');
|
|
32
|
+
need(Object.hasOwn(spec, 'look'), 'look must be an own property');
|
|
33
|
+
const look = spec.look;
|
|
34
|
+
const hasSay = Object.hasOwn(spec, 'say'), hasAt = Object.hasOwn(spec, 'at');
|
|
35
|
+
const say = hasSay ? spec.say : undefined, at = hasAt ? spec.at : undefined;
|
|
36
|
+
need(look === 'lantern' || look === 'bird', 'look must be lantern or bird');
|
|
37
|
+
need(!hasSay || (typeof say === 'string' && say.length <= 240 && say.trim().length > 0 && Array.from(say).length <= 80 && !DIRECTIONS.test(say)), 'say must be 1..80 code points, at most 240 UTF-16 units, one non-blank line without control, direction or zero-width characters');
|
|
38
|
+
need(!hasAt || (typeof at === 'string' && at.length >= 1 && at.length <= 64), 'at must be a scene actor id of 1..64 characters');
|
|
39
|
+
const hasDress = Object.hasOwn(spec, 'dress');
|
|
40
|
+
need(!hasDress || look === 'bird', 'dress requires bird');
|
|
41
|
+
const dress = hasDress ? checkDress(spec.dress) : undefined;
|
|
42
|
+
const hasPose = Object.hasOwn(spec, 'pose'), pose = hasPose ? spec.pose : undefined;
|
|
43
|
+
need(!hasPose || (look === 'bird' && pose === 'show'), 'pose must be show and requires bird');
|
|
44
|
+
return { look, ...(hasSay ? { say } : {}), ...(hasAt ? { at } : {}), ...(dress ? { dress } : {}), ...(hasPose ? { pose } : {}) };
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// NPC replies are plain text in the panel and over the body. Keep the mind's
|
|
2
|
+
// canonical reply intact; remove only paired emphasis markers for display.
|
|
3
|
+
export function npcDisplayText(text) {
|
|
4
|
+
let line = text.trim();
|
|
5
|
+
if (line.length > 1 && /^["“]/.test(line) && /["”]$/.test(line)) {
|
|
6
|
+
line = line.slice(1, -1).trim();
|
|
7
|
+
}
|
|
8
|
+
const stack = [];
|
|
9
|
+
const removed = new Set();
|
|
10
|
+
for (let i = 0; i < line.length; i++) {
|
|
11
|
+
const marker = line[i];
|
|
12
|
+
if (marker === '\n') {
|
|
13
|
+
stack.length = 0;
|
|
14
|
+
}
|
|
15
|
+
if (marker !== '*' && marker !== '_') {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const start = i;
|
|
19
|
+
while (line[i + 1] === marker) {
|
|
20
|
+
i++;
|
|
21
|
+
}
|
|
22
|
+
const size = i - start + 1;
|
|
23
|
+
if (size > 3 || line[start - 1] === '\\') {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const before = line[start - 1] ?? '';
|
|
27
|
+
const after = line[i + 1] ?? '';
|
|
28
|
+
// Whitespace-surrounded stars and underscores inside identifiers are literal.
|
|
29
|
+
const closes = Boolean(before && !/\s/.test(before) && (marker !== '_' || !/\w/.test(after)));
|
|
30
|
+
const opens = Boolean(after && !/\s/.test(after) && (marker !== '_' || !/\w/.test(before)));
|
|
31
|
+
let remaining = size;
|
|
32
|
+
if (closes) {
|
|
33
|
+
while (remaining && stack.length && stack[stack.length - 1].marker === marker) {
|
|
34
|
+
const opening = stack[stack.length - 1];
|
|
35
|
+
const consumed = Math.min(opening.size, remaining);
|
|
36
|
+
for (let j = 0; j < consumed; j++) {
|
|
37
|
+
removed.add(opening.start + opening.size - consumed + j);
|
|
38
|
+
removed.add(start + size - remaining + j);
|
|
39
|
+
}
|
|
40
|
+
remaining -= consumed;
|
|
41
|
+
opening.size -= consumed;
|
|
42
|
+
if (!opening.size) {
|
|
43
|
+
stack.pop();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (opens && remaining) {
|
|
48
|
+
stack.push({ marker, start: start + size - remaining, size: remaining });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return line
|
|
52
|
+
.split('')
|
|
53
|
+
.filter((_char, i) => !removed.has(i))
|
|
54
|
+
.join('');
|
|
55
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Shared by private chip labels, prompt titles and answers: controls, every
|
|
2
|
+
// Bidi_Control character and the zero-width ones are refused.
|
|
3
|
+
export const REFUSED_TEXT = /[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u202a-\u202e\u2060-\u2069\ufeff]/;
|
|
4
|
+
|
|
5
|
+
// Pure validation shared by the client and server; no hooks or state imports.
|
|
6
|
+
export const validPrivateText = (text, max) => typeof text === 'string' && text.length <= 4 * max &&
|
|
7
|
+
text.trim().length > 0 && Array.from(text).length <= max && !REFUSED_TEXT.test(text);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// v1.127: private prompt sets and one-shot presses. No state without hub.act.
|
|
2
|
+
import { interaction } from '../shared/act.js';
|
|
3
|
+
import * as Idle from './idle.js';
|
|
4
|
+
import * as Grab from './grab.js';
|
|
5
|
+
|
|
6
|
+
export const HOLD_MS = 500;
|
|
7
|
+
export const HOLD_LATENCY_ALLOWANCE_MS = 150;
|
|
8
|
+
const MAX_HOLD_MS = 2000;
|
|
9
|
+
function available(h, id) {
|
|
10
|
+
const entry = h.players.get(id);
|
|
11
|
+
return entry?.arrived && !entry.ended && !entry.progressReading &&
|
|
12
|
+
h.session?.players.some(p => p.playerId === id) && h.sim.players.has(id) &&
|
|
13
|
+
!h.resumeDeparting?.has(id) && !h.actDeparting?.has(id) && !h.resumePending?.has(id) &&
|
|
14
|
+
(!h.held.has(id) || Boolean(Idle.seat(h, id)));
|
|
15
|
+
}
|
|
16
|
+
function shown(h, id, actor) {
|
|
17
|
+
return !(h.visMe?.get(id)?.get(actor) ?? h.hidden.has(actor));
|
|
18
|
+
}
|
|
19
|
+
function pose(h, actor) {
|
|
20
|
+
return h.sim.objects?.get(actor.id)?.body?.translation() ?? h.sim.bodies?.get(actor.id)?.translation() ??
|
|
21
|
+
h.poses?.get(actor.id) ?? h.spawned?.get(actor.id)?.at ?? actor.components.Transform;
|
|
22
|
+
}
|
|
23
|
+
export function offers(h, id) {
|
|
24
|
+
if (!available(h, id)) {return [];}
|
|
25
|
+
const at = h.sim.players.get(id).at, seated = Idle.seat(h, id), holding = Grab.holding(h, id);
|
|
26
|
+
const out = [], seen = new Set(), duplicate = new Set();
|
|
27
|
+
const actors = [...h.actors, ...[...(h.spawned?.values() ?? [])].map(entry => entry.actor)];
|
|
28
|
+
for (const actor of actors) {
|
|
29
|
+
const item = interaction(actor, h.place, h.spawned?.has(actor.id));
|
|
30
|
+
if (!item) {continue;}
|
|
31
|
+
if (seen.has(item.id)) {duplicate.add(item.id);}
|
|
32
|
+
seen.add(item.id);
|
|
33
|
+
if (!shown(h, id, actor.id) || (seated && actor.id !== seated) || (holding && actor.id !== holding)) {continue;}
|
|
34
|
+
const t = { ...actor.components.Transform, ...pose(h, actor) };
|
|
35
|
+
if (!at || !t || !Number.isFinite(t.x) || !Number.isFinite(t.y) || !Number.isFinite(t.z)) {continue;}
|
|
36
|
+
let distance = Math.hypot(at.x - t.x, at.y - t.y, at.z - t.z);
|
|
37
|
+
if (item.op === 'sit') {
|
|
38
|
+
if (!Idle.seatOf(h, actor.id) || [...h.seated].some(([other, seat]) => other !== id && seat === actor.id)) {continue;}
|
|
39
|
+
distance = Idle.footprintDistance({ ...actor, components: { ...actor.components, Transform: t } }, at);
|
|
40
|
+
if (Math.abs(at.y - t.y) > 3) {continue;}
|
|
41
|
+
if (seated) {item.verb = 'Stand'; item.op = 'stand';}
|
|
42
|
+
}
|
|
43
|
+
if (item.op === 'grab') {
|
|
44
|
+
const object = h.sim.objects?.get(actor.id);
|
|
45
|
+
if (!object?.body || object.owner !== id || (h.keptFor?.has(actor.id) && h.keptFor.get(actor.id) !== id)) {continue;}
|
|
46
|
+
if (holding) {item.verb = 'Throw'; item.op = 'throw'; distance = 0;}
|
|
47
|
+
else if (!object.claimable) {continue;}
|
|
48
|
+
}
|
|
49
|
+
if (distance <= item.reach) {out.push(item);}
|
|
50
|
+
}
|
|
51
|
+
return out.filter(item => !duplicate.has(item.id)).sort((a, b) => a.id.localeCompare(b.id));
|
|
52
|
+
}
|
|
53
|
+
function state(h, id) {
|
|
54
|
+
h.actPlayers ??= new Map();
|
|
55
|
+
if (!h.actPlayers.has(id)) {h.actPlayers.set(id, { json: null, sent: [], last: 0, hold: null });}
|
|
56
|
+
return h.actPlayers.get(id);
|
|
57
|
+
}
|
|
58
|
+
function sync(h, id, replay = false) {
|
|
59
|
+
const s = state(h, id), items = offers(h, id).map(({ id, verb, hold }) => ({ id, verb, hold }));
|
|
60
|
+
const json = JSON.stringify(items);
|
|
61
|
+
if (json !== s.json || replay) {
|
|
62
|
+
s.hold = null;
|
|
63
|
+
s.json = json; s.sent = items;
|
|
64
|
+
h.session.send(id, { k: 'hub-prompts', items });
|
|
65
|
+
}
|
|
66
|
+
return s;
|
|
67
|
+
}
|
|
68
|
+
export function tick(h) {
|
|
69
|
+
if (h.manifest.act !== true) {return;}
|
|
70
|
+
for (const [id] of h.players) {
|
|
71
|
+
if (!h.session?.players.some(p => p.playerId === id)) {forget(h, id); continue;}
|
|
72
|
+
const s = sync(h, id);
|
|
73
|
+
if (s.hold && (h.sim.timeMs - s.hold.at > MAX_HOLD_MS || !offers(h, id).some(item => item.id === s.hold.id))) {s.hold = null;}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function replay(h, id) {
|
|
77
|
+
if (h.manifest.act === true) {h.actDeparting?.delete(id); sync(h, id, true);}
|
|
78
|
+
}
|
|
79
|
+
export function forget(h, id) {h.actPlayers?.delete(id); h.actDeparting?.delete(id);}
|
|
80
|
+
export function message(h, player, data, placeAt) {
|
|
81
|
+
if (h.manifest.act !== true || !available(h, player?.playerId)) {return;}
|
|
82
|
+
const id = player.playerId, s = state(h, id), now = h.sim.timeMs;
|
|
83
|
+
// Cancellation never waits for a rate token: an early release cannot be
|
|
84
|
+
// turned into a completed hold by exhausting the input budget.
|
|
85
|
+
if (data?.k === 'hub-act-hold' && data.down === false && s.hold?.id === data.id && s.hold.n === data.n) {s.hold = null; return;}
|
|
86
|
+
s.budget ??= { tokens: 8, at: now };
|
|
87
|
+
s.budget.tokens = Math.min(8, s.budget.tokens + Math.max(0, now - s.budget.at) * 0.006);
|
|
88
|
+
s.budget.at = now;
|
|
89
|
+
if (s.budget.tokens < 1) {return;}
|
|
90
|
+
s.budget.tokens -= 1;
|
|
91
|
+
const holdWire = data?.k === 'hub-act-hold';
|
|
92
|
+
if (!data || !Object.keys(data).every(key => (holdWire ? ['k', 'id', 'n', 'down'] : ['k', 'id', 'n']).includes(key)) ||
|
|
93
|
+
typeof data.id !== 'string' || !Number.isSafeInteger(data.n) || data.n <= 0) {return;}
|
|
94
|
+
const item = offers(h, id).find(item => item.id === data.id);
|
|
95
|
+
if (!item || !s.sent.some(sent => sent.id === item.id && sent.verb === item.verb && sent.hold === item.hold)) {
|
|
96
|
+
s.hold = null; return;
|
|
97
|
+
}
|
|
98
|
+
if (holdWire) {
|
|
99
|
+
if (typeof data.down !== 'boolean' || !item.hold) {return;}
|
|
100
|
+
if (!data.down) {
|
|
101
|
+
if (s.hold?.id === data.id && s.hold.n === data.n) {s.hold = null;}
|
|
102
|
+
} else if (data.n > s.last) {
|
|
103
|
+
s.last = data.n; s.hold = { id: item.id, n: data.n, at: now };
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (item.hold) {
|
|
108
|
+
const press = s.hold;
|
|
109
|
+
s.hold = null;
|
|
110
|
+
if (!press || press.id !== data.id || press.n !== data.n || now - press.at < HOLD_MS - HOLD_LATENCY_ALLOWANCE_MS || now - press.at > MAX_HOLD_MS) {return;}
|
|
111
|
+
} else {
|
|
112
|
+
if (data.n <= s.last) {return;}
|
|
113
|
+
s.last = data.n;
|
|
114
|
+
}
|
|
115
|
+
// Consume before hooks; even a hook that throws cannot repeat the press.
|
|
116
|
+
if (item.op === 'sit') {Idle.sitMessage(h, placeAt, id, { seat: item.actor });}
|
|
117
|
+
else if (item.op === 'stand') {Idle.standMessage(h, id);}
|
|
118
|
+
else if (item.op === 'grab' || item.op === 'throw') {Grab.message(h, id, { actor: item.actor, op: item.op });}
|
|
119
|
+
else if (item.op === 'talk') {h.npcs.message(player, { k: 'hub-npc-open', npc: item.actor });}
|
|
120
|
+
else {
|
|
121
|
+
try {h.hooks.message?.(h.ctx, player, { k: 'hub-act', id: item.id, n: data.n });}
|
|
122
|
+
catch {console.warn('[hub] Act message hook failed');}
|
|
123
|
+
}
|
|
124
|
+
}
|