@routevn/creator-model 1.13.2 → 1.13.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 (3) hide show
  1. package/README.md +18 -8
  2. package/package.json +1 -1
  3. package/src/model.js +12 -148
package/README.md CHANGED
@@ -354,8 +354,17 @@ Audio effects are foldered resources stored in `audioEffects.items` and
354
354
  },
355
355
  audioEffect: {
356
356
  type: "transition",
357
- prev: { fade: { duration: 600, easing: "easeInOutSine" } },
358
- next: { fade: { duration: 900, easing: "easeInOutSine" } },
357
+ prev: {
358
+ volume: {
359
+ keyframes: [{ value: 0, duration: 600, easing: "easeInOutSine" }],
360
+ },
361
+ },
362
+ next: {
363
+ volume: {
364
+ initialValue: 0,
365
+ keyframes: [{ value: 100, duration: 900, easing: "easeInOutSine" }],
366
+ },
367
+ },
359
368
  },
360
369
  }
361
370
  ```
@@ -365,12 +374,13 @@ transition effect, or a single `target` sound slot for an update effect. Each
365
374
  slot is an object containing a `soundId`.
366
375
 
367
376
  `audioEffect.type` is either `transition` or `update`. Transition effects have
368
- at least one `prev.fade` or `next.fade`. Update effects tween one or more of
369
- `volume`, `pan`, and `playbackRate`; each property has non-empty keyframes and
370
- must finish with an absolute numeric keyframe. That final number becomes the
371
- persistent BGM property value after the effect finishes. Absolute volume values
372
- are bounded to `0..100`, pan to `-1..1`, and playback rate to `>= 0`; relative
373
- keyframes represent unbounded numeric deltas and cannot be final.
377
+ at least one property under `prev` or `next`; update effects place properties
378
+ under `tween`. Both support only `volume`, `pan`, and `playbackRate`. Each
379
+ property has non-empty keyframes and must finish with an absolute numeric
380
+ keyframe. A final `tween` or `next` value becomes the persistent BGM property
381
+ value after the effect finishes. Absolute volume values are bounded to
382
+ `0..100`, pan to `-1..1`, and playback rate to `>= 0`; relative keyframes
383
+ represent unbounded numeric deltas and cannot be final.
374
384
 
375
385
  ## Current Scope
376
386
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routevn/creator-model",
3
- "version": "1.13.2",
3
+ "version": "1.13.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/model.js CHANGED
@@ -344,7 +344,7 @@ const ANIMATION_EASING_KEYS = [
344
344
  "easeOutElastic",
345
345
  "easeInOutElastic",
346
346
  ];
347
- const AUDIO_EFFECT_TWEEN_PROPERTY_KEYS = ["volume", "pan", "playbackRate"];
347
+ const AUDIO_EFFECT_PROPERTY_KEYS = ["volume", "pan", "playbackRate"];
348
348
  const VARIABLE_SCOPE_KEYS = ["context", "device", "account"];
349
349
  const VARIABLE_TYPE_KEYS = ["string", "number", "boolean", "object"];
350
350
  const LAYOUT_TYPE_KEYS = [
@@ -2656,23 +2656,23 @@ const validateAudioEffectKeyframes = ({
2656
2656
  }
2657
2657
  };
2658
2658
 
2659
- const validateAudioEffectTween = ({ tween, path, errorFactory }) => {
2660
- if (!isPlainObject(tween)) {
2659
+ const validateAudioEffectPropertyTracks = ({ tracks, path, errorFactory }) => {
2660
+ if (!isPlainObject(tracks)) {
2661
2661
  return invalidFromErrorFactory(errorFactory, `${path} must be an object`);
2662
2662
  }
2663
2663
 
2664
- if (Object.keys(tween).length === 0) {
2664
+ if (Object.keys(tracks).length === 0) {
2665
2665
  return invalidFromErrorFactory(
2666
2666
  errorFactory,
2667
- `${path} must contain at least one tween property`,
2667
+ `${path} must contain at least one audio property`,
2668
2668
  );
2669
2669
  }
2670
2670
 
2671
- for (const [property, config] of Object.entries(tween)) {
2672
- if (!AUDIO_EFFECT_TWEEN_PROPERTY_KEYS.includes(property)) {
2671
+ for (const [property, config] of Object.entries(tracks)) {
2672
+ if (!AUDIO_EFFECT_PROPERTY_KEYS.includes(property)) {
2673
2673
  return invalidFromErrorFactory(
2674
2674
  errorFactory,
2675
- `${path}.${property} is not a supported audio effect tween property`,
2675
+ `${path}.${property} is not a supported audio effect property`,
2676
2676
  );
2677
2677
  }
2678
2678
 
@@ -2721,141 +2721,6 @@ const validateAudioEffectTween = ({ tween, path, errorFactory }) => {
2721
2721
  }
2722
2722
  };
2723
2723
 
2724
- const validateAudioEffectFade = ({ fade, path, side, errorFactory }) => {
2725
- if (!isPlainObject(fade)) {
2726
- return invalidFromErrorFactory(errorFactory, `${path} must be an object`);
2727
- }
2728
-
2729
- if (Object.hasOwn(fade, "keyframes")) {
2730
- {
2731
- const result = validateAllowedKeys({
2732
- value: fade,
2733
- allowedKeys: ["initialValue", "keyframes"],
2734
- path,
2735
- errorFactory,
2736
- });
2737
- if (result?.valid === false) {
2738
- return result;
2739
- }
2740
- }
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
-
2754
- {
2755
- const result = validateAudioEffectKeyframes({
2756
- keyframes: fade.keyframes,
2757
- property: "volume",
2758
- path: `${path}.keyframes`,
2759
- errorFactory,
2760
- });
2761
- if (result?.valid === false) {
2762
- return result;
2763
- }
2764
- }
2765
-
2766
- for (const [index, keyframe] of fade.keyframes.entries()) {
2767
- if (keyframe.relative === true) {
2768
- return invalidFromErrorFactory(
2769
- errorFactory,
2770
- `${path}.keyframes[${index}].relative is not supported for transition fades`,
2771
- );
2772
- }
2773
- }
2774
-
2775
- return;
2776
- }
2777
-
2778
- {
2779
- const result = validateAllowedKeys({
2780
- value: fade,
2781
- allowedKeys: ["initialValue", "delay", "duration", "easing"],
2782
- path,
2783
- errorFactory,
2784
- });
2785
- if (result?.valid === false) {
2786
- return result;
2787
- }
2788
- }
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
-
2802
- if (!Object.hasOwn(fade, "duration")) {
2803
- return invalidFromErrorFactory(
2804
- errorFactory,
2805
- `${path}.duration is required`,
2806
- );
2807
- }
2808
-
2809
- if (!isFiniteNumber(fade.duration) || fade.duration < 0) {
2810
- return invalidFromErrorFactory(
2811
- errorFactory,
2812
- `${path}.duration must be a finite number >= 0`,
2813
- );
2814
- }
2815
-
2816
- if (
2817
- fade.delay !== undefined &&
2818
- (!isFiniteNumber(fade.delay) || fade.delay < 0)
2819
- ) {
2820
- return invalidFromErrorFactory(
2821
- errorFactory,
2822
- `${path}.delay must be a finite number >= 0 when provided`,
2823
- );
2824
- }
2825
-
2826
- return validateAudioEffectEasing({
2827
- value: fade.easing,
2828
- path: `${path}.easing`,
2829
- errorFactory,
2830
- });
2831
- };
2832
-
2833
- const validateAudioEffectTransitionSide = ({
2834
- side,
2835
- sideName,
2836
- path,
2837
- errorFactory,
2838
- }) => {
2839
- {
2840
- const result = validateExactKeys({
2841
- value: side,
2842
- expectedKeys: ["fade"],
2843
- path,
2844
- errorFactory,
2845
- });
2846
- if (result?.valid === false) {
2847
- return result;
2848
- }
2849
- }
2850
-
2851
- return validateAudioEffectFade({
2852
- fade: side.fade,
2853
- path: `${path}.fade`,
2854
- side: sideName,
2855
- errorFactory,
2856
- });
2857
- };
2858
-
2859
2724
  const validateAudioEffectDefinition = ({ audioEffect, path, errorFactory }) => {
2860
2725
  {
2861
2726
  const result = validateAllowedKeys({
@@ -2891,8 +2756,8 @@ const validateAudioEffectDefinition = ({ audioEffect, path, errorFactory }) => {
2891
2756
  );
2892
2757
  }
2893
2758
 
2894
- return validateAudioEffectTween({
2895
- tween: audioEffect.tween,
2759
+ return validateAudioEffectPropertyTracks({
2760
+ tracks: audioEffect.tween,
2896
2761
  path: `${path}.tween`,
2897
2762
  errorFactory,
2898
2763
  });
@@ -2917,9 +2782,8 @@ const validateAudioEffectDefinition = ({ audioEffect, path, errorFactory }) => {
2917
2782
  continue;
2918
2783
  }
2919
2784
 
2920
- const result = validateAudioEffectTransitionSide({
2921
- side: audioEffect[side],
2922
- sideName: side,
2785
+ const result = validateAudioEffectPropertyTracks({
2786
+ tracks: audioEffect[side],
2923
2787
  path: `${path}.${side}`,
2924
2788
  errorFactory,
2925
2789
  });