@vived/app 4.34.10 → 4.34.11
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/Label/Factories/index.d.ts +1 -0
- package/lib/Components/Label/Factories/index.js +13 -0
- package/lib/Components/Label/Factories/setupLabel.d.ts +2 -0
- package/lib/Components/Label/Factories/setupLabel.js +11 -0
- package/lib/Components/Label/UC/SerializeCustomLabels.d.ts +26 -0
- package/lib/Components/Label/UC/SerializeCustomLabels.js +86 -0
- package/lib/Components/Label/UC/index.d.ts +1 -0
- package/lib/Components/Label/UC/index.js +1 -0
- package/lib/Components/Label/index.d.ts +1 -0
- package/lib/Components/Label/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./setupLabel";
|
|
@@ -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("./setupLabel"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupLabel = void 0;
|
|
4
|
+
const UC_1 = require("../UC");
|
|
5
|
+
function setupLabel(appObjects) {
|
|
6
|
+
const ao = appObjects.getOrCreate("Label");
|
|
7
|
+
// UCs
|
|
8
|
+
UC_1.makeSerializeCustomLabels(ao);
|
|
9
|
+
return ao;
|
|
10
|
+
}
|
|
11
|
+
exports.setupLabel = setupLabel;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AppObject, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
import { SerializedSystem } from "../../StateMachine";
|
|
3
|
+
export declare abstract class SerializeCustomLabels extends AppObjectUC implements SerializedSystem {
|
|
4
|
+
static readonly type = "SerializeCustomLabels";
|
|
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 makeSerializeCustomLabels(appObject: AppObject): SerializeCustomLabels;
|
|
12
|
+
export declare class SerializeCustomLabelsImp extends SerializeCustomLabels {
|
|
13
|
+
seriliziationVersion: number;
|
|
14
|
+
getSystemState(): object;
|
|
15
|
+
applySystemState(state: object, version: number, durationS: number): Promise<void> | void;
|
|
16
|
+
private applyStateV1;
|
|
17
|
+
applyDefaultState(): void;
|
|
18
|
+
constructor(appObj: AppObject);
|
|
19
|
+
}
|
|
20
|
+
export interface SerializedCustomLabelsV1 {
|
|
21
|
+
customLabels: SerializedCustomLabelV1[];
|
|
22
|
+
}
|
|
23
|
+
export interface SerializedCustomLabelV1 {
|
|
24
|
+
objectId: string;
|
|
25
|
+
customLabel: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerializeCustomLabelsImp = exports.makeSerializeCustomLabels = exports.SerializeCustomLabels = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const StateMachine_1 = require("../../StateMachine");
|
|
6
|
+
const Entities_1 = require("../Entities");
|
|
7
|
+
class SerializeCustomLabels extends AppObject_1.AppObjectUC {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.name = "serialize-custom-labels";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SerializeCustomLabels = SerializeCustomLabels;
|
|
14
|
+
SerializeCustomLabels.type = "SerializeCustomLabels";
|
|
15
|
+
function makeSerializeCustomLabels(appObject) {
|
|
16
|
+
return new SerializeCustomLabelsImp(appObject);
|
|
17
|
+
}
|
|
18
|
+
exports.makeSerializeCustomLabels = makeSerializeCustomLabels;
|
|
19
|
+
class SerializeCustomLabelsImp extends SerializeCustomLabels {
|
|
20
|
+
constructor(appObj) {
|
|
21
|
+
super(appObj, SerializeCustomLabels.type);
|
|
22
|
+
this.seriliziationVersion = 1;
|
|
23
|
+
const stateMachine = this.appObjects.getSingleton(StateMachine_1.StateMachineEntity.type);
|
|
24
|
+
if (stateMachine) {
|
|
25
|
+
stateMachine.registerSerializedSystem(this);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.warn("Unable to find StateMachineEntity");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getSystemState() {
|
|
32
|
+
const customLabels = [];
|
|
33
|
+
const allLabels = this.appObjects.getAllComponents(Entities_1.LabelEntity.type);
|
|
34
|
+
allLabels.forEach((label) => {
|
|
35
|
+
if (label.hasCustomLabel)
|
|
36
|
+
customLabels.push({
|
|
37
|
+
objectId: label.appObject.id,
|
|
38
|
+
customLabel: label.custom,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
const state = {
|
|
42
|
+
customLabels,
|
|
43
|
+
};
|
|
44
|
+
return state;
|
|
45
|
+
}
|
|
46
|
+
applySystemState(state, version, durationS) {
|
|
47
|
+
if (version === 1) {
|
|
48
|
+
return this.applyStateV1(state, durationS);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.applyDefaultState();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
applyStateV1(state, durationS) {
|
|
55
|
+
const { customLabels } = state;
|
|
56
|
+
if (!customLabels || customLabels.length === 0) {
|
|
57
|
+
this.applyDefaultState();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Create a Map for faster lookups
|
|
61
|
+
const customLabelsLookup = new Map();
|
|
62
|
+
customLabels.forEach((customLabel) => {
|
|
63
|
+
customLabelsLookup.set(customLabel.objectId, customLabel.customLabel);
|
|
64
|
+
});
|
|
65
|
+
const allLabels = this.appObjects.getAllComponents(Entities_1.LabelEntity.type);
|
|
66
|
+
allLabels.forEach((label) => {
|
|
67
|
+
var _a;
|
|
68
|
+
const appObjectId = label.appObject.id;
|
|
69
|
+
label.custom = (_a = customLabelsLookup.get(appObjectId)) !== null && _a !== void 0 ? _a : "";
|
|
70
|
+
});
|
|
71
|
+
customLabelsLookup.forEach((customLabel, objectId) => {
|
|
72
|
+
const appObject = this.appObjects.getOrCreate(objectId);
|
|
73
|
+
if (appObject) {
|
|
74
|
+
const label = Entities_1.LabelEntity.addIfMissing(appObject);
|
|
75
|
+
label.custom = customLabel;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
applyDefaultState() {
|
|
80
|
+
const allLabels = this.appObjects.getAllComponents(Entities_1.LabelEntity.type);
|
|
81
|
+
allLabels.forEach((label) => {
|
|
82
|
+
label.custom = "";
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.SerializeCustomLabelsImp = SerializeCustomLabelsImp;
|
|
@@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./ClearCustomLabelUC"), exports);
|
|
14
14
|
__exportStar(require("./SetCustomLabelUC"), exports);
|
|
15
|
+
__exportStar(require("./SerializeCustomLabels"), exports);
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./Adapters"), exports);
|
|
14
14
|
__exportStar(require("./Controller"), exports);
|
|
15
15
|
__exportStar(require("./Entities"), exports);
|
|
16
|
+
__exportStar(require("./Factories"), exports);
|
|
16
17
|
__exportStar(require("./Mocks"), exports);
|
|
17
18
|
__exportStar(require("./PM"), exports);
|
|
18
19
|
__exportStar(require("./UC"), exports);
|