Skip to content

Refactoring: API for defining new frame sources#311

Merged
bkeepers merged 16 commits intomasterfrom
refactor-sources
Jan 26, 2025
Merged

Refactoring: API for defining new frame sources#311
bkeepers merged 16 commits intomasterfrom
refactor-sources

Conversation

@bkeepers
Copy link
Collaborator

@bkeepers bkeepers commented Jan 18, 2025

This pull request aims to create a public API for defining new frame sources, and refactors exising layer sources to use it.

  • Create an API for defining new frame sources
import { defineFrameSource, type BaseLayer } from 'editly';

type GifLayer extends BaseLayer {
  type: 'gif';
  path: string;
}

export default defineFrameSource<GifLayer>('gif', async ({ params, width, height }) => {
  const { path } = params;

  // Initial setup here, like loading the file

  return {
    async readNextFrame(progress, canvas) { /* Draw on `canvas` or return RGBA data */ },
    close() { /* Do any cleanup here */ }
  };
});

Later:

  • Expose a public API to register new frame sources
  • Refactor handleLayer in config.ts to move validations into individual layer types
  • Create an example
  • Update README
  • A plugin API so we can extract existing frame sources into separate packages with their own dependencies

@bkeepers bkeepers force-pushed the refactor-sources branch 2 times, most recently from a71b89e to 71fa230 Compare January 26, 2025 15:51
@bkeepers bkeepers marked this pull request as ready for review January 26, 2025 16:17
@bkeepers bkeepers changed the title API for defining new frame sources Refactoring: API for defining new frame sources Jan 26, 2025
@bkeepers bkeepers merged commit e4ed047 into master Jan 26, 2025
48 checks passed
@bkeepers bkeepers deleted the refactor-sources branch January 26, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant