@vived/core 1.6.0 → 2.0.1

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 (97) hide show
  1. package/dist/cjs/AppObject/AppObjectComponent.js +8 -10
  2. package/dist/cjs/AppObject/AppObjectComponent.js.map +1 -1
  3. package/dist/cjs/AppObject/AppObjectEntityRepo.js +113 -11
  4. package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +1 -1
  5. package/dist/cjs/AppObject/AppObjectPM.js +106 -6
  6. package/dist/cjs/AppObject/AppObjectPM.js.map +1 -1
  7. package/dist/cjs/AppObject/AppObjectRepo.js +4 -1
  8. package/dist/cjs/AppObject/AppObjectRepo.js.map +1 -1
  9. package/dist/cjs/AppObject/AppObjectSingletonEntity.js +40 -0
  10. package/dist/cjs/AppObject/AppObjectSingletonEntity.js.map +1 -0
  11. package/dist/cjs/AppObject/AppObjectSingletonEntityRepo.js +54 -0
  12. package/dist/cjs/AppObject/AppObjectSingletonEntityRepo.js.map +1 -0
  13. package/dist/cjs/AppObject/AppObjectSingletonPM.js +69 -0
  14. package/dist/cjs/AppObject/AppObjectSingletonPM.js.map +1 -0
  15. package/dist/cjs/AppObject/AppObjectSingletonUC.js +60 -0
  16. package/dist/cjs/AppObject/AppObjectSingletonUC.js.map +1 -0
  17. package/dist/cjs/AppObject/index.js +4 -0
  18. package/dist/cjs/AppObject/index.js.map +1 -1
  19. package/dist/cjs/Entities/ObserverList.js +6 -0
  20. package/dist/cjs/Entities/ObserverList.js.map +1 -1
  21. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js +10 -22
  22. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
  23. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js +1 -3
  24. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -1
  25. package/dist/cjs/ExampleFeature/Factory/ExampleFeatureFactory.js +1 -1
  26. package/dist/cjs/ExampleFeature/Factory/ExampleFeatureFactory.js.map +1 -1
  27. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js +5 -13
  28. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js.map +1 -1
  29. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js +8 -12
  30. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -1
  31. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js +0 -4
  32. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -1
  33. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js +2 -8
  34. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -1
  35. package/dist/esm/AppObject/AppObjectComponent.js +8 -10
  36. package/dist/esm/AppObject/AppObjectComponent.js.map +1 -1
  37. package/dist/esm/AppObject/AppObjectEntityRepo.js +113 -11
  38. package/dist/esm/AppObject/AppObjectEntityRepo.js.map +1 -1
  39. package/dist/esm/AppObject/AppObjectPM.js +107 -7
  40. package/dist/esm/AppObject/AppObjectPM.js.map +1 -1
  41. package/dist/esm/AppObject/AppObjectRepo.js +4 -1
  42. package/dist/esm/AppObject/AppObjectRepo.js.map +1 -1
  43. package/dist/esm/AppObject/AppObjectSingletonEntity.js +36 -0
  44. package/dist/esm/AppObject/AppObjectSingletonEntity.js.map +1 -0
  45. package/dist/esm/AppObject/AppObjectSingletonEntityRepo.js +50 -0
  46. package/dist/esm/AppObject/AppObjectSingletonEntityRepo.js.map +1 -0
  47. package/dist/esm/AppObject/AppObjectSingletonPM.js +65 -0
  48. package/dist/esm/AppObject/AppObjectSingletonPM.js.map +1 -0
  49. package/dist/esm/AppObject/AppObjectSingletonUC.js +56 -0
  50. package/dist/esm/AppObject/AppObjectSingletonUC.js.map +1 -0
  51. package/dist/esm/AppObject/index.js +4 -0
  52. package/dist/esm/AppObject/index.js.map +1 -1
  53. package/dist/esm/Entities/ObserverList.js +6 -0
  54. package/dist/esm/Entities/ObserverList.js.map +1 -1
  55. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js +10 -22
  56. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
  57. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js +2 -4
  58. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -1
  59. package/dist/esm/ExampleFeature/Factory/ExampleFeatureFactory.js +1 -1
  60. package/dist/esm/ExampleFeature/Factory/ExampleFeatureFactory.js.map +1 -1
  61. package/dist/esm/ExampleFeature/PMs/ExamplePM.js +5 -13
  62. package/dist/esm/ExampleFeature/PMs/ExamplePM.js.map +1 -1
  63. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js +9 -13
  64. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -1
  65. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js +0 -4
  66. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -1
  67. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js +3 -9
  68. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -1
  69. package/dist/types/AppObject/AppObjectComponent.d.ts +6 -4
  70. package/dist/types/AppObject/AppObjectComponent.d.ts.map +1 -1
  71. package/dist/types/AppObject/AppObjectEntityRepo.d.ts +80 -7
  72. package/dist/types/AppObject/AppObjectEntityRepo.d.ts.map +1 -1
  73. package/dist/types/AppObject/AppObjectPM.d.ts +82 -2
  74. package/dist/types/AppObject/AppObjectPM.d.ts.map +1 -1
  75. package/dist/types/AppObject/AppObjectRepo.d.ts +6 -0
  76. package/dist/types/AppObject/AppObjectRepo.d.ts.map +1 -1
  77. package/dist/types/AppObject/AppObjectSingletonEntity.d.ts +31 -0
  78. package/dist/types/AppObject/AppObjectSingletonEntity.d.ts.map +1 -0
  79. package/dist/types/AppObject/AppObjectSingletonEntityRepo.d.ts +46 -0
  80. package/dist/types/AppObject/AppObjectSingletonEntityRepo.d.ts.map +1 -0
  81. package/dist/types/AppObject/AppObjectSingletonPM.d.ts +60 -0
  82. package/dist/types/AppObject/AppObjectSingletonPM.d.ts.map +1 -0
  83. package/dist/types/AppObject/AppObjectSingletonUC.d.ts +51 -0
  84. package/dist/types/AppObject/AppObjectSingletonUC.d.ts.map +1 -0
  85. package/dist/types/AppObject/index.d.ts +4 -0
  86. package/dist/types/AppObject/index.d.ts.map +1 -1
  87. package/dist/types/Entities/ObserverList.d.ts +4 -0
  88. package/dist/types/Entities/ObserverList.d.ts.map +1 -1
  89. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts +1 -5
  90. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts.map +1 -1
  91. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts +2 -2
  92. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts.map +1 -1
  93. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts +4 -4
  94. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts.map +1 -1
  95. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts +2 -2
  96. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts.map +1 -1
  97. package/package.json +2 -2
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectSingletonEntity = void 0;
4
+ const AppObjectEntity_1 = require("./AppObjectEntity");
5
+ /**
6
+ * Singleton entity component that manages application state
7
+ *
8
+ * AppObjectSingletonEntity extends AppObjectEntity and automatically registers itself
9
+ * as a singleton in the AppObjectRepo upon construction. This ensures only one instance
10
+ * of this entity type exists across the entire application.
11
+ *
12
+ * Use this class when you need an entity that should have only one instance globally,
13
+ * such as application-wide configuration or shared state managers.
14
+ */
15
+ class AppObjectSingletonEntity extends AppObjectEntity_1.AppObjectEntity {
16
+ /**
17
+ * Creates a new singleton entity component and attaches it to the specified AppObject
18
+ * Automatically registers itself as a singleton in the AppObjectRepo
19
+ *
20
+ * @param appObject The parent AppObject this component will be attached to
21
+ * @param type The unique type identifier for this component
22
+ */
23
+ constructor(appObject, type) {
24
+ super(appObject, type);
25
+ this.appObjects.registerSingleton(this);
26
+ }
27
+ /**
28
+ * Cleans up resources and unregisters the singleton
29
+ *
30
+ * This method:
31
+ * 1. Unregisters itself from the singleton registry
32
+ * 2. Calls the parent class dispose method
33
+ */
34
+ dispose() {
35
+ this.appObjects.unregisterSingleton(this.type);
36
+ super.dispose();
37
+ }
38
+ }
39
+ exports.AppObjectSingletonEntity = AppObjectSingletonEntity;
40
+ //# sourceMappingURL=AppObjectSingletonEntity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonEntity.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonEntity.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEpD;;;;;;;;;GASG;AACH,MAAa,wBAAyB,SAAQ,iCAAe;IAC3D;;;;;;OAMG;IACH,YAAY,SAAoB,EAAE,IAAY;QAC5C,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAEvB,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,OAAO;QACL,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAzBD,4DAyBC","sourcesContent":["import { AppObject } from \"./AppObject\";\r\nimport { AppObjectEntity } from \"./AppObjectEntity\";\r\n\r\n/**\r\n * Singleton entity component that manages application state\r\n *\r\n * AppObjectSingletonEntity extends AppObjectEntity and automatically registers itself\r\n * as a singleton in the AppObjectRepo upon construction. This ensures only one instance\r\n * of this entity type exists across the entire application.\r\n *\r\n * Use this class when you need an entity that should have only one instance globally,\r\n * such as application-wide configuration or shared state managers.\r\n */\r\nexport class AppObjectSingletonEntity extends AppObjectEntity {\r\n /**\r\n * Creates a new singleton entity component and attaches it to the specified AppObject\r\n * Automatically registers itself as a singleton in the AppObjectRepo\r\n *\r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n super(appObject, type);\r\n\r\n this.appObjects.registerSingleton(this);\r\n }\r\n\r\n /**\r\n * Cleans up resources and unregisters the singleton\r\n *\r\n * This method:\r\n * 1. Unregisters itself from the singleton registry\r\n * 2. Calls the parent class dispose method\r\n */\r\n dispose() {\r\n this.appObjects.unregisterSingleton(this.type);\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectSingletonEntityRepo = void 0;
4
+ const AppObjectEntityRepo_1 = require("./AppObjectEntityRepo");
5
+ /**
6
+ * A singleton repository for managing collections of AppObjectEntity instances.
7
+ *
8
+ * This generic class extends AppObjectEntityRepo and automatically registers itself
9
+ * as a singleton in the AppObjectRepo upon construction. This ensures only one instance
10
+ * of this repository type exists across the entire application.
11
+ *
12
+ * Use this class when you need a centralized repository that should have only one instance
13
+ * globally, such as application-wide entity collections or shared resource managers.
14
+ *
15
+ * @template T - The type of entities managed by this repository, must extend AppObjectEntity
16
+ * @extends AppObjectEntityRepo
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Create a singleton repository for player entities
21
+ * class PlayerRepo extends AppObjectSingletonEntityRepo<PlayerEntity> {
22
+ * static type = "playerRepo";
23
+ * constructor(appObject: AppObject) {
24
+ * super(appObject, PlayerRepo.type);
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ class AppObjectSingletonEntityRepo extends AppObjectEntityRepo_1.AppObjectEntityRepo {
30
+ /**
31
+ * Creates a new singleton entity repository component and attaches it to the specified AppObject
32
+ * Automatically registers itself as a singleton in the AppObjectRepo
33
+ *
34
+ * @param appObject The parent AppObject this component will be attached to
35
+ * @param type The unique type identifier for this component
36
+ */
37
+ constructor(appObject, type) {
38
+ super(appObject, type);
39
+ this.appObjects.registerSingleton(this);
40
+ }
41
+ /**
42
+ * Cleans up resources and unregisters the singleton
43
+ *
44
+ * This method:
45
+ * 1. Unregisters itself from the singleton registry
46
+ * 2. Calls the parent class dispose method
47
+ */
48
+ dispose() {
49
+ this.appObjects.unregisterSingleton(this.type);
50
+ super.dispose();
51
+ }
52
+ }
53
+ exports.AppObjectSingletonEntityRepo = AppObjectSingletonEntityRepo;
54
+ //# sourceMappingURL=AppObjectSingletonEntityRepo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonEntityRepo.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonEntityRepo.ts"],"names":[],"mappings":";;;AAEA,+DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,4BAEX,SAAQ,yCAAsB;IAC9B;;;;;;OAMG;IACH,YAAY,SAAoB,EAAE,IAAY;QAC5C,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAEvB,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,OAAO;QACL,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AA3BD,oEA2BC","sourcesContent":["import { AppObject } from \"./AppObject\";\r\nimport { AppObjectEntity } from \"./AppObjectEntity\";\r\nimport { AppObjectEntityRepo } from \"./AppObjectEntityRepo\";\r\n\r\n/**\r\n * A singleton repository for managing collections of AppObjectEntity instances.\r\n *\r\n * This generic class extends AppObjectEntityRepo and automatically registers itself\r\n * as a singleton in the AppObjectRepo upon construction. This ensures only one instance\r\n * of this repository type exists across the entire application.\r\n *\r\n * Use this class when you need a centralized repository that should have only one instance\r\n * globally, such as application-wide entity collections or shared resource managers.\r\n *\r\n * @template T - The type of entities managed by this repository, must extend AppObjectEntity\r\n * @extends AppObjectEntityRepo\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a singleton repository for player entities\r\n * class PlayerRepo extends AppObjectSingletonEntityRepo<PlayerEntity> {\r\n * static type = \"playerRepo\";\r\n * constructor(appObject: AppObject) {\r\n * super(appObject, PlayerRepo.type);\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AppObjectSingletonEntityRepo<\r\n T extends AppObjectEntity,\r\n> extends AppObjectEntityRepo<T> {\r\n /**\r\n * Creates a new singleton entity repository component and attaches it to the specified AppObject\r\n * Automatically registers itself as a singleton in the AppObjectRepo\r\n *\r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n super(appObject, type);\r\n\r\n this.appObjects.registerSingleton(this);\r\n }\r\n\r\n /**\r\n * Cleans up resources and unregisters the singleton\r\n *\r\n * This method:\r\n * 1. Unregisters itself from the singleton registry\r\n * 2. Calls the parent class dispose method\r\n */\r\n dispose() {\r\n this.appObjects.unregisterSingleton(this.type);\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectSingletonPM = void 0;
4
+ const AppObjectPM_1 = require("./AppObjectPM");
5
+ /**
6
+ * Singleton Presentation Manager (PM) component that transforms application state into view models
7
+ *
8
+ * AppObjectSingletonPM extends AppObjectPM and automatically registers itself as a singleton
9
+ * in the AppObjectRepo upon construction. This ensures only one instance of this PM type exists
10
+ * across the entire application.
11
+ *
12
+ * Use this class when you need a presentation manager that should have only one instance globally,
13
+ * such as application-wide UI state managers or shared view model providers.
14
+ *
15
+ * A singleton PM typically:
16
+ * 1. Observes entity changes
17
+ * 2. Transforms entity data into view models
18
+ * 3. Notifies attached views when view models change
19
+ * 4. Handles view model caching and optimization
20
+ * 5. Exists as a single instance across the application
21
+ *
22
+ * @typeparam T The view model type this PM produces
23
+ * @extends AppObjectPM
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * class GlobalSettingsPM extends AppObjectSingletonPM<SettingsVM> {
28
+ * static type = "globalSettingsPM";
29
+ *
30
+ * constructor(appObject: AppObject) {
31
+ * super(appObject, GlobalSettingsPM.type);
32
+ * }
33
+ *
34
+ * vmsAreEqual(a: SettingsVM, b: SettingsVM): boolean {
35
+ * return a.theme === b.theme && a.language === b.language;
36
+ * }
37
+ *
38
+ * formVM(): void {
39
+ * // Form view model from entities
40
+ * }
41
+ * }
42
+ * ```
43
+ */
44
+ class AppObjectSingletonPM extends AppObjectPM_1.AppObjectPM {
45
+ /**
46
+ * Creates a new singleton presentation manager component and attaches it to the specified AppObject
47
+ * Automatically registers itself as a singleton in the AppObjectRepo
48
+ *
49
+ * @param appObject The parent AppObject this component will be attached to
50
+ * @param type The unique type identifier for this component
51
+ */
52
+ constructor(appObject, type) {
53
+ super(appObject, type);
54
+ this.appObjects.registerSingleton(this);
55
+ }
56
+ /**
57
+ * Cleans up resources and unregisters the singleton
58
+ *
59
+ * This method:
60
+ * 1. Unregisters itself from the singleton registry
61
+ * 2. Calls the parent class dispose method (which handles entity observers and views)
62
+ */
63
+ dispose() {
64
+ this.appObjects.unregisterSingleton(this.type);
65
+ super.dispose();
66
+ }
67
+ }
68
+ exports.AppObjectSingletonPM = AppObjectSingletonPM;
69
+ //# sourceMappingURL=AppObjectSingletonPM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonPM.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonPM.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAsB,oBAAwB,SAAQ,yBAAc;IAClE;;;;;;OAMG;IACH,YAAY,SAAoB,EAAE,IAAY;QAC5C,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAEvB,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,OAAO;QACL,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAzBD,oDAyBC","sourcesContent":["import { AppObject } from \"./AppObject\";\r\nimport { AppObjectPM } from \"./AppObjectPM\";\r\n\r\n/**\r\n * Singleton Presentation Manager (PM) component that transforms application state into view models\r\n *\r\n * AppObjectSingletonPM extends AppObjectPM and automatically registers itself as a singleton\r\n * in the AppObjectRepo upon construction. This ensures only one instance of this PM type exists\r\n * across the entire application.\r\n *\r\n * Use this class when you need a presentation manager that should have only one instance globally,\r\n * such as application-wide UI state managers or shared view model providers.\r\n *\r\n * A singleton PM typically:\r\n * 1. Observes entity changes\r\n * 2. Transforms entity data into view models\r\n * 3. Notifies attached views when view models change\r\n * 4. Handles view model caching and optimization\r\n * 5. Exists as a single instance across the application\r\n *\r\n * @typeparam T The view model type this PM produces\r\n * @extends AppObjectPM\r\n *\r\n * @example\r\n * ```typescript\r\n * class GlobalSettingsPM extends AppObjectSingletonPM<SettingsVM> {\r\n * static type = \"globalSettingsPM\";\r\n *\r\n * constructor(appObject: AppObject) {\r\n * super(appObject, GlobalSettingsPM.type);\r\n * }\r\n *\r\n * vmsAreEqual(a: SettingsVM, b: SettingsVM): boolean {\r\n * return a.theme === b.theme && a.language === b.language;\r\n * }\r\n *\r\n * formVM(): void {\r\n * // Form view model from entities\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport abstract class AppObjectSingletonPM<T> extends AppObjectPM<T> {\r\n /**\r\n * Creates a new singleton presentation manager component and attaches it to the specified AppObject\r\n * Automatically registers itself as a singleton in the AppObjectRepo\r\n *\r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n super(appObject, type);\r\n\r\n this.appObjects.registerSingleton(this);\r\n }\r\n\r\n /**\r\n * Cleans up resources and unregisters the singleton\r\n *\r\n * This method:\r\n * 1. Unregisters itself from the singleton registry\r\n * 2. Calls the parent class dispose method (which handles entity observers and views)\r\n */\r\n dispose() {\r\n this.appObjects.unregisterSingleton(this.type);\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppObjectSingletonUC = void 0;
4
+ const AppObjectUC_1 = require("./AppObjectUC");
5
+ /**
6
+ * AppObjectSingletonUC (Use Case) serves as a singleton use case class within the application framework.
7
+ *
8
+ * This class extends AppObjectUC and automatically registers itself as a singleton in the
9
+ * AppObjectRepo upon construction. This ensures only one instance of this use case type exists
10
+ * across the entire application.
11
+ *
12
+ * Use Cases are components that represent specific application operations or workflows.
13
+ * They encapsulate business rules and coordinate interactions between different parts
14
+ * of the application. Use this singleton version when the use case should exist as a
15
+ * single instance globally, such as application-wide orchestration or workflow managers.
16
+ *
17
+ * @extends AppObjectUC
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * class GlobalPurchaseManagerUC extends AppObjectSingletonUC {
22
+ * static type = "globalPurchaseManagerUC";
23
+ *
24
+ * constructor(appObject: AppObject) {
25
+ * super(appObject, GlobalPurchaseManagerUC.type);
26
+ * }
27
+ *
28
+ * execute(itemId: string, quantity: number): boolean {
29
+ * // Implement the purchase item use case
30
+ * return true; // if successful
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ class AppObjectSingletonUC extends AppObjectUC_1.AppObjectUC {
36
+ /**
37
+ * Creates a new singleton use case component and attaches it to the specified AppObject
38
+ * Automatically registers itself as a singleton in the AppObjectRepo
39
+ *
40
+ * @param appObject The parent AppObject this component will be attached to
41
+ * @param type The unique type identifier for this component
42
+ */
43
+ constructor(appObject, type) {
44
+ super(appObject, type);
45
+ this.appObjects.registerSingleton(this);
46
+ }
47
+ /**
48
+ * Cleans up resources and unregisters the singleton
49
+ *
50
+ * This method:
51
+ * 1. Unregisters itself from the singleton registry
52
+ * 2. Calls the parent class dispose method
53
+ */
54
+ dispose() {
55
+ this.appObjects.unregisterSingleton(this.type);
56
+ super.dispose();
57
+ }
58
+ }
59
+ exports.AppObjectSingletonUC = AppObjectSingletonUC;
60
+ //# sourceMappingURL=AppObjectSingletonUC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonUC.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonUC.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,oBAAqB,SAAQ,yBAAW;IACnD;;;;;;OAMG;IACH,YAAY,SAAoB,EAAE,IAAY;QAC5C,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAEvB,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,OAAO;QACL,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAzBD,oDAyBC","sourcesContent":["import { AppObject } from \"./AppObject\";\r\nimport { AppObjectUC } from \"./AppObjectUC\";\r\n\r\n/**\r\n * AppObjectSingletonUC (Use Case) serves as a singleton use case class within the application framework.\r\n *\r\n * This class extends AppObjectUC and automatically registers itself as a singleton in the\r\n * AppObjectRepo upon construction. This ensures only one instance of this use case type exists\r\n * across the entire application.\r\n *\r\n * Use Cases are components that represent specific application operations or workflows.\r\n * They encapsulate business rules and coordinate interactions between different parts\r\n * of the application. Use this singleton version when the use case should exist as a\r\n * single instance globally, such as application-wide orchestration or workflow managers.\r\n *\r\n * @extends AppObjectUC\r\n *\r\n * @example\r\n * ```typescript\r\n * class GlobalPurchaseManagerUC extends AppObjectSingletonUC {\r\n * static type = \"globalPurchaseManagerUC\";\r\n *\r\n * constructor(appObject: AppObject) {\r\n * super(appObject, GlobalPurchaseManagerUC.type);\r\n * }\r\n *\r\n * execute(itemId: string, quantity: number): boolean {\r\n * // Implement the purchase item use case\r\n * return true; // if successful\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AppObjectSingletonUC extends AppObjectUC {\r\n /**\r\n * Creates a new singleton use case component and attaches it to the specified AppObject\r\n * Automatically registers itself as a singleton in the AppObjectRepo\r\n *\r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n super(appObject, type);\r\n\r\n this.appObjects.registerSingleton(this);\r\n }\r\n\r\n /**\r\n * Cleans up resources and unregisters the singleton\r\n *\r\n * This method:\r\n * 1. Unregisters itself from the singleton registry\r\n * 2. Calls the parent class dispose method\r\n */\r\n dispose() {\r\n this.appObjects.unregisterSingleton(this.type);\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -22,6 +22,10 @@ __exportStar(require("./AppObjectRepo"), exports);
22
22
  __exportStar(require("./AppObjectUC"), exports);
