etro 0.9.1 → 0.10.1
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.
- package/CHANGELOG.md +49 -0
- package/CONTRIBUTING.md +25 -20
- package/README.md +12 -2
- package/dist/custom-array.d.ts +10 -0
- package/dist/effect/base.d.ts +10 -1
- package/dist/effect/shader.d.ts +11 -1
- package/dist/effect/stack.d.ts +6 -2
- package/dist/etro-cjs.js +1153 -577
- package/dist/etro-iife.js +1153 -577
- package/dist/event.d.ts +10 -5
- package/dist/layer/audio-source.d.ts +9 -4
- package/dist/layer/audio.d.ts +15 -2
- package/dist/layer/base.d.ts +49 -3
- package/dist/layer/image.d.ts +15 -1
- package/dist/layer/text.d.ts +3 -0
- package/dist/layer/video.d.ts +13 -1
- package/dist/layer/visual.d.ts +6 -2
- package/dist/movie/effects.d.ts +6 -0
- package/dist/movie/index.d.ts +1 -0
- package/dist/movie/layers.d.ts +6 -0
- package/dist/movie/movie.d.ts +260 -0
- package/dist/object.d.ts +9 -6
- package/dist/util.d.ts +4 -10
- package/eslint.conf.js +2 -2
- package/karma.conf.js +4 -7
- package/package.json +8 -7
- package/src/custom-array.ts +43 -0
- package/src/effect/base.ts +23 -22
- package/src/effect/gaussian-blur.ts +11 -6
- package/src/effect/pixelate.ts +3 -3
- package/src/effect/shader.ts +33 -27
- package/src/effect/stack.ts +43 -30
- package/src/effect/transform.ts +14 -7
- package/src/event.ts +111 -21
- package/src/layer/audio-source.ts +60 -20
- package/src/layer/audio.ts +22 -4
- package/src/layer/base.ts +79 -26
- package/src/layer/image.ts +26 -2
- package/src/layer/text.ts +7 -0
- package/src/layer/video.ts +31 -4
- package/src/layer/visual-source.ts +43 -1
- package/src/layer/visual.ts +50 -28
- package/src/movie/effects.ts +26 -0
- package/src/movie/index.ts +1 -0
- package/src/movie/layers.ts +26 -0
- package/src/movie/movie.ts +855 -0
- package/src/object.ts +9 -6
- package/src/util.ts +68 -89
- package/dist/movie.d.ts +0 -201
- package/src/movie.ts +0 -744
- /package/scripts/{gen-effect-samples.html → effect/gen-effect-samples.html} +0 -0
- /package/scripts/{save-effect-samples.js → effect/save-effect-samples.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,53 @@ 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.1] - 2023-07-16
|
|
9
|
+
### Security
|
|
10
|
+
- Bump engine.io and socket.io.
|
|
11
|
+
- Bump socket.io-parser from 4.2.1 to 4.2.3.
|
|
12
|
+
|
|
13
|
+
## [0.10.0] - 2023-04-18
|
|
14
|
+
### Added
|
|
15
|
+
- `Movie#stream()` to stream the movie to a `MediaStream`.
|
|
16
|
+
- New `onStart` option for `Movie#play()` and `Movie#record()`.
|
|
17
|
+
- Image, audio and video layers' `source` properties now accept urls ([#153](https://github.com/etro-js/etro/pull/153)).
|
|
18
|
+
- Movies, layers and effects have a new `ready` getter, indicating if they are ready to play.
|
|
19
|
+
- Layers and effects now have an async `whenReady` method.
|
|
20
|
+
- `Movie#seek()` method.
|
|
21
|
+
- Layers have new `seek()` and `progress()` methods.
|
|
22
|
+
- `once` option for `subscribe`.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- The (deprecated) `'movie.pause'` event is now published every time playback stops, regardless of the reason.
|
|
26
|
+
- `source` properties of `Image`, `Audio` and `Video` have been retyped to `HTMLImageElement`, `HTMLAudioElement` and `HTMLVideoElement` respectively.
|
|
27
|
+
|
|
28
|
+
### Deprecated
|
|
29
|
+
- `etro.applyOptions()` and `EtroObject#getDefaultOptions()` are deprecated. Instead, set each option in the constructor ([#131](https://github.com/etro-js/etro/issues/131)).
|
|
30
|
+
- The `Movie#currentTime` setter is deprecated. Use `Movie#seek()` instead.
|
|
31
|
+
- `Movie#setCurrentTime()` is deprecated. Instead, call `seek()` and `refresh()` separately.
|
|
32
|
+
- The `'movie.seek'` event is deprecated. Override the `seek()` method on layers instead.
|
|
33
|
+
- The `'movie.timeupdate'` event is deprecated. Override the `progress()` method on layers instead.
|
|
34
|
+
- The `'movie.loadeddata'` event is deprecated.
|
|
35
|
+
- The `'movie.play'` event is deprecated. Provide the `onStart` option to `play()`, `stream()` or `record()` instead.
|
|
36
|
+
- The `'movie.pause'` event is deprecated. Wait for `play()`, `stream()` or `record()` to resolve instead.
|
|
37
|
+
- The `'movie.record'` event is deprecated. Provide the `onStart` option to `record()` instead.
|
|
38
|
+
- The `'movie.recordended'` event is deprecated. Wait for `record()` to resolve instead.
|
|
39
|
+
- The `'movie.ended'` event is deprecated.
|
|
40
|
+
|
|
41
|
+
### Removed
|
|
42
|
+
- `Movie#autoRefresh` (see [#130](https://github.com/etro-js/etro/issues/130)).
|
|
43
|
+
- `change` events (see [#130](https://github.com/etro-js/etro/issues/130)).
|
|
44
|
+
- `watchPublic()` and `publicExcludes` (see [#130](https://github.com/etro-js/etro/issues/130)).
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
- `Movie#currentTime` is now reset to 0 when the movie ends.
|
|
48
|
+
- `Movie#play()` and `Movie#record()` now wait until all resources are loaded before starting.
|
|
49
|
+
- `Movie#pause()` no longer stops inactive layers ([#203](https://github.com/etro-js/etro/issues/203)).
|
|
50
|
+
- Array methods like `unshift` for `etro.layer.Visual#effects` and `etro.effect.Stack#effects` work properly.
|
|
51
|
+
- `AudioSource#playbackRate` is now optional.
|
|
52
|
+
- `duration` option for `Audio` and `Video` layers is now optional.
|
|
53
|
+
- `Video` constructor now accepts missing options.
|
|
54
|
+
|
|
8
55
|
## [0.9.1] - 2022-09-18
|
|
9
56
|
### Fixed
|
|
10
57
|
- Update color types from `string` to `Color` ([#135](https://github.com/etro-js/etro/pull/135)).
|
|
@@ -233,6 +280,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
233
280
|
- Gaussian blur
|
|
234
281
|
- Transform
|
|
235
282
|
|
|
283
|
+
[0.10.1]: https://github.com/etro-js/etro/compare/v0.10.0...v0.10.1
|
|
284
|
+
[0.10.0]: https://github.com/etro-js/etro/compare/v0.9.1...v0.10.0
|
|
236
285
|
[0.9.1]: https://github.com/etro-js/etro/compare/v0.9.0...v0.9.1
|
|
237
286
|
[0.9.0]: https://github.com/etro-js/etro/compare/v0.8.5...v0.9.0
|
|
238
287
|
[0.8.5]: https://github.com/etro-js/etro/compare/v0.8.4...v0.8.5
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
+
> If you would like to update the docs, please see [the docs repo](https://github.com/etro-js/etro-js.github.io).
|
|
4
|
+
|
|
3
5
|
## Introduction
|
|
4
6
|
|
|
5
7
|
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).
|
|
@@ -17,44 +19,47 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
17
19
|
- Create your own fork of Etro. Then run
|
|
18
20
|
|
|
19
21
|
```
|
|
20
|
-
git clone
|
|
22
|
+
git clone https://github.com/YOUR_USERNAME/etro.git
|
|
21
23
|
cd etro
|
|
22
24
|
npm install
|
|
23
|
-
|
|
25
|
+
npm test
|
|
24
26
|
```
|
|
25
27
|
|
|
26
28
|
## Making your changes
|
|
27
29
|
|
|
28
30
|
#### Step 2: Code
|
|
29
31
|
|
|
30
|
-
- Make some changes
|
|
32
|
+
- Make some changes and update tests
|
|
31
33
|
- If you are writing code, the linter uses [StandardJS](https://standardjs.com/rules.html) for style conventions
|
|
34
|
+
- If you're adding or updating an effect:
|
|
35
|
+
- Add your effect to **scripts/gen-effect-samples.html**
|
|
36
|
+
- Run `npm run effects`
|
|
37
|
+
- Briefly review the images in **spec/integration/assets/effect/**
|
|
32
38
|
- When you're ready to submit, first run
|
|
33
|
-
|
|
34
39
|
```
|
|
35
40
|
npm run lint
|
|
36
41
|
npm run build
|
|
37
42
|
npm test
|
|
38
43
|
```
|
|
39
44
|
|
|
40
|
-
to lint the code, generate the [dist](dist) files and run unit tests on them. It
|
|
45
|
+
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
46
|
|
|
42
|
-
|
|
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:
|
|
47
|
+
#### Step 3: Commit
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
- Please follow these commit message guidelines:
|
|
50
|
+
- Optionally, prefix each commit message with [an appropriate emoji](https://gitmoji.dev), such as `:bug:` for fixes.
|
|
51
|
+
- Write in the imperative tense
|
|
52
|
+
- Wrap lines after 72 characters (for Vim add `filetype indent plugin on` to ~/.vimrc, it's enabled by default in Atom).
|
|
53
|
+
- Format:
|
|
54
|
+
```
|
|
55
|
+
:emoji: One-liner
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
Optional description
|
|
58
|
+
```
|
|
54
59
|
|
|
55
60
|
## Submitting your changes
|
|
56
61
|
|
|
57
|
-
#### Step
|
|
62
|
+
#### Step 4: Push
|
|
58
63
|
|
|
59
64
|
- First, rebase (please avoid merging) to integrate your work with any new changes in the main repository
|
|
60
65
|
|
|
@@ -65,12 +70,12 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
65
70
|
|
|
66
71
|
- Push to the fork
|
|
67
72
|
|
|
68
|
-
#### Step
|
|
73
|
+
#### Step 5: Pull request
|
|
69
74
|
|
|
70
75
|
- Open a pull request from the branch in your fork to the main repository
|
|
71
76
|
- If you changed any core functionality, make sure you explain your motives for those changes
|
|
72
77
|
|
|
73
|
-
#### Step
|
|
78
|
+
#### Step 6: Feedback
|
|
74
79
|
|
|
75
80
|
- 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
81
|
|
|
@@ -78,9 +83,9 @@ Thank you for considering contributing to Etro! There are many ways you can cont
|
|
|
78
83
|
|
|
79
84
|
### Etro Overview
|
|
80
85
|
|
|
81
|
-
Check out [the
|
|
86
|
+
Check out [the user docs](https://etrojs.dev/docs/intro) for a high-level overview of Etro.
|
|
82
87
|
|
|
83
|
-
###
|
|
88
|
+
### Events
|
|
84
89
|
|
|
85
90
|
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
91
|
|
package/README.md
CHANGED
|
@@ -42,6 +42,9 @@ movie.record({ frameRate: 24 }) // or just `play` if you don't need to save it
|
|
|
42
42
|
The blob could then be downloaded as a video file or displayed using a `<video>`
|
|
43
43
|
element.
|
|
44
44
|
|
|
45
|
+
See the [documentation](https://etrojs.dev/docs/category/layers) for a list of
|
|
46
|
+
all built-in layers.
|
|
47
|
+
|
|
45
48
|
## Effects
|
|
46
49
|
|
|
47
50
|
Effects can transform the output of a layer or movie:
|
|
@@ -50,6 +53,9 @@ var layer = new etro.layer.Video({ startTime: 0, source: videoElement })
|
|
|
50
53
|
.addEffect(new etro.effect.Brightness({ brightness: +100) }))
|
|
51
54
|
```
|
|
52
55
|
|
|
56
|
+
See the [documentation](https://etrojs.dev/docs/category/effects) for a list of
|
|
57
|
+
all built-in effects.
|
|
58
|
+
|
|
53
59
|
## Dynamic Properties
|
|
54
60
|
|
|
55
61
|
Most properties also support keyframes and functions:
|
|
@@ -64,17 +70,21 @@ layer.effects[0].brightness = new etro.KeyFrame(
|
|
|
64
70
|
layer.effects[0].brightness = () => 100 * Math.random() - 50
|
|
65
71
|
```
|
|
66
72
|
|
|
73
|
+
See the [documentation](https://etrojs.dev/docs/reference/dynamic-properties)
|
|
74
|
+
for more info.
|
|
75
|
+
|
|
67
76
|
## Using in Node
|
|
68
77
|
|
|
69
78
|
To use Etro in Node, see the [wrapper](https://github.com/etro-js/etro-node):
|
|
70
79
|
|
|
71
80
|
## Running the Examples
|
|
72
81
|
|
|
73
|
-
Start the development server (only used for
|
|
82
|
+
Start the development server (only used for convenience while developing; you
|
|
74
83
|
don't need a server to use Etro):
|
|
75
84
|
|
|
76
85
|
```
|
|
77
86
|
npm i
|
|
87
|
+
npm run build
|
|
78
88
|
npm start
|
|
79
89
|
```
|
|
80
90
|
|
|
@@ -83,7 +93,7 @@ http://127.0.0.1:8080/examples/introduction/hello-world1.html).
|
|
|
83
93
|
|
|
84
94
|
## Further Reading
|
|
85
95
|
|
|
86
|
-
- [Documentation](https://etrojs.dev/docs)
|
|
96
|
+
- [Documentation](https://etrojs.dev/docs/intro)
|
|
87
97
|
|
|
88
98
|
## Contributing
|
|
89
99
|
|
|
@@ -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
|
+
}
|
package/dist/effect/base.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
}
|
package/dist/effect/shader.d.ts
CHANGED
|
@@ -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]
|
|
84
|
+
* @param [options]
|
|
85
|
+
* @returns the prepared value
|
|
76
86
|
*/
|
|
77
87
|
private _prepareValue;
|
|
78
88
|
private static _initRectBuffers;
|
package/dist/effect/stack.d.ts
CHANGED
|
@@ -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:
|
|
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 {};
|