@twick/video-editor 0.14.2 → 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/README.md CHANGED
@@ -1,19 +1,135 @@
1
1
  # @twick/video-editor
2
2
 
3
- A React component for video editing and timeline management
3
+ A React component for video editing and timeline management with advanced features.
4
+
5
+ ## Overview
6
+
7
+ This package provides a comprehensive video editing interface with timeline management, multi-track support, and real-time preview capabilities. It integrates seamlessly with other Twick packages to create a complete video editing solution.
4
8
 
5
9
  ## Features
6
10
 
7
- - 🎥 Video preview with custom controls
8
- - ⏱️ Timeline-based editing interface
9
- - 📊 Multi-track timeline support
10
- - 🎯 Customizable video dimensions
11
- - 🔄 Drag-and-drop timeline reordering
12
- - High-performance video rendering
11
+ - Video preview with custom controls
12
+ - Timeline-based editing interface
13
+ - Multi-track timeline support
14
+ - Customizable video dimensions
15
+ - Drag-and-drop timeline reordering
16
+ - High-performance video rendering
17
+ - Real-time project updates
18
+ - Advanced timeline manipulation
19
+ - Professional editing tools
13
20
 
14
21
  ## Requirements
15
22
 
16
23
  - React 18 or higher
17
24
  - Browser environment with HTML5 Video support
18
25
 
19
- ## Installation
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install @twick/video-editor
30
+ # or
31
+ pnpm add @twick/video-editor
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```tsx
37
+ import { VideoEditor } from '@twick/video-editor';
38
+ import { LivePlayerProvider } from '@twick/live-player';
39
+ import { TimelineProvider } from '@twick/timeline';
40
+
41
+ function App() {
42
+ return (
43
+ <LivePlayerProvider>
44
+ <TimelineProvider
45
+ initialData={{
46
+ timeline: [],
47
+ version: 0,
48
+ }}
49
+ >
50
+ <VideoEditor
51
+ leftPanel={null}
52
+ rightPanel={null}
53
+ editorConfig={{
54
+ videoProps: {
55
+ width: 720,
56
+ height: 1280,
57
+ },
58
+ }}
59
+ />
60
+ </TimelineProvider>
61
+ </LivePlayerProvider>
62
+ );
63
+ }
64
+ ```
65
+
66
+ ## Key Features
67
+
68
+ ### Video Preview
69
+ - Real-time video playback with custom controls
70
+ - Frame-accurate timeline scrubbing
71
+ - Multiple preview quality options
72
+ - Responsive video display
73
+
74
+ ### Timeline Management
75
+ - Multi-track timeline interface
76
+ - Drag-and-drop element reordering
77
+ - Visual timeline representation
78
+ - Time-based element positioning
79
+
80
+ ### Editing Tools
81
+ - Text overlay capabilities
82
+ - Image and video element support
83
+ - Audio track management
84
+ - Effect and transition tools
85
+
86
+ ### Performance
87
+ - Optimized rendering pipeline
88
+ - Efficient memory management
89
+ - Smooth playback performance
90
+ - Real-time updates
91
+
92
+ ## API Reference
93
+
94
+ ### Components
95
+
96
+ - `VideoEditor`: Main video editor component
97
+
98
+ ### Props
99
+
100
+ - `leftPanel`: Custom left panel component
101
+ - `rightPanel`: Custom right panel component
102
+ - `editorConfig`: Editor configuration object
103
+ - `videoProps`: Video properties configuration
104
+
105
+ ### Types
106
+
107
+ - `VideoEditorProps`: Props interface for VideoEditor
108
+ - `EditorConfig`: Editor configuration interface
109
+ - `VideoProps`: Video properties interface
110
+
111
+ For complete API documentation, refer to the generated documentation.
112
+
113
+ ## Browser Support
114
+
115
+ This package requires a browser environment with support for:
116
+ - HTML5 Video and Audio
117
+ - Canvas API
118
+ - Drag and Drop API
119
+ - Modern JavaScript features (ES2020+)
120
+
121
+ ## Documentation
122
+
123
+ For complete documentation, refer to the project documentation site.
124
+
125
+ ## License
126
+
127
+ This package is licensed under the **Sustainable Use License (SUL) Version 1.0**.
128
+
129
+ - Free for use in commercial and non-commercial apps
130
+ - Can be modified and self-hosted
131
+ - Cannot be sold, rebranded, or distributed as a standalone SDK
132
+
133
+ For commercial licensing inquiries, contact: contact@kifferai.com
134
+
135
+ For full license terms, see the main LICENSE.md file in the project root.
@@ -2,18 +2,57 @@ import { default as React } from 'react';
2
2
  import { PLAYER_STATE } from '@twick/live-player';
