Skip to content

Commit 28d3362

Browse files
committed
applied breaking renaming changes
1 parent 7321510 commit 28d3362

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+238
-222
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ const text = new core.TextClip({
4848
const composition = new core.Composition(); // 1920x1080
4949

5050
// this is how to compose your clips
51-
await composition.appendClip(video); // convenience function for
52-
await composition.appendClip(text); // clip -> track -> composition
51+
await composition.add(video); // convenience function for
52+
await composition.add(text); // clip -> track -> composition
5353

5454
// export video using webcodecs at 25 FPS
5555
new core.WebcodecsEncoder(composition, { fps: 25 })
@@ -62,13 +62,13 @@ This may look familiar to some. That is because the API is heavily inspired by *
6262

6363
Whereas each track contains zero or more clips of a single type in ascending chronological order. Clips within a track cannot overlap with other clips, similar to Adobe Premiere etc.
6464

65-
A track will be created implicitly with `composition.appendClip(clip)` however you can also create them manually like this:
65+
A track will be created implicitly with `composition.add(clip)` however you can also create them manually like this:
6666

6767
```typescript
68-
const track = composition.appendTrack(core.TextTrack);
69-
await track.appendClip(text0);
70-
await track.appendClip(text1);
71-
await track.appendClip(text2);
68+
const track = composition.createTrack('text');
69+
await track.add(text0);
70+
await track.add(text1);
71+
await track.add(text2);
7272
...
7373
```
7474

playground/hello-world.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const text = new core.TextClip({
2020
const composition = new core.Composition();
2121

2222
// this is how to compose your clips
23-
await composition.appendClip(video);
24-
await composition.appendClip(text);
23+
await composition.add(video);
24+
await composition.add(text);
2525

2626
// export video using webcodecs at 25 FPS
2727
new core.WebcodecsEncoder(composition, { fps: 25 })

playground/main.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ await composition.attachPlayer(app!);
3232
composition.canvas!.style.transform = 'scale(0.4) translateY(20px)';
3333
composition.canvas!.style.transformOrigin = 'top left';
3434

35-
await composition.appendClip(
35+
await composition.add(
3636
new core.VideoClip(
3737
await core.VideoSource
3838
.from('/sample_aac_h264_yuv420p_1080p_60fps.mp4'),
@@ -49,7 +49,7 @@ await composition.appendClip(
4949
.offsetBy(30)
5050
);
5151

52-
await composition.appendClip(
52+
await composition.add(
5353
new core.ImageClip(await core.ImageSource.from('/lenna.png'), {
5454
position: 'center',
5555
height: 600,
@@ -65,7 +65,7 @@ await composition.appendClip(
6565
})
6666
);
6767

68-
await composition.appendClip(
68+
await composition.add(
6969
new core.HtmlClip(await core.HtmlSource.from('/test.html'), {
7070
position: {
7171
x: '50%',
@@ -77,13 +77,13 @@ await composition.appendClip(
7777
})
7878
)
7979

80-
await composition.appendClip(
80+
await composition.add(
8181
new core.AudioClip(await core.AudioSource.from('/audio.mp3'), {
8282
transcript: core.Transcript.fromJSON(captions).optimize(),
8383
})
8484
);
8585

86-
await composition.appendClip(
86+
await composition.add(
8787
new core.TextClip({
8888
text: "Basic text in Diffusion Studio",
8989
stop: 120,
@@ -99,7 +99,7 @@ await composition.appendClip(
9999
})
100100
);
101101

102-
await composition.appendClip(
102+
await composition.add(
103103
new core.ComplexTextClip({
104104
text: "Complex Text",
105105
stop: composition.duration,
@@ -131,6 +131,6 @@ await composition.appendClip(
131131
})
132132
);
133133

134-
await composition.appendTrack(core.CaptionTrack)
134+
await composition.createTrack('caption')
135135
.from(composition.findClips(core.AudioClip)[0])
136136
.create();

src/clips/audio/audio.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('The Audio Clip', () => {
4343
clip.element.dispatchEvent(new Event('canplay'));
4444
expect(clip.element).toBeDefined();
4545
expect(loadFn).toBeCalledTimes(1);
46-
expect(clip.type).toBe('AUDIO');
46+
expect(clip.type).toBe('audio');
4747
expect(clip.state).toBe('READY');
4848
expect(clip.source.name).toBe('audio.mp3');
4949
expect(clip.element.src).toBe(
@@ -120,7 +120,7 @@ describe('The Audio Clip', () => {
120120
clip.subclip(<frame>20, <frame>60);
121121

122122
const composition = new Composition();
123-
const promise = composition.appendClip(clip);
123+
const promise = composition.add(clip);
124124
clip.element.dispatchEvent(new Event('canplay'));
125125
await promise;
126126

src/clips/audio/audio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { Track } from '../../tracks';
1313
import type { AudioClipProps } from './audio.interfaces';
1414

1515
export class AudioClip extends MediaClip<AudioClipProps> {
16-
public readonly type = 'AUDIO';
16+
public readonly type = 'audio';
1717
public declare track?: Track<AudioClip>;
1818
/**
1919
* Access to the HTML5 audio element

src/clips/clip/clip.desierializer.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,34 @@ import type { Source } from '../../sources';
1414
export class ClipDeserializer {
1515
public static fromType(data: { type: ClipType }): Clip {
1616
switch (data.type) {
17-
case 'VIDEO':
17+
case 'video':
1818
return new VideoClip();
19-
case 'AUDIO':
19+
case 'audio':
2020
return new AudioClip();
21-
case 'HTML':
21+
case 'html':
2222
return new HtmlClip();
23-
case 'IMAGE':
23+
case 'image':
2424
return new ImageClip();
25-
case 'TEXT':
25+
case 'text':
2626
return new TextClip();
27-
case 'COMPLEX_TEXT':
27+
case 'complex_text':
2828
return new ComplexTextClip();
2929
default:
3030
return new Clip();
3131
}
3232
}
3333

3434
public static fromSource(data: Source) {
35-
if (data.type == 'AUDIO' && data instanceof AudioSource) {
35+
if (data.type == 'audio' && data instanceof AudioSource) {
3636
return new AudioClip(data);
3737
}
38-
if (data.type == 'VIDEO' && data instanceof VideoSource) {
38+
if (data.type == 'video' && data instanceof VideoSource) {
3939
return new VideoClip(data);
4040
}
41-
if (data.type == 'IMAGE' && data instanceof ImageSource) {
41+
if (data.type == 'image' && data instanceof ImageSource) {
4242
return new ImageClip(data);
4343
}
44-
if (data.type == 'HTML' && data instanceof HtmlSource) {
44+
if (data.type == 'html' && data instanceof HtmlSource) {
4545
return new HtmlClip(data);
4646
}
4747
}

src/clips/clip/clip.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ describe('The Clip Object', () => {
7474

7575
// 30 fps is the default
7676
const composition = new Composition();
77-
const track = composition.appendTrack(Track);
78-
await track.appendClip(clip);
77+
const track = composition.createTrack('base');
78+
await track.add(clip);
7979

8080
expect(clip.track?.id).toBe(track.id);
8181
expect(clip.state).toBe('ATTACHED');
@@ -92,11 +92,11 @@ describe('The Clip Object', () => {
9292
const secondClip = new Clip({ stop: <frame>900, start: <frame>570 });
9393

9494
const composition = new Composition();
95-
const track = composition.appendTrack(Track);
95+
const track = composition.createTrack('base');
9696
expect(track.clips.length).toBe(0);
97-
await track.appendClip(clip);
97+
await track.add(clip);
9898
expect(track.clips.length).toBe(1);
99-
await track.appendClip(secondClip);
99+
await track.add(secondClip);
100100
expect(track.clips.length).toBe(2);
101101
expect(track.clips.findIndex((n) => n.id == clip.id)).toBe(0);
102102
expect(clip.state).toBe('ATTACHED');
@@ -110,9 +110,9 @@ describe('The Clip Object', () => {
110110

111111
it('should be not remove error state on detach', async () => {
112112
const composition = new Composition();
113-
const track = composition.appendTrack(Track);
113+
const track = composition.createTrack('base');
114114

115-
await track.appendClip(clip);
115+
await track.add(clip);
116116
expect(track.clips.length).toBe(1);
117117
clip.state = 'ERROR';
118118
expect(clip.state).toBe('ERROR');
@@ -126,9 +126,9 @@ describe('The Clip Object', () => {
126126
clip.set({ stop: <frame>120, start: <frame>100, name: 'foo' });
127127

128128
const composition = new Composition();
129-
const track = composition.appendTrack(Track);
130-
await track.appendClip(clip);
131-
await track.appendClip(new Clip({ stop: <frame>80, start: <frame>60 }));
129+
const track = composition.createTrack('base');
130+
await track.add(clip);
131+
await track.add(new Clip({ stop: <frame>80, start: <frame>60 }));
132132

133133
expect(track.clips.length).toBe(2);
134134
expect(track.clips[1].name).toBe('foo');
@@ -180,16 +180,16 @@ describe('Split tests - the Clip object', () => {
180180
});
181181
const track = new Track();
182182

183-
await track.appendClip(clip);
183+
await track.add(clip);
184184

185185
// add a second one after
186-
await track.appendClip(new Clip({
186+
await track.add(new Clip({
187187
start: new Timestamp(5001),
188188
stop: new Timestamp(6000)
189189
}));
190190

191191
// add a third one befor
192-
await track.appendClip(new Clip({
192+
await track.add(new Clip({
193193
start: new Timestamp(100),
194194
stop: new Timestamp(999)
195195
}));
@@ -220,8 +220,8 @@ describe('Split tests - the Clip object', () => {
220220
stop: new Timestamp(5000),
221221
});
222222
const comp = new Composition();
223-
const track = comp.appendTrack(Track);
224-
await track.appendClip(clip);
223+
const track = comp.createTrack('base');
224+
await track.add(clip);
225225

226226
comp.frame = new Timestamp(2700).frames;
227227

@@ -247,7 +247,7 @@ describe('Split tests - the Clip object', () => {
247247
stop: new Timestamp(5000),
248248
});
249249

250-
await new Track().appendClip(clip);
250+
await new Track().add(clip);
251251

252252
await expect(() => clip.split(new Timestamp(1000))).rejects.toThrowError();
253253
await expect(() => clip.split(new Timestamp(5000))).rejects.toThrowError();

src/clips/clip/clip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class Clip<Props extends ClipProps = ClipProps> extends EventEmitterMixin
3333
/**
3434
* Defines the type of the clip
3535
*/
36-
public readonly type: ClipType = 'BASE';
36+
public readonly type: ClipType = 'base';
3737

3838
/**
3939
* Defines the source of the clip with a
@@ -226,7 +226,7 @@ export class Clip<Props extends ClipProps = ClipProps> extends EventEmitterMixin
226226

227227
replaceKeyframes(copy, copy.start.subtract(this.start));
228228

229-
await this.track.appendClip(copy);
229+
await this.track.add(copy);
230230

231231
return copy;
232232
}

src/clips/clip/clip.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import type { Timestamp } from '../../models';
99

10-
export type ClipType = 'IMAGE' | 'AUDIO' | 'TEXT' | 'VIDEO' | 'BASE' | 'HTML' | 'COMPLEX_TEXT';
10+
export type ClipType = 'image' | 'audio' | 'text' | 'video' | 'base' | 'html' | 'complex_text';
1111

1212
export type ClipState = 'IDLE' | 'LOADING' | 'ATTACHED' | 'READY' | 'ERROR';
1313

src/clips/html/html.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('The Html Clip', () => {
3939
await sleep(0);
4040
expect(clip.element).toBeDefined();
4141
expect(loadFn).toBeCalledTimes(1);
42-
expect(clip.type).toBe('HTML');
42+
expect(clip.type).toBe('html');
4343
expect(clip.state).toBe('READY');
4444
expect(clip.source.name).toBe('index.html');
4545
});

0 commit comments

Comments
 (0)