@routevn/creator-model 1.6.0 → 1.6.3

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 +92 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routevn/creator-model",
3
- "version": "1.6.0",
3
+ "version": "1.6.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/model.js CHANGED
@@ -283,11 +283,18 @@ const UPDATE_TWEEN_PROPERTY_KEYS = [
283
283
  "alpha",
284
284
  "x",
285
285
  "y",
286
+ "translateX",
287
+ "translateY",
286
288
  "scaleX",
287
289
  "scaleY",
288
290
  "rotation",
291
+ "blurX",
292
+ "blurY",
293
+ "uProgress",
289
294
  ];
290
295
  const TRANSITION_TWEEN_PROPERTY_KEYS = [
296
+ "x",
297
+ "y",
291
298
  "translateX",
292
299
  "translateY",
293
300
  "alpha",
@@ -343,6 +350,7 @@ const LAYOUT_TYPE_KEYS = [
343
350
  ];
344
351
  const LAYOUT_ELEMENT_TEXT_STYLE_ALIGN_KEYS = ["left", "center", "right"];
345
352
  const LAYOUT_TEXT_REVEAL_EFFECT_KEYS = ["typewriter", "softWipe", "none"];
353
+ const LAYOUT_ELEMENT_BLUR_KERNEL_SIZE_OPTIONS = [5, 7, 9, 11, 13, 15];
346
354
  const CONTROL_KEYBOARD_KEYS = [
347
355
  "enter",
348
356
  "space",
@@ -3348,6 +3356,56 @@ const validateLayoutElementInteraction = ({
3348
3356
  }
3349
3357
  };
3350
3358
 
3359
+ const validateLayoutElementBlur = ({ blur, path, errorFactory }) => {
3360
+ if (!isPlainObject(blur)) {
3361
+ return invalidFromErrorFactory(
3362
+ errorFactory,
3363
+ `${path} must be an object when provided`,
3364
+ );
3365
+ }
3366
+
3367
+ {
3368
+ const result = validateAllowedKeys({
3369
+ value: blur,
3370
+ allowedKeys: ["x", "y", "quality", "kernelSize", "repeatEdgePixels"],
3371
+ path,
3372
+ errorFactory,
3373
+ });
3374
+ if (result?.valid === false) {
3375
+ return result;
3376
+ }
3377
+ }
3378
+
3379
+ for (const key of ["x", "y", "quality"]) {
3380
+ if (blur[key] !== undefined && !isFiniteNumber(blur[key])) {
3381
+ return invalidFromErrorFactory(
3382
+ errorFactory,
3383
+ `${path}.${key} must be a finite number when provided`,
3384
+ );
3385
+ }
3386
+ }
3387
+
3388
+ if (
3389
+ blur.kernelSize !== undefined &&
3390
+ !LAYOUT_ELEMENT_BLUR_KERNEL_SIZE_OPTIONS.includes(blur.kernelSize)
3391
+ ) {
3392
+ return invalidFromErrorFactory(
3393
+ errorFactory,
3394
+ `${path}.kernelSize must be one of ${LAYOUT_ELEMENT_BLUR_KERNEL_SIZE_OPTIONS.join(", ")} when provided`,
3395
+ );
3396
+ }
3397
+
3398
+ if (
3399
+ blur.repeatEdgePixels !== undefined &&
3400
+ typeof blur.repeatEdgePixels !== "boolean"
3401
+ ) {
3402
+ return invalidFromErrorFactory(
3403
+ errorFactory,
3404
+ `${path}.repeatEdgePixels must be a boolean when provided`,
3405
+ );
3406
+ }
3407
+ };
3408
+
3351
3409
  const validateLayoutElementData = ({
3352
3410
  data,
3353
3411
  path,
@@ -3372,6 +3430,7 @@ const validateLayoutElementData = ({
3372
3430
  "scaleY",
3373
3431
  "rotation",
3374
3432
  "opacity",
3433
+ "blur",
3375
3434
  "fill",
3376
3435
  "border",
3377
3436
  "text",
@@ -3506,6 +3565,26 @@ const validateLayoutElementData = ({
3506
3565
  );
3507
3566
  }
3508
3567
 
3568
+ if (data.blur !== undefined) {
3569
+ {
3570
+ const result = validateLayoutElementBlur({
3571
+ blur: data.blur,
3572
+ path: `${path}.blur`,
3573
+ errorFactory,
3574
+ });
3575
+ if (result?.valid === false) {
3576
+ return result;
3577
+ }
3578
+ }
3579
+
3580
+ if (data.type !== undefined && data.type !== "sprite") {
3581
+ return invalidFromErrorFactory(
3582
+ errorFactory,
3583
+ `${path}.blur can only be provided for sprite elements`,
3584
+ );
3585
+ }
3586
+ }
3587
+
3509
3588
  for (const key of [
3510
3589
  "text",
3511
3590
  "resourceId",
@@ -3947,6 +4026,7 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
3947
4026
  "scaleY",
3948
4027
  "rotation",
3949
4028
  "opacity",
4029
+ "blur",
3950
4030
  "fill",
3951
4031
  "border",
3952
4032
  "text",
@@ -11090,6 +11170,18 @@ const validateVisualElementReferenceTargets = ({
11090
11170
  state,
11091
11171
  errorFactory,
11092
11172
  }) => {
11173
+ if (data.blur !== undefined && data.type !== "sprite") {
11174
+ return invalidFromErrorFactory(
11175
+ errorFactory,
11176
+ `${ownerLabel} element blur can only be provided for sprite elements`,
11177
+ {
11178
+ [ownerIdField]: ownerId,
11179
+ elementId,
11180
+ field: "blur",
11181
+ },
11182
+ );
11183
+ }
11184
+
11093
11185
  if (
11094
11186
  data.type === "spritesheet-animation" ||
11095
11187
  data.resourceId !== undefined ||