1){if(r===String){o="string"}else if(r===Number){o="number"}}var s;if(n){if(Symbol.toPrimitive){s=l(e,Symbol.toPrimitive)}else if(u(e)){s=Symbol.prototype.valueOf}}if(typeof s!=="undefined"){var c=s.call(e,o);if(i(c)){return c}throw new TypeError("unable to convert exotic object to primitive")}if(o==="default"&&(p(e)||u(e))){o="string"}return a(e,o==="default"?"number":o)}},{"./helpers/isPrimitive":25,"is-callable":29,"is-date-object":30,"is-symbol":32}],25:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],26:[function(t,e,r){var n=Object.prototype.hasOwnProperty;var i=Object.prototype.toString;e.exports=function t(e,r,o){if(i.call(r)!=="[object Function]"){throw new TypeError("iterator must be a function")}var p=e.length;if(p===+p){for(var u=0;u0&&!n.call(e,0)){for(var m=0;m0){for(var b=0;b=0&&n.call(e.callee)==="[object Function]"}return i}},{}],35:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){return Array.prototype.includes||n}},{"./implementation":13}],36:[function(t,e,r){"use strict";var n=t("define-properties");var i=t("./polyfill");e.exports=function t(){var e=i();if(Array.prototype.includes!==e){n(Array.prototype,{includes:e})}return e}},{"./polyfill":35,"define-properties":15}],37:[function(t,e,r){"use strict";var n=t("es-abstract/es7");var i=t("has");var o=t("function-bind");var p=o.call(Function.call,Object.prototype.propertyIsEnumerable);e.exports=function t(e){var r=n.RequireObjectCoercible(e);var o=[];for(var u in r){if(i(r,u)&&p(r,u)){o.push([u,r[u]])}}return o}},{"es-abstract/es7":42,"function-bind":53,has:54}],38:[function(t,e,r){"use strict";var n=t("define-properties");var i=t("./implementation");var o=t("./polyfill");var p=t("./shim");n(i,{getPolyfill:o,implementation:i,shim:p});e.exports=i},{"./implementation":37,"./polyfill":61,"./shim":62,"define-properties":39}],39:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:51,"object-keys":59}],40:[function(t,e,r){arguments[4][16][0].apply(r,arguments)},{"./helpers/isFinite":44,"./helpers/mod":46,"./helpers/sign":47,dup:16,"es-to-primitive/es5":48,"is-callable":55}],41:[function(t,e,r){arguments[4][17][0].apply(r,arguments)},{"./es5":40,"./helpers/assign":43,"./helpers/isFinite":44,"./helpers/isPrimitive":45,"./helpers/mod":46,"./helpers/sign":47,dup:17,"es-to-primitive/es6":49,"function-bind":53,"is-regex":57}],42:[function(t,e,r){"use strict";var n=t("./es6");var i=t("./helpers/assign");var o=i(n,{SameValueNonNumber:function t(e,r){if(typeof e==="number"||typeof e!==typeof r){throw new TypeError("SameValueNonNumber requires two non-number values of the same type.")}return this.SameValue(e,r)}});e.exports=o},{"./es6":41,"./helpers/assign":43}],43:[function(t,e,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],44:[function(t,e,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],45:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],46:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],47:[function(t,e,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],48:[function(t,e,r){arguments[4][23][0].apply(r,arguments)},{"./helpers/isPrimitive":50,dup:23,"is-callable":55}],49:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{"./helpers/isPrimitive":50,dup:24,"is-callable":55,"is-date-object":56,"is-symbol":58}],50:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],51:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],52:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],53:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":52,dup:28}],54:[function(t,e,r){var n=t("function-bind");e.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},{"function-bind":53}],55:[function(t,e,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],56:[function(t,e,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],57:[function(t,e,r){arguments[4][31][0].apply(r,arguments)},{dup:31}],58:[function(t,e,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],59:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":60,dup:33}],60:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],61:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){return typeof Object.entries==="function"?Object.entries:n}},{"./implementation":37}],62:[function(t,e,r){"use strict";var n=t("./polyfill");var i=t("define-properties");e.exports=function t(){var e=n();i(Object,{entries:e},{entries:function(){return Object.entries!==e}});return e}},{"./polyfill":61,"define-properties":39}],63:[function(t,e,r){"use strict";var n=t("es-abstract/es7");var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.getOwnPropertySymbols;var a=Function.call.bind(Array.prototype.concat);var l=Function.call.bind(Array.prototype.reduce);var s=u?function(t){return a(p(t),u(t))}:p;var c=n.IsCallable(o)&&n.IsCallable(p);var f=function t(e,r,n){if(i&&r in e){i(e,r,{configurable:true,enumerable:true,value:n,writable:true})}else{e[r]=n}};e.exports=function t(e){n.RequireObjectCoercible(e);if(!c){throw new TypeError("getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor")}var r=n.ToObject(e);return l(s(r),function(t,e){f(t,e,o(r,e));return t},{})}},{"es-abstract/es7":68}],64:[function(t,e,r){arguments[4][38][0].apply(r,arguments)},{"./implementation":63,"./polyfill":86,"./shim":87,"define-properties":65,dup:38}],65:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:77,"object-keys":84}],66:[function(t,e,r){arguments[4][16][0].apply(r,arguments)},{"./helpers/isFinite":70,"./helpers/mod":72,"./helpers/sign":73,dup:16,"es-to-primitive/es5":74,"is-callable":80}],67:[function(t,e,r){arguments[4][17][0].apply(r,arguments)},{"./es5":66,"./helpers/assign":69,"./helpers/isFinite":70,"./helpers/isPrimitive":71,"./helpers/mod":72,"./helpers/sign":73,dup:17,"es-to-primitive/es6":75,"function-bind":79,"is-regex":82}],68:[function(t,e,r){arguments[4][42][0].apply(r,arguments)},{"./es6":67,"./helpers/assign":69,dup:42}],69:[function(t,e,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],70:[function(t,e,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],71:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],72:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],73:[function(t,e,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],74:[function(t,e,r){arguments[4][23][0].apply(r,arguments)},{"./helpers/isPrimitive":76,dup:23,"is-callable":80}],75:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{"./helpers/isPrimitive":76,dup:24,"is-callable":80,"is-date-object":81,"is-symbol":83}],76:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],77:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],78:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],79:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":78,dup:28}],80:[function(t,e,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],81:[function(t,e,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],82:[function(t,e,r){arguments[4][31][0].apply(r,arguments)},{dup:31}],83:[function(t,e,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],84:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":85,dup:33}],85:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],86:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){return typeof Object.getOwnPropertyDescriptors==="function"?Object.getOwnPropertyDescriptors:n}},{"./implementation":63}],87:[function(t,e,r){"use strict";var n=t("./polyfill");var i=t("define-properties");e.exports=function t(){var e=n();i(Object,{getOwnPropertyDescriptors:e},{getOwnPropertyDescriptors:function(){return Object.getOwnPropertyDescriptors!==e}});return e}},{"./polyfill":86,"define-properties":65}],88:[function(t,e,r){"use strict";var n=t("es-abstract/es7");var i=t("has");var o=t("function-bind");var p=o.call(Function.call,Object.prototype.propertyIsEnumerable);e.exports=function t(e){var r=n.RequireObjectCoercible(e);var o=[];for(var u in r){if(i(r,u)&&p(r,u)){o.push(r[u])}}return o}},{"es-abstract/es7":93,"function-bind":104,has:105}],89:[function(t,e,r){arguments[4][38][0].apply(r,arguments)},{"./implementation":88,"./polyfill":112,"./shim":113,"define-properties":90,dup:38}],90:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:102,"object-keys":110}],91:[function(t,e,r){arguments[4][16][0].apply(r,arguments)},{"./helpers/isFinite":95,"./helpers/mod":97,"./helpers/sign":98,dup:16,"es-to-primitive/es5":99,"is-callable":106}],92:[function(t,e,r){arguments[4][17][0].apply(r,arguments)},{"./es5":91,"./helpers/assign":94,"./helpers/isFinite":95,"./helpers/isPrimitive":96,"./helpers/mod":97,"./helpers/sign":98,dup:17,"es-to-primitive/es6":100,"function-bind":104,"is-regex":108}],93:[function(t,e,r){arguments[4][42][0].apply(r,arguments)},{"./es6":92,"./helpers/assign":94,dup:42}],94:[function(t,e,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],95:[function(t,e,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],96:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],97:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],98:[function(t,e,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],99:[function(t,e,r){arguments[4][23][0].apply(r,arguments)},{"./helpers/isPrimitive":101,dup:23,"is-callable":106}],100:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{"./helpers/isPrimitive":101,dup:24,"is-callable":106,"is-date-object":107,"is-symbol":109}],101:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],102:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],103:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],104:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":103,dup:28}],105:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{dup:54,"function-bind":104}],106:[function(t,e,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],107:[function(t,e,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],108:[function(t,e,r){arguments[4][31][0].apply(r,arguments)},{dup:31}],109:[function(t,e,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],110:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":111,dup:33}],111:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],112:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){return typeof Object.values==="function"?Object.values:n}},{"./implementation":88}],113:[function(t,e,r){"use strict";var n=t("./polyfill");var i=t("define-properties");e.exports=function t(){var e=n();i(Object,{values:e},{values:function(){return Object.values!==e}});return e}},{"./polyfill":112,"define-properties":90}],114:[function(t,e,r){"use strict";var n=t("define-properties");var i=t("es-abstract/es7");var o=t("function-bind");var p=function t(e){i.RequireObjectCoercible(this);var r=i.ToObject(this);var n=i.ToString(r);var o=i.ToInteger(e);var p=n.length;if(o<0||o>=p){return""}var u=n.charCodeAt(o);var a;var l=o+1;var s=1;var c=u>=55296&&u<=56319;if(c&&p>l){a=n.charCodeAt(l);if(a>=56320&&a<=57343){s=2}}return n.slice(o,o+s)};var u=o.call(Function.call,p);n(u,{method:p,shim:function t(){n(String.prototype,{at:p});return String.prototype.at}});e.exports=u},{"define-properties":115,"es-abstract/es7":118,"function-bind":129}],115:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:127,"object-keys":134}],116:[function(t,e,r){arguments[4][16][0].apply(r,arguments)},{"./helpers/isFinite":120,"./helpers/mod":122,"./helpers/sign":123,dup:16,"es-to-primitive/es5":124,"is-callable":130}],117:[function(t,e,r){arguments[4][17][0].apply(r,arguments)},{"./es5":116,"./helpers/assign":119,"./helpers/isFinite":120,"./helpers/isPrimitive":121,"./helpers/mod":122,"./helpers/sign":123,dup:17,"es-to-primitive/es6":125,"function-bind":129,"is-regex":132}],118:[function(t,e,r){arguments[4][42][0].apply(r,arguments)},{"./es6":117,"./helpers/assign":119,dup:42}],119:[function(t,e,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],120:[function(t,e,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],121:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],122:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],123:[function(t,e,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],124:[function(t,e,r){arguments[4][23][0].apply(r,arguments)},{"./helpers/isPrimitive":126,dup:23,"is-callable":130}],125:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{"./helpers/isPrimitive":126,dup:24,"is-callable":130,"is-date-object":131,"is-symbol":133}],126:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],127:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],128:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],129:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":128,dup:28}],130:[function(t,e,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],131:[function(t,e,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],132:[function(t,e,r){arguments[4][31][0].apply(r,arguments)},{dup:31}],133:[function(t,e,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],134:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":135,dup:33}],135:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],136:[function(t,e,r){"use strict";var n=t("function-bind");var i=t("es-abstract/es7");var o=n.call(Function.call,String.prototype.slice);e.exports=function t(e){var r=i.RequireObjectCoercible(this);var n=i.ToString(r);var p=i.ToLength(n.length);var u;if(arguments.length>1){u=arguments[1]}var a=typeof u==="undefined"?"":i.ToString(u);if(a===""){a=" "}var l=i.ToLength(e);if(l<=p){return n}var s=l-p;while(a.lengthf?o(a,0,f):a}var y=a.length>s?o(a,0,s):a;return n+y}},{"es-abstract/es7":141,"function-bind":152}],137:[function(t,e,r){"use strict";var n=t("function-bind");var i=t("define-properties");var o=t("es-abstract/es7");var p=t("./implementation");var u=t("./polyfill");var a=t("./shim");var l=n.call(Function.apply,p);var s=function t(e,r){o.RequireObjectCoercible(e);var n=[r];if(arguments.length>2){n.push(arguments[2])}return l(e,n)};i(s,{getPolyfill:u,implementation:p,shim:a});e.exports=s},{"./implementation":136,"./polyfill":159,"./shim":160,"define-properties":138,"es-abstract/es7":141,"function-bind":152}],138:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:150,"object-keys":157}],139:[function(t,e,r){arguments[4][16][0].apply(r,arguments)},{"./helpers/isFinite":143,"./helpers/mod":145,"./helpers/sign":146,dup:16,"es-to-primitive/es5":147,"is-callable":153}],140:[function(t,e,r){arguments[4][17][0].apply(r,arguments)},{"./es5":139,"./helpers/assign":142,"./helpers/isFinite":143,"./helpers/isPrimitive":144,"./helpers/mod":145,"./helpers/sign":146,dup:17,"es-to-primitive/es6":148,"function-bind":152,"is-regex":155}],141:[function(t,e,r){arguments[4][42][0].apply(r,arguments)},{"./es6":140,"./helpers/assign":142,dup:42}],142:[function(t,e,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],143:[function(t,e,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],144:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],145:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],146:[function(t,e,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],147:[function(t,e,r){arguments[4][23][0].apply(r,arguments)},{"./helpers/isPrimitive":149,dup:23,"is-callable":153}],148:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{"./helpers/isPrimitive":149,dup:24,"is-callable":153,"is-date-object":154,"is-symbol":156}],149:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],150:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],151:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],152:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":151,dup:28}],153:[function(t,e,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],154:[function(t,e,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],155:[function(t,e,r){arguments[4][31][0].apply(r,arguments)},{dup:31}],156:[function(t,e,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],157:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":158,dup:33}],158:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],159:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){return typeof String.prototype.padEnd==="function"?String.prototype.padEnd:n}},{"./implementation":136}],160:[function(t,e,r){"use strict";var n=t("./polyfill");var i=t("define-properties");e.exports=function t(){var e=n();i(String.prototype,{padEnd:e},{padEnd:function(){return String.prototype.padEnd!==e}});return e}},{"./polyfill":159,"define-properties":138}],161:[function(t,e,r){"use strict";var n=t("function-bind");var i=t("es-abstract/es7");var o=n.call(Function.call,String.prototype.slice);e.exports=function t(e){var r=i.RequireObjectCoercible(this);var n=i.ToString(r);var p=i.ToLength(n.length);var u;if(arguments.length>1){u=arguments[1]}var a=typeof u==="undefined"?"":i.ToString(u);if(a===""){a=" "}var l=i.ToLength(e);if(l<=p){return n}var s=l-p;while(a.lengthf?o(a,0,f):a}var y=a.length>s?o(a,0,s):a;return y+n}},{"es-abstract/es7":166,"function-bind":177}],162:[function(t,e,r){"use strict";var n=t("function-bind");var i=t("define-properties");var o=t("es-abstract/es7");var p=t("./implementation");var u=t("./polyfill");var a=t("./shim");var l=n.call(Function.apply,p);var s=function t(e,r){o.RequireObjectCoercible(e);var n=[r];if(arguments.length>2){
7 | n.push(arguments[2])}return l(e,n)};i(s,{getPolyfill:u,implementation:p,shim:a});e.exports=s},{"./implementation":161,"./polyfill":184,"./shim":185,"define-properties":163,"es-abstract/es7":166,"function-bind":177}],163:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:175,"object-keys":182}],164:[function(t,e,r){arguments[4][16][0].apply(r,arguments)},{"./helpers/isFinite":168,"./helpers/mod":170,"./helpers/sign":171,dup:16,"es-to-primitive/es5":172,"is-callable":178}],165:[function(t,e,r){arguments[4][17][0].apply(r,arguments)},{"./es5":164,"./helpers/assign":167,"./helpers/isFinite":168,"./helpers/isPrimitive":169,"./helpers/mod":170,"./helpers/sign":171,dup:17,"es-to-primitive/es6":173,"function-bind":177,"is-regex":180}],166:[function(t,e,r){arguments[4][42][0].apply(r,arguments)},{"./es6":165,"./helpers/assign":167,dup:42}],167:[function(t,e,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],168:[function(t,e,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],169:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],170:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],171:[function(t,e,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],172:[function(t,e,r){arguments[4][23][0].apply(r,arguments)},{"./helpers/isPrimitive":174,dup:23,"is-callable":178}],173:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{"./helpers/isPrimitive":174,dup:24,"is-callable":178,"is-date-object":179,"is-symbol":181}],174:[function(t,e,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],175:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],176:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],177:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":176,dup:28}],178:[function(t,e,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],179:[function(t,e,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],180:[function(t,e,r){arguments[4][31][0].apply(r,arguments)},{dup:31}],181:[function(t,e,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],182:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":183,dup:33}],183:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],184:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){return typeof String.prototype.padStart==="function"?String.prototype.padStart:n}},{"./implementation":161}],185:[function(t,e,r){"use strict";var n=t("./polyfill");var i=t("define-properties");e.exports=function t(){var e=n();i(String.prototype,{padStart:e},{padStart:function(){return String.prototype.padStart!==e}});return e}},{"./polyfill":184,"define-properties":163}],186:[function(t,e,r){"use strict";var n=t("function-bind");var i=n.call(Function.call,String.prototype.replace);var o=/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*/;e.exports=function t(){return i(this,o,"")}},{"function-bind":191}],187:[function(t,e,r){"use strict";var n=t("function-bind");var i=t("define-properties");var o=t("./implementation");var p=t("./polyfill");var u=t("./shim");var a=n.call(Function.call,p());i(a,{getPolyfill:p,implementation:o,shim:u});e.exports=a},{"./implementation":186,"./polyfill":194,"./shim":195,"define-properties":188,"function-bind":191}],188:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:189,"object-keys":192}],189:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],190:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],191:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":190,dup:28}],192:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":193,dup:33}],193:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],194:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){if(!String.prototype.trimLeft){return n}var e="\u200b";if(e.trimLeft()!==e){return n}return String.prototype.trimLeft}},{"./implementation":186}],195:[function(t,e,r){"use strict";var n=t("define-properties");var i=t("./polyfill");e.exports=function t(){var e=i();n(String.prototype,{trimLeft:e},{trimLeft:function(){return String.prototype.trimLeft!==e}});return e}},{"./polyfill":194,"define-properties":188}],196:[function(t,e,r){"use strict";var n=t("function-bind");var i=n.call(Function.call,String.prototype.replace);var o=/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*$/;e.exports=function t(){return i(this,o,"")}},{"function-bind":201}],197:[function(t,e,r){arguments[4][187][0].apply(r,arguments)},{"./implementation":196,"./polyfill":204,"./shim":205,"define-properties":198,dup:187,"function-bind":201}],198:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15,foreach:199,"object-keys":202}],199:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],200:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],201:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{"./implementation":200,dup:28}],202:[function(t,e,r){arguments[4][33][0].apply(r,arguments)},{"./isArguments":203,dup:33}],203:[function(t,e,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],204:[function(t,e,r){"use strict";var n=t("./implementation");e.exports=function t(){if(!String.prototype.trimRight){return n}var e="\u200b";if(e.trimRight()!==e){return n}return String.prototype.trimRight}},{"./implementation":196}],205:[function(t,e,r){"use strict";var n=t("define-properties");var i=t("./polyfill");e.exports=function t(){var e=i();n(String.prototype,{trimRight:e},{trimRight:function(){return String.prototype.trimRight!==e}});return e}},{"./polyfill":204,"define-properties":198}],206:[function(t,e,r){"use strict";e.exports=t("./es7-shim").shim()},{"./es7-shim":12}]},{},[206]);
8 | //# sourceMappingURL=dist/es7-shim.map
9 |
--------------------------------------------------------------------------------
/tests/ionic-tests.ts:
--------------------------------------------------------------------------------
1 | // TODO: make it real test
2 |
3 | import { PhotoLibrary, LibraryItem } from 'ionic-native';
4 |
5 | class Test {
6 |
7 | test () {
8 |
9 | PhotoLibrary.requestAuthorization({ read: true, write: true })
10 | .then(() => {
11 | console.log('permission granted');
12 | return this.getLibrary();
13 | })
14 | .then((library: LibraryItem[]) => {
15 | return this.getThumbnailURL(library[0]).then(() => library);
16 | })
17 | .then((library: LibraryItem[]) => {
18 | return this.getPhotoURL(library[0]).then(() => library);
19 | })
20 | .then((library: LibraryItem[]) => {
21 | return this.getThumbnail(library[0]).then(() => library);
22 | })
23 | .then((library: LibraryItem[]) => {
24 | return this.getPhoto(library[0]).then(() => library);
25 | })
26 | .then(() => {
27 | return this.getAlbums();
28 | })
29 | .then(() => {
30 | return this.saveImage();
31 | })
32 | .catch(err => {
33 | console.log(err);
34 | });
35 |
36 | }
37 |
38 | getLibrary() {
39 | return new Promise((resolve, reject) => {
40 | let library = [];
41 | PhotoLibrary.getLibrary({ itemsInChunk: 1000 }).subscribe({
42 | next: chunk => {
43 | console.log(`chunk arrived: ${chunk.length}`);
44 | library = library.concat(chunk);
45 | }, error: err => {
46 | console.log('getLibrary error: ' + err);
47 | reject(err);
48 | }, complete: () => {
49 | console.log(`completed: ${library.length}`);
50 | resolve(library);
51 | }
52 | });
53 | });
54 | }
55 |
56 | getAlbums() {
57 | return PhotoLibrary.getAlbums().then(albums => {
58 | albums.forEach(album => console.log(JSON.stringify(album)));
59 | });
60 | }
61 |
62 | getThumbnailURL(libraryItem: LibraryItem) {
63 | return PhotoLibrary.getThumbnailURL(libraryItem).then(url => console.log(url));
64 | }
65 |
66 | getPhotoURL(libraryItem: LibraryItem) {
67 | return PhotoLibrary.getPhotoURL(libraryItem).then(url => console.log(url));
68 | }
69 |
70 | getThumbnail(libraryItem: LibraryItem) {
71 | return PhotoLibrary.getThumbnail(libraryItem).then(url => console.log(url));
72 | }
73 |
74 | getPhoto(libraryItem: LibraryItem) {
75 | return PhotoLibrary.getPhoto(libraryItem).then(url => console.log(url));
76 | }
77 |
78 | saveImage() {
79 | var canvas = document.createElement('canvas');
80 | canvas.width = 150;
81 | canvas.height = 150;
82 | var ctx = canvas.getContext('2d');
83 | ctx.fillRect(25, 25, 100, 100);
84 | ctx.clearRect(45, 45, 60, 60);
85 | ctx.strokeRect(50, 50, 50, 50);
86 | var dataURL = canvas.toDataURL('image/jpg');
87 |
88 | return PhotoLibrary.saveImage(dataURL, 'ionic-native').then(libraryItem => console.log(JSON.stringify(libraryItem)));
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/tests/ios/get-booted-simulator.sh:
--------------------------------------------------------------------------------
1 | xcrun simctl list | grep Booted | awk -F "[()]" '{ for (i=2; i
2 |
6 | Photo Library Tests
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/tests/test-images/Landscape_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_1.jpg
--------------------------------------------------------------------------------
/tests/test-images/Landscape_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_2.jpg
--------------------------------------------------------------------------------
/tests/test-images/Landscape_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_3.jpg
--------------------------------------------------------------------------------
/tests/test-images/Landscape_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_4.jpg
--------------------------------------------------------------------------------
/tests/test-images/Landscape_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_5.jpg
--------------------------------------------------------------------------------
/tests/test-images/Landscape_6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_6.jpg
--------------------------------------------------------------------------------
/tests/test-images/Landscape_7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_7.jpg
--------------------------------------------------------------------------------
/tests/test-images/Landscape_8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Landscape_8.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_1.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_2.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_3.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_4.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_5.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_6.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_7.jpg
--------------------------------------------------------------------------------
/tests/test-images/Portrait_8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/Portrait_8.jpg
--------------------------------------------------------------------------------
/tests/test-images/geotagged.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmarkclx/cordova-plugin-photo-library-sism/aa0b7cdd08cccbea94aecea0fa082d8e7bc6d6b1/tests/test-images/geotagged.jpg
--------------------------------------------------------------------------------
/tests/test-utils.js:
--------------------------------------------------------------------------------
1 | exports.resolveLocalFileSystemURL = function (fileSystem) {
2 |
3 | return new Promise(function (resolve, reject) {
4 |
5 | window.resolveLocalFileSystemURL(fileSystem, resolve, reject);
6 |
7 | });
8 |
9 | };
10 |
11 | exports.createFile = function (dirEntry, fileName) {
12 |
13 | return new Promise(function (resolve, reject) {
14 |
15 | dirEntry.getFile(fileName, {create: true, exclusive: false}, resolve, reject);
16 |
17 | });
18 |
19 | };
20 |
21 | exports.writeFile = function (fileEntry, dataObj) {
22 |
23 | return new Promise(function (resolve, reject) {
24 |
25 | fileEntry.createWriter(function (fileWriter) {
26 |
27 | fileWriter.onwriteend = function () { resolve (fileEntry); };
28 | fileWriter.onerror = reject;
29 |
30 | fileWriter.write(dataObj);
31 |
32 | });
33 |
34 | });
35 |
36 | };
37 |
--------------------------------------------------------------------------------
/tests/tests.js:
--------------------------------------------------------------------------------
1 | // Tests should be written on JavaScript version that supported on both iOS and Android WebView (no lambdas).
2 | // But functionality provided by esshims can be used :)
3 |
4 | // Include shims for useful javascript functions to work on all devices
5 | cordova.require('cordova-plugin-photo-library-tests.es5-shim');
6 | cordova.require('cordova-plugin-photo-library-tests.es6-shim');
7 | cordova.require('cordova-plugin-photo-library-tests.es7-shim');
8 | cordova.require('cordova-plugin-photo-library-tests.blueimp-canvastoblob');
9 |
10 | var testUtils = cordova.require('cordova-plugin-photo-library-tests.test-utils');
11 |
12 | var expectedImages = [
13 | { fileName: 'Landscape_1.jpg', width: 600, height: 450, },
14 | { fileName: 'Landscape_2.jpg', width: 600, height: 450, },
15 | { fileName: 'Landscape_3.jpg', width: 600, height: 450, },
16 | { fileName: 'Landscape_4.jpg', width: 600, height: 450, },
17 | { fileName: 'Landscape_5.jpg', width: 600, height: 450, },
18 | { fileName: 'Landscape_6.jpg', width: 600, height: 450, },
19 | { fileName: 'Landscape_7.jpg', width: 600, height: 450, },
20 | { fileName: 'Landscape_8.jpg', width: 600, height: 450, },
21 | { fileName: 'Portrait_1.jpg', width: 450, height: 600, },
22 | { fileName: 'Portrait_2.jpg', width: 450, height: 600, },
23 | { fileName: 'Portrait_3.jpg', width: 450, height: 600, },
24 | { fileName: 'Portrait_4.jpg', width: 450, height: 600, },
25 | { fileName: 'Portrait_5.jpg', width: 450, height: 600, },
26 | { fileName: 'Portrait_6.jpg', width: 450, height: 600, },
27 | { fileName: 'Portrait_7.jpg', width: 450, height: 600, },
28 | { fileName: 'Portrait_8.jpg', width: 450, height: 600, },
29 | ];
30 |
31 | exports.defineAutoTests = function () {
32 |
33 | // Configure jasmine
34 | var jasmineEnv = jasmine.getEnv();
35 | jasmineEnv.catchExceptions(true); // without this, syntax error will hang a test, instead of reporting it failed
36 |
37 | describe('cordova.plugins', function () {
38 |
39 | it('photoLibrary should exist', function () {
40 | expect(cordova.plugins.photoLibrary).toBeDefined();
41 | });
42 |
43 | describe('cordova.plugins.photoLibrary', function () {
44 |
45 | var library = null;
46 | var libraryError = null;
47 | var getLibraryResultCalledTimes = 0;
48 | var getLibraryIsLastChunk = null;
49 |
50 | beforeAll(function (done) {
51 | cordova.plugins.photoLibrary.getLibrary(function (result) {
52 | library = result.library;
53 | getLibraryResultCalledTimes += 1;
54 | getLibraryIsLastChunk = result.isLastChunk;
55 | done();
56 | },
57 | function (err) {
58 | libraryError = err;
59 | done.fail(err);
60 | },
61 | {
62 | useOriginalFileNames: true, // We want to compare file names in test
63 | includeAlbumData: true, // We want to check albums
64 | });
65 | }, 20000); // In browser platform, gives a time to select photos.
66 |
67 | it('should not fail', function () {
68 | expect(libraryError).toBeNull('getLibrary failed with error: ' + libraryError);
69 | });
70 |
71 | it('should load library', function () {
72 | expect(library).not.toBeNull();
73 | });
74 |
75 | it('result callback should be executed exactly once', function () {
76 | expect(getLibraryResultCalledTimes).toEqual(1);
77 | });
78 |
79 | it('result callback should be treated as last chunk', function () {
80 | expect(getLibraryIsLastChunk).toBeTruthy();
81 | });
82 |
83 | describe('cordova.plugins.photoLibrary.getAlbums', function () {
84 |
85 | var albums = null;
86 | var getAlbumsError = null;
87 |
88 | beforeAll(function (done) {
89 | cordova.plugins.photoLibrary.getAlbums(function (albs) {
90 | albums = albs;
91 | done();
92 | },
93 | function (err) {
94 | getAlbumsError = err;
95 | done.fail(err);
96 | });
97 | });
98 |
99 | it('should not fail', function() {
100 | expect(getAlbumsError).toBeNull('getAlbums failed with error: ' + getAlbumsError);
101 | });
102 |
103 | it('should return an array', function() {
104 | expect(albums).toEqual(jasmine.any(Array));
105 | });
106 |
107 | it('shoud return at least one album', function() {
108 | expect(albums.length).toBeGreaterThan(0);
109 | });
110 |
111 | });
112 |
113 | describe('cordova.plugins.photoLibrary.getLibrary', function () {
114 |
115 | it('should return multiple photos', function () {
116 | expect(library.length).toBeGreaterThan(0);
117 | });
118 |
119 | expectedImages.forEach(function (expectedImage) {
120 |
121 | describe('test-images/' + expectedImage.fileName, function () {
122 |
123 | beforeEach(function () {
124 | this.libraryItem = library.find(function (libraryItem) { return libraryItem.fileName === expectedImage.fileName });
125 | });
126 |
127 | it('should exist', function () {
128 | expect(this.libraryItem).toBeDefined();
129 | });
130 |
131 | it('should have not-empty id', function () {
132 | expect(this.libraryItem.id).toEqual(jasmine.any(String));
133 | expect(this.libraryItem.id.length).not.toEqual(0);
134 | });
135 |
136 | it('should have not-empty photoURL', function () {
137 | expect(this.libraryItem.photoURL).toEqual(jasmine.any(String));
138 | expect(this.libraryItem.photoURL.length).not.toEqual(0);
139 | });
140 |
141 | it('should have not-empty thumbnailURL', function () {
142 | expect(this.libraryItem.thumbnailURL).toEqual(jasmine.any(String));
143 | expect(this.libraryItem.thumbnailURL.length).not.toEqual(0);
144 | });
145 |
146 | it('should have right width', function () {
147 | expect(this.libraryItem.width).toBe(expectedImage.width);
148 | });
149 |
150 | it('should have right height', function () {
151 | expect(this.libraryItem.height).toBe(expectedImage.height);
152 | });
153 |
154 | it('should have creationDate', function () {
155 | expect(this.libraryItem.creationDate).toEqual(jasmine.any(Date));
156 | expect(this.libraryItem.creationDate.getFullYear()).toBeGreaterThan(2015);
157 | });
158 |
159 | it('should have albumIds array', function() {
160 | expect(this.libraryItem.albumIds).toEqual(jasmine.any(Array));
161 | });
162 |
163 | it('albumIds array should contain at least one album', function() {
164 | expect(this.libraryItem.albumIds.length).toBeGreaterThan(0);
165 | });
166 |
167 | });
168 |
169 | });
170 |
171 | describe('geotagged image', function() {
172 |
173 | beforeEach(function () {
174 | this.libraryItem = library.find(function (libraryItem) { return libraryItem.fileName === 'geotagged.jpg'; });
175 | });
176 |
177 | it('should have correct latitude', function() {
178 | expect(this.libraryItem.latitude).toBeCloseTo(32.517078, 5); // 32' 31'' 1.482'''
179 | });
180 |
181 | it('should have correct longitude', function() {
182 | expect(this.libraryItem.longitude).toBeCloseTo(34.955096, 5); // 34' 57'' 18.348'''
183 | });
184 |
185 | });
186 |
187 | });
188 |
189 | describe('cordova.plugins.photoLibrary.getThumbnailURL', function () {
190 |
191 | var thumbnailURL = null;
192 | var getThumbnailURLError = null;
193 |
194 | beforeAll(function (done) {
195 | cordova.plugins.photoLibrary.getThumbnailURL(
196 | library[0],
197 | function (url) {
198 | thumbnailURL = url;
199 | done();
200 | },
201 | function (err) {
202 | getThumbnailURLError = err;
203 | done.fail(err);
204 | }, {
205 | thumbnailWidth: 123,
206 | thumbnailHeight: 234,
207 | quality: 0.25
208 | });
209 | });
210 |
211 | it('should not fail', function () {
212 | expect(getThumbnailURLError).toBeNull('failed with error: ' + getThumbnailURLError);
213 | });
214 |
215 | it('should return non-empty url', function () {
216 | expect(thumbnailURL).toEqual(jasmine.any(String));
217 | expect(thumbnailURL.length).not.toEqual(0);
218 | });
219 |
220 | it('thumbnailURL should contain requested width', function () {
221 | expect(thumbnailURL).toContain('width=123');
222 | });
223 |
224 | it('thumbnailURL should contain requested height', function () {
225 | expect(thumbnailURL).toContain('height=234');
226 | });
227 |
228 | it('thumbnailURL should contain requested quality', function () {
229 | expect(thumbnailURL).toContain('quality=0.25');
230 | });
231 |
232 | });
233 |
234 | describe('cordova.plugins.photoLibrary.getPhotoURL', function () {
235 |
236 | var photoURL = null;
237 | var getPhotoURLError = null;
238 |
239 | beforeAll(function (done) {
240 | cordova.plugins.photoLibrary.getPhotoURL(
241 | library[0],
242 | function (url) {
243 | photoURL = url;
244 | done();
245 | },
246 | function (err) {
247 | getPhotoURLError = err;
248 | done.fail(err);
249 | });
250 | });
251 |
252 | it('should not fail', function () {
253 | expect(getPhotoURLError).toBeNull('failed with error: ' + getPhotoURLError);
254 | });
255 |
256 | it('should return non-empty url', function () {
257 | expect(photoURL).toEqual(jasmine.any(String));
258 | expect(photoURL.length).not.toEqual(0);
259 | });
260 |
261 | });
262 |
263 | describe('cordova.plugins.photoLibrary.getThumbnail', function () {
264 |
265 | var thumbnailBlob = null;
266 | var getThumbnailError = null;
267 |
268 | beforeAll(function (done) {
269 | cordova.plugins.photoLibrary.getThumbnail(
270 | library[0].id,
271 | function (blob) {
272 | thumbnailBlob = blob;
273 | done();
274 | },
275 | function (err) {
276 | getThumbnailError = err;
277 | done.fail(err);
278 | }, {
279 | thumbnailWidth: 123,
280 | thumbnailHeight: 234,
281 | quality: 0.25
282 | });
283 | });
284 |
285 | it('should not fail', function () {
286 | expect(getThumbnailError).toBeNull('failed with error: ' + getThumbnailError);
287 | });
288 |
289 | it('should return non-empty blob', function () {
290 | expect(thumbnailBlob).toEqual(jasmine.any(Blob));
291 | expect(thumbnailBlob.size).not.toEqual(0);
292 | });
293 |
294 | describe('thumbnailBlob', function () {
295 |
296 | var imageObj;
297 |
298 | beforeAll(function (done) {
299 | imageObj = new Image();
300 | imageObj.onload = function () {
301 | done();
302 | };
303 | var dataURL = URL.createObjectURL(thumbnailBlob);
304 | imageObj.src = dataURL;
305 | });
306 |
307 | it('width should be as requested', function () {
308 | expect(imageObj.width).toBe(123);
309 | });
310 |
311 | it('height should be as requested', function () {
312 | expect(imageObj.height).toBe(234);
313 | });
314 |
315 | });
316 |
317 | });
318 |
319 | describe('cordova.plugins.photoLibrary.getPhoto', function () {
320 |
321 | var photoBlob = null;
322 | var getPhotoError = null;
323 |
324 | beforeAll(function (done) {
325 | cordova.plugins.photoLibrary.getPhoto(
326 | library[0],
327 | function (blob) {
328 | photoBlob = blob;
329 | done();
330 | },
331 | function (err) {
332 | getPhotoError = err;
333 | done.fail(err);
334 | });
335 | });
336 |
337 | it('should not fail', function () {
338 | expect(getPhotoError).toBeNull('failed with error: ' + getPhotoError);
339 | });
340 |
341 | it('should return non-empty blob', function () {
342 | expect(photoBlob).toEqual(jasmine.any(Blob));
343 | expect(photoBlob.size).not.toEqual(0);
344 | });
345 |
346 | });
347 |
348 | describe('cordova.plugins.photoLibrary.requestAuthorization', function () {
349 |
350 | it('should be defined', function () {
351 | expect(cordova.plugins.photoLibrary.requestAuthorization).toEqual(jasmine.any(Function));
352 | });
353 |
354 | // Use manual tests to check it working
355 |
356 | });
357 |
358 | var chunkOptionsArray = [{itemsInChunk: 1, chunkTimeSec: 0}, {itemsInChunk: 0, chunkTimeSec: 0.000000001}];
359 |
360 | chunkOptionsArray.forEach(function (chunkOptions) {
361 |
362 | describe('chunked output by ' + (chunkOptions.itemsInChunk > 0? 'itemsInChunk' : 'chunkTimeSec'), function () {
363 | var libraryChunks = [];
364 | var chunkedError = null;
365 |
366 | beforeAll(function (done) {
367 | cordova.plugins.photoLibrary.getLibrary(function (result) {
368 | libraryChunks.push(result.library);
369 | if (result.isLastChunk) {
370 | done();
371 | }
372 | },
373 | function (err) {
374 | chunkedError = err;
375 | done.fail(err);
376 | },
377 | {
378 | itemsInChunk: chunkOptions.itemsInChunk,
379 | chunkTimeSec: chunkOptions.chunkTimeSec,
380 | useOriginalFileNames: true,
381 | });
382 | }, 20000); // In browser platform, gives a time to select photos.
383 |
384 | it('should not fail', function () {
385 | expect(chunkedError).toBeNull('chunked getLibrary failed with error: ' + chunkedError);
386 | });
387 |
388 | if (chunkOptions.itemsInChunk > 0) {
389 | it('should return correct number of chunks', function () {
390 | expect(libraryChunks.length).toEqual(library.length);
391 | });
392 | }
393 |
394 | if (chunkOptions.chunkTimeSec > 0) {
395 | it('should return multiple chunks', function () {
396 | expect(libraryChunks.length).toBeGreaterThan(0);
397 | });
398 | }
399 |
400 | it('should return same photos in chunks as without chunks', function () {
401 | var unchunkedNames = library.map(function(item) { return item.id; });
402 | var flattenedChunks = [].concat.apply([], libraryChunks);
403 | var chunkedNames = flattenedChunks.map(function(item) { return item.id; });
404 | expect(chunkedNames).toEqual(unchunkedNames);
405 | });
406 |
407 | });
408 |
409 | });
410 |
411 | });
412 |
413 | describe('cordova.plugins.photoLibrary.saveImage', function () {
414 |
415 | it('should be defined', function () {
416 | expect(cordova.plugins.photoLibrary.saveImage).toEqual(jasmine.any(Function));
417 | });
418 |
419 | describe('saving image as dataURL', function() {
420 |
421 | var saveImageLibraryItem = null;
422 | var saveImageError = null;
423 |
424 | beforeAll(function(done) {
425 | var canvas = document.createElement('canvas');
426 | canvas.width = 150;
427 | canvas.height = 150;
428 | var ctx = canvas.getContext('2d');
429 | ctx.fillRect(25, 25, 100, 100);
430 | ctx.clearRect(45, 45, 60, 60);
431 | ctx.strokeRect(50, 50, 50, 50);
432 | var dataURL = canvas.toDataURL('image/jpg');
433 |
434 | cordova.plugins.photoLibrary.saveImage(dataURL, 'PhotoLibraryTests',
435 | function(libraryItem) {
436 | saveImageLibraryItem = libraryItem;
437 | done();
438 | },
439 | function(err) {
440 | saveImageError = err;
441 | done.fail(err);
442 | });
443 | });
444 |
445 | it('should not fail', function() {
446 | expect(saveImageError).toBeNull('failed with error: ' + saveImageError);
447 | });
448 |
449 | it('should return valid library item', function() {
450 | expect(saveImageLibraryItem).not.toBeNull();
451 | expect(saveImageLibraryItem.id).toBeDefined();
452 | });
453 |
454 | });
455 |
456 | describe('saving image from local URL', function() {
457 |
458 | var saveImageLibraryItem = null;
459 | var saveImageError = null;
460 |
461 | beforeAll(function(done) {
462 | var canvas = document.createElement('canvas');
463 | canvas.width = 150;
464 | canvas.height = 150;
465 | var ctx = canvas.getContext('2d');
466 | ctx.fillRect(25, 25, 100, 100);
467 | ctx.clearRect(45, 45, 60, 60);
468 | ctx.strokeStyle = '#87CEEB'; // Sky blue
469 | ctx.strokeRect(50, 50, 50, 50);
470 |
471 | testUtils.resolveLocalFileSystemURL(cordova.file.cacheDirectory)
472 | .then(function (dirEntry) {
473 |
474 | return testUtils.createFile(dirEntry, 'test-image.jpg');
475 |
476 | })
477 | .then(function (fileEntry) {
478 |
479 | return new Promise(function (resolve, reject) {
480 | canvas.toBlob(function(blob) {
481 | resolve({fileEntry: fileEntry, blob: blob});
482 | }, 'image/jpeg');
483 | });
484 |
485 | })
486 | .then(function (result) {
487 |
488 | var fileEntry = result.fileEntry;
489 | var blob = result.blob;
490 | return testUtils.writeFile(fileEntry, blob);
491 |
492 | })
493 | .then(function(fileEntry) {
494 |
495 | var localURL = fileEntry.toURL();
496 | return new Promise(function (resolve, reject) {
497 | cordova.plugins.photoLibrary.saveImage(localURL, 'PhotoLibraryTests',
498 | function(libraryItem) {
499 | saveImageLibraryItem = libraryItem;
500 | resolve();
501 | },
502 | function(err) {
503 | saveImageError = err;
504 | reject(err);
505 | });
506 | });
507 |
508 | })
509 | .then(done)
510 | .catch(function (err) { done.fail(err); });
511 | });
512 |
513 | it('should not fail', function() {
514 | expect(saveImageError).toBeNull('failed with error: ' + saveImageError);
515 | });
516 |
517 | it('should return valid library item', function() {
518 | expect(saveImageLibraryItem).not.toBeNull();
519 | expect(saveImageLibraryItem.id).toBeDefined();
520 | });
521 |
522 | });
523 |
524 | describe('saving image from remote URL', function() {
525 |
526 | var saveImageLibraryItem = null;
527 | var saveImageError = null;
528 |
529 | beforeAll(function(done) {
530 | var remoteURL = 'http://openphoto.net/volumes/nmarchildon/20041218/opl_imgp0196.jpg';
531 |
532 | cordova.plugins.photoLibrary.saveImage(remoteURL, 'PhotoLibraryTests',
533 | function(libraryItem) {
534 | saveImageLibraryItem = libraryItem;
535 | done();
536 | },
537 | function(err) {
538 | saveImageError = err;
539 | done.fail(err);
540 | });
541 | });
542 |
543 | it('should not fail', function() {
544 | expect(saveImageError).toBeNull('failed with error: ' + saveImageError);
545 | });
546 |
547 | it('should return valid library item', function() {
548 | expect(saveImageLibraryItem).not.toBeNull();
549 | expect(saveImageLibraryItem.id).toBeDefined();
550 | });
551 |
552 | });
553 |
554 | });
555 |
556 | describe('cordova.plugins.photoLibrary.saveVideo', function () {
557 |
558 | it('should be defined', function () {
559 | expect(cordova.plugins.photoLibrary.saveVideo).toEqual(jasmine.any(Function));
560 | });
561 |
562 | // TODO: add more tests
563 |
564 | });
565 |
566 | });
567 |
568 | };
569 |
570 | exports.defineManualTests = function (contentEl, createActionButton) {
571 |
572 | var logMessage = function (message, color) {
573 | var log = document.getElementById('info');
574 | var logLine = document.createElement('div');
575 | if (color) {
576 | logLine.style.color = color;
577 | }
578 | logLine.innerHTML = message;
579 | log.appendChild(logLine);
580 | };
581 |
582 | var clearLog = function () {
583 | var log = document.getElementById('info');
584 | log.innerHTML = '';
585 | };
586 |
587 | var photo_library_tests = 'Press requestAuthorization button to authorize storage
' +
588 | '' +
589 | 'Expected result: If authorized, this fact will be logged. On iOS: settings page will open. On Android: confirmation prompt will open.' +
590 |
591 | 'Press the button to visually inspect test-images
' +
592 | '' +
593 | 'Expected result: All the images should be rotated right way' +
594 |
595 | 'Press the button to visually inspect thumbnails of test-images
' +
596 | '' +
597 | 'Expected result: All the images should be rotated right way' +
598 |
599 | 'Press the button to measure speed of getLibrary
' +
600 | '' +
601 | 'Expected result: Time per image should be adequate' +
602 |
603 | 'Press the button to display albums
' +
604 | '' +
605 | 'Expected result: Should return all the albums'
606 | ;
607 |
608 | contentEl.innerHTML = '' + photo_library_tests;
609 |
610 | createActionButton('requestAuthorization', function () {
611 | clearLog();
612 | cordova.plugins.photoLibrary.requestAuthorization(
613 | function () {
614 | logMessage('User gave us permission to his library');
615 | },
616 | function (err) {
617 | logMessage('User denied the access: ' + err);
618 | },
619 | {
620 | read: true,
621 | write: true // Needed for saveImage tests
622 | }
623 | );
624 | }, 'request_authorization');
625 |
626 | createActionButton('inspect test images', function () {
627 | clearLog();
628 | cordova.plugins.photoLibrary.getLibrary(
629 | function (result) {
630 | var found = 0;
631 | result.library.forEach(function (libraryItem) {
632 | if (expectedImages.some(function (expectedImage) { return expectedImage.fileName === libraryItem.fileName; })) {
633 | found += 1;
634 | logMessage('
');
635 | }
636 | });
637 | if (found < expectedImages.length) {
638 | logMessage('Some test-images are missing. Please put photos from test-images folder to device library.')
639 | }
640 | },
641 | function (err) {
642 | logMessage('Error occured in getLibrary: ' + err);
643 | },
644 | {
645 | useOriginalFileNames: true,
646 | }
647 | );
648 | }, 'inspect_test_images');
649 |
650 | createActionButton('inspect thumbnail test images', function () {
651 | clearLog();
652 | cordova.plugins.photoLibrary.getLibrary(
653 | function (result) {
654 | var found = 0;
655 | result.library.forEach(function (libraryItem) {
656 | if (expectedImages.some(function (expectedImage) { return expectedImage.fileName === libraryItem.fileName; })) {
657 | found += 1;
658 | logMessage('
');
659 | }
660 | });
661 | if (found < expectedImages.length) {
662 | logMessage('Some test-images are missing. Please put photos from test-images folder to device library.')
663 | }
664 | },
665 | function (err) {
666 | logMessage('Error occured in getLibrary: ' + err);
667 | },
668 | {
669 | thumbnailWidth: 256,
670 | thumbnailHeight: 256,
671 | useOriginalFileNames: true,
672 | }
673 | );
674 | }, 'inspect_thumbnail_test_images');
675 |
676 | createActionButton('measure', function () {
677 | clearLog();
678 | logMessage('measuring, please wait...');
679 | var start = performance.now();
680 | cordova.plugins.photoLibrary.getLibrary(
681 | function (result) {
682 | var library = result.library;
683 | var end = performance.now();
684 | var elapsedMs = end - start;
685 | logMessage('getLibrary returned ' + library.length + ' items.');
686 | logMessage('it took ' + Math.round(elapsedMs) + ' ms.');
687 | logMessage('time per photo is ' + Math.round(elapsedMs / library.length) + ' ms.');
688 | },
689 | function (err) {
690 | logMessage('Error occured in getLibrary: ' + err);
691 | }
692 | );
693 | }, 'measure_get_library_speed');
694 |
695 | createActionButton('display albums', function () {
696 | clearLog();
697 | cordova.plugins.photoLibrary.getAlbums(
698 | function (albums) {
699 | albums.forEach(function(album) {
700 | logMessage(JSON.stringify(album));
701 | });
702 | },
703 | function (err) {
704 | logMessage('Error occured in getAlbums: ' + err);
705 | }
706 | );
707 | }, 'display_albums');
708 |
709 | };
710 |
--------------------------------------------------------------------------------
/www/PhotoLibrary.js:
--------------------------------------------------------------------------------
1 | var exec = require('cordova/exec');
2 |
3 | var async = cordova.require('cordova-plugin-photo-library-sism.async');
4 |
5 | var defaultThumbnailWidth = 512; // optimal for android
6 | var defaultThumbnailHeight = 384; // optimal for android
7 |
8 | var defaultQuality = 0.5;
9 |
10 | var isBrowser = cordova.platformId == 'browser';
11 |
12 | var photoLibrary = {};
13 |
14 | // Will start caching for specified size
15 | photoLibrary.getLibrary = function (success, error, options) {
16 |
17 | if (!options) {
18 | options = {};
19 | }
20 |
21 | options = {
22 | thumbnailWidth: options.thumbnailWidth || defaultThumbnailWidth,
23 | thumbnailHeight: options.thumbnailHeight || defaultThumbnailHeight,
24 | quality: options.quality || defaultQuality,
25 | itemsInChunk: options.itemsInChunk || 0,
26 | chunkTimeSec: options.chunkTimeSec || 0,
27 | useOriginalFileNames: options.useOriginalFileNames || false,
28 | includeImages: options.includeImages !== undefined ? options.includeImages : true,
29 | includeAlbumData: options.includeAlbumData || false,
30 | includeCloudData: options.includeCloudData !== undefined ? options.includeCloudData : true,
31 | includeVideos: options.includeVideos || false,
32 | maxItems: options.maxItems || 0
33 | };
34 |
35 | // queue that keeps order of async processing
36 | var q = async.queue(function(chunk, done) {
37 |
38 | var library = chunk.library;
39 | var isLastChunk = chunk.isLastChunk;
40 |
41 | processLibrary(library, function(library) {
42 | var result = { library: library, isLastChunk: isLastChunk };
43 | success(result);
44 | done();
45 | }, options);
46 |
47 | });
48 |
49 | var chunksToProcess = []; // chunks are stored in its index
50 | var currentChunkNum = 0;
51 |
52 | cordova.exec(
53 | function (chunk) {
54 | // callbacks arrive from cordova.exec not in order, restoring the order here
55 | if (chunk.chunkNum === currentChunkNum) {
56 | // the chunk arrived in order
57 | q.push(chunk);
58 | currentChunkNum += 1;
59 | while (chunksToProcess[currentChunkNum]) {
60 | q.push(chunksToProcess[currentChunkNum]);
61 | delete chunksToProcess[currentChunkNum];
62 | currentChunkNum += 1;
63 | }
64 | } else {
65 | // the chunk arrived not in order
66 | chunksToProcess[chunk.chunkNum] = chunk;
67 | }
68 | },
69 | error,
70 | 'PhotoLibrary',
71 | 'getLibrary', [options]
72 | );
73 |
74 | };
75 |
76 | photoLibrary.getAlbums = function (success, error) {
77 |
78 | cordova.exec(
79 | function (result) {
80 | success(result);
81 | },
82 | error,
83 | 'PhotoLibrary',
84 | 'getAlbums', []
85 | );
86 |
87 | };
88 |
89 | photoLibrary.getPhotosFromAlbum = function (albumTitle, success, error) {
90 |
91 | cordova.exec(
92 | function (result) {
93 | success(result);
94 | },
95 | error,
96 | 'PhotoLibrary',
97 | 'getPhotosFromAlbum', [albumTitle]
98 | );
99 |
100 | };
101 |
102 | photoLibrary.isAuthorized = function (success, error) {
103 |
104 | cordova.exec(
105 | function (result) {
106 | success(result);
107 | },
108 | error,
109 | 'PhotoLibrary',
110 | 'isAuthorized', []
111 | );
112 |
113 | };
114 |
115 | // Generates url that can be accessed directly, so it will work more efficiently than getThumbnail, which does base64 encode/decode.
116 | // If success callback not provided, will return value immediately, but use overload with success as it browser-friendly
117 | photoLibrary.getThumbnailURL = function (photoIdOrLibraryItem, success, error, options) {
118 |
119 | var photoId = typeof photoIdOrLibraryItem.id !== 'undefined' ? photoIdOrLibraryItem.id : photoIdOrLibraryItem;
120 |
121 | if (typeof success !== 'function' && typeof options === 'undefined') {
122 | options = success;
123 | success = undefined;
124 | }
125 |
126 | options = getThumbnailOptionsWithDefaults(options);
127 |
128 | var urlParams = 'photoId=' + fixedEncodeURIComponent(photoId) +
129 | '&width=' + fixedEncodeURIComponent(options.thumbnailWidth) +
130 | '&height=' + fixedEncodeURIComponent(options.thumbnailHeight) +
131 | '&quality=' + fixedEncodeURIComponent(options.quality);
132 | var thumbnailURL = 'cdvphotolibrary://thumbnail?' + urlParams;
133 |
134 | if (success) {
135 | if (isBrowser) {
136 | cordova.exec(function(thumbnailURL) { success(thumbnailURL + '#' + urlParams); }, error, 'PhotoLibrary', '_getThumbnailURLBrowser', [photoId, options]);
137 | } else {
138 | success(thumbnailURL);
139 | }
140 | } else {
141 | return thumbnailURL;
142 | }
143 |
144 | };
145 |
146 | // Generates url that can be accessed directly, so it will work more efficiently than getPhoto, which does base64 encode/decode.
147 | // If success callback not provided, will return value immediately, but use overload with success as it browser-friendly
148 | photoLibrary.getPhotoURL = function (photoIdOrLibraryItem, success, error, options) {
149 |
150 | var photoId = typeof photoIdOrLibraryItem.id !== 'undefined' ? photoIdOrLibraryItem.id : photoIdOrLibraryItem;
151 |
152 | if (typeof success !== 'function' && typeof options === 'undefined') {
153 | options = success;
154 | success = undefined;
155 | }
156 |
157 | if (!options) {
158 | options = {};
159 | }
160 |
161 | var urlParams = 'photoId=' + fixedEncodeURIComponent(photoId);
162 | var photoURL = 'cdvphotolibrary://photo?' + urlParams;
163 |
164 | if (success) {
165 | if (isBrowser) {
166 | cordova.exec(function(photoURL) { success(photoURL + '#' + urlParams); }, error, 'PhotoLibrary', '_getPhotoURLBrowser', [photoId, options]);
167 | } else {
168 | success(photoURL);
169 | }
170 | } else {
171 | return photoURL;
172 | }
173 |
174 | };
175 |
176 | // Provide same size as when calling getLibrary for better performance
177 | photoLibrary.getThumbnail = function (photoIdOrLibraryItem, success, error, options) {
178 |
179 | var photoId = typeof photoIdOrLibraryItem.id !== 'undefined' ? photoIdOrLibraryItem.id : photoIdOrLibraryItem;
180 |
181 | options = getThumbnailOptionsWithDefaults(options);
182 |
183 | cordova.exec(
184 | function (data, mimeType) {
185 | var blob = dataAndMimeTypeToBlob(data, mimeType);
186 | success(blob);
187 | },
188 | error,
189 | 'PhotoLibrary',
190 | 'getThumbnail', [photoId, options]
191 | );
192 |
193 | };
194 |
195 | photoLibrary.getPhoto = function (photoIdOrLibraryItem, success, error, options) {
196 |
197 | var photoId = typeof photoIdOrLibraryItem.id !== 'undefined' ? photoIdOrLibraryItem.id : photoIdOrLibraryItem;
198 |
199 | if (!options) {
200 | options = {};
201 | }
202 |
203 | cordova.exec(
204 | function (data, mimeType) {
205 | var blob = dataAndMimeTypeToBlob(data, mimeType);
206 | success(blob);
207 | },
208 | error,
209 | 'PhotoLibrary',
210 | 'getPhoto', [photoId, options]
211 | );
212 |
213 | };
214 |
215 | photoLibrary.getLibraryItem = function (libraryItem, success, error, options) {
216 |
217 | if (!options) {
218 | options = {};
219 | }
220 |
221 | cordova.exec(
222 | function (data, mimeType) {
223 | var blob = dataAndMimeTypeToBlob(data, mimeType);
224 | success(blob);
225 | },
226 | error,
227 | 'PhotoLibrary',
228 | 'getLibraryItem', [libraryItem, options]
229 | );
230 |
231 | };
232 |
233 | // Call when thumbnails are not longer needed for better performance
234 | photoLibrary.stopCaching = function (success, error) {
235 |
236 | cordova.exec(
237 | success,
238 | error,
239 | 'PhotoLibrary',
240 | 'stopCaching', []
241 | );
242 |
243 | };
244 |
245 | // Call when getting errors that begin with 'Permission Denial'
246 | photoLibrary.requestAuthorization = function (success, error, options) {
247 |
248 | options = getRequestAuthenticationOptionsWithDefaults(options);
249 |
250 | cordova.exec(
251 | success,
252 | error,
253 | 'PhotoLibrary',
254 | 'requestAuthorization', [options]
255 | );
256 |
257 | };
258 |
259 | // url is file url or dataURL
260 | photoLibrary.saveImage = function (url, album, success, error, options) {
261 |
262 | options = getThumbnailOptionsWithDefaults(options);
263 |
264 | if (album.title) {
265 | album = album.title;
266 | }
267 |
268 | cordova.exec(
269 | function (libraryItem) {
270 | var library = libraryItem ? [libraryItem] : [];
271 |
272 | processLibrary(library, function(library) {
273 | success(library[0] || null);
274 | }, options);
275 |
276 | },
277 | error,
278 | 'PhotoLibrary',
279 | 'saveImage', [url, album]
280 | );
281 |
282 | };
283 |
284 | // url is file url or dataURL
285 | photoLibrary.saveVideo = function (url, album, success, error) {
286 |
287 | if (album.title) {
288 | album = album.title;
289 | }
290 |
291 | cordova.exec(
292 | success,
293 | error,
294 | 'PhotoLibrary',
295 | 'saveVideo', [url, album]
296 | );
297 |
298 | };
299 |
300 | module.exports = photoLibrary;
301 |
302 | var getThumbnailOptionsWithDefaults = function (options) {
303 |
304 | if (!options) {
305 | options = {};
306 | }
307 |
308 | options = {
309 | thumbnailWidth: options.thumbnailWidth || defaultThumbnailWidth,
310 | thumbnailHeight: options.thumbnailHeight || defaultThumbnailHeight,
311 | quality: options.quality || defaultQuality,
312 | };
313 |
314 | return options;
315 |
316 | };
317 |
318 | var getRequestAuthenticationOptionsWithDefaults = function (options) {
319 |
320 | if (!options) {
321 | options = {};
322 | }
323 |
324 | options = {
325 | read: options.read || true,
326 | write: options.write || false,
327 | };
328 |
329 | return options;
330 |
331 | };
332 |
333 | var processLibrary = function (library, success, options) {
334 |
335 | parseDates(library);
336 |
337 | addUrlsToLibrary(library, success, options);
338 |
339 | };
340 |
341 | var parseDates = function (library) {
342 | var i;
343 | for (i = 0; i < library.length; i++) {
344 | var libraryItem = library[i];
345 | if (libraryItem.creationDate) {
346 | libraryItem.creationDate = new Date(libraryItem.creationDate);
347 | }
348 | }
349 | };
350 |
351 | var addUrlsToLibrary = function (library, callback, options) {
352 |
353 | var urlsLeft = library.length;
354 |
355 | var handlePhotoURL = function (libraryItem, photoURL) {
356 | libraryItem.photoURL = photoURL;
357 | urlsLeft -= 1;
358 | if (urlsLeft === 0) {
359 | callback(library);
360 | }
361 | };
362 |
363 | var handleThumbnailURL = function (libraryItem, thumbnailURL) {
364 | libraryItem.thumbnailURL = thumbnailURL;
365 | photoLibrary.getPhotoURL(libraryItem, handlePhotoURL.bind(null, libraryItem), handleUrlError);
366 | };
367 |
368 | var handleUrlError = function () {}; // Should never happen
369 |
370 | var i;
371 | for (i = 0; i < library.length; i++) {
372 | var libraryItem = library[i];
373 | photoLibrary.getThumbnailURL(libraryItem, handleThumbnailURL.bind(null, libraryItem), handleUrlError, options);
374 | }
375 |
376 | };
377 |
378 | var dataAndMimeTypeToBlob = function (data, mimeType) {
379 | if (!mimeType && data.data && data.mimeType) {
380 | // workaround for browser platform cannot return multipart result
381 | mimeType = data.mimeType;
382 | data = data.data;
383 | }
384 | if (typeof data === 'string') {
385 | // workaround for data arrives as base64 instead of arrayBuffer, with cordova-android 6.x
386 | data = cordova.require('cordova/base64').toArrayBuffer(data);
387 | }
388 | var blob = new Blob([data], {
389 | type: mimeType
390 | });
391 |
392 | return blob;
393 | };
394 |
395 | // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
396 | function fixedEncodeURIComponent(str) {
397 | return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
398 | return '%' + c.charCodeAt(0).toString(16);
399 | });
400 | }
401 |
--------------------------------------------------------------------------------
/www/async/dist/async.min.js:
--------------------------------------------------------------------------------
1 | !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async=n.async||{})}(this,function(n){"use strict";function t(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}function e(n,e,r){return e=rt(void 0===e?n.length-1:e,0),function(){for(var u=arguments,o=-1,i=rt(u.length-e,0),c=Array(i);++o-1&&n%1==0&&n<=kt}function p(n){return null!=n&&s(n.length)&&!l(n)}function h(){}function y(n){return function(){if(null!==n){var t=n;n=null,t.apply(this,arguments)}}}function v(n,t){for(var e=-1,r=Array(n);++e-1&&n%1==0&&nu?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(u);++r=r?n:K(n,t,e)}function Y(n,t){for(var e=n.length;e--&&Q(t,n[e],0)>-1;);return e}function Z(n,t){for(var e=-1,r=n.length;++e-1;);return e}function nn(n){return n.split("")}function tn(n){return We.test(n)}function en(n){return n.match(fr)||[]}function rn(n){return tn(n)?en(n):nn(n)}function un(n){return null==n?"":J(n)}function on(n,t,e){if(n=un(n),n&&(e||void 0===t))return n.replace(ar,"");if(!n||!(t=J(t)))return n;var r=rn(n),u=rn(t),o=Z(r,u),i=Y(r,u)+1;return X(r,o,i).join("")}function cn(n){return n=n.toString().replace(hr,""),n=n.match(lr)[2].replace(" ",""),n=n?n.split(sr):[],n=n.map(function(n){return on(n.replace(pr,""))})}function fn(n,t){var e={};C(n,function(n,t){function r(t,e){var r=G(u,function(n){return t[n]});r.push(e),n.apply(null,r)}var u;if(Ft(n))u=n.slice(0,-1),n=n[n.length-1],e[t]=u.concat(u.length>0?r:n);else if(1===n.length)e[t]=n;else{if(u=cn(n),0===n.length&&0===u.length)throw new Error("autoInject task functions require explicit parameters.");u.pop(),e[t]=u.concat(r)}}),Me(e,t)}function an(n){setTimeout(n,0)}function ln(n){return u(function(t,e){n(function(){t.apply(null,e)})})}function sn(){this.head=this.tail=null,this.length=0}function pn(n,t){n.length=1,n.head=n.tail=t}function hn(n,t,e){function r(n,t,e){if(null!=e&&"function"!=typeof e)throw new Error("task callback must be a function");if(f.started=!0,Ft(n)||(n=[n]),0===n.length&&f.idle())return dr(function(){f.drain()});for(var r=0,u=n.length;r=0&&c.splice(o),u.callback.apply(u,t),null!=t[0]&&f.error(t[0],u.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()})}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var i=0,c=[],f={_tasks:new sn,concurrency:t,payload:e,saturated:h,unsaturated:h,buffer:t/4,empty:h,drain:h,error:h,started:!1,paused:!1,push:function(n,t){r(n,!1,t)},kill:function(){f.drain=h,f._tasks.empty()},unshift:function(n,t){r(n,!0,t)},process:function(){for(;!f.paused&&i3?(i=i||h,n(r,u,f,c)):(i=o,i=i||h,o=u,n(r,f,c))}}function bn(n,t){return t}function jn(n){return u(function(t,e){t.apply(null,e.concat([u(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&D(e,function(t){console[n](t)}))})]))})}function Sn(n,t,e){function r(t,r){return t?e(t):r?void n(o):e(null)}e=I(e||h);var o=u(function(n,u){return n?e(n):(u.push(r),void t.apply(this,u))});r(null,!0)}function kn(n,t,e){e=I(e||h);var r=u(function(u,o){return u?e(u):t.apply(this,o)?n(r):void e.apply(null,[null].concat(o))});n(r)}function wn(n,t,e){kn(n,function(){return!t.apply(this,arguments)},e)}function xn(n,t,e){function r(t){return t?e(t):void n(u)}function u(n,u){return n?e(n):u?void t(r):e(null)}e=I(e||h),n(u)}function On(n){return function(t,e,r){return n(t,r)}}function En(n,t,e){Ee(n,On(t),e)}function Ln(n,t,e,r){_(t)(n,On(e),r)}function An(n){return ut(function(t,e){var r=!0;t.push(function(){var n=arguments;r?dr(function(){e.apply(null,n)}):e.apply(null,n)}),n.apply(this,t),r=!1})}function Tn(n){return!n}function Fn(n){return function(t){return null==t?void 0:t[n]}}function In(n,t,e,r){var u=new Array(t.length);n(t,function(n,t,r){e(n,function(n,e){u[t]=!!e,r(n)})},function(n){if(n)return r(n);for(var e=[],o=0;o1&&(r=t),e(null,{value:r})}})),n.apply(this,t)})}function Wn(n,t,e,r){Bn(n,t,function(n,t){e(n,function(n,e){t(n,!e)})},r)}function Nn(n){var t;return Ft(n)?t=G(n,$n):(t={},C(n,function(n,e){t[e]=$n.call(this,n)})),t}function Qn(n){return function(){return n}}function Gn(n,t,e){function r(n,t){if("object"==typeof t)n.times=+t.times||o,n.intervalFunc="function"==typeof t.interval?t.interval:Qn(+t.interval||i),n.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");n.times=+t||o}}function u(){t(function(n){n&&f++r?1:0}Le(n,function(n,e){t(n,function(t,r){return t?e(t):void e(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,G(t.sort(r),Fn("value")))})}function Kn(n,t,e){function r(){c||(o.apply(null,arguments),clearTimeout(i))}function u(){var t=n.name||"anonymous",r=new Error('Callback function "'+t+'" timed out.');r.code="ETIMEDOUT",e&&(r.info=e),c=!0,o(r)}var o,i,c=!1;return ut(function(e,c){o=c,i=setTimeout(u,t),n.apply(null,e.concat(r))})}function Xn(n,t,e,r){for(var u=-1,o=Kr(Jr((t-n)/(e||1)),0),i=Array(o);o--;)i[r?o:++u]=n,n+=e;return i}function Yn(n,t,e,r){Te(Xn(0,n,1),t,e,r)}function Zn(n,t,e,r){3===arguments.length&&(r=e,e=t,t=Ft(n)?[]:{}),r=y(r||h),Ee(n,function(n,r,u){e(t,n,r,u)},function(n){r(n,t)})}function nt(n){return function(){return(n.unmemoized||n).apply(null,arguments)}}function tt(n,t,e){if(e=I(e||h),!n())return e(null);var r=u(function(u,o){return u?e(u):n()?t(r):void e.apply(null,[null].concat(o))});t(r)}function et(n,t,e){tt(function(){return!n.apply(this,arguments)},t,e)}var rt=Math.max,ut=function(n){return u(function(t){var e=t.pop();n.call(this,t,e)})},ot="object"==typeof global&&global&&global.Object===Object&&global,it="object"==typeof self&&self&&self.Object===Object&&self,ct=ot||it||Function("return this")(),ft=ct.Symbol,at=Object.prototype,lt=at.hasOwnProperty,st=at.toString,pt=ft?ft.toStringTag:void 0,ht=Object.prototype,yt=ht.toString,vt="[object Null]",dt="[object Undefined]",mt=ft?ft.toStringTag:void 0,gt="[object AsyncFunction]",bt="[object Function]",jt="[object GeneratorFunction]",St="[object Proxy]",kt=9007199254740991,wt="function"==typeof Symbol&&Symbol.iterator,xt=function(n){return wt&&n[wt]&&n[wt]()},Ot="[object Arguments]",Et=Object.prototype,Lt=Et.hasOwnProperty,At=Et.propertyIsEnumerable,Tt=m(function(){return arguments}())?m:function(n){return d(n)&&Lt.call(n,"callee")&&!At.call(n,"callee")},Ft=Array.isArray,It="object"==typeof n&&n&&!n.nodeType&&n,_t=It&&"object"==typeof module&&module&&!module.nodeType&&module,Bt=_t&&_t.exports===It,Mt=Bt?ct.Buffer:void 0,Ut=Mt?Mt.isBuffer:void 0,zt=Ut||g,Vt=9007199254740991,Pt=/^(?:0|[1-9]\d*)$/,qt="[object Arguments]",Dt="[object Array]",Rt="[object Boolean]",Ct="[object Date]",$t="[object Error]",Wt="[object Function]",Nt="[object Map]",Qt="[object Number]",Gt="[object Object]",Ht="[object RegExp]",Jt="[object Set]",Kt="[object String]",Xt="[object WeakMap]",Yt="[object ArrayBuffer]",Zt="[object DataView]",ne="[object Float32Array]",te="[object Float64Array]",ee="[object Int8Array]",re="[object Int16Array]",ue="[object Int32Array]",oe="[object Uint8Array]",ie="[object Uint8ClampedArray]",ce="[object Uint16Array]",fe="[object Uint32Array]",ae={};ae[ne]=ae[te]=ae[ee]=ae[re]=ae[ue]=ae[oe]=ae[ie]=ae[ce]=ae[fe]=!0,ae[qt]=ae[Dt]=ae[Yt]=ae[Rt]=ae[Zt]=ae[Ct]=ae[$t]=ae[Wt]=ae[Nt]=ae[Qt]=ae[Gt]=ae[Ht]=ae[Jt]=ae[Kt]=ae[Xt]=!1;var le,se="object"==typeof n&&n&&!n.nodeType&&n,pe=se&&"object"==typeof module&&module&&!module.nodeType&&module,he=pe&&pe.exports===se,ye=he&&ot.process,ve=function(){try{return ye&&ye.binding("util")}catch(n){}}(),de=ve&&ve.isTypedArray,me=de?S(de):j,ge=Object.prototype,be=ge.hasOwnProperty,je=Object.prototype,Se=x(Object.keys,Object),ke=Object.prototype,we=ke.hasOwnProperty,xe={},Oe=M(B,1/0),Ee=function(n,t,e){var r=p(n)?U:Oe;r(n,t,e)},Le=z(V),Ae=o(Le),Te=P(V),Fe=M(Te,1),Ie=o(Fe),_e=u(function(n,t){return u(function(e){return n.apply(null,t.concat(e))})}),Be=R(),Me=function(n,t,e){function r(n,t){b.push(function(){f(n,t)})}function o(){if(0===b.length&&0===d)return e(null,v);for(;b.length&&d1?o(v,r):o(r)}}function a(){for(var n,t=0;j.length;)n=j.pop(),t++,D(l(n),function(n){0===--S[n]&&j.push(n)});if(t!==p)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function l(t){var e=[];return C(n,function(n,r){Ft(n)&&Q(n,t,0)>=0&&e.push(r)}),e}"function"==typeof t&&(e=t,t=null),e=y(e||h);var s=E(n),p=s.length;if(!p)return e(null);t||(t=p);var v={},d=0,m=!1,g={},b=[],j=[],S={};C(n,function(t,e){if(!Ft(t))return r(e,[t]),void j.push(e);var u=t.slice(0,t.length-1),o=u.length;return 0===o?(r(e,t),void j.push(e)):(S[e]=o,void D(u,function(c){if(!n[c])throw new Error("async.auto task `"+e+"` has a non-existent dependency in "+u.join(", "));i(c,function(){o--,0===o&&r(e,t)})}))}),a(),o()},Ue="[object Symbol]",ze=1/0,Ve=ft?ft.prototype:void 0,Pe=Ve?Ve.toString:void 0,qe="\\ud800-\\udfff",De="\\u0300-\\u036f\\ufe20-\\ufe23",Re="\\u20d0-\\u20f0",Ce="\\ufe0e\\ufe0f",$e="\\u200d",We=RegExp("["+$e+qe+De+Re+Ce+"]"),Ne="\\ud800-\\udfff",Qe="\\u0300-\\u036f\\ufe20-\\ufe23",Ge="\\u20d0-\\u20f0",He="\\ufe0e\\ufe0f",Je="["+Ne+"]",Ke="["+Qe+Ge+"]",Xe="\\ud83c[\\udffb-\\udfff]",Ye="(?:"+Ke+"|"+Xe+")",Ze="[^"+Ne+"]",nr="(?:\\ud83c[\\udde6-\\uddff]){2}",tr="[\\ud800-\\udbff][\\udc00-\\udfff]",er="\\u200d",rr=Ye+"?",ur="["+He+"]?",or="(?:"+er+"(?:"+[Ze,nr,tr].join("|")+")"+ur+rr+")*",ir=ur+rr+or,cr="(?:"+[Ze+Ke+"?",Ke,nr,tr,Je].join("|")+")",fr=RegExp(Xe+"(?="+Xe+")|"+cr+ir,"g"),ar=/^\s+|\s+$/g,lr=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,sr=/,/,pr=/(=.+)?(\s*)$/,hr=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,yr="function"==typeof setImmediate&&setImmediate,vr="object"==typeof process&&"function"==typeof process.nextTick;le=yr?setImmediate:vr?process.nextTick:an;var dr=ln(le);sn.prototype.removeLink=function(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n},sn.prototype.empty=sn,sn.prototype.insertAfter=function(n,t){t.prev=n,t.next=n.next,n.next?n.next.prev=t:this.tail=t,n.next=t,this.length+=1},sn.prototype.insertBefore=function(n,t){t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:this.head=t,n.prev=t,this.length+=1},sn.prototype.unshift=function(n){this.head?this.insertBefore(this.head,n):pn(this,n)},sn.prototype.push=function(n){this.tail?this.insertAfter(this.tail,n):pn(this,n)},sn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},sn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var mr,gr=M(B,1),br=u(function(n){return u(function(t){var e=this,r=t[t.length-1];"function"==typeof r?t.pop():r=h,vn(n,t,function(n,t,r){t.apply(e,n.concat([u(function(n,t){r(n,t)})]))},function(n,t){r.apply(e,[n].concat(t))})})}),jr=u(function(n){return br.apply(null,n.reverse())}),Sr=z(dn),kr=mn(dn),wr=u(function(n){var t=[null].concat(n);return ut(function(n,e){return e.apply(this,t)})}),xr=gn(Ee,r,bn),Or=gn(B,r,bn),Er=gn(gr,r,bn),Lr=jn("dir"),Ar=M(Ln,1),Tr=gn(Ee,Tn,Tn),Fr=gn(B,Tn,Tn),Ir=M(Fr,1),_r=z(Bn),Br=P(Bn),Mr=M(Br,1),Ur=jn("log"),zr=M(Un,1/0),Vr=M(Un,1);mr=vr?process.nextTick:yr?setImmediate:an;var Pr=ln(mr),qr=function(n,t){return hn(function(t,e){n(t[0],e)},t,1)},Dr=function(n,t){var e=qr(n,t);return e.push=function(n,t,r){if(null==r&&(r=h),"function"!=typeof r)throw new Error("task callback must be a function");if(e.started=!0,Ft(n)||(n=[n]),0===n.length)return dr(function(){e.drain()});t=t||0;for(var u=e._tasks.head;u&&t>=u.priority;)u=u.next;for(var o=0,i=n.length;o