@vived/core 1.4.3 → 1.4.5

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 (152) hide show
  1. package/README.md +25 -1
  2. package/dist/cjs/ExampleFeature/Adapters/examplePmAdapter.js +64 -0
  3. package/dist/cjs/ExampleFeature/Adapters/examplePmAdapter.js.map +1 -0
  4. package/dist/cjs/ExampleFeature/Adapters/exampleSingletonPmAdapter.js +60 -0
  5. package/dist/cjs/ExampleFeature/Adapters/exampleSingletonPmAdapter.js.map +1 -0
  6. package/dist/cjs/ExampleFeature/Adapters/index.js +19 -0
  7. package/dist/cjs/ExampleFeature/Adapters/index.js.map +1 -0
  8. package/dist/cjs/ExampleFeature/Controllers/index.js +19 -0
  9. package/dist/cjs/ExampleFeature/Controllers/index.js.map +1 -0
  10. package/dist/cjs/ExampleFeature/Controllers/setExampleText.js +48 -0
  11. package/dist/cjs/ExampleFeature/Controllers/setExampleText.js.map +1 -0
  12. package/dist/cjs/ExampleFeature/Controllers/toggleExampleBoolean.js +47 -0
  13. package/dist/cjs/ExampleFeature/Controllers/toggleExampleBoolean.js.map +1 -0
  14. package/dist/cjs/ExampleFeature/Entities/ExampleEntity.js +90 -0
  15. package/dist/cjs/ExampleFeature/Entities/ExampleEntity.js.map +1 -0
  16. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js +113 -0
  17. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js.map +1 -0
  18. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js +69 -0
  19. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -0
  20. package/dist/cjs/ExampleFeature/Entities/index.js +20 -0
  21. package/dist/cjs/ExampleFeature/Entities/index.js.map +1 -0
  22. package/dist/cjs/ExampleFeature/Factory/index.js +18 -0
  23. package/dist/cjs/ExampleFeature/Factory/index.js.map +1 -0
  24. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js +29 -0
  25. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js.map +1 -0
  26. package/dist/cjs/ExampleFeature/Mocks/MockEditExampleStringUC.js +47 -0
  27. package/dist/cjs/ExampleFeature/Mocks/MockEditExampleStringUC.js.map +1 -0
  28. package/dist/cjs/ExampleFeature/Mocks/MockExamplePM.js +48 -0
  29. package/dist/cjs/ExampleFeature/Mocks/MockExamplePM.js.map +1 -0
  30. package/dist/cjs/ExampleFeature/Mocks/MockExampleSingletonPM.js +59 -0
  31. package/dist/cjs/ExampleFeature/Mocks/MockExampleSingletonPM.js.map +1 -0
  32. package/dist/cjs/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js +57 -0
  33. package/dist/cjs/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js.map +1 -0
  34. package/dist/cjs/ExampleFeature/Mocks/index.js +21 -0
  35. package/dist/cjs/ExampleFeature/Mocks/index.js.map +1 -0
  36. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js +97 -0
  37. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js.map +1 -0
  38. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js +102 -0
  39. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -0
  40. package/dist/cjs/ExampleFeature/PMs/index.js +19 -0
  41. package/dist/cjs/ExampleFeature/PMs/index.js.map +1 -0
  42. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js +87 -0
  43. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -0
  44. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js +79 -0
  45. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -0
  46. package/dist/cjs/ExampleFeature/UCs/index.js +19 -0
  47. package/dist/cjs/ExampleFeature/UCs/index.js.map +1 -0
  48. package/dist/cjs/ExampleFeature/index.js +24 -0
  49. package/dist/cjs/ExampleFeature/index.js.map +1 -0
  50. package/dist/cjs/index.js +1 -0
  51. package/dist/cjs/index.js.map +1 -1
  52. package/dist/esm/ExampleFeature/Adapters/examplePmAdapter.js +61 -0
  53. package/dist/esm/ExampleFeature/Adapters/examplePmAdapter.js.map +1 -0
  54. package/dist/esm/ExampleFeature/Adapters/exampleSingletonPmAdapter.js +57 -0
  55. package/dist/esm/ExampleFeature/Adapters/exampleSingletonPmAdapter.js.map +1 -0
  56. package/dist/esm/ExampleFeature/Adapters/index.js +3 -0
  57. package/dist/esm/ExampleFeature/Adapters/index.js.map +1 -0
  58. package/dist/esm/ExampleFeature/Controllers/index.js +3 -0
  59. package/dist/esm/ExampleFeature/Controllers/index.js.map +1 -0
  60. package/dist/esm/ExampleFeature/Controllers/setExampleText.js +45 -0
  61. package/dist/esm/ExampleFeature/Controllers/setExampleText.js.map +1 -0
  62. package/dist/esm/ExampleFeature/Controllers/toggleExampleBoolean.js +44 -0
  63. package/dist/esm/ExampleFeature/Controllers/toggleExampleBoolean.js.map +1 -0
  64. package/dist/esm/ExampleFeature/Entities/ExampleEntity.js +85 -0
  65. package/dist/esm/ExampleFeature/Entities/ExampleEntity.js.map +1 -0
  66. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js +108 -0
  67. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js.map +1 -0
  68. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js +64 -0
  69. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -0
  70. package/dist/esm/ExampleFeature/Entities/index.js +4 -0
  71. package/dist/esm/ExampleFeature/Entities/index.js.map +1 -0
  72. package/dist/esm/ExampleFeature/Factory/index.js +2 -0
  73. package/dist/esm/ExampleFeature/Factory/index.js.map +1 -0
  74. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js +26 -0
  75. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js.map +1 -0
  76. package/dist/esm/ExampleFeature/Mocks/MockEditExampleStringUC.js +43 -0
  77. package/dist/esm/ExampleFeature/Mocks/MockEditExampleStringUC.js.map +1 -0
  78. package/dist/esm/ExampleFeature/Mocks/MockExamplePM.js +44 -0
  79. package/dist/esm/ExampleFeature/Mocks/MockExamplePM.js.map +1 -0
  80. package/dist/esm/ExampleFeature/Mocks/MockExampleSingletonPM.js +54 -0
  81. package/dist/esm/ExampleFeature/Mocks/MockExampleSingletonPM.js.map +1 -0
  82. package/dist/esm/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js +52 -0
  83. package/dist/esm/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js.map +1 -0
  84. package/dist/esm/ExampleFeature/Mocks/index.js +5 -0
  85. package/dist/esm/ExampleFeature/Mocks/index.js.map +1 -0
  86. package/dist/esm/ExampleFeature/PMs/ExamplePM.js +92 -0
  87. package/dist/esm/ExampleFeature/PMs/ExamplePM.js.map +1 -0
  88. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js +97 -0
  89. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -0
  90. package/dist/esm/ExampleFeature/PMs/index.js +3 -0
  91. package/dist/esm/ExampleFeature/PMs/index.js.map +1 -0
  92. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js +82 -0
  93. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -0
  94. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js +74 -0
  95. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -0
  96. package/dist/esm/ExampleFeature/UCs/index.js +3 -0
  97. package/dist/esm/ExampleFeature/UCs/index.js.map +1 -0
  98. package/dist/esm/ExampleFeature/index.js +8 -0
  99. package/dist/esm/ExampleFeature/index.js.map +1 -0
  100. package/dist/esm/index.js +1 -0
  101. package/dist/esm/index.js.map +1 -1
  102. package/dist/types/ExampleFeature/Adapters/examplePmAdapter.d.ts +29 -0
  103. package/dist/types/ExampleFeature/Adapters/examplePmAdapter.d.ts.map +1 -0
  104. package/dist/types/ExampleFeature/Adapters/exampleSingletonPmAdapter.d.ts +31 -0
  105. package/dist/types/ExampleFeature/Adapters/exampleSingletonPmAdapter.d.ts.map +1 -0
  106. package/dist/types/ExampleFeature/Adapters/index.d.ts +3 -0
  107. package/dist/types/ExampleFeature/Adapters/index.d.ts.map +1 -0
  108. package/dist/types/ExampleFeature/Controllers/index.d.ts +3 -0
  109. package/dist/types/ExampleFeature/Controllers/index.d.ts.map +1 -0
  110. package/dist/types/ExampleFeature/Controllers/setExampleText.d.ts +35 -0
  111. package/dist/types/ExampleFeature/Controllers/setExampleText.d.ts.map +1 -0
  112. package/dist/types/ExampleFeature/Controllers/toggleExampleBoolean.d.ts +34 -0
  113. package/dist/types/ExampleFeature/Controllers/toggleExampleBoolean.d.ts.map +1 -0
  114. package/dist/types/ExampleFeature/Entities/ExampleEntity.d.ts +55 -0
  115. package/dist/types/ExampleFeature/Entities/ExampleEntity.d.ts.map +1 -0
  116. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts +62 -0
  117. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts.map +1 -0
  118. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts +43 -0
  119. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts.map +1 -0
  120. package/dist/types/ExampleFeature/Entities/index.d.ts +4 -0
  121. package/dist/types/ExampleFeature/Entities/index.d.ts.map +1 -0
  122. package/dist/types/ExampleFeature/Factory/index.d.ts +2 -0
  123. package/dist/types/ExampleFeature/Factory/index.d.ts.map +1 -0
  124. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts +17 -0
  125. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts.map +1 -0
  126. package/dist/types/ExampleFeature/Mocks/MockEditExampleStringUC.d.ts +42 -0
  127. package/dist/types/ExampleFeature/Mocks/MockEditExampleStringUC.d.ts.map +1 -0
  128. package/dist/types/ExampleFeature/Mocks/MockExamplePM.d.ts +41 -0
  129. package/dist/types/ExampleFeature/Mocks/MockExamplePM.d.ts.map +1 -0
  130. package/dist/types/ExampleFeature/Mocks/MockExampleSingletonPM.d.ts +49 -0
  131. package/dist/types/ExampleFeature/Mocks/MockExampleSingletonPM.d.ts.map +1 -0
  132. package/dist/types/ExampleFeature/Mocks/MockToggleExampleBooleanUC.d.ts +47 -0
  133. package/dist/types/ExampleFeature/Mocks/MockToggleExampleBooleanUC.d.ts.map +1 -0
  134. package/dist/types/ExampleFeature/Mocks/index.d.ts +5 -0
  135. package/dist/types/ExampleFeature/Mocks/index.d.ts.map +1 -0
  136. package/dist/types/ExampleFeature/PMs/ExamplePM.d.ts +42 -0
  137. package/dist/types/ExampleFeature/PMs/ExamplePM.d.ts.map +1 -0
  138. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts +52 -0
  139. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts.map +1 -0
  140. package/dist/types/ExampleFeature/PMs/index.d.ts +3 -0
  141. package/dist/types/ExampleFeature/PMs/index.d.ts.map +1 -0
  142. package/dist/types/ExampleFeature/UCs/EditExampleStringUC.d.ts +52 -0
  143. package/dist/types/ExampleFeature/UCs/EditExampleStringUC.d.ts.map +1 -0
  144. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts +44 -0
  145. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts.map +1 -0
  146. package/dist/types/ExampleFeature/UCs/index.d.ts +3 -0
  147. package/dist/types/ExampleFeature/UCs/index.d.ts.map +1 -0
  148. package/dist/types/ExampleFeature/index.d.ts +8 -0
  149. package/dist/types/ExampleFeature/index.d.ts.map +1 -0
  150. package/dist/types/index.d.ts +1 -0
  151. package/dist/types/index.d.ts.map +1 -1
  152. package/package.json +6 -4
