etro 0.9.1 → 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 (52) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/CONTRIBUTING.md +23 -20
  3. package/README.md +3 -2
  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 +1156 -575
  9. package/dist/etro-iife.js +1156 -575
  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 +3 -0
  16. package/dist/layer/video.d.ts +13 -1
  17. package/dist/layer/visual.d.ts +6 -2
  18. package/dist/movie/effects.d.ts +6 -0
  19. package/dist/movie/index.d.ts +1 -0
  20. package/dist/movie/layers.d.ts +6 -0
  21. package/dist/movie/movie.d.ts +260 -0
  22. package/dist/object.d.ts +9 -6
  23. package/dist/util.d.ts +4 -10
  24. package/eslint.conf.js +2 -2
  25. package/karma.conf.js +4 -7
  26. package/package.json +8 -7
  27. package/src/custom-array.ts +43 -0
  28. package/src/effect/base.ts +23 -22
  29. package/src/effect/gaussian-blur.ts +11 -6
  30. package/src/effect/pixelate.ts +3 -3
  31. package/src/effect/shader.ts +33 -27
  32. package/src/effect/stack.ts +43 -30
  33. package/src/effect/transform.ts +14 -7
  34. package/src/event.ts +111 -21
  35. package/src/layer/audio-source.ts +60 -20
  36. package/src/layer/audio.ts +25 -3
  37. package/src/layer/base.ts +79 -26
  38. package/src/layer/image.ts +26 -2
  39. package/src/layer/text.ts +7 -0
  40. package/src/layer/video.ts +31 -4
  41. package/src/layer/visual-source.ts +43 -1
  42. package/src/layer/visual.ts +50 -28
  43. package/src/movie/effects.ts +26 -0
  44. package/src/movie/index.ts +1 -0
  45. package/src/movie/layers.ts +26 -0
  46. package/src/movie/movie.ts +855 -0
  47. package/src/object.ts +9 -6
  48. package/src/util.ts +68 -89
  49. package/dist/movie.d.ts +0 -201
  50. package/src/movie.ts +0 -744
  51. /package/scripts/{gen-effect-samples.html → effect/gen-effect-samples.html} +0 -0
  52. /package/scripts/{save-effect-samples.js → effect/save-effect-samples.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,48 @@ 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
+
8
50
  ## [0.9.1] - 2022-09-18
9
51
  ### Fixed
10
52
  - Update color types from `string` to `Color` ([#135](https://github.com/etro-js/etro/pull/135)).
@@ -233,6 +275,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
233
275
  - Gaussian blur
234
276
  - Transform
235
277
 
278
+ [0.10.0]: https://github.com/etro-js/etro/compare/v0.9.1...v0.10.0
236
279
  [0.9.1]: https://github.com/etro-js/etro/compare/v0.9.0...v0.9.1
237
280
  [0.9.0]: https://github.com/etro-js/etro/compare/v0.8.5...v0.9.0
238
281
  [0.8.5]: https://github.com/etro-js/etro/compare/v0.8.4...v0.8.5
package/CONTRIBUTING.md CHANGED
@@ -17,44 +17,47 @@ Thank you for considering contributing to Etro! There are many ways you can cont
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 follow these commit message guidelines:
44
- - Optionally, prefix each commit message with [an appropriate emoji](https://gitmoji.dev), such as `:bug:` for fixes.
45
- - Write in the imperative tense
46
- - Wrap lines after 72 characters (for Vim add `filetype indent plugin on` to ~/.vimrc, it's enabled by default in Atom).
47
- - Format:
45
+ #### Step 3: Commit
48
46
 
49
- ```
50
- :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
51
54
 
52
- Optional description
53
- ```
55
+ Optional description
56
+ ```
54
57
 
55
58
  ## Submitting your changes
56
59
 
57
- #### Step 3: Push
60
+ #### Step 4: Push
58
61
 
59
62
  - First, rebase (please avoid merging) to integrate your work with any new changes in the main repository
60
63
 
@@ -65,12 +68,12 @@ Thank you for considering contributing to Etro! There are many ways you can cont
65
68
 
66
69
  - Push to the fork
67
70
 
68
- #### Step 4: Pull request
71
+ #### Step 5: Pull request
69
72
 
70
73
  - Open a pull request from the branch in your fork to the main repository
71
74
  - If you changed any core functionality, make sure you explain your motives for those changes
72
75
 
73
- #### Step 5: Feedback
76
+ #### Step 6: Feedback
74
77
 
75
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.
76
79
 
@@ -78,9 +81,9 @@ Thank you for considering contributing to Etro! There are many ways you can cont
78
81
 
79
82
  ### Etro Overview
80
83
 
81
- Check out [the overview guide](https://etrojs.dev/docs/overview) for usage information
84
+ Check out [the user docs](https://etrojs.dev/docs/intro) for a high-level overview of Etro.
82
85
 
83
- ### Pub/sub system
86
+ ### Events
84
87
 
85
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,
86
89
 
package/README.md CHANGED
@@ -70,11 +70,12 @@ To use Etro in Node, see the [wrapper](https://github.com/etro-js/etro-node):
70
70
 
71
71
  ## Running the Examples
72
72
 
73
- Start the development server (only used for convience while developing; you
73
+ Start the development server (only used for convenience while developing; you
74
74
  don't need a server to use Etro):
75
75
 
76
76
  ```
77
77
  npm i
78
+ npm run build
78
79
  npm start
79
80
  ```
80
81
 
@@ -83,7 +84,7 @@ http://127.0.0.1:8080/examples/introduction/hello-world1.html).
83
84
 
84
85
  ## Further Reading
85
86
 
86
- - [Documentation](https://etrojs.dev/docs)
87
+ - [Documentation](https://etrojs.dev/docs/intro)
87
88
 
88
89
  ## Contributing
89
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 {};