@vived/app 2.26.0 → 2.28.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.
@@ -0,0 +1,6 @@
1
+ export declare type Handler = (request: Request) => void;
2
+ export interface Request {
3
+ type: string;
4
+ version: number;
5
+ payload?: unknown;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ import { Handler, Request } from "./AppBoundary";
2
+ export interface AssetMetaDTO {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ }
7
+ export declare abstract class AppDispatcher {
8
+ abstract registerHostHandler: (hostHandler: Handler) => void;
9
+ abstract dispatch: (request: Request) => void;
10
+ abstract stateHasChanged: (state: object, validationErrorMessage?: string) => void;
11
+ abstract stateIsCompleted: () => void;
12
+ abstract getAppAssetsURL: () => Promise<string>;
13
+ abstract registerExternalStylesheets: (stylesheets: string[]) => void;
14
+ abstract appIsReady: () => void;
15
+ abstract log: (sender: string, message: string) => void;
16
+ abstract logWarnign: (sender: string, message: string) => void;
17
+ abstract logError: (sender: string, message: string) => void;
18
+ abstract logFatalError: (sender: string, message: string) => void;
19
+ abstract submitHitResult: (success: boolean, description: string) => void;
20
+ abstract submitMultiHitResult: (hits: number, misses: number, unanswered: number, description: string) => void;
21
+ abstract submitQualityResult: (stars: number, maxStars: number, description: string) => void;
22
+ abstract submitScoreResult: (score: number, maxScore: number, description: string) => void;
23
+ abstract getAssetBlob: (assetID: string) => Promise<string>;
24
+ abstract getAssetMeta: (assetID: string) => Promise<AssetMetaDTO>;
25
+ abstract getAssetsForOwner: (ownerID: string) => Promise<AssetMetaDTO[]>;
26
+ }
27
+ export declare function makeAppDispatcher(): AppDispatcher;
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeAppDispatcher = exports.AppDispatcher = void 0;
4
+ class AppDispatcher {
5
+ }
6
+ exports.AppDispatcher = AppDispatcher;
7
+ function makeAppDispatcher() {
8
+ return new AppDistpatcherImp();
9
+ }
10
+ exports.makeAppDispatcher = makeAppDispatcher;
11
+ class AppDistpatcherImp extends AppDispatcher {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.registerHostHandler = (hostHandler) => {
15
+ this.hostHandler = hostHandler;
16
+ };
17
+ this.dispatch = (request) => {
18
+ if (!this.hostHandler) {
19
+ console.error("[AppDispatcher] No host handler has been registered");
20
+ return;
21
+ }
22
+ this.hostHandler(request);
23
+ };
24
+ this.stateHasChanged = (stateObject, validationErrorMessage) => {
25
+ const payload = {
26
+ stateObject,
27
+ validationErrorMessage,
28
+ };
29
+ this.formRequestAndDispatch("ON_STATE_CHANGE", 2, payload);
30
+ };
31
+ this.stateIsCompleted = () => {
32
+ this.formRequestAndDispatch("ON_STATE_COMPLETED", 1);
33
+ };
34
+ this.getAppAssetsURL = () => {
35
+ return new Promise((resolve, reject) => {
36
+ const callback = (url) => {
37
+ if (!url) {
38
+ reject(new Error("URL to asset folder is empty"));
39
+ }
40
+ else {
41
+ resolve(url);
42
+ }
43
+ };
44
+ const payload = {
45
+ callback,
46
+ };
47
+ if (!this.hostHandler) {
48
+ reject(new Error("No host handler has been registered"));
49
+ }
50
+ else {
51
+ this.formRequestAndDispatch("GET_APP_ASSET_URL", 1, payload);
52
+ }
53
+ });
54
+ };
55
+ this.registerExternalStylesheets = (stylesheets) => {
56
+ const payload = {
57
+ stylesheets,
58
+ };
59
+ this.formRequestAndDispatch("REGISTER_EXTERNAL_STYLESHEETS", 1, payload);
60
+ };
61
+ this.appIsReady = () => {
62
+ this.formRequestAndDispatch("APP_IS_READY", 1);
63
+ };
64
+ this.submitLog = (sender, message) => {
65
+ const payload = {
66
+ sender,
67
+ severity: "LOG",
68
+ message,
69
+ };
70
+ this.formRequestAndDispatch("SUBMIT_LOG", 1, payload);
71
+ };
72
+ this.log = (sender, message) => {
73
+ const payload = {
74
+ sender,
75
+ severity: "LOG",
76
+ message,
77
+ };
78
+ this.formRequestAndDispatch("SUBMIT_LOG", 1, payload);
79
+ };
80
+ this.logWarnign = (sender, message) => {
81
+ const payload = {
82
+ sender,
83
+ severity: "WARNING",
84
+ message,
85
+ };
86
+ this.formRequestAndDispatch("SUBMIT_LOG", 1, payload);
87
+ };
88
+ this.logError = (sender, message) => {
89
+ const payload = {
90
+ sender,
91
+ severity: "ERROR",
92
+ message,
93
+ };
94
+ this.formRequestAndDispatch("SUBMIT_LOG", 1, payload);
95
+ };
96
+ this.logFatalError = (sender, message) => {
97
+ const payload = {
98
+ sender,
99
+ severity: "FATAL",
100
+ message,
101
+ };
102
+ this.formRequestAndDispatch("SUBMIT_LOG", 1, payload);
103
+ };
104
+ this.submitHitResult = (success, description) => {
105
+ const payload = {
106
+ resultType: "HIT_V1",
107
+ description,
108
+ result: {
109
+ success,
110
+ },
111
+ };
112
+ this.formRequestAndDispatch("SUBMIT_RESULTS", 3, payload);
113
+ };
114
+ this.submitMultiHitResult = (hits, misses, unanswered, description) => {
115
+ const payload = {
116
+ resultType: "MULTIHIT_V1",
117
+ description,
118
+ result: {
119
+ hits,
120
+ misses,
121
+ unanswered,
122
+ },
123
+ };
124
+ this.formRequestAndDispatch("SUBMIT_RESULTS", 3, payload);
125
+ };
126
+ this.submitQualityResult = (stars, maxStars, description) => {
127
+ const payload = {
128
+ resultType: "QUALITY_V1",
129
+ description,
130
+ result: {
131
+ stars,
132
+ maxStars,
133
+ },
134
+ };
135
+ this.formRequestAndDispatch("SUBMIT_RESULTS", 3, payload);
136
+ };
137
+ this.submitScoreResult = (score, maxScore, description) => {
138
+ const payload = {
139
+ resultType: "SCORE_V1",
140
+ description,
141
+ result: {
142
+ score,
143
+ maxScore,
144
+ },
145
+ };
146
+ this.formRequestAndDispatch("SUBMIT_RESULTS", 3, payload);
147
+ };
148
+ this.getAssetBlob = (assetID) => {
149
+ return new Promise((resolve, reject) => {
150
+ const callback = (blobURL) => {
151
+ if (blobURL === undefined) {
152
+ reject(new Error("Blob URL is undefined"));
153
+ }
154
+ else {
155
+ resolve(blobURL);
156
+ }
157
+ };
158
+ const payload = {
159
+ assetID,
160
+ callback,
161
+ };
162
+ if (!this.hostHandler) {
163
+ reject(new Error("No host handler has been registered"));
164
+ }
165
+ else {
166
+ this.formRequestAndDispatch("GET_ASSET_BLOB", 1, payload);
167
+ }
168
+ });
169
+ };
170
+ this.getAssetMeta = (assetID) => {
171
+ return new Promise((resolve, reject) => {
172
+ const callback = (assetMeta) => {
173
+ if (assetMeta === undefined) {
174
+ reject(new Error("Meta is undefined"));
175
+ }
176
+ else {
177
+ resolve(assetMeta);
178
+ }
179
+ };
180
+ const payload = {
181
+ assetID,
182
+ callback,
183
+ };
184
+ if (!this.hostHandler) {
185
+ reject(new Error("No host handler has been registered"));
186
+ }
187
+ else {
188
+ this.formRequestAndDispatch("GET_ASSET_META", 1, payload);
189
+ }
190
+ });
191
+ };
192
+ this.getAssetsForOwner = (ownerID) => {
193
+ return new Promise((resolve, reject) => {
194
+ const callback = (assetMetas) => {
195
+ resolve(assetMetas);
196
+ };
197
+ const payload = {
198
+ ownerID,
199
+ callback,
200
+ };
201
+ if (!this.hostHandler) {
202
+ reject(new Error("No host handler has been registered"));
203
+ }
204
+ else {
205
+ this.formRequestAndDispatch("GET_ASSET_FOR_OWNER", 1, payload);
206
+ }
207
+ });
208
+ };
209
+ }
210
+ formRequestAndDispatch(type, version, payload) {
211
+ const request = {
212
+ type,
213
+ version,
214
+ payload,
215
+ };
216
+ this.dispatch(request);
217
+ }
218
+ }
@@ -0,0 +1,20 @@
1
+ import { Handler } from "./AppBoundary";
2
+ export declare abstract class RequestHandler {
3
+ abstract readonly requestType: string;
4
+ abstract payloadVersion: number;
5
+ abstract handleRequest: (version: number, payload?: unknown) => void;
6
+ }
7
+ export declare abstract class AppHandler {
8
+ abstract handler: Handler;
9
+ abstract registerRequestHandler: (requestHandler: RequestHandler) => void;
10
+ }
11
+ export declare function makeAppHandler(): AppHandler;
12
+ export declare class UnsupportedRequestVerion extends Error {
13
+ constructor(requestType: string, version: number);
14
+ }
15
+ export declare class ActionNotImplemented extends Error {
16
+ constructor(requestType: string);
17
+ }
18
+ export declare class UnableToParsePayload extends Error {
19
+ constructor(requestType: string, version: number, payload: string);
20
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnableToParsePayload = exports.ActionNotImplemented = exports.UnsupportedRequestVerion = exports.makeAppHandler = exports.AppHandler = exports.RequestHandler = void 0;
4
+ class RequestHandler {
5
+ }
6
+ exports.RequestHandler = RequestHandler;
7
+ class AppHandler {
8
+ }
9
+ exports.AppHandler = AppHandler;
10
+ function makeAppHandler() {
11
+ return new RequestHandlerImp();
12
+ }
13
+ exports.makeAppHandler = makeAppHandler;
14
+ class RequestHandlerImp extends AppHandler {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.handlers = new Map();
18
+ this.getAppPayloadRequest = "GET_APP_PAYLOAD_VERSION";
19
+ this.getAppHandlerVersionRequest = "GET_APP_HANDLER_VERSION";
20
+ this.appHandlerVersion = 1;
21
+ this.handler = (request) => {
22
+ if (request.type === this.getAppPayloadRequest) {
23
+ this.handlePayloadVersionRequest(request);
24
+ return;
25
+ }
26
+ if (request.type === this.getAppHandlerVersionRequest) {
27
+ this.handleAppHandlerVersionRequest(request);
28
+ return;
29
+ }
30
+ const handler = this.handlers.get(request.type);
31
+ if (!handler) {
32
+ console.warn(`[AppHandler] Unsupported request type recieved: ${request.type}`);
33
+ return;
34
+ }
35
+ try {
36
+ handler.handleRequest(request.version, request.payload);
37
+ }
38
+ catch (e) {
39
+ console.warn(`[AppHandler] ${e}`);
40
+ }
41
+ };
42
+ this.registerRequestHandler = (handler) => {
43
+ if (this.handlers.has(handler.requestType)) {
44
+ console.warn(`[AppHandler] More than one handler is being registered for ${handler.requestType}. Previous handler is being overwritten`);
45
+ }
46
+ this.handlers.set(handler.requestType, handler);
47
+ };
48
+ }
49
+ handlePayloadVersionRequest(request) {
50
+ if (request.version !== 2) {
51
+ throw new UnsupportedRequestVerion(request.type, request.version);
52
+ }
53
+ const payload = request.payload;
54
+ if (payload.callback === undefined) {
55
+ throw new UnableToParsePayload(request.type, request.version, JSON.stringify(payload));
56
+ }
57
+ const versionMap = new Map();
58
+ this.handlers.forEach((handler) => {
59
+ versionMap.set(handler.requestType, handler.payloadVersion);
60
+ });
61
+ payload.callback(versionMap);
62
+ }
63
+ handleAppHandlerVersionRequest(request) {
64
+ if (request.version !== 1) {
65
+ throw new UnsupportedRequestVerion(request.type, request.version);
66
+ }
67
+ const payload = request.payload;
68
+ if (payload.callback === undefined) {
69
+ throw new UnableToParsePayload(request.type, request.version, JSON.stringify(payload));
70
+ }
71
+ payload.callback(this.appHandlerVersion);
72
+ }
73
+ }
74
+ class UnsupportedRequestVerion extends Error {
75
+ constructor(requestType, version) {
76
+ const msg = `Version ${version} of request type ${requestType} is not supported`;
77
+ super(msg);
78
+ }
79
+ }
80
+ exports.UnsupportedRequestVerion = UnsupportedRequestVerion;
81
+ class ActionNotImplemented extends Error {
82
+ constructor(requestType) {
83
+ const msg = `Action for request type ${requestType} is not implemented`;
84
+ super(msg);
85
+ }
86
+ }
87
+ exports.ActionNotImplemented = ActionNotImplemented;
88
+ class UnableToParsePayload extends Error {
89
+ constructor(requestType, version, payload) {
90
+ const msg = `Unable to parse paylod for version ${version} of request type ${requestType}: ${payload}`;
91
+ super(msg);
92
+ }
93
+ }
94
+ exports.UnableToParsePayload = UnableToParsePayload;
@@ -1,3 +1,6 @@
1
+ export * from "./AppBoundary";
2
+ export * from "./AppDispatcher";
3
+ export * from "./AppHandler";
1
4
  export * from "./Babylon";
