@voltro/plugin-rooms 0.0.0-stage → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (495) hide show
  1. package/CHANGELOG.md +24492 -0
  2. package/LICENSE +61 -0
  3. package/README.md +9204 -2
  4. package/SECURITY.md +56 -0
  5. package/THIRD-PARTY-NOTICES.md +12496 -0
  6. package/dist/actor.js +1473 -0
  7. package/dist/apiBinding.js +677 -0
  8. package/dist/apiRegistryBinding.js +398 -0
  9. package/dist/apiReservations.js +432 -0
  10. package/dist/baselines.js +72 -0
  11. package/dist/bots.d.ts +1485 -0
  12. package/dist/bots.js +562 -0
  13. package/dist/catalog.js +79 -0
  14. package/dist/checkpointJson.js +23 -0
  15. package/dist/checkpointStore.js +385 -0
  16. package/dist/client.js +55 -0
  17. package/dist/clockSync.js +50 -0
  18. package/dist/collision.js +155 -0
  19. package/dist/commandDelivery.js +100 -0
  20. package/dist/commandRecord.js +10 -0
  21. package/dist/commandWithdrawal.js +182 -0
  22. package/dist/connection.js +496 -0
  23. package/dist/controlCarrier.js +374 -0
  24. package/dist/controlRegistry.js +78 -0
  25. package/dist/controlTarget.js +44 -0
  26. package/dist/controlTransport.js +573 -0
  27. package/dist/developmentBinding.js +112 -0
  28. package/dist/directory.js +322 -0
  29. package/dist/directoryProjection.js +116 -0
  30. package/dist/errors.d.ts +125 -0
  31. package/dist/errors.js +52 -0
  32. package/dist/fixed.d.ts +284 -0
  33. package/dist/fixed.js +10 -0
  34. package/dist/fixed32.js +133 -0
  35. package/dist/fixedCollision.js +59 -0
  36. package/dist/fixedCollision32.js +108 -0
  37. package/dist/fixedMath.js +55 -0
  38. package/dist/fixedRaw.js +10 -0
  39. package/dist/fixedSlabs.js +33 -0
  40. package/dist/fixedTrig.js +47 -0
  41. package/dist/fixedTrig32.js +37 -0
  42. package/dist/fixedVectors.js +112 -0
  43. package/dist/fixedVectors32.js +94 -0
  44. package/dist/fixedWide.js +49 -0
  45. package/dist/fixedWords.js +45 -0
  46. package/dist/gateway.js +56 -0
  47. package/dist/geometry-retention-app/rooms.geometryJournalRetention.workflow.server.tsx +4 -0
  48. package/dist/geometry-retention-app/rooms.geometryJournalRetention.workflow.tsx +14 -0
  49. package/dist/geometry-worker/worker.d.mts +2 -0
  50. package/dist/geometry-worker/worker.mjs +50 -0
  51. package/dist/geometry.d.ts +2249 -0
  52. package/dist/geometry.js +40 -0
  53. package/dist/geometryActivation.js +81 -0
  54. package/dist/geometryActorInventory.js +107 -0
  55. package/dist/geometryAdminClient.js +86 -0
  56. package/dist/geometryAdminData.js +31 -0
  57. package/dist/geometryAdminFixtures.js +49 -0
  58. package/dist/geometryAdminPorts.js +4 -0
  59. package/dist/geometryAdminRpc.js +57 -0
  60. package/dist/geometryAdminRpcRoutes.js +48 -0
  61. package/dist/geometryAdminSchemas.js +38 -0
  62. package/dist/geometryAdministration.js +189 -0
  63. package/dist/geometryAdministrationPorts.js +4 -0
  64. package/dist/geometryApiBinding.js +164 -0
  65. package/dist/geometryAppStorage.js +57 -0
  66. package/dist/geometryArtifacts.js +197 -0
  67. package/dist/geometryAssetBundle.js +116 -0
  68. package/dist/geometryAssetClient.js +24 -0
  69. package/dist/geometryAssetData.js +105 -0
  70. package/dist/geometryAssetHttp.js +122 -0
  71. package/dist/geometryAssetPorts.js +4 -0
  72. package/dist/geometryAssetRpc.js +29 -0
  73. package/dist/geometryAssetRpcRoutes.js +39 -0
  74. package/dist/geometryAssetStorageGrant.js +102 -0
  75. package/dist/geometryBoxOverlap.js +109 -0
  76. package/dist/geometryCatalogueDigest.js +110 -0
  77. package/dist/geometryCellCoverage.js +84 -0
  78. package/dist/geometryCellLoader.js +27 -0
  79. package/dist/geometryChannel.js +133 -0
  80. package/dist/geometryChunkHttp.js +53 -0
  81. package/dist/geometryChunkLeases.js +21 -0
  82. package/dist/geometryClient.d.ts +1429 -0
  83. package/dist/geometryClient.js +148 -0
  84. package/dist/geometryClientChunks.js +329 -0
  85. package/dist/geometryClientDelta.js +24 -0
  86. package/dist/geometryClientHttp.js +36 -0
  87. package/dist/geometryClientInterest.js +108 -0
  88. package/dist/geometryClientStatic.js +33 -0
  89. package/dist/geometryCms.d.ts +763 -0
  90. package/dist/geometryCms.js +216 -0
  91. package/dist/geometryCommitCoordinator.js +240 -0
  92. package/dist/geometryCompactionFixture.js +83 -0
  93. package/dist/geometryCompactionStrategies.js +37 -0
  94. package/dist/geometryConnectionClient.js +22 -0
  95. package/dist/geometryDerivationFixtures.js +140 -0
  96. package/dist/geometryDerivationStrategies.js +26 -0
  97. package/dist/geometryDigest.js +12 -0
  98. package/dist/geometryEditChannel.js +69 -0
  99. package/dist/geometryEditIngress.js +262 -0
  100. package/dist/geometryEdits.js +365 -0
  101. package/dist/geometryEnvelope.js +40 -0
  102. package/dist/geometryGridRaycast.js +91 -0
  103. package/dist/geometryGridSweep.js +91 -0
  104. package/dist/geometryHeightfield.js +165 -0
  105. package/dist/geometryHeightfieldRaycast.js +73 -0
  106. package/dist/geometryHeightfieldSweep.js +84 -0
  107. package/dist/geometryHeightfieldVolume.js +44 -0
  108. package/dist/geometryHost.js +321 -0
  109. package/dist/geometryHostDirectory.js +206 -0
  110. package/dist/geometryHostMutations.js +136 -0
  111. package/dist/geometryHostStreams.js +123 -0
  112. package/dist/geometryHttpBody.js +75 -0
  113. package/dist/geometryHttpRoutes.js +111 -0
  114. package/dist/geometryImportGltf.js +299 -0
  115. package/dist/geometryImportLdtk.js +53 -0
  116. package/dist/geometryImportPng.js +143 -0
  117. package/dist/geometryImportPublication.js +66 -0
  118. package/dist/geometryImportTiled.js +38 -0
  119. package/dist/geometryImportTiles.js +135 -0
  120. package/dist/geometryImportVox.js +129 -0
  121. package/dist/geometryImportedSource.js +100 -0
  122. package/dist/geometryInspectEndpoint.js +247 -0
  123. package/dist/geometryInspection.js +91 -0
  124. package/dist/geometryInstall.js +120 -0
  125. package/dist/geometryJournalArchiveData.js +20 -0
  126. package/dist/geometryJournalArchiveIndex.js +329 -0
  127. package/dist/geometryJournalArchiveTable.js +20 -0
  128. package/dist/geometryJournalCompaction.js +99 -0
  129. package/dist/geometryJournalPatch.js +46 -0
  130. package/dist/geometryJournalRetention.js +111 -0
  131. package/dist/geometryJournalRetentionSchemas.js +35 -0
  132. package/dist/geometryJournalRetentionSweep.js +111 -0
  133. package/dist/geometryJournalRetentionWorkflow.js +27 -0
  134. package/dist/geometryJournalRetentionWorkflowData.js +30 -0
  135. package/dist/geometryJournalStorage.js +147 -0
  136. package/dist/geometryLoader.js +117 -0
  137. package/dist/geometryManifest.js +112 -0
  138. package/dist/geometryManifestChannel.js +92 -0
  139. package/dist/geometryManifestClient.js +121 -0
  140. package/dist/geometryManifestData.js +48 -0
  141. package/dist/geometryManifestPorts.js +4 -0
  142. package/dist/geometryManifestPublication.js +108 -0
  143. package/dist/geometryManifestSource.js +67 -0
  144. package/dist/geometryMigrationJournal.js +13 -0
  145. package/dist/geometryMigrationStrategies.js +6 -0
  146. package/dist/geometryMigrations.js +322 -0
  147. package/dist/geometryNativeMetadata.js +51 -0
  148. package/dist/geometryPatch.js +169 -0
  149. package/dist/geometryPersistence.js +448 -0
  150. package/dist/geometryPersistenceCapture.js +68 -0
  151. package/dist/geometryPersistenceData.js +139 -0
  152. package/dist/geometryPersistencePorts.js +4 -0
  153. package/dist/geometryPlayerAdmission.js +33 -0
  154. package/dist/geometryPlayerEditOwner.js +264 -0
  155. package/dist/geometryPlayerEdits.js +48 -0
  156. package/dist/geometryPrepared.js +187 -0
  157. package/dist/geometryPrivacyFence.js +23 -0
  158. package/dist/geometryProceduralPublication.js +90 -0
  159. package/dist/geometryProceduralWorker.js +163 -0
  160. package/dist/geometryPublication.js +109 -0
  161. package/dist/geometryRayAlgebra.js +115 -0
  162. package/dist/geometryReadClient.js +156 -0
  163. package/dist/geometryReadPorts.js +4 -0
  164. package/dist/geometryReadRpc.js +26 -0
  165. package/dist/geometryReadRpcRoutes.js +46 -0
  166. package/dist/geometryReliablePublication.js +81 -0
  167. package/dist/geometryReloadPorts.js +45 -0
  168. package/dist/geometryReloadSource.js +277 -0
  169. package/dist/geometryRenderCache.js +164 -0
  170. package/dist/geometryRenderLod.js +101 -0
  171. package/dist/geometryRollback.js +124 -0
  172. package/dist/geometryRollbackCoordinator.js +202 -0
  173. package/dist/geometryRollbackPorts.js +45 -0
  174. package/dist/geometryRollbackSource.js +208 -0
  175. package/dist/geometryRollbackStore.js +197 -0
  176. package/dist/geometrySchemas.js +26 -0
  177. package/dist/geometryServer.d.ts +2766 -0
  178. package/dist/geometryServer.js +62 -0
  179. package/dist/geometryShapeRaycast.js +110 -0
  180. package/dist/geometryShapeSegments.js +33 -0
  181. package/dist/geometryShapes.js +222 -0
  182. package/dist/geometrySnapshot.js +75 -0
  183. package/dist/geometrySnapshotChannel.js +159 -0
  184. package/dist/geometrySnapshotClient.js +158 -0
  185. package/dist/geometrySnapshotPreparation.js +75 -0
  186. package/dist/geometrySnapshotServer.js +190 -0
  187. package/dist/geometrySqlOwner.js +20 -0
  188. package/dist/geometryStorage.js +126 -0
  189. package/dist/geometryStorageGrant.js +68 -0
  190. package/dist/geometryStorageIdentity.js +8 -0
  191. package/dist/geometryTileArtifact.js +9 -0
  192. package/dist/geometryTileCodec.js +193 -0
  193. package/dist/geometryTileCollision.js +95 -0
  194. package/dist/geometryTileNavigation.js +127 -0
  195. package/dist/geometryTileView.js +34 -0
  196. package/dist/geometryVersionActivation.js +113 -0
  197. package/dist/geometryVersionClient.js +237 -0
  198. package/dist/geometryVersionCompare.js +39 -0
  199. package/dist/geometryVersionMigration.js +105 -0
  200. package/dist/geometryVoxel.js +252 -0
  201. package/dist/geometryWorldEntitySubject.js +31 -0
  202. package/dist/geometryWorldExtent.js +11 -0
  203. package/dist/geometryWorldMetadata.js +37 -0
  204. package/dist/geometryWorldStrategyFixtures.js +126 -0
  205. package/dist/geometryWorldView.js +306 -0
  206. package/dist/host.js +127 -0
  207. package/dist/hostBinding.js +276 -0
  208. package/dist/hostCellObservation.js +113 -0
  209. package/dist/hostClientCapacity.js +89 -0
  210. package/dist/hostCommandScope.js +63 -0
  211. package/dist/hostController.js +3093 -0
  212. package/dist/hostDeployment.js +64 -0
  213. package/dist/hostDrain.js +151 -0
  214. package/dist/hostDrainPorts.js +4 -0
  215. package/dist/hostDriver.js +178 -0
  216. package/dist/hostLane.js +287 -0
  217. package/dist/hostListener.js +78 -0
  218. package/dist/hostListenerBinding.js +18 -0
  219. package/dist/hostLoopObservation.js +89 -0
  220. package/dist/hostMetrics.js +55 -0
  221. package/dist/hostRegistryBinding.js +417 -0
  222. package/dist/hostSelection.js +15 -0
  223. package/dist/hostShutdown.js +46 -0
  224. package/dist/hostTurnObservation.js +52 -0
  225. package/dist/identities.js +3 -0
  226. package/dist/index.d.ts +8632 -0
  227. package/dist/index.js +231 -0
  228. package/dist/inputReceipts.js +62 -0
  229. package/dist/inputRedundancy.js +54 -0
  230. package/dist/inspect.js +237 -0
  231. package/dist/lockstep.d.ts +436 -0
  232. package/dist/lockstep.js +381 -0
  233. package/dist/lockstepAdmission.js +261 -0
  234. package/dist/lockstepAdmissionCodec.js +93 -0
  235. package/dist/lockstepAdmissionPorts.js +4 -0
  236. package/dist/lockstepClientSession.js +577 -0
  237. package/dist/lockstepDefinition.js +147 -0
  238. package/dist/lockstepHostLoop.js +242 -0
  239. package/dist/lockstepInitialAdmission.js +66 -0
  240. package/dist/lockstepInitialStrategyFixtures.js +44 -0
  241. package/dist/lockstepJournal.js +394 -0
  242. package/dist/lockstepJournalCodec.js +253 -0
  243. package/dist/lockstepJournalPorts.js +4 -0
  244. package/dist/lockstepJournalRebuild.js +207 -0
  245. package/dist/lockstepJournalRows.js +56 -0
  246. package/dist/lockstepMembers.js +130 -0
  247. package/dist/lockstepMessages.js +46 -0
  248. package/dist/lockstepOwnedRoom.js +763 -0
  249. package/dist/lockstepPolicies.js +83 -0
  250. package/dist/lockstepReact.js +46 -0
  251. package/dist/lockstepRecoveryTruth.js +120 -0
  252. package/dist/lockstepRosterConfig.js +31 -0
  253. package/dist/lockstepSeed.js +11 -0
  254. package/dist/lockstepSeedFixture.js +19 -0
  255. package/dist/lockstepServer.d.ts +3897 -0
  256. package/dist/lockstepServer.js +324 -0
  257. package/dist/lockstepServerConfig.js +100 -0
  258. package/dist/lockstepServerRoles.js +402 -0
  259. package/dist/lockstepServerStrategyFixtures.js +32 -0
  260. package/dist/lockstepStrategies.js +5 -0
  261. package/dist/lockstepStrategyFixtures.js +136 -0
  262. package/dist/lockstepTerminal.js +89 -0
  263. package/dist/lockstepTerminalPorts.js +4 -0
  264. package/dist/lockstepTransport.js +772 -0
  265. package/dist/lockstepTransportConfig.js +31 -0
  266. package/dist/lockstepWireRoster.js +33 -0
  267. package/dist/matchRoomProvider.js +31 -0
  268. package/dist/matchRooms.js +18 -0
  269. package/dist/membershipObserver.js +46 -0
  270. package/dist/moderation.js +97 -0
  271. package/dist/movementSpecials.js +103 -0
  272. package/dist/ownership.js +16 -0
  273. package/dist/ownershipWithdrawal.js +17 -0
  274. package/dist/pcg32.js +95 -0
  275. package/dist/ports.d.ts +1241 -0
  276. package/dist/ports.js +10 -0
  277. package/dist/quaternion.js +69 -0
  278. package/dist/react.d.ts +406 -0
  279. package/dist/react.js +108 -0
  280. package/dist/reaper-app/rooms.reaper.workflow.server.tsx +5 -0
  281. package/dist/reaper-app/rooms.reaper.workflow.tsx +13 -0
  282. package/dist/reaper.js +242 -0
  283. package/dist/reaperSchemas.js +41 -0
  284. package/dist/reaperWorkflow.js +69 -0
  285. package/dist/recovery.js +188 -0
  286. package/dist/recoverySeats.js +25 -0
  287. package/dist/replay.d.ts +273 -0
  288. package/dist/replay.js +484 -0
  289. package/dist/replayPorts.js +4 -0
  290. package/dist/replayRecording.js +66 -0
  291. package/dist/replaySchema.js +156 -0
  292. package/dist/replayStorage.d.ts +149 -0
  293. package/dist/replayStorage.js +484 -0
  294. package/dist/reservationBatch.js +421 -0
  295. package/dist/reservationSchemas.js +16 -0
  296. package/dist/reservations.js +258 -0
  297. package/dist/reservePort.js +68 -0
  298. package/dist/resolvedOptions.js +3 -0
  299. package/dist/room.d.ts +1006 -0
  300. package/dist/room.js +283 -0
  301. package/dist/roomAccessSweep.js +94 -0
  302. package/dist/roomAppCommandControl.js +58 -0
  303. package/dist/roomAuthoringStrategy.js +16 -0
  304. package/dist/roomErasure.js +197 -0
  305. package/dist/roomPoolRuntimeDefaults.js +23 -0
  306. package/dist/roomPoolSelection.js +18 -0
  307. package/dist/roomPoolTopology.js +211 -0
  308. package/dist/rpc.d.ts +551 -0
  309. package/dist/rpc.js +111 -0
  310. package/dist/rpcClient.js +151 -0
  311. package/dist/rpcRoutes.js +27 -0
  312. package/dist/runtime.js +1122 -0
  313. package/dist/schemaHistory.js +97 -0
  314. package/dist/seatStore.js +150 -0
  315. package/dist/seatStrategyFixtures.js +51 -0
  316. package/dist/seatSubject.js +31 -0
  317. package/dist/seats.js +129 -0
  318. package/dist/serverSession.js +810 -0
  319. package/dist/serverSessionConfig.js +42 -0
  320. package/dist/sessionAdmission.js +52 -0
  321. package/dist/sidecarAdmission.js +102 -0
  322. package/dist/sidecarConfig.js +115 -0
  323. package/dist/sidecarConfigPublication.js +63 -0
  324. package/dist/sidecarHostListener.js +207 -0
  325. package/dist/sidecarIpc.js +204 -0
  326. package/dist/sidecarPeer.js +309 -0
  327. package/dist/sidecarProcessPort.js +27 -0
  328. package/dist/sidecarRuntime.js +167 -0
  329. package/dist/sidecarSelection.js +141 -0
  330. package/dist/sidecarWire.js +177 -0
  331. package/dist/sidecarWrites.js +162 -0
  332. package/dist/simulation.d.ts +391 -0
  333. package/dist/simulation.js +281 -0
  334. package/dist/simulationAuthoring.js +28 -0
  335. package/dist/simulationBytes.js +26 -0
  336. package/dist/simulationConformance.js +304 -0
  337. package/dist/simulationInputHistoryCapture.js +34 -0
  338. package/dist/simulationInputHistoryWire.js +192 -0
  339. package/dist/simulationOptionsWire.js +77 -0
  340. package/dist/simulationRecoveryWire.js +133 -0
  341. package/dist/simulationReplay.js +126 -0
  342. package/dist/simulationSnapshotWire.js +111 -0
  343. package/dist/simulationState.js +177 -0
  344. package/dist/snapshotBlob.js +125 -0
  345. package/dist/snapshotBlobCleanup.js +92 -0
  346. package/dist/snapshotBlobIndex.js +37 -0
  347. package/dist/snapshotBudget.js +79 -0
  348. package/dist/snapshotChain.js +184 -0
  349. package/dist/snapshotErasure.js +171 -0
  350. package/dist/snapshotInspection.js +104 -0
  351. package/dist/snapshotSegmentBlobs.js +57 -0
  352. package/dist/snapshotUploads.js +165 -0
  353. package/dist/socketTransport.js +252 -0
  354. package/dist/spatial.js +103 -0
  355. package/dist/spectatorPolicy.js +25 -0
  356. package/dist/spectatorProducer.js +88 -0
  357. package/dist/startFailureCause.js +3 -0
  358. package/dist/stateCodec.js +657 -0
  359. package/dist/strategies.d.ts +210 -0
  360. package/dist/strategies.js +8 -0
  361. package/dist/strategiesServer.d.ts +286 -0
  362. package/dist/strategiesServer.js +11 -0
  363. package/dist/strategyFixtures.js +181 -0
  364. package/dist/streamFraming.js +121 -0
  365. package/dist/streamTransport.js +265 -0
  366. package/dist/subjectAdmission.js +49 -0
  367. package/dist/subjectPrivacy.js +280 -0
  368. package/dist/subjectPrivacyBinding.js +89 -0
  369. package/dist/systemManifest.js +181 -0
  370. package/dist/tables.js +158 -0
  371. package/dist/testHarness.js +88 -0
  372. package/dist/testing.d.ts +3684 -0
  373. package/dist/testing.js +220 -0
  374. package/dist/testingPorts.js +270 -0
  375. package/dist/testingServer.d.ts +4060 -0
  376. package/dist/testingServer.js +18 -0
  377. package/dist/transform.d.ts +692 -0
  378. package/dist/transform.js +216 -0
  379. package/dist/transform3d.js +117 -0
  380. package/dist/transformCollection.js +23 -0
  381. package/dist/transformCollection3d.js +23 -0
  382. package/dist/transformCollectionCore.js +155 -0
  383. package/dist/transformFrames.js +120 -0
  384. package/dist/transformPrediction3d.js +126 -0
  385. package/dist/transformRules.js +122 -0
  386. package/dist/transformSchemas.js +19 -0
  387. package/dist/transport.js +31 -0
  388. package/dist/transportAuthoring.js +28 -0
  389. package/dist/transportCleanup.js +21 -0
  390. package/dist/transportConformance.js +123 -0
  391. package/dist/transportConnector.js +81 -0
  392. package/dist/transportEndpoints.js +37 -0
  393. package/dist/transportsServer.d.ts +5515 -0
  394. package/dist/transportsServer.js +6 -0
  395. package/dist/viewProjection.js +15 -0
  396. package/dist/web.d.ts +2286 -0
  397. package/dist/web.js +517 -0
  398. package/dist/webTransportClient.js +172 -0
  399. package/dist/wire.d.ts +992 -0
  400. package/dist/wire.js +491 -0
  401. package/dist/withdrawalPort.js +27 -0
  402. package/dist/world.d.ts +1894 -0
  403. package/dist/world.js +332 -0
  404. package/dist/worldActorReceipts.js +47 -0
  405. package/dist/worldActorTransferSnapshot.js +13 -0
  406. package/dist/worldAdmissionPending.js +7 -0
  407. package/dist/worldBoundaryCoordinator.js +147 -0
  408. package/dist/worldCatalog.js +80 -0
  409. package/dist/worldCellAllocation.js +202 -0
  410. package/dist/worldCellDestination.js +67 -0
  411. package/dist/worldCells.js +488 -0
  412. package/dist/worldChange.js +31 -0
  413. package/dist/worldClient.js +663 -0
  414. package/dist/worldClientControl.js +140 -0
  415. package/dist/worldClientPendingInput.js +15 -0
  416. package/dist/worldClientRpc.js +132 -0
  417. package/dist/worldClientRpcRoutes.js +42 -0
  418. package/dist/worldClientSchemas.js +27 -0
  419. package/dist/worldCommands.js +139 -0
  420. package/dist/worldData.js +41 -0
  421. package/dist/worldDefaultBinding.js +376 -0
  422. package/dist/worldDefaultGroupAdmission.js +81 -0
  423. package/dist/worldDefaultGroupAppServices.js +30 -0
  424. package/dist/worldDefaultGroupCompensation.js +108 -0
  425. package/dist/worldDefaultGroupContinuation.js +95 -0
  426. package/dist/worldDefaultGroupControl.js +71 -0
  427. package/dist/worldDefaultGroupMembers.js +84 -0
  428. package/dist/worldDefaultGroups.js +20 -0
  429. package/dist/worldDefaultPending.js +78 -0
  430. package/dist/worldDefaultService.js +244 -0
  431. package/dist/worldEntities.js +2979 -0
  432. package/dist/worldEntityCodec.js +20 -0
  433. package/dist/worldEntityHandoffView.js +153 -0
  434. package/dist/worldGeometry.js +169 -0
  435. package/dist/worldGhostAdmission.js +64 -0
  436. package/dist/worldGhostDestination.js +117 -0
  437. package/dist/worldGhostGateway.js +131 -0
  438. package/dist/worldGhostHandshake.js +107 -0
  439. package/dist/worldGhostHost.js +41 -0
  440. package/dist/worldGhostIngress.js +131 -0
  441. package/dist/worldGhostNeighborhood.js +69 -0
  442. package/dist/worldGhostNeighbors.js +85 -0
  443. package/dist/worldGhostOutbound.js +109 -0
  444. package/dist/worldGhostPublisher.js +215 -0
  445. package/dist/worldGhostReceiver.js +212 -0
  446. package/dist/worldGhostSender.js +145 -0
  447. package/dist/worldGhostSocket.js +77 -0
  448. package/dist/worldGhostWire.js +171 -0
  449. package/dist/worldGroupCommand.js +48 -0
  450. package/dist/worldGroupDeadline.js +114 -0
  451. package/dist/worldGroupPreparation.js +114 -0
  452. package/dist/worldGroupReadyControl.js +127 -0
  453. package/dist/worldGroupSupervisor.js +119 -0
  454. package/dist/worldHandoffMetrics.js +58 -0
  455. package/dist/worldHandoffView.js +99 -0
  456. package/dist/worldHostSource.js +68 -0
  457. package/dist/worldInspectEndpoint.js +249 -0
  458. package/dist/worldInspection.js +108 -0
  459. package/dist/worldInstanceAdmission.js +30 -0
  460. package/dist/worldInstanceAllocation.js +115 -0
  461. package/dist/worldInstanceDestination.js +63 -0
  462. package/dist/worldInstanceExpiry.js +281 -0
  463. package/dist/worldInstanceExpirySupervisor.js +87 -0
  464. package/dist/worldInstanceLifecycle.js +102 -0
  465. package/dist/worldInstanceState.js +51 -0
  466. package/dist/worldInstances.js +477 -0
  467. package/dist/worldJoin.js +55 -0
  468. package/dist/worldLayers.js +150 -0
  469. package/dist/worldLeases.js +77 -0
  470. package/dist/worldManifest.js +24 -0
  471. package/dist/worldMovement.js +62 -0
  472. package/dist/worldPersistence.js +133 -0
  473. package/dist/worldProjection.js +220 -0
  474. package/dist/worldReact.js +109 -0
  475. package/dist/worldRecoveryActor.js +34 -0
  476. package/dist/worldReturnAnchor.js +48 -0
  477. package/dist/worldRoomHooks.js +56 -0
  478. package/dist/worldRoomPool.js +26 -0
  479. package/dist/worldRoomSteps.js +132 -0
  480. package/dist/worldSeatBinding.js +35 -0
  481. package/dist/worldServer.d.ts +6936 -0
  482. package/dist/worldServer.js +48 -0
  483. package/dist/worldSourceSeatPending.js +8 -0
  484. package/dist/worldStrategyFixtures.js +163 -0
  485. package/dist/worldTesting.js +26 -0
  486. package/dist/worldTransitionDefaults.js +197 -0
  487. package/dist/worldTransitionExecutor.js +518 -0
  488. package/dist/worldTransitionGroup.js +112 -0
  489. package/dist/worldTransitionPhysicalSteps.js +39 -0
  490. package/dist/worldTransitionResolver.js +227 -0
  491. package/dist/worldTransitionSeatGroup.js +63 -0
  492. package/dist/worldTransitionSeats.js +259 -0
  493. package/dist/worldTransitionState.js +94 -0
  494. package/dist/worldTransitions.js +100 -0
  495. package/package.json +189 -4