23
23
  __exportStar(require("./AppObjectController"), exports);
24
24
  __exportStar(require("./AppObjectView"), exports);
25
+ __exportStar(require("./AppObjectSingletonEntity"), exports);
26
+ __exportStar(require("./AppObjectSingletonEntityRepo"), exports);
27
+ __exportStar(require("./AppObjectSingletonPM"), exports);
28
+ __exportStar(require("./AppObjectSingletonUC"), exports);
25
29
  __exportStar(require("./getSingletonComponent"), exports);
26
30
  __exportStar(require("./printAppObjectDetails"), exports);
27
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/AppObject/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,oDAAiC;AACjC,wDAAqC;AACrC,gDAA6B;AAC7B,kDAA+B;AAC/B,gDAA6B;AAC7B,wDAAqC;AACrC,kDAA+B;AAC/B,0DAAwC;AACxC,0DAAwC","sourcesContent":["export * from \"./AppObject\"\r\nexport * from \"./AppObjectEntity\"\r\nexport * from \"./AppObjectEntityRepo\"\r\nexport * from \"./AppObjectPM\"\r\nexport * from \"./AppObjectRepo\"\r\nexport * from \"./AppObjectUC\"\r\nexport * from \"./AppObjectController\"\r\nexport * from \"./AppObjectView\"\r\nexport * from \"./getSingletonComponent\";\r\nexport * from \"./printAppObjectDetails\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/AppObject/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,oDAAkC;AAClC,wDAAsC;AACtC,gDAA8B;AAC9B,kDAAgC;AAChC,gDAA8B;AAC9B,wDAAsC;AACtC,kDAAgC;AAChC,6DAA2C;AAC3C,iEAA+C;AAC/C,yDAAuC;AACvC,yDAAuC;AACvC,0DAAwC;AACxC,0DAAwC","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./AppObjectEntity\";\r\nexport * from \"./AppObjectEntityRepo\";\r\nexport * from \"./AppObjectPM\";\r\nexport * from \"./AppObjectRepo\";\r\nexport * from \"./AppObjectUC\";\r\nexport * from \"./AppObjectController\";\r\nexport * from \"./AppObjectView\";\r\nexport * from \"./AppObjectSingletonEntity\";\r\nexport * from \"./AppObjectSingletonEntityRepo\";\r\nexport * from \"./AppObjectSingletonPM\";\r\nexport * from \"./AppObjectSingletonUC\";\r\nexport * from \"./getSingletonComponent\";\r\nexport * from \"./printAppObjectDetails\";\r\n"]}
@@ -43,6 +43,12 @@ class ObserverList {
43
43
  this.observers = [];
44
44
  };
