@vived/app 6.8.0 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -145
- package/dist/cjs/Callouts/Factories/CalloutsFeatureFactory.js +67 -0
- package/dist/cjs/Callouts/Factories/CalloutsFeatureFactory.js.map +1 -0
- package/dist/cjs/Callouts/Factories/CalloutsFeatureFactory.test.js +84 -0
- package/dist/cjs/Callouts/Factories/CalloutsFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Callouts/Factories/index.js +1 -0
- package/dist/cjs/Callouts/Factories/index.js.map +1 -1
- package/dist/cjs/ChannelModel/Factories/ChannelModelFeatureFactory.js +52 -0
- package/dist/cjs/ChannelModel/Factories/ChannelModelFeatureFactory.js.map +1 -0
- package/dist/cjs/ChannelModel/Factories/ChannelModelFeatureFactory.test.js +44 -0
- package/dist/cjs/ChannelModel/Factories/ChannelModelFeatureFactory.test.js.map +1 -0
- package/dist/cjs/ChannelModel/Factories/index.js +1 -0
- package/dist/cjs/ChannelModel/Factories/index.js.map +1 -1
- package/dist/cjs/Dispatcher/Factories/DispatcherFeatureFactory.js +4 -3
- package/dist/cjs/Dispatcher/Factories/DispatcherFeatureFactory.js.map +1 -1
- package/dist/cjs/Dispatcher/Factories/DispatcherFeatureFactory.test.js +35 -0
- package/dist/cjs/Dispatcher/Factories/DispatcherFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Dispatcher/Factories/setupDispatchers.js +1 -0
- package/dist/cjs/Dispatcher/Factories/setupDispatchers.js.map +1 -1
- package/dist/cjs/Dispatcher/Factories/setupDispatchers.test.js +33 -0
- package/dist/cjs/Dispatcher/Factories/setupDispatchers.test.js.map +1 -0
- package/dist/cjs/Environment/Factories/EnvironmentFeatureFactory.js +50 -0
- package/dist/cjs/Environment/Factories/EnvironmentFeatureFactory.js.map +1 -0
- package/dist/cjs/Environment/Factories/EnvironmentFeatureFactory.test.js +39 -0
- package/dist/cjs/Environment/Factories/EnvironmentFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Environment/Factories/index.js +2 -1
- package/dist/cjs/Environment/Factories/index.js.map +1 -1
- package/dist/cjs/Environment/Factories/setupEnvironments.js +19 -0
- package/dist/cjs/Environment/Factories/setupEnvironments.js.map +1 -0
- package/dist/cjs/Hideable/Factories/HideableFeatureFactory.js +69 -0
- package/dist/cjs/Hideable/Factories/HideableFeatureFactory.js.map +1 -0
- package/dist/cjs/Hideable/Factories/HideableFeatureFactory.test.js +116 -0
- package/dist/cjs/Hideable/Factories/HideableFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Hideable/Factories/index.js +1 -0
- package/dist/cjs/Hideable/Factories/index.js.map +1 -1
- package/dist/cjs/HoverLabel/Factories/HoverLabelFeatureFactory.js +79 -0
- package/dist/cjs/HoverLabel/Factories/HoverLabelFeatureFactory.js.map +1 -0
- package/dist/cjs/HoverLabel/Factories/HoverLabelFeatureFactory.test.js +81 -0
- package/dist/cjs/HoverLabel/Factories/HoverLabelFeatureFactory.test.js.map +1 -0
- package/dist/cjs/HoverLabel/Factories/index.js +1 -0
- package/dist/cjs/HoverLabel/Factories/index.js.map +1 -1
- package/dist/cjs/Landmarks/Factories/LandmarksFeatureFactory.js +85 -0
- package/dist/cjs/Landmarks/Factories/LandmarksFeatureFactory.js.map +1 -0
- package/dist/cjs/Landmarks/Factories/LandmarksFeatureFactory.test.js +100 -0
- package/dist/cjs/Landmarks/Factories/LandmarksFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Landmarks/Factories/index.js +1 -0
- package/dist/cjs/Landmarks/Factories/index.js.map +1 -1
- package/dist/cjs/Selection/Factories/SelectionFeatureFactory.js +57 -0
- package/dist/cjs/Selection/Factories/SelectionFeatureFactory.js.map +1 -0
- package/dist/cjs/Selection/Factories/SelectionFeatureFactory.test.js +60 -0
- package/dist/cjs/Selection/Factories/SelectionFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Selection/Factories/index.js +1 -0
- package/dist/cjs/Selection/Factories/index.js.map +1 -1
- package/dist/cjs/Stick/Factories/StickFeatureFactory.js +45 -0
- package/dist/cjs/Stick/Factories/StickFeatureFactory.js.map +1 -0
- package/dist/cjs/Stick/Factories/StickFeatureFactory.test.js +44 -0
- package/dist/cjs/Stick/Factories/StickFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Stick/Factories/index.js +1 -0
- package/dist/cjs/Stick/Factories/index.js.map +1 -1
- package/dist/cjs/StoredView/Factories/StoredViewFeatureFactory.js +48 -0
- package/dist/cjs/StoredView/Factories/StoredViewFeatureFactory.js.map +1 -0
- package/dist/cjs/StoredView/Factories/StoredViewFeatureFactory.test.js +39 -0
- package/dist/cjs/StoredView/Factories/StoredViewFeatureFactory.test.js.map +1 -0
- package/dist/cjs/StoredView/Factories/index.js +1 -0
- package/dist/cjs/StoredView/Factories/index.js.map +1 -1
- package/dist/cjs/Stylus/Factories/StylusFeatureFactory.js +47 -0
- package/dist/cjs/Stylus/Factories/StylusFeatureFactory.js.map +1 -0
- package/dist/cjs/Stylus/Factories/StylusFeatureFactory.test.js +35 -0
- package/dist/cjs/Stylus/Factories/StylusFeatureFactory.test.js.map +1 -0
- package/dist/cjs/Stylus/Factories/index.js +1 -0
- package/dist/cjs/Stylus/Factories/index.js.map +1 -1
- package/dist/cjs/zSpace/Factory/ZSpaceFeatureFactory.js +70 -0
- package/dist/cjs/zSpace/Factory/ZSpaceFeatureFactory.js.map +1 -0
- package/dist/cjs/zSpace/Factory/ZSpaceFeatureFactory.test.js +78 -0
- package/dist/cjs/zSpace/Factory/ZSpaceFeatureFactory.test.js.map +1 -0
- package/dist/cjs/zSpace/Factory/index.js +1 -0
- package/dist/cjs/zSpace/Factory/index.js.map +1 -1
- package/dist/esm/Callouts/Factories/CalloutsFeatureFactory.js +62 -0
- package/dist/esm/Callouts/Factories/CalloutsFeatureFactory.js.map +1 -0
- package/dist/esm/Callouts/Factories/CalloutsFeatureFactory.test.js +82 -0
- package/dist/esm/Callouts/Factories/CalloutsFeatureFactory.test.js.map +1 -0
- package/dist/esm/Callouts/Factories/index.js +1 -0
- package/dist/esm/Callouts/Factories/index.js.map +1 -1
- package/dist/esm/ChannelModel/Factories/ChannelModelFeatureFactory.js +47 -0
- package/dist/esm/ChannelModel/Factories/ChannelModelFeatureFactory.js.map +1 -0
- package/dist/esm/ChannelModel/Factories/ChannelModelFeatureFactory.test.js +42 -0
- package/dist/esm/ChannelModel/Factories/ChannelModelFeatureFactory.test.js.map +1 -0
- package/dist/esm/ChannelModel/Factories/index.js +1 -0
- package/dist/esm/ChannelModel/Factories/index.js.map +1 -1
- package/dist/esm/Dispatcher/Factories/DispatcherFeatureFactory.js +5 -4
- package/dist/esm/Dispatcher/Factories/DispatcherFeatureFactory.js.map +1 -1
- package/dist/esm/Dispatcher/Factories/DispatcherFeatureFactory.test.js +33 -0
- package/dist/esm/Dispatcher/Factories/DispatcherFeatureFactory.test.js.map +1 -0
- package/dist/esm/Dispatcher/Factories/setupDispatchers.js +2 -1
- package/dist/esm/Dispatcher/Factories/setupDispatchers.js.map +1 -1
- package/dist/esm/Dispatcher/Factories/setupDispatchers.test.js +31 -0
- package/dist/esm/Dispatcher/Factories/setupDispatchers.test.js.map +1 -0
- package/dist/esm/Environment/Factories/EnvironmentFeatureFactory.js +45 -0
- package/dist/esm/Environment/Factories/EnvironmentFeatureFactory.js.map +1 -0
- package/dist/esm/Environment/Factories/EnvironmentFeatureFactory.test.js +37 -0
- package/dist/esm/Environment/Factories/EnvironmentFeatureFactory.test.js.map +1 -0
- package/dist/esm/Environment/Factories/index.js +2 -1
- package/dist/esm/Environment/Factories/index.js.map +1 -1
- package/dist/esm/Environment/Factories/setupEnvironments.js +16 -0
- package/dist/esm/Environment/Factories/setupEnvironments.js.map +1 -0
- package/dist/esm/Hideable/Factories/HideableFeatureFactory.js +64 -0
- package/dist/esm/Hideable/Factories/HideableFeatureFactory.js.map +1 -0
- package/dist/esm/Hideable/Factories/HideableFeatureFactory.test.js +114 -0
- package/dist/esm/Hideable/Factories/HideableFeatureFactory.test.js.map +1 -0
- package/dist/esm/Hideable/Factories/index.js +1 -0
- package/dist/esm/Hideable/Factories/index.js.map +1 -1
- package/dist/esm/HoverLabel/Factories/HoverLabelFeatureFactory.js +74 -0
- package/dist/esm/HoverLabel/Factories/HoverLabelFeatureFactory.js.map +1 -0
- package/dist/esm/HoverLabel/Factories/HoverLabelFeatureFactory.test.js +79 -0
- package/dist/esm/HoverLabel/Factories/HoverLabelFeatureFactory.test.js.map +1 -0
- package/dist/esm/HoverLabel/Factories/index.js +1 -0
- package/dist/esm/HoverLabel/Factories/index.js.map +1 -1
- package/dist/esm/Landmarks/Factories/LandmarksFeatureFactory.js +80 -0
- package/dist/esm/Landmarks/Factories/LandmarksFeatureFactory.js.map +1 -0
- package/dist/esm/Landmarks/Factories/LandmarksFeatureFactory.test.js +98 -0
- package/dist/esm/Landmarks/Factories/LandmarksFeatureFactory.test.js.map +1 -0
- package/dist/esm/Landmarks/Factories/index.js +1 -0
- package/dist/esm/Landmarks/Factories/index.js.map +1 -1
- package/dist/esm/Selection/Factories/SelectionFeatureFactory.js +52 -0
- package/dist/esm/Selection/Factories/SelectionFeatureFactory.js.map +1 -0
- package/dist/esm/Selection/Factories/SelectionFeatureFactory.test.js +58 -0
- package/dist/esm/Selection/Factories/SelectionFeatureFactory.test.js.map +1 -0
- package/dist/esm/Selection/Factories/index.js +1 -0
- package/dist/esm/Selection/Factories/index.js.map +1 -1
- package/dist/esm/Stick/Factories/StickFeatureFactory.js +40 -0
- package/dist/esm/Stick/Factories/StickFeatureFactory.js.map +1 -0
- package/dist/esm/Stick/Factories/StickFeatureFactory.test.js +42 -0
- package/dist/esm/Stick/Factories/StickFeatureFactory.test.js.map +1 -0
- package/dist/esm/Stick/Factories/index.js +1 -0
- package/dist/esm/Stick/Factories/index.js.map +1 -1
- package/dist/esm/StoredView/Factories/StoredViewFeatureFactory.js +43 -0
- package/dist/esm/StoredView/Factories/StoredViewFeatureFactory.js.map +1 -0
- package/dist/esm/StoredView/Factories/StoredViewFeatureFactory.test.js +37 -0
- package/dist/esm/StoredView/Factories/StoredViewFeatureFactory.test.js.map +1 -0
- package/dist/esm/StoredView/Factories/index.js +1 -0
- package/dist/esm/StoredView/Factories/index.js.map +1 -1
- package/dist/esm/Stylus/Factories/StylusFeatureFactory.js +42 -0
- package/dist/esm/Stylus/Factories/StylusFeatureFactory.js.map +1 -0
- package/dist/esm/Stylus/Factories/StylusFeatureFactory.test.js +33 -0
- package/dist/esm/Stylus/Factories/StylusFeatureFactory.test.js.map +1 -0
- package/dist/esm/Stylus/Factories/index.js +1 -0
- package/dist/esm/Stylus/Factories/index.js.map +1 -1
- package/dist/esm/zSpace/Factory/ZSpaceFeatureFactory.js +65 -0
- package/dist/esm/zSpace/Factory/ZSpaceFeatureFactory.js.map +1 -0
- package/dist/esm/zSpace/Factory/ZSpaceFeatureFactory.test.js +76 -0
- package/dist/esm/zSpace/Factory/ZSpaceFeatureFactory.test.js.map +1 -0
- package/dist/esm/zSpace/Factory/index.js +1 -0
- package/dist/esm/zSpace/Factory/index.js.map +1 -1
- package/dist/types/Callouts/Factories/CalloutsFeatureFactory.d.ts +24 -0
- package/dist/types/Callouts/Factories/CalloutsFeatureFactory.d.ts.map +1 -0
- package/dist/types/Callouts/Factories/CalloutsFeatureFactory.test.d.ts +2 -0
- package/dist/types/Callouts/Factories/CalloutsFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Callouts/Factories/index.d.ts +1 -0
- package/dist/types/Callouts/Factories/index.d.ts.map +1 -1
- package/dist/types/ChannelModel/Factories/ChannelModelFeatureFactory.d.ts +23 -0
- package/dist/types/ChannelModel/Factories/ChannelModelFeatureFactory.d.ts.map +1 -0
- package/dist/types/ChannelModel/Factories/ChannelModelFeatureFactory.test.d.ts +2 -0
- package/dist/types/ChannelModel/Factories/ChannelModelFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/ChannelModel/Factories/index.d.ts +1 -0
- package/dist/types/ChannelModel/Factories/index.d.ts.map +1 -1
- package/dist/types/Dispatcher/Factories/DispatcherFeatureFactory.d.ts +3 -3
- package/dist/types/Dispatcher/Factories/DispatcherFeatureFactory.d.ts.map +1 -1
- package/dist/types/Dispatcher/Factories/DispatcherFeatureFactory.test.d.ts +2 -0
- package/dist/types/Dispatcher/Factories/DispatcherFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Dispatcher/Factories/setupDispatchers.d.ts.map +1 -1
- package/dist/types/Dispatcher/Factories/setupDispatchers.test.d.ts +2 -0
- package/dist/types/Dispatcher/Factories/setupDispatchers.test.d.ts.map +1 -0
- package/dist/types/Environment/Factories/EnvironmentFeatureFactory.d.ts +23 -0
- package/dist/types/Environment/Factories/EnvironmentFeatureFactory.d.ts.map +1 -0
- package/dist/types/Environment/Factories/EnvironmentFeatureFactory.test.d.ts +2 -0
- package/dist/types/Environment/Factories/EnvironmentFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Environment/Factories/index.d.ts +2 -1
- package/dist/types/Environment/Factories/index.d.ts.map +1 -1
- package/dist/types/Environment/Factories/setupEnvironments.d.ts +3 -0
- package/dist/types/Environment/Factories/setupEnvironments.d.ts.map +1 -0
- package/dist/types/Hideable/Factories/HideableFeatureFactory.d.ts +32 -0
- package/dist/types/Hideable/Factories/HideableFeatureFactory.d.ts.map +1 -0
- package/dist/types/Hideable/Factories/HideableFeatureFactory.test.d.ts +2 -0
- package/dist/types/Hideable/Factories/HideableFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Hideable/Factories/index.d.ts +1 -0
- package/dist/types/Hideable/Factories/index.d.ts.map +1 -1
- package/dist/types/HoverLabel/Factories/HoverLabelFeatureFactory.d.ts +34 -0
- package/dist/types/HoverLabel/Factories/HoverLabelFeatureFactory.d.ts.map +1 -0
- package/dist/types/HoverLabel/Factories/HoverLabelFeatureFactory.test.d.ts +2 -0
- package/dist/types/HoverLabel/Factories/HoverLabelFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/HoverLabel/Factories/index.d.ts +1 -0
- package/dist/types/HoverLabel/Factories/index.d.ts.map +1 -1
- package/dist/types/Landmarks/Factories/LandmarksFeatureFactory.d.ts +26 -0
- package/dist/types/Landmarks/Factories/LandmarksFeatureFactory.d.ts.map +1 -0
- package/dist/types/Landmarks/Factories/LandmarksFeatureFactory.test.d.ts +2 -0
- package/dist/types/Landmarks/Factories/LandmarksFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Landmarks/Factories/index.d.ts +1 -0
- package/dist/types/Landmarks/Factories/index.d.ts.map +1 -1
- package/dist/types/Selection/Factories/SelectionFeatureFactory.d.ts +27 -0
- package/dist/types/Selection/Factories/SelectionFeatureFactory.d.ts.map +1 -0
- package/dist/types/Selection/Factories/SelectionFeatureFactory.test.d.ts +2 -0
- package/dist/types/Selection/Factories/SelectionFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Selection/Factories/index.d.ts +1 -0
- package/dist/types/Selection/Factories/index.d.ts.map +1 -1
- package/dist/types/Stick/Factories/StickFeatureFactory.d.ts +23 -0
- package/dist/types/Stick/Factories/StickFeatureFactory.d.ts.map +1 -0
- package/dist/types/Stick/Factories/StickFeatureFactory.test.d.ts +2 -0
- package/dist/types/Stick/Factories/StickFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Stick/Factories/index.d.ts +1 -0
- package/dist/types/Stick/Factories/index.d.ts.map +1 -1
- package/dist/types/StoredView/Factories/StoredViewFeatureFactory.d.ts +23 -0
- package/dist/types/StoredView/Factories/StoredViewFeatureFactory.d.ts.map +1 -0
- package/dist/types/StoredView/Factories/StoredViewFeatureFactory.test.d.ts +2 -0
- package/dist/types/StoredView/Factories/StoredViewFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/StoredView/Factories/index.d.ts +1 -0
- package/dist/types/StoredView/Factories/index.d.ts.map +1 -1
- package/dist/types/Stylus/Factories/StylusFeatureFactory.d.ts +23 -0
- package/dist/types/Stylus/Factories/StylusFeatureFactory.d.ts.map +1 -0
- package/dist/types/Stylus/Factories/StylusFeatureFactory.test.d.ts +2 -0
- package/dist/types/Stylus/Factories/StylusFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/Stylus/Factories/index.d.ts +1 -0
- package/dist/types/Stylus/Factories/index.d.ts.map +1 -1
- package/dist/types/zSpace/Factory/ZSpaceFeatureFactory.d.ts +26 -0
- package/dist/types/zSpace/Factory/ZSpaceFeatureFactory.d.ts.map +1 -0
- package/dist/types/zSpace/Factory/ZSpaceFeatureFactory.test.d.ts +2 -0
- package/dist/types/zSpace/Factory/ZSpaceFeatureFactory.test.d.ts.map +1 -0
- package/dist/types/zSpace/Factory/index.d.ts +1 -0
- package/dist/types/zSpace/Factory/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Dispatcher/README.md +9 -6
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HoverLabelFeatureFactory = void 0;
|
|
4
|
+
exports.makeHoverLabelFeatureFactory = makeHoverLabelFeatureFactory;
|
|
5
|
+
const core_1 = require("@vived/core");
|
|
6
|
+
const Stylus_1 = require("../../Stylus");
|
|
7
|
+
const Transform3D_1 = require("../../Transform3D");
|
|
8
|
+
const Controllers_1 = require("../Controllers");
|
|
9
|
+
const Entities_1 = require("../Entities");
|
|
10
|
+
const PM_1 = require("../PM");
|
|
11
|
+
const UseCases_1 = require("../UseCases");
|
|
12
|
+
/**
|
|
13
|
+
* Factory responsible for setting up the HoverLabel Feature domain components.
|
|
14
|
+
*
|
|
15
|
+
* Builds the same components as the legacy setupHoverLabel function, split
|
|
16
|
+
* into the DomainFactory phases. The hover label transform is parented to the
|
|
17
|
+
* StylusEntity in finalSetup, so the Stylus Feature's factory can be
|
|
18
|
+
* registered before or after this one.
|
|
19
|
+
*
|
|
20
|
+
* @extends DomainFactory
|
|
21
|
+
*/
|
|
22
|
+
class HoverLabelFeatureFactory extends core_1.DomainFactory {
|
|
23
|
+
/**
|
|
24
|
+
* @param appObject The HoverLabel AppObject
|
|
25
|
+
* @param options Optional configuration, as for setupHoverLabel
|
|
26
|
+
*/
|
|
27
|
+
constructor(appObject, options) {
|
|
28
|
+
super(appObject);
|
|
29
|
+
this.factoryName = "HoverLabelFeatureFactory";
|
|
30
|
+
this.options = options;
|
|
31
|
+
}
|
|
32
|
+
setupEntities() {
|
|
33
|
+
this.hoverLabelEntity = (0, Entities_1.makeHoverLabelEntity)(this.appObject);
|
|
34
|
+
}
|
|
35
|
+
setupUCs() {
|
|
36
|
+
if (this.options?.tryShowFactory) {
|
|
37
|
+
this.options.tryShowFactory(this.appObject);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
(0, UseCases_1.makeTryShowHoverLabel)(this.appObject);
|
|
41
|
+
}
|
|
42
|
+
(0, UseCases_1.makeToggleAllowHoverLabel)(this.appObject);
|
|
43
|
+
new UseCases_1.SerializeAllowHoverLabel(this.appObject);
|
|
44
|
+
}
|
|
45
|
+
setupPMs() {
|
|
46
|
+
(0, PM_1.makeWorldHoverLabelPM)(this.appObject);
|
|
47
|
+
(0, PM_1.makeScreenHoverLabelPM)(this.appObject);
|
|
48
|
+
(0, PM_1.makeAllowHoverLabelPM)(this.appObject);
|
|
49
|
+
(0, Transform3D_1.makeTransform3DPM)(this.appObject);
|
|
50
|
+
}
|
|
51
|
+
finalSetup() {
|
|
52
|
+
(0, Controllers_1.makeHoverLabelMouse)(this.appObject);
|
|
53
|
+
(0, Controllers_1.makeHoverLabelTouch)(this.appObject);
|
|
54
|
+
(0, Controllers_1.makeStylusHoverLabelController)(this.appObject);
|
|
55
|
+
if (!this.hoverLabelEntity)
|
|
56
|
+
return;
|
|
57
|
+
const stylus = Stylus_1.StylusEntity.get(this.appObjects);
|
|
58
|
+
if (!stylus) {
|
|
59
|
+
this.appObjects.submitError(this.factoryName, "StylusEntity needs to be setup for Hover Label");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const transform = this.hoverLabelEntity.transform;
|
|
63
|
+
transform.parent = stylus.transform;
|
|
64
|
+
transform.localPosition = core_1.Vector3.Zero();
|
|
65
|
+
transform.localRotation = core_1.Quaternion.Identity();
|
|
66
|
+
transform.localScale = core_1.Vector3.One();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.HoverLabelFeatureFactory = HoverLabelFeatureFactory;
|
|
70
|
+
/**
|
|
71
|
+
* Factory function to create a new HoverLabelFeatureFactory
|
|
72
|
+
* @param appObjects The AppObjectRepo to get or create the HoverLabel AppObject from
|
|
73
|
+
* @param options Optional configuration, as for setupHoverLabel
|
|
74
|
+
* @returns A new HoverLabelFeatureFactory instance
|
|
75
|
+
*/
|
|
76
|
+
function makeHoverLabelFeatureFactory(appObjects, options) {
|
|
77
|
+
return new HoverLabelFeatureFactory(appObjects.getOrCreate("HoverLabel"), options);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=HoverLabelFeatureFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HoverLabelFeatureFactory.js","sourceRoot":"","sources":["../../../../src/HoverLabel/Factories/HoverLabelFeatureFactory.ts"],"names":[],"mappings":";;;AAwGA,oEAQC;AAhHD,sCAMqB;AACrB,yCAA4C;AAC5C,mDAAsD;AACtD,gDAIwB;AACxB,0CAAqE;AACrE,8BAIe;AACf,0CAIqB;AAGrB;;;;;;;;;GASG;AACH,MAAa,wBAAyB,SAAQ,oBAAa;IAMzD;;;OAGG;IACH,YAAY,SAAoB,EAAE,OAA2B;QAC3D,KAAK,CAAC,SAAS,CAAC,CAAC;QAVnB,gBAAW,GAAG,0BAA0B,CAAC;QAWvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,aAAa;QACX,IAAI,CAAC,gBAAgB,GAAG,IAAA,+BAAoB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,OAAO,EAAE,cAAc,E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,EAAE,CAAC;QAChD,SAAS,CAAC,UAAU,GAAG,cAAO,CAAC,GAAG,EAAE,CAAC;IACvC,CAAC;CACF;AA3DD,4DA2DC;AAED;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,UAAyB,EACzB,OAA2B;IAE3B,OAAO,IAAI,wBAAwB,CACjC,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,EACpC,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["import {\r\n AppObject,\r\n AppObjectRepo,\r\n DomainFactory,\r\n Quaternion,\r\n Vector3,\r\n} from \"@vived/core\";\r\nimport { StylusEntity } from \"../../Stylus\";\r\nimport { makeTransform3DPM } from \"../../Transform3D\";\r\nimport {\r\n makeHoverLabelMouse,\r\n makeHoverLabelTouch,\r\n makeStylusHoverLabelController,\r\n} from \"../Controllers\";\r\nimport { HoverLabelEntity, makeHoverLabelEntity } from \"../Entities\";\r\nimport {\r\n makeAllowHoverLabelPM,\r\n makeScreenHoverLabelPM,\r\n makeWorldHoverLabelPM,\r\n} from \"../PM\";\r\nimport {\r\n makeToggleAllowHoverLabel,\r\n makeTryShowHoverLabel,\r\n SerializeAllowHoverLabel,\r\n} from \"../UseCases\";\r\nimport { HoverLabelOptions } from \"./setupHoverLabel\";\r\n\r\n/**\r\n * Factory responsible for setting up the HoverLabel Feature domain components.\r\n *\r\n * Builds the same components as the legacy setupHoverLabel function, split\r\n * into the DomainFactory phases. The hover label transform is parented to the\r\n * StylusEntity in finalSetup, so the Stylus Feature's factory can be\r\n * registered before or after this one.\r\n *\r\n * @extends DomainFactory\r\n */\r\nexport class HoverLabelFeatureFactory extends DomainFactory {\r\n factoryName = \"HoverLabelFeatureFactory\";\r\n\r\n private hoverLabelEntity?: HoverLabelEntity;\r\n private options?: HoverLabelOptions;\r\n\r\n /**\r\n * @param appObject The HoverLabel AppObject\r\n * @param options Optional configuration, as for setupHoverLabel\r\n */\r\n constructor(appObject: AppObject, options?: HoverLabelOptions) {\r\n super(appObject);\r\n this.options = options;\r\n }\r\n\r\n setupEntities(): void {\r\n this.hoverLabelEntity = makeHoverLabelEntity(this.appObject);\r\n }\r\n\r\n setupUCs(): void {\r\n if (this.options?.tryShowFactory) {\r\n this.options.tryShowFactory(this.appObject);\r\n } else {\r\n makeTryShowHoverLabel(this.appObject);\r\n }\r\n\r\n makeToggleAllowHoverLabel(this.appObject);\r\n new SerializeAllowHoverLabel(this.appObject);\r\n }\r\n\r\n setupPMs(): void {\r\n makeWorldHoverLabelPM(this.appObject);\r\n makeScreenHoverLabelPM(this.appObject);\r\n makeAllowHoverLabelPM(this.appObject);\r\n makeTransform3DPM(this.appObject);\r\n }\r\n\r\n finalSetup(): void {\r\n makeHoverLabelMouse(this.appObject);\r\n makeHoverLabelTouch(this.appObject);\r\n makeStylusHoverLabelController(this.appObject);\r\n\r\n if (!this.hoverLabelEntity) return;\r\n\r\n const stylus = StylusEntity.get(this.appObjects);\r\n if (!stylus) {\r\n this.appObjects.submitError(\r\n this.factoryName,\r\n \"StylusEntity needs to be setup for Hover Label\",\r\n );\r\n return;\r\n }\r\n\r\n const transform = this.hoverLabelEntity.transform;\r\n transform.parent = stylus.transform;\r\n transform.localPosition = Vector3.Zero();\r\n transform.localRotation = Quaternion.Identity();\r\n transform.localScale = Vector3.One();\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new HoverLabelFeatureFactory\r\n * @param appObjects The AppObjectRepo to get or create the HoverLabel AppObject from\r\n * @param options Optional configuration, as for setupHoverLabel\r\n * @returns A new HoverLabelFeatureFactory instance\r\n */\r\nexport function makeHoverLabelFeatureFactory(\r\n appObjects: AppObjectRepo,\r\n options?: HoverLabelOptions,\r\n): HoverLabelFeatureFactory {\r\n return new HoverLabelFeatureFactory(\r\n appObjects.getOrCreate(\"HoverLabel\"),\r\n options,\r\n );\r\n}\r\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@vived/core");
|
|
4
|
+
const MouseInput_1 = require("../../MouseInput");
|
|
5
|
+
const StateMachine_1 = require("../../StateMachine");
|
|
6
|
+
const Stylus_1 = require("../../Stylus");
|
|
7
|
+
const TouchController_1 = require("../../TouchController");
|
|
8
|
+
const Entities_1 = require("../Entities");
|
|
9
|
+
const UseCases_1 = require("../UseCases");
|
|
10
|
+
const HoverLabelFeatureFactory_1 = require("./HoverLabelFeatureFactory");
|
|
11
|
+
const setupHoverLabel_1 = require("./setupHoverLabel");
|
|
12
|
+
function makeTestRig() {
|
|
13
|
+
const appObjects = (0, core_1.makeAppObjectRepo)();
|
|
14
|
+
const factories = (0, core_1.makeDomainFactoryRepo)(appObjects);
|
|
15
|
+
const mockError = jest.fn();
|
|
16
|
+
appObjects.submitError = mockError;
|
|
17
|
+
return { appObjects, factories, mockError };
|
|
18
|
+
}
|
|
19
|
+
function registerCollaborators(appObjects) {
|
|
20
|
+
(0, MouseInput_1.makeMouseInputFeatureFactory)(appObjects);
|
|
21
|
+
(0, TouchController_1.makeTouchControllerFeatureFactory)(appObjects);
|
|
22
|
+
(0, StateMachine_1.makeStateMachineFeatureFactory)(appObjects);
|
|
23
|
+
}
|
|
24
|
+
function componentTypes(appObjects) {
|
|
25
|
+
const types = {};
|
|
26
|
+
appObjects.getAll().forEach((ao) => {
|
|
27
|
+
types[ao.id] = ao
|
|
28
|
+
.allComponents()
|
|
29
|
+
.filter((c) => !(c instanceof core_1.DomainFactory))
|
|
30
|
+
.map((c) => c.type)
|
|
31
|
+
.sort();
|
|
32
|
+
});
|
|
33
|
+
return types;
|
|
34
|
+
}
|
|
35
|
+
describe("HoverLabelFeatureFactory", () => {
|
|
36
|
+
it("Builds the same components as setupHoverLabel", () => {
|
|
37
|
+
const legacy = makeTestRig();
|
|
38
|
+
registerCollaborators(legacy.appObjects);
|
|
39
|
+
(0, Stylus_1.makeStylusFeatureFactory)(legacy.appObjects);
|
|
40
|
+
legacy.factories.setupDomain();
|
|
41
|
+
(0, setupHoverLabel_1.setupHoverLabel)(legacy.appObjects);
|
|
42
|
+
const { appObjects, factories, mockError } = makeTestRig();
|
|
43
|
+
registerCollaborators(appObjects);
|
|
44
|
+
(0, Stylus_1.makeStylusFeatureFactory)(appObjects);
|
|
45
|
+
(0, HoverLabelFeatureFactory_1.makeHoverLabelFeatureFactory)(appObjects);
|
|
46
|
+
factories.setupDomain();
|
|
47
|
+
expect(componentTypes(appObjects)).toEqual(componentTypes(legacy.appObjects));
|
|
48
|
+
expect(mockError).not.toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
it("Parents the hover label to the stylus when the Stylus factory is registered after it", () => {
|
|
51
|
+
const { appObjects, factories, mockError } = makeTestRig();
|
|
52
|
+
registerCollaborators(appObjects);
|
|
53
|
+
(0, HoverLabelFeatureFactory_1.makeHoverLabelFeatureFactory)(appObjects);
|
|
54
|
+
(0, Stylus_1.makeStylusFeatureFactory)(appObjects);
|
|
55
|
+
factories.setupDomain();
|
|
56
|
+
const hoverLabel = Entities_1.HoverLabelEntity.get(appObjects);
|
|
57
|
+
const stylus = Stylus_1.StylusEntity.get(appObjects);
|
|
58
|
+
expect(hoverLabel.transform.parent).toBe(stylus.transform);
|
|
59
|
+
expect(mockError).not.toHaveBeenCalled();
|
|
60
|
+
});
|
|
61
|
+
it("Submits an error when there is no Stylus Feature", () => {
|
|
62
|
+
const { appObjects, factories, mockError } = makeTestRig();
|
|
63
|
+
registerCollaborators(appObjects);
|
|
64
|
+
(0, HoverLabelFeatureFactory_1.makeHoverLabelFeatureFactory)(appObjects);
|
|
65
|
+
factories.setupDomain();
|
|
66
|
+
expect(mockError).toHaveBeenCalledWith("HoverLabelFeatureFactory", "StylusEntity needs to be setup for Hover Label");
|
|
67
|
+
});
|
|
68
|
+
it("Uses the try show factory if it is passed in", () => {
|
|
69
|
+
const { appObjects, factories } = makeTestRig();
|
|
70
|
+
registerCollaborators(appObjects);
|
|
71
|
+
(0, Stylus_1.makeStylusFeatureFactory)(appObjects);
|
|
72
|
+
const tryShowFactory = jest.fn();
|
|
73
|
+
const factory = (0, HoverLabelFeatureFactory_1.makeHoverLabelFeatureFactory)(appObjects, {
|
|
74
|
+
tryShowFactory,
|
|
75
|
+
});
|
|
76
|
+
factories.setupDomain();
|
|
77
|
+
expect(tryShowFactory).toHaveBeenCalledWith(factory.appObject);
|
|
78
|
+
expect(factory.appObject.hasComponent(UseCases_1.TryShowHoverLabel.type)).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=HoverLabelFeatureFactory.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HoverLabelFeatureFactory.test.js","sourceRoot":"","sources":["../../../../src/HoverLabel/Factories/HoverLabelFeatureFactory.test.ts"],"names":[],"mappings":";;AAAA,sCAKqB;AACrB,iDAAgE;AAChE,qDAAoE;AACpE,yCAAsE;AACtE,2DAA0E;AAC1E,0CAA+C;AAC/C,0CAAgD;AAChD,yEAA0E;AAC1E,uDAAoD;AAEpD,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,IAAA,wBAAiB,GAAE,CAAC;IACvC,MAAM,SAAS,GAAG,IAAA,4BAAqB,EAAC,UAAU,CAAC,CAAC;IAEpD,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAC5B,UAAU,CAAC,WAAW,GAAG,SAAS,CAAC;IAEnC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAyB;IACtD,IAAA,yCAA4B,EAAC,UAAU,CAAC,CAAC;IACzC,IAAA,mDAAiC,EAAC,UAAU,CAAC,CAAC;IAC9C,IAAA,6CAA8B,EAAC,UAAU,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,cAAc,CAAC,UAAyB;IAC/C,MAAM,KAAK,GAA+B,EAAE,CAAC;IAC7C,UAAU,CAAC,MAAM,EAAE,CAAC,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,SAAS,CAAC,WAAW,EAAE,CAAC;QAExB,MAAM,CAAC,cAAc,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC/D,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,4BAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\r\n AppObjectRepo,\r\n DomainFactory,\r\n makeAppObjectRepo,\r\n makeDomainFactoryRepo,\r\n} from \"@vived/core\";\r\nimport { makeMouseInputFeatureFactory } from \"../../MouseInput\";\r\nimport { makeStateMachineFeatureFactory } from \"../../StateMachine\";\r\nimport { makeStylusFeatureFactory, StylusEntity } from \"../../Stylus\";\r\nimport { makeTouchControllerFeatureFactory } from \"../../TouchController\";\r\nimport { HoverLabelEntity } from \"../Entities\";\r\nimport { TryShowHoverLabel } from \"../UseCases\";\r\nimport { makeHoverLabelFeatureFactory } from \"./HoverLabelFeatureFactory\";\r\nimport { setupHoverLabel } from \"./setupHoverLabel\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n const factories = makeDomainFactoryRepo(appObjects);\r\n\r\n const mockError = jest.fn();\r\n appObjects.submitError = mockError;\r\n\r\n return { appObjects, factories, mockError };\r\n}\r\n\r\nfunction registerCollaborators(appObjects: AppObjectRepo) {\r\n makeMouseInputFeatureFactory(appObjects);\r\n makeTouchControllerFeatureFactory(appObjects);\r\n makeStateMachineFeatureFactory(appObjects);\r\n}\r\n\r\nfunction componentTypes(appObjects: AppObjectRepo) {\r\n const types: { [id: string]: string[] } = {};\r\n appObjects.getAll().forEach((ao) => {\r\n types[ao.id] = ao\r\n .allComponents()\r\n .filter((c) => !(c instanceof DomainFactory))\r\n .map((c) => c.type)\r\n .sort();\r\n });\r\n return types;\r\n}\r\n\r\ndescribe(\"HoverLabelFeatureFactory\", () => {\r\n it(\"Builds the same components as setupHoverLabel\", () => {\r\n const legacy = makeTestRig();\r\n registerCollaborators(legacy.appObjects);\r\n makeStylusFeatureFactory(legacy.appObjects);\r\n legacy.factories.setupDomain();\r\n setupHoverLabel(legacy.appObjects);\r\n\r\n const { appObjects, factories, mockError } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeStylusFeatureFactory(appObjects);\r\n makeHoverLabelFeatureFactory(appObjects);\r\n factories.setupDomain();\r\n\r\n expect(componentTypes(appObjects)).toEqual(\r\n componentTypes(legacy.appObjects),\r\n );\r\n expect(mockError).not.toHaveBeenCalled();\r\n });\r\n\r\n it(\"Parents the hover label to the stylus when the Stylus factory is registered after it\", () => {\r\n const { appObjects, factories, mockError } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeHoverLabelFeatureFactory(appObjects);\r\n makeStylusFeatureFactory(appObjects);\r\n factories.setupDomain();\r\n\r\n const hoverLabel = HoverLabelEntity.get(appObjects)!;\r\n const stylus = StylusEntity.get(appObjects)!;\r\n expect(hoverLabel.transform.parent).toBe(stylus.transform);\r\n expect(mockError).not.toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits an error when there is no Stylus Feature\", () => {\r\n const { appObjects, factories, mockError } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeHoverLabelFeatureFactory(appObjects);\r\n factories.setupDomain();\r\n\r\n expect(mockError).toHaveBeenCalledWith(\r\n \"HoverLabelFeatureFactory\",\r\n \"StylusEntity needs to be setup for Hover Label\",\r\n );\r\n });\r\n\r\n it(\"Uses the try show factory if it is passed in\", () => {\r\n const { appObjects, factories } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeStylusFeatureFactory(appObjects);\r\n const tryShowFactory = jest.fn();\r\n const factory = makeHoverLabelFeatureFactory(appObjects, {\r\n tryShowFactory,\r\n });\r\n factories.setupDomain();\r\n\r\n expect(tryShowFactory).toHaveBeenCalledWith(factory.appObject);\r\n expect(factory.appObject.hasComponent(TryShowHoverLabel.type)).toBe(false);\r\n });\r\n});\r\n"]}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./setupHoverLabel"), exports);
|
|
18
|
+
__exportStar(require("./HoverLabelFeatureFactory"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/HoverLabel/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC","sourcesContent":["export * from \"./setupHoverLabel\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/HoverLabel/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,6DAA2C","sourcesContent":["export * from \"./setupHoverLabel\";\r\nexport * from \"./HoverLabelFeatureFactory\";\r\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LandmarksFeatureFactory = void 0;
|
|
4
|
+
exports.makeLandmarksFeatureFactory = makeLandmarksFeatureFactory;
|
|
5
|
+
const core_1 = require("@vived/core");
|
|
6
|
+
const Hideable_1 = require("../../Hideable");
|
|
7
|
+
const OverlayColor_1 = require("../../OverlayColor");
|
|
8
|
+
const Selection_1 = require("../../Selection");
|
|
9
|
+
const Tools_1 = require("../../Tools");
|
|
10
|
+
const Transform3D_1 = require("../../Transform3D");
|
|
11
|
+
const Controller_1 = require("../Controller");
|
|
12
|
+
const Entities_1 = require("../Entities");
|
|
13
|
+
const UseCases_1 = require("../UseCases");
|
|
14
|
+
const landmarkRepoFactory_1 = require("./landmarkRepoFactory");
|
|
15
|
+
/**
|
|
16
|
+
* Factory responsible for setting up the Landmarks Feature domain components.
|
|
17
|
+
*
|
|
18
|
+
* Builds the same components as the legacy setupLandmarks function, split
|
|
19
|
+
* into the DomainFactory phases, including the "LandmarkPreview" AppObject.
|
|
20
|
+
* The LANDMARK tool is created in finalSetup, so its place in the toolbar
|
|
21
|
+
* follows the order the factories are registered.
|
|
22
|
+
*
|
|
23
|
+
* @extends DomainFactory
|
|
24
|
+
*/
|
|
25
|
+
class LandmarksFeatureFactory extends core_1.DomainFactory {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.factoryName = "LandmarksFeatureFactory";
|
|
29
|
+
}
|
|
30
|
+
get previewAO() {
|
|
31
|
+
return this.appObjects.getOrCreate("LandmarkPreview");
|
|
32
|
+
}
|
|
33
|
+
setupEntities() {
|
|
34
|
+
const globals = (0, Entities_1.makeLandmarkGlobals)(this.appObject);
|
|
35
|
+
globals.landmarkRepoFactory = (0, landmarkRepoFactory_1.makeLandmarkRepoFactory)(this.appObjects);
|
|
36
|
+
const preview = (0, Entities_1.makeLandmarkEntity)(this.previewAO);
|
|
37
|
+
const previewHidable = Hideable_1.Hideable.get(this.previewAO.id, this.appObjects);
|
|
38
|
+
if (previewHidable) {
|
|
39
|
+
previewHidable.ignoreSerialization = true;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.appObjects.submitError(this.factoryName, "Unable to find Hideable on preview landmark");
|
|
43
|
+
}
|
|
44
|
+
globals.previewLandmark = preview;
|
|
45
|
+
}
|
|
46
|
+
setupUCs() {
|
|
47
|
+
new UseCases_1.SerializeLandmarks(this.appObject);
|
|
48
|
+
(0, UseCases_1.makeDeleteAllLandmarksUC)(this.appObject);
|
|
49
|
+
(0, UseCases_1.makeTryAddLandmarkUC)(this.appObject);
|
|
50
|
+
(0, UseCases_1.makeTryPreviewLandmark)(this.previewAO);
|
|
51
|
+
}
|
|
52
|
+
setupPMs() {
|
|
53
|
+
const previewAO = this.previewAO;
|
|
54
|
+
(0, Transform3D_1.makeTransform3DPM)(previewAO);
|
|
55
|
+
(0, OverlayColor_1.makeOverlayColorPM)(previewAO);
|
|
56
|
+
(0, Selection_1.makeSelectableStatePM)(previewAO);
|
|
57
|
+
(0, Hideable_1.makeIsHiddenPM)(previewAO);
|
|
58
|
+
}
|
|
59
|
+
finalSetup() {
|
|
60
|
+
(0, Controller_1.makeMouseLandmark)(this.appObject);
|
|
61
|
+
(0, Controller_1.makeTouchLandmark)(this.appObject);
|
|
62
|
+
const toolRepo = Tools_1.ToolRepository.get(this.appObjects);
|
|
63
|
+
if (!toolRepo) {
|
|
64
|
+
this.appObjects.submitError(this.factoryName, "Unable to find tool repo");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
toolRepo.makeToolFromData({
|
|
68
|
+
toolType: "LANDMARK",
|
|
69
|
+
isDefault: false,
|
|
70
|
+
label: "Landmark",
|
|
71
|
+
shortcutLabel: "l",
|
|
72
|
+
hotkeys: [{ keyCode: "KeyL" }],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.LandmarksFeatureFactory = LandmarksFeatureFactory;
|
|
77
|
+
/**
|
|
78
|
+
* Factory function to create a new LandmarksFeatureFactory
|
|
79
|
+
* @param appObjects The AppObjectRepo to get or create the Landmarks AppObject from
|
|
80
|
+
* @returns A new LandmarksFeatureFactory instance
|
|
81
|
+
*/
|
|
82
|
+
function makeLandmarksFeatureFactory(appObjects) {
|
|
83
|
+
return new LandmarksFeatureFactory(appObjects.getOrCreate("Landmarks"));
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=LandmarksFeatureFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LandmarksFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Landmarks/Factories/LandmarksFeatureFactory.ts"],"names":[],"mappings":";;;AA6FA,kEAIC;AAjGD,sCAAsE;AACtE,6CAA0D;AAC1D,qDAAwD;AACxD,+CAAwD;AACxD,uCAA6C;AAC7C,mDAAsD;AACtD,8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,IAAA,iCAAkB,EAAC,SAAS,CAAC,CAAC;QAC9B,IAAA,iCAAqB,EAAC,SAAS,CAAC,CAAC;QACjC,IAAA,yBAAc,EAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAED,UAAU;QACR,IAAA,8BAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAClC,IAAA,8BAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,sBAAc,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC;YACxB,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,UAAU;YACjB,aAAa,EAAE,GAAG;YAClB,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;CACF;AA5DD,0DA4DC;AAED;;;;GAIG;AACH,SAAgB,2BAA2B,CACzC,UAAyB;IAEzB,OAAO,IAAI,uBAAuB,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import { AppObject, AppObjectRepo, DomainFactory } from \"@vived/core\";\r\nimport { Hideable, makeIsHiddenPM } from \"../../Hideable\";\r\nimport { makeOverlayColorPM } from \"../../OverlayColor\";\r\nimport { makeSelectableStatePM } from \"../../Selection\";\r\nimport { ToolRepository } from \"../../Tools\";\r\nimport { makeTransform3DPM } from \"../../Transform3D\";\r\nimport { makeMouseLandmark, makeTouchLandmark } from \"../Controller\";\r\nimport { makeLandmarkEntity, makeLandmarkGlobals } from \"../Entities\";\r\nimport {\r\n makeDeleteAllLandmarksUC,\r\n makeTryAddLandmarkUC,\r\n makeTryPreviewLandmark,\r\n SerializeLandmarks,\r\n} from \"../UseCases\";\r\nimport { makeLandmarkRepoFactory } from \"./landmarkRepoFactory\";\r\n\r\n/**\r\n * Factory responsible for setting up the Landmarks Feature domain components.\r\n *\r\n * Builds the same components as the legacy setupLandmarks function, split\r\n * into the DomainFactory phases, including the \"LandmarkPreview\" AppObject.\r\n * The LANDMARK tool is created in finalSetup, so its place in the toolbar\r\n * follows the order the factories are registered.\r\n *\r\n * @extends DomainFactory\r\n */\r\nexport class LandmarksFeatureFactory extends DomainFactory {\r\n factoryName = \"LandmarksFeatureFactory\";\r\n\r\n private get previewAO(): AppObject {\r\n return this.appObjects.getOrCreate(\"LandmarkPreview\");\r\n }\r\n\r\n setupEntities(): void {\r\n const globals = makeLandmarkGlobals(this.appObject);\r\n globals.landmarkRepoFactory = makeLandmarkRepoFactory(this.appObjects);\r\n\r\n const preview = makeLandmarkEntity(this.previewAO);\r\n\r\n const previewHidable = Hideable.get(this.previewAO.id, this.appObjects);\r\n if (previewHidable) {\r\n previewHidable.ignoreSerialization = true;\r\n } else {\r\n this.appObjects.submitError(\r\n this.factoryName,\r\n \"Unable to find Hideable on preview landmark\",\r\n );\r\n }\r\n\r\n globals.previewLandmark = preview;\r\n }\r\n\r\n setupUCs(): void {\r\n new SerializeLandmarks(this.appObject);\r\n makeDeleteAllLandmarksUC(this.appObject);\r\n makeTryAddLandmarkUC(this.appObject);\r\n\r\n makeTryPreviewLandmark(this.previewAO);\r\n }\r\n\r\n setupPMs(): void {\r\n const previewAO = this.previewAO;\r\n makeTransform3DPM(previewAO);\r\n makeOverlayColorPM(previewAO);\r\n makeSelectableStatePM(previewAO);\r\n makeIsHiddenPM(previewAO);\r\n }\r\n\r\n finalSetup(): void {\r\n makeMouseLandmark(this.appObject);\r\n makeTouchLandmark(this.appObject);\r\n\r\n const toolRepo = ToolRepository.get(this.appObjects);\r\n if (!toolRepo) {\r\n this.appObjects.submitError(this.factoryName, \"Unable to find tool repo\");\r\n return;\r\n }\r\n\r\n toolRepo.makeToolFromData({\r\n toolType: \"LANDMARK\",\r\n isDefault: false,\r\n label: \"Landmark\",\r\n shortcutLabel: \"l\",\r\n hotkeys: [{ keyCode: \"KeyL\" }],\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new LandmarksFeatureFactory\r\n * @param appObjects The AppObjectRepo to get or create the Landmarks AppObject from\r\n * @returns A new LandmarksFeatureFactory instance\r\n */\r\nexport function makeLandmarksFeatureFactory(\r\n appObjects: AppObjectRepo,\r\n): LandmarksFeatureFactory {\r\n return new LandmarksFeatureFactory(appObjects.getOrCreate(\"Landmarks\"));\r\n}\r\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@vived/core");
|
|
4
|
+
const BaseAppState_1 = require("../../BaseApp/Entity/BaseAppState");
|
|
5
|
+
const Callouts_1 = require("../../Callouts");
|
|
6
|
+
const Hideable_1 = require("../../Hideable");
|
|
7
|
+
const KeyboardInput_1 = require("../../KeyboardInput");
|
|
8
|
+
const MouseInput_1 = require("../../MouseInput");
|
|
9
|
+
const Selection_1 = require("../../Selection");
|
|
10
|
+
const StateMachine_1 = require("../../StateMachine");
|
|
11
|
+
const Tools_1 = require("../../Tools");
|
|
12
|
+
const TouchController_1 = require("../../TouchController");
|
|
13
|
+
const Entities_1 = require("../Entities");
|
|
14
|
+
const LandmarksFeatureFactory_1 = require("./LandmarksFeatureFactory");
|
|
15
|
+
const setupLandmarks_1 = require("./setupLandmarks");
|
|
16
|
+
function makeTestRig() {
|
|
17
|
+
const appObjects = (0, core_1.makeAppObjectRepo)();
|
|
18
|
+
const factories = (0, core_1.makeDomainFactoryRepo)(appObjects);
|
|
19
|
+
const mockError = jest.fn();
|
|
20
|
+
appObjects.submitError = mockError;
|
|
21
|
+
return { appObjects, factories, mockError };
|
|
22
|
+
}
|
|
23
|
+
function registerCollaborators(appObjects) {
|
|
24
|
+
(0, KeyboardInput_1.makeKeyboardInputFeatureFactory)(appObjects);
|
|
25
|
+
(0, MouseInput_1.makeMouseInputFeatureFactory)(appObjects);
|
|
26
|
+
(0, TouchController_1.makeTouchControllerFeatureFactory)(appObjects);
|
|
27
|
+
(0, StateMachine_1.makeStateMachineFeatureFactory)(appObjects);
|
|
28
|
+
(0, BaseAppState_1.makeBaseAppState)(appObjects.getOrCreate("BaseApp"));
|
|
29
|
+
(0, Selection_1.makeSelectionFeatureFactory)(appObjects);
|
|
30
|
+
}
|
|
31
|
+
function componentTypes(appObjects) {
|
|
32
|
+
const types = {};
|
|
33
|
+
appObjects.getAll().forEach((ao) => {
|
|
34
|
+
types[ao.id] = ao
|
|
35
|
+
.allComponents()
|
|
36
|
+
.filter((c) => !(c instanceof core_1.DomainFactory))
|
|
37
|
+
.map((c) => c.type)
|
|
38
|
+
.sort();
|
|
39
|
+
});
|
|
40
|
+
return types;
|
|
41
|
+
}
|
|
42
|
+
function toolTypes(appObjects) {
|
|
43
|
+
return Tools_1.ToolRepository.get(appObjects).allTools.map((t) => t.toolType);
|
|
44
|
+
}
|
|
45
|
+
describe("LandmarksFeatureFactory", () => {
|
|
46
|
+
it("Builds the same components as setupLandmarks", () => {
|
|
47
|
+
const legacy = makeTestRig();
|
|
48
|
+
registerCollaborators(legacy.appObjects);
|
|
49
|
+
(0, Tools_1.makeToolsFeatureFactory)(legacy.appObjects);
|
|
50
|
+
legacy.factories.setupDomain();
|
|
51
|
+
(0, setupLandmarks_1.setupLandmarks)(legacy.appObjects);
|
|
52
|
+
const { appObjects, factories, mockError } = makeTestRig();
|
|
53
|
+
registerCollaborators(appObjects);
|
|
54
|
+
(0, Tools_1.makeToolsFeatureFactory)(appObjects);
|
|
55
|
+
(0, LandmarksFeatureFactory_1.makeLandmarksFeatureFactory)(appObjects);
|
|
56
|
+
factories.setupDomain();
|
|
57
|
+
expect(componentTypes(appObjects)).toEqual(componentTypes(legacy.appObjects));
|
|
58
|
+
expect(mockError).not.toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
it("Sets up the preview landmark", () => {
|
|
61
|
+
const { appObjects, factories } = makeTestRig();
|
|
62
|
+
registerCollaborators(appObjects);
|
|
63
|
+
(0, Tools_1.makeToolsFeatureFactory)(appObjects);
|
|
64
|
+
(0, LandmarksFeatureFactory_1.makeLandmarksFeatureFactory)(appObjects);
|
|
65
|
+
factories.setupDomain();
|
|
66
|
+
const preview = Entities_1.LandmarkGlobals.get(appObjects).previewLandmark;
|
|
67
|
+
expect(preview?.appObject.id).toEqual("LandmarkPreview");
|
|
68
|
+
expect(Hideable_1.Hideable.get("LandmarkPreview", appObjects).ignoreSerialization).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
it("Creates the LANDMARK tool in finalSetup", () => {
|
|
71
|
+
const { appObjects, factories } = makeTestRig();
|
|
72
|
+
registerCollaborators(appObjects);
|
|
73
|
+
(0, Tools_1.makeToolsFeatureFactory)(appObjects);
|
|
74
|
+
(0, LandmarksFeatureFactory_1.makeLandmarksFeatureFactory)(appObjects);
|
|
75
|
+
const all = factories.getAll();
|
|
76
|
+
all.forEach((f) => f.setupEntities());
|
|
77
|
+
all.forEach((f) => f.setupUCs());
|
|
78
|
+
all.forEach((f) => f.setupPMs());
|
|
79
|
+
expect(Tools_1.ToolRepository.get(appObjects).getTool("LANDMARK")).toBeUndefined();
|
|
80
|
+
all.forEach((f) => f.finalSetup());
|
|
81
|
+
expect(Tools_1.ToolRepository.get(appObjects).getTool("LANDMARK")).toBeDefined();
|
|
82
|
+
});
|
|
83
|
+
it("Creates tools in factory registration order", () => {
|
|
84
|
+
const first = makeTestRig();
|
|
85
|
+
registerCollaborators(first.appObjects);
|
|
86
|
+
(0, LandmarksFeatureFactory_1.makeLandmarksFeatureFactory)(first.appObjects);
|
|
87
|
+
(0, Callouts_1.makeCalloutsFeatureFactory)(first.appObjects);
|
|
88
|
+
(0, Tools_1.makeToolsFeatureFactory)(first.appObjects);
|
|
89
|
+
first.factories.setupDomain();
|
|
90
|
+
const second = makeTestRig();
|
|
91
|
+
registerCollaborators(second.appObjects);
|
|
92
|
+
(0, Callouts_1.makeCalloutsFeatureFactory)(second.appObjects);
|
|
93
|
+
(0, LandmarksFeatureFactory_1.makeLandmarksFeatureFactory)(second.appObjects);
|
|
94
|
+
(0, Tools_1.makeToolsFeatureFactory)(second.appObjects);
|
|
95
|
+
second.factories.setupDomain();
|
|
96
|
+
expect(toolTypes(first.appObjects)).toEqual(["LANDMARK", "CALLOUT"]);
|
|
97
|
+
expect(toolTypes(second.appObjects)).toEqual(["CALLOUT", "LANDMARK"]);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=LandmarksFeatureFactory.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LandmarksFeatureFactory.test.js","sourceRoot":"","sources":["../../../../src/Landmarks/Factories/LandmarksFeatureFactory.test.ts"],"names":[],"mappings":";;AAAA,sCAKqB;AACrB,oEAAqE;AACrE,6CAA4D;AAC5D,6CAA0C;AAC1C,uDAAsE;AACtE,iDAAgE;AAChE,+CAA8D;AAC9D,qDAAoE;AACpE,uCAAsE;AACtE,2DAA0E;AAC1E,0CAA8C;AAC9C,uEAAwE;AACxE,qDAAkD;AAElD,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,IAAA,wBAAiB,GAAE,CAAC;IACvC,MAAM,SAAS,GAAG,IAAA,4BAAqB,EAAC,UAAU,CAAC,CAAC;IAEpD,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAC5B,UAAU,CAAC,WAAW,GAAG,SAAS,CAAC;IAEnC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAyB;IACtD,IAAA,+CAA+B,EAAC,UAAU,CAAC,CAAC;IAC5C,IAAA,yCAA4B,EAAC,UAA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AM,CAAC,UAAU,CAAC,CAAC;QAC9C,IAAA,qDAA2B,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAA,+BAAuB,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3C,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAE/B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;QACrE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\r\n AppObjectRepo,\r\n DomainFactory,\r\n makeAppObjectRepo,\r\n makeDomainFactoryRepo,\r\n} from \"@vived/core\";\r\nimport { makeBaseAppState } from \"../../BaseApp/Entity/BaseAppState\";\r\nimport { makeCalloutsFeatureFactory } from \"../../Callouts\";\r\nimport { Hideable } from \"../../Hideable\";\r\nimport { makeKeyboardInputFeatureFactory } from \"../../KeyboardInput\";\r\nimport { makeMouseInputFeatureFactory } from \"../../MouseInput\";\r\nimport { makeSelectionFeatureFactory } from \"../../Selection\";\r\nimport { makeStateMachineFeatureFactory } from \"../../StateMachine\";\r\nimport { makeToolsFeatureFactory, ToolRepository } from \"../../Tools\";\r\nimport { makeTouchControllerFeatureFactory } from \"../../TouchController\";\r\nimport { LandmarkGlobals } from \"../Entities\";\r\nimport { makeLandmarksFeatureFactory } from \"./LandmarksFeatureFactory\";\r\nimport { setupLandmarks } from \"./setupLandmarks\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n const factories = makeDomainFactoryRepo(appObjects);\r\n\r\n const mockError = jest.fn();\r\n appObjects.submitError = mockError;\r\n\r\n return { appObjects, factories, mockError };\r\n}\r\n\r\nfunction registerCollaborators(appObjects: AppObjectRepo) {\r\n makeKeyboardInputFeatureFactory(appObjects);\r\n makeMouseInputFeatureFactory(appObjects);\r\n makeTouchControllerFeatureFactory(appObjects);\r\n makeStateMachineFeatureFactory(appObjects);\r\n makeBaseAppState(appObjects.getOrCreate(\"BaseApp\"));\r\n makeSelectionFeatureFactory(appObjects);\r\n}\r\n\r\nfunction componentTypes(appObjects: AppObjectRepo) {\r\n const types: { [id: string]: string[] } = {};\r\n appObjects.getAll().forEach((ao) => {\r\n types[ao.id] = ao\r\n .allComponents()\r\n .filter((c) => !(c instanceof DomainFactory))\r\n .map((c) => c.type)\r\n .sort();\r\n });\r\n return types;\r\n}\r\n\r\nfunction toolTypes(appObjects: AppObjectRepo) {\r\n return ToolRepository.get(appObjects)!.allTools.map((t) => t.toolType);\r\n}\r\n\r\ndescribe(\"LandmarksFeatureFactory\", () => {\r\n it(\"Builds the same components as setupLandmarks\", () => {\r\n const legacy = makeTestRig();\r\n registerCollaborators(legacy.appObjects);\r\n makeToolsFeatureFactory(legacy.appObjects);\r\n legacy.factories.setupDomain();\r\n setupLandmarks(legacy.appObjects);\r\n\r\n const { appObjects, factories, mockError } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeToolsFeatureFactory(appObjects);\r\n makeLandmarksFeatureFactory(appObjects);\r\n factories.setupDomain();\r\n\r\n expect(componentTypes(appObjects)).toEqual(\r\n componentTypes(legacy.appObjects),\r\n );\r\n expect(mockError).not.toHaveBeenCalled();\r\n });\r\n\r\n it(\"Sets up the preview landmark\", () => {\r\n const { appObjects, factories } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeToolsFeatureFactory(appObjects);\r\n makeLandmarksFeatureFactory(appObjects);\r\n factories.setupDomain();\r\n\r\n const preview = LandmarkGlobals.get(appObjects)!.previewLandmark;\r\n expect(preview?.appObject.id).toEqual(\"LandmarkPreview\");\r\n expect(\r\n Hideable.get(\"LandmarkPreview\", appObjects)!.ignoreSerialization,\r\n ).toBe(true);\r\n });\r\n\r\n it(\"Creates the LANDMARK tool in finalSetup\", () => {\r\n const { appObjects, factories } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeToolsFeatureFactory(appObjects);\r\n makeLandmarksFeatureFactory(appObjects);\r\n\r\n const all = factories.getAll();\r\n all.forEach((f) => f.setupEntities());\r\n all.forEach((f) => f.setupUCs());\r\n all.forEach((f) => f.setupPMs());\r\n expect(ToolRepository.get(appObjects)!.getTool(\"LANDMARK\")).toBeUndefined();\r\n\r\n all.forEach((f) => f.finalSetup());\r\n expect(ToolRepository.get(appObjects)!.getTool(\"LANDMARK\")).toBeDefined();\r\n });\r\n\r\n it(\"Creates tools in factory registration order\", () => {\r\n const first = makeTestRig();\r\n registerCollaborators(first.appObjects);\r\n makeLandmarksFeatureFactory(first.appObjects);\r\n makeCalloutsFeatureFactory(first.appObjects);\r\n makeToolsFeatureFactory(first.appObjects);\r\n first.factories.setupDomain();\r\n\r\n const second = makeTestRig();\r\n registerCollaborators(second.appObjects);\r\n makeCalloutsFeatureFactory(second.appObjects);\r\n makeLandmarksFeatureFactory(second.appObjects);\r\n makeToolsFeatureFactory(second.appObjects);\r\n second.factories.setupDomain();\r\n\r\n expect(toolTypes(first.appObjects)).toEqual([\"LANDMARK\", \"CALLOUT\"]);\r\n expect(toolTypes(second.appObjects)).toEqual([\"CALLOUT\", \"LANDMARK\"]);\r\n });\r\n});\r\n"]}
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./landmarkFactory"), exports);
|
|
18
18
|
__exportStar(require("./landmarkRepoFactory"), exports);
|
|
19
19
|
__exportStar(require("./setupLandmarks"), exports);
|
|
20
|
+
__exportStar(require("./LandmarksFeatureFactory"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Landmarks/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,wDAAsC;AACtC,mDAAiC","sourcesContent":["export * from \"./landmarkFactory\";\nexport * from \"./landmarkRepoFactory\";\nexport * from \"./setupLandmarks\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Landmarks/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,wDAAsC;AACtC,mDAAiC;AACjC,4DAA0C","sourcesContent":["export * from \"./landmarkFactory\";\r\nexport * from \"./landmarkRepoFactory\";\r\nexport * from \"./setupLandmarks\";\r\nexport * from \"./LandmarksFeatureFactory\";\r\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectionFeatureFactory = void 0;
|
|
4
|
+
exports.makeSelectionFeatureFactory = makeSelectionFeatureFactory;
|
|
5
|
+
const core_1 = require("@vived/core");
|
|
6
|
+
const Controller_1 = require("../Controller");
|
|
7
|
+
const Entities_1 = require("../Entities");
|
|
8
|
+
const PM_1 = require("../PM");
|
|
9
|
+
const UC_1 = require("../UC");
|
|
10
|
+
/**
|
|
11
|
+
* Factory responsible for setting up the Selection Feature domain components.
|
|
12
|
+
*
|
|
13
|
+
* Builds the same components as the legacy setupSelection function, split
|
|
14
|
+
* into the DomainFactory phases.
|
|
15
|
+
*
|
|
16
|
+
* The Hover, Press and Select UCs exist after setupUCs. An app that overrides
|
|
17
|
+
* their allow* hooks can do so from its own factory's setupPMs or finalSetup,
|
|
18
|
+
* through HoverAppObjectUC.get, PressAppObjectUC.get and SelectAppObjectUC.get.
|
|
19
|
+
*
|
|
20
|
+
* @extends DomainFactory
|
|
21
|
+
*/
|
|
22
|
+
class SelectionFeatureFactory extends core_1.DomainFactory {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.factoryName = "SelectionFeatureFactory";
|
|
26
|
+
}
|
|
27
|
+
setupEntities() {
|
|
28
|
+
(0, Entities_1.makeSelection)(this.appObject);
|
|
29
|
+
}
|
|
30
|
+
setupUCs() {
|
|
31
|
+
new UC_1.ClearSelectionUCHook(this.appObject);
|
|
32
|
+
(0, UC_1.makeHoverAppObject)(this.appObject);
|
|
33
|
+
(0, UC_1.makePressAppObject)(this.appObject);
|
|
34
|
+
(0, UC_1.makeSelectAppObject)(this.appObject);
|
|
35
|
+
}
|
|
36
|
+
setupPMs() {
|
|
37
|
+
(0, PM_1.makeSelectedObjectPM)(this.appObject);
|
|
38
|
+
}
|
|
39
|
+
finalSetup() {
|
|
40
|
+
new Controller_1.MouseHoverOnAppObject(this.appObject);
|
|
41
|
+
new Controller_1.MousePressOnAppObject(this.appObject);
|
|
42
|
+
new Controller_1.TouchPressOnAppObject(this.appObject);
|
|
43
|
+
new Controller_1.MouseSelectAppObject(this.appObject);
|
|
44
|
+
new Controller_1.TapToSelectAppObject(this.appObject);
|
|
45
|
+
new Controller_1.KeyboardToClearSelection(this.appObject);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.SelectionFeatureFactory = SelectionFeatureFactory;
|
|
49
|
+
/**
|
|
50
|
+
* Factory function to create a new SelectionFeatureFactory
|
|
51
|
+
* @param appObjects The AppObjectRepo to get or create the Selection AppObject from
|
|
52
|
+
* @returns A new SelectionFeatureFactory instance
|
|
53
|
+
*/
|
|
54
|
+
function makeSelectionFeatureFactory(appObjects) {
|
|
55
|
+
return new SelectionFeatureFactory(appObjects.getOrCreate("Selection"));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=SelectionFeatureFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Selection/Factories/SelectionFeatureFactory.ts"],"names":[],"mappings":";;;AA+DA,kEAIC;AAnED,sCAA2D;AAC3D,8CAOuB;AACvB,0CAA4C;AAC5C,8BAA6C;AAC7C,8BAKe;AAEf;;;;;;;;;;;GAWG;AACH,MAAa,uBAAwB,SAAQ,oBAAa;IAA1D;;QACE,gBAAW,GAAG,yBAAyB,CAAC;IAyB1C,CAAC;IAvBC,aAAa;QACX,IAAA,wBAAa,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,QAAQ;QACN,IAAI,yBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,IAAA,uBAAkB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnC,IAAA,uBAAkB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnC,IAAA,wBAAmB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACN,IAAA,yBAAoB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,UAAU;QACR,IAAI,kCAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,kCAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,kCAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,iCAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,iCAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,qCAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;CACF;AA1BD,0DA0BC;AAED;;;;GAIG;AACH,SAAgB,2BAA2B,CACzC,UAAyB;IAEzB,OAAO,IAAI,uBAAuB,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import { AppObjectRepo, DomainFactory } from \"@vived/core\";\r\nimport {\r\n KeyboardToClearSelection,\r\n MouseHoverOnAppObject,\r\n MousePressOnAppObject,\r\n MouseSelectAppObject,\r\n TapToSelectAppObject,\r\n TouchPressOnAppObject,\r\n} from \"../Controller\";\r\nimport { makeSelection } from \"../Entities\";\r\nimport { makeSelectedObjectPM } from \"../PM\";\r\nimport {\r\n ClearSelectionUCHook,\r\n makeHoverAppObject,\r\n makePressAppObject,\r\n makeSelectAppObject,\r\n} from \"../UC\";\r\n\r\n/**\r\n * Factory responsible for setting up the Selection Feature domain components.\r\n *\r\n * Builds the same components as the legacy setupSelection function, split\r\n * into the DomainFactory phases.\r\n *\r\n * The Hover, Press and Select UCs exist after setupUCs. An app that overrides\r\n * their allow* hooks can do so from its own factory's setupPMs or finalSetup,\r\n * through HoverAppObjectUC.get, PressAppObjectUC.get and SelectAppObjectUC.get.\r\n *\r\n * @extends DomainFactory\r\n */\r\nexport class SelectionFeatureFactory extends DomainFactory {\r\n factoryName = \"SelectionFeatureFactory\";\r\n\r\n setupEntities(): void {\r\n makeSelection(this.appObject);\r\n }\r\n\r\n setupUCs(): void {\r\n new ClearSelectionUCHook(this.appObject);\r\n makeHoverAppObject(this.appObject);\r\n makePressAppObject(this.appObject);\r\n makeSelectAppObject(this.appObject);\r\n }\r\n\r\n setupPMs(): void {\r\n makeSelectedObjectPM(this.appObject);\r\n }\r\n\r\n finalSetup(): void {\r\n new MouseHoverOnAppObject(this.appObject);\r\n new MousePressOnAppObject(this.appObject);\r\n new TouchPressOnAppObject(this.appObject);\r\n new MouseSelectAppObject(this.appObject);\r\n new TapToSelectAppObject(this.appObject);\r\n new KeyboardToClearSelection(this.appObject);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new SelectionFeatureFactory\r\n * @param appObjects The AppObjectRepo to get or create the Selection AppObject from\r\n * @returns A new SelectionFeatureFactory instance\r\n */\r\nexport function makeSelectionFeatureFactory(\r\n appObjects: AppObjectRepo,\r\n): SelectionFeatureFactory {\r\n return new SelectionFeatureFactory(appObjects.getOrCreate(\"Selection\"));\r\n}\r\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@vived/core");
|
|
4
|
+
const BaseAppState_1 = require("../../BaseApp/Entity/BaseAppState");
|
|
5
|
+
const KeyboardInput_1 = require("../../KeyboardInput");
|
|
6
|
+
const MouseInput_1 = require("../../MouseInput");
|
|
7
|
+
const TouchController_1 = require("../../TouchController");
|
|
8
|
+
const UC_1 = require("../UC");
|
|
9
|
+
const SelectionFeatureFactory_1 = require("./SelectionFeatureFactory");
|
|
10
|
+
const setupSelection_1 = require("./setupSelection");
|
|
11
|
+
function makeTestRig() {
|
|
12
|
+
const appObjects = (0, core_1.makeAppObjectRepo)();
|
|
13
|
+
const factories = (0, core_1.makeDomainFactoryRepo)(appObjects);
|
|
14
|
+
const mockError = jest.fn();
|
|
15
|
+
appObjects.submitError = mockError;
|
|
16
|
+
return { appObjects, factories, mockError };
|
|
17
|
+
}
|
|
18
|
+
function registerCollaborators(appObjects) {
|
|
19
|
+
(0, BaseAppState_1.makeBaseAppState)(appObjects.getOrCreate("BaseApp"));
|
|
20
|
+
(0, KeyboardInput_1.makeKeyboardInputFeatureFactory)(appObjects);
|
|
21
|
+
(0, MouseInput_1.makeMouseInputFeatureFactory)(appObjects);
|
|
22
|
+
(0, TouchController_1.makeTouchControllerFeatureFactory)(appObjects);
|
|
23
|
+
}
|
|
24
|
+
function componentTypes(appObjects) {
|
|
25
|
+
const types = {};
|
|
26
|
+
appObjects.getAll().forEach((ao) => {
|
|
27
|
+
types[ao.id] = ao
|
|
28
|
+
.allComponents()
|
|
29
|
+
.filter((c) => !(c instanceof core_1.DomainFactory))
|
|
30
|
+
.map((c) => c.type)
|
|
31
|
+
.sort();
|
|
32
|
+
});
|
|
33
|
+
return types;
|
|
34
|
+
}
|
|
35
|
+
describe("SelectionFeatureFactory", () => {
|
|
36
|
+
it("Builds the same components as setupSelection", () => {
|
|
37
|
+
const legacy = makeTestRig();
|
|
38
|
+
registerCollaborators(legacy.appObjects);
|
|
39
|
+
legacy.factories.setupDomain();
|
|
40
|
+
(0, setupSelection_1.setupSelection)(legacy.appObjects);
|
|
41
|
+
const { appObjects, factories, mockError } = makeTestRig();
|
|
42
|
+
registerCollaborators(appObjects);
|
|
43
|
+
(0, SelectionFeatureFactory_1.makeSelectionFeatureFactory)(appObjects);
|
|
44
|
+
factories.setupDomain();
|
|
45
|
+
expect(componentTypes(appObjects)).toEqual(componentTypes(legacy.appObjects));
|
|
46
|
+
expect(mockError).not.toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
it("Builds the Hover, Press and Select UCs in setupUCs, so a later phase can override their allow hooks", () => {
|
|
49
|
+
const { appObjects, factories } = makeTestRig();
|
|
50
|
+
registerCollaborators(appObjects);
|
|
51
|
+
(0, SelectionFeatureFactory_1.makeSelectionFeatureFactory)(appObjects);
|
|
52
|
+
const all = factories.getAll();
|
|
53
|
+
all.forEach((f) => f.setupEntities());
|
|
54
|
+
all.forEach((f) => f.setupUCs());
|
|
55
|
+
expect(UC_1.HoverAppObjectUC.get(appObjects)).toBeDefined();
|
|
56
|
+
expect(UC_1.PressAppObjectUC.get(appObjects)).toBeDefined();
|
|
57
|
+
expect(UC_1.SelectAppObjectUC.get(appObjects)).toBeDefined();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=SelectionFeatureFactory.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionFeatureFactory.test.js","sourceRoot":"","sources":["../../../../src/Selection/Factories/SelectionFeatureFactory.test.ts"],"names":[],"mappings":";;AAAA,sCAKqB;AACrB,oEAAqE;AACrE,uDAAsE;AACtE,iDAAgE;AAChE,2DAA0E;AAC1E,8BAA8E;AAC9E,uEAAwE;AACxE,qDAAkD;AAElD,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,IAAA,wBAAiB,GAAE,CAAC;IACvC,MAAM,SAAS,GAAG,IAAA,4BAAqB,EAAC,UAAU,CAAC,CAAC;IAEpD,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE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AAU,CAAC,CAAC;QAClC,IAAA,qDAA2B,EAAC,UAAU,CAAC,CAAC;QACxC,SAAS,CAAC,WAAW,EAAE,CAAC;QAExB,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CACxC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAClC,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qGAAqG,EAAE,GAAG,EAAE;QAC7G,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,WAAW,EAAE,CAAC;QAChD,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAClC,IAAA,qDAA2B,EAAC,UAAU,CAAC,CAAC;QAExC,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;QACtC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEjC,MAAM,CAAC,qBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACvD,MAAM,CAAC,qBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACvD,MAAM,CAAC,sBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\r\n AppObjectRepo,\r\n DomainFactory,\r\n makeAppObjectRepo,\r\n makeDomainFactoryRepo,\r\n} from \"@vived/core\";\r\nimport { makeBaseAppState } from \"../../BaseApp/Entity/BaseAppState\";\r\nimport { makeKeyboardInputFeatureFactory } from \"../../KeyboardInput\";\r\nimport { makeMouseInputFeatureFactory } from \"../../MouseInput\";\r\nimport { makeTouchControllerFeatureFactory } from \"../../TouchController\";\r\nimport { HoverAppObjectUC, PressAppObjectUC, SelectAppObjectUC } from \"../UC\";\r\nimport { makeSelectionFeatureFactory } from \"./SelectionFeatureFactory\";\r\nimport { setupSelection } from \"./setupSelection\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n const factories = makeDomainFactoryRepo(appObjects);\r\n\r\n const mockError = jest.fn();\r\n appObjects.submitError = mockError;\r\n\r\n return { appObjects, factories, mockError };\r\n}\r\n\r\nfunction registerCollaborators(appObjects: AppObjectRepo) {\r\n makeBaseAppState(appObjects.getOrCreate(\"BaseApp\"));\r\n makeKeyboardInputFeatureFactory(appObjects);\r\n makeMouseInputFeatureFactory(appObjects);\r\n makeTouchControllerFeatureFactory(appObjects);\r\n}\r\n\r\nfunction componentTypes(appObjects: AppObjectRepo) {\r\n const types: { [id: string]: string[] } = {};\r\n appObjects.getAll().forEach((ao) => {\r\n types[ao.id] = ao\r\n .allComponents()\r\n .filter((c) => !(c instanceof DomainFactory))\r\n .map((c) => c.type)\r\n .sort();\r\n });\r\n return types;\r\n}\r\n\r\ndescribe(\"SelectionFeatureFactory\", () => {\r\n it(\"Builds the same components as setupSelection\", () => {\r\n const legacy = makeTestRig();\r\n registerCollaborators(legacy.appObjects);\r\n legacy.factories.setupDomain();\r\n setupSelection(legacy.appObjects);\r\n\r\n const { appObjects, factories, mockError } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeSelectionFeatureFactory(appObjects);\r\n factories.setupDomain();\r\n\r\n expect(componentTypes(appObjects)).toEqual(\r\n componentTypes(legacy.appObjects),\r\n );\r\n expect(mockError).not.toHaveBeenCalled();\r\n });\r\n\r\n it(\"Builds the Hover, Press and Select UCs in setupUCs, so a later phase can override their allow hooks\", () => {\r\n const { appObjects, factories } = makeTestRig();\r\n registerCollaborators(appObjects);\r\n makeSelectionFeatureFactory(appObjects);\r\n\r\n const all = factories.getAll();\r\n all.forEach((f) => f.setupEntities());\r\n all.forEach((f) => f.setupUCs());\r\n\r\n expect(HoverAppObjectUC.get(appObjects)).toBeDefined();\r\n expect(PressAppObjectUC.get(appObjects)).toBeDefined();\r\n expect(SelectAppObjectUC.get(appObjects)).toBeDefined();\r\n });\r\n});\r\n"]}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./setupSelection"), exports);
|
|
18
|
+
__exportStar(require("./SelectionFeatureFactory"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Selection/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC","sourcesContent":["export * from \"./setupSelection\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Selection/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,4DAA0C","sourcesContent":["export * from \"./setupSelection\";\r\nexport * from \"./SelectionFeatureFactory\";\r\n"]}
|