etro 0.12.1 → 0.14.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 (145) hide show
  1. package/.github/dependabot.yml +6 -0
  2. package/.github/scripts/update-changelog.js +72 -0
  3. package/.github/workflows/dependabot-changelog.yml +57 -0
  4. package/.github/workflows/nodejs.yml +6 -2
  5. package/.github/workflows/shipjs-trigger.yml +2 -1
  6. package/.husky/pre-commit +1 -1
  7. package/AGENTS.md +106 -0
  8. package/CHANGELOG.md +46 -0
  9. package/CONTRIBUTING.md +5 -5
  10. package/README.md +8 -7
  11. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/base.css +224 -0
  12. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/block-navigation.js +87 -0
  13. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/favicon.png +0 -0
  14. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/index.html +161 -0
  15. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/prettify.css +1 -0
  16. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/prettify.js +2 -0
  17. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/sort-arrow-sprite.png +0 -0
  18. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/sorter.js +196 -0
  19. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/custom-array.ts.html +214 -0
  20. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/base.ts.html +481 -0
  21. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/brightness.ts.html +214 -0
  22. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/channels.ts.html +235 -0
  23. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/chroma-key.ts.html +331 -0
  24. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/contrast.ts.html +211 -0
  25. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/elliptical-mask.ts.html +310 -0
  26. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/gaussian-blur.ts.html +796 -0
  27. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/grayscale.ts.html +187 -0
  28. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/index.html +311 -0
  29. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/index.ts.html +154 -0
  30. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/pixelate.ts.html +259 -0
  31. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/shader.ts.html +1774 -0
  32. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/stack.ts.html +358 -0
  33. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/transform.ts.html +685 -0
  34. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/effect/visual.ts.html +148 -0
  35. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/etro.ts.html +163 -0
  36. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/event.ts.html +691 -0
  37. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/index.html +176 -0
  38. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/index.ts.html +109 -0
  39. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/audio-source.ts.html +835 -0
  40. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/audio.ts.html +241 -0
  41. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/base.ts.html +826 -0
  42. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/image.ts.html +181 -0
  43. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/index.html +236 -0
  44. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/index.ts.html +124 -0
  45. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/text.ts.html +658 -0
  46. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/video.ts.html +211 -0
  47. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/visual-source.ts.html +721 -0
  48. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/layer/visual.ts.html +760 -0
  49. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/movie/effects.ts.html +163 -0
  50. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/movie/index.html +161 -0
  51. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/movie/index.ts.html +88 -0
  52. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/movie/layers.ts.html +163 -0
  53. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/movie/movie.ts.html +3037 -0
  54. package/coverage/Chrome Headless 148.0.0.0 (Mac OS 10.15.7)/html/src/util.ts.html +1765 -0
  55. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/base.css +224 -0
  56. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/block-navigation.js +87 -0
  57. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/favicon.png +0 -0
  58. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/index.html +161 -0
  59. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/prettify.css +1 -0
  60. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/prettify.js +2 -0
  61. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/sort-arrow-sprite.png +0 -0
  62. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/sorter.js +196 -0
  63. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/custom-array.ts.html +214 -0
  64. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/base.ts.html +481 -0
  65. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/brightness.ts.html +214 -0
  66. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/channels.ts.html +235 -0
  67. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/chroma-key.ts.html +331 -0
  68. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/contrast.ts.html +211 -0
  69. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/elliptical-mask.ts.html +310 -0
  70. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/gaussian-blur.ts.html +796 -0
  71. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/grayscale.ts.html +187 -0
  72. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/index.html +311 -0
  73. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/index.ts.html +154 -0
  74. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/pixelate.ts.html +259 -0
  75. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/shader.ts.html +1774 -0
  76. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/stack.ts.html +358 -0
  77. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/transform.ts.html +685 -0
  78. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/effect/visual.ts.html +148 -0
  79. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/etro.ts.html +163 -0
  80. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/event.ts.html +691 -0
  81. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/index.html +176 -0
  82. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/index.ts.html +109 -0
  83. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/audio-source.ts.html +835 -0
  84. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/audio.ts.html +241 -0
  85. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/base.ts.html +826 -0
  86. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/image.ts.html +181 -0
  87. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/index.html +236 -0
  88. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/index.ts.html +124 -0
  89. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/text.ts.html +658 -0
  90. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/video.ts.html +211 -0
  91. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/visual-source.ts.html +721 -0
  92. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/layer/visual.ts.html +760 -0
  93. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/movie/effects.ts.html +163 -0
  94. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/movie/index.html +161 -0
  95. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/movie/index.ts.html +88 -0
  96. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/movie/layers.ts.html +163 -0
  97. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/movie/movie.ts.html +3037 -0
  98. package/coverage/Firefox 151.0 (Mac OS 10.15)/html/src/util.ts.html +1765 -0
  99. package/dist/custom-array.d.ts +10 -10
  100. package/dist/effect/base.d.ts +61 -60
  101. package/dist/effect/brightness.d.ts +16 -16
  102. package/dist/effect/channels.d.ts +23 -23
  103. package/dist/effect/chroma-key.d.ts +23 -23
  104. package/dist/effect/contrast.d.ts +15 -15
  105. package/dist/effect/elliptical-mask.d.ts +31 -31
  106. package/dist/effect/gaussian-blur.d.ts +60 -60
  107. package/dist/effect/grayscale.d.ts +7 -7
  108. package/dist/effect/index.d.ts +16 -16
  109. package/dist/effect/pixelate.d.ts +18 -18
  110. package/dist/effect/shader.d.ts +109 -109
  111. package/dist/effect/stack.d.ts +27 -27
  112. package/dist/effect/transform.d.ts +73 -73
  113. package/dist/effect/visual.d.ts +17 -17
  114. package/dist/etro-cjs.js +3601 -3556
  115. package/dist/etro-iife.js +3602 -3557
  116. package/dist/etro.d.ts +7 -7
  117. package/dist/event.d.ts +40 -40
  118. package/dist/index.d.ts +6 -6
  119. package/dist/layer/audio-source.d.ts +28 -28
  120. package/dist/layer/audio.d.ts +27 -27
  121. package/dist/layer/base.d.ts +129 -128
  122. package/dist/layer/image.d.ts +20 -20
  123. package/dist/layer/index.d.ts +11 -11
  124. package/dist/layer/text.d.ts +78 -78
  125. package/dist/layer/video.d.ts +23 -23
  126. package/dist/layer/visual-source.d.ts +47 -47
  127. package/dist/layer/visual.d.ts +62 -62
  128. package/dist/movie/effects.d.ts +6 -6
  129. package/dist/movie/index.d.ts +1 -1
  130. package/dist/movie/layers.d.ts +6 -6
  131. package/dist/movie/movie.d.ts +280 -277
  132. package/dist/object.d.ts +19 -19
  133. package/dist/util.d.ts +128 -121
  134. package/karma.conf.js +70 -3
  135. package/package.json +14 -17
  136. package/ship.config.js +9 -11
  137. package/src/effect/base.ts +16 -0
  138. package/src/effect/shader.ts +1 -1
  139. package/src/layer/base.ts +19 -1
  140. package/src/movie/movie.ts +123 -8
  141. package/src/util.ts +116 -3
  142. package/tsconfig.json +3 -2
  143. package/.husky/commit-msg +0 -4
  144. package/.husky/prepare-commit-msg +0 -11
  145. package/commitlint.config.ts +0 -39
