etro 0.8.0 → 0.8.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.
Files changed (95) hide show
  1. package/.github/workflows/nodejs.yml +3 -1
  2. package/CHANGELOG.md +9 -1
  3. package/CODE_OF_CONDUCT.md +5 -5
  4. package/CONTRIBUTING.md +22 -72
  5. package/README.md +1 -1
  6. package/dist/effect/base.d.ts +14 -1
  7. package/dist/etro-cjs.js +156 -213
  8. package/dist/etro-iife.js +156 -213
  9. package/dist/layer/base.d.ts +13 -0
  10. package/eslint.conf.js +2 -1
  11. package/eslint.test-conf.js +1 -0
  12. package/examples/application/readme-screenshot.html +4 -8
  13. package/examples/application/video-player.html +3 -4
  14. package/examples/introduction/effects.html +23 -4
  15. package/karma.conf.js +4 -2
  16. package/package.json +4 -1
  17. package/scripts/gen-effect-samples.html +0 -3
  18. package/src/effect/base.ts +29 -10
  19. package/src/effect/gaussian-blur.ts +10 -10
  20. package/src/effect/pixelate.ts +1 -2
  21. package/src/effect/shader.ts +18 -22
  22. package/src/effect/stack.ts +5 -2
  23. package/src/effect/transform.ts +13 -14
  24. package/src/event.ts +8 -14
  25. package/src/layer/audio-source.ts +16 -14
  26. package/src/layer/audio.ts +1 -2
  27. package/src/layer/base.ts +26 -7
  28. package/src/layer/visual.ts +5 -6
  29. package/src/movie.ts +41 -49
  30. package/src/util.ts +50 -57
  31. package/docs/effect.js.html +0 -1215
  32. package/docs/event.js.html +0 -145
  33. package/docs/index.html +0 -81
  34. package/docs/index.js.html +0 -92
  35. package/docs/layer.js.html +0 -888
  36. package/docs/module-effect-GaussianBlurComponent.html +0 -345
  37. package/docs/module-effect.Brightness.html +0 -339
  38. package/docs/module-effect.Channels.html +0 -319
  39. package/docs/module-effect.ChromaKey.html +0 -611
  40. package/docs/module-effect.Contrast.html +0 -339
  41. package/docs/module-effect.EllipticalMask.html +0 -200
  42. package/docs/module-effect.GaussianBlur.html +0 -202
  43. package/docs/module-effect.GaussianBlurHorizontal.html +0 -242
  44. package/docs/module-effect.GaussianBlurVertical.html +0 -242
  45. package/docs/module-effect.Pixelate.html +0 -330
  46. package/docs/module-effect.Shader.html +0 -1227
  47. package/docs/module-effect.Stack.html +0 -406
  48. package/docs/module-effect.Transform.Matrix.html +0 -193
  49. package/docs/module-effect.Transform.html +0 -1174
  50. package/docs/module-effect.html +0 -148
  51. package/docs/module-event.html +0 -473
  52. package/docs/module-index.html +0 -186
  53. package/docs/module-layer-Media.html +0 -1116
  54. package/docs/module-layer-MediaMixin.html +0 -164
  55. package/docs/module-layer.Audio.html +0 -1188
  56. package/docs/module-layer.Base.html +0 -629
  57. package/docs/module-layer.Image.html +0 -1421
  58. package/docs/module-layer.Text.html +0 -1731
  59. package/docs/module-layer.Video.html +0 -1938
  60. package/docs/module-layer.Visual.html +0 -1698
  61. package/docs/module-layer.html +0 -137
  62. package/docs/module-movie.html +0 -3118
  63. package/docs/module-util.Color.html +0 -702
  64. package/docs/module-util.Font.html +0 -395
  65. package/docs/module-util.html +0 -845
  66. package/docs/movie.js.html +0 -689
  67. package/docs/scripts/collapse.js +0 -20
  68. package/docs/scripts/linenumber.js +0 -25
  69. package/docs/scripts/nav.js +0 -12
  70. package/docs/scripts/polyfill.js +0 -4
  71. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  72. package/docs/scripts/prettify/lang-css.js +0 -2
  73. package/docs/scripts/prettify/prettify.js +0 -28
  74. package/docs/scripts/search.js +0 -83
  75. package/docs/styles/jsdoc.css +0 -671
  76. package/docs/styles/prettify.css +0 -79
  77. package/docs/util.js.html +0 -503
  78. package/spec/assets/effect/gaussian-blur-horizontal.png +0 -0
  79. package/spec/assets/effect/gaussian-blur-vertical.png +0 -0
  80. package/spec/assets/effect/grayscale.png +0 -0
  81. package/spec/assets/effect/original.png +0 -0
  82. package/spec/assets/effect/pixelate.png +0 -0
  83. package/spec/assets/effect/transform/multiply.png +0 -0
  84. package/spec/assets/effect/transform/rotate.png +0 -0
  85. package/spec/assets/effect/transform/scale-fraction.png +0 -0
  86. package/spec/assets/effect/transform/scale.png +0 -0
  87. package/spec/assets/effect/transform/translate-fraction.png +0 -0
  88. package/spec/assets/effect/transform/translate.png +0 -0
  89. package/spec/assets/layer/audio.wav +0 -0
  90. package/spec/assets/layer/image.jpg +0 -0
  91. package/spec/effect.spec.js +0 -421
  92. package/spec/event.spec.js +0 -39
  93. package/spec/layer.spec.js +0 -307
  94. package/spec/movie.spec.js +0 -346
  95. package/spec/util.spec.js +0 -294
