@vived/core 1.5.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +1 -48
  2. package/dist/cjs/AppObject/AppObjectComponent.js +8 -10
  3. package/dist/cjs/AppObject/AppObjectComponent.js.map +1 -1
  4. package/dist/cjs/AppObject/AppObjectEntityRepo.js +99 -11
  5. package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +1 -1
  6. package/dist/cjs/AppObject/AppObjectPM.js +106 -6
  7. package/dist/cjs/AppObject/AppObjectPM.js.map +1 -1
  8. package/dist/cjs/AppObject/AppObjectRepo.js +11 -1
  9. package/dist/cjs/AppObject/AppObjectRepo.js.map +1 -1
  10. package/dist/cjs/AppObject/AppObjectSingletonEntity.js +40 -0
  11. package/dist/cjs/AppObject/AppObjectSingletonEntity.js.map +1 -0
  12. package/dist/cjs/AppObject/AppObjectSingletonEntityRepo.js +54 -0
  13. package/dist/cjs/AppObject/AppObjectSingletonEntityRepo.js.map +1 -0
  14. package/dist/cjs/AppObject/AppObjectSingletonPM.js +69 -0
  15. package/dist/cjs/AppObject/AppObjectSingletonPM.js.map +1 -0
  16. package/dist/cjs/AppObject/AppObjectSingletonUC.js +60 -0
  17. package/dist/cjs/AppObject/AppObjectSingletonUC.js.map +1 -0
  18. package/dist/cjs/AppObject/index.js +4 -0
  19. package/dist/cjs/AppObject/index.js.map +1 -1
  20. package/dist/cjs/DomainFactories/Entities/DomainFactoryRepo.js +5 -0
  21. package/dist/cjs/DomainFactories/Entities/DomainFactoryRepo.js.map +1 -1
  22. package/dist/cjs/Entities/ObserverList.js +6 -0
  23. package/dist/cjs/Entities/ObserverList.js.map +1 -1
  24. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js +11 -22
  25. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
  26. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js +1 -3
  27. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -1
  28. package/dist/cjs/ExampleFeature/Factory/ExampleFeatureFactory.js +65 -0
  29. package/dist/cjs/ExampleFeature/Factory/ExampleFeatureFactory.js.map +1 -0
  30. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js +5 -13
  31. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js.map +1 -1
  32. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js +8 -12
  33. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -1
  34. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js +0 -4
  35. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -1
  36. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js +2 -8
  37. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -1
  38. package/dist/cjs/index.js +0 -1
  39. package/dist/cjs/index.js.map +1 -1
  40. package/dist/esm/AppObject/AppObjectComponent.js +8 -10
  41. package/dist/esm/AppObject/AppObjectComponent.js.map +1 -1
  42. package/dist/esm/AppObject/AppObjectEntityRepo.js +99 -11
  43. package/dist/esm/AppObject/AppObjectEntityRepo.js.map +1 -1
  44. package/dist/esm/AppObject/AppObjectPM.js +107 -7
  45. package/dist/esm/AppObject/AppObjectPM.js.map +1 -1
  46. package/dist/esm/AppObject/AppObjectRepo.js +11 -1
  47. package/dist/esm/AppObject/AppObjectRepo.js.map +1 -1
  48. package/dist/esm/AppObject/AppObjectSingletonEntity.js +36 -0
  49. package/dist/esm/AppObject/AppObjectSingletonEntity.js.map +1 -0
  50. package/dist/esm/AppObject/AppObjectSingletonEntityRepo.js +50 -0
  51. package/dist/esm/AppObject/AppObjectSingletonEntityRepo.js.map +1 -0
  52. package/dist/esm/AppObject/AppObjectSingletonPM.js +65 -0
  53. package/dist/esm/AppObject/AppObjectSingletonPM.js.map +1 -0
  54. package/dist/esm/AppObject/AppObjectSingletonUC.js +56 -0
  55. package/dist/esm/AppObject/AppObjectSingletonUC.js.map +1 -0
  56. package/dist/esm/AppObject/index.js +4 -0
  57. package/dist/esm/AppObject/index.js.map +1 -1
  58. package/dist/esm/DomainFactories/Entities/DomainFactoryRepo.js +4 -0
  59. package/dist/esm/DomainFactories/Entities/DomainFactoryRepo.js.map +1 -1
  60. package/dist/esm/Entities/ObserverList.js +6 -0
  61. package/dist/esm/Entities/ObserverList.js.map +1 -1
  62. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js +11 -22
  63. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
  64. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js +2 -4
  65. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -1
  66. package/dist/esm/ExampleFeature/Factory/ExampleFeatureFactory.js +60 -0
  67. package/dist/esm/ExampleFeature/Factory/ExampleFeatureFactory.js.map +1 -0
  68. package/dist/esm/ExampleFeature/PMs/ExamplePM.js +5 -13
  69. package/dist/esm/ExampleFeature/PMs/ExamplePM.js.map +1 -1
  70. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js +9 -13
  71. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -1
  72. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js +0 -4
  73. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -1
  74. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js +3 -9
  75. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -1
  76. package/dist/esm/index.js +0 -1
  77. package/dist/esm/index.js.map +1 -1
  78. package/dist/types/AppObject/AppObjectComponent.d.ts +6 -4
  79. package/dist/types/AppObject/AppObjectComponent.d.ts.map +1 -1
  80. package/dist/types/AppObject/AppObjectEntityRepo.d.ts +72 -7
  81. package/dist/types/AppObject/AppObjectEntityRepo.d.ts.map +1 -1
  82. package/dist/types/AppObject/AppObjectPM.d.ts +82 -2
  83. package/dist/types/AppObject/AppObjectPM.d.ts.map +1 -1
  84. package/dist/types/AppObject/AppObjectRepo.d.ts +13 -0
  85. package/dist/types/AppObject/AppObjectRepo.d.ts.map +1 -1
  86. package/dist/types/AppObject/AppObjectSingletonEntity.d.ts +31 -0
  87. package/dist/types/AppObject/AppObjectSingletonEntity.d.ts.map +1 -0
  88. package/dist/types/AppObject/AppObjectSingletonEntityRepo.d.ts +46 -0
  89. package/dist/types/AppObject/AppObjectSingletonEntityRepo.d.ts.map +1 -0
  90. package/dist/types/AppObject/AppObjectSingletonPM.d.ts +60 -0
  91. package/dist/types/AppObject/AppObjectSingletonPM.d.ts.map +1 -0
  92. package/dist/types/AppObject/AppObjectSingletonUC.d.ts +51 -0
  93. package/dist/types/AppObject/AppObjectSingletonUC.d.ts.map +1 -0
  94. package/dist/types/AppObject/index.d.ts +4 -0
  95. package/dist/types/AppObject/index.d.ts.map +1 -1
  96. package/dist/types/DomainFactories/Entities/DomainFactoryRepo.d.ts +1 -0
  97. package/dist/types/DomainFactories/Entities/DomainFactoryRepo.d.ts.map +1 -1
  98. package/dist/types/Entities/ObserverList.d.ts +4 -0
  99. package/dist/types/Entities/ObserverList.d.ts.map +1 -1
  100. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts +0 -4
  101. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts.map +1 -1
  102. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts +2 -2
  103. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts.map +1 -1
  104. package/dist/types/ExampleFeature/Factory/ExampleFeatureFactory.d.ts +44 -0
  105. package/dist/types/ExampleFeature/Factory/ExampleFeatureFactory.d.ts.map +1 -0
  106. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts +4 -4
  107. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts.map +1 -1
  108. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts +2 -2
  109. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts.map +1 -1
  110. package/dist/types/index.d.ts +0 -1
  111. package/dist/types/index.d.ts.map +1 -1
  112. package/package.json +2 -2
  113. package/dist/cjs/ExampleFeature/Adapters/index.js +0 -19
  114. package/dist/cjs/ExampleFeature/Adapters/index.js.map +0 -1
  115. package/dist/cjs/ExampleFeature/Controllers/index.js +0 -19
  116. package/dist/cjs/ExampleFeature/Controllers/index.js.map +0 -1
  117. package/dist/cjs/ExampleFeature/Entities/index.js +0 -20
  118. package/dist/cjs/ExampleFeature/Entities/index.js.map +0 -1
  119. package/dist/cjs/ExampleFeature/Factory/index.js +0 -18
  120. package/dist/cjs/ExampleFeature/Factory/index.js.map +0 -1
  121. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js +0 -29
  122. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js.map +0 -1
  123. package/dist/cjs/ExampleFeature/Mocks/index.js +0 -21
  124. package/dist/cjs/ExampleFeature/Mocks/index.js.map +0 -1
  125. package/dist/cjs/ExampleFeature/PMs/index.js +0 -19
  126. package/dist/cjs/ExampleFeature/PMs/index.js.map +0 -1
  127. package/dist/cjs/ExampleFeature/UCs/index.js +0 -19
  128. package/dist/cjs/ExampleFeature/UCs/index.js.map +0 -1
  129. package/dist/cjs/ExampleFeature/index.js +0 -24
  130. package/dist/cjs/ExampleFeature/index.js.map +0 -1
  131. package/dist/esm/ExampleFeature/Adapters/index.js +0 -3
  132. package/dist/esm/ExampleFeature/Adapters/index.js.map +0 -1
  133. package/dist/esm/ExampleFeature/Controllers/index.js +0 -3
  134. package/dist/esm/ExampleFeature/Controllers/index.js.map +0 -1
  135. package/dist/esm/ExampleFeature/Entities/index.js +0 -4
  136. package/dist/esm/ExampleFeature/Entities/index.js.map +0 -1
  137. package/dist/esm/ExampleFeature/Factory/index.js +0 -2
  138. package/dist/esm/ExampleFeature/Factory/index.js.map +0 -1
  139. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js +0 -26
  140. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js.map +0 -1
  141. package/dist/esm/ExampleFeature/Mocks/index.js +0 -5
  142. package/dist/esm/ExampleFeature/Mocks/index.js.map +0 -1
  143. package/dist/esm/ExampleFeature/PMs/index.js +0 -3
  144. package/dist/esm/ExampleFeature/PMs/index.js.map +0 -1
  145. package/dist/esm/ExampleFeature/UCs/index.js +0 -3
  146. package/dist/esm/ExampleFeature/UCs/index.js.map +0 -1
  147. package/dist/esm/ExampleFeature/index.js +0 -8
  148. package/dist/esm/ExampleFeature/index.js.map +0 -1
  149. package/dist/types/ExampleFeature/Adapters/index.d.ts +0 -3
  150. package/dist/types/ExampleFeature/Adapters/index.d.ts.map +0 -1
  151. package/dist/types/ExampleFeature/Controllers/index.d.ts +0 -3
  152. package/dist/types/ExampleFeature/Controllers/index.d.ts.map +0 -1
  153. package/dist/types/ExampleFeature/Entities/index.d.ts +0 -4
  154. package/dist/types/ExampleFeature/Entities/index.d.ts.map +0 -1
  155. package/dist/types/ExampleFeature/Factory/index.d.ts +0 -2
  156. package/dist/types/ExampleFeature/Factory/index.d.ts.map +0 -1
  157. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts +0 -17
  158. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts.map +0 -1
  159. package/dist/types/ExampleFeature/Mocks/index.d.ts +0 -5
  160. package/dist/types/ExampleFeature/Mocks/index.d.ts.map +0 -1
  161. package/dist/types/ExampleFeature/PMs/index.d.ts +0 -3
  162. package/dist/types/ExampleFeature/PMs/index.d.ts.map +0 -1
  163. package/dist/types/ExampleFeature/UCs/index.d.ts +0 -3
  164. package/dist/types/ExampleFeature/UCs/index.d.ts.map +0 -1
  165. package/dist/types/ExampleFeature/index.d.ts +0 -8
  166. package/dist/types/ExampleFeature/index.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DomainFactoryRepo.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactoryRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEnB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAkB,SAAQ,mBAAkC;IAIvE;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,qBAAqB,CAC1B,iBAAiB,CAAC,IAAI,EACtB,UAAU,CACX,CAAC;IACJ,CAAC;IA+BD;;;;OAIG;IACH,SAAS,CAAC,IAAY;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QA5C3C;;;;WAIG;QACH,gBAAW,GAAG,GAAG,EAAE;YACjB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAEnC,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;YAEH,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,4CAA4C;YAC5C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,0CAA0C;YAC1C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,UAAU,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IAkBF,CAAC;;AA5DD,gDAAgD;AACzC,sBAAI,GAAG,mBAAmB,AAAtB,CAAuB","sourcesContent":["import {\r\n AppObject,\r\n AppObjectEntityRepo,\r\n AppObjectRepo,\r\n getSingletonComponent,\r\n} from \"../../AppObject\";\r\nimport { DomainFactory } from \"./DomainFactory\";\r\n\r\n/**\r\n * Repository for managing DomainFactory instances in the application.\r\n *\r\n * DomainFactoryRepo is implemented as a singleton that coordinates the setup\r\n * and initialization of all domain factories. It ensures that the setup phases\r\n * are executed in the correct order across all registered factories:\r\n * 1. All factories set up their entities first\r\n * 2. Then all factories set up their use cases\r\n * 3. Next all factories set up their presentation managers\r\n * 4. Finally, all factories perform their final setup operations\r\n *\r\n * This phased approach ensures that components in one domain can depend on\r\n * components from another domain being properly initialized.\r\n */\r\nexport class DomainFactoryRepo extends AppObjectEntityRepo<DomainFactory> {\r\n /** Unique type identifier for this component */\r\n static type = \"DomainFactoryRepo\";\r\n\r\n /**\r\n * Global accessor for the singleton repository\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton DomainFactoryRepo or undefined if not created yet\r\n */\r\n static get(appObjects: AppObjectRepo) {\r\n return getSingletonComponent<DomainFactoryRepo>(\r\n DomainFactoryRepo.type,\r\n appObjects\r\n );\r\n }\r\n\r\n /**\r\n * Orchestrates the setup of the entire domain layer in the correct sequence.\r\n * Calls each setup phase on all factories before proceeding to the next phase.\r\n * This ensures cross-domain dependencies are properly resolved.\r\n */\r\n setupDomain = () => {\r\n const allFactories = this.getAll();\r\n\r\n // Phase 1: Set up all entities first\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupEntities();\r\n });\r\n\r\n // Phase 2: Set up all use cases next\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupUCs();\r\n });\r\n\r\n // Phase 3: Set up all presentation managers\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupPMs();\r\n });\r\n\r\n // Phase 4: Perform final setup operations\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.finalSetup();\r\n });\r\n };\r\n\r\n /**\r\n * Retrieves a domain factory by its name.\r\n * @param name The name of the domain factory to find\r\n * @returns The matching domain factory or undefined if not found\r\n */\r\n getByName(name: string): DomainFactory | undefined {\r\n const allFactories = this.getAll();\r\n return allFactories.find((factory) => factory.factoryName === name);\r\n }\r\n\r\n /**\r\n * Creates a new DomainFactoryRepo and registers it with the given AppObject.\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, DomainFactoryRepo.type);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DomainFactoryRepo.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactoryRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEnB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAkB,SAAQ,mBAAkC;IAIvE;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,qBAAqB,CAC1B,iBAAiB,CAAC,IAAI,EACtB,UAAU,CACX,CAAC;IACJ,CAAC;IA+BD;;;;OAIG;IACH,SAAS,CAAC,IAAY;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QA5C3C;;;;WAIG;QACH,gBAAW,GAAG,GAAG,EAAE;YACjB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAEnC,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;YAEH,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,4CAA4C;YAC5C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,0CAA0C;YAC1C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,UAAU,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IAkBF,CAAC;;AA5DD,gDAAgD;AACzC,sBAAI,GAAG,mBAAmB,AAAtB,CAAuB;AA8DpC,MAAM,UAAU,qBAAqB,CAAC,UAAyB;IAC7D,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC9D,OAAO,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {\r\n AppObject,\r\n AppObjectEntityRepo,\r\n AppObjectRepo,\r\n getSingletonComponent,\r\n} from \"../../AppObject\";\r\nimport { DomainFactory } from \"./DomainFactory\";\r\n\r\n/**\r\n * Repository for managing DomainFactory instances in the application.\r\n *\r\n * DomainFactoryRepo is implemented as a singleton that coordinates the setup\r\n * and initialization of all domain factories. It ensures that the setup phases\r\n * are executed in the correct order across all registered factories:\r\n * 1. All factories set up their entities first\r\n * 2. Then all factories set up their use cases\r\n * 3. Next all factories set up their presentation managers\r\n * 4. Finally, all factories perform their final setup operations\r\n *\r\n * This phased approach ensures that components in one domain can depend on\r\n * components from another domain being properly initialized.\r\n */\r\nexport class DomainFactoryRepo extends AppObjectEntityRepo<DomainFactory> {\r\n /** Unique type identifier for this component */\r\n static type = \"DomainFactoryRepo\";\r\n\r\n /**\r\n * Global accessor for the singleton repository\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton DomainFactoryRepo or undefined if not created yet\r\n */\r\n static get(appObjects: AppObjectRepo) {\r\n return getSingletonComponent<DomainFactoryRepo>(\r\n DomainFactoryRepo.type,\r\n appObjects\r\n );\r\n }\r\n\r\n /**\r\n * Orchestrates the setup of the entire domain layer in the correct sequence.\r\n * Calls each setup phase on all factories before proceeding to the next phase.\r\n * This ensures cross-domain dependencies are properly resolved.\r\n */\r\n setupDomain = () => {\r\n const allFactories = this.getAll();\r\n\r\n // Phase 1: Set up all entities first\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupEntities();\r\n });\r\n\r\n // Phase 2: Set up all use cases next\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupUCs();\r\n });\r\n\r\n // Phase 3: Set up all presentation managers\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupPMs();\r\n });\r\n\r\n // Phase 4: Perform final setup operations\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.finalSetup();\r\n });\r\n };\r\n\r\n /**\r\n * Retrieves a domain factory by its name.\r\n * @param name The name of the domain factory to find\r\n * @returns The matching domain factory or undefined if not found\r\n */\r\n getByName(name: string): DomainFactory | undefined {\r\n const allFactories = this.getAll();\r\n return allFactories.find((factory) => factory.factoryName === name);\r\n }\r\n\r\n /**\r\n * Creates a new DomainFactoryRepo and registers it with the given AppObject.\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, DomainFactoryRepo.type);\r\n }\r\n}\r\n\r\nexport function makeDomainFactoryRepo(appObjects: AppObjectRepo) {\r\n const appObject = appObjects.getOrCreate(\"DomainFactoryRepo\");\r\n return new DomainFactoryRepo(appObject);\r\n}"]}
