1/* 2 * Safari and Edge polyfill for createImageBitmap 3 * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap 4 * 5 * Support source image types Blob and ImageData. 6 * 7 * From: https://dev.to/nektro/createimagebitmap-polyfill-for-safari-and-edge-228 8 * Updated by Yoan Tournade <[email protected]> 9 */ 10if (!('createImageBitmap' in window)) { 11 window.createImageBitmap = async function (data) { 12 return new Promise((resolve,reject) => { 13 let dataURL; 14 if (data instanceof Blob) { 15 dataURL = URL.createObjectURL(data); 16 } else if (data instanceof ImageData) { 17 const canvas = document.createElement('canvas'); 18 const ctx = canvas.getContext('2d'); 19 canvas.width = data.width; 20 canvas.height = data.height; 21 ctx.putImageData(data,0,0); 22 dataURL = canvas.toDataURL(); 23 } else { 24 throw new Error('createImageBitmap does not handle the provided image source type'); 25 } 26 const img = document.createElement('img'); 27 img.addEventListener('load',function () { 28 resolve(this); 29 }); 30 img.src = dataURL; 31 }); 32 }; 33} 34 35if (!('dynamicImport' in globalThis)) { 36 globalThis.dynamicImport = function(uri) { 37 return import(uri); 38 } 39}; 40 41var global = globalThis; 42 43/* 44 MIT License 45 46Copyright (c) 2021 Tobias Buschor 47 48Permission is hereby granted, free of charge, to any person obtaining a copy 49of this software and associated documentation files (the "Software"), to deal 50in the Software without restriction, including without limitation the rights 51to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 52copies of the Software, and to permit persons to whom the Software is 53furnished to do so, subject to the following conditions: 54 55The above copyright notice and this permission notice shall be included in all 56copies or substantial portions of the Software. 57 58THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 62LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 63OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 64SOFTWARE. 65*/ 66 67// Polyfill for `scrollIntoViewIfNeeded` function not existing in Firefox. 68// https://github.com/nuxodin/lazyfill 69 70 71;(function() { 72 if (!Element.prototype.scrollIntoViewIfNeeded) { 73 Element.prototype.scrollIntoViewIfNeeded = function ( centerIfNeeded = true ) { 74 const el = this; 75 new IntersectionObserver( function( [entry] ) { 76 const ratio = entry.intersectionRatio; 77 if (ratio < 1) { 78 let place = ratio <= 0 && centerIfNeeded ? 'center' : 'nearest'; 79 el.scrollIntoView( { 80 block: place, 81 inline: place, 82 } ); 83 } 84 this.disconnect(); 85 } ).observe(this); 86 }; 87 } 88})()
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.