@vived/host 3.0.0 → 3.2.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 (169) hide show
  1. package/lib/Components/Apps/Adapters/activeAppPMAdapter.d.ts +3 -0
  2. package/lib/Components/Apps/Adapters/activeAppPMAdapter.js +23 -0
  3. package/lib/Components/Apps/Adapters/appListPMAdapter.d.ts +2 -0
  4. package/lib/Components/Apps/Adapters/appListPMAdapter.js +23 -0
  5. package/lib/Components/Apps/Adapters/appPMAdapter.d.ts +3 -0
  6. package/lib/Components/Apps/Adapters/appPMAdapter.js +23 -0
  7. package/lib/Components/Apps/Adapters/index.d.ts +3 -0
  8. package/lib/Components/Apps/Adapters/index.js +15 -0
  9. package/lib/Components/Apps/Controllers/index.d.ts +1 -0
  10. package/lib/Components/Apps/Controllers/index.js +13 -0
  11. package/lib/Components/Apps/Controllers/updateApp.d.ts +2 -0
  12. package/lib/Components/Apps/Controllers/updateApp.js +13 -0
  13. package/lib/Components/Apps/Entities/AppEntity.d.ts +28 -0
  14. package/lib/Components/Apps/Entities/AppEntity.js +93 -0
  15. package/lib/Components/Apps/Entities/AppRepo.d.ts +19 -0
  16. package/lib/Components/Apps/Entities/AppRepo.js +57 -0
  17. package/lib/Components/Apps/Entities/index.d.ts +2 -0
  18. package/lib/Components/Apps/Entities/index.js +14 -0
  19. package/lib/Components/Apps/Mocks/MockActiveAppPM.d.ts +8 -0
  20. package/lib/Components/Apps/Mocks/MockActiveAppPM.js +15 -0
  21. package/lib/Components/Apps/Mocks/MockAppListPM.d.ts +8 -0
  22. package/lib/Components/Apps/Mocks/MockAppListPM.js +15 -0
  23. package/lib/Components/Apps/Mocks/MockAppMounterUC.d.ts +10 -0
  24. package/lib/Components/Apps/Mocks/MockAppMounterUC.js +14 -0
  25. package/lib/Components/Apps/Mocks/MockAppPM.d.ts +7 -0
  26. package/lib/Components/Apps/Mocks/MockAppPM.js +11 -0
  27. package/lib/Components/Apps/Mocks/MockStartAppUC.d.ts +7 -0
  28. package/lib/Components/Apps/Mocks/MockStartAppUC.js +11 -0
  29. package/lib/Components/Apps/Mocks/MockStopAppUC.d.ts +7 -0
  30. package/lib/Components/Apps/Mocks/MockStopAppUC.js +11 -0
  31. package/lib/Components/Apps/Mocks/MockUpdateAppUC.d.ts +7 -0
  32. package/lib/Components/Apps/Mocks/MockUpdateAppUC.js +11 -0
  33. package/lib/Components/Apps/Mocks/index.d.ts +7 -0
  34. package/lib/Components/Apps/Mocks/index.js +19 -0
  35. package/lib/Components/Apps/PMs/ActiveAppPM.d.ts +10 -0
  36. package/lib/Components/Apps/PMs/ActiveAppPM.js +15 -0
  37. package/lib/Components/Apps/PMs/AppPM.d.ts +13 -0
  38. package/lib/Components/Apps/PMs/AppPM.js +57 -0
  39. package/lib/Components/Apps/PMs/AppsListPM.d.ts +6 -0
  40. package/lib/Components/Apps/PMs/AppsListPM.js +51 -0
  41. package/lib/Components/Apps/PMs/index.d.ts +3 -0
  42. package/lib/Components/Apps/PMs/index.js +15 -0
  43. package/lib/Components/Apps/UCs/MounterUC.d.ts +12 -0
  44. package/lib/Components/Apps/UCs/MounterUC.js +15 -0
  45. package/lib/Components/Apps/UCs/StartAppUC.d.ts +8 -0
  46. package/lib/Components/Apps/UCs/StartAppUC.js +27 -0
  47. package/lib/Components/Apps/UCs/StopAppUC.d.ts +8 -0
  48. package/lib/Components/Apps/UCs/StopAppUC.js +27 -0
  49. package/lib/Components/Apps/UCs/UpdateAppUC.d.ts +7 -0
  50. package/lib/Components/Apps/UCs/UpdateAppUC.js +23 -0
  51. package/lib/Components/Apps/UCs/appIDWithVersion.d.ts +3 -0
  52. package/lib/Components/Apps/UCs/appIDWithVersion.js +8 -0
  53. package/lib/Components/Apps/UCs/index.d.ts +5 -0
  54. package/lib/Components/Apps/UCs/index.js +17 -0
  55. package/lib/Components/Apps/index.d.ts +6 -0
  56. package/lib/Components/Apps/index.js +18 -0
  57. package/lib/Components/AssetPlugin/Adapters/assetPluginPMAdapter.d.ts +3 -0
  58. package/lib/Components/AssetPlugin/Adapters/assetPluginPMAdapter.js +23 -0
  59. package/lib/Components/AssetPlugin/Adapters/index.d.ts +1 -0
  60. package/lib/Components/AssetPlugin/Adapters/index.js +13 -0
  61. package/lib/Components/AssetPlugin/Controllers/clearAssetPluginContainer.d.ts +2 -0
  62. package/lib/Components/AssetPlugin/Controllers/clearAssetPluginContainer.js +14 -0
  63. package/lib/Components/AssetPlugin/Controllers/index.d.ts +2 -0
  64. package/lib/Components/AssetPlugin/Controllers/index.js +14 -0
  65. package/lib/Components/AssetPlugin/Controllers/setAssetPluginContainer.d.ts +2 -0
  66. package/lib/Components/AssetPlugin/Controllers/setAssetPluginContainer.js +14 -0
  67. package/lib/Components/AssetPlugin/Entities/AssetPluginEntity.d.ts +14 -0
  68. package/lib/Components/AssetPlugin/Entities/AssetPluginEntity.js +40 -0
  69. package/lib/Components/AssetPlugin/Entities/index.d.ts +1 -0
  70. package/lib/Components/AssetPlugin/Entities/index.js +13 -0
  71. package/lib/Components/AssetPlugin/Mocks/MockAssetPluginContainerUC.d.ts +9 -0
  72. package/lib/Components/AssetPlugin/Mocks/MockAssetPluginContainerUC.js +16 -0
  73. package/lib/Components/AssetPlugin/Mocks/MockAssetPluginPM.d.ts +8 -0
  74. package/lib/Components/AssetPlugin/Mocks/MockAssetPluginPM.js +15 -0
  75. package/lib/Components/AssetPlugin/Mocks/index.d.ts +2 -0
  76. package/lib/Components/AssetPlugin/Mocks/index.js +14 -0
  77. package/lib/Components/AssetPlugin/PM/AssetPluginPM.d.ts +12 -0
  78. package/lib/Components/AssetPlugin/PM/AssetPluginPM.js +68 -0
  79. package/lib/Components/AssetPlugin/PM/index.d.ts +1 -0
  80. package/lib/Components/AssetPlugin/PM/index.js +13 -0
  81. package/lib/Components/AssetPlugin/UCs/AssetPluginContainerUC.d.ts +7 -0
  82. package/lib/Components/AssetPlugin/UCs/AssetPluginContainerUC.js +11 -0
  83. package/lib/Components/AssetPlugin/UCs/index.d.ts +1 -0
  84. package/lib/Components/AssetPlugin/UCs/index.js +13 -0
  85. package/lib/Components/AssetPlugin/index.d.ts +6 -0
  86. package/lib/Components/AssetPlugin/index.js +18 -0
  87. package/lib/Components/Assets/Entities/AssetEntity.d.ts +1 -1
  88. package/lib/Components/Assets/Entities/AssetEntity.js +11 -9
  89. package/lib/Components/Assets/Mocks/MockPrefetchAssets.d.ts +8 -0
  90. package/lib/Components/Assets/Mocks/MockPrefetchAssets.js +15 -0
  91. package/lib/Components/Assets/Mocks/index.d.ts +1 -0
  92. package/lib/Components/Assets/Mocks/index.js +1 -0
  93. package/lib/Components/Assets/UCs/PrefetchAssetsUC.d.ts +7 -0
  94. package/lib/Components/Assets/UCs/PrefetchAssetsUC.js +69 -0
  95. package/lib/Components/Assets/UCs/index.d.ts +9 -8
  96. package/lib/Components/Assets/UCs/index.js +1 -0
  97. package/lib/Components/Dispatcher/Entities/HostDispatchEntity.js +7 -2
  98. package/lib/Components/Dispatcher/UCs/DispatchStartBrowseChannelsUC.d.ts +1 -1
  99. package/lib/Components/Dispatcher/UCs/DispatchStartBrowseChannelsUC.js +1 -1
  100. package/lib/Components/Handler/UCs/GetAssetFolderURLHandler.js +12 -2
  101. package/lib/Components/Handler/UCs/HasNextStateHandler.js +15 -2
  102. package/lib/Components/Handler/UCs/HasPreviousStateHandler.js +15 -2
  103. package/lib/Components/Handler/UCs/OnAppIsReadyHandler.js +9 -1
  104. package/lib/Components/Handler/UCs/OnStateChangeHandler.d.ts +3 -1
  105. package/lib/Components/Handler/UCs/OnStateChangeHandler.js +39 -2
  106. package/lib/Components/Handler/UCs/RegisterExternalStyleSheetsHandler.js +11 -1
  107. package/lib/Components/StateMachine/Adapters/hostStateMachinePMAdapter.d.ts +3 -0
  108. package/lib/Components/StateMachine/Adapters/hostStateMachinePMAdapter.js +23 -0
  109. package/lib/Components/StateMachine/Adapters/hostStateMachinePMAdater.d.ts +3 -0
  110. package/lib/Components/StateMachine/Adapters/hostStateMachinePMAdater.js +23 -0
  111. package/lib/Components/StateMachine/Adapters/index.d.ts +1 -0
  112. package/lib/Components/StateMachine/Adapters/index.js +13 -0
  113. package/lib/Components/StateMachine/Adapters/isEditingPMAdapter.d.ts +3 -0
  114. package/lib/Components/StateMachine/Adapters/isEditingPMAdapter.js +23 -0
  115. package/lib/Components/StateMachine/Controllers/deleteState.d.ts +2 -0
  116. package/lib/Components/StateMachine/Controllers/deleteState.js +13 -0
  117. package/lib/Components/StateMachine/Controllers/duplicateState.d.ts +2 -0
  118. package/lib/Components/StateMachine/Controllers/duplicateState.js +13 -0
  119. package/lib/Components/StateMachine/Controllers/index.d.ts +2 -0
  120. package/lib/Components/StateMachine/Controllers/index.js +14 -0
  121. package/lib/Components/StateMachine/Entities/HostEditingStateEntity.d.ts +16 -0
  122. package/lib/Components/StateMachine/Entities/HostEditingStateEntity.js +121 -0
  123. package/lib/Components/StateMachine/Entities/HostStateEntity.d.ts +31 -0
  124. package/lib/Components/StateMachine/Entities/HostStateEntity.js +124 -0
  125. package/lib/Components/StateMachine/Entities/HostStateMachine.d.ts +20 -0
  126. package/lib/Components/StateMachine/Entities/HostStateMachine.js +161 -0
  127. package/lib/Components/StateMachine/Entities/index.d.ts +3 -0
  128. package/lib/Components/StateMachine/Entities/index.js +15 -0
  129. package/lib/Components/StateMachine/Mocks/MockDeleteStateUC.d.ts +8 -0
  130. package/lib/Components/StateMachine/Mocks/MockDeleteStateUC.js +15 -0
  131. package/lib/Components/StateMachine/Mocks/MockDuplicateStateUC.d.ts +8 -0
  132. package/lib/Components/StateMachine/Mocks/MockDuplicateStateUC.js +15 -0
  133. package/lib/Components/StateMachine/Mocks/MockHostEditingStateEntity.d.ts +16 -0
  134. package/lib/Components/StateMachine/Mocks/MockHostEditingStateEntity.js +30 -0
  135. package/lib/Components/StateMachine/Mocks/MockHostStateMachinePM.d.ts +8 -0
  136. package/lib/Components/StateMachine/Mocks/MockHostStateMachinePM.js +15 -0
  137. package/lib/Components/StateMachine/Mocks/MockIsEditingStatePM.d.ts +8 -0
  138. package/lib/Components/StateMachine/Mocks/MockIsEditingStatePM.js +15 -0
  139. package/lib/Components/StateMachine/Mocks/MockStateEntity.d.ts +16 -0
  140. package/lib/Components/StateMachine/Mocks/MockStateEntity.js +27 -0
  141. package/lib/Components/StateMachine/Mocks/index.d.ts +6 -0
  142. package/lib/Components/StateMachine/Mocks/index.js +18 -0
  143. package/lib/Components/StateMachine/PMs/EditingStatePM.d.ts +19 -0
  144. package/lib/Components/StateMachine/PMs/EditingStatePM.js +54 -0
  145. package/lib/Components/StateMachine/PMs/HostStateMachinePM.d.ts +23 -0
  146. package/lib/Components/StateMachine/PMs/HostStateMachinePM.js +70 -0
  147. package/lib/Components/StateMachine/PMs/IsEditingStatePM.d.ts +13 -0
  148. package/lib/Components/StateMachine/PMs/IsEditingStatePM.js +36 -0
  149. package/lib/Components/StateMachine/PMs/index.d.ts +2 -0
  150. package/lib/Components/StateMachine/PMs/index.js +14 -0
  151. package/lib/Components/StateMachine/UCs/DeleteStateUC.d.ts +7 -0
  152. package/lib/Components/StateMachine/UCs/DeleteStateUC.js +37 -0
  153. package/lib/Components/StateMachine/UCs/DuplicateStateUC.d.ts +7 -0
  154. package/lib/Components/StateMachine/UCs/DuplicateStateUC.js +39 -0
  155. package/lib/Components/StateMachine/UCs/index.d.ts +2 -0
  156. package/lib/Components/StateMachine/UCs/index.js +14 -0
  157. package/lib/Components/StateMachine/index.d.ts +6 -0
  158. package/lib/Components/StateMachine/index.js +18 -0
  159. package/lib/Components/index.d.ts +3 -0
  160. package/lib/Components/index.js +3 -0
  161. package/lib/Types/PmAdapter.d.ts +6 -0
  162. package/lib/Types/PmAdapter.js +2 -0
  163. package/lib/Types/ReactHookPmAdapter.d.ts +6 -0
  164. package/lib/Types/ReactHookPmAdapter.js +2 -0
  165. package/lib/Types/SingletonPmAdapter.d.ts +6 -0
  166. package/lib/Types/SingletonPmAdapter.js +2 -0
  167. package/lib/Types/index.d.ts +3 -1
  168. package/lib/Types/index.js +2 -0
  169. package/package.json +1 -1
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeRegisterExternalStyleSheetsHandler = exports.RegisterExternalStyleSheetsHandler = void 0;
4
4
  const HostAppObject_1 = require("../../../HostAppObject");
