@vived/core 1.4.1 → 1.4.3

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 (356) hide show
  1. package/README.md +118 -20
  2. package/dist/cjs/AppObject/AppObject.js +112 -0
  3. package/dist/cjs/AppObject/AppObject.js.map +1 -0
  4. package/dist/cjs/AppObject/AppObjectComponent.js +160 -0
  5. package/dist/cjs/AppObject/AppObjectComponent.js.map +1 -0
  6. package/dist/cjs/AppObject/AppObjectController.js +34 -0
  7. package/dist/cjs/AppObject/AppObjectController.js.map +1 -0
  8. package/dist/cjs/AppObject/AppObjectEntity.js +90 -0
  9. package/dist/cjs/AppObject/AppObjectEntity.js.map +1 -0
  10. package/dist/cjs/AppObject/AppObjectEntityRepo.js +130 -0
  11. package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +1 -0
  12. package/dist/cjs/AppObject/AppObjectPM.js +86 -0
  13. package/dist/cjs/AppObject/AppObjectPM.js.map +1 -0
  14. package/dist/cjs/AppObject/AppObjectRepo.js +153 -0
  15. package/dist/cjs/AppObject/AppObjectRepo.js.map +1 -0
  16. package/dist/cjs/AppObject/AppObjectUC.js +35 -0
  17. package/dist/cjs/AppObject/AppObjectUC.js.map +1 -0
  18. package/dist/cjs/AppObject/AppObjectView.js +34 -0
  19. package/dist/cjs/AppObject/AppObjectView.js.map +1 -0
  20. package/dist/cjs/AppObject/getSingletonComponent.js +26 -0
  21. package/dist/cjs/AppObject/getSingletonComponent.js.map +1 -0
  22. package/dist/cjs/AppObject/index.js +27 -0
  23. package/dist/cjs/AppObject/index.js.map +1 -0
  24. package/dist/cjs/AppObject/printAppObjectDetails.js +18 -0
  25. package/dist/cjs/AppObject/printAppObjectDetails.js.map +1 -0
  26. package/dist/cjs/Entities/MemoizedAngle.js +44 -0
  27. package/dist/cjs/Entities/MemoizedAngle.js.map +1 -0
  28. package/dist/cjs/Entities/MemoizedBoolean.js +44 -0
  29. package/dist/cjs/Entities/MemoizedBoolean.js.map +1 -0
  30. package/dist/cjs/Entities/MemoizedColor.js +45 -0
  31. package/dist/cjs/Entities/MemoizedColor.js.map +1 -0
  32. package/dist/cjs/Entities/MemoizedNumber.js +44 -0
  33. package/dist/cjs/Entities/MemoizedNumber.js.map +1 -0
  34. package/dist/cjs/Entities/MemoizedQuaternion.js +45 -0
  35. package/dist/cjs/Entities/MemoizedQuaternion.js.map +1 -0
  36. package/dist/cjs/Entities/MemoizedString.js +44 -0
  37. package/dist/cjs/Entities/MemoizedString.js.map +1 -0
  38. package/dist/cjs/Entities/MemoizedVector2.js +45 -0
  39. package/dist/cjs/Entities/MemoizedVector2.js.map +1 -0
  40. package/dist/cjs/Entities/MemoizedVector3.js +45 -0
  41. package/dist/cjs/Entities/MemoizedVector3.js.map +1 -0
  42. package/dist/cjs/Entities/ObservableEntity.js +37 -0
  43. package/dist/cjs/Entities/ObservableEntity.js.map +1 -0
  44. package/dist/cjs/Entities/ObserverList.js +48 -0
  45. package/dist/cjs/Entities/ObserverList.js.map +1 -0
  46. package/dist/cjs/Entities/RangedNumber.js +65 -0
  47. package/dist/cjs/Entities/RangedNumber.js.map +1 -0
  48. package/dist/cjs/Entities/index.js +28 -0
  49. package/dist/cjs/Entities/index.js.map +1 -0
  50. package/dist/cjs/Types/AppBoundary.js +3 -0
  51. package/dist/cjs/Types/AppBoundary.js.map +1 -0
  52. package/dist/cjs/Types/EaseFn.js +3 -0
  53. package/dist/cjs/Types/EaseFn.js.map +1 -0
  54. package/dist/cjs/Types/PmAdapter.js +3 -0
  55. package/dist/cjs/Types/PmAdapter.js.map +1 -0
  56. package/dist/cjs/Types/SingletonPmAdapter.js +3 -0
  57. package/dist/cjs/Types/SingletonPmAdapter.js.map +1 -0
  58. package/dist/cjs/Types/index.js +21 -0
  59. package/dist/cjs/Types/index.js.map +1 -0
  60. package/dist/cjs/Utilities/LengthConverters.js +21 -0
  61. package/dist/cjs/Utilities/LengthConverters.js.map +1 -0
  62. package/dist/cjs/Utilities/LerpNumber.js +85 -0
  63. package/dist/cjs/Utilities/LerpNumber.js.map +1 -0
  64. package/dist/cjs/Utilities/addAlphaToHex.js +16 -0
  65. package/dist/cjs/Utilities/addAlphaToHex.js.map +1 -0
  66. package/dist/cjs/Utilities/alphaToHex.js +21 -0
  67. package/dist/cjs/Utilities/alphaToHex.js.map +1 -0
  68. package/dist/cjs/Utilities/degreesToRadians.js +7 -0
  69. package/dist/cjs/Utilities/degreesToRadians.js.map +1 -0
  70. package/dist/cjs/Utilities/downloadFile.js +14 -0
  71. package/dist/cjs/Utilities/downloadFile.js.map +1 -0
  72. package/dist/cjs/Utilities/easeFunctions.js +208 -0
  73. package/dist/cjs/Utilities/easeFunctions.js.map +1 -0
  74. package/dist/cjs/Utilities/generateUniqueID.js +8 -0
  75. package/dist/cjs/Utilities/generateUniqueID.js.map +1 -0
  76. package/dist/cjs/Utilities/index.js +25 -0
  77. package/dist/cjs/Utilities/index.js.map +1 -0
  78. package/dist/cjs/Utilities/interpolateNumber.js +18 -0
  79. package/dist/cjs/Utilities/interpolateNumber.js.map +1 -0
  80. package/dist/cjs/ValueObjects/Angle.js +47 -0
  81. package/dist/cjs/ValueObjects/Angle.js.map +1 -0
  82. package/dist/cjs/ValueObjects/Color.js +859 -0
  83. package/dist/cjs/ValueObjects/Color.js.map +1 -0
  84. package/dist/cjs/ValueObjects/LineSegment2D.js +72 -0
  85. package/dist/cjs/ValueObjects/LineSegment2D.js.map +1 -0
  86. package/dist/cjs/ValueObjects/Matrix.js +466 -0
  87. package/dist/cjs/ValueObjects/Matrix.js.map +1 -0
  88. package/dist/cjs/ValueObjects/ParametricLine.js +77 -0
  89. package/dist/cjs/ValueObjects/ParametricLine.js.map +1 -0
  90. package/dist/cjs/ValueObjects/ParametricPlane.js +65 -0
  91. package/dist/cjs/ValueObjects/ParametricPlane.js.map +1 -0
  92. package/dist/cjs/ValueObjects/Quaternion.js +290 -0
  93. package/dist/cjs/ValueObjects/Quaternion.js.map +1 -0
  94. package/dist/cjs/ValueObjects/Rectangle.js +24 -0
  95. package/dist/cjs/ValueObjects/Rectangle.js.map +1 -0
  96. package/dist/cjs/ValueObjects/Vector2.js +191 -0
  97. package/dist/cjs/ValueObjects/Vector2.js.map +1 -0
  98. package/dist/cjs/ValueObjects/Vector3.js +231 -0
  99. package/dist/cjs/ValueObjects/Vector3.js.map +1 -0
  100. package/dist/cjs/ValueObjects/Version.js +171 -0
  101. package/dist/cjs/ValueObjects/Version.js.map +1 -0
  102. package/dist/cjs/ValueObjects/index.js +28 -0
  103. package/dist/cjs/ValueObjects/index.js.map +1 -0
  104. package/dist/cjs/index.js +22 -0
  105. package/dist/cjs/index.js.map +1 -0
  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/Types/PmAdapter.js.map +1 -1
  149. package/dist/esm/Types/SingletonPmAdapter.js.map +1 -1
  150. package/dist/esm/ValueObjects/Angle.js +1 -1
  151. package/dist/esm/ValueObjects/Angle.js.map +1 -1
  152. package/dist/esm/ValueObjects/LineSegment2D.js +6 -6
  153. package/dist/esm/ValueObjects/LineSegment2D.js.map +1 -1
  154. package/dist/esm/ValueObjects/Matrix.js +6 -6
  155. package/dist/esm/ValueObjects/Matrix.js.map +1 -1
  156. package/dist/esm/ValueObjects/Quaternion.js +17 -17
  157. package/dist/esm/ValueObjects/Quaternion.js.map +1 -1
  158. package/dist/esm/ValueObjects/Vector2.js +15 -8
  159. package/dist/esm/ValueObjects/Vector2.js.map +1 -1
  160. package/dist/types/AppObject/AppObject.d.ts +42 -0
  161. package/dist/types/AppObject/AppObject.d.ts.map +1 -1
  162. package/dist/types/AppObject/AppObjectComponent.d.ts +80 -0
  163. package/dist/types/AppObject/AppObjectComponent.d.ts.map +1 -1
  164. package/dist/types/AppObject/AppObjectController.d.ts +22 -0
  165. package/dist/types/AppObject/AppObjectController.d.ts.map +1 -1
  166. package/dist/types/AppObject/AppObjectEntity.d.ts +55 -0
  167. package/dist/types/AppObject/AppObjectEntity.d.ts.map +1 -1
  168. package/dist/types/AppObject/AppObjectEntityRepo.d.ts +75 -0
  169. package/dist/types/AppObject/AppObjectEntityRepo.d.ts.map +1 -1
  170. package/dist/types/AppObject/AppObjectPM.d.ts +53 -0
  171. package/dist/types/AppObject/AppObjectPM.d.ts.map +1 -1
  172. package/dist/types/AppObject/AppObjectRepo.d.ts +124 -0
  173. package/dist/types/AppObject/AppObjectRepo.d.ts.map +1 -1
  174. package/dist/types/AppObject/AppObjectUC.d.ts +23 -0
  175. package/dist/types/AppObject/AppObjectUC.d.ts.map +1 -1
  176. package/dist/types/AppObject/AppObjectView.d.ts +22 -0
  177. package/dist/types/AppObject/AppObjectView.d.ts.map +1 -1
  178. package/dist/types/AppObject/getSingletonComponent.d.ts +19 -0
  179. package/dist/types/AppObject/getSingletonComponent.d.ts.map +1 -1
  180. package/dist/types/Entities/MemoizedAngle.d.ts +21 -0
  181. package/dist/types/Entities/MemoizedAngle.d.ts.map +1 -1
  182. package/dist/types/Entities/MemoizedBoolean.d.ts +21 -0
  183. package/dist/types/Entities/MemoizedBoolean.d.ts.map +1 -1
  184. package/dist/types/Entities/MemoizedColor.d.ts +21 -0
  185. package/dist/types/Entities/MemoizedColor.d.ts.map +1 -1
  186. package/dist/types/Entities/MemoizedNumber.d.ts +21 -0
  187. package/dist/types/Entities/MemoizedNumber.d.ts.map +1 -1
  188. package/dist/types/Entities/MemoizedQuaternion.d.ts +21 -0
  189. package/dist/types/Entities/MemoizedQuaternion.d.ts.map +1 -1
  190. package/dist/types/Entities/MemoizedString.d.ts +21 -0
  191. package/dist/types/Entities/MemoizedString.d.ts.map +1 -1
  192. package/dist/types/Entities/MemoizedVector2.d.ts +21 -0
  193. package/dist/types/Entities/MemoizedVector2.d.ts.map +1 -1
  194. package/dist/types/Entities/MemoizedVector3.d.ts +21 -0
  195. package/dist/types/Entities/MemoizedVector3.d.ts.map +1 -1
  196. package/dist/types/Entities/ObservableEntity.d.ts +20 -0
  197. package/dist/types/Entities/ObservableEntity.d.ts.map +1 -1
  198. package/dist/types/Entities/ObserverList.d.ts +21 -0
  199. package/dist/types/Entities/ObserverList.d.ts.map +1 -1
  200. package/dist/types/Entities/RangedNumber.d.ts +37 -0
  201. package/dist/types/Entities/RangedNumber.d.ts.map +1 -1
  202. package/dist/types/Types/PmAdapter.d.ts +60 -0
  203. package/dist/types/Types/PmAdapter.d.ts.map +1 -1
  204. package/dist/types/Types/SingletonPmAdapter.d.ts +55 -0
  205. package/dist/types/Types/SingletonPmAdapter.d.ts.map +1 -1
  206. package/dist/types/ValueObjects/Angle.d.ts +1 -1
  207. package/dist/types/ValueObjects/Matrix.d.ts +5 -5
  208. package/dist/types/ValueObjects/Matrix.d.ts.map +1 -1
  209. package/dist/types/ValueObjects/Quaternion.d.ts +17 -17
  210. package/dist/types/ValueObjects/Vector2.d.ts +8 -3
  211. package/dist/types/ValueObjects/Vector2.d.ts.map +1 -1
  212. package/package.json +58 -55
  213. package/dist/esm/AppObject/AppObject.test.js +0 -110
  214. package/dist/esm/AppObject/AppObject.test.js.map +0 -1
  215. package/dist/esm/AppObject/AppObjectComponent.test.js +0 -130
  216. package/dist/esm/AppObject/AppObjectComponent.test.js.map +0 -1
  217. package/dist/esm/AppObject/AppObjectEntity.test.js +0 -106
  218. package/dist/esm/AppObject/AppObjectEntity.test.js.map +0 -1
  219. package/dist/esm/AppObject/AppObjectEntityRepo.test.js +0 -147
  220. package/dist/esm/AppObject/AppObjectEntityRepo.test.js.map +0 -1
  221. package/dist/esm/AppObject/AppObjectPM.test.js +0 -101
  222. package/dist/esm/AppObject/AppObjectPM.test.js.map +0 -1
  223. package/dist/esm/AppObject/AppObjectRepo.test.js +0 -211
  224. package/dist/esm/AppObject/AppObjectRepo.test.js.map +0 -1
  225. package/dist/esm/AppObject/getSingletonComponent.test.js +0 -11
  226. package/dist/esm/AppObject/getSingletonComponent.test.js.map +0 -1
  227. package/dist/esm/Entities/MemoizedAngle.test.js +0 -28
  228. package/dist/esm/Entities/MemoizedAngle.test.js.map +0 -1
  229. package/dist/esm/Entities/MemoizedBoolean.test.js +0 -32
  230. package/dist/esm/Entities/MemoizedBoolean.test.js.map +0 -1
  231. package/dist/esm/Entities/MemoizedColor.test.js +0 -30
  232. package/dist/esm/Entities/MemoizedColor.test.js.map +0 -1
  233. package/dist/esm/Entities/MemoizedNumber.test.js +0 -27
  234. package/dist/esm/Entities/MemoizedNumber.test.js.map +0 -1
  235. package/dist/esm/Entities/MemoizedQuaternion.test.js +0 -30
  236. package/dist/esm/Entities/MemoizedQuaternion.test.js.map +0 -1
  237. package/dist/esm/Entities/MemoizedString.test.js +0 -27
  238. package/dist/esm/Entities/MemoizedString.test.js.map +0 -1
  239. package/dist/esm/Entities/MemoizedVector2.test.js +0 -30
  240. package/dist/esm/Entities/MemoizedVector2.test.js.map +0 -1
  241. package/dist/esm/Entities/MemoizedVector3.test.js +0 -30
  242. package/dist/esm/Entities/MemoizedVector3.test.js.map +0 -1
  243. package/dist/esm/Entities/ObservableEntity.test.js +0 -23
  244. package/dist/esm/Entities/ObservableEntity.test.js.map +0 -1
  245. package/dist/esm/Entities/ObserverList.test.js +0 -42
  246. package/dist/esm/Entities/ObserverList.test.js.map +0 -1
  247. package/dist/esm/Entities/RangedNumber.test.js +0 -94
  248. package/dist/esm/Entities/RangedNumber.test.js.map +0 -1
  249. package/dist/esm/Utilities/LengthConverters.test.js +0 -22
  250. package/dist/esm/Utilities/LengthConverters.test.js.map +0 -1
  251. package/dist/esm/Utilities/LerpNumber.test.js +0 -88
  252. package/dist/esm/Utilities/LerpNumber.test.js.map +0 -1
  253. package/dist/esm/Utilities/addAlphaToHex.test.js +0 -32
  254. package/dist/esm/Utilities/addAlphaToHex.test.js.map +0 -1
  255. package/dist/esm/Utilities/alphaToHex.test.js +0 -73
  256. package/dist/esm/Utilities/alphaToHex.test.js.map +0 -1
  257. package/dist/esm/Utilities/degreesToRadians.test.js +0 -7
  258. package/dist/esm/Utilities/degreesToRadians.test.js.map +0 -1
  259. package/dist/esm/Utilities/easeFunctions.test.js +0 -207
  260. package/dist/esm/Utilities/easeFunctions.test.js.map +0 -1
  261. package/dist/esm/Utilities/interpolateNumber.test.js +0 -24
  262. package/dist/esm/Utilities/interpolateNumber.test.js.map +0 -1
  263. package/dist/esm/ValueObjects/Angle.test.js +0 -26
  264. package/dist/esm/ValueObjects/Angle.test.js.map +0 -1
  265. package/dist/esm/ValueObjects/Color.test.js +0 -145
  266. package/dist/esm/ValueObjects/Color.test.js.map +0 -1
  267. package/dist/esm/ValueObjects/LineSegment2D.test.js +0 -100
  268. package/dist/esm/ValueObjects/LineSegment2D.test.js.map +0 -1
  269. package/dist/esm/ValueObjects/Matrix.test.js +0 -383
  270. package/dist/esm/ValueObjects/Matrix.test.js.map +0 -1
  271. package/dist/esm/ValueObjects/ParametricLine.test.js +0 -124
  272. package/dist/esm/ValueObjects/ParametricLine.test.js.map +0 -1
  273. package/dist/esm/ValueObjects/ParametricPlane.test.js +0 -99
  274. package/dist/esm/ValueObjects/ParametricPlane.test.js.map +0 -1
  275. package/dist/esm/ValueObjects/Quaternion.test.js +0 -238
  276. package/dist/esm/ValueObjects/Quaternion.test.js.map +0 -1
  277. package/dist/esm/ValueObjects/Rectangle.test.js +0 -30
  278. package/dist/esm/ValueObjects/Rectangle.test.js.map +0 -1
  279. package/dist/esm/ValueObjects/Vector2.test.js +0 -134
  280. package/dist/esm/ValueObjects/Vector2.test.js.map +0 -1
  281. package/dist/esm/ValueObjects/Vector3.test.js +0 -186
  282. package/dist/esm/ValueObjects/Vector3.test.js.map +0 -1
  283. package/dist/esm/ValueObjects/Version.test.js +0 -308
  284. package/dist/esm/ValueObjects/Version.test.js.map +0 -1
  285. package/dist/types/AppObject/AppObject.test.d.ts +0 -7
  286. package/dist/types/AppObject/AppObject.test.d.ts.map +0 -1
  287. package/dist/types/AppObject/AppObjectComponent.test.d.ts +0 -2
  288. package/dist/types/AppObject/AppObjectComponent.test.d.ts.map +0 -1
  289. package/dist/types/AppObject/AppObjectEntity.test.d.ts +0 -2
  290. package/dist/types/AppObject/AppObjectEntity.test.d.ts.map +0 -1
  291. package/dist/types/AppObject/AppObjectEntityRepo.test.d.ts +0 -2
  292. package/dist/types/AppObject/AppObjectEntityRepo.test.d.ts.map +0 -1
  293. package/dist/types/AppObject/AppObjectPM.test.d.ts +0 -2
  294. package/dist/types/AppObject/AppObjectPM.test.d.ts.map +0 -1
  295. package/dist/types/AppObject/AppObjectRepo.test.d.ts +0 -2
  296. package/dist/types/AppObject/AppObjectRepo.test.d.ts.map +0 -1
  297. package/dist/types/AppObject/getSingletonComponent.test.d.ts +0 -2
  298. package/dist/types/AppObject/getSingletonComponent.test.d.ts.map +0 -1
  299. package/dist/types/Entities/MemoizedAngle.test.d.ts +0 -2
  300. package/dist/types/Entities/MemoizedAngle.test.d.ts.map +0 -1
  301. package/dist/types/Entities/MemoizedBoolean.test.d.ts +0 -2
  302. package/dist/types/Entities/MemoizedBoolean.test.d.ts.map +0 -1
  303. package/dist/types/Entities/MemoizedColor.test.d.ts +0 -2
  304. package/dist/types/Entities/MemoizedColor.test.d.ts.map +0 -1
  305. package/dist/types/Entities/MemoizedNumber.test.d.ts +0 -2
  306. package/dist/types/Entities/MemoizedNumber.test.d.ts.map +0 -1
  307. package/dist/types/Entities/MemoizedQuaternion.test.d.ts +0 -2
  308. package/dist/types/Entities/MemoizedQuaternion.test.d.ts.map +0 -1
  309. package/dist/types/Entities/MemoizedString.test.d.ts +0 -2
  310. package/dist/types/Entities/MemoizedString.test.d.ts.map +0 -1
  311. package/dist/types/Entities/MemoizedVector2.test.d.ts +0 -2
  312. package/dist/types/Entities/MemoizedVector2.test.d.ts.map +0 -1
  313. package/dist/types/Entities/MemoizedVector3.test.d.ts +0 -2
  314. package/dist/types/Entities/MemoizedVector3.test.d.ts.map +0 -1
  315. package/dist/types/Entities/ObservableEntity.test.d.ts +0 -2
  316. package/dist/types/Entities/ObservableEntity.test.d.ts.map +0 -1
  317. package/dist/types/Entities/ObserverList.test.d.ts +0 -2
  318. package/dist/types/Entities/ObserverList.test.d.ts.map +0 -1
  319. package/dist/types/Entities/RangedNumber.test.d.ts +0 -2
  320. package/dist/types/Entities/RangedNumber.test.d.ts.map +0 -1
  321. package/dist/types/Utilities/LengthConverters.test.d.ts +0 -2
  322. package/dist/types/Utilities/LengthConverters.test.d.ts.map +0 -1
  323. package/dist/types/Utilities/LerpNumber.test.d.ts +0 -2
  324. package/dist/types/Utilities/LerpNumber.test.d.ts.map +0 -1
  325. package/dist/types/Utilities/addAlphaToHex.test.d.ts +0 -2
  326. package/dist/types/Utilities/addAlphaToHex.test.d.ts.map +0 -1
  327. package/dist/types/Utilities/alphaToHex.test.d.ts +0 -2
  328. package/dist/types/Utilities/alphaToHex.test.d.ts.map +0 -1
  329. package/dist/types/Utilities/degreesToRadians.test.d.ts +0 -2
  330. package/dist/types/Utilities/degreesToRadians.test.d.ts.map +0 -1
  331. package/dist/types/Utilities/easeFunctions.test.d.ts +0 -2
  332. package/dist/types/Utilities/easeFunctions.test.d.ts.map +0 -1
  333. package/dist/types/Utilities/interpolateNumber.test.d.ts +0 -2
  334. package/dist/types/Utilities/interpolateNumber.test.d.ts.map +0 -1
  335. package/dist/types/ValueObjects/Angle.test.d.ts +0 -2
  336. package/dist/types/ValueObjects/Angle.test.d.ts.map +0 -1
  337. package/dist/types/ValueObjects/Color.test.d.ts +0 -2
  338. package/dist/types/ValueObjects/Color.test.d.ts.map +0 -1
  339. package/dist/types/ValueObjects/LineSegment2D.test.d.ts +0 -2
  340. package/dist/types/ValueObjects/LineSegment2D.test.d.ts.map +0 -1
  341. package/dist/types/ValueObjects/Matrix.test.d.ts +0 -2
  342. package/dist/types/ValueObjects/Matrix.test.d.ts.map +0 -1
  343. package/dist/types/ValueObjects/ParametricLine.test.d.ts +0 -2
  344. package/dist/types/ValueObjects/ParametricLine.test.d.ts.map +0 -1
  345. package/dist/types/ValueObjects/ParametricPlane.test.d.ts +0 -2
  346. package/dist/types/ValueObjects/ParametricPlane.test.d.ts.map +0 -1
  347. package/dist/types/ValueObjects/Quaternion.test.d.ts +0 -2
  348. package/dist/types/ValueObjects/Quaternion.test.d.ts.map +0 -1
  349. package/dist/types/ValueObjects/Rectangle.test.d.ts +0 -2
  350. package/dist/types/ValueObjects/Rectangle.test.d.ts.map +0 -1
  351. package/dist/types/ValueObjects/Vector2.test.d.ts +0 -2
  352. package/dist/types/ValueObjects/Vector2.test.d.ts.map +0 -1
  353. package/dist/types/ValueObjects/Vector3.test.d.ts +0 -2
  354. package/dist/types/ValueObjects/Vector3.test.d.ts.map +0 -1
  355. package/dist/types/ValueObjects/Version.test.d.ts +0 -2
  356. package/dist/types/ValueObjects/Version.test.d.ts.map +0 -1
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectEntityRepo = void 0;
4
+ const Entities_1 = require("../Entities");
5
+ const AppObjectEntity_1 = require("./AppObjectEntity");
6
+ /**
7
+ * A repository for managing collections of AppObjectEntity instances.
8
+ *
9
+ * This generic class provides a centralized way to store, retrieve, and manage
10
+ * entities that are associated with specific AppObjects. It implements the observer
11
+ * pattern to notify listeners when entities are added or removed.
12
+ *
13
+ * @template T - The type of entities managed by this repository, must extend AppObjectEntity
14
+ * @extends AppObjectEntity
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Create a repository for player entities
19
+ * const playerRepo = new AppObjectEntityRepo<PlayerEntity>();
20
+ *
21
+ * // Add a new player
22
+ * const player = new PlayerEntity(appObject);
23
+ * playerRepo.add(player);
24
+ *
25
+ * // Get a player by its AppObject ID
26
+ * const retrievedPlayer = playerRepo.getForAppObject("player1");
27
+ * ```
28
+ */
29
+ class AppObjectEntityRepo extends AppObjectEntity_1.AppObjectEntity {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.entityLookup = new Map();
33
+ this.onEntityAddedObservers = new Entities_1.ObserverList();
34
+ /**
35
+ * Registers an observer to be notified when an entity is added to the repository.
36
+ *
37
+ * @param {(addedEntity: T) => void} observer - The callback function to invoke when an entity is added
38
+ */
39
+ this.addEntityAddedObserver = (observer) => {
40
+ this.onEntityAddedObservers.add(observer);
41
+ };
42
+ /**
43
+ * Removes an observer previously registered for entity addition notifications.
44
+ *
45
+ * @param {(addedEntity: T) => void} observer - The callback function to remove
46
+ */
47
+ this.removeEntityAddedObserver = (observer) => {
48
+ this.onEntityAddedObservers.remove(observer);
49
+ };
50
+ this.onEntityRemovedObservers = new Entities_1.ObserverList();
51
+ /**
52
+ * Registers an observer to be notified when an entity is removed from the repository.
53
+ *
54
+ * @param {(removedEntity: T) => void} observer - The callback function to invoke when an entity is removed
55
+ */
56
+ this.addEntityRemovedObserver = (observer) => {
57
+ this.onEntityRemovedObservers.add(observer);
58
+ };
59
+ /**
60
+ * Removes an observer previously registered for entity removal notifications.
61
+ *
62
+ * @param {(removedEntity: T) => void} observer - The callback function to remove
63
+ */
64
+ this.removeEntityRemovedObserver = (observer) => {
65
+ this.onEntityRemovedObservers.remove(observer);
66
+ };
67
+ /**
68
+ * Checks if an entity exists for the given AppObject ID.
69
+ *
70
+ * @param {string} appObjectID - The ID of the AppObject
71
+ * @returns {boolean} True if an entity exists for the given AppObject ID, false otherwise
72
+ */
73
+ this.hasForAppObject = (appObjectID) => {
74
+ return this.entityLookup.has(appObjectID);
75
+ };
76
+ /**
77
+ * Removes the entity associated with the specified AppObject ID.
78
+ *
79
+ * Notifies all registered observers after the entity is removed.
80
+ *
81
+ * @param {string} id - The ID of the AppObject whose entity should be removed
82
+ */
83
+ this.removeForAppObject = (id) => {
84
+ const existing = this.entityLookup.get(id);
85
+ if (!existing)
86
+ return;
87
+ this.entityLookup.delete(id);
88
+ existing.removeChangeObserver(this.notifyOnChange);
89
+ this.notifyOnChange();
90
+ this.onEntityRemovedObservers.notify(existing);
91
+ };
92
+ /**
93
+ * Gets the entity associated with the specified AppObject ID.
94
+ *
95
+ * @param {string} appObjectID - The ID of the AppObject
96
+ * @returns {T | undefined} The entity if found, undefined otherwise
97
+ */
98
+ this.getForAppObject = (appObjectID) => {
99
+ return this.entityLookup.get(appObjectID);
100
+ };
101
+ /**
102
+ * Gets all entities in the repository.
103
+ *
104
+ * @returns {T[]} An array of all entities
105
+ */
106
+ this.getAll = () => {
107
+ return Array.from(this.entityLookup.values());
108
+ };
109
+ }
110
+ /**
111
+ * Adds an entity to the repository.
112
+ *
113
+ * If an entity with the same AppObject ID already exists, it is replaced.
114
+ * Notifies all registered observers after the entity is added.
115
+ *
116
+ * @param {T} entity - The entity to add
117
+ */
118
+ add(entity) {
119
+ const existing = this.entityLookup.get(entity.appObject.id);
120
+ if (existing) {
121
+ existing.removeChangeObserver(this.notifyOnChange);
122
+ }
123
+ this.entityLookup.set(entity.appObject.id, entity);
124
+ entity.addChangeObserver(this.notifyOnChange);
125
+ this.notifyOnChange();
126
+ this.onEntityAddedObservers.notify(entity);
127
+ }
128
+ }
129
+ exports.AppObjectEntityRepo = AppObjectEntityRepo;
130
+ //# sourceMappingURL=AppObjectEntityRepo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectEntityRepo.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntityRepo.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAC3C,uDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,mBAEX,SAAQ,iCAAe;IAFzB;;QAGU,iBAAY,GAAG,IAAI,GAAG,EAAa,CAAC;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,CAAC;QAEF;;;;;WAKG;QACH,oBAAe,GAAG,CAAC,WAAmB,EAAiB,EAAE;YACvD,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC5C,CAAC,CAAC;QAEF;;;;WAIG;QACH,WAAM,GAAG,GAAQ,EAAE;YACjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC;IAvDC;;;;;;;OAOG;IACH,GAAG,CAAC,MAAS;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC5D,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CAqCF;AA9GD,kDA8GC","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { AppObjectEntity } from \"./AppObjectEntity\";\r\n\r\n/**\r\n * A repository for managing collections of AppObjectEntity instances.\r\n *\r\n * This generic class provides a centralized way to store, retrieve, and manage\r\n * entities that are associated with specific AppObjects. It implements the observer\r\n * pattern to notify listeners when entities are added or removed.\r\n *\r\n * @template T - The type of entities managed by this repository, must extend AppObjectEntity\r\n * @extends AppObjectEntity\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a repository for player entities\r\n * const playerRepo = new AppObjectEntityRepo<PlayerEntity>();\r\n *\r\n * // Add a new player\r\n * const player = new PlayerEntity(appObject);\r\n * playerRepo.add(player);\r\n *\r\n * // Get a player by its AppObject ID\r\n * const retrievedPlayer = playerRepo.getForAppObject(\"player1\");\r\n * ```\r\n */\r\nexport class AppObjectEntityRepo<\r\n T extends AppObjectEntity,\r\n> extends AppObjectEntity {\r\n private entityLookup = new Map<string, T>();\r\n\r\n private onEntityAddedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is added to the repository.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to invoke when an entity is added\r\n */\r\n addEntityAddedObserver = (observer: (addedEntity: T) => void) => {\r\n this.onEntityAddedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity addition notifications.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityAddedObserver = (observer: (addedEntity: T) => void): void => {\r\n this.onEntityAddedObservers.remove(observer);\r\n };\r\n\r\n private onEntityRemovedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is removed from the repository.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to invoke when an entity is removed\r\n */\r\n addEntityRemovedObserver = (observer: (removedEntity: T) => void) => {\r\n this.onEntityRemovedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity removal notifications.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityRemovedObserver = (\r\n observer: (removedEntity: T) => void\r\n ): void => {\r\n this.onEntityRemovedObservers.remove(observer);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given AppObject ID, false otherwise\r\n */\r\n hasForAppObject = (appObjectID: string): boolean => {\r\n return this.entityLookup.has(appObjectID);\r\n };\r\n\r\n /**\r\n * Adds an entity to the repository.\r\n *\r\n * If an entity with the same AppObject ID already exists, it is replaced.\r\n * Notifies all registered observers after the entity is added.\r\n *\r\n * @param {T} entity - The entity to add\r\n */\r\n add(entity: T) {\r\n const existing = this.entityLookup.get(entity.appObject.id);\r\n if (existing) {\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n }\r\n\r\n this.entityLookup.set(entity.appObject.id, entity);\r\n entity.addChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityAddedObservers.notify(entity);\r\n }\r\n\r\n /**\r\n * Removes the entity associated with the specified AppObject ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n */\r\n removeForAppObject = (id: string) => {\r\n const existing = this.entityLookup.get(id);\r\n if (!existing) return;\r\n\r\n this.entityLookup.delete(id);\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityRemovedObservers.notify(existing);\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n */\r\n getForAppObject = (appObjectID: string): T | undefined => {\r\n return this.entityLookup.get(appObjectID);\r\n };\r\n\r\n /**\r\n * Gets all entities in the repository.\r\n *\r\n * @returns {T[]} An array of all entities\r\n */\r\n getAll = (): T[] => {\r\n return Array.from(this.entityLookup.values());\r\n };\r\n}\r\n"]}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectPM = void 0;
4
+ const Entities_1 = require("../Entities");
5
+ const AppObjectComponent_1 = require("./AppObjectComponent");
6
+ /**
7
+ * Presentation Manager (PM) component that transforms application state into view models
8
+ *
9
+ * AppObjectPM acts as a mediator between application state (entities) and views.
10
+ * It transforms raw application data into a format that's optimized for presentation,
11
+ * implementing the presentation model or MVVM pattern.
12
+ *
13
+ * A PM typically:
14
+ * 1. Observes entity changes
15
+ * 2. Transforms entity data into view models
16
+ * 3. Notifies attached views when view models change
17
+ * 4. Handles view model caching and optimization
18
+ *
19
+ * @typeparam T The view model type this PM produces
20
+ */
21
+ class AppObjectPM extends AppObjectComponent_1.AppObjectComponent {
22
+ constructor() {
23
+ super(...arguments);
24
+ /** Identifies this as a Presentation Manager component */
25
+ this.componentType = AppObjectComponent_1.AppObjectComponentType.PM;
26
+ /** List of view update functions to notify when the view model changes */
27
+ this.observerList = new Entities_1.ObserverList();
28
+ }
29
+ /**
30
+ * Gets the most recently generated view model
31
+ * @returns The last view model or undefined if none has been generated
32
+ */
33
+ get lastVM() {
34
+ return this._lastVM;
35
+ }
36
+ /**
37
+ * Registers a view update function to be called when the view model changes
38
+ * If a view model already exists, the provided function is called immediately with that model
39
+ *
40
+ * @param updateView Function to call with updated view models
41
+ */
42
+ addView(updateView) {
43
+ this.observerList.add(updateView);
44
+ // Immediately update the view with current view model if one exists
45
+ if (this._lastVM !== undefined) {
46
+ updateView(this._lastVM);
47
+ }
48
+ }
49
+ /**
50
+ * Unregisters a previously added view update function
51
+ *
52
+ * @param updateView The view update function to remove
53
+ */
54
+ removeView(updateView) {
55
+ this.observerList.remove(updateView);
56
+ }
57
+ /**
58
+ * Updates the view model and notifies all registered views if the model has changed
59
+ * This method should be called by derived classes when the view model needs to be updated
60
+ *
61
+ * The method performs equality checking to prevent unnecessary updates when
62
+ * the new view model is equivalent to the previous one
63
+ *
64
+ * @param vm The new view model
65
+ */
66
+ doUpdateView(vm) {
67
+ // Skip update if the view model hasn't changed
68
+ if (this._lastVM && this.vmsAreEqual(this._lastVM, vm)) {
69
+ return;
70
+ }
71
+ this._lastVM = vm;
72
+ this.observerList.notify(vm);
73
+ }
74
+ /**
75
+ * Cleans up resources and detaches this PM from its parent AppObject
76
+ */
77
+ dispose() {
78
+ this.observerList.clear();
79
+ if (this.appObject.getComponent(this.type) === this) {
80
+ this.appObject.removeComponent(this.type);
81
+ }
82
+ super.dispose();
83
+ }
84
+ }
85
+ exports.AppObjectPM = AppObjectPM;
86
+ //# sourceMappingURL=AppObjectPM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectPM.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectPM.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAC3C,6DAAkF;AAElF;;;;;;;;;;;;;;GAcG;AACH,MAAsB,WAAe,SAAQ,uCAAkB;IAA/D;;QACE,0DAA0D;QACjD,kBAAa,GAAG,2CAAsB,CAAC,EAAE,CAAC;QAuBnD,0EAA0E;QAClE,iBAAY,GAAG,IAAI,uBAAY,EAAK,CAAC;IAuD/C,CAAC;IAhEC;;;OAGG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAKD;;;;;OAKG;IACH,OAAO,CAAC,UAA2B;QACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAElC,oEAAoE;QACpE,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC/B,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,UAA2B;QACpC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAK;QAChB,+CAA+C;QAC/C,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;YACvD,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,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;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAjFD,kCAiFC","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { AppObjectComponent, AppObjectComponentType } from \"./AppObjectComponent\";\r\n\r\n/**\r\n * Presentation Manager (PM) component that transforms application state into view models\r\n * \r\n * AppObjectPM acts as a mediator between application state (entities) and views.\r\n * It transforms raw application data into a format that's optimized for presentation,\r\n * implementing the presentation model or MVVM pattern.\r\n * \r\n * A PM typically:\r\n * 1. Observes entity changes\r\n * 2. Transforms entity data into view models\r\n * 3. Notifies attached views when view models change\r\n * 4. Handles view model caching and optimization\r\n * \r\n * @typeparam T The view model type this PM produces\r\n */\r\nexport abstract class AppObjectPM<T> extends AppObjectComponent {\r\n /** Identifies this as a Presentation Manager component */\r\n readonly componentType = AppObjectComponentType.PM;\r\n \r\n /**\r\n * Compares two view models to determine if they're equivalent\r\n * Used to prevent unnecessary view updates when the view model hasn't changed\r\n * \r\n * @param a First view model to compare\r\n * @param b Second view model to compare\r\n * @returns True if the view models are considered equal, false otherwise\r\n */\r\n abstract vmsAreEqual(a: T, b: T): boolean;\r\n\r\n /** The most recently generated view model */\r\n private _lastVM?: T;\r\n \r\n /**\r\n * Gets the most recently generated view model\r\n * @returns The last view model or undefined if none has been generated\r\n */\r\n get lastVM(): T | undefined {\r\n return this._lastVM;\r\n }\r\n\r\n /** List of view update functions to notify when the view model changes */\r\n private observerList = new ObserverList<T>();\r\n\r\n /**\r\n * Registers a view update function to be called when the view model changes\r\n * If a view model already exists, the provided function is called immediately with that model\r\n * \r\n * @param updateView Function to call with updated view models\r\n */\r\n addView(updateView: (vm: T) => void): void {\r\n this.observerList.add(updateView);\r\n\r\n // Immediately update the view with current view model if one exists\r\n if (this._lastVM !== undefined) {\r\n updateView(this._lastVM);\r\n }\r\n }\r\n\r\n /**\r\n * Unregisters a previously added view update function\r\n * \r\n * @param updateView The view update function to remove\r\n */\r\n removeView(updateView: (vm: T) => void): void {\r\n this.observerList.remove(updateView);\r\n }\r\n\r\n /**\r\n * Updates the view model and notifies all registered views if the model has changed\r\n * This method should be called by derived classes when the view model needs to be updated\r\n * \r\n * The method performs equality checking to prevent unnecessary updates when\r\n * the new view model is equivalent to the previous one\r\n * \r\n * @param vm The new view model\r\n */\r\n doUpdateView(vm: T) {\r\n // Skip update if the view model hasn't changed\r\n if (this._lastVM && this.vmsAreEqual(this._lastVM, vm)) {\r\n return;\r\n }\r\n\r\n this._lastVM = vm;\r\n this.observerList.notify(vm);\r\n }\r\n\r\n /**\r\n * Cleans up resources and detaches this PM from its parent AppObject\r\n */\r\n dispose() {\r\n this.observerList.clear();\r\n if (this.appObject.getComponent(this.type) === this) {\r\n this.appObject.removeComponent(this.type);\r\n }\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectRepo = void 0;
4
+ exports.makeAppObjectRepo = makeAppObjectRepo;
5
+ const Entities_1 = require("../Entities");
6
+ const AppObject_1 = require("./AppObject");
7
+ /**
8
+ * Abstract repository class for managing AppObjects and their components.
9
+ *
10
+ * This class provides the interface for storing, retrieving, and managing application
11
+ * objects, their components, and singletons. It also includes logging functionality
12
+ * and observer pattern implementation for tracking changes to the repository.
13
+ *
14
+ * @extends ObservableEntity
15
+ */
16
+ class AppObjectRepo extends Entities_1.ObservableEntity {
17
+ }
18
+ exports.AppObjectRepo = AppObjectRepo;
19
+ /**
20
+ * Creates and returns a new AppObjectRepo instance.
21
+ *
22
+ * @returns {AppObjectRepo} A new AppObjectRepo instance
23
+ */
24
+ function makeAppObjectRepo() {
25
+ return new AppObjectRepoImp();
26
+ }
27
+ /**
28
+ * Implementation of the AppObjectRepo abstract class.
29
+ *
30
+ * @private
31
+ * @extends AppObjectRepo
32
+ */
33
+ class AppObjectRepoImp extends AppObjectRepo {
34
+ constructor() {
35
+ super(...arguments);
36
+ this.appObjectLookup = new Map();
37
+ this.singletons = new Map();
38
+ this.onAppObjectAddedObserver = new Entities_1.ObserverList();
39
+ this.addAppObjectAddedObserver = (observer) => {
40
+ this.onAppObjectAddedObserver.add(observer);
41
+ };
42
+ this.removeAppObjectAddedObserver = (observer) => {
43
+ this.onAppObjectAddedObserver.remove(observer);
44
+ };
45
+ this.onAppObjectRemovedObservers = new Entities_1.ObserverList();
46
+ this.addAppObjectRemovedObserver = (observer) => {
47
+ this.onAppObjectRemovedObservers.add(observer);
48
+ };
49
+ this.removedAppObjectRemovedObserver = (observer) => {
50
+ this.onAppObjectRemovedObservers.remove(observer);
51
+ };
52
+ this.has = (id) => {
53
+ return this.appObjectLookup.has(id);
54
+ };
55
+ this.add = (appObject) => {
56
+ const existing = this.appObjectLookup.get(appObject.id);
57
+ if (existing) {
58
+ existing.removeObserver(this.notify);
59
+ }
60
+ this.appObjectLookup.set(appObject.id, appObject);
61
+ appObject.addObserver(this.notify);
62
+ this.notify();
63
+ this.onAppObjectAddedObserver.notify(appObject);
64
+ };
65
+ this.remove = (id) => {
66
+ const existing = this.appObjectLookup.get(id);
67
+ if (!existing)
68
+ return;
69
+ this.appObjectLookup.delete(id);
70
+ existing.removeObserver(this.notify);
71
+ this.notify();
72
+ this.onAppObjectRemovedObservers.notify(existing);
73
+ };
74
+ this.get = (id) => {
75
+ return this.appObjectLookup.get(id);
76
+ };
77
+ this.getOrCreate = (id) => {
78
+ const existing = this.appObjectLookup.get(id);
79
+ if (!existing) {
80
+ return (0, AppObject_1.makeAppObject)(id, this);
81
+ }
82
+ else {
83
+ return existing;
84
+ }
85
+ };
86
+ this.getAll = () => {
87
+ return Array.from(this.appObjectLookup.values());
88
+ };
89
+ }
90
+ getAllAppObjectsWithComponent(componentType) {
91
+ const rArray = [];
92
+ this.appObjectLookup.forEach((appObj) => {
93
+ if (appObj.hasComponent(componentType)) {
94
+ rArray.push(appObj);
95
+ }
96
+ });
97
+ return rArray;
98
+ }
99
+ getAllComponents(type) {
100
+ const rArray = [];
101
+ this.appObjectLookup.forEach((appObj) => {
102
+ const aoEntity = appObj.getComponent(type);
103
+ if (aoEntity) {
104
+ rArray.push(aoEntity);
105
+ }
106
+ });
107
+ return rArray;
108
+ }
109
+ getAppObjectComponent(id, entityType) {
110
+ const ao = this.appObjectLookup.get(id);
111
+ if (!ao) {
112
+ return undefined;
113
+ }
114
+ return ao.getComponent(entityType);
115
+ }
116
+ submitLog(sender, message) {
117
+ console.log(`[${sender}]: ${message}`);
118
+ }
119
+ submitWarning(sender, message) {
120
+ console.warn(`[${sender}]: ${message}`);
121
+ }
122
+ submitError(sender, message) {
123
+ console.error(`[${sender}]: ${message}`);
124
+ }
125
+ submitFatal(sender, message) {
126
+ console.error(`FATAL ERROR - [${sender}]: ${message}`);
127
+ }
128
+ registerSingleton(component) {
129
+ if (this.singletons.has(component.type)) {
130
+ this.submitWarning("AppObjectRepo", `Singleton for type ${component.type} already exists. Relpacing`);
131
+ }
132
+ this.singletons.set(component.type, component);
133
+ }
134
+ getSingleton(type) {
135
+ if (this.singletons.has(type)) {
136
+ return this.singletons.get(type);
137
+ }
138
+ const components = this.getAllComponents(type);
139
+ if (components.length === 1) {
140
+ this.singletons.set(components[0].type, components[0]);
141
+ return components[0];
142
+ }
143
+ else if (components.length === 0) {
144
+ this.submitWarning("AppObjectRepo", `Unable to find a singleton for ${type}`);
145
+ return undefined;
146
+ }
147
+ else if (components.length > 1) {
148
+ this.submitWarning("AppObjectRepo", `Multiple ${type} found. There should only be one if it truly a singleton. Using the first one`);
149
+ return components[0];
150
+ }
151
+ }
152
+ }
153
+ //# sourceMappingURL=AppObjectRepo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectRepo.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectRepo.ts"],"names":[],"mappings":";;;A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C,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,aAAa,CAChB,eAAe,EACf,YAAY,IAAI,+EAA+E,CAChG,CAAC;YACF,OAAO,UAAU,CAAC,CAAC,CAAM,CAAC;QAC5B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { ObservableEntity, ObserverList } from \"../Entities\";\r\nimport { AppObject, makeAppObject } from \"./AppObject\";\r\nimport { AppObjectComponent } from \"./AppObjectComponent\";\r\n\r\n/**\r\n * Abstract repository class for managing AppObjects and their components.\r\n *\r\n * This class provides the interface for storing, retrieving, and managing application\r\n * objects, their components, and singletons. It also includes logging functionality\r\n * and observer pattern implementation for tracking changes to the repository.\r\n *\r\n * @extends ObservableEntity\r\n */\r\nexport abstract class AppObjectRepo extends ObservableEntity {\r\n /**\r\n * Checks if an AppObject with the specified ID exists in the repository.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject to check\r\n * @returns {boolean} True if the AppObject exists, false otherwise\r\n */\r\n abstract has(appObjectID: string): boolean;\r\n\r\n /**\r\n * Adds an AppObject to the repository.\r\n *\r\n * @param {AppObject} appObject - The AppObject to add\r\n */\r\n abstract add(appObject: AppObject): void;\r\n\r\n /**\r\n * Removes an AppObject with the specified ID from the repository.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject to remove\r\n */\r\n abstract remove(appObjectID: string): void;\r\n\r\n /**\r\n * Gets an AppObject by its ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject to retrieve\r\n * @returns {AppObject | undefined} The AppObject if found, undefined otherwise\r\n */\r\n abstract get(appObjectID: string): AppObject | undefined;\r\n\r\n /**\r\n * Gets an AppObject by its ID, or creates a new one if it doesn't exist.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject to retrieve or create\r\n * @returns {AppObject} The existing or newly created AppObject\r\n */\r\n abstract getOrCreate(appObjectID: string): AppObject;\r\n\r\n /**\r\n * Gets all AppObjects in the repository.\r\n *\r\n * @returns {AppObject[]} An array of all AppObjects\r\n */\r\n abstract getAll(): AppObject[];\r\n\r\n /**\r\n * Logs an informational message.\r\n *\r\n * @param {string} sender - The identifier of the message sender\r\n * @param {string} message - The message to log\r\n */\r\n abstract submitLog(sender: string, message: string): void;\r\n\r\n /**\r\n * Logs a warning message.\r\n *\r\n * @param {string} sender - The identifier of the message sender\r\n * @param {string} message - The warning message to log\r\n */\r\n abstract submitWarning(sender: string, message: string): void;\r\n\r\n /**\r\n * Logs an error message.\r\n *\r\n * @param {string} sender - The identifier of the message sender\r\n * @param {string} message - The error message to log\r\n */\r\n abstract submitError(sender: string, message: string): void;\r\n\r\n /**\r\n * Logs a fatal error message.\r\n *\r\n * @param {string} sender - The identifier of the message sender\r\n * @param {string} message - The fatal error message to log\r\n */\r\n abstract submitFatal(sender: string, message: string): void;\r\n\r\n /**\r\n * Registers a component as a singleton in the repository.\r\n *\r\n * @param {AppObjectComponent} component - The component to register as a singleton\r\n */\r\n abstract registerSingleton(component: AppObjectComponent): void;\r\n\r\n /**\r\n * Gets a singleton component of the specified type.\r\n *\r\n * @template T - Type of the component to retrieve, must extend AppObjectComponent\r\n * @param {string} type - The type of the singleton to retrieve\r\n * @returns {T | undefined} The singleton component if found, undefined otherwise\r\n */\r\n abstract getSingleton<T extends AppObjectComponent>(\r\n type: string\r\n ): T | undefined;\r\n\r\n /**\r\n * Gets a component of the specified type from an AppObject.\r\n *\r\n * @template T - Type of the component to retrieve, must extend AppObjectComponent\r\n * @param {string} appObjectID - The ID of the AppObject containing the component\r\n * @param {string} type - The type of the component to retrieve\r\n * @returns {T | undefined} The component if found, undefined otherwise\r\n */\r\n abstract getAppObjectComponent<T extends AppObjectComponent>(\r\n appObjectID: string,\r\n type: string\r\n ): T | undefined;\r\n\r\n /**\r\n * Gets all AppObjects that have a component of the specified type.\r\n *\r\n * @param {string} componentType - The component type to filter by\r\n * @returns {AppObject[]} An array of AppObjects having the specified component type\r\n */\r\n abstract getAllAppObjectsWithComponent(componentType: string): AppObject[];\r\n\r\n /**\r\n * Gets all components of the specified type across all AppObjects.\r\n *\r\n * @template T - Type of the components to retrieve, must extend AppObjectComponent\r\n * @param {string} type - The type of components to retrieve\r\n * @returns {T[]} An array of all components of the specified type\r\n */\r\n abstract getAllComponents<T extends AppObjectComponent>(type: string): T[];\r\n\r\n /**\r\n * Adds an observer to be notified when an AppObject is added to the repository.\r\n *\r\n * @param {(addedEntity: AppObject) => void} observer - The observer function\r\n */\r\n abstract addAppObjectAddedObserver: (\r\n observer: (addedEntity: AppObject) => void\r\n ) => void;\r\n\r\n /**\r\n * Removes an observer previously registered for AppObject addition notifications.\r\n *\r\n * @param {(addedEntity: AppObject) => void} observer - The observer function to remove\r\n */\r\n abstract removeAppObjectAddedObserver: (\r\n observer: (addedEntity: AppObject) => void\r\n ) => void;\r\n\r\n /**\r\n * Adds an observer to be notified when an AppObject is removed from the repository.\r\n *\r\n * @param {(addedEntity: AppObject) => void} observer - The observer function\r\n */\r\n abstract addAppObjectRemovedObserver: (\r\n observer: (addedEntity: AppObject) => void\r\n ) => void;\r\n\r\n /**\r\n * Removes an observer previously registered for AppObject removal notifications.\r\n *\r\n * @param {(addedEntity: AppObject) => void} observer - The observer function to remove\r\n */\r\n abstract removedAppObjectRemovedObserver: (\r\n observer: (addedEntity: AppObject) => void\r\n ) => void;\r\n}\r\n\r\n/**\r\n * Creates and returns a new AppObjectRepo instance.\r\n *\r\n * @returns {AppObjectRepo} A new AppObjectRepo instance\r\n */\r\nexport function makeAppObjectRepo(): AppObjectRepo {\r\n return new AppObjectRepoImp();\r\n}\r\n\r\n/**\r\n * Implementation of the AppObjectRepo abstract class.\r\n *\r\n * @private\r\n * @extends AppObjectRepo\r\n */\r\nclass AppObjectRepoImp extends AppObjectRepo {\r\n private appObjectLookup = new Map<string, AppObject>();\r\n private singletons = new Map<string, AppObjectComponent>();\r\n\r\n private onAppObjectAddedObserver = new ObserverList<AppObject>();\r\n addAppObjectAddedObserver = (observer: (addedEntity: AppObject) => void) => {\r\n this.onAppObjectAddedObserver.add(observer);\r\n };\r\n removeAppObjectAddedObserver = (\r\n observer: (addedEntity: AppObject) => void\r\n ): void => {\r\n this.onAppObjectAddedObserver.remove(observer);\r\n };\r\n\r\n private onAppObjectRemovedObservers = new ObserverList<AppObject>();\r\n addAppObjectRemovedObserver = (\r\n observer: (removedEntity: AppObject) => void\r\n ) => {\r\n this.onAppObjectRemovedObservers.add(observer);\r\n };\r\n removedAppObjectRemovedObserver = (\r\n observer: (removedEntity: AppObject) => void\r\n ): void => {\r\n this.onAppObjectRemovedObservers.remove(observer);\r\n };\r\n\r\n has = (id: string): boolean => {\r\n return this.appObjectLookup.has(id);\r\n };\r\n\r\n add = (appObject: AppObject) => {\r\n const existing = this.appObjectLookup.get(appObject.id);\r\n if (existing) {\r\n existing.removeObserver(this.notify);\r\n }\r\n\r\n this.appObjectLookup.set(appObject.id, appObject);\r\n appObject.addObserver(this.notify);\r\n this.notify();\r\n this.onAppObjectAddedObserver.notify(appObject);\r\n };\r\n\r\n remove = (id: string) => {\r\n const existing = this.appObjectLookup.get(id);\r\n if (!existing) return;\r\n\r\n this.appObjectLookup.delete(id);\r\n existing.removeObserver(this.notify);\r\n this.notify();\r\n this.onAppObjectRemovedObservers.notify(existing);\r\n };\r\n\r\n get = (id: string): AppObject | undefined => {\r\n return this.appObjectLookup.get(id);\r\n };\r\n\r\n getOrCreate = (id: string): AppObject => {\r\n const existing = this.appObjectLookup.get(id);\r\n\r\n if (!existing) {\r\n return makeAppObject(id, this);\r\n } else {\r\n return existing;\r\n }\r\n };\r\n\r\n getAll = (): AppObject[] => {\r\n return Array.from(this.appObjectLookup.values());\r\n };\r\n\r\n getAllAppObjectsWithComponent(componentType: string): AppObject[] {\r\n const rArray: AppObject[] = [];\r\n\r\n this.appObjectLookup.forEach((appObj) => {\r\n if (appObj.hasComponent(componentType)) {\r\n rArray.push(appObj);\r\n }\r\n });\r\n\r\n return rArray;\r\n }\r\n\r\n getAllComponents<T extends AppObjectComponent>(type: string): T[] {\r\n const rArray: T[] = [];\r\n\r\n this.appObjectLookup.forEach((appObj) => {\r\n const aoEntity = appObj.getComponent(type);\r\n if (aoEntity) {\r\n rArray.push(aoEntity as T);\r\n }\r\n });\r\n\r\n return rArray;\r\n }\r\n\r\n getAppObjectComponent<T extends AppObjectComponent>(\r\n id: string,\r\n entityType: string\r\n ): T | undefined {\r\n const ao = this.appObjectLookup.get(id);\r\n if (!ao) {\r\n return undefined;\r\n }\r\n\r\n return ao.getComponent(entityType) as T;\r\n }\r\n\r\n submitLog(sender: string, message: string): void {\r\n console.log(`[${sender}]: ${message}`);\r\n }\r\n submitWarning(sender: string, message: string): void {\r\n console.warn(`[${sender}]: ${message}`);\r\n }\r\n submitError(sender: string, message: string): void {\r\n console.error(`[${sender}]: ${message}`);\r\n }\r\n submitFatal(sender: string, message: string): void {\r\n console.error(`FATAL ERROR - [${sender}]: ${message}`);\r\n }\r\n\r\n registerSingleton(component: AppObjectComponent): void {\r\n if (this.singletons.has(component.type)) {\r\n this.submitWarning(\r\n \"AppObjectRepo\",\r\n `Singleton for type ${component.type} already exists. Relpacing`\r\n );\r\n }\r\n\r\n this.singletons.set(component.type, component);\r\n }\r\n\r\n getSingleton<T extends AppObjectComponent>(type: string): T | undefined {\r\n if (this.singletons.has(type)) {\r\n return this.singletons.get(type) as T;\r\n }\r\n\r\n const components = this.getAllComponents<AppObjectComponent>(type);\r\n if (components.length === 1) {\r\n this.singletons.set(components[0].type, components[0]);\r\n return components[0] as T;\r\n } else if (components.length === 0) {\r\n this.submitWarning(\r\n \"AppObjectRepo\",\r\n `Unable to find a singleton for ${type}`\r\n );\r\n return undefined;\r\n } else if (components.length > 1) {\r\n this.submitWarning(\r\n \"AppObjectRepo\",\r\n `Multiple ${type} found. There should only be one if it truly a singleton. Using the first one`\r\n );\r\n return components[0] as T;\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectUC = void 0;
4
+ const AppObjectComponent_1 = require("./AppObjectComponent");
5
+ /**
6
+ * AppObjectUC (Use Case) serves as a base use case class within the application framework.
7
+ *
8
+ * Use Cases are components that represent specific application operations or workflows.
9
+ * They encapsulate business rules and coordinate interactions between different parts
10
+ * of the application. Extend this class to implement specific use case scenarios.
11
+ *
12
+ * @extends AppObjectComponent
13
+ * @example
14
+ * ```typescript
15
+ * class PurchaseItemUC extends AppObjectUC {
16
+ * execute(itemId: string, quantity: number): boolean {
17
+ * // Implement the purchase item use case
18
+ * return true; // if successful
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ class AppObjectUC extends AppObjectComponent_1.AppObjectComponent {
24
+ constructor() {
25
+ super(...arguments);
26
+ /**
27
+ * The component type identifier used to categorize this component as a use case
28
+ * This property helps the component system identify and manage use case components.
29
+ * @readonly
30
+ */
31
+ this.componentType = AppObjectComponent_1.AppObjectComponentType.UC;
32
+ }
33
+ }
34
+ exports.AppObjectUC = AppObjectUC;
35
+ //# sourceMappingURL=AppObjectUC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectUC.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectUC.ts"],"names":[],"mappings":";;;AAAA,6DAG8B;AAE9B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,WAAY,SAAQ,uCAAkB;IAAnD;;QACE;;;;WAIG;QACM,kBAAa,GAAG,2CAAsB,CAAC,EAAE,CAAC;IACrD,CAAC;CAAA;AAPD,kCAOC","sourcesContent":["import {\r\n AppObjectComponent,\r\n AppObjectComponentType,\r\n} from \"./AppObjectComponent\";\r\n\r\n/**\r\n * AppObjectUC (Use Case) serves as a base use case class within the application framework.\r\n *\r\n * Use Cases are components that represent specific application operations or workflows.\r\n * They encapsulate business rules and coordinate interactions between different parts\r\n * of the application. Extend this class to implement specific use case scenarios.\r\n *\r\n * @extends AppObjectComponent\r\n * @example\r\n * ```typescript\r\n * class PurchaseItemUC extends AppObjectUC {\r\n * execute(itemId: string, quantity: number): boolean {\r\n * // Implement the purchase item use case\r\n * return true; // if successful\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AppObjectUC extends AppObjectComponent {\r\n /**\r\n * The component type identifier used to categorize this component as a use case\r\n * This property helps the component system identify and manage use case components.\r\n * @readonly\r\n */\r\n readonly componentType = AppObjectComponentType.UC;\r\n}\r\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectView = void 0;
4
+ const AppObjectComponent_1 = require("./AppObjectComponent");
5
+ /**
6
+ * AppObjectView serves as a base view class within the application framework.
7
+ *
8
+ * Views are components that handle the visual representation of an AppObject,
9
+ * such as rendering, animations, or user interface elements. Extend this class
10
+ * to create custom visual representations for specific application objects.
11
+ *
12
+ * @extends AppObjectComponent
13
+ * @example
14
+ * ```typescript
15
+ * class PlayerView extends AppObjectView {
16
+ * render(renderContext: RenderContext) {
17
+ * // Render the player character on screen
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ class AppObjectView extends AppObjectComponent_1.AppObjectComponent {
23
+ constructor() {
24
+ super(...arguments);
25
+ /**
26
+ * The component type identifier used to categorize this component as a view
27
+ * This property helps the component system identify and manage view components.
28
+ * @readonly
29
+ */
30
+ this.componentType = AppObjectComponent_1.AppObjectComponentType.VIEW;
31
+ }
32
+ }
33
+ exports.AppObjectView = AppObjectView;
34
+ //# sourceMappingURL=AppObjectView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectView.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectView.ts"],"names":[],"mappings":";;;AAAA,6DAG8B;AAE9B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,aAAc,SAAQ,uCAAkB;IAArD;;QACE;;;;WAIG;QACM,kBAAa,GAAG,2CAAsB,CAAC,IAAI,CAAC;IACvD,CAAC;CAAA;AAPD,sCAOC","sourcesContent":["import {\r\n AppObjectComponent,\r\n AppObjectComponentType,\r\n} from \"./AppObjectComponent\";\r\n\r\n/**\r\n * AppObjectView serves as a base view class within the application framework.\r\n *\r\n * Views are components that handle the visual representation of an AppObject,\r\n * such as rendering, animations, or user interface elements. Extend this class\r\n * to create custom visual representations for specific application objects.\r\n *\r\n * @extends AppObjectComponent\r\n * @example\r\n * ```typescript\r\n * class PlayerView extends AppObjectView {\r\n * render(renderContext: RenderContext) {\r\n * // Render the player character on screen\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AppObjectView extends AppObjectComponent {\r\n /**\r\n * The component type identifier used to categorize this component as a view\r\n * This property helps the component system identify and manage view components.\r\n * @readonly\r\n */\r\n readonly componentType = AppObjectComponentType.VIEW;\r\n}\r\n"]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSingletonComponent = getSingletonComponent;
4
+ /**
5
+ * Retrieves a singleton component of the specified type from the application objects repository.
6
+ *
7
+ * This utility function provides a convenient way to access singleton components that should
8
+ * have only one instance across the entire application.
9
+ *
10
+ * @template T - Type of the component to retrieve, must extend AppObjectComponent
11
+ * @param {string} type - The type identifier of the component to retrieve
12
+ * @param {AppObjectRepo} appObjects - The repository containing all application objects
13
+ * @returns {T | undefined} The singleton component instance if found, otherwise undefined
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const cameraController = getSingletonComponent<CameraController>(CameraController.type, appObjectRepo);
18
+ * if (cameraController) {
19
+ * cameraController.focusOn(targetObject);
20
+ * }
21
+ * ```
22
+ */
23
+ function getSingletonComponent(type, appObjects) {
24
+ return appObjects.getSingleton(type);
25
+ }
26
+ //# sourceMappingURL=getSingletonComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSingletonComponent.js","sourceRoot":"","sources":["../../../src/AppObject/getSingletonComponent.ts"],"names":[],"mappings":";;AAsBA,sDAKC;AAxBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,qBAAqB,CACnC,IAAY,EACZ,UAAyB;IAEzB,OAAO,UAAU,CAAC,YAAY,CAAI,IAAI,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import { AppObjectComponent } from \"./AppObjectComponent\";\r\nimport { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\n/**\r\n * Retrieves a singleton component of the specified type from the application objects repository.\r\n *\r\n * This utility function provides a convenient way to access singleton components that should\r\n * have only one instance across the entire application.\r\n *\r\n * @template T - Type of the component to retrieve, must extend AppObjectComponent\r\n * @param {string} type - The type identifier of the component to retrieve\r\n * @param {AppObjectRepo} appObjects - The repository containing all application objects\r\n * @returns {T | undefined} The singleton component instance if found, otherwise undefined\r\n *\r\n * @example\r\n * ```typescript\r\n * const cameraController = getSingletonComponent<CameraController>(CameraController.type, appObjectRepo);\r\n * if (cameraController) {\r\n * cameraController.focusOn(targetObject);\r\n * }\r\n * ```\r\n */\r\nexport function getSingletonComponent<T extends AppObjectComponent>(\r\n type: string,\r\n appObjects: AppObjectRepo\r\n): T | undefined {\r\n return appObjects.getSingleton<T>(type);\r\n}\r\n"]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AppObject"), exports);
18
+ __exportStar(require("./AppObjectEntity"), exports);
19
+ __exportStar(require("./AppObjectEntityRepo"), exports);
20
+ __exportStar(require("./AppObjectPM"), exports);
21
+ __exportStar(require("./AppObjectRepo"), exports);
22
+ __exportStar(require("./AppObjectUC"), exports);
23
+ __exportStar(require("./AppObjectController"), exports);
24
+ __exportStar(require("./AppObjectView"), exports);
25
+ __exportStar(require("./getSingletonComponent"), exports);
26
+ __exportStar(require("./printAppObjectDetails"), exports);
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/AppObject/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,oDAAiC;AACjC,wDAAqC;AACrC,gDAA6B;AAC7B,kDAA+B;AAC/B,gDAA6B;AAC7B,wDAAqC;AACrC,kDAA+B;AAC/B,0DAAwC;AACxC,0DAAwC","sourcesContent":["export * from \"./AppObject\"\r\nexport * from \"./AppObjectEntity\"\r\nexport * from \"./AppObjectEntityRepo\"\r\nexport * from \"./AppObjectPM\"\r\nexport * from \"./AppObjectRepo\"\r\nexport * from \"./AppObjectUC\"\r\nexport * from \"./AppObjectController\"\r\nexport * from \"./AppObjectView\"\r\nexport * from \"./getSingletonComponent\";\r\nexport * from \"./printAppObjectDetails\";"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printAppObjectDetails = printAppObjectDetails;
4
+ function printAppObjectDetails(id, appObjects) {
5
+ const appObject = appObjects.get(id);
6
+ if (!appObject) {
7
+ console.warn("[printAppObjectDetails] Unable to find App Object by ID");
8
+ return;
9
+ }
10
+ console.log("[printAppObjectDetails] Start App Object Details ---");
11
+ console.log(`id: ${appObject.id}`);
12
+ const components = appObject.allComponents();
13
+ components.forEach((component) => {
14
+ console.log(`Has Component: ${component.type}`);
15
+ });
16
+ console.log("[printAppObjectDetails] End App Object Details ---");
17
+ }
18
+ //# sourceMappingURL=printAppObjectDetails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printAppObjectDetails.js","sourceRoot":"","sources":["../../../src/AppObject/printAppObjectDetails.ts"],"names":[],"mappings":";;AAEA,sDAcC;AAdD,SAAgB,qBAAqB,CAAC,EAAU,EAAE,UAAyB;IACzE,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;QACxE,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,OAAO,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC;IAC7C,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC/B,OAAO,CAAC,GAAG,CAAC,kBAAkB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\nexport function printAppObjectDetails(id: string, appObjects: AppObjectRepo) {\r\n const appObject = appObjects.get(id);\r\n if (!appObject) {\r\n console.warn(\"[printAppObjectDetails] Unable to find App Object by ID\");\r\n return;\r\n }\r\n\r\n console.log(\"[printAppObjectDetails] Start App Object Details ---\");\r\n console.log(`id: ${appObject.id}`);\r\n const components = appObject.allComponents();\r\n components.forEach((component) => {\r\n console.log(`Has Component: ${component.type}`);\r\n });\r\n console.log(\"[printAppObjectDetails] End App Object Details ---\");\r\n}\r\n"]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MemoizedAngle = void 0;
4
+ /**
5
+ * A wrapper class for Angle objects that tracks changes and triggers callbacks.
6
+ * Only triggers the callback when the angle value actually changes.
7
+ */
8
+ class MemoizedAngle {
9
+ /**
10
+ * Gets the current angle value
11
+ */
12
+ get val() {
13
+ return this._val;
14
+ }
15
+ /**
16
+ * Sets the angle value and triggers the onChange callback if the value changed
17
+ * @param b - The new Angle value
18
+ */
19
+ set val(b) {
20
+ if (this._val.degrees === b.degrees)
21
+ return;
22
+ this._val = b;
23
+ this.onChangeCallback();
24
+ }
25
+ /**
26
+ * Sets the value without triggering the onChange callback
27
+ * @param val - The new Angle value
28
+ */
29
+ setValQuietly(val) {
30
+ this._val = val;
31
+ }
32
+ /**
33
+ * Creates a new MemoizedAngle instance
34
+ *
35
+ * @param initialValue - The initial Angle value
36
+ * @param onChangeCallback - Function to call when the value changes
37
+ */
38
+ constructor(initialValue, onChangeCallback) {
39
+ this._val = initialValue;
40
+ this.onChangeCallback = onChangeCallback;
41
+ }
42
+ }
43
+ exports.MemoizedAngle = MemoizedAngle;
44
+ //# sourceMappingURL=MemoizedAngle.js.map