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.
43 lines
1010 B
43 lines
1010 B
8 years ago
|
import 'intl';
|
||
7 years ago
|
import 'intl/locale-data/jsonp/en';
|
||
8 years ago
|
import 'es6-symbol/implement';
|
||
|
import includes from 'array-includes';
|
||
|
import assign from 'object-assign';
|
||
6 years ago
|
import values from 'object.values';
|
||
2 years ago
|
import { decode as decodeBase64 } from './utils/base64';
|
||
5 years ago
|
import promiseFinally from 'promise.prototype.finally';
|
||
8 years ago
|
|
||
|
if (!Array.prototype.includes) {
|
||
|
includes.shim();
|
||
|
}
|
||
|
|
||
|
if (!Object.assign) {
|
||
|
Object.assign = assign;
|
||
|
}
|
||
|
|
||
6 years ago
|
if (!Object.values) {
|
||
|
values.shim();
|
||
|
}
|
||
|
|
||
5 years ago
|
promiseFinally.shim();
|
||
|
|
||
6 years ago
|
if (!HTMLCanvasElement.prototype.toBlob) {
|
||
|
const BASE64_MARKER = ';base64,';
|
||
|
|
||
|
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
|
||
|
value(callback, type = 'image/png', quality) {
|
||
|
const dataURL = this.toDataURL(type, quality);
|
||
|
let data;
|
||
|
|
||
|
if (dataURL.indexOf(BASE64_MARKER) >= 0) {
|
||
|
const [, base64] = dataURL.split(BASE64_MARKER);
|
||
|
data = decodeBase64(base64);
|
||
|
} else {
|
||
|
[, data] = dataURL.split(',');
|
||
|
}
|
||
|
|
||
|
callback(new Blob([data], { type }));
|
||
|
},
|
||
|
});
|
||
|
}
|