@vived/app 4.10.1 → 4.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,6 +4,9 @@ export declare class AppObjectComponent {
|
|
|
4
4
|
readonly type: string;
|
|
5
5
|
readonly appObject: AppObject;
|
|
6
6
|
get appObjects(): AppObjectRepo;
|
|
7
|
+
private cachedSingletons;
|
|
8
|
+
getCachedSingleton<T extends AppObjectComponent>(type: string): T | undefined;
|
|
9
|
+
getSingleton<T extends AppObjectComponent>(type: string, logType?: "LOG" | "WARN" | "ERROR"): T | undefined;
|
|
7
10
|
dispose(): void;
|
|
8
11
|
log(message: string): void;
|
|
9
12
|
warn(message: string): void;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppObjectComponent = void 0;
|
|
4
4
|
class AppObjectComponent {
|
|
5
5
|
constructor(appObject, type) {
|
|
6
|
+
this.cachedSingletons = new Map();
|
|
6
7
|
this.appObject = appObject;
|
|
7
8
|
this.type = type;
|
|
8
9
|
appObject.addComponent(this);
|
|
@@ -10,6 +11,37 @@ class AppObjectComponent {
|
|
|
10
11
|
get appObjects() {
|
|
11
12
|
return this.appObject.appObjectRepo;
|
|
12
13
|
}
|
|
14
|
+
getCachedSingleton(type) {
|
|
15
|
+
if (!this.cachedSingletons.has(type)) {
|
|
16
|
+
const component = this.appObjects.getSingleton(type);
|
|
17
|
+
if (!component) {
|
|
18
|
+
this.warn("Unable to get cached singleton type " + type);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.cachedSingletons.set(type, component);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return this.cachedSingletons.get(type);
|
|
25
|
+
}
|
|
26
|
+
getSingleton(type, logType = "WARN") {
|
|
27
|
+
const comp = this.appObjects.getSingleton(type);
|
|
28
|
+
if (!comp) {
|
|
29
|
+
const msg = "Unable to get singleton type " + type;
|
|
30
|
+
switch (logType) {
|
|
31
|
+
case "ERROR":
|
|
32
|
+
this.error(msg);
|
|
33
|
+
break;
|
|
34
|
+
case "LOG":
|
|
35
|
+
this.log(msg);
|
|
36
|
+
break;
|
|
37
|
+
case "WARN":
|
|
38
|
+
this.warn(msg);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return comp;
|
|
43
|
+
}
|
|
44
|
+
;
|
|
13
45
|
dispose() {
|
|
14
46
|
if (this.appObject.getComponent(this.type) === this) {
|
|
15
47
|
this.appObject.removeComponent(this.type);
|
|
@@ -21,6 +53,7 @@ class AppObjectComponent {
|
|
|
21
53
|
warn(message) {
|
|
22
54
|
this.appObjects.submitWarning(`${this.appObject.id}/${this.type}`, message);
|
|
23
55
|
}
|
|
56
|
+
;
|
|
24
57
|
error(message) {
|
|
25
58
|
this.appObjects.submitError(`${this.appObject.id}/${this.type}`, message);
|
|
26
59
|
}
|
|
@@ -2,14 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSingletonComponent = void 0;
|
|
4
4
|
function getSingletonComponent(type, appObjects) {
|
|
5
|
-
|
|
6
|
-
if (components.length === 0) {
|
|
7
|
-
appObjects.submitWarning("HasStoredViewPM", `Unable to find component ${type}. Add one on Mount`);
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
else if (components.length > 1) {
|
|
11
|
-
appObjects.submitWarning("HasStoredViewPM", `Multiple ${type} found. There should only be one. Using the first one`);
|
|
12
|
-
}
|
|
13
|
-
return components[0];
|
|
5
|
+
return appObjects.getSingleton(type);
|
|
14
6
|
}
|
|
15
7
|
exports.getSingletonComponent = getSingletonComponent;
|
|
@@ -6,15 +6,7 @@ const Dispatcher_1 = require("../../Dispatcher");
|
|
|
6
6
|
const HoverLabel_1 = require("../Entities/HoverLabel");
|
|
7
7
|
class ToggleAllowHoverLabelUC extends AppObject_1.AppObjectUC {
|
|
8
8
|
static get(appObjects) {
|
|
9
|
-
|
|
10
|
-
if (ucs.length === 0) {
|
|
11
|
-
console.warn("Unable to find a ToggleAllowHoverLabelUC. Add one on Mount");
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
else if (ucs.length > 1) {
|
|
15
|
-
console.warn("Multiple ToggleAllowHoverLabelUC have been found. There should only be one. Using the first one");
|
|
16
|
-
}
|
|
17
|
-
return ucs[0];
|
|
9
|
+
return AppObject_1.getSingletonComponent(ToggleAllowHoverLabelUC.type, appObjects);
|
|
18
10
|
}
|
|
19
11
|
}
|
|
20
12
|
exports.ToggleAllowHoverLabelUC = ToggleAllowHoverLabelUC;
|
|
@@ -29,7 +21,8 @@ class ToggleAllowHoverLabelIMP extends ToggleAllowHoverLabelUC {
|
|
|
29
21
|
this.toggleAllowHoverLabel = () => {
|
|
30
22
|
if (!this.hoverLabelEntity)
|
|
31
23
|
return;
|
|
32
|
-
this.hoverLabelEntity.allowHoverLabel = !this.hoverLabelEntity
|
|
24
|
+
this.hoverLabelEntity.allowHoverLabel = !this.hoverLabelEntity
|
|
25
|
+
.allowHoverLabel;
|
|
33
26
|
Dispatcher_1.dispatchStateChange(this.appObjects);
|
|
34
27
|
};
|
|
35
28
|
this.hoverLabelEntity = this.appObject.getComponent(HoverLabel_1.HoverLabelEntity.type);
|