@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,497 @@
1
+ import { BudgetExceeded as e, ProtocolError as t, RoomAuthoringError as n, RoomGone as r, RoomPoolWaking as i } from "./errors.js";
2
+ import { captureOptionalRoomTransportDataMethod as a, captureRoomTransportDataMethod as o } from "./transportAuthoring.js";
3
+ import { RoomTransportCleanupFailure as s } from "./transportCleanup.js";
4
+ import { captureRoomTransportEndpoints as c } from "./transportEndpoints.js";
5
+ import { RoomInputRedundancy as l, defaultRoomInputRedundancy as u } from "./inputRedundancy.js";
6
+ import { RoomSession as d, defaultRoomClockSampling as f } from "./web.js";
7
+ //#region src/connection.ts
8
+ var p = (e) => e < 3e3 ? 200 : 1e3, m = (e) => {
9
+ if (!Number.isSafeInteger(e.attempt) || e.attempt < 0 || !Number.isFinite(e.initialBackoffMs) || e.initialBackoffMs <= 0 || !Number.isFinite(e.maxBackoffMs) || e.maxBackoffMs < e.initialBackoffMs || !Number.isFinite(e.remainingMs) || e.remainingMs <= 0 || !Number.isFinite(e.random) || e.random < 0 || e.random >= 1) throw new n({
10
+ room: "client",
11
+ detail: "Reconnect policy input is invalid"
12
+ });
13
+ let t = Math.min(e.maxBackoffMs, e.initialBackoffMs * 2 ** Math.min(e.attempt, 53));
14
+ return Math.min(e.remainingMs, t * (.5 + e.random * .5));
15
+ }, h = () => new t({ detail: "Room connection was cancelled" }), g = (e, t) => new Promise((n, r) => {
16
+ let i = () => {
17
+ t.removeEventListener("abort", i), r(h());
18
+ };
19
+ t.aborted ? (e.catch(() => void 0), i()) : (t.addEventListener("abort", i, { once: !0 }), e.then((e) => {
20
+ t.removeEventListener("abort", i), t.aborted || n(e);
21
+ }, (e) => {
22
+ t.removeEventListener("abort", i), r(e);
23
+ }));
24
+ }), _ = (e, t) => new Promise((n, r) => {
25
+ if (t.aborted) {
26
+ r(h());
27
+ return;
28
+ }
29
+ let i = () => {
30
+ clearTimeout(a), t.removeEventListener("abort", i), r(h());
31
+ }, a = setTimeout(() => {
32
+ t.removeEventListener("abort", i), n();
33
+ }, e);
34
+ t.addEventListener("abort", i, { once: !0 });
35
+ }), v = /* @__PURE__ */ new WeakMap(), y = class {
36
+ manifest;
37
+ clock;
38
+ reservations;
39
+ connect;
40
+ controller = new AbortController();
41
+ listeners = /* @__PURE__ */ new Set();
42
+ buffered = [];
43
+ pendingInputs = /* @__PURE__ */ new Map();
44
+ options;
45
+ session = null;
46
+ handoffDetach = null;
47
+ handoffListeners = /* @__PURE__ */ new Set();
48
+ sessionDetach = null;
49
+ currentState = null;
50
+ currentStatus = "reserving";
51
+ currentError = null;
52
+ reconnectTask = null;
53
+ startTask = null;
54
+ started = !1;
55
+ leaving = !1;
56
+ lastSessionId = null;
57
+ lastTick = -1;
58
+ nextSeq = 0;
59
+ appliedSeq = -1;
60
+ clockTimer = null;
61
+ messageListeners = /* @__PURE__ */ new Map();
62
+ messageDetach = /* @__PURE__ */ new Map();
63
+ reservation = null;
64
+ cleanupTasks = /* @__PURE__ */ new Set();
65
+ cleanupFailures = [];
66
+ pendingReservationCalls = 0;
67
+ pendingTransportCalls = 0;
68
+ transportOwners = /* @__PURE__ */ new Map();
69
+ transportLifetimes = /* @__PURE__ */ new WeakMap();
70
+ withdrawalAttempted;
71
+ leaveTask = null;
72
+ left = !1;
73
+ constructor(e, t, r, i, a) {
74
+ this.manifest = e, this.clock = t, this.reservations = r, this.connect = i;
75
+ let o = a.inputRedundancy ?? u;
76
+ new l(o), this.options = {
77
+ graceMs: a.graceMs,
78
+ maxBufferedInputs: a.maxBufferedInputs ?? 128,
79
+ maxPendingInputs: a.maxPendingInputs ?? 256,
80
+ initialBackoffMs: a.initialBackoffMs ?? 250,
81
+ maxBackoffMs: a.maxBackoffMs ?? 8e3,
82
+ connectTimeoutMs: a.connectTimeoutMs ?? 5e3,
83
+ random: a.random ?? Math.random,
84
+ sleep: a.sleep ?? _,
85
+ reconnectPolicy: a.reconnectPolicy ?? m,
86
+ clockSampling: a.clockSampling ?? f,
87
+ inputRedundancy: Object.freeze({ ...o }),
88
+ clockPingCadence: a.clockPingCadence ?? p,
89
+ maxPendingReservationCalls: a.maxPendingReservationCalls ?? 4,
90
+ maxCleanupFailures: a.maxCleanupFailures ?? 32,
91
+ maxPendingTransportCalls: a.maxPendingTransportCalls ?? 4,
92
+ wakeTimeoutMs: a.wakeTimeoutMs ?? 18e4
93
+ };
94
+ for (let e of [
95
+ this.options.graceMs,
96
+ this.options.initialBackoffMs,
97
+ this.options.maxBackoffMs,
98
+ this.options.connectTimeoutMs,
99
+ this.options.wakeTimeoutMs
100
+ ]) if (!Number.isFinite(e) || e <= 0) throw new n({
101
+ room: "client",
102
+ detail: "Reconnect durations must be positive"
103
+ });
104
+ if (!Number.isSafeInteger(this.options.maxBufferedInputs) || this.options.maxBufferedInputs < 1 || !Number.isSafeInteger(this.options.maxPendingInputs) || this.options.maxPendingInputs < 1 || !Number.isSafeInteger(this.options.maxPendingReservationCalls) || this.options.maxPendingReservationCalls < 1 || !Number.isSafeInteger(this.options.maxCleanupFailures) || this.options.maxCleanupFailures < 1 || !Number.isSafeInteger(this.options.maxPendingTransportCalls) || this.options.maxPendingTransportCalls < 1 || this.options.maxBackoffMs < this.options.initialBackoffMs) throw new n({
105
+ room: "client",
106
+ detail: "Reconnect buffer/backoff budget is invalid"
107
+ });
108
+ v.set(this, () => this.captureGeometrySession());
109
+ }
110
+ captureGeometrySession() {
111
+ return this.currentStatus === "joined" && !this.leaving ? this.session : null;
112
+ }
113
+ get status() {
114
+ return this.currentStatus;
115
+ }
116
+ get error() {
117
+ return this.currentError;
118
+ }
119
+ get state() {
120
+ return this.currentState === null ? null : structuredClone(this.currentState);
121
+ }
122
+ get id() {
123
+ return this.lastSessionId;
124
+ }
125
+ get roomId() {
126
+ return this.reservation?.roomId ?? null;
127
+ }
128
+ get lastAppliedTick() {
129
+ return this.lastTick;
130
+ }
131
+ get lastAppliedInputSeq() {
132
+ return this.appliedSeq;
133
+ }
134
+ get reconciliationSnapshot() {
135
+ return this.session?.reconciliationSnapshot ?? null;
136
+ }
137
+ deliveredSnapshot() {
138
+ return this.currentStatus === "joined" ? this.session?.deliveredSnapshot() ?? null : null;
139
+ }
140
+ clockStats() {
141
+ return this.session?.clockSync.stats() ?? {
142
+ rttMs: null,
143
+ offsetMs: null
144
+ };
145
+ }
146
+ serverNow() {
147
+ return this.session?.clockSync.serverNow() ?? null;
148
+ }
149
+ get lossRate() {
150
+ return this.session?.lossRate ?? null;
151
+ }
152
+ subscribe(e) {
153
+ return this.listeners.add(e), () => {
154
+ this.listeners.delete(e);
155
+ };
156
+ }
157
+ notify() {
158
+ for (let e of this.listeners) e();
159
+ }
160
+ active() {
161
+ if (this.controller.signal.aborted || this.leaving) throw h();
162
+ }
163
+ start(e) {
164
+ return this.started ? Promise.reject(new t({ detail: "Room connection already started" })) : (this.started = !0, this.startTask = (async () => {
165
+ try {
166
+ let t = this.clock.now() + this.options.wakeTimeoutMs;
167
+ for (;;) try {
168
+ await this.attempt(this.clock.now() + this.options.connectTimeoutMs, async (t) => {
169
+ let n = await this.requestReservation(() => this.reservations.reserve(e, t), t);
170
+ await this.install(n, !1, t);
171
+ });
172
+ break;
173
+ } catch (e) {
174
+ if (!(e instanceof i) || this.clock.now() + e.retryAfterMs > t) throw e;
175
+ this.currentStatus = "waking", this.currentError = null, this.notify(), await this.options.sleep(e.retryAfterMs, this.controller.signal), this.active(), this.currentStatus = "reserving", this.notify();
176
+ }
177
+ } catch (e) {
178
+ throw this.leaving || this.terminal(e, e instanceof r ? "gone" : "left"), e;
179
+ }
180
+ })(), this.startTask);
181
+ }
182
+ async attempt(e, t) {
183
+ this.active();
184
+ let n = e - this.clock.now();
185
+ if (n <= 0) throw new r({ roomId: "" });
186
+ let i = new AbortController(), a = () => {
187
+ i.abort();
188
+ };
189
+ this.controller.signal.addEventListener("abort", a, { once: !0 });
190
+ let o = setTimeout(a, n);
191
+ try {
192
+ await t(i.signal);
193
+ } finally {
194
+ clearTimeout(o), this.controller.signal.removeEventListener("abort", a);
195
+ }
196
+ }
197
+ async install(n, r, i) {
198
+ let a = n.endpoints === void 0 ? void 0 : c(n.endpoints);
199
+ if (this.reservation = {
200
+ ...n,
201
+ token: Uint8Array.from(n.token),
202
+ ...a === void 0 ? {} : { endpoints: a }
203
+ }, this.active(), this.pendingTransportCalls >= this.options.maxPendingTransportCalls) throw new e({
204
+ budget: "pendingTransportCalls",
205
+ limit: this.options.maxPendingTransportCalls
206
+ });
207
+ if (this.transportOwners.size) throw new t({ detail: "Room transport withdrawal must complete before another acquisition" });
208
+ this.pendingTransportCalls++;
209
+ let o = Promise.resolve().then(() => this.connect(n.address, i, a)), l = o.then(async (e) => {
210
+ this.pendingTransportCalls--, (i.aborted || this.leaving) && await this.releaseTransport(e, "Late cancelled room connection");
211
+ }, (e) => {
212
+ this.pendingTransportCalls--, e instanceof s && this.transportOwners.set(e, e);
213
+ }).catch((e) => {
214
+ this.currentError = e, this.notify();
215
+ });
216
+ this.cleanupTasks.add(l), l.then(() => {
217
+ this.cleanupTasks.delete(l);
218
+ });
219
+ let u = await g(o, i);
220
+ if (i.aborted || this.controller.signal.aborted || this.leaving) throw await this.releaseTransport(u, "Cancelled room connection"), h();
221
+ try {
222
+ this.sessionDetach?.(), this.sessionDetach = null, this.handoffDetach?.(), this.handoffDetach = null, this.stopClockSampling();
223
+ for (let e of this.messageDetach.values()) e();
224
+ this.messageDetach.clear();
225
+ let e = new d(u, this.manifest, this.clock, 8, {
226
+ nextSeq: this.nextSeq,
227
+ lastAppliedSeq: this.appliedSeq
228
+ }, this.options.clockSampling, this.options.inputRedundancy);
229
+ this.session = e, this.handoffDetach = e.onWorldHandoff((t) => {
230
+ if (!(e !== this.session || this.leaving)) for (let e of this.handoffListeners) e(t);
231
+ });
232
+ for (let t of this.messageListeners.keys()) this.attachMessages(e, t);
233
+ if (this.currentStatus = r ? "reconnecting" : "connecting", this.notify(), this.sessionDetach = e.subscribe(() => {
234
+ if (e !== this.session || this.leaving) return;
235
+ let n = e.state;
236
+ n !== null && (this.currentState = n), e.id && (this.lastSessionId = e.id), this.lastTick = Math.max(this.lastTick, e.lastAppliedTick), this.appliedSeq = Math.max(this.appliedSeq, e.lastAppliedInputSeq);
237
+ for (let e of this.pendingInputs.keys()) e <= this.appliedSeq && this.pendingInputs.delete(e);
238
+ if (e.status === "reconnecting") this.beginReconnect();
239
+ else if (e.status === "kicked" || e.status === "gone" || e.status === "left") {
240
+ if (r) {
241
+ this.notify();
242
+ return;
243
+ }
244
+ this.terminal(e.error ?? new t({ detail: "Room session ended" }), e.status);
245
+ } else this.notify();
246
+ }), await g(e.start(n.token, r && this.lastTick >= 0 ? this.lastTick : void 0), i), await this.waitForJoin(e, i), e.id !== n.sessionId) throw new t({ detail: "Welcome does not match the reserved session" });
247
+ if (this.lastSessionId = n.sessionId, r) for (let [t, n] of [...this.pendingInputs]) t <= this.appliedSeq || await g(e.replay(t, n), i);
248
+ for (; this.buffered.length;) {
249
+ this.active();
250
+ let t = this.buffered.shift();
251
+ if (!t) break;
252
+ try {
253
+ t.resolve(await g(this.submit(e, t.input), i));
254
+ } catch (e) {
255
+ throw t.reject(e), e;
256
+ }
257
+ }
258
+ if (this.active(), e.status !== "joined") throw new t({ detail: "Room disconnected before buffered inputs were delivered" });
259
+ this.currentState = e.state, this.lastTick = e.lastAppliedTick, this.currentStatus = "joined", this.currentError = null, this.notify(), this.startClockSampling(e);
260
+ } catch (e) {
261
+ this.sessionDetach?.(), this.sessionDetach = null, this.handoffDetach?.(), this.handoffDetach = null;
262
+ try {
263
+ await this.releaseTransport(u, "Room connection attempt ended");
264
+ } catch (t) {
265
+ throw AggregateError([e, t], "Room connection attempt and transport withdrawal failed");
266
+ }
267
+ throw e;
268
+ }
269
+ }
270
+ waitForJoin(e, t) {
271
+ return new Promise((n, r) => {
272
+ let i, a = (e) => {
273
+ i?.(), t.removeEventListener("abort", o), e === void 0 ? n() : r(e);
274
+ }, o = () => a(h()), s = () => {
275
+ t.aborted ? o() : e.status === "joined" ? a() : [
276
+ "left",
277
+ "kicked",
278
+ "gone",
279
+ "reconnecting"
280
+ ].includes(e.status) && a(e.error ?? h());
281
+ };
282
+ i = e.subscribe(s), t.addEventListener("abort", o, { once: !0 }), s();
283
+ });
284
+ }
285
+ beginReconnect() {
286
+ if (this.stopClockSampling(), this.reconnectTask || this.leaving || this.controller.signal.aborted) return;
287
+ let e = this.lastSessionId;
288
+ if (!e) {
289
+ this.terminal(new r({ roomId: "" }), "gone");
290
+ return;
291
+ }
292
+ this.currentStatus = "reconnecting", this.notify();
293
+ let t = this.clock.now() + this.options.graceMs;
294
+ this.reconnectTask = (async () => {
295
+ let i = 0;
296
+ try {
297
+ for (;;) {
298
+ this.active();
299
+ let a = t - this.clock.now();
300
+ if (a <= 0) throw new r({ roomId: "" });
301
+ let o = this.options.random();
302
+ if (!Number.isFinite(o) || o < 0 || o >= 1) throw new n({
303
+ room: "client",
304
+ detail: "Reconnect jitter source must be in [0, 1)"
305
+ });
306
+ let s = this.options.reconnectPolicy({
307
+ attempt: i,
308
+ remainingMs: a,
309
+ random: o,
310
+ initialBackoffMs: this.options.initialBackoffMs,
311
+ maxBackoffMs: this.options.maxBackoffMs
312
+ });
313
+ if (!Number.isFinite(s) || s <= 0 || s > Math.min(this.options.maxBackoffMs, a)) throw new n({
314
+ room: "client",
315
+ detail: "Reconnect policy exceeded its duration budget"
316
+ });
317
+ if (await this.options.sleep(s, this.controller.signal), this.active(), this.clock.now() >= t) throw new r({ roomId: "" });
318
+ try {
319
+ this.session && await this.releaseTransport(this.session.transport, "Room reconnect replaces the withdrawn transport"), await this.attempt(Math.min(t, this.clock.now() + this.options.connectTimeoutMs), async (t) => {
320
+ let n = await this.requestReservation(() => this.reservations.resume(e, t), t);
321
+ await this.install(n, !0, t);
322
+ });
323
+ return;
324
+ } catch (e) {
325
+ if (e instanceof r || this.transportOwners.size) throw e;
326
+ this.active(), this.currentError = e, this.currentStatus = "reconnecting", this.notify();
327
+ }
328
+ if (!Number.isSafeInteger(++i)) throw new n({
329
+ room: "client",
330
+ detail: "Reconnect attempt counter exhausted"
331
+ });
332
+ }
333
+ } catch (e) {
334
+ this.leaving || this.terminal(e, e instanceof r ? "gone" : "left");
335
+ } finally {
336
+ this.reconnectTask = null;
337
+ }
338
+ })();
339
+ }
340
+ send(n) {
341
+ return this.currentStatus === "joined" && this.session ? this.submit(this.session, n) : this.currentStatus === "reconnecting" ? this.buffered.length >= this.options.maxBufferedInputs ? Promise.reject(new e({
342
+ budget: "reconnectInputs",
343
+ limit: this.options.maxBufferedInputs
344
+ })) : new Promise((e, t) => {
345
+ this.buffered.push({
346
+ input: structuredClone(n),
347
+ resolve: e,
348
+ reject: t
349
+ });
350
+ }) : Promise.reject(new t({ detail: "Inputs require a joined or reconnecting room" }));
351
+ }
352
+ submit(t, n) {
353
+ if (this.pendingInputs.size >= this.options.maxPendingInputs) return Promise.reject(new e({
354
+ budget: "unacknowledgedInputs",
355
+ limit: this.options.maxPendingInputs
356
+ }));
357
+ let r = structuredClone(n), i = t.nextInputSeq, a = t.send(r);
358
+ return t.nextInputSeq === i + 1 && (this.pendingInputs.set(i, r), this.nextSeq = t.nextInputSeq), a;
359
+ }
360
+ message(e, n) {
361
+ return this.currentStatus !== "joined" || !this.session ? Promise.reject(new t({ detail: "Messages require a joined room" })) : this.session.message(e, n);
362
+ }
363
+ onWorldHandoff(e) {
364
+ return this.handoffListeners.add(e), () => {
365
+ this.handoffListeners.delete(e);
366
+ };
367
+ }
368
+ onMessage(e, n) {
369
+ if (!this.manifest.messages?.[e] || this.manifest.messages[e].direction === "client") throw new t({ detail: "Channel is not server-sendable" });
370
+ let r = this.messageListeners.get(e), i = r ?? /* @__PURE__ */ new Set();
371
+ return i.add(n), this.messageListeners.set(e, i), !r && this.session && this.attachMessages(this.session, e), () => {
372
+ i.delete(n), i.size === 0 && (this.messageListeners.delete(e), this.messageDetach.get(e)?.(), this.messageDetach.delete(e));
373
+ };
374
+ }
375
+ attachMessages(e, t) {
376
+ this.messageDetach.set(t, e.onMessage(t, (e) => {
377
+ for (let n of this.messageListeners.get(t) ?? []) n(structuredClone(e));
378
+ }));
379
+ }
380
+ requestReservation(t, n) {
381
+ if (this.pendingReservationCalls >= this.options.maxPendingReservationCalls) return Promise.reject(new e({
382
+ budget: "pendingReservationCalls",
383
+ limit: this.options.maxPendingReservationCalls
384
+ }));
385
+ this.pendingReservationCalls++;
386
+ let r;
387
+ try {
388
+ r = t();
389
+ } catch (e) {
390
+ return this.pendingReservationCalls--, Promise.reject(e);
391
+ }
392
+ return r.then((e) => {
393
+ this.pendingReservationCalls--, n.aborted && this.releaseReservation(e);
394
+ }, () => {
395
+ this.pendingReservationCalls--;
396
+ }).catch((e) => {
397
+ this.currentError = e, this.notify();
398
+ }), g(r, n);
399
+ }
400
+ releaseReservation(e) {
401
+ let t = this.reservations.release;
402
+ if (!t) return;
403
+ let n = new AbortController(), r = setTimeout(() => n.abort(), this.options.connectTimeoutMs), i = (async () => {
404
+ try {
405
+ await g(t.call(this.reservations, e.sessionId, Uint8Array.from(e.token), n.signal), n.signal);
406
+ } catch (e) {
407
+ this.currentError = e, this.cleanupFailures.length === this.options.maxCleanupFailures && this.cleanupFailures.shift(), this.cleanupFailures.push(e), this.notify();
408
+ } finally {
409
+ clearTimeout(r);
410
+ }
411
+ })();
412
+ this.cleanupTasks.add(i), i.finally(() => {
413
+ this.cleanupTasks.delete(i);
414
+ });
415
+ }
416
+ stopClockSampling() {
417
+ this.clockTimer !== null && clearTimeout(this.clockTimer), this.clockTimer = null;
418
+ }
419
+ releaseTransport(e, t) {
420
+ let n = this.retainTransport(e, t);
421
+ return this.runTransportCleanup(e, n);
422
+ }
423
+ retainTransport(e, t) {
424
+ let n = this.transportLifetimes.get(e);
425
+ if (!n) {
426
+ let r = a(e, "closeAsync", "Room transport requires an actual asynchronous close method") ?? o(e, "close", "Room transport requires an actual close method");
427
+ n = new s(async () => {
428
+ await r(1e3, t);
429
+ }), this.transportLifetimes.set(e, n), this.transportOwners.set(e, n);
430
+ }
431
+ return n;
432
+ }
433
+ runTransportCleanup(e, t) {
434
+ this.withdrawalAttempted?.add(e);
435
+ let n = t.cleanupAsync();
436
+ return this.cleanupTasks.add(n), n.then(() => {
437
+ this.cleanupTasks.delete(n), this.transportOwners.get(e) === t && this.transportOwners.delete(e);
438
+ }, (e) => {
439
+ this.cleanupTasks.delete(n), this.currentError = e, this.notify();
440
+ }), n;
441
+ }
442
+ startClockSampling(e) {
443
+ let t = this.clock.now(), r = () => {
444
+ if (e !== this.session || this.currentStatus !== "joined" || this.leaving) return;
445
+ let i = this.options.clockPingCadence(Math.max(0, this.clock.now() - t));
446
+ !Number.isSafeInteger(i) || i <= 0 || i > 2147483647 ? this.terminal(new n({
447
+ room: "client",
448
+ detail: "Clock ping cadence must return a bounded positive timer duration"
449
+ }), "left") : this.clockTimer = setTimeout(() => {
450
+ this.clockTimer = null, !(e !== this.session || this.currentStatus !== "joined" || this.leaving) && e.ping().then(r, (t) => {
451
+ e !== this.session || this.currentStatus !== "joined" || this.leaving || (this.currentError = t, this.notify(), r());
452
+ });
453
+ }, i);
454
+ };
455
+ r();
456
+ }
457
+ terminal(e, t) {
458
+ this.stopClockSampling(), this.currentError = e, this.currentStatus = t, this.sessionDetach?.(), this.sessionDetach = null, this.handoffDetach?.(), this.handoffDetach = null;
459
+ for (let e of this.messageDetach.values()) e();
460
+ this.messageDetach.clear(), this.session && this.releaseTransport(this.session.transport, "Room connection ended").catch(() => {}), this.reservation &&= (this.releaseReservation(this.reservation), null);
461
+ for (let t of this.buffered.splice(0)) t.reject(e);
462
+ this.notify();
463
+ }
464
+ leave() {
465
+ if (this.left) return Promise.resolve();
466
+ if (this.leaveTask) return this.leaveTask;
467
+ let e = this.withdraw();
468
+ return this.leaveTask = e, e.catch(() => {
469
+ this.leaveTask === e && (this.leaveTask = null);
470
+ }), e;
471
+ }
472
+ async withdraw() {
473
+ this.withdrawalAttempted = /* @__PURE__ */ new Set(), this.leaving = !0, this.controller.abort(), this.stopClockSampling(), this.pendingInputs.clear(), this.sessionDetach?.(), this.sessionDetach = null, this.handoffDetach?.(), this.handoffDetach = null;
474
+ for (let e of this.buffered.splice(0)) e.reject(h());
475
+ let e = [];
476
+ this.session && e.push(this.session.leave()), this.startTask && e.push(this.startTask), this.reconnectTask && e.push(this.reconnectTask);
477
+ let t = await Promise.allSettled(e);
478
+ for (this.session && this.retainTransport(this.session.transport, "Room connection left"), this.reservation &&= (this.releaseReservation(this.reservation), null); this.cleanupTasks.size;) await Promise.allSettled([...this.cleanupTasks]);
479
+ let n = await Promise.allSettled([...this.transportOwners].filter(([e]) => !this.withdrawalAttempted.has(e)).map(([e, t]) => this.runTransportCleanup(e, t)));
480
+ for (let e of this.messageDetach.values()) e();
481
+ this.messageDetach.clear(), this.messageListeners.clear(), this.currentStatus = "left", this.notify();
482
+ let r = [...this.cleanupFailures, ...t.flatMap((e) => e.status === "rejected" ? [e.reason] : [])], i = n.flatMap((e) => e.status === "rejected" ? [e.reason] : []);
483
+ if (this.withdrawalAttempted = void 0, this.cleanupFailures.length || this.transportOwners.size || i.length) throw AggregateError([
484
+ ...r,
485
+ ...i,
486
+ ...this.transportOwners.values()
487
+ ], "Room connection withdrawal failed");
488
+ this.left = !0, this.listeners.clear();
489
+ }
490
+ }, b = (e) => {
491
+ if (!e || typeof e != "object") throw h();
492
+ let n = v.get(e)?.();
493
+ if (!n) throw new t({ detail: "Geometry requires its genuine currently joined Room connection" });
494
+ return n;
495
+ };
496
+ //#endregion
497
+ export { y as RoomConnection, b as captureRoomConnectionGeometrySession, p as defaultRoomClockPingCadence, m as defaultRoomReconnectPolicy };