@vived/app 4.20.0 → 4.22.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.
Files changed (80) hide show
  1. package/lib/Components/ChannelModel/Adapters/activeModelAdapter.d.ts +2 -0
  2. package/lib/Components/ChannelModel/Adapters/activeModelAdapter.js +23 -0
  3. package/lib/Components/ChannelModel/Adapters/index.d.ts +1 -0
  4. package/lib/Components/ChannelModel/Adapters/index.js +1 -0
  5. package/lib/Components/ChannelModel/Controllers/clickSelectChannelModel.d.ts +2 -0
  6. package/lib/Components/ChannelModel/Controllers/clickSelectChannelModel.js +13 -0
  7. package/lib/Components/ChannelModel/Controllers/index.d.ts +1 -0
  8. package/lib/Components/ChannelModel/Controllers/index.js +1 -0
  9. package/lib/Components/ChannelModel/Entities/ChannelModelRepo.d.ts +2 -2
  10. package/lib/Components/ChannelModel/Entities/ChannelModelRepo.js +3 -3
  11. package/lib/Components/ChannelModel/Mocks/ActiveModelMock.d.ts +8 -0
  12. package/lib/Components/ChannelModel/Mocks/ActiveModelMock.js +15 -0
  13. package/lib/Components/ChannelModel/Mocks/LoadChannelModelMock.d.ts +9 -0
  14. package/lib/Components/ChannelModel/Mocks/LoadChannelModelMock.js +16 -0
  15. package/lib/Components/ChannelModel/Mocks/SelectChannelModelUCMock.d.ts +8 -0
  16. package/lib/Components/ChannelModel/Mocks/SelectChannelModelUCMock.js +15 -0
  17. package/lib/Components/ChannelModel/Mocks/index.d.ts +3 -0
  18. package/lib/Components/ChannelModel/Mocks/index.js +3 -0
  19. package/lib/Components/ChannelModel/PMs/ActiveModelPM.d.ts +13 -0
  20. package/lib/Components/ChannelModel/PMs/ActiveModelPM.js +36 -0
  21. package/lib/Components/ChannelModel/PMs/index.d.ts +1 -0
  22. package/lib/Components/ChannelModel/PMs/index.js +1 -0
  23. package/lib/Components/ChannelModel/UC/LoadChannelModelUC.d.ts +10 -0
  24. package/lib/Components/ChannelModel/UC/LoadChannelModelUC.js +132 -0
  25. package/lib/Components/ChannelModel/UC/SelectChannelModelUC.js +34 -34
  26. package/lib/Components/ChannelModel/UC/SerializeActiveModel.d.ts +26 -0
  27. package/lib/Components/ChannelModel/UC/SerializeActiveModel.js +80 -0
  28. package/lib/Components/ChannelModel/UC/index.d.ts +3 -0
  29. package/lib/Components/ChannelModel/UC/index.js +3 -0
  30. package/lib/Components/Dispatcher/Mocks/GetAssetBlobURLUCMock.d.ts +8 -0
  31. package/lib/Components/Dispatcher/Mocks/GetAssetBlobURLUCMock.js +15 -0
  32. package/lib/Components/Dispatcher/Mocks/GetLinkedAssetsUCMock.d.ts +8 -0
  33. package/lib/Components/Dispatcher/Mocks/GetLinkedAssetsUCMock.js +15 -0
  34. package/lib/Components/Dispatcher/Mocks/MockGetAssetFolderURL.d.ts +1 -1
  35. package/lib/Components/Dispatcher/Mocks/MockGetAssetFolderURL.js +3 -3
  36. package/lib/Components/Dispatcher/Mocks/MockShowAlert.d.ts +1 -1
  37. package/lib/Components/Dispatcher/Mocks/MockShowAlert.js +3 -3
  38. package/lib/Components/Dispatcher/Mocks/MockShowConfirm.d.ts +1 -1
  39. package/lib/Components/Dispatcher/Mocks/MockShowConfirm.js +3 -3
  40. package/lib/Components/Dispatcher/Mocks/MockShowMarkdown.d.ts +1 -1
  41. package/lib/Components/Dispatcher/Mocks/MockShowMarkdown.js +3 -3
  42. package/lib/Components/Dispatcher/Mocks/MockShowSpinner.d.ts +8 -0
  43. package/lib/Components/Dispatcher/Mocks/MockShowSpinner.js +15 -0
  44. package/lib/Components/Dispatcher/Mocks/MockSubmitResult.d.ts +1 -1
  45. package/lib/Components/Dispatcher/Mocks/MockSubmitResult.js +3 -3
  46. package/lib/Components/Dispatcher/Mocks/ShowSelectModelUCMock.d.ts +8 -0
  47. package/lib/Components/Dispatcher/Mocks/ShowSelectModelUCMock.js +15 -0
  48. package/lib/Components/Dispatcher/Mocks/index.d.ts +6 -1
  49. package/lib/Components/Dispatcher/Mocks/index.js +6 -1
  50. package/lib/Components/Dispatcher/UC/AppIsReadyUC.js +5 -5
  51. package/lib/Components/Dispatcher/UC/DispatchStartZSpaceUC.js +5 -5
  52. package/lib/Components/Dispatcher/UC/DispatchStateChangeUC.js +4 -4
  53. package/lib/Components/Dispatcher/UC/DispatchStopZSpaceUC.js +5 -5
  54. package/lib/Components/Dispatcher/UC/GetAssetBlobURLUC.js +21 -21
  55. package/lib/Components/Dispatcher/UC/GetAssetFolderURLUC.js +20 -20
  56. package/lib/Components/Dispatcher/UC/GetAssetMetaUC.js +21 -21
  57. package/lib/Components/Dispatcher/UC/GetAssetsForOwnerUC.js +21 -21
  58. package/lib/Components/Dispatcher/UC/GetLinkedAssetsUC.js +22 -22
  59. package/lib/Components/Dispatcher/UC/GoToNextStateUC.js +5 -5
  60. package/lib/Components/Dispatcher/UC/GoToPreviousStateUC.js +5 -5
  61. package/lib/Components/Dispatcher/UC/HasNextStateUC.js +15 -15
  62. package/lib/Components/Dispatcher/UC/HasPreviousStateUC.js +15 -15
  63. package/lib/Components/Dispatcher/UC/IsAssetFetchedUC.js +16 -16
  64. package/lib/Components/Dispatcher/UC/IsZSpaceAvailableUC.js +15 -15
  65. package/lib/Components/Dispatcher/UC/LogUC.js +12 -12
  66. package/lib/Components/Dispatcher/UC/RegisterExternalStylesheetsUC.js +7 -7
  67. package/lib/Components/Dispatcher/UC/RestoreCurrentStateUC.js +5 -5
  68. package/lib/Components/Dispatcher/UC/ShowAlertUC.js +11 -11
  69. package/lib/Components/Dispatcher/UC/ShowConfirmUC.js +13 -13
  70. package/lib/Components/Dispatcher/UC/ShowMarkdownEditorUC.js +13 -13
  71. package/lib/Components/Dispatcher/UC/ShowSelectModelUC.js +15 -15
  72. package/lib/Components/Dispatcher/UC/StateIsCompleteUC.js +5 -5
  73. package/lib/Components/Dispatcher/UC/SubmitActivityAssetUC.js +21 -21
  74. package/lib/Components/Dispatcher/UC/SubmitResultResultUC.js +69 -69
  75. package/lib/Components/Dispatcher/index.d.ts +1 -0
  76. package/lib/Components/Dispatcher/index.js +1 -0
  77. package/lib/Components/GLBModel/Mocks/LoadGlbFileUCMock.d.ts +1 -0
  78. package/lib/Components/GLBModel/Mocks/LoadGlbFileUCMock.js +1 -0
  79. package/lib/Components/GLBModel/UCs/LoadGlbFileUC.d.ts +1 -0
  80. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import { SingletonPmAdapter } from "../../../Types";
