@twick/timeline 0.14.3 → 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/context/timeline-context.d.ts +8 -2
- package/dist/core/addOns/animation.d.ts +3 -0
- package/dist/core/editor/timeline.editor.d.ts +8 -4
- 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-CXhwwSX--DHE9Xex3.js.map +1 -1
- package/dist/index.js +146 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -35
- 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 +3 -3
|
@@ -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;
|
|
@@ -32,8 +32,12 @@ export declare class TimelineEditor {
|
|
|
32
32
|
pauseVideo(): void;
|
|
33
33
|
getTimelineData(): TimelineTrackData | null;
|
|
34
34
|
getLatestVersion(): number;
|
|
35
|
-
protected setTimelineData(tracks
|
|
36
|
-
|
|
35
|
+
protected setTimelineData({ tracks, version, updatePlayerData, }: {
|
|
36
|
+
tracks: Track[];
|
|
37
|
+
version?: number;
|
|
38
|
+
updatePlayerData?: boolean;
|
|
39
|
+
}): TimelineTrackData;
|
|
40
|
+
addTrack(name: string, type?: string): Track;
|
|
37
41
|
getTrackById(id: string): Track | null;
|
|
38
42
|
getTrackByName(name: string): Track | null;
|
|
39
43
|
removeTrackById(id: string): void;
|
|
@@ -58,9 +62,9 @@ export declare class TimelineEditor {
|
|
|
58
62
|
/**
|
|
59
63
|
* Update an element in a specific track using the visitor pattern
|
|
60
64
|
* @param element The updated element
|
|
61
|
-
* @returns
|
|
65
|
+
* @returns TrackElement the updated element
|
|
62
66
|
*/
|
|
63
|
-
updateElement(element: TrackElement):
|
|
67
|
+
updateElement(element: TrackElement): TrackElement;
|
|
64
68
|
/**
|
|
65
69
|
* Split an element at a specific time point using the visitor pattern
|
|
66
70
|
* @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
|
*/
|