@benev/tact 0.1.0-3 → 0.1.0-4

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 (398) hide show
  1. package/README.md +111 -103
  2. package/package.json +7 -7
  3. package/s/core/bindings/action.ts +14 -4
  4. package/s/core/bindings/parts/defaults.ts +3 -1
  5. package/s/core/bindings/parts/lens-algo.ts +17 -13
  6. package/s/core/bindings/resolver.ts +12 -12
  7. package/s/core/bindings/sample-map.ts +25 -0
  8. package/s/core/bindings/types.ts +3 -1
  9. package/s/core/core.test.ts +46 -34
  10. package/s/core/devices/auto-gamepads.ts +8 -0
  11. package/s/core/devices/device.ts +12 -0
  12. package/s/core/devices/infra/group.ts +24 -0
  13. package/s/core/devices/infra/sampler.ts +22 -0
  14. package/s/core/devices/standard/gamepad.ts +83 -0
  15. package/s/core/{controllers → devices}/standard/index.ts +2 -1
  16. package/s/core/devices/standard/keyboard.ts +31 -0
  17. package/s/core/{controllers → devices}/standard/pointer.ts +15 -11
  18. package/s/core/devices/standard/primary.ts +20 -0
  19. package/s/core/devices/standard/stick.ts +27 -0
  20. package/s/core/{controllers/standard/virtual-gamepad.ts → devices/standard/vpad.ts} +9 -9
  21. package/s/core/{controllers → devices}/types.ts +0 -1
  22. package/s/core/hub/hub.ts +78 -62
  23. package/s/core/hub/meta-bindings.ts +23 -0
  24. package/s/core/hub/parts/connected.ts +15 -0
  25. package/s/core/hub/port.ts +26 -0
  26. package/s/core/hub/types.ts +5 -6
  27. package/s/core/index.ts +12 -14
  28. package/s/core/testing/testing.ts +19 -14
  29. package/s/deck/deck.ts +77 -0
  30. package/s/deck/index.ts +14 -0
  31. package/s/deck/parts/catalog.ts +58 -0
  32. package/s/deck/parts/db.ts +66 -0
  33. package/s/deck/parts/device-skins/device-icons.ts +38 -0
  34. package/s/deck/parts/device-skins/device-skin.ts +29 -0
  35. package/s/deck/parts/local-storage-kv.ts +8 -0
  36. package/s/deck/parts/merge-bindings.ts +21 -0
  37. package/s/deck/parts/overlay-visibility.ts +49 -0
  38. package/s/deck/views/deck-overlay/component.ts +48 -0
  39. package/s/deck/views/deck-overlay/style.css.ts +112 -0
  40. package/s/deck/views/framework.ts +14 -0
  41. package/s/demo/game/game.ts +85 -0
  42. package/s/demo/game/parts/agent.ts +10 -0
  43. package/s/demo/game/parts/game-bindings.ts +20 -0
  44. package/s/demo/game/parts/logic.ts +24 -0
  45. package/s/demo/game/parts/player.ts +32 -0
  46. package/s/demo/game/parts/renderer.ts +113 -0
  47. package/s/demo/game/parts/state.ts +24 -0
  48. package/s/demo/game/parts/virtual-device.ts +13 -0
  49. package/s/demo/main.bundle.ts +6 -12
  50. package/s/demo/main.css +30 -2
  51. package/s/demo/ui/tact-demo/component.ts +13 -0
  52. package/s/demo/ui/tact-demo/style.css.ts +4 -0
  53. package/s/demo/ui/theater/styles.css.ts +57 -0
  54. package/s/demo/ui/theater/view.ts +53 -0
  55. package/s/demo/ui/theater/virtual/style.css.ts +43 -0
  56. package/s/demo/ui/theater/virtual/view.ts +31 -0
  57. package/s/demo/ui/utils/loader.ts +5 -0
  58. package/s/index.html.ts +16 -6
  59. package/s/index.ts +3 -1
  60. package/s/nubs/components.ts +14 -0
  61. package/s/nubs/index.ts +6 -0
  62. package/s/nubs/lookpad/component.ts +45 -0
  63. package/s/nubs/stick/component.ts +115 -0
  64. package/s/nubs/stick/style.css.ts +70 -0
  65. package/s/nubs/{virtual-gamepad/view.ts → vpad/component.ts} +21 -11
  66. package/s/nubs/{virtual-gamepad → vpad}/styles.css.ts +1 -0
  67. package/s/utils/circular-clamp.ts +15 -0
  68. package/s/utils/dispensers.ts +20 -0
  69. package/s/utils/split-axis.ts +10 -2
  70. package/x/core/bindings/action.d.ts +3 -1
  71. package/x/core/bindings/action.js +12 -4
  72. package/x/core/bindings/action.js.map +1 -1
  73. package/x/core/bindings/parts/defaults.js +3 -1
  74. package/x/core/bindings/parts/defaults.js.map +1 -1
  75. package/x/core/bindings/parts/lens-algo.js +14 -7
  76. package/x/core/bindings/parts/lens-algo.js.map +1 -1
  77. package/x/core/bindings/resolver.d.ts +5 -4
  78. package/x/core/bindings/resolver.js +12 -10
  79. package/x/core/bindings/resolver.js.map +1 -1
  80. package/x/core/bindings/sample-map.d.ts +7 -0
  81. package/x/core/bindings/sample-map.js +22 -0
  82. package/x/core/bindings/sample-map.js.map +1 -0
  83. package/x/core/bindings/types.d.ts +3 -1
  84. package/x/core/core.test.d.ts +5 -4
  85. package/x/core/core.test.js +45 -34
  86. package/x/core/core.test.js.map +1 -1
  87. package/x/core/devices/auto-gamepads.d.ts +2 -0
  88. package/x/core/devices/auto-gamepads.js +6 -0
  89. package/x/core/devices/auto-gamepads.js.map +1 -0
  90. package/x/core/devices/device.d.ts +5 -0
  91. package/x/core/devices/device.js +7 -0
  92. package/x/core/devices/device.js.map +1 -0
  93. package/x/core/devices/infra/group.d.ts +8 -0
  94. package/x/core/devices/infra/group.js +21 -0
  95. package/x/core/devices/infra/group.js.map +1 -0
  96. package/x/core/devices/infra/sampler.d.ts +9 -0
  97. package/x/core/devices/infra/sampler.js +18 -0
  98. package/x/core/devices/infra/sampler.js.map +1 -0
  99. package/x/core/devices/standard/gamepad.d.ts +11 -0
  100. package/x/core/devices/standard/gamepad.js +65 -0
  101. package/x/core/devices/standard/gamepad.js.map +1 -0
  102. package/x/core/{controllers → devices}/standard/index.d.ts +2 -1
  103. package/x/core/{controllers → devices}/standard/index.js +2 -1
  104. package/x/core/devices/standard/index.js.map +1 -0
  105. package/x/core/devices/standard/keyboard.d.ts +9 -0
  106. package/x/core/devices/standard/keyboard.js +28 -0
  107. package/x/core/devices/standard/keyboard.js.map +1 -0
  108. package/x/core/devices/standard/pointer.d.ts +15 -0
  109. package/x/core/{controllers → devices}/standard/pointer.js +14 -11
  110. package/x/core/devices/standard/pointer.js.map +1 -0
  111. package/x/core/devices/standard/primary.d.ts +10 -0
  112. package/x/core/devices/standard/primary.js +17 -0
  113. package/x/core/devices/standard/primary.js.map +1 -0
  114. package/x/core/devices/standard/stick.d.ts +15 -0
  115. package/x/core/devices/standard/stick.js +24 -0
  116. package/x/core/devices/standard/stick.js.map +1 -0
  117. package/x/core/devices/standard/vpad.d.ts +7 -0
  118. package/x/core/{controllers/standard/virtual-gamepad.js → devices/standard/vpad.js} +10 -10
  119. package/x/core/devices/standard/vpad.js.map +1 -0
  120. package/x/core/{controllers → devices}/types.d.ts +0 -1
  121. package/x/core/{controllers → devices}/types.js.map +1 -1
  122. package/x/core/hub/hub.d.ts +27 -23
  123. package/x/core/hub/hub.js +71 -61
  124. package/x/core/hub/hub.js.map +1 -1
  125. package/x/core/hub/meta-bindings.d.ts +2 -0
  126. package/x/core/hub/meta-bindings.js +21 -0
  127. package/x/core/hub/meta-bindings.js.map +1 -0
  128. package/x/core/hub/parts/connected.d.ts +14 -0
  129. package/x/core/hub/parts/connected.js +12 -0
  130. package/x/core/hub/parts/connected.js.map +1 -0
  131. package/x/core/hub/port.d.ts +10 -0
  132. package/x/core/hub/port.js +19 -0
  133. package/x/core/hub/port.js.map +1 -0
  134. package/x/core/hub/types.d.ts +5 -5
  135. package/x/core/hub/types.js +1 -1
  136. package/x/core/hub/types.js.map +1 -1
  137. package/x/core/index.d.ts +12 -12
  138. package/x/core/index.js +12 -12
  139. package/x/core/index.js.map +1 -1
  140. package/x/core/testing/testing.d.ts +13 -11
  141. package/x/core/testing/testing.js +14 -13
  142. package/x/core/testing/testing.js.map +1 -1
  143. package/x/deck/deck.d.ts +35 -0
  144. package/x/deck/deck.js +50 -0
  145. package/x/deck/deck.js.map +1 -0
  146. package/x/deck/index.d.ts +10 -0
  147. package/x/deck/index.js +11 -0
  148. package/x/deck/index.js.map +1 -0
  149. package/x/deck/parts/catalog.d.ts +23 -0
  150. package/x/deck/parts/catalog.js +35 -0
  151. package/x/deck/parts/catalog.js.map +1 -0
  152. package/x/deck/parts/db.d.ts +20 -0
  153. package/x/deck/parts/db.js +52 -0
  154. package/x/deck/parts/db.js.map +1 -0
  155. package/x/deck/parts/device-skins/device-icons.d.ts +12 -0
  156. package/x/deck/parts/device-skins/device-icons.js +27 -0
  157. package/x/deck/parts/device-skins/device-icons.js.map +1 -0
  158. package/x/deck/parts/device-skins/device-skin.d.ts +14 -0
  159. package/x/deck/parts/device-skins/device-skin.js +22 -0
  160. package/x/deck/parts/device-skins/device-skin.js.map +1 -0
  161. package/x/deck/parts/local-storage-kv.js +6 -0
  162. package/x/deck/parts/local-storage-kv.js.map +1 -0
  163. package/x/deck/parts/merge-bindings.d.ts +2 -0
  164. package/x/deck/parts/merge-bindings.js +15 -0
  165. package/x/deck/parts/merge-bindings.js.map +1 -0
  166. package/x/deck/parts/overlay-visibility.d.ts +21 -0
  167. package/x/deck/parts/overlay-visibility.js +35 -0
  168. package/x/deck/parts/overlay-visibility.js.map +1 -0
  169. package/x/deck/views/deck-overlay/component.d.ts +2 -0
  170. package/x/deck/views/deck-overlay/component.js +40 -0
  171. package/x/deck/views/deck-overlay/component.js.map +1 -0
  172. package/x/deck/views/deck-overlay/style.css.js +109 -0
  173. package/x/deck/views/deck-overlay/style.css.js.map +1 -0
  174. package/x/deck/views/framework.d.ts +3 -0
  175. package/x/deck/views/framework.js +8 -0
  176. package/x/deck/views/framework.js.map +1 -0
  177. package/x/demo/game/game.d.ts +20 -0
  178. package/x/demo/game/game.js +63 -0
  179. package/x/demo/game/game.js.map +1 -0
  180. package/x/demo/game/parts/agent.d.ts +7 -0
  181. package/x/demo/game/parts/agent.js +8 -0
  182. package/x/demo/game/parts/agent.js.map +1 -0
  183. package/x/demo/game/parts/game-bindings.d.ts +15 -0
  184. package/x/demo/game/parts/game-bindings.js +10 -0
  185. package/x/demo/game/parts/game-bindings.js.map +1 -0
  186. package/x/demo/game/parts/logic.d.ts +8 -0
  187. package/x/demo/game/parts/logic.js +21 -0
  188. package/x/demo/game/parts/logic.js.map +1 -0
  189. package/x/demo/game/parts/player.d.ts +14 -0
  190. package/x/demo/game/parts/player.js +26 -0
  191. package/x/demo/game/parts/player.js.map +1 -0
  192. package/x/demo/game/parts/renderer.d.ts +13 -0
  193. package/x/demo/game/parts/renderer.js +91 -0
  194. package/x/demo/game/parts/renderer.js.map +1 -0
  195. package/x/demo/game/parts/state.d.ts +8 -0
  196. package/x/demo/game/parts/state.js +20 -0
  197. package/x/demo/game/parts/state.js.map +1 -0
  198. package/x/demo/game/parts/virtual-device.d.ts +8 -0
  199. package/x/demo/game/parts/virtual-device.js +11 -0
  200. package/x/demo/game/parts/virtual-device.js.map +1 -0
  201. package/x/demo/main.bundle.js +4 -10
  202. package/x/demo/main.bundle.js.map +1 -1
  203. package/x/demo/main.bundle.min.js +315 -54
  204. package/x/demo/main.bundle.min.js.map +4 -4
  205. package/x/demo/main.css +30 -2
  206. package/x/demo/ui/tact-demo/component.d.ts +4 -0
  207. package/x/demo/ui/tact-demo/component.js +12 -0
  208. package/x/demo/ui/tact-demo/component.js.map +1 -0
  209. package/x/demo/ui/tact-demo/style.css.d.ts +2 -0
  210. package/x/demo/ui/tact-demo/style.css.js +3 -0
  211. package/x/demo/ui/tact-demo/style.css.js.map +1 -0
  212. package/x/demo/ui/theater/styles.css.js +56 -0
  213. package/x/demo/ui/theater/styles.css.js.map +1 -0
  214. package/x/demo/ui/theater/view.d.ts +2 -0
  215. package/x/demo/ui/theater/view.js +42 -0
  216. package/x/demo/ui/theater/view.js.map +1 -0
  217. package/x/demo/ui/theater/virtual/style.css.d.ts +2 -0
  218. package/x/demo/ui/theater/virtual/style.css.js +42 -0
  219. package/x/demo/ui/theater/virtual/style.css.js.map +1 -0
  220. package/x/demo/ui/theater/virtual/view.d.ts +4 -0
  221. package/x/demo/ui/theater/virtual/view.js +19 -0
  222. package/x/demo/ui/theater/virtual/view.js.map +1 -0
  223. package/x/demo/ui/utils/loader.d.ts +1 -0
  224. package/x/demo/ui/utils/loader.js +3 -0
  225. package/x/demo/ui/utils/loader.js.map +1 -0
  226. package/x/index.d.ts +3 -1
  227. package/x/index.html +47 -8
  228. package/x/index.html.js +16 -6
  229. package/x/index.html.js.map +1 -1
  230. package/x/index.js +3 -1
  231. package/x/index.js.map +1 -1
  232. package/x/nubs/components.d.ts +9 -0
  233. package/x/nubs/components.js +11 -0
  234. package/x/nubs/components.js.map +1 -0
  235. package/x/nubs/index.d.ts +4 -0
  236. package/x/nubs/index.js +5 -0
  237. package/x/nubs/index.js.map +1 -0
  238. package/x/nubs/lookpad/component.d.ts +4 -0
  239. package/x/nubs/lookpad/component.js +36 -0
  240. package/x/nubs/lookpad/component.js.map +1 -0
  241. package/x/nubs/stick/component.d.ts +368 -0
  242. package/x/nubs/stick/component.js +101 -0
  243. package/x/nubs/stick/component.js.map +1 -0
  244. package/x/nubs/stick/style.css.d.ts +2 -0
  245. package/x/nubs/stick/style.css.js +69 -0
  246. package/x/nubs/stick/style.css.js.map +1 -0
  247. package/x/nubs/vpad/component.d.ts +368 -0
  248. package/x/nubs/{virtual-gamepad/view.js → vpad/component.js} +20 -11
  249. package/x/nubs/vpad/component.js.map +1 -0
  250. package/x/nubs/vpad/styles.css.d.ts +2 -0
  251. package/x/nubs/vpad/styles.css.js.map +1 -0
  252. package/x/nubs/vpad/utils/gamepad-inputs.js.map +1 -0
  253. package/x/nubs/vpad/utils/prevent-default-touch-shenanigans.js.map +1 -0
  254. package/x/nubs/vpad/utils/touch-tracking.js.map +1 -0
  255. package/x/utils/circular-clamp.d.ts +2 -0
  256. package/x/utils/circular-clamp.js +8 -0
  257. package/x/utils/circular-clamp.js.map +1 -0
  258. package/x/utils/dispensers.d.ts +7 -0
  259. package/x/utils/dispensers.js +16 -0
  260. package/x/utils/dispensers.js.map +1 -0
  261. package/x/utils/split-axis.d.ts +7 -0
  262. package/x/utils/split-axis.js +7 -2
  263. package/x/utils/split-axis.js.map +1 -1
  264. package/s/core/controllers/controller.ts +0 -7
  265. package/s/core/controllers/infra/group.ts +0 -17
  266. package/s/core/controllers/infra/sampler.ts +0 -22
  267. package/s/core/controllers/standard/gamepad.ts +0 -77
  268. package/s/core/controllers/standard/keyboard.ts +0 -50
  269. package/s/core/controllers/standard/stick.ts +0 -30
  270. package/s/core/deck/deck.ts +0 -40
  271. package/s/core/deck/parts/bindings-depot.ts +0 -24
  272. package/s/core/deck/parts/local-storage-kv.ts +0 -7
  273. package/s/core/hub/auto-gamepads.ts +0 -8
  274. package/s/core/hub/bindings.ts +0 -18
  275. package/s/core/port/port.ts +0 -34
  276. package/s/core/port/utils/aggregate_samples_into_map.ts +0 -20
  277. package/s/core/port/utils/wipe_samples_map.ts +0 -8
  278. package/s/nubs/lookpad/utils/listeners.ts +0 -53
  279. package/s/nubs/lookpad/view.ts +0 -32
  280. package/s/nubs/stick/styles.ts +0 -22
  281. package/s/nubs/stick/utils/calculate_new_vector_from_pointer_position.ts +0 -27
  282. package/s/nubs/stick/utils/find_closest_point_on_circle.ts +0 -15
  283. package/s/nubs/stick/utils/make_pointer_listeners.ts +0 -50
  284. package/s/nubs/stick/utils/within_radius.ts +0 -6
  285. package/s/nubs/stick/view.ts +0 -50
  286. package/s/nubs/stick-graphic/styles.ts +0 -38
  287. package/s/nubs/stick-graphic/types/basis.ts +0 -5
  288. package/s/nubs/stick-graphic/utils/calculate_basis.ts +0 -19
  289. package/s/nubs/stick-graphic/utils/stick_vector_to_pixels.ts +0 -13
  290. package/s/nubs/stick-graphic/utils/transform.ts +0 -10
  291. package/s/nubs/stick-graphic/view.ts +0 -43
  292. package/x/core/controllers/controller.d.ts +0 -4
  293. package/x/core/controllers/controller.js +0 -3
  294. package/x/core/controllers/controller.js.map +0 -1
  295. package/x/core/controllers/infra/group.d.ts +0 -7
  296. package/x/core/controllers/infra/group.js +0 -13
  297. package/x/core/controllers/infra/group.js.map +0 -1
  298. package/x/core/controllers/infra/sampler.d.ts +0 -8
  299. package/x/core/controllers/infra/sampler.js +0 -17
  300. package/x/core/controllers/infra/sampler.js.map +0 -1
  301. package/x/core/controllers/standard/gamepad.d.ts +0 -9
  302. package/x/core/controllers/standard/gamepad.js +0 -66
  303. package/x/core/controllers/standard/gamepad.js.map +0 -1
  304. package/x/core/controllers/standard/index.js.map +0 -1
  305. package/x/core/controllers/standard/keyboard.d.ts +0 -9
  306. package/x/core/controllers/standard/keyboard.js +0 -39
  307. package/x/core/controllers/standard/keyboard.js.map +0 -1
  308. package/x/core/controllers/standard/pointer.d.ts +0 -11
  309. package/x/core/controllers/standard/pointer.js.map +0 -1
  310. package/x/core/controllers/standard/stick.d.ts +0 -15
  311. package/x/core/controllers/standard/stick.js +0 -27
  312. package/x/core/controllers/standard/stick.js.map +0 -1
  313. package/x/core/controllers/standard/virtual-gamepad.d.ts +0 -7
  314. package/x/core/controllers/standard/virtual-gamepad.js.map +0 -1
  315. package/x/core/deck/deck.d.ts +0 -16
  316. package/x/core/deck/deck.js +0 -31
  317. package/x/core/deck/deck.js.map +0 -1
  318. package/x/core/deck/parts/bindings-depot.d.ts +0 -9
  319. package/x/core/deck/parts/bindings-depot.js +0 -19
  320. package/x/core/deck/parts/bindings-depot.js.map +0 -1
  321. package/x/core/deck/parts/local-storage-kv.js +0 -5
  322. package/x/core/deck/parts/local-storage-kv.js.map +0 -1
  323. package/x/core/hub/auto-gamepads.d.ts +0 -2
  324. package/x/core/hub/auto-gamepads.js +0 -6
  325. package/x/core/hub/auto-gamepads.js.map +0 -1
  326. package/x/core/hub/bindings.d.ts +0 -2
  327. package/x/core/hub/bindings.js +0 -16
  328. package/x/core/hub/bindings.js.map +0 -1
  329. package/x/core/port/port.d.ts +0 -12
  330. package/x/core/port/port.js +0 -25
  331. package/x/core/port/port.js.map +0 -1
  332. package/x/core/port/utils/aggregate_samples_into_map.d.ts +0 -3
  333. package/x/core/port/utils/aggregate_samples_into_map.js +0 -11
  334. package/x/core/port/utils/aggregate_samples_into_map.js.map +0 -1
  335. package/x/core/port/utils/wipe_samples_map.d.ts +0 -2
  336. package/x/core/port/utils/wipe_samples_map.js +0 -5
  337. package/x/core/port/utils/wipe_samples_map.js.map +0 -1
  338. package/x/nubs/lookpad/utils/listeners.d.ts +0 -19
  339. package/x/nubs/lookpad/utils/listeners.js +0 -37
  340. package/x/nubs/lookpad/utils/listeners.js.map +0 -1
  341. package/x/nubs/lookpad/view.d.ts +0 -1
  342. package/x/nubs/lookpad/view.js +0 -24
  343. package/x/nubs/lookpad/view.js.map +0 -1
  344. package/x/nubs/stick/styles.d.ts +0 -1
  345. package/x/nubs/stick/styles.js +0 -22
  346. package/x/nubs/stick/styles.js.map +0 -1
  347. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.d.ts +0 -3
  348. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js +0 -16
  349. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js.map +0 -1
  350. package/x/nubs/stick/utils/find_closest_point_on_circle.d.ts +0 -2
  351. package/x/nubs/stick/utils/find_closest_point_on_circle.js +0 -6
  352. package/x/nubs/stick/utils/find_closest_point_on_circle.js.map +0 -1
  353. package/x/nubs/stick/utils/make_pointer_listeners.d.ts +0 -16
  354. package/x/nubs/stick/utils/make_pointer_listeners.js +0 -34
  355. package/x/nubs/stick/utils/make_pointer_listeners.js.map +0 -1
  356. package/x/nubs/stick/utils/within_radius.d.ts +0 -2
  357. package/x/nubs/stick/utils/within_radius.js +0 -4
  358. package/x/nubs/stick/utils/within_radius.js.map +0 -1
  359. package/x/nubs/stick/view.d.ts +0 -2
  360. package/x/nubs/stick/view.js +0 -38
  361. package/x/nubs/stick/view.js.map +0 -1
  362. package/x/nubs/stick-graphic/styles.js +0 -38
  363. package/x/nubs/stick-graphic/styles.js.map +0 -1
  364. package/x/nubs/stick-graphic/types/basis.d.ts +0 -4
  365. package/x/nubs/stick-graphic/types/basis.js +0 -2
  366. package/x/nubs/stick-graphic/types/basis.js.map +0 -1
  367. package/x/nubs/stick-graphic/utils/calculate_basis.d.ts +0 -2
  368. package/x/nubs/stick-graphic/utils/calculate_basis.js +0 -10
  369. package/x/nubs/stick-graphic/utils/calculate_basis.js.map +0 -1
  370. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.d.ts +0 -2
  371. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js +0 -7
  372. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js.map +0 -1
  373. package/x/nubs/stick-graphic/utils/transform.d.ts +0 -2
  374. package/x/nubs/stick-graphic/utils/transform.js +0 -7
  375. package/x/nubs/stick-graphic/utils/transform.js.map +0 -1
  376. package/x/nubs/stick-graphic/view.d.ts +0 -3
  377. package/x/nubs/stick-graphic/view.js +0 -30
  378. package/x/nubs/stick-graphic/view.js.map +0 -1
  379. package/x/nubs/virtual-gamepad/styles.css.js.map +0 -1
  380. package/x/nubs/virtual-gamepad/utils/gamepad-inputs.js.map +0 -1
  381. package/x/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.js.map +0 -1
  382. package/x/nubs/virtual-gamepad/utils/touch-tracking.js.map +0 -1
  383. package/x/nubs/virtual-gamepad/view.d.ts +0 -2
  384. package/x/nubs/virtual-gamepad/view.js.map +0 -1
  385. /package/s/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.ts +0 -0
  386. /package/s/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.ts +0 -0
  387. /package/s/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.ts +0 -0
  388. /package/x/core/{controllers → devices}/types.js +0 -0
  389. /package/x/{core/deck → deck}/parts/local-storage-kv.d.ts +0 -0
  390. /package/x/{nubs/virtual-gamepad/styles.css.d.ts → deck/views/deck-overlay/style.css.d.ts} +0 -0
  391. /package/x/{nubs/stick-graphic/styles.d.ts → demo/ui/theater/styles.css.d.ts} +0 -0
  392. /package/x/nubs/{virtual-gamepad → vpad}/styles.css.js +0 -0
  393. /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.d.ts +0 -0
  394. /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.js +0 -0
  395. /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.d.ts +0 -0
  396. /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.js +0 -0
  397. /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.d.ts +0 -0
  398. /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.js +0 -0