2
5
  export * from "./BaseApp";
3
6
  export * from "./DevicePreview";
@@ -10,7 +13,6 @@ export * from "./MemoizedVector2";
10
13
  export * from "./MemoizedVector3";
11
14
  export * from "./MessageSystem";
12
15
  export * from "./ObserverList";
13
- export * from "./FocusCamera";
14
16
  export * from "./StateMachine";
15
17
  export * from "./Tool";
16
18
  export * from "./ToolRepository";
@@ -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("./AppBoundary"), exports);
14
+ __exportStar(require("./AppDispatcher"), exports);
15
+ __exportStar(require("./AppHandler"), exports);
13
16
  __exportStar(require("./Babylon"), exports);
14
17
  __exportStar(require("./BaseApp"), exports);
15
18
  __exportStar(require("./DevicePreview"), exports);
@@ -22,7 +25,6 @@ __exportStar(require("./MemoizedVector2"), exports);
22
25
  __exportStar(require("./MemoizedVector3"), exports);
23
26
  __exportStar(require("./MessageSystem"), exports);
24
27
  __exportStar(require("./ObserverList"), exports);
25
- __exportStar(require("./FocusCamera"), exports);
26
28
  __exportStar(require("./StateMachine"), exports);
27
29
  __exportStar(require("./Tool"), exports);
