@routevn/creator-model 1.13.0 → 1.13.2

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 +91 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routevn/creator-model",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/model.js CHANGED
@@ -1685,7 +1685,14 @@ const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
1685
1685
  {
1686
1686
  const result = validateAllowedKeys({
1687
1687
  value: keyframe,
1688
- allowedKeys: ["value", "duration", "delay", "easing", "relative"],
1688
+ allowedKeys: [
1689
+ "startValue",
1690
+ "value",
1691
+ "duration",
1692
+ "delay",
1693
+ "easing",
1694
+ "relative",
1695
+ ],
1689
1696
  path: keyframePath,
1690
1697
  errorFactory,
1691
1698
  });
@@ -1715,6 +1722,16 @@ const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
1715
1722
  );
1716
1723
  }
1717
1724
 
1725
+ if (
1726
+ keyframe.startValue !== undefined &&
1727
+ !isFiniteNumber(keyframe.startValue)
1728
+ ) {
1729
+ return invalidFromErrorFactory(
1730
+ errorFactory,
1731
+ `${keyframePath}.startValue must be a finite number when provided`,
1732
+ );
1733
+ }
1734
+
1718
1735
  if (!isFiniteNumber(keyframe.duration) || keyframe.duration < 1) {
1719
1736
  return invalidFromErrorFactory(
1720
1737
  errorFactory,
@@ -2476,6 +2493,31 @@ const validateAudioEffectAbsoluteValue = ({
2476
2493
  }
2477
2494
  };
2478
2495
 
2496
+ const validateAudioEffectInitialValue = ({
2497
+ value,
2498
+ property,
2499
+ path,
2500
+ errorFactory,
2501
+ }) => {
2502
+ if (value === undefined) {
2503
+ return;
2504
+ }
2505
+
2506
+ if (!isFiniteNumber(value)) {
2507
+ return invalidFromErrorFactory(
2508
+ errorFactory,
2509
+ `${path} must be a finite number when provided`,
2510
+ );
2511
+ }
2512
+
2513
+ return validateAudioEffectAbsoluteValue({
2514
+ value,
2515
+ property,
2516
+ path,
2517
+ errorFactory,
2518
+ });
2519
+ };
2520
+
2479
2521
  const validateAudioEffectKeyframes = ({
2480
2522
  keyframes,
2481
2523
  property,
@@ -2635,9 +2677,9 @@ const validateAudioEffectTween = ({ tween, path, errorFactory }) => {
2635
2677
  }
2636
2678
 
2637
2679
  {
2638
- const result = validateExactKeys({
2680
+ const result = validateAllowedKeys({
2639
2681
  value: config,
2640
- expectedKeys: ["keyframes"],
2682
+ allowedKeys: ["initialValue", "keyframes"],
2641
2683
  path: `${path}.${property}`,
2642
2684
  errorFactory,
2643
2685
  });
@@ -2646,6 +2688,25 @@ const validateAudioEffectTween = ({ tween, path, errorFactory }) => {
2646
2688
  }
2647
2689
  }
2648
2690
 
2691
+ if (!Object.hasOwn(config, "keyframes")) {
2692
+ return invalidFromErrorFactory(
2693
+ errorFactory,
2694
+ `${path}.${property}.keyframes is required`,
2695
+ );
2696
+ }
2697
+
2698
+ {
2699
+ const result = validateAudioEffectInitialValue({
2700
+ value: config.initialValue,
2701
+ property,
2702
+ path: `${path}.${property}.initialValue`,
2703
+ errorFactory,
2704
+ });
2705
+ if (result?.valid === false) {
2706
+ return result;
2707
+ }
2708
+ }
2709
+
2649
2710
  {
2650
2711
  const result = validateAudioEffectKeyframes({
2651
2712
  keyframes: config.keyframes,
@@ -2667,9 +2728,9 @@ const validateAudioEffectFade = ({ fade, path, side, errorFactory }) => {
2667
2728
 
2668
2729
  if (Object.hasOwn(fade, "keyframes")) {
2669
2730
  {
2670
- const result = validateExactKeys({
2731
+ const result = validateAllowedKeys({
2671
2732
  value: fade,
2672
- expectedKeys: ["keyframes"],
2733
+ allowedKeys: ["initialValue", "keyframes"],
2673
2734
  path,
2674
2735
  errorFactory,
2675
2736
  });
@@ -2678,6 +2739,18 @@ const validateAudioEffectFade = ({ fade, path, side, errorFactory }) => {
2678
2739
  }
2679
2740
  }
2680
2741
 
2742
+ {
2743
+ const result = validateAudioEffectInitialValue({
2744
+ value: fade.initialValue,
2745
+ property: "volume",
2746
+ path: `${path}.initialValue`,
2747
+ errorFactory,
2748
+ });
2749
+ if (result?.valid === false) {
2750
+ return result;
2751
+ }
2752
+ }
2753
+
2681
2754
  {
2682
2755
  const result = validateAudioEffectKeyframes({
2683
2756
  keyframes: fade.keyframes,
@@ -2705,7 +2778,7 @@ const validateAudioEffectFade = ({ fade, path, side, errorFactory }) => {
2705
2778
  {
2706
2779
  const result = validateAllowedKeys({
2707
2780
  value: fade,
2708
- allowedKeys: ["delay", "duration", "easing"],
2781
+ allowedKeys: ["initialValue", "delay", "duration", "easing"],
2709
2782
  path,
2710
2783
  errorFactory,
2711
2784
  });
@@ -2714,6 +2787,18 @@ const validateAudioEffectFade = ({ fade, path, side, errorFactory }) => {
2714
2787
  }
2715
2788
  }
2716
2789
 
2790
+ {
2791
+ const result = validateAudioEffectInitialValue({
2792
+ value: fade.initialValue,
2793
+ property: "volume",
2794
+ path: `${path}.initialValue`,
2795
+ errorFactory,
2796
+ });
2797
+ if (result?.valid === false) {
2798
+ return result;
2799
+ }
2800
+ }
2801
+
2717
2802
  if (!Object.hasOwn(fade, "duration")) {
2718
2803
  return invalidFromErrorFactory(
2719
2804
  errorFactory,