@routevn/creator-model 1.8.1 → 1.10.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/model.js +38 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routevn/creator-model",
3
- "version": "1.8.1",
3
+ "version": "1.10.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/model.js CHANGED
@@ -394,7 +394,7 @@ const LAYOUT_ELEMENT_BASE_TYPES = [
394
394
  "container-ref-confirm-dialog-ok",
395
395
  "container-ref-confirm-dialog-cancel",
396
396
  ];
397
- export const SCHEMA_VERSION = 8;
397
+ export const SCHEMA_VERSION = 10;
398
398
  const LAYOUT_CONTAINER_ELEMENT_TYPES = [
399
399
  "folder",
400
400
  "container",
@@ -3800,6 +3800,7 @@ const validateLayoutElementData = ({
3800
3800
  "scaleX",
3801
3801
  "scaleY",
3802
3802
  "rotation",
3803
+ "hidden",
3803
3804
  "opacity",
3804
3805
  "blur",
3805
3806
  "fill",
@@ -3817,6 +3818,7 @@ const validateLayoutElementData = ({
3817
3818
  "clickImageId",
3818
3819
  "hoverSoundId",
3819
3820
  "clickSoundId",
3821
+ "revealSoundId",
3820
3822
  "textStyleId",
3821
3823
  "hoverTextStyleId",
3822
3824
  "clickTextStyleId",
@@ -3896,6 +3898,13 @@ const validateLayoutElementData = ({
3896
3898
  }
3897
3899
  }
3898
3900
 
3901
+ if (data.hidden !== undefined && typeof data.hidden !== "boolean") {
3902
+ return invalidFromErrorFactory(
3903
+ errorFactory,
3904
+ `${path}.hidden must be a boolean when provided`,
3905
+ );
3906
+ }
3907
+
3899
3908
  for (const key of [
3900
3909
  "x",
3901
3910
  "y",
@@ -4044,6 +4053,7 @@ const validateLayoutElementData = ({
4044
4053
  "clickImageId",
4045
4054
  "hoverSoundId",
4046
4055
  "clickSoundId",
4056
+ "revealSoundId",
4047
4057
  "textStyleId",
4048
4058
  "hoverTextStyleId",
4049
4059
  "clickTextStyleId",
@@ -4544,6 +4554,7 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
4544
4554
  "scaleX",
4545
4555
  "scaleY",
4546
4556
  "rotation",
4557
+ "hidden",
4547
4558
  "opacity",
4548
4559
  "blur",
4549
4560
  "fill",
@@ -4562,6 +4573,7 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
4562
4573
  "clickImageId",
4563
4574
  "hoverSoundId",
4564
4575
  "clickSoundId",
4576
+ "revealSoundId",
4565
4577
  "textStyleId",
4566
4578
  "hoverTextStyleId",
4567
4579
  "clickTextStyleId",
@@ -8060,7 +8072,7 @@ export const assertInvariants = ({ state }) => {
8060
8072
  }
8061
8073
  }
8062
8074
 
8063
- for (const field of ["hoverSoundId", "clickSoundId"]) {
8075
+ for (const field of ["hoverSoundId", "clickSoundId", "revealSoundId"]) {
8064
8076
  if (element[field] !== undefined) {
8065
8077
  const result = assertSoundReference({
8066
8078
  ownerIdField,
@@ -12301,6 +12313,22 @@ const validateVisualElementReferenceTargets = ({
12301
12313
  }
12302
12314
  }
12303
12315
 
12316
+ if (data.revealSoundId !== undefined) {
12317
+ const sound = state.sounds.items[data.revealSoundId];
12318
+ if (!isPlainObject(sound) || sound.type === "folder") {
12319
+ return invalidFromErrorFactory(
12320
+ errorFactory,
12321
+ `${ownerLabel} element revealSoundId must reference an existing non-folder sound`,
12322
+ {
12323
+ [ownerIdField]: ownerId,
12324
+ elementId,
12325
+ field: "revealSoundId",
12326
+ targetId: data.revealSoundId,
12327
+ },
12328
+ );
12329
+ }
12330
+ }
12331
+
12304
12332
  if (data.thumbImageId !== undefined) {
12305
12333
  const image = state.images.items[data.thumbImageId];
12306
12334
  if (!isPlainObject(image) || image.type === "folder") {
@@ -19983,10 +20011,12 @@ const COMMAND_DEFINITIONS = [
19983
20011
 
19984
20012
  if (
19985
20013
  currentItem.type === "folder" &&
19986
- Object.keys(payload.data).some((key) => key !== "name")
20014
+ Object.keys(payload.data).some(
20015
+ (key) => key !== "name" && key !== "hidden",
20016
+ )
19987
20017
  ) {
19988
20018
  return invalidPrecondition(
19989
- "folder layout elements cannot update non-name fields",
20019
+ "folder layout elements can only update name and hidden fields",
19990
20020
  );
19991
20021
  }
19992
20022
 
@@ -20342,10 +20372,12 @@ const COMMAND_DEFINITIONS = [
20342
20372
 
20343
20373
  if (
20344
20374
  currentItem.type === "folder" &&
20345
- Object.keys(payload.data).some((key) => key !== "name")
20375
+ Object.keys(payload.data).some(
20376
+ (key) => key !== "name" && key !== "hidden",
20377
+ )
20346
20378
  ) {
20347
20379
  return invalidPrecondition(
20348
- "folder control elements cannot update non-name fields",
20380
+ "folder control elements can only update name and hidden fields",
20349
20381
  );
20350
20382
  }
20351
20383