瀏覽代碼

Remove TextDecoder polyfill

Lutz Roeder 3 年之前
父節點
當前提交
69646de007
共有 4 個文件被更改,包括 118 次插入246 次删除
  1. 12 12
      source/electron.html
  2. 34 15
      source/electron.js
  3. 14 14
      source/index.html
  4. 58 205
      source/index.js

+ 12 - 12
source/electron.html

@@ -47,8 +47,8 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome button:focus { outline: 0; }
 .welcome .open-file-button { top: 170px; left: -150px; width: 125px; opacity: 1; }
 .welcome .github-button { top: 170px; left: 150px; width: 125px; opacity: 1; }
-.welcome .consent-accept-button { top: 220px; left: 0px; width: 125px; display: none; opacity: 0; }
-.welcome .consent-message { top: 120px; left: 0px; font-size: 13px; text-align: center; line-height: 20px; color: #444444; display: none; opacity: 0; }
+.welcome .message-button { top: 220px; left: 0px; width: 125px; display: none; opacity: 0; }
+.welcome .message { top: 120px; left: 0px; font-size: 13px; text-align: center; line-height: 20px; color: #444444; display: none; opacity: 0; }
 .welcome .graph { display: none; opacity: 0; }
 .welcome.spinner .logo-spinner { display: block; -webkit-animation: orbit 0.5s infinite linear; animation: orbit 0.5s infinite linear; cursor: wait; }
 @-webkit-keyframes orbit { 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
@@ -57,11 +57,11 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome.spinner .logo-name { display: none; }
 .welcome.spinner .open-file-button { opacity: 0; display: none; }
 .welcome.spinner .github-button { opacity: 0; display: none; }
-.welcome.consent .logo-name { display: none; }
-.welcome.consent .open-file-button { opacity: 0; display: none; }
-.welcome.consent .github-button { opacity: 0; display: none; }
-.welcome.consent .consent-accept-button { opacity: 1; display: block; }
-.welcome.consent .consent-message { opacity: 1; display: block; }
+.welcome.message .logo-name { display: none; }
+.welcome.message .open-file-button { opacity: 0; display: none; }
+.welcome.message .github-button { opacity: 0; display: none; }
+.welcome.message .message-button { opacity: 1; display: block; }
+.welcome.message .message { opacity: 1; display: block; }
 .welcome.spinner .graph { display: flex; opacity: 0; }
 .welcome .toolbar { display: none; }
 .default { background-color: #ffffff; }
@@ -80,7 +80,7 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome .logo-spinner-stroke { stroke: #ffffff; }
 .welcome .logo button { color: #888888; background-color: #1e1e1e; border-color: #888888; }
 .welcome .logo button:hover { color: #1e1e1e; background-color: #888888; }
-.welcome .consent-message { color: #888888; display: none; opacity: 0; }
+.welcome .message { color: #888888; display: none; opacity: 0; }
 .icon .border { stroke: #1d1d1d; }
 .icon .stroke { stroke: #aaaaaa; }
 .icon:hover .stroke { stroke: #dfdfdf; }
@@ -101,8 +101,8 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome .logo-spinner { left: 0; top: 0; width: 128px; height: 128px; }
 .welcome .logo .open-file-button { top: 180px; left: 0; }
 .welcome .logo .github-button { top: 270px; left: 0; }
-.welcome .logo .consent-message { top: 140px; }
-.welcome .logo .consent-accept-button { top: 310px; }
+.welcome .logo .message { top: 140px; }
+.welcome .logo .message-button { top: 310px; }
 .about .logo { border-radius: 0; border-left: 0px; border-right: 0px; width: 100%; padding-left: 0; padding-right: 0; }
 .about.desktop .logo { width: 320px; padding: 40px; }
 }
@@ -301,8 +301,8 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
                 C438.536,184.851,428.728,148.168,409.132,114.573z"/>
         </svg>
     </a>
-    <span class="center consent-message">This app uses cookies to report errors and anonymous usage information.</span>
-    <button id="consent-accept-button" class="center consent-accept-button">Accept</button>
+    <span id="message" class="center message"></span>
+    <button id="message-button" class="center message-button"></button>
     <button id="open-file-button" class="center open-file-button" tabindex="0">Open Model&hellip;</button>
     <button id="github-button" class="center github-button">GitHub</button>
     <input type="file" id="open-file-dialog" class="open-file-dialog" multiple="false" accept="">

+ 34 - 15
source/electron.js

@@ -58,25 +58,21 @@ host.ElectronHost = class {
             this._openPath(data.path);
         });
         return new Promise((resolve /*, reject */) => {
-            const accept = () => {
+            const telemetry = () => {
                 if (this._environment.package) {
                     this._telemetry = new host.Telemetry('UA-54146-13', this._getConfiguration('userId'), navigator.userAgent, this.type, this.version);
                 }
                 resolve();
             };
-            const request = () => {
-                this._view.show('welcome consent');
-                const acceptButton = this.document.getElementById('consent-accept-button');
-                if (acceptButton) {
-                    acceptButton.addEventListener('click', () => {
-                        this._setConfiguration('consent', Date.now());
-                        accept();
-                    });
-                }
+            const consent = () => {
+                this._message('This app uses cookies to report errors and anonymous usage information.', 'Accept', () => {
+                    this._setConfiguration('consent', Date.now());
+                    telemetry();
+                });
             };
             const time = this._getConfiguration('consent');
             if (time && (Date.now() - time) < 30 * 24 * 60 * 60 * 1000) {
-                accept();
+                telemetry();
             }
             else {
                 this._request('https://ipinfo.io/json', { 'Content-Type': 'application/json' }, 2000).then((text) => {
@@ -85,17 +81,17 @@ host.ElectronHost = class {
                         const countries = ['AT', 'BE', 'BG', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'EL', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'NO', 'PL', 'PT', 'SK', 'ES', 'SE', 'GB', 'UK', 'GR', 'EU', 'RO'];
                         if (json && json.country && !countries.indexOf(json.country) !== -1) {
                             this._setConfiguration('consent', Date.now());
-                            accept();
+                            telemetry();
                         }
                         else {
-                            request();
+                            consent();
                         }
                     }
                     catch (err) {
-                        request();
+                        consent();
                     }
                 }).catch(() => {
-                    request();
+                    consent();
                 });
             }
         });
@@ -461,6 +457,29 @@ host.ElectronHost = class {
     _update(data) {
         electron.ipcRenderer.send('update', data);
     }
+
+    _message(message, button, callback) {
+        const messageText = this.document.getElementById('message');
+        if (messageText) {
+            messageText.innerText = message;
+        }
+        const messageButton = this.document.getElementById('message-button');
+        if (messageButton) {
+            if (button && callback) {
+                messageButton.style.removeProperty('display');
+                messageButton.innerText = button;
+                messageButton.onclick = () => {
+                    messageButton.onclick = null;
+                    callback();
+                };
+            }
+            else {
+                messageButton.style.display = 'none';
+                messageButton.onclick = null;
+            }
+        }
+        this._view.show('welcome message');
+    }
 };
 
 host.Telemetry = class {

+ 14 - 14
source/index.html

@@ -75,8 +75,8 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .about .logo-github { top: 130px; width: 24px; height: 24px; }
 .about .open-file-button { display: none; }
 .about .github-button { display: none; }
-.about .consent-message { display: none; }
-.about .consent-accept-button { display: none; }
+.about .message { display: none; }
+.about .message-button { display: none; }
 .about .graph { display: flex; opacity: 1; }
 .about .toolbar { display: block; opacity: 1; }
 .about .transparent { display: block; opacity: 0.5; }
@@ -97,8 +97,8 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome button:focus { outline: 0; }
 .welcome .open-file-button { top: 170px; left: -150px; width: 125px; opacity: 1; }
 .welcome .github-button { top: 170px; left: 150px; width: 125px; opacity: 1; }
-.welcome .consent-accept-button { top: 220px; left: 0px; width: 125px; display: none; opacity: 0; }
-.welcome .consent-message { top: 120px; left: 0px; font-size: 13px; text-align: center; line-height: 20px; color: #444444; display: none; opacity: 0; }
+.welcome .message-button { top: 220px; left: 0px; width: 125px; display: none; opacity: 0; }
+.welcome .message { top: 120px; left: 0px; font-size: 13px; text-align: center; line-height: 20px; color: #444444; display: none; opacity: 0; }
 .welcome .graph { display: none; opacity: 0; }
 .welcome.spinner .logo-spinner { display: block; -webkit-animation: orbit 0.5s infinite linear; animation: orbit 0.5s infinite linear; cursor: wait; }
 @-webkit-keyframes orbit { 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
@@ -107,11 +107,11 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome.spinner .logo-name { display: none; }
 .welcome.spinner .open-file-button { opacity: 0; display: none; }
 .welcome.spinner .github-button { opacity: 0; display: none; }
-.welcome.consent .logo-name { display: none; }
-.welcome.consent .open-file-button { opacity: 0; display: none; }
-.welcome.consent .github-button { opacity: 0; display: none; }
-.welcome.consent .consent-accept-button { opacity: 1; display: block; }
-.welcome.consent .consent-message { opacity: 1; display: block; }
+.welcome.message .logo-name { display: none; }
+.welcome.message .open-file-button { opacity: 0; display: none; }
+.welcome.message .github-button { opacity: 0; display: none; }
+.welcome.message .message-button { opacity: 1; display: block; }
+.welcome.message .message { opacity: 1; display: block; }
 .welcome.spinner .graph { display: flex; opacity: 0; }
 .welcome .toolbar { display: none; }
 .default { background-color: #ffffff; }
@@ -138,7 +138,7 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome .logo-spinner-stroke { stroke: #ffffff; }
 .welcome .logo button { color: #888888; background-color: #1e1e1e; border-color: #888888; }
 .welcome .logo button:hover { color: #1e1e1e; background-color: #888888; }
-.welcome .consent-message { color: #888888; display: none; opacity: 0; }
+.welcome .message { color: #888888; display: none; opacity: 0; }
 .icon .border { stroke: #1d1d1d; }
 .icon .stroke { stroke: #aaaaaa; }
 .icon:hover .stroke { stroke: #dfdfdf; }
@@ -159,8 +159,8 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .welcome .logo-spinner { left: 0; top: 0; width: 128px; height: 128px; }
 .welcome .logo .open-file-button { top: 180px; left: 0; }
 .welcome .logo .github-button { top: 270px; left: 0; }
-.welcome .logo .consent-message { top: 140px; }
-.welcome .logo .consent-accept-button { top: 310px; }
+.welcome .logo .message { top: 140px; }
+.welcome .logo .message-button { top: 310px; }
 .about .logo { border-radius: 0; border-left: 0px; border-right: 0px; width: 100%; padding-left: 0; padding-right: 0; }
 .about.desktop .logo { width: 320px; padding: 40px; }
 }
@@ -361,8 +361,8 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
                 C438.536,184.851,428.728,148.168,409.132,114.573z"/>
         </svg>
     </a>
-    <span class="center consent-message">This app uses cookies to report errors and anonymous usage information.</span>
-    <button id="consent-accept-button" class="center consent-accept-button">Accept</button>
+    <span id="message" class="center message"></span>
+    <button id="message-button" class="center message-button">Accept</button>
     <button id="open-file-button" class="center open-file-button">Open Model&hellip;</button>
     <button id="github-button" class="center github-button">Download</button>
     <input type="file" id="open-file-dialog" class="open-file-dialog" multiple="false" accept=".onnx, .ort, .pb, .meta, .tflite, .lite, .tfl, .keras, .h5, .hd5, .hdf5, .json, .model, .mar, .params, .param, .armnn, .mnn, .ncnn, .tnnproto, .tmfile, .ms, .om, .nn, .uff, .rknn, .xmodel, .kmodel, .paddle, .pdmodel, .pdiparams, .pdparams, .pdopt, .nb, .dnn, .cmf, .mlmodel, .mlpackage, .caffemodel, .pbtxt, .prototxt, .pkl, .pt, .pth, .ptl, .t7, .joblib, .cfg, .xml, .zip, .tar">

+ 58 - 205
source/index.js

@@ -1,8 +1,6 @@
 
-/* eslint "no-global-assign": ["error", {"exceptions": [ "TextDecoder", "TextEncoder", "URLSearchParams" ] } ] */
-/* global view */
-
 var host = {};
+var view = view || {};
 
 host.BrowserHost = class {
 
@@ -57,7 +55,27 @@ host.BrowserHost = class {
     initialize(view) {
         this._view = view;
         return new Promise((resolve /*, reject */) => {
-            const accept = () => {
+            const features = () => {
+                const features = [ 'TextDecoder', 'TextEncoder', 'fetch', 'URLSearchParams', 'HTMLCanvasElement.prototype.toBlob' ];
+                const supported = features.filter((feature) => {
+                    const path = feature.split('.').reverse();
+                    let item = this.window[path.pop()];
+                    while (item && path.length > 0) {
+                        item = item[path.pop()];
+                    }
+                    return !item;
+                });
+                if (supported.length > 0) {
+                    for (const feature of features) {
+                        this.event('Host', 'Browser', feature, 1);
+                    }
+                    this._message('Your browser is not supported.');
+                }
+                else {
+                    resolve();
+                }
+            };
+            const telemetry = () => {
                 if (this._telemetry) {
                     const script = this.document.createElement('script');
                     script.setAttribute('type', 'text/javascript');
@@ -68,32 +86,25 @@ host.BrowserHost = class {
                             this.window.ga('create', 'UA-54146-13', 'auto');
                             this.window.ga('set', 'anonymizeIp', true);
                         }
-                        if (typeof fetch === 'undefined') {
-                            this.event('Host', 'Browser', 'fetch', 1);
-                        }
-                        resolve();
+                        features();
                     };
                     script.onerror = () => {
-                        resolve();
+                        features();
                     };
                     this.document.body.appendChild(script);
                 }
                 else {
-                    resolve();
+                    features();
                 }
             };
-            const request = () => {
-                this._view.show('welcome consent');
-                const acceptButton = this.document.getElementById('consent-accept-button');
-                if (acceptButton) {
-                    acceptButton.addEventListener('click', () => {
-                        this._setCookie('consent', 'yes', 30);
-                        accept();
-                    });
-                }
+            const consent = () => {
+                this._message('This app uses cookies to report errors and anonymous usage information.', 'Accept', () => {
+                    this._setCookie('consent', 'yes', 30);
+                    telemetry();
+                });
             };
             if (this._getCookie('consent')) {
-                accept();
+                telemetry();
             }
             else {
                 this._request('https://ipinfo.io/json', { 'Content-Type': 'application/json' }, 'utf-8', 2000).then((text) => {
@@ -102,17 +113,17 @@ host.BrowserHost = class {
                         const countries = ['AT', 'BE', 'BG', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'EL', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'NO', 'PL', 'PT', 'SK', 'ES', 'SE', 'GB', 'UK', 'GR', 'EU', 'RO'];
                         if (json && json.country && !countries.indexOf(json.country) !== -1) {
                             this._setCookie('consent', Date.now(), 30);
-                            accept();
+                            telemetry();
                         }
                         else {
-                            request();
+                            consent();
                         }
                     }
                     catch (err) {
-                        request();
+                        consent();
                     }
                 }).catch(() => {
-                    request();
+                    consent();
                 });
             }
         });
@@ -523,6 +534,29 @@ host.BrowserHost = class {
         return parts.length < 2 ? undefined : parts.pop().split(';').shift();
     }
 
+    _message(message, button, callback) {
+        const messageText = this.document.getElementById('message');
+        if (messageText) {
+            messageText.innerText = message;
+        }
+        const messageButton = this.document.getElementById('message-button');
+        if (messageButton) {
+            if (button && callback) {
+                messageButton.style.removeProperty('display');
+                messageButton.innerText = button;
+                messageButton.onclick = () => {
+                    messageButton.onclick = null;
+                    callback();
+                };
+            }
+            else {
+                messageButton.style.display = 'none';
+                messageButton.onclick = null;
+            }
+        }
+        this._view.show('welcome message');
+    }
+
     _about() {
         const self = this;
         const eventHandler = () => {
@@ -840,187 +874,6 @@ host.BrowserHost.BrowserContext = class {
     }
 };
 
-if (typeof TextDecoder === "undefined") {
-    TextDecoder = function TextDecoder(encoding) {
-        this._encoding = encoding;
-        if (window.__host__ && !TextEncoder.__event__) {
-            TextEncoder.__event__ = true;
-            window.__host__.event('Host', 'Browser', 'TextDecoder', 1);
-        }
-    };
-    TextDecoder.prototype.decode = function decode(buffer) {
-        let result = '';
-        const length = buffer.length;
-        let i = 0;
-        switch (this._encoding) {
-            case 'utf-8':
-                while (i < length) {
-                    const c = buffer[i++];
-                    switch(c >> 4) {
-                        case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
-                            result += String.fromCharCode(c);
-                            break;
-                        }
-                        case 12: case 13: {
-                            const c2 = buffer[i++];
-                            result += String.fromCharCode(((c & 0x1F) << 6) | (c2 & 0x3F));
-                            break;
-                        }
-                        case 14: {
-                            const c2 = buffer[i++];
-                            const c3 = buffer[i++];
-                            result += String.fromCharCode(((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0));
-                            break;
-                        }
-                        case 15: {
-                            const c2 = buffer[i++];
-                            const c3 = buffer[i++];
-                            const c4 = buffer[i++];
-                            result += String.fromCodePoint(((c & 0x07) << 18) | ((c2 & 0x3F) << 12) | ((c3 & 0x3F) << 6) | (c4 & 0x3F));
-                            break;
-                        }
-                        default: {
-                            break;
-                        }
-                    }
-                }
-                break;
-            case 'ascii':
-                while (i < length) {
-                    result += String.fromCharCode(buffer[i++]);
-                }
-                break;
-            default:
-                break;
-        }
-        return result;
-    };
-}
-
-if (typeof TextEncoder === 'undefined') {
-    TextEncoder = function TextEncoder() {
-        if (window.__host__ && !TextEncoder.__event__) {
-            TextEncoder.__event__ = true;
-            window.__host__.event('Host', 'Browser', 'TextEncoder', 1);
-        }
-    };
-    TextEncoder.prototype.encode = function encode(str) {
-        "use strict";
-        const length = str.length;
-        let resPos = -1;
-        const resArr = typeof Uint8Array === "undefined" ? new Array(length * 2) : new Uint8Array(length * 3);
-        for (let point = 0, nextcode = 0, i = 0; i !== length; ) {
-            point = str.charCodeAt(i);
-            i += 1;
-            if (point >= 0xD800 && point <= 0xDBFF) {
-                if (i === length) {
-                    resArr[resPos += 1] = 0xef; resArr[resPos += 1] = 0xbf;
-                    resArr[resPos += 1] = 0xbd; break;
-                }
-                nextcode = str.charCodeAt(i);
-                if (nextcode >= 0xDC00 && nextcode <= 0xDFFF) {
-                    point = (point - 0xD800) * 0x400 + nextcode - 0xDC00 + 0x10000;
-                    i += 1;
-                    if (point > 0xffff) {
-                        resArr[resPos += 1] = (0x1e<<3) | (point>>>18);
-                        resArr[resPos += 1] = (0x2<<6) | ((point>>>12)&0x3f);
-                        resArr[resPos += 1] = (0x2<<6) | ((point>>>6)&0x3f);
-                        resArr[resPos += 1] = (0x2<<6) | (point&0x3f);
-                        continue;
-                    }
-                }
-                else {
-                    resArr[resPos += 1] = 0xef; resArr[resPos += 1] = 0xbf;
-                    resArr[resPos += 1] = 0xbd; continue;
-                }
-            }
-            if (point <= 0x007f) {
-                resArr[resPos += 1] = (0x0<<7) | point;
-            }
-            else if (point <= 0x07ff) {
-                resArr[resPos += 1] = (0x6<<5) | (point>>>6);
-                resArr[resPos += 1] = (0x2<<6) | (point&0x3f);
-            }
-            else {
-                resArr[resPos += 1] = (0xe<<4) | (point>>>12);
-                resArr[resPos += 1] = (0x2<<6) | ((point>>>6)&0x3f);
-                resArr[resPos += 1] = (0x2<<6) | (point&0x3f);
-            }
-        }
-        if (typeof Uint8Array !== "undefined") {
-            return new Uint8Array(resArr.buffer.slice(0, resPos+1));
-        }
-        return resArr.length === resPos + 1 ? resArr : resArr.slice(0, resPos + 1);
-    };
-    TextEncoder.prototype.toString = function() {
-        return "[object TextEncoder]";
-    };
-    try {
-        Object.defineProperty(TextEncoder.prototype,"encoding", {
-            get:function() {
-                if (Object.prototype.isPrototypeOf.call(TextEncoder.prototype, this)) {
-                    return"utf-8";
-                }
-                throw new TypeError("Illegal invocation");
-            }
-        });
-    }
-    catch (e) {
-        TextEncoder.prototype.encoding = "utf-8";
-    }
-    if (typeof Symbol !== "undefined") {
-        TextEncoder.prototype[Symbol.toStringTag] = "TextEncoder";
-    }
-}
-
-if (typeof URLSearchParams === 'undefined') {
-    URLSearchParams = function URLSearchParams(search) {
-        if (window.__host__ && !URLSearchParams.__event__) {
-            URLSearchParams.__event__ = true;
-            window.__host__.event('Host', 'Browser', 'URLSearchParams', 1);
-        }
-        const decode = (str) => {
-            return str.replace(/[ +]/g, '%20').replace(/(%[a-f0-9]{2})+/ig, (match) => { return decodeURIComponent(match); });
-        };
-        this._dict = {};
-        if (typeof search === 'string') {
-            search = search.indexOf('?') === 0 ? search.substring(1) : search;
-            const properties = search.split('&');
-            for (const property of properties) {
-                const index = property.indexOf('=');
-                const name = (index > -1) ? decode(property.substring(0, index)) : decode(property);
-                const value = (index > -1) ? decode(property.substring(index + 1)) : '';
-                if (!Object.prototype.hasOwnProperty.call(this._dict, name)) {
-                    this._dict[name] = [];
-                }
-                this._dict[name].push(value);
-            }
-        }
-    };
-    URLSearchParams.prototype.get = function(name) {
-        return Object.prototype.hasOwnProperty.call(this._dict, name) ? this._dict[name][0] : null;
-    };
-}
-
-if (!HTMLCanvasElement.prototype.toBlob) {
-    HTMLCanvasElement.prototype.toBlob = function(callback, type, quality) {
-        if (window.__host__ && !HTMLCanvasElement.__event__) {
-            HTMLCanvasElement.__event__ = true;
-            window.__host__.event('Host', 'Browser', 'HTMLCanvasElement.toBlob', 1);
-        }
-        const canvas = this;
-        setTimeout(function() {
-            const data = atob(canvas.toDataURL(type, quality).split(',')[1]);
-            const length = data.length;
-            const buffer = new Uint8Array(length);
-            for (let i = 0; i < length; i++) {
-                buffer[i] = data.charCodeAt(i);
-            }
-            callback(new Blob([ buffer ], { type: type || 'image/png' }));
-        });
-    };
-}
-
 if (!('scrollBehavior' in window.document.documentElement.style)) {
     const __scrollTo__ = Element.prototype.scrollTo;
     Element.prototype.scrollTo = function(options) {