@@ -0,0 +1,112 @@
1
+
2
+ import {css} from "lit"
3
+ export default css`
4
+
5
+ :host {
6
+ --gap: 0.3em;
7
+ pointer-events: none;
8
+ cursor: default;
9
+ user-select: none;
10
+ }
11
+
12
+ .portlist {
13
+ pointer-events: none;
14
+
15
+ display: flex;
16
+ align-items: start;
17
+
18
+ width: max-content;
19
+ gap: var(--gap);
20
+ padding: 0.5em;
21
+
22
+ color: #fff8;
23
+ background: #222a;
24
+ border-radius: 1em;
25
+
26
+ opacity: 0;
27
+ transition: opacity 300ms linear;
28
+
29
+ &[data-active] {
30
+ opacity: 1;
31
+ pointer-events: all;
32
+ }
33
+
34
+ .port {
35
+ flex: 1 0 0;
36
+ display: flex;
37
+ flex-direction: column;
38
+
39
+ min-width: 6em;
40
+ gap: var(--gap);
41
+
42
+ > * {
43
+ color: white;
44
+ font-weight: bold;
45
+ text-shadow: 0.05em 0.05em 0.1em #0008;
46
+ text-transform: uppercase;
47
+ }
48
+
49
+ header {
50
+ text-align: center;
51
+ color: #fff8;
52
+ }
53
+
54
+ .device {
55
+ display: flex;
56
+ flex-direction: column;
57
+ gap: var(--gap);
58
+
59
+ box-shadow: 0.1em 0.2em 0.7em #0004;
60
+ background: color-mix(in srgb, #fffa, var(--color) 50%);
61
+ border-top: 2px solid #fff8;
62
+ border-bottom: 2px solid #0004;
63
+ border-radius: 0.5em;
64
+
65
+ .row {
66
+ display: flex;
67
+ align-items: center;
68
+
69
+ &.primary {
70
+ justify-content: space-between;
71
+ }
72
+
73
+ &.secondary {
74
+ justify-content: center;
75
+ }
76
+ }
77
+
78
+ .icon {
79
+ font-size: 1.5em;
80
+ }
81
+
82
+ .label {
83
+ font-family: monospace;
84
+ font-size: 0.8em;
85
+ opacity: 0.5;
86
+ line-height: 0.9em;
87
+ }
88
+
89
+ button {
90
+ opacity: 0.2;
91
+ cursor: pointer;
92
+ padding: 0 0.2em;
93
+ font-family: monospace;
94
+ font-size: 1.5em;
95
+ font-weight: bold;
96
+
97
+ background: transparent;
98
+ border: 1px solid transparent;
99
+ text-shadow: inherit;
100
+
101
+ &:is(:hover, :focus-visible) {
102
+ opacity: 1;
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ `
110
+
111
+
112
+
@@ -0,0 +1,14 @@
1
+
2
+ import {Content, Use, view} from "@e280/sly"
3
+ import {Deck} from "../deck.js"
4
+
5
+ export function deckView(
6
+ fn: (deck: Deck<any>) => (use: Use) => Content
7
+ ) {
8
+
9
+ return (deck: Deck<any>) => {
10
+ const fn2 = fn(deck)
11
+ return view(use => () => fn2(use))
12
+ }
13
+ }
14
+
@@ -0,0 +1,85 @@
1
+
2
+ import {disposer, nap, repeat} from "@e280/stz"
3
+ import {Logic} from "./parts/logic.js"
4
+ import {State} from "./parts/state.js"
5
+ import {Deck} from "../../deck/deck.js"
6
+ import {Players} from "./parts/player.js"
7
+ import {Renderer} from "./parts/renderer.js"
8
+ import {Device} from "../../core/devices/device.js"
9
+ import {VirtualDevice} from "./parts/virtual-device.js"
10
+ import {gameBindings, GameDeck} from "./parts/game-bindings.js"
11
+ import {autoGamepads} from "../../core/devices/auto-gamepads.js"
12
+ import {localStorageKv} from "../../deck/parts/local-storage-kv.js"
13
+ import {PrimaryDevice} from "../../core/devices/standard/primary.js"
14
+
15
+ export class Game {
16
+ static async load() {
17
+ return new this(
18
+ await Deck.load({
19
+ portCount: 4,
20
+ kv: localStorageKv(),
21
+ bindings: gameBindings,
22
+ })
23
+ )
24
+ }
25
+
26
+ logic: Logic
27
+ dispose = disposer()
28
+ state = new State()
29
+ renderer = new Renderer(this.state)
30
+
31
+ constructor(public deck: GameDeck) {
32
+
33
+ // add an icon for our demo virtual device
34
+ this.deck.deviceSkins.icons.add(
35
+ [VirtualDevice, "🔘"],
36
+ )
37
+
38
+ // establish game logic
39
+ this.logic = new Logic(
40
+ this.state,
41
+ new Players(deck.hub, this.state),
42
+ )
43
+
44
+ // on hub update, set agent.alive based on port status
45
+ this.dispose.schedule(
46
+ this.deck.hub.on(() => {
47
+ for (const player of this.logic.players) {
48
+ player.agent.alive = player.port.devices.size > 0
49
+ const [firstDevice] = player.port.devices
50
+ player.agent.color = firstDevice
51
+ ? this.deck.deviceSkins.get(firstDevice).color
52
+ : "#444"
53
+ }
54
+ })
55
+ )
56
+
57
+ // plug in initial devices
58
+ this.plug(new PrimaryDevice())
59
+ this.plug(new VirtualDevice(deck.hub))
60
+
61
+ // dynamically plug in detected gamepads
62
+ this.dispose.schedule(
63
+ autoGamepads(deck.hub.plug)
64
+ )
65
+ }
66
+
67
+ plug(device: Device) {
68
+ this.deck.hub.plug(device)
69
+ return () => this.unplug(device)
70
+ }
71
+
72
+ unplug(device: Device) {
73
+ this.deck.hub.unplug(device)
74
+ }
75
+
76
+ loop(hz: number) {
77
+ return repeat(async() => {
78
+ await nap(1000 / hz)
79
+ this.deck.hub.poll()
80
+ this.logic.tick()
81
+ this.renderer.render()
82
+ })
83
+ }
84
+ }
85
+
@@ -0,0 +1,10 @@
1
+
2
+ import {Vec2} from "@benev/math"
3
+
4
+ export class Agent {
5
+ label = "0"
6
+ alive = true
7
+ color = "#444"
8
+ position = Vec2.zero()
9
+ }
10
+
@@ -0,0 +1,20 @@
1
+
2
+ import {Deck} from "../../../deck/deck.js"
3
+ import {Hub} from "../../../core/hub/hub.js"
4
+ import {Port} from "../../../core/hub/port.js"
5
+ import {asBindings} from "../../../core/bindings/types.js"
6
+
7
+ export type GameBindings = typeof gameBindings
8
+ export type GamePort = Port<GameBindings>
9
+ export type GameDeck = Deck<GameBindings>
10
+ export type GameHub = Hub<GameBindings>
11
+
12
+ export const gameBindings = asBindings({
13
+ gameplay: {
14
+ up: ["or", "KeyW", "ArrowUp", "stick.up", "gamepad.stick.left.up", "gamepad.stick.right.up"],
15
+ down: ["or", "KeyS", "ArrowDown", "stick.down", "gamepad.stick.left.down", "gamepad.stick.right.down"],
16
+ left: ["or", "KeyA", "ArrowLeft", "stick.left", "gamepad.stick.left.left", "gamepad.stick.right.left"],
17
+ right: ["or", "KeyD", "ArrowRight", "stick.right", "gamepad.stick.left.right", "gamepad.stick.right.right"],
18
+ },
19
+ })
20
+
@@ -0,0 +1,24 @@
1
+
2
+ import {Vec2} from "@benev/math"
3
+ import {State} from "./state.js"
4
+ import {Players} from "./player.js"
5
+
6
+ export class Logic {
7
+ constructor(
8
+ public state: State,
9
+ public players: Players,
10
+ ) {}
11
+
12
+ tick() {
13
+ for (const player of this.players) {
14
+ const {agent, port: {actions}} = player
15
+ const speed = 1
16
+ agent.position.y += speed * actions.gameplay.up.value
17
+ agent.position.y -= speed * actions.gameplay.down.value
18
+ agent.position.x -= speed * actions.gameplay.left.value
19
+ agent.position.x += speed * actions.gameplay.right.value
20
+ agent.position.clamp(Vec2.zero(), this.state.arenaSize)
21
+ }
22
+ }
23
+ }
24
+
@@ -0,0 +1,32 @@
1
+
2
+ import {MapG} from "@e280/stz"
3
+ import {Agent} from "./agent.js"
4
+ import {State} from "./state.js"
5
+ import {GameHub, GamePort} from "./game-bindings.js"
6
+
7
+ export class Player {
8
+ constructor(
9
+ public port: GamePort,
10
+ public agent: Agent,
11
+ ) {}
12
+ }
13
+
14
+ export class Players {
15
+ #map = new MapG<GamePort, Player>()
16
+
17
+ constructor(hub: GameHub, state: State) {
18
+ for (const [index, port] of hub.ports.entries()) {
19
+ const label = (index + 1).toString()
20
+ this.#map.set(port, new Player(port, state.makeAgent(label)))
21
+ }
22
+ }
23
+
24
+ ;[Symbol.iterator]() {
25
+ return this.#map.values()
26
+ }
27
+
28
+ require(port: GamePort) {
29
+ return this.#map.require(port)
30
+ }
31
+ }
32
+
@@ -0,0 +1,113 @@
1
+
2
+ import {Vec2} from "@benev/math"
3
+ import {Agent} from "./agent.js"
4
+ import {State} from "./state.js"
5
+
6
+ export class Renderer {
7
+ canvas = (() => {
8
+ const canvas = document.createElement("canvas")
9
+ canvas.width = 200
10
+ canvas.height = 100
11
+ return canvas
12
+ })()
13
+
14
+ ctx = this.canvas.getContext("2d")!
15
+
16
+ constructor(public state: State) {}
17
+
18
+ percent(n: number) {
19
+ const shorty = Math.min(this.canvas.width, this.canvas.height)
20
+ return Math.ceil(shorty * (n / 100))
21
+ }
22
+
23
+ /** take a game-state position and resolve it into canvas coordinates */
24
+ resolve(position: Vec2) {
25
+ return position.clone()
26
+
27
+ // 0-1 relative to arena scale
28
+ .divide(this.state.arenaSize)
29
+
30
+ // flip y axis
31
+ .morph(v => {v.y = 1 - v.y})
32
+
33
+ // stretch to the size of the canvas
34
+ .multiply_(this.canvas.width, this.canvas.height)
35
+ }
36
+
37
+ render() {
38
+ const {state} = this
39
+ this.#renderBackground()
40
+ const agents = [...state.agents].reverse()
41
+ const dead = agents.filter(a => !a.alive)
42
+ const alive = agents.filter(a => a.alive)
43
+
44
+ for (const agent of dead)
45
+ this.#renderDeadAgent(agent)
46
+
47
+ for (const agent of alive)
48
+ this.#renderAliveAgent(agent)
49
+ }
50
+
51
+ #getCleanCtx() {
52
+ const {ctx} = this
53
+ ctx.imageSmoothingEnabled = false
54
+ ctx.fillStyle = "#000"
55
+ ctx.strokeStyle = "#000"
56
+ ctx.lineWidth = 1
57
+ ctx.font = `10px sans-serif`
58
+ ctx.textAlign = "center"
59
+ ctx.textBaseline = "middle"
60
+ return ctx
61
+ }
62
+
63
+ #renderBackground() {
64
+ const {canvas} = this
65
+ const ctx = this.#getCleanCtx()
66
+ ctx.fillStyle = "#000"
67
+ ctx.fillRect(0, 0, canvas.width, canvas.height)
68
+ }
69
+
70
+ #renderDeadAgent(agent: Agent) {
71
+ const ctx = this.#getCleanCtx()
72
+
73
+ const radius = this.percent(10)
74
+ const {position} = agent
75
+ const [x, y] = this.resolve(position)
76
+
77
+ // draw label
78
+ ctx.font = `${radius * 1.3}px sans-serif`
79
+ ctx.textAlign = "center"
80
+ ctx.textBaseline = "middle"
81
+ ctx.fillStyle = "#fff4"
82
+ ctx.fillText(agent.label, x, y)
83
+ }
84
+
85
+ #renderAliveAgent(agent: Agent) {
86
+ const ctx = this.#getCleanCtx()
87
+
88
+ const radius = this.percent(10)
89
+ const {color, position} = agent
90
+ const [x, y] = this.resolve(position)
91
+
92
+ // circle
93
+ ctx.beginPath()
94
+ ctx.arc(x, y, radius, 0, Math.PI * 2)
95
+ ctx.fillStyle = color
96
+ ctx.fill()
97
+
98
+ // outline
99
+ ctx.lineWidth = this.percent(2)
100
+ ctx.strokeStyle = "#fff"
101
+ ctx.stroke()
102
+
103
+ // draw label
104
+ ctx.font = `${radius * 1.3}px sans-serif`
105
+ ctx.textAlign = "center"
106
+ ctx.textBaseline = "middle"
107
+ ctx.strokeStyle = "#0004"
108
+ ctx.strokeText(agent.label, x, y)
109
+ ctx.fillStyle = "#fff"
110
+ ctx.fillText(agent.label, x, y)
111
+ }
112
+ }
113
+
@@ -0,0 +1,24 @@
1
+
2
+ import {Vec2} from "@benev/math"
3
+ import {Agent} from "./agent.js"
4
+
5
+ export class State {
6
+ arenaSize = new Vec2(200, 100)
7
+ agents = new Set<Agent>()
8
+
9
+ makeAgent(label: string) {
10
+ const agent = new Agent()
11
+ agent.label = label
12
+ agent.position
13
+ .set_(0.5, 0.5)
14
+ .multiply(this.arenaSize)
15
+ this.agents.add(agent)
16
+ return agent
17
+ }
18
+
19
+ deleteAgent(agent: Agent) {
20
+ this.agents.delete(agent)
21
+ return this
22
+ }
23
+ }
24
+
@@ -0,0 +1,13 @@
1
+
2
+ import {Hub} from "../../../core/hub/hub.js"
3
+ import {StickDevice} from "../../../core/devices/standard/stick.js"
4
+
5
+ export class VirtualDevice extends StickDevice {
6
+ constructor(private hub: Hub<any>) {
7
+ super()
8
+ }
9
+
10
+ shimmyNext = () => this.hub.shimmy(this, 1)
11
+ shimmyPrevious = () => this.hub.shimmy(this, -1)
12
+ }
13
+
@@ -1,14 +1,8 @@
1
1
 
