@designcombo/video 0.0.2 → 0.0.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.
Files changed (32) hide show
  1. package/dist/{SharedSystems-BWe03l6N.js → SharedSystems-Cv0Hv-t_.js} +1 -1
  2. package/dist/{WebGLRenderer-CKduQ9yw.js → WebGLRenderer-CeXIsNm5.js} +2 -2
  3. package/dist/{WebGPURenderer-BSX8DZj-.js → WebGPURenderer-CKsFf2P8.js} +2 -2
  4. package/dist/{browserAll-CwPYLzJJ.js → browserAll-CVO4QZK1.js} +2 -2
  5. package/dist/clips/audio-clip.d.ts +1 -4
  6. package/dist/clips/base-clip.d.ts +6 -1
  7. package/dist/clips/caption-clip.d.ts +10 -9
  8. package/dist/clips/effect-clip.d.ts +37 -0
  9. package/dist/clips/iclip.d.ts +22 -0
  10. package/dist/clips/image-clip.d.ts +2 -1
  11. package/dist/clips/index.d.ts +2 -0
  12. package/dist/clips/text-clip.d.ts +53 -52
  13. package/dist/clips/transition-clip.d.ts +37 -0
  14. package/dist/clips/video-clip.d.ts +7 -7
  15. package/dist/effect/glsl/custom-glsl.d.ts +499 -5
  16. package/dist/{index-C333riU-.js → index-CZk_O50g.js} +15065 -8677
  17. package/dist/index.d.ts +4 -1
  18. package/dist/index.es.js +20 -16
  19. package/dist/index.umd.js +5010 -162
  20. package/dist/json-serialization.d.ts +32 -4
  21. package/dist/sprite/base-sprite.d.ts +44 -21
  22. package/dist/sprite/pixi-sprite-renderer.d.ts +0 -12
  23. package/dist/studio.d.ts +152 -6
  24. package/dist/transition/fragment.d.ts +1 -0
  25. package/dist/transition/glsl/custom-glsl.d.ts +229 -0
  26. package/dist/transition/glsl/gl-transition.d.ts +14 -0
  27. package/dist/transition/transition.d.ts +5 -0
  28. package/dist/transition/types.d.ts +29 -0
  29. package/dist/transition/uniforms.d.ts +35 -0
  30. package/dist/transition/vertex.d.ts +1 -0
  31. package/dist/{webworkerAll-aNnyDpl9.js → webworkerAll-C-9pdN3u.js} +1 -1
  32. package/package.json +2 -1
