etro 0.8.3 → 0.9.0

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.
@@ -1,6 +1,8 @@
1
1
  name: Node CI
2
2
 
3
- on: [push]
3
+ on:
4
+ - push
5
+ - pull_request
4
6
 
5
7
  jobs:
6
8
  build:
@@ -8,7 +10,7 @@ jobs:
8
10
 
9
11
  strategy:
10
12
  matrix:
11
- node-version: [10.x, 12.x]
13
+ node-version: [15.x, 16.x, 17.x]
12
14
 
13
15
  steps:
14
16
  - uses: actions/checkout@v1
@@ -22,8 +24,9 @@ jobs:
22
24
  - name: npm install, lint, build, and test
23
25
  run: |
24
26
  npm ci
27
+ node node_modules/puppeteer/install.js
25
28
  npm run lint
26
29
  npm run build
27
- npm test
30
+ xvfb-run --auto-servernum npm test
28
31
  env:
29
32
  CI: true
package/CHANGELOG.md CHANGED
@@ -5,6 +5,40 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [0.9.0] - 2022-07-17
9
+ ### Changed
10
+ - Methods in the `Base` effect now accept `Base` layers instead of `Visual` layers.
11
+
12
+ ### Deprecated
13
+ - `autoRefresh` option ([#130](https://github.com/etro-js/etro/issues/130)).
14
+ - `publicExcludes` ([#130](https://github.com/etro-js/etro/issues/130)).
15
+ - All `change` events ([#130](https://github.com/etro-js/etro/issues/130)).
16
+
17
+ ### Fixed
18
+ - Layers no longer trigger infinite loops when their active states change ([#127](https://github.com/etro-js/etro/issues/127)).
19
+ - Add missing `VisualSource` options to `Image` layer ([#128](https://github.com/etro-js/etro/pull/128)).
20
+ - Layers are now stopped when recording ends.
21
+ - `stop()` is no longer called on inactive layers.
22
+ - Movies no longer publish `'movie.ended'` when done recording.
23
+ - `Audio` and `Video` layers not detaching properly.
24
+ - When done playing or recording, movies only reset their time if they're in repeat mode.
25
+ - The `timeupdate` event is no longer fired when `currentTime` remains the same (due to `performance.now()` rounding).
26
+
27
+ ## [0.8.5] - 2022-03-06
28
+ ### Deprecated
29
+ - `vd.effect.Base` - All visual effects now inherit from `vd.effect.Visual` instead.
30
+
31
+ ### Fixed
32
+ - Movie constructor throwing `Can't find variable: AudioContext` on WebKit browsers.
33
+
34
+ ## [0.8.4] - 2022-02-23
35
+ ### Fixed
36
+ - **Major memory leak.**
37
+ - `Movie#play()` not resolving.
38
+ - `Movie#paused` set to false after done playing or recording.
39
+ - Movies' `currentTime` being off by a fraction of a second a few frames after playing.
40
+ - Movies' `currentTime` setter not respecting `autoRefresh`.
41
+
8
42
  ## [0.8.3] - 2022-01-18
9
43
  ### Fixed
10
44
  - Recording not respecting the `type` option.
@@ -193,6 +227,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
193
227
  - Gaussian blur
194
228
  - Transform
195
229
 
230
+ [0.9.0]: https://github.com/etro-js/etro/compare/v0.8.5...v0.9.0
231
+ [0.8.5]: https://github.com/etro-js/etro/compare/v0.8.4...v0.8.5
232
+ [0.8.4]: https://github.com/etro-js/etro/compare/v0.8.3...v0.8.4
196
233
  [0.8.3]: https://github.com/etro-js/etro/compare/v0.8.2...v0.8.3
197
234
  [0.8.2]: https://github.com/etro-js/etro/compare/v0.8.1...v0.8.2
198
235
  [0.8.1]: https://github.com/etro-js/etro/compare/v0.8.0...v0.8.1
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
55
55
  ## Enforcement
56
56
 
57
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting me at **\@etro-js** on Twitter. All complaints will be
58
+ reported by contacting us at etroframework\@gmail.com. All complaints will be
59
59
  reviewed and investigated and will result in a response that is deemed necessary
60
60
  and appropriate to the circumstances. The project team is obligated to maintain
61
61
  confidentiality with regard to the reporter of an incident. Further details of
package/CONTRIBUTING.md CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  Thank you for considering contributing to Etro! There are many ways you can contribute to Etro, like creating issues for features or bugs, improving the docs or wiki, or writing the actual code for the library. This page covers how to make changes to the repository files (either code or docs).
6
6
 
7
- > Etro has a [Taiga Project](https://tree.taiga.io/project/etro-js-etro/epics) for managing issues and a [GitHub Discussion page](https://github.com/etro-js/etro/discussions) for questions, ideas and casual discussion
7
+ [Join our Discord](https://discord.gg/myrBsQ8Cht)
8
8
 
9
9
  ## Setting up your local environment
10
10
 
11
11
  #### Step 0: Dependencies
12
12
 
13
- - You will need Git, Node, NPM (at least 7.x) and Chrome (for headless unit testing) installed
13
+ - You will need Git, Node, NPM (at least 7.x) and Firefox (for headless unit testing) installed
14
14
 
15
15
  #### Step 1: Fork
16
16
 
@@ -20,15 +20,16 @@ Thank you for considering contributing to Etro! There are many ways you can cont
20
20
  git clone -b master --single-branch https://github.com/username/etro.git
21
21
  cd etro
22
22
  npm install
23
+ node node_modules/puppeteer/install.js
23
24
  ```
24
25
 
25
26
  ## Making your changes
26
27
 
27
28
  #### Step 2: Code
28
29
 
29
- - Make some changes.
30
- - If you are writing code, the linter uses [StandardJS](https://standardjs.com/rules.html) for style conventions.
31
- - When you're ready to submit a piece of code, first run
30
+ - Make some changes
31
+ - If you are writing code, the linter uses [StandardJS](https://standardjs.com/rules.html) for style conventions
32
+ - When you're ready to submit, first run
32
33
 
33
34
  ```
34
35
  npm run lint
@@ -56,19 +57,18 @@ Thank you for considering contributing to Etro! There are many ways you can cont
56
57
 
57
58
  #### Step 3: Push
58
59
 
59
- - First, rebase (don't merge) to integrate your work with the main repository
60
+ - First, rebase (please avoid merging) to integrate your work with any new changes in the main repository
60
61
 
61
62
  ```
62
63
  git fetch upstream
63
64
  git rebase upstream/master
64
65
  ```
65
66
 
66
- - Push to your fork
67
+ - Push to the fork
67
68
 
68
69
  #### Step 4: Pull request
69
70
 
70
- - Open a pull request from your the branch in your fork to the main repository
71
- - In the PR title, include **fixes ###** for bugs and **resolves ###** for feature requests
71
+ - Open a pull request from the branch in your fork to the main repository
72
72
  - If you changed any core functionality, make sure you explain your motives for those changes
73
73
 
74
74
  #### Step 5: Feedback
@@ -79,7 +79,7 @@ Thank you for considering contributing to Etro! There are many ways you can cont
79
79
 
80
80
  ### Etro Overview
81
81
 
82
- If you are new to the core elements of etro, you should probably read [the overview guide](https://etrojs.dev/docs/overview).
82
+ Check out [the overview guide](https://etrojs.dev/docs/overview) for usage information
83
83
 
84
84
  ### API Structure
85
85
 
package/README.md CHANGED
@@ -3,25 +3,25 @@
3
3
  [![](https://img.shields.io/npm/v/etro)](https://www.npmjs.com/package/etro)
4
4
  [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fetro-js%2Fetro%2Fbadge&style=flat)](https://actions-badge.atrox.dev/etro-js/etro/goto)
5
5
 
6
- > [Version 0.8 is out](https://etrojs.dev/blog/introducing-v0-8-0)!
7
- > Check out [this guide](https://etrojs.dev/docs/migrating-v0-8-0)
8
- > for migrating.
6
+ > Etro was previously known as Etro, but it had to be renamed to avoid
7
+ > confusion with an existing software product.
9
8
 
10
- Etro is a typescript framework for programmatically editing videos. Similar
11
- to GUI-based video-editing software, it lets you layer media and other
12
- content on a timeline. Audio, image, video and other tracks are supported,
13
- along with powerful video effects for existing tracks. Being very flexible
14
- and extendable, you can choose to only use the core components or define your
15
- own.
9
+ Etro is a typescript framework for programmatically editing videos. Similar to
10
+ GUI-based video-editing software, it lets you composite layers and add effects.
11
+ Etro comes shipped with text, video, audio and image layers, along with a bunch
12
+ of GLSL effects. You can also define your own layers and effects with javascript
13
+ and GLSL.
14
+
15
+ [Join our Discord](https://discord.gg/myrBsQ8Cht)
16
16
 
17
17
  ## Features
18
18
 
19
19
  - Composite video and audio layers
20
20
  - Use built-in hardware accelerated effects
21
21
  - Write your own effects in JavaScript and GLSL
22
- - Manipulate audio with the web audio API
23
- - Define layer and effect properties as keyframes and functions
24
- - Export to a blob or file
22
+ - Manipulate audio with the web audio API *(audio effects coming soon)*
23
+ - Define layer and effect parameters as keyframes or custom functions
24
+ - Render to a blob in realtime *(offline rendering coming soon)*
25
25
 
26
26
  ## Installation
27
27
 
@@ -29,29 +29,24 @@ own.
29
29
  npm i etro
30
30
  ```
31
31
 
32
- ## Usage
32
+ ## Basic Usage
33
33
 
34
- You can use CommonJS syntax:
34
+ Let's look at an example:
35
35
  ```js
36
36
  import etro from 'etro'
37
- ```
38
-
39
- Or include it as a global etro:
40
- ```js
41
- <script src="node_modules/etro/dist/etro-iife.js"></script>
42
- ```
43
37
 
44
- Let's look at an example:
45
- ```js
46
38
  var movie = new etro.Movie({ canvas: outputCanvas })
47
39
  var layer = new etro.layer.Video({ startTime: 0, source: videoElement }) // the layer starts at 0s
48
40
  movie.addLayer(layer)
41
+
49
42
  movie.record({ frameRate: 24 }) // or just `play` if you don't need to save it
50
43
  .then(blob => ...)
51
44
  ```
52
45
 
53
- This renders `videoElement` to a blob at 24 fps. This blob can then be
54
- downloaded as a video file.
46
+ The blob could then be downloaded as a video file or displayed using a `<video>`
47
+ element.
48
+
49
+ ## Effects
55
50
 
56
51
  Effects can transform the output of a layer or movie:
57
52
  ```js
@@ -59,32 +54,23 @@ var layer = new etro.layer.Video({ startTime: 0, source: videoElement })
59
54
  .addEffect(new etro.effect.Brightness({ brightness: +100) }))
60
55
  ```
61
56
 
62
- ## Using in Node
63
-
64
- To use Etro in Node, use the [wrapper](https://github.com/etro-js/etro-node):
65
- ```
66
- npm i etro-node
67
- ```
57
+ ## Dynamic Properties
68
58
 
59
+ Most properties also support keyframes and functions:
69
60
  ```js
70
- var etroNode = require('etro-node')
71
-
72
- etroNode(() => {
73
- // You can access inputs as html elements and pass them to Etro as usual.
74
- var image = document.getElementById('input1') // <img> element
75
-
76
- // Use etro normally ...
77
-
78
- movie
79
- .exportRaw()
80
- .then(window.done)
81
- // Tell Etro Node what inputs to load with { id: path }
82
- }, { input1: 'image.png' }, 'output.mp4')
61
+ // Keyframes
62
+ layer.effects[0].brightness = new etro.KeyFrame(
63
+ [0, -75], // brightness == -75 at 0 seconds
64
+ [2, +75] // +75 at 2 seconds
65
+ )
66
+
67
+ // Function
68
+ layer.effects[0].brightness = () => 100 * Math.random() - 50
83
69
  ```
84
70
 
85
- `etroNode()` takes an optional Puppeteer page argument, so you can run
86
- multiple Etro scripts on the same movie (useful for servers). See [the
87
- docs](https://github.com/etro-js/etro-node#documentation).
71
+ ## Using in Node
72
+
73
+ To use Etro in Node, see the [wrapper](https://github.com/etro-js/etro-node):
88
74
 
89
75
  ## Running the Examples
90
76
 
@@ -104,12 +90,6 @@ npm start
104
90
  Now you can open any example (such as
105
91
  http://127.0.0.1:8080/examples/introduction/hello-world1.html).
106
92
 
107
- ## TypeScript
108
-
109
- Etro is written in TypeScript, so it should work out of the box with TypeScript
110
- projects. However, it is also compatible with projects that do not use
111
- TypeScript.
112
-
113
93
  ## Further Reading
114
94
 
115
95
  - [Documentation](https://etrojs.dev/docs)
@@ -1,8 +1,8 @@
1
1
  import { Movie } from '../movie';
2
- import { Visual } from '../layer/index';
2
+ import { Base as BaseLayer } from '../layer/index';
3
3
  import BaseObject from '../object';
4
4
  /**
5
- * Modifies the visual contents of a layer.
5
+ * @deprecated All visual effects now inherit from `Visual` instead
6
6
  */
7
7
  export declare class Base implements BaseObject {
8
8
  type: string;
@@ -21,8 +21,8 @@ export declare class Base implements BaseObject {
21
21
  * Attaches this effect to `target` if not already attached.
22
22
  * @ignore
23
23
  */
24
- tryAttach(target: Movie | Visual): void;
25
- attach(movie: Movie | Visual): void;
24
+ tryAttach(target: Movie | BaseLayer): void;
25
+ attach(movie: Movie | BaseLayer): void;
26
26
  /**
27
27
  * Dettaches this effect from its target if the number of times `tryDetach`
28
28
  * has been called (including this call) equals the number of times
@@ -40,12 +40,12 @@ export declare class Base implements BaseObject {
40
40
  * (will soon be replaced with an instance getter)
41
41
  * @abstract
42
42
  */
43
- apply(target: Movie | Visual, reltime: number): void;
43
+ apply(target: Movie | BaseLayer, reltime: number): void;
44
44
  /**
45
45
  * The current time of the target
46
46
  */
47
47
  get currentTime(): number;
48
- get parent(): Movie | Visual;
48
+ get parent(): Movie | BaseLayer;
49
49
  get movie(): Movie;
50
50
  getDefaultOptions(): Record<string, unknown>;
51
51
  }
@@ -1,7 +1,7 @@
1
1
  import { Movie } from '../movie';
2
2
  import { Dynamic } from '../util';
3
- import { Base } from './base';
4
- import { Visual } from '../layer/index';
3
+ import { Visual } from './visual';
4
+ import { Visual as VisualLayer } from '../layer/index';
5
5
  export declare class EllipticalMaskOptions {
6
6
  x: Dynamic<number>;
7
7
  y: Dynamic<number>;
@@ -15,7 +15,7 @@ export declare class EllipticalMaskOptions {
15
15
  /**
16
16
  * Preserves an ellipse of the layer and clears the rest
17
17
  */
18
- export declare class EllipticalMask extends Base {
18
+ export declare class EllipticalMask extends Visual {
19
19
  x: Dynamic<number>;
20
20
  y: Dynamic<number>;
21
21
  radiusX: Dynamic<number>;
@@ -27,5 +27,5 @@ export declare class EllipticalMask extends Base {
27
27
  private _tmpCanvas;
28
28
  private _tmpCtx;
29
29
  constructor(options: EllipticalMaskOptions);
30
- apply(target: Movie | Visual, reltime: number): void;
30
+ apply(target: Movie | VisualLayer, reltime: number): void;
31
31
  }
@@ -13,3 +13,4 @@ export * from './pixelate';
13
13
  export * from './shader';
14
14
  export * from './stack';
15
15
  export * from './transform';
16
+ export * from './visual';
@@ -1,6 +1,6 @@
1
- import { Visual } from '../layer/index';
1
+ import { Visual as VisualLayer } from '../layer/index';
2
2
  import { Movie } from '../movie';
3
- import { Base } from './base';
3
+ import { Visual } from './visual';
4
4
  export interface UniformOptions {
5
5
  type?: string;
6
6
  defaultFloatComponent?: number;
@@ -26,7 +26,7 @@ export interface ShaderOptions {
26
26
  /**
27
27
  * A hardware-accelerated pixel mapping using WebGL
28
28
  */
29
- export declare class Shader extends Base {
29
+ export declare class Shader extends Visual {
30
30
  /**
31
31
  * WebGL texture units consumed by {@link Shader}
32
32
  */
@@ -57,7 +57,7 @@ export declare class Shader extends Base {
57
57
  private _initTextures;
58
58
  private _initAttribs;
59
59
  private _initUniforms;
60
- apply(target: Movie | Visual, reltime: number): void;
60
+ apply(target: Movie | VisualLayer, reltime: number): void;
61
61
  private _checkDimensions;
62
62
  private _refreshGl;
63
63
  private _enablePositionAttrib;
@@ -1,23 +1,23 @@
1
1
  import { Movie } from '../movie';
2
- import { Base } from './base';
3
- import { Visual } from '../layer';
2
+ import { Visual } from './visual';
3
+ import { Visual as VisualLayer } from '../layer';
4
4
  export interface StackOptions {
5
- effects: Base[];
5
+ effects: Visual[];
6
6
  }
7
7
  /**
8
8
  * A sequence of effects to apply, treated as one effect. This can be useful
9
9
  * for defining reused effect sequences as one effect.
10
10
  */
11
- export declare class Stack extends Base {
12
- readonly effects: Base[];
11
+ export declare class Stack extends Visual {
12
+ readonly effects: Visual[];
13
13
  private _effectsBack;
14
14
  constructor(options: StackOptions);
15
15
  attach(movie: Movie): void;
16
16
  detach(): void;
17
- apply(target: Movie | Visual, reltime: number): void;
17
+ apply(target: Movie | VisualLayer, reltime: number): void;
18
18
  /**
19
19
  * Convenience method for chaining
20
20
  * @param effect - the effect to append
21
21
  */
22
- addEffect(effect: Base): Stack;
22
+ addEffect(effect: Visual): Stack;
23
23
  }
@@ -1,7 +1,7 @@
1
- import { Visual } from '../layer/index';
1
+ import { Visual as VisualLayer } from '../layer/index';
2
2
  import { Movie } from '../movie';
3
3
  import { Dynamic } from '../util';
4
- import { Base } from './base';
4
+ import { Visual } from './visual';
5
5
  export interface TransformOptions {
6
6
  matrix: Dynamic<Transform.Matrix>;
7
7
  }
@@ -11,7 +11,7 @@ export interface TransformOptions {
11
11
  * translations, scalings and rotations) or B) input the matrix values
12
12
  * directly, using the optional argument in the constructor.
13
13
  */
14
- declare class Transform extends Base {
14
+ declare class Transform extends Visual {
15
15
  /** Matrix that determines how to transform the target */
16
16
  matrix: Dynamic<Transform.Matrix>;
17
17
  private _tmpMatrix;
@@ -21,7 +21,7 @@ declare class Transform extends Base {
21
21
  * @param matrix - matrix that determines how to transform the target
22
22
  */
23
23
  constructor(options: TransformOptions);
24
- apply(target: Movie | Visual, reltime: number): void;
24
+ apply(target: Movie | VisualLayer, reltime: number): void;
25
25
  }
26
26
  declare namespace Transform {
27
27
  /**
@@ -0,0 +1,17 @@
1
+ import { Movie } from '../movie';
2
+ import { Visual as VisualLayer } from '../layer/index';
3
+ import { Base } from './base';
4
+ /**
5
+ * Modifies the visual contents of a layer.
6
+ */
7
+ export declare class Visual extends Base {
8
+ /**
9
+ * Apply this effect to a target at the given time
10
+ *
11
+ * @param target
12
+ * @param reltime - the movie's current time relative to the layer
13
+ * (will soon be replaced with an instance getter)
14
+ * @abstract
15
+ */
16
+ apply(target: Movie | VisualLayer, reltime: number): void;
17
+ }