@sprucelabs/spruce-heartwood-utils 35.0.1 → 36.1.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.
@@ -1,4 +1,5 @@
1
1
  import { ViewControllerMap, ControllerOptions, ViewController, SkillViewController } from '@sprucelabs/heartwood-view-controllers';
2
+ import { SkillTheme } from '../../types/heartwood.types';
2
3
  import { RemoteFactoryOptions, RemoteViewControllerFactory } from '../../views/RemoteViewControllerFactory';
3
4
  export default class MockRemoteViewControllerFactory implements RemoteViewControllerFactory {
4
5
  private static instance?;
@@ -8,17 +9,19 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
8
9
  private views;
9
10
  private static controllers?;
10
11
  private static wasReset;
12
+ private themes;
11
13
  constructor(options: RemoteFactoryOptions);
12
14
  fetchRemoteController(_name: string): Promise<(new () => ViewController<any>) & {
13
15
  id: string;
14
16
  }>;
15
- Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(_name: N, _options: O): ViewControllerMap[N];
17
+ Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(name: N, options: O): ViewControllerMap[N];
16
18
  static dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
17
19
  private static dropInControllers;
18
20
  assertSkillViewRendersRemoteCard(vc: SkillViewController, name: string, id?: string): void;
19
21
  static reset(): void;
20
22
  static getInstance(): MockRemoteViewControllerFactory;
21
- getTheme(_namespace?: string | undefined): undefined;
23
+ getTheme(namespace?: string | undefined): SkillTheme | undefined;
24
+ setTheme(namespace: string, theme: SkillTheme): void;
22
25
  assertDidNotFetchRemoteController(id: string): void;
23
26
  assertFetchedRemoteController(name: string, options?: Record<string, any>): void;
24
27
  assertRemoteCardConstructorOptionsEqual(id: string, expected: Record<string, any>): void;
@@ -6,6 +6,7 @@ class MockRemoteViewControllerFactory {
6
6
  constructor(options) {
7
7
  this.loadedControllers = {};
8
8
  this.constructorOptionsById = {};
9
+ this.themes = {};
9
10
  MockRemoteViewControllerFactory.instance = this;
10
11
  this.views = options.vcFactory;
11
12
  MockRemoteViewControllerFactory.dropInControllers(this);
@@ -13,8 +14,8 @@ class MockRemoteViewControllerFactory {
13
14
  fetchRemoteController(_name) {
14
15
  throw new Error('Not implemented in mock. Maybe you meant to use this.remote.RemoteController(..)?');
15
16
  }
16
- Controller(_name, _options) {
17
- return {};
17
+ Controller(name, options) {
18
+ return this.views.Controller(name, options);
18
19
  }
19
20
  static dropInRemoteController(id, Class) {
20
21
  if (!this.controllers) {
@@ -72,8 +73,11 @@ class MockRemoteViewControllerFactory {
72
73
  }
73
74
  return this.instance;
74
75
  }
75
- getTheme(_namespace) {
76
- return undefined;
76
+ getTheme(namespace) {
77
+ return namespace ? this.themes[namespace] : undefined;
78
+ }
79
+ setTheme(namespace, theme) {
80
+ this.themes[namespace] = theme;
77
81
  }
78
82
  assertDidNotFetchRemoteController(id) {
79
83
  try {
@@ -1,4 +1,5 @@
1
1
  import { ViewControllerMap, ControllerOptions, ViewController, SkillViewController } from '@sprucelabs/heartwood-view-controllers';
2
+ import { SkillTheme } from '../../types/heartwood.types';
2
3
  import { RemoteFactoryOptions, RemoteViewControllerFactory } from '../../views/RemoteViewControllerFactory';
3
4
  export default class MockRemoteViewControllerFactory implements RemoteViewControllerFactory {
4
5
  private static instance?;
@@ -8,17 +9,19 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
8
9
  private views;
9
10
  private static controllers?;
10
11
  private static wasReset;
12
+ private themes;
11
13
  constructor(options: RemoteFactoryOptions);
12
14
  fetchRemoteController(_name: string): Promise<(new () => ViewController<any>) & {
13
15
  id: string;
14
16
  }>;
15
- Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(_name: N, _options: O): ViewControllerMap[N];
17
+ Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(name: N, options: O): ViewControllerMap[N];
16
18
  static dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
17
19
  private static dropInControllers;
18
20
  assertSkillViewRendersRemoteCard(vc: SkillViewController, name: string, id?: string): void;
19
21
  static reset(): void;
20
22
  static getInstance(): MockRemoteViewControllerFactory;
21
- getTheme(_namespace?: string | undefined): undefined;
23
+ getTheme(namespace?: string | undefined): SkillTheme | undefined;
24
+ setTheme(namespace: string, theme: SkillTheme): void;
22
25
  assertDidNotFetchRemoteController(id: string): void;
23
26
  assertFetchedRemoteController(name: string, options?: Record<string, any>): void;
24
27
  assertRemoteCardConstructorOptionsEqual(id: string, expected: Record<string, any>): void;
@@ -13,6 +13,7 @@ class MockRemoteViewControllerFactory {
13
13
  constructor(options) {
14
14
  this.loadedControllers = {};
15
15
  this.constructorOptionsById = {};
16
+ this.themes = {};
16
17
  MockRemoteViewControllerFactory.instance = this;
17
18
  this.views = options.vcFactory;
18
19
  MockRemoteViewControllerFactory.dropInControllers(this);
@@ -20,8 +21,8 @@ class MockRemoteViewControllerFactory {
20
21
  fetchRemoteController(_name) {
21
22
  throw new Error('Not implemented in mock. Maybe you meant to use this.remote.RemoteController(..)?');
22
23
  }
23
- Controller(_name, _options) {
24
- return {};
24
+ Controller(name, options) {
25
+ return this.views.Controller(name, options);
25
26
  }
26
27
  static dropInRemoteController(id, Class) {
27
28
  if (!this.controllers) {
@@ -80,8 +81,11 @@ class MockRemoteViewControllerFactory {
80
81
  }
81
82
  return this.instance;
82
83
  }
83
- getTheme(_namespace) {
84
- return undefined;
84
+ getTheme(namespace) {
85
+ return namespace ? this.themes[namespace] : undefined;
86
+ }
87
+ setTheme(namespace, theme) {
88
+ this.themes[namespace] = theme;
85
89
  }
86
90
  assertDidNotFetchRemoteController(id) {
87
91
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-heartwood-utils",
3
3
  "description": "Heartwood Utilities",
4
- "version": "35.0.1",
4
+ "version": "36.1.0",
5
5
  "skill": {
6
6
  "namespace": "heartwood"
7
7
  },