@voltro/plugin-rooms 0.0.0-stage → 0.87.0
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/CHANGELOG.md +24329 -0
- package/LICENSE +61 -0
- package/README.md +9204 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +11322 -0
- package/dist/actor.js +1474 -0
- package/dist/apiBinding.js +678 -0
- package/dist/apiRegistryBinding.js +399 -0
- package/dist/apiReservations.js +433 -0
- package/dist/baselines.js +73 -0
- package/dist/bots.d.ts +1485 -0
- package/dist/bots.js +563 -0
- package/dist/catalog.js +80 -0
- package/dist/checkpointJson.js +24 -0
- package/dist/checkpointStore.js +386 -0
- package/dist/client.js +56 -0
- package/dist/clockSync.js +51 -0
- package/dist/collision.js +156 -0
- package/dist/commandDelivery.js +101 -0
- package/dist/commandRecord.js +11 -0
- package/dist/commandWithdrawal.js +183 -0
- package/dist/connection.js +497 -0
- package/dist/controlCarrier.js +375 -0
- package/dist/controlRegistry.js +79 -0
- package/dist/controlTarget.js +45 -0
- package/dist/controlTransport.js +574 -0
- package/dist/developmentBinding.js +113 -0
- package/dist/directory.js +323 -0
- package/dist/directoryProjection.js +117 -0
- package/dist/errors.d.ts +125 -0
- package/dist/errors.js +53 -0
- package/dist/fixed.d.ts +284 -0
- package/dist/fixed.js +10 -0
- package/dist/fixed32.js +134 -0
- package/dist/fixedCollision.js +60 -0
- package/dist/fixedCollision32.js +109 -0
- package/dist/fixedMath.js +56 -0
- package/dist/fixedRaw.js +11 -0
- package/dist/fixedSlabs.js +34 -0
- package/dist/fixedTrig.js +48 -0
- package/dist/fixedTrig32.js +38 -0
- package/dist/fixedVectors.js +113 -0
- package/dist/fixedVectors32.js +95 -0
- package/dist/fixedWide.js +50 -0
- package/dist/fixedWords.js +46 -0
- package/dist/gateway.js +57 -0
- package/dist/geometry-retention-app/rooms.geometryJournalRetention.workflow.server.tsx +4 -0
- package/dist/geometry-retention-app/rooms.geometryJournalRetention.workflow.tsx +14 -0
- package/dist/geometry-worker/worker.d.mts +2 -0
- package/dist/geometry-worker/worker.mjs +50 -0
- package/dist/geometry.d.ts +2249 -0
- package/dist/geometry.js +40 -0
- package/dist/geometryActivation.js +82 -0
- package/dist/geometryActorInventory.js +108 -0
- package/dist/geometryAdminClient.js +87 -0
- package/dist/geometryAdminData.js +32 -0
- package/dist/geometryAdminFixtures.js +50 -0
- package/dist/geometryAdminPorts.js +5 -0
- package/dist/geometryAdminRpc.js +58 -0
- package/dist/geometryAdminRpcRoutes.js +49 -0
- package/dist/geometryAdminSchemas.js +39 -0
- package/dist/geometryAdministration.js +190 -0
- package/dist/geometryAdministrationPorts.js +5 -0
- package/dist/geometryApiBinding.js +165 -0
- package/dist/geometryAppStorage.js +58 -0
- package/dist/geometryArtifacts.js +198 -0
- package/dist/geometryAssetBundle.js +117 -0
- package/dist/geometryAssetClient.js +25 -0
- package/dist/geometryAssetData.js +106 -0
- package/dist/geometryAssetHttp.js +123 -0
- package/dist/geometryAssetPorts.js +5 -0
- package/dist/geometryAssetRpc.js +30 -0
- package/dist/geometryAssetRpcRoutes.js +40 -0
- package/dist/geometryAssetStorageGrant.js +103 -0
- package/dist/geometryBoxOverlap.js +110 -0
- package/dist/geometryCatalogueDigest.js +111 -0
- package/dist/geometryCellCoverage.js +85 -0
- package/dist/geometryCellLoader.js +28 -0
- package/dist/geometryChannel.js +134 -0
- package/dist/geometryChunkHttp.js +54 -0
- package/dist/geometryChunkLeases.js +22 -0
- package/dist/geometryClient.d.ts +1429 -0
- package/dist/geometryClient.js +149 -0
- package/dist/geometryClientChunks.js +330 -0
- package/dist/geometryClientDelta.js +25 -0
- package/dist/geometryClientHttp.js +37 -0
- package/dist/geometryClientInterest.js +109 -0
- package/dist/geometryClientStatic.js +34 -0
- package/dist/geometryCms.d.ts +763 -0
- package/dist/geometryCms.js +217 -0
- package/dist/geometryCommitCoordinator.js +241 -0
- package/dist/geometryCompactionFixture.js +84 -0
- package/dist/geometryCompactionStrategies.js +38 -0
- package/dist/geometryConnectionClient.js +23 -0
- package/dist/geometryDerivationFixtures.js +141 -0
- package/dist/geometryDerivationStrategies.js +27 -0
- package/dist/geometryDigest.js +13 -0
- package/dist/geometryEditChannel.js +70 -0
- package/dist/geometryEditIngress.js +263 -0
- package/dist/geometryEdits.js +366 -0
- package/dist/geometryEnvelope.js +41 -0
- package/dist/geometryGridRaycast.js +92 -0
- package/dist/geometryGridSweep.js +92 -0
- package/dist/geometryHeightfield.js +166 -0
- package/dist/geometryHeightfieldRaycast.js +74 -0
- package/dist/geometryHeightfieldSweep.js +85 -0
- package/dist/geometryHeightfieldVolume.js +45 -0
- package/dist/geometryHost.js +322 -0
- package/dist/geometryHostDirectory.js +207 -0
- package/dist/geometryHostMutations.js +137 -0
- package/dist/geometryHostStreams.js +124 -0
- package/dist/geometryHttpBody.js +76 -0
- package/dist/geometryHttpRoutes.js +112 -0
- package/dist/geometryImportGltf.js +300 -0
- package/dist/geometryImportLdtk.js +54 -0
- package/dist/geometryImportPng.js +144 -0
- package/dist/geometryImportPublication.js +67 -0
- package/dist/geometryImportTiled.js +39 -0
- package/dist/geometryImportTiles.js +136 -0
- package/dist/geometryImportVox.js +130 -0
- package/dist/geometryImportedSource.js +101 -0
- package/dist/geometryInspectEndpoint.js +248 -0
- package/dist/geometryInspection.js +92 -0
- package/dist/geometryInstall.js +121 -0
- package/dist/geometryJournalArchiveData.js +21 -0
- package/dist/geometryJournalArchiveIndex.js +330 -0
- package/dist/geometryJournalArchiveTable.js +21 -0
- package/dist/geometryJournalCompaction.js +100 -0
- package/dist/geometryJournalPatch.js +47 -0
- package/dist/geometryJournalRetention.js +112 -0
- package/dist/geometryJournalRetentionSchemas.js +36 -0
- package/dist/geometryJournalRetentionSweep.js +112 -0
- package/dist/geometryJournalRetentionWorkflow.js +28 -0
- package/dist/geometryJournalRetentionWorkflowData.js +31 -0
- package/dist/geometryJournalStorage.js +148 -0
- package/dist/geometryLoader.js +118 -0
- package/dist/geometryManifest.js +113 -0
- package/dist/geometryManifestChannel.js +93 -0
- package/dist/geometryManifestClient.js +122 -0
- package/dist/geometryManifestData.js +49 -0
- package/dist/geometryManifestPorts.js +5 -0
- package/dist/geometryManifestPublication.js +109 -0
- package/dist/geometryManifestSource.js +68 -0
- package/dist/geometryMigrationJournal.js +14 -0
- package/dist/geometryMigrationStrategies.js +7 -0
- package/dist/geometryMigrations.js +323 -0
- package/dist/geometryNativeMetadata.js +52 -0
- package/dist/geometryPatch.js +170 -0
- package/dist/geometryPersistence.js +449 -0
- package/dist/geometryPersistenceCapture.js +69 -0
- package/dist/geometryPersistenceData.js +140 -0
- package/dist/geometryPersistencePorts.js +5 -0
- package/dist/geometryPlayerAdmission.js +34 -0
- package/dist/geometryPlayerEditOwner.js +265 -0
- package/dist/geometryPlayerEdits.js +49 -0
- package/dist/geometryPrepared.js +188 -0
- package/dist/geometryPrivacyFence.js +24 -0
- package/dist/geometryProceduralPublication.js +91 -0
- package/dist/geometryProceduralWorker.js +164 -0
- package/dist/geometryPublication.js +110 -0
- package/dist/geometryRayAlgebra.js +116 -0
- package/dist/geometryReadClient.js +157 -0
- package/dist/geometryReadPorts.js +5 -0
- package/dist/geometryReadRpc.js +27 -0
- package/dist/geometryReadRpcRoutes.js +47 -0
- package/dist/geometryReliablePublication.js +82 -0
- package/dist/geometryReloadPorts.js +46 -0
- package/dist/geometryReloadSource.js +278 -0
- package/dist/geometryRenderCache.js +165 -0
- package/dist/geometryRenderLod.js +102 -0
- package/dist/geometryRollback.js +125 -0
- package/dist/geometryRollbackCoordinator.js +203 -0
- package/dist/geometryRollbackPorts.js +46 -0
- package/dist/geometryRollbackSource.js +209 -0
- package/dist/geometryRollbackStore.js +198 -0
- package/dist/geometrySchemas.js +27 -0
- package/dist/geometryServer.d.ts +2766 -0
- package/dist/geometryServer.js +62 -0
- package/dist/geometryShapeRaycast.js +111 -0
- package/dist/geometryShapeSegments.js +34 -0
- package/dist/geometryShapes.js +223 -0
- package/dist/geometrySnapshot.js +76 -0
- package/dist/geometrySnapshotChannel.js +160 -0
- package/dist/geometrySnapshotClient.js +159 -0
- package/dist/geometrySnapshotPreparation.js +76 -0
- package/dist/geometrySnapshotServer.js +191 -0
- package/dist/geometrySqlOwner.js +21 -0
- package/dist/geometryStorage.js +127 -0
- package/dist/geometryStorageGrant.js +69 -0
- package/dist/geometryStorageIdentity.js +9 -0
- package/dist/geometryTileArtifact.js +10 -0
- package/dist/geometryTileCodec.js +194 -0
- package/dist/geometryTileCollision.js +96 -0
- package/dist/geometryTileNavigation.js +128 -0
- package/dist/geometryTileView.js +35 -0
- package/dist/geometryVersionActivation.js +114 -0
- package/dist/geometryVersionClient.js +238 -0
- package/dist/geometryVersionCompare.js +40 -0
- package/dist/geometryVersionMigration.js +106 -0
- package/dist/geometryVoxel.js +253 -0
- package/dist/geometryWorldEntitySubject.js +32 -0
- package/dist/geometryWorldExtent.js +12 -0
- package/dist/geometryWorldMetadata.js +38 -0
- package/dist/geometryWorldStrategyFixtures.js +127 -0
- package/dist/geometryWorldView.js +307 -0
- package/dist/host.js +128 -0
- package/dist/hostBinding.js +277 -0
- package/dist/hostCellObservation.js +114 -0
- package/dist/hostClientCapacity.js +90 -0
- package/dist/hostCommandScope.js +64 -0
- package/dist/hostController.js +3094 -0
- package/dist/hostDeployment.js +65 -0
- package/dist/hostDrain.js +152 -0
- package/dist/hostDrainPorts.js +5 -0
- package/dist/hostDriver.js +179 -0
- package/dist/hostLane.js +288 -0
- package/dist/hostListener.js +79 -0
- package/dist/hostListenerBinding.js +19 -0
- package/dist/hostLoopObservation.js +90 -0
- package/dist/hostMetrics.js +56 -0
- package/dist/hostRegistryBinding.js +418 -0
- package/dist/hostSelection.js +16 -0
- package/dist/hostShutdown.js +47 -0
- package/dist/hostTurnObservation.js +53 -0
- package/dist/identities.js +4 -0
- package/dist/index.d.ts +8632 -0
- package/dist/index.js +232 -0
- package/dist/inputReceipts.js +63 -0
- package/dist/inputRedundancy.js +55 -0
- package/dist/inspect.js +238 -0
- package/dist/lockstep.d.ts +436 -0
- package/dist/lockstep.js +382 -0
- package/dist/lockstepAdmission.js +262 -0
- package/dist/lockstepAdmissionCodec.js +94 -0
- package/dist/lockstepAdmissionPorts.js +5 -0
- package/dist/lockstepClientSession.js +578 -0
- package/dist/lockstepDefinition.js +148 -0
- package/dist/lockstepHostLoop.js +243 -0
- package/dist/lockstepInitialAdmission.js +67 -0
- package/dist/lockstepInitialStrategyFixtures.js +45 -0
- package/dist/lockstepJournal.js +395 -0
- package/dist/lockstepJournalCodec.js +254 -0
- package/dist/lockstepJournalPorts.js +5 -0
- package/dist/lockstepJournalRebuild.js +208 -0
- package/dist/lockstepJournalRows.js +57 -0
- package/dist/lockstepMembers.js +131 -0
- package/dist/lockstepMessages.js +47 -0
- package/dist/lockstepOwnedRoom.js +764 -0
- package/dist/lockstepPolicies.js +84 -0
- package/dist/lockstepReact.js +47 -0
- package/dist/lockstepRecoveryTruth.js +121 -0
- package/dist/lockstepRosterConfig.js +32 -0
- package/dist/lockstepSeed.js +12 -0
- package/dist/lockstepSeedFixture.js +20 -0
- package/dist/lockstepServer.d.ts +3897 -0
- package/dist/lockstepServer.js +325 -0
- package/dist/lockstepServerConfig.js +101 -0
- package/dist/lockstepServerRoles.js +403 -0
- package/dist/lockstepServerStrategyFixtures.js +33 -0
- package/dist/lockstepStrategies.js +6 -0
- package/dist/lockstepStrategyFixtures.js +137 -0
- package/dist/lockstepTerminal.js +90 -0
- package/dist/lockstepTerminalPorts.js +5 -0
- package/dist/lockstepTransport.js +773 -0
- package/dist/lockstepTransportConfig.js +32 -0
- package/dist/lockstepWireRoster.js +34 -0
- package/dist/matchRoomProvider.js +32 -0
- package/dist/matchRooms.js +19 -0
- package/dist/membershipObserver.js +47 -0
- package/dist/moderation.js +98 -0
- package/dist/movementSpecials.js +104 -0
- package/dist/ownership.js +17 -0
- package/dist/ownershipWithdrawal.js +18 -0
- package/dist/pcg32.js +96 -0
- package/dist/ports.d.ts +1241 -0
- package/dist/ports.js +11 -0
- package/dist/quaternion.js +70 -0
- package/dist/react.d.ts +406 -0
- package/dist/react.js +109 -0
- package/dist/reaper-app/rooms.reaper.workflow.server.tsx +5 -0
- package/dist/reaper-app/rooms.reaper.workflow.tsx +13 -0
- package/dist/reaper.js +243 -0
- package/dist/reaperSchemas.js +42 -0
- package/dist/reaperWorkflow.js +70 -0
- package/dist/recovery.js +189 -0
- package/dist/recoverySeats.js +26 -0
- package/dist/replay.d.ts +273 -0
- package/dist/replay.js +485 -0
- package/dist/replayPorts.js +5 -0
- package/dist/replayRecording.js +67 -0
- package/dist/replaySchema.js +157 -0
- package/dist/replayStorage.d.ts +149 -0
- package/dist/replayStorage.js +485 -0
- package/dist/reservationBatch.js +422 -0
- package/dist/reservationSchemas.js +17 -0
- package/dist/reservations.js +259 -0
- package/dist/reservePort.js +69 -0
- package/dist/resolvedOptions.js +4 -0
- package/dist/room.d.ts +1006 -0
- package/dist/room.js +284 -0
- package/dist/roomAccessSweep.js +95 -0
- package/dist/roomAppCommandControl.js +59 -0
- package/dist/roomAuthoringStrategy.js +17 -0
- package/dist/roomErasure.js +198 -0
- package/dist/roomPoolRuntimeDefaults.js +24 -0
- package/dist/roomPoolSelection.js +19 -0
- package/dist/roomPoolTopology.js +212 -0
- package/dist/rpc.d.ts +551 -0
- package/dist/rpc.js +112 -0
- package/dist/rpcClient.js +152 -0
- package/dist/rpcRoutes.js +28 -0
- package/dist/runtime.js +1123 -0
- package/dist/schemaHistory.js +98 -0
- package/dist/seatStore.js +151 -0
- package/dist/seatStrategyFixtures.js +52 -0
- package/dist/seatSubject.js +32 -0
- package/dist/seats.js +130 -0
- package/dist/serverSession.js +811 -0
- package/dist/serverSessionConfig.js +43 -0
- package/dist/sessionAdmission.js +53 -0
- package/dist/sidecarAdmission.js +103 -0
- package/dist/sidecarConfig.js +116 -0
- package/dist/sidecarConfigPublication.js +64 -0
- package/dist/sidecarHostListener.js +208 -0
- package/dist/sidecarIpc.js +205 -0
- package/dist/sidecarPeer.js +310 -0
- package/dist/sidecarProcessPort.js +28 -0
- package/dist/sidecarRuntime.js +168 -0
- package/dist/sidecarSelection.js +142 -0
- package/dist/sidecarWire.js +178 -0
- package/dist/sidecarWrites.js +163 -0
- package/dist/simulation.d.ts +391 -0
- package/dist/simulation.js +282 -0
- package/dist/simulationAuthoring.js +29 -0
- package/dist/simulationBytes.js +27 -0
- package/dist/simulationConformance.js +305 -0
- package/dist/simulationInputHistoryCapture.js +35 -0
- package/dist/simulationInputHistoryWire.js +193 -0
- package/dist/simulationOptionsWire.js +78 -0
- package/dist/simulationRecoveryWire.js +134 -0
- package/dist/simulationReplay.js +127 -0
- package/dist/simulationSnapshotWire.js +112 -0
- package/dist/simulationState.js +178 -0
- package/dist/snapshotBlob.js +126 -0
- package/dist/snapshotBlobCleanup.js +93 -0
- package/dist/snapshotBlobIndex.js +38 -0
- package/dist/snapshotBudget.js +80 -0
- package/dist/snapshotChain.js +185 -0
- package/dist/snapshotErasure.js +172 -0
- package/dist/snapshotInspection.js +105 -0
- package/dist/snapshotSegmentBlobs.js +58 -0
- package/dist/snapshotUploads.js +166 -0
- package/dist/socketTransport.js +253 -0
- package/dist/spatial.js +104 -0
- package/dist/spectatorPolicy.js +26 -0
- package/dist/spectatorProducer.js +89 -0
- package/dist/startFailureCause.js +4 -0
- package/dist/stateCodec.js +658 -0
- package/dist/strategies.d.ts +210 -0
- package/dist/strategies.js +8 -0
- package/dist/strategiesServer.d.ts +286 -0
- package/dist/strategiesServer.js +11 -0
- package/dist/strategyFixtures.js +182 -0
- package/dist/streamFraming.js +122 -0
- package/dist/streamTransport.js +266 -0
- package/dist/subjectAdmission.js +50 -0
- package/dist/subjectPrivacy.js +281 -0
- package/dist/subjectPrivacyBinding.js +90 -0
- package/dist/systemManifest.js +182 -0
- package/dist/tables.js +159 -0
- package/dist/testHarness.js +89 -0
- package/dist/testing.d.ts +3684 -0
- package/dist/testing.js +221 -0
- package/dist/testingPorts.js +271 -0
- package/dist/testingServer.d.ts +4060 -0
- package/dist/testingServer.js +18 -0
- package/dist/transform.d.ts +692 -0
- package/dist/transform.js +217 -0
- package/dist/transform3d.js +118 -0
- package/dist/transformCollection.js +24 -0
- package/dist/transformCollection3d.js +24 -0
- package/dist/transformCollectionCore.js +156 -0
- package/dist/transformFrames.js +121 -0
- package/dist/transformPrediction3d.js +127 -0
- package/dist/transformRules.js +123 -0
- package/dist/transformSchemas.js +20 -0
- package/dist/transport.js +32 -0
- package/dist/transportAuthoring.js +29 -0
- package/dist/transportCleanup.js +22 -0
- package/dist/transportConformance.js +124 -0
- package/dist/transportConnector.js +82 -0
- package/dist/transportEndpoints.js +38 -0
- package/dist/transportsServer.d.ts +5515 -0
- package/dist/transportsServer.js +6 -0
- package/dist/viewProjection.js +16 -0
- package/dist/web.d.ts +2286 -0
- package/dist/web.js +518 -0
- package/dist/webTransportClient.js +173 -0
- package/dist/wire.d.ts +992 -0
- package/dist/wire.js +492 -0
- package/dist/withdrawalPort.js +28 -0
- package/dist/world.d.ts +1894 -0
- package/dist/world.js +333 -0
- package/dist/worldActorReceipts.js +48 -0
- package/dist/worldActorTransferSnapshot.js +14 -0
- package/dist/worldAdmissionPending.js +8 -0
- package/dist/worldBoundaryCoordinator.js +148 -0
- package/dist/worldCatalog.js +81 -0
- package/dist/worldCellAllocation.js +203 -0
- package/dist/worldCellDestination.js +68 -0
- package/dist/worldCells.js +489 -0
- package/dist/worldChange.js +32 -0
- package/dist/worldClient.js +664 -0
- package/dist/worldClientControl.js +141 -0
- package/dist/worldClientPendingInput.js +16 -0
- package/dist/worldClientRpc.js +133 -0
- package/dist/worldClientRpcRoutes.js +43 -0
- package/dist/worldClientSchemas.js +28 -0
- package/dist/worldCommands.js +140 -0
- package/dist/worldData.js +42 -0
- package/dist/worldDefaultBinding.js +377 -0
- package/dist/worldDefaultGroupAdmission.js +82 -0
- package/dist/worldDefaultGroupAppServices.js +31 -0
- package/dist/worldDefaultGroupCompensation.js +109 -0
- package/dist/worldDefaultGroupContinuation.js +96 -0
- package/dist/worldDefaultGroupControl.js +72 -0
- package/dist/worldDefaultGroupMembers.js +85 -0
- package/dist/worldDefaultGroups.js +21 -0
- package/dist/worldDefaultPending.js +79 -0
- package/dist/worldDefaultService.js +245 -0
- package/dist/worldEntities.js +2980 -0
- package/dist/worldEntityCodec.js +21 -0
- package/dist/worldEntityHandoffView.js +154 -0
- package/dist/worldGeometry.js +170 -0
- package/dist/worldGhostAdmission.js +65 -0
- package/dist/worldGhostDestination.js +118 -0
- package/dist/worldGhostGateway.js +132 -0
- package/dist/worldGhostHandshake.js +108 -0
- package/dist/worldGhostHost.js +42 -0
- package/dist/worldGhostIngress.js +132 -0
- package/dist/worldGhostNeighborhood.js +70 -0
- package/dist/worldGhostNeighbors.js +86 -0
- package/dist/worldGhostOutbound.js +110 -0
- package/dist/worldGhostPublisher.js +216 -0
- package/dist/worldGhostReceiver.js +213 -0
- package/dist/worldGhostSender.js +146 -0
- package/dist/worldGhostSocket.js +78 -0
- package/dist/worldGhostWire.js +172 -0
- package/dist/worldGroupCommand.js +49 -0
- package/dist/worldGroupDeadline.js +115 -0
- package/dist/worldGroupPreparation.js +115 -0
- package/dist/worldGroupReadyControl.js +128 -0
- package/dist/worldGroupSupervisor.js +120 -0
- package/dist/worldHandoffMetrics.js +59 -0
- package/dist/worldHandoffView.js +100 -0
- package/dist/worldHostSource.js +69 -0
- package/dist/worldInspectEndpoint.js +250 -0
- package/dist/worldInspection.js +109 -0
- package/dist/worldInstanceAdmission.js +31 -0
- package/dist/worldInstanceAllocation.js +116 -0
- package/dist/worldInstanceDestination.js +64 -0
- package/dist/worldInstanceExpiry.js +282 -0
- package/dist/worldInstanceExpirySupervisor.js +88 -0
- package/dist/worldInstanceLifecycle.js +103 -0
- package/dist/worldInstanceState.js +52 -0
- package/dist/worldInstances.js +478 -0
- package/dist/worldJoin.js +56 -0
- package/dist/worldLayers.js +151 -0
- package/dist/worldLeases.js +78 -0
- package/dist/worldManifest.js +25 -0
- package/dist/worldMovement.js +63 -0
- package/dist/worldPersistence.js +134 -0
- package/dist/worldProjection.js +221 -0
- package/dist/worldReact.js +110 -0
- package/dist/worldRecoveryActor.js +35 -0
- package/dist/worldReturnAnchor.js +49 -0
- package/dist/worldRoomHooks.js +57 -0
- package/dist/worldRoomPool.js +27 -0
- package/dist/worldRoomSteps.js +133 -0
- package/dist/worldSeatBinding.js +36 -0
- package/dist/worldServer.d.ts +6936 -0
- package/dist/worldServer.js +48 -0
- package/dist/worldSourceSeatPending.js +9 -0
- package/dist/worldStrategyFixtures.js +164 -0
- package/dist/worldTesting.js +27 -0
- package/dist/worldTransitionDefaults.js +198 -0
- package/dist/worldTransitionExecutor.js +519 -0
- package/dist/worldTransitionGroup.js +113 -0
- package/dist/worldTransitionPhysicalSteps.js +40 -0
- package/dist/worldTransitionResolver.js +228 -0
- package/dist/worldTransitionSeatGroup.js +64 -0
- package/dist/worldTransitionSeats.js +260 -0
- package/dist/worldTransitionState.js +95 -0
- package/dist/worldTransitions.js +101 -0
- package/package.json +189 -4
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
import { BudgetExceeded as e, ProtocolError as t, RoomAuthoringError as n, RoomForbidden as r } from "./errors.js";
|
|
2
|
+
import { decodeRoomFrame as i, encodeRoomFrame as a } from "./wire.js";
|
|
3
|
+
import { roomCodecs as o } from "./web.js";
|
|
4
|
+
import { captureRoomConsumedSeat as s } from "./inputReceipts.js";
|
|
5
|
+
import { WorldSourceSeatPending as c } from "./worldSourceSeatPending.js";
|
|
6
|
+
import { WorldAdmissionPending as l } from "./worldAdmissionPending.js";
|
|
7
|
+
import { RoomLockstepMemberOwner as u, isRoomLockstepMemberOwner as d } from "./lockstepMembers.js";
|
|
8
|
+
import { RoomBaselineRing as f } from "./baselines.js";
|
|
9
|
+
import { captureRoomServerSessionLimits as p } from "./serverSessionConfig.js";
|
|
10
|
+
import { resolveRoomSeatTokenStrategies as m, roomSeatTokenDigest as h, verifyRoomSeat as g } from "./seats.js";
|
|
11
|
+
import { projectRoomView as _ } from "./viewProjection.js";
|
|
12
|
+
import { definedOnly as v } from "./resolvedOptions.js";
|
|
13
|
+
import { SpectatorDelayBuffer as y } from "./replay.js";
|
|
14
|
+
import { captureRoomSessionAdmissionEvidence as b } from "./sessionAdmission.js";
|
|
15
|
+
import { Effect as x, Result as S } from "effect";
|
|
16
|
+
//#region src/serverSession.ts
|
|
17
|
+
var C = 250, w = /* @__PURE__ */ new WeakSet(), T = class extends AggregateError {
|
|
18
|
+
releaseListeners;
|
|
19
|
+
constructor(e, t) {
|
|
20
|
+
super(e, "Room Session listener acquisition failed"), this.releaseListeners = t;
|
|
21
|
+
}
|
|
22
|
+
}, E = class E {
|
|
23
|
+
owner;
|
|
24
|
+
transport;
|
|
25
|
+
clock;
|
|
26
|
+
seats;
|
|
27
|
+
options;
|
|
28
|
+
codecs;
|
|
29
|
+
baselines;
|
|
30
|
+
detach = [];
|
|
31
|
+
writes = /* @__PURE__ */ new Set();
|
|
32
|
+
maxPendingWrites;
|
|
33
|
+
maxFramesPerSecond;
|
|
34
|
+
phase = "awaitingHello";
|
|
35
|
+
claims = null;
|
|
36
|
+
credentialDigest = null;
|
|
37
|
+
memberJoined = !1;
|
|
38
|
+
welcomeDelivered = !1;
|
|
39
|
+
datagramsAdmitted = !1;
|
|
40
|
+
resync = !1;
|
|
41
|
+
worldNotices = /* @__PURE__ */ new Map();
|
|
42
|
+
worldNoticeStateFence = null;
|
|
43
|
+
lastSentTick = -1;
|
|
44
|
+
lastSentAt = -1;
|
|
45
|
+
repairedTick = -1;
|
|
46
|
+
lastAckSeq = -1;
|
|
47
|
+
lastAckTick = -1;
|
|
48
|
+
sendLevel = 0;
|
|
49
|
+
sendSkip = 0;
|
|
50
|
+
sendThrottles = 0;
|
|
51
|
+
deltaDatagramsSent = 0;
|
|
52
|
+
reportedLossPermille = null;
|
|
53
|
+
staleInputsDropped = 0;
|
|
54
|
+
closeTask = null;
|
|
55
|
+
closeFailure = null;
|
|
56
|
+
localCleanupFailures = [];
|
|
57
|
+
ownershipLost = !1;
|
|
58
|
+
drainRequested = !1;
|
|
59
|
+
drainTask = null;
|
|
60
|
+
drainSettled = !1;
|
|
61
|
+
deferredClose = null;
|
|
62
|
+
authTask = null;
|
|
63
|
+
terminalError = null;
|
|
64
|
+
frameTokens;
|
|
65
|
+
byteTokens;
|
|
66
|
+
replenishedAt;
|
|
67
|
+
viewDurationMs = 0;
|
|
68
|
+
viewOverruns = 0;
|
|
69
|
+
lifecycleAbort = new AbortController();
|
|
70
|
+
helloTimeoutMs;
|
|
71
|
+
authTimeoutMs;
|
|
72
|
+
idleTimeoutMs;
|
|
73
|
+
connectedAt;
|
|
74
|
+
lastReceivedAt;
|
|
75
|
+
authenticatingAt = null;
|
|
76
|
+
authSettled = !0;
|
|
77
|
+
closeSettled = !1;
|
|
78
|
+
seatToken;
|
|
79
|
+
spectatorHistory;
|
|
80
|
+
delayedCursor;
|
|
81
|
+
delayedTask = null;
|
|
82
|
+
authorizeWorldPlayer;
|
|
83
|
+
authorizeWorldTarget;
|
|
84
|
+
revalidateSeat;
|
|
85
|
+
onClientMessage;
|
|
86
|
+
lockstepBinding = null;
|
|
87
|
+
lockstepActivated = !1;
|
|
88
|
+
constructor(e, r, i, a, s) {
|
|
89
|
+
this.owner = e, this.transport = r, this.clock = i, this.seats = a, this.options = s;
|
|
90
|
+
let c = e;
|
|
91
|
+
if (e instanceof u && !d(e)) throw new t({ detail: "Lockstep membership requires the genuine constructed owner" });
|
|
92
|
+
if (d(e) && s.epoch !== e.epoch) throw new t({ detail: "Lockstep Session epoch must match its member owner" });
|
|
93
|
+
if (d(e) && s.spectatorHistory) throw new t({ detail: "Lockstep membership cannot use state spectator history" });
|
|
94
|
+
let l = Object.getOwnPropertyDescriptor(s, "authorizeWorldPlayer");
|
|
95
|
+
if (l && (!("value" in l) || typeof l.value != "function") || !l && "authorizeWorldPlayer" in s) throw new t({ detail: "World player admission requires an own callback" });
|
|
96
|
+
this.authorizeWorldPlayer = l?.value.bind(s);
|
|
97
|
+
let h = Object.getOwnPropertyDescriptor(s, "authorizeWorldTarget");
|
|
98
|
+
if (h && (!("value" in h) || typeof h.value != "function") || !h && "authorizeWorldTarget" in s) throw new t({ detail: "World target admission requires an own callback" });
|
|
99
|
+
this.authorizeWorldTarget = h?.value.bind(s);
|
|
100
|
+
let g = Object.getOwnPropertyDescriptor(a, "revalidate");
|
|
101
|
+
if (g && (!("value" in g) || typeof g.value != "function") || !g && "revalidate" in a) throw new t({ detail: "Seat revalidation requires an own actual callback" });
|
|
102
|
+
if (this.revalidateSeat = g?.value.bind(a), this.seatToken = m(s.seatToken), s.onClientMessage !== void 0 && typeof s.onClientMessage != "function") throw new t({ detail: "Invalid client message hook" });
|
|
103
|
+
if (this.onClientMessage = s.onClientMessage?.bind(s), !Number.isSafeInteger(s.epoch) || s.epoch < 0) throw new n({
|
|
104
|
+
room: c.id,
|
|
105
|
+
detail: "Room epoch must be a nonnegative safe integer"
|
|
106
|
+
});
|
|
107
|
+
let _ = p(v({
|
|
108
|
+
maxPendingWrites: s.maxPendingWrites,
|
|
109
|
+
maxFramesPerSecond: s.maxFramesPerSecond,
|
|
110
|
+
baselineCapacity: s.baselineCapacity,
|
|
111
|
+
maxBaselineAgeMs: s.maxBaselineAgeMs,
|
|
112
|
+
helloTimeoutMs: s.helloTimeoutMs,
|
|
113
|
+
authTimeoutMs: s.authTimeoutMs,
|
|
114
|
+
idleTimeoutMs: s.idleTimeoutMs
|
|
115
|
+
}), c.id);
|
|
116
|
+
if (this.maxPendingWrites = _.maxPendingWrites, this.maxFramesPerSecond = _.maxFramesPerSecond, this.helloTimeoutMs = _.helloTimeoutMs, this.authTimeoutMs = _.authTimeoutMs, this.idleTimeoutMs = _.idleTimeoutMs, this.connectedAt = i.now(), this.lastReceivedAt = this.connectedAt, !Number.isFinite(this.connectedAt) || this.connectedAt < 0) throw new t({ detail: "Session clock must be monotonic" });
|
|
117
|
+
this.codecs = o(c.descriptor);
|
|
118
|
+
let b = s.spectatorHistory;
|
|
119
|
+
if (b !== void 0) {
|
|
120
|
+
if (b.roomId !== c.id || b.tenantId !== c.tenantId || !(b.history instanceof y) || typeof b.authorize != "function" || b.history.schemaDescription() !== this.codecs.state.schemaDescription()) throw new t({ detail: "Delayed spectator history requires the exact room, tenant, layout and group admission" });
|
|
121
|
+
this.spectatorHistory = Object.freeze({
|
|
122
|
+
delivery: b.history.delivery.bind(b.history),
|
|
123
|
+
authorize: b.authorize.bind(b),
|
|
124
|
+
delayMs: b.history.limits.delayMs
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
this.frameTokens = c.descriptor.budgets.burst, this.byteTokens = c.descriptor.budgets.bytesPerSecond, this.replenishedAt = i.now(), this.baselines = new f(_.baselineCapacity, _.maxBaselineAgeMs);
|
|
128
|
+
let x = !1, S = (e, n = !1) => {
|
|
129
|
+
if (!x) throw new t({ detail: "Native listeners cannot deliver before Session acquisition completes" });
|
|
130
|
+
this.receive(e, n);
|
|
131
|
+
};
|
|
132
|
+
try {
|
|
133
|
+
this.detach.push(r.reliable.onFrame((e) => S(e))), r.unreliable && this.detach.push(r.unreliable.onFrame((e) => S(e, !0)));
|
|
134
|
+
let e = () => {
|
|
135
|
+
this.backgroundClose("reconnecting");
|
|
136
|
+
};
|
|
137
|
+
r.signal.addEventListener("abort", e, { once: !0 }), this.detach.push(() => r.signal.removeEventListener("abort", e)), x = !0, r.signal.aborted && e();
|
|
138
|
+
} catch (e) {
|
|
139
|
+
this.phase = "closed", this.lifecycleAbort.abort();
|
|
140
|
+
let t = [e], n = /* @__PURE__ */ new Set();
|
|
141
|
+
for (let e of this.detach.splice(0)) try {
|
|
142
|
+
e();
|
|
143
|
+
} catch (r) {
|
|
144
|
+
t.push(r), n.add(e);
|
|
145
|
+
}
|
|
146
|
+
throw this.worldNotices.clear(), this.worldNoticeStateFence = null, this.baselines.release(), new T(t, () => {
|
|
147
|
+
let e = [];
|
|
148
|
+
for (let t of n) try {
|
|
149
|
+
t(), n.delete(t);
|
|
150
|
+
} catch (t) {
|
|
151
|
+
e.push(t);
|
|
152
|
+
}
|
|
153
|
+
if (e.length) throw AggregateError(e, "Room Session listener release remains incomplete");
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
w.add(this);
|
|
157
|
+
}
|
|
158
|
+
get actor() {
|
|
159
|
+
if (d(this.owner)) throw new t({ detail: "Lockstep membership owns no state actor" });
|
|
160
|
+
return this.owner;
|
|
161
|
+
}
|
|
162
|
+
get membershipMode() {
|
|
163
|
+
return d(this.owner) ? "lockstep" : "state-sync";
|
|
164
|
+
}
|
|
165
|
+
get status() {
|
|
166
|
+
return this.phase;
|
|
167
|
+
}
|
|
168
|
+
get failure() {
|
|
169
|
+
return this.terminalError;
|
|
170
|
+
}
|
|
171
|
+
teardownReady() {
|
|
172
|
+
return this.phase === "closed" && this.authSettled && this.closeSettled && this.writes.size === 0 && this.delayedTask === null;
|
|
173
|
+
}
|
|
174
|
+
admitFirstFrame(e) {
|
|
175
|
+
if (this.phase !== "awaitingHello") throw new t({ detail: "Room first frame has already been admitted" });
|
|
176
|
+
this.receive(Uint8Array.from(e));
|
|
177
|
+
}
|
|
178
|
+
maintenance() {
|
|
179
|
+
if (this.phase === "closed" || this.drainRequested) return;
|
|
180
|
+
let e = this.clock.now();
|
|
181
|
+
!Number.isFinite(e) || e < this.lastReceivedAt || e < this.connectedAt ? (this.terminalError = new t({ detail: "Session clock must be monotonic" }), this.backgroundClose("kicked")) : (this.phase === "awaitingHello" ? e - this.connectedAt >= this.helloTimeoutMs : this.phase === "authenticating" ? this.authenticatingAt !== null && e - this.authenticatingAt >= this.authTimeoutMs : e - this.lastReceivedAt >= this.idleTimeoutMs) && (this.terminalError = new t({ detail: "Room session deadline expired" }), this.backgroundClose("timeout"));
|
|
182
|
+
}
|
|
183
|
+
metrics() {
|
|
184
|
+
return {
|
|
185
|
+
viewDurationMs: this.viewDurationMs,
|
|
186
|
+
viewOverruns: this.viewOverruns,
|
|
187
|
+
pendingWrites: this.writes.size
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
snapshot() {
|
|
191
|
+
let e = this.actor.lastGoodSnapshot(), n = this.actor.descriptor.view;
|
|
192
|
+
if (!this.claims) return e;
|
|
193
|
+
let r = this.clock.now(), i = _(this.actor.descriptor.state, n, {
|
|
194
|
+
state: e.state,
|
|
195
|
+
tick: e.tick,
|
|
196
|
+
role: this.claims.role,
|
|
197
|
+
client: Object.freeze({
|
|
198
|
+
sessionId: this.claims.sessionId,
|
|
199
|
+
subjectId: this.claims.subjectId,
|
|
200
|
+
tenantId: this.claims.tenantId
|
|
201
|
+
})
|
|
202
|
+
}), a = this.clock.now() - r;
|
|
203
|
+
if (!Number.isFinite(a) || a < 0) throw new t({ detail: "Room view clock must be monotonic" });
|
|
204
|
+
return this.viewDurationMs += a, a > this.actor.descriptor.viewBudgetMs && this.viewOverruns++, {
|
|
205
|
+
tick: e.tick,
|
|
206
|
+
state: i
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async write(e) {
|
|
210
|
+
let t = a(e);
|
|
211
|
+
if (S.isFailure(t)) throw t.failure;
|
|
212
|
+
return this.writeEncoded(t.success);
|
|
213
|
+
}
|
|
214
|
+
async writeEncoded(n) {
|
|
215
|
+
if (this.phase === "closed" || this.transport.signal.aborted) throw new t({ detail: "Room transport is closed" });
|
|
216
|
+
if (this.writes.size >= this.maxPendingWrites) throw new e({
|
|
217
|
+
budget: "pendingRoomWrites",
|
|
218
|
+
limit: this.maxPendingWrites
|
|
219
|
+
});
|
|
220
|
+
let r = this.transport.reliable.send(n);
|
|
221
|
+
this.writes.add(r);
|
|
222
|
+
try {
|
|
223
|
+
await r;
|
|
224
|
+
} finally {
|
|
225
|
+
this.writes.delete(r);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
send(e) {
|
|
229
|
+
if (this.datagramsAdmitted && this.transport.unreliable && (e.kind === "Delta" || e.kind === "InputAck" || e.kind === "Pong" || e.kind === "ServerMessage" && this.codecs.channels[e.channelId]?.reliable === !1)) try {
|
|
230
|
+
let t = a(e);
|
|
231
|
+
if (S.isFailure(t)) throw t.failure;
|
|
232
|
+
if (t.success.byteLength <= this.transport.unreliable.maxDatagramBytes) {
|
|
233
|
+
this.transport.unreliable.send(t.success), e.kind === "Delta" && this.deltaDatagramsSent++;
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
} catch (e) {
|
|
237
|
+
this.terminalError = e, this.backgroundClose("kicked");
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
this.write(e).catch((e) => {
|
|
241
|
+
this.terminalError = e, this.backgroundClose("kicked");
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
backgroundClose(e) {
|
|
245
|
+
this.close(e).catch((e) => {
|
|
246
|
+
this.terminalError = e;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async authenticate(e) {
|
|
250
|
+
try {
|
|
251
|
+
if (e.protocolVersion !== 1 || e.schemaHash !== this.codecs.schemaHash || !(e.transportCaps & 1) || e.transportCaps & -4) throw new t({ detail: "Room protocol or schema manifest mismatch" });
|
|
252
|
+
this.datagramsAdmitted = !!(e.transportCaps & 2) && this.transport.unreliable !== void 0;
|
|
253
|
+
let n = g(e.token, this.options.secrets, this.options.epochNow(), {
|
|
254
|
+
roomId: this.owner.id,
|
|
255
|
+
tenantId: this.owner.tenantId,
|
|
256
|
+
epoch: this.options.epoch
|
|
257
|
+
}, this.seatToken.verify);
|
|
258
|
+
if (n.subjectId === null && this.owner.descriptor.auth !== "public") throw new r({ roomId: this.owner.id });
|
|
259
|
+
if (this.membershipMode === "lockstep" && (n.role !== "player" || n.subjectId === null || e.resumeFromTick !== void 0)) throw new t({ detail: "Lockstep membership requires a current Subject player and explicit initial admission" });
|
|
260
|
+
let a = h(e.token), o = await x.runPromise(this.seats.consume(n, a));
|
|
261
|
+
this.claims = n, this.credentialDigest = a;
|
|
262
|
+
let c = s(o);
|
|
263
|
+
if (c.worldTarget && (!this.authorizeWorldTarget || this.membershipMode !== "state-sync" || n.role !== "player")) throw new t({ detail: "World target Seat requires transition-aware player Host admission" });
|
|
264
|
+
if (this.status === "closed" || this.transport.signal.aborted) {
|
|
265
|
+
this.ownershipLost || await x.runPromise(this.seats.disconnect(n, "reconnecting", a));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
let l = n.role === "spectator" ? this.spectatorHistory : void 0, f;
|
|
269
|
+
if (l) {
|
|
270
|
+
let e = l.authorize(Object.freeze({ ...n }));
|
|
271
|
+
if (!x.isEffect(e)) throw new t({ detail: "Spectator group admission must return an Effect" });
|
|
272
|
+
if (await x.runPromise(e, { signal: this.lifecycleAbort.signal }), this.status === "closed" || this.transport.signal.aborted) return;
|
|
273
|
+
let r = l.delivery(Math.floor(this.clock.now()));
|
|
274
|
+
if (S.isFailure(r)) throw r.failure;
|
|
275
|
+
if (r.success.kind !== "full") throw new t({ detail: "Delayed spectator history is not yet available" });
|
|
276
|
+
let a = i(r.success.bytes);
|
|
277
|
+
if (S.isFailure(a)) throw a.failure;
|
|
278
|
+
if (a.success.kind !== "Full" || a.success.tick !== r.success.cursor.tick || a.success.epoch !== r.success.cursor.epoch || a.success.epoch > this.options.epoch) throw new t({ detail: "Delayed Welcome has invalid state authority" });
|
|
279
|
+
f = a.success, this.delayedCursor = r.success.cursor;
|
|
280
|
+
}
|
|
281
|
+
let p = {
|
|
282
|
+
sessionId: n.sessionId,
|
|
283
|
+
subjectId: n.subjectId,
|
|
284
|
+
tenantId: n.tenantId,
|
|
285
|
+
...n.attributes === void 0 ? {} : { attributes: n.attributes },
|
|
286
|
+
send: (e, n) => {
|
|
287
|
+
let r = this.codecs.channels.findIndex((t) => t.name === e), i = this.codecs.channels[r];
|
|
288
|
+
if (!i || i.direction === "client") throw new t({ detail: "Channel is not server-sendable" });
|
|
289
|
+
let a = i.codec.full(n);
|
|
290
|
+
if (S.isFailure(a)) throw a.failure;
|
|
291
|
+
this.send({
|
|
292
|
+
kind: "ServerMessage",
|
|
293
|
+
channelId: r,
|
|
294
|
+
payload: a.success
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
kick: (e) => {
|
|
298
|
+
this.write({
|
|
299
|
+
kind: "Kick",
|
|
300
|
+
code: 1,
|
|
301
|
+
reason: e
|
|
302
|
+
}).then(() => this.close("kicked")).catch((e) => {
|
|
303
|
+
this.terminalError = e, this.backgroundClose("kicked");
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}, m = this.revalidateSeat ? async () => {
|
|
307
|
+
let e = this.revalidateSeat(n, a);
|
|
308
|
+
if (!x.isEffect(e)) throw new t({ detail: "Seat revalidation requires actual Effect" });
|
|
309
|
+
let r = await x.runPromise(x.result(e), { signal: this.lifecycleAbort.signal });
|
|
310
|
+
if (S.isFailure(r)) throw r.failure;
|
|
311
|
+
} : void 0;
|
|
312
|
+
if (c.worldTarget) {
|
|
313
|
+
let e = c.worldTarget;
|
|
314
|
+
await this.actor.joinWorldReservedAsync(p, c, async () => {
|
|
315
|
+
m && await m();
|
|
316
|
+
let r = this.authorizeWorldTarget(n, e, a);
|
|
317
|
+
if (!x.isEffect(r)) throw new t({ detail: "World target admission requires an actual Effect" });
|
|
318
|
+
let i = await x.runPromise(r, { signal: this.lifecycleAbort.signal });
|
|
319
|
+
if (i !== "pending" && i !== "committed" && i !== "settled") throw new t({ detail: "World admission returned an invalid activation phase" });
|
|
320
|
+
return i;
|
|
321
|
+
}, this.lifecycleAbort.signal);
|
|
322
|
+
} else this.membershipMode === "state-sync" ? await this.actor.joinReservedAsync(p, c, this.lifecycleAbort.signal, async () => {
|
|
323
|
+
if (m && await m(), this.authorizeWorldPlayer && n.role === "player") {
|
|
324
|
+
let e = this.authorizeWorldPlayer(n);
|
|
325
|
+
if (!x.isEffect(e)) throw new t({ detail: "World player admission requires an actual Effect" });
|
|
326
|
+
return await x.runPromise(e, { signal: this.lifecycleAbort.signal });
|
|
327
|
+
}
|
|
328
|
+
}) : await this.owner.joinReservedAsync(p, c, this.lifecycleAbort.signal);
|
|
329
|
+
if (this.memberJoined = !0, this.status === "closed" || this.transport.signal.aborted) {
|
|
330
|
+
try {
|
|
331
|
+
await this.owner.leaveAsync(n.sessionId, "reconnecting"), this.memberJoined = !1;
|
|
332
|
+
} catch (e) {
|
|
333
|
+
throw this.localCleanupFailures.push(e), e;
|
|
334
|
+
}
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (d(this.owner) && !u.prototype.isCurrent.call(this.owner, n.sessionId, n.subjectId)) throw new t({ detail: "Lockstep member was withdrawn before Welcome publication" });
|
|
338
|
+
let _, v, y;
|
|
339
|
+
if (this.membershipMode === "lockstep") _ = 0, v = this.options.epoch, y = /* @__PURE__ */ new Uint8Array();
|
|
340
|
+
else if (f) _ = f.tick, v = f.epoch, y = f.baseline;
|
|
341
|
+
else {
|
|
342
|
+
let e = this.snapshot(), t = this.codecs.state.full(e.state);
|
|
343
|
+
if (S.isFailure(t)) throw t.failure;
|
|
344
|
+
this.baselines.record({
|
|
345
|
+
tick: e.tick,
|
|
346
|
+
epoch: this.options.epoch,
|
|
347
|
+
state: e.state
|
|
348
|
+
}), _ = e.tick, v = this.options.epoch, y = t.success;
|
|
349
|
+
}
|
|
350
|
+
this.lastSentTick = _, this.phase = "joined", await this.write({
|
|
351
|
+
kind: "Welcome",
|
|
352
|
+
sessionId: n.sessionId,
|
|
353
|
+
tick: _,
|
|
354
|
+
epoch: v,
|
|
355
|
+
serverTimeMs: this.observerNow(),
|
|
356
|
+
baseline: y,
|
|
357
|
+
transformRules: this.codecs.transformRules
|
|
358
|
+
}), this.welcomeDelivered = !0;
|
|
359
|
+
let b = this.membershipMode === "lockstep" ? -1 : this.actor.lastAppliedInputSeq(n.sessionId);
|
|
360
|
+
n.role === "player" && e.resumeFromTick !== void 0 && b >= 0 && (this.lastAckSeq = b, this.lastAckTick = _, await this.write({
|
|
361
|
+
kind: "InputAck",
|
|
362
|
+
lastAppliedSeq: b,
|
|
363
|
+
tick: _,
|
|
364
|
+
flags: 0
|
|
365
|
+
}));
|
|
366
|
+
} catch (e) {
|
|
367
|
+
this.terminalError = e, this.drainRequested || await this.close(e instanceof l || e instanceof c ? "reconnecting" : "kicked");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
receive(a, o = !1) {
|
|
371
|
+
if (!(this.phase === "closed" || this.drainRequested)) try {
|
|
372
|
+
let s = this.clock.now(), c = this.owner.descriptor.budgets;
|
|
373
|
+
if (!Number.isFinite(s) || s < this.replenishedAt) throw new t({ detail: "Room transport clock must be monotonic" });
|
|
374
|
+
let l = (s - this.replenishedAt) / 1e3;
|
|
375
|
+
if (this.frameTokens = Math.min(c.burst, this.frameTokens + l * this.maxFramesPerSecond), this.byteTokens = Math.min(c.bytesPerSecond, this.byteTokens + l * c.bytesPerSecond), this.replenishedAt = s, this.frameTokens < 1 || this.byteTokens < a.byteLength) throw new e({
|
|
376
|
+
budget: "roomIncomingFrames",
|
|
377
|
+
limit: this.maxFramesPerSecond
|
|
378
|
+
});
|
|
379
|
+
this.frameTokens--, this.byteTokens -= a.byteLength;
|
|
380
|
+
let u = i(a);
|
|
381
|
+
if (S.isFailure(u)) throw u.failure;
|
|
382
|
+
let d = u.success;
|
|
383
|
+
if (this.lastReceivedAt = s, o && (!this.datagramsAdmitted || d.kind !== "Input" && d.kind !== "Ack" && !(this.lockstepActivated && d.kind === "LsInput") && (d.kind !== "ClientMessage" || this.codecs.channels[d.channelId]?.reliable !== !1))) throw new t({ detail: "Room control and reliable message frames require the admitted reliable lane" });
|
|
384
|
+
if (this.phase === "awaitingHello") {
|
|
385
|
+
if (d.kind !== "Hello") throw new t({ detail: "Hello must be the first room frame" });
|
|
386
|
+
this.phase = "authenticating", this.authenticatingAt = s, this.authSettled = !1, this.authTask = this.authenticate(d).finally(() => {
|
|
387
|
+
this.authSettled = !0;
|
|
388
|
+
}), this.authTask.catch((e) => {
|
|
389
|
+
this.terminalError = e;
|
|
390
|
+
});
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (this.phase !== "joined" || !this.claims) throw new t({ detail: "Room admission is not complete" });
|
|
394
|
+
if (this.membershipMode === "lockstep" && !this.lockstepActivated && d.kind !== "Ping" && d.kind !== "Leave") throw new t({ detail: "Lockstep member cannot receive game frames before actual roster activation" });
|
|
395
|
+
if (this.lockstepActivated) {
|
|
396
|
+
if (!this.lockstepBinding || E.prototype.admittedIdentity.call(this) === null) throw new t({ detail: "Lockstep session ownership has been withdrawn" });
|
|
397
|
+
if (d.kind === "LsInput" || d.kind === "LsHash") {
|
|
398
|
+
if (this.lockstepBinding.receive(d) !== void 0) throw new t({ detail: "Lockstep intent delivery must be synchronous" });
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (d.kind === "Input" || d.kind === "Ack") throw new t({ detail: "State-sync input and baseline acknowledgements cannot enter an activated lockstep session" });
|
|
402
|
+
}
|
|
403
|
+
switch (d.kind) {
|
|
404
|
+
case "Input":
|
|
405
|
+
if (this.claims.role !== "player") throw new r({ roomId: this.owner.id });
|
|
406
|
+
d.ackTick !== void 0 && this.acknowledgeBaseline(d.ackTick);
|
|
407
|
+
for (let e = 0; e < d.inputs.length; e++) {
|
|
408
|
+
let n = d.inputs[e];
|
|
409
|
+
if (!n) throw new t({ detail: "Missing batched input" });
|
|
410
|
+
let r = this.codecs.input.decodeFull(n.payload);
|
|
411
|
+
if (S.isFailure(r)) throw r.failure;
|
|
412
|
+
this.staleInput(n.tickHint) ? this.staleInputsDropped++ : this.actor.input(this.claims.sessionId, d.firstSeq + e, n.tickHint, r.success, n.payload.byteLength);
|
|
413
|
+
}
|
|
414
|
+
return;
|
|
415
|
+
case "Ack":
|
|
416
|
+
this.acknowledgeBaseline(d.tick), d.lossPermille !== void 0 && this.datagramsAdmitted && (this.reportedLossPermille = d.lossPermille);
|
|
417
|
+
return;
|
|
418
|
+
case "Ping":
|
|
419
|
+
this.send({
|
|
420
|
+
kind: "Pong",
|
|
421
|
+
clientTimeMs: d.clientTimeMs,
|
|
422
|
+
serverTimeMs: this.observerNow(),
|
|
423
|
+
tick: this.lockstepBinding ? this.lockstepBinding.tick() : this.claims.role === "spectator" && this.spectatorHistory ? this.lastSentTick : this.membershipMode === "lockstep" ? 0 : this.actor.lastGoodSnapshot().tick,
|
|
424
|
+
...this.datagramsAdmitted ? { deltaDatagramsSent: this.deltaDatagramsSent } : {}
|
|
425
|
+
});
|
|
426
|
+
return;
|
|
427
|
+
case "Leave":
|
|
428
|
+
this.backgroundClose("left");
|
|
429
|
+
return;
|
|
430
|
+
case "ClientMessage": {
|
|
431
|
+
let e = this.codecs.channels[d.channelId];
|
|
432
|
+
if (!e || e.direction === "server" || !this.onClientMessage) throw new t({ detail: "Channel is not client-receivable" });
|
|
433
|
+
if (this.claims.role === "spectator" && e.name !== "spectators") throw new r({ roomId: this.owner.id });
|
|
434
|
+
let i = e.codec.decodeFull(d.payload);
|
|
435
|
+
if (S.isFailure(i)) throw i.failure;
|
|
436
|
+
if (this.membershipMode === "state-sync" && (this.actor.isWorldPending(this.claims.sessionId) || this.actor.isWorldFinalizationHeld())) return;
|
|
437
|
+
if (this.onClientMessage(e.name, i.success, this.claims) !== void 0) throw new n({
|
|
438
|
+
room: this.owner.id,
|
|
439
|
+
detail: "Client message hooks must be synchronous"
|
|
440
|
+
});
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
default: throw new t({ detail: "Client sent a server-only or duplicate admission frame" });
|
|
444
|
+
}
|
|
445
|
+
} catch (e) {
|
|
446
|
+
this.terminalError = e, this.backgroundClose("kicked");
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
acknowledgeBaseline(e) {
|
|
450
|
+
this.claims?.role === "spectator" && this.spectatorHistory ? e !== this.lastSentTick && (this.resync = !0) : this.baselines.acknowledge(e, this.clock.now()) ? (e < this.lastSentTick && (this.resync = !0), this.worldNoticeStateFence !== null && e > this.worldNoticeStateFence && (this.worldNoticeStateFence = null)) : this.resync = !0;
|
|
451
|
+
}
|
|
452
|
+
repairUnacknowledgedState(e, t) {
|
|
453
|
+
if (!this.datagramsAdmitted || !this.transport.unreliable || this.repairedTick === e.tick || this.lastSentAt < 0) return;
|
|
454
|
+
let n = this.clock.now();
|
|
455
|
+
if (n - this.lastSentAt < C) return;
|
|
456
|
+
let r = this.baselines.current(n);
|
|
457
|
+
if (r === null || r.tick >= e.tick) return;
|
|
458
|
+
let i = this.codecs.state.delta(e.state, r.state, t >= 0);
|
|
459
|
+
if (S.isFailure(i)) {
|
|
460
|
+
this.terminalError = i.failure, this.backgroundClose("kicked");
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (this.repairedTick = e.tick, i.success === null) return;
|
|
464
|
+
let a = {
|
|
465
|
+
kind: "Delta",
|
|
466
|
+
tick: e.tick,
|
|
467
|
+
baseTick: r.tick,
|
|
468
|
+
patch: i.success,
|
|
469
|
+
...t >= 0 ? { inputAck: {
|
|
470
|
+
lastAppliedSeq: t,
|
|
471
|
+
flags: 1
|
|
472
|
+
} } : {}
|
|
473
|
+
};
|
|
474
|
+
this.write(a).catch((e) => {
|
|
475
|
+
this.terminalError = e, this.backgroundClose("kicked");
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
publishState() {
|
|
479
|
+
if (this.lockstepActivated || this.membershipMode === "lockstep" || this.drainRequested || this.actor.isWorldFinalizationHeld() || this.phase !== "joined" || !this.claims) return;
|
|
480
|
+
if (this.claims.role === "spectator" && this.spectatorHistory) {
|
|
481
|
+
this.publishDelayedState();
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (this.backpressured()) return;
|
|
485
|
+
let e;
|
|
486
|
+
try {
|
|
487
|
+
e = this.snapshot();
|
|
488
|
+
} catch (e) {
|
|
489
|
+
this.terminalError = e, this.backgroundClose("kicked");
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
let t = this.actor.lastAppliedInputSeq(this.claims.sessionId), n = t > this.lastAckSeq;
|
|
493
|
+
if (e.tick === this.lastSentTick && !this.resync) {
|
|
494
|
+
n && (this.lastAckSeq = t, this.lastAckTick = e.tick, this.send({
|
|
495
|
+
kind: "InputAck",
|
|
496
|
+
lastAppliedSeq: t,
|
|
497
|
+
tick: e.tick,
|
|
498
|
+
flags: 0
|
|
499
|
+
})), this.repairUnacknowledgedState(e, t);
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
let r = this.resync || this.worldNoticeStateFence !== null ? null : this.baselines.current(this.clock.now()), i = this.lastAckTick >= 0 && (r === null || r.tick < this.lastAckTick), a = t >= 0 && (n || i || this.resync), o;
|
|
503
|
+
if (r && r.tick < e.tick) {
|
|
504
|
+
let t = this.codecs.state.delta(e.state, r.state, a);
|
|
505
|
+
if (S.isFailure(t)) {
|
|
506
|
+
this.terminalError = t.failure, this.backgroundClose("kicked");
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (t.success !== null) o = {
|
|
510
|
+
kind: "Delta",
|
|
511
|
+
tick: e.tick,
|
|
512
|
+
baseTick: r.tick,
|
|
513
|
+
patch: t.success
|
|
514
|
+
};
|
|
515
|
+
else return;
|
|
516
|
+
} else {
|
|
517
|
+
let t = this.codecs.state.full(e.state);
|
|
518
|
+
if (S.isFailure(t)) {
|
|
519
|
+
this.terminalError = t.failure, this.backgroundClose("kicked");
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
o = {
|
|
523
|
+
kind: "Full",
|
|
524
|
+
tick: e.tick,
|
|
525
|
+
epoch: this.options.epoch,
|
|
526
|
+
baseline: t.success
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
n && (this.lastAckSeq = t, this.lastAckTick = e.tick), a && (o = {
|
|
530
|
+
...o,
|
|
531
|
+
inputAck: {
|
|
532
|
+
lastAppliedSeq: t,
|
|
533
|
+
flags: +(o.kind === "Delta")
|
|
534
|
+
}
|
|
535
|
+
}), a && o.kind === "Delta" && this.send({
|
|
536
|
+
kind: "InputAck",
|
|
537
|
+
lastAppliedSeq: t,
|
|
538
|
+
tick: e.tick,
|
|
539
|
+
flags: 1
|
|
540
|
+
}), this.send(o), a && o.kind === "Full" && this.send({
|
|
541
|
+
kind: "InputAck",
|
|
542
|
+
lastAppliedSeq: t,
|
|
543
|
+
tick: e.tick,
|
|
544
|
+
flags: 0
|
|
545
|
+
}), e.tick > this.lastSentTick && this.baselines.record({
|
|
546
|
+
tick: e.tick,
|
|
547
|
+
epoch: this.options.epoch,
|
|
548
|
+
state: e.state
|
|
549
|
+
}), this.lastSentTick = e.tick, this.lastSentAt = this.clock.now(), this.resync = !1;
|
|
550
|
+
}
|
|
551
|
+
backpressured() {
|
|
552
|
+
if (this.sendSkip > 0) return this.sendSkip--, !0;
|
|
553
|
+
let { budgets: e, sendRate: t } = this.actor.descriptor, n = e.bytesPerSecond / t * 4, r = this.transport.stats().queuedBytes, i = this.reportedLossPermille ?? 0, a = i >= 100;
|
|
554
|
+
return r > n && this.sendLevel < 3 || a && this.sendLevel < 2 ? (this.sendLevel++, this.sendThrottles++) : r <= n / 2 && i < 50 && this.sendLevel > 0 && this.sendLevel--, this.sendSkip = (1 << this.sendLevel) - 1, !1;
|
|
555
|
+
}
|
|
556
|
+
staleInput(e) {
|
|
557
|
+
let { budgets: t, tickRate: n } = this.actor.descriptor, r = this.datagramsAdmitted && this.transport.unreliable ? this.baselines.acknowledgedTick() ?? -1 : this.lastSentTick;
|
|
558
|
+
return r >= 0 && e < r && (r - e) * 1e3 / n > t.inputLatencyBudgetMs;
|
|
559
|
+
}
|
|
560
|
+
staleInputs() {
|
|
561
|
+
return this.staleInputsDropped;
|
|
562
|
+
}
|
|
563
|
+
sendThrottle() {
|
|
564
|
+
return {
|
|
565
|
+
level: this.sendLevel,
|
|
566
|
+
throttles: this.sendThrottles
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
reportedLoss() {
|
|
570
|
+
return this.reportedLossPermille;
|
|
571
|
+
}
|
|
572
|
+
get id() {
|
|
573
|
+
return this.claims?.sessionId ?? null;
|
|
574
|
+
}
|
|
575
|
+
canSendLockstepMessages() {
|
|
576
|
+
return this.membershipMode === "lockstep" && this.lockstepActivated && this.lockstepBinding !== null && E.prototype.admittedIdentity.call(this) !== null;
|
|
577
|
+
}
|
|
578
|
+
async sendLockstepMessage(e) {
|
|
579
|
+
if (e.kind !== "ServerMessage" || !E.prototype.canSendLockstepMessages.call(this)) throw new t({ detail: "Lockstep messages need the same current activated native Session" });
|
|
580
|
+
let n = this.codecs.channels[e.channelId];
|
|
581
|
+
if (!n || n.direction === "client") throw new t({ detail: "Channel is not server-sendable" });
|
|
582
|
+
let r = n.codec.decodeFull(e.payload);
|
|
583
|
+
if (S.isFailure(r)) throw r.failure;
|
|
584
|
+
let i = a(e);
|
|
585
|
+
if (S.isFailure(i)) throw i.failure;
|
|
586
|
+
!n.reliable && this.datagramsAdmitted && this.transport.unreliable && i.success.byteLength <= this.transport.unreliable.maxDatagramBytes ? this.transport.unreliable.send(i.success) : n.reliable ? await E.prototype.writeReliableChannel.call(this, n.name, r.success, n.codec.schemaHash) : await this.writeEncoded(i.success);
|
|
587
|
+
}
|
|
588
|
+
async writeReliableChannel(e, n, r) {
|
|
589
|
+
let i = E.prototype.admittedIdentity.call(this), o = this.codecs.channels.find((t) => t.name === e);
|
|
590
|
+
if (!i || !o || !o.reliable || o.direction === "client" || o.codec.schemaHash !== r) throw new t({ detail: "Reliable channel delivery requires its exact current native player Session and layout" });
|
|
591
|
+
let s = o.codec.full(n);
|
|
592
|
+
if (S.isFailure(s)) throw s.failure;
|
|
593
|
+
let c = a({
|
|
594
|
+
kind: "ServerMessage",
|
|
595
|
+
channelId: this.codecs.channels.indexOf(o),
|
|
596
|
+
payload: s.success
|
|
597
|
+
});
|
|
598
|
+
if (S.isFailure(c)) throw c.failure;
|
|
599
|
+
if (await this.writeEncoded(c.success), JSON.stringify(E.prototype.admittedIdentity.call(this)) !== JSON.stringify(i)) throw new t({ detail: "Reliable native Session changed before delivery confirmation" });
|
|
600
|
+
}
|
|
601
|
+
async kick(e) {
|
|
602
|
+
if (this.phase === "closed") return this.close("kicked");
|
|
603
|
+
try {
|
|
604
|
+
await this.write({
|
|
605
|
+
kind: "Kick",
|
|
606
|
+
code: 1,
|
|
607
|
+
reason: e
|
|
608
|
+
});
|
|
609
|
+
} catch (e) {
|
|
610
|
+
this.terminalError = e;
|
|
611
|
+
}
|
|
612
|
+
await this.close("kicked");
|
|
613
|
+
}
|
|
614
|
+
admittedIdentity() {
|
|
615
|
+
return d(this.owner) && !u.prototype.isCurrent.call(this.owner, this.claims?.sessionId ?? "", this.claims?.subjectId ?? null) || this.phase !== "joined" || !this.authSettled || !this.memberJoined || !this.welcomeDelivered || this.closeTask !== null || this.ownershipLost || this.terminalError !== null || this.lifecycleAbort.signal.aborted || !this.claims || this.claims.role !== "player" || this.claims.subjectId === null || this.credentialDigest === null || this.claims.roomId !== this.owner.id || this.claims.tenantId !== this.owner.tenantId || this.claims.epoch !== this.owner.epoch ? null : b({
|
|
616
|
+
tenantId: this.claims.tenantId,
|
|
617
|
+
subjectId: this.claims.subjectId,
|
|
618
|
+
roomId: this.owner.id,
|
|
619
|
+
sessionId: this.claims.sessionId,
|
|
620
|
+
epoch: this.claims.epoch,
|
|
621
|
+
role: "player",
|
|
622
|
+
nonce: this.claims.nonce,
|
|
623
|
+
credentialDigest: this.credentialDigest
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
admittedInputSchemaHash() {
|
|
627
|
+
return E.prototype.admittedIdentity.call(this) === null ? null : this.codecs.input.schemaHash;
|
|
628
|
+
}
|
|
629
|
+
installLockstep(e) {
|
|
630
|
+
if (!this.canInstallLockstep() || this.spectatorHistory || typeof e.receive != "function" || typeof e.tick != "function") throw new t({ detail: "Lockstep binding needs the current welcomed player exactly once" });
|
|
631
|
+
return d(this.owner) && u.prototype.seal.call(this.owner), this.lockstepBinding = Object.freeze({
|
|
632
|
+
receive: e.receive,
|
|
633
|
+
tick: e.tick
|
|
634
|
+
}), this.lockstepActivated = !0, this.worldNotices.clear(), this.worldNoticeStateFence = null, this.baselines.release(), this.lockstepBinding;
|
|
635
|
+
}
|
|
636
|
+
canInstallLockstep() {
|
|
637
|
+
return !this.lockstepActivated && !this.spectatorHistory && E.prototype.admittedIdentity.call(this) !== null;
|
|
638
|
+
}
|
|
639
|
+
async writeLockstep(e, n) {
|
|
640
|
+
if (!this.lockstepBinding || this.lockstepBinding !== n || E.prototype.admittedIdentity.call(this) === null) throw new t({ detail: "Lockstep delivery requires the same live welcomed player" });
|
|
641
|
+
if (e.kind !== "LsStart" && e.kind !== "LsInputs" && e.kind !== "LsStall" && e.kind !== "LsDesync" && e.kind !== "LsJoin") throw new t({ detail: "Invalid server lockstep delivery" });
|
|
642
|
+
await this.write(e);
|
|
643
|
+
}
|
|
644
|
+
withdrawLockstep(e) {
|
|
645
|
+
this.lockstepBinding === e && (this.lockstepBinding = null);
|
|
646
|
+
}
|
|
647
|
+
observerNow() {
|
|
648
|
+
let e = Math.floor(this.clock.now());
|
|
649
|
+
if (!Number.isSafeInteger(e) || e < 0) throw new t({ detail: "Invalid observer clock" });
|
|
650
|
+
return this.claims?.role === "spectator" && this.spectatorHistory ? Math.max(0, e - this.spectatorHistory.delayMs) : e;
|
|
651
|
+
}
|
|
652
|
+
publishDelayedState() {
|
|
653
|
+
if (!this.spectatorHistory || this.delayedTask) return;
|
|
654
|
+
let e, n;
|
|
655
|
+
try {
|
|
656
|
+
let r = this.spectatorHistory.delivery(Math.floor(this.clock.now()), this.resync ? void 0 : this.delayedCursor);
|
|
657
|
+
if (S.isFailure(r)) throw r.failure;
|
|
658
|
+
if (r.success.kind === "unavailable" || r.success.kind === "unchanged") return;
|
|
659
|
+
if (n = r.success.cursor, n.epoch > this.options.epoch) throw new t({ detail: "Delayed state exceeds the admitted SQL epoch" });
|
|
660
|
+
e = r.success.kind === "full" ? [r.success.bytes] : r.success.frames.map((e) => e.bytes), this.resync = !1;
|
|
661
|
+
} catch (e) {
|
|
662
|
+
this.terminalError = e, this.backgroundClose("kicked");
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
let r = (async () => {
|
|
666
|
+
for (let n of e) {
|
|
667
|
+
let e = i(n);
|
|
668
|
+
if (S.isFailure(e)) throw e.failure;
|
|
669
|
+
if (e.success.kind !== "Full" && e.success.kind !== "Delta") throw new t({ detail: "Delayed history returned a non-state frame" });
|
|
670
|
+
this.lastSentTick = e.success.tick, await this.writeEncoded(n);
|
|
671
|
+
}
|
|
672
|
+
this.delayedCursor = n, this.lastSentTick = n.tick;
|
|
673
|
+
})();
|
|
674
|
+
this.delayedTask = r, r.then(() => {
|
|
675
|
+
this.delayedTask = null;
|
|
676
|
+
}, (e) => {
|
|
677
|
+
this.delayedTask = null, this.terminalError = e, this.backgroundClose("kicked");
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
close(e = "left") {
|
|
681
|
+
if (this.closeTask) return this.closeTask;
|
|
682
|
+
if (this.drainRequested && !this.ownershipLost && e !== "disposed") return this.deferredClose ??= Promise.withResolvers(), this.deferredClose.promise;
|
|
683
|
+
this.phase = "closed", this.lockstepBinding = null, this.lifecycleAbort.abort();
|
|
684
|
+
for (let e of this.detach.splice(0)) try {
|
|
685
|
+
e();
|
|
686
|
+
} catch (e) {
|
|
687
|
+
this.localCleanupFailures.push(e);
|
|
688
|
+
}
|
|
689
|
+
let t = this.claims;
|
|
690
|
+
return this.closeTask = (async () => {
|
|
691
|
+
let n = [];
|
|
692
|
+
if (t && this.memberJoined && (this.memberJoined = !1, !this.owner.isDisposed() && !this.owner.isFaulted() && !this.owner.isRetiring())) try {
|
|
693
|
+
await this.owner.leaveAsync(t.sessionId, e);
|
|
694
|
+
} catch (e) {
|
|
695
|
+
this.localCleanupFailures.push(e);
|
|
696
|
+
}
|
|
697
|
+
if (!this.ownershipLost && t && this.credentialDigest) try {
|
|
698
|
+
await x.runPromise(this.seats.disconnect(t, e, this.credentialDigest));
|
|
699
|
+
} catch (e) {
|
|
700
|
+
n.push(e);
|
|
701
|
+
}
|
|
702
|
+
try {
|
|
703
|
+
this.transport.close(e === "kicked" ? 1008 : 1e3, "Room session closed");
|
|
704
|
+
} catch (e) {
|
|
705
|
+
this.localCleanupFailures.push(e);
|
|
706
|
+
}
|
|
707
|
+
if (n.push(...this.localCleanupFailures), n.length) throw this.closeFailure = AggregateError(n, "Room session teardown failed"), this.closeFailure;
|
|
708
|
+
})().finally(() => {
|
|
709
|
+
this.closeSettled = !0;
|
|
710
|
+
}), this.closeTask.then(() => this.deferredClose?.resolve(), (e) => this.deferredClose?.reject(e)), this.closeTask;
|
|
711
|
+
}
|
|
712
|
+
quiesceForDrain() {
|
|
713
|
+
if (this.drainRequested = !0, this.drainTask) return this.drainTask;
|
|
714
|
+
let e = (async () => {
|
|
715
|
+
if (await this.settled(), this.terminalError !== null) throw this.terminalError;
|
|
716
|
+
this.drainSettled = !0;
|
|
717
|
+
})();
|
|
718
|
+
return this.drainTask = e, e.catch(() => {
|
|
719
|
+
this.drainTask = null;
|
|
720
|
+
}), e;
|
|
721
|
+
}
|
|
722
|
+
notifyWorldHandoff(n) {
|
|
723
|
+
if (this.phase !== "joined" || !this.claims || this.drainRequested || this.membershipMode !== "state-sync" || this.claims.role === "spectator") return;
|
|
724
|
+
if (n.sourceEpoch !== this.claims.epoch) throw new t({ detail: "World notice differs from the admitted Session epoch" });
|
|
725
|
+
let r = this.clock.now();
|
|
726
|
+
for (let [e, t] of this.worldNotices) t.expiresAt <= r && this.worldNotices.delete(e);
|
|
727
|
+
let i = this.worldNotices.get(n.transitionId);
|
|
728
|
+
if (n.phase === "departed") {
|
|
729
|
+
if (i) return;
|
|
730
|
+
let t = this.baselines.current(r)?.state, a = t && Object.getOwnPropertyDescriptor(t, "entities"), o = a && "value" in a ? a.value : void 0;
|
|
731
|
+
if (!o || typeof o != "object" || !Object.hasOwn(o, n.entityId)) return;
|
|
732
|
+
if (this.worldNotices.size >= 128) {
|
|
733
|
+
this.terminalError = new e({
|
|
734
|
+
budget: "worldHandoffNotices",
|
|
735
|
+
limit: 128
|
|
736
|
+
}), this.backgroundClose("kicked");
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
this.worldNotices.set(n.transitionId, {
|
|
740
|
+
entityId: n.entityId,
|
|
741
|
+
expiresAt: r + n.holdMs
|
|
742
|
+
});
|
|
743
|
+
} else {
|
|
744
|
+
if (!i || i.entityId !== n.entityId) return;
|
|
745
|
+
this.worldNotices.delete(n.transitionId);
|
|
746
|
+
}
|
|
747
|
+
this.worldNoticeStateFence = Math.max(this.worldNoticeStateFence ?? -1, n.tick), this.send(n);
|
|
748
|
+
}
|
|
749
|
+
async notifyMigration(e, n) {
|
|
750
|
+
if (!this.drainSettled || !Number.isSafeInteger(e) || e < 1 || e > 4294967295) throw new t({ detail: "Migration notification requires a quiesced Session and bounded grace" });
|
|
751
|
+
this.phase === "closed" || this.transport.signal.aborted || await this.write({
|
|
752
|
+
kind: "Migrate",
|
|
753
|
+
graceMs: e,
|
|
754
|
+
...n === void 0 ? {} : { address: n }
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
async settled() {
|
|
758
|
+
let e = (await Promise.allSettled([
|
|
759
|
+
...this.authTask ? [this.authTask] : [],
|
|
760
|
+
...this.closeTask ? [this.closeTask] : [],
|
|
761
|
+
...this.delayedTask ? [this.delayedTask] : [],
|
|
762
|
+
...this.writes
|
|
763
|
+
])).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
764
|
+
if (e.length) throw AggregateError(e, "Room session work did not settle successfully");
|
|
765
|
+
}
|
|
766
|
+
async closeFenced() {
|
|
767
|
+
this.ownershipLost = !0;
|
|
768
|
+
let e = this.close("reconnecting"), t = await Promise.allSettled([
|
|
769
|
+
e,
|
|
770
|
+
...this.authTask ? [this.authTask] : [],
|
|
771
|
+
...this.delayedTask ? [this.delayedTask] : [],
|
|
772
|
+
...this.writes
|
|
773
|
+
]), n = [...this.localCleanupFailures];
|
|
774
|
+
for (let e of t) e.status === "rejected" && e.reason !== this.closeFailure && n.push(e.reason);
|
|
775
|
+
if (n.length) throw AggregateError(n, "Revoked Room session cleanup failed");
|
|
776
|
+
}
|
|
777
|
+
}, D = E.prototype.admittedIdentity, O = E.prototype.admittedInputSchemaHash, k = E.prototype.canInstallLockstep, A = E.prototype.installLockstep, j = E.prototype.writeLockstep, M = E.prototype.withdrawLockstep, N = (e) => {
|
|
778
|
+
P(e);
|
|
779
|
+
let n = e, r = null;
|
|
780
|
+
return Object.freeze({
|
|
781
|
+
identity: () => D.call(n),
|
|
782
|
+
inputSchemaHash: () => O.call(n),
|
|
783
|
+
canActivate: () => k.call(n),
|
|
784
|
+
activate: (e, i) => {
|
|
785
|
+
if (r) throw new t({ detail: "Captured lockstep Session port is already activated" });
|
|
786
|
+
r = A.call(n, {
|
|
787
|
+
receive: e,
|
|
788
|
+
tick: i
|
|
789
|
+
});
|
|
790
|
+
},
|
|
791
|
+
send: (e) => r ? j.call(n, e, r) : Promise.reject(new t({ detail: "Captured lockstep Session port is not activated" })),
|
|
792
|
+
withdraw: () => {
|
|
793
|
+
r && M.call(n, r), r = null;
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}, P = (e) => {
|
|
797
|
+
if (!e || typeof e != "object" || !w.has(e)) throw new t({ detail: "Actual constructed Room server session is required" });
|
|
798
|
+
let n = e;
|
|
799
|
+
return Object.freeze({
|
|
800
|
+
identity: () => D.call(n),
|
|
801
|
+
inputSchemaHash: () => O.call(n)
|
|
802
|
+
});
|
|
803
|
+
}, F = E.prototype.writeReliableChannel, I = (e) => {
|
|
804
|
+
let t = P(e), n = e;
|
|
805
|
+
return Object.freeze({
|
|
806
|
+
identity: t.identity,
|
|
807
|
+
write: (e, t, r) => F.call(n, e, t, r)
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
//#endregion
|
|
811
|
+
export { E as RoomServerSession, T as RoomServerSessionAcquisitionFailure, P as captureRoomAdmittedSessionReader, N as captureRoomLockstepSessionPort, I as captureRoomReliableChannelWriter };
|