@@ -40,5 +40,11 @@ export class ObserverList {
40
40
  this.observers = [];
41
41
  };
42
42
  }
43
+ /**
44
+ * Gets the number of observers in the list
45
+ */
46
+ get length() {
47
+ return this.observers.length;
48
+ }
43
49
  }
44
50
  //# sourceMappingURL=ObserverList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObserverList.js","sourceRoot":"","sources":["../../../src/Entities/ObserverList.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAAzB;QACU,cAAS,GAAyB,EAAE,CAAC;QAE7C;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAM,EAAE,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,GAAG,CAAC,GAAG,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF;;;WAGG;QACI,QAAG,GAAG,CAAC,GAAqB,EAAE,EAAE;YACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAqB,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC;QAEF;;WAEG;QACI,UAAK,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;CAAA","sourcesContent":["/**\r\n * A generic implementation of the Observer pattern.\r\n * Maintains a list of observer functions that can be notified with a message.\r\n *\r\n * @typeParam T - The type of message that will be passed to observers\r\n */\r\nexport class ObserverList<T> {\r\n private observers: ((msg: T) => void)[] = [];\r\n\r\n /**\r\n * Notifies all observers by calling them with the provided message\r\n * @param msg - The message to send to all observers\r\n */\r\n public notify = (msg: T) => {\r\n this.observers.forEach((obs) => {\r\n obs(msg);\r\n });\r\n };\r\n\r\n /**\r\n * Adds a new observer function to the list\r\n * @param obs - The observer function to add\r\n */\r\n public add = (obs: (msg: T) => void) => {\r\n this.observers.push(obs);\r\n };\r\n\r\n /**\r\n * Removes an observer from the list\r\n * @param obs - The observer function to remove\r\n */\r\n public remove = (obs: (msg: T) => void) => {\r\n const index = this.observers.indexOf(obs);\r\n if (index >= 0) {\r\n this.observers.splice(index, 1);\r\n }\r\n };\r\n\r\n /**\r\n * Removes all observers from the list\r\n */\r\n public clear = () => {\r\n this.observers = [];\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"ObserverList.js","sourceRoot":"","sources":["../../../src/Entities/ObserverList.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAAzB;QACU,cAAS,GAAyB,EAAE,CAAC;QAS7C;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAM,EAAE,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,GAAG,CAAC,GAAG,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF;;;WAGG;QACI,QAAG,GAAG,CAAC,GAAqB,EAAE,EAAE;YACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAqB,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC;QAEF;;WAEG;QACI,UAAK,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;IA1CC;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B,CAAC;CAqCF","sourcesContent":["/**\r\n * A generic implementation of the Observer pattern.\r\n * Maintains a list of observer functions that can be notified with a message.\r\n *\r\n * @typeParam T - The type of message that will be passed to observers\r\n */\r\nexport class ObserverList<T> {\r\n private observers: ((msg: T) => void)[] = [];\r\n\r\n /**\r\n * Gets the number of observers in the list\r\n */\r\n public get length(): number {\r\n return this.observers.length;\r\n }\r\n\r\n /**\r\n * Notifies all observers by calling them with the provided message\r\n * @param msg - The message to send to all observers\r\n */\r\n public notify = (msg: T) => {\r\n this.observers.forEach((obs) => {\r\n obs(msg);\r\n });\r\n };\r\n\r\n /**\r\n * Adds a new observer function to the list\r\n * @param obs - The observer function to add\r\n */\r\n public add = (obs: (msg: T) => void) => {\r\n this.observers.push(obs);\r\n };\r\n\r\n /**\r\n * Removes an observer from the list\r\n * @param obs - The observer function to remove\r\n */\r\n public remove = (obs: (msg: T) => void) => {\r\n const index = this.observers.indexOf(obs);\r\n if (index >= 0) {\r\n this.observers.splice(index, 1);\r\n }\r\n };\r\n\r\n /**\r\n * Removes all observers from the list\r\n */\r\n public clear = () => {\r\n this.observers = [];\r\n };\r\n}\r\n"]}
