@multitapio/multitap 0.0.1

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 (286) hide show
  1. package/dist/.stamp +0 -0
  2. package/dist/cache.d.ts +117 -0
  3. package/dist/cache.d.ts.map +1 -0
  4. package/dist/channel.d.ts +91 -0
  5. package/dist/channel.d.ts.map +1 -0
  6. package/dist/channel.worker.d.ts +3 -0
  7. package/dist/channel.worker.d.ts.map +1 -0
  8. package/dist/codegen/config.d.ts +107 -0
  9. package/dist/codegen/config.d.ts.map +1 -0
  10. package/dist/codegen/generator.d.ts +78 -0
  11. package/dist/codegen/generator.d.ts.map +1 -0
  12. package/dist/codegen/index.d.ts +13 -0
  13. package/dist/codegen/index.d.ts.map +1 -0
  14. package/dist/codegen/inject.d.ts +51 -0
  15. package/dist/codegen/inject.d.ts.map +1 -0
  16. package/dist/codegen/rust.d.ts +22 -0
  17. package/dist/codegen/rust.d.ts.map +1 -0
  18. package/dist/codegen/typescript.d.ts +22 -0
  19. package/dist/codegen/typescript.d.ts.map +1 -0
  20. package/dist/constants.d.ts +5 -0
  21. package/dist/constants.d.ts.map +1 -0
  22. package/dist/crypto.d.ts +141 -0
  23. package/dist/crypto.d.ts.map +1 -0
  24. package/dist/debug.d.ts +39 -0
  25. package/dist/debug.d.ts.map +1 -0
  26. package/dist/diagnostics/index.d.ts +12 -0
  27. package/dist/diagnostics/index.d.ts.map +1 -0
  28. package/dist/diagnostics.js +5502 -0
  29. package/dist/e2e/cli.d.ts +2 -0
  30. package/dist/e2e/cli.d.ts.map +1 -0
  31. package/dist/executor.d.ts +130 -0
  32. package/dist/executor.d.ts.map +1 -0
  33. package/dist/globals.d.ts +32 -0
  34. package/dist/helpers.d.ts +3 -0
  35. package/dist/helpers.d.ts.map +1 -0
  36. package/dist/input-codec.d.ts +136 -0
  37. package/dist/input-codec.d.ts.map +1 -0
  38. package/dist/input-graph.d.ts +106 -0
  39. package/dist/input-graph.d.ts.map +1 -0
  40. package/dist/lib.d.ts +10 -0
  41. package/dist/lib.d.ts.map +1 -0
  42. package/dist/lib.js +9409 -0
  43. package/dist/messages.d.ts +63 -0
  44. package/dist/messages.d.ts.map +1 -0
  45. package/dist/peer-mesh.d.ts +77 -0
  46. package/dist/peer-mesh.d.ts.map +1 -0
  47. package/dist/react/Crosshair.d.ts +17 -0
  48. package/dist/react/Crosshair.d.ts.map +1 -0
  49. package/dist/react/Player.d.ts +10 -0
  50. package/dist/react/Player.d.ts.map +1 -0
  51. package/dist/react/PlayerPoseContext.d.ts +31 -0
  52. package/dist/react/PlayerPoseContext.d.ts.map +1 -0
  53. package/dist/react/hooks/index.d.ts +7 -0
  54. package/dist/react/hooks/index.d.ts.map +1 -0
  55. package/dist/react/hooks/useEvent.d.ts +46 -0
  56. package/dist/react/hooks/useEvent.d.ts.map +1 -0
  57. package/dist/react/hooks/useFrame.d.ts +23 -0
  58. package/dist/react/hooks/useFrame.d.ts.map +1 -0
  59. package/dist/react/hooks/usePlayers.d.ts +24 -0
  60. package/dist/react/hooks/usePlayers.d.ts.map +1 -0
  61. package/dist/react/hooks/useQuery.d.ts +41 -0
  62. package/dist/react/hooks/useQuery.d.ts.map +1 -0
  63. package/dist/react/hooks/useSession.d.ts +10 -0
  64. package/dist/react/hooks/useSession.d.ts.map +1 -0
  65. package/dist/react/index.d.ts +18 -0
  66. package/dist/react/index.d.ts.map +1 -0
  67. package/dist/react/input/DesktopInputMapper.d.ts +38 -0
  68. package/dist/react/input/DesktopInputMapper.d.ts.map +1 -0
  69. package/dist/react/input/index.d.ts +4 -0
  70. package/dist/react/input/index.d.ts.map +1 -0
  71. package/dist/react/input/types.d.ts +46 -0
  72. package/dist/react/input/types.d.ts.map +1 -0
  73. package/dist/react/providers/SessionProvider.d.ts +17 -0
  74. package/dist/react/providers/SessionProvider.d.ts.map +1 -0
  75. package/dist/react/providers/index.d.ts +2 -0
  76. package/dist/react/providers/index.d.ts.map +1 -0
  77. package/dist/react/types/index.d.ts +2 -0
  78. package/dist/react/types/index.d.ts.map +1 -0
  79. package/dist/react/types/session.d.ts +88 -0
  80. package/dist/react/types/session.d.ts.map +1 -0
  81. package/dist/react/types.d.ts +134 -0
  82. package/dist/react/types.d.ts.map +1 -0
  83. package/dist/react/utils/math.d.ts +19 -0
  84. package/dist/react/utils/math.d.ts.map +1 -0
  85. package/dist/react/views/AsteroidsView.d.ts +24 -0
  86. package/dist/react/views/AsteroidsView.d.ts.map +1 -0
  87. package/dist/react/views/FirstPersonView.d.ts +10 -0
  88. package/dist/react/views/FirstPersonView.d.ts.map +1 -0
  89. package/dist/react/views/IsometricView.d.ts +21 -0
  90. package/dist/react/views/IsometricView.d.ts.map +1 -0
  91. package/dist/react/views/MapView.d.ts +16 -0
  92. package/dist/react/views/MapView.d.ts.map +1 -0
  93. package/dist/react/views/MobaView.d.ts +17 -0
  94. package/dist/react/views/MobaView.d.ts.map +1 -0
  95. package/dist/react/views/SideOnView.d.ts +23 -0
  96. package/dist/react/views/SideOnView.d.ts.map +1 -0
  97. package/dist/react/views/ThirdPersonFixedView.d.ts +21 -0
  98. package/dist/react/views/ThirdPersonFixedView.d.ts.map +1 -0
  99. package/dist/react/views/ThirdPersonView.d.ts +12 -0
  100. package/dist/react/views/ThirdPersonView.d.ts.map +1 -0
  101. package/dist/react/views/TopDownFixedView.d.ts +20 -0
  102. package/dist/react/views/TopDownFixedView.d.ts.map +1 -0
  103. package/dist/react/views/TopDownView.d.ts +12 -0
  104. package/dist/react/views/TopDownView.d.ts.map +1 -0
  105. package/dist/react/views/TwinStickView.d.ts +13 -0
  106. package/dist/react/views/TwinStickView.d.ts.map +1 -0
  107. package/dist/react/views/VehicleFixedView.d.ts +16 -0
  108. package/dist/react/views/VehicleFixedView.d.ts.map +1 -0
  109. package/dist/react/views/VehicleView.d.ts +13 -0
  110. package/dist/react/views/VehicleView.d.ts.map +1 -0
  111. package/dist/react/views/index.d.ts +21 -0
  112. package/dist/react/views/index.d.ts.map +1 -0
  113. package/dist/react/views/types.d.ts +136 -0
  114. package/dist/react/views/types.d.ts.map +1 -0
  115. package/dist/rollback.d.ts +193 -0
  116. package/dist/rollback.d.ts.map +1 -0
  117. package/dist/rollback.worker.d.ts +3 -0
  118. package/dist/rollback.worker.d.ts.map +1 -0
  119. package/dist/schema.d.ts +309 -0
  120. package/dist/schema.d.ts.map +1 -0
  121. package/dist/session-config.d.ts +119 -0
  122. package/dist/session-config.d.ts.map +1 -0
  123. package/dist/session.d.ts +120 -0
  124. package/dist/session.d.ts.map +1 -0
  125. package/dist/state.d.ts +400 -0
  126. package/dist/state.d.ts.map +1 -0
  127. package/dist/stats.d.ts +21 -0
  128. package/dist/stats.d.ts.map +1 -0
  129. package/dist/test-session.d.ts +170 -0
  130. package/dist/test-session.d.ts.map +1 -0
  131. package/dist/types/cache.d.ts +117 -0
  132. package/dist/types/cache.d.ts.map +1 -0
  133. package/dist/types/channel.d.ts +91 -0
  134. package/dist/types/channel.d.ts.map +1 -0
  135. package/dist/types/channel.worker.d.ts +3 -0
  136. package/dist/types/channel.worker.d.ts.map +1 -0
  137. package/dist/types/codegen/config.d.ts +107 -0
  138. package/dist/types/codegen/config.d.ts.map +1 -0
  139. package/dist/types/codegen/generator.d.ts +78 -0
  140. package/dist/types/codegen/generator.d.ts.map +1 -0
  141. package/dist/types/codegen/index.d.ts +13 -0
  142. package/dist/types/codegen/index.d.ts.map +1 -0
  143. package/dist/types/codegen/inject.d.ts +51 -0
  144. package/dist/types/codegen/inject.d.ts.map +1 -0
  145. package/dist/types/codegen/rust.d.ts +22 -0
  146. package/dist/types/codegen/rust.d.ts.map +1 -0
  147. package/dist/types/codegen/typescript.d.ts +22 -0
  148. package/dist/types/codegen/typescript.d.ts.map +1 -0
  149. package/dist/types/constants.d.ts +5 -0
  150. package/dist/types/constants.d.ts.map +1 -0
  151. package/dist/types/crypto.d.ts +141 -0
  152. package/dist/types/crypto.d.ts.map +1 -0
  153. package/dist/types/debug.d.ts +39 -0
  154. package/dist/types/debug.d.ts.map +1 -0
  155. package/dist/types/diagnostics/index.d.ts +12 -0
  156. package/dist/types/diagnostics/index.d.ts.map +1 -0
  157. package/dist/types/e2e/cli.d.ts +2 -0
  158. package/dist/types/e2e/cli.d.ts.map +1 -0
  159. package/dist/types/executor.d.ts +130 -0
  160. package/dist/types/executor.d.ts.map +1 -0
  161. package/dist/types/helpers.d.ts +3 -0
  162. package/dist/types/helpers.d.ts.map +1 -0
  163. package/dist/types/input-codec.d.ts +136 -0
  164. package/dist/types/input-codec.d.ts.map +1 -0
  165. package/dist/types/input-graph.d.ts +106 -0
  166. package/dist/types/input-graph.d.ts.map +1 -0
  167. package/dist/types/lib.d.ts +10 -0
  168. package/dist/types/lib.d.ts.map +1 -0
  169. package/dist/types/messages.d.ts +63 -0
  170. package/dist/types/messages.d.ts.map +1 -0
  171. package/dist/types/peer-mesh.d.ts +77 -0
  172. package/dist/types/peer-mesh.d.ts.map +1 -0
  173. package/dist/types/react/Crosshair.d.ts +17 -0
  174. package/dist/types/react/Crosshair.d.ts.map +1 -0
  175. package/dist/types/react/Player.d.ts +10 -0
  176. package/dist/types/react/Player.d.ts.map +1 -0
  177. package/dist/types/react/PlayerPoseContext.d.ts +31 -0
  178. package/dist/types/react/PlayerPoseContext.d.ts.map +1 -0
  179. package/dist/types/react/hooks/index.d.ts +7 -0
  180. package/dist/types/react/hooks/index.d.ts.map +1 -0
  181. package/dist/types/react/hooks/useEvent.d.ts +46 -0
  182. package/dist/types/react/hooks/useEvent.d.ts.map +1 -0
  183. package/dist/types/react/hooks/useFrame.d.ts +23 -0
  184. package/dist/types/react/hooks/useFrame.d.ts.map +1 -0
  185. package/dist/types/react/hooks/usePlayers.d.ts +24 -0
  186. package/dist/types/react/hooks/usePlayers.d.ts.map +1 -0
  187. package/dist/types/react/hooks/useQuery.d.ts +41 -0
  188. package/dist/types/react/hooks/useQuery.d.ts.map +1 -0
  189. package/dist/types/react/hooks/useSession.d.ts +10 -0
  190. package/dist/types/react/hooks/useSession.d.ts.map +1 -0
  191. package/dist/types/react/index.d.ts +18 -0
  192. package/dist/types/react/index.d.ts.map +1 -0
  193. package/dist/types/react/input/DesktopInputMapper.d.ts +38 -0
  194. package/dist/types/react/input/DesktopInputMapper.d.ts.map +1 -0
  195. package/dist/types/react/input/index.d.ts +4 -0
  196. package/dist/types/react/input/index.d.ts.map +1 -0
  197. package/dist/types/react/input/types.d.ts +46 -0
  198. package/dist/types/react/input/types.d.ts.map +1 -0
  199. package/dist/types/react/providers/SessionProvider.d.ts +17 -0
  200. package/dist/types/react/providers/SessionProvider.d.ts.map +1 -0
  201. package/dist/types/react/providers/index.d.ts +2 -0
  202. package/dist/types/react/providers/index.d.ts.map +1 -0
  203. package/dist/types/react/types/index.d.ts +2 -0
  204. package/dist/types/react/types/index.d.ts.map +1 -0
  205. package/dist/types/react/types/session.d.ts +88 -0
  206. package/dist/types/react/types/session.d.ts.map +1 -0
  207. package/dist/types/react/types.d.ts +134 -0
  208. package/dist/types/react/types.d.ts.map +1 -0
  209. package/dist/types/react/utils/math.d.ts +19 -0
  210. package/dist/types/react/utils/math.d.ts.map +1 -0
  211. package/dist/types/react/views/AsteroidsView.d.ts +24 -0
  212. package/dist/types/react/views/AsteroidsView.d.ts.map +1 -0
  213. package/dist/types/react/views/FirstPersonView.d.ts +10 -0
  214. package/dist/types/react/views/FirstPersonView.d.ts.map +1 -0
  215. package/dist/types/react/views/IsometricView.d.ts +21 -0
  216. package/dist/types/react/views/IsometricView.d.ts.map +1 -0
  217. package/dist/types/react/views/MapView.d.ts +16 -0
  218. package/dist/types/react/views/MapView.d.ts.map +1 -0
  219. package/dist/types/react/views/MobaView.d.ts +17 -0
  220. package/dist/types/react/views/MobaView.d.ts.map +1 -0
  221. package/dist/types/react/views/SideOnView.d.ts +23 -0
  222. package/dist/types/react/views/SideOnView.d.ts.map +1 -0
  223. package/dist/types/react/views/ThirdPersonFixedView.d.ts +21 -0
  224. package/dist/types/react/views/ThirdPersonFixedView.d.ts.map +1 -0
  225. package/dist/types/react/views/ThirdPersonView.d.ts +12 -0
  226. package/dist/types/react/views/ThirdPersonView.d.ts.map +1 -0
  227. package/dist/types/react/views/TopDownFixedView.d.ts +20 -0
  228. package/dist/types/react/views/TopDownFixedView.d.ts.map +1 -0
  229. package/dist/types/react/views/TopDownView.d.ts +12 -0
  230. package/dist/types/react/views/TopDownView.d.ts.map +1 -0
  231. package/dist/types/react/views/TwinStickView.d.ts +13 -0
  232. package/dist/types/react/views/TwinStickView.d.ts.map +1 -0
  233. package/dist/types/react/views/VehicleFixedView.d.ts +16 -0
  234. package/dist/types/react/views/VehicleFixedView.d.ts.map +1 -0
  235. package/dist/types/react/views/VehicleView.d.ts +13 -0
  236. package/dist/types/react/views/VehicleView.d.ts.map +1 -0
  237. package/dist/types/react/views/index.d.ts +21 -0
  238. package/dist/types/react/views/index.d.ts.map +1 -0
  239. package/dist/types/react/views/types.d.ts +136 -0
  240. package/dist/types/react/views/types.d.ts.map +1 -0
  241. package/dist/types/rollback.d.ts +193 -0
  242. package/dist/types/rollback.d.ts.map +1 -0
  243. package/dist/types/rollback.worker.d.ts +3 -0
  244. package/dist/types/rollback.worker.d.ts.map +1 -0
  245. package/dist/types/schema.d.ts +309 -0
  246. package/dist/types/schema.d.ts.map +1 -0
  247. package/dist/types/session-config.d.ts +119 -0
  248. package/dist/types/session-config.d.ts.map +1 -0
  249. package/dist/types/session.d.ts +120 -0
  250. package/dist/types/session.d.ts.map +1 -0
  251. package/dist/types/state.d.ts +400 -0
  252. package/dist/types/state.d.ts.map +1 -0
  253. package/dist/types/stats.d.ts +21 -0
  254. package/dist/types/stats.d.ts.map +1 -0
  255. package/dist/types/test-session.d.ts +170 -0
  256. package/dist/types/test-session.d.ts.map +1 -0
  257. package/dist/types/utils.d.ts +26 -0
  258. package/dist/types/utils.d.ts.map +1 -0
  259. package/dist/types/vite/codegen-runner.d.ts +27 -0
  260. package/dist/types/vite/codegen-runner.d.ts.map +1 -0
  261. package/dist/types/vite/index.d.ts +20 -0
  262. package/dist/types/vite/index.d.ts.map +1 -0
  263. package/dist/types/vite/module-builder.d.ts +28 -0
  264. package/dist/types/vite/module-builder.d.ts.map +1 -0
  265. package/dist/types/vite/plugin.d.ts +27 -0
  266. package/dist/types/vite/plugin.d.ts.map +1 -0
  267. package/dist/types/vite/types.d.ts +37 -0
  268. package/dist/types/vite/types.d.ts.map +1 -0
  269. package/dist/types/vite/wasm-compiler.d.ts +32 -0
  270. package/dist/types/vite/wasm-compiler.d.ts.map +1 -0
  271. package/dist/utils.d.ts +26 -0
  272. package/dist/utils.d.ts.map +1 -0
  273. package/dist/vite/codegen-runner.d.ts +27 -0
  274. package/dist/vite/codegen-runner.d.ts.map +1 -0
  275. package/dist/vite/index.d.ts +20 -0
  276. package/dist/vite/index.d.ts.map +1 -0
  277. package/dist/vite/index.js +4202 -0
  278. package/dist/vite/module-builder.d.ts +28 -0
  279. package/dist/vite/module-builder.d.ts.map +1 -0
  280. package/dist/vite/plugin.d.ts +27 -0
  281. package/dist/vite/plugin.d.ts.map +1 -0
  282. package/dist/vite/types.d.ts +37 -0
  283. package/dist/vite/types.d.ts.map +1 -0
  284. package/dist/vite/wasm-compiler.d.ts +32 -0
  285. package/dist/vite/wasm-compiler.d.ts.map +1 -0
  286. package/package.json +92 -0
