@vived/core 1.5.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +1 -48
  2. package/dist/cjs/AppObject/AppObjectComponent.js +8 -10
  3. package/dist/cjs/AppObject/AppObjectComponent.js.map +1 -1
  4. package/dist/cjs/AppObject/AppObjectEntityRepo.js +99 -11
  5. package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +1 -1
  6. package/dist/cjs/AppObject/AppObjectPM.js +106 -6
  7. package/dist/cjs/AppObject/AppObjectPM.js.map +1 -1
  8. package/dist/cjs/AppObject/AppObjectRepo.js +11 -1
  9. package/dist/cjs/AppObject/AppObjectRepo.js.map +1 -1
  10. package/dist/cjs/AppObject/AppObjectSingletonEntity.js +40 -0
  11. package/dist/cjs/AppObject/AppObjectSingletonEntity.js.map +1 -0
  12. package/dist/cjs/AppObject/AppObjectSingletonEntityRepo.js +54 -0
  13. package/dist/cjs/AppObject/AppObjectSingletonEntityRepo.js.map +1 -0
  14. package/dist/cjs/AppObject/AppObjectSingletonPM.js +69 -0
  15. package/dist/cjs/AppObject/AppObjectSingletonPM.js.map +1 -0
  16. package/dist/cjs/AppObject/AppObjectSingletonUC.js +60 -0
  17. package/dist/cjs/AppObject/AppObjectSingletonUC.js.map +1 -0
  18. package/dist/cjs/AppObject/index.js +4 -0
  19. package/dist/cjs/AppObject/index.js.map +1 -1
  20. package/dist/cjs/DomainFactories/Entities/DomainFactoryRepo.js +5 -0
  21. package/dist/cjs/DomainFactories/Entities/DomainFactoryRepo.js.map +1 -1
  22. package/dist/cjs/Entities/ObserverList.js +6 -0
  23. package/dist/cjs/Entities/ObserverList.js.map +1 -1
  24. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js +11 -22
  25. package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
  26. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js +1 -3
  27. package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -1
  28. package/dist/cjs/ExampleFeature/Factory/ExampleFeatureFactory.js +65 -0
  29. package/dist/cjs/ExampleFeature/Factory/ExampleFeatureFactory.js.map +1 -0
  30. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js +5 -13
  31. package/dist/cjs/ExampleFeature/PMs/ExamplePM.js.map +1 -1
  32. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js +8 -12
  33. package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -1
  34. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js +0 -4
  35. package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -1
  36. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js +2 -8
  37. package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -1
  38. package/dist/cjs/index.js +0 -1
  39. package/dist/cjs/index.js.map +1 -1
  40. package/dist/esm/AppObject/AppObjectComponent.js +8 -10
  41. package/dist/esm/AppObject/AppObjectComponent.js.map +1 -1
  42. package/dist/esm/AppObject/AppObjectEntityRepo.js +99 -11
  43. package/dist/esm/AppObject/AppObjectEntityRepo.js.map +1 -1
  44. package/dist/esm/AppObject/AppObjectPM.js +107 -7
  45. package/dist/esm/AppObject/AppObjectPM.js.map +1 -1
  46. package/dist/esm/AppObject/AppObjectRepo.js +11 -1
  47. package/dist/esm/AppObject/AppObjectRepo.js.map +1 -1
  48. package/dist/esm/AppObject/AppObjectSingletonEntity.js +36 -0
  49. package/dist/esm/AppObject/AppObjectSingletonEntity.js.map +1 -0
  50. package/dist/esm/AppObject/AppObjectSingletonEntityRepo.js +50 -0
  51. package/dist/esm/AppObject/AppObjectSingletonEntityRepo.js.map +1 -0
  52. package/dist/esm/AppObject/AppObjectSingletonPM.js +65 -0
  53. package/dist/esm/AppObject/AppObjectSingletonPM.js.map +1 -0
  54. package/dist/esm/AppObject/AppObjectSingletonUC.js +56 -0
  55. package/dist/esm/AppObject/AppObjectSingletonUC.js.map +1 -0
  56. package/dist/esm/AppObject/index.js +4 -0
  57. package/dist/esm/AppObject/index.js.map +1 -1
  58. package/dist/esm/DomainFactories/Entities/DomainFactoryRepo.js +4 -0
  59. package/dist/esm/DomainFactories/Entities/DomainFactoryRepo.js.map +1 -1
  60. package/dist/esm/Entities/ObserverList.js +6 -0
  61. package/dist/esm/Entities/ObserverList.js.map +1 -1
  62. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js +11 -22
  63. package/dist/esm/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
  64. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js +2 -4
  65. package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -1
  66. package/dist/esm/ExampleFeature/Factory/ExampleFeatureFactory.js +60 -0
  67. package/dist/esm/ExampleFeature/Factory/ExampleFeatureFactory.js.map +1 -0
  68. package/dist/esm/ExampleFeature/PMs/ExamplePM.js +5 -13
  69. package/dist/esm/ExampleFeature/PMs/ExamplePM.js.map +1 -1
  70. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js +9 -13
  71. package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -1
  72. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js +0 -4
  73. package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -1
  74. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js +3 -9
  75. package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -1
  76. package/dist/esm/index.js +0 -1
  77. package/dist/esm/index.js.map +1 -1
  78. package/dist/types/AppObject/AppObjectComponent.d.ts +6 -4
  79. package/dist/types/AppObject/AppObjectComponent.d.ts.map +1 -1
  80. package/dist/types/AppObject/AppObjectEntityRepo.d.ts +72 -7
  81. package/dist/types/AppObject/AppObjectEntityRepo.d.ts.map +1 -1
  82. package/dist/types/AppObject/AppObjectPM.d.ts +82 -2
  83. package/dist/types/AppObject/AppObjectPM.d.ts.map +1 -1
  84. package/dist/types/AppObject/AppObjectRepo.d.ts +13 -0
  85. package/dist/types/AppObject/AppObjectRepo.d.ts.map +1 -1
  86. package/dist/types/AppObject/AppObjectSingletonEntity.d.ts +31 -0
  87. package/dist/types/AppObject/AppObjectSingletonEntity.d.ts.map +1 -0
  88. package/dist/types/AppObject/AppObjectSingletonEntityRepo.d.ts +46 -0
  89. package/dist/types/AppObject/AppObjectSingletonEntityRepo.d.ts.map +1 -0
  90. package/dist/types/AppObject/AppObjectSingletonPM.d.ts +60 -0
  91. package/dist/types/AppObject/AppObjectSingletonPM.d.ts.map +1 -0
  92. package/dist/types/AppObject/AppObjectSingletonUC.d.ts +51 -0
  93. package/dist/types/AppObject/AppObjectSingletonUC.d.ts.map +1 -0
  94. package/dist/types/AppObject/index.d.ts +4 -0
  95. package/dist/types/AppObject/index.d.ts.map +1 -1
  96. package/dist/types/DomainFactories/Entities/DomainFactoryRepo.d.ts +1 -0
  97. package/dist/types/DomainFactories/Entities/DomainFactoryRepo.d.ts.map +1 -1
  98. package/dist/types/Entities/ObserverList.d.ts +4 -0
  99. package/dist/types/Entities/ObserverList.d.ts.map +1 -1
  100. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts +0 -4
  101. package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts.map +1 -1
  102. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts +2 -2
  103. package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts.map +1 -1
  104. package/dist/types/ExampleFeature/Factory/ExampleFeatureFactory.d.ts +44 -0
  105. package/dist/types/ExampleFeature/Factory/ExampleFeatureFactory.d.ts.map +1 -0
  106. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts +4 -4
  107. package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts.map +1 -1
  108. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts +2 -2
  109. package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts.map +1 -1
  110. package/dist/types/index.d.ts +0 -1
  111. package/dist/types/index.d.ts.map +1 -1
  112. package/package.json +2 -2
  113. package/dist/cjs/ExampleFeature/Adapters/index.js +0 -19
  114. package/dist/cjs/ExampleFeature/Adapters/index.js.map +0 -1
  115. package/dist/cjs/ExampleFeature/Controllers/index.js +0 -19
  116. package/dist/cjs/ExampleFeature/Controllers/index.js.map +0 -1
  117. package/dist/cjs/ExampleFeature/Entities/index.js +0 -20
  118. package/dist/cjs/ExampleFeature/Entities/index.js.map +0 -1
  119. package/dist/cjs/ExampleFeature/Factory/index.js +0 -18
  120. package/dist/cjs/ExampleFeature/Factory/index.js.map +0 -1
  121. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js +0 -29
  122. package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js.map +0 -1
  123. package/dist/cjs/ExampleFeature/Mocks/index.js +0 -21
  124. package/dist/cjs/ExampleFeature/Mocks/index.js.map +0 -1
  125. package/dist/cjs/ExampleFeature/PMs/index.js +0 -19
  126. package/dist/cjs/ExampleFeature/PMs/index.js.map +0 -1
  127. package/dist/cjs/ExampleFeature/UCs/index.js +0 -19
  128. package/dist/cjs/ExampleFeature/UCs/index.js.map +0 -1
  129. package/dist/cjs/ExampleFeature/index.js +0 -24
  130. package/dist/cjs/ExampleFeature/index.js.map +0 -1
  131. package/dist/esm/ExampleFeature/Adapters/index.js +0 -3
  132. package/dist/esm/ExampleFeature/Adapters/index.js.map +0 -1
  133. package/dist/esm/ExampleFeature/Controllers/index.js +0 -3
  134. package/dist/esm/ExampleFeature/Controllers/index.js.map +0 -1
  135. package/dist/esm/ExampleFeature/Entities/index.js +0 -4
  136. package/dist/esm/ExampleFeature/Entities/index.js.map +0 -1
  137. package/dist/esm/ExampleFeature/Factory/index.js +0 -2
  138. package/dist/esm/ExampleFeature/Factory/index.js.map +0 -1
  139. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js +0 -26
  140. package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js.map +0 -1
  141. package/dist/esm/ExampleFeature/Mocks/index.js +0 -5
  142. package/dist/esm/ExampleFeature/Mocks/index.js.map +0 -1
  143. package/dist/esm/ExampleFeature/PMs/index.js +0 -3
  144. package/dist/esm/ExampleFeature/PMs/index.js.map +0 -1
  145. package/dist/esm/ExampleFeature/UCs/index.js +0 -3
  146. package/dist/esm/ExampleFeature/UCs/index.js.map +0 -1
  147. package/dist/esm/ExampleFeature/index.js +0 -8
  148. package/dist/esm/ExampleFeature/index.js.map +0 -1
  149. package/dist/types/ExampleFeature/Adapters/index.d.ts +0 -3
  150. package/dist/types/ExampleFeature/Adapters/index.d.ts.map +0 -1
  151. package/dist/types/ExampleFeature/Controllers/index.d.ts +0 -3
  152. package/dist/types/ExampleFeature/Controllers/index.d.ts.map +0 -1
  153. package/dist/types/ExampleFeature/Entities/index.d.ts +0 -4
  154. package/dist/types/ExampleFeature/Entities/index.d.ts.map +0 -1
  155. package/dist/types/ExampleFeature/Factory/index.d.ts +0 -2
  156. package/dist/types/ExampleFeature/Factory/index.d.ts.map +0 -1
  157. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts +0 -17
  158. package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts.map +0 -1
  159. package/dist/types/ExampleFeature/Mocks/index.d.ts +0 -5
  160. package/dist/types/ExampleFeature/Mocks/index.d.ts.map +0 -1
  161. package/dist/types/ExampleFeature/PMs/index.d.ts +0 -3
  162. package/dist/types/ExampleFeature/PMs/index.d.ts.map +0 -1
  163. package/dist/types/ExampleFeature/UCs/index.d.ts +0 -3
  164. package/dist/types/ExampleFeature/UCs/index.d.ts.map +0 -1
  165. package/dist/types/ExampleFeature/index.d.ts +0 -8
  166. package/dist/types/ExampleFeature/index.d.ts.map +0 -1
