@twick/timeline 0.14.3 → 0.14.4
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/context/timeline-context.d.ts +8 -2
- package/dist/core/addOns/animation.d.ts +3 -0
- package/dist/core/editor/timeline.editor.d.ts +3 -3
- package/dist/core/elements/base.element.d.ts +4 -0
- package/dist/core/elements/circle.element.d.ts +4 -0
- package/dist/core/elements/icon.element.d.ts +8 -3
- package/dist/core/elements/rect.element.d.ts +8 -0
- package/dist/core/track/track.d.ts +4 -3
- package/dist/index.js +123 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -24
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +12 -157
- package/dist/types.d.ts +128 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Track } from '../core/track/track';
|
|
2
2
|
import { TrackElement } from '../core/elements/base.element';
|
|
3
|
-
import { ProjectJSON, TrackJSON } from '../types';
|
|
3
|
+
import { ProjectJSON, Size, TrackJSON } from '../types';
|
|
4
4
|
import { TimelineEditor } from '../core/editor/timeline.editor';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -36,6 +36,8 @@ export type TimelineContextType = {
|
|
|
36
36
|
type: string;
|
|
37
37
|
payload: any;
|
|
38
38
|
};
|
|
39
|
+
/** Resolution of the video */
|
|
40
|
+
videoResolution: Size;
|
|
39
41
|
/** Total duration of the timeline in seconds */
|
|
40
42
|
totalDuration: number;
|
|
41
43
|
/** Current project state */
|
|
@@ -48,6 +50,8 @@ export type TimelineContextType = {
|
|
|
48
50
|
setSelectedItem: (item: Track | TrackElement | null) => void;
|
|
49
51
|
/** Function to set timeline actions */
|
|
50
52
|
setTimelineAction: (type: string, payload: any) => void;
|
|
53
|
+
/** Function to set the video resolution */
|
|
54
|
+
setVideoResolution: (size: Size) => void;
|
|
51
55
|
};
|
|
52
56
|
/**
|
|
53
57
|
* Props for the TimelineProvider component.
|
|
@@ -70,6 +74,8 @@ export interface TimelineProviderProps {
|
|
|
70
74
|
children: React.ReactNode;
|
|
71
75
|
/** Unique identifier for this timeline context */
|
|
72
76
|
contextId: string;
|
|
77
|
+
/** resolution of the video */
|
|
78
|
+
resolution?: Size;
|
|
73
79
|
/** Initial timeline data to load */
|
|
74
80
|
initialData?: {
|
|
75
81
|
tracks: TrackJSON[];
|
|
@@ -100,7 +106,7 @@ export interface TimelineProviderProps {
|
|
|
100
106
|
* </TimelineProvider>
|
|
101
107
|
* ```
|
|
102
108
|
*/
|
|
103
|
-
export declare const TimelineProvider: ({ contextId, children, initialData, undoRedoPersistenceKey, maxHistorySize, }: TimelineProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
109
|
+
export declare const TimelineProvider: ({ contextId, children, resolution, initialData, undoRedoPersistenceKey, maxHistorySize, }: TimelineProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
104
110
|
/**
|
|
105
111
|
* Hook to access the Timeline context.
|
|
106
112
|
* Provides access to timeline state, editor instance, and timeline management functions.
|
|
@@ -3,6 +3,7 @@ import { Animation } from '../../types';
|
|
|
3
3
|
export declare class ElementAnimation {
|
|
4
4
|
private name;
|
|
5
5
|
private interval?;
|
|
6
|
+
private duration?;
|
|
6
7
|
private intensity?;
|
|
7
8
|
private animate?;
|
|
8
9
|
private mode?;
|
|
@@ -10,11 +11,13 @@ export declare class ElementAnimation {
|
|
|
10
11
|
constructor(name: string);
|
|
11
12
|
getName(): string;
|
|
12
13
|
getInterval(): number | undefined;
|
|
14
|
+
getDuration(): number | undefined;
|
|
13
15
|
getIntensity(): number | undefined;
|
|
14
16
|
getAnimate(): "enter" | "exit" | "both" | undefined;
|
|
15
17
|
getMode(): "in" | "out" | undefined;
|
|
16
18
|
getDirection(): "left" | "center" | "right" | "up" | "down" | undefined;
|
|
17
19
|
setInterval(interval?: number): this;
|
|
20
|
+
setDuration(duration?: number): this;
|
|
18
21
|
setIntensity(intensity?: number): this;
|
|
19
22
|
setAnimate(animate?: "enter" | "exit" | "both"): this;
|
|
20
23
|
setMode(mode?: "in" | "out"): this;
|
|
@@ -33,7 +33,7 @@ export declare class TimelineEditor {
|
|
|
33
33
|
getTimelineData(): TimelineTrackData | null;
|
|
34
34
|
getLatestVersion(): number;
|
|
35
35
|
protected setTimelineData(tracks: Track[], version?: number): TimelineTrackData;
|
|
36
|
-
addTrack(name: string): Track;
|
|
36
|
+
addTrack(name: string, type?: string): Track;
|
|
37
37
|
getTrackById(id: string): Track | null;
|
|
38
38
|
getTrackByName(name: string): Track | null;
|
|
39
39
|
removeTrackById(id: string): void;
|
|
@@ -58,9 +58,9 @@ export declare class TimelineEditor {
|
|
|
58
58
|
/**
|
|
59
59
|
* Update an element in a specific track using the visitor pattern
|
|
60
60
|
* @param element The updated element
|
|
61
|
-
* @returns
|
|
61
|
+
* @returns TrackElement the updated element
|
|
62
62
|
*/
|
|
63
|
-
updateElement(element: TrackElement):
|
|
63
|
+
updateElement(element: TrackElement): TrackElement;
|
|
64
64
|
/**
|
|
65
65
|
* Split an element at a specific time point using the visitor pattern
|
|
66
66
|
* @param element The element to split
|
|
@@ -23,6 +23,8 @@ export declare abstract class TrackElement {
|
|
|
23
23
|
getName(): string;
|
|
24
24
|
getAnimation(): ElementAnimation | undefined;
|
|
25
25
|
getPosition(): Position;
|
|
26
|
+
getRotation(): number;
|
|
27
|
+
getOpacity(): number;
|
|
26
28
|
setId(id: string): this;
|
|
27
29
|
setType(type: string): this;
|
|
28
30
|
setStart(s: number): this;
|
|
@@ -31,5 +33,7 @@ export declare abstract class TrackElement {
|
|
|
31
33
|
setName(name: string): this;
|
|
32
34
|
setAnimation(animation?: ElementAnimation): this;
|
|
33
35
|
setPosition(position: Position): this;
|
|
36
|
+
setRotation(rotation: number): this;
|
|
37
|
+
setOpacity(opacity: number): this;
|
|
34
38
|
setProps(props: Record<string, any>): this;
|
|
35
39
|
}
|
|
@@ -7,7 +7,11 @@ export declare class CircleElement extends TrackElement {
|
|
|
7
7
|
constructor(fill: string, radius: number);
|
|
8
8
|
getFill(): string;
|
|
9
9
|
getRadius(): number;
|
|
10
|
+
getStrokeColor(): string;
|
|
11
|
+
getLineWidth(): number;
|
|
10
12
|
setFill(fill: string): this;
|
|
11
13
|
setRadius(radius: number): this;
|
|
14
|
+
setStrokeColor(strokeColor: string): this;
|
|
15
|
+
setLineWidth(lineWidth: number): this;
|
|
12
16
|
accept<T>(visitor: ElementVisitor<T>): T;
|
|
13
17
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { TrackElement } from './base.element';
|
|
2
2
|
import { ElementVisitor } from '../visitor/element-visitor';
|
|
3
|
-
import {
|
|
3
|
+
import { Size } from '../../types';
|
|
4
4
|
|
|
5
5
|
export declare class IconElement extends TrackElement {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
constructor(src: string, size: Size, fill?: string);
|
|
7
|
+
getSrc(): string;
|
|
8
|
+
getFill(): string;
|
|
9
|
+
getSize(): Size | undefined;
|
|
10
|
+
setSrc(src: string): this;
|
|
11
|
+
setFill(fill: string): this;
|
|
12
|
+
setSize(size: Size): this;
|
|
8
13
|
accept<T>(visitor: ElementVisitor<T>): T;
|
|
9
14
|
}
|
|
@@ -5,7 +5,15 @@ import { ElementVisitor } from '../visitor/element-visitor';
|
|
|
5
5
|
export declare class RectElement extends TrackElement {
|
|
6
6
|
protected props: RectProps;
|
|
7
7
|
constructor(fill: string, size: Size);
|
|
8
|
+
getFill(): string;
|
|
8
9
|
setFill(fill: string): this;
|
|
10
|
+
getSize(): Size;
|
|
11
|
+
getCornerRadius(): number;
|
|
12
|
+
getStrokeColor(): string;
|
|
13
|
+
getLineWidth(): number;
|
|
9
14
|
setSize(size: Size): this;
|
|
15
|
+
setCornerRadius(cornerRadius: number): this;
|
|
16
|
+
setStrokeColor(strokeColor: string): this;
|
|
17
|
+
setLineWidth(lineWidth: number): this;
|
|
10
18
|
accept<T>(visitor: ElementVisitor<T>): T;
|
|
11
19
|
}
|
|
@@ -38,15 +38,16 @@ export declare class Track {
|
|
|
38
38
|
* Creates a new Track instance.
|
|
39
39
|
*
|
|
40
40
|
* @param name - The display name for the track
|
|
41
|
+
* @param type - The type of the track
|
|
41
42
|
* @param id - Optional unique identifier (auto-generated if not provided)
|
|
42
43
|
*
|
|
43
44
|
* @example
|
|
44
45
|
* ```js
|
|
45
46
|
* const track = new Track("My Video Track");
|
|
46
|
-
* const trackWithId = new Track("Audio Track", "
|
|
47
|
+
* const trackWithId = new Track("Audio Track", "element", "video-track-1");
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
|
-
constructor(name: string, id?: string);
|
|
50
|
+
constructor(name: string, type?: string, id?: string);
|
|
50
51
|
/**
|
|
51
52
|
* Creates a friend instance for explicit access to protected methods.
|
|
52
53
|
* This implements the Friend Class Pattern to allow controlled access
|
|
@@ -126,7 +127,7 @@ export declare class Track {
|
|
|
126
127
|
*
|
|
127
128
|
* @example
|
|
128
129
|
* ```js
|
|
129
|
-
* const track = new Track("My Track", "track-123");
|
|
130
|
+
* const track = new Track("My Track", "element", "track-123");
|
|
130
131
|
* const id = track.getId(); // "track-123"
|
|
131
132
|
* ```
|
|
132
133
|
*/
|
package/dist/index.js
CHANGED
|
@@ -484,7 +484,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
484
484
|
this.type = type;
|
|
485
485
|
this.props = {
|
|
486
486
|
x: 0,
|
|
487
|
-
y: 0
|
|
487
|
+
y: 0,
|
|
488
|
+
opacity: 1,
|
|
489
|
+
rotation: 0
|
|
488
490
|
};
|
|
489
491
|
}
|
|
490
492
|
getId() {
|
|
@@ -521,6 +523,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
521
523
|
y: ((_b = this.props) == null ? void 0 : _b.y) ?? 0
|
|
522
524
|
};
|
|
523
525
|
}
|
|
526
|
+
getRotation() {
|
|
527
|
+
return this.props.rotation ?? 0;
|
|
528
|
+
}
|
|
529
|
+
getOpacity() {
|
|
530
|
+
return this.props.opacity ?? 1;
|
|
531
|
+
}
|
|
524
532
|
setId(id) {
|
|
525
533
|
this.id = id;
|
|
526
534
|
return this;
|
|
@@ -554,6 +562,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
554
562
|
this.props.y = position.y;
|
|
555
563
|
return this;
|
|
556
564
|
}
|
|
565
|
+
setRotation(rotation) {
|
|
566
|
+
this.props.rotation = rotation;
|
|
567
|
+
return this;
|
|
568
|
+
}
|
|
569
|
+
setOpacity(opacity) {
|
|
570
|
+
this.props.opacity = opacity;
|
|
571
|
+
return this;
|
|
572
|
+
}
|
|
557
573
|
setProps(props) {
|
|
558
574
|
this.props = structuredClone(props);
|
|
559
575
|
return this;
|
|
@@ -1042,13 +1058,35 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1042
1058
|
}
|
|
1043
1059
|
}
|
|
1044
1060
|
class IconElement extends TrackElement {
|
|
1045
|
-
constructor(src, size) {
|
|
1061
|
+
constructor(src, size, fill = "#866bbf") {
|
|
1046
1062
|
super(TIMELINE_ELEMENT_TYPE.ICON);
|
|
1047
1063
|
this.props = {
|
|
1048
1064
|
src,
|
|
1065
|
+
fill,
|
|
1049
1066
|
size
|
|
1050
1067
|
};
|
|
1051
1068
|
}
|
|
1069
|
+
getSrc() {
|
|
1070
|
+
return this.props.src;
|
|
1071
|
+
}
|
|
1072
|
+
getFill() {
|
|
1073
|
+
return this.props.fill;
|
|
1074
|
+
}
|
|
1075
|
+
getSize() {
|
|
1076
|
+
return this.props.size;
|
|
1077
|
+
}
|
|
1078
|
+
setSrc(src) {
|
|
1079
|
+
this.props.src = src;
|
|
1080
|
+
return this;
|
|
1081
|
+
}
|
|
1082
|
+
setFill(fill) {
|
|
1083
|
+
this.props.fill = fill;
|
|
1084
|
+
return this;
|
|
1085
|
+
}
|
|
1086
|
+
setSize(size) {
|
|
1087
|
+
this.props.size = size;
|
|
1088
|
+
return this;
|
|
1089
|
+
}
|
|
1052
1090
|
accept(visitor) {
|
|
1053
1091
|
return visitor.visitIconElement(this);
|
|
1054
1092
|
}
|
|
@@ -1058,7 +1096,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1058
1096
|
super(TIMELINE_ELEMENT_TYPE.CIRCLE);
|
|
1059
1097
|
this.props = {
|
|
1060
1098
|
radius,
|
|
1061
|
-
fill
|
|
1099
|
+
fill,
|
|
1100
|
+
strokeColor: fill,
|
|
1101
|
+
lineWidth: 1
|
|
1062
1102
|
};
|
|
1063
1103
|
}
|
|
1064
1104
|
getFill() {
|
|
@@ -1067,6 +1107,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1067
1107
|
getRadius() {
|
|
1068
1108
|
return this.props.radius;
|
|
1069
1109
|
}
|
|
1110
|
+
getStrokeColor() {
|
|
1111
|
+
return this.props.strokeColor || this.props.fill;
|
|
1112
|
+
}
|
|
1113
|
+
getLineWidth() {
|
|
1114
|
+
return this.props.lineWidth ?? 0;
|
|
1115
|
+
}
|
|
1070
1116
|
setFill(fill) {
|
|
1071
1117
|
this.props.fill = fill;
|
|
1072
1118
|
return this;
|
|
@@ -1075,6 +1121,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1075
1121
|
this.props.radius = radius;
|
|
1076
1122
|
return this;
|
|
1077
1123
|
}
|
|
1124
|
+
setStrokeColor(strokeColor) {
|
|
1125
|
+
this.props.strokeColor = strokeColor;
|
|
1126
|
+
return this;
|
|
1127
|
+
}
|
|
1128
|
+
setLineWidth(lineWidth) {
|
|
1129
|
+
this.props.lineWidth = lineWidth;
|
|
1130
|
+
return this;
|
|
1131
|
+
}
|
|
1078
1132
|
accept(visitor) {
|
|
1079
1133
|
return visitor.visitCircleElement(this);
|
|
1080
1134
|
}
|
|
@@ -1085,18 +1139,48 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1085
1139
|
this.props = {
|
|
1086
1140
|
width: size.width,
|
|
1087
1141
|
height: size.height,
|
|
1088
|
-
fill
|
|
1142
|
+
fill,
|
|
1143
|
+
radius: 0,
|
|
1144
|
+
strokeColor: fill,
|
|
1145
|
+
lineWidth: 1
|
|
1089
1146
|
};
|
|
1090
1147
|
}
|
|
1148
|
+
getFill() {
|
|
1149
|
+
return this.props.fill;
|
|
1150
|
+
}
|
|
1091
1151
|
setFill(fill) {
|
|
1092
1152
|
this.props.fill = fill;
|
|
1093
1153
|
return this;
|
|
1094
1154
|
}
|
|
1155
|
+
getSize() {
|
|
1156
|
+
return { width: this.props.width, height: this.props.height };
|
|
1157
|
+
}
|
|
1158
|
+
getCornerRadius() {
|
|
1159
|
+
return this.props.radius;
|
|
1160
|
+
}
|
|
1161
|
+
getStrokeColor() {
|
|
1162
|
+
return this.props.strokeColor || this.props.fill;
|
|
1163
|
+
}
|
|
1164
|
+
getLineWidth() {
|
|
1165
|
+
return this.props.lineWidth ?? 0;
|
|
1166
|
+
}
|
|
1095
1167
|
setSize(size) {
|
|
1096
1168
|
this.props.width = size.width;
|
|
1097
1169
|
this.props.height = size.height;
|
|
1098
1170
|
return this;
|
|
1099
1171
|
}
|
|
1172
|
+
setCornerRadius(cornerRadius) {
|
|
1173
|
+
this.props.radius = cornerRadius;
|
|
1174
|
+
return this;
|
|
1175
|
+
}
|
|
1176
|
+
setStrokeColor(strokeColor) {
|
|
1177
|
+
this.props.strokeColor = strokeColor;
|
|
1178
|
+
return this;
|
|
1179
|
+
}
|
|
1180
|
+
setLineWidth(lineWidth) {
|
|
1181
|
+
this.props.lineWidth = lineWidth;
|
|
1182
|
+
return this;
|
|
1183
|
+
}
|
|
1100
1184
|
accept(visitor) {
|
|
1101
1185
|
return visitor.visitRectElement(this);
|
|
1102
1186
|
}
|
|
@@ -1105,6 +1189,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1105
1189
|
constructor(name) {
|
|
1106
1190
|
__publicField(this, "name");
|
|
1107
1191
|
__publicField(this, "interval");
|
|
1192
|
+
__publicField(this, "duration");
|
|
1108
1193
|
__publicField(this, "intensity");
|
|
1109
1194
|
__publicField(this, "animate");
|
|
1110
1195
|
__publicField(this, "mode");
|
|
@@ -1117,6 +1202,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1117
1202
|
getInterval() {
|
|
1118
1203
|
return this.interval;
|
|
1119
1204
|
}
|
|
1205
|
+
getDuration() {
|
|
1206
|
+
return this.duration;
|
|
1207
|
+
}
|
|
1120
1208
|
getIntensity() {
|
|
1121
1209
|
return this.intensity;
|
|
1122
1210
|
}
|
|
@@ -1133,6 +1221,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1133
1221
|
this.interval = interval;
|
|
1134
1222
|
return this;
|
|
1135
1223
|
}
|
|
1224
|
+
setDuration(duration) {
|
|
1225
|
+
this.duration = duration;
|
|
1226
|
+
return this;
|
|
1227
|
+
}
|
|
1136
1228
|
setIntensity(intensity) {
|
|
1137
1229
|
this.intensity = intensity;
|
|
1138
1230
|
return this;
|
|
@@ -1153,6 +1245,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1153
1245
|
return {
|
|
1154
1246
|
name: this.name,
|
|
1155
1247
|
interval: this.interval,
|
|
1248
|
+
duration: this.duration,
|
|
1156
1249
|
intensity: this.intensity,
|
|
1157
1250
|
animate: this.animate,
|
|
1158
1251
|
mode: this.mode,
|
|
@@ -1162,6 +1255,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1162
1255
|
static fromJSON(json) {
|
|
1163
1256
|
const animation = new ElementAnimation(json.name);
|
|
1164
1257
|
animation.setInterval(json.interval);
|
|
1258
|
+
animation.setDuration(json.duration);
|
|
1165
1259
|
animation.setIntensity(json.intensity);
|
|
1166
1260
|
animation.setAnimate(json.animate);
|
|
1167
1261
|
animation.setMode(json.mode);
|
|
@@ -1247,7 +1341,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1247
1341
|
return {
|
|
1248
1342
|
name: this.name,
|
|
1249
1343
|
delay: this.delay,
|
|
1250
|
-
duration: this.duration,
|
|
1344
|
+
duration: this.duration ?? 1,
|
|
1251
1345
|
bufferTime: this.bufferTime
|
|
1252
1346
|
};
|
|
1253
1347
|
}
|
|
@@ -1315,11 +1409,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1315
1409
|
return captionElement;
|
|
1316
1410
|
}
|
|
1317
1411
|
static deserializeIconElement(json) {
|
|
1318
|
-
var _a, _b;
|
|
1319
|
-
const size = ((_a = json.props) == null ? void 0 : _a.size)
|
|
1412
|
+
var _a, _b, _c;
|
|
1413
|
+
const size = ((_a = json.props) == null ? void 0 : _a.size) ?? { width: 100, height: 100 };
|
|
1320
1414
|
const iconElement = new IconElement(
|
|
1321
1415
|
((_b = json.props) == null ? void 0 : _b.src) || "",
|
|
1322
|
-
size
|
|
1416
|
+
size,
|
|
1417
|
+
(_c = json.props) == null ? void 0 : _c.fill
|
|
1323
1418
|
);
|
|
1324
1419
|
ElementDeserializer.deserializeBaseElement(iconElement, json);
|
|
1325
1420
|
return iconElement;
|
|
@@ -1555,10 +1650,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1555
1650
|
const basicValidation = this.validateBasicProperties(element);
|
|
1556
1651
|
const errors = [...basicValidation.errors];
|
|
1557
1652
|
const warnings = [...basicValidation.warnings];
|
|
1558
|
-
const props = element.getProps();
|
|
1559
|
-
if (!(props == null ? void 0 : props.icon)) {
|
|
1560
|
-
errors.push("Icon element must have an icon name");
|
|
1561
|
-
}
|
|
1562
1653
|
return { errors, warnings };
|
|
1563
1654
|
}
|
|
1564
1655
|
validateCircleElement(element) {
|
|
@@ -1714,15 +1805,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1714
1805
|
* Creates a new Track instance.
|
|
1715
1806
|
*
|
|
1716
1807
|
* @param name - The display name for the track
|
|
1808
|
+
* @param type - The type of the track
|
|
1717
1809
|
* @param id - Optional unique identifier (auto-generated if not provided)
|
|
1718
1810
|
*
|
|
1719
1811
|
* @example
|
|
1720
1812
|
* ```js
|
|
1721
1813
|
* const track = new Track("My Video Track");
|
|
1722
|
-
* const trackWithId = new Track("Audio Track", "
|
|
1814
|
+
* const trackWithId = new Track("Audio Track", "element", "video-track-1");
|
|
1723
1815
|
* ```
|
|
1724
1816
|
*/
|
|
1725
|
-
constructor(name, id) {
|
|
1817
|
+
constructor(name, type = "element", id) {
|
|
1726
1818
|
__publicField(this, "id");
|
|
1727
1819
|
__publicField(this, "name");
|
|
1728
1820
|
__publicField(this, "type");
|
|
@@ -1730,7 +1822,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1730
1822
|
__publicField(this, "validator");
|
|
1731
1823
|
this.name = name;
|
|
1732
1824
|
this.id = id ?? `t-${generateShortUuid}`;
|
|
1733
|
-
this.type =
|
|
1825
|
+
this.type = type;
|
|
1734
1826
|
this.elements = [];
|
|
1735
1827
|
this.validator = new ElementValidator();
|
|
1736
1828
|
}
|
|
@@ -1821,7 +1913,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1821
1913
|
*
|
|
1822
1914
|
* @example
|
|
1823
1915
|
* ```js
|
|
1824
|
-
* const track = new Track("My Track", "track-123");
|
|
1916
|
+
* const track = new Track("My Track", "element", "track-123");
|
|
1825
1917
|
* const id = track.getId(); // "track-123"
|
|
1826
1918
|
* ```
|
|
1827
1919
|
*/
|
|
@@ -2163,7 +2255,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2163
2255
|
* ```
|
|
2164
2256
|
*/
|
|
2165
2257
|
static fromJSON(json) {
|
|
2166
|
-
const track = new Track(json.name, json.id);
|
|
2258
|
+
const track = new Track(json.name, json.type ?? "element", json.id);
|
|
2167
2259
|
track.type = json.type;
|
|
2168
2260
|
track.elements = (json.elements || []).map(ElementDeserializer.fromJSON);
|
|
2169
2261
|
return track;
|
|
@@ -2585,7 +2677,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2585
2677
|
visitIconElement(element) {
|
|
2586
2678
|
const clonedElement = new IconElement(
|
|
2587
2679
|
element.getProps().src,
|
|
2588
|
-
element.getProps().size
|
|
2680
|
+
element.getProps().size,
|
|
2681
|
+
element.getProps().fill
|
|
2589
2682
|
);
|
|
2590
2683
|
this.cloneElementProperties(element, clonedElement);
|
|
2591
2684
|
return clonedElement;
|
|
@@ -2774,10 +2867,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2774
2867
|
this.context.updateChangeLog();
|
|
2775
2868
|
return updatedTimelineData;
|
|
2776
2869
|
}
|
|
2777
|
-
addTrack(name) {
|
|
2870
|
+
addTrack(name, type = "element") {
|
|
2778
2871
|
const prevTimelineData = this.getTimelineData();
|
|
2779
2872
|
const id = `t-${generateShortUuid()}`;
|
|
2780
|
-
const track = new Track(name, id);
|
|
2873
|
+
const track = new Track(name, type, id);
|
|
2781
2874
|
const updatedTimelines = [...(prevTimelineData == null ? void 0 : prevTimelineData.tracks) || [], track];
|
|
2782
2875
|
this.setTimelineData(updatedTimelines);
|
|
2783
2876
|
return track;
|
|
@@ -2864,12 +2957,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2864
2957
|
/**
|
|
2865
2958
|
* Update an element in a specific track using the visitor pattern
|
|
2866
2959
|
* @param element The updated element
|
|
2867
|
-
* @returns
|
|
2960
|
+
* @returns TrackElement the updated element
|
|
2868
2961
|
*/
|
|
2869
2962
|
updateElement(element) {
|
|
2870
2963
|
const track = this.getTrackById(element.getTrackId());
|
|
2871
2964
|
if (!track) {
|
|
2872
|
-
return
|
|
2965
|
+
return element;
|
|
2873
2966
|
}
|
|
2874
2967
|
try {
|
|
2875
2968
|
const elementUpdater = new ElementUpdater(track);
|
|
@@ -2880,9 +2973,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2880
2973
|
this.setTimelineData(currentData.tracks);
|
|
2881
2974
|
}
|
|
2882
2975
|
}
|
|
2883
|
-
return
|
|
2976
|
+
return element;
|
|
2884
2977
|
} catch (error) {
|
|
2885
|
-
return
|
|
2978
|
+
return element;
|
|
2886
2979
|
}
|
|
2887
2980
|
}
|
|
2888
2981
|
/**
|
|
@@ -7695,6 +7788,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7695
7788
|
const TimelineProviderInner = ({
|
|
7696
7789
|
contextId,
|
|
7697
7790
|
children,
|
|
7791
|
+
resolution,
|
|
7698
7792
|
initialData
|
|
7699
7793
|
}) => {
|
|
7700
7794
|
const [timelineAction, setTimelineActionState] = React.useState({
|
|
@@ -7704,6 +7798,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7704
7798
|
const [selectedItem, setSelectedItem] = React.useState(
|
|
7705
7799
|
null
|
|
7706
7800
|
);
|
|
7801
|
+
const [videoResolution, setVideoResolution] = React.useState(resolution ?? { width: 720, height: 1280 });
|
|
7707
7802
|
const [totalDuration, setTotalDuration] = React.useState(0);
|
|
7708
7803
|
const [changeLog, setChangeLog] = React.useState(0);
|
|
7709
7804
|
const undoRedoContext = useUndoRedo();
|
|
@@ -7758,9 +7853,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7758
7853
|
timelineAction,
|
|
7759
7854
|
totalDuration,
|
|
7760
7855
|
changeLog,
|
|
7856
|
+
videoResolution,
|
|
7761
7857
|
present: undoRedoContext.present,
|
|
7762
7858
|
canUndo: undoRedoContext.canUndo,
|
|
7763
7859
|
canRedo: undoRedoContext.canRedo,
|
|
7860
|
+
setVideoResolution,
|
|
7764
7861
|
setSelectedItem,
|
|
7765
7862
|
setTimelineAction,
|
|
7766
7863
|
editor
|
|
@@ -7771,6 +7868,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7771
7868
|
const TimelineProvider = ({
|
|
7772
7869
|
contextId,
|
|
7773
7870
|
children,
|
|
7871
|
+
resolution = { width: 720, height: 1280 },
|
|
7774
7872
|
initialData,
|
|
7775
7873
|
undoRedoPersistenceKey,
|
|
7776
7874
|
maxHistorySize
|
|
@@ -7792,6 +7890,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7792
7890
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7793
7891
|
TimelineProviderInner,
|
|
7794
7892
|
{
|
|
7893
|
+
resolution,
|
|
7795
7894
|
initialData,
|
|
7796
7895
|
contextId,
|
|
7797
7896
|
undoRedoPersistenceKey,
|