45
45
  }
46
+ /**
47
+ * Gets the number of observers in the list
48
+ */
49
+ get length() {
50
+ return this.observers.length;
51
+ }
46
52
  }
47
53
  exports.ObserverList = ObserverList;
48
54
  //# sourceMappingURL=ObserverList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObserverList.js","sourceRoot":"","sources":["../../../src/Entities/ObserverList.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,YAAY;IAAzB;QACU,cAAS,GAAyB,EAAE,CAAC;QAE7C;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAM,EAAE,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,GAAG,CAAC,GAAG,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF;;;WAGG;QACI,QAAG,GAAG,CAAC,GAAqB,EAAE,EAAE;YACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAqB,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC;QAEF;;WAEG;QACI,UAAK,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;CAAA;AAtCD,oCAsCC","sourcesContent":["/**\r\n * A generic implementation of the Observer pattern.\r\n * Maintains a list of observer functions that can be notified with a message.\r\n *\r\n * @typeParam T - The type of message that will be passed to observers\r\n */\r\nexport class ObserverList<T> {\r\n private observers: ((msg: T) => void)[] = [];\r\n\r\n /**\r\n * Notifies all observers by calling them with the provided message\r\n * @param msg - The message to send to all observers\r\n */\r\n public notify = (msg: T) => {\r\n this.observers.forEach((obs) => {\r\n obs(msg);\r\n });\r\n };\r\n\r\n /**\r\n * Adds a new observer function to the list\r\n * @param obs - The observer function to add\r\n */\r\n public add = (obs: (msg: T) => void) => {\r\n this.observers.push(obs);\r\n };\r\n\r\n /**\r\n * Removes an observer from the list\r\n * @param obs - The observer function to remove\r\n */\r\n public remove = (obs: (msg: T) => void) => {\r\n const index = this.observers.indexOf(obs);\r\n if (index >= 0) {\r\n this.observers.splice(index, 1);\r\n }\r\n };\r\n\r\n /**\r\n * Removes all observers from the list\r\n */\r\n public clear = () => {\r\n this.observers = [];\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"ObserverList.js","sourceRoot":"","sources":["../../../src/Entities/ObserverList.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,YAAY;IAAzB;QACU,cAAS,GAAyB,EAAE,CAAC;QAS7C;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAM,EAAE,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,GAAG,CAAC,GAAG,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF;;;WAGG;QACI,QAAG,GAAG,CAAC,GAAqB,EAAE,EAAE;YACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF;;;WAGG;QACI,WAAM,GAAG,CAAC,GAAqB,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC;QAEF;;WAEG;QACI,UAAK,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;IA1CC;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B,CAAC;CAqCF;AA7CD,oCA6CC","sourcesContent":["/**\r\n * A generic implementation of the Observer pattern.\r\n * Maintains a list of observer functions that can be notified with a message.\r\n *\r\n * @typeParam T - The type of message that will be passed to observers\r\n */\r\nexport class ObserverList<T> {\r\n private observers: ((msg: T) => void)[] = [];\r\n\r\n /**\r\n * Gets the number of observers in the list\r\n */\r\n public get length(): number {\r\n return this.observers.length;\r\n }\r\n\r\n /**\r\n * Notifies all observers by calling them with the provided message\r\n * @param msg - The message to send to all observers\r\n */\r\n public notify = (msg: T) => {\r\n this.observers.forEach((obs) => {\r\n obs(msg);\r\n });\r\n };\r\n\r\n /**\r\n * Adds a new observer function to the list\r\n * @param obs - The observer function to add\r\n */\r\n public add = (obs: (msg: T) => void) => {\r\n this.observers.push(obs);\r\n };\r\n\r\n /**\r\n * Removes an observer from the list\r\n * @param obs - The observer function to remove\r\n */\r\n public remove = (obs: (msg: T) => void) => {\r\n const index = this.observers.indexOf(obs);\r\n if (index >= 0) {\r\n this.observers.splice(index, 1);\r\n }\r\n };\r\n\r\n /**\r\n * Removes all observers from the list\r\n */\r\n public clear = () => {\r\n this.observers = [];\r\n };\r\n}\r\n"]}
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.ExampleRepo = void 0;
22
22
  exports.makeExampleRepo = makeExampleRepo;