2
- import {$, view} from "@e280/sly"
3
- import {NubStick} from "../nubs/stick/view.js"
4
- import {StickController} from "../core/controllers/standard/stick.js"
5
-
6
- $.register({
7
- TactDemo: view.component(use => {
8
- const stick = use.once(() => new StickController())
9
- return NubStick(stick)
10
- }),
11
- })
12
-
13
- console.log("tact")
2
+ import {dom} from "@e280/sly"
3
+ import {TactDemo} from "./ui/tact-demo/component.js"
4
+
5
+ dom.register({TactDemo})
6
+
7
+ console.log("🎮 tact")
14
8
 
package/s/demo/main.css CHANGED
@@ -5,8 +5,9 @@
5
5
  :root {
6
6
  color-scheme: dark;
7
7
  --link: cyan;
8
+ --prime: #ccc;
8
9
  --bg: #181818;
9
- --prime: #aaa;
10
+ --bg2: #111111;
10
11
  }
11
12
  }
12
13
 
@@ -46,12 +47,39 @@
46
47
  body { min-height: 100%; }
47
48
 
48
49
  html, body {
49
- font-size: 21px;
50
+ font-family: sans-serif;
51
+ font-size: 12px;
50
52
  color: var(--prime);
51
53
  background: var(--bg);
52
54
  }
