1(function (root) { 2 'use strict'; 3 4 if (!('serviceWorker' in root.navigator)) { 5 return; 6 } 7 8 var layers = root.MKPwaUi && root.MKPwaUi.layers ? root.MKPwaUi.layers : null; 9 if (!layers) { 10 return; 11 } 12 13 var bootstrap = root.__PWA_UI_BOOTSTRAP__ || {}; 14 var logEnabled = /(?:\?|&)pwa_debug=1(?:&|$)/.test(root.location.search || ''); 15 var config = { 16 staleHomeUiEnabled: false, 17 swUrl: typeof bootstrap.swUrl === 'string' && bootstrap.swUrl ? bootstrap.swUrl : '/sw.js', 18 enableLogLayer: logEnabled, 19 domInstallButtonSelector: typeof bootstrap.domInstallButtonSelector === 'string' && bootstrap.domInstallButtonSelector 20 ? bootstrap.domInstallButtonSelector 21 : '[data-pwa-install-button]' 22 }; 23 var logger = { 24 enabled: logEnabled, 25 info: function () { 26 if (logEnabled && root.console && typeof root.console.info === 'function') { 27 root.console.info.apply(root.console, arguments); 28 } 29 }, 30 warn: function () { 31 if (root.console && typeof root.console.warn === 'function') { 32 root.console.warn.apply(root.console, arguments); 33 } 34 }, 35 log: function () { 36 if (logEnabled && root.console && typeof root.console.log === 'function') { 37 root.console.log.apply(root.console, arguments); 38 } 39 } 40 }; 41 42 logger.log('[PWA sw]', config.swUrl); 43 44 var context = { 45 config: config, 46 logger: logger, 47 install: null, 48 swBridge: null, 49 trackPwaEvent: function (name, payload) { 50 logger.info('[PWA]', name, payload || {}); 51 } 52 }; 53 54 context.install = layers.createInstallLayer(context); 55 context.swBridge = layers.createSwBridgeLayer(context); 56 context.swBridge.requestStaleHomeNotice(); 57 58 root.MKPageState = root.MKPageState || {}; 59 root.MKPageState.pwa = { 60 swUrl: config.swUrl, 61 logging: config.enableLogLayer 62 }; 63 64 root.addEventListener('load', function () { 65 context.swBridge.register(); 66 }); 67})(window);
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.