@sprucelabs/spruce-heartwood-utils 5.14.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,6 +18,8 @@ export default class RemoteViewControllerFactory implements Factory {
|
|
|
18
18
|
Controller(name: string, options: Record<string, any>): any;
|
|
19
19
|
private getNamespace;
|
|
20
20
|
getController(name: string): any;
|
|
21
|
+
fetchRemoteController(name: string): Promise<any>;
|
|
21
22
|
RemoteController(name: string, options: Record<string, any>): Promise<any>;
|
|
23
|
+
private optionallLoadController;
|
|
22
24
|
}
|
|
23
25
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
4
|
-
const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
5
4
|
class RemoteViewControllerFactory {
|
|
6
5
|
constructor(options) {
|
|
7
6
|
this.themesByNamespace = {};
|
|
@@ -26,16 +25,23 @@ class RemoteViewControllerFactory {
|
|
|
26
25
|
getController(name) {
|
|
27
26
|
return this.vcFactory.getController(name);
|
|
28
27
|
}
|
|
28
|
+
async fetchRemoteController(name) {
|
|
29
|
+
await this.optionallLoadController(name);
|
|
30
|
+
return this.vcFactory.getController(name);
|
|
31
|
+
}
|
|
29
32
|
async RemoteController(name, options) {
|
|
33
|
+
await this.optionallLoadController(name);
|
|
34
|
+
return this.vcFactory.Controller(name, options);
|
|
35
|
+
}
|
|
36
|
+
async optionallLoadController(name) {
|
|
30
37
|
const namespace = this.getNamespace(name);
|
|
31
38
|
if (!this.hasController(name) && namespace) {
|
|
32
39
|
const client = await this.connectToApi();
|
|
33
|
-
const
|
|
40
|
+
const [{ source, theme }] = await client.emitAndFlattenResponses('heartwood.get-skill-views::v2021_02_11', {
|
|
34
41
|
target: {
|
|
35
42
|
namespace,
|
|
36
43
|
},
|
|
37
44
|
});
|
|
38
|
-
const { source, theme } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
39
45
|
const importer = heartwood_view_controllers_1.ViewControllerImporter.Importer();
|
|
40
46
|
const skillViews = importer.import(source);
|
|
41
47
|
skillViews.forEach((sv) => {
|
|
@@ -46,7 +52,6 @@ class RemoteViewControllerFactory {
|
|
|
46
52
|
this.themesByNamespace[namespace] = Object.assign(Object.assign({}, theme), { namespace, name: namespace });
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
|
-
return this.vcFactory.Controller(name, options);
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
exports.default = RemoteViewControllerFactory;
|
|
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { ViewControllerImporter, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
|
-
import { eventResponseUtil } from '@sprucelabs/spruce-event-utils';
|
|
12
11
|
export default class RemoteViewControllerFactory {
|
|
13
12
|
constructor(options) {
|
|
14
13
|
this.themesByNamespace = {};
|
|
@@ -33,17 +32,28 @@ export default class RemoteViewControllerFactory {
|
|
|
33
32
|
getController(name) {
|
|
34
33
|
return this.vcFactory.getController(name);
|
|
35
34
|
}
|
|
35
|
+
fetchRemoteController(name) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
yield this.optionallLoadController(name);
|
|
38
|
+
return this.vcFactory.getController(name);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
36
41
|
RemoteController(name, options) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
yield this.optionallLoadController(name);
|
|
44
|
+
return this.vcFactory.Controller(name, options);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
optionallLoadController(name) {
|
|
37
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
49
|
const namespace = this.getNamespace(name);
|
|
39
50
|
if (!this.hasController(name) && namespace) {
|
|
40
51
|
const client = yield this.connectToApi();
|
|
41
|
-
const
|
|
52
|
+
const [{ source, theme }] = yield client.emitAndFlattenResponses('heartwood.get-skill-views::v2021_02_11', {
|
|
42
53
|
target: {
|
|
43
54
|
namespace,
|
|
44
55
|
},
|
|
45
56
|
});
|
|
46
|
-
const { source, theme } = eventResponseUtil.getFirstResponseOrThrow(results);
|
|
47
57
|
const importer = ViewControllerImporter.Importer();
|
|
48
58
|
const skillViews = importer.import(source);
|
|
49
59
|
skillViews.forEach((sv) => {
|
|
@@ -54,7 +64,6 @@ export default class RemoteViewControllerFactory {
|
|
|
54
64
|
this.themesByNamespace[namespace] = Object.assign(Object.assign({}, theme), { namespace, name: namespace });
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
|
-
return this.vcFactory.Controller(name, options);
|
|
58
67
|
});
|
|
59
68
|
}
|
|
60
69
|
}
|