@@ -6,20 +6,32 @@ import { AppObjectEntity } from "./AppObjectEntity";
6
6
  * entities that are associated with specific AppObjects. It implements the observer
7
7
  * pattern to notify listeners when entities are added or removed.
8
8
  *
9
+ * Derived classes should override the `entityFactory` method to provide custom
10
+ * entity creation logic for the `create` method.
11
+ *
9
12
  * @template T - The type of entities managed by this repository, must extend AppObjectEntity
10
13
  * @extends AppObjectEntity
11
14
  *
12
15
  * @example
13
16
  * ```typescript
14
- * // Create a repository for player entities
15
- * const playerRepo = new AppObjectEntityRepo<PlayerEntity>();
17
+ * // Create a custom repository with entity factory
18
+ * class PlayerRepo extends AppObjectEntityRepo<PlayerEntity> {
19
+ * entityFactory(id: string): PlayerEntity {
20
+ * const appObject = makeAppObject(id, this.appObjects);
21
+ * return new PlayerEntity(appObject);
22
+ * }
23
+ * }
24
+ *
25
+ * const playerRepo = new PlayerRepo(repoAppObject);
16
26
  *
17
- * // Add a new player
18
- * const player = new PlayerEntity(appObject);
19
- * playerRepo.add(player);
27
+ * // Create a new player with auto-generated ID
28
+ * const player = playerRepo.create();
20
29
  *
21
- * // Get a player by its AppObject ID
22
- * const retrievedPlayer = playerRepo.getForAppObject("player1");
30
+ * // Create a new player with specific ID
31
+ * const specificPlayer = playerRepo.create("player1");
32
+ *
33
+ * // Get a player by its ID
34
+ * const retrievedPlayer = playerRepo.getById("player1");
23
35
  * ```