@@ -17,7 +17,6 @@
17
17
  * 4. Delete entities through the repository when they're no longer needed
18
18
  */
19
19
  import { AppObjectEntityRepo } from "../../AppObject";
20
- import { generateUniqueID } from "../../Utilities/generateUniqueID";
21
20
  import { makeExampleEntity } from "./ExampleEntity";
22
21
  /**
23
22
  * ExampleRepo manages a collection of ExampleEntity instances.
@@ -71,38 +70,28 @@ export function makeExampleRepo(appObject) {
71
70
  * This private class handles the actual implementation details
72
71
  */
73
72
  class ExampleRepoImp extends ExampleRepo {
73
+ /**
74
+ * Factory implementation for creating ExampleEntity instances
75
+ * @param id The ID for the entity's AppObject
76
+ * @returns A newly created ExampleEntity
77
+ */
78
+ entityFactory(id) {
79
+ const ao = this.appObjects.getOrCreate(id);
80
+ return makeExampleEntity(ao);
81
+ }
74
82
  /**
75
83
  * Deletes an ExampleEntity from the repository by its AppObject ID
76
84
  * @param id The ID of the entity's AppObject
77
85
  */
78
86
  deleteExampleEntity(id) {
79
- const entity = this.getForAppObject(id);
87
+ const entity = this.getById(id);
80
88
  if (!entity)
81
89
  return;
82
90
  entity.appObject.dispose();
83
- this.removeForAppObject(id);
91
+ this.removeById(id);
84
92
  }
85
93
  constructor(appObject) {
86
94
  super(appObject, ExampleRepo.type);
87
- /**
88
- * Creates a new ExampleEntity and adds it to the repository
89
- * @param id Optional ID for the entity's AppObject (generates one if not provided)
90
- * @returns The newly created ExampleEntity
91
- */
92
- this.createExampleEntity = (id) => {
93
- const idToUse = id ?? generateUniqueID();
94
- const entity = this.exampleEntityFactory(idToUse);
95
- this.add(entity);
96
- return entity;
97
- };
98
- /**
99
- * Default factory implementation for creating ExampleEntity instances
100
- * Can be overridden to create specialized entities
101
- */
102
- this.exampleEntityFactory = (id) => {
103
- const ao = this.appObjects.getOrCreate(id);
104
- return makeExampleEntity(ao);
105
- };
106
95
  }
107
96
  }
108
97
  //# sourceMappingURL=ExampleRepo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleRepo.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAEL,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAiB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKnE;;;GAGG;AACH,MAAM,OAAgB,WAAY,SAAQ,mBAAkC;IAa1E;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAU,EACV,UAAyB;QAEzB,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAoB;QACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAc,WAAW,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;;AA9CD,gDAAgD;AAChC,gBAAI,GAAG,iBAAiB,CAAC;AAgD3C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,cAAe,SAAQ,WAAW;IAatC;;;OAGG;IACH,mBAAmB,CAAC,EAAU;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAWD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QAlCrC;;;;WAIG;QACH,wBAAmB,GAAG,CAAC,EAAsB,EAAiB,EAAE;YAC9D,MAAM,OAAO,GAAG,EAAE,IAAI,gBAAgB,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAClD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjB,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAcF;;;WAGG;QACH,yBAAoB,GAAG,CAAC,EAAU,EAAiB,EAAE;YACnD,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAC3C,OAAO,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC;IAIF,CAAC;CACF","sourcesContent":["/**\r\n * ExampleRepo.ts\r\n * \r\n * This file demonstrates how to implement a repository to manage collections of entities.\r\n * Repositories are responsible for creating, retrieving, and deleting entities.\r\n * \r\n * Key concepts:\r\n * - Repositories extend AppObjectEntityRepo<T> where T is the entity type\r\n * - They provide methods to create and delete entities\r\n * - They manage collections of entities and provide access to them\r\n * - They can use custom entity factories to create specialized entities\r\n * \r\n * Usage pattern:\r\n * 1. Get or create a repository using getById, get, or addIfMissing\r\n * 2. Use the repository to create new entities\r\n * 3. Access entities through the repository's getters\r\n * 4. Delete entities through the repository when they're no longer needed\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectEntityRepo,\r\n AppObjectRepo\r\n} from \"../../AppObject\";\r\nimport { generateUniqueID } from \"../../Utilities/generateUniqueID\";\r\nimport { ExampleEntity, makeExampleEntity } from \"./ExampleEntity\";\r\n\r\n/** Type definition for a factory function that creates ExampleEntity instances */\r\nexport type ExampleEntityFactory = (id: string) => ExampleEntity;\r\n\r\n/**\r\n * ExampleRepo manages a collection of ExampleEntity instances.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleRepoType\";\r\n\r\n /** Factory function used to create new entities */\r\n abstract exampleEntityFactory: ExampleEntityFactory;\r\n\r\n /** Creates a new entity with an optional ID */\r\n abstract createExampleEntity(id?: string): ExampleEntity;\r\n \r\n /** Deletes an entity by its AppObject ID */\r\n abstract deleteExampleEntity(id: string): void;\r\n\r\n /**\r\n * Retrieves an ExampleRepo component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static get(appObj: AppObject): ExampleRepo | undefined {\r\n return appObj.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an ExampleRepo by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): ExampleRepo | undefined {\r\n return appObjects.get(id)?.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Ensures an ExampleRepo exists on the AppObject, creating one if needed\r\n * @param appObject The AppObject to check/add the component to\r\n * @returns The existing or newly created ExampleRepo\r\n */\r\n static addIfMissing(appObject: AppObject): ExampleRepo {\r\n const existing = appObject.getComponent<ExampleRepo>(ExampleRepo.type);\r\n if (existing) {\r\n return existing;\r\n } else {\r\n return makeExampleRepo(appObject);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExampleRepo\r\n * @param appObject The AppObject to attach the repo to\r\n * @returns A new ExampleRepo instance\r\n */\r\nexport function makeExampleRepo(appObject: AppObject): ExampleRepo {\r\n return new ExampleRepoImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleRepo\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleRepoImp extends ExampleRepo {\r\n /**\r\n * Creates a new ExampleEntity and adds it to the repository\r\n * @param id Optional ID for the entity's AppObject (generates one if not provided)\r\n * @returns The newly created ExampleEntity\r\n */\r\n createExampleEntity = (id: string | undefined): ExampleEntity => {\r\n const idToUse = id ?? generateUniqueID();\r\n const entity = this.exampleEntityFactory(idToUse);\r\n this.add(entity);\r\n return entity;\r\n };\r\n\r\n /**\r\n * Deletes an ExampleEntity from the repository by its AppObject ID\r\n * @param id The ID of the entity's AppObject\r\n */\r\n deleteExampleEntity(id: string): void {\r\n const entity = this.getForAppObject(id);\r\n if (!entity) return;\r\n\r\n entity.appObject.dispose();\r\n this.removeForAppObject(id);\r\n }\r\n\r\n /**\r\n * Default factory implementation for creating ExampleEntity instances\r\n * Can be overridden to create specialized entities\r\n */\r\n exampleEntityFactory = (id: string): ExampleEntity => {\r\n const ao = this.appObjects.getOrCreate(id);\r\n return makeExampleEntity(ao);\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleRepo.type);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExampleRepo.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAa,mBAAmB,EAAiB,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAiB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKnE;;;GAGG;AACH,MAAM,OAAgB,WAAY,SAAQ,mBAAkC;IAO1E;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAU,EACV,UAAyB;QAEzB,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAoB;QACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAc,WAAW,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;;AAxCD,gDAAgD;AAChC,gBAAI,GAAG,iBAAiB,CAAC;AA0C3C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,cAAe,SAAQ,WAAW;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAU;QACtB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC3C,OAAO,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,EAAU;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACF","sourcesContent":["/**\r\n * ExampleRepo.ts\r\n *\r\n * This file demonstrates how to implement a repository to manage collections of entities.\r\n * Repositories are responsible for creating, retrieving, and deleting entities.\r\n *\r\n * Key concepts:\r\n * - Repositories extend AppObjectEntityRepo<T> where T is the entity type\r\n * - They provide methods to create and delete entities\r\n * - They manage collections of entities and provide access to them\r\n * - They can use custom entity factories to create specialized entities\r\n *\r\n * Usage pattern:\r\n * 1. Get or create a repository using getById, get, or addIfMissing\r\n * 2. Use the repository to create new entities\r\n * 3. Access entities through the repository's getters\r\n * 4. Delete entities through the repository when they're no longer needed\r\n */\r\n\r\nimport { AppObject, AppObjectEntityRepo, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity, makeExampleEntity } from \"./ExampleEntity\";\r\n\r\n/** Type definition for a factory function that creates ExampleEntity instances */\r\nexport type ExampleEntityFactory = (id: string) => ExampleEntity;\r\n\r\n/**\r\n * ExampleRepo manages a collection of ExampleEntity instances.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleRepoType\";\r\n\r\n /** Deletes an entity by its AppObject ID */\r\n abstract deleteExampleEntity(id: string): void;\r\n\r\n /**\r\n * Retrieves an ExampleRepo component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static get(appObj: AppObject): ExampleRepo | undefined {\r\n return appObj.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an ExampleRepo by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): ExampleRepo | undefined {\r\n return appObjects.get(id)?.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Ensures an ExampleRepo exists on the AppObject, creating one if needed\r\n * @param appObject The AppObject to check/add the component to\r\n * @returns The existing or newly created ExampleRepo\r\n */\r\n static addIfMissing(appObject: AppObject): ExampleRepo {\r\n const existing = appObject.getComponent<ExampleRepo>(ExampleRepo.type);\r\n if (existing) {\r\n return existing;\r\n } else {\r\n return makeExampleRepo(appObject);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExampleRepo\r\n * @param appObject The AppObject to attach the repo to\r\n * @returns A new ExampleRepo instance\r\n */\r\nexport function makeExampleRepo(appObject: AppObject): ExampleRepo {\r\n return new ExampleRepoImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleRepo\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleRepoImp extends ExampleRepo {\r\n /**\r\n * Factory implementation for creating ExampleEntity instances\r\n * @param id The ID for the entity's AppObject\r\n * @returns A newly created ExampleEntity\r\n */\r\n entityFactory(id: string): ExampleEntity {\r\n const ao = this.appObjects.getOrCreate(id);\r\n return makeExampleEntity(ao);\r\n }\r\n\r\n /**\r\n * Deletes an ExampleEntity from the repository by its AppObject ID\r\n * @param id The ID of the entity's AppObject\r\n */\r\n deleteExampleEntity(id: string): void {\r\n const entity = this.getById(id);\r\n if (!entity) return;\r\n\r\n entity.appObject.dispose();\r\n this.removeById(id);\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleRepo.type);\r\n }\r\n}\r\n"]}
