murow 0.0.60 → 0.0.71

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 (425) hide show
  1. package/README.md +52 -37
  2. package/dist/cjs/core/binary-codec/binary-codec.js +1 -0
  3. package/dist/cjs/core/binary-codec/index.js +1 -0
  4. package/dist/cjs/core/driver/driver.js +1 -0
  5. package/dist/cjs/core/driver/drivers/immediate.js +1 -0
  6. package/dist/cjs/core/driver/drivers/index.js +1 -0
  7. package/dist/cjs/core/driver/drivers/raf.js +1 -0
  8. package/dist/cjs/core/driver/drivers/timeout.js +1 -0
  9. package/dist/cjs/core/driver/index.js +1 -0
  10. package/dist/cjs/core/events/event-system.js +1 -0
  11. package/dist/cjs/core/events/index.js +1 -0
  12. package/dist/cjs/core/fixed-ticker/fixed-ticker.js +1 -0
  13. package/dist/cjs/core/fixed-ticker/index.js +1 -0
  14. package/dist/cjs/core/free-list/free-list.js +1 -0
  15. package/dist/cjs/core/free-list/index.js +1 -0
  16. package/dist/cjs/core/generate-id/generate-id.js +1 -0
  17. package/dist/cjs/core/generate-id/index.js +1 -0
  18. package/dist/cjs/core/index.js +1 -0
  19. package/dist/cjs/core/input/index.js +1 -0
  20. package/dist/cjs/core/input/manager.js +1 -0
  21. package/dist/cjs/core/input/sources/browser.js +1 -0
  22. package/dist/cjs/core/input/sources/index.js +1 -0
  23. package/dist/cjs/core/input/types.js +1 -0
  24. package/dist/cjs/core/lerp/index.js +1 -0
  25. package/dist/cjs/core/lerp/lerp.js +1 -0
  26. package/dist/cjs/core/navmesh/index.js +1 -0
  27. package/dist/cjs/core/navmesh/navmesh-worker-pool.js +1 -0
  28. package/dist/cjs/core/navmesh/navmesh.js +1 -0
  29. package/dist/cjs/core/navmesh/navmesh.worker.js +1 -0
  30. package/dist/cjs/core/pooled-codec/index.js +1 -0
  31. package/dist/cjs/core/pooled-codec/pooled-codec.js +1 -0
  32. package/dist/cjs/core/prediction/index.js +1 -0
  33. package/dist/cjs/core/prediction/prediction.js +1 -0
  34. package/dist/cjs/core/ray/index.js +1 -0
  35. package/dist/cjs/core/ray/ray-2d.js +1 -0
  36. package/dist/cjs/core/ray/ray-3d.js +1 -0
  37. package/dist/cjs/core/simple-rng/index.js +1 -0
  38. package/dist/cjs/core/simple-rng/simple-rng.js +1 -0
  39. package/dist/cjs/core/sparse-batcher/index.js +1 -0
  40. package/dist/cjs/core/sparse-batcher/sparse-batcher.js +1 -0
  41. package/dist/cjs/ecs/component-store.js +1 -0
  42. package/dist/cjs/ecs/component.js +1 -0
  43. package/dist/cjs/ecs/entity-handle.js +1 -0
  44. package/dist/cjs/ecs/index.js +1 -0
  45. package/dist/cjs/ecs/system-builder.js +1 -0
  46. package/dist/cjs/ecs/world-systems.js +1 -0
  47. package/dist/cjs/ecs/world.js +1 -0
  48. package/dist/cjs/game/index.js +1 -0
  49. package/dist/cjs/game/loop/index.js +1 -0
  50. package/dist/cjs/game/loop/loop.js +1 -0
  51. package/dist/cjs/index.js +1 -0
  52. package/dist/cjs/net/adapters/browser-websocket.js +1 -0
  53. package/dist/cjs/net/adapters/bun-websocket.js +1 -0
  54. package/dist/cjs/net/buffer-pool.js +1 -0
  55. package/dist/cjs/net/client.js +1 -0
  56. package/dist/cjs/net/index.js +1 -0
  57. package/dist/cjs/net/server.js +1 -0
  58. package/dist/cjs/net/types.js +1 -0
  59. package/dist/cjs/net/validators.js +1 -0
  60. package/dist/cjs/protocol/index.js +1 -0
  61. package/dist/cjs/protocol/intent/define-intent.js +1 -0
  62. package/dist/cjs/protocol/intent/index.js +1 -0
  63. package/dist/cjs/protocol/intent/intent-registry.js +1 -0
  64. package/dist/cjs/protocol/intent/intent.js +1 -0
  65. package/dist/cjs/protocol/rpc/define-rpc.js +1 -0
  66. package/dist/cjs/protocol/rpc/index.js +1 -0
  67. package/dist/cjs/protocol/rpc/rpc-registry.js +1 -0
  68. package/dist/cjs/protocol/rpc/rpc.js +1 -0
  69. package/dist/cjs/protocol/snapshot/index.js +1 -0
  70. package/dist/cjs/protocol/snapshot/snapshot-codec.js +1 -0
  71. package/dist/cjs/protocol/snapshot/snapshot-registry.js +1 -0
  72. package/dist/cjs/protocol/snapshot/snapshot.js +1 -0
  73. package/dist/cjs/renderer/base-2d-renderer.js +1 -0
  74. package/dist/cjs/renderer/base-3d-renderer.js +1 -0
  75. package/dist/cjs/renderer/base-renderer.js +1 -0
  76. package/dist/cjs/renderer/index.js +1 -0
  77. package/dist/cjs/renderer/types.js +1 -0
  78. package/dist/esm/core/binary-codec/binary-codec.js +1 -0
  79. package/dist/esm/core/binary-codec/index.js +1 -0
  80. package/dist/esm/core/driver/driver.js +1 -0
  81. package/dist/esm/core/driver/drivers/immediate.js +1 -0
  82. package/dist/esm/core/driver/drivers/index.js +1 -0
  83. package/dist/esm/core/driver/drivers/raf.js +1 -0
  84. package/dist/esm/core/driver/drivers/timeout.js +1 -0
  85. package/dist/esm/core/driver/index.js +1 -0
  86. package/dist/esm/core/events/event-system.js +1 -0
  87. package/dist/esm/core/events/index.js +1 -0
  88. package/dist/esm/core/fixed-ticker/fixed-ticker.js +1 -0
  89. package/dist/esm/core/fixed-ticker/index.js +1 -0
  90. package/dist/esm/core/free-list/free-list.js +1 -0
  91. package/dist/esm/core/free-list/index.js +1 -0
  92. package/dist/esm/core/generate-id/generate-id.js +1 -0
  93. package/dist/esm/core/generate-id/index.js +1 -0
  94. package/dist/esm/core/index.js +1 -0
  95. package/dist/esm/core/input/index.js +1 -0
  96. package/dist/esm/core/input/manager.js +1 -0
  97. package/dist/esm/core/input/sources/browser.js +1 -0
  98. package/dist/esm/core/input/sources/index.js +1 -0
  99. package/dist/esm/core/input/types.js +0 -0
  100. package/dist/esm/core/lerp/index.js +1 -0
  101. package/dist/esm/core/lerp/lerp.js +1 -0
  102. package/dist/esm/core/navmesh/index.js +1 -0
  103. package/dist/esm/core/navmesh/navmesh-worker-pool.js +1 -0
  104. package/dist/esm/core/navmesh/navmesh.js +1 -0
  105. package/dist/esm/core/navmesh/navmesh.worker.js +1 -0
  106. package/dist/esm/core/pooled-codec/index.js +1 -0
  107. package/dist/esm/core/pooled-codec/pooled-codec.js +1 -0
  108. package/dist/esm/core/prediction/index.js +1 -0
  109. package/dist/esm/core/prediction/prediction.js +1 -0
  110. package/dist/esm/core/ray/index.js +1 -0
  111. package/dist/esm/core/ray/ray-2d.js +1 -0
  112. package/dist/esm/core/ray/ray-3d.js +1 -0
  113. package/dist/esm/core/simple-rng/index.js +1 -0
  114. package/dist/esm/core/simple-rng/simple-rng.js +1 -0
  115. package/dist/esm/core/sparse-batcher/index.js +1 -0
  116. package/dist/esm/core/sparse-batcher/sparse-batcher.js +1 -0
  117. package/dist/esm/ecs/component-store.js +1 -0
  118. package/dist/esm/ecs/component.js +1 -0
  119. package/dist/esm/ecs/entity-handle.js +1 -0
  120. package/dist/esm/ecs/index.js +1 -0
  121. package/dist/esm/ecs/system-builder.js +1 -0
  122. package/dist/esm/ecs/world-systems.js +1 -0
  123. package/dist/esm/ecs/world.js +1 -0
  124. package/dist/esm/game/index.js +1 -0
  125. package/dist/esm/game/loop/index.js +1 -0
  126. package/dist/esm/game/loop/loop.js +1 -0
  127. package/dist/esm/index.js +1 -0
  128. package/dist/esm/net/adapters/browser-websocket.js +1 -0
  129. package/dist/esm/net/adapters/bun-websocket.js +1 -0
  130. package/dist/esm/net/buffer-pool.js +1 -0
  131. package/dist/esm/net/client.js +1 -0
  132. package/dist/esm/net/index.js +1 -0
  133. package/dist/esm/net/server.js +1 -0
  134. package/dist/esm/net/types.js +1 -0
  135. package/dist/esm/net/validators.js +1 -0
  136. package/dist/esm/protocol/index.js +1 -0
  137. package/dist/esm/protocol/intent/define-intent.js +1 -0
  138. package/dist/esm/protocol/intent/index.js +1 -0
  139. package/dist/esm/protocol/intent/intent-registry.js +1 -0
  140. package/dist/esm/protocol/intent/intent.js +0 -0
  141. package/dist/esm/protocol/rpc/define-rpc.js +1 -0
  142. package/dist/esm/protocol/rpc/index.js +1 -0
  143. package/dist/esm/protocol/rpc/rpc-registry.js +1 -0
  144. package/dist/esm/protocol/rpc/rpc.js +0 -0
  145. package/dist/esm/protocol/snapshot/index.js +1 -0
  146. package/dist/esm/protocol/snapshot/snapshot-codec.js +1 -0
  147. package/dist/esm/protocol/snapshot/snapshot-registry.js +1 -0
  148. package/dist/esm/protocol/snapshot/snapshot.js +1 -0
  149. package/dist/esm/renderer/base-2d-renderer.js +1 -0
  150. package/dist/esm/renderer/base-3d-renderer.js +1 -0
  151. package/dist/esm/renderer/base-renderer.js +1 -0
  152. package/dist/esm/renderer/index.js +1 -0
  153. package/dist/esm/renderer/types.js +0 -0
  154. package/dist/{core → types/core}/binary-codec/binary-codec.d.ts +4 -0
  155. package/dist/{core/loop → types/core/driver}/drivers/immediate.d.ts +1 -1
  156. package/dist/{core/loop → types/core/driver}/drivers/raf.d.ts +1 -1
  157. package/dist/{core/loop → types/core/driver}/drivers/timeout.d.ts +1 -1
  158. package/dist/{core/loop → types/core/driver}/index.d.ts +1 -1
  159. package/dist/{core → types/core}/events/event-system.d.ts +14 -33
  160. package/dist/{core → types/core}/fixed-ticker/fixed-ticker.d.ts +1 -1
  161. package/dist/types/core/free-list/free-list.d.ts +31 -0
  162. package/dist/types/core/free-list/index.d.ts +1 -0
  163. package/dist/{core → types/core}/index.d.ts +7 -1
  164. package/dist/types/core/input/index.d.ts +3 -0
  165. package/dist/types/core/input/manager.d.ts +56 -0
  166. package/dist/types/core/input/sources/browser.d.ts +9 -0
  167. package/dist/types/core/input/sources/index.d.ts +1 -0
  168. package/dist/types/core/input/types.d.ts +36 -0
  169. package/dist/{core → types/core}/navmesh/navmesh.d.ts +1 -21
  170. package/dist/types/core/ray/index.d.ts +2 -0
  171. package/dist/types/core/ray/ray-2d.d.ts +37 -0
  172. package/dist/types/core/ray/ray-3d.d.ts +42 -0
  173. package/dist/types/core/simple-rng/index.d.ts +1 -0
  174. package/dist/types/core/simple-rng/simple-rng.d.ts +36 -0
  175. package/dist/types/core/sparse-batcher/index.d.ts +1 -0
  176. package/dist/types/core/sparse-batcher/sparse-batcher.d.ts +55 -0
  177. package/dist/{ecs → types/ecs}/system-builder.d.ts +20 -9
  178. package/dist/{ecs → types/ecs}/world.d.ts +11 -0
  179. package/dist/types/game/index.d.ts +1 -0
  180. package/dist/types/game/loop/index.d.ts +1 -0
  181. package/dist/types/game/loop/loop.d.ts +175 -0
  182. package/dist/{index.d.ts → types/index.d.ts} +2 -0
  183. package/dist/{net → types/net}/index.d.ts +2 -2
  184. package/dist/{net → types/net}/server.d.ts +39 -19
  185. package/dist/{protocol → types/protocol}/intent/define-intent.d.ts +15 -0
  186. package/dist/{protocol → types/protocol}/intent/index.d.ts +1 -1
  187. package/dist/types/renderer/base-2d-renderer.d.ts +13 -0
  188. package/dist/types/renderer/base-3d-renderer.d.ts +10 -0
  189. package/dist/types/renderer/base-renderer.d.ts +21 -0
  190. package/dist/types/renderer/index.d.ts +4 -0
  191. package/dist/types/renderer/types.d.ts +79 -0
  192. package/dist/webgpu/cjs/index.js +6004 -0
  193. package/dist/webgpu/esm/index.js +5972 -0
  194. package/dist/webgpu/types/2d/animation.d.ts +97 -0
  195. package/dist/webgpu/types/2d/renderer.d.ts +55 -0
  196. package/dist/webgpu/types/2d/shader.d.ts +61 -0
  197. package/dist/webgpu/types/2d/sprite-accessor.d.ts +47 -0
  198. package/dist/webgpu/types/2d/sprite-accessor.test.d.ts +1 -0
  199. package/dist/webgpu/types/3d/gltf-skin-parser.d.ts +101 -0
  200. package/dist/webgpu/types/3d/morph-animation.d.ts +69 -0
  201. package/dist/webgpu/types/3d/morph-animation.test.d.ts +1 -0
  202. package/dist/webgpu/types/3d/renderer.d.ts +216 -0
  203. package/dist/webgpu/types/3d/shader.d.ts +136 -0
  204. package/dist/webgpu/types/3d/skeletal-animation-compute/index.d.ts +2 -0
  205. package/dist/webgpu/types/3d/skeletal-animation-compute/kernel.d.ts +8 -0
  206. package/dist/webgpu/types/3d/skeletal-animation-compute/packer.d.ts +32 -0
  207. package/dist/webgpu/types/3d/skeletal-animation.d.ts +90 -0
  208. package/dist/webgpu/types/camera/camera-2d.d.ts +53 -0
  209. package/dist/webgpu/types/camera/camera-2d.test.d.ts +1 -0
  210. package/dist/webgpu/types/camera/camera-3d.d.ts +81 -0
  211. package/dist/webgpu/types/camera/camera-3d.test.d.ts +1 -0
  212. package/dist/webgpu/types/camera/index.d.ts +2 -0
  213. package/dist/webgpu/types/compute/compute-builder.d.ts +123 -0
  214. package/dist/webgpu/types/compute/compute-builder.test.d.ts +1 -0
  215. package/dist/webgpu/types/core/constants.d.ts +59 -0
  216. package/dist/webgpu/types/core/constants.test.d.ts +1 -0
  217. package/dist/webgpu/types/core/index.d.ts +2 -0
  218. package/dist/webgpu/types/core/math.d.ts +37 -0
  219. package/dist/webgpu/types/core/types.d.ts +125 -0
  220. package/dist/webgpu/types/core/types.test.d.ts +1 -0
  221. package/dist/webgpu/types/geometry/built-in.d.ts +58 -0
  222. package/dist/webgpu/types/geometry/built-in.test.d.ts +1 -0
  223. package/dist/webgpu/types/geometry/geometry-builder.d.ts +281 -0
  224. package/dist/webgpu/types/geometry/geometry-builder.test.d.ts +1 -0
  225. package/dist/webgpu/types/geometry/index.d.ts +2 -0
  226. package/dist/webgpu/types/index.d.ts +32 -0
  227. package/dist/webgpu/types/particle/emitter.d.ts +36 -0
  228. package/dist/webgpu/types/shaders/index.d.ts +2 -0
  229. package/dist/webgpu/types/shaders/runtime-transpile.d.ts +18 -0
  230. package/dist/webgpu/types/shaders/sprite-2d.wgsl.d.ts +10 -0
  231. package/dist/webgpu/types/shaders/typegpu.d.ts +9 -0
  232. package/dist/webgpu/types/shaders/utils.d.ts +28 -0
  233. package/dist/webgpu/types/shaders/utils.test.d.ts +1 -0
  234. package/dist/webgpu/types/spritesheet/index.d.ts +1 -0
  235. package/dist/webgpu/types/spritesheet/spritesheet.d.ts +57 -0
  236. package/dist/webgpu/types/spritesheet/spritesheet.test.d.ts +1 -0
  237. package/package.json +96 -26
  238. package/dist/core/binary-codec/binary-codec.js +0 -354
  239. package/dist/core/binary-codec/index.js +0 -1
  240. package/dist/core/events/event-system.js +0 -88
  241. package/dist/core/events/index.js +0 -1
  242. package/dist/core/fixed-ticker/fixed-ticker.js +0 -101
  243. package/dist/core/fixed-ticker/index.js +0 -1
  244. package/dist/core/generate-id/generate-id.js +0 -25
  245. package/dist/core/generate-id/index.js +0 -1
  246. package/dist/core/index.js +0 -9
  247. package/dist/core/lerp/index.js +0 -1
  248. package/dist/core/lerp/lerp.js +0 -42
  249. package/dist/core/loop/drivers/immediate.js +0 -61
  250. package/dist/core/loop/drivers/index.js +0 -3
  251. package/dist/core/loop/drivers/raf.js +0 -62
  252. package/dist/core/loop/drivers/timeout.js +0 -71
  253. package/dist/core/loop/index.js +0 -2
  254. package/dist/core/loop/loop.js +0 -47
  255. package/dist/core/navmesh/index.js +0 -1
  256. package/dist/core/navmesh/navmesh-worker-pool.js +0 -180
  257. package/dist/core/navmesh/navmesh.js +0 -799
  258. package/dist/core/navmesh/navmesh.worker.js +0 -79
  259. package/dist/core/pooled-codec/index.js +0 -1
  260. package/dist/core/pooled-codec/pooled-codec.js +0 -410
  261. package/dist/core/prediction/index.js +0 -1
  262. package/dist/core/prediction/prediction.js +0 -99
  263. package/dist/core.esm.js +0 -1
  264. package/dist/core.js +0 -1
  265. package/dist/ecs/component-store.js +0 -175
  266. package/dist/ecs/component.js +0 -43
  267. package/dist/ecs/entity-handle.js +0 -515
  268. package/dist/ecs/example.js +0 -125
  269. package/dist/ecs/index.js +0 -4
  270. package/dist/ecs/system-builder.js +0 -180
  271. package/dist/ecs/system.d.ts +0 -63
  272. package/dist/ecs/system.js +0 -92
  273. package/dist/ecs/world-systems.js +0 -79
  274. package/dist/ecs/world.js +0 -684
  275. package/dist/index.js +0 -24
  276. package/dist/net/adapters/browser-websocket.js +0 -74
  277. package/dist/net/adapters/bun-websocket.js +0 -245
  278. package/dist/net/buffer-pool.js +0 -89
  279. package/dist/net/client.js +0 -586
  280. package/dist/net/index.js +0 -58
  281. package/dist/net/server.js +0 -938
  282. package/dist/net/types.js +0 -31
  283. package/dist/net/validators.js +0 -88
  284. package/dist/protocol/index.js +0 -92
  285. package/dist/protocol/intent/define-intent.js +0 -125
  286. package/dist/protocol/intent/index.js +0 -91
  287. package/dist/protocol/intent/intent-registry.js +0 -91
  288. package/dist/protocol/rpc/define-rpc.js +0 -84
  289. package/dist/protocol/rpc/index.js +0 -3
  290. package/dist/protocol/rpc/rpc-registry.js +0 -159
  291. package/dist/protocol/rpc/rpc.js +0 -12
  292. package/dist/protocol/snapshot/index.js +0 -43
  293. package/dist/protocol/snapshot/snapshot-codec.js +0 -67
  294. package/dist/protocol/snapshot/snapshot-registry.js +0 -168
  295. package/dist/protocol/snapshot/snapshot.js +0 -30
  296. package/src/core/binary-codec/README.md +0 -60
  297. package/src/core/binary-codec/binary-codec.test.ts +0 -300
  298. package/src/core/binary-codec/binary-codec.ts +0 -448
  299. package/src/core/binary-codec/index.ts +0 -1
  300. package/src/core/events/README.md +0 -47
  301. package/src/core/events/event-system.test.ts +0 -243
  302. package/src/core/events/event-system.ts +0 -140
  303. package/src/core/events/index.ts +0 -1
  304. package/src/core/fixed-ticker/README.md +0 -77
  305. package/src/core/fixed-ticker/fixed-ticker.test.ts +0 -151
  306. package/src/core/fixed-ticker/fixed-ticker.ts +0 -169
  307. package/src/core/fixed-ticker/index.ts +0 -1
  308. package/src/core/generate-id/README.md +0 -18
  309. package/src/core/generate-id/generate-id.test.ts +0 -79
  310. package/src/core/generate-id/generate-id.ts +0 -37
  311. package/src/core/generate-id/index.ts +0 -1
  312. package/src/core/index.ts +0 -9
  313. package/src/core/lerp/README.md +0 -79
  314. package/src/core/lerp/index.ts +0 -1
  315. package/src/core/lerp/lerp.test.ts +0 -90
  316. package/src/core/lerp/lerp.ts +0 -42
  317. package/src/core/loop/README.md +0 -97
  318. package/src/core/loop/drivers/immediate.ts +0 -66
  319. package/src/core/loop/drivers/index.ts +0 -3
  320. package/src/core/loop/drivers/raf.ts +0 -67
  321. package/src/core/loop/drivers/timeout.ts +0 -77
  322. package/src/core/loop/index.ts +0 -2
  323. package/src/core/loop/loop.test.ts +0 -414
  324. package/src/core/loop/loop.ts +0 -71
  325. package/src/core/navmesh/README.md +0 -164
  326. package/src/core/navmesh/index.ts +0 -1
  327. package/src/core/navmesh/navmesh-worker-pool.ts +0 -236
  328. package/src/core/navmesh/navmesh-workers.test.ts +0 -356
  329. package/src/core/navmesh/navmesh.test.ts +0 -344
  330. package/src/core/navmesh/navmesh.ts +0 -1047
  331. package/src/core/navmesh/navmesh.worker.ts +0 -147
  332. package/src/core/pooled-codec/README.md +0 -70
  333. package/src/core/pooled-codec/index.ts +0 -1
  334. package/src/core/pooled-codec/pooled-codec.test.ts +0 -862
  335. package/src/core/pooled-codec/pooled-codec.ts +0 -504
  336. package/src/core/prediction/README.md +0 -64
  337. package/src/core/prediction/index.ts +0 -1
  338. package/src/core/prediction/prediction.test.ts +0 -423
  339. package/src/core/prediction/prediction.ts +0 -112
  340. package/src/ecs/README.md +0 -427
  341. package/src/ecs/benchmark.test.ts +0 -1645
  342. package/src/ecs/component-store.ts +0 -198
  343. package/src/ecs/component.ts +0 -90
  344. package/src/ecs/entity-handle.test.ts +0 -393
  345. package/src/ecs/entity-handle.ts +0 -563
  346. package/src/ecs/example.ts +0 -152
  347. package/src/ecs/index.ts +0 -4
  348. package/src/ecs/system-builder.ts +0 -309
  349. package/src/ecs/system.ts +0 -111
  350. package/src/ecs/world-systems.ts +0 -83
  351. package/src/ecs/world.test.ts +0 -310
  352. package/src/ecs/world.ts +0 -828
  353. package/src/index.ts +0 -28
  354. package/src/net/README.md +0 -474
  355. package/src/net/adapters/browser-websocket.ts +0 -86
  356. package/src/net/adapters/bun-websocket.ts +0 -292
  357. package/src/net/buffer-pool.ts +0 -106
  358. package/src/net/client.test.ts +0 -807
  359. package/src/net/client.ts +0 -695
  360. package/src/net/index.ts +0 -60
  361. package/src/net/server.test.ts +0 -799
  362. package/src/net/server.ts +0 -1116
  363. package/src/net/types.ts +0 -228
  364. package/src/net/validators.ts +0 -104
  365. package/src/protocol/README.md +0 -469
  366. package/src/protocol/index.ts +0 -93
  367. package/src/protocol/intent/define-intent.test.ts +0 -397
  368. package/src/protocol/intent/define-intent.ts +0 -182
  369. package/src/protocol/intent/index.ts +0 -94
  370. package/src/protocol/intent/intent-registry.test.ts +0 -198
  371. package/src/protocol/intent/intent-registry.ts +0 -112
  372. package/src/protocol/intent/intent.ts +0 -12
  373. package/src/protocol/rpc/define-rpc.test.ts +0 -141
  374. package/src/protocol/rpc/define-rpc.ts +0 -113
  375. package/src/protocol/rpc/index.ts +0 -3
  376. package/src/protocol/rpc/rpc-registry.test.ts +0 -168
  377. package/src/protocol/rpc/rpc-registry.ts +0 -176
  378. package/src/protocol/rpc/rpc.ts +0 -37
  379. package/src/protocol/snapshot/index.ts +0 -45
  380. package/src/protocol/snapshot/snapshot-codec.test.ts +0 -138
  381. package/src/protocol/snapshot/snapshot-codec.ts +0 -87
  382. package/src/protocol/snapshot/snapshot-registry.test.ts +0 -310
  383. package/src/protocol/snapshot/snapshot-registry.ts +0 -201
  384. package/src/protocol/snapshot/snapshot.test.ts +0 -76
  385. package/src/protocol/snapshot/snapshot.ts +0 -41
  386. /package/dist/{core → types/core}/binary-codec/index.d.ts +0 -0
  387. /package/dist/{core/loop/loop.d.ts → types/core/driver/driver.d.ts} +0 -0
  388. /package/dist/{core/loop → types/core/driver}/drivers/index.d.ts +0 -0
  389. /package/dist/{core → types/core}/events/index.d.ts +0 -0
  390. /package/dist/{core → types/core}/fixed-ticker/index.d.ts +0 -0
  391. /package/dist/{core → types/core}/generate-id/generate-id.d.ts +0 -0
  392. /package/dist/{core → types/core}/generate-id/index.d.ts +0 -0
  393. /package/dist/{core → types/core}/lerp/index.d.ts +0 -0
  394. /package/dist/{core → types/core}/lerp/lerp.d.ts +0 -0
  395. /package/dist/{core → types/core}/navmesh/index.d.ts +0 -0
  396. /package/dist/{core → types/core}/navmesh/navmesh-worker-pool.d.ts +0 -0
  397. /package/dist/{core → types/core}/navmesh/navmesh.worker.d.ts +0 -0
  398. /package/dist/{core → types/core}/pooled-codec/index.d.ts +0 -0
  399. /package/dist/{core → types/core}/pooled-codec/pooled-codec.d.ts +0 -0
  400. /package/dist/{core → types/core}/prediction/index.d.ts +0 -0
  401. /package/dist/{core → types/core}/prediction/prediction.d.ts +0 -0
  402. /package/dist/{ecs → types/ecs}/component-store.d.ts +0 -0
  403. /package/dist/{ecs → types/ecs}/component.d.ts +0 -0
  404. /package/dist/{ecs → types/ecs}/entity-handle.d.ts +0 -0
  405. /package/dist/{ecs → types/ecs}/example.d.ts +0 -0
  406. /package/dist/{ecs → types/ecs}/index.d.ts +0 -0
  407. /package/dist/{ecs → types/ecs}/world-systems.d.ts +0 -0
  408. /package/dist/{net → types/net}/adapters/browser-websocket.d.ts +0 -0
  409. /package/dist/{net → types/net}/adapters/bun-websocket.d.ts +0 -0
  410. /package/dist/{net → types/net}/buffer-pool.d.ts +0 -0
  411. /package/dist/{net → types/net}/client.d.ts +0 -0
  412. /package/dist/{net → types/net}/types.d.ts +0 -0
  413. /package/dist/{net → types/net}/validators.d.ts +0 -0
  414. /package/dist/{protocol → types/protocol}/index.d.ts +0 -0
  415. /package/dist/{protocol → types/protocol}/intent/intent-registry.d.ts +0 -0
  416. /package/dist/{protocol → types/protocol}/intent/intent.d.ts +0 -0
  417. /package/dist/{protocol → types/protocol}/rpc/define-rpc.d.ts +0 -0
  418. /package/dist/{protocol → types/protocol}/rpc/index.d.ts +0 -0
  419. /package/dist/{protocol → types/protocol}/rpc/rpc-registry.d.ts +0 -0
  420. /package/dist/{protocol → types/protocol}/rpc/rpc.d.ts +0 -0
  421. /package/dist/{protocol → types/protocol}/snapshot/index.d.ts +0 -0
  422. /package/dist/{protocol → types/protocol}/snapshot/snapshot-codec.d.ts +0 -0
  423. /package/dist/{protocol → types/protocol}/snapshot/snapshot-registry.d.ts +0 -0
  424. /package/dist/{protocol → types/protocol}/snapshot/snapshot.d.ts +0 -0
  425. /package/dist/{protocol/intent/intent.js → webgpu/types/2d/animation.test.d.ts} +0 -0