@@ -0,0 +1,20 @@
1
+ import { RoomAuthoringError as e } from "./errors.js";
2
+ import { RoomStateCodec as t } from "./stateCodec.js";
3
+ import { Schema as n } from "effect";
4
+ // src/worldEntityCodec.ts
5
+ var r = (r, i = {}) => {
6
+ let a = () => {
7
+ throw new e({
8
+ room: "world-entity-codec",
9
+ detail: "World transfer requires a declared non-optional entities string record"
10
+ });
11
+ }, o = (e) => e.encoding === void 0 ? e : a(), s = o(r.ast);
12
+ if (s._tag !== "Objects") return a();
13
+ let c = s.propertySignatures.find((e) => e.name === "entities");
14
+ if (!c || c.type.context?.isOptional) return a();
15
+ let l = o(c.type);
16
+ if (l._tag !== "Objects" || l.propertySignatures.length !== 0 || l.indexSignatures.length !== 1) return a();
17
+ let u = l.indexSignatures[0];
18
+ return u.parameter._tag === "String" ? new t(n.make(u.type), i) : a();
19
+ };
20
+ export { r as roomWorldEntityCodec };
@@ -0,0 +1,153 @@
1
+ import { BudgetExceeded as e, ProtocolError as t } from "./errors.js";
2
+ import { simulationOwnData as n } from "./simulationAuthoring.js";
3
+ import { captureWorldData as r } from "./worldData.js";
4
+ import { encodeRoomFrame as i } from "./wire.js";
5
+ import { Result as a } from "effect";
6
+ // src/worldEntityHandoffView.ts
7
+ var o = () => new t({ detail: "Entity handoff presentation requires bounded exact delivered views" }), s = (e) => typeof e == "string" && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,190}$/.test(e), c = (t) => {
8
+ let c = [
9
+ "maxEntities",
10
+ "maxBytes",
11
+ "maxHoldMs",
12
+ "maxConnections",
13
+ "now",
14
+ "entity"
15
+ ];
16
+ n(t, c, c);
17
+ let { maxEntities: l, maxBytes: u, maxHoldMs: d, maxConnections: f } = t;
18
+ if (!Number.isSafeInteger(l) || l < 1 || l > 4095 || !Number.isSafeInteger(u) || u < 1 || u > 16777216 || !Number.isSafeInteger(d) || d < 1 || d > 3e5 || !Number.isSafeInteger(f) || f < 1 || f > 128 || typeof t.now != "function" || typeof t.entity != "function") throw o();
19
+ let p = t.now.bind(t), m = t.entity.bind(t), h = new TextEncoder(), g = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), y = 0, b = -1, x = !1, S, C = () => {
20
+ let e = p();
21
+ if (!Number.isSafeInteger(e) || e < 0 || e < b || e > 2 ** 53 - 1 - d) throw o();
22
+ return b = e, e;
23
+ }, w = (e) => {
24
+ let t = g.get(e);
25
+ t && (y -= t.bytes, g.delete(e));
26
+ }, T = () => {
27
+ let e = C();
28
+ for (let [t, n] of g) n.value.expiresAt <= e && w(t);
29
+ return e;
30
+ }, E = () => {
31
+ if (S !== void 0) throw S;
32
+ if (x) throw o();
33
+ }, D = (e, t) => {
34
+ if (!Number.isSafeInteger(e.epoch) || e.epoch < 1 || !Number.isSafeInteger(e.tick) || e.tick < 0 || !Number.isFinite(e.receivedAt) || e.receivedAt < 0) throw o();
35
+ let n = m(e.state, t);
36
+ if (n instanceof Promise) throw n.catch(() => void 0), o();
37
+ return n;
38
+ }, O = (e, t) => {
39
+ if (E(), T(), !s(e)) throw o();
40
+ if (t) for (let [n, r] of g) {
41
+ let i = r.value;
42
+ i.targetRoomId === e && i.targetEpoch === t.epoch && D(t, i.entityId) !== void 0 && w(n);
43
+ }
44
+ }, k = (t, n, c) => {
45
+ E();
46
+ let f = T();
47
+ if (!s(t) || a.isFailure(i(n))) throw o();
48
+ let p = JSON.stringify([
49
+ t,
50
+ n.sourceEpoch,
51
+ n.transitionId,
52
+ n.entityId
53
+ ]), m = g.get(p);
54
+ if (m && (m.value.targetRoomId !== n.targetRoomId || m.value.targetEpoch !== n.targetEpoch)) throw o();
55
+ if (n.phase === "cancelled") {
56
+ m && w(p);
57
+ return;
58
+ }
59
+ if (m || !c || c.epoch !== n.sourceEpoch || c.tick > n.tick) return;
60
+ let _ = D(c, n.entityId);
61
+ if (_ === void 0) return;
62
+ for (let e of g.values()) if (e.value.sourceRoomId === t && e.value.sourceEpoch === n.sourceEpoch && e.value.entityId === n.entityId) throw o();
63
+ if (g.size >= l) throw new e({
64
+ budget: "worldHandoffEntities",
65
+ limit: l
66
+ });
67
+ if (y >= u) throw new e({
68
+ budget: "worldHandoffProjectionBytes",
69
+ limit: u
70
+ });
71
+ let v = r({
72
+ transitionId: n.transitionId,
73
+ entityId: n.entityId,
74
+ sourceRoomId: t,
75
+ sourceEpoch: n.sourceEpoch,
76
+ sourceTick: c.tick,
77
+ receivedAt: c.receivedAt,
78
+ targetRoomId: n.targetRoomId,
79
+ targetEpoch: n.targetEpoch,
80
+ expiresAt: f + Math.min(d, n.holdMs),
81
+ entity: _
82
+ }, u - y), b = h.encode(JSON.stringify(v)).byteLength;
83
+ g.set(p, {
84
+ value: v,
85
+ bytes: b
86
+ }), y += b;
87
+ }, A = () => {
88
+ x = !0, g.clear(), y = 0;
89
+ let e = [];
90
+ for (let t of [..._.values()]) try {
91
+ t();
92
+ } catch (t) {
93
+ e.push(t);
94
+ }
95
+ if (e.length) throw AggregateError(e, "World handoff listener cleanup incomplete");
96
+ };
97
+ return Object.freeze({
98
+ notice: k,
99
+ observe: O,
100
+ read: (e, t) => (O(e, t), Object.freeze([...g.values()].filter(({ value: n }) => !(n.sourceRoomId !== e && n.targetRoomId !== e || t && !(n.sourceRoomId === e && n.sourceEpoch === t.epoch || n.targetRoomId === e && n.targetEpoch === t.epoch) || t && t.epoch === n.sourceEpoch && e === n.sourceRoomId && D(t, n.entityId) !== void 0)).map((e) => e.value))),
101
+ attach: (t, n) => {
102
+ if (E(), T(), !s(t) || _.has(t)) throw o();
103
+ if (_.size >= f) throw new e({
104
+ budget: "worldHandoffConnections",
105
+ limit: f
106
+ });
107
+ let r = n.deliveredSnapshot.bind(n), i = n.onWorldHandoff.bind(n), a = n.subscribe.bind(n), c = [], l = () => {
108
+ let e = [];
109
+ for (let t of [...c]) try {
110
+ t(), c.splice(c.indexOf(t), 1);
111
+ } catch (t) {
112
+ e.push(t);
113
+ }
114
+ if (c.length || (_.delete(t), v.delete(t)), e.length) throw AggregateError(e, "World handoff binding cleanup incomplete");
115
+ }, u = (e) => {
116
+ if (!x) try {
117
+ e();
118
+ } catch (e) {
119
+ S = e;
120
+ try {
121
+ A();
122
+ } catch (t) {
123
+ S = AggregateError([e, t], "World handoff presentation and cleanup failed");
124
+ }
125
+ }
126
+ };
127
+ _.set(t, l), v.set(t, r);
128
+ try {
129
+ if (c.push(i((e) => u(() => {
130
+ k(t, e, r());
131
+ let n = v.get(e.targetRoomId);
132
+ n && O(e.targetRoomId, n());
133
+ }))), x || (c.push(a(() => u(() => O(t, r())))), x)) throw S ?? o();
134
+ O(t, r());
135
+ } catch (e) {
136
+ try {
137
+ l();
138
+ } catch (t) {
139
+ throw AggregateError([e, t], "World handoff attachment failed");
140
+ }
141
+ throw e;
142
+ }
143
+ return l;
144
+ },
145
+ stats: () => (E(), T(), Object.freeze({
146
+ entities: g.size,
147
+ bytes: y,
148
+ connections: _.size
149
+ })),
150
+ close: A
151
+ });
152
+ };
153
+ export { c as makeWorldEntityHandoffView };
@@ -0,0 +1,169 @@
1
+ import { RoomAuthoringError as e } from "./errors.js";
2
+ import { geometryOwnData as t } from "./geometryTileCodec.js";
3
+ import { captureGeometryEditStrategies as n } from "./geometryEdits.js";
4
+ import { captureGeometryDerivationStrategies as r } from "./geometryDerivationStrategies.js";
5
+ import { defaultGeometryMigrateDelta as i } from "./geometryMigrationStrategies.js";
6
+ import { captureGeometryCompactionStrategies as a } from "./geometryCompactionStrategies.js";
7
+ // src/worldGeometry.ts
8
+ var o = /* @__PURE__ */ new WeakSet(), s = /* @__PURE__ */ new WeakMap();
9
+ function c() {
10
+ throw new e({
11
+ room: "world-geometry",
12
+ detail: "World geometry requires complete bounded own configuration and an explicit source"
13
+ });
14
+ }
15
+ var l = (e, t = 96) => typeof e == "string" && e.length <= t && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(e) ? e : c(), u = (e, t, n) => typeof e == "number" && Number.isSafeInteger(e) && e >= t && e <= n ? e === 0 ? 0 : e : c(), d = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && Number.isInteger(e * 65536) && e * 65536 <= 2147483647 ? e * 65536 : c(), f = (e) => (o.add(e), Object.freeze(e)), p = (e, n = {}) => {
16
+ let r = t(n, ["channel"], []);
17
+ return f({
18
+ _tag: "GeometrySource",
19
+ kind: "cms",
20
+ key: l(e, 191),
21
+ channel: Object.hasOwn(r, "channel") ? l(r.channel, 64) : "live"
22
+ });
23
+ }, m = (e) => typeof e != "string" || e.length > 4096 || !e.startsWith("./") || e.includes("\\") || e.includes("%") || e.slice(2).split("/").some((e) => !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(e) || e === "." || e === "..") ? c() : f({
24
+ _tag: "GeometrySource",
25
+ kind: "imported",
26
+ directory: e
27
+ }), h = (e) => {
28
+ let n = t(e, ["seed", "generator"]);
29
+ return typeof n.generator == "function" ? f({
30
+ _tag: "GeometrySource",
31
+ kind: "procedural",
32
+ seed: u(n.seed, 0, 4294967295),
33
+ generator: n.generator
34
+ }) : c();
35
+ }, g = (e) => typeof e != "object" || !e || !o.has(e) ? c() : e, _ = (e, t, n) => {
36
+ if (!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype || e.length > t || Reflect.ownKeys(e).length !== e.length + 1) return c();
37
+ let r = [];
38
+ for (let t = 0; t < e.length; t++) {
39
+ let i = Object.getOwnPropertyDescriptor(e, String(t));
40
+ if (!i?.enumerable || !("value" in i)) return c();
41
+ r.push(n(i.value));
42
+ }
43
+ return Object.freeze(r);
44
+ }, v = (e, n, r) => Object.hasOwn(e, n) ? t(e[n], r, []) : {}, y = (e, t, n, r, i) => Object.hasOwn(e, t) ? u(e[t], r, i) : n, b = (e, t, n) => Object.hasOwn(e, t) ? typeof e[t] == "boolean" ? e[t] : c() : n, x = (e, o) => {
45
+ if (l(o), s.has(e)) return s.get(e) === o ? e : c();
46
+ let f = t(e, [
47
+ "_tag",
48
+ "kind",
49
+ "static",
50
+ "chunkSize",
51
+ "chunkSizeRaw",
52
+ "dynamic",
53
+ "collision",
54
+ "nav",
55
+ "streaming",
56
+ "lod",
57
+ "budgets",
58
+ "strategies"
59
+ ], ["kind", "static"]), p = f.kind;
60
+ if (![
61
+ "2d-tiles",
62
+ "2d-heightfield",
63
+ "3d-voxel",
64
+ "3d-shapes"
65
+ ].includes(p)) return c();
66
+ let m = v(f, "strategies", [
67
+ "migrateDelta",
68
+ "opValidator",
69
+ "applyOp",
70
+ "collisionDerive",
71
+ "navDerive",
72
+ "compaction"
73
+ ]), h = Object.hasOwn(m, "migrateDelta") ? m.migrateDelta : i, x = a(Object.hasOwn(m, "compaction") ? { compaction: m.compaction } : {}), S = r({
74
+ ...Object.hasOwn(m, "collisionDerive") ? { collisionDerive: m.collisionDerive } : {},
75
+ ...Object.hasOwn(m, "navDerive") ? { navDerive: m.navDerive } : {}
76
+ }), C = n({
77
+ ...Object.hasOwn(m, "opValidator") ? { opValidator: m.opValidator } : {},
78
+ ...Object.hasOwn(m, "applyOp") ? { applyOp: m.applyOp } : {}
79
+ });
80
+ if (typeof h != "function") return c();
81
+ let w = g(f.static), T = Object.hasOwn(f, "chunkSize") ? f.chunkSize : 64, E = d(T), D = v(f, "dynamic", [
82
+ "enabled",
83
+ "maxDeltaBytesPerChunk",
84
+ "persist"
85
+ ]), O = v(D, "persist", ["everyMs", "onUnload"]), k = Object.freeze({
86
+ enabled: b(D, "enabled", !1),
87
+ maxDeltaBytesPerChunk: y(D, "maxDeltaBytesPerChunk", 262144, 512, 16777216),
88
+ persist: Object.freeze({
89
+ everyMs: y(O, "everyMs", 1e4, 1, 864e5),
90
+ onUnload: b(O, "onUnload", !0)
91
+ })
92
+ }), A = v(f, "collision", [
93
+ "derive",
94
+ "resolution",
95
+ "resolutionRaw"
96
+ ]), j = p === "2d-heightfield" ? "heightfield" : p === "3d-shapes" ? "shapes" : "bitgrid", M = Object.hasOwn(A, "derive") ? A.derive : j, N = Object.hasOwn(A, "resolution") ? A.resolution : .25, P = d(N);
97
+ if (M !== j || P > E || E % P !== 0) return c();
98
+ let F = Object.freeze({
99
+ derive: j,
100
+ resolution: N,
101
+ resolutionRaw: P
102
+ }), I = v(f, "nav", [
103
+ "derive",
104
+ "navBudgetMs",
105
+ "maxAdvanceSteps"
106
+ ]), L = Object.hasOwn(I, "derive") ? I.derive : p === "2d-tiles" ? "grid" : "none", R = Object.hasOwn(I, "navBudgetMs") ? I.navBudgetMs : 2;
107
+ if (L !== "grid" && L !== "none" || L === "grid" && p !== "2d-tiles" || typeof R != "number" || !Number.isFinite(R) || R <= 0 || R > 1e3) return c();
108
+ let z = Object.freeze({
109
+ derive: L,
110
+ navBudgetMs: R,
111
+ maxAdvanceSteps: y(I, "maxAdvanceSteps", 64, 1, 4096)
112
+ }), B = v(f, "streaming", ["client", "cell"]), V = v(B, "client", [
113
+ "radiusChunks",
114
+ "prefetchChunks",
115
+ "maxConcurrent",
116
+ "maxCachedChunks"
117
+ ]), H = v(B, "cell", ["marginChunks"]), U = y(V, "radiusChunks", 3, 0, 64), W = y(V, "prefetchChunks", 5, 0, 128), G = y(V, "maxConcurrent", 4, 1, 64), K = y(V, "maxCachedChunks", p.startsWith("3d-") ? 512 : 256, 1, 65536), q = y(H, "marginChunks", 1, 0, 64), J = v(f, "budgets", [
118
+ "maxPreparedChunks",
119
+ "maxPreparedBytes",
120
+ "maxLodLevels",
121
+ "maxRayCells",
122
+ "maxOverlapTests"
123
+ ]), Y = Object.freeze({
124
+ maxPreparedChunks: y(J, "maxPreparedChunks", 256, 1, 65536),
125
+ maxPreparedBytes: y(J, "maxPreparedBytes", 52428800, 512, 268435456),
126
+ maxLodLevels: y(J, "maxLodLevels", 8, 0, 32),
127
+ maxRayCells: y(J, "maxRayCells", 4096, 1, 1048576),
128
+ maxOverlapTests: y(J, "maxOverlapTests", 4096, 1, 1048576)
129
+ });
130
+ if (W < U || G > K || K < (2 * U + 1) ** (p.startsWith("3d-") ? 3 : 2)) return c();
131
+ let X = p === "2d-tiles" ? ["tiles"] : p === "2d-heightfield" ? ["heights", "heightsCoarse"] : p === "3d-voxel" ? ["voxels"] : ["shapes"], Z = Object.hasOwn(f, "lod") ? _(f.lod, Y.maxLodLevels, (e) => {
132
+ let n = t(e, ["beyondChunks", "fields"]), r = u(n.beyondChunks, U, 1024), i = _(n.fields, X.length, (e) => typeof e == "string" && X.includes(e) ? e : c());
133
+ return !i.length || new Set(i).size !== i.length ? c() : Object.freeze({
134
+ beyondChunks: r,
135
+ fields: i
136
+ });
137
+ }) : Object.freeze([]);
138
+ for (let e = 1; e < Z.length; e++) if (Z[e - 1].beyondChunks >= Z[e].beyondChunks) return c();
139
+ if (Object.hasOwn(f, "_tag") && f._tag !== "WorldGeometry" || Object.hasOwn(f, "chunkSizeRaw") && f.chunkSizeRaw !== E || Object.hasOwn(A, "resolutionRaw") && A.resolutionRaw !== P) return c();
140
+ let Q = Object.freeze({
141
+ _tag: "WorldGeometry",
142
+ kind: p,
143
+ static: w,
144
+ chunkSize: T,
145
+ chunkSizeRaw: E,
146
+ dynamic: k,
147
+ collision: F,
148
+ nav: z,
149
+ strategies: Object.freeze({
150
+ ...x,
151
+ ...S,
152
+ ...C,
153
+ migrateDelta: h
154
+ }),
155
+ streaming: Object.freeze({
156
+ client: Object.freeze({
157
+ radiusChunks: U,
158
+ prefetchChunks: W,
159
+ maxConcurrent: G,
160
+ maxCachedChunks: K
161
+ }),
162
+ cell: Object.freeze({ marginChunks: q })
163
+ }),
164
+ lod: Z,
165
+ budgets: Y
166
+ });
167
+ return s.set(Q, o), Q;
168
+ };
169
+ export { g as captureGeometrySource, x as captureWorldGeometry, p as cmsGeometry, m as importedGeometry, h as procedural };
@@ -0,0 +1,64 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { captureRoomTransportDataMethod as t } from "./transportAuthoring.js";
3
+ // src/worldGhostAdmission.ts
4
+ var n = () => new e({ detail: "World ghost connection admission refused" }), r = (e, r) => {
5
+ let i = [
6
+ "carrier",
7
+ "epochNow",
8
+ "maxNonces",
9
+ "maxInFlight",
10
+ "authorize"
11
+ ];
12
+ if (!r || Object.getPrototypeOf(r) !== Object.prototype || Reflect.ownKeys(r).length !== i.length || i.some((e) => {
13
+ let t = Object.getOwnPropertyDescriptor(r, e);
14
+ return !t?.enumerable || !("value" in t);
15
+ }) || typeof r.epochNow != "function" || typeof r.authorize != "function" || !Number.isSafeInteger(r.maxNonces) || r.maxNonces < 1 || r.maxNonces > 65536 || !Number.isSafeInteger(r.maxInFlight) || r.maxInFlight < 1 || r.maxInFlight > r.maxNonces) throw n();
16
+ let a = t(r.carrier, "readHello", "Ghost admission requires actual signed Hello verification"), o = t(r.carrier, "welcome", "Ghost admission requires actual Welcome signing"), s = t(e, "admitWorldGhostHandshake", "Ghost admission requires actual Host authority"), c = r.authorize.bind(r), l = r.epochNow.bind(r), u = r.maxNonces, d = r.maxInFlight, f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Set(), m = -1, h = !1, g, _ = () => {
17
+ let e = l();
18
+ if (!Number.isSafeInteger(e) || e < m || e < 0) throw n();
19
+ return m = e, e;
20
+ }, v = () => {
21
+ let e = _();
22
+ for (let [t, n] of f) !n.active && n.expiresAt <= e && f.delete(t);
23
+ };
24
+ return Object.freeze({
25
+ accept: (e, t) => {
26
+ let r;
27
+ try {
28
+ if (h || t.aborted || p.size >= d || (v(), r = a(e), r.expiresAt <= _() || f.has(r.nonce) || f.size >= u)) throw n();
29
+ f.set(r.nonce, {
30
+ expiresAt: r.expiresAt,
31
+ active: !0
32
+ });
33
+ } catch (e) {
34
+ return Promise.reject(e);
35
+ }
36
+ let i = Promise.resolve().then(async () => {
37
+ try {
38
+ if (h || t.aborted || (await s(r, c), h || t.aborted || r.expiresAt <= _())) throw n();
39
+ return Object.freeze({
40
+ hello: r,
41
+ welcome: o(r)
42
+ });
43
+ } finally {
44
+ let e = f.get(r.nonce);
45
+ e && (e.active = !1);
46
+ }
47
+ });
48
+ return p.add(i), i.then(() => {
49
+ p.delete(i);
50
+ }, () => {
51
+ p.delete(i);
52
+ }), i;
53
+ },
54
+ close: () => (h = !0, g || (g = Promise.allSettled([...p]).then(() => {
55
+ f.clear();
56
+ }), g)),
57
+ snapshot: () => (v(), Object.freeze({
58
+ nonces: f.size,
59
+ active: p.size,
60
+ closed: h
61
+ }))
62
+ });
63
+ };
64
+ export { r as makeWorldGhostAdmission };
@@ -0,0 +1,117 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { simulationOwnData as t } from "./simulationAuthoring.js";
3
+ import { captureWorldData as n } from "./worldData.js";
4
+ import { roomHostTransportEndpoints as r } from "./transportEndpoints.js";
5
+ import { ROOMS_TABLE as i, ROOM_HOSTS_TABLE as a } from "./identities.js";
6
+ import { WORLD_CELLS_TABLE as o } from "./worldCells.js";
7
+ import { and as s, eq as c } from "@voltro/database";
8
+ import { Effect as l } from "effect";
9
+ // src/worldGhostDestination.ts
10
+ function u() {
11
+ throw new e({ detail: "World ghost destination is not currently admitted" });
12
+ }
13
+ var d = (e) => typeof e == "string" && e.length > 0 && e.length <= 191 && e.trim() === e ? e : u(), f = (e) => {
14
+ let t = e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : NaN;
15
+ return Number.isSafeInteger(t) && t >= 0 ? t : u();
16
+ }, p = (p, m) => {
17
+ let h = [
18
+ "tenantId",
19
+ "source",
20
+ "path",
21
+ "epochNow",
22
+ "heartbeatTtlMs",
23
+ "authorize"
24
+ ];
25
+ t(m, h, h);
26
+ let g = d(m.tenantId), _ = n(m.source, 1024), v = m.path, y = m.heartbeatTtlMs;
27
+ t(_, [
28
+ "hostId",
29
+ "instanceId",
30
+ "startedAt"
31
+ ], [
32
+ "hostId",
33
+ "instanceId",
34
+ "startedAt"
35
+ ]), d(_.hostId), d(_.instanceId), (!Number.isSafeInteger(_.startedAt) || _.startedAt < 0 || typeof v != "string" || v.length > 191 || !/^\/[A-Za-z0-9/_-]+$/.test(v) || v.startsWith("//") || !Number.isSafeInteger(y) || y < 1 || y > 2147483647 || typeof m.epochNow != "function" || typeof m.authorize != "function") && u();
36
+ let b = m.epochNow.bind(m), x = m.authorize.bind(m), S = () => {
37
+ let e = b();
38
+ return Number.isSafeInteger(e) && e >= 0 ? e : u();
39
+ }, C = async (e, t) => {
40
+ let n = await p.query({
41
+ table: e,
42
+ predicate: t,
43
+ order: [],
44
+ take: 2,
45
+ skip: void 0,
46
+ projection: void 0
47
+ });
48
+ return n.length === 1 ? n[0] : u();
49
+ }, w = async (e) => {
50
+ let t = await C(a, c("id", e));
51
+ return (t.ready !== !0 || t.draining !== !1 || f(t.lastHeartbeatAt) <= S() - y) && u(), {
52
+ row: t,
53
+ peer: Object.freeze({
54
+ hostId: e,
55
+ instanceId: d(t.instanceId),
56
+ startedAt: f(t.membershipStartedAt)
57
+ })
58
+ };
59
+ };
60
+ return Object.freeze({ resolve: (t) => {
61
+ let a;
62
+ try {
63
+ a = n(t, 4096), a && a.tenantId === g && a.state === "live" && a.hostId !== null || u();
64
+ for (let e of [
65
+ a.id,
66
+ a.worldId,
67
+ a.zoneId,
68
+ a.cellId,
69
+ a.roomId,
70
+ a.hostId
71
+ ]) d(e);
72
+ [
73
+ a.layer,
74
+ a.epoch,
75
+ a.revision
76
+ ].every((e) => Number.isSafeInteger(e) && e > 0) || u();
77
+ } catch (t) {
78
+ return l.fail(t instanceof e ? t : new e({ detail: "Invalid World ghost cell observation" }));
79
+ }
80
+ return l.uninterruptible(l.tryPromise({
81
+ try: async () => {
82
+ let e = x(a);
83
+ l.isEffect(e) && await l.runPromise(e) === void 0 || u();
84
+ let t = async () => {
85
+ let e = await C(o, s(c("id", a.id), c("tenantId", g)));
86
+ for (let t of [
87
+ "worldId",
88
+ "zoneId",
89
+ "cellId",
90
+ "layer",
91
+ "roomId",
92
+ "hostId",
93
+ "epoch",
94
+ "revision",
95
+ "state"
96
+ ]) e[t] !== a[t] && u();
97
+ let t = await C(i, s(c("id", a.roomId), c("tenantId", g)));
98
+ (t.hostId !== a.hostId || t.epoch !== a.epoch || t.state !== "live") && u();
99
+ };
100
+ await t();
101
+ let n = await w(_.hostId), d = await w(a.hostId);
102
+ (n.peer.instanceId !== _.instanceId || n.peer.startedAt !== _.startedAt || (n.row.pool ?? null) !== (d.row.pool ?? null)) && u();
103
+ let f = new URL(r(d.row.publicAddress, d.row.webTransportAddress).ws);
104
+ f.toString().length > 2048 && u(), f.pathname = v, await t();
105
+ let p = await w(a.hostId), m = await w(_.hostId);
106
+ return (p.peer.instanceId !== d.peer.instanceId || p.peer.startedAt !== d.peer.startedAt || p.row.publicAddress !== d.row.publicAddress || (p.row.pool ?? null) !== (d.row.pool ?? null) || m.peer.instanceId !== _.instanceId || m.peer.startedAt !== _.startedAt || (m.row.pool ?? null) !== (p.row.pool ?? null)) && u(), Object.freeze({
107
+ address: f.toString(),
108
+ source: _,
109
+ target: p.peer,
110
+ cell: a
111
+ });
112
+ },
113
+ catch: (t) => t instanceof e ? t : new e({ detail: "World ghost routing lookup remains incomplete" })
114
+ }));
115
+ } });
116
+ };
117
+ export { p as dataStoreWorldGhostDestination };
@@ -0,0 +1,131 @@
1
+ import { ProtocolError as e } from "./errors.js";
2
+ import { simulationOwnData as t } from "./simulationAuthoring.js";
3
+ import { captureWorldData as n } from "./worldData.js";
4
+ import { captureRoomTransportDataMethod as r } from "./transportAuthoring.js";
5
+ import { gatewayRoomTransport as i } from "./transport.js";
6
+ import { defineWebSocket as a } from "@voltro/protocol";
7
+ // src/worldGhostGateway.ts
8
+ var o = () => new e({ detail: "World ghost gateway acquisition remains incomplete" }), s = (e, s) => {
9
+ let c = [
10
+ "path",
11
+ "admission",
12
+ "authorize",
13
+ "ingress",
14
+ "limits",
15
+ "maxConnections",
16
+ "maxSignedBytes",
17
+ "verificationTimeoutMs"
18
+ ];
19
+ t(s, c, c);
20
+ let l = s.maxConnections, u = s.maxSignedBytes, d = s.verificationTimeoutMs;
21
+ if (!Number.isSafeInteger(l) || l < 1 || l > 65536 || !Number.isSafeInteger(u) || u < 1024 || u > 65536 || !Number.isSafeInteger(d) || d < 1 || d > 6e4 || typeof s.authorize != "function") throw o();
22
+ let f = n(s.ingress, 1024), p = n(s.limits, 1024), m = s.authorize.bind(s), h = r(s.admission, "accept", "Ghost gateway requires actual signed admission"), g = r(s.admission, "close", "Ghost gateway requires admission withdrawal"), _ = r(e, "bindWorldGhostTransport", "Ghost gateway requires actual target binding");
23
+ if (!Number.isSafeInteger(p.maxMessageBytes) || p.maxMessageBytes < Math.max(u + 1, f.maxFrameBytes + 1, 1025) || !Number.isSafeInteger(p.maxPendingBytes) || p.maxPendingBytes < p.maxMessageBytes || !Number.isSafeInteger(p.maxPendingMessages) || p.maxPendingMessages < 1) throw o();
24
+ let v = /* @__PURE__ */ new Map(), y = !1, b, x = (e) => {
25
+ if (e.closed = !0, e.cleanup) return e.cleanup;
26
+ let t = Promise.resolve().then(async () => {
27
+ let t = [];
28
+ try {
29
+ e.connection?.close(1e3, "World ghost gateway ended");
30
+ } catch (e) {
31
+ t.push(e);
32
+ }
33
+ e.verifying && await e.verifying.catch(() => void 0), e.setup && await e.setup.catch(() => void 0);
34
+ try {
35
+ await e.binding?.close();
36
+ } catch (e) {
37
+ t.push(e);
38
+ }
39
+ if (t.length) throw AggregateError(t, "Ghost gateway cleanup remains incomplete");
40
+ e.signal.removeEventListener("abort", e.abort), v.get(e.signal) === e && v.delete(e.signal);
41
+ });
42
+ return e.cleanup = t, t.catch(() => {
43
+ e.cleanup === t && (e.cleanup = void 0);
44
+ }), t;
45
+ }, S = a({
46
+ path: s.path,
47
+ auth: "token",
48
+ verificationTimeoutMs: d,
49
+ limits: p,
50
+ verify: (e, t) => {
51
+ if (y || t.signal.aborted || v.has(t.signal) || v.size >= l || !(e instanceof Uint8Array) || !e.length || e.length > u) return null;
52
+ let n;
53
+ try {
54
+ n = new TextDecoder("utf-8", { fatal: !0 }).decode(e);
55
+ } catch {
56
+ return null;
57
+ }
58
+ let r = {
59
+ signal: t.signal,
60
+ closed: !1,
61
+ abort: () => {
62
+ x(r).catch(() => void 0);
63
+ }
64
+ };
65
+ v.set(t.signal, r), t.signal.addEventListener("abort", r.abort, { once: !0 });
66
+ let i = Promise.resolve().then(async () => {
67
+ try {
68
+ let e = await h(n, t.signal);
69
+ return y || r.closed || t.signal.aborted ? null : (r.verified = e, { subject: {
70
+ type: "serviceAccount",
71
+ id: e.hello.nonce,
72
+ tenantId: e.hello.tenantId,
73
+ scopes: []
74
+ } });
75
+ } catch {
76
+ return null;
77
+ }
78
+ });
79
+ return r.verifying = i, i.then((e) => {
80
+ e === null && x(r).catch(() => void 0);
81
+ }), i;
82
+ },
83
+ onConnection: (e) => {
84
+ let t = v.get(e.signal);
85
+ if (y || !t?.verified || t.closed || t.setup || e.signal.aborted) throw o();
86
+ t.connection = e;
87
+ let n = Promise.resolve().then(async () => {
88
+ try {
89
+ let n = t.verified;
90
+ if (t.binding = await _(n.hello, i(e), f, m), y || t.closed || e.signal.aborted) throw o();
91
+ let r = new TextEncoder().encode(n.welcome);
92
+ if (!r.length || r.length > u) throw o();
93
+ let a = new Uint8Array(r.length + 1);
94
+ if (a[0] = 0, a.set(r, 1), await e.sendAsync(a), y || t.closed || e.signal.aborted) throw o();
95
+ return () => {
96
+ x(t).catch(() => void 0);
97
+ };
98
+ } catch (n) {
99
+ t.closed = !0;
100
+ try {
101
+ e.close(1008, "World ghost gateway setup refused");
102
+ } catch {}
103
+ throw n;
104
+ }
105
+ });
106
+ return t.setup = n, n.catch(() => {
107
+ x(t).catch(() => void 0);
108
+ }), n;
109
+ }
110
+ });
111
+ return Object.freeze({
112
+ route: S,
113
+ runDue: async () => {
114
+ if ((await Promise.allSettled([...v.values()].filter((e) => e.closed || e.signal.aborted).map(x))).some((e) => e.status === "rejected")) throw o();
115
+ },
116
+ close: () => {
117
+ if (y = !0, b) return b;
118
+ let e = (async () => {
119
+ if ((await Promise.allSettled([g(), ...[...v.values()].map(x)])).some((e) => e.status === "rejected")) throw o();
120
+ })();
121
+ return b = e, e.catch(() => {
122
+ b === e && (b = void 0);
123
+ }), e;
124
+ },
125
+ snapshot: () => Object.freeze({
126
+ connections: v.size,
127
+ closed: y
128
+ })
129
+ });
130
+ };
131
+ export { s as makeWorldGhostGateway };