From 993dbc81228d0cb0a3a97d668db0023f42c7b64d Mon Sep 17 00:00:00 2001 From: Unsigno Date: Tue, 20 Nov 2018 16:03:21 +0100 Subject: [PATCH 1/8] Joined all the object definitions in a single context (webm-writer) --- src/webm-writer-0.2.0.js | 53 +++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/webm-writer-0.2.0.js b/src/webm-writer-0.2.0.js index dbe2a25..c58abb5 100644 --- a/src/webm-writer-0.2.0.js +++ b/src/webm-writer-0.2.0.js @@ -206,20 +206,19 @@ } else { window.ArrayBufferDataStream = ArrayBufferDataStream; } -}());"use strict"; -/** - * Allows a series of Blob-convertible objects (ArrayBuffer, Blob, String, etc) to be added to a buffer. Seeking and - * overwriting of blobs is allowed. - * - * You can supply a FileWriter, in which case the BlobBuffer is just used as temporary storage before it writes it - * through to the disk. - * - * By Nicholas Sherlock - * - * Released under the WTFPLv2 https://en.wikipedia.org/wiki/WTFPL - */ -(function() { + /** + * Allows a series of Blob-convertible objects (ArrayBuffer, Blob, String, etc) to be added to a buffer. Seeking and + * overwriting of blobs is allowed. + * + * You can supply a FileWriter, in which case the BlobBuffer is just used as temporary storage before it writes it + * through to the disk. + * + * By Nicholas Sherlock + * + * Released under the WTFPLv2 https://en.wikipedia.org/wiki/WTFPL + */ + var BlobBuffer = function(fs) { return function(destination) { var @@ -432,23 +431,21 @@ } else { window.BlobBuffer = BlobBuffer(null); } -})();/** - * WebM video encoder for Google Chrome. This implementation is suitable for creating very large video files, because - * it can stream Blobs directly to a FileWriter without buffering the entire video in memory. - * - * When FileWriter is not available or not desired, it can buffer the video in memory as a series of Blobs which are - * eventually returned as one composite Blob. - * - * By Nicholas Sherlock. - * - * Based on the ideas from Whammy: https://github.com/antimatter15/whammy - * - * Released under the WTFPLv2 https://en.wikipedia.org/wiki/WTFPL - */ -"use strict"; + /** + * WebM video encoder for Google Chrome. This implementation is suitable for creating very large video files, because + * it can stream Blobs directly to a FileWriter without buffering the entire video in memory. + * + * When FileWriter is not available or not desired, it can buffer the video in memory as a series of Blobs which are + * eventually returned as one composite Blob. + * + * By Nicholas Sherlock. + * + * Based on the ideas from Whammy: https://github.com/antimatter15/whammy + * + * Released under the WTFPLv2 https://en.wikipedia.org/wiki/WTFPL + */ -(function() { var WebMWriter = function(ArrayBufferDataStream, BlobBuffer) { function extend(base, top) { var From 719f4a75db1af7c67a6c6c43e38ba67104ccf1ae Mon Sep 17 00:00:00 2001 From: Unsigno Date: Tue, 20 Nov 2018 16:08:34 +0100 Subject: [PATCH 2/8] Replaced require's, since the objects are in the same context in this package --- src/webm-writer-0.2.0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webm-writer-0.2.0.js b/src/webm-writer-0.2.0.js index c58abb5..29bc24c 100644 --- a/src/webm-writer-0.2.0.js +++ b/src/webm-writer-0.2.0.js @@ -1087,7 +1087,7 @@ }; if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - module.exports = WebMWriter(require("./ArrayBufferDataStream"), require("./BlobBuffer")); + module.exports = WebMWriter(ArrayBufferDataStream, BlobBuffer); } else { window.WebMWriter = WebMWriter(ArrayBufferDataStream, BlobBuffer); } From 4944bbff04c09ac9d99a8b3c145a95654481602c Mon Sep 17 00:00:00 2001 From: Unsigno Date: Tue, 20 Nov 2018 16:15:15 +0100 Subject: [PATCH 3/8] Exporting Tar module for Node --- src/tar.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tar.js b/src/tar.js index 650742e..2e84056 100644 --- a/src/tar.js +++ b/src/tar.js @@ -330,5 +330,9 @@ struct posix_header { // byte offset this.out = utils.clean(blockSize); }; - window.Tar = Tar; + if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { + module.exports = Tar; + } else { + window.Tar = Tar; + } }()); From 2f1823f7e062bee4fbc20250526b0556aefb1a68 Mon Sep 17 00:00:00 2001 From: Unsigno Date: Tue, 20 Nov 2018 16:20:00 +0100 Subject: [PATCH 4/8] Updated download.js --- src/download.js | 290 +++++++++++++++++++++++++++--------------------- 1 file changed, 165 insertions(+), 125 deletions(-) diff --git a/src/download.js b/src/download.js index 85a7282..2a2928d 100644 --- a/src/download.js +++ b/src/download.js @@ -1,132 +1,172 @@ -//download.js v3.0, by dandavis; 2008-2014. [CCBY2] see http://danml.com/download.html for tests/usage -// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime +//download.js v4.21, by dandavis; 2008-2018. [MIT] see http://danml.com/download.html for tests/usage +// v1 landed a FF+Chrome compatible way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs -// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support - -// data can be a string, Blob, File, or dataURL - - - - -function download(data, strFileName, strMimeType) { - - var self = window, // this script is only for browsers anyway... - u = "application/octet-stream", // this default mime also triggers iframe downloads - m = strMimeType || u, - x = data, - D = document, - a = D.createElement("a"), - z = function(a){return String(a);}, - - - B = self.Blob || self.MozBlob || self.WebKitBlob || z, - BB = self.MSBlobBuilder || self.WebKitBlobBuilder || self.BlobBuilder, - fn = strFileName || "download", - blob, - b, - ua, - fr; - - //if(typeof B.bind === 'function' ){ B=B.bind(self); } - - if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback - x=[x, m]; - m=x[0]; - x=x[1]; +// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling. +// v4 adds AMD/UMD, commonJS, and plain browser support +// v4.1 adds url download capability via solo URL argument (same domain/CORS only) +// v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors +// https://github.com/rndme/download + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.download = factory(); } - - - - //go ahead and download dataURLs right away - if(String(x).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/)){ - return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs: - navigator.msSaveBlob(d2b(x), fn) : - saver(x) ; // everyone else can save dataURLs un-processed - }//end if dataURL passed? - - try{ - - blob = x instanceof B ? - x : - new B([x], {type: m}) ; - }catch(y){ - if(BB){ - b = new BB(); - b.append([x]); - blob = b.getBlob(m); // the blob +}(this, function () { + + return function download(data, strFileName, strMimeType) { + + var self = window, // this script is only for browsers anyway... + defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads + mimeType = strMimeType || defaultMime, + payload = data, + url = !strFileName && !strMimeType && payload, + anchor = document.createElement("a"), + toString = function(a){return String(a);}, + myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString), + fileName = strFileName || "download", + blob, + reader; + myBlob= myBlob.call ? myBlob.bind(self) : Blob ; + + if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback + payload=[payload, mimeType]; + mimeType=payload[0]; + payload=payload[1]; } - - } - - - - function d2b(u) { - var p= u.split(/[:;,]/), - t= p[1], - dec= p[2] == "base64" ? atob : decodeURIComponent, - bin= dec(p.pop()), - mx= bin.length, - i= 0, - uia= new Uint8Array(mx); - - for(i;i (1024*1024*1.999) && myBlob !== toString ){ + payload=dataUrlToBlob(payload); + mimeType=payload.type || defaultMime; + }else{ + return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs: + navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : + saver(payload) ; // everyone else can save dataURLs un-processed + } + + }else{//not data url, is it a string with special needs? + if(/([\x80-\xff])/.test(payload)){ + var i=0, tempUiArr= new Uint8Array(payload.length), mx=tempUiArr.length; + for(i;i0 ? 3: 2, + decoder= parts[indexDecoder] == "base64" ? atob : decodeURIComponent, + binData= decoder( parts.pop() ), + mx= binData.length, + i= 0, + uiArr= new Uint8Array(mx); + + for(i;i Date: Tue, 20 Nov 2018 17:20:25 +0100 Subject: [PATCH 5/8] Require external modules for Node on CCapture, if not check window var --- src/CCapture.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/CCapture.js b/src/CCapture.js index 703972d..336de0e 100755 --- a/src/CCapture.js +++ b/src/CCapture.js @@ -2,6 +2,13 @@ "use strict"; +var isNodeEnviroment = typeof module !== 'undefined' && typeof module.exports !== 'undefined'; + +var Tar = isNodeEnviroment ? require('./tar') : window.Tar; +var download = isNodeEnviroment ? require('./download') : window.download; +var GIF = isNodeEnviroment ? require('./gif').GIF : window.GIF; +var WebMWriter = isNodeEnviroment ? require('./webm-writer-0.2.0') : window.WebMWriter; + var objectTypes = { 'function': true, 'object': true From 48ec494e439a4352be6057d56c844c55eaf3d7c0 Mon Sep 17 00:00:00 2001 From: Unsigno Date: Tue, 20 Nov 2018 18:35:03 +0100 Subject: [PATCH 6/8] Fixed webm-writer to work in a single file and return a single module --- src/webm-writer-0.2.0.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/webm-writer-0.2.0.js b/src/webm-writer-0.2.0.js index 29bc24c..c2f30f7 100644 --- a/src/webm-writer-0.2.0.js +++ b/src/webm-writer-0.2.0.js @@ -9,10 +9,14 @@ "use strict"; (function(){ - /* + + var isNodeEnviroment = typeof module !== 'undefined' && typeof module.exports !== 'undefined'; + + /** * Create an ArrayBuffer of the given length and present it as a writable stream with methods * for writing data in different formats. */ + var ArrayBufferDataStream = function(length) { this.data = new Uint8Array(length); this.pos = 0; @@ -200,12 +204,8 @@ throw "ArrayBufferDataStream's pos lies beyond end of buffer"; } }; - - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - module.exports = ArrayBufferDataStream; - } else { - window.ArrayBufferDataStream = ArrayBufferDataStream; - } + + window.ArrayBufferDataStream = ArrayBufferDataStream; /** * Allows a series of Blob-convertible objects (ArrayBuffer, Blob, String, etc) to be added to a buffer. Seeking and @@ -424,13 +424,9 @@ return writePromise; }; }; - }; + }(isNodeEnviroment ? require('fs') : null); - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - module.exports = BlobBuffer(require('fs')); - } else { - window.BlobBuffer = BlobBuffer(null); - } + window.BlobBuffer = BlobBuffer; /** * WebM video encoder for Google Chrome. This implementation is suitable for creating very large video files, because @@ -1086,7 +1082,7 @@ }; }; - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { + if (isNodeEnviroment) { module.exports = WebMWriter(ArrayBufferDataStream, BlobBuffer); } else { window.WebMWriter = WebMWriter(ArrayBufferDataStream, BlobBuffer); From 314d302a8b5e613514ecb0311b48ef764c8c1015 Mon Sep 17 00:00:00 2001 From: Unsigno Date: Fri, 30 Nov 2018 04:32:20 +0100 Subject: [PATCH 7/8] Build minified files --- build/CCapture.all.min.js | 3 +-- build/CCapture.min.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build/CCapture.all.min.js b/build/CCapture.all.min.js index bda376d..3903df9 100644 --- a/build/CCapture.all.min.js +++ b/build/CCapture.all.min.js @@ -1,2 +1 @@ -"use strict";function download(t,e,i){function n(t){var e=t.split(/[:;,]/),i=e[1],n="base64"==e[2]?atob:decodeURIComponent,r=n(e.pop()),o=r.length,a=0,s=new Uint8Array(o);for(a;a>8,this.data[this.pos++]=t},t.prototype.writeDoubleBE=function(t){for(var e=new Uint8Array(new Float64Array([t]).buffer),i=e.length-1;i>=0;i--)this.writeByte(e[i])},t.prototype.writeFloatBE=function(t){for(var e=new Uint8Array(new Float32Array([t]).buffer),i=e.length-1;i>=0;i--)this.writeByte(e[i])},t.prototype.writeString=function(t){for(var e=0;e>8),this.writeU8(t);break;case 3:this.writeU8(32|t>>16),this.writeU8(t>>8),this.writeU8(t);break;case 4:this.writeU8(16|t>>24),this.writeU8(t>>16),this.writeU8(t>>8),this.writeU8(t);break;case 5:this.writeU8(8|t/4294967296&7),this.writeU8(t>>24),this.writeU8(t>>16),this.writeU8(t>>8),this.writeU8(t);break;default:throw new RuntimeException("Bad EBML VINT size "+e)}},t.prototype.measureEBMLVarInt=function(t){if(t<127)return 1;if(t<16383)return 2;if(t<2097151)return 3;if(t<268435455)return 4;if(t<34359738367)return 5;throw new RuntimeException("EBML VINT size not supported "+t)},t.prototype.writeEBMLVarInt=function(t){this.writeEBMLVarIntWidth(t,this.measureEBMLVarInt(t))},t.prototype.writeUnsignedIntBE=function(t,e){switch(void 0===e&&(e=this.measureUnsignedInt(t)),e){case 5:this.writeU8(Math.floor(t/4294967296));case 4:this.writeU8(t>>24);case 3:this.writeU8(t>>16);case 2:this.writeU8(t>>8);case 1:this.writeU8(t);break;default:throw new RuntimeException("Bad UINT size "+e)}},t.prototype.measureUnsignedInt=function(t){return t<256?1:t<65536?2:t<1<<24?3:t<4294967296?4:5},t.prototype.getAsDataArray=function(){if(this.posthis.length)throw"Seeking beyond the end of file is not allowed";this.pos=t},this.write=function(e){var i={offset:this.pos,data:e,length:r(e)},f=i.offset>=this.length;this.pos+=i.length,this.length=Math.max(this.length,this.pos),a=a.then(function(){if(h)return new Promise(function(e,r){n(i.data).then(function(n){var r=0,o=Buffer.from(n.buffer),a=function(n,o,s){r+=o,r>=s.length?e():t.write(h,s,r,s.length-r,i.offset+r,a)};t.write(h,o,0,o.length,i.offset,a)})});if(s)return new Promise(function(t,e){s.onwriteend=t,s.seek(i.offset),s.write(new Blob([i.data]))});if(!f)for(var e=0;e=r.offset+r.length)){if(i.offsetr.offset+r.length)throw new Error("Overwrite crosses blob boundaries");return i.offset==r.offset&&i.length==r.length?void(r.data=i.data):n(r.data).then(function(t){return r.data=t,n(i.data)}).then(function(t){i.data=t,r.data.set(i.data,i.offset-r.offset)})}}o.push(i)})},this.complete=function(t){return a=h||s?a.then(function(){return null}):a.then(function(){for(var e=[],i=0;i0&&e.trackNumber<127))throw"TrackNumber must be > 0 and < 127";return i.writeEBMLVarInt(e.trackNumber),i.writeU16BE(e.timecode),i.writeByte(128),{id:163,data:[i.getAsDataArray(),e.frame]}}function l(t){return{id:524531317,data:[{id:231,data:Math.round(t.timecode)}]}}function c(t,e,i){_.push({id:187,data:[{id:179,data:e},{id:183,data:[{id:247,data:t},{id:241,data:a(i)}]}]})}function p(){var e={id:475249515,data:_},i=new t(16+32*_.length);h(i,S.pos,e),S.write(i.getAsDataArray()),D.Cues.positionEBML.data=a(e.offset)}function m(){if(0!=T.length){for(var e=0,i=0;i=E&&m()}function y(){var e=new t(x.size),i=S.pos;h(e,x.dataOffset,x.data),S.seek(x.dataOffset),S.write(e.getAsDataArray()),S.seek(i)}function v(){var e=new t(8),i=S.pos;e.writeDoubleBE(U),S.seek(M.dataOffset),S.write(e.getAsDataArray()),S.seek(i)}var b,k,B,x,E=5e3,A=1,L=!1,T=[],U=0,F=0,I={quality:.95,fileWriter:null,fd:null,frameDuration:null,frameRate:null},D={Cues:{id:new Uint8Array([28,83,187,107]),positionEBML:null},SegmentInfo:{id:new Uint8Array([21,73,169,102]),positionEBML:null},Tracks:{id:new Uint8Array([22,84,174,107]),positionEBML:null}},M={id:17545,data:new s(0)},_=[],S=new e(n.fileWriter||n.fd);this.addFrame=function(t){if(L){if(t.width!=b||t.height!=k)throw"Frame size differs from previous frames"}else b=t.width,k=t.height,u(),L=!0;var e=r(t,{quality:n.quality});if(!e)throw"Couldn't decode WebP frame, does the browser support WebP?";g({frame:o(e),duration:n.frameDuration})},this.complete=function(){return m(),p(),y(),v(),S.complete("video/webm")},this.getWrittenSize=function(){return S.length},n=i(I,n||{}),w()}};"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=t(require("./ArrayBufferDataStream"),require("./BlobBuffer")):window.WebMWriter=t(ArrayBufferDataStream,BlobBuffer)}(),function(){function t(t){var e,i=new Uint8Array(t);for(e=0;e>18&63]+o[t>>12&63]+o[t>>6&63]+o[63&t]}var i,n,r,a=t.length%3,s="";for(i=0,r=t.length-a;in&&(e.push({blocks:o,length:i}),o=[],i=0),o.push(t),i+=t.headerLength+t.inputLength}),e.push({blocks:o,length:i}),e.forEach(function(e){var i=new Uint8Array(e.length),n=0;e.blocks.forEach(function(t){i.set(t.header,n),n+=t.headerLength,i.set(t.input,n),n+=t.inputLength}),t.push(i)}),t.push(new Uint8Array(2*r)),new Blob(t,{type:"octet/stream"})},t.prototype.clear=function(){this.written=0,this.out=n.clean(e)},window.Tar=t}(),function(t){function e(t,i){if({}.hasOwnProperty.call(e.cache,t))return e.cache[t];var n=e.resolve(t);if(!n)throw new Error("Failed to resolve module "+t);var r={id:t,require:e,filename:t,exports:{},loaded:!1,parent:i,children:[]};i&&i.children.push(r);var o=t.slice(0,t.lastIndexOf("/")+1);return e.cache[t]=r.exports,n.call(r.exports,r,r.exports,o,t),r.loaded=!0,e.cache[t]=r.exports}e.modules={},e.cache={},e.resolve=function(t){return{}.hasOwnProperty.call(e.modules,t)?e.modules[t]:void 0},e.define=function(t,i){e.modules[t]=i};var i=function(e){return e="/",{title:"browser",version:"v0.10.26",browser:!0,env:{},argv:[],nextTick:t.setImmediate||function(t){setTimeout(t,0)},cwd:function(){return e},chdir:function(t){e=t}}}();e.define("/gif.coffee",function(t,i,n,r){function o(t,e){return{}.hasOwnProperty.call(t,e)}function a(t,e){for(var i=0,n=e.length;ithis.frames.length;0<=this.frames.length?++e:--e)t.push(e);return t}.apply(this,arguments),n=0,r=i.length;ne;0<=e?++i:--i)t.push(i);return t}.apply(this,arguments),n=0,r=i.length;nt;this.freeWorkers.length<=t?++i:--i)e.push(i);return e}.apply(this,arguments).forEach(function(t){return function(e){var i;return console.log("spawning worker "+e),i=new Worker(t.options.workerScript),i.onmessage=function(t){return function(e){return t.activeWorkers.splice(t.activeWorkers.indexOf(i),1),t.freeWorkers.push(i),t.frameFinished(e.data)}}(t),t.freeWorkers.push(i)}}(this)),t},e.prototype.frameFinished=function(t){return console.log("frame "+t.index+" finished - "+this.activeWorkers.length+" active"),this.finishedFrames++,this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[t.index]=t,a(null,this.imageParts)?this.renderNextFrame():this.finishRendering()},e.prototype.finishRendering=function(){var t,e,i,n,r,o,a;r=0;for(var s=0,h=this.imageParts.length;s=this.frames.length?void 0:(t=this.frames[this.nextFrame++],i=this.freeWorkers.shift(),e=this.getTask(t),console.log("starting frame "+(e.index+1)+" of "+this.frames.length),this.activeWorkers.push(i),i.postMessage(e))},e.prototype.getContextData=function(t){return t.getImageData(0,0,this.options.width,this.options.height).data},e.prototype.getImageData=function(t){var e;return null!=this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),e=this._canvas.getContext("2d"),e.setFill=this.options.background,e.fillRect(0,0,this.options.width,this.options.height),e.drawImage(t,0,0),this.getContextData(e)},e.prototype.getTask=function(t){var e,i;if(e=this.frames.indexOf(t),i={index:e,last:e===this.frames.length-1,delay:t.delay,transparent:t.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,repeat:this.options.repeat,canTransfer:"chrome"===h.name},null!=t.data)i.data=t.data;else if(null!=t.context)i.data=this.getContextData(t.context);else{if(null==t.image)throw new Error("Invalid frame");i.data=this.getImageData(t.image)}return i},e}(u),t.exports=l}),e.define("/browser.coffee",function(t,e,i,n){var r,o,a,s,h;s=navigator.userAgent.toLowerCase(),a=navigator.platform.toLowerCase(),h=s.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0],o="ie"===h[1]&&document.documentMode,r={name:"version"===h[1]?h[3]:h[1],version:o||parseFloat("opera"===h[1]&&h[4]?h[4]:h[2]),platform:{name:s.match(/ip(?:ad|od|hone)/)?"ios":(s.match(/(?:webos|android)/)||a.match(/mac|win|linux/)||["other"])[0]}},r[r.name]=!0,r[r.name+parseInt(r.version,10)]=!0,r.platform[r.platform.name]=!0,t.exports=r}),e.define("events",function(t,e,n,r){i.EventEmitter||(i.EventEmitter=function(){});var o=e.EventEmitter=i.EventEmitter,a="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},s=10;o.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},o.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||a(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"!=typeof e){if(a(e)){for(var i=Array.prototype.slice.call(arguments,1),n=e.slice(),r=0,o=n.length;r0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){var i=this;return i.on(t,function n(){i.removeListener(t,n),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var i=this._events[t];if(a(i)){var n=i.indexOf(e);if(n<0)return this;i.splice(n,1),0==i.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},o.prototype.removeAllListeners=function(t){return t&&this._events&&this._events[t]&&(this._events[t]=null),this},o.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),a(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}}),t.GIF=e("/gif.coffee")}.call(this,this),function(){function t(t){return t&&t.Object===Object?t:null}function e(t){return String("0000000"+t).slice(-7)}function i(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}function n(t){var e={};this.settings=t,this.on=function(t,i){e[t]=i},this.emit=function(t){var i=e[t];i&&i.apply(null,Array.prototype.slice.call(arguments,1))},this.filename=t.name||i(),this.extension="",this.mimeType=""}function r(t){n.call(this,t),this.extension=".tar",this.mimeType="application/x-tar",this.fileExtension="",this.baseFilename=this.filename,this.tape=null,this.count=0,this.part=1,this.frames=0}function o(t){r.call(this,t),this.type="image/png",this.fileExtension=".png"}function a(t){r.call(this,t),this.type="image/jpeg",this.fileExtension=".jpg",this.quality=t.quality/100||.8}function s(t){var e=document.createElement("canvas");"image/webp"!==e.toDataURL("image/webp").substr(5,10)&&console.log("WebP not supported - try another export format"),n.call(this,t),this.quality=t.quality/100||.8,this.extension=".webm",this.mimeType="video/webm",this.baseFilename=this.filename,this.framerate=t.framerate,this.frames=0,this.part=1,this.videoWriter=new WebMWriter({quality:this.quality,fileWriter:null,fd:null,frameRate:this.framerate})}function h(t){n.call(this,t),t.quality=t.quality/100||.8,this.encoder=new FFMpegServer.Video(t),this.encoder.on("process",function(){this.emit("process")}.bind(this)),this.encoder.on("finished",function(t,e){var i=this.callback;i&&(this.callback=void 0,i(t,e))}.bind(this)),this.encoder.on("progress",function(t){this.settings.onProgress&&this.settings.onProgress(t)}.bind(this)),this.encoder.on("error",function(t){alert(JSON.stringify(t,null,2))}.bind(this))}function f(t){n.call(this,t),this.framerate=this.settings.framerate,this.type="video/webm",this.extension=".webm",this.stream=null,this.mediaRecorder=null,this.chunks=[]}function u(t){n.call(this,t),t.quality=31-(30*t.quality/100||10),t.workers=t.workers||4,this.extension=".gif",this.mimeType="image/gif",this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.sizeSet=!1,this.encoder=new GIF({workers:t.workers,quality:t.quality,workerScript:t.workersPath+"gif.worker.js"}),this.encoder.on("progress",function(t){this.settings.onProgress&&this.settings.onProgress(t)}.bind(this)),this.encoder.on("finished",function(t){var e=this.callback;e&&(this.callback=void 0,e(t))}.bind(this))}function d(t){function e(){function t(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),it.push(this)),this._hookedTime+M.startTime}b("Capturer start"),U=window.Date.now(),T=U+M.startTime,I=window.performance.now(),F=I+M.startTime,window.Date.prototype.getTime=function(){return T},window.Date.now=function(){return T},window.setTimeout=function(t,e){var i={callback:t,time:e,triggerTime:T+e};return _.push(i),b("Timeout set to "+i.time),i},window.clearTimeout=function(t){for(var e=0;e<_.length;e++)_[e]!=t||(_.splice(e,1),b("Timeout cleared"))},window.setInterval=function(t,e){var i={callback:t,time:e,triggerTime:T+e};return S.push(i),b("Interval set to "+i.time),i},window.clearInterval=function(t){return b("clear Interval"),null},window.requestAnimationFrame=function(t){W.push(t)},window.performance.now=function(){return F};try{Object.defineProperty(HTMLVideoElement.prototype,"currentTime",{get:t}),Object.defineProperty(HTMLAudioElement.prototype,"currentTime",{get:t})}catch(t){b(t)}}function i(){e(),D.start(),R=!0}function n(){R=!1,D.stop(),l()}function r(t,e){Z(t,0,e)}function d(){r(y)}function l(){b("Capturer stop"),window.setTimeout=Z,window.setInterval=J,window.clearInterval=Y,window.clearTimeout=$,window.requestAnimationFrame=Q,window.Date.prototype.getTime=et,window.Date.now=X,window.performance.now=tt}function c(){var t=C/M.framerate;(M.frameLimit&&C>=M.frameLimit||M.timeLimit&&t>=M.timeLimit)&&(n(),v());var e=new Date(null);e.setSeconds(t),M.motionBlurFrames>2?j.textContent="CCapture "+M.format+" | "+C+" frames ("+O+" inter) | "+e.toISOString().substr(11,8):j.textContent="CCapture "+M.format+" | "+C+" frames | "+e.toISOString().substr(11,8)}function p(t){N.width===t.width&&N.height===t.height||(N.width=t.width,N.height=t.height,z=new Uint16Array(N.height*N.width*4),V.fillStyle="#0",V.fillRect(0,0,N.width,N.height))}function m(t){V.drawImage(t,0,0),q=V.getImageData(0,0,N.width,N.height);for(var e=0;e2?(p(t),m(t),O>=.5*M.motionBlurFrames?w():d()):(D.add(t),C++,b("Full Frame! "+C)))}function y(){var t=1e3/M.framerate,e=(C+O/M.motionBlurFrames)*t;T=U+e,F=I+e,it.forEach(function(t){t._hookedTime=e/1e3}),c(),b("Frame: "+C+" "+O);for(var i=0;i<_.length;i++)T>=_[i].triggerTime&&(r(_[i].callback),_.splice(i,1));for(var i=0;i=S[i].triggerTime&&(r(S[i].callback),S[i].triggerTime+=S[i].time);W.forEach(function(t){r(t,T-k)}),W=[]}function v(t){t||(t=function(t){return download(t,D.filename+D.extension,D.mimeType),!1}),D.save(t)}function b(t){A&&console.log(t)}function B(t,e){P[t]=e}function x(t){var e=P[t];e&&e.apply(null,Array.prototype.slice.call(arguments,1))}function E(t){x("progress",t)}var A,L,T,U,F,I,d,D,M=t||{},_=(new Date,[]),S=[],C=0,O=0,W=[],R=!1,P={};M.framerate=M.framerate||60,M.motionBlurFrames=2*(M.motionBlurFrames||1),A=M.verbose||!1,L=M.display||!1,M.step=1e3/M.framerate,M.timeLimit=M.timeLimit||0,M.frameLimit=M.frameLimit||0,M.startTime=M.startTime||0;var j=document.createElement("div");j.style.position="absolute",j.style.left=j.style.top=0,j.style.backgroundColor="black",j.style.fontFamily="monospace",j.style.fontSize="11px",j.style.padding="5px",j.style.color="red",j.style.zIndex=1e5,M.display&&document.body.appendChild(j);var z,q,N=document.createElement("canvas"),V=N.getContext("2d");b("Step is set to "+M.step+"ms");var G={gif:u,webm:s,ffmpegserver:h,png:o,jpg:a,"webm-mediarecorder":f},H=G[M.format];if(!H)throw"Error: Incorrect or missing format: Valid formats are "+Object.keys(G).join(", ");if(D=new H(M),D.step=d,D.on("process",y),D.on("progress",E),"performance"in window==0&&(window.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in window.performance==0){var K=Date.now();performance.timing&&performance.timing.navigationStart&&(K=performance.timing.navigationStart),window.performance.now=function(){return Date.now()-K}}var Z=window.setTimeout,J=window.setInterval,Y=window.clearInterval,$=window.clearTimeout,Q=window.requestAnimationFrame,X=window.Date.now,tt=window.performance.now,et=window.Date.prototype.getTime,it=[];return{start:i,capture:g,stop:n,save:v,on:B}}var l={function:!0,object:!0},c=(parseFloat,parseInt,l[typeof exports]&&exports&&!exports.nodeType?exports:void 0),p=l[typeof module]&&module&&!module.nodeType?module:void 0,m=p&&p.exports===c?c:void 0,w=t(c&&p&&"object"==typeof global&&global),g=t(l[typeof self]&&self),y=t(l[typeof window]&&window),v=t(l[typeof this]&&this),b=w||y!==(v&&v.window)&&y||g||v||Function("return this")();"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var n=atob(this.toDataURL(e,i).split(",")[1]),r=n.length,o=new Uint8Array(r),a=0;a0&&this.frames/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+e(this.part),download(t,this.filename+this.extension,this.mimeType);var i=this.count;this.dispose(),this.count=i+1,this.part++,this.filename=this.baseFilename+"-part-"+e(this.part),this.frames=0,this.step()}.bind(this)):(this.count++,this.frames++,this.step())}.bind(this),i.readAsArrayBuffer(t)},r.prototype.save=function(t){t(this.tape.save())},r.prototype.dispose=function(){this.tape=new Tar,this.count=0},o.prototype=Object.create(r.prototype),o.prototype.add=function(t){t.toBlob(function(t){r.prototype.add.call(this,t)}.bind(this),this.type)},a.prototype=Object.create(r.prototype),a.prototype.add=function(t){t.toBlob(function(t){r.prototype.add.call(this,t)}.bind(this),this.type,this.quality)},s.prototype=Object.create(n.prototype),s.prototype.start=function(t){this.dispose()},s.prototype.add=function(t){this.videoWriter.addFrame(t),this.settings.autoSaveTime>0&&this.frames/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+e(this.part),download(t,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+e(this.part),this.step()}.bind(this)):(this.frames++,this.step())},s.prototype.save=function(t){this.videoWriter.complete().then(t)},s.prototype.dispose=function(t){this.frames=0,this.videoWriter=new WebMWriter({quality:this.quality,fileWriter:null,fd:null,frameRate:this.framerate})},h.prototype=Object.create(n.prototype),h.prototype.start=function(){this.encoder.start(this.settings)},h.prototype.add=function(t){this.encoder.add(t)},h.prototype.save=function(t){this.callback=t,this.encoder.end()},h.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},f.prototype=Object.create(n.prototype),f.prototype.add=function(t){this.stream||(this.stream=t.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(t){this.chunks.push(t.data)}.bind(this)),this.step()},f.prototype.save=function(t){this.mediaRecorder.onstop=function(e){var i=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],t(i)}.bind(this),this.mediaRecorder.stop()},u.prototype=Object.create(n.prototype),u.prototype.add=function(t){this.sizeSet||(this.encoder.setOption("width",t.width),this.encoder.setOption("height",t.height),this.sizeSet=!0),this.canvas.width=t.width,this.canvas.height=t.height,this.ctx.drawImage(t,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},u.prototype.save=function(t){this.callback=t,this.encoder.render()},(y||g||{}).CCapture=d,"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return d}):c&&p?(m&&((p.exports=d).CCapture=d),c.CCapture=d):b.CCapture=d}(); \ No newline at end of file +"use strict";!function(){var t="undefined"!=typeof module&&void 0!==module.exports,e=function(t){this.data=new Uint8Array(t),this.pos=0};e.prototype.seek=function(t){this.pos=t},e.prototype.writeBytes=function(t){for(var e=0;e>8,this.data[this.pos++]=t},e.prototype.writeDoubleBE=function(t){for(var e=new Uint8Array(new Float64Array([t]).buffer),i=e.length-1;0<=i;i--)this.writeByte(e[i])},e.prototype.writeFloatBE=function(t){for(var e=new Uint8Array(new Float32Array([t]).buffer),i=e.length-1;0<=i;i--)this.writeByte(e[i])},e.prototype.writeString=function(t){for(var e=0;e>8),this.writeU8(t);break;case 3:this.writeU8(32|t>>16),this.writeU8(t>>8),this.writeU8(t);break;case 4:this.writeU8(16|t>>24),this.writeU8(t>>16),this.writeU8(t>>8),this.writeU8(t);break;case 5:this.writeU8(8|t/4294967296&7),this.writeU8(t>>24),this.writeU8(t>>16),this.writeU8(t>>8),this.writeU8(t);break;default:throw new RuntimeException("Bad EBML VINT size "+e)}},e.prototype.measureEBMLVarInt=function(t){if(t<127)return 1;if(t<16383)return 2;if(t<2097151)return 3;if(t<268435455)return 4;if(t<34359738367)return 5;throw new RuntimeException("EBML VINT size not supported "+t)},e.prototype.writeEBMLVarInt=function(t){this.writeEBMLVarIntWidth(t,this.measureEBMLVarInt(t))},e.prototype.writeUnsignedIntBE=function(t,e){switch(void 0===e&&(e=this.measureUnsignedInt(t)),e){case 5:this.writeU8(Math.floor(t/4294967296));case 4:this.writeU8(t>>24);case 3:this.writeU8(t>>16);case 2:this.writeU8(t>>8);case 1:this.writeU8(t);break;default:throw new RuntimeException("Bad UINT size "+e)}},e.prototype.measureUnsignedInt=function(t){return t<256?1:t<65536?2:t<1<<24?3:t<4294967296?4:5},e.prototype.getAsDataArray=function(){if(this.posthis.length)throw"Seeking beyond the end of file is not allowed";this.pos=t},this.write=function(t){var a={offset:this.pos,data:t,length:function(t){var e=t.byteLength||t.length||t.size;if(!Number.isInteger(e))throw"Failed to determine size of element";return e}(t)},i=a.offset>=this.length;this.pos+=a.length,this.length=Math.max(this.length,this.pos),e=e.then(function(){if(s)return new Promise(function(o,t){h(a.data).then(function(t){var n=0,e=Buffer.from(t.buffer),r=function(t,e,i){(n+=e)>=i.length?o():f.write(s,i,n,i.length-n,a.offset+n,r)};f.write(s,e,0,e.length,a.offset,r)})});if(r)return new Promise(function(t,e){r.onwriteend=t,r.seek(a.offset),r.write(new Blob([a.data]))});if(!i)for(var t=0;t=e.offset+e.length)){if(a.offsete.offset+e.length)throw new Error("Overwrite crosses blob boundaries");return a.offset==e.offset&&a.length==e.length?void(e.data=a.data):h(e.data).then(function(t){return e.data=t,h(a.data)}).then(function(t){a.data=t,e.data.set(a.data,a.offset-e.offset)})}}n.push(a)})},this.complete=function(i){return e=s||r?e.then(function(){return null}):e.then(function(){for(var t=[],e=0;e 0 and < 127";return e.writeEBMLVarInt(t.trackNumber),e.writeU16BE(t.timecode),e.writeByte(128),{id:163,data:[e.getAsDataArray(),t.frame]}}function k(){if(0!=u.length){for(var t=0,e=0;e>18&63]+s[r>>12&63]+s[r>>6&63]+s[63&r];switch(a.length%4){case 1:a+="=";break;case 2:a+="=="}return a}}(),function(){var e,i=window.utils;e=[{field:"fileName",length:100},{field:"fileMode",length:8},{field:"uid",length:8},{field:"gid",length:8},{field:"fileSize",length:12},{field:"mtime",length:12},{field:"checksum",length:8},{field:"type",length:1},{field:"linkName",length:100},{field:"ustar",length:8},{field:"owner",length:32},{field:"group",length:32},{field:"majorNumber",length:8},{field:"minorNumber",length:8},{field:"filenamePrefix",length:155},{field:"padding",length:12}],window.header={},window.header.structure=e,window.header.format=function(r,t){var o=i.clean(512),a=0;return e.forEach(function(t){var e,i,n=r[t.field]||"";for(e=0,i=n.length;er&&(e.push({blocks:o,length:i}),o=[],i=0),o.push(t),i+=t.headerLength+t.inputLength}),e.push({blocks:o,length:i}),e.forEach(function(t){var e=new Uint8Array(t.length),i=0;t.blocks.forEach(function(t){e.set(t.header,i),i+=t.headerLength,e.set(t.input,i),i+=t.inputLength}),n.push(e)}),n.push(new Uint8Array(1024)),new Blob(n,{type:"octet/stream"})},t.prototype.clear=function(){this.written=0,this.out=p.clean(e)},"undefined"!=typeof module&&void 0!==module.exports?module.exports=t:window.Tar=t}(),function(t){function d(t,e){if({}.hasOwnProperty.call(d.cache,t))return d.cache[t];var i=d.resolve(t);if(!i)throw new Error("Failed to resolve module "+t);var n={id:t,require:d,filename:t,exports:{},loaded:!1,parent:e,children:[]};e&&e.children.push(n);var r=t.slice(0,t.lastIndexOf("/")+1);return d.cache[t]=n.exports,i.call(n.exports,n,n.exports,r,t),n.loaded=!0,d.cache[t]=n.exports}d.modules={},d.cache={},d.resolve=function(t){return{}.hasOwnProperty.call(d.modules,t)?d.modules[t]:void 0},d.define=function(t,e){d.modules[t]=e};var e,o=(e="/",{title:"browser",version:"v0.10.26",browser:!0,env:{},argv:[],nextTick:t.setImmediate||function(t){setTimeout(t,0)},cwd:function(){return e},chdir:function(t){e=t}});d.define("/gif.coffee",function(t,e,i,n){function r(t,e){return{}.hasOwnProperty.call(t,e)}var o,a,s,h,f;s=d("events",t).EventEmitter,o=d("/browser.coffee",t),f=function(t){function e(t){var e,i;for(e in this.running=!1,this.options={},this.frames=[],this.freeWorkers=[],this.activeWorkers=[],this.setOptions(t),a)i=a[e],null!=this.options[e]?this.options[e]:this.options[e]=i}return function(t,e){function i(){this.constructor=t}for(var n in e)r(e,n)&&(t[n]=e[n]);i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(e,s),h={delay:500,copy:!(a={workerScript:"gif.worker.js",workers:2,repeat:0,background:"#fff",quality:10,width:null,height:null,transparent:null})},e.prototype.setOption=function(t,e){return this.options[t]=e,null==this._canvas||"width"!==t&&"height"!==t?void 0:this._canvas[t]=e},e.prototype.setOptions=function(e){var i,n;return function(t){for(i in e)r(e,i)&&(n=e[i],t.push(this.setOption(i,n)));return t}.call(this,[])},e.prototype.addFrame=function(t,e){var i,n;for(n in null==e&&(e={}),(i={}).transparent=this.options.transparent,h)i[n]=e[n]||h[n];if(null!=this.options.width||this.setOption("width",t.width),null!=this.options.height||this.setOption("height",t.height),"undefined"!=typeof ImageData&&null!=ImageData&&t instanceof ImageData)i.data=t.data;else if("undefined"!=typeof CanvasRenderingContext2D&&null!=CanvasRenderingContext2D&&t instanceof CanvasRenderingContext2D||"undefined"!=typeof WebGLRenderingContext&&null!=WebGLRenderingContext&&t instanceof WebGLRenderingContext)e.copy?i.data=this.getContextData(t):i.context=t;else{if(null==t.childNodes)throw new Error("Invalid image");e.copy?i.data=this.getImageData(t):i.image=t}return this.frames.push(i)},e.prototype.render=function(){var i;if(this.running)throw new Error("Already running");if(null==this.options.width||null==this.options.height)throw new Error("Width and height must be set prior to rendering");this.running=!0,this.nextFrame=0,this.finishedFrames=0,this.imageParts=function(t){for(var e=function(){var t;t=[];for(var e=0;0<=this.frames.length?ethis.frames.length;0<=this.frames.length?++e:--e)t.push(e);return t}.apply(this,arguments),i=0,n=e.length;i=this.frames.length?void 0:(t=this.frames[this.nextFrame++],i=this.freeWorkers.shift(),e=this.getTask(t),console.log("starting frame "+(e.index+1)+" of "+this.frames.length),this.activeWorkers.push(i),i.postMessage(e))},e.prototype.getContextData=function(t){return t.getImageData(0,0,this.options.width,this.options.height).data},e.prototype.getImageData=function(t){var e;return null!=this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),(e=this._canvas.getContext("2d")).setFill=this.options.background,e.fillRect(0,0,this.options.width,this.options.height),e.drawImage(t,0,0),this.getContextData(e)},e.prototype.getTask=function(t){var e,i;if(i={index:e=this.frames.indexOf(t),last:e===this.frames.length-1,delay:t.delay,transparent:t.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,repeat:this.options.repeat,canTransfer:"chrome"===o.name},null!=t.data)i.data=t.data;else if(null!=t.context)i.data=this.getContextData(t.context);else{if(null==t.image)throw new Error("Invalid frame");i.data=this.getImageData(t.image)}return i},e}(),t.exports=f}),d.define("/browser.coffee",function(t,e,i,n){var r,o,a,s,h;s=navigator.userAgent.toLowerCase(),a=navigator.platform.toLowerCase(),o="ie"===(h=s.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0])[1]&&document.documentMode,(r={name:"version"===h[1]?h[3]:h[1],version:o||parseFloat("opera"===h[1]&&h[4]?h[4]:h[2]),platform:{name:s.match(/ip(?:ad|od|hone)/)?"ios":(s.match(/(?:webos|android)/)||a.match(/mac|win|linux/)||["other"])[0]}})[r.name]=!0,r[r.name+parseInt(r.version,10)]=!0,r.platform[r.platform.name]=!0,t.exports=r}),d.define("events",function(t,e,i,n){o.EventEmitter||(o.EventEmitter=function(){});var r=e.EventEmitter=o.EventEmitter,a="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};r.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},r.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||a(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"!=typeof e){if(a(e)){for(var i=Array.prototype.slice.call(arguments,1),n=e.slice(),r=0,o=n.length;ri&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace());this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,i){var n=this;return n.on(e,function t(){n.removeListener(e,t),i.apply(this,arguments)}),this},r.prototype.removeListener=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var i=this._events[t];if(a(i)){var n=i.indexOf(e);if(n<0)return this;i.splice(n,1),0==i.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},r.prototype.removeAllListeners=function(t){return t&&this._events&&this._events[t]&&(this._events[t]=null),this},r.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),a(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}}),t.GIF=d("/gif.coffee")}.call(this,this),function(){var t="undefined"!=typeof module&&void 0!==module.exports,e=t?require("./tar"):window.Tar,R=t?require("./download"):window.download,i=t?require("./gif").GIF:window.GIF,n=t?require("./webm-writer-0.2.0"):window.WebMWriter,r={function:!0,object:!0};function o(t){return t&&t.Object===Object?t:null}parseFloat,parseInt;var a=r[typeof exports]&&exports&&!exports.nodeType?exports:void 0,s=r[typeof module]&&module&&!module.nodeType?module:void 0,h=s&&s.exports===a?a:void 0,f=o(a&&s&&"object"==typeof global&&global),d=o(r[typeof self]&&self),u=o(r[typeof window]&&window),l=o(r[typeof this]&&this),c=f||u!==(l&&l.window)&&u||d||l||Function("return this")();function p(t){return String("0000000"+t).slice(-7)}"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var n=atob(this.toDataURL(e,i).split(",")[1]),r=n.length,o=new Uint8Array(r),a=0;a=h.frameLimit||h.timeLimit&&t>=h.timeLimit)&&(M(),S());var e=new Date(null);e.setSeconds(t),2=f[i].triggerTime&&(C(f[i].callback),f.splice(i,1));for(i=0;i=d[i].triggerTime&&(C(d[i].callback),d[i].triggerTime+=d[i].time);c.forEach(function(t){C(t,n-P)}),c=[]}function S(t){t||(t=function(t){return R(t,s.filename+s.extension,s.mimeType),!1}),s.save(t)}function W(t){e&&console.log(t)}return{start:function(){!function(){function t(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),_.push(this)),this._hookedTime+h.startTime}W("Capturer start"),r=window.Date.now(),n=r+h.startTime,a=window.performance.now(),o=a+h.startTime,window.Date.prototype.getTime=function(){return n},window.Date.now=function(){return n},window.setTimeout=function(t,e){var i={callback:t,time:e,triggerTime:n+e};return f.push(i),W("Timeout set to "+i.time),i},window.clearTimeout=function(t){for(var e=0;e=.5*h.motionBlurFrames?function(){for(var t=y.data,e=0;e=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+p(this.part),R(t,this.filename+this.extension,this.mimeType);var e=this.count;this.dispose(),this.count=e+1,this.part++,this.filename=this.baseFilename+"-part-"+p(this.part),this.frames=0,this.step()}.bind(this)):(this.count++,this.frames++,this.step())}.bind(this),e.readAsArrayBuffer(t)},w.prototype.save=function(t){t(this.tape.save())},w.prototype.dispose=function(){this.tape=new e,this.count=0},(j.prototype=Object.create(w.prototype)).add=function(t){t.toBlob(function(t){w.prototype.add.call(this,t)}.bind(this),this.type)},(q.prototype=Object.create(w.prototype)).add=function(t){t.toBlob(function(t){w.prototype.add.call(this,t)}.bind(this),this.type,this.quality)},(z.prototype=Object.create(m.prototype)).start=function(t){this.dispose()},z.prototype.add=function(t){this.videoWriter.addFrame(t),0=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+p(this.part),R(t,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+p(this.part),this.step()}.bind(this)):(this.frames++,this.step())},z.prototype.save=function(t){this.videoWriter.complete().then(t)},z.prototype.dispose=function(t){this.frames=0,this.videoWriter=new n({quality:this.quality,fileWriter:null,fd:null,frameRate:this.framerate})},(N.prototype=Object.create(m.prototype)).start=function(){this.encoder.start(this.settings)},N.prototype.add=function(t){this.encoder.add(t)},N.prototype.save=function(t){this.callback=t,this.encoder.end()},N.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},(V.prototype=Object.create(m.prototype)).add=function(t){this.stream||(this.stream=t.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(t){this.chunks.push(t.data)}.bind(this)),this.step()},V.prototype.save=function(i){this.mediaRecorder.onstop=function(t){var e=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],i(e)}.bind(this),this.mediaRecorder.stop()},(G.prototype=Object.create(m.prototype)).add=function(t){this.sizeSet||(this.encoder.setOption("width",t.width),this.encoder.setOption("height",t.height),this.sizeSet=!0),this.canvas.width=t.width,this.canvas.height=t.height,this.ctx.drawImage(t,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},G.prototype.save=function(t){this.callback=t,this.encoder.render()},(u||d||{}).CCapture=g,"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return g}):a&&s?(h&&((s.exports=g).CCapture=g),a.CCapture=g):c.CCapture=g}(); \ No newline at end of file diff --git a/build/CCapture.min.js b/build/CCapture.min.js index 5f8e144..5c50e82 100755 --- a/build/CCapture.min.js +++ b/build/CCapture.min.js @@ -1 +1 @@ -!function(){"use strict";function t(t){return t&&t.Object===Object?t:null}function e(t){return String("0000000"+t).slice(-7)}function i(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}function n(t){var e={};this.settings=t,this.on=function(t,i){e[t]=i},this.emit=function(t){var i=e[t];i&&i.apply(null,Array.prototype.slice.call(arguments,1))},this.filename=t.name||i(),this.extension="",this.mimeType=""}function o(t){n.call(this,t),this.extension=".tar",this.mimeType="application/x-tar",this.fileExtension="",this.baseFilename=this.filename,this.tape=null,this.count=0,this.part=1,this.frames=0}function r(t){o.call(this,t),this.type="image/png",this.fileExtension=".png"}function a(t){o.call(this,t),this.type="image/jpeg",this.fileExtension=".jpg",this.quality=t.quality/100||.8}function s(t){var e=document.createElement("canvas");"image/webp"!==e.toDataURL("image/webp").substr(5,10)&&console.log("WebP not supported - try another export format"),n.call(this,t),this.quality=t.quality/100||.8,this.extension=".webm",this.mimeType="video/webm",this.baseFilename=this.filename,this.framerate=t.framerate,this.frames=0,this.part=1,this.videoWriter=new WebMWriter({quality:this.quality,fileWriter:null,fd:null,frameRate:this.framerate})}function c(t){n.call(this,t),t.quality=t.quality/100||.8,this.encoder=new FFMpegServer.Video(t),this.encoder.on("process",function(){this.emit("process")}.bind(this)),this.encoder.on("finished",function(t,e){var i=this.callback;i&&(this.callback=void 0,i(t,e))}.bind(this)),this.encoder.on("progress",function(t){this.settings.onProgress&&this.settings.onProgress(t)}.bind(this)),this.encoder.on("error",function(t){alert(JSON.stringify(t,null,2))}.bind(this))}function p(t){n.call(this,t),this.framerate=this.settings.framerate,this.type="video/webm",this.extension=".webm",this.stream=null,this.mediaRecorder=null,this.chunks=[]}function h(t){n.call(this,t),t.quality=31-(30*t.quality/100||10),t.workers=t.workers||4,this.extension=".gif",this.mimeType="image/gif",this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.sizeSet=!1,this.encoder=new GIF({workers:t.workers,quality:t.quality,workerScript:t.workersPath+"gif.worker.js"}),this.encoder.on("progress",function(t){this.settings.onProgress&&this.settings.onProgress(t)}.bind(this)),this.encoder.on("finished",function(t){var e=this.callback;e&&(this.callback=void 0,e(t))}.bind(this))}function m(t){function e(){function t(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),it.push(this)),this._hookedTime+B.startTime}b("Capturer start"),j=window.Date.now(),C=j+B.startTime,I=window.performance.now(),q=I+B.startTime,window.Date.prototype.getTime=function(){return C},window.Date.now=function(){return C},window.setTimeout=function(t,e){var i={callback:t,time:e,triggerTime:C+e};return E.push(i),b("Timeout set to "+i.time),i},window.clearTimeout=function(t){for(var e=0;e=B.frameLimit||B.timeLimit&&t>=B.timeLimit)&&(n(),v());var e=new Date(null);e.setSeconds(t),B.motionBlurFrames>2?z.textContent="CCapture "+B.format+" | "+R+" frames ("+A+" inter) | "+e.toISOString().substr(11,8):z.textContent="CCapture "+B.format+" | "+R+" frames | "+e.toISOString().substr(11,8)}function l(t){H.width===t.width&&H.height===t.height||(H.width=t.width,H.height=t.height,U=new Uint16Array(H.height*H.width*4),V.fillStyle="#0",V.fillRect(0,0,H.width,H.height))}function f(t){V.drawImage(t,0,0),_=V.getImageData(0,0,H.width,H.height);for(var e=0;e2?(l(t),f(t),A>=.5*B.motionBlurFrames?w():m()):(O.add(t),R++,b("Full Frame! "+R)))}function g(){var t=1e3/B.framerate,e=(R+A/B.motionBlurFrames)*t;C=j+e,q=I+e,it.forEach(function(t){t._hookedTime=e/1e3}),u(),b("Frame: "+R+" "+A);for(var i=0;i=E[i].triggerTime&&(o(E[i].callback),E.splice(i,1));for(var i=0;i=L[i].triggerTime&&(o(L[i].callback),L[i].triggerTime+=L[i].time);P.forEach(function(t){o(t,C-T)}),P=[]}function v(t){t||(t=function(t){return download(t,O.filename+O.extension,O.mimeType),!1}),O.save(t)}function b(t){S&&console.log(t)}function F(t,e){W[t]=e}function x(t){var e=W[t];e&&e.apply(null,Array.prototype.slice.call(arguments,1))}function k(t){x("progress",t)}var S,D,C,j,q,I,m,O,B=t||{},E=(new Date,[]),L=[],R=0,A=0,P=[],M=!1,W={};B.framerate=B.framerate||60,B.motionBlurFrames=2*(B.motionBlurFrames||1),S=B.verbose||!1,D=B.display||!1,B.step=1e3/B.framerate,B.timeLimit=B.timeLimit||0,B.frameLimit=B.frameLimit||0,B.startTime=B.startTime||0;var z=document.createElement("div");z.style.position="absolute",z.style.left=z.style.top=0,z.style.backgroundColor="black",z.style.fontFamily="monospace",z.style.fontSize="11px",z.style.padding="5px",z.style.color="red",z.style.zIndex=1e5,B.display&&document.body.appendChild(z);var U,_,H=document.createElement("canvas"),V=H.getContext("2d");b("Step is set to "+B.step+"ms");var G={gif:h,webm:s,ffmpegserver:c,png:r,jpg:a,"webm-mediarecorder":p},J=G[B.format];if(!J)throw"Error: Incorrect or missing format: Valid formats are "+Object.keys(G).join(", ");if(O=new J(B),O.step=m,O.on("process",g),O.on("progress",k),"performance"in window==0&&(window.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in window.performance==0){var N=Date.now();performance.timing&&performance.timing.navigationStart&&(N=performance.timing.navigationStart),window.performance.now=function(){return Date.now()-N}}var K=window.setTimeout,Q=window.setInterval,X=window.clearInterval,Y=window.clearTimeout,Z=window.requestAnimationFrame,$=window.Date.now,tt=window.performance.now,et=window.Date.prototype.getTime,it=[];return{start:i,capture:y,stop:n,save:v,on:F}}var d={function:!0,object:!0},u=(parseFloat,parseInt,d[typeof exports]&&exports&&!exports.nodeType?exports:void 0),l=d[typeof module]&&module&&!module.nodeType?module:void 0,f=l&&l.exports===u?u:void 0,w=t(u&&l&&"object"==typeof global&&global),y=t(d[typeof self]&&self),g=t(d[typeof window]&&window),v=t(d[typeof this]&&this),b=w||g!==(v&&v.window)&&g||y||v||Function("return this")();"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var n=atob(this.toDataURL(e,i).split(",")[1]),o=n.length,r=new Uint8Array(o),a=0;a0&&this.frames/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+e(this.part),download(t,this.filename+this.extension,this.mimeType);var i=this.count;this.dispose(),this.count=i+1,this.part++,this.filename=this.baseFilename+"-part-"+e(this.part),this.frames=0,this.step()}.bind(this)):(this.count++,this.frames++,this.step())}.bind(this),i.readAsArrayBuffer(t)},o.prototype.save=function(t){t(this.tape.save())},o.prototype.dispose=function(){this.tape=new Tar,this.count=0},r.prototype=Object.create(o.prototype),r.prototype.add=function(t){t.toBlob(function(t){o.prototype.add.call(this,t)}.bind(this),this.type)},a.prototype=Object.create(o.prototype),a.prototype.add=function(t){t.toBlob(function(t){o.prototype.add.call(this,t)}.bind(this),this.type,this.quality)},s.prototype=Object.create(n.prototype),s.prototype.start=function(t){this.dispose()},s.prototype.add=function(t){this.videoWriter.addFrame(t),this.settings.autoSaveTime>0&&this.frames/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+e(this.part),download(t,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+e(this.part),this.step()}.bind(this)):(this.frames++,this.step())},s.prototype.save=function(t){this.videoWriter.complete().then(t)},s.prototype.dispose=function(t){this.frames=0,this.videoWriter=new WebMWriter({quality:this.quality,fileWriter:null,fd:null,frameRate:this.framerate})},c.prototype=Object.create(n.prototype),c.prototype.start=function(){this.encoder.start(this.settings)},c.prototype.add=function(t){this.encoder.add(t)},c.prototype.save=function(t){this.callback=t,this.encoder.end()},c.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},p.prototype=Object.create(n.prototype),p.prototype.add=function(t){this.stream||(this.stream=t.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(t){this.chunks.push(t.data)}.bind(this)),this.step()},p.prototype.save=function(t){this.mediaRecorder.onstop=function(e){var i=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],t(i)}.bind(this),this.mediaRecorder.stop()},h.prototype=Object.create(n.prototype),h.prototype.add=function(t){this.sizeSet||(this.encoder.setOption("width",t.width),this.encoder.setOption("height",t.height),this.sizeSet=!0),this.canvas.width=t.width,this.canvas.height=t.height,this.ctx.drawImage(t,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},h.prototype.save=function(t){this.callback=t,this.encoder.render()},(g||y||{}).CCapture=m,"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return m}):u&&l?(f&&((l.exports=m).CCapture=m),u.CCapture=m):b.CCapture=m}(); \ No newline at end of file +!function(){"use strict";var t="undefined"!=typeof module&&void 0!==module.exports,e=t?require("./tar"):window.Tar,M=t?require("./download"):window.download,i=t?require("./gif").GIF:window.GIF,n=t?require("./webm-writer-0.2.0"):window.WebMWriter,o={function:!0,object:!0};function r(t){return t&&t.Object===Object?t:null}parseFloat,parseInt;var a=o[typeof exports]&&exports&&!exports.nodeType?exports:void 0,s=o[typeof module]&&module&&!module.nodeType?module:void 0,c=s&&s.exports===a?a:void 0,h=r(a&&s&&"object"==typeof global&&global),p=r(o[typeof self]&&self),m=r(o[typeof window]&&window),d=r(o[typeof this]&&this),u=h||m!==(d&&d.window)&&m||p||d||Function("return this")();function l(t){return String("0000000"+t).slice(-7)}"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var n=atob(this.toDataURL(e,i).split(",")[1]),o=n.length,r=new Uint8Array(o),a=0;a=c.frameLimit||c.timeLimit&&t>=c.timeLimit)&&(E(),A());var e=new Date(null);e.setSeconds(t),2=h[i].triggerTime&&(L(h[i].callback),h.splice(i,1));for(i=0;i=p[i].triggerTime&&(L(p[i].callback),p[i].triggerTime+=p[i].time);u.forEach(function(t){L(t,n-W)}),u=[]}function A(t){t||(t=function(t){return M(t,s.filename+s.extension,s.mimeType),!1}),s.save(t)}function P(t){e&&console.log(t)}return{start:function(){!function(){function t(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),B.push(this)),this._hookedTime+c.startTime}P("Capturer start"),o=window.Date.now(),n=o+c.startTime,a=window.performance.now(),r=a+c.startTime,window.Date.prototype.getTime=function(){return n},window.Date.now=function(){return n},window.setTimeout=function(t,e){var i={callback:t,time:e,triggerTime:n+e};return h.push(i),P("Timeout set to "+i.time),i},window.clearTimeout=function(t){for(var e=0;e=.5*c.motionBlurFrames?function(){for(var t=g.data,e=0;e=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+l(this.part),M(t,this.filename+this.extension,this.mimeType);var e=this.count;this.dispose(),this.count=e+1,this.part++,this.filename=this.baseFilename+"-part-"+l(this.part),this.frames=0,this.step()}.bind(this)):(this.count++,this.frames++,this.step())}.bind(this),e.readAsArrayBuffer(t)},w.prototype.save=function(t){t(this.tape.save())},w.prototype.dispose=function(){this.tape=new e,this.count=0},(z.prototype=Object.create(w.prototype)).add=function(t){t.toBlob(function(t){w.prototype.add.call(this,t)}.bind(this),this.type)},(U.prototype=Object.create(w.prototype)).add=function(t){t.toBlob(function(t){w.prototype.add.call(this,t)}.bind(this),this.type,this.quality)},(_.prototype=Object.create(f.prototype)).start=function(t){this.dispose()},_.prototype.add=function(t){this.videoWriter.addFrame(t),0=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+l(this.part),M(t,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+l(this.part),this.step()}.bind(this)):(this.frames++,this.step())},_.prototype.save=function(t){this.videoWriter.complete().then(t)},_.prototype.dispose=function(t){this.frames=0,this.videoWriter=new n({quality:this.quality,fileWriter:null,fd:null,frameRate:this.framerate})},(H.prototype=Object.create(f.prototype)).start=function(){this.encoder.start(this.settings)},H.prototype.add=function(t){this.encoder.add(t)},H.prototype.save=function(t){this.callback=t,this.encoder.end()},H.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},(V.prototype=Object.create(f.prototype)).add=function(t){this.stream||(this.stream=t.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(t){this.chunks.push(t.data)}.bind(this)),this.step()},V.prototype.save=function(i){this.mediaRecorder.onstop=function(t){var e=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],i(e)}.bind(this),this.mediaRecorder.stop()},(G.prototype=Object.create(f.prototype)).add=function(t){this.sizeSet||(this.encoder.setOption("width",t.width),this.encoder.setOption("height",t.height),this.sizeSet=!0),this.canvas.width=t.width,this.canvas.height=t.height,this.ctx.drawImage(t,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},G.prototype.save=function(t){this.callback=t,this.encoder.render()},(m||p||{}).CCapture=y,"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return y}):a&&s?(c&&((s.exports=y).CCapture=y),a.CCapture=y):u.CCapture=y}(); \ No newline at end of file From 27da814ef7d34a7099a5a1a06ab147e3f8dc664e Mon Sep 17 00:00:00 2001 From: Unsigno Date: Thu, 20 Dec 2018 10:19:13 +0100 Subject: [PATCH 8/8] Updated module entry point --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 48ebc47..a986a91 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ccapture.js", "version": "1.0.9", "description": "A library to capture canvas-based animations at a fixed framerate", - "main": "build/CCapture.all.min.js", + "main": "src/CCapture.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" },