@twick/timeline 0.14.4 → 0.14.6
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/core/editor/timeline.editor.d.ts +5 -1
- package/dist/index-CXhwwSX--DHE9Xex3.js.map +1 -1
- package/dist/index.js +48 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -11
- package/dist/index.mjs.map +1 -1
- package/dist/utils/constants.d.ts +35 -0
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,30 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import React, { useState, createContext, useContext, useRef, useMemo, useEffect } from "react";
|
|
6
|
+
const INITIAL_TIMELINE_DATA = {
|
|
7
|
+
tracks: [
|
|
8
|
+
{
|
|
9
|
+
type: "element",
|
|
10
|
+
id: "t-sample",
|
|
11
|
+
name: "sample",
|
|
12
|
+
elements: [
|
|
13
|
+
{
|
|
14
|
+
id: "e-sample",
|
|
15
|
+
trackId: "t-sample",
|
|
16
|
+
name: "sample",
|
|
17
|
+
type: "text",
|
|
18
|
+
s: 0,
|
|
19
|
+
e: 5,
|
|
20
|
+
props: {
|
|
21
|
+
text: "Twick SDK",
|
|
22
|
+
fill: "#FFFFFF"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
version: 1
|
|
29
|
+
};
|
|
6
30
|
const PLAYER_STATE = {
|
|
7
31
|
/** Player is refreshing/reloading content */
|
|
8
32
|
REFRESH: "Refresh",
|
|
@@ -2850,7 +2874,12 @@ class TimelineEditor {
|
|
|
2850
2874
|
const timelineData = timelineContextStore.getTimelineData(contextId);
|
|
2851
2875
|
return (timelineData == null ? void 0 : timelineData.version) || 0;
|
|
2852
2876
|
}
|
|
2853
|
-
setTimelineData(
|
|
2877
|
+
setTimelineData({
|
|
2878
|
+
tracks,
|
|
2879
|
+
version,
|
|
2880
|
+
updatePlayerData
|
|
2881
|
+
}) {
|
|
2882
|
+
var _a, _b;
|
|
2854
2883
|
const prevTimelineData = this.getTimelineData();
|
|
2855
2884
|
const updatedVersion = version ?? ((prevTimelineData == null ? void 0 : prevTimelineData.version) || 0) + 1;
|
|
2856
2885
|
const updatedTimelineData = {
|
|
@@ -2863,6 +2892,13 @@ class TimelineEditor {
|
|
|
2863
2892
|
);
|
|
2864
2893
|
this.updateHistory(updatedTimelineData);
|
|
2865
2894
|
this.context.updateChangeLog();
|
|
2895
|
+
if (updatePlayerData) {
|
|
2896
|
+
(_b = (_a = this.context) == null ? void 0 : _a.setTimelineAction) == null ? void 0 : _b.call(
|
|
2897
|
+
_a,
|
|
2898
|
+
TIMELINE_ACTION.UPDATE_PLAYER_DATA,
|
|
2899
|
+
updatedTimelineData
|
|
2900
|
+
);
|
|
2901
|
+
}
|
|
2866
2902
|
return updatedTimelineData;
|
|
2867
2903
|
}
|
|
2868
2904
|
addTrack(name, type = "element") {
|
|
@@ -2870,7 +2906,7 @@ class TimelineEditor {
|
|
|
2870
2906
|
const id = `t-${generateShortUuid()}`;
|
|
2871
2907
|
const track = new Track(name, type, id);
|
|
2872
2908
|
const updatedTimelines = [...(prevTimelineData == null ? void 0 : prevTimelineData.tracks) || [], track];
|
|
2873
|
-
this.setTimelineData(updatedTimelines);
|
|
2909
|
+
this.setTimelineData({ tracks: updatedTimelines, updatePlayerData: true });
|
|
2874
2910
|
return track;
|
|
2875
2911
|
}
|
|
2876
2912
|
getTrackById(id) {
|
|
@@ -2887,13 +2923,13 @@ class TimelineEditor {
|
|
|
2887
2923
|
var _a;
|
|
2888
2924
|
const tracks = ((_a = this.getTimelineData()) == null ? void 0 : _a.tracks) || [];
|
|
2889
2925
|
const updatedTracks = tracks.filter((t2) => t2.getId() !== id);
|
|
2890
|
-
this.setTimelineData(updatedTracks);
|
|
2926
|
+
this.setTimelineData({ tracks: updatedTracks, updatePlayerData: true });
|
|
2891
2927
|
}
|
|
2892
2928
|
removeTrack(track) {
|
|
2893
2929
|
var _a;
|
|
2894
2930
|
const tracks = ((_a = this.getTimelineData()) == null ? void 0 : _a.tracks) || [];
|
|
2895
2931
|
const updatedTracks = tracks.filter((t2) => t2.getId() !== track.getId());
|
|
2896
|
-
this.setTimelineData(updatedTracks);
|
|
2932
|
+
this.setTimelineData({ tracks: updatedTracks, updatePlayerData: true });
|
|
2897
2933
|
}
|
|
2898
2934
|
/**
|
|
2899
2935
|
* Refresh the timeline data
|
|
@@ -2901,7 +2937,7 @@ class TimelineEditor {
|
|
|
2901
2937
|
refresh() {
|
|
2902
2938
|
const currentData = this.getTimelineData();
|
|
2903
2939
|
if (currentData) {
|
|
2904
|
-
this.setTimelineData(currentData.tracks);
|
|
2940
|
+
this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
|
|
2905
2941
|
}
|
|
2906
2942
|
}
|
|
2907
2943
|
/**
|
|
@@ -2920,7 +2956,7 @@ class TimelineEditor {
|
|
|
2920
2956
|
if (result) {
|
|
2921
2957
|
const currentData = this.getTimelineData();
|
|
2922
2958
|
if (currentData) {
|
|
2923
|
-
this.setTimelineData(currentData.tracks);
|
|
2959
|
+
this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
|
|
2924
2960
|
}
|
|
2925
2961
|
}
|
|
2926
2962
|
return result;
|
|
@@ -2944,7 +2980,7 @@ class TimelineEditor {
|
|
|
2944
2980
|
if (result) {
|
|
2945
2981
|
const currentData = this.getTimelineData();
|
|
2946
2982
|
if (currentData) {
|
|
2947
|
-
this.setTimelineData(currentData.tracks);
|
|
2983
|
+
this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
|
|
2948
2984
|
}
|
|
2949
2985
|
}
|
|
2950
2986
|
return result;
|
|
@@ -2968,7 +3004,7 @@ class TimelineEditor {
|
|
|
2968
3004
|
if (result) {
|
|
2969
3005
|
const currentData = this.getTimelineData();
|
|
2970
3006
|
if (currentData) {
|
|
2971
|
-
this.setTimelineData(currentData.tracks);
|
|
3007
|
+
this.setTimelineData({ tracks: currentData.tracks });
|
|
2972
3008
|
}
|
|
2973
3009
|
}
|
|
2974
3010
|
return element;
|
|
@@ -2998,7 +3034,7 @@ class TimelineEditor {
|
|
|
2998
3034
|
result.secondElement.accept(elementAdder);
|
|
2999
3035
|
const currentData = this.getTimelineData();
|
|
3000
3036
|
if (currentData) {
|
|
3001
|
-
this.setTimelineData(currentData.tracks);
|
|
3037
|
+
this.setTimelineData({ tracks: currentData.tracks, updatePlayerData: true });
|
|
3002
3038
|
}
|
|
3003
3039
|
}
|
|
3004
3040
|
return result;
|
|
@@ -3020,7 +3056,7 @@ class TimelineEditor {
|
|
|
3020
3056
|
}
|
|
3021
3057
|
}
|
|
3022
3058
|
reorderTracks(tracks) {
|
|
3023
|
-
this.setTimelineData(tracks);
|
|
3059
|
+
this.setTimelineData({ tracks, updatePlayerData: true });
|
|
3024
3060
|
}
|
|
3025
3061
|
updateHistory(timelineTrackData) {
|
|
3026
3062
|
const tracks = timelineTrackData.tracks.map((t2) => t2.serialize());
|
|
@@ -3105,7 +3141,7 @@ class TimelineEditor {
|
|
|
3105
3141
|
this.pauseVideo();
|
|
3106
3142
|
this.context.handleResetHistory();
|
|
3107
3143
|
const timelineTracks = tracks.map((t2) => Track.fromJSON(t2));
|
|
3108
|
-
this.setTimelineData(timelineTracks, version);
|
|
3144
|
+
this.setTimelineData({ tracks: timelineTracks, version, updatePlayerData: true });
|
|
3109
3145
|
if ((_a = this.context) == null ? void 0 : _a.setTimelineAction) {
|
|
3110
3146
|
this.context.setTimelineAction(TIMELINE_ACTION.UPDATE_PLAYER_DATA, {
|
|
3111
3147
|
tracks,
|
|
@@ -7964,6 +8000,7 @@ export {
|
|
|
7964
8000
|
ElementTextEffect,
|
|
7965
8001
|
ElementUpdater,
|
|
7966
8002
|
ElementValidator,
|
|
8003
|
+
INITIAL_TIMELINE_DATA,
|
|
7967
8004
|
IconElement,
|
|
7968
8005
|
ImageElement,
|
|
7969
8006
|
PLAYER_STATE,
|