@@ -16,14 +16,14 @@
16
16
  * 2. Access or modify properties via getters/setters
17
17
  * 3. Register change observers to react to property updates
18
18
  */
19
- import { AppObjectEntity } from "../../AppObject";
19
+ import { AppObjectSingletonEntity, } from "../../AppObject";
20
20
  import { getSingletonComponent } from "../../AppObject/getSingletonComponent";
21
21
  import { MemoizedBoolean } from "../../Entities/MemoizedBoolean";
22
22
  /**
23
23
  * SingletonEntityExample represents a global entity with a boolean property.
24
24
  * As a singleton, only one instance exists in the application.
25
25
  */
26
- export class SingletonEntityExample extends AppObjectEntity {
26
+ export class SingletonEntityExample extends AppObjectSingletonEntity {
27
27
  }
28
28
  /** Unique type identifier for this component */
29
29
  SingletonEntityExample.type = "SingletonEntityExampleType";
@@ -57,8 +57,6 @@ class SingletonEntityExampleImp extends SingletonEntityExample {
57
57
  super(appObject, SingletonEntityExample.type);
58
58
  // MemoizedBoolean tracks changes to the boolean value and calls notifyOnChange when updated
59
59
  this.memoizedIsAuthoring = new MemoizedBoolean(false, this.notifyOnChange);
60
- // Register this entity as a singleton so it can be accessed globally
61
- this.appObjects.registerSingleton(this);
62
60
  }
63
61
  }
64
62
  //# sourceMappingURL=ExampleSingletonEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleSingletonEntity.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleSingletonEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAEL,eAAe,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;GAGG;AACH,MAAM,OAAgB,sBAAuB,SAAQ,eAAe;;AAClE,gDAAgD;AAChC,2BAAI,GAAG,4BAA4B,CAAC;AAMpD;;;;GAIG;AACI,0BAAG,GAAG,CACX,UAAyB,EACW,EAAE,CACtC,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAGnE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAoB;IAEpB,OAAO,IAAI,yBAAyB,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,yBAA0B,SAAQ,sBAAsB;IAI5D,iDAAiD;IACjD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;IACtC,CAAC;IAED,IAAI,aAAa,CAAC,GAAY;QAC5B,IAAI,CAAC,mBAAmB,CAAC,GAAG,GAAG,GAAG,CAAC;IACrC,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAbhD,4FAA4F;QACpF,wBAAmB,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAa5E,qEAAqE;QACrE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonEntity.ts\r\n * \r\n * This file demonstrates how to implement a singleton entity in the application.\r\n * Singleton entities are special entities that exist only once in the application\r\n * and can be accessed globally from anywhere.\r\n * \r\n * Key concepts:\r\n * - Singleton entities extend AppObjectEntity like regular entities\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - There's only one instance of a singleton entity in the entire application\r\n * \r\n * Usage pattern:\r\n * 1. Access the singleton entity using the static get() method\r\n * 2. Access or modify properties via getters/setters\r\n * 3. Register change observers to react to property updates\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectEntity,\r\n AppObjectRepo\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { MemoizedBoolean } from \"../../Entities/MemoizedBoolean\";\r\n\r\n/**\r\n * SingletonEntityExample represents a global entity with a boolean property.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class SingletonEntityExample extends AppObjectEntity {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"SingletonEntityExampleType\";\r\n\r\n /** Boolean property accessor methods that must be implemented */\r\n abstract get aBoolProperty(): boolean;\r\n abstract set aBoolProperty(val: boolean);\r\n\r\n /**\r\n * Global accessor for the singleton entity\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton entity or undefined if not created yet\r\n */\r\n static get = (\r\n appObjects: AppObjectRepo\r\n ): SingletonEntityExample | undefined =>\r\n getSingletonComponent(SingletonEntityExample.type, appObjects);\r\n}\r\n\r\n/**\r\n * Factory function to create a new SingletonEntityExample\r\n * @param appObject The AppObject to attach the entity to\r\n * @returns A new SingletonEntityExample instance\r\n */\r\nexport function makeSingletonEntityExample(\r\n appObject: AppObject\r\n): SingletonEntityExample {\r\n return new SingletonEntityExampleImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of SingletonEntityExample\r\n * This private class handles the actual implementation details\r\n */\r\nclass SingletonEntityExampleImp extends SingletonEntityExample {\r\n // MemoizedBoolean tracks changes to the boolean value and calls notifyOnChange when updated\r\n private memoizedIsAuthoring = new MemoizedBoolean(false, this.notifyOnChange);\r\n \r\n // Property accessors that use the memoized value\r\n get aBoolProperty() {\r\n return this.memoizedIsAuthoring.val;\r\n }\r\n \r\n set aBoolProperty(val: boolean) {\r\n this.memoizedIsAuthoring.val = val;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, SingletonEntityExample.type);\r\n // Register this entity as a singleton so it can be accessed globally\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExampleSingletonEntity.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleSingletonEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAGL,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;GAGG;AACH,MAAM,OAAgB,sBAAuB,SAAQ,wBAAwB;;AAC3E,gDAAgD;AAChC,2BAAI,GAAG,4BAA4B,CAAC;AAMpD;;;;GAIG;AACI,0BAAG,GAAG,CACX,UAAyB,EACW,EAAE,CACtC,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAGnE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAoB;IAEpB,OAAO,IAAI,yBAAyB,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,yBAA0B,SAAQ,sBAAsB;IAI5D,iDAAiD;IACjD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;IACtC,CAAC;IAED,IAAI,aAAa,CAAC,GAAY;QAC5B,IAAI,CAAC,mBAAmB,CAAC,GAAG,GAAG,GAAG,CAAC;IACrC,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAbhD,4FAA4F;QACpF,wBAAmB,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAa9E,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonEntity.ts\r\n *\r\n * This file demonstrates how to implement a singleton entity in the application.\r\n * Singleton entities are special entities that exist only once in the application\r\n * and can be accessed globally from anywhere.\r\n *\r\n * Key concepts:\r\n * - Singleton entities extend AppObjectEntity like regular entities\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - There's only one instance of a singleton entity in the entire application\r\n *\r\n * Usage pattern:\r\n * 1. Access the singleton entity using the static get() method\r\n * 2. Access or modify properties via getters/setters\r\n * 3. Register change observers to react to property updates\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectSingletonEntity,\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { MemoizedBoolean } from \"../../Entities/MemoizedBoolean\";\r\n\r\n/**\r\n * SingletonEntityExample represents a global entity with a boolean property.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class SingletonEntityExample extends AppObjectSingletonEntity {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"SingletonEntityExampleType\";\r\n\r\n /** Boolean property accessor methods that must be implemented */\r\n abstract get aBoolProperty(): boolean;\r\n abstract set aBoolProperty(val: boolean);\r\n\r\n /**\r\n * Global accessor for the singleton entity\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton entity or undefined if not created yet\r\n */\r\n static get = (\r\n appObjects: AppObjectRepo\r\n ): SingletonEntityExample | undefined =>\r\n getSingletonComponent(SingletonEntityExample.type, appObjects);\r\n}\r\n\r\n/**\r\n * Factory function to create a new SingletonEntityExample\r\n * @param appObject The AppObject to attach the entity to\r\n * @returns A new SingletonEntityExample instance\r\n */\r\nexport function makeSingletonEntityExample(\r\n appObject: AppObject\r\n): SingletonEntityExample {\r\n return new SingletonEntityExampleImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of SingletonEntityExample\r\n * This private class handles the actual implementation details\r\n */\r\nclass SingletonEntityExampleImp extends SingletonEntityExample {\r\n // MemoizedBoolean tracks changes to the boolean value and calls notifyOnChange when updated\r\n private memoizedIsAuthoring = new MemoizedBoolean(false, this.notifyOnChange);\r\n\r\n // Property accessors that use the memoized value\r\n get aBoolProperty() {\r\n return this.memoizedIsAuthoring.val;\r\n }\r\n\r\n set aBoolProperty(val: boolean) {\r\n this.memoizedIsAuthoring.val = val;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, SingletonEntityExample.type);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,60 @@
