@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.
Files changed (495) hide show
  1. package/CHANGELOG.md +24329 -0
  2. package/LICENSE +61 -0
  3. package/README.md +9204 -2
  4. package/SECURITY.md +56 -0
  5. package/THIRD-PARTY-NOTICES.md +11322 -0
  6. package/dist/actor.js +1474 -0
  7. package/dist/apiBinding.js +678 -0
  8. package/dist/apiRegistryBinding.js +399 -0
  9. package/dist/apiReservations.js +433 -0
  10. package/dist/baselines.js +73 -0
  11. package/dist/bots.d.ts +1485 -0
  12. package/dist/bots.js +563 -0
  13. package/dist/catalog.js +80 -0
  14. package/dist/checkpointJson.js +24 -0
  15. package/dist/checkpointStore.js +386 -0
  16. package/dist/client.js +56 -0
  17. package/dist/clockSync.js +51 -0
  18. package/dist/collision.js +156 -0
  19. package/dist/commandDelivery.js +101 -0
  20. package/dist/commandRecord.js +11 -0
  21. package/dist/commandWithdrawal.js +183 -0
  22. package/dist/connection.js +497 -0
  23. package/dist/controlCarrier.js +375 -0
  24. package/dist/controlRegistry.js +79 -0
  25. package/dist/controlTarget.js +45 -0
  26. package/dist/controlTransport.js +574 -0
  27. package/dist/developmentBinding.js +113 -0
  28. package/dist/directory.js +323 -0
  29. package/dist/directoryProjection.js +117 -0
  30. package/dist/errors.d.ts +125 -0
  31. package/dist/errors.js +53 -0
  32. package/dist/fixed.d.ts +284 -0
  33. package/dist/fixed.js +10 -0
  34. package/dist/fixed32.js +134 -0
  35. package/dist/fixedCollision.js +60 -0
  36. package/dist/fixedCollision32.js +109 -0
  37. package/dist/fixedMath.js +56 -0
  38. package/dist/fixedRaw.js +11 -0
  39. package/dist/fixedSlabs.js +34 -0
  40. package/dist/fixedTrig.js +48 -0
  41. package/dist/fixedTrig32.js +38 -0
  42. package/dist/fixedVectors.js +113 -0
  43. package/dist/fixedVectors32.js +95 -0
  44. package/dist/fixedWide.js +50 -0
  45. package/dist/fixedWords.js +46 -0
  46. package/dist/gateway.js +57 -0
  47. package/dist/geometry-retention-app/rooms.geometryJournalRetention.workflow.server.tsx +4 -0
  48. package/dist/geometry-retention-app/rooms.geometryJournalRetention.workflow.tsx +14 -0
  49. package/dist/geometry-worker/worker.d.mts +2 -0
  50. package/dist/geometry-worker/worker.mjs +50 -0
  51. package/dist/geometry.d.ts +2249 -0
  52. package/dist/geometry.js +40 -0
  53. package/dist/geometryActivation.js +82 -0
  54. package/dist/geometryActorInventory.js +108 -0
  55. package/dist/geometryAdminClient.js +87 -0
  56. package/dist/geometryAdminData.js +32 -0
  57. package/dist/geometryAdminFixtures.js +50 -0
  58. package/dist/geometryAdminPorts.js +5 -0
  59. package/dist/geometryAdminRpc.js +58 -0
  60. package/dist/geometryAdminRpcRoutes.js +49 -0
  61. package/dist/geometryAdminSchemas.js +39 -0
  62. package/dist/geometryAdministration.js +190 -0
  63. package/dist/geometryAdministrationPorts.js +5 -0
  64. package/dist/geometryApiBinding.js +165 -0
  65. package/dist/geometryAppStorage.js +58 -0
  66. package/dist/geometryArtifacts.js +198 -0
  67. package/dist/geometryAssetBundle.js +117 -0
  68. package/dist/geometryAssetClient.js +25 -0
  69. package/dist/geometryAssetData.js +106 -0
  70. package/dist/geometryAssetHttp.js +123 -0
  71. package/dist/geometryAssetPorts.js +5 -0
  72. package/dist/geometryAssetRpc.js +30 -0
  73. package/dist/geometryAssetRpcRoutes.js +40 -0
  74. package/dist/geometryAssetStorageGrant.js +103 -0
  75. package/dist/geometryBoxOverlap.js +110 -0
  76. package/dist/geometryCatalogueDigest.js +111 -0
  77. package/dist/geometryCellCoverage.js +85 -0
  78. package/dist/geometryCellLoader.js +28 -0
  79. package/dist/geometryChannel.js +134 -0
  80. package/dist/geometryChunkHttp.js +54 -0
  81. package/dist/geometryChunkLeases.js +22 -0
  82. package/dist/geometryClient.d.ts +1429 -0
  83. package/dist/geometryClient.js +149 -0
  84. package/dist/geometryClientChunks.js +330 -0
  85. package/dist/geometryClientDelta.js +25 -0
  86. package/dist/geometryClientHttp.js +37 -0
  87. package/dist/geometryClientInterest.js +109 -0
  88. package/dist/geometryClientStatic.js +34 -0
  89. package/dist/geometryCms.d.ts +763 -0
  90. package/dist/geometryCms.js +217 -0
  91. package/dist/geometryCommitCoordinator.js +241 -0
  92. package/dist/geometryCompactionFixture.js +84 -0
  93. package/dist/geometryCompactionStrategies.js +38 -0
  94. package/dist/geometryConnectionClient.js +23 -0
  95. package/dist/geometryDerivationFixtures.js +141 -0
  96. package/dist/geometryDerivationStrategies.js +27 -0
  97. package/dist/geometryDigest.js +13 -0
  98. package/dist/geometryEditChannel.js +70 -0
  99. package/dist/geometryEditIngress.js +263 -0
  100. package/dist/geometryEdits.js +366 -0
  101. package/dist/geometryEnvelope.js +41 -0
  102. package/dist/geometryGridRaycast.js +92 -0
  103. package/dist/geometryGridSweep.js +92 -0
  104. package/dist/geometryHeightfield.js +166 -0
  105. package/dist/geometryHeightfieldRaycast.js +74 -0
  106. package/dist/geometryHeightfieldSweep.js +85 -0
  107. package/dist/geometryHeightfieldVolume.js +45 -0
  108. package/dist/geometryHost.js +322 -0
  109. package/dist/geometryHostDirectory.js +207 -0
  110. package/dist/geometryHostMutations.js +137 -0
  111. package/dist/geometryHostStreams.js +124 -0
  112. package/dist/geometryHttpBody.js +76 -0
  113. package/dist/geometryHttpRoutes.js +112 -0
  114. package/dist/geometryImportGltf.js +300 -0
  115. package/dist/geometryImportLdtk.js +54 -0
  116. package/dist/geometryImportPng.js +144 -0
  117. package/dist/geometryImportPublication.js +67 -0
  118. package/dist/geometryImportTiled.js +39 -0
  119. package/dist/geometryImportTiles.js +136 -0
  120. package/dist/geometryImportVox.js +130 -0
  121. package/dist/geometryImportedSource.js +101 -0
  122. package/dist/geometryInspectEndpoint.js +248 -0
  123. package/dist/geometryInspection.js +92 -0
  124. package/dist/geometryInstall.js +121 -0
  125. package/dist/geometryJournalArchiveData.js +21 -0
  126. package/dist/geometryJournalArchiveIndex.js +330 -0
  127. package/dist/geometryJournalArchiveTable.js +21 -0
  128. package/dist/geometryJournalCompaction.js +100 -0
  129. package/dist/geometryJournalPatch.js +47 -0
  130. package/dist/geometryJournalRetention.js +112 -0
  131. package/dist/geometryJournalRetentionSchemas.js +36 -0
  132. package/dist/geometryJournalRetentionSweep.js +112 -0
  133. package/dist/geometryJournalRetentionWorkflow.js +28 -0
  134. package/dist/geometryJournalRetentionWorkflowData.js +31 -0
  135. package/dist/geometryJournalStorage.js +148 -0
  136. package/dist/geometryLoader.js +118 -0
  137. package/dist/geometryManifest.js +113 -0
  138. package/dist/geometryManifestChannel.js +93 -0
  139. package/dist/geometryManifestClient.js +122 -0
  140. package/dist/geometryManifestData.js +49 -0
  141. package/dist/geometryManifestPorts.js +5 -0
  142. package/dist/geometryManifestPublication.js +109 -0
  143. package/dist/geometryManifestSource.js +68 -0
  144. package/dist/geometryMigrationJournal.js +14 -0
  145. package/dist/geometryMigrationStrategies.js +7 -0
  146. package/dist/geometryMigrations.js +323 -0
  147. package/dist/geometryNativeMetadata.js +52 -0
  148. package/dist/geometryPatch.js +170 -0
  149. package/dist/geometryPersistence.js +449 -0
  150. package/dist/geometryPersistenceCapture.js +69 -0
  151. package/dist/geometryPersistenceData.js +140 -0
  152. package/dist/geometryPersistencePorts.js +5 -0
  153. package/dist/geometryPlayerAdmission.js +34 -0
  154. package/dist/geometryPlayerEditOwner.js +265 -0
  155. package/dist/geometryPlayerEdits.js +49 -0
  156. package/dist/geometryPrepared.js +188 -0
  157. package/dist/geometryPrivacyFence.js +24 -0
  158. package/dist/geometryProceduralPublication.js +91 -0
  159. package/dist/geometryProceduralWorker.js +164 -0
  160. package/dist/geometryPublication.js +110 -0
  161. package/dist/geometryRayAlgebra.js +116 -0
  162. package/dist/geometryReadClient.js +157 -0
  163. package/dist/geometryReadPorts.js +5 -0
  164. package/dist/geometryReadRpc.js +27 -0
  165. package/dist/geometryReadRpcRoutes.js +47 -0
  166. package/dist/geometryReliablePublication.js +82 -0
  167. package/dist/geometryReloadPorts.js +46 -0
  168. package/dist/geometryReloadSource.js +278 -0
  169. package/dist/geometryRenderCache.js +165 -0
  170. package/dist/geometryRenderLod.js +102 -0
  171. package/dist/geometryRollback.js +125 -0
  172. package/dist/geometryRollbackCoordinator.js +203 -0
  173. package/dist/geometryRollbackPorts.js +46 -0
  174. package/dist/geometryRollbackSource.js +209 -0
  175. package/dist/geometryRollbackStore.js +198 -0
  176. package/dist/geometrySchemas.js +27 -0
  177. package/dist/geometryServer.d.ts +2766 -0
  178. package/dist/geometryServer.js +62 -0
  179. package/dist/geometryShapeRaycast.js +111 -0
  180. package/dist/geometryShapeSegments.js +34 -0
  181. package/dist/geometryShapes.js +223 -0
  182. package/dist/geometrySnapshot.js +76 -0
  183. package/dist/geometrySnapshotChannel.js +160 -0
  184. package/dist/geometrySnapshotClient.js +159 -0
  185. package/dist/geometrySnapshotPreparation.js +76 -0
  186. package/dist/geometrySnapshotServer.js +191 -0
  187. package/dist/geometrySqlOwner.js +21 -0
  188. package/dist/geometryStorage.js +127 -0
  189. package/dist/geometryStorageGrant.js +69 -0
  190. package/dist/geometryStorageIdentity.js +9 -0
  191. package/dist/geometryTileArtifact.js +10 -0
  192. package/dist/geometryTileCodec.js +194 -0
  193. package/dist/geometryTileCollision.js +96 -0
  194. package/dist/geometryTileNavigation.js +128 -0
  195. package/dist/geometryTileView.js +35 -0
  196. package/dist/geometryVersionActivation.js +114 -0
  197. package/dist/geometryVersionClient.js +238 -0
  198. package/dist/geometryVersionCompare.js +40 -0
  199. package/dist/geometryVersionMigration.js +106 -0
  200. package/dist/geometryVoxel.js +253 -0
  201. package/dist/geometryWorldEntitySubject.js +32 -0
  202. package/dist/geometryWorldExtent.js +12 -0
  203. package/dist/geometryWorldMetadata.js +38 -0
  204. package/dist/geometryWorldStrategyFixtures.js +127 -0
  205. package/dist/geometryWorldView.js +307 -0
  206. package/dist/host.js +128 -0
  207. package/dist/hostBinding.js +277 -0
  208. package/dist/hostCellObservation.js +114 -0
  209. package/dist/hostClientCapacity.js +90 -0
  210. package/dist/hostCommandScope.js +64 -0
  211. package/dist/hostController.js +3094 -0
  212. package/dist/hostDeployment.js +65 -0
  213. package/dist/hostDrain.js +152 -0
  214. package/dist/hostDrainPorts.js +5 -0
  215. package/dist/hostDriver.js +179 -0
  216. package/dist/hostLane.js +288 -0
  217. package/dist/hostListener.js +79 -0
  218. package/dist/hostListenerBinding.js +19 -0
  219. package/dist/hostLoopObservation.js +90 -0
  220. package/dist/hostMetrics.js +56 -0
  221. package/dist/hostRegistryBinding.js +418 -0
  222. package/dist/hostSelection.js +16 -0
  223. package/dist/hostShutdown.js +47 -0
  224. package/dist/hostTurnObservation.js +53 -0
  225. package/dist/identities.js +4 -0
  226. package/dist/index.d.ts +8632 -0
  227. package/dist/index.js +232 -0
  228. package/dist/inputReceipts.js +63 -0
  229. package/dist/inputRedundancy.js +55 -0
  230. package/dist/inspect.js +238 -0
  231. package/dist/lockstep.d.ts +436 -0
  232. package/dist/lockstep.js +382 -0
  233. package/dist/lockstepAdmission.js +262 -0
  234. package/dist/lockstepAdmissionCodec.js +94 -0
  235. package/dist/lockstepAdmissionPorts.js +5 -0
  236. package/dist/lockstepClientSession.js +578 -0
  237. package/dist/lockstepDefinition.js +148 -0
  238. package/dist/lockstepHostLoop.js +243 -0
  239. package/dist/lockstepInitialAdmission.js +67 -0
  240. package/dist/lockstepInitialStrategyFixtures.js +45 -0
  241. package/dist/lockstepJournal.js +395 -0
  242. package/dist/lockstepJournalCodec.js +254 -0
  243. package/dist/lockstepJournalPorts.js +5 -0
  244. package/dist/lockstepJournalRebuild.js +208 -0
  245. package/dist/lockstepJournalRows.js +57 -0
  246. package/dist/lockstepMembers.js +131 -0
  247. package/dist/lockstepMessages.js +47 -0
  248. package/dist/lockstepOwnedRoom.js +764 -0
  249. package/dist/lockstepPolicies.js +84 -0
  250. package/dist/lockstepReact.js +47 -0
  251. package/dist/lockstepRecoveryTruth.js +121 -0
  252. package/dist/lockstepRosterConfig.js +32 -0
  253. package/dist/lockstepSeed.js +12 -0
  254. package/dist/lockstepSeedFixture.js +20 -0
  255. package/dist/lockstepServer.d.ts +3897 -0
  256. package/dist/lockstepServer.js +325 -0
  257. package/dist/lockstepServerConfig.js +101 -0
  258. package/dist/lockstepServerRoles.js +403 -0
  259. package/dist/lockstepServerStrategyFixtures.js +33 -0
  260. package/dist/lockstepStrategies.js +6 -0
  261. package/dist/lockstepStrategyFixtures.js +137 -0
  262. package/dist/lockstepTerminal.js +90 -0
  263. package/dist/lockstepTerminalPorts.js +5 -0
  264. package/dist/lockstepTransport.js +773 -0
  265. package/dist/lockstepTransportConfig.js +32 -0
  266. package/dist/lockstepWireRoster.js +34 -0
  267. package/dist/matchRoomProvider.js +32 -0
  268. package/dist/matchRooms.js +19 -0
  269. package/dist/membershipObserver.js +47 -0
  270. package/dist/moderation.js +98 -0
  271. package/dist/movementSpecials.js +104 -0
  272. package/dist/ownership.js +17 -0
  273. package/dist/ownershipWithdrawal.js +18 -0
  274. package/dist/pcg32.js +96 -0
  275. package/dist/ports.d.ts +1241 -0
  276. package/dist/ports.js +11 -0
  277. package/dist/quaternion.js +70 -0
  278. package/dist/react.d.ts +406 -0
  279. package/dist/react.js +109 -0
  280. package/dist/reaper-app/rooms.reaper.workflow.server.tsx +5 -0
  281. package/dist/reaper-app/rooms.reaper.workflow.tsx +13 -0
  282. package/dist/reaper.js +243 -0
  283. package/dist/reaperSchemas.js +42 -0
  284. package/dist/reaperWorkflow.js +70 -0
  285. package/dist/recovery.js +189 -0
  286. package/dist/recoverySeats.js +26 -0
  287. package/dist/replay.d.ts +273 -0
  288. package/dist/replay.js +485 -0
  289. package/dist/replayPorts.js +5 -0
  290. package/dist/replayRecording.js +67 -0
  291. package/dist/replaySchema.js +157 -0
  292. package/dist/replayStorage.d.ts +149 -0
  293. package/dist/replayStorage.js +485 -0
  294. package/dist/reservationBatch.js +422 -0
  295. package/dist/reservationSchemas.js +17 -0
  296. package/dist/reservations.js +259 -0
  297. package/dist/reservePort.js +69 -0
  298. package/dist/resolvedOptions.js +4 -0
  299. package/dist/room.d.ts +1006 -0
  300. package/dist/room.js +284 -0
  301. package/dist/roomAccessSweep.js +95 -0
  302. package/dist/roomAppCommandControl.js +59 -0
  303. package/dist/roomAuthoringStrategy.js +17 -0
  304. package/dist/roomErasure.js +198 -0
  305. package/dist/roomPoolRuntimeDefaults.js +24 -0
  306. package/dist/roomPoolSelection.js +19 -0
  307. package/dist/roomPoolTopology.js +212 -0
  308. package/dist/rpc.d.ts +551 -0
  309. package/dist/rpc.js +112 -0
  310. package/dist/rpcClient.js +152 -0
  311. package/dist/rpcRoutes.js +28 -0
  312. package/dist/runtime.js +1123 -0
  313. package/dist/schemaHistory.js +98 -0
  314. package/dist/seatStore.js +151 -0
  315. package/dist/seatStrategyFixtures.js +52 -0
  316. package/dist/seatSubject.js +32 -0
  317. package/dist/seats.js +130 -0
  318. package/dist/serverSession.js +811 -0
  319. package/dist/serverSessionConfig.js +43 -0
  320. package/dist/sessionAdmission.js +53 -0
  321. package/dist/sidecarAdmission.js +103 -0
  322. package/dist/sidecarConfig.js +116 -0
  323. package/dist/sidecarConfigPublication.js +64 -0
  324. package/dist/sidecarHostListener.js +208 -0
  325. package/dist/sidecarIpc.js +205 -0
  326. package/dist/sidecarPeer.js +310 -0
  327. package/dist/sidecarProcessPort.js +28 -0
  328. package/dist/sidecarRuntime.js +168 -0
  329. package/dist/sidecarSelection.js +142 -0
  330. package/dist/sidecarWire.js +178 -0
  331. package/dist/sidecarWrites.js +163 -0
  332. package/dist/simulation.d.ts +391 -0
  333. package/dist/simulation.js +282 -0
  334. package/dist/simulationAuthoring.js +29 -0
  335. package/dist/simulationBytes.js +27 -0
  336. package/dist/simulationConformance.js +305 -0
  337. package/dist/simulationInputHistoryCapture.js +35 -0
  338. package/dist/simulationInputHistoryWire.js +193 -0
  339. package/dist/simulationOptionsWire.js +78 -0
  340. package/dist/simulationRecoveryWire.js +134 -0
  341. package/dist/simulationReplay.js +127 -0
  342. package/dist/simulationSnapshotWire.js +112 -0
  343. package/dist/simulationState.js +178 -0
  344. package/dist/snapshotBlob.js +126 -0
  345. package/dist/snapshotBlobCleanup.js +93 -0
  346. package/dist/snapshotBlobIndex.js +38 -0
  347. package/dist/snapshotBudget.js +80 -0
  348. package/dist/snapshotChain.js +185 -0
  349. package/dist/snapshotErasure.js +172 -0
  350. package/dist/snapshotInspection.js +105 -0
  351. package/dist/snapshotSegmentBlobs.js +58 -0
  352. package/dist/snapshotUploads.js +166 -0
  353. package/dist/socketTransport.js +253 -0
  354. package/dist/spatial.js +104 -0
  355. package/dist/spectatorPolicy.js +26 -0
  356. package/dist/spectatorProducer.js +89 -0
  357. package/dist/startFailureCause.js +4 -0
  358. package/dist/stateCodec.js +658 -0
  359. package/dist/strategies.d.ts +210 -0
  360. package/dist/strategies.js +8 -0
  361. package/dist/strategiesServer.d.ts +286 -0
  362. package/dist/strategiesServer.js +11 -0
  363. package/dist/strategyFixtures.js +182 -0
  364. package/dist/streamFraming.js +122 -0
  365. package/dist/streamTransport.js +266 -0
  366. package/dist/subjectAdmission.js +50 -0
  367. package/dist/subjectPrivacy.js +281 -0
  368. package/dist/subjectPrivacyBinding.js +90 -0
  369. package/dist/systemManifest.js +182 -0
  370. package/dist/tables.js +159 -0
  371. package/dist/testHarness.js +89 -0
  372. package/dist/testing.d.ts +3684 -0
  373. package/dist/testing.js +221 -0
  374. package/dist/testingPorts.js +271 -0
  375. package/dist/testingServer.d.ts +4060 -0
  376. package/dist/testingServer.js +18 -0
  377. package/dist/transform.d.ts +692 -0
  378. package/dist/transform.js +217 -0
  379. package/dist/transform3d.js +118 -0
  380. package/dist/transformCollection.js +24 -0
  381. package/dist/transformCollection3d.js +24 -0
  382. package/dist/transformCollectionCore.js +156 -0
  383. package/dist/transformFrames.js +121 -0
  384. package/dist/transformPrediction3d.js +127 -0
  385. package/dist/transformRules.js +123 -0
  386. package/dist/transformSchemas.js +20 -0
  387. package/dist/transport.js +32 -0
  388. package/dist/transportAuthoring.js +29 -0
  389. package/dist/transportCleanup.js +22 -0
  390. package/dist/transportConformance.js +124 -0
  391. package/dist/transportConnector.js +82 -0
  392. package/dist/transportEndpoints.js +38 -0
  393. package/dist/transportsServer.d.ts +5515 -0
  394. package/dist/transportsServer.js +6 -0
  395. package/dist/viewProjection.js +16 -0
  396. package/dist/web.d.ts +2286 -0
  397. package/dist/web.js +518 -0
  398. package/dist/webTransportClient.js +173 -0
  399. package/dist/wire.d.ts +992 -0
  400. package/dist/wire.js +492 -0
  401. package/dist/withdrawalPort.js +28 -0
  402. package/dist/world.d.ts +1894 -0
  403. package/dist/world.js +333 -0
  404. package/dist/worldActorReceipts.js +48 -0
  405. package/dist/worldActorTransferSnapshot.js +14 -0
  406. package/dist/worldAdmissionPending.js +8 -0
  407. package/dist/worldBoundaryCoordinator.js +148 -0
  408. package/dist/worldCatalog.js +81 -0
  409. package/dist/worldCellAllocation.js +203 -0
  410. package/dist/worldCellDestination.js +68 -0
  411. package/dist/worldCells.js +489 -0
  412. package/dist/worldChange.js +32 -0
  413. package/dist/worldClient.js +664 -0
  414. package/dist/worldClientControl.js +141 -0
  415. package/dist/worldClientPendingInput.js +16 -0
  416. package/dist/worldClientRpc.js +133 -0
  417. package/dist/worldClientRpcRoutes.js +43 -0
  418. package/dist/worldClientSchemas.js +28 -0
  419. package/dist/worldCommands.js +140 -0
  420. package/dist/worldData.js +42 -0
  421. package/dist/worldDefaultBinding.js +377 -0
  422. package/dist/worldDefaultGroupAdmission.js +82 -0
  423. package/dist/worldDefaultGroupAppServices.js +31 -0
  424. package/dist/worldDefaultGroupCompensation.js +109 -0
  425. package/dist/worldDefaultGroupContinuation.js +96 -0
  426. package/dist/worldDefaultGroupControl.js +72 -0
  427. package/dist/worldDefaultGroupMembers.js +85 -0
  428. package/dist/worldDefaultGroups.js +21 -0
  429. package/dist/worldDefaultPending.js +79 -0
  430. package/dist/worldDefaultService.js +245 -0
  431. package/dist/worldEntities.js +2980 -0
  432. package/dist/worldEntityCodec.js +21 -0
  433. package/dist/worldEntityHandoffView.js +154 -0
  434. package/dist/worldGeometry.js +170 -0
  435. package/dist/worldGhostAdmission.js +65 -0
  436. package/dist/worldGhostDestination.js +118 -0
  437. package/dist/worldGhostGateway.js +132 -0
  438. package/dist/worldGhostHandshake.js +108 -0
  439. package/dist/worldGhostHost.js +42 -0
  440. package/dist/worldGhostIngress.js +132 -0
  441. package/dist/worldGhostNeighborhood.js +70 -0
  442. package/dist/worldGhostNeighbors.js +86 -0
  443. package/dist/worldGhostOutbound.js +110 -0
  444. package/dist/worldGhostPublisher.js +216 -0
  445. package/dist/worldGhostReceiver.js +213 -0
  446. package/dist/worldGhostSender.js +146 -0
  447. package/dist/worldGhostSocket.js +78 -0
  448. package/dist/worldGhostWire.js +172 -0
  449. package/dist/worldGroupCommand.js +49 -0
  450. package/dist/worldGroupDeadline.js +115 -0
  451. package/dist/worldGroupPreparation.js +115 -0
  452. package/dist/worldGroupReadyControl.js +128 -0
  453. package/dist/worldGroupSupervisor.js +120 -0
  454. package/dist/worldHandoffMetrics.js +59 -0
  455. package/dist/worldHandoffView.js +100 -0
  456. package/dist/worldHostSource.js +69 -0
  457. package/dist/worldInspectEndpoint.js +250 -0
  458. package/dist/worldInspection.js +109 -0
  459. package/dist/worldInstanceAdmission.js +31 -0
  460. package/dist/worldInstanceAllocation.js +116 -0
  461. package/dist/worldInstanceDestination.js +64 -0
  462. package/dist/worldInstanceExpiry.js +282 -0
  463. package/dist/worldInstanceExpirySupervisor.js +88 -0
  464. package/dist/worldInstanceLifecycle.js +103 -0
  465. package/dist/worldInstanceState.js +52 -0
  466. package/dist/worldInstances.js +478 -0
  467. package/dist/worldJoin.js +56 -0
  468. package/dist/worldLayers.js +151 -0
  469. package/dist/worldLeases.js +78 -0
  470. package/dist/worldManifest.js +25 -0
  471. package/dist/worldMovement.js +63 -0
  472. package/dist/worldPersistence.js +134 -0
  473. package/dist/worldProjection.js +221 -0
  474. package/dist/worldReact.js +110 -0
  475. package/dist/worldRecoveryActor.js +35 -0
  476. package/dist/worldReturnAnchor.js +49 -0
  477. package/dist/worldRoomHooks.js +57 -0
  478. package/dist/worldRoomPool.js +27 -0
  479. package/dist/worldRoomSteps.js +133 -0
  480. package/dist/worldSeatBinding.js +36 -0
  481. package/dist/worldServer.d.ts +6936 -0
  482. package/dist/worldServer.js +48 -0
  483. package/dist/worldSourceSeatPending.js +9 -0
  484. package/dist/worldStrategyFixtures.js +164 -0
  485. package/dist/worldTesting.js +27 -0
  486. package/dist/worldTransitionDefaults.js +198 -0
  487. package/dist/worldTransitionExecutor.js +519 -0
  488. package/dist/worldTransitionGroup.js +113 -0
  489. package/dist/worldTransitionPhysicalSteps.js +40 -0
  490. package/dist/worldTransitionResolver.js +228 -0
  491. package/dist/worldTransitionSeatGroup.js +64 -0
  492. package/dist/worldTransitionSeats.js +260 -0
  493. package/dist/worldTransitionState.js +95 -0
  494. package/dist/worldTransitions.js +101 -0
  495. package/package.json +189 -4
