@vived/host 3.9.3 → 3.10.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.
@@ -35,7 +35,7 @@ class StartAppUCImp extends StartAppUC {
35
35
  constructor(appObject) {
36
36
  super(appObject, StartAppUC.type);
37
37
  this.start = (container) => {
38
- var _a, _b, _c;
38
+ var _a, _b, _c, _d;
39
39
  if (!this.stateMachine)
40
40
  return;
41
41
  if (!this.dispatchStart)
@@ -43,20 +43,26 @@ class StartAppUCImp extends StartAppUC {
43
43
  if (!this.editStateEntity)
44
44
  return;
45
45
  this.dispatchStart.doDispatch(container);
46
- let stateString = "";
47
- if (this.stateMachine.activeState && this.stateMachine.activeState) {
48
- const state = this.stateMachine.getStateByID(this.stateMachine.activeState);
49
- if (state) {
50
- stateString = JSON.stringify(state.stateData);
51
- }
46
+ let state;
47
+ if (this.stateMachine.activeState) {
48
+ state = (_a = this.stateMachine.getStateByID(this.stateMachine.activeState)) === null || _a === void 0 ? void 0 : _a.stateData;
52
49
  }
53
- (_a = this.dispatchSetState) === null || _a === void 0 ? void 0 : _a.doDispatch(stateString);
50
+ const hideNavigation = this.stateMachine.states.length <= 1;
51
+ const hasNextSlide = this.stateMachine.nextState !== undefined;
52
+ const hasPreviousSlide = this.stateMachine.previousState !== undefined;
53
+ const dto = {
54
+ finalState: state,
55
+ hideNavigation,
56
+ hasNextSlide,
57
+ hasPreviousSlide
58
+ };
59
+ (_b = this.dispatchSetState) === null || _b === void 0 ? void 0 : _b.doDispatch(dto);
54
60
  let isAuthoring = this.editStateEntity.isEditing;
55
61
  if (this.stateMachine.activeState === undefined) {
56
62
  isAuthoring = true;
57
63
  }
58
- (_b = this.dispatchSetIsAuthoring) === null || _b === void 0 ? void 0 : _b.doDispatch(isAuthoring);
59
- (_c = this.dispatchThemeColors) === null || _c === void 0 ? void 0 : _c.doDispatch();
64
+ (_c = this.dispatchSetIsAuthoring) === null || _c === void 0 ? void 0 : _c.doDispatch(isAuthoring);
65
+ (_d = this.dispatchThemeColors) === null || _d === void 0 ? void 0 : _d.doDispatch();
60
66
  };
61
67
  }
62
68
  get stateMachine() {
@@ -1,9 +1,27 @@
1
1
  import { HostAppObject, HostAppObjectRepo, HostAppObjectUC } from "../../../HostAppObject";
2
+ export interface DispatchStateDTO {
3
+ finalState?: object;
4
+ hideNavigation: boolean;
5
+ hasNextSlide: boolean;
6
+ hasPreviousSlide: boolean;
7
+ duration?: number;
8
+ }
2
9
  export declare abstract class DispatchSetStateUC extends HostAppObjectUC {
3
10
  static readonly type = "DispatchSetStateUC";
4
11
  readonly requestType = "SET_APP_STATE";
5
- abstract doDispatch(finalState: string, duration?: number | undefined): void;
12
+ abstract doDispatch(dto: DispatchStateDTO): void;
6
13
  static get(appObject: HostAppObject): DispatchSetStateUC | undefined;
7
14
  static getByID(id: string, appObjects: HostAppObjectRepo): DispatchSetStateUC | undefined;
8
15
  }
9
16
  export declare function makeDispatchSetStateUC(appObject: HostAppObject): DispatchSetStateUC;
17
+ export interface SetStatePayloadV2 {
18
+ finalState: string;
19
+ duration?: number;
20
+ }
21
+ export interface SetStatePayloadV3 {
22
+ hideNavigation: boolean;
23
+ hasNextSlide: boolean;
24
+ hasPreviousSlide: boolean;
25
+ duration?: number;
26
+ finalState?: object;
27
+ }
@@ -31,22 +31,37 @@ function makeDispatchSetStateUC(appObject) {
31
31
  }
32
32
  exports.makeDispatchSetStateUC = makeDispatchSetStateUC;
33
33
  class DispatchSetStateUCImp extends DispatchSetStateUC {
34
- constructor(appObject) {
35
- super(appObject, DispatchSetStateUC.type);
36
- this.requestVersion = 2;
37
- this.dispatcher = appObject.getComponent(Entities_1.HostDispatchEntity.type);
38
- if (!this.dispatcher) {
39
- this.error("UC has been added to an App Object that does not have a HostDispatchEntity. Add a dispatcher first");
40
- this.dispose();
41
- }
34
+ get dispatcher() {
35
+ return this.getCachedLocalComponent(Entities_1.HostDispatchEntity.type);
42
36
  }
43
- doDispatch(finalState, duration) {
37
+ doDispatch(dto) {
44
38
  if (!this.dispatcher)
45
39
  return;
40
+ const { finalState, duration, hasNextSlide, hasPreviousSlide, hideNavigation } = dto;
41
+ const requestedPayload = this.dispatcher.getRequestPayloadVersion(this.requestType);
42
+ if (!requestedPayload || requestedPayload <= 2) {
43
+ this.dispatchV2(finalState, duration);
44
+ return;
45
+ }
46
+ const payload = {
47
+ finalState,
48
+ duration,
49
+ hasNextSlide,
50
+ hasPreviousSlide,
51
+ hideNavigation
52
+ };
53
+ this.dispatcher.formRequestAndDispatch(this.requestType, 3, payload);
54
+ }
55
+ dispatchV2(state, duration) {
56
+ var _a;
57
+ const finalState = state ? JSON.stringify(state) : "";
46
58
  const payload = {
47
59
  finalState,
48
60
  duration
49
61
  };
50
- this.dispatcher.formRequestAndDispatch(this.requestType, this.requestVersion, payload);
62
+ (_a = this.dispatcher) === null || _a === void 0 ? void 0 : _a.formRequestAndDispatch(this.requestType, 2, payload);
63
+ }
64
+ constructor(appObject) {
65
+ super(appObject, DispatchSetStateUC.type);
51
66
  }
52
67
  }
@@ -30,8 +30,16 @@ class CancelSandboxEditingUC extends CancelEditingUC_1.CancelEditingUC {
30
30
  if (this.stateMachine.activeState) {
31
31
  const state = this.stateMachine.getStateByID(this.stateMachine.activeState);
32
32
  if (state) {
33
- const stateData = JSON.stringify(state.stateData);
34
- dispatchSetState.doDispatch(stateData);
33
+ const hideNavigation = this.stateMachine.states.length <= 1;
34
+ const hasNextSlide = this.stateMachine.nextState !== undefined;
35
+ const hasPreviousSlide = this.stateMachine.previousState !== undefined;
36
+ const dto = {
37
+ finalState: state.stateData,
38
+ hideNavigation,
39
+ hasNextSlide,
40
+ hasPreviousSlide
41
+ };
42
+ dispatchSetState.doDispatch(dto);
35
43
  }
36
44
  }
37
45
  else {
@@ -34,8 +34,16 @@ class EditActiveSandboxStateUCImp extends EditActiveStateUC_1.EditActiveStateUC
34
34
  this.warn("Unable to find state");
35
35
  return;
36
36
  }
37
- const stateStr = JSON.stringify(state.stateData);
38
- dispatchSetState.doDispatch(stateStr);
37
+ const hideNavigation = this.stateMachine.states.length <= 1;
38
+ const hasNextSlide = this.stateMachine.nextState !== undefined;
39
+ const hasPreviousSlide = this.stateMachine.previousState !== undefined;
40
+ const dto = {
41
+ finalState: state.stateData,
42
+ hideNavigation,
43
+ hasNextSlide,
44
+ hasPreviousSlide
45
+ };
46
+ dispatchSetState.doDispatch(dto);
39
47
  dispatchSetIsAuthoring.doDispatch(true);
40
48
  this.editStateEntity.startEditing(state);
41
49
  };
@@ -31,9 +31,18 @@ class TransitionToSandboxStateUCImp extends TransitionToStateUC_1.TransitionToSt
31
31
  return;
32
32
  }
33
33
  stateMachine.setActiveStateByID(id);
34
- const stateStr = JSON.stringify(state.stateData);
35
34
  const duration = stateMachine.transitionDuration;
36
- dispatchSetState.doDispatch(stateStr, duration);
35
+ const hideNavigation = stateMachine.states.length <= 1;
36
+ const hasNextSlide = stateMachine.nextState !== undefined;
37
+ const hasPreviousSlide = stateMachine.previousState !== undefined;
38
+ const dto = {
39
+ finalState: state.stateData,
40
+ duration,
41
+ hideNavigation,
42
+ hasNextSlide,
43
+ hasPreviousSlide
44
+ };
45
+ dispatchSetState.doDispatch(dto);
37
46
  }
38
47
  constructor(appObject) {
39
48
  super(appObject, TransitionToStateUC_1.TransitionToStateUC.type);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/host",
3
- "version": "3.9.3",
3
+ "version": "3.10.1",
4
4
  "description": "Public Host package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",