@dcl/hammurabi-server 1.0.0-17268386187.commit-b609629

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 (520) hide show
  1. package/CLAUDE.md +90 -0
  2. package/LICENSE +201 -0
  3. package/README.md +125 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +79 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/lib/babylon/avatar-rendering-system.d.ts +16 -0
  9. package/dist/lib/babylon/avatar-rendering-system.d.ts.map +1 -0
  10. package/dist/lib/babylon/avatar-rendering-system.js +96 -0
  11. package/dist/lib/babylon/avatar-rendering-system.js.map +1 -0
  12. package/dist/lib/babylon/avatars/AvatarRenderer.d.ts +40 -0
  13. package/dist/lib/babylon/avatars/AvatarRenderer.d.ts.map +1 -0
  14. package/dist/lib/babylon/avatars/AvatarRenderer.js +260 -0
  15. package/dist/lib/babylon/avatars/AvatarRenderer.js.map +1 -0
  16. package/dist/lib/babylon/avatars/CharacterController.d.ts +88 -0
  17. package/dist/lib/babylon/avatars/CharacterController.d.ts.map +1 -0
  18. package/dist/lib/babylon/avatars/CharacterController.js +463 -0
  19. package/dist/lib/babylon/avatars/CharacterController.js.map +1 -0
  20. package/dist/lib/babylon/avatars/adr-65/body.d.ts +4 -0
  21. package/dist/lib/babylon/avatars/adr-65/body.d.ts.map +1 -0
  22. package/dist/lib/babylon/avatars/adr-65/body.js +47 -0
  23. package/dist/lib/babylon/avatars/adr-65/body.js.map +1 -0
  24. package/dist/lib/babylon/avatars/adr-65/customizations.d.ts +11 -0
  25. package/dist/lib/babylon/avatars/adr-65/customizations.d.ts.map +1 -0
  26. package/dist/lib/babylon/avatars/adr-65/customizations.js +111 -0
  27. package/dist/lib/babylon/avatars/adr-65/customizations.js.map +1 -0
  28. package/dist/lib/babylon/avatars/adr-65/emote.d.ts +9 -0
  29. package/dist/lib/babylon/avatars/adr-65/emote.d.ts.map +1 -0
  30. package/dist/lib/babylon/avatars/adr-65/emote.js +46 -0
  31. package/dist/lib/babylon/avatars/adr-65/emote.js.map +1 -0
  32. package/dist/lib/babylon/avatars/adr-65/loader.d.ts +8 -0
  33. package/dist/lib/babylon/avatars/adr-65/loader.d.ts.map +1 -0
  34. package/dist/lib/babylon/avatars/adr-65/loader.js +54 -0
  35. package/dist/lib/babylon/avatars/adr-65/loader.js.map +1 -0
  36. package/dist/lib/babylon/avatars/adr-65/representation.d.ts +12 -0
  37. package/dist/lib/babylon/avatars/adr-65/representation.d.ts.map +1 -0
  38. package/dist/lib/babylon/avatars/adr-65/representation.js +77 -0
  39. package/dist/lib/babylon/avatars/adr-65/representation.js.map +1 -0
  40. package/dist/lib/babylon/avatars/adr-65/slots.d.ts +5 -0
  41. package/dist/lib/babylon/avatars/adr-65/slots.d.ts.map +1 -0
  42. package/dist/lib/babylon/avatars/adr-65/slots.js +62 -0
  43. package/dist/lib/babylon/avatars/adr-65/slots.js.map +1 -0
  44. package/dist/lib/babylon/avatars/adr-65/types.d.ts +17 -0
  45. package/dist/lib/babylon/avatars/adr-65/types.d.ts.map +1 -0
  46. package/dist/lib/babylon/avatars/adr-65/types.js +3 -0
  47. package/dist/lib/babylon/avatars/adr-65/types.js.map +1 -0
  48. package/dist/lib/babylon/avatars/adr-65/utils.d.ts +8 -0
  49. package/dist/lib/babylon/avatars/adr-65/utils.d.ts.map +1 -0
  50. package/dist/lib/babylon/avatars/adr-65/utils.js +29 -0
  51. package/dist/lib/babylon/avatars/adr-65/utils.js.map +1 -0
  52. package/dist/lib/babylon/avatars/adr-65/wearable.d.ts +7 -0
  53. package/dist/lib/babylon/avatars/adr-65/wearable.d.ts.map +1 -0
  54. package/dist/lib/babylon/avatars/adr-65/wearable.js +64 -0
  55. package/dist/lib/babylon/avatars/adr-65/wearable.js.map +1 -0
  56. package/dist/lib/babylon/avatars/avatar-asset-manager.d.ts +12 -0
  57. package/dist/lib/babylon/avatars/avatar-asset-manager.d.ts.map +1 -0
  58. package/dist/lib/babylon/avatars/avatar-asset-manager.js +31 -0
  59. package/dist/lib/babylon/avatars/avatar-asset-manager.js.map +1 -0
  60. package/dist/lib/babylon/avatars/loader.d.ts +6 -0
  61. package/dist/lib/babylon/avatars/loader.d.ts.map +1 -0
  62. package/dist/lib/babylon/avatars/loader.js +108 -0
  63. package/dist/lib/babylon/avatars/loader.js.map +1 -0
  64. package/dist/lib/babylon/avatars/urn.d.ts +2 -0
  65. package/dist/lib/babylon/avatars/urn.d.ts.map +1 -0
  66. package/dist/lib/babylon/avatars/urn.js +9 -0
  67. package/dist/lib/babylon/avatars/urn.js.map +1 -0
  68. package/dist/lib/babylon/index.d.ts +6 -0
  69. package/dist/lib/babylon/index.d.ts.map +1 -0
  70. package/dist/lib/babylon/index.js +85 -0
  71. package/dist/lib/babylon/index.js.map +1 -0
  72. package/dist/lib/babylon/input.d.ts +35 -0
  73. package/dist/lib/babylon/input.d.ts.map +1 -0
  74. package/dist/lib/babylon/input.js +137 -0
  75. package/dist/lib/babylon/input.js.map +1 -0
  76. package/dist/lib/babylon/scene/AssetManager.d.ts +19 -0
  77. package/dist/lib/babylon/scene/AssetManager.d.ts.map +1 -0
  78. package/dist/lib/babylon/scene/AssetManager.js +271 -0
  79. package/dist/lib/babylon/scene/AssetManager.js.map +1 -0
  80. package/dist/lib/babylon/scene/BabylonEntity.d.ts +84 -0
  81. package/dist/lib/babylon/scene/BabylonEntity.d.ts.map +1 -0
  82. package/dist/lib/babylon/scene/BabylonEntity.js +174 -0
  83. package/dist/lib/babylon/scene/BabylonEntity.js.map +1 -0
  84. package/dist/lib/babylon/scene/connect-context-rpc.d.ts +8 -0
  85. package/dist/lib/babylon/scene/connect-context-rpc.d.ts.map +1 -0
  86. package/dist/lib/babylon/scene/connect-context-rpc.js +210 -0
  87. package/dist/lib/babylon/scene/connect-context-rpc.js.map +1 -0
  88. package/dist/lib/babylon/scene/coordinates.d.ts +5 -0
  89. package/dist/lib/babylon/scene/coordinates.d.ts.map +1 -0
  90. package/dist/lib/babylon/scene/coordinates.js +17 -0
  91. package/dist/lib/babylon/scene/coordinates.js.map +1 -0
  92. package/dist/lib/babylon/scene/hot-reload.d.ts +9 -0
  93. package/dist/lib/babylon/scene/hot-reload.d.ts.map +1 -0
  94. package/dist/lib/babylon/scene/hot-reload.js +65 -0
  95. package/dist/lib/babylon/scene/hot-reload.js.map +1 -0
  96. package/dist/lib/babylon/scene/load.d.ts +54 -0
  97. package/dist/lib/babylon/scene/load.d.ts.map +1 -0
  98. package/dist/lib/babylon/scene/load.js +154 -0
  99. package/dist/lib/babylon/scene/load.js.map +1 -0
  100. package/dist/lib/babylon/scene/logic/apply-animations.d.ts +3 -0
  101. package/dist/lib/babylon/scene/logic/apply-animations.d.ts.map +1 -0
  102. package/dist/lib/babylon/scene/logic/apply-animations.js +50 -0
  103. package/dist/lib/babylon/scene/logic/apply-animations.js.map +1 -0
  104. package/dist/lib/babylon/scene/logic/billboards.d.ts +3 -0
  105. package/dist/lib/babylon/scene/logic/billboards.d.ts.map +1 -0
  106. package/dist/lib/babylon/scene/logic/billboards.js +12 -0
  107. package/dist/lib/babylon/scene/logic/billboards.js.map +1 -0
  108. package/dist/lib/babylon/scene/logic/camera-follows-player.d.ts +7 -0
  109. package/dist/lib/babylon/scene/logic/camera-follows-player.d.ts.map +1 -0
  110. package/dist/lib/babylon/scene/logic/camera-follows-player.js +35 -0
  111. package/dist/lib/babylon/scene/logic/camera-follows-player.js.map +1 -0
  112. package/dist/lib/babylon/scene/logic/colliders.d.ts +9 -0
  113. package/dist/lib/babylon/scene/logic/colliders.d.ts.map +1 -0
  114. package/dist/lib/babylon/scene/logic/colliders.js +79 -0
  115. package/dist/lib/babylon/scene/logic/colliders.js.map +1 -0
  116. package/dist/lib/babylon/scene/logic/cyclic-transform.d.ts +12 -0
  117. package/dist/lib/babylon/scene/logic/cyclic-transform.d.ts.map +1 -0
  118. package/dist/lib/babylon/scene/logic/cyclic-transform.js +67 -0
  119. package/dist/lib/babylon/scene/logic/cyclic-transform.js.map +1 -0
  120. package/dist/lib/babylon/scene/logic/delayed-interpolation.d.ts +27 -0
  121. package/dist/lib/babylon/scene/logic/delayed-interpolation.d.ts.map +1 -0
  122. package/dist/lib/babylon/scene/logic/delayed-interpolation.js +49 -0
  123. package/dist/lib/babylon/scene/logic/delayed-interpolation.js.map +1 -0
  124. package/dist/lib/babylon/scene/logic/easings.d.ts +7 -0
  125. package/dist/lib/babylon/scene/logic/easings.d.ts.map +1 -0
  126. package/dist/lib/babylon/scene/logic/easings.js +100 -0
  127. package/dist/lib/babylon/scene/logic/easings.js.map +1 -0
  128. package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.d.ts +5 -0
  129. package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.d.ts.map +1 -0
  130. package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.js +145 -0
  131. package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.js.map +1 -0
  132. package/dist/lib/babylon/scene/logic/local-avatar-scene.d.ts +10 -0
  133. package/dist/lib/babylon/scene/logic/local-avatar-scene.d.ts.map +1 -0
  134. package/dist/lib/babylon/scene/logic/local-avatar-scene.js +50 -0
  135. package/dist/lib/babylon/scene/logic/local-avatar-scene.js.map +1 -0
  136. package/dist/lib/babylon/scene/logic/pointer-events.d.ts +12 -0
  137. package/dist/lib/babylon/scene/logic/pointer-events.d.ts.map +1 -0
  138. package/dist/lib/babylon/scene/logic/pointer-events.js +199 -0
  139. package/dist/lib/babylon/scene/logic/pointer-events.js.map +1 -0
  140. package/dist/lib/babylon/scene/logic/raycasts.d.ts +21 -0
  141. package/dist/lib/babylon/scene/logic/raycasts.d.ts.map +1 -0
  142. package/dist/lib/babylon/scene/logic/raycasts.js +142 -0
  143. package/dist/lib/babylon/scene/logic/raycasts.js.map +1 -0
  144. package/dist/lib/babylon/scene/logic/static-entities.d.ts +18 -0
  145. package/dist/lib/babylon/scene/logic/static-entities.d.ts.map +1 -0
  146. package/dist/lib/babylon/scene/logic/static-entities.js +64 -0
  147. package/dist/lib/babylon/scene/logic/static-entities.js.map +1 -0
  148. package/dist/lib/babylon/scene/nodejs-runtime.d.ts +4 -0
  149. package/dist/lib/babylon/scene/nodejs-runtime.d.ts.map +1 -0
  150. package/dist/lib/babylon/scene/nodejs-runtime.js +100 -0
  151. package/dist/lib/babylon/scene/nodejs-runtime.js.map +1 -0
  152. package/dist/lib/babylon/scene/scene-context.d.ts +116 -0
  153. package/dist/lib/babylon/scene/scene-context.d.ts.map +1 -0
  154. package/dist/lib/babylon/scene/scene-context.js +492 -0
  155. package/dist/lib/babylon/scene/scene-context.js.map +1 -0
  156. package/dist/lib/babylon/scene/scene-culling.d.ts +6 -0
  157. package/dist/lib/babylon/scene/scene-culling.d.ts.map +1 -0
  158. package/dist/lib/babylon/scene/scene-culling.js +23 -0
  159. package/dist/lib/babylon/scene/scene-culling.js.map +1 -0
  160. package/dist/lib/babylon/scene/update-scheduler.d.ts +7 -0
  161. package/dist/lib/babylon/scene/update-scheduler.d.ts.map +1 -0
  162. package/dist/lib/babylon/scene/update-scheduler.js +40 -0
  163. package/dist/lib/babylon/scene/update-scheduler.js.map +1 -0
  164. package/dist/lib/babylon/time-based-animation.d.ts +13 -0
  165. package/dist/lib/babylon/time-based-animation.d.ts.map +1 -0
  166. package/dist/lib/babylon/time-based-animation.js +35 -0
  167. package/dist/lib/babylon/time-based-animation.js.map +1 -0
  168. package/dist/lib/babylon/visual/ambientLights.d.ts +6 -0
  169. package/dist/lib/babylon/visual/ambientLights.d.ts.map +1 -0
  170. package/dist/lib/babylon/visual/ambientLights.js +65 -0
  171. package/dist/lib/babylon/visual/ambientLights.js.map +1 -0
  172. package/dist/lib/babylon/visual/glowLayer.d.ts +6 -0
  173. package/dist/lib/babylon/visual/glowLayer.d.ts.map +1 -0
  174. package/dist/lib/babylon/visual/glowLayer.js +59 -0
  175. package/dist/lib/babylon/visual/glowLayer.js.map +1 -0
  176. package/dist/lib/babylon/visual/parcelOutline.d.ts +7 -0
  177. package/dist/lib/babylon/visual/parcelOutline.d.ts.map +1 -0
  178. package/dist/lib/babylon/visual/parcelOutline.js +88 -0
  179. package/dist/lib/babylon/visual/parcelOutline.js.map +1 -0
  180. package/dist/lib/babylon/visual/reticle.d.ts +3 -0
  181. package/dist/lib/babylon/visual/reticle.d.ts.map +1 -0
  182. package/dist/lib/babylon/visual/reticle.js +60 -0
  183. package/dist/lib/babylon/visual/reticle.js.map +1 -0
  184. package/dist/lib/babylon/visual/ui.d.ts +8 -0
  185. package/dist/lib/babylon/visual/ui.d.ts.map +1 -0
  186. package/dist/lib/babylon/visual/ui.js +54 -0
  187. package/dist/lib/babylon/visual/ui.js.map +1 -0
  188. package/dist/lib/common-runtime/game-loop.d.ts +4 -0
  189. package/dist/lib/common-runtime/game-loop.d.ts.map +1 -0
  190. package/dist/lib/common-runtime/game-loop.js +31 -0
  191. package/dist/lib/common-runtime/game-loop.js.map +1 -0
  192. package/dist/lib/common-runtime/modules.d.ts +244 -0
  193. package/dist/lib/common-runtime/modules.d.ts.map +1 -0
  194. package/dist/lib/common-runtime/modules.js +74 -0
  195. package/dist/lib/common-runtime/modules.js.map +1 -0
  196. package/dist/lib/common-runtime/startup.d.ts +8 -0
  197. package/dist/lib/common-runtime/startup.d.ts.map +1 -0
  198. package/dist/lib/common-runtime/startup.js +45 -0
  199. package/dist/lib/common-runtime/startup.js.map +1 -0
  200. package/dist/lib/common-runtime/types.d.ts +15 -0
  201. package/dist/lib/common-runtime/types.d.ts.map +1 -0
  202. package/dist/lib/common-runtime/types.js +7 -0
  203. package/dist/lib/common-runtime/types.js.map +1 -0
  204. package/dist/lib/decentraland/ByteBuffer/index.d.ts +75 -0
  205. package/dist/lib/decentraland/ByteBuffer/index.d.ts.map +1 -0
  206. package/dist/lib/decentraland/ByteBuffer/index.js +279 -0
  207. package/dist/lib/decentraland/ByteBuffer/index.js.map +1 -0
  208. package/dist/lib/decentraland/ByteBuffer/types.d.ts +109 -0
  209. package/dist/lib/decentraland/ByteBuffer/types.d.ts.map +1 -0
  210. package/dist/lib/decentraland/ByteBuffer/types.js +3 -0
  211. package/dist/lib/decentraland/ByteBuffer/types.js.map +1 -0
  212. package/dist/lib/decentraland/communications/CommsTransportWrapper.d.ts +45 -0
  213. package/dist/lib/decentraland/communications/CommsTransportWrapper.d.ts.map +1 -0
  214. package/dist/lib/decentraland/communications/CommsTransportWrapper.js +174 -0
  215. package/dist/lib/decentraland/communications/CommsTransportWrapper.js.map +1 -0
  216. package/dist/lib/decentraland/communications/avatar-communication-system.d.ts +18 -0
  217. package/dist/lib/decentraland/communications/avatar-communication-system.d.ts.map +1 -0
  218. package/dist/lib/decentraland/communications/avatar-communication-system.js +203 -0
  219. package/dist/lib/decentraland/communications/avatar-communication-system.js.map +1 -0
  220. package/dist/lib/decentraland/communications/connect-adapter.d.ts +5 -0
  221. package/dist/lib/decentraland/communications/connect-adapter.d.ts.map +1 -0
  222. package/dist/lib/decentraland/communications/connect-adapter.js +110 -0
  223. package/dist/lib/decentraland/communications/connect-adapter.js.map +1 -0
  224. package/dist/lib/decentraland/communications/connect-transport.d.ts +5 -0
  225. package/dist/lib/decentraland/communications/connect-transport.d.ts.map +1 -0
  226. package/dist/lib/decentraland/communications/connect-transport.js +32 -0
  227. package/dist/lib/decentraland/communications/connect-transport.js.map +1 -0
  228. package/dist/lib/decentraland/communications/networked-profile-system.d.ts +10 -0
  229. package/dist/lib/decentraland/communications/networked-profile-system.d.ts.map +1 -0
  230. package/dist/lib/decentraland/communications/networked-profile-system.js +73 -0
  231. package/dist/lib/decentraland/communications/networked-profile-system.js.map +1 -0
  232. package/dist/lib/decentraland/communications/player-entity-manager.d.ts +55 -0
  233. package/dist/lib/decentraland/communications/player-entity-manager.d.ts.map +1 -0
  234. package/dist/lib/decentraland/communications/player-entity-manager.js +167 -0
  235. package/dist/lib/decentraland/communications/player-entity-manager.js.map +1 -0
  236. package/dist/lib/decentraland/communications/position-report-system.d.ts +8 -0
  237. package/dist/lib/decentraland/communications/position-report-system.d.ts.map +1 -0
  238. package/dist/lib/decentraland/communications/position-report-system.js +51 -0
  239. package/dist/lib/decentraland/communications/position-report-system.js.map +1 -0
  240. package/dist/lib/decentraland/communications/realm-communications-system.d.ts +17 -0
  241. package/dist/lib/decentraland/communications/realm-communications-system.d.ts.map +1 -0
  242. package/dist/lib/decentraland/communications/realm-communications-system.js +111 -0
  243. package/dist/lib/decentraland/communications/realm-communications-system.js.map +1 -0
  244. package/dist/lib/decentraland/communications/scene-comms.d.ts +9 -0
  245. package/dist/lib/decentraland/communications/scene-comms.d.ts.map +1 -0
  246. package/dist/lib/decentraland/communications/scene-comms.js +20 -0
  247. package/dist/lib/decentraland/communications/scene-comms.js.map +1 -0
  248. package/dist/lib/decentraland/communications/transports/livekit.d.ts +27 -0
  249. package/dist/lib/decentraland/communications/transports/livekit.d.ts.map +1 -0
  250. package/dist/lib/decentraland/communications/transports/livekit.js +135 -0
  251. package/dist/lib/decentraland/communications/transports/livekit.js.map +1 -0
  252. package/dist/lib/decentraland/communications/transports/ws-room.d.ts +26 -0
  253. package/dist/lib/decentraland/communications/transports/ws-room.d.ts.map +1 -0
  254. package/dist/lib/decentraland/communications/transports/ws-room.js +235 -0
  255. package/dist/lib/decentraland/communications/transports/ws-room.js.map +1 -0
  256. package/dist/lib/decentraland/communications/types.d.ts +76 -0
  257. package/dist/lib/decentraland/communications/types.d.ts.map +1 -0
  258. package/dist/lib/decentraland/communications/types.js +6 -0
  259. package/dist/lib/decentraland/communications/types.js.map +1 -0
  260. package/dist/lib/decentraland/communications/ws-async-channel.d.ts +6 -0
  261. package/dist/lib/decentraland/communications/ws-async-channel.d.ts.map +1 -0
  262. package/dist/lib/decentraland/communications/ws-async-channel.js +52 -0
  263. package/dist/lib/decentraland/communications/ws-async-channel.js.map +1 -0
  264. package/dist/lib/decentraland/crdt-internal/components.d.ts +156 -0
  265. package/dist/lib/decentraland/crdt-internal/components.d.ts.map +1 -0
  266. package/dist/lib/decentraland/crdt-internal/components.js +8 -0
  267. package/dist/lib/decentraland/crdt-internal/components.js.map +1 -0
  268. package/dist/lib/decentraland/crdt-internal/conflict-resolution.d.ts +45 -0
  269. package/dist/lib/decentraland/crdt-internal/conflict-resolution.d.ts.map +1 -0
  270. package/dist/lib/decentraland/crdt-internal/conflict-resolution.js +49 -0
  271. package/dist/lib/decentraland/crdt-internal/conflict-resolution.js.map +1 -0
  272. package/dist/lib/decentraland/crdt-internal/dataCompare.d.ts +6 -0
  273. package/dist/lib/decentraland/crdt-internal/dataCompare.d.ts.map +1 -0
  274. package/dist/lib/decentraland/crdt-internal/dataCompare.js +34 -0
  275. package/dist/lib/decentraland/crdt-internal/dataCompare.js.map +1 -0
  276. package/dist/lib/decentraland/crdt-internal/generational-index-pool.d.ts +22 -0
  277. package/dist/lib/decentraland/crdt-internal/generational-index-pool.d.ts.map +1 -0
  278. package/dist/lib/decentraland/crdt-internal/generational-index-pool.js +91 -0
  279. package/dist/lib/decentraland/crdt-internal/generational-index-pool.js.map +1 -0
  280. package/dist/lib/decentraland/crdt-internal/grow-only-set.d.ts +10 -0
  281. package/dist/lib/decentraland/crdt-internal/grow-only-set.d.ts.map +1 -0
  282. package/dist/lib/decentraland/crdt-internal/grow-only-set.js +129 -0
  283. package/dist/lib/decentraland/crdt-internal/grow-only-set.js.map +1 -0
  284. package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.d.ts +11 -0
  285. package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.d.ts.map +1 -0
  286. package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.js +224 -0
  287. package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.js.map +1 -0
  288. package/dist/lib/decentraland/crdt-wire-protocol/appendValue.d.ts +15 -0
  289. package/dist/lib/decentraland/crdt-wire-protocol/appendValue.d.ts.map +1 -0
  290. package/dist/lib/decentraland/crdt-wire-protocol/appendValue.js +50 -0
  291. package/dist/lib/decentraland/crdt-wire-protocol/appendValue.js.map +1 -0
  292. package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.d.ts +31 -0
  293. package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.d.ts.map +1 -0
  294. package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.js +72 -0
  295. package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.js.map +1 -0
  296. package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.d.ts +14 -0
  297. package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.d.ts.map +1 -0
  298. package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.js +44 -0
  299. package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.js.map +1 -0
  300. package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.d.ts +11 -0
  301. package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.d.ts.map +1 -0
  302. package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.js +35 -0
  303. package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.js.map +1 -0
  304. package/dist/lib/decentraland/crdt-wire-protocol/index.d.ts +8 -0
  305. package/dist/lib/decentraland/crdt-wire-protocol/index.d.ts.map +1 -0
  306. package/dist/lib/decentraland/crdt-wire-protocol/index.js +24 -0
  307. package/dist/lib/decentraland/crdt-wire-protocol/index.js.map +1 -0
  308. package/dist/lib/decentraland/crdt-wire-protocol/message.d.ts +17 -0
  309. package/dist/lib/decentraland/crdt-wire-protocol/message.d.ts.map +1 -0
  310. package/dist/lib/decentraland/crdt-wire-protocol/message.js +49 -0
  311. package/dist/lib/decentraland/crdt-wire-protocol/message.js.map +1 -0
  312. package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.d.ts +4 -0
  313. package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.d.ts.map +1 -0
  314. package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.js +26 -0
  315. package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.js.map +1 -0
  316. package/dist/lib/decentraland/crdt-wire-protocol/putComponent.d.ts +15 -0
  317. package/dist/lib/decentraland/crdt-wire-protocol/putComponent.d.ts.map +1 -0
  318. package/dist/lib/decentraland/crdt-wire-protocol/putComponent.js +48 -0
  319. package/dist/lib/decentraland/crdt-wire-protocol/putComponent.js.map +1 -0
  320. package/dist/lib/decentraland/crdt-wire-protocol/types.d.ts +80 -0
  321. package/dist/lib/decentraland/crdt-wire-protocol/types.d.ts.map +1 -0
  322. package/dist/lib/decentraland/crdt-wire-protocol/types.js +15 -0
  323. package/dist/lib/decentraland/crdt-wire-protocol/types.js.map +1 -0
  324. package/dist/lib/decentraland/identifiers.d.ts +6 -0
  325. package/dist/lib/decentraland/identifiers.d.ts.map +1 -0
  326. package/dist/lib/decentraland/identifiers.js +22 -0
  327. package/dist/lib/decentraland/identifiers.js.map +1 -0
  328. package/dist/lib/decentraland/identity/avatar.d.ts +4 -0
  329. package/dist/lib/decentraland/identity/avatar.d.ts.map +1 -0
  330. package/dist/lib/decentraland/identity/avatar.js +57 -0
  331. package/dist/lib/decentraland/identity/avatar.js.map +1 -0
  332. package/dist/lib/decentraland/identity/login.d.ts +8 -0
  333. package/dist/lib/decentraland/identity/login.d.ts.map +1 -0
  334. package/dist/lib/decentraland/identity/login.js +121 -0
  335. package/dist/lib/decentraland/identity/login.js.map +1 -0
  336. package/dist/lib/decentraland/identity/signed-fetch.d.ts +17 -0
  337. package/dist/lib/decentraland/identity/signed-fetch.d.ts.map +1 -0
  338. package/dist/lib/decentraland/identity/signed-fetch.js +47 -0
  339. package/dist/lib/decentraland/identity/signed-fetch.js.map +1 -0
  340. package/dist/lib/decentraland/identity/types.d.ts +11 -0
  341. package/dist/lib/decentraland/identity/types.d.ts.map +1 -0
  342. package/dist/lib/decentraland/identity/types.js +3 -0
  343. package/dist/lib/decentraland/identity/types.js.map +1 -0
  344. package/dist/lib/decentraland/positions.d.ts +15 -0
  345. package/dist/lib/decentraland/positions.d.ts.map +1 -0
  346. package/dist/lib/decentraland/positions.js +40 -0
  347. package/dist/lib/decentraland/positions.js.map +1 -0
  348. package/dist/lib/decentraland/realm/resolution.d.ts +2 -0
  349. package/dist/lib/decentraland/realm/resolution.d.ts.map +1 -0
  350. package/dist/lib/decentraland/realm/resolution.js +39 -0
  351. package/dist/lib/decentraland/realm/resolution.js.map +1 -0
  352. package/dist/lib/decentraland/scene/content-server-entity.d.ts +34 -0
  353. package/dist/lib/decentraland/scene/content-server-entity.d.ts.map +1 -0
  354. package/dist/lib/decentraland/scene/content-server-entity.js +22 -0
  355. package/dist/lib/decentraland/scene/content-server-entity.js.map +1 -0
  356. package/dist/lib/decentraland/scene/spawn-points.d.ts +16 -0
  357. package/dist/lib/decentraland/scene/spawn-points.d.ts.map +1 -0
  358. package/dist/lib/decentraland/scene/spawn-points.js +78 -0
  359. package/dist/lib/decentraland/scene/spawn-points.js.map +1 -0
  360. package/dist/lib/decentraland/scene/types.d.ts +38 -0
  361. package/dist/lib/decentraland/scene/types.d.ts.map +1 -0
  362. package/dist/lib/decentraland/scene/types.js +3 -0
  363. package/dist/lib/decentraland/scene/types.js.map +1 -0
  364. package/dist/lib/decentraland/sdk-components/animator-component.d.ts +3 -0
  365. package/dist/lib/decentraland/sdk-components/animator-component.d.ts.map +1 -0
  366. package/dist/lib/decentraland/sdk-components/animator-component.js +12 -0
  367. package/dist/lib/decentraland/sdk-components/animator-component.js.map +1 -0
  368. package/dist/lib/decentraland/sdk-components/avatar-base.d.ts +5 -0
  369. package/dist/lib/decentraland/sdk-components/avatar-base.d.ts.map +1 -0
  370. package/dist/lib/decentraland/sdk-components/avatar-base.js +40 -0
  371. package/dist/lib/decentraland/sdk-components/avatar-base.js.map +1 -0
  372. package/dist/lib/decentraland/sdk-components/avatar-customizations.d.ts +5 -0
  373. package/dist/lib/decentraland/sdk-components/avatar-customizations.d.ts.map +1 -0
  374. package/dist/lib/decentraland/sdk-components/avatar-customizations.js +9 -0
  375. package/dist/lib/decentraland/sdk-components/avatar-customizations.js.map +1 -0
  376. package/dist/lib/decentraland/sdk-components/avatar-shape.d.ts +5 -0
  377. package/dist/lib/decentraland/sdk-components/avatar-shape.d.ts.map +1 -0
  378. package/dist/lib/decentraland/sdk-components/avatar-shape.js +33 -0
  379. package/dist/lib/decentraland/sdk-components/avatar-shape.js.map +1 -0
  380. package/dist/lib/decentraland/sdk-components/billboard-component.d.ts +3 -0
  381. package/dist/lib/decentraland/sdk-components/billboard-component.d.ts.map +1 -0
  382. package/dist/lib/decentraland/sdk-components/billboard-component.js +15 -0
  383. package/dist/lib/decentraland/sdk-components/billboard-component.js.map +1 -0
  384. package/dist/lib/decentraland/sdk-components/delayed-interpolation.d.ts +3 -0
  385. package/dist/lib/decentraland/sdk-components/delayed-interpolation.d.ts.map +1 -0
  386. package/dist/lib/decentraland/sdk-components/delayed-interpolation.js +15 -0
  387. package/dist/lib/decentraland/sdk-components/delayed-interpolation.js.map +1 -0
  388. package/dist/lib/decentraland/sdk-components/engine-info.d.ts +3 -0
  389. package/dist/lib/decentraland/sdk-components/engine-info.d.ts.map +1 -0
  390. package/dist/lib/decentraland/sdk-components/engine-info.js +7 -0
  391. package/dist/lib/decentraland/sdk-components/engine-info.js.map +1 -0
  392. package/dist/lib/decentraland/sdk-components/gltf-component.d.ts +3 -0
  393. package/dist/lib/decentraland/sdk-components/gltf-component.d.ts.map +1 -0
  394. package/dist/lib/decentraland/sdk-components/gltf-component.js +114 -0
  395. package/dist/lib/decentraland/sdk-components/gltf-component.js.map +1 -0
  396. package/dist/lib/decentraland/sdk-components/gltf-loading-state.d.ts +3 -0
  397. package/dist/lib/decentraland/sdk-components/gltf-loading-state.d.ts.map +1 -0
  398. package/dist/lib/decentraland/sdk-components/gltf-loading-state.js +7 -0
  399. package/dist/lib/decentraland/sdk-components/gltf-loading-state.js.map +1 -0
  400. package/dist/lib/decentraland/sdk-components/material-component.d.ts +5 -0
  401. package/dist/lib/decentraland/sdk-components/material-component.d.ts.map +1 -0
  402. package/dist/lib/decentraland/sdk-components/material-component.js +92 -0
  403. package/dist/lib/decentraland/sdk-components/material-component.js.map +1 -0
  404. package/dist/lib/decentraland/sdk-components/mesh-collider-component.d.ts +3 -0
  405. package/dist/lib/decentraland/sdk-components/mesh-collider-component.d.ts.map +1 -0
  406. package/dist/lib/decentraland/sdk-components/mesh-collider-component.js +37 -0
  407. package/dist/lib/decentraland/sdk-components/mesh-collider-component.js.map +1 -0
  408. package/dist/lib/decentraland/sdk-components/mesh-renderer-component.d.ts +5 -0
  409. package/dist/lib/decentraland/sdk-components/mesh-renderer-component.d.ts.map +1 -0
  410. package/dist/lib/decentraland/sdk-components/mesh-renderer-component.js +111 -0
  411. package/dist/lib/decentraland/sdk-components/mesh-renderer-component.js.map +1 -0
  412. package/dist/lib/decentraland/sdk-components/pb-based-component-helper.d.ts +10 -0
  413. package/dist/lib/decentraland/sdk-components/pb-based-component-helper.d.ts.map +1 -0
  414. package/dist/lib/decentraland/sdk-components/pb-based-component-helper.js +23 -0
  415. package/dist/lib/decentraland/sdk-components/pb-based-component-helper.js.map +1 -0
  416. package/dist/lib/decentraland/sdk-components/player-identity-data.d.ts +3 -0
  417. package/dist/lib/decentraland/sdk-components/player-identity-data.d.ts.map +1 -0
  418. package/dist/lib/decentraland/sdk-components/player-identity-data.js +7 -0
  419. package/dist/lib/decentraland/sdk-components/player-identity-data.js.map +1 -0
  420. package/dist/lib/decentraland/sdk-components/pointer-events-result.d.ts +3 -0
  421. package/dist/lib/decentraland/sdk-components/pointer-events-result.d.ts.map +1 -0
  422. package/dist/lib/decentraland/sdk-components/pointer-events-result.js +7 -0
  423. package/dist/lib/decentraland/sdk-components/pointer-events-result.js.map +1 -0
  424. package/dist/lib/decentraland/sdk-components/pointer-events.d.ts +3 -0
  425. package/dist/lib/decentraland/sdk-components/pointer-events.d.ts.map +1 -0
  426. package/dist/lib/decentraland/sdk-components/pointer-events.js +15 -0
  427. package/dist/lib/decentraland/sdk-components/pointer-events.js.map +1 -0
  428. package/dist/lib/decentraland/sdk-components/raycast-component.d.ts +5 -0
  429. package/dist/lib/decentraland/sdk-components/raycast-component.d.ts.map +1 -0
  430. package/dist/lib/decentraland/sdk-components/raycast-component.js +66 -0
  431. package/dist/lib/decentraland/sdk-components/raycast-component.js.map +1 -0
  432. package/dist/lib/decentraland/sdk-components/transform-component.d.ts +13 -0
  433. package/dist/lib/decentraland/sdk-components/transform-component.d.ts.map +1 -0
  434. package/dist/lib/decentraland/sdk-components/transform-component.js +84 -0
  435. package/dist/lib/decentraland/sdk-components/transform-component.js.map +1 -0
  436. package/dist/lib/decentraland/sdk-components/tween.d.ts +3 -0
  437. package/dist/lib/decentraland/sdk-components/tween.d.ts.map +1 -0
  438. package/dist/lib/decentraland/sdk-components/tween.js +15 -0
  439. package/dist/lib/decentraland/sdk-components/tween.js.map +1 -0
  440. package/dist/lib/decentraland/state.d.ts +24 -0
  441. package/dist/lib/decentraland/state.d.ts.map +1 -0
  442. package/dist/lib/decentraland/state.js +16 -0
  443. package/dist/lib/decentraland/state.js.map +1 -0
  444. package/dist/lib/decentraland/system.d.ts +7 -0
  445. package/dist/lib/decentraland/system.d.ts.map +1 -0
  446. package/dist/lib/decentraland/system.js +13 -0
  447. package/dist/lib/decentraland/system.js.map +1 -0
  448. package/dist/lib/decentraland/types.d.ts +9 -0
  449. package/dist/lib/decentraland/types.d.ts.map +1 -0
  450. package/dist/lib/decentraland/types.js +3 -0
  451. package/dist/lib/decentraland/types.js.map +1 -0
  452. package/dist/lib/decentraland/virtual-scene.d.ts +12 -0
  453. package/dist/lib/decentraland/virtual-scene.d.ts.map +1 -0
  454. package/dist/lib/decentraland/virtual-scene.js +3 -0
  455. package/dist/lib/decentraland/virtual-scene.js.map +1 -0
  456. package/dist/lib/engine-main.d.ts +8 -0
  457. package/dist/lib/engine-main.d.ts.map +1 -0
  458. package/dist/lib/engine-main.js +103 -0
  459. package/dist/lib/engine-main.js.map +1 -0
  460. package/dist/lib/misc/atom.d.ts +13 -0
  461. package/dist/lib/misc/atom.d.ts.map +1 -0
  462. package/dist/lib/misc/atom.js +66 -0
  463. package/dist/lib/misc/atom.js.map +1 -0
  464. package/dist/lib/misc/bit-operations.d.ts +3 -0
  465. package/dist/lib/misc/bit-operations.d.ts.map +1 -0
  466. package/dist/lib/misc/bit-operations.js +14 -0
  467. package/dist/lib/misc/bit-operations.js.map +1 -0
  468. package/dist/lib/misc/flat-fetch.d.ts +16 -0
  469. package/dist/lib/misc/flat-fetch.d.ts.map +1 -0
  470. package/dist/lib/misc/flat-fetch.js +26 -0
  471. package/dist/lib/misc/flat-fetch.js.map +1 -0
  472. package/dist/lib/misc/json.d.ts +3 -0
  473. package/dist/lib/misc/json.d.ts.map +1 -0
  474. package/dist/lib/misc/json.js +24 -0
  475. package/dist/lib/misc/json.js.map +1 -0
  476. package/dist/lib/misc/logger.d.ts +6 -0
  477. package/dist/lib/misc/logger.d.ts.map +1 -0
  478. package/dist/lib/misc/logger.js +24 -0
  479. package/dist/lib/misc/logger.js.map +1 -0
  480. package/dist/lib/misc/memoize.d.ts +2 -0
  481. package/dist/lib/misc/memoize.d.ts.map +1 -0
  482. package/dist/lib/misc/memoize.js +16 -0
  483. package/dist/lib/misc/memoize.js.map +1 -0
  484. package/dist/lib/misc/promises.d.ts +3 -0
  485. package/dist/lib/misc/promises.d.ts.map +1 -0
  486. package/dist/lib/misc/promises.js +14 -0
  487. package/dist/lib/misc/promises.js.map +1 -0
  488. package/dist/lib/polyfills/xmlhttprequest.d.ts +6 -0
  489. package/dist/lib/polyfills/xmlhttprequest.d.ts.map +1 -0
  490. package/dist/lib/polyfills/xmlhttprequest.js +127 -0
  491. package/dist/lib/polyfills/xmlhttprequest.js.map +1 -0
  492. package/dist/lib/quick-js/convert-handles.d.ts +14 -0
  493. package/dist/lib/quick-js/convert-handles.d.ts.map +1 -0
  494. package/dist/lib/quick-js/convert-handles.js +83 -0
  495. package/dist/lib/quick-js/convert-handles.js.map +1 -0
  496. package/dist/lib/quick-js/index.d.ts +12 -0
  497. package/dist/lib/quick-js/index.d.ts.map +1 -0
  498. package/dist/lib/quick-js/index.js +159 -0
  499. package/dist/lib/quick-js/index.js.map +1 -0
  500. package/dist/lib/quick-js/rpc-scene-runtime.d.ts +13 -0
  501. package/dist/lib/quick-js/rpc-scene-runtime.d.ts.map +1 -0
  502. package/dist/lib/quick-js/rpc-scene-runtime.js +32 -0
  503. package/dist/lib/quick-js/rpc-scene-runtime.js.map +1 -0
  504. package/dist/lib/quick-js/types.d.ts +35 -0
  505. package/dist/lib/quick-js/types.d.ts.map +1 -0
  506. package/dist/lib/quick-js/types.js +3 -0
  507. package/dist/lib/quick-js/types.js.map +1 -0
  508. package/dist/lib/web-worker-runtime/context.d.ts +12 -0
  509. package/dist/lib/web-worker-runtime/context.d.ts.map +1 -0
  510. package/dist/lib/web-worker-runtime/context.js +97 -0
  511. package/dist/lib/web-worker-runtime/context.js.map +1 -0
  512. package/dist/lib/web-worker-runtime/sandbox.d.ts +9 -0
  513. package/dist/lib/web-worker-runtime/sandbox.d.ts.map +1 -0
  514. package/dist/lib/web-worker-runtime/sandbox.js +98 -0
  515. package/dist/lib/web-worker-runtime/sandbox.js.map +1 -0
  516. package/dist/lib/web-worker-runtime/web-worker-scene-runtime.d.ts +13 -0
  517. package/dist/lib/web-worker-runtime/web-worker-scene-runtime.d.ts.map +1 -0
  518. package/dist/lib/web-worker-runtime/web-worker-scene-runtime.js +32 -0
  519. package/dist/lib/web-worker-runtime/web-worker-scene-runtime.js.map +1 -0
  520. package/package.json +73 -0
