@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.mjs CHANGED
@@ -2850,7 +2850,12 @@ class TimelineEditor {
2850
2850
  const timelineData = timelineContextStore.getTimelineData(contextId);
2851
2851
  return (timelineData == null ? void 0 : timelineData.version) || 0;
2852
2852
  }
2853
- setTimelineData(tracks, version) {
2853
+ setTimelineData({
2854
+ tracks,
2855
+ version,
2856
+ updatePlayerData
2857
+ }) {
2858
+ var _a, _b;
2854
2859
  const prevTimelineData = this.getTimelineData();
2855
2860
  const updatedVersion = version ?? ((prevTimelineData == null ? void 0 : prevTimelineData.version) || 0) + 1;
2856
2861
  const updatedTimelineData = {
@@ -2863,6 +2868,13 @@ class TimelineEditor {
2863
2868
  );
2864
2869
  this.updateHistory(updatedTimelineData);
2865
2870
  this.context.updateChangeLog();
2871
+ if (updatePlayerData) {
2872
+ (_b = (_a = this.context) == null ? void 0 : _a.setTimelineAction) == null ? void 0 : _b.call(
2873
+ _a,
2874
+ TIMELINE_ACTION.UPDATE_PLAYER_DATA,
2875
+ updatedTimelineData
2876
+ );
2877
+ }
2866
2878
  return updatedTimelineData;
2867
2879
  }
2868
2880
  addTrack(name, type = "element") {
@@ -2870,7 +2882,7 @@ class TimelineEditor {
2870
2882
  const id = `t-${generateShortUuid()}`;
2871
2883
  const track = new Track(name, type, id);
2872
2884
  const updatedTimelines = [...(prevTimelineData == null ? void 0 : prevTimelineData.tracks) || [], track];
2873
- this.setTimelineData(updatedTimelines);
2885
+ this.setTimelineData({ tracks: updatedTimelines, updatePlayerData: true });
2874
2886
  return track;
2875
2887
  }
2876
2888
  getTrackById(id) {
@@ -2887,13 +2899,13 @@ class TimelineEditor {
2887
2899
  var _a;
2888
2900
  const tracks = ((_a = this.getTimelineData()) == null ? void 0 : _a.tracks) || [];
2889
2901
  const updatedTracks = tracks.filter((t2) => t2.getId() !== id);
2890
- this.setTimelineData(updatedTracks);
2902
+ this.setTimelineData({ tracks: updatedTracks, updatePlayerData: true });
2891
2903
  }
2892
2904
  removeTrack(track) {
2893
2905
  var _a;
2894
2906
  const tracks = ((_a = this.getTimelineData()) == null ? void 0 : _a.tracks) || [];
2895
2907
  const updatedTracks = tracks.filter((t2) => t2.getId() !== track.getId());
2896
- this.setTimelineData(updatedTracks);
2908
+ this.setTimelineData({ tracks: updatedTracks, updatePlayerData: true });
2897
2909
  }
2898
2910
  /**
2899
2911
  * Refresh the timeline data
@@ -2901,7 +2913,7 @@ class TimelineEditor {
2901
2913
  refresh() {
2902
2914
  const currentData = this.getTimelineData();
2903
2915
  if (currentData) {
2904
- this.setTimelineData(currentData.tracks);
2916
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
2905
2917
  }
2906
2918
  }
2907
2919
  /**
@@ -2920,7 +2932,7 @@ class TimelineEditor {
2920
2932
  if (result) {
2921
2933
  const currentData = this.getTimelineData();
2922
2934
  if (currentData) {
2923
- this.setTimelineData(currentData.tracks);
2935
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
2924
2936
  }
2925
2937
  }
2926
2938
  return result;
@@ -2944,7 +2956,7 @@ class TimelineEditor {
2944
2956
  if (result) {
2945
2957
  const currentData = this.getTimelineData();
2946
2958
  if (currentData) {
2947
- this.setTimelineData(currentData.tracks);
2959
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
2948
2960
  }
2949
2961
  }
2950
2962
  return result;
@@ -2968,7 +2980,7 @@ class TimelineEditor {
2968
2980
  if (result) {
2969
2981
  const currentData = this.getTimelineData();
2970
2982
  if (currentData) {
2971
- this.setTimelineData(currentData.tracks);
2983
+ this.setTimelineData({ tracks: currentData.tracks });
2972
2984
  }
2973
2985
  }
2974
2986
  return element;
@@ -2998,7 +3010,7 @@ class TimelineEditor {
2998
3010
  result.secondElement.accept(elementAdder);
2999
3011
  const currentData = this.getTimelineData();
3000
3012
  if (currentData) {
3001
- this.setTimelineData(currentData.tracks);
3013
+ this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
3002
3014
  }
3003
3015
  }
3004
3016
  return result;
@@ -3020,7 +3032,7 @@ class TimelineEditor {
3020
3032
  }
3021
3033
  }
3022
3034
  reorderTracks(tracks) {
3023
- this.setTimelineData(tracks);
3035
+ this.setTimelineData({ tracks, updatePlayerData: true });
3024
3036
  }
3025
3037
  updateHistory(timelineTrackData) {
3026
3038
  const tracks = timelineTrackData.tracks.map((t2) => t2.serialize());
@@ -3105,7 +3117,7 @@ class TimelineEditor {
3105
3117
  this.pauseVideo();
3106
3118
  this.context.handleResetHistory();
3107
3119
  const timelineTracks = tracks.map((t2) => Track.fromJSON(t2));
3108
- this.setTimelineData(timelineTracks, version);
3120
+ this.setTimelineData({ tracks: timelineTracks, version, updatePlayerData: true });
3109
3121
  if ((_a = this.context) == null ? void 0 : _a.setTimelineAction) {
3110
3122
  this.context.setTimelineAction(TIMELINE_ACTION.UPDATE_PLAYER_DATA, {
3111
3123
  tracks,