@sprucelabs/spruce-heartwood-utils 16.10.1 → 16.10.2
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/build/__tests__/support/remoteVcAssert.d.ts +1 -1
- package/build/esm/__tests__/support/remoteVcAssert.d.ts +1 -1
- package/build/esm/skillViews/CardRegistrar.d.ts +5 -5
- package/build/esm/skillViews/CardRegistrar.js +3 -3
- package/build/esm/skillViews/RemoteViewControllerFactory.d.ts +4 -4
- package/build/esm/skillViews/RemoteViewControllerFactory.js +7 -6
- package/build/esm/theming/ThemeManager.d.ts +2 -2
- package/build/esm/types/heartwood-module.types.d.ts +1 -1
- package/build/skillViews/CardRegistrar.d.ts +5 -5
- package/build/skillViews/CardRegistrar.js +3 -3
- package/build/skillViews/RemoteViewControllerFactory.d.ts +4 -4
- package/build/skillViews/RemoteViewControllerFactory.js +6 -6
- package/build/theming/ThemeManager.d.ts +2 -2
- package/build/types/heartwood-module.types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -14,17 +14,17 @@ export default class CardRegistrar<Contract extends SkillEventContract = SkillEv
|
|
|
14
14
|
fetch(options?: CardFetchOptions<Contract, Name>): Promise<AbstractViewController<Card>[]>;
|
|
15
15
|
private ErrorCardVc;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
18
|
+
type ResponsePayload<Contract extends EventContract, Name extends EventName<Contract>> = Contract['eventSignatures'][Name]['responsePayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['responsePayloadSchema']> : never;
|
|
19
|
+
type EmitPayload<Contract extends EventContract, Name extends EventName<Contract>> = Contract['eventSignatures'][Name]['emitPayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['emitPayloadSchema']> : never;
|
|
20
20
|
export interface CardRegistrarOptions<Contract extends SkillEventContract, Name extends EventName<Contract>> {
|
|
21
21
|
client: MercuryClient;
|
|
22
22
|
eventName: Name;
|
|
23
23
|
vcFactory: VcFactoryForRemoteFactory;
|
|
24
24
|
vcIdsTransformer: (payload: ResponsePayload<Contract, Name>) => string[];
|
|
25
25
|
}
|
|
26
|
-
export
|
|
27
|
-
export
|
|
26
|
+
export type EachCardHandler = (vcs: AbstractViewController<any>[]) => Promise<void> | void;
|
|
27
|
+
export type CardFetchOptions<Contract extends EventContract, Name extends EventName<Contract>> = {
|
|
28
28
|
each?: EachCardHandler;
|
|
29
29
|
controllerOptionsHandler?: (vcId: string) => Record<string, any>;
|
|
30
30
|
} & EmitPayload<Contract, Name>;
|
|
@@ -10,6 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { assertOptions } from '@sprucelabs/schema';
|
|
11
11
|
import RemoteViewControllerFactoryImpl from './RemoteViewControllerFactory.js';
|
|
12
12
|
export default class CardRegistrar {
|
|
13
|
+
static Registrar(options) {
|
|
14
|
+
return new this(options);
|
|
15
|
+
}
|
|
13
16
|
/** @ts-ignore */
|
|
14
17
|
constructor(options) {
|
|
15
18
|
assertOptions(options, [
|
|
@@ -27,9 +30,6 @@ export default class CardRegistrar {
|
|
|
27
30
|
vcFactory: options.vcFactory,
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
|
-
static Registrar(options) {
|
|
31
|
-
return new this(options);
|
|
32
|
-
}
|
|
33
33
|
fetch(options) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
try {
|
|
@@ -22,14 +22,14 @@ export default class RemoteViewControllerFactoryImpl implements RemoteViewContro
|
|
|
22
22
|
private optionallyLoadController;
|
|
23
23
|
private fetchFromUrl;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export
|
|
25
|
+
type Theme = SkillTheme;
|
|
26
|
+
type ConnectToApi = () => Promise<MercuryClient>;
|
|
27
|
+
export type VcFactoryForRemoteFactory = Pick<ViewControllerFactory, 'setController' | 'hasController' | 'getController' | 'Controller' | 'importControllers'>;
|
|
28
28
|
export interface RemoteFactoryOptions {
|
|
29
29
|
connectToApi: ConnectToApi;
|
|
30
30
|
vcFactory: VcFactoryForRemoteFactory;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
type Factory = Pick<ViewControllerFactory, 'hasController' | 'Controller'>;
|
|
33
33
|
export interface RemoteViewControllerFactory extends Factory {
|
|
34
34
|
RemoteController: (name: string, options: Record<string, any>) => Promise<ViewController<Record<string, any>>>;
|
|
35
35
|
getTheme: (namespace?: string) => Theme | undefined;
|
|
@@ -9,12 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { ViewControllerImporter, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
11
|
import SpruceError from '../errors/SpruceError.js';
|
|
12
|
-
|
|
13
|
-
constructor(options) {
|
|
14
|
-
this.themesByNamespace = {};
|
|
15
|
-
this.connectToApi = options.connectToApi;
|
|
16
|
-
this.vcFactory = options.vcFactory;
|
|
17
|
-
}
|
|
12
|
+
class RemoteViewControllerFactoryImpl {
|
|
18
13
|
static Factory(options) {
|
|
19
14
|
var _a;
|
|
20
15
|
return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
|
|
@@ -22,6 +17,11 @@ export default class RemoteViewControllerFactoryImpl {
|
|
|
22
17
|
static reset() {
|
|
23
18
|
delete this.Class;
|
|
24
19
|
}
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.themesByNamespace = {};
|
|
22
|
+
this.connectToApi = options.connectToApi;
|
|
23
|
+
this.vcFactory = options.vcFactory;
|
|
24
|
+
}
|
|
25
25
|
hasController(name) {
|
|
26
26
|
return this.vcFactory.hasController(name);
|
|
27
27
|
}
|
|
@@ -99,3 +99,4 @@ export default class RemoteViewControllerFactoryImpl {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
RemoteViewControllerFactoryImpl.Request = typeof XMLHttpRequest === 'undefined' ? {} : XMLHttpRequest;
|
|
102
|
+
export default RemoteViewControllerFactoryImpl;
|
|
@@ -18,8 +18,8 @@ export declare class ThemeManagerImpl implements ThemeManager {
|
|
|
18
18
|
private setProp;
|
|
19
19
|
reset(): Promise<void>;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
export
|
|
21
|
+
type Theme = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Theme;
|
|
22
|
+
export type SkillTheme = Theme & {
|
|
23
23
|
name: string;
|
|
24
24
|
slug: string;
|
|
25
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SkillViewControllerLoadOptions, SpruceSchemas, ViewController } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
|
|
2
|
+
type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
3
3
|
export interface RemoteDashboardCard extends ViewController<Card> {
|
|
4
4
|
load?(options: SkillViewControllerLoadOptions): Promise<void>;
|
|
5
5
|
}
|
|
@@ -14,17 +14,17 @@ export default class CardRegistrar<Contract extends SkillEventContract = SkillEv
|
|
|
14
14
|
fetch(options?: CardFetchOptions<Contract, Name>): Promise<AbstractViewController<Card>[]>;
|
|
15
15
|
private ErrorCardVc;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
18
|
+
type ResponsePayload<Contract extends EventContract, Name extends EventName<Contract>> = Contract['eventSignatures'][Name]['responsePayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['responsePayloadSchema']> : never;
|
|
19
|
+
type EmitPayload<Contract extends EventContract, Name extends EventName<Contract>> = Contract['eventSignatures'][Name]['emitPayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['emitPayloadSchema']> : never;
|
|
20
20
|
export interface CardRegistrarOptions<Contract extends SkillEventContract, Name extends EventName<Contract>> {
|
|
21
21
|
client: MercuryClient;
|
|
22
22
|
eventName: Name;
|
|
23
23
|
vcFactory: VcFactoryForRemoteFactory;
|
|
24
24
|
vcIdsTransformer: (payload: ResponsePayload<Contract, Name>) => string[];
|
|
25
25
|
}
|
|
26
|
-
export
|
|
27
|
-
export
|
|
26
|
+
export type EachCardHandler = (vcs: AbstractViewController<any>[]) => Promise<void> | void;
|
|
27
|
+
export type CardFetchOptions<Contract extends EventContract, Name extends EventName<Contract>> = {
|
|
28
28
|
each?: EachCardHandler;
|
|
29
29
|
controllerOptionsHandler?: (vcId: string) => Record<string, any>;
|
|
30
30
|
} & EmitPayload<Contract, Name>;
|
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const schema_1 = require("@sprucelabs/schema");
|
|
7
7
|
const RemoteViewControllerFactory_1 = __importDefault(require("./RemoteViewControllerFactory"));
|
|
8
8
|
class CardRegistrar {
|
|
9
|
+
static Registrar(options) {
|
|
10
|
+
return new this(options);
|
|
11
|
+
}
|
|
9
12
|
/** @ts-ignore */
|
|
10
13
|
constructor(options) {
|
|
11
14
|
(0, schema_1.assertOptions)(options, [
|
|
@@ -23,9 +26,6 @@ class CardRegistrar {
|
|
|
23
26
|
vcFactory: options.vcFactory,
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
|
-
static Registrar(options) {
|
|
27
|
-
return new this(options);
|
|
28
|
-
}
|
|
29
29
|
async fetch(options) {
|
|
30
30
|
try {
|
|
31
31
|
//@ts-ignore
|
|
@@ -22,14 +22,14 @@ export default class RemoteViewControllerFactoryImpl implements RemoteViewContro
|
|
|
22
22
|
private optionallyLoadController;
|
|
23
23
|
private fetchFromUrl;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export
|
|
25
|
+
type Theme = SkillTheme;
|
|
26
|
+
type ConnectToApi = () => Promise<MercuryClient>;
|
|
27
|
+
export type VcFactoryForRemoteFactory = Pick<ViewControllerFactory, 'setController' | 'hasController' | 'getController' | 'Controller' | 'importControllers'>;
|
|
28
28
|
export interface RemoteFactoryOptions {
|
|
29
29
|
connectToApi: ConnectToApi;
|
|
30
30
|
vcFactory: VcFactoryForRemoteFactory;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
type Factory = Pick<ViewControllerFactory, 'hasController' | 'Controller'>;
|
|
33
33
|
export interface RemoteViewControllerFactory extends Factory {
|
|
34
34
|
RemoteController: (name: string, options: Record<string, any>) => Promise<ViewController<Record<string, any>>>;
|
|
35
35
|
getTheme: (namespace?: string) => Theme | undefined;
|
|
@@ -6,11 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
7
7
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
8
8
|
class RemoteViewControllerFactoryImpl {
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.themesByNamespace = {};
|
|
11
|
-
this.connectToApi = options.connectToApi;
|
|
12
|
-
this.vcFactory = options.vcFactory;
|
|
13
|
-
}
|
|
14
9
|
static Factory(options) {
|
|
15
10
|
var _a;
|
|
16
11
|
return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
|
|
@@ -18,6 +13,11 @@ class RemoteViewControllerFactoryImpl {
|
|
|
18
13
|
static reset() {
|
|
19
14
|
delete this.Class;
|
|
20
15
|
}
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.themesByNamespace = {};
|
|
18
|
+
this.connectToApi = options.connectToApi;
|
|
19
|
+
this.vcFactory = options.vcFactory;
|
|
20
|
+
}
|
|
21
21
|
hasController(name) {
|
|
22
22
|
return this.vcFactory.hasController(name);
|
|
23
23
|
}
|
|
@@ -86,6 +86,6 @@ class RemoteViewControllerFactoryImpl {
|
|
|
86
86
|
}));
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
exports.default = RemoteViewControllerFactoryImpl;
|
|
90
89
|
RemoteViewControllerFactoryImpl.Request = typeof XMLHttpRequest === 'undefined' ? {} : XMLHttpRequest;
|
|
90
|
+
exports.default = RemoteViewControllerFactoryImpl;
|
|
91
91
|
//# sourceMappingURL=RemoteViewControllerFactory.js.map
|
|
@@ -18,8 +18,8 @@ export declare class ThemeManagerImpl implements ThemeManager {
|
|
|
18
18
|
private setProp;
|
|
19
19
|
reset(): Promise<void>;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
export
|
|
21
|
+
type Theme = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Theme;
|
|
22
|
+
export type SkillTheme = Theme & {
|
|
23
23
|
name: string;
|
|
24
24
|
slug: string;
|
|
25
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SkillViewControllerLoadOptions, SpruceSchemas, ViewController } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
|
|
2
|
+
type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
3
3
|
export interface RemoteDashboardCard extends ViewController<Card> {
|
|
4
4
|
load?(options: SkillViewControllerLoadOptions): Promise<void>;
|
|
5
5
|
}
|