@rb-games/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/README.md +488 -0
  2. package/dist/devtools/DraggableController.d.ts +10 -0
  3. package/dist/devtools/DraggableController.d.ts.map +1 -0
  4. package/dist/devtools/ResizableController.d.ts +19 -0
  5. package/dist/devtools/ResizableController.d.ts.map +1 -0
  6. package/dist/devtools/index.d.ts +7 -0
  7. package/dist/devtools/index.d.ts.map +1 -0
  8. package/dist/devtools/index.js +884 -0
  9. package/dist/devtools/index.js.map +1 -0
  10. package/dist/devtools/overlayPlugin.d.ts +3 -0
  11. package/dist/devtools/overlayPlugin.d.ts.map +1 -0
  12. package/dist/devtools/spinePropertiesPlugin.d.ts +3 -0
  13. package/dist/devtools/spinePropertiesPlugin.d.ts.map +1 -0
  14. package/dist/devtools/spriteTextPropertiesPlugin.d.ts +3 -0
  15. package/dist/devtools/spriteTextPropertiesPlugin.d.ts.map +1 -0
  16. package/dist/devtools/treePlugin.d.ts +7 -0
  17. package/dist/devtools/treePlugin.d.ts.map +1 -0
  18. package/dist/engine/PixiEngine.d.ts +404 -0
  19. package/dist/engine/PixiEngine.d.ts.map +1 -0
  20. package/dist/engine/index.d.ts +2 -0
  21. package/dist/engine/index.d.ts.map +1 -0
  22. package/dist/engine/index.js +1818 -0
  23. package/dist/engine/index.js.map +1 -0
  24. package/dist/filters/ChromaKeyFilter.d.ts +64 -0
  25. package/dist/filters/ChromaKeyFilter.d.ts.map +1 -0
  26. package/dist/filters/index.d.ts +2 -0
  27. package/dist/filters/index.d.ts.map +1 -0
  28. package/dist/filters/index.js +248 -0
  29. package/dist/filters/index.js.map +1 -0
  30. package/dist/helpers/AssetHelper.d.ts +117 -0
  31. package/dist/helpers/AssetHelper.d.ts.map +1 -0
  32. package/dist/helpers/SVGAssetHelper.d.ts +397 -0
  33. package/dist/helpers/SVGAssetHelper.d.ts.map +1 -0
  34. package/dist/helpers/SVGLoader.d.ts +46 -0
  35. package/dist/helpers/SVGLoader.d.ts.map +1 -0
  36. package/dist/helpers/SVGParser.d.ts +121 -0
  37. package/dist/helpers/SVGParser.d.ts.map +1 -0
  38. package/dist/helpers/eventBridge.d.ts +150 -0
  39. package/dist/helpers/eventBridge.d.ts.map +1 -0
  40. package/dist/helpers/index.d.ts +8 -0
  41. package/dist/helpers/index.d.ts.map +1 -0
  42. package/dist/helpers/index.js +702 -0
  43. package/dist/helpers/index.js.map +1 -0
  44. package/dist/helpers/mergeUtils.d.ts +21 -0
  45. package/dist/helpers/mergeUtils.d.ts.map +1 -0
  46. package/dist/helpers/resolvePublicPath.d.ts +6 -0
  47. package/dist/helpers/resolvePublicPath.d.ts.map +1 -0
  48. package/dist/i18n/index.d.ts +2 -0
  49. package/dist/i18n/index.d.ts.map +1 -0
  50. package/dist/i18n/index.js +527 -0
  51. package/dist/i18n/index.js.map +1 -0
  52. package/dist/i18n/sharedI18n.d.ts +11 -0
  53. package/dist/i18n/sharedI18n.d.ts.map +1 -0
  54. package/dist/layout/Align.d.ts +126 -0
  55. package/dist/layout/Align.d.ts.map +1 -0
  56. package/dist/layout/Bounds.d.ts +120 -0
  57. package/dist/layout/Bounds.d.ts.map +1 -0
  58. package/dist/layout/Distribute.d.ts +103 -0
  59. package/dist/layout/Distribute.d.ts.map +1 -0
  60. package/dist/layout/Flow.d.ts +213 -0
  61. package/dist/layout/Flow.d.ts.map +1 -0
  62. package/dist/layout/PositionUtils.d.ts +57 -0
  63. package/dist/layout/PositionUtils.d.ts.map +1 -0
  64. package/dist/layout/index.d.ts +6 -0
  65. package/dist/layout/index.d.ts.map +1 -0
  66. package/dist/layout/index.js +673 -0
  67. package/dist/layout/index.js.map +1 -0
  68. package/dist/particle/Emitter.d.ts +290 -0
  69. package/dist/particle/Emitter.d.ts.map +1 -0
  70. package/dist/particle/EmitterConfig.d.ts +228 -0
  71. package/dist/particle/EmitterConfig.d.ts.map +1 -0
  72. package/dist/particle/LinkedListContainer.d.ts +7 -0
  73. package/dist/particle/LinkedListContainer.d.ts.map +1 -0
  74. package/dist/particle/Particle.d.ts +63 -0
  75. package/dist/particle/Particle.d.ts.map +1 -0
  76. package/dist/particle/ParticleUtils.d.ts +97 -0
  77. package/dist/particle/ParticleUtils.d.ts.map +1 -0
  78. package/dist/particle/PropertyList.d.ts +40 -0
  79. package/dist/particle/PropertyList.d.ts.map +1 -0
  80. package/dist/particle/PropertyNode.d.ts +74 -0
  81. package/dist/particle/PropertyNode.d.ts.map +1 -0
  82. package/dist/particle/SpineEmitter.d.ts +55 -0
  83. package/dist/particle/SpineEmitter.d.ts.map +1 -0
  84. package/dist/particle/SpineParticle.d.ts +74 -0
  85. package/dist/particle/SpineParticle.d.ts.map +1 -0
  86. package/dist/particle/behaviors/AccelerationMovement.d.ts +62 -0
  87. package/dist/particle/behaviors/AccelerationMovement.d.ts.map +1 -0
  88. package/dist/particle/behaviors/Alpha.d.ts +60 -0
  89. package/dist/particle/behaviors/Alpha.d.ts.map +1 -0
  90. package/dist/particle/behaviors/AnimatedTexture.d.ts +111 -0
  91. package/dist/particle/behaviors/AnimatedTexture.d.ts.map +1 -0
  92. package/dist/particle/behaviors/Behaviors.d.ts +71 -0
  93. package/dist/particle/behaviors/Behaviors.d.ts.map +1 -0
  94. package/dist/particle/behaviors/BlendMode.d.ts +31 -0
  95. package/dist/particle/behaviors/BlendMode.d.ts.map +1 -0
  96. package/dist/particle/behaviors/BurstSpawn.d.ts +43 -0
  97. package/dist/particle/behaviors/BurstSpawn.d.ts.map +1 -0
  98. package/dist/particle/behaviors/Color.d.ts +60 -0
  99. package/dist/particle/behaviors/Color.d.ts.map +1 -0
  100. package/dist/particle/behaviors/MultiStateAnimatedTexture.d.ts +99 -0
  101. package/dist/particle/behaviors/MultiStateAnimatedTexture.d.ts.map +1 -0
  102. package/dist/particle/behaviors/OrderedTexture.d.ts +33 -0
  103. package/dist/particle/behaviors/OrderedTexture.d.ts.map +1 -0
  104. package/dist/particle/behaviors/PathMovement.d.ts +68 -0
  105. package/dist/particle/behaviors/PathMovement.d.ts.map +1 -0
  106. package/dist/particle/behaviors/PointSpawn.d.ts +21 -0
  107. package/dist/particle/behaviors/PointSpawn.d.ts.map +1 -0
  108. package/dist/particle/behaviors/RandomColor.d.ts +17 -0
  109. package/dist/particle/behaviors/RandomColor.d.ts.map +1 -0
  110. package/dist/particle/behaviors/RandomTexture.d.ts +32 -0
  111. package/dist/particle/behaviors/RandomTexture.d.ts.map +1 -0
  112. package/dist/particle/behaviors/Rotation.d.ts +114 -0
  113. package/dist/particle/behaviors/Rotation.d.ts.map +1 -0
  114. package/dist/particle/behaviors/Scale.d.ts +74 -0
  115. package/dist/particle/behaviors/Scale.d.ts.map +1 -0
  116. package/dist/particle/behaviors/ShapeSpawn.d.ts +58 -0
  117. package/dist/particle/behaviors/ShapeSpawn.d.ts.map +1 -0
  118. package/dist/particle/behaviors/SingleTexture.d.ts +32 -0
  119. package/dist/particle/behaviors/SingleTexture.d.ts.map +1 -0
  120. package/dist/particle/behaviors/SpeedMovement.d.ts +76 -0
  121. package/dist/particle/behaviors/SpeedMovement.d.ts.map +1 -0
  122. package/dist/particle/behaviors/SpineTexture.d.ts +173 -0
  123. package/dist/particle/behaviors/SpineTexture.d.ts.map +1 -0
  124. package/dist/particle/behaviors/ZindexBehavior.d.ts +16 -0
  125. package/dist/particle/behaviors/ZindexBehavior.d.ts.map +1 -0
  126. package/dist/particle/behaviors/editor/Types.d.ts +104 -0
  127. package/dist/particle/behaviors/editor/Types.d.ts.map +1 -0
  128. package/dist/particle/behaviors/editor/behaviors/AccelerationMovement.d.ts +2 -0
  129. package/dist/particle/behaviors/editor/behaviors/AccelerationMovement.d.ts.map +1 -0
  130. package/dist/particle/behaviors/editor/behaviors/Alpha.d.ts +2 -0
  131. package/dist/particle/behaviors/editor/behaviors/Alpha.d.ts.map +1 -0
  132. package/dist/particle/behaviors/editor/behaviors/AnimatedTexture.d.ts +2 -0
  133. package/dist/particle/behaviors/editor/behaviors/AnimatedTexture.d.ts.map +1 -0
  134. package/dist/particle/behaviors/editor/behaviors/BlendMode.d.ts +2 -0
  135. package/dist/particle/behaviors/editor/behaviors/BlendMode.d.ts.map +1 -0
  136. package/dist/particle/behaviors/editor/behaviors/BurstSpawn.d.ts +2 -0
  137. package/dist/particle/behaviors/editor/behaviors/BurstSpawn.d.ts.map +1 -0
  138. package/dist/particle/behaviors/editor/behaviors/Color.d.ts +2 -0
  139. package/dist/particle/behaviors/editor/behaviors/Color.d.ts.map +1 -0
  140. package/dist/particle/behaviors/editor/behaviors/OrderedTexture.d.ts +2 -0
  141. package/dist/particle/behaviors/editor/behaviors/OrderedTexture.d.ts.map +1 -0
  142. package/dist/particle/behaviors/editor/behaviors/PathMovement.d.ts +2 -0
  143. package/dist/particle/behaviors/editor/behaviors/PathMovement.d.ts.map +1 -0
  144. package/dist/particle/behaviors/editor/behaviors/PointSpawn.d.ts +2 -0
  145. package/dist/particle/behaviors/editor/behaviors/PointSpawn.d.ts.map +1 -0
  146. package/dist/particle/behaviors/editor/behaviors/RandomTexture.d.ts +2 -0
  147. package/dist/particle/behaviors/editor/behaviors/RandomTexture.d.ts.map +1 -0
  148. package/dist/particle/behaviors/editor/behaviors/Rotation.d.ts +2 -0
  149. package/dist/particle/behaviors/editor/behaviors/Rotation.d.ts.map +1 -0
  150. package/dist/particle/behaviors/editor/behaviors/Scale.d.ts +2 -0
  151. package/dist/particle/behaviors/editor/behaviors/Scale.d.ts.map +1 -0
  152. package/dist/particle/behaviors/editor/behaviors/ShapeSpawn.d.ts +2 -0
  153. package/dist/particle/behaviors/editor/behaviors/ShapeSpawn.d.ts.map +1 -0
  154. package/dist/particle/behaviors/editor/behaviors/SingleTexture.d.ts +2 -0
  155. package/dist/particle/behaviors/editor/behaviors/SingleTexture.d.ts.map +1 -0
  156. package/dist/particle/behaviors/editor/behaviors/SpeedMovement.d.ts +2 -0
  157. package/dist/particle/behaviors/editor/behaviors/SpeedMovement.d.ts.map +1 -0
  158. package/dist/particle/behaviors/editor/behaviors/index.d.ts +15 -0
  159. package/dist/particle/behaviors/editor/behaviors/index.d.ts.map +1 -0
  160. package/dist/particle/behaviors/editor/index.d.ts +5 -0
  161. package/dist/particle/behaviors/editor/index.d.ts.map +1 -0
  162. package/dist/particle/behaviors/editor/shapes/PolygonalChain.d.ts +2 -0
  163. package/dist/particle/behaviors/editor/shapes/PolygonalChain.d.ts.map +1 -0
  164. package/dist/particle/behaviors/editor/shapes/Rectangle.d.ts +2 -0
  165. package/dist/particle/behaviors/editor/shapes/Rectangle.d.ts.map +1 -0
  166. package/dist/particle/behaviors/editor/shapes/Torus.d.ts +2 -0
  167. package/dist/particle/behaviors/editor/shapes/Torus.d.ts.map +1 -0
  168. package/dist/particle/behaviors/index.d.ts +25 -0
  169. package/dist/particle/behaviors/index.d.ts.map +1 -0
  170. package/dist/particle/behaviors/shapes/PolygonalChain.d.ts +57 -0
  171. package/dist/particle/behaviors/shapes/PolygonalChain.d.ts.map +1 -0
  172. package/dist/particle/behaviors/shapes/Rectangle.d.ts +59 -0
  173. package/dist/particle/behaviors/shapes/Rectangle.d.ts.map +1 -0
  174. package/dist/particle/behaviors/shapes/SpawnShape.d.ts +32 -0
  175. package/dist/particle/behaviors/shapes/SpawnShape.d.ts.map +1 -0
  176. package/dist/particle/behaviors/shapes/Torus.d.ts +71 -0
  177. package/dist/particle/behaviors/shapes/Torus.d.ts.map +1 -0
  178. package/dist/particle/behaviors/shapes/index.d.ts +5 -0
  179. package/dist/particle/behaviors/shapes/index.d.ts.map +1 -0
  180. package/dist/particle/index.d.ts +11 -0
  181. package/dist/particle/index.d.ts.map +1 -0
  182. package/dist/particle/index.js +2845 -0
  183. package/dist/particle/index.js.map +1 -0
  184. package/dist/plugins/Plugin.types.d.ts +80 -0
  185. package/dist/plugins/Plugin.types.d.ts.map +1 -0
  186. package/dist/plugins/device/DeviceOptimizerPlugin.d.ts +187 -0
  187. package/dist/plugins/device/DeviceOptimizerPlugin.d.ts.map +1 -0
  188. package/dist/plugins/device/DeviceOptimizerPlugin.types.d.ts +134 -0
  189. package/dist/plugins/device/DeviceOptimizerPlugin.types.d.ts.map +1 -0
  190. package/dist/plugins/device/index.d.ts +3 -0
  191. package/dist/plugins/device/index.d.ts.map +1 -0
  192. package/dist/plugins/display/DisplayPlugin.d.ts +208 -0
  193. package/dist/plugins/display/DisplayPlugin.d.ts.map +1 -0
  194. package/dist/plugins/display/DisplayPlugin.types.d.ts +174 -0
  195. package/dist/plugins/display/DisplayPlugin.types.d.ts.map +1 -0
  196. package/dist/plugins/display/displayViewport.d.ts +10 -0
  197. package/dist/plugins/display/displayViewport.d.ts.map +1 -0
  198. package/dist/plugins/display/index.d.ts +4 -0
  199. package/dist/plugins/display/index.d.ts.map +1 -0
  200. package/dist/plugins/eventbus/EventBusPlugin.d.ts +21 -0
  201. package/dist/plugins/eventbus/EventBusPlugin.d.ts.map +1 -0
  202. package/dist/plugins/eventbus/EventBusPlugin.types.d.ts +24 -0
  203. package/dist/plugins/eventbus/EventBusPlugin.types.d.ts.map +1 -0
  204. package/dist/plugins/eventbus/index.d.ts +3 -0
  205. package/dist/plugins/eventbus/index.d.ts.map +1 -0
  206. package/dist/plugins/gsap/GsapPlugin.d.ts +307 -0
  207. package/dist/plugins/gsap/GsapPlugin.d.ts.map +1 -0
  208. package/dist/plugins/gsap/index.d.ts +2 -0
  209. package/dist/plugins/gsap/index.d.ts.map +1 -0
  210. package/dist/plugins/index.d.ts +13 -0
  211. package/dist/plugins/index.d.ts.map +1 -0
  212. package/dist/plugins/index.js +12806 -0
  213. package/dist/plugins/index.js.map +1 -0
  214. package/dist/plugins/input/InputPlugin.const.d.ts +80 -0
  215. package/dist/plugins/input/InputPlugin.const.d.ts.map +1 -0
  216. package/dist/plugins/input/InputPlugin.d.ts +141 -0
  217. package/dist/plugins/input/InputPlugin.d.ts.map +1 -0
  218. package/dist/plugins/input/InputPlugin.types.d.ts +41 -0
  219. package/dist/plugins/input/InputPlugin.types.d.ts.map +1 -0
  220. package/dist/plugins/input/KeyboardManager.d.ts +139 -0
  221. package/dist/plugins/input/KeyboardManager.d.ts.map +1 -0
  222. package/dist/plugins/input/KeyboardManager.types.d.ts +27 -0
  223. package/dist/plugins/input/KeyboardManager.types.d.ts.map +1 -0
  224. package/dist/plugins/input/index.d.ts +4 -0
  225. package/dist/plugins/input/index.d.ts.map +1 -0
  226. package/dist/plugins/language/I18NextPlugin.d.ts +30 -0
  227. package/dist/plugins/language/I18NextPlugin.d.ts.map +1 -0
  228. package/dist/plugins/language/I18NextPlugin.types.d.ts +29 -0
  229. package/dist/plugins/language/I18NextPlugin.types.d.ts.map +1 -0
  230. package/dist/plugins/language/index.d.ts +3 -0
  231. package/dist/plugins/language/index.d.ts.map +1 -0
  232. package/dist/plugins/resource/ResourcePlugin.d.ts +189 -0
  233. package/dist/plugins/resource/ResourcePlugin.d.ts.map +1 -0
  234. package/dist/plugins/resource/ResourcePlugin.types.d.ts +153 -0
  235. package/dist/plugins/resource/ResourcePlugin.types.d.ts.map +1 -0
  236. package/dist/plugins/resource/index.d.ts +3 -0
  237. package/dist/plugins/resource/index.d.ts.map +1 -0
  238. package/dist/plugins/scene/Scene.d.ts +203 -0
  239. package/dist/plugins/scene/Scene.d.ts.map +1 -0
  240. package/dist/plugins/scene/ScenePlugin.d.ts +162 -0
  241. package/dist/plugins/scene/ScenePlugin.d.ts.map +1 -0
  242. package/dist/plugins/scene/ScenePlugin.types.d.ts +35 -0
  243. package/dist/plugins/scene/ScenePlugin.types.d.ts.map +1 -0
  244. package/dist/plugins/scene/index.d.ts +4 -0
  245. package/dist/plugins/scene/index.d.ts.map +1 -0
  246. package/dist/plugins/sentry/SentryPlugin.d.ts +66 -0
  247. package/dist/plugins/sentry/SentryPlugin.d.ts.map +1 -0
  248. package/dist/plugins/sentry/SentryPlugin.types.d.ts +8 -0
  249. package/dist/plugins/sentry/SentryPlugin.types.d.ts.map +1 -0
  250. package/dist/plugins/sentry/index.d.ts +3 -0
  251. package/dist/plugins/sentry/index.d.ts.map +1 -0
  252. package/dist/plugins/service/ServiceAdapter.d.ts +88 -0
  253. package/dist/plugins/service/ServiceAdapter.d.ts.map +1 -0
  254. package/dist/plugins/service/ServiceEventHelper.d.ts +6 -0
  255. package/dist/plugins/service/ServiceEventHelper.d.ts.map +1 -0
  256. package/dist/plugins/service/ServicePlugin.d.ts +135 -0
  257. package/dist/plugins/service/ServicePlugin.d.ts.map +1 -0
  258. package/dist/plugins/service/ServicePlugin.types.d.ts +14 -0
  259. package/dist/plugins/service/ServicePlugin.types.d.ts.map +1 -0
  260. package/dist/plugins/service/adapters/DevAuthAdapter.d.ts +56 -0
  261. package/dist/plugins/service/adapters/DevAuthAdapter.d.ts.map +1 -0
  262. package/dist/plugins/service/adapters/RGSAdapter.d.ts +82 -0
  263. package/dist/plugins/service/adapters/RGSAdapter.d.ts.map +1 -0
  264. package/dist/plugins/service/adapters/index.d.ts +7 -0
  265. package/dist/plugins/service/adapters/index.d.ts.map +1 -0
  266. package/dist/plugins/service/adapters/resolvePublicIp.d.ts +10 -0
  267. package/dist/plugins/service/adapters/resolvePublicIp.d.ts.map +1 -0
  268. package/dist/plugins/service/index.d.ts +10 -0
  269. package/dist/plugins/service/index.d.ts.map +1 -0
  270. package/dist/plugins/service/types/api.types.d.ts +299 -0
  271. package/dist/plugins/service/types/api.types.d.ts.map +1 -0
  272. package/dist/plugins/service/types/index.d.ts +6 -0
  273. package/dist/plugins/service/types/index.d.ts.map +1 -0
  274. package/dist/plugins/skin/ISkin.d.ts +62 -0
  275. package/dist/plugins/skin/ISkin.d.ts.map +1 -0
  276. package/dist/plugins/skin/Skin.d.ts +155 -0
  277. package/dist/plugins/skin/Skin.d.ts.map +1 -0
  278. package/dist/plugins/skin/SkinPlugin.d.ts +285 -0
  279. package/dist/plugins/skin/SkinPlugin.d.ts.map +1 -0
  280. package/dist/plugins/skin/SkinPlugin.types.d.ts +56 -0
  281. package/dist/plugins/skin/SkinPlugin.types.d.ts.map +1 -0
  282. package/dist/plugins/skin/index.d.ts +5 -0
  283. package/dist/plugins/skin/index.d.ts.map +1 -0
  284. package/dist/plugins/sound/SoundPlugin.d.ts +319 -0
  285. package/dist/plugins/sound/SoundPlugin.d.ts.map +1 -0
  286. package/dist/plugins/sound/SoundPlugin.types.d.ts +102 -0
  287. package/dist/plugins/sound/SoundPlugin.types.d.ts.map +1 -0
  288. package/dist/plugins/sound/SoundTestGUI.d.ts +42 -0
  289. package/dist/plugins/sound/SoundTestGUI.d.ts.map +1 -0
  290. package/dist/plugins/sound/index.d.ts +4 -0
  291. package/dist/plugins/sound/index.d.ts.map +1 -0
  292. package/dist/state-machine/ConfigBuilder.d.ts +239 -0
  293. package/dist/state-machine/ConfigBuilder.d.ts.map +1 -0
  294. package/dist/state-machine/StateMachine.d.ts +251 -0
  295. package/dist/state-machine/StateMachine.d.ts.map +1 -0
  296. package/dist/state-machine/guards.d.ts +151 -0
  297. package/dist/state-machine/guards.d.ts.map +1 -0
  298. package/dist/state-machine/index.d.ts +5 -0
  299. package/dist/state-machine/index.d.ts.map +1 -0
  300. package/dist/state-machine/index.js +954 -0
  301. package/dist/state-machine/index.js.map +1 -0
  302. package/dist/state-machine/types.d.ts +65 -0
  303. package/dist/state-machine/types.d.ts.map +1 -0
  304. package/dist/store/DataStore.d.ts +167 -0
  305. package/dist/store/DataStore.d.ts.map +1 -0
  306. package/dist/store/index.d.ts +3 -0
  307. package/dist/store/index.d.ts.map +1 -0
  308. package/dist/store/index.js +197 -0
  309. package/dist/store/index.js.map +1 -0
  310. package/dist/ui/behaviors/ButtonBehavior.d.ts +245 -0
  311. package/dist/ui/behaviors/ButtonBehavior.d.ts.map +1 -0
  312. package/dist/ui/behaviors/InputBehavior.d.ts +169 -0
  313. package/dist/ui/behaviors/InputBehavior.d.ts.map +1 -0
  314. package/dist/ui/behaviors/ScrollbarBehavior.d.ts +371 -0
  315. package/dist/ui/behaviors/ScrollbarBehavior.d.ts.map +1 -0
  316. package/dist/ui/behaviors/index.d.ts +4 -0
  317. package/dist/ui/behaviors/index.d.ts.map +1 -0
  318. package/dist/ui/components/ButtonComp.d.ts +138 -0
  319. package/dist/ui/components/ButtonComp.d.ts.map +1 -0
  320. package/dist/ui/components/Comp.utils.d.ts +390 -0
  321. package/dist/ui/components/Comp.utils.d.ts.map +1 -0
  322. package/dist/ui/components/Component.types.d.ts +41 -0
  323. package/dist/ui/components/Component.types.d.ts.map +1 -0
  324. package/dist/ui/components/InputComp.d.ts +43 -0
  325. package/dist/ui/components/InputComp.d.ts.map +1 -0
  326. package/dist/ui/components/LabelBox.d.ts +49 -0
  327. package/dist/ui/components/LabelBox.d.ts.map +1 -0
  328. package/dist/ui/components/ListTableComp.d.ts +106 -0
  329. package/dist/ui/components/ListTableComp.d.ts.map +1 -0
  330. package/dist/ui/components/Skinable.d.ts +261 -0
  331. package/dist/ui/components/Skinable.d.ts.map +1 -0
  332. package/dist/ui/components/SliderComp.d.ts +60 -0
  333. package/dist/ui/components/SliderComp.d.ts.map +1 -0
  334. package/dist/ui/components/SpriteTextBBCode.d.ts +16 -0
  335. package/dist/ui/components/SpriteTextBBCode.d.ts.map +1 -0
  336. package/dist/ui/components/StepperComp.d.ts +89 -0
  337. package/dist/ui/components/StepperComp.d.ts.map +1 -0
  338. package/dist/ui/components/index.d.ts +12 -0
  339. package/dist/ui/components/index.d.ts.map +1 -0
  340. package/dist/ui/components/spriteText/SpriteText.d.ts +114 -0
  341. package/dist/ui/components/spriteText/SpriteText.d.ts.map +1 -0
  342. package/dist/ui/components/spriteText/SpriteText.types.d.ts +109 -0
  343. package/dist/ui/components/spriteText/SpriteText.types.d.ts.map +1 -0
  344. package/dist/ui/components/spriteText/SpriteTextAlignment.d.ts +25 -0
  345. package/dist/ui/components/spriteText/SpriteTextAlignment.d.ts.map +1 -0
  346. package/dist/ui/components/spriteText/SpriteTextBezier.d.ts +20 -0
  347. package/dist/ui/components/spriteText/SpriteTextBezier.d.ts.map +1 -0
  348. package/dist/ui/components/spriteText/SpriteTextCurve.d.ts +4 -0
  349. package/dist/ui/components/spriteText/SpriteTextCurve.d.ts.map +1 -0
  350. package/dist/ui/components/spriteText/SpriteTextKerning.d.ts +7 -0
  351. package/dist/ui/components/spriteText/SpriteTextKerning.d.ts.map +1 -0
  352. package/dist/ui/components/spriteText/SpriteTextTexture.d.ts +16 -0
  353. package/dist/ui/components/spriteText/SpriteTextTexture.d.ts.map +1 -0
  354. package/dist/ui/components/spriteText/SpriteTextWrap.d.ts +19 -0
  355. package/dist/ui/components/spriteText/SpriteTextWrap.d.ts.map +1 -0
  356. package/dist/ui/components/spriteText/index.d.ts +3 -0
  357. package/dist/ui/components/spriteText/index.d.ts.map +1 -0
  358. package/dist/ui/index.d.ts +3 -0
  359. package/dist/ui/index.d.ts.map +1 -0
  360. package/dist/ui/index.js +4778 -0
  361. package/dist/ui/index.js.map +1 -0
  362. package/dist/utils/ArrayUtils.d.ts +24 -0
  363. package/dist/utils/ArrayUtils.d.ts.map +1 -0
  364. package/dist/utils/ColorUtils.d.ts +34 -0
  365. package/dist/utils/ColorUtils.d.ts.map +1 -0
  366. package/dist/utils/DataInjector.d.ts +67 -0
  367. package/dist/utils/DataInjector.d.ts.map +1 -0
  368. package/dist/utils/Logger.d.ts +332 -0
  369. package/dist/utils/Logger.d.ts.map +1 -0
  370. package/dist/utils/NumberFormatter.d.ts +126 -0
  371. package/dist/utils/NumberFormatter.d.ts.map +1 -0
  372. package/dist/utils/ObjectUtils.d.ts +64 -0
  373. package/dist/utils/ObjectUtils.d.ts.map +1 -0
  374. package/dist/utils/PixiUtils.d.ts +118 -0
  375. package/dist/utils/PixiUtils.d.ts.map +1 -0
  376. package/dist/utils/Throttle.d.ts +103 -0
  377. package/dist/utils/Throttle.d.ts.map +1 -0
  378. package/dist/utils/index.d.ts +9 -0
  379. package/dist/utils/index.d.ts.map +1 -0
  380. package/dist/utils/index.js +899 -0
  381. package/dist/utils/index.js.map +1 -0
  382. package/dist/vite/index.d.ts +3 -0
  383. package/dist/vite/index.d.ts.map +1 -0
  384. package/dist/vite/index.js +126 -0
  385. package/dist/vite/index.js.map +1 -0
  386. package/dist/vite/mergeLocalesPlugin.d.ts +22 -0
  387. package/dist/vite/mergeLocalesPlugin.d.ts.map +1 -0
  388. package/package.json +143 -0