@@ -0,0 +1,97 @@
1
+ /**
2
+ * ExampleSingletonPM.ts
3
+ *
4
+ * This file demonstrates how to implement a Singleton Presentation Manager (PM).
5
+ * Singleton PMs are special PMs that exist only once in the application and can be
6
+ * accessed globally. They transform data from singleton entities into view models.
7
+ *
8
+ * Key concepts:
9
+ * - Singleton PMs extend AppObjectPM<VM> like regular PMs
10
+ * - They register themselves as singletons with appObjects.registerSingleton()
11
+ * - They're accessed through a static get() method using getSingletonComponent()
12
+ * - They typically observe singleton entities and provide data to multiple UI components
13
+ *
14
+ * Usage pattern:
15
+ * 1. Access the singleton PM using the static get() method
16
+ * 2. Register UI components as views using addView(callback)
17
+ * 3. PM will call the view callbacks with updated view models when entities change
18
+ * 4. Remove UI components with removeView(callback) when they're unmounted
19
+ */
20
+ import { AppObjectPM, } from "../../AppObject";
21
+ import { getSingletonComponent } from "../../AppObject/getSingletonComponent";
22
+ import { SingletonEntityExample } from "../Entities/ExampleSingletonEntity";
23
+ /**
24
+ * ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.
25
+ * As a singleton, only one instance exists in the application.
26
+ */
27
+ export class ExampleSingletonPM extends AppObjectPM {
28
+ }
29
+ /** Unique type identifier for this component */
30
+ ExampleSingletonPM.type = "ExampleSingletonPMType";
31
+ /**
32
+ * Global accessor for the singleton PM
33
+ * @param appObjects The AppObjectRepo to search in
34
+ * @returns The singleton PM or undefined if not created yet
35
+ */
36
+ ExampleSingletonPM.get = (appObjects) => getSingletonComponent(ExampleSingletonPM.type, appObjects);
37
+ /**
38
+ * Default view model used when no data is available
39
+ * UI components can use this initially or when the PM is not found
40
+ */
41
+ export const defaultSlideNavigationVM = {
42
+ aBoolProperty: true
43
+ };
44
+ /**
45
+ * Factory function to create a new ExampleSingletonPM
46
+ * @param appObject The AppObject to attach the PM to
47
+ * @returns A new ExampleSingletonPM instance
48
+ */
49
+ export function makeExampleSingletonPM(appObject) {
50
+ return new ExampleSingletonPMImp(appObject);
51
+ }
52
+ /**
53
+ * Concrete implementation of ExampleSingletonPM
54
+ * This private class handles the actual implementation details
55
+ */
56
+ class ExampleSingletonPMImp extends ExampleSingletonPM {
57
+ /**
58
+ * Gets the SingletonEntityExample from the application
59
+ * Uses getCachedSingleton for efficient repeated access
60
+ */
61
+ get exampleEntity() {
62
+ return this.getCachedSingleton(SingletonEntityExample.type);
63
+ }
64
+ /**
65
+ * Compares two view models to determine if they're equal
66
+ * Used to avoid unnecessary view updates when values haven't changed
67
+ */
68
+ vmsAreEqual(a, b) {
69
+ if (a.aBoolProperty !== b.aBoolProperty)
70
+ return false;
71
+ return true;
72
+ }
73
+ constructor(appObject) {
74
+ super(appObject, ExampleSingletonPM.type);
75
+ /**
76
+ * Handler for entity change events
77
+ * Transforms entity data into a view model and updates views
78
+ */
79
+ this.onEntityChange = () => {
80
+ if (!this.exampleEntity)
81
+ return;
82
+ // Extract the boolean property from the entity
83
+ const aBoolProperty = this.exampleEntity.aBoolProperty;
84
+ // Create a view model with the extracted data
85
+ const vm = { aBoolProperty };
86
+ // Update all registered views with the new view model
87
+ this.doUpdateView(vm);
88
+ };
89
+ // Register as an observer of the entity to receive change notifications
90
+ this.exampleEntity?.addChangeObserver(this.onEntityChange);
91
+ // 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);
95
+ }
96
+ }
97
+ //# sourceMappingURL=ExampleSingletonPM.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,3 @@
1
+ export * from "./ExamplePM";
2
+ export * from "./ExampleSingletonPM";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./ExamplePM\";\r\nexport * from \"./ExampleSingletonPM\";\r\n"]}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * EditExampleStringUC.ts
3
+ *
4
+ * This file demonstrates how to implement a Use Case (UC) component.
5
+ * UCs handle business logic and operations that modify entities.
6
+ * They encapsulate specific actions that can be performed in the application.
7
+ *
8
+ * Key concepts:
9
+ * - UCs extend AppObjectUC and provide methods for specific operations
10
+ * - They implement business logic for modifying entities
11
+ * - They validate inputs and handle errors
12
+ * - Each UC instance is associated with a specific AppObject
13
+ *
14
+ * Usage pattern:
15
+ * 1. Get a UC instance using getById or get
16
+ * 2. Call the UC's methods to perform operations
17
+ * 3. The UC will update entities, which will trigger PM updates and UI refreshes
18
+ */
19
+ import { AppObjectUC } from "../../AppObject";
20
+ import { ExampleEntity } from "../Entities/ExampleEntity";
21
+ /**
22
+ * EditExampleStringUC provides functionality to update the string property of an ExampleEntity.
23
+ * Abstract class provides the interface and static helper methods.
24
+ */
25
+ export class EditExampleStringUC extends AppObjectUC {
26
+ /**
27
+ * Retrieves an EditExampleStringUC component from an AppObject
28
+ * @param appObj The AppObject to get the component from
29
+ * @returns The EditExampleStringUC component or undefined if not found
30
+ */
31
+ static get(appObj) {
32
+ return appObj.getComponent(this.type);
33
+ }
34
+ /**
35
+ * Retrieves an EditExampleStringUC by its parent AppObject's ID
36
+ * @param id The ID of the parent AppObject
37
+ * @param appObjects The AppObjectRepo to search in
38
+ * @returns The EditExampleStringUC component or undefined if not found
39
+ */
40
+ static getById(id, appObjects) {
41
+ return appObjects.get(id)?.getComponent(this.type);
42
+ }
43
+ }
44
+ /** Unique type identifier for this component */
45
+ EditExampleStringUC.type = "EditExampleStringUCType";
46
+ /**
47
+ * Factory function to create a new EditExampleStringUC
48
+ * @param appObject The AppObject to attach the UC to
49
+ * @returns A new EditExampleStringUC instance
50
+ */
51
+ export function makeEditSlideTextUC(appObject) {
52
+ return new EditSlideTextUCImp(appObject);
53
+ }
54
+ /**
55
+ * Concrete implementation of EditExampleStringUC
56
+ * This private class handles the actual implementation details
57
+ */
58
+ class EditSlideTextUCImp extends EditExampleStringUC {
59
+ /**
60
+ * Gets the ExampleEntity from the same AppObject
61
+ * Uses getCachedLocalComponent for efficient repeated access
62
+ */
63
+ get exampleEntity() {
64
+ return this.getCachedLocalComponent(ExampleEntity.type);
65
+ }
66
+ constructor(appObject) {
67
+ super(appObject, EditExampleStringUC.type);
68
+ /**
69
+ * Implements the editExampleString method to update the entity's string property
70
+ * @param text The new string value to set
71
+ */
72
+ this.editExampleString = (text) => {
73
+ if (!this.exampleEntity) {
74
+ this.warn("Unable to find AppState");
75
+ return;
76
+ }
77
+ // Update the entity property, which will trigger PM updates and UI refreshes
78
+ this.exampleEntity.aStringProperty = text;
79
+ };
80
+ }
81
+ }
82
+ //# sourceMappingURL=EditExampleStringUC.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * ToggleExampleBooleanUC.ts
3
+ *
4
+ * This file demonstrates how to implement a Singleton Use Case (UC) component.
5
+ * Singleton UCs are special UCs that exist only once in the application and can be
6
+ * accessed globally. They handle business logic and operations that modify singleton entities.
7
+ *
8
+ * Key concepts:
9
+ * - Singleton UCs extend AppObjectUC like regular UCs
10
+ * - They register themselves as singletons with appObjects.registerSingleton()
11
+ * - They're accessed through a static get() method using getSingletonComponent()
12
+ * - They typically operate on singleton entities
13
+ *
14
+ * Usage pattern:
15
+ * 1. Access the singleton UC using the static get() method
16
+ * 2. Call the UC's methods to perform operations
17
+ * 3. The UC will update entities, which will trigger PM updates and UI refreshes
18
+ */
19
+ import { AppObjectUC } from "../../AppObject";
20
+ import { getSingletonComponent } from "../../AppObject/getSingletonComponent";
21
+ import { SingletonEntityExample } from "../Entities/ExampleSingletonEntity";
22
+ /**
23
+ * ToggleExampleBooleanUC provides functionality to toggle the boolean property
24
+ * of the SingletonEntityExample. As a singleton, only one instance exists in the application.
25
+ */
26
+ export class ToggleExampleBooleanUC extends AppObjectUC {
27
+ }
28
+ /** Unique type identifier for this component */
29
+ ToggleExampleBooleanUC.type = "ToggleExampleBooleanUCType";
30
+ /**
31
+ * Global accessor for the singleton UC
32
+ * @param appObjects The AppObjectRepo to search in
33
+ * @returns The singleton UC or undefined if not created yet
34
+ */
35
+ ToggleExampleBooleanUC.get = (appObjects) => getSingletonComponent(ToggleExampleBooleanUC.type, appObjects);
36
+ /**
37
+ * Factory function to create a new ToggleExampleBooleanUC
38
+ * @param appObject The AppObject to attach the UC to
39
+ * @returns A new ToggleExampleBooleanUC instance
40
+ */
41
+ export function makeToggleExampleBooleanUC(appObject) {
42
+ return new ToggleExampleBooleanUCImp(appObject);
43
+ }
44
+ /**
45
+ * Concrete implementation of ToggleExampleBooleanUC
46
+ * This private class handles the actual implementation details
47
+ */
48
+ class ToggleExampleBooleanUCImp extends ToggleExampleBooleanUC {
49
+ /**
50
+ * Gets the SingletonEntityExample from the application
51
+ * Uses getCachedSingleton for efficient repeated access
52
+ */
53
+ get singletonEntityExample() {
54
+ return this.getCachedSingleton(SingletonEntityExample.type);
55
+ }
56
+ constructor(appObject) {
57
+ super(appObject, ToggleExampleBooleanUC.type);
58
+ /**
59
+ * Implements the toggleExampleBoolean method to invert the entity's boolean property
60
+ */
61
+ this.toggleExampleBoolean = () => {
62
+ if (!this.singletonEntityExample) {
63
+ this.warn("Unable to find SingletonEntityExample");
64
+ return;
65
+ }
66
+ // Toggle the boolean property by inverting its current value
67
+ this.singletonEntityExample.aBoolProperty =
68
+ !this.singletonEntityExample?.aBoolProperty;
69
+ };
70
+ // Register this UC as a singleton so it can be accessed globally
71
+ this.appObjects.registerSingleton(this);
72
+ }
73
+ }
74
+ //# sourceMappingURL=ToggleExampleBooleanUC.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,3 @@
1
+ export * from "./EditExampleStringUC";
2
+ export * from "./ToggleExampleBooleanUC";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./EditExampleStringUC\";\r\nexport * from \"./ToggleExampleBooleanUC\";\r\n"]}
@@ -0,0 +1,8 @@
1
+ export * from "./Adapters";
2
+ export * from "./Controllers";
3
+ export * from "./Entities";
4
+ export * from "./Factory";
5
+ export * from "./Mocks";
6
+ export * from "./PMs";
7
+ export * from "./UCs";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ExampleFeature/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC","sourcesContent":["export * from \"./Adapters\";\r\nexport * from \"./Controllers\";\r\nexport * from \"./Entities\";\r\nexport * from \"./Factory\";\r\nexport * from \"./Mocks\";\r\nexport * from \"./PMs\";\r\nexport * from \"./UCs\";"]}
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./AppObject";
2
2
  export * from "./Entities";
