@vived/core 1.4.2 → 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 +142 -20
- package/dist/cjs/AppObject/AppObject.js +53 -0
- package/dist/cjs/AppObject/AppObject.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectComponent.js +78 -0
- package/dist/cjs/AppObject/AppObjectComponent.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectController.js +22 -0
- package/dist/cjs/AppObject/AppObjectController.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectEntity.js +52 -0
- package/dist/cjs/AppObject/AppObjectEntity.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectEntityRepo.js +75 -1
- package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectPM.js +46 -0
- package/dist/cjs/AppObject/AppObjectPM.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectRepo.js +20 -0
- package/dist/cjs/AppObject/AppObjectRepo.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectUC.js +23 -0
- package/dist/cjs/AppObject/AppObjectUC.js.map +1 -1
- package/dist/cjs/AppObject/AppObjectView.js +22 -0
- package/dist/cjs/AppObject/AppObjectView.js.map +1 -1
- package/dist/cjs/AppObject/getSingletonComponent.js +19 -0
- package/dist/cjs/AppObject/getSingletonComponent.js.map +1 -1
- package/dist/cjs/Entities/MemoizedAngle.js +21 -0
- package/dist/cjs/Entities/MemoizedAngle.js.map +1 -1
- package/dist/cjs/Entities/MemoizedBoolean.js +21 -0
- package/dist/cjs/Entities/MemoizedBoolean.js.map +1 -1
- package/dist/cjs/Entities/MemoizedColor.js +21 -0
- package/dist/cjs/Entities/MemoizedColor.js.map +1 -1
- package/dist/cjs/Entities/MemoizedNumber.js +21 -0
- package/dist/cjs/Entities/MemoizedNumber.js.map +1 -1
- package/dist/cjs/Entities/MemoizedQuaternion.js +21 -0
- package/dist/cjs/Entities/MemoizedQuaternion.js.map +1 -1
- package/dist/cjs/Entities/MemoizedString.js +21 -0
- package/dist/cjs/Entities/MemoizedString.js.map +1 -1
- package/dist/cjs/Entities/MemoizedVector2.js +21 -0
- package/dist/cjs/Entities/MemoizedVector2.js.map +1 -1
- package/dist/cjs/Entities/MemoizedVector3.js +21 -0
- package/dist/cjs/Entities/MemoizedVector3.js.map +1 -1
- package/dist/cjs/Entities/ObservableEntity.js +17 -0
- package/dist/cjs/Entities/ObservableEntity.js.map +1 -1
- package/dist/cjs/Entities/ObserverList.js +21 -0
- package/dist/cjs/Entities/ObserverList.js.map +1 -1
- package/dist/cjs/Entities/RangedNumber.js +29 -0
- package/dist/cjs/Entities/RangedNumber.js.map +1 -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/Types/PmAdapter.js.map +1 -1
- package/dist/cjs/Types/SingletonPmAdapter.js.map +1 -1
- package/dist/cjs/ValueObjects/Angle.js +1 -1
- package/dist/cjs/ValueObjects/Angle.js.map +1 -1
- package/dist/cjs/ValueObjects/LineSegment2D.js +6 -6
- package/dist/cjs/ValueObjects/LineSegment2D.js.map +1 -1
- package/dist/cjs/ValueObjects/Matrix.js +6 -6
- package/dist/cjs/ValueObjects/Matrix.js.map +1 -1
- package/dist/cjs/ValueObjects/Quaternion.js +17 -17
- package/dist/cjs/ValueObjects/Quaternion.js.map +1 -1
- package/dist/cjs/ValueObjects/Vector2.js +15 -8
- package/dist/cjs/ValueObjects/Vector2.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/AppObject/AppObject.js +53 -0
- package/dist/esm/AppObject/AppObject.js.map +1 -1
- package/dist/esm/AppObject/AppObjectComponent.js +78 -0
- package/dist/esm/AppObject/AppObjectComponent.js.map +1 -1
- package/dist/esm/AppObject/AppObjectController.js +22 -0
- package/dist/esm/AppObject/AppObjectController.js.map +1 -1
- package/dist/esm/AppObject/AppObjectEntity.js +52 -0
- package/dist/esm/AppObject/AppObjectEntity.js.map +1 -1
- package/dist/esm/AppObject/AppObjectEntityRepo.js +75 -1
- package/dist/esm/AppObject/AppObjectEntityRepo.js.map +1 -1
- package/dist/esm/AppObject/AppObjectPM.js +46 -0
- package/dist/esm/AppObject/AppObjectPM.js.map +1 -1
- package/dist/esm/AppObject/AppObjectRepo.js +20 -0
- package/dist/esm/AppObject/AppObjectRepo.js.map +1 -1
- package/dist/esm/AppObject/AppObjectUC.js +24 -1
- package/dist/esm/AppObject/AppObjectUC.js.map +1 -1
- package/dist/esm/AppObject/AppObjectView.js +23 -1
- package/dist/esm/AppObject/AppObjectView.js.map +1 -1
- package/dist/esm/AppObject/getSingletonComponent.js +19 -0
- package/dist/esm/AppObject/getSingletonComponent.js.map +1 -1
- package/dist/esm/Entities/MemoizedAngle.js +21 -0
- package/dist/esm/Entities/MemoizedAngle.js.map +1 -1
- package/dist/esm/Entities/MemoizedBoolean.js +21 -0
- package/dist/esm/Entities/MemoizedBoolean.js.map +1 -1
- package/dist/esm/Entities/MemoizedColor.js +21 -0
- package/dist/esm/Entities/MemoizedColor.js.map +1 -1
- package/dist/esm/Entities/MemoizedNumber.js +21 -0
- package/dist/esm/Entities/MemoizedNumber.js.map +1 -1
- package/dist/esm/Entities/MemoizedQuaternion.js +21 -0
- package/dist/esm/Entities/MemoizedQuaternion.js.map +1 -1
- package/dist/esm/Entities/MemoizedString.js +21 -0
- package/dist/esm/Entities/MemoizedString.js.map +1 -1
- package/dist/esm/Entities/MemoizedVector2.js +21 -0
- package/dist/esm/Entities/MemoizedVector2.js.map +1 -1
- package/dist/esm/Entities/MemoizedVector3.js +21 -0
- package/dist/esm/Entities/MemoizedVector3.js.map +1 -1
- package/dist/esm/Entities/ObservableEntity.js +17 -0
- package/dist/esm/Entities/ObservableEntity.js.map +1 -1
- package/dist/esm/Entities/ObserverList.js +21 -0
- package/dist/esm/Entities/ObserverList.js.map +1 -1
- package/dist/esm/Entities/RangedNumber.js +29 -0
- package/dist/esm/Entities/RangedNumber.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/Types/PmAdapter.js.map +1 -1
- package/dist/esm/Types/SingletonPmAdapter.js.map +1 -1
- package/dist/esm/ValueObjects/Angle.js +1 -1
- package/dist/esm/ValueObjects/Angle.js.map +1 -1
- package/dist/esm/ValueObjects/LineSegment2D.js +6 -6
- package/dist/esm/ValueObjects/LineSegment2D.js.map +1 -1
- package/dist/esm/ValueObjects/Matrix.js +6 -6
- package/dist/esm/ValueObjects/Matrix.js.map +1 -1
- package/dist/esm/ValueObjects/Quaternion.js +17 -17
- package/dist/esm/ValueObjects/Quaternion.js.map +1 -1
- package/dist/esm/ValueObjects/Vector2.js +15 -8
- package/dist/esm/ValueObjects/Vector2.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/AppObject/AppObject.d.ts +42 -0
- package/dist/types/AppObject/AppObject.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectComponent.d.ts +80 -0
- package/dist/types/AppObject/AppObjectComponent.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectController.d.ts +22 -0
- package/dist/types/AppObject/AppObjectController.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectEntity.d.ts +55 -0
- package/dist/types/AppObject/AppObjectEntity.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectEntityRepo.d.ts +75 -0
- package/dist/types/AppObject/AppObjectEntityRepo.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectPM.d.ts +53 -0
- package/dist/types/AppObject/AppObjectPM.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectRepo.d.ts +124 -0
- package/dist/types/AppObject/AppObjectRepo.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectUC.d.ts +23 -0
- package/dist/types/AppObject/AppObjectUC.d.ts.map +1 -1
- package/dist/types/AppObject/AppObjectView.d.ts +22 -0
- package/dist/types/AppObject/AppObjectView.d.ts.map +1 -1
- package/dist/types/AppObject/getSingletonComponent.d.ts +19 -0
- package/dist/types/AppObject/getSingletonComponent.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedAngle.d.ts +21 -0
- package/dist/types/Entities/MemoizedAngle.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedBoolean.d.ts +21 -0
- package/dist/types/Entities/MemoizedBoolean.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedColor.d.ts +21 -0
- package/dist/types/Entities/MemoizedColor.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedNumber.d.ts +21 -0
- package/dist/types/Entities/MemoizedNumber.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedQuaternion.d.ts +21 -0
- package/dist/types/Entities/MemoizedQuaternion.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedString.d.ts +21 -0
- package/dist/types/Entities/MemoizedString.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedVector2.d.ts +21 -0
- package/dist/types/Entities/MemoizedVector2.d.ts.map +1 -1
- package/dist/types/Entities/MemoizedVector3.d.ts +21 -0
- package/dist/types/Entities/MemoizedVector3.d.ts.map +1 -1
- package/dist/types/Entities/ObservableEntity.d.ts +20 -0
- package/dist/types/Entities/ObservableEntity.d.ts.map +1 -1
- package/dist/types/Entities/ObserverList.d.ts +21 -0
- package/dist/types/Entities/ObserverList.d.ts.map +1 -1
- package/dist/types/Entities/RangedNumber.d.ts +37 -0
- package/dist/types/Entities/RangedNumber.d.ts.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/Types/PmAdapter.d.ts +60 -0
- package/dist/types/Types/PmAdapter.d.ts.map +1 -1
- package/dist/types/Types/SingletonPmAdapter.d.ts +55 -0
- package/dist/types/Types/SingletonPmAdapter.d.ts.map +1 -1
- package/dist/types/ValueObjects/Angle.d.ts +1 -1
- package/dist/types/ValueObjects/Matrix.d.ts +5 -5
- package/dist/types/ValueObjects/Matrix.d.ts.map +1 -1
- package/dist/types/ValueObjects/Quaternion.d.ts +17 -17
- package/dist/types/ValueObjects/Vector2.d.ts +8 -3
- package/dist/types/ValueObjects/Vector2.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -4
- package/dist/cjs/AppObject/AppObject.test.js +0 -113
- package/dist/cjs/AppObject/AppObject.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectComponent.test.js +0 -132
- package/dist/cjs/AppObject/AppObjectComponent.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectEntity.test.js +0 -108
- package/dist/cjs/AppObject/AppObjectEntity.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectEntityRepo.test.js +0 -149
- package/dist/cjs/AppObject/AppObjectEntityRepo.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectPM.test.js +0 -103
- package/dist/cjs/AppObject/AppObjectPM.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectRepo.test.js +0 -213
- package/dist/cjs/AppObject/AppObjectRepo.test.js.map +0 -1
- package/dist/cjs/AppObject/getSingletonComponent.test.js +0 -13
- package/dist/cjs/AppObject/getSingletonComponent.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedAngle.test.js +0 -30
- package/dist/cjs/Entities/MemoizedAngle.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedBoolean.test.js +0 -34
- package/dist/cjs/Entities/MemoizedBoolean.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedColor.test.js +0 -32
- package/dist/cjs/Entities/MemoizedColor.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedNumber.test.js +0 -29
- package/dist/cjs/Entities/MemoizedNumber.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedQuaternion.test.js +0 -32
- package/dist/cjs/Entities/MemoizedQuaternion.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedString.test.js +0 -29
- package/dist/cjs/Entities/MemoizedString.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedVector2.test.js +0 -32
- package/dist/cjs/Entities/MemoizedVector2.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedVector3.test.js +0 -32
- package/dist/cjs/Entities/MemoizedVector3.test.js.map +0 -1
- package/dist/cjs/Entities/ObservableEntity.test.js +0 -25
- package/dist/cjs/Entities/ObservableEntity.test.js.map +0 -1
- package/dist/cjs/Entities/ObserverList.test.js +0 -44
- package/dist/cjs/Entities/ObserverList.test.js.map +0 -1
- package/dist/cjs/Entities/RangedNumber.test.js +0 -96
- package/dist/cjs/Entities/RangedNumber.test.js.map +0 -1
- package/dist/cjs/Utilities/LengthConverters.test.js +0 -24
- package/dist/cjs/Utilities/LengthConverters.test.js.map +0 -1
- package/dist/cjs/Utilities/LerpNumber.test.js +0 -90
- package/dist/cjs/Utilities/LerpNumber.test.js.map +0 -1
- package/dist/cjs/Utilities/addAlphaToHex.test.js +0 -34
- package/dist/cjs/Utilities/addAlphaToHex.test.js.map +0 -1
- package/dist/cjs/Utilities/alphaToHex.test.js +0 -75
- package/dist/cjs/Utilities/alphaToHex.test.js.map +0 -1
- package/dist/cjs/Utilities/degreesToRadians.test.js +0 -9
- package/dist/cjs/Utilities/degreesToRadians.test.js.map +0 -1
- package/dist/cjs/Utilities/easeFunctions.test.js +0 -209
- package/dist/cjs/Utilities/easeFunctions.test.js.map +0 -1
- package/dist/cjs/Utilities/interpolateNumber.test.js +0 -26
- package/dist/cjs/Utilities/interpolateNumber.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Angle.test.js +0 -28
- package/dist/cjs/ValueObjects/Angle.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Color.test.js +0 -147
- package/dist/cjs/ValueObjects/Color.test.js.map +0 -1
- package/dist/cjs/ValueObjects/LineSegment2D.test.js +0 -102
- package/dist/cjs/ValueObjects/LineSegment2D.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Matrix.test.js +0 -385
- package/dist/cjs/ValueObjects/Matrix.test.js.map +0 -1
- package/dist/cjs/ValueObjects/ParametricLine.test.js +0 -126
- package/dist/cjs/ValueObjects/ParametricLine.test.js.map +0 -1
- package/dist/cjs/ValueObjects/ParametricPlane.test.js +0 -101
- package/dist/cjs/ValueObjects/ParametricPlane.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Quaternion.test.js +0 -240
- package/dist/cjs/ValueObjects/Quaternion.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Rectangle.test.js +0 -32
- package/dist/cjs/ValueObjects/Rectangle.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Vector2.test.js +0 -136
- package/dist/cjs/ValueObjects/Vector2.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Vector3.test.js +0 -188
- package/dist/cjs/ValueObjects/Vector3.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Version.test.js +0 -310
- package/dist/cjs/ValueObjects/Version.test.js.map +0 -1
- package/dist/esm/AppObject/AppObject.test.js +0 -110
- package/dist/esm/AppObject/AppObject.test.js.map +0 -1
- package/dist/esm/AppObject/AppObjectComponent.test.js +0 -130
- package/dist/esm/AppObject/AppObjectComponent.test.js.map +0 -1
- package/dist/esm/AppObject/AppObjectEntity.test.js +0 -106
- package/dist/esm/AppObject/AppObjectEntity.test.js.map +0 -1
- package/dist/esm/AppObject/AppObjectEntityRepo.test.js +0 -147
- package/dist/esm/AppObject/AppObjectEntityRepo.test.js.map +0 -1
- package/dist/esm/AppObject/AppObjectPM.test.js +0 -101
- package/dist/esm/AppObject/AppObjectPM.test.js.map +0 -1
- package/dist/esm/AppObject/AppObjectRepo.test.js +0 -211
- package/dist/esm/AppObject/AppObjectRepo.test.js.map +0 -1
- package/dist/esm/AppObject/getSingletonComponent.test.js +0 -11
- package/dist/esm/AppObject/getSingletonComponent.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedAngle.test.js +0 -28
- package/dist/esm/Entities/MemoizedAngle.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedBoolean.test.js +0 -32
- package/dist/esm/Entities/MemoizedBoolean.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedColor.test.js +0 -30
- package/dist/esm/Entities/MemoizedColor.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedNumber.test.js +0 -27
- package/dist/esm/Entities/MemoizedNumber.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedQuaternion.test.js +0 -30
- package/dist/esm/Entities/MemoizedQuaternion.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedString.test.js +0 -27
- package/dist/esm/Entities/MemoizedString.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedVector2.test.js +0 -30
- package/dist/esm/Entities/MemoizedVector2.test.js.map +0 -1
- package/dist/esm/Entities/MemoizedVector3.test.js +0 -30
- package/dist/esm/Entities/MemoizedVector3.test.js.map +0 -1
- package/dist/esm/Entities/ObservableEntity.test.js +0 -23
- package/dist/esm/Entities/ObservableEntity.test.js.map +0 -1
- package/dist/esm/Entities/ObserverList.test.js +0 -42
- package/dist/esm/Entities/ObserverList.test.js.map +0 -1
- package/dist/esm/Entities/RangedNumber.test.js +0 -94
- package/dist/esm/Entities/RangedNumber.test.js.map +0 -1
- package/dist/esm/Utilities/LengthConverters.test.js +0 -22
- package/dist/esm/Utilities/LengthConverters.test.js.map +0 -1
- package/dist/esm/Utilities/LerpNumber.test.js +0 -88
- package/dist/esm/Utilities/LerpNumber.test.js.map +0 -1
- package/dist/esm/Utilities/addAlphaToHex.test.js +0 -32
- package/dist/esm/Utilities/addAlphaToHex.test.js.map +0 -1
- package/dist/esm/Utilities/alphaToHex.test.js +0 -73
- package/dist/esm/Utilities/alphaToHex.test.js.map +0 -1
- package/dist/esm/Utilities/degreesToRadians.test.js +0 -7
- package/dist/esm/Utilities/degreesToRadians.test.js.map +0 -1
- package/dist/esm/Utilities/easeFunctions.test.js +0 -207
- package/dist/esm/Utilities/easeFunctions.test.js.map +0 -1
- package/dist/esm/Utilities/interpolateNumber.test.js +0 -24
- package/dist/esm/Utilities/interpolateNumber.test.js.map +0 -1
- package/dist/esm/ValueObjects/Angle.test.js +0 -26
- package/dist/esm/ValueObjects/Angle.test.js.map +0 -1
- package/dist/esm/ValueObjects/Color.test.js +0 -145
- package/dist/esm/ValueObjects/Color.test.js.map +0 -1
- package/dist/esm/ValueObjects/LineSegment2D.test.js +0 -100
- package/dist/esm/ValueObjects/LineSegment2D.test.js.map +0 -1
- package/dist/esm/ValueObjects/Matrix.test.js +0 -383
- package/dist/esm/ValueObjects/Matrix.test.js.map +0 -1
- package/dist/esm/ValueObjects/ParametricLine.test.js +0 -124
- package/dist/esm/ValueObjects/ParametricLine.test.js.map +0 -1
- package/dist/esm/ValueObjects/ParametricPlane.test.js +0 -99
- package/dist/esm/ValueObjects/ParametricPlane.test.js.map +0 -1
- package/dist/esm/ValueObjects/Quaternion.test.js +0 -238
- package/dist/esm/ValueObjects/Quaternion.test.js.map +0 -1
- package/dist/esm/ValueObjects/Rectangle.test.js +0 -30
- package/dist/esm/ValueObjects/Rectangle.test.js.map +0 -1
- package/dist/esm/ValueObjects/Vector2.test.js +0 -134
- package/dist/esm/ValueObjects/Vector2.test.js.map +0 -1
- package/dist/esm/ValueObjects/Vector3.test.js +0 -186
- package/dist/esm/ValueObjects/Vector3.test.js.map +0 -1
- package/dist/esm/ValueObjects/Version.test.js +0 -308
- package/dist/esm/ValueObjects/Version.test.js.map +0 -1
- package/dist/types/AppObject/AppObject.test.d.ts +0 -7
- package/dist/types/AppObject/AppObject.test.d.ts.map +0 -1
- package/dist/types/AppObject/AppObjectComponent.test.d.ts +0 -2
- package/dist/types/AppObject/AppObjectComponent.test.d.ts.map +0 -1
- package/dist/types/AppObject/AppObjectEntity.test.d.ts +0 -2
- package/dist/types/AppObject/AppObjectEntity.test.d.ts.map +0 -1
- package/dist/types/AppObject/AppObjectEntityRepo.test.d.ts +0 -2
- package/dist/types/AppObject/AppObjectEntityRepo.test.d.ts.map +0 -1
- package/dist/types/AppObject/AppObjectPM.test.d.ts +0 -2
- package/dist/types/AppObject/AppObjectPM.test.d.ts.map +0 -1
- package/dist/types/AppObject/AppObjectRepo.test.d.ts +0 -2
- package/dist/types/AppObject/AppObjectRepo.test.d.ts.map +0 -1
- package/dist/types/AppObject/getSingletonComponent.test.d.ts +0 -2
- package/dist/types/AppObject/getSingletonComponent.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedAngle.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedAngle.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedBoolean.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedBoolean.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedColor.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedColor.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedNumber.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedNumber.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedQuaternion.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedQuaternion.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedString.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedString.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedVector2.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedVector2.test.d.ts.map +0 -1
- package/dist/types/Entities/MemoizedVector3.test.d.ts +0 -2
- package/dist/types/Entities/MemoizedVector3.test.d.ts.map +0 -1
- package/dist/types/Entities/ObservableEntity.test.d.ts +0 -2
- package/dist/types/Entities/ObservableEntity.test.d.ts.map +0 -1
- package/dist/types/Entities/ObserverList.test.d.ts +0 -2
- package/dist/types/Entities/ObserverList.test.d.ts.map +0 -1
- package/dist/types/Entities/RangedNumber.test.d.ts +0 -2
- package/dist/types/Entities/RangedNumber.test.d.ts.map +0 -1
- package/dist/types/Utilities/LengthConverters.test.d.ts +0 -2
- package/dist/types/Utilities/LengthConverters.test.d.ts.map +0 -1
- package/dist/types/Utilities/LerpNumber.test.d.ts +0 -2
- package/dist/types/Utilities/LerpNumber.test.d.ts.map +0 -1
- package/dist/types/Utilities/addAlphaToHex.test.d.ts +0 -2
- package/dist/types/Utilities/addAlphaToHex.test.d.ts.map +0 -1
- package/dist/types/Utilities/alphaToHex.test.d.ts +0 -2
- package/dist/types/Utilities/alphaToHex.test.d.ts.map +0 -1
- package/dist/types/Utilities/degreesToRadians.test.d.ts +0 -2
- package/dist/types/Utilities/degreesToRadians.test.d.ts.map +0 -1
- package/dist/types/Utilities/easeFunctions.test.d.ts +0 -2
- package/dist/types/Utilities/easeFunctions.test.d.ts.map +0 -1
- package/dist/types/Utilities/interpolateNumber.test.d.ts +0 -2
- package/dist/types/Utilities/interpolateNumber.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Angle.test.d.ts +0 -2
- package/dist/types/ValueObjects/Angle.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Color.test.d.ts +0 -2
- package/dist/types/ValueObjects/Color.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/LineSegment2D.test.d.ts +0 -2
- package/dist/types/ValueObjects/LineSegment2D.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Matrix.test.d.ts +0 -2
- package/dist/types/ValueObjects/Matrix.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/ParametricLine.test.d.ts +0 -2
- package/dist/types/ValueObjects/ParametricLine.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/ParametricPlane.test.d.ts +0 -2
- package/dist/types/ValueObjects/ParametricPlane.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Quaternion.test.d.ts +0 -2
- package/dist/types/ValueObjects/Quaternion.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Rectangle.test.d.ts +0 -2
- package/dist/types/ValueObjects/Rectangle.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Vector2.test.d.ts +0 -2
- package/dist/types/ValueObjects/Vector2.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Vector3.test.d.ts +0 -2
- package/dist/types/ValueObjects/Vector3.test.d.ts.map +0 -1
- package/dist/types/ValueObjects/Version.test.d.ts +0 -2
- package/dist/types/ValueObjects/Version.test.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,29 +1,151 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vived/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Core Components for VIVED Apps and Hosts
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Version
|
|
9
|
-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
7
|
+
@vived/core provides foundational architecture components used across VIVED applications. This library implements a component-based architecture pattern that enables building complex applications with proper separation of concerns.
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
## Installation
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
11
|
+
```bash
|
|
12
|
+
npm install @vived/core
|
|
13
|
+
```
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
## Core Concepts
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
* Code review
|
|
24
|
-
* Other guidelines
|
|
17
|
+
The package is built around the "AppObject" architecture, which follows a component-based design pattern:
|
|
25
18
|
|
|
26
|
-
###
|
|
19
|
+
### AppObject
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
- The central entity that acts as a container for components
|
|
22
|
+
- Each AppObject has a unique ID and belongs to an AppObjectRepo
|
|
23
|
+
- Components can be added, removed, and queried
|
|
24
|
+
- AppObjects are observable entities, notifying observers when components change
|
|
25
|
+
|
|
26
|
+
### AppObjectRepo
|
|
27
|
+
|
|
28
|
+
- Manages a collection of AppObjects
|
|
29
|
+
- Provides methods to find, create, and manage AppObjects
|
|
30
|
+
- Handles singleton components across the application
|
|
31
|
+
- Includes logging infrastructure for debugging
|
|
32
|
+
|
|
33
|
+
### Component Types
|
|
34
|
+
|
|
35
|
+
The architecture implements a clean separation of concerns through specialized components:
|
|
36
|
+
|
|
37
|
+
1. **Entity (AppObjectEntity)**
|
|
38
|
+
- Holds and manages application state
|
|
39
|
+
- Provides change notifications when state is modified
|
|
40
|
+
|
|
41
|
+
2. **Presentation Manager (AppObjectPM)**
|
|
42
|
+
- Manages view models for UI representation
|
|
43
|
+
- Transforms application state into UI-ready data
|
|
44
|
+
- Notifies views when view models change
|
|
45
|
+
|
|
46
|
+
3. **Use Case (AppObjectUC)**
|
|
47
|
+
- Implements business logic
|
|
48
|
+
- Coordinates between data layer and presentation
|
|
49
|
+
|
|
50
|
+
4. **Controller (AppObjectController)**
|
|
51
|
+
- Handles external inputs (user actions, system events)
|
|
52
|
+
- Delegates to appropriate use cases
|
|
53
|
+
|
|
54
|
+
5. **View (AppObjectView)**
|
|
55
|
+
- UI representation components
|
|
56
|
+
- Consumes view models and renders UI
|
|
57
|
+
|
|
58
|
+
## Example Implementation
|
|
59
|
+
|
|
60
|
+
The package includes a fully implemented `ExampleFeature` that demonstrates the App Object Component architecture. This example demonstrates how to structure your code following the recommended patterns:
|
|
61
|
+
|
|
62
|
+
### Directory Structure
|
|
63
|
+
- **Entities/** - Domain models for storing and managing state
|
|
64
|
+
- **PMs/** - Presentation Managers that transform data for UI consumption
|
|
65
|
+
- **UCs/** - Use Cases that implement business logic operations
|
|
66
|
+
- **Controllers/** - Simplified API for UI interaction
|
|
67
|
+
- **Adapters/** - Connect UI frameworks to PMs
|
|
68
|
+
- **Mocks/** - Test doubles for unit testing
|
|
69
|
+
|
|
70
|
+
### Implementation Patterns
|
|
71
|
+
The example demonstrates:
|
|
72
|
+
- Observable entities with memoized properties
|
|
73
|
+
- Presentation managers with view model transformation
|
|
74
|
+
- Use cases that implement business logic
|
|
75
|
+
- Controllers that provide a simple UI-friendly API
|
|
76
|
+
- Component registration and retrieval
|
|
77
|
+
- Singleton component access
|
|
78
|
+
- Test patterns for each component type
|
|
79
|
+
|
|
80
|
+
### Sample Usage
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// Create a repository and an app object
|
|
84
|
+
const repo = makeAppObjectRepo();
|
|
85
|
+
const appObject = repo.getOrCreate("myObject");
|
|
86
|
+
|
|
87
|
+
// Add an entity component to hold state
|
|
88
|
+
class MyEntity extends AppObjectEntity {
|
|
89
|
+
private _value = 0;
|
|
90
|
+
|
|
91
|
+
get value() { return this._value; }
|
|
92
|
+
set value(newValue: number) {
|
|
93
|
+
this._value = newValue;
|
|
94
|
+
this.notifyOnChange();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Add the entity to the app object
|
|
99
|
+
const entity = new MyEntity(appObject, "MyEntity");
|
|
100
|
+
|
|
101
|
+
// Create a presentation manager
|
|
102
|
+
class MyPM extends AppObjectPM<{value: number}> {
|
|
103
|
+
vmsAreEqual(a: {value: number}, b: {value: number}): boolean {
|
|
104
|
+
return a.value === b.value;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
updateViewModel() {
|
|
108
|
+
const entity = this.getCachedLocalComponent<MyEntity>("MyEntity");
|
|
109
|
+
if (entity) {
|
|
110
|
+
this.doUpdateView({value: entity.value});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// The architecture enables clean, testable, and maintainable code
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Refer to the `ExampleFeature` directory for a complete implementation example that shows the interaction between all component types.
|
|
119
|
+
|
|
120
|
+
## Value Objects
|
|
121
|
+
|
|
122
|
+
The package provides immutable value objects for mathematical and graphical operations:
|
|
123
|
+
|
|
124
|
+
### Geometric & Mathematical Types
|
|
125
|
+
- **Vector2**: 2D vector with operations like addition, dot product, rotation, and unit vector calculation
|
|
126
|
+
- **Vector3**: 3D vector with similar operations plus cross product and coordinate transformations
|
|
127
|
+
- **Quaternion**: For 3D rotations with methods for creation from angles, Euler angles, and matrices plus interpolation
|
|
128
|
+
- **Matrix**: For transformation operations like translation, rotation, and scaling
|
|
129
|
+
- **Angle**: Encapsulates angle values with automatic conversion between degrees and radians
|
|
130
|
+
- **Rectangle**: For 2D rectangular regions with intersection testing
|
|
131
|
+
|
|
132
|
+
### Parametric Geometry
|
|
133
|
+
- **ParametricLine**: Represents lines with point and direction for intersection calculations
|
|
134
|
+
- **ParametricPlane**: Represents planes with point and normal for 3D geometric operations
|
|
135
|
+
- **LineSegment2D**: Represents finite line segments with intersection testing
|
|
136
|
+
|
|
137
|
+
### Graphics & Utilities
|
|
138
|
+
- **Color**: RGBA color representation with utility methods for conversion between formats (RGB, Hex, X11 names)
|
|
139
|
+
- **Version**: Semantic versioning implementation with comparison operators
|
|
140
|
+
|
|
141
|
+
## Utilities
|
|
142
|
+
|
|
143
|
+
The package also includes various utility functions:
|
|
144
|
+
- Color manipulation (adding alpha to hex, converting alpha to hex)
|
|
145
|
+
- Length converters for different measurement systems
|
|
146
|
+
- Linear interpolation and easing functions
|
|
147
|
+
- Angle conversion between degrees and radians
|
|
148
|
+
- File operations like downloading
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
ISC
|
|
@@ -3,16 +3,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppObject = void 0;
|
|
4
4
|
exports.makeAppObject = makeAppObject;
|
|
5
5
|
const Entities_1 = require("../Entities");
|
|
6
|
+
/**
|
|
7
|
+
* AppObject is the central class in the VIVED application architecture.
|
|
8
|
+
* It serves as a container for components that implement the application's functionality.
|
|
9
|
+
* Each AppObject is identified by a unique ID and registered with an AppObjectRepo.
|
|
10
|
+
*
|
|
11
|
+
* AppObjects are observable entities that notify observers when their components change.
|
|
12
|
+
* This enables reactive programming patterns throughout the application.
|
|
13
|
+
*/
|
|
6
14
|
class AppObject extends Entities_1.ObservableEntity {
|
|
7
15
|
}
|
|
8
16
|
exports.AppObject = AppObject;
|
|
17
|
+
/**
|
|
18
|
+
* Factory function to create a new AppObject
|
|
19
|
+
* @param id Unique identifier for the new AppObject
|
|
20
|
+
* @param repo Repository to register the AppObject with
|
|
21
|
+
* @returns A new AppObject instance
|
|
22
|
+
*/
|
|
9
23
|
function makeAppObject(id, repo) {
|
|
10
24
|
return new AppObjectImp(id, repo);
|
|
11
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Implementation of the AppObject abstract class
|
|
28
|
+
* This class handles the component management functionality
|
|
29
|
+
*/
|
|
12
30
|
class AppObjectImp extends AppObject {
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a component of the specified type exists
|
|
33
|
+
* @param type The component type identifier
|
|
34
|
+
* @returns True if the component exists, false otherwise
|
|
35
|
+
*/
|
|
13
36
|
hasComponent(type) {
|
|
14
37
|
return this.componentLookup.has(type);
|
|
15
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Adds a component to this AppObject
|
|
41
|
+
* If a component of the same type already exists, it will be disposed and replaced
|
|
42
|
+
* Notifies observers after adding the component
|
|
43
|
+
* @param component The component to add
|
|
44
|
+
*/
|
|
16
45
|
addComponent(component) {
|
|
17
46
|
const currentComponent = this.componentLookup.get(component.type);
|
|
18
47
|
if (currentComponent) {
|
|
@@ -22,6 +51,11 @@ class AppObjectImp extends AppObject {
|
|
|
22
51
|
this.componentLookup.set(component.type, component);
|
|
23
52
|
this.notify();
|
|
24
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves a component by type
|
|
56
|
+
* @param type The component type identifier
|
|
57
|
+
* @returns The component cast to type T, or undefined if not found
|
|
58
|
+
*/
|
|
25
59
|
getComponent(type) {
|
|
26
60
|
if (this.componentLookup.has(type)) {
|
|
27
61
|
return this.componentLookup.get(type);
|
|
@@ -30,6 +64,10 @@ class AppObjectImp extends AppObject {
|
|
|
30
64
|
return undefined;
|
|
31
65
|
}
|
|
32
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Removes a component by type and notifies observers
|
|
69
|
+
* @param type The component type identifier
|
|
70
|
+
*/
|
|
33
71
|
removeComponent(type) {
|
|
34
72
|
const component = this.componentLookup.get(type);
|
|
35
73
|
if (!component)
|
|
@@ -37,12 +75,27 @@ class AppObjectImp extends AppObject {
|
|
|
37
75
|
this.componentLookup.delete(type);
|
|
38
76
|
this.notify();
|
|
39
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets all components attached to this AppObject
|
|
80
|
+
* @returns Array of all components
|
|
81
|
+
*/
|
|
40
82
|
allComponents() {
|
|
41
83
|
return Array.from(this.componentLookup.values());
|
|
42
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new AppObject instance
|
|
87
|
+
* @param id Unique identifier for this AppObject
|
|
88
|
+
* @param repo Repository to register with
|
|
89
|
+
*/
|
|
43
90
|
constructor(id, repo) {
|
|
44
91
|
super();
|
|
92
|
+
/** Map of component types to component instances */
|
|
45
93
|
this.componentLookup = new Map();
|
|
94
|
+
/**
|
|
95
|
+
* Cleans up resources by:
|
|
96
|
+
* 1. Disposing all attached components
|
|
97
|
+
* 2. Removing this AppObject from its repository
|
|
98
|
+
*/
|
|
46
99
|
this.dispose = () => {
|
|
47
100
|
const components = Array.from(this.componentLookup.values());
|
|
48
101
|
this.componentLookup.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppObject.js","sourceRoot":"","sources":["../../../src/AppObject/AppObject.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AppObject.js","sourceRoot":"","sources":["../../../src/AppObject/AppObject.ts"],"names":[],"mappings":";;;AAgEA,sCAEC;AAlED,0CAA+C;AAI/C;;;;;;;GAOG;AACH,MAAsB,SAAU,SAAQ,2BAAgB;CA4CvD;AA5CD,8BA4CC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,EAAU,EAAE,IAAmB;IAC3D,OAAO,IAAI,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,YAAa,SAAQ,SAAS;IAOlC;;;;OAIG;IACH,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,SAA6B;QACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClE,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CACV,yBAAyB,SAAS,CAAC,IAAI,yBAAyB,IAAI,CAAC,EAAE,EAAE,CAC1E,CAAC;YACF,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,YAAY,CAA+B,IAAY;QACrD,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAM,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,IAAY;QAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;IAiBD;;;;OAIG;IACH,YAAY,EAAU,EAAE,IAAmB;QACzC,KAAK,EAAE,CAAC;QAtFV,oDAAoD;QAC5C,oBAAe,GAAG,IAAI,GAAG,EAA8B,CAAC;QAgEhE;;;;WAIG;QACH,YAAO,GAAG,GAAS,EAAE;YACnB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7D,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC7B,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAErC,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC,CAAC;QASA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import { ObservableEntity } from \"../Entities\";\r\nimport { AppObjectComponent } from \"./AppObjectComponent\";\r\nimport { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\n/**\r\n * AppObject is the central class in the VIVED application architecture.\r\n * It serves as a container for components that implement the application's functionality.\r\n * Each AppObject is identified by a unique ID and registered with an AppObjectRepo.\r\n * \r\n * AppObjects are observable entities that notify observers when their components change.\r\n * This enables reactive programming patterns throughout the application.\r\n */\r\nexport abstract class AppObject extends ObservableEntity {\r\n /** Unique identifier for this AppObject */\r\n abstract readonly id: string;\r\n \r\n /** Repository that manages this AppObject */\r\n abstract readonly appObjectRepo: AppObjectRepo;\r\n\r\n /**\r\n * Checks if this AppObject has a component of the specified type\r\n * @param type The component type identifier\r\n * @returns True if the component exists, false otherwise\r\n */\r\n abstract hasComponent(type: string): boolean;\r\n \r\n /**\r\n * Adds a component to this AppObject\r\n * If a component of the same type already exists, it will be replaced\r\n * @param component The component to add\r\n */\r\n abstract addComponent(component: AppObjectComponent): void;\r\n \r\n /**\r\n * Retrieves a component by type\r\n * @param type The component type identifier\r\n * @returns The component cast to type T, or undefined if not found\r\n */\r\n abstract getComponent<T extends AppObjectComponent>(type: string): T | undefined;\r\n \r\n /**\r\n * Removes a component by type\r\n * @param type The component type identifier\r\n */\r\n abstract removeComponent(type: string): void;\r\n \r\n /**\r\n * Gets all components attached to this AppObject\r\n * @returns Array of all components\r\n */\r\n abstract allComponents(): AppObjectComponent[];\r\n\r\n /**\r\n * Cleans up resources and removes this AppObject from its repository\r\n */\r\n abstract dispose(): void;\r\n}\r\n\r\n/**\r\n * Factory function to create a new AppObject\r\n * @param id Unique identifier for the new AppObject\r\n * @param repo Repository to register the AppObject with\r\n * @returns A new AppObject instance\r\n */\r\nexport function makeAppObject(id: string, repo: AppObjectRepo): AppObject {\r\n return new AppObjectImp(id, repo);\r\n}\r\n\r\n/**\r\n * Implementation of the AppObject abstract class\r\n * This class handles the component management functionality\r\n */\r\nclass AppObjectImp extends AppObject {\r\n readonly id: string;\r\n readonly appObjectRepo: AppObjectRepo;\r\n\r\n /** Map of component types to component instances */\r\n private componentLookup = new Map<string, AppObjectComponent>();\r\n\r\n /**\r\n * Checks if a component of the specified type exists\r\n * @param type The component type identifier\r\n * @returns True if the component exists, false otherwise\r\n */\r\n hasComponent(type: string): boolean {\r\n return this.componentLookup.has(type);\r\n }\r\n\r\n /**\r\n * Adds a component to this AppObject\r\n * If a component of the same type already exists, it will be disposed and replaced\r\n * Notifies observers after adding the component\r\n * @param component The component to add\r\n */\r\n addComponent(component: AppObjectComponent): void {\r\n const currentComponent = this.componentLookup.get(component.type);\r\n if (currentComponent) {\r\n console.warn(\r\n `[AppObject] Component ${component.type} is being replaced on ${this.id}`\r\n );\r\n currentComponent.dispose();\r\n }\r\n\r\n this.componentLookup.set(component.type, component);\r\n this.notify();\r\n }\r\n\r\n /**\r\n * Retrieves a component by type\r\n * @param type The component type identifier\r\n * @returns The component cast to type T, or undefined if not found\r\n */\r\n getComponent<T extends AppObjectComponent>(type: string): T | undefined {\r\n if (this.componentLookup.has(type)) {\r\n return this.componentLookup.get(type) as T;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Removes a component by type and notifies observers\r\n * @param type The component type identifier\r\n */\r\n removeComponent(type: string): void {\r\n const component = this.componentLookup.get(type);\r\n\r\n if (!component) return;\r\n\r\n this.componentLookup.delete(type);\r\n this.notify();\r\n }\r\n\r\n /**\r\n * Gets all components attached to this AppObject\r\n * @returns Array of all components\r\n */\r\n allComponents(): AppObjectComponent[] {\r\n return Array.from(this.componentLookup.values());\r\n }\r\n\r\n /**\r\n * Cleans up resources by:\r\n * 1. Disposing all attached components\r\n * 2. Removing this AppObject from its repository\r\n */\r\n dispose = (): void => {\r\n const components = Array.from(this.componentLookup.values());\r\n this.componentLookup.clear();\r\n components.forEach(c => c.dispose());\r\n\r\n if (this.appObjectRepo.has(this.id)) {\r\n this.appObjectRepo.remove(this.id);\r\n }\r\n };\r\n\r\n /**\r\n * Creates a new AppObject instance\r\n * @param id Unique identifier for this AppObject\r\n * @param repo Repository to register with\r\n */\r\n constructor(id: string, repo: AppObjectRepo) {\r\n super();\r\n this.id = id;\r\n this.appObjectRepo = repo;\r\n this.appObjectRepo.add(this);\r\n }\r\n}\r\n"]}
|
|
@@ -1,19 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppObjectComponent = exports.AppObjectComponentType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enumeration of the different types of components in the architecture.
|
|
6
|
+
* Each type serves a specific purpose in the application structure.
|
|
7
|
+
*/
|
|
4
8
|
var AppObjectComponentType;
|
|
5
9
|
(function (AppObjectComponentType) {
|
|
10
|
+
/** Stores and manages application state */
|
|
6
11
|
AppObjectComponentType["ENTITY"] = "Entity";
|
|
12
|
+
/** Transforms application state into view models */
|
|
7
13
|
AppObjectComponentType["PM"] = "Presentation Manager";
|
|
14
|
+
/** Implements business logic and coordinates between layers */
|
|
8
15
|
AppObjectComponentType["UC"] = "Use Case";
|
|
16
|
+
/** Handles user inputs and external events */
|
|
9
17
|
AppObjectComponentType["CONTROLLER"] = "Controller";
|
|
18
|
+
/** Renders UI elements and interacts with the DOM/rendering system */
|
|
10
19
|
AppObjectComponentType["VIEW"] = "View";
|
|
20
|
+
/** Default type for components that don't fit the standard categories */
|
|
11
21
|
AppObjectComponentType["UNKNOWN"] = "Unknown";
|
|
12
22
|
})(AppObjectComponentType || (exports.AppObjectComponentType = AppObjectComponentType = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Base class for all components in the AppObject architecture.
|
|
25
|
+
*
|
|
26
|
+
* Components attach to AppObjects and provide specific functionality based on their type.
|
|
27
|
+
* The architecture follows a clean separation of concerns, with each component type
|
|
28
|
+
* having a well-defined responsibility in the application.
|
|
29
|
+
*
|
|
30
|
+
* Components can communicate with each other through various mechanisms:
|
|
31
|
+
* - Direct access via parent AppObject
|
|
32
|
+
* - Repository-level singleton access
|
|
33
|
+
* - Observer patterns for reactive updates
|
|
34
|
+
*/
|
|
13
35
|
class AppObjectComponent {
|
|
36
|
+
/**
|
|
37
|
+
* Convenience accessor for the repository containing all AppObjects
|
|
38
|
+
* @returns The application's AppObjectRepo
|
|
39
|
+
*/
|
|
14
40
|
get appObjects() {
|
|
15
41
|
return this.appObject.appObjectRepo;
|
|
16
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves a singleton component of the specified type from the repository
|
|
45
|
+
* Results are cached for better performance in repeated calls
|
|
46
|
+
*
|
|
47
|
+
* @param type The component type identifier to look up
|
|
48
|
+
* @returns The singleton component cast to type T, or undefined if not found
|
|
49
|
+
*/
|
|
17
50
|
getCachedSingleton(type) {
|
|
18
51
|
if (!this.cachedComponents.has(type)) {
|
|
19
52
|
const component = this.appObjects.getSingleton(type);
|
|
@@ -26,6 +59,13 @@ class AppObjectComponent {
|
|
|
26
59
|
}
|
|
27
60
|
return this.cachedComponents.get(type);
|
|
28
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves a component from the same AppObject as this component
|
|
64
|
+
* Results are cached for better performance in repeated calls
|
|
65
|
+
*
|
|
66
|
+
* @param type The component type identifier to look up
|
|
67
|
+
* @returns The component cast to type T, or undefined if not found
|
|
68
|
+
*/
|
|
29
69
|
getCachedLocalComponent(type) {
|
|
30
70
|
if (!this.cachedComponents.has(type)) {
|
|
31
71
|
const component = this.appObject.getComponent(type);
|
|
@@ -38,6 +78,14 @@ class AppObjectComponent {
|
|
|
38
78
|
}
|
|
39
79
|
return this.cachedComponents.get(type);
|
|
40
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves a singleton component from the repository with customizable logging
|
|
83
|
+
* Unlike getCachedSingleton, results are not cached
|
|
84
|
+
*
|
|
85
|
+
* @param type The component type identifier to look up
|
|
86
|
+
* @param logType The severity level for logging if component isn't found
|
|
87
|
+
* @returns The singleton component cast to type T, or undefined if not found
|
|
88
|
+
*/
|
|
41
89
|
getSingleton(type, logType = "WARN") {
|
|
42
90
|
const comp = this.appObjects.getSingleton(type);
|
|
43
91
|
if (!comp) {
|
|
@@ -56,22 +104,52 @@ class AppObjectComponent {
|
|
|
56
104
|
}
|
|
57
105
|
return comp;
|
|
58
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Cleans up resources used by this component
|
|
109
|
+
* Removes itself from the parent AppObject if it's still attached
|
|
110
|
+
*/
|
|
59
111
|
dispose() {
|
|
60
112
|
if (this.appObject.getComponent(this.type) === this) {
|
|
61
113
|
this.appObject.removeComponent(this.type);
|
|
62
114
|
}
|
|
63
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Logs an informational message to the application's logging system
|
|
118
|
+
* Messages are prefixed with the AppObject ID and component type for easier debugging
|
|
119
|
+
*
|
|
120
|
+
* @param message The message to log
|
|
121
|
+
*/
|
|
64
122
|
log(message) {
|
|
65
123
|
this.appObjects.submitLog(`${this.appObject.id}/${this.type}`, message);
|
|
66
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Logs a warning message to the application's logging system
|
|
127
|
+
* Messages are prefixed with the AppObject ID and component type for easier debugging
|
|
128
|
+
*
|
|
129
|
+
* @param message The warning message to log
|
|
130
|
+
*/
|
|
67
131
|
warn(message) {
|
|
68
132
|
this.appObjects.submitWarning(`${this.appObject.id}/${this.type}`, message);
|
|
69
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Logs an error message to the application's logging system
|
|
136
|
+
* Messages are prefixed with the AppObject ID and component type for easier debugging
|
|
137
|
+
*
|
|
138
|
+
* @param message The error message to log
|
|
139
|
+
*/
|
|
70
140
|
error(message) {
|
|
71
141
|
this.appObjects.submitError(`${this.appObject.id}/${this.type}`, message);
|
|
72
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new component and attaches it to the specified AppObject
|
|
145
|
+
*
|
|
146
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
147
|
+
* @param type The unique type identifier for this component
|
|
148
|
+
*/
|
|
73
149
|
constructor(appObject, type) {
|
|
150
|
+
/** The type category of this component */
|
|
74
151
|
this.componentType = AppObjectComponentType.UNKNOWN;
|
|
152
|
+
/** Cache for components to avoid repeated lookups */
|
|
75
153
|
this.cachedComponents = new Map();
|
|
76
154
|
this.appObject = appObject;
|
|
77
155
|
this.type = type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppObjectComponent.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectComponent.ts"],"names":[],"mappings":";;;AAGA,IAAY,
|
|
1
|
+
{"version":3,"file":"AppObjectComponent.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectComponent.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,IAAY,sBAkBX;AAlBD,WAAY,sBAAsB;IAChC,2CAA2C;IAC3C,2CAAiB,CAAA;IAEjB,oDAAoD;IACpD,qDAA2B,CAAA;IAE3B,+DAA+D;IAC/D,yCAAe,CAAA;IAEf,8CAA8C;IAC9C,mDAAyB,CAAA;IAEzB,sEAAsE;IACtE,uCAAa,CAAA;IAEb,yEAAyE;IACzE,6CAAmB,CAAA;AACrB,CAAC,EAlBW,sBAAsB,sCAAtB,sBAAsB,QAkBjC;AAED;;;;;;;;;;;GAWG;AACH,MAAa,kBAAkB;IAU7B;;;OAGG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC,CAAC;IAKD;;;;;;OAMG;IACH,kBAAkB,CAChB,IAAY;QAEZ,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,sCAAsC,GAAG,IAAI,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAM,CAAC;IAC9C,CAAC;IAED;;;;;;OAMG;IACH,uBAAuB,CACrB,IAAY;QAEZ,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAEpD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,wCAAwC,GAAG,IAAI,CAAC,CAAC;YAC7D,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAM,CAAC;IAC9C,CAAC;IAED;;;;;;;OAOG;IACH,YAAY,CACV,IAAY,EACZ,UAAoC,MAAM;QAE1C,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAI,IAAI,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,GAAG,GAAG,+BAA+B,GAAG,IAAI,CAAC;YACnD,QAAQ,OAAO,EAAE,CAAC;gBAChB,KAAK,OAAO;oBACV,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAChB,MAAM;gBACR,KAAK,KAAK;oBACR,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBACd,MAAM;gBACR,KAAK,MAAM;oBACT,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACf,MAAM;YACV,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACpD,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,OAAe;QACjB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACH,YAAY,SAAoB,EAAE,IAAY;QA/I9C,0CAA0C;QACjC,kBAAa,GAA2B,sBAAsB,CAAC,OAAO,CAAC;QAgBhF,qDAAqD;QAC7C,qBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;QA8H/D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AArJD,gDAqJC","sourcesContent":["import { AppObject } from \"./AppObject\";\r\nimport { AppObjectRepo } from \"./AppObjectRepo\";\r\n\r\n/**\r\n * Enumeration of the different types of components in the architecture.\r\n * Each type serves a specific purpose in the application structure.\r\n */\r\nexport enum AppObjectComponentType {\r\n /** Stores and manages application state */\r\n ENTITY = \"Entity\",\r\n \r\n /** Transforms application state into view models */\r\n PM = \"Presentation Manager\",\r\n \r\n /** Implements business logic and coordinates between layers */\r\n UC = \"Use Case\",\r\n \r\n /** Handles user inputs and external events */\r\n CONTROLLER = \"Controller\",\r\n \r\n /** Renders UI elements and interacts with the DOM/rendering system */\r\n VIEW = \"View\",\r\n \r\n /** Default type for components that don't fit the standard categories */\r\n UNKNOWN = \"Unknown\",\r\n}\r\n\r\n/**\r\n * Base class for all components in the AppObject architecture.\r\n * \r\n * Components attach to AppObjects and provide specific functionality based on their type.\r\n * The architecture follows a clean separation of concerns, with each component type\r\n * having a well-defined responsibility in the application.\r\n * \r\n * Components can communicate with each other through various mechanisms:\r\n * - Direct access via parent AppObject\r\n * - Repository-level singleton access\r\n * - Observer patterns for reactive updates\r\n */\r\nexport class AppObjectComponent {\r\n /** The type category of this component */\r\n readonly componentType: AppObjectComponentType = AppObjectComponentType.UNKNOWN;\r\n \r\n /** Unique type identifier for this specific component */\r\n readonly type: string;\r\n \r\n /** The parent AppObject this component is attached to */\r\n readonly appObject: AppObject;\r\n \r\n /**\r\n * Convenience accessor for the repository containing all AppObjects\r\n * @returns The application's AppObjectRepo\r\n */\r\n get appObjects(): AppObjectRepo {\r\n return this.appObject.appObjectRepo;\r\n }\r\n\r\n /** Cache for components to avoid repeated lookups */\r\n private cachedComponents = new Map<string, AppObjectComponent>();\r\n \r\n /**\r\n * Retrieves a singleton component of the specified type from the repository\r\n * Results are cached for better performance in repeated calls\r\n * \r\n * @param type The component type identifier to look up\r\n * @returns The singleton component cast to type T, or undefined if not found\r\n */\r\n getCachedSingleton<T extends AppObjectComponent>(\r\n type: string\r\n ): T | undefined {\r\n if (!this.cachedComponents.has(type)) {\r\n const component = this.appObjects.getSingleton(type);\r\n if (!component) {\r\n this.warn(\"Unable to get cached singleton type \" + type);\r\n } else {\r\n this.cachedComponents.set(type, component);\r\n }\r\n }\r\n\r\n return this.cachedComponents.get(type) as T;\r\n }\r\n\r\n /**\r\n * Retrieves a component from the same AppObject as this component\r\n * Results are cached for better performance in repeated calls\r\n * \r\n * @param type The component type identifier to look up\r\n * @returns The component cast to type T, or undefined if not found\r\n */\r\n getCachedLocalComponent<T extends AppObjectComponent>(\r\n type: string\r\n ): T | undefined {\r\n if (!this.cachedComponents.has(type)) {\r\n const component = this.appObject.getComponent(type);\r\n\r\n if (!component) {\r\n this.warn(\"Unable to get local component of type \" + type);\r\n } else {\r\n this.cachedComponents.set(type, component);\r\n }\r\n }\r\n\r\n return this.cachedComponents.get(type) as T;\r\n }\r\n\r\n /**\r\n * Retrieves a singleton component from the repository with customizable logging\r\n * Unlike getCachedSingleton, results are not cached\r\n * \r\n * @param type The component type identifier to look up\r\n * @param logType The severity level for logging if component isn't found\r\n * @returns The singleton component cast to type T, or undefined if not found\r\n */\r\n getSingleton<T extends AppObjectComponent>(\r\n type: string,\r\n logType: \"LOG\" | \"WARN\" | \"ERROR\" = \"WARN\"\r\n ): T | undefined {\r\n const comp = this.appObjects.getSingleton<T>(type);\r\n\r\n if (!comp) {\r\n const msg = \"Unable to get singleton type \" + type;\r\n switch (logType) {\r\n case \"ERROR\":\r\n this.error(msg);\r\n break;\r\n case \"LOG\":\r\n this.log(msg);\r\n break;\r\n case \"WARN\":\r\n this.warn(msg);\r\n break;\r\n }\r\n }\r\n\r\n return comp;\r\n }\r\n\r\n /**\r\n * Cleans up resources used by this component\r\n * Removes itself from the parent AppObject if it's still attached\r\n */\r\n dispose() {\r\n if (this.appObject.getComponent(this.type) === this) {\r\n this.appObject.removeComponent(this.type);\r\n }\r\n }\r\n\r\n /**\r\n * Logs an informational message to the application's logging system\r\n * Messages are prefixed with the AppObject ID and component type for easier debugging\r\n * \r\n * @param message The message to log\r\n */\r\n log(message: string) {\r\n this.appObjects.submitLog(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n /**\r\n * Logs a warning message to the application's logging system\r\n * Messages are prefixed with the AppObject ID and component type for easier debugging\r\n * \r\n * @param message The warning message to log\r\n */\r\n warn(message: string) {\r\n this.appObjects.submitWarning(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n /**\r\n * Logs an error message to the application's logging system\r\n * Messages are prefixed with the AppObject ID and component type for easier debugging\r\n * \r\n * @param message The error message to log\r\n */\r\n error(message: string) {\r\n this.appObjects.submitError(`${this.appObject.id}/${this.type}`, message);\r\n }\r\n\r\n /**\r\n * Creates a new component and attaches it to the specified AppObject\r\n * \r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n this.appObject = appObject;\r\n this.type = type;\r\n appObject.addComponent(this);\r\n }\r\n}\r\n"]}
|
|
@@ -2,9 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppObjectController = void 0;
|
|
4
4
|
const AppObjectComponent_1 = require("./AppObjectComponent");
|
|
5
|
+
/**
|
|
6
|
+
* AppObjectController serves as a base controller class within the application framework.
|
|
7
|
+
*
|
|
8
|
+
* Controllers are components that handle logic-related operations for an AppObject,
|
|
9
|
+
* such as user input processing, state management, or business logic implementation.
|
|
10
|
+
* Extend this class to create specialized controllers for specific application features.
|
|
11
|
+
*
|
|
12
|
+
* @extends AppObjectComponent
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* class PlayerController extends AppObjectController {
|
|
16
|
+
* handleUserInput(input: UserInput) {
|
|
17
|
+
* // Process user input to control player object
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
5
22
|
class AppObjectController extends AppObjectComponent_1.AppObjectComponent {
|
|
6
23
|
constructor() {
|
|
7
24
|
super(...arguments);
|
|
25
|
+
/**
|
|
26
|
+
* The component type identifier used to categorize this component as a controller
|
|
27
|
+
* This property helps the component system identify and manage controller components.
|
|
28
|
+
* @readonly
|
|
29
|
+
*/
|
|
8
30
|
this.componentType = AppObjectComponent_1.AppObjectComponentType.CONTROLLER;
|
|
9
31
|
}
|
|
10
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppObjectController.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectController.ts"],"names":[],"mappings":";;;AAAA,6DAG8B;AAE9B,MAAa,mBAAoB,SAAQ,uCAAkB;IAA3D;;
|
|
1
|
+
{"version":3,"file":"AppObjectController.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectController.ts"],"names":[],"mappings":";;;AAAA,6DAG8B;AAE9B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,mBAAoB,SAAQ,uCAAkB;IAA3D;;QACE;;;;WAIG;QACM,kBAAa,GAAG,2CAAsB,CAAC,UAAU,CAAC;IAC7D,CAAC;CAAA;AAPD,kDAOC","sourcesContent":["import {\r\n AppObjectComponent,\r\n AppObjectComponentType,\r\n} from \"./AppObjectComponent\";\r\n\r\n/**\r\n * AppObjectController serves as a base controller class within the application framework.\r\n *\r\n * Controllers are components that handle logic-related operations for an AppObject,\r\n * such as user input processing, state management, or business logic implementation.\r\n * Extend this class to create specialized controllers for specific application features.\r\n *\r\n * @extends AppObjectComponent\r\n * @example\r\n * ```typescript\r\n * class PlayerController extends AppObjectController {\r\n * handleUserInput(input: UserInput) {\r\n * // Process user input to control player object\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AppObjectController extends AppObjectComponent {\r\n /**\r\n * The component type identifier used to categorize this component as a controller\r\n * This property helps the component system identify and manage controller components.\r\n * @readonly\r\n */\r\n readonly componentType = AppObjectComponentType.CONTROLLER;\r\n}\r\n"]}
|
|
@@ -3,7 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppObjectEntity = void 0;
|
|
4
4
|
const Entities_1 = require("../Entities");
|
|
5
5
|
const AppObjectComponent_1 = require("./AppObjectComponent");
|
|
6
|
+
/**
|
|
7
|
+
* Entity component that manages application state
|
|
8
|
+
*
|
|
9
|
+
* AppObjectEntity is responsible for storing and managing state data within the application.
|
|
10
|
+
* It uses the observer pattern to notify interested parties of changes to its state.
|
|
11
|
+
*
|
|
12
|
+
* In a typical application flow:
|
|
13
|
+
* 1. Controllers modify entity state in response to user actions
|
|
14
|
+
* 2. Entities notify observers (typically PMs) of state changes
|
|
15
|
+
* 3. PMs transform entity state into view models
|
|
16
|
+
* 4. Views render based on the view models
|
|
17
|
+
*/
|
|
6
18
|
class AppObjectEntity extends AppObjectComponent_1.AppObjectComponent {
|
|
19
|
+
/**
|
|
20
|
+
* Cleans up resources and notifies dispose observers
|
|
21
|
+
*
|
|
22
|
+
* This method:
|
|
23
|
+
* 1. Removes the change observer from the parent AppObject
|
|
24
|
+
* 2. Notifies all dispose observers
|
|
25
|
+
* 3. Clears all observer lists
|
|
26
|
+
* 4. Calls the parent class dispose method
|
|
27
|
+
*/
|
|
7
28
|
dispose() {
|
|
8
29
|
this.removeChangeObserver(this.appObject.notify);
|
|
9
30
|
this.onDisposeObserverList.notify();
|
|
@@ -11,26 +32,57 @@ class AppObjectEntity extends AppObjectComponent_1.AppObjectComponent {
|
|
|
11
32
|
this.onDisposeObserverList.clear();
|
|
12
33
|
super.dispose();
|
|
13
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new entity component and attaches it to the specified AppObject
|
|
37
|
+
* Automatically adds the AppObject's notify method as a change observer
|
|
38
|
+
*
|
|
39
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
40
|
+
* @param type The unique type identifier for this component
|
|
41
|
+
*/
|
|
14
42
|
constructor(appObject, type) {
|
|
15
43
|
super(appObject, type);
|
|
44
|
+
/** Identifies this as an Entity component */
|
|
16
45
|
this.componentType = AppObjectComponent_1.AppObjectComponentType.ENTITY;
|
|
46
|
+
/** List of observers to notify when this entity is disposed */
|
|
17
47
|
this.onDisposeObserverList = new Entities_1.ObserverList();
|
|
48
|
+
/**
|
|
49
|
+
* Adds an observer to be notified when this entity is disposed
|
|
50
|
+
* @param observer Function to call on disposal
|
|
51
|
+
*/
|
|
18
52
|
this.addOnDisposeObserver = (observer) => {
|
|
19
53
|
this.onDisposeObserverList.add(observer);
|
|
20
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Removes a previously added dispose observer
|
|
57
|
+
* @param observer The observer function to remove
|
|
58
|
+
*/
|
|
21
59
|
this.removeOnDisposeObserver = (observer) => {
|
|
22
60
|
this.onDisposeObserverList.remove(observer);
|
|
23
61
|
};
|
|
62
|
+
/** List of observers to notify when this entity's state changes */
|
|
24
63
|
this.onChangeObserverList = new Entities_1.ObserverList();
|
|
64
|
+
/**
|
|
65
|
+
* Adds an observer to be notified when this entity's state changes
|
|
66
|
+
* @param observer Function to call on state change
|
|
67
|
+
*/
|
|
25
68
|
this.addChangeObserver = (observer) => {
|
|
26
69
|
this.onChangeObserverList.add(observer);
|
|
27
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Removes a previously added change observer
|
|
73
|
+
* @param observer The observer function to remove
|
|
74
|
+
*/
|
|
28
75
|
this.removeChangeObserver = (observer) => {
|
|
29
76
|
this.onChangeObserverList.remove(observer);
|
|
30
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Notifies all change observers that this entity's state has changed
|
|
80
|
+
* This should be called by derived classes when their state changes
|
|
81
|
+
*/
|
|
31
82
|
this.notifyOnChange = () => {
|
|
32
83
|
this.onChangeObserverList.notify();
|
|
33
84
|
};
|
|
85
|
+
// When this entity changes, notify the parent AppObject
|
|
34
86
|
this.addChangeObserver(appObject.notify);
|
|
35
87
|
}
|
|
36
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppObjectEntity.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntity.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAE3C,6DAAkF;
|
|
1
|
+
{"version":3,"file":"AppObjectEntity.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntity.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAE3C,6DAAkF;AAQlF;;;;;;;;;;;GAWG;AACH,MAAa,eAAgB,SAAQ,uCAAkB;IAkDrD;;;;;;;;OAQG;IACH,OAAO;QACL,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QAEnC,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,YAAY,SAAoB,EAAE,IAAY;QAC5C,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;QA5ExB,6CAA6C;QACpC,kBAAa,GAAG,2CAAsB,CAAC,MAAM,CAAC;QAEvD,+DAA+D;QACvD,0BAAqB,GAAG,IAAI,uBAAY,EAAQ,CAAC;QAEzD;;;WAGG;QACH,yBAAoB,GAAG,CAAC,QAAiC,EAAE,EAAE;YAC3D,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC,CAAC;QAEF;;;WAGG;QACH,4BAAuB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YACpE,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC,CAAC;QAEF,mEAAmE;QAC3D,yBAAoB,GAAG,IAAI,uBAAY,EAAQ,CAAC;QAExD;;;WAGG;QACH,sBAAiB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YAC9D,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF;;;WAGG;QACH,yBAAoB,GAAG,CAAC,QAAiC,EAAQ,EAAE;YACjE,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC;QAEF;;;WAGG;QACH,mBAAc,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC,CAAC;QA+BA,wDAAwD;QACxD,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF;AAlFD,0CAkFC","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { AppObject } from \"./AppObject\";\r\nimport { AppObjectComponent, AppObjectComponentType } from \"./AppObjectComponent\";\r\n\r\n/**\r\n * Observer function type for entity state changes or disposal\r\n * No parameters are passed to the observer functions\r\n */\r\nexport type AppObjectEntityObserver = () => void;\r\n\r\n/**\r\n * Entity component that manages application state\r\n * \r\n * AppObjectEntity is responsible for storing and managing state data within the application.\r\n * It uses the observer pattern to notify interested parties of changes to its state.\r\n * \r\n * In a typical application flow:\r\n * 1. Controllers modify entity state in response to user actions\r\n * 2. Entities notify observers (typically PMs) of state changes\r\n * 3. PMs transform entity state into view models\r\n * 4. Views render based on the view models\r\n */\r\nexport class AppObjectEntity extends AppObjectComponent {\r\n /** Identifies this as an Entity component */\r\n readonly componentType = AppObjectComponentType.ENTITY;\r\n \r\n /** List of observers to notify when this entity is disposed */\r\n private onDisposeObserverList = new ObserverList<void>();\r\n \r\n /**\r\n * Adds an observer to be notified when this entity is disposed\r\n * @param observer Function to call on disposal\r\n */\r\n addOnDisposeObserver = (observer: AppObjectEntityObserver) => {\r\n this.onDisposeObserverList.add(observer);\r\n };\r\n \r\n /**\r\n * Removes a previously added dispose observer\r\n * @param observer The observer function to remove\r\n */\r\n removeOnDisposeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onDisposeObserverList.remove(observer);\r\n };\r\n\r\n /** List of observers to notify when this entity's state changes */\r\n private onChangeObserverList = new ObserverList<void>();\r\n \r\n /**\r\n * Adds an observer to be notified when this entity's state changes\r\n * @param observer Function to call on state change\r\n */\r\n addChangeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onChangeObserverList.add(observer);\r\n };\r\n \r\n /**\r\n * Removes a previously added change observer\r\n * @param observer The observer function to remove\r\n */\r\n removeChangeObserver = (observer: AppObjectEntityObserver): void => {\r\n this.onChangeObserverList.remove(observer);\r\n };\r\n\r\n /**\r\n * Notifies all change observers that this entity's state has changed\r\n * This should be called by derived classes when their state changes\r\n */\r\n notifyOnChange = () => {\r\n this.onChangeObserverList.notify();\r\n };\r\n\r\n /**\r\n * Cleans up resources and notifies dispose observers\r\n * \r\n * This method:\r\n * 1. Removes the change observer from the parent AppObject\r\n * 2. Notifies all dispose observers\r\n * 3. Clears all observer lists\r\n * 4. Calls the parent class dispose method\r\n */\r\n dispose() {\r\n this.removeChangeObserver(this.appObject.notify);\r\n\r\n this.onDisposeObserverList.notify();\r\n this.onChangeObserverList.clear();\r\n this.onDisposeObserverList.clear();\r\n\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Creates a new entity component and attaches it to the specified AppObject\r\n * Automatically adds the AppObject's notify method as a change observer\r\n * \r\n * @param appObject The parent AppObject this component will be attached to\r\n * @param type The unique type identifier for this component\r\n */\r\n constructor(appObject: AppObject, type: string) {\r\n super(appObject, type)\r\n \r\n // When this entity changes, notify the parent AppObject\r\n this.addChangeObserver(appObject.notify);\r\n }\r\n}\r\n"]}
|