@vived/app 4.21.0 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Components/ChannelModel/Adapters/activeModelAdapter.d.ts +2 -0
- package/lib/Components/ChannelModel/Adapters/activeModelAdapter.js +23 -0
- package/lib/Components/ChannelModel/Adapters/index.d.ts +1 -0
- package/lib/Components/ChannelModel/Adapters/index.js +1 -0
- package/lib/Components/ChannelModel/Entities/ChannelModelRepo.d.ts +2 -2
- package/lib/Components/ChannelModel/Entities/ChannelModelRepo.js +3 -3
- package/lib/Components/ChannelModel/Mocks/ActiveModelMock.d.ts +8 -0
- package/lib/Components/ChannelModel/Mocks/ActiveModelMock.js +15 -0
- package/lib/Components/ChannelModel/Mocks/index.d.ts +1 -0
- package/lib/Components/ChannelModel/Mocks/index.js +1 -0
- package/lib/Components/ChannelModel/PMs/ActiveModelPM.d.ts +13 -0
- package/lib/Components/ChannelModel/PMs/ActiveModelPM.js +36 -0
- package/lib/Components/ChannelModel/PMs/index.d.ts +1 -0
- package/lib/Components/ChannelModel/PMs/index.js +1 -0
- package/lib/Components/ChannelModel/UC/SelectChannelModelUC.js +7 -1
- package/lib/Components/ChannelModel/UC/SerializeActiveModel.d.ts +26 -0
- package/lib/Components/ChannelModel/UC/SerializeActiveModel.js +80 -0
- package/lib/Components/ChannelModel/UC/index.d.ts +1 -0
- package/lib/Components/ChannelModel/UC/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activeModelAdapter = void 0;
|
|
4
|
+
const ActiveModelPM_1 = require("../PMs/ActiveModelPM");
|
|
5
|
+
exports.activeModelAdapter = {
|
|
6
|
+
defaultVM: "",
|
|
7
|
+
subscribe: (appObjects, setVM) => {
|
|
8
|
+
const pm = ActiveModelPM_1.ActiveModelPM.get(appObjects);
|
|
9
|
+
if (!pm) {
|
|
10
|
+
appObjects.submitError("animationFrameAdapter", "Unable to find ActiveModelPM");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
pm.addView(setVM);
|
|
14
|
+
},
|
|
15
|
+
unsubscribe: (appObjects, setVM) => {
|
|
16
|
+
const pm = ActiveModelPM_1.ActiveModelPM.get(appObjects);
|
|
17
|
+
if (!pm) {
|
|
18
|
+
appObjects.submitError("animationFrameAdapter", "Unable to find ActiveModelPM");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
pm.removeView(setVM);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -10,5 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./activeModelAdapter"), exports);
|
|
13
14
|
__exportStar(require("./channelModelAdapter"), exports);
|
|
14
15
|
__exportStar(require("./channelModelObjectAdapter"), exports);
|
|
@@ -2,8 +2,8 @@ import { AppObject, AppObjectEntityRepo, AppObjectRepo } from "../../../AppObjec
|
|
|
2
2
|
import { ChannelModelEntity } from "./ChannelModel";
|
|
3
3
|
export declare abstract class ChannelModelRepo extends AppObjectEntityRepo<ChannelModelEntity> {
|
|
4
4
|
static readonly type = "CHANNEL_MODEL_REPO";
|
|
5
|
-
abstract get
|
|
6
|
-
abstract set
|
|
5
|
+
abstract get activeModel(): string;
|
|
6
|
+
abstract set activeModel(val: string);
|
|
7
7
|
abstract getChannelModel(id: string, createIfMissing: boolean): ChannelModelEntity | undefined;
|
|
8
8
|
abstract channelModelFactory(id: string): ChannelModelEntity;
|
|
9
9
|
abstract createChannelModel(id?: string): ChannelModelEntity;
|
|
@@ -17,7 +17,7 @@ exports.makeChannelModelRepo = makeChannelModelRepo;
|
|
|
17
17
|
class ChannelModelRepoImp extends ChannelModelRepo {
|
|
18
18
|
constructor(appObject) {
|
|
19
19
|
super(appObject, ChannelModelRepo.type);
|
|
20
|
-
this.memoizedIsLoading = new Entities_1.
|
|
20
|
+
this.memoizedIsLoading = new Entities_1.MemoizedString("", this.notifyOnChange);
|
|
21
21
|
this.getChannelModel = (id, createIfMissing) => {
|
|
22
22
|
let rVal = this.getForAppObject(id);
|
|
23
23
|
if (rVal === undefined && createIfMissing) {
|
|
@@ -37,10 +37,10 @@ class ChannelModelRepoImp extends ChannelModelRepo {
|
|
|
37
37
|
return ChannelModel_1.makeChannelModelEntity(ao);
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
get
|
|
40
|
+
get activeModel() {
|
|
41
41
|
return this.memoizedIsLoading.val;
|
|
42
42
|
}
|
|
43
|
-
set
|
|
43
|
+
set activeModel(val) {
|
|
44
44
|
this.memoizedIsLoading.val = val;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { AppObject, AppObjectRepo } from "../../../AppObject";
|
|
3
|
+
import { ActiveModelPM } from "../PMs";
|
|
4
|
+
export declare class ActiveModelMock extends ActiveModelPM {
|
|
5
|
+
vmsAreEqual: jest.Mock<any, any>;
|
|
6
|
+
constructor(appObject: AppObject);
|
|
7
|
+
}
|
|
8
|
+
export declare function makeActiveModelMock(appObjects: AppObjectRepo): ActiveModelMock;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeActiveModelMock = exports.ActiveModelMock = void 0;
|
|
4
|
+
const PMs_1 = require("../PMs");
|
|
5
|
+
class ActiveModelMock extends PMs_1.ActiveModelPM {
|
|
6
|
+
constructor(appObject) {
|
|
7
|
+
super(appObject, PMs_1.ActiveModelPM.type);
|
|
8
|
+
this.vmsAreEqual = jest.fn();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ActiveModelMock = ActiveModelMock;
|
|
12
|
+
function makeActiveModelMock(appObjects) {
|
|
13
|
+
return new ActiveModelMock(appObjects.getOrCreate("ActiveModelMock"));
|
|
14
|
+
}
|
|
15
|
+
exports.makeActiveModelMock = makeActiveModelMock;
|
|
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./ActiveModelMock"), exports);
|
|
13
14
|
__exportStar(require("./ChannelModelObjectPMMock"), exports);
|
|
14
15
|
__exportStar(require("./ChannelModelPMMock"), exports);
|
|
15
16
|
__exportStar(require("./ChannelModelViewFactoryMock"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppObject, AppObjectPM, AppObjectRepo } from "../../../AppObject";
|
|
2
|
+
export declare abstract class ActiveModelPM extends AppObjectPM<string> {
|
|
3
|
+
static readonly type = "ActiveModelPM";
|
|
4
|
+
static get(appObjects: AppObjectRepo): ActiveModelPM | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare function makeActiveModelPM(appObject: AppObject): ActiveModelPMImp;
|
|
7
|
+
declare class ActiveModelPMImp extends ActiveModelPM {
|
|
8
|
+
private get repo();
|
|
9
|
+
vmsAreEqual(a: string, b: string): boolean;
|
|
10
|
+
onEntityChange: () => void;
|
|
11
|
+
constructor(appObject: AppObject);
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeActiveModelPM = exports.ActiveModelPM = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const Entities_1 = require("../Entities");
|
|
6
|
+
class ActiveModelPM extends AppObject_1.AppObjectPM {
|
|
7
|
+
static get(appObjects) {
|
|
8
|
+
return AppObject_1.getSingletonComponent(ActiveModelPM.type, appObjects);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ActiveModelPM = ActiveModelPM;
|
|
12
|
+
ActiveModelPM.type = "ActiveModelPM";
|
|
13
|
+
function makeActiveModelPM(appObject) {
|
|
14
|
+
return new ActiveModelPMImp(appObject);
|
|
15
|
+
}
|
|
16
|
+
exports.makeActiveModelPM = makeActiveModelPM;
|
|
17
|
+
class ActiveModelPMImp extends ActiveModelPM {
|
|
18
|
+
constructor(appObject) {
|
|
19
|
+
var _a;
|
|
20
|
+
super(appObject, ActiveModelPM.type);
|
|
21
|
+
this.onEntityChange = () => {
|
|
22
|
+
if (!this.repo)
|
|
23
|
+
return;
|
|
24
|
+
this.doUpdateView(this.repo.activeModel);
|
|
25
|
+
};
|
|
26
|
+
(_a = this.repo) === null || _a === void 0 ? void 0 : _a.addChangeObserver(this.onEntityChange);
|
|
27
|
+
this.onEntityChange();
|
|
28
|
+
this.appObjects.registerSingleton(this);
|
|
29
|
+
}
|
|
30
|
+
get repo() {
|
|
31
|
+
return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
|
|
32
|
+
}
|
|
33
|
+
vmsAreEqual(a, b) {
|
|
34
|
+
return a === b;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -10,5 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./ActiveModelPM"), exports);
|
|
13
14
|
__exportStar(require("./ChannelModelObjectPM"), exports);
|
|
14
15
|
__exportStar(require("./ChannelModelPM"), exports);
|
|
@@ -4,6 +4,7 @@ exports.makeSelectChannelModelUC = exports.SelectChannelModelUC = void 0;
|
|
|
4
4
|
const AppObject_1 = require("../../../AppObject");
|
|
5
5
|
const Dispatcher_1 = require("../../Dispatcher");
|
|
6
6
|
const SceneRoot_1 = require("../../SceneRoot");
|
|
7
|
+
const Entities_1 = require("../Entities");
|
|
7
8
|
const LoadChannelModelUC_1 = require("./LoadChannelModelUC");
|
|
8
9
|
class SelectChannelModelUC extends AppObject_1.AppObjectUC {
|
|
9
10
|
}
|
|
@@ -21,7 +22,8 @@ class SelectChannelModelUCImp extends SelectChannelModelUC {
|
|
|
21
22
|
const showSelectModel = this.showSelectModel;
|
|
22
23
|
const loadChannelModel = this.loadChannelModel;
|
|
23
24
|
const sceneRoot = this.sceneRoot;
|
|
24
|
-
|
|
25
|
+
const repo = this.repo;
|
|
26
|
+
if (!showSelectModel || !loadChannelModel || !sceneRoot || !repo) {
|
|
25
27
|
return Promise.reject(new Error("Missing Components"));
|
|
26
28
|
}
|
|
27
29
|
return showSelectModel
|
|
@@ -33,6 +35,7 @@ class SelectChannelModelUCImp extends SelectChannelModelUC {
|
|
|
33
35
|
sceneRoot.position = channelModel.defaultPosition;
|
|
34
36
|
sceneRoot.rotation = channelModel.defaultRotation;
|
|
35
37
|
sceneRoot.scale = channelModel.defaultScale;
|
|
38
|
+
repo.activeModel = channelModel.id;
|
|
36
39
|
return channelModel.id;
|
|
37
40
|
});
|
|
38
41
|
};
|
|
@@ -48,4 +51,7 @@ class SelectChannelModelUCImp extends SelectChannelModelUC {
|
|
|
48
51
|
get sceneRoot() {
|
|
49
52
|
return this.getCachedSingleton(SceneRoot_1.SceneRootEntity.type);
|
|
50
53
|
}
|
|
54
|
+
get repo() {
|
|
55
|
+
return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
|
|
56
|
+
}
|
|
51
57
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AppObject, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
import { SerializedSystem } from "../../StateMachine";
|
|
3
|
+
export declare abstract class SerializeActiveModel extends AppObjectUC implements SerializedSystem {
|
|
4
|
+
static readonly type = "SerializeDemoState";
|
|
5
|
+
name: string;
|
|
6
|
+
abstract seriliziationVersion: number;
|
|
7
|
+
abstract getSystemState(): object;
|
|
8
|
+
abstract applySystemState(state: object, version: number, transitionDuration: number): void;
|
|
9
|
+
abstract applyDefaultState(transitionDuration: number): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function makeSerializeActiveModel(appObject: AppObject): SerializeActiveModel;
|
|
12
|
+
export declare class SerializeActiveModelImp extends SerializeActiveModel {
|
|
13
|
+
seriliziationVersion: number;
|
|
14
|
+
private get repo();
|
|
15
|
+
private get stateMachine();
|
|
16
|
+
private get loadChannelModel();
|
|
17
|
+
private get showSelectModel();
|
|
18
|
+
getSystemState(): object;
|
|
19
|
+
applySystemState(state: object, version: number): void;
|
|
20
|
+
applyStateV1(state: SerializedActiveModelStateV1): void;
|
|
21
|
+
applyDefaultState(): void;
|
|
22
|
+
constructor(appObject: AppObject);
|
|
23
|
+
}
|
|
24
|
+
export interface SerializedActiveModelStateV1 {
|
|
25
|
+
modelID: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerializeActiveModelImp = exports.makeSerializeActiveModel = exports.SerializeActiveModel = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const StateMachine_1 = require("../../StateMachine");
|
|
6
|
+
const Entities_1 = require("../Entities");
|
|
7
|
+
const LoadChannelModelUC_1 = require("./LoadChannelModelUC");
|
|
8
|
+
const SelectChannelModelUC_1 = require("./SelectChannelModelUC");
|
|
9
|
+
class SerializeActiveModel extends AppObject_1.AppObjectUC {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.name = "active-model";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.SerializeActiveModel = SerializeActiveModel;
|
|
16
|
+
SerializeActiveModel.type = "SerializeDemoState";
|
|
17
|
+
function makeSerializeActiveModel(appObject) {
|
|
18
|
+
return new SerializeActiveModelImp(appObject);
|
|
19
|
+
}
|
|
20
|
+
exports.makeSerializeActiveModel = makeSerializeActiveModel;
|
|
21
|
+
class SerializeActiveModelImp extends SerializeActiveModel {
|
|
22
|
+
constructor(appObject) {
|
|
23
|
+
var _a;
|
|
24
|
+
super(appObject, SerializeActiveModel.type);
|
|
25
|
+
this.seriliziationVersion = 1;
|
|
26
|
+
(_a = this.stateMachine) === null || _a === void 0 ? void 0 : _a.registerSerializedSystem(this);
|
|
27
|
+
}
|
|
28
|
+
get repo() {
|
|
29
|
+
return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
|
|
30
|
+
}
|
|
31
|
+
get stateMachine() {
|
|
32
|
+
return this.getCachedSingleton(StateMachine_1.StateMachineEntity.type);
|
|
33
|
+
}
|
|
34
|
+
get loadChannelModel() {
|
|
35
|
+
var _a;
|
|
36
|
+
return (_a = this.getCachedSingleton(LoadChannelModelUC_1.LoadChannelModelUC.type)) === null || _a === void 0 ? void 0 : _a.loadChannelModel;
|
|
37
|
+
}
|
|
38
|
+
get showSelectModel() {
|
|
39
|
+
var _a;
|
|
40
|
+
return (_a = this.getCachedSingleton(SelectChannelModelUC_1.SelectChannelModelUC.type)) === null || _a === void 0 ? void 0 : _a.selectChannelModel;
|
|
41
|
+
}
|
|
42
|
+
getSystemState() {
|
|
43
|
+
if (!this.repo)
|
|
44
|
+
return {};
|
|
45
|
+
const appState = {
|
|
46
|
+
modelID: this.repo.activeModel,
|
|
47
|
+
};
|
|
48
|
+
return appState;
|
|
49
|
+
}
|
|
50
|
+
applySystemState(state, version) {
|
|
51
|
+
if (version === 1) {
|
|
52
|
+
this.applyStateV1(state);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// Unsupported version
|
|
56
|
+
this.warn(`Unsupported data version ${version} for serialized system ${this.name}. Reverting to default state`);
|
|
57
|
+
this.applyDefaultState();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
applyStateV1(state) {
|
|
61
|
+
const { modelID } = state;
|
|
62
|
+
if (!modelID) {
|
|
63
|
+
this.applyDefaultState();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!this.repo || !this.loadChannelModel) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.repo.activeModel = modelID;
|
|
70
|
+
this.loadChannelModel(modelID);
|
|
71
|
+
}
|
|
72
|
+
applyDefaultState() {
|
|
73
|
+
if (!this.repo || !this.showSelectModel) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.repo.activeModel = "";
|
|
77
|
+
this.showSelectModel();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.SerializeActiveModelImp = SerializeActiveModelImp;
|
|
@@ -13,3 +13,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./ChannelModelViewFactory"), exports);
|
|
14
14
|
__exportStar(require("./LoadChannelModelUC"), exports);
|
|
15
15
|
__exportStar(require("./SelectChannelModelUC"), exports);
|
|
16
|
+
__exportStar(require("./SerializeActiveModel"), exports);
|