3
+ export * from "./ExampleFeature";
3
4
  export * from "./Types";
4
5
  export * from "./Utilities";
5
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,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./Entities\";\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,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 \"./Entities\";\r\nexport * from \"./ExampleFeature\"\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * examplePmAdapter.ts
3
+ *
4
+ * This file demonstrates how to implement a PM Adapter to connect UI components to PMs.
5
+ * PM Adapters provide a standardized way for UI frameworks to subscribe to PM updates.
6
+ * This adapter connects to regular (non-singleton) PMs that require an AppObject ID.
7
+ *
8
+ * Key concepts:
9
+ * - PM Adapters implement the PmAdapter<VM> interface where VM is the view model type
10
+ * - They handle subscribing UI components to PMs and unsubscribing when done
11
+ * - They provide a default view model for initial rendering before data is available
12
+ * - They abstract away the details of finding and connecting to specific PMs
13
+ *
14
+ * Usage pattern (React example):
15
+ * ```typescript
16
+ * // In a React component
17
+ * function MyComponent({ id }) {
18
+ * const viewModel = usePmAdapter(examplePmAdapter, id);
19
+ * return <div>{viewModel}</div>;
20
+ * }
21
+ * ```
22
+ */
23
+ import { PmAdapter } from "../../Types/PmAdapter";
24
+ /**
25
+ * An adapter that connects UI components to ExamplePM instances.
26
+ * Implements PmAdapter<string> because ExamplePM provides string view models.
27
+ */
28
+ export declare const examplePmAdapter: PmAdapter<string>;
29
+ //# sourceMappingURL=examplePmAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examplePmAdapter.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Adapters/examplePmAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,CAAC,MAAM,CA2C9C,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * exampleSingletonPmAdapter.ts
3
+ *
4
+ * This file demonstrates how to implement a Singleton PM Adapter to connect UI components
5
+ * to singleton PMs. Singleton PM Adapters provide a standardized way for UI frameworks
6
+ * to subscribe to singleton PM updates without needing to specify an AppObject ID.
7
+ *
8
+ * Key concepts:
9
+ * - Singleton PM Adapters implement the SingletonPmAdapter<VM> interface
10
+ * - They handle subscribing UI components to singleton PMs and unsubscribing when done
11
+ * - They provide a default view model for initial rendering before data is available
12
+ * - They don't require an AppObject ID since they connect to globally accessible singletons
13
+ *
14
+ * Usage pattern (React example):
15
+ * ```typescript
16
+ * // In a React component
17
+ * function MyComponent() {
18
+ * // Note: no ID needed since it's connecting to a singleton
19
+ * const viewModel = useSingletonPmAdapter(exampleSingletonPmAdapter);
20
+ * return <div>{viewModel.aBoolProperty ? "True" : "False"}</div>;
21
+ * }
22
+ * ```
23
+ */
24
+ import { SingletonPmAdapter } from "../../Types/SingletonPmAdapter";
25
+ import { ExampleVM } from "../PMs/ExampleSingletonPM";
26
+ /**
27
+ * An adapter that connects UI components to the ExampleSingletonPM.
28
+ * Implements SingletonPmAdapter<ExampleVM> because ExampleSingletonPM provides ExampleVM view models.
29
+ */
30
+ export declare const exampleSingletonPmAdapter: SingletonPmAdapter<ExampleVM>;
31
+ //# sourceMappingURL=exampleSingletonPmAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exampleSingletonPmAdapter.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Adapters/exampleSingletonPmAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAGL,SAAS,EACV,MAAM,2BAA2B,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CAAC,SAAS,CAiCnE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./examplePmAdapter";
2
+ export * from "./exampleSingletonPmAdapter";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./setExampleText";
2
+ export * from "./toggleExampleBoolean";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Controllers/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * setExampleText.ts
3
+ *
4
+ * This file demonstrates how to implement a Controller function.
5
+ * Controllers are simple functions that provide a simplified API for UI components
6
+ * to interact with Use Cases (UCs). They handle the details of finding the right
7
+ * UC and calling its methods with the appropriate parameters.
8
+ *
9
+ * Key concepts:
10
+ * - Controllers are functions that take parameters from UI components
11
+ * - They find the appropriate UC and call its methods
12
+ * - They handle error cases and provide appropriate feedback
13
+ * - They simplify the API for UI components
14
+ *
15
+ * Usage pattern (React example):
16
+ * ```typescript
17
+ * // In a React component
18
+ * function ExampleTextInput({ id, appObjects }) {
19
+ * const handleChange = (e) => {
20
+ * setExampleText(e.target.value, id, appObjects);
21
+ * };
22
+ * return <input onChange={handleChange} />;
23
+ * }
24
+ * ```
25
+ */
26
+ import { AppObjectRepo } from "../../AppObject";
27
+ /**
28
+ * Controller function to update the text of an ExampleEntity
29
+ *
30
+ * @param text The new text to set
31
+ * @param id The ID of the AppObject containing the EditExampleStringUC
32
+ * @param appObjects The application's AppObjectRepo
33
+ */
34
+ export declare function setExampleText(text: string, id: string, appObjects: AppObjectRepo): void;
35
+ //# sourceMappingURL=setExampleText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setExampleText.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Controllers/setExampleText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,aAAa,QAgB1B"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * toggleExampleBoolean.ts
3
+ *
4
+ * This file demonstrates how to implement a Controller function for a singleton UC.
5
+ * This controller provides a simplified API for UI components to interact with
6
+ * the ToggleExampleBooleanUC singleton, handling the details of finding the UC
7
+ * and calling its method.
8
+ *
9
+ * Key concepts:
10
+ * - Controllers for singleton UCs don't need an ID parameter
11
+ * - They access the singleton UC using its static get() method
12
+ * - They handle error cases and provide appropriate feedback
13
+ * - They simplify the API for UI components
14
+ *
15
+ * Usage pattern (React example):
16
+ * ```typescript
17
+ * // In a React component
18
+ * function ToggleButton({ appObjects }) {
19
+ * return (
20
+ * <button onClick={() => toggleExampleBoolean(appObjects)}>
21
+ * Toggle
22
+ * </button>
23
+ * );
24
+ * }
25
+ * ```
26
+ */
27
+ import { AppObjectRepo } from "../../AppObject";
28
+ /**
29
+ * Controller function to toggle the boolean property of the SingletonEntityExample
30
+ *
31
+ * @param appObjects The application's AppObjectRepo
32
+ */
33
+ export declare function toggleExampleBoolean(appObjects: AppObjectRepo): void;
34
+ //# sourceMappingURL=toggleExampleBoolean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggleExampleBoolean.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Controllers/toggleExampleBoolean.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,aAAa,QAe7D"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * ExampleEntity.ts
3
+ *
4
+ * This file demonstrates how to implement a standard (non-singleton) entity in the application.
5
+ * Entities store and manage data, track state changes, and notify observers when changes occur.
6
+ *
7
+ * Key concepts:
8
+ * - Entity classes extend AppObjectEntity
9
+ * - They provide access to data properties
10
+ * - They use Memoized types (MemoizedString, MemoizedBoolean, etc.) to track changes
11
+ * - They notify observers when properties change
12
+ *
13
+ * Usage pattern:
14
+ * 1. Get or create an entity instance using getById, get, or addIfMissing
15
+ * 2. Access or modify properties via getters/setters
16
+ * 3. Register change observers to react to property updates
17
+ */
18
+ import { AppObject, AppObjectEntity, AppObjectRepo } from "../../AppObject";
19
+ /**
20
+ * ExampleEntity represents a basic entity with a string property.
21
+ * Abstract class provides the interface and static helper methods.
22
+ */
23
+ export declare abstract class ExampleEntity extends AppObjectEntity {
24
+ /** Unique type identifier for this component */
25
+ static readonly type = "ExampleEntityType";
26
+ /** String property accessor methods that must be implemented */
27
+ abstract get aStringProperty(): string;
28
+ abstract set aStringProperty(val: string);
29
+ /**
30
+ * Retrieves an ExampleEntity component from an AppObject
31
+ * @param appObj The AppObject to get the component from
32
+ * @returns The ExampleEntity component or undefined if not found
33
+ */
34
+ static get(appObj: AppObject): ExampleEntity | undefined;
35
+ /**
36
+ * Retrieves an ExampleEntity by its parent AppObject's ID
37
+ * @param id The ID of the parent AppObject
38
+ * @param appObjects The AppObjectRepo to search in
39
+ * @returns The ExampleEntity component or undefined if not found
40
+ */
41
+ static getById(id: string, appObjects: AppObjectRepo): ExampleEntity | undefined;
42
+ /**
43
+ * Ensures an ExampleEntity exists on the AppObject, creating one if needed
44
+ * @param appObj The AppObject to check/add the component to
45
+ * @returns The existing or newly created ExampleEntity
46
+ */
47
+ static addIfMissing(appObj: AppObject): ExampleEntity;
48
+ }
49
+ /**
50
+ * Factory function to create a new ExampleEntity
51
+ * @param appObject The AppObject to attach the entity to
52
+ * @returns A new ExampleEntity instance
53
+ */
54
+ export declare function makeExampleEntity(appObject: AppObject): ExampleEntity;
55
+ //# sourceMappingURL=ExampleEntity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleEntity.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,SAAS,EACT,eAAe,EACf,aAAa,EACd,MAAM,iBAAiB,CAAC;AAGzB;;;GAGG;AACH,8BAAsB,aAAc,SAAQ,eAAe;IACzD,gDAAgD;IAChD,MAAM,CAAC,QAAQ,CAAC,IAAI,uBAAuB;IAE3C,gEAAgE;IAChE,QAAQ,KAAK,eAAe,IAAI,MAAM,CAAC;IACvC,QAAQ,KAAK,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE;IAE1C;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS;IAIxD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,aAAa,GACxB,aAAa,GAAG,SAAS;IAI5B;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa;CAQtD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,GACnB,aAAa,CAEf"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * ExampleRepo.ts
3
+ *
4
+ * This file demonstrates how to implement a repository to manage collections of entities.
5
+ * Repositories are responsible for creating, retrieving, and deleting entities.
6
+ *
7
+ * Key concepts:
8
+ * - Repositories extend AppObjectEntityRepo<T> where T is the entity type
9
+ * - They provide methods to create and delete entities
10
+ * - They manage collections of entities and provide access to them
11
+ * - They can use custom entity factories to create specialized entities
12
+ *
13
+ * Usage pattern:
14
+ * 1. Get or create a repository using getById, get, or addIfMissing
15
+ * 2. Use the repository to create new entities
16
+ * 3. Access entities through the repository's getters
17
+ * 4. Delete entities through the repository when they're no longer needed
18
+ */
19
+ import { AppObject, AppObjectEntityRepo, AppObjectRepo } from "../../AppObject";
20
+ import { ExampleEntity } from "./ExampleEntity";
21
+ /** Type definition for a factory function that creates ExampleEntity instances */
22
+ export type ExampleEntityFactory = (id: string) => ExampleEntity;
23
+ /**
24
+ * ExampleRepo manages a collection of ExampleEntity instances.
25
+ * Abstract class provides the interface and static helper methods.
26
+ */
27
+ export declare abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {
28
+ /** Unique type identifier for this component */
29
+ static readonly type = "ExampleRepoType";
30
+ /** Factory function used to create new entities */
31
+ abstract exampleEntityFactory: ExampleEntityFactory;
32
+ /** Creates a new entity with an optional ID */
33
+ abstract createExampleEntity(id?: string): ExampleEntity;
34
+ /** Deletes an entity by its AppObject ID */
35
+ abstract deleteExampleEntity(id: string): void;
36
+ /**
37
+ * Retrieves an ExampleRepo component from an AppObject
38
+ * @param appObj The AppObject to get the component from
39
+ * @returns The ExampleRepo component or undefined if not found
40
+ */
41
+ static get(appObj: AppObject): ExampleRepo | undefined;
42
+ /**
43
+ * Retrieves an ExampleRepo by its parent AppObject's ID
44
+ * @param id The ID of the parent AppObject
45
+ * @param appObjects The AppObjectRepo to search in
46
+ * @returns The ExampleRepo component or undefined if not found
47
+ */
48
+ static getById(id: string, appObjects: AppObjectRepo): ExampleRepo | undefined;
49
+ /**
50
+ * Ensures an ExampleRepo exists on the AppObject, creating one if needed
51
+ * @param appObject The AppObject to check/add the component to
52
+ * @returns The existing or newly created ExampleRepo
53
+ */
54
+ static addIfMissing(appObject: AppObject): ExampleRepo;
55
+ }
56
+ /**
57
+ * Factory function to create a new ExampleRepo
58
+ * @param appObject The AppObject to attach the repo to
59
+ * @returns A new ExampleRepo instance
60
+ */
61
+ export declare function makeExampleRepo(appObject: AppObject): ExampleRepo;
62
+ //# sourceMappingURL=ExampleRepo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleRepo.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAqB,MAAM,iBAAiB,CAAC;AAEnE,kFAAkF;AAClF,MAAM,MAAM,oBAAoB,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,aAAa,CAAC;AAEjE;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,mBAAmB,CAAC,aAAa,CAAC;IAC1E,gDAAgD;IAChD,MAAM,CAAC,QAAQ,CAAC,IAAI,qBAAqB;IAEzC,mDAAmD;IACnD,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAEpD,+CAA+C;IAC/C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa;IAExD,4CAA4C;IAC5C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAE9C;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS;IAItD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,aAAa,GACxB,WAAW,GAAG,SAAS;IAI1B;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW;CAQvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAEjE"}