@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,277 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { simulationOwnData as t } from "./simulationAuthoring.js";
3
+ import { captureWorldCatalog as n } from "./world.js";
4
+ import { captureRoomPoolCatalog as r, roomPoolHostedNames as i } from "./roomPoolTopology.js";
5
+ import { captureRoomHostDrainPolicy as a } from "./hostDrain.js";
6
+ import { frameworkStartCause as o } from "./startFailureCause.js";
7
+ import { RoomHostLane as s, RoomHostLaneStartFailure as c } from "./hostLane.js";
8
+ import { assertRoomHostListenerDeployment as l } from "./hostListenerBinding.js";
9
+ import { captureRoomHostShutdownPolicy as u, superviseRoomHostDrain as d } from "./hostShutdown.js";
10
+ import { captureRoomHostDeployment as f } from "./hostDeployment.js";
11
+ import { validateWorldRooms as p } from "./worldCatalog.js";
12
+ import { performance as m } from "node:perf_hooks";
13
+ //#region src/hostBinding.ts
14
+ var h = (n) => {
15
+ let r = t(n, ["pool", "region"], []), i = {};
16
+ for (let t of ["pool", "region"]) {
17
+ if (!Object.hasOwn(r, t)) continue;
18
+ let n = r[t];
19
+ if (typeof n != "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,95}$/.test(n) || [
20
+ "__proto__",
21
+ "prototype",
22
+ "constructor"
23
+ ].includes(n)) throw new e({ detail: "Room host selection requires bounded pool and region identifiers" });
24
+ i[t] = n;
25
+ }
26
+ return Object.freeze(i);
27
+ }, g = class extends Error {
28
+ retryCleanup;
29
+ name = "RoomsHostBindFailure";
30
+ constructor(e) {
31
+ super("Room host provider cleanup remains incomplete"), this.retryCleanup = e;
32
+ }
33
+ }, _ = class extends Error {
34
+ stage;
35
+ retryCleanup;
36
+ name = "RoomsHostStartFailure";
37
+ constructor(e, t, n) {
38
+ super(`Room host startup failed during ${e}; cleanup remains owned`, o(n) === void 0 ? void 0 : { cause: n }), this.stage = e, this.retryCleanup = t;
39
+ }
40
+ }, v = class extends Error {
41
+ retryCleanup;
42
+ name = "RoomsHostStopFailure";
43
+ constructor(e) {
44
+ super("Room host cleanup remains incomplete"), this.retryCleanup = e;
45
+ }
46
+ }, y = class {
47
+ pluginName;
48
+ binder;
49
+ phase = "idle";
50
+ abort = new AbortController();
51
+ acquisition = null;
52
+ closing = null;
53
+ lane = null;
54
+ laneClosing = null;
55
+ control = null;
56
+ partialLane = null;
57
+ partialControl = null;
58
+ release = null;
59
+ failed = !1;
60
+ plannedDrain = null;
61
+ shutdownPolicy = null;
62
+ shutdownDeadline = null;
63
+ stopping = null;
64
+ worldState;
65
+ constructor(t, n, r = {}) {
66
+ if (this.pluginName = t, this.binder = n, !t.trim() || typeof n != "function") throw new e({ detail: "Room host requires an explicit complete provider" });
67
+ let i = r.worldState ?? "none";
68
+ if (![
69
+ "none",
70
+ "entities",
71
+ "transitions"
72
+ ].includes(i)) throw new e({ detail: "Room host World state must be none, entities or transitions" });
73
+ this.worldState = i;
74
+ }
75
+ get status() {
76
+ return this.phase;
77
+ }
78
+ get signal() {
79
+ return this.abort.signal;
80
+ }
81
+ get hasRuntimeFailure() {
82
+ return this.failed;
83
+ }
84
+ start(t, a, o = [], d = {}, m, v) {
85
+ if (this.phase !== "idle") return Promise.reject(new e({ detail: "Room host owner is single-use" }));
86
+ let y, b;
87
+ try {
88
+ if (y = h(d), b = m === void 0 ? void 0 : r(m, a.inventory().map((e) => e.descriptor.name)), b) {
89
+ let t = y.pool ?? b.default, n = b.pools[t];
90
+ if (!n || y.region !== void 0 && !n.regions.includes(y.region)) throw new e({ detail: "Room host selection is outside the app pool topology" });
91
+ y = Object.freeze({
92
+ ...y,
93
+ pool: t
94
+ });
95
+ }
96
+ } catch (e) {
97
+ return Promise.reject(e);
98
+ }
99
+ let x, S;
100
+ try {
101
+ x = n(o), S = p(x, a);
102
+ } catch {
103
+ return Promise.reject(new e({ detail: "World catalogue does not match the admitted Room inventory" }));
104
+ }
105
+ let C = new Set(i(b, b === void 0 ? void 0 : y.pool, a.inventory().map((e) => e.descriptor.name))), w = Object.freeze(a.inventory().filter((e) => C.has(e.descriptor.name))), T = Object.freeze(x.filter((e) => S.some((t) => t.worldId === e.name && C.has(t.room))));
106
+ if (this.phase = "starting", v !== void 0 && typeof v != "function") return Promise.reject(new e({ detail: "Room host app dependencies must be a function" }));
107
+ let E = Object.freeze({
108
+ root: t,
109
+ pluginName: this.pluginName,
110
+ catalog: a,
111
+ hostedRooms: w,
112
+ hostedWorlds: T,
113
+ worlds: x,
114
+ worldRooms: S,
115
+ worldState: this.worldState,
116
+ selection: y,
117
+ pools: b,
118
+ signal: this.abort.signal,
119
+ ...v === void 0 ? {} : { appDependencies: v }
120
+ }), D = Object.freeze({
121
+ VOLTRO_ROOMS_HOST_DEPLOYMENT: process.env.VOLTRO_ROOMS_HOST_DEPLOYMENT,
122
+ VOLTRO_ROOMS_HOST_METRICS_TOKEN: process.env.VOLTRO_ROOMS_HOST_METRICS_TOKEN,
123
+ VOLTRO_ROOMS_HOST_METRICS_TOKEN_PREVIOUS: process.env.VOLTRO_ROOMS_HOST_METRICS_TOKEN_PREVIOUS,
124
+ VOLTRO_ROOMS_HOST_POD_NAME: process.env.VOLTRO_ROOMS_HOST_POD_NAME
125
+ }), O = (async () => {
126
+ let t = "provider";
127
+ try {
128
+ let n = await this.binder(E);
129
+ if (typeof n?.release != "function") throw new e({ detail: "Room host provider must return its owned release operation" });
130
+ if (this.release = n.release.bind(n), this.shutdownPolicy = n.shutdown === void 0 ? null : u(n.shutdown), !n.store || !n.options || typeof n.openControl != "function") throw new e({ detail: "Room host provider must supply SQL, host configuration and control transport" });
131
+ if (b !== void 0 && n.options.host.pools !== b) throw new e({ detail: "Room host provider did not retain the app pool topology" });
132
+ if (y.pool !== void 0 && n.options.host.pool !== y.pool || y.region !== void 0 && n.options.host.region !== y.region) throw new e({ detail: "Room host provider did not honor the process pool and region selection" });
133
+ let r = f(D, n.options.host.pool, n.options.host.region);
134
+ if (r) {
135
+ if (r.shutdown && (!this.shutdownPolicy || this.shutdownPolicy.drainMs > r.shutdown.drainMs)) throw new e({ detail: "Room host shutdown policy exceeds or is missing from its deployment drain budget" });
136
+ if (l(n.options.listener, r), r.publicAddress !== void 0 && n.options.host.address !== r.publicAddress) throw new e({ detail: "Room host provider did not apply its deployment public address" });
137
+ }
138
+ let i = n.openControl.bind(n);
139
+ this.requireAcquiring(), t = "lane";
140
+ let o = n.options.driver.onFailure.bind(n.options.driver);
141
+ this.lane = await s.start(n.store, a, {
142
+ ...n.options,
143
+ processRole: "rooms",
144
+ startSuspended: !0,
145
+ host: {
146
+ ...n.options.host,
147
+ worlds: T
148
+ },
149
+ driver: {
150
+ ...n.options.driver,
151
+ onFailure: (t) => {
152
+ this.failed = !0, this.abort.abort(), this.close().catch(() => void 0);
153
+ let n = o(t);
154
+ if (n !== void 0) throw n instanceof Promise && n.catch(() => void 0), new e({ detail: "Room host failure observer must return synchronous void" });
155
+ }
156
+ }
157
+ }), this.requireAcquiring(), t = "control";
158
+ let c = await i(this.lane, E);
159
+ if (typeof c?.close != "function") throw new e({ detail: "Room control provider must return its owned cleanup" });
160
+ if (this.control = {
161
+ fence: typeof c.fence == "function" ? c.fence.bind(c) : () => {
162
+ throw new e({ detail: "Room control provider has no admission fence" });
163
+ },
164
+ close: c.close.bind(c)
165
+ }, typeof c.fence != "function") throw new e({ detail: "Room control provider must return a synchronous fence" });
166
+ return this.requireAcquiring(), t = "activation", await this.lane.activate(), this.requireAcquiring(), this.phase = "running", this.lane;
167
+ } catch (e) {
168
+ this.phase = "closing", this.abort.abort(), e instanceof c && !this.lane && (this.partialLane = e.retryCleanup), e instanceof g && (t === "control" ? this.partialControl = e.retryCleanup : this.release = e.retryCleanup);
169
+ try {
170
+ await this.releaseResources();
171
+ } catch {}
172
+ throw new _(t, () => this.close(), e);
173
+ }
174
+ })();
175
+ return this.acquisition = O, O.then(() => {
176
+ this.acquisition = null;
177
+ }, () => {
178
+ this.acquisition = null;
179
+ }), O;
180
+ }
181
+ requireAcquiring() {
182
+ if (this.abort.signal.aborted || this.phase !== "starting") throw new e({ detail: "Room host acquisition was cancelled" });
183
+ }
184
+ fenceLane() {
185
+ if (this.laneClosing) return this.laneClosing;
186
+ if (!this.lane) return Promise.resolve();
187
+ try {
188
+ this.laneClosing = this.plannedDrain ? this.lane.drain(this.plannedDrain) : this.lane.close();
189
+ } catch (e) {
190
+ this.laneClosing = Promise.reject(e);
191
+ }
192
+ return this.laneClosing.catch(() => void 0), this.laneClosing;
193
+ }
194
+ async releaseResources() {
195
+ let t = [];
196
+ if (this.control) try {
197
+ this.control.fence();
198
+ } catch (e) {
199
+ t.push(e);
200
+ }
201
+ let n = this.lane, r = this.control, i = await Promise.allSettled([
202
+ n ? this.fenceLane().then(() => {
203
+ this.lane = null;
204
+ }).finally(() => {
205
+ this.laneClosing = null;
206
+ }) : Promise.resolve(),
207
+ r ? Promise.resolve().then(() => r.close()).then(() => {
208
+ this.control = null;
209
+ }) : Promise.resolve(),
210
+ this.partialLane ? Promise.resolve().then(() => this.partialLane()).then(() => {
211
+ this.partialLane = null;
212
+ }) : Promise.resolve(),
213
+ this.partialControl ? Promise.resolve().then(() => this.partialControl()).then(() => {
214
+ this.partialControl = null;
215
+ }) : Promise.resolve()
216
+ ]);
217
+ for (let e of i) e.status === "rejected" && t.push(e.reason);
218
+ if (t.length > 0) throw new e({ detail: "Room host lane or control cleanup remains incomplete" });
219
+ this.release &&= (await this.release(), null), this.phase = "closed";
220
+ }
221
+ stop() {
222
+ if (this.phase === "closed") return Promise.resolve();
223
+ if (this.stopping) return this.stopping;
224
+ if (!this.shutdownPolicy || !this.plannedDrain && (this.phase !== "running" || this.failed)) return this.close();
225
+ let e = this.plannedDrain ?? this.shutdownPolicy;
226
+ this.shutdownDeadline ??= m.now() + this.shutdownPolicy.drainMs;
227
+ let t = Promise.withResolvers();
228
+ return this.stopping = t.promise, d(() => this.drain({
229
+ graceMs: e.graceMs,
230
+ maxCheckpointBytes: e.maxCheckpointBytes
231
+ }), this.shutdownDeadline, () => this.close()).then(t.resolve, t.reject), t.promise.then(() => {
232
+ this.stopping = null;
233
+ }, () => {
234
+ this.stopping = null;
235
+ }), t.promise;
236
+ }
237
+ drain(t) {
238
+ try {
239
+ let n = a(t);
240
+ if (this.plannedDrain) {
241
+ if (n.graceMs !== this.plannedDrain.graceMs || n.maxCheckpointBytes !== this.plannedDrain.maxCheckpointBytes) throw new e({ detail: "Room host owner drain retry cannot change its retained policy" });
242
+ } else {
243
+ if (this.phase !== "running" || !this.lane?.controller.host.membership || this.failed) throw new e({ detail: "Planned owner drain requires a running registered process" });
244
+ this.plannedDrain = n;
245
+ }
246
+ return this.close();
247
+ } catch (e) {
248
+ return Promise.reject(e);
249
+ }
250
+ }
251
+ close() {
252
+ if (this.phase === "closed") return Promise.resolve();
253
+ if (this.closing) return this.closing;
254
+ this.phase = "closing", this.abort.abort();
255
+ try {
256
+ this.control?.fence();
257
+ } catch {}
258
+ this.lane && this.fenceLane().catch(() => void 0);
259
+ let e = (async () => {
260
+ try {
261
+ await this.acquisition;
262
+ } catch {}
263
+ try {
264
+ await this.releaseResources();
265
+ } catch {
266
+ throw new v(() => this.close());
267
+ }
268
+ })();
269
+ return this.closing = e, e.then(() => {
270
+ this.closing = null;
271
+ }, () => {
272
+ this.closing = null;
273
+ }), e;
274
+ }
275
+ };
276
+ //#endregion
277
+ export { g as RoomsHostBindFailure, y as RoomsHostOwner, _ as RoomsHostStartFailure, v as RoomsHostStopFailure };
@@ -0,0 +1,114 @@
1
+ import { ROOMS_TABLE as e } from "./identities.js";
2
+ import { captureWorldCatalog as t } from "./world.js";
3
+ import { WORLD_CELLS_TABLE as n } from "./worldCells.js";
4
+ import { and as r, eq as i } from "@voltro/database";
5
+ import { performance as a } from "node:perf_hooks";
6
+ //#region src/hostCellObservation.ts
7
+ var o = class {
8
+ hostId;
9
+ capacity;
10
+ now;
11
+ worlds;
12
+ observed = null;
13
+ next = 0;
14
+ last = 0;
15
+ invalidClock = !1;
16
+ constructor(e, n, r, i = () => a.now()) {
17
+ this.hostId = n, this.capacity = r, this.now = i, this.worlds = e === void 0 ? void 0 : t(e);
18
+ }
19
+ time() {
20
+ try {
21
+ let e = this.now();
22
+ return (!Number.isFinite(e) || e < this.last) && (this.invalidClock = !0), this.invalidClock ? null : (this.last = e, e);
23
+ } catch {
24
+ return this.invalidClock = !0, null;
25
+ }
26
+ }
27
+ identity(e) {
28
+ return JSON.stringify(e.map((e) => [
29
+ e.roomId,
30
+ e.tenantId,
31
+ e.epoch,
32
+ e.name,
33
+ e.published
34
+ ]).sort((e, t) => String(e[0]).localeCompare(String(t[0]))));
35
+ }
36
+ snapshot(e) {
37
+ let t = this.time(), n = this.observed;
38
+ return t !== null && n !== null && t - n.at < 5e3 && n.owners === this.identity(e) ? n.count : null;
39
+ }
40
+ async refresh(t, a) {
41
+ let o = this.time(), s = this.identity(a);
42
+ if (o === null || this.worlds === void 0) this.observed = null;
43
+ else if (!(o < this.next)) {
44
+ this.next = o + 1e3, this.observed = null;
45
+ try {
46
+ let c = this.worlds, l = new Map(a.map((e) => [e.roomId, e]));
47
+ if (l.size !== a.length || a.length > this.capacity) return;
48
+ let u = c.length === 0 ? 0 : await t.transactional(async (t) => {
49
+ let o = await t.query({
50
+ table: n,
51
+ predicate: i("hostId", this.hostId),
52
+ order: [{
53
+ column: "id",
54
+ direction: "asc"
55
+ }],
56
+ take: this.capacity + 1,
57
+ skip: void 0,
58
+ projection: [
59
+ "tenantId",
60
+ "worldId",
61
+ "zoneId",
62
+ "cellId",
63
+ "layer",
64
+ "roomId",
65
+ "hostId",
66
+ "epoch",
67
+ "state"
68
+ ]
69
+ });
70
+ if (o.length > this.capacity) return null;
71
+ let s = await t.query({
72
+ table: e,
73
+ predicate: r(i("hostId", this.hostId), i("state", "live")),
74
+ order: [{
75
+ column: "id",
76
+ direction: "asc"
77
+ }],
78
+ take: this.capacity + 1,
79
+ skip: void 0,
80
+ projection: [
81
+ "id",
82
+ "tenantId",
83
+ "hostId",
84
+ "epoch",
85
+ "name",
86
+ "state"
87
+ ]
88
+ });
89
+ if (s.length > this.capacity) return null;
90
+ let u = new Map(s.map((e) => [e.id, e]));
91
+ if (u.size !== s.length) return null;
92
+ let d = /* @__PURE__ */ new Set();
93
+ for (let e of o) {
94
+ let t = typeof e.roomId == "string" ? l.get(e.roomId) : void 0, n = c.find((t) => t.name === e.worldId);
95
+ if (!t?.published || !n || e.hostId !== this.hostId || e.state !== "live" || e.tenantId !== t.tenantId || e.epoch !== t.epoch || !n.zones.some((n) => n.id === e.zoneId && n.room === t.name) || typeof e.cellId != "string" || !e.cellId || !Number.isSafeInteger(e.layer) || Number(e.layer) < 1 || d.has(t.roomId)) return null;
96
+ d.add(t.roomId);
97
+ let r = u.get(t.roomId);
98
+ if (!r || r.tenantId !== t.tenantId || r.hostId !== this.hostId || r.epoch !== t.epoch || r.name !== t.name || r.state !== "live") return null;
99
+ }
100
+ return a.some((e) => c.some((t) => t.zones.some((t) => t.room === e.name)) && !d.has(e.roomId)) ? null : o.length;
101
+ });
102
+ u !== null && (this.observed = {
103
+ count: u,
104
+ at: o,
105
+ owners: s
106
+ });
107
+ } catch {
108
+ this.observed = null;
109
+ }
110
+ }
111
+ }
112
+ };
113
+ //#endregion
114
+ export { o as RoomHostCellObservation };
@@ -0,0 +1,90 @@
1
+ import { ProtocolError as e, RoomFull as t, RoomGone as n } from "./errors.js";
2
+ import { ROOMS_TABLE as r, ROOM_HOSTS_TABLE as i } from "./identities.js";
3
+ import { and as a, eq as o, or as s } from "@voltro/database";
4
+ //#region src/hostClientCapacity.ts
5
+ function c() {
6
+ throw new e({ detail: "Host client capacity authority is inconsistent or exceeds its scan budget" });
7
+ }
8
+ var l = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : c(), u = async (e, t, s) => {
9
+ let l = [...new Set(t)].sort(), u = /* @__PURE__ */ new Map();
10
+ for (let t of l) {
11
+ let i = (await e.query({
12
+ table: r,
13
+ predicate: a(o("id", t), o("tenantId", s)),
14
+ order: [],
15
+ take: 1,
16
+ skip: void 0,
17
+ projection: ["hostId"]
18
+ }))[0];
19
+ if (!i) throw new n({ roomId: t });
20
+ let l = i.hostId;
21
+ if (l !== null && (typeof l != "string" || !l)) return c();
22
+ u.set(t, l);
23
+ }
24
+ for (let t of [...new Set([...u.values()].filter((e) => e !== null))].sort()) await e.query({
25
+ table: i,
26
+ predicate: o("id", t),
27
+ order: [],
28
+ take: 1,
29
+ skip: void 0,
30
+ projection: ["id"],
31
+ lock: "update"
32
+ });
33
+ let d = /* @__PURE__ */ new Map();
34
+ for (let t of l) {
35
+ let i = (await e.query({
36
+ table: r,
37
+ predicate: a(o("id", t), o("tenantId", s)),
38
+ order: [],
39
+ take: 1,
40
+ skip: void 0,
41
+ projection: void 0,
42
+ lock: "update"
43
+ }))[0];
44
+ if (!i || i.hostId !== u.get(t)) throw new n({ roomId: t });
45
+ d.set(t, i);
46
+ }
47
+ return d;
48
+ }, d = async (e, u, d, f) => {
49
+ if (l(d), !Number.isSafeInteger(f) || f < 1 || f >= 2 ** 53 - 1) return c();
50
+ let p = (await e.query({
51
+ table: i,
52
+ predicate: o("id", u),
53
+ order: [],
54
+ take: 1,
55
+ skip: void 0,
56
+ projection: [
57
+ "pool",
58
+ "clientCapacity",
59
+ "capacity"
60
+ ],
61
+ lock: "update"
62
+ }))[0];
63
+ if (!p) throw new n({ roomId: "host" });
64
+ if (p.pool == null && p.clientCapacity == null) return;
65
+ if (typeof p.pool != "string" || !p.pool) return c();
66
+ let m = l(p.clientCapacity), h = l(p.capacity);
67
+ if (m < 1 || h < 1 || h > f) return c();
68
+ let g = await e.query({
69
+ table: r,
70
+ predicate: a(o("hostId", u), s(o("state", "live"), o("state", "creating"), o("state", "hibernating"))),
71
+ order: [{
72
+ column: "id",
73
+ direction: "asc"
74
+ }],
75
+ take: h + 1,
76
+ skip: void 0,
77
+ projection: ["clients"],
78
+ lock: "update"
79
+ });
80
+ if (g.length > h) return c();
81
+ let _ = m;
82
+ for (let e of g) {
83
+ let n = l(e.clients);
84
+ if (n > _) throw new t({ roomId: "host" });
85
+ _ -= n;
86
+ }
87
+ if (d > _) throw new t({ roomId: "host" });
88
+ };
89
+ //#endregion
90
+ export { d as assertHostClientCapacity, u as lockRoomReservationOwners };
@@ -0,0 +1,64 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { AsyncLocalStorage as t } from "node:async_hooks";
3
+ //#region src/hostCommandScope.ts
4
+ var n = new t(), r = (e) => {
5
+ for (let t = n.getStore(); t; t = t.parent) if (t.owner === e) return !0;
6
+ return !1;
7
+ }, i = () => n.getStore() !== void 0, a = (e, t) => {
8
+ let n = Promise.resolve().then(t);
9
+ return e.pending = n, n.then(() => {
10
+ e.pending === n && (e.pending = null);
11
+ }, (t) => {
12
+ e.failed = !0, e.failure = t, e.pending === n && (e.pending = null);
13
+ }), n;
14
+ }, o = (t, i, o) => {
15
+ let s = n.getStore();
16
+ if (!s) return o();
17
+ if (r(t) || !s.active || s.pending || i) return Promise.reject(new e({ detail: "Host command cannot wait on an occupied, ancestral or expired control lane" }));
18
+ let c;
19
+ try {
20
+ c = o();
21
+ } catch (e) {
22
+ c = Promise.reject(e);
23
+ }
24
+ return a(s, () => c);
25
+ }, s = (t, i) => {
26
+ let o = n.getStore();
27
+ if (o) return o.owner === t ? !o.active || o.pending ? Promise.reject(new e({ detail: "Host command operation scope is expired or already occupied" })) : a(o, () => o.dispatch ? o.dispatch(i) : i()) : r(t) ? Promise.reject(new e({ detail: "Host command cannot reenter an ancestral control lane" })) : void 0;
28
+ }, c = async (e, t, r, i) => {
29
+ let a = {
30
+ owner: e,
31
+ parent: r,
32
+ dispatch: i,
33
+ active: !0,
34
+ pending: null,
35
+ failure: void 0,
36
+ failed: !1
37
+ };
38
+ return n.run(a, async () => {
39
+ try {
40
+ let e = await t();
41
+ if (a.active = !1, a.pending && await a.pending, a.failed) throw a.failure;
42
+ return e;
43
+ } finally {
44
+ a.active = !1, a.pending && await a.pending;
45
+ }
46
+ });
47
+ }, l = async (t, i, a) => {
48
+ if (r(t)) throw new e({ detail: "Host command delivery cannot recursively deliver commands" });
49
+ return c(t, i, n.getStore(), a);
50
+ }, u = (t) => {
51
+ let r = !0, i = Promise.resolve();
52
+ return Object.freeze({
53
+ run: (a) => {
54
+ if (!r) return Promise.reject(new e({ detail: "Host command World operation window is closed" }));
55
+ let o = n.getStore(), s = i.then(() => c(t, a, o));
56
+ return i = s.then(() => void 0, () => void 0), s;
57
+ },
58
+ close: async () => {
59
+ r = !1, await i;
60
+ }
61
+ });
62
+ };
63
+ //#endregion
64
+ export { r as hasRoomHostCommandScope, i as insideRoomHostCommandScope, u as makeRoomHostCommandWindow, o as queueRoomHostCommandOperation, s as runRoomHostCommandOperation, l as withRoomHostCommandScope };