@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,87 @@
1
+ "use strict";
2
+ /**
3
+ * EditExampleStringUC.ts
4
+ *
5
+ * This file demonstrates how to implement a Use Case (UC) component.
6
+ * UCs handle business logic and operations that modify entities.
7
+ * They encapsulate specific actions that can be performed in the application.
8
+ *
9
+ * Key concepts:
10
+ * - UCs extend AppObjectUC and provide methods for specific operations
11
+ * - They implement business logic for modifying entities
12
+ * - They validate inputs and handle errors
13
+ * - Each UC instance is associated with a specific AppObject
14
+ *
15
+ * Usage pattern:
16
+ * 1. Get a UC instance using getById or get
17
+ * 2. Call the UC's methods to perform operations
18
+ * 3. The UC will update entities, which will trigger PM updates and UI refreshes
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.EditExampleStringUC = void 0;
22
+ exports.makeEditSlideTextUC = makeEditSlideTextUC;
23
+ const AppObject_1 = require("../../AppObject");
24
+ const ExampleEntity_1 = require("../Entities/ExampleEntity");
25
+ /**
26
+ * EditExampleStringUC provides functionality to update the string property of an ExampleEntity.
27
+ * Abstract class provides the interface and static helper methods.
28
+ */
29
+ class EditExampleStringUC extends AppObject_1.AppObjectUC {
30
+ /**
31
+ * Retrieves an EditExampleStringUC component from an AppObject
32
+ * @param appObj The AppObject to get the component from
33
+ * @returns The EditExampleStringUC component or undefined if not found
34
+ */
35
+ static get(appObj) {
36
+ return appObj.getComponent(this.type);
37
+ }
38
+ /**
39
+ * Retrieves an EditExampleStringUC by its parent AppObject's ID
40
+ * @param id The ID of the parent AppObject
41
+ * @param appObjects The AppObjectRepo to search in
42
+ * @returns The EditExampleStringUC component or undefined if not found
43
+ */
44
+ static getById(id, appObjects) {
45
+ return appObjects.get(id)?.getComponent(this.type);
46
+ }
47
+ }
48
+ exports.EditExampleStringUC = EditExampleStringUC;
49
+ /** Unique type identifier for this component */
50
+ EditExampleStringUC.type = "EditExampleStringUCType";
51
+ /**
52
+ * Factory function to create a new EditExampleStringUC
53
+ * @param appObject The AppObject to attach the UC to
54
+ * @returns A new EditExampleStringUC instance
55
+ */
56
+ function makeEditSlideTextUC(appObject) {
57
+ return new EditSlideTextUCImp(appObject);
58
+ }
59
+ /**
60
+ * Concrete implementation of EditExampleStringUC
61
+ * This private class handles the actual implementation details
62
+ */
63
+ class EditSlideTextUCImp extends EditExampleStringUC {
64
+ /**
65
+ * Gets the ExampleEntity from the same AppObject
66
+ * Uses getCachedLocalComponent for efficient repeated access
67
+ */
68
+ get exampleEntity() {
69
+ return this.getCachedLocalComponent(ExampleEntity_1.ExampleEntity.type);
70
+ }
71
+ constructor(appObject) {
72
+ super(appObject, EditExampleStringUC.type);
73
+ /**
74
+ * Implements the editExampleString method to update the entity's string property
75
+ * @param text The new string value to set
76
+ */
77
+ this.editExampleString = (text) => {
78
+ if (!this.exampleEntity) {
79
+ this.warn("Unable to find AppState");
80
+ return;
81
+ }
82
+ // Update the entity property, which will trigger PM updates and UI refreshes
83
+ this.exampleEntity.aStringProperty = text;
84
+ };
85
+ }
86
+ }
87
+ //# sourceMappingURL=EditExampleStringUC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditExampleStringUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/EditExampleStringUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AA+CH,kDAEC;AA/CD,+CAAwE;AACxE,6DAA0D;AAE1D;;;GAGG;AACH,MAAsB,mBAAoB,SAAQ,uBAAW;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;;AA9BH,kDA+BC;AA9BC,gDAAgD;AAChC,wBAAI,GAAG,yBAAyB,CAAC;AA+BnD;;;;GAIG;AACH,SAAgB,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,6BAAa,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,79 @@
1
+ "use strict";
2
+ /**
3
+ * ToggleExampleBooleanUC.ts
4
+ *
5
+ * This file demonstrates how to implement a Singleton Use Case (UC) component.
6
+ * Singleton UCs are special UCs that exist only once in the application and can be
7
+ * accessed globally. They handle business logic and operations that modify singleton entities.
8
+ *
9
+ * Key concepts:
10
+ * - Singleton UCs extend AppObjectUC like regular UCs
11
+ * - They register themselves as singletons with appObjects.registerSingleton()
12
+ * - They're accessed through a static get() method using getSingletonComponent()
13
+ * - They typically operate on singleton entities
14
+ *
15
+ * Usage pattern:
16
+ * 1. Access the singleton UC using the static get() method
17
+ * 2. Call the UC's methods to perform operations
18
+ * 3. The UC will update entities, which will trigger PM updates and UI refreshes
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ToggleExampleBooleanUC = void 0;
22
+ exports.makeToggleExampleBooleanUC = makeToggleExampleBooleanUC;
23
+ const AppObject_1 = require("../../AppObject");
24
+ const getSingletonComponent_1 = require("../../AppObject/getSingletonComponent");
25
+ const ExampleSingletonEntity_1 = require("../Entities/ExampleSingletonEntity");
26
+ /**
27
+ * ToggleExampleBooleanUC provides functionality to toggle the boolean property
28
+ * of the SingletonEntityExample. As a singleton, only one instance exists in the application.
29
+ */
30
+ class ToggleExampleBooleanUC extends AppObject_1.AppObjectUC {
31
+ }
32
+ exports.ToggleExampleBooleanUC = ToggleExampleBooleanUC;
33
+ /** Unique type identifier for this component */
34
+ ToggleExampleBooleanUC.type = "ToggleExampleBooleanUCType";
35
+ /**
36
+ * Global accessor for the singleton UC
37
+ * @param appObjects The AppObjectRepo to search in
38
+ * @returns The singleton UC or undefined if not created yet
39
+ */
40
+ ToggleExampleBooleanUC.get = (appObjects) => (0, getSingletonComponent_1.getSingletonComponent)(ToggleExampleBooleanUC.type, appObjects);
41
+ /**
42
+ * Factory function to create a new ToggleExampleBooleanUC
43
+ * @param appObject The AppObject to attach the UC to
44
+ * @returns A new ToggleExampleBooleanUC instance
45
+ */
46
+ function makeToggleExampleBooleanUC(appObject) {
47
+ return new ToggleExampleBooleanUCImp(appObject);
48
+ }
49
+ /**
50
+ * Concrete implementation of ToggleExampleBooleanUC
51
+ * This private class handles the actual implementation details
52
+ */
53
+ class ToggleExampleBooleanUCImp extends ToggleExampleBooleanUC {
54
+ /**
55
+ * Gets the SingletonEntityExample from the application
56
+ * Uses getCachedSingleton for efficient repeated access
57
+ */
58
+ get singletonEntityExample() {
59
+ return this.getCachedSingleton(ExampleSingletonEntity_1.SingletonEntityExample.type);
60
+ }
61
+ constructor(appObject) {
62
+ super(appObject, ToggleExampleBooleanUC.type);
63
+ /**
64
+ * Implements the toggleExampleBoolean method to invert the entity's boolean property
65
+ */
66
+ this.toggleExampleBoolean = () => {
67
+ if (!this.singletonEntityExample) {
68
+ this.warn("Unable to find SingletonEntityExample");
69
+ return;
70
+ }
71
+ // Toggle the boolean property by inverting its current value
72
+ this.singletonEntityExample.aBoolProperty =
73
+ !this.singletonEntityExample?.aBoolProperty;
74
+ };
75
+ // Register this UC as a singleton so it can be accessed globally
76
+ this.appObjects.registerSingleton(this);
77
+ }
78
+ }
79
+ //# sourceMappingURL=ToggleExampleBooleanUC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleExampleBooleanUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/ToggleExampleBooleanUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAuCH,gEAIC;AAzCD,+CAIyB;AACzB,iFAA8E;AAC9E,+EAA4E;AAE5E;;;GAGG;AACH,MAAsB,sBAAuB,SAAQ,uBAAW;;AAAhE,wDAkBC;AAjBC,gDAAgD;AAChC,2BAAI,GAAG,4BAA4B,CAAC;AAOpD;;;;GAIG;AACI,0BAAG,GAAG,CACX,UAAyB,EACW,EAAE,CACtC,IAAA,6CAAqB,EAAC,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAGnE;;;;GAIG;AACH,SAAgB,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,+CAAsB,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,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./EditExampleStringUC"), exports);
18
+ __exportStar(require("./ToggleExampleBooleanUC"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/UCs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,2DAAyC","sourcesContent":["export * from \"./EditExampleStringUC\";\r\nexport * from \"./ToggleExampleBooleanUC\";\r\n"]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Adapters"), exports);
18
+ __exportStar(require("./Controllers"), exports);
19
+ __exportStar(require("./Entities"), exports);
20
+ __exportStar(require("./Factory"), exports);
21
+ __exportStar(require("./Mocks"), exports);
22
+ __exportStar(require("./PMs"), exports);
23
+ __exportStar(require("./UCs"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ExampleFeature/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gDAA8B;AAC9B,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,wCAAsB;AACtB,wCAAsB","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/cjs/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./AppObject"), exports);
18
18
  __exportStar(require("./Entities"), exports);
19
+ __exportStar(require("./ExampleFeature"), exports);
19
20
  __exportStar(require("./Types"), exports);
20
21
  __exportStar(require("./Utilities"), exports);
21
22
  __exportStar(require("./ValueObjects"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,iDAA+B","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./Entities\";\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAgC;AAChC,0CAAwB;AACxB,8CAA4B;AAC5B,iDAA+B","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./Entities\";\r\nexport * from \"./ExampleFeature\"\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
@@ -0,0 +1,61 @@
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 { ExamplePM } from "../PMs/ExamplePM";
24
+ /**
25
+ * An adapter that connects UI components to ExamplePM instances.
26
+ * Implements PmAdapter<string> because ExamplePM provides string view models.
27
+ */
28
+ export const examplePmAdapter = {
29
+ // Default view model to use before data is available
30
+ defaultVM: "",
31
+ /**
32
+ * Subscribes a UI component to updates from an ExamplePM
33
+ * @param id The ID of the AppObject containing the PM
34
+ * @param appObjects The application's AppObjectRepo
35
+ * @param setVM Callback function that updates the UI component
36
+ */
37
+ subscribe: (id, appObjects, setVM) => {
38
+ // Return early if no ID is provided
39
+ if (!id)
40
+ return;
41
+ // Find the PM using the provided ID
42
+ const pm = ExamplePM.getById(id, appObjects);
43
+ if (!pm) {
44
+ appObjects.submitWarning("examplePmAdapter", "Unable to find ExamplePM");
45
+ return;
46
+ }
47
+ // Register the UI component's callback to receive updates
48
+ pm.addView(setVM);
49
+ },
50
+ /**
51
+ * Unsubscribes a UI component from updates when it's no longer needed
52
+ * @param id The ID of the AppObject containing the PM
53
+ * @param appObjects The application's AppObjectRepo
54
+ * @param setVM The same callback function that was used to subscribe
55
+ */
56
+ unsubscribe: (id, appObjects, setVM) => {
57
+ // Find the PM and remove the view if it exists
58
+ ExamplePM.getById(id, appObjects)?.removeView(setVM);
59
+ }
60
+ };
61
+ //# sourceMappingURL=examplePmAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examplePmAdapter.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Adapters/examplePmAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,qDAAqD;IACrD,SAAS,EAAE,EAAE;IAEb;;;;;OAKG;IACH,SAAS,EAAE,CACT,EAAU,EACV,UAAyB,EACzB,KAA2B,EAC3B,EAAE;QACF,oCAAoC;QACpC,IAAI,CAAC,EAAE;YAAE,OAAO;QAEhB,oCAAoC;QACpC,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,aAAa,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;YACzE,OAAO;QACT,CAAC;QAED,0DAA0D;QAC1D,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,WAAW,EAAE,CACX,EAAU,EACV,UAAyB,EACzB,KAA2B,EAC3B,EAAE;QACF,+CAA+C;QAC/C,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;CACF,CAAC","sourcesContent":["/**\r\n * examplePmAdapter.ts\r\n * \r\n * This file demonstrates how to implement a PM Adapter to connect UI components to PMs.\r\n * PM Adapters provide a standardized way for UI frameworks to subscribe to PM updates.\r\n * This adapter connects to regular (non-singleton) PMs that require an AppObject ID.\r\n * \r\n * Key concepts:\r\n * - PM Adapters implement the PmAdapter<VM> interface where VM is the view model type\r\n * - They handle subscribing UI components to PMs and unsubscribing when done\r\n * - They provide a default view model for initial rendering before data is available\r\n * - They abstract away the details of finding and connecting to specific PMs\r\n * \r\n * Usage pattern (React example):\r\n * ```typescript\r\n * // In a React component\r\n * function MyComponent({ id }) {\r\n * const viewModel = usePmAdapter(examplePmAdapter, id);\r\n * return <div>{viewModel}</div>;\r\n * }\r\n * ```\r\n */\r\n\r\nimport { AppObjectRepo } from \"../../AppObject\";\r\nimport { PmAdapter } from \"../../Types/PmAdapter\";\r\nimport { ExamplePM } from \"../PMs/ExamplePM\";\r\n\r\n/**\r\n * An adapter that connects UI components to ExamplePM instances.\r\n * Implements PmAdapter<string> because ExamplePM provides string view models.\r\n */\r\nexport const examplePmAdapter: PmAdapter<string> = {\r\n // Default view model to use before data is available\r\n defaultVM: \"\",\r\n \r\n /**\r\n * Subscribes a UI component to updates from an ExamplePM\r\n * @param id The ID of the AppObject containing the PM\r\n * @param appObjects The application's AppObjectRepo\r\n * @param setVM Callback function that updates the UI component\r\n */\r\n subscribe: (\r\n id: string,\r\n appObjects: AppObjectRepo,\r\n setVM: (vm: string) => void\r\n ) => {\r\n // Return early if no ID is provided\r\n if (!id) return;\r\n\r\n // Find the PM using the provided ID\r\n const pm = ExamplePM.getById(id, appObjects);\r\n if (!pm) {\r\n appObjects.submitWarning(\"examplePmAdapter\", \"Unable to find ExamplePM\");\r\n return;\r\n }\r\n \r\n // Register the UI component's callback to receive updates\r\n pm.addView(setVM);\r\n },\r\n \r\n /**\r\n * Unsubscribes a UI component from updates when it's no longer needed\r\n * @param id The ID of the AppObject containing the PM\r\n * @param appObjects The application's AppObjectRepo\r\n * @param setVM The same callback function that was used to subscribe\r\n */\r\n unsubscribe: (\r\n id: string,\r\n appObjects: AppObjectRepo,\r\n setVM: (vm: string) => void\r\n ) => {\r\n // Find the PM and remove the view if it exists\r\n ExamplePM.getById(id, appObjects)?.removeView(setVM);\r\n }\r\n};\r\n"]}
@@ -0,0 +1,57 @@
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 { defaultSlideNavigationVM, ExampleSingletonPM } from "../PMs/ExampleSingletonPM";
25
+ /**
26
+ * An adapter that connects UI components to the ExampleSingletonPM.
27
+ * Implements SingletonPmAdapter<ExampleVM> because ExampleSingletonPM provides ExampleVM view models.
28
+ */
29
+ export const exampleSingletonPmAdapter = {
30
+ // Default view model to use before data is available
31
+ defaultVM: defaultSlideNavigationVM,
32
+ /**
33
+ * Subscribes a UI component to updates from the ExampleSingletonPM
34
+ * @param appObjects The application's AppObjectRepo
35
+ * @param setVM Callback function that updates the UI component
36
+ */
37
+ subscribe: (appObjects, setVM) => {
38
+ // Find the singleton PM using its static get method
39
+ const pm = ExampleSingletonPM.get(appObjects);
40
+ if (!pm) {
41
+ appObjects.submitWarning("exampleSingletonPmAdapter", "Unable to find ExampleSingletonPM");
42
+ return;
43
+ }
44
+ // Register the UI component's callback to receive updates
45
+ pm.addView(setVM);
46
+ },
47
+ /**
48
+ * Unsubscribes a UI component from updates when it's no longer needed
49
+ * @param appObjects The application's AppObjectRepo
50
+ * @param setVM The same callback function that was used to subscribe
51
+ */
52
+ unsubscribe: (appObjects, setVM) => {
53
+ // Find the singleton PM and remove the view if it exists
54
+ ExampleSingletonPM.get(appObjects)?.removeView(setVM);
55
+ }
56
+ };
57
+ //# sourceMappingURL=exampleSingletonPmAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exampleSingletonPmAdapter.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Adapters/exampleSingletonPmAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAkC;IACtE,qDAAqD;IACrD,SAAS,EAAE,wBAAwB;IAEnC;;;;OAIG;IACH,SAAS,EAAE,CAAC,UAAyB,EAAE,KAA8B,EAAE,EAAE;QACvE,oDAAoD;QACpD,MAAM,EAAE,GAAG,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9C,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,aAAa,CACtB,2BAA2B,EAC3B,mCAAmC,CACpC,CAAC;YACF,OAAO;QACT,CAAC;QAED,0DAA0D;QAC1D,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,WAAW,EAAE,CAAC,UAAyB,EAAE,KAA8B,EAAE,EAAE;QACzE,yDAAyD;QACzD,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;CACF,CAAC","sourcesContent":["/**\r\n * exampleSingletonPmAdapter.ts\r\n * \r\n * This file demonstrates how to implement a Singleton PM Adapter to connect UI components\r\n * to singleton PMs. Singleton PM Adapters provide a standardized way for UI frameworks\r\n * to subscribe to singleton PM updates without needing to specify an AppObject ID.\r\n * \r\n * Key concepts:\r\n * - Singleton PM Adapters implement the SingletonPmAdapter<VM> interface\r\n * - They handle subscribing UI components to singleton PMs and unsubscribing when done\r\n * - They provide a default view model for initial rendering before data is available\r\n * - They don't require an AppObject ID since they connect to globally accessible singletons\r\n * \r\n * Usage pattern (React example):\r\n * ```typescript\r\n * // In a React component\r\n * function MyComponent() {\r\n * // Note: no ID needed since it's connecting to a singleton\r\n * const viewModel = useSingletonPmAdapter(exampleSingletonPmAdapter);\r\n * return <div>{viewModel.aBoolProperty ? \"True\" : \"False\"}</div>;\r\n * }\r\n * ```\r\n */\r\n\r\nimport { AppObjectRepo } from \"../../AppObject\";\r\nimport { SingletonPmAdapter } from \"../../Types/SingletonPmAdapter\";\r\nimport {\r\n defaultSlideNavigationVM,\r\n ExampleSingletonPM,\r\n ExampleVM\r\n} from \"../PMs/ExampleSingletonPM\";\r\n\r\n/**\r\n * An adapter that connects UI components to the ExampleSingletonPM.\r\n * Implements SingletonPmAdapter<ExampleVM> because ExampleSingletonPM provides ExampleVM view models.\r\n */\r\nexport const exampleSingletonPmAdapter: SingletonPmAdapter<ExampleVM> = {\r\n // Default view model to use before data is available\r\n defaultVM: defaultSlideNavigationVM,\r\n \r\n /**\r\n * Subscribes a UI component to updates from the ExampleSingletonPM\r\n * @param appObjects The application's AppObjectRepo\r\n * @param setVM Callback function that updates the UI component\r\n */\r\n subscribe: (appObjects: AppObjectRepo, setVM: (vm: ExampleVM) => void) => {\r\n // Find the singleton PM using its static get method\r\n const pm = ExampleSingletonPM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitWarning(\r\n \"exampleSingletonPmAdapter\",\r\n \"Unable to find ExampleSingletonPM\"\r\n );\r\n return;\r\n }\r\n \r\n // Register the UI component's callback to receive updates\r\n pm.addView(setVM);\r\n },\r\n \r\n /**\r\n * Unsubscribes a UI component from updates when it's no longer needed\r\n * @param appObjects The application's AppObjectRepo\r\n * @param setVM The same callback function that was used to subscribe\r\n */\r\n unsubscribe: (appObjects: AppObjectRepo, setVM: (vm: ExampleVM) => void) => {\r\n // Find the singleton PM and remove the view if it exists\r\n ExampleSingletonPM.get(appObjects)?.removeView(setVM);\r\n }\r\n};\r\n"]}
@@ -0,0 +1,3 @@
1
+ export * from "./examplePmAdapter";
2
+ export * from "./exampleSingletonPmAdapter";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC","sourcesContent":["export * from \"./examplePmAdapter\";\r\nexport * from \"./exampleSingletonPmAdapter\";\r\n"]}
@@ -0,0 +1,3 @@
1
+ export * from "./setExampleText";
2
+ export * from "./toggleExampleBoolean";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Controllers/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from \"./setExampleText\";\r\nexport * from \"./toggleExampleBoolean\";\r\n"]}
@@ -0,0 +1,45 @@
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 { EditExampleStringUC } from "../UCs/EditExampleStringUC";
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 function setExampleText(text, id, appObjects) {
35
+ // Find the Use Case using the provided ID
36
+ const uc = EditExampleStringUC.getById(id, appObjects);
37
+ // Handle the case where the UC doesn't exist
38
+ if (!uc) {
39
+ appObjects.submitWarning("setExampleText", "Unable to find EditExampleStringUC");
40
+ return;
41
+ }
42
+ // Call the UC method to perform the operation
43
+ uc.editExampleString(text);
44
+ }
45
+ //# sourceMappingURL=setExampleText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setExampleText.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Controllers/setExampleText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,EAAU,EACV,UAAyB;IAEzB,0CAA0C;IAC1C,MAAM,EAAE,GAAG,mBAAmB,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAEvD,6CAA6C;IAC7C,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,UAAU,CAAC,aAAa,CACtB,gBAAgB,EAChB,oCAAoC,CACrC,CAAC;QACF,OAAO;IACT,CAAC;IAED,8CAA8C;IAC9C,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/**\r\n * setExampleText.ts\r\n * \r\n * This file demonstrates how to implement a Controller function.\r\n * Controllers are simple functions that provide a simplified API for UI components\r\n * to interact with Use Cases (UCs). They handle the details of finding the right\r\n * UC and calling its methods with the appropriate parameters.\r\n * \r\n * Key concepts:\r\n * - Controllers are functions that take parameters from UI components\r\n * - They find the appropriate UC and call its methods\r\n * - They handle error cases and provide appropriate feedback\r\n * - They simplify the API for UI components\r\n * \r\n * Usage pattern (React example):\r\n * ```typescript\r\n * // In a React component\r\n * function ExampleTextInput({ id, appObjects }) {\r\n * const handleChange = (e) => {\r\n * setExampleText(e.target.value, id, appObjects);\r\n * };\r\n * return <input onChange={handleChange} />;\r\n * }\r\n * ```\r\n */\r\n\r\nimport { AppObjectRepo } from \"../../AppObject\";\r\nimport { EditExampleStringUC } from \"../UCs/EditExampleStringUC\";\r\n\r\n/**\r\n * Controller function to update the text of an ExampleEntity\r\n * \r\n * @param text The new text to set\r\n * @param id The ID of the AppObject containing the EditExampleStringUC\r\n * @param appObjects The application's AppObjectRepo\r\n */\r\nexport function setExampleText(\r\n text: string,\r\n id: string,\r\n appObjects: AppObjectRepo\r\n) {\r\n // Find the Use Case using the provided ID\r\n const uc = EditExampleStringUC.getById(id, appObjects);\r\n \r\n // Handle the case where the UC doesn't exist\r\n if (!uc) {\r\n appObjects.submitWarning(\r\n \"setExampleText\",\r\n \"Unable to find EditExampleStringUC\"\r\n );\r\n return;\r\n }\r\n\r\n // Call the UC method to perform the operation\r\n uc.editExampleString(text);\r\n}\r\n"]}
@@ -0,0 +1,44 @@
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 { ToggleExampleBooleanUC } from "../UCs/ToggleExampleBooleanUC";
28
+ /**
29
+ * Controller function to toggle the boolean property of the SingletonEntityExample
30
+ *
31
+ * @param appObjects The application's AppObjectRepo
32
+ */
33
+ export function toggleExampleBoolean(appObjects) {
34
+ // Access the singleton UC using its static get method
35
+ const uc = ToggleExampleBooleanUC.get(appObjects);
36
+ // Handle the case where the UC doesn't exist yet
37
+ if (!uc) {
38
+ appObjects.submitWarning("toggleExampleBoolean", "Unable to find ToggleExampleBooleanUC");
39
+ return;
40
+ }
41
+ // Call the UC method to perform the operation
42
+ uc.toggleExampleBoolean();
43
+ }
44
+ //# sourceMappingURL=toggleExampleBoolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggleExampleBoolean.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Controllers/toggleExampleBoolean.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAyB;IAC5D,sDAAsD;IACtD,MAAM,EAAE,GAAG,sBAAsB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAElD,iDAAiD;IACjD,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,UAAU,CAAC,aAAa,CACtB,sBAAsB,EACtB,uCAAuC,CACxC,CAAC;QACF,OAAO;IACT,CAAC;IAED,8CAA8C;IAC9C,EAAE,CAAC,oBAAoB,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["/**\r\n * toggleExampleBoolean.ts\r\n * \r\n * This file demonstrates how to implement a Controller function for a singleton UC.\r\n * This controller provides a simplified API for UI components to interact with \r\n * the ToggleExampleBooleanUC singleton, handling the details of finding the UC\r\n * and calling its method.\r\n * \r\n * Key concepts:\r\n * - Controllers for singleton UCs don't need an ID parameter\r\n * - They access the singleton UC using its static get() method\r\n * - They handle error cases and provide appropriate feedback\r\n * - They simplify the API for UI components\r\n * \r\n * Usage pattern (React example):\r\n * ```typescript\r\n * // In a React component\r\n * function ToggleButton({ appObjects }) {\r\n * return (\r\n * <button onClick={() => toggleExampleBoolean(appObjects)}>\r\n * Toggle\r\n * </button>\r\n * );\r\n * }\r\n * ```\r\n */\r\n\r\nimport { AppObjectRepo } from \"../../AppObject\";\r\nimport { ToggleExampleBooleanUC } from \"../UCs/ToggleExampleBooleanUC\";\r\n\r\n/**\r\n * Controller function to toggle the boolean property of the SingletonEntityExample\r\n * \r\n * @param appObjects The application's AppObjectRepo\r\n */\r\nexport function toggleExampleBoolean(appObjects: AppObjectRepo) {\r\n // Access the singleton UC using its static get method\r\n const uc = ToggleExampleBooleanUC.get(appObjects);\r\n \r\n // Handle the case where the UC doesn't exist yet\r\n if (!uc) {\r\n appObjects.submitWarning(\r\n \"toggleExampleBoolean\",\r\n \"Unable to find ToggleExampleBooleanUC\"\r\n );\r\n return;\r\n }\r\n\r\n // Call the UC method to perform the operation\r\n uc.toggleExampleBoolean();\r\n}\r\n"]}
@@ -0,0 +1,85 @@
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 { AppObjectEntity } from "../../AppObject";
19
+ import { MemoizedString } from "../../Entities/MemoizedString";
20
+ /**
21
+ * ExampleEntity represents a basic entity with a string property.
22
+ * Abstract class provides the interface and static helper methods.
23
+ */
24
+ export class ExampleEntity extends AppObjectEntity {
25
+ /**
26
+ * Retrieves an ExampleEntity component from an AppObject
27
+ * @param appObj The AppObject to get the component from
28
+ * @returns The ExampleEntity component or undefined if not found
29
+ */
30
+ static get(appObj) {
31
+ return appObj.getComponent(this.type);
32
+ }
33
+ /**
34
+ * Retrieves an ExampleEntity by its parent AppObject's ID
35
+ * @param id The ID of the parent AppObject
36
+ * @param appObjects The AppObjectRepo to search in
37
+ * @returns The ExampleEntity component or undefined if not found
38
+ */
39
+ static getById(id, appObjects) {
40
+ return appObjects.get(id)?.getComponent(this.type);
41
+ }
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) {
48
+ const existing = appObj.getComponent(this.type);
49
+ if (existing) {
50
+ return existing;
51
+ }
52
+ else {
53
+ return makeExampleEntity(appObj);
54
+ }
55
+ }
56
+ }
57
+ /** Unique type identifier for this component */
58
+ ExampleEntity.type = "ExampleEntityType";
59
+ /**
60
+ * Factory function to create a new ExampleEntity
61
+ * @param appObject The AppObject to attach the entity to
62
+ * @returns A new ExampleEntity instance
63
+ */
64
+ export function makeExampleEntity(appObject) {
65
+ return new ExampleEntityImp(appObject);
66
+ }
67
+ /**
68
+ * Concrete implementation of ExampleEntity
69
+ * This private class handles the actual implementation details
70
+ */
71
+ class ExampleEntityImp extends ExampleEntity {
72
+ // Property accessors that use the memoized value
73
+ get aStringProperty() {
74
+ return this.memoizedIsAuthoring.val;
75
+ }
76
+ set aStringProperty(val) {
77
+ this.memoizedIsAuthoring.val = val;
78
+ }
79
+ constructor(appObject) {
80
+ super(appObject, ExampleEntity.type);
81
+ // MemoizedString tracks changes to the string value and calls notifyOnChange when updated
82
+ this.memoizedIsAuthoring = new MemoizedString("", this.notifyOnChange);
83
+ }
84
+ }
85
+ //# sourceMappingURL=ExampleEntity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleEntity.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEL,eAAe,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,eAAe;IAQzD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAgB,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAU,EACV,UAAyB;QAEzB,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAgB,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,MAAiB;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAgB,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;;AAzCD,gDAAgD;AAChC,kBAAI,GAAG,mBAAmB,CAAC;AA2C7C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAoB;IAEpB,OAAO,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,gBAAiB,SAAQ,aAAa;IAI1C,iDAAiD;IACjD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;IACtC,CAAC;IAED,IAAI,eAAe,CAAC,GAAW;QAC7B,IAAI,CAAC,mBAAmB,CAAC,GAAG,GAAG,GAAG,CAAC;IACrC,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QAbvC,0FAA0F;QAClF,wBAAmB,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAa1E,CAAC;CACF","sourcesContent":["/**\r\n * ExampleEntity.ts\r\n * \r\n * This file demonstrates how to implement a standard (non-singleton) entity in the application.\r\n * Entities store and manage data, track state changes, and notify observers when changes occur.\r\n * \r\n * Key concepts:\r\n * - Entity classes extend AppObjectEntity\r\n * - They provide access to data properties\r\n * - They use Memoized types (MemoizedString, MemoizedBoolean, etc.) to track changes\r\n * - They notify observers when properties change\r\n * \r\n * Usage pattern:\r\n * 1. Get or create an entity instance using getById, get, or addIfMissing\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 { MemoizedString } from \"../../Entities/MemoizedString\";\r\n\r\n/**\r\n * ExampleEntity represents a basic entity with a string property.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExampleEntity extends AppObjectEntity {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleEntityType\";\r\n\r\n /** String property accessor methods that must be implemented */\r\n abstract get aStringProperty(): string;\r\n abstract set aStringProperty(val: string);\r\n\r\n /**\r\n * Retrieves an ExampleEntity component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The ExampleEntity component or undefined if not found\r\n */\r\n static get(appObj: AppObject): ExampleEntity | undefined {\r\n return appObj.getComponent<ExampleEntity>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an ExampleEntity 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 ExampleEntity component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): ExampleEntity | undefined {\r\n return appObjects.get(id)?.getComponent<ExampleEntity>(this.type);\r\n }\r\n\r\n /**\r\n * Ensures an ExampleEntity exists on the AppObject, creating one if needed\r\n * @param appObj The AppObject to check/add the component to\r\n * @returns The existing or newly created ExampleEntity\r\n */\r\n static addIfMissing(appObj: AppObject): ExampleEntity {\r\n const existing = appObj.getComponent<ExampleEntity>(this.type);\r\n if (existing) {\r\n return existing;\r\n } else {\r\n return makeExampleEntity(appObj);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExampleEntity\r\n * @param appObject The AppObject to attach the entity to\r\n * @returns A new ExampleEntity instance\r\n */\r\nexport function makeExampleEntity(\r\n appObject: AppObject\r\n): ExampleEntity {\r\n return new ExampleEntityImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleEntity\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleEntityImp extends ExampleEntity {\r\n // MemoizedString tracks changes to the string value and calls notifyOnChange when updated\r\n private memoizedIsAuthoring = new MemoizedString(\"\", this.notifyOnChange);\r\n \r\n // Property accessors that use the memoized value\r\n get aStringProperty() {\r\n return this.memoizedIsAuthoring.val;\r\n }\r\n \r\n set aStringProperty(val: string) {\r\n this.memoizedIsAuthoring.val = val;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleEntity.type);\r\n }\r\n}\r\n"]}