@vived/app 3.5.3 → 3.7.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.
@@ -2,20 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeBasicDispatcher = exports.APP_DISPATCHER_ID = void 0;
4
4
  const AppDispatcher_1 = require("../Entities/AppDispatcher");
5
+ const DispatchStartZSpaceUC_1 = require("../UC/DispatchStartZSpaceUC");
5
6
  const DispatchStopZSpaceUC_1 = require("../UC/DispatchStopZSpaceUC");
6
7
  const GoToNextStateUC_1 = require("../UC/GoToNextStateUC");
7
8
  const GoToPreviousStateUC_1 = require("../UC/GoToPreviousStateUC");
8
9
  const HasNextStateUC_1 = require("../UC/HasNextStateUC");
9
10
  const HasPreviousStateUC_1 = require("../UC/HasPreviousStateUC");
11
+ const IsZSpaceAvailableUC_1 = require("../UC/IsZSpaceAvailableUC");
10
12
  exports.APP_DISPATCHER_ID = "AppDispatcher";
11
13
  function makeBasicDispatcher(appObjects, hostHandler) {
12
14
  const dispatcherAO = appObjects.getOrCreate(exports.APP_DISPATCHER_ID);
13
15
  AppDispatcher_1.makeAppDispatcher(dispatcherAO, hostHandler);
14
16
  DispatchStopZSpaceUC_1.makeDispatchStopZSpaceUC(dispatcherAO);
17
+ DispatchStartZSpaceUC_1.makeDispatchStartZSpaceUC(dispatcherAO);
15
18
  GoToPreviousStateUC_1.makeGoToPreviousStateUC(dispatcherAO);
16
19
  GoToNextStateUC_1.makeGoToNextStateUC(dispatcherAO);
17
20
  HasPreviousStateUC_1.makeHasPreviousStateUC(dispatcherAO);
18
21
  HasNextStateUC_1.makeHasNextStateUC(dispatcherAO);
22
+ IsZSpaceAvailableUC_1.makeIsZSpaceAvailableUC(dispatcherAO);
19
23
  return dispatcherAO;
20
24
  }
21
25
  exports.makeBasicDispatcher = makeBasicDispatcher;
@@ -0,0 +1,10 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectRepo } from "../../../AppObject/AppObjectRepo";
3
+ import { AppObjectUC } from "../../../AppObject/AppObjectUC";
4
+ export declare abstract class DispatchStartZSpaceUC extends AppObjectUC {
5
+ static readonly type = "DispatchStartZSpaceUC";
6
+ readonly requestType = "START_ZSPACE";
7
+ abstract doDispatch(): void;
8
+ static get(appObjects: AppObjectRepo): DispatchStartZSpaceUC | undefined;
9
+ }
10
+ export declare function makeDispatchStartZSpaceUC(appObject: AppObject): DispatchStartZSpaceUC;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeDispatchStartZSpaceUC = exports.DispatchStartZSpaceUC = void 0;
4
+ const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const AppDispatcher_1 = require("../Entities/AppDispatcher");
6
+ class DispatchStartZSpaceUC extends AppObjectUC_1.AppObjectUC {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.requestType = "START_ZSPACE";
10
+ }
11
+ static get(appObjects) {
12
+ const selectionEntities = appObjects.getAllComponents(DispatchStartZSpaceUC.type);
13
+ if (selectionEntities.length === 0) {
14
+ console.warn("Unable to find a DispatchStartZSpaceUC. Add one on Mount");
15
+ return undefined;
16
+ }
17
+ else if (selectionEntities.length > 1) {
18
+ console.warn("Multiple DispatchStartZSpaceUC have been found. There should only be one. Using the first one");
19
+ }
20
+ return selectionEntities[0];
21
+ }
22
+ }
23
+ exports.DispatchStartZSpaceUC = DispatchStartZSpaceUC;
24
+ DispatchStartZSpaceUC.type = "DispatchStartZSpaceUC";
25
+ function makeDispatchStartZSpaceUC(appObject) {
26
+ return new DispatchStateChangeUCImp(appObject);
27
+ }
28
+ exports.makeDispatchStartZSpaceUC = makeDispatchStartZSpaceUC;
29
+ class DispatchStateChangeUCImp extends DispatchStartZSpaceUC {
30
+ constructor(appObject) {
31
+ super(appObject, DispatchStartZSpaceUC.type);
32
+ this.requestVersion = 1;
33
+ this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
34
+ if (!this.appDispatcher) {
35
+ console.warn("DispatchStartZSpaceUC has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
36
+ this.dispose();
37
+ }
38
+ }
39
+ doDispatch() {
40
+ if (!this.appDispatcher)
41
+ return;
42
+ this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion);
43
+ }
44
+ }
@@ -0,0 +1,10 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectRepo } from "../../../AppObject/AppObjectRepo";
3
+ import { AppObjectUC } from "../../../AppObject/AppObjectUC";
4
+ export declare abstract class IsZSpaceAvailableUC extends AppObjectUC {
5
+ static readonly type = "IsZSpaceAvailableUC";
6
+ readonly requestType = "IS_ZSPACE_AVAILABLE";
7
+ abstract doDispatch(): Promise<boolean>;
8
+ static get(appObjects: AppObjectRepo): IsZSpaceAvailableUC | undefined;
9
+ }
10
+ export declare function makeIsZSpaceAvailableUC(appObject: AppObject): IsZSpaceAvailableUC;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeIsZSpaceAvailableUC = exports.IsZSpaceAvailableUC = void 0;
4
+ const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const AppDispatcher_1 = require("../Entities/AppDispatcher");
6
+ class IsZSpaceAvailableUC extends AppObjectUC_1.AppObjectUC {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.requestType = "IS_ZSPACE_AVAILABLE";
10
+ }
11
+ static get(appObjects) {
12
+ const selectionEntities = appObjects.getAllComponents(IsZSpaceAvailableUC.type);
13
+ if (selectionEntities.length === 0) {
14
+ console.warn("Unable to find a IsZSpaceAvailableUC. Add one on Mount");
15
+ return undefined;
16
+ }
17
+ else if (selectionEntities.length > 1) {
18
+ console.warn("Multiple IsZSpaceAvailableUC have been found. There should only be one. Using the first one");
19
+ }
20
+ return selectionEntities[0];
21
+ }
22
+ }
23
+ exports.IsZSpaceAvailableUC = IsZSpaceAvailableUC;
24
+ IsZSpaceAvailableUC.type = "IsZSpaceAvailableUC";
25
+ function makeIsZSpaceAvailableUC(appObject) {
26
+ return new DispatchStateChangeUCImp(appObject);
27
+ }
28
+ exports.makeIsZSpaceAvailableUC = makeIsZSpaceAvailableUC;
29
+ class DispatchStateChangeUCImp extends IsZSpaceAvailableUC {
30
+ constructor(appObject) {
31
+ super(appObject, IsZSpaceAvailableUC.type);
32
+ this.requestVersion = 1;
33
+ this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
34
+ if (!this.appDispatcher) {
35
+ console.warn("IsZSpaceAvailableUC has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
36
+ this.dispose();
37
+ }
38
+ }
39
+ doDispatch() {
40
+ return new Promise((resolve, reject) => {
41
+ const callback = (IsZSpaceAvailable) => {
42
+ resolve(IsZSpaceAvailable);
43
+ };
44
+ const payload = {
45
+ callback,
46
+ };
47
+ if (!this.appDispatcher)
48
+ return reject(new Error("No host handler has been registered"));
49
+ else {
50
+ this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion, payload);
51
+ }
52
+ });
53
+ }
54
+ }
@@ -1,7 +1,9 @@
1
1
  export * from "./Entities/AppDispatcher";