@@ -1,277 +1,280 @@
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
- /** The timestamp last frame in seconds */
66
- private _lastRealTime;
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
- * @param [options.duration] The duration of the movie to play in seconds
78
- *
79
- * @return Fulfilled when the movie is done playing, never fails
80
- */
81
- play(options?: {
82
- onStart?: () => void;
83
- duration?: number;
84
- }): Promise<void>;
85
- /**
86
- * Updates the rendering canvas and audio destination to the visible canvas
87
- * and the audio context destination.
88
- */
89
- private _show;
90
- /**
91
- * Streams the movie to a MediaStream
92
- *
93
- * @param options Options for the stream
94
- * @param options.frameRate The frame rate of the stream's video
95
- * @param options.duration The duration of the stream in seconds
96
- * @param options.video Whether to stream video. Defaults to true.
97
- * @param options.audio Whether to stream audio. Defaults to true.
98
- * @param options.onStart Called when the stream is started
99
- * @return Fulfilled when the stream is done, never fails
100
- */
101
- stream(options: {
102
- frameRate: number;
103
- duration?: number;
104
- video?: boolean;
105
- audio?: boolean;
106
- onStart(stream: MediaStream): void;
107
- }): Promise<void>;
108
- /**
109
- * Plays the movie in the background and records it
110
- *
111
- * @param options
112
- * @param [options.frameRate] - Video frame rate
113
- * @param [options.video=true] - whether to include video in recording
114
- * @param [options.audio=true] - whether to include audio in recording
115
- * @param [options.mediaRecorderOptions=undefined] - Options to pass to the
116
- * `MediaRecorder` constructor
117
- * @param [options.type='video/webm'] - MIME type for exported video
118
- * @param [options.onStart] - Called when the recording starts
119
- * @return Resolves when done recording, rejects when media recorder errors
120
- */
121
- record(options: {
122
- frameRate: number;
123
- duration?: number;
124
- type?: string;
125
- video?: boolean;
126
- audio?: boolean;
127
- mediaRecorderOptions?: Record<string, unknown>;
128
- onStart?: (recorder: MediaRecorder) => void;
129
- }): Promise<Blob>;
130
- /**
131
- * Stops the movie without resetting the playback position
132
- * @return The movie
133
- */
134
- pause(): Movie;
135
- /**
136
- * Stops playback and resets the playback position
137
- * @return The movie
138
- */
139
- stop(): Movie;
140
- /**
141
- * Processes one frame of the movie and draws it to the canvas
142
- *
143
- * @param [timestamp=performance.now()]
144
- * @param [done=undefined] - Called when done playing or when the current
145
- * frame is loaded
146
- */
147
- private _render;
148
- private _updateCurrentTime;
149
- /**
150
- * Draws the movie's background to the canvas
151
- *
152
- * @param timestamp The current high-resolution timestamp in milliseconds
153
- */
154
- private _renderBackground;
155
- /**
156
- * Ticks all layers and renders them to the canvas
157
- */
158
- private _renderLayers;
159
- /**
160
- * Applies all of the movie's effects to the canvas
161
- *
162
- * Note: This method only applies the movie's effects, not the layers'
163
- * effects.
164
- */
165
- private _applyEffects;
166
- /**
167
- * Refreshes the screen
168
- *
169
- * Only use this if auto-refresh is disabled
170
- *
171
- * @return - Promise that resolves when the frame is loaded
172
- */
173
- refresh(): Promise<null>;
174
- /**
175
- * Convienence method (TODO: remove)
176
- */
177
- private _publishToLayers;
178
- /**
179
- * `true` if the movie is playing, recording or refreshing
180
- */
181
- get rendering(): boolean;
182
- /**
183
- * `true` if the movie is refreshing the current frame
184
- */
185
- get renderingFrame(): boolean;
186
- /**
187
- * `true` if the movie is recording
188
- */
189
- get recording(): boolean;
190
- /**
191
- * The duration of the movie in seconds
192
- *
193
- * Calculated from the end time of the last layer
194
- */
195
- get duration(): number;
196
- /**
197
- * Convenience method for `layers.push()`
198
- *
199
- * @param layer
200
- * @return The movie
201
- */
202
- addLayer(layer: BaseLayer): Movie;
203
- /**
204
- * Convenience method for `effects.push()`
205
- *
206
- * @param effect
207
- * @return the movie
208
- */
209
- addEffect(effect: BaseEffect): Movie;
210
- /**
211
- * `true` if the movie is paused
212
- */
213
- get paused(): boolean;
214
- /**
215
- * `true` if the playback position is at the end of the movie
216
- */
217
- get ended(): boolean;
218
- /**
219
- * Skips to the provided playback position, updating {@link currentTime}.
220
- *
221
- * @param time - The new playback position (in seconds)
222
- */
223
- seek(time: number): void;
224
- /**
225
- * The current playback position in seconds
226
- */
227
- get currentTime(): number;
228
- /**
229
- * Skips to the provided playback position, updating {@link currentTime}.
230
- *
231
- * @param time - The new playback position (in seconds)
232
- *
233
- * @deprecated Use `seek` instead
234
- */
235
- set currentTime(time: number);
236
- /**
237
- * Skips to the provided playback position, updating {@link currentTime}.
238
- *
239
- * @param time - The new time (in seconds)
240
- * @param [refresh=true] - Render a single frame?
241
- * @return Promise that resolves when the current frame is rendered if
242
- * `refresh` is true; otherwise resolves immediately.
243
- *
244
- * @deprecated Call {@link seek} and {@link refresh} separately
245
- */
246
- setCurrentTime(time: number, refresh?: boolean): Promise<void>;
247
- /**
248
- * `true` if the movie is ready for playback
249
- */
250
- get ready(): boolean;
251
- /**
252
- * The HTML canvas element used for rendering
253
- */
254
- get canvas(): HTMLCanvasElement;
255
- /**
256
- * The canvas context used for rendering
257
- */
258
- get cctx(): CanvasRenderingContext2D;
259
- /**
260
- * The width of the output canvas
261
- */
262
- get width(): number;
263
- set width(width: number);
264
- /**
265
- * The height of the output canvas
266
- */
267
- get height(): number;
268
- set height(height: number);
269
- /**
270
- * @return The movie
271
- */
272
- get movie(): Movie;
273
- /**
274
- * @deprecated See {@link https://github.com/etro-js/etro/issues/131}
275
- */
276
- getDefaultOptions(): MovieOptions;
277
- }
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
+ /** The timestamp last frame in seconds */
66
+ private _lastRealTime;
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.onDraw] Called when the current frame is drawn to the canvas
77
+ * @param [options.onStart] Called when the movie starts playing
78
+ * @param [options.duration] The duration of the movie to play in seconds
79
+ * @return Fulfilled when the movie is done playing, never fails
80
+ */
81
+ play(options?: {
82
+ onDraw?: () => void;
83
+ onStart?: () => void;
84
+ duration?: number;
85
+ }): Promise<void>;
86
+ /**
87
+ * Updates the rendering canvas and audio destination to the visible canvas
88
+ * and the audio context destination.
89
+ */
90
+ private _show;
91
+ /**
92
+ * Streams the movie to a MediaStream
93
+ *
94
+ * @param options Options for the stream
95
+ * @param options.frameRate The maximum frame rate of the stream's video
96
+ * @param options.duration The duration of the stream in seconds
97
+ * @param options.video Whether to stream video. Defaults to true.
98
+ * @param options.audio Whether to stream audio. Defaults to true.
99
+ * @param options.onStart Called when the stream is started
100
+ * @return Fulfilled when the stream is done, never fails
101
+ */
102
+ stream(options: {
103
+ frameRate: number;
104
+ duration?: number;
105
+ video?: boolean;
106
+ audio?: boolean;
107
+ onStart(stream: MediaStream): void;
108
+ }): Promise<void>;
109
+ /**
110
+ * Plays the movie in the background and records it
111
+ *
112
+ * @param options
113
+ * @param [options.frameRate] - Maximum video frame rate (fps)
114
+ * @param [options.video=true] - whether to include video in recording
115
+ * @param [options.audio=true] - whether to include audio in recording
116
+ * @param [options.mediaRecorderOptions=undefined] - Options to pass to the
117
+ * `MediaRecorder` constructor
118
+ * @param [options.type='video/webm'] - MIME type for exported video
119
+ * @param [options.onStart] - Called when the recording starts
120
+ * @return Resolves when done recording, rejects when media recorder errors
121
+ */
122
+ record(options: {
123
+ frameRate: number;
124
+ duration?: number;
125
+ type?: string;
126
+ video?: boolean;
127
+ audio?: boolean;
128
+ mediaRecorderOptions?: Record<string, unknown>;
129
+ onStart?: (recorder: MediaRecorder) => void;
130
+ }): Promise<Blob>;
131
+ /**
132
+ * Stops the movie without resetting the playback position
133
+ * @return The movie
134
+ */
135
+ pause(): Movie;
136
+ /**
137
+ * Stops playback and resets the playback position
138
+ * @return The movie
139
+ */
140
+ stop(): Movie;
141
+ /**
142
+ * Processes one frame of the movie and draws it to the canvas
143
+ *
144
+ * @param [timestamp=performance.now()]
145
+ * @param [done=undefined] - Called when done playing or when the current frame is loaded
146
+ * @param [onFrameRender=undefined] - Called when the current frame is rendered
147
+ */
148
+ private _render;
149
+ private _updateCurrentTime;
150
+ /**
151
+ * Draws the movie's background to the canvas
152
+ *
153
+ * @param timestamp The current high-resolution timestamp in milliseconds
154
+ */
155
+ private _renderBackground;
156
+ /**
157
+ * Ticks all layers and renders them to the canvas
158
+ */
159
+ private _renderLayers;
160
+ /**
161
+ * Applies all of the movie's effects to the canvas
162
+ *
163
+ * Note: This method only applies the movie's effects, not the layers'
164
+ * effects.
165
+ */
166
+ private _applyEffects;
167
+ /**
168
+ * Refreshes the screen
169
+ *
170
+ * Only use this if auto-refresh is disabled
171
+ *
172
+ * @return - Promise that resolves when the frame is loaded
173
+ */
174
+ refresh(): Promise<null>;
175
+ /**
176
+ * Convienence method (TODO: remove)
177
+ */
178
+ private _publishToLayers;
179
+ /**
180
+ * `true` if the movie is playing, recording or refreshing
181
+ */
182
+ get rendering(): boolean;
183
+ /**
184
+ * `true` if the movie is refreshing the current frame
185
+ */
186
+ get renderingFrame(): boolean;
187
+ /**
188
+ * `true` if the movie is recording
189
+ */
190
+ get recording(): boolean;
191
+ /**
192
+ * The duration of the movie in seconds
193
+ *
194
+ * Calculated from the end time of the last layer
195
+ */
196
+ get duration(): number;
197
+ /**
198
+ * Convenience method for `layers.push()`
199
+ *
200
+ * @param layer
201
+ * @return The movie
202
+ */
203
+ addLayer(layer: BaseLayer): Movie;
204
+ /**
205
+ * Convenience method for `effects.push()`
206
+ *
207
+ * @param effect
208
+ * @return the movie
209
+ */
210
+ addEffect(effect: BaseEffect): Movie;
211
+ /**
212
+ * `true` if the movie is paused
213
+ */
214
+ get paused(): boolean;
215
+ /**
216
+ * `true` if the playback position is at the end of the movie
217
+ */
218
+ get ended(): boolean;
219
+ /**
220
+ * Skips to the provided playback position, updating {@link currentTime}.
221
+ *
222
+ * @param time - The new playback position (in seconds)
223
+ */
224
+ seek(time: number): void;
225
+ /**
226
+ * The current playback position in seconds
227
+ */
228
+ get currentTime(): number;
229
+ /**
230
+ * Skips to the provided playback position, updating {@link currentTime}.
231
+ *
232
+ * @param time - The new playback position (in seconds)
233
+ *
234
+ * @deprecated Use `seek` instead
235
+ */
236
+ set currentTime(time: number);
237
+ /**
238
+ * Skips to the provided playback position, updating {@link currentTime}.
239
+ *
240
+ * @param time - The new time (in seconds)
241
+ * @param [refresh=true] - Render a single frame?
242
+ * @return Promise that resolves when the current frame is rendered if
243
+ * `refresh` is true; otherwise resolves immediately.
244
+ *
245
+ * @deprecated Call {@link seek} and {@link refresh} separately
246
+ */
247
+ setCurrentTime(time: number, refresh?: boolean): Promise<void>;
248
+ /**
249
+ * `true` if the movie is ready for playback
250
+ */
251
+ get ready(): boolean;
252
+ /**
253
+ * The HTML canvas element used for rendering
254
+ */
255
+ get canvas(): HTMLCanvasElement;
256
+ /**
257
+ * The canvas context used for rendering
258
+ */
259
+ get cctx(): CanvasRenderingContext2D;
260
+ /**
261
+ * The width of the output canvas
262
+ */
263
+ get width(): number;
264
+ set width(width: number);
265
+ /**
266
+ * The height of the output canvas
267
+ */
268
+ get height(): number;
269
+ set height(height: number);
270
+ /**
271
+ * @return The movie
272
+ */
273
+ get movie(): Movie;
274
+ /**
275
+ * @deprecated See {@link https://github.com/etro-js/etro/issues/131}
276
+ */
277
+ getDefaultOptions(): MovieOptions;
278
+ toJSON(): object;
279
+ static fromJSON(json: any, canvas?: HTMLCanvasElement, actx?: AudioContext): Movie;
280
+ }
package/dist/object.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import { Movie } from './movie';
2
- /** A movie, layer or effect */
3
- export default interface EtroObject {
4
- currentTime: number;
5
- /** Used in etro internals */
6
- type: string;
7
- /** Map of property name to function to run on result of `val` */
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
- movie: Movie;
15
- /**
16
- * @deprecated See {@link https://github.com/etro-js/etro/issues/131}
17
- */
18
- getDefaultOptions(): object;
19
- }
1
+ import { Movie } from './movie';
2
+ /** A movie, layer or effect */
3
+ export default interface EtroObject {
4
+ currentTime: number;
5
+ /** Used in etro internals */
6
+ type: string;
7
+ /** Map of property name to function to run on result of `val` */
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
+ movie: Movie;
15
+ /**
16
+ * @deprecated See {@link https://github.com/etro-js/etro/issues/131}
17
+ */
18
+ getDefaultOptions(): object;
19
+ }