You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 lines
82 KiB

/** gifler.js | github.com/themadcreator/gifler | @license: Apache-2.0 */
!function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};e[s][0].call(l.exports,function(t){var n=e[s][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e,n){var r,i,o,s,a,u,c=function(t,e){return function(){return t.apply(e,arguments)}};s=t("omggif").GifReader,a=t("bluebird"),u=function(t){var e,n,r;return r=new XMLHttpRequest,r.open("GET",t,e=!0),r.responseType="arraybuffer",n=new a(function(t,e){return r.onload=function(e){return t(this.response)}}),r.send(),new o(n)},o=function(){function t(t){this._animatorPromise=t.then(function(t){var e;return e=new s(new Uint8Array(t)),i.decodeFramesAsync(e).then(function(t){return new r(e,t)})})}return t.getCanvasElement=function(t){var e,n;if("string"==typeof t&&"CANVAS"===(null!=(n=e=document.querySelector(t))?n.tagName:void 0))return e;if("CANVAS"===(null!=t?t.tagName:void 0))return t;throw new Error("Unexpected selector type. Valid types are query-selector-string/canvas-element")},t.prototype.animate=function(e){var n;return n=t.getCanvasElement(e),this._animatorPromise.then(function(t){return t.animateInCanvas(n)})},t.prototype.frames=function(e,n,r){var i;return null==r&&(r=!1),i=t.getCanvasElement(e),this._animatorPromise.then(function(t){return t.onDrawFrame=n,t.animateInCanvas(i,r)})},t.prototype.get=function(t){return this._animatorPromise},t}(),i=function(){function t(){}return t.decodeFramesSync=function(e){var n;return function(){n=[];for(var t=0,r=e.numFrames();r>=0?r>t:t>r;r>=0?t++:t--)n.push(t);return n}.apply(this).map(function(n){return t.decodeFrame(e,n)})},t.decodeFramesAsync=function(e){var n,r;return a.map(function(){r=[];for(var t=0,n=e.numFrames();n>=0?n>t:t>n;n>=0?t++:t--)r.push(t);return r}.apply(this),function(n){return t.decodeFrame(e,n)},n=1)},t.decodeFrame=function(t,e){var n;return n=t.frameInfo(e),n.pixels=new Uint8ClampedArray(t.width*t.height*4),t.decodeAndBlitFrameRGBA(e,n.pixels),n},t}(),r=function(){function t(t,e){var n;this._reader=t,this._frames=e,this._advanceFrame=c(this._advanceFrame,this),this._nextFrameRender=c(this._nextFrameRender,this),this._nextFrame=c(this._nextFrame,this),n=this._reader,this.width=n.width,this.height=n.height,this._loopCount=this._reader.loopCount(),this._loops=0,this._frameIndex=0,this._running=!1}return t.createBufferCanvas=function(t,e,n){var r,i,o;return r=document.createElement("canvas"),i=r.getContext("2d"),r.width=t.width,r.height=t.height,o=i.createImageData(e,n),o.data.set(t.pixels),i.putImageData(o,-t.x,-t.y),r},t.prototype.start=function(){return this._lastTime=(new Date).valueOf(),this._delayCompensation=0,this._running=!0,setTimeout(this._nextFrame,0),this},t.prototype.stop=function(){return this._running=!1,this},t.prototype.reset=function(){return this._frameIndex=0,this._loops=0,this},t.prototype.running=function(){return this._running},t.prototype._nextFrame=function(){requestAnimationFrame(this._nextFrameRender)},t.prototype._nextFrameRender=function(){var t,e;if(this._running)return t=this._frames[this._frameIndex],null!=(e=this.onFrame)&&e.apply(this,[t,this._frameIndex]),this._enqueueNextFrame()},t.prototype._advanceFrame=function(){this._frameIndex+=1,this._frameIndex>=this._frames.length&&(0!==this._loopCount&&this._loopCount===this._loops?this.stop():(this._frameIndex=0,this._loops+=1))},t.prototype._enqueueNextFrame=function(){var t,e,n,r;for(this._advanceFrame();this._running;){if(n=this._frames[this._frameIndex],e=(new Date).valueOf()-this._lastTime,this._lastTime+=e,this._delayCompensation+=e,r=10*n.delay,t=r-this._delayCompensation,this._delayCompensation-=r,!(0>t)){setTimeout(this._nextFrame,t);break}this._advanceFrame()}},t.prototype.animateInCanvas=function(e,n){var r;return null==n&&(n=!0),n&&(e.width=this.width,e.height=this.height),r=e.getContext("2d"),null==this.onDrawFrame&&(this.
this._yieldedPromise=null,t.cancel()}},u.prototype.promise=function(){return this._promise},u.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._promiseFulfilled(void 0)},u.prototype._continue=function(t){var n=this._promise;if(t===f)return this._cleanup(),n._rejectCallback(t.e,!1);var r=t.value;if(t.done===!0)return this._cleanup(),n._resolveCallback(r);var o=i(r,this._promise);if(!(o instanceof e)&&(o=a(o,this._yieldHandlers,this._promise),null===o))return void this._promiseRejected(new l("A value %s was yielded that could not be treated as a promise\n\n See http://goo.gl/MqrFmX\n\n".replace("%s",r)+"From coroutine:\n"+this._stack.split("\n").slice(1,-7).join("\n")));o=o._target();var s=o._bitField;0===(50397184&s)?(this._yieldedPromise=o,o._proxy(this,null)):0!==(33554432&s)?this._promiseFulfilled(o._value()):0!==(16777216&s)?this._promiseRejected(o._reason()):this._promiseCancelled()},e.coroutine=function(t,e){if("function"!=typeof t)throw new l("generatorFunction must be a function\n\n See http://goo.gl/MqrFmX\n");var n=Object(e).yieldHandler,r=u,i=(new Error).stack;return function(){var e=t.apply(this,arguments),o=new r(void 0,void 0,n,i),s=o.promise();return o._generator=e,o._promiseFulfilled(void 0),s}},e.coroutine.addYieldHandler=function(t){if("function"!=typeof t)throw new l("expecting a function but got "+h.classString(t));_.push(t)},e.spawn=function(t){if(s.deprecated("Promise.spawn()","Promise.coroutine()"),"function"!=typeof t)return n("generatorFunction must be a function\n\n See http://goo.gl/MqrFmX\n");var r=new u(t,this),i=r.promise();return r._run(e.spawn),i}}},{"./errors":12,"./util":36}],17:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util");o.canEvaluate,o.tryCatch,o.errorObj;e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var r}var i=[].slice.call(arguments);t&&i.pop();var r=new n(i).promise();return void 0!==t?r.spread(t):r}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,e,n,r){this.constructor$(t),this._promise._captureStackTrace();var i=c();this._callback=null===i?e:i.bind(e),this._preservedValues=r===o?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=n>=1?[]:p,this._init$(void 0,-2)}function u(t,e,n,i){if("function"!=typeof e)return r("expecting a function but got "+l.classString(e));var o="object"==typeof n&&null!==n?n.concurrency:0;return o="number"==typeof o&&isFinite(o)&&o>=1?o:0,new a(t,e,o,i).promise()}var c=e._getDomain,l=t("./util"),h=l.tryCatch,f=l.errorObj,p=[];l.inherits(a,n),a.prototype._init=function(){},a.prototype._promiseFulfilled=function(t,n){var r=this._values,o=this.length(),a=this._preservedValues,u=this._limit;if(0>n){if(n=-1*n-1,r[n]=t,u>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(u>=1&&this._inFlight>=u)return r[n]=t,this._queue.push(n),!1;null!==a&&(a[n]=t);var c=this._promise,l=this._callback,p=c._boundValue();c._pushContext();var _=h(l).call(p,t,n,o),d=c._popContext();if(s.checkForgottenReturns(_,d,null!==a?"Promise.filter":"Promise.map",c),_===f)return this._reject(_.e),!0;var v=i(_,this._promise);if(v instanceof e){v=v._target();var y=v._bitField;if(0===(50397184&y))return u>=1&&this._inFlight++,r[n]=v,v._proxy(this,-1*(n+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(v._reason()),!0):(this._cancel(),!0);_=v._value()}r[n]=_}var m=++this._totalResolved;return m>=o?(null!==a?this._filter(r,a):this._resolve(r),!0):!1},a.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlight<e;){if(this._isResolved())return;var r=t.pop();this._promiseFulfilled(n[r],r)}},a.prototype._filter=function(t,e){for(var n=e.length,r=new Array(n),i=0,o=0;n>o;++o)t[o]&&(r[i++]=e[o]);r.length=i,this._resolve(r)},a.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return u(this,t,e,null)},e.map=function(
var n=new i(t),o=n.promise();return n.setHowMany(e),n.init(),o}var s=t("./util"),a=t("./errors").RangeError,u=t("./errors").AggregateError,c=s.isArray,l={};s.inherits(i,n),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=c(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(l),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new u,e=this.length();e<this._values.length;++e)this._values[e]!==l&&t.push(this._values[e]);return t.length>0?this._reject(t):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},s=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},a=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=t.prototype._isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype.isCancelled=function(){return this._target()._isCancelled()},t.prototype.isPending=function(){return s.call(this._target())},t.prototype.isRejected=function(){return o.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return a.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,r){if(l(t)){if(t instanceof e)return t;var i=o(t);if(i===c){r&&r._pushContext();var u=e.reject(i.e);return r&&r._popContext