24
36
  */
25
37
  export declare class AppObjectEntityRepo<T extends AppObjectEntity> extends AppObjectEntity {
@@ -50,11 +62,19 @@ export declare class AppObjectEntityRepo<T extends AppObjectEntity> extends AppO
50
62
  * @param {(removedEntity: T) => void} observer - The callback function to remove
51
63
  */
52
64
  removeEntityRemovedObserver: (observer: (removedEntity: T) => void) => void;
65
+ /**
66
+ * Checks if an entity exists for the given ID.
67
+ *
68
+ * @param {string} id - The ID of the AppObject
69
+ * @returns {boolean} True if an entity exists for the given ID, false otherwise
70
+ */
71
+ has: (id: string) => boolean;
53
72
  /**
54
73
  * Checks if an entity exists for the given AppObject ID.
55
74
  *
56
75
  * @param {string} appObjectID - The ID of the AppObject
57
76
  * @returns {boolean} True if an entity exists for the given AppObject ID, false otherwise
77
+ * @deprecated Use has instead
58
78
  */
59
79
  hasForAppObject: (appObjectID: string) => boolean;
60
80
  /**
@@ -66,19 +86,64 @@ export declare class AppObjectEntityRepo<T extends AppObjectEntity> extends AppO
66
86
  * @param {T} entity - The entity to add
67
87
  */
68
88
  add(entity: T): void;
89
+ /**
90
+ * Creates a new entity with the specified or auto-generated ID and adds it to the repository.
91
+ *
92
+ * This method uses the `entityFactory` method to create the entity instance.
93
+ * If no ID is provided, a unique ID is generated automatically.
94
+ *
95
+ * @param {string} [id] - Optional ID for the entity. If not provided, a unique ID is generated.
96
+ * @returns {T} The newly created entity
97
+ */
98
+ create(id?: string): T;
99
+ /**
100
+ * Factory method for creating entity instances.
101
+ *
102
+ * This method must be overridden in derived classes to provide custom entity creation logic.
103
+ * It is called by the `create` method to instantiate new entities.
104
+ *
105
+ * @param {string} id - The ID to use for the new entity
106
+ * @returns {T} A new entity instance
107
+ * @throws {Error} If not overridden in derived class
108
+ */
109
+ entityFactory(id: string): T;
110
+ /**
111
+ * Removes the entity associated with the specified ID.
112
+ *
113
+ * Notifies all registered observers after the entity is removed.
114
+ *
115
+ * @param {string} id - The ID of the AppObject whose entity should be removed
116
+ */
117
+ removeById: (id: string) => void;
69
118
  /**
70
119
  * Removes the entity associated with the specified AppObject ID.
71
120
  *
72
121
  * Notifies all registered observers after the entity is removed.
73
122
  *
74
123
  * @param {string} id - The ID of the AppObject whose entity should be removed
124
+ * @deprecated Use removeById instead
75
125
  */
76
126
  removeForAppObject: (id: string) => void;
127
+ /**
128
+ * Removes all entities from the repository.
129
+ *
130
+ * Unsubscribes from all entity change observers and notifies all registered
131
+ * removal observers for each entity before clearing the repository.
132
+ */
133
+ deleteAll: () => void;
134
+ /**
135
+ * Gets the entity associated with the specified ID.
136
+ *
137
+ * @param {string} id - The ID of the AppObject
138
+ * @returns {T | undefined} The entity if found, undefined otherwise
139
+ */
140
+ getById: (id: string) => T | undefined;
77
141
  /**
78
142
  * Gets the entity associated with the specified AppObject ID.
79
143
  *
80
144
  * @param {string} appObjectID - The ID of the AppObject
81
145
  * @returns {T | undefined} The entity if found, undefined otherwise
146
+ * @deprecated Use getById instead
82
147
  */
83
148
  getForAppObject: (appObjectID: string) => T | undefined;
84
149
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AppObjectEntityRepo.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntityRepo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,mBAAmB,CAC9B,CAAC,SAAS,eAAe,CACzB,SAAQ,eAAe;IACvB,OAAO,CAAC,YAAY,CAAwB;IAE5C,OAAO,CAAC,sBAAsB,CAAyB;IACvD;;;;OAIG;IACH,sBAAsB,GAAI,UAAU,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,UAE1D;IAEF;;;;OAIG;IACH,yBAAyB,GAAI,UAAU,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,KAAG,IAAI,CAEpE;IAEF,OAAO,CAAC,wBAAwB,CAAyB;IACzD;;;;OAIG;IACH,wBAAwB,GAAI,UAAU,CAAC,aAAa,EAAE,CAAC,KAAK,IAAI,UAE9D;IAEF;;;;OAIG;IACH,2BAA2B,GACzB,UAAU,CAAC,aAAa,EAAE,CAAC,KAAK,IAAI,KACnC,IAAI,CAEL;IAEF;;;;;OAKG;IACH,eAAe,GAAI,aAAa,MAAM,KAAG,OAAO,CAE9C;IAEF;;;;;;;OAOG;IACH,GAAG,CAAC,MAAM,EAAE,CAAC;IAYb;;;;;;OAMG;IACH,kBAAkB,GAAI,IAAI,MAAM,UAQ9B;IAEF;;;;;OAKG;IACH,eAAe,GAAI,aAAa,MAAM,KAAG,CAAC,GAAG,SAAS,CAEpD;IAEF;;;;OAIG;IACH,MAAM,QAAO,CAAC,EAAE,CAEd;CACH"}
1
+ {"version":3,"file":"A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G,CAAC,GAAG,SAAS,CAEnC;IAEF;;;;;;OAMG;IACH,eAAe,GAAI,aAAa,MAAM,KAAG,CAAC,GAAG,SAAS,CAEpD;IAEF;;;;OAIG;IACH,MAAM,QAAO,CAAC,EAAE,CAEd;CACH"}
@@ -1,4 +1,5 @@
1
1
  import { AppObjectComponent, AppObjectComponentType } from "./AppObjectComponent";
2
+ import { AppObjectEntity } from "./AppObjectEntity";
2
3
  /**
3
4
  * Presentation Manager (PM) component that transforms application state into view models
4
5
  *
@@ -28,13 +29,28 @@ export declare abstract class AppObjectPM<T> extends AppObjectComponent {
28
29
  abstract vmsAreEqual(a: T, b: T): boolean;
29
30
  /** The most recently generated view model */
30
31
  private _lastVM?;
32
+ /**
33
+ * Optional default view model to return when no view model has been generated yet.
34
+ * If set, this value will be returned by the `lastVM` getter before any view model
35
+ * has been created via `doUpdateView`.
36
+ *
37
+ * This is useful for providing initial state to views without requiring immediate
38
+ * view model generation.
39
+ */
40
+ defaultVM?: T;
31
41
  /**
32
42
  * Gets the most recently generated view model
33
- * @returns The last view model or undefined if none has been generated
43
+ * @returns The last view model, or `defaultVM` if no view model has been generated yet,
44
+ * or undefined if neither exists
34
45
  */
35
46
  get lastVM(): T | undefined;
36
47
  /** List of view update functions to notify when the view model changes */
37
- private observerList;
48
+ private views;
49
+ /**
50
+ * List of entities being observed by this PM.
51
+ * Used for automatic cleanup during disposal.
52
+ */
53
+ private observedEntities;
38
54
  /**
39
55
  * Registers a view update function to be called when the view model changes
40
56
  * If a view model already exists, the provided function is called immediately with that model
@@ -42,6 +58,64 @@ export declare abstract class AppObjectPM<T> extends AppObjectComponent {
42
58
  * @param updateView Function to call with updated view models
43
59
  */
44
60
  addView(updateView: (vm: T) => void): void;
61
+ /**
62
+ * Called when an observed entity changes.
63
+ * If views are registered, this method calls `formVM()` to regenerate the view model.
64
+ *
65
+ * This method is automatically invoked when entities registered via `observeEntity()`
66
+ * notify their observers. It implements lazy evaluation - view models are only
67
+ * formed when there are views to receive them.
68
+ */
69
+ onEntityChanged(): void;
70
+ /**
71
+ * Forms and updates the view model based on current entity state.
72
+ *
73
+ * Override this method in derived classes to:
74
+ * 1. Read data from observed entities
75
+ * 2. Transform the data into a view model
76
+ * 3. Call `doUpdateView(vm)` with the new view model
77
+ *
78
+ * This method is only called when at least one view has been registered,
79
+ * implementing lazy evaluation to avoid unnecessary computation.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * formVM(): void {
84
+ * const entity = this.getCachedLocalComponent<MyEntity>(MyEntity.type);
85
+ * if (entity) {
86
+ * this.doUpdateView({
87
+ * displayName: entity.name,
88
+ * isActive: entity.active
89
+ * });
90
+ * }
91
+ * }
92
+ * ```
93
+ */
94
+ formVM(): void;
95
+ onViewAdded(): void;
96
+ /**
97
+ * Registers an entity to be observed for changes.
98
+ *
99
+ * When the entity notifies of changes (via `notifyOnChange()`), this PM will
100
+ * automatically call `onEntityChanged()`, which in turn calls `formVM()` if
101
+ * views are registered.
102
+ *
103
+ * The entity observer is automatically cleaned up when this PM is disposed.
104
+ *
105
+ * @param entity The entity to observe for changes
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * constructor(appObj: AppObject) {
110
+ * super(appObj, MyPM.type);
111
+ * const entity = appObj.getComponent<MyEntity>(MyEntity.type);
112
+ * if (entity) {
113
+ * this.observeEntity(entity);
114
+ * }
115
+ * }
116
+ * ```
117
+ */
118
+ protected observeEntity(entity: AppObjectEntity): void;
45
119
  /**
46
120
  * Unregisters a previously added view update function
47
121
  *
@@ -60,6 +134,12 @@ export declare abstract class AppObjectPM<T> extends AppObjectComponent {
60
134
  doUpdateView(vm: T): void;
61
135
  /**
62
136
  * Cleans up resources and detaches this PM from its parent AppObject
137
+ *
138
+ * This method:
139
+ * 1. Removes change observers from all observed entities
140
+ * 2. Clears all view observers
141
+ * 3. Removes this component from its parent AppObject if still attached
142
+ * 4. Calls the parent class dispose method
63
143
  */
64
144
  dispose(): void;
65
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AppObjectPM.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectPM.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAElF;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,WAAW,CAAC,CAAC,CAAE,SAAQ,kBAAkB;IAC7D,0DAA0D;IAC1D,QAAQ,CAAC,aAAa,6BAA6B;IAEnD;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO;IAEzC,6CAA6C;IAC7C,OAAO,CAAC,OAAO,CAAC,CAAI;IAEpB;;;OAGG;IACH,IAAI,MAAM,IAAI,CAAC,GAAG,SAAS,CAE1B;IAED,0EAA0E;IAC1E,OAAO,CAAC,YAAY,CAAyB;IAE7C;;;;;OAKG;IACH,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAS1C;;;;OAIG;IACH,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAI7C;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,EAAE,CAAC;IAUlB;;OAEG;IACH,OAAO;CAOR"}
1
+ {"version":3,"file":"AppObjectPM.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectPM.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,WAAW,CAAC,CAAC,CAAE,SAAQ,kBAAkB;IAC7D,0DAA0D;IAC1D,QAAQ,CAAC,aAAa,6BAA6B;IAEnD;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO;IAEzC,6CAA6C;IAC7C,OAAO,CAAC,OAAO,CAAC,CAAI;IAEpB;;;;;;;OAOG;IACI,SAAS,CAAC,EAAE,CAAC,CAAC;IAErB;;;;OAIG;IACH,IAAI,MAAM,IAAI,CAAC,GAAG,SAAS,CAG1B;IAED,0EAA0E;IAC1E,OAAO,CAAC,KAAK,CAAyB;IAEtC;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAyB;IAEjD;;;;;OAKG;IACH,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAgB1C;;;;;;;OAOG;IACH,eAAe,IAAI,IAAI;IAQvB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,IAAI,IAAI;IAMd,WAAW,IAAI,IAAI;IAInB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAQtD;;;;OAIG;IACH,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAI7C;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,EAAE,CAAC;IAUlB;;;;;;;;OAQG;IACH,OAAO;CAaR"}
@@ -84,6 +84,19 @@ export declare abstract class AppObjectRepo extends ObservableEntity {
84
84
  * @param {AppObjectComponent} component - The component to register as a singleton
85
85
  */
86
86
  abstract registerSingleton(component: AppObjectComponent): void;
87
+ /**
88
+ * Unregisters a singleton component from the repository.
89
+ *
90
+ * @param {string} type - The type of the singleton to unregister
91
+ */
92
+ abstract unregisterSingleton(type: string): void;
93
+ /**
94
+ * Checks if a singleton component of the specified type exists.
95
+ *
96
+ * @param {string} type - The type of the singleton to check
97
+ * @returns {boolean} True if a singleton of the specified type exists, false otherwise
98
+ */
99
+ abstract hasSingleton(type: string): boolean;
87
100
  /**
88
101
  * Gets a singleton component of the specified type.
89
102
  *
@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AMG;IACH,QAAQ,CAAC,YAAY,CAAC,CAAC,SAAS,kBAAkB,EAChD,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,SAAS;IAEhB;;;;;;;OAOG;IACH,QAAQ,CAAC,qBAAqB,CAAC,CAAC,SAAS,kBAAkB,EACzD,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,SAAS;IAEhB;;;;;OAKG;IACH,QAAQ,CAAC,6BAA6B,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,EAAE;IAE1E;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,CAAC,CAAC,SAAS,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE;IAE1E;;;;OAIG;IACH,QAAQ,CAAC,yBAAyB,EAAE,CAClC,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,KAAK,IAAI,KACvC,IAAI,CAAC;IAEV;;;;OAIG;IACH,QAAQ,CAAC,4BAA4B,EAAE,CACrC,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,KAAK,IAAI,KACvC,IAAI,CAAC;IAEV;;;;OAIG;IACH,QAAQ,CAAC,2BAA2B,EAAE,CACpC,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,KAAK,IAAI,KACvC,IAAI,CAAC;IAEV;;;;OAIG;IACH,QAAQ,CAAC,+BAA+B,EAAE,CACxC,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,KAAK,IAAI,KACvC,IAAI,CAAC;CACX;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,aAAa,CAEjD"}
@@ -0,0 +1,31 @@
1
+ import { AppObject } from "./AppObject";
2
+ import { AppObjectEntity } from "./AppObjectEntity";
3
+ /**
4
+ * Singleton entity component that manages application state
5
+ *
6
+ * AppObjectSingletonEntity extends AppObjectEntity and automatically registers itself
7
+ * as a singleton in the AppObjectRepo upon construction. This ensures only one instance
8
+ * of this entity type exists across the entire application.
9
+ *
10
+ * Use this class when you need an entity that should have only one instance globally,
11
+ * such as application-wide configuration or shared state managers.
12
+ */
13
+ export declare class AppObjectSingletonEntity extends AppObjectEntity {
14
+ /**
15
+ * Creates a new singleton entity component and attaches it to the specified AppObject
16
+ * Automatically registers itself as a singleton in the AppObjectRepo
17
+ *
18
+ * @param appObject The parent AppObject this component will be attached to
19
+ * @param type The unique type identifier for this component
20
+ */
21
+ constructor(appObject: AppObject, type: string);
22
+ /**
23
+ * Cleans up resources and unregisters the singleton
24
+ *
25
+ * This method:
26
+ * 1. Unregisters itself from the singleton registry
27
+ * 2. Calls the parent class dispose method
28
+ */
29
+ dispose(): void;
30
+ }
31
+ //# sourceMappingURL=AppObjectSingletonEntity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonEntity.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;GASG;AACH,qBAAa,wBAAyB,SAAQ,eAAe;IAC3D;;;;;;OAMG;gBACS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM;IAM9C;;;;;;OAMG;IACH,OAAO;CAIR"}
@@ -0,0 +1,46 @@
1
+ import { AppObject } from "./AppObject";
2
+ import { AppObjectEntity } from "./AppObjectEntity";
3
+ import { AppObjectEntityRepo } from "./AppObjectEntityRepo";
4
+ /**
5
+ * A singleton repository for managing collections of AppObjectEntity instances.
6
+ *
7
+ * This generic class extends AppObjectEntityRepo and automatically registers itself
8
+ * as a singleton in the AppObjectRepo upon construction. This ensures only one instance
9
+ * of this repository type exists across the entire application.
10
+ *
11
+ * Use this class when you need a centralized repository that should have only one instance
12
+ * globally, such as application-wide entity collections or shared resource managers.
13
+ *
14
+ * @template T - The type of entities managed by this repository, must extend AppObjectEntity
15
+ * @extends AppObjectEntityRepo
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Create a singleton repository for player entities
20
+ * class PlayerRepo extends AppObjectSingletonEntityRepo<PlayerEntity> {
21
+ * static type = "playerRepo";
22
+ * constructor(appObject: AppObject) {
23
+ * super(appObject, PlayerRepo.type);
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ export declare class AppObjectSingletonEntityRepo<T extends AppObjectEntity> extends AppObjectEntityRepo<T> {
29
+ /**
30
+ * Creates a new singleton entity repository component and attaches it to the specified AppObject
31
+ * Automatically registers itself as a singleton in the AppObjectRepo
32
+ *
33
+ * @param appObject The parent AppObject this component will be attached to
34
+ * @param type The unique type identifier for this component
35
+ */
36
+ constructor(appObject: AppObject, type: string);
37
+ /**
38
+ * Cleans up resources and unregisters the singleton
39
+ *
40
+ * This method:
41
+ * 1. Unregisters itself from the singleton registry
42
+ * 2. Calls the parent class dispose method
43
+ */
44
+ dispose(): void;
45
+ }
46
+ //# sourceMappingURL=AppObjectSingletonEntityRepo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonEntityRepo.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonEntityRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,4BAA4B,CACvC,CAAC,SAAS,eAAe,CACzB,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAC9B;;;;;;OAMG;gBACS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM;IAM9C;;;;;;OAMG;IACH,OAAO;CAIR"}
@@ -0,0 +1,60 @@
1
+ import { AppObject } from "./AppObject";
2
+ import { AppObjectPM } from "./AppObjectPM";
3
+ /**
4
+ * Singleton Presentation Manager (PM) component that transforms application state into view models
5
+ *
6
+ * AppObjectSingletonPM extends AppObjectPM and automatically registers itself as a singleton
7
+ * in the AppObjectRepo upon construction. This ensures only one instance of this PM type exists
8
+ * across the entire application.
9
+ *
10
+ * Use this class when you need a presentation manager that should have only one instance globally,
11
+ * such as application-wide UI state managers or shared view model providers.
12
+ *
13
+ * A singleton PM typically:
14
+ * 1. Observes entity changes
15
+ * 2. Transforms entity data into view models
16
+ * 3. Notifies attached views when view models change
17
+ * 4. Handles view model caching and optimization
18
+ * 5. Exists as a single instance across the application
19
+ *
20
+ * @typeparam T The view model type this PM produces
21
+ * @extends AppObjectPM
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * class GlobalSettingsPM extends AppObjectSingletonPM<SettingsVM> {
26
+ * static type = "globalSettingsPM";
27
+ *
28
+ * constructor(appObject: AppObject) {
29
+ * super(appObject, GlobalSettingsPM.type);
30
+ * }
31
+ *
32
+ * vmsAreEqual(a: SettingsVM, b: SettingsVM): boolean {
33
+ * return a.theme === b.theme && a.language === b.language;
34
+ * }
35
+ *
36
+ * formVM(): void {
37
+ * // Form view model from entities
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ export declare abstract class AppObjectSingletonPM<T> extends AppObjectPM<T> {
43
+ /**
44
+ * Creates a new singleton presentation manager component and attaches it to the specified AppObject
45
+ * Automatically registers itself as a singleton in the AppObjectRepo
46
+ *
47
+ * @param appObject The parent AppObject this component will be attached to
48
+ * @param type The unique type identifier for this component
49
+ */
50
+ constructor(appObject: AppObject, type: string);
51
+ /**
52
+ * Cleans up resources and unregisters the singleton
53
+ *
54
+ * This method:
55
+ * 1. Unregisters itself from the singleton registry
56
+ * 2. Calls the parent class dispose method (which handles entity observers and views)
57
+ */
58
+ dispose(): void;
59
+ }
60
+ //# sourceMappingURL=AppObjectSingletonPM.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonPM.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonPM.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,8BAAsB,oBAAoB,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IAClE;;;;;;OAMG;gBACS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM;IAM9C;;;;;;OAMG;IACH,OAAO;CAIR"}
@@ -0,0 +1,51 @@
1
+ import { AppObject } from "./AppObject";
2
+ import { AppObjectUC } from "./AppObjectUC";
3
+ /**
4
+ * AppObjectSingletonUC (Use Case) serves as a singleton use case class within the application framework.
5
+ *
6
+ * This class extends AppObjectUC and automatically registers itself as a singleton in the
7
+ * AppObjectRepo upon construction. This ensures only one instance of this use case type exists
8
+ * across the entire application.
9
+ *
10
+ * Use Cases are components that represent specific application operations or workflows.
11
+ * They encapsulate business rules and coordinate interactions between different parts
12
+ * of the application. Use this singleton version when the use case should exist as a
13
+ * single instance globally, such as application-wide orchestration or workflow managers.
14
+ *
15
+ * @extends AppObjectUC
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * class GlobalPurchaseManagerUC extends AppObjectSingletonUC {
20
+ * static type = "globalPurchaseManagerUC";
21
+ *
22
+ * constructor(appObject: AppObject) {
23
+ * super(appObject, GlobalPurchaseManagerUC.type);
24
+ * }
25
+ *
26
+ * execute(itemId: string, quantity: number): boolean {
27
+ * // Implement the purchase item use case
28
+ * return true; // if successful
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ export declare class AppObjectSingletonUC extends AppObjectUC {
34
+ /**
35
+ * Creates a new singleton use case component and attaches it to the specified AppObject
36
+ * Automatically registers itself as a singleton in the AppObjectRepo
37
+ *
38
+ * @param appObject The parent AppObject this component will be attached to
39
+ * @param type The unique type identifier for this component
40
+ */
41
+ constructor(appObject: AppObject, type: string);
42
+ /**
43
+ * Cleans up resources and unregisters the singleton
44
+ *
45
+ * This method:
46
+ * 1. Unregisters itself from the singleton registry
47
+ * 2. Calls the parent class dispose method
48
+ */
49
+ dispose(): void;
50
+ }
51
+ //# sourceMappingURL=AppObjectSingletonUC.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppObjectSingletonUC.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectSingletonUC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;IACnD;;;;;;OAMG;gBACS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM;IAM9C;;;;;;OAMG;IACH,OAAO;CAIR"}
@@ -6,6 +6,10 @@ export * from "./AppObjectRepo";
6
6
  export * from "./AppObjectUC";
