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.

44 lines
1000 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 isNaN from 'is-nan';
  8. import { decode as decodeBase64 } from './base64';
  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. if (!Number.isNaN) {
  19. Number.isNaN = isNaN;
  20. }
  21. if (!HTMLCanvasElement.prototype.toBlob) {
  22. const BASE64_MARKER = ';base64,';
  23. Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
  24. value(callback, type = 'image/png', quality) {
  25. const dataURL = this.toDataURL(type, quality);
  26. let data;
  27. if (dataURL.indexOf(BASE64_MARKER) >= 0) {
  28. const [, base64] = dataURL.split(BASE64_MARKER);
  29. data = decodeBase64(base64);
  30. } else {
  31. [, data] = dataURL.split(',');
  32. }
  33. callback(new Blob([data], { type }));
  34. },
  35. });
  36. }