@@ -1,356 +0,0 @@
1
- import { describe, test, expect, beforeEach } from "bun:test";
2
- import { NavMesh } from "./navmesh";
3
-
4
- interface Vec2 {
5
- x: number;
6
- y: number;
7
- }
8
-
9
- describe("NavMesh - Worker Configuration", () => {
10
- test("should initialize with default options (workers disabled)", () => {
11
- const navmesh = new NavMesh("grid");
12
-
13
- const status = navmesh.getWorkerStatus();
14
- expect(status.workersEnabled).toBe(false);
15
- expect(status.workerPoolActive).toBe(false);
16
- expect(status.pendingPaths).toBe(0);
17
- expect(status.usingWorkersNow).toBe(false);
18
- });
19
-
20
- test("should accept workers: false option", () => {
21
- const navmesh = new NavMesh("grid", { workers: false });
22
-
23
- const status = navmesh.getWorkerStatus();
24
- expect(status.workersEnabled).toBe(false);
25
- });
26
-
27
- test("should accept workers: 'auto' option", () => {
28
- const navmesh = new NavMesh("grid", { workers: "auto" });
29
-
30
- const status = navmesh.getWorkerStatus();
31
- expect(status.workersEnabled).toBe("auto");
32
- expect(status.workerPoolActive).toBe(false); // Not initialized yet
33
- });
34
-
35
- test("should accept workers: true option", () => {
36
- const navmesh = new NavMesh("grid", { workers: true });
37
-
38
- const status = navmesh.getWorkerStatus();
39
- expect(status.workersEnabled).toBe(true);
40
- });
41
-
42
- test("should accept workerPoolSize option", () => {
43
- const navmesh = new NavMesh("grid", {
44
- workers: false,
45
- workerPoolSize: 8
46
- });
47
-
48
- // Pool size stored but not used when workers disabled
49
- expect(navmesh).toBeDefined();
50
- });
51
-
52
- test("should accept workerPath option", () => {
53
- const navmesh = new NavMesh("grid", {
54
- workers: false,
55
- workerPath: "./custom-worker.js"
56
- });
57
-
58
- expect(navmesh).toBeDefined();
59
- });
60
- });
61
-
62
- describe("NavMesh - Synchronous Pathfinding (workers: false)", () => {
63
- let navmesh: NavMesh<false>;
64
-
65
- beforeEach(() => {
66
- navmesh = new NavMesh("grid", { workers: false });
67
- });
68
-
69
- test("should find path synchronously", () => {
70
- const path = navmesh.findPath({
71
- from: { x: 0, y: 0 },
72
- to: { x: 5, y: 5 }
73
- }); // No type assertion needed! Typed as Vec2[]
74
-
75
- // Result should be an array (not a Promise)
76
- expect(Array.isArray(path)).toBe(true);
77
- expect(path.length).toBeGreaterThan(0);
78
- });
79
-
80
- test("should handle obstacles with sync pathfinding", () => {
81
- navmesh.addObstacle({
82
- type: "circle",
83
- pos: { x: 2, y: 2 },
84
- radius: 1,
85
- });
86
-
87
- const path = navmesh.findPath({
88
- from: { x: 0, y: 0 },
89
- to: { x: 5, y: 5 }
90
- }); // No type assertion needed!
91
-
92
- expect(Array.isArray(path)).toBe(true);
93
- expect(path.length).toBeGreaterThan(0);
94
- });
95
-
96
- test("should never use workers when disabled", () => {
97
- const status1 = navmesh.getWorkerStatus();
98
- expect(status1.usingWorkersNow).toBe(false);
99
-
100
- // Even with many pending paths (simulate by checking status)
101
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
102
-
103
- const status2 = navmesh.getWorkerStatus();
104
- expect(status2.usingWorkersNow).toBe(false);
105
- expect(Array.isArray(path)).toBe(true);
106
- });
107
-
108
- test("should handle multiple sequential paths", () => {
109
- const paths: Vec2[][] = [];
110
-
111
- for (let i = 0; i < 10; i++) {
112
- const path = navmesh.findPath({
113
- from: { x: i, y: 0 },
114
- to: { x: i, y: 5 },
115
- });
116
- paths.push(path);
117
- }
118
-
119
- expect(paths.length).toBe(10);
120
- paths.forEach((path) => {
121
- expect(Array.isArray(path)).toBe(true);
122
- });
123
- });
124
- });
125
-
126
- describe("NavMesh - Auto Mode (workers: 'auto')", () => {
127
- let navmesh: NavMesh<'auto'>;
128
-
129
- beforeEach(() => {
130
- navmesh = new NavMesh("grid", { workers: "auto" });
131
- });
132
-
133
- test("should use sync for small number of paths", () => {
134
- const status1 = navmesh.getWorkerStatus();
135
- expect(status1.usingWorkersNow).toBe(false);
136
-
137
- // Single path should be sync - typed as Vec2[] | Promise<Vec2[]>
138
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
139
- // In auto mode with low load, it returns Vec2[] (sync)
140
- expect(Array.isArray(path) || path instanceof Promise).toBe(true);
141
- });
142
-
143
- test("should track pending paths", () => {
144
- const status1 = navmesh.getWorkerStatus();
145
- expect(status1.pendingPaths).toBe(0);
146
-
147
- // After finding a path synchronously
148
- navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
149
-
150
- const status2 = navmesh.getWorkerStatus();
151
- expect(status2.pendingPaths).toBe(0); // Sync path completes immediately
152
- });
153
-
154
- test("should not initialize workers until threshold reached", () => {
155
- const status = navmesh.getWorkerStatus();
156
- expect(status.workerPoolActive).toBe(false);
157
- });
158
- });
159
-
160
- describe("NavMesh - Return Type Handling", () => {
161
- test("sync mode returns Vec2[]", () => {
162
- const navmesh = new NavMesh("grid", { workers: false });
163
- const result = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
164
-
165
- // Should be a plain array - TypeScript knows it's Vec2[]
166
- expect(Array.isArray(result)).toBe(true);
167
- expect(result).not.toBeInstanceOf(Promise);
168
- expect(result.length).toBeGreaterThan(0); // No type error!
169
- });
170
-
171
- test("auto mode with low load", () => {
172
- const navmesh = new NavMesh("grid", { workers: "auto" });
173
- const result = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
174
-
175
- // Could be Vec2[] or Promise<Vec2[]>
176
- expect(Array.isArray(result) || result instanceof Promise).toBe(true);
177
- });
178
-
179
- test("should handle both sync and async results gracefully", async () => {
180
- const navmesh = new NavMesh("grid", { workers: "auto" });
181
-
182
- const result = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
183
-
184
- // Handle both cases
185
- const path = result instanceof Promise ? await result : result;
186
-
187
- expect(Array.isArray(path)).toBe(true);
188
- expect(path.length).toBeGreaterThan(0);
189
- });
190
- });
191
-
192
- describe("NavMesh - Obstacle Management with Workers", () => {
193
- test("should add obstacles before pathfinding (sync)", () => {
194
- const navmesh = new NavMesh("grid", { workers: false });
195
-
196
- const id1 = navmesh.addObstacle({ type: "circle", pos: { x: 2, y: 2 }, radius: 1 });
197
- const id2 = navmesh.addObstacle({ type: "circle", pos: { x: 3, y: 3 }, radius: 1 });
198
-
199
- expect(id1).toBeGreaterThan(0);
200
- expect(id2).toBeGreaterThan(0);
201
- expect(id1).not.toBe(id2);
202
-
203
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
204
- expect(Array.isArray(path)).toBe(true);
205
- });
206
-
207
- test("should move obstacles (sync)", () => {
208
- const navmesh = new NavMesh("grid", { workers: false });
209
-
210
- const id = navmesh.addObstacle({ type: "circle", pos: { x: 2, y: 2 }, radius: 1 });
211
- navmesh.moveObstacle(id, { x: 3, y: 3 });
212
-
213
- const obstacles = navmesh.getObstacles();
214
- expect(obstacles[0].pos.x).toBe(3);
215
- expect(obstacles[0].pos.y).toBe(3);
216
- });
217
-
218
- test("should remove obstacles (sync)", () => {
219
- const navmesh = new NavMesh("grid", { workers: false });
220
-
221
- const id = navmesh.addObstacle({ type: "circle", pos: { x: 2, y: 2 }, radius: 1 });
222
- expect(navmesh.getObstacles().length).toBe(1);
223
-
224
- navmesh.removeObstacle(id);
225
- expect(navmesh.getObstacles().length).toBe(0);
226
- });
227
- });
228
-
229
- describe("NavMesh - Cleanup", () => {
230
- test("should dispose cleanly (sync mode)", () => {
231
- const navmesh = new NavMesh("grid", { workers: false });
232
-
233
- navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
234
- navmesh.dispose();
235
-
236
- const status = navmesh.getWorkerStatus();
237
- expect(status.workerPoolActive).toBe(false);
238
- });
239
-
240
- test("should dispose cleanly (auto mode, not initialized)", () => {
241
- const navmesh = new NavMesh("grid", { workers: "auto" });
242
-
243
- navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
244
- navmesh.dispose();
245
-
246
- const status = navmesh.getWorkerStatus();
247
- expect(status.workerPoolActive).toBe(false);
248
- });
249
- });
250
-
251
- describe("NavMesh - Edge Cases", () => {
252
- test("should handle same start and end position", () => {
253
- const navmesh = new NavMesh("grid", { workers: false });
254
- const path = navmesh.findPath({ from: { x: 5, y: 5 }, to: { x: 5, y: 5 } });
255
-
256
- expect(Array.isArray(path)).toBe(true);
257
- expect(path.length).toBeGreaterThan(0);
258
- });
259
-
260
- test("should handle no path available", () => {
261
- const navmesh = new NavMesh("grid", { workers: false });
262
-
263
- // Create a small blocked area (not too large to avoid memory issues)
264
- for (let x = -1; x <= 1; x++) {
265
- for (let y = -1; y <= 1; y++) {
266
- if (x === 0 && y === 0) continue;
267
- navmesh.addObstacle({
268
- type: "circle",
269
- pos: { x, y },
270
- radius: 0.9,
271
- });
272
- }
273
- }
274
-
275
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 10, y: 10 } });
276
- expect(path.length).toBe(0);
277
- });
278
-
279
- test("should handle negative coordinates", () => {
280
- const navmesh = new NavMesh("grid", { workers: false });
281
- const path = navmesh.findPath({
282
- from: { x: -5, y: -5 },
283
- to: { x: 5, y: 5 },
284
- });
285
-
286
- expect(Array.isArray(path)).toBe(true);
287
- expect(path.length).toBeGreaterThan(0);
288
- });
289
- });
290
-
291
- describe("NavMesh - Graph Navigation with Workers", () => {
292
- test("should support graph mode with sync", () => {
293
- const navmesh = new NavMesh("graph", { workers: false });
294
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 10, y: 10 } });
295
-
296
- expect(Array.isArray(path)).toBe(true);
297
- expect(path.length).toBeGreaterThan(0);
298
- });
299
-
300
- test("should support graph mode with auto", () => {
301
- const navmesh = new NavMesh("graph", { workers: "auto" });
302
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 10, y: 10 } }) as Vec2[];
303
-
304
- expect(Array.isArray(path)).toBe(true);
305
- expect(path.length).toBeGreaterThan(0);
306
- });
307
- });
308
-
309
- describe("NavMesh - Integration Tests", () => {
310
- test("should handle realistic game scenario (10 units)", () => {
311
- const navmesh = new NavMesh("grid", { workers: "auto" });
312
-
313
- // Add some obstacles
314
- for (let i = 0; i < 5; i++) {
315
- navmesh.addObstacle({
316
- type: "circle",
317
- pos: { x: Math.random() * 20, y: Math.random() * 20 },
318
- radius: 0.5,
319
- });
320
- }
321
-
322
- // Find paths for 10 units
323
- const paths = [];
324
- for (let i = 0; i < 10; i++) {
325
- const path = navmesh.findPath({
326
- from: { x: i, y: 0 },
327
- to: { x: i, y: 20 },
328
- });
329
- paths.push(path);
330
- }
331
-
332
- expect(paths.length).toBe(10);
333
- paths.forEach((path) => {
334
- expect(Array.isArray(path)).toBe(true);
335
- });
336
-
337
- navmesh.dispose();
338
- });
339
-
340
- test("should maintain worker status throughout lifecycle", () => {
341
- const navmesh = new NavMesh("grid", { workers: "auto" });
342
-
343
- const status1 = navmesh.getWorkerStatus();
344
- expect(status1.pendingPaths).toBe(0);
345
-
346
- navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 5 } });
347
-
348
- const status2 = navmesh.getWorkerStatus();
349
- expect(status2.pendingPaths).toBe(0); // Completed synchronously
350
-
351
- navmesh.dispose();
352
-
353
- const status3 = navmesh.getWorkerStatus();
354
- expect(status3.workerPoolActive).toBe(false);
355
- });
356
- });
@@ -1,344 +0,0 @@
1
- import { describe, expect, test, beforeEach } from "bun:test";
2
- import { NavMesh } from "./navmesh";
3
-
4
- describe("NavMesh - Grid Navigation", () => {
5
- let navmesh: NavMesh;
6
-
7
- beforeEach(() => {
8
- navmesh = new NavMesh("grid");
9
- });
10
-
11
- test("should initialize with grid type", () => {
12
- expect(navmesh).toBeDefined();
13
- });
14
-
15
- test("should find straight path with no obstacles", () => {
16
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 3, y: 0 } });
17
- expect(path.length).toBeGreaterThan(0);
18
- // Path returns cell centers (0.5, 0.5) not exact coordinates
19
- expect(path[0].x).toBeCloseTo(0.5, 1);
20
- expect(path[0].y).toBeCloseTo(0.5, 1);
21
- });
22
-
23
- test("should add circle obstacle", () => {
24
- const id = navmesh.addObstacle({
25
- type: "circle",
26
- pos: { x: 5, y: 5 },
27
- radius: 2,
28
- });
29
- expect(id).toBeGreaterThan(0);
30
- expect(navmesh.getObstacles().length).toBe(1);
31
- });
32
-
33
- test("should add rectangle obstacle", () => {
34
- const id = navmesh.addObstacle({
35
- type: "rect",
36
- pos: { x: 5, y: 5 },
37
- size: { x: 2, y: 3 },
38
- });
39
- expect(id).toBeGreaterThan(0);
40
- });
41
-
42
- test("should add polygon obstacle", () => {
43
- const id = navmesh.addObstacle({
44
- type: "polygon",
45
- points: [
46
- { x: 0, y: 0 },
47
- { x: 1, y: 0 },
48
- { x: 1, y: 1 },
49
- { x: 0, y: 1 },
50
- ],
51
- pos: { x: 10, y: 10 },
52
- });
53
- expect(id).toBeGreaterThan(0);
54
- });
55
-
56
- test("should find path around circle obstacle", () => {
57
- navmesh.addObstacle({
58
- type: "circle",
59
- pos: { x: 2, y: 0 },
60
- radius: 1,
61
- });
62
-
63
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 4, y: 0 } });
64
- expect(path.length).toBeGreaterThan(2); // Should go around, not through
65
- });
66
-
67
- test("should find path around rectangle obstacle", () => {
68
- navmesh.addObstacle({
69
- type: "rect",
70
- pos: { x: 2, y: -1 },
71
- size: { x: 2, y: 2 },
72
- });
73
-
74
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 5, y: 0 } });
75
- expect(path.length).toBeGreaterThan(0);
76
- });
77
-
78
- test("should return empty path when completely surrounded", () => {
79
- // Surround the start position completely
80
- for (let x = -2; x <= 2; x++) {
81
- for (let y = -2; y <= 2; y++) {
82
- if (x === 0 && y === 0) continue; // Skip the start position
83
- navmesh.addObstacle({
84
- type: "circle",
85
- pos: { x, y },
86
- radius: 0.9,
87
- });
88
- }
89
- }
90
-
91
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 10, y: 10 } });
92
- expect(path.length).toBe(0);
93
- });
94
-
95
- test("should remove obstacle", () => {
96
- const id = navmesh.addObstacle({
97
- type: "circle",
98
- pos: { x: 5, y: 5 },
99
- radius: 1,
100
- });
101
-
102
- expect(navmesh.getObstacles().length).toBe(1);
103
- navmesh.removeObstacle(id);
104
- expect(navmesh.getObstacles().length).toBe(0);
105
- });
106
-
107
- test("should move obstacle", () => {
108
- const id = navmesh.addObstacle({
109
- type: "circle",
110
- pos: { x: 5, y: 5 },
111
- radius: 1,
112
- });
113
-
114
- navmesh.moveObstacle(id, { x: 10, y: 10 });
115
- const obstacles = navmesh.getObstacles();
116
- expect(obstacles[0].pos.x).toBe(10);
117
- expect(obstacles[0].pos.y).toBe(10);
118
- });
119
-
120
- test("should handle multiple obstacles", () => {
121
- navmesh.addObstacle({ type: "circle", pos: { x: 2, y: 2 }, radius: 1 });
122
- navmesh.addObstacle({ type: "circle", pos: { x: 4, y: 2 }, radius: 1 });
123
- navmesh.addObstacle({ type: "circle", pos: { x: 6, y: 2 }, radius: 1 });
124
-
125
- expect(navmesh.getObstacles().length).toBe(3);
126
- });
127
-
128
- test("should rebuild navigation when obstacles change", () => {
129
- const id = navmesh.addObstacle({
130
- type: "circle",
131
- pos: { x: 2, y: 0 },
132
- radius: 1,
133
- });
134
-
135
- const path1 = navmesh.findPath({
136
- from: { x: 0, y: 0 },
137
- to: { x: 4, y: 0 },
138
- });
139
-
140
- navmesh.removeObstacle(id);
141
-
142
- const path2 = navmesh.findPath({
143
- from: { x: 0, y: 0 },
144
- to: { x: 4, y: 0 },
145
- });
146
-
147
- // Path should be shorter after removing obstacle
148
- expect(path2.length).toBeLessThanOrEqual(path1.length);
149
- });
150
-
151
- test("should handle rotated rectangle obstacle", () => {
152
- const id = navmesh.addObstacle({
153
- type: "rect",
154
- pos: { x: 5, y: 5 },
155
- size: { x: 3, y: 1 },
156
- rotation: Math.PI / 4, // 45 degrees
157
- });
158
-
159
- expect(navmesh.getObstacles().length).toBe(1);
160
- });
161
-
162
- test("should handle rotated polygon obstacle", () => {
163
- const id = navmesh.addObstacle({
164
- type: "polygon",
165
- points: [
166
- { x: -1, y: -1 },
167
- { x: 1, y: -1 },
168
- { x: 1, y: 1 },
169
- { x: -1, y: 1 },
170
- ],
171
- pos: { x: 5, y: 5 },
172
- rotation: Math.PI / 6,
173
- });
174
-
175
- expect(navmesh.getObstacles().length).toBe(1);
176
- });
177
-
178
- test("should handle non-solid obstacles", () => {
179
- navmesh.addObstacle({
180
- type: "circle",
181
- pos: { x: 2, y: 0 },
182
- radius: 1,
183
- solid: false,
184
- });
185
-
186
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 4, y: 0 } });
187
- // Path should go through non-solid obstacle
188
- expect(path.length).toBeGreaterThan(0);
189
- });
190
-
191
- test("should find optimal path", () => {
192
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 0, y: 5 } });
193
- // Direct path should be approximately 6 steps (0 to 5)
194
- expect(path.length).toBeLessThanOrEqual(10);
195
- });
196
- });
197
-
198
- describe("NavMesh - Graph Navigation", () => {
199
- let navmesh: NavMesh;
200
-
201
- beforeEach(() => {
202
- navmesh = new NavMesh("graph");
203
- });
204
-
205
- test("should initialize with graph type", () => {
206
- expect(navmesh).toBeDefined();
207
- });
208
-
209
- test("should find direct path with no obstacles", () => {
210
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 10, y: 10 } });
211
- expect(path.length).toBeGreaterThan(0);
212
- expect(path[0].x).toBeCloseTo(0, 1);
213
- expect(path[0].y).toBeCloseTo(0, 1);
214
- });
215
-
216
- test("should add obstacles", () => {
217
- const id = navmesh.addObstacle({
218
- type: "circle",
219
- pos: { x: 5, y: 5 },
220
- radius: 2,
221
- });
222
- expect(id).toBeGreaterThan(0);
223
- });
224
-
225
- test("should find path around obstacles", () => {
226
- navmesh.addObstacle({
227
- type: "circle",
228
- pos: { x: 5, y: 5 },
229
- radius: 2,
230
- });
231
-
232
- const path = navmesh.findPath({ from: { x: 0, y: 5 }, to: { x: 10, y: 5 } });
233
- expect(path.length).toBeGreaterThan(0);
234
- });
235
- });
236
-
237
- describe("NavMesh - Edge Cases", () => {
238
- test("should handle same start and end position", () => {
239
- const navmesh = new NavMesh("grid");
240
- const path = navmesh.findPath({ from: { x: 5, y: 5 }, to: { x: 5, y: 5 } });
241
- expect(path.length).toBeGreaterThan(0);
242
- });
243
-
244
- test("should handle negative coordinates", () => {
245
- const navmesh = new NavMesh("grid");
246
- const path = navmesh.findPath({
247
- from: { x: -5, y: -5 },
248
- to: { x: 5, y: 5 },
249
- });
250
- expect(path.length).toBeGreaterThan(0);
251
- });
252
-
253
- test("should handle large distances", () => {
254
- const navmesh = new NavMesh("grid");
255
- const path = navmesh.findPath({
256
- from: { x: 0, y: 0 },
257
- to: { x: 100, y: 100 },
258
- });
259
- expect(path.length).toBeGreaterThan(0);
260
- });
261
-
262
- test("should handle very small obstacles", () => {
263
- const navmesh = new NavMesh("grid");
264
- navmesh.addObstacle({
265
- type: "circle",
266
- pos: { x: 5, y: 5 },
267
- radius: 0.1,
268
- });
269
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 10, y: 10 } });
270
- expect(path.length).toBeGreaterThan(0);
271
- });
272
-
273
- test("should handle overlapping obstacles", () => {
274
- const navmesh = new NavMesh("grid");
275
- navmesh.addObstacle({ type: "circle", pos: { x: 5, y: 5 }, radius: 2 });
276
- navmesh.addObstacle({ type: "circle", pos: { x: 5, y: 5 }, radius: 3 });
277
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 10, y: 10 } });
278
- expect(path.length).toBeGreaterThanOrEqual(0);
279
- });
280
-
281
- test("should generate unique obstacle IDs", () => {
282
- const navmesh = new NavMesh("grid");
283
- const id1 = navmesh.addObstacle({
284
- type: "circle",
285
- pos: { x: 1, y: 1 },
286
- radius: 1,
287
- });
288
- const id2 = navmesh.addObstacle({
289
- type: "circle",
290
- pos: { x: 2, y: 2 },
291
- radius: 1,
292
- });
293
- const id3 = navmesh.addObstacle({
294
- type: "circle",
295
- pos: { x: 3, y: 3 },
296
- radius: 1,
297
- });
298
-
299
- expect(id1).not.toBe(id2);
300
- expect(id2).not.toBe(id3);
301
- expect(id1).not.toBe(id3);
302
- });
303
-
304
- test("should handle complex polygon shapes", () => {
305
- const navmesh = new NavMesh("grid");
306
- navmesh.addObstacle({
307
- type: "polygon",
308
- points: [
309
- { x: -2, y: -1 },
310
- { x: 0, y: -2 },
311
- { x: 2, y: -1 },
312
- { x: 2, y: 1 },
313
- { x: 0, y: 2 },
314
- { x: -2, y: 1 },
315
- ],
316
- pos: { x: 10, y: 10 },
317
- });
318
-
319
- const path = navmesh.findPath({ from: { x: 0, y: 10 }, to: { x: 20, y: 10 } });
320
- expect(path.length).toBeGreaterThanOrEqual(0);
321
- });
322
- });
323
-
324
- describe("NavMesh - Performance", () => {
325
- test("should handle many obstacles efficiently", () => {
326
- const navmesh = new NavMesh("grid");
327
-
328
- // Add 100 random obstacles
329
- for (let i = 0; i < 100; i++) {
330
- navmesh.addObstacle({
331
- type: "circle",
332
- pos: { x: Math.random() * 50, y: Math.random() * 50 },
333
- radius: 0.5,
334
- });
335
- }
336
-
337
- const start = performance.now();
338
- const path = navmesh.findPath({ from: { x: 0, y: 0 }, to: { x: 50, y: 50 } });
339
- const duration = performance.now() - start;
340
-
341
- expect(duration).toBeLessThan(1000); // Should complete in under 1 second
342
- expect(path).toBeDefined();
343
- });
344
- });