@vived/app 2.28.0 → 2.29.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.
Files changed (147) hide show
  1. package/lib/Entities/AppDispatcher.d.ts +1 -0
  2. package/lib/Entities/AppDispatcher.js +22 -0
  3. package/package.json +1 -1
  4. package/lib/Core/BaseApp/Boundary.d.ts +0 -49
  5. package/lib/Core/BaseApp/Boundary.js +0 -2
  6. package/lib/Core/BaseApp/Entity.d.ts +0 -11
  7. package/lib/Core/BaseApp/Entity.js +0 -2
  8. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.d.ts +0 -3
  9. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.js +0 -12
  10. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.d.ts +0 -3
  11. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.js +0 -10
  12. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.d.ts +0 -3
  13. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.js +0 -10
  14. package/lib/Core/BaseApp/Errors/index.d.ts +0 -3
  15. package/lib/Core/BaseApp/Errors/index.js +0 -15
  16. package/lib/Core/BaseApp/UseCase.d.ts +0 -43
  17. package/lib/Core/BaseApp/UseCase.js +0 -250
  18. package/lib/Core/BaseAppState/Boundary.d.ts +0 -14
  19. package/lib/Core/BaseAppState/Boundary.js +0 -2
  20. package/lib/Core/BaseAppState/Entity.d.ts +0 -5
  21. package/lib/Core/BaseAppState/Entity.js +0 -2
  22. package/lib/Core/BaseAppState/UseCase.d.ts +0 -16
  23. package/lib/Core/BaseAppState/UseCase.js +0 -54
  24. package/lib/Core/BaseAppState/UseCase_Imp.d.ts +0 -16
  25. package/lib/Core/BaseAppState/UseCase_Imp.js +0 -54
  26. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.d.ts +0 -16
  27. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.js +0 -56
  28. package/lib/Core/DevicePreview/boundary.d.ts +0 -14
  29. package/lib/Core/DevicePreview/boundary.js +0 -2
  30. package/lib/Core/DevicePreview/entity.d.ts +0 -5
  31. package/lib/Core/DevicePreview/entity.js +0 -2
  32. package/lib/Core/DispatchToHost/Entity.d.ts +0 -4
  33. package/lib/Core/DispatchToHost/Entity.js +0 -2
  34. package/lib/Core/DispatchToHost/UseCase.d.ts +0 -12
  35. package/lib/Core/DispatchToHost/UseCase.js +0 -70
  36. package/lib/Core/DispatchToHost/boundary.d.ts +0 -9
  37. package/lib/Core/DispatchToHost/boundary.js +0 -2
  38. package/lib/Core/Serilization/Boundary.d.ts +0 -20
  39. package/lib/Core/Serilization/Boundary.js +0 -2
  40. package/lib/Core/Serilization/Entity.d.ts +0 -3
  41. package/lib/Core/Serilization/Entity.js +0 -2
  42. package/lib/Core/Serilization/ErrorDuplicateSystemName.d.ts +0 -3
  43. package/lib/Core/Serilization/ErrorDuplicateSystemName.js +0 -12
  44. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.d.ts +0 -3
  45. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.js +0 -10
  46. package/lib/Core/Serilization/Errors.d.ts +0 -6
  47. package/lib/Core/Serilization/Errors.js +0 -19
  48. package/lib/Core/Serilization/UseCase.d.ts +0 -10
  49. package/lib/Core/Serilization/UseCase.js +0 -52
  50. package/lib/Core/Serilization/UseCase_Imp.d.ts +0 -10
  51. package/lib/Core/Serilization/UseCase_Imp.js +0 -51
  52. package/lib/Core/index.d.ts +0 -3
  53. package/lib/Core/index.js +0 -19
  54. package/lib/Entities/Color.d.ts +0 -20
  55. package/lib/Entities/Color.js +0 -59
  56. package/lib/Entities/FocusCamera.d.ts +0 -70
  57. package/lib/Entities/FocusCamera.js +0 -272
  58. package/lib/Entities/LineSegment2D.d.ts +0 -11
  59. package/lib/Entities/LineSegment2D.js +0 -70
  60. package/lib/Entities/MouseSceneInput.d.ts +0 -15
  61. package/lib/Entities/MouseSceneInput.js +0 -109
  62. package/lib/Entities/OrbitCamera.d.ts +0 -76
  63. package/lib/Entities/OrbitCamera.js +0 -243
  64. package/lib/Entities/ParametricLine.d.ts +0 -29
  65. package/lib/Entities/ParametricLine.js +0 -79
  66. package/lib/Entities/ParametricPlane.d.ts +0 -20
  67. package/lib/Entities/ParametricPlane.js +0 -63
  68. package/lib/Entities/Vector2.d.ts +0 -21
  69. package/lib/Entities/Vector2.js +0 -83
  70. package/lib/Entities/Vector3.d.ts +0 -19
  71. package/lib/Entities/Vector3.js +0 -75
  72. package/lib/Interface/Controllers/appHandler.d.ts +0 -12
  73. package/lib/Interface/Controllers/appHandler.js +0 -94
  74. package/lib/Interface/Controllers/defaultAppHanlderFunctions.d.ts +0 -3
  75. package/lib/Interface/Controllers/defaultAppHanlderFunctions.js +0 -31
  76. package/lib/Interface/Controllers/dispatchStateChange.d.ts +0 -2
  77. package/lib/Interface/Controllers/dispatchStateChange.js +0 -10
  78. package/lib/Interface/Controllers/index.d.ts +0 -9
  79. package/lib/Interface/Controllers/index.js +0 -21
  80. package/lib/Interface/Controllers/makeAppHandler.d.ts +0 -12
  81. package/lib/Interface/Controllers/makeAppHandler.js +0 -96
  82. package/lib/Interface/Controllers/setDevicePreview.d.ts +0 -2
  83. package/lib/Interface/Controllers/setDevicePreview.js +0 -14
  84. package/lib/Interface/Controllers/setIsAuthoring.d.ts +0 -2
  85. package/lib/Interface/Controllers/setIsAuthoring.js +0 -14
  86. package/lib/Interface/Controllers/setState.d.ts +0 -2
  87. package/lib/Interface/Controllers/setState.js +0 -21
  88. package/lib/Interface/Controllers/showBabylonInspector.d.ts +0 -2
  89. package/lib/Interface/Controllers/showBabylonInspector.js +0 -9
  90. package/lib/Interface/Controllers/startApp.d.ts +0 -1
  91. package/lib/Interface/Controllers/startApp.js +0 -9
  92. package/lib/Interface/Controllers/stopApp.d.ts +0 -2
  93. package/lib/Interface/Controllers/stopApp.js +0 -10
  94. package/lib/Interface/PresentationManagers/DevicePreviewPM.d.ts +0 -13
  95. package/lib/Interface/PresentationManagers/DevicePreviewPM.js +0 -25
  96. package/lib/Interface/PresentationManagers/IsAuthoringPM.d.ts +0 -10
  97. package/lib/Interface/PresentationManagers/IsAuthoringPM.js +0 -23
  98. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.d.ts +0 -10
  99. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.js +0 -23
  100. package/lib/Interface/PresentationManagers/index.d.ts +0 -3
  101. package/lib/Interface/PresentationManagers/index.js +0 -15
  102. package/lib/Interface/appHandler.d.ts +0 -12
  103. package/lib/Interface/appHandler.js +0 -94
  104. package/lib/Interface/index.d.ts +0 -2
  105. package/lib/Interface/index.js +0 -14
  106. package/lib/PresentationManagers/FocusCameraPM.d.ts +0 -15
  107. package/lib/PresentationManagers/FocusCameraPM.js +0 -31
  108. package/lib/PresentationManagers/FocusCameraPosRotPM.d.ts +0 -13
  109. package/lib/PresentationManagers/FocusCameraPosRotPM.js +0 -28
  110. package/lib/PresentationManagers/HoverLabelPM.d.ts +0 -17
  111. package/lib/PresentationManagers/HoverLabelPM.js +0 -32
  112. package/lib/PresentationManagers/OrbitCameraPM.d.ts +0 -14
  113. package/lib/PresentationManagers/OrbitCameraPM.js +0 -31
  114. package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +0 -17
  115. package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +0 -64
  116. package/lib/UseCases/FocusCamera/LerpFocusCamera.d.ts +0 -36
  117. package/lib/UseCases/FocusCamera/LerpFocusCamera.js +0 -71
  118. package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.d.ts +0 -11
  119. package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +0 -36
  120. package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +0 -11
  121. package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +0 -36
  122. package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +0 -11
  123. package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +0 -26
  124. package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +0 -11
  125. package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +0 -33
  126. package/lib/UseCases/FocusCamera/SerializeFocusCamera.d.ts +0 -22
  127. package/lib/UseCases/FocusCamera/SerializeFocusCamera.js +0 -81
  128. package/lib/UseCases/FocusCamera/index.d.ts +0 -7
  129. package/lib/UseCases/FocusCamera/index.js +0 -19
  130. package/lib/UseCases/LerpOrbitCamera.d.ts +0 -36
  131. package/lib/UseCases/LerpOrbitCamera.js +0 -71
  132. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +0 -36
  133. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +0 -71
  134. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +0 -9
  135. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +0 -31
  136. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +0 -10
  137. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +0 -31
  138. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +0 -22
  139. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +0 -81
  140. package/lib/UseCases/OrbitCamera/index.d.ts +0 -4
  141. package/lib/UseCases/OrbitCamera/index.js +0 -16
  142. package/lib/UseCases/SerializeCamera.d.ts +0 -21
  143. package/lib/UseCases/SerializeCamera.js +0 -59
  144. package/lib/UseCases/SerializeOrbitCamera.d.ts +0 -21
  145. package/lib/UseCases/SerializeOrbitCamera.js +0 -59
  146. package/lib/UseCases/SerializedCamDemo.d.ts +0 -0
  147. package/lib/UseCases/SerializedCamDemo.js +0 -1