@@ -0,0 +1,109 @@
1
+ import { WorldTransitionPhaseSchema as e } from "./worldCommands.js";
2
+ import { Schema as t } from "effect";
3
+ //#region src/worldInspection.ts
4
+ var n = t.String.pipe(t.check(t.isMinLength(1)), t.check(t.isMaxLength(191)), t.check(t.makeFilter((e) => e.trim() === e))), r = t.Number.pipe(t.check(t.isInt()), t.check(t.isGreaterThanOrEqualTo(0)), t.check(t.makeFilter(Number.isSafeInteger))), i = r.pipe(t.check(t.isGreaterThan(0))), a = t.Number.pipe(t.check(t.isFinite())), o = t.Tuple([a, a]), s = t.Tuple([o, o]).pipe(t.check(t.makeFilter((e) => e[1][0] > e[0][0] && e[1][1] > e[0][1] && Number.isFinite(e[1][0] - e[0][0]) && Number.isFinite(e[1][1] - e[0][1])))), c = t.String.pipe(t.check(t.makeFilter((e) => Number.isFinite(Date.parse(e))))), l = t.Struct({
5
+ id: n,
6
+ bounds: s,
7
+ cellSize: t.NullOr(a.pipe(t.check(t.isGreaterThan(0)))),
8
+ maxPlayers: t.NullOr(i)
9
+ }), u = t.Struct({
10
+ id: n,
11
+ bounds: s,
12
+ zones: t.Array(l).pipe(t.check(t.isMinLength(1)), t.check(t.isMaxLength(256))),
13
+ layerPolicy: t.Literals(["default", "custom"]),
14
+ transitionPolicy: t.Literals(["default", "custom"]),
15
+ worldChangePolicy: t.Literals(["default", "custom"])
16
+ }), d = t.Struct({
17
+ id: n,
18
+ zoneId: n,
19
+ cellId: n,
20
+ layer: i,
21
+ bounds: s,
22
+ players: r,
23
+ epoch: i,
24
+ revision: i,
25
+ state: t.Literals([
26
+ "creating",
27
+ "live",
28
+ "hibernated"
29
+ ]),
30
+ roomObservation: t.Literals([
31
+ "matching",
32
+ "stale",
33
+ "missing"
34
+ ]),
35
+ updatedAt: c
36
+ }), f = t.Struct({
37
+ worldId: n,
38
+ zoneId: n,
39
+ cellId: n,
40
+ layer: i
41
+ }), p = t.Struct({
42
+ id: n,
43
+ mode: t.Literals(["seamless", "portal"]),
44
+ phase: e,
45
+ revision: i,
46
+ entityRevision: i,
47
+ source: f,
48
+ target: f,
49
+ createdAt: c,
50
+ updatedAt: c,
51
+ committedAt: t.NullOr(c)
52
+ }), m = t.Struct({
53
+ worldState: t.Literals([
54
+ "none",
55
+ "entities",
56
+ "transitions"
57
+ ]),
58
+ worldClientControls: t.Boolean,
59
+ catalog: t.Array(n).pipe(t.check(t.isMaxLength(256))),
60
+ page: t.Struct({
61
+ tenantId: n,
62
+ worldId: t.NullOr(n),
63
+ after: t.NullOr(n),
64
+ nextAfter: t.NullOr(n)
65
+ }),
66
+ world: t.NullOr(u),
67
+ cells: t.Array(d).pipe(t.check(t.isMaxLength(50))),
68
+ transitions: t.NullOr(t.Struct({
69
+ after: t.NullOr(n),
70
+ nextAfter: t.NullOr(n),
71
+ entries: t.Array(p).pipe(t.check(t.isMaxLength(50)))
72
+ }))
73
+ }).pipe(t.check(t.makeFilter((e) => {
74
+ if (e.worldClientControls && e.worldState !== "transitions" || new Set(e.catalog).size !== e.catalog.length || new Set(e.cells.map((e) => e.id)).size !== e.cells.length || new Set(e.cells.map((e) => JSON.stringify([
75
+ e.zoneId,
76
+ e.cellId,
77
+ e.layer
78
+ ]))).size !== e.cells.length) return !1;
79
+ if (e.world === null) return e.page.worldId === null && e.page.after === null && e.page.nextAfter === null && e.cells.length === 0 && e.transitions === null;
80
+ if (e.world.id !== e.page.worldId || !e.catalog.includes(e.world.id) || new Set(e.world.zones.map((e) => e.id)).size !== e.world.zones.length) return !1;
81
+ let t = e.world.bounds;
82
+ for (let n of e.world.zones) if (n.bounds[0][0] < t[0][0] || n.bounds[0][1] < t[0][1] || n.bounds[1][0] > t[1][0] || n.bounds[1][1] > t[1][1]) return !1;
83
+ for (let t = 0; t < e.cells.length; t++) {
84
+ let n = e.cells[t], r = e.world.zones.find((e) => e.id === n.zoneId);
85
+ if (!r || (n.state === "hibernated" || n.state === "creating" && n.epoch === 1) && n.players !== 0 || r.maxPlayers !== null && n.players > r.maxPlayers || e.page.after !== null && n.id <= e.page.after || t > 0 && e.cells[t - 1].id >= n.id) return !1;
86
+ let i = n.cellId.split(":"), a = Number(i[1]), o = Number(i[2]);
87
+ if (i.length !== 3 || i[0] !== r.id || !Number.isSafeInteger(a) || a < 0 || String(a) !== i[1] || !Number.isSafeInteger(o) || o < 0 || String(o) !== i[2]) return !1;
88
+ let s = r.cellSize ?? Math.max(r.bounds[1][0] - r.bounds[0][0], r.bounds[1][1] - r.bounds[0][1]), c = r.bounds[0][0] + a * s, l = r.bounds[0][1] + o * s;
89
+ if (!Number.isFinite(c) || !Number.isFinite(l) || c >= r.bounds[1][0] || l >= r.bounds[1][1] || n.bounds[0][0] !== c || n.bounds[0][1] !== l || n.bounds[1][0] !== Math.min(c + s, r.bounds[1][0]) || n.bounds[1][1] !== Math.min(l + s, r.bounds[1][1])) return !1;
90
+ }
91
+ if (e.page.nextAfter !== null && (e.cells.length !== 50 || e.page.nextAfter !== e.cells.at(-1)?.id)) return !1;
92
+ if (e.worldState !== "transitions") return e.transitions === null;
93
+ if (e.transitions === null) return !1;
94
+ let n = e.transitions;
95
+ if (new Set(n.entries.map((e) => e.id)).size !== n.entries.length) return !1;
96
+ for (let t = 0; t < n.entries.length; t++) {
97
+ let r = n.entries[t], i = r.phase === "committed" || r.phase === "settled";
98
+ if (!e.catalog.includes(r.source.worldId) || !e.catalog.includes(r.target.worldId) || r.source.worldId !== e.world.id && r.target.worldId !== e.world.id || n.after !== null && r.id <= n.after || t > 0 && n.entries[t - 1].id >= r.id || i !== (r.committedAt !== null) || Date.parse(r.updatedAt) < Date.parse(r.createdAt) || r.committedAt !== null && (Date.parse(r.committedAt) < Date.parse(r.createdAt) || Date.parse(r.committedAt) > Date.parse(r.updatedAt))) return !1;
99
+ for (let t of [r.source, r.target]) if (t.worldId === e.world.id) {
100
+ let n = e.world.zones.find((e) => e.id === t.zoneId), r = t.cellId.split(":"), i = Number(r[1]), a = Number(r[2]);
101
+ if (!n || r.length !== 3 || r[0] !== n.id || !Number.isSafeInteger(i) || i < 0 || String(i) !== r[1] || !Number.isSafeInteger(a) || a < 0 || String(a) !== r[2]) return !1;
102
+ let o = n.cellSize ?? Math.max(n.bounds[1][0] - n.bounds[0][0], n.bounds[1][1] - n.bounds[0][1]);
103
+ if (n.bounds[0][0] + i * o >= n.bounds[1][0] || n.bounds[0][1] + a * o >= n.bounds[1][1]) return !1;
104
+ }
105
+ }
106
+ return n.nextAfter === null || n.entries.length === 50 && n.nextAfter === n.entries.at(-1)?.id;
107
+ }))), h = (e) => t.decodeUnknownSync(m)(e);
108
+ //#endregion
109
+ export { m as WorldInspectionSchema, h as decodeWorldInspection };
@@ -0,0 +1,31 @@
1
+ import { WORLD_INSTANCES_TABLE as e } from "./worldInstanceState.js";
2
+ import { ProtocolError as t } from "./errors.js";
3
+ import { assertWorldRoomPool as n } from "./worldRoomPool.js";
4
+ import { and as r, eq as i } from "@voltro/database";
5
+ //#region src/worldInstanceAdmission.ts
6
+ var a = async (a, o, s, c) => {
7
+ let l = s.flatMap((e) => e.instances.filter((e) => e.room === o.name).map((t) => ({
8
+ world: e,
9
+ instance: t
10
+ })));
11
+ if (!l.length) return;
12
+ let u = () => {
13
+ throw new t({ detail: "World instance Session requires a live unexpired owner" });
14
+ }, d = await a.query({
15
+ table: e,
16
+ predicate: r(i("tenantId", o.tenantId), i("roomId", o.id)),
17
+ order: [],
18
+ take: 2,
19
+ skip: void 0,
20
+ projection: void 0,
21
+ lock: "update"
22
+ }), f = d[0];
23
+ if (d.length !== 1 || !f || f.state !== "live" || o.state !== "live" || f.hostId !== o.hostId || f.epoch !== o.epoch) return u();
24
+ let p = l.find(({ world: e, instance: t }) => e.name === f.worldId && t.id === f.instance);
25
+ if (!p) return u();
26
+ await n(a, p.world, o, !1);
27
+ let m = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : NaN, h = m(f.createdAt), g = m(f.expiresAt), _ = c();
28
+ if (!Number.isSafeInteger(h) || h < 0 || !Number.isSafeInteger(g) || g - h !== p.instance.ttlMs || !Number.isSafeInteger(_) || _ < h || _ >= g) return u();
29
+ };
30
+ //#endregion
31
+ export { a as assertWorldInstanceSeatAdmission };
@@ -0,0 +1,116 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { captureWorldData as t } from "./worldData.js";
3
+ import { ROOM_CREATIONS_TABLE as n } from "./identities.js";
4
+ import { captureWorldCatalog as r } from "./world.js";
5
+ import { assertWorldInstanceRecreation as i, dataStoreWorldInstances as a, worldInstanceCreationKey as o } from "./worldInstances.js";
6
+ import { and as s, eq as c } from "@voltro/database";
7
+ import { Effect as l } from "effect";
8
+ //#region src/worldInstanceAllocation.ts
9
+ function u() {
10
+ throw new e({ detail: "Instance allocation requires exact live Host publication" });
11
+ }
12
+ var d = (t) => l.suspend(() => {
13
+ let e = t();
14
+ return l.isEffect(e) ? e : u();
15
+ }).pipe(l.catchCause(() => l.fail(new e({ detail: "Instance allocation remains incomplete" })))), f = (e, t) => {
16
+ (!e || Object.getPrototypeOf(e) !== Object.prototype || Reflect.ownKeys(e).length !== t.length || t.some((t) => {
17
+ let n = Object.getOwnPropertyDescriptor(e, t);
18
+ return !n?.enumerable || !("value" in n);
19
+ })) && u();
20
+ }, p = (p, m) => {
21
+ f(m, [
22
+ "tenantId",
23
+ "worlds",
24
+ "epochNow",
25
+ "maxManagedGroups",
26
+ "authorize",
27
+ "prepare",
28
+ ...Object.hasOwn(m, "wake") ? ["wake"] : []
29
+ ]);
30
+ let h = r(m.worlds), g = m.tenantId;
31
+ (typeof g != "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,190}$/.test(g) || typeof m.epochNow != "function" || typeof m.authorize != "function" || typeof m.prepare != "function" || m.wake !== void 0 && typeof m.wake != "function") && u();
32
+ let _ = m.epochNow.bind(m), v = m.authorize.bind(m), y = m.prepare.bind(m), b = m.wake?.bind(m), x = m.maxManagedGroups;
33
+ return a(p, {
34
+ worlds: h,
35
+ epochNow: _,
36
+ maxManagedGroups: x,
37
+ authorize: () => l.void
38
+ }), Object.freeze({ ensure: (r, m = 1) => {
39
+ let S;
40
+ try {
41
+ f(r, [
42
+ "tenantId",
43
+ "worldId",
44
+ "instance",
45
+ "groupId"
46
+ ]), S = t(r, 4096), S.tenantId !== g && u(), o(S, m);
47
+ } catch {
48
+ return l.fail(new e({ detail: "Invalid instance allocation identity" }));
49
+ }
50
+ let C = Object.freeze({
51
+ identity: S,
52
+ generation: m
53
+ });
54
+ return d(() => l.gen(function* () {
55
+ let r = h.find((e) => e.name === S.worldId), w = r?.instances.find((e) => e.id === S.instance);
56
+ if (!r || !w) return u();
57
+ yield* d(() => v("allocate", C));
58
+ let T = a(p, {
59
+ worlds: h,
60
+ epochNow: _,
61
+ maxManagedGroups: x,
62
+ authorize: () => d(() => v("observe", C))
63
+ }), E = yield* T.inspect(S), D = E?.publication ?? null;
64
+ if (D && D.state !== "retired" && (D.generation !== m || D.expired)) return u();
65
+ if (D?.state === "live" && E?.synchronized) return D;
66
+ let O, k = E?.owner;
67
+ if (D && k && (k.state === "hibernated" || k.state === "orphaned" || k.epoch > 1)) {
68
+ if (!b) return u();
69
+ yield* d(() => v("wake", C));
70
+ let e = k.state === "hibernated" || k.state === "orphaned" ? k.epoch : k.epoch - 1;
71
+ if (O = t(yield* d(() => b(Object.freeze({
72
+ ...C,
73
+ existing: D,
74
+ priorEpoch: e
75
+ }))), 4096), f(O, [
76
+ "roomId",
77
+ "hostId",
78
+ "epoch"
79
+ ]), O.roomId !== D.roomId || O.epoch !== e + 1) return u();
80
+ } else {
81
+ if (D && (D.state !== "retired" && D.state !== "creating" || D.state === "retired" && m <= D.generation)) return u();
82
+ m > 1 && (yield* d(() => v("reset", C)), yield* l.tryPromise({
83
+ try: () => i(p, r, S, m),
84
+ catch: () => new e({ detail: "Instance reset predecessor is not disposed and empty" })
85
+ }));
86
+ let a = o(S, m);
87
+ if (O = t(yield* d(() => y(Object.freeze({
88
+ ...C,
89
+ roomName: w.room,
90
+ creationKey: a,
91
+ existing: D
92
+ }))), 4096), f(O, [
93
+ "roomId",
94
+ "hostId",
95
+ "epoch"
96
+ ]), O.epoch !== 1 || D?.state === "creating" && (O.roomId !== D.roomId || O.hostId !== D.hostId)) return u();
97
+ let h = yield* l.tryPromise({
98
+ try: () => p.query({
99
+ table: n,
100
+ predicate: s(c("tenantId", g), c("requestKey", a)),
101
+ order: [],
102
+ take: 2,
103
+ skip: void 0,
104
+ projection: ["roomId"]
105
+ }),
106
+ catch: () => new e({ detail: "Instance creation receipt remains unavailable" })
107
+ });
108
+ if (h.length !== 1 || h[0].roomId !== O.roomId) return u();
109
+ }
110
+ let A = yield* T.observe(S);
111
+ return !A || A.state !== "live" || A.expired || A.generation !== m || A.roomId !== O.roomId || A.hostId !== O.hostId || A.epoch !== O.epoch || typeof O.hostId != "string" || !O.hostId || D && D.state !== "retired" && (A.id !== D.id || A.createdAt !== D.createdAt || A.expiresAt !== D.expiresAt) ? u() : A;
112
+ }));
113
+ } });
114
+ };
115
+ //#endregion
116
+ export { p as dataStoreWorldInstanceAllocation };
@@ -0,0 +1,64 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { captureWorldData as t } from "./worldData.js";
3
+ import { worldTransitionRequest as n } from "./worldCommands.js";
4
+ import { captureWorldCatalog as r, worldCellAt as i } from "./world.js";
5
+ import { dataStoreWorldInstances as a } from "./worldInstances.js";
6
+ import { Effect as o } from "effect";
7
+ //#region src/worldInstanceDestination.ts
8
+ var s = (s, c) => {
9
+ let l = [
10
+ "tenantId",
11
+ "worlds",
12
+ "maxDataBytes",
13
+ "maxManagedGroups",
14
+ "epochNow",
15
+ "authorize",
16
+ ...Object.hasOwn(c, "prepare") ? ["prepare"] : []
17
+ ], u = () => {
18
+ throw new e({ detail: "Instance destination requires an actual live group Room" });
19
+ };
20
+ (!c || Object.getPrototypeOf(c) !== Object.prototype || Reflect.ownKeys(c).length !== l.length || l.some((e) => {
21
+ let t = Object.getOwnPropertyDescriptor(c, e);
22
+ return !t?.enumerable || !("value" in t);
23
+ })) && u();
24
+ let d = r(c.worlds), f = c.tenantId, p = c.maxDataBytes;
25
+ (typeof f != "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,190}$/.test(f) || !Number.isSafeInteger(p) || p < 1 || typeof c.epochNow != "function" || typeof c.authorize != "function") && u(), c.prepare !== void 0 && typeof c.prepare != "function" && u();
26
+ let m = c.prepare?.bind(c), h = a(s, {
27
+ worlds: d,
28
+ epochNow: c.epochNow.bind(c),
29
+ maxManagedGroups: c.maxManagedGroups,
30
+ authorize: c.authorize.bind(c)
31
+ });
32
+ return (r) => o.suspend(() => {
33
+ let e = n(r.intent), a = t(r.current.location, 4096), s = t(r.current.data, p), c = d.find((e) => e.name === a.worldId);
34
+ if (e.target.kind !== "instance" || e.options.returnTo !== "here" || !c || r.entity.returnAnchor || r.origin.tenantId !== f || r.entity.tenantId !== f || r.entity.entityId !== e.entityId || r.origin.roomId !== a.roomId || r.entity.roomId !== a.roomId || r.entity.epoch !== a.epoch || r.entity.worldId !== a.worldId || r.entity.zoneId !== a.zoneId || r.entity.layer !== a.layer || i(c, {
35
+ zone: a.zoneId,
36
+ at: a.at
37
+ }).id !== r.entity.cellId) return u();
38
+ let l = Object.freeze({
39
+ tenantId: f,
40
+ worldId: c.name,
41
+ instance: e.target.instance,
42
+ groupId: e.target.group
43
+ });
44
+ return o.gen(function* () {
45
+ let e = yield* h.inspect(l), t = e?.publication ?? null;
46
+ if (t?.expired || t?.state === "retired") return u();
47
+ if (!t || t.state !== "live" || !e?.synchronized) {
48
+ if (!m) return u();
49
+ let e = t, n = m(l);
50
+ if (!o.isEffect(n) || (yield* n) !== void 0 || (t = yield* h.observe(l), e && (!t || t.id !== e.id || t.generation !== e.generation || t.roomId !== e.roomId || t.createdAt !== e.createdAt || t.expiresAt !== e.expiresAt))) return u();
51
+ }
52
+ return !t || t.state !== "live" || t.expired || !t.hostId || t.roomId === a.roomId ? u() : Object.freeze({
53
+ location: Object.freeze({
54
+ ...a,
55
+ roomId: t.roomId,
56
+ epoch: t.epoch
57
+ }),
58
+ data: s
59
+ });
60
+ });
61
+ }).pipe(o.catchCause(() => o.fail(new e({ detail: "SQL instance destination remains unavailable" }))));
62
+ };
63
+ //#endregion
64
+ export { s as dataStoreWorldInstanceDestination };
@@ -0,0 +1,282 @@
1
+ import { WORLD_INSTANCES_TABLE as e } from "./worldInstanceState.js";
2
+ import { ProtocolError as t } from "./errors.js";
3
+ import { captureWorldData as n } from "./worldData.js";
4
+ import { worldTransitionRequest as r } from "./worldCommands.js";
5
+ import { WORLD_TRANSITIONS_TABLE as i } from "./identities.js";
6
+ import { captureWorldCatalog as a } from "./world.js";
7
+ import { lockRoomReservationOwners as o } from "./hostClientCapacity.js";
8
+ import { assertWorldRoomPool as s } from "./worldRoomPool.js";
9
+ import { captureWorldEntityReturnAnchor as c } from "./worldReturnAnchor.js";
10
+ import { WORLD_ENTITIES_TABLE as l } from "./worldEntities.js";
11
+ import { worldInstanceGroupKey as u } from "./worldInstances.js";
12
+ import { and as d, eq as f, gt as p, lte as m, neq as h } from "@voltro/database";
13
+ import { Effect as g } from "effect";
14
+ //#region src/worldInstanceExpiry.ts
15
+ function _() {
16
+ throw new t({ detail: "Instance expiry inventory requires current bounded SQL authority" });
17
+ }
18
+ var v = (e) => typeof e == "string" && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,190}$/.test(e) ? e : _(), y = (e, t = 0) => typeof e == "number" && Number.isSafeInteger(e) && e >= t && e <= 2147483647 ? e : _(), b = (e) => {
19
+ let t = e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : NaN;
20
+ return Number.isSafeInteger(t) && t >= 0 ? t : _();
21
+ }, x = (x, S) => {
22
+ let C = [
23
+ "tenantId",
24
+ "worlds",
25
+ "epochNow",
26
+ "maxPageRows",
27
+ "maxEntityRows",
28
+ "maxInventoryBytes",
29
+ "authorize"
30
+ ];
31
+ (!S || Object.getPrototypeOf(S) !== Object.prototype || Reflect.ownKeys(S).length !== C.length || C.some((e) => {
32
+ let t = Object.getOwnPropertyDescriptor(S, e);
33
+ return !t?.enumerable || !("value" in t);
34
+ })) && _();
35
+ let w = v(S.tenantId), T = a(S.worlds), E = y(S.maxPageRows, 1);
36
+ (E > 1024 || !T.some((e) => e.instances.length) || typeof S.epochNow != "function" || typeof S.authorize != "function") && _();
37
+ let D = y(S.maxEntityRows, 1), O = y(S.maxInventoryBytes, 1);
38
+ (D > 1024 || O > 16777216) && _();
39
+ let k = S.epochNow.bind(S), A = S.authorize.bind(S), j = () => {
40
+ let e = k();
41
+ return Number.isSafeInteger(e) && e >= 0 ? e : _();
42
+ }, M = async (e, t) => {
43
+ let n = A(e, Object.freeze({
44
+ tenantId: w,
45
+ ...t ? { instanceId: t } : {}
46
+ }));
47
+ if (!g.isEffect(n)) return _();
48
+ await g.runPromise(n);
49
+ };
50
+ return Object.freeze({
51
+ scan: (n) => {
52
+ let r, i;
53
+ try {
54
+ if (!n || Object.getPrototypeOf(n) !== Object.prototype || Reflect.ownKeys(n).length !== 2 || ["afterId", "limit"].some((e) => {
55
+ let t = Object.getOwnPropertyDescriptor(n, e);
56
+ return !t?.enumerable || !("value" in t);
57
+ }) || (r = n.afterId === null ? null : v(n.afterId), i = y(n.limit, 1), i > E)) return _();
58
+ } catch {
59
+ return g.fail(new t({ detail: "Invalid bounded instance expiry cursor" }));
60
+ }
61
+ return g.tryPromise({
62
+ try: async () => {
63
+ await M("scan");
64
+ let t = j(), n = await x.query({
65
+ table: e,
66
+ predicate: d(f("tenantId", w), h("state", "retired"), m("expiresAt", new Date(t)), ...r ? [p("id", r)] : []),
67
+ order: [{
68
+ column: "id",
69
+ direction: "asc"
70
+ }],
71
+ take: i + 1,
72
+ skip: void 0,
73
+ projection: ["id", "roomId"]
74
+ }), a = n.slice(0, i), c = [], l = [];
75
+ for (let t of a) {
76
+ let n = v(t.id), r = v(t.roomId);
77
+ try {
78
+ await M("inspect", n);
79
+ let t = await x.transactional(async (t) => {
80
+ let i = (await o(t, [r], w)).get(r), a = await t.query({
81
+ table: e,
82
+ predicate: d(f("tenantId", w), f("id", n)),
83
+ order: [],
84
+ take: 2,
85
+ skip: void 0,
86
+ projection: void 0,
87
+ lock: "update"
88
+ }), c = a[0];
89
+ if (a.length !== 1 || !c || !i || c.roomId !== r) return _();
90
+ if (c.state === "retired" || b(c.expiresAt) > j()) return null;
91
+ let l = T.find((e) => e.name === c.worldId), u = l?.instances.find((e) => e.id === c.instance), p = c.state, m = y(c.epoch, 1), h = c.hostId === null ? null : v(c.hostId);
92
+ return !l || !u || u.room !== i.name || i.epoch !== m || ![
93
+ "creating",
94
+ "live",
95
+ "hibernated"
96
+ ].includes(String(p)) || i.hostId !== h || ![
97
+ "creating",
98
+ "live",
99
+ "hibernating",
100
+ "hibernated",
101
+ "disposed",
102
+ "faulted"
103
+ ].includes(String(i.state)) || b(c.expiresAt) - b(c.createdAt) !== u.ttlMs || typeof c.groupKey != "string" || !/^[a-f0-9]{64}$/.test(c.groupKey) ? _() : (await s(t, l, i, !1), Object.freeze({
104
+ id: n,
105
+ tenantId: w,
106
+ worldId: l.name,
107
+ instance: u.id,
108
+ groupKey: c.groupKey,
109
+ roomId: r,
110
+ epoch: m,
111
+ hostId: h,
112
+ revision: y(c.revision, 1),
113
+ expiresAt: b(c.expiresAt),
114
+ players: y(i.clients),
115
+ state: p,
116
+ roomState: String(i.state)
117
+ }));
118
+ });
119
+ t && c.push(t);
120
+ } catch {
121
+ l.push(n);
122
+ }
123
+ }
124
+ return Object.freeze({
125
+ entries: Object.freeze(c),
126
+ deferred: Object.freeze(l),
127
+ nextCursor: n.length > i ? v(a[a.length - 1].id) : null
128
+ });
129
+ },
130
+ catch: () => new t({ detail: "Instance expiry SQL inventory remains unavailable" })
131
+ });
132
+ },
133
+ inventory: (a) => {
134
+ let p;
135
+ try {
136
+ if (p = n(a, 4096), p.tenantId !== w || Object.keys(p).sort().join(",") !== "epoch,expiresAt,groupKey,hostId,id,instance,players,revision,roomId,roomState,state,tenantId,worldId") return _();
137
+ v(p.id), v(p.roomId);
138
+ } catch {
139
+ return g.fail(new t({ detail: "Invalid instance expiry inventory identity" }));
140
+ }
141
+ return g.tryPromise({
142
+ try: async () => (await M("inventory", p.id), x.transactional(async (t) => {
143
+ let a = (await o(t, [p.roomId], w)).get(p.roomId), m = await t.query({
144
+ table: e,
145
+ predicate: d(f("tenantId", w), f("id", p.id)),
146
+ order: [],
147
+ take: 2,
148
+ skip: void 0,
149
+ projection: void 0,
150
+ lock: "update"
151
+ }), h = m[0], g = T.find((e) => e.name === p.worldId), x = g?.instances.find((e) => e.id === p.instance);
152
+ if (m.length !== 1 || !h || !a || !g || !x || x.room !== a.name || h.roomId !== p.roomId || h.worldId !== g.name || h.instance !== x.id || h.groupKey !== p.groupKey || h.revision !== p.revision || h.epoch !== p.epoch || h.state !== p.state || h.hostId !== p.hostId || h.state === "retired" || a.epoch !== p.epoch || a.hostId !== p.hostId || a.state !== p.roomState || a.clients !== p.players || b(h.expiresAt) !== p.expiresAt || b(h.expiresAt) - b(h.createdAt) !== x.ttlMs || j() < p.expiresAt) return _();
153
+ await s(t, g, a, !1);
154
+ let S = await t.query({
155
+ table: l,
156
+ predicate: d(f("tenantId", w), f("roomId", p.roomId)),
157
+ order: [{
158
+ column: "entityId",
159
+ direction: "asc"
160
+ }],
161
+ take: D + 1,
162
+ skip: void 0,
163
+ projection: [
164
+ "tenantId",
165
+ "entityId",
166
+ "subjectId",
167
+ "subjectKind",
168
+ "worldId",
169
+ "roomId",
170
+ "epoch",
171
+ "revision",
172
+ "activeTransitionId",
173
+ "returnAnchor"
174
+ ],
175
+ lock: "update"
176
+ });
177
+ if (S.length > D) return _();
178
+ let C = [], E = [];
179
+ for (let e of S) {
180
+ let t = v(e.entityId), n = y(e.revision, 1);
181
+ if (e.tenantId !== w || e.worldId !== g.name || e.roomId !== p.roomId || e.epoch !== p.epoch) return _();
182
+ if (e.activeTransitionId != null) {
183
+ C.push({
184
+ entityId: t,
185
+ reason: "openTransition"
186
+ });
187
+ continue;
188
+ }
189
+ if (e.returnAnchor == null) {
190
+ C.push({
191
+ entityId: t,
192
+ reason: "missingAnchor"
193
+ });
194
+ continue;
195
+ }
196
+ if (e.subjectId === null || !["user", "guest"].includes(String(e.subjectKind))) {
197
+ C.push({
198
+ entityId: t,
199
+ reason: "missingSubject"
200
+ });
201
+ continue;
202
+ }
203
+ let r = c(e.returnAnchor, T);
204
+ if (r.instanceId !== p.id || r.instance !== p.instance || r.instanceRoomId !== p.roomId || r.groupKey !== p.groupKey || r.enteredRevision > n || r.source.worldId !== g.name) return _();
205
+ E.push({
206
+ entityId: t,
207
+ revision: n,
208
+ anchor: r,
209
+ subject: Object.freeze({
210
+ id: v(e.subjectId),
211
+ kind: e.subjectKind
212
+ })
213
+ });
214
+ }
215
+ let k = null, A = [];
216
+ for (let e of E.sort((e, t) => e.anchor.entryTransitionId < t.anchor.entryTransitionId ? -1 : +(e.anchor.entryTransitionId > t.anchor.entryTransitionId))) {
217
+ let a = await t.query({
218
+ table: i,
219
+ predicate: d(f("tenantId", w), f("id", e.anchor.entryTransitionId)),
220
+ order: [],
221
+ take: 2,
222
+ skip: void 0,
223
+ projection: [
224
+ "id",
225
+ "tenantId",
226
+ "entityId",
227
+ "subjectId",
228
+ "subjectKind",
229
+ "sourceRoomId",
230
+ "requestId",
231
+ "phase",
232
+ "mode",
233
+ "source",
234
+ "target",
235
+ "intent",
236
+ "result",
237
+ "entityRevision"
238
+ ],
239
+ lock: "update"
240
+ }), o = a[0];
241
+ if (a.length !== 1 || !o || o.entityId !== e.entityId || o.subjectId !== e.subject.id || o.subjectKind !== e.subject.kind || o.mode !== "portal" || !["committed", "settled"].includes(String(o.phase)) || o.entityRevision !== e.anchor.enteredRevision || o.sourceRoomId !== e.anchor.source.roomId) return _();
242
+ let s = r(o.intent);
243
+ if (s.entityId !== e.entityId || s.target.kind !== "instance" || s.options.returnTo !== "here" || s.target.instance !== x.id || u({
244
+ tenantId: w,
245
+ worldId: g.name,
246
+ instance: x.id,
247
+ groupId: s.target.group
248
+ }) !== p.groupKey || k !== null && k !== s.target.group) return _();
249
+ k = s.target.group;
250
+ let l = n(o.result, O), m = n(o.target, 4096);
251
+ if (m.worldId !== g.name || m.roomId !== p.roomId || y(m.epoch, 1) > p.epoch || l.epoch !== m.epoch || l.revision !== e.anchor.enteredRevision) return _();
252
+ let h = c(l.returnAnchor, T), v = c({
253
+ ...h,
254
+ source: o.source
255
+ }, T).source;
256
+ if (l.tenantId !== w || l.entityId !== e.entityId || l.roomId !== p.roomId || l.subject?.id !== e.subject.id || l.subject?.kind !== e.subject.kind || JSON.stringify(h) !== JSON.stringify(e.anchor) || JSON.stringify(v) !== JSON.stringify(h.source)) return _();
257
+ let b = o.requestId;
258
+ if (typeof b != "string" || b.length > 384 || !/^[A-Za-z0-9][A-Za-z0-9_.:-]*$/.test(b)) return _();
259
+ A.push(Object.freeze({
260
+ ...e,
261
+ entryOrigin: Object.freeze({
262
+ tenantId: w,
263
+ roomId: h.source.roomId,
264
+ requestId: b
265
+ })
266
+ }));
267
+ }
268
+ let M = Object.freeze({
269
+ instance: Object.freeze(p),
270
+ groupId: k,
271
+ members: Object.freeze(A.sort((e, t) => e.entityId < t.entityId ? -1 : +(e.entityId > t.entityId))),
272
+ blocked: Object.freeze(C.map((e) => Object.freeze(e)))
273
+ });
274
+ return n(M, O), M;
275
+ })),
276
+ catch: () => new t({ detail: "Instance expiry entity inventory remains incomplete" })
277
+ });
278
+ }
279
+ });
280
+ };
281
+ //#endregion
282
+ export { x as dataStoreWorldInstanceExpiry };