@twick/timeline 0.14.4 → 0.14.5

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/dist/index.js CHANGED
@@ -2852,7 +2852,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2852
2852
  const timelineData = timelineContextStore.getTimelineData(contextId);
2853
2853
  return (timelineData == null ? void 0 : timelineData.version) || 0;
2854
2854
  }
2855
- setTimelineData(tracks, version) {
2855
+ setTimelineData({
2856
+ tracks,
2857
+ version,
2858
+ updatePlayerData
2859
+ }) {
2860
+ var _a, _b;
2856
2861
  const prevTimelineData = this.getTimelineData();
2857
2862
  const updatedVersion = version ?? ((prevTimelineData == null ? void 0 : prevTimelineData.version) || 0) + 1;
2858
2863
  const updatedTimelineData = {
@@ -2865,6 +2870,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2865
2870
  );
2866
2871
  this.updateHistory(updatedTimelineData);
2867
2872
  this.context.updateChangeLog();
2873
+ if (updatePlayerData) {
2874
+ (_b = (_a = this.context) == null ? void 0 : _a.setTimelineAction) == null ? void 0 : _b.call(
2875
+ _a,
2876
+ TIMELINE_ACTION.UPDATE_PLAYER_DATA,
2877
+ updatedTimelineData
2878
+ );
2879
+ }
2868
2880
  return updatedTimelineData;
2869
2881
  }
2870
2882
  addTrack(name, type = "element") {
@@ -2872,7 +2884,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2872
2884
  const id = `t-${generateShortUuid()}`;
2873
2885
  const track = new Track(name, type, id);
2874
2886
  const updatedTimelines = [...(prevTimelineData == null ? void 0 : prevTimelineData.tracks) || [], track];
2875
- this.setTimelineData(updatedTimelines);
2887
+ this.setTimelineData({ tracks: updatedTimelines, updatePlayerData: true });
2876
2888
  return track;
2877
2889
  }
2878
2890
  getTrackById(id) {
@@ -2889,13 +2901,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2889
2901
  var _a;
2890
2902
  const tracks = ((_a = this.getTimelineData()) == null ? void 0 : _a.tracks) || [];
2891
2903
  const updatedTracks = tracks.filter((t2) => t2.getId() !== id);
2892
- this.setTimelineData(updatedTracks);
2904
+ this.setTimelineData({ tracks: updatedTracks, updatePlayerData: true });
2893
2905
  }
2894
2906
  removeTrack(track) {
2895
2907
  var _a;
2896
2908
  const tracks = ((_a = this.getTimelineData()) == null ? void 0 : _a.tracks) || [];
2897
2909
  const updatedTracks = tracks.filter((t2) => t2.getId() !== track.getId());
2898
- this.setTimelineData(updatedTracks);
2910
+ this.setTimelineData({ tracks: updatedTracks, updatePlayerData: true });
2899
2911
  }
2900
2912
  /**
2901
2913
  * Refresh the timeline data
@@ -2903,7 +2915,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2903
2915
  refresh() {
2904
2916
  const currentData = this.getTimelineData();
2905
2917
  if (currentData) {
2906
- this.setTimelineData(currentData.tracks);
2918
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
2907
2919
  }
2908
2920
  }
2909
2921
  /**
@@ -2922,7 +2934,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2922
2934
  if (result) {
2923
2935
  const currentData = this.getTimelineData();
2924
2936
  if (currentData) {
2925
- this.setTimelineData(currentData.tracks);
2937
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
2926
2938
  }
2927
2939
  }
2928
2940
  return result;
@@ -2946,7 +2958,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2946
2958
  if (result) {
2947
2959
  const currentData = this.getTimelineData();
2948
2960
  if (currentData) {
2949
- this.setTimelineData(currentData.tracks);
2961
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
2950
2962
  }
2951
2963
  }
2952
2964
  return result;
@@ -2970,7 +2982,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2970
2982
  if (result) {
2971
2983
  const currentData = this.getTimelineData();
2972
2984
  if (currentData) {
2973
- this.setTimelineData(currentData.tracks);
2985
+ this.setTimelineData({ tracks: currentData.tracks });
2974
2986
  }
2975
2987
  }
2976
2988
  return element;
@@ -3000,7 +3012,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3000
3012
  result.secondElement.accept(elementAdder);
3001
3013
  const currentData = this.getTimelineData();
3002
3014
  if (currentData) {
3003
- this.setTimelineData(currentData.tracks);
3015
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
3004
3016
  }
3005
3017
  }
3006
3018
  return result;
@@ -3022,7 +3034,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3022
3034
  }
3023
3035
  }
3024
3036
  reorderTracks(tracks) {
3025
- this.setTimelineData(tracks);
3037
+ this.setTimelineData({ tracks, updatePlayerData: true });
3026
3038
  }
3027
3039
  updateHistory(timelineTrackData) {
3028
3040
  const tracks = timelineTrackData.tracks.map((t2) => t2.serialize());
@@ -3107,7 +3119,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3107
3119
  this.pauseVideo();
3108
3120
  this.context.handleResetHistory();
3109
3121
  const timelineTracks = tracks.map((t2) => Track.fromJSON(t2));
3110
- this.setTimelineData(timelineTracks, version);
3122
+ this.setTimelineData({ tracks: timelineTracks, version, updatePlayerData: true });
3111
3123
  if ((_a = this.context) == null ? void 0 : _a.setTimelineAction) {
3112
3124
  this.context.setTimelineAction(TIMELINE_ACTION.UPDATE_PLAYER_DATA, {
3113
3125
  tracks,