@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,773 @@
1
+ import { BudgetExceeded as e, ProtocolError as t, RoomAuthoringError as n } from "./errors.js";
2
+ import { unsignedWord as r } from "./fixedWords.js";
3
+ import { simulationOwnData as i } from "./simulationAuthoring.js";
4
+ import { createSimulationOptionsCodec as a } from "./simulationOptionsWire.js";
5
+ import { createSimulationInputHistoryCodec as o } from "./simulationInputHistoryWire.js";
6
+ import { createSimulationRecoveryCodec as s } from "./simulationRecoveryWire.js";
7
+ import { assertCapturedSimulation as c } from "./simulation.js";
8
+ import { captureRoomLockstepServerOptions as l } from "./lockstepServerConfig.js";
9
+ import { RoomInputCodec as u } from "./stateCodec.js";
10
+ import { captureRoomLockstepWireRoster as d, roomLockstepStartBudgetRoster as f } from "./lockstepWireRoster.js";
11
+ import { encodeRoomFrame as p } from "./wire.js";
12
+ import { roomLockstepJournalRosterAt as m } from "./lockstepJournalPorts.js";
13
+ import { captureLockstepJournalScope as h, createLockstepJournalCodec as g, extendsRoomLockstepJournal as _, lockstepJournalIdentity as v } from "./lockstepJournalCodec.js";
14
+ import { captureRoomLockstepSessionPort as y } from "./serverSession.js";
15
+ import { captureRoomLockstepTransportLimits as b } from "./lockstepTransportConfig.js";
16
+ import { createRoomLockstepHostLoop as x } from "./lockstepHostLoop.js";
17
+ import { Effect as S, Result as C } from "effect";
18
+ //#region src/lockstepTransport.ts
19
+ function w(e) {
20
+ throw new t({ detail: e });
21
+ }
22
+ var T = (e, t) => t !== null && Object.keys(e).every((n) => e[n] === t[n]), E = class {
23
+ id;
24
+ #e;
25
+ #t;
26
+ #n;
27
+ #r;
28
+ #i;
29
+ #a;
30
+ #o;
31
+ #s;
32
+ #c;
33
+ #l;
34
+ #u;
35
+ #d = /* @__PURE__ */ new Map();
36
+ #f = /* @__PURE__ */ new WeakMap();
37
+ #p;
38
+ #m = null;
39
+ #h = null;
40
+ #g = [];
41
+ #_;
42
+ #v = null;
43
+ #y = null;
44
+ #b = null;
45
+ #x = null;
46
+ #S = /* @__PURE__ */ new Map();
47
+ #C = [];
48
+ #w = [];
49
+ #T = null;
50
+ #E = !1;
51
+ #D = !1;
52
+ #O = !1;
53
+ #k = null;
54
+ #A = null;
55
+ constructor(e, t, o, d, p, m = {}, _ = {}, y = {}) {
56
+ if (c(e), this.#e = e, this.#a = r(t), typeof p != "function") throw new n({
57
+ room: "lockstep",
58
+ detail: "Transport owner requires the actual host clock"
59
+ });
60
+ this.#i = p;
61
+ let S = i(y, [
62
+ "redundantTicks",
63
+ "maxFlushWork",
64
+ "maxPendingWireBytes",
65
+ "maxRedundancyWireBytes",
66
+ "maxPendingHashResults",
67
+ "journal"
68
+ ], []), { journal: C, ...T } = S, E = b(T);
69
+ if (this.#c = h(d), this.#_ = g(e, 65536, 67108864, 64), Object.hasOwn(S, "journal")) {
70
+ let e = i(S.journal, [
71
+ "service",
72
+ "runEffect",
73
+ "startRequestId"
74
+ ], [
75
+ "service",
76
+ "runEffect",
77
+ "startRequestId"
78
+ ]), t = i(e.service, [
79
+ "initialize",
80
+ "append",
81
+ "join",
82
+ "load",
83
+ "adopt",
84
+ "exportSubject",
85
+ "erase"
86
+ ], [
87
+ "initialize",
88
+ "append",
89
+ "load",
90
+ "adopt",
91
+ "exportSubject",
92
+ "erase"
93
+ ]);
94
+ (typeof e.runEffect != "function" || Object.values(t).some((e) => typeof e != "function")) && w("Durable transport requires a complete Journal capability and actual Effect runner");
95
+ let n = v(e.startRequestId);
96
+ n.length > 150 && w("Journal start request leaves no bounded immutable tick suffix"), this.#l = Object.freeze({
97
+ service: Object.freeze(Object.fromEntries(Object.entries(t).map(([t, n]) => [t, n.bind(e.service)]))),
98
+ runEffect: e.runEffect,
99
+ startRequestId: n
100
+ });
101
+ } else this.#l = null;
102
+ let D = l(m);
103
+ this.#s = Object.freeze(E), this.#p = D.limits.maxReplayTicks, this.#u = D.limits.hashHistoryTicks, this.#o = a(e).encode(o), this.#n = new u(e.definition.input, e.inputCodec.limits), this.#r = s(e, {
104
+ maxBytes: this.#s.maxPendingWireBytes,
105
+ maxTicks: 4096
106
+ });
107
+ let O = Object.getOwnPropertyDescriptor(m, "maxPlayers");
108
+ (O && (!O.enumerable || !("value" in O)) || !O && "maxPlayers" in m) && w("Start player budget requires own data without accessors"), this.frameBytes({
109
+ kind: "LsStart",
110
+ startTick: 0,
111
+ seed: this.#a,
112
+ options: this.#o,
113
+ serverTimeMs: 2 ** 53 - 1,
114
+ localPlayerId: 4294967295,
115
+ roster: f(O ? O.value : 8)
116
+ }), this.#t = x(e, t, o, d, p, m, _), this.id = this.#t.id;
117
+ }
118
+ live() {
119
+ if (this.#D || this.#t.isDisposed()) return w("Lockstep transport owner is withdrawn");
120
+ }
121
+ operation(e) {
122
+ if (this.#O) return w("Lockstep transport supervision cannot reenter active work");
123
+ this.#O = !0;
124
+ try {
125
+ return e();
126
+ } finally {
127
+ this.#O = !1;
128
+ }
129
+ }
130
+ current(e) {
131
+ if (!T(e.evidence, e.port.identity()) || e.port.inputSchemaHash() !== this.#n.schemaHash) return w("Lockstep transport requires the same current SQL-admitted Session and input layout");
132
+ }
133
+ deliverable(e) {
134
+ return e.port.identity() !== null && (this.current(e), !0);
135
+ }
136
+ frameBytes(e) {
137
+ let t = p(e, {
138
+ maxBytes: this.#s.maxPendingWireBytes,
139
+ maxInputs: 4096
140
+ });
141
+ if (C.isFailure(t)) throw t.failure;
142
+ return t.success.byteLength;
143
+ }
144
+ admit(e, t) {
145
+ return this.operation(() => {
146
+ if (this.live(), this.#E || this.#b) return w("Transport roster cannot admit after start or a durable start attempt");
147
+ let n = y(t), r = n.identity();
148
+ if (!r || !n.canActivate()) return w("Transport needs a live unbound welcomed player");
149
+ let i = this.#t.admit(e, t), a = Object.freeze({
150
+ actual: t,
151
+ port: n,
152
+ evidence: r,
153
+ player: i
154
+ });
155
+ return this.#S.set(i.playerId, a), i;
156
+ });
157
+ }
158
+ stageRecovery(e) {
159
+ this.operation(() => {
160
+ if (this.live(), this.#E || this.#S.size || this.#v) return w("Recovery requires a fresh private transport owner");
161
+ let t = this.#_.captureStored(e, this.#c);
162
+ if (!this.#l || !t.adoption || t.adoption.priorEpoch !== this.#c.epoch - 1 || t.initial.seed !== this.#a || t.initial.options !== Buffer.from(this.#o).toString("base64url") || t.initial.requestId !== this.#l.startRequestId) return w("Recovery journal changed actual initial ownership");
163
+ let n = this.#t.serverRole === "relay" || t.ticks.length <= this.#t.roleMetrics().refereeLagTicks, r = n && t.ticks.length ? this.inputHistory(t, this.#p) : null, i = d(m(t, t.ticks.length).map((e) => ({
164
+ slot: e.slot,
165
+ playerId: e.playerId
166
+ })));
167
+ if (n) for (let e of i) this.frameBytes({
168
+ kind: "LsStart",
169
+ startTick: t.ticks.length,
170
+ seed: this.#a,
171
+ options: this.#o,
172
+ serverTimeMs: 2 ** 53 - 1,
173
+ roster: i,
174
+ localPlayerId: e.playerId,
175
+ ...r ? { history: r } : {}
176
+ });
177
+ this.#v = {
178
+ journal: t,
179
+ history: r,
180
+ cursor: 0,
181
+ sealed: !1,
182
+ replayed: !1
183
+ }, this.#y = t;
184
+ });
185
+ }
186
+ admitRecovered(e) {
187
+ return this.operation(() => {
188
+ this.live();
189
+ let t = this.#v;
190
+ if (!t || this.#E || this.#b) return w("Recovered roster is not awaiting genuine current Sessions");
191
+ let n = y(e), r = n.identity(), i = r ? m(t.journal, 2 ** 53 - 1).find((e) => e.sessionId === r.sessionId && e.subjectId === r.subjectId) : void 0;
192
+ if (!i || !r || !n.canActivate() || this.#S.has(i.playerId)) return w("Recovery requires its exact retained Subject/Seat with actual current Welcome");
193
+ let a = t.journal.joins?.some((e) => e.playerId === i.playerId) ?? !1 ? Object.freeze({
194
+ slot: i.slot,
195
+ playerId: i.playerId
196
+ }) : this.#t.admitAt({
197
+ slot: i.slot,
198
+ playerId: i.playerId
199
+ }, e), o = Object.freeze({
200
+ actual: e,
201
+ port: n,
202
+ evidence: r,
203
+ player: a
204
+ });
205
+ return this.#S.set(a.playerId, o), a;
206
+ });
207
+ }
208
+ rebindAsync(e) {
209
+ if (this.#m || this.#h || this.#x || this.#k || this.#O) return Promise.reject(new t({ detail: "Reconnect cannot overlap active transport supervision" }));
210
+ let n, r, i, a, o = this.#l, s = this.#y;
211
+ if (!o || !s) return Promise.reject(new t({ detail: "Reconnect requires a confirmed SQL Journal capability" }));
212
+ try {
213
+ this.operation(() => {
214
+ if (this.live(), !this.#E || !o || !s || this.#T || this.#g.length || this.#t.roleMetrics().pendingDeliveries > 0 || this.#w.length || s.ticks.length !== this.#t.metrics().tick) return w("Reconnect requires a fully confirmed durable current frontier");
215
+ let t = y(e), i = t.identity(), a = i ? [...this.#S.values()].find((e) => e.evidence.sessionId === i.sessionId && e.evidence.subjectId === i.subjectId) : void 0;
216
+ if (!i || !a || a.port.identity() !== null || !t.canActivate()) return w("Reconnect requires a withdrawn retained Seat and genuine current Welcome");
217
+ let c = m(s, 2 ** 53 - 1).find((e) => e.sessionId === i.sessionId && e.subjectId === i.subjectId);
218
+ if (!c || c.slot !== a.player.slot || c.playerId !== a.player.playerId) return w("Reconnect changed retained SQL player identity");
219
+ n = Object.freeze({
220
+ actual: e,
221
+ port: t,
222
+ evidence: i,
223
+ player: a.player
224
+ }), r = a;
225
+ });
226
+ } catch (e) {
227
+ return Promise.reject(e);
228
+ }
229
+ let c = async () => {
230
+ for (let e = 0; e < 2; e++) {
231
+ let t = this.#_.captureStored(await this.runJournal(o.service.load(this.#c)), this.#c, s.hostId);
232
+ if (this.live(), t.digest !== s.digest || this.#y !== s || this.#t.metrics().tick !== s.ticks.length) return w("Reconnect lost its exact current SQL journal frontier");
233
+ if (this.current(n), !n.port.canActivate() || r.port.identity() !== null) return w("Reconnect admission changed while confirming SQL");
234
+ e === 0 && this.operation(() => {
235
+ i = this.bootstrap(s, n.player.playerId), a = this.frameBytes(i);
236
+ });
237
+ }
238
+ return this.operation(() => {
239
+ if (this.live(), this.#T || this.#S.get(r.player.playerId) !== r) return w("Reconnect lost its retained delivery owner");
240
+ let t = this.#t.rebind(e);
241
+ return n.port.activate((e) => {
242
+ this.receive(n, e);
243
+ }, () => this.#t.metrics().tick), r.port.withdraw(), this.#S.set(t.playerId, n), this.#b &&= Object.freeze(this.#b.map((e) => e === r ? n : e)), this.#T = {
244
+ frame: i,
245
+ bytes: a,
246
+ targets: Object.freeze([n]),
247
+ next: 0
248
+ }, this.#g.push(...this.futureJoins(s, [n])), t;
249
+ });
250
+ };
251
+ return this.#m = Promise.resolve().then(c).finally(() => {
252
+ this.#m = null;
253
+ }), this.#m;
254
+ }
255
+ inputHistory(e, t) {
256
+ let n = e.ticks.length, r = (e.joins ?? []).filter((e) => e.tick <= n);
257
+ return o(this.#e, {
258
+ maxBytes: this.#s.maxPendingWireBytes,
259
+ maxTicks: t,
260
+ maxPlayers: 64
261
+ }).encode({
262
+ fromTick: 0,
263
+ playerIds: m(e, n).map((e) => e.playerId),
264
+ ...r.length ? { joins: r.map((e) => ({
265
+ playerId: e.playerId,
266
+ tick: e.tick
267
+ })) } : {},
268
+ inputs: e.ticks.map((t) => {
269
+ let n = m(e, t.tick);
270
+ return {
271
+ tick: t.tick,
272
+ inputs: t.inputs.map((e, t) => ({
273
+ playerId: n[t].playerId,
274
+ input: this.#_.decodeInput(e)
275
+ }))
276
+ };
277
+ })
278
+ });
279
+ }
280
+ futureJoins(e, t) {
281
+ return (e.joins ?? []).filter((t) => t.tick > e.ticks.length).map((e) => {
282
+ let n = {
283
+ kind: "LsJoin",
284
+ tick: e.tick,
285
+ slot: e.slot,
286
+ playerId: e.playerId
287
+ };
288
+ return {
289
+ frame: n,
290
+ bytes: this.frameBytes(n),
291
+ targets: Object.freeze([...t]),
292
+ next: 0
293
+ };
294
+ });
295
+ }
296
+ bootstrap(e, t) {
297
+ if (this.live(), e.ticks.length !== this.#t.metrics().tick) return w("Bootstrap requires the exact confirmed actual authority frontier");
298
+ let n = this.#t.roleMetrics().refereeTick, r = n !== null && n > 0 ? this.#t.recovery() : null;
299
+ if (r) {
300
+ if ((e.joins ?? []).some((t) => t.tick > r.snapshot.tick && t.tick <= e.ticks.length)) return w("Snapshot bootstrap waits until the referee passes the latest late join");
301
+ for (let t of [{
302
+ tick: r.snapshot.tick,
303
+ inputs: r.inputs
304
+ }, ...r.continuation ?? []]) {
305
+ let n = e.ticks[t.tick - 1], r = m(e, t.tick);
306
+ if (!n || t.inputs.length !== r.length) return w("Snapshot bootstrap needs its exact confirmed SQL matrix base/tail");
307
+ for (let e of t.inputs) {
308
+ let t = r.findIndex((t) => t.playerId === e.playerId), i = this.#n.full(e.input);
309
+ if (t < 0 || C.isFailure(i) || this.#_.captureInput(i.success) !== n.inputs[t]) return w("Snapshot bootstrap changed actual SQL intentions");
310
+ }
311
+ }
312
+ }
313
+ let i = r ? this.#r.encode(r) : void 0, a = this.#v?.journal.digest === e.digest ? this.#v : null, o = !r && e.ticks.length ? a?.history?.slice() ?? this.inputHistory(e, this.#p) : void 0, s = Math.floor(this.#i());
314
+ return !Number.isSafeInteger(s) || s < 0 ? w("Bootstrap needs the actual monotonic host time") : {
315
+ kind: "LsStart",
316
+ startTick: e.ticks.length,
317
+ seed: this.#a,
318
+ options: this.#o.slice(),
319
+ serverTimeMs: s,
320
+ roster: d(m(e, e.ticks.length).map((e) => ({
321
+ slot: e.slot,
322
+ playerId: e.playerId
323
+ }))),
324
+ localPlayerId: t,
325
+ ...o ? { history: o } : {},
326
+ ...i ? { snapshot: i } : {}
327
+ };
328
+ }
329
+ start() {
330
+ return this.operation(() => {
331
+ if (this.live(), this.#l) return w("Durable transport must await startAsync SQL admission");
332
+ if (this.#E) return w("Lockstep transport is already started");
333
+ let e = [...this.#S.values()];
334
+ if (!e.length) return w("Lockstep start requires players");
335
+ for (let t of e) if (this.current(t), !t.port.canActivate()) return w("Lockstep Session was bound by another owner");
336
+ return this.queueStart(e);
337
+ });
338
+ }
339
+ queueStart(e, t = !1, n) {
340
+ let r = n?.serverTimeMs ?? Math.floor(this.#i());
341
+ if (!Number.isSafeInteger(r) || r < 0) return w("Invalid host start time");
342
+ let i = d(e.map((e) => ({
343
+ slot: e.player.slot,
344
+ playerId: e.player.playerId
345
+ }))), a = n ?? (t ? this.bootstrap(this.#v.journal, e[0].player.playerId) : {
346
+ kind: "LsStart",
347
+ startTick: 0,
348
+ seed: this.#a,
349
+ options: this.#o.slice(),
350
+ serverTimeMs: r,
351
+ roster: i,
352
+ localPlayerId: e[0].player.playerId
353
+ }), o = Math.max(...e.map((e) => this.frameBytes({
354
+ ...a,
355
+ localPlayerId: e.player.playerId
356
+ })));
357
+ for (let t of e) if (this.current(t), !t.port.canActivate()) return w("Lockstep start lost its current Session");
358
+ let s = t ? Object.freeze(e.map((e) => e.player)) : this.#t.seal();
359
+ t || this.#t.finishBootstrap();
360
+ for (let t of e) if (this.current(t), !t.port.canActivate()) return w("Lockstep seal lost its unbound Session");
361
+ for (let t of e) t.port.activate((e) => {
362
+ this.receive(t, e);
363
+ }, () => this.#t.metrics().tick);
364
+ return this.#E = !0, this.#T = {
365
+ frame: a,
366
+ bytes: o,
367
+ targets: Object.freeze(e),
368
+ next: 0
369
+ }, s;
370
+ }
371
+ startAsync() {
372
+ if (!this.#l) return Promise.resolve().then(() => this.start());
373
+ if (this.#x || this.#O || this.#E) return Promise.reject(new t({ detail: "Durable start cannot overlap or restart a sealed owner" }));
374
+ let e = this.#l;
375
+ try {
376
+ this.operation(() => {
377
+ this.live();
378
+ let e = this.#b ?? Object.freeze([...this.#S.values()]);
379
+ if (!e.length) return w("Durable start requires actual players");
380
+ for (let t of e) if (this.current(t), !t.port.canActivate()) return w("Durable start lost an unbound current Session");
381
+ this.#b = e;
382
+ });
383
+ } catch (e) {
384
+ return Promise.reject(e);
385
+ }
386
+ let n = async () => {
387
+ if (this.#v) return this.startRecovered();
388
+ let t = this.#b;
389
+ this.live();
390
+ let n = this.#_.optionsWire.decode(this.#o);
391
+ this.live();
392
+ let r = e.service.initialize({
393
+ ...this.#c,
394
+ requestId: e.startRequestId,
395
+ seed: this.#a,
396
+ options: n,
397
+ players: t.map((e) => ({
398
+ ...e.player,
399
+ actualSession: e.actual
400
+ }))
401
+ }), i = await this.runJournal(r);
402
+ return this.operation(() => {
403
+ this.live();
404
+ let n = this.#_.captureStored(i, this.#c);
405
+ if (n.ownerEpoch !== this.#c.epoch || n.adoption !== null || n.ticks.length || n.initial.requestId !== e.startRequestId || n.initial.seed !== this.#a || n.initial.options !== Buffer.from(this.#o).toString("base64url") || n.initial.players.length !== t.length) return w("Durable start receipt is not the exact new SQL seed/roster");
406
+ for (let e = 0; e < t.length; e++) {
407
+ let r = t[e], i = n.initial.players[e];
408
+ if (this.current(r), i.slot !== r.player.slot || i.playerId !== r.player.playerId || i.subjectId !== r.evidence.subjectId || i.sessionId !== r.evidence.sessionId) return w("Durable start receipt changed actual admitted identity");
409
+ }
410
+ return this.#y = n, this.queueStart(t);
411
+ });
412
+ };
413
+ return this.#x = Promise.resolve().then(n).finally(() => {
414
+ this.#x = null;
415
+ }), this.#x;
416
+ }
417
+ async startRecovered() {
418
+ let e = this.#v, t = this.#b, n = this.#l, r = m(e.journal, 2 ** 53 - 1).map((e) => t.find((t) => t.player.playerId === e.playerId));
419
+ if (r.length !== t.length || r.some((e) => !e)) return w("Recovery Start requires every retained genuine Session");
420
+ let i = r, a = async () => {
421
+ if (this.#_.captureStored(await this.runJournal(n.service.load(this.#c)), this.#c, e.journal.hostId).digest !== e.journal.digest) return w("Recovery Start lost its actual current SQL journal");
422
+ for (let e of i) if (this.current(e), !e.port.canActivate()) return w("Recovery Start lost its actual unbound Session");
423
+ };
424
+ if (await a(), this.live(), !e.sealed) {
425
+ this.#t.seal();
426
+ for (let t of e.journal.joins ?? []) this.#t.join({
427
+ slot: t.slot,
428
+ playerId: t.playerId
429
+ }, i.find((e) => e.player.playerId === t.playerId).actual, t.tick);
430
+ e.sealed = !0;
431
+ }
432
+ for (; e.cursor < e.journal.ticks.length; e.cursor++) {
433
+ let t = e.journal.ticks[e.cursor], n = m(e.journal, t.tick);
434
+ this.#t.replayMatrix(t.tick, n.map((e) => i.find((t) => t.player.playerId === e.playerId).actual), t.inputs.map((e) => Uint8Array.from(Buffer.from(e, "base64url"))));
435
+ }
436
+ e.replayed ||= (this.#t.finishBootstrap(), !0);
437
+ let o = this.operation(() => this.bootstrap(e.journal, i[0].player.playerId));
438
+ return this.frameBytes(o), await a(), this.live(), this.operation(() => {
439
+ let t = this.queueStart(i, !0, o);
440
+ return this.#g.push(...this.futureJoins(e.journal, i)), t;
441
+ });
442
+ }
443
+ retains(e) {
444
+ let t = y(e).identity();
445
+ return t !== null && [...this.#S.values()].some((e) => e.evidence.sessionId === t.sessionId && e.evidence.subjectId === t.subjectId);
446
+ }
447
+ lateJoinReady() {
448
+ let e = this.#y;
449
+ if (this.#D || !this.#E || !this.#l?.service.join || !e || this.#m || this.#h || this.#x || this.#k || this.#O || this.#T || this.#g.length || this.#t.roleMetrics().pendingDeliveries > 0 || this.#w.length || e.ticks.length !== this.#t.metrics().tick) return !1;
450
+ let t = this.#t.roleMetrics().refereeTick;
451
+ return t === null || t === 0 || !(e.joins ?? []).some((e) => e.tick > t);
452
+ }
453
+ joinAsync(e, n, i) {
454
+ if (this.#m || this.#h || this.#x || this.#k || this.#O) return Promise.reject(new t({ detail: "Late join cannot overlap active transport supervision" }));
455
+ let a = this.#l, o = this.#y, s = a?.service.join;
456
+ if (!a || !o || !s) return Promise.reject(new t({ detail: "Late join requires a confirmed SQL Journal with join support" }));
457
+ let c, l, u, d;
458
+ try {
459
+ this.operation(() => {
460
+ if (this.live(), !this.#E || this.#T || this.#g.length || this.#t.roleMetrics().pendingDeliveries > 0 || this.#w.length || o.ticks.length !== this.#t.metrics().tick) return w("Late join requires a fully confirmed durable current frontier");
461
+ if (!Number.isSafeInteger(i) || i < 1 || i > 4096) return w("Late join lead must be 1..4096 ticks");
462
+ let t = y(e), a = t.identity(), s = m(o, 2 ** 53 - 1);
463
+ if (!a || !t.canActivate() || s.some((e) => e.sessionId === a.sessionId || e.playerId === n)) return w("Late join requires a new player with a genuine current Welcome");
464
+ let f = 0;
465
+ for (; s.some((e) => e.slot === f);) f++;
466
+ d = o.ticks.length + i, c = Object.freeze({
467
+ actual: e,
468
+ port: t,
469
+ evidence: a,
470
+ player: Object.freeze({
471
+ slot: f,
472
+ playerId: r(n)
473
+ })
474
+ }), l = this.bootstrap(o, c.player.playerId), u = this.frameBytes(l);
475
+ });
476
+ } catch (e) {
477
+ return Promise.reject(e);
478
+ }
479
+ let f = async () => {
480
+ let t = await this.runJournal(s({
481
+ ...this.#c,
482
+ requestId: `${a.startRequestId}::join:${c.player.playerId}`,
483
+ tick: d,
484
+ player: {
485
+ ...c.player,
486
+ actualSession: e
487
+ }
488
+ }));
489
+ return this.operation(() => {
490
+ this.live();
491
+ let n = this.#_.captureStored(t, this.#c, o.hostId), r = n.joins?.find((e) => e.playerId === c.player.playerId);
492
+ if (this.#y !== o || this.#T || this.#g.length || this.#t.metrics().tick !== o.ticks.length || JSON.stringify(n.ticks) !== JSON.stringify(o.ticks) || JSON.stringify(n.initial) !== JSON.stringify(o.initial) || !r || r.tick !== d || r.slot !== c.player.slot || r.subjectId !== c.evidence.subjectId || r.sessionId !== c.evidence.sessionId) return w("Late join receipt changed the confirmed frontier or admitted identity");
493
+ if (this.current(c), !c.port.canActivate()) return w("Late join lost its unbound Session");
494
+ let i = Object.freeze([...this.#S.values()].filter((e) => this.deliverable(e))), a = this.#t.join(c.player, e, d);
495
+ return c.port.activate((e) => {
496
+ this.receive(c, e);
497
+ }, () => this.#t.metrics().tick), this.#S.set(a.playerId, c), this.#y = n, this.#T = {
498
+ frame: l,
499
+ bytes: u,
500
+ targets: Object.freeze([c]),
501
+ next: 0
502
+ }, this.#g.push(...this.futureJoins(n, [c]).map((e) => e.frame.playerId === a.playerId ? {
503
+ ...e,
504
+ targets: Object.freeze([...i, c])
505
+ } : e)), a;
506
+ });
507
+ };
508
+ return this.#h = Promise.resolve().then(f).finally(() => {
509
+ this.#h = null;
510
+ }), this.#h;
511
+ }
512
+ runJournal(e) {
513
+ return !this.#l || !S.isEffect(e) ? Promise.reject(new t({ detail: "Journal must return an actual Effect" })) : this.#l.runEffect(S.uninterruptible(e));
514
+ }
515
+ receive(t, n) {
516
+ this.operation(() => {
517
+ if (this.live(), this.current(t), n.kind === "LsInput") {
518
+ this.#t.submit(t.actual, n.firstTick, n.inputs);
519
+ return;
520
+ }
521
+ if (this.#t.serverRole === "relay") return n.tick < 1 || n.tick > this.#t.metrics().tick ? w("Relay hash is outside actual confirmed input history") : void 0;
522
+ if (this.#w.length >= this.#s.maxPendingHashResults) throw new e({
523
+ budget: "lockstepWireHashResults",
524
+ limit: this.#s.maxPendingHashResults
525
+ });
526
+ let r = `${n.tick}/${t.player.playerId}`;
527
+ if (!this.#d.has(r) && this.#d.size >= this.#s.maxPendingHashResults) throw new e({
528
+ budget: "lockstepWireHashSources",
529
+ limit: this.#s.maxPendingHashResults
530
+ });
531
+ let i = this.#t.submitHash(t.actual, n.tick, {
532
+ hi: n.hi,
533
+ lo: n.lo
534
+ });
535
+ i._tag === "pending" && this.#d.set(r, Object.freeze({
536
+ tick: n.tick,
537
+ peer: t
538
+ })), i._tag === "desync" && (this.#f.set(i, t), this.#w.push(i));
539
+ });
540
+ }
541
+ advance() {
542
+ return this.operation(() => (this.live(), this.#m || this.#h ? 0 : this.#t.advance()));
543
+ }
544
+ prepareNext() {
545
+ return this.operation(() => {
546
+ if (this.live(), this.#T) return !0;
547
+ let t = this.#g.shift();
548
+ if (t) return this.#T = t, !0;
549
+ let n = this.#t.nextDelivery();
550
+ if (n) {
551
+ let t = Object.freeze([...this.#S.values()].filter((e) => this.deliverable(e))), r, i;
552
+ if (n._tag === "relayed") {
553
+ let t = n.inputs.map((e) => {
554
+ let t = this.#n.full(e.input);
555
+ if (C.isFailure(t)) throw t.failure;
556
+ return t.success;
557
+ }), a = Object.freeze({
558
+ players: n.players,
559
+ inputs: Object.freeze(t)
560
+ }), o = {
561
+ tick: n.tick,
562
+ matrix: a,
563
+ bytes: t.reduce((e, t) => e + t.length, 8)
564
+ };
565
+ if (i = [...this.#C, o].slice(-this.#s.redundantTicks), i.some((e, t) => t > 0 && e.tick !== i[t - 1].tick + 1)) return w("Redundant authority matrices are not contiguous");
566
+ if (i.reduce((e, t) => e + t.bytes, 0) > this.#s.maxRedundancyWireBytes) throw new e({
567
+ budget: "lockstepWireRedundancy",
568
+ limit: this.#s.maxRedundancyWireBytes
569
+ });
570
+ r = {
571
+ kind: "LsInputs",
572
+ firstTick: i[0].tick,
573
+ matrices: Object.freeze(i.map((e) => e.matrix))
574
+ };
575
+ } else r = {
576
+ kind: "LsStall",
577
+ waitingFor: n.waitingFor
578
+ };
579
+ let a = this.frameBytes(r);
580
+ for (let e of t) this.current(e);
581
+ let o = n._tag === "relayed" && this.#l ? Object.freeze({
582
+ ...this.#c,
583
+ requestId: `${this.#l.startRequestId}::tick:${n.tick}`,
584
+ tick: n.tick,
585
+ inputs: Object.freeze(i[i.length - 1].matrix.inputs.map((e) => e.slice()))
586
+ }) : void 0;
587
+ return this.#T = {
588
+ frame: r,
589
+ bytes: a,
590
+ targets: t,
591
+ next: 0,
592
+ prepared: {
593
+ delivery: n,
594
+ ...i ? { history: i } : {},
595
+ ...o ? { append: o } : {}
596
+ }
597
+ }, !0;
598
+ }
599
+ let r = this.#t.roleMetrics().refereeTick;
600
+ if (r !== null) for (let [e, t] of this.#d) t.tick <= r - this.#u && this.#d.delete(e);
601
+ if (!this.#w.length && this.#t.serverRole !== "relay") {
602
+ let e = this.#t.comparePendingHashes(1);
603
+ if (e.length) {
604
+ for (let t of e) {
605
+ let e = t._tag === "desync" ? `${t.incident.tick}/${t.incident.playerId}` : `${t.tick}/${t.playerId}`, n = this.#d.get(e);
606
+ if (t._tag === "desync") {
607
+ if (!n) return w("Delayed hash result lost its actual Session provenance");
608
+ this.#f.set(t, n.peer), this.#w.push(t);
609
+ }
610
+ this.#d.delete(e);
611
+ }
612
+ if (!this.#w.length) return !0;
613
+ }
614
+ }
615
+ let i = this.#w[0];
616
+ if (!i || i._tag !== "desync") return !1;
617
+ let a = this.#f.get(i);
618
+ if (!a) return w("Desync result has no actual submitted Session provenance");
619
+ if (!this.deliverable(a)) return this.#w.shift(), !0;
620
+ let o = i.action === "resync" ? {
621
+ kind: "LsDesync",
622
+ tick: i.incident.tick,
623
+ action: "resync",
624
+ snapshot: this.#r.encode({
625
+ snapshot: i.snapshot,
626
+ inputs: i.inputs,
627
+ continuation: i.continuation
628
+ })
629
+ } : {
630
+ kind: "LsDesync",
631
+ tick: i.incident.tick,
632
+ action: i.action
633
+ }, s = this.frameBytes(o);
634
+ return this.current(a), this.#w.shift(), this.#T = {
635
+ frame: o,
636
+ bytes: s,
637
+ targets: Object.freeze([a]),
638
+ next: 0
639
+ }, !0;
640
+ });
641
+ }
642
+ async commitPrepared(e) {
643
+ let t = e.prepared;
644
+ if (t) {
645
+ if (t.append && !t.durable) {
646
+ this.live();
647
+ let n = this.#y;
648
+ if (!n || !this.#l) return w("No initialized SQL input journal");
649
+ let r = await this.runJournal(this.#l.service.append({
650
+ ...t.append,
651
+ inputs: Object.freeze(t.append.inputs.map((e) => e.slice()))
652
+ }));
653
+ this.operation(() => {
654
+ if (this.live(), this.#T !== e) return w("Journal completion lost its retained delivery owner");
655
+ let i = this.#_.captureStored(r, this.#c, n.hostId), a = t.append.tick, o = i.ticks[a - 1];
656
+ if (i.ticks.length !== a || JSON.stringify(i.initial) !== JSON.stringify(n.initial) || JSON.stringify(i.adoption) !== JSON.stringify(n.adoption) || !_(i, n) || !o || o.requestId !== t.append.requestId || o.inputs.length !== t.append.inputs.length || o.inputs.some((e, n) => e !== this.#_.captureInput(t.append.inputs[n]))) return w("Journal receipt changed its immutable seed/prefix or current matrix");
657
+ this.#y = i, t.durable = !0;
658
+ });
659
+ }
660
+ this.operation(() => {
661
+ if (this.live(), this.#T !== e) return w("Prepared delivery lost its owner");
662
+ for (let t of e.targets) this.deliverable(t);
663
+ this.#t.consumeDelivery(t.delivery), t.history && (this.#C = t.history), delete e.prepared;
664
+ });
665
+ }
666
+ }
667
+ flush() {
668
+ if (this.#k || this.#m || this.#h || this.#O) return Promise.reject(new t({ detail: "Lockstep flush cannot overlap or reenter supervision" }));
669
+ if (this.live(), !this.#E) return Promise.resolve(Object.freeze({
670
+ writes: 0,
671
+ pending: !1
672
+ }));
673
+ let e = async () => {
674
+ let e = 0;
675
+ for (let t = 0; t < this.#s.maxFlushWork && !this.#D && (this.#T || this.prepareNext()); t++) {
676
+ let t = this.#T;
677
+ if (!t) continue;
678
+ if (await this.commitPrepared(t), this.#D) break;
679
+ let n = t.targets[t.next];
680
+ if (!n) this.#T = null;
681
+ else if (!this.deliverable(n)) t.next++, t.next === t.targets.length && (this.#T = null);
682
+ else {
683
+ if (await n.port.send(t.frame.kind === "LsStart" ? {
684
+ ...t.frame,
685
+ localPlayerId: n.player.playerId
686
+ } : t.frame), this.#D) break;
687
+ this.deliverable(n), t.next++, e++, t.next === t.targets.length && (this.#T = null);
688
+ }
689
+ }
690
+ return Object.freeze({
691
+ writes: e,
692
+ pending: this.#T !== null || this.#g.length > 0 || this.#t.roleMetrics().pendingDeliveries > 0 || this.#w.length > 0
693
+ });
694
+ };
695
+ return this.#k = Promise.resolve().then(e).finally(() => {
696
+ this.#k = null;
697
+ }), this.#k;
698
+ }
699
+ retryFault() {
700
+ this.operation(() => {
701
+ this.live(), this.#t.retryFault();
702
+ });
703
+ }
704
+ drainOutbox() {
705
+ return this.#t.drainOutbox();
706
+ }
707
+ metrics() {
708
+ return this.#t.metrics();
709
+ }
710
+ journalBoundary() {
711
+ if (this.live(), !this.#l || this.#O || this.#k || this.#x || this.#m || this.#h || this.#T || this.#g.length || this.#t.roleMetrics().pendingDeliveries || this.#w.length || this.#b && !this.#E) return w("Lockstep journal boundary requires completed retained supervision");
712
+ let e = this.#y?.ticks.length ?? 0;
713
+ return this.#E && e !== this.#t.metrics().tick ? w("Lockstep journal does not cover the actual simulated frontier") : Object.freeze({
714
+ digest: this.#y?.digest ?? null,
715
+ tick: e
716
+ });
717
+ }
718
+ transportMetrics() {
719
+ return Object.freeze({
720
+ ...this.#t.roleMetrics(),
721
+ started: this.#E,
722
+ disposed: this.#D,
723
+ pendingWireBytes: this.#T?.bytes ?? 0,
724
+ pendingTargets: this.#T ? this.#T.targets.length - this.#T.next : 0,
725
+ redundancyTicks: this.#C.length,
726
+ redundancyWireBytes: this.#C.reduce((e, t) => e + t.bytes, 0),
727
+ pendingHashResults: this.#w.length,
728
+ pendingHashSources: this.#d.size,
729
+ reconnecting: this.#m !== null,
730
+ joining: this.#h !== null,
731
+ queuedFrames: this.#g.length,
732
+ flushing: this.#k !== null,
733
+ journaled: this.#l !== null,
734
+ journalTick: this.#y?.ticks.length ?? 0,
735
+ initializing: this.#x !== null
736
+ });
737
+ }
738
+ exportSubject(e, t) {
739
+ return this.operation(() => this.#t.exportSubject(e, t));
740
+ }
741
+ async eraseSubject(e, t) {
742
+ let n = this.operation(() => this.#t.eraseSubject(e, t));
743
+ return n && await this.disposeAsync(), n;
744
+ }
745
+ release() {
746
+ if (!this.#D) {
747
+ this.#D = !0;
748
+ for (let e of this.#S.values()) e.port.withdraw();
749
+ this.#v?.history?.fill(0), this.#v = null, this.#t.dispose(), this.#S.clear(), this.#C = [], this.#w = [], this.#d.clear(), this.#f = /* @__PURE__ */ new WeakMap(), this.#T = null, this.#g = [], this.#y = null, this.#b = null, this.#o.fill(0);
750
+ }
751
+ }
752
+ dispose() {
753
+ this.operation(() => this.release());
754
+ }
755
+ disposeAsync() {
756
+ if (this.#A) return this.#A;
757
+ let e = [
758
+ this.#k ?? Promise.resolve(),
759
+ this.#x ?? Promise.resolve(),
760
+ this.#m ?? Promise.resolve(),
761
+ this.#h ?? Promise.resolve()
762
+ ];
763
+ return this.dispose(), this.#A = (async () => {
764
+ let t = (await Promise.allSettled(e)).find((e) => e.status === "rejected");
765
+ if (t?.status === "rejected") throw t.reason;
766
+ })(), this.#A;
767
+ }
768
+ isDisposed() {
769
+ return this.#D || this.#t.isDisposed();
770
+ }
771
+ }, D = (e, t, n, r, i, a = {}, o = {}, s = {}) => new E(e, t, n, r, i, a, o, s);
772
+ //#endregion
773
+ export { E as RoomLockstepTransportOwner, D as createRoomLockstepTransportOwner };