23
23
  const AppObject_1 = require("../../AppObject");
24
- const generateUniqueID_1 = require("../../Utilities/generateUniqueID");
25
24
  const ExampleEntity_1 = require("./ExampleEntity");
26
25
  /**
27
26
  * ExampleRepo manages a collection of ExampleEntity instances.
@@ -76,38 +75,27 @@ function makeExampleRepo(appObject) {
76
75
  * This private class handles the actual implementation details
77
76
  */
78
77
  class ExampleRepoImp extends ExampleRepo {
78
+ /**
79
+ * Factory implementation for creating ExampleEntity instances
80
+ * @param appObject The AppObject for the entity
81
+ * @returns A newly created ExampleEntity
82
+ */
83
+ entityFactory(appObject) {
84
+ return (0, ExampleEntity_1.makeExampleEntity)(appObject);
85
+ }
79
86
  /**
80
87
  * Deletes an ExampleEntity from the repository by its AppObject ID
81
88
  * @param id The ID of the entity's AppObject
82
89
  */
83
90
  deleteExampleEntity(id) {
84
- const entity = this.getForAppObject(id);
91
+ const entity = this.getById(id);
85
92
  if (!entity)
86
93
  return;
87
94
  entity.appObject.dispose();
88
- this.removeForAppObject(id);
95
+ this.removeById(id);
89
96
  }
90
97
  constructor(appObject) {
91
98
  super(appObject, ExampleRepo.type);
92
- /**
93
- * Creates a new ExampleEntity and adds it to the repository
94
- * @param id Optional ID for the entity's AppObject (generates one if not provided)
95
- * @returns The newly created ExampleEntity
96
- */
97
- this.createExampleEntity = (id) => {
98
- const idToUse = id ?? (0, generateUniqueID_1.generateUniqueID)();
99
- const entity = this.exampleEntityFactory(idToUse);
100
- this.add(entity);
101
- return entity;
102
- };
103
- /**
104
- * Default factory implementation for creating ExampleEntity instances
105
- * Can be overridden to create specialized entities
106
- */
107
- this.exampleEntityFactory = (id) => {
108
- const ao = this.appObjects.getOrCreate(id);
109
- return (0, ExampleEntity_1.makeExampleEntity)(ao);
110
- };
111
99
  }
112
100
  }
113
101
  //# sourceMappingURL=ExampleRepo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleRepo.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAwEH,0CAEC;AAxED,+CAIyB;AACzB,uEAAoE;AACpE,mDAAmE;AAKnE;;;GAGG;AACH,MAAsB,WAAY,SAAQ,+BAAkC;IAa1E;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAU,EACV,UAAyB;QAEzB,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAoB;QACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAc,WAAW,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;;AA/CH,kCAgDC;AA/CC,gDAAgD;AAChC,gBAAI,GAAG,iBAAiB,CAAC;AAgD3C;;;;GAIG;AACH,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,cAAe,SAAQ,WAAW;IAatC;;;OAGG;IACH,mBAAmB,CAAC,EAAU;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAWD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QAlCrC;;;;WAIG;QACH,wBAAmB,GAAG,CAAC,EAAsB,EAAiB,EAAE;YAC9D,MAAM,OAAO,GAAG,EAAE,IAAI,IAAA,mCAAgB,GAAE,CAAC;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAClD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjB,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAcF;;;WAGG;QACH,yBAAoB,GAAG,CAAC,EAAU,EAAiB,EAAE;YACnD,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAC3C,OAAO,IAAA,iCAAiB,EAAC,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC;IAIF,CAAC;CACF","sourcesContent":["/**\r\n * ExampleRepo.ts\r\n * \r\n * This file demonstrates how to implement a repository to manage collections of entities.\r\n * Repositories are responsible for creating, retrieving, and deleting entities.\r\n * \r\n * Key concepts:\r\n * - Repositories extend AppObjectEntityRepo<T> where T is the entity type\r\n * - They provide methods to create and delete entities\r\n * - They manage collections of entities and provide access to them\r\n * - They can use custom entity factories to create specialized entities\r\n * \r\n * Usage pattern:\r\n * 1. Get or create a repository using getById, get, or addIfMissing\r\n * 2. Use the repository to create new entities\r\n * 3. Access entities through the repository's getters\r\n * 4. Delete entities through the repository when they're no longer needed\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectEntityRepo,\r\n AppObjectRepo\r\n} from \"../../AppObject\";\r\nimport { generateUniqueID } from \"../../Utilities/generateUniqueID\";\r\nimport { ExampleEntity, makeExampleEntity } from \"./ExampleEntity\";\r\n\r\n/** Type definition for a factory function that creates ExampleEntity instances */\r\nexport type ExampleEntityFactory = (id: string) => ExampleEntity;\r\n\r\n/**\r\n * ExampleRepo manages a collection of ExampleEntity instances.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleRepoType\";\r\n\r\n /** Factory function used to create new entities */\r\n abstract exampleEntityFactory: ExampleEntityFactory;\r\n\r\n /** Creates a new entity with an optional ID */\r\n abstract createExampleEntity(id?: string): ExampleEntity;\r\n \r\n /** Deletes an entity by its AppObject ID */\r\n abstract deleteExampleEntity(id: string): void;\r\n\r\n /**\r\n * Retrieves an ExampleRepo component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static get(appObj: AppObject): ExampleRepo | undefined {\r\n return appObj.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an ExampleRepo by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): ExampleRepo | undefined {\r\n return appObjects.get(id)?.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Ensures an ExampleRepo exists on the AppObject, creating one if needed\r\n * @param appObject The AppObject to check/add the component to\r\n * @returns The existing or newly created ExampleRepo\r\n */\r\n static addIfMissing(appObject: AppObject): ExampleRepo {\r\n const existing = appObject.getComponent<ExampleRepo>(ExampleRepo.type);\r\n if (existing) {\r\n return existing;\r\n } else {\r\n return makeExampleRepo(appObject);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExampleRepo\r\n * @param appObject The AppObject to attach the repo to\r\n * @returns A new ExampleRepo instance\r\n */\r\nexport function makeExampleRepo(appObject: AppObject): ExampleRepo {\r\n return new ExampleRepoImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleRepo\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleRepoImp extends ExampleRepo {\r\n /**\r\n * Creates a new ExampleEntity and adds it to the repository\r\n * @param id Optional ID for the entity's AppObject (generates one if not provided)\r\n * @returns The newly created ExampleEntity\r\n */\r\n createExampleEntity = (id: string | undefined): ExampleEntity => {\r\n const idToUse = id ?? generateUniqueID();\r\n const entity = this.exampleEntityFactory(idToUse);\r\n this.add(entity);\r\n return entity;\r\n };\r\n\r\n /**\r\n * Deletes an ExampleEntity from the repository by its AppObject ID\r\n * @param id The ID of the entity's AppObject\r\n */\r\n deleteExampleEntity(id: string): void {\r\n const entity = this.getForAppObject(id);\r\n if (!entity) return;\r\n\r\n entity.appObject.dispose();\r\n this.removeForAppObject(id);\r\n }\r\n\r\n /**\r\n * Default factory implementation for creating ExampleEntity instances\r\n * Can be overridden to create specialized entities\r\n */\r\n exampleEntityFactory = (id: string): ExampleEntity => {\r\n const ao = this.appObjects.getOrCreate(id);\r\n return makeExampleEntity(ao);\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleRepo.type);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExampleRepo.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AA6DH,0CAEC;AA7DD,+CAAgF;AAChF,mDAAmE;AAKnE;;;GAGG;AACH,MAAsB,WAAY,SAAQ,+BAAkC;IAO1E;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAU,EACV,UAAyB;QAEzB,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAoB;QACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAc,WAAW,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;;AAzCH,kCA0CC;AAzCC,gDAAgD;AAChC,gBAAI,GAAG,iBAAiB,CAAC;AA0C3C;;;;GAIG;AACH,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,cAAe,SAAQ,WAAW;IACtC;;;;OAIG;IACH,aAAa,CAAC,SAAoB;QAChC,OAAO,IAAA,iCAAiB,EAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,EAAU;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACF","sourcesContent":["/**\r\n * ExampleRepo.ts\r\n *\r\n * This file demonstrates how to implement a repository to manage collections of entities.\r\n * Repositories are responsible for creating, retrieving, and deleting entities.\r\n *\r\n * Key concepts:\r\n * - Repositories extend AppObjectEntityRepo<T> where T is the entity type\r\n * - They provide methods to create and delete entities\r\n * - They manage collections of entities and provide access to them\r\n * - They can use custom entity factories to create specialized entities\r\n *\r\n * Usage pattern:\r\n * 1. Get or create a repository using getById, get, or addIfMissing\r\n * 2. Use the repository to create new entities\r\n * 3. Access entities through the repository's getters\r\n * 4. Delete entities through the repository when they're no longer needed\r\n */\r\n\r\nimport { AppObject, AppObjectEntityRepo, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity, makeExampleEntity } from \"./ExampleEntity\";\r\n\r\n/** Type definition for a factory function that creates ExampleEntity instances */\r\nexport type ExampleEntityFactory = (appObject: AppObject) => ExampleEntity;\r\n\r\n/**\r\n * ExampleRepo manages a collection of ExampleEntity instances.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleRepoType\";\r\n\r\n /** Deletes an entity by its AppObject ID */\r\n abstract deleteExampleEntity(id: string): void;\r\n\r\n /**\r\n * Retrieves an ExampleRepo component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static get(appObj: AppObject): ExampleRepo | undefined {\r\n return appObj.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an ExampleRepo by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): ExampleRepo | undefined {\r\n return appObjects.get(id)?.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Ensures an ExampleRepo exists on the AppObject, creating one if needed\r\n * @param appObject The AppObject to check/add the component to\r\n * @returns The existing or newly created ExampleRepo\r\n */\r\n static addIfMissing(appObject: AppObject): ExampleRepo {\r\n const existing = appObject.getComponent<ExampleRepo>(ExampleRepo.type);\r\n if (existing) {\r\n return existing;\r\n } else {\r\n return makeExampleRepo(appObject);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExampleRepo\r\n * @param appObject The AppObject to attach the repo to\r\n * @returns A new ExampleRepo instance\r\n */\r\nexport function makeExampleRepo(appObject: AppObject): ExampleRepo {\r\n return new ExampleRepoImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleRepo\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleRepoImp extends ExampleRepo {\r\n /**\r\n * Factory implementation for creating ExampleEntity instances\r\n * @param appObject The AppObject for the entity\r\n * @returns A newly created ExampleEntity\r\n */\r\n entityFactory(appObject: AppObject): ExampleEntity {\r\n return makeExampleEntity(appObject);\r\n }\r\n\r\n /**\r\n * Deletes an ExampleEntity from the repository by its AppObject ID\r\n * @param id The ID of the entity's AppObject\r\n */\r\n deleteExampleEntity(id: string): void {\r\n const entity = this.getById(id);\r\n if (!entity) return;\r\n\r\n entity.appObject.dispose();\r\n this.removeById(id);\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleRepo.type);\r\n }\r\n}\r\n"]}
