@voltro/plugin-rooms 0.0.0-stage → 0.88.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 +24492 -0
  2. package/LICENSE +61 -0
  3. package/README.md +9204 -2
  4. package/SECURITY.md +56 -0
  5. package/THIRD-PARTY-NOTICES.md +12496 -0
  6. package/dist/actor.js +1473 -0
  7. package/dist/apiBinding.js +677 -0
  8. package/dist/apiRegistryBinding.js +398 -0
  9. package/dist/apiReservations.js +432 -0
  10. package/dist/baselines.js +72 -0
  11. package/dist/bots.d.ts +1485 -0
  12. package/dist/bots.js +562 -0
  13. package/dist/catalog.js +79 -0
  14. package/dist/checkpointJson.js +23 -0
  15. package/dist/checkpointStore.js +385 -0
  16. package/dist/client.js +55 -0
  17. package/dist/clockSync.js +50 -0
  18. package/dist/collision.js +155 -0
  19. package/dist/commandDelivery.js +100 -0
  20. package/dist/commandRecord.js +10 -0
  21. package/dist/commandWithdrawal.js +182 -0
  22. package/dist/connection.js +496 -0
  23. package/dist/controlCarrier.js +374 -0
  24. package/dist/controlRegistry.js +78 -0
  25. package/dist/controlTarget.js +44 -0
  26. package/dist/controlTransport.js +573 -0
  27. package/dist/developmentBinding.js +112 -0
  28. package/dist/directory.js +322 -0
  29. package/dist/directoryProjection.js +116 -0
  30. package/dist/errors.d.ts +125 -0
  31. package/dist/errors.js +52 -0
  32. package/dist/fixed.d.ts +284 -0
  33. package/dist/fixed.js +10 -0
  34. package/dist/fixed32.js +133 -0
  35. package/dist/fixedCollision.js +59 -0
  36. package/dist/fixedCollision32.js +108 -0
  37. package/dist/fixedMath.js +55 -0
  38. package/dist/fixedRaw.js +10 -0
  39. package/dist/fixedSlabs.js +33 -0
  40. package/dist/fixedTrig.js +47 -0
  41. package/dist/fixedTrig32.js +37 -0
  42. package/dist/fixedVectors.js +112 -0
  43. package/dist/fixedVectors32.js +94 -0
  44. package/dist/fixedWide.js +49 -0
  45. package/dist/fixedWords.js +45 -0
  46. package/dist/gateway.js +56 -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 +81 -0
  54. package/dist/geometryActorInventory.js +107 -0
  55. package/dist/geometryAdminClient.js +86 -0
  56. package/dist/geometryAdminData.js +31 -0
  57. package/dist/geometryAdminFixtures.js +49 -0
  58. package/dist/geometryAdminPorts.js +4 -0
  59. package/dist/geometryAdminRpc.js +57 -0
  60. package/dist/geometryAdminRpcRoutes.js +48 -0
  61. package/dist/geometryAdminSchemas.js +38 -0
  62. package/dist/geometryAdministration.js +189 -0
  63. package/dist/geometryAdministrationPorts.js +4 -0
  64. package/dist/geometryApiBinding.js +164 -0
  65. package/dist/geometryAppStorage.js +57 -0
  66. package/dist/geometryArtifacts.js +197 -0
  67. package/dist/geometryAssetBundle.js +116 -0
  68. package/dist/geometryAssetClient.js +24 -0
  69. package/dist/geometryAssetData.js +105 -0
  70. package/dist/geometryAssetHttp.js +122 -0
  71. package/dist/geometryAssetPorts.js +4 -0
  72. package/dist/geometryAssetRpc.js +29 -0
  73. package/dist/geometryAssetRpcRoutes.js +39 -0
  74. package/dist/geometryAssetStorageGrant.js +102 -0
  75. package/dist/geometryBoxOverlap.js +109 -0
  76. package/dist/geometryCatalogueDigest.js +110 -0
  77. package/dist/geometryCellCoverage.js +84 -0
  78. package/dist/geometryCellLoader.js +27 -0
  79. package/dist/geometryChannel.js +133 -0
  80. package/dist/geometryChunkHttp.js +53 -0
  81. package/dist/geometryChunkLeases.js +21 -0
  82. package/dist/geometryClient.d.ts +1429 -0
  83. package/dist/geometryClient.js +148 -0
  84. package/dist/geometryClientChunks.js +329 -0
  85. package/dist/geometryClientDelta.js +24 -0
  86. package/dist/geometryClientHttp.js +36 -0
  87. package/dist/geometryClientInterest.js +108 -0
  88. package/dist/geometryClientStatic.js +33 -0
  89. package/dist/geometryCms.d.ts +763 -0
  90. package/dist/geometryCms.js +216 -0
  91. package/dist/geometryCommitCoordinator.js +240 -0
  92. package/dist/geometryCompactionFixture.js +83 -0
  93. package/dist/geometryCompactionStrategies.js +37 -0
  94. package/dist/geometryConnectionClient.js +22 -0
  95. package/dist/geometryDerivationFixtures.js +140 -0
  96. package/dist/geometryDerivationStrategies.js +26 -0
  97. package/dist/geometryDigest.js +12 -0
  98. package/dist/geometryEditChannel.js +69 -0
  99. package/dist/geometryEditIngress.js +262 -0
  100. package/dist/geometryEdits.js +365 -0
  101. package/dist/geometryEnvelope.js +40 -0
  102. package/dist/geometryGridRaycast.js +91 -0
  103. package/dist/geometryGridSweep.js +91 -0
  104. package/dist/geometryHeightfield.js +165 -0
  105. package/dist/geometryHeightfieldRaycast.js +73 -0
  106. package/dist/geometryHeightfieldSweep.js +84 -0
  107. package/dist/geometryHeightfieldVolume.js +44 -0
  108. package/dist/geometryHost.js +321 -0
  109. package/dist/geometryHostDirectory.js +206 -0
  110. package/dist/geometryHostMutations.js +136 -0
  111. package/dist/geometryHostStreams.js +123 -0
  112. package/dist/geometryHttpBody.js +75 -0
  113. package/dist/geometryHttpRoutes.js +111 -0
  114. package/dist/geometryImportGltf.js +299 -0
  115. package/dist/geometryImportLdtk.js +53 -0
  116. package/dist/geometryImportPng.js +143 -0
  117. package/dist/geometryImportPublication.js +66 -0
  118. package/dist/geometryImportTiled.js +38 -0
  119. package/dist/geometryImportTiles.js +135 -0
  120. package/dist/geometryImportVox.js +129 -0
  121. package/dist/geometryImportedSource.js +100 -0
  122. package/dist/geometryInspectEndpoint.js +247 -0
  123. package/dist/geometryInspection.js +91 -0
  124. package/dist/geometryInstall.js +120 -0
  125. package/dist/geometryJournalArchiveData.js +20 -0
  126. package/dist/geometryJournalArchiveIndex.js +329 -0
  127. package/dist/geometryJournalArchiveTable.js +20 -0
  128. package/dist/geometryJournalCompaction.js +99 -0
  129. package/dist/geometryJournalPatch.js +46 -0
  130. package/dist/geometryJournalRetention.js +111 -0
  131. package/dist/geometryJournalRetentionSchemas.js +35 -0
  132. package/dist/geometryJournalRetentionSweep.js +111 -0
  133. package/dist/geometryJournalRetentionWorkflow.js +27 -0
  134. package/dist/geometryJournalRetentionWorkflowData.js +30 -0
  135. package/dist/geometryJournalStorage.js +147 -0
  136. package/dist/geometryLoader.js +117 -0
  137. package/dist/geometryManifest.js +112 -0
  138. package/dist/geometryManifestChannel.js +92 -0
  139. package/dist/geometryManifestClient.js +121 -0
  140. package/dist/geometryManifestData.js +48 -0
  141. package/dist/geometryManifestPorts.js +4 -0
  142. package/dist/geometryManifestPublication.js +108 -0
  143. package/dist/geometryManifestSource.js +67 -0
  144. package/dist/geometryMigrationJournal.js +13 -0
  145. package/dist/geometryMigrationStrategies.js +6 -0
  146. package/dist/geometryMigrations.js +322 -0
  147. package/dist/geometryNativeMetadata.js +51 -0
  148. package/dist/geometryPatch.js +169 -0
  149. package/dist/geometryPersistence.js +448 -0
  150. package/dist/geometryPersistenceCapture.js +68 -0
  151. package/dist/geometryPersistenceData.js +139 -0
  152. package/dist/geometryPersistencePorts.js +4 -0
  153. package/dist/geometryPlayerAdmission.js +33 -0
  154. package/dist/geometryPlayerEditOwner.js +264 -0
  155. package/dist/geometryPlayerEdits.js +48 -0
  156. package/dist/geometryPrepared.js +187 -0
  157. package/dist/geometryPrivacyFence.js +23 -0
  158. package/dist/geometryProceduralPublication.js +90 -0
  159. package/dist/geometryProceduralWorker.js +163 -0
  160. package/dist/geometryPublication.js +109 -0
  161. package/dist/geometryRayAlgebra.js +115 -0
  162. package/dist/geometryReadClient.js +156 -0
  163. package/dist/geometryReadPorts.js +4 -0
  164. package/dist/geometryReadRpc.js +26 -0
  165. package/dist/geometryReadRpcRoutes.js +46 -0
  166. package/dist/geometryReliablePublication.js +81 -0
  167. package/dist/geometryReloadPorts.js +45 -0
  168. package/dist/geometryReloadSource.js +277 -0
  169. package/dist/geometryRenderCache.js +164 -0
  170. package/dist/geometryRenderLod.js +101 -0
  171. package/dist/geometryRollback.js +124 -0
  172. package/dist/geometryRollbackCoordinator.js +202 -0
  173. package/dist/geometryRollbackPorts.js +45 -0
  174. package/dist/geometryRollbackSource.js +208 -0
  175. package/dist/geometryRollbackStore.js +197 -0
  176. package/dist/geometrySchemas.js +26 -0
  177. package/dist/geometryServer.d.ts +2766 -0
  178. package/dist/geometryServer.js +62 -0
  179. package/dist/geometryShapeRaycast.js +110 -0
  180. package/dist/geometryShapeSegments.js +33 -0
  181. package/dist/geometryShapes.js +222 -0
  182. package/dist/geometrySnapshot.js +75 -0
  183. package/dist/geometrySnapshotChannel.js +159 -0
  184. package/dist/geometrySnapshotClient.js +158 -0
  185. package/dist/geometrySnapshotPreparation.js +75 -0
  186. package/dist/geometrySnapshotServer.js +190 -0
  187. package/dist/geometrySqlOwner.js +20 -0
  188. package/dist/geometryStorage.js +126 -0
  189. package/dist/geometryStorageGrant.js +68 -0
  190. package/dist/geometryStorageIdentity.js +8 -0
  191. package/dist/geometryTileArtifact.js +9 -0
  192. package/dist/geometryTileCodec.js +193 -0
  193. package/dist/geometryTileCollision.js +95 -0
  194. package/dist/geometryTileNavigation.js +127 -0
  195. package/dist/geometryTileView.js +34 -0
  196. package/dist/geometryVersionActivation.js +113 -0
  197. package/dist/geometryVersionClient.js +237 -0
  198. package/dist/geometryVersionCompare.js +39 -0
  199. package/dist/geometryVersionMigration.js +105 -0
  200. package/dist/geometryVoxel.js +252 -0
  201. package/dist/geometryWorldEntitySubject.js +31 -0
  202. package/dist/geometryWorldExtent.js +11 -0
  203. package/dist/geometryWorldMetadata.js +37 -0
  204. package/dist/geometryWorldStrategyFixtures.js +126 -0
  205. package/dist/geometryWorldView.js +306 -0
  206. package/dist/host.js +127 -0
  207. package/dist/hostBinding.js +276 -0
  208. package/dist/hostCellObservation.js +113 -0
  209. package/dist/hostClientCapacity.js +89 -0
  210. package/dist/hostCommandScope.js +63 -0
  211. package/dist/hostController.js +3093 -0
  212. package/dist/hostDeployment.js +64 -0
  213. package/dist/hostDrain.js +151 -0
  214. package/dist/hostDrainPorts.js +4 -0
  215. package/dist/hostDriver.js +178 -0
  216. package/dist/hostLane.js +287 -0
  217. package/dist/hostListener.js +78 -0
  218. package/dist/hostListenerBinding.js +18 -0
  219. package/dist/hostLoopObservation.js +89 -0
  220. package/dist/hostMetrics.js +55 -0
  221. package/dist/hostRegistryBinding.js +417 -0
  222. package/dist/hostSelection.js +15 -0
  223. package/dist/hostShutdown.js +46 -0
  224. package/dist/hostTurnObservation.js +52 -0
  225. package/dist/identities.js +3 -0
  226. package/dist/index.d.ts +8632 -0
  227. package/dist/index.js +231 -0
  228. package/dist/inputReceipts.js +62 -0
  229. package/dist/inputRedundancy.js +54 -0
  230. package/dist/inspect.js +237 -0
  231. package/dist/lockstep.d.ts +436 -0
  232. package/dist/lockstep.js +381 -0
  233. package/dist/lockstepAdmission.js +261 -0
  234. package/dist/lockstepAdmissionCodec.js +93 -0
  235. package/dist/lockstepAdmissionPorts.js +4 -0
  236. package/dist/lockstepClientSession.js +577 -0
  237. package/dist/lockstepDefinition.js +147 -0
  238. package/dist/lockstepHostLoop.js +242 -0
  239. package/dist/lockstepInitialAdmission.js +66 -0
  240. package/dist/lockstepInitialStrategyFixtures.js +44 -0
  241. package/dist/lockstepJournal.js +394 -0
  242. package/dist/lockstepJournalCodec.js +253 -0
  243. package/dist/lockstepJournalPorts.js +4 -0
  244. package/dist/lockstepJournalRebuild.js +207 -0
  245. package/dist/lockstepJournalRows.js +56 -0
  246. package/dist/lockstepMembers.js +130 -0
  247. package/dist/lockstepMessages.js +46 -0
  248. package/dist/lockstepOwnedRoom.js +763 -0
  249. package/dist/lockstepPolicies.js +83 -0
  250. package/dist/lockstepReact.js +46 -0
  251. package/dist/lockstepRecoveryTruth.js +120 -0
  252. package/dist/lockstepRosterConfig.js +31 -0
  253. package/dist/lockstepSeed.js +11 -0
  254. package/dist/lockstepSeedFixture.js +19 -0
  255. package/dist/lockstepServer.d.ts +3897 -0
  256. package/dist/lockstepServer.js +324 -0
  257. package/dist/lockstepServerConfig.js +100 -0
  258. package/dist/lockstepServerRoles.js +402 -0
  259. package/dist/lockstepServerStrategyFixtures.js +32 -0
  260. package/dist/lockstepStrategies.js +5 -0
  261. package/dist/lockstepStrategyFixtures.js +136 -0
  262. package/dist/lockstepTerminal.js +89 -0
  263. package/dist/lockstepTerminalPorts.js +4 -0
  264. package/dist/lockstepTransport.js +772 -0
  265. package/dist/lockstepTransportConfig.js +31 -0
  266. package/dist/lockstepWireRoster.js +33 -0
  267. package/dist/matchRoomProvider.js +31 -0
  268. package/dist/matchRooms.js +18 -0
  269. package/dist/membershipObserver.js +46 -0
  270. package/dist/moderation.js +97 -0
  271. package/dist/movementSpecials.js +103 -0
  272. package/dist/ownership.js +16 -0
  273. package/dist/ownershipWithdrawal.js +17 -0
  274. package/dist/pcg32.js +95 -0
  275. package/dist/ports.d.ts +1241 -0
  276. package/dist/ports.js +10 -0
  277. package/dist/quaternion.js +69 -0
  278. package/dist/react.d.ts +406 -0
  279. package/dist/react.js +108 -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 +242 -0
  283. package/dist/reaperSchemas.js +41 -0
  284. package/dist/reaperWorkflow.js +69 -0
  285. package/dist/recovery.js +188 -0
  286. package/dist/recoverySeats.js +25 -0
  287. package/dist/replay.d.ts +273 -0
  288. package/dist/replay.js +484 -0
  289. package/dist/replayPorts.js +4 -0
  290. package/dist/replayRecording.js +66 -0
  291. package/dist/replaySchema.js +156 -0
  292. package/dist/replayStorage.d.ts +149 -0
  293. package/dist/replayStorage.js +484 -0
  294. package/dist/reservationBatch.js +421 -0
  295. package/dist/reservationSchemas.js +16 -0
  296. package/dist/reservations.js +258 -0
  297. package/dist/reservePort.js +68 -0
  298. package/dist/resolvedOptions.js +3 -0
  299. package/dist/room.d.ts +1006 -0
  300. package/dist/room.js +283 -0
  301. package/dist/roomAccessSweep.js +94 -0
  302. package/dist/roomAppCommandControl.js +58 -0
  303. package/dist/roomAuthoringStrategy.js +16 -0
  304. package/dist/roomErasure.js +197 -0
  305. package/dist/roomPoolRuntimeDefaults.js +23 -0
  306. package/dist/roomPoolSelection.js +18 -0
  307. package/dist/roomPoolTopology.js +211 -0
  308. package/dist/rpc.d.ts +551 -0
  309. package/dist/rpc.js +111 -0
  310. package/dist/rpcClient.js +151 -0
  311. package/dist/rpcRoutes.js +27 -0
  312. package/dist/runtime.js +1122 -0
  313. package/dist/schemaHistory.js +97 -0
  314. package/dist/seatStore.js +150 -0
  315. package/dist/seatStrategyFixtures.js +51 -0
  316. package/dist/seatSubject.js +31 -0
  317. package/dist/seats.js +129 -0
  318. package/dist/serverSession.js +810 -0
  319. package/dist/serverSessionConfig.js +42 -0
  320. package/dist/sessionAdmission.js +52 -0
  321. package/dist/sidecarAdmission.js +102 -0
  322. package/dist/sidecarConfig.js +115 -0
  323. package/dist/sidecarConfigPublication.js +63 -0
  324. package/dist/sidecarHostListener.js +207 -0
  325. package/dist/sidecarIpc.js +204 -0
  326. package/dist/sidecarPeer.js +309 -0
  327. package/dist/sidecarProcessPort.js +27 -0
  328. package/dist/sidecarRuntime.js +167 -0
  329. package/dist/sidecarSelection.js +141 -0
  330. package/dist/sidecarWire.js +177 -0
  331. package/dist/sidecarWrites.js +162 -0
  332. package/dist/simulation.d.ts +391 -0
  333. package/dist/simulation.js +281 -0
  334. package/dist/simulationAuthoring.js +28 -0
  335. package/dist/simulationBytes.js +26 -0
  336. package/dist/simulationConformance.js +304 -0
  337. package/dist/simulationInputHistoryCapture.js +34 -0
  338. package/dist/simulationInputHistoryWire.js +192 -0
  339. package/dist/simulationOptionsWire.js +77 -0
  340. package/dist/simulationRecoveryWire.js +133 -0
  341. package/dist/simulationReplay.js +126 -0
  342. package/dist/simulationSnapshotWire.js +111 -0
  343. package/dist/simulationState.js +177 -0
  344. package/dist/snapshotBlob.js +125 -0
  345. package/dist/snapshotBlobCleanup.js +92 -0
  346. package/dist/snapshotBlobIndex.js +37 -0
  347. package/dist/snapshotBudget.js +79 -0
  348. package/dist/snapshotChain.js +184 -0
  349. package/dist/snapshotErasure.js +171 -0
  350. package/dist/snapshotInspection.js +104 -0
  351. package/dist/snapshotSegmentBlobs.js +57 -0
  352. package/dist/snapshotUploads.js +165 -0
  353. package/dist/socketTransport.js +252 -0
  354. package/dist/spatial.js +103 -0
  355. package/dist/spectatorPolicy.js +25 -0
  356. package/dist/spectatorProducer.js +88 -0
  357. package/dist/startFailureCause.js +3 -0
  358. package/dist/stateCodec.js +657 -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 +181 -0
  364. package/dist/streamFraming.js +121 -0
  365. package/dist/streamTransport.js +265 -0
  366. package/dist/subjectAdmission.js +49 -0
  367. package/dist/subjectPrivacy.js +280 -0
  368. package/dist/subjectPrivacyBinding.js +89 -0
  369. package/dist/systemManifest.js +181 -0
  370. package/dist/tables.js +158 -0
  371. package/dist/testHarness.js +88 -0
  372. package/dist/testing.d.ts +3684 -0
  373. package/dist/testing.js +220 -0
  374. package/dist/testingPorts.js +270 -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 +216 -0
  379. package/dist/transform3d.js +117 -0
  380. package/dist/transformCollection.js +23 -0
  381. package/dist/transformCollection3d.js +23 -0
  382. package/dist/transformCollectionCore.js +155 -0
  383. package/dist/transformFrames.js +120 -0
  384. package/dist/transformPrediction3d.js +126 -0
  385. package/dist/transformRules.js +122 -0
  386. package/dist/transformSchemas.js +19 -0
  387. package/dist/transport.js +31 -0
  388. package/dist/transportAuthoring.js +28 -0
  389. package/dist/transportCleanup.js +21 -0
  390. package/dist/transportConformance.js +123 -0
  391. package/dist/transportConnector.js +81 -0
  392. package/dist/transportEndpoints.js +37 -0
  393. package/dist/transportsServer.d.ts +5515 -0
  394. package/dist/transportsServer.js +6 -0
  395. package/dist/viewProjection.js +15 -0
  396. package/dist/web.d.ts +2286 -0
  397. package/dist/web.js +517 -0
  398. package/dist/webTransportClient.js +172 -0
  399. package/dist/wire.d.ts +992 -0
  400. package/dist/wire.js +491 -0
  401. package/dist/withdrawalPort.js +27 -0
  402. package/dist/world.d.ts +1894 -0
  403. package/dist/world.js +332 -0
  404. package/dist/worldActorReceipts.js +47 -0
  405. package/dist/worldActorTransferSnapshot.js +13 -0
  406. package/dist/worldAdmissionPending.js +7 -0
  407. package/dist/worldBoundaryCoordinator.js +147 -0
  408. package/dist/worldCatalog.js +80 -0
  409. package/dist/worldCellAllocation.js +202 -0
  410. package/dist/worldCellDestination.js +67 -0
  411. package/dist/worldCells.js +488 -0
  412. package/dist/worldChange.js +31 -0
  413. package/dist/worldClient.js +663 -0
  414. package/dist/worldClientControl.js +140 -0
  415. package/dist/worldClientPendingInput.js +15 -0
  416. package/dist/worldClientRpc.js +132 -0
  417. package/dist/worldClientRpcRoutes.js +42 -0
  418. package/dist/worldClientSchemas.js +27 -0
  419. package/dist/worldCommands.js +139 -0
  420. package/dist/worldData.js +41 -0
  421. package/dist/worldDefaultBinding.js +376 -0
  422. package/dist/worldDefaultGroupAdmission.js +81 -0
  423. package/dist/worldDefaultGroupAppServices.js +30 -0
  424. package/dist/worldDefaultGroupCompensation.js +108 -0
  425. package/dist/worldDefaultGroupContinuation.js +95 -0
  426. package/dist/worldDefaultGroupControl.js +71 -0
  427. package/dist/worldDefaultGroupMembers.js +84 -0
  428. package/dist/worldDefaultGroups.js +20 -0
  429. package/dist/worldDefaultPending.js +78 -0
  430. package/dist/worldDefaultService.js +244 -0
  431. package/dist/worldEntities.js +2979 -0
  432. package/dist/worldEntityCodec.js +20 -0
  433. package/dist/worldEntityHandoffView.js +153 -0
  434. package/dist/worldGeometry.js +169 -0
  435. package/dist/worldGhostAdmission.js +64 -0
  436. package/dist/worldGhostDestination.js +117 -0
  437. package/dist/worldGhostGateway.js +131 -0
  438. package/dist/worldGhostHandshake.js +107 -0
  439. package/dist/worldGhostHost.js +41 -0
  440. package/dist/worldGhostIngress.js +131 -0
  441. package/dist/worldGhostNeighborhood.js +69 -0
  442. package/dist/worldGhostNeighbors.js +85 -0
  443. package/dist/worldGhostOutbound.js +109 -0
  444. package/dist/worldGhostPublisher.js +215 -0
  445. package/dist/worldGhostReceiver.js +212 -0
  446. package/dist/worldGhostSender.js +145 -0
  447. package/dist/worldGhostSocket.js +77 -0
  448. package/dist/worldGhostWire.js +171 -0
  449. package/dist/worldGroupCommand.js +48 -0
  450. package/dist/worldGroupDeadline.js +114 -0
  451. package/dist/worldGroupPreparation.js +114 -0
  452. package/dist/worldGroupReadyControl.js +127 -0
  453. package/dist/worldGroupSupervisor.js +119 -0
  454. package/dist/worldHandoffMetrics.js +58 -0
  455. package/dist/worldHandoffView.js +99 -0
  456. package/dist/worldHostSource.js +68 -0
  457. package/dist/worldInspectEndpoint.js +249 -0
  458. package/dist/worldInspection.js +108 -0
  459. package/dist/worldInstanceAdmission.js +30 -0
  460. package/dist/worldInstanceAllocation.js +115 -0
  461. package/dist/worldInstanceDestination.js +63 -0
  462. package/dist/worldInstanceExpiry.js +281 -0
  463. package/dist/worldInstanceExpirySupervisor.js +87 -0
  464. package/dist/worldInstanceLifecycle.js +102 -0
  465. package/dist/worldInstanceState.js +51 -0
  466. package/dist/worldInstances.js +477 -0
  467. package/dist/worldJoin.js +55 -0
  468. package/dist/worldLayers.js +150 -0
  469. package/dist/worldLeases.js +77 -0
  470. package/dist/worldManifest.js +24 -0
  471. package/dist/worldMovement.js +62 -0
  472. package/dist/worldPersistence.js +133 -0
  473. package/dist/worldProjection.js +220 -0
  474. package/dist/worldReact.js +109 -0
  475. package/dist/worldRecoveryActor.js +34 -0
  476. package/dist/worldReturnAnchor.js +48 -0
  477. package/dist/worldRoomHooks.js +56 -0
  478. package/dist/worldRoomPool.js +26 -0
  479. package/dist/worldRoomSteps.js +132 -0
  480. package/dist/worldSeatBinding.js +35 -0
  481. package/dist/worldServer.d.ts +6936 -0
  482. package/dist/worldServer.js +48 -0
  483. package/dist/worldSourceSeatPending.js +8 -0
  484. package/dist/worldStrategyFixtures.js +163 -0
  485. package/dist/worldTesting.js +26 -0
  486. package/dist/worldTransitionDefaults.js +197 -0
  487. package/dist/worldTransitionExecutor.js +518 -0
  488. package/dist/worldTransitionGroup.js +112 -0
  489. package/dist/worldTransitionPhysicalSteps.js +39 -0
  490. package/dist/worldTransitionResolver.js +227 -0
  491. package/dist/worldTransitionSeatGroup.js +63 -0
  492. package/dist/worldTransitionSeats.js +259 -0
  493. package/dist/worldTransitionState.js +94 -0
  494. package/dist/worldTransitions.js +100 -0
  495. package/package.json +189 -4
