@vived/core 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. package/README.md +142 -20
  2. package/dist/cjs/AppObject/AppObject.js +53 -0
  3. package/dist/cjs/AppObject/AppObject.js.map +1 -1
  4. package/dist/cjs/AppObject/AppObjectComponent.js +78 -0
  5. package/dist/cjs/AppObject/AppObjectComponent.js.map +1 -1
  6. package/dist/cjs/AppObject/AppObjectController.js +22 -0
  7. package/dist/cjs/AppObject/AppObjectController.js.map +1 -1
  8. package/dist/cjs/AppObject/AppObjectEntity.js +52 -0
  9. package/dist/cjs/AppObject/AppObjectEntity.js.map +1 -1
  10. package/dist/cjs/AppObject/AppObjectEntityRepo.js +75 -1
  11. package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +1 -1
  12. package/dist/cjs/AppObject/AppObjectPM.js +46 -0
  13. package/dist/cjs/AppObject/AppObjectPM.js.map +1 -1
  14. package/dist/cjs/AppObject/AppObjectRepo.js +20 -0
  15. package/dist/cjs/AppObject/AppObjectRepo.js.map +1 -1
  16. package/dist/cjs/AppObject/AppObjectUC.js +23 -0
  17. package/dist/cjs/AppObject/AppObjectUC.js.map +1 -1
  18. package/dist/cjs/AppObject/AppObjectView.js +22 -0
  19. package/dist/cjs/AppObject/AppObjectView.js.map +1 -1
  20. package/dist/cjs/AppObject/getSingletonComponent.js +19 -0
  21. package/dist/cjs/AppObject/getSingletonComponent.js.map +1 -1
  22. package/dist/cjs/Entities/MemoizedAngle.js +21 -0
  23. package/dist/cjs/Entities/MemoizedAngle.js.map +1 -1
  24. package/dist/cjs/Entities/MemoizedBoolean.js +21 -0
  25. package/dist/cjs/Entities/MemoizedBoolean.js.map +1 -1
  26. package/dist/cjs/Entities/MemoizedColor.js +21 -0
  27. package/dist/cjs/Entities/MemoizedColor.js.map +1 -1
  28. package/dist/cjs/Entities/MemoizedNumber.js +21 -0
  29. package/dist/cjs/Entities/MemoizedNumber.js.map +1 -1
  30. package/dist/cjs/Entities/MemoizedQuaternion.js +21 -0
  31. package/dist/cjs/Entities/MemoizedQuaternion.js.map +1 -1
  32. package/dist/cjs/Entities/MemoizedString.js +21 -0
  33. package/dist/cjs/Entities/MemoizedString.js.map +1 -1
  34. package/dist/cjs/Entities/MemoizedVector2.js +21 -0
  35. package/dist/cjs/Entities/MemoizedVector2.js.map +1 -1
  36. package/dist/cjs/Entities/MemoizedVector3.js +21 -0
  37. package/dist/cjs/Entities/MemoizedVector3.js.map +1 -1
  38. package/dist/cjs/Entities/ObservableEntity.js +17 -0
  39. package/dist/cjs/Entities/ObservableEntity.js.map +1 -1
  40. package/dist/cjs/Entities/ObserverList.js +21 -0
  41. package/dist/cjs/Entities/ObserverList.js.map +1 -1
  42. package/dist/cjs/Entities/RangedNumber.js +29 -0
  43. package/dist/cjs/Entities/RangedNumber.js.map +1 -1
  44. package/dist/cjs/ExampleFeature/Adapters/examplePmAdapter.js +64 -0
  45. package/dist/cjs/ExampleFeature/Adapters/examplePmAdapter.js.map +1 -0
  46. package/dist/cjs/ExampleFeature/Adapters/exampleSingletonPmAdapter.js +60 -0
  47. package/dist/cjs/ExampleFeature/Adapters/exampleSingletonPmAdapter.js.map +1 -0
  48. package/dist/cjs/ExampleFeature/Adapters/index.js +19 -0
  49. package/dist/cjs/ExampleFeature/Adapters/index.js.map +1 -0
  50. package/dist/cjs/ExampleFeature/Controllers/index.js +19 -0
  51. package/dist/cjs/ExampleFeature/Controllers/index.js.map +1 -0
  52. package/dist/cjs/ExampleFeature/Controllers/setExampleText.js +48 -0
  53. package/dist/cjs/ExampleFeature/Controllers/setExampleText.js.map +1 -0
  54. package/dist/cjs/ExampleFeature/Controllers/toggleExampleBoolean.js +47 -0
  55. package/dist/cjs/ExampleFeature/Controllers/toggleExampleBoolean.js.map +1 -0
  56. package/dist/cjs/ExampleFeature/Entities/ExampleEntity.js +90 -0
  57. package/dist/cjs/ExampleFeature/Entities/ExampleEntity.js.map +1 -0
  58. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js +113 -0
  59. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js.map +1 -0
  60. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js +69 -0
  61. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -0
  62. package/dist/cjs/ExampleFeature/Entities/index.js +20 -0
  63. package/dist/cjs/ExampleFeature/Entities/index.js.map +1 -0
  64. package/dist/cjs/ExampleFeature/Factory/index.js +18 -0
  65. package/dist/cjs/ExampleFeature/Factory/index.js.map +1 -0
  66. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js +29 -0
  67. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js.map +1 -0
  68. package/dist/cjs/ExampleFeature/Mocks/MockEditExampleStringUC.js +47 -0
  69. package/dist/cjs/ExampleFeature/Mocks/MockEditExampleStringUC.js.map +1 -0
  70. package/dist/cjs/ExampleFeature/Mocks/MockExamplePM.js +48 -0
  71. package/dist/cjs/ExampleFeature/Mocks/MockExamplePM.js.map +1 -0
  72. package/dist/cjs/ExampleFeature/Mocks/MockExampleSingletonPM.js +59 -0
  73. package/dist/cjs/ExampleFeature/Mocks/MockExampleSingletonPM.js.map +1 -0
  74. package/dist/cjs/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js +57 -0
  75. package/dist/cjs/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js.map +1 -0
  76. package/dist/cjs/ExampleFeature/Mocks/index.js +21 -0
  77. package/dist/cjs/ExampleFeature/Mocks/index.js.map +1 -0
  78. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js +97 -0
  79. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js.map +1 -0
  80. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js +102 -0
  81. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -0
  82. package/dist/cjs/ExampleFeature/PMs/index.js +19 -0
  83. package/dist/cjs/ExampleFeature/PMs/index.js.map +1 -0
  84. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js +87 -0
  85. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -0
  86. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js +79 -0
  87. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -0
  88. package/dist/cjs/ExampleFeature/UCs/index.js +19 -0
  89. package/dist/cjs/ExampleFeature/UCs/index.js.map +1 -0
  90. package/dist/cjs/ExampleFeature/index.js +24 -0
  91. package/dist/cjs/ExampleFeature/index.js.map +1 -0
  92. package/dist/cjs/Types/PmAdapter.js.map +1 -1
  93. package/dist/cjs/Types/SingletonPmAdapter.js.map +1 -1
  94. package/dist/cjs/ValueObjects/Angle.js +1 -1
  95. package/dist/cjs/ValueObjects/Angle.js.map +1 -1
  96. package/dist/cjs/ValueObjects/LineSegment2D.js +6 -6
  97. package/dist/cjs/ValueObjects/LineSegment2D.js.map +1 -1
  98. package/dist/cjs/ValueObjects/Matrix.js +6 -6
  99. package/dist/cjs/ValueObjects/Matrix.js.map +1 -1
  100. package/dist/cjs/ValueObjects/Quaternion.js +17 -17
  101. package/dist/cjs/ValueObjects/Quaternion.js.map +1 -1
  102. package/dist/cjs/ValueObjects/Vector2.js +15 -8
  103. package/dist/cjs/ValueObjects/Vector2.js.map +1 -1
  104. package/dist/cjs/index.js +1 -0
  105. package/dist/cjs/index.js.map +1 -1
  106. package/dist/esm/AppObject/AppObject.js +53 -0
  107. package/dist/esm/AppObject/AppObject.js.map +1 -1
  108. package/dist/esm/AppObject/AppObjectComponent.js +78 -0
  109. package/dist/esm/AppObject/AppObjectComponent.js.map +1 -1
  110. package/dist/esm/AppObject/AppObjectController.js +22 -0
  111. package/dist/esm/AppObject/AppObjectController.js.map +1 -1
  112. package/dist/esm/AppObject/AppObjectEntity.js +52 -0
  113. package/dist/esm/AppObject/AppObjectEntity.js.map +1 -1
  114. package/dist/esm/AppObject/AppObjectEntityRepo.js +75 -1
  115. package/dist/esm/AppObject/AppObjectEntityRepo.js.map +1 -1
  116. package/dist/esm/AppObject/AppObjectPM.js +46 -0
  117. package/dist/esm/AppObject/AppObjectPM.js.map +1 -1
  118. package/dist/esm/AppObject/AppObjectRepo.js +20 -0
  119. package/dist/esm/AppObject/AppObjectRepo.js.map +1 -1
  120. package/dist/esm/AppObject/AppObjectUC.js +24 -1
  121. package/dist/esm/AppObject/AppObjectUC.js.map +1 -1
  122. package/dist/esm/AppObject/AppObjectView.js +23 -1
  123. package/dist/esm/AppObject/AppObjectView.js.map +1 -1
  124. package/dist/esm/AppObject/getSingletonComponent.js +19 -0
  125. package/dist/esm/AppObject/getSingletonComponent.js.map +1 -1
  126. package/dist/esm/Entities/MemoizedAngle.js +21 -0
  127. package/dist/esm/Entities/MemoizedAngle.js.map +1 -1
  128. package/dist/esm/Entities/MemoizedBoolean.js +21 -0
  129. package/dist/esm/Entities/MemoizedBoolean.js.map +1 -1
  130. package/dist/esm/Entities/MemoizedColor.js +21 -0
  131. package/dist/esm/Entities/MemoizedColor.js.map +1 -1
  132. package/dist/esm/Entities/MemoizedNumber.js +21 -0
  133. package/dist/esm/Entities/MemoizedNumber.js.map +1 -1
  134. package/dist/esm/Entities/MemoizedQuaternion.js +21 -0
  135. package/dist/esm/Entities/MemoizedQuaternion.js.map +1 -1
  136. package/dist/esm/Entities/MemoizedString.js +21 -0
  137. package/dist/esm/Entities/MemoizedString.js.map +1 -1
  138. package/dist/esm/Entities/MemoizedVector2.js +21 -0
  139. package/dist/esm/Entities/MemoizedVector2.js.map +1 -1
  140. package/dist/esm/Entities/MemoizedVector3.js +21 -0
  141. package/dist/esm/Entities/MemoizedVector3.js.map +1 -1
  142. package/dist/esm/Entities/ObservableEntity.js +17 -0
  143. package/dist/esm/Entities/ObservableEntity.js.map +1 -1
  144. package/dist/esm/Entities/ObserverList.js +21 -0
  145. package/dist/esm/Entities/ObserverList.js.map +1 -1
  146. package/dist/esm/Entities/RangedNumber.js +29 -0
  147. package/dist/esm/Entities/RangedNumber.js.map +1 -1
  148. package/dist/esm/ExampleFeature/Adapters/examplePmAdapter.js +61 -0
  149. package/dist/esm/ExampleFeature/Adapters/examplePmAdapter.js.map +1 -0
  150. package/dist/esm/ExampleFeature/Adapters/exampleSingletonPmAdapter.js +57 -0
  151. package/dist/esm/ExampleFeature/Adapters/exampleSingletonPmAdapter.js.map +1 -0
  152. package/dist/esm/ExampleFeature/Adapters/index.js +3 -0
  153. package/dist/esm/ExampleFeature/Adapters/index.js.map +1 -0
  154. package/dist/esm/ExampleFeature/Controllers/index.js +3 -0
  155. package/dist/esm/ExampleFeature/Controllers/index.js.map +1 -0
  156. package/dist/esm/ExampleFeature/Controllers/setExampleText.js +45 -0
  157. package/dist/esm/ExampleFeature/Controllers/setExampleText.js.map +1 -0
  158. package/dist/esm/ExampleFeature/Controllers/toggleExampleBoolean.js +44 -0
  159. package/dist/esm/ExampleFeature/Controllers/toggleExampleBoolean.js.map +1 -0
  160. package/dist/esm/ExampleFeature/Entities/ExampleEntity.js +85 -0
  161. package/dist/esm/ExampleFeature/Entities/ExampleEntity.js.map +1 -0
  162. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js +108 -0
  163. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js.map +1 -0
  164. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js +64 -0
  165. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -0
  166. package/dist/esm/ExampleFeature/Entities/index.js +4 -0
  167. package/dist/esm/ExampleFeature/Entities/index.js.map +1 -0
  168. package/dist/esm/ExampleFeature/Factory/index.js +2 -0
  169. package/dist/esm/ExampleFeature/Factory/index.js.map +1 -0
  170. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js +26 -0
  171. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js.map +1 -0
  172. package/dist/esm/ExampleFeature/Mocks/MockEditExampleStringUC.js +43 -0
  173. package/dist/esm/ExampleFeature/Mocks/MockEditExampleStringUC.js.map +1 -0
  174. package/dist/esm/ExampleFeature/Mocks/MockExamplePM.js +44 -0
  175. package/dist/esm/ExampleFeature/Mocks/MockExamplePM.js.map +1 -0
  176. package/dist/esm/ExampleFeature/Mocks/MockExampleSingletonPM.js +54 -0
  177. package/dist/esm/ExampleFeature/Mocks/MockExampleSingletonPM.js.map +1 -0
  178. package/dist/esm/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js +52 -0
  179. package/dist/esm/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js.map +1 -0
  180. package/dist/esm/ExampleFeature/Mocks/index.js +5 -0
  181. package/dist/esm/ExampleFeature/Mocks/index.js.map +1 -0
  182. package/dist/esm/ExampleFeature/PMs/ExamplePM.js +92 -0
  183. package/dist/esm/ExampleFeature/PMs/ExamplePM.js.map +1 -0
  184. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js +97 -0
  185. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -0
  186. package/dist/esm/ExampleFeature/PMs/index.js +3 -0
  187. package/dist/esm/ExampleFeature/PMs/index.js.map +1 -0
  188. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js +82 -0
  189. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -0
  190. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js +74 -0
  191. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -0
  192. package/dist/esm/ExampleFeature/UCs/index.js +3 -0
  193. package/dist/esm/ExampleFeature/UCs/index.js.map +1 -0
  194. package/dist/esm/ExampleFeature/index.js +8 -0
  195. package/dist/esm/ExampleFeature/index.js.map +1 -0
  196. package/dist/esm/Types/PmAdapter.js.map +1 -1
  197. package/dist/esm/Types/SingletonPmAdapter.js.map +1 -1
  198. package/dist/esm/ValueObjects/Angle.js +1 -1
  199. package/dist/esm/ValueObjects/Angle.js.map +1 -1
  200. package/dist/esm/ValueObjects/LineSegment2D.js +6 -6
  201. package/dist/esm/ValueObjects/LineSegment2D.js.map +1 -1
  202. package/dist/esm/ValueObjects/Matrix.js +6 -6
  203. package/dist/esm/ValueObjects/Matrix.js.map +1 -1
  204. package/dist/esm/ValueObjects/Quaternion.js +17 -17
  205. package/dist/esm/ValueObjects/Quaternion.js.map +1 -1
  206. package/dist/esm/ValueObjects/Vector2.js +15 -8
  207. package/dist/esm/ValueObjects/Vector2.js.map +1 -1
  208. package/dist/esm/index.js +1 -0
  209. package/dist/esm/index.js.map +1 -1
  210. package/dist/types/AppObject/AppObject.d.ts +42 -0
  211. package/dist/types/AppObject/AppObject.d.ts.map +1 -1
  212. package/dist/types/AppObject/AppObjectComponent.d.ts +80 -0
  213. package/dist/types/AppObject/AppObjectComponent.d.ts.map +1 -1
  214. package/dist/types/AppObject/AppObjectController.d.ts +22 -0
  215. package/dist/types/AppObject/AppObjectController.d.ts.map +1 -1
  216. package/dist/types/AppObject/AppObjectEntity.d.ts +55 -0
  217. package/dist/types/AppObject/AppObjectEntity.d.ts.map +1 -1
  218. package/dist/types/AppObject/AppObjectEntityRepo.d.ts +75 -0
  219. package/dist/types/AppObject/AppObjectEntityRepo.d.ts.map +1 -1
  220. package/dist/types/AppObject/AppObjectPM.d.ts +53 -0
  221. package/dist/types/AppObject/AppObjectPM.d.ts.map +1 -1
  222. package/dist/types/AppObject/AppObjectRepo.d.ts +124 -0
  223. package/dist/types/AppObject/AppObjectRepo.d.ts.map +1 -1
  224. package/dist/types/AppObject/AppObjectUC.d.ts +23 -0
  225. package/dist/types/AppObject/AppObjectUC.d.ts.map +1 -1
  226. package/dist/types/AppObject/AppObjectView.d.ts +22 -0
  227. package/dist/types/AppObject/AppObjectView.d.ts.map +1 -1
  228. package/dist/types/AppObject/getSingletonComponent.d.ts +19 -0
  229. package/dist/types/AppObject/getSingletonComponent.d.ts.map +1 -1
  230. package/dist/types/Entities/MemoizedAngle.d.ts +21 -0
  231. package/dist/types/Entities/MemoizedAngle.d.ts.map +1 -1
  232. package/dist/types/Entities/MemoizedBoolean.d.ts +21 -0
  233. package/dist/types/Entities/MemoizedBoolean.d.ts.map +1 -1
  234. package/dist/types/Entities/MemoizedColor.d.ts +21 -0
  235. package/dist/types/Entities/MemoizedColor.d.ts.map +1 -1
  236. package/dist/types/Entities/MemoizedNumber.d.ts +21 -0
  237. package/dist/types/Entities/MemoizedNumber.d.ts.map +1 -1
  238. package/dist/types/Entities/MemoizedQuaternion.d.ts +21 -0
  239. package/dist/types/Entities/MemoizedQuaternion.d.ts.map +1 -1
  240. package/dist/types/Entities/MemoizedString.d.ts +21 -0
  241. package/dist/types/Entities/MemoizedString.d.ts.map +1 -1
  242. package/dist/types/Entities/MemoizedVector2.d.ts +21 -0
  243. package/dist/types/Entities/MemoizedVector2.d.ts.map +1 -1
  244. package/dist/types/Entities/MemoizedVector3.d.ts +21 -0
  245. package/dist/types/Entities/MemoizedVector3.d.ts.map +1 -1
  246. package/dist/types/Entities/ObservableEntity.d.ts +20 -0
  247. package/dist/types/Entities/ObservableEntity.d.ts.map +1 -1
  248. package/dist/types/Entities/ObserverList.d.ts +21 -0
  249. package/dist/types/Entities/ObserverList.d.ts.map +1 -1
  250. package/dist/types/Entities/RangedNumber.d.ts +37 -0
  251. package/dist/types/Entities/RangedNumber.d.ts.map +1 -1
  252. package/dist/types/ExampleFeature/Adapters/examplePmAdapter.d.ts +29 -0
  253. package/dist/types/ExampleFeature/Adapters/examplePmAdapter.d.ts.map +1 -0
  254. package/dist/types/ExampleFeature/Adapters/exampleSingletonPmAdapter.d.ts +31 -0
  255. package/dist/types/ExampleFeature/Adapters/exampleSingletonPmAdapter.d.ts.map +1 -0
  256. package/dist/types/ExampleFeature/Adapters/index.d.ts +3 -0
  257. package/dist/types/ExampleFeature/Adapters/index.d.ts.map +1 -0
  258. package/dist/types/ExampleFeature/Controllers/index.d.ts +3 -0
  259. package/dist/types/ExampleFeature/Controllers/index.d.ts.map +1 -0
  260. package/dist/types/ExampleFeature/Controllers/setExampleText.d.ts +35 -0
  261. package/dist/types/ExampleFeature/Controllers/setExampleText.d.ts.map +1 -0
  262. package/dist/types/ExampleFeature/Controllers/toggleExampleBoolean.d.ts +34 -0
  263. package/dist/types/ExampleFeature/Controllers/toggleExampleBoolean.d.ts.map +1 -0
  264. package/dist/types/ExampleFeature/Entities/ExampleEntity.d.ts +55 -0
  265. package/dist/types/ExampleFeature/Entities/ExampleEntity.d.ts.map +1 -0
  266. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts +62 -0
  267. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts.map +1 -0
  268. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts +43 -0
  269. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts.map +1 -0
  270. package/dist/types/ExampleFeature/Entities/index.d.ts +4 -0
  271. package/dist/types/ExampleFeature/Entities/index.d.ts.map +1 -0
  272. package/dist/types/ExampleFeature/Factory/index.d.ts +2 -0
  273. package/dist/types/ExampleFeature/Factory/index.d.ts.map +1 -0
  274. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts +17 -0
  275. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts.map +1 -0
  276. package/dist/types/ExampleFeature/Mocks/MockEditExampleStringUC.d.ts +42 -0
  277. package/dist/types/ExampleFeature/Mocks/MockEditExampleStringUC.d.ts.map +1 -0
  278. package/dist/types/ExampleFeature/Mocks/MockExamplePM.d.ts +41 -0
  279. package/dist/types/ExampleFeature/Mocks/MockExamplePM.d.ts.map +1 -0
  280. package/dist/types/ExampleFeature/Mocks/MockExampleSingletonPM.d.ts +49 -0
  281. package/dist/types/ExampleFeature/Mocks/MockExampleSingletonPM.d.ts.map +1 -0
  282. package/dist/types/ExampleFeature/Mocks/MockToggleExampleBooleanUC.d.ts +47 -0
  283. package/dist/types/ExampleFeature/Mocks/MockToggleExampleBooleanUC.d.ts.map +1 -0
  284. package/dist/types/ExampleFeature/Mocks/index.d.ts +5 -0
  285. package/dist/types/ExampleFeature/Mocks/index.d.ts.map +1 -0
  286. package/dist/types/ExampleFeature/PMs/ExamplePM.d.ts +42 -0
  287. package/dist/types/ExampleFeature/PMs/ExamplePM.d.ts.map +1 -0
  288. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts +52 -0
  289. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts.map +1 -0
  290. package/dist/types/ExampleFeature/PMs/index.d.ts +3 -0
  291. package/dist/types/ExampleFeature/PMs/index.d.ts.map +1 -0
  292. package/dist/types/ExampleFeature/UCs/EditExampleStringUC.d.ts +52 -0
  293. package/dist/types/ExampleFeature/UCs/EditExampleStringUC.d.ts.map +1 -0
  294. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts +44 -0
  295. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts.map +1 -0
  296. package/dist/types/ExampleFeature/UCs/index.d.ts +3 -0
  297. package/dist/types/ExampleFeature/UCs/index.d.ts.map +1 -0
  298. package/dist/types/ExampleFeature/index.d.ts +8 -0
  299. package/dist/types/ExampleFeature/index.d.ts.map +1 -0
  300. package/dist/types/Types/PmAdapter.d.ts +60 -0
  301. package/dist/types/Types/PmAdapter.d.ts.map +1 -1
  302. package/dist/types/Types/SingletonPmAdapter.d.ts +55 -0
  303. package/dist/types/Types/SingletonPmAdapter.d.ts.map +1 -1
  304. package/dist/types/ValueObjects/Angle.d.ts +1 -1
  305. package/dist/types/ValueObjects/Matrix.d.ts +5 -5
  306. package/dist/types/ValueObjects/Matrix.d.ts.map +1 -1
  307. package/dist/types/ValueObjects/Quaternion.d.ts +17 -17
  308. package/dist/types/ValueObjects/Vector2.d.ts +8 -3
  309. package/dist/types/ValueObjects/Vector2.d.ts.map +1 -1
  310. package/dist/types/index.d.ts +1 -0
  311. package/dist/types/index.d.ts.map +1 -1
  312. package/package.json +6 -4
  313. package/dist/cjs/AppObject/AppObject.test.js +0 -113
  314. package/dist/cjs/AppObject/AppObject.test.js.map +0 -1
  315. package/dist/cjs/AppObject/AppObjectComponent.test.js +0 -132
  316. package/dist/cjs/AppObject/AppObjectComponent.test.js.map +0 -1
  317. package/dist/cjs/AppObject/AppObjectEntity.test.js +0 -108
  318. package/dist/cjs/AppObject/AppObjectEntity.test.js.map +0 -1
  319. package/dist/cjs/AppObject/AppObjectEntityRepo.test.js +0 -149
  320. package/dist/cjs/AppObject/AppObjectEntityRepo.test.js.map +0 -1
  321. package/dist/cjs/AppObject/AppObjectPM.test.js +0 -103
  322. package/dist/cjs/AppObject/AppObjectPM.test.js.map +0 -1
  323. package/dist/cjs/AppObject/AppObjectRepo.test.js +0 -213
  324. package/dist/cjs/AppObject/AppObjectRepo.test.js.map +0 -1
  325. package/dist/cjs/AppObject/getSingletonComponent.test.js +0 -13
  326. package/dist/cjs/AppObject/getSingletonComponent.test.js.map +0 -1
  327. package/dist/cjs/Entities/MemoizedAngle.test.js +0 -30
  328. package/dist/cjs/Entities/MemoizedAngle.test.js.map +0 -1
  329. package/dist/cjs/Entities/MemoizedBoolean.test.js +0 -34
  330. package/dist/cjs/Entities/MemoizedBoolean.test.js.map +0 -1
  331. package/dist/cjs/Entities/MemoizedColor.test.js +0 -32
  332. package/dist/cjs/Entities/MemoizedColor.test.js.map +0 -1
  333. package/dist/cjs/Entities/MemoizedNumber.test.js +0 -29
  334. package/dist/cjs/Entities/MemoizedNumber.test.js.map +0 -1
  335. package/dist/cjs/Entities/MemoizedQuaternion.test.js +0 -32
  336. package/dist/cjs/Entities/MemoizedQuaternion.test.js.map +0 -1
  337. package/dist/cjs/Entities/MemoizedString.test.js +0 -29
  338. package/dist/cjs/Entities/MemoizedString.test.js.map +0 -1
  339. package/dist/cjs/Entities/MemoizedVector2.test.js +0 -32
  340. package/dist/cjs/Entities/MemoizedVector2.test.js.map +0 -1
  341. package/dist/cjs/Entities/MemoizedVector3.test.js +0 -32
  342. package/dist/cjs/Entities/MemoizedVector3.test.js.map +0 -1
  343. package/dist/cjs/Entities/ObservableEntity.test.js +0 -25
  344. package/dist/cjs/Entities/ObservableEntity.test.js.map +0 -1
  345. package/dist/cjs/Entities/ObserverList.test.js +0 -44
  346. package/dist/cjs/Entities/ObserverList.test.js.map +0 -1
  347. package/dist/cjs/Entities/RangedNumber.test.js +0 -96
  348. package/dist/cjs/Entities/RangedNumber.test.js.map +0 -1
  349. package/dist/cjs/Utilities/LengthConverters.test.js +0 -24
  350. package/dist/cjs/Utilities/LengthConverters.test.js.map +0 -1
  351. package/dist/cjs/Utilities/LerpNumber.test.js +0 -90
  352. package/dist/cjs/Utilities/LerpNumber.test.js.map +0 -1
  353. package/dist/cjs/Utilities/addAlphaToHex.test.js +0 -34
  354. package/dist/cjs/Utilities/addAlphaToHex.test.js.map +0 -1
  355. package/dist/cjs/Utilities/alphaToHex.test.js +0 -75
  356. package/dist/cjs/Utilities/alphaToHex.test.js.map +0 -1
  357. package/dist/cjs/Utilities/degreesToRadians.test.js +0 -9
  358. package/dist/cjs/Utilities/degreesToRadians.test.js.map +0 -1
  359. package/dist/cjs/Utilities/easeFunctions.test.js +0 -209
  360. package/dist/cjs/Utilities/easeFunctions.test.js.map +0 -1
  361. package/dist/cjs/Utilities/interpolateNumber.test.js +0 -26
  362. package/dist/cjs/Utilities/interpolateNumber.test.js.map +0 -1
  363. package/dist/cjs/ValueObjects/Angle.test.js +0 -28
  364. package/dist/cjs/ValueObjects/Angle.test.js.map +0 -1
  365. package/dist/cjs/ValueObjects/Color.test.js +0 -147
  366. package/dist/cjs/ValueObjects/Color.test.js.map +0 -1
  367. package/dist/cjs/ValueObjects/LineSegment2D.test.js +0 -102
  368. package/dist/cjs/ValueObjects/LineSegment2D.test.js.map +0 -1
  369. package/dist/cjs/ValueObjects/Matrix.test.js +0 -385
  370. package/dist/cjs/ValueObjects/Matrix.test.js.map +0 -1
  371. package/dist/cjs/ValueObjects/ParametricLine.test.js +0 -126
  372. package/dist/cjs/ValueObjects/ParametricLine.test.js.map +0 -1
  373. package/dist/cjs/ValueObjects/ParametricPlane.test.js +0 -101
  374. package/dist/cjs/ValueObjects/ParametricPlane.test.js.map +0 -1
  375. package/dist/cjs/ValueObjects/Quaternion.test.js +0 -240
  376. package/dist/cjs/ValueObjects/Quaternion.test.js.map +0 -1
  377. package/dist/cjs/ValueObjects/Rectangle.test.js +0 -32
  378. package/dist/cjs/ValueObjects/Rectangle.test.js.map +0 -1
  379. package/dist/cjs/ValueObjects/Vector2.test.js +0 -136
  380. package/dist/cjs/ValueObjects/Vector2.test.js.map +0 -1
  381. package/dist/cjs/ValueObjects/Vector3.test.js +0 -188
  382. package/dist/cjs/ValueObjects/Vector3.test.js.map +0 -1
  383. package/dist/cjs/ValueObjects/Version.test.js +0 -310
  384. package/dist/cjs/ValueObjects/Version.test.js.map +0 -1
  385. package/dist/esm/AppObject/AppObject.test.js +0 -110
  386. package/dist/esm/AppObject/AppObject.test.js.map +0 -1
  387. package/dist/esm/AppObject/AppObjectComponent.test.js +0 -130
  388. package/dist/esm/AppObject/AppObjectComponent.test.js.map +0 -1
  389. package/dist/esm/AppObject/AppObjectEntity.test.js +0 -106
  390. package/dist/esm/AppObject/AppObjectEntity.test.js.map +0 -1
  391. package/dist/esm/AppObject/AppObjectEntityRepo.test.js +0 -147
  392. package/dist/esm/AppObject/AppObjectEntityRepo.test.js.map +0 -1
  393. package/dist/esm/AppObject/AppObjectPM.test.js +0 -101
  394. package/dist/esm/AppObject/AppObjectPM.test.js.map +0 -1
  395. package/dist/esm/AppObject/AppObjectRepo.test.js +0 -211
  396. package/dist/esm/AppObject/AppObjectRepo.test.js.map +0 -1
  397. package/dist/esm/AppObject/getSingletonComponent.test.js +0 -11
  398. package/dist/esm/AppObject/getSingletonComponent.test.js.map +0 -1
  399. package/dist/esm/Entities/MemoizedAngle.test.js +0 -28
  400. package/dist/esm/Entities/MemoizedAngle.test.js.map +0 -1
  401. package/dist/esm/Entities/MemoizedBoolean.test.js +0 -32
  402. package/dist/esm/Entities/MemoizedBoolean.test.js.map +0 -1
  403. package/dist/esm/Entities/MemoizedColor.test.js +0 -30
  404. package/dist/esm/Entities/MemoizedColor.test.js.map +0 -1
  405. package/dist/esm/Entities/MemoizedNumber.test.js +0 -27
  406. package/dist/esm/Entities/MemoizedNumber.test.js.map +0 -1
  407. package/dist/esm/Entities/MemoizedQuaternion.test.js +0 -30
  408. package/dist/esm/Entities/MemoizedQuaternion.test.js.map +0 -1
  409. package/dist/esm/Entities/MemoizedString.test.js +0 -27
  410. package/dist/esm/Entities/MemoizedString.test.js.map +0 -1
  411. package/dist/esm/Entities/MemoizedVector2.test.js +0 -30
  412. package/dist/esm/Entities/MemoizedVector2.test.js.map +0 -1
  413. package/dist/esm/Entities/MemoizedVector3.test.js +0 -30
  414. package/dist/esm/Entities/MemoizedVector3.test.js.map +0 -1
  415. package/dist/esm/Entities/ObservableEntity.test.js +0 -23
  416. package/dist/esm/Entities/ObservableEntity.test.js.map +0 -1
  417. package/dist/esm/Entities/ObserverList.test.js +0 -42
  418. package/dist/esm/Entities/ObserverList.test.js.map +0 -1
  419. package/dist/esm/Entities/RangedNumber.test.js +0 -94
  420. package/dist/esm/Entities/RangedNumber.test.js.map +0 -1
  421. package/dist/esm/Utilities/LengthConverters.test.js +0 -22
  422. package/dist/esm/Utilities/LengthConverters.test.js.map +0 -1
  423. package/dist/esm/Utilities/LerpNumber.test.js +0 -88
  424. package/dist/esm/Utilities/LerpNumber.test.js.map +0 -1
  425. package/dist/esm/Utilities/addAlphaToHex.test.js +0 -32
  426. package/dist/esm/Utilities/addAlphaToHex.test.js.map +0 -1
  427. package/dist/esm/Utilities/alphaToHex.test.js +0 -73
  428. package/dist/esm/Utilities/alphaToHex.test.js.map +0 -1
  429. package/dist/esm/Utilities/degreesToRadians.test.js +0 -7
  430. package/dist/esm/Utilities/degreesToRadians.test.js.map +0 -1
  431. package/dist/esm/Utilities/easeFunctions.test.js +0 -207
  432. package/dist/esm/Utilities/easeFunctions.test.js.map +0 -1
  433. package/dist/esm/Utilities/interpolateNumber.test.js +0 -24
  434. package/dist/esm/Utilities/interpolateNumber.test.js.map +0 -1
  435. package/dist/esm/ValueObjects/Angle.test.js +0 -26
  436. package/dist/esm/ValueObjects/Angle.test.js.map +0 -1
  437. package/dist/esm/ValueObjects/Color.test.js +0 -145
  438. package/dist/esm/ValueObjects/Color.test.js.map +0 -1
  439. package/dist/esm/ValueObjects/LineSegment2D.test.js +0 -100
  440. package/dist/esm/ValueObjects/LineSegment2D.test.js.map +0 -1
  441. package/dist/esm/ValueObjects/Matrix.test.js +0 -383
  442. package/dist/esm/ValueObjects/Matrix.test.js.map +0 -1
  443. package/dist/esm/ValueObjects/ParametricLine.test.js +0 -124
  444. package/dist/esm/ValueObjects/ParametricLine.test.js.map +0 -1
  445. package/dist/esm/ValueObjects/ParametricPlane.test.js +0 -99
  446. package/dist/esm/ValueObjects/ParametricPlane.test.js.map +0 -1
  447. package/dist/esm/ValueObjects/Quaternion.test.js +0 -238
  448. package/dist/esm/ValueObjects/Quaternion.test.js.map +0 -1
  449. package/dist/esm/ValueObjects/Rectangle.test.js +0 -30
  450. package/dist/esm/ValueObjects/Rectangle.test.js.map +0 -1
  451. package/dist/esm/ValueObjects/Vector2.test.js +0 -134
  452. package/dist/esm/ValueObjects/Vector2.test.js.map +0 -1
  453. package/dist/esm/ValueObjects/Vector3.test.js +0 -186
  454. package/dist/esm/ValueObjects/Vector3.test.js.map +0 -1
  455. package/dist/esm/ValueObjects/Version.test.js +0 -308
  456. package/dist/esm/ValueObjects/Version.test.js.map +0 -1
  457. package/dist/types/AppObject/AppObject.test.d.ts +0 -7
  458. package/dist/types/AppObject/AppObject.test.d.ts.map +0 -1
  459. package/dist/types/AppObject/AppObjectComponent.test.d.ts +0 -2
  460. package/dist/types/AppObject/AppObjectComponent.test.d.ts.map +0 -1
  461. package/dist/types/AppObject/AppObjectEntity.test.d.ts +0 -2
  462. package/dist/types/AppObject/AppObjectEntity.test.d.ts.map +0 -1
  463. package/dist/types/AppObject/AppObjectEntityRepo.test.d.ts +0 -2
  464. package/dist/types/AppObject/AppObjectEntityRepo.test.d.ts.map +0 -1
  465. package/dist/types/AppObject/AppObjectPM.test.d.ts +0 -2
  466. package/dist/types/AppObject/AppObjectPM.test.d.ts.map +0 -1
  467. package/dist/types/AppObject/AppObjectRepo.test.d.ts +0 -2
  468. package/dist/types/AppObject/AppObjectRepo.test.d.ts.map +0 -1
  469. package/dist/types/AppObject/getSingletonComponent.test.d.ts +0 -2
  470. package/dist/types/AppObject/getSingletonComponent.test.d.ts.map +0 -1
  471. package/dist/types/Entities/MemoizedAngle.test.d.ts +0 -2
  472. package/dist/types/Entities/MemoizedAngle.test.d.ts.map +0 -1
  473. package/dist/types/Entities/MemoizedBoolean.test.d.ts +0 -2
  474. package/dist/types/Entities/MemoizedBoolean.test.d.ts.map +0 -1
  475. package/dist/types/Entities/MemoizedColor.test.d.ts +0 -2
  476. package/dist/types/Entities/MemoizedColor.test.d.ts.map +0 -1
  477. package/dist/types/Entities/MemoizedNumber.test.d.ts +0 -2
  478. package/dist/types/Entities/MemoizedNumber.test.d.ts.map +0 -1
  479. package/dist/types/Entities/MemoizedQuaternion.test.d.ts +0 -2
  480. package/dist/types/Entities/MemoizedQuaternion.test.d.ts.map +0 -1
  481. package/dist/types/Entities/MemoizedString.test.d.ts +0 -2
  482. package/dist/types/Entities/MemoizedString.test.d.ts.map +0 -1
  483. package/dist/types/Entities/MemoizedVector2.test.d.ts +0 -2
  484. package/dist/types/Entities/MemoizedVector2.test.d.ts.map +0 -1
  485. package/dist/types/Entities/MemoizedVector3.test.d.ts +0 -2
  486. package/dist/types/Entities/MemoizedVector3.test.d.ts.map +0 -1
  487. package/dist/types/Entities/ObservableEntity.test.d.ts +0 -2
  488. package/dist/types/Entities/ObservableEntity.test.d.ts.map +0 -1
  489. package/dist/types/Entities/ObserverList.test.d.ts +0 -2
  490. package/dist/types/Entities/ObserverList.test.d.ts.map +0 -1
  491. package/dist/types/Entities/RangedNumber.test.d.ts +0 -2
  492. package/dist/types/Entities/RangedNumber.test.d.ts.map +0 -1
  493. package/dist/types/Utilities/LengthConverters.test.d.ts +0 -2
  494. package/dist/types/Utilities/LengthConverters.test.d.ts.map +0 -1
  495. package/dist/types/Utilities/LerpNumber.test.d.ts +0 -2
  496. package/dist/types/Utilities/LerpNumber.test.d.ts.map +0 -1
  497. package/dist/types/Utilities/addAlphaToHex.test.d.ts +0 -2
  498. package/dist/types/Utilities/addAlphaToHex.test.d.ts.map +0 -1
  499. package/dist/types/Utilities/alphaToHex.test.d.ts +0 -2
  500. package/dist/types/Utilities/alphaToHex.test.d.ts.map +0 -1
  501. package/dist/types/Utilities/degreesToRadians.test.d.ts +0 -2
  502. package/dist/types/Utilities/degreesToRadians.test.d.ts.map +0 -1
  503. package/dist/types/Utilities/easeFunctions.test.d.ts +0 -2
  504. package/dist/types/Utilities/easeFunctions.test.d.ts.map +0 -1
  505. package/dist/types/Utilities/interpolateNumber.test.d.ts +0 -2
  506. package/dist/types/Utilities/interpolateNumber.test.d.ts.map +0 -1
  507. package/dist/types/ValueObjects/Angle.test.d.ts +0 -2
  508. package/dist/types/ValueObjects/Angle.test.d.ts.map +0 -1
  509. package/dist/types/ValueObjects/Color.test.d.ts +0 -2
  510. package/dist/types/ValueObjects/Color.test.d.ts.map +0 -1
  511. package/dist/types/ValueObjects/LineSegment2D.test.d.ts +0 -2
  512. package/dist/types/ValueObjects/LineSegment2D.test.d.ts.map +0 -1
  513. package/dist/types/ValueObjects/Matrix.test.d.ts +0 -2
  514. package/dist/types/ValueObjects/Matrix.test.d.ts.map +0 -1
  515. package/dist/types/ValueObjects/ParametricLine.test.d.ts +0 -2
  516. package/dist/types/ValueObjects/ParametricLine.test.d.ts.map +0 -1
  517. package/dist/types/ValueObjects/ParametricPlane.test.d.ts +0 -2
  518. package/dist/types/ValueObjects/ParametricPlane.test.d.ts.map +0 -1
  519. package/dist/types/ValueObjects/Quaternion.test.d.ts +0 -2
  520. package/dist/types/ValueObjects/Quaternion.test.d.ts.map +0 -1
  521. package/dist/types/ValueObjects/Rectangle.test.d.ts +0 -2
  522. package/dist/types/ValueObjects/Rectangle.test.d.ts.map +0 -1
  523. package/dist/types/ValueObjects/Vector2.test.d.ts +0 -2
  524. package/dist/types/ValueObjects/Vector2.test.d.ts.map +0 -1
  525. package/dist/types/ValueObjects/Vector3.test.d.ts +0 -2
  526. package/dist/types/ValueObjects/Vector3.test.d.ts.map +0 -1
  527. package/dist/types/ValueObjects/Version.test.d.ts +0 -2
  528. package/dist/types/ValueObjects/Version.test.d.ts.map +0 -1