28
30
  __exportStar(require("./ToolRepository"), exports);
@@ -4,9 +4,7 @@ export * from "./PresentationManager";
4
4
  export * from "./ShowBabylonInspectorPM";
5
5
  export * from "./HasRedoPM";
6
6
  export * from "./HasUndoPM";
7
- export * from "./FocusCameraPM";
8
7
  export * from "./QuestionChallenge";
9
- export * from "./FocusCameraPosRotPM";
10
8
  export * from "./ToolPM";
11
9
  export * from "./TransformNodePM";
12
10
  export * from "./HoverLabels";
@@ -16,9 +16,7 @@ __exportStar(require("./PresentationManager"), exports);
16
16
  __exportStar(require("./ShowBabylonInspectorPM"), exports);
17
17
  __exportStar(require("./HasRedoPM"), exports);
18
18
  __exportStar(require("./HasUndoPM"), exports);
19
- __exportStar(require("./FocusCameraPM"), exports);
20
19
  __exportStar(require("./QuestionChallenge"), exports);
21
- __exportStar(require("./FocusCameraPosRotPM"), exports);
22
20
  __exportStar(require("./ToolPM"), exports);
23
21
  __exportStar(require("./TransformNodePM"), exports);
24
22
  __exportStar(require("./HoverLabels"), exports);
