@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,182 @@
1
+ import { defaultRoomSpectatorPolicy as e } from "./spectatorPolicy.js";
2
+ import { defaultRoomBudgets as t, defaultRoomReconnectPolicy as n, defaultRoomSnapshotPolicy as r, defaultRoomView as i, defineRoom as a } from "./room.js";
3
+ import { captureRoomSnapshotBudget as o, defaultRoomSnapshotBudget as s } from "./snapshotBudget.js";
4
+ import { leastLoadedRoomHostInRegion as c, resolveRoomHostSelection as l } from "./hostSelection.js";
5
+ import { Effect as u, Schema as d } from "effect";
6
+ //#region src/strategyFixtures.ts
7
+ var f = {
8
+ name: "strategy-fixture",
9
+ state: d.Struct({ n: d.Int }),
10
+ input: d.Struct({}),
11
+ options: d.Struct({}),
12
+ onTick: () => void 0
13
+ }, p = { burst: 31 }, m = { graceMs: 1234 }, h = {
14
+ kind: "slot",
15
+ defaultImplementation: t,
16
+ defaultProbe: {
17
+ run: () => u.sync(() => a({
18
+ ...f,
19
+ budgets: p
20
+ }).budgets.burst),
21
+ expected: 31
22
+ },
23
+ overrideProbe: {
24
+ run: () => u.sync(() => a({
25
+ ...f,
26
+ budgets: p,
27
+ strategies: { budgets: (e) => ({
28
+ ...t(e),
29
+ burst: 7
30
+ }) }
31
+ }).budgets.burst),
32
+ expected: 7
33
+ }
34
+ }, g = {
35
+ kind: "slot",
36
+ defaultImplementation: n,
37
+ defaultProbe: {
38
+ run: () => u.sync(() => a({
39
+ ...f,
40
+ reconnect: m
41
+ }).reconnect.graceMs),
42
+ expected: 1234
43
+ },
44
+ overrideProbe: {
45
+ run: () => u.sync(() => a({
46
+ ...f,
47
+ reconnect: m,
48
+ strategies: { reconnectPolicy: (e) => ({ graceMs: n(e).graceMs * 2 }) }
49
+ }).reconnect.graceMs),
50
+ expected: 2468
51
+ }
52
+ }, _ = {
53
+ kind: "slot",
54
+ defaultImplementation: r,
55
+ defaultProbe: {
56
+ run: () => u.sync(() => a({
57
+ ...f,
58
+ snapshot: {
59
+ everyMs: 1234,
60
+ maxInlineBytes: 8192
61
+ }
62
+ }).snapshot.maxInlineBytes),
63
+ expected: 8192
64
+ },
65
+ overrideProbe: {
66
+ run: () => u.sync(() => a({
67
+ ...f,
68
+ snapshot: {
69
+ everyMs: 1234,
70
+ maxInlineBytes: 8192
71
+ },
72
+ strategies: { snapshotPolicy: (e) => ({
73
+ ...r(e),
74
+ maxInlineBytes: 4096
75
+ }) }
76
+ }).snapshot.maxInlineBytes),
77
+ expected: 4096
78
+ }
79
+ }, v = {
80
+ kind: "slot",
81
+ defaultImplementation: s,
82
+ defaultProbe: {
83
+ run: () => u.sync(() => {
84
+ let e = o(s, {
85
+ budgetBytesPerSec: 10,
86
+ burstBytes: 10
87
+ });
88
+ return e.forced(20, 0), e.metrics().debtBytes;
89
+ }),
90
+ expected: 10
91
+ },
92
+ overrideProbe: {
93
+ run: () => u.sync(() => {
94
+ let e = o((e) => s({
95
+ ...e,
96
+ burstBytes: 20
97
+ }), {
98
+ budgetBytesPerSec: 10,
99
+ burstBytes: 10
100
+ });
101
+ return e.forced(20, 0), e.metrics().debtBytes;
102
+ }),
103
+ expected: 0
104
+ }
105
+ }, y = () => ({
106
+ state: { n: 7 },
107
+ tick: 1,
108
+ role: "player",
109
+ client: {
110
+ sessionId: "fixture-session",
111
+ subjectId: "fixture-subject",
112
+ tenantId: "fixture-tenant"
113
+ }
114
+ }), b = {
115
+ kind: "slot",
116
+ defaultImplementation: i,
117
+ defaultProbe: {
118
+ run: () => u.sync(() => a(f).view(y()).n),
119
+ expected: 7
120
+ },
121
+ overrideProbe: {
122
+ run: () => u.sync(() => a({
123
+ ...f,
124
+ view: () => ({ n: 0 })
125
+ }).view(y()).n),
126
+ expected: 0
127
+ }
128
+ }, x = () => [{
129
+ id: "first",
130
+ address: "wss://first.invalid/rooms",
131
+ region: "fixture-region",
132
+ capacity: 2,
133
+ rooms: 1,
134
+ clients: 1,
135
+ cpu: .25,
136
+ lastHeartbeatAt: 1,
137
+ ready: !0
138
+ }, {
139
+ id: "second",
140
+ address: "wss://second.invalid/rooms",
141
+ region: "fixture-region",
142
+ capacity: 2,
143
+ rooms: 0,
144
+ clients: 0,
145
+ cpu: .5,
146
+ lastHeartbeatAt: 1,
147
+ ready: !0
148
+ }], S = {
149
+ kind: "slot",
150
+ defaultImplementation: c,
151
+ defaultProbe: {
152
+ run: () => u.sync(() => l(x(), "fixture-region")?.id),
153
+ expected: "second"
154
+ },
155
+ overrideProbe: {
156
+ run: () => u.sync(() => l(x(), "fixture-region", (e) => e[0] ?? null)?.id),
157
+ expected: "first"
158
+ }
159
+ }, C = {
160
+ kind: "slot",
161
+ defaultImplementation: e,
162
+ defaultProbe: {
163
+ run: () => u.sync(() => a({
164
+ ...f,
165
+ spectator: { delayMs: 100 }
166
+ }).spectator?.delayMs),
167
+ expected: 100
168
+ },
169
+ overrideProbe: {
170
+ run: () => u.sync(() => a({
171
+ ...f,
172
+ spectator: { delayMs: 100 },
173
+ strategies: { spectatorPolicy: (t) => ({
174
+ ...e(t),
175
+ delayMs: 200
176
+ }) }
177
+ }).spectator?.delayMs),
178
+ expected: 200
179
+ }
180
+ };
181
+ //#endregion
182
+ export { h as roomBudgetsSlotFixture, g as roomReconnectSlotFixture, S as roomSelectHostSlotFixture, v as roomSnapshotBudgetSlotFixture, _ as roomSnapshotSlotFixture, C as roomSpectatorSlotFixture, b as roomViewSlotFixture };
@@ -0,0 +1,122 @@
1
+ import { BudgetExceeded as e, ProtocolError as t, RoomAuthoringError as n } from "./errors.js";
2
+ //#region src/streamFraming.ts
3
+ var r = (e, t) => {
4
+ if (typeof e != "number" || !Number.isSafeInteger(e) || e < 1 || e > t) throw new n({
5
+ room: "stream-framing",
6
+ detail: "Stream framing requires explicit positive bounded budgets"
7
+ });
8
+ return e;
9
+ }, i = (e) => {
10
+ if (!(e instanceof Uint8Array)) throw new t({ detail: "Room stream chunks must contain binary bytes" });
11
+ return e;
12
+ }, a = (n, a) => {
13
+ let o = i(n), s = r(a, 16777216);
14
+ if (!o.byteLength) throw new t({ detail: "Room stream cannot encode an empty frame" });
15
+ if (o.byteLength > s) throw new e({
16
+ budget: "roomStreamFrameBytes",
17
+ limit: s
18
+ });
19
+ let c = new Uint8Array(o.byteLength + 4);
20
+ return new DataView(c.buffer).setUint32(0, o.byteLength, !1), c.set(o, 4), c;
21
+ }, o = class {
22
+ options;
23
+ header = /* @__PURE__ */ new Uint8Array(4);
24
+ headerBytes = 0;
25
+ payload = null;
26
+ payloadBytes = 0;
27
+ ended = !1;
28
+ constructor(e) {
29
+ if (!e || Object.getPrototypeOf(e) !== Object.prototype || Reflect.ownKeys(e).length !== 3 || [
30
+ "maxFrameBytes",
31
+ "maxChunkBytes",
32
+ "maxFramesPerChunk"
33
+ ].some((t) => {
34
+ let n = Object.getOwnPropertyDescriptor(e, t);
35
+ return !n?.enumerable || !("value" in n);
36
+ })) throw new n({
37
+ room: "stream-framing",
38
+ detail: "Stream framing configuration requires own bounded data"
39
+ });
40
+ this.options = Object.freeze({
41
+ maxFrameBytes: r(e.maxFrameBytes, 16777216),
42
+ maxChunkBytes: r(e.maxChunkBytes, 33554432),
43
+ maxFramesPerChunk: r(e.maxFramesPerChunk, 65536)
44
+ });
45
+ }
46
+ get bufferedBytes() {
47
+ return this.headerBytes + this.payloadBytes;
48
+ }
49
+ push(n) {
50
+ if (this.ended) throw new t({ detail: "Room stream framing is closed or failed" });
51
+ try {
52
+ let r = i(n);
53
+ if (r.byteLength > this.options.maxChunkBytes) throw new e({
54
+ budget: "roomStreamChunkBytes",
55
+ limit: this.options.maxChunkBytes
56
+ });
57
+ let a = [], o = 0;
58
+ for (; o < r.byteLength;) {
59
+ if (this.payload === null) {
60
+ let n = Math.min(4 - this.headerBytes, r.byteLength - o);
61
+ if (this.header.set(r.subarray(o, o + n), this.headerBytes), this.headerBytes += n, o += n, this.headerBytes < 4) break;
62
+ let i = new DataView(this.header.buffer).getUint32(0, !1);
63
+ if (!i) throw new t({ detail: "Room stream declared an empty frame" });
64
+ if (i > this.options.maxFrameBytes) throw new e({
65
+ budget: "roomStreamFrameBytes",
66
+ limit: this.options.maxFrameBytes
67
+ });
68
+ if (a.length >= this.options.maxFramesPerChunk) throw new e({
69
+ budget: "roomStreamFramesPerChunk",
70
+ limit: this.options.maxFramesPerChunk
71
+ });
72
+ this.payload = new Uint8Array(i), this.payloadBytes = 0;
73
+ }
74
+ let n = Math.min(this.payload.byteLength - this.payloadBytes, r.byteLength - o);
75
+ this.payload.set(r.subarray(o, o + n), this.payloadBytes), this.payloadBytes += n, o += n, this.payloadBytes === this.payload.byteLength && (a.push(this.payload), this.payload = null, this.payloadBytes = 0, this.headerBytes = 0);
76
+ }
77
+ return Object.freeze(a);
78
+ } catch (e) {
79
+ throw this.ended = !0, this.payload = null, this.payloadBytes = 0, this.headerBytes = 0, e;
80
+ }
81
+ }
82
+ finish() {
83
+ if (this.ended) throw new t({ detail: "Room stream framing is already closed or failed" });
84
+ this.ended = !0;
85
+ let e = this.headerBytes !== 0 || this.payload !== null;
86
+ if (this.payload = null, this.headerBytes = 0, this.payloadBytes = 0, e) throw new t({ detail: "Room stream ended inside a frame" });
87
+ }
88
+ }, s = class {
89
+ maxDatagramBytes;
90
+ pending = null;
91
+ dropped = 0;
92
+ ended = !1;
93
+ constructor(e) {
94
+ this.maxDatagramBytes = r(e, 65535);
95
+ }
96
+ get droppedDatagrams() {
97
+ return this.dropped;
98
+ }
99
+ get bufferedBytes() {
100
+ return this.pending?.byteLength ?? 0;
101
+ }
102
+ offer(n) {
103
+ if (this.ended) throw new t({ detail: "Room datagram mailbox is closed" });
104
+ let r = i(n);
105
+ if (!r.byteLength) throw new t({ detail: "Room datagram cannot contain an empty frame" });
106
+ if (r.byteLength > this.maxDatagramBytes) throw new e({
107
+ budget: "maxDatagramBytes",
108
+ limit: this.maxDatagramBytes
109
+ });
110
+ this.pending && this.dropped++, this.pending = r.slice();
111
+ }
112
+ take() {
113
+ if (this.ended) throw new t({ detail: "Room datagram mailbox is closed" });
114
+ let e = this.pending;
115
+ return this.pending = null, e;
116
+ }
117
+ close() {
118
+ this.pending && this.dropped++, this.pending = null, this.ended = !0;
119
+ }
120
+ };
121
+ //#endregion
122
+ export { s as RoomLatestDatagram, o as RoomStreamFrameDecoder, a as encodeRoomStreamFrame };
@@ -0,0 +1,266 @@
1
+ import { BudgetExceeded as e, ProtocolError as t, RoomAuthoringError as n } from "./errors.js";
2
+ import { captureRoomTransportClock as r } from "./transportAuthoring.js";
3
+ import { RoomTransportCleanupFailure as i } from "./transportCleanup.js";
4
+ import { RoomLatestDatagram as a, RoomStreamFrameDecoder as o, encodeRoomStreamFrame as s } from "./streamFraming.js";
5
+ //#region src/streamTransport.ts
6
+ var c = (e) => new t({ detail: e }), l = async (t) => {
7
+ let l = [
8
+ "reliable",
9
+ "datagrams",
10
+ "maxFrameBytes",
11
+ "maxChunkBytes",
12
+ "maxFramesPerChunk",
13
+ "maxQueuedBytes",
14
+ "maxListeners",
15
+ "clock",
16
+ "signal",
17
+ "release"
18
+ ];
19
+ if (!t || Object.getPrototypeOf(t) !== Object.prototype || Reflect.ownKeys(t).some((e) => {
20
+ let n = Object.getOwnPropertyDescriptor(t, e);
21
+ return typeof e != "string" || !l.includes(e) || !n?.enumerable || !("value" in n);
22
+ }) || !Number.isSafeInteger(t.maxQueuedBytes) || t.maxQueuedBytes < 1 || t.maxQueuedBytes > 33554432 || !Number.isSafeInteger(t.maxListeners) || t.maxListeners < 1 || t.maxListeners > 1024 || typeof t.release != "function" || !(t.signal instanceof AbortSignal)) throw new n({
23
+ room: "stream-transport",
24
+ detail: "Stream transport requires complete actual providers and bounded budgets"
25
+ });
26
+ let u = (e) => {
27
+ if (!e || Object.getPrototypeOf(e) !== Object.prototype || Reflect.ownKeys(e).some((t) => {
28
+ let n = Object.getOwnPropertyDescriptor(e, t);
29
+ return typeof t != "string" || ![
30
+ "readable",
31
+ "writable",
32
+ "maxDatagramBytes"
33
+ ].includes(t) || !n?.enumerable || !("value" in n);
34
+ }) || !(e.readable instanceof ReadableStream) || !(e.writable instanceof WritableStream)) throw new n({
35
+ room: "stream-transport",
36
+ detail: "Room duplex requires actual transferred readable and writable streams"
37
+ });
38
+ return Object.freeze({
39
+ readable: e.readable,
40
+ writable: e.writable
41
+ });
42
+ }, d = r(t.clock);
43
+ if (t.signal.aborted) throw c("Room stream admission was cancelled before resource transfer");
44
+ let f = u(t.reliable), p = t.datagrams === void 0 ? void 0 : u(t.datagrams), m = new o({
45
+ maxFrameBytes: t.maxFrameBytes,
46
+ maxChunkBytes: t.maxChunkBytes,
47
+ maxFramesPerChunk: t.maxFramesPerChunk
48
+ }), h = t.maxFrameBytes, g = t.maxQueuedBytes, _ = t.maxListeners, v = d.now, y = t.release.bind(t), b = t.signal, x = t.datagrams === void 0 ? void 0 : new a(t.datagrams.maxDatagramBytes), S = [], C, w, T, E;
49
+ try {
50
+ C = f.readable.getReader(), S.push(C), w = f.writable.getWriter(), S.push(w), p && (T = p.readable.getReader(), S.push(T), E = p.writable.getWriter(), S.push(E));
51
+ } catch {
52
+ let e = /* @__PURE__ */ new Set(), t = !1, n = new i(async () => {
53
+ let n = !1;
54
+ for (let t of S) if (!e.has(t)) try {
55
+ t.releaseLock(), e.add(t);
56
+ } catch {
57
+ n = !0;
58
+ }
59
+ if (!t) try {
60
+ await y(1011, "Room stream acquisition failed"), t = !0;
61
+ } catch {
62
+ n = !0;
63
+ }
64
+ if (n) throw c("Room stream acquisition cleanup remains incomplete");
65
+ });
66
+ try {
67
+ await n.cleanupAsync();
68
+ } catch {
69
+ throw n;
70
+ }
71
+ throw c("Room stream acquisition failed");
72
+ }
73
+ let D = new AbortController(), O = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Set(), A = [], j = 0, M, N, P, F, I = !1, L, R = !1, z = -1, B = /* @__PURE__ */ new Set(), V = /* @__PURE__ */ new Set(), H, U = async (e, t) => {
74
+ let n = [], r = async (e, t) => {
75
+ if (!B.has(e)) try {
76
+ await t(), B.add(e);
77
+ } catch (e) {
78
+ n.push(e);
79
+ }
80
+ };
81
+ await Promise.all([
82
+ r(C, () => C.cancel()),
83
+ r(w, () => w.abort()),
84
+ ...T ? [r(T, () => T.cancel())] : [],
85
+ ...E ? [r(E, () => E.abort())] : [],
86
+ (async () => {
87
+ if (!R) try {
88
+ await y(e, t), R = !0;
89
+ } catch (e) {
90
+ n.push(e);
91
+ }
92
+ })()
93
+ ]);
94
+ let i = await Promise.allSettled([
95
+ M,
96
+ N,
97
+ P,
98
+ F
99
+ ].filter((e) => e !== void 0));
100
+ for (let e of i) e.status === "rejected" && n.push(e.reason);
101
+ for (let e of S) if (B.has(e) && !V.has(e)) try {
102
+ e.releaseLock(), V.add(e);
103
+ } catch (e) {
104
+ n.push(e);
105
+ }
106
+ if (n.length) throw c("Room stream transport cleanup remains incomplete");
107
+ }, W = (e, t) => {
108
+ if (!Number.isSafeInteger(e) || e < 0 || e > 4294967295 || typeof t != "string" || !t.isWellFormed() || new TextEncoder().encode(t).byteLength > 1024) return Promise.reject(c("Invalid Room stream close information"));
109
+ if (L) return L;
110
+ if (!I) {
111
+ H = Object.freeze({
112
+ code: e,
113
+ reason: t
114
+ }), I = !0, b.removeEventListener("abort", K), D.abort(c("Room stream transport closed")), O.clear(), k.clear(), x?.close();
115
+ for (let e of A.splice(0)) j -= e.bytes.byteLength, e.reject(c("Room stream write was withdrawn before submission"));
116
+ }
117
+ let n = U(H.code, H.reason);
118
+ return L = n, n.catch(() => {
119
+ L === n && (L = void 0);
120
+ }), n;
121
+ }, G = (e, t) => {
122
+ W(e, t).catch(() => {});
123
+ }, K = () => {
124
+ G(1e3, "Room stream parent admission was cancelled");
125
+ }, q = () => {
126
+ G(1002, "Room stream operation failed");
127
+ }, J = (e, t) => {
128
+ let n = v();
129
+ if (!Number.isFinite(n) || n < 0 || n < z) throw c("Room stream requires a monotonic observation clock");
130
+ z = n;
131
+ for (let r of e) {
132
+ if (I) return;
133
+ r(t.slice(), n);
134
+ }
135
+ }, Y = async () => {
136
+ try {
137
+ for (; !I;) {
138
+ let e = await C.read();
139
+ if (I) return;
140
+ if (e.done) {
141
+ m.finish(), G(1e3, "Room reliable stream ended");
142
+ return;
143
+ }
144
+ for (let t of m.push(e.value)) J(O, t);
145
+ }
146
+ } catch {
147
+ I || q();
148
+ }
149
+ }, X = async () => {
150
+ try {
151
+ for (; !I;) {
152
+ let e = await T.read();
153
+ if (I) return;
154
+ if (e.done) {
155
+ G(1e3, "Room datagram stream ended");
156
+ return;
157
+ }
158
+ if (!(e.value instanceof Uint8Array) || !e.value.byteLength || e.value.byteLength > x.maxDatagramBytes) throw c("Room datagram exceeded its admitted binary budget");
159
+ J(k, e.value);
160
+ }
161
+ } catch {
162
+ I || q();
163
+ }
164
+ }, Z = () => {
165
+ if (P || I) return;
166
+ let e = (async () => {
167
+ for (; !I && A.length;) {
168
+ let e = A.shift();
169
+ try {
170
+ await w.write(e.bytes), I ? e.reject(c("Room native stream write outcome was withdrawn")) : e.resolve();
171
+ } catch {
172
+ e.reject(c("Room native stream write remains incomplete")), I || q();
173
+ } finally {
174
+ j -= e.bytes.byteLength;
175
+ }
176
+ }
177
+ })();
178
+ P = e;
179
+ let t = () => {
180
+ P === e && (P = void 0), !I && A.length && Z();
181
+ };
182
+ e.then(t, () => {
183
+ q(), t();
184
+ });
185
+ }, Q = () => {
186
+ if (F || I) return;
187
+ let e = (async () => {
188
+ try {
189
+ for (; !I && x.bufferedBytes;) {
190
+ if (await E.ready, I) return;
191
+ let e = x.take();
192
+ e && await E.write(e);
193
+ }
194
+ } catch {
195
+ I || q();
196
+ }
197
+ })();
198
+ F = e;
199
+ let t = () => {
200
+ F === e && (F = void 0), !I && x.bufferedBytes && Q();
201
+ };
202
+ e.then(t, () => {
203
+ q(), t();
204
+ });
205
+ }, $ = (t, n, r) => {
206
+ if (typeof n != "function" || I) throw c("Room stream cannot attach a listener after close");
207
+ if (!t.has(n) && t.size >= _) throw new e({
208
+ budget: "roomTransportListeners",
209
+ limit: _
210
+ });
211
+ return t.add(n), r ? N ??= X() : M ??= Y(), () => {
212
+ t.delete(n);
213
+ };
214
+ };
215
+ if (b.addEventListener("abort", K, { once: !0 }), b.aborted) {
216
+ let e = new i(() => W(1e3, "Room stream parent admission was cancelled"));
217
+ try {
218
+ await e.cleanupAsync();
219
+ } catch {
220
+ throw e;
221
+ }
222
+ throw c("Room stream admission was cancelled");
223
+ }
224
+ return Object.freeze({
225
+ name: "wt",
226
+ signal: D.signal,
227
+ reliable: Object.freeze({
228
+ send: (t) => {
229
+ if (I) return Promise.reject(c("Room stream transport is closed"));
230
+ let n;
231
+ try {
232
+ n = s(t, h);
233
+ } catch (e) {
234
+ return Promise.reject(e);
235
+ }
236
+ return j + n.byteLength > g ? (G(1009, "Room stream output exceeded its budget"), Promise.reject(new e({
237
+ budget: "maxQueuedBytes",
238
+ limit: g
239
+ }))) : new Promise((e, t) => {
240
+ j += n.byteLength, A.push({
241
+ bytes: n,
242
+ resolve: e,
243
+ reject: t
244
+ }), Z();
245
+ });
246
+ },
247
+ onFrame: (e) => $(O, e, !1)
248
+ }),
249
+ ...x === void 0 ? {} : { unreliable: Object.freeze({
250
+ maxDatagramBytes: x.maxDatagramBytes,
251
+ send: (e) => {
252
+ x.offer(e), Q();
253
+ },
254
+ onFrame: (e) => $(k, e, !0)
255
+ }) },
256
+ stats: () => ({
257
+ rttMs: null,
258
+ queuedBytes: j,
259
+ droppedDatagrams: x?.droppedDatagrams ?? 0
260
+ }),
261
+ close: G,
262
+ closeAsync: W
263
+ });
264
+ };
265
+ //#endregion
266
+ export { l as makeRoomStreamTransport };
@@ -0,0 +1,50 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { ROOM_SUBJECT_PRIVACY_TABLE as t } from "./identities.js";
3
+ import { canonicalRoomJson as n } from "./checkpointJson.js";
4
+ import { and as r, eq as i, inSet as a } from "@voltro/database";
5
+ import { createHash as o } from "node:crypto";
6
+ //#region src/subjectAdmission.ts
7
+ var s = (t, r) => {
8
+ if (![t, r].every((e) => typeof e == "string" && e.trim().length > 0 && e.length <= 191)) throw new e({ detail: "Rooms Subject admission requires an explicit tenant and identity" });
9
+ return o("sha256").update(n([t, r])).digest("hex");
10
+ }, c = async (n, a) => {
11
+ let o = a.tenantId, c = a.subjectId;
12
+ if (typeof o != "string" || !o.trim() || o.length > 191) throw new e({ detail: "Rooms Subject admission requires an explicit tenant" });
13
+ if (c === null) return;
14
+ let l = s(o, c), u;
15
+ try {
16
+ u = await n.query({
17
+ table: t,
18
+ predicate: r(i("tenantId", o), i("subjectKey", l)),
19
+ order: [],
20
+ take: 2,
21
+ skip: void 0,
22
+ projection: ["tenantId", "subjectKey"]
23
+ });
24
+ } catch {
25
+ throw new e({ detail: "Rooms Subject admission could not be verified" });
26
+ }
27
+ if (!Array.isArray(u) || u.length > 1 || u.some((e) => typeof e != "object" || !e || e.tenantId !== o || e.subjectKey !== l)) throw new e({ detail: "Rooms Subject admission observation changed scope" });
28
+ if (u.length !== 0) throw new e({ detail: "Rooms Subject admission is fenced" });
29
+ }, l = async (n, o, c) => {
30
+ if (typeof o != "string" || !o.trim() || o.length > 191) throw new e({ detail: "Rooms Subject admission requires an explicit tenant" });
31
+ let l = [...new Set(c.map((e) => s(o, e)))];
32
+ if (l.length === 0) return;
33
+ let u;
34
+ try {
35
+ u = await n.query({
36
+ table: t,
37
+ predicate: r(i("tenantId", o), a("subjectKey", l)),
38
+ order: [],
39
+ take: l.length + 1,
40
+ skip: void 0,
41
+ projection: ["tenantId", "subjectKey"]
42
+ });
43
+ } catch {
44
+ throw new e({ detail: "Rooms Subject admission could not be verified" });
45
+ }
46
+ if (!Array.isArray(u) || u.some((e) => typeof e != "object" || !e || e.tenantId !== o || !l.includes(e.subjectKey))) throw new e({ detail: "Rooms Subject admission observation changed scope" });
47
+ if (u.length !== 0) throw new e({ detail: "Rooms Subject admission is fenced" });
48
+ };
49
+ //#endregion
50
+ export { c as assertRoomSubjectAdmission, l as assertRoomSubjectsAdmission, s as roomSubjectPrivacyKey };