@vived/core 1.4.3 → 1.4.4
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.
- package/README.md +25 -1
- package/dist/cjs/ExampleFeature/Adapters/examplePmAdapter.js +64 -0
- package/dist/cjs/ExampleFeature/Adapters/examplePmAdapter.js.map +1 -0
- package/dist/cjs/ExampleFeature/Adapters/exampleSingletonPmAdapter.js +60 -0
- package/dist/cjs/ExampleFeature/Adapters/exampleSingletonPmAdapter.js.map +1 -0
- package/dist/cjs/ExampleFeature/Adapters/index.js +19 -0
- package/dist/cjs/ExampleFeature/Adapters/index.js.map +1 -0
- package/dist/cjs/ExampleFeature/Controllers/index.js +19 -0
- package/dist/cjs/ExampleFeature/Controllers/index.js.map +1 -0
- package/dist/cjs/ExampleFeature/Controllers/setExampleText.js +48 -0
- package/dist/cjs/ExampleFeature/Controllers/setExampleText.js.map +1 -0
- package/dist/cjs/ExampleFeature/Controllers/toggleExampleBoolean.js +47 -0
- package/dist/cjs/ExampleFeature/Controllers/toggleExampleBoolean.js.map +1 -0
- package/dist/cjs/ExampleFeature/Entities/ExampleEntity.js +90 -0
- package/dist/cjs/ExampleFeature/Entities/ExampleEntity.js.map +1 -0
- package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js +113 -0
- package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js.map +1 -0
- package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js +69 -0
- package/dist/cjs/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -0
- package/dist/cjs/ExampleFeature/Entities/index.js +20 -0
- package/dist/cjs/ExampleFeature/Entities/index.js.map +1 -0
- package/dist/cjs/ExampleFeature/Factory/index.js +18 -0
- package/dist/cjs/ExampleFeature/Factory/index.js.map +1 -0
- package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js +29 -0
- package/dist/cjs/ExampleFeature/Factory/setupExampleFeature.js.map +1 -0
- package/dist/cjs/ExampleFeature/Mocks/MockEditExampleStringUC.js +47 -0
- package/dist/cjs/ExampleFeature/Mocks/MockEditExampleStringUC.js.map +1 -0
- package/dist/cjs/ExampleFeature/Mocks/MockExamplePM.js +48 -0
- package/dist/cjs/ExampleFeature/Mocks/MockExamplePM.js.map +1 -0
- package/dist/cjs/ExampleFeature/Mocks/MockExampleSingletonPM.js +59 -0
- package/dist/cjs/ExampleFeature/Mocks/MockExampleSingletonPM.js.map +1 -0
- package/dist/cjs/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js +57 -0
- package/dist/cjs/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js.map +1 -0
- package/dist/cjs/ExampleFeature/Mocks/index.js +21 -0
- package/dist/cjs/ExampleFeature/Mocks/index.js.map +1 -0
- package/dist/cjs/ExampleFeature/PMs/ExamplePM.js +97 -0
- package/dist/cjs/ExampleFeature/PMs/ExamplePM.js.map +1 -0
- package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js +102 -0
- package/dist/cjs/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -0
- package/dist/cjs/ExampleFeature/PMs/index.js +19 -0
- package/dist/cjs/ExampleFeature/PMs/index.js.map +1 -0
- package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js +87 -0
- package/dist/cjs/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -0
- package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js +79 -0
- package/dist/cjs/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -0
- package/dist/cjs/ExampleFeature/UCs/index.js +19 -0
- package/dist/cjs/ExampleFeature/UCs/index.js.map +1 -0
- package/dist/cjs/ExampleFeature/index.js +24 -0
- package/dist/cjs/ExampleFeature/index.js.map +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/ExampleFeature/Adapters/examplePmAdapter.js +61 -0
- package/dist/esm/ExampleFeature/Adapters/examplePmAdapter.js.map +1 -0
- package/dist/esm/ExampleFeature/Adapters/exampleSingletonPmAdapter.js +57 -0
- package/dist/esm/ExampleFeature/Adapters/exampleSingletonPmAdapter.js.map +1 -0
- package/dist/esm/ExampleFeature/Adapters/index.js +3 -0
- package/dist/esm/ExampleFeature/Adapters/index.js.map +1 -0
- package/dist/esm/ExampleFeature/Controllers/index.js +3 -0
- package/dist/esm/ExampleFeature/Controllers/index.js.map +1 -0
- package/dist/esm/ExampleFeature/Controllers/setExampleText.js +45 -0
- package/dist/esm/ExampleFeature/Controllers/setExampleText.js.map +1 -0
- package/dist/esm/ExampleFeature/Controllers/toggleExampleBoolean.js +44 -0
- package/dist/esm/ExampleFeature/Controllers/toggleExampleBoolean.js.map +1 -0
- package/dist/esm/ExampleFeature/Entities/ExampleEntity.js +85 -0
- package/dist/esm/ExampleFeature/Entities/ExampleEntity.js.map +1 -0
- package/dist/esm/ExampleFeature/Entities/ExampleRepo.js +108 -0
- package/dist/esm/ExampleFeature/Entities/ExampleRepo.js.map +1 -0
- package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js +64 -0
- package/dist/esm/ExampleFeature/Entities/ExampleSingletonEntity.js.map +1 -0
- package/dist/esm/ExampleFeature/Entities/index.js +4 -0
- package/dist/esm/ExampleFeature/Entities/index.js.map +1 -0
- package/dist/esm/ExampleFeature/Factory/index.js +2 -0
- package/dist/esm/ExampleFeature/Factory/index.js.map +1 -0
- package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js +26 -0
- package/dist/esm/ExampleFeature/Factory/setupExampleFeature.js.map +1 -0
- package/dist/esm/ExampleFeature/Mocks/MockEditExampleStringUC.js +43 -0
- package/dist/esm/ExampleFeature/Mocks/MockEditExampleStringUC.js.map +1 -0
- package/dist/esm/ExampleFeature/Mocks/MockExamplePM.js +44 -0
- package/dist/esm/ExampleFeature/Mocks/MockExamplePM.js.map +1 -0
- package/dist/esm/ExampleFeature/Mocks/MockExampleSingletonPM.js +54 -0
- package/dist/esm/ExampleFeature/Mocks/MockExampleSingletonPM.js.map +1 -0
- package/dist/esm/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js +52 -0
- package/dist/esm/ExampleFeature/Mocks/MockToggleExampleBooleanUC.js.map +1 -0
- package/dist/esm/ExampleFeature/Mocks/index.js +5 -0
- package/dist/esm/ExampleFeature/Mocks/index.js.map +1 -0
- package/dist/esm/ExampleFeature/PMs/ExamplePM.js +92 -0
- package/dist/esm/ExampleFeature/PMs/ExamplePM.js.map +1 -0
- package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js +97 -0
- package/dist/esm/ExampleFeature/PMs/ExampleSingletonPM.js.map +1 -0
- package/dist/esm/ExampleFeature/PMs/index.js +3 -0
- package/dist/esm/ExampleFeature/PMs/index.js.map +1 -0
- package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js +82 -0
- package/dist/esm/ExampleFeature/UCs/EditExampleStringUC.js.map +1 -0
- package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js +74 -0
- package/dist/esm/ExampleFeature/UCs/ToggleExampleBooleanUC.js.map +1 -0
- package/dist/esm/ExampleFeature/UCs/index.js +3 -0
- package/dist/esm/ExampleFeature/UCs/index.js.map +1 -0
- package/dist/esm/ExampleFeature/index.js +8 -0
- package/dist/esm/ExampleFeature/index.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/ExampleFeature/Adapters/examplePmAdapter.d.ts +29 -0
- package/dist/types/ExampleFeature/Adapters/examplePmAdapter.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Adapters/exampleSingletonPmAdapter.d.ts +31 -0
- package/dist/types/ExampleFeature/Adapters/exampleSingletonPmAdapter.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Adapters/index.d.ts +3 -0
- package/dist/types/ExampleFeature/Adapters/index.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Controllers/index.d.ts +3 -0
- package/dist/types/ExampleFeature/Controllers/index.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Controllers/setExampleText.d.ts +35 -0
- package/dist/types/ExampleFeature/Controllers/setExampleText.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Controllers/toggleExampleBoolean.d.ts +34 -0
- package/dist/types/ExampleFeature/Controllers/toggleExampleBoolean.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Entities/ExampleEntity.d.ts +55 -0
- package/dist/types/ExampleFeature/Entities/ExampleEntity.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts +62 -0
- package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts +43 -0
- package/dist/types/ExampleFeature/Entities/ExampleSingletonEntity.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Entities/index.d.ts +4 -0
- package/dist/types/ExampleFeature/Entities/index.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Factory/index.d.ts +2 -0
- package/dist/types/ExampleFeature/Factory/index.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts +17 -0
- package/dist/types/ExampleFeature/Factory/setupExampleFeature.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Mocks/MockEditExampleStringUC.d.ts +42 -0
- package/dist/types/ExampleFeature/Mocks/MockEditExampleStringUC.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Mocks/MockExamplePM.d.ts +41 -0
- package/dist/types/ExampleFeature/Mocks/MockExamplePM.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Mocks/MockExampleSingletonPM.d.ts +49 -0
- package/dist/types/ExampleFeature/Mocks/MockExampleSingletonPM.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Mocks/MockToggleExampleBooleanUC.d.ts +47 -0
- package/dist/types/ExampleFeature/Mocks/MockToggleExampleBooleanUC.d.ts.map +1 -0
- package/dist/types/ExampleFeature/Mocks/index.d.ts +5 -0
- package/dist/types/ExampleFeature/Mocks/index.d.ts.map +1 -0
- package/dist/types/ExampleFeature/PMs/ExamplePM.d.ts +42 -0
- package/dist/types/ExampleFeature/PMs/ExamplePM.d.ts.map +1 -0
- package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts +52 -0
- package/dist/types/ExampleFeature/PMs/ExampleSingletonPM.d.ts.map +1 -0
- package/dist/types/ExampleFeature/PMs/index.d.ts +3 -0
- package/dist/types/ExampleFeature/PMs/index.d.ts.map +1 -0
- package/dist/types/ExampleFeature/UCs/EditExampleStringUC.d.ts +52 -0
- package/dist/types/ExampleFeature/UCs/EditExampleStringUC.d.ts.map +1 -0
- package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts +44 -0
- package/dist/types/ExampleFeature/UCs/ToggleExampleBooleanUC.d.ts.map +1 -0
- package/dist/types/ExampleFeature/UCs/index.d.ts +3 -0
- package/dist/types/ExampleFeature/UCs/index.d.ts.map +1 -0
- package/dist/types/ExampleFeature/index.d.ts +8 -0
- package/dist/types/ExampleFeature/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ExampleEntity"), exports);
|
|
18
|
+
__exportStar(require("./ExampleRepo"), exports);
|
|
19
|
+
__exportStar(require("./ExampleSingletonEntity"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,gDAA8B;AAC9B,2DAAyC","sourcesContent":["export * from \"./ExampleEntity\";\r\nexport * from \"./ExampleRepo\";\r\nexport * from \"./ExampleSingletonEntity\";\r\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./setupExampleFeature"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Factory/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC","sourcesContent":["export * from \"./setupExampleFeature\";"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* setupExampleFeature.ts
|
|
4
|
+
*
|
|
5
|
+
* This file provides a setup function to initialize the ExampleFeature components.
|
|
6
|
+
* It creates a dedicated AppObject for ExampleFeature and adds all required
|
|
7
|
+
* singleton components to it.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.setupExampleFeature = setupExampleFeature;
|
|
11
|
+
const ExampleSingletonEntity_1 = require("../Entities/ExampleSingletonEntity");
|
|
12
|
+
const ExampleSingletonPM_1 = require("../PMs/ExampleSingletonPM");
|
|
13
|
+
const ToggleExampleBooleanUC_1 = require("../UCs/ToggleExampleBooleanUC");
|
|
14
|
+
/**
|
|
15
|
+
* Sets up the ExampleFeature by creating an AppObject and attaching required components.
|
|
16
|
+
*
|
|
17
|
+
* @param appObjects - Repository of AppObjects to use for creating the feature
|
|
18
|
+
* @returns The singleton entity instance
|
|
19
|
+
*/
|
|
20
|
+
function setupExampleFeature(appObjects) {
|
|
21
|
+
// Create a dedicated AppObject for ExampleFeature
|
|
22
|
+
const appObject = appObjects.getOrCreate("ExampleFeature");
|
|
23
|
+
// Add singleton components to the AppObject
|
|
24
|
+
const entity = (0, ExampleSingletonEntity_1.makeSingletonEntityExample)(appObject);
|
|
25
|
+
(0, ExampleSingletonPM_1.makeExampleSingletonPM)(appObject);
|
|
26
|
+
(0, ToggleExampleBooleanUC_1.makeToggleExampleBooleanUC)(appObject);
|
|
27
|
+
return entity;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=setupExampleFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupExampleFeature.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Factory/setupExampleFeature.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAaH,kDAUC;AApBD,+EAAwG;AACxG,kEAAmE;AACnE,0EAA2E;AAE3E;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,UAAyB;IAC3D,kDAAkD;IAClD,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAE3D,4CAA4C;IAC5C,MAAM,MAAM,GAAG,IAAA,mDAA0B,EAAC,SAAS,CAAC,CAAC;IACrD,IAAA,2CAAsB,EAAC,SAAS,CAAC,CAAC;IAClC,IAAA,mDAA0B,EAAC,SAAS,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * setupExampleFeature.ts\r\n * \r\n * This file provides a setup function to initialize the ExampleFeature components.\r\n * It creates a dedicated AppObject for ExampleFeature and adds all required\r\n * singleton components to it.\r\n */\r\n\r\nimport { AppObjectRepo } from \"../../AppObject\";\r\nimport { makeSingletonEntityExample, SingletonEntityExample } from \"../Entities/ExampleSingletonEntity\";\r\nimport { makeExampleSingletonPM } from \"../PMs/ExampleSingletonPM\";\r\nimport { makeToggleExampleBooleanUC } from \"../UCs/ToggleExampleBooleanUC\";\r\n\r\n/**\r\n * Sets up the ExampleFeature by creating an AppObject and attaching required components.\r\n * \r\n * @param appObjects - Repository of AppObjects to use for creating the feature\r\n * @returns The singleton entity instance\r\n */\r\nexport function setupExampleFeature(appObjects: AppObjectRepo): SingletonEntityExample {\r\n // Create a dedicated AppObject for ExampleFeature\r\n const appObject = appObjects.getOrCreate(\"ExampleFeature\");\r\n \r\n // Add singleton components to the AppObject\r\n const entity = makeSingletonEntityExample(appObject);\r\n makeExampleSingletonPM(appObject);\r\n makeToggleExampleBooleanUC(appObject);\r\n \r\n return entity;\r\n}"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MockEditExampleStringUC.ts
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to implement a mock UC for testing.
|
|
6
|
+
* Mock UCs extend the real UC classes but override their methods with test implementations.
|
|
7
|
+
* This allows tests to verify that the UC methods are called correctly without
|
|
8
|
+
* actually modifying entities or performing real operations.
|
|
9
|
+
*
|
|
10
|
+
* Key concepts:
|
|
11
|
+
* - Mock UCs extend the real UC classes
|
|
12
|
+
* - They override methods with test implementations (often empty or spy functions)
|
|
13
|
+
* - They're used in unit tests to isolate components from their dependencies
|
|
14
|
+
* - They help verify that methods are called with the correct parameters
|
|
15
|
+
*
|
|
16
|
+
* Usage pattern (in tests):
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // In a test file
|
|
19
|
+
* const mockUC = new MockEditExampleStringUC(appObject);
|
|
20
|
+
* const spy = jest.spyOn(mockUC, 'editExampleString');
|
|
21
|
+
*
|
|
22
|
+
* // Call the function that should use the UC
|
|
23
|
+
* someFunction(appObject);
|
|
24
|
+
*
|
|
25
|
+
* // Verify the UC method was called correctly
|
|
26
|
+
* expect(spy).toHaveBeenCalledWith('expected value');
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.MockEditExampleStringUC = void 0;
|
|
31
|
+
const EditExampleStringUC_1 = require("../UCs/EditExampleStringUC");
|
|
32
|
+
/**
|
|
33
|
+
* Mock implementation of EditExampleStringUC for testing
|
|
34
|
+
* Provides a no-op implementation of editExampleString that can be spied on in tests
|
|
35
|
+
*/
|
|
36
|
+
class MockEditExampleStringUC extends EditExampleStringUC_1.EditExampleStringUC {
|
|
37
|
+
constructor(appObject) {
|
|
38
|
+
super(appObject, EditExampleStringUC_1.EditExampleStringUC.type);
|
|
39
|
+
/**
|
|
40
|
+
* Mock implementation that does nothing
|
|
41
|
+
* In tests, this can be replaced with a Jest spy to track calls
|
|
42
|
+
*/
|
|
43
|
+
this.editExampleString = (text) => { };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.MockEditExampleStringUC = MockEditExampleStringUC;
|
|
47
|
+
//# sourceMappingURL=MockEditExampleStringUC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockEditExampleStringUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Mocks/MockEditExampleStringUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AAGH,oEAAiE;AAEjE;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,yCAAmB;IAO9D,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,yCAAmB,CAAC,IAAI,CAAC,CAAC;QAP7C;;;WAGG;QACH,sBAAiB,GAAG,CAAC,IAAY,EAAQ,EAAE,GAAE,CAAC,CAAC;IAI/C,CAAC;CACF;AAVD,0DAUC","sourcesContent":["/**\r\n * MockEditExampleStringUC.ts\r\n * \r\n * This file demonstrates how to implement a mock UC for testing.\r\n * Mock UCs extend the real UC classes but override their methods with test implementations.\r\n * This allows tests to verify that the UC methods are called correctly without\r\n * actually modifying entities or performing real operations.\r\n * \r\n * Key concepts:\r\n * - Mock UCs extend the real UC classes\r\n * - They override methods with test implementations (often empty or spy functions)\r\n * - They're used in unit tests to isolate components from their dependencies\r\n * - They help verify that methods are called with the correct parameters\r\n * \r\n * Usage pattern (in tests):\r\n * ```typescript\r\n * // In a test file\r\n * const mockUC = new MockEditExampleStringUC(appObject);\r\n * const spy = jest.spyOn(mockUC, 'editExampleString');\r\n * \r\n * // Call the function that should use the UC\r\n * someFunction(appObject);\r\n * \r\n * // Verify the UC method was called correctly\r\n * expect(spy).toHaveBeenCalledWith('expected value');\r\n * ```\r\n */\r\n\r\nimport { AppObject } from \"../../AppObject\";\r\nimport { EditExampleStringUC } from \"../UCs/EditExampleStringUC\";\r\n\r\n/**\r\n * Mock implementation of EditExampleStringUC for testing\r\n * Provides a no-op implementation of editExampleString that can be spied on in tests\r\n */\r\nexport class MockEditExampleStringUC extends EditExampleStringUC {\r\n /**\r\n * Mock implementation that does nothing\r\n * In tests, this can be replaced with a Jest spy to track calls\r\n */\r\n editExampleString = (text: string): void => {};\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, EditExampleStringUC.type);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MockExamplePM.ts
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to implement a mock PM for testing.
|
|
6
|
+
* Mock PMs extend the real PM classes but override their methods with test implementations.
|
|
7
|
+
* This allows tests to verify PM behavior without depending on real entities.
|
|
8
|
+
*
|
|
9
|
+
* Key concepts:
|
|
10
|
+
* - Mock PMs extend the real PM classes
|
|
11
|
+
* - They override methods with test implementations
|
|
12
|
+
* - They're used in unit tests to isolate components from their dependencies
|
|
13
|
+
* - They help test adapters and other components that use PMs
|
|
14
|
+
*
|
|
15
|
+
* Usage pattern (in tests):
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // In a test file
|
|
18
|
+
* const mockPM = new MockExamplePM(appObject);
|
|
19
|
+
* const addViewSpy = jest.spyOn(mockPM, 'addView');
|
|
20
|
+
*
|
|
21
|
+
* // Test the component that uses the PM
|
|
22
|
+
* adapter.subscribe(id, appObjects, setVM);
|
|
23
|
+
*
|
|
24
|
+
* // Verify the PM method was called correctly
|
|
25
|
+
* expect(addViewSpy).toHaveBeenCalledWith(setVM);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.MockExamplePM = void 0;
|
|
30
|
+
const ExamplePM_1 = require("../PMs/ExamplePM");
|
|
31
|
+
/**
|
|
32
|
+
* Mock implementation of ExamplePM for testing
|
|
33
|
+
* Provides simplified implementations of required methods
|
|
34
|
+
*/
|
|
35
|
+
class MockExamplePM extends ExamplePM_1.ExamplePM {
|
|
36
|
+
constructor(appObject) {
|
|
37
|
+
super(appObject, ExamplePM_1.ExamplePM.type);
|
|
38
|
+
/**
|
|
39
|
+
* Simplified implementation that always returns true
|
|
40
|
+
* This avoids the need to implement real comparison logic in tests
|
|
41
|
+
*/
|
|
42
|
+
this.vmsAreEqual = () => {
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.MockExamplePM = MockExamplePM;
|
|
48
|
+
//# sourceMappingURL=MockExamplePM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockExamplePM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Mocks/MockExamplePM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAGH,gDAA6C;AAE7C;;;GAGG;AACH,MAAa,aAAc,SAAQ,qBAAS;IAS1C,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,qBAAS,CAAC,IAAI,CAAC,CAAC;QATnC;;;WAGG;QACH,gBAAW,GAAG,GAAG,EAAE;YACjB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IAIF,CAAC;CACF;AAZD,sCAYC","sourcesContent":["/**\r\n * MockExamplePM.ts\r\n * \r\n * This file demonstrates how to implement a mock PM for testing.\r\n * Mock PMs extend the real PM classes but override their methods with test implementations.\r\n * This allows tests to verify PM behavior without depending on real entities.\r\n * \r\n * Key concepts:\r\n * - Mock PMs extend the real PM classes\r\n * - They override methods with test implementations\r\n * - They're used in unit tests to isolate components from their dependencies\r\n * - They help test adapters and other components that use PMs\r\n * \r\n * Usage pattern (in tests):\r\n * ```typescript\r\n * // In a test file\r\n * const mockPM = new MockExamplePM(appObject);\r\n * const addViewSpy = jest.spyOn(mockPM, 'addView');\r\n * \r\n * // Test the component that uses the PM\r\n * adapter.subscribe(id, appObjects, setVM);\r\n * \r\n * // Verify the PM method was called correctly\r\n * expect(addViewSpy).toHaveBeenCalledWith(setVM);\r\n * ```\r\n */\r\n\r\nimport { AppObject } from \"../../AppObject\";\r\nimport { ExamplePM } from \"../PMs/ExamplePM\";\r\n\r\n/**\r\n * Mock implementation of ExamplePM for testing\r\n * Provides simplified implementations of required methods\r\n */\r\nexport class MockExamplePM extends ExamplePM {\r\n /**\r\n * Simplified implementation that always returns true\r\n * This avoids the need to implement real comparison logic in tests\r\n */\r\n vmsAreEqual = () => {\r\n return true;\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExamplePM.type);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MockExampleSingletonPM.ts
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to implement a mock singleton PM for testing.
|
|
6
|
+
* Mock singleton PMs extend the real singleton PM classes and provide helper
|
|
7
|
+
* functions to create and access them in tests.
|
|
8
|
+
*
|
|
9
|
+
* Key concepts:
|
|
10
|
+
* - Mock singleton PMs extend the real singleton PM classes
|
|
11
|
+
* - They override methods with test implementations
|
|
12
|
+
* - They include helper functions to create and access them in tests
|
|
13
|
+
* - They're used to test adapters and controllers that depend on singleton PMs
|
|
14
|
+
*
|
|
15
|
+
* Usage pattern (in tests):
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // In a test file
|
|
18
|
+
* const mockPM = makeMockExampleSingletonPM(appObjects);
|
|
19
|
+
* const addViewSpy = jest.spyOn(mockPM, 'addView');
|
|
20
|
+
*
|
|
21
|
+
* // Test the component that uses the singleton PM
|
|
22
|
+
* adapter.subscribe(appObjects, setVM);
|
|
23
|
+
*
|
|
24
|
+
* // Verify the PM method was called correctly
|
|
25
|
+
* expect(addViewSpy).toHaveBeenCalledWith(setVM);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.MockExampleSingletonPM = void 0;
|
|
30
|
+
exports.makeMockExampleSingletonPM = makeMockExampleSingletonPM;
|
|
31
|
+
const ExampleSingletonPM_1 = require("../PMs/ExampleSingletonPM");
|
|
32
|
+
/**
|
|
33
|
+
* Mock implementation of ExampleSingletonPM for testing
|
|
34
|
+
* Provides simplified implementations of required methods
|
|
35
|
+
*/
|
|
36
|
+
class MockExampleSingletonPM extends ExampleSingletonPM_1.ExampleSingletonPM {
|
|
37
|
+
constructor(appObject) {
|
|
38
|
+
super(appObject, ExampleSingletonPM_1.ExampleSingletonPM.type);
|
|
39
|
+
/**
|
|
40
|
+
* Simplified implementation that always returns true
|
|
41
|
+
* This avoids the need to implement real comparison logic in tests
|
|
42
|
+
*/
|
|
43
|
+
this.vmsAreEqual = () => {
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.MockExampleSingletonPM = MockExampleSingletonPM;
|
|
49
|
+
/**
|
|
50
|
+
* Helper function to create and register a MockExampleSingletonPM
|
|
51
|
+
* Returns the created mock for use in tests
|
|
52
|
+
*
|
|
53
|
+
* @param appObjects The AppObjectRepo to register the mock with
|
|
54
|
+
* @returns A new MockExampleSingletonPM instance
|
|
55
|
+
*/
|
|
56
|
+
function makeMockExampleSingletonPM(appObjects) {
|
|
57
|
+
return new MockExampleSingletonPM(appObjects.getOrCreate("MockExampleSingletonPM"));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=MockExampleSingletonPM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockExampleSingletonPM.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Mocks/MockExampleSingletonPM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AA8BH,gEAIC;AA/BD,kEAA+D;AAE/D;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,uCAAkB;IAS5D,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,uCAAkB,CAAC,IAAI,CAAC,CAAC;QAT5C;;;WAGG;QACH,gBAAW,GAAG,GAAG,EAAE;YACjB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IAIF,CAAC;CACF;AAZD,wDAYC;AAED;;;;;;GAMG;AACH,SAAgB,0BAA0B,CAAC,UAAyB;IAClE,OAAO,IAAI,sBAAsB,CAC/B,UAAU,CAAC,WAAW,CAAC,wBAAwB,CAAC,CACjD,CAAC;AACJ,CAAC","sourcesContent":["/**\r\n * MockExampleSingletonPM.ts\r\n * \r\n * This file demonstrates how to implement a mock singleton PM for testing.\r\n * Mock singleton PMs extend the real singleton PM classes and provide helper\r\n * functions to create and access them in tests.\r\n * \r\n * Key concepts:\r\n * - Mock singleton PMs extend the real singleton PM classes\r\n * - They override methods with test implementations\r\n * - They include helper functions to create and access them in tests\r\n * - They're used to test adapters and controllers that depend on singleton PMs\r\n * \r\n * Usage pattern (in tests):\r\n * ```typescript\r\n * // In a test file\r\n * const mockPM = makeMockExampleSingletonPM(appObjects);\r\n * const addViewSpy = jest.spyOn(mockPM, 'addView');\r\n * \r\n * // Test the component that uses the singleton PM\r\n * adapter.subscribe(appObjects, setVM);\r\n * \r\n * // Verify the PM method was called correctly\r\n * expect(addViewSpy).toHaveBeenCalledWith(setVM);\r\n * ```\r\n */\r\n\r\nimport { AppObject, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleSingletonPM } from \"../PMs/ExampleSingletonPM\";\r\n\r\n/**\r\n * Mock implementation of ExampleSingletonPM for testing\r\n * Provides simplified implementations of required methods\r\n */\r\nexport class MockExampleSingletonPM extends ExampleSingletonPM {\r\n /**\r\n * Simplified implementation that always returns true\r\n * This avoids the need to implement real comparison logic in tests\r\n */\r\n vmsAreEqual = () => {\r\n return true;\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleSingletonPM.type);\r\n }\r\n}\r\n\r\n/**\r\n * Helper function to create and register a MockExampleSingletonPM\r\n * Returns the created mock for use in tests\r\n * \r\n * @param appObjects The AppObjectRepo to register the mock with\r\n * @returns A new MockExampleSingletonPM instance\r\n */\r\nexport function makeMockExampleSingletonPM(appObjects: AppObjectRepo) {\r\n return new MockExampleSingletonPM(\r\n appObjects.getOrCreate(\"MockExampleSingletonPM\")\r\n );\r\n}\r\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MockToggleExampleBooleanUC.ts
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to implement a mock singleton UC for testing.
|
|
6
|
+
* Mock singleton UCs extend the real UC classes and provide helper functions
|
|
7
|
+
* to create and register them as singletons for tests.
|
|
8
|
+
*
|
|
9
|
+
* Key concepts:
|
|
10
|
+
* - Mock singleton UCs extend the real UC classes
|
|
11
|
+
* - They override methods with test implementations
|
|
12
|
+
* - They register themselves as singletons just like the real UCs
|
|
13
|
+
* - They include helper functions to create them in tests
|
|
14
|
+
*
|
|
15
|
+
* Usage pattern (in tests):
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // In a test file
|
|
18
|
+
* const mockUC = makeMockToggleExampleBooleanUC(appObject);
|
|
19
|
+
* const spy = jest.spyOn(mockUC, 'toggleExampleBoolean');
|
|
20
|
+
*
|
|
21
|
+
* // Call the function that should use the UC
|
|
22
|
+
* toggleExampleBoolean(appObjects);
|
|
23
|
+
*
|
|
24
|
+
* // Verify the UC method was called correctly
|
|
25
|
+
* expect(spy).toHaveBeenCalled();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.MockToggleExampleBooleanUC = void 0;
|
|
30
|
+
exports.makeMockToggleExampleBooleanUC = makeMockToggleExampleBooleanUC;
|
|
31
|
+
const ToggleExampleBooleanUC_1 = require("../UCs/ToggleExampleBooleanUC");
|
|
32
|
+
/**
|
|
33
|
+
* Mock implementation of ToggleExampleBooleanUC for testing
|
|
34
|
+
* Provides a no-op implementation of toggleExampleBoolean that can be spied on in tests
|
|
35
|
+
*/
|
|
36
|
+
class MockToggleExampleBooleanUC extends ToggleExampleBooleanUC_1.ToggleExampleBooleanUC {
|
|
37
|
+
constructor(appObject) {
|
|
38
|
+
super(appObject, ToggleExampleBooleanUC_1.ToggleExampleBooleanUC.type);
|
|
39
|
+
/**
|
|
40
|
+
* Mock implementation that does nothing
|
|
41
|
+
* In tests, this can be replaced with a Jest spy to track calls
|
|
42
|
+
*/
|
|
43
|
+
this.toggleExampleBoolean = () => { };
|
|
44
|
+
// Register as a singleton just like the real UC
|
|
45
|
+
this.appObjects.registerSingleton(this);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.MockToggleExampleBooleanUC = MockToggleExampleBooleanUC;
|
|
49
|
+
/**
|
|
50
|
+
* Helper factory function to create a mock ToggleExampleBooleanUC
|
|
51
|
+
* @param appObject The AppObject to attach the UC to
|
|
52
|
+
* @returns A new MockToggleExampleBooleanUC instance
|
|
53
|
+
*/
|
|
54
|
+
function makeMockToggleExampleBooleanUC(appObject) {
|
|
55
|
+
return new MockToggleExampleBooleanUC(appObject);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=MockToggleExampleBooleanUC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockToggleExampleBooleanUC.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Mocks/MockToggleExampleBooleanUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AA4BH,wEAIC;AA7BD,0EAAuE;AAEvE;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,+CAAsB;IAOpE,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,+CAAsB,CAAC,IAAI,CAAC,CAAC;QAPhD;;;WAGG;QACH,yBAAoB,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;QAIpC,gDAAgD;QAChD,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF;AAZD,gEAYC;AAED;;;;GAIG;AACH,SAAgB,8BAA8B,CAC5C,SAAoB;IAEpB,OAAO,IAAI,0BAA0B,CAAC,SAAS,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\r\n * MockToggleExampleBooleanUC.ts\r\n * \r\n * This file demonstrates how to implement a mock singleton UC for testing.\r\n * Mock singleton UCs extend the real UC classes and provide helper functions\r\n * to create and register them as singletons for tests.\r\n * \r\n * Key concepts:\r\n * - Mock singleton UCs extend the real UC classes\r\n * - They override methods with test implementations\r\n * - They register themselves as singletons just like the real UCs\r\n * - They include helper functions to create them in tests\r\n * \r\n * Usage pattern (in tests):\r\n * ```typescript\r\n * // In a test file\r\n * const mockUC = makeMockToggleExampleBooleanUC(appObject);\r\n * const spy = jest.spyOn(mockUC, 'toggleExampleBoolean');\r\n * \r\n * // Call the function that should use the UC\r\n * toggleExampleBoolean(appObjects);\r\n * \r\n * // Verify the UC method was called correctly\r\n * expect(spy).toHaveBeenCalled();\r\n * ```\r\n */\r\n\r\nimport { AppObject } from \"../../AppObject\";\r\nimport { ToggleExampleBooleanUC } from \"../UCs/ToggleExampleBooleanUC\";\r\n\r\n/**\r\n * Mock implementation of ToggleExampleBooleanUC for testing\r\n * Provides a no-op implementation of toggleExampleBoolean that can be spied on in tests\r\n */\r\nexport class MockToggleExampleBooleanUC extends ToggleExampleBooleanUC {\r\n /**\r\n * Mock implementation that does nothing\r\n * In tests, this can be replaced with a Jest spy to track calls\r\n */\r\n toggleExampleBoolean = (): void => {};\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ToggleExampleBooleanUC.type);\r\n // Register as a singleton just like the real UC\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n\r\n/**\r\n * Helper factory function to create a mock ToggleExampleBooleanUC\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new MockToggleExampleBooleanUC instance\r\n */\r\nexport function makeMockToggleExampleBooleanUC(\r\n appObject: AppObject\r\n): MockToggleExampleBooleanUC {\r\n return new MockToggleExampleBooleanUC(appObject);\r\n}\r\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MockEditExampleStringUC"), exports);
|
|
18
|
+
__exportStar(require("./MockExamplePM"), exports);
|
|
19
|
+
__exportStar(require("./MockExampleSingletonPM"), exports);
|
|
20
|
+
__exportStar(require("./MockToggleExampleBooleanUC"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,kDAAgC;AAChC,2DAAyC;AACzC,+DAA6C","sourcesContent":["export * from \"./MockEditExampleStringUC\";\r\nexport * from \"./MockExamplePM\";\r\nexport * from \"./MockExampleSingletonPM\";\r\nexport * from \"./MockToggleExampleBooleanUC\";\r\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ExamplePM.ts
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to implement a Presentation Manager (PM) component.
|
|
6
|
+
* PMs are responsible for transforming entity data into view models (VMs) for the UI.
|
|
7
|
+
* They observe entities for changes and update their views when data changes.
|
|
8
|
+
*
|
|
9
|
+
* Key concepts:
|
|
10
|
+
* - PMs extend AppObjectPM<VM> where VM is the view model type
|
|
11
|
+
* - They observe entities and transform entity data into view models
|
|
12
|
+
* - They notify UI components (views) when view models change
|
|
13
|
+
* - Each PM instance is associated with a specific AppObject
|
|
14
|
+
*
|
|
15
|
+
* Usage pattern:
|
|
16
|
+
* 1. Get a PM instance using getById
|
|
17
|
+
* 2. Register UI components as views using addView(callback)
|
|
18
|
+
* 3. PM will call the view callbacks with updated view models when entities change
|
|
19
|
+
* 4. Remove UI components with removeView(callback) when they're unmounted
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.ExamplePM = void 0;
|
|
23
|
+
exports.makeExamplePM = makeExamplePM;
|
|
24
|
+
const AppObject_1 = require("../../AppObject");
|
|
25
|
+
const ExampleEntity_1 = require("../Entities/ExampleEntity");
|
|
26
|
+
/**
|
|
27
|
+
* ExamplePM transforms ExampleEntity data into a simple string view model.
|
|
28
|
+
* Abstract class provides the interface and static helper methods.
|
|
29
|
+
*/
|
|
30
|
+
class ExamplePM extends AppObject_1.AppObjectPM {
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves an ExamplePM by its parent AppObject's ID
|
|
33
|
+
* @param id The ID of the parent AppObject
|
|
34
|
+
* @param appObjects The AppObjectRepo to search in
|
|
35
|
+
* @returns The ExamplePM component or undefined if not found
|
|
36
|
+
*/
|
|
37
|
+
static getById(id, appObjects) {
|
|
38
|
+
return appObjects.get(id)?.getComponent(ExamplePM.type);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ExamplePM = ExamplePM;
|
|
42
|
+
/** Unique type identifier for this component */
|
|
43
|
+
ExamplePM.type = "ExamplePMType";
|
|
44
|
+
/**
|
|
45
|
+
* Factory function to create a new ExamplePM
|
|
46
|
+
* @param appObject The AppObject to attach the PM to
|
|
47
|
+
* @returns A new ExamplePM instance
|
|
48
|
+
*/
|
|
49
|
+
function makeExamplePM(appObject) {
|
|
50
|
+
return new ExamplePMImp(appObject);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Concrete implementation of ExamplePM
|
|
54
|
+
* This private class handles the actual implementation details
|
|
55
|
+
*/
|
|
56
|
+
class ExamplePMImp extends ExamplePM {
|
|
57
|
+
/**
|
|
58
|
+
* Gets the ExampleEntity from the same AppObject
|
|
59
|
+
* Uses getCachedLocalComponent for efficient repeated access
|
|
60
|
+
*/
|
|
61
|
+
get exampleEntity() {
|
|
62
|
+
return this.getCachedLocalComponent(ExampleEntity_1.ExampleEntity.type);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Compares two view models to determine if they're equal
|
|
66
|
+
* Used to avoid unnecessary view updates when values haven't changed
|
|
67
|
+
*/
|
|
68
|
+
vmsAreEqual(a, b) {
|
|
69
|
+
return a === b;
|
|
70
|
+
}
|
|
71
|
+
constructor(appObject) {
|
|
72
|
+
super(appObject, ExamplePM.type);
|
|
73
|
+
/**
|
|
74
|
+
* Handler for entity change events
|
|
75
|
+
* Transforms entity data into a view model and updates views
|
|
76
|
+
*/
|
|
77
|
+
this.onEntityChange = () => {
|
|
78
|
+
if (!this.exampleEntity)
|
|
79
|
+
return;
|
|
80
|
+
// In this simple case, our view model is just the string property value
|
|
81
|
+
this.doUpdateView(this.exampleEntity.aStringProperty);
|
|
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
|
+
// Register as an observer of the entity to receive change notifications
|
|
92
|
+
this.exampleEntity?.addChangeObserver(this.onEntityChange);
|
|
93
|
+
// Call the change handler initially to set up the initial view model
|
|
94
|
+
this.onEntityChange();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=ExamplePM.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ExampleSingletonPM.ts
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to implement a Singleton Presentation Manager (PM).
|
|
6
|
+
* Singleton PMs are special PMs that exist only once in the application and can be
|
|
7
|
+
* accessed globally. They transform data from singleton entities into view models.
|
|
8
|
+
*
|
|
9
|
+
* Key concepts:
|
|
10
|
+
* - Singleton PMs extend AppObjectPM<VM> like regular PMs
|
|
11
|
+
* - They register themselves as singletons with appObjects.registerSingleton()
|
|
12
|
+
* - They're accessed through a static get() method using getSingletonComponent()
|
|
13
|
+
* - They typically observe singleton entities and provide data to multiple UI components
|
|
14
|
+
*
|
|
15
|
+
* Usage pattern:
|
|
16
|
+
* 1. Access the singleton PM using the static get() method
|
|
17
|
+
* 2. Register UI components as views using addView(callback)
|
|
18
|
+
* 3. PM will call the view callbacks with updated view models when entities change
|
|
19
|
+
* 4. Remove UI components with removeView(callback) when they're unmounted
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.defaultSlideNavigationVM = exports.ExampleSingletonPM = void 0;
|
|
23
|
+
exports.makeExampleSingletonPM = makeExampleSingletonPM;
|
|
24
|
+
const AppObject_1 = require("../../AppObject");
|
|
25
|
+
const getSingletonComponent_1 = require("../../AppObject/getSingletonComponent");
|
|
26
|
+
const ExampleSingletonEntity_1 = require("../Entities/ExampleSingletonEntity");
|
|
27
|
+
/**
|
|
28
|
+
* ExampleSingletonPM transforms SingletonEntityExample data into an ExampleVM.
|
|
29
|
+
* As a singleton, only one instance exists in the application.
|
|
30
|
+
*/
|
|
31
|
+
class ExampleSingletonPM extends AppObject_1.AppObjectPM {
|
|
32
|
+
}
|
|
33
|
+
exports.ExampleSingletonPM = ExampleSingletonPM;
|
|
34
|
+
/** Unique type identifier for this component */
|
|
35
|
+
ExampleSingletonPM.type = "ExampleSingletonPMType";
|
|
36
|
+
/**
|
|
37
|
+
* Global accessor for the singleton PM
|
|
38
|
+
* @param appObjects The AppObjectRepo to search in
|
|
39
|
+
* @returns The singleton PM or undefined if not created yet
|
|
40
|
+
*/
|
|
41
|
+
ExampleSingletonPM.get = (appObjects) => (0, getSingletonComponent_1.getSingletonComponent)(ExampleSingletonPM.type, appObjects);
|
|
42
|
+
/**
|
|
43
|
+
* Default view model used when no data is available
|
|
44
|
+
* UI components can use this initially or when the PM is not found
|
|
45
|
+
*/
|
|
46
|
+
exports.defaultSlideNavigationVM = {
|
|
47
|
+
aBoolProperty: true
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Factory function to create a new ExampleSingletonPM
|
|
51
|
+
* @param appObject The AppObject to attach the PM to
|
|
52
|
+
* @returns A new ExampleSingletonPM instance
|
|
53
|
+
*/
|
|
54
|
+
function makeExampleSingletonPM(appObject) {
|
|
55
|
+
return new ExampleSingletonPMImp(appObject);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Concrete implementation of ExampleSingletonPM
|
|
59
|
+
* This private class handles the actual implementation details
|
|
60
|
+
*/
|
|
61
|
+
class ExampleSingletonPMImp extends ExampleSingletonPM {
|
|
62
|
+
/**
|
|
63
|
+
* Gets the SingletonEntityExample from the application
|
|
64
|
+
* Uses getCachedSingleton for efficient repeated access
|
|
65
|
+
*/
|
|
66
|
+
get exampleEntity() {
|
|
67
|
+
return this.getCachedSingleton(ExampleSingletonEntity_1.SingletonEntityExample.type);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Compares two view models to determine if they're equal
|
|
71
|
+
* Used to avoid unnecessary view updates when values haven't changed
|
|
72
|
+
*/
|
|
73
|
+
vmsAreEqual(a, b) {
|
|
74
|
+
if (a.aBoolProperty !== b.aBoolProperty)
|
|
75
|
+
return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
constructor(appObject) {
|
|
79
|
+
super(appObject, ExampleSingletonPM.type);
|
|
80
|
+
/**
|
|
81
|
+
* Handler for entity change events
|
|
82
|
+
* Transforms entity data into a view model and updates views
|
|
83
|
+
*/
|
|
84
|
+
this.onEntityChange = () => {
|
|
85
|
+
if (!this.exampleEntity)
|
|
86
|
+
return;
|
|
87
|
+
// Extract the boolean property from the entity
|
|
88
|
+
const aBoolProperty = this.exampleEntity.aBoolProperty;
|
|
89
|
+
// Create a view model with the extracted data
|
|
90
|
+
const vm = { aBoolProperty };
|
|
91
|
+
// Update all registered views with the new view model
|
|
92
|
+
this.doUpdateView(vm);
|
|
93
|
+
};
|
|
94
|
+
// Register as an observer of the entity to receive change notifications
|
|
95
|
+
this.exampleEntity?.addChangeObserver(this.onEntityChange);
|
|
96
|
+
// 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);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=ExampleSingletonPM.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ExamplePM"), exports);
|
|
18
|
+
__exportStar(require("./ExampleSingletonPM"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/PMs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,uDAAqC","sourcesContent":["export * from \"./ExamplePM\";\r\nexport * from \"./ExampleSingletonPM\";\r\n"]}
|