1
+ import { DomainFactory } from "../../DomainFactories";
2
+ import { makeSingletonEntityExample } from "../Entities/ExampleSingletonEntity";
3
+ import { makeExampleSingletonPM } from "../PMs/ExampleSingletonPM";
4
+ import { makeToggleExampleBooleanUC } from "../UCs/ToggleExampleBooleanUC";
5
+ /**
6
+ * Factory responsible for setting up the Example Feature domain components.
7
+ *
8
+ * This factory initializes all entities, use cases, and presentation models
9
+ * required for the Example Feature functionality. It follows the domain-driven
10
+ * design pattern by organizing components into their respective layers.
11
+ *
12
+ * @extends DomainFactory
13
+ */
14
+ export class ExampleFeatureFactory extends DomainFactory {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.factoryName = "ExampleFeatureFactory";
18
+ }
19
+ /**
20
+ * Sets up all entities required for the Example Feature.
21
+ *
22
+ * Initializes singleton entities that maintain the state and business
23
+ * logic for the example feature functionality.
24
+ */
25
+ setupEntities() {
26
+ makeSingletonEntityExample(this.appObject);
27
+ }
28
+ /**
29
+ * Sets up all use cases for the Example Feature.
30
+ *
31
+ * Initializes use cases that define the business operations and
32
+ * workflows available in the example feature.
33
+ */
34
+ setupUCs() {
35
+ makeToggleExampleBooleanUC(this.appObject);
36
+ }
37
+ /**
38
+ * Sets up all presentation models for the Example Feature.
39
+ *
40
+ * Initializes presentation models that handle the view logic and
41
+ * state management for UI components related to the example feature.
42
+ */
43
+ setupPMs() {
44
+ makeExampleSingletonPM(this.appObject);
45
+ }
46
+ /**
47
+ * Performs any final setup operations after all components are initialized.
48
+ *
49
+ * This method is called after entities, use cases, and presentation models
50
+ * have been set up. Currently no additional setup is required for this feature.
51
+ */
52
+ finalSetup() {
53
+ // No additional setup required for this feature
54
+ }
55
+ }
56
+ export function makeExampleFeatureFactory(appObjects) {
57
+ const appObject = appObjects.getOrCreate("FeatureName");
58
+ return new ExampleFeatureFactory(appObject);
59
+ }
60
+ //# sourceMappingURL=ExampleFeatureFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleFeatureFactory.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Factory/ExampleFeatureFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;;;;;;;GAQG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IAAxD;;QAEC,gBAAW,GAAG,uBAAuB,CAAC;IA6CvC,CAAC;IA3CA;;;;;OAKG;IACH,aAAa;QAEZ,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QAEP,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QAEP,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,UAAU;QAET,gDAAgD;IACjD,CAAC;CACD;AAED,MAAM,UAAU,yBAAyB,CAAC,UAAyB;IAClE,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IACxD,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { AppObjectRepo } from \"../../AppObject\";\r\nimport { DomainFactory } from \"../../DomainFactories\";\r\nimport { makeSingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\nimport { makeExampleSingletonPM } from \"../PMs/ExampleSingletonPM\";\r\nimport { makeToggleExampleBooleanUC } from \"../UCs/ToggleExampleBooleanUC\";\r\n\r\n/**\r\n * Factory responsible for setting up the Example Feature domain components.\r\n * \r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Example Feature functionality. It follows the domain-driven\r\n * design pattern by organizing components into their respective layers.\r\n * \r\n * @extends DomainFactory\r\n */\r\nexport class ExampleFeatureFactory extends DomainFactory\r\n{\r\n\tfactoryName = \"ExampleFeatureFactory\";\r\n\r\n\t/**\r\n\t * Sets up all entities required for the Example Feature.\r\n\t * \r\n\t * Initializes singleton entities that maintain the state and business\r\n\t * logic for the example feature functionality.\r\n\t */\r\n\tsetupEntities(): void\r\n\t{\r\n\t\tmakeSingletonEntityExample(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up all use cases for the Example Feature.\r\n\t * \r\n\t * Initializes use cases that define the business operations and\r\n\t * workflows available in the example feature.\r\n\t */\r\n\tsetupUCs(): void\r\n\t{\r\n\t\tmakeToggleExampleBooleanUC(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up all presentation models for the Example Feature.\r\n\t * \r\n\t * Initializes presentation models that handle the view logic and\r\n\t * state management for UI components related to the example feature.\r\n\t */\r\n\tsetupPMs(): void\r\n\t{\r\n\t\tmakeExampleSingletonPM(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Performs any final setup operations after all components are initialized.\r\n\t * \r\n\t * This method is called after entities, use cases, and presentation models\r\n\t * have been set up. Currently no additional setup is required for this feature.\r\n\t */\r\n\tfinalSetup(): void\r\n\t{\r\n\t\t// No additional setup required for this feature\r\n\t}\r\n}\r\n\r\nexport function makeExampleFeatureFactory(appObjects: AppObjectRepo):ExampleFeatureFactory {\r\n\tconst appObject = appObjects.getOrCreate(\"FeatureName\");\r\n\treturn new ExampleFeatureFactory(appObject);\r\n}"]}
@@ -65,28 +65,20 @@ class ExamplePMImp extends ExamplePM {
65
65
  }
66
66
  constructor(appObject) {
67
67
  super(appObject, ExamplePM.type);
68
+ /** Default view model before any entity data is available */
69
+ this.defaultVM = "";
68
70
  /**
69
71
  * Handler for entity change events
70
72
  * Transforms entity data into a view model and updates views
71
73
  */
72
- this.onEntityChange = () => {
73
- if (!this.exampleEntity)
74
- return;
74
+ this.formVM = () => {
75
75
  // In this simple case, our view model is just the string property value
76
76
  this.doUpdateView(this.exampleEntity.aStringProperty);
77
77
  };
78
- /**
79
- * Cleanup method called when the PM is being disposed
80
- * Removes any observers to prevent memory leaks
81
- */
82
- this.dispose = () => {
83
- super.dispose();
84
- this.exampleEntity?.removeChangeObserver(this.onEntityChange);
85
- };
86
78
  // Register as an observer of the entity to receive change notifications
87
- this.exampleEntity?.addChangeObserver(this.onEntityChange);
79
+ this.observeEntity(this.exampleEntity);
88
80
  // Call the change handler initially to set up the initial view model
89
- this.onEntityChange();
81
+ this.formVM();
90
82
  }
91
83
  }
92
84
  //# sourceMappingURL=ExamplePM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExamplePM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExamplePM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAa,WAAW,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAgB,SAAU,SAAQ,WAAmB;IAIzD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,EAAU,EAAE,UAAyB;QAClD,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAY,SAAS,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;;AAXD,gDAAgD;AAChC,cAAI,GAAG,eAAe,CAAC;AAazC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAoB;IAChD,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,YAAa,SAAQ,SAAS;IAClC;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAgB,aAAa,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,CAAS,EAAE,CAAS;QAC9B,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAsBD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QArBnC;;;WAGG;QACH,mBAAc,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,aAAa;gBAAE,OAAO;YAEhC,wEAAwE;YACxE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC;QAEF;;;WAGG;QACH,YAAO,GAAG,GAAS,EAAE;YACnB,KAAK,CAAC,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAChE,CAAC,CAAC;QAKA,wEAAwE;QACxE,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3D,qEAAqE;QACrE,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF","sourcesContent":["/**\r\n * ExamplePM.ts\r\n * \r\n * This file demonstrates how to implement a Presentation Manager (PM) component.\r\n * PMs are responsible for transforming entity data into view models (VMs) for the UI.\r\n * They observe entities for changes and update their views when data changes.\r\n * \r\n * Key concepts:\r\n * - PMs extend AppObjectPM<VM> where VM is the view model type\r\n * - They observe entities and transform entity data into view models\r\n * - They notify UI components (views) when view models change\r\n * - Each PM instance is associated with a specific AppObject\r\n * \r\n * Usage pattern:\r\n * 1. Get a PM instance using getById\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport { AppObject, AppObjectPM, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity } from \"../Entities/ExampleEntity\";\r\n\r\n/**\r\n * ExamplePM transforms ExampleEntity data into a simple string view model.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExamplePM extends AppObjectPM<string> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExamplePMType\";\r\n\r\n /**\r\n * Retrieves an ExamplePM by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExamplePM component or undefined if not found\r\n */\r\n static getById(id: string, appObjects: AppObjectRepo) {\r\n return appObjects.get(id)?.getComponent<ExamplePM>(ExamplePM.type);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExamplePM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExamplePM instance\r\n */\r\nexport function makeExamplePM(appObject: AppObject): ExamplePM {\r\n return new ExamplePMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExamplePM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExamplePMImp extends ExamplePM {\r\n /**\r\n * Gets the ExampleEntity from the same AppObject\r\n * Uses getCachedLocalComponent for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedLocalComponent<ExampleEntity>(ExampleEntity.type);\r\n }\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: string, b: string): boolean {\r\n return a === b;\r\n }\r\n\r\n /**\r\n * Handler for entity change events\r\n * Transforms entity data into a view model and updates views\r\n */\r\n onEntityChange = () => {\r\n if (!this.exampleEntity) return;\r\n\r\n // In this simple case, our view model is just the string property value\r\n this.doUpdateView(this.exampleEntity.aStringProperty);\r\n };\r\n\r\n /**\r\n * Cleanup method called when the PM is being disposed\r\n * Removes any observers to prevent memory leaks\r\n */\r\n dispose = (): void => {\r\n super.dispose();\r\n this.exampleEntity?.removeChangeObserver(this.onEntityChange);\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExamplePM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.exampleEntity?.addChangeObserver(this.onEntityChange);\r\n \r\n // Call the change handler initially to set up the initial view model\r\n this.onEntityChange();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExamplePM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExamplePM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAa,WAAW,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAgB,SAAU,SAAQ,WAAmB;IAIzD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,EAAU,EAAE,UAAyB;QAClD,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAY,SAAS,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;;AAXD,gDAAgD;AAChC,cAAI,GAAG,eAAe,CAAC;AAazC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAoB;IAChD,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,YAAa,SAAQ,SAAS;IAIlC;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAgB,aAAa,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,CAAS,EAAE,CAAS;QAC9B,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAYD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QA9BnC,6DAA6D;QACpD,cAAS,GAAG,EAAE,CAAC;QAkBxB;;;WAGG;QACH,WAAM,GAAG,GAAG,EAAE;YACZ,wEAAwE;YACxE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC;QAMA,wEAAwE;QACxE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvC,qEAAqE;QACrE,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF","sourcesContent":["/**\r\n * ExamplePM.ts\r\n *\r\n * This file demonstrates how to implement a Presentation Manager (PM) component.\r\n * PMs are responsible for transforming entity data into view models (VMs) for the UI.\r\n * They observe entities for changes and update their views when data changes.\r\n *\r\n * Key concepts:\r\n * - PMs extend AppObjectPM<VM> where VM is the view model type\r\n * - They observe entities and transform entity data into view models\r\n * - They notify UI components (views) when view models change\r\n * - Each PM instance is associated with a specific AppObject\r\n *\r\n * Usage pattern:\r\n * 1. Get a PM instance using getById\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport { AppObject, AppObjectPM, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity } from \"../Entities/ExampleEntity\";\r\n\r\n/**\r\n * ExamplePM transforms ExampleEntity data into a simple string view model.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExamplePM extends AppObjectPM<string> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExamplePMType\";\r\n\r\n /**\r\n * Retrieves an ExamplePM by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExamplePM component or undefined if not found\r\n */\r\n static getById(id: string, appObjects: AppObjectRepo) {\r\n return appObjects.get(id)?.getComponent<ExamplePM>(ExamplePM.type);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExamplePM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExamplePM instance\r\n */\r\nexport function makeExamplePM(appObject: AppObject): ExamplePM {\r\n return new ExamplePMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExamplePM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExamplePMImp extends ExamplePM {\r\n /** Default view model before any entity data is available */\r\n readonly defaultVM = \"\";\r\n\r\n /**\r\n * Gets the ExampleEntity from the same AppObject\r\n * Uses getCachedLocalComponent for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedLocalComponent<ExampleEntity>(ExampleEntity.type);\r\n }\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: string, b: string): boolean {\r\n return a === b;\r\n }\r\n\r\n /**\r\n * Handler for entity change events\r\n * Transforms entity data into a view model and updates views\r\n */\r\n formVM = () => {\r\n // In this simple case, our view model is just the string property value\r\n this.doUpdateView(this.exampleEntity.aStringProperty);\r\n };\r\n\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExamplePM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.observeEntity(this.exampleEntity);\r\n\r\n // Call the change handler initially to set up the initial view model\r\n this.formVM();\r\n }\r\n}\r\n"]}
@@ -6,10 +6,10 @@
6
6
  * accessed globally. They transform data from singleton entities into view models.
7
7
  *