@@ -0,0 +1,954 @@
1
+ import { EventEmitter } from 'pixi.js';
2
+ import merge from 'lodash/merge';
3
+
4
+ // state-machine/StateMachine.ts
5
+ var StateMachine = class extends EventEmitter {
6
+ config;
7
+ context;
8
+ isTransitioning = false;
9
+ resolvedStateCache = /* @__PURE__ */ new Map();
10
+ constructor(config) {
11
+ super();
12
+ this.config = config;
13
+ if (!this.config.modes[this.config.initialMode]) {
14
+ throw new Error(`Initial mode "${this.config.initialMode}" not found in config`);
15
+ }
16
+ const initialMode = this.config.modes[this.config.initialMode];
17
+ if (!initialMode.states[this.config.initialState]) {
18
+ throw new Error(
19
+ `Initial state "${this.config.initialState}" not found in mode "${this.config.initialMode}"`
20
+ );
21
+ }
22
+ this.context = {
23
+ currentState: this.config.initialState,
24
+ previousState: null,
25
+ currentMode: this.config.initialMode,
26
+ previousMode: null,
27
+ timestamp: Date.now(),
28
+ data: this.config.initialData ?? {},
29
+ metadata: {}
30
+ };
31
+ }
32
+ /**
33
+ * Current state key (e.g., 'IDLE', 'SPIN', 'MATCH')
34
+ */
35
+ get state() {
36
+ return this.context.currentState;
37
+ }
38
+ /**
39
+ * Current mode key (e.g., 'NORMAL', 'FREESPIN', 'BONUS')
40
+ */
41
+ get mode() {
42
+ return this.context.currentMode;
43
+ }
44
+ /**
45
+ * Current state data (mutable)
46
+ */
47
+ get data() {
48
+ return this.context.data;
49
+ }
50
+ /**
51
+ * Get a readonly copy of the current state context
52
+ *
53
+ * @returns Readonly state context with current state, mode, data, and metadata
54
+ */
55
+ getContext() {
56
+ return { ...this.context };
57
+ }
58
+ /**
59
+ * Update state data using an updater function
60
+ *
61
+ * @param updater - Function that receives current data and optionally returns new data
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * machine.updateData(data => {
66
+ * data.balance = 1000;
67
+ * data.bet = 10;
68
+ * });
69
+ * ```
70
+ */
71
+ updateData(updater) {
72
+ const result = updater(this.context.data);
73
+ if (result !== void 0) {
74
+ this.context.data = result;
75
+ }
76
+ }
77
+ resolveStateDefinition(state, mode) {
78
+ const modeKey = mode ?? this.context.currentMode;
79
+ const cacheKey = `${modeKey}:${state}`;
80
+ if (this.resolvedStateCache.has(cacheKey)) {
81
+ return this.resolvedStateCache.get(cacheKey);
82
+ }
83
+ const currentMode = this.config.modes[modeKey];
84
+ const stateDef = currentMode.states[state];
85
+ if (!stateDef) {
86
+ throw new Error(`State "${state}" not found in mode "${modeKey}"`);
87
+ }
88
+ if (!stateDef.extends) {
89
+ this.resolvedStateCache.set(cacheKey, stateDef);
90
+ return stateDef;
91
+ }
92
+ const chain = [];
93
+ const visited = /* @__PURE__ */ new Set();
94
+ let current = stateDef;
95
+ let currentKey = state;
96
+ while (current) {
97
+ if (visited.has(currentKey)) {
98
+ throw new Error(`Circular extends detected in state "${state}"`);
99
+ }
100
+ visited.add(currentKey);
101
+ chain.unshift(current);
102
+ if (current.extends) {
103
+ const parentKey = current.extends;
104
+ const parent = currentMode.states[parentKey];
105
+ if (!parent) {
106
+ throw new Error(`Parent state "${parentKey}" not found for state "${state}"`);
107
+ }
108
+ current = parent;
109
+ currentKey = parentKey;
110
+ } else {
111
+ break;
112
+ }
113
+ }
114
+ const resolved = merge({}, ...chain);
115
+ delete resolved.extends;
116
+ resolved.guards = stateDef.guards;
117
+ resolved.onEnter = stateDef.onEnter;
118
+ resolved.onExit = stateDef.onExit;
119
+ this.resolvedStateCache.set(cacheKey, resolved);
120
+ return resolved;
121
+ }
122
+ resolveScopeData(scopeConfig) {
123
+ if (!scopeConfig) return {};
124
+ const resolved = {};
125
+ for (const [scopeName, scopeData] of Object.entries(scopeConfig)) {
126
+ resolved[scopeName] = {};
127
+ for (const [componentName, componentData] of Object.entries(scopeData)) {
128
+ resolved[scopeName][componentName] = {};
129
+ for (const [propName, propValue] of Object.entries(componentData)) {
130
+ resolved[scopeName][componentName][propName] = this.resolveValue(propValue);
131
+ }
132
+ }
133
+ }
134
+ return resolved;
135
+ }
136
+ resolveValue(value) {
137
+ if (typeof value === "function") {
138
+ return value(this.context);
139
+ }
140
+ return value;
141
+ }
142
+ /**
143
+ * Get resolved scope data for a specific scope
144
+ *
145
+ * @param scopeName - Name of the scope (e.g., 'ui', 'scene', 'audio')
146
+ * @returns Resolved scope data with all resolver functions evaluated
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * const uiState = machine.getScope('ui');
151
+ * console.log(uiState.spinButton.enabled); // true
152
+ * ```
153
+ */
154
+ getScope(scopeName) {
155
+ const resolvedState = this.resolveStateDefinition(this.context.currentState);
156
+ const scopeData = this.resolveScopeData(resolvedState.scopes);
157
+ return scopeData[scopeName] ?? {};
158
+ }
159
+ /**
160
+ * Get all resolved scope data for the current state
161
+ *
162
+ * @returns Object containing all scopes with resolved data
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const scopes = machine.getAllScopes();
167
+ * console.log(scopes.ui); // UI scope data
168
+ * console.log(scopes.scene); // Scene scope data
169
+ * ```
170
+ */
171
+ getAllScopes() {
172
+ const resolvedState = this.resolveStateDefinition(this.context.currentState);
173
+ return this.resolveScopeData(resolvedState.scopes);
174
+ }
175
+ /**
176
+ * Transition to a new state within the current mode
177
+ *
178
+ * This is an async operation that:
179
+ * 1. Checks guards (canExit, canEnter)
180
+ * 2. Calls onExit hook of current state
181
+ * 3. Changes the state
182
+ * 4. Calls onEnter hook of target state
183
+ * 5. Emits events (state:exit, state:enter, state:change, scope:update)
184
+ *
185
+ * @param targetState - Target state key to transition to
186
+ * @param options - Transition options
187
+ * @param options.force - Skip guard checks and force transition
188
+ * @param options.silent - Skip event emissions
189
+ * @returns Promise that resolves to true if transition succeeded, false otherwise
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * // Normal transition
194
+ * await machine.transition('SPIN');
195
+ *
196
+ * // Force transition (skip guards)
197
+ * await machine.transition('SPIN', { force: true });
198
+ *
199
+ * // Silent transition (no events)
200
+ * await machine.transition('SPIN', { silent: true });
201
+ * ```
202
+ *
203
+ * @fires state:exit - When exiting current state
204
+ * @fires state:enter - When entering target state
205
+ * @fires state:change - After state change completes
206
+ * @fires scope:update - For each scope after state change
207
+ * @fires transition:blocked - If guard check fails
208
+ * @fires error - If an error occurs during transition
209
+ */
210
+ async transition(targetState, options = {}) {
211
+ if (this.isTransitioning && !options.force) {
212
+ console.warn("Transition already in progress");
213
+ return false;
214
+ }
215
+ const fromState = this.context.currentState;
216
+ if (fromState === targetState) {
217
+ return true;
218
+ }
219
+ const currentMode = this.config.modes[this.context.currentMode];
220
+ if (!currentMode.states[targetState]) {
221
+ const error = new Error(
222
+ `State "${targetState}" not found in mode "${this.context.currentMode}"`
223
+ );
224
+ if (this.config.strict) {
225
+ throw error;
226
+ }
227
+ this.emit("error", error, this.context);
228
+ return false;
229
+ }
230
+ if (!options.force) {
231
+ const canTransition = await this.checkGuards(fromState, targetState);
232
+ if (!canTransition.allowed) {
233
+ this.emit(
234
+ "transition:blocked",
235
+ fromState,
236
+ targetState,
237
+ canTransition.reason || "Guard check failed",
238
+ this.context
239
+ );
240
+ return false;
241
+ }
242
+ }
243
+ this.isTransitioning = true;
244
+ try {
245
+ if (!options.silent) {
246
+ this.emit("transition:start", fromState, targetState, this.context);
247
+ }
248
+ const fromStateDef = this.resolveStateDefinition(fromState);
249
+ if (fromStateDef.onExit) {
250
+ await fromStateDef.onExit(this.context);
251
+ }
252
+ if (!options.silent) {
253
+ this.emit("state:exit", fromState, this.context);
254
+ }
255
+ const previousState = this.context.currentState;
256
+ this.context = {
257
+ ...this.context,
258
+ currentState: targetState,
259
+ previousState,
260
+ timestamp: Date.now()
261
+ };
262
+ const toStateDef = this.resolveStateDefinition(targetState);
263
+ if (toStateDef.onEnter) {
264
+ await toStateDef.onEnter(this.context);
265
+ }
266
+ if (!options.silent) {
267
+ this.emit("state:enter", targetState, this.context);
268
+ this.emit("state:change", fromState, targetState, this.context);
269
+ const scopes = this.getAllScopes();
270
+ for (const [scopeName, scopeData] of Object.entries(scopes)) {
271
+ this.emit("scope:update", scopeName, scopeData, this.context);
272
+ this.emit(`scope:update:${scopeName}`, scopeData, this.context);
273
+ }
274
+ this.emit("transition:complete", fromState, targetState, this.context);
275
+ }
276
+ return true;
277
+ } catch (error) {
278
+ this.emit("error", error, this.context);
279
+ return false;
280
+ } finally {
281
+ this.isTransitioning = false;
282
+ }
283
+ }
284
+ /**
285
+ * Change to a different mode with an optional initial state
286
+ *
287
+ * This will:
288
+ * 1. Call onExit hook of current mode
289
+ * 2. Clear state resolution cache
290
+ * 3. Change mode and state
291
+ * 4. Call onEnter hook of target mode
292
+ * 5. Call onEnter hook of initial state
293
+ * 6. Emit events
294
+ *
295
+ * @param targetMode - Target mode key to switch to
296
+ * @param initialState - Optional initial state in the target mode (defaults to config.initialState)
297
+ * @returns Promise that resolves to true if mode change succeeded, false otherwise
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * // Switch to freespin mode
302
+ * await machine.changeMode('FREESPIN', 'IDLE');
303
+ *
304
+ * // Return to normal mode
305
+ * await machine.changeMode('NORMAL', 'IDLE');
306
+ * ```
307
+ *
308
+ * @fires mode:exit - When exiting current mode
309
+ * @fires mode:enter - When entering target mode
310
+ * @fires mode:change - After mode change completes
311
+ * @fires state:enter - When entering initial state
312
+ * @fires scope:update - For each scope after mode change
313
+ */
314
+ async changeMode(targetMode, initialState) {
315
+ if (this.context.currentMode === targetMode) {
316
+ return true;
317
+ }
318
+ const targetModeDef = this.config.modes[targetMode];
319
+ if (!targetModeDef) {
320
+ const error = new Error(`Mode "${targetMode}" not found`);
321
+ if (this.config.strict) {
322
+ throw error;
323
+ }
324
+ this.emit("error", error, this.context);
325
+ return false;
326
+ }
327
+ const targetState = initialState ?? this.config.initialState;
328
+ if (!targetModeDef.states[targetState]) {
329
+ const error = new Error(`State "${targetState}" not found in mode "${targetMode}"`);
330
+ if (this.config.strict) {
331
+ throw error;
332
+ }
333
+ this.emit("error", error, this.context);
334
+ return false;
335
+ }
336
+ const fromMode = this.context.currentMode;
337
+ const currentModeDef = this.config.modes[fromMode];
338
+ try {
339
+ if (currentModeDef.onExit) {
340
+ await currentModeDef.onExit(this.context);
341
+ }
342
+ this.emit("mode:exit", fromMode, this.context);
343
+ this.resolvedStateCache.clear();
344
+ const previousMode = this.context.currentMode;
345
+ this.context = {
346
+ ...this.context,
347
+ currentMode: targetMode,
348
+ previousMode,
349
+ currentState: targetState,
350
+ previousState: this.context.currentState,
351
+ timestamp: Date.now()
352
+ };
353
+ if (targetModeDef.onEnter) {
354
+ await targetModeDef.onEnter(this.context);
355
+ }
356
+ this.emit("mode:enter", targetMode, this.context);
357
+ this.emit("mode:change", fromMode, targetMode, this.context);
358
+ const toStateDef = this.resolveStateDefinition(targetState);
359
+ if (toStateDef.onEnter) {
360
+ await toStateDef.onEnter(this.context);
361
+ }
362
+ this.emit("state:enter", targetState, this.context);
363
+ const scopes = this.getAllScopes();
364
+ for (const [scopeName, scopeData] of Object.entries(scopes)) {
365
+ this.emit("scope:update", scopeName, scopeData, this.context);
366
+ this.emit(`scope:update:${scopeName}`, scopeData, this.context);
367
+ }
368
+ return true;
369
+ } catch (error) {
370
+ this.emit("error", error, this.context);
371
+ return false;
372
+ }
373
+ }
374
+ /**
375
+ * Check if a state exists in the current mode (synchronous, no guard check)
376
+ *
377
+ * @param targetState - State key to check
378
+ * @returns True if state exists in current mode, false otherwise
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * if (machine.can('SPIN')) {
383
+ * console.log('SPIN state exists');
384
+ * }
385
+ * ```
386
+ */
387
+ can(targetState) {
388
+ const currentMode = this.config.modes[this.context.currentMode];
389
+ return !!(currentMode == null ? void 0 : currentMode.states[targetState]);
390
+ }
391
+ /**
392
+ * Check if transition to a state is allowed (async, includes guard check)
393
+ *
394
+ * @param targetState - State key to check
395
+ * @returns Promise that resolves to true if transition is allowed, false otherwise
396
+ *
397
+ * @example
398
+ * ```typescript
399
+ * if (await machine.canAsync('SPIN')) {
400
+ * await machine.transition('SPIN');
401
+ * } else {
402
+ * console.log('Cannot transition to SPIN');
403
+ * }
404
+ * ```
405
+ */
406
+ async canAsync(targetState) {
407
+ const result = await this.checkGuards(this.context.currentState, targetState);
408
+ return result.allowed;
409
+ }
410
+ async checkGuards(fromState, toState) {
411
+ var _a, _b;
412
+ const fromStateDef = this.resolveStateDefinition(fromState);
413
+ const toStateDef = this.resolveStateDefinition(toState);
414
+ if ((_a = fromStateDef.guards) == null ? void 0 : _a.canExit) {
415
+ const canExit = await fromStateDef.guards.canExit(this.context);
416
+ if (!canExit) {
417
+ return { allowed: false, reason: `Cannot exit state "${fromState}"` };
418
+ }
419
+ }
420
+ if ((_b = toStateDef.guards) == null ? void 0 : _b.canEnter) {
421
+ const canEnter = await toStateDef.guards.canEnter(this.context);
422
+ if (!canEnter) {
423
+ return { allowed: false, reason: `Cannot enter state "${toState}"` };
424
+ }
425
+ }
426
+ return { allowed: true };
427
+ }
428
+ /**
429
+ * Check if current state matches the given state key
430
+ *
431
+ * @param state - State key to compare
432
+ * @returns True if current state matches, false otherwise
433
+ *
434
+ * @example
435
+ * ```typescript
436
+ * if (machine.is('SPIN')) {
437
+ * console.log('Currently spinning');
438
+ * }
439
+ * ```
440
+ */
441
+ is(state) {
442
+ return this.context.currentState === state;
443
+ }
444
+ /**
445
+ * Check if current mode matches the given mode key
446
+ *
447
+ * @param mode - Mode key to compare
448
+ * @returns True if current mode matches, false otherwise
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * if (machine.isMode('FREESPIN')) {
453
+ * console.log('In freespin mode');
454
+ * }
455
+ * ```
456
+ */
457
+ isMode(mode) {
458
+ return this.context.currentMode === mode;
459
+ }
460
+ /**
461
+ * Reset state machine to initial state and mode
462
+ *
463
+ * Clears cache and resets context to initial configuration
464
+ *
465
+ * @example
466
+ * ```typescript
467
+ * machine.reset();
468
+ * console.log(machine.state); // Initial state
469
+ * console.log(machine.mode); // Initial mode
470
+ * ```
471
+ */
472
+ reset() {
473
+ this.resolvedStateCache.clear();
474
+ this.context = {
475
+ currentState: this.config.initialState,
476
+ previousState: null,
477
+ currentMode: this.config.initialMode,
478
+ previousMode: null,
479
+ timestamp: Date.now(),
480
+ data: this.config.initialData ?? {},
481
+ metadata: {}
482
+ };
483
+ }
484
+ /**
485
+ * Destroy state machine and clean up resources
486
+ *
487
+ * Clears cache and removes all event listeners
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * machine.destroy();
492
+ * ```
493
+ */
494
+ destroy() {
495
+ this.resolvedStateCache.clear();
496
+ this.removeAllListeners();
497
+ }
498
+ };
499
+
500
+ // state-machine/ConfigBuilder.ts
501
+ var ConfigBuilder = class {
502
+ constructor(initialData) {
503
+ this.config.initialData = initialData;
504
+ }
505
+ config = {
506
+ modes: {}
507
+ };
508
+ currentMode = null;
509
+ currentState = null;
510
+ /**
511
+ * Define a new mode or switch to an existing mode
512
+ *
513
+ * @param name - Mode key (e.g., 'NORMAL', 'FREESPIN', 'BONUS')
514
+ * @returns This builder for chaining
515
+ */
516
+ mode(name) {
517
+ this.currentMode = name;
518
+ if (!this.config.modes[name]) {
519
+ this.config.modes[name] = { states: {} };
520
+ }
521
+ return this;
522
+ }
523
+ /**
524
+ * Define a new state in the current mode
525
+ *
526
+ * @param name - State key (e.g., 'IDLE', 'SPIN', 'MATCH')
527
+ * @returns This builder for chaining
528
+ * @throws Error if mode() hasn't been called first
529
+ */
530
+ state(name) {
531
+ if (!this.currentMode) {
532
+ throw new Error("Must call mode() before state()");
533
+ }
534
+ this.currentState = name;
535
+ const mode = this.config.modes[this.currentMode];
536
+ if (!mode.states[name]) {
537
+ mode.states[name] = {};
538
+ }
539
+ return this;
540
+ }
541
+ /**
542
+ * Make current state extend from a parent state (inheritance)
543
+ *
544
+ * Child state will inherit all properties from parent state using lodash merge.
545
+ * Child properties override parent properties.
546
+ *
547
+ * @param parentState - Parent state key to extend from
548
+ * @returns This builder for chaining
549
+ * @throws Error if mode() and state() haven't been called first
550
+ *
551
+ * @example
552
+ * ```typescript
553
+ * .state('IDLE')
554
+ * .scope('ui', { spinButton: { enabled: true, icon: 'spin' } })
555
+ *
556
+ * .state('SPIN')
557
+ * .extends('IDLE') // Inherits from IDLE
558
+ * .scope('ui', { spinButton: { icon: 'stop' } }) // Only override icon
559
+ * ```
560
+ */
561
+ extends(parentState) {
562
+ if (!this.currentMode || !this.currentState) {
563
+ throw new Error("Must call mode() and state() before extends()");
564
+ }
565
+ const state = this.config.modes[this.currentMode].states[this.currentState];
566
+ state.extends = parentState;
567
+ return this;
568
+ }
569
+ /**
570
+ * Define scope configuration for current state
571
+ *
572
+ * Scopes organize related configuration (ui, scene, audio, etc.).
573
+ * Values can be static or resolver functions.
574
+ *
575
+ * @param scopeName - Scope key (e.g., 'ui', 'scene', 'audio')
576
+ * @param scopeData - Scope configuration object
577
+ * @returns This builder for chaining
578
+ * @throws Error if mode() and state() haven't been called first
579
+ *
580
+ * @example
581
+ * ```typescript
582
+ * .scope('ui', {
583
+ * spinButton: {
584
+ * enabled: true,
585
+ * icon: (ctx) => ctx.data.isQuickSpin ? 'quick_spin' : 'spin',
586
+ * },
587
+ * betButtons: { enabled: false },
588
+ * })
589
+ * .scope('scene', {
590
+ * reels: { spinning: true },
591
+ * })
592
+ * ```
593
+ */
594
+ scope(scopeName, scopeData) {
595
+ if (!this.currentMode || !this.currentState) {
596
+ throw new Error("Must call mode() and state() before scope()");
597
+ }
598
+ const state = this.config.modes[this.currentMode].states[this.currentState];
599
+ if (!state.scopes) {
600
+ state.scopes = {};
601
+ }
602
+ state.scopes[scopeName] = scopeData;
603
+ return this;
604
+ }
605
+ /**
606
+ * Add onEnter lifecycle hook to current state
607
+ *
608
+ * Called when entering this state. Can be async.
609
+ * Transition waits for this hook to complete.
610
+ *
611
+ * @param hook - Lifecycle hook function
612
+ * @returns This builder for chaining
613
+ * @throws Error if mode() and state() haven't been called first
614
+ *
615
+ * @example
616
+ * ```typescript
617
+ * .onEnter(async (ctx) => {
618
+ * ctx.data.balance -= ctx.data.bet;
619
+ * await scene.playAnimation();
620
+ * })
621
+ * ```
622
+ */
623
+ onEnter(hook) {
624
+ if (!this.currentMode || !this.currentState) {
625
+ throw new Error("Must call mode() and state() before onEnter()");
626
+ }
627
+ const state = this.config.modes[this.currentMode].states[this.currentState];
628
+ state.onEnter = hook;
629
+ return this;
630
+ }
631
+ /**
632
+ * Add onExit lifecycle hook to current state
633
+ *
634
+ * Called when exiting this state. Can be async.
635
+ * Transition waits for this hook to complete.
636
+ *
637
+ * @param hook - Lifecycle hook function
638
+ * @returns This builder for chaining
639
+ * @throws Error if mode() and state() haven't been called first
640
+ *
641
+ * @example
642
+ * ```typescript
643
+ * .onExit(async (ctx) => {
644
+ * await scene.cleanup();
645
+ * })
646
+ * ```
647
+ */
648
+ onExit(hook) {
649
+ if (!this.currentMode || !this.currentState) {
650
+ throw new Error("Must call mode() and state() before onExit()");
651
+ }
652
+ const state = this.config.modes[this.currentMode].states[this.currentState];
653
+ state.onExit = hook;
654
+ return this;
655
+ }
656
+ /**
657
+ * Add transition guard to current state
658
+ *
659
+ * Guards control whether transitions are allowed.
660
+ * Return false to block transition.
661
+ *
662
+ * @param type - Guard type ('canEnter' or 'canExit')
663
+ * @param guard - Guard function
664
+ * @returns This builder for chaining
665
+ * @throws Error if mode() and state() haven't been called first
666
+ *
667
+ * @example
668
+ * ```typescript
669
+ * .guard('canEnter', (ctx) => ctx.data.balance >= ctx.data.bet)
670
+ * .guard('canExit', (ctx) => !ctx.data.isLocked)
671
+ * ```
672
+ */
673
+ guard(type, guard) {
674
+ if (!this.currentMode || !this.currentState) {
675
+ throw new Error("Must call mode() and state() before guard()");
676
+ }
677
+ const state = this.config.modes[this.currentMode].states[this.currentState];
678
+ if (!state.guards) {
679
+ state.guards = {};
680
+ }
681
+ state.guards[type] = guard;
682
+ return this;
683
+ }
684
+ /**
685
+ * Add metadata to current state
686
+ *
687
+ * @param data - Metadata object
688
+ * @returns This builder for chaining
689
+ * @throws Error if mode() and state() haven't been called first
690
+ */
691
+ metadata(data) {
692
+ if (!this.currentMode || !this.currentState) {
693
+ throw new Error("Must call mode() and state() before metadata()");
694
+ }
695
+ const state = this.config.modes[this.currentMode].states[this.currentState];
696
+ state.metadata = { ...state.metadata, ...data };
697
+ return this;
698
+ }
699
+ /**
700
+ * Add lifecycle hook to current mode
701
+ *
702
+ * @param type - Hook type ('onEnter' or 'onExit')
703
+ * @param hook - Lifecycle hook function
704
+ * @returns This builder for chaining
705
+ * @throws Error if mode() hasn't been called first
706
+ *
707
+ * @example
708
+ * ```typescript
709
+ * .mode('FREESPIN')
710
+ * .modeHook('onEnter', (ctx) => {
711
+ * ctx.data.freeSpinsRemaining = 10;
712
+ * })
713
+ * ```
714
+ */
715
+ modeHook(type, hook) {
716
+ if (!this.currentMode) {
717
+ throw new Error("Must call mode() before modeHook()");
718
+ }
719
+ const mode = this.config.modes[this.currentMode];
720
+ mode[type] = hook;
721
+ return this;
722
+ }
723
+ /**
724
+ * Set initial state and mode
725
+ *
726
+ * @param state - Initial state key
727
+ * @param mode - Initial mode key
728
+ * @returns This builder for chaining
729
+ *
730
+ * @example
731
+ * ```typescript
732
+ * .initial('IDLE', 'NORMAL')
733
+ * ```
734
+ */
735
+ initial(state, mode) {
736
+ this.config.initialState = state;
737
+ this.config.initialMode = mode;
738
+ return this;
739
+ }
740
+ /**
741
+ * Set initial data for state context
742
+ *
743
+ * @param data - Initial data object
744
+ * @returns This builder for chaining
745
+ *
746
+ * @example
747
+ * ```typescript
748
+ * .initialData({ balance: 1000, bet: 10 })
749
+ * ```
750
+ */
751
+ initialData(data) {
752
+ this.config.initialData = data;
753
+ return this;
754
+ }
755
+ /**
756
+ * Enable strict mode (throws errors instead of emitting error events)
757
+ *
758
+ * @param value - Enable strict mode (default: true)
759
+ * @returns This builder for chaining
760
+ */
761
+ strict(value = true) {
762
+ this.config.strict = value;
763
+ return this;
764
+ }
765
+ /**
766
+ * Build and return the final state machine configuration
767
+ *
768
+ * @returns Complete state machine configuration
769
+ * @throws Error if initial state and mode haven't been set
770
+ *
771
+ * @example
772
+ * ```typescript
773
+ * const config = createConfig()
774
+ * .initial('IDLE', 'NORMAL')
775
+ * .mode('NORMAL')
776
+ * .state('IDLE')
777
+ * .build();
778
+ * ```
779
+ */
780
+ build() {
781
+ if (!this.config.initialState || !this.config.initialMode) {
782
+ throw new Error("Must set initial state and mode");
783
+ }
784
+ return this.config;
785
+ }
786
+ };
787
+ function createConfig(initialData) {
788
+ return new ConfigBuilder(initialData);
789
+ }
790
+
791
+ // state-machine/guards.ts
792
+ var guards = {
793
+ /**
794
+ * Always allow transition
795
+ *
796
+ * @returns Guard that always returns true
797
+ *
798
+ * @example
799
+ * ```typescript
800
+ * .guard('canEnter', guards.always())
801
+ * ```
802
+ */
803
+ always: () => () => true,
804
+ /**
805
+ * Never allow transition
806
+ *
807
+ * @returns Guard that always returns false
808
+ *
809
+ * @example
810
+ * ```typescript
811
+ * .guard('canEnter', guards.never())
812
+ * ```
813
+ */
814
+ never: () => () => false,
815
+ /**
816
+ * Check if data key exists and is not null/undefined
817
+ *
818
+ * @template TData - Type of state data
819
+ * @param key - Data key to check
820
+ * @returns Guard that checks if key exists
821
+ *
822
+ * @example
823
+ * ```typescript
824
+ * .guard('canEnter', guards.hasData('balance'))
825
+ * ```
826
+ */
827
+ hasData: (key) => {
828
+ return (context) => context.data[key] !== void 0 && context.data[key] !== null;
829
+ },
830
+ /**
831
+ * Check if data key equals a specific value
832
+ *
833
+ * @template TData - Type of state data
834
+ * @param key - Data key to check
835
+ * @param value - Value to compare against
836
+ * @returns Guard that checks equality
837
+ *
838
+ * @example
839
+ * ```typescript
840
+ * .guard('canEnter', guards.dataEquals('gameMode', 'normal'))
841
+ * ```
842
+ */
843
+ dataEquals: (key, value) => {
844
+ return (context) => context.data[key] === value;
845
+ },
846
+ /**
847
+ * Check if data key is greater than a value
848
+ *
849
+ * @template TData - Type of state data
850
+ * @param key - Data key to check (must be number)
851
+ * @param value - Value to compare against
852
+ * @returns Guard that checks if key > value
853
+ *
854
+ * @example
855
+ * ```typescript
856
+ * .guard('canEnter', guards.dataGreaterThan('balance', 0))
857
+ * ```
858
+ */
859
+ dataGreaterThan: (key, value) => {
860
+ return (context) => context.data[key] > value;
861
+ },
862
+ /**
863
+ * Check if data key is less than a value
864
+ *
865
+ * @template TData - Type of state data
866
+ * @param key - Data key to check (must be number)
867
+ * @param value - Value to compare against
868
+ * @returns Guard that checks if key < value
869
+ *
870
+ * @example
871
+ * ```typescript
872
+ * .guard('canEnter', guards.dataLessThan('lives', 3))
873
+ * ```
874
+ */
875
+ dataLessThan: (key, value) => {
876
+ return (context) => context.data[key] < value;
877
+ },
878
+ /**
879
+ * Combine multiple guards with AND logic
880
+ *
881
+ * All guards must return true for transition to be allowed.
882
+ *
883
+ * @template TData - Type of state data
884
+ * @param guards - Guards to combine
885
+ * @returns Guard that checks all guards
886
+ *
887
+ * @example
888
+ * ```typescript
889
+ * .guard('canEnter', guards.and(
890
+ * guards.hasData('balance'),
891
+ * guards.dataGreaterThan('balance', 10),
892
+ * (ctx) => ctx.data.isActive
893
+ * ))
894
+ * ```
895
+ */
896
+ and: (...guards2) => {
897
+ return async (context) => {
898
+ for (const guard of guards2) {
899
+ const result = await guard(context);
900
+ if (!result) return false;
901
+ }
902
+ return true;
903
+ };
904
+ },
905
+ /**
906
+ * Combine multiple guards with OR logic
907
+ *
908
+ * At least one guard must return true for transition to be allowed.
909
+ *
910
+ * @template TData - Type of state data
911
+ * @param guards - Guards to combine
912
+ * @returns Guard that checks any guard
913
+ *
914
+ * @example
915
+ * ```typescript
916
+ * .guard('canEnter', guards.or(
917
+ * guards.dataEquals('mode', 'demo'),
918
+ * guards.dataGreaterThan('balance', 0)
919
+ * ))
920
+ * ```
921
+ */
922
+ or: (...guards2) => {
923
+ return async (context) => {
924
+ for (const guard of guards2) {
925
+ const result = await guard(context);
926
+ if (result) return true;
927
+ }
928
+ return false;
929
+ };
930
+ },
931
+ /**
932
+ * Negate a guard (NOT logic)
933
+ *
934
+ * Returns opposite of the guard's result.
935
+ *
936
+ * @template TData - Type of state data
937
+ * @param guard - Guard to negate
938
+ * @returns Guard that returns opposite result
939
+ *
940
+ * @example
941
+ * ```typescript
942
+ * .guard('canEnter', guards.not(
943
+ * guards.dataEquals('isLocked', true)
944
+ * ))
945
+ * ```
946
+ */
947
+ not: (guard) => {
948
+ return async (context) => !await guard(context);
949
+ }
950
+ };
951
+
952
+ export { ConfigBuilder, StateMachine, createConfig, guards };
953
+ //# sourceMappingURL=index.js.map
954
+ //# sourceMappingURL=index.js.map