@@ -0,0 +1,763 @@
1
+ import { BudgetExceeded as e, ProtocolError as t, RoomGone as n } from "./errors.js";
2
+ import { unsignedWord as r } from "./fixedWords.js";
3
+ import { freezeSimulationValue as i, simulationOwnData as a, simulationSyncValue as o } from "./simulationAuthoring.js";
4
+ import { defineRoom as s } from "./room.js";
5
+ import { roomLockstepStartBudgetRoster as c } from "./lockstepWireRoster.js";
6
+ import { encodeRoomFrame as l } from "./wire.js";
7
+ import { roomCodecs as u } from "./web.js";
8
+ import { captureLockstepJournalScope as d, createLockstepJournalCodec as f, lockstepJournalIdentity as p } from "./lockstepJournalCodec.js";
9
+ import { createRoomLockstepAdmissionCodec as m } from "./lockstepAdmissionCodec.js";
10
+ import { RoomLockstepMemberOwner as h } from "./lockstepMembers.js";
11
+ import { captureRoomServerSessionLimits as g } from "./serverSessionConfig.js";
12
+ import { assertRoomSeatSecrets as _, resolveRoomSeatTokenStrategies as v } from "./seats.js";
13
+ import { RoomServerSession as y, RoomServerSessionAcquisitionFailure as b, captureRoomLockstepSessionPort as x } from "./serverSession.js";
14
+ import { captureRoomLockstepTransportLimits as S } from "./lockstepTransportConfig.js";
15
+ import { createRoomLockstepTransportOwner as C } from "./lockstepTransport.js";
16
+ import { captureRoomLockstepInitialStrategies as w, resolveRoomLockstepInitialPlayerId as T, resolveRoomLockstepInitialStart as E } from "./lockstepInitialAdmission.js";
17
+ import { Effect as D, Result as O } from "effect";
18
+ // src/lockstepOwnedRoom.ts
19
+ var k = /* @__PURE__ */ new WeakSet(), A = (e) => typeof e == "object" && !!e && k.has(e);
20
+ function j(e) {
21
+ throw new t({ detail: e });
22
+ }
23
+ var M = (e, t, n = []) => {
24
+ let r = a(e, [...t, ...n], t);
25
+ for (let e of n) if (Object.hasOwn(r, e) && typeof r[e] != "function") return j("Lockstep owned room requires complete actual capabilities");
26
+ for (let e of t) if (typeof r[e] != "function") return j("Lockstep owned room requires complete actual capabilities");
27
+ }, N = class A {
28
+ id;
29
+ tenantId;
30
+ hostId;
31
+ epoch;
32
+ descriptor;
33
+ #e;
34
+ #t;
35
+ #n;
36
+ #r;
37
+ #i;
38
+ #a;
39
+ #o;
40
+ #s = [];
41
+ #c = 0;
42
+ #l = !1;
43
+ #u = /* @__PURE__ */ new Set();
44
+ #d = /* @__PURE__ */ new Map();
45
+ #f = !1;
46
+ #p = !1;
47
+ #m = null;
48
+ #h = !1;
49
+ #g = !1;
50
+ #_ = !1;
51
+ #v = null;
52
+ #y = !1;
53
+ #b = !1;
54
+ #x = null;
55
+ #S = null;
56
+ #C = null;
57
+ #w = !1;
58
+ #T = null;
59
+ #E = null;
60
+ constructor(e, t, n, r, i = null) {
61
+ this.#e = i, this.#t = JSON.stringify(r), this.id = t.roomId, this.tenantId = t.tenantId, this.hostId = n.hostId, this.epoch = t.epoch, this.descriptor = e, this.#i = n, this.#n = new h(e.simulation, {
62
+ roomId: this.id,
63
+ tenantId: this.tenantId,
64
+ epoch: this.epoch
65
+ }, {
66
+ name: e.name,
67
+ maxClients: e.maxClients,
68
+ budgets: e.budgets,
69
+ messages: e.messages,
70
+ ...e.lockstep.lateJoin ? { lateJoin: !0 } : {}
71
+ }), this.#a = u(e), this.#o = S(n.transport);
72
+ let { inputSchema: a, inputDelayTicks: o, rollbackHorizonTicks: s, inputPrediction: c, lateJoin: l, ...d } = e.lockstep;
73
+ try {
74
+ this.#r = C(e.simulation, t.seed, t.options, {
75
+ roomId: this.id,
76
+ tenantId: this.tenantId,
77
+ epoch: this.epoch
78
+ }, n.clock.now, d, {
79
+ tickRate: e.tickRate,
80
+ maxCatchUpTicks: n.maxCatchUpTicks ?? e.maxCatchUpTicks
81
+ }, {
82
+ ...n.transport,
83
+ journal: {
84
+ service: n.journal,
85
+ runEffect: n.runEffect,
86
+ startRequestId: `${t.requestId}::start`
87
+ }
88
+ });
89
+ } catch (e) {
90
+ throw this.#n.withdraw(), e;
91
+ }
92
+ Object.freeze(this);
93
+ }
94
+ static async create(e, t, n) {
95
+ return A.build(e, t, n, null);
96
+ }
97
+ static async restore(e, t, n, r) {
98
+ let i = s(e), o = d(t), c = a(n, [
99
+ "admission",
100
+ "journal",
101
+ "options"
102
+ ], [
103
+ "admission",
104
+ "journal",
105
+ "options"
106
+ ]), l = a(r, [
107
+ "hostId",
108
+ "admission",
109
+ "journal",
110
+ "runEffect",
111
+ "clock",
112
+ "seats",
113
+ "sessionOptions",
114
+ "transport",
115
+ "maxCatchUpTicks"
116
+ ], [
117
+ "hostId",
118
+ "admission",
119
+ "journal",
120
+ "runEffect",
121
+ "clock",
122
+ "seats",
123
+ "sessionOptions"
124
+ ]), u = p(l.hostId), h = m(i.simulation, 67108864), g = h.captureStored(c.admission, o, u);
125
+ if (!g.adoption || g.adoption.priorEpoch !== o.epoch - 1 || g.initial.name !== i.name) return j("Owned successor requires actual matching adopted SQL admission");
126
+ let _ = c.journal === null ? null : f(i.simulation, 65536, 67108864, i.maxClients).captureStored(c.journal, o, u);
127
+ if (_ && (!_.adoption || _.adoption.priorEpoch !== g.adoption.priorEpoch || _.initial.seed !== g.initial.seed || _.initial.options !== g.initial.options || _.initial.stateSchemaHash !== g.initial.stateSchemaHash || _.initial.inputSchemaHash !== g.initial.inputSchemaHash)) return j("Owned successor metadata and retained input truth disagree");
128
+ let v = h.optionsWire.decode(Buffer.from(g.initial.options, "base64url"));
129
+ if (Buffer.from(h.optionsWire.encode(c.options)).toString("base64url") !== g.initial.options) return j("Owned successor canonical options changed");
130
+ let y = Object.freeze({
131
+ admission: g,
132
+ journal: _,
133
+ options: v
134
+ });
135
+ return A.build(i, {
136
+ ...o,
137
+ requestId: g.initial.requestId,
138
+ creatorSubjectId: g.initial.creatorSubjectId,
139
+ seed: g.initial.seed,
140
+ options: v
141
+ }, Object.freeze({ ...l }), y);
142
+ }
143
+ static async build(e, t, n, o) {
144
+ let u = s(e), h = [
145
+ "roomId",
146
+ "tenantId",
147
+ "epoch",
148
+ "requestId",
149
+ "creatorSubjectId",
150
+ "seed",
151
+ "options"
152
+ ], y = a(t, h, h), b = d({
153
+ roomId: y.roomId,
154
+ tenantId: y.tenantId,
155
+ epoch: y.epoch
156
+ }), x = m(u.simulation, 67108864), C = x.optionsWire.capture(y.options), w = a(n, [
157
+ "hostId",
158
+ "admission",
159
+ "journal",
160
+ "runEffect",
161
+ "clock",
162
+ "seats",
163
+ "sessionOptions",
164
+ "transport",
165
+ "maxCatchUpTicks"
166
+ ], [
167
+ "hostId",
168
+ "admission",
169
+ "journal",
170
+ "runEffect",
171
+ "clock",
172
+ "seats",
173
+ "sessionOptions"
174
+ ]);
175
+ M(w.admission, [
176
+ "prepare",
177
+ "publish",
178
+ "load",
179
+ "adopt",
180
+ "exportSubject",
181
+ "erase"
182
+ ]), M(w.journal, [
183
+ "initialize",
184
+ "append",
185
+ "load",
186
+ "adopt",
187
+ "exportSubject",
188
+ "erase"
189
+ ], ["join"]), M(w.seats, ["consume", "disconnect"], ["revalidate"]);
190
+ let T = p(w.hostId), E = w.runEffect, N = w.maxCatchUpTicks;
191
+ if (N !== void 0 && (!Number.isSafeInteger(N) || N < 1 || N > 128)) return j("Invalid Lockstep host catch-up budget");
192
+ let P = w.clock, F = P && typeof P == "object" ? Object.getOwnPropertyDescriptor(P, "now") : void 0, I = { now: F && "value" in F ? F.value : void 0 };
193
+ if (typeof E != "function" || typeof I.now != "function") return j("Owned room requires its actual Effect runner and clock");
194
+ let L = a(w.sessionOptions, [
195
+ "secrets",
196
+ "epochNow",
197
+ "seatToken",
198
+ "maxPendingWrites",
199
+ "maxFramesPerSecond",
200
+ "baselineCapacity",
201
+ "maxBaselineAgeMs",
202
+ "helloTimeoutMs",
203
+ "authTimeoutMs",
204
+ "idleTimeoutMs"
205
+ ], ["secrets", "epochNow"]), { secrets: ee, epochNow: te, seatToken: ne, ...re } = L, ie = g(re, b.roomId), R = L;
206
+ if (typeof R.epochNow != "function") return j("Owned room requires an actual Seat epoch clock");
207
+ let z = a(R.secrets, ["current", "previous"], ["current"]), B = i({
208
+ current: a(z.current, ["kid", "secret"], ["kid", "secret"]),
209
+ ...z.previous === void 0 ? {} : { previous: a(z.previous, ["kid", "secret"], ["kid", "secret"]) }
210
+ });
211
+ _(B);
212
+ let ae = v(R.seatToken === void 0 ? {} : a(R.seatToken, ["sign", "verify"], [])), V = S(w.transport ?? {}), H = r(y.seed), U = x.optionsWire.encode(C), W = l({
213
+ kind: "LsStart",
214
+ startTick: 0,
215
+ seed: H,
216
+ options: U,
217
+ serverTimeMs: 2 ** 53 - 1,
218
+ localPlayerId: 4294967295,
219
+ roster: c(u.maxClients)
220
+ }, {
221
+ maxBytes: V.maxPendingWireBytes,
222
+ maxInputs: 4096
223
+ });
224
+ if (O.isFailure(W)) throw W.failure;
225
+ let G = w.admission, K = w.journal, q = w.seats, J = Object.freeze({
226
+ hostId: T,
227
+ runEffect: E,
228
+ clock: Object.freeze({ now: I.now.bind(w.clock) }),
229
+ admission: Object.freeze({
230
+ prepare: G.prepare.bind(G),
231
+ publish: G.publish.bind(G),
232
+ load: G.load.bind(G),
233
+ adopt: G.adopt.bind(G),
234
+ exportSubject: G.exportSubject.bind(G),
235
+ erase: G.erase.bind(G)
236
+ }),
237
+ journal: Object.freeze({
238
+ initialize: K.initialize.bind(K),
239
+ append: K.append.bind(K),
240
+ load: K.load.bind(K),
241
+ adopt: K.adopt.bind(K),
242
+ exportSubject: K.exportSubject.bind(K),
243
+ erase: K.erase.bind(K),
244
+ ...typeof K.join == "function" ? { join: K.join.bind(K) } : {}
245
+ }),
246
+ seats: Object.freeze({
247
+ consume: q.consume.bind(q),
248
+ disconnect: q.disconnect.bind(q)
249
+ }),
250
+ sessionOptions: Object.freeze({
251
+ ...ie,
252
+ epochNow: R.epochNow,
253
+ secrets: B,
254
+ seatToken: ae
255
+ }),
256
+ transport: V,
257
+ ...N === void 0 ? {} : { maxCatchUpTicks: N }
258
+ }), Y = Object.freeze({
259
+ ...b,
260
+ requestId: p(y.requestId),
261
+ creatorSubjectId: p(y.creatorSubjectId),
262
+ seed: H,
263
+ options: C
264
+ });
265
+ if (p(`${Y.requestId}::start`).length > 150) return j("Owned room Start request leaves no bounded tick suffix");
266
+ let X = o ? J.admission.load(b) : J.admission.prepare(Y);
267
+ if (!D.isEffect(X)) return j("Owned room preparation must return the actual admission Effect");
268
+ let Z = x.captureStored(await E(X), b, T);
269
+ if (Z.initial.requestId !== Y.requestId || Z.initial.creatorSubjectId !== Y.creatorSubjectId || Z.initial.name !== u.name || Z.initial.seed !== Y.seed || Z.initial.options !== Buffer.from(U).toString("base64url") || (o ? JSON.stringify(Z) !== JSON.stringify(o.admission) : Z.adoption !== null)) return j("Owned room preparation returned an unrelated creation receipt");
270
+ let Q = async () => {
271
+ let e = J.journal.load(b);
272
+ if (!D.isEffect(e)) return j("Owned successor Journal load must return its actual Effect");
273
+ let t = await E(e), n = t === null ? null : f(u.simulation, 65536, 67108864, u.maxClients).captureStored(t, b, T);
274
+ if (JSON.stringify(n) !== JSON.stringify(o?.journal ?? null)) return j("Owned successor retained SQL journal changed during construction");
275
+ };
276
+ o && await Q();
277
+ let $ = new A(u, {
278
+ ...Y,
279
+ seed: Z.initial.seed,
280
+ options: x.optionsWire.decode(Buffer.from(Z.initial.options, "base64url"))
281
+ }, J, Z, o);
282
+ try {
283
+ if (o) {
284
+ o.journal && $.#r.stageRecovery(o.journal);
285
+ let e = J.admission.load(b);
286
+ if (!D.isEffect(e)) return j("Owned successor admission bookend must return its actual Effect");
287
+ let t = x.captureStored(await E(e), b, T);
288
+ if (JSON.stringify(t) !== JSON.stringify(Z)) return j("Owned successor metadata changed after construction");
289
+ await Q();
290
+ }
291
+ return k.add($), $;
292
+ } catch (e) {
293
+ try {
294
+ await $.disposeAsync(!0);
295
+ } catch (t) {
296
+ throw AggregateError([e, t], "Owned successor construction and withdrawal failed");
297
+ }
298
+ throw e;
299
+ }
300
+ }
301
+ publishAsync() {
302
+ try {
303
+ if (this.admitWork(), this.#v || this.#x || this.#S || this.#m) return j("Owned publication cannot overlap active supervision");
304
+ } catch (e) {
305
+ return Promise.reject(e);
306
+ }
307
+ if (this.#_) return Promise.resolve();
308
+ let e = Promise.resolve().then(async () => {
309
+ let e = {
310
+ roomId: this.id,
311
+ tenantId: this.tenantId,
312
+ epoch: this.epoch
313
+ }, t = this.#i.admission.publish(e);
314
+ if (!D.isEffect(t)) return j("Owned publication must return its actual Admission Effect");
315
+ let n = m(this.descriptor.simulation, 67108864), r = n.captureStored(await this.#i.runEffect(t), e, this.hostId);
316
+ if (this.live(), JSON.stringify(r) !== this.#t) return j("Publication returned unrelated initial SQL creation");
317
+ let i = this.#i.admission.load(e);
318
+ if (!D.isEffect(i)) return j("Owned current publication must return its actual Admission Effect");
319
+ let a = await this.#i.runEffect(i), o = n.captureStored(a, e, this.hostId);
320
+ if (JSON.stringify(o) !== JSON.stringify(r)) return j("Publication changed its current SQL creation receipt");
321
+ this.live(), this.#_ = !0;
322
+ });
323
+ return this.#v = e, e.then(() => {
324
+ this.#v = null;
325
+ }, () => {
326
+ this.#v = null;
327
+ }), e;
328
+ }
329
+ recoveryTruth() {
330
+ return this.live(), this.#e;
331
+ }
332
+ rosterOpen() {
333
+ return this.#w || !this.isPublished() || this.#m ? !1 : this.#y ? this.descriptor.lockstep.lateJoin === !0 && this.#d.size < this.descriptor.maxClients : !this.#e?.journal && !this.#b;
334
+ }
335
+ isPublished() {
336
+ return this.#_ && !this.#g;
337
+ }
338
+ outside() {
339
+ if (this.#f || this.#p) return j("Owned lockstep supervision cannot run in tick or reenter an initial strategy");
340
+ }
341
+ live() {
342
+ if (this.outside(), this.#g || this.#r.isDisposed()) throw new n({ roomId: this.id });
343
+ }
344
+ admitWork() {
345
+ if (this.live(), this.#w) return j("Lockstep owner is frozen for planned handoff");
346
+ }
347
+ connect(t) {
348
+ if (this.admitWork(), !this.#_) return j("Owned Sessions require confirmed SQL publication after Runtime installation");
349
+ if (this.#m) return j("Owned Session cleanup cannot overlap connection admission");
350
+ if (this.#b && !this.#y) return j("A durable Start attempt sealed the initial roster; it cannot acquire another Session");
351
+ if (this.#d.size >= this.descriptor.maxClients) throw new e({
352
+ budget: "lockstepOwnedSessions",
353
+ limit: this.descriptor.maxClients
354
+ });
355
+ let n = t.closeAsync;
356
+ if (n !== void 0 && typeof n != "function") return j("Native async close must be callable");
357
+ try {
358
+ let e = new y(this.#n, t, this.#i.clock, this.#i.seats, {
359
+ ...this.#i.sessionOptions,
360
+ epoch: this.epoch,
361
+ onClientMessage: (t, n, r) => {
362
+ this.receiveMessage(e, t, n, r);
363
+ }
364
+ });
365
+ return this.#d.set(e, {
366
+ session: e,
367
+ closeNative: n ? () => n.call(t, 1e3, "Owned Room closed") : null,
368
+ player: null,
369
+ nativeClosed: n === void 0
370
+ }), e;
371
+ } catch (e) {
372
+ throw e instanceof b && this.#u.add(e.releaseListeners), e;
373
+ }
374
+ }
375
+ admit(e, t) {
376
+ if (this.admitWork(), !this.#_) return j("Owned Sessions require confirmed SQL publication after Runtime installation");
377
+ if (this.#m) return j("Owned Session cleanup cannot overlap roster admission");
378
+ let n = this.#d.get(t);
379
+ if (!n || n.player || this.#b) return j("Lockstep roster requires an unbound actual owned Session");
380
+ let r = this.#r.admit(e, t);
381
+ return n.player = r, r;
382
+ }
383
+ roster() {
384
+ return this.outside(), Object.freeze([...this.#d.values()].flatMap((e) => e.player ? [e.player] : []).sort((e, t) => e.slot - t.slot));
385
+ }
386
+ async prepareInitialRoster(e = {}) {
387
+ this.admitWork();
388
+ let t = w(e);
389
+ if (this.#y) {
390
+ if (this.#x) return this.#x;
391
+ if (this.#m || this.#S || this.#v) return this.roster();
392
+ let e = Promise.resolve().then(async () => {
393
+ for (let e of this.#d.values()) {
394
+ if (e.player) continue;
395
+ let n = x(e.session), r = n.identity();
396
+ if (!r || !n.canActivate()) continue;
397
+ if (!this.#r.retains(e.session)) {
398
+ if (this.descriptor.lockstep.lateJoin !== !0 || !this.#r.lateJoinReady()) continue;
399
+ let n = this.roster(), i;
400
+ this.#p = !0;
401
+ try {
402
+ i = T({
403
+ roomId: this.id,
404
+ tenantId: this.tenantId,
405
+ epoch: this.epoch,
406
+ maxPlayers: this.descriptor.maxClients,
407
+ players: n,
408
+ subjectId: r.subjectId,
409
+ sessionId: r.sessionId
410
+ }, t.playerId);
411
+ } finally {
412
+ this.#p = !1;
413
+ }
414
+ this.live(), e.player = await this.#r.joinAsync(e.session, i, Math.max(this.descriptor.lockstep.inputDelayTicks, 1) + 1), this.live(), this.#h = !0;
415
+ break;
416
+ }
417
+ let i = await this.#r.rebindAsync(e.session);
418
+ this.live();
419
+ for (let t of this.#d.values()) t !== e && t.player?.playerId === i.playerId && (t.player = null);
420
+ e.player = i, this.#h = !0;
421
+ break;
422
+ }
423
+ return this.roster();
424
+ });
425
+ return this.#x = e, e.then(() => {
426
+ this.#x = null;
427
+ }, () => {
428
+ this.#x = null;
429
+ }), e;
430
+ }
431
+ if (this.#x) return this.#x;
432
+ if (this.#b) return this.startAsync();
433
+ if (!this.#_ || this.#m || this.#v) return this.roster();
434
+ if (this.#e?.journal) {
435
+ for (let e of this.#d.values()) {
436
+ if (e.player) continue;
437
+ let t = x(e.session);
438
+ t.identity() && t.canActivate() && (this.live(), e.player = this.#r.admitRecovered(e.session));
439
+ }
440
+ return this.roster().length === this.#e.journal.initial.players.length + (this.#e.journal.joins?.length ?? 0) ? this.startAsync() : this.roster();
441
+ }
442
+ for (let e of this.#d.values()) {
443
+ if (e.player) continue;
444
+ let n = x(e.session), r = n.identity();
445
+ if (!r || !n.canActivate()) continue;
446
+ let i = this.roster(), a;
447
+ this.#p = !0;
448
+ try {
449
+ a = T({
450
+ roomId: this.id,
451
+ tenantId: this.tenantId,
452
+ epoch: this.epoch,
453
+ maxPlayers: this.descriptor.maxClients,
454
+ players: i,
455
+ subjectId: r.subjectId,
456
+ sessionId: r.sessionId
457
+ }, t.playerId);
458
+ } finally {
459
+ this.#p = !1;
460
+ }
461
+ this.live(), this.admit(a, e.session);
462
+ }
463
+ let n = this.roster(), r;
464
+ this.#p = !0;
465
+ try {
466
+ r = E({
467
+ roomId: this.id,
468
+ tenantId: this.tenantId,
469
+ epoch: this.epoch,
470
+ maxPlayers: this.descriptor.maxClients,
471
+ players: n
472
+ }, t.start);
473
+ } finally {
474
+ this.#p = !1;
475
+ }
476
+ return this.live(), r ? this.startAsync() : n;
477
+ }
478
+ startAsync() {
479
+ try {
480
+ this.admitWork();
481
+ } catch (e) {
482
+ return Promise.reject(e);
483
+ }
484
+ return this.startAccepted();
485
+ }
486
+ startAccepted() {
487
+ try {
488
+ if (this.live(), !this.#_) return j("Owned Start requires confirmed SQL publication");
489
+ if (this.#m) return j("Owned Session cleanup cannot overlap Start");
490
+ if (this.#y || this.#x || !this.#d.size || [...this.#d.values()].some((e) => !e.player)) return j("Start needs the complete admitted owned roster");
491
+ } catch (e) {
492
+ return Promise.reject(e);
493
+ }
494
+ this.#b = !0;
495
+ let e = this.#r.startAsync().then((e) => this.#g ? j("Owned room was withdrawn during Start") : (this.#y = !0, this.#h = !0, e));
496
+ return this.#x = e, e.then(() => {
497
+ this.#x = null;
498
+ }, () => {
499
+ this.#x = null;
500
+ }), e;
501
+ }
502
+ advance() {
503
+ if (this.outside(), this.#g || this.#w || !this.#y || this.#x || this.#h || this.#S || this.#m) return 0;
504
+ this.#f = !0;
505
+ try {
506
+ return this.#h = !0, this.#r.advance();
507
+ } finally {
508
+ this.#f = !1;
509
+ }
510
+ }
511
+ messageTargets() {
512
+ return [...this.#d.values()].filter((e) => e.player && e.session.canSendLockstepMessages()).map((e) => e.session);
513
+ }
514
+ captureMessage(e, t, n) {
515
+ let r = this.#a.channels.findIndex((t) => t.name === e), i = this.#a.channels[r];
516
+ if (!i || i.direction === "client") return j("Channel is not server-sendable");
517
+ let a = i.codec.full(t);
518
+ if (O.isFailure(a)) throw a.failure;
519
+ let o = {
520
+ kind: "ServerMessage",
521
+ channelId: r,
522
+ payload: Uint8Array.from(a.success)
523
+ }, s = l(o, { maxBytes: this.#o.maxPendingWireBytes });
524
+ if (O.isFailure(s)) throw s.failure;
525
+ return {
526
+ frame: o,
527
+ bytes: s.success.byteLength,
528
+ targets: new Set(n)
529
+ };
530
+ }
531
+ admitMessages(t) {
532
+ let n = t.filter((e) => e.targets.size > 0), r = n.reduce((e, t) => e + t.bytes, 0);
533
+ if (this.#s.length + n.length > this.descriptor.budgets.maxOutboxCommands) throw new e({
534
+ budget: "lockstepMessageCommands",
535
+ limit: this.descriptor.budgets.maxOutboxCommands
536
+ });
537
+ if (this.#c + r > this.#o.maxPendingWireBytes) throw new e({
538
+ budget: "lockstepMessageBytes",
539
+ limit: this.#o.maxPendingWireBytes
540
+ });
541
+ this.#s.push(...n), this.#c += r;
542
+ }
543
+ broadcast(e, t) {
544
+ if (this.admitWork(), !this.#y || this.#l) return j("Message broadcast requires current outside-hook supervision");
545
+ this.admitMessages([this.captureMessage(e, t, this.messageTargets())]);
546
+ }
547
+ receiveMessage(t, n, r, a) {
548
+ this.admitWork();
549
+ let s = this.#d.get(t), c = this.descriptor.onMessage;
550
+ if (!this.#y || this.#l || !s?.player || !t.canSendLockstepMessages() || !c || t.id !== a.sessionId || a.roomId !== this.id || a.tenantId !== this.tenantId || a.epoch !== this.epoch || !a.subjectId) return j("Message hook requires the same current authenticated Lockstep player");
551
+ let l = [], u = !0, d = 0, f = (t, n, r) => {
552
+ if (this.live(), !u || !this.#l) return j("Message hook capabilities expire on return");
553
+ if (this.#s.length + l.length >= this.descriptor.budgets.maxOutboxCommands) throw new e({
554
+ budget: "lockstepMessageCommands",
555
+ limit: this.descriptor.budgets.maxOutboxCommands
556
+ });
557
+ let i = this.captureMessage(t, n, r);
558
+ if (this.#c + d + i.bytes > this.#o.maxPendingWireBytes) throw new e({
559
+ budget: "lockstepMessageBytes",
560
+ limit: this.#o.maxPendingWireBytes
561
+ });
562
+ d += i.bytes, l.push(i);
563
+ };
564
+ this.#l = !0;
565
+ try {
566
+ if (o(c(Object.freeze({
567
+ roomId: this.id,
568
+ tenantId: this.tenantId,
569
+ epoch: this.epoch,
570
+ client: Object.freeze({
571
+ sessionId: a.sessionId,
572
+ subjectId: a.subjectId,
573
+ tenantId: a.tenantId
574
+ }),
575
+ channel: n,
576
+ payload: i(r),
577
+ reply: (e, n) => f(e, n, [t]),
578
+ broadcast: (e, t) => f(e, t, this.messageTargets())
579
+ }))) !== void 0) return j("Message hooks must return undefined synchronously");
580
+ if (this.live(), !t.canSendLockstepMessages()) return j("Message author withdrew its actual native Session");
581
+ this.admitMessages(l);
582
+ } finally {
583
+ u = !1, this.#l = !1;
584
+ }
585
+ }
586
+ async flushMessages() {
587
+ let e = 0, t = 0;
588
+ for (; !this.#g && this.#s.length && t < this.#o.maxFlushWork;) {
589
+ let n = this.#s[0];
590
+ for (let r of n.targets) {
591
+ if (t++ >= this.#o.maxFlushWork) break;
592
+ if (!this.#d.get(r)?.player || !r.canSendLockstepMessages()) n.targets.delete(r);
593
+ else if (await r.sendLockstepMessage(n.frame), n.targets.delete(r), e++, this.#g) break;
594
+ }
595
+ if (this.#g || n.targets.size) break;
596
+ this.#s.shift(), this.#c -= n.bytes;
597
+ }
598
+ return {
599
+ writes: e,
600
+ pending: this.#s.length > 0
601
+ };
602
+ }
603
+ messageMetrics() {
604
+ return this.outside(), Object.freeze({
605
+ pendingCommands: this.#s.length,
606
+ pendingBytes: this.#c
607
+ });
608
+ }
609
+ flush() {
610
+ try {
611
+ this.admitWork();
612
+ } catch (e) {
613
+ return Promise.reject(e);
614
+ }
615
+ return this.flushAccepted();
616
+ }
617
+ flushAccepted() {
618
+ try {
619
+ if (this.live(), this.#S || this.#x || this.#m || this.#v) return j("Owned lockstep flush cannot overlap Start or another flush");
620
+ } catch (e) {
621
+ return Promise.reject(e);
622
+ }
623
+ let e = this.#r.flush().then(async (e) => {
624
+ this.#h = e.pending;
625
+ let t = await this.flushMessages();
626
+ return {
627
+ writes: e.writes + t.writes,
628
+ pending: e.pending || t.pending
629
+ };
630
+ });
631
+ return this.#S = e, e.then(() => {
632
+ this.#S = null;
633
+ }, () => {
634
+ this.#S = null;
635
+ }), e;
636
+ }
637
+ async releaseSession(e, t) {
638
+ let n = t === void 0 ? [e.session.settled()] : t ? [e.session.closeFenced()] : [e.session.close("disposed"), e.session.settled()], r = (await Promise.allSettled(n)).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
639
+ if (!e.nativeClosed) try {
640
+ await e.closeNative?.(), e.nativeClosed = !0;
641
+ } catch (e) {
642
+ r.push(e);
643
+ }
644
+ if (r.length) throw AggregateError(r, "Owned Session release remains incomplete");
645
+ this.#d.delete(e.session);
646
+ }
647
+ maintenance() {
648
+ try {
649
+ if (this.admitWork(), this.#m || this.#x || this.#S || this.#v) return j("Owned Session cleanup cannot overlap active supervision");
650
+ } catch (e) {
651
+ return Promise.reject(e);
652
+ }
653
+ let e = Promise.resolve().then(async () => {
654
+ let e = [];
655
+ for (let t of this.#u) try {
656
+ t(), this.#u.delete(t);
657
+ } catch (t) {
658
+ e.push(t);
659
+ }
660
+ for (let t of this.#d.values()) try {
661
+ if (t.session.maintenance(), !t.session.teardownReady()) continue;
662
+ await this.releaseSession(t);
663
+ } catch (t) {
664
+ e.push(t);
665
+ }
666
+ if (e.length) throw AggregateError(e, "Owned lockstep Session cleanup remains incomplete");
667
+ });
668
+ return this.#m = e, e.then(() => {
669
+ this.#m = null;
670
+ }, () => {
671
+ this.#m = null;
672
+ }), e;
673
+ }
674
+ metrics() {
675
+ return Object.freeze({
676
+ ...this.#r.metrics(),
677
+ clients: this.#n.roster().length
678
+ });
679
+ }
680
+ prepareDrain() {
681
+ try {
682
+ if (this.live(), !this.#_) return j("Drain requires confirmed Lockstep publication");
683
+ } catch (e) {
684
+ return Promise.reject(e);
685
+ }
686
+ if (this.#E) return Promise.resolve(this.#E);
687
+ if (this.#T) return this.#T;
688
+ this.#w = !0;
689
+ let e = [
690
+ this.#v,
691
+ this.#x,
692
+ this.#S,
693
+ this.#m
694
+ ].filter((e) => e !== null), t = [...this.#d.values()].map((e) => e.session), n = t.map((e) => e.quiesceForDrain()), r = Promise.resolve().then(async () => {
695
+ let r = (await Promise.allSettled([...e, ...n])).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
696
+ if (r.length) throw AggregateError(r, "Accepted Lockstep drain work remains incomplete");
697
+ if (this.live(), this.#b && !this.#y && await this.startAccepted(), (await this.flushAccepted()).pending) return j("Lockstep drain has retained bounded flush work; retry preparation");
698
+ if (await Promise.all(t.map((e) => e.settled())), t.some((e) => e.failure !== null)) return j("Lockstep Session failed before the final journal boundary");
699
+ let i = this.#r.journalBoundary(), a = {
700
+ roomId: this.id,
701
+ tenantId: this.tenantId,
702
+ epoch: this.epoch
703
+ }, o = async (e) => D.isEffect(e) ? this.#i.runEffect(D.uninterruptible(e)) : j("Drain truth requires its actual SQL Effect"), s = m(this.descriptor.simulation, 67108864).captureStored(await o(this.#i.admission.load(a)), a, this.hostId);
704
+ if (JSON.stringify(s) !== this.#t) return j("Lockstep drain creation changed its retained SQL truth");
705
+ let c = await o(this.#i.journal.load(a)), l = c === null ? null : f(this.descriptor.simulation, 65536, 67108864, this.descriptor.maxClients).captureStored(c, a, this.hostId);
706
+ return this.live(), (l?.digest ?? null) !== i.digest || (l?.ticks.length ?? 0) !== i.tick ? j("Lockstep drain SQL journal changed its retained durable frontier") : (this.#E = Object.freeze({
707
+ ...a,
708
+ mode: "lockstep",
709
+ tick: i.tick,
710
+ admissionDigest: s.digest,
711
+ journalDigest: i.digest
712
+ }), this.#E);
713
+ });
714
+ return this.#T = r, r.catch(() => {
715
+ this.#T = null;
716
+ }), r;
717
+ }
718
+ transportMetrics() {
719
+ return this.#r.transportMetrics();
720
+ }
721
+ drainOutbox() {
722
+ return this.outside(), this.#r.drainOutbox();
723
+ }
724
+ isDisposed() {
725
+ return this.#g || this.#r.isDisposed();
726
+ }
727
+ dispose() {
728
+ this.outside(), this.#g = !0, this.#e = null, this.#t = "", this.#s.length = 0, this.#c = 0, this.#n.withdraw(), this.#r.dispose();
729
+ }
730
+ disposeAsync(e = !1) {
731
+ if (this.outside(), typeof e != "boolean") return Promise.reject(new t({ detail: "Invalid actual ownership withdrawal mode" }));
732
+ if (this.#C) return this.#C;
733
+ let n = [
734
+ ...this.#T ? [this.#T] : [],
735
+ ...this.#v ? [this.#v] : [],
736
+ ...this.#x ? [this.#x] : [],
737
+ ...this.#S ? [this.#S] : [],
738
+ ...this.#m ? [this.#m] : []
739
+ ];
740
+ this.dispose();
741
+ let r = (async () => {
742
+ let t = [], r = await Promise.allSettled(n);
743
+ t.push(...r.flatMap((e) => e.status === "rejected" ? [e.reason] : []));
744
+ for (let e of this.#u) try {
745
+ e(), this.#u.delete(e);
746
+ } catch (e) {
747
+ t.push(e);
748
+ }
749
+ let i = await Promise.allSettled([this.#r.disposeAsync(), ...[...this.#d.values()].map(async (n) => {
750
+ try {
751
+ await this.releaseSession(n, e);
752
+ } catch (e) {
753
+ t.push(e);
754
+ }
755
+ })]);
756
+ if (t.push(...i.flatMap((e) => e.status === "rejected" ? [e.reason] : [])), t.length) throw AggregateError(t, "Owned lockstep room cleanup remains incomplete");
757
+ })();
758
+ return this.#C = r, r.catch(() => {
759
+ this.#C = null;
760
+ }), r;
761
+ }
762
+ };
763
+ export { N as RoomLockstepOwnedRoom, A as isRoomLockstepOwnedRoom };