8
8
  * Key concepts:
9
- * - Singleton PMs extend AppObjectPM<VM> like regular PMs
10
- * - They register themselves as singletons with appObjects.registerSingleton()
9
+ * - Singleton PMs extend AppObjectSingletonPM<VM> which handles singleton registration automatically
11
10
  * - They're accessed through a static get() method using getSingletonComponent()
12
11
  * - They typically observe singleton entities and provide data to multiple UI components
12
+ * - They use formVM() to transform entity data into view models
13
13
  *
14
14
  * Usage pattern:
15
15
  * 1. Access the singleton PM using the static get() method
@@ -17,14 +17,14 @@
17
17
  * 3. PM will call the view callbacks with updated view models when entities change
18
18
  * 4. Remove UI components with removeView(callback) when they're unmounted
19
19
  */
20
- import { AppObjectPM, } from "../../AppObject";
20
+ import { AppObjectSingletonPM, } from "../../AppObject";
21
21
  import { getSingletonComponent } from "../../AppObject/getSingletonComponent";
22
22
  import { SingletonEntityExample } from "../Entities/ExampleSingletonEntity";
23
23
  /**
24
24
  * ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.
25
25
  * As a singleton, only one instance exists in the application.
26
26
  */
27
- export class ExampleSingletonPM extends AppObjectPM {
27
+ export class ExampleSingletonPM extends AppObjectSingletonPM {
28
28
  }
29
29
  /** Unique type identifier for this component */
30
30
  ExampleSingletonPM.type = "ExampleSingletonPMType";
@@ -39,7 +39,7 @@ ExampleSingletonPM.get = (appObjects) => getSingletonComponent(ExampleSingletonP
39
39
  * UI components can use this initially or when the PM is not found
40
40
  */
41
41
  export const defaultSlideNavigationVM = {
42
- aBoolProperty: true
42
+ aBoolProperty: true,
43
43
  };
44
44
  /**
45
45
  * Factory function to create a new ExampleSingletonPM
@@ -73,12 +73,10 @@ class ExampleSingletonPMImp extends ExampleSingletonPM {
73
73
  constructor(appObject) {
74
74
  super(appObject, ExampleSingletonPM.type);
75
75
  /**
76
- * Handler for entity change events
77
76
  * Transforms entity data into a view model and updates views
77
+ * Called automatically when observed entities change
78
78
  */
79
- this.onEntityChange = () => {
80
- if (!this.exampleEntity)
81
- return;
79
+ this.formVM = () => {
82
80
  // Extract the boolean property from the entity
83
81
  const aBoolProperty = this.exampleEntity.aBoolProperty;
84
82
  // Create a view model with the extracted data
@@ -87,11 +85,9 @@ class ExampleSingletonPMImp extends ExampleSingletonPM {
87
85
  this.doUpdateView(vm);
88
86
  };
89
87
  // Register as an observer of the entity to receive change notifications
90
- this.exampleEntity?.addChangeObserver(this.onEntityChange);
88
+ this.observeEntity(this.exampleEntity);
91
89
  // Call the change handler initially to set up the initial view model
92
- this.onEntityChange();
93
- // Register this PM as a singleton so it can be accessed globally
94
- this.appObjects.registerSingleton(this);
90
+ this.formVM();
95
91
  }
96
92
  }
97
93
  //# sourceMappingURL=ExampleSingletonPM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleSingletonPM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExampleSingletonPM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEL,WAAW,GAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAS5E;;;GAGG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,WAAsB;;AACrE,gDAAgD;AAChC,uBAAI,GAAG,wBAAwB,CAAC;AAEhD;;;;GAIG;AACI,sBAAG,GAAG,CAAC,UAAyB,EAAkC,EAAE,CACzE,qBAAqB,CAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAG/D;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAc;IACjD,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAoB;IAEpB,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,qBAAsB,SAAQ,kBAAkB;IACpD;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,kBAAkB,CAC5B,sBAAsB,CAAC,IAAI,CAC5B,CAAC;IACJ,CAAC;IAmBD;;;OAGG;IACH,WAAW,CAAC,CAAY,EAAE,CAAY;QACpC,IAAI,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;QA3B5C;;;WAGG;QACH,mBAAc,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,aAAa;gBAAE,OAAO;YAEhC,+CAA+C;YAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;YAEvD,8CAA8C;YAC9C,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YAE7B,sDAAsD;YACtD,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC;QAcA,wEAAwE;QACxE,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3D,qEAAqE;QACrE,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,iEAAiE;QACjE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonPM.ts\r\n * \r\n * This file demonstrates how to implement a Singleton Presentation Manager (PM).\r\n * Singleton PMs are special PMs that exist only once in the application and can be\r\n * accessed globally. They transform data from singleton entities into view models.\r\n * \r\n * Key concepts:\r\n * - Singleton PMs extend AppObjectPM<VM> like regular PMs\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - They typically observe singleton entities and provide data to multiple UI components\r\n * \r\n * Usage pattern:\r\n * 1. Access the singleton PM using the static get() method\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectPM,\r\n AppObjectRepo,\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { SingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\n\r\n/**\r\n * Interface defining the structure of the view model provided by ExampleSingletonPM\r\n */\r\nexport interface ExampleVM {\r\n aBoolProperty: boolean;\r\n}\r\n\r\n/**\r\n * ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class ExampleSingletonPM extends AppObjectPM<ExampleVM> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleSingletonPMType\";\r\n\r\n /**\r\n * Global accessor for the singleton PM\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton PM or undefined if not created yet\r\n */\r\n static get = (appObjects: AppObjectRepo): ExampleSingletonPM | undefined =>\r\n getSingletonComponent(ExampleSingletonPM.type, appObjects);\r\n}\r\n\r\n/**\r\n * Default view model used when no data is available\r\n * UI components can use this initially or when the PM is not found\r\n */\r\nexport const defaultSlideNavigationVM: ExampleVM = {\r\n aBoolProperty: true\r\n};\r\n\r\n/**\r\n * Factory function to create a new ExampleSingletonPM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExampleSingletonPM instance\r\n */\r\nexport function makeExampleSingletonPM(\r\n appObject: AppObject\r\n): ExampleSingletonPM {\r\n return new ExampleSingletonPMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleSingletonPM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleSingletonPMImp extends ExampleSingletonPM {\r\n /**\r\n * Gets the SingletonEntityExample from the application\r\n * Uses getCachedSingleton for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedSingleton<SingletonEntityExample>(\r\n SingletonEntityExample.type\r\n );\r\n }\r\n\r\n /**\r\n * Handler for entity change events\r\n * Transforms entity data into a view model and updates views\r\n */\r\n onEntityChange = () => {\r\n if (!this.exampleEntity) return;\r\n\r\n // Extract the boolean property from the entity\r\n const aBoolProperty = this.exampleEntity.aBoolProperty;\r\n\r\n // Create a view model with the extracted data\r\n const vm = { aBoolProperty };\r\n\r\n // Update all registered views with the new view model\r\n this.doUpdateView(vm);\r\n };\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: ExampleVM, b: ExampleVM): boolean {\r\n if (a.aBoolProperty !== b.aBoolProperty) return false;\r\n return true;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleSingletonPM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.exampleEntity?.addChangeObserver(this.onEntityChange);\r\n \r\n // Call the change handler initially to set up the initial view model\r\n this.onEntityChange();\r\n \r\n // Register this PM as a singleton so it can be accessed globally\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExampleSingletonPM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExampleSingletonPM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAGL,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAS5E;;;GAGG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,oBAA+B;;AAC9E,gDAAgD;AAChC,uBAAI,GAAG,wBAAwB,CAAC;AAEhD;;;;GAIG;AACI,sBAAG,GAAG,CAAC,UAAyB,EAAkC,EAAE,CACzE,qBAAqB,CAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAG/D;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAc;IACjD,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAoB;IAEpB,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,qBAAsB,SAAQ,kBAAkB;IACpD;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,kBAAkB,CAC5B,sBAAsB,CAAC,IAAI,CAC5B,CAAC;IACJ,CAAC;IAiBD;;;OAGG;IACH,WAAW,CAAC,CAAY,EAAE,CAAY;QACpC,IAAI,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAzB5C;;;WAGG;QACH,WAAM,GAAG,GAAG,EAAE;YACZ,+CAA+C;YAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;YAEvD,8CAA8C;YAC9C,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YAE7B,sDAAsD;YACtD,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC;QAcA,wEAAwE;QACxE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvC,qEAAqE;QACrE,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonPM.ts\r\n *\r\n * This file demonstrates how to implement a Singleton Presentation Manager (PM).\r\n * Singleton PMs are special PMs that exist only once in the application and can be\r\n * accessed globally. They transform data from singleton entities into view models.\r\n *\r\n * Key concepts:\r\n * - Singleton PMs extend AppObjectSingletonPM<VM> which handles singleton registration automatically\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - They typically observe singleton entities and provide data to multiple UI components\r\n * - They use formVM() to transform entity data into view models\r\n *\r\n * Usage pattern:\r\n * 1. Access the singleton PM using the static get() method\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectSingletonPM,\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { SingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\n\r\n/**\r\n * Interface defining the structure of the view model provided by ExampleSingletonPM\r\n */\r\nexport interface ExampleVM {\r\n aBoolProperty: boolean;\r\n}\r\n\r\n/**\r\n * ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class ExampleSingletonPM extends AppObjectSingletonPM<ExampleVM> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleSingletonPMType\";\r\n\r\n /**\r\n * Global accessor for the singleton PM\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton PM or undefined if not created yet\r\n */\r\n static get = (appObjects: AppObjectRepo): ExampleSingletonPM | undefined =>\r\n getSingletonComponent(ExampleSingletonPM.type, appObjects);\r\n}\r\n\r\n/**\r\n * Default view model used when no data is available\r\n * UI components can use this initially or when the PM is not found\r\n */\r\nexport const defaultSlideNavigationVM: ExampleVM = {\r\n aBoolProperty: true,\r\n};\r\n\r\n/**\r\n * Factory function to create a new ExampleSingletonPM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExampleSingletonPM instance\r\n */\r\nexport function makeExampleSingletonPM(\r\n appObject: AppObject\r\n): ExampleSingletonPM {\r\n return new ExampleSingletonPMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleSingletonPM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleSingletonPMImp extends ExampleSingletonPM {\r\n /**\r\n * Gets the SingletonEntityExample from the application\r\n * Uses getCachedSingleton for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedSingleton<SingletonEntityExample>(\r\n SingletonEntityExample.type\r\n );\r\n }\r\n\r\n /**\r\n * Transforms entity data into a view model and updates views\r\n * Called automatically when observed entities change\r\n */\r\n formVM = () => {\r\n // Extract the boolean property from the entity\r\n const aBoolProperty = this.exampleEntity.aBoolProperty;\r\n\r\n // Create a view model with the extracted data\r\n const vm = { aBoolProperty };\r\n\r\n // Update all registered views with the new view model\r\n this.doUpdateView(vm);\r\n };\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: ExampleVM, b: ExampleVM): boolean {\r\n if (a.aBoolProperty !== b.aBoolProperty) return false;\r\n return true;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleSingletonPM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.observeEntity(this.exampleEntity);\r\n\r\n // Call the change handler initially to set up the initial view model\r\n this.formVM();\r\n }\r\n}\r\n"]}
@@ -70,10 +70,6 @@ class EditSlideTextUCImp extends EditExampleStringUC {
70
70
  * @param text The new string value to set
71
71
  */
72
72
  this.editExampleString = (text) => {
73
- if (!this.exampleEntity) {
74
- this.warn("Unable to find AppState");
75
- return;
76
- }
77
73
  // Update the entity property, which will trigger PM updates and UI refreshes
78
74
  this.exampleEntity.aStringProperty = text;
79
75
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EditExampleStringUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/EditExampleStringUC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAA4B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,WAAW;IAU3D;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAsB,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAU,EACV,UAAyB;QAEzB,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAsB,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;;AA7BD,gDAAgD;AAChC,wBAAI,GAAG,yBAAyB,CAAC;AA+BnD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAoB;IACtD,OAAO,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,kBAAmB,SAAQ,mBAAmB;IAClD;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAgB,aAAa,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAgBD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAf7C;;;WAGG;QACH,sBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;YACnC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;gBACxB,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;gBACrC,OAAO;YACT,CAAC;YAED,6EAA6E;YAC7E,IAAI,CAAC,aAAa,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5C,CAAC,CAAC;IAIF,CAAC;CACF","sourcesContent":["/**\r\n * EditExampleStringUC.ts\r\n * \r\n * This file demonstrates how to implement a Use Case (UC) component.\r\n * UCs handle business logic and operations that modify entities.\r\n * They encapsulate specific actions that can be performed in the application.\r\n * \r\n * Key concepts:\r\n * - UCs extend AppObjectUC and provide methods for specific operations\r\n * - They implement business logic for modifying entities\r\n * - They validate inputs and handle errors\r\n * - Each UC instance is associated with a specific AppObject\r\n * \r\n * Usage pattern:\r\n * 1. Get a UC instance using getById or get\r\n * 2. Call the UC's methods to perform operations\r\n * 3. The UC will update entities, which will trigger PM updates and UI refreshes\r\n */\r\n\r\nimport { AppObject, AppObjectRepo, AppObjectUC } from \"../../AppObject\";\r\nimport { ExampleEntity } from \"../Entities/ExampleEntity\";\r\n\r\n/**\r\n * EditExampleStringUC provides functionality to update the string property of an ExampleEntity.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class EditExampleStringUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"EditExampleStringUCType\";\r\n\r\n /**\r\n * Updates the string property of the associated ExampleEntity\r\n * @param text The new string value to set\r\n */\r\n abstract editExampleString(text: string): void;\r\n\r\n /**\r\n * Retrieves an EditExampleStringUC component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The EditExampleStringUC component or undefined if not found\r\n */\r\n static get(appObj: AppObject): EditExampleStringUC | undefined {\r\n return appObj.getComponent<EditExampleStringUC>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an EditExampleStringUC by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The EditExampleStringUC component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): EditExampleStringUC | undefined {\r\n return appObjects.get(id)?.getComponent<EditExampleStringUC>(this.type);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new EditExampleStringUC\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new EditExampleStringUC instance\r\n */\r\nexport function makeEditSlideTextUC(appObject: AppObject): EditExampleStringUC {\r\n return new EditSlideTextUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of EditExampleStringUC\r\n * This private class handles the actual implementation details\r\n */\r\nclass EditSlideTextUCImp extends EditExampleStringUC {\r\n /**\r\n * Gets the ExampleEntity from the same AppObject\r\n * Uses getCachedLocalComponent for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedLocalComponent<ExampleEntity>(ExampleEntity.type);\r\n }\r\n\r\n /**\r\n * Implements the editExampleString method to update the entity's string property\r\n * @param text The new string value to set\r\n */\r\n editExampleString = (text: string) => {\r\n if (!this.exampleEntity) {\r\n this.warn(\"Unable to find AppState\");\r\n return;\r\n }\r\n\r\n // Update the entity property, which will trigger PM updates and UI refreshes\r\n this.exampleEntity.aStringProperty = text;\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, EditExampleStringUC.type);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"EditExampleStringUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/EditExampleStringUC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAA4B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,WAAW;IAU3D;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAsB,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAU,EACV,UAAyB;QAEzB,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAsB,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;;AA7BD,gDAAgD;AAChC,wBAAI,GAAG,yBAAyB,CAAC;AA+BnD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAoB;IACtD,OAAO,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,kBAAmB,SAAQ,mBAAmB;IAClD;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAgB,aAAa,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAYD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAX7C;;;WAGG;QACH,sBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;YAEnC,6EAA6E;YAC7E,IAAI,CAAC,aAAa,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5C,CAAC,CAAC;IAIF,CAAC;CACF","sourcesContent":["/**\r\n * EditExampleStringUC.ts\r\n * \r\n * This file demonstrates how to implement a Use Case (UC) component.\r\n * UCs handle business logic and operations that modify entities.\r\n * They encapsulate specific actions that can be performed in the application.\r\n * \r\n * Key concepts:\r\n * - UCs extend AppObjectUC and provide methods for specific operations\r\n * - They implement business logic for modifying entities\r\n * - They validate inputs and handle errors\r\n * - Each UC instance is associated with a specific AppObject\r\n * \r\n * Usage pattern:\r\n * 1. Get a UC instance using getById or get\r\n * 2. Call the UC's methods to perform operations\r\n * 3. The UC will update entities, which will trigger PM updates and UI refreshes\r\n */\r\n\r\nimport { AppObject, AppObjectRepo, AppObjectUC } from \"../../AppObject\";\r\nimport { ExampleEntity } from \"../Entities/ExampleEntity\";\r\n\r\n/**\r\n * EditExampleStringUC provides functionality to update the string property of an ExampleEntity.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class EditExampleStringUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"EditExampleStringUCType\";\r\n\r\n /**\r\n * Updates the string property of the associated ExampleEntity\r\n * @param text The new string value to set\r\n */\r\n abstract editExampleString(text: string): void;\r\n\r\n /**\r\n * Retrieves an EditExampleStringUC component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The EditExampleStringUC component or undefined if not found\r\n */\r\n static get(appObj: AppObject): EditExampleStringUC | undefined {\r\n return appObj.getComponent<EditExampleStringUC>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an EditExampleStringUC by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The EditExampleStringUC component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): EditExampleStringUC | undefined {\r\n return appObjects.get(id)?.getComponent<EditExampleStringUC>(this.type);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new EditExampleStringUC\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new EditExampleStringUC instance\r\n */\r\nexport function makeEditSlideTextUC(appObject: AppObject): EditExampleStringUC {\r\n return new EditSlideTextUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of EditExampleStringUC\r\n * This private class handles the actual implementation details\r\n */\r\nclass EditSlideTextUCImp extends EditExampleStringUC {\r\n /**\r\n * Gets the ExampleEntity from the same AppObject\r\n * Uses getCachedLocalComponent for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedLocalComponent<ExampleEntity>(ExampleEntity.type);\r\n }\r\n\r\n /**\r\n * Implements the editExampleString method to update the entity's string property\r\n * @param text The new string value to set\r\n */\r\n editExampleString = (text: string) => {\r\n\r\n // Update the entity property, which will trigger PM updates and UI refreshes\r\n this.exampleEntity.aStringProperty = text;\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, EditExampleStringUC.type);\r\n }\r\n}\r\n"]}
@@ -16,14 +16,14 @@
16
16
  * 2. Call the UC's methods to perform operations
17
17
  * 3. The UC will update entities, which will trigger PM updates and UI refreshes
18
18
  */
19
- import { AppObjectUC } from "../../AppObject";
19
+ import { AppObjectSingletonUC, } from "../../AppObject";
20
20
  import { getSingletonComponent } from "../../AppObject/getSingletonComponent";
21
21
  import { SingletonEntityExample } from "../Entities/ExampleSingletonEntity";
22
22
  /**
23
23
  * ToggleExampleBooleanUC provides functionality to toggle the boolean property
24
24
  * of the SingletonEntityExample. As a singleton, only one instance exists in the application.
25
25
  */
26
- export class ToggleExampleBooleanUC extends AppObjectUC {
26
+ export class ToggleExampleBooleanUC extends AppObjectSingletonUC {
27
27
  }
28
28
  /** Unique type identifier for this component */
29
29
  ToggleExampleBooleanUC.type = "ToggleExampleBooleanUCType";
@@ -59,16 +59,10 @@ class ToggleExampleBooleanUCImp extends ToggleExampleBooleanUC {
59
59
  * Implements the toggleExampleBoolean method to invert the entity's boolean property
60
60
  */
61
61
  this.toggleExampleBoolean = () => {
62
- if (!this.singletonEntityExample) {
63
- this.warn("Unable to find SingletonEntityExample");
64
- return;
65
- }
66
62
  // Toggle the boolean property by inverting its current value
67
63
  this.singletonEntityExample.aBoolProperty =
68
- !this.singletonEntityExample?.aBoolProperty;
64
+ !this.singletonEntityExample.aBoolProperty;
69
65
  };
70
- // Register this UC as a singleton so it can be accessed globally
71
- this.appObjects.registerSingleton(this);
72
66
  }
73
67
  }
74
68
  //# sourceMappingURL=ToggleExampleBooleanUC.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToggleExampleBooleanUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/ToggleExampleBooleanUC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAGL,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAgB,sBAAuB,SAAQ,WAAW;;AAC9D,gDAAgD;AAChC,2BAAI,GAAG,4BAA4B,CAAC;AAOpD;;;;GAIG;AACI,0BAAG,GAAG,CACX,UAAyB,EACW,EAAE,CACtC,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAGnE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAoB;IAEpB,OAAO,IAAI,yBAAyB,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,yBAA0B,SAAQ,sBAAsB;IAC5D;;;OAGG;IACH,IAAY,sBAAsB;QAChC,OAAO,IAAI,CAAC,kBAAkB,CAC5B,sBAAsB,CAAC,IAAI,CAC5B,CAAC;IACJ,CAAC;IAgBD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAfhD;;WAEG;QACH,yBAAoB,GAAG,GAAG,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBACjC,IAAI,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;gBACnD,OAAO;YACT,CAAC;YAED,6DAA6D;YAC7D,IAAI,CAAC,sBAAsB,CAAC,aAAa;gBACvC,CAAC,IAAI,CAAC,sBAAsB,EAAE,aAAa,CAAC;QAChD,CAAC,CAAC;QAIA,iEAAiE;QACjE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * ToggleExampleBooleanUC.ts\r\n * \r\n * This file demonstrates how to implement a Singleton Use Case (UC) component.\r\n * Singleton UCs are special UCs that exist only once in the application and can be\r\n * accessed globally. They handle business logic and operations that modify singleton entities.\r\n * \r\n * Key concepts:\r\n * - Singleton UCs extend AppObjectUC like regular UCs\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - They typically operate on singleton entities\r\n * \r\n * Usage pattern:\r\n * 1. Access the singleton UC using the static get() method\r\n * 2. Call the UC's methods to perform operations\r\n * 3. The UC will update entities, which will trigger PM updates and UI refreshes\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { SingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\n\r\n/**\r\n * ToggleExampleBooleanUC provides functionality to toggle the boolean property\r\n * of the SingletonEntityExample. As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class ToggleExampleBooleanUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ToggleExampleBooleanUCType\";\r\n\r\n /**\r\n * Toggles the boolean property of the SingletonEntityExample\r\n */\r\n abstract toggleExampleBoolean(): void;\r\n\r\n /**\r\n * Global accessor for the singleton UC\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton UC or undefined if not created yet\r\n */\r\n static get = (\r\n appObjects: AppObjectRepo\r\n ): ToggleExampleBooleanUC | undefined =>\r\n getSingletonComponent(ToggleExampleBooleanUC.type, appObjects);\r\n}\r\n\r\n/**\r\n * Factory function to create a new ToggleExampleBooleanUC\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new ToggleExampleBooleanUC instance\r\n */\r\nexport function makeToggleExampleBooleanUC(\r\n appObject: AppObject\r\n): ToggleExampleBooleanUC {\r\n return new ToggleExampleBooleanUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ToggleExampleBooleanUC\r\n * This private class handles the actual implementation details\r\n */\r\nclass ToggleExampleBooleanUCImp extends ToggleExampleBooleanUC {\r\n /**\r\n * Gets the SingletonEntityExample from the application\r\n * Uses getCachedSingleton for efficient repeated access\r\n */\r\n private get singletonEntityExample() {\r\n return this.getCachedSingleton<SingletonEntityExample>(\r\n SingletonEntityExample.type\r\n );\r\n }\r\n\r\n /**\r\n * Implements the toggleExampleBoolean method to invert the entity's boolean property\r\n */\r\n toggleExampleBoolean = () => {\r\n if (!this.singletonEntityExample) {\r\n this.warn(\"Unable to find SingletonEntityExample\");\r\n return;\r\n }\r\n\r\n // Toggle the boolean property by inverting its current value\r\n this.singletonEntityExample.aBoolProperty =\r\n !this.singletonEntityExample?.aBoolProperty;\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ToggleExampleBooleanUC.type);\r\n // Register this UC as a singleton so it can be accessed globally\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ToggleExampleBooleanUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/ToggleExampleBooleanUC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAGL,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAgB,sBAAuB,SAAQ,oBAAoB;;AACvE,gDAAgD;AAChC,2BAAI,GAAG,4BAA4B,CAAC;AAOpD;;;;GAIG;AACI,0BAAG,GAAG,CACX,UAAyB,EACW,EAAE,CACtC,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAGnE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAoB;IAEpB,OAAO,IAAI,yBAAyB,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,yBAA0B,SAAQ,sBAAsB;IAC5D;;;OAGG;IACH,IAAY,sBAAsB;QAChC,OAAO,IAAI,CAAC,kBAAkB,CAC5B,sBAAsB,CAAC,IAAI,CAC5B,CAAC;IACJ,CAAC;IAWD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAVhD;;WAEG;QACH,yBAAoB,GAAG,GAAG,EAAE;YAC1B,6DAA6D;YAC7D,IAAI,CAAC,sBAAsB,CAAC,aAAa;gBACvC,CAAC,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;QAC/C,CAAC,CAAC;IAIF,CAAC;CACF","sourcesContent":["/**\r\n * ToggleExampleBooleanUC.ts\r\n *\r\n * This file demonstrates how to implement a Singleton Use Case (UC) component.\r\n * Singleton UCs are special UCs that exist only once in the application and can be\r\n * accessed globally. They handle business logic and operations that modify singleton entities.\r\n *\r\n * Key concepts:\r\n * - Singleton UCs extend AppObjectUC like regular UCs\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - They typically operate on singleton entities\r\n *\r\n * Usage pattern:\r\n * 1. Access the singleton UC using the static get() method\r\n * 2. Call the UC's methods to perform operations\r\n * 3. The UC will update entities, which will trigger PM updates and UI refreshes\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectSingletonUC,\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { SingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\n\r\n/**\r\n * ToggleExampleBooleanUC provides functionality to toggle the boolean property\r\n * of the SingletonEntityExample. As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class ToggleExampleBooleanUC extends AppObjectSingletonUC {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ToggleExampleBooleanUCType\";\r\n\r\n /**\r\n * Toggles the boolean property of the SingletonEntityExample\r\n */\r\n abstract toggleExampleBoolean(): void;\r\n\r\n /**\r\n * Global accessor for the singleton UC\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton UC or undefined if not created yet\r\n */\r\n static get = (\r\n appObjects: AppObjectRepo\r\n ): ToggleExampleBooleanUC | undefined =>\r\n getSingletonComponent(ToggleExampleBooleanUC.type, appObjects);\r\n}\r\n\r\n/**\r\n * Factory function to create a new ToggleExampleBooleanUC\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new ToggleExampleBooleanUC instance\r\n */\r\nexport function makeToggleExampleBooleanUC(\r\n appObject: AppObject\r\n): ToggleExampleBooleanUC {\r\n return new ToggleExampleBooleanUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ToggleExampleBooleanUC\r\n * This private class handles the actual implementation details\r\n */\r\nclass ToggleExampleBooleanUCImp extends ToggleExampleBooleanUC {\r\n /**\r\n * Gets the SingletonEntityExample from the application\r\n * Uses getCachedSingleton for efficient repeated access\r\n */\r\n private get singletonEntityExample() {\r\n return this.getCachedSingleton<SingletonEntityExample>(\r\n SingletonEntityExample.type\r\n );\r\n }\r\n\r\n /**\r\n * Implements the toggleExampleBoolean method to invert the entity's boolean property\r\n */\r\n toggleExampleBoolean = () => {\r\n // Toggle the boolean property by inverting its current value\r\n this.singletonEntityExample.aBoolProperty =\r\n !this.singletonEntityExample.aBoolProperty;\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ToggleExampleBooleanUC.type);\r\n }\r\n}\r\n"]}
package/dist/esm/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from "./AppObject";
2
2
  export * from "./DomainFactories";
3
3
  export * from "./Entities";
4
- export * from "./ExampleFeature";
5
4
  export * from "./Types";
6
5
  export * from "./Utilities";
7
6
  export * from "./ValueObjects";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./DomainFactories\"\r\nexport * from \"./Entities\";\r\nexport * from \"./ExampleFeature\"\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,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./DomainFactories\"\r\nexport * from \"./Entities\";\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
@@ -49,17 +49,19 @@ export declare class AppObjectComponent {
49
49
  * Results are cached for better performance in repeated calls
50
50
  *
51
51
  * @param type The component type identifier to look up
52
- * @returns The singleton component cast to type T, or undefined if not found
52
+ * @returns The singleton component cast to type T
53
+ * @throws Error if the component is not found
53
54
  */
54
- getCachedSingleton<T extends AppObjectComponent>(type: string): T | undefined;
55
+ getCachedSingleton<T extends AppObjectComponent>(type: string): T;
55
56
  /**
56
57
  * Retrieves a component from the same AppObject as this component
57
58
  * Results are cached for better performance in repeated calls
58
59
  *
59
60
  * @param type The component type identifier to look up
60
- * @returns The component cast to type T, or undefined if not found
61
+ * @returns The component cast to type T
62
+ * @throws Error if the component is not found
61
63
  */
62
- getCachedLocalComponent<T extends AppObjectComponent>(type: string): T | undefined;
64
+ getCachedLocalComponent<T extends AppObjectComponent>(type: string): T;
63
65
  /**
64
66
  * Retrieves a singleton component from the repository with customizable logging
65
67
  * Unlike getCachedSingleton, results are not cached
@@ -1 +1 @@
1
- {"version":3,"file":"AppObjectComponent.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,oBAAY,sBAAsB;IAChC,2CAA2C;IAC3C,MAAM,WAAW;IAEjB,oDAAoD;IACpD,EAAE,yBAAyB;IAE3B,+DAA+D;IAC/D,EAAE,aAAa;IAEf,8CAA8C;IAC9C,UAAU,eAAe;IAEzB,sEAAsE;IACtE,IAAI,SAAS;IAEb,yEAAyE;IACzE,OAAO,YAAY;CACpB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAkB;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAkC;IAEhF,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B;;;OAGG;IACH,IAAI,UAAU,IAAI,aAAa,CAE9B;IAED,qDAAqD;IACrD,OAAO,CAAC,gBAAgB,CAAyC;IAEjE;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,SAAS,kBAAkB,EAC7C,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,SAAS;IAahB;;;;;;OAMG;IACH,uBAAuB,CAAC,CAAC,SAAS,kBAAkB,EAClD,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,SAAS;IAchB;;;;;;;OAOG;IACH,YAAY,CAAC,CAAC,SAAS,kBAAkB,EACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,KAAK,GAAG,MAAM,GAAG,OAAgB,GACzC,CAAC,GAAG,SAAS;IAqBhB;;;OAGG;IACH,OAAO;IAMP;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM;IAInB;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM;IAIpB;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM;IAIrB;;;;;OAKG;gBACS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM;CAK/C"}
1
+ {"version":3,"file":"AppObjectComponent.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,oBAAY,sBAAsB;IAChC,2CAA2C;IAC3C,MAAM,WAAW;IAEjB,oDAAoD;IACpD,EAAE,yBAAyB;IAE3B,+DAA+D;IAC/D,EAAE,aAAa;IAEf,8CAA8C;IAC9C,UAAU,eAAe;IAEzB,sEAAsE;IACtE,IAAI,SAAS;IAEb,yEAAyE;IACzE,OAAO,YAAY;CACpB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAkB;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CACb;IAEjC,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B;;;OAGG;IACH,IAAI,UAAU,IAAI,aAAa,CAE9B;IAED,qDAAqD;IACrD,OAAO,CAAC,gBAAgB,CAAyC;IAEjE;;;;;;;OAOG;IACH,kBAAkB,CAAC,CAAC,SAAS,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAYjE;;;;;;;OAOG;IACH,uBAAuB,CAAC,CAAC,SAAS,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAatE;;;;;;;OAOG;IACH,YAAY,CAAC,CAAC,SAAS,kBAAkB,EACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,KAAK,GAAG,MAAM,GAAG,OAAgB,GACzC,CAAC,GAAG,SAAS;IAqBhB;;;OAGG;IACH,OAAO;IAMP;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM;IAInB;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM;IAIpB;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM;IAIrB;;;;;OAKG;gBACS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM;CAK/C"}