@@ -0,0 +1,8 @@
1
+ import { AppHandler, RequestHandler } from "../../Entities";
2
+ export declare class DisposeAppBase extends RequestHandler {
3
+ readonly requestType = "DISPOSE_APP";
4
+ readonly payloadVersion = 1;
5
+ action: () => void;
6
+ handleRequest: (version: number) => void;
7
+ constructor(handler: AppHandler);
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DisposeAppBase = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class DisposeAppBase extends Entities_1.RequestHandler {
6
+ constructor(handler) {
7
+ super();
8
+ this.requestType = "DISPOSE_APP";
9
+ this.payloadVersion = 1;
10
+ this.action = () => {
11
+ throw new Entities_1.ActionNotImplemented(this.requestType);
12
+ };
13
+ this.handleRequest = (version) => {
14
+ if (version === this.payloadVersion) {
15
+ this.action();
16
+ }
17
+ else {
18
+ throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
19
+ }
20
+ };
21
+ handler.registerRequestHandler(this);
22
+ }
23
+ }
24
+ exports.DisposeAppBase = DisposeAppBase;
@@ -0,0 +1,10 @@
1
+ import { AppHandler, RequestHandler } from "../../Entities";
2
+ export declare type SetAppStateAction = (finalState: string, duration?: number) => void;
3
+ export declare class SetAppStateBase extends RequestHandler {
4
+ readonly requestType = "SET_APP_STATE";
5
+ readonly payloadVersion = 2;
6
+ action: SetAppStateAction;
7
+ handleRequest: (version: number, payload: unknown) => void;
8
+ private castPayload;
9
+ constructor(handler: AppHandler);
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetAppStateBase = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class SetAppStateBase extends Entities_1.RequestHandler {
6
+ constructor(handler) {
7
+ super();
8
+ this.requestType = "SET_APP_STATE";
9
+ this.payloadVersion = 2;
10
+ this.action = (finalState, duration) => {
11
+ throw new Entities_1.ActionNotImplemented(this.requestType);
12
+ };
13
+ this.handleRequest = (version, payload) => {
14
+ if (version === this.payloadVersion) {
15
+ const { finalState, duration } = this.castPayload(payload);
16
+ this.action(finalState, duration);
17
+ }
18
+ else {
19
+ throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
20
+ }
21
+ };
22
+ handler.registerRequestHandler(this);
23
+ }
24
+ castPayload(payload) {
25
+ const castPayload = payload;
26
+ if (castPayload.finalState === undefined) {
27
+ throw new Entities_1.UnableToParsePayload(this.requestType, 1, JSON.stringify(payload));
28
+ }
29
+ return castPayload;
30
+ }
31
+ }
32
+ exports.SetAppStateBase = SetAppStateBase;
@@ -0,0 +1,10 @@
1
+ import { AppHandler, RequestHandler } from "../../Entities";
2
+ export declare type SetDevicePreviewAction = (px: number, py: number) => void;
3
+ export declare class SetDevicePreviewBase extends RequestHandler {
4
+ readonly requestType = "SET_DEVICE_PREVIEW";
5
+ readonly payloadVersion = 1;
6
+ action: SetDevicePreviewAction;
7
+ handleRequest: (version: number, payload: unknown) => void;
8
+ private castPayloadV1;
9
+ constructor(handler: AppHandler);
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetDevicePreviewBase = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class SetDevicePreviewBase extends Entities_1.RequestHandler {
6
+ constructor(handler) {
7
+ super();
8
+ this.requestType = "SET_DEVICE_PREVIEW";
9
+ this.payloadVersion = 1;
10
+ this.action = (px, py) => {
11
+ throw new Entities_1.ActionNotImplemented(this.requestType);
12
+ };
13
+ this.handleRequest = (version, payload) => {
14
+ if (version === this.payloadVersion) {
15
+ const { x, y } = this.castPayloadV1(payload);
16
+ this.action(x, y);
17
+ }
18
+ else {
19
+ throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
20
+ }
21
+ };
22
+ handler.registerRequestHandler(this);
23
+ }
24
+ castPayloadV1(payload) {
25
+ const castPayload = payload;
26
+ if (castPayload.x === undefined || castPayload.y === undefined) {
27
+ throw new Entities_1.UnableToParsePayload(this.requestType, 1, JSON.stringify(payload));
28
+ }
29
+ return castPayload;
30
+ }
31
+ }
32
+ exports.SetDevicePreviewBase = SetDevicePreviewBase;
@@ -0,0 +1,10 @@
1
+ import { AppHandler, RequestHandler } from "../../Entities";
2
+ export declare type SetIsAuthoringAction = (isAuthoring: boolean) => void;
3
+ export declare class SetIsAuthoringBase extends RequestHandler {
4
+ readonly requestType = "SET_IS_AUTHORING";
5
+ readonly payloadVersion = 1;
6
+ action: SetIsAuthoringAction;
7
+ handleRequest: (version: number, payload: unknown) => void;
8
+ private castPayloadV1;
9
+ constructor(handler: AppHandler);
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetIsAuthoringBase = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class SetIsAuthoringBase extends Entities_1.RequestHandler {
6
+ constructor(handler) {
7
+ super();
8
+ this.requestType = "SET_IS_AUTHORING";
9
+ this.payloadVersion = 1;
10
+ this.action = (show) => {
11
+ throw new Entities_1.ActionNotImplemented(this.requestType);
12
+ };
13
+ this.handleRequest = (version, payload) => {
14
+ if (version === this.payloadVersion) {
15
+ const { isAuthoring: setIsAuthoring } = this.castPayloadV1(payload);
16
+ this.action(setIsAuthoring);
17
+ }
18
+ else {
19
+ throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
20
+ }
21
+ };
22
+ handler.registerRequestHandler(this);
23
+ }
24
+ castPayloadV1(payload) {
25
+ const castPayload = payload;
26
+ if (castPayload.isAuthoring === undefined) {
27
+ throw new Entities_1.UnableToParsePayload(this.requestType, 1, JSON.stringify(payload));
28
+ }
29
+ return castPayload;
30
+ }
31
+ }
32
+ exports.SetIsAuthoringBase = SetIsAuthoringBase;
@@ -0,0 +1,10 @@
1
+ import { AppHandler, RequestHandler } from "../../Entities";
2
+ export declare type ShowBabylonInspectorAction = (show: boolean) => void;
3
+ export declare class ShowBabylonInspectorBase extends RequestHandler {
4
+ readonly requestType = "SHOW_BABYLON_INSPECTOR";
5
+ readonly payloadVersion = 1;
6
+ action: ShowBabylonInspectorAction;
7
+ handleRequest: (version: number, payload: unknown) => void;
8
+ private castPayloadV1;
9
+ constructor(handler: AppHandler);
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShowBabylonInspectorBase = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class ShowBabylonInspectorBase extends Entities_1.RequestHandler {
6
+ constructor(handler) {
7
+ super();
8
+ this.requestType = "SHOW_BABYLON_INSPECTOR";
9
+ this.payloadVersion = 1;
10
+ this.action = (show) => {
11
+ throw new Entities_1.ActionNotImplemented(this.requestType);
12
+ };
13
+ this.handleRequest = (version, payload) => {
14
+ if (version === this.payloadVersion) {
15
+ const { showBabylonInspector } = this.castPayloadV1(payload);
16
+ this.action(showBabylonInspector);
17
+ }
18
+ else {
19
+ throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
20
+ }
21
+ };
22
+ handler.registerRequestHandler(this);
23
+ }
24
+ castPayloadV1(payload) {
25
+ const castPayload = payload;
26
+ if (castPayload.showBabylonInspector === undefined) {
27
+ throw new Entities_1.UnableToParsePayload(this.requestType, 1, JSON.stringify(payload));
28
+ }
29
+ return castPayload;
30
+ }
31
+ }
32
+ exports.ShowBabylonInspectorBase = ShowBabylonInspectorBase;
@@ -0,0 +1,10 @@
1
+ import { AppHandler, RequestHandler } from "../../Entities";
2
+ export declare type StartAppAction = (container: HTMLElement) => void;
3
+ export declare class StartAppBase extends RequestHandler {
4
+ readonly requestType = "START_APP";
5
+ readonly payloadVersion = 2;
6
+ action: StartAppAction;
7
+ handleRequest: (version: number, payload: unknown) => void;
8
+ private castPayloadV2;
9
+ constructor(handler: AppHandler);
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StartAppBase = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class StartAppBase extends Entities_1.RequestHandler {
6
+ constructor(handler) {
7
+ super();
8
+ this.requestType = "START_APP";
9
+ this.payloadVersion = 2;
10
+ this.action = (container) => {
11
+ throw new Entities_1.ActionNotImplemented(this.requestType);
12
+ };
13
+ this.handleRequest = (version, payload) => {
14
+ if (version === this.payloadVersion) {
15
+ const { container } = this.castPayloadV2(payload);
16
+ this.action(container);
17
+ }
18
+ else {
19
+ throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
20
+ }
21
+ };
22
+ handler.registerRequestHandler(this);
23
+ }
24
+ castPayloadV2(payload) {
25
+ const castPayload = payload;
26
+ if (castPayload.container === undefined) {
27
+ throw new Entities_1.UnableToParsePayload(this.requestType, 1, JSON.stringify(payload));
28
+ }
29
+ return castPayload;
30
+ }
31
+ }
32
+ exports.StartAppBase = StartAppBase;
@@ -0,0 +1,8 @@
1
+ import { AppHandler, RequestHandler } from "../../Entities";
2
+ export declare class StopAppBase extends RequestHandler {
3
+ readonly requestType = "STOP_APP";
4
+ readonly payloadVersion = 1;
5
+ action: () => void;
6
+ handleRequest: (version: number) => void;
7
+ constructor(handler: AppHandler);
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StopAppBase = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class StopAppBase extends Entities_1.RequestHandler {
6
+ constructor(handler) {
7
+ super();
8
+ this.requestType = "STOP_APP";
9
+ this.payloadVersion = 1;
10
+ this.action = () => {
11
+ throw new Entities_1.ActionNotImplemented(this.requestType);
12
+ };
13
+ this.handleRequest = (version) => {
14
+ if (version === this.payloadVersion) {
15
+ this.action();
16
+ }
17
+ else {
18
+ throw new Entities_1.UnsupportedRequestVerion(this.requestType, version);
19
+ }
20
+ };
21
+ handler.registerRequestHandler(this);
22
+ }
23
+ }
24
+ exports.StopAppBase = StopAppBase;
@@ -0,0 +1,7 @@
1
+ export * from "./DisposeAppBase";
2
+ export * from "./SetAppStateBase";
3
+ export * from "./SetDevicePreviewBase";
4
+ export * from "./SetIsAuthoringBase";
5
+ export * from "./ShowBabylonInspectorBase";
6
+ export * from "./StartAppBase";
7
+ export * from "./StopAppBase";
@@ -0,0 +1,19 @@
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("./DisposeAppBase"), exports);
14
+ __exportStar(require("./SetAppStateBase"), exports);
15
+ __exportStar(require("./SetDevicePreviewBase"), exports);
16
+ __exportStar(require("./SetIsAuthoringBase"), exports);
17
+ __exportStar(require("./ShowBabylonInspectorBase"), exports);
18
+ __exportStar(require("./StartAppBase"), exports);
19
+ __exportStar(require("./StopAppBase"), exports);
@@ -1,5 +1,5 @@
1
1
  export * from "./setDevicePreview";
2
- export * from "./FocusCamera";
2
+ export * from "./Handlers";
3
3
  export * from "./QuestionChallenge";
4
4
  export * from "./LerpVector3";
5
5
  export * from "./SceneRoot";
@@ -11,7 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./setDevicePreview"), exports);
14
- __exportStar(require("./FocusCamera"), exports);
14
+ __exportStar(require("./Handlers"), exports);
15
15
  __exportStar(require("./QuestionChallenge"), exports);
16
16
  __exportStar(require("./LerpVector3"), exports);
17
17
  __exportStar(require("./SceneRoot"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "2.26.0",
3
+ "version": "2.28.0",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",