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.

42 lines
1010 B

  1. import 'intl';
  2. import 'intl/locale-data/jsonp/en';
  3. import 'es6-symbol/implement';
  4. import includes from 'array-includes';
  5. import assign from 'object-assign';
  6. import values from 'object.values';
  7. import { decode as decodeBase64 } from './utils/base64';
  8. import promiseFinally from 'promise.prototype.finally';
  9. if (!Array.prototype.includes) {
  10. includes.shim();
  11. }
  12. if (!Object.assign) {
  13. Object.assign = assign;
  14. }
  15. if (!Object.values) {
  16. values.shim();
  17. }
  18. promiseFinally.shim();
  19. if (!HTMLCanvasElement.prototype.toBlob) {
  20. const BASE64_MARKER = ';base64,';
  21. Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
  22. value(callback, type = 'image/png', quality) {
  23. const dataURL = this.toDataURL(type, quality);
  24. let data;
  25. if (dataURL.indexOf(BASE64_MARKER) >= 0) {
  26. const [, base64] = dataURL.split(BASE64_MARKER);
  27. data = decodeBase64(base64);
  28. } else {
  29. [, data] = dataURL.split(',');
  30. }
  31. callback(new Blob([data], { type }));
  32. },
  33. });
  34. }