etro 0.9.0 → 0.10.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/CONTRIBUTING.md +25 -34
  3. package/README.md +9 -17
  4. package/dist/custom-array.d.ts +10 -0
  5. package/dist/effect/base.d.ts +10 -1
  6. package/dist/effect/shader.d.ts +11 -1
  7. package/dist/effect/stack.d.ts +6 -2
  8. package/dist/etro-cjs.js +1182 -592
  9. package/dist/etro-iife.js +1182 -592
  10. package/dist/event.d.ts +10 -5
  11. package/dist/layer/audio-source.d.ts +9 -4
  12. package/dist/layer/audio.d.ts +15 -2
  13. package/dist/layer/base.d.ts +49 -3
  14. package/dist/layer/image.d.ts +15 -1
  15. package/dist/layer/text.d.ts +6 -3
  16. package/dist/layer/video.d.ts +13 -1
  17. package/dist/layer/visual-source.d.ts +18 -3
  18. package/dist/layer/visual.d.ts +11 -7
  19. package/dist/movie/effects.d.ts +6 -0
  20. package/dist/movie/index.d.ts +1 -0
  21. package/dist/movie/layers.d.ts +6 -0
  22. package/dist/movie/movie.d.ts +260 -0
  23. package/dist/object.d.ts +9 -2
  24. package/dist/util.d.ts +4 -10
  25. package/eslint.conf.js +4 -2
  26. package/eslint.test-conf.js +1 -2
  27. package/karma.conf.js +10 -14
  28. package/package.json +23 -22
  29. package/scripts/{gen-effect-samples.html → effect/gen-effect-samples.html} +24 -0
  30. package/scripts/{save-effect-samples.js → effect/save-effect-samples.js} +1 -1
  31. package/src/custom-array.ts +43 -0
  32. package/src/effect/base.ts +23 -22
  33. package/src/effect/gaussian-blur.ts +11 -6
  34. package/src/effect/pixelate.ts +3 -3
  35. package/src/effect/shader.ts +33 -27
  36. package/src/effect/stack.ts +43 -30
  37. package/src/effect/transform.ts +16 -9
  38. package/src/event.ts +111 -21
  39. package/src/layer/audio-source.ts +60 -20
  40. package/src/layer/audio.ts +25 -3
  41. package/src/layer/base.ts +79 -25
  42. package/src/layer/image.ts +26 -2
  43. package/src/layer/text.ts +11 -4
  44. package/src/layer/video.ts +31 -4
  45. package/src/layer/visual-source.ts +70 -8
  46. package/src/layer/visual.ts +57 -35
  47. package/src/movie/effects.ts +26 -0
  48. package/src/movie/index.ts +1 -0
  49. package/src/movie/layers.ts +26 -0
  50. package/src/movie/movie.ts +855 -0
  51. package/src/object.ts +9 -2
  52. package/src/util.ts +68 -89
  53. package/tsconfig.json +3 -1
  54. package/dist/movie.d.ts +0 -201
  55. package/examples/application/readme-screenshot.html +0 -85
  56. package/examples/application/video-player.html +0 -130
  57. package/examples/application/webcam.html +0 -28
  58. package/examples/introduction/audio.html +0 -64
  59. package/examples/introduction/effects.html +0 -79
  60. package/examples/introduction/export.html +0 -83
  61. package/examples/introduction/functions.html +0 -37
  62. package/examples/introduction/hello-world1.html +0 -37
  63. package/examples/introduction/hello-world2.html +0 -32
  64. package/examples/introduction/keyframes.html +0 -79
  65. package/examples/introduction/media.html +0 -63
  66. package/examples/introduction/text.html +0 -31
  67. package/private-todo.txt +0 -70
  68. package/src/movie.ts +0 -742