53
55
  }
54
56
 
55
57
  @layer page {
58
+ body {
59
+ display: flex;
60
+ flex-direction: column;
61
+ align-items: center;
62
+
63
+ gap: 1em;
64
+ padding: 2em;
65
+
66
+ > * {
67
+ width: 100%;
68
+ max-width: 42em;
69
+ }
70
+
71
+ > header {
72
+ padding: 0 2em;
73
+ h1 small { font-size: 0.6em; font-weight: normal; }
74
+ * + * { margin-top: 0.5em; }
75
+ }
76
+
77
+ > section {
78
+ padding: 0 2em;
79
+ ul {
80
+ padding-left: 1em;
81
+ }
82
+ }
83
+ }
56
84
  }
57
85
 
@@ -0,0 +1,13 @@
1
+
2
+ import {cssReset, view} from "@e280/sly"
3
+ import styleCss from "./style.css.js"
4
+ import {Game} from "../../game/game.js"
5
+ import {loader} from "../utils/loader.js"
6
+ import {Theater} from "../theater/view.js"
7
+
8
+ export class TactDemo extends view.component(use => {
9
+ use.css(cssReset, styleCss)
10
+ const opGame = use.op.load(async() => Game.load())
11
+ return loader(opGame, game => Theater(game))
12
+ }) {}
13
+
@@ -0,0 +1,4 @@
1
+
2
+ import {css} from "lit"
3
+ export default css``
4
+
@@ -0,0 +1,57 @@
1
+
2
+ import {css} from "lit"
3
+ export const styles = css`
4
+
5
+ :host {
6
+ display: flex;
7
+ flex-direction: column;
8
+ align-items: center;
9
+
10
+ gap: 1em;
11
+ }
12
+
13
+ .surface {
14
+ position: relative;
15
+ width: 100%;
16
+ height: auto;
17
+ aspect-ratio: 2 / 1;
18
+ overflow: hidden;
19
+
20
+ background: #000;
21
+ border: 0.5em solid #fff4;
22
+ border-radius: 2em;
23
+
24
+ canvas {
25
+ display: block;
26
+ position: absolute;
27
+ inset: 0;
28
+
29
+ width: 100%;
30
+ height: 100%;
31
+
32
+ image-rendering: pixelated;
33
+ outline: 1px solid red;
34
+ }
35
+
36
+ [deck="overlay"] {
37
+ position: absolute;
38
+ top: 10%;
39
+ left: 0;
40
+ right: 0;
41
+
42
+ display: flex;
43
+ justify-content: center;
44
+ align-items: center;
45
+ }
46
+ }
47
+
48
+ .dlist {
49
+ display: flex;
50
+ flex-wrap: wrap;
51
+ justify-content: center;
52
+ align-items: center;
53
+ gap: 0.5em;
54
+ }
55
+
56
+ `
57
+
@@ -0,0 +1,53 @@
1
+
2
+ import {html} from "lit"
3
+ import {cssReset, view} from "@e280/sly"
4
+ import {repeat} from "lit/directives/repeat.js"
5
+
6
+ import {styles} from "./styles.css.js"
7
+ import {Game} from "../../game/game.js"
8
+ import {VirtualDeviceView} from "./virtual/view.js"
9
+ import {VirtualDevice} from "../../game/parts/virtual-device.js"
10
+
11
+ export const Theater = view(use => (game: Game) => {
12
+ use.css(cssReset, styles)
13
+ use.mount(() => game.loop(60))
14
+ use.mount(() => game.deck.hub.on(use.render))
15
+
16
+ const addVirtual = () => game.plug(new VirtualDevice(game.deck.hub))
17
+ const revealOverlay = () => game.deck.overlayVisibility.bump()
18
+
19
+ const virtualDevices = game.deck.hub.ports
20
+ .flatMap(port => port.devices.array())
21
+ .filter(device => device instanceof VirtualDevice)
22
+ .map(device => ({device, skin: game.deck.deviceSkins.get(device)}))
23
+ .sort((a, b) => a.skin.label < b.skin.label ? -1 : 1)
24
+
25
+ return html`
26
+ <div class=surface>
27
+ ${game.renderer.canvas}
28
+ ${game.deck.views.DeckOverlay()}
29
+ </div>
30
+
31
+ <div class=dlist>
32
+ ${repeat(
33
+ virtualDevices,
34
+ d => d.skin.label,
35
+ ({device, skin}) => {
36
+ return VirtualDeviceView
37
+ .props(game.deck.hub, device, skin)
38
+ .attr("style", `--color: ${skin.color};`)
39
+ .render()
40
+ },
41
+ )}
42
+
43
+ <button @click="${addVirtual}">
44
+
45
+ </button>
46
+
47
+ <button @click="${revealOverlay}">
48
+ 👁️
49
+ </button>
50
+ </div>
51
+ `
52
+ })
53
+
@@ -0,0 +1,43 @@
1
+
2
+ import {css} from "lit"
3
+ export default css`
4
+
5
+ :host {
6
+ --color: #aaa;
7
+ }
8
+
9
+ .box {
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+
14
+ gap: 0.2em;
15
+ padding: 0.2em;
16
+ padding-right: 0.5em;
17
+
18
+ border-radius: 2em;
19
+ background: color-mix(in srgb, #fff4, var(--color));
20
+ }
21
+
22
+ [view="nub-stick"] {
23
+ width: 2em;
24
+ }
25
+
26
+ .label {
27
+ font-size: 1.2em;
28
+ font-weight: bold;
29
+
30
+ padding: 0 0.5em;
31
+ text-align: center;
32
+
33
+ color: white;
34
+ text-shadow: 0.1em 0.1em 0.1em #0004;
35
+ }
36
+
37
+ button {
38
+ font-size: 0.8em;
39
+ padding: 0.2em;
40
+ }
41
+
42
+ `
43
+