package/CLAUDE.md ADDED
@@ -0,0 +1,90 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Build Commands
6
+
7
+ This project is a headless Node.js server implementation of the Decentraland protocol using Babylon.js NullEngine for 3D scene processing without rendering.
8
+
9
+ ```bash
10
+ # Build TypeScript to JavaScript
11
+ npm run build
12
+
13
+ # Run tests
14
+ npm run test
15
+
16
+ # Start development server
17
+ npm start # runs: ./start --realm=localhost:8000
18
+
19
+ # Run the server with specific realm
20
+ npx @dcl/hammurabi-server --realm=localhost:8000
21
+ ```
22
+
23
+ The project uses simple TypeScript compilation (`tsc`) instead of complex bundling. The compiled output goes to `dist/` folder.
24
+
25
+ ## Project Architecture
26
+
27
+ This is the **Hammurabi Server** - a headless implementation of the Decentraland protocol that runs entirely in Node.js without browser dependencies.
28
+
29
+ ### Core Architecture Components
30
+
31
+ **Engine Initialization (`src/lib/engine-main.ts`)**:
32
+ - Entry point that creates Babylon.js NullEngine for headless 3D processing
33
+ - Creates guest identity for authentication
34
+ - Fetches realm configuration from `/about` endpoint
35
+ - Initializes all systems (avatar rendering, scene culling, character controller, etc.)
36
+ - Scene loading uses `loadSceneContextFromLocal` with hot reload support
37
+
38
+ **Scene Management (`src/lib/babylon/scene/`)**:
39
+ - `SceneContext` - Central class managing scene state, CRDT message processing, and entity lifecycle
40
+ - `BabylonEntity` - Wrapper around Babylon.js objects with component-based architecture
41
+ - **Node.js Runtime**: Uses `connectSceneContextUsingNodeJs` with in-process WebWorker runtime and MemoryTransport (no actual worker threads)
42
+ - Hot reload support for local development
43
+
44
+ **Communications System (`src/lib/decentraland/communications/`)**:
45
+ - **LiveKit Transport** (`transports/livekit.ts`): Uses `@livekit/rtc-node` package for Node.js multiplayer
46
+ - Room management without browser-specific APIs
47
+ - Uses `connectionState` instead of `state` property
48
+ - No `waitForPCInitialConnection()` in Node.js version
49
+ - `CommsTransportWrapper` - Transport abstraction layer
50
+ - Scene-specific communications via `createSceneComms`
51
+ - Local gatekeeper connection at `localhost:3000` for preview scenes
52
+
53
+ **Headless Adaptations**:
54
+ - **Babylon.js** (`src/lib/babylon/index.ts`): Always uses NullEngine, no canvas/WebGL
55
+ - **Avatar Rendering** (`src/lib/babylon/avatars/AvatarRenderer.ts`):
56
+ - Skips UI texture creation when `OffscreenCanvas` is undefined
57
+ - No emote loading in headless mode
58
+ - Avatar components created but not visually rendered
59
+ - **Asset Loading**: Custom XMLHttpRequest polyfill in `cli.ts` for GLTF loading
60
+ - **Environment**: Simplified lighting without complex visual materials
61
+
62
+ ### Key Technical Details
63
+
64
+ - **Node.js 18+**: Uses native fetch API, no polyfills needed
65
+ - **Error Resilience**: Global uncaught exception handlers prevent server crashes
66
+ - **No DOM Dependencies**: All browser-specific code is conditional or removed
67
+ - **LiveKit Node SDK**: Direct imports from `@livekit/rtc-node`, no conditional loading
68
+ - **Entity Allocation**: Unity-compatible reserved ranges (1 for local player, 32-255 for remote)
69
+ - **CRDT Protocol**: Component-based entity system with conflict resolution
70
+ - **Profile System**: ADR-204 compliant with Catalyst-based fetching
71
+
72
+ ### CLI Structure (`src/cli.ts`)
73
+
74
+ The CLI provides:
75
+ - XMLHttpRequest polyfill for Babylon.js asset loading
76
+ - Argument parsing for `--realm`, `--address`, `--authenticated` flags
77
+ - Global error handlers that keep server running despite errors
78
+ - Direct execution as npm bin via `dist/cli.js`
79
+
80
+ ### GitHub Actions Publishing
81
+
82
+ The `.github/workflows/build-release.yaml` workflow:
83
+ - Triggers on pushes to main, all PRs, and releases
84
+ - Uses `decentraland/oddish-action@master` for npm/S3 publishing
85
+ - Creates deterministic snapshots for PR testing
86
+ - Publishes to `@dcl/hammurabi-server` on npm
87
+
88
+ ### Testing
89
+
90
+ The project uses Jest for testing. Integration tests may require the testing realm to be built, though most of that infrastructure has been simplified for the headless server.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # Hammurabi Server
2
+
3
+
4
+ A headless Node.js implementation of the Decentraland protocol using Babylon.js for 3D scene processing.
5
+
6
+ This server can run Decentraland scenes in a headless environment, making it perfect for:
7
+ - **Server-side simulation** of Decentraland worlds
8
+ - **Multiplayer backend** processing with LiveKit communications
9
+ - **Scene validation** and testing infrastructure
10
+ - **Headless bots** and automated agents
11
+ - **Performance testing** without browser overhead
12
+
13
+ **Status: Production Ready** ✅
14
+
15
+ ## Features
16
+
17
+ - 🏃‍♂️ **Headless 3D Processing** - Full Babylon.js scene simulation without rendering
18
+ - 🌐 **LiveKit Communications** - Real multiplayer support via Node.js LiveKit SDK
19
+ - 🤖 **Scene Execution** - Runs Decentraland SDK7 scenes with full ECS support
20
+ - 🔧 **Asset Loading** - GLTF models, textures, and colliders for spatial logic
21
+ - 🎮 **Avatar System** - Multiplayer player management without visual rendering
22
+ - 🔄 **Hot Reload** - Development server with automatic scene updates
23
+ - ⚡ **Error Resilient** - Continues running despite scene errors
24
+
25
+ ## Installation
26
+
27
+ ### Global Installation
28
+ ```bash
29
+ npm install -g @dcl/hammurabi-server
30
+ hammurabi --realm=localhost:8000
31
+ ```
32
+
33
+ ### Local Development
34
+ ```bash
35
+ git clone https://github.com/decentraland/hammurabi
36
+ cd hammurabi
37
+ npm install
38
+ npm run build
39
+ ./hammurabi --realm=localhost:8000
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### Basic Server
45
+ ```bash
46
+ # Connect to local development realm
47
+ hammurabi --realm=localhost:8000
48
+
49
+ # Connect to remote realm
50
+ hammurabi --realm=https://sdk-team-cdn.decentraland.org
51
+ ```
52
+
53
+ ### Programmatic Usage
54
+ ```typescript
55
+ import { main } from '@dcl/hammurabi-server'
56
+
57
+ const scene = await main({
58
+ realmUrl: 'localhost:8000'
59
+ })
60
+
61
+ console.log('Headless scene running:', !!scene)
62
+ ```
63
+
64
+ ## Architecture
65
+
66
+ ### Headless Components
67
+ - **Babylon.js NullEngine** - 3D processing without GPU rendering
68
+ - **In-process Scene Runtime** - WebWorker scripts via QuickJS
69
+ - **LiveKit Node.js SDK** - Multiplayer communications
70
+ - **Asset Manager** - GLTF loading with collider support
71
+ - **Avatar Renderer** - Multiplayer entities without UI textures
72
+
73
+ ### Scene Support
74
+ - **ECS7 Scenes** - Full Decentraland SDK7 compatibility
75
+ - **Component Systems** - Transform, mesh, avatar, pointer events
76
+ - **CRDT Protocol** - Entity state synchronization
77
+ - **Asset Loading** - Models, textures, audio (headless)
78
+ - **Spatial Queries** - Raycasting and collision detection
79
+
80
+ ## Development
81
+
82
+ ### Build
83
+ ```bash
84
+ npm run build # Compile TypeScript
85
+ npm run test # Run test suite
86
+ npm start # Start development server
87
+ ```
88
+
89
+ ### Environment Variables
90
+ ```bash
91
+ # Optional: Configure LiveKit server
92
+ LIVEKIT_URL=wss://your-livekit-server.com
93
+ LIVEKIT_TOKEN=your-jwt-token
94
+ ```
95
+
96
+ ## Configuration
97
+
98
+ The server automatically:
99
+ - Creates guest identity for headless authentication
100
+ - Fetches realm configuration from `/about` endpoint
101
+ - Establishes LiveKit room for multiplayer communications
102
+ - Loads and executes scene scripts in isolated runtime
103
+ - Processes CRDT messages for entity synchronization
104
+
105
+ ## Publishing
106
+
107
+ This package is automatically published via GitHub Actions:
108
+ - **Main branch** → Latest release to npm
109
+ - **Pull requests** → Snapshot versions for testing
110
+ - **Releases** → Tagged versions with provenance
111
+
112
+ ## Contributing
113
+
114
+ 1. Fork the repository
115
+ 2. Create a feature branch: `git checkout -b feat/amazing-feature`
116
+ 3. Make changes and test: `npm run build && npm run test`
117
+ 4. Create pull request - snapshots will be automatically published for testing
118
+
119
+ ## License
120
+
121
+ Apache-2.0
122
+
123
+ ---
124
+
125
+ **Protocol Squad** - Building the future of virtual worlds 🌐
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const engine_main_1 = require("./lib/engine-main");
5
+ // Parse arguments
6
+ const args = process.argv.slice(2);
7
+ let realmUrl = 'localhost:8000';
8
+ for (const arg of args) {
9
+ if (arg === '--help' || arg === '-h') {
10
+ console.log(`
11
+ Usage: npx @dcl/hammurabi-server [--realm=<url>]
12
+
13
+ Options:
14
+ --realm=<url> Realm URL to connect to (default: localhost:8000)
15
+ --help, -h Show this help
16
+
17
+ Example:
18
+ npx @dcl/hammurabi-server --realm=localhost:8000
19
+ `);
20
+ process.exit(0);
21
+ }
22
+ if (arg.startsWith('--realm=')) {
23
+ realmUrl = arg.split('=')[1];
24
+ }
25
+ }
26
+ // Global error handlers
27
+ process.on('uncaughtException', (error) => {
28
+ console.error('❌ Error:', error.message);
29
+ console.log('Press [R] to restart or [Ctrl+C] to exit');
30
+ });
31
+ process.on('unhandledRejection', (reason) => {
32
+ console.error('❌ Error:', reason?.message || reason);
33
+ console.log('Press [R] to restart or [Ctrl+C] to exit');
34
+ });
35
+ // Simple restart mechanism
36
+ let isRestarting = false;
37
+ async function start() {
38
+ try {
39
+ const scene = await (0, engine_main_1.main)({ realmUrl });
40
+ console.log('✅ Server running - Press [R] to restart or [Ctrl+C] to exit');
41
+ return scene;
42
+ }
43
+ catch (error) {
44
+ console.error('❌ Failed to start:', error.message);
45
+ console.log('Press [R] to retry or [Ctrl+C] to exit');
46
+ throw error;
47
+ }
48
+ }
49
+ async function restart() {
50
+ if (isRestarting)
51
+ return;
52
+ isRestarting = true;
53
+ console.log('🔄 Restarting...');
54
+ try {
55
+ (0, engine_main_1.resetEngine)();
56
+ await new Promise(resolve => setTimeout(resolve, 100));
57
+ await start();
58
+ }
59
+ catch (error) {
60
+ console.error('❌ Restart failed');
61
+ }
62
+ isRestarting = false;
63
+ }
64
+ // Key listener
65
+ process.stdin.setRawMode(true);
66
+ process.stdin.resume();
67
+ process.stdin.setEncoding('utf8');
68
+ process.stdin.on('data', (key) => {
69
+ const keyStr = key.toString();
70
+ if (keyStr === 'r' || keyStr === 'R')
71
+ restart();
72
+ if (keyStr === '\u0003')
73
+ process.exit(0); // Ctrl+C
74
+ });
75
+ // Start server
76
+ start().catch(() => {
77
+ // Error already logged, just setup retry listener
78
+ });
79
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ import { Scene } from "@babylonjs/core";
2
+ import { BabylonEntity } from "./scene/BabylonEntity";
3
+ import { SceneContext } from "./scene/scene-context";
4
+ import { Entity } from "../decentraland/types";
5
+ /**
6
+ * This system is in charge of deciding which of all AvatarShape components will be rendered the next frame.
7
+ */
8
+ export declare function createAvatarRendererSystem(scene: Scene, getScenes: () => Iterable<SceneContext>): {
9
+ update: () => void;
10
+ };
11
+ export declare class AvatarEntityReference {
12
+ parentAvatar: WeakRef<BabylonEntity>;
13
+ constructor(parentAvatar: WeakRef<BabylonEntity>);
14
+ }
15
+ export declare function uniqueAvatarId(sceneId: number, entity: Entity): string;
16
+ //# sourceMappingURL=avatar-rendering-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-rendering-system.d.ts","sourceRoot":"","sources":["../../../src/lib/babylon/avatar-rendering-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC,YAAY,CAAC;;EA6E/F;AAED,qBAAa,qBAAqB;IACb,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC;gBAApC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC;CACxD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAQ7D"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uniqueAvatarId = exports.AvatarEntityReference = exports.createAvatarRendererSystem = void 0;
4
+ const avatar_shape_1 = require("../decentraland/sdk-components/avatar-shape");
5
+ const static_entities_1 = require("./scene/logic/static-entities");
6
+ const generational_index_pool_1 = require("../decentraland/crdt-internal/generational-index-pool");
7
+ /**
8
+ * This system is in charge of deciding which of all AvatarShape components will be rendered the next frame.
9
+ */
10
+ function createAvatarRendererSystem(scene, getScenes) {
11
+ const avatarEntities = new Map();
12
+ function update() {
13
+ const avatars = new Map();
14
+ const materializedScenes = Array.from(getScenes());
15
+ // look for all avatars from all runnning scenes
16
+ function addAvatar(key, avatar) {
17
+ const list = avatars.get(key);
18
+ if (list) {
19
+ list.push(avatar);
20
+ }
21
+ else {
22
+ avatars.set(key, [avatar]);
23
+ }
24
+ }
25
+ // iterate over all running scenes and their AvatarShape. get a unique id
26
+ // for each avatar and add them to a list
27
+ for (const scene of materializedScenes) {
28
+ const AvatarShape = scene.components[avatar_shape_1.avatarShapeComponent.componentId];
29
+ for (const [entity] of AvatarShape.iterator()) {
30
+ const avatar = scene.entities.get(entity);
31
+ if (avatar) {
32
+ addAvatar(uniqueAvatarId(scene.id, entity), avatar);
33
+ }
34
+ }
35
+ }
36
+ // =========================================================================
37
+ const finalAvatars = new Map();
38
+ // then filter by priority and deduplicate results. we consider a duplicated result
39
+ // any entity that is present in more than one scene and it is within the range of
40
+ // reserved entities for avatars (128 to 512)
41
+ for (const [_id, list] of avatars) {
42
+ // TODO, we render everything for now picking the first one
43
+ const [first, ...rest] = list;
44
+ finalAvatars.set(_id, first);
45
+ if (first.appliedComponents.avatarRenderer) {
46
+ first.appliedComponents.avatarRenderer.visible = true;
47
+ }
48
+ for (const avatar of rest) {
49
+ if (avatar.appliedComponents.avatarRenderer) {
50
+ avatar.appliedComponents.avatarRenderer.visible = false;
51
+ }
52
+ }
53
+ }
54
+ // =========================================================================
55
+ // finally, render the avatars into objects. first removing the entities
56
+ // that don't exist anymore and then adding the new ones
57
+ // delete old ones
58
+ for (const [id] of avatarEntities) {
59
+ if (!finalAvatars.has(id)) {
60
+ avatarEntities.delete(id);
61
+ }
62
+ }
63
+ // create new ones
64
+ for (const [id, avatar] of finalAvatars) {
65
+ const existing = avatarEntities.get(id);
66
+ if (!existing) {
67
+ avatarEntities.set(id, new AvatarEntityReference(new WeakRef(avatar)));
68
+ }
69
+ else {
70
+ existing.parentAvatar = new WeakRef(avatar);
71
+ }
72
+ }
73
+ // =========================================================================
74
+ }
75
+ return {
76
+ update
77
+ };
78
+ }
79
+ exports.createAvatarRendererSystem = createAvatarRendererSystem;
80
+ class AvatarEntityReference {
81
+ constructor(parentAvatar) {
82
+ this.parentAvatar = parentAvatar;
83
+ }
84
+ }
85
+ exports.AvatarEntityReference = AvatarEntityReference;
86
+ function uniqueAvatarId(sceneId, entity) {
87
+ // avatar ids are in the range [128, 512) and are considered unique
88
+ if ((0, static_entities_1.entityIsInRange)(entity, static_entities_1.AVATAR_ENTITY_RANGE)) {
89
+ const [entityNumber] = generational_index_pool_1.EntityUtils.fromEntityId(entity);
90
+ return `${entityNumber}`;
91
+ }
92
+ // on the contrary, every other entity is considered unique per scene
93
+ return `${sceneId}:${entity}`;
94
+ }
95
+ exports.uniqueAvatarId = uniqueAvatarId;
96
+ //# sourceMappingURL=avatar-rendering-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-rendering-system.js","sourceRoot":"","sources":["../../../src/lib/babylon/avatar-rendering-system.ts"],"names":[],"mappings":";;;AACA,8EAAkF;AAGlF,mEAAoF;AACpF,mGAAmF;AAGnF;;GAEG;AACH,SAAgB,0BAA0B,CAAC,KAAY,EAAE,SAAuC;IAC9F,MAAM,cAAc,GAAG,IAAI,GAAG,EAAiC,CAAA;IAE/D,SAAS,MAAM;QACb,MAAM,OAAO,GAAG,IAAI,GAAG,EAAgC,CAAA;QACvD,MAAM,kBAAkB,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;QAElD,gDAAgD;QAChD,SAAS,SAAS,CAAC,GAAW,EAAE,MAAqB;YACnD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC7B,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;aAClB;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;aAC3B;QACH,CAAC;QAED,yEAAyE;QACzE,yCAAyC;QACzC,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE;YACtC,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,mCAAoB,CAAC,WAAW,CAAC,CAAA;YACtE,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE;gBAC7C,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;gBACzC,IAAI,MAAM,EAAE;oBACV,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;iBACpD;aACF;SACF;QAED,4EAA4E;QAC5E,MAAM,YAAY,GAAG,IAAI,GAAG,EAAyB,CAAA;QAErD,mFAAmF;QACnF,kFAAkF;QAClF,6CAA6C;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE;YACjC,2DAA2D;YAC3D,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;YAE7B,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YAC5B,IAAI,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE;gBAC1C,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,OAAO,GAAG,IAAI,CAAA;aACtD;YAED,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE;gBACzB,IAAI,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE;oBAC3C,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,OAAO,GAAG,KAAK,CAAA;iBACxD;aACF;SACF;QAED,4EAA4E;QAC5E,wEAAwE;QACxE,wDAAwD;QAExD,oBAAoB;QACpB,KAAK,MAAM,CAAC,EAAE,CAAC,IAAI,cAAc,EAAE;YACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBACzB,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;aAC1B;SACF;QAED,oBAAoB;QACpB,KAAK,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,YAAY,EAAE;YACvC,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACvC,IAAI,CAAC,QAAQ,EAAE;gBACb,cAAc,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,qBAAqB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;aACvE;iBAAM;gBACL,QAAQ,CAAC,YAAY,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;aAC5C;SACF;QACD,4EAA4E;IAC9E,CAAC;IAED,OAAO;QACL,MAAM;KACP,CAAA;AACH,CAAC;AA7ED,gEA6EC;AAED,MAAa,qBAAqB;IAChC,YAAmB,YAAoC;QAApC,iBAAY,GAAZ,YAAY,CAAwB;IAAI,CAAC;CAC7D;AAFD,sDAEC;AAED,SAAgB,cAAc,CAAC,OAAe,EAAE,MAAc;IAC5D,mEAAmE;IACnE,IAAI,IAAA,iCAAe,EAAC,MAAM,EAAE,qCAAmB,CAAC,EAAE;QAChD,MAAM,CAAC,YAAY,CAAC,GAAG,qCAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;QACvD,OAAO,GAAG,YAAY,EAAE,CAAA;KACzB;IACD,qEAAqE;IACrE,OAAO,GAAG,OAAO,IAAI,MAAM,EAAE,CAAA;AAC/B,CAAC;AARD,wCAQC"}