Skip to content

Commit

Permalink
Fix element type hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
casperkloppenburg committed Sep 11, 2023
1 parent 2999e78 commit bab8295
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@creatomate/preview",
"version": "1.1.1",
"version": "1.2.0",
"description": "Render video and image previews in your web app prior to creating a final MP4, GIF, JPEG or PNG through the API.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/AudioState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface AudioState {
import { ElementState } from './ElementState';

export interface AudioState extends ElementState {
/**
* Audio element property. The total length of the media file used in the element.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/CompositionState.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ElementState } from './ElementState';

export interface CompositionState {
export interface CompositionState extends ElementState {
/**
* Composition element property. The elements in the composition.
*/
Expand Down
7 changes: 1 addition & 6 deletions src/ElementState.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { CompositionState } from './CompositionState';
import { TextState } from './TextState';
import { VideoState } from './VideoState';
import { AudioState } from './AudioState';

export interface ElementState extends CompositionState, TextState, VideoState, AudioState {
export interface ElementState {
/**
* This element's track number.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { v4 as uuid } from 'uuid';
import { PreviewState } from './PreviewState';
import { ElementState } from './ElementState';
import { CompositionState } from './CompositionState';

export class Preview {
/**
Expand Down Expand Up @@ -261,8 +262,8 @@ export class Preview {
return element;
}

if (element.elements) {
const foundNestedElement = this.findElement(predicate, element);
if ('elements' in element) {
const foundNestedElement = this.findElement(predicate, element as CompositionState);
if (foundNestedElement) {
return foundNestedElement;
}
Expand Down
4 changes: 3 additions & 1 deletion src/TextState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface TextState {
import { ElementState } from './ElementState';

export interface TextState extends ElementState {
/**
* Text element property. The fixed or auto-calculated font size of the text element.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/VideoState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface VideoState {
import { ElementState } from './ElementState';

export interface VideoState extends ElementState {
/**
* Video element property. The total length of the media file used in the element.
*/
Expand Down

0 comments on commit bab8295

Please sign in to comment.