@@ -27,7 +27,7 @@ const MemoizedBoolean_1 = require("../../Entities/MemoizedBoolean");
27
27
  * SingletonEntityExample represents a global entity with a boolean property.
28
28
  * As a singleton, only one instance exists in the application.
29
29
  */
30
- class SingletonEntityExample extends AppObject_1.AppObjectEntity {
30
+ class SingletonEntityExample extends AppObject_1.AppObjectSingletonEntity {
31
31
  }
32
32
  exports.SingletonEntityExample = SingletonEntityExample;
33
33
  /** Unique type identifier for this component */
@@ -62,8 +62,6 @@ class SingletonEntityExampleImp extends SingletonEntityExample {
62
62
  super(appObject, SingletonEntityExample.type);
63
63
  // MemoizedBoolean tracks changes to the boolean value and calls notifyOnChange when updated
64
64
  this.memoizedIsAuthoring = new MemoizedBoolean_1.MemoizedBoolean(false, this.notifyOnChange);
65
- // Register this entity as a singleton so it can be accessed globally
66
- this.appObjects.registerSingleton(this);
67
65
  }
68
66
  }
69
67
  //# sourceMappingURL=ExampleSingletonEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleSingletonEntity.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleSingletonEntity.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAsCH,gEAIC;AAxCD,+CAIyB;AACzB,iFAA8E;AAC9E,oEAAiE;AAEjE;;;GAGG;AACH,MAAsB,sBAAuB,SAAQ,2BAAe;;AAApE,wDAiBC;AAhBC,gDAAgD;AAChC,2BAAI,GAAG,4BAA4B,CAAC;AAMpD;;;;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;IAI5D,iDAAiD;IACjD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;IACtC,CAAC;IAED,IAAI,aAAa,CAAC,GAAY;QAC5B,IAAI,CAAC,mBAAmB,CAAC,GAAG,GAAG,GAAG,CAAC;IACrC,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAbhD,4FAA4F;QACpF,wBAAmB,GAAG,IAAI,iCAAe,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAa5E,qEAAqE;QACrE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonEntity.ts\r\n * \r\n * This file demonstrates how to implement a singleton entity in the application.\r\n * Singleton entities are special entities that exist only once in the application\r\n * and can be accessed globally from anywhere.\r\n * \r\n * Key concepts:\r\n * - Singleton entities extend AppObjectEntity like regular entities\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - There's only one instance of a singleton entity in the entire application\r\n * \r\n * Usage pattern:\r\n * 1. Access the singleton entity using the static get() method\r\n * 2. Access or modify properties via getters/setters\r\n * 3. Register change observers to react to property updates\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectEntity,\r\n AppObjectRepo\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { MemoizedBoolean } from \"../../Entities/MemoizedBoolean\";\r\n\r\n/**\r\n * SingletonEntityExample represents a global entity with a boolean property.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class SingletonEntityExample extends AppObjectEntity {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"SingletonEntityExampleType\";\r\n\r\n /** Boolean property accessor methods that must be implemented */\r\n abstract get aBoolProperty(): boolean;\r\n abstract set aBoolProperty(val: boolean);\r\n\r\n /**\r\n * Global accessor for the singleton entity\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton entity or undefined if not created yet\r\n */\r\n static get = (\r\n appObjects: AppObjectRepo\r\n ): SingletonEntityExample | undefined =>\r\n getSingletonComponent(SingletonEntityExample.type, appObjects);\r\n}\r\n\r\n/**\r\n * Factory function to create a new SingletonEntityExample\r\n * @param appObject The AppObject to attach the entity to\r\n * @returns A new SingletonEntityExample instance\r\n */\r\nexport function makeSingletonEntityExample(\r\n appObject: AppObject\r\n): SingletonEntityExample {\r\n return new SingletonEntityExampleImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of SingletonEntityExample\r\n * This private class handles the actual implementation details\r\n */\r\nclass SingletonEntityExampleImp extends SingletonEntityExample {\r\n // MemoizedBoolean tracks changes to the boolean value and calls notifyOnChange when updated\r\n private memoizedIsAuthoring = new MemoizedBoolean(false, this.notifyOnChange);\r\n \r\n // Property accessors that use the memoized value\r\n get aBoolProperty() {\r\n return this.memoizedIsAuthoring.val;\r\n }\r\n \r\n set aBoolProperty(val: boolean) {\r\n this.memoizedIsAuthoring.val = val;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, SingletonEntityExample.type);\r\n // Register this entity as a singleton so it can be accessed globally\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExampleSingletonEntity.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleSingletonEntity.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAsCH,gEAIC;AAxCD,+CAIyB;AACzB,iFAA8E;AAC9E,oEAAiE;AAEjE;;;GAGG;AACH,MAAsB,sBAAuB,SAAQ,oCAAwB;;AAA7E,wDAiBC;AAhBC,gDAAgD;AAChC,2BAAI,GAAG,4BAA4B,CAAC;AAMpD;;;;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;IAI5D,iDAAiD;IACjD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;IACtC,CAAC;IAED,IAAI,aAAa,CAAC,GAAY;QAC5B,IAAI,CAAC,mBAAmB,CAAC,GAAG,GAAG,GAAG,CAAC;IACrC,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAbhD,4FAA4F;QACpF,wBAAmB,GAAG,IAAI,iCAAe,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAa9E,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonEntity.ts\r\n *\r\n * This file demonstrates how to implement a singleton entity in the application.\r\n * Singleton entities are special entities that exist only once in the application\r\n * and can be accessed globally from anywhere.\r\n *\r\n * Key concepts:\r\n * - Singleton entities extend AppObjectEntity like regular entities\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - There's only one instance of a singleton entity in the entire application\r\n *\r\n * Usage pattern:\r\n * 1. Access the singleton entity using the static get() method\r\n * 2. Access or modify properties via getters/setters\r\n * 3. Register change observers to react to property updates\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectSingletonEntity,\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { MemoizedBoolean } from \"../../Entities/MemoizedBoolean\";\r\n\r\n/**\r\n * SingletonEntityExample represents a global entity with a boolean property.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class SingletonEntityExample extends AppObjectSingletonEntity {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"SingletonEntityExampleType\";\r\n\r\n /** Boolean property accessor methods that must be implemented */\r\n abstract get aBoolProperty(): boolean;\r\n abstract set aBoolProperty(val: boolean);\r\n\r\n /**\r\n * Global accessor for the singleton entity\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton entity or undefined if not created yet\r\n */\r\n static get = (\r\n appObjects: AppObjectRepo\r\n ): SingletonEntityExample | undefined =>\r\n getSingletonComponent(SingletonEntityExample.type, appObjects);\r\n}\r\n\r\n/**\r\n * Factory function to create a new SingletonEntityExample\r\n * @param appObject The AppObject to attach the entity to\r\n * @returns A new SingletonEntityExample instance\r\n */\r\nexport function makeSingletonEntityExample(\r\n appObject: AppObject\r\n): SingletonEntityExample {\r\n return new SingletonEntityExampleImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of SingletonEntityExample\r\n * This private class handles the actual implementation details\r\n */\r\nclass SingletonEntityExampleImp extends SingletonEntityExample {\r\n // MemoizedBoolean tracks changes to the boolean value and calls notifyOnChange when updated\r\n private memoizedIsAuthoring = new MemoizedBoolean(false, this.notifyOnChange);\r\n\r\n // Property accessors that use the memoized value\r\n get aBoolProperty() {\r\n return this.memoizedIsAuthoring.val;\r\n }\r\n\r\n set aBoolProperty(val: boolean) {\r\n this.memoizedIsAuthoring.val = val;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, SingletonEntityExample.type);\r\n }\r\n}\r\n"]}