5
+ const Apps_1 = require("../../Apps");
5
6
  const Entities_1 = require("../Entities");
6
7
  class RegisterExternalStyleSheetsHandler extends HostAppObject_1.HostAppObjectUC {
7
8
  constructor() {
@@ -20,7 +21,13 @@ class RegisterExternalStyleSheetsHandlerImp extends RegisterExternalStyleSheetsH
20
21
  super(appObject, RegisterExternalStyleSheetsHandler.type);
21
22
  this.requestType = "REGISTER_EXTERNAL_STYLESHEETS";
22
23
  this.action = (stylesheets) => {
23
- this.log(`Style sheets: ${stylesheets}`);
24
+ if (!this.app)
25
+ return;
26
+ stylesheets.forEach((sheet) => {
27
+ var _a;
28
+ (_a = this.app) === null || _a === void 0 ? void 0 : _a.styles.push(sheet);
29
+ });
30
+ this.app.notifyOnChange();
24
31
  };
25
32
  this.handleRequest = (version, payload) => {
26
33
  if (version === 1) {
@@ -38,6 +45,9 @@ class RegisterExternalStyleSheetsHandlerImp extends RegisterExternalStyleSheetsH
38
45
  }
39
46
  hostHandler.registerRequestHandler(this);
40
47
  }
48
+ get app() {
49
+ return this.getCachedLocalComponent(Apps_1.AppEntity.type);
50
+ }
41
51
  castPayloadV1(payload) {
42
52
  const castPayload = payload;
43
53
  if (castPayload.stylesheets === undefined) {
@@ -0,0 +1,3 @@
1
+ import { SingletonPmAdapter } from "../../../Types/SingletonPmAdapter";
2
+ import { HostStateMachineVM } from "../PMs";
3
+ export declare const hostStateMachinePMAdapter: SingletonPmAdapter<HostStateMachineVM>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hostStateMachinePMAdapter = void 0;
4
+ const PMs_1 = require("../PMs");
5
+ exports.hostStateMachinePMAdapter = {
6
+ defaultVM: PMs_1.defaultHostStateMachineVM,
7
+ subscribe: (appObjects, setVM) => {
8
+ const pm = PMs_1.HostStateMachinePM.get(appObjects);
9
+ if (!pm) {
10
+ appObjects.submitError("hostStateMachinePMAdapter", "Unable to find HostStateMachinePM");
11
+ return;
12
+ }
13
+ pm.addView(setVM);
14
+ },
15
+ unsubscribe: (appObjects, setVM) => {
16
+ const pm = PMs_1.HostStateMachinePM.get(appObjects);
17
+ if (!pm) {
18
+ appObjects.submitError("hostStateMachinePMAdapter", "Unable to find HostStateMachinePM");
19
+ return;
20
+ }
21
+ pm.removeView(setVM);
22
+ }
23
+ };
@@ -0,0 +1,3 @@
1
+ import { ReactHookPmAdapter } from "../../../Types/ReactHookPmAdapter";
2
+ import { HostStateMachineVM } from "../PMs";
3
+ export declare const hostStateMachinePMAdapter: ReactHookPmAdapter<HostStateMachineVM>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hostStateMachinePMAdapter = void 0;
4
+ const PMs_1 = require("../PMs");
5
+ exports.hostStateMachinePMAdapter = {
6
+ defaultVM: PMs_1.defaultHostStateMachineVM,
7
+ subscribe: (appObjects, setVM) => {
8
+ const pm = PMs_1.HostStateMachinePM.get(appObjects);
9
+ if (!pm) {
10
+ appObjects.submitError("hostStateMachinePMAdater", "Unable to find HostStateMachinePM");
11
+ return;
12
+ }
13
+ pm.addView(setVM);
14
+ },
15
+ unsubscribe: (appObjects, setVM) => {
16
+ const pm = PMs_1.HostStateMachinePM.get(appObjects);
17
+ if (!pm) {
18
+ appObjects.submitError("hostStateMachinePMAdater", "Unable to find HostStateMachinePM");
19
+ return;
20
+ }
21
+ pm.removeView(setVM);
22
+ }
23
+ };
@@ -0,0 +1 @@
1
+ export * from "./hostStateMachinePMAdapter";
@@ -0,0 +1,13 @@
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("./hostStateMachinePMAdapter"), exports);
@@ -0,0 +1,3 @@
1
+ import { ReactHookPmAdapter } from "../../../Types/ReactHookPmAdapter";
2
+ import { EditingStateVM } from "../PMs";
3
+ export declare const isEditingPMAdapter: ReactHookPmAdapter<EditingStateVM>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEditingPMAdapter = void 0;
4
+ const PMs_1 = require("../PMs");
5
+ exports.isEditingPMAdapter = {
6
+ defaultVM: PMs_1.defaultIsEditingStateVM,
7
+ subscribe: (appObjects, setVM) => {
8
+ const pm = PMs_1.EditingStatePM.get(appObjects);
9
+ if (!pm) {
10
+ appObjects.submitError("isEditingPMAdapter", "Unable to find HostStateMachinePM");
11
+ return;
12
+ }
13
+ pm.addView(setVM);
14
+ },
15
+ unsubscribe: (appObjects, setVM) => {
16
+ const pm = PMs_1.EditingStatePM.get(appObjects);
17
+ if (!pm) {
18
+ appObjects.submitError("isEditingPMAdapter", "Unable to find HostStateMachinePM");
19
+ return;
20
+ }
21
+ pm.removeView(setVM);
22
+ }
23
+ };
@@ -0,0 +1,2 @@
1
+ import { HostAppObjectRepo } from "../../../HostAppObject";
2
+ export declare function deleteState(id: string, appObjects: HostAppObjectRepo): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteState = void 0;
4
+ const UCs_1 = require("../UCs");
5
+ function deleteState(id, appObjects) {
6
+ const uc = UCs_1.DeleteStateUC.get(appObjects);
7
+ if (!uc) {
8
+ appObjects.submitWarning("duplicateState", "Unable to find DeleteStateUC");
9
+ return;
10
+ }
11
+ uc.deleteState(id);
12
+ }
13
+ exports.deleteState = deleteState;
@@ -0,0 +1,2 @@
1
+ import { HostAppObjectRepo } from "../../../HostAppObject";
2
+ export declare function duplicateState(id: string, appObjects: HostAppObjectRepo): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.duplicateState = void 0;
4
+ const UCs_1 = require("../UCs");
5
+ function duplicateState(id, appObjects) {
6
+ const uc = UCs_1.DuplicateStateUC.get(appObjects);
7
+ if (!uc) {
8
+ appObjects.submitWarning("duplicateState", "Unable to find DuplicateStateUC");
9
+ return;
10
+ }
11
+ uc.duplicateState(id);
12
+ }
13
+ exports.duplicateState = duplicateState;
@@ -0,0 +1,2 @@
1
+ export * from "./deleteState";
2
+ export * from "./duplicateState";
@@ -0,0 +1,14 @@
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("./deleteState"), exports);
14
+ __exportStar(require("./duplicateState"), exports);
@@ -0,0 +1,16 @@
1
+ import { HostAppObject, HostAppObjectEntity, HostAppObjectRepo } from "../../../HostAppObject";
2
+ import { HostStateEntity } from "./HostStateEntity";
3
+ export declare abstract class HostEditingStateEntity extends HostAppObjectEntity {
4
+ static type: string;
5
+ abstract get isEditing(): boolean;
6
+ abstract get isNewState(): boolean;
7
+ abstract get editingState(): HostStateEntity | undefined;
8
+ abstract get somethingHasChanged(): boolean;
9
+ abstract stateValidationMessage?: string;
10
+ abstract startNewState(): HostStateEntity | undefined;
11
+ abstract startEditing(state: HostStateEntity): void;
12
+ abstract cancelEditState(): void;
13
+ abstract finishEditing(): void;
14
+ static get(appObjects: HostAppObjectRepo): HostEditingStateEntity | undefined;
15
+ }
16
+ export declare function makeHostEditingStateEntity(appObject: HostAppObject): HostEditingStateEntity;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeHostEditingStateEntity = exports.HostEditingStateEntity = void 0;
4
+ const Entities_1 = require("../../../Entities");
5
+ const HostAppObject_1 = require("../../../HostAppObject");
6
+ const HostStateMachine_1 = require("./HostStateMachine");
7
+ class HostEditingStateEntity extends HostAppObject_1.HostAppObjectEntity {
8
+ static get(appObjects) {
9
+ return HostAppObject_1.getSingletonComponent(HostEditingStateEntity.type, appObjects);
10
+ }
11
+ }
12
+ exports.HostEditingStateEntity = HostEditingStateEntity;
13
+ HostEditingStateEntity.type = "HostEditingStateEntity";
14
+ function makeHostEditingStateEntity(appObject) {
15
+ return new HostEditingStateEntityImp(appObject);
16
+ }
17
+ exports.makeHostEditingStateEntity = makeHostEditingStateEntity;
18
+ class HostEditingStateEntityImp extends HostEditingStateEntity {
19
+ constructor(appObject) {
20
+ super(appObject, HostEditingStateEntity.type);
21
+ this._isNewState = false;
22
+ this.memoizedSomethingHasChanged = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
23
+ this.checkForChange = () => {
24
+ var _a, _b;
25
+ if (!this._editingState)
26
+ return false;
27
+ if (!this.originalStateData)
28
+ return true;
29
+ if (this._editingState.name !== this.originalStateData.name)
30
+ return true;
31
+ if (this._editingState.expectedResponse !== this.originalStateData.response)
32
+ return true;
33
+ if (this._editingState.assets.length !== this.originalStateData.assets.length)
34
+ return true;
35
+ let assetsHaveChanged = false;
36
+ this._editingState.assets.forEach((currentAssetID, i) => {
37
+ const originalAssetId = this.originalStateData.assets[i];
38
+ if (originalAssetId !== currentAssetID) {
39
+ assetsHaveChanged = true;
40
+ }
41
+ });
42
+ if (assetsHaveChanged) {
43
+ return true;
44
+ }
45
+ const currentDataString = JSON.stringify(this._editingState.stateData);
46
+ const originalData = JSON.stringify((_b = (_a = this.originalStateData) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : "");
47
+ if (currentDataString !== originalData)
48
+ return true;
49
+ return false;
50
+ };
51
+ this.onStateEntityChange = () => {
52
+ this.memoizedSomethingHasChanged.val = this.checkForChange();
53
+ };
54
+ this.startNewState = () => {
55
+ if (!this.hostStateMachine)
56
+ return;
57
+ this.originalStateData = undefined;
58
+ this._isNewState = true;
59
+ this._editingState = this.hostStateMachine.createNewState();
60
+ this._editingState.addChangeObserver(this.onStateEntityChange);
61
+ this.memoizedSomethingHasChanged.val = true;
62
+ return this._editingState;
63
+ };
64
+ this.startEditing = (state) => {
65
+ this._editingState = state;
66
+ this.originalStateData = state.getDTO();
67
+ this._editingState.addChangeObserver(this.onStateEntityChange);
68
+ this.notifyOnChange();
69
+ };
70
+ this.cancelEditState = () => {
71
+ var _a;
72
+ if (!this._editingState)
73
+ return;
74
+ if (this.originalStateData) {
75
+ this._editingState.setDTO(this.originalStateData);
76
+ }
77
+ else {
78
+ (_a = this.hostStateMachine) === null || _a === void 0 ? void 0 : _a.deleteState(this._editingState.id);
79
+ }
80
+ this.resetInternalState();
81
+ };
82
+ this.finishEditing = () => {
83
+ this.resetInternalState();
84
+ };
85
+ this.resetInternalState = () => {
86
+ if (!this._editingState)
87
+ return;
88
+ this._isNewState = false;
89
+ this._editingState.removeChangeObserver(this.onStateEntityChange);
90
+ this._stateValidationMessage = undefined;
91
+ this._editingState = undefined;
92
+ this.memoizedSomethingHasChanged.val = false;
93
+ this.notifyOnChange();
94
+ };
95
+ this.appObjects.registerSingleton(this);
96
+ }
97
+ get isNewState() {
98
+ return this._isNewState;
99
+ }
100
+ get stateValidationMessage() {
101
+ return this._stateValidationMessage;
102
+ }
103
+ set stateValidationMessage(val) {
104
+ if (this._stateValidationMessage === val)
105
+ return;
106
+ this._stateValidationMessage = val;
107
+ this.notifyOnChange();
108
+ }
109
+ get hostStateMachine() {
110
+ return this.getCachedSingleton(HostStateMachine_1.HostStateMachine.type);
111
+ }
112
+ get somethingHasChanged() {
113
+ return this.memoizedSomethingHasChanged.val;
114
+ }
115
+ get isEditing() {
116
+ return this._editingState !== undefined;
117
+ }
118
+ get editingState() {
119
+ return this._editingState;
120
+ }
121
+ }
@@ -0,0 +1,31 @@
1
+ import { HostAppObject, HostAppObjectEntity, HostAppObjectRepo } from "../../../HostAppObject";
2
+ export declare enum ChallengeResponse {
3
+ NONE = "NONE",
4
+ SCORE = "SCORE",
5
+ HIT = "HIT",
6
+ MULTIHIT = "MULTIHIT",
7
+ PROGRESS = "PROGRESS",
8
+ QUALITY = "QUALITY"
9
+ }
10
+ export interface StateDTO {
11
+ id: string;
12
+ name: string;
13
+ data: object;
14
+ assets: string[];
15
+ response: string | undefined;
16
+ appID: string;
17
+ }
18
+ export declare abstract class HostStateEntity extends HostAppObjectEntity {
19
+ static type: string;
20
+ abstract get id(): string;
21
+ abstract name: string;
22
+ abstract assets: string[];
23
+ abstract expectedResponse: ChallengeResponse | undefined;
24
+ abstract appID: string;
25
+ abstract getDTO(): StateDTO;
26
+ abstract setDTO(dto: StateDTO): void;
27
+ abstract get stateData(): object;
28
+ abstract setStateData(val: object, checkForChange?: boolean): void;
29
+ static get(id: string, appObjects: HostAppObjectRepo): HostStateEntity | undefined;
30
+ }
31
+ export declare function makeHostStateEntity(appObject: HostAppObject): HostStateEntity;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeHostStateEntity = exports.HostStateEntity = exports.ChallengeResponse = void 0;
4
+ const Entities_1 = require("../../../Entities");
5
+ const HostAppObject_1 = require("../../../HostAppObject");
6
+ var ChallengeResponse;
7
+ (function (ChallengeResponse) {
8
+ ChallengeResponse["NONE"] = "NONE";
9
+ ChallengeResponse["SCORE"] = "SCORE";
10
+ ChallengeResponse["HIT"] = "HIT";
11
+ ChallengeResponse["MULTIHIT"] = "MULTIHIT";
12
+ ChallengeResponse["PROGRESS"] = "PROGRESS";
13
+ ChallengeResponse["QUALITY"] = "QUALITY";
14
+ })(ChallengeResponse = exports.ChallengeResponse || (exports.ChallengeResponse = {}));
15
+ class HostStateEntity extends HostAppObject_1.HostAppObjectEntity {
16
+ static get(id, appObjects) {
17
+ const ao = appObjects.get(id);
18
+ return ao === null || ao === void 0 ? void 0 : ao.getComponent(HostStateEntity.type);
19
+ }
20
+ }
21
+ exports.HostStateEntity = HostStateEntity;
22
+ HostStateEntity.type = "HostStateEntity";
23
+ function makeHostStateEntity(appObject) {
24
+ return new HostStateEntityImp(appObject);
25
+ }
26
+ exports.makeHostStateEntity = makeHostStateEntity;
27
+ class HostStateEntityImp extends HostStateEntity {
28
+ constructor(appObject) {
29
+ super(appObject, HostStateEntity.type);
30
+ this.memoizedName = new Entities_1.MemoizedString("", this.notifyOnChange);
31
+ this._data = {};
32
+ this._assets = [];
33
+ this.memoisedAppID = new Entities_1.MemoizedString("", this.notifyOnChange);
34
+ }
35
+ get id() {
36
+ return this.appObject.id;
37
+ }
38
+ get name() {
39
+ return this.memoizedName.val;
40
+ }
41
+ set name(val) {
42
+ this.memoizedName.val = val;
43
+ }
44
+ get stateData() {
45
+ return this._data;
46
+ }
47
+ setStateData(val, checkForChange) {
48
+ let notify = true;
49
+ if (checkForChange) {
50
+ const currentData = JSON.stringify(this._data);
51
+ const newData = JSON.stringify(val);
52
+ if (currentData === newData) {
53
+ notify = false;
54
+ }
55
+ }
56
+ this._data = val;
57
+ if (notify) {
58
+ this.notifyOnChange();
59
+ }
60
+ }
61
+ get assets() {
62
+ return [...this._assets];
63
+ }
64
+ set assets(val) {
65
+ if (val.length !== this._assets.length) {
66
+ this._assets = val;
67
+ this.notifyOnChange();
68
+ return;
69
+ }
70
+ let somethingHasChanged = false;
71
+ val.forEach((newAsset, i) => {
72
+ const existingAsset = this._assets[i];
73
+ if (existingAsset !== newAsset) {
74
+ somethingHasChanged = true;
75
+ }
76
+ });
77
+ if (!somethingHasChanged) {
78
+ return;
79
+ }
80
+ this._assets = val;
81
+ this.notifyOnChange();
82
+ }
83
+ get expectedResponse() {
84
+ return this._expectedResponse;
85
+ }
86
+ set expectedResponse(val) {
87
+ if (val === this._expectedResponse)
88
+ return;
89
+ this._expectedResponse = val;
90
+ this.notifyOnChange();
91
+ }
92
+ getDTO() {
93
+ return {
94
+ id: this.id,
95
+ assets: [...this._assets],
96
+ data: this._data,
97
+ name: this.memoizedName.val,
98
+ response: this._expectedResponse,
99
+ appID: this.appID
100
+ };
101
+ }
102
+ setDTO(dto) {
103
+ if (dto.id !== this.id) {
104
+ this.warn("DTO id does not match my ID. Skipping");
105
+ return;
106
+ }
107
+ this.setStateData(dto.data, true);
108
+ this.assets = [...dto.assets];
109
+ this.memoizedName.val = dto.name;
110
+ this.memoisedAppID.val = dto.appID;
111
+ if (Object.values(ChallengeResponse).includes(dto.response)) {
112
+ this.expectedResponse = dto.response;
113
+ }
114
+ else {
115
+ this.expectedResponse = undefined;
116
+ }
117
+ }
118
+ get appID() {
119
+ return this.memoisedAppID.val;
120
+ }
121
+ set appID(val) {
122
+ this.memoisedAppID.val = val;
123
+ }
124
+ }
@@ -0,0 +1,20 @@
1
+ import { HostAppObject, HostAppObjectEntity, HostAppObjectRepo } from "../../../HostAppObject";
2
+ import { HostStateEntity } from "./HostStateEntity";
3
+ export declare abstract class HostStateMachine extends HostAppObjectEntity {
4
+ static type: string;
5
+ abstract states: string[];
6
+ abstract activeState: string | undefined;
7
+ abstract previousState: string | undefined;
8
+ abstract nextState: string | undefined;
9
+ abstract setActiveStateByID: (id: string) => void;
10
+ abstract clearActiveState: () => void;
11
+ abstract setStates: (states: HostStateEntity[]) => void;
12
+ abstract createNewState: () => HostStateEntity;
13
+ abstract getStateByID: (id: string) => HostStateEntity | undefined;
14
+ abstract deleteState: (id: string) => void;
15
+ abstract getStateIndex: (id: string) => number | undefined;
16
+ abstract hasState: (id: string) => boolean;
17
+ abstract stateFactory: (id: string) => HostStateEntity;
18
+ static get(appObjects: HostAppObjectRepo): HostStateMachine | undefined;
19
+ }
20
+ export declare function makeHostStateMachine(appObject: HostAppObject): HostStateMachine;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeHostStateMachine = exports.HostStateMachine = void 0;
4
+ const Entities_1 = require("../../../Entities");
5
+ const HostAppObject_1 = require("../../../HostAppObject");
6
+ const Utilities_1 = require("../../../Utilities");
7
+ const HostStateEntity_1 = require("./HostStateEntity");
8
+ class HostStateMachine extends HostAppObject_1.HostAppObjectEntity {
9
+ static get(appObjects) {
10
+ return HostAppObject_1.getSingletonComponent(HostStateMachine.type, appObjects);
11
+ }
12
+ }
13
+ exports.HostStateMachine = HostStateMachine;
14
+ HostStateMachine.type = "HostStateMachine";
15
+ function makeHostStateMachine(appObject) {
16
+ return new HostStateMachineImp(appObject);
17
+ }
18
+ exports.makeHostStateMachine = makeHostStateMachine;
19
+ class HostStateMachineImp extends HostStateMachine {
20
+ constructor(appObject) {
21
+ super(appObject, HostStateMachine.type);
22
+ this._states = [];
23
+ this.memoizedIsAuthoring = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
24
+ this._lastAssets = [];
25
+ this.hasState = (id) => {
26
+ const state = this.findStateByID(id);
27
+ if (state) {
28
+ return true;
29
+ }
30
+ else {
31
+ return false;
32
+ }
33
+ };
34
+ this.setActiveStateByID = (id) => {
35
+ const state = this.findStateByID(id);
36
+ if (!state)
37
+ return;
38
+ if (state.id === this._activeState)
39
+ return;
40
+ this._activeState = state.id;
41
+ const index = this.getStateIndex(id);
42
+ if (index === undefined) {
43
+ this._nextState = undefined;
44
+ this._previousState = undefined;
45
+ return;
46
+ }
47
+ const prevIndex = index - 1;
48
+ const nextIndex = index + 1;
49
+ if (prevIndex >= 0) {
50
+ this._previousState = this._states[prevIndex].id;
51
+ }
52
+ else {
53
+ this._previousState = undefined;
54
+ }
55
+ if (nextIndex < this._states.length) {
56
+ this._nextState = this._states[nextIndex].id;
57
+ }
58
+ else {
59
+ this._nextState = undefined;
60
+ }
61
+ this.notifyOnChange();
62
+ };
63
+ this.clearActiveState = () => {
64
+ if (!this.activeState)
65
+ return;
66
+ this._nextState = undefined;
67
+ this._previousState = undefined;
68
+ this._activeState = undefined;
69
+ this.notifyOnChange();
70
+ };
71
+ this.setStates = (states) => {
72
+ this._states = states;
73
+ this.notifyOnChange();
74
+ };
75
+ this.stateFactory = (id) => {
76
+ const ao = this.appObjects.getOrCreate(id);
77
+ return HostStateEntity_1.makeHostStateEntity(ao);
78
+ };
79
+ this.createNewState = () => {
80
+ const newState = this.stateFactory(Utilities_1.generateUniqueID());
81
+ this._states.push(newState);
82
+ this.notifyOnChange();
83
+ return newState;
84
+ };
85
+ this.getStateByID = (id) => {
86
+ return this.findStateByID(id);
87
+ };
88
+ this.deleteState = (id) => {
89
+ const index = this.getStateIndex(id);
90
+ if (index === undefined) {
91
+ return;
92
+ }
93
+ const state = this.getStateByID(id);
94
+ state === null || state === void 0 ? void 0 : state.appObject.dispose();
95
+ this._states.splice(index, 1);
96
+ this.notifyOnChange();
97
+ };
98
+ this.getStateIndex = (id) => {
99
+ let index = -1;
100
+ this._states.forEach((state, i) => {
101
+ if (state.id === id) {
102
+ index = i;
103
+ }
104
+ });
105
+ if (index >= 0) {
106
+ return index;
107
+ }
108
+ else {
109
+ return undefined;
110
+ }
111
+ };
112
+ this.appObjects.registerSingleton(this);
113
+ }
114
+ get states() {
115
+ return this._states.map((state) => state.id);
116
+ }
117
+ get activeState() {
118
+ return this._activeState;
119
+ }
120
+ get previousState() {
121
+ return this._previousState;
122
+ }
123
+ get nextState() {
124
+ return this._nextState;
125
+ }
126
+ get isAuthoring() {
127
+ return this.memoizedIsAuthoring.val;
128
+ }
129
+ set isAuthoring(val) {
130
+ this.memoizedIsAuthoring.val = val;
131
+ }
132
+ get lastEditingState() {
133
+ return this._lastEditingState;
134
+ }
135
+ set lastEditingState(val) {
136
+ if (this._lastEditingState === undefined && val === undefined)
137
+ return;
138
+ const lastStateStr = this.lastEditingState === undefined
139
+ ? ""
140
+ : JSON.stringify(this.lastEditingState);
141
+ const valStateStr = val === undefined ? "" : JSON.stringify(val);
142
+ if (lastStateStr === valStateStr)
143
+ return;
144
+ this._lastEditingState = val;
145
+ this.notifyOnChange();
146
+ }
147
+ get lastAssets() {
148
+ return this._lastAssets;
149
+ }
150
+ set lastAssets(lastAssets) {
151
+ this._lastAssets = lastAssets;
152
+ }
153
+ findStateByID(id) {
154
+ for (const state of this._states) {
155
+ if (state.id === id) {
156
+ return state;
157
+ }
158
+ }
159
+ return undefined;
160
+ }
161
+ }