2
2
  export * from "./Factories/makeBasicDispatcher";
3
3
  export * from "./UC/DispatchStopZSpaceUC";
4
+ export * from "./UC/DispatchStartZSpaceUC";
4
5
  export * from "./UC/GoToNextStateUC";
5
6
  export * from "./UC/GoToPreviousStateUC";
6
7
  export * from "./UC/HasNextStateUC";
7
8
  export * from "./UC/HasPreviousStateUC";
9
+ export * from "./UC/IsZSpaceAvailableUC";
@@ -13,7 +13,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./Entities/AppDispatcher"), exports);
14
14
  __exportStar(require("./Factories/makeBasicDispatcher"), exports);
15
15
  __exportStar(require("./UC/DispatchStopZSpaceUC"), exports);
16
+ __exportStar(require("./UC/DispatchStartZSpaceUC"), exports);
16
17
  __exportStar(require("./UC/GoToNextStateUC"), exports);
17
18
  __exportStar(require("./UC/GoToPreviousStateUC"), exports);
18
19
  __exportStar(require("./UC/HasNextStateUC"), exports);
19
20
  __exportStar(require("./UC/HasPreviousStateUC"), exports);
21
+ __exportStar(require("./UC/IsZSpaceAvailableUC"), exports);
@@ -1,10 +1,10 @@
1
1
  import { AppHandler, RequestHandler } from "../../Entities";
2
- export declare type StartZSpaceAction = (device: string, session: any, emulate: boolean) => void;
2
+ export declare type StartZSpaceAction = (deviceScaleFactor: number, session: any, emulate: boolean) => void;
3
3
  export declare class StartZSpaceBase extends RequestHandler {
4
4
  readonly requestType = "START_ZSPACE";
5
- readonly payloadVersion = 2;
5
+ readonly payloadVersion = 3;
6
6
  action: StartZSpaceAction;
7
7
  handleRequest: (version: number, payload: unknown) => void;
8
- private castPayloadV2;
8
+ private castPayloadV3;
9
9
  constructor(handler: AppHandler);
10
10
  }
@@ -6,14 +6,14 @@ class StartZSpaceBase extends Entities_1.RequestHandler {
6
6
  constructor(handler) {
7
7
  super();
8
8
  this.requestType = "START_ZSPACE";
9
- this.payloadVersion = 2;
9
+ this.payloadVersion = 3;
10
10
  this.action = () => {
11
11
  throw new Entities_1.ActionNotImplemented(this.requestType);
12
12
  };
13
13
  this.handleRequest = (version, payload) => {
14
14
  if (version === this.payloadVersion) {
15
- const { device, session, emulate } = this.castPayloadV2(payload);
16
- this.action(device, session, emulate);
15
+ const { deviceScaleFactor, session, emulate } = this.castPayloadV3(payload);
16
+ this.action(deviceScaleFactor, session, emulate);
17
17
  }
18
18
  else {
19
19
  throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
@@ -21,9 +21,10 @@ class StartZSpaceBase extends Entities_1.RequestHandler {
21
21
  };
22
22
  handler.registerRequestHandler(this);
23
23
  }
24
- castPayloadV2(payload) {
24
+ castPayloadV3(payload) {
25
25
  const castPayload = payload;
26
- if (castPayload.device === undefined || castPayload.session === undefined) {
26
+ if (castPayload.deviceScaleFactor === undefined ||
27
+ castPayload.session === undefined) {
27
28
  throw new Entities_1.UnableToParsePayload(this.requestType, 1, JSON.stringify(payload));
28
29
  }
29
30
  if (castPayload.emulate === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "3.5.3",
3
+ "version": "3.7.0",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",