package/CHANGELOG.md CHANGED
@@ -5,6 +5,54 @@ 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.10.0] - 2023-04-18
9
+ ### Added
10
+ - `Movie#stream()` to stream the movie to a `MediaStream`.
11
+ - New `onStart` option for `Movie#play()` and `Movie#record()`.
12
+ - Image, audio and video layers' `source` properties now accept urls ([#153](https://github.com/etro-js/etro/pull/153)).
13
+ - Movies, layers and effects have a new `ready` getter, indicating if they are ready to play.
14
+ - Layers and effects now have an async `whenReady` method.
15
+ - `Movie#seek()` method.
16
+ - Layers have new `seek()` and `progress()` methods.
17
+ - `once` option for `subscribe`.
18
+
19
+ ### Changed
20
+ - The (deprecated) `'movie.pause'` event is now published every time playback stops, regardless of the reason.
21
+ - `source` properties of `Image`, `Audio` and `Video` have been retyped to `HTMLImageElement`, `HTMLAudioElement` and `HTMLVideoElement` respectively.
22
+
23
+ ### Deprecated
24
+ - `etro.applyOptions()` and `EtroObject#getDefaultOptions()` are deprecated. Instead, set each option in the constructor ([#131](https://github.com/etro-js/etro/issues/131)).
25
+ - The `Movie#currentTime` setter is deprecated. Use `Movie#seek()` instead.
26
+ - `Movie#setCurrentTime()` is deprecated. Instead, call `seek()` and `refresh()` separately.
27
+ - The `'movie.seek'` event is deprecated. Override the `seek()` method on layers instead.
28
+ - The `'movie.timeupdate'` event is deprecated. Override the `progress()` method on layers instead.
29
+ - The `'movie.loadeddata'` event is deprecated.
30
+ - The `'movie.play'` event is deprecated. Provide the `onStart` option to `play()`, `stream()` or `record()` instead.
31
+ - The `'movie.pause'` event is deprecated. Wait for `play()`, `stream()` or `record()` to resolve instead.
32
+ - The `'movie.record'` event is deprecated. Provide the `onStart` option to `record()` instead.
33
+ - The `'movie.recordended'` event is deprecated. Wait for `record()` to resolve instead.
34
+ - The `'movie.ended'` event is deprecated.
35
+
36
+ ### Removed
37
+ - `Movie#autoRefresh` (see [#130](https://github.com/etro-js/etro/issues/130)).
38
+ - `change` events (see [#130](https://github.com/etro-js/etro/issues/130)).
39
+ - `watchPublic()` and `publicExcludes` (see [#130](https://github.com/etro-js/etro/issues/130)).
40
+
41
+ ### Fixed
42
+ - `Movie#currentTime` is now reset to 0 when the movie ends.
43
+ - `Movie#play()` and `Movie#record()` now wait until all resources are loaded before starting.
44
+ - `Movie#pause()` no longer stops inactive layers ([#203](https://github.com/etro-js/etro/issues/203)).
45
+ - Array methods like `unshift` for `etro.layer.Visual#effects` and `etro.effect.Stack#effects` work properly.
46
+ - `AudioSource#playbackRate` is now optional.
47
+ - `duration` option for `Audio` and `Video` layers is now optional.
48
+ - `Video` constructor now accepts missing options.
49
+
50
+ ## [0.9.1] - 2022-09-18
51
+ ### Fixed
52
+ - Update color types from `string` to `Color` ([#135](https://github.com/etro-js/etro/pull/135)).
53
+ - `Image` and `Video` classes now include missing properties.
54
+ - `Movie#currentTime` no longer exceeds the stop time.
55
+
8
56
  ## [0.9.0] - 2022-07-17
9
57
  ### Changed
10
58
  - Methods in the `Base` effect now accept `Base` layers instead of `Visual` layers.
@@ -227,6 +275,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
227
275
  - Gaussian blur
228
276
  - Transform
229
277
 
278
+ [0.10.0]: https://github.com/etro-js/etro/compare/v0.9.1...v0.10.0
279
+ [0.9.1]: https://github.com/etro-js/etro/compare/v0.9.0...v0.9.1
230
280
  [0.9.0]: https://github.com/etro-js/etro/compare/v0.8.5...v0.9.0
231
281
  [0.8.5]: https://github.com/etro-js/etro/compare/v0.8.4...v0.8.5
232
282
  [0.8.4]: https://github.com/etro-js/etro/compare/v0.8.3...v0.8.4
package/CONTRIBUTING.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Introduction
4
4
 
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).
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 code for the library. This page covers how to make changes to the repository files (either code or jsdocs).
6
6
 
7
7
  [Join our Discord](https://discord.gg/myrBsQ8Cht)
8
8
 
@@ -10,52 +10,54 @@ Thank you for considering contributing to Etro! There are many ways you can cont
10
10
 
11
11
  #### Step 0: Dependencies
12
12
 
13
- - You will need Git, Node, NPM (at least 7.x) and Firefox (for headless unit testing) installed
13
+ - You will need Git, Node, NPM (at least 7.x) and Firefox (for headless functional testing) installed.
14
14
 
15
15
  #### Step 1: Fork
16
16
 
17
17
  - Create your own fork of Etro. Then run
18
18
 
19
19
  ```
20
- git clone -b master --single-branch https://github.com/username/etro.git
20
+ git clone https://github.com/YOUR_USERNAME/etro.git
21
21
  cd etro
22
22
  npm install
23
- node node_modules/puppeteer/install.js
23
+ npm test
24
24
  ```
25
25
 
26
26
  ## Making your changes
27
27
 
28
28
  #### Step 2: Code
29
29
 
30
- - Make some changes
30
+ - Make some changes and update tests
31
31
  - If you are writing code, the linter uses [StandardJS](https://standardjs.com/rules.html) for style conventions
32
+ - If you're adding or updating an effect:
33
+ - Add your effect to **scripts/gen-effect-samples.html**
34
+ - Run `npm run effects`
35
+ - Briefly review the images in **spec/integration/assets/effect/**
32
36
  - When you're ready to submit, first run
33
-
34
37
  ```
35
38
  npm run lint
36
39
  npm run build
37
40
  npm test
38
41
  ```
39
42
 
40
- to lint the code, generate the [dist](dist) files and run unit tests on them. It may be helpful to put these commands in a pre-commit hook.
43
+ to lint the code, generate the [dist](dist) files and run unit tests on them. It's helpful to put these commands in a pre-commit hook.
41
44
 
42
- - Commit your changes
43
- - Please avoid squashing all your commits into one; we try to keep atomic commits.
44
- - Please follow these commit message guidelines:
45
- - Optionally, prefix each commit message with [an appropriate emoji](https://gitmoji.dev)
46
- - Write in the imperative tense
47
- - Wrap lines after 72 characters (for Vim add `filetype indent plugin on` to ~/.vimrc, it's enabled by default in Atom).
48
- - Example:
45
+ #### Step 3: Commit
49
46
 
50
- ```
51
- :emoji: One-liner
47
+ - Please follow these commit message guidelines:
48
+ - Optionally, prefix each commit message with [an appropriate emoji](https://gitmoji.dev), such as `:bug:` for fixes.
49
+ - Write in the imperative tense
50
+ - Wrap lines after 72 characters (for Vim add `filetype indent plugin on` to ~/.vimrc, it's enabled by default in Atom).
51
+ - Format:
52
+ ```
53
+ :emoji: One-liner
52
54
 
53
- Optional description
54
- ```
55
+ Optional description
56
+ ```
55
57
 
56
58
  ## Submitting your changes
57
59
 
58
- #### Step 3: Push
60
+ #### Step 4: Push
59
61
 
60
62
  - First, rebase (please avoid merging) to integrate your work with any new changes in the main repository
61
63
 
@@ -66,12 +68,12 @@ Thank you for considering contributing to Etro! There are many ways you can cont
66
68
 
67
69
  - Push to the fork
68
70
 
69
- #### Step 4: Pull request
71
+ #### Step 5: Pull request
70
72
 
71
73
  - Open a pull request from the branch in your fork to the main repository
72
74
  - If you changed any core functionality, make sure you explain your motives for those changes
73
75
 
74
- #### Step 5: Feedback
76
+ #### Step 6: Feedback
75
77
 
76
78
  - A large part of the submission process is receiving feedback on how you can improve you pull request. If you need to change your pull request, feel free to push more commits.
77
79
 
@@ -79,20 +81,9 @@ Thank you for considering contributing to Etro! There are many ways you can cont
79
81
 
80
82
  ### Etro Overview
81
83
 
82
- Check out [the overview guide](https://etrojs.dev/docs/overview) for usage information
83
-
84
- ### API Structure
85
-
86
- * `etro.Movie` - the movie
87
- * `etro.layer.*` - all layers
88
- * `etro.effect.*` - all (visual) effects
89
- - `etro.event.publish` - emit an event
90
- - `etro.event.subscribe` - add an event listener
91
- - `etro.*` - other utility classes and methods (see **src/util.ts**)
92
-
93
- ### Etro concepts
84
+ Check out [the user docs](https://etrojs.dev/docs/intro) for a high-level overview of Etro.
94
85
 
95
- #### Pub/sub system
86
+ ### Events
96
87
 
97
88
  Events emitted by Etro objects use a [pub/sub system](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern). To emit an event, use `event.publish(target, type, event)`. For instance,
98
89
 
package/README.md CHANGED
@@ -3,14 +3,10 @@
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
- > Etro was previously known as Etro, but it had to be renamed to avoid
7
- > confusion with an existing software product.
8
-
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.
6
+ Etro is a typescript framework for programmatically editing videos. It lets you
7
+ composite layers and add filters (effects). Etro comes shipped with text, video,
8
+ audio and image layers, along with a bunch of GLSL effects. You can also define
9
+ your own layers and effects with javascript and GLSL.
14
10
 
15
11
  [Join our Discord](https://discord.gg/myrBsQ8Cht)
16
12
 
@@ -74,16 +70,12 @@ To use Etro in Node, see the [wrapper](https://github.com/etro-js/etro-node):
74
70
 
75
71
  ## Running the Examples
76
72
 
77
- First, download the assets for the examples:
78
-
79
- ```
80
- npm run assets
81
- ```
82
-
83
- Then, start the development server (only used for convience while developing;
84
- you don't need a server to use Etro):
73
+ Start the development server (only used for convenience while developing; you
74
+ don't need a server to use Etro):
85
75
 
86
76
  ```
77
+ npm i
78
+ npm run build
87
79
  npm start
88
80
  ```
89
81
 
@@ -92,7 +84,7 @@ http://127.0.0.1:8080/examples/introduction/hello-world1.html).
92
84
 
93
85
  ## Further Reading
94
86
 
95
- - [Documentation](https://etrojs.dev/docs)
87
+ - [Documentation](https://etrojs.dev/docs/intro)
96
88
 
97
89
  ## Contributing
98
90
 
@@ -0,0 +1,10 @@
1
+ export declare abstract class CustomArrayListener<T> {
2
+ abstract onAdd(item: T): void;
3
+ abstract onRemove(item: T): void;
4
+ }
5
+ /**
6
+ * An array that notifies a listener when items are added or removed.
7
+ */
8
+ export declare class CustomArray<T> extends Array<T> {
9
+ constructor(target: T[], listener: CustomArrayListener<T>);
10
+ }
@@ -17,6 +17,10 @@ export declare class Base implements BaseObject {
17
17
  */
18
18
  private _occurrenceCount;
19
19
  constructor();
20
+ /**
21
+ * Wait until this effect is ready to be applied
22
+ */
23
+ whenReady(): Promise<void>;
20
24
  /**
21
25
  * Attaches this effect to `target` if not already attached.
22
26
  * @ignore
@@ -24,7 +28,7 @@ export declare class Base implements BaseObject {
24
28
  tryAttach(target: Movie | BaseLayer): void;
25
29
  attach(movie: Movie | BaseLayer): void;
26
30
  /**
27
- * Dettaches this effect from its target if the number of times `tryDetach`
31
+ * Detaches this effect from its target if the number of times `tryDetach`
28
32
  * has been called (including this call) equals the number of times
29
33
  * `tryAttach` has been called.
30
34
  *
@@ -45,7 +49,12 @@ export declare class Base implements BaseObject {
45
49
  * The current time of the target
46
50
  */
47
51
  get currentTime(): number;
52
+ /** `true` if this effect is ready to be applied */
53
+ get ready(): boolean;
48
54
  get parent(): Movie | BaseLayer;
49
55
  get movie(): Movie;
56
+ /**
57
+ * @deprecated See {@link https://github.com/etro-js/etro/issues/131}
58
+ */
50
59
  getDefaultOptions(): Record<string, unknown>;
51
60
  }
@@ -2,6 +2,9 @@ import { Visual as VisualLayer } from '../layer/index';
2
2
  import { Movie } from '../movie';
3
3
  import { Visual } from './visual';
4
4
  export interface UniformOptions {
5
+ /**
6
+ * The type of the uniform.
7
+ */
5
8
  type?: string;
6
9
  defaultFloatComponent?: number;
7
10
  }
@@ -63,16 +66,23 @@ export declare class Shader extends Visual {
63
66
  private _enablePositionAttrib;
64
67
  private _enableTexCoordAttrib;
65
68
  private _prepareTextures;
69
+ /**
70
+ * Set the shader's uniforms.
71
+ * @param target The movie or layer to apply the shader to.
72
+ * @param reltime The relative time of the movie or layer.
73
+ */
66
74
  private _prepareUniforms;
67
75
  private _draw;
68
76
  /**
69
77
  * Converts a value of a standard type for javascript to a standard type for
70
78
  * GLSL
79
+ *
71
80
  * @param value - the raw value to prepare
72
81
  * @param outputType - the WebGL type of |value|; example:
73
82
  * <code>1f</code> for a float
74
83
  * @param reltime - current time, relative to the target
75
- * @param [options] - Optional config
84
+ * @param [options]
85
+ * @returns the prepared value
76
86
  */
77
87
  private _prepareValue;
78
88
  private static _initRectBuffers;
@@ -1,6 +1,10 @@
1
1
  import { Movie } from '../movie';
2
2
  import { Visual } from './visual';
3
3
  import { Visual as VisualLayer } from '../layer';
4
+ import { CustomArray } from '../custom-array';
5
+ declare class StackEffects extends CustomArray<Visual> {
6
+ constructor(target: Visual[], stack: Stack);
7
+ }
4
8
  export interface StackOptions {
5
9
  effects: Visual[];
6
10
  }
@@ -9,8 +13,7 @@ export interface StackOptions {
9
13
  * for defining reused effect sequences as one effect.
10
14
  */
11
15
  export declare class Stack extends Visual {
12
- readonly effects: Visual[];
13
- private _effectsBack;
16
+ readonly effects: StackEffects;
14
17
  constructor(options: StackOptions);
15
18
  attach(movie: Movie): void;
16
19
  detach(): void;
@@ -21,3 +24,4 @@ export declare class Stack extends Visual {
21
24
  */
22
25
  addEffect(effect: Visual): Stack;
23
26
  }
27
+ export {};