2
+ export declare const activeModelAdapter: SingletonPmAdapter<string>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.activeModelAdapter = void 0;
4
+ const ActiveModelPM_1 = require("../PMs/ActiveModelPM");
5
+ exports.activeModelAdapter = {
6
+ defaultVM: "",
7
+ subscribe: (appObjects, setVM) => {
8
+ const pm = ActiveModelPM_1.ActiveModelPM.get(appObjects);
9
+ if (!pm) {
10
+ appObjects.submitError("animationFrameAdapter", "Unable to find ActiveModelPM");
11
+ return;
12
+ }
13
+ pm.addView(setVM);
14
+ },
15
+ unsubscribe: (appObjects, setVM) => {
16
+ const pm = ActiveModelPM_1.ActiveModelPM.get(appObjects);
17
+ if (!pm) {
18
+ appObjects.submitError("animationFrameAdapter", "Unable to find ActiveModelPM");
19
+ return;
20
+ }
21
+ pm.removeView(setVM);
22
+ },
23
+ };
@@ -1,2 +1,3 @@
1
+ export * from "./activeModelAdapter";
1
2
  export * from "./channelModelAdapter";
2
3
  export * from "./channelModelObjectAdapter";
@@ -10,5 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./activeModelAdapter"), exports);
13
14
  __exportStar(require("./channelModelAdapter"), exports);
