diff --git a/pwacompat.js b/pwacompat.js
index 2988204..9c89773 100644
--- a/pwacompat.js
+++ b/pwacompat.js
@@ -18,11 +18,7 @@
(function() {
if (!('fetch' in window)) {
- return;
- } else if (document.readyState === 'complete') {
- setup();
- } else {
- window.addEventListener('load', setup);
+ return; // basic feature detection: from Mobile Safari 10.3+
}
const capableDisplayModes = ['standalone', 'fullscreen', 'minimal-ui'];
@@ -44,7 +40,11 @@
if (!manifestHref) {
throw `can't find '`;
}
- return window.fetch(manifestHref);
+ const opts = /** @type {!RequestInit} */ ({});
+ if (manifestHref.crossOrigin === 'use-credentials') {
+ opts.credentials = 'include';
+ }
+ return window.fetch(manifestHref, opts);
})
.then((response) => response.json())
.then((data) => process(data, manifestHref))
@@ -252,4 +252,11 @@
canvas.height = height;
return canvas.getContext('2d');
}
+
+ // actually run PWACompat here
+ if (document.readyState === 'complete') {
+ setup();
+ } else {
+ window.addEventListener('load', setup);
+ }
}());
diff --git a/pwacompat.min.js b/pwacompat.min.js
index 7a2541d..4527a56 100644
--- a/pwacompat.min.js
+++ b/pwacompat.min.js
@@ -1,7 +1,7 @@
-(function(){function l(){var a=document.head.querySelector('link[rel="manifest"]'),b=a?a.href:"";Promise.resolve().then(function(){if(!b)throw'can\'t find \'';return window.fetch(b)}).then(function(a){return a.json()}).then(function(a){return n(a,b)}).catch(function(a){return console.warn("pwacompat.js error",a)})}function p(a,b){a=document.createElement(a);for(var c in b)a.setAttribute(c,b[c]);document.head.appendChild(a);return a}function h(a,b){b&&(!0===b&&(b="yes"),
-p("meta",{name:a,content:b}))}function n(a,b){function c(e,c,b){var d=e.width,g=e.height,f=window.devicePixelRatio;e=q({width:d*f,height:g*f});e.scale(f,f);e.fillStyle=a.background_color||"#f8f9fa";e.fillRect(0,0,d,g);e.translate(d/2,(g-32)/2);e.font="24px HelveticaNeue-CondensedBold";e.fillStyle=l?"white":"black";d=e.measureText(r).width;b&&(g=b.width/f,f=b.height/f,128a?a/12.92:Math.pow((a+.055)/1.055,2.4)});return 3\'';var a={};"use-credentials"===b.crossOrigin&&(a.credentials="include");return window.fetch(b,a)}).then(function(a){return a.json()}).then(function(a){return n(a,b)}).catch(function(a){return console.warn("pwacompat.js error",a)})}function p(a,b){a=document.createElement(a);for(var c in b)a.setAttribute(c,b[c]);
+document.head.appendChild(a);return a}function h(a,b){b&&(!0===b&&(b="yes"),p("meta",{name:a,content:b}))}function n(a,b){function c(e,c,b){var d=e.width,g=e.height,f=window.devicePixelRatio;e=q({width:d*f,height:g*f});e.scale(f,f);e.fillStyle=a.background_color||"#f8f9fa";e.fillRect(0,0,d,g);e.translate(d/2,(g-32)/2);e.font="24px HelveticaNeue-CondensedBold";e.fillStyle=l?"white":"black";d=e.measureText(r).width;b&&(g=b.width/f,f=b.height/f,128a?a/12.92:Math.pow((a+.055)/1.055,2.4)});return 3