package/spec/util.spec.js DELETED
@@ -1,294 +0,0 @@
1
- describe('Util', function () {
2
- describe('applyOptions', function () {
3
- it('should not apply any options with no provided or default options', function () {
4
- const etroobj = {
5
- getDefaultOptions () {
6
- return {}
7
- }
8
- }
9
- const snapshot = { ...etroobj } // store state before applying options
10
- etro.applyOptions({}, etroobj)
11
- expect(etroobj).toEqual(snapshot) // should be the same as it was
12
- })
13
-
14
- it('should apply default options', function () {
15
- const etroobj = {
16
- getDefaultOptions () {
17
- return defaultOpt
18
- }
19
- }
20
- const snapshot = { ...etroobj } // store state before applying options
21
- const defaultOpt = { foo: 1 }
22
- etro.applyOptions({}, etroobj)
23
- expect(etroobj).toEqual({ ...defaultOpt, ...snapshot }) // defaultOpt should be applied to etroobj
24
- })
25
-
26
- it('should not override provided options with default values', function () {
27
- const etroobj = {
28
- getDefaultOptions () {
29
- return { foo: 1 }
30
- }
31
- }
32
- const providedOpt = { foo: 2 }
33
- etro.applyOptions(providedOpt, etroobj)
34
- expect(etroobj.foo).toBe(providedOpt.foo)
35
- })
36
-
37
- it('should not override existing object state', function () {
38
- const etroobj = {
39
- foo: 0,
40
- getDefaultOptions () {
41
- return { foo: 1 }
42
- }
43
- }
44
- const originalFoo = etroobj.foo
45
- etro.applyOptions({ foo: 2 }, etroobj)
46
- expect(etroobj.foo).toBe(originalFoo)
47
- })
48
-
49
- it('should not allow arbitrary options', function () {
50
- const etroobj = {
51
- getDefaultOptions () {
52
- return {}
53
- }
54
- }
55
- expect(() => etro.applyOptions({ foo: null }, etroobj).toThrow(new Error("Invalid option: 'foo'")))
56
- })
57
- })
58
-
59
- describe('val', function () {
60
- it('should work on simple values', function () {
61
- // _movie is unique, so it won't depend on existing cache
62
- const elem = { prop: 'value', movie: {}, propertyFilters: {} }
63
- expect(etro.val(elem, 'prop', 0)).toBe(elem.prop)
64
- })
65
-
66
- it('should interpolate keyframes', function () {
67
- const elem = {
68
- prop: new etro.KeyFrame([0, 0], [4, 1]),
69
- movie: {}, // _movie is unique, so it won't depend on existing cache
70
- propertyFilters: {}
71
- }
72
- for (let i = 0; i <= 4; i += Math.random()) {
73
- expect(etro.val(elem, 'prop', i)).toBe(i / 4)
74
- etro.clearCachedValues(elem.movie)
75
- }
76
- })
77
-
78
- it('should work with noninterpolated keyframes', function () {
79
- const elem = {
80
- prop: new etro.KeyFrame([0, 'start'], [4, 'end']),
81
- movie: {}, // _movie is unique, so it won't depend on existing cache
82
- propertyFilters: {}
83
- }
84
- expect(etro.val(elem, 'prop', 0)).toBe('start')
85
- etro.clearCachedValues(elem.movie)
86
- expect(etro.val(elem, 'prop', 3)).toBe('start')
87
- etro.clearCachedValues(elem.movie)
88
- expect(etro.val(elem, 'prop', 4)).toBe('end')
89
- etro.clearCachedValues(elem.movie)
90
- })
91
-
92
- it('should use individual interpolation methods', function () {
93
- const elem = {
94
- prop: new etro.KeyFrame([0, 0, etro.cosineInterp], [1, 4]),
95
- movie: {},
96
- propertyFilters: {}
97
- }
98
- expect(etro.val(elem, 'prop', 0.5)).toBe(etro.cosineInterp(0, 4, 0.5))
99
- })
100
-
101
- it('should call property filters', function () {
102
- const elem = {
103
- prop: 'value',
104
- movie: {},
105
- propertyFilters: {
106
- prop: () => 'new value'
107
- }
108
- }
109
- expect(etro.val(elem, 'prop', 0)).toBe('new value')
110
- })
111
- })
112
-
113
- describe('linearInterp', function () {
114
- it('should interpolate numbers', function () {
115
- expect(etro.linearInterp(5, 10, 0.5, undefined)).toBe(7.5)
116
- })
117
-
118
- it('should choose the first string', function () {
119
- expect(etro.linearInterp('hello', 'world', 0.5)).toBe('hello')
120
- })
121
-
122
- it('should interpolate objects recursively', function () {
123
- expect(etro.linearInterp(
124
- {
125
- foo: {
126
- bar: 0
127
- }
128
- },
129
- {
130
- foo: {
131
- bar: 100
132
- }
133
- },
134
- 0.5,
135
- undefined
136
- )).toEqual(
137
- {
138
- foo: {
139
- bar: 50
140
- }
141
- }
142
- )
143
- })
144
- })
145
-
146
- describe('cosineInterp', function () {
147
- it('should interpolate numbers', function () {
148
- const x1 = 5
149
- const x2 = 10
150
- const t = 0.5
151
- const cos = Math.cos(t * Math.PI / 2)
152
- expect(etro.cosineInterp(x1, x2, t, undefined))
153
- .toBe(cos * x1 + (1 - cos) * x2)
154
- })
155
-
156
- it('should choose the first string', function () {
157
- expect(etro.linearInterp('hello', 'world', 0.5)).toBe('hello')
158
- })
159
-
160
- it('should interpolate objects recursively', function () {
161
- expect(etro.cosineInterp(
162
- {
163
- foo: {
164
- bar: 0
165
- }
166
- },
167
- {
168
- foo: {
169
- bar: 100
170
- }
171
- },
172
- 0.5,
173
- undefined
174
- )).toEqual(
175
- {
176
- foo: {
177
- bar: (1 - Math.cos(0.5 * Math.PI / 2)) * 100
178
- }
179
- }
180
- )
181
- })
182
- })
183
-
184
- describe('Color ->', function () {
185
- it('toString() should convert to RGBA', function () {
186
- expect(new etro.Color(255, 0, 255, 0.5).toString())
187
- .toBe('rgba(255, 0, 255, 0.5)')
188
- })
189
- })
190
-
191
- describe('parseColor', function () {
192
- it('should parse RGB colors', function () {
193
- expect(etro.parseColor('rgb(255,0,0)'))
194
- .toEqual(new etro.Color(255, 0, 0))
195
- })
196
-
197
- it('should parse RGBA colors', function () {
198
- expect(etro.parseColor('rgba(0,255,0,1)'))
199
- .toEqual(new etro.Color(0, 255, 0, 1))
200
- })
201
-
202
- it('should parse hex colors', function () {
203
- expect(etro.parseColor('#00f'))
204
- .toEqual(new etro.Color(0, 0, 255))
205
- })
206
-
207
- it('should parse named colors', function () {
208
- expect(etro.parseColor('blue'))
209
- .toEqual(new etro.Color(0, 0, 255))
210
- })
211
- })
212
-
213
- describe('Font ->', function () {
214
- it('toString() should convert to CSS font', function () {
215
- expect(new etro.Font(16, 'px', 'monospace').toString())
216
- .toBe('16px monospace')
217
- })
218
- })
219
-
220
- describe('parseFont', function () {
221
- it('should parse CSS fonts', function () {
222
- expect(etro.parseFont('16em monospace'))
223
- .toEqual(new etro.Font(16, 'em', 'monospace'))
224
- })
225
-
226
- it('should work with multiple word fonts', function () {
227
- expect(etro.parseFont('16px "Times New Roman"'))
228
- .toEqual(new etro.Font(16, 'px', '"Times New Roman"'))
229
- })
230
- })
231
-
232
- describe('watchPublic', function () {
233
- it('should watch public properties', function () {
234
- const element = etro.watchPublic({
235
- // mock etro element
236
- publicExcludes: [],
237
- type: 'test'
238
- })
239
- element.foo = 0 // intiialize (must be after watchPublic)
240
- const history = []
241
- etro.event.subscribe(element, 'test.change.modify', event => history.push(event))
242
-
243
- element.foo = 1
244
- expect(history).toEqual([
245
- {
246
- target: element,
247
- type: 'test.change.modify',
248
- property: 'foo',
249
- newValue: 1
250
- }
251
- ])
252
- })
253
-
254
- it("should watch recursive modifications that don't change the schema", function () {
255
- const element = etro.watchPublic({
256
- publicExcludes: [],
257
- type: 'test'
258
- })
259
- element.foo = { bar: 0 } // intiialize (must be after watchPublic)
260
- const history = []
261
- etro.event.subscribe(element, 'test.change.modify', event => history.push(event))
262
-
263
- element.foo.bar = 1
264
- expect(history).toEqual([
265
- {
266
- target: element,
267
- type: 'test.change.modify',
268
- property: 'foo.bar',
269
- newValue: 1
270
- }
271
- ])
272
- })
273
-
274
- it('should watch recursive modifications that change the schema', function () {
275
- const element = etro.watchPublic({
276
- publicExcludes: [],
277
- type: 'test'
278
- })
279
- element.foo = {} // intiialize (must be after watchPublic)
280
- const history = []
281
- etro.event.subscribe(element, 'test.change.modify', event => history.push(event))
282
-
283
- element.foo.bar = 1
284
- expect(history).toEqual([
285
- {
286
- target: element,
287
- type: 'test.change.modify',
288
- property: 'foo.bar',
289
- newValue: 1
290
- }
291
- ])
292
- })
293
- })
294
- })