@vived/app 3.4.0 → 3.5.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.
@@ -3,11 +3,19 @@ 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
5
  const DispatchStopZSpaceUC_1 = require("../UC/DispatchStopZSpaceUC");
6
+ const GoToNextStateUC_1 = require("../UC/GoToNextStateUC");
7
+ const GoToPreviousStateUC_1 = require("../UC/GoToPreviousStateUC");
8
+ const HasNextStateUC_1 = require("../UC/HasNextStateUC");
9
+ const HasPreviousStateUC_1 = require("../UC/HasPreviousStateUC");
6
10
  exports.APP_DISPATCHER_ID = "AppDispatcher";
7
11
  function makeBasicDispatcher(appObjects, hostHandler) {
8
12
  const dispatcherAO = appObjects.getOrCreate(exports.APP_DISPATCHER_ID);
9
13
  AppDispatcher_1.makeAppDispatcher(dispatcherAO, hostHandler);
10
14
  DispatchStopZSpaceUC_1.makeDispatchStopZSpaceUC(dispatcherAO);
15
+ GoToPreviousStateUC_1.makeGoToPreviousStateUC(dispatcherAO);
16
+ GoToNextStateUC_1.makeGoToNextStateUC(dispatcherAO);
17
+ HasPreviousStateUC_1.makeHasPreviousStateUC(dispatcherAO);
18
+ HasNextStateUC_1.makeHasNextStateUC(dispatcherAO);
11
19
  return dispatcherAO;
12
20
  }