@@ -59,7 +59,7 @@ class ExampleFeatureFactory extends DomainFactories_1.DomainFactory {
59
59
  }
60
60
  exports.ExampleFeatureFactory = ExampleFeatureFactory;
61
61
  function makeExampleFeatureFactory(appObjects) {
62
- const appObject = appObjects.getOrCreate("ExampleFeatureFactory");
62
+ const appObject = appObjects.getOrCreate("FeatureName");
63
63
  return new ExampleFeatureFactory(appObject);
64
64
  }
65
65
  //# sourceMappingURL=ExampleFeatureFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleFeatureFactory.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Factory/ExampleFeatureFactory.ts"],"names":[],"mappings":";;;AAgEA,8DAGC;AAlED,2DAAsD;AACtD,+EAAgF;AAChF,kEAAmE;AACnE,0EAA2E;AAE3E;;;;;;;;GAQG;AACH,MAAa,qBAAsB,SAAQ,+BAAa;IAAxD;;QAEC,gBAAW,GAAG,uBAAuB,CAAC;IA6CvC,CAAC;IA3CA;;;;;OAKG;IACH,aAAa;QAEZ,IAAA,mDAA0B,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QAEP,IAAA,mDAA0B,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QAEP,IAAA,2CAAsB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,UAAU;QAET,gDAAgD;IACjD,CAAC;CACD;AA/CD,sDA+CC;AAED,SAAgB,yBAAyB,CAAC,UAAyB;IAClE,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAClE,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { AppObjectRepo } from \"../../AppObject\";\r\nimport { DomainFactory } from \"../../DomainFactories\";\r\nimport { makeSingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\nimport { makeExampleSingletonPM } from \"../PMs/ExampleSingletonPM\";\r\nimport { makeToggleExampleBooleanUC } from \"../UCs/ToggleExampleBooleanUC\";\r\n\r\n/**\r\n * Factory responsible for setting up the Example Feature domain components.\r\n * \r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Example Feature functionality. It follows the domain-driven\r\n * design pattern by organizing components into their respective layers.\r\n * \r\n * @extends DomainFactory\r\n */\r\nexport class ExampleFeatureFactory extends DomainFactory\r\n{\r\n\tfactoryName = \"ExampleFeatureFactory\";\r\n\r\n\t/**\r\n\t * Sets up all entities required for the Example Feature.\r\n\t * \r\n\t * Initializes singleton entities that maintain the state and business\r\n\t * logic for the example feature functionality.\r\n\t */\r\n\tsetupEntities(): void\r\n\t{\r\n\t\tmakeSingletonEntityExample(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up all use cases for the Example Feature.\r\n\t * \r\n\t * Initializes use cases that define the business operations and\r\n\t * workflows available in the example feature.\r\n\t */\r\n\tsetupUCs(): void\r\n\t{\r\n\t\tmakeToggleExampleBooleanUC(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up all presentation models for the Example Feature.\r\n\t * \r\n\t * Initializes presentation models that handle the view logic and\r\n\t * state management for UI components related to the example feature.\r\n\t */\r\n\tsetupPMs(): void\r\n\t{\r\n\t\tmakeExampleSingletonPM(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Performs any final setup operations after all components are initialized.\r\n\t * \r\n\t * This method is called after entities, use cases, and presentation models\r\n\t * have been set up. Currently no additional setup is required for this feature.\r\n\t */\r\n\tfinalSetup(): void\r\n\t{\r\n\t\t// No additional setup required for this feature\r\n\t}\r\n}\r\n\r\nexport function makeExampleFeatureFactory(appObjects: AppObjectRepo):ExampleFeatureFactory {\r\n\tconst appObject = appObjects.getOrCreate(\"ExampleFeatureFactory\");\r\n\treturn new ExampleFeatureFactory(appObject);\r\n}"]}
1
+ {"version":3,"file":"ExampleFeatureFactory.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Factory/ExampleFeatureFactory.ts"],"names":[],"mappings":";;;AAgEA,8DAGC;AAlED,2DAAsD;AACtD,+EAAgF;AAChF,kEAAmE;AACnE,0EAA2E;AAE3E;;;;;;;;GAQG;AACH,MAAa,qBAAsB,SAAQ,+BAAa;IAAxD;;QAEC,gBAAW,GAAG,uBAAuB,CAAC;IA6CvC,CAAC;IA3CA;;;;;OAKG;IACH,aAAa;QAEZ,IAAA,mDAA0B,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QAEP,IAAA,mDAA0B,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QAEP,IAAA,2CAAsB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,UAAU;QAET,gDAAgD;IACjD,CAAC;CACD;AA/CD,sDA+CC;AAED,SAAgB,yBAAyB,CAAC,UAAyB;IAClE,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IACxD,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { AppObjectRepo } from \"../../AppObject\";\r\nimport { DomainFactory } from \"../../DomainFactories\";\r\nimport { makeSingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\nimport { makeExampleSingletonPM } from \"../PMs/ExampleSingletonPM\";\r\nimport { makeToggleExampleBooleanUC } from \"../UCs/ToggleExampleBooleanUC\";\r\n\r\n/**\r\n * Factory responsible for setting up the Example Feature domain components.\r\n * \r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Example Feature functionality. It follows the domain-driven\r\n * design pattern by organizing components into their respective layers.\r\n * \r\n * @extends DomainFactory\r\n */\r\nexport class ExampleFeatureFactory extends DomainFactory\r\n{\r\n\tfactoryName = \"ExampleFeatureFactory\";\r\n\r\n\t/**\r\n\t * Sets up all entities required for the Example Feature.\r\n\t * \r\n\t * Initializes singleton entities that maintain the state and business\r\n\t * logic for the example feature functionality.\r\n\t */\r\n\tsetupEntities(): void\r\n\t{\r\n\t\tmakeSingletonEntityExample(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up all use cases for the Example Feature.\r\n\t * \r\n\t * Initializes use cases that define the business operations and\r\n\t * workflows available in the example feature.\r\n\t */\r\n\tsetupUCs(): void\r\n\t{\r\n\t\tmakeToggleExampleBooleanUC(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up all presentation models for the Example Feature.\r\n\t * \r\n\t * Initializes presentation models that handle the view logic and\r\n\t * state management for UI components related to the example feature.\r\n\t */\r\n\tsetupPMs(): void\r\n\t{\r\n\t\tmakeExampleSingletonPM(this.appObject);\r\n\t}\r\n\r\n\t/**\r\n\t * Performs any final setup operations after all components are initialized.\r\n\t * \r\n\t * This method is called after entities, use cases, and presentation models\r\n\t * have been set up. Currently no additional setup is required for this feature.\r\n\t */\r\n\tfinalSetup(): void\r\n\t{\r\n\t\t// No additional setup required for this feature\r\n\t}\r\n}\r\n\r\nexport function makeExampleFeatureFactory(appObjects: AppObjectRepo):ExampleFeatureFactory {\r\n\tconst appObject = appObjects.getOrCreate(\"FeatureName\");\r\n\treturn new ExampleFeatureFactory(appObject);\r\n}"]}
@@ -70,28 +70,20 @@ class ExamplePMImp extends ExamplePM {
70
70
  }
71
71
  constructor(appObject) {
72
72
  super(appObject, ExamplePM.type);
73
+ /** Default view model before any entity data is available */
74
+ this.defaultVM = "";
73
75
  /**
74
76
  * Handler for entity change events
75
77
  * Transforms entity data into a view model and updates views
76
78
  */
77
- this.onEntityChange = () => {
78
- if (!this.exampleEntity)
79
- return;
79
+ this.formVM = () => {
80
80
  // In this simple case, our view model is just the string property value
81
81
  this.doUpdateView(this.exampleEntity.aStringProperty);
82
82
  };
83
- /**
84
- * Cleanup method called when the PM is being disposed
85
- * Removes any observers to prevent memory leaks
86
- */
87
- this.dispose = () => {
88
- super.dispose();
89
- this.exampleEntity?.removeChangeObserver(this.onEntityChange);
90
- };
91
83
  // Register as an observer of the entity to receive change notifications
92
- this.exampleEntity?.addChangeObserver(this.onEntityChange);
84
+ this.observeEntity(this.exampleEntity);
93
85
  // Call the change handler initially to set up the initial view model
94
- this.onEntityChange();
86
+ this.formVM();
95
87
  }
96
88
  }
