@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,478 @@
|
|
|
1
|
+
import { WORLD_INSTANCES_TABLE as e, WORLD_INSTANCE_HISTORY_TABLE as t, WORLD_INSTANCE_SCOPES_TABLE as n } from "./worldInstanceState.js";
|
|
2
|
+
import { ProtocolError as r } from "./errors.js";
|
|
3
|
+
import { ROOMS_TABLE as i, ROOM_CREATIONS_TABLE as a } from "./identities.js";
|
|
4
|
+
import { captureWorldCatalog as o } from "./world.js";
|
|
5
|
+
import { lockRoomReservationOwners as s } from "./hostClientCapacity.js";
|
|
6
|
+
import { assertWorldRoomPool as c } from "./worldRoomPool.js";
|
|
7
|
+
import "./worldEntities.js";
|
|
8
|
+
import { and as l, eq as u, generateId as d, neq as f } from "@voltro/database";
|
|
9
|
+
import { Effect as p } from "effect";
|
|
10
|
+
import { createHash as m } from "node:crypto";
|
|
11
|
+
//#region src/worldInstances.ts
|
|
12
|
+
function h() {
|
|
13
|
+
throw new r({ detail: "World instance requires exact group and Room authority" });
|
|
14
|
+
}
|
|
15
|
+
var g = (e, t = 191) => typeof e == "string" && e.length <= t && /^[A-Za-z0-9][A-Za-z0-9_.:-]*$/.test(e) ? e : h(), _ = (e, t = 1) => typeof e == "number" && Number.isSafeInteger(e) && e >= t && e <= 2147483647 ? e : h(), v = (e) => {
|
|
16
|
+
let t = e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : NaN;
|
|
17
|
+
return Number.isSafeInteger(t) && t >= 0 ? t : h();
|
|
18
|
+
}, y = (e, t) => {
|
|
19
|
+
(!e || Object.getPrototypeOf(e) !== Object.prototype || Reflect.ownKeys(e).length !== t.length || t.some((t) => {
|
|
20
|
+
let n = Object.getOwnPropertyDescriptor(e, t);
|
|
21
|
+
return !n?.enumerable || !("value" in n);
|
|
22
|
+
})) && h();
|
|
23
|
+
}, b = (e) => m("sha256").update(JSON.stringify([
|
|
24
|
+
"world-instance-group-v1",
|
|
25
|
+
g(e.tenantId),
|
|
26
|
+
g(e.worldId, 120),
|
|
27
|
+
g(e.instance, 120),
|
|
28
|
+
g(e.groupId)
|
|
29
|
+
])).digest("hex"), x = (e, t = 1) => m("sha256").update(JSON.stringify(_(t) === 1 ? ["world-instance-room-v1", b(e)] : [
|
|
30
|
+
"world-instance-room-v1",
|
|
31
|
+
b(e),
|
|
32
|
+
t
|
|
33
|
+
])).digest("hex"), S = async (e, t, n) => {
|
|
34
|
+
if (_(n) < 2) return h();
|
|
35
|
+
let r = await e.query({
|
|
36
|
+
table: a,
|
|
37
|
+
predicate: l(u("tenantId", t.tenantId), u("requestKey", x(t, n - 1))),
|
|
38
|
+
order: [],
|
|
39
|
+
take: 2,
|
|
40
|
+
skip: void 0,
|
|
41
|
+
projection: ["roomId"]
|
|
42
|
+
});
|
|
43
|
+
return r.length === 1 ? g(r[0].roomId) : h();
|
|
44
|
+
}, C = async (e, t, n, r) => {
|
|
45
|
+
let a = await e.query({
|
|
46
|
+
table: i,
|
|
47
|
+
predicate: l(u("tenantId", t), u("id", n)),
|
|
48
|
+
order: [],
|
|
49
|
+
take: 2,
|
|
50
|
+
skip: void 0,
|
|
51
|
+
projection: [
|
|
52
|
+
"name",
|
|
53
|
+
"state",
|
|
54
|
+
"clients"
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
if (a.length !== 1 || a[0].name !== r || a[0].state !== "disposed" || a[0].clients !== 0 || (await e.query({
|
|
58
|
+
table: "_voltro_world_entities",
|
|
59
|
+
predicate: l(u("tenantId", t), u("roomId", n)),
|
|
60
|
+
order: [],
|
|
61
|
+
take: 1,
|
|
62
|
+
skip: void 0,
|
|
63
|
+
projection: ["id"]
|
|
64
|
+
})).length) return h();
|
|
65
|
+
}, w = async (e, t, n, r) => {
|
|
66
|
+
let i = t.instances.find((e) => e.id === n.instance);
|
|
67
|
+
if (t.name !== n.worldId || !i) return h();
|
|
68
|
+
await e.transactional(async (e) => {
|
|
69
|
+
let t = await S(e, n, r);
|
|
70
|
+
await s(e, [t], n.tenantId), await C(e, n.tenantId, t, i.room);
|
|
71
|
+
});
|
|
72
|
+
}, T = (e) => Object.freeze({
|
|
73
|
+
tenantId: g(e.tenantId),
|
|
74
|
+
worldId: g(e.worldId, 120),
|
|
75
|
+
instance: g(e.instance, 120),
|
|
76
|
+
groupId: g(e.groupId)
|
|
77
|
+
}), E = (e) => l(u("tenantId", e.tenantId), u("worldId", e.worldId), u("instance", e.instance)), D = (e) => l(E(e), u("groupKey", b(e))), O = (t, n, r = !1) => t.query({
|
|
78
|
+
table: e,
|
|
79
|
+
predicate: D(n),
|
|
80
|
+
order: [],
|
|
81
|
+
take: 2,
|
|
82
|
+
skip: void 0,
|
|
83
|
+
projection: void 0,
|
|
84
|
+
...r ? { lock: "update" } : {}
|
|
85
|
+
}), k = (e) => p.uninterruptible(p.tryPromise({
|
|
86
|
+
try: e,
|
|
87
|
+
catch: (e) => e instanceof r ? e : new r({ detail: "World instance SQL operation remains incomplete" })
|
|
88
|
+
})), A = (m, w) => {
|
|
89
|
+
y(w, [
|
|
90
|
+
"worlds",
|
|
91
|
+
"epochNow",
|
|
92
|
+
"maxManagedGroups",
|
|
93
|
+
"authorize"
|
|
94
|
+
]);
|
|
95
|
+
let A = o(w.worlds), j = _(w.maxManagedGroups);
|
|
96
|
+
(j > 65536 || typeof w.epochNow != "function" || typeof w.authorize != "function") && h();
|
|
97
|
+
let M = w.epochNow.bind(w), N = w.authorize.bind(w), P = () => {
|
|
98
|
+
let e = M();
|
|
99
|
+
return Number.isSafeInteger(e) && e >= 0 ? e : h();
|
|
100
|
+
}, F = (e) => {
|
|
101
|
+
let t = A.find((t) => t.name === e.worldId), n = t?.instances.find((t) => t.id === e.instance);
|
|
102
|
+
return !t || !n || n.maxGroups > j || n.ttlMs > 2147483647 ? h() : {
|
|
103
|
+
world: t,
|
|
104
|
+
instance: n
|
|
105
|
+
};
|
|
106
|
+
}, I = (e, t) => {
|
|
107
|
+
let n = e.state, r = e.hostId, i = v(e.createdAt), a = v(e.expiresAt), o = v(e.updatedAt);
|
|
108
|
+
return e.tenantId !== t.tenantId || e.worldId !== t.worldId || e.instance !== t.instance || e.groupKey !== b(t) || ![
|
|
109
|
+
"creating",
|
|
110
|
+
"live",
|
|
111
|
+
"hibernated",
|
|
112
|
+
"retired"
|
|
113
|
+
].includes(String(n)) || a <= i || o < i || (n === "creating" || n === "live") && r === null || n === "hibernated" && r !== null || (n === "hibernated" || n === "retired") && e.players !== 0 ? h() : Object.freeze({
|
|
114
|
+
id: g(e.id),
|
|
115
|
+
tenantId: t.tenantId,
|
|
116
|
+
worldId: t.worldId,
|
|
117
|
+
instance: t.instance,
|
|
118
|
+
groupKey: b(t),
|
|
119
|
+
roomId: g(e.roomId),
|
|
120
|
+
hostId: r === null ? null : g(r),
|
|
121
|
+
generation: _(e.generation ?? 1),
|
|
122
|
+
epoch: _(e.epoch),
|
|
123
|
+
revision: _(e.revision),
|
|
124
|
+
players: _(e.players, 0),
|
|
125
|
+
state: n,
|
|
126
|
+
createdAt: i,
|
|
127
|
+
expiresAt: a,
|
|
128
|
+
updatedAt: o,
|
|
129
|
+
expired: P() >= a
|
|
130
|
+
});
|
|
131
|
+
}, L = (e, t, n) => p.suspend(() => {
|
|
132
|
+
F(t);
|
|
133
|
+
let i = N(e, t);
|
|
134
|
+
return p.isEffect(i) ? i.pipe(p.flatMap(n)) : p.fail(new r({ detail: "World instance policy must return an actual Effect" }));
|
|
135
|
+
}).pipe(p.catchCause(() => p.fail(new r({ detail: "World instance operation remains incomplete" })))), R = async (e, t) => {
|
|
136
|
+
let { instance: r } = F(t), i = await e.query({
|
|
137
|
+
table: n,
|
|
138
|
+
predicate: E(t),
|
|
139
|
+
order: [],
|
|
140
|
+
take: 2,
|
|
141
|
+
skip: void 0,
|
|
142
|
+
projection: void 0,
|
|
143
|
+
lock: "update"
|
|
144
|
+
});
|
|
145
|
+
if (i.length > 1) return h();
|
|
146
|
+
if (!i.length) await e.insert(n, {
|
|
147
|
+
id: d({
|
|
148
|
+
kind: "typeid",
|
|
149
|
+
prefix: "wiscope"
|
|
150
|
+
}, n),
|
|
151
|
+
tenantId: t.tenantId,
|
|
152
|
+
worldId: t.worldId,
|
|
153
|
+
instance: t.instance,
|
|
154
|
+
maxGroups: r.maxGroups,
|
|
155
|
+
ttlMs: r.ttlMs
|
|
156
|
+
});
|
|
157
|
+
else if (i[0].maxGroups !== r.maxGroups || i[0].ttlMs !== r.ttlMs) return h();
|
|
158
|
+
return r;
|
|
159
|
+
}, z = async (e, t, n) => {
|
|
160
|
+
let { world: r, instance: a } = F(t);
|
|
161
|
+
n && await s(e, [t.roomId], t.tenantId);
|
|
162
|
+
let o = await e.query({
|
|
163
|
+
table: i,
|
|
164
|
+
predicate: l(u("tenantId", t.tenantId), u("id", t.roomId)),
|
|
165
|
+
order: [],
|
|
166
|
+
take: 2,
|
|
167
|
+
skip: void 0,
|
|
168
|
+
projection: void 0,
|
|
169
|
+
...n ? { lock: "update" } : {}
|
|
170
|
+
}), d = o[0];
|
|
171
|
+
return o.length !== 1 || !d || d.id !== t.roomId || d.tenantId !== t.tenantId || d.name !== a.room || d.epoch !== t.epoch || d.hostId !== t.hostId || _(d.clients, 0) > _(d.maxClients) ? h() : (await c(e, r, d, n), d);
|
|
172
|
+
}, B = (n, i) => {
|
|
173
|
+
let o;
|
|
174
|
+
try {
|
|
175
|
+
y(n, [
|
|
176
|
+
"tenantId",
|
|
177
|
+
"worldId",
|
|
178
|
+
"instance",
|
|
179
|
+
"groupId",
|
|
180
|
+
"roomId",
|
|
181
|
+
"hostId",
|
|
182
|
+
"epoch",
|
|
183
|
+
...Object.hasOwn(n, "generation") ? ["generation"] : []
|
|
184
|
+
]), o = Object.freeze({
|
|
185
|
+
...T(n),
|
|
186
|
+
roomId: g(n.roomId),
|
|
187
|
+
hostId: n.hostId === null ? null : g(n.hostId),
|
|
188
|
+
epoch: _(n.epoch),
|
|
189
|
+
...n.generation === void 0 ? {} : { generation: _(n.generation) }
|
|
190
|
+
});
|
|
191
|
+
} catch {
|
|
192
|
+
return p.fail(new r({ detail: "Invalid World instance publication" }));
|
|
193
|
+
}
|
|
194
|
+
let c = o.generation ?? 1, v = i && c > 1;
|
|
195
|
+
return L(v ? "reset" : i ? "prepare" : "publish", o, () => k(() => m.transactional(async (n) => {
|
|
196
|
+
let r = await R(n, o), p = await O(n, o);
|
|
197
|
+
if (p.length > 1) return h();
|
|
198
|
+
let m = v ? await S(n, o, c) : void 0;
|
|
199
|
+
if (v) {
|
|
200
|
+
let e = await n.query({
|
|
201
|
+
table: a,
|
|
202
|
+
predicate: l(u("tenantId", o.tenantId), u("requestKey", x(o, c))),
|
|
203
|
+
order: [],
|
|
204
|
+
take: 2,
|
|
205
|
+
skip: void 0,
|
|
206
|
+
projection: ["roomId"]
|
|
207
|
+
});
|
|
208
|
+
if (e.length !== 1 || e[0].roomId !== o.roomId) return h();
|
|
209
|
+
}
|
|
210
|
+
await s(n, [
|
|
211
|
+
o.roomId,
|
|
212
|
+
...m ? [m] : [],
|
|
213
|
+
...p[0] ? [g(p[0].roomId)] : []
|
|
214
|
+
], o.tenantId);
|
|
215
|
+
let y = await z(n, o, !0), w = y.state, T = await O(n, o, !0), D = P();
|
|
216
|
+
if ((i ? w !== "creating" : w !== "live" && w !== "hibernated") || T.length > 1 || T.length !== p.length || T[0]?.id !== p[0]?.id) return h();
|
|
217
|
+
let k = T[0] ? I(T[0], o) : void 0, A = k?.state === "retired";
|
|
218
|
+
if (m && await C(n, o.tenantId, m, r.room), !k || A) {
|
|
219
|
+
if (!i || o.epoch !== 1 || y.clients !== 0 || k && (!v || c <= k.generation) || (await n.query({
|
|
220
|
+
table: "_voltro_world_instances",
|
|
221
|
+
predicate: l(E(o), f("state", "retired")),
|
|
222
|
+
order: [],
|
|
223
|
+
take: r.maxGroups + 1,
|
|
224
|
+
skip: void 0,
|
|
225
|
+
projection: ["id"]
|
|
226
|
+
})).length >= r.maxGroups || !Number.isSafeInteger(D + r.ttlMs) || k && (k.roomId === o.roomId || D < k.updatedAt || (await C(n, o.tenantId, k.roomId, r.room), await n.insert(t, {
|
|
227
|
+
...T[0],
|
|
228
|
+
generation: k.generation
|
|
229
|
+
}), await n.deleteMany("_voltro_world_instances", { where: l(u("id", k.id), u("revision", k.revision), u("state", "retired")) }) !== 1))) return h();
|
|
230
|
+
let a = {
|
|
231
|
+
id: d({
|
|
232
|
+
kind: "typeid",
|
|
233
|
+
prefix: "winst"
|
|
234
|
+
}, e),
|
|
235
|
+
tenantId: o.tenantId,
|
|
236
|
+
worldId: o.worldId,
|
|
237
|
+
instance: o.instance,
|
|
238
|
+
groupKey: b(o),
|
|
239
|
+
roomId: o.roomId,
|
|
240
|
+
generation: c,
|
|
241
|
+
hostId: o.hostId,
|
|
242
|
+
epoch: o.epoch,
|
|
243
|
+
revision: 1,
|
|
244
|
+
players: 0,
|
|
245
|
+
state: w,
|
|
246
|
+
createdAt: new Date(D),
|
|
247
|
+
expiresAt: new Date(D + r.ttlMs),
|
|
248
|
+
updatedAt: new Date(D)
|
|
249
|
+
};
|
|
250
|
+
return await n.insert(e, a), I(a, o);
|
|
251
|
+
}
|
|
252
|
+
let j = _(y.clients, 0);
|
|
253
|
+
if (k.roomId !== o.roomId || k.epoch > o.epoch || o.generation !== void 0 && k.generation !== c || i && k.epoch === o.epoch && k.state !== "creating" || k.revision === 2147483647 || D < k.updatedAt) return h();
|
|
254
|
+
if (k.hostId === o.hostId && k.epoch === o.epoch && k.state === w && k.players === j) return k;
|
|
255
|
+
if (k.epoch === o.epoch && k.hostId !== o.hostId && w !== "hibernated") return h();
|
|
256
|
+
let M = {
|
|
257
|
+
hostId: o.hostId,
|
|
258
|
+
epoch: o.epoch,
|
|
259
|
+
revision: k.revision + 1,
|
|
260
|
+
players: j,
|
|
261
|
+
state: w,
|
|
262
|
+
updatedAt: new Date(D)
|
|
263
|
+
};
|
|
264
|
+
return await n.updateMany("_voltro_world_instances", M, { where: l(u("id", k.id), u("revision", k.revision)) }) === 1 ? I({
|
|
265
|
+
...T[0],
|
|
266
|
+
...M
|
|
267
|
+
}, o) : h();
|
|
268
|
+
})));
|
|
269
|
+
};
|
|
270
|
+
return Object.freeze({
|
|
271
|
+
history: (e, n) => {
|
|
272
|
+
let i, a;
|
|
273
|
+
try {
|
|
274
|
+
y(e, [
|
|
275
|
+
"tenantId",
|
|
276
|
+
"worldId",
|
|
277
|
+
"instance",
|
|
278
|
+
"groupId"
|
|
279
|
+
]), i = T(e), a = _(n);
|
|
280
|
+
} catch {
|
|
281
|
+
return p.fail(new r({ detail: "Invalid World instance history identity" }));
|
|
282
|
+
}
|
|
283
|
+
return L("observe", i, () => k(async () => {
|
|
284
|
+
let e = await m.query({
|
|
285
|
+
table: t,
|
|
286
|
+
predicate: l(D(i), u("generation", a)),
|
|
287
|
+
order: [],
|
|
288
|
+
take: 2,
|
|
289
|
+
skip: void 0,
|
|
290
|
+
projection: void 0
|
|
291
|
+
});
|
|
292
|
+
if (e.length > 1) return h();
|
|
293
|
+
if (!e.length) return null;
|
|
294
|
+
let n = I(e[0], i);
|
|
295
|
+
return n.state !== "retired" || n.generation !== a ? h() : n;
|
|
296
|
+
}));
|
|
297
|
+
},
|
|
298
|
+
inspect: (e) => {
|
|
299
|
+
let t;
|
|
300
|
+
try {
|
|
301
|
+
y(e, [
|
|
302
|
+
"tenantId",
|
|
303
|
+
"worldId",
|
|
304
|
+
"instance",
|
|
305
|
+
"groupId"
|
|
306
|
+
]), t = T(e);
|
|
307
|
+
} catch {
|
|
308
|
+
return p.fail(new r({ detail: "Invalid World instance inspection" }));
|
|
309
|
+
}
|
|
310
|
+
return L("observe", t, () => k(() => m.transactional(async (e) => {
|
|
311
|
+
let n = await O(e, t);
|
|
312
|
+
if (n.length > 1) return h();
|
|
313
|
+
if (!n.length) return null;
|
|
314
|
+
let r = I(n[0], t), i = await s(e, [r.roomId], t.tenantId), a = await O(e, t, !0);
|
|
315
|
+
if (a.length !== 1 || a[0].id !== r.id || a[0].revision !== r.revision) return h();
|
|
316
|
+
let o = I(a[0], t);
|
|
317
|
+
if (o.state === "retired") return Object.freeze({
|
|
318
|
+
publication: o,
|
|
319
|
+
owner: null,
|
|
320
|
+
synchronized: !1
|
|
321
|
+
});
|
|
322
|
+
let l = i.get(r.roomId), { world: u, instance: d } = F(t);
|
|
323
|
+
if (l.name !== d.room || _(l.epoch) < o.epoch || ![
|
|
324
|
+
"creating",
|
|
325
|
+
"live",
|
|
326
|
+
"hibernated",
|
|
327
|
+
"orphaned"
|
|
328
|
+
].includes(String(l.state)) || _(l.clients, 0) > _(l.maxClients)) return h();
|
|
329
|
+
let f = l.hostId === null ? null : g(l.hostId), p = _(l.epoch), m = l.state;
|
|
330
|
+
if (m === "hibernated" ? f !== null || l.clients !== 0 : f === null) return h();
|
|
331
|
+
await c(e, u, l, !0);
|
|
332
|
+
let v = o.hostId === f && o.epoch === p && o.state === m && o.players === l.clients;
|
|
333
|
+
return Object.freeze({
|
|
334
|
+
publication: o,
|
|
335
|
+
owner: Object.freeze({
|
|
336
|
+
hostId: f,
|
|
337
|
+
epoch: p,
|
|
338
|
+
state: m
|
|
339
|
+
}),
|
|
340
|
+
synchronized: v
|
|
341
|
+
});
|
|
342
|
+
})));
|
|
343
|
+
},
|
|
344
|
+
reset: (e) => {
|
|
345
|
+
let t = e && Object.getOwnPropertyDescriptor(e, "generation");
|
|
346
|
+
return !t || !("value" in t) || !Number.isSafeInteger(t.value) || t.value < 2 ? p.fail(new r({ detail: "Explicit instance reset requires a newer bounded generation" })) : B(e, !0);
|
|
347
|
+
},
|
|
348
|
+
prepare: (e) => B(e, !0),
|
|
349
|
+
publish: (e) => B(e, !1),
|
|
350
|
+
observe: (e) => {
|
|
351
|
+
let t;
|
|
352
|
+
try {
|
|
353
|
+
y(e, [
|
|
354
|
+
"tenantId",
|
|
355
|
+
"worldId",
|
|
356
|
+
"instance",
|
|
357
|
+
"groupId"
|
|
358
|
+
]), t = T(e);
|
|
359
|
+
} catch {
|
|
360
|
+
return p.fail(new r({ detail: "Invalid World instance observation" }));
|
|
361
|
+
}
|
|
362
|
+
return L("observe", t, () => k(() => m.transactional(async (e) => {
|
|
363
|
+
let n = await O(e, t);
|
|
364
|
+
if (n.length > 1) return h();
|
|
365
|
+
if (!n.length) return null;
|
|
366
|
+
let r = I(n[0], t);
|
|
367
|
+
if (r.state !== "retired") {
|
|
368
|
+
let n = await z(e, {
|
|
369
|
+
...t,
|
|
370
|
+
roomId: r.roomId,
|
|
371
|
+
hostId: r.hostId,
|
|
372
|
+
epoch: r.epoch
|
|
373
|
+
}, !1);
|
|
374
|
+
if (n.state !== r.state || n.clients !== r.players) return h();
|
|
375
|
+
}
|
|
376
|
+
return r;
|
|
377
|
+
})));
|
|
378
|
+
},
|
|
379
|
+
retire: (e) => {
|
|
380
|
+
let t;
|
|
381
|
+
try {
|
|
382
|
+
y(e, [
|
|
383
|
+
"tenantId",
|
|
384
|
+
"worldId",
|
|
385
|
+
"instance",
|
|
386
|
+
"groupId"
|
|
387
|
+
]), t = T(e);
|
|
388
|
+
} catch {
|
|
389
|
+
return p.fail(new r({ detail: "Invalid World instance retirement" }));
|
|
390
|
+
}
|
|
391
|
+
return L("retire", t, () => k(() => m.transactional(async (e) => {
|
|
392
|
+
await R(e, t);
|
|
393
|
+
let n = await O(e, t);
|
|
394
|
+
if (n.length !== 1) return h();
|
|
395
|
+
let r = I(n[0], t);
|
|
396
|
+
if (r.state === "retired") return r;
|
|
397
|
+
await s(e, [r.roomId], t.tenantId);
|
|
398
|
+
let a = await e.query({
|
|
399
|
+
table: i,
|
|
400
|
+
predicate: l(u("id", r.roomId), u("tenantId", t.tenantId)),
|
|
401
|
+
order: [],
|
|
402
|
+
take: 2,
|
|
403
|
+
skip: void 0,
|
|
404
|
+
projection: [
|
|
405
|
+
"id",
|
|
406
|
+
"tenantId",
|
|
407
|
+
"state",
|
|
408
|
+
"clients",
|
|
409
|
+
"epoch"
|
|
410
|
+
],
|
|
411
|
+
lock: "update"
|
|
412
|
+
});
|
|
413
|
+
if (a.length !== 1 || a[0].state !== "disposed" || a[0].clients !== 0 || _(a[0].epoch) < r.epoch) return h();
|
|
414
|
+
let o = await O(e, t, !0);
|
|
415
|
+
if (o.length !== 1 || o[0].id !== r.id || o[0].revision !== r.revision || (await e.query({
|
|
416
|
+
table: "_voltro_world_entities",
|
|
417
|
+
predicate: l(u("tenantId", t.tenantId), u("roomId", r.roomId)),
|
|
418
|
+
order: [],
|
|
419
|
+
take: 1,
|
|
420
|
+
skip: void 0,
|
|
421
|
+
projection: ["id"]
|
|
422
|
+
})).length) return h();
|
|
423
|
+
let c = P();
|
|
424
|
+
if (c < r.updatedAt || r.revision === 2147483647) return h();
|
|
425
|
+
let d = {
|
|
426
|
+
state: "retired",
|
|
427
|
+
players: 0,
|
|
428
|
+
revision: r.revision + 1,
|
|
429
|
+
updatedAt: new Date(c)
|
|
430
|
+
};
|
|
431
|
+
return await e.updateMany("_voltro_world_instances", d, { where: l(u("id", r.id), u("revision", r.revision)) }) === 1 ? I({
|
|
432
|
+
...n[0],
|
|
433
|
+
...d
|
|
434
|
+
}, t) : h();
|
|
435
|
+
})));
|
|
436
|
+
},
|
|
437
|
+
withAdmission: (e, t) => {
|
|
438
|
+
let n;
|
|
439
|
+
try {
|
|
440
|
+
y(e, [
|
|
441
|
+
"tenantId",
|
|
442
|
+
"worldId",
|
|
443
|
+
"instance",
|
|
444
|
+
"groupId"
|
|
445
|
+
]), n = T(e), typeof t != "function" && h();
|
|
446
|
+
} catch {
|
|
447
|
+
return p.fail(new r({ detail: "Invalid World instance admission scope" }));
|
|
448
|
+
}
|
|
449
|
+
return L("admit", n, () => k(() => m.transactional(async (e) => {
|
|
450
|
+
let r = await O(e, n);
|
|
451
|
+
if (r.length !== 1) return h();
|
|
452
|
+
let i = I(r[0], n);
|
|
453
|
+
if (i.state !== "live" || i.expired || i.hostId === null) return h();
|
|
454
|
+
let a = {
|
|
455
|
+
...n,
|
|
456
|
+
roomId: i.roomId,
|
|
457
|
+
hostId: i.hostId,
|
|
458
|
+
epoch: i.epoch
|
|
459
|
+
}, o = await z(e, a, !0), s = await O(e, n, !0);
|
|
460
|
+
if (s.length !== 1 || s[0].id !== i.id || s[0].revision !== i.revision || o.state !== "live" || o.clients !== i.players || P() >= i.expiresAt) return h();
|
|
461
|
+
let c = t(e, i);
|
|
462
|
+
if (!(c instanceof Promise)) return h();
|
|
463
|
+
let d = await c, f = await z(e, a, !0), p = await O(e, n, !0), m = P();
|
|
464
|
+
if (p.length !== 1 || m >= i.expiresAt || m < i.updatedAt || f.state !== "live") return h();
|
|
465
|
+
let g = I(p[0], n);
|
|
466
|
+
if (g.id !== i.id || g.revision !== i.revision || g.updatedAt !== i.updatedAt || g.roomId !== i.roomId || g.hostId !== i.hostId || g.epoch !== i.epoch || g.state !== i.state || g.expiresAt !== i.expiresAt || g.createdAt !== i.createdAt || g.players !== i.players) return h();
|
|
467
|
+
let v = _(f.clients, 0);
|
|
468
|
+
return v !== i.players && (i.revision === 2147483647 || await e.updateMany("_voltro_world_instances", {
|
|
469
|
+
players: v,
|
|
470
|
+
revision: i.revision + 1,
|
|
471
|
+
updatedAt: new Date(m)
|
|
472
|
+
}, { where: l(u("id", i.id), u("revision", i.revision)) }) !== 1) ? h() : d;
|
|
473
|
+
})));
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
//#endregion
|
|
478
|
+
export { w as assertWorldInstanceRecreation, A as dataStoreWorldInstances, x as worldInstanceCreationKey, b as worldInstanceGroupKey };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ProtocolError as e } from "./errors.js";
|
|
2
|
+
import { captureWorldCatalog as t, worldSpawn as n } from "./world.js";
|
|
3
|
+
import { Effect as r } from "effect";
|
|
4
|
+
//#region src/worldJoin.ts
|
|
5
|
+
var i = (t) => new e({ detail: t }), a = (a) => {
|
|
6
|
+
let { tenantId: o, entities: s, allocateCell: c, reserve: l } = a, u = t(a.worlds), d = (t, n) => t.pipe(r.mapError((t) => t instanceof e ? t : i(n)));
|
|
7
|
+
return Object.freeze({ join: (e, t) => r.gen(function* () {
|
|
8
|
+
if (t.type !== "user" || t.tenantId !== o || !t.id) return yield* r.fail(i("Only a signed-in player joins a World"));
|
|
9
|
+
let a = u.find((t) => t.name === e);
|
|
10
|
+
if (!a) return yield* r.fail(i("World is not declared"));
|
|
11
|
+
let f = t.id, p = t.kind === "guest" ? "guest" : "user", m = yield* d(s.observe({
|
|
12
|
+
tenantId: o,
|
|
13
|
+
entityId: f
|
|
14
|
+
}), "World entity is unavailable");
|
|
15
|
+
if (m && (m.subject?.id !== t.id || m.subject.kind !== p)) return yield* r.fail(i("World entity belongs to another player"));
|
|
16
|
+
if (!m) {
|
|
17
|
+
let e = n(a, {
|
|
18
|
+
id: t.id,
|
|
19
|
+
kind: p
|
|
20
|
+
}), l = yield* c({
|
|
21
|
+
worldId: a.name,
|
|
22
|
+
zoneId: e.zone,
|
|
23
|
+
at: e.at,
|
|
24
|
+
layer: 1
|
|
25
|
+
}, t);
|
|
26
|
+
if (yield* s.create({
|
|
27
|
+
tenantId: o,
|
|
28
|
+
entityId: f,
|
|
29
|
+
subject: {
|
|
30
|
+
id: t.id,
|
|
31
|
+
kind: p
|
|
32
|
+
},
|
|
33
|
+
kind: "player",
|
|
34
|
+
data: {},
|
|
35
|
+
location: {
|
|
36
|
+
worldId: a.name,
|
|
37
|
+
zoneId: e.zone,
|
|
38
|
+
at: e.at,
|
|
39
|
+
layer: 1,
|
|
40
|
+
roomId: l.roomId,
|
|
41
|
+
epoch: l.epoch
|
|
42
|
+
}
|
|
43
|
+
}).pipe(r.ignore), m = yield* d(s.observe({
|
|
44
|
+
tenantId: o,
|
|
45
|
+
entityId: f
|
|
46
|
+
}), "World entity is unavailable"), !m || m.subject?.id !== t.id || m.subject.kind !== p) return yield* r.fail(i("World entity could not be created"));
|
|
47
|
+
}
|
|
48
|
+
let h = yield* d(l(m.roomId, t), "World Room Seat is unavailable");
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
entityId: f,
|
|
51
|
+
reservation: h
|
|
52
|
+
});
|
|
53
|
+
}) });
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { a as makeWorldJoin };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { RoomAuthoringError as e } from "./errors.js";
|
|
2
|
+
//#region src/worldLayers.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
throw new e({
|
|
5
|
+
room: "world",
|
|
6
|
+
detail: t
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
var n = (e, n = !1) => {
|
|
10
|
+
(!Number.isSafeInteger(e) || e < +!n) && t("Invalid World layer count");
|
|
11
|
+
}, r = (e, n) => {
|
|
12
|
+
(typeof e != "object" || !e || Object.getPrototypeOf(e) !== Object.prototype) && t("World layers require plain own data");
|
|
13
|
+
for (let r of Reflect.ownKeys(e)) {
|
|
14
|
+
let i = Object.getOwnPropertyDescriptor(e, r);
|
|
15
|
+
(typeof r != "string" || !n.includes(r) || !i?.enumerable || !("value" in i)) && t("Invalid World layer field");
|
|
16
|
+
}
|
|
17
|
+
}, i = (e) => {
|
|
18
|
+
r(e, [
|
|
19
|
+
"policy",
|
|
20
|
+
"layers",
|
|
21
|
+
"groupSize",
|
|
22
|
+
"affinity",
|
|
23
|
+
"maxLayers"
|
|
24
|
+
]), r(e.policy, [
|
|
25
|
+
"maxPlayers",
|
|
26
|
+
"splitAt",
|
|
27
|
+
"mergeBelow"
|
|
28
|
+
]), n(e.policy.maxPlayers), n(e.policy.splitAt), n(e.policy.mergeBelow, !0), n(e.groupSize), n(e.maxLayers), (e.policy.mergeBelow >= e.policy.splitAt || e.policy.splitAt >= e.policy.maxPlayers) && t("Invalid World layering thresholds"), e.affinity !== null && n(e.affinity), (!Array.isArray(e.layers) || e.layers.length > e.maxLayers || Reflect.ownKeys(e.layers).length !== e.layers.length + 1) && t("Invalid World layer inventory");
|
|
29
|
+
let i = /* @__PURE__ */ new Set(), a = [];
|
|
30
|
+
for (let o = 0; o < e.layers.length; o++) {
|
|
31
|
+
let s = Object.getOwnPropertyDescriptor(e.layers, String(o));
|
|
32
|
+
(!s?.enumerable || !("value" in s)) && t("World layer inventory must use own entries");
|
|
33
|
+
let c = s.value;
|
|
34
|
+
r(c, [
|
|
35
|
+
"layer",
|
|
36
|
+
"players",
|
|
37
|
+
"state"
|
|
38
|
+
]), n(c.layer), n(c.players, !0), (i.has(c.layer) || ![
|
|
39
|
+
"live",
|
|
40
|
+
"hibernated",
|
|
41
|
+
"splitting",
|
|
42
|
+
"merging"
|
|
43
|
+
].includes(c.state) || c.state === "hibernated" && c.players !== 0) && t("Duplicate or contradictory World layer observation"), i.add(c.layer), a.push(Object.freeze({
|
|
44
|
+
layer: c.layer,
|
|
45
|
+
players: c.players,
|
|
46
|
+
state: c.state
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
...e,
|
|
51
|
+
policy: Object.freeze({ ...e.policy }),
|
|
52
|
+
layers: Object.freeze(a)
|
|
53
|
+
});
|
|
54
|
+
}, a = (e, t) => (e.state === "live" || e.state === "hibernated") && t.groupSize <= t.policy.maxPlayers - e.players, o = (e) => Object.freeze({
|
|
55
|
+
kind: "use",
|
|
56
|
+
layer: e.layer,
|
|
57
|
+
wake: e.state === "hibernated"
|
|
58
|
+
}), s = (e) => {
|
|
59
|
+
if (e.layers.some((e) => e.state === "splitting")) return Object.freeze({
|
|
60
|
+
kind: "blocked",
|
|
61
|
+
reason: "capacity"
|
|
62
|
+
});
|
|
63
|
+
if (e.layers.length >= e.maxLayers) return Object.freeze({
|
|
64
|
+
kind: "blocked",
|
|
65
|
+
reason: "layer-budget"
|
|
66
|
+
});
|
|
67
|
+
let t = e.layers.reduce((e, t) => Math.max(e, t.layer), 0) + 1;
|
|
68
|
+
return Object.freeze(Number.isSafeInteger(t) ? {
|
|
69
|
+
kind: "create",
|
|
70
|
+
layer: t
|
|
71
|
+
} : {
|
|
72
|
+
kind: "blocked",
|
|
73
|
+
reason: "layer-budget"
|
|
74
|
+
});
|
|
75
|
+
}, c = (e) => {
|
|
76
|
+
let t = i(e);
|
|
77
|
+
if (t.groupSize > t.policy.maxPlayers) return Object.freeze({
|
|
78
|
+
kind: "blocked",
|
|
79
|
+
reason: "capacity"
|
|
80
|
+
});
|
|
81
|
+
if (t.affinity !== null) {
|
|
82
|
+
let e = t.layers.find((e) => e.layer === t.affinity);
|
|
83
|
+
return e && a(e, t) ? o(e) : Object.freeze({
|
|
84
|
+
kind: "blocked",
|
|
85
|
+
reason: "affinity-unavailable"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
let n = t.layers.filter((e) => a(e, t)).sort((e, t) => e.players - t.players || e.layer - t.layer)[0];
|
|
89
|
+
if (n && n.players <= t.policy.splitAt) return o(n);
|
|
90
|
+
let r = s(t);
|
|
91
|
+
return r.kind === "blocked" && n ? o(n) : r;
|
|
92
|
+
}, l = (e, n = c) => {
|
|
93
|
+
let l = i(e);
|
|
94
|
+
typeof n != "function" && t("World layer policy requires a synchronous strategy");
|
|
95
|
+
let u;
|
|
96
|
+
try {
|
|
97
|
+
u = n(l);
|
|
98
|
+
} catch {
|
|
99
|
+
return t("World layer policy failed");
|
|
100
|
+
}
|
|
101
|
+
if (r(u, [
|
|
102
|
+
"kind",
|
|
103
|
+
"layer",
|
|
104
|
+
"wake",
|
|
105
|
+
"reason"
|
|
106
|
+
]), u.kind === "blocked") return (![
|
|
107
|
+
"affinity-unavailable",
|
|
108
|
+
"capacity",
|
|
109
|
+
"layer-budget"
|
|
110
|
+
].includes(u.reason) || Reflect.ownKeys(u).length !== 2) && t("Invalid World layer refusal"), Object.freeze({
|
|
111
|
+
kind: "blocked",
|
|
112
|
+
reason: u.reason
|
|
113
|
+
});
|
|
114
|
+
if (l.groupSize > l.policy.maxPlayers && t("World layer policy exceeded group capacity"), u.kind === "use") {
|
|
115
|
+
let e = l.layers.find((e) => e.layer === u.layer);
|
|
116
|
+
return (Reflect.ownKeys(u).length !== 3 || !e || !a(e, l) || u.wake !== (e.state === "hibernated") || l.affinity !== null && u.layer !== l.affinity) && t("World layer policy selected an ineligible layer"), o(e);
|
|
117
|
+
}
|
|
118
|
+
if (u.kind === "create") {
|
|
119
|
+
let e = s(l);
|
|
120
|
+
return (Reflect.ownKeys(u).length !== 2 || l.affinity !== null || e.kind !== "create" || e.layer !== u.layer) && t("World layer policy selected an invalid new layer"), e;
|
|
121
|
+
}
|
|
122
|
+
return t("Invalid World layer decision");
|
|
123
|
+
}, u = (e) => {
|
|
124
|
+
r(e, [
|
|
125
|
+
"policy",
|
|
126
|
+
"layers",
|
|
127
|
+
"maxLayers"
|
|
128
|
+
]);
|
|
129
|
+
let t = i({
|
|
130
|
+
...e,
|
|
131
|
+
affinity: null,
|
|
132
|
+
groupSize: 1
|
|
133
|
+
}), n = [...t.layers].sort((e, t) => e.layer - t.layer), a = n.filter((e) => e.state === "live" || e.state === "hibernated"), o = a.find((e) => e.players >= t.policy.mergeBelow) ?? a[0], c = [];
|
|
134
|
+
for (let e of n) e.state === "merging" && e.players === 0 ? c.push(Object.freeze({
|
|
135
|
+
kind: "dispose",
|
|
136
|
+
layer: e.layer
|
|
137
|
+
})) : e.state === "live" && e.layer !== o?.layer && e.players < t.policy.mergeBelow ? c.push(Object.freeze({
|
|
138
|
+
kind: "drain",
|
|
139
|
+
layer: e.layer
|
|
140
|
+
})) : e.state === "live" && e.players === 0 && c.push(Object.freeze({
|
|
141
|
+
kind: "hibernate",
|
|
142
|
+
layer: e.layer
|
|
143
|
+
}));
|
|
144
|
+
if (a.length > 0 && a.every((e) => e.players > t.policy.splitAt)) {
|
|
145
|
+
let e = s(t);
|
|
146
|
+
e.kind === "create" && c.push(e);
|
|
147
|
+
}
|
|
148
|
+
return Object.freeze(c);
|
|
149
|
+
};
|
|
150
|
+
//#endregion
|
|
151
|
+
export { c as defaultWorldLayerPolicy, l as resolveWorldLayerPolicy, u as worldLayerMaintenance };
|