@vived/app 2.18.1 → 2.19.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.
- package/lib/Core/BaseApp/Boundary.d.ts +49 -0
- package/lib/Core/BaseApp/Boundary.js +2 -0
- package/lib/Core/BaseApp/Entity.d.ts +11 -0
- package/lib/Core/BaseApp/Entity.js +2 -0
- package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.js +12 -0
- package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.js +10 -0
- package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.js +10 -0
- package/lib/Core/BaseApp/Errors/index.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/index.js +15 -0
- package/lib/Core/BaseApp/UseCase.d.ts +43 -0
- package/lib/Core/BaseApp/UseCase.js +250 -0
- package/lib/Core/BaseAppState/Boundary.d.ts +14 -0
- package/lib/Core/BaseAppState/Boundary.js +2 -0
- package/lib/Core/BaseAppState/Entity.d.ts +5 -0
- package/lib/Core/BaseAppState/Entity.js +2 -0
- package/lib/Core/BaseAppState/UseCase.d.ts +16 -0
- package/lib/Core/BaseAppState/UseCase.js +54 -0
- package/lib/Core/BaseAppState/UseCase_Imp.d.ts +16 -0
- package/lib/Core/BaseAppState/UseCase_Imp.js +54 -0
- package/lib/Core/DevicePreview/DevicePreviewUC_Imp.d.ts +16 -0
- package/lib/Core/DevicePreview/DevicePreviewUC_Imp.js +56 -0
- package/lib/Core/DevicePreview/boundary.d.ts +14 -0
- package/lib/Core/DevicePreview/boundary.js +2 -0
- package/lib/Core/DevicePreview/entity.d.ts +5 -0
- package/lib/Core/DevicePreview/entity.js +2 -0
- package/lib/Core/DispatchToHost/Entity.d.ts +4 -0
- package/lib/Core/DispatchToHost/Entity.js +2 -0
- package/lib/Core/DispatchToHost/UseCase.d.ts +12 -0
- package/lib/Core/DispatchToHost/UseCase.js +70 -0
- package/lib/Core/DispatchToHost/boundary.d.ts +9 -0
- package/lib/Core/DispatchToHost/boundary.js +2 -0
- package/lib/Core/Serilization/Boundary.d.ts +20 -0
- package/lib/Core/Serilization/Boundary.js +2 -0
- package/lib/Core/Serilization/Entity.d.ts +3 -0
- package/lib/Core/Serilization/Entity.js +2 -0
- package/lib/Core/Serilization/ErrorDuplicateSystemName.d.ts +3 -0
- package/lib/Core/Serilization/ErrorDuplicateSystemName.js +12 -0
- package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.d.ts +3 -0
- package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.js +10 -0
- package/lib/Core/Serilization/Errors.d.ts +6 -0
- package/lib/Core/Serilization/Errors.js +19 -0
- package/lib/Core/Serilization/UseCase.d.ts +10 -0
- package/lib/Core/Serilization/UseCase.js +52 -0
- package/lib/Core/Serilization/UseCase_Imp.d.ts +10 -0
- package/lib/Core/Serilization/UseCase_Imp.js +51 -0
- package/lib/Core/index.d.ts +3 -0
- package/lib/Core/index.js +19 -0
- package/lib/Entities/Babylon.js +5 -0
- package/lib/Entities/Color.d.ts +20 -0
- package/lib/Entities/Color.js +59 -0
- package/lib/Entities/FocusCamera.js +1 -1
- package/lib/Entities/LineSegment2D.d.ts +11 -0
- package/lib/Entities/LineSegment2D.js +70 -0
- package/lib/Entities/MouseSceneInput.d.ts +15 -0
- package/lib/Entities/MouseSceneInput.js +109 -0
- package/lib/Entities/OrbitCamera.d.ts +76 -0
- package/lib/Entities/OrbitCamera.js +243 -0
- package/lib/Entities/ParametricLine.d.ts +29 -0
- package/lib/Entities/ParametricLine.js +79 -0
- package/lib/Entities/ParametricPlane.d.ts +20 -0
- package/lib/Entities/ParametricPlane.js +63 -0
- package/lib/Entities/StateMachine.d.ts +3 -0
- package/lib/Entities/StateMachine.js +10 -0
- package/lib/Entities/Vector2.d.ts +21 -0
- package/lib/Entities/Vector2.js +83 -0
- package/lib/Entities/Vector3.d.ts +19 -0
- package/lib/Entities/Vector3.js +75 -0
- package/lib/Interface/Controllers/appHandler.d.ts +12 -0
- package/lib/Interface/Controllers/appHandler.js +94 -0
- package/lib/Interface/Controllers/defaultAppHanlderFunctions.d.ts +3 -0
- package/lib/Interface/Controllers/defaultAppHanlderFunctions.js +31 -0
- package/lib/Interface/Controllers/dispatchStateChange.d.ts +2 -0
- package/lib/Interface/Controllers/dispatchStateChange.js +10 -0
- package/lib/Interface/Controllers/index.d.ts +9 -0
- package/lib/Interface/Controllers/index.js +21 -0
- package/lib/Interface/Controllers/makeAppHandler.d.ts +12 -0
- package/lib/Interface/Controllers/makeAppHandler.js +96 -0
- package/lib/Interface/Controllers/setDevicePreview.d.ts +2 -0
- package/lib/Interface/Controllers/setDevicePreview.js +14 -0
- package/lib/Interface/Controllers/setIsAuthoring.d.ts +2 -0
- package/lib/Interface/Controllers/setIsAuthoring.js +14 -0
- package/lib/Interface/Controllers/setState.d.ts +2 -0
- package/lib/Interface/Controllers/setState.js +21 -0
- package/lib/Interface/Controllers/showBabylonInspector.d.ts +2 -0
- package/lib/Interface/Controllers/showBabylonInspector.js +9 -0
- package/lib/Interface/Controllers/startApp.d.ts +1 -0
- package/lib/Interface/Controllers/startApp.js +9 -0
- package/lib/Interface/Controllers/stopApp.d.ts +2 -0
- package/lib/Interface/Controllers/stopApp.js +10 -0
- package/lib/Interface/PresentationManagers/DevicePreviewPM.d.ts +13 -0
- package/lib/Interface/PresentationManagers/DevicePreviewPM.js +25 -0
- package/lib/Interface/PresentationManagers/IsAuthoringPM.d.ts +10 -0
- package/lib/Interface/PresentationManagers/IsAuthoringPM.js +23 -0
- package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.d.ts +10 -0
- package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.js +23 -0
- package/lib/Interface/PresentationManagers/index.d.ts +3 -0
- package/lib/Interface/PresentationManagers/index.js +15 -0
- package/lib/Interface/appHandler.d.ts +12 -0
- package/lib/Interface/appHandler.js +94 -0
- package/lib/Interface/index.d.ts +2 -0
- package/lib/Interface/index.js +14 -0
- package/lib/PresentationManagers/OrbitCameraPM.d.ts +14 -0
- package/lib/PresentationManagers/OrbitCameraPM.js +31 -0
- package/lib/UseCases/LerpOrbitCamera.d.ts +36 -0
- package/lib/UseCases/LerpOrbitCamera.js +71 -0
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +36 -0
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +71 -0
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +9 -0
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +31 -0
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +10 -0
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +31 -0
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +22 -0
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +81 -0
- package/lib/UseCases/OrbitCamera/index.d.ts +4 -0
- package/lib/UseCases/OrbitCamera/index.js +16 -0
- package/lib/UseCases/SerializeCamera.d.ts +21 -0
- package/lib/UseCases/SerializeCamera.js +59 -0
- package/lib/UseCases/SerializeOrbitCamera.d.ts +21 -0
- package/lib/UseCases/SerializeOrbitCamera.js +59 -0
- package/lib/UseCases/SerializedCamDemo.d.ts +0 -0
- package/lib/UseCases/SerializedCamDemo.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vector2 = void 0;
|
|
4
|
+
class Vector2 {
|
|
5
|
+
constructor(x, y) {
|
|
6
|
+
this.setLength = (length) => {
|
|
7
|
+
const unit = this.unit;
|
|
8
|
+
this.x = length * unit.x;
|
|
9
|
+
this.y = length * unit.y;
|
|
10
|
+
};
|
|
11
|
+
this.add = (vector2) => {
|
|
12
|
+
return new Vector2(this.x + vector2.x, this.y + vector2.y);
|
|
13
|
+
};
|
|
14
|
+
this.subtract = (vector2) => {
|
|
15
|
+
return new Vector2(this.x - vector2.x, this.y - vector2.y);
|
|
16
|
+
};
|
|
17
|
+
this.equal = (a) => {
|
|
18
|
+
if (a.x === this.x && a.y === this.y)
|
|
19
|
+
return true;
|
|
20
|
+
else
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
this.close = (vec) => {
|
|
24
|
+
const diff = this.subtract(vec);
|
|
25
|
+
const diffMag = diff.magnitued;
|
|
26
|
+
if (diffMag < 0.01)
|
|
27
|
+
return true;
|
|
28
|
+
else
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
this.copy = () => {
|
|
32
|
+
return new Vector2(this.x, this.y);
|
|
33
|
+
};
|
|
34
|
+
this.asArray = () => {
|
|
35
|
+
return [this.x, this.y];
|
|
36
|
+
};
|
|
37
|
+
this.rotate = (theta) => {
|
|
38
|
+
const thetaRadians = theta * Math.PI / 180;
|
|
39
|
+
const x = this.x * Math.cos(thetaRadians) - this.y * Math.sin(thetaRadians);
|
|
40
|
+
const y = this.x * Math.sin(thetaRadians) + this.y * Math.cos(thetaRadians);
|
|
41
|
+
return new Vector2(x, y);
|
|
42
|
+
};
|
|
43
|
+
this.dot = (vec) => {
|
|
44
|
+
return this.x * vec.x + this.y * vec.y;
|
|
45
|
+
};
|
|
46
|
+
this.angleTo = (vec) => {
|
|
47
|
+
const dot = this.dot(vec);
|
|
48
|
+
const magnitues = vec.magnitued * this.magnitued;
|
|
49
|
+
const angRadians = Math.acos(dot / magnitues);
|
|
50
|
+
return angRadians * 180 / Math.PI;
|
|
51
|
+
};
|
|
52
|
+
this.cross = (vec) => {
|
|
53
|
+
return (this.x * vec.y) - (this.y * vec.x);
|
|
54
|
+
};
|
|
55
|
+
this.x = x;
|
|
56
|
+
this.y = y;
|
|
57
|
+
}
|
|
58
|
+
static Zero() {
|
|
59
|
+
return new Vector2(0, 0);
|
|
60
|
+
}
|
|
61
|
+
static One() {
|
|
62
|
+
return new Vector2(1, 1);
|
|
63
|
+
}
|
|
64
|
+
get magnitued() {
|
|
65
|
+
const xSqr = this.x * this.x;
|
|
66
|
+
const ySqr = this.y * this.y;
|
|
67
|
+
const magnitude = Math.sqrt(xSqr + ySqr);
|
|
68
|
+
return magnitude;
|
|
69
|
+
}
|
|
70
|
+
get unit() {
|
|
71
|
+
const mag = this.magnitued;
|
|
72
|
+
if (mag === 0) {
|
|
73
|
+
return Vector2.Zero();
|
|
74
|
+
}
|
|
75
|
+
const unitX = this.x / mag;
|
|
76
|
+
const unitY = this.y / mag;
|
|
77
|
+
return new Vector2(unitX, unitY);
|
|
78
|
+
}
|
|
79
|
+
get theta() {
|
|
80
|
+
return (Math.atan2(this.y, this.x) * 180) / Math.PI;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.Vector2 = Vector2;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class Vector3 {
|
|
2
|
+
static Zero(): Vector3;
|
|
3
|
+
static One(): Vector3;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
z: number;
|
|
7
|
+
get magnitued(): number;
|
|
8
|
+
get unit(): Vector3;
|
|
9
|
+
setLength: (length: number) => void;
|
|
10
|
+
add: (a: Vector3) => Vector3;
|
|
11
|
+
subtract: (vector2: Vector3) => Vector3;
|
|
12
|
+
copy: () => Vector3;
|
|
13
|
+
equals: (vec: Vector3) => boolean;
|
|
14
|
+
close: (vec: Vector3) => boolean;
|
|
15
|
+
cross: (vec: Vector3) => Vector3;
|
|
16
|
+
dot: (vec: Vector3) => number;
|
|
17
|
+
asArray: () => [number, number, number];
|
|
18
|
+
constructor(x: number, y: number, z: number);
|
|
19
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vector3 = void 0;
|
|
4
|
+
class Vector3 {
|
|
5
|
+
constructor(x, y, z) {
|
|
6
|
+
this.setLength = (length) => {
|
|
7
|
+
const unit = this.unit;
|
|
8
|
+
this.x = length * unit.x;
|
|
9
|
+
this.y = length * unit.y;
|
|
10
|
+
this.z = length * unit.z;
|
|
11
|
+
};
|
|
12
|
+
this.add = (a) => {
|
|
13
|
+
return new Vector3(this.x + a.x, this.y + a.y, this.z + a.z);
|
|
14
|
+
};
|
|
15
|
+
this.subtract = (vector2) => {
|
|
16
|
+
return new Vector3(this.x - vector2.x, this.y - vector2.y, this.z - vector2.z);
|
|
17
|
+
};
|
|
18
|
+
this.copy = () => {
|
|
19
|
+
return new Vector3(this.x, this.y, this.z);
|
|
20
|
+
};
|
|
21
|
+
this.equals = (vec) => {
|
|
22
|
+
if (vec.x === this.x && vec.y === this.y && vec.z === this.z)
|
|
23
|
+
return true;
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
this.close = (vec) => {
|
|
28
|
+
const diff = this.subtract(vec);
|
|
29
|
+
const diffMag = diff.magnitued;
|
|
30
|
+
if (diffMag < 0.01)
|
|
31
|
+
return true;
|
|
32
|
+
else
|
|
33
|
+
return false;
|
|
34
|
+
};
|
|
35
|
+
this.cross = (vec) => {
|
|
36
|
+
const x = this.y * vec.z - this.z * vec.y;
|
|
37
|
+
const y = this.z * vec.x - this.x * vec.z;
|
|
38
|
+
const z = this.x * vec.y - this.y * vec.x;
|
|
39
|
+
return new Vector3(x, y, z);
|
|
40
|
+
};
|
|
41
|
+
this.dot = (vec) => {
|
|
42
|
+
return this.x * vec.x + this.y * vec.y + this.z * vec.z;
|
|
43
|
+
};
|
|
44
|
+
this.asArray = () => {
|
|
45
|
+
return [this.x, this.y, this.z];
|
|
46
|
+
};
|
|
47
|
+
this.x = x;
|
|
48
|
+
this.y = y;
|
|
49
|
+
this.z = z;
|
|
50
|
+
}
|
|
51
|
+
static Zero() {
|
|
52
|
+
return new Vector3(0, 0, 0);
|
|
53
|
+
}
|
|
54
|
+
static One() {
|
|
55
|
+
return new Vector3(1, 1, 1);
|
|
56
|
+
}
|
|
57
|
+
get magnitued() {
|
|
58
|
+
const xSqr = this.x * this.x;
|
|
59
|
+
const ySqr = this.y * this.y;
|
|
60
|
+
const zSqr = this.z * this.z;
|
|
61
|
+
const magnitude = Math.sqrt(xSqr + ySqr + zSqr);
|
|
62
|
+
return magnitude;
|
|
63
|
+
}
|
|
64
|
+
get unit() {
|
|
65
|
+
const mag = this.magnitued;
|
|
66
|
+
if (mag === 0) {
|
|
67
|
+
return Vector3.Zero();
|
|
68
|
+
}
|
|
69
|
+
const unitX = this.x / mag;
|
|
70
|
+
const unitY = this.y / mag;
|
|
71
|
+
const unitZ = this.z / mag;
|
|
72
|
+
return new Vector3(unitX, unitY, unitZ);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.Vector3 = Vector3;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AppPayloadVersions, Handler } from "@vived/app-host-boundary";
|
|
2
|
+
export declare const appPayloadVersions: AppPayloadVersions;
|
|
3
|
+
export interface AppHandlerFunctions {
|
|
4
|
+
showBabylonInspector: (show: boolean) => void;
|
|
5
|
+
setIsAuthoring: (isAuthoring: boolean) => void;
|
|
6
|
+
disposeApp: () => void;
|
|
7
|
+
stopApp: () => void;
|
|
8
|
+
startApp: (container: HTMLElement) => void;
|
|
9
|
+
setState: (finalState: string, duration?: number) => void;
|
|
10
|
+
setDevicePreview: (x: number, y: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function makeAppHandler(functions: AppHandlerFunctions): Handler;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeAppHandler = exports.appPayloadVersions = void 0;
|
|
4
|
+
const app_host_boundary_1 = require("@vived/app-host-boundary");
|
|
5
|
+
const verbose = false;
|
|
6
|
+
exports.appPayloadVersions = {
|
|
7
|
+
disposeApp: 1,
|
|
8
|
+
setDevicePreview: 1,
|
|
9
|
+
setIsAuthoring: 1,
|
|
10
|
+
showBabylonInspector: 1,
|
|
11
|
+
startApp: 2,
|
|
12
|
+
stopApp: 1,
|
|
13
|
+
setState: 2,
|
|
14
|
+
};
|
|
15
|
+
function makeAppHandler(functions) {
|
|
16
|
+
const handler = (request) => {
|
|
17
|
+
switch (request.type) {
|
|
18
|
+
case app_host_boundary_1.SHOW_BABYLON_INSPECTOR:
|
|
19
|
+
if (request.version === exports.appPayloadVersions.showBabylonInspector) {
|
|
20
|
+
const payload = request.payload;
|
|
21
|
+
functions.showBabylonInspector(payload.showBabylonInspector);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
case app_host_boundary_1.SET_IS_AUTHORING:
|
|
28
|
+
if (request.version === exports.appPayloadVersions.setIsAuthoring) {
|
|
29
|
+
const payload = request.payload;
|
|
30
|
+
functions.setIsAuthoring(payload.isAuthoring);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
case app_host_boundary_1.DISPOSE_APP:
|
|
37
|
+
if (request.version === exports.appPayloadVersions.disposeApp) {
|
|
38
|
+
functions.disposeApp();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
case app_host_boundary_1.STOP_APP:
|
|
45
|
+
if (request.version === exports.appPayloadVersions.stopApp) {
|
|
46
|
+
functions.stopApp();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case app_host_boundary_1.SET_DEVICE_PREVIEW:
|
|
53
|
+
if (request.version === exports.appPayloadVersions.setDevicePreview) {
|
|
54
|
+
const payload = request.payload;
|
|
55
|
+
functions.setDevicePreview(payload.x, payload.y);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case app_host_boundary_1.START_APP:
|
|
62
|
+
if (request.version === exports.appPayloadVersions.startApp) {
|
|
63
|
+
const payload = request.payload;
|
|
64
|
+
functions.startApp(payload.container);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case app_host_boundary_1.SET_APP_STATE:
|
|
71
|
+
if (request.version === exports.appPayloadVersions.setState) {
|
|
72
|
+
const payload = request.payload;
|
|
73
|
+
functions.setState(payload.finalState, payload.duration);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case app_host_boundary_1.GET_APP_PAYLOAD_VERSIONS:
|
|
80
|
+
if (request.version === 1) {
|
|
81
|
+
const payload = request.payload;
|
|
82
|
+
payload.callback(exports.appPayloadVersions);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
throw new app_host_boundary_1.UnsupportedRequestTypeError(request.type);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return handler;
|
|
93
|
+
}
|
|
94
|
+
exports.makeAppHandler = makeAppHandler;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultAppHandlerFunctions = void 0;
|
|
4
|
+
const setDevicePreview_1 = require("./setDevicePreview");
|
|
5
|
+
const setIsAuthoring_1 = require("./setIsAuthoring");
|
|
6
|
+
const setState_1 = require("./setState");
|
|
7
|
+
const showBabylonInspector_1 = require("./showBabylonInspector");
|
|
8
|
+
const startApp_1 = require("./startApp");
|
|
9
|
+
const stopApp_1 = require("./stopApp");
|
|
10
|
+
function defaultAppHandlerFunctions(baseApp, startRendering, stopRendering) {
|
|
11
|
+
const showBabylonInspector = showBabylonInspector_1.makeShowBabylonInspector(baseApp);
|
|
12
|
+
const disposeApp = () => {
|
|
13
|
+
// Todo, override this in your app if you have something to dispose.
|
|
14
|
+
};
|
|
15
|
+
const setDevicePreview = setDevicePreview_1.makeSetDevicePreview(baseApp);
|
|
16
|
+
const setIsAuthoring = setIsAuthoring_1.makeSetIsAuthoring(baseApp);
|
|
17
|
+
const startApp = startApp_1.makeStartApp(startRendering);
|
|
18
|
+
const stopApp = stopApp_1.makeStopApp(baseApp, stopRendering);
|
|
19
|
+
const setState = setState_1.makeSetState(baseApp);
|
|
20
|
+
const appHandlerFunctions = {
|
|
21
|
+
showBabylonInspector,
|
|
22
|
+
disposeApp,
|
|
23
|
+
setDevicePreview,
|
|
24
|
+
setIsAuthoring,
|
|
25
|
+
startApp,
|
|
26
|
+
stopApp,
|
|
27
|
+
setState,
|
|
28
|
+
};
|
|
29
|
+
return appHandlerFunctions;
|
|
30
|
+
}
|
|
31
|
+
exports.defaultAppHandlerFunctions = defaultAppHandlerFunctions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeDispatchStateChange = void 0;
|
|
4
|
+
function makeDispatchStateChange(baseApp) {
|
|
5
|
+
return function dispatchStateChange() {
|
|
6
|
+
const state = baseApp.getSerializedState();
|
|
7
|
+
baseApp.dispatchOnStateChange(state);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.makeDispatchStateChange = makeDispatchStateChange;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./dispatchStateChange";
|
|
2
|
+
export * from "./setDevicePreview";
|
|
3
|
+
export * from "./setIsAuthoring";
|
|
4
|
+
export * from "./showBabylonInspector";
|
|
5
|
+
export * from "./startApp";
|
|
6
|
+
export * from "./stopApp";
|
|
7
|
+
export * from "./makeAppHandler";
|
|
8
|
+
export * from "./defaultAppHanlderFunctions";
|
|
9
|
+
export * from "./setState";
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./dispatchStateChange"), exports);
|
|
14
|
+
__exportStar(require("./setDevicePreview"), exports);
|
|
15
|
+
__exportStar(require("./setIsAuthoring"), exports);
|
|
16
|
+
__exportStar(require("./showBabylonInspector"), exports);
|
|
17
|
+
__exportStar(require("./startApp"), exports);
|
|
18
|
+
__exportStar(require("./stopApp"), exports);
|
|
19
|
+
__exportStar(require("./makeAppHandler"), exports);
|
|
20
|
+
__exportStar(require("./defaultAppHanlderFunctions"), exports);
|
|
21
|
+
__exportStar(require("./setState"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AppPayloadVersions, Handler } from "@vived/app-host-boundary";
|
|
2
|
+
export declare const appPayloadVersions: AppPayloadVersions;
|
|
3
|
+
export interface AppHandlerFunctions {
|
|
4
|
+
showBabylonInspector: (show: boolean) => void;
|
|
5
|
+
setIsAuthoring: (isAuthoring: boolean) => void;
|
|
6
|
+
disposeApp: () => void;
|
|
7
|
+
stopApp: () => void;
|
|
8
|
+
startApp: (container: HTMLElement) => void;
|
|
9
|
+
setState: (finalState: string, duration?: number) => void;
|
|
10
|
+
setDevicePreview: (x: number, y: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function makeAppHandler(functions: AppHandlerFunctions, verbose?: boolean): Handler;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeAppHandler = exports.appPayloadVersions = void 0;
|
|
4
|
+
const app_host_boundary_1 = require("@vived/app-host-boundary");
|
|
5
|
+
exports.appPayloadVersions = {
|
|
6
|
+
disposeApp: 1,
|
|
7
|
+
setDevicePreview: 1,
|
|
8
|
+
setIsAuthoring: 1,
|
|
9
|
+
showBabylonInspector: 1,
|
|
10
|
+
startApp: 2,
|
|
11
|
+
stopApp: 1,
|
|
12
|
+
setState: 2,
|
|
13
|
+
};
|
|
14
|
+
function makeAppHandler(functions, verbose = false) {
|
|
15
|
+
const handler = (request) => {
|
|
16
|
+
if (verbose) {
|
|
17
|
+
console.log(request);
|
|
18
|
+
}
|
|
19
|
+
switch (request.type) {
|
|
20
|
+
case 'SHOW_BABYLON_INSPECTOR':
|
|
21
|
+
if (request.version === exports.appPayloadVersions.showBabylonInspector) {
|
|
22
|
+
const payload = request.payload;
|
|
23
|
+
functions.showBabylonInspector(payload.showBabylonInspector);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case 'SET_IS_AUTHORING':
|
|
30
|
+
if (request.version === exports.appPayloadVersions.setIsAuthoring) {
|
|
31
|
+
const payload = request.payload;
|
|
32
|
+
functions.setIsAuthoring(payload.isAuthoring);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case 'DISPOSE_APP':
|
|
39
|
+
if (request.version === exports.appPayloadVersions.disposeApp) {
|
|
40
|
+
functions.disposeApp();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case 'STOP_APP':
|
|
47
|
+
if (request.version === exports.appPayloadVersions.stopApp) {
|
|
48
|
+
functions.stopApp();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case 'SET_DEVICE_PREVIEW':
|
|
55
|
+
if (request.version === exports.appPayloadVersions.setDevicePreview) {
|
|
56
|
+
const payload = request.payload;
|
|
57
|
+
functions.setDevicePreview(payload.x, payload.y);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case 'START_APP':
|
|
64
|
+
if (request.version === exports.appPayloadVersions.startApp) {
|
|
65
|
+
const payload = request.payload;
|
|
66
|
+
functions.startApp(payload.container);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case 'SET_APP_STATE':
|
|
73
|
+
if (request.version === exports.appPayloadVersions.setState) {
|
|
74
|
+
const payload = request.payload;
|
|
75
|
+
functions.setState(payload.finalState, payload.duration);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case 'GET_APP_PAYLOAD_VERSION':
|
|
82
|
+
if (request.version === 1) {
|
|
83
|
+
const payload = request.payload;
|
|
84
|
+
payload.callback(exports.appPayloadVersions);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
throw new app_host_boundary_1.UnsupportedRequestTypeError(request.type);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return handler;
|
|
95
|
+
}
|
|
96
|
+
exports.makeAppHandler = makeAppHandler;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSetDevicePreview = void 0;
|
|
4
|
+
function makeSetDevicePreview(devicePreviewUC) {
|
|
5
|
+
return function setDevicePreview(x, y) {
|
|
6
|
+
if (x < 0 || y < 0) {
|
|
7
|
+
devicePreviewUC.clearDevicePreview();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
devicePreviewUC.setDevicePreview(x, y);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.makeSetDevicePreview = makeSetDevicePreview;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSetIsAuthoring = void 0;
|
|
4
|
+
const dispatchStateChange_1 = require("./dispatchStateChange");
|
|
5
|
+
function makeSetIsAuthoring(appStateUC) {
|
|
6
|
+
const dispatchStateChange = dispatchStateChange_1.makeDispatchStateChange(appStateUC);
|
|
7
|
+
return function setIsAuthoring(isAuthoring) {
|
|
8
|
+
appStateUC.setIsAuthoring(isAuthoring);
|
|
9
|
+
if (isAuthoring) {
|
|
10
|
+
dispatchStateChange();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.makeSetIsAuthoring = makeSetIsAuthoring;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSetState = void 0;
|
|
4
|
+
function makeSetState(baseApp) {
|
|
5
|
+
return function setState(state, duration = 0) {
|
|
6
|
+
if (state) {
|
|
7
|
+
try {
|
|
8
|
+
const stateObj = JSON.parse(state);
|
|
9
|
+
baseApp.setSerializedState(stateObj, duration);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
baseApp.setDefaultState(duration);
|
|
13
|
+
console.warn("[setState] Failed to deserialize state string: " + e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
baseApp.setDefaultState(duration);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.makeSetState = makeSetState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeShowBabylonInspector = void 0;
|
|
4
|
+
function makeShowBabylonInspector(appStateUC) {
|
|
5
|
+
return function showBabylonInspector(showInspector) {
|
|
6
|
+
appStateUC.setShowBabylonInspector(showInspector);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
exports.makeShowBabylonInspector = makeShowBabylonInspector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeStartApp(startRendering: (container: HTMLElement) => void): (container: HTMLElement) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeStartApp = void 0;
|
|
4
|
+
function makeStartApp(startRendering) {
|
|
5
|
+
return function startApp(container) {
|
|
6
|
+
startRendering(container);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
exports.makeStartApp = makeStartApp;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeStopApp = void 0;
|
|
4
|
+
function makeStopApp(appStateUC, stopRendering) {
|
|
5
|
+
return function stopApp() {
|
|
6
|
+
stopRendering();
|
|
7
|
+
appStateUC.setIsAuthoring(false);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.makeStopApp = makeStopApp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseAppStateObserver, BaseAppUC } from "../../Core";
|
|
2
|
+
export interface DevicePreviewVM {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
useDevicePreview: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class DevicePreviewPM implements BaseAppStateObserver {
|
|
8
|
+
devicePreviewUC: BaseAppUC;
|
|
9
|
+
updateView: (vm: DevicePreviewVM) => void;
|
|
10
|
+
constructor(baseAppUC: BaseAppUC, updateView: (vm: DevicePreviewVM) => void);
|
|
11
|
+
onBaseAppChange: () => void;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DevicePreviewPM = void 0;
|
|
4
|
+
class DevicePreviewPM {
|
|
5
|
+
constructor(baseAppUC, updateView) {
|
|
6
|
+
this.onBaseAppChange = () => {
|
|
7
|
+
const useDevicePreview = this.devicePreviewUC.getUseDevicePreview();
|
|
8
|
+
const x = this.devicePreviewUC.getDevicePreviewSize().x;
|
|
9
|
+
const y = this.devicePreviewUC.getDevicePreviewSize().y;
|
|
10
|
+
this.updateView({
|
|
11
|
+
x,
|
|
12
|
+
y,
|
|
13
|
+
useDevicePreview,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
this.devicePreviewUC = baseAppUC;
|
|
17
|
+
this.updateView = updateView;
|
|
18
|
+
this.onBaseAppChange();
|
|
19
|
+
this.devicePreviewUC.addObserver(this);
|
|
20
|
+
}
|
|
21
|
+
dispose() {
|
|
22
|
+
this.devicePreviewUC.removeObserver(this);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.DevicePreviewPM = DevicePreviewPM;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseAppStateObserver, BaseAppUC } from "../../Core";
|
|
2
|
+
export declare class IsAuthoringPM implements BaseAppStateObserver {
|
|
3
|
+
private appStateUC;
|
|
4
|
+
private updateView;
|
|
5
|
+
private lastSetState?;
|
|
6
|
+
constructor(baseAppStateUC: BaseAppUC, updateView: (isAuthoring: boolean) => void);
|
|
7
|
+
dispose(): void;
|
|
8
|
+
onBaseAppChange: () => void;
|
|
9
|
+
private doUpdateView;
|
|
10
|
+
}
|