etro 0.6.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 (103) hide show
  1. package/.env +2 -0
  2. package/.github/workflows/nodejs.yml +27 -0
  3. package/CHANGELOG.md +109 -0
  4. package/CODE_OF_CONDUCT.md +77 -0
  5. package/CONTRIBUTING.md +155 -0
  6. package/LICENSE +674 -0
  7. package/README.md +57 -0
  8. package/dist/etro.js +3397 -0
  9. package/docs/effect.js.html +1215 -0
  10. package/docs/event.js.html +145 -0
  11. package/docs/index.html +81 -0
  12. package/docs/index.js.html +92 -0
  13. package/docs/layer.js.html +888 -0
  14. package/docs/module-effect-GaussianBlurComponent.html +345 -0
  15. package/docs/module-effect.Brightness.html +339 -0
  16. package/docs/module-effect.Channels.html +319 -0
  17. package/docs/module-effect.ChromaKey.html +611 -0
  18. package/docs/module-effect.Contrast.html +339 -0
  19. package/docs/module-effect.EllipticalMask.html +200 -0
  20. package/docs/module-effect.GaussianBlur.html +202 -0
  21. package/docs/module-effect.GaussianBlurHorizontal.html +242 -0
  22. package/docs/module-effect.GaussianBlurVertical.html +242 -0
  23. package/docs/module-effect.Pixelate.html +330 -0
  24. package/docs/module-effect.Shader.html +1227 -0
  25. package/docs/module-effect.Stack.html +406 -0
  26. package/docs/module-effect.Transform.Matrix.html +193 -0
  27. package/docs/module-effect.Transform.html +1174 -0
  28. package/docs/module-effect.html +148 -0
  29. package/docs/module-event.html +473 -0
  30. package/docs/module-index.html +186 -0
  31. package/docs/module-layer-Media.html +1116 -0
  32. package/docs/module-layer-MediaMixin.html +164 -0
  33. package/docs/module-layer.Audio.html +1188 -0
  34. package/docs/module-layer.Base.html +629 -0
  35. package/docs/module-layer.Image.html +1421 -0
  36. package/docs/module-layer.Text.html +1731 -0
  37. package/docs/module-layer.Video.html +1938 -0
  38. package/docs/module-layer.Visual.html +1698 -0
  39. package/docs/module-layer.html +137 -0
  40. package/docs/module-movie.html +3118 -0
  41. package/docs/module-util.Color.html +702 -0
  42. package/docs/module-util.Font.html +395 -0
  43. package/docs/module-util.html +845 -0
  44. package/docs/movie.js.html +689 -0
  45. package/docs/scripts/collapse.js +20 -0
  46. package/docs/scripts/linenumber.js +25 -0
  47. package/docs/scripts/nav.js +12 -0
  48. package/docs/scripts/polyfill.js +4 -0
  49. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  50. package/docs/scripts/prettify/lang-css.js +2 -0
  51. package/docs/scripts/prettify/prettify.js +28 -0
  52. package/docs/scripts/search.js +83 -0
  53. package/docs/styles/jsdoc.css +671 -0
  54. package/docs/styles/prettify.css +79 -0
  55. package/docs/util.js.html +503 -0
  56. package/eslint.conf.js +28 -0
  57. package/eslint.test-conf.js +4 -0
  58. package/examples/application/readme-screenshot.html +86 -0
  59. package/examples/application/video-player.html +131 -0
  60. package/examples/application/webcam.html +28 -0
  61. package/examples/introduction/audio.html +52 -0
  62. package/examples/introduction/effects.html +56 -0
  63. package/examples/introduction/export.html +70 -0
  64. package/examples/introduction/functions.html +35 -0
  65. package/examples/introduction/hello-world1.html +33 -0
  66. package/examples/introduction/hello-world2.html +32 -0
  67. package/examples/introduction/keyframes.html +67 -0
  68. package/examples/introduction/media.html +55 -0
  69. package/examples/introduction/text.html +27 -0
  70. package/jsdoc.conf.json +3 -0
  71. package/karma.conf.js +60 -0
  72. package/package.json +63 -0
  73. package/private-todo.txt +70 -0
  74. package/rename-file.sh +18 -0
  75. package/rename-versions.sh +14 -0
  76. package/rename.sh +22 -0
  77. package/rollup.config.js +31 -0
  78. package/screenshots/2019-08-17_0.png +0 -0
  79. package/scripts/gen-effect-samples.html +99 -0
  80. package/scripts/save-effect-samples.js +43 -0
  81. package/spec/assets/effect/gaussian-blur-horizontal.png +0 -0
  82. package/spec/assets/effect/gaussian-blur-vertical.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 +352 -0
  94. package/spec/event.spec.js +25 -0
  95. package/spec/layer.spec.js +128 -0
  96. package/spec/movie.spec.js +154 -0
  97. package/spec/util.spec.js +285 -0
  98. package/src/effect.js +1265 -0
  99. package/src/event.js +78 -0
  100. package/src/index.js +23 -0
  101. package/src/layer.js +875 -0
  102. package/src/movie.js +636 -0
  103. package/src/util.js +487 -0
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "etro",
3
+ "version": "0.6.0",
4
+ "description": "A flexible video-editing library for the browser",
5
+ "browser": "src/index.js",
6
+ "directories": {
7
+ "doc": "docs",
8
+ "example": "examples",
9
+ "test": "spec"
10
+ },
11
+ "dependencies": {},
12
+ "devDependencies": {
13
+ "docdash": "^1.1.1",
14
+ "eslint": "^6.5.1",
15
+ "eslint-config-standard": "^14.1.0",
16
+ "eslint-plugin-html": "^6.0.0",
17
+ "eslint-plugin-import": "^2.18.2",
18
+ "eslint-plugin-node": "^10.0.0",
19
+ "eslint-plugin-promise": "^4.2.1",
20
+ "eslint-plugin-standard": "^4.0.1",
21
+ "ev": "0.0.7",
22
+ "http-server": "^0.11.1",
23
+ "jasmine": "^3.4.0",
24
+ "jsdoc": "^3.6.3",
25
+ "jsdoc-export-default-interop": "^0.3.1",
26
+ "karma": "^4.3.0",
27
+ "karma-chrome-launcher": "^3.1.0",
28
+ "karma-jasmine": "^2.0.1",
29
+ "puppeteer": "^2.0.0",
30
+ "rollup": "^1.19.4",
31
+ "rollup-plugin-eslint": "^7.0.0",
32
+ "rollup-plugin-node-resolve": "^5.2.0",
33
+ "rollup-plugin-uglify-es": "^0.0.1"
34
+ },
35
+ "scripts": {
36
+ "build": "rollup -c",
37
+ "doc": "rm -rf docs && npx jsdoc -r src -d docs -t node_modules/docdash",
38
+ "effects": "node scripts/save-effect-samples.js",
39
+ "fix:main": "eslint -c eslint.conf.js --fix --ext .js,.html src examples",
40
+ "fix:test": "eslint -c eslint.test-conf.js --fix spec",
41
+ "lint": "npm run --silent lint:main && npm run --silent lint:test",
42
+ "lint:main": "eslint -c eslint.conf.js --ext .js,.html src examples",
43
+ "lint:test": "eslint -c eslint.test-conf.js spec",
44
+ "start": "http-server",
45
+ "test": "karma start"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/etro-js/etro.git"
50
+ },
51
+ "keywords": [
52
+ "video-editing",
53
+ "video-editor",
54
+ "browser",
55
+ "api-driven"
56
+ ],
57
+ "author": "Caleb Sacks (https://calebsacks.me)",
58
+ "license": "GPL-3.0",
59
+ "bugs": {
60
+ "url": "https://github.com/etro-js/etro/issues"
61
+ },
62
+ "homepage": "https://github.com/etro-js/etro#readme"
63
+ }
@@ -0,0 +1,70 @@
1
+ (A) 2021-04-21 offline recording with ffmpeg.wasm
2
+ (A) 2021-04-21 document events
3
+ (A) 2021-05-17 test recording to mp4
4
+ (A) 2021-05-17 test that keyframes extend last frame for infinity!!
5
+ (B) 2020-08-03 make sure each event's purpose is to notify the public world of notable things that happen in the object.
6
+ (B) 2020-08-27 transitions?
7
+ (B) 2020-12-30 emit modify events when effects are added to layer?
8
+ (B) 2020-12-30 ensure order of `set` and `deleteProperty` are correct in array proxy with `pop`
9
+ (B) 2021-04-12 disable autoRefresh in tests and test integration with this switch some other way
10
+ (C) 2019-10-13 idea: layer inheritance
11
+ (C) 2019-10-13 ignore leading underscore in shader uniform property names
12
+ (C) 2019-10-13 fix opacity with shader effects
13
+ (C) 2020-08-08 Replace val(element, 'property', reltime) with element.property.value
14
+ (C) 2020-08-12 call URL.revokeObjectURL when recording
15
+ (C) 2020-12-30 simplify movie.change.* into movie.change
16
+ (C) 2021-03-28 make all color properties use `Color`
17
+ (C) 2021-04-02 abort recording
18
+ (C) 2021-04-21 webcam example doesn't work on FF unless autoRefresh is set to false
19
+ (C) 2021-07-13 make all layers canvases the same size as the movie
20
+ (C) 2021-07-18 movie stops recording a few frames late when duration is supplied
21
+ (D) 2019-10-15 change chroma key constructor signature
22
+ (D) 2019-11-11 treat zero as invalid for pixelate radius
23
+ (D) 2019-11-11 decide on effect.Transform using hardware acceleration
24
+ (D) 2019-11-18 Look at linearInterp objectKeys default value
25
+ (D) 2019-12-25 Rename `Stack` to something else
26
+ (D) 2020-08-02 Not every option should be set as a property on the object
27
+ (D) 2021-01-24 Remove path support in val (because users would expect it to evaluate every path part)
28
+ (D) 2021-01-26 Fix inheritance checking for media mixin
29
+ (D) 2021-01-26 Media docstring type
30
+ (D) 2021-01-26 Call super in all media mixin methods
31
+ (D) 2021-01-27 Use options.js
32
+ (D) 2021-04-02 error on invalid `record` options
33
+ (D) 2021-04-12 use val() when recalculating AudioSource#duration based on playbackRate
34
+ (D) 2021-07-09 multiple layers of proxies in watched objects
35
+
36
+ x (B) 2021-04-12 make error range for pixel tests
37
+ x (C) 2021-02-26 make sure that movie background gets val'd
38
+ x (B) 2021-04-03 expose MovieOptions
39
+ x (D) 2019-10-09 probably convert to typescript
40
+ x (C) 2019-10-22 make image and video both extend a mixin
41
+ x (C) 2021-04-03 2019-01-07 record for interval of time
42
+ x (B) 2021-04-03 2021-04-03 add missing properties to MixedVisualSource
43
+ x (D) 2021-04-03 2021-04-03 move opacity out of `border` in Visual
44
+ x (B) 2021-01-28 2020-12-18 split layers up into multiple files
45
+ x (B) 2021-01-28 2020-12-18 split effects up into multiple files
46
+ x (B) 2020-08-27 individual interpolation for keyframe sets
47
+ x (B) 2019-12-24 support node
48
+ x (B) 2020-12-31 2020-12-30 Detach effect when replaced in layer
49
+ x (D) 2020-12-18 2020-08-02 Rename `cctx` -> `vctx`
50
+ x (B) 2019-01-02 fix movie record test failing with GitHub actions
51
+ x (B) 2020-08-03 2020-08-03 don't set Image#clipWidth in init
52
+ x (B) 2020-08-03 2020-08-03 remove properties like Video#mediaWidth, effectively removing layer borders
53
+ x (B) 2020-08-03 2019-10-04 decide on the purpose of events - it's to notify the outside world of notable things that happen in the object
54
+ x (B) 2019-12-25 decide on public / private properties
55
+ x (C) 2019-12-25 2019-12-24 make getDefaultOptions private
56
+ x (D) 2019-11-18 Change Color constructor default a from 255 -> 1.0
57
+ x (A) 2019-12-06 2019-11-11 Start roadmap
58
+ x (A) 2019-11-19 2019-10-22 Util tests
59
+ x (A) 2019-10-22 Effect tests
60
+ x (D) 2019-11-18 2019-11-18 update watchPublic description, removing part that says "after all public properties are initialized in constructor"
61
+ x (B) 2019-10-13 mv examples/media examples/assets
62
+ x (A) 2019-10-22 2019-10-22 Layer tests
63
+ x (B) 2019-10-12 support media live streams
64
+ x (C) 2019-10-03 research if dist/etris-esm.js is necessary
65
+ x (A) 2019-10-04 upload to npm
66
+ x (C) 2019-10-07 lint examples
67
+ x (B) 2019-10-04 fix jsdoc comments after linting
68
+ x (A) 2019-10-07 2019-10-07 fix recording silent movie on chrome
69
+ x (A) 2019-10-05 2019-10-03 research if I can include open media in my repo
70
+ x 2019-10-04 2019-10-03 use one of eslint's official configs
package/rename-file.sh ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/bash
2
+
3
+ set -e
4
+
5
+ file=$1
6
+
7
+ # Update file contents
8
+ sed -i 's/clabe45.github.io\/vidar/etrojs.dev/g' $file
9
+ sed -i 's/calebsacks.me\/vidar/etrojs.dev/g' $file
10
+ sed -i 's/vidar/etro/g' $file
11
+ sed -i 's/Vidar/Etro/g' $file
12
+ sed -i 's/vd/etro/g' $file
13
+ sed -i 's/clabe45/etro-js/g' $file
14
+
15
+ # Update file name
16
+ rename 's/vidar/etro/' $file
17
+
18
+ echo "Updated $file"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/bash
2
+
3
+ set -e
4
+
5
+ for version in "$@"
6
+ do
7
+ git checkout v$version
8
+
9
+ $(dirname "$0")/rename.sh
10
+
11
+ git tag v$version-renamed
12
+
13
+ echo ""
14
+ done
package/rename.sh ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/bash
2
+
3
+ set -e
4
+
5
+ find -type f -not -name 'rename*.sh' -not -path '*./package-lock.json' -not -path '*./.git/*' -not -path '*./node_modules/*' -exec $(dirname "$0")/rename-file.sh {} \;
6
+ jq '.author = "Caleb Sacks (https://calebsacks.me)"' package.json > package.json.tmp
7
+ mv package.json{.tmp,}
8
+
9
+ set +e
10
+
11
+ npm i && npm run lint --if-present && npm run build --if-present && npm run test --if-present
12
+
13
+ if [[ $? -ne 0 ]]
14
+ then
15
+ read -p "CI workflow failed. Press [Enter] to continue or Ctrl-C to exit" _
16
+ fi
17
+
18
+ set -e
19
+
20
+ git add .
21
+ git rm --cached rename*.sh
22
+ force_commit=true git commit -m "Rename project to 'etro'"
@@ -0,0 +1,31 @@
1
+ // import uglify from "rollup-plugin-uglify-es";
2
+ import resolve from 'rollup-plugin-node-resolve'
3
+
4
+ export default [
5
+ // iife bundle
6
+ {
7
+ input: 'src/index.js',
8
+ output: { file: 'dist/etro.js', format: 'iife', name: 'etro' },
9
+ plugins: [resolve()]
10
+ }
11
+ // // es6 module bundle
12
+ // {
13
+ // input: "src/index.js",
14
+ // output: { file: "dist/etro-esm.js", format: "esm", name: "etro" }
15
+ // },
16
+
17
+ /* ERRORS FOR SOME REASON
18
+ // iife bundle (minified)
19
+ {
20
+ input: 'src/index.js',
21
+ output: { file: 'dist/etro-iife.min.js', format: 'iife', name: 'mv' },
22
+ plugins: [ uglify() ]
23
+ },
24
+ // es6 module bundle (minified)
25
+ {
26
+ input: 'src/index.js',
27
+ output: { file: 'dist/etro-esm.min.js', format: 'esm', name: 'mv' },
28
+ plugins: [ uglify() ]
29
+ }
30
+ */
31
+ ]
Binary file
@@ -0,0 +1,99 @@
1
+ <!-- Used by ./save-effect-samples.js (npm run effects) -->
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <body>
5
+ <script src="../dist/etro.js"></script>
6
+ <script>
7
+ /**
8
+ * Prepares a canvas for saving
9
+ */
10
+ function save(canvas, path) {
11
+ const p = document.createElement('p')
12
+ p.dataset.path = path
13
+ p.innerHTML = canvas.toDataURL()
14
+ document.body.appendChild(p)
15
+ }
16
+
17
+ /**
18
+ * Create a square canvas with random opaque noise
19
+ * @param {number} size the width and height
20
+ * @return {TestCanvas}
21
+ *
22
+ * @typedef {Object} TestCanvas
23
+ * @property {CanvasRenderingContext2D} ctx
24
+ * @property {ImageData} imageData
25
+ */
26
+ function genRandomNoise (width, height) {
27
+ const canvas = document.createElement('canvas')
28
+ canvas.width = width
29
+ canvas.height = height
30
+ const ctx = canvas.getContext('2d')
31
+ // Create a grid of random colors
32
+ const imageData = ctx.createImageData(canvas.width, canvas.height)
33
+ // opaque so premultiplied alpha won't mess up the rgb comparisons
34
+ const data = imageData.data.map((_, i) => i % 4 === 3 ? 255 : Math.floor(256 * Math.random()))
35
+ for (let i = 0; i < data.length; i++) {
36
+ imageData.data[i] = data[i]
37
+ }
38
+ ctx.putImageData(imageData, 0, 0)
39
+
40
+ return canvas
41
+ }
42
+
43
+ /**
44
+ * Save an effect sample to the disk
45
+ */
46
+ function saveSample(original, effect, path) {
47
+ // don't overwrite original's contents
48
+ const buffer = document.createElement('canvas')
49
+ buffer.width = original.width
50
+ buffer.height = original.height
51
+ const ctx = buffer.getContext('2d')
52
+ ctx.drawImage(original, 0, 0)
53
+
54
+ // do effect
55
+ effect.apply({
56
+ canvas: buffer, cctx: ctx,
57
+ width: original.width, height: original.height
58
+ })
59
+
60
+ save(buffer, path)
61
+ }
62
+
63
+ window.onload = () => {
64
+ const original = genRandomNoise(16, 16)
65
+ save(original, 'original.png')
66
+
67
+ const samples = {
68
+ 'gaussian-blur-horizontal.png': new etro.effect.GaussianBlurHorizontal(5),
69
+ 'gaussian-blur-vertical.png': new etro.effect.GaussianBlurVertical(5),
70
+ 'pixelate.png': new etro.effect.Pixelate(3),
71
+ 'transform/translate.png': new etro.effect.Transform(
72
+ new etro.effect.Transform.Matrix().translate(-3, 5)
73
+ ),
74
+ 'transform/translate-fraction.png': new etro.effect.Transform(
75
+ new etro.effect.Transform.Matrix().translate(0.5, 0.5)
76
+ ),
77
+ 'transform/scale.png': new etro.effect.Transform(
78
+ new etro.effect.Transform.Matrix().scale(2, 2)
79
+ ),
80
+ 'transform/scale-fraction.png': new etro.effect.Transform(
81
+ new etro.effect.Transform.Matrix().scale(0.5, 0.5)
82
+ ),
83
+ 'transform/rotate.png': new etro.effect.Transform(
84
+ new etro.effect.Transform.Matrix().rotate(Math.PI / 6)
85
+ ),
86
+ 'transform/multiply.png': new etro.effect.Transform(
87
+ new etro.effect.Transform.Matrix().scale(2, 2)
88
+ .multiply(new etro.effect.Transform.Matrix().translate(-3, 5))
89
+ )
90
+ }
91
+
92
+ for (let path in samples) {
93
+ const effect = samples[path]
94
+ saveSample(original, effect, path)
95
+ }
96
+ }
97
+ </script>
98
+ </body>
99
+ </html>
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @module
3
+ * <em>Run this script and review the results whenever you add a unit test or make an effect algorithm change.</em>
4
+ */
5
+
6
+ const path = require('path')
7
+ const fs = require('fs')
8
+ const puppeteer = require('puppeteer')
9
+
10
+ // parent directory
11
+ const projectDir = __dirname.split('/').slice(0, -1).join('/')
12
+
13
+ function createDirs(filePath) {
14
+ const dirname = path.dirname(filePath)
15
+ if (fs.existsSync(dirname)) {
16
+ return
17
+ }
18
+ createDirs(dirname)
19
+ fs.mkdirSync(dirname)
20
+ }
21
+
22
+ (async () => {
23
+ const browser = await puppeteer.launch()
24
+ const page = await browser.newPage()
25
+
26
+ page.on('load', async () => {
27
+ // console.log(await page.$$('p'));
28
+ const items = await page.$$eval('p', elems => elems.map(p => {
29
+ return { data: p.innerHTML, path: p.dataset.path }
30
+ }))
31
+
32
+ items.forEach(item => {
33
+ // remove prefix and save to png
34
+ const buffer = Buffer.from(item.data.replace(/^data:image\/png;base64,/, ''), 'base64')
35
+ console.log(`writing ${item.path} ...`)
36
+ const path = projectDir + '/spec/assets/effect/' + item.path
37
+ createDirs(path)
38
+ fs.writeFileSync(path, buffer)
39
+ })
40
+ await browser.close()
41
+ })
42
+ await page.goto(`file://${__dirname}/gen-effect-samples.html`)
43
+ })()
Binary file
Binary file
Binary file
Binary file