2017-05-11 18:26:06 +09:00
|
|
|
import 'intl';
|
2017-10-16 18:12:09 +09:00
|
|
|
import 'intl/locale-data/jsonp/en';
|
2023-05-09 21:55:35 +09:00
|
|
|
import 'core-js/features/object/assign';
|
|
|
|
import 'core-js/features/object/values';
|
|
|
|
import 'core-js/features/symbol';
|
|
|
|
import 'core-js/features/promise/finally';
|
|
|
|
import { decode as decodeBase64 } from '../utils/base64';
|
2020-02-19 01:22:44 +09:00
|
|
|
|
2018-04-23 16:15:51 +09:00
|
|
|
if (!HTMLCanvasElement.prototype.toBlob) {
|
|
|
|
const BASE64_MARKER = ';base64,';
|
|
|
|
|
|
|
|
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
|
2023-05-09 21:55:35 +09:00
|
|
|
value(callback: BlobCallback, type = 'image/png', quality: any) {
|
2018-04-23 16:15:51 +09:00
|
|
|
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 }));
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|