@@ -0,0 +1,21 @@
1
+ import type { ViewType } from '../types';
2
+ import type { View } from './types';
3
+ /**
4
+ * Get a view implementation by type
5
+ */
6
+ export declare function getView(type: ViewType): View;
7
+ export { FirstPersonView } from './FirstPersonView';
8
+ export { ThirdPersonView } from './ThirdPersonView';
9
+ export { ThirdPersonFixedView } from './ThirdPersonFixedView';
10
+ export { TopDownView } from './TopDownView';
11
+ export { TopDownFixedView } from './TopDownFixedView';
12
+ export { IsometricView } from './IsometricView';
13
+ export { SideOnView } from './SideOnView';
14
+ export { MapView } from './MapView';
15
+ export { VehicleView } from './VehicleView';
16
+ export { VehicleFixedView } from './VehicleFixedView';
17
+ export { TwinStickView } from './TwinStickView';
18
+ export { MobaView } from './MobaView';
19
+ export { AsteroidsView } from './AsteroidsView';
20
+ export type { CrosshairConfig, CrosshairMode, View, ViewContext, ViewState } from './types';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/views/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAkCnC;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAE5C;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,136 @@
1
+ import type { Camera, Object3D, Quaternion, Vector2, Vector3 } from 'three';
2
+ import type { RawInput } from '../input/types';
3
+ import type { PlayerProps } from '../types';
4
+ /**
5
+ * State managed by a view
6
+ *
7
+ * Coordinate convention (matches Three.js):
8
+ * - Right-handed, Y-up, XZ ground plane
9
+ * - Forward = -Z in heading-space (matches Three.js camera/object look direction)
10
+ *
11
+ * Intent model:
12
+ * - `heading`: Movement reference frame (move vector is relative to this)
13
+ * - `aim`: Attack/targeting direction (where camera points)
14
+ * - `move`: Movement intent relative to heading (move.z < 0 = forward, move.z > 0 = backward)
15
+ *
16
+ * For many views, heading === aim (same quaternion value).
17
+ *
18
+ * Views where aim can differ from heading:
19
+ * - Orbit-style thirdPerson: aim follows direction of travel while heading stays camera-relative.
20
+ * - Vehicle: heading = body direction (from server), aim = mouse direction
21
+ * - TwinStick: heading = screen up (fixed), aim = cursor direction
22
+ * - Moba: heading = iso camera direction (fixed), aim = cursor direction
23
+ */
24
+ export interface ViewState {
25
+ /** Horizontal orbit angle (radians) */
26
+ yaw: number;
27
+ /** Vertical look angle (radians, clamped) */
28
+ pitch: number;
29
+ /** Movement reference frame (facing direction quaternion) */
30
+ heading: Quaternion;
31
+ /** Attack/look direction (where camera points) */
32
+ aim: Quaternion;
33
+ /** Current movement intent relative to heading (move.z < 0 = forward) */
34
+ move: Vector3;
35
+ /** Standard action flags (bitmask of ACTION_* constants, passed through from RawInput) */
36
+ actions: number;
37
+ /** Pan offset X (world units) - used by GodCam */
38
+ panX?: number;
39
+ /** Pan offset Z (world units) - used by GodCam */
40
+ panZ?: number;
41
+ /** Zoom multiplier - used by GodCam */
42
+ zoom?: number;
43
+ /** Facing direction (+1 or -1) - used by SideOnView */
44
+ facingDirection?: number;
45
+ }
46
+ /**
47
+ * Context passed to view update/apply functions
48
+ */
49
+ export interface ViewContext {
50
+ /** Current body position */
51
+ position: Vector3;
52
+ /** Current body rotation */
53
+ rotation: Quaternion;
54
+ /**
55
+ * Pointer position in normalized device coordinates (NDC), typically from R3F:
56
+ * - x,y are in [-1, +1]
57
+ * - (0,0) is the center of the canvas
58
+ *
59
+ * Optional for backwards compatibility; views that need cursor-based aiming can use it.
60
+ */
61
+ pointer?: Vector2;
62
+ /** Camera pivot (controls yaw and follows player) */
63
+ pivot: Object3D;
64
+ /** Camera (controls pitch and distance from pivot) */
65
+ camera: Camera;
66
+ /** Raw input from input mapper */
67
+ input: RawInput;
68
+ /** Delta time since last frame */
69
+ delta: number;
70
+ /** View-specific props from Player component (all optional) */
71
+ props: {
72
+ cameraDistance: number | undefined;
73
+ cameraHeight: number | undefined;
74
+ cameraOffset: PlayerProps['cameraOffset'];
75
+ damping: number | undefined;
76
+ cameraAngle: number | undefined;
77
+ fixedYaw: number | undefined;
78
+ reverseCam: boolean | undefined;
79
+ };
80
+ }
81
+ /**
82
+ * Interface for view implementations
83
+ */
84
+ /**
85
+ * Crosshair positioning mode for different view types
86
+ */
87
+ export type CrosshairMode = 'center' | 'cursor' | 'none';
88
+ /**
89
+ * Crosshair configuration for a view
90
+ */
91
+ export interface CrosshairConfig {
92
+ mode: CrosshairMode;
93
+ /**
94
+ * Vertical offset as percentage of screen height (positive = down).
95
+ * Used to compensate for parallax in third-person views where bullets
96
+ * fire from player position, not camera position.
97
+ */
98
+ offsetY?: number;
99
+ }
100
+ export interface View {
101
+ /** Human-readable name */
102
+ name: string;
103
+ /**
104
+ * If true, the player body rotation follows the view's heading.
105
+ * Used by firstPerson and thirdPersonFixed where camera+body rotate together.
106
+ * Default: false (body rotation comes from server/props)
107
+ */
108
+ bodyFollowsHeading?: boolean;
109
+ /**
110
+ * How the crosshair should be positioned for this view.
111
+ * - 'center': Fixed at screen center (FPS, third-person mouselook)
112
+ * - 'cursor': Follows mouse cursor position (twin-stick, MOBA)
113
+ * - 'none': No crosshair (map, sideOn, asteroids)
114
+ * Default: 'none'
115
+ */
116
+ crosshairMode?: CrosshairMode;
117
+ /**
118
+ * Vertical offset for the crosshair as percentage of screen height.
119
+ * Positive values move the crosshair down.
120
+ * Used to compensate for parallax in third-person views.
121
+ */
122
+ crosshairOffsetY?: number;
123
+ /** Initialize view state, optionally preserving values from previous view */
124
+ init(prevState?: ViewState): ViewState;
125
+ /**
126
+ * Update view state based on input
127
+ * Called every frame when enableInput is true
128
+ */
129
+ update(state: ViewState, ctx: ViewContext): ViewState;
130
+ /**
131
+ * Position and orient the pivot and camera based on current state
132
+ * Called every frame
133
+ */
134
+ applyToCamera(state: ViewState, ctx: ViewContext): void;
135
+ }
136
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/react/views/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,6DAA6D;IAC7D,OAAO,EAAE,UAAU,CAAA;IACnB,kDAAkD;IAClD,GAAG,EAAE,UAAU,CAAA;IACf,yEAAyE;IACzE,IAAI,EAAE,OAAO,CAAA;IACb,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAA;IAGf,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4BAA4B;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,4BAA4B;IAC5B,QAAQ,EAAE,UAAU,CAAA;IACpB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,qDAAqD;IACrD,KAAK,EAAE,QAAQ,CAAA;IACf,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,kCAAkC;IAClC,KAAK,EAAE,QAAQ,CAAA;IACf,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,KAAK,EAAE;QACL,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;QAClC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;QAChC,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,CAAA;QACzC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;QAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;QAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;QAC5B,UAAU,EAAE,OAAO,GAAG,SAAS,CAAA;KAChC,CAAA;CACF;AAED;;GAEG;AACH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAA;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,IAAI;IACnB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IAEZ;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAE7B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,6EAA6E;IAC7E,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAEtC;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,CAAA;IAErD;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAAA;CACxD"}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * StateManager - Orchestrates InputGraph, state transitions, and caching with automatic rollback support.
3
+ *
4
+ * Key features:
5
+ * - Pure determinism: Transition function receives only what it needs
6
+ * - Automatic rollback: Detects when ticks arrive earlier than current position
7
+ * - Cache optimization: Skips computation when cache hits
8
+ * - Sync checkpoint: Pins sync head state (can never rollback past it)
9
+ * - Web worker ready: Transferable Uint8Array buffers
10
+ * - Pluggable transitions: Same interface for JS or WASM implementations
11
+ *
12
+ * @module state-manager
13
+ */
14
+ import { type AsyncTickLog } from './input-graph';
15
+ import { type InputCodec, InputInstance } from './input-codec';
16
+ import { StateCache } from './cache';
17
+ import { type CompiledSchema, type StateBuffer } from './state';
18
+ import { type BatchTransitionExecutor, type ExecutorOptions } from './executor';
19
+ /**
20
+ * Context passed to per-tick JS transition functions.
21
+ * Used with createJsTransition helper.
22
+ */
23
+ export interface TransitionContext {
24
+ /** Compiled state schema (pass to state.ts functions) */
25
+ schema: CompiledSchema;
26
+ /** State buffer to mutate */
27
+ state: StateBuffer;
28
+ /** Current tick number */
29
+ tick: number;
30
+ /** Decoded inputs, one per participant */
31
+ inputs: InputInstance[];
32
+ }
33
+ /**
34
+ * Result of a tick() call.
35
+ */
36
+ export interface TickResult {
37
+ /** The state buffer after applying ticks (transferable) */
38
+ state: Uint8Array;
39
+ /** The tick number of the returned state - null if t=0 is not yet initialized */
40
+ tick: number | null;
41
+ /** Node ID for the returned state (pass to next tick() call) */
42
+ nodeId: string;
43
+ /** True if rollback occurred */
44
+ rolledBack: boolean;
45
+ /** Number of ticks computed (0 if all cache hits) */
46
+ ticksComputed: number;
47
+ }
48
+ /**
49
+ * Options for StateManager configuration.
50
+ */
51
+ export type RollbackOptions = {
52
+ /** Be noisy in the console */
53
+ debug?: boolean | undefined;
54
+ /** Compiled state schema */
55
+ stateSchema: CompiledSchema;
56
+ /** InputGraph for tick data - pass via setLog() for MessagePort transfer to work */
57
+ log?: AsyncTickLog;
58
+ /** Genesis hash for genesis state */
59
+ genesisHash: Uint8Array;
60
+ /** Tick rate in Hz (ticks per second) - stored in state header for physics */
61
+ tickRate?: number;
62
+ /** Optional cache (created internally if not provided) */
63
+ cache?: StateCache;
64
+ /**
65
+ * Executor configuration - either:
66
+ * - ExecutorOptions: WASM module config (creates Executor internally)
67
+ * - BatchTransitionExecutor: Pre-built executor (useful for testing/mocking)
68
+ */
69
+ executor: ExecutorOptions | BatchTransitionExecutor;
70
+ /** grace backoff period between tick attempts that result in no new ticks (default 10ms) */
71
+ tickGraceMs?: number | undefined;
72
+ /** number of ticks to lag behind the input graph (default 1), larger will mean
73
+ * fewer rollbacks but simulation will lag behind reality */
74
+ tickLag?: number | undefined;
75
+ /** maximum number of ticks to process in a single batch (default 100) */
76
+ maxBatchSize?: number | undefined;
77
+ /** disable the tick loop (default false) - you will have to manually call tick() to advance the state*/
78
+ disableTicking?: boolean | undefined;
79
+ };
80
+ /**
81
+ * Create a batch transition function from a per-tick JS function.
82
+ */
83
+ export declare function createJsExecutor(schema: CompiledSchema, inputCodec: InputCodec, perTick: (ctx: TransitionContext) => void): BatchTransitionExecutor;
84
+ type OnStateUpdateFn = (state: StateBuffer) => void;
85
+ /**
86
+ * Manages state transitions with automatic rollback support.
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * ```
91
+ */
92
+ export declare class Rollback {
93
+ private debug;
94
+ private stateSchema;
95
+ private inputs;
96
+ private cache;
97
+ private executor;
98
+ private genesisStateId;
99
+ private options;
100
+ private ticking;
101
+ private tickGraceMs;
102
+ private tickLag;
103
+ private maxBatchSize;
104
+ private currentState;
105
+ private currentTick;
106
+ private currentNodeId;
107
+ private prevOnStateUpdateState;
108
+ private onStateUpdate?;
109
+ private syncCheckpoint;
110
+ private readonly stateHistory;
111
+ private readonly maxHistory;
112
+ private stats;
113
+ constructor(options: RollbackOptions);
114
+ /**
115
+ * Set the tick log (for MessagePort transfer via comlink).
116
+ * Must be called before init() if log wasn't provided in constructor.
117
+ */
118
+ setLog(port: MessagePort): void;
119
+ /**
120
+ * Set the state update callback.
121
+ * Must be called before init() if onStateUpdate wasn't provided in constructor.
122
+ */
123
+ setOnStateUpdate(callback: OnStateUpdateFn | null): void;
124
+ init(): Promise<StateBuffer>;
125
+ private loop;
126
+ private _loop;
127
+ /**
128
+ * Advance state by processing available ticks from InputGraph.
129
+ * Automatically handles rollback when earlier ticks arrive.
130
+ *
131
+ * Strategy:
132
+ * 1. Fast-forward through cache hits (O(1) lookup per tick)
133
+ * 2. Split remaining ticks at sync boundary
134
+ * 3. Process sync ticks, checkpoint the result
135
+ * 4. Process predicted ticks
136
+ * @param maxTickNum - Optional limit on largest tick number to process.
137
+ *
138
+ * @returns TickResult with new state and metadata
139
+ */
140
+ tick(maxTickNum?: number | null): Promise<TickResult>;
141
+ getStats(): Promise<{
142
+ rollbacks: number;
143
+ executions: number;
144
+ updates: number;
145
+ }>;
146
+ /**
147
+ * Process ticks with cache fast-forward, then batch the rest.
148
+ *
149
+ * @returns Number of ticks computed (excludes cache hits)
150
+ */
151
+ private processTicks;
152
+ /**
153
+ * Compute the final stateId after processing a batch of ticks.
154
+ * StateId is computed incrementally: hash(prevStateId || tick || payloads)
155
+ */
156
+ private computeBatchStateId;
157
+ /**
158
+ * Get current state (copy, safe to transfer).
159
+ */
160
+ getState(): Uint8Array;
161
+ /**
162
+ * Get current tick number.
163
+ */
164
+ getTick(): number | null;
165
+ /**
166
+ * Reset to genesis state.
167
+ */
168
+ reset(): void;
169
+ close(): void;
170
+ /**
171
+ * Rollback to process from the target tick onwards.
172
+ *
173
+ * The goal is to find the best starting point:
174
+ * - If checkpoint is at or past the target, we can skip some ticks
175
+ * - Otherwise, find the closest state before the target
176
+ */
177
+ private rollbackTo;
178
+ /**
179
+ * Update the sync checkpoint with the latest sync tick state.
180
+ * This state is pinned and won't be evicted.
181
+ */
182
+ private updateSyncCheckpoint;
183
+ /**
184
+ * Record a recent snapshot for rollback recovery.
185
+ */
186
+ private recordStateSnapshot;
187
+ /**
188
+ * Find the newest snapshot at or before the requested tick.
189
+ */
190
+ private findSnapshotAtOrBefore;
191
+ }
192
+ export {};
193
+ //# sourceMappingURL=rollback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollback.d.ts","sourceRoot":"","sources":["../../src/rollback.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ declare const _default: new () => Worker;
2
+ export default _default;
3
+ //# sourceMappingURL=rollback.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollback.worker.d.ts","sourceRoot":"","sources":["../../src/rollback.worker.ts"],"names":[],"mappings":"wBAMkC,UAAU,MAAM;AAAlD,wBAAmD"}
@@ -0,0 +1,309 @@
1
+ /**
2
+ * Shared schema types and compilation for state and input.
3
+ *
4
+ * This module contains all type definitions and compilation functions needed
5
+ * by both the runtime (state.ts, input-codec.ts) and the codegen system.
6
+ *
7
+ * @module schema
8
+ */
9
+ /**
10
+ * Magic number for state buffer header: "MTAP" in ASCII (0x4D544150)
11
+ * Used to identify valid state buffers.
12
+ */
13
+ export declare const MAGIC = 1297367376;
14
+ /**
15
+ * Null entity reference value (0xFFFFFFFF).
16
+ * Used to represent "no entity" in entityRef fields.
17
+ */
18
+ export declare const NULL_ENTITY: EntityRef;
19
+ /** Size of the state buffer header in bytes */
20
+ export declare const HEADER_SIZE = 44;
21
+ /** Offset of the stateId field in the header */
22
+ export declare const STATE_ID_OFFSET = 8;
23
+ /** Size of the stateId field (SHA256 hash) */
24
+ export declare const STATE_ID_SIZE = 32;
25
+ /** Offset of the tick field in the header */
26
+ export declare const TICK_OFFSET = 40;
27
+ /** Offset of the tick rate field in the header (uses one of the reserved bytes) */
28
+ export declare const TICK_RATE_OFFSET = 6;
29
+ /** Byte sizes for state primitive types (excludes input-specific flags types) */
30
+ export declare const TYPE_SIZES: Record<string, number>;
31
+ /** Byte sizes for input types (includes flags types) */
32
+ export declare const INPUT_TYPE_SIZES: Record<string, number>;
33
+ /** Valid primitive types that can be used as array element types */
34
+ export declare const PRIMITIVE_TYPES: Set<string>;
35
+ /** Valid primitive scalar types for input array elements (excludes entityRef) */
36
+ export declare const INPUT_PRIMITIVE_SCALAR_TYPES: Set<string>;
37
+ export type Vec2 = [number, number];
38
+ export type Vec3 = [number, number, number];
39
+ export type Quat = [number, number, number, number];
40
+ /**
41
+ * Primitive field types supported by the ECS.
42
+ */
43
+ export type PrimitiveType = 'bool' | 'uint8' | 'int8' | 'uint16' | 'int16' | 'uint32' | 'int32' | 'entityRef' | 'f32';
44
+ /**
45
+ * Compound field types (vectors and quaternions).
46
+ */
47
+ export type CompoundType = 'vec2' | 'vec3' | 'quat';
48
+ /**
49
+ * Fixed-size array type pattern: "type[length]"
50
+ */
51
+ export type ArrayType = `${PrimitiveType}[${number}]`;
52
+ /**
53
+ * Enum field type (backed by uint8).
54
+ */
55
+ export type EnumType = 'enum';
56
+ /**
57
+ * All valid field types.
58
+ */
59
+ export type FieldType = PrimitiveType | CompoundType | ArrayType | EnumType;
60
+ /**
61
+ * Entity reference - a 32-bit packed value containing index and generation.
62
+ */
63
+ export type EntityRef = number;
64
+ /**
65
+ * State buffer type alias.
66
+ */
67
+ export type StateBuffer = Uint8Array;
68
+ /**
69
+ * Field definition for compound components.
70
+ */
71
+ export interface FieldDef {
72
+ readonly name: string;
73
+ readonly type: string;
74
+ readonly variants?: readonly string[];
75
+ }
76
+ /**
77
+ * Component definition.
78
+ */
79
+ export interface ComponentDef {
80
+ readonly name: string;
81
+ readonly type: string;
82
+ readonly singleton?: boolean;
83
+ readonly fields?: readonly FieldDef[];
84
+ readonly variants?: readonly string[];
85
+ }
86
+ /**
87
+ * Event definition.
88
+ */
89
+ export interface EventDef {
90
+ readonly name: string;
91
+ readonly maxEvents?: number;
92
+ readonly fields: readonly FieldDef[];
93
+ }
94
+ /**
95
+ * State schema definition.
96
+ */
97
+ export interface StateSchema {
98
+ readonly maxEntities: number;
99
+ readonly components: readonly ComponentDef[];
100
+ readonly events?: readonly EventDef[];
101
+ }
102
+ /**
103
+ * Flag type names for input controls.
104
+ */
105
+ export type FlagType = 'flags8' | 'flags16' | 'flags32';
106
+ /**
107
+ * Input field type (includes flag types).
108
+ */
109
+ export type InputFieldType = PrimitiveType | FlagType | CompoundType | ArrayType;
110
+ /**
111
+ * Control definition in input schema.
112
+ */
113
+ export interface ControlDef {
114
+ readonly name: string;
115
+ readonly type: string;
116
+ readonly options?: readonly string[];
117
+ readonly hint?: string;
118
+ readonly retain?: 'tick' | 'always';
119
+ }
120
+ /**
121
+ * Command argument definition.
122
+ */
123
+ export interface CommandArgDef {
124
+ readonly name: string;
125
+ readonly type: string;
126
+ }
127
+ /**
128
+ * Command definition in input schema.
129
+ */
130
+ export interface CommandDef {
131
+ readonly name: string;
132
+ readonly args: readonly CommandArgDef[];
133
+ }
134
+ /**
135
+ * Input schema definition.
136
+ */
137
+ export interface InputSchema {
138
+ readonly controls: readonly ControlDef[];
139
+ readonly commands: readonly CommandDef[];
140
+ }
141
+ /**
142
+ * Compiled field information with pre-calculated offsets.
143
+ */
144
+ export interface CompiledField {
145
+ name: string;
146
+ type: FieldType;
147
+ size: number;
148
+ offset: number;
149
+ arrayLength?: number;
150
+ arrayElementType?: PrimitiveType;
151
+ variants?: string[];
152
+ }
153
+ /**
154
+ * Compiled component information with pre-calculated offsets.
155
+ */
156
+ export interface CompiledComponent {
157
+ name: string;
158
+ index: number;
159
+ isTag: boolean;
160
+ isSingleton: boolean;
161
+ size: number;
162
+ storageOffset: number;
163
+ fields: CompiledField[];
164
+ }
165
+ /**
166
+ * Compiled event information with pre-calculated layout.
167
+ */
168
+ export interface CompiledEvent {
169
+ name: string;
170
+ index: number;
171
+ maxEvents: number;
172
+ recordSize: number;
173
+ storageOffset: number;
174
+ bufferSize: number;
175
+ fields: CompiledField[];
176
+ }
177
+ /**
178
+ * Compiled state schema with all pre-calculated layout information.
179
+ */
180
+ export interface CompiledStateSchema {
181
+ maxEntities: number;
182
+ components: CompiledComponent[];
183
+ entityComponents: CompiledComponent[];
184
+ singletonComponents: CompiledComponent[];
185
+ componentByName: Map<string, CompiledComponent>;
186
+ definition: StateSchema;
187
+ events?: CompiledEvent[] | undefined;
188
+ eventByName?: Map<string, CompiledEvent> | undefined;
189
+ headerOffset: 0;
190
+ headerSize: number;
191
+ entityTableOffset: number;
192
+ entityRecordSize: number;
193
+ freeStackOffset: number;
194
+ freeStackSize: number;
195
+ componentStorageOffset: number;
196
+ singletonStorageOffset: number;
197
+ singletonStorageSize: number;
198
+ eventStorageOffset?: number | undefined;
199
+ eventStorageSize?: number | undefined;
200
+ totalSize: number;
201
+ bitmaskSize: number;
202
+ }
203
+ /**
204
+ * Compiled control information with pre-calculated layout.
205
+ * Matches Go's CompiledControl structure for codegen compatibility.
206
+ */
207
+ export interface CompiledControl {
208
+ name: string;
209
+ index: number;
210
+ type: string;
211
+ size: number;
212
+ options?: readonly string[] | undefined;
213
+ hint?: string | undefined;
214
+ retain: 'tick' | 'always';
215
+ }
216
+ /**
217
+ * Compiled command argument (uses same structure as CompiledField).
218
+ */
219
+ export interface CompiledCommandArg {
220
+ name: string;
221
+ type: string;
222
+ size: number;
223
+ offset: number;
224
+ arrayLength?: number;
225
+ arrayElementType?: string;
226
+ }
227
+ /**
228
+ * Compiled command information with pre-calculated layout.
229
+ */
230
+ export interface CompiledCommand {
231
+ name: string;
232
+ index: number;
233
+ args: CompiledCommandArg[];
234
+ totalSize: number;
235
+ }
236
+ /**
237
+ * Compiled input schema with pre-calculated information for encoding/decoding.
238
+ */
239
+ export interface CompiledInputSchema {
240
+ controls: CompiledControl[];
241
+ commands: CompiledCommand[];
242
+ controlByName: Map<string, CompiledControl>;
243
+ commandByName: Map<string, CompiledCommand>;
244
+ }
245
+ /**
246
+ * Parse an array type string like "uint16[8]" into element type and length.
247
+ * Only primitive types (not vec2/vec3) are valid array element types.
248
+ */
249
+ export declare function parseArrayType(type: string): {
250
+ elementType: PrimitiveType;
251
+ length: number;
252
+ } | null;
253
+ /**
254
+ * Parse an input array type string (allows any primitive scalar type).
255
+ */
256
+ export declare function parseInputArrayType(type: string): {
257
+ elementType: string;
258
+ length: number;
259
+ } | null;
260
+ /**
261
+ * Calculate the byte size of a state field type.
262
+ */
263
+ export declare function getTypeSize(type: FieldType): number;
264
+ /**
265
+ * Calculate the byte size of an input field type.
266
+ */
267
+ export declare function getInputTypeSize(type: string): number;
268
+ /**
269
+ * Wrapper around getTypeSize that rethrows errors with component/field context.
270
+ */
271
+ export declare function getValidatedTypeSize(type: string, componentName: string, fieldName?: string): number;
272
+ /**
273
+ * Validate enum variants.
274
+ */
275
+ export declare function validateEnumVariants(rawVariants: unknown, subject: string): string[];
276
+ /**
277
+ * Convert a string from PascalCase/camelCase to UPPER_SNAKE_CASE.
278
+ */
279
+ export declare function toUpperSnake(s: string): string;
280
+ /**
281
+ * Convert a string to lower_snake_case.
282
+ */
283
+ export declare function toLowerSnake(s: string): string;
284
+ /**
285
+ * Convert a string to camelCase.
286
+ */
287
+ export declare function toCamelCase(s: string): string;
288
+ /**
289
+ * Convert a string to PascalCase.
290
+ */
291
+ export declare function toPascalCase(s: string): string;
292
+ /**
293
+ * Check if a schema is already compiled.
294
+ */
295
+ export declare function isCompiledStateSchema(schema: StateSchema | CompiledStateSchema): schema is CompiledStateSchema;
296
+ /**
297
+ * Compile a state schema if needed, or return it if already compiled.
298
+ * Also hydrates componentByName and eventByName Maps for Go-compiled schemas.
299
+ */
300
+ export declare function ensureCompiledStateSchema(schema: StateSchema | CompiledStateSchema): CompiledStateSchema;
301
+ /**
302
+ * Compile a state schema definition into a CompiledStateSchema with all layout offsets.
303
+ */
304
+ export declare function compileStateSchema(schema: StateSchema): CompiledStateSchema;
305
+ /**
306
+ * Compile an input schema definition into a CompiledInputSchema.
307
+ */
308
+ export declare function compileInputSchema(schema: InputSchema): CompiledInputSchema;
309
+ //# sourceMappingURL=schema.d.ts.map