@@ -59,17 +59,24 @@ class Vector2 {
59
59
  /**
60
60
  * Get the magnitude (length) of the vector
61
61
  */
62
- get magnitued() {
62
+ get magnitude() {
63
63
  const xSqr = this.x * this.x;
64
64
  const ySqr = this.y * this.y;
65
65
  const magnitude = Math.sqrt(xSqr + ySqr);
66
66
  return magnitude;
67
67
  }
68
+ /**
69
+ * @deprecated Use magnitude instead - this property is kept for backward compatibility
70
+ * Get the magnitude (length) of the vector
71
+ */
72
+ get magnitued() {
73
+ return this.magnitude;
74
+ }
68
75
  /**
69
76
  * Get the unit vector
70
77
  */
71
78
  get unit() {
72
- const mag = this.magnitued;
79
+ const mag = this.magnitude;
73
80
  if (mag === 0) {
74
81
  return Vector2.Zero();
75
82
  }
@@ -78,14 +85,14 @@ class Vector2 {
78
85
  return new Vector2(unitX, unitY);
79
86
  }
80
87
  /**
81
- * Returns the angle of the direction of this angle in degrees.
88
+ * Returns the angle of the direction of this vector in degrees.
82
89
  * A right vector [1,0] will return 0, a left vector [-1,0] will return 180, an up vector [0,1] will return 90 and a down vector [0,-1] will return -90
83
90
  */
84
91
  get theta() {
85
92
  return (Math.atan2(this.y, this.x) * 180) / Math.PI;
86
93
  }
87
94
  /**
88
- * Retuns the vector as an array of numbers [x,y]
95
+ * Returns the vector as an array of numbers [x,y]
89
96
  */
90
97
  get array() {
91
98
  return [this.x, this.y];
@@ -111,7 +118,7 @@ exports.Vector2 = Vector2;
111
118
  */
112
119
  Vector2.Close = (a, b, threshold = 0.01) => {
113
120
  const diff = Vector2.Subtract(a, b);
114
- const diffMag = diff.magnitued;
121
+ const diffMag = diff.magnitude;
115
122
  if (diffMag < threshold)
116
123
  return true;
117
124
  else
@@ -140,7 +147,7 @@ Vector2.Scale = (vector, scale) => {
140
147
  return new Vector2(x, y);
141
148
  };
142
149
  /**
143
- * Creates a new vector of a given lenght and a unit that is equal to the original vector
150
+ * Creates a new vector of a given length and a unit that is equal to the original vector
144
151
  * @param vector The original vector. This determines the unit of the final vector
145
152
  * @param length The desired length of the final vector
146
153
  * @returns The final vector
@@ -168,8 +175,8 @@ Vector2.Dot = (a, b) => {
168
175
  */
169
176
  Vector2.AngleBetween = (a, b) => {
170
177
  const dot = Vector2.Dot(a, b);
171
- const magnitues = a.magnitued * b.magnitued;
172
- const angRadians = Math.acos(dot / magnitues);
178
+ const magnitudes = a.magnitude * b.magnitude;
179
+ const angRadians = Math.acos(dot / magnitudes);
173
180
  return _1.Angle.FromRadians(angRadians);
174
181
  };
175
182
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Vector2.js","sourceRoot":"","sources":["../../../src/ValueObjects/Vector2.ts"],"names":[],"mappings":";;;AAAA,wBAA0B;AAE1B,MAAa,OAAO;IAClB;;;OAGG;IACI,MAAM,CAAC,IAAI;QAChB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,GAAG;QACf,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,CAAU,EAAE,CAAU;QACxC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO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,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IAE9C,OAAO,QAAK,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF;;;;;GAKG;AACW,aAAK,GAAG,CAAC,CAAU,EAAE,CAAU,EAAU,EAAE;IACvD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["import { Angle } from \".\";\r\n\r\nexport class Vector2 {\r\n /**\r\n * Creates a zero vector\r\n * @returns Vector [0,0]\r\n */\r\n public static Zero(): Vector2 {\r\n return new Vector2(0, 0);\r\n }\r\n\r\n /**\r\n * Creates a one vector\r\n * @returns Vector [1,1]\r\n */\r\n public static One(): Vector2 {\r\n return new Vector2(1, 1);\r\n }\r\n\r\n /**\r\n * Checks to see if Vector A equals Vector B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns True if Vector A === Vector B\r\n */\r\n public static Equal(a: Vector2, b: Vector2): boolean {\r\n if (a.x !== b.x) return false;\r\n if (a.y !== b.y) return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates a Vector from a Data Transfer Object\r\n * @param dto The Data Transfer Object\r\n * @returns The Vector\r\n */\r\n public static FromDTO(dto: { x: number; y: number }): Vector2 {\r\n return new Vector2(dto.x, dto.y);\r\n }\r\n\r\n /**\r\n * Adds Vector B to Vector A\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A + B\r\n */\r\n public static Add(a: Vector2, b: Vector2): Vector2 {\r\n return new Vector2(a.x + b.x, a.y + b.y);\r\n }\r\n\r\n /**\r\n * Subtracts Vector B from Vector A\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A - B\r\n */\r\n public static Subtract(a: Vector2, b: Vector2): Vector2 {\r\n return new Vector2(a.x - b.x, a.y - b.y);\r\n }\r\n\r\n /**\r\n * Checks to see if Vector A is close to Vector B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @param threshold Tolerance to define \"close\". Defaults to 0.01\r\n * @returns True if A and B are close enough\r\n */\r\n public static Close = (\r\n a: Vector2,\r\n b: Vector2,\r\n threshold: number = 0.01\r\n ): boolean => {\r\n const diff = Vector2.Subtract(a, b);\r\n const diffMag = diff.magnitued;\r\n\r\n if (diffMag < threshold) return true;\r\n else return false;\r\n };\r\n\r\n /**\r\n * Rotates a vector by an angle\r\n * @param vec The original vector\r\n * @param angle The angle\r\n * @returns A new Vector that has been rotated from the original by an angle\r\n */\r\n public static Rotate = (vec: Vector2, angle: Angle): Vector2 => {\r\n const x = vec.x * Math.cos(angle.radians) - vec.y * Math.sin(angle.radians);\r\n const y = vec.x * Math.sin(angle.radians) + vec.y * Math.cos(angle.radians);\r\n return new Vector2(x, y);\r\n };\r\n\r\n /**\r\n * Scales a vector uniformly\r\n * @param vector The original vector\r\n * @param scale Scale factor\r\n * @returns A new, scaled vector\r\n */\r\n public static Scale = (vector: Vector2, scale: number): Vector2 => {\r\n const x = scale * vector.x;\r\n const y = scale * vector.y;\r\n return new Vector2(x, y);\r\n };\r\n\r\n /**\r\n * Creates a new vector of a given lenght and a unit that is equal to the original vector\r\n * @param vector The original vector. This determines the unit of the final vector\r\n * @param length The desired length of the final vector\r\n * @returns The final vector\r\n */\r\n public static NewVectorOfLength = (\r\n vector: Vector2,\r\n length: number\r\n ): Vector2 => {\r\n const unit = vector.unit;\r\n const x = length * unit.x;\r\n const y = length * unit.y;\r\n return new Vector2(x, y);\r\n };\r\n\r\n /**\r\n * Calculate the dot product between Vectors A and B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns The Dot product between A and B\r\n */\r\n public static Dot = (a: Vector2, b: Vector2): number => {\r\n return a.x * b.x + a.y * b.y;\r\n };\r\n\r\n /**\r\n * Calculates the dot product between Vectors A and B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A . B\r\n */\r\n public static AngleBetween = (a: Vector2, b: Vector2): Angle => {\r\n const dot = Vector2.Dot(a, b);\r\n const magnitues = a.magnitued * b.magnitued;\r\n\r\n const angRadians = Math.acos(dot / magnitues);\r\n\r\n return Angle.FromRadians(angRadians);\r\n };\r\n\r\n /**\r\n * Calculates the Cross product between Vectors A and B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A X B\r\n */\r\n public static Cross = (a: Vector2, b: Vector2): number => {\r\n return a.x * b.y - a.y * b.x;\r\n };\r\n\r\n readonly x: number;\r\n readonly y: number;\r\n\r\n /**\r\n * Get the magnitude (length) of the vector\r\n */\r\n get magnitued(): number {\r\n const xSqr = this.x * this.x;\r\n const ySqr = this.y * this.y;\r\n\r\n const magnitude = Math.sqrt(xSqr + ySqr);\r\n return magnitude;\r\n }\r\n\r\n /**\r\n * Get the unit vector\r\n */\r\n get unit(): Vector2 {\r\n const mag = this.magnitued;\r\n if (mag === 0) {\r\n return Vector2.Zero();\r\n }\r\n\r\n const unitX = this.x / mag;\r\n const unitY = this.y / mag;\r\n return new Vector2(unitX, unitY);\r\n }\r\n\r\n /**\r\n * Returns the angle of the direction of this angle in degrees.\r\n * A right vector [1,0] will return 0, a left vector [-1,0] will return 180, an up vector [0,1] will return 90 and a down vector [0,-1] will return -90\r\n */\r\n get theta(): number {\r\n return (Math.atan2(this.y, this.x) * 180) / Math.PI;\r\n }\r\n\r\n /**\r\n * Retuns the vector as an array of numbers [x,y]\r\n */\r\n get array(): [number, number] {\r\n return [this.x, this.y];\r\n }\r\n\r\n /**\r\n * Get the vector as a Data Transfer Object\r\n */\r\n get dto(): { x: number; y: number } {\r\n return { x: this.x, y: this.y };\r\n }\r\n\r\n constructor(x: number, y: number) {\r\n this.x = x;\r\n this.y = y;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Vector2.js","sourceRoot":"","sources":["../../../src/ValueObjects/Vector2.ts"],"names":[],"mappings":";;;AAAA,wBAA0B;AAE1B,MAAa,OAAO;IAClB;;;OAGG;IACI,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,EAAE,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF;;;;;GAKG;AACW,WAAG,GAAG,CAAC,CAAU,EAAE,CAAU,EAAU,EAAE;IACrD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;;GAKG;AACW,oBAAY,GAAG,CAAC,CAAU,EAAE,CAAU,EAAS,EAAE;IAC7D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;IAE7C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAE/C,OAAO,QAAK,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF;;;;;GAKG;AACW,aAAK,GAAG,CAAC,CAAU,EAAE,CAAU,EAAU,EAAE;IACvD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["import { Angle } from \".\";\r\n\r\nexport class Vector2 {\r\n /**\r\n * Creates a zero vector\r\n * @returns Vector [0,0]\r\n */\r\n public static Zero(): Vector2 {\r\n return new Vector2(0, 0);\r\n }\r\n\r\n /**\r\n * Creates a one vector\r\n * @returns Vector [1,1]\r\n */\r\n public static One(): Vector2 {\r\n return new Vector2(1, 1);\r\n }\r\n\r\n /**\r\n * Checks to see if Vector A equals Vector B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns True if Vector A === Vector B\r\n */\r\n public static Equal(a: Vector2, b: Vector2): boolean {\r\n if (a.x !== b.x) return false;\r\n if (a.y !== b.y) return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates a Vector from a Data Transfer Object\r\n * @param dto The Data Transfer Object\r\n * @returns The Vector\r\n */\r\n public static FromDTO(dto: { x: number; y: number }): Vector2 {\r\n return new Vector2(dto.x, dto.y);\r\n }\r\n\r\n /**\r\n * Adds Vector B to Vector A\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A + B\r\n */\r\n public static Add(a: Vector2, b: Vector2): Vector2 {\r\n return new Vector2(a.x + b.x, a.y + b.y);\r\n }\r\n\r\n /**\r\n * Subtracts Vector B from Vector A\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A - B\r\n */\r\n public static Subtract(a: Vector2, b: Vector2): Vector2 {\r\n return new Vector2(a.x - b.x, a.y - b.y);\r\n }\r\n\r\n /**\r\n * Checks to see if Vector A is close to Vector B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @param threshold Tolerance to define \"close\". Defaults to 0.01\r\n * @returns True if A and B are close enough\r\n */\r\n public static Close = (\r\n a: Vector2,\r\n b: Vector2,\r\n threshold: number = 0.01\r\n ): boolean => {\r\n const diff = Vector2.Subtract(a, b);\r\n const diffMag = diff.magnitude;\r\n\r\n if (diffMag < threshold) return true;\r\n else return false;\r\n };\r\n\r\n /**\r\n * Rotates a vector by an angle\r\n * @param vec The original vector\r\n * @param angle The angle\r\n * @returns A new Vector that has been rotated from the original by an angle\r\n */\r\n public static Rotate = (vec: Vector2, angle: Angle): Vector2 => {\r\n const x = vec.x * Math.cos(angle.radians) - vec.y * Math.sin(angle.radians);\r\n const y = vec.x * Math.sin(angle.radians) + vec.y * Math.cos(angle.radians);\r\n return new Vector2(x, y);\r\n };\r\n\r\n /**\r\n * Scales a vector uniformly\r\n * @param vector The original vector\r\n * @param scale Scale factor\r\n * @returns A new, scaled vector\r\n */\r\n public static Scale = (vector: Vector2, scale: number): Vector2 => {\r\n const x = scale * vector.x;\r\n const y = scale * vector.y;\r\n return new Vector2(x, y);\r\n };\r\n\r\n /**\r\n * Creates a new vector of a given length and a unit that is equal to the original vector\r\n * @param vector The original vector. This determines the unit of the final vector\r\n * @param length The desired length of the final vector\r\n * @returns The final vector\r\n */\r\n public static NewVectorOfLength = (\r\n vector: Vector2,\r\n length: number\r\n ): Vector2 => {\r\n const unit = vector.unit;\r\n const x = length * unit.x;\r\n const y = length * unit.y;\r\n return new Vector2(x, y);\r\n };\r\n\r\n /**\r\n * Calculate the dot product between Vectors A and B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns The Dot product between A and B\r\n */\r\n public static Dot = (a: Vector2, b: Vector2): number => {\r\n return a.x * b.x + a.y * b.y;\r\n };\r\n\r\n /**\r\n * Calculates the dot product between Vectors A and B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A . B\r\n */\r\n public static AngleBetween = (a: Vector2, b: Vector2): Angle => {\r\n const dot = Vector2.Dot(a, b);\r\n const magnitudes = a.magnitude * b.magnitude;\r\n\r\n const angRadians = Math.acos(dot / magnitudes);\r\n\r\n return Angle.FromRadians(angRadians);\r\n };\r\n\r\n /**\r\n * Calculates the Cross product between Vectors A and B\r\n * @param a Vector A\r\n * @param b Vector B\r\n * @returns A X B\r\n */\r\n public static Cross = (a: Vector2, b: Vector2): number => {\r\n return a.x * b.y - a.y * b.x;\r\n };\r\n\r\n readonly x: number;\r\n readonly y: number;\r\n\r\n /**\r\n * Get the magnitude (length) of the vector\r\n */\r\n get magnitude(): number {\r\n const xSqr = this.x * this.x;\r\n const ySqr = this.y * this.y;\r\n\r\n const magnitude = Math.sqrt(xSqr + ySqr);\r\n return magnitude;\r\n }\r\n \r\n /**\r\n * @deprecated Use magnitude instead - this property is kept for backward compatibility\r\n * Get the magnitude (length) of the vector\r\n */\r\n get magnitued(): number {\r\n return this.magnitude;\r\n }\r\n\r\n /**\r\n * Get the unit vector\r\n */\r\n get unit(): Vector2 {\r\n const mag = this.magnitude;\r\n if (mag === 0) {\r\n return Vector2.Zero();\r\n }\r\n\r\n const unitX = this.x / mag;\r\n const unitY = this.y / mag;\r\n return new Vector2(unitX, unitY);\r\n }\r\n\r\n /**\r\n * Returns the angle of the direction of this vector in degrees.\r\n * A right vector [1,0] will return 0, a left vector [-1,0] will return 180, an up vector [0,1] will return 90 and a down vector [0,-1] will return -90\r\n */\r\n get theta(): number {\r\n return (Math.atan2(this.y, this.x) * 180) / Math.PI;\r\n }\r\n\r\n /**\r\n * Returns the vector as an array of numbers [x,y]\r\n */\r\n get array(): [number, number] {\r\n return [this.x, this.y];\r\n }\r\n\r\n /**\r\n * Get the vector as a Data Transfer Object\r\n */\r\n get dto(): { x: number; y: number } {\r\n return { x: this.x, y: this.y };\r\n }\r\n\r\n constructor(x: number, y: number) {\r\n this.x = x;\r\n this.y = y;\r\n }\r\n}\r\n"]}
package/dist/cjs/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./AppObject"), exports);
18
18
  __exportStar(require("./Entities"), exports);
19
+ __exportStar(require("./ExampleFeature"), exports);
19
20
  __exportStar(require("./Types"), exports);
20
21
  __exportStar(require("./Utilities"), exports);
21
22
  __exportStar(require("./ValueObjects"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,iDAA+B","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./Entities\";\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAgC;AAChC,0CAAwB;AACxB,8CAA4B;AAC5B,iDAA+B","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./Entities\";\r\nexport * from \"./ExampleFeature\"\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
@@ -1,13 +1,42 @@
1
1
  import { ObservableEntity } from "../Entities";
2
+ /**
3
+ * AppObject is the central class in the VIVED application architecture.
4
+ * It serves as a container for components that implement the application's functionality.
5
+ * Each AppObject is identified by a unique ID and registered with an AppObjectRepo.
6
+ *
7
+ * AppObjects are observable entities that notify observers when their components change.
8
+ * This enables reactive programming patterns throughout the application.
9
+ */
2
10
  export class AppObject extends ObservableEntity {
3
11
  }
12
+ /**
13
+ * Factory function to create a new AppObject
14
+ * @param id Unique identifier for the new AppObject
15
+ * @param repo Repository to register the AppObject with
16
+ * @returns A new AppObject instance
17
+ */
4
18
  export function makeAppObject(id, repo) {
5
19
  return new AppObjectImp(id, repo);
6
20
  }
21
+ /**
22
+ * Implementation of the AppObject abstract class
23
+ * This class handles the component management functionality
24
+ */
7
25
  class AppObjectImp extends AppObject {
26
+ /**
27
+ * Checks if a component of the specified type exists
28
+ * @param type The component type identifier
29
+ * @returns True if the component exists, false otherwise
30
+ */
8
31
  hasComponent(type) {
9
32
  return this.componentLookup.has(type);
10
33
  }
34
+ /**
35
+ * Adds a component to this AppObject
36
+ * If a component of the same type already exists, it will be disposed and replaced
37
+ * Notifies observers after adding the component
38
+ * @param component The component to add
39
+ */
11
40
  addComponent(component) {
12
41
  const currentComponent = this.componentLookup.get(component.type);
13
42
  if (currentComponent) {
@@ -17,6 +46,11 @@ class AppObjectImp extends AppObject {
17
46
  this.componentLookup.set(component.type, component);
18
47
  this.notify();
19
48
  }
49
+ /**
50
+ * Retrieves a component by type
51
+ * @param type The component type identifier
52
+ * @returns The component cast to type T, or undefined if not found
53
+ */
20
54
  getComponent(type) {
21
55
  if (this.componentLookup.has(type)) {
22
56
  return this.componentLookup.get(type);
@@ -25,6 +59,10 @@ class AppObjectImp extends AppObject {
25
59
  return undefined;
26
60
  }
27
61
  }
62
+ /**
63
+ * Removes a component by type and notifies observers
64
+ * @param type The component type identifier
65
+ */
28
66
  removeComponent(type) {
29
67
  const component = this.componentLookup.get(type);
30
68
  if (!component)
@@ -32,12 +70,27 @@ class AppObjectImp extends AppObject {
32
70
  this.componentLookup.delete(type);
33
71
  this.notify();
34
72
  }
73
+ /**
74
+ * Gets all components attached to this AppObject
75
+ * @returns Array of all components
76
+ */
35
77
  allComponents() {
36
78
  return Array.from(this.componentLookup.values());
37
79
  }
80
+ /**
81
+ * Creates a new AppObject instance
82
+ * @param id Unique identifier for this AppObject
83
+ * @param repo Repository to register with
84
+ */
38
85
  constructor(id, repo) {
39
86
  super();
87
+ /** Map of component types to component instances */
40
88
  this.componentLookup = new Map();
89
+ /**
90
+ * Cleans up resources by:
91
+ * 1. Disposing all attached components
92
+ * 2. Removing this AppObject from its repository
93
+ */
41
94
  this.dispose = () => {
42
95
  const components = Array.from(this.componentLookup.values());
43
96
  this.componentLookup.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"AppObject.js","sourceRoot":"","sources":["../../../src/AppObject/AppObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,OAAgB,SAAU,SAAQ,gBAAgB;CAWvD;AAED,MAAM,UAAU,aAAa,CAAC,EAAU,EAAE,IAAmB;IAC3D,OAAO,IAAI,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,YAAa,SAAQ,SAAS;IAMlC,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,YAAY,CAAC,SAA6B;QACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClE,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CACV,yBAAyB,SAA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C,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC,CAAC;QAIA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import { ObservableEntity } from \"../Entities\";\r\nimport { AppObjectComponent } from \"./AppObjectComponent\";\r\nimport { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\nexport abstract class AppObject extends ObservableEntity {\r\n abstract readonly id: string;\r\n abstract readonly appObjectRepo: AppObjectRepo;\r\n\r\n abstract hasComponent(type: string): boolean;\r\n abstract addComponent(component: AppObjectComponent): void;\r\n abstract getComponent<T extends AppObjectComponent>(type: string): T | undefined;\r\n abstract removeComponent(type: string): void;\r\n abstract allComponents(): AppObjectComponent[];\r\n\r\n abstract dispose(): void;\r\n}\r\n\r\nexport function makeAppObject(id: string, repo: AppObjectRepo): AppObject {\r\n return new AppObjectImp(id, repo);\r\n}\r\n\r\nclass AppObjectImp extends AppObject {\r\n readonly id: string;\r\n readonly appObjectRepo: AppObjectRepo;\r\n\r\n private componentLookup = new Map<string, AppObjectComponent>();\r\n\r\n hasComponent(type: string): boolean {\r\n return this.componentLookup.has(type);\r\n }\r\n\r\n addComponent(component: AppObjectComponent): void {\r\n const currentComponent = this.componentLookup.get(component.type);\r\n if (currentComponent) {\r\n console.warn(\r\n `[AppObject] Component ${component.type} is being replaced on ${this.id}`\r\n );\r\n currentComponent.dispose();\r\n }\r\n\r\n this.componentLookup.set(component.type, component);\r\n this.notify();\r\n }\r\n\r\n getComponent<T extends AppObjectComponent>(type: string): T | undefined {\r\n if (this.componentLookup.has(type)) {\r\n return this.componentLookup.get(type) as T;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n removeComponent(type: string): void {\r\n const component = this.componentLookup.get(type);\r\n\r\n if (!component) return;\r\n\r\n this.componentLookup.delete(type);\r\n this.notify();\r\n }\r\n\r\n allComponents(): AppObjectComponent[] {\r\n return Array.from(this.componentLookup.values());\r\n }\r\n\r\n\r\n dispose = (): void => {\r\n const components = Array.from(this.componentLookup.values());\r\n this.componentLookup.clear();\r\n components.forEach(c => c.dispose());\r\n\r\n if (this.appObjectRepo.has(this.id)) {\r\n this.appObjectRepo.remove(this.id);\r\n }\r\n };\r\n\r\n constructor(id: string, repo: AppObjectRepo) {\r\n super();\r\n this.id = id;\r\n this.appObjectRepo = repo;\r\n this.appObjectRepo.add(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AppObject.js","sourceRoot":"","sources":["../../../src/AppObject/AppObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C;;;;;;;GAOG;AACH,MAAM,OAAgB,SAAU,SAAQ,gBAAgB;CA4CvD;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU,EAAE,IAAmB;IAC3D,OAAO,IAAI,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,YAAa,SAAQ,SAAS;IAOlC;;;;OAIG;IACH,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,SAA6B;QACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClE,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CACV,yBAAyB,SAAS,CAAC,IAAI,yBAAyB,IAAI,CAAC,EAAE,EAAE,CAC1E,CAAC;YACF,gBAAgB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,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC,CAAC;QASA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import { ObservableEntity } from \"../Entities\";\r\nimport { AppObjectComponent } from \"./AppObjectComponent\";\r\nimport { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\n/**\r\n * AppObject is the central class in the VIVED application architecture.\r\n * It serves as a container for components that implement the application's functionality.\r\n * Each AppObject is identified by a unique ID and registered with an AppObjectRepo.\r\n * \r\n * AppObjects are observable entities that notify observers when their components change.\r\n * This enables reactive programming patterns throughout the application.\r\n */\r\nexport abstract class AppObject extends ObservableEntity {\r\n /** Unique identifier for this AppObject */\r\n abstract readonly id: string;\r\n \r\n /** Repository that manages this AppObject */\r\n abstract readonly appObjectRepo: AppObjectRepo;\r\n\r\n /**\r\n * Checks if this AppObject has a component of the specified type\r\n * @param type The component type identifier\r\n * @returns True if the component exists, false otherwise\r\n */\r\n abstract hasComponent(type: string): boolean;\r\n \r\n /**\r\n * Adds a component to this AppObject\r\n * If a component of the same type already exists, it will be replaced\r\n * @param component The component to add\r\n */\r\n abstract addComponent(component: AppObjectComponent): void;\r\n \r\n /**\r\n * Retrieves a component by type\r\n * @param type The component type identifier\r\n * @returns The component cast to type T, or undefined if not found\r\n */\r\n abstract getComponent<T extends AppObjectComponent>(type: string): T | undefined;\r\n \r\n /**\r\n * Removes a component by type\r\n * @param type The component type identifier\r\n */\r\n abstract removeComponent(type: string): void;\r\n \r\n /**\r\n * Gets all components attached to this AppObject\r\n * @returns Array of all components\r\n */\r\n abstract allComponents(): AppObjectComponent[];\r\n\r\n /**\r\n * Cleans up resources and removes this AppObject from its repository\r\n */\r\n abstract dispose(): void;\r\n}\r\n\r\n/**\r\n * Factory function to create a new AppObject\r\n * @param id Unique identifier for the new AppObject\r\n * @param repo Repository to register the AppObject with\r\n * @returns A new AppObject instance\r\n */\r\nexport function makeAppObject(id: string, repo: AppObjectRepo): AppObject {\r\n return new AppObjectImp(id, repo);\r\n}\r\n\r\n/**\r\n * Implementation of the AppObject abstract class\r\n * This class handles the component management functionality\r\n */\r\nclass AppObjectImp extends AppObject {\r\n readonly id: string;\r\n readonly appObjectRepo: AppObjectRepo;\r\n\r\n /** Map of component types to component instances */\r\n private componentLookup = new Map<string, AppObjectComponent>();\r\n\r\n /**\r\n * Checks if a component of the specified type exists\r\n * @param type The component type identifier\r\n * @returns True if the component exists, false otherwise\r\n */\r\n hasComponent(type: string): boolean {\r\n return this.componentLookup.has(type);\r\n }\r\n\r\n /**\r\n * Adds a component to this AppObject\r\n * If a component of the same type already exists, it will be disposed and replaced\r\n * Notifies observers after adding the component\r\n * @param component The component to add\r\n */\r\n addComponent(component: AppObjectComponent): void {\r\n const currentComponent = this.componentLookup.get(component.type);\r\n if (currentComponent) {\r\n console.warn(\r\n `[AppObject] Component ${component.type} is being replaced on ${this.id}`\r\n );\r\n currentComponent.dispose();\r\n }\r\n\r\n this.componentLookup.set(component.type, component);\r\n this.notify();\r\n }\r\n\r\n /**\r\n * Retrieves a component by type\r\n * @param type The component type identifier\r\n * @returns The component cast to type T, or undefined if not found\r\n */\r\n getComponent<T extends AppObjectComponent>(type: string): T | undefined {\r\n if (this.componentLookup.has(type)) {\r\n return this.componentLookup.get(type) as T;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Removes a component by type and notifies observers\r\n * @param type The component type identifier\r\n */\r\n removeComponent(type: string): void {\r\n const component = this.componentLookup.get(type);\r\n\r\n if (!component) return;\r\n\r\n this.componentLookup.delete(type);\r\n this.notify();\r\n }\r\n\r\n /**\r\n * Gets all components attached to this AppObject\r\n * @returns Array of all components\r\n */\r\n allComponents(): AppObjectComponent[] {\r\n return Array.from(this.componentLookup.values());\r\n }\r\n\r\n /**\r\n * Cleans up resources by:\r\n * 1. Disposing all attached components\r\n * 2. Removing this AppObject from its repository\r\n */\r\n dispose = (): void => {\r\n const components = Array.from(this.componentLookup.values());\r\n this.componentLookup.clear();\r\n components.forEach(c => c.dispose());\r\n\r\n if (this.appObjectRepo.has(this.id)) {\r\n this.appObjectRepo.remove(this.id);\r\n }\r\n };\r\n\r\n /**\r\n * Creates a new AppObject instance\r\n * @param id Unique identifier for this AppObject\r\n * @param repo Repository to register with\r\n */\r\n constructor(id: string, repo: AppObjectRepo) {\r\n super();\r\n this.id = id;\r\n this.appObjectRepo = repo;\r\n this.appObjectRepo.add(this);\r\n }\r\n}\r\n"]}
@@ -1,16 +1,49 @@
1
+ /**
2
+ * Enumeration of the different types of components in the architecture.
3
+ * Each type serves a specific purpose in the application structure.
4
+ */
1
5
  export var AppObjectComponentType;
2
6
  (function (AppObjectComponentType) {
7
+ /** Stores and manages application state */
3
8
  AppObjectComponentType["ENTITY"] = "Entity";
9
+ /** Transforms application state into view models */
4
10
  AppObjectComponentType["PM"] = "Presentation Manager";
11
+ /** Implements business logic and coordinates between layers */
5
12
  AppObjectComponentType["UC"] = "Use Case";
13
+ /** Handles user inputs and external events */
6
14
  AppObjectComponentType["CONTROLLER"] = "Controller";
15
+ /** Renders UI elements and interacts with the DOM/rendering system */
7
16
  AppObjectComponentType["VIEW"] = "View";
17
+ /** Default type for components that don't fit the standard categories */
8
18
  AppObjectComponentType["UNKNOWN"] = "Unknown";
9
19
  })(AppObjectComponentType || (AppObjectComponentType = {}));
20
+ /**
21
+ * Base class for all components in the AppObject architecture.
22
+ *
23
+ * Components attach to AppObjects and provide specific functionality based on their type.
24
+ * The architecture follows a clean separation of concerns, with each component type
25
+ * having a well-defined responsibility in the application.
26
+ *
27
+ * Components can communicate with each other through various mechanisms:
28
+ * - Direct access via parent AppObject
29
+ * - Repository-level singleton access
30
+ * - Observer patterns for reactive updates
31
+ */
10
32
  export class AppObjectComponent {
33
+ /**
34
+ * Convenience accessor for the repository containing all AppObjects
35
+ * @returns The application's AppObjectRepo
36
+ */
11
37
  get appObjects() {
12
38
  return this.appObject.appObjectRepo;
13
39
  }
40
+ /**
41
+ * Retrieves a singleton component of the specified type from the repository
42
+ * Results are cached for better performance in repeated calls
43
+ *
44
+ * @param type The component type identifier to look up
45
+ * @returns The singleton component cast to type T, or undefined if not found
46
+ */
14
47
  getCachedSingleton(type) {
15
48
  if (!this.cachedComponents.has(type)) {
16
49
  const component = this.appObjects.getSingleton(type);
@@ -23,6 +56,13 @@ export class AppObjectComponent {
23
56
  }
24
57
  return this.cachedComponents.get(type);
25
58
  }
59
+ /**
60
+ * Retrieves a component from the same AppObject as this component
61
+ * Results are cached for better performance in repeated calls
62
+ *
63
+ * @param type The component type identifier to look up
64
+ * @returns The component cast to type T, or undefined if not found
65
+ */
26
66
  getCachedLocalComponent(type) {
27
67
  if (!this.cachedComponents.has(type)) {
28
68
  const component = this.appObject.getComponent(type);
@@ -35,6 +75,14 @@ export class AppObjectComponent {
35
75
  }
36
76
  return this.cachedComponents.get(type);
37
77
  }
78
+ /**
79
+ * Retrieves a singleton component from the repository with customizable logging
80
+ * Unlike getCachedSingleton, results are not cached
81
+ *
82
+ * @param type The component type identifier to look up
83
+ * @param logType The severity level for logging if component isn't found
84
+ * @returns The singleton component cast to type T, or undefined if not found
85
+ */
38
86
  getSingleton(type, logType = "WARN") {
39
87
  const comp = this.appObjects.getSingleton(type);
40
88
  if (!comp) {
@@ -53,22 +101,52 @@ export class AppObjectComponent {
53
101
  }
54
102
  return comp;
55
103
  }
104
+ /**
105
+ * Cleans up resources used by this component
106
+ * Removes itself from the parent AppObject if it's still attached
107
+ */
56
108
  dispose() {
57
109
  if (this.appObject.getComponent(this.type) === this) {
58
110
  this.appObject.removeComponent(this.type);
59
111
  }
60
112
  }
113
+ /**
114
+ * Logs an informational message to the application's logging system
115
+ * Messages are prefixed with the AppObject ID and component type for easier debugging
116
+ *
117
+ * @param message The message to log
118
+ */
61
119
  log(message) {
62
120
  this.appObjects.submitLog(`${this.appObject.id}/${this.type}`, message);
63
121
  }
122
+ /**
123
+ * Logs a warning message to the application's logging system
124
+ * Messages are prefixed with the AppObject ID and component type for easier debugging
125
+ *
126
+ * @param message The warning message to log
127
+ */
64
128
  warn(message) {
65
129
  this.appObjects.submitWarning(`${this.appObject.id}/${this.type}`, message);
66
130
  }
131
+ /**
132
+ * Logs an error message to the application's logging system
133
+ * Messages are prefixed with the AppObject ID and component type for easier debugging
134
+ *
135
+ * @param message The error message to log
136
+ */
67
137
  error(message) {
68
138
  this.appObjects.submitError(`${this.appObject.id}/${this.type}`, message);
69
139
  }
140
+ /**
141
+ * Creates a new component and attaches it to the specified AppObject
142
+ *
143
+ * @param appObject The parent AppObject this component will be attached to
144
+ * @param type The unique type identifier for this component
145
+ */
70
146
  constructor(appObject, type) {
147
+ /** The type category of this component */
71
148
  this.componentType = AppObjectComponentType.UNKNOWN;
149
+ /** Cache for components to avoid repeated lookups */
72
150
  this.cachedComponents = new Map();
73
151
  this.appObject = appObject;
74
152
  this.type = type;
@@ -1 +1 @@
1
- {"version":3,"file":"AppObjectComponent.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectComponent.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,qDAA2B,CAAA;IAC3B,yCAAe,CAAA;IACf,mDAAyB,CAAA;IACzB,uCAAa,CAAA;IACb,6CAAmB,CAAA;AACrB,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC;AAED,MAAM,OAAO,kBAAkB;IAI7B,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC,CAAC;IAGD,kBAAkB,CAChB,IAAY;QAEZ,IAAI,CAAC,I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{ AppObject } from \"./AppObject\";\r\nimport { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\nexport enum AppObjectComponentType {\r\n ENTITY = \"Entity\",\r\n PM = \"Presentation Manager\",\r\n UC = \"Use Case\",\r\n CONTROLLER = \"Controller\",\r\n VIEW = \"View\",\r\n UNKNOWN = \"Unknown\",\r\n}\r\n\r\nexport class AppObjectComponent {\r\n readonly componentType: AppObjectComponentType = AppObjectComponentType.UNKNOWN;\r\n readonly type: string;\r\n readonly appObject: AppObject;\r\n get appObjects(): AppObjectRepo {\r\n return this.appObject.appObjectRepo;\r\n }\r\n\r\n private cachedComponents = new Map<string, AppObjectComponent>();\r\n getCachedSingleton<T extends AppObjectComponent>(\r\n type: string\r\n ): T | undefined {\r\n if (!this.cachedComponents.has(type)) {\r\n const component = this.appObjects.getSingleton(type);\r\n if (!component) {\r\n this.warn(\"Unable to get cached singleton type \" + type);\r\n } else {\r\n this.cachedComponents.set(type, component);\r\n }\r\n }\r\n\r\n return this.cachedComponents.get(type) as T;\r\n }\r\n\r\n getCachedLocalComponent<T extends AppObjectComponent>(\r\n type: string\r\n ): T | undefined {\r\n if (!this.cachedComponents.has(type)) {\r\n const component = this.appObject.getComponent(type);\r\n\r\n if (!component) {\r\n this.warn(\"Unable to get local component of type \" + type);\r\n } else {\r\n this.cachedComponents.set(type, component);\r\n }\r\n }\r\n\r\n return this.cachedComponents.get(type) as T;\r\n }\r\n\r\n getSingleton<T extends AppObjectComponent>(\r\n type: string,\r\n logType: \"LOG\" | \"WARN\" | \"ERROR\" = \"WARN\"\r\n ): T | undefined {\r\n const comp = this.appObjects.getSingleton<T>(type);\r\n\r\n if (!comp) {\r\n const msg = \"Unable to get singleton type \" + type;\r\n switch (logType) {\r\n case \"ERROR\":\r\n this.error(msg);\r\n break;\r\n case \"LOG\":\r\n this.log(msg);\r\n break;\r\n case \"WARN\":\r\n this.warn(msg);\r\n break;\r\n }\r\n }\r\n\r\n return comp;\r\n }\r\n\r\n dispose() {\r\n if (this.appObject.getComponent(this.type) === this) {\r\n this.appObject.removeComponent(this.type);\r\n }\r\n }\r\n\r\n log(message: string) {\r\n this.appObjects.submitLog(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n warn(message: string) {\r\n this.appObjects.submitWarning(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n error(message: string) {\r\n this.appObjects.submitError(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n constructor(appObject: AppObject, type: string) {\r\n this.appObject = appObject;\r\n this.type = type;\r\n appObject.addComponent(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AppObjectComponent.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectComponent.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAN,IAAY,sBAkBX;AAlBD,WAAY,sBAAsB;IAChC,2CAA2C;IAC3C,2CAAiB,CAAA;IAEjB,oDAAoD;IACpD,qDAA2B,CAAA;IAE3B,+DAA+D;IAC/D,yCAAe,CAAA;IAEf,8CAA8C;IAC9C,mDAAyB,CAAA;IAEzB,sEAAsE;IACtE,uCAAa,CAAA;IAEb,yEAAyE;IACzE,6CAAmB,CAAA;AACrB,CAAC,EAlBW,sBAAsB,KAAtB,sBAAsB,QAkBjC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,kBAAkB;IAU7B;;;OAGG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC,CAAC;IAKD;;;;;;OAMG;IACH,kBAAkB,CAChB,IAAY;QAEZ,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,sCAAsC,GAAG,IAAI,CAAC,CAAC;YAC3D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,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACpD,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,OAAe;QACjB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACH,YAAY,SAAoB,EAAE,IAAY;QA/I9C,0CAA0C;QACjC,kBAAa,GAA2B,sBAAsB,CAAC,OAAO,CAAC;QAgBhF,qDAAqD;QAC7C,qBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;QA8H/D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import { AppObject } from \"./AppObject\";\r\nimport { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\n/**\r\n * Enumeration of the different types of components in the architecture.\r\n * Each type serves a specific purpose in the application structure.\r\n */\r\nexport enum AppObjectComponentType {\r\n /** Stores and manages application state */\r\n ENTITY = \"Entity\",\r\n \r\n /** Transforms application state into view models */\r\n PM = \"Presentation Manager\",\r\n \r\n /** Implements business logic and coordinates between layers */\r\n UC = \"Use Case\",\r\n \r\n /** Handles user inputs and external events */\r\n CONTROLLER = \"Controller\",\r\n \r\n /** Renders UI elements and interacts with the DOM/rendering system */\r\n VIEW = \"View\",\r\n \r\n /** Default type for components that don't fit the standard categories */\r\n UNKNOWN = \"Unknown\",\r\n}\r\n\r\n/**\r\n * Base class for all components in the AppObject architecture.\r\n * \r\n * Components attach to AppObjects and provide specific functionality based on their type.\r\n * The architecture follows a clean separation of concerns, with each component type\r\n * having a well-defined responsibility in the application.\r\n * \r\n * Components can communicate with each other through various mechanisms:\r\n * - Direct access via parent AppObject\r\n * - Repository-level singleton access\r\n * - Observer patterns for reactive updates\r\n */\r\nexport class AppObjectComponent {\r\n /** The type category of this component */\r\n readonly componentType: AppObjectComponentType = AppObjectComponentType.UNKNOWN;\r\n \r\n /** Unique type identifier for this specific component */\r\n readonly type: string;\r\n \r\n /** The parent AppObject this component is attached to */\r\n readonly appObject: AppObject;\r\n \r\n /**\r\n * Convenience accessor for the repository containing all AppObjects\r\n * @returns The application's AppObjectRepo\r\n */\r\n get appObjects(): AppObjectRepo {\r\n return this.appObject.appObjectRepo;\r\n }\r\n\r\n /** Cache for components to avoid repeated lookups */\r\n private cachedComponents = new Map<string, AppObjectComponent>();\r\n \r\n /**\r\n * Retrieves a singleton component of the specified type from the repository\r\n * Results are cached for better performance in repeated calls\r\n * \r\n * @param type The component type identifier to look up\r\n * @returns The singleton component cast to type T, or undefined if not found\r\n */\r\n getCachedSingleton<T extends AppObjectComponent>(\r\n type: string\r\n ): T | undefined {\r\n if (!this.cachedComponents.has(type)) {\r\n const component = this.appObjects.getSingleton(type);\r\n if (!component) {\r\n this.warn(\"Unable to get cached singleton type \" + type);\r\n } else {\r\n this.cachedComponents.set(type, component);\r\n }\r\n }\r\n\r\n return this.cachedComponents.get(type) as T;\r\n }\r\n\r\n /**\r\n * Retrieves a component from the same AppObject as this component\r\n * Results are cached for better performance in repeated calls\r\n * \r\n * @param type The component type identifier to look up\r\n * @returns The component cast to type T, or undefined if not found\r\n */\r\n getCachedLocalComponent<T extends AppObjectComponent>(\r\n type: string\r\n ): T | undefined {\r\n if (!this.cachedComponents.has(type)) {\r\n const component = this.appObject.getComponent(type);\r\n\r\n if (!component) {\r\n this.warn(\"Unable to get local component of type \" + type);\r\n } else {\r\n this.cachedComponents.set(type, component);\r\n }\r\n }\r\n\r\n return this.cachedComponents.get(type) as T;\r\n }\r\n\r\n /**\r\n * Retrieves a singleton component from the repository with customizable logging\r\n * Unlike getCachedSingleton, results are not cached\r\n * \r\n * @param type The component type identifier to look up\r\n * @param logType The severity level for logging if component isn't found\r\n * @returns The singleton component cast to type T, or undefined if not found\r\n */\r\n getSingleton<T extends AppObjectComponent>(\r\n type: string,\r\n logType: \"LOG\" | \"WARN\" | \"ERROR\" = \"WARN\"\r\n ): T | undefined {\r\n const comp = this.appObjects.getSingleton<T>(type);\r\n\r\n if (!comp) {\r\n const msg = \"Unable to get singleton type \" + type;\r\n switch (logType) {\r\n case \"ERROR\":\r\n this.error(msg);\r\n break;\r\n case \"LOG\":\r\n this.log(msg);\r\n break;\r\n case \"WARN\":\r\n this.warn(msg);\r\n break;\r\n }\r\n }\r\n\r\n return comp;\r\n }\r\n\r\n /**\r\n * Cleans up resources used by this component\r\n * Removes itself from the parent AppObject if it's still attached\r\n */\r\n dispose() {\r\n if (this.appObject.getComponent(this.type) === this) {\r\n this.appObject.removeComponent(this.type);\r\n }\r\n }\r\n\r\n /**\r\n * Logs an informational message to the application's logging system\r\n * Messages are prefixed with the AppObject ID and component type for easier debugging\r\n * \r\n * @param message The message to log\r\n */\r\n log(message: string) {\r\n this.appObjects.submitLog(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n /**\r\n * Logs a warning message to the application's logging system\r\n * Messages are prefixed with the AppObject ID and component type for easier debugging\r\n * \r\n * @param message The warning message to log\r\n */\r\n warn(message: string) {\r\n this.appObjects.submitWarning(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n /**\r\n * Logs an error message to the application's logging system\r\n * Messages are prefixed with the AppObject ID and component type for easier debugging\r\n * \r\n * @param message The error message to log\r\n */\r\n error(message: string) {\r\n this.appObjects.submitError(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n /**\r\n * Creates a new component and attaches it to the specified AppObject\r\n * \r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n this.appObject = appObject;\r\n this.type = type;\r\n appObject.addComponent(this);\r\n }\r\n}\r\n"]}
@@ -1,7 +1,29 @@
1
1
  import { AppObjectComponent, AppObjectComponentType, } from "./AppObjectComponent";
2
+ /**
3
+ * AppObjectController serves as a base controller class within the application framework.
4
+ *
5
+ * Controllers are components that handle logic-related operations for an AppObject,
6
+ * such as user input processing, state management, or business logic implementation.
7
+ * Extend this class to create specialized controllers for specific application features.
8
+ *
9
+ * @extends AppObjectComponent
10
+ * @example
11
+ * ```typescript
12
+ * class PlayerController extends AppObjectController {
13
+ * handleUserInput(input: UserInput) {
14
+ * // Process user input to control player object
15
+ * }
16
+ * }
17
+ * ```
18
+ */
2
19
  export class AppObjectController extends AppObjectComponent {
3
20
  constructor() {
4
21
  super(...arguments);
22
+ /**
23
+ * The component type identifier used to categorize this component as a controller
24
+ * This property helps the component system identify and manage controller components.
25
+ * @readonly
26
+ */
5
27
  this.componentType = AppObjectComponentType.CONTROLLER;
6
28
  }
7
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AppObjectController.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IAA3D;;QACW,kBAAa,GAAG,sBAAsB,CAAC,UAAU,CAAC;IAC7D,CAAC;CAAA","sourcesContent":["import {\r\n AppObjectComponent,\r\n AppObjectComponentType,\r\n} from \"./AppObjectComponent\";\r\n\r\nexport class AppObjectController extends AppObjectComponent {\r\n readonly componentType = AppObjectComponentType.CONTROLLER;\r\n}\r\n"]}
1
+ {"version":3,"file":"AppObjectController.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IAA3D;;QACE;;;;WAIG;QACM,kBAAa,GAAG,sBAAsB,CAAC,UAAU,CAAC;IAC7D,CAAC;CAAA","sourcesContent":["import {\r\n AppObjectComponent,\r\n AppObjectComponentType,\r\n} from \"./AppObjectComponent\";\r\n\r\n/**\r\n * AppObjectController serves as a base controller class within the application framework.\r\n *\r\n * Controllers are components that handle logic-related operations for an AppObject,\r\n * such as user input processing, state management, or business logic implementation.\r\n * Extend this class to create specialized controllers for specific application features.\r\n *\r\n * @extends AppObjectComponent\r\n * @example\r\n * ```typescript\r\n * class PlayerController extends AppObjectController {\r\n * handleUserInput(input: UserInput) {\r\n * // Process user input to control player object\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AppObjectController extends AppObjectComponent {\r\n /**\r\n * The component type identifier used to categorize this component as a controller\r\n * This property helps the component system identify and manage controller components.\r\n * @readonly\r\n */\r\n readonly componentType = AppObjectComponentType.CONTROLLER;\r\n}\r\n"]}
@@ -1,6 +1,27 @@
1
1
  import { ObserverList } from "../Entities";
2
2
  import { AppObjectComponent, AppObjectComponentType } from "./AppObjectComponent";
3
+ /**
4
+ * Entity component that manages application state
5
+ *
6
+ * AppObjectEntity is responsible for storing and managing state data within the application.
7
+ * It uses the observer pattern to notify interested parties of changes to its state.
8
+ *
9
+ * In a typical application flow:
10
+ * 1. Controllers modify entity state in response to user actions
11
+ * 2. Entities notify observers (typically PMs) of state changes
12
+ * 3. PMs transform entity state into view models
13
+ * 4. Views render based on the view models
14
+ */
3
15
  export class AppObjectEntity extends AppObjectComponent {
16
+ /**
17
+ * Cleans up resources and notifies dispose observers
18
+ *
19
+ * This method:
20
+ * 1. Removes the change observer from the parent AppObject
21
+ * 2. Notifies all dispose observers
22
+ * 3. Clears all observer lists
23
+ * 4. Calls the parent class dispose method
24
+ */
4
25
  dispose() {
5
26
  this.removeChangeObserver(this.appObject.notify);
6
27
  this.onDisposeObserverList.notify();
@@ -8,26 +29,57 @@ export class AppObjectEntity extends AppObjectComponent {
8
29
  this.onDisposeObserverList.clear();
9
30
  super.dispose();
10
31
  }
32
+ /**
33
+ * Creates a new entity component and attaches it to the specified AppObject
34
+ * Automatically adds the AppObject's notify method as a change observer
35
+ *
36
+ * @param appObject The parent AppObject this component will be attached to
37
+ * @param type The unique type identifier for this component
38
+ */
11
39
  constructor(appObject, type) {
12
40
  super(appObject, type);
41
+ /** Identifies this as an Entity component */
13
42
  this.componentType = AppObjectComponentType.ENTITY;
43
+ /** List of observers to notify when this entity is disposed */
14
44
  this.onDisposeObserverList = new ObserverList();
45
+ /**
46
+ * Adds an observer to be notified when this entity is disposed
47
+ * @param observer Function to call on disposal
48
+ */
15
49
  this.addOnDisposeObserver = (observer) => {
16
50
  this.onDisposeObserverList.add(observer);
17
51
  };
52
+ /**
53
+ * Removes a previously added dispose observer
54
+ * @param observer The observer function to remove
55
+ */
18
56
  this.removeOnDisposeObserver = (observer) => {
19
57
  this.onDisposeObserverList.remove(observer);
20
58
  };
59
+ /** List of observers to notify when this entity's state changes */
21
60
  this.onChangeObserverList = new ObserverList();
61
+ /**
62
+ * Adds an observer to be notified when this entity's state changes
63
+ * @param observer Function to call on state change
64
+ */
22
65
  this.addChangeObserver = (observer) => {
23
66
  this.onChangeObserverList.add(observer);
24
67
  };
68
+ /**
69
+ * Removes a previously added change observer
70
+ * @param observer The observer function to remove
71
+ */
25
72
  this.removeChangeObserver = (observer) => {
26
73
  this.onChangeObserverList.remove(observer);
27
74
  };
75
+ /**
76
+ * Notifies all change observers that this entity's state has changed
77
+ * This should be called by derived classes when their state changes
78
+ */
28
79
  this.notifyOnChange = () => {
29
80
  this.onChangeObserverList.notify();
30
81
  };
82
+ // When this entity changes, notify the parent AppObject
31
83
  this.addChangeObserver(appObject.notify);
32
84
  }
33
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AppObjectEntity.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAIlF,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IAuBrD,OAAO;QACL,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QAEnC,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED,YAAY,SAAoB,EAAE,IAAY;QAC5C,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;QAjCf,kBAAa,GAAG,sBAAsB,CAAC,MAAM,CAAC;QAE/C,0BAAqB,GAAG,IAAI,YAAY,EAAQ,CAAC;QACzD,yBAAoB,GAAG,CAAC,QAAiC,EAAE,EAAE;YAC3D,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC,CAAC;QACF,4BAAuB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YACpE,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC,CAAC;QAEM,yBAAoB,GAAG,IAAI,YAAY,EAAQ,CAAC;QACxD,sBAAiB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YAC9D,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC;QACF,yBAAoB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YACjE,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC;QAEF,mBAAc,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC,CAAC;QAeA,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { AppObject } from \"./AppObject\";\r\nimport { AppObjectComponent, AppObjectComponentType } from \"./AppObjectComponent\";\r\n\r\nexport type AppObjectEntityObserver = () => void;\r\n\r\nexport class AppObjectEntity extends AppObjectComponent {\r\n readonly componentType = AppObjectComponentType.ENTITY;\r\n \r\n private onDisposeObserverList = new ObserverList<void>();\r\n addOnDisposeObserver = (observer: AppObjectEntityObserver) => {\r\n this.onDisposeObserverList.add(observer);\r\n };\r\n removeOnDisposeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onDisposeObserverList.remove(observer);\r\n };\r\n\r\n private onChangeObserverList = new ObserverList<void>();\r\n addChangeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onChangeObserverList.add(observer);\r\n };\r\n removeChangeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onChangeObserverList.remove(observer);\r\n };\r\n\r\n notifyOnChange = () => {\r\n this.onChangeObserverList.notify();\r\n };\r\n\r\n dispose() {\r\n this.removeChangeObserver(this.appObject.notify);\r\n\r\n this.onDisposeObserverList.notify();\r\n this.onChangeObserverList.clear();\r\n this.onDisposeObserverList.clear();\r\n\r\n super.dispose();\r\n }\r\n\r\n constructor(appObject: AppObject, type: string) {\r\n super(appObject, type)\r\n \r\n this.addChangeObserver(appObject.notify);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AppObjectEntity.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAQlF;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IAkDrD;;;;;;;;OAQG;IACH,OAAO;QACL,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QAEnC,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,YAAY,SAAoB,EAAE,IAAY;QAC5C,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;QA5ExB,6CAA6C;QACpC,kBAAa,GAAG,sBAAsB,CAAC,MAAM,CAAC;QAEvD,+DAA+D;QACvD,0BAAqB,GAAG,IAAI,YAAY,EAAQ,CAAC;QAEzD;;;WAGG;QACH,yBAAoB,GAAG,CAAC,QAAiC,EAAE,EAAE;YAC3D,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC,CAAC;QAEF;;;WAGG;QACH,4BAAuB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YACpE,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC,CAAC;QAEF,mEAAmE;QAC3D,yBAAoB,GAAG,IAAI,YAAY,EAAQ,CAAC;QAExD;;;WAGG;QACH,sBAAiB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YAC9D,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF;;;WAGG;QACH,yBAAoB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YACjE,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC;QAEF;;;WAGG;QACH,mBAAc,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC,CAAC;QA+BA,wDAAwD;QACxD,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { AppObject } from \"./AppObject\";\r\nimport { AppObjectComponent, AppObjectComponentType } from \"./AppObjectComponent\";\r\n\r\n/**\r\n * Observer function type for entity state changes or disposal\r\n * No parameters are passed to the observer functions\r\n */\r\nexport type AppObjectEntityObserver = () => void;\r\n\r\n/**\r\n * Entity component that manages application state\r\n * \r\n * AppObjectEntity is responsible for storing and managing state data within the application.\r\n * It uses the observer pattern to notify interested parties of changes to its state.\r\n * \r\n * In a typical application flow:\r\n * 1. Controllers modify entity state in response to user actions\r\n * 2. Entities notify observers (typically PMs) of state changes\r\n * 3. PMs transform entity state into view models\r\n * 4. Views render based on the view models\r\n */\r\nexport class AppObjectEntity extends AppObjectComponent {\r\n /** Identifies this as an Entity component */\r\n readonly componentType = AppObjectComponentType.ENTITY;\r\n \r\n /** List of observers to notify when this entity is disposed */\r\n private onDisposeObserverList = new ObserverList<void>();\r\n \r\n /**\r\n * Adds an observer to be notified when this entity is disposed\r\n * @param observer Function to call on disposal\r\n */\r\n addOnDisposeObserver = (observer: AppObjectEntityObserver) => {\r\n this.onDisposeObserverList.add(observer);\r\n };\r\n \r\n /**\r\n * Removes a previously added dispose observer\r\n * @param observer The observer function to remove\r\n */\r\n removeOnDisposeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onDisposeObserverList.remove(observer);\r\n };\r\n\r\n /** List of observers to notify when this entity's state changes */\r\n private onChangeObserverList = new ObserverList<void>();\r\n \r\n /**\r\n * Adds an observer to be notified when this entity's state changes\r\n * @param observer Function to call on state change\r\n */\r\n addChangeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onChangeObserverList.add(observer);\r\n };\r\n \r\n /**\r\n * Removes a previously added change observer\r\n * @param observer The observer function to remove\r\n */\r\n removeChangeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onChangeObserverList.remove(observer);\r\n };\r\n\r\n /**\r\n * Notifies all change observers that this entity's state has changed\r\n * This should be called by derived classes when their state changes\r\n */\r\n notifyOnChange = () => {\r\n this.onChangeObserverList.notify();\r\n };\r\n\r\n /**\r\n * Cleans up resources and notifies dispose observers\r\n * \r\n * This method:\r\n * 1. Removes the change observer from the parent AppObject\r\n * 2. Notifies all dispose observers\r\n * 3. Clears all observer lists\r\n * 4. Calls the parent class dispose method\r\n */\r\n dispose() {\r\n this.removeChangeObserver(this.appObject.notify);\r\n\r\n this.onDisposeObserverList.notify();\r\n this.onChangeObserverList.clear();\r\n this.onDisposeObserverList.clear();\r\n\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Creates a new entity component and attaches it to the specified AppObject\r\n * Automatically adds the AppObject's notify method as a change observer\r\n * \r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n super(appObject, type)\r\n \r\n // When this entity changes, notify the parent AppObject\r\n this.addChangeObserver(appObject.notify);\r\n }\r\n}\r\n"]}