@routevn/creator-model 1.3.3 → 1.3.5
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/package.json +1 -1
- package/src/model.js +63 -1
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -40,6 +40,7 @@ const LINE_UPDATE_ACTIONS_PRESERVE_PATHS = ["dialogue.content"];
|
|
|
40
40
|
const LINE_UPDATE_ACTIONS_PRESERVE_PATHS_SET = new Set(
|
|
41
41
|
LINE_UPDATE_ACTIONS_PRESERVE_PATHS,
|
|
42
42
|
);
|
|
43
|
+
const isPositiveFiniteNumber = (value) => isFiniteNumber(value) && value > 0;
|
|
43
44
|
const createEmptyCollectionState = () => ({
|
|
44
45
|
items: {},
|
|
45
46
|
tree: [],
|
|
@@ -210,6 +211,17 @@ const LAYOUT_TYPE_KEYS = [
|
|
|
210
211
|
];
|
|
211
212
|
const LAYOUT_ELEMENT_TEXT_STYLE_ALIGN_KEYS = ["left", "center", "right"];
|
|
212
213
|
const LAYOUT_TEXT_REVEAL_EFFECT_KEYS = ["typewriter", "softWipe", "none"];
|
|
214
|
+
const CONTROL_KEYBOARD_KEYS = [
|
|
215
|
+
"enter",
|
|
216
|
+
"space",
|
|
217
|
+
"esc",
|
|
218
|
+
"ctrl",
|
|
219
|
+
"left",
|
|
220
|
+
"right",
|
|
221
|
+
"up",
|
|
222
|
+
"down",
|
|
223
|
+
];
|
|
224
|
+
const CONTROL_KEYBOARD_KEY_SET = new Set(CONTROL_KEYBOARD_KEYS);
|
|
213
225
|
const LAYOUT_ELEMENT_BASE_TYPES = [
|
|
214
226
|
"folder",
|
|
215
227
|
"container",
|
|
@@ -973,7 +985,7 @@ const validateSpritesheetAnimationMap = ({
|
|
|
973
985
|
{
|
|
974
986
|
const result = validateAllowedKeys({
|
|
975
987
|
value: animation,
|
|
976
|
-
allowedKeys: ["frames", "animationSpeed", "loop"],
|
|
988
|
+
allowedKeys: ["frames", "animationSpeed", "fps", "loop"],
|
|
977
989
|
path: animationPath,
|
|
978
990
|
errorFactory,
|
|
979
991
|
});
|
|
@@ -1009,6 +1021,13 @@ const validateSpritesheetAnimationMap = ({
|
|
|
1009
1021
|
);
|
|
1010
1022
|
}
|
|
1011
1023
|
|
|
1024
|
+
if (animation.fps !== undefined && !isPositiveFiniteNumber(animation.fps)) {
|
|
1025
|
+
return invalidFromErrorFactory(
|
|
1026
|
+
errorFactory,
|
|
1027
|
+
`${animationPath}.fps must be a positive finite number when provided`,
|
|
1028
|
+
);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1012
1031
|
if (animation.loop !== undefined && typeof animation.loop !== "boolean") {
|
|
1013
1032
|
return invalidFromErrorFactory(
|
|
1014
1033
|
errorFactory,
|
|
@@ -4501,6 +4520,13 @@ const validateKeyboardMap = ({ value, path, errorFactory }) => {
|
|
|
4501
4520
|
);
|
|
4502
4521
|
}
|
|
4503
4522
|
|
|
4523
|
+
if (!CONTROL_KEYBOARD_KEY_SET.has(key)) {
|
|
4524
|
+
return invalidFromErrorFactory(
|
|
4525
|
+
errorFactory,
|
|
4526
|
+
`${path}.${key} must be one of: ${CONTROL_KEYBOARD_KEYS.map((value) => `'${value}'`).join(", ")}`,
|
|
4527
|
+
);
|
|
4528
|
+
}
|
|
4529
|
+
|
|
4504
4530
|
if (!isPlainObject(interaction)) {
|
|
4505
4531
|
return invalidFromErrorFactory(
|
|
4506
4532
|
errorFactory,
|
|
@@ -4686,6 +4712,7 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
4686
4712
|
"preview",
|
|
4687
4713
|
"elements",
|
|
4688
4714
|
"keyboard",
|
|
4715
|
+
"keyup",
|
|
4689
4716
|
],
|
|
4690
4717
|
path: itemPath,
|
|
4691
4718
|
errorFactory,
|
|
@@ -4780,6 +4807,17 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
4780
4807
|
return result;
|
|
4781
4808
|
}
|
|
4782
4809
|
}
|
|
4810
|
+
|
|
4811
|
+
{
|
|
4812
|
+
const result = validateKeyboardMap({
|
|
4813
|
+
value: item.keyup,
|
|
4814
|
+
path: `${itemPath}.keyup`,
|
|
4815
|
+
errorFactory,
|
|
4816
|
+
});
|
|
4817
|
+
if (result?.valid === false) {
|
|
4818
|
+
return result;
|
|
4819
|
+
}
|
|
4820
|
+
}
|
|
4783
4821
|
}
|
|
4784
4822
|
}
|
|
4785
4823
|
};
|
|
@@ -10043,6 +10081,7 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
10043
10081
|
"preview",
|
|
10044
10082
|
"elements",
|
|
10045
10083
|
"keyboard",
|
|
10084
|
+
"keyup",
|
|
10046
10085
|
],
|
|
10047
10086
|
path: "payload.data",
|
|
10048
10087
|
errorFactory,
|
|
@@ -10123,6 +10162,17 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
10123
10162
|
return result;
|
|
10124
10163
|
}
|
|
10125
10164
|
}
|
|
10165
|
+
|
|
10166
|
+
{
|
|
10167
|
+
const result = validateKeyboardMap({
|
|
10168
|
+
value: data.keyup,
|
|
10169
|
+
path: "payload.data.keyup",
|
|
10170
|
+
errorFactory,
|
|
10171
|
+
});
|
|
10172
|
+
if (result?.valid === false) {
|
|
10173
|
+
return result;
|
|
10174
|
+
}
|
|
10175
|
+
}
|
|
10126
10176
|
}
|
|
10127
10177
|
};
|
|
10128
10178
|
|
|
@@ -10135,6 +10185,7 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
10135
10185
|
"description",
|
|
10136
10186
|
"tagIds",
|
|
10137
10187
|
"keyboard",
|
|
10188
|
+
"keyup",
|
|
10138
10189
|
"thumbnailFileId",
|
|
10139
10190
|
"preview",
|
|
10140
10191
|
],
|
|
@@ -10199,6 +10250,17 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
10199
10250
|
}
|
|
10200
10251
|
}
|
|
10201
10252
|
|
|
10253
|
+
{
|
|
10254
|
+
const result = validateKeyboardMap({
|
|
10255
|
+
value: data.keyup,
|
|
10256
|
+
path: "payload.data.keyup",
|
|
10257
|
+
errorFactory,
|
|
10258
|
+
});
|
|
10259
|
+
if (result?.valid === false) {
|
|
10260
|
+
return result;
|
|
10261
|
+
}
|
|
10262
|
+
}
|
|
10263
|
+
|
|
10202
10264
|
{
|
|
10203
10265
|
const result = validateOptionalUniqueIdArray({
|
|
10204
10266
|
value: data.tagIds,
|