From 713d214bbc12e9d9021e829fe8fa6a102d7b5c19 Mon Sep 17 00:00:00 2001 From: Sam Thorogood Date: Thu, 20 Aug 2020 11:24:35 +1000 Subject: [PATCH] fix compile and remove --- package.json | 2 +- pwacompat.min.js | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 3caa296..1b642e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pwacompat", - "version": "2.0.15", + "version": "2.0.16", "description": "library to bring Web App Manifest contents to non-compliant browsers", "main": "pwacompat.min.js", "module": "src/pwacompat.js", diff --git a/pwacompat.min.js b/pwacompat.min.js index b9fb5df..dcccf7c 100644 --- a/pwacompat.min.js +++ b/pwacompat.min.js @@ -1,14 +1,13 @@ -var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(l){return l.raw=l};$jscomp.createTemplateTagFirstArgWithRaw=function(l,p){l.raw=p;return l};function unused(){"Please don't use this file directly: include pwacompat.min.js instead!"} -(function(){function l(a){try{return document.head.querySelector(a)}catch(b){return null}}function p(a,b){a="__pwacompat_"+a;void 0!==b&&(n[a]=b);return n[a]}function q(){var a=(w=l('link[rel="manifest"]'))?w.href:"";if(!a)throw'can\'t find \'';var b=J([a,location]),e=p("manifest");if(e)try{var m=JSON.parse(e);x(m,b)}catch(C){console.warn("PWACompat error",C)}else{var c=new XMLHttpRequest;c.open("GET",a);c.withCredentials="use-credentials"===w.getAttribute("crossorigin"); -c.onload=function(){try{var a=JSON.parse(c.responseText);p("manifest",c.responseText);x(a,b)}catch(r){console.warn("PWACompat error",r)}};c.send(null)}}function J(a){for(var b={},e=0;e.6*b)g.fillText(G,h/-2,0),g.translate(0,1.2*c),f.splice(0,d),d=0}return function(){var a=g.canvas.toDataURL();m(e,a);return a}}function m(a,b){var d=document.createElement("link");d.setAttribute("rel","apple-touch-startup-image");d.setAttribute("media","(orientation: "+a+")");d.setAttribute("href",b);document.head.appendChild(d)}function n(a,b){var d=window.screen,c=e(d.width,d.height,"portrait",a),g=e(d.height,d.width,"landscape",a);setTimeout(function(){u.p=c();setTimeout(function(){u.l= -g();b()},10)},10)}function C(a){var b=z.length+1,c=function(){--b||a()};c();z.forEach(function(a){var b=new Image;b.crossOrigin="anonymous";b.onerror=c;b.onload=function(){b.onload=null;a.href=H(b,y,!0);u.i[b.src]=a.href;c()};b.src=a.href})}function r(){p("iOS",JSON.stringify(u))}function q(){var b=z.shift();if(b){var d=new Image;d.crossOrigin="anonymous";d.onerror=function(){return void q()};d.onload=function(){d.onload=null;n(d,function(){var c=a.background_color&&H(d,y);c?(b.href=c,u.i[d.src]= -c,C(r)):r()})};d.src=b.href}else n(null,r)}var k=a.icons||[],h=k.filter(function(a){return(a.purpose||"").includes("maskable")});k.sort(function(a,b){return t(b)-t(a)});h.sort(function(a,b){return t(b)-t(a)});var z=(0t(a)))return c.rel="apple-touch-icon",D("link",c,'[rel="apple-touch-icon"]'+e)}).filter(Boolean);h=l('meta[name="viewport"]');var x=!!(h&&h.content|| -"").match(/\bviewport-fit\s*=\s*cover\b/),v=a.display;h=-1!==K.indexOf(v);c("mobile-web-app-capable",h);L(a.theme_color||"black",x);M&&(c("application-name",a.short_name),c("msapplication-tooltip",a.description),c("msapplication-starturl",b(a.start_url||".")),c("msapplication-navbutton-color",a.theme_color),(k=k[0])&&c("msapplication-TileImage",b(k.src)),c("msapplication-TileColor",a.background_color));c("theme-color",a.theme_color);if(A){var y=a.background_color||"#f8f9fa",B=I(y);(k=N(a.related_applications))&& -c("apple-itunes-app","app-id="+k);c("apple-mobile-web-app-capable",h);c("apple-mobile-web-app-title",a.short_name||a.name);if(h=p("iOS"))try{var F=JSON.parse(h);m("portrait",F.p);m("landscape",F.l);z.forEach(function(a){var b=F.i[a.href];b&&(a.href=b)});return}catch(g){}var u={i:{}};q()}else k={por:"portrait",lan:"landscape"}[String(a.orientation||"").substr(0,3)]||"",c("x5-orientation",k),c("screen-orientation",k),"fullscreen"===v?(c("x5-fullscreen","true"),c("full-screen","yes")):h&&(c("x5-page-mode", -"app"),c("browsermode","application"))}function N(a){var b;(a||[]).filter(function(a){return"itunes"===a.platform}).forEach(function(a){a.id?b=a.id:(a=a.url.match(/id(\d+)/))&&(b=a[1])});return b}function L(a,b){if(A||O){var e=I(a);if(A)c("apple-mobile-web-app-status-bar-style",b?"black-translucent":e?"black":"default");else{a:{try{var m=Windows.UI.ViewManagement.ApplicationView.getForCurrentView().titleBar;break a}catch(P){}m=void 0}if(b=m)e=e?255:0,b.foregroundColor={r:e,g:e,b:e,a:255},a=v(a),b.backgroundColor= -{r:a[0],g:a[1],b:a[2],a:a[3]}}}}function v(a){var b=E();b.fillStyle=a;b.fillRect(0,0,1,1);return b.getImageData(0,0,1,1).data||[]}function I(a){a=v(a).map(function(a){a/=255;return.03928>a?a/12.92:Math.pow((a+.055)/1.055,2.4)});return 3\'';var b=Q([a,location]),d=v("manifest");if(d)try{var g=JSON.parse(d);G(g,b)}catch(r){console.warn("PWACompat error",r)}else{var n=new XMLHttpRequest;n.open("GET",a);n.withCredentials="use-credentials"===x.getAttribute("crossorigin"); +n.onload=function(){try{var r=JSON.parse(n.responseText);v("manifest",n.responseText);G(r,b)}catch(t){console.warn("PWACompat error",t)}};n.send(null)}}function Q(a){for(var b={},d=0;d.6*f)l.fillText(H,I/-2,0),l.translate(0,1.2*m),e.splice(0, +c),c=0}return function(){var J=l.canvas.toDataURL();g(h,J);return J}}function g(f,c){var h=document.createElement("link");h.setAttribute("rel","apple-touch-startup-image");h.setAttribute("media","(orientation: "+f+")");h.setAttribute("href",c);document.head.appendChild(h)}function n(f,c){var h=window.screen,m=d(h.width,h.height,"portrait",f),e=d(h.height,h.width,"landscape",f);setTimeout(function(){u.p=m();setTimeout(function(){u.l=e();c()},10)},10)}function r(f){function c(){--h||f()}var h=z.length+ +1;c();z.forEach(function(m){var e=new Image;e.crossOrigin="anonymous";e.onerror=c;e.onload=function(){e.onload=null;m.href=K(e,y,!0);u.i[e.src]=m.href;c()};e.src=m.href})}function t(){v("iOS",JSON.stringify(u))}function L(){var f=z.shift();if(f){var c=new Image;c.crossOrigin="anonymous";c.onerror=function(){return void L()};c.onload=function(){c.onload=null;n(c,function(){var h=a.background_color&&K(c,y);h?(f.href=h,u.i[c.src]=h,r(t)):t()})};c.src=f.href}else n(null,t)}var p=(a.icons||[]).map(R).sort(function(f, +c){return c.h-f.h}),q=p.filter(function(f){return-1largestSize(f)))return c.rel="apple-touch-icon",C("link",c,'[rel="apple-touch-icon"]'+h)}).filter(Boolean);p=B('meta[name="viewport"]');var T=!!(p&&p.content||"").match(/\bviewport-fit\s*=\s*cover\b/),M=a.display;p=-1!== +U.indexOf(M);k("mobile-web-app-capable",p);V(a.theme_color||"black",T);W&&(k("application-name",a.short_name),k("msapplication-tooltip",a.description),k("msapplication-starturl",b(a.start_url||".")),k("msapplication-navbutton-color",a.theme_color),(q=q[0])&&k("msapplication-TileImage",b(q.src)),k("msapplication-TileColor",a.background_color));k("theme-color",a.theme_color);if(A){var y=a.background_color||"#f8f9fa",S=N(y);(q=X(a.related_applications))&&k("apple-itunes-app","app-id="+q);k("apple-mobile-web-app-capable", +p);k("apple-mobile-web-app-title",a.short_name||a.name);if(q=v("iOS"))try{var E=JSON.parse(q);g("portrait",E.p);g("landscape",E.l);z.forEach(function(f){var c=E.i[f.href];c&&(f.href=c)});return}catch(f){}var u={i:{}};L()}else q={por:"portrait",lan:"landscape"}[String(a.orientation||"").substr(0,3)]||"",k("x5-orientation",q),k("screen-orientation",q),"fullscreen"===M?(k("x5-fullscreen","true"),k("full-screen","yes")):p&&(k("x5-page-mode","app"),k("browsermode","application"))}function X(a){var b;(a|| +[]).filter(function(d){return"itunes"===d.platform}).forEach(function(d){d.id?b=d.id:(d=d.url.match(/id(\d+)/))&&(b=d[1])});return b}function V(a,b){if(A||Y){var d=N(a);if(A)k("apple-mobile-web-app-status-bar-style",b?"black-translucent":d?"black":"default");else{a:{try{var g=Windows.UI.ViewManagement.ApplicationView.getForCurrentView().titleBar;break a}catch(n){}g=void 0}if(b=g)d=d?255:0,b.foregroundColor={r:d,g:d,b:d,a:255},a=O(a),b.backgroundColor={r:a[0],g:a[1],b:a[2],a:a[3]}}}}function O(a){var b= +D();b.fillStyle=a;b.fillRect(0,0,1,1);return b.getImageData(0,0,1,1).data||[]}function N(a){a=O(a).map(function(b){b/=255;return.03928>b?b/12.92:Math.pow((b+.055)/1.055,2.4)});return 3