@routevn/creator-model 1.6.3 → 1.7.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/package.json +1 -1
- package/src/model.js +115 -4
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -347,6 +347,7 @@ const LAYOUT_TYPE_KEYS = [
|
|
|
347
347
|
"dialogue-nvl",
|
|
348
348
|
"choice",
|
|
349
349
|
"history",
|
|
350
|
+
"input",
|
|
350
351
|
];
|
|
351
352
|
const LAYOUT_ELEMENT_TEXT_STYLE_ALIGN_KEYS = ["left", "center", "right"];
|
|
352
353
|
const LAYOUT_TEXT_REVEAL_EFFECT_KEYS = ["typewriter", "softWipe", "none"];
|
|
@@ -371,6 +372,7 @@ const LAYOUT_ELEMENT_BASE_TYPES = [
|
|
|
371
372
|
"spritesheet-animation",
|
|
372
373
|
"text",
|
|
373
374
|
"text-revealing",
|
|
375
|
+
"input",
|
|
374
376
|
"slider",
|
|
375
377
|
"text-ref-character-name",
|
|
376
378
|
"text-revealing-ref-dialogue-content",
|
|
@@ -383,17 +385,19 @@ const LAYOUT_ELEMENT_BASE_TYPES = [
|
|
|
383
385
|
"sprite-ref-save-load-slot-image",
|
|
384
386
|
"fragment-ref",
|
|
385
387
|
"container-ref-choice-item",
|
|
388
|
+
"container-ref-choice-single-item",
|
|
386
389
|
"container-ref-save-load-slot",
|
|
387
390
|
"container-ref-dialogue-line",
|
|
388
391
|
"container-ref-history-line",
|
|
389
392
|
"container-ref-confirm-dialog-ok",
|
|
390
393
|
"container-ref-confirm-dialog-cancel",
|
|
391
394
|
];
|
|
392
|
-
export const SCHEMA_VERSION =
|
|
395
|
+
export const SCHEMA_VERSION = 7;
|
|
393
396
|
const LAYOUT_CONTAINER_ELEMENT_TYPES = [
|
|
394
397
|
"folder",
|
|
395
398
|
"container",
|
|
396
399
|
"container-ref-choice-item",
|
|
400
|
+
"container-ref-choice-single-item",
|
|
397
401
|
"container-ref-save-load-slot",
|
|
398
402
|
"container-ref-dialogue-line",
|
|
399
403
|
"container-ref-history-line",
|
|
@@ -3447,6 +3451,13 @@ const validateLayoutElementData = ({
|
|
|
3447
3451
|
"textStyleId",
|
|
3448
3452
|
"hoverTextStyleId",
|
|
3449
3453
|
"clickTextStyleId",
|
|
3454
|
+
"field",
|
|
3455
|
+
"value",
|
|
3456
|
+
"placeholder",
|
|
3457
|
+
"multiline",
|
|
3458
|
+
"disabled",
|
|
3459
|
+
"maxLength",
|
|
3460
|
+
"padding",
|
|
3450
3461
|
"conditionalOverrides",
|
|
3451
3462
|
"direction",
|
|
3452
3463
|
"gapX",
|
|
@@ -3458,6 +3469,13 @@ const validateLayoutElementData = ({
|
|
|
3458
3469
|
"rightClick",
|
|
3459
3470
|
"scrollUp",
|
|
3460
3471
|
"scrollDown",
|
|
3472
|
+
"submit",
|
|
3473
|
+
"focusEvent",
|
|
3474
|
+
"blurEvent",
|
|
3475
|
+
"selectionChange",
|
|
3476
|
+
"compositionStart",
|
|
3477
|
+
"compositionUpdate",
|
|
3478
|
+
"compositionEnd",
|
|
3461
3479
|
"anchorToBottom",
|
|
3462
3480
|
"thumbImageId",
|
|
3463
3481
|
"barImageId",
|
|
@@ -3473,6 +3491,7 @@ const validateLayoutElementData = ({
|
|
|
3473
3491
|
"paginationMode",
|
|
3474
3492
|
"paginationVariableId",
|
|
3475
3493
|
"paginationSize",
|
|
3494
|
+
"choiceItemIndex",
|
|
3476
3495
|
"$when",
|
|
3477
3496
|
"change",
|
|
3478
3497
|
];
|
|
@@ -3524,7 +3543,9 @@ const validateLayoutElementData = ({
|
|
|
3524
3543
|
"max",
|
|
3525
3544
|
"step",
|
|
3526
3545
|
"paginationSize",
|
|
3546
|
+
"choiceItemIndex",
|
|
3527
3547
|
"opacity",
|
|
3548
|
+
"maxLength",
|
|
3528
3549
|
]) {
|
|
3529
3550
|
if (data[key] !== undefined && !isFiniteNumber(data[key])) {
|
|
3530
3551
|
return invalidFromErrorFactory(
|
|
@@ -3534,6 +3555,18 @@ const validateLayoutElementData = ({
|
|
|
3534
3555
|
}
|
|
3535
3556
|
}
|
|
3536
3557
|
|
|
3558
|
+
if (
|
|
3559
|
+
data.choiceItemIndex !== undefined &&
|
|
3560
|
+
(!Number.isInteger(data.choiceItemIndex) ||
|
|
3561
|
+
data.choiceItemIndex < 0 ||
|
|
3562
|
+
data.choiceItemIndex > 19)
|
|
3563
|
+
) {
|
|
3564
|
+
return invalidFromErrorFactory(
|
|
3565
|
+
errorFactory,
|
|
3566
|
+
`${path}.choiceItemIndex must be an integer between 0 and 19 when provided`,
|
|
3567
|
+
);
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3537
3570
|
if (
|
|
3538
3571
|
data.aspectRatioLock !== undefined &&
|
|
3539
3572
|
(!isFiniteNumber(data.aspectRatioLock) || data.aspectRatioLock <= 0)
|
|
@@ -3598,6 +3631,9 @@ const validateLayoutElementData = ({
|
|
|
3598
3631
|
"textStyleId",
|
|
3599
3632
|
"hoverTextStyleId",
|
|
3600
3633
|
"clickTextStyleId",
|
|
3634
|
+
"field",
|
|
3635
|
+
"value",
|
|
3636
|
+
"placeholder",
|
|
3601
3637
|
"containerType",
|
|
3602
3638
|
"variableId",
|
|
3603
3639
|
"fragmentLayoutId",
|
|
@@ -3652,6 +3688,18 @@ const validateLayoutElementData = ({
|
|
|
3652
3688
|
}
|
|
3653
3689
|
}
|
|
3654
3690
|
|
|
3691
|
+
if (data.type === "input") {
|
|
3692
|
+
if (
|
|
3693
|
+
(!allowPartial || data.field !== undefined) &&
|
|
3694
|
+
!isNonEmptyString(data.field)
|
|
3695
|
+
) {
|
|
3696
|
+
return invalidFromErrorFactory(
|
|
3697
|
+
errorFactory,
|
|
3698
|
+
`${path}.field must be a non-empty string`,
|
|
3699
|
+
);
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3655
3703
|
if (data.conditionalOverrides !== undefined) {
|
|
3656
3704
|
if (!Array.isArray(data.conditionalOverrides)) {
|
|
3657
3705
|
return invalidFromErrorFactory(
|
|
@@ -3953,6 +4001,27 @@ const validateLayoutElementData = ({
|
|
|
3953
4001
|
}
|
|
3954
4002
|
}
|
|
3955
4003
|
|
|
4004
|
+
for (const key of [
|
|
4005
|
+
"submit",
|
|
4006
|
+
"focusEvent",
|
|
4007
|
+
"blurEvent",
|
|
4008
|
+
"selectionChange",
|
|
4009
|
+
"compositionStart",
|
|
4010
|
+
"compositionUpdate",
|
|
4011
|
+
"compositionEnd",
|
|
4012
|
+
]) {
|
|
4013
|
+
if (data[key] !== undefined) {
|
|
4014
|
+
const result = validateLayoutElementInteraction({
|
|
4015
|
+
interaction: data[key],
|
|
4016
|
+
path: `${path}.${key}`,
|
|
4017
|
+
errorFactory,
|
|
4018
|
+
});
|
|
4019
|
+
if (result?.valid === false) {
|
|
4020
|
+
return result;
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
|
|
3956
4025
|
if (
|
|
3957
4026
|
data.anchorToBottom !== undefined &&
|
|
3958
4027
|
typeof data.anchorToBottom !== "boolean"
|
|
@@ -3963,6 +4032,33 @@ const validateLayoutElementData = ({
|
|
|
3963
4032
|
);
|
|
3964
4033
|
}
|
|
3965
4034
|
|
|
4035
|
+
for (const key of ["multiline", "disabled"]) {
|
|
4036
|
+
if (data[key] !== undefined && typeof data[key] !== "boolean") {
|
|
4037
|
+
return invalidFromErrorFactory(
|
|
4038
|
+
errorFactory,
|
|
4039
|
+
`${path}.${key} must be a boolean when provided`,
|
|
4040
|
+
);
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
if (data.maxLength !== undefined && data.maxLength < 0) {
|
|
4045
|
+
return invalidFromErrorFactory(
|
|
4046
|
+
errorFactory,
|
|
4047
|
+
`${path}.maxLength must be a finite number greater than or equal to 0 when provided`,
|
|
4048
|
+
);
|
|
4049
|
+
}
|
|
4050
|
+
|
|
4051
|
+
if (
|
|
4052
|
+
data.padding !== undefined &&
|
|
4053
|
+
!isFiniteNumber(data.padding) &&
|
|
4054
|
+
!isPlainObject(data.padding)
|
|
4055
|
+
) {
|
|
4056
|
+
return invalidFromErrorFactory(
|
|
4057
|
+
errorFactory,
|
|
4058
|
+
`${path}.padding must be a finite number or object when provided`,
|
|
4059
|
+
);
|
|
4060
|
+
}
|
|
4061
|
+
|
|
3966
4062
|
if (data.textStyle !== undefined) {
|
|
3967
4063
|
{
|
|
3968
4064
|
const result = validateLayoutElementTextStyle({
|
|
@@ -4044,6 +4140,13 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
|
|
|
4044
4140
|
"textStyleId",
|
|
4045
4141
|
"hoverTextStyleId",
|
|
4046
4142
|
"clickTextStyleId",
|
|
4143
|
+
"field",
|
|
4144
|
+
"value",
|
|
4145
|
+
"placeholder",
|
|
4146
|
+
"multiline",
|
|
4147
|
+
"disabled",
|
|
4148
|
+
"maxLength",
|
|
4149
|
+
"padding",
|
|
4047
4150
|
"conditionalOverrides",
|
|
4048
4151
|
"direction",
|
|
4049
4152
|
"gapX",
|
|
@@ -4055,6 +4158,13 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
|
|
|
4055
4158
|
"rightClick",
|
|
4056
4159
|
"scrollUp",
|
|
4057
4160
|
"scrollDown",
|
|
4161
|
+
"submit",
|
|
4162
|
+
"focusEvent",
|
|
4163
|
+
"blurEvent",
|
|
4164
|
+
"selectionChange",
|
|
4165
|
+
"compositionStart",
|
|
4166
|
+
"compositionUpdate",
|
|
4167
|
+
"compositionEnd",
|
|
4058
4168
|
"anchorToBottom",
|
|
4059
4169
|
"thumbImageId",
|
|
4060
4170
|
"barImageId",
|
|
@@ -4069,6 +4179,7 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
|
|
|
4069
4179
|
"paginationMode",
|
|
4070
4180
|
"paginationVariableId",
|
|
4071
4181
|
"paginationSize",
|
|
4182
|
+
"choiceItemIndex",
|
|
4072
4183
|
"$when",
|
|
4073
4184
|
"change",
|
|
4074
4185
|
],
|
|
@@ -5257,7 +5368,7 @@ const validateLayoutItems = ({ items, path, errorFactory }) => {
|
|
|
5257
5368
|
if (!LAYOUT_TYPE_KEYS.includes(item.layoutType)) {
|
|
5258
5369
|
return invalidFromErrorFactory(
|
|
5259
5370
|
errorFactory,
|
|
5260
|
-
`${itemPath}.layoutType must be 'general', 'save-load', 'confirmDialog', 'dialogue-adv', 'dialogue-nvl', 'choice', or '
|
|
5371
|
+
`${itemPath}.layoutType must be 'general', 'save-load', 'confirmDialog', 'dialogue-adv', 'dialogue-nvl', 'choice', 'history', or 'input'`,
|
|
5261
5372
|
);
|
|
5262
5373
|
}
|
|
5263
5374
|
|
|
@@ -10776,7 +10887,7 @@ const validateLayoutCreateData = ({ data, errorFactory }) => {
|
|
|
10776
10887
|
if (!LAYOUT_TYPE_KEYS.includes(data.layoutType)) {
|
|
10777
10888
|
return invalidFromErrorFactory(
|
|
10778
10889
|
errorFactory,
|
|
10779
|
-
"payload.data.layoutType must be 'general', 'save-load', 'confirmDialog', 'dialogue-adv', 'dialogue-nvl', 'choice', or '
|
|
10890
|
+
"payload.data.layoutType must be 'general', 'save-load', 'confirmDialog', 'dialogue-adv', 'dialogue-nvl', 'choice', 'history', or 'input'",
|
|
10780
10891
|
);
|
|
10781
10892
|
}
|
|
10782
10893
|
|
|
@@ -10892,7 +11003,7 @@ const validateLayoutUpdateData = ({ data, errorFactory }) => {
|
|
|
10892
11003
|
) {
|
|
10893
11004
|
return invalidFromErrorFactory(
|
|
10894
11005
|
errorFactory,
|
|
10895
|
-
"payload.data.layoutType must be 'general', 'save-load', 'confirmDialog', 'dialogue-adv', 'dialogue-nvl', 'choice', or '
|
|
11006
|
+
"payload.data.layoutType must be 'general', 'save-load', 'confirmDialog', 'dialogue-adv', 'dialogue-nvl', 'choice', 'history', or 'input' when provided",
|
|
10896
11007
|
);
|
|
10897
11008
|
}
|
|
10898
11009
|
|