14
15
  __exportStar(require("./channelModelObjectAdapter"), exports);
@@ -0,0 +1,2 @@
1
+ import { AppObjectRepo } from "../../../AppObject";
2
+ export declare function clickSelectChannelModel(appObjects: AppObjectRepo): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clickSelectChannelModel = void 0;
4
+ const SelectChannelModelUC_1 = require("../UC/SelectChannelModelUC");
5
+ function clickSelectChannelModel(appObjects) {
6
+ const selectChannelModelUC = SelectChannelModelUC_1.SelectChannelModelUC.get(appObjects);
7
+ if (!selectChannelModelUC) {
8
+ appObjects.submitError("clickSelectChannelModel", "Unable to find SelectChannelModelUC");
9
+ return;
10
+ }
11
+ selectChannelModelUC.selectChannelModel();
12
+ }
13
+ exports.clickSelectChannelModel = clickSelectChannelModel;
@@ -1 +1,2 @@
1
+ export * from "./clickSelectChannelModel";
1
2
  export * from "./setModelObjectLabel";
@@ -10,4 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./clickSelectChannelModel"), exports);
13
14
  __exportStar(require("./setModelObjectLabel"), exports);
@@ -2,8 +2,8 @@ import { AppObject, AppObjectEntityRepo, AppObjectRepo } from "../../../AppObjec
2
2
  import { ChannelModelEntity } from "./ChannelModel";
