@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,664 @@
1
+ import { BudgetExceeded as e, ProtocolError as t, RoomAuthoringError as n, WorldTransitionCooldown as r } from "./errors.js";
2
+ import { RoomInputCodec as i } from "./stateCodec.js";
3
+ import { worldTransitionRequest as a } from "./worldCommands.js";
4
+ import { WorldClientReceiptSchema as o, WorldClientRequestIdSchema as s, WorldClientTicketSchema as c } from "./worldClientSchemas.js";
5
+ import { makeWorldHandoffView as l } from "./worldHandoffView.js";
6
+ import { captureGeometryAssetBundle as u } from "./geometryAssetBundle.js";
7
+ import { captureRoomConnectionGeometrySession as d } from "./connection.js";
8
+ import { captureOwnedRoomGeometryChunkCache as f, captureRoomGeometryChunkCache as p, captureRoomGeometryChunkCacheRoot as m } from "./geometryClientChunks.js";
9
+ import { captureGeometryRenderLodCacheOptions as h, makeGeometryRenderLodCache as g } from "./geometryRenderCache.js";
10
+ import { captureWorldCatalog as _ } from "./world.js";
11
+ import { Result as v, Schema as y } from "effect";
12
+ //#region src/worldClient.ts
13
+ var b = (e) => new t({ detail: e }), x = (e, t) => {
14
+ if (!e || typeof e != "object" || Object.getPrototypeOf(e) !== Object.prototype || Reflect.ownKeys(e).length !== t.length) throw b("Invalid World client record");
15
+ for (let n of t) {
16
+ let t = Object.getOwnPropertyDescriptor(e, n);
17
+ if (!t?.enumerable || !("value" in t)) throw b("World client records require own data");
18
+ }
19
+ return e;
20
+ }, S = (e) => {
21
+ x(x(e, [
22
+ "requestId",
23
+ "transitionId",
24
+ "mode",
25
+ "target"
26
+ ]).target, [
27
+ "worldId",
28
+ "cellId",
29
+ "layer",
30
+ "roomId",
31
+ "epoch"
32
+ ]);
33
+ try {
34
+ let t = y.decodeUnknownSync(c)(e);
35
+ return Object.freeze({
36
+ requestId: t.requestId,
37
+ transitionId: t.transitionId,
38
+ mode: t.mode,
39
+ target: Object.freeze({
40
+ worldId: t.target.worldId,
41
+ cellId: t.target.cellId,
42
+ layer: t.target.layer,
43
+ roomId: t.target.roomId,
44
+ epoch: t.target.epoch
45
+ })
46
+ });
47
+ } catch {
48
+ throw b("Invalid World client ticket");
49
+ }
50
+ }, C = (e) => {
51
+ let t = x(e, [
52
+ "ticket",
53
+ "phase",
54
+ "entityRevision"
55
+ ]), n = S(t.ticket);
56
+ try {
57
+ let e = y.decodeUnknownSync(o)({
58
+ ...t,
59
+ ticket: n
60
+ });
61
+ return Object.freeze({
62
+ ticket: n,
63
+ phase: e.phase,
64
+ entityRevision: e.entityRevision
65
+ });
66
+ } catch {
67
+ throw b("Invalid or contradictory World client receipt");
68
+ }
69
+ }, w = (e, t) => JSON.stringify(e) === JSON.stringify(t), T = class {
70
+ options;
71
+ input;
72
+ handoffView;
73
+ handoffError = null;
74
+ controller = new AbortController();
75
+ commitWaitMs;
76
+ listeners = /* @__PURE__ */ new Set();
77
+ queue = [];
78
+ sends = /* @__PURE__ */ new Set();
79
+ receiptSubscriptions = /* @__PURE__ */ new Set();
80
+ draining = !1;
81
+ bytes = 0;
82
+ active;
83
+ source;
84
+ target = null;
85
+ sourceGeometry = null;
86
+ targetGeometry = null;
87
+ recoveryGeometry = null;
88
+ preparingAssets = null;
89
+ earlyAssets = null;
90
+ earlyAssetController = null;
91
+ earlyAssetFailed = !1;
92
+ pendingAssetBundles = /* @__PURE__ */ new Set();
93
+ geometryAssets = /* @__PURE__ */ new Map();
94
+ geometryRenders = /* @__PURE__ */ new Map();
95
+ detachSource = null;
96
+ detachTarget = null;
97
+ request = null;
98
+ prepared = null;
99
+ committed = !1;
100
+ assetsReady = !1;
101
+ operation = null;
102
+ closeTask = null;
103
+ closing = !1;
104
+ currentError = null;
105
+ snapshot;
106
+ constructor(e) {
107
+ let t = [
108
+ "source",
109
+ "input",
110
+ "maxBufferedInputs",
111
+ "maxBufferedBytes",
112
+ "maxInFlightInputs",
113
+ "prepare",
114
+ "observe",
115
+ "commit",
116
+ "cancel",
117
+ "createTarget",
118
+ "prefetchAssets"
119
+ ], r = [
120
+ "commitWaitMs",
121
+ "subscribeReceipt",
122
+ "geometry",
123
+ "handoffView"
124
+ ].filter((t) => Object.hasOwn(e, t));
125
+ x(e, [...t, ...r]);
126
+ let a = e.commitWaitMs ?? 2e4;
127
+ if (!Number.isSafeInteger(a) || a < 1 || a > 3e5) throw b("World commit wait requires a bounded live-query deadline");
128
+ if (this.commitWaitMs = a, !e || !Number.isSafeInteger(e.maxInFlightInputs) || e.maxInFlightInputs < 1 || e.maxInFlightInputs > 65536 || !Number.isSafeInteger(e.maxBufferedInputs) || e.maxBufferedInputs < 1 || e.maxBufferedInputs > 65536 || !Number.isSafeInteger(e.maxBufferedBytes) || e.maxBufferedBytes < 1 || e.maxBufferedBytes > 67108864) throw new n({
129
+ room: "world-client",
130
+ detail: "World input buffers require explicit bounded budgets"
131
+ });
132
+ this.handoffView = Object.hasOwn(e, "handoffView") ? l(e.handoffView) : null;
133
+ let o = { ...e };
134
+ for (let t of [
135
+ "prepare",
136
+ "observe",
137
+ "commit",
138
+ "cancel",
139
+ "createTarget",
140
+ "prefetchAssets"
141
+ ]) {
142
+ let n = Object.getOwnPropertyDescriptor(e, t);
143
+ if (!n || !("value" in n) || typeof n.value != "function") throw b("World client requires actual own provider methods");
144
+ o[t] = n.value.bind(e);
145
+ }
146
+ if (Object.hasOwn(e, "subscribeReceipt")) {
147
+ let t = Object.getOwnPropertyDescriptor(e, "subscribeReceipt");
148
+ if (!t || !("value" in t) || typeof t.value != "function") throw b("World receipt wait requires an actual own subscription provider");
149
+ o.subscribeReceipt = t.value.bind(e);
150
+ }
151
+ if (Object.hasOwn(e, "geometry")) {
152
+ let t = x(e.geometry, [
153
+ "source",
154
+ "prepare",
155
+ ...[
156
+ "recover",
157
+ "worlds",
158
+ "render",
159
+ "assets"
160
+ ].filter((t) => Object.hasOwn(e.geometry, t))
161
+ ]);
162
+ if (typeof t.prepare != "function") throw b("World geometry requires an actual own preparation provider");
163
+ let n = p(t.source, d(e.source));
164
+ if (Object.hasOwn(t, "recover") && typeof t.recover != "function") throw b("World geometry recovery requires an actual own provider");
165
+ let r = Object.hasOwn(t, "worlds") ? _(t.worlds) : void 0, i = Object.hasOwn(t, "render") ? h(t.render) : void 0;
166
+ if (i && !r?.length || r && !r.some((e) => e.geometry && e.name === m(n).worldId)) throw b("World render preparation requires its actual immutable geometry catalogue");
167
+ let a;
168
+ if (Object.hasOwn(t, "assets")) {
169
+ let e = x(t.assets, ["prepare", ...[
170
+ "source",
171
+ "recover",
172
+ "preload"
173
+ ].filter((e) => Object.hasOwn(t.assets, e))]);
174
+ if (typeof e.prepare != "function" || Object.hasOwn(e, "recover") && typeof e.recover != "function" || Object.hasOwn(e, "preload") && typeof e.preload != "function") throw b("World assets require actual own preparation/recovery capabilities");
175
+ let r = Object.hasOwn(e, "source") ? this.admitGeometryAssets(e.source, n) : void 0;
176
+ a = Object.freeze({
177
+ ...Object.hasOwn(e, "preload") ? { preload: e.preload.bind(t.assets) } : {},
178
+ prepare: e.prepare.bind(t.assets),
179
+ ...Object.hasOwn(e, "recover") ? { recover: e.recover.bind(t.assets) } : {},
180
+ ...r ? { source: r } : {}
181
+ }), r && this.geometryAssets.set(n, r);
182
+ }
183
+ o.geometry = Object.freeze({
184
+ source: n,
185
+ ...a ? { assets: a } : {},
186
+ ...r ? { worlds: r } : {},
187
+ ...i ? { render: i } : {},
188
+ prepare: t.prepare.bind(e.geometry),
189
+ ...Object.hasOwn(t, "recover") ? { recover: t.recover.bind(e.geometry) } : {}
190
+ }), this.sourceGeometry = n;
191
+ }
192
+ if (this.options = Object.freeze(o), this.input = new i(e.input), this.source = this.active = e.source, this.admitRoom(this.source), this.source.status !== "joined") throw b("World client requires its actual joined source");
193
+ this.snapshot = Object.freeze({
194
+ status: "idle",
195
+ step: null,
196
+ mode: null,
197
+ bufferedInputs: 0,
198
+ bufferedBytes: 0,
199
+ committed: !1,
200
+ error: null
201
+ }), this.detachSource = this.source.subscribe(() => this.notify());
202
+ }
203
+ get observation() {
204
+ return this.snapshot;
205
+ }
206
+ get roomId() {
207
+ return this.closing || this.committed && this.active !== this.target && this.request !== null ? null : this.active.roomId;
208
+ }
209
+ get geometry() {
210
+ return this.closing || this.committed && this.active !== this.target && this.request !== null ? null : this.active === this.target ? this.targetGeometry : this.sourceGeometry;
211
+ }
212
+ renderGeometry(e, t) {
213
+ try {
214
+ let n = this.geometry, r = this.options.geometry?.worlds;
215
+ if (!n || !r?.length || this.closing) throw b("World rendering requires its current verified geometry and actual catalogue");
216
+ let i = m(n), a = r.find((e) => e.name === i.worldId && e.geometry?.kind === i.kind);
217
+ if (!a) throw b("World render cache escaped its captured catalogue");
218
+ let o = this.geometryRenders.get(n);
219
+ return o || (o = g(n, a, this.options.geometry?.render), this.geometryRenders.set(n, o)), o.prepare(e, t);
220
+ } catch {
221
+ return Promise.reject(b("World native render preparation could not be admitted"));
222
+ }
223
+ }
224
+ get geometryRenderObservation() {
225
+ let e = this.geometry;
226
+ return e ? this.geometryRenders.get(e)?.observation() ?? null : null;
227
+ }
228
+ asset(e) {
229
+ let t = this.geometry, n = t ? this.geometryAssets.get(t) : void 0;
230
+ if (!n || this.closing) throw b("World asset access requires its selected fully verified owned bundle");
231
+ return n.at(e);
232
+ }
233
+ get assetObservation() {
234
+ let e = this.geometry;
235
+ return e ? this.geometryAssets.get(e)?.observation() ?? null : null;
236
+ }
237
+ admitGeometryAssets(e, t) {
238
+ let n = m(t), r = u(e, n.worldId), i = r.root;
239
+ if (i.tenantId !== n.tenantId || i.layerSetId !== n.layerSetId || i.version !== n.version || !r.observation().ready) throw b("World asset bundle escaped its actual geometry root or completed prefetch");
240
+ return r;
241
+ }
242
+ async closeGeometry(e) {
243
+ let t = this.geometryRenders.get(e), n = this.geometryAssets.get(e);
244
+ if ((await Promise.allSettled([
245
+ e.close(),
246
+ ...t ? [t.close()] : [],
247
+ ...n ? [n.close()] : []
248
+ ])).some((e) => e.status === "rejected")) throw b("World native geometry/render cleanup remains incomplete");
249
+ this.geometryRenders.delete(e), this.geometryAssets.delete(e);
250
+ }
251
+ get error() {
252
+ return this.currentError;
253
+ }
254
+ get state() {
255
+ return this.committed && this.active !== this.target && this.request !== null ? null : this.active.state;
256
+ }
257
+ deliveredSnapshot() {
258
+ return this.committed && this.active !== this.target && this.request !== null ? null : this.active.deliveredSnapshot();
259
+ }
260
+ presentationSnapshot() {
261
+ if (this.closing) return null;
262
+ if (this.handoffError) throw this.handoffError;
263
+ if (this.handoffView) return this.handoffView.read(this.active.roomId, this.deliveredSnapshot());
264
+ let e = this.deliveredSnapshot();
265
+ return e ? Object.freeze({
266
+ snapshot: e,
267
+ handoff: !1
268
+ }) : null;
269
+ }
270
+ presentationWork(e) {
271
+ if (!(!this.handoffView || this.handoffError || this.closing)) try {
272
+ e(this.handoffView);
273
+ } catch {
274
+ this.handoffView.close(), this.handoffError = b("World handoff presentation is unavailable; authoritative delivery remains separate");
275
+ }
276
+ }
277
+ subscribe(e) {
278
+ return this.listeners.add(e), () => {
279
+ this.listeners.delete(e);
280
+ };
281
+ }
282
+ notify() {
283
+ this.request && !this.committed && this.presentationWork((e) => e.source(this.source.deliveredSnapshot()));
284
+ for (let e of this.listeners) try {
285
+ e();
286
+ } catch {}
287
+ }
288
+ update(e, t) {
289
+ this.snapshot = Object.freeze({
290
+ status: e,
291
+ step: t,
292
+ mode: this.prepared?.mode ?? null,
293
+ bufferedInputs: this.queue.length,
294
+ bufferedBytes: this.bytes,
295
+ committed: this.committed,
296
+ error: this.currentError ? "incomplete" : null
297
+ }), this.notify();
298
+ }
299
+ admitRoom(e) {
300
+ if (!e || [
301
+ "send",
302
+ "subscribe",
303
+ "leave",
304
+ "deliveredSnapshot"
305
+ ].some((t) => typeof Reflect.get(e, t) != "function")) throw b("World client requires a complete Room connection");
306
+ }
307
+ run(e) {
308
+ if (this.closing || this.operation) return Promise.reject(b("World client is busy or closing"));
309
+ let t = {
310
+ status: this.snapshot.status,
311
+ step: this.snapshot.step
312
+ }, n = Promise.resolve().then(async () => {
313
+ try {
314
+ if (this.closing) throw b("World client is closing");
315
+ this.currentError = null, this.stopReceipts(), await e(), this.update(this.snapshot.status, this.snapshot.step);
316
+ } catch (e) {
317
+ throw e instanceof r ? (this.update(t.status, t.step), e) : (this.currentError = b("World client operation remains incomplete; confirm the saved request before retry"), this.update("failed", this.snapshot.step), this.currentError);
318
+ }
319
+ });
320
+ return this.operation = n, n.then(() => {
321
+ this.operation = null;
322
+ }, () => {
323
+ this.operation = null;
324
+ }), n;
325
+ }
326
+ stopReceipts() {
327
+ for (let e of this.receiptSubscriptions) e(), this.receiptSubscriptions.delete(e);
328
+ }
329
+ transition(e, t) {
330
+ let n, i;
331
+ try {
332
+ i = y.decodeUnknownSync(s)(e), n = a(t);
333
+ } catch (e) {
334
+ return Promise.reject(e);
335
+ }
336
+ return this.request !== null || this.recoveryGeometry ? Promise.reject(b("A World transition request or geometry recovery cleanup is still retained")) : this.run(async () => {
337
+ this.beginRequest(i, n.entityId);
338
+ let e;
339
+ try {
340
+ e = await this.options.prepare(i, structuredClone(n), this.controller.signal);
341
+ } catch (e) {
342
+ let t = typeof e == "object" && e && e._tag === "WorldTransitionCooldown" ? Number(e.retryAfterMs) : NaN;
343
+ throw Number.isFinite(t) && t >= 0 ? (this.request = null, this.handoffView?.rollback(), new r({ retryAfterMs: t })) : e;
344
+ }
345
+ this.acceptTicket(e), await this.connectAndCommit();
346
+ });
347
+ }
348
+ beginRequest(e, t) {
349
+ if (this.handoffError = null, this.handoffView) {
350
+ this.handoffView.read(this.active.roomId, this.deliveredSnapshot());
351
+ let n = this.source.deliveredSnapshot();
352
+ if (!n) throw b("World handoff presentation requires an actual source snapshot");
353
+ this.handoffView.begin(e, t, n);
354
+ }
355
+ this.request = Object.freeze({ id: e }), this.committed = !1, this.assetsReady = !1, this.prepared = null, this.update("preparing", "reserve");
356
+ }
357
+ adopt(e, t) {
358
+ let n;
359
+ try {
360
+ if (n = y.decodeUnknownSync(s)(e), typeof t != "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,190}$/.test(t)) throw b("Invalid World adoption entity identity");
361
+ } catch (e) {
362
+ return Promise.reject(e);
363
+ }
364
+ return this.request !== null || this.recoveryGeometry ? Promise.reject(b("A World transition request or geometry recovery cleanup is still retained")) : this.run(async () => {
365
+ this.beginRequest(n, t), await this.reconcileRequest();
366
+ });
367
+ }
368
+ beginAssetPrefetch() {
369
+ let e = this.options.geometry?.assets, t = this.prepared;
370
+ if (!e?.preload || !t || this.preparingAssets || this.earlyAssets || this.assetsReady || this.targetGeometry && this.geometryAssets.has(this.targetGeometry)) return;
371
+ let n = new AbortController(), r = () => n.abort();
372
+ this.earlyAssetController = n, this.earlyAssetFailed = !1, this.controller.signal.addEventListener("abort", r, { once: !0 }), this.controller.signal.aborted && n.abort();
373
+ let i = Promise.resolve().then(async () => {
374
+ let r = e.preload(t, n.signal);
375
+ if (!(r instanceof Promise)) throw b("World early asset preparation requires its actual Promise");
376
+ let i = u(await r);
377
+ if (i === this.geometryAssets.get(this.sourceGeometry)) throw b("World early target assets cannot alias the active source");
378
+ this.pendingAssetBundles.add(i);
379
+ let a = this.sourceGeometry ? m(this.sourceGeometry) : null;
380
+ if (!a || i.root.tenantId !== a.tenantId || i.root.worldId !== t.target.worldId || !i.observation().ready || n.signal.aborted) throw b("World early assets escaped their authenticated target or completed lifetime");
381
+ return this.earlyAssets = i, i;
382
+ }).finally(() => {
383
+ this.controller.signal.removeEventListener("abort", r);
384
+ });
385
+ this.preparingAssets = i, i.catch(() => {
386
+ this.earlyAssetFailed = !0;
387
+ });
388
+ }
389
+ async closePendingAssetBundles() {
390
+ if (this.earlyAssetController?.abort(), this.preparingAssets && await this.preparingAssets.then(() => void 0, () => void 0), (await Promise.allSettled([...this.pendingAssetBundles].map((e) => e.close()))).some((e) => e.status === "rejected")) throw b("World early asset cleanup remains incomplete");
391
+ this.pendingAssetBundles.clear(), this.preparingAssets = null, this.earlyAssets = null, this.earlyAssetController = null, this.earlyAssetFailed = !1;
392
+ }
393
+ acceptTicket(e) {
394
+ let t = S(e);
395
+ if (!this.request || t.requestId !== this.request.id || this.prepared && !w(this.prepared, t)) throw b("World preparation changed request or target");
396
+ this.presentationWork((e) => e.prepare(t.mode, {
397
+ roomId: t.target.roomId,
398
+ epoch: t.target.epoch
399
+ })), this.prepared = t, this.beginAssetPrefetch();
400
+ }
401
+ acceptReceipt(e) {
402
+ let t = C(e);
403
+ return this.acceptTicket(t.ticket), t;
404
+ }
405
+ async connectTarget() {
406
+ if (this.earlyAssetFailed && (await this.closePendingAssetBundles(), this.beginAssetPrefetch()), !this.prepared) throw b("World target has no preparation");
407
+ if (this.target && this.target.status !== "joined" && (this.targetGeometry &&= (await this.closeGeometry(this.targetGeometry), null), await this.target.leave(), this.detachTarget?.(), this.detachTarget = null, this.target = null), !this.target) {
408
+ this.update("loading", "connect");
409
+ let e = this.options.createTarget(this.prepared);
410
+ if (this.admitRoom(e), e === this.source || typeof e.start != "function" || e.status !== "reserving" || e.roomId !== null || e.state !== null) throw b("World target must be a separate unopened Room connection");
411
+ this.target = e, this.detachTarget = e.subscribe(() => this.notify()), this.update("loading", "welcome"), await e.start(this.prepared);
412
+ }
413
+ if (this.target.status !== "joined") throw b("World target has not received its Welcome");
414
+ let e = this.target.deliveredSnapshot();
415
+ if (!e || e.epoch !== this.prepared.target.epoch || this.target.roomId !== this.prepared.target.roomId) throw b("World Welcome does not match the target epoch");
416
+ if (this.options.geometry && !this.targetGeometry) {
417
+ this.update("loading", "geometry");
418
+ let e = f(await this.options.geometry.prepare(this.target, this.prepared, this.controller.signal));
419
+ if (e === this.sourceGeometry) throw b("World target geometry must be separately owned");
420
+ this.targetGeometry = e;
421
+ try {
422
+ p(e, d(this.target), this.prepared.target.worldId);
423
+ } catch {
424
+ throw await this.closeGeometry(e), this.targetGeometry = null, b("World target geometry does not match actual native admission/World");
425
+ }
426
+ if (this.controller.signal.aborted) throw b("World geometry acquisition was cancelled");
427
+ }
428
+ if (!this.assetsReady) {
429
+ if (this.update("loading", "assets"), this.options.geometry?.assets && this.targetGeometry && !this.geometryAssets.has(this.targetGeometry)) {
430
+ let e = this.preparingAssets ? await this.preparingAssets : u(await this.options.geometry.assets.prepare(this.target, this.targetGeometry, this.prepared, this.controller.signal));
431
+ try {
432
+ let t = this.admitGeometryAssets(e, this.targetGeometry);
433
+ if (this.controller.signal.aborted || this.geometryAssets.get(this.sourceGeometry) === t) throw b("World target assets require separate owned live preparation");
434
+ this.geometryAssets.set(this.targetGeometry, t), this.pendingAssetBundles.delete(t), this.earlyAssets = null, this.preparingAssets = null;
435
+ } catch (t) {
436
+ throw e !== this.geometryAssets.get(this.sourceGeometry) && await e.close(), t;
437
+ }
438
+ }
439
+ await this.options.prefetchAssets(this.prepared, this.controller.signal), this.assetsReady = !0;
440
+ }
441
+ }
442
+ async connectAndCommit() {
443
+ if (await this.connectTarget(), this.update("switching", "commit"), (await Promise.allSettled([...this.sends])).some((e) => e.status === "rejected")) throw b("Source intentions remain unconfirmed before commit");
444
+ let e = null;
445
+ try {
446
+ e = { value: await this.options.commit(this.prepared, this.controller.signal) };
447
+ } catch (e) {
448
+ if (!this.options.subscribeReceipt) throw e;
449
+ }
450
+ let t = e === null ? await this.waitReceipt() : this.acceptReceipt(e.value);
451
+ if (t.phase === "prepared" && (t = await this.waitReceipt()), t.phase === "rolledBack") await this.finishRollback();
452
+ else {
453
+ if (t.phase !== "committed" && t.phase !== "settled") throw b("World server did not confirm its SQL commit");
454
+ this.committed = !0, this.presentationWork((e) => e.commit()), this.active = this.target, this.update("switching", "cleanup"), await this.finishCommit();
455
+ }
456
+ }
457
+ waitReceipt() {
458
+ let e = this.controller.signal, t = this.options.subscribeReceipt;
459
+ if (e.aborted || !this.request || !this.target || this.target.status !== "joined" || !t) return Promise.reject(b("World common commit wait requires its actual live receipt subscription/target"));
460
+ let n = this.request.id;
461
+ return new Promise((r, i) => {
462
+ let a, o = !1, s = !0, c, l, u = !1, d = (t, n) => {
463
+ if (!o) {
464
+ o = !0, clearTimeout(p), e.removeEventListener("abort", f);
465
+ try {
466
+ a && (a(), this.receiptSubscriptions.delete(a));
467
+ } catch {
468
+ i(b("World receipt subscription withdrawal remains incomplete"));
469
+ return;
470
+ }
471
+ t ? r(t) : i(n ?? b("World common commit receipt remains incomplete"));
472
+ }
473
+ }, f = () => {
474
+ d(void 0, b("World commit wait was closed"));
475
+ }, p = setTimeout(() => {
476
+ d(void 0, b("World common commit wait budget expired; retain the original request"));
477
+ }, this.commitWaitMs), m = (e) => {
478
+ if (!o) try {
479
+ let t = this.acceptReceipt(e);
480
+ if (s) {
481
+ c = t;
482
+ return;
483
+ }
484
+ t.phase !== "prepared" && d(t);
485
+ } catch (e) {
486
+ s ? (u = !0, l = e) : d(void 0, e);
487
+ }
488
+ }, h = (e) => {
489
+ s ? (u = !0, l = e) : d(void 0, e);
490
+ };
491
+ e.addEventListener("abort", f, { once: !0 });
492
+ try {
493
+ let r = t(n, {
494
+ onValue: m,
495
+ onError: h
496
+ }, e), i = r && Object.getOwnPropertyDescriptor(r, "unsubscribe");
497
+ if (!i || !("value" in i) || typeof i.value != "function") throw b("World receipt subscription requires actual withdrawal");
498
+ let p = i.value.bind(r);
499
+ a = p, this.receiptSubscriptions.add(p), s = !1, o ? (p(), this.receiptSubscriptions.delete(p)) : e.aborted ? f() : u ? d(void 0, l) : c?.phase !== "prepared" && c && d(c);
500
+ } catch (e) {
501
+ s = !1, d(void 0, e);
502
+ }
503
+ });
504
+ }
505
+ async flush(e, t) {
506
+ this.draining = !0;
507
+ try {
508
+ for (; this.queue.length;) {
509
+ if (this.closing) throw b("World client is closing");
510
+ let n = this.queue.shift();
511
+ this.bytes -= n.bytes, this.update(this.snapshot.status, this.snapshot.step);
512
+ try {
513
+ let r = await e.send(n.input);
514
+ n.resolve(t ? {
515
+ sourceSeq: null,
516
+ targetSeq: r
517
+ } : {
518
+ sourceSeq: r,
519
+ targetSeq: null
520
+ });
521
+ } catch {
522
+ let e = b("Buffered World intention delivery is unconfirmed");
523
+ throw n.reject(e), e;
524
+ }
525
+ }
526
+ } finally {
527
+ this.draining = !1;
528
+ }
529
+ }
530
+ async finishCommit() {
531
+ if (!this.committed || !this.target) throw b("No confirmed World target");
532
+ this.active = this.target, this.update("switching", "cleanup"), this.sourceGeometry &&= (await this.closeGeometry(this.sourceGeometry), null), await this.source.leave(), this.detachSource?.(), this.detachSource = null, await this.flush(this.target, !0), this.sourceGeometry = this.targetGeometry, this.targetGeometry = null, this.source = this.target, this.target = null, this.detachSource = this.detachTarget, this.detachTarget = null, this.request = null, this.update("settled", null);
533
+ }
534
+ resume() {
535
+ return this.run(() => this.reconcileRequest());
536
+ }
537
+ async reconcileRequest() {
538
+ if (!this.request) throw b("No retained World transition request");
539
+ let e = this.acceptReceipt(await this.options.observe(this.request.id, this.controller.signal));
540
+ if (e.phase === "rolledBack") await this.finishRollback();
541
+ else if (e.phase === "committed" || e.phase === "settled") this.committed = !0, this.presentationWork((e) => e.commit()), await this.connectTarget(), this.active = this.target, await this.finishCommit();
542
+ else {
543
+ if (this.committed) throw b("World server receipt regressed after commit");
544
+ await this.connectAndCommit();
545
+ }
546
+ }
547
+ recoverGeometry() {
548
+ return this.run(async () => {
549
+ let e = this.options.geometry;
550
+ if (!e?.recover || !this.sourceGeometry || this.request || this.target || this.source.status !== "joined") throw b("World geometry recovery requires its current joined source and no retained transition");
551
+ this.recoveryGeometry &&= (await this.closeGeometry(this.recoveryGeometry), null), this.update("loading", "geometry");
552
+ let t = m(this.sourceGeometry).worldId, n = f(await e.recover(this.source, this.controller.signal));
553
+ if (n === this.sourceGeometry) {
554
+ if (p(n, d(this.source), t), this.controller.signal.aborted) throw b("World geometry recovery was closed");
555
+ this.update(this.committed ? "settled" : "idle", null);
556
+ } else {
557
+ this.recoveryGeometry = n;
558
+ try {
559
+ if (p(n, d(this.source), t), this.controller.signal.aborted) throw b("World geometry recovery was closed");
560
+ if (e.assets) {
561
+ if (!e.assets.recover) throw b("World asset recovery requires its actual preparation source");
562
+ let t = u(await e.assets.recover(this.source, n, this.controller.signal));
563
+ try {
564
+ let e = this.admitGeometryAssets(t, n);
565
+ if (this.controller.signal.aborted || e === this.geometryAssets.get(this.sourceGeometry)) throw b("World recovered assets must have their own current lifetime");
566
+ this.geometryAssets.set(n, e);
567
+ } catch (e) {
568
+ throw t !== this.geometryAssets.get(this.sourceGeometry) && await t.close(), e;
569
+ }
570
+ }
571
+ if (await this.closeGeometry(this.sourceGeometry), p(n, d(this.source), t), this.controller.signal.aborted) throw b("World geometry recovery was closed");
572
+ this.sourceGeometry = n, this.recoveryGeometry = null, this.update(this.committed ? "settled" : "idle", null);
573
+ } catch (e) {
574
+ throw await this.closeGeometry(n), this.recoveryGeometry = null, e;
575
+ }
576
+ }
577
+ });
578
+ }
579
+ cancel() {
580
+ return this.run(async () => {
581
+ if (!this.request || this.committed) throw b("World cancellation requires retained pre-commit work");
582
+ let e = this.acceptReceipt(await this.options.cancel(this.request.id, this.controller.signal));
583
+ if (e.phase === "committed" || e.phase === "settled") throw this.committed = !0, this.presentationWork((e) => e.commit()), this.target && (this.active = this.target), this.update("switching", "cleanup"), b("World request committed; resume its target");
584
+ if (e.phase !== "rolledBack") throw b("World rollback is not confirmed");
585
+ await this.finishRollback();
586
+ });
587
+ }
588
+ async finishRollback() {
589
+ if (this.handoffView?.rollback(), this.handoffError = null, await this.closePendingAssetBundles(), this.committed) throw b("Committed World ownership cannot roll back");
590
+ this.targetGeometry &&= (await this.closeGeometry(this.targetGeometry), null), this.target && await this.target.leave(), this.detachTarget?.(), this.detachTarget = null, this.target = null, this.active = this.source, await this.flush(this.source, !1), this.request = null, this.prepared = null, this.assetsReady = !1, this.update("idle", null);
591
+ }
592
+ send(t) {
593
+ if (this.closing || this.draining) return Promise.reject(b("World client is closing or draining accepted intentions"));
594
+ if (this.sends.size >= this.options.maxInFlightInputs) return Promise.reject(new e({
595
+ budget: "worldInFlightInputs",
596
+ limit: this.options.maxInFlightInputs
597
+ }));
598
+ let n = this.input.full(t);
599
+ if (v.isFailure(n)) return Promise.reject(n.failure);
600
+ let r = this.input.decodeFull(n.success);
601
+ if (v.isFailure(r)) return Promise.reject(r.failure);
602
+ if (this.request && (this.prepared?.mode !== "seamless" || this.committed || this.snapshot.status === "failed" || this.snapshot.status === "switching")) return this.bytes + n.success.byteLength > this.options.maxBufferedBytes ? Promise.reject(new e({
603
+ budget: "worldBufferedInputBytes",
604
+ limit: this.options.maxBufferedBytes
605
+ })) : this.queue.length >= this.options.maxBufferedInputs ? Promise.reject(new e({
606
+ budget: "worldTransitionInputs",
607
+ limit: this.options.maxBufferedInputs
608
+ })) : new Promise((e, t) => {
609
+ this.queue.push({
610
+ input: r.success,
611
+ bytes: n.success.byteLength,
612
+ resolve: e,
613
+ reject: t
614
+ }), this.bytes += n.success.byteLength, this.update(this.snapshot.status, this.snapshot.step);
615
+ });
616
+ if (this.request && this.prepared?.mode === "seamless" && this.target?.status === "joined") return this.trackSend(Promise.allSettled([this.source.send(r.success), this.target.send(structuredClone(r.success))]).then((e) => {
617
+ if (e[0].status === "rejected" || e[1].status === "rejected") throw b("Seamless intention delivery is partially or wholly unconfirmed");
618
+ return {
619
+ sourceSeq: e[0].value,
620
+ targetSeq: e[1].value
621
+ };
622
+ }));
623
+ let i = this.committed, a = this.active;
624
+ return this.trackSend(a.send(r.success).then((e) => i ? {
625
+ sourceSeq: null,
626
+ targetSeq: e
627
+ } : {
628
+ sourceSeq: e,
629
+ targetSeq: null
630
+ }));
631
+ }
632
+ trackSend(e) {
633
+ return this.sends.add(e), e.then(() => {
634
+ this.sends.delete(e);
635
+ }, () => {
636
+ this.sends.delete(e);
637
+ }), e;
638
+ }
639
+ close() {
640
+ if (this.closeTask) return this.closeTask;
641
+ this.closing = !0, this.handoffView?.close(), this.controller.abort();
642
+ let e = (async () => {
643
+ try {
644
+ await this.operation;
645
+ } catch {}
646
+ await this.closePendingAssetBundles(), await Promise.allSettled([...this.sends]), this.stopReceipts();
647
+ for (let e of this.queue.splice(0)) e.reject(b("World client closed before intention delivery"));
648
+ if (this.bytes = 0, (await Promise.allSettled([...new Set([
649
+ this.sourceGeometry,
650
+ this.targetGeometry,
651
+ this.recoveryGeometry
652
+ ].filter((e) => e !== null))].map((e) => this.closeGeometry(e)))).some((e) => e.status === "rejected")) throw b("World geometry cleanup remains incomplete");
653
+ if (this.sourceGeometry = this.targetGeometry = this.recoveryGeometry = null, (await Promise.allSettled([...new Set([this.source, this.target].filter((e) => e !== null))].map((e) => e.leave()))).some((e) => e.status === "rejected")) throw b("World connection cleanup remains incomplete");
654
+ this.detachSource?.(), this.detachTarget?.(), this.detachSource = this.detachTarget = null, this.update("closed", null), this.listeners.clear();
655
+ })();
656
+ return this.closeTask = e, e.then(() => {
657
+ this.closeTask = null;
658
+ }, () => {
659
+ this.closeTask = null;
660
+ }), e;
661
+ }
662
+ };
663
+ //#endregion
664
+ export { T as WorldClient, C as worldClientReceipt, S as worldClientTicket };