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.
- package/CHANGELOG.md +43 -0
- package/CONTRIBUTING.md +23 -20
- package/README.md +3 -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 +1156 -575
- package/dist/etro-iife.js +1156 -575
- 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 +25 -3
- 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/dist/event.d.ts
CHANGED
|
@@ -6,19 +6,24 @@ export interface Event {
|
|
|
6
6
|
target: EtroObject;
|
|
7
7
|
type: string;
|
|
8
8
|
}
|
|
9
|
+
export declare function deprecate(type: string, newType: string, message?: string): void;
|
|
9
10
|
/**
|
|
10
|
-
* Listen for an event or category of events
|
|
11
|
+
* Listen for an event or category of events.
|
|
11
12
|
*
|
|
12
|
-
* @param target -
|
|
13
|
+
* @param target - an etro object
|
|
13
14
|
* @param type - the id of the type (can contain subtypes, such as
|
|
14
15
|
* "type.subtype")
|
|
15
16
|
* @param listener
|
|
17
|
+
* @param options - options
|
|
18
|
+
* @param options.once - if true, the listener will only be called once
|
|
16
19
|
*/
|
|
17
|
-
export declare function subscribe(target: EtroObject, type: string, listener: <T extends Event>(T: any) => void
|
|
20
|
+
export declare function subscribe(target: EtroObject, type: string, listener: <T extends Event>(T: any) => void, options?: {
|
|
21
|
+
once?: boolean;
|
|
22
|
+
}): void;
|
|
18
23
|
/**
|
|
19
24
|
* Remove an event listener
|
|
20
25
|
*
|
|
21
|
-
* @param target -
|
|
26
|
+
* @param target - an etro object
|
|
22
27
|
* @param type - the id of the type (can contain subtypes, such as
|
|
23
28
|
* "type.subtype")
|
|
24
29
|
* @param listener
|
|
@@ -27,7 +32,7 @@ export declare function unsubscribe(target: EtroObject, listener: <T extends Eve
|
|
|
27
32
|
/**
|
|
28
33
|
* Emits an event to all listeners
|
|
29
34
|
*
|
|
30
|
-
* @param target -
|
|
35
|
+
* @param target - an etro object
|
|
31
36
|
* @param type - the id of the type (can contain subtypes, such as
|
|
32
37
|
* "type.subtype")
|
|
33
38
|
* @param event - any additional event data
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { Base, BaseOptions } from './base';
|
|
2
2
|
declare type Constructor<T> = new (...args: unknown[]) => T;
|
|
3
3
|
interface AudioSource extends Base {
|
|
4
|
-
|
|
4
|
+
/** HTML media element (an audio or video element) */
|
|
5
|
+
readonly source: HTMLAudioElement;
|
|
6
|
+
/** Audio source node for the media */
|
|
5
7
|
readonly audioNode: AudioNode;
|
|
6
8
|
playbackRate: number;
|
|
7
|
-
/**
|
|
9
|
+
/** Seconds to skip ahead by */
|
|
8
10
|
sourceStartTime: number;
|
|
9
11
|
}
|
|
10
|
-
interface AudioSourceOptions extends BaseOptions {
|
|
12
|
+
interface AudioSourceOptions extends Omit<BaseOptions, 'duration'> {
|
|
13
|
+
duration?: number;
|
|
14
|
+
/** HTML media element (an audio or video element) */
|
|
11
15
|
source: HTMLMediaElement;
|
|
16
|
+
/** Seconds to skip ahead by */
|
|
12
17
|
sourceStartTime?: number;
|
|
13
18
|
muted?: boolean;
|
|
14
19
|
volume?: number;
|
|
15
|
-
playbackRate
|
|
20
|
+
playbackRate?: number;
|
|
16
21
|
onload?: (source: HTMLMediaElement, options: AudioSourceOptions) => void;
|
|
17
22
|
}
|
|
18
23
|
/**
|
package/dist/layer/audio.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import { AudioSourceOptions } from './audio-source';
|
|
2
|
-
|
|
2
|
+
interface AudioOptions extends Omit<AudioSourceOptions, 'source'> {
|
|
3
|
+
/**
|
|
4
|
+
* The raw html `<audio>` element
|
|
5
|
+
*/
|
|
6
|
+
source: string | HTMLAudioElement;
|
|
7
|
+
}
|
|
3
8
|
declare const Audio_base: new (...args: unknown[]) => import("./audio-source").AudioSource;
|
|
4
9
|
/**
|
|
10
|
+
* Layer for an HTML audio element
|
|
5
11
|
* @extends AudioSource
|
|
6
12
|
*/
|
|
7
13
|
declare class Audio extends Audio_base {
|
|
14
|
+
/**
|
|
15
|
+
* The raw html `<audio>` element
|
|
16
|
+
*/
|
|
17
|
+
source: HTMLAudioElement;
|
|
8
18
|
/**
|
|
9
19
|
* Creates an audio layer
|
|
10
20
|
*/
|
|
11
21
|
constructor(options: AudioOptions);
|
|
12
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated See {@link https://github.com/etro-js/etro/issues/131}
|
|
24
|
+
*/
|
|
25
|
+
getDefaultOptions(): any;
|
|
13
26
|
}
|
|
14
27
|
export { Audio, AudioOptions };
|
package/dist/layer/base.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare class Base implements EtroObject {
|
|
|
25
25
|
private _occurrenceCount;
|
|
26
26
|
private _startTime;
|
|
27
27
|
private _duration;
|
|
28
|
+
private _currentTime;
|
|
28
29
|
private _movie;
|
|
29
30
|
/**
|
|
30
31
|
* Creates a new empty layer
|
|
@@ -36,47 +37,92 @@ declare class Base implements EtroObject {
|
|
|
36
37
|
* movie's timeline
|
|
37
38
|
*/
|
|
38
39
|
constructor(options: BaseOptions);
|
|
40
|
+
/**
|
|
41
|
+
* Wait until this layer is ready to render
|
|
42
|
+
*/
|
|
43
|
+
whenReady(): Promise<void>;
|
|
39
44
|
/**
|
|
40
45
|
* Attaches this layer to `movie` if not already attached.
|
|
41
46
|
* @ignore
|
|
42
47
|
*/
|
|
43
48
|
tryAttach(movie: Movie): void;
|
|
49
|
+
/**
|
|
50
|
+
* Attaches this layer to `movie`
|
|
51
|
+
*
|
|
52
|
+
* Called when the layer is added to a movie's `layers` array.
|
|
53
|
+
*
|
|
54
|
+
* @param movie The movie to attach to
|
|
55
|
+
*/
|
|
44
56
|
attach(movie: Movie): void;
|
|
45
57
|
/**
|
|
46
|
-
*
|
|
58
|
+
* Detaches this layer from its movie if the number of times `tryDetach` has
|
|
47
59
|
* been called (including this call) equals the number of times `tryAttach`
|
|
48
60
|
* has been called.
|
|
49
61
|
*
|
|
50
62
|
* @ignore
|
|
51
63
|
*/
|
|
52
64
|
tryDetach(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Detaches this layer from its movie
|
|
67
|
+
*
|
|
68
|
+
* Called when the layer is removed from a movie's `layers` array.
|
|
69
|
+
*/
|
|
53
70
|
detach(): void;
|
|
54
71
|
/**
|
|
55
72
|
* Called when the layer is activated
|
|
56
73
|
*/
|
|
57
74
|
start(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Update {@link currentTime} when seeking
|
|
77
|
+
*
|
|
78
|
+
* This method is called when the movie seeks to a new time at the request of
|
|
79
|
+
* the user. {@link progress} is called when the movie's `currentTime` is
|
|
80
|
+
* updated due to playback.
|
|
81
|
+
*
|
|
82
|
+
* @param time - The new time in the layer
|
|
83
|
+
*/
|
|
84
|
+
seek(time: number): void;
|
|
85
|
+
/**
|
|
86
|
+
* Update {@link currentTime} due to playback
|
|
87
|
+
*
|
|
88
|
+
* This method is called when the movie's `currentTime` is updated due to
|
|
89
|
+
* playback. {@link seek} is called when the movie seeks to a new time at the
|
|
90
|
+
* request of the user.
|
|
91
|
+
*
|
|
92
|
+
* @param time - The new time in the layer
|
|
93
|
+
*/
|
|
94
|
+
progress(time: number): void;
|
|
58
95
|
/**
|
|
59
96
|
* Called when the movie renders and the layer is active
|
|
60
97
|
*/
|
|
61
98
|
render(): void;
|
|
62
99
|
/**
|
|
63
|
-
|
|
100
|
+
* Called when the layer is deactivated
|
|
64
101
|
*/
|
|
65
102
|
stop(): void;
|
|
66
103
|
get parent(): Movie;
|
|
67
104
|
/**
|
|
105
|
+
* The time in the movie at which this layer starts (in seconds)
|
|
68
106
|
*/
|
|
69
107
|
get startTime(): number;
|
|
70
108
|
set startTime(val: number);
|
|
71
109
|
/**
|
|
72
|
-
* The current time of the movie relative to this layer
|
|
110
|
+
* The current time of the movie relative to this layer (in seconds)
|
|
73
111
|
*/
|
|
74
112
|
get currentTime(): number;
|
|
75
113
|
/**
|
|
114
|
+
* The duration of this layer (in seconds)
|
|
76
115
|
*/
|
|
77
116
|
get duration(): number;
|
|
78
117
|
set duration(val: number);
|
|
118
|
+
/**
|
|
119
|
+
* `true` if this layer is ready to be rendered, `false` otherwise
|
|
120
|
+
*/
|
|
121
|
+
get ready(): boolean;
|
|
79
122
|
get movie(): Movie;
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated See {@link https://github.com/etro-js/etro/issues/131}
|
|
125
|
+
*/
|
|
80
126
|
getDefaultOptions(): BaseOptions;
|
|
81
127
|
}
|
|
82
128
|
export { Base, BaseOptions };
|
package/dist/layer/image.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { VisualSourceOptions } from './visual-source';
|
|
2
|
-
|
|
2
|
+
interface ImageOptions extends Omit<VisualSourceOptions, 'source'> {
|
|
3
|
+
/**
|
|
4
|
+
* The raw html `<img>` element
|
|
5
|
+
*/
|
|
6
|
+
source: string | HTMLImageElement;
|
|
7
|
+
}
|
|
3
8
|
declare const Image_base: new (...args: unknown[]) => import("./visual-source").VisualSource;
|
|
9
|
+
/**
|
|
10
|
+
* Layer for an HTML image element
|
|
11
|
+
* @extends VisualSource
|
|
12
|
+
*/
|
|
4
13
|
declare class Image extends Image_base {
|
|
14
|
+
/**
|
|
15
|
+
* The raw html `<img>` element
|
|
16
|
+
*/
|
|
17
|
+
source: HTMLImageElement;
|
|
18
|
+
constructor(options: ImageOptions);
|
|
5
19
|
}
|
|
6
20
|
export { Image, ImageOptions };
|
package/dist/layer/text.d.ts
CHANGED
|
@@ -55,6 +55,9 @@ declare class Text extends Visual {
|
|
|
55
55
|
*/
|
|
56
56
|
constructor(options: TextOptions);
|
|
57
57
|
doRender(): void;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated See {@link https://github.com/etro-js/etro/issues/131}
|
|
60
|
+
*/
|
|
58
61
|
getDefaultOptions(): TextOptions;
|
|
59
62
|
}
|
|
60
63
|
export { Text, TextOptions };
|
package/dist/layer/video.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { VisualSourceOptions } from './visual-source';
|
|
2
2
|
import { AudioSourceOptions } from './audio-source';
|
|
3
|
-
|
|
3
|
+
interface VideoOptions extends Omit<AudioSourceOptions & VisualSourceOptions, 'duration' | 'source'> {
|
|
4
|
+
duration?: number;
|
|
5
|
+
/**
|
|
6
|
+
* The raw html `<video>` element
|
|
7
|
+
*/
|
|
8
|
+
source: string | HTMLVideoElement;
|
|
9
|
+
}
|
|
4
10
|
declare const Video_base: new (...args: unknown[]) => import("./audio-source").AudioSource;
|
|
5
11
|
/**
|
|
12
|
+
* Layer for an HTML video element
|
|
6
13
|
* @extends AudioSource
|
|
7
14
|
* @extends VisualSource
|
|
8
15
|
*/
|
|
9
16
|
declare class Video extends Video_base {
|
|
17
|
+
/**
|
|
18
|
+
* The raw html `<video>` element
|
|
19
|
+
*/
|
|
20
|
+
source: HTMLVideoElement;
|
|
21
|
+
constructor(options: VideoOptions);
|
|
10
22
|
}
|
|
11
23
|
export { Video, VideoOptions };
|
package/dist/layer/visual.d.ts
CHANGED
|
@@ -34,11 +34,11 @@ declare class Visual extends Base {
|
|
|
34
34
|
*/
|
|
35
35
|
readonly cctx: CanvasRenderingContext2D;
|
|
36
36
|
readonly effects: VisualEffect[];
|
|
37
|
-
private _effectsBack;
|
|
38
37
|
/**
|
|
39
38
|
* Creates a visual layer
|
|
40
39
|
*/
|
|
41
40
|
constructor(options: VisualOptions);
|
|
41
|
+
whenReady(): Promise<void>;
|
|
42
42
|
/**
|
|
43
43
|
* Render visual output
|
|
44
44
|
*/
|
|
@@ -48,11 +48,15 @@ declare class Visual extends Base {
|
|
|
48
48
|
endRender(): void;
|
|
49
49
|
_applyEffects(): void;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Convenience method for <code>effects.push()</code>
|
|
52
52
|
* @param effect
|
|
53
53
|
* @return the layer (for chaining)
|
|
54
54
|
*/
|
|
55
55
|
addEffect(effect: VisualEffect): Visual;
|
|
56
|
+
get ready(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated See {@link https://github.com/etro-js/etro/issues/131}
|
|
59
|
+
*/
|
|
56
60
|
getDefaultOptions(): VisualOptions;
|
|
57
61
|
}
|
|
58
62
|
export { Visual, VisualOptions };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CustomArray } from '../custom-array';
|
|
2
|
+
import { Visual as VisualEffect } from '../effect/index';
|
|
3
|
+
import { Movie } from './movie';
|
|
4
|
+
export declare class MovieEffects extends CustomArray<VisualEffect> {
|
|
5
|
+
constructor(target: VisualEffect[], movie: Movie);
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './movie';
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module movie
|
|
3
|
+
*/
|
|
4
|
+
import { Dynamic, Color } from '../util';
|
|
5
|
+
import { Base as BaseLayer } from '../layer/index';
|
|
6
|
+
import { Base as BaseEffect } from '../effect/index';
|
|
7
|
+
import { MovieEffects } from './effects';
|
|
8
|
+
import { MovieLayers } from './layers';
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
webkitAudioContext: typeof AudioContext;
|
|
12
|
+
}
|
|
13
|
+
interface HTMLCanvasElement {
|
|
14
|
+
captureStream(frameRate?: number): MediaStream;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare class MovieOptions {
|
|
18
|
+
/** The html canvas element to use for playback */
|
|
19
|
+
canvas: HTMLCanvasElement;
|
|
20
|
+
/** The audio context to use for playback, defaults to a new audio context */
|
|
21
|
+
actx?: AudioContext;
|
|
22
|
+
/** @deprecated Use <code>actx</code> instead */
|
|
23
|
+
audioContext?: AudioContext;
|
|
24
|
+
/** The background color of the movie as a cSS string */
|
|
25
|
+
background?: Dynamic<Color>;
|
|
26
|
+
/**
|
|
27
|
+
* If set to true, the movie will repeat when it reaches the end (unless it's
|
|
28
|
+
* recording)
|
|
29
|
+
*/
|
|
30
|
+
repeat?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The movie contains everything included in the render.
|
|
34
|
+
*
|
|
35
|
+
* Implements a pub/sub system.
|
|
36
|
+
*/
|
|
37
|
+
export declare class Movie {
|
|
38
|
+
type: string;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Auto-refresh will be removed in the future. If you want to
|
|
41
|
+
* refresh the canvas, call `refresh`. See
|
|
42
|
+
* {@link https://github.com/etro-js/etro/issues/130}
|
|
43
|
+
*/
|
|
44
|
+
publicExcludes: string[];
|
|
45
|
+
propertyFilters: Record<string, <T>(value: T) => T>;
|
|
46
|
+
repeat: boolean;
|
|
47
|
+
/** The background color of the movie as a cSS string */
|
|
48
|
+
background: Dynamic<Color>;
|
|
49
|
+
/** The audio context to which audio output is sent during playback */
|
|
50
|
+
readonly actx: AudioContext;
|
|
51
|
+
readonly effects: MovieEffects;
|
|
52
|
+
readonly layers: MovieLayers;
|
|
53
|
+
/** The canvas that we are currently rendering to */
|
|
54
|
+
private _canvas;
|
|
55
|
+
private _visibleCanvas;
|
|
56
|
+
private _cctx;
|
|
57
|
+
private _recorder;
|
|
58
|
+
private _currentTime;
|
|
59
|
+
private _paused;
|
|
60
|
+
private _ended;
|
|
61
|
+
private _renderingFrame;
|
|
62
|
+
private _recording;
|
|
63
|
+
private _currentStream;
|
|
64
|
+
private _endTime;
|
|
65
|
+
private _lastPlayed;
|
|
66
|
+
private _lastPlayedOffset;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new movie.
|
|
69
|
+
*/
|
|
70
|
+
constructor(options: MovieOptions);
|
|
71
|
+
private _whenReady;
|
|
72
|
+
/**
|
|
73
|
+
* Plays the movie
|
|
74
|
+
*
|
|
75
|
+
* @param [options]
|
|
76
|
+
* @param [options.onStart] Called when the movie starts playing
|
|
77
|
+
*
|
|
78
|
+
* @return Fulfilled when the movie is done playing, never fails
|
|
79
|
+
*/
|
|
80
|
+
play(options?: {
|
|
81
|
+
onStart?: () => void;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Updates the rendering canvas and audio destination to the visible canvas
|
|
85
|
+
* and the audio context destination.
|
|
86
|
+
*/
|
|
87
|
+
private _show;
|
|
88
|
+
/**
|
|
89
|
+
* Streams the movie to a MediaStream
|
|
90
|
+
*
|
|
91
|
+
* @param options Options for the stream
|
|
92
|
+
* @param options.frameRate The frame rate of the stream's video
|
|
93
|
+
* @param options.duration The duration of the stream in seconds
|
|
94
|
+
* @param options.video Whether to stream video. Defaults to true.
|
|
95
|
+
* @param options.audio Whether to stream audio. Defaults to true.
|
|
96
|
+
* @param options.onStart Called when the stream is started
|
|
97
|
+
* @return Fulfilled when the stream is done, never fails
|
|
98
|
+
*/
|
|
99
|
+
stream(options: {
|
|
100
|
+
frameRate: number;
|
|
101
|
+
duration?: number;
|
|
102
|
+
video?: boolean;
|
|
103
|
+
audio?: boolean;
|
|
104
|
+
onStart(stream: MediaStream): void;
|
|
105
|
+
}): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Plays the movie in the background and records it
|
|
108
|
+
*
|
|
109
|
+
* @param options
|
|
110
|
+
* @param [options.frameRate] - Video frame rate
|
|
111
|
+
* @param [options.video=true] - whether to include video in recording
|
|
112
|
+
* @param [options.audio=true] - whether to include audio in recording
|
|
113
|
+
* @param [options.mediaRecorderOptions=undefined] - Options to pass to the
|
|
114
|
+
* `MediaRecorder` constructor
|
|
115
|
+
* @param [options.type='video/webm'] - MIME type for exported video
|
|
116
|
+
* @param [options.onStart] - Called when the recording starts
|
|
117
|
+
* @return Resolves when done recording, rejects when media recorder errors
|
|
118
|
+
*/
|
|
119
|
+
record(options: {
|
|
120
|
+
frameRate: number;
|
|
121
|
+
duration?: number;
|
|
122
|
+
type?: string;
|
|
123
|
+
video?: boolean;
|
|
124
|
+
audio?: boolean;
|
|
125
|
+
mediaRecorderOptions?: Record<string, unknown>;
|
|
126
|
+
onStart?: (recorder: MediaRecorder) => void;
|
|
127
|
+
}): Promise<Blob>;
|
|
128
|
+
/**
|
|
129
|
+
* Stops the movie without resetting the playback position
|
|
130
|
+
* @return The movie
|
|
131
|
+
*/
|
|
132
|
+
pause(): Movie;
|
|
133
|
+
/**
|
|
134
|
+
* Stops playback and resets the playback position
|
|
135
|
+
* @return The movie
|
|
136
|
+
*/
|
|
137
|
+
stop(): Movie;
|
|
138
|
+
/**
|
|
139
|
+
* @param [timestamp=performance.now()]
|
|
140
|
+
* @param [done=undefined] - Called when done playing or when the current
|
|
141
|
+
* frame is loaded
|
|
142
|
+
*/
|
|
143
|
+
private _render;
|
|
144
|
+
private _updateCurrentTime;
|
|
145
|
+
private _renderBackground;
|
|
146
|
+
/**
|
|
147
|
+
* @param [timestamp=performance.now()]
|
|
148
|
+
*/
|
|
149
|
+
private _renderLayers;
|
|
150
|
+
private _applyEffects;
|
|
151
|
+
/**
|
|
152
|
+
* Refreshes the screen
|
|
153
|
+
*
|
|
154
|
+
* Only use this if auto-refresh is disabled
|
|
155
|
+
*
|
|
156
|
+
* @return - Promise that resolves when the frame is loaded
|
|
157
|
+
*/
|
|
158
|
+
refresh(): Promise<null>;
|
|
159
|
+
/**
|
|
160
|
+
* Convienence method (TODO: remove)
|
|
161
|
+
*/
|
|
162
|
+
private _publishToLayers;
|
|
163
|
+
/**
|
|
164
|
+
* `true` if the movie is playing, recording or refreshing
|
|
165
|
+
*/
|
|
166
|
+
get rendering(): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* `true` if the movie is refreshing the current frame
|
|
169
|
+
*/
|
|
170
|
+
get renderingFrame(): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* `true` if the movie is recording
|
|
173
|
+
*/
|
|
174
|
+
get recording(): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The duration of the movie in seconds
|
|
177
|
+
*
|
|
178
|
+
* Calculated from the end time of the last layer
|
|
179
|
+
*/
|
|
180
|
+
get duration(): number;
|
|
181
|
+
/**
|
|
182
|
+
* Convenience method for `layers.push()`
|
|
183
|
+
* @param layer
|
|
184
|
+
* @return The movie
|
|
185
|
+
*/
|
|
186
|
+
addLayer(layer: BaseLayer): Movie;
|
|
187
|
+
/**
|
|
188
|
+
* Convenience method for `effects.push()`
|
|
189
|
+
* @param effect
|
|
190
|
+
* @return the movie
|
|
191
|
+
*/
|
|
192
|
+
addEffect(effect: BaseEffect): Movie;
|
|
193
|
+
/**
|
|
194
|
+
* `true` if the movie is paused
|
|
195
|
+
*/
|
|
196
|
+
get paused(): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* `true` if the playback position is at the end of the movie
|
|
199
|
+
*/
|
|
200
|
+
get ended(): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Skips to the provided playback position, updating {@link currentTime}.
|
|
203
|
+
*
|
|
204
|
+
* @param time - The new playback position (in seconds)
|
|
205
|
+
*/
|
|
206
|
+
seek(time: number): void;
|
|
207
|
+
/**
|
|
208
|
+
* The current playback position in seconds
|
|
209
|
+
*/
|
|
210
|
+
get currentTime(): number;
|
|
211
|
+
/**
|
|
212
|
+
* Skips to the provided playback position, updating {@link currentTime}.
|
|
213
|
+
*
|
|
214
|
+
* @param time - The new playback position (in seconds)
|
|
215
|
+
*
|
|
216
|
+
* @deprecated Use `seek` instead
|
|
217
|
+
*/
|
|
218
|
+
set currentTime(time: number);
|
|
219
|
+
/**
|
|
220
|
+
* Skips to the provided playback position, updating {@link currentTime}.
|
|
221
|
+
*
|
|
222
|
+
* @param time - The new time (in seconds)
|
|
223
|
+
* @param [refresh=true] - Render a single frame?
|
|
224
|
+
* @return Promise that resolves when the current frame is rendered if
|
|
225
|
+
* `refresh` is true; otherwise resolves immediately.
|
|
226
|
+
*
|
|
227
|
+
* @deprecated Call {@link seek} and {@link refresh} separately
|
|
228
|
+
*/
|
|
229
|
+
setCurrentTime(time: number, refresh?: boolean): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* `true` if the movie is ready for playback
|
|
232
|
+
*/
|
|
233
|
+
get ready(): boolean;
|
|
234
|
+
/**
|
|
235
|
+
* The HTML canvas element used for rendering
|
|
236
|
+
*/
|
|
237
|
+
get canvas(): HTMLCanvasElement;
|
|
238
|
+
/**
|
|
239
|
+
* The canvas context used for rendering
|
|
240
|
+
*/
|
|
241
|
+
get cctx(): CanvasRenderingContext2D;
|
|
242
|
+
/**
|
|
243
|
+
* The width of the output canvas
|
|
244
|
+
*/
|
|
245
|
+
get width(): number;
|
|
246
|
+
set width(width: number);
|
|
247
|
+
/**
|
|
248
|
+
* The height of the output canvas
|
|
249
|
+
*/
|
|
250
|
+
get height(): number;
|
|
251
|
+
set height(height: number);
|
|
252
|
+
/**
|
|
253
|
+
* @return The movie
|
|
254
|
+
*/
|
|
255
|
+
get movie(): Movie;
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated See {@link https://github.com/etro-js/etro/issues/131}
|
|
258
|
+
*/
|
|
259
|
+
getDefaultOptions(): MovieOptions;
|
|
260
|
+
}
|
package/dist/object.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Movie } from './movie';
|
|
2
2
|
/** A movie, layer or effect */
|
|
3
3
|
export default interface EtroObject {
|
|
4
|
+
currentTime: number;
|
|
4
5
|
/** Used in etro internals */
|
|
5
6
|
type: string;
|
|
6
|
-
/**
|
|
7
|
-
* Which properties to not watch for changes, for `Movie#autoRefresh`
|
|
8
|
-
*
|
|
9
|
-
* @deprecated `Movie#autoRefresh` is deprecated
|
|
10
|
-
*/
|
|
11
|
-
publicExcludes: string[];
|
|
12
7
|
/** Map of property name to function to run on result of `val` */
|
|
13
8
|
propertyFilters: Record<string, <T>(value: T) => T>;
|
|
9
|
+
/**
|
|
10
|
+
* `true` if this object is ready to be played/rendered/applied, `false`
|
|
11
|
+
* otherwise
|
|
12
|
+
*/
|
|
13
|
+
ready: boolean;
|
|
14
14
|
movie: Movie;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated See {@link https://github.com/etro-js/etro/issues/131}
|
|
17
|
+
*/
|
|
15
18
|
getDefaultOptions(): object;
|
|
16
19
|
}
|
package/dist/util.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ import { Movie } from './movie';
|
|
|
7
7
|
* Merges `options` with `defaultOptions`, and then copies the properties with
|
|
8
8
|
* the keys in `defaultOptions` from the merged object to `destObj`.
|
|
9
9
|
*
|
|
10
|
+
* @deprecated Each option should be copied individually, and the default value
|
|
11
|
+
* should be set in the constructor. See
|
|
12
|
+
* {@link https://github.com/etro-js/etro/issues/131} for more info.
|
|
13
|
+
*
|
|
10
14
|
* @return
|
|
11
15
|
*/
|
|
12
16
|
export declare function applyOptions(options: object, destObj: EtroObject): void;
|
|
@@ -115,13 +119,3 @@ export declare function parseFont(str: string): Font;
|
|
|
115
119
|
* @deprecated Use {@link effect.Shader} instead
|
|
116
120
|
*/
|
|
117
121
|
export declare function mapPixels(mapper: (pixels: Uint8ClampedArray, i: number) => void, canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, flush?: boolean): void;
|
|
118
|
-
/**
|
|
119
|
-
* <p>Emits "change" event when public properties updated, recursively.
|
|
120
|
-
* <p>Must be called before any watchable properties are set, and only once in
|
|
121
|
-
* the prototype chain.
|
|
122
|
-
*
|
|
123
|
-
* @deprecated Will be removed in the future (see issue #130)
|
|
124
|
-
*
|
|
125
|
-
* @param target - object to watch
|
|
126
|
-
*/
|
|
127
|
-
export declare function watchPublic(target: EtroObject): EtroObject;
|
package/eslint.conf.js
CHANGED
package/karma.conf.js
CHANGED
|
@@ -63,7 +63,10 @@ module.exports = function (config) {
|
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
client: {
|
|
66
|
-
captureConsole: true
|
|
66
|
+
captureConsole: true,
|
|
67
|
+
jasmine: {
|
|
68
|
+
timeoutInterval: 20000
|
|
69
|
+
}
|
|
67
70
|
},
|
|
68
71
|
|
|
69
72
|
browserConsoleLogOptions: {
|
|
@@ -77,11 +80,5 @@ module.exports = function (config) {
|
|
|
77
80
|
// Concurrency level
|
|
78
81
|
// how many browser should be started simultaneous
|
|
79
82
|
concurrency: Infinity,
|
|
80
|
-
|
|
81
|
-
client: {
|
|
82
|
-
jasmine: {
|
|
83
|
-
timeoutInterval: 10000
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
83
|
})
|
|
87
84
|
}
|