@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
package/dist/web.js ADDED
@@ -0,0 +1,518 @@
1
+ import { BudgetExceeded as e, ProtocolError as t, RoomAuthoringError as n } from "./errors.js";
2
+ import { RoomInputCodec as r, RoomStateCodec as i } from "./stateCodec.js";
3
+ import { WorldClientReceiptSchema as a, WorldClientRequestIdSchema as o, WorldClientTicketSchema as s } from "./worldClientSchemas.js";
4
+ import { makeWorldHandoffView as c } from "./worldHandoffView.js";
5
+ import { RoomTransportCleanupFailure as l } from "./transportCleanup.js";
6
+ import { captureRoomTransportEndpoints as u } from "./transportEndpoints.js";
7
+ import { RoomInputRedundancy as d, defaultRoomInputRedundancy as f } from "./inputRedundancy.js";
8
+ import { RoomConnection as p, defaultRoomClockPingCadence as m, defaultRoomReconnectPolicy as h } from "./connection.js";
9
+ import { defaultRoomWebSocketFactory as g, openRoomSocketTransport as _ } from "./socketTransport.js";
10
+ import { RoomLatestDatagram as v, RoomStreamFrameDecoder as ee, encodeRoomStreamFrame as y } from "./streamFraming.js";
11
+ import { makeRoomStreamTransport as b } from "./streamTransport.js";
12
+ import { defaultRoomWebTransportFactory as x, openRoomWebTransport as S } from "./webTransportClient.js";
13
+ import { roomTransportConnector as C } from "./transportConnector.js";
14
+ import { listRooms as w, roomRpcReservations as T, worldRpcControls as E, worldRpcFollowerReservations as D, worldRpcPending as O, worldRpcReservations as k } from "./rpcClient.js";
15
+ import { createRoom as A, createRoomClient as j, joinById as M, joinRoom as N, joinSeat as te, joinWorld as P } from "./client.js";
16
+ import { RoomClockSync as F } from "./clockSync.js";
17
+ import { decodeRoomFrame as I, encodeRoomFrame as L, roomFrameLayout as R } from "./wire.js";
18
+ import { makeWorldEntityHandoffView as z } from "./worldEntityHandoffView.js";
19
+ import { WorldClient as B, worldClientReceipt as V, worldClientTicket as H } from "./worldClient.js";
20
+ import { shapeDigest as U } from "@voltro/protocol";
21
+ import { Result as W } from "effect";
22
+ //#region src/web.ts
23
+ var G = Object.freeze({
24
+ maxPendingPings: 8,
25
+ pingTimeoutMs: 1e4
26
+ }), K = (e) => {
27
+ let t = new i(e.state), a = new r(e.input), o = Object.entries(e.messages ?? {}).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => {
28
+ if (!/^[A-Za-z][A-Za-z0-9._-]*$/.test(e)) throw new n({
29
+ room: "wire",
30
+ detail: "Channel names must be stable ASCII identifiers"
31
+ });
32
+ return Object.freeze({
33
+ name: e,
34
+ direction: t.direction,
35
+ reliable: t.reliable,
36
+ codec: new r(t.schema)
37
+ });
38
+ }), s = Number.parseInt(U(JSON.stringify([
39
+ R,
40
+ t.schemaHash,
41
+ a.schemaHash,
42
+ o.map((e) => [
43
+ e.name,
44
+ e.codec.schemaHash,
45
+ e.direction,
46
+ e.reliable
47
+ ])
48
+ ])), 16), c = new TextEncoder().encode(JSON.stringify(t.transformRulesManifest()));
49
+ return Object.freeze({
50
+ state: t,
51
+ input: a,
52
+ channels: Object.freeze(o),
53
+ schemaHash: s,
54
+ get transformRules() {
55
+ return Uint8Array.from(c);
56
+ }
57
+ });
58
+ }, q = /* @__PURE__ */ new WeakSet(), J = class {
59
+ transport;
60
+ clock;
61
+ maxBaselines;
62
+ codecs;
63
+ baselines = /* @__PURE__ */ new Map();
64
+ handoffListeners = /* @__PURE__ */ new Set();
65
+ listeners = /* @__PURE__ */ new Set();
66
+ messageListeners = /* @__PURE__ */ new Map();
67
+ detach = [];
68
+ currentState = null;
69
+ currentStatus = "connecting";
70
+ currentError = null;
71
+ tick = -1;
72
+ epoch = -1;
73
+ receivedAt = -1;
74
+ seq = 0;
75
+ inputAck = -1;
76
+ acknowledgedTick = -1;
77
+ pendingInputAck = null;
78
+ pairedInputState = null;
79
+ sessionId = null;
80
+ started = !1;
81
+ pendingPings = /* @__PURE__ */ new Map();
82
+ deltaDatagramsReceived = 0;
83
+ lossSample = null;
84
+ lossEstimate = null;
85
+ sampling;
86
+ clockSync;
87
+ inputHistory;
88
+ constructor(e, t, r, i = 8, a = {
89
+ nextSeq: 0,
90
+ lastAppliedSeq: -1
91
+ }, o = G, s = f) {
92
+ if (this.transport = e, this.clock = r, this.maxBaselines = i, this.inputHistory = new d(s), !Number.isSafeInteger(i) || i < 1) throw new n({
93
+ room: "client",
94
+ detail: "Client baseline history must be bounded"
95
+ });
96
+ if (!Number.isSafeInteger(a.nextSeq) || a.nextSeq < 0 || !Number.isSafeInteger(a.lastAppliedSeq) || a.lastAppliedSeq < -1 || a.lastAppliedSeq >= a.nextSeq) throw new n({
97
+ room: "client",
98
+ detail: "Invalid input recovery cursor"
99
+ });
100
+ if (this.seq = a.nextSeq, this.inputAck = a.lastAppliedSeq, !Number.isSafeInteger(o.maxPendingPings) || o.maxPendingPings < 1 || !Number.isSafeInteger(o.pingTimeoutMs) || o.pingTimeoutMs < 1) throw new n({
101
+ room: "client",
102
+ detail: "Clock sampling budgets must be positive safe integers"
103
+ });
104
+ this.sampling = Object.freeze({ ...o }), this.codecs = K(t), this.clockSync = new F(r), this.detach.push(e.reliable.onFrame((e, t) => this.receive(e, t))), e.unreliable && this.detach.push(e.unreliable.onFrame((e, t) => this.receive(e, t, !0)));
105
+ let c = () => {
106
+ (this.currentStatus === "joined" || this.currentStatus === "connecting") && (this.currentStatus = "reconnecting"), this.cleanup(), this.notify();
107
+ };
108
+ e.signal.addEventListener("abort", c, { once: !0 }), this.detach.push(() => e.signal.removeEventListener("abort", c)), e.signal.aborted && c(), q.add(this);
109
+ }
110
+ currentReliableChannelIdentity(e, t) {
111
+ let n = this.codecs.channels.find((t) => t.name === e);
112
+ return this.currentStatus !== "joined" || this.transport.signal.aborted || this.currentState === null || !this.sessionId || !n || !n.reliable || n.direction === "client" || n.codec.schemaHash !== t ? null : Object.freeze({
113
+ sessionId: this.sessionId,
114
+ epoch: this.epoch
115
+ });
116
+ }
117
+ currentReliableClientChannelIdentity(e, t) {
118
+ let n = this.codecs.channels.find((t) => t.name === e);
119
+ return this.currentStatus !== "joined" || this.transport.signal.aborted || this.currentState === null || !this.sessionId || !n || !n.reliable || n.direction !== "client" || n.codec.schemaHash !== t ? null : Object.freeze({
120
+ sessionId: this.sessionId,
121
+ epoch: this.epoch
122
+ });
123
+ }
124
+ get status() {
125
+ return this.currentStatus;
126
+ }
127
+ get error() {
128
+ return this.currentError;
129
+ }
130
+ get state() {
131
+ return this.currentState === null ? null : structuredClone(this.currentState);
132
+ }
133
+ get lastAppliedTick() {
134
+ return this.tick;
135
+ }
136
+ get lastAppliedInputSeq() {
137
+ return this.inputAck;
138
+ }
139
+ get reconciliationSnapshot() {
140
+ return this.pairedInputState === null ? null : structuredClone(this.pairedInputState);
141
+ }
142
+ get nextInputSeq() {
143
+ return this.seq;
144
+ }
145
+ get id() {
146
+ return this.sessionId;
147
+ }
148
+ get lossRate() {
149
+ return this.lossEstimate;
150
+ }
151
+ deliveredSnapshot() {
152
+ return this.currentStatus !== "joined" || this.currentState === null ? null : {
153
+ epoch: this.epoch,
154
+ tick: this.tick,
155
+ receivedAt: this.receivedAt,
156
+ state: structuredClone(this.currentState)
157
+ };
158
+ }
159
+ serverNow() {
160
+ return this.clockSync.serverNow();
161
+ }
162
+ async start(e, n) {
163
+ if (this.started || this.transport.signal.aborted) throw new t({ detail: "Session already started or transport closed" });
164
+ this.started = !0, await this.sendFrame({
165
+ kind: "Hello",
166
+ protocolVersion: 1,
167
+ token: e,
168
+ schemaHash: this.codecs.schemaHash,
169
+ ...n === void 0 ? {} : { resumeFromTick: n },
170
+ transportCaps: this.transport.unreliable ? 3 : 1
171
+ });
172
+ }
173
+ async send(e) {
174
+ if (this.currentStatus !== "joined") throw new t({ detail: "Inputs require a joined session" });
175
+ if (!Number.isSafeInteger(this.seq)) throw new t({ detail: "Input sequence exhausted" });
176
+ let n = this.codecs.input.full(e);
177
+ if (W.isFailure(n)) throw n.failure;
178
+ let r = this.seq, i = this.acknowledgedTick < 0 ? {} : { ackTick: this.acknowledgedTick }, a = {
179
+ kind: "Input",
180
+ firstSeq: r,
181
+ inputs: [{
182
+ tickHint: this.tick,
183
+ payload: n.success
184
+ }],
185
+ ...i
186
+ };
187
+ if (this.transport.unreliable) {
188
+ let e = this.inputHistory.offer(r, this.tick, n.success), t = L({
189
+ ...e,
190
+ ...i
191
+ });
192
+ this.seq++, W.isSuccess(t) && t.success.byteLength <= this.transport.unreliable.maxDatagramBytes ? this.transport.unreliable.send(t.success) : await this.sendFrame(a);
193
+ } else this.seq++, await this.sendFrame(a);
194
+ return r;
195
+ }
196
+ async message(e, n) {
197
+ if (this.currentStatus !== "joined") throw new t({ detail: "Messages require a joined session" });
198
+ let r = this.codecs.channels.findIndex((t) => t.name === e), i = this.codecs.channels[r];
199
+ if (!i || i.direction === "server") throw new t({ detail: "Channel is not client-sendable" });
200
+ let a = i.codec.full(n);
201
+ if (W.isFailure(a)) throw a.failure;
202
+ let o = {
203
+ kind: "ClientMessage",
204
+ channelId: r,
205
+ payload: a.success
206
+ }, s = L(o);
207
+ if (W.isFailure(s)) throw s.failure;
208
+ !i.reliable && this.transport.unreliable && s.success.byteLength <= this.transport.unreliable.maxDatagramBytes ? this.transport.unreliable.send(s.success) : await this.transport.reliable.send(s.success);
209
+ }
210
+ async replay(e, n) {
211
+ if (this.currentStatus !== "joined" || !Number.isSafeInteger(e) || e <= this.inputAck || e >= this.seq) throw new t({ detail: "Replay requires a joined session and an unacknowledged submitted sequence" });
212
+ let r = this.codecs.input.full(n);
213
+ if (W.isFailure(r)) throw r.failure;
214
+ await this.sendFrame({
215
+ kind: "Input",
216
+ firstSeq: e,
217
+ inputs: [{
218
+ tickHint: this.tick,
219
+ payload: r.success
220
+ }],
221
+ ...this.acknowledgedTick < 0 ? {} : { ackTick: this.acknowledgedTick }
222
+ });
223
+ }
224
+ async ping() {
225
+ if (this.currentStatus !== "joined") throw new t({ detail: "Ping requires a joined session" });
226
+ let n = this.clock.now(), r = Math.floor(n);
227
+ if (!Number.isFinite(n) || n < 0 || !Number.isSafeInteger(r)) throw new t({ detail: "Invalid local ping clock" });
228
+ for (let [e, t] of this.pendingPings) n - t >= this.sampling.pingTimeoutMs && this.pendingPings.delete(e);
229
+ if (!this.pendingPings.has(r)) {
230
+ if (this.pendingPings.size >= this.sampling.maxPendingPings) throw new e({
231
+ budget: "pendingClockPings",
232
+ limit: this.sampling.maxPendingPings
233
+ });
234
+ this.pendingPings.set(r, n);
235
+ try {
236
+ await this.sendFrame({
237
+ kind: "Ping",
238
+ clientTimeMs: r
239
+ });
240
+ } catch (e) {
241
+ throw this.pendingPings.delete(r), e;
242
+ }
243
+ }
244
+ }
245
+ subscribe(e) {
246
+ return this.listeners.add(e), () => {
247
+ this.listeners.delete(e);
248
+ };
249
+ }
250
+ onWorldHandoff(e) {
251
+ return this.handoffListeners.add(e), () => {
252
+ this.handoffListeners.delete(e);
253
+ };
254
+ }
255
+ onMessage(e, t) {
256
+ let n = this.messageListeners.get(e) ?? /* @__PURE__ */ new Set();
257
+ return n.add(t), this.messageListeners.set(e, n), () => {
258
+ n.delete(t), n.size === 0 && this.messageListeners.delete(e);
259
+ };
260
+ }
261
+ async sendFrame(e) {
262
+ let t = L(e);
263
+ if (W.isFailure(t)) throw t.failure;
264
+ await this.transport.reliable.send(t.success);
265
+ }
266
+ sampleLoss(e) {
267
+ let t = this.deltaDatagramsReceived, n = this.lossSample;
268
+ if (n === null || e < n.sent) {
269
+ this.lossSample = {
270
+ sent: e,
271
+ received: t
272
+ };
273
+ return;
274
+ }
275
+ let r = e - n.sent;
276
+ if (r < 8) return;
277
+ let i = 1 - Math.min(r, t - n.received) / r;
278
+ this.lossEstimate = this.lossEstimate === null ? i : this.lossEstimate * .75 + i * .25, this.lossSample = {
279
+ sent: e,
280
+ received: t
281
+ };
282
+ }
283
+ ackFrame(e) {
284
+ return this.lossEstimate === null ? {
285
+ kind: "Ack",
286
+ tick: e
287
+ } : {
288
+ kind: "Ack",
289
+ tick: e,
290
+ lossPermille: Math.round(this.lossEstimate * 1e3)
291
+ };
292
+ }
293
+ acknowledge(e = this.tick) {
294
+ if (this.acknowledgedTick = e, this.transport.unreliable) {
295
+ let t = L(this.ackFrame(e));
296
+ if (W.isFailure(t)) {
297
+ this.fail(t.failure);
298
+ return;
299
+ }
300
+ if (t.success.byteLength <= this.transport.unreliable.maxDatagramBytes) {
301
+ try {
302
+ this.transport.unreliable.send(t.success);
303
+ } catch (e) {
304
+ this.fail(e);
305
+ }
306
+ return;
307
+ }
308
+ }
309
+ this.sendFrame(this.ackFrame(e)).catch((e) => this.fail(e));
310
+ }
311
+ fail(e) {
312
+ this.currentStatus !== "left" && this.currentStatus !== "kicked" && this.currentStatus !== "gone" && (this.currentError = e instanceof t ? e : new t({ detail: "Room transport failed" }), this.currentStatus = "left", this.cleanup(), this.transport.close(1002, "Room protocol error"), this.notify());
313
+ }
314
+ install(e, t, n) {
315
+ for (this.tick = e, this.receivedAt = n, this.currentState = structuredClone(t), this.baselines.set(e, structuredClone(t)); this.baselines.size > this.maxBaselines;) {
316
+ let e = this.baselines.keys().next();
317
+ if (e.done) break;
318
+ this.baselines.delete(e.value);
319
+ }
320
+ this.pairInputState(), this.acknowledge(), this.notify();
321
+ }
322
+ pairInputState() {
323
+ let e = this.pendingInputAck;
324
+ if (!e || !this.baselines.has(e.tick)) return;
325
+ let t = this.baselines.get(e.tick);
326
+ this.pairedInputState = Object.freeze({
327
+ epoch: this.epoch,
328
+ tick: e.tick,
329
+ lastAppliedSeq: e.seq,
330
+ state: structuredClone(t)
331
+ });
332
+ }
333
+ observeInputAck(e, n, r) {
334
+ if (n >= this.seq) return this.fail(new t({ detail: "Input acknowledgement exceeds submitted history" })), "refused";
335
+ if (r & -2) return this.fail(new t({ detail: "Unknown input acknowledgement flags" })), "refused";
336
+ let i = this.pendingInputAck;
337
+ return i && (n < i.seq || n === i.seq && e <= i.tick) ? "ignored" : i && e < i.tick ? (this.fail(new t({ detail: "Input receipt tick regressed while its sequence advanced" })), "refused") : (this.inputAck = Math.max(this.inputAck, n), this.pendingInputAck = Object.freeze({
338
+ tick: e,
339
+ seq: n
340
+ }), "accepted");
341
+ }
342
+ receive(e, n, r = !1) {
343
+ if (!Number.isFinite(n) || n < 0) {
344
+ this.fail(new t({ detail: "Invalid local room observation time" }));
345
+ return;
346
+ }
347
+ let i = I(e);
348
+ if (W.isFailure(i)) {
349
+ this.fail(i.failure);
350
+ return;
351
+ }
352
+ let a = i.success;
353
+ if (r && a.kind !== "Delta" && a.kind !== "InputAck" && a.kind !== "Pong" && (a.kind !== "ServerMessage" || this.codecs.channels[a.channelId]?.reliable !== !1)) this.fail(new t({ detail: "Room control and reliable message frames require the reliable lane" }));
354
+ else switch (r && a.kind === "Delta" && this.deltaDatagramsReceived++, a.kind) {
355
+ case "Welcome": {
356
+ if (!this.started || this.currentStatus !== "connecting") {
357
+ this.fail(new t({ detail: "Unexpected Welcome" }));
358
+ return;
359
+ }
360
+ let e = this.codecs.transformRules;
361
+ if (e.length !== a.transformRules.length || e.some((e, t) => e !== a.transformRules[t])) {
362
+ this.fail(new t({ detail: "Room transform rules do not match the admitted client manifest" }));
363
+ return;
364
+ }
365
+ let r = this.codecs.state.decodeFull(a.baseline);
366
+ if (W.isFailure(r)) {
367
+ this.fail(r.failure);
368
+ return;
369
+ }
370
+ try {
371
+ this.clockSync.anchor(a.serverTimeMs, n);
372
+ } catch (e) {
373
+ this.fail(e);
374
+ return;
375
+ }
376
+ this.sessionId = a.sessionId, this.epoch = a.epoch, this.currentStatus = "joined", this.install(a.tick, r.success, n);
377
+ return;
378
+ }
379
+ case "Full": {
380
+ if (this.currentStatus !== "joined") {
381
+ this.fail(new t({ detail: "Full requires a joined session" }));
382
+ return;
383
+ }
384
+ if (a.epoch < this.epoch || a.epoch === this.epoch && a.tick < this.tick) return;
385
+ let e = this.codecs.state.decodeFull(a.baseline);
386
+ if (W.isFailure(e)) {
387
+ this.fail(e.failure);
388
+ return;
389
+ }
390
+ if (a.epoch !== this.epoch && (this.clockSync.reset(), this.pendingPings.clear(), this.pendingInputAck = null, this.pairedInputState = null), a.inputAck && this.observeInputAck(a.tick, a.inputAck.lastAppliedSeq, a.inputAck.flags) === "refused") return;
391
+ this.epoch = a.epoch, this.baselines.clear(), this.install(a.tick, e.success, n);
392
+ return;
393
+ }
394
+ case "Delta": {
395
+ if (this.currentStatus !== "joined") {
396
+ this.fail(new t({ detail: "Delta requires a joined session" }));
397
+ return;
398
+ }
399
+ if (a.tick <= this.tick) return;
400
+ let e = this.baselines.get(a.baseTick);
401
+ if (e === void 0) {
402
+ this.acknowledge();
403
+ return;
404
+ }
405
+ let r = this.codecs.state.decodeDelta(a.patch, e);
406
+ if (W.isFailure(r)) {
407
+ this.fail(r.failure);
408
+ return;
409
+ }
410
+ if (a.inputAck && this.observeInputAck(a.tick, a.inputAck.lastAppliedSeq, a.inputAck.flags) === "refused") return;
411
+ this.install(a.tick, r.success, n);
412
+ return;
413
+ }
414
+ case "InputAck":
415
+ if (this.currentStatus !== "joined") {
416
+ this.fail(new t({ detail: "Input acknowledgement requires a joined session" }));
417
+ return;
418
+ }
419
+ if (r && a.tick <= this.tick || this.observeInputAck(a.tick, a.lastAppliedSeq, a.flags) !== "accepted") return;
420
+ this.pairInputState(), !this.baselines.has(a.tick) && a.tick < this.tick && this.acknowledge(Math.max(0, Math.min(this.tick, a.tick - 1))), this.notify();
421
+ return;
422
+ case "Pong": {
423
+ if (this.currentStatus !== "joined") {
424
+ this.fail(new t({ detail: "Pong requires a joined session" }));
425
+ return;
426
+ }
427
+ if (a.deltaDatagramsSent !== void 0 && this.pendingPings.has(a.clientTimeMs) && this.sampleLoss(a.deltaDatagramsSent), r && a.tick <= this.tick) return;
428
+ let e = this.pendingPings.get(a.clientTimeMs);
429
+ if (e === void 0 || (this.pendingPings.delete(a.clientTimeMs), n - e >= this.sampling.pingTimeoutMs)) return;
430
+ try {
431
+ this.clockSync.pong(e, a.serverTimeMs, n), this.notify();
432
+ } catch (e) {
433
+ this.fail(e);
434
+ }
435
+ return;
436
+ }
437
+ case "ServerMessage": {
438
+ if (this.currentStatus !== "joined") {
439
+ this.fail(new t({ detail: "Messages require a joined session" }));
440
+ return;
441
+ }
442
+ let e = this.codecs.channels[a.channelId];
443
+ if (!e || e.direction === "client") {
444
+ this.fail(new t({ detail: "Channel is not server-sendable" }));
445
+ return;
446
+ }
447
+ let n = e.codec.decodeFull(a.payload);
448
+ if (W.isFailure(n)) {
449
+ this.fail(n.failure);
450
+ return;
451
+ }
452
+ for (let t of this.messageListeners.get(e.name) ?? []) t(n.success);
453
+ return;
454
+ }
455
+ case "WorldHandoff": {
456
+ if (this.currentStatus !== "joined") {
457
+ this.fail(new t({ detail: "World handoff requires a joined session" }));
458
+ return;
459
+ }
460
+ if (a.sourceEpoch < this.epoch) return;
461
+ if (a.sourceEpoch !== this.epoch) {
462
+ this.fail(new t({ detail: "World handoff source epoch does not match the session" }));
463
+ return;
464
+ }
465
+ let e = Object.freeze({ ...a });
466
+ for (let t of this.handoffListeners) t(e);
467
+ return;
468
+ }
469
+ case "Kick":
470
+ this.currentStatus = "kicked", this.cleanup(), this.transport.close(1e3, "Room kicked"), this.notify();
471
+ return;
472
+ case "Migrate":
473
+ this.currentStatus = "reconnecting", this.cleanup(), this.transport.close(1e3, "Room migrating"), this.notify();
474
+ return;
475
+ case "Error":
476
+ this.fail(new t({ detail: a.detail }));
477
+ return;
478
+ default: this.fail(new t({ detail: "Server sent a client-only frame" }));
479
+ }
480
+ }
481
+ notify() {
482
+ for (let e of this.listeners) e();
483
+ }
484
+ cleanup() {
485
+ this.pendingPings.clear(), this.inputHistory.clear();
486
+ for (let e of this.detach.splice(0)) e();
487
+ }
488
+ async leave() {
489
+ try {
490
+ !this.transport.signal.aborted && this.currentStatus === "joined" && await this.sendFrame({
491
+ kind: "Leave",
492
+ reason: 0
493
+ });
494
+ } finally {
495
+ this.currentStatus = "left", this.cleanup(), this.transport.close(1e3, "Room left"), this.notify(), this.listeners.clear(), this.messageListeners.clear(), this.handoffListeners.clear();
496
+ }
497
+ }
498
+ }, Y = J.prototype.currentReliableChannelIdentity, X = J.prototype.onMessage, Z = J.prototype.subscribe, Q = (e, n, r) => {
499
+ if (!e || typeof e != "object" || !q.has(e)) throw new t({ detail: "Actual constructed Room client Session is required" });
500
+ let i = e;
501
+ return Object.freeze({
502
+ identity: () => Y.call(i, n, r),
503
+ onMessage: (e) => X.call(i, n, e),
504
+ subscribe: (e) => Z.call(i, e)
505
+ });
506
+ }, $ = J.prototype.currentReliableClientChannelIdentity, ne = J.prototype.message, re = (e, n, r) => {
507
+ if (!e || typeof e != "object" || !q.has(e)) throw new t({ detail: "Actual constructed client Session required for geometry requests" });
508
+ let i = e;
509
+ return Object.freeze({
510
+ identity: () => $.call(i, n, r),
511
+ write: (e) => {
512
+ if (!$.call(i, n, r)) throw new t({ detail: "Geometry request lost its exact native client channel admission" });
513
+ return ne.call(i, n, e);
514
+ }
515
+ });
516
+ };
517
+ //#endregion
518
+ export { p as RoomConnection, d as RoomInputRedundancy, v as RoomLatestDatagram, J as RoomSession, ee as RoomStreamFrameDecoder, l as RoomTransportCleanupFailure, B as WorldClient, a as WorldClientReceiptSchema, o as WorldClientRequestIdSchema, s as WorldClientTicketSchema, Q as captureRoomClientReliableChannel, re as captureRoomClientReliableIntention, u as captureRoomTransportEndpoints, A as createRoom, j as createRoomClient, m as defaultRoomClockPingCadence, G as defaultRoomClockSampling, f as defaultRoomInputRedundancy, h as defaultRoomReconnectPolicy, g as defaultRoomWebSocketFactory, x as defaultRoomWebTransportFactory, y as encodeRoomStreamFrame, M as joinById, N as joinRoom, te as joinSeat, P as joinWorld, w as listRooms, b as makeRoomStreamTransport, z as makeWorldEntityHandoffView, c as makeWorldHandoffView, _ as openRoomSocketTransport, S as openRoomWebTransport, K as roomCodecs, T as roomRpcReservations, C as roomTransportConnector, V as worldClientReceipt, H as worldClientTicket, E as worldRpcControls, D as worldRpcFollowerReservations, O as worldRpcPending, k as worldRpcReservations };
@@ -0,0 +1,173 @@
1
+ import { ProtocolError as e, RoomAuthoringError as t } from "./errors.js";
2
+ import { captureRoomTransportClock as n } from "./transportAuthoring.js";
3
+ import { RoomTransportCleanupFailure as r } from "./transportCleanup.js";
4
+ import { RoomStreamFrameDecoder as i } from "./streamFraming.js";
5
+ import { makeRoomStreamTransport as a } from "./streamTransport.js";
6
+ //#region src/webTransportClient.ts
7
+ var o = (t, n) => {
8
+ let r = Reflect.get(globalThis, "WebTransport");
9
+ if (typeof r != "function") throw new e({ detail: "This platform requires a Room WebTransport factory" });
10
+ let i = n === void 0 ? {} : { serverCertificateHashes: [{
11
+ algorithm: "sha-256",
12
+ value: Uint8Array.from(atob(n), (e) => e.charCodeAt(0))
13
+ }] };
14
+ return Reflect.construct(r, [t, {
15
+ requireUnreliable: !1,
16
+ datagramsReadableType: "bytes",
17
+ ...i
18
+ }]);
19
+ }, s = (e) => {
20
+ if (typeof e.createWritable == "function") return () => e.createWritable();
21
+ let t = e.writable;
22
+ return t instanceof WritableStream ? () => t : void 0;
23
+ }, c = async (c, l, u, d) => {
24
+ let f = [
25
+ "factory",
26
+ "clock",
27
+ "connectTimeoutMs",
28
+ "maxFrameBytes",
29
+ "maxChunkBytes",
30
+ "maxFramesPerChunk",
31
+ "maxQueuedBytes",
32
+ "maxListeners",
33
+ "maxDatagramBytes"
34
+ ];
35
+ if (!u || Object.getPrototypeOf(u) !== Object.prototype || Reflect.ownKeys(u).some((e) => {
36
+ let t = Object.getOwnPropertyDescriptor(u, e);
37
+ return typeof e != "string" || !f.includes(e) || !t?.enumerable || !("value" in t);
38
+ }) || u.factory !== void 0 && typeof u.factory != "function" || !Number.isSafeInteger(u.connectTimeoutMs) || u.connectTimeoutMs < 1 || u.connectTimeoutMs > 3e5 || !Number.isSafeInteger(u.maxQueuedBytes) || u.maxQueuedBytes < 1 || u.maxQueuedBytes > 33554432 || !Number.isSafeInteger(u.maxListeners) || u.maxListeners < 1 || u.maxListeners > 1024 || !Number.isSafeInteger(u.maxDatagramBytes) || u.maxDatagramBytes < 1 || u.maxDatagramBytes > 65535) throw new t({
39
+ room: "webtransport",
40
+ detail: "Room WebTransport requires actual providers and bounded budgets"
41
+ });
42
+ let p = Object.freeze({
43
+ maxFrameBytes: u.maxFrameBytes,
44
+ maxChunkBytes: u.maxChunkBytes,
45
+ maxFramesPerChunk: u.maxFramesPerChunk
46
+ });
47
+ new i(p);
48
+ let m = n(u.clock), h = u.factory ?? o, g = u.maxQueuedBytes, _ = u.maxListeners, v = u.maxDatagramBytes, y = u.connectTimeoutMs, b;
49
+ try {
50
+ b = new URL(c);
51
+ } catch {
52
+ throw new e({ detail: "Room WebTransport requires a valid HTTPS address" });
53
+ }
54
+ if (b.protocol !== "https:" || b.username || b.password || b.search || b.hash) throw new e({ detail: "Room WebTransport address must use HTTPS without credentials, query or fragment" });
55
+ if (l.aborted) throw new e({ detail: "Room WebTransport admission was cancelled" });
56
+ let x;
57
+ if (d !== void 0 && !/^[A-Za-z0-9+/]{43}=$/.test(d)) throw new e({ detail: "Room WebTransport certificate hash must be one base64 SHA-256 digest" });
58
+ try {
59
+ x = d === void 0 ? h(b.toString()) : h(b.toString(), d);
60
+ } catch {
61
+ throw new e({ detail: "Room WebTransport native acquisition failed" });
62
+ }
63
+ if (!x || typeof x.close != "function" || typeof x.createBidirectionalStream != "function" || typeof x.ready?.then != "function" || typeof x.closed?.then != "function") {
64
+ typeof x?.ready?.then == "function" && Promise.resolve(x.ready).catch(() => {});
65
+ let t = !1, n = new r(async () => {
66
+ if (x && typeof x.close == "function" && !t && (x.close({
67
+ closeCode: 1e3,
68
+ reason: "Room WebTransport provider admission failed"
69
+ }), t = !0), !t || typeof x.closed?.then != "function") throw new e({ detail: "Room WebTransport provider lifetime remains unknown" });
70
+ await Promise.resolve(x.closed).catch(() => {});
71
+ });
72
+ try {
73
+ await n.cleanupAsync();
74
+ } catch {
75
+ throw n;
76
+ }
77
+ throw new e({ detail: "Room WebTransport provider admission failed" });
78
+ }
79
+ let S = x.close.bind(x), C = x.createBidirectionalStream.bind(x), w = x.ready, T = x.closed, E = new AbortController(), D = !1, O, k, A, j, M, N, P = Promise.resolve(T).then(() => {
80
+ D = !0, E.abort();
81
+ }, () => {
82
+ D = !0, E.abort();
83
+ }), F = () => {
84
+ E.abort();
85
+ };
86
+ l.addEventListener("abort", F, { once: !0 }), l.aborted && E.abort();
87
+ let I = () => {
88
+ O !== void 0 && clearTimeout(O), O = void 0, l.removeEventListener("abort", F);
89
+ }, L = async (e, t) => {
90
+ I(), D || S({
91
+ closeCode: e,
92
+ reason: t
93
+ }), await P;
94
+ }, R = () => {}, z = new Promise((t, n) => {
95
+ let r = () => {
96
+ n(new e({ detail: "Room WebTransport admission was cancelled, closed or exceeded its deadline" }));
97
+ };
98
+ E.signal.addEventListener("abort", r, { once: !0 }), R = () => {
99
+ E.signal.removeEventListener("abort", r);
100
+ }, O = setTimeout(() => {
101
+ E.abort();
102
+ }, y), E.signal.aborted && r();
103
+ }), B = (async () => {
104
+ if (await w, E.signal.aborted) throw new e({ detail: "Room WebTransport closed before stream admission" });
105
+ let t = x.reliability, n = t === void 0 ? Number.isSafeInteger(x.datagrams?.maxDatagramSize) && x.datagrams.maxDatagramSize > 0 && s(x.datagrams) !== void 0 ? "supports-unreliable" : "reliable-only" : t;
106
+ if (n !== "reliable-only" && n !== "supports-unreliable") throw new e({ detail: "Room WebTransport did not establish a reliability capability" });
107
+ let r = await C();
108
+ if (k = {
109
+ readable: r.readable,
110
+ writable: r.writable
111
+ }, E.signal.aborted) throw new e({ detail: "Room WebTransport closed before stream transfer" });
112
+ if (n === "supports-unreliable") {
113
+ let t = x.datagrams, n = t.maxDatagramSize, r = s(t);
114
+ if (!Number.isSafeInteger(n) || n < 1 || n > 65535 || r === void 0) throw new e({ detail: "Room WebTransport did not provide an actual bounded datagram capability" });
115
+ j = t.readable, A = {
116
+ readable: j,
117
+ writable: r()
118
+ }, M = await a({
119
+ ...p,
120
+ reliable: k,
121
+ datagrams: {
122
+ ...A,
123
+ maxDatagramBytes: Math.min(v, n)
124
+ },
125
+ maxQueuedBytes: g,
126
+ maxListeners: _,
127
+ clock: m,
128
+ signal: E.signal,
129
+ release: L
130
+ });
131
+ } else M = await a({
132
+ ...p,
133
+ reliable: k,
134
+ maxQueuedBytes: g,
135
+ maxListeners: _,
136
+ clock: m,
137
+ signal: E.signal,
138
+ release: L
139
+ });
140
+ return M;
141
+ })().catch((e) => {
142
+ throw e instanceof r && (N = e), e;
143
+ });
144
+ try {
145
+ let t = await Promise.race([B, z]);
146
+ if (E.signal.aborted) throw new e({ detail: "Room WebTransport closed during admission" });
147
+ return O !== void 0 && clearTimeout(O), O = void 0, R(), t;
148
+ } catch {
149
+ E.abort(), R();
150
+ let t = /* @__PURE__ */ new Set(), n = new r(async () => {
151
+ if (await L(1e3, "Room WebTransport admission failed"), await Promise.allSettled([B]), M) await M.closeAsync(1e3, "Room WebTransport admission failed");
152
+ else {
153
+ N && await N.cleanupAsync();
154
+ let n = [], r = (e, r) => {
155
+ t.has(e) || n.push(Promise.resolve().then(r).then(() => {
156
+ t.add(e);
157
+ }));
158
+ };
159
+ for (let e of [k, A]) e && (r(e.readable, () => e.readable.cancel()), r(e.writable, () => e.writable.abort()));
160
+ if (j && !A && r(j, () => j.cancel()), (await Promise.allSettled(n)).some((e) => e.status === "rejected")) throw new e({ detail: "Room WebTransport stream cleanup remains incomplete" });
161
+ }
162
+ I();
163
+ });
164
+ try {
165
+ await n.cleanupAsync();
166
+ } catch {
167
+ throw n;
168
+ }
169
+ throw new e({ detail: "Room WebTransport admission failed" });
170
+ }
171
+ };
172
+ //#endregion
173
+ export { o as defaultRoomWebTransportFactory, c as openRoomWebTransport };