3
3
  export declare abstract class ChannelModelRepo extends AppObjectEntityRepo<ChannelModelEntity> {
4
4
  static readonly type = "CHANNEL_MODEL_REPO";
5
- abstract get isLoadingChannelModel(): boolean;
6
- abstract set isLoadingChannelModel(val: boolean);
5
+ abstract get activeModel(): string;
6
+ abstract set activeModel(val: string);
7
7
  abstract getChannelModel(id: string, createIfMissing: boolean): ChannelModelEntity | undefined;
8
8
  abstract channelModelFactory(id: string): ChannelModelEntity;
9
9
  abstract createChannelModel(id?: string): ChannelModelEntity;
@@ -17,7 +17,7 @@ exports.makeChannelModelRepo = makeChannelModelRepo;
17
17
  class ChannelModelRepoImp extends ChannelModelRepo {
18
18
  constructor(appObject) {
19
19
  super(appObject, ChannelModelRepo.type);
20
- this.memoizedIsLoading = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
20
+ this.memoizedIsLoading = new Entities_1.MemoizedString("", this.notifyOnChange);
21
21
  this.getChannelModel = (id, createIfMissing) => {
22
22
  let rVal = this.getForAppObject(id);
23
23
  if (rVal === undefined && createIfMissing) {
@@ -37,10 +37,10 @@ class ChannelModelRepoImp extends ChannelModelRepo {
37
37
  return ChannelModel_1.makeChannelModelEntity(ao);
38
38
  };
39
39
  }
40
- get isLoadingChannelModel() {
40
+ get activeModel() {
41
41
  return this.memoizedIsLoading.val;
42
42
  }
43
- set isLoadingChannelModel(val) {
43
+ set activeModel(val) {
44
44
  this.memoizedIsLoading.val = val;
45
45
  }
46
46
  }
@@ -0,0 +1,8 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject, AppObjectRepo } from "../../../AppObject";
3
+ import { ActiveModelPM } from "../PMs";
4
+ export declare class ActiveModelMock extends ActiveModelPM {
5
+ vmsAreEqual: jest.Mock<any, any>;
6
+ constructor(appObject: AppObject);
7
+ }
8
+ export declare function makeActiveModelMock(appObjects: AppObjectRepo): ActiveModelMock;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeActiveModelMock = exports.ActiveModelMock = void 0;
4
+ const PMs_1 = require("../PMs");
5
+ class ActiveModelMock extends PMs_1.ActiveModelPM {
6
+ constructor(appObject) {
7
+ super(appObject, PMs_1.ActiveModelPM.type);
8
+ this.vmsAreEqual = jest.fn();
9
+ }
10
+ }
11
+ exports.ActiveModelMock = ActiveModelMock;
12
+ function makeActiveModelMock(appObjects) {
13
+ return new ActiveModelMock(appObjects.getOrCreate("ActiveModelMock"));
14
+ }
15
+ exports.makeActiveModelMock = makeActiveModelMock;
@@ -0,0 +1,9 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject, AppObjectRepo } from "../../../AppObject";
3
+ import { LoadChannelModelUC } from "../UC";
4
+ export declare class LoadChannelModelUCMock extends LoadChannelModelUC {
5
+ loadChannelModel: jest.Mock<any, any>;
6
+ blobToJSON: jest.Mock<any, any>;
7
+ constructor(appObject: AppObject);
8
+ }
9
+ export declare function makeLoadChannelModelUCMock(appObjects: AppObjectRepo): LoadChannelModelUCMock;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeLoadChannelModelUCMock = exports.LoadChannelModelUCMock = void 0;
4
+ const UC_1 = require("../UC");
5
+ class LoadChannelModelUCMock extends UC_1.LoadChannelModelUC {
6
+ constructor(appObject) {
7
+ super(appObject, UC_1.LoadChannelModelUC.type);
8
+ this.loadChannelModel = jest.fn();
9
+ this.blobToJSON = jest.fn();
10
+ }
11
+ }
12
+ exports.LoadChannelModelUCMock = LoadChannelModelUCMock;
13
+ function makeLoadChannelModelUCMock(appObjects) {
14
+ return new LoadChannelModelUCMock(appObjects.getOrCreate("LoadChannelModelUCMock"));
15
+ }
16
+ exports.makeLoadChannelModelUCMock = makeLoadChannelModelUCMock;
@@ -0,0 +1,8 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject, AppObjectRepo } from "../../../AppObject";
3
+ import { SelectChannelModelUC } from "../UC/SelectChannelModelUC";
4
+ export declare class SelectChannelModelUCMock extends SelectChannelModelUC {
5
+ selectChannelModel: jest.Mock<any, any>;
6
+ constructor(appObject: AppObject);
7
+ }
8
+ export declare function makeSelectChannelModelUCMock(appObjects: AppObjectRepo): SelectChannelModelUCMock;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeSelectChannelModelUCMock = exports.SelectChannelModelUCMock = void 0;
4
+ const SelectChannelModelUC_1 = require("../UC/SelectChannelModelUC");
5
+ class SelectChannelModelUCMock extends SelectChannelModelUC_1.SelectChannelModelUC {
6
+ constructor(appObject) {
7
+ super(appObject, SelectChannelModelUC_1.SelectChannelModelUC.type);
8
+ this.selectChannelModel = jest.fn();
9
+ }
10
+ }
11
+ exports.SelectChannelModelUCMock = SelectChannelModelUCMock;
12
+ function makeSelectChannelModelUCMock(appObjects) {
13
+ return new SelectChannelModelUCMock(appObjects.getOrCreate("SelectChannelModelUCMock"));
14
+ }
15
+ exports.makeSelectChannelModelUCMock = makeSelectChannelModelUCMock;
@@ -1,3 +1,6 @@
1
+ export * from "./ActiveModelMock";
1
2
  export * from "./ChannelModelObjectPMMock";
2
3
  export * from "./ChannelModelPMMock";
3
4
  export * from "./ChannelModelViewFactoryMock";
5
+ export * from "./LoadChannelModelMock";
6
+ export * from "./SelectChannelModelUCMock";
@@ -10,6 +10,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./ActiveModelMock"), exports);
13
14
  __exportStar(require("./ChannelModelObjectPMMock"), exports);
14
15
  __exportStar(require("./ChannelModelPMMock"), exports);
15
16
  __exportStar(require("./ChannelModelViewFactoryMock"), exports);
17
+ __exportStar(require("./LoadChannelModelMock"), exports);
18
+ __exportStar(require("./SelectChannelModelUCMock"), exports);
@@ -0,0 +1,13 @@
1
+ import { AppObject, AppObjectPM, AppObjectRepo } from "../../../AppObject";
2
+ export declare abstract class ActiveModelPM extends AppObjectPM<string> {
3
+ static readonly type = "ActiveModelPM";
4
+ static get(appObjects: AppObjectRepo): ActiveModelPM | undefined;
5
+ }
6
+ export declare function makeActiveModelPM(appObject: AppObject): ActiveModelPMImp;
7
+ declare class ActiveModelPMImp extends ActiveModelPM {
8
+ private get repo();
9
+ vmsAreEqual(a: string, b: string): boolean;
10
+ onEntityChange: () => void;
11
+ constructor(appObject: AppObject);
12
+ }
13
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeActiveModelPM = exports.ActiveModelPM = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const Entities_1 = require("../Entities");
6
+ class ActiveModelPM extends AppObject_1.AppObjectPM {
7
+ static get(appObjects) {
8
+ return AppObject_1.getSingletonComponent(ActiveModelPM.type, appObjects);
9
+ }
10
+ }
11
+ exports.ActiveModelPM = ActiveModelPM;
12
+ ActiveModelPM.type = "ActiveModelPM";
13
+ function makeActiveModelPM(appObject) {
14
+ return new ActiveModelPMImp(appObject);
15
+ }
16
+ exports.makeActiveModelPM = makeActiveModelPM;
17
+ class ActiveModelPMImp extends ActiveModelPM {
18
+ constructor(appObject) {
19
+ var _a;
20
+ super(appObject, ActiveModelPM.type);
21
+ this.onEntityChange = () => {
22
+ if (!this.repo)
23
+ return;
24
+ this.doUpdateView(this.repo.activeModel);
25
+ };
26
+ (_a = this.repo) === null || _a === void 0 ? void 0 : _a.addChangeObserver(this.onEntityChange);
27
+ this.onEntityChange();
28
+ this.appObjects.registerSingleton(this);
29
+ }
30
+ get repo() {
31
+ return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
32
+ }
33
+ vmsAreEqual(a, b) {
34
+ return a === b;
35
+ }
36
+ }
@@ -1,2 +1,3 @@
1
+ export * from "./ActiveModelPM";
1
2
  export * from "./ChannelModelObjectPM";
2
3
  export * from "./ChannelModelPM";
@@ -10,5 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./ActiveModelPM"), exports);
13
14
  __exportStar(require("./ChannelModelObjectPM"), exports);
14
15
  __exportStar(require("./ChannelModelPM"), exports);
@@ -0,0 +1,10 @@
1
+ import { AppObject, AppObjectRepo, AppObjectUC } from "../../../AppObject";
2
+ import { ChannelModelEntity } from "../Entities";
3
+ export declare const SCENE_MODEL_DATA_ASSET_LINK_TYPE = "default_model_data";
4
+ export declare abstract class LoadChannelModelUC extends AppObjectUC {
5
+ static type: string;
6
+ abstract loadChannelModel(id: string): Promise<ChannelModelEntity>;
7
+ abstract blobToJSON(blobURL: string): Promise<object>;
8
+ static get(appObjects: AppObjectRepo): LoadChannelModelUC | undefined;
9
+ }
10
+ export declare function makeLoadChannelModelUC(appObject: AppObject): LoadChannelModelUC;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeLoadChannelModelUC = exports.LoadChannelModelUC = exports.SCENE_MODEL_DATA_ASSET_LINK_TYPE = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const Dispatcher_1 = require("../../Dispatcher");
6
+ const GLBModel_1 = require("../../GLBModel");
7
+ const Entities_1 = require("../Entities");
8
+ const ChannelModelViewFactory_1 = require("./ChannelModelViewFactory");
9
+ exports.SCENE_MODEL_DATA_ASSET_LINK_TYPE = "default_model_data";
10
+ class LoadChannelModelUC extends AppObject_1.AppObjectUC {
11
+ static get(appObjects) {
12
+ return AppObject_1.getSingletonComponent(LoadChannelModelUC.type, appObjects);
13
+ }
14
+ }
15
+ exports.LoadChannelModelUC = LoadChannelModelUC;
16
+ LoadChannelModelUC.type = "LoadChannelModelUC";
17
+ function makeLoadChannelModelUC(appObject) {
18
+ return new LoadChannelModelUCImp(appObject);
19
+ }
20
+ exports.makeLoadChannelModelUC = makeLoadChannelModelUC;
21
+ class LoadChannelModelUCImp extends LoadChannelModelUC {
22
+ constructor(appObject) {
23
+ super(appObject, LoadChannelModelUC.type);
24
+ this.loadChannelModel = (modelID) => {
25
+ if (!this.channelModelRepo ||
26
+ !this.glbRepo ||
27
+ !this.loadGlbFile ||
28
+ !this.getAssetBlob ||
29
+ !this.getLinkedAsset ||
30
+ !this.channelModelViewFactory ||
31
+ !this.showSpinner) {
32
+ this.error("Missing Component(s)");
33
+ return Promise.reject(new Error("Missing Component(s)"));
34
+ }
35
+ const existingChannelModel = this.channelModelRepo.getForAppObject(modelID);
36
+ if (existingChannelModel) {
37
+ if (existingChannelModel.state === Entities_1.ChannelModelState.READY) {
38
+ return Promise.resolve(existingChannelModel);
39
+ }
40
+ else if (existingChannelModel.state === Entities_1.ChannelModelState.LOADING) {
41
+ return this.waitForExistingToLoad(existingChannelModel);
42
+ }
43
+ else if (existingChannelModel.state === Entities_1.ChannelModelState.ERROR) {
44
+ return Promise.reject(existingChannelModel.modelError);
45
+ }
46
+ }
47
+ const channelModel = this.channelModelRepo.createChannelModel(modelID);
48
+ channelModel.state = Entities_1.ChannelModelState.LOADING;
49
+ const getLinkedAsset = this.getLinkedAsset;
50
+ const getAssetBlob = this.getAssetBlob;
51
+ const channelModelViewFactory = this.channelModelViewFactory;
52
+ let closeSpinner = () => { };
53
+ return this.showSpinner("Loading Model", "Loading channel model...")
54
+ .then((closeCB) => {
55
+ closeSpinner = closeCB;
56
+ return getAssetBlob(modelID);
57
+ })
58
+ .then((blobURL) => {
59
+ const glbModel = this.glbRepo.createGlbModel(modelID);
60
+ return this.loadGlbFile.loadBlobURL(blobURL, glbModel);
61
+ })
62
+ .then(() => {
63
+ return getLinkedAsset(modelID, exports.SCENE_MODEL_DATA_ASSET_LINK_TYPE);
64
+ })
65
+ .then((dataAssets) => {
66
+ if (dataAssets.length === 0) {
67
+ return Promise.reject(new Error("Model asset does not have data"));
68
+ }
69
+ return getAssetBlob(dataAssets[0].id);
70
+ })
71
+ .then((blobURL) => {
72
+ return this.blobToJSON(blobURL);
73
+ })
74
+ .then((dto) => {
75
+ channelModel.setupFromData(dto);
76
+ channelModelViewFactory.initializeView(channelModel);
77
+ channelModel.state = Entities_1.ChannelModelState.READY;
78
+ closeSpinner();
79
+ return channelModel;
80
+ })
81
+ .catch((e) => {
82
+ closeSpinner();
83
+ return Promise.reject(e);
84
+ });
85
+ };
86
+ this.blobToJSON = (url) => {
87
+ return fetch(url).then((resp) => {
88
+ return resp.json();
89
+ });
90
+ };
91
+ this.appObjects.registerSingleton(this);
92
+ }
93
+ get channelModelRepo() {
94
+ return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
95
+ }
96
+ get loadGlbFile() {
97
+ return this.getCachedSingleton(GLBModel_1.LoadGlbFileUC.type);
98
+ }
99
+ get glbRepo() {
100
+ return this.getCachedSingleton(GLBModel_1.GlbModelRepo.type);
101
+ }
102
+ get channelModelViewFactory() {
103
+ return this.getCachedSingleton(ChannelModelViewFactory_1.ChannelModelViewFactory.type);
104
+ }
105
+ get getAssetBlob() {
106
+ var _a;
107
+ return (_a = this.getCachedSingleton(Dispatcher_1.GetAssetBlobURLUC.type)) === null || _a === void 0 ? void 0 : _a.doDispatch;
108
+ }
109
+ get getLinkedAsset() {
110
+ var _a;
111
+ return (_a = this.getCachedSingleton(Dispatcher_1.GetLinkedAssetsUC.type)) === null || _a === void 0 ? void 0 : _a.doDispatch;
112
+ }
113
+ get showSpinner() {
114
+ var _a;
115
+ return (_a = this.getCachedSingleton(Dispatcher_1.ShowSpinnerUC.type)) === null || _a === void 0 ? void 0 : _a.showSpinner;
116
+ }
117
+ waitForExistingToLoad(existing) {
118
+ return new Promise((resolve, reject) => {
119
+ const onExistingModelChange = () => {
120
+ if (existing.state === Entities_1.ChannelModelState.READY) {
121
+ existing.removeChangeObserver(onExistingModelChange);
122
+ resolve(existing);
123
+ }
124
+ else if (existing.state === Entities_1.ChannelModelState.ERROR) {
125
+ existing.removeChangeObserver(onExistingModelChange);
126
+ reject(existing.modelError);
127
+ }
128
+ };
129
+ existing.addChangeObserver(onExistingModelChange);
130
+ });
131
+ }
132
+ }
@@ -4,7 +4,8 @@ exports.makeSelectChannelModelUC = exports.SelectChannelModelUC = void 0;
4
4
  const AppObject_1 = require("../../../AppObject");
5
5
  const Dispatcher_1 = require("../../Dispatcher");
6
6
  const SceneRoot_1 = require("../../SceneRoot");
7
- const SetupChannelModelUC_1 = require("./SetupChannelModelUC");
7
+ const Entities_1 = require("../Entities");
8
+ const LoadChannelModelUC_1 = require("./LoadChannelModelUC");
8
9
  class SelectChannelModelUC extends AppObject_1.AppObjectUC {
9
10
  }
10
11
  exports.SelectChannelModelUC = SelectChannelModelUC;
@@ -18,40 +19,39 @@ class SelectChannelModelUCImp extends SelectChannelModelUC {
18
19
  constructor(appObject) {
19
20
  super(appObject, SelectChannelModelUC.type);
20
21
  this.selectChannelModel = () => {
21
- return new Promise((resolve, reject) => {
22
- const appObjects = this.appObject.appObjectRepo;
23
- const setupChannelModelUC = SetupChannelModelUC_1.SetupChannelModelUC.get(appObjects);
24
- if (!setupChannelModelUC) {
25
- this.warn("Unable to get setupChannelModelUC from the model repo App Object");
26
- reject(new Error("Unable to get setupChannelModelUC from the model repo App Object"));
27
- return;
28
- }
29
- const showSelectModel = Dispatcher_1.ShowSelectModelUC.get(appObjects);
30
- if (!showSelectModel) {
31
- this.warn("Unable to find show select model UC");
32
- reject(new Error("Unable to find show select model UC"));
33
- return;
34
- }
35
- let modelID = "";
36
- showSelectModel
37
- .doDispatch()
38
- .then((resp) => {
39
- modelID = resp.modelId;
40
- return setupChannelModelUC.setupChannelModel(modelID);
41
- })
42
- .then((channelModel) => {
43
- const sceneRoot = SceneRoot_1.SceneRootEntity.get(appObjects);
44
- if (!sceneRoot)
45
- return;
46
- sceneRoot.position = channelModel.defaultPosition;
47
- sceneRoot.rotation = channelModel.defaultRotation;
48
- sceneRoot.scale = channelModel.defaultScale;
49
- resolve(modelID);
50
- })
51
- .catch((e) => {
52
- reject(e);
53
- });
22
+ const showSelectModel = this.showSelectModel;
23
+ const loadChannelModel = this.loadChannelModel;
24
+ const sceneRoot = this.sceneRoot;
25
+ const repo = this.repo;
26
+ if (!showSelectModel || !loadChannelModel || !sceneRoot || !repo) {
27
+ return Promise.reject(new Error("Missing Components"));
28
+ }
29
+ return showSelectModel
30
+ .doDispatch()
31
+ .then((resp) => {
32
+ return loadChannelModel(resp.modelId);
33
+ })
34
+ .then((channelModel) => {
35
+ sceneRoot.position = channelModel.defaultPosition;
36
+ sceneRoot.rotation = channelModel.defaultRotation;
37
+ sceneRoot.scale = channelModel.defaultScale;
38
+ repo.activeModel = channelModel.id;
39
+ return channelModel.id;
54
40
  });
55
41
  };
42
+ this.appObjects.registerSingleton(this);
43
+ }
44
+ get showSelectModel() {
45
+ return this.getCachedSingleton(Dispatcher_1.ShowSelectModelUC.type);
46
+ }
47
+ get loadChannelModel() {
48
+ var _a;
49
+ return (_a = this.getCachedSingleton(LoadChannelModelUC_1.LoadChannelModelUC.type)) === null || _a === void 0 ? void 0 : _a.loadChannelModel;
50
+ }
51
+ get sceneRoot() {
52
+ return this.getCachedSingleton(SceneRoot_1.SceneRootEntity.type);
53
+ }
54
+ get repo() {
55
+ return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
56
56
  }
57
57
  }
@@ -0,0 +1,26 @@
1
+ import { AppObject, AppObjectUC } from "../../../AppObject";
2
+ import { SerializedSystem } from "../../StateMachine";
3
+ export declare abstract class SerializeActiveModel extends AppObjectUC implements SerializedSystem {
4
+ static readonly type = "SerializeDemoState";
5
+ name: string;
6
+ abstract seriliziationVersion: number;
7
+ abstract getSystemState(): object;
8
+ abstract applySystemState(state: object, version: number, transitionDuration: number): void;
9
+ abstract applyDefaultState(transitionDuration: number): void;
10
+ }
11
+ export declare function makeSerializeActiveModel(appObject: AppObject): SerializeActiveModel;
12
+ export declare class SerializeActiveModelImp extends SerializeActiveModel {
13
+ seriliziationVersion: number;
14
+ private get repo();
15
+ private get stateMachine();
16
+ private get loadChannelModel();
17
+ private get showSelectModel();
18
+ getSystemState(): object;
19
+ applySystemState(state: object, version: number): void;
20
+ applyStateV1(state: SerializedActiveModelStateV1): void;
21
+ applyDefaultState(): void;
22
+ constructor(appObject: AppObject);
23
+ }
24
+ export interface SerializedActiveModelStateV1 {
25
+ modelID: string;
26
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializeActiveModelImp = exports.makeSerializeActiveModel = exports.SerializeActiveModel = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const StateMachine_1 = require("../../StateMachine");
6
+ const Entities_1 = require("../Entities");
7
+ const LoadChannelModelUC_1 = require("./LoadChannelModelUC");
8
+ const SelectChannelModelUC_1 = require("./SelectChannelModelUC");
9
+ class SerializeActiveModel extends AppObject_1.AppObjectUC {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.name = "active-model";
13
+ }
14
+ }
15
+ exports.SerializeActiveModel = SerializeActiveModel;
16
+ SerializeActiveModel.type = "SerializeDemoState";
17
+ function makeSerializeActiveModel(appObject) {
18
+ return new SerializeActiveModelImp(appObject);
19
+ }
20
+ exports.makeSerializeActiveModel = makeSerializeActiveModel;
21
+ class SerializeActiveModelImp extends SerializeActiveModel {
22
+ constructor(appObject) {
23
+ var _a;
24
+ super(appObject, SerializeActiveModel.type);
25
+ this.seriliziationVersion = 1;
26
+ (_a = this.stateMachine) === null || _a === void 0 ? void 0 : _a.registerSerializedSystem(this);
27
+ }
28
+ get repo() {
29
+ return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
30
+ }
31
+ get stateMachine() {
32
+ return this.getCachedSingleton(StateMachine_1.StateMachineEntity.type);
33
+ }
34
+ get loadChannelModel() {
35
+ var _a;
36
+ return (_a = this.getCachedSingleton(LoadChannelModelUC_1.LoadChannelModelUC.type)) === null || _a === void 0 ? void 0 : _a.loadChannelModel;
37
+ }
38
+ get showSelectModel() {
39
+ var _a;
40
+ return (_a = this.getCachedSingleton(SelectChannelModelUC_1.SelectChannelModelUC.type)) === null || _a === void 0 ? void 0 : _a.selectChannelModel;
41
+ }
42
+ getSystemState() {
43
+ if (!this.repo)
44
+ return {};
45
+ const appState = {
46
+ modelID: this.repo.activeModel,
47
+ };
48
+ return appState;
49
+ }
50
+ applySystemState(state, version) {
51
+ if (version === 1) {
52
+ this.applyStateV1(state);
53
+ }
54
+ else {
55
+ // Unsupported version
56
+ this.warn(`Unsupported data version ${version} for serialized system ${this.name}. Reverting to default state`);
57
+ this.applyDefaultState();
58
+ }
59
+ }
60
+ applyStateV1(state) {
61
+ const { modelID } = state;
62
+ if (!modelID) {
63
+ this.applyDefaultState();
64
+ return;
65
+ }
66
+ if (!this.repo || !this.loadChannelModel) {
67
+ return;
68
+ }
69
+ this.repo.activeModel = modelID;
70
+ this.loadChannelModel(modelID);
71
+ }
72
+ applyDefaultState() {
73
+ if (!this.repo || !this.showSelectModel) {
74
+ return;
75
+ }
76
+ this.repo.activeModel = "";
77
+ this.showSelectModel();
78
+ }
79
+ }
80
+ exports.SerializeActiveModelImp = SerializeActiveModelImp;
@@ -1 +1,4 @@
1
1
  export * from "./ChannelModelViewFactory";
2
+ export * from "./LoadChannelModelUC";
3
+ export * from "./SelectChannelModelUC";
4
+ export * from "./SerializeActiveModel";
@@ -11,3 +11,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./ChannelModelViewFactory"), exports);
14
+ __exportStar(require("./LoadChannelModelUC"), exports);
15
+ __exportStar(require("./SelectChannelModelUC"), exports);
16
+ __exportStar(require("./SerializeActiveModel"), exports);
@@ -0,0 +1,8 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject, AppObjectRepo } from "../../../AppObject";
3
+ import { GetAssetBlobURLUC } from "../UC";
4
+ export declare class GetAssetBlobURLUCMock extends GetAssetBlobURLUC {
5
+ doDispatch: jest.Mock<any, any>;
6
+ constructor(appObject: AppObject);
7
+ }
8
+ export declare function makeGetAssetBlobURLUCMock(appObjects: AppObjectRepo): GetAssetBlobURLUCMock;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeGetAssetBlobURLUCMock = exports.GetAssetBlobURLUCMock = void 0;
4
+ const UC_1 = require("../UC");
5
+ class GetAssetBlobURLUCMock extends UC_1.GetAssetBlobURLUC {
6
+ constructor(appObject) {
7
+ super(appObject, UC_1.GetAssetBlobURLUC.type);
8
+ this.doDispatch = jest.fn();
9
+ }
10
+ }
11
+ exports.GetAssetBlobURLUCMock = GetAssetBlobURLUCMock;
12
+ function makeGetAssetBlobURLUCMock(appObjects) {
13
+ return new GetAssetBlobURLUCMock(appObjects.getOrCreate("GetAssetBlobURLUCMock"));
14
+ }
15
+ exports.makeGetAssetBlobURLUCMock = makeGetAssetBlobURLUCMock;