7
7
  export * from "./AppObjectController";
8
8
  export * from "./AppObjectView";
9
+ export * from "./AppObjectSingletonEntity";
10
+ export * from "./AppObjectSingletonEntityRepo";
11
+ export * from "./AppObjectSingletonPM";
12
+ export * from "./AppObjectSingletonUC";
9
13
  export * from "./getSingletonComponent";
10
14
  export * from "./printAppObjectDetails";
11
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/AppObject/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/AppObject/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
@@ -41,4 +41,5 @@ export declare class DomainFactoryRepo extends AppObjectEntityRepo<DomainFactory
41
41
  */
42
42
  constructor(appObject: AppObject);
43
43
  }
44
+ export declare function makeDomainFactoryRepo(appObjects: AppObjectRepo): DomainFactoryRepo;
44
45
  //# sourceMappingURL=DomainFactoryRepo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomainFactoryRepo.d.ts","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactoryRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,aAAa,EAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB,CAAC,aAAa,CAAC;IACvE,gDAAgD;IAChD,MAAM,CAAC,IAAI,SAAuB;IAElC;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa;IAOpC;;;;OAIG;IACH,WAAW,aAsBT;IAEF;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAKlD;;;OAGG;gBACS,SAAS,EAAE,SAAS;CAGjC"}