97
89
  //# sourceMappingURL=ExamplePM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExamplePM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExamplePM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA6BH,sCAEC;AA7BD,+CAAwE;AACxE,6DAA0D;AAE1D;;;GAGG;AACH,MAAsB,SAAU,SAAQ,uBAAmB;IAIzD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,EAAU,EAAE,UAAyB;QAClD,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAY,SAAS,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;;AAZH,8BAaC;AAZC,gDAAgD;AAChC,cAAI,GAAG,eAAe,CAAC;AAazC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,SAAoB;IAChD,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,YAAa,SAAQ,SAAS;IAClC;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAgB,6BAAa,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,CAAS,EAAE,CAAS;QAC9B,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAsBD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QArBnC;;;WAGG;QACH,mBAAc,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,aAAa;gBAAE,OAAO;YAEhC,wEAAwE;YACxE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC;QAEF;;;WAGG;QACH,YAAO,GAAG,GAAS,EAAE;YACnB,KAAK,CAAC,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAChE,CAAC,CAAC;QAKA,wEAAwE;QACxE,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3D,qEAAqE;QACrE,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF","sourcesContent":["/**\r\n * ExamplePM.ts\r\n * \r\n * This file demonstrates how to implement a Presentation Manager (PM) component.\r\n * PMs are responsible for transforming entity data into view models (VMs) for the UI.\r\n * They observe entities for changes and update their views when data changes.\r\n * \r\n * Key concepts:\r\n * - PMs extend AppObjectPM<VM> where VM is the view model type\r\n * - They observe entities and transform entity data into view models\r\n * - They notify UI components (views) when view models change\r\n * - Each PM instance is associated with a specific AppObject\r\n * \r\n * Usage pattern:\r\n * 1. Get a PM instance using getById\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport { AppObject, AppObjectPM, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity } from \"../Entities/ExampleEntity\";\r\n\r\n/**\r\n * ExamplePM transforms ExampleEntity data into a simple string view model.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExamplePM extends AppObjectPM<string> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExamplePMType\";\r\n\r\n /**\r\n * Retrieves an ExamplePM by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExamplePM component or undefined if not found\r\n */\r\n static getById(id: string, appObjects: AppObjectRepo) {\r\n return appObjects.get(id)?.getComponent<ExamplePM>(ExamplePM.type);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExamplePM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExamplePM instance\r\n */\r\nexport function makeExamplePM(appObject: AppObject): ExamplePM {\r\n return new ExamplePMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExamplePM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExamplePMImp extends ExamplePM {\r\n /**\r\n * Gets the ExampleEntity from the same AppObject\r\n * Uses getCachedLocalComponent for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedLocalComponent<ExampleEntity>(ExampleEntity.type);\r\n }\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: string, b: string): boolean {\r\n return a === b;\r\n }\r\n\r\n /**\r\n * Handler for entity change events\r\n * Transforms entity data into a view model and updates views\r\n */\r\n onEntityChange = () => {\r\n if (!this.exampleEntity) return;\r\n\r\n // In this simple case, our view model is just the string property value\r\n this.doUpdateView(this.exampleEntity.aStringProperty);\r\n };\r\n\r\n /**\r\n * Cleanup method called when the PM is being disposed\r\n * Removes any observers to prevent memory leaks\r\n */\r\n dispose = (): void => {\r\n super.dispose();\r\n this.exampleEntity?.removeChangeObserver(this.onEntityChange);\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExamplePM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.exampleEntity?.addChangeObserver(this.onEntityChange);\r\n \r\n // Call the change handler initially to set up the initial view model\r\n this.onEntityChange();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExamplePM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExamplePM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA6BH,sCAEC;AA7BD,+CAAwE;AACxE,6DAA0D;AAE1D;;;GAGG;AACH,MAAsB,SAAU,SAAQ,uBAAmB;IAIzD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,EAAU,EAAE,UAAyB;QAClD,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAY,SAAS,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;;AAZH,8BAaC;AAZC,gDAAgD;AAChC,cAAI,GAAG,eAAe,CAAC;AAazC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,SAAoB;IAChD,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,YAAa,SAAQ,SAAS;IAIlC;;;OAGG;IACH,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAgB,6BAAa,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,CAAS,EAAE,CAAS;QAC9B,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAYD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QA9BnC,6DAA6D;QACpD,cAAS,GAAG,EAAE,CAAC;QAkBxB;;;WAGG;QACH,WAAM,GAAG,GAAG,EAAE;YACZ,wEAAwE;YACxE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC;QAMA,wEAAwE;QACxE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvC,qEAAqE;QACrE,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF","sourcesContent":["/**\r\n * ExamplePM.ts\r\n *\r\n * This file demonstrates how to implement a Presentation Manager (PM) component.\r\n * PMs are responsible for transforming entity data into view models (VMs) for the UI.\r\n * They observe entities for changes and update their views when data changes.\r\n *\r\n * Key concepts:\r\n * - PMs extend AppObjectPM<VM> where VM is the view model type\r\n * - They observe entities and transform entity data into view models\r\n * - They notify UI components (views) when view models change\r\n * - Each PM instance is associated with a specific AppObject\r\n *\r\n * Usage pattern:\r\n * 1. Get a PM instance using getById\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport { AppObject, AppObjectPM, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity } from \"../Entities/ExampleEntity\";\r\n\r\n/**\r\n * ExamplePM transforms ExampleEntity data into a simple string view model.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExamplePM extends AppObjectPM<string> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExamplePMType\";\r\n\r\n /**\r\n * Retrieves an ExamplePM by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExamplePM component or undefined if not found\r\n */\r\n static getById(id: string, appObjects: AppObjectRepo) {\r\n return appObjects.get(id)?.getComponent<ExamplePM>(ExamplePM.type);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExamplePM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExamplePM instance\r\n */\r\nexport function makeExamplePM(appObject: AppObject): ExamplePM {\r\n return new ExamplePMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExamplePM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExamplePMImp extends ExamplePM {\r\n /** Default view model before any entity data is available */\r\n readonly defaultVM = \"\";\r\n\r\n /**\r\n * Gets the ExampleEntity from the same AppObject\r\n * Uses getCachedLocalComponent for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedLocalComponent<ExampleEntity>(ExampleEntity.type);\r\n }\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: string, b: string): boolean {\r\n return a === b;\r\n }\r\n\r\n /**\r\n * Handler for entity change events\r\n * Transforms entity data into a view model and updates views\r\n */\r\n formVM = () => {\r\n // In this simple case, our view model is just the string property value\r\n this.doUpdateView(this.exampleEntity.aStringProperty);\r\n };\r\n\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExamplePM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.observeEntity(this.exampleEntity);\r\n\r\n // Call the change handler initially to set up the initial view model\r\n this.formVM();\r\n }\r\n}\r\n"]}
@@ -7,10 +7,10 @@
7
7
  * accessed globally. They transform data from singleton entities into view models.
8
8
  *
9
9
  * Key concepts:
10
- * - Singleton PMs extend AppObjectPM<VM> like regular PMs
11
- * - They register themselves as singletons with appObjects.registerSingleton()
10
+ * - Singleton PMs extend AppObjectSingletonPM<VM> which handles singleton registration automatically
12
11
  * - They're accessed through a static get() method using getSingletonComponent()
13
12
  * - They typically observe singleton entities and provide data to multiple UI components
13
+ * - They use formVM() to transform entity data into view models
14
14
  *
15
15
  * Usage pattern:
16
16
  * 1. Access the singleton PM using the static get() method
@@ -28,7 +28,7 @@ const ExampleSingletonEntity_1 = require("../Entities/ExampleSingletonEntity");
28
28
  * ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.
29
29
  * As a singleton, only one instance exists in the application.
30
30
  */
