etro 0.8.0 → 0.8.3

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 (97) hide show
  1. package/.github/workflows/nodejs.yml +3 -1
  2. package/.github/workflows/shipjs-trigger.yml +29 -0
  3. package/CHANGELOG.md +36 -13
  4. package/CODE_OF_CONDUCT.md +5 -5
  5. package/CONTRIBUTING.md +22 -72
  6. package/README.md +2 -2
  7. package/dist/effect/base.d.ts +14 -1
  8. package/dist/etro-cjs.js +189 -230
  9. package/dist/etro-iife.js +189 -230
  10. package/dist/layer/base.d.ts +13 -0
  11. package/eslint.conf.js +2 -1
  12. package/eslint.test-conf.js +1 -0
  13. package/examples/application/readme-screenshot.html +4 -8
  14. package/examples/application/video-player.html +3 -4
  15. package/examples/introduction/effects.html +23 -4
  16. package/karma.conf.js +4 -2
  17. package/package.json +8 -4
  18. package/scripts/gen-effect-samples.html +0 -3
  19. package/ship.config.js +80 -0
  20. package/src/effect/base.ts +29 -10
  21. package/src/effect/gaussian-blur.ts +10 -10
  22. package/src/effect/pixelate.ts +1 -2
  23. package/src/effect/shader.ts +18 -22
  24. package/src/effect/stack.ts +8 -4
  25. package/src/effect/transform.ts +13 -14
  26. package/src/event.ts +8 -14
  27. package/src/layer/audio-source.ts +16 -14
  28. package/src/layer/audio.ts +1 -2
  29. package/src/layer/base.ts +26 -7
  30. package/src/layer/visual.ts +11 -6
  31. package/src/movie.ts +70 -64
  32. package/src/util.ts +50 -57
  33. package/docs/effect.js.html +0 -1215
  34. package/docs/event.js.html +0 -145
  35. package/docs/index.html +0 -81
  36. package/docs/index.js.html +0 -92
  37. package/docs/layer.js.html +0 -888
  38. package/docs/module-effect-GaussianBlurComponent.html +0 -345
  39. package/docs/module-effect.Brightness.html +0 -339
  40. package/docs/module-effect.Channels.html +0 -319
  41. package/docs/module-effect.ChromaKey.html +0 -611
  42. package/docs/module-effect.Contrast.html +0 -339
  43. package/docs/module-effect.EllipticalMask.html +0 -200
  44. package/docs/module-effect.GaussianBlur.html +0 -202
  45. package/docs/module-effect.GaussianBlurHorizontal.html +0 -242
  46. package/docs/module-effect.GaussianBlurVertical.html +0 -242
  47. package/docs/module-effect.Pixelate.html +0 -330
  48. package/docs/module-effect.Shader.html +0 -1227
  49. package/docs/module-effect.Stack.html +0 -406
  50. package/docs/module-effect.Transform.Matrix.html +0 -193
  51. package/docs/module-effect.Transform.html +0 -1174
  52. package/docs/module-effect.html +0 -148
  53. package/docs/module-event.html +0 -473
  54. package/docs/module-index.html +0 -186
  55. package/docs/module-layer-Media.html +0 -1116
  56. package/docs/module-layer-MediaMixin.html +0 -164
  57. package/docs/module-layer.Audio.html +0 -1188
  58. package/docs/module-layer.Base.html +0 -629
  59. package/docs/module-layer.Image.html +0 -1421
  60. package/docs/module-layer.Text.html +0 -1731
  61. package/docs/module-layer.Video.html +0 -1938
  62. package/docs/module-layer.Visual.html +0 -1698
  63. package/docs/module-layer.html +0 -137
  64. package/docs/module-movie.html +0 -3118
  65. package/docs/module-util.Color.html +0 -702
  66. package/docs/module-util.Font.html +0 -395
  67. package/docs/module-util.html +0 -845
  68. package/docs/movie.js.html +0 -689
  69. package/docs/scripts/collapse.js +0 -20
  70. package/docs/scripts/linenumber.js +0 -25
  71. package/docs/scripts/nav.js +0 -12
  72. package/docs/scripts/polyfill.js +0 -4
  73. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  74. package/docs/scripts/prettify/lang-css.js +0 -2
  75. package/docs/scripts/prettify/prettify.js +0 -28
  76. package/docs/scripts/search.js +0 -83
  77. package/docs/styles/jsdoc.css +0 -671
  78. package/docs/styles/prettify.css +0 -79
  79. package/docs/util.js.html +0 -503
  80. package/spec/assets/effect/gaussian-blur-horizontal.png +0 -0
  81. package/spec/assets/effect/gaussian-blur-vertical.png +0 -0
  82. package/spec/assets/effect/grayscale.png +0 -0
  83. package/spec/assets/effect/original.png +0 -0
  84. package/spec/assets/effect/pixelate.png +0 -0
  85. package/spec/assets/effect/transform/multiply.png +0 -0
  86. package/spec/assets/effect/transform/rotate.png +0 -0
  87. package/spec/assets/effect/transform/scale-fraction.png +0 -0
  88. package/spec/assets/effect/transform/scale.png +0 -0
  89. package/spec/assets/effect/transform/translate-fraction.png +0 -0
  90. package/spec/assets/effect/transform/translate.png +0 -0
  91. package/spec/assets/layer/audio.wav +0 -0
  92. package/spec/assets/layer/image.jpg +0 -0
  93. package/spec/effect.spec.js +0 -421
  94. package/spec/event.spec.js +0 -39
  95. package/spec/layer.spec.js +0 -307
  96. package/spec/movie.spec.js +0 -346
  97. 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
- })