1
+ {"version":3,"file":"DomainFactoryRepo.d.ts","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactoryRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,aAAa,EAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB,CAAC,aAAa,CAAC;IACvE,gDAAgD;IAChD,MAAM,CAAC,IAAI,SAAuB;IAElC;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa;IAOpC;;;;OAIG;IACH,WAAW,aAsBT;IAEF;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAKlD;;;OAGG;gBACS,SAAS,EAAE,SAAS;CAGjC;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,aAAa,qBAG9D"}
@@ -6,6 +6,10 @@
6
6
  */
7
7
  export declare class ObserverList<T> {
8
8
  private observers;
9
+ /**
10
+ * Gets the number of observers in the list
11
+ */
12
+ get length(): number;
9
13
  /**
10
14
  * Notifies all observers by calling them with the provided message
11
15
  * @param msg - The message to send to all observers
@@ -1 +1 @@
1
- {"version":3,"file":"ObserverList.d.ts","sourceRoot":"","sources":["../../../src/Entities/ObserverList.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,SAAS,CAA4B;IAE7C;;;OAGG;IACI,MAAM,GAAI,KAAK,CAAC,UAIrB;IAEF;;;OAGG;IACI,GAAG,GAAI,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,UAEjC;IAEF;;;OAGG;IACI,MAAM,GAAI,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,UAKpC;IAEF;;OAEG;IACI,KAAK,aAEV;CACH"}
1
+ {"version":3,"file":"ObserverList.d.ts","sourceRoot":"","sources":["../../../src/Entities/ObserverList.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,SAAS,CAA4B;IAE7C;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;;OAGG;IACI,MAAM,GAAI,KAAK,CAAC,UAIrB;IAEF;;;OAGG;IACI,GAAG,GAAI,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,UAEjC;IAEF;;;OAGG;IACI,MAAM,GAAI,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,UAKpC;IAEF;;OAEG;IACI,KAAK,aAEV;CACH"}
@@ -27,10 +27,6 @@ export type ExampleEntityFactory = (id: string) => ExampleEntity;
27
27
  export declare abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {
28
28
  /** Unique type identifier for this component */
29
29
  static readonly type = "ExampleRepoType";
30
- /** Factory function used to create new entities */
31
- abstract exampleEntityFactory: ExampleEntityFactory;
32
- /** Creates a new entity with an optional ID */
33
- abstract createExampleEntity(id?: string): ExampleEntity;
34
30
  /** Deletes an entity by its AppObject ID */
35
31
  abstract deleteExampleEntity(id: string): void;
36
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleRepo.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAqB,MAAM,iBAAiB,CAAC;AAEnE,kFAAkF;AAClF,MAAM,MAAM,oBAAoB,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,aAAa,CAAC;AAEjE;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,mBAAmB,CAAC,aAAa,CAAC;IAC1E,gDAAgD;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AG,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS;IAItD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,aAAa,GACxB,WAAW,GAAG,SAAS;IAI1B;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW;CAQvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAEjE"}
@@ -16,12 +16,12 @@
16
16
  * 2. Access or modify properties via getters/setters
17
17
  * 3. Register change observers to react to property updates
18
18
  */
19
- import { AppObject, AppObjectEntity, AppObjectRepo } from "../../AppObject";
19
+ import { AppObject, AppObjectRepo, AppObjectSingletonEntity } from "../../AppObject";
20
20
  /**
21
21
  * SingletonEntityExample represents a global entity with a boolean property.
22
22
  * As a singleton, only one instance exists in the application.
23
23
  */
24
- export declare abstract class SingletonEntityExample extends AppObjectEntity {
24
+ export declare abstract class SingletonEntityExample extends AppObjectSingletonEntity {
25
25
  /** Unique type identifier for this component */
26
26
  static readonly type = "SingletonEntityExampleType";
27
27
  /** Boolean property accessor methods that must be implemented */
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleSingletonEntity.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleSingletonEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,SAAS,EACT,eAAe,EACf,aAAa,EACd,MAAM,iBAAiB,CAAC;AAIzB;;;GAGG;AACH,8BAAsB,sBAAuB,SAAQ,eAAe;IAClE,gDAAgD;IAChD,MAAM,CAAC,QAAQ,CAAC,IAAI,gCAAgC;IAEpD,iEAAiE;IACjE,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC;IACtC,QAAQ,KAAK,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE;IAEzC;;;;OAIG;IACH,MAAM,CAAC,GAAG,GACR,YAAY,aAAa,KACxB,sBAAsB,GAAG,SAAS,CAC4B;CAClE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,SAAS,GACnB,sBAAsB,CAExB"}
1
+ {"version":3,"file":"ExampleSingletonEntity.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleSingletonEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,SAAS,EACT,aAAa,EACb,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AAIzB;;;GAGG;AACH,8BAAsB,sBAAuB,SAAQ,wBAAwB;IAC3E,gDAAgD;IAChD,MAAM,CAAC,QAAQ,CAAC,IAAI,gCAAgC;IAEpD,iEAAiE;IACjE,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC;IACtC,QAAQ,KAAK,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE;IAEzC;;;;OAIG;IACH,MAAM,CAAC,GAAG,GACR,YAAY,aAAa,KACxB,sBAAsB,GAAG,SAAS,CAC4B;CAClE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,SAAS,GACnB,sBAAsB,CAExB"}
@@ -0,0 +1,44 @@
1
+ import { AppObjectRepo } from "../../AppObject";
2
+ import { DomainFactory } from "../../DomainFactories";
3
+ /**
4
+ * Factory responsible for setting up the Example Feature domain components.
5
+ *
6
+ * This factory initializes all entities, use cases, and presentation models
7
+ * required for the Example Feature functionality. It follows the domain-driven
8
+ * design pattern by organizing components into their respective layers.
9
+ *
10
+ * @extends DomainFactory
11
+ */
12
+ export declare class ExampleFeatureFactory extends DomainFactory {
13
+ factoryName: string;
14
+ /**
15
+ * Sets up all entities required for the Example Feature.
16
+ *
17
+ * Initializes singleton entities that maintain the state and business
18
+ * logic for the example feature functionality.
19
+ */
20
+ setupEntities(): void;
21
+ /**
22
+ * Sets up all use cases for the Example Feature.
23
+ *
24
+ * Initializes use cases that define the business operations and
25
+ * workflows available in the example feature.
26
+ */
27
+ setupUCs(): void;
28
+ /**
29
+ * Sets up all presentation models for the Example Feature.
30
+ *
31
+ * Initializes presentation models that handle the view logic and
32
+ * state management for UI components related to the example feature.
33
+ */
34
+ setupPMs(): void;
35
+ /**
36
+ * Performs any final setup operations after all components are initialized.
37
+ *
38
+ * This method is called after entities, use cases, and presentation models
39
+ * have been set up. Currently no additional setup is required for this feature.
40
+ */
41
+ finalSetup(): void;
42
+ }
43
+ export declare function makeExampleFeatureFactory(appObjects: AppObjectRepo): ExampleFeatureFactory;
44
+ //# sourceMappingURL=ExampleFeatureFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleFeatureFactory.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Factory/ExampleFeatureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKtD;;;;;;;;GAQG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;IAEvD,WAAW,SAA2B;IAEtC;;;;;OAKG;IACH,aAAa,IAAI,IAAI;IAKrB;;;;;OAKG;IACH,QAAQ,IAAI,IAAI;IAKhB;;;;;OAKG;IACH,QAAQ,IAAI,IAAI;IAKhB;;;;;OAKG;IACH,UAAU,IAAI,IAAI;CAIlB;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,aAAa,GAAE,qBAAqB,CAGzF"}