@@ -23,5 +23,6 @@ export declare abstract class AppDispatcher {
23
23
  abstract getAssetBlob: (assetID: string) => Promise<string>;
24
24
  abstract getAssetMeta: (assetID: string) => Promise<AssetMetaDTO>;
25
25
  abstract getAssetsForOwner: (ownerID: string) => Promise<AssetMetaDTO[]>;
26
+ abstract submitNewActivityAsset: (file: File) => Promise<string>;
26
27
  }
27
28
  export declare function makeAppDispatcher(): AppDispatcher;
@@ -206,6 +206,28 @@ class AppDistpatcherImp extends AppDispatcher {
206
206
  }
207
207
  });
208
208
  };
209
+ this.submitNewActivityAsset = (file) => {
210
+ return new Promise((resolve, reject) => {
211
+ const callback = (assetID) => {
212
+ if (assetID) {
213
+ resolve(assetID);
214
+ }
215
+ else {
216
+ reject(new Error("Failed to get asset ID"));
217
+ }
218
+ };
219
+ const payload = {
220
+ file,
221
+ callback,
222
+ };
223
+ if (!this.hostHandler) {
224
+ reject(new Error("No host handler has been registered"));
225
+ }
226
+ else {
227
+ this.formRequestAndDispatch("NEW_ACTIVITY_ASSET", 1, payload);
228
+ }
229
+ });
230
+ };
209
231
  }
