@vived/app 4.16.0 → 4.17.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/Components/StateMachine/Controller/clickRestoreScene.d.ts +2 -0
- package/lib/Components/StateMachine/Controller/clickRestoreScene.js +14 -0
- package/lib/Components/StateMachine/Controller/index.d.ts +1 -0
- package/lib/Components/StateMachine/Controller/index.js +13 -0
- package/lib/Components/StateMachine/Entities/StateMachineEntity.d.ts +2 -0
- package/lib/Components/StateMachine/Entities/StateMachineEntity.js +11 -0
- package/lib/Components/StateMachine/Mocks/MockStateMachine.d.ts +4 -1
- package/lib/Components/StateMachine/Mocks/MockStateMachine.js +7 -1
- package/lib/Components/StateMachine/index.d.ts +1 -0
- package/lib/Components/StateMachine/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clickRestoreScene = void 0;
|
|
4
|
+
const Entities_1 = require("../Entities");
|
|
5
|
+
function clickRestoreScene(appObjects) {
|
|
6
|
+
const entity = Entities_1.StateMachineEntity.get(appObjects);
|
|
7
|
+
if (entity) {
|
|
8
|
+
entity.restoreLastState();
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
appObjects.submitError("clickRestoreScene", "Unable to find StateMachineEntity");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.clickRestoreScene = clickRestoreScene;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./clickRestoreScene";
|
|
@@ -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("./clickRestoreScene"), exports);
|
|
@@ -19,10 +19,12 @@ export interface SerializedSystem {
|
|
|
19
19
|
}
|
|
20
20
|
export declare abstract class StateMachineEntity extends AppObjectEntity {
|
|
21
21
|
static readonly type = "StateMachineEntity";
|
|
22
|
+
abstract restoreDurationS: number;
|
|
22
23
|
abstract transitionEaseFunction: (normalizedTime: number) => number;
|
|
23
24
|
abstract getSerializedStates(): SerializedStates;
|
|
24
25
|
abstract setSerializedStates(state: SerializedStates, transitionTime: number): void;
|
|
25
26
|
abstract applySerializedStatesString: (state: string, duration?: number) => void;
|
|
27
|
+
abstract restoreLastState(): void;
|
|
26
28
|
abstract setDefaultState(transitionTime: number): void;
|
|
27
29
|
abstract registerSerializedSystem(serializedSystem: SerializedSystem): void;
|
|
28
30
|
static get: (appObjects: AppObjectRepo) => StateMachineEntity | undefined;
|
|
@@ -17,6 +17,7 @@ class StateMachineImp extends StateMachineEntity {
|
|
|
17
17
|
super(appObject, StateMachineEntity.type);
|
|
18
18
|
this.serializedSystems = new Map();
|
|
19
19
|
this.serilizationVersion = 2;
|
|
20
|
+
this.restoreDurationS = 1;
|
|
20
21
|
this.transitionEaseFunction = (normalizedTime) => {
|
|
21
22
|
return normalizedTime; // default to a linear function
|
|
22
23
|
};
|
|
@@ -81,6 +82,7 @@ class StateMachineImp extends StateMachineEntity {
|
|
|
81
82
|
system.applySystemState(systemState.state, systemState.seriliziationVersion, duration);
|
|
82
83
|
}
|
|
83
84
|
});
|
|
85
|
+
this.lastState = states;
|
|
84
86
|
this.notifyOnChange();
|
|
85
87
|
return;
|
|
86
88
|
}
|
|
@@ -94,7 +96,16 @@ class StateMachineImp extends StateMachineEntity {
|
|
|
94
96
|
this.serializedSystems.forEach((system) => {
|
|
95
97
|
system.applyDefaultState(duration);
|
|
96
98
|
});
|
|
99
|
+
this.lastState = undefined;
|
|
97
100
|
this.notifyOnChange();
|
|
98
101
|
};
|
|
99
102
|
}
|
|
103
|
+
restoreLastState() {
|
|
104
|
+
if (this.lastState) {
|
|
105
|
+
this.setSerializedStates(this.lastState, this.restoreDurationS);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.setDefaultState(this.restoreDurationS);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
100
111
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
import { AppObject } from "../../../AppObject";
|
|
2
|
+
import { AppObject, AppObjectRepo } from "../../../AppObject";
|
|
3
3
|
import { StateMachineEntity } from "../Entities";
|
|
4
4
|
export declare class MockStateMachine extends StateMachineEntity {
|
|
5
|
+
restoreDurationS: number;
|
|
6
|
+
restoreLastState: jest.Mock<any, any>;
|
|
5
7
|
transitionEaseFunction: jest.Mock<any, any>;
|
|
6
8
|
getSerializedStates: jest.Mock<any, any>;
|
|
7
9
|
setSerializedStates: jest.Mock<any, any>;
|
|
@@ -10,3 +12,4 @@ export declare class MockStateMachine extends StateMachineEntity {
|
|
|
10
12
|
registerSerializedSystem: jest.Mock<any, any>;
|
|
11
13
|
constructor(appObject: AppObject);
|
|
12
14
|
}
|
|
15
|
+
export declare function makeMockStateMachine(appObjects: AppObjectRepo): MockStateMachine;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockStateMachine = void 0;
|
|
3
|
+
exports.makeMockStateMachine = exports.MockStateMachine = void 0;
|
|
4
4
|
const Entities_1 = require("../Entities");
|
|
5
5
|
class MockStateMachine extends Entities_1.StateMachineEntity {
|
|
6
6
|
constructor(appObject) {
|
|
7
7
|
super(appObject, Entities_1.StateMachineEntity.type);
|
|
8
|
+
this.restoreDurationS = 1;
|
|
9
|
+
this.restoreLastState = jest.fn();
|
|
8
10
|
this.transitionEaseFunction = jest.fn();
|
|
9
11
|
this.getSerializedStates = jest.fn();
|
|
10
12
|
this.setSerializedStates = jest.fn();
|
|
@@ -14,3 +16,7 @@ class MockStateMachine extends Entities_1.StateMachineEntity {
|
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
exports.MockStateMachine = MockStateMachine;
|
|
19
|
+
function makeMockStateMachine(appObjects) {
|
|
20
|
+
return new MockStateMachine(appObjects.getOrCreate("MockStateMachine"));
|
|
21
|
+
}
|
|
22
|
+
exports.makeMockStateMachine = makeMockStateMachine;
|
|
@@ -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("./Controller"), exports);
|
|
13
14
|
__exportStar(require("./Entities"), exports);
|
|
14
15
|
__exportStar(require("./Mocks"), exports);
|