13
21
  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 GoToNextStateUC extends AppObjectUC {
5
+ static readonly type = "GoToNextStateUC";
6
+ readonly requestType = "GO_TO_NEXT_STATE";
7
+ abstract doDispatch(): void;
8
+ static get(appObjects: AppObjectRepo): GoToNextStateUC | undefined;
9
+ }
10
+ export declare function makeGoToNextStateUC(appObject: AppObject): GoToNextStateUC;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeGoToNextStateUC = exports.GoToNextStateUC = void 0;
4
+ const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const AppDispatcher_1 = require("../Entities/AppDispatcher");
6
+ class GoToNextStateUC extends AppObjectUC_1.AppObjectUC {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.requestType = "GO_TO_NEXT_STATE";
10
+ }
11
+ static get(appObjects) {
12
+ const selectionEntities = appObjects.getAllComponents(GoToNextStateUC.type);
13
+ if (selectionEntities.length === 0) {
14
+ console.warn("Unable to find a GoToNextStateUC. Add one on Mount");
15
+ return undefined;
16
+ }
17
+ else if (selectionEntities.length > 1) {
18
+ console.warn("Multiple GoToNextStateUC have been found. There should only be one. Using the first one");
19
+ }
20
+ return selectionEntities[0];
21
+ }
22
+ }
23
+ exports.GoToNextStateUC = GoToNextStateUC;
24
+ GoToNextStateUC.type = "GoToNextStateUC";
25
+ function makeGoToNextStateUC(appObject) {
26
+ return new DispatchStateChangeUCImp(appObject);
27
+ }
28
+ exports.makeGoToNextStateUC = makeGoToNextStateUC;
29
+ class DispatchStateChangeUCImp extends GoToNextStateUC {
30
+ constructor(appObject) {
31
+ super(appObject, GoToNextStateUC.type);
32
+ this.requestVersion = 1;
33
+ this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
34
+ if (!this.appDispatcher) {
35
+ console.warn("GoToNextStateUC 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 GoToPreviousStateUC extends AppObjectUC {
5
+ static readonly type = "GoToPreviousStateUC";
6
+ readonly requestType = "GO_TO_PREVIOUS_STATE";
7
+ abstract doDispatch(): void;
8
+ static get(appObjects: AppObjectRepo): GoToPreviousStateUC | undefined;
9
+ }
10
+ export declare function makeGoToPreviousStateUC(appObject: AppObject): GoToPreviousStateUC;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeGoToPreviousStateUC = exports.GoToPreviousStateUC = void 0;
4
+ const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const AppDispatcher_1 = require("../Entities/AppDispatcher");
6
+ class GoToPreviousStateUC extends AppObjectUC_1.AppObjectUC {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.requestType = "GO_TO_PREVIOUS_STATE";
10
+ }
11
+ static get(appObjects) {
12
+ const selectionEntities = appObjects.getAllComponents(GoToPreviousStateUC.type);
13
+ if (selectionEntities.length === 0) {
14
+ console.warn("Unable to find a GoToPreviousStateUC. Add one on Mount");
15
+ return undefined;
16
+ }
17
+ else if (selectionEntities.length > 1) {
18
+ console.warn("Multiple GoToPreviousStateUC have been found. There should only be one. Using the first one");
19
+ }
20
+ return selectionEntities[0];
21
+ }
22
+ }
23
+ exports.GoToPreviousStateUC = GoToPreviousStateUC;
24
+ GoToPreviousStateUC.type = "GoToPreviousStateUC";
25
+ function makeGoToPreviousStateUC(appObject) {
26
+ return new DispatchStateChangeUCImp(appObject);
27
+ }
28
+ exports.makeGoToPreviousStateUC = makeGoToPreviousStateUC;
29
+ class DispatchStateChangeUCImp extends GoToPreviousStateUC {
30
+ constructor(appObject) {
31
+ super(appObject, GoToPreviousStateUC.type);
32
+ this.requestVersion = 1;
33
+ this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
34
+ if (!this.appDispatcher) {
35
+ console.warn("GoToPreviousStateUC 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 HasNextStateUC extends AppObjectUC {
5
+ static readonly type = "HasNextStateUC";
6
+ readonly requestType = "HAS_NEXT_STATE";
7
+ abstract doDispatch(): Promise<boolean>;
8
+ static get(appObjects: AppObjectRepo): HasNextStateUC | undefined;
9
+ }
10
+ export declare function makeHasNextStateUC(appObject: AppObject): HasNextStateUC;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeHasNextStateUC = exports.HasNextStateUC = void 0;
4
+ const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const AppDispatcher_1 = require("../Entities/AppDispatcher");
6
+ class HasNextStateUC extends AppObjectUC_1.AppObjectUC {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.requestType = "HAS_NEXT_STATE";
10
+ }
11
+ static get(appObjects) {
12
+ const selectionEntities = appObjects.getAllComponents(HasNextStateUC.type);
13
+ if (selectionEntities.length === 0) {
14
+ console.warn("Unable to find a HasNextStateUC. Add one on Mount");
15
+ return undefined;
16
+ }
17
+ else if (selectionEntities.length > 1) {
18
+ console.warn("Multiple HasNextStateUC have been found. There should only be one. Using the first one");
19
+ }
20
+ return selectionEntities[0];
21
+ }
22
+ }
23
+ exports.HasNextStateUC = HasNextStateUC;
24
+ HasNextStateUC.type = "HasNextStateUC";
25
+ function makeHasNextStateUC(appObject) {
26
+ return new DispatchStateChangeUCImp(appObject);
27
+ }
28
+ exports.makeHasNextStateUC = makeHasNextStateUC;
29
+ class DispatchStateChangeUCImp extends HasNextStateUC {
30
+ constructor(appObject) {
31
+ super(appObject, HasNextStateUC.type);
32
+ this.requestVersion = 1;
33
+ this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
34
+ if (!this.appDispatcher) {
35
+ console.warn("HasNextStateUC 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 = (hasNextState) => {
42
+ resolve(hasNextState);
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
+ }
@@ -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 HasPreviousStateUC extends AppObjectUC {
5
+ static readonly type = "HasPreviousStateUC";
6
+ readonly requestType = "HAS_PREVIOUS_STATE";
7
+ abstract doDispatch(): Promise<boolean>;
8
+ static get(appObjects: AppObjectRepo): HasPreviousStateUC | undefined;
9
+ }
10
+ export declare function makeHasPreviousStateUC(appObject: AppObject): HasPreviousStateUC;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeHasPreviousStateUC = exports.HasPreviousStateUC = void 0;
4
+ const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const AppDispatcher_1 = require("../Entities/AppDispatcher");
6
+ class HasPreviousStateUC extends AppObjectUC_1.AppObjectUC {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.requestType = "HAS_PREVIOUS_STATE";
10
+ }
11
+ static get(appObjects) {
12
+ const selectionEntities = appObjects.getAllComponents(HasPreviousStateUC.type);
13
+ if (selectionEntities.length === 0) {
14
+ console.warn("Unable to find a HasPreviousStateUC. Add one on Mount");
15
+ return undefined;
16
+ }
17
+ else if (selectionEntities.length > 1) {
18
+ console.warn("Multiple HasPreviousStateUC have been found. There should only be one. Using the first one");
19
+ }
20
+ return selectionEntities[0];
21
+ }
22
+ }
23
+ exports.HasPreviousStateUC = HasPreviousStateUC;
24
+ HasPreviousStateUC.type = "HasPreviousStateUC";
25
+ function makeHasPreviousStateUC(appObject) {
26
+ return new DispatchStateChangeUCImp(appObject);
27
+ }
28
+ exports.makeHasPreviousStateUC = makeHasPreviousStateUC;
29
+ class DispatchStateChangeUCImp extends HasPreviousStateUC {
30
+ constructor(appObject) {
31
+ super(appObject, HasPreviousStateUC.type);
32
+ this.requestVersion = 1;
33
+ this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
34
+ if (!this.appDispatcher) {
35
+ console.warn("HasPreviousStateUC 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 = (hasNextState) => {
42
+ resolve(hasNextState);
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,3 +1,7 @@
1
1
  export * from "./Entities/AppDispatcher";
2
2
  export * from "./Factories/makeBasicDispatcher";
3
3
  export * from "./UC/DispatchStopZSpaceUC";
4
+ export * from "./UC/GoToNextStateUC";
5
+ export * from "./UC/GoToPreviousStateUC";
6
+ export * from "./UC/HasNextStateUC";
7
+ export * from "./UC/HasPreviousStateUC";
@@ -13,3 +13,7 @@ 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/GoToNextStateUC"), exports);
17
+ __exportStar(require("./UC/GoToPreviousStateUC"), exports);
18
+ __exportStar(require("./UC/HasNextStateUC"), exports);
19
+ __exportStar(require("./UC/HasPreviousStateUC"), exports);
@@ -25,7 +25,15 @@ class StickTransform3D extends AppObjectUC_1.AppObjectUC {
25
25
  get canBeStuck() {
26
26
  if (!this.transform)
27
27
  return false;
28
- return !ValueObjects_1.Vector3.Equal(this.transform.localPosition, ValueObjects_1.Vector3.Zero());
28
+ if (!ValueObjects_1.Vector3.Equal(this.transform.localPosition, ValueObjects_1.Vector3.Zero())) {
29
+ return true;
30
+ }
31
+ else if (!ValueObjects_1.Quaternion.Equal(this.transform.localRotation, ValueObjects_1.Quaternion.Identity())) {
32
+ return true;
33
+ }
34
+ else {
35
+ return false;
36
+ }
29
37
  }
30
38
  stick(onCompleteCallback) {
31
39
  var _a;
@@ -35,7 +43,7 @@ class StickTransform3D extends AppObjectUC_1.AppObjectUC {
35
43
  }
36
44
  return;
37
45
  }
38
- (_a = this.transform) === null || _a === void 0 ? void 0 : _a.lerp(this.stickDurationMS, this.easeFn, ValueObjects_1.Vector3.Zero(), undefined, undefined, onCompleteCallback);
46
+ (_a = this.transform) === null || _a === void 0 ? void 0 : _a.lerp(this.stickDurationMS, this.easeFn, ValueObjects_1.Vector3.Zero(), ValueObjects_1.Quaternion.Identity(), undefined, onCompleteCallback);
39
47
  }
40
48
  static get(appObj) {
41
49
  return appObj.getComponent(this.type);
@@ -36,10 +36,6 @@ export declare abstract class AppDispatcher {
36
36
  abstract dispatch: (request: Request) => void;
37
37
  abstract stateHasChanged: (state: object, assets: string[], validationErrorMessage?: string) => void;
38
38
  abstract stateIsCompleted: () => void;
39
- abstract goToPreviousState: () => void;
40
- abstract goToNextState: () => void;
41
- abstract hasPreviousState: () => Promise<boolean>;
42
- abstract hasNextState: () => Promise<boolean>;
43
39
  abstract getAppAssetsURL: () => Promise<string>;
44
40
  abstract registerExternalStylesheets: (stylesheets: string[]) => void;
45
41
  abstract appIsReady: () => void;
@@ -262,44 +262,6 @@ class AppDistpatcherImp extends AppDispatcher {
262
262
  }
263
263
  });
264
264
  };
265
- this.goToPreviousState = () => {
266
- this.formRequestAndDispatch("GO_TO_PREVIOUS_STATE", 1);
267
- };
268
- this.goToNextState = () => {
269
- this.formRequestAndDispatch("GO_TO_NEXT_STATE", 1);
270
- };
271
- this.hasNextState = () => {
272
- return new Promise((resolve, reject) => {
273
- const callback = (hasNextState) => {
274
- resolve(hasNextState);
275
- };
276
- const payload = {
277
- callback,
278
- };
279
- if (!this.hostHandler) {
280
- reject(new Error("No host handler has been registered"));
281
- }
282
- else {
283
- this.formRequestAndDispatch("HAS_NEXT_STATE", 1, payload);
284
- }
285
- });
286
- };
287
- this.hasPreviousState = () => {
288
- return new Promise((resolve, reject) => {
289
- const callback = (hasPreviousState) => {
290
- resolve(hasPreviousState);
291
- };
292
- const payload = {
293
- callback,
294
- };
295
- if (!this.hostHandler) {
296
- reject(new Error("No host handler has been registered"));
297
- }
298
- else {
299
- this.formRequestAndDispatch("HAS_PREVIOUS_STATE", 1, payload);
300
- }
301
- });
302
- };
303
265
  this.showAlert = (data) => {
304
266
  const payload = {
305
267
  title: data.title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "3.4.0",
3
+ "version": "3.5.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",