@@ -1,4 +1,4 @@
1
- import { IClip } from './clips';
1
+ import { IClip, ITransitionInfo } from './clips';
2
2
  interface BaseClipJSON {
3
3
  id?: string;
4
4
  effects?: Array<{
@@ -23,6 +23,11 @@ interface BaseClipJSON {
23
23
  zIndex: number;
24
24
  opacity: number;
25
25
  flip: 'horizontal' | 'vertical' | null;
26
+ trim?: {
27
+ from: number;
28
+ to: number;
29
+ };
30
+ transition?: ITransitionInfo;
26
31
  animation?: {
27
32
  keyFrames: Record<string, Partial<{
28
33
  x: number;
@@ -43,6 +48,7 @@ interface BaseClipJSON {
43
48
  export interface VideoClipJSON extends BaseClipJSON {
44
49
  type: 'Video';
45
50
  audio?: boolean;
51
+ volume?: number;
46
52
  }
47
53
  export interface AudioClipJSON extends BaseClipJSON {
48
54
  type: 'Audio';
@@ -71,8 +77,8 @@ export interface TextStyleJSON {
71
77
  color: string;
72
78
  alpha: number;
73
79
  blur: number;
74
- offsetX: number;
75
- offsetY: number;
80
+ distance: number;
81
+ angle: number;
76
82
  };
77
83
  wordWrap?: boolean;
78
84
  wordWrapWidth?: number;
@@ -129,9 +135,31 @@ export interface CaptionClipJSON extends BaseClipJSON {
129
135
  videoHeight?: number;
130
136
  fontUrl?: string;
131
137
  }
132
- export type ClipJSON = VideoClipJSON | AudioClipJSON | ImageClipJSON | TextClipJSON | CaptionClipJSON;
138
+ export interface EffectClipJSON extends BaseClipJSON {
139
+ type: 'Effect';
140
+ effect: {
141
+ id: string;
142
+ key: string;
143
+ name: string;
144
+ };
145
+ }
146
+ export interface TransitionJSON {
147
+ key: string;
148
+ duration: number;
149
+ clips: string[];
150
+ }
151
+ export type ClipJSON = VideoClipJSON | AudioClipJSON | ImageClipJSON | TextClipJSON | CaptionClipJSON | EffectClipJSON;
152
+ export interface StudioTrackJSON {
153
+ id: string;
154
+ name: string;
155
+ type: string;
156
+ clipIds: string[];
157
+ }
133
158
  export interface ProjectJSON {
159
+ tracks?: StudioTrackJSON[];
134
160
  clips: ClipJSON[];
161
+ transition?: TransitionJSON[];
162
+ transitions?: TransitionJSON[];
135
163
  globalEffects?: Array<{
136
164
  id: string;
137
165
  key: string;
@@ -1,3 +1,4 @@
1
+ import { default as EventEmitter } from '../event-emitter';
1
2
  type IRectBaseProps = any;
2
3
  interface IAnimationOpts {
3
4
  duration: number;
@@ -9,12 +10,30 @@ type TAnimateProps = IRectBaseProps & {
9
10
  };
10
11
  export type TAnimationKeyFrame = Array<[number, Partial<TAnimateProps>]>;
11
12
  type TKeyFrameOpts = Partial<Record<`${number}%` | 'from' | 'to', Partial<TAnimateProps>>>;
13
+ export interface BaseSpriteEvents {
14
+ propsChange: Partial<{
15
+ left: number;
16
+ top: number;
17
+ width: number;
18
+ height: number;
19
+ angle: number;
20
+ zIndex: number;
21
+ opacity: number;
22
+ volume: number;
23
+ }>;
24
+ [key: string]: any;
25
+ [key: symbol]: any;
26
+ }
12
27
  /**
13
28
  * Sprite base class
14
29
  *
15
30
  * @see {@link OffscreenSprite}
16
31
  */
17
- export declare abstract class BaseSprite {
32
+ export declare abstract class BaseSprite extends EventEmitter<BaseSpriteEvents> {
33
+ /**
34
+ * Unique identifier for the sprite/clip
35
+ */
36
+ id: string;
18
37
  /**
19
38
  * Control display time range of clips, commonly used in editing scenario timeline (track) module
20
39
  * from: start time offset in microseconds
@@ -36,22 +55,16 @@ export declare abstract class BaseSprite {
36
55
  * 2. Audio uses the simplest interpolation algorithm to change rate, so changing rate will cause pitch variation, for custom algorithm please use {@link VideoClip.tickInterceptor} to implement
37
56
  */
38
57
  playbackRate: number;
39
- private evtTool;
40
58
  /**
41
- * Listen to property change events
42
- * @example
43
- * sprite.on('propsChange', (changedProps) => {})
44
- */
45
- on: <Type extends "propsChange">(type: Type, listener: {
46
- propsChange: (value: Partial<{
47
- left: number;
48
- top: number;
49
- width: number;
50
- height: number;
51
- angle: number;
52
- zIndex: number;
53
- }>) => void;
54
- }[Type]) => (() => void);
59
+ * Trim range of the source media in microseconds
60
+ * from: start time in microseconds
61
+ * to: end time in microseconds
62
+ */
63
+ trim: {
64
+ from: number;
65
+ to: number;
66
+ };
67
+ constructor();
55
68
  private _left;
56
69
  /**
57
70
  * Left position (x coordinate)
@@ -78,8 +91,7 @@ export declare abstract class BaseSprite {
78
91
  set height(v: number);
79
92
  private _angle;
80
93
  /**
81
- * Rotation angle
82
- * @see [MDN Canvas rotate](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/rotate)
94
+ * Rotation angle in degrees
83
95
  */
84
96
  get angle(): number;
85
97
  set angle(v: number);
@@ -96,10 +108,18 @@ export declare abstract class BaseSprite {
96
108
  * Control layering relationship between clips, clips with smaller zIndex will be occluded
97
109
  */
98
110
  set zIndex(v: number);
111
+ private _opacity;
99
112
  /**
100
- * Opacity
113
+ * Opacity (0.0 to 1.0)
101
114
  */
102
- opacity: number;
115
+ get opacity(): number;
116
+ set opacity(v: number);
117
+ private _volume;
118
+ /**
119
+ * Audio volume level (0.0 to 1.0)
120
+ */
121
+ get volume(): number;
122
+ set volume(v: number);
103
123
  /**
104
124
  * Flip clip horizontally or vertically
105
125
  */
@@ -118,7 +138,6 @@ export declare abstract class BaseSprite {
118
138
  * For clips, this should be Promise<IClipMeta>, but for BaseSprite it's just Promise<void>
119
139
  */
120
140
  ready: Promise<any>;
121
- constructor();
122
141
  protected _render(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
123
142
  /**
124
143
  * Add animation to clip, usage reference CSS animation
@@ -148,6 +167,10 @@ export declare abstract class BaseSprite {
148
167
  * Used for cloning or copying state between {@link OffscreenSprite} instances
149
168
  */
150
169
  copyStateTo<T extends BaseSprite>(target: T): void;
170
+ /**
171
+ * Update multiple properties at once
172
+ */
173
+ update(updates: Partial<this>): void;
151
174
  protected destroy(): void;
152
175
  }
153
176
  export declare function linearTimeFn(time: number, keyFrame: TAnimationKeyFrame, opts: Required<IAnimationOpts>): Partial<TAnimateProps>;
@@ -28,21 +28,9 @@ export declare class PixiSpriteRenderer {
28
28
  updateFrame(frame: ImageBitmap | Texture | null): Promise<void>;
29
29
  /**
30
30
  * Apply sprite transformations to the Pixi Sprite
31
- * This reads the current sprite properties (which may have been updated by animations)
32
- * and applies them to the Pixi sprite
33
31
  */
34
32
  private applySpriteTransforms;
35
- /**
36
- * Update sprite properties without changing the frame
37
- * Useful when sprite properties change but frame stays the same
38
- */
39
33
  updateTransforms(): void;
40
- /**
41
- * Get the Pixi Sprite instance
42
- */
43
34
  getSprite(): Sprite | null;
44
- /**
45
- * Destroy the renderer and clean up resources
46
- */
47
35
  destroy(): void;
48
36
  }
package/dist/studio.d.ts CHANGED
@@ -1,4 +1,7 @@
1
+ import { Texture } from 'pixi.js';
2
+ import { ImageClip } from './clips/image-clip';
1
3
  import { IClip } from './clips/iclip';
4
+ import { VideoClip } from './clips/video-clip';
2
5
  import { ProjectJSON } from './json-serialization';
3
6
  import { EffectKey } from './effect/glsl/gl-effect';
4
7
  import { default as EventEmitter } from './event-emitter';
@@ -11,18 +14,49 @@ export interface IStudioOpts {
11
14
  interactivity?: boolean;
12
15
  }
13
16
  export interface StudioEvents {
14
- "selection:created": {
17
+ 'selection:created': {
15
18
  selected: IClip[];
16
19
  };
17
- "selection:updated": {
20
+ 'selection:updated': {
18
21
  selected: IClip[];
19
22
  };
20
- "selection:cleared": {
23
+ 'selection:cleared': {
21
24
  deselected: IClip[];
22
25
  };
26
+ 'track:added': {
27
+ track: StudioTrack;
28
+ };
29
+ 'track:removed': {
30
+ trackId: string;
31
+ };
32
+ 'clip:added': {
33
+ clip: IClip;
34
+ trackId: string;
35
+ };
36
+ 'clip:removed': {
37
+ clipId: string;
38
+ };
39
+ 'clip:updated': {
40
+ clip: IClip;
41
+ };
42
+ currentTime: {
43
+ currentTime: number;
44
+ };
45
+ play: {
46
+ isPlaying: boolean;
47
+ };
48
+ pause: {
49
+ isPlaying: boolean;
50
+ };
23
51
  [key: string]: any;
24
52
  [key: symbol]: any;
25
53
  }
54
+ export interface StudioTrack {
55
+ id: string;
56
+ name: string;
57
+ type: string;
58
+ clipIds: string[];
59
+ }
26
60
  /**
27
61
  * Interactive preview studio for clips with playback controls
28
62
  * Useful for previewing clips before rendering with Compositor
@@ -45,6 +79,7 @@ export interface StudioEvents {
45
79
  */
46
80
  export declare class Studio extends EventEmitter<StudioEvents> {
47
81
  private pixiApp;
82
+ private tracks;
48
83
  private clips;
49
84
  private spriteRenderers;
50
85
  private artboard;
@@ -56,6 +91,7 @@ export declare class Studio extends EventEmitter<StudioEvents> {
56
91
  private interactiveClips;
57
92
  private playbackElements;
58
93
  private videoSprites;
94
+ private clipListeners;
59
95
  private isPlaying;
60
96
  private currentTime;
61
97
  private playStartTime;
@@ -66,32 +102,89 @@ export declare class Studio extends EventEmitter<StudioEvents> {
66
102
  private destroyed;
67
103
  private globalEffects;
68
104
  private activeGlobalEffect;
69
- private postProcessContainer;
105
+ private currentGlobalEffectSprite;
70
106
  private effectFilters;
71
- private scale;
107
+ private transitionRenderers;
108
+ private transitionSprites;
109
+ private transFromTexture;
110
+ private transToTexture;
111
+ private transBgGraphics;
72
112
  private clipsNormalContainer;
73
113
  private clipsEffectContainer;
114
+ private videoTextureCache;
115
+ private lastFromFrame;
116
+ private lastToFrame;
74
117
  /**
75
118
  * Convert hex color string to number
76
119
  */
77
120
  private hexToNumber;
121
+ ready: Promise<void>;
78
122
  /**
79
123
  * Create a new Studio instance
80
124
  */
81
125
  constructor(opts: IStudioOpts);
82
126
  private initPixiApp;
127
+ /**
128
+ * Get studio options
129
+ */
130
+ getOptions(): IStudioOpts;
83
131
  private handleResize;
84
132
  private updateArtboardLayout;
85
133
  /**
86
134
  * Get the canvas element (creates one if not provided)
87
135
  */
88
136
  getCanvas(): HTMLCanvasElement;
137
+ /**
138
+ * Add a Media clip (Video/Image) to the main track with ripple effect
139
+ */
140
+ addMedia(clip: VideoClip | ImageClip): Promise<void>;
141
+ /**
142
+ * Add a Transition clip at the join where the selected clip starts.
143
+ */
144
+ addTransition(transitionKey: string, duration?: number): Promise<void>;
145
+ findTrackIdByClipId(clipId: string): string | undefined;
89
146
  /**
90
147
  * Add a clip to the studio
91
148
  * @param clip The clip to add
92
149
  * @param audioSource Optional audio source (URL, File, or Blob) for AudioClip playback
93
150
  */
94
- addClip(clip: IClip, audioSource?: string | File | Blob): Promise<void>;
151
+ addClip(clip: IClip, options?: {
152
+ trackId?: string;
153
+ audioSource?: string | File | Blob;
154
+ } | string | File | Blob): Promise<void>;
155
+ /**
156
+ * Add a new track to the studio
157
+ */
158
+ addTrack(track: {
159
+ name: string;
160
+ type: string;
161
+ id?: string;
162
+ }): StudioTrack;
163
+ /**
164
+ * Set tracks (and implicitly clips if they are new)
165
+ */
166
+ setTracks(tracks: StudioTrack[]): Promise<void>;
167
+ /**
168
+ * Remove a track and all its clips
169
+ */
170
+ removeTrack(trackId: string): Promise<void>;
171
+ /**
172
+ * Get a clip by its ID
173
+ */
174
+ getClipById(id: string): IClip | undefined;
175
+ /**
176
+ * Update a clip's properties
177
+ * Handles consistency between display (from/to) and duration
178
+ */
179
+ updateClip(id: string, updates: Partial<IClip>): Promise<void>;
180
+ /**
181
+ * Get all tracks
182
+ */
183
+ getTracks(): StudioTrack[];
184
+ /**
185
+ * Get a clip by ID
186
+ */
187
+ getClip(id: string): IClip | undefined;
95
188
  /**
96
189
  * Setup sprite interactivity for click selection
97
190
  */
@@ -105,6 +198,31 @@ export declare class Studio extends EventEmitter<StudioEvents> {
105
198
  * Remove a clip from the studio
106
199
  */
107
200
  removeClip(clip: IClip): Promise<void>;
201
+ /**
202
+ * Remove a clip by its ID
203
+ */
204
+ removeClipById(clipId: string): Promise<void>;
205
+ /**
206
+ * Delete all currently selected clips
207
+ */
208
+ deleteSelected(): Promise<void>;
209
+ /**
210
+ * Duplicate all currently selected clips
211
+ */
212
+ duplicateSelected(): Promise<void>;
213
+ /**
214
+ * Split the selected clip at the given time or current time
215
+ */
216
+ splitSelected(splitTime?: number): Promise<void>;
217
+ /**
218
+ * Trim the selected clip from a specified time
219
+ * @param trimFromSeconds - Number of seconds to trim from the start of the clip
220
+ */
221
+ trimSelected(trimFromSeconds: number): Promise<void>;
222
+ /**
223
+ * Update properties for all currently selected clips
224
+ */
225
+ updateSelected(updates: Partial<IClip>): Promise<void>;
108
226
  /**
109
227
  * Clear all clips from the studio
110
228
  */
@@ -138,7 +256,12 @@ export declare class Studio extends EventEmitter<StudioEvents> {
138
256
  * Check if currently playing
139
257
  */
140
258
  getIsPlaying(): boolean;
259
+ /**
260
+ * Get currently selected clips
261
+ */
262
+ getSelectedClips(): IClip[];
141
263
  private renderLoop;
264
+ private getVideoTexture;
142
265
  private updateFrame;
143
266
  private recalculateMaxDuration;
144
267
  /**
@@ -150,6 +273,16 @@ export declare class Studio extends EventEmitter<StudioEvents> {
150
273
  duration?: number;
151
274
  id?: string;
152
275
  }, clips: IClip[]): string;
276
+ getTrackIndex(clipId: string): number;
277
+ /**
278
+ * Get the frame from the previous clip on the same track for transition
279
+ */
280
+ getTransitionFromFrame(clip: IClip, timestamp: number): Promise<ImageBitmap | null | Texture>;
281
+ private getPreviousClipOnTrack;
282
+ /**
283
+ * Renders a clip frame onto a transition texture with red background
284
+ */
285
+ private renderClipToTransitionTexture;
153
286
  removeGlobalEffect(id: string): void;
154
287
  clearGlobalEffects(): void;
155
288
  private updateActiveGlobalEffect;
@@ -179,6 +312,18 @@ export declare class Studio extends EventEmitter<StudioEvents> {
179
312
  * This ensures clip properties are always up-to-date during transformations
180
313
  */
181
314
  private syncSelectedClipsTransforms;
315
+ /**
316
+ * Sync sprite transforms back to clip properties
317
+ */
318
+ private syncSpriteToClipProperties;
319
+ /**
320
+ * Set the selection to a specific list of clips
321
+ */
322
+ setSelection(clips: IClip[]): void;
323
+ /**
324
+ * Select clips by their IDs
325
+ */
326
+ selectClipsByIds(ids: string[]): void;
182
327
  /**
183
328
  * Deselect the current clip and hide transform controls
184
329
  */
@@ -193,4 +338,5 @@ export declare class Studio extends EventEmitter<StudioEvents> {
193
338
  * @param json The JSON project data
194
339
  */
195
340
  loadFromJSON(json: ProjectJSON): Promise<void>;
341
+ private loadClipIntoTrack;
196
342
  }
@@ -0,0 +1 @@
1
+ export declare const fragment: (glsl: string) => string;