const legacyLoaderString =
legacyLoader.toString()
.replace(/const |let /g, 'var ')
.replace(/\(\) =>/g, 'function ()')
.split(/\s*\n\s*/g)
.filter((line) => {
return !/^\/\//.test(line)
})
.join('')
+ 'legacyLoader(window, document);';
function legacyLoader(window: any, document: any) {
const log_fn = console? console.log.bind(console) : () => {
};
if (!window.hasOwnProperty('console')) {
log_fn('shim console object');
if (!window.hasOwnProperty('console')) {
window['cons' + 'ole'] = {};
}
// @formatter:off
const consoleMethod = ['assert','clear','count','debug','dir','dirxml','error','group','groupCollapsed','groupEnd','info','markTimeline','memory','profile','profileEnd','table','time','timeEnd','timeStamp','timeline','timelineEnd','trace','warn',];
// @formatter:on
if (!console.log) {
console.log = () => {
};
}
for (let i = 0; i < consoleMethod.length; i++) {
if (!console[consoleMethod[i]]) {
console[consoleMethod[i]] = log_fn;
}
}
}
try {
new CustomEvent('bla-bla', {bubbles: true, detail: {a: 1}});
} catch (e) {
(() => {
if (typeof window.CustomEvent === "function") {
return false;
}
function CustomEvent(event, params) {
params = params || {bubbles: false, cancelable: false, detail: undefined};
const evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();
}
if (navigator.appName == 'Microsoft Internet Explorer' || !!navigator.userAgent.match(/Trident/)) {
document.write('`;
export let polyfillScripts = `
${polyfillTooOld}
`;
//