3
3
  import { TrackElement, Track } from '@twick/timeline';
4
4
 
5
- interface PlayerControlsProps {
5
+ /**
6
+ * Props for the PlayerControls component.
7
+ * Defines the configuration options and callback functions for player controls.
8
+ *
9
+ * @example
10
+ * ```jsx
11
+ * <PlayerControls
12
+ * selectedItem={selectedElement}
13
+ * currentTime={5.5}
14
+ * duration={120}
15
+ * canUndo={true}
16
+ * canRedo={false}
17
+ * playerState={PLAYER_STATE.PLAYING}
18
+ * togglePlayback={handleTogglePlayback}
19
+ * onUndo={handleUndo}
20
+ * onRedo={handleRedo}
21
+ * onDelete={handleDelete}
22
+ * onSplit={handleSplit}
23
+ * zoomLevel={1.0}
24
+ * setZoomLevel={handleZoomChange}
25
+ * />
26
+ * ```
27
+ */
28
+ export interface PlayerControlsProps {
29
+ /** Currently selected timeline element or track */
6
30
  selectedItem: TrackElement | Track | null;
31
+ /** Current playback time in seconds */
7
32
  currentTime: number;
33
+ /** Total duration of the timeline in seconds */
8
34
  duration: number;
35
+ /** Whether undo operation is available */
9
36
  canUndo: boolean;
37
+ /** Whether redo operation is available */
10
38
  canRedo: boolean;
39
+ /** Current player state (playing, paused, refresh) */
11
40
  playerState: keyof typeof PLAYER_STATE;
41
+ /** Function to toggle between play and pause */
12
42
  togglePlayback: () => void;
43
+ /** Optional callback for undo operation */
13
44
  onUndo?: () => void;
45
+ /** Optional callback for redo operation */
14
46
  onRedo?: () => void;
47
+ /** Optional callback for delete operation */
15
48
  onDelete?: (item: TrackElement | Track) => void;
49
+ /** Optional callback for split operation */
16
50
  onSplit?: (item: TrackElement, splitTime: number) => void;
51
+ /** Current zoom level for timeline */
52
+ zoomLevel?: number;
53
+ /** Function to set zoom level */
54
+ setZoomLevel?: (zoom: number) => void;
55
+ /** Optional CSS class name for styling */
17
56
  className?: string;
18
57
  }
19
58
  declare const PlayerControls: React.FC<PlayerControlsProps>;
@@ -3,6 +3,7 @@ export declare const PlayerManager: ({ videoProps, canvasMode, }: {
3
3
  videoProps: {
4
4
  width: number;
5
5
  height: number;
6
+ backgroundColor?: string;
6
7
  };
7
8
  canvasMode: boolean;
8
9
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,13 @@
1
1
  import { Track, TrackElement } from '@twick/timeline';
2
2
 
3
- declare function TimelineView({ zoomLevel, selectedItem, duration, tracks, seekTrack, onReorder, onSelectionChange, onElementDrag, }: {
3
+ declare function TimelineView({ zoomLevel, selectedItem, duration, tracks, seekTrack, onAddTrack, onReorder, onSelectionChange, onElementDrag, }: {
4
4
  timelineControls?: React.ReactNode;
5
5
  zoomLevel: number;
6
6
  duration: number;
7
7
  tracks: Track[];
8
8
  selectedItem: Track | TrackElement | null;
9
9
  seekTrack?: React.ReactNode;
10
+ onAddTrack: () => void;
10
11
  onReorder: (tracks: Track[]) => void;
11
12
  onElementDrag: ({ element, dragType, updates, }: {
12
13
  element: TrackElement;
@@ -5,7 +5,7 @@ export declare const TrackElementView: React.FC<{
5
5
  selectedItem: TrackElement | null;
6
6
  parentWidth: number;
7
7
  duration: number;
8
- nextStart: number;
8
+ nextStart: number | null;
9
9
  prevEnd: number;
10
10
  allowOverlap: boolean;
11
11
  onSelection: (element: TrackElement) => void;
@@ -1,18 +1,106 @@
1
1
  import { default as React } from 'react';
2
2
 
3
- interface VideoEditorProps {
3
+ /**
4
+ * Configuration options for the video editor.
5
+ * Defines the video properties and editor behavior settings.
6
+ *
7
+ * @example
8
+ * ```js
9
+ * const editorConfig = {
10
+ * videoProps: { width: 1920, height: 1080 },
11
+ * canvasMode: true
12
+ * };
13
+ * ```
14
+ */
15
+ export interface VideoEditorConfig {
16
+ /** Video dimensions and properties */
17
+ videoProps: {
18
+ /** Width of the video in pixels */
19
+ width: number;
20
+ /** Height of the video in pixels */
21
+ height: number;
22
+ /** Background color of the video */
23
+ backgroundColor?: string;
24
+ };
25
+ /** Whether to use canvas mode for rendering */
26
+ canvasMode?: boolean;
27
+ }
28
+ /**
29
+ * Props for the VideoEditor component.
30
+ * Defines the configuration options and custom panels for the video editor.
31
+ *
32
+ * @example
33
+ * ```jsx
34
+ * <VideoEditor
35
+ * leftPanel={<MediaPanel />}
36
+ * rightPanel={<PropertiesPanel />}
37
+ * bottomPanel={<EffectsPanel />}
38
+ * editorConfig={{
39
+ * videoProps: { width: 1920, height: 1080 },
40
+ * canvasMode: true
41
+ * }}
42
+ * defaultPlayControls={true}
43
+ * />
44
+ * ```
45
+ */
46
+ export interface VideoEditorProps {
47
+ /** Custom left panel component (e.g., media library) */
4
48
  leftPanel?: React.ReactNode;
49
+ /** Custom right panel component (e.g., properties inspector) */
5
50
  rightPanel?: React.ReactNode;
51
+ /** Custom bottom panel component (e.g., effects library) */
6
52
  bottomPanel?: React.ReactNode;
53
+ /** Custom play controls component */
7
54
  playControls?: React.ReactNode;
55
+ /** Whether to show default play controls if no custom controls provided */
8
56
  defaultPlayControls?: boolean;
9
- editorConfig: {
10
- videoProps: {
11
- width: number;
12
- height: number;
13
- };
14
- canvasMode?: boolean;
15
- };
57
+ /** Editor configuration including video properties and mode settings */
58
+ editorConfig: VideoEditorConfig;
16
59
  }
60
+ /**
61
+ * VideoEditor is the main component for the Twick video editing interface.
62
+ * Provides a complete video editing environment with timeline management,
63
+ * player controls, and customizable panels for media, properties, and effects.
64
+ *
65
+ * The editor consists of:
66
+ * - Left panel: Media library and assets
67
+ * - Center: Video player and preview
68
+ * - Right panel: Properties and settings
69
+ * - Bottom: Timeline and track management
70
+ * - Controls: Playback controls and timeline zoom
71
+ *
72
+ * @param props - VideoEditor configuration and custom panels
73
+ * @returns Complete video editing interface
74
+ *
75
+ * @example
76
+ * ```jsx
77
+ * import VideoEditor from '@twick/video-editor';
78
+ *
79
+ * function MyVideoEditor() {
80
+ * return (
81
+ * <VideoEditor
82
+ * leftPanel={<MediaLibrary />}
83
+ * rightPanel={<PropertiesPanel />}
84
+ * bottomPanel={<EffectsPanel />}
85
+ * editorConfig={{
86
+ * videoProps: { width: 1920, height: 1080 },
87
+ * canvasMode: true
88
+ * }}
89
+ * defaultPlayControls={true}
90
+ * />
91
+ * );
92
+ * }
93
+ * ```
94
+ *
95
+ * @example
96
+ * ```jsx
97
+ * // Minimal configuration
98
+ * <VideoEditor
99
+ * editorConfig={{
100
+ * videoProps: { width: 1280, height: 720 }
101
+ * }}
102
+ * />
103
+ * ```
104
+ */
17
105
  declare const VideoEditor: React.FC<VideoEditorProps>;
18
106
  export default VideoEditor;
@@ -1,3 +1,38 @@
1
1
  import { Animation } from './types';
2
2
 
3
+ /**
4
+ * Collection of available animations for video editor elements.
5
+ * Provides predefined animation configurations with sample previews
6
+ * that can be applied to timeline elements.
7
+ *
8
+ * @example
9
+ * ```js
10
+ * import { ANIMATIONS } from '@twick/video-editor';
11
+ *
12
+ * // Get all available animations
13
+ * const allAnimations = ANIMATIONS;
14
+ *
15
+ * // Find a specific animation
16
+ * const fadeAnimation = ANIMATIONS.find(anim => anim.name === 'fade');
17
+ *
18
+ * // Get animation sample
19
+ * const sampleGif = fadeAnimation.getSample();
20
+ *
21
+ * // Apply animation to element
22
+ * element.setAnimation(fadeAnimation);
23
+ * ```
24
+ *
25
+ * @example
26
+ * ```js
27
+ * // Use animation with custom settings
28
+ * const riseAnimation = ANIMATIONS.find(anim => anim.name === 'rise');
29
+ * const customRise = {
30
+ * ...riseAnimation,
31
+ * direction: 'down',
32
+ * interval: 2
33
+ * };
34
+ *
35
+ * element.setAnimation(customRise);
36
+ * ```
37
+ */
3
38
  export declare const ANIMATIONS: Animation[];
@@ -1,5 +1,20 @@
1
1
  import { ElementColors } from './types';
2
2
 
3
+ /**
4
+ * Initial timeline data structure for new video editor projects.
5
+ * Provides a default timeline with a sample text element to get started.
6
+ *
7
+ * @example
8
+ * ```js
9
+ * import { INITIAL_TIMELINE_DATA } from '@twick/video-editor';
10
+ *
11
+ * // Use as starting point for new projects
12
+ * const newProject = {
13
+ * ...INITIAL_TIMELINE_DATA,
14
+ * tracks: [...INITIAL_TIMELINE_DATA.tracks, newTrack]
15
+ * };
16
+ * ```
17
+ */
3
18
  export declare const INITIAL_TIMELINE_DATA: {
4
19
  tracks: {
5
20
  type: string;
@@ -20,35 +35,140 @@ export declare const INITIAL_TIMELINE_DATA: {
20
35
  }[];
21
36
  version: number;
22
37
  };
38
+ /**
39
+ * Minimum duration for timeline elements in seconds.
40
+ * Used to prevent elements from having zero or negative duration.
41
+ *
42
+ * @example
43
+ * ```js
44
+ * import { MIN_DURATION } from '@twick/video-editor';
45
+ *
46
+ * const elementDuration = Math.max(duration, MIN_DURATION);
47
+ * // Ensures element has at least 0.1 seconds duration
48
+ * ```
49
+ */
23
50
  export declare const MIN_DURATION = 0.1;
51
+ /**
52
+ * Drag operation types for timeline interactions.
53
+ * Defines the different phases of drag operations on timeline elements.
54
+ *
55
+ * @example
56
+ * ```js
57
+ * import { DRAG_TYPE } from '@twick/video-editor';
58
+ *
59
+ * function handleDrag(type) {
60
+ * switch (type) {
61
+ * case DRAG_TYPE.START:
62
+ * // Handle drag start
63
+ * break;
64
+ * case DRAG_TYPE.MOVE:
65
+ * // Handle drag move
66
+ * break;
67
+ * case DRAG_TYPE.END:
68
+ * // Handle drag end
69
+ * break;
70
+ * }
71
+ * }
72
+ * ```
73
+ */
24
74
  export declare const DRAG_TYPE: {
25
- START: string;
26
- MOVE: string;
27
- END: string;
75
+ /** Drag operation is starting */
76
+ readonly START: "start";
77
+ /** Drag operation is in progress */
78
+ readonly MOVE: "move";
79
+ /** Drag operation has ended */
80
+ readonly END: "end";
28
81
  };
82
+ /**
83
+ * Default zoom level for timeline view.
84
+ * Controls the initial magnification of the timeline interface.
85
+ *
86
+ * @example
87
+ * ```js
88
+ * import { DEFAULT_TIMELINE_ZOOM } from '@twick/video-editor';
89
+ *
90
+ * const [zoom, setZoom] = useState(DEFAULT_TIMELINE_ZOOM);
91
+ * // Timeline starts with 1.5x zoom
92
+ * ```
93
+ */
29
94
  export declare const DEFAULT_TIMELINE_ZOOM = 1.5;
95
+ /**
96
+ * Default color scheme for different element types in the timeline.
97
+ * Provides consistent visual distinction between various timeline elements.
98
+ *
99
+ * @example
100
+ * ```js
101
+ * import { DEFAULT_ELEMENT_COLORS } from '@twick/video-editor';
102
+ *
103
+ * const videoColor = DEFAULT_ELEMENT_COLORS.video; // "#4B2E83"
104
+ * const textColor = DEFAULT_ELEMENT_COLORS.text; // "#375A7F"
105
+ *
106
+ * // Apply colors to timeline elements
107
+ * element.style.backgroundColor = DEFAULT_ELEMENT_COLORS[element.type];
108
+ * ```
109
+ */
30
110
  export declare const DEFAULT_ELEMENT_COLORS: ElementColors;
111
+ /**
112
+ * Available text fonts for video editor text elements.
113
+ * Includes Google Fonts, display fonts, and custom CDN fonts.
114
+ *
115
+ * @example
116
+ * ```js
117
+ * import { AVAILABLE_TEXT_FONTS } from '@twick/video-editor';
118
+ *
119
+ * // Use Google Fonts
120
+ * const googleFont = AVAILABLE_TEXT_FONTS.ROBOTO; // "Roboto"
121
+ *
122
+ * // Use decorative fonts
123
+ * const decorativeFont = AVAILABLE_TEXT_FONTS.BANGERS; // "Bangers"
124
+ *
125
+ * // Apply font to text element
126
+ * textElement.style.fontFamily = AVAILABLE_TEXT_FONTS.POPPINS;
127
+ * ```
128
+ */
31
129
  export declare const AVAILABLE_TEXT_FONTS: {
32
- RUBIK: string;
33
- MULISH: string;
34
- LUCKIEST_GUY: string;
35
- PLAYFAIR_DISPLAY: string;
36
- ROBOTO: string;
37
- POPPINS: string;
38
- BANGERS: string;
39
- BIRTHSTONE: string;
40
- CORINTHIA: string;
41
- IMPERIAL_SCRIPT: string;
42
- KUMAR_ONE_OUTLINE: string;
43
- LONDRI_OUTLINE: string;
44
- MARCK_SCRIPT: string;
45
- MONTSERRAT: string;
46
- PATTAYA: string;
47
- PERALTA: string;
48
- IMPACT: string;
49
- LUMANOSIMO: string;
50
- KAPAKANA: string;
51
- HANDYRUSH: string;
52
- DASHER: string;
53
- BRITTANY_SIGNATURE: string;
130
+ /** Modern sans-serif font */
131
+ readonly RUBIK: "Rubik";
132
+ /** Clean and readable font */
133
+ readonly MULISH: "Mulish";
134
+ /** Bold display font */
135
+ readonly LUCKIEST_GUY: "Luckiest Guy";
136
+ /** Elegant serif font */
137
+ readonly PLAYFAIR_DISPLAY: "Playfair Display";
138
+ /** Classic sans-serif font */
139
+ readonly ROBOTO: "Roboto";
140
+ /** Modern geometric font */
141
+ readonly POPPINS: "Poppins";
142
+ /** Comic-style display font */
143
+ readonly BANGERS: "Bangers";
144
+ /** Handwritten-style font */
145
+ readonly BIRTHSTONE: "Birthstone";
146
+ /** Elegant script font */
147
+ readonly CORINTHIA: "Corinthia";
148
+ /** Formal script font */
149
+ readonly IMPERIAL_SCRIPT: "Imperial Script";
150
+ /** Bold outline font */
151
+ readonly KUMAR_ONE_OUTLINE: "Kumar One Outline";
152
+ /** Light outline font */
153
+ readonly LONDRI_OUTLINE: "Londrina Outline";
154
+ /** Casual script font */
155
+ readonly MARCK_SCRIPT: "Marck Script";
156
+ /** Modern sans-serif font */
157
+ readonly MONTSERRAT: "Montserrat";
158
+ /** Stylish display font */
159
+ readonly PATTAYA: "Pattaya";
160
+ /** Unique display font */
161
+ readonly PERALTA: "Peralta";
162
+ /** Bold impact font */
163
+ readonly IMPACT: "Impact";
164
+ /** Handwritten-style font */
165
+ readonly LUMANOSIMO: "Lumanosimo";
166
+ /** Custom display font */
167
+ readonly KAPAKANA: "Kapakana";
168
+ /** Handwritten font */
169
+ readonly HANDYRUSH: "HandyRush";
170
+ /** Decorative font */
171
+ readonly DASHER: "Dasher";
172
+ /** Signature-style font */
173
+ readonly BRITTANY_SIGNATURE: "Brittany Signature";
54
174
  };
@@ -1,3 +1,35 @@
1
1
  import { TextEffect } from './types';
2
2
 
3
+ /**
4
+ * Collection of available text effects for video editor text elements.
5
+ * Provides predefined text animation configurations that can be applied
6
+ * to text elements in the timeline.
7
+ *
8
+ * @example
9
+ * ```js
10
+ * import { TEXT_EFFECTS } from '@twick/video-editor';
11
+ *
12
+ * // Get all available text effects
13
+ * const allTextEffects = TEXT_EFFECTS;
14
+ *
15
+ * // Find a specific text effect
16
+ * const typewriterEffect = TEXT_EFFECTS.find(effect => effect.name === 'typewriter');
17
+ *
18
+ * // Apply text effect to element
19
+ * textElement.setTextEffect(typewriterEffect);
20
+ * ```
21
+ *
22
+ * @example
23
+ * ```js
24
+ * // Use text effect with custom settings
25
+ * const elasticEffect = TEXT_EFFECTS.find(effect => effect.name === 'elastic');
26
+ * const customElastic = {
27
+ * ...elasticEffect,
28
+ * delay: 0.5,
29
+ * bufferTime: 0.2
30
+ * };
31
+ *
32
+ * textElement.setTextEffect(customElastic);
33
+ * ```
34
+ */
3
35
  export declare const TEXT_EFFECTS: TextEffect[];