31
- class ExampleSingletonPM extends AppObject_1.AppObjectPM {
31
+ class ExampleSingletonPM extends AppObject_1.AppObjectSingletonPM {
32
32
  }
33
33
  exports.ExampleSingletonPM = ExampleSingletonPM;
34
34
  /** Unique type identifier for this component */
@@ -44,7 +44,7 @@ ExampleSingletonPM.get = (appObjects) => (0, getSingletonComponent_1.getSingleto
44
44
  * UI components can use this initially or when the PM is not found
45
45
  */
46
46
  exports.defaultSlideNavigationVM = {
47
- aBoolProperty: true
47
+ aBoolProperty: true,
48
48
  };
49
49
  /**
50
50
  * Factory function to create a new ExampleSingletonPM
@@ -78,12 +78,10 @@ class ExampleSingletonPMImp extends ExampleSingletonPM {
78
78
  constructor(appObject) {
79
79
  super(appObject, ExampleSingletonPM.type);
80
80
  /**
81
- * Handler for entity change events
82
81
  * Transforms entity data into a view model and updates views
82
+ * Called automatically when observed entities change
83
83
  */
84
- this.onEntityChange = () => {
85
- if (!this.exampleEntity)
86
- return;
84
+ this.formVM = () => {
87
85
  // Extract the boolean property from the entity
88
86
  const aBoolProperty = this.exampleEntity.aBoolProperty;
89
87
  // Create a view model with the extracted data
@@ -92,11 +90,9 @@ class ExampleSingletonPMImp extends ExampleSingletonPM {
92
90
  this.doUpdateView(vm);
93
91
  };
94
92
  // Register as an observer of the entity to receive change notifications
95
- this.exampleEntity?.addChangeObserver(this.onEntityChange);
93
+ this.observeEntity(this.exampleEntity);
96
94
  // Call the change handler initially to set up the initial view model
97
- this.onEntityChange();
98
- // Register this PM as a singleton so it can be accessed globally
99
- this.appObjects.registerSingleton(this);
95
+ this.formVM();
100
96
  }
101
97
  }
102
98
  //# sourceMappingURL=ExampleSingletonPM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleSingletonPM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExampleSingletonPM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA+CH,wDAIC;AAjDD,+CAIyB;AACzB,iFAA8E;AAC9E,+EAA4E;AAS5E;;;GAGG;AACH,MAAsB,kBAAmB,SAAQ,uBAAsB;;AAAvE,gDAWC;AAVC,gDAAgD;AAChC,uBAAI,GAAG,wBAAwB,CAAC;AAEhD;;;;GAIG;AACI,sBAAG,GAAG,CAAC,UAAyB,EAAkC,EAAE,CACzE,IAAA,6CAAqB,EAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAG/D;;;GAGG;AACU,QAAA,wBAAwB,GAAc;IACjD,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF;;;;GAIG;AACH,SAAgB,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,+CAAsB,CAAC,IAAI,CAC5B,CAAC;IACJ,CAAC;IAmBD;;;OAGG;IACH,WAAW,CAAC,CAAY,EAAE,CAAY;QACpC,IAAI,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;QA3B5C;;;WAGG;QACH,mBAAc,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,aAAa;gBAAE,OAAO;YAEhC,+CAA+C;YAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;YAEvD,8CAA8C;YAC9C,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YAE7B,sDAAsD;YACtD,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC;QAcA,wEAAwE;QACxE,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3D,qEAAqE;QACrE,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,iEAAiE;QACjE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonPM.ts\r\n * \r\n * This file demonstrates how to implement a Singleton Presentation Manager (PM).\r\n * Singleton PMs are special PMs that exist only once in the application and can be\r\n * accessed globally. They transform data from singleton entities into view models.\r\n * \r\n * Key concepts:\r\n * - Singleton PMs extend AppObjectPM<VM> like regular PMs\r\n * - They register themselves as singletons with appObjects.registerSingleton()\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - They typically observe singleton entities and provide data to multiple UI components\r\n * \r\n * Usage pattern:\r\n * 1. Access the singleton PM using the static get() method\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectPM,\r\n AppObjectRepo,\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { SingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\n\r\n/**\r\n * Interface defining the structure of the view model provided by ExampleSingletonPM\r\n */\r\nexport interface ExampleVM {\r\n aBoolProperty: boolean;\r\n}\r\n\r\n/**\r\n * ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class ExampleSingletonPM extends AppObjectPM<ExampleVM> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleSingletonPMType\";\r\n\r\n /**\r\n * Global accessor for the singleton PM\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton PM or undefined if not created yet\r\n */\r\n static get = (appObjects: AppObjectRepo): ExampleSingletonPM | undefined =>\r\n getSingletonComponent(ExampleSingletonPM.type, appObjects);\r\n}\r\n\r\n/**\r\n * Default view model used when no data is available\r\n * UI components can use this initially or when the PM is not found\r\n */\r\nexport const defaultSlideNavigationVM: ExampleVM = {\r\n aBoolProperty: true\r\n};\r\n\r\n/**\r\n * Factory function to create a new ExampleSingletonPM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExampleSingletonPM instance\r\n */\r\nexport function makeExampleSingletonPM(\r\n appObject: AppObject\r\n): ExampleSingletonPM {\r\n return new ExampleSingletonPMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleSingletonPM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleSingletonPMImp extends ExampleSingletonPM {\r\n /**\r\n * Gets the SingletonEntityExample from the application\r\n * Uses getCachedSingleton for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedSingleton<SingletonEntityExample>(\r\n SingletonEntityExample.type\r\n );\r\n }\r\n\r\n /**\r\n * Handler for entity change events\r\n * Transforms entity data into a view model and updates views\r\n */\r\n onEntityChange = () => {\r\n if (!this.exampleEntity) return;\r\n\r\n // Extract the boolean property from the entity\r\n const aBoolProperty = this.exampleEntity.aBoolProperty;\r\n\r\n // Create a view model with the extracted data\r\n const vm = { aBoolProperty };\r\n\r\n // Update all registered views with the new view model\r\n this.doUpdateView(vm);\r\n };\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: ExampleVM, b: ExampleVM): boolean {\r\n if (a.aBoolProperty !== b.aBoolProperty) return false;\r\n return true;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleSingletonPM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.exampleEntity?.addChangeObserver(this.onEntityChange);\r\n \r\n // Call the change handler initially to set up the initial view model\r\n this.onEntityChange();\r\n \r\n // Register this PM as a singleton so it can be accessed globally\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExampleSingletonPM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/ExampleSingletonPM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA+CH,wDAIC;AAjDD,+CAIyB;AACzB,iFAA8E;AAC9E,+EAA4E;AAS5E;;;GAGG;AACH,MAAsB,kBAAmB,SAAQ,gCAA+B;;AAAhF,gDAWC;AAVC,gDAAgD;AAChC,uBAAI,GAAG,wBAAwB,CAAC;AAEhD;;;;GAIG;AACI,sBAAG,GAAG,CAAC,UAAyB,EAAkC,EAAE,CACzE,IAAA,6CAAqB,EAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAG/D;;;GAGG;AACU,QAAA,wBAAwB,GAAc;IACjD,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF;;;;GAIG;AACH,SAAgB,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,+CAAsB,CAAC,IAAI,CAC5B,CAAC;IACJ,CAAC;IAiBD;;;OAGG;IACH,WAAW,CAAC,CAAY,EAAE,CAAY;QACpC,IAAI,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAzB5C;;;WAGG;QACH,WAAM,GAAG,GAAG,EAAE;YACZ,+CAA+C;YAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;YAEvD,8CAA8C;YAC9C,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YAE7B,sDAAsD;YACtD,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC;QAcA,wEAAwE;QACxE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvC,qEAAqE;QACrE,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF","sourcesContent":["/**\r\n * ExampleSingletonPM.ts\r\n *\r\n * This file demonstrates how to implement a Singleton Presentation Manager (PM).\r\n * Singleton PMs are special PMs that exist only once in the application and can be\r\n * accessed globally. They transform data from singleton entities into view models.\r\n *\r\n * Key concepts:\r\n * - Singleton PMs extend AppObjectSingletonPM<VM> which handles singleton registration automatically\r\n * - They're accessed through a static get() method using getSingletonComponent()\r\n * - They typically observe singleton entities and provide data to multiple UI components\r\n * - They use formVM() to transform entity data into view models\r\n *\r\n * Usage pattern:\r\n * 1. Access the singleton PM using the static get() method\r\n * 2. Register UI components as views using addView(callback)\r\n * 3. PM will call the view callbacks with updated view models when entities change\r\n * 4. Remove UI components with removeView(callback) when they're unmounted\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectSingletonPM,\r\n} from \"../../AppObject\";\r\nimport { getSingletonComponent } from \"../../AppObject/getSingletonComponent\";\r\nimport { SingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\n\r\n/**\r\n * Interface defining the structure of the view model provided by ExampleSingletonPM\r\n */\r\nexport interface ExampleVM {\r\n aBoolProperty: boolean;\r\n}\r\n\r\n/**\r\n * ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.\r\n * As a singleton, only one instance exists in the application.\r\n */\r\nexport abstract class ExampleSingletonPM extends AppObjectSingletonPM<ExampleVM> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleSingletonPMType\";\r\n\r\n /**\r\n * Global accessor for the singleton PM\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton PM or undefined if not created yet\r\n */\r\n static get = (appObjects: AppObjectRepo): ExampleSingletonPM | undefined =>\r\n getSingletonComponent(ExampleSingletonPM.type, appObjects);\r\n}\r\n\r\n/**\r\n * Default view model used when no data is available\r\n * UI components can use this initially or when the PM is not found\r\n */\r\nexport const defaultSlideNavigationVM: ExampleVM = {\r\n aBoolProperty: true,\r\n};\r\n\r\n/**\r\n * Factory function to create a new ExampleSingletonPM\r\n * @param appObject The AppObject to attach the PM to\r\n * @returns A new ExampleSingletonPM instance\r\n */\r\nexport function makeExampleSingletonPM(\r\n appObject: AppObject\r\n): ExampleSingletonPM {\r\n return new ExampleSingletonPMImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleSingletonPM\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleSingletonPMImp extends ExampleSingletonPM {\r\n /**\r\n * Gets the SingletonEntityExample from the application\r\n * Uses getCachedSingleton for efficient repeated access\r\n */\r\n private get exampleEntity() {\r\n return this.getCachedSingleton<SingletonEntityExample>(\r\n SingletonEntityExample.type\r\n );\r\n }\r\n\r\n /**\r\n * Transforms entity data into a view model and updates views\r\n * Called automatically when observed entities change\r\n */\r\n formVM = () => {\r\n // Extract the boolean property from the entity\r\n const aBoolProperty = this.exampleEntity.aBoolProperty;\r\n\r\n // Create a view model with the extracted data\r\n const vm = { aBoolProperty };\r\n\r\n // Update all registered views with the new view model\r\n this.doUpdateView(vm);\r\n };\r\n\r\n /**\r\n * Compares two view models to determine if they're equal\r\n * Used to avoid unnecessary view updates when values haven't changed\r\n */\r\n vmsAreEqual(a: ExampleVM, b: ExampleVM): boolean {\r\n if (a.aBoolProperty !== b.aBoolProperty) return false;\r\n return true;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleSingletonPM.type);\r\n\r\n // Register as an observer of the entity to receive change notifications\r\n this.observeEntity(this.exampleEntity);\r\n\r\n // Call the change handler initially to set up the initial view model\r\n this.formVM();\r\n }\r\n}\r\n"]}