210
232
  formRequestAndDispatch(type, version, payload) {
211
233
  const request = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "2.28.0",
3
+ "version": "2.29.1",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,49 +0,0 @@
1
- import { Handler } from "@vived/app-host-boundary";
2
- export interface BaseAppUC {
3
- getIsAuthoring(): boolean;
4
- setIsAuthoring(isAuthoring: boolean): void;
5
- getShowBabylonInspector(): boolean;
6
- setShowBabylonInspector(showInspector: boolean): void;
7
- addObserver(observer: BaseAppStateObserver): void;
8
- removeObserver(observer: BaseAppStateObserver): void;
9
- setVerbose(verbose: boolean): void;
10
- getSerializedState(): SerializedStates;
11
- setSerializedState(state: SerializedStates, transitionTime: number): void;
12
- setDefaultState(transitionTime: number): void;
13
- registerSerializableSystem(serializedSystem: SerializableSystem): void;
14
- getIsTransitioning(): boolean;
15
- abortTransition(): void;
16
- setTransitionEaseFn: (easeFn: (normalizedTime: number) => number) => void;
17
- setHostHandler(handler: Handler): void;
18
- hasHostHandler(): boolean;
19
- dispatchOnStateChange(stateObject: object): void;
20
- dispatchOnStateComplete(): void;
21
- dispatchSubmitResults(results: object): void;
22
- dispatchGetAppAssetsURL(): string;
23
- setDevicePreview(x: number, y: number): void;
24
- clearDevicePreview(): void;
25
- getUseDevicePreview(): boolean;
26
- getDevicePreviewSize(): {
27
- x: number;
28
- y: number;
29
- };
30
- }
31
- export interface BaseAppStateObserver {
32
- onBaseAppChange: () => void;
33
- }
34
- export interface SerializedStates {
35
- version: number;
36
- systems: SystemState[];
37
- }
38
- export interface SystemState {
39
- name: string;
40
- seriliziationVersion: number;
41
- state: object;
42
- }
43
- export interface SerializableSystem {
44
- name: string;
45
- seriliziationVersion: number;
46
- getSerializedObject(): object;
47
- intializeStateForTransition(serializedState: object | null, version: number): void;
48
- applyTransition(percent: number): void;
49
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- export interface BaseAppState {
2
- isAuthoring: boolean;
3
- showBabyonInspector: boolean;
4
- handler?: unknown;
5
- appAssetsURL?: string;
6
- useDevicePreview: boolean;
7
- x: number;
8
- y: number;
9
- isTransitioning: boolean;
10
- verbose: boolean;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- export declare class DuplicateSystemNameError extends Error {
2
- constructor(name: string);
3
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DuplicateSystemNameError = void 0;
4
- class DuplicateSystemNameError extends Error {
5
- constructor(name) {
6
- const msg = "Cannot add two serialized systems named " +
7
- name +
8
- ". Every system name must be unique";
9
- super(msg);
10
- }
11
- }
12
- exports.DuplicateSystemNameError = DuplicateSystemNameError;
@@ -1,3 +0,0 @@
1
- export declare class ErrorNoHostHandler extends Error {
2
- constructor();
3
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorNoHostHandler = void 0;
4
- class ErrorNoHostHandler extends Error {
5
- constructor() {
6
- const msg = "Host Handler has not been set";
7
- super(msg);
8
- }
9
- }
10
- exports.ErrorNoHostHandler = ErrorNoHostHandler;
@@ -1,3 +0,0 @@
1
- export declare class UnsupportedVersionNumber extends Error {
2
- constructor(version: number);
3
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnsupportedVersionNumber = void 0;
4
- class UnsupportedVersionNumber extends Error {
5
- constructor(version) {
6
- const msg = "Serialization version " + version + " is not supported";
7
- super(msg);
8
- }
9
- }
10
- exports.UnsupportedVersionNumber = UnsupportedVersionNumber;
@@ -1,3 +0,0 @@
1
- export * from "./ErrorDuplicateSystemName";
2
- export * from "./ErrorUnsupportedVersionNumber";
3
- export * from "./ErrorNoHostHandler";
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./ErrorDuplicateSystemName"), exports);
14
- __exportStar(require("./ErrorUnsupportedVersionNumber"), exports);
15
- __exportStar(require("./ErrorNoHostHandler"), exports);
@@ -1,43 +0,0 @@
1
- import { Handler } from "@vived/app-host-boundary";
2
- import { BaseAppStateObserver, BaseAppUC, SerializableSystem, SerializedStates } from "./Boundary";
3
- export declare class BaseAppUCImp implements BaseAppUC {
4
- private appState;
5
- private observers;
6
- private systems;
7
- private serilizationVersion;
8
- private currentInterval?;
9
- private easeFunction;
10
- constructor();
11
- setVerbose(verbose: boolean): void;
12
- abortTransition: () => void;
13
- setTransitionEaseFn: (easeFn: (normalizedTime: number) => number) => void;
14
- getIsTransitioning: () => boolean;
15
- setDevicePreview: (x: number, y: number) => void;
16
- clearDevicePreview: () => void;
17
- getUseDevicePreview: () => boolean;
18
- getDevicePreviewSize: () => {
19
- x: number;
20
- y: number;
21
- };
22
- setHostHandler: (handler: Handler) => void;
23
- hasHostHandler: () => boolean;
24
- dispatchOnStateChange: (stateObject: object) => void;
25
- dispatchOnStateComplete: () => void;
26
- dispatchSubmitResults: (results: object) => void;
27
- dispatchGetAppAssetsURL: () => string;
28
- registerSerializableSystem: (serializedSystem: SerializableSystem) => void;
29
- getSerializedState: () => SerializedStates;
30
- setSerializedState: (state: SerializedStates, duration: number) => void;
31
- setDefaultState: (duration: number) => void;
32
- getShowBabylonInspector: () => boolean;
33
- setShowBabylonInspector: (showInspector: boolean) => void;
34
- getIsAuthoring: () => boolean;
35
- setIsAuthoring: (isAuthoring: boolean) => void;
36
- addObserver: (observer: BaseAppStateObserver) => void;
37
- removeObserver: (observer: BaseAppStateObserver) => void;
38
- private logToConsole;
39
- private startTransition;
40
- private applyTransitionToSystems;
41
- private notify;
42
- private dispatch;
43
- }
@@ -1,250 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseAppUCImp = void 0;
4
- const app_host_boundary_1 = require("@vived/app-host-boundary");
5
- const Errors_1 = require("./Errors");
6
- class BaseAppUCImp {
7
- constructor() {
8
- this.observers = [];
9
- this.systems = new Map();
10
- this.serilizationVersion = 2;
11
- this.easeFunction = (normalizedTime) => {
12
- return normalizedTime; // default to a linear function
13
- };
14
- this.abortTransition = () => {
15
- if (this.currentInterval) {
16
- clearInterval(this.currentInterval);
17
- }
18
- this.appState.isTransitioning = false;
19
- };
20
- this.setTransitionEaseFn = (easeFn) => {
21
- this.easeFunction = easeFn;
22
- };
23
- this.getIsTransitioning = () => {
24
- return this.appState.isTransitioning;
25
- };
26
- this.setDevicePreview = (x, y) => {
27
- if (this.appState.useDevicePreview &&
28
- x === this.appState.x &&
29
- y === this.appState.y) {
30
- return;
31
- }
32
- this.appState.useDevicePreview = true;
33
- this.appState.x = x;
34
- this.appState.y = y;
35
- this.notify();
36
- this.logToConsole(`Device Preview set to ${x}, ${y}`);
37
- };
38
- this.clearDevicePreview = () => {
39
- if (!this.appState.useDevicePreview)
40
- return;
41
- this.appState.useDevicePreview = false;
42
- this.appState.x = -1;
43
- this.appState.y = -1;
44
- this.notify();
45
- this.logToConsole(`Device Preview cleared`);
46
- };
47
- this.getUseDevicePreview = () => {
48
- return this.appState.useDevicePreview;
49
- };
50
- this.getDevicePreviewSize = () => {
51
- const { x, y } = this.appState;
52
- return { x, y };
53
- };
54
- this.setHostHandler = (handler) => {
55
- this.appState.handler = handler;
56
- this.logToConsole("Handler set");
57
- };
58
- this.hasHostHandler = () => {
59
- if (this.appState.handler) {
60
- return true;
61
- }
62
- else {
63
- return false;
64
- }
65
- };
66
- this.dispatchOnStateChange = (stateObject) => {
67
- const request = {
68
- type: app_host_boundary_1.ON_STATE_CHANGE,
69
- version: 1,
70
- payload: {
71
- stateObject,
72
- },
73
- };
74
- this.dispatch(request);
75
- };
76
- this.dispatchOnStateComplete = () => {
77
- const request = {
78
- type: app_host_boundary_1.ON_STATE_COMPLETED,
79
- version: 1,
80
- };
81
- this.dispatch(request);
82
- };
83
- this.dispatchSubmitResults = (results) => {
84
- const request = {
85
- type: app_host_boundary_1.SUBMIT_RESULTS,
86
- version: 1,
87
- payload: {
88
- results,
89
- },
90
- };
91
- this.dispatch(request);
92
- };
93
- this.dispatchGetAppAssetsURL = () => {
94
- var _a;
95
- const callback = (url) => {
96
- this.appState.appAssetsURL = url;
97
- };
98
- const request = {
99
- type: app_host_boundary_1.GET_APP_ASSET_URL,
100
- version: 1,
101
- payload: {
102
- callback,
103
- },
104
- };
105
- this.dispatch(request);
106
- return (_a = this.appState.appAssetsURL) !== null && _a !== void 0 ? _a : "";
107
- };
108
- this.registerSerializableSystem = (serializedSystem) => {
109
- if (this.systems.has(serializedSystem.name)) {
110
- throw new Errors_1.DuplicateSystemNameError(serializedSystem.name);
111
- }
112
- this.systems.set(serializedSystem.name, serializedSystem);
113
- };
114
- this.getSerializedState = () => {
115
- const systems = Array.from(this.systems.values());
116
- const serializedStates = systems.map((system) => {
117
- const state = system.getSerializedObject();
118
- return {
119
- seriliziationVersion: system.seriliziationVersion,
120
- name: system.name,
121
- state,
122
- };
123
- });
124
- return {
125
- version: this.serilizationVersion,
126
- systems: serializedStates,
127
- };
128
- };
129
- this.setSerializedState = (state, duration) => {
130
- if (state.version === 2) {
131
- state.systems.forEach((systemState) => {
132
- const seriliazableSystem = this.systems.get(systemState.name);
133
- if (seriliazableSystem) {
134
- seriliazableSystem.intializeStateForTransition(systemState.state, systemState.seriliziationVersion);
135
- }
136
- else {
137
- console.warn("Unable to find seriarializedSystem " + systemState.name);
138
- }
139
- });
140
- }
141
- // Here is where we will add support for future versions
142
- else {
143
- throw new Errors_1.UnsupportedVersionNumber(state.version);
144
- }
145
- this.startTransition(duration);
146
- this.logToConsole(`State set to ${JSON.stringify(state)} with a ${duration} second duration`);
147
- };
148
- this.setDefaultState = (duration) => {
149
- this.systems.forEach((system) => {
150
- system.intializeStateForTransition(null, -1);
151
- });
152
- this.startTransition(duration);
153
- this.logToConsole(`State has been set to transition to default over ${duration} seconds`);
154
- };
155
- this.getShowBabylonInspector = () => {
156
- return this.appState.showBabyonInspector;
157
- };
158
- this.setShowBabylonInspector = (showInspector) => {
159
- if (this.appState.showBabyonInspector === showInspector)
160
- return;
161
- this.appState.showBabyonInspector = showInspector;
162
- this.notify();
163
- this.logToConsole(`Show Babylon Inspector set to ${showInspector}`);
164
- };
165
- this.getIsAuthoring = () => {
166
- return this.appState.isAuthoring;
167
- };
168
- this.setIsAuthoring = (isAuthoring) => {
169
- if (isAuthoring === this.appState.isAuthoring)
170
- return;
171
- this.appState.isAuthoring = isAuthoring;
172
- this.notify();
173
- this.logToConsole(`Is Authoring set to ${isAuthoring}`);
174
- };
175
- this.addObserver = (observer) => {
176
- this.observers.push(observer);
177
- };
178
- this.removeObserver = (observer) => {
179
- const index = this.observers.indexOf(observer);
180
- if (index >= 0) {
181
- this.observers.splice(index, 1);
182
- }
183
- };
184
- this.appState = {
185
- isAuthoring: false,
186
- showBabyonInspector: false,
187
- useDevicePreview: false,
188
- x: -1,
189
- y: -1,
190
- isTransitioning: false,
191
- verbose: false,
192
- };
193
- }
194
- setVerbose(verbose) {
195
- this.appState.verbose = verbose;
196
- }
197
- logToConsole(message) {
198
- if (!this.appState.verbose)
199
- return;
200
- console.log("[Base App UC] " + message);
201
- }
202
- startTransition(duration) {
203
- if (duration === 0) {
204
- if (this.currentInterval) {
205
- clearInterval(this.currentInterval);
206
- this.appState.isTransitioning = false;
207
- }
208
- this.applyTransitionToSystems(1);
209
- }
210
- else {
211
- if (this.currentInterval) {
212
- clearInterval(this.currentInterval);
213
- }
214
- this.appState.isTransitioning = true;
215
- const durationInMS = duration * 1000;
216
- let chrono = 0;
217
- const transitionDelta = 10;
218
- this.currentInterval = setInterval(() => {
219
- chrono = chrono + transitionDelta;
220
- let normalizedTime = chrono / durationInMS;
221
- if (normalizedTime > 1) {
222
- normalizedTime = 1;
223
- }
224
- const percent = this.easeFunction(normalizedTime);
225
- this.applyTransitionToSystems(percent);
226
- if (normalizedTime >= 1 && this.currentInterval) {
227
- clearInterval(this.currentInterval);
228
- this.appState.isTransitioning = false;
229
- }
230
- }, transitionDelta);
231
- }
232
- }
233
- applyTransitionToSystems(percent) {
234
- this.systems.forEach((system) => {
235
- system.applyTransition(percent);
236
- });
237
- }
238
- notify() {
239
- this.observers.forEach((observer) => observer.onBaseAppChange());
240
- }
241
- dispatch(request) {
242
- if (!this.appState.handler) {
243
- throw new Errors_1.ErrorNoHostHandler();
244
- }
245
- const handler = this.appState.handler;
246
- handler(request);
247
- this.logToConsole(`Dispatched request: ${JSON.stringify(request)}`);
248
- }
249
- }
250
- exports.BaseAppUCImp = BaseAppUCImp;
@@ -1,14 +0,0 @@
1
- export interface BaseAppStateUC {
2
- getIsAuthoring(): boolean;
3
- setIsAuthoring(isAuthoring: boolean): void;
4
- getShowBabylonInspector(): boolean;
5
- setShowBabylonInspector(showInspector: boolean): void;
6
- getAppContainer(): HTMLElement | undefined;
7
- setAppContainer(container: HTMLElement): void;
8
- clearAppContainer(): void;
9
- addObserver(observer: BaseAppStateObserver): void;
10
- removeObserver(observer: BaseAppStateObserver): void;
11
- }
12
- export interface BaseAppStateObserver {
13
- onAppStateChange: () => void;
14
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export interface BaseAppState {
2
- isAuthoring: boolean;
3
- showBabyonInspector: boolean;
4
- appContainer?: HTMLElement;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +0,0 @@
1
- import { BaseAppStateObserver, BaseAppStateUC } from "./Boundary";
2
- export declare class BaseAppStateUCImp implements BaseAppStateUC {
3
- private appState;
4
- private observers;
5
- constructor();
6
- getAppContainer(): HTMLElement | undefined;
7
- setAppContainer(container: HTMLElement): void;
8
- clearAppContainer(): void;
9
- getShowBabylonInspector(): boolean;
10
- setShowBabylonInspector(showInspector: boolean): void;
11
- getIsAuthoring(): boolean;
12
- setIsAuthoring(isAuthoring: boolean): void;
13
- addObserver(observer: BaseAppStateObserver): void;
14
- removeObserver(observer: BaseAppStateObserver): void;
15
- private notify;
16
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseAppStateUCImp = void 0;
4
- class BaseAppStateUCImp {
5
- constructor() {
6
- this.observers = [];
7
- this.appState = {
8
- isAuthoring: false,
9
- showBabyonInspector: false,
10
- };
11
- }
12
- getAppContainer() {
13
- return this.appState.appContainer;
14
- }
15
- setAppContainer(container) {
16
- this.appState.appContainer = container;
17
- this.notify();
18
- }
19
- clearAppContainer() {
20
- this.appState.appContainer = undefined;
21
- this.notify();
22
- }
23
- getShowBabylonInspector() {
24
- return this.appState.showBabyonInspector;
25
- }
26
- setShowBabylonInspector(showInspector) {
27
- if (this.appState.showBabyonInspector === showInspector)
28
- return;
29
- this.appState.showBabyonInspector = showInspector;
30
- this.notify();
31
- }
32
- getIsAuthoring() {
33
- return this.appState.isAuthoring;
34
- }
35
- setIsAuthoring(isAuthoring) {
36
- if (isAuthoring === this.appState.isAuthoring)
37
- return;
38
- this.appState.isAuthoring = isAuthoring;
39
- this.notify();
40
- }
41
- addObserver(observer) {
42
- this.observers.push(observer);
43
- }
44
- removeObserver(observer) {
45
- const index = this.observers.indexOf(observer);
46
- if (index >= 0) {
47
- this.observers.splice(index, 1);
48
- }
49
- }
50
- notify() {
51
- this.observers.forEach((observer) => observer.onAppStateChange());
52
- }
53
- }
54
- exports.BaseAppStateUCImp = BaseAppStateUCImp;
@@ -1,16 +0,0 @@
1
- import { BaseAppStateObserver, BaseAppStateUC } from "./Boundary";
2
- export declare class BaseAppStateUC_Imp implements BaseAppStateUC {
3
- private appState;
4
- private observers;
5
- constructor();
6
- getAppContainer(): HTMLElement | undefined;
7
- setAppContainer(container: HTMLElement): void;
8
- clearAppContainer(): void;
9
- getShowBabylonInspector(): boolean;
10
- setShowBabylonInspector(showInspector: boolean): void;
11
- getIsAuthoring(): boolean;
12
- setIsAuthoring(isAuthoring: boolean): void;
13
- addObserver(observer: BaseAppStateObserver): void;
14
- removeObserver(observer: BaseAppStateObserver): void;
15
- private notify;
16
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseAppStateUC_Imp = void 0;
4
- class BaseAppStateUC_Imp {
5
- constructor() {
6
- this.observers = [];
7
- this.appState = {
8
- isAuthoring: false,
9
- showBabyonInspector: false,
10
- };
11
- }
12
- getAppContainer() {
13
- return this.appState.appContainer;
14
- }
15
- setAppContainer(container) {
16
- this.appState.appContainer = container;
17
- this.notify();
18
- }
19
- clearAppContainer() {
20
- this.appState.appContainer = undefined;
21
- this.notify();
22
- }
23
- getShowBabylonInspector() {
24
- return this.appState.showBabyonInspector;
25
- }
26
- setShowBabylonInspector(showInspector) {
27
- if (this.appState.showBabyonInspector === showInspector)
28
- return;
29
- this.appState.showBabyonInspector = showInspector;
30
- this.notify();
31
- }
32
- getIsAuthoring() {
33
- return this.appState.isAuthoring;
34
- }
35
- setIsAuthoring(isAuthoring) {
36
- if (isAuthoring === this.appState.isAuthoring)
37
- return;
38
- this.appState.isAuthoring = isAuthoring;
39
- this.notify();
40
- }
41
- addObserver(observer) {
42
- this.observers.push(observer);
43
- }
44
- removeObserver(observer) {
45
- const index = this.observers.indexOf(observer);
46
- if (index >= 0) {
47
- this.observers.splice(index, 1);
48
- }
49
- }
50
- notify() {
51
- this.observers.forEach((observer) => observer.onAppStateChange());
52
- }
53
- }
54
- exports.BaseAppStateUC_Imp = BaseAppStateUC_Imp;
@@ -1,16 +0,0 @@
1
- import { DevicePreviewUC, OnDevicePreviewChange } from "./boundary";
2
- export declare class DevicePreviewUCImp implements DevicePreviewUC {
3
- private observers;
4
- private entity;
5
- constructor();
6
- setDevicePreview(x: number, y: number): void;
7
- clearDevicePreview(): void;
8
- getUseDevicePreview(): boolean;
9
- getDevicePreviewSize(): {
10
- x: number;
11
- y: number;
12
- };
13
- addObserver(observer: OnDevicePreviewChange): void;
14
- removeObserver